specrails-desktop 2.29.0 → 2.29.1

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 (236) hide show
  1. package/client/dist/assets/{ActivityFeedPage-Be-6L0Ld.js → ActivityFeedPage-D8RKRRoM.js} +1 -1
  2. package/client/dist/assets/AgentBrowserCapture-BUHPHNSN.js +1 -0
  3. package/client/dist/assets/{AgentModeCodePane-DLltTOqp.js → AgentModeCodePane-GZc8bNGT.js} +2 -2
  4. package/client/dist/assets/AgentModeJobsPane-DWtQqj3k.js +1 -0
  5. package/client/dist/assets/AgentsPage-CKPtHkRP.js +86 -0
  6. package/client/dist/assets/{AnalyticsPage-C4Ik95FX.js → AnalyticsPage-CZW8c77k.js} +1 -1
  7. package/client/dist/assets/{BarChart-DVZgrhJd.js → BarChart-DugEoe2q.js} +2 -2
  8. package/client/dist/assets/CodePage-CQ-uKETG.js +2 -0
  9. package/client/dist/assets/{DesktopAnalyticsPage-2Xf-52x2.js → DesktopAnalyticsPage-Bgo4SyCH.js} +1 -1
  10. package/client/dist/assets/{DocsDialog-CHihLjWd.js → DocsDialog-DxpWw_La.js} +2 -2
  11. package/client/dist/assets/DocsPage-CmcOkK19.js +11 -0
  12. package/client/dist/assets/{ExportDropdown-DLHFQxVn.js → ExportDropdown-DvTS2wc7.js} +1 -1
  13. package/client/dist/assets/IntegrationsPage-B72WxJ3Z.js +1 -0
  14. package/client/dist/assets/InteractiveJobComposer-B5gh4Qoy.js +19 -0
  15. package/client/dist/assets/JobDetailModal-D-BeqsJ6.js +1 -0
  16. package/client/dist/assets/JobDetailPage-DwdozwLO.js +1 -0
  17. package/client/dist/assets/JobsPage-BDkinklt.js +1 -0
  18. package/client/dist/assets/{LoopBuilderPage-CpBaW59t.js → LoopBuilderPage-CclJ3VZA.js} +2 -2
  19. package/client/dist/assets/{LoopPreviewModal-CwpKcv0Y.js → LoopPreviewModal-Dw4UgoLu.js} +1 -1
  20. package/client/dist/assets/LoopsPage-D7ac4M24.js +1 -0
  21. package/client/dist/assets/PluginsPage-wdC-qa40.js +2 -0
  22. package/client/dist/assets/ProjectSettingsDialog-BlTlRtGI.js +1 -0
  23. package/client/dist/assets/TemplatePreviewModal-CeMx2Red.js +1 -0
  24. package/client/dist/assets/{brain-DecvjjPU.js → brain-C92rjjYP.js} +1 -1
  25. package/client/dist/assets/{dist-js-UjXbEWhN.js → dist-js-CgpP6tKI.js} +1 -1
  26. package/client/dist/assets/{dist-js-BTAcxhPb.js → dist-js-DHiN-A_E.js} +1 -1
  27. package/client/dist/assets/{index-OBDI7bHm.js → index-DyY1QyIn.js} +10 -10
  28. package/client/dist/assets/{lib-C5ZxrPSR.js → lib-0PFDyMxJ.js} +1 -1
  29. package/client/dist/assets/{settings-Bp24JHlv2.js → settings-1w1O5Og82.js} +1 -1
  30. package/client/dist/assets/{settings-C_T0-j9d.js → settings-BSihkr0e.js} +1 -1
  31. package/client/dist/assets/{settings-DhaFKpcw2.js → settings-BiDOB3hV2.js} +1 -1
  32. package/client/dist/assets/{settings-BemR_e3F.js → settings-BoubJhDP2.js} +1 -1
  33. package/client/dist/assets/{settings-BvIwQ3A1.js → settings-CB-EZ_W8.js} +1 -1
  34. package/client/dist/assets/{settings-B_v3zgJf.js → settings-DNL68KTE.js} +1 -1
  35. package/client/dist/assets/{settings-Bx2ObkTR2.js → settings-Jc46vUhd.js} +1 -1
  36. package/client/dist/assets/{settings-BYCMtxOz.js → settings-cJNynGIZ.js} +1 -1
  37. package/client/dist/assets/{upload-lgjKJgrl.js → upload-CmR4h9H1.js} +1 -1
  38. package/client/dist/assets/{value-Bc0_jlJA.js → value-JA3bf47v.js} +1 -1
  39. package/client/dist/index.html +2 -2
  40. package/package.json +1 -1
  41. package/server/dist/rail-isolated-launch.js +23 -9
  42. package/server/dist/rail-pr-decision.js +18 -6
  43. package/server/dist/rail-worktree-release.js +12 -6
  44. package/server/dist/rails-router.js +8 -1
  45. package/server/dist/worktree-manager.js +64 -16
  46. package/client/dist/assets/AgentBrowserCapture-CpZ-dd8O.js +0 -1
  47. package/client/dist/assets/AgentIntegrationsModal-DO1pN_Ez.js +0 -1
  48. package/client/dist/assets/AgentModeJobsPane-Dp5YvmW0.js +0 -1
  49. package/client/dist/assets/AgentsPage-ehHuVUds.js +0 -86
  50. package/client/dist/assets/CodePage-D4OCMfxL.js +0 -2
  51. package/client/dist/assets/DocsPage-1vEk7XbH.js +0 -11
  52. package/client/dist/assets/IntegrationsPage-CCb2YuyJ.js +0 -1
  53. package/client/dist/assets/InteractiveJobComposer-CxJJEnjw.js +0 -19
  54. package/client/dist/assets/JobDetailModal-CJI7qRkm.js +0 -1
  55. package/client/dist/assets/JobDetailPage-DwA9bbwx.js +0 -1
  56. package/client/dist/assets/JobsPage-BDIyFfd5.js +0 -1
  57. package/client/dist/assets/LoopsPage-BO0Pa8oz.js +0 -1
  58. package/client/dist/assets/PluginsPage-BBGTBpGh.js +0 -2
  59. package/client/dist/assets/ProjectSettingsDialog-M9zGQo0l.js +0 -1
  60. package/client/dist/assets/TemplatePreviewModal-eBI0zL5P.js +0 -1
  61. /package/client/dist/assets/{activity-BbWiDfn-2.js → activity--iN4Ad2R2.js} +0 -0
  62. /package/client/dist/assets/{activity-DvECTYGt.js → activity-6hM_ZSg9.js} +0 -0
  63. /package/client/dist/assets/{activity-BZZlEG3a.js → activity-BZNfOdiS.js} +0 -0
  64. /package/client/dist/assets/{activity-DtzRy92x.js → activity-BuVo5sPB.js} +0 -0
  65. /package/client/dist/assets/{activity-D3Ic-HTS.js → activity-CIOLxGvh.js} +0 -0
  66. /package/client/dist/assets/{activity-FleOlK0l2.js → activity-D2r2h3SE2.js} +0 -0
  67. /package/client/dist/assets/{activity-DFbvNqhE2.js → activity-DtxrAUMo2.js} +0 -0
  68. /package/client/dist/assets/{addspec-CFxGvmJR2.js → addspec-BMtLZLW62.js} +0 -0
  69. /package/client/dist/assets/{addspec-DaA-CbTt.js → addspec-CP0HRuxY.js} +0 -0
  70. /package/client/dist/assets/{addspec-NBbcTbLc.js → addspec-CRuvWn8d.js} +0 -0
  71. /package/client/dist/assets/{addspec-BKrH2Ucz.js → addspec-D-JLDsUV.js} +0 -0
  72. /package/client/dist/assets/{addspec-B_LQMHW3.js → addspec-DfhDbg5c.js} +0 -0
  73. /package/client/dist/assets/{addspec-Bw_YQwo62.js → addspec-bsNDdqRm2.js} +0 -0
  74. /package/client/dist/assets/{addspec-CR8MB5Fr2.js → addspec-mgPOt5q02.js} +0 -0
  75. /package/client/dist/assets/{agent-BoXSzaBk2.js → agent-B8BXmlUQ2.js} +0 -0
  76. /package/client/dist/assets/{agent-CeRTdGT12.js → agent-BYc3-6Ln2.js} +0 -0
  77. /package/client/dist/assets/{agent-fQI_6tsA.js → agent-BbJorPdT.js} +0 -0
  78. /package/client/dist/assets/{agent-DZ8zTrQT.js → agent-CewFImgL.js} +0 -0
  79. /package/client/dist/assets/{agent-tJdAobaM.js → agent-DfhYoUmp.js} +0 -0
  80. /package/client/dist/assets/{agent-DqyzT33X.js → agent-TK_rrK4d.js} +0 -0
  81. /package/client/dist/assets/{agent-C2-rROL52.js → agent-bHjA9R_j2.js} +0 -0
  82. /package/client/dist/assets/{agents-BHgn--3j.js → agents-78bTZGZh.js} +0 -0
  83. /package/client/dist/assets/{agents-CV-_xBvX2.js → agents-BLhWCmDS2.js} +0 -0
  84. /package/client/dist/assets/{agents-B_qGaB0F.js → agents-BUdEi3-N.js} +0 -0
  85. /package/client/dist/assets/{agents-B9pFSJQI2.js → agents-BpoUaoW92.js} +0 -0
  86. /package/client/dist/assets/{agents-HFCqQH0Z.js → agents-CWo-KyAB.js} +0 -0
  87. /package/client/dist/assets/{agents-VsyFhGOS2.js → agents-DDtCJ5M02.js} +0 -0
  88. /package/client/dist/assets/{agents-CP8_ezYG.js → agents-bvyRLczL.js} +0 -0
  89. /package/client/dist/assets/{agentstudio-BEp7Sb46.js → agentstudio-BMQxc_bz.js} +0 -0
  90. /package/client/dist/assets/{agentstudio-RfZavULt2.js → agentstudio-COZriimI2.js} +0 -0
  91. /package/client/dist/assets/{agentstudio-D2A5peWV2.js → agentstudio-CWgXG5W52.js} +0 -0
  92. /package/client/dist/assets/{agentstudio-Br3WD7Xs.js → agentstudio-C_Jq8Tl4.js} +0 -0
  93. /package/client/dist/assets/{agentstudio-BOjG6tgJ.js → agentstudio-Dtq3dGYk.js} +0 -0
  94. /package/client/dist/assets/{agentstudio-RsxnZtUA.js → agentstudio-jKMTdT70.js} +0 -0
  95. /package/client/dist/assets/{agentstudio-CuTt3ZGe2.js → agentstudio-sI27TpBu2.js} +0 -0
  96. /package/client/dist/assets/{aiedit-CV520D4W2.js → aiedit-6CHdb_iv2.js} +0 -0
  97. /package/client/dist/assets/{aiedit-DrIjSojo.js → aiedit-B03pD_Na.js} +0 -0
  98. /package/client/dist/assets/{aiedit-a-Z-g5iC.js → aiedit-BtRqRxML.js} +0 -0
  99. /package/client/dist/assets/{aiedit-D0Syl-mC.js → aiedit-eMN4eQPF.js} +0 -0
  100. /package/client/dist/assets/{aiedit-DnBzjlVz2.js → aiedit-hknZlly82.js} +0 -0
  101. /package/client/dist/assets/{aiedit-26p5A_HY2.js → aiedit-igmw-ZoZ2.js} +0 -0
  102. /package/client/dist/assets/{aiedit-CcugGPbS.js → aiedit-pc5JDUq1.js} +0 -0
  103. /package/client/dist/assets/{analytics-Bpe41fnX2.js → analytics-BWMUZ2Pq2.js} +0 -0
  104. /package/client/dist/assets/{analytics-CpSTNfui.js → analytics-Bj-SmKHa.js} +0 -0
  105. /package/client/dist/assets/{analytics-4-eskbtX.js → analytics-C5dpiS0o.js} +0 -0
  106. /package/client/dist/assets/{analytics-DEe5BMz8.js → analytics-CCprAqk3.js} +0 -0
  107. /package/client/dist/assets/{analytics-4HvXb0Vn2.js → analytics-CR1TJqUi2.js} +0 -0
  108. /package/client/dist/assets/{analytics-DcOITHla2.js → analytics-DfNdXR0y2.js} +0 -0
  109. /package/client/dist/assets/{analytics-Bd9rHGjV.js → analytics-rmHuJv0V.js} +0 -0
  110. /package/client/dist/assets/{attachments-CgOQ9K-6.js → attachments-BgBNSqQd.js} +0 -0
  111. /package/client/dist/assets/{attachments-CA2f3qL3.js → attachments-BjyMmrwE.js} +0 -0
  112. /package/client/dist/assets/{attachments-DlEQu56g2.js → attachments-C9GTTJsx2.js} +0 -0
  113. /package/client/dist/assets/{attachments-CHDbhKeH.js → attachments-DCZOL1RU.js} +0 -0
  114. /package/client/dist/assets/{attachments-jVdKzAXn.js → attachments-DL-bPy9E.js} +0 -0
  115. /package/client/dist/assets/{attachments-D2jwJXQ42.js → attachments-DPCmkFZu2.js} +0 -0
  116. /package/client/dist/assets/{attachments-CKAY5aYG2.js → attachments-rNn1ekRy2.js} +0 -0
  117. /package/client/dist/assets/{browser-Cl-FwPXs.js → browser-BPkhILSJ.js} +0 -0
  118. /package/client/dist/assets/{browser-kA31eYhu2.js → browser-BijVYG0Y2.js} +0 -0
  119. /package/client/dist/assets/{browser-JsiohNmW.js → browser-BqLqJVVT.js} +0 -0
  120. /package/client/dist/assets/{browser-C4VJ5CW12.js → browser-Cc0iDqUi.js} +0 -0
  121. /package/client/dist/assets/{browser-BQFDxrRq.js → browser-Cvg-QHvd2.js} +0 -0
  122. /package/client/dist/assets/{browser-Do2jf8_N.js → browser-FRv8P02E.js} +0 -0
  123. /package/client/dist/assets/{browser-BbJ_q_OT2.js → browser-rWKj-RR_2.js} +0 -0
  124. /package/client/dist/assets/{chat-SaG-ng1x2.js → chat-BgL3zv6x2.js} +0 -0
  125. /package/client/dist/assets/{chat-n43nZGvn.js → chat-Bh3NdgJs.js} +0 -0
  126. /package/client/dist/assets/{chat-BalviUAD.js → chat-Bom6bqK3.js} +0 -0
  127. /package/client/dist/assets/{chat-BMWD_Rx12.js → chat-DdwZjT8K2.js} +0 -0
  128. /package/client/dist/assets/{chat-D5xEtsf3.js → chat-Dnwg-NpQ.js} +0 -0
  129. /package/client/dist/assets/{chat-CJddjN3D2.js → chat-DsbwJhus.js} +0 -0
  130. /package/client/dist/assets/{chat-Ds8GvCnv.js → chat-vylxqR0P2.js} +0 -0
  131. /package/client/dist/assets/{code-BotxM43N2.js → code-BRcDlze52.js} +0 -0
  132. /package/client/dist/assets/{code-CIPmDEd0.js → code-BdMy3Ffq.js} +0 -0
  133. /package/client/dist/assets/{code-HDK4P6Rx.js → code-CeQ0FZpC.js} +0 -0
  134. /package/client/dist/assets/{code-F_KjccGf.js → code-CwnBPPyA.js} +0 -0
  135. /package/client/dist/assets/{code-DUe1Bouz.js → code-DgeHz9CB.js} +0 -0
  136. /package/client/dist/assets/{code-Bit_z2Xd2.js → code-DzC1rMk12.js} +0 -0
  137. /package/client/dist/assets/{code-C9U6M5-e2.js → code-UPVvmAKM2.js} +0 -0
  138. /package/client/dist/assets/{commands-CzFSoIiq2.js → commands-C4Y3C-PF2.js} +0 -0
  139. /package/client/dist/assets/{commands-BllkJauO.js → commands-CSDs9q_2.js} +0 -0
  140. /package/client/dist/assets/{commands-BFQZc9AG.js → commands-DkU0qliq.js} +0 -0
  141. /package/client/dist/assets/{commands-KBbhsnw8.js → commands-JWMfGDmr.js} +0 -0
  142. /package/client/dist/assets/{commands-cKTaLwwV2.js → commands-RHOchN4n2.js} +0 -0
  143. /package/client/dist/assets/{commands-BMkC5-ki.js → commands-u-4eEHCN.js} +0 -0
  144. /package/client/dist/assets/{commands-CWX9WmDX2.js → commands-xHDDGfcP2.js} +0 -0
  145. /package/client/dist/assets/{common-DZbXlmq72.js → common-BM3LFLCE2.js} +0 -0
  146. /package/client/dist/assets/{common-Cfmwcrl52.js → common-Bwafujnc2.js} +0 -0
  147. /package/client/dist/assets/{common-D2cimsul.js → common-C-vU-j-I.js} +0 -0
  148. /package/client/dist/assets/{common-DH7fjyL1.js → common-C5HKSbbz.js} +0 -0
  149. /package/client/dist/assets/{common-CF8iGXrG.js → common-DhWTkocg.js} +0 -0
  150. /package/client/dist/assets/{common-DtXmzX2o2.js → common-DiPTT7V_2.js} +0 -0
  151. /package/client/dist/assets/{common-BfQD173j.js → common-DmqBPwZG.js} +0 -0
  152. /package/client/dist/assets/{dashboard-CiOyDh9L.js → dashboard-B5ang-ZS.js} +0 -0
  153. /package/client/dist/assets/{dashboard-BFfnCtq52.js → dashboard-CHHcOWVL2.js} +0 -0
  154. /package/client/dist/assets/{dashboard-BIC8KtRf2.js → dashboard-DBD4wPGY2.js} +0 -0
  155. /package/client/dist/assets/{dashboard-5C2FOZQX.js → dashboard-DSnztwWH.js} +0 -0
  156. /package/client/dist/assets/{dashboard-CEgg9NAr.js → dashboard-D_aP_InU.js} +0 -0
  157. /package/client/dist/assets/{dashboard-B6iQ-IL_.js → dashboard-DmBcdl1B.js} +0 -0
  158. /package/client/dist/assets/{dashboard-D6x5OnNj2.js → dashboard-RIcUKY1Y2.js} +0 -0
  159. /package/client/dist/assets/{explore-CAc8Qzu32.js → explore-B7fblXBb2.js} +0 -0
  160. /package/client/dist/assets/{explore-ELbrSZyQ2.js → explore-BHtEpoNN2.js} +0 -0
  161. /package/client/dist/assets/{explore-Bhy7WWXv.js → explore-C0k8HrkN.js} +0 -0
  162. /package/client/dist/assets/{explore-BO_OinBD.js → explore-CNBzrEPS.js} +0 -0
  163. /package/client/dist/assets/{explore-DCZL9gRN2.js → explore-D_mWBYCS2.js} +0 -0
  164. /package/client/dist/assets/{explore-DW_YTkQh.js → explore-Dahc1lOx.js} +0 -0
  165. /package/client/dist/assets/{explore-BEpIs343.js → explore-UvW1jEMa.js} +0 -0
  166. /package/client/dist/assets/{format-command-Db1viey1.js → format-command-CuWuRvka.js} +0 -0
  167. /package/client/dist/assets/{integrations-CWjh5VRk.js → integrations-2YcNyAl3.js} +0 -0
  168. /package/client/dist/assets/{integrations-RJfzXkPx2.js → integrations-BXCvXUlG2.js} +0 -0
  169. /package/client/dist/assets/{integrations-CUNe3t9l2.js → integrations-C1ThkTC52.js} +0 -0
  170. /package/client/dist/assets/{integrations-CAjq5tdW2.js → integrations-Crk2rFhL2.js} +0 -0
  171. /package/client/dist/assets/{integrations-CP_aiV_8.js → integrations-D9YrJ_Ep.js} +0 -0
  172. /package/client/dist/assets/{integrations-JOHSCvB3.js → integrations-Dn4JiGtW.js} +0 -0
  173. /package/client/dist/assets/{integrations-CG2dp3Kd.js → integrations-TAcYNh0b.js} +0 -0
  174. /package/client/dist/assets/{jira-C5UjxHE4.js → jira-BHAKtc4B.js} +0 -0
  175. /package/client/dist/assets/{jira-ZdKb-50F2.js → jira-Be369RIR2.js} +0 -0
  176. /package/client/dist/assets/{jira-DTYu3hJi2.js → jira-CPpgA-5z2.js} +0 -0
  177. /package/client/dist/assets/{jira-CQ7mrZde.js → jira-D5efgwp_.js} +0 -0
  178. /package/client/dist/assets/{jira-DtZpokjJ.js → jira-DS7ownDy.js} +0 -0
  179. /package/client/dist/assets/{jira-DIRkZk9U.js → jira-bDs7Im2C.js} +0 -0
  180. /package/client/dist/assets/{jira-B5wszJ1-2.js → jira-uNH1gETL2.js} +0 -0
  181. /package/client/dist/assets/{jobs-DAGiPVIS2.js → jobs-1GV2-4zd2.js} +0 -0
  182. /package/client/dist/assets/{jobs-DAU8C_tZ.js → jobs-26F9gGcE.js} +0 -0
  183. /package/client/dist/assets/{jobs-BJ-Gcao22.js → jobs-BgQzB0Sx2.js} +0 -0
  184. /package/client/dist/assets/{jobs-Da0GaaSc.js → jobs-BqWui9_f.js} +0 -0
  185. /package/client/dist/assets/{jobs-BFIdeDTw.js → jobs-CE8qeIYj.js} +0 -0
  186. /package/client/dist/assets/{jobs-p360zdf1.js → jobs-DzeuASRf.js} +0 -0
  187. /package/client/dist/assets/{jobs-P3unxtxo2.js → jobs-Wh7dn28q2.js} +0 -0
  188. /package/client/dist/assets/{loops-BjK8lmoZ2.js → loops-BvqQ-bHR2.js} +0 -0
  189. /package/client/dist/assets/{loops-Bi4ywYGn.js → loops-CvOWsi5r.js} +0 -0
  190. /package/client/dist/assets/{loops-DDs4KPu_.js → loops-D6D3XHjj.js} +0 -0
  191. /package/client/dist/assets/{loops-Du-bNVpc2.js → loops-DJNhp17p2.js} +0 -0
  192. /package/client/dist/assets/{loops-D3wdUkZV.js → loops-K5_HXfJa.js} +0 -0
  193. /package/client/dist/assets/{loops-DKzYFcq6.js → loops-LIgO_-eM.js} +0 -0
  194. /package/client/dist/assets/{loops-DvGbSfxw2.js → loops-vhJdbcz92.js} +0 -0
  195. /package/client/dist/assets/{mcp-DyULurYS2.js → mcp-CjVKXAhD2.js} +0 -0
  196. /package/client/dist/assets/{mcp-DfmzoT5t.js → mcp-Dcl-XxkR.js} +0 -0
  197. /package/client/dist/assets/{mcp-CbJ04oFS2.js → mcp-DtbxuH3V2.js} +0 -0
  198. /package/client/dist/assets/{mcp-Dd844F5_.js → mcp-H-gnQUdN.js} +0 -0
  199. /package/client/dist/assets/{mcp-zSJ2TsJj.js → mcp-N1nzp8oL.js} +0 -0
  200. /package/client/dist/assets/{mcp-BG-OCJca2.js → mcp-XJNRfxVp2.js} +0 -0
  201. /package/client/dist/assets/{mcp-CrWdq5db.js → mcp-sRmWE8WJ.js} +0 -0
  202. /package/client/dist/assets/{nav-DUuw9VIU2.js → nav-BElxljIF2.js} +0 -0
  203. /package/client/dist/assets/{nav-BY_4EWRv.js → nav-BXO7PJJG2.js} +0 -0
  204. /package/client/dist/assets/{nav-BAMkVEId.js → nav-C8kOuGh8.js} +0 -0
  205. /package/client/dist/assets/{nav-D0Erv9ZJ2.js → nav-COu2E_-L.js} +0 -0
  206. /package/client/dist/assets/{nav-CVXtv0wX2.js → nav-CW9pxWfC2.js} +0 -0
  207. /package/client/dist/assets/{nav-B2_ToNqS.js → nav-CXHUA4uf.js} +0 -0
  208. /package/client/dist/assets/{nav-S4HM94vW.js → nav-DdHF5VWJ.js} +0 -0
  209. /package/client/dist/assets/{setup-q0wRHUp1.js → setup-7J8TjG4O.js} +0 -0
  210. /package/client/dist/assets/{setup-DQWsu2TR.js → setup-BXpw07r-.js} +0 -0
  211. /package/client/dist/assets/{setup-mXnzww4f.js → setup-BiduSX9d.js} +0 -0
  212. /package/client/dist/assets/{setup-1vN48B-m2.js → setup-BuQNKztt2.js} +0 -0
  213. /package/client/dist/assets/{setup-BmJ0Kx16.js → setup-BwMovM9z2.js} +0 -0
  214. /package/client/dist/assets/{setup-JeBwoXoM.js → setup-D84y3wx-.js} +0 -0
  215. /package/client/dist/assets/{setup-T_ApeQDV2.js → setup-DU0ULX8q2.js} +0 -0
  216. /package/client/dist/assets/{specs-Ce5y2iFc2.js → specs-C9Sd7BhH2.js} +0 -0
  217. /package/client/dist/assets/{specs-C6J2zrLM.js → specs-CBDvEYKv.js} +0 -0
  218. /package/client/dist/assets/{specs-DZDoZsDq.js → specs-CIPr9reA2.js} +0 -0
  219. /package/client/dist/assets/{specs-BGRKhM8t.js → specs-CWtKcVDC.js} +0 -0
  220. /package/client/dist/assets/{specs-CT8exGOy2.js → specs-D2clrt2c2.js} +0 -0
  221. /package/client/dist/assets/{specs-GkiL-snY.js → specs-DTplt2XM.js} +0 -0
  222. /package/client/dist/assets/{specs-DbtIzV8a.js → specs-PozUNhqb.js} +0 -0
  223. /package/client/dist/assets/{terminal-Cvabyzm42.js → terminal-BRm03iFA2.js} +0 -0
  224. /package/client/dist/assets/{terminal-BTpE7iki.js → terminal-De2Brd23.js} +0 -0
  225. /package/client/dist/assets/{terminal-D0z12_sJ2.js → terminal-DxQWCqSD2.js} +0 -0
  226. /package/client/dist/assets/{terminal-a6Uq8B0p.js → terminal-WSAvHXoU.js} +0 -0
  227. /package/client/dist/assets/{terminal-DDk_bTw0.js → terminal-Z7KsDM_n.js} +0 -0
  228. /package/client/dist/assets/{terminal-DEyt0prF.js → terminal-cqfd3EDV.js} +0 -0
  229. /package/client/dist/assets/{terminal-BNSg2lR7.js → terminal-xGbCZJHg.js} +0 -0
  230. /package/client/dist/assets/{tickets-sVun0I6v.js → tickets-B7zT4IRf.js} +0 -0
  231. /package/client/dist/assets/{tickets-DZut8Ryt.js → tickets-BoXom7l8.js} +0 -0
  232. /package/client/dist/assets/{tickets-BIxU86j12.js → tickets-C3b8cHhd2.js} +0 -0
  233. /package/client/dist/assets/{tickets-dQfsc7Ph.js → tickets-CFXnJsYF.js} +0 -0
  234. /package/client/dist/assets/{tickets-LfK6LzKl2.js → tickets-CWYFvx1W2.js} +0 -0
  235. /package/client/dist/assets/{tickets-D1IeX2EW.js → tickets-DTHo9c3C.js} +0 -0
  236. /package/client/dist/assets/{tickets-C2BhwzwR.js → tickets-SuX_HkK4.js} +0 -0
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/activity-Dbl71S-E.js","assets/chunk-BNv3lrIs.js","assets/addspec-DrXqP8ip.js","assets/agent-BEXYxDbs.js","assets/agents-CGDn_3kB.js","assets/agentstudio-Dxe_94PK.js","assets/aiedit-DrfHQnlz.js","assets/analytics-CxDYcBl9.js","assets/attachments-DvxQbBTC.js","assets/browser-DM8G151q.js","assets/chat-0dg5hOo_.js","assets/code-B62fClk-.js","assets/commands-DCJ-R9E4.js","assets/common-DXrmj6WD.js","assets/dashboard-DBuLfWo9.js","assets/explore-_XyU5e7R.js","assets/integrations-By80EBkf.js","assets/jira-DeIjwCK3.js","assets/jobs-DrYmsKy5.js","assets/loops-CO6q75W8.js","assets/mcp-HwBbQDk0.js","assets/nav-BTg8s-cD.js","assets/settings-BYCMtxOz.js","assets/setup-D2CmgAro.js","assets/specs-PGIOzMtc.js","assets/terminal-CFt56A5f.js","assets/tickets-BHv3ewvq.js","assets/JobDetailModal-CJI7qRkm.js","assets/InteractiveJobComposer-CxJJEnjw.js","assets/lib-C5ZxrPSR.js","assets/brain-DecvjjPU.js","assets/auth-DpZq5p1e.js","assets/LoopPreviewModal-CwpKcv0Y.js","assets/TemplatePreviewModal-eBI0zL5P.js","assets/ProjectSettingsDialog-M9zGQo0l.js","assets/addon-image-CwoZj17F.js","assets/addon-ligatures-CWDrED80.js","assets/addon-webgl-DMbGeI_u.js","assets/AgentModeCodePane-DLltTOqp.js","assets/preload-helper-DSXbuxSR.js","assets/AgentModeJobsPane-Dp5YvmW0.js","assets/format-command-Db1viey1.js","assets/AgentBrowserCapture-CpZ-dd8O.js","assets/AgentIntegrationsModal-DO1pN_Ez.js","assets/PluginsPage-BBGTBpGh.js","assets/JobDetailPage-DwA9bbwx.js","assets/JobsPage-BDIyFfd5.js","assets/ExportDropdown-DLHFQxVn.js","assets/AnalyticsPage-C4Ik95FX.js","assets/BarChart-DVZgrhJd.js","assets/clsx-CNmW0Nip.js","assets/value-Bc0_jlJA.js","assets/ActivityFeedPage-Be-6L0Ld.js","assets/AgentsPage-ehHuVUds.js","assets/CodePage-D4OCMfxL.js","assets/DesktopAnalyticsPage-2Xf-52x2.js","assets/DocsPage-1vEk7XbH.js","assets/atom-one-dark-BMDPFwRZ.js","assets/atom-one-dark-B-oHczHB.css","assets/DocsDialog-CHihLjWd.js","assets/LoopsPage-BO0Pa8oz.js","assets/upload-lgjKJgrl.js","assets/LoopBuilderPage-CpBaW59t.js","assets/LoopBuilderPage-DtxX27Jz.css"])))=>i.map(i=>d[i]);
2
- import{a as e,i as t,n,r,t as i}from"./chunk-BNv3lrIs.js";import{t as a}from"./preload-helper-DSXbuxSR.js";import{a as o,i as s,n as c,r as l,t as u}from"./auth-DpZq5p1e.js";import{t as d}from"./activity-Dbl71S-E.js";import{t as f}from"./addspec-DrXqP8ip.js";import{t as p}from"./agent-BEXYxDbs.js";import{t as m}from"./agents-CGDn_3kB.js";import{t as h}from"./agentstudio-Dxe_94PK.js";import{t as g}from"./aiedit-DrfHQnlz.js";import{t as _}from"./analytics-CxDYcBl9.js";import{t as v}from"./attachments-DvxQbBTC.js";import{t as y}from"./browser-DM8G151q.js";import{t as b}from"./chat-0dg5hOo_.js";import{t as x}from"./code-B62fClk-.js";import{t as S}from"./commands-DCJ-R9E4.js";import{t as C}from"./common-DXrmj6WD.js";import{t as w}from"./dashboard-DBuLfWo9.js";import{t as T}from"./explore-_XyU5e7R.js";import{t as E}from"./integrations-By80EBkf.js";import{t as D}from"./jira-DeIjwCK3.js";import{t as O}from"./jobs-DrYmsKy5.js";import{t as k}from"./loops-CO6q75W8.js";import{t as A}from"./mcp-HwBbQDk0.js";import{t as j}from"./nav-BTg8s-cD.js";import{t as M}from"./settings-BYCMtxOz.js";import{t as N}from"./setup-D2CmgAro.js";import{t as P}from"./specs-PGIOzMtc.js";import{t as F}from"./terminal-CFt56A5f.js";import{t as I}from"./tickets-BHv3ewvq.js";import{t as L}from"./clsx-CNmW0Nip.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var R=i((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.iterator;function m(e){return typeof e!=`object`||!e?null:(e=p&&e[p]||e[`@@iterator`],typeof e==`function`?e:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,_={};function v(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}v.prototype.isReactComponent={},v.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},v.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function y(){}y.prototype=v.prototype;function b(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}var x=b.prototype=new y;x.constructor=b,g(x,v.prototype),x.isPureReactComponent=!0;var S=Array.isArray;function C(){}var w={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function E(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function D(e,t){return E(e.type,t,e.props)}function O(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function k(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var A=/\/+/g;function j(e,t){return typeof e==`object`&&e&&e.key!=null?k(``+e.key):t.toString(36)}function M(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(C,C):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function N(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,N(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+j(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(A,`$&/`)+`/`),N(o,r,i,``,function(e){return e})):o!=null&&(O(o)&&(o=D(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(A,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(S(e))for(var u=0;u<e.length;u++)a=e[u],s=l+j(a,u),c+=N(a,r,i,s,o);else if(u=m(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+j(a,u++),c+=N(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return N(M(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function P(e,t,n){if(e==null)return e;var r=[],i=0;return N(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function F(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t)},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var I=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},L={map:P,forEach:function(e,t,n){P(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return P(e,function(){t++}),t},toArray:function(e){return P(e,function(e){return e})||[]},only:function(e){if(!O(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=L,e.Component=v,e.Fragment=r,e.Profiler=a,e.PureComponent=b,e.StrictMode=i,e.Suspense=l,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=w,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return w.H.useMemoCache(e)}},e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=g({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!T.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return E(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)T.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return E(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=O,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:F}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=function(e){var t=w.T,n={};w.T=n;try{var r=e(),i=w.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(C,I)}catch(e){I(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),w.T=t}},e.unstable_useCacheRefresh=function(){return w.H.useCacheRefresh()},e.use=function(e){return w.H.use(e)},e.useActionState=function(e,t,n){return w.H.useActionState(e,t,n)},e.useCallback=function(e,t){return w.H.useCallback(e,t)},e.useContext=function(e){return w.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return w.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return w.H.useEffect(e,t)},e.useEffectEvent=function(e){return w.H.useEffectEvent(e)},e.useId=function(){return w.H.useId()},e.useImperativeHandle=function(e,t,n){return w.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return w.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return w.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return w.H.useMemo(e,t)},e.useOptimistic=function(e,t){return w.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return w.H.useReducer(e,t,n)},e.useRef=function(e){return w.H.useRef(e)},e.useState=function(e){return w.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return w.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return w.H.useTransition()},e.version=`19.2.4`})),z=i(((e,t)=>{t.exports=R()})),ee=i((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),te=i(((e,t)=>{t.exports=ee()})),B=i((e=>{var t=z();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`);function o(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var s=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function c(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return o(e,t,null,r)},e.flushSync=function(e){var t=s.T,n=i.p;try{if(s.T=null,i.p=2,e)return e()}finally{s.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`)if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=c(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t??i.d.M(e)},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`)if(t){var n=c(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else i.d.m(e)},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return s.H.useFormState(e,t,n)},e.useFormStatus=function(){return s.H.useHostTransitionStatus()},e.version=`19.2.4`})),ne=i(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=B()})),V=i((e=>{var t=te(),n=z(),r=ne();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}var f=Object.assign,p=Symbol.for(`react.element`),m=Symbol.for(`react.transitional.element`),h=Symbol.for(`react.portal`),g=Symbol.for(`react.fragment`),_=Symbol.for(`react.strict_mode`),v=Symbol.for(`react.profiler`),y=Symbol.for(`react.consumer`),b=Symbol.for(`react.context`),x=Symbol.for(`react.forward_ref`),S=Symbol.for(`react.suspense`),C=Symbol.for(`react.suspense_list`),w=Symbol.for(`react.memo`),T=Symbol.for(`react.lazy`),E=Symbol.for(`react.activity`),D=Symbol.for(`react.memo_cache_sentinel`),O=Symbol.iterator;function k(e){return typeof e!=`object`||!e?null:(e=O&&e[O]||e[`@@iterator`],typeof e==`function`?e:null)}var A=Symbol.for(`react.client.reference`);function j(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===A?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case g:return`Fragment`;case v:return`Profiler`;case _:return`StrictMode`;case S:return`Suspense`;case C:return`SuspenseList`;case E:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case h:return`Portal`;case b:return e.displayName||`Context`;case y:return(e._context.displayName||`Context`)+`.Consumer`;case x:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case w:return t=e.displayName||null,t===null?j(e.type)||`Memo`:t;case T:t=e._payload,e=e._init;try{return j(e(t))}catch{}}return null}var M=Array.isArray,N=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,P=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F={pending:!1,data:null,method:null,action:null},I=[],L=-1;function R(e){return{current:e}}function ee(e){0>L||(e.current=I[L],I[L]=null,L--)}function B(e,t){L++,I[L]=e.current,e.current=t}var V=R(null),re=R(null),H=R(null),U=R(null);function ie(e,t){switch(B(H,t),B(re,e),B(V,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Kd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Kd(t),e=qd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}ee(V),B(V,e)}function ae(){ee(V),ee(re),ee(H)}function W(e){e.memoizedState!==null&&B(U,e);var t=V.current,n=qd(t,e.type);t!==n&&(B(re,e),B(V,n))}function oe(e){re.current===e&&(ee(V),ee(re)),U.current===e&&(ee(U),np._currentValue=F)}var se,ce;function le(e){if(se===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);se=t&&t[1]||``,ce=-1<e.stack.indexOf(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/activity-Dbl71S-E.js","assets/chunk-BNv3lrIs.js","assets/addspec-DrXqP8ip.js","assets/agent-BEXYxDbs.js","assets/agents-CGDn_3kB.js","assets/agentstudio-Dxe_94PK.js","assets/aiedit-DrfHQnlz.js","assets/analytics-CxDYcBl9.js","assets/attachments-DvxQbBTC.js","assets/browser-DM8G151q.js","assets/chat-0dg5hOo_.js","assets/code-B62fClk-.js","assets/commands-DCJ-R9E4.js","assets/common-DXrmj6WD.js","assets/dashboard-DBuLfWo9.js","assets/explore-_XyU5e7R.js","assets/integrations-By80EBkf.js","assets/jira-DeIjwCK3.js","assets/jobs-DrYmsKy5.js","assets/loops-CO6q75W8.js","assets/mcp-HwBbQDk0.js","assets/nav-BTg8s-cD.js","assets/settings-cJNynGIZ.js","assets/setup-D2CmgAro.js","assets/specs-PGIOzMtc.js","assets/terminal-CFt56A5f.js","assets/tickets-BHv3ewvq.js","assets/JobDetailModal-D-BeqsJ6.js","assets/InteractiveJobComposer-B5gh4Qoy.js","assets/lib-0PFDyMxJ.js","assets/brain-C92rjjYP.js","assets/auth-DpZq5p1e.js","assets/LoopPreviewModal-Dw4UgoLu.js","assets/TemplatePreviewModal-CeMx2Red.js","assets/ProjectSettingsDialog-BlTlRtGI.js","assets/addon-image-CwoZj17F.js","assets/addon-ligatures-CWDrED80.js","assets/addon-webgl-DMbGeI_u.js","assets/AgentModeCodePane-GZc8bNGT.js","assets/preload-helper-DSXbuxSR.js","assets/AgentModeJobsPane-DWtQqj3k.js","assets/format-command-CuWuRvka.js","assets/AgentBrowserCapture-BUHPHNSN.js","assets/JobDetailPage-DwdozwLO.js","assets/JobsPage-BDkinklt.js","assets/ExportDropdown-DvTS2wc7.js","assets/AnalyticsPage-CZW8c77k.js","assets/BarChart-DugEoe2q.js","assets/clsx-CNmW0Nip.js","assets/value-JA3bf47v.js","assets/ActivityFeedPage-D8RKRRoM.js","assets/AgentsPage-CKPtHkRP.js","assets/CodePage-CQ-uKETG.js","assets/PluginsPage-wdC-qa40.js","assets/DesktopAnalyticsPage-Bgo4SyCH.js","assets/DocsPage-CmcOkK19.js","assets/atom-one-dark-BMDPFwRZ.js","assets/atom-one-dark-B-oHczHB.css","assets/DocsDialog-DxpWw_La.js","assets/LoopsPage-D7ac4M24.js","assets/upload-CmR4h9H1.js","assets/LoopBuilderPage-CclJ3VZA.js","assets/LoopBuilderPage-DtxX27Jz.css"])))=>i.map(i=>d[i]);
2
+ import{a as e,i as t,n,r,t as i}from"./chunk-BNv3lrIs.js";import{t as a}from"./preload-helper-DSXbuxSR.js";import{a as o,i as s,n as c,r as l,t as u}from"./auth-DpZq5p1e.js";import{t as d}from"./activity-Dbl71S-E.js";import{t as f}from"./addspec-DrXqP8ip.js";import{t as p}from"./agent-BEXYxDbs.js";import{t as m}from"./agents-CGDn_3kB.js";import{t as h}from"./agentstudio-Dxe_94PK.js";import{t as g}from"./aiedit-DrfHQnlz.js";import{t as _}from"./analytics-CxDYcBl9.js";import{t as v}from"./attachments-DvxQbBTC.js";import{t as y}from"./browser-DM8G151q.js";import{t as b}from"./chat-0dg5hOo_.js";import{t as x}from"./code-B62fClk-.js";import{t as S}from"./commands-DCJ-R9E4.js";import{t as C}from"./common-DXrmj6WD.js";import{t as w}from"./dashboard-DBuLfWo9.js";import{t as T}from"./explore-_XyU5e7R.js";import{t as E}from"./integrations-By80EBkf.js";import{t as D}from"./jira-DeIjwCK3.js";import{t as O}from"./jobs-DrYmsKy5.js";import{t as k}from"./loops-CO6q75W8.js";import{t as A}from"./mcp-HwBbQDk0.js";import{t as j}from"./nav-BTg8s-cD.js";import{t as M}from"./settings-cJNynGIZ.js";import{t as N}from"./setup-D2CmgAro.js";import{t as P}from"./specs-PGIOzMtc.js";import{t as F}from"./terminal-CFt56A5f.js";import{t as I}from"./tickets-BHv3ewvq.js";import{t as L}from"./clsx-CNmW0Nip.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var R=i((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.iterator;function m(e){return typeof e!=`object`||!e?null:(e=p&&e[p]||e[`@@iterator`],typeof e==`function`?e:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,_={};function v(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}v.prototype.isReactComponent={},v.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},v.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function y(){}y.prototype=v.prototype;function b(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}var x=b.prototype=new y;x.constructor=b,g(x,v.prototype),x.isPureReactComponent=!0;var S=Array.isArray;function C(){}var w={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function E(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function D(e,t){return E(e.type,t,e.props)}function O(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function k(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var A=/\/+/g;function j(e,t){return typeof e==`object`&&e&&e.key!=null?k(``+e.key):t.toString(36)}function M(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(C,C):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function N(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,N(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+j(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(A,`$&/`)+`/`),N(o,r,i,``,function(e){return e})):o!=null&&(O(o)&&(o=D(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(A,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(S(e))for(var u=0;u<e.length;u++)a=e[u],s=l+j(a,u),c+=N(a,r,i,s,o);else if(u=m(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+j(a,u++),c+=N(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return N(M(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function P(e,t,n){if(e==null)return e;var r=[],i=0;return N(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function F(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t)},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var I=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},L={map:P,forEach:function(e,t,n){P(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return P(e,function(){t++}),t},toArray:function(e){return P(e,function(e){return e})||[]},only:function(e){if(!O(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=L,e.Component=v,e.Fragment=r,e.Profiler=a,e.PureComponent=b,e.StrictMode=i,e.Suspense=l,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=w,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return w.H.useMemoCache(e)}},e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=g({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!T.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return E(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)T.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return E(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=O,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:F}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=function(e){var t=w.T,n={};w.T=n;try{var r=e(),i=w.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(C,I)}catch(e){I(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),w.T=t}},e.unstable_useCacheRefresh=function(){return w.H.useCacheRefresh()},e.use=function(e){return w.H.use(e)},e.useActionState=function(e,t,n){return w.H.useActionState(e,t,n)},e.useCallback=function(e,t){return w.H.useCallback(e,t)},e.useContext=function(e){return w.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return w.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return w.H.useEffect(e,t)},e.useEffectEvent=function(e){return w.H.useEffectEvent(e)},e.useId=function(){return w.H.useId()},e.useImperativeHandle=function(e,t,n){return w.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return w.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return w.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return w.H.useMemo(e,t)},e.useOptimistic=function(e,t){return w.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return w.H.useReducer(e,t,n)},e.useRef=function(e){return w.H.useRef(e)},e.useState=function(e){return w.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return w.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return w.H.useTransition()},e.version=`19.2.4`})),z=i(((e,t)=>{t.exports=R()})),ee=i((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),te=i(((e,t)=>{t.exports=ee()})),B=i((e=>{var t=z();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`);function o(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var s=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function c(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return o(e,t,null,r)},e.flushSync=function(e){var t=s.T,n=i.p;try{if(s.T=null,i.p=2,e)return e()}finally{s.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`)if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=c(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t??i.d.M(e)},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`)if(t){var n=c(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else i.d.m(e)},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return s.H.useFormState(e,t,n)},e.useFormStatus=function(){return s.H.useHostTransitionStatus()},e.version=`19.2.4`})),ne=i(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=B()})),V=i((e=>{var t=te(),n=z(),r=ne();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}var f=Object.assign,p=Symbol.for(`react.element`),m=Symbol.for(`react.transitional.element`),h=Symbol.for(`react.portal`),g=Symbol.for(`react.fragment`),_=Symbol.for(`react.strict_mode`),v=Symbol.for(`react.profiler`),y=Symbol.for(`react.consumer`),b=Symbol.for(`react.context`),x=Symbol.for(`react.forward_ref`),S=Symbol.for(`react.suspense`),C=Symbol.for(`react.suspense_list`),w=Symbol.for(`react.memo`),T=Symbol.for(`react.lazy`),E=Symbol.for(`react.activity`),D=Symbol.for(`react.memo_cache_sentinel`),O=Symbol.iterator;function k(e){return typeof e!=`object`||!e?null:(e=O&&e[O]||e[`@@iterator`],typeof e==`function`?e:null)}var A=Symbol.for(`react.client.reference`);function j(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===A?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case g:return`Fragment`;case v:return`Profiler`;case _:return`StrictMode`;case S:return`Suspense`;case C:return`SuspenseList`;case E:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case h:return`Portal`;case b:return e.displayName||`Context`;case y:return(e._context.displayName||`Context`)+`.Consumer`;case x:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case w:return t=e.displayName||null,t===null?j(e.type)||`Memo`:t;case T:t=e._payload,e=e._init;try{return j(e(t))}catch{}}return null}var M=Array.isArray,N=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,P=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F={pending:!1,data:null,method:null,action:null},I=[],L=-1;function R(e){return{current:e}}function ee(e){0>L||(e.current=I[L],I[L]=null,L--)}function B(e,t){L++,I[L]=e.current,e.current=t}var V=R(null),re=R(null),H=R(null),U=R(null);function ie(e,t){switch(B(H,t),B(re,e),B(V,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Kd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Kd(t),e=qd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}ee(V),B(V,e)}function ae(){ee(V),ee(re),ee(H)}function W(e){e.memoizedState!==null&&B(U,e);var t=V.current,n=qd(t,e.type);t!==n&&(B(re,e),B(V,n))}function oe(e){re.current===e&&(ee(V),ee(re)),U.current===e&&(ee(U),np._currentValue=F)}var se,ce;function le(e){if(se===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);se=t&&t[1]||``,ce=-1<e.stack.indexOf(`
3
3
  at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
4
4
  `+se+e+ce}var ue=!1;function de(e,t){if(!e||ue)return``;ue=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,`props`,{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,`name`,{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
5
5
  `),l=s.split(`
@@ -13,7 +13,7 @@ Please change the parent <Route path="${e}"> to <Route path="${e===`/`?`*`:`${e}
13
13
  To pick up a draggable item, press the space bar.
14
14
  While dragging, use the arrow keys to move the item.
15
15
  Press space again to drop the item in its new position, or press escape to cancel.
16
- `},nl={onDragStart(e){let{active:t}=e;return`Picked up draggable item `+t.id+`.`},onDragOver(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was moved over droppable area `+n.id+`.`:`Draggable item `+t.id+` is no longer over a droppable area.`},onDragEnd(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was dropped over droppable area `+n.id:`Draggable item `+t.id+` was dropped.`},onDragCancel(e){let{active:t}=e;return`Dragging was cancelled. Draggable item `+t.id+` was dropped.`}};function rl(e){let{announcements:t=nl,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=tl}=e,{announce:a,announcement:o}=Zc(),s=Lc(`DndLiveRegion`),[c,l]=(0,H.useState)(!1);if((0,H.useEffect)(()=>{l(!0)},[]),$c((0,H.useMemo)(()=>({onDragStart(e){let{active:n}=e;a(t.onDragStart({active:n}))},onDragMove(e){let{active:n,over:r}=e;t.onDragMove&&a(t.onDragMove({active:n,over:r}))},onDragOver(e){let{active:n,over:r}=e;a(t.onDragOver({active:n,over:r}))},onDragEnd(e){let{active:n,over:r}=e;a(t.onDragEnd({active:n,over:r}))},onDragCancel(e){let{active:n,over:r}=e;a(t.onDragCancel({active:n,over:r}))}}),[a,t])),!c)return null;let u=H.createElement(H.Fragment,null,H.createElement(Yc,{id:r,value:i.draggable}),H.createElement(Xc,{id:s,announcement:o}));return n?(0,sr.createPortal)(u,n):u}var il;(function(e){e.DragStart=`dragStart`,e.DragMove=`dragMove`,e.DragEnd=`dragEnd`,e.DragCancel=`dragCancel`,e.DragOver=`dragOver`,e.RegisterDroppable=`registerDroppable`,e.SetDroppableDisabled=`setDroppableDisabled`,e.UnregisterDroppable=`unregisterDroppable`})(il||={});function al(){}function ol(e,t){return(0,H.useMemo)(()=>({sensor:e,options:t??{}}),[e,t])}function sl(){var e=[...arguments];return(0,H.useMemo)(()=>[...e].filter(e=>e!=null),[...e])}var cl=Object.freeze({x:0,y:0});function ll(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function ul(e,t){let n=Wc(e);if(!n)return`0 0`;let r={x:(n.x-t.left)/t.width*100,y:(n.y-t.top)/t.height*100};return r.x+`% `+r.y+`%`}function dl(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function fl(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function pl(e){let{left:t,top:n,height:r,width:i}=e;return[{x:t,y:n},{x:t+i,y:n},{x:t,y:n+r},{x:t+i,y:n+r}]}function ml(e,t){if(!e||e.length===0)return null;let[n]=e;return t?n[t]:n}function hl(e,t,n){return t===void 0&&(t=e.left),n===void 0&&(n=e.top),{x:t+e.width*.5,y:n+e.height*.5}}var gl=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=hl(t,t.left,t.top),a=[];for(let e of r){let{id:t}=e,r=n.get(t);if(r){let n=ll(hl(r),i);a.push({id:t,data:{droppableContainer:e,value:n}})}}return a.sort(dl)},_l=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=pl(t),a=[];for(let e of r){let{id:t}=e,r=n.get(t);if(r){let n=pl(r),o=i.reduce((e,t,r)=>e+ll(n[r],t),0),s=Number((o/4).toFixed(4));a.push({id:t,data:{droppableContainer:e,value:s}})}}return a.sort(dl)};function vl(e,t){let n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),i=Math.min(t.left+t.width,e.left+e.width),a=Math.min(t.top+t.height,e.top+e.height),o=i-r,s=a-n;if(r<i&&n<a){let n=t.width*t.height,r=e.width*e.height,i=o*s,a=i/(n+r-i);return Number(a.toFixed(4))}return 0}var yl=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=[];for(let e of r){let{id:r}=e,a=n.get(r);if(a){let n=vl(a,t);n>0&&i.push({id:r,data:{droppableContainer:e,value:n}})}}return i.sort(fl)};function bl(e,t){let{top:n,left:r,bottom:i,right:a}=t;return n<=e.y&&e.y<=i&&r<=e.x&&e.x<=a}var xl=e=>{let{droppableContainers:t,droppableRects:n,pointerCoordinates:r}=e;if(!r)return[];let i=[];for(let e of t){let{id:t}=e,a=n.get(t);if(a&&bl(r,a)){let n=pl(a).reduce((e,t)=>e+ll(r,t),0),o=Number((n/4).toFixed(4));i.push({id:t,data:{droppableContainer:e,value:o}})}}return i.sort(dl)};function Sl(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function Cl(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:cl}function wl(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>({...t,top:t.top+e*n.y,bottom:t.bottom+e*n.y,left:t.left+e*n.x,right:t.right+e*n.x}),{...t})}}var Tl=wl(1);function El(e){if(e.startsWith(`matrix3d(`)){let t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith(`matrix(`)){let t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function Dl(e,t,n){let r=El(t);if(!r)return e;let{scaleX:i,scaleY:a,x:o,y:s}=r,c=e.left-o-(1-i)*parseFloat(n),l=e.top-s-(1-a)*parseFloat(n.slice(n.indexOf(` `)+1)),u=i?e.width/i:e.width,d=a?e.height/a:e.height;return{width:u,height:d,top:l,right:c+u,bottom:l+d,left:c}}var Ol={ignoreTransform:!1};function kl(e,t){t===void 0&&(t=Ol);let n=e.getBoundingClientRect();if(t.ignoreTransform){let{transform:t,transformOrigin:r}=wc(e).getComputedStyle(e);t&&(n=Dl(n,t,r))}let{top:r,left:i,width:a,height:o,bottom:s,right:c}=n;return{top:r,left:i,width:a,height:o,bottom:s,right:c}}function Al(e){return kl(e,{ignoreTransform:!0})}function jl(e){let t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function Ml(e,t){return t===void 0&&(t=wc(e).getComputedStyle(e)),t.position===`fixed`}function Nl(e,t){t===void 0&&(t=wc(e).getComputedStyle(e));let n=/(auto|scroll|overlay)/;return[`overflow`,`overflowX`,`overflowY`].some(e=>{let r=t[e];return typeof r==`string`?n.test(r):!1})}function Pl(e,t){let n=[];function r(i){if(t!=null&&n.length>=t||!i)return n;if(Tc(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!Ec(i)||Dc(i)||n.includes(i))return n;let a=wc(e).getComputedStyle(i);return i!==e&&Nl(i,a)&&n.push(i),Ml(i,a)?n:r(i.parentNode)}return e?r(e):n}function Fl(e){let[t]=Pl(e,1);return t??null}function Il(e){return!xc||!e?null:Sc(e)?e:Cc(e)?Tc(e)||e===Oc(e).scrollingElement?window:Ec(e)?e:null:null}function Ll(e){return Sc(e)?e.scrollX:e.scrollLeft}function Rl(e){return Sc(e)?e.scrollY:e.scrollTop}function zl(e){return{x:Ll(e),y:Rl(e)}}var Bl;(function(e){e[e.Forward=1]=`Forward`,e[e.Backward=-1]=`Backward`})(Bl||={});function Vl(e){return!xc||!e?!1:e===document.scrollingElement}function Hl(e){let t={x:0,y:0},n=Vl(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height};return{isTop:e.scrollTop<=t.y,isLeft:e.scrollLeft<=t.x,isBottom:e.scrollTop>=r.y,isRight:e.scrollLeft>=r.x,maxScroll:r,minScroll:t}}var Ul={x:.2,y:.2};function Wl(e,t,n,r,i){let{top:a,left:o,right:s,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=Ul);let{isTop:l,isBottom:u,isLeft:d,isRight:f}=Hl(e),p={x:0,y:0},m={x:0,y:0},h={height:t.height*i.y,width:t.width*i.x};return!l&&a<=t.top+h.height?(p.y=Bl.Backward,m.y=r*Math.abs((t.top+h.height-a)/h.height)):!u&&c>=t.bottom-h.height&&(p.y=Bl.Forward,m.y=r*Math.abs((t.bottom-h.height-c)/h.height)),!f&&s>=t.right-h.width?(p.x=Bl.Forward,m.x=r*Math.abs((t.right-h.width-s)/h.width)):!d&&o<=t.left+h.width&&(p.x=Bl.Backward,m.x=r*Math.abs((t.left+h.width-o)/h.width)),{direction:p,speed:m}}function Gl(e){if(e===document.scrollingElement){let{innerWidth:e,innerHeight:t}=window;return{top:0,left:0,right:e,bottom:t,width:e,height:t}}let{top:t,left:n,right:r,bottom:i}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:i,width:e.clientWidth,height:e.clientHeight}}function Kl(e){return e.reduce((e,t)=>zc(e,zl(t)),cl)}function ql(e){return e.reduce((e,t)=>e+Ll(t),0)}function Jl(e){return e.reduce((e,t)=>e+Rl(t),0)}function Yl(e,t){if(t===void 0&&(t=kl),!e)return;let{top:n,left:r,bottom:i,right:a}=t(e);Fl(e)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:`center`,inline:`center`})}var Xl=[[`x`,[`left`,`right`],ql],[`y`,[`top`,`bottom`],Jl]],Zl=class{constructor(e,t){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;let n=Pl(t),r=Kl(n);this.rect={...e},this.width=e.width,this.height=e.height;for(let[e,t,i]of Xl)for(let a of t)Object.defineProperty(this,a,{get:()=>{let t=i(n),o=r[e]-t;return this.rect[a]+o},enumerable:!0});Object.defineProperty(this,`rect`,{enumerable:!1})}},Ql=class{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(e=>this.target?.removeEventListener(...e))},this.target=e}add(e,t,n){var r;(r=this.target)==null||r.addEventListener(e,t,n),this.listeners.push([e,t,n])}};function $l(e){let{EventTarget:t}=wc(e);return e instanceof t?e:Oc(e)}function eu(e,t){let n=Math.abs(e.x),r=Math.abs(e.y);return typeof t==`number`?Math.sqrt(n**2+r**2)>t:`x`in t&&`y`in t?n>t.x&&r>t.y:`x`in t?n>t.x:`y`in t?r>t.y:!1}var tu;(function(e){e.Click=`click`,e.DragStart=`dragstart`,e.Keydown=`keydown`,e.ContextMenu=`contextmenu`,e.Resize=`resize`,e.SelectionChange=`selectionchange`,e.VisibilityChange=`visibilitychange`})(tu||={});function nu(e){e.preventDefault()}function ru(e){e.stopPropagation()}var iu;(function(e){e.Space=`Space`,e.Down=`ArrowDown`,e.Right=`ArrowRight`,e.Left=`ArrowLeft`,e.Up=`ArrowUp`,e.Esc=`Escape`,e.Enter=`Enter`,e.Tab=`Tab`})(iu||={});var au={start:[iu.Space,iu.Enter],cancel:[iu.Esc],end:[iu.Space,iu.Enter,iu.Tab]},ou=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case iu.Right:return{...n,x:n.x+25};case iu.Left:return{...n,x:n.x-25};case iu.Down:return{...n,y:n.y+25};case iu.Up:return{...n,y:n.y-25}}},su=class{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;let{event:{target:t}}=e;this.props=e,this.listeners=new Ql(Oc(t)),this.windowListeners=new Ql(wc(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(tu.Resize,this.handleCancel),this.windowListeners.add(tu.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(tu.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&Yl(n),t(cl)}handleKeyDown(e){if(Hc(e)){let{active:t,context:n,options:r}=this.props,{keyboardCodes:i=au,coordinateGetter:a=ou,scrollBehavior:o=`smooth`}=r,{code:s}=e;if(i.end.includes(s)){this.handleEnd(e);return}if(i.cancel.includes(s)){this.handleCancel(e);return}let{collisionRect:c}=n.current,l=c?{x:c.left,y:c.top}:cl;this.referenceCoordinates||=l;let u=a(e,{active:t,context:n.current,currentCoordinates:l});if(u){let t=Bc(u,l),r={x:0,y:0},{scrollableAncestors:i}=n.current;for(let n of i){let i=e.code,{isTop:a,isRight:s,isLeft:c,isBottom:l,maxScroll:d,minScroll:f}=Hl(n),p=Gl(n),m={x:Math.min(i===iu.Right?p.right-p.width/2:p.right,Math.max(i===iu.Right?p.left:p.left+p.width/2,u.x)),y:Math.min(i===iu.Down?p.bottom-p.height/2:p.bottom,Math.max(i===iu.Down?p.top:p.top+p.height/2,u.y))},h=i===iu.Right&&!s||i===iu.Left&&!c,g=i===iu.Down&&!l||i===iu.Up&&!a;if(h&&m.x!==u.x){let e=n.scrollLeft+t.x,a=i===iu.Right&&e<=d.x||i===iu.Left&&e>=f.x;if(a&&!t.y){n.scrollTo({left:e,behavior:o});return}a?r.x=n.scrollLeft-e:r.x=i===iu.Right?n.scrollLeft-d.x:n.scrollLeft-f.x,r.x&&n.scrollBy({left:-r.x,behavior:o});break}else if(g&&m.y!==u.y){let e=n.scrollTop+t.y,a=i===iu.Down&&e<=d.y||i===iu.Up&&e>=f.y;if(a&&!t.x){n.scrollTo({top:e,behavior:o});return}a?r.y=n.scrollTop-e:r.y=i===iu.Down?n.scrollTop-d.y:n.scrollTop-f.y,r.y&&n.scrollBy({top:-r.y,behavior:o});break}}this.handleMove(e,zc(Bc(u,this.referenceCoordinates),r))}}}handleMove(e,t){let{onMove:n}=this.props;e.preventDefault(),n(t)}handleEnd(e){let{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){let{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}};su.activators=[{eventName:`onKeyDown`,handler:(e,t,n)=>{let{keyboardCodes:r=au,onActivation:i}=t,{active:a}=n,{code:o}=e.nativeEvent;if(r.start.includes(o)){let t=a.activatorNode.current;return t&&e.target!==t?!1:(e.preventDefault(),i?.({event:e.nativeEvent}),!0)}return!1}}];function cu(e){return!!(e&&`distance`in e)}function lu(e){return!!(e&&`delay`in e)}var uu=class{constructor(e,t,n){n===void 0&&(n=$l(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=t;let{event:r}=e,{target:i}=r;this.props=e,this.events=t,this.document=Oc(i),this.documentListeners=new Ql(this.document),this.listeners=new Ql(n),this.windowListeners=new Ql(wc(i)),this.initialCoordinates=Wc(r)??cl,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){let{events:e,props:{options:{activationConstraint:t,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(tu.Resize,this.handleCancel),this.windowListeners.add(tu.DragStart,nu),this.windowListeners.add(tu.VisibilityChange,this.handleCancel),this.windowListeners.add(tu.ContextMenu,nu),this.documentListeners.add(tu.Keydown,this.handleKeydown),t){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(lu(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(cu(t)){this.handlePending(t);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,t){let{active:n,onPending:r}=this.props;r(n,e,this.initialCoordinates,t)}handleStart(){let{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(tu.Click,ru,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(tu.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){let{activated:t,initialCoordinates:n,props:r}=this,{onMove:i,options:{activationConstraint:a}}=r;if(!n)return;let o=Wc(e)??cl,s=Bc(n,o);if(!t&&a){if(cu(a)){if(a.tolerance!=null&&eu(s,a.tolerance))return this.handleCancel();if(eu(s,a.distance))return this.handleStart()}if(lu(a)&&eu(s,a.tolerance))return this.handleCancel();this.handlePending(a,s);return}e.cancelable&&e.preventDefault(),i(o)}handleEnd(){let{onAbort:e,onEnd:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleCancel(){let{onAbort:e,onCancel:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleKeydown(e){e.code===iu.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}},du={cancel:{name:`pointercancel`},move:{name:`pointermove`},end:{name:`pointerup`}},fu=class extends uu{constructor(e){let{event:t}=e,n=Oc(t.target);super(e,du,n)}};fu.activators=[{eventName:`onPointerDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];var pu={move:{name:`mousemove`},end:{name:`mouseup`}},mu;(function(e){e[e.RightClick=2]=`RightClick`})(mu||={});var hu=class extends uu{constructor(e){super(e,pu,Oc(e.event.target))}};hu.activators=[{eventName:`onMouseDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===mu.RightClick?!1:(r?.({event:n}),!0)}}];var gu={cancel:{name:`touchcancel`},move:{name:`touchmove`},end:{name:`touchend`}},_u=class extends uu{constructor(e){super(e,gu)}static setup(){return window.addEventListener(gu.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(gu.move.name,e)};function e(){}}};_u.activators=[{eventName:`onTouchStart`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t,{touches:i}=n;return i.length>1?!1:(r?.({event:n}),!0)}}];var vu;(function(e){e[e.Pointer=0]=`Pointer`,e[e.DraggableRect=1]=`DraggableRect`})(vu||={});var yu;(function(e){e[e.TreeOrder=0]=`TreeOrder`,e[e.ReversedTreeOrder=1]=`ReversedTreeOrder`})(yu||={});function bu(e){let{acceleration:t,activator:n=vu.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:s=yu.TreeOrder,pointerCoordinates:c,scrollableAncestors:l,scrollableAncestorRects:u,delta:d,threshold:f}=e,p=Su({delta:d,disabled:!a}),[m,h]=jc(),g=(0,H.useRef)({x:0,y:0}),_=(0,H.useRef)({x:0,y:0}),v=(0,H.useMemo)(()=>{switch(n){case vu.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case vu.DraggableRect:return i}},[n,i,c]),y=(0,H.useRef)(null),b=(0,H.useCallback)(()=>{let e=y.current;if(!e)return;let t=g.current.x*_.current.x,n=g.current.y*_.current.y;e.scrollBy(t,n)},[]),x=(0,H.useMemo)(()=>s===yu.TreeOrder?[...l].reverse():l,[s,l]);(0,H.useEffect)(()=>{if(!a||!l.length||!v){h();return}for(let e of x){if(r?.(e)===!1)continue;let n=u[l.indexOf(e)];if(!n)continue;let{direction:i,speed:a}=Wl(e,n,v,t,f);for(let e of[`x`,`y`])p[e][i[e]]||(a[e]=0,i[e]=0);if(a.x>0||a.y>0){h(),y.current=e,m(b,o),g.current=a,_.current=i;return}}g.current={x:0,y:0},_.current={x:0,y:0},h()},[t,b,r,h,a,o,JSON.stringify(v),JSON.stringify(p),m,l,x,u,JSON.stringify(f)])}var xu={x:{[Bl.Backward]:!1,[Bl.Forward]:!1},y:{[Bl.Backward]:!1,[Bl.Forward]:!1}};function Su(e){let{delta:t,disabled:n}=e,r=Fc(t);return Nc(e=>{if(n||!r||!e)return xu;let i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[Bl.Backward]:e.x[Bl.Backward]||i.x===-1,[Bl.Forward]:e.x[Bl.Forward]||i.x===1},y:{[Bl.Backward]:e.y[Bl.Backward]||i.y===-1,[Bl.Forward]:e.y[Bl.Forward]||i.y===1}}},[n,t,r])}function Cu(e,t){let n=t==null?void 0:e.get(t),r=n?n.node.current:null;return Nc(e=>t==null?null:r??e??null,[r,t])}function wu(e,t){return(0,H.useMemo)(()=>e.reduce((e,n)=>{let{sensor:r}=n,i=r.activators.map(e=>({eventName:e.eventName,handler:t(e.handler,n)}));return[...e,...i]},[]),[e,t])}var Tu;(function(e){e[e.Always=0]=`Always`,e[e.BeforeDragging=1]=`BeforeDragging`,e[e.WhileDragging=2]=`WhileDragging`})(Tu||={});var Eu;(function(e){e.Optimized=`optimized`})(Eu||={});var Du=new Map;function Ou(e,t){let{dragging:n,dependencies:r,config:i}=t,[a,o]=(0,H.useState)(null),{frequency:s,measure:c,strategy:l}=i,u=(0,H.useRef)(e),d=g(),f=Mc(d),p=(0,H.useCallback)(function(e){e===void 0&&(e=[]),!f.current&&o(t=>t===null?e:t.concat(e.filter(e=>!t.includes(e))))},[f]),m=(0,H.useRef)(null),h=Nc(t=>{if(d&&!n)return Du;if(!t||t===Du||u.current!==e||a!=null){let t=new Map;for(let n of e){if(!n)continue;if(a&&a.length>0&&!a.includes(n.id)&&n.rect.current){t.set(n.id,n.rect.current);continue}let e=n.node.current,r=e?new Zl(c(e),e):null;n.rect.current=r,r&&t.set(n.id,r)}return t}return t},[e,a,n,d,c]);return(0,H.useEffect)(()=>{u.current=e},[e]),(0,H.useEffect)(()=>{d||p()},[n,d]),(0,H.useEffect)(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),(0,H.useEffect)(()=>{d||typeof s!=`number`||m.current!==null||(m.current=setTimeout(()=>{p(),m.current=null},s))},[s,d,p,...r]),{droppableRects:h,measureDroppableContainers:p,measuringScheduled:a!=null};function g(){switch(l){case Tu.Always:return!1;case Tu.BeforeDragging:return n;default:return!n}}}function ku(e,t){return Nc(n=>e?n||(typeof t==`function`?t(e):e):null,[t,e])}function Au(e,t){return ku(e,t)}function ju(e){let{callback:t,disabled:n}=e,r=Ac(t),i=(0,H.useMemo)(()=>{if(n||typeof window>`u`||window.MutationObserver===void 0)return;let{MutationObserver:e}=window;return new e(r)},[r,n]);return(0,H.useEffect)(()=>()=>i?.disconnect(),[i]),i}function Mu(e){let{callback:t,disabled:n}=e,r=Ac(t),i=(0,H.useMemo)(()=>{if(n||typeof window>`u`||window.ResizeObserver===void 0)return;let{ResizeObserver:e}=window;return new e(r)},[n]);return(0,H.useEffect)(()=>()=>i?.disconnect(),[i]),i}function Nu(e){return new Zl(kl(e),e)}function Pu(e,t,n){t===void 0&&(t=Nu);let[r,i]=(0,H.useState)(null);function a(){i(r=>{if(!e)return null;if(e.isConnected===!1)return r??n??null;let i=t(e);return JSON.stringify(r)===JSON.stringify(i)?r:i})}let o=ju({callback(t){if(e)for(let n of t){let{type:t,target:r}=n;if(t===`childList`&&r instanceof HTMLElement&&r.contains(e)){a();break}}}}),s=Mu({callback:a});return kc(()=>{a(),e?(s?.observe(e),o?.observe(document.body,{childList:!0,subtree:!0})):(s?.disconnect(),o?.disconnect())},[e]),r}function Fu(e){return Cl(e,ku(e))}var Iu=[];function Lu(e){let t=(0,H.useRef)(e),n=Nc(n=>e?n&&n!==Iu&&e&&t.current&&e.parentNode===t.current.parentNode?n:Pl(e):Iu,[e]);return(0,H.useEffect)(()=>{t.current=e},[e]),n}function Ru(e){let[t,n]=(0,H.useState)(null),r=(0,H.useRef)(e),i=(0,H.useCallback)(e=>{let t=Il(e.target);t&&n(e=>e?(e.set(t,zl(t)),new Map(e)):null)},[]);return(0,H.useEffect)(()=>{let t=r.current;if(e!==t){a(t);let o=e.map(e=>{let t=Il(e);return t?(t.addEventListener(`scroll`,i,{passive:!0}),[t,zl(t)]):null}).filter(e=>e!=null);n(o.length?new Map(o):null),r.current=e}return()=>{a(e),a(t)};function a(e){e.forEach(e=>{Il(e)?.removeEventListener(`scroll`,i)})}},[i,e]),(0,H.useMemo)(()=>e.length?t?Array.from(t.values()).reduce((e,t)=>zc(e,t),cl):Kl(e):cl,[e,t])}function zu(e,t){t===void 0&&(t=[]);let n=(0,H.useRef)(null);return(0,H.useEffect)(()=>{n.current=null},t),(0,H.useEffect)(()=>{let t=e!==cl;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)},[e]),n.current?Bc(e,n.current):cl}function Bu(e){(0,H.useEffect)(()=>{if(!xc)return;let t=e.map(e=>{let{sensor:t}=e;return t.setup==null?void 0:t.setup()});return()=>{for(let e of t)e?.()}},e.map(e=>{let{sensor:t}=e;return t}))}function Vu(e,t){return(0,H.useMemo)(()=>e.reduce((e,n)=>{let{eventName:r,handler:i}=n;return e[r]=e=>{i(e,t)},e},{}),[e,t])}function Hu(e){return(0,H.useMemo)(()=>e?jl(e):null,[e])}var Uu=[];function Wu(e,t){t===void 0&&(t=kl);let[n]=e,r=Hu(n?wc(n):null),[i,a]=(0,H.useState)(Uu);function o(){a(()=>e.length?e.map(e=>Vl(e)?r:new Zl(t(e),e)):Uu)}let s=Mu({callback:o});return kc(()=>{s?.disconnect(),o(),e.forEach(e=>s?.observe(e))},[e]),i}function Gu(e){if(!e)return null;if(e.children.length>1)return e;let t=e.children[0];return Ec(t)?t:e}function Ku(e){let{measure:t}=e,[n,r]=(0,H.useState)(null),i=Mu({callback:(0,H.useCallback)(e=>{for(let{target:n}of e)if(Ec(n)){r(e=>{let r=t(n);return e?{...e,width:r.width,height:r.height}:r});break}},[t])}),[a,o]=Pc((0,H.useCallback)(e=>{let n=Gu(e);i?.disconnect(),n&&i?.observe(n),r(n?t(n):null)},[t,i]));return(0,H.useMemo)(()=>({nodeRef:a,rect:n,setRef:o}),[n,a,o])}var qu=[{sensor:fu,options:{}},{sensor:su,options:{}}],Ju={current:{}},Yu={draggable:{measure:Al},droppable:{measure:Al,strategy:Tu.WhileDragging,frequency:Eu.Optimized},dragOverlay:{measure:kl}},Xu=class extends Map{get(e){return e==null?void 0:super.get(e)??void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:t}=e;return!t})}getNodeFor(e){return this.get(e)?.node.current??void 0}},Zu={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Xu,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:al},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Yu,measureDroppableContainers:al,windowRect:null,measuringScheduled:!1},Qu={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:``},dispatch:al,draggableNodes:new Map,over:null,measureDroppableContainers:al},$u=(0,H.createContext)(Qu),ed=(0,H.createContext)(Zu);function td(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Xu}}}function nd(e,t){switch(t.type){case il.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case il.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case il.DragEnd:case il.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case il.RegisterDroppable:{let{element:n}=t,{id:r}=n,i=new Xu(e.droppable.containers);return i.set(r,n),{...e,droppable:{...e.droppable,containers:i}}}case il.SetDroppableDisabled:{let{id:n,key:r,disabled:i}=t,a=e.droppable.containers.get(n);if(!a||r!==a.key)return e;let o=new Xu(e.droppable.containers);return o.set(n,{...a,disabled:i}),{...e,droppable:{...e.droppable,containers:o}}}case il.UnregisterDroppable:{let{id:n,key:r}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;let a=new Xu(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function rd(e){let{disabled:t}=e,{active:n,activatorEvent:r,draggableNodes:i}=(0,H.useContext)($u),a=Fc(r),o=Fc(n?.id);return(0,H.useEffect)(()=>{if(!t&&!r&&a&&o!=null){if(!Hc(a)||document.activeElement===a.target)return;let e=i.get(o);if(!e)return;let{activatorNode:t,node:n}=e;if(!t.current&&!n.current)return;requestAnimationFrame(()=>{for(let e of[t.current,n.current]){if(!e)continue;let t=qc(e);if(t){t.focus();break}}})}},[r,t,i,o,a]),null}function id(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((e,t)=>t({transform:e,...r}),n):n}function ad(e){return(0,H.useMemo)(()=>({draggable:{...Yu.draggable,...e?.draggable},droppable:{...Yu.droppable,...e?.droppable},dragOverlay:{...Yu.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function od(e){let{activeNode:t,measure:n,initialRect:r,config:i=!0}=e,a=(0,H.useRef)(!1),{x:o,y:s}=typeof i==`boolean`?{x:i,y:i}:i;kc(()=>{if(!o&&!s||!t){a.current=!1;return}if(a.current||!r)return;let e=t?.node.current;if(!e||e.isConnected===!1)return;let i=Cl(n(e),r);if(o||(i.x=0),s||(i.y=0),a.current=!0,Math.abs(i.x)>0||Math.abs(i.y)>0){let t=Fl(e);t&&t.scrollBy({top:i.y,left:i.x})}},[t,o,s,r,n])}var sd=(0,H.createContext)({...cl,scaleX:1,scaleY:1}),cd;(function(e){e[e.Uninitialized=0]=`Uninitialized`,e[e.Initializing=1]=`Initializing`,e[e.Initialized=2]=`Initialized`})(cd||={});var ld=(0,H.memo)(function(e){let{id:t,accessibility:n,autoScroll:r=!0,children:i,sensors:a=qu,collisionDetection:o=yl,measuring:s,modifiers:c,...l}=e,[u,d]=(0,H.useReducer)(nd,void 0,td),[f,p]=el(),[m,h]=(0,H.useState)(cd.Uninitialized),g=m===cd.Initialized,{draggable:{active:_,nodes:v,translate:y},droppable:{containers:b}}=u,x=_==null?null:v.get(_),S=(0,H.useRef)({initial:null,translated:null}),C=(0,H.useMemo)(()=>_==null?null:{id:_,data:x?.data??Ju,rect:S},[_,x]),w=(0,H.useRef)(null),[T,E]=(0,H.useState)(null),[D,O]=(0,H.useState)(null),k=Mc(l,Object.values(l)),A=Lc(`DndDescribedBy`,t),j=(0,H.useMemo)(()=>b.getEnabled(),[b]),M=ad(s),{droppableRects:N,measureDroppableContainers:P,measuringScheduled:F}=Ou(j,{dragging:g,dependencies:[y.x,y.y],config:M.droppable}),I=Cu(v,_),L=(0,H.useMemo)(()=>D?Wc(D):null,[D]),R=we(),z=Au(I,M.draggable.measure);od({activeNode:_==null?null:v.get(_),config:R.layoutShiftCompensation,initialRect:z,measure:M.draggable.measure});let ee=Pu(I,M.draggable.measure,z),te=Pu(I?I.parentElement:null),B=(0,H.useRef)({activatorEvent:null,active:null,activeNode:I,collisionRect:null,collisions:null,droppableRects:N,draggableNodes:v,draggingNode:null,draggingNodeRect:null,droppableContainers:b,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ne=b.getNodeFor(B.current.over?.id),V=Ku({measure:M.dragOverlay.measure}),re=V.nodeRef.current??I,U=g?V.rect??ee:null,ie=!!(V.nodeRef.current&&V.rect),ae=Fu(ie?null:ee),W=Hu(re?wc(re):null),oe=Lu(g?ne??I:null),se=Wu(oe),ce=id(c,{transform:{x:y.x-ae.x,y:y.y-ae.y,scaleX:1,scaleY:1},activatorEvent:D,active:C,activeNodeRect:ee,containerNodeRect:te,draggingNodeRect:U,over:B.current.over,overlayNodeRect:V.rect,scrollableAncestors:oe,scrollableAncestorRects:se,windowRect:W}),le=L?zc(L,y):null,ue=Ru(oe),de=zu(ue),fe=zu(ue,[ee]),pe=zc(ce,de),me=U?Tl(U,ce):null,he=C&&me?o({active:C,collisionRect:me,droppableRects:N,droppableContainers:j,pointerCoordinates:le}):null,ge=ml(he,`id`),[_e,ve]=(0,H.useState)(null),ye=Sl(ie?ce:zc(ce,fe),_e?.rect??null,ee),G=(0,H.useRef)(null),be=(0,H.useCallback)((e,t)=>{let{sensor:n,options:r}=t;if(w.current==null)return;let i=v.get(w.current);if(!i)return;let a=e.nativeEvent;G.current=new n({active:w.current,activeNode:i,event:a,options:r,context:B,onAbort(e){if(!v.get(e))return;let{onDragAbort:t}=k.current,n={id:e};t?.(n),f({type:`onDragAbort`,event:n})},onPending(e,t,n,r){if(!v.get(e))return;let{onDragPending:i}=k.current,a={id:e,constraint:t,initialCoordinates:n,offset:r};i?.(a),f({type:`onDragPending`,event:a})},onStart(e){let t=w.current;if(t==null)return;let n=v.get(t);if(!n)return;let{onDragStart:r}=k.current,i={activatorEvent:a,active:{id:t,data:n.data,rect:S}};(0,sr.unstable_batchedUpdates)(()=>{r?.(i),h(cd.Initializing),d({type:il.DragStart,initialCoordinates:e,active:t}),f({type:`onDragStart`,event:i}),E(G.current),O(a)})},onMove(e){d({type:il.DragMove,coordinates:e})},onEnd:o(il.DragEnd),onCancel:o(il.DragCancel)});function o(e){return async function(){let{active:t,collisions:n,over:r,scrollAdjustedTranslate:i}=B.current,o=null;if(t&&i){let{cancelDrop:s}=k.current;o={activatorEvent:a,active:t,collisions:n,delta:i,over:r},e===il.DragEnd&&typeof s==`function`&&await Promise.resolve(s(o))&&(e=il.DragCancel)}w.current=null,(0,sr.unstable_batchedUpdates)(()=>{d({type:e}),h(cd.Uninitialized),ve(null),E(null),O(null),G.current=null;let t=e===il.DragEnd?`onDragEnd`:`onDragCancel`;if(o){let e=k.current[t];e?.(o),f({type:t,event:o})}})}}},[v]),xe=wu(a,(0,H.useCallback)((e,t)=>(n,r)=>{let i=n.nativeEvent,a=v.get(r);if(w.current!==null||!a||i.dndKit||i.defaultPrevented)return;let o={active:a};e(n,t.options,o)===!0&&(i.dndKit={capturedBy:t.sensor},w.current=r,be(n,t))},[v,be]));Bu(a),kc(()=>{ee&&m===cd.Initializing&&h(cd.Initialized)},[ee,m]),(0,H.useEffect)(()=>{let{onDragMove:e}=k.current,{active:t,activatorEvent:n,collisions:r,over:i}=B.current;if(!t||!n)return;let a={active:t,activatorEvent:n,collisions:r,delta:{x:pe.x,y:pe.y},over:i};(0,sr.unstable_batchedUpdates)(()=>{e?.(a),f({type:`onDragMove`,event:a})})},[pe.x,pe.y]),(0,H.useEffect)(()=>{let{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:i}=B.current;if(!e||w.current==null||!t||!i)return;let{onDragOver:a}=k.current,o=r.get(ge),s=o&&o.rect.current?{id:o.id,rect:o.rect.current,data:o.data,disabled:o.disabled}:null,c={active:e,activatorEvent:t,collisions:n,delta:{x:i.x,y:i.y},over:s};(0,sr.unstable_batchedUpdates)(()=>{ve(s),a?.(c),f({type:`onDragOver`,event:c})})},[ge]),kc(()=>{B.current={activatorEvent:D,active:C,activeNode:I,collisionRect:me,collisions:he,droppableRects:N,draggableNodes:v,draggingNode:re,draggingNodeRect:U,droppableContainers:b,over:_e,scrollableAncestors:oe,scrollAdjustedTranslate:pe},S.current={initial:U,translated:me}},[C,I,he,me,v,re,U,N,b,_e,oe,pe]),bu({...R,delta:y,draggingRect:me,pointerCoordinates:le,scrollableAncestors:oe,scrollableAncestorRects:se});let Se=(0,H.useMemo)(()=>({active:C,activeNode:I,activeNodeRect:ee,activatorEvent:D,collisions:he,containerNodeRect:te,dragOverlay:V,draggableNodes:v,droppableContainers:b,droppableRects:N,over:_e,measureDroppableContainers:P,scrollableAncestors:oe,scrollableAncestorRects:se,measuringConfiguration:M,measuringScheduled:F,windowRect:W}),[C,I,ee,D,he,te,V,v,b,N,_e,P,oe,se,M,F,W]),Ce=(0,H.useMemo)(()=>({activatorEvent:D,activators:xe,active:C,activeNodeRect:ee,ariaDescribedById:{draggable:A},dispatch:d,draggableNodes:v,over:_e,measureDroppableContainers:P}),[D,xe,C,ee,d,A,v,_e,P]);return H.createElement(Qc.Provider,{value:p},H.createElement($u.Provider,{value:Ce},H.createElement(ed.Provider,{value:Se},H.createElement(sd.Provider,{value:ye},i)),H.createElement(rd,{disabled:n?.restoreFocus===!1})),H.createElement(rl,{...n,hiddenTextDescribedById:A}));function we(){let e=T?.autoScrollEnabled===!1,t=typeof r==`object`?r.enabled===!1:r===!1,n=g&&!e&&!t;return typeof r==`object`?{...r,enabled:n}:{enabled:n}}}),ud=(0,H.createContext)(null),dd=`button`,fd=`Draggable`;function pd(e){let{id:t,data:n,disabled:r=!1,attributes:i}=e,a=Lc(fd),{activators:o,activatorEvent:s,active:c,activeNodeRect:l,ariaDescribedById:u,draggableNodes:d,over:f}=(0,H.useContext)($u),{role:p=dd,roleDescription:m=`draggable`,tabIndex:h=0}=i??{},g=c?.id===t,_=(0,H.useContext)(g?sd:ud),[v,y]=Pc(),[b,x]=Pc(),S=Vu(o,t),C=Mc(n);return kc(()=>(d.set(t,{id:t,key:a,node:v,activatorNode:b,data:C}),()=>{let e=d.get(t);e&&e.key===a&&d.delete(t)}),[d,t]),{active:c,activatorEvent:s,activeNodeRect:l,attributes:(0,H.useMemo)(()=>({role:p,tabIndex:h,"aria-disabled":r,"aria-pressed":g&&p===dd?!0:void 0,"aria-roledescription":m,"aria-describedby":u.draggable}),[r,p,h,g,m,u.draggable]),isDragging:g,listeners:r?void 0:S,node:v,over:f,setNodeRef:y,setActivatorNodeRef:x,transform:_}}function md(){return(0,H.useContext)(ed)}var hd=`Droppable`,gd={timeout:25};function _d(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:i}=e,a=Lc(hd),{active:o,dispatch:s,over:c,measureDroppableContainers:l}=(0,H.useContext)($u),u=(0,H.useRef)({disabled:n}),d=(0,H.useRef)(!1),f=(0,H.useRef)(null),p=(0,H.useRef)(null),{disabled:m,updateMeasurementsFor:h,timeout:g}={...gd,...i},_=Mc(h??r),v=Mu({callback:(0,H.useCallback)(()=>{if(!d.current){d.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{l(Array.isArray(_.current)?_.current:[_.current]),p.current=null},g)},[g]),disabled:m||!o}),[y,b]=Pc((0,H.useCallback)((e,t)=>{v&&(t&&(v.unobserve(t),d.current=!1),e&&v.observe(e))},[v])),x=Mc(t);return(0,H.useEffect)(()=>{!v||!y.current||(v.disconnect(),d.current=!1,v.observe(y.current))},[y,v]),(0,H.useEffect)(()=>(s({type:il.RegisterDroppable,element:{id:r,key:a,disabled:n,node:y,rect:f,data:x}}),()=>s({type:il.UnregisterDroppable,key:a,id:r})),[r]),(0,H.useEffect)(()=>{n!==u.current.disabled&&(s({type:il.SetDroppableDisabled,id:r,key:a,disabled:n}),u.current.disabled=n)},[r,a,n,s]),{active:o,rect:f,isOver:c?.id===r,node:y,over:c,setNodeRef:b}}function vd(e){let{animation:t,children:n}=e,[r,i]=(0,H.useState)(null),[a,o]=(0,H.useState)(null),s=Fc(n);return!n&&!r&&s&&i(s),kc(()=>{if(!a)return;let e=r?.key,n=r?.props.id;if(e==null||n==null){i(null);return}Promise.resolve(t(n,a)).then(()=>{i(null)})},[t,r,a]),H.createElement(H.Fragment,null,n,r?(0,H.cloneElement)(r,{ref:o}):null)}var yd={x:0,y:0,scaleX:1,scaleY:1};function bd(e){let{children:t}=e;return H.createElement($u.Provider,{value:Qu},H.createElement(sd.Provider,{value:yd},t))}var xd={position:`fixed`,touchAction:`none`},Sd=e=>Hc(e)?`transform 250ms ease`:void 0,Cd=(0,H.forwardRef)((e,t)=>{let{as:n,activatorEvent:r,adjustScale:i,children:a,className:o,rect:s,style:c,transform:l,transition:u=Sd}=e;if(!s)return null;let d=i?l:{...l,scaleX:1,scaleY:1},f={...xd,width:s.width,height:s.height,top:s.top,left:s.left,transform:Gc.Transform.toString(d),transformOrigin:i&&r?ul(r,s):void 0,transition:typeof u==`function`?u(r):u,...c};return H.createElement(n,{className:o,style:f,ref:t},a)}),wd={duration:250,easing:`ease`,keyframes:e=>{let{transform:{initial:t,final:n}}=e;return[{transform:Gc.Transform.toString(t)},{transform:Gc.Transform.toString(n)}]},sideEffects:(e=>t=>{let{active:n,dragOverlay:r}=t,i={},{styles:a,className:o}=e;if(a!=null&&a.active)for(let[e,t]of Object.entries(a.active))t!==void 0&&(i[e]=n.node.style.getPropertyValue(e),n.node.style.setProperty(e,t));if(a!=null&&a.dragOverlay)for(let[e,t]of Object.entries(a.dragOverlay))t!==void 0&&r.node.style.setProperty(e,t);return o!=null&&o.active&&n.node.classList.add(o.active),o!=null&&o.dragOverlay&&r.node.classList.add(o.dragOverlay),function(){for(let[e,t]of Object.entries(i))n.node.style.setProperty(e,t);o!=null&&o.active&&n.node.classList.remove(o.active)}})({styles:{active:{opacity:`0`}}})};function Td(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:i}=e;return Ac((e,a)=>{if(t===null)return;let o=n.get(e);if(!o)return;let s=o.node.current;if(!s)return;let c=Gu(a);if(!c)return;let{transform:l}=wc(a).getComputedStyle(a),u=El(l);if(!u)return;let d=typeof t==`function`?t:Ed(t);return Yl(s,i.draggable.measure),d({active:{id:e,data:o.data,node:s,rect:i.draggable.measure(s)},draggableNodes:n,dragOverlay:{node:a,rect:i.dragOverlay.measure(c)},droppableContainers:r,measuringConfiguration:i,transform:u})})}function Ed(e){let{duration:t,easing:n,sideEffects:r,keyframes:i}={...wd,...e};return e=>{let{active:a,dragOverlay:o,transform:s,...c}=e;if(!t)return;let l={x:o.rect.left-a.rect.left,y:o.rect.top-a.rect.top},u={scaleX:s.scaleX===1?1:a.rect.width*s.scaleX/o.rect.width,scaleY:s.scaleY===1?1:a.rect.height*s.scaleY/o.rect.height},d={x:s.x-l.x,y:s.y-l.y,...u},f=i({...c,active:a,dragOverlay:o,transform:{initial:s,final:d}}),[p]=f,m=f[f.length-1];if(JSON.stringify(p)===JSON.stringify(m))return;let h=r?.({active:a,dragOverlay:o,...c}),g=o.node.animate(f,{duration:t,easing:n,fill:`forwards`});return new Promise(e=>{g.onfinish=()=>{h?.(),e()}})}}var Dd=0;function Od(e){return(0,H.useMemo)(()=>{if(e!=null)return Dd++,Dd},[e])}var kd=H.memo(e=>{let{adjustScale:t=!1,children:n,dropAnimation:r,style:i,transition:a,modifiers:o,wrapperElement:s=`div`,className:c,zIndex:l=999}=e,{activatorEvent:u,active:d,activeNodeRect:f,containerNodeRect:p,draggableNodes:m,droppableContainers:h,dragOverlay:g,over:_,measuringConfiguration:v,scrollableAncestors:y,scrollableAncestorRects:b,windowRect:x}=md(),S=(0,H.useContext)(sd),C=Od(d?.id),w=id(o,{activatorEvent:u,active:d,activeNodeRect:f,containerNodeRect:p,draggingNodeRect:g.rect,over:_,overlayNodeRect:g.rect,scrollableAncestors:y,scrollableAncestorRects:b,transform:S,windowRect:x}),T=ku(f),E=Td({config:r,draggableNodes:m,droppableContainers:h,measuringConfiguration:v}),D=T?g.setRef:void 0;return H.createElement(bd,null,H.createElement(vd,{animation:E},d&&C?H.createElement(Cd,{key:C,id:d.id,ref:D,as:s,activatorEvent:u,adjustScale:t,className:c,transition:a,rect:T,style:{zIndex:l,...i},transform:w},n):null))});function Ad(e,t,n){let r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function jd(e,t){return e.reduce((e,n,r)=>{let i=t.get(n);return i&&(e[r]=i),e},Array(e.length))}function Md(e){return e!==null&&e>=0}function Nd(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Pd(e){return typeof e==`boolean`?{draggable:e,droppable:e}:e}var Fd=e=>{let{rects:t,activeIndex:n,overIndex:r,index:i}=e,a=Ad(t,r,n),o=t[i],s=a[i];return!s||!o?null:{x:s.left-o.left,y:s.top-o.top,scaleX:s.width/o.width,scaleY:s.height/o.height}},Id={scaleX:1,scaleY:1},Ld=e=>{let{activeIndex:t,activeNodeRect:n,index:r,rects:i,overIndex:a}=e,o=i[t]??n;if(!o)return null;if(r===t){let e=i[a];return e?{x:0,y:t<a?e.top+e.height-(o.top+o.height):e.top-o.top,...Id}:null}let s=Rd(i,r,t);return r>t&&r<=a?{x:0,y:-o.height-s,...Id}:r<t&&r>=a?{x:0,y:o.height+s,...Id}:{x:0,y:0,...Id}};function Rd(e,t,n){let r=e[t],i=e[t-1],a=e[t+1];return r?n<t?i?r.top-(i.top+i.height):a?a.top-(r.top+r.height):0:a?a.top-(r.top+r.height):i?r.top-(i.top+i.height):0:0}var zd=`Sortable`,Bd=H.createContext({activeIndex:-1,containerId:zd,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:Fd,disabled:{draggable:!1,droppable:!1}});function Vd(e){let{children:t,id:n,items:r,strategy:i=Fd,disabled:a=!1}=e,{active:o,dragOverlay:s,droppableRects:c,over:l,measureDroppableContainers:u}=md(),d=Lc(zd,n),f=s.rect!==null,p=(0,H.useMemo)(()=>r.map(e=>typeof e==`object`&&`id`in e?e.id:e),[r]),m=o!=null,h=o?p.indexOf(o.id):-1,g=l?p.indexOf(l.id):-1,_=(0,H.useRef)(p),v=!Nd(p,_.current),y=g!==-1&&h===-1||v,b=Pd(a);kc(()=>{v&&m&&u(p)},[v,p,m,u]),(0,H.useEffect)(()=>{_.current=p},[p]);let x=(0,H.useMemo)(()=>({activeIndex:h,containerId:d,disabled:b,disableTransforms:y,items:p,overIndex:g,useDragOverlay:f,sortedRects:jd(p,c),strategy:i}),[h,d,b.draggable,b.droppable,y,p,g,c,f,i]);return H.createElement(Bd.Provider,{value:x},t)}var Hd=e=>{let{id:t,items:n,activeIndex:r,overIndex:i}=e;return Ad(n,r,i).indexOf(t)},Ud=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:i,items:a,newIndex:o,previousItems:s,previousContainerId:c,transition:l}=e;return!l||!r||s!==a&&i===o?!1:n?!0:o!==i&&t===c},Wd={duration:200,easing:`ease`},Gd=`transform`,Kd=Gc.Transition.toString({property:Gd,duration:0,easing:`linear`}),qd={roleDescription:`sortable`};function Jd(e){let{disabled:t,index:n,node:r,rect:i}=e,[a,o]=(0,H.useState)(null),s=(0,H.useRef)(n);return kc(()=>{if(!t&&n!==s.current&&r.current){let e=i.current;if(e){let t=kl(r.current,{ignoreTransform:!0}),n={x:e.left-t.left,y:e.top-t.top,scaleX:e.width/t.width,scaleY:e.height/t.height};(n.x||n.y)&&o(n)}}n!==s.current&&(s.current=n)},[t,n,r,i]),(0,H.useEffect)(()=>{a&&o(null)},[a]),a}function Yd(e){let{animateLayoutChanges:t=Ud,attributes:n,disabled:r,data:i,getNewIndex:a=Hd,id:o,strategy:s,resizeObserverConfig:c,transition:l=Wd}=e,{items:u,containerId:d,activeIndex:f,disabled:p,disableTransforms:m,sortedRects:h,overIndex:g,useDragOverlay:_,strategy:v}=(0,H.useContext)(Bd),y=Xd(r,p),b=u.indexOf(o),x=(0,H.useMemo)(()=>({sortable:{containerId:d,index:b,items:u},...i}),[d,i,b,u]),S=(0,H.useMemo)(()=>u.slice(u.indexOf(o)),[u,o]),{rect:C,node:w,isOver:T,setNodeRef:E}=_d({id:o,data:x,disabled:y.droppable,resizeObserverConfig:{updateMeasurementsFor:S,...c}}),{active:D,activatorEvent:O,activeNodeRect:k,attributes:A,setNodeRef:j,listeners:M,isDragging:N,over:P,setActivatorNodeRef:F,transform:I}=pd({id:o,data:x,attributes:{...qd,...n},disabled:y.draggable}),L=bc(E,j),R=!!D,z=R&&!m&&Md(f)&&Md(g),ee=!_&&N,te=z?(ee&&z?I:null)??(s??v)({rects:h,activeNodeRect:k,activeIndex:f,overIndex:g,index:b}):null,B=Md(f)&&Md(g)?a({id:o,items:u,activeIndex:f,overIndex:g}):b,ne=D?.id,V=(0,H.useRef)({activeId:ne,items:u,newIndex:B,containerId:d}),re=u!==V.current.items,U=t({active:D,containerId:d,isDragging:N,isSorting:R,id:o,index:b,items:u,newIndex:V.current.newIndex,previousItems:V.current.items,previousContainerId:V.current.containerId,transition:l,wasDragging:V.current.activeId!=null}),ie=Jd({disabled:!U,index:b,node:w,rect:C});return(0,H.useEffect)(()=>{R&&V.current.newIndex!==B&&(V.current.newIndex=B),d!==V.current.containerId&&(V.current.containerId=d),u!==V.current.items&&(V.current.items=u)},[R,B,d,u]),(0,H.useEffect)(()=>{if(ne===V.current.activeId)return;if(ne!=null&&V.current.activeId==null){V.current.activeId=ne;return}let e=setTimeout(()=>{V.current.activeId=ne},50);return()=>clearTimeout(e)},[ne]),{active:D,activeIndex:f,attributes:A,data:x,rect:C,index:b,newIndex:B,items:u,isOver:T,isSorting:R,isDragging:N,listeners:M,node:w,overIndex:g,over:P,setNodeRef:L,setActivatorNodeRef:F,setDroppableNodeRef:E,setDraggableNodeRef:j,transform:ie??te,transition:ae()};function ae(){if(ie||re&&V.current.newIndex===b)return Kd;if(!(ee&&!Hc(O)||!l)&&(R||U))return Gc.Transition.toString({...l,property:Gd})}}function Xd(e,t){return typeof e==`boolean`?{draggable:e,droppable:!1}:{draggable:e?.draggable??t.draggable,droppable:e?.droppable??t.droppable}}function Zd(e){if(!e)return!1;let t=e.data.current;return!!(t&&`sortable`in t&&typeof t.sortable==`object`&&`containerId`in t.sortable&&`items`in t.sortable&&`index`in t.sortable)}var Qd=[iu.Down,iu.Right,iu.Up,iu.Left],$d=(e,t)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:a,over:o,scrollableAncestors:s}}=t;if(Qd.includes(e.code)){if(e.preventDefault(),!n||!r)return;let t=[];a.getEnabled().forEach(n=>{if(!n||n!=null&&n.disabled)return;let a=i.get(n.id);if(a)switch(e.code){case iu.Down:r.top<a.top&&t.push(n);break;case iu.Up:r.top>a.top&&t.push(n);break;case iu.Left:r.left>a.left&&t.push(n);break;case iu.Right:r.left<a.left&&t.push(n);break}});let c=_l({active:n,collisionRect:r,droppableRects:i,droppableContainers:t,pointerCoordinates:null}),l=ml(c,`id`);if(l===o?.id&&c.length>1&&(l=c[1].id),l!=null){let e=a.get(n.id),t=a.get(l),o=t?i.get(t.id):null,c=t?.node.current;if(c&&o&&e&&t){let n=Pl(c).some((e,t)=>s[t]!==e),i=ef(e,t),a=tf(e,t),l=n||!i?{x:0,y:0}:{x:a?r.width-o.width:0,y:a?r.height-o.height:0},u={x:o.left,y:o.top};return l.x&&l.y?u:Bc(u,l)}}}};function ef(e,t){return!Zd(e)||!Zd(t)?!1:e.data.current.sortable.containerId===t.data.current.sortable.containerId}function tf(e,t){return!Zd(e)||!Zd(t)||!ef(e,t)?!1:e.data.current.sortable.index<t.data.current.sortable.index}var nf=null;function rf(e){nf=e}function af(){if(!nf)throw Error(`getApiBase called with no active project — call setActiveProjectId first`);return`${o}/api/projects/${nf}`}var of=i((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),sf=i(((e,t)=>{t.exports=of()})),Y=sf(),cf=[1e3,2e3,4e3,8e3,16e3],lf=(0,H.createContext)(null);function uf({url:e,children:t}){let[n,r]=(0,H.useState)(`connecting`),i=(0,H.useRef)(new Map),a=(0,H.useRef)(null),o=(0,H.useRef)(0),s=(0,H.useRef)(null);(0,H.useEffect)(()=>{let t=!1;function n(){if(t)return;let l=c(),u=l?new WebSocket(e,[`specrails-desktop`,l]):new WebSocket(e);a.current=u,r(`connecting`),u.onopen=()=>{if(t){u.close();return}o.current=0,r(`connected`)},u.onmessage=e=>{if(t)return;let n;try{n=JSON.parse(e.data)}catch{return}for(let e of i.current.values())try{e(n)}catch(e){console.error(`[useSharedWebSocket] handler threw while processing message`,e)}},u.onclose=()=>{if(t)return;a.current=null;let e=o.current;if(e>=cf.length){r(`connecting`),s.current=setTimeout(n,3e4);return}r(`connecting`);let i=cf[e];o.current+=1,s.current=setTimeout(n,i)}}return n(),()=>{t=!0,s.current&&clearTimeout(s.current);let e=a.current;if(e)if(e.onmessage=null,e.onclose=null,e.onerror=null,e.readyState===WebSocket.CONNECTING)e.onopen=()=>{try{e.close()}catch{}};else{e.onopen=null;try{e.close()}catch{}}}},[e]);let l=(0,H.useCallback)((e,t)=>{i.current.set(e,t)},[]),u=(0,H.useCallback)(e=>{i.current.delete(e)},[]),d=(0,H.useMemo)(()=>({registerHandler:l,unregisterHandler:u,connectionStatus:n}),[l,u,n]);return(0,Y.jsx)(lf.Provider,{value:d,children:t})}function df(){let e=(0,H.useContext)(lf);if(!e)throw Error(`useSharedWebSocket must be used within SharedWebSocketProvider`);return e}function ff(e){return(t={})=>{let n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}function pf(e){return(t,n)=>{let r=n?.context?String(n.context):`standalone`,i;if(r===`formatting`&&e.formattingValues){let t=e.defaultFormattingWidth||e.defaultWidth,r=n?.width?String(n.width):t;i=e.formattingValues[r]||e.formattingValues[t]}else{let t=e.defaultWidth,r=n?.width?String(n.width):e.defaultWidth;i=e.values[r]||e.values[t]}let a=e.argumentCallback?e.argumentCallback(t):t;return i[a]}}function mf(e){return(t,n={})=>{let r=n.width,i=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],a=t.match(i);if(!a)return null;let o=a[0],s=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],c=Array.isArray(s)?gf(s,e=>e.test(o)):hf(s,e=>e.test(o)),l;l=e.valueCallback?e.valueCallback(c):c,l=n.valueCallback?n.valueCallback(l):l;let u=t.slice(o.length);return{value:l,rest:u}}}function hf(e,t){for(let n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function gf(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function _f(e){return(t,n={})=>{let r=t.match(e.matchPattern);if(!r)return null;let i=r[0],a=t.match(e.parsePattern);if(!a)return null;let o=e.valueCallback?e.valueCallback(a[0]):a[0];o=n.valueCallback?n.valueCallback(o):o;let s=t.slice(i.length);return{value:o,rest:s}}}var vf=365.2425,yf=6048e5,bf=864e5,xf=6e4,Sf=36e5,Cf=43200,wf=1440,Tf=3600*24;Tf*7,Tf*vf/12*3;var Ef=Symbol.for(`constructDateFrom`);function Df(e,t){return typeof e==`function`?e(t):e&&typeof e==`object`&&Ef in e?e[Ef](t):e instanceof Date?new e.constructor(t):new Date(t)}function Of(e,...t){let n=Df.bind(null,e||t.find(e=>typeof e==`object`));return t.map(n)}var kf={};function Af(){return kf}function jf(e,t){return Df(t||e,e)}function Mf(e,t){let n=Af(),r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,i=jf(e,t?.in),a=i.getDay(),o=(a<r?7:0)+a-r;return i.setDate(i.getDate()-o),i.setHours(0,0,0,0),i}function Nf(e,t,n){let[r,i]=Of(n?.in,e,t);return+Mf(r,n)==+Mf(i,n)}var Pf={lessThanXSeconds:{standalone:{one:`weniger als 1 Sekunde`,other:`weniger als {{count}} Sekunden`},withPreposition:{one:`weniger als 1 Sekunde`,other:`weniger als {{count}} Sekunden`}},xSeconds:{standalone:{one:`1 Sekunde`,other:`{{count}} Sekunden`},withPreposition:{one:`1 Sekunde`,other:`{{count}} Sekunden`}},halfAMinute:{standalone:`eine halbe Minute`,withPreposition:`einer halben Minute`},lessThanXMinutes:{standalone:{one:`weniger als 1 Minute`,other:`weniger als {{count}} Minuten`},withPreposition:{one:`weniger als 1 Minute`,other:`weniger als {{count}} Minuten`}},xMinutes:{standalone:{one:`1 Minute`,other:`{{count}} Minuten`},withPreposition:{one:`1 Minute`,other:`{{count}} Minuten`}},aboutXHours:{standalone:{one:`etwa 1 Stunde`,other:`etwa {{count}} Stunden`},withPreposition:{one:`etwa 1 Stunde`,other:`etwa {{count}} Stunden`}},xHours:{standalone:{one:`1 Stunde`,other:`{{count}} Stunden`},withPreposition:{one:`1 Stunde`,other:`{{count}} Stunden`}},xDays:{standalone:{one:`1 Tag`,other:`{{count}} Tage`},withPreposition:{one:`1 Tag`,other:`{{count}} Tagen`}},aboutXWeeks:{standalone:{one:`etwa 1 Woche`,other:`etwa {{count}} Wochen`},withPreposition:{one:`etwa 1 Woche`,other:`etwa {{count}} Wochen`}},xWeeks:{standalone:{one:`1 Woche`,other:`{{count}} Wochen`},withPreposition:{one:`1 Woche`,other:`{{count}} Wochen`}},aboutXMonths:{standalone:{one:`etwa 1 Monat`,other:`etwa {{count}} Monate`},withPreposition:{one:`etwa 1 Monat`,other:`etwa {{count}} Monaten`}},xMonths:{standalone:{one:`1 Monat`,other:`{{count}} Monate`},withPreposition:{one:`1 Monat`,other:`{{count}} Monaten`}},aboutXYears:{standalone:{one:`etwa 1 Jahr`,other:`etwa {{count}} Jahre`},withPreposition:{one:`etwa 1 Jahr`,other:`etwa {{count}} Jahren`}},xYears:{standalone:{one:`1 Jahr`,other:`{{count}} Jahre`},withPreposition:{one:`1 Jahr`,other:`{{count}} Jahren`}},overXYears:{standalone:{one:`mehr als 1 Jahr`,other:`mehr als {{count}} Jahre`},withPreposition:{one:`mehr als 1 Jahr`,other:`mehr als {{count}} Jahren`}},almostXYears:{standalone:{one:`fast 1 Jahr`,other:`fast {{count}} Jahre`},withPreposition:{one:`fast 1 Jahr`,other:`fast {{count}} Jahren`}}},Ff=(e,t,n)=>{let r,i=n?.addSuffix?Pf[e].withPreposition:Pf[e].standalone;return r=typeof i==`string`?i:t===1?i.one:i.other.replace(`{{count}}`,String(t)),n?.addSuffix?n.comparison&&n.comparison>0?`in `+r:`vor `+r:r},If={date:ff({formats:{full:`EEEE, do MMMM y`,long:`do MMMM y`,medium:`do MMM y`,short:`dd.MM.y`},defaultWidth:`full`}),time:ff({formats:{full:`HH:mm:ss zzzz`,long:`HH:mm:ss z`,medium:`HH:mm:ss`,short:`HH:mm`},defaultWidth:`full`}),dateTime:ff({formats:{full:`{{date}} 'um' {{time}}`,long:`{{date}} 'um' {{time}}`,medium:`{{date}} {{time}}`,short:`{{date}} {{time}}`},defaultWidth:`full`})},Lf={lastWeek:`'letzten' eeee 'um' p`,yesterday:`'gestern um' p`,today:`'heute um' p`,tomorrow:`'morgen um' p`,nextWeek:`eeee 'um' p`,other:`P`},Rf=(e,t,n,r)=>Lf[e],zf={narrow:[`v.Chr.`,`n.Chr.`],abbreviated:[`v.Chr.`,`n.Chr.`],wide:[`vor Christus`,`nach Christus`]},Bf={narrow:[`1`,`2`,`3`,`4`],abbreviated:[`Q1`,`Q2`,`Q3`,`Q4`],wide:[`1. Quartal`,`2. Quartal`,`3. Quartal`,`4. Quartal`]},Vf={narrow:[`J`,`F`,`M`,`A`,`M`,`J`,`J`,`A`,`S`,`O`,`N`,`D`],abbreviated:[`Jan`,`Feb`,`Mär`,`Apr`,`Mai`,`Jun`,`Jul`,`Aug`,`Sep`,`Okt`,`Nov`,`Dez`],wide:[`Januar`,`Februar`,`März`,`April`,`Mai`,`Juni`,`Juli`,`August`,`September`,`Oktober`,`November`,`Dezember`]},Hf={narrow:Vf.narrow,abbreviated:[`Jan.`,`Feb.`,`März`,`Apr.`,`Mai`,`Juni`,`Juli`,`Aug.`,`Sep.`,`Okt.`,`Nov.`,`Dez.`],wide:Vf.wide},Uf={code:`de`,formatDistance:Ff,formatLong:If,formatRelative:Rf,localize:{ordinalNumber:e=>Number(e)+`.`,era:pf({values:zf,defaultWidth:`wide`}),quarter:pf({values:Bf,defaultWidth:`wide`,argumentCallback:e=>e-1}),month:pf({values:Vf,formattingValues:Hf,defaultWidth:`wide`}),day:pf({values:{narrow:[`S`,`M`,`D`,`M`,`D`,`F`,`S`],short:[`So`,`Mo`,`Di`,`Mi`,`Do`,`Fr`,`Sa`],abbreviated:[`So.`,`Mo.`,`Di.`,`Mi.`,`Do.`,`Fr.`,`Sa.`],wide:[`Sonntag`,`Montag`,`Dienstag`,`Mittwoch`,`Donnerstag`,`Freitag`,`Samstag`]},defaultWidth:`wide`}),dayPeriod:pf({values:{narrow:{am:`vm.`,pm:`nm.`,midnight:`Mitternacht`,noon:`Mittag`,morning:`Morgen`,afternoon:`Nachm.`,evening:`Abend`,night:`Nacht`},abbreviated:{am:`vorm.`,pm:`nachm.`,midnight:`Mitternacht`,noon:`Mittag`,morning:`Morgen`,afternoon:`Nachmittag`,evening:`Abend`,night:`Nacht`},wide:{am:`vormittags`,pm:`nachmittags`,midnight:`Mitternacht`,noon:`Mittag`,morning:`Morgen`,afternoon:`Nachmittag`,evening:`Abend`,night:`Nacht`}},defaultWidth:`wide`,formattingValues:{narrow:{am:`vm.`,pm:`nm.`,midnight:`Mitternacht`,noon:`Mittag`,morning:`morgens`,afternoon:`nachm.`,evening:`abends`,night:`nachts`},abbreviated:{am:`vorm.`,pm:`nachm.`,midnight:`Mitternacht`,noon:`Mittag`,morning:`morgens`,afternoon:`nachmittags`,evening:`abends`,night:`nachts`},wide:{am:`vormittags`,pm:`nachmittags`,midnight:`Mitternacht`,noon:`Mittag`,morning:`morgens`,afternoon:`nachmittags`,evening:`abends`,night:`nachts`}},defaultFormattingWidth:`wide`})},match:{ordinalNumber:_f({matchPattern:/^(\d+)(\.)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e)}),era:mf({matchPatterns:{narrow:/^(v\.? ?Chr\.?|n\.? ?Chr\.?)/i,abbreviated:/^(v\.? ?Chr\.?|n\.? ?Chr\.?)/i,wide:/^(vor Christus|vor unserer Zeitrechnung|nach Christus|unserer Zeitrechnung)/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/^v/i,/^n/i]},defaultParseWidth:`any`}),quarter:mf({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](\.)? Quartal/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:`any`,valueCallback:e=>e+1}),month:mf({matchPatterns:{narrow:/^[jfmasond]/i,abbreviated:/^(j[aä]n|feb|mär[z]?|apr|mai|jun[i]?|jul[i]?|aug|sep|okt|nov|dez)\.?/i,wide:/^(januar|februar|märz|april|mai|juni|juli|august|september|oktober|november|dezember)/i},defaultMatchWidth:`wide`,parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^j[aä]/i,/^f/i,/^mär/i,/^ap/i,/^mai/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},defaultParseWidth:`any`}),day:mf({matchPatterns:{narrow:/^[smdmf]/i,short:/^(so|mo|di|mi|do|fr|sa)/i,abbreviated:/^(son?|mon?|die?|mit?|don?|fre?|sam?)\.?/i,wide:/^(sonntag|montag|dienstag|mittwoch|donnerstag|freitag|samstag)/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/^so/i,/^mo/i,/^di/i,/^mi/i,/^do/i,/^f/i,/^sa/i]},defaultParseWidth:`any`}),dayPeriod:mf({matchPatterns:{narrow:/^(vm\.?|nm\.?|Mitternacht|Mittag|morgens|nachm\.?|abends|nachts)/i,abbreviated:/^(vorm\.?|nachm\.?|Mitternacht|Mittag|morgens|nachm\.?|abends|nachts)/i,wide:/^(vormittags|nachmittags|Mitternacht|Mittag|morgens|nachmittags|abends|nachts)/i},defaultMatchWidth:`wide`,parsePatterns:{any:{am:/^v/i,pm:/^n/i,midnight:/^Mitte/i,noon:/^Mitta/i,morning:/morgens/i,afternoon:/nachmittags/i,evening:/abends/i,night:/nachts/i}},defaultParseWidth:`any`})},options:{weekStartsOn:1,firstWeekContainsDate:4}},Wf={lessThanXSeconds:{one:`less than a second`,other:`less than {{count}} seconds`},xSeconds:{one:`1 second`,other:`{{count}} seconds`},halfAMinute:`half a minute`,lessThanXMinutes:{one:`less than a minute`,other:`less than {{count}} minutes`},xMinutes:{one:`1 minute`,other:`{{count}} minutes`},aboutXHours:{one:`about 1 hour`,other:`about {{count}} hours`},xHours:{one:`1 hour`,other:`{{count}} hours`},xDays:{one:`1 day`,other:`{{count}} days`},aboutXWeeks:{one:`about 1 week`,other:`about {{count}} weeks`},xWeeks:{one:`1 week`,other:`{{count}} weeks`},aboutXMonths:{one:`about 1 month`,other:`about {{count}} months`},xMonths:{one:`1 month`,other:`{{count}} months`},aboutXYears:{one:`about 1 year`,other:`about {{count}} years`},xYears:{one:`1 year`,other:`{{count}} years`},overXYears:{one:`over 1 year`,other:`over {{count}} years`},almostXYears:{one:`almost 1 year`,other:`almost {{count}} years`}},Gf=(e,t,n)=>{let r,i=Wf[e];return r=typeof i==`string`?i:t===1?i.one:i.other.replace(`{{count}}`,t.toString()),n?.addSuffix?n.comparison&&n.comparison>0?`in `+r:r+` ago`:r},Kf={lastWeek:`'last' eeee 'at' p`,yesterday:`'yesterday at' p`,today:`'today at' p`,tomorrow:`'tomorrow at' p`,nextWeek:`eeee 'at' p`,other:`P`},qf=(e,t,n,r)=>Kf[e],Jf={ordinalNumber:(e,t)=>{let n=Number(e),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+`st`;case 2:return n+`nd`;case 3:return n+`rd`}return n+`th`},era:pf({values:{narrow:[`B`,`A`],abbreviated:[`BC`,`AD`],wide:[`Before Christ`,`Anno Domini`]},defaultWidth:`wide`}),quarter:pf({values:{narrow:[`1`,`2`,`3`,`4`],abbreviated:[`Q1`,`Q2`,`Q3`,`Q4`],wide:[`1st quarter`,`2nd quarter`,`3rd quarter`,`4th quarter`]},defaultWidth:`wide`,argumentCallback:e=>e-1}),month:pf({values:{narrow:[`J`,`F`,`M`,`A`,`M`,`J`,`J`,`A`,`S`,`O`,`N`,`D`],abbreviated:[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],wide:[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`]},defaultWidth:`wide`}),day:pf({values:{narrow:[`S`,`M`,`T`,`W`,`T`,`F`,`S`],short:[`Su`,`Mo`,`Tu`,`We`,`Th`,`Fr`,`Sa`],abbreviated:[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],wide:[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`]},defaultWidth:`wide`}),dayPeriod:pf({values:{narrow:{am:`a`,pm:`p`,midnight:`mi`,noon:`n`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},abbreviated:{am:`AM`,pm:`PM`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},wide:{am:`a.m.`,pm:`p.m.`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`}},defaultWidth:`wide`,formattingValues:{narrow:{am:`a`,pm:`p`,midnight:`mi`,noon:`n`,morning:`in the morning`,afternoon:`in the afternoon`,evening:`in the evening`,night:`at night`},abbreviated:{am:`AM`,pm:`PM`,midnight:`midnight`,noon:`noon`,morning:`in the morning`,afternoon:`in the afternoon`,evening:`in the evening`,night:`at night`},wide:{am:`a.m.`,pm:`p.m.`,midnight:`midnight`,noon:`noon`,morning:`in the morning`,afternoon:`in the afternoon`,evening:`in the evening`,night:`at night`}},defaultFormattingWidth:`wide`})},Yf={ordinalNumber:_f({matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:mf({matchPatterns:{narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/^b/i,/^(a|c)/i]},defaultParseWidth:`any`}),quarter:mf({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:`any`,valueCallback:e=>e+1}),month:mf({matchPatterns:{narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},defaultMatchWidth:`wide`,parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},defaultParseWidth:`any`}),day:mf({matchPatterns:{narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},defaultMatchWidth:`wide`,parsePatterns:{narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},defaultParseWidth:`any`}),dayPeriod:mf({matchPatterns:{narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},defaultMatchWidth:`any`,parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},defaultParseWidth:`any`})},Xf={code:`en-US`,formatDistance:Gf,formatLong:{date:ff({formats:{full:`EEEE, MMMM do, y`,long:`MMMM do, y`,medium:`MMM d, y`,short:`MM/dd/yyyy`},defaultWidth:`full`}),time:ff({formats:{full:`h:mm:ss a zzzz`,long:`h:mm:ss a z`,medium:`h:mm:ss a`,short:`h:mm a`},defaultWidth:`full`}),dateTime:ff({formats:{full:`{{date}} 'at' {{time}}`,long:`{{date}} 'at' {{time}}`,medium:`{{date}}, {{time}}`,short:`{{date}}, {{time}}`},defaultWidth:`full`})},formatRelative:qf,localize:Jf,match:Yf,options:{weekStartsOn:0,firstWeekContainsDate:1}},Zf={lessThanXSeconds:{one:`menos de un segundo`,other:`menos de {{count}} segundos`},xSeconds:{one:`1 segundo`,other:`{{count}} segundos`},halfAMinute:`medio minuto`,lessThanXMinutes:{one:`menos de un minuto`,other:`menos de {{count}} minutos`},xMinutes:{one:`1 minuto`,other:`{{count}} minutos`},aboutXHours:{one:`alrededor de 1 hora`,other:`alrededor de {{count}} horas`},xHours:{one:`1 hora`,other:`{{count}} horas`},xDays:{one:`1 día`,other:`{{count}} días`},aboutXWeeks:{one:`alrededor de 1 semana`,other:`alrededor de {{count}} semanas`},xWeeks:{one:`1 semana`,other:`{{count}} semanas`},aboutXMonths:{one:`alrededor de 1 mes`,other:`alrededor de {{count}} meses`},xMonths:{one:`1 mes`,other:`{{count}} meses`},aboutXYears:{one:`alrededor de 1 año`,other:`alrededor de {{count}} años`},xYears:{one:`1 año`,other:`{{count}} años`},overXYears:{one:`más de 1 año`,other:`más de {{count}} años`},almostXYears:{one:`casi 1 año`,other:`casi {{count}} años`}},Qf=(e,t,n)=>{let r,i=Zf[e];return r=typeof i==`string`?i:t===1?i.one:i.other.replace(`{{count}}`,t.toString()),n?.addSuffix?n.comparison&&n.comparison>0?`en `+r:`hace `+r:r},$f={date:ff({formats:{full:`EEEE, d 'de' MMMM 'de' y`,long:`d 'de' MMMM 'de' y`,medium:`d MMM y`,short:`dd/MM/y`},defaultWidth:`full`}),time:ff({formats:{full:`HH:mm:ss zzzz`,long:`HH:mm:ss z`,medium:`HH:mm:ss`,short:`HH:mm`},defaultWidth:`full`}),dateTime:ff({formats:{full:`{{date}} 'a las' {{time}}`,long:`{{date}} 'a las' {{time}}`,medium:`{{date}}, {{time}}`,short:`{{date}}, {{time}}`},defaultWidth:`full`})},ep={lastWeek:`'el' eeee 'pasado a la' p`,yesterday:`'ayer a la' p`,today:`'hoy a la' p`,tomorrow:`'mañana a la' p`,nextWeek:`eeee 'a la' p`,other:`P`},tp={lastWeek:`'el' eeee 'pasado a las' p`,yesterday:`'ayer a las' p`,today:`'hoy a las' p`,tomorrow:`'mañana a las' p`,nextWeek:`eeee 'a las' p`,other:`P`},np={code:`es`,formatDistance:Qf,formatLong:$f,formatRelative:(e,t,n,r)=>t.getHours()===1?ep[e]:tp[e],localize:{ordinalNumber:(e,t)=>Number(e)+`º`,era:pf({values:{narrow:[`AC`,`DC`],abbreviated:[`AC`,`DC`],wide:[`antes de cristo`,`después de cristo`]},defaultWidth:`wide`}),quarter:pf({values:{narrow:[`1`,`2`,`3`,`4`],abbreviated:[`T1`,`T2`,`T3`,`T4`],wide:[`1º trimestre`,`2º trimestre`,`3º trimestre`,`4º trimestre`]},defaultWidth:`wide`,argumentCallback:e=>Number(e)-1}),month:pf({values:{narrow:[`e`,`f`,`m`,`a`,`m`,`j`,`j`,`a`,`s`,`o`,`n`,`d`],abbreviated:[`ene`,`feb`,`mar`,`abr`,`may`,`jun`,`jul`,`ago`,`sep`,`oct`,`nov`,`dic`],wide:[`enero`,`febrero`,`marzo`,`abril`,`mayo`,`junio`,`julio`,`agosto`,`septiembre`,`octubre`,`noviembre`,`diciembre`]},defaultWidth:`wide`}),day:pf({values:{narrow:[`d`,`l`,`m`,`m`,`j`,`v`,`s`],short:[`do`,`lu`,`ma`,`mi`,`ju`,`vi`,`sá`],abbreviated:[`dom`,`lun`,`mar`,`mié`,`jue`,`vie`,`sáb`],wide:[`domingo`,`lunes`,`martes`,`miércoles`,`jueves`,`viernes`,`sábado`]},defaultWidth:`wide`}),dayPeriod:pf({values:{narrow:{am:`a`,pm:`p`,midnight:`mn`,noon:`md`,morning:`mañana`,afternoon:`tarde`,evening:`tarde`,night:`noche`},abbreviated:{am:`AM`,pm:`PM`,midnight:`medianoche`,noon:`mediodia`,morning:`mañana`,afternoon:`tarde`,evening:`tarde`,night:`noche`},wide:{am:`a.m.`,pm:`p.m.`,midnight:`medianoche`,noon:`mediodia`,morning:`mañana`,afternoon:`tarde`,evening:`tarde`,night:`noche`}},defaultWidth:`wide`,formattingValues:{narrow:{am:`a`,pm:`p`,midnight:`mn`,noon:`md`,morning:`de la mañana`,afternoon:`de la tarde`,evening:`de la tarde`,night:`de la noche`},abbreviated:{am:`AM`,pm:`PM`,midnight:`medianoche`,noon:`mediodia`,morning:`de la mañana`,afternoon:`de la tarde`,evening:`de la tarde`,night:`de la noche`},wide:{am:`a.m.`,pm:`p.m.`,midnight:`medianoche`,noon:`mediodia`,morning:`de la mañana`,afternoon:`de la tarde`,evening:`de la tarde`,night:`de la noche`}},defaultFormattingWidth:`wide`})},match:{ordinalNumber:_f({matchPattern:/^(\d+)(º)?/i,parsePattern:/\d+/i,valueCallback:function(e){return parseInt(e,10)}}),era:mf({matchPatterns:{narrow:/^(ac|dc|a|d)/i,abbreviated:/^(a\.?\s?c\.?|a\.?\s?e\.?\s?c\.?|d\.?\s?c\.?|e\.?\s?c\.?)/i,wide:/^(antes de cristo|antes de la era com[uú]n|despu[eé]s de cristo|era com[uú]n)/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/^ac/i,/^dc/i],wide:[/^(antes de cristo|antes de la era com[uú]n)/i,/^(despu[eé]s de cristo|era com[uú]n)/i]},defaultParseWidth:`any`}),quarter:mf({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^T[1234]/i,wide:/^[1234](º)? trimestre/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:`any`,valueCallback:e=>e+1}),month:mf({matchPatterns:{narrow:/^[efmajsond]/i,abbreviated:/^(ene|feb|mar|abr|may|jun|jul|ago|sep|oct|nov|dic)/i,wide:/^(enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre)/i},defaultMatchWidth:`wide`,parsePatterns:{narrow:[/^e/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^en/i,/^feb/i,/^mar/i,/^abr/i,/^may/i,/^jun/i,/^jul/i,/^ago/i,/^sep/i,/^oct/i,/^nov/i,/^dic/i]},defaultParseWidth:`any`}),day:mf({matchPatterns:{narrow:/^[dlmjvs]/i,short:/^(do|lu|ma|mi|ju|vi|s[áa])/i,abbreviated:/^(dom|lun|mar|mi[ée]|jue|vie|s[áa]b)/i,wide:/^(domingo|lunes|martes|mi[ée]rcoles|jueves|viernes|s[áa]bado)/i},defaultMatchWidth:`wide`,parsePatterns:{narrow:[/^d/i,/^l/i,/^m/i,/^m/i,/^j/i,/^v/i,/^s/i],any:[/^do/i,/^lu/i,/^ma/i,/^mi/i,/^ju/i,/^vi/i,/^sa/i]},defaultParseWidth:`any`}),dayPeriod:mf({matchPatterns:{narrow:/^(a|p|mn|md|(de la|a las) (mañana|tarde|noche))/i,any:/^([ap]\.?\s?m\.?|medianoche|mediodia|(de la|a las) (mañana|tarde|noche))/i},defaultMatchWidth:`any`,parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mn/i,noon:/^md/i,morning:/mañana/i,afternoon:/tarde/i,evening:/tarde/i,night:/noche/i}},defaultParseWidth:`any`})},options:{weekStartsOn:1,firstWeekContainsDate:1}},rp={lessThanXSeconds:{one:`moins d’une seconde`,other:`moins de {{count}} secondes`},xSeconds:{one:`1 seconde`,other:`{{count}} secondes`},halfAMinute:`30 secondes`,lessThanXMinutes:{one:`moins d’une minute`,other:`moins de {{count}} minutes`},xMinutes:{one:`1 minute`,other:`{{count}} minutes`},aboutXHours:{one:`environ 1 heure`,other:`environ {{count}} heures`},xHours:{one:`1 heure`,other:`{{count}} heures`},xDays:{one:`1 jour`,other:`{{count}} jours`},aboutXWeeks:{one:`environ 1 semaine`,other:`environ {{count}} semaines`},xWeeks:{one:`1 semaine`,other:`{{count}} semaines`},aboutXMonths:{one:`environ 1 mois`,other:`environ {{count}} mois`},xMonths:{one:`1 mois`,other:`{{count}} mois`},aboutXYears:{one:`environ 1 an`,other:`environ {{count}} ans`},xYears:{one:`1 an`,other:`{{count}} ans`},overXYears:{one:`plus d’un an`,other:`plus de {{count}} ans`},almostXYears:{one:`presqu’un an`,other:`presque {{count}} ans`}},ip=(e,t,n)=>{let r,i=rp[e];return r=typeof i==`string`?i:t===1?i.one:i.other.replace(`{{count}}`,String(t)),n?.addSuffix?n.comparison&&n.comparison>0?`dans `+r:`il y a `+r:r},ap={date:ff({formats:{full:`EEEE d MMMM y`,long:`d MMMM y`,medium:`d MMM y`,short:`dd/MM/y`},defaultWidth:`full`}),time:ff({formats:{full:`HH:mm:ss zzzz`,long:`HH:mm:ss z`,medium:`HH:mm:ss`,short:`HH:mm`},defaultWidth:`full`}),dateTime:ff({formats:{full:`{{date}} 'à' {{time}}`,long:`{{date}} 'à' {{time}}`,medium:`{{date}}, {{time}}`,short:`{{date}}, {{time}}`},defaultWidth:`full`})},op={lastWeek:`eeee 'dernier à' p`,yesterday:`'hier à' p`,today:`'aujourd’hui à' p`,tomorrow:`'demain à' p'`,nextWeek:`eeee 'prochain à' p`,other:`P`},sp=(e,t,n,r)=>op[e],cp={narrow:[`av. J.-C`,`ap. J.-C`],abbreviated:[`av. J.-C`,`ap. J.-C`],wide:[`avant Jésus-Christ`,`après Jésus-Christ`]},lp={narrow:[`T1`,`T2`,`T3`,`T4`],abbreviated:[`1er trim.`,`2ème trim.`,`3ème trim.`,`4ème trim.`],wide:[`1er trimestre`,`2ème trimestre`,`3ème trimestre`,`4ème trimestre`]},up={narrow:[`J`,`F`,`M`,`A`,`M`,`J`,`J`,`A`,`S`,`O`,`N`,`D`],abbreviated:[`janv.`,`févr.`,`mars`,`avr.`,`mai`,`juin`,`juil.`,`août`,`sept.`,`oct.`,`nov.`,`déc.`],wide:[`janvier`,`février`,`mars`,`avril`,`mai`,`juin`,`juillet`,`août`,`septembre`,`octobre`,`novembre`,`décembre`]},dp={narrow:[`D`,`L`,`M`,`M`,`J`,`V`,`S`],short:[`di`,`lu`,`ma`,`me`,`je`,`ve`,`sa`],abbreviated:[`dim.`,`lun.`,`mar.`,`mer.`,`jeu.`,`ven.`,`sam.`],wide:[`dimanche`,`lundi`,`mardi`,`mercredi`,`jeudi`,`vendredi`,`samedi`]},fp={narrow:{am:`AM`,pm:`PM`,midnight:`minuit`,noon:`midi`,morning:`mat.`,afternoon:`ap.m.`,evening:`soir`,night:`mat.`},abbreviated:{am:`AM`,pm:`PM`,midnight:`minuit`,noon:`midi`,morning:`matin`,afternoon:`après-midi`,evening:`soir`,night:`matin`},wide:{am:`AM`,pm:`PM`,midnight:`minuit`,noon:`midi`,morning:`du matin`,afternoon:`de l’après-midi`,evening:`du soir`,night:`du matin`}},pp=(e,t)=>{let n=Number(e),r=t?.unit;if(n===0)return`0`;let i=[`year`,`week`,`hour`,`minute`,`second`],a;return a=n===1?r&&i.includes(r)?`ère`:`er`:`ème`,n+a},mp=[`MMM`,`MMMM`],hp={code:`fr`,formatDistance:ip,formatLong:ap,formatRelative:sp,localize:{preprocessor:(e,t)=>e.getDate()===1||!t.some(e=>e.isToken&&mp.includes(e.value))?t:t.map(e=>e.isToken&&e.value===`do`?{isToken:!0,value:`d`}:e),ordinalNumber:pp,era:pf({values:cp,defaultWidth:`wide`}),quarter:pf({values:lp,defaultWidth:`wide`,argumentCallback:e=>e-1}),month:pf({values:up,defaultWidth:`wide`}),day:pf({values:dp,defaultWidth:`wide`}),dayPeriod:pf({values:fp,defaultWidth:`wide`})},match:{ordinalNumber:_f({matchPattern:/^(\d+)(ième|ère|ème|er|e)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e)}),era:mf({matchPatterns:{narrow:/^(av\.J\.C|ap\.J\.C|ap\.J\.-C)/i,abbreviated:/^(av\.J\.-C|av\.J-C|apr\.J\.-C|apr\.J-C|ap\.J-C)/i,wide:/^(avant Jésus-Christ|après Jésus-Christ)/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/^av/i,/^ap/i]},defaultParseWidth:`any`}),quarter:mf({matchPatterns:{narrow:/^T?[1234]/i,abbreviated:/^[1234](er|ème|e)? trim\.?/i,wide:/^[1234](er|ème|e)? trimestre/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:`any`,valueCallback:e=>e+1}),month:mf({matchPatterns:{narrow:/^[jfmasond]/i,abbreviated:/^(janv|févr|mars|avr|mai|juin|juill|juil|août|sept|oct|nov|déc)\.?/i,wide:/^(janvier|février|mars|avril|mai|juin|juillet|août|septembre|octobre|novembre|décembre)/i},defaultMatchWidth:`wide`,parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^av/i,/^ma/i,/^juin/i,/^juil/i,/^ao/i,/^s/i,/^o/i,/^n/i,/^d/i]},defaultParseWidth:`any`}),day:mf({matchPatterns:{narrow:/^[lmjvsd]/i,short:/^(di|lu|ma|me|je|ve|sa)/i,abbreviated:/^(dim|lun|mar|mer|jeu|ven|sam)\.?/i,wide:/^(dimanche|lundi|mardi|mercredi|jeudi|vendredi|samedi)/i},defaultMatchWidth:`wide`,parsePatterns:{narrow:[/^d/i,/^l/i,/^m/i,/^m/i,/^j/i,/^v/i,/^s/i],any:[/^di/i,/^lu/i,/^ma/i,/^me/i,/^je/i,/^ve/i,/^sa/i]},defaultParseWidth:`any`}),dayPeriod:mf({matchPatterns:{narrow:/^(a|p|minuit|midi|mat\.?|ap\.?m\.?|soir|nuit)/i,any:/^([ap]\.?\s?m\.?|du matin|de l'après[-\s]midi|du soir|de la nuit)/i},defaultMatchWidth:`any`,parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^min/i,noon:/^mid/i,morning:/mat/i,afternoon:/ap/i,evening:/soir/i,night:/nuit/i}},defaultParseWidth:`any`})},options:{weekStartsOn:1,firstWeekContainsDate:4}},gp={lessThanXSeconds:{one:`meno di un secondo`,other:`meno di {{count}} secondi`},xSeconds:{one:`un secondo`,other:`{{count}} secondi`},halfAMinute:`alcuni secondi`,lessThanXMinutes:{one:`meno di un minuto`,other:`meno di {{count}} minuti`},xMinutes:{one:`un minuto`,other:`{{count}} minuti`},aboutXHours:{one:`circa un'ora`,other:`circa {{count}} ore`},xHours:{one:`un'ora`,other:`{{count}} ore`},xDays:{one:`un giorno`,other:`{{count}} giorni`},aboutXWeeks:{one:`circa una settimana`,other:`circa {{count}} settimane`},xWeeks:{one:`una settimana`,other:`{{count}} settimane`},aboutXMonths:{one:`circa un mese`,other:`circa {{count}} mesi`},xMonths:{one:`un mese`,other:`{{count}} mesi`},aboutXYears:{one:`circa un anno`,other:`circa {{count}} anni`},xYears:{one:`un anno`,other:`{{count}} anni`},overXYears:{one:`più di un anno`,other:`più di {{count}} anni`},almostXYears:{one:`quasi un anno`,other:`quasi {{count}} anni`}},_p=(e,t,n)=>{let r,i=gp[e];return r=typeof i==`string`?i:t===1?i.one:i.other.replace(`{{count}}`,t.toString()),n?.addSuffix?n.comparison&&n.comparison>0?`tra `+r:r+` fa`:r},vp={date:ff({formats:{full:`EEEE d MMMM y`,long:`d MMMM y`,medium:`d MMM y`,short:`dd/MM/y`},defaultWidth:`full`}),time:ff({formats:{full:`HH:mm:ss zzzz`,long:`HH:mm:ss z`,medium:`HH:mm:ss`,short:`HH:mm`},defaultWidth:`full`}),dateTime:ff({formats:{full:`{{date}} {{time}}`,long:`{{date}} {{time}}`,medium:`{{date}} {{time}}`,short:`{{date}} {{time}}`},defaultWidth:`full`})},yp=[`domenica`,`lunedì`,`martedì`,`mercoledì`,`giovedì`,`venerdì`,`sabato`];function bp(e){switch(e){case 0:return`'domenica scorsa alle' p`;default:return`'`+yp[e]+` scorso alle' p`}}function xp(e){return`'`+yp[e]+` alle' p`}function Sp(e){switch(e){case 0:return`'domenica prossima alle' p`;default:return`'`+yp[e]+` prossimo alle' p`}}var Cp={lastWeek:(e,t,n)=>{let r=e.getDay();return Nf(e,t,n)?xp(r):bp(r)},yesterday:`'ieri alle' p`,today:`'oggi alle' p`,tomorrow:`'domani alle' p`,nextWeek:(e,t,n)=>{let r=e.getDay();return Nf(e,t,n)?xp(r):Sp(r)},other:`P`},wp={code:`it`,formatDistance:_p,formatLong:vp,formatRelative:(e,t,n,r)=>{let i=Cp[e];return typeof i==`function`?i(t,n,r):i},localize:{ordinalNumber:(e,t)=>{let n=Number(e);return String(n)},era:pf({values:{narrow:[`aC`,`dC`],abbreviated:[`a.C.`,`d.C.`],wide:[`avanti Cristo`,`dopo Cristo`]},defaultWidth:`wide`}),quarter:pf({values:{narrow:[`1`,`2`,`3`,`4`],abbreviated:[`T1`,`T2`,`T3`,`T4`],wide:[`1º trimestre`,`2º trimestre`,`3º trimestre`,`4º trimestre`]},defaultWidth:`wide`,argumentCallback:e=>e-1}),month:pf({values:{narrow:[`G`,`F`,`M`,`A`,`M`,`G`,`L`,`A`,`S`,`O`,`N`,`D`],abbreviated:[`gen`,`feb`,`mar`,`apr`,`mag`,`giu`,`lug`,`ago`,`set`,`ott`,`nov`,`dic`],wide:[`gennaio`,`febbraio`,`marzo`,`aprile`,`maggio`,`giugno`,`luglio`,`agosto`,`settembre`,`ottobre`,`novembre`,`dicembre`]},defaultWidth:`wide`}),day:pf({values:{narrow:[`D`,`L`,`M`,`M`,`G`,`V`,`S`],short:[`dom`,`lun`,`mar`,`mer`,`gio`,`ven`,`sab`],abbreviated:[`dom`,`lun`,`mar`,`mer`,`gio`,`ven`,`sab`],wide:[`domenica`,`lunedì`,`martedì`,`mercoledì`,`giovedì`,`venerdì`,`sabato`]},defaultWidth:`wide`}),dayPeriod:pf({values:{narrow:{am:`m.`,pm:`p.`,midnight:`mezzanotte`,noon:`mezzogiorno`,morning:`mattina`,afternoon:`pomeriggio`,evening:`sera`,night:`notte`},abbreviated:{am:`AM`,pm:`PM`,midnight:`mezzanotte`,noon:`mezzogiorno`,morning:`mattina`,afternoon:`pomeriggio`,evening:`sera`,night:`notte`},wide:{am:`AM`,pm:`PM`,midnight:`mezzanotte`,noon:`mezzogiorno`,morning:`mattina`,afternoon:`pomeriggio`,evening:`sera`,night:`notte`}},defaultWidth:`wide`,formattingValues:{narrow:{am:`m.`,pm:`p.`,midnight:`mezzanotte`,noon:`mezzogiorno`,morning:`di mattina`,afternoon:`del pomeriggio`,evening:`di sera`,night:`di notte`},abbreviated:{am:`AM`,pm:`PM`,midnight:`mezzanotte`,noon:`mezzogiorno`,morning:`di mattina`,afternoon:`del pomeriggio`,evening:`di sera`,night:`di notte`},wide:{am:`AM`,pm:`PM`,midnight:`mezzanotte`,noon:`mezzogiorno`,morning:`di mattina`,afternoon:`del pomeriggio`,evening:`di sera`,night:`di notte`}},defaultFormattingWidth:`wide`})},match:{ordinalNumber:_f({matchPattern:/^(\d+)(º)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:mf({matchPatterns:{narrow:/^(aC|dC)/i,abbreviated:/^(a\.?\s?C\.?|a\.?\s?e\.?\s?v\.?|d\.?\s?C\.?|e\.?\s?v\.?)/i,wide:/^(avanti Cristo|avanti Era Volgare|dopo Cristo|Era Volgare)/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/^a/i,/^(d|e)/i]},defaultParseWidth:`any`}),quarter:mf({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^t[1234]/i,wide:/^[1234](º)? trimestre/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:`any`,valueCallback:e=>e+1}),month:mf({matchPatterns:{narrow:/^[gfmalsond]/i,abbreviated:/^(gen|feb|mar|apr|mag|giu|lug|ago|set|ott|nov|dic)/i,wide:/^(gennaio|febbraio|marzo|aprile|maggio|giugno|luglio|agosto|settembre|ottobre|novembre|dicembre)/i},defaultMatchWidth:`wide`,parsePatterns:{narrow:[/^g/i,/^f/i,/^m/i,/^a/i,/^m/i,/^g/i,/^l/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ge/i,/^f/i,/^mar/i,/^ap/i,/^mag/i,/^gi/i,/^l/i,/^ag/i,/^s/i,/^o/i,/^n/i,/^d/i]},defaultParseWidth:`any`}),day:mf({matchPatterns:{narrow:/^[dlmgvs]/i,short:/^(do|lu|ma|me|gi|ve|sa)/i,abbreviated:/^(dom|lun|mar|mer|gio|ven|sab)/i,wide:/^(domenica|luned[i|ì]|marted[i|ì]|mercoled[i|ì]|gioved[i|ì]|venerd[i|ì]|sabato)/i},defaultMatchWidth:`wide`,parsePatterns:{narrow:[/^d/i,/^l/i,/^m/i,/^m/i,/^g/i,/^v/i,/^s/i],any:[/^d/i,/^l/i,/^ma/i,/^me/i,/^g/i,/^v/i,/^s/i]},defaultParseWidth:`any`}),dayPeriod:mf({matchPatterns:{narrow:/^(a|m\.|p|mezzanotte|mezzogiorno|(di|del) (mattina|pomeriggio|sera|notte))/i,any:/^([ap]\.?\s?m\.?|mezzanotte|mezzogiorno|(di|del) (mattina|pomeriggio|sera|notte))/i},defaultMatchWidth:`any`,parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mezza/i,noon:/^mezzo/i,morning:/mattina/i,afternoon:/pomeriggio/i,evening:/sera/i,night:/notte/i}},defaultParseWidth:`any`})},options:{weekStartsOn:1,firstWeekContainsDate:4}},Tp={lessThanXSeconds:{one:`1秒未満`,other:`{{count}}秒未満`,oneWithSuffix:`約1秒`,otherWithSuffix:`約{{count}}秒`},xSeconds:{one:`1秒`,other:`{{count}}秒`},halfAMinute:`30秒`,lessThanXMinutes:{one:`1分未満`,other:`{{count}}分未満`,oneWithSuffix:`約1分`,otherWithSuffix:`約{{count}}分`},xMinutes:{one:`1分`,other:`{{count}}分`},aboutXHours:{one:`約1時間`,other:`約{{count}}時間`},xHours:{one:`1時間`,other:`{{count}}時間`},xDays:{one:`1日`,other:`{{count}}日`},aboutXWeeks:{one:`約1週間`,other:`約{{count}}週間`},xWeeks:{one:`1週間`,other:`{{count}}週間`},aboutXMonths:{one:`約1か月`,other:`約{{count}}か月`},xMonths:{one:`1か月`,other:`{{count}}か月`},aboutXYears:{one:`約1年`,other:`約{{count}}年`},xYears:{one:`1年`,other:`{{count}}年`},overXYears:{one:`1年以上`,other:`{{count}}年以上`},almostXYears:{one:`1年近く`,other:`{{count}}年近く`}},Ep=(e,t,n)=>{n||={};let r,i=Tp[e];return r=typeof i==`string`?i:t===1?n.addSuffix&&i.oneWithSuffix?i.oneWithSuffix:i.one:n.addSuffix&&i.otherWithSuffix?i.otherWithSuffix.replace(`{{count}}`,String(t)):i.other.replace(`{{count}}`,String(t)),n.addSuffix?n.comparison&&n.comparison>0?r+`後`:r+`前`:r},Dp={date:ff({formats:{full:`y年M月d日EEEE`,long:`y年M月d日`,medium:`y/MM/dd`,short:`y/MM/dd`},defaultWidth:`full`}),time:ff({formats:{full:`H時mm分ss秒 zzzz`,long:`H:mm:ss z`,medium:`H:mm:ss`,short:`H:mm`},defaultWidth:`full`}),dateTime:ff({formats:{full:`{{date}} {{time}}`,long:`{{date}} {{time}}`,medium:`{{date}} {{time}}`,short:`{{date}} {{time}}`},defaultWidth:`full`})},Op={lastWeek:`先週のeeeeのp`,yesterday:`昨日のp`,today:`今日のp`,tomorrow:`明日のp`,nextWeek:`翌週のeeeeのp`,other:`P`},kp={code:`ja`,formatDistance:Ep,formatLong:Dp,formatRelative:(e,t,n,r)=>Op[e],localize:{ordinalNumber:(e,t)=>{let n=Number(e);switch(String(t?.unit)){case`year`:return`${n}年`;case`quarter`:return`第${n}四半期`;case`month`:return`${n}月`;case`week`:return`第${n}週`;case`date`:return`${n}日`;case`hour`:return`${n}時`;case`minute`:return`${n}分`;case`second`:return`${n}秒`;default:return`${n}`}},era:pf({values:{narrow:[`BC`,`AC`],abbreviated:[`紀元前`,`西暦`],wide:[`紀元前`,`西暦`]},defaultWidth:`wide`}),quarter:pf({values:{narrow:[`1`,`2`,`3`,`4`],abbreviated:[`Q1`,`Q2`,`Q3`,`Q4`],wide:[`第1四半期`,`第2四半期`,`第3四半期`,`第4四半期`]},defaultWidth:`wide`,argumentCallback:e=>Number(e)-1}),month:pf({values:{narrow:[`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`,`10`,`11`,`12`],abbreviated:[`1月`,`2月`,`3月`,`4月`,`5月`,`6月`,`7月`,`8月`,`9月`,`10月`,`11月`,`12月`],wide:[`1月`,`2月`,`3月`,`4月`,`5月`,`6月`,`7月`,`8月`,`9月`,`10月`,`11月`,`12月`]},defaultWidth:`wide`}),day:pf({values:{narrow:[`日`,`月`,`火`,`水`,`木`,`金`,`土`],short:[`日`,`月`,`火`,`水`,`木`,`金`,`土`],abbreviated:[`日`,`月`,`火`,`水`,`木`,`金`,`土`],wide:[`日曜日`,`月曜日`,`火曜日`,`水曜日`,`木曜日`,`金曜日`,`土曜日`]},defaultWidth:`wide`}),dayPeriod:pf({values:{narrow:{am:`午前`,pm:`午後`,midnight:`深夜`,noon:`正午`,morning:`朝`,afternoon:`午後`,evening:`夜`,night:`深夜`},abbreviated:{am:`午前`,pm:`午後`,midnight:`深夜`,noon:`正午`,morning:`朝`,afternoon:`午後`,evening:`夜`,night:`深夜`},wide:{am:`午前`,pm:`午後`,midnight:`深夜`,noon:`正午`,morning:`朝`,afternoon:`午後`,evening:`夜`,night:`深夜`}},defaultWidth:`wide`,formattingValues:{narrow:{am:`午前`,pm:`午後`,midnight:`深夜`,noon:`正午`,morning:`朝`,afternoon:`午後`,evening:`夜`,night:`深夜`},abbreviated:{am:`午前`,pm:`午後`,midnight:`深夜`,noon:`正午`,morning:`朝`,afternoon:`午後`,evening:`夜`,night:`深夜`},wide:{am:`午前`,pm:`午後`,midnight:`深夜`,noon:`正午`,morning:`朝`,afternoon:`午後`,evening:`夜`,night:`深夜`}},defaultFormattingWidth:`wide`})},match:{ordinalNumber:_f({matchPattern:/^第?\d+(年|四半期|月|週|日|時|分|秒)?/i,parsePattern:/\d+/i,valueCallback:function(e){return parseInt(e,10)}}),era:mf({matchPatterns:{narrow:/^(B\.?C\.?|A\.?D\.?)/i,abbreviated:/^(紀元[前後]|西暦)/i,wide:/^(紀元[前後]|西暦)/i},defaultMatchWidth:`wide`,parsePatterns:{narrow:[/^B/i,/^A/i],any:[/^(紀元前)/i,/^(西暦|紀元後)/i]},defaultParseWidth:`any`}),quarter:mf({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^Q[1234]/i,wide:/^第[1234一二三四1234]四半期/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/(1|一|1)/i,/(2|二|2)/i,/(3|三|3)/i,/(4|四|4)/i]},defaultParseWidth:`any`,valueCallback:e=>e+1}),month:mf({matchPatterns:{narrow:/^([123456789]|1[012])/,abbreviated:/^([123456789]|1[012])月/i,wide:/^([123456789]|1[012])月/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/^1\D/,/^2/,/^3/,/^4/,/^5/,/^6/,/^7/,/^8/,/^9/,/^10/,/^11/,/^12/]},defaultParseWidth:`any`}),day:mf({matchPatterns:{narrow:/^[日月火水木金土]/,short:/^[日月火水木金土]/,abbreviated:/^[日月火水木金土]/,wide:/^[日月火水木金土]曜日/},defaultMatchWidth:`wide`,parsePatterns:{any:[/^日/,/^月/,/^火/,/^水/,/^木/,/^金/,/^土/]},defaultParseWidth:`any`}),dayPeriod:mf({matchPatterns:{any:/^(AM|PM|午前|午後|正午|深夜|真夜中|夜|朝)/i},defaultMatchWidth:`any`,parsePatterns:{any:{am:/^(A|午前)/i,pm:/^(P|午後)/i,midnight:/^深夜|真夜中/i,noon:/^正午/i,morning:/^朝/i,afternoon:/^午後/i,evening:/^夜/i,night:/^深夜/i}},defaultParseWidth:`any`})},options:{weekStartsOn:0,firstWeekContainsDate:1}},Ap={lessThanXSeconds:{one:`menos de um segundo`,other:`menos de {{count}} segundos`},xSeconds:{one:`1 segundo`,other:`{{count}} segundos`},halfAMinute:`meio minuto`,lessThanXMinutes:{one:`menos de um minuto`,other:`menos de {{count}} minutos`},xMinutes:{one:`1 minuto`,other:`{{count}} minutos`},aboutXHours:{one:`aproximadamente 1 hora`,other:`aproximadamente {{count}} horas`},xHours:{one:`1 hora`,other:`{{count}} horas`},xDays:{one:`1 dia`,other:`{{count}} dias`},aboutXWeeks:{one:`aproximadamente 1 semana`,other:`aproximadamente {{count}} semanas`},xWeeks:{one:`1 semana`,other:`{{count}} semanas`},aboutXMonths:{one:`aproximadamente 1 mês`,other:`aproximadamente {{count}} meses`},xMonths:{one:`1 mês`,other:`{{count}} meses`},aboutXYears:{one:`aproximadamente 1 ano`,other:`aproximadamente {{count}} anos`},xYears:{one:`1 ano`,other:`{{count}} anos`},overXYears:{one:`mais de 1 ano`,other:`mais de {{count}} anos`},almostXYears:{one:`quase 1 ano`,other:`quase {{count}} anos`}},jp=(e,t,n)=>{let r,i=Ap[e];return r=typeof i==`string`?i:t===1?i.one:i.other.replace(`{{count}}`,String(t)),n?.addSuffix?n.comparison&&n.comparison>0?`daqui a `+r:`há `+r:r},Mp={date:ff({formats:{full:`EEEE, d 'de' MMMM 'de' y`,long:`d 'de' MMMM 'de' y`,medium:`d 'de' MMM 'de' y`,short:`dd/MM/y`},defaultWidth:`full`}),time:ff({formats:{full:`HH:mm:ss zzzz`,long:`HH:mm:ss z`,medium:`HH:mm:ss`,short:`HH:mm`},defaultWidth:`full`}),dateTime:ff({formats:{full:`{{date}} 'às' {{time}}`,long:`{{date}} 'às' {{time}}`,medium:`{{date}}, {{time}}`,short:`{{date}}, {{time}}`},defaultWidth:`full`})},Np={lastWeek:e=>{let t=e.getDay();return`'`+(t===0||t===6?`último`:`última`)+`' eeee 'às' p`},yesterday:`'ontem às' p`,today:`'hoje às' p`,tomorrow:`'amanhã às' p`,nextWeek:`eeee 'às' p`,other:`P`},Pp={code:`pt`,formatDistance:jp,formatLong:Mp,formatRelative:(e,t,n,r)=>{let i=Np[e];return typeof i==`function`?i(t):i},localize:{ordinalNumber:(e,t)=>Number(e)+`º`,era:pf({values:{narrow:[`aC`,`dC`],abbreviated:[`a.C.`,`d.C.`],wide:[`antes de Cristo`,`depois de Cristo`]},defaultWidth:`wide`}),quarter:pf({values:{narrow:[`1`,`2`,`3`,`4`],abbreviated:[`T1`,`T2`,`T3`,`T4`],wide:[`1º trimestre`,`2º trimestre`,`3º trimestre`,`4º trimestre`]},defaultWidth:`wide`,argumentCallback:e=>e-1}),month:pf({values:{narrow:[`j`,`f`,`m`,`a`,`m`,`j`,`j`,`a`,`s`,`o`,`n`,`d`],abbreviated:[`jan`,`fev`,`mar`,`abr`,`mai`,`jun`,`jul`,`ago`,`set`,`out`,`nov`,`dez`],wide:[`janeiro`,`fevereiro`,`março`,`abril`,`maio`,`junho`,`julho`,`agosto`,`setembro`,`outubro`,`novembro`,`dezembro`]},defaultWidth:`wide`}),day:pf({values:{narrow:[`d`,`s`,`t`,`q`,`q`,`s`,`s`],short:[`dom`,`seg`,`ter`,`qua`,`qui`,`sex`,`sáb`],abbreviated:[`dom`,`seg`,`ter`,`qua`,`qui`,`sex`,`sáb`],wide:[`domingo`,`segunda-feira`,`terça-feira`,`quarta-feira`,`quinta-feira`,`sexta-feira`,`sábado`]},defaultWidth:`wide`}),dayPeriod:pf({values:{narrow:{am:`AM`,pm:`PM`,midnight:`meia-noite`,noon:`meio-dia`,morning:`manhã`,afternoon:`tarde`,evening:`noite`,night:`madrugada`},abbreviated:{am:`AM`,pm:`PM`,midnight:`meia-noite`,noon:`meio-dia`,morning:`manhã`,afternoon:`tarde`,evening:`noite`,night:`madrugada`},wide:{am:`AM`,pm:`PM`,midnight:`meia-noite`,noon:`meio-dia`,morning:`manhã`,afternoon:`tarde`,evening:`noite`,night:`madrugada`}},defaultWidth:`wide`,formattingValues:{narrow:{am:`AM`,pm:`PM`,midnight:`meia-noite`,noon:`meio-dia`,morning:`da manhã`,afternoon:`da tarde`,evening:`da noite`,night:`da madrugada`},abbreviated:{am:`AM`,pm:`PM`,midnight:`meia-noite`,noon:`meio-dia`,morning:`da manhã`,afternoon:`da tarde`,evening:`da noite`,night:`da madrugada`},wide:{am:`AM`,pm:`PM`,midnight:`meia-noite`,noon:`meio-dia`,morning:`da manhã`,afternoon:`da tarde`,evening:`da noite`,night:`da madrugada`}},defaultFormattingWidth:`wide`})},match:{ordinalNumber:_f({matchPattern:/^(\d+)(º|ª)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:mf({matchPatterns:{narrow:/^(ac|dc|a|d)/i,abbreviated:/^(a\.?\s?c\.?|a\.?\s?e\.?\s?c\.?|d\.?\s?c\.?|e\.?\s?c\.?)/i,wide:/^(antes de cristo|antes da era comum|depois de cristo|era comum)/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/^ac/i,/^dc/i],wide:[/^(antes de cristo|antes da era comum)/i,/^(depois de cristo|era comum)/i]},defaultParseWidth:`any`}),quarter:mf({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^T[1234]/i,wide:/^[1234](º|ª)? trimestre/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:`any`,valueCallback:e=>e+1}),month:mf({matchPatterns:{narrow:/^[jfmasond]/i,abbreviated:/^(jan|fev|mar|abr|mai|jun|jul|ago|set|out|nov|dez)/i,wide:/^(janeiro|fevereiro|março|abril|maio|junho|julho|agosto|setembro|outubro|novembro|dezembro)/i},defaultMatchWidth:`wide`,parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ab/i,/^mai/i,/^jun/i,/^jul/i,/^ag/i,/^s/i,/^o/i,/^n/i,/^d/i]},defaultParseWidth:`any`}),day:mf({matchPatterns:{narrow:/^[dstq]/i,short:/^(dom|seg|ter|qua|qui|sex|s[áa]b)/i,abbreviated:/^(dom|seg|ter|qua|qui|sex|s[áa]b)/i,wide:/^(domingo|segunda-?\s?feira|terça-?\s?feira|quarta-?\s?feira|quinta-?\s?feira|sexta-?\s?feira|s[áa]bado)/i},defaultMatchWidth:`wide`,parsePatterns:{narrow:[/^d/i,/^s/i,/^t/i,/^q/i,/^q/i,/^s/i,/^s/i],any:[/^d/i,/^seg/i,/^t/i,/^qua/i,/^qui/i,/^sex/i,/^s[áa]/i]},defaultParseWidth:`any`}),dayPeriod:mf({matchPatterns:{narrow:/^(a|p|meia-?\s?noite|meio-?\s?dia|(da) (manh[ãa]|tarde|noite|madrugada))/i,any:/^([ap]\.?\s?m\.?|meia-?\s?noite|meio-?\s?dia|(da) (manh[ãa]|tarde|noite|madrugada))/i},defaultMatchWidth:`any`,parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^meia/i,noon:/^meio/i,morning:/manh[ãa]/i,afternoon:/tarde/i,evening:/noite/i,night:/madrugada/i}},defaultParseWidth:`any`})},options:{weekStartsOn:1,firstWeekContainsDate:4}},Fp={lessThanXSeconds:{one:`不到 1 秒`,other:`不到 {{count}} 秒`},xSeconds:{one:`1 秒`,other:`{{count}} 秒`},halfAMinute:`半分钟`,lessThanXMinutes:{one:`不到 1 分钟`,other:`不到 {{count}} 分钟`},xMinutes:{one:`1 分钟`,other:`{{count}} 分钟`},xHours:{one:`1 小时`,other:`{{count}} 小时`},aboutXHours:{one:`大约 1 小时`,other:`大约 {{count}} 小时`},xDays:{one:`1 天`,other:`{{count}} 天`},aboutXWeeks:{one:`大约 1 个星期`,other:`大约 {{count}} 个星期`},xWeeks:{one:`1 个星期`,other:`{{count}} 个星期`},aboutXMonths:{one:`大约 1 个月`,other:`大约 {{count}} 个月`},xMonths:{one:`1 个月`,other:`{{count}} 个月`},aboutXYears:{one:`大约 1 年`,other:`大约 {{count}} 年`},xYears:{one:`1 年`,other:`{{count}} 年`},overXYears:{one:`超过 1 年`,other:`超过 {{count}} 年`},almostXYears:{one:`将近 1 年`,other:`将近 {{count}} 年`}},Ip=(e,t,n)=>{let r,i=Fp[e];return r=typeof i==`string`?i:t===1?i.one:i.other.replace(`{{count}}`,String(t)),n?.addSuffix?n.comparison&&n.comparison>0?r+`内`:r+`前`:r},Lp={date:ff({formats:{full:`y'年'M'月'd'日' EEEE`,long:`y'年'M'月'd'日'`,medium:`yyyy-MM-dd`,short:`yy-MM-dd`},defaultWidth:`full`}),time:ff({formats:{full:`zzzz a h:mm:ss`,long:`z a h:mm:ss`,medium:`a h:mm:ss`,short:`a h:mm`},defaultWidth:`full`}),dateTime:ff({formats:{full:`{{date}} {{time}}`,long:`{{date}} {{time}}`,medium:`{{date}} {{time}}`,short:`{{date}} {{time}}`},defaultWidth:`full`})};function Rp(e,t,n){let r=`eeee p`;return Nf(e,t,n)?r:e.getTime()>t.getTime()?`'下个'`+r:`'上个'`+r}var zp={lastWeek:Rp,yesterday:`'昨天' p`,today:`'今天' p`,tomorrow:`'明天' p`,nextWeek:Rp,other:`PP p`},Bp={code:`zh-CN`,formatDistance:Ip,formatLong:Lp,formatRelative:(e,t,n,r)=>{let i=zp[e];return typeof i==`function`?i(t,n,r):i},localize:{ordinalNumber:(e,t)=>{let n=Number(e);switch(t?.unit){case`date`:return n.toString()+`日`;case`hour`:return n.toString()+`时`;case`minute`:return n.toString()+`分`;case`second`:return n.toString()+`秒`;default:return`第 `+n.toString()}},era:pf({values:{narrow:[`前`,`公元`],abbreviated:[`前`,`公元`],wide:[`公元前`,`公元`]},defaultWidth:`wide`}),quarter:pf({values:{narrow:[`1`,`2`,`3`,`4`],abbreviated:[`第一季`,`第二季`,`第三季`,`第四季`],wide:[`第一季度`,`第二季度`,`第三季度`,`第四季度`]},defaultWidth:`wide`,argumentCallback:e=>e-1}),month:pf({values:{narrow:[`一`,`二`,`三`,`四`,`五`,`六`,`七`,`八`,`九`,`十`,`十一`,`十二`],abbreviated:[`1月`,`2月`,`3月`,`4月`,`5月`,`6月`,`7月`,`8月`,`9月`,`10月`,`11月`,`12月`],wide:[`一月`,`二月`,`三月`,`四月`,`五月`,`六月`,`七月`,`八月`,`九月`,`十月`,`十一月`,`十二月`]},defaultWidth:`wide`}),day:pf({values:{narrow:[`日`,`一`,`二`,`三`,`四`,`五`,`六`],short:[`日`,`一`,`二`,`三`,`四`,`五`,`六`],abbreviated:[`周日`,`周一`,`周二`,`周三`,`周四`,`周五`,`周六`],wide:[`星期日`,`星期一`,`星期二`,`星期三`,`星期四`,`星期五`,`星期六`]},defaultWidth:`wide`}),dayPeriod:pf({values:{narrow:{am:`上`,pm:`下`,midnight:`凌晨`,noon:`午`,morning:`早`,afternoon:`下午`,evening:`晚`,night:`夜`},abbreviated:{am:`上午`,pm:`下午`,midnight:`凌晨`,noon:`中午`,morning:`早晨`,afternoon:`中午`,evening:`晚上`,night:`夜间`},wide:{am:`上午`,pm:`下午`,midnight:`凌晨`,noon:`中午`,morning:`早晨`,afternoon:`中午`,evening:`晚上`,night:`夜间`}},defaultWidth:`wide`,formattingValues:{narrow:{am:`上`,pm:`下`,midnight:`凌晨`,noon:`午`,morning:`早`,afternoon:`下午`,evening:`晚`,night:`夜`},abbreviated:{am:`上午`,pm:`下午`,midnight:`凌晨`,noon:`中午`,morning:`早晨`,afternoon:`中午`,evening:`晚上`,night:`夜间`},wide:{am:`上午`,pm:`下午`,midnight:`凌晨`,noon:`中午`,morning:`早晨`,afternoon:`中午`,evening:`晚上`,night:`夜间`}},defaultFormattingWidth:`wide`})},match:{ordinalNumber:_f({matchPattern:/^(第\s*)?\d+(日|时|分|秒)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:mf({matchPatterns:{narrow:/^(前)/i,abbreviated:/^(前)/i,wide:/^(公元前|公元)/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/^(前)/i,/^(公元)/i]},defaultParseWidth:`any`}),quarter:mf({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^第[一二三四]刻/i,wide:/^第[一二三四]刻钟/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/(1|一)/i,/(2|二)/i,/(3|三)/i,/(4|四)/i]},defaultParseWidth:`any`,valueCallback:e=>e+1}),month:mf({matchPatterns:{narrow:/^(一|二|三|四|五|六|七|八|九|十[二一])/i,abbreviated:/^(一|二|三|四|五|六|七|八|九|十[二一]|\d|1[12])月/i,wide:/^(一|二|三|四|五|六|七|八|九|十[二一])月/i},defaultMatchWidth:`wide`,parsePatterns:{narrow:[/^一/i,/^二/i,/^三/i,/^四/i,/^五/i,/^六/i,/^七/i,/^八/i,/^九/i,/^十(?!(一|二))/i,/^十一/i,/^十二/i],any:[/^一|1/i,/^二|2/i,/^三|3/i,/^四|4/i,/^五|5/i,/^六|6/i,/^七|7/i,/^八|8/i,/^九|9/i,/^十(?!(一|二))|10/i,/^十一|11/i,/^十二|12/i]},defaultParseWidth:`any`}),day:mf({matchPatterns:{narrow:/^[一二三四五六日]/i,short:/^[一二三四五六日]/i,abbreviated:/^周[一二三四五六日]/i,wide:/^星期[一二三四五六日]/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/日/i,/一/i,/二/i,/三/i,/四/i,/五/i,/六/i]},defaultParseWidth:`any`}),dayPeriod:mf({matchPatterns:{any:/^(上午?|下午?|午夜|[中正]午|早上?|下午|晚上?|凌晨|)/i},defaultMatchWidth:`any`,parsePatterns:{any:{am:/^上午?/i,pm:/^下午?/i,midnight:/^午夜/i,noon:/^[中正]午/i,morning:/^早上/i,afternoon:/^下午/i,evening:/^晚上?/i,night:/^凌晨/i}},defaultParseWidth:`any`})},options:{weekStartsOn:1,firstWeekContainsDate:4}},Vp=[`en`,`es`,`fr`,`de`,`pt`,`it`,`zh`,`ja`],Hp={en:{id:`en`,nativeName:`English`,englishName:`English`},es:{id:`es`,nativeName:`Español`,englishName:`Spanish`},fr:{id:`fr`,nativeName:`Français`,englishName:`French`},de:{id:`de`,nativeName:`Deutsch`,englishName:`German`},pt:{id:`pt`,nativeName:`Português`,englishName:`Portuguese`},it:{id:`it`,nativeName:`Italiano`,englishName:`Italian`},zh:{id:`zh`,nativeName:`中文`,englishName:`Chinese`},ja:{id:`ja`,nativeName:`日本語`,englishName:`Japanese`}},Up=`specrails-desktop:ui-language`;function Wp(e){return typeof e==`string`&&Vp.includes(e)}function Gp(e){return e.split(`/`).pop().replace(/\.json$/,``)}var Kp=Object.assign({"../locales/en/activity.json":d,"../locales/en/addspec.json":f,"../locales/en/agent.json":p,"../locales/en/agents.json":m,"../locales/en/agentstudio.json":h,"../locales/en/aiedit.json":g,"../locales/en/analytics.json":_,"../locales/en/attachments.json":v,"../locales/en/browser.json":y,"../locales/en/chat.json":b,"../locales/en/code.json":x,"../locales/en/commands.json":S,"../locales/en/common.json":C,"../locales/en/dashboard.json":w,"../locales/en/explore.json":T,"../locales/en/integrations.json":E,"../locales/en/jira.json":D,"../locales/en/jobs.json":O,"../locales/en/loops.json":k,"../locales/en/mcp.json":A,"../locales/en/nav.json":j,"../locales/en/settings.json":M,"../locales/en/setup.json":N,"../locales/en/specs.json":P,"../locales/en/terminal.json":F,"../locales/en/tickets.json":I}),qp=Object.assign({"../locales/de/activity.json":()=>a(()=>import(`./activity-BZZlEG3a.js`),[]),"../locales/de/addspec.json":()=>a(()=>import(`./addspec-BKrH2Ucz.js`),[]),"../locales/de/agent.json":()=>a(()=>import(`./agent-DqyzT33X.js`),[]),"../locales/de/agents.json":()=>a(()=>import(`./agents-CP8_ezYG.js`),[]),"../locales/de/agentstudio.json":()=>a(()=>import(`./agentstudio-RsxnZtUA.js`),[]),"../locales/de/aiedit.json":()=>a(()=>import(`./aiedit-DrIjSojo.js`),[]),"../locales/de/analytics.json":()=>a(()=>import(`./analytics-CpSTNfui.js`),[]),"../locales/de/attachments.json":()=>a(()=>import(`./attachments-CHDbhKeH.js`),[]),"../locales/de/browser.json":()=>a(()=>import(`./browser-JsiohNmW.js`),[]),"../locales/de/chat.json":()=>a(()=>import(`./chat-BalviUAD.js`),[]),"../locales/de/code.json":()=>a(()=>import(`./code-HDK4P6Rx.js`),[]),"../locales/de/commands.json":()=>a(()=>import(`./commands-KBbhsnw8.js`),[]),"../locales/de/common.json":()=>a(()=>import(`./common-CF8iGXrG.js`),[]),"../locales/de/dashboard.json":()=>a(()=>import(`./dashboard-CEgg9NAr.js`),[]),"../locales/de/explore.json":()=>a(()=>import(`./explore-DW_YTkQh.js`),[]),"../locales/de/integrations.json":()=>a(()=>import(`./integrations-CWjh5VRk.js`),[]),"../locales/de/jira.json":()=>a(()=>import(`./jira-CQ7mrZde.js`),[]),"../locales/de/jobs.json":()=>a(()=>import(`./jobs-BFIdeDTw.js`),[]),"../locales/de/loops.json":()=>a(()=>import(`./loops-D3wdUkZV.js`),[]),"../locales/de/mcp.json":()=>a(()=>import(`./mcp-Dd844F5_.js`),[]),"../locales/de/nav.json":()=>a(()=>import(`./nav-B2_ToNqS.js`),[]),"../locales/de/settings.json":()=>a(()=>import(`./settings-BvIwQ3A1.js`),[]),"../locales/de/setup.json":()=>a(()=>import(`./setup-mXnzww4f.js`),[]),"../locales/de/specs.json":()=>a(()=>import(`./specs-C6J2zrLM.js`),[]),"../locales/de/terminal.json":()=>a(()=>import(`./terminal-BTpE7iki.js`),[]),"../locales/de/tickets.json":()=>a(()=>import(`./tickets-sVun0I6v.js`),[]),"../locales/en/activity.json":()=>a(()=>import(`./activity-Dbl71S-E.js`).then(e=>e.t),__vite__mapDeps([0,1])),"../locales/en/addspec.json":()=>a(()=>import(`./addspec-DrXqP8ip.js`).then(e=>e.t),__vite__mapDeps([2,1])),"../locales/en/agent.json":()=>a(()=>import(`./agent-BEXYxDbs.js`).then(e=>e.t),__vite__mapDeps([3,1])),"../locales/en/agents.json":()=>a(()=>import(`./agents-CGDn_3kB.js`).then(e=>e.t),__vite__mapDeps([4,1])),"../locales/en/agentstudio.json":()=>a(()=>import(`./agentstudio-Dxe_94PK.js`).then(e=>e.t),__vite__mapDeps([5,1])),"../locales/en/aiedit.json":()=>a(()=>import(`./aiedit-DrfHQnlz.js`).then(e=>e.t),__vite__mapDeps([6,1])),"../locales/en/analytics.json":()=>a(()=>import(`./analytics-CxDYcBl9.js`).then(e=>e.t),__vite__mapDeps([7,1])),"../locales/en/attachments.json":()=>a(()=>import(`./attachments-DvxQbBTC.js`).then(e=>e.t),__vite__mapDeps([8,1])),"../locales/en/browser.json":()=>a(()=>import(`./browser-DM8G151q.js`).then(e=>e.t),__vite__mapDeps([9,1])),"../locales/en/chat.json":()=>a(()=>import(`./chat-0dg5hOo_.js`).then(e=>e.t),__vite__mapDeps([10,1])),"../locales/en/code.json":()=>a(()=>import(`./code-B62fClk-.js`).then(e=>e.t),__vite__mapDeps([11,1])),"../locales/en/commands.json":()=>a(()=>import(`./commands-DCJ-R9E4.js`).then(e=>e.t),__vite__mapDeps([12,1])),"../locales/en/common.json":()=>a(()=>import(`./common-DXrmj6WD.js`).then(e=>e.t),__vite__mapDeps([13,1])),"../locales/en/dashboard.json":()=>a(()=>import(`./dashboard-DBuLfWo9.js`).then(e=>e.t),__vite__mapDeps([14,1])),"../locales/en/explore.json":()=>a(()=>import(`./explore-_XyU5e7R.js`).then(e=>e.t),__vite__mapDeps([15,1])),"../locales/en/integrations.json":()=>a(()=>import(`./integrations-By80EBkf.js`).then(e=>e.t),__vite__mapDeps([16,1])),"../locales/en/jira.json":()=>a(()=>import(`./jira-DeIjwCK3.js`).then(e=>e.t),__vite__mapDeps([17,1])),"../locales/en/jobs.json":()=>a(()=>import(`./jobs-DrYmsKy5.js`).then(e=>e.t),__vite__mapDeps([18,1])),"../locales/en/loops.json":()=>a(()=>import(`./loops-CO6q75W8.js`).then(e=>e.t),__vite__mapDeps([19,1])),"../locales/en/mcp.json":()=>a(()=>import(`./mcp-HwBbQDk0.js`).then(e=>e.t),__vite__mapDeps([20,1])),"../locales/en/nav.json":()=>a(()=>import(`./nav-BTg8s-cD.js`).then(e=>e.t),__vite__mapDeps([21,1])),"../locales/en/settings.json":()=>a(()=>import(`./settings-BYCMtxOz.js`).then(e=>e.t),__vite__mapDeps([22,1])),"../locales/en/setup.json":()=>a(()=>import(`./setup-D2CmgAro.js`).then(e=>e.t),__vite__mapDeps([23,1])),"../locales/en/specs.json":()=>a(()=>import(`./specs-PGIOzMtc.js`).then(e=>e.t),__vite__mapDeps([24,1])),"../locales/en/terminal.json":()=>a(()=>import(`./terminal-CFt56A5f.js`).then(e=>e.t),__vite__mapDeps([25,1])),"../locales/en/tickets.json":()=>a(()=>import(`./tickets-BHv3ewvq.js`).then(e=>e.t),__vite__mapDeps([26,1])),"../locales/es/activity.json":()=>a(()=>import(`./activity-BbWiDfn-2.js`),[]),"../locales/es/addspec.json":()=>a(()=>import(`./addspec-CFxGvmJR2.js`),[]),"../locales/es/agent.json":()=>a(()=>import(`./agent-C2-rROL52.js`),[]),"../locales/es/agents.json":()=>a(()=>import(`./agents-CV-_xBvX2.js`),[]),"../locales/es/agentstudio.json":()=>a(()=>import(`./agentstudio-RfZavULt2.js`),[]),"../locales/es/aiedit.json":()=>a(()=>import(`./aiedit-DnBzjlVz2.js`),[]),"../locales/es/analytics.json":()=>a(()=>import(`./analytics-4HvXb0Vn2.js`),[]),"../locales/es/attachments.json":()=>a(()=>import(`./attachments-DlEQu56g2.js`),[]),"../locales/es/browser.json":()=>a(()=>import(`./browser-BbJ_q_OT2.js`),[]),"../locales/es/chat.json":()=>a(()=>import(`./chat-BMWD_Rx12.js`),[]),"../locales/es/code.json":()=>a(()=>import(`./code-C9U6M5-e2.js`),[]),"../locales/es/commands.json":()=>a(()=>import(`./commands-cKTaLwwV2.js`),[]),"../locales/es/common.json":()=>a(()=>import(`./common-Cfmwcrl52.js`),[]),"../locales/es/dashboard.json":()=>a(()=>import(`./dashboard-BFfnCtq52.js`),[]),"../locales/es/explore.json":()=>a(()=>import(`./explore-CAc8Qzu32.js`),[]),"../locales/es/integrations.json":()=>a(()=>import(`./integrations-RJfzXkPx2.js`),[]),"../locales/es/jira.json":()=>a(()=>import(`./jira-B5wszJ1-2.js`),[]),"../locales/es/jobs.json":()=>a(()=>import(`./jobs-P3unxtxo2.js`),[]),"../locales/es/loops.json":()=>a(()=>import(`./loops-Du-bNVpc2.js`),[]),"../locales/es/mcp.json":()=>a(()=>import(`./mcp-BG-OCJca2.js`),[]),"../locales/es/nav.json":()=>a(()=>import(`./nav-DUuw9VIU2.js`),[]),"../locales/es/settings.json":()=>a(()=>import(`./settings-DhaFKpcw2.js`),[]),"../locales/es/setup.json":()=>a(()=>import(`./setup-BmJ0Kx16.js`),[]),"../locales/es/specs.json":()=>a(()=>import(`./specs-DZDoZsDq.js`),[]),"../locales/es/terminal.json":()=>a(()=>import(`./terminal-DDk_bTw0.js`),[]),"../locales/es/tickets.json":()=>a(()=>import(`./tickets-D1IeX2EW.js`),[]),"../locales/fr/activity.json":()=>a(()=>import(`./activity-DtzRy92x.js`),[]),"../locales/fr/addspec.json":()=>a(()=>import(`./addspec-B_LQMHW3.js`),[]),"../locales/fr/agent.json":()=>a(()=>import(`./agent-tJdAobaM.js`),[]),"../locales/fr/agents.json":()=>a(()=>import(`./agents-BHgn--3j.js`),[]),"../locales/fr/agentstudio.json":()=>a(()=>import(`./agentstudio-Br3WD7Xs.js`),[]),"../locales/fr/aiedit.json":()=>a(()=>import(`./aiedit-D0Syl-mC.js`),[]),"../locales/fr/analytics.json":()=>a(()=>import(`./analytics-4-eskbtX.js`),[]),"../locales/fr/attachments.json":()=>a(()=>import(`./attachments-CgOQ9K-6.js`),[]),"../locales/fr/browser.json":()=>a(()=>import(`./browser-Do2jf8_N.js`),[]),"../locales/fr/chat.json":()=>a(()=>import(`./chat-n43nZGvn.js`),[]),"../locales/fr/code.json":()=>a(()=>import(`./code-CIPmDEd0.js`),[]),"../locales/fr/commands.json":()=>a(()=>import(`./commands-BMkC5-ki.js`),[]),"../locales/fr/common.json":()=>a(()=>import(`./common-D2cimsul.js`),[]),"../locales/fr/dashboard.json":()=>a(()=>import(`./dashboard-B6iQ-IL_.js`),[]),"../locales/fr/explore.json":()=>a(()=>import(`./explore-BO_OinBD.js`),[]),"../locales/fr/integrations.json":()=>a(()=>import(`./integrations-CG2dp3Kd.js`),[]),"../locales/fr/jira.json":()=>a(()=>import(`./jira-C5UjxHE4.js`),[]),"../locales/fr/jobs.json":()=>a(()=>import(`./jobs-DAU8C_tZ.js`),[]),"../locales/fr/loops.json":()=>a(()=>import(`./loops-Bi4ywYGn.js`),[]),"../locales/fr/mcp.json":()=>a(()=>import(`./mcp-DfmzoT5t.js`),[]),"../locales/fr/nav.json":()=>a(()=>import(`./nav-S4HM94vW.js`),[]),"../locales/fr/settings.json":()=>a(()=>import(`./settings-C_T0-j9d.js`),[]),"../locales/fr/setup.json":()=>a(()=>import(`./setup-q0wRHUp1.js`),[]),"../locales/fr/specs.json":()=>a(()=>import(`./specs-GkiL-snY.js`),[]),"../locales/fr/terminal.json":()=>a(()=>import(`./terminal-BNSg2lR7.js`),[]),"../locales/fr/tickets.json":()=>a(()=>import(`./tickets-C2BhwzwR.js`),[]),"../locales/it/activity.json":()=>a(()=>import(`./activity-D3Ic-HTS.js`),[]),"../locales/it/addspec.json":()=>a(()=>import(`./addspec-NBbcTbLc.js`),[]),"../locales/it/agent.json":()=>a(()=>import(`./agent-DZ8zTrQT.js`),[]),"../locales/it/agents.json":()=>a(()=>import(`./agents-HFCqQH0Z.js`),[]),"../locales/it/agentstudio.json":()=>a(()=>import(`./agentstudio-BEp7Sb46.js`),[]),"../locales/it/aiedit.json":()=>a(()=>import(`./aiedit-CcugGPbS.js`),[]),"../locales/it/analytics.json":()=>a(()=>import(`./analytics-DEe5BMz8.js`),[]),"../locales/it/attachments.json":()=>a(()=>import(`./attachments-CA2f3qL3.js`),[]),"../locales/it/browser.json":()=>a(()=>import(`./browser-C4VJ5CW12.js`),[]),"../locales/it/chat.json":()=>a(()=>import(`./chat-CJddjN3D2.js`),[]),"../locales/it/code.json":()=>a(()=>import(`./code-BotxM43N2.js`),[]),"../locales/it/commands.json":()=>a(()=>import(`./commands-CWX9WmDX2.js`),[]),"../locales/it/common.json":()=>a(()=>import(`./common-DtXmzX2o2.js`),[]),"../locales/it/dashboard.json":()=>a(()=>import(`./dashboard-BIC8KtRf2.js`),[]),"../locales/it/explore.json":()=>a(()=>import(`./explore-DCZL9gRN2.js`),[]),"../locales/it/integrations.json":()=>a(()=>import(`./integrations-CAjq5tdW2.js`),[]),"../locales/it/jira.json":()=>a(()=>import(`./jira-ZdKb-50F2.js`),[]),"../locales/it/jobs.json":()=>a(()=>import(`./jobs-BJ-Gcao22.js`),[]),"../locales/it/loops.json":()=>a(()=>import(`./loops-BjK8lmoZ2.js`),[]),"../locales/it/mcp.json":()=>a(()=>import(`./mcp-DyULurYS2.js`),[]),"../locales/it/nav.json":()=>a(()=>import(`./nav-CVXtv0wX2.js`),[]),"../locales/it/settings.json":()=>a(()=>import(`./settings-Bp24JHlv2.js`),[]),"../locales/it/setup.json":()=>a(()=>import(`./setup-T_ApeQDV2.js`),[]),"../locales/it/specs.json":()=>a(()=>import(`./specs-Ce5y2iFc2.js`),[]),"../locales/it/terminal.json":()=>a(()=>import(`./terminal-Cvabyzm42.js`),[]),"../locales/it/tickets.json":()=>a(()=>import(`./tickets-BIxU86j12.js`),[]),"../locales/ja/activity.json":()=>a(()=>import(`./activity-FleOlK0l2.js`),[]),"../locales/ja/addspec.json":()=>a(()=>import(`./addspec-Bw_YQwo62.js`),[]),"../locales/ja/agent.json":()=>a(()=>import(`./agent-CeRTdGT12.js`),[]),"../locales/ja/agents.json":()=>a(()=>import(`./agents-B9pFSJQI2.js`),[]),"../locales/ja/agentstudio.json":()=>a(()=>import(`./agentstudio-CuTt3ZGe2.js`),[]),"../locales/ja/aiedit.json":()=>a(()=>import(`./aiedit-26p5A_HY2.js`),[]),"../locales/ja/analytics.json":()=>a(()=>import(`./analytics-DcOITHla2.js`),[]),"../locales/ja/attachments.json":()=>a(()=>import(`./attachments-CKAY5aYG2.js`),[]),"../locales/ja/browser.json":()=>a(()=>import(`./browser-BQFDxrRq.js`),[]),"../locales/ja/chat.json":()=>a(()=>import(`./chat-Ds8GvCnv.js`),[]),"../locales/ja/code.json":()=>a(()=>import(`./code-DUe1Bouz.js`),[]),"../locales/ja/commands.json":()=>a(()=>import(`./commands-BllkJauO.js`),[]),"../locales/ja/common.json":()=>a(()=>import(`./common-BfQD173j.js`),[]),"../locales/ja/dashboard.json":()=>a(()=>import(`./dashboard-CiOyDh9L.js`),[]),"../locales/ja/explore.json":()=>a(()=>import(`./explore-BEpIs343.js`),[]),"../locales/ja/integrations.json":()=>a(()=>import(`./integrations-CP_aiV_8.js`),[]),"../locales/ja/jira.json":()=>a(()=>import(`./jira-DtZpokjJ.js`),[]),"../locales/ja/jobs.json":()=>a(()=>import(`./jobs-p360zdf1.js`),[]),"../locales/ja/loops.json":()=>a(()=>import(`./loops-DDs4KPu_.js`),[]),"../locales/ja/mcp.json":()=>a(()=>import(`./mcp-CrWdq5db.js`),[]),"../locales/ja/nav.json":()=>a(()=>import(`./nav-BAMkVEId.js`),[]),"../locales/ja/settings.json":()=>a(()=>import(`./settings-B_v3zgJf.js`),[]),"../locales/ja/setup.json":()=>a(()=>import(`./setup-JeBwoXoM.js`),[]),"../locales/ja/specs.json":()=>a(()=>import(`./specs-DbtIzV8a.js`),[]),"../locales/ja/terminal.json":()=>a(()=>import(`./terminal-DEyt0prF.js`),[]),"../locales/ja/tickets.json":()=>a(()=>import(`./tickets-dQfsc7Ph.js`),[]),"../locales/pt/activity.json":()=>a(()=>import(`./activity-DvECTYGt.js`),[]),"../locales/pt/addspec.json":()=>a(()=>import(`./addspec-DaA-CbTt.js`),[]),"../locales/pt/agent.json":()=>a(()=>import(`./agent-fQI_6tsA.js`),[]),"../locales/pt/agents.json":()=>a(()=>import(`./agents-B_qGaB0F.js`),[]),"../locales/pt/agentstudio.json":()=>a(()=>import(`./agentstudio-BOjG6tgJ.js`),[]),"../locales/pt/aiedit.json":()=>a(()=>import(`./aiedit-a-Z-g5iC.js`),[]),"../locales/pt/analytics.json":()=>a(()=>import(`./analytics-Bd9rHGjV.js`),[]),"../locales/pt/attachments.json":()=>a(()=>import(`./attachments-jVdKzAXn.js`),[]),"../locales/pt/browser.json":()=>a(()=>import(`./browser-Cl-FwPXs.js`),[]),"../locales/pt/chat.json":()=>a(()=>import(`./chat-D5xEtsf3.js`),[]),"../locales/pt/code.json":()=>a(()=>import(`./code-F_KjccGf.js`),[]),"../locales/pt/commands.json":()=>a(()=>import(`./commands-BFQZc9AG.js`),[]),"../locales/pt/common.json":()=>a(()=>import(`./common-DH7fjyL1.js`),[]),"../locales/pt/dashboard.json":()=>a(()=>import(`./dashboard-5C2FOZQX.js`),[]),"../locales/pt/explore.json":()=>a(()=>import(`./explore-Bhy7WWXv.js`),[]),"../locales/pt/integrations.json":()=>a(()=>import(`./integrations-JOHSCvB3.js`),[]),"../locales/pt/jira.json":()=>a(()=>import(`./jira-DIRkZk9U.js`),[]),"../locales/pt/jobs.json":()=>a(()=>import(`./jobs-Da0GaaSc.js`),[]),"../locales/pt/loops.json":()=>a(()=>import(`./loops-DKzYFcq6.js`),[]),"../locales/pt/mcp.json":()=>a(()=>import(`./mcp-zSJ2TsJj.js`),[]),"../locales/pt/nav.json":()=>a(()=>import(`./nav-D0Erv9ZJ2.js`),[]),"../locales/pt/settings.json":()=>a(()=>import(`./settings-Bx2ObkTR2.js`),[]),"../locales/pt/setup.json":()=>a(()=>import(`./setup-1vN48B-m2.js`),[]),"../locales/pt/specs.json":()=>a(()=>import(`./specs-CT8exGOy2.js`),[]),"../locales/pt/terminal.json":()=>a(()=>import(`./terminal-D0z12_sJ2.js`),[]),"../locales/pt/tickets.json":()=>a(()=>import(`./tickets-LfK6LzKl2.js`),[]),"../locales/zh/activity.json":()=>a(()=>import(`./activity-DFbvNqhE2.js`),[]),"../locales/zh/addspec.json":()=>a(()=>import(`./addspec-CR8MB5Fr2.js`),[]),"../locales/zh/agent.json":()=>a(()=>import(`./agent-BoXSzaBk2.js`),[]),"../locales/zh/agents.json":()=>a(()=>import(`./agents-VsyFhGOS2.js`),[]),"../locales/zh/agentstudio.json":()=>a(()=>import(`./agentstudio-D2A5peWV2.js`),[]),"../locales/zh/aiedit.json":()=>a(()=>import(`./aiedit-CV520D4W2.js`),[]),"../locales/zh/analytics.json":()=>a(()=>import(`./analytics-Bpe41fnX2.js`),[]),"../locales/zh/attachments.json":()=>a(()=>import(`./attachments-D2jwJXQ42.js`),[]),"../locales/zh/browser.json":()=>a(()=>import(`./browser-kA31eYhu2.js`),[]),"../locales/zh/chat.json":()=>a(()=>import(`./chat-SaG-ng1x2.js`),[]),"../locales/zh/code.json":()=>a(()=>import(`./code-Bit_z2Xd2.js`),[]),"../locales/zh/commands.json":()=>a(()=>import(`./commands-CzFSoIiq2.js`),[]),"../locales/zh/common.json":()=>a(()=>import(`./common-DZbXlmq72.js`),[]),"../locales/zh/dashboard.json":()=>a(()=>import(`./dashboard-D6x5OnNj2.js`),[]),"../locales/zh/explore.json":()=>a(()=>import(`./explore-ELbrSZyQ2.js`),[]),"../locales/zh/integrations.json":()=>a(()=>import(`./integrations-CUNe3t9l2.js`),[]),"../locales/zh/jira.json":()=>a(()=>import(`./jira-DTYu3hJi2.js`),[]),"../locales/zh/jobs.json":()=>a(()=>import(`./jobs-DAGiPVIS2.js`),[]),"../locales/zh/loops.json":()=>a(()=>import(`./loops-DvGbSfxw2.js`),[]),"../locales/zh/mcp.json":()=>a(()=>import(`./mcp-CbJ04oFS2.js`),[]),"../locales/zh/nav.json":()=>a(()=>import(`./nav-BY_4EWRv.js`),[]),"../locales/zh/settings.json":()=>a(()=>import(`./settings-BemR_e3F.js`),[]),"../locales/zh/setup.json":()=>a(()=>import(`./setup-DQWsu2TR.js`),[]),"../locales/zh/specs.json":()=>a(()=>import(`./specs-BGRKhM8t.js`),[]),"../locales/zh/terminal.json":()=>a(()=>import(`./terminal-a6Uq8B0p.js`),[]),"../locales/zh/tickets.json":()=>a(()=>import(`./tickets-DZut8Ryt.js`),[])}),Jp={};for(let[e,t]of Object.entries(Kp))Jp[Gp(e)]=t.default;var Yp=Object.keys(Jp),Xp=new Set([`en`]);function Zp(){if(typeof navigator<`u`){let e=navigator.languages&&navigator.languages.length>0?navigator.languages:[navigator.language];for(let t of e){if(!t)continue;let e=t.toLowerCase().split(`-`)[0];if(Wp(e))return e}}return`en`}function Qp(){if(typeof localStorage<`u`)try{let e=localStorage.getItem(Up);if(Wp(e))return e}catch{}return Zp()}ri.use(Ki).init({lng:`en`,fallbackLng:`en`,defaultNS:`common`,ns:Yp,resources:{en:Jp},interpolation:{escapeValue:!1},returnNull:!1});async function $p(e){if(Xp.has(e))return;let t=Object.entries(qp).filter(([t])=>t.includes(`/locales/${e}/`)),n=await Promise.all(t.map(async([e,t])=>[Gp(e),(await t()).default]));for(let[t,r]of n)ri.addResourceBundle(e,t,r,!0,!0);Xp.add(e)}async function em(e){await $p(e),await ri.changeLanguage(e),typeof document<`u`&&(document.documentElement.lang=e)}async function tm(){let e=Qp();if(e!==`en`)try{await em(e)}catch{}}function nm(){return Wp(ri.language)?ri.language:`en`}var rm={en:Xf,es:np,fr:hp,de:Uf,pt:Pp,it:wp,zh:Bp,ja:kp};function im(e){let t=e??ri.language;return rm[Wp(t)?t:`en`]}var am=ri,om=new Map;function sm(e,t){return`${e}:${t}`}function cm(e){if(!e)return;let t=`${e}:`;for(let e of om.keys())e.startsWith(t)&&om.delete(e)}function eee({namespace:e,projectId:t,initialValue:n,fetcher:r,pollInterval:i=0}){let a=t?sm(t,e):null,[o,s]=(0,H.useState)(()=>a&&om.has(a)?om.get(a):n),[c,l]=(0,H.useState)(()=>a?!om.has(a):!0),[u,d]=(0,H.useState)(c),f=(0,H.useRef)(r);f.current=r;let p=(0,H.useRef)(a);return p.current=a,(0,H.useEffect)(()=>{if(!a)return;let e=om.get(a);e===void 0?(s(n),l(!0),d(!0)):(s(e),l(!1),d(!1));let t=!1;async function r(){try{let e=await f.current();if(t)return;om.set(a,e),s(e)}catch{}finally{t||(d(!1),l(!1))}}r();let o;return i>0&&(o=setInterval(r,i)),()=>{t=!0,o&&clearInterval(o)}},[a,i]),{data:o,isLoading:u,isFirstLoad:c,refresh:(0,H.useCallback)(()=>{if(!a)return;let e=a;f.current().then(t=>{om.set(e,t),p.current===e&&s(t)}).catch(()=>{})},[a])}}function lm(e){return e.providers&&e.providers.length>0?e.providers:[e.provider]}var um=(0,H.createContext)(null),dm=`specrails-desktop:activeProjectId`;function fm(e){try{e?localStorage.setItem(dm,e):localStorage.removeItem(dm)}catch{}}function pm(){try{return localStorage.getItem(dm)}catch{return null}}function mm({children:e}){let[t,n]=(0,H.useState)([]),[r,i]=(0,H.useState)(null),[a,s]=(0,H.useState)(!0),[c,l]=(0,H.useState)(!1),[u,d]=(0,H.useState)(new Set),f=(0,H.useRef)(null),p=(0,H.useRef)(new Set),m=(0,H.useCallback)(e=>{fm(e),rf(e),i(t=>(t!==null&&t!==e&&(f.current&&clearTimeout(f.current),l(!0),f.current=setTimeout(()=>l(!1),400)),e))},[]),{registerHandler:h,unregisterHandler:g}=df();(0,H.useEffect)(()=>{async function e(){try{let e=await fetch(`${o}/api/projects`);if(!e.ok)return;let t=await e.json();n(t.projects),t.setupProjectIds&&t.setupProjectIds.length>0&&d(new Set(t.setupProjectIds))}catch{}finally{s(!1)}}e()},[]);let _=(0,H.useCallback)(e=>{let t=e;if(typeof t.type==`string`){if(t.type===`desktop.projects`){if(!Array.isArray(t.projects))return;let e=t.projects;n(e),i(t=>{let n;if(t&&e.find(e=>e.id===t))n=t;else{let t=pm();n=t&&e.find(e=>e.id===t)?t:e.length>0?e[0].id:null}return fm(n),rf(n),n}),s(!1)}else if(t.type===`desktop.project_added`){let e=t.project;n(t=>t.find(t=>t.id===e.id)?t:[...t,e]),p.current.has(e.id)?p.current.delete(e.id):(q.success(am.t(`nav:projects.added`,{name:e.name})),m(e.id))}else if(t.type===`desktop.project_removed`){let e=t.projectId;q.success(am.t(`nav:projects.removed`)),cm(e),n(t=>t.filter(t=>t.id!==e)),i(t=>t===e?(fm(null),rf(null),null):t)}}},[]);(0,H.useLayoutEffect)(()=>(h(`desktop`,_),()=>g(`desktop`)),[_,h,g]);let v=(0,H.useCallback)(async(e,t,r=[`claude`])=>{try{let i={path:e,providers:r.length>0?r:[`claude`]};t&&(i.name=t);let a=await fetch(`/api/projects`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(i)});if(!a.ok){let e=await a.json();throw Error(e.error??`HTTP ${a.status}`)}let o=await a.json();return p.current.add(o.project.id),n(e=>e.find(e=>e.id===o.project.id)?e:[...e,o.project]),m(o.project.id),o}catch(e){throw console.error(`[useDesktop] addProject error:`,e),e}},[m]),y=(0,H.useCallback)(async e=>{try{let t=await fetch(`${o}/api/projects/${e}`,{method:`DELETE`});if(!t.ok){let e=await t.json();throw Error(e.error??`HTTP ${t.status}`)}cm(e),n(t=>t.filter(t=>t.id!==e)),d(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n}),i(t=>t===e?(fm(null),rf(null),null):t)}catch(e){throw console.error(`[useDesktop] removeProject error:`,e),e}},[]),b=(0,H.useCallback)(e=>{d(t=>new Set([...t,e]))},[]),x=(0,H.useCallback)(e=>{d(t=>{let n=new Set(t);return n.delete(e),n})},[]),S=(0,H.useMemo)(()=>({projects:t,activeProjectId:r,setActiveProjectId:m,addProject:v,removeProject:y,isLoading:a,isSwitchingProject:c,setupProjectIds:u,startSetupWizard:b,completeSetupWizard:x}),[t,r,m,v,y,a,c,u,b,x]);return(0,Y.jsx)(um.Provider,{value:S,children:e})}var hm={projects:[],activeProjectId:null,setActiveProjectId:()=>{},addProject:async()=>null,removeProject:async()=>{},isLoading:!1,isSwitchingProject:!1,setupProjectIds:new Set,startSetupWizard:()=>{},completeSetupWizard:()=>{}};function gm(){return(0,H.useContext)(um)??hm}var _m=new Map,vm=2e3;function ym(e){_m.set(e,(_m.get(e)??0)+1)}function bm(e){(_m.get(e)??0)<=0||setTimeout(()=>{let t=(_m.get(e)??0)-1;t<=0?_m.delete(e):_m.set(e,t)},vm)}function xm(e){return e?(_m.get(e)??0)>0:!1}var Sm=3e3,Cm=`
16
+ `},nl={onDragStart(e){let{active:t}=e;return`Picked up draggable item `+t.id+`.`},onDragOver(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was moved over droppable area `+n.id+`.`:`Draggable item `+t.id+` is no longer over a droppable area.`},onDragEnd(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was dropped over droppable area `+n.id:`Draggable item `+t.id+` was dropped.`},onDragCancel(e){let{active:t}=e;return`Dragging was cancelled. Draggable item `+t.id+` was dropped.`}};function rl(e){let{announcements:t=nl,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=tl}=e,{announce:a,announcement:o}=Zc(),s=Lc(`DndLiveRegion`),[c,l]=(0,H.useState)(!1);if((0,H.useEffect)(()=>{l(!0)},[]),$c((0,H.useMemo)(()=>({onDragStart(e){let{active:n}=e;a(t.onDragStart({active:n}))},onDragMove(e){let{active:n,over:r}=e;t.onDragMove&&a(t.onDragMove({active:n,over:r}))},onDragOver(e){let{active:n,over:r}=e;a(t.onDragOver({active:n,over:r}))},onDragEnd(e){let{active:n,over:r}=e;a(t.onDragEnd({active:n,over:r}))},onDragCancel(e){let{active:n,over:r}=e;a(t.onDragCancel({active:n,over:r}))}}),[a,t])),!c)return null;let u=H.createElement(H.Fragment,null,H.createElement(Yc,{id:r,value:i.draggable}),H.createElement(Xc,{id:s,announcement:o}));return n?(0,sr.createPortal)(u,n):u}var il;(function(e){e.DragStart=`dragStart`,e.DragMove=`dragMove`,e.DragEnd=`dragEnd`,e.DragCancel=`dragCancel`,e.DragOver=`dragOver`,e.RegisterDroppable=`registerDroppable`,e.SetDroppableDisabled=`setDroppableDisabled`,e.UnregisterDroppable=`unregisterDroppable`})(il||={});function al(){}function ol(e,t){return(0,H.useMemo)(()=>({sensor:e,options:t??{}}),[e,t])}function sl(){var e=[...arguments];return(0,H.useMemo)(()=>[...e].filter(e=>e!=null),[...e])}var cl=Object.freeze({x:0,y:0});function ll(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function ul(e,t){let n=Wc(e);if(!n)return`0 0`;let r={x:(n.x-t.left)/t.width*100,y:(n.y-t.top)/t.height*100};return r.x+`% `+r.y+`%`}function dl(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function fl(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function pl(e){let{left:t,top:n,height:r,width:i}=e;return[{x:t,y:n},{x:t+i,y:n},{x:t,y:n+r},{x:t+i,y:n+r}]}function ml(e,t){if(!e||e.length===0)return null;let[n]=e;return t?n[t]:n}function hl(e,t,n){return t===void 0&&(t=e.left),n===void 0&&(n=e.top),{x:t+e.width*.5,y:n+e.height*.5}}var gl=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=hl(t,t.left,t.top),a=[];for(let e of r){let{id:t}=e,r=n.get(t);if(r){let n=ll(hl(r),i);a.push({id:t,data:{droppableContainer:e,value:n}})}}return a.sort(dl)},_l=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=pl(t),a=[];for(let e of r){let{id:t}=e,r=n.get(t);if(r){let n=pl(r),o=i.reduce((e,t,r)=>e+ll(n[r],t),0),s=Number((o/4).toFixed(4));a.push({id:t,data:{droppableContainer:e,value:s}})}}return a.sort(dl)};function vl(e,t){let n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),i=Math.min(t.left+t.width,e.left+e.width),a=Math.min(t.top+t.height,e.top+e.height),o=i-r,s=a-n;if(r<i&&n<a){let n=t.width*t.height,r=e.width*e.height,i=o*s,a=i/(n+r-i);return Number(a.toFixed(4))}return 0}var yl=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=[];for(let e of r){let{id:r}=e,a=n.get(r);if(a){let n=vl(a,t);n>0&&i.push({id:r,data:{droppableContainer:e,value:n}})}}return i.sort(fl)};function bl(e,t){let{top:n,left:r,bottom:i,right:a}=t;return n<=e.y&&e.y<=i&&r<=e.x&&e.x<=a}var xl=e=>{let{droppableContainers:t,droppableRects:n,pointerCoordinates:r}=e;if(!r)return[];let i=[];for(let e of t){let{id:t}=e,a=n.get(t);if(a&&bl(r,a)){let n=pl(a).reduce((e,t)=>e+ll(r,t),0),o=Number((n/4).toFixed(4));i.push({id:t,data:{droppableContainer:e,value:o}})}}return i.sort(dl)};function Sl(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function Cl(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:cl}function wl(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>({...t,top:t.top+e*n.y,bottom:t.bottom+e*n.y,left:t.left+e*n.x,right:t.right+e*n.x}),{...t})}}var Tl=wl(1);function El(e){if(e.startsWith(`matrix3d(`)){let t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith(`matrix(`)){let t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function Dl(e,t,n){let r=El(t);if(!r)return e;let{scaleX:i,scaleY:a,x:o,y:s}=r,c=e.left-o-(1-i)*parseFloat(n),l=e.top-s-(1-a)*parseFloat(n.slice(n.indexOf(` `)+1)),u=i?e.width/i:e.width,d=a?e.height/a:e.height;return{width:u,height:d,top:l,right:c+u,bottom:l+d,left:c}}var Ol={ignoreTransform:!1};function kl(e,t){t===void 0&&(t=Ol);let n=e.getBoundingClientRect();if(t.ignoreTransform){let{transform:t,transformOrigin:r}=wc(e).getComputedStyle(e);t&&(n=Dl(n,t,r))}let{top:r,left:i,width:a,height:o,bottom:s,right:c}=n;return{top:r,left:i,width:a,height:o,bottom:s,right:c}}function Al(e){return kl(e,{ignoreTransform:!0})}function jl(e){let t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function Ml(e,t){return t===void 0&&(t=wc(e).getComputedStyle(e)),t.position===`fixed`}function Nl(e,t){t===void 0&&(t=wc(e).getComputedStyle(e));let n=/(auto|scroll|overlay)/;return[`overflow`,`overflowX`,`overflowY`].some(e=>{let r=t[e];return typeof r==`string`?n.test(r):!1})}function Pl(e,t){let n=[];function r(i){if(t!=null&&n.length>=t||!i)return n;if(Tc(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!Ec(i)||Dc(i)||n.includes(i))return n;let a=wc(e).getComputedStyle(i);return i!==e&&Nl(i,a)&&n.push(i),Ml(i,a)?n:r(i.parentNode)}return e?r(e):n}function Fl(e){let[t]=Pl(e,1);return t??null}function Il(e){return!xc||!e?null:Sc(e)?e:Cc(e)?Tc(e)||e===Oc(e).scrollingElement?window:Ec(e)?e:null:null}function Ll(e){return Sc(e)?e.scrollX:e.scrollLeft}function Rl(e){return Sc(e)?e.scrollY:e.scrollTop}function zl(e){return{x:Ll(e),y:Rl(e)}}var Bl;(function(e){e[e.Forward=1]=`Forward`,e[e.Backward=-1]=`Backward`})(Bl||={});function Vl(e){return!xc||!e?!1:e===document.scrollingElement}function Hl(e){let t={x:0,y:0},n=Vl(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height};return{isTop:e.scrollTop<=t.y,isLeft:e.scrollLeft<=t.x,isBottom:e.scrollTop>=r.y,isRight:e.scrollLeft>=r.x,maxScroll:r,minScroll:t}}var Ul={x:.2,y:.2};function Wl(e,t,n,r,i){let{top:a,left:o,right:s,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=Ul);let{isTop:l,isBottom:u,isLeft:d,isRight:f}=Hl(e),p={x:0,y:0},m={x:0,y:0},h={height:t.height*i.y,width:t.width*i.x};return!l&&a<=t.top+h.height?(p.y=Bl.Backward,m.y=r*Math.abs((t.top+h.height-a)/h.height)):!u&&c>=t.bottom-h.height&&(p.y=Bl.Forward,m.y=r*Math.abs((t.bottom-h.height-c)/h.height)),!f&&s>=t.right-h.width?(p.x=Bl.Forward,m.x=r*Math.abs((t.right-h.width-s)/h.width)):!d&&o<=t.left+h.width&&(p.x=Bl.Backward,m.x=r*Math.abs((t.left+h.width-o)/h.width)),{direction:p,speed:m}}function Gl(e){if(e===document.scrollingElement){let{innerWidth:e,innerHeight:t}=window;return{top:0,left:0,right:e,bottom:t,width:e,height:t}}let{top:t,left:n,right:r,bottom:i}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:i,width:e.clientWidth,height:e.clientHeight}}function Kl(e){return e.reduce((e,t)=>zc(e,zl(t)),cl)}function ql(e){return e.reduce((e,t)=>e+Ll(t),0)}function Jl(e){return e.reduce((e,t)=>e+Rl(t),0)}function Yl(e,t){if(t===void 0&&(t=kl),!e)return;let{top:n,left:r,bottom:i,right:a}=t(e);Fl(e)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:`center`,inline:`center`})}var Xl=[[`x`,[`left`,`right`],ql],[`y`,[`top`,`bottom`],Jl]],Zl=class{constructor(e,t){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;let n=Pl(t),r=Kl(n);this.rect={...e},this.width=e.width,this.height=e.height;for(let[e,t,i]of Xl)for(let a of t)Object.defineProperty(this,a,{get:()=>{let t=i(n),o=r[e]-t;return this.rect[a]+o},enumerable:!0});Object.defineProperty(this,`rect`,{enumerable:!1})}},Ql=class{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(e=>this.target?.removeEventListener(...e))},this.target=e}add(e,t,n){var r;(r=this.target)==null||r.addEventListener(e,t,n),this.listeners.push([e,t,n])}};function $l(e){let{EventTarget:t}=wc(e);return e instanceof t?e:Oc(e)}function eu(e,t){let n=Math.abs(e.x),r=Math.abs(e.y);return typeof t==`number`?Math.sqrt(n**2+r**2)>t:`x`in t&&`y`in t?n>t.x&&r>t.y:`x`in t?n>t.x:`y`in t?r>t.y:!1}var tu;(function(e){e.Click=`click`,e.DragStart=`dragstart`,e.Keydown=`keydown`,e.ContextMenu=`contextmenu`,e.Resize=`resize`,e.SelectionChange=`selectionchange`,e.VisibilityChange=`visibilitychange`})(tu||={});function nu(e){e.preventDefault()}function ru(e){e.stopPropagation()}var iu;(function(e){e.Space=`Space`,e.Down=`ArrowDown`,e.Right=`ArrowRight`,e.Left=`ArrowLeft`,e.Up=`ArrowUp`,e.Esc=`Escape`,e.Enter=`Enter`,e.Tab=`Tab`})(iu||={});var au={start:[iu.Space,iu.Enter],cancel:[iu.Esc],end:[iu.Space,iu.Enter,iu.Tab]},ou=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case iu.Right:return{...n,x:n.x+25};case iu.Left:return{...n,x:n.x-25};case iu.Down:return{...n,y:n.y+25};case iu.Up:return{...n,y:n.y-25}}},su=class{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;let{event:{target:t}}=e;this.props=e,this.listeners=new Ql(Oc(t)),this.windowListeners=new Ql(wc(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(tu.Resize,this.handleCancel),this.windowListeners.add(tu.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(tu.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&Yl(n),t(cl)}handleKeyDown(e){if(Hc(e)){let{active:t,context:n,options:r}=this.props,{keyboardCodes:i=au,coordinateGetter:a=ou,scrollBehavior:o=`smooth`}=r,{code:s}=e;if(i.end.includes(s)){this.handleEnd(e);return}if(i.cancel.includes(s)){this.handleCancel(e);return}let{collisionRect:c}=n.current,l=c?{x:c.left,y:c.top}:cl;this.referenceCoordinates||=l;let u=a(e,{active:t,context:n.current,currentCoordinates:l});if(u){let t=Bc(u,l),r={x:0,y:0},{scrollableAncestors:i}=n.current;for(let n of i){let i=e.code,{isTop:a,isRight:s,isLeft:c,isBottom:l,maxScroll:d,minScroll:f}=Hl(n),p=Gl(n),m={x:Math.min(i===iu.Right?p.right-p.width/2:p.right,Math.max(i===iu.Right?p.left:p.left+p.width/2,u.x)),y:Math.min(i===iu.Down?p.bottom-p.height/2:p.bottom,Math.max(i===iu.Down?p.top:p.top+p.height/2,u.y))},h=i===iu.Right&&!s||i===iu.Left&&!c,g=i===iu.Down&&!l||i===iu.Up&&!a;if(h&&m.x!==u.x){let e=n.scrollLeft+t.x,a=i===iu.Right&&e<=d.x||i===iu.Left&&e>=f.x;if(a&&!t.y){n.scrollTo({left:e,behavior:o});return}a?r.x=n.scrollLeft-e:r.x=i===iu.Right?n.scrollLeft-d.x:n.scrollLeft-f.x,r.x&&n.scrollBy({left:-r.x,behavior:o});break}else if(g&&m.y!==u.y){let e=n.scrollTop+t.y,a=i===iu.Down&&e<=d.y||i===iu.Up&&e>=f.y;if(a&&!t.x){n.scrollTo({top:e,behavior:o});return}a?r.y=n.scrollTop-e:r.y=i===iu.Down?n.scrollTop-d.y:n.scrollTop-f.y,r.y&&n.scrollBy({top:-r.y,behavior:o});break}}this.handleMove(e,zc(Bc(u,this.referenceCoordinates),r))}}}handleMove(e,t){let{onMove:n}=this.props;e.preventDefault(),n(t)}handleEnd(e){let{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){let{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}};su.activators=[{eventName:`onKeyDown`,handler:(e,t,n)=>{let{keyboardCodes:r=au,onActivation:i}=t,{active:a}=n,{code:o}=e.nativeEvent;if(r.start.includes(o)){let t=a.activatorNode.current;return t&&e.target!==t?!1:(e.preventDefault(),i?.({event:e.nativeEvent}),!0)}return!1}}];function cu(e){return!!(e&&`distance`in e)}function lu(e){return!!(e&&`delay`in e)}var uu=class{constructor(e,t,n){n===void 0&&(n=$l(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=t;let{event:r}=e,{target:i}=r;this.props=e,this.events=t,this.document=Oc(i),this.documentListeners=new Ql(this.document),this.listeners=new Ql(n),this.windowListeners=new Ql(wc(i)),this.initialCoordinates=Wc(r)??cl,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){let{events:e,props:{options:{activationConstraint:t,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(tu.Resize,this.handleCancel),this.windowListeners.add(tu.DragStart,nu),this.windowListeners.add(tu.VisibilityChange,this.handleCancel),this.windowListeners.add(tu.ContextMenu,nu),this.documentListeners.add(tu.Keydown,this.handleKeydown),t){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(lu(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(cu(t)){this.handlePending(t);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,t){let{active:n,onPending:r}=this.props;r(n,e,this.initialCoordinates,t)}handleStart(){let{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(tu.Click,ru,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(tu.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){let{activated:t,initialCoordinates:n,props:r}=this,{onMove:i,options:{activationConstraint:a}}=r;if(!n)return;let o=Wc(e)??cl,s=Bc(n,o);if(!t&&a){if(cu(a)){if(a.tolerance!=null&&eu(s,a.tolerance))return this.handleCancel();if(eu(s,a.distance))return this.handleStart()}if(lu(a)&&eu(s,a.tolerance))return this.handleCancel();this.handlePending(a,s);return}e.cancelable&&e.preventDefault(),i(o)}handleEnd(){let{onAbort:e,onEnd:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleCancel(){let{onAbort:e,onCancel:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleKeydown(e){e.code===iu.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}},du={cancel:{name:`pointercancel`},move:{name:`pointermove`},end:{name:`pointerup`}},fu=class extends uu{constructor(e){let{event:t}=e,n=Oc(t.target);super(e,du,n)}};fu.activators=[{eventName:`onPointerDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];var pu={move:{name:`mousemove`},end:{name:`mouseup`}},mu;(function(e){e[e.RightClick=2]=`RightClick`})(mu||={});var hu=class extends uu{constructor(e){super(e,pu,Oc(e.event.target))}};hu.activators=[{eventName:`onMouseDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===mu.RightClick?!1:(r?.({event:n}),!0)}}];var gu={cancel:{name:`touchcancel`},move:{name:`touchmove`},end:{name:`touchend`}},_u=class extends uu{constructor(e){super(e,gu)}static setup(){return window.addEventListener(gu.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(gu.move.name,e)};function e(){}}};_u.activators=[{eventName:`onTouchStart`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t,{touches:i}=n;return i.length>1?!1:(r?.({event:n}),!0)}}];var vu;(function(e){e[e.Pointer=0]=`Pointer`,e[e.DraggableRect=1]=`DraggableRect`})(vu||={});var yu;(function(e){e[e.TreeOrder=0]=`TreeOrder`,e[e.ReversedTreeOrder=1]=`ReversedTreeOrder`})(yu||={});function bu(e){let{acceleration:t,activator:n=vu.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:s=yu.TreeOrder,pointerCoordinates:c,scrollableAncestors:l,scrollableAncestorRects:u,delta:d,threshold:f}=e,p=Su({delta:d,disabled:!a}),[m,h]=jc(),g=(0,H.useRef)({x:0,y:0}),_=(0,H.useRef)({x:0,y:0}),v=(0,H.useMemo)(()=>{switch(n){case vu.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case vu.DraggableRect:return i}},[n,i,c]),y=(0,H.useRef)(null),b=(0,H.useCallback)(()=>{let e=y.current;if(!e)return;let t=g.current.x*_.current.x,n=g.current.y*_.current.y;e.scrollBy(t,n)},[]),x=(0,H.useMemo)(()=>s===yu.TreeOrder?[...l].reverse():l,[s,l]);(0,H.useEffect)(()=>{if(!a||!l.length||!v){h();return}for(let e of x){if(r?.(e)===!1)continue;let n=u[l.indexOf(e)];if(!n)continue;let{direction:i,speed:a}=Wl(e,n,v,t,f);for(let e of[`x`,`y`])p[e][i[e]]||(a[e]=0,i[e]=0);if(a.x>0||a.y>0){h(),y.current=e,m(b,o),g.current=a,_.current=i;return}}g.current={x:0,y:0},_.current={x:0,y:0},h()},[t,b,r,h,a,o,JSON.stringify(v),JSON.stringify(p),m,l,x,u,JSON.stringify(f)])}var xu={x:{[Bl.Backward]:!1,[Bl.Forward]:!1},y:{[Bl.Backward]:!1,[Bl.Forward]:!1}};function Su(e){let{delta:t,disabled:n}=e,r=Fc(t);return Nc(e=>{if(n||!r||!e)return xu;let i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[Bl.Backward]:e.x[Bl.Backward]||i.x===-1,[Bl.Forward]:e.x[Bl.Forward]||i.x===1},y:{[Bl.Backward]:e.y[Bl.Backward]||i.y===-1,[Bl.Forward]:e.y[Bl.Forward]||i.y===1}}},[n,t,r])}function Cu(e,t){let n=t==null?void 0:e.get(t),r=n?n.node.current:null;return Nc(e=>t==null?null:r??e??null,[r,t])}function wu(e,t){return(0,H.useMemo)(()=>e.reduce((e,n)=>{let{sensor:r}=n,i=r.activators.map(e=>({eventName:e.eventName,handler:t(e.handler,n)}));return[...e,...i]},[]),[e,t])}var Tu;(function(e){e[e.Always=0]=`Always`,e[e.BeforeDragging=1]=`BeforeDragging`,e[e.WhileDragging=2]=`WhileDragging`})(Tu||={});var Eu;(function(e){e.Optimized=`optimized`})(Eu||={});var Du=new Map;function Ou(e,t){let{dragging:n,dependencies:r,config:i}=t,[a,o]=(0,H.useState)(null),{frequency:s,measure:c,strategy:l}=i,u=(0,H.useRef)(e),d=g(),f=Mc(d),p=(0,H.useCallback)(function(e){e===void 0&&(e=[]),!f.current&&o(t=>t===null?e:t.concat(e.filter(e=>!t.includes(e))))},[f]),m=(0,H.useRef)(null),h=Nc(t=>{if(d&&!n)return Du;if(!t||t===Du||u.current!==e||a!=null){let t=new Map;for(let n of e){if(!n)continue;if(a&&a.length>0&&!a.includes(n.id)&&n.rect.current){t.set(n.id,n.rect.current);continue}let e=n.node.current,r=e?new Zl(c(e),e):null;n.rect.current=r,r&&t.set(n.id,r)}return t}return t},[e,a,n,d,c]);return(0,H.useEffect)(()=>{u.current=e},[e]),(0,H.useEffect)(()=>{d||p()},[n,d]),(0,H.useEffect)(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),(0,H.useEffect)(()=>{d||typeof s!=`number`||m.current!==null||(m.current=setTimeout(()=>{p(),m.current=null},s))},[s,d,p,...r]),{droppableRects:h,measureDroppableContainers:p,measuringScheduled:a!=null};function g(){switch(l){case Tu.Always:return!1;case Tu.BeforeDragging:return n;default:return!n}}}function ku(e,t){return Nc(n=>e?n||(typeof t==`function`?t(e):e):null,[t,e])}function Au(e,t){return ku(e,t)}function ju(e){let{callback:t,disabled:n}=e,r=Ac(t),i=(0,H.useMemo)(()=>{if(n||typeof window>`u`||window.MutationObserver===void 0)return;let{MutationObserver:e}=window;return new e(r)},[r,n]);return(0,H.useEffect)(()=>()=>i?.disconnect(),[i]),i}function Mu(e){let{callback:t,disabled:n}=e,r=Ac(t),i=(0,H.useMemo)(()=>{if(n||typeof window>`u`||window.ResizeObserver===void 0)return;let{ResizeObserver:e}=window;return new e(r)},[n]);return(0,H.useEffect)(()=>()=>i?.disconnect(),[i]),i}function Nu(e){return new Zl(kl(e),e)}function Pu(e,t,n){t===void 0&&(t=Nu);let[r,i]=(0,H.useState)(null);function a(){i(r=>{if(!e)return null;if(e.isConnected===!1)return r??n??null;let i=t(e);return JSON.stringify(r)===JSON.stringify(i)?r:i})}let o=ju({callback(t){if(e)for(let n of t){let{type:t,target:r}=n;if(t===`childList`&&r instanceof HTMLElement&&r.contains(e)){a();break}}}}),s=Mu({callback:a});return kc(()=>{a(),e?(s?.observe(e),o?.observe(document.body,{childList:!0,subtree:!0})):(s?.disconnect(),o?.disconnect())},[e]),r}function Fu(e){return Cl(e,ku(e))}var Iu=[];function Lu(e){let t=(0,H.useRef)(e),n=Nc(n=>e?n&&n!==Iu&&e&&t.current&&e.parentNode===t.current.parentNode?n:Pl(e):Iu,[e]);return(0,H.useEffect)(()=>{t.current=e},[e]),n}function Ru(e){let[t,n]=(0,H.useState)(null),r=(0,H.useRef)(e),i=(0,H.useCallback)(e=>{let t=Il(e.target);t&&n(e=>e?(e.set(t,zl(t)),new Map(e)):null)},[]);return(0,H.useEffect)(()=>{let t=r.current;if(e!==t){a(t);let o=e.map(e=>{let t=Il(e);return t?(t.addEventListener(`scroll`,i,{passive:!0}),[t,zl(t)]):null}).filter(e=>e!=null);n(o.length?new Map(o):null),r.current=e}return()=>{a(e),a(t)};function a(e){e.forEach(e=>{Il(e)?.removeEventListener(`scroll`,i)})}},[i,e]),(0,H.useMemo)(()=>e.length?t?Array.from(t.values()).reduce((e,t)=>zc(e,t),cl):Kl(e):cl,[e,t])}function zu(e,t){t===void 0&&(t=[]);let n=(0,H.useRef)(null);return(0,H.useEffect)(()=>{n.current=null},t),(0,H.useEffect)(()=>{let t=e!==cl;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)},[e]),n.current?Bc(e,n.current):cl}function Bu(e){(0,H.useEffect)(()=>{if(!xc)return;let t=e.map(e=>{let{sensor:t}=e;return t.setup==null?void 0:t.setup()});return()=>{for(let e of t)e?.()}},e.map(e=>{let{sensor:t}=e;return t}))}function Vu(e,t){return(0,H.useMemo)(()=>e.reduce((e,n)=>{let{eventName:r,handler:i}=n;return e[r]=e=>{i(e,t)},e},{}),[e,t])}function Hu(e){return(0,H.useMemo)(()=>e?jl(e):null,[e])}var Uu=[];function Wu(e,t){t===void 0&&(t=kl);let[n]=e,r=Hu(n?wc(n):null),[i,a]=(0,H.useState)(Uu);function o(){a(()=>e.length?e.map(e=>Vl(e)?r:new Zl(t(e),e)):Uu)}let s=Mu({callback:o});return kc(()=>{s?.disconnect(),o(),e.forEach(e=>s?.observe(e))},[e]),i}function Gu(e){if(!e)return null;if(e.children.length>1)return e;let t=e.children[0];return Ec(t)?t:e}function Ku(e){let{measure:t}=e,[n,r]=(0,H.useState)(null),i=Mu({callback:(0,H.useCallback)(e=>{for(let{target:n}of e)if(Ec(n)){r(e=>{let r=t(n);return e?{...e,width:r.width,height:r.height}:r});break}},[t])}),[a,o]=Pc((0,H.useCallback)(e=>{let n=Gu(e);i?.disconnect(),n&&i?.observe(n),r(n?t(n):null)},[t,i]));return(0,H.useMemo)(()=>({nodeRef:a,rect:n,setRef:o}),[n,a,o])}var qu=[{sensor:fu,options:{}},{sensor:su,options:{}}],Ju={current:{}},Yu={draggable:{measure:Al},droppable:{measure:Al,strategy:Tu.WhileDragging,frequency:Eu.Optimized},dragOverlay:{measure:kl}},Xu=class extends Map{get(e){return e==null?void 0:super.get(e)??void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:t}=e;return!t})}getNodeFor(e){return this.get(e)?.node.current??void 0}},Zu={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Xu,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:al},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Yu,measureDroppableContainers:al,windowRect:null,measuringScheduled:!1},Qu={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:``},dispatch:al,draggableNodes:new Map,over:null,measureDroppableContainers:al},$u=(0,H.createContext)(Qu),ed=(0,H.createContext)(Zu);function td(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Xu}}}function nd(e,t){switch(t.type){case il.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case il.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case il.DragEnd:case il.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case il.RegisterDroppable:{let{element:n}=t,{id:r}=n,i=new Xu(e.droppable.containers);return i.set(r,n),{...e,droppable:{...e.droppable,containers:i}}}case il.SetDroppableDisabled:{let{id:n,key:r,disabled:i}=t,a=e.droppable.containers.get(n);if(!a||r!==a.key)return e;let o=new Xu(e.droppable.containers);return o.set(n,{...a,disabled:i}),{...e,droppable:{...e.droppable,containers:o}}}case il.UnregisterDroppable:{let{id:n,key:r}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;let a=new Xu(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function rd(e){let{disabled:t}=e,{active:n,activatorEvent:r,draggableNodes:i}=(0,H.useContext)($u),a=Fc(r),o=Fc(n?.id);return(0,H.useEffect)(()=>{if(!t&&!r&&a&&o!=null){if(!Hc(a)||document.activeElement===a.target)return;let e=i.get(o);if(!e)return;let{activatorNode:t,node:n}=e;if(!t.current&&!n.current)return;requestAnimationFrame(()=>{for(let e of[t.current,n.current]){if(!e)continue;let t=qc(e);if(t){t.focus();break}}})}},[r,t,i,o,a]),null}function id(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((e,t)=>t({transform:e,...r}),n):n}function ad(e){return(0,H.useMemo)(()=>({draggable:{...Yu.draggable,...e?.draggable},droppable:{...Yu.droppable,...e?.droppable},dragOverlay:{...Yu.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function od(e){let{activeNode:t,measure:n,initialRect:r,config:i=!0}=e,a=(0,H.useRef)(!1),{x:o,y:s}=typeof i==`boolean`?{x:i,y:i}:i;kc(()=>{if(!o&&!s||!t){a.current=!1;return}if(a.current||!r)return;let e=t?.node.current;if(!e||e.isConnected===!1)return;let i=Cl(n(e),r);if(o||(i.x=0),s||(i.y=0),a.current=!0,Math.abs(i.x)>0||Math.abs(i.y)>0){let t=Fl(e);t&&t.scrollBy({top:i.y,left:i.x})}},[t,o,s,r,n])}var sd=(0,H.createContext)({...cl,scaleX:1,scaleY:1}),cd;(function(e){e[e.Uninitialized=0]=`Uninitialized`,e[e.Initializing=1]=`Initializing`,e[e.Initialized=2]=`Initialized`})(cd||={});var ld=(0,H.memo)(function(e){let{id:t,accessibility:n,autoScroll:r=!0,children:i,sensors:a=qu,collisionDetection:o=yl,measuring:s,modifiers:c,...l}=e,[u,d]=(0,H.useReducer)(nd,void 0,td),[f,p]=el(),[m,h]=(0,H.useState)(cd.Uninitialized),g=m===cd.Initialized,{draggable:{active:_,nodes:v,translate:y},droppable:{containers:b}}=u,x=_==null?null:v.get(_),S=(0,H.useRef)({initial:null,translated:null}),C=(0,H.useMemo)(()=>_==null?null:{id:_,data:x?.data??Ju,rect:S},[_,x]),w=(0,H.useRef)(null),[T,E]=(0,H.useState)(null),[D,O]=(0,H.useState)(null),k=Mc(l,Object.values(l)),A=Lc(`DndDescribedBy`,t),j=(0,H.useMemo)(()=>b.getEnabled(),[b]),M=ad(s),{droppableRects:N,measureDroppableContainers:P,measuringScheduled:F}=Ou(j,{dragging:g,dependencies:[y.x,y.y],config:M.droppable}),I=Cu(v,_),L=(0,H.useMemo)(()=>D?Wc(D):null,[D]),R=we(),z=Au(I,M.draggable.measure);od({activeNode:_==null?null:v.get(_),config:R.layoutShiftCompensation,initialRect:z,measure:M.draggable.measure});let ee=Pu(I,M.draggable.measure,z),te=Pu(I?I.parentElement:null),B=(0,H.useRef)({activatorEvent:null,active:null,activeNode:I,collisionRect:null,collisions:null,droppableRects:N,draggableNodes:v,draggingNode:null,draggingNodeRect:null,droppableContainers:b,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ne=b.getNodeFor(B.current.over?.id),V=Ku({measure:M.dragOverlay.measure}),re=V.nodeRef.current??I,U=g?V.rect??ee:null,ie=!!(V.nodeRef.current&&V.rect),ae=Fu(ie?null:ee),W=Hu(re?wc(re):null),oe=Lu(g?ne??I:null),se=Wu(oe),ce=id(c,{transform:{x:y.x-ae.x,y:y.y-ae.y,scaleX:1,scaleY:1},activatorEvent:D,active:C,activeNodeRect:ee,containerNodeRect:te,draggingNodeRect:U,over:B.current.over,overlayNodeRect:V.rect,scrollableAncestors:oe,scrollableAncestorRects:se,windowRect:W}),le=L?zc(L,y):null,ue=Ru(oe),de=zu(ue),fe=zu(ue,[ee]),pe=zc(ce,de),me=U?Tl(U,ce):null,he=C&&me?o({active:C,collisionRect:me,droppableRects:N,droppableContainers:j,pointerCoordinates:le}):null,ge=ml(he,`id`),[_e,ve]=(0,H.useState)(null),ye=Sl(ie?ce:zc(ce,fe),_e?.rect??null,ee),G=(0,H.useRef)(null),be=(0,H.useCallback)((e,t)=>{let{sensor:n,options:r}=t;if(w.current==null)return;let i=v.get(w.current);if(!i)return;let a=e.nativeEvent;G.current=new n({active:w.current,activeNode:i,event:a,options:r,context:B,onAbort(e){if(!v.get(e))return;let{onDragAbort:t}=k.current,n={id:e};t?.(n),f({type:`onDragAbort`,event:n})},onPending(e,t,n,r){if(!v.get(e))return;let{onDragPending:i}=k.current,a={id:e,constraint:t,initialCoordinates:n,offset:r};i?.(a),f({type:`onDragPending`,event:a})},onStart(e){let t=w.current;if(t==null)return;let n=v.get(t);if(!n)return;let{onDragStart:r}=k.current,i={activatorEvent:a,active:{id:t,data:n.data,rect:S}};(0,sr.unstable_batchedUpdates)(()=>{r?.(i),h(cd.Initializing),d({type:il.DragStart,initialCoordinates:e,active:t}),f({type:`onDragStart`,event:i}),E(G.current),O(a)})},onMove(e){d({type:il.DragMove,coordinates:e})},onEnd:o(il.DragEnd),onCancel:o(il.DragCancel)});function o(e){return async function(){let{active:t,collisions:n,over:r,scrollAdjustedTranslate:i}=B.current,o=null;if(t&&i){let{cancelDrop:s}=k.current;o={activatorEvent:a,active:t,collisions:n,delta:i,over:r},e===il.DragEnd&&typeof s==`function`&&await Promise.resolve(s(o))&&(e=il.DragCancel)}w.current=null,(0,sr.unstable_batchedUpdates)(()=>{d({type:e}),h(cd.Uninitialized),ve(null),E(null),O(null),G.current=null;let t=e===il.DragEnd?`onDragEnd`:`onDragCancel`;if(o){let e=k.current[t];e?.(o),f({type:t,event:o})}})}}},[v]),xe=wu(a,(0,H.useCallback)((e,t)=>(n,r)=>{let i=n.nativeEvent,a=v.get(r);if(w.current!==null||!a||i.dndKit||i.defaultPrevented)return;let o={active:a};e(n,t.options,o)===!0&&(i.dndKit={capturedBy:t.sensor},w.current=r,be(n,t))},[v,be]));Bu(a),kc(()=>{ee&&m===cd.Initializing&&h(cd.Initialized)},[ee,m]),(0,H.useEffect)(()=>{let{onDragMove:e}=k.current,{active:t,activatorEvent:n,collisions:r,over:i}=B.current;if(!t||!n)return;let a={active:t,activatorEvent:n,collisions:r,delta:{x:pe.x,y:pe.y},over:i};(0,sr.unstable_batchedUpdates)(()=>{e?.(a),f({type:`onDragMove`,event:a})})},[pe.x,pe.y]),(0,H.useEffect)(()=>{let{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:i}=B.current;if(!e||w.current==null||!t||!i)return;let{onDragOver:a}=k.current,o=r.get(ge),s=o&&o.rect.current?{id:o.id,rect:o.rect.current,data:o.data,disabled:o.disabled}:null,c={active:e,activatorEvent:t,collisions:n,delta:{x:i.x,y:i.y},over:s};(0,sr.unstable_batchedUpdates)(()=>{ve(s),a?.(c),f({type:`onDragOver`,event:c})})},[ge]),kc(()=>{B.current={activatorEvent:D,active:C,activeNode:I,collisionRect:me,collisions:he,droppableRects:N,draggableNodes:v,draggingNode:re,draggingNodeRect:U,droppableContainers:b,over:_e,scrollableAncestors:oe,scrollAdjustedTranslate:pe},S.current={initial:U,translated:me}},[C,I,he,me,v,re,U,N,b,_e,oe,pe]),bu({...R,delta:y,draggingRect:me,pointerCoordinates:le,scrollableAncestors:oe,scrollableAncestorRects:se});let Se=(0,H.useMemo)(()=>({active:C,activeNode:I,activeNodeRect:ee,activatorEvent:D,collisions:he,containerNodeRect:te,dragOverlay:V,draggableNodes:v,droppableContainers:b,droppableRects:N,over:_e,measureDroppableContainers:P,scrollableAncestors:oe,scrollableAncestorRects:se,measuringConfiguration:M,measuringScheduled:F,windowRect:W}),[C,I,ee,D,he,te,V,v,b,N,_e,P,oe,se,M,F,W]),Ce=(0,H.useMemo)(()=>({activatorEvent:D,activators:xe,active:C,activeNodeRect:ee,ariaDescribedById:{draggable:A},dispatch:d,draggableNodes:v,over:_e,measureDroppableContainers:P}),[D,xe,C,ee,d,A,v,_e,P]);return H.createElement(Qc.Provider,{value:p},H.createElement($u.Provider,{value:Ce},H.createElement(ed.Provider,{value:Se},H.createElement(sd.Provider,{value:ye},i)),H.createElement(rd,{disabled:n?.restoreFocus===!1})),H.createElement(rl,{...n,hiddenTextDescribedById:A}));function we(){let e=T?.autoScrollEnabled===!1,t=typeof r==`object`?r.enabled===!1:r===!1,n=g&&!e&&!t;return typeof r==`object`?{...r,enabled:n}:{enabled:n}}}),ud=(0,H.createContext)(null),dd=`button`,fd=`Draggable`;function pd(e){let{id:t,data:n,disabled:r=!1,attributes:i}=e,a=Lc(fd),{activators:o,activatorEvent:s,active:c,activeNodeRect:l,ariaDescribedById:u,draggableNodes:d,over:f}=(0,H.useContext)($u),{role:p=dd,roleDescription:m=`draggable`,tabIndex:h=0}=i??{},g=c?.id===t,_=(0,H.useContext)(g?sd:ud),[v,y]=Pc(),[b,x]=Pc(),S=Vu(o,t),C=Mc(n);return kc(()=>(d.set(t,{id:t,key:a,node:v,activatorNode:b,data:C}),()=>{let e=d.get(t);e&&e.key===a&&d.delete(t)}),[d,t]),{active:c,activatorEvent:s,activeNodeRect:l,attributes:(0,H.useMemo)(()=>({role:p,tabIndex:h,"aria-disabled":r,"aria-pressed":g&&p===dd?!0:void 0,"aria-roledescription":m,"aria-describedby":u.draggable}),[r,p,h,g,m,u.draggable]),isDragging:g,listeners:r?void 0:S,node:v,over:f,setNodeRef:y,setActivatorNodeRef:x,transform:_}}function md(){return(0,H.useContext)(ed)}var hd=`Droppable`,gd={timeout:25};function _d(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:i}=e,a=Lc(hd),{active:o,dispatch:s,over:c,measureDroppableContainers:l}=(0,H.useContext)($u),u=(0,H.useRef)({disabled:n}),d=(0,H.useRef)(!1),f=(0,H.useRef)(null),p=(0,H.useRef)(null),{disabled:m,updateMeasurementsFor:h,timeout:g}={...gd,...i},_=Mc(h??r),v=Mu({callback:(0,H.useCallback)(()=>{if(!d.current){d.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{l(Array.isArray(_.current)?_.current:[_.current]),p.current=null},g)},[g]),disabled:m||!o}),[y,b]=Pc((0,H.useCallback)((e,t)=>{v&&(t&&(v.unobserve(t),d.current=!1),e&&v.observe(e))},[v])),x=Mc(t);return(0,H.useEffect)(()=>{!v||!y.current||(v.disconnect(),d.current=!1,v.observe(y.current))},[y,v]),(0,H.useEffect)(()=>(s({type:il.RegisterDroppable,element:{id:r,key:a,disabled:n,node:y,rect:f,data:x}}),()=>s({type:il.UnregisterDroppable,key:a,id:r})),[r]),(0,H.useEffect)(()=>{n!==u.current.disabled&&(s({type:il.SetDroppableDisabled,id:r,key:a,disabled:n}),u.current.disabled=n)},[r,a,n,s]),{active:o,rect:f,isOver:c?.id===r,node:y,over:c,setNodeRef:b}}function vd(e){let{animation:t,children:n}=e,[r,i]=(0,H.useState)(null),[a,o]=(0,H.useState)(null),s=Fc(n);return!n&&!r&&s&&i(s),kc(()=>{if(!a)return;let e=r?.key,n=r?.props.id;if(e==null||n==null){i(null);return}Promise.resolve(t(n,a)).then(()=>{i(null)})},[t,r,a]),H.createElement(H.Fragment,null,n,r?(0,H.cloneElement)(r,{ref:o}):null)}var yd={x:0,y:0,scaleX:1,scaleY:1};function bd(e){let{children:t}=e;return H.createElement($u.Provider,{value:Qu},H.createElement(sd.Provider,{value:yd},t))}var xd={position:`fixed`,touchAction:`none`},Sd=e=>Hc(e)?`transform 250ms ease`:void 0,Cd=(0,H.forwardRef)((e,t)=>{let{as:n,activatorEvent:r,adjustScale:i,children:a,className:o,rect:s,style:c,transform:l,transition:u=Sd}=e;if(!s)return null;let d=i?l:{...l,scaleX:1,scaleY:1},f={...xd,width:s.width,height:s.height,top:s.top,left:s.left,transform:Gc.Transform.toString(d),transformOrigin:i&&r?ul(r,s):void 0,transition:typeof u==`function`?u(r):u,...c};return H.createElement(n,{className:o,style:f,ref:t},a)}),wd={duration:250,easing:`ease`,keyframes:e=>{let{transform:{initial:t,final:n}}=e;return[{transform:Gc.Transform.toString(t)},{transform:Gc.Transform.toString(n)}]},sideEffects:(e=>t=>{let{active:n,dragOverlay:r}=t,i={},{styles:a,className:o}=e;if(a!=null&&a.active)for(let[e,t]of Object.entries(a.active))t!==void 0&&(i[e]=n.node.style.getPropertyValue(e),n.node.style.setProperty(e,t));if(a!=null&&a.dragOverlay)for(let[e,t]of Object.entries(a.dragOverlay))t!==void 0&&r.node.style.setProperty(e,t);return o!=null&&o.active&&n.node.classList.add(o.active),o!=null&&o.dragOverlay&&r.node.classList.add(o.dragOverlay),function(){for(let[e,t]of Object.entries(i))n.node.style.setProperty(e,t);o!=null&&o.active&&n.node.classList.remove(o.active)}})({styles:{active:{opacity:`0`}}})};function Td(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:i}=e;return Ac((e,a)=>{if(t===null)return;let o=n.get(e);if(!o)return;let s=o.node.current;if(!s)return;let c=Gu(a);if(!c)return;let{transform:l}=wc(a).getComputedStyle(a),u=El(l);if(!u)return;let d=typeof t==`function`?t:Ed(t);return Yl(s,i.draggable.measure),d({active:{id:e,data:o.data,node:s,rect:i.draggable.measure(s)},draggableNodes:n,dragOverlay:{node:a,rect:i.dragOverlay.measure(c)},droppableContainers:r,measuringConfiguration:i,transform:u})})}function Ed(e){let{duration:t,easing:n,sideEffects:r,keyframes:i}={...wd,...e};return e=>{let{active:a,dragOverlay:o,transform:s,...c}=e;if(!t)return;let l={x:o.rect.left-a.rect.left,y:o.rect.top-a.rect.top},u={scaleX:s.scaleX===1?1:a.rect.width*s.scaleX/o.rect.width,scaleY:s.scaleY===1?1:a.rect.height*s.scaleY/o.rect.height},d={x:s.x-l.x,y:s.y-l.y,...u},f=i({...c,active:a,dragOverlay:o,transform:{initial:s,final:d}}),[p]=f,m=f[f.length-1];if(JSON.stringify(p)===JSON.stringify(m))return;let h=r?.({active:a,dragOverlay:o,...c}),g=o.node.animate(f,{duration:t,easing:n,fill:`forwards`});return new Promise(e=>{g.onfinish=()=>{h?.(),e()}})}}var Dd=0;function Od(e){return(0,H.useMemo)(()=>{if(e!=null)return Dd++,Dd},[e])}var kd=H.memo(e=>{let{adjustScale:t=!1,children:n,dropAnimation:r,style:i,transition:a,modifiers:o,wrapperElement:s=`div`,className:c,zIndex:l=999}=e,{activatorEvent:u,active:d,activeNodeRect:f,containerNodeRect:p,draggableNodes:m,droppableContainers:h,dragOverlay:g,over:_,measuringConfiguration:v,scrollableAncestors:y,scrollableAncestorRects:b,windowRect:x}=md(),S=(0,H.useContext)(sd),C=Od(d?.id),w=id(o,{activatorEvent:u,active:d,activeNodeRect:f,containerNodeRect:p,draggingNodeRect:g.rect,over:_,overlayNodeRect:g.rect,scrollableAncestors:y,scrollableAncestorRects:b,transform:S,windowRect:x}),T=ku(f),E=Td({config:r,draggableNodes:m,droppableContainers:h,measuringConfiguration:v}),D=T?g.setRef:void 0;return H.createElement(bd,null,H.createElement(vd,{animation:E},d&&C?H.createElement(Cd,{key:C,id:d.id,ref:D,as:s,activatorEvent:u,adjustScale:t,className:c,transition:a,rect:T,style:{zIndex:l,...i},transform:w},n):null))});function Ad(e,t,n){let r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function jd(e,t){return e.reduce((e,n,r)=>{let i=t.get(n);return i&&(e[r]=i),e},Array(e.length))}function Md(e){return e!==null&&e>=0}function Nd(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Pd(e){return typeof e==`boolean`?{draggable:e,droppable:e}:e}var Fd=e=>{let{rects:t,activeIndex:n,overIndex:r,index:i}=e,a=Ad(t,r,n),o=t[i],s=a[i];return!s||!o?null:{x:s.left-o.left,y:s.top-o.top,scaleX:s.width/o.width,scaleY:s.height/o.height}},Id={scaleX:1,scaleY:1},Ld=e=>{let{activeIndex:t,activeNodeRect:n,index:r,rects:i,overIndex:a}=e,o=i[t]??n;if(!o)return null;if(r===t){let e=i[a];return e?{x:0,y:t<a?e.top+e.height-(o.top+o.height):e.top-o.top,...Id}:null}let s=Rd(i,r,t);return r>t&&r<=a?{x:0,y:-o.height-s,...Id}:r<t&&r>=a?{x:0,y:o.height+s,...Id}:{x:0,y:0,...Id}};function Rd(e,t,n){let r=e[t],i=e[t-1],a=e[t+1];return r?n<t?i?r.top-(i.top+i.height):a?a.top-(r.top+r.height):0:a?a.top-(r.top+r.height):i?r.top-(i.top+i.height):0:0}var zd=`Sortable`,Bd=H.createContext({activeIndex:-1,containerId:zd,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:Fd,disabled:{draggable:!1,droppable:!1}});function Vd(e){let{children:t,id:n,items:r,strategy:i=Fd,disabled:a=!1}=e,{active:o,dragOverlay:s,droppableRects:c,over:l,measureDroppableContainers:u}=md(),d=Lc(zd,n),f=s.rect!==null,p=(0,H.useMemo)(()=>r.map(e=>typeof e==`object`&&`id`in e?e.id:e),[r]),m=o!=null,h=o?p.indexOf(o.id):-1,g=l?p.indexOf(l.id):-1,_=(0,H.useRef)(p),v=!Nd(p,_.current),y=g!==-1&&h===-1||v,b=Pd(a);kc(()=>{v&&m&&u(p)},[v,p,m,u]),(0,H.useEffect)(()=>{_.current=p},[p]);let x=(0,H.useMemo)(()=>({activeIndex:h,containerId:d,disabled:b,disableTransforms:y,items:p,overIndex:g,useDragOverlay:f,sortedRects:jd(p,c),strategy:i}),[h,d,b.draggable,b.droppable,y,p,g,c,f,i]);return H.createElement(Bd.Provider,{value:x},t)}var Hd=e=>{let{id:t,items:n,activeIndex:r,overIndex:i}=e;return Ad(n,r,i).indexOf(t)},Ud=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:i,items:a,newIndex:o,previousItems:s,previousContainerId:c,transition:l}=e;return!l||!r||s!==a&&i===o?!1:n?!0:o!==i&&t===c},Wd={duration:200,easing:`ease`},Gd=`transform`,Kd=Gc.Transition.toString({property:Gd,duration:0,easing:`linear`}),qd={roleDescription:`sortable`};function Jd(e){let{disabled:t,index:n,node:r,rect:i}=e,[a,o]=(0,H.useState)(null),s=(0,H.useRef)(n);return kc(()=>{if(!t&&n!==s.current&&r.current){let e=i.current;if(e){let t=kl(r.current,{ignoreTransform:!0}),n={x:e.left-t.left,y:e.top-t.top,scaleX:e.width/t.width,scaleY:e.height/t.height};(n.x||n.y)&&o(n)}}n!==s.current&&(s.current=n)},[t,n,r,i]),(0,H.useEffect)(()=>{a&&o(null)},[a]),a}function Yd(e){let{animateLayoutChanges:t=Ud,attributes:n,disabled:r,data:i,getNewIndex:a=Hd,id:o,strategy:s,resizeObserverConfig:c,transition:l=Wd}=e,{items:u,containerId:d,activeIndex:f,disabled:p,disableTransforms:m,sortedRects:h,overIndex:g,useDragOverlay:_,strategy:v}=(0,H.useContext)(Bd),y=Xd(r,p),b=u.indexOf(o),x=(0,H.useMemo)(()=>({sortable:{containerId:d,index:b,items:u},...i}),[d,i,b,u]),S=(0,H.useMemo)(()=>u.slice(u.indexOf(o)),[u,o]),{rect:C,node:w,isOver:T,setNodeRef:E}=_d({id:o,data:x,disabled:y.droppable,resizeObserverConfig:{updateMeasurementsFor:S,...c}}),{active:D,activatorEvent:O,activeNodeRect:k,attributes:A,setNodeRef:j,listeners:M,isDragging:N,over:P,setActivatorNodeRef:F,transform:I}=pd({id:o,data:x,attributes:{...qd,...n},disabled:y.draggable}),L=bc(E,j),R=!!D,z=R&&!m&&Md(f)&&Md(g),ee=!_&&N,te=z?(ee&&z?I:null)??(s??v)({rects:h,activeNodeRect:k,activeIndex:f,overIndex:g,index:b}):null,B=Md(f)&&Md(g)?a({id:o,items:u,activeIndex:f,overIndex:g}):b,ne=D?.id,V=(0,H.useRef)({activeId:ne,items:u,newIndex:B,containerId:d}),re=u!==V.current.items,U=t({active:D,containerId:d,isDragging:N,isSorting:R,id:o,index:b,items:u,newIndex:V.current.newIndex,previousItems:V.current.items,previousContainerId:V.current.containerId,transition:l,wasDragging:V.current.activeId!=null}),ie=Jd({disabled:!U,index:b,node:w,rect:C});return(0,H.useEffect)(()=>{R&&V.current.newIndex!==B&&(V.current.newIndex=B),d!==V.current.containerId&&(V.current.containerId=d),u!==V.current.items&&(V.current.items=u)},[R,B,d,u]),(0,H.useEffect)(()=>{if(ne===V.current.activeId)return;if(ne!=null&&V.current.activeId==null){V.current.activeId=ne;return}let e=setTimeout(()=>{V.current.activeId=ne},50);return()=>clearTimeout(e)},[ne]),{active:D,activeIndex:f,attributes:A,data:x,rect:C,index:b,newIndex:B,items:u,isOver:T,isSorting:R,isDragging:N,listeners:M,node:w,overIndex:g,over:P,setNodeRef:L,setActivatorNodeRef:F,setDroppableNodeRef:E,setDraggableNodeRef:j,transform:ie??te,transition:ae()};function ae(){if(ie||re&&V.current.newIndex===b)return Kd;if(!(ee&&!Hc(O)||!l)&&(R||U))return Gc.Transition.toString({...l,property:Gd})}}function Xd(e,t){return typeof e==`boolean`?{draggable:e,droppable:!1}:{draggable:e?.draggable??t.draggable,droppable:e?.droppable??t.droppable}}function Zd(e){if(!e)return!1;let t=e.data.current;return!!(t&&`sortable`in t&&typeof t.sortable==`object`&&`containerId`in t.sortable&&`items`in t.sortable&&`index`in t.sortable)}var Qd=[iu.Down,iu.Right,iu.Up,iu.Left],$d=(e,t)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:a,over:o,scrollableAncestors:s}}=t;if(Qd.includes(e.code)){if(e.preventDefault(),!n||!r)return;let t=[];a.getEnabled().forEach(n=>{if(!n||n!=null&&n.disabled)return;let a=i.get(n.id);if(a)switch(e.code){case iu.Down:r.top<a.top&&t.push(n);break;case iu.Up:r.top>a.top&&t.push(n);break;case iu.Left:r.left>a.left&&t.push(n);break;case iu.Right:r.left<a.left&&t.push(n);break}});let c=_l({active:n,collisionRect:r,droppableRects:i,droppableContainers:t,pointerCoordinates:null}),l=ml(c,`id`);if(l===o?.id&&c.length>1&&(l=c[1].id),l!=null){let e=a.get(n.id),t=a.get(l),o=t?i.get(t.id):null,c=t?.node.current;if(c&&o&&e&&t){let n=Pl(c).some((e,t)=>s[t]!==e),i=ef(e,t),a=tf(e,t),l=n||!i?{x:0,y:0}:{x:a?r.width-o.width:0,y:a?r.height-o.height:0},u={x:o.left,y:o.top};return l.x&&l.y?u:Bc(u,l)}}}};function ef(e,t){return!Zd(e)||!Zd(t)?!1:e.data.current.sortable.containerId===t.data.current.sortable.containerId}function tf(e,t){return!Zd(e)||!Zd(t)||!ef(e,t)?!1:e.data.current.sortable.index<t.data.current.sortable.index}var nf=null;function rf(e){nf=e}function af(){if(!nf)throw Error(`getApiBase called with no active project — call setActiveProjectId first`);return`${o}/api/projects/${nf}`}var of=i((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),sf=i(((e,t)=>{t.exports=of()})),Y=sf(),cf=[1e3,2e3,4e3,8e3,16e3],lf=(0,H.createContext)(null);function uf({url:e,children:t}){let[n,r]=(0,H.useState)(`connecting`),i=(0,H.useRef)(new Map),a=(0,H.useRef)(null),o=(0,H.useRef)(0),s=(0,H.useRef)(null);(0,H.useEffect)(()=>{let t=!1;function n(){if(t)return;let l=c(),u=l?new WebSocket(e,[`specrails-desktop`,l]):new WebSocket(e);a.current=u,r(`connecting`),u.onopen=()=>{if(t){u.close();return}o.current=0,r(`connected`)},u.onmessage=e=>{if(t)return;let n;try{n=JSON.parse(e.data)}catch{return}for(let e of i.current.values())try{e(n)}catch(e){console.error(`[useSharedWebSocket] handler threw while processing message`,e)}},u.onclose=()=>{if(t)return;a.current=null;let e=o.current;if(e>=cf.length){r(`connecting`),s.current=setTimeout(n,3e4);return}r(`connecting`);let i=cf[e];o.current+=1,s.current=setTimeout(n,i)}}return n(),()=>{t=!0,s.current&&clearTimeout(s.current);let e=a.current;if(e)if(e.onmessage=null,e.onclose=null,e.onerror=null,e.readyState===WebSocket.CONNECTING)e.onopen=()=>{try{e.close()}catch{}};else{e.onopen=null;try{e.close()}catch{}}}},[e]);let l=(0,H.useCallback)((e,t)=>{i.current.set(e,t)},[]),u=(0,H.useCallback)(e=>{i.current.delete(e)},[]),d=(0,H.useMemo)(()=>({registerHandler:l,unregisterHandler:u,connectionStatus:n}),[l,u,n]);return(0,Y.jsx)(lf.Provider,{value:d,children:t})}function df(){let e=(0,H.useContext)(lf);if(!e)throw Error(`useSharedWebSocket must be used within SharedWebSocketProvider`);return e}function ff(e){return(t={})=>{let n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}function pf(e){return(t,n)=>{let r=n?.context?String(n.context):`standalone`,i;if(r===`formatting`&&e.formattingValues){let t=e.defaultFormattingWidth||e.defaultWidth,r=n?.width?String(n.width):t;i=e.formattingValues[r]||e.formattingValues[t]}else{let t=e.defaultWidth,r=n?.width?String(n.width):e.defaultWidth;i=e.values[r]||e.values[t]}let a=e.argumentCallback?e.argumentCallback(t):t;return i[a]}}function mf(e){return(t,n={})=>{let r=n.width,i=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],a=t.match(i);if(!a)return null;let o=a[0],s=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],c=Array.isArray(s)?gf(s,e=>e.test(o)):hf(s,e=>e.test(o)),l;l=e.valueCallback?e.valueCallback(c):c,l=n.valueCallback?n.valueCallback(l):l;let u=t.slice(o.length);return{value:l,rest:u}}}function hf(e,t){for(let n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function gf(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function _f(e){return(t,n={})=>{let r=t.match(e.matchPattern);if(!r)return null;let i=r[0],a=t.match(e.parsePattern);if(!a)return null;let o=e.valueCallback?e.valueCallback(a[0]):a[0];o=n.valueCallback?n.valueCallback(o):o;let s=t.slice(i.length);return{value:o,rest:s}}}var vf=365.2425,yf=6048e5,bf=864e5,xf=6e4,Sf=36e5,Cf=43200,wf=1440,Tf=3600*24;Tf*7,Tf*vf/12*3;var Ef=Symbol.for(`constructDateFrom`);function Df(e,t){return typeof e==`function`?e(t):e&&typeof e==`object`&&Ef in e?e[Ef](t):e instanceof Date?new e.constructor(t):new Date(t)}function Of(e,...t){let n=Df.bind(null,e||t.find(e=>typeof e==`object`));return t.map(n)}var kf={};function Af(){return kf}function jf(e,t){return Df(t||e,e)}function Mf(e,t){let n=Af(),r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,i=jf(e,t?.in),a=i.getDay(),o=(a<r?7:0)+a-r;return i.setDate(i.getDate()-o),i.setHours(0,0,0,0),i}function Nf(e,t,n){let[r,i]=Of(n?.in,e,t);return+Mf(r,n)==+Mf(i,n)}var Pf={lessThanXSeconds:{standalone:{one:`weniger als 1 Sekunde`,other:`weniger als {{count}} Sekunden`},withPreposition:{one:`weniger als 1 Sekunde`,other:`weniger als {{count}} Sekunden`}},xSeconds:{standalone:{one:`1 Sekunde`,other:`{{count}} Sekunden`},withPreposition:{one:`1 Sekunde`,other:`{{count}} Sekunden`}},halfAMinute:{standalone:`eine halbe Minute`,withPreposition:`einer halben Minute`},lessThanXMinutes:{standalone:{one:`weniger als 1 Minute`,other:`weniger als {{count}} Minuten`},withPreposition:{one:`weniger als 1 Minute`,other:`weniger als {{count}} Minuten`}},xMinutes:{standalone:{one:`1 Minute`,other:`{{count}} Minuten`},withPreposition:{one:`1 Minute`,other:`{{count}} Minuten`}},aboutXHours:{standalone:{one:`etwa 1 Stunde`,other:`etwa {{count}} Stunden`},withPreposition:{one:`etwa 1 Stunde`,other:`etwa {{count}} Stunden`}},xHours:{standalone:{one:`1 Stunde`,other:`{{count}} Stunden`},withPreposition:{one:`1 Stunde`,other:`{{count}} Stunden`}},xDays:{standalone:{one:`1 Tag`,other:`{{count}} Tage`},withPreposition:{one:`1 Tag`,other:`{{count}} Tagen`}},aboutXWeeks:{standalone:{one:`etwa 1 Woche`,other:`etwa {{count}} Wochen`},withPreposition:{one:`etwa 1 Woche`,other:`etwa {{count}} Wochen`}},xWeeks:{standalone:{one:`1 Woche`,other:`{{count}} Wochen`},withPreposition:{one:`1 Woche`,other:`{{count}} Wochen`}},aboutXMonths:{standalone:{one:`etwa 1 Monat`,other:`etwa {{count}} Monate`},withPreposition:{one:`etwa 1 Monat`,other:`etwa {{count}} Monaten`}},xMonths:{standalone:{one:`1 Monat`,other:`{{count}} Monate`},withPreposition:{one:`1 Monat`,other:`{{count}} Monaten`}},aboutXYears:{standalone:{one:`etwa 1 Jahr`,other:`etwa {{count}} Jahre`},withPreposition:{one:`etwa 1 Jahr`,other:`etwa {{count}} Jahren`}},xYears:{standalone:{one:`1 Jahr`,other:`{{count}} Jahre`},withPreposition:{one:`1 Jahr`,other:`{{count}} Jahren`}},overXYears:{standalone:{one:`mehr als 1 Jahr`,other:`mehr als {{count}} Jahre`},withPreposition:{one:`mehr als 1 Jahr`,other:`mehr als {{count}} Jahren`}},almostXYears:{standalone:{one:`fast 1 Jahr`,other:`fast {{count}} Jahre`},withPreposition:{one:`fast 1 Jahr`,other:`fast {{count}} Jahren`}}},Ff=(e,t,n)=>{let r,i=n?.addSuffix?Pf[e].withPreposition:Pf[e].standalone;return r=typeof i==`string`?i:t===1?i.one:i.other.replace(`{{count}}`,String(t)),n?.addSuffix?n.comparison&&n.comparison>0?`in `+r:`vor `+r:r},If={date:ff({formats:{full:`EEEE, do MMMM y`,long:`do MMMM y`,medium:`do MMM y`,short:`dd.MM.y`},defaultWidth:`full`}),time:ff({formats:{full:`HH:mm:ss zzzz`,long:`HH:mm:ss z`,medium:`HH:mm:ss`,short:`HH:mm`},defaultWidth:`full`}),dateTime:ff({formats:{full:`{{date}} 'um' {{time}}`,long:`{{date}} 'um' {{time}}`,medium:`{{date}} {{time}}`,short:`{{date}} {{time}}`},defaultWidth:`full`})},Lf={lastWeek:`'letzten' eeee 'um' p`,yesterday:`'gestern um' p`,today:`'heute um' p`,tomorrow:`'morgen um' p`,nextWeek:`eeee 'um' p`,other:`P`},Rf=(e,t,n,r)=>Lf[e],zf={narrow:[`v.Chr.`,`n.Chr.`],abbreviated:[`v.Chr.`,`n.Chr.`],wide:[`vor Christus`,`nach Christus`]},Bf={narrow:[`1`,`2`,`3`,`4`],abbreviated:[`Q1`,`Q2`,`Q3`,`Q4`],wide:[`1. Quartal`,`2. Quartal`,`3. Quartal`,`4. Quartal`]},Vf={narrow:[`J`,`F`,`M`,`A`,`M`,`J`,`J`,`A`,`S`,`O`,`N`,`D`],abbreviated:[`Jan`,`Feb`,`Mär`,`Apr`,`Mai`,`Jun`,`Jul`,`Aug`,`Sep`,`Okt`,`Nov`,`Dez`],wide:[`Januar`,`Februar`,`März`,`April`,`Mai`,`Juni`,`Juli`,`August`,`September`,`Oktober`,`November`,`Dezember`]},Hf={narrow:Vf.narrow,abbreviated:[`Jan.`,`Feb.`,`März`,`Apr.`,`Mai`,`Juni`,`Juli`,`Aug.`,`Sep.`,`Okt.`,`Nov.`,`Dez.`],wide:Vf.wide},Uf={code:`de`,formatDistance:Ff,formatLong:If,formatRelative:Rf,localize:{ordinalNumber:e=>Number(e)+`.`,era:pf({values:zf,defaultWidth:`wide`}),quarter:pf({values:Bf,defaultWidth:`wide`,argumentCallback:e=>e-1}),month:pf({values:Vf,formattingValues:Hf,defaultWidth:`wide`}),day:pf({values:{narrow:[`S`,`M`,`D`,`M`,`D`,`F`,`S`],short:[`So`,`Mo`,`Di`,`Mi`,`Do`,`Fr`,`Sa`],abbreviated:[`So.`,`Mo.`,`Di.`,`Mi.`,`Do.`,`Fr.`,`Sa.`],wide:[`Sonntag`,`Montag`,`Dienstag`,`Mittwoch`,`Donnerstag`,`Freitag`,`Samstag`]},defaultWidth:`wide`}),dayPeriod:pf({values:{narrow:{am:`vm.`,pm:`nm.`,midnight:`Mitternacht`,noon:`Mittag`,morning:`Morgen`,afternoon:`Nachm.`,evening:`Abend`,night:`Nacht`},abbreviated:{am:`vorm.`,pm:`nachm.`,midnight:`Mitternacht`,noon:`Mittag`,morning:`Morgen`,afternoon:`Nachmittag`,evening:`Abend`,night:`Nacht`},wide:{am:`vormittags`,pm:`nachmittags`,midnight:`Mitternacht`,noon:`Mittag`,morning:`Morgen`,afternoon:`Nachmittag`,evening:`Abend`,night:`Nacht`}},defaultWidth:`wide`,formattingValues:{narrow:{am:`vm.`,pm:`nm.`,midnight:`Mitternacht`,noon:`Mittag`,morning:`morgens`,afternoon:`nachm.`,evening:`abends`,night:`nachts`},abbreviated:{am:`vorm.`,pm:`nachm.`,midnight:`Mitternacht`,noon:`Mittag`,morning:`morgens`,afternoon:`nachmittags`,evening:`abends`,night:`nachts`},wide:{am:`vormittags`,pm:`nachmittags`,midnight:`Mitternacht`,noon:`Mittag`,morning:`morgens`,afternoon:`nachmittags`,evening:`abends`,night:`nachts`}},defaultFormattingWidth:`wide`})},match:{ordinalNumber:_f({matchPattern:/^(\d+)(\.)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e)}),era:mf({matchPatterns:{narrow:/^(v\.? ?Chr\.?|n\.? ?Chr\.?)/i,abbreviated:/^(v\.? ?Chr\.?|n\.? ?Chr\.?)/i,wide:/^(vor Christus|vor unserer Zeitrechnung|nach Christus|unserer Zeitrechnung)/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/^v/i,/^n/i]},defaultParseWidth:`any`}),quarter:mf({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](\.)? Quartal/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:`any`,valueCallback:e=>e+1}),month:mf({matchPatterns:{narrow:/^[jfmasond]/i,abbreviated:/^(j[aä]n|feb|mär[z]?|apr|mai|jun[i]?|jul[i]?|aug|sep|okt|nov|dez)\.?/i,wide:/^(januar|februar|märz|april|mai|juni|juli|august|september|oktober|november|dezember)/i},defaultMatchWidth:`wide`,parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^j[aä]/i,/^f/i,/^mär/i,/^ap/i,/^mai/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},defaultParseWidth:`any`}),day:mf({matchPatterns:{narrow:/^[smdmf]/i,short:/^(so|mo|di|mi|do|fr|sa)/i,abbreviated:/^(son?|mon?|die?|mit?|don?|fre?|sam?)\.?/i,wide:/^(sonntag|montag|dienstag|mittwoch|donnerstag|freitag|samstag)/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/^so/i,/^mo/i,/^di/i,/^mi/i,/^do/i,/^f/i,/^sa/i]},defaultParseWidth:`any`}),dayPeriod:mf({matchPatterns:{narrow:/^(vm\.?|nm\.?|Mitternacht|Mittag|morgens|nachm\.?|abends|nachts)/i,abbreviated:/^(vorm\.?|nachm\.?|Mitternacht|Mittag|morgens|nachm\.?|abends|nachts)/i,wide:/^(vormittags|nachmittags|Mitternacht|Mittag|morgens|nachmittags|abends|nachts)/i},defaultMatchWidth:`wide`,parsePatterns:{any:{am:/^v/i,pm:/^n/i,midnight:/^Mitte/i,noon:/^Mitta/i,morning:/morgens/i,afternoon:/nachmittags/i,evening:/abends/i,night:/nachts/i}},defaultParseWidth:`any`})},options:{weekStartsOn:1,firstWeekContainsDate:4}},Wf={lessThanXSeconds:{one:`less than a second`,other:`less than {{count}} seconds`},xSeconds:{one:`1 second`,other:`{{count}} seconds`},halfAMinute:`half a minute`,lessThanXMinutes:{one:`less than a minute`,other:`less than {{count}} minutes`},xMinutes:{one:`1 minute`,other:`{{count}} minutes`},aboutXHours:{one:`about 1 hour`,other:`about {{count}} hours`},xHours:{one:`1 hour`,other:`{{count}} hours`},xDays:{one:`1 day`,other:`{{count}} days`},aboutXWeeks:{one:`about 1 week`,other:`about {{count}} weeks`},xWeeks:{one:`1 week`,other:`{{count}} weeks`},aboutXMonths:{one:`about 1 month`,other:`about {{count}} months`},xMonths:{one:`1 month`,other:`{{count}} months`},aboutXYears:{one:`about 1 year`,other:`about {{count}} years`},xYears:{one:`1 year`,other:`{{count}} years`},overXYears:{one:`over 1 year`,other:`over {{count}} years`},almostXYears:{one:`almost 1 year`,other:`almost {{count}} years`}},Gf=(e,t,n)=>{let r,i=Wf[e];return r=typeof i==`string`?i:t===1?i.one:i.other.replace(`{{count}}`,t.toString()),n?.addSuffix?n.comparison&&n.comparison>0?`in `+r:r+` ago`:r},Kf={lastWeek:`'last' eeee 'at' p`,yesterday:`'yesterday at' p`,today:`'today at' p`,tomorrow:`'tomorrow at' p`,nextWeek:`eeee 'at' p`,other:`P`},qf=(e,t,n,r)=>Kf[e],Jf={ordinalNumber:(e,t)=>{let n=Number(e),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+`st`;case 2:return n+`nd`;case 3:return n+`rd`}return n+`th`},era:pf({values:{narrow:[`B`,`A`],abbreviated:[`BC`,`AD`],wide:[`Before Christ`,`Anno Domini`]},defaultWidth:`wide`}),quarter:pf({values:{narrow:[`1`,`2`,`3`,`4`],abbreviated:[`Q1`,`Q2`,`Q3`,`Q4`],wide:[`1st quarter`,`2nd quarter`,`3rd quarter`,`4th quarter`]},defaultWidth:`wide`,argumentCallback:e=>e-1}),month:pf({values:{narrow:[`J`,`F`,`M`,`A`,`M`,`J`,`J`,`A`,`S`,`O`,`N`,`D`],abbreviated:[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],wide:[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`]},defaultWidth:`wide`}),day:pf({values:{narrow:[`S`,`M`,`T`,`W`,`T`,`F`,`S`],short:[`Su`,`Mo`,`Tu`,`We`,`Th`,`Fr`,`Sa`],abbreviated:[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],wide:[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`]},defaultWidth:`wide`}),dayPeriod:pf({values:{narrow:{am:`a`,pm:`p`,midnight:`mi`,noon:`n`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},abbreviated:{am:`AM`,pm:`PM`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},wide:{am:`a.m.`,pm:`p.m.`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`}},defaultWidth:`wide`,formattingValues:{narrow:{am:`a`,pm:`p`,midnight:`mi`,noon:`n`,morning:`in the morning`,afternoon:`in the afternoon`,evening:`in the evening`,night:`at night`},abbreviated:{am:`AM`,pm:`PM`,midnight:`midnight`,noon:`noon`,morning:`in the morning`,afternoon:`in the afternoon`,evening:`in the evening`,night:`at night`},wide:{am:`a.m.`,pm:`p.m.`,midnight:`midnight`,noon:`noon`,morning:`in the morning`,afternoon:`in the afternoon`,evening:`in the evening`,night:`at night`}},defaultFormattingWidth:`wide`})},Yf={ordinalNumber:_f({matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:mf({matchPatterns:{narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/^b/i,/^(a|c)/i]},defaultParseWidth:`any`}),quarter:mf({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:`any`,valueCallback:e=>e+1}),month:mf({matchPatterns:{narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},defaultMatchWidth:`wide`,parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},defaultParseWidth:`any`}),day:mf({matchPatterns:{narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},defaultMatchWidth:`wide`,parsePatterns:{narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},defaultParseWidth:`any`}),dayPeriod:mf({matchPatterns:{narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},defaultMatchWidth:`any`,parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},defaultParseWidth:`any`})},Xf={code:`en-US`,formatDistance:Gf,formatLong:{date:ff({formats:{full:`EEEE, MMMM do, y`,long:`MMMM do, y`,medium:`MMM d, y`,short:`MM/dd/yyyy`},defaultWidth:`full`}),time:ff({formats:{full:`h:mm:ss a zzzz`,long:`h:mm:ss a z`,medium:`h:mm:ss a`,short:`h:mm a`},defaultWidth:`full`}),dateTime:ff({formats:{full:`{{date}} 'at' {{time}}`,long:`{{date}} 'at' {{time}}`,medium:`{{date}}, {{time}}`,short:`{{date}}, {{time}}`},defaultWidth:`full`})},formatRelative:qf,localize:Jf,match:Yf,options:{weekStartsOn:0,firstWeekContainsDate:1}},Zf={lessThanXSeconds:{one:`menos de un segundo`,other:`menos de {{count}} segundos`},xSeconds:{one:`1 segundo`,other:`{{count}} segundos`},halfAMinute:`medio minuto`,lessThanXMinutes:{one:`menos de un minuto`,other:`menos de {{count}} minutos`},xMinutes:{one:`1 minuto`,other:`{{count}} minutos`},aboutXHours:{one:`alrededor de 1 hora`,other:`alrededor de {{count}} horas`},xHours:{one:`1 hora`,other:`{{count}} horas`},xDays:{one:`1 día`,other:`{{count}} días`},aboutXWeeks:{one:`alrededor de 1 semana`,other:`alrededor de {{count}} semanas`},xWeeks:{one:`1 semana`,other:`{{count}} semanas`},aboutXMonths:{one:`alrededor de 1 mes`,other:`alrededor de {{count}} meses`},xMonths:{one:`1 mes`,other:`{{count}} meses`},aboutXYears:{one:`alrededor de 1 año`,other:`alrededor de {{count}} años`},xYears:{one:`1 año`,other:`{{count}} años`},overXYears:{one:`más de 1 año`,other:`más de {{count}} años`},almostXYears:{one:`casi 1 año`,other:`casi {{count}} años`}},Qf=(e,t,n)=>{let r,i=Zf[e];return r=typeof i==`string`?i:t===1?i.one:i.other.replace(`{{count}}`,t.toString()),n?.addSuffix?n.comparison&&n.comparison>0?`en `+r:`hace `+r:r},$f={date:ff({formats:{full:`EEEE, d 'de' MMMM 'de' y`,long:`d 'de' MMMM 'de' y`,medium:`d MMM y`,short:`dd/MM/y`},defaultWidth:`full`}),time:ff({formats:{full:`HH:mm:ss zzzz`,long:`HH:mm:ss z`,medium:`HH:mm:ss`,short:`HH:mm`},defaultWidth:`full`}),dateTime:ff({formats:{full:`{{date}} 'a las' {{time}}`,long:`{{date}} 'a las' {{time}}`,medium:`{{date}}, {{time}}`,short:`{{date}}, {{time}}`},defaultWidth:`full`})},ep={lastWeek:`'el' eeee 'pasado a la' p`,yesterday:`'ayer a la' p`,today:`'hoy a la' p`,tomorrow:`'mañana a la' p`,nextWeek:`eeee 'a la' p`,other:`P`},tp={lastWeek:`'el' eeee 'pasado a las' p`,yesterday:`'ayer a las' p`,today:`'hoy a las' p`,tomorrow:`'mañana a las' p`,nextWeek:`eeee 'a las' p`,other:`P`},np={code:`es`,formatDistance:Qf,formatLong:$f,formatRelative:(e,t,n,r)=>t.getHours()===1?ep[e]:tp[e],localize:{ordinalNumber:(e,t)=>Number(e)+`º`,era:pf({values:{narrow:[`AC`,`DC`],abbreviated:[`AC`,`DC`],wide:[`antes de cristo`,`después de cristo`]},defaultWidth:`wide`}),quarter:pf({values:{narrow:[`1`,`2`,`3`,`4`],abbreviated:[`T1`,`T2`,`T3`,`T4`],wide:[`1º trimestre`,`2º trimestre`,`3º trimestre`,`4º trimestre`]},defaultWidth:`wide`,argumentCallback:e=>Number(e)-1}),month:pf({values:{narrow:[`e`,`f`,`m`,`a`,`m`,`j`,`j`,`a`,`s`,`o`,`n`,`d`],abbreviated:[`ene`,`feb`,`mar`,`abr`,`may`,`jun`,`jul`,`ago`,`sep`,`oct`,`nov`,`dic`],wide:[`enero`,`febrero`,`marzo`,`abril`,`mayo`,`junio`,`julio`,`agosto`,`septiembre`,`octubre`,`noviembre`,`diciembre`]},defaultWidth:`wide`}),day:pf({values:{narrow:[`d`,`l`,`m`,`m`,`j`,`v`,`s`],short:[`do`,`lu`,`ma`,`mi`,`ju`,`vi`,`sá`],abbreviated:[`dom`,`lun`,`mar`,`mié`,`jue`,`vie`,`sáb`],wide:[`domingo`,`lunes`,`martes`,`miércoles`,`jueves`,`viernes`,`sábado`]},defaultWidth:`wide`}),dayPeriod:pf({values:{narrow:{am:`a`,pm:`p`,midnight:`mn`,noon:`md`,morning:`mañana`,afternoon:`tarde`,evening:`tarde`,night:`noche`},abbreviated:{am:`AM`,pm:`PM`,midnight:`medianoche`,noon:`mediodia`,morning:`mañana`,afternoon:`tarde`,evening:`tarde`,night:`noche`},wide:{am:`a.m.`,pm:`p.m.`,midnight:`medianoche`,noon:`mediodia`,morning:`mañana`,afternoon:`tarde`,evening:`tarde`,night:`noche`}},defaultWidth:`wide`,formattingValues:{narrow:{am:`a`,pm:`p`,midnight:`mn`,noon:`md`,morning:`de la mañana`,afternoon:`de la tarde`,evening:`de la tarde`,night:`de la noche`},abbreviated:{am:`AM`,pm:`PM`,midnight:`medianoche`,noon:`mediodia`,morning:`de la mañana`,afternoon:`de la tarde`,evening:`de la tarde`,night:`de la noche`},wide:{am:`a.m.`,pm:`p.m.`,midnight:`medianoche`,noon:`mediodia`,morning:`de la mañana`,afternoon:`de la tarde`,evening:`de la tarde`,night:`de la noche`}},defaultFormattingWidth:`wide`})},match:{ordinalNumber:_f({matchPattern:/^(\d+)(º)?/i,parsePattern:/\d+/i,valueCallback:function(e){return parseInt(e,10)}}),era:mf({matchPatterns:{narrow:/^(ac|dc|a|d)/i,abbreviated:/^(a\.?\s?c\.?|a\.?\s?e\.?\s?c\.?|d\.?\s?c\.?|e\.?\s?c\.?)/i,wide:/^(antes de cristo|antes de la era com[uú]n|despu[eé]s de cristo|era com[uú]n)/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/^ac/i,/^dc/i],wide:[/^(antes de cristo|antes de la era com[uú]n)/i,/^(despu[eé]s de cristo|era com[uú]n)/i]},defaultParseWidth:`any`}),quarter:mf({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^T[1234]/i,wide:/^[1234](º)? trimestre/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:`any`,valueCallback:e=>e+1}),month:mf({matchPatterns:{narrow:/^[efmajsond]/i,abbreviated:/^(ene|feb|mar|abr|may|jun|jul|ago|sep|oct|nov|dic)/i,wide:/^(enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre)/i},defaultMatchWidth:`wide`,parsePatterns:{narrow:[/^e/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^en/i,/^feb/i,/^mar/i,/^abr/i,/^may/i,/^jun/i,/^jul/i,/^ago/i,/^sep/i,/^oct/i,/^nov/i,/^dic/i]},defaultParseWidth:`any`}),day:mf({matchPatterns:{narrow:/^[dlmjvs]/i,short:/^(do|lu|ma|mi|ju|vi|s[áa])/i,abbreviated:/^(dom|lun|mar|mi[ée]|jue|vie|s[áa]b)/i,wide:/^(domingo|lunes|martes|mi[ée]rcoles|jueves|viernes|s[áa]bado)/i},defaultMatchWidth:`wide`,parsePatterns:{narrow:[/^d/i,/^l/i,/^m/i,/^m/i,/^j/i,/^v/i,/^s/i],any:[/^do/i,/^lu/i,/^ma/i,/^mi/i,/^ju/i,/^vi/i,/^sa/i]},defaultParseWidth:`any`}),dayPeriod:mf({matchPatterns:{narrow:/^(a|p|mn|md|(de la|a las) (mañana|tarde|noche))/i,any:/^([ap]\.?\s?m\.?|medianoche|mediodia|(de la|a las) (mañana|tarde|noche))/i},defaultMatchWidth:`any`,parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mn/i,noon:/^md/i,morning:/mañana/i,afternoon:/tarde/i,evening:/tarde/i,night:/noche/i}},defaultParseWidth:`any`})},options:{weekStartsOn:1,firstWeekContainsDate:1}},rp={lessThanXSeconds:{one:`moins d’une seconde`,other:`moins de {{count}} secondes`},xSeconds:{one:`1 seconde`,other:`{{count}} secondes`},halfAMinute:`30 secondes`,lessThanXMinutes:{one:`moins d’une minute`,other:`moins de {{count}} minutes`},xMinutes:{one:`1 minute`,other:`{{count}} minutes`},aboutXHours:{one:`environ 1 heure`,other:`environ {{count}} heures`},xHours:{one:`1 heure`,other:`{{count}} heures`},xDays:{one:`1 jour`,other:`{{count}} jours`},aboutXWeeks:{one:`environ 1 semaine`,other:`environ {{count}} semaines`},xWeeks:{one:`1 semaine`,other:`{{count}} semaines`},aboutXMonths:{one:`environ 1 mois`,other:`environ {{count}} mois`},xMonths:{one:`1 mois`,other:`{{count}} mois`},aboutXYears:{one:`environ 1 an`,other:`environ {{count}} ans`},xYears:{one:`1 an`,other:`{{count}} ans`},overXYears:{one:`plus d’un an`,other:`plus de {{count}} ans`},almostXYears:{one:`presqu’un an`,other:`presque {{count}} ans`}},ip=(e,t,n)=>{let r,i=rp[e];return r=typeof i==`string`?i:t===1?i.one:i.other.replace(`{{count}}`,String(t)),n?.addSuffix?n.comparison&&n.comparison>0?`dans `+r:`il y a `+r:r},ap={date:ff({formats:{full:`EEEE d MMMM y`,long:`d MMMM y`,medium:`d MMM y`,short:`dd/MM/y`},defaultWidth:`full`}),time:ff({formats:{full:`HH:mm:ss zzzz`,long:`HH:mm:ss z`,medium:`HH:mm:ss`,short:`HH:mm`},defaultWidth:`full`}),dateTime:ff({formats:{full:`{{date}} 'à' {{time}}`,long:`{{date}} 'à' {{time}}`,medium:`{{date}}, {{time}}`,short:`{{date}}, {{time}}`},defaultWidth:`full`})},op={lastWeek:`eeee 'dernier à' p`,yesterday:`'hier à' p`,today:`'aujourd’hui à' p`,tomorrow:`'demain à' p'`,nextWeek:`eeee 'prochain à' p`,other:`P`},sp=(e,t,n,r)=>op[e],cp={narrow:[`av. J.-C`,`ap. J.-C`],abbreviated:[`av. J.-C`,`ap. J.-C`],wide:[`avant Jésus-Christ`,`après Jésus-Christ`]},lp={narrow:[`T1`,`T2`,`T3`,`T4`],abbreviated:[`1er trim.`,`2ème trim.`,`3ème trim.`,`4ème trim.`],wide:[`1er trimestre`,`2ème trimestre`,`3ème trimestre`,`4ème trimestre`]},up={narrow:[`J`,`F`,`M`,`A`,`M`,`J`,`J`,`A`,`S`,`O`,`N`,`D`],abbreviated:[`janv.`,`févr.`,`mars`,`avr.`,`mai`,`juin`,`juil.`,`août`,`sept.`,`oct.`,`nov.`,`déc.`],wide:[`janvier`,`février`,`mars`,`avril`,`mai`,`juin`,`juillet`,`août`,`septembre`,`octobre`,`novembre`,`décembre`]},dp={narrow:[`D`,`L`,`M`,`M`,`J`,`V`,`S`],short:[`di`,`lu`,`ma`,`me`,`je`,`ve`,`sa`],abbreviated:[`dim.`,`lun.`,`mar.`,`mer.`,`jeu.`,`ven.`,`sam.`],wide:[`dimanche`,`lundi`,`mardi`,`mercredi`,`jeudi`,`vendredi`,`samedi`]},fp={narrow:{am:`AM`,pm:`PM`,midnight:`minuit`,noon:`midi`,morning:`mat.`,afternoon:`ap.m.`,evening:`soir`,night:`mat.`},abbreviated:{am:`AM`,pm:`PM`,midnight:`minuit`,noon:`midi`,morning:`matin`,afternoon:`après-midi`,evening:`soir`,night:`matin`},wide:{am:`AM`,pm:`PM`,midnight:`minuit`,noon:`midi`,morning:`du matin`,afternoon:`de l’après-midi`,evening:`du soir`,night:`du matin`}},pp=(e,t)=>{let n=Number(e),r=t?.unit;if(n===0)return`0`;let i=[`year`,`week`,`hour`,`minute`,`second`],a;return a=n===1?r&&i.includes(r)?`ère`:`er`:`ème`,n+a},mp=[`MMM`,`MMMM`],hp={code:`fr`,formatDistance:ip,formatLong:ap,formatRelative:sp,localize:{preprocessor:(e,t)=>e.getDate()===1||!t.some(e=>e.isToken&&mp.includes(e.value))?t:t.map(e=>e.isToken&&e.value===`do`?{isToken:!0,value:`d`}:e),ordinalNumber:pp,era:pf({values:cp,defaultWidth:`wide`}),quarter:pf({values:lp,defaultWidth:`wide`,argumentCallback:e=>e-1}),month:pf({values:up,defaultWidth:`wide`}),day:pf({values:dp,defaultWidth:`wide`}),dayPeriod:pf({values:fp,defaultWidth:`wide`})},match:{ordinalNumber:_f({matchPattern:/^(\d+)(ième|ère|ème|er|e)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e)}),era:mf({matchPatterns:{narrow:/^(av\.J\.C|ap\.J\.C|ap\.J\.-C)/i,abbreviated:/^(av\.J\.-C|av\.J-C|apr\.J\.-C|apr\.J-C|ap\.J-C)/i,wide:/^(avant Jésus-Christ|après Jésus-Christ)/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/^av/i,/^ap/i]},defaultParseWidth:`any`}),quarter:mf({matchPatterns:{narrow:/^T?[1234]/i,abbreviated:/^[1234](er|ème|e)? trim\.?/i,wide:/^[1234](er|ème|e)? trimestre/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:`any`,valueCallback:e=>e+1}),month:mf({matchPatterns:{narrow:/^[jfmasond]/i,abbreviated:/^(janv|févr|mars|avr|mai|juin|juill|juil|août|sept|oct|nov|déc)\.?/i,wide:/^(janvier|février|mars|avril|mai|juin|juillet|août|septembre|octobre|novembre|décembre)/i},defaultMatchWidth:`wide`,parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^av/i,/^ma/i,/^juin/i,/^juil/i,/^ao/i,/^s/i,/^o/i,/^n/i,/^d/i]},defaultParseWidth:`any`}),day:mf({matchPatterns:{narrow:/^[lmjvsd]/i,short:/^(di|lu|ma|me|je|ve|sa)/i,abbreviated:/^(dim|lun|mar|mer|jeu|ven|sam)\.?/i,wide:/^(dimanche|lundi|mardi|mercredi|jeudi|vendredi|samedi)/i},defaultMatchWidth:`wide`,parsePatterns:{narrow:[/^d/i,/^l/i,/^m/i,/^m/i,/^j/i,/^v/i,/^s/i],any:[/^di/i,/^lu/i,/^ma/i,/^me/i,/^je/i,/^ve/i,/^sa/i]},defaultParseWidth:`any`}),dayPeriod:mf({matchPatterns:{narrow:/^(a|p|minuit|midi|mat\.?|ap\.?m\.?|soir|nuit)/i,any:/^([ap]\.?\s?m\.?|du matin|de l'après[-\s]midi|du soir|de la nuit)/i},defaultMatchWidth:`any`,parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^min/i,noon:/^mid/i,morning:/mat/i,afternoon:/ap/i,evening:/soir/i,night:/nuit/i}},defaultParseWidth:`any`})},options:{weekStartsOn:1,firstWeekContainsDate:4}},gp={lessThanXSeconds:{one:`meno di un secondo`,other:`meno di {{count}} secondi`},xSeconds:{one:`un secondo`,other:`{{count}} secondi`},halfAMinute:`alcuni secondi`,lessThanXMinutes:{one:`meno di un minuto`,other:`meno di {{count}} minuti`},xMinutes:{one:`un minuto`,other:`{{count}} minuti`},aboutXHours:{one:`circa un'ora`,other:`circa {{count}} ore`},xHours:{one:`un'ora`,other:`{{count}} ore`},xDays:{one:`un giorno`,other:`{{count}} giorni`},aboutXWeeks:{one:`circa una settimana`,other:`circa {{count}} settimane`},xWeeks:{one:`una settimana`,other:`{{count}} settimane`},aboutXMonths:{one:`circa un mese`,other:`circa {{count}} mesi`},xMonths:{one:`un mese`,other:`{{count}} mesi`},aboutXYears:{one:`circa un anno`,other:`circa {{count}} anni`},xYears:{one:`un anno`,other:`{{count}} anni`},overXYears:{one:`più di un anno`,other:`più di {{count}} anni`},almostXYears:{one:`quasi un anno`,other:`quasi {{count}} anni`}},_p=(e,t,n)=>{let r,i=gp[e];return r=typeof i==`string`?i:t===1?i.one:i.other.replace(`{{count}}`,t.toString()),n?.addSuffix?n.comparison&&n.comparison>0?`tra `+r:r+` fa`:r},vp={date:ff({formats:{full:`EEEE d MMMM y`,long:`d MMMM y`,medium:`d MMM y`,short:`dd/MM/y`},defaultWidth:`full`}),time:ff({formats:{full:`HH:mm:ss zzzz`,long:`HH:mm:ss z`,medium:`HH:mm:ss`,short:`HH:mm`},defaultWidth:`full`}),dateTime:ff({formats:{full:`{{date}} {{time}}`,long:`{{date}} {{time}}`,medium:`{{date}} {{time}}`,short:`{{date}} {{time}}`},defaultWidth:`full`})},yp=[`domenica`,`lunedì`,`martedì`,`mercoledì`,`giovedì`,`venerdì`,`sabato`];function bp(e){switch(e){case 0:return`'domenica scorsa alle' p`;default:return`'`+yp[e]+` scorso alle' p`}}function xp(e){return`'`+yp[e]+` alle' p`}function Sp(e){switch(e){case 0:return`'domenica prossima alle' p`;default:return`'`+yp[e]+` prossimo alle' p`}}var Cp={lastWeek:(e,t,n)=>{let r=e.getDay();return Nf(e,t,n)?xp(r):bp(r)},yesterday:`'ieri alle' p`,today:`'oggi alle' p`,tomorrow:`'domani alle' p`,nextWeek:(e,t,n)=>{let r=e.getDay();return Nf(e,t,n)?xp(r):Sp(r)},other:`P`},wp={code:`it`,formatDistance:_p,formatLong:vp,formatRelative:(e,t,n,r)=>{let i=Cp[e];return typeof i==`function`?i(t,n,r):i},localize:{ordinalNumber:(e,t)=>{let n=Number(e);return String(n)},era:pf({values:{narrow:[`aC`,`dC`],abbreviated:[`a.C.`,`d.C.`],wide:[`avanti Cristo`,`dopo Cristo`]},defaultWidth:`wide`}),quarter:pf({values:{narrow:[`1`,`2`,`3`,`4`],abbreviated:[`T1`,`T2`,`T3`,`T4`],wide:[`1º trimestre`,`2º trimestre`,`3º trimestre`,`4º trimestre`]},defaultWidth:`wide`,argumentCallback:e=>e-1}),month:pf({values:{narrow:[`G`,`F`,`M`,`A`,`M`,`G`,`L`,`A`,`S`,`O`,`N`,`D`],abbreviated:[`gen`,`feb`,`mar`,`apr`,`mag`,`giu`,`lug`,`ago`,`set`,`ott`,`nov`,`dic`],wide:[`gennaio`,`febbraio`,`marzo`,`aprile`,`maggio`,`giugno`,`luglio`,`agosto`,`settembre`,`ottobre`,`novembre`,`dicembre`]},defaultWidth:`wide`}),day:pf({values:{narrow:[`D`,`L`,`M`,`M`,`G`,`V`,`S`],short:[`dom`,`lun`,`mar`,`mer`,`gio`,`ven`,`sab`],abbreviated:[`dom`,`lun`,`mar`,`mer`,`gio`,`ven`,`sab`],wide:[`domenica`,`lunedì`,`martedì`,`mercoledì`,`giovedì`,`venerdì`,`sabato`]},defaultWidth:`wide`}),dayPeriod:pf({values:{narrow:{am:`m.`,pm:`p.`,midnight:`mezzanotte`,noon:`mezzogiorno`,morning:`mattina`,afternoon:`pomeriggio`,evening:`sera`,night:`notte`},abbreviated:{am:`AM`,pm:`PM`,midnight:`mezzanotte`,noon:`mezzogiorno`,morning:`mattina`,afternoon:`pomeriggio`,evening:`sera`,night:`notte`},wide:{am:`AM`,pm:`PM`,midnight:`mezzanotte`,noon:`mezzogiorno`,morning:`mattina`,afternoon:`pomeriggio`,evening:`sera`,night:`notte`}},defaultWidth:`wide`,formattingValues:{narrow:{am:`m.`,pm:`p.`,midnight:`mezzanotte`,noon:`mezzogiorno`,morning:`di mattina`,afternoon:`del pomeriggio`,evening:`di sera`,night:`di notte`},abbreviated:{am:`AM`,pm:`PM`,midnight:`mezzanotte`,noon:`mezzogiorno`,morning:`di mattina`,afternoon:`del pomeriggio`,evening:`di sera`,night:`di notte`},wide:{am:`AM`,pm:`PM`,midnight:`mezzanotte`,noon:`mezzogiorno`,morning:`di mattina`,afternoon:`del pomeriggio`,evening:`di sera`,night:`di notte`}},defaultFormattingWidth:`wide`})},match:{ordinalNumber:_f({matchPattern:/^(\d+)(º)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:mf({matchPatterns:{narrow:/^(aC|dC)/i,abbreviated:/^(a\.?\s?C\.?|a\.?\s?e\.?\s?v\.?|d\.?\s?C\.?|e\.?\s?v\.?)/i,wide:/^(avanti Cristo|avanti Era Volgare|dopo Cristo|Era Volgare)/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/^a/i,/^(d|e)/i]},defaultParseWidth:`any`}),quarter:mf({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^t[1234]/i,wide:/^[1234](º)? trimestre/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:`any`,valueCallback:e=>e+1}),month:mf({matchPatterns:{narrow:/^[gfmalsond]/i,abbreviated:/^(gen|feb|mar|apr|mag|giu|lug|ago|set|ott|nov|dic)/i,wide:/^(gennaio|febbraio|marzo|aprile|maggio|giugno|luglio|agosto|settembre|ottobre|novembre|dicembre)/i},defaultMatchWidth:`wide`,parsePatterns:{narrow:[/^g/i,/^f/i,/^m/i,/^a/i,/^m/i,/^g/i,/^l/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ge/i,/^f/i,/^mar/i,/^ap/i,/^mag/i,/^gi/i,/^l/i,/^ag/i,/^s/i,/^o/i,/^n/i,/^d/i]},defaultParseWidth:`any`}),day:mf({matchPatterns:{narrow:/^[dlmgvs]/i,short:/^(do|lu|ma|me|gi|ve|sa)/i,abbreviated:/^(dom|lun|mar|mer|gio|ven|sab)/i,wide:/^(domenica|luned[i|ì]|marted[i|ì]|mercoled[i|ì]|gioved[i|ì]|venerd[i|ì]|sabato)/i},defaultMatchWidth:`wide`,parsePatterns:{narrow:[/^d/i,/^l/i,/^m/i,/^m/i,/^g/i,/^v/i,/^s/i],any:[/^d/i,/^l/i,/^ma/i,/^me/i,/^g/i,/^v/i,/^s/i]},defaultParseWidth:`any`}),dayPeriod:mf({matchPatterns:{narrow:/^(a|m\.|p|mezzanotte|mezzogiorno|(di|del) (mattina|pomeriggio|sera|notte))/i,any:/^([ap]\.?\s?m\.?|mezzanotte|mezzogiorno|(di|del) (mattina|pomeriggio|sera|notte))/i},defaultMatchWidth:`any`,parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mezza/i,noon:/^mezzo/i,morning:/mattina/i,afternoon:/pomeriggio/i,evening:/sera/i,night:/notte/i}},defaultParseWidth:`any`})},options:{weekStartsOn:1,firstWeekContainsDate:4}},Tp={lessThanXSeconds:{one:`1秒未満`,other:`{{count}}秒未満`,oneWithSuffix:`約1秒`,otherWithSuffix:`約{{count}}秒`},xSeconds:{one:`1秒`,other:`{{count}}秒`},halfAMinute:`30秒`,lessThanXMinutes:{one:`1分未満`,other:`{{count}}分未満`,oneWithSuffix:`約1分`,otherWithSuffix:`約{{count}}分`},xMinutes:{one:`1分`,other:`{{count}}分`},aboutXHours:{one:`約1時間`,other:`約{{count}}時間`},xHours:{one:`1時間`,other:`{{count}}時間`},xDays:{one:`1日`,other:`{{count}}日`},aboutXWeeks:{one:`約1週間`,other:`約{{count}}週間`},xWeeks:{one:`1週間`,other:`{{count}}週間`},aboutXMonths:{one:`約1か月`,other:`約{{count}}か月`},xMonths:{one:`1か月`,other:`{{count}}か月`},aboutXYears:{one:`約1年`,other:`約{{count}}年`},xYears:{one:`1年`,other:`{{count}}年`},overXYears:{one:`1年以上`,other:`{{count}}年以上`},almostXYears:{one:`1年近く`,other:`{{count}}年近く`}},Ep=(e,t,n)=>{n||={};let r,i=Tp[e];return r=typeof i==`string`?i:t===1?n.addSuffix&&i.oneWithSuffix?i.oneWithSuffix:i.one:n.addSuffix&&i.otherWithSuffix?i.otherWithSuffix.replace(`{{count}}`,String(t)):i.other.replace(`{{count}}`,String(t)),n.addSuffix?n.comparison&&n.comparison>0?r+`後`:r+`前`:r},Dp={date:ff({formats:{full:`y年M月d日EEEE`,long:`y年M月d日`,medium:`y/MM/dd`,short:`y/MM/dd`},defaultWidth:`full`}),time:ff({formats:{full:`H時mm分ss秒 zzzz`,long:`H:mm:ss z`,medium:`H:mm:ss`,short:`H:mm`},defaultWidth:`full`}),dateTime:ff({formats:{full:`{{date}} {{time}}`,long:`{{date}} {{time}}`,medium:`{{date}} {{time}}`,short:`{{date}} {{time}}`},defaultWidth:`full`})},Op={lastWeek:`先週のeeeeのp`,yesterday:`昨日のp`,today:`今日のp`,tomorrow:`明日のp`,nextWeek:`翌週のeeeeのp`,other:`P`},kp={code:`ja`,formatDistance:Ep,formatLong:Dp,formatRelative:(e,t,n,r)=>Op[e],localize:{ordinalNumber:(e,t)=>{let n=Number(e);switch(String(t?.unit)){case`year`:return`${n}年`;case`quarter`:return`第${n}四半期`;case`month`:return`${n}月`;case`week`:return`第${n}週`;case`date`:return`${n}日`;case`hour`:return`${n}時`;case`minute`:return`${n}分`;case`second`:return`${n}秒`;default:return`${n}`}},era:pf({values:{narrow:[`BC`,`AC`],abbreviated:[`紀元前`,`西暦`],wide:[`紀元前`,`西暦`]},defaultWidth:`wide`}),quarter:pf({values:{narrow:[`1`,`2`,`3`,`4`],abbreviated:[`Q1`,`Q2`,`Q3`,`Q4`],wide:[`第1四半期`,`第2四半期`,`第3四半期`,`第4四半期`]},defaultWidth:`wide`,argumentCallback:e=>Number(e)-1}),month:pf({values:{narrow:[`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`,`10`,`11`,`12`],abbreviated:[`1月`,`2月`,`3月`,`4月`,`5月`,`6月`,`7月`,`8月`,`9月`,`10月`,`11月`,`12月`],wide:[`1月`,`2月`,`3月`,`4月`,`5月`,`6月`,`7月`,`8月`,`9月`,`10月`,`11月`,`12月`]},defaultWidth:`wide`}),day:pf({values:{narrow:[`日`,`月`,`火`,`水`,`木`,`金`,`土`],short:[`日`,`月`,`火`,`水`,`木`,`金`,`土`],abbreviated:[`日`,`月`,`火`,`水`,`木`,`金`,`土`],wide:[`日曜日`,`月曜日`,`火曜日`,`水曜日`,`木曜日`,`金曜日`,`土曜日`]},defaultWidth:`wide`}),dayPeriod:pf({values:{narrow:{am:`午前`,pm:`午後`,midnight:`深夜`,noon:`正午`,morning:`朝`,afternoon:`午後`,evening:`夜`,night:`深夜`},abbreviated:{am:`午前`,pm:`午後`,midnight:`深夜`,noon:`正午`,morning:`朝`,afternoon:`午後`,evening:`夜`,night:`深夜`},wide:{am:`午前`,pm:`午後`,midnight:`深夜`,noon:`正午`,morning:`朝`,afternoon:`午後`,evening:`夜`,night:`深夜`}},defaultWidth:`wide`,formattingValues:{narrow:{am:`午前`,pm:`午後`,midnight:`深夜`,noon:`正午`,morning:`朝`,afternoon:`午後`,evening:`夜`,night:`深夜`},abbreviated:{am:`午前`,pm:`午後`,midnight:`深夜`,noon:`正午`,morning:`朝`,afternoon:`午後`,evening:`夜`,night:`深夜`},wide:{am:`午前`,pm:`午後`,midnight:`深夜`,noon:`正午`,morning:`朝`,afternoon:`午後`,evening:`夜`,night:`深夜`}},defaultFormattingWidth:`wide`})},match:{ordinalNumber:_f({matchPattern:/^第?\d+(年|四半期|月|週|日|時|分|秒)?/i,parsePattern:/\d+/i,valueCallback:function(e){return parseInt(e,10)}}),era:mf({matchPatterns:{narrow:/^(B\.?C\.?|A\.?D\.?)/i,abbreviated:/^(紀元[前後]|西暦)/i,wide:/^(紀元[前後]|西暦)/i},defaultMatchWidth:`wide`,parsePatterns:{narrow:[/^B/i,/^A/i],any:[/^(紀元前)/i,/^(西暦|紀元後)/i]},defaultParseWidth:`any`}),quarter:mf({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^Q[1234]/i,wide:/^第[1234一二三四1234]四半期/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/(1|一|1)/i,/(2|二|2)/i,/(3|三|3)/i,/(4|四|4)/i]},defaultParseWidth:`any`,valueCallback:e=>e+1}),month:mf({matchPatterns:{narrow:/^([123456789]|1[012])/,abbreviated:/^([123456789]|1[012])月/i,wide:/^([123456789]|1[012])月/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/^1\D/,/^2/,/^3/,/^4/,/^5/,/^6/,/^7/,/^8/,/^9/,/^10/,/^11/,/^12/]},defaultParseWidth:`any`}),day:mf({matchPatterns:{narrow:/^[日月火水木金土]/,short:/^[日月火水木金土]/,abbreviated:/^[日月火水木金土]/,wide:/^[日月火水木金土]曜日/},defaultMatchWidth:`wide`,parsePatterns:{any:[/^日/,/^月/,/^火/,/^水/,/^木/,/^金/,/^土/]},defaultParseWidth:`any`}),dayPeriod:mf({matchPatterns:{any:/^(AM|PM|午前|午後|正午|深夜|真夜中|夜|朝)/i},defaultMatchWidth:`any`,parsePatterns:{any:{am:/^(A|午前)/i,pm:/^(P|午後)/i,midnight:/^深夜|真夜中/i,noon:/^正午/i,morning:/^朝/i,afternoon:/^午後/i,evening:/^夜/i,night:/^深夜/i}},defaultParseWidth:`any`})},options:{weekStartsOn:0,firstWeekContainsDate:1}},Ap={lessThanXSeconds:{one:`menos de um segundo`,other:`menos de {{count}} segundos`},xSeconds:{one:`1 segundo`,other:`{{count}} segundos`},halfAMinute:`meio minuto`,lessThanXMinutes:{one:`menos de um minuto`,other:`menos de {{count}} minutos`},xMinutes:{one:`1 minuto`,other:`{{count}} minutos`},aboutXHours:{one:`aproximadamente 1 hora`,other:`aproximadamente {{count}} horas`},xHours:{one:`1 hora`,other:`{{count}} horas`},xDays:{one:`1 dia`,other:`{{count}} dias`},aboutXWeeks:{one:`aproximadamente 1 semana`,other:`aproximadamente {{count}} semanas`},xWeeks:{one:`1 semana`,other:`{{count}} semanas`},aboutXMonths:{one:`aproximadamente 1 mês`,other:`aproximadamente {{count}} meses`},xMonths:{one:`1 mês`,other:`{{count}} meses`},aboutXYears:{one:`aproximadamente 1 ano`,other:`aproximadamente {{count}} anos`},xYears:{one:`1 ano`,other:`{{count}} anos`},overXYears:{one:`mais de 1 ano`,other:`mais de {{count}} anos`},almostXYears:{one:`quase 1 ano`,other:`quase {{count}} anos`}},jp=(e,t,n)=>{let r,i=Ap[e];return r=typeof i==`string`?i:t===1?i.one:i.other.replace(`{{count}}`,String(t)),n?.addSuffix?n.comparison&&n.comparison>0?`daqui a `+r:`há `+r:r},Mp={date:ff({formats:{full:`EEEE, d 'de' MMMM 'de' y`,long:`d 'de' MMMM 'de' y`,medium:`d 'de' MMM 'de' y`,short:`dd/MM/y`},defaultWidth:`full`}),time:ff({formats:{full:`HH:mm:ss zzzz`,long:`HH:mm:ss z`,medium:`HH:mm:ss`,short:`HH:mm`},defaultWidth:`full`}),dateTime:ff({formats:{full:`{{date}} 'às' {{time}}`,long:`{{date}} 'às' {{time}}`,medium:`{{date}}, {{time}}`,short:`{{date}}, {{time}}`},defaultWidth:`full`})},Np={lastWeek:e=>{let t=e.getDay();return`'`+(t===0||t===6?`último`:`última`)+`' eeee 'às' p`},yesterday:`'ontem às' p`,today:`'hoje às' p`,tomorrow:`'amanhã às' p`,nextWeek:`eeee 'às' p`,other:`P`},Pp={code:`pt`,formatDistance:jp,formatLong:Mp,formatRelative:(e,t,n,r)=>{let i=Np[e];return typeof i==`function`?i(t):i},localize:{ordinalNumber:(e,t)=>Number(e)+`º`,era:pf({values:{narrow:[`aC`,`dC`],abbreviated:[`a.C.`,`d.C.`],wide:[`antes de Cristo`,`depois de Cristo`]},defaultWidth:`wide`}),quarter:pf({values:{narrow:[`1`,`2`,`3`,`4`],abbreviated:[`T1`,`T2`,`T3`,`T4`],wide:[`1º trimestre`,`2º trimestre`,`3º trimestre`,`4º trimestre`]},defaultWidth:`wide`,argumentCallback:e=>e-1}),month:pf({values:{narrow:[`j`,`f`,`m`,`a`,`m`,`j`,`j`,`a`,`s`,`o`,`n`,`d`],abbreviated:[`jan`,`fev`,`mar`,`abr`,`mai`,`jun`,`jul`,`ago`,`set`,`out`,`nov`,`dez`],wide:[`janeiro`,`fevereiro`,`março`,`abril`,`maio`,`junho`,`julho`,`agosto`,`setembro`,`outubro`,`novembro`,`dezembro`]},defaultWidth:`wide`}),day:pf({values:{narrow:[`d`,`s`,`t`,`q`,`q`,`s`,`s`],short:[`dom`,`seg`,`ter`,`qua`,`qui`,`sex`,`sáb`],abbreviated:[`dom`,`seg`,`ter`,`qua`,`qui`,`sex`,`sáb`],wide:[`domingo`,`segunda-feira`,`terça-feira`,`quarta-feira`,`quinta-feira`,`sexta-feira`,`sábado`]},defaultWidth:`wide`}),dayPeriod:pf({values:{narrow:{am:`AM`,pm:`PM`,midnight:`meia-noite`,noon:`meio-dia`,morning:`manhã`,afternoon:`tarde`,evening:`noite`,night:`madrugada`},abbreviated:{am:`AM`,pm:`PM`,midnight:`meia-noite`,noon:`meio-dia`,morning:`manhã`,afternoon:`tarde`,evening:`noite`,night:`madrugada`},wide:{am:`AM`,pm:`PM`,midnight:`meia-noite`,noon:`meio-dia`,morning:`manhã`,afternoon:`tarde`,evening:`noite`,night:`madrugada`}},defaultWidth:`wide`,formattingValues:{narrow:{am:`AM`,pm:`PM`,midnight:`meia-noite`,noon:`meio-dia`,morning:`da manhã`,afternoon:`da tarde`,evening:`da noite`,night:`da madrugada`},abbreviated:{am:`AM`,pm:`PM`,midnight:`meia-noite`,noon:`meio-dia`,morning:`da manhã`,afternoon:`da tarde`,evening:`da noite`,night:`da madrugada`},wide:{am:`AM`,pm:`PM`,midnight:`meia-noite`,noon:`meio-dia`,morning:`da manhã`,afternoon:`da tarde`,evening:`da noite`,night:`da madrugada`}},defaultFormattingWidth:`wide`})},match:{ordinalNumber:_f({matchPattern:/^(\d+)(º|ª)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:mf({matchPatterns:{narrow:/^(ac|dc|a|d)/i,abbreviated:/^(a\.?\s?c\.?|a\.?\s?e\.?\s?c\.?|d\.?\s?c\.?|e\.?\s?c\.?)/i,wide:/^(antes de cristo|antes da era comum|depois de cristo|era comum)/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/^ac/i,/^dc/i],wide:[/^(antes de cristo|antes da era comum)/i,/^(depois de cristo|era comum)/i]},defaultParseWidth:`any`}),quarter:mf({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^T[1234]/i,wide:/^[1234](º|ª)? trimestre/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:`any`,valueCallback:e=>e+1}),month:mf({matchPatterns:{narrow:/^[jfmasond]/i,abbreviated:/^(jan|fev|mar|abr|mai|jun|jul|ago|set|out|nov|dez)/i,wide:/^(janeiro|fevereiro|março|abril|maio|junho|julho|agosto|setembro|outubro|novembro|dezembro)/i},defaultMatchWidth:`wide`,parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ab/i,/^mai/i,/^jun/i,/^jul/i,/^ag/i,/^s/i,/^o/i,/^n/i,/^d/i]},defaultParseWidth:`any`}),day:mf({matchPatterns:{narrow:/^[dstq]/i,short:/^(dom|seg|ter|qua|qui|sex|s[áa]b)/i,abbreviated:/^(dom|seg|ter|qua|qui|sex|s[áa]b)/i,wide:/^(domingo|segunda-?\s?feira|terça-?\s?feira|quarta-?\s?feira|quinta-?\s?feira|sexta-?\s?feira|s[áa]bado)/i},defaultMatchWidth:`wide`,parsePatterns:{narrow:[/^d/i,/^s/i,/^t/i,/^q/i,/^q/i,/^s/i,/^s/i],any:[/^d/i,/^seg/i,/^t/i,/^qua/i,/^qui/i,/^sex/i,/^s[áa]/i]},defaultParseWidth:`any`}),dayPeriod:mf({matchPatterns:{narrow:/^(a|p|meia-?\s?noite|meio-?\s?dia|(da) (manh[ãa]|tarde|noite|madrugada))/i,any:/^([ap]\.?\s?m\.?|meia-?\s?noite|meio-?\s?dia|(da) (manh[ãa]|tarde|noite|madrugada))/i},defaultMatchWidth:`any`,parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^meia/i,noon:/^meio/i,morning:/manh[ãa]/i,afternoon:/tarde/i,evening:/noite/i,night:/madrugada/i}},defaultParseWidth:`any`})},options:{weekStartsOn:1,firstWeekContainsDate:4}},Fp={lessThanXSeconds:{one:`不到 1 秒`,other:`不到 {{count}} 秒`},xSeconds:{one:`1 秒`,other:`{{count}} 秒`},halfAMinute:`半分钟`,lessThanXMinutes:{one:`不到 1 分钟`,other:`不到 {{count}} 分钟`},xMinutes:{one:`1 分钟`,other:`{{count}} 分钟`},xHours:{one:`1 小时`,other:`{{count}} 小时`},aboutXHours:{one:`大约 1 小时`,other:`大约 {{count}} 小时`},xDays:{one:`1 天`,other:`{{count}} 天`},aboutXWeeks:{one:`大约 1 个星期`,other:`大约 {{count}} 个星期`},xWeeks:{one:`1 个星期`,other:`{{count}} 个星期`},aboutXMonths:{one:`大约 1 个月`,other:`大约 {{count}} 个月`},xMonths:{one:`1 个月`,other:`{{count}} 个月`},aboutXYears:{one:`大约 1 年`,other:`大约 {{count}} 年`},xYears:{one:`1 年`,other:`{{count}} 年`},overXYears:{one:`超过 1 年`,other:`超过 {{count}} 年`},almostXYears:{one:`将近 1 年`,other:`将近 {{count}} 年`}},Ip=(e,t,n)=>{let r,i=Fp[e];return r=typeof i==`string`?i:t===1?i.one:i.other.replace(`{{count}}`,String(t)),n?.addSuffix?n.comparison&&n.comparison>0?r+`内`:r+`前`:r},Lp={date:ff({formats:{full:`y'年'M'月'd'日' EEEE`,long:`y'年'M'月'd'日'`,medium:`yyyy-MM-dd`,short:`yy-MM-dd`},defaultWidth:`full`}),time:ff({formats:{full:`zzzz a h:mm:ss`,long:`z a h:mm:ss`,medium:`a h:mm:ss`,short:`a h:mm`},defaultWidth:`full`}),dateTime:ff({formats:{full:`{{date}} {{time}}`,long:`{{date}} {{time}}`,medium:`{{date}} {{time}}`,short:`{{date}} {{time}}`},defaultWidth:`full`})};function Rp(e,t,n){let r=`eeee p`;return Nf(e,t,n)?r:e.getTime()>t.getTime()?`'下个'`+r:`'上个'`+r}var zp={lastWeek:Rp,yesterday:`'昨天' p`,today:`'今天' p`,tomorrow:`'明天' p`,nextWeek:Rp,other:`PP p`},Bp={code:`zh-CN`,formatDistance:Ip,formatLong:Lp,formatRelative:(e,t,n,r)=>{let i=zp[e];return typeof i==`function`?i(t,n,r):i},localize:{ordinalNumber:(e,t)=>{let n=Number(e);switch(t?.unit){case`date`:return n.toString()+`日`;case`hour`:return n.toString()+`时`;case`minute`:return n.toString()+`分`;case`second`:return n.toString()+`秒`;default:return`第 `+n.toString()}},era:pf({values:{narrow:[`前`,`公元`],abbreviated:[`前`,`公元`],wide:[`公元前`,`公元`]},defaultWidth:`wide`}),quarter:pf({values:{narrow:[`1`,`2`,`3`,`4`],abbreviated:[`第一季`,`第二季`,`第三季`,`第四季`],wide:[`第一季度`,`第二季度`,`第三季度`,`第四季度`]},defaultWidth:`wide`,argumentCallback:e=>e-1}),month:pf({values:{narrow:[`一`,`二`,`三`,`四`,`五`,`六`,`七`,`八`,`九`,`十`,`十一`,`十二`],abbreviated:[`1月`,`2月`,`3月`,`4月`,`5月`,`6月`,`7月`,`8月`,`9月`,`10月`,`11月`,`12月`],wide:[`一月`,`二月`,`三月`,`四月`,`五月`,`六月`,`七月`,`八月`,`九月`,`十月`,`十一月`,`十二月`]},defaultWidth:`wide`}),day:pf({values:{narrow:[`日`,`一`,`二`,`三`,`四`,`五`,`六`],short:[`日`,`一`,`二`,`三`,`四`,`五`,`六`],abbreviated:[`周日`,`周一`,`周二`,`周三`,`周四`,`周五`,`周六`],wide:[`星期日`,`星期一`,`星期二`,`星期三`,`星期四`,`星期五`,`星期六`]},defaultWidth:`wide`}),dayPeriod:pf({values:{narrow:{am:`上`,pm:`下`,midnight:`凌晨`,noon:`午`,morning:`早`,afternoon:`下午`,evening:`晚`,night:`夜`},abbreviated:{am:`上午`,pm:`下午`,midnight:`凌晨`,noon:`中午`,morning:`早晨`,afternoon:`中午`,evening:`晚上`,night:`夜间`},wide:{am:`上午`,pm:`下午`,midnight:`凌晨`,noon:`中午`,morning:`早晨`,afternoon:`中午`,evening:`晚上`,night:`夜间`}},defaultWidth:`wide`,formattingValues:{narrow:{am:`上`,pm:`下`,midnight:`凌晨`,noon:`午`,morning:`早`,afternoon:`下午`,evening:`晚`,night:`夜`},abbreviated:{am:`上午`,pm:`下午`,midnight:`凌晨`,noon:`中午`,morning:`早晨`,afternoon:`中午`,evening:`晚上`,night:`夜间`},wide:{am:`上午`,pm:`下午`,midnight:`凌晨`,noon:`中午`,morning:`早晨`,afternoon:`中午`,evening:`晚上`,night:`夜间`}},defaultFormattingWidth:`wide`})},match:{ordinalNumber:_f({matchPattern:/^(第\s*)?\d+(日|时|分|秒)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:mf({matchPatterns:{narrow:/^(前)/i,abbreviated:/^(前)/i,wide:/^(公元前|公元)/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/^(前)/i,/^(公元)/i]},defaultParseWidth:`any`}),quarter:mf({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^第[一二三四]刻/i,wide:/^第[一二三四]刻钟/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/(1|一)/i,/(2|二)/i,/(3|三)/i,/(4|四)/i]},defaultParseWidth:`any`,valueCallback:e=>e+1}),month:mf({matchPatterns:{narrow:/^(一|二|三|四|五|六|七|八|九|十[二一])/i,abbreviated:/^(一|二|三|四|五|六|七|八|九|十[二一]|\d|1[12])月/i,wide:/^(一|二|三|四|五|六|七|八|九|十[二一])月/i},defaultMatchWidth:`wide`,parsePatterns:{narrow:[/^一/i,/^二/i,/^三/i,/^四/i,/^五/i,/^六/i,/^七/i,/^八/i,/^九/i,/^十(?!(一|二))/i,/^十一/i,/^十二/i],any:[/^一|1/i,/^二|2/i,/^三|3/i,/^四|4/i,/^五|5/i,/^六|6/i,/^七|7/i,/^八|8/i,/^九|9/i,/^十(?!(一|二))|10/i,/^十一|11/i,/^十二|12/i]},defaultParseWidth:`any`}),day:mf({matchPatterns:{narrow:/^[一二三四五六日]/i,short:/^[一二三四五六日]/i,abbreviated:/^周[一二三四五六日]/i,wide:/^星期[一二三四五六日]/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/日/i,/一/i,/二/i,/三/i,/四/i,/五/i,/六/i]},defaultParseWidth:`any`}),dayPeriod:mf({matchPatterns:{any:/^(上午?|下午?|午夜|[中正]午|早上?|下午|晚上?|凌晨|)/i},defaultMatchWidth:`any`,parsePatterns:{any:{am:/^上午?/i,pm:/^下午?/i,midnight:/^午夜/i,noon:/^[中正]午/i,morning:/^早上/i,afternoon:/^下午/i,evening:/^晚上?/i,night:/^凌晨/i}},defaultParseWidth:`any`})},options:{weekStartsOn:1,firstWeekContainsDate:4}},Vp=[`en`,`es`,`fr`,`de`,`pt`,`it`,`zh`,`ja`],Hp={en:{id:`en`,nativeName:`English`,englishName:`English`},es:{id:`es`,nativeName:`Español`,englishName:`Spanish`},fr:{id:`fr`,nativeName:`Français`,englishName:`French`},de:{id:`de`,nativeName:`Deutsch`,englishName:`German`},pt:{id:`pt`,nativeName:`Português`,englishName:`Portuguese`},it:{id:`it`,nativeName:`Italiano`,englishName:`Italian`},zh:{id:`zh`,nativeName:`中文`,englishName:`Chinese`},ja:{id:`ja`,nativeName:`日本語`,englishName:`Japanese`}},Up=`specrails-desktop:ui-language`;function Wp(e){return typeof e==`string`&&Vp.includes(e)}function Gp(e){return e.split(`/`).pop().replace(/\.json$/,``)}var Kp=Object.assign({"../locales/en/activity.json":d,"../locales/en/addspec.json":f,"../locales/en/agent.json":p,"../locales/en/agents.json":m,"../locales/en/agentstudio.json":h,"../locales/en/aiedit.json":g,"../locales/en/analytics.json":_,"../locales/en/attachments.json":v,"../locales/en/browser.json":y,"../locales/en/chat.json":b,"../locales/en/code.json":x,"../locales/en/commands.json":S,"../locales/en/common.json":C,"../locales/en/dashboard.json":w,"../locales/en/explore.json":T,"../locales/en/integrations.json":E,"../locales/en/jira.json":D,"../locales/en/jobs.json":O,"../locales/en/loops.json":k,"../locales/en/mcp.json":A,"../locales/en/nav.json":j,"../locales/en/settings.json":M,"../locales/en/setup.json":N,"../locales/en/specs.json":P,"../locales/en/terminal.json":F,"../locales/en/tickets.json":I}),qp=Object.assign({"../locales/de/activity.json":()=>a(()=>import(`./activity-BZNfOdiS.js`),[]),"../locales/de/addspec.json":()=>a(()=>import(`./addspec-D-JLDsUV.js`),[]),"../locales/de/agent.json":()=>a(()=>import(`./agent-TK_rrK4d.js`),[]),"../locales/de/agents.json":()=>a(()=>import(`./agents-bvyRLczL.js`),[]),"../locales/de/agentstudio.json":()=>a(()=>import(`./agentstudio-jKMTdT70.js`),[]),"../locales/de/aiedit.json":()=>a(()=>import(`./aiedit-B03pD_Na.js`),[]),"../locales/de/analytics.json":()=>a(()=>import(`./analytics-Bj-SmKHa.js`),[]),"../locales/de/attachments.json":()=>a(()=>import(`./attachments-DCZOL1RU.js`),[]),"../locales/de/browser.json":()=>a(()=>import(`./browser-BqLqJVVT.js`),[]),"../locales/de/chat.json":()=>a(()=>import(`./chat-Bom6bqK3.js`),[]),"../locales/de/code.json":()=>a(()=>import(`./code-CeQ0FZpC.js`),[]),"../locales/de/commands.json":()=>a(()=>import(`./commands-JWMfGDmr.js`),[]),"../locales/de/common.json":()=>a(()=>import(`./common-DhWTkocg.js`),[]),"../locales/de/dashboard.json":()=>a(()=>import(`./dashboard-D_aP_InU.js`),[]),"../locales/de/explore.json":()=>a(()=>import(`./explore-Dahc1lOx.js`),[]),"../locales/de/integrations.json":()=>a(()=>import(`./integrations-2YcNyAl3.js`),[]),"../locales/de/jira.json":()=>a(()=>import(`./jira-D5efgwp_.js`),[]),"../locales/de/jobs.json":()=>a(()=>import(`./jobs-CE8qeIYj.js`),[]),"../locales/de/loops.json":()=>a(()=>import(`./loops-K5_HXfJa.js`),[]),"../locales/de/mcp.json":()=>a(()=>import(`./mcp-H-gnQUdN.js`),[]),"../locales/de/nav.json":()=>a(()=>import(`./nav-CXHUA4uf.js`),[]),"../locales/de/settings.json":()=>a(()=>import(`./settings-CB-EZ_W8.js`),[]),"../locales/de/setup.json":()=>a(()=>import(`./setup-BiduSX9d.js`),[]),"../locales/de/specs.json":()=>a(()=>import(`./specs-CBDvEYKv.js`),[]),"../locales/de/terminal.json":()=>a(()=>import(`./terminal-De2Brd23.js`),[]),"../locales/de/tickets.json":()=>a(()=>import(`./tickets-B7zT4IRf.js`),[]),"../locales/en/activity.json":()=>a(()=>import(`./activity-Dbl71S-E.js`).then(e=>e.t),__vite__mapDeps([0,1])),"../locales/en/addspec.json":()=>a(()=>import(`./addspec-DrXqP8ip.js`).then(e=>e.t),__vite__mapDeps([2,1])),"../locales/en/agent.json":()=>a(()=>import(`./agent-BEXYxDbs.js`).then(e=>e.t),__vite__mapDeps([3,1])),"../locales/en/agents.json":()=>a(()=>import(`./agents-CGDn_3kB.js`).then(e=>e.t),__vite__mapDeps([4,1])),"../locales/en/agentstudio.json":()=>a(()=>import(`./agentstudio-Dxe_94PK.js`).then(e=>e.t),__vite__mapDeps([5,1])),"../locales/en/aiedit.json":()=>a(()=>import(`./aiedit-DrfHQnlz.js`).then(e=>e.t),__vite__mapDeps([6,1])),"../locales/en/analytics.json":()=>a(()=>import(`./analytics-CxDYcBl9.js`).then(e=>e.t),__vite__mapDeps([7,1])),"../locales/en/attachments.json":()=>a(()=>import(`./attachments-DvxQbBTC.js`).then(e=>e.t),__vite__mapDeps([8,1])),"../locales/en/browser.json":()=>a(()=>import(`./browser-DM8G151q.js`).then(e=>e.t),__vite__mapDeps([9,1])),"../locales/en/chat.json":()=>a(()=>import(`./chat-0dg5hOo_.js`).then(e=>e.t),__vite__mapDeps([10,1])),"../locales/en/code.json":()=>a(()=>import(`./code-B62fClk-.js`).then(e=>e.t),__vite__mapDeps([11,1])),"../locales/en/commands.json":()=>a(()=>import(`./commands-DCJ-R9E4.js`).then(e=>e.t),__vite__mapDeps([12,1])),"../locales/en/common.json":()=>a(()=>import(`./common-DXrmj6WD.js`).then(e=>e.t),__vite__mapDeps([13,1])),"../locales/en/dashboard.json":()=>a(()=>import(`./dashboard-DBuLfWo9.js`).then(e=>e.t),__vite__mapDeps([14,1])),"../locales/en/explore.json":()=>a(()=>import(`./explore-_XyU5e7R.js`).then(e=>e.t),__vite__mapDeps([15,1])),"../locales/en/integrations.json":()=>a(()=>import(`./integrations-By80EBkf.js`).then(e=>e.t),__vite__mapDeps([16,1])),"../locales/en/jira.json":()=>a(()=>import(`./jira-DeIjwCK3.js`).then(e=>e.t),__vite__mapDeps([17,1])),"../locales/en/jobs.json":()=>a(()=>import(`./jobs-DrYmsKy5.js`).then(e=>e.t),__vite__mapDeps([18,1])),"../locales/en/loops.json":()=>a(()=>import(`./loops-CO6q75W8.js`).then(e=>e.t),__vite__mapDeps([19,1])),"../locales/en/mcp.json":()=>a(()=>import(`./mcp-HwBbQDk0.js`).then(e=>e.t),__vite__mapDeps([20,1])),"../locales/en/nav.json":()=>a(()=>import(`./nav-BTg8s-cD.js`).then(e=>e.t),__vite__mapDeps([21,1])),"../locales/en/settings.json":()=>a(()=>import(`./settings-cJNynGIZ.js`).then(e=>e.t),__vite__mapDeps([22,1])),"../locales/en/setup.json":()=>a(()=>import(`./setup-D2CmgAro.js`).then(e=>e.t),__vite__mapDeps([23,1])),"../locales/en/specs.json":()=>a(()=>import(`./specs-PGIOzMtc.js`).then(e=>e.t),__vite__mapDeps([24,1])),"../locales/en/terminal.json":()=>a(()=>import(`./terminal-CFt56A5f.js`).then(e=>e.t),__vite__mapDeps([25,1])),"../locales/en/tickets.json":()=>a(()=>import(`./tickets-BHv3ewvq.js`).then(e=>e.t),__vite__mapDeps([26,1])),"../locales/es/activity.json":()=>a(()=>import(`./activity--iN4Ad2R2.js`),[]),"../locales/es/addspec.json":()=>a(()=>import(`./addspec-BMtLZLW62.js`),[]),"../locales/es/agent.json":()=>a(()=>import(`./agent-bHjA9R_j2.js`),[]),"../locales/es/agents.json":()=>a(()=>import(`./agents-BLhWCmDS2.js`),[]),"../locales/es/agentstudio.json":()=>a(()=>import(`./agentstudio-COZriimI2.js`),[]),"../locales/es/aiedit.json":()=>a(()=>import(`./aiedit-hknZlly82.js`),[]),"../locales/es/analytics.json":()=>a(()=>import(`./analytics-CR1TJqUi2.js`),[]),"../locales/es/attachments.json":()=>a(()=>import(`./attachments-C9GTTJsx2.js`),[]),"../locales/es/browser.json":()=>a(()=>import(`./browser-rWKj-RR_2.js`),[]),"../locales/es/chat.json":()=>a(()=>import(`./chat-DdwZjT8K2.js`),[]),"../locales/es/code.json":()=>a(()=>import(`./code-UPVvmAKM2.js`),[]),"../locales/es/commands.json":()=>a(()=>import(`./commands-RHOchN4n2.js`),[]),"../locales/es/common.json":()=>a(()=>import(`./common-Bwafujnc2.js`),[]),"../locales/es/dashboard.json":()=>a(()=>import(`./dashboard-CHHcOWVL2.js`),[]),"../locales/es/explore.json":()=>a(()=>import(`./explore-B7fblXBb2.js`),[]),"../locales/es/integrations.json":()=>a(()=>import(`./integrations-BXCvXUlG2.js`),[]),"../locales/es/jira.json":()=>a(()=>import(`./jira-uNH1gETL2.js`),[]),"../locales/es/jobs.json":()=>a(()=>import(`./jobs-Wh7dn28q2.js`),[]),"../locales/es/loops.json":()=>a(()=>import(`./loops-DJNhp17p2.js`),[]),"../locales/es/mcp.json":()=>a(()=>import(`./mcp-XJNRfxVp2.js`),[]),"../locales/es/nav.json":()=>a(()=>import(`./nav-BElxljIF2.js`),[]),"../locales/es/settings.json":()=>a(()=>import(`./settings-BiDOB3hV2.js`),[]),"../locales/es/setup.json":()=>a(()=>import(`./setup-BwMovM9z2.js`),[]),"../locales/es/specs.json":()=>a(()=>import(`./specs-CIPr9reA2.js`),[]),"../locales/es/terminal.json":()=>a(()=>import(`./terminal-Z7KsDM_n.js`),[]),"../locales/es/tickets.json":()=>a(()=>import(`./tickets-DTHo9c3C.js`),[]),"../locales/fr/activity.json":()=>a(()=>import(`./activity-BuVo5sPB.js`),[]),"../locales/fr/addspec.json":()=>a(()=>import(`./addspec-DfhDbg5c.js`),[]),"../locales/fr/agent.json":()=>a(()=>import(`./agent-DfhYoUmp.js`),[]),"../locales/fr/agents.json":()=>a(()=>import(`./agents-78bTZGZh.js`),[]),"../locales/fr/agentstudio.json":()=>a(()=>import(`./agentstudio-C_Jq8Tl4.js`),[]),"../locales/fr/aiedit.json":()=>a(()=>import(`./aiedit-eMN4eQPF.js`),[]),"../locales/fr/analytics.json":()=>a(()=>import(`./analytics-C5dpiS0o.js`),[]),"../locales/fr/attachments.json":()=>a(()=>import(`./attachments-BgBNSqQd.js`),[]),"../locales/fr/browser.json":()=>a(()=>import(`./browser-FRv8P02E.js`),[]),"../locales/fr/chat.json":()=>a(()=>import(`./chat-Bh3NdgJs.js`),[]),"../locales/fr/code.json":()=>a(()=>import(`./code-BdMy3Ffq.js`),[]),"../locales/fr/commands.json":()=>a(()=>import(`./commands-u-4eEHCN.js`),[]),"../locales/fr/common.json":()=>a(()=>import(`./common-C-vU-j-I.js`),[]),"../locales/fr/dashboard.json":()=>a(()=>import(`./dashboard-DmBcdl1B.js`),[]),"../locales/fr/explore.json":()=>a(()=>import(`./explore-CNBzrEPS.js`),[]),"../locales/fr/integrations.json":()=>a(()=>import(`./integrations-TAcYNh0b.js`),[]),"../locales/fr/jira.json":()=>a(()=>import(`./jira-BHAKtc4B.js`),[]),"../locales/fr/jobs.json":()=>a(()=>import(`./jobs-26F9gGcE.js`),[]),"../locales/fr/loops.json":()=>a(()=>import(`./loops-CvOWsi5r.js`),[]),"../locales/fr/mcp.json":()=>a(()=>import(`./mcp-Dcl-XxkR.js`),[]),"../locales/fr/nav.json":()=>a(()=>import(`./nav-DdHF5VWJ.js`),[]),"../locales/fr/settings.json":()=>a(()=>import(`./settings-BSihkr0e.js`),[]),"../locales/fr/setup.json":()=>a(()=>import(`./setup-7J8TjG4O.js`),[]),"../locales/fr/specs.json":()=>a(()=>import(`./specs-DTplt2XM.js`),[]),"../locales/fr/terminal.json":()=>a(()=>import(`./terminal-xGbCZJHg.js`),[]),"../locales/fr/tickets.json":()=>a(()=>import(`./tickets-SuX_HkK4.js`),[]),"../locales/it/activity.json":()=>a(()=>import(`./activity-CIOLxGvh.js`),[]),"../locales/it/addspec.json":()=>a(()=>import(`./addspec-CRuvWn8d.js`),[]),"../locales/it/agent.json":()=>a(()=>import(`./agent-CewFImgL.js`),[]),"../locales/it/agents.json":()=>a(()=>import(`./agents-CWo-KyAB.js`),[]),"../locales/it/agentstudio.json":()=>a(()=>import(`./agentstudio-BMQxc_bz.js`),[]),"../locales/it/aiedit.json":()=>a(()=>import(`./aiedit-pc5JDUq1.js`),[]),"../locales/it/analytics.json":()=>a(()=>import(`./analytics-CCprAqk3.js`),[]),"../locales/it/attachments.json":()=>a(()=>import(`./attachments-BjyMmrwE.js`),[]),"../locales/it/browser.json":()=>a(()=>import(`./browser-Cc0iDqUi.js`),[]),"../locales/it/chat.json":()=>a(()=>import(`./chat-DsbwJhus.js`),[]),"../locales/it/code.json":()=>a(()=>import(`./code-BRcDlze52.js`),[]),"../locales/it/commands.json":()=>a(()=>import(`./commands-xHDDGfcP2.js`),[]),"../locales/it/common.json":()=>a(()=>import(`./common-DiPTT7V_2.js`),[]),"../locales/it/dashboard.json":()=>a(()=>import(`./dashboard-DBD4wPGY2.js`),[]),"../locales/it/explore.json":()=>a(()=>import(`./explore-D_mWBYCS2.js`),[]),"../locales/it/integrations.json":()=>a(()=>import(`./integrations-Crk2rFhL2.js`),[]),"../locales/it/jira.json":()=>a(()=>import(`./jira-Be369RIR2.js`),[]),"../locales/it/jobs.json":()=>a(()=>import(`./jobs-BgQzB0Sx2.js`),[]),"../locales/it/loops.json":()=>a(()=>import(`./loops-BvqQ-bHR2.js`),[]),"../locales/it/mcp.json":()=>a(()=>import(`./mcp-CjVKXAhD2.js`),[]),"../locales/it/nav.json":()=>a(()=>import(`./nav-CW9pxWfC2.js`),[]),"../locales/it/settings.json":()=>a(()=>import(`./settings-1w1O5Og82.js`),[]),"../locales/it/setup.json":()=>a(()=>import(`./setup-DU0ULX8q2.js`),[]),"../locales/it/specs.json":()=>a(()=>import(`./specs-C9Sd7BhH2.js`),[]),"../locales/it/terminal.json":()=>a(()=>import(`./terminal-BRm03iFA2.js`),[]),"../locales/it/tickets.json":()=>a(()=>import(`./tickets-C3b8cHhd2.js`),[]),"../locales/ja/activity.json":()=>a(()=>import(`./activity-D2r2h3SE2.js`),[]),"../locales/ja/addspec.json":()=>a(()=>import(`./addspec-bsNDdqRm2.js`),[]),"../locales/ja/agent.json":()=>a(()=>import(`./agent-BYc3-6Ln2.js`),[]),"../locales/ja/agents.json":()=>a(()=>import(`./agents-BpoUaoW92.js`),[]),"../locales/ja/agentstudio.json":()=>a(()=>import(`./agentstudio-sI27TpBu2.js`),[]),"../locales/ja/aiedit.json":()=>a(()=>import(`./aiedit-igmw-ZoZ2.js`),[]),"../locales/ja/analytics.json":()=>a(()=>import(`./analytics-DfNdXR0y2.js`),[]),"../locales/ja/attachments.json":()=>a(()=>import(`./attachments-rNn1ekRy2.js`),[]),"../locales/ja/browser.json":()=>a(()=>import(`./browser-Cvg-QHvd2.js`),[]),"../locales/ja/chat.json":()=>a(()=>import(`./chat-vylxqR0P2.js`),[]),"../locales/ja/code.json":()=>a(()=>import(`./code-DgeHz9CB.js`),[]),"../locales/ja/commands.json":()=>a(()=>import(`./commands-CSDs9q_2.js`),[]),"../locales/ja/common.json":()=>a(()=>import(`./common-DmqBPwZG.js`),[]),"../locales/ja/dashboard.json":()=>a(()=>import(`./dashboard-B5ang-ZS.js`),[]),"../locales/ja/explore.json":()=>a(()=>import(`./explore-UvW1jEMa.js`),[]),"../locales/ja/integrations.json":()=>a(()=>import(`./integrations-D9YrJ_Ep.js`),[]),"../locales/ja/jira.json":()=>a(()=>import(`./jira-DS7ownDy.js`),[]),"../locales/ja/jobs.json":()=>a(()=>import(`./jobs-DzeuASRf.js`),[]),"../locales/ja/loops.json":()=>a(()=>import(`./loops-D6D3XHjj.js`),[]),"../locales/ja/mcp.json":()=>a(()=>import(`./mcp-sRmWE8WJ.js`),[]),"../locales/ja/nav.json":()=>a(()=>import(`./nav-C8kOuGh8.js`),[]),"../locales/ja/settings.json":()=>a(()=>import(`./settings-DNL68KTE.js`),[]),"../locales/ja/setup.json":()=>a(()=>import(`./setup-D84y3wx-.js`),[]),"../locales/ja/specs.json":()=>a(()=>import(`./specs-PozUNhqb.js`),[]),"../locales/ja/terminal.json":()=>a(()=>import(`./terminal-cqfd3EDV.js`),[]),"../locales/ja/tickets.json":()=>a(()=>import(`./tickets-CFXnJsYF.js`),[]),"../locales/pt/activity.json":()=>a(()=>import(`./activity-6hM_ZSg9.js`),[]),"../locales/pt/addspec.json":()=>a(()=>import(`./addspec-CP0HRuxY.js`),[]),"../locales/pt/agent.json":()=>a(()=>import(`./agent-BbJorPdT.js`),[]),"../locales/pt/agents.json":()=>a(()=>import(`./agents-BUdEi3-N.js`),[]),"../locales/pt/agentstudio.json":()=>a(()=>import(`./agentstudio-Dtq3dGYk.js`),[]),"../locales/pt/aiedit.json":()=>a(()=>import(`./aiedit-BtRqRxML.js`),[]),"../locales/pt/analytics.json":()=>a(()=>import(`./analytics-rmHuJv0V.js`),[]),"../locales/pt/attachments.json":()=>a(()=>import(`./attachments-DL-bPy9E.js`),[]),"../locales/pt/browser.json":()=>a(()=>import(`./browser-BPkhILSJ.js`),[]),"../locales/pt/chat.json":()=>a(()=>import(`./chat-Dnwg-NpQ.js`),[]),"../locales/pt/code.json":()=>a(()=>import(`./code-CwnBPPyA.js`),[]),"../locales/pt/commands.json":()=>a(()=>import(`./commands-DkU0qliq.js`),[]),"../locales/pt/common.json":()=>a(()=>import(`./common-C5HKSbbz.js`),[]),"../locales/pt/dashboard.json":()=>a(()=>import(`./dashboard-DSnztwWH.js`),[]),"../locales/pt/explore.json":()=>a(()=>import(`./explore-C0k8HrkN.js`),[]),"../locales/pt/integrations.json":()=>a(()=>import(`./integrations-Dn4JiGtW.js`),[]),"../locales/pt/jira.json":()=>a(()=>import(`./jira-bDs7Im2C.js`),[]),"../locales/pt/jobs.json":()=>a(()=>import(`./jobs-BqWui9_f.js`),[]),"../locales/pt/loops.json":()=>a(()=>import(`./loops-LIgO_-eM.js`),[]),"../locales/pt/mcp.json":()=>a(()=>import(`./mcp-N1nzp8oL.js`),[]),"../locales/pt/nav.json":()=>a(()=>import(`./nav-COu2E_-L.js`),[]),"../locales/pt/settings.json":()=>a(()=>import(`./settings-Jc46vUhd.js`),[]),"../locales/pt/setup.json":()=>a(()=>import(`./setup-BuQNKztt2.js`),[]),"../locales/pt/specs.json":()=>a(()=>import(`./specs-D2clrt2c2.js`),[]),"../locales/pt/terminal.json":()=>a(()=>import(`./terminal-DxQWCqSD2.js`),[]),"../locales/pt/tickets.json":()=>a(()=>import(`./tickets-CWYFvx1W2.js`),[]),"../locales/zh/activity.json":()=>a(()=>import(`./activity-DtxrAUMo2.js`),[]),"../locales/zh/addspec.json":()=>a(()=>import(`./addspec-mgPOt5q02.js`),[]),"../locales/zh/agent.json":()=>a(()=>import(`./agent-B8BXmlUQ2.js`),[]),"../locales/zh/agents.json":()=>a(()=>import(`./agents-DDtCJ5M02.js`),[]),"../locales/zh/agentstudio.json":()=>a(()=>import(`./agentstudio-CWgXG5W52.js`),[]),"../locales/zh/aiedit.json":()=>a(()=>import(`./aiedit-6CHdb_iv2.js`),[]),"../locales/zh/analytics.json":()=>a(()=>import(`./analytics-BWMUZ2Pq2.js`),[]),"../locales/zh/attachments.json":()=>a(()=>import(`./attachments-DPCmkFZu2.js`),[]),"../locales/zh/browser.json":()=>a(()=>import(`./browser-BijVYG0Y2.js`),[]),"../locales/zh/chat.json":()=>a(()=>import(`./chat-BgL3zv6x2.js`),[]),"../locales/zh/code.json":()=>a(()=>import(`./code-DzC1rMk12.js`),[]),"../locales/zh/commands.json":()=>a(()=>import(`./commands-C4Y3C-PF2.js`),[]),"../locales/zh/common.json":()=>a(()=>import(`./common-BM3LFLCE2.js`),[]),"../locales/zh/dashboard.json":()=>a(()=>import(`./dashboard-RIcUKY1Y2.js`),[]),"../locales/zh/explore.json":()=>a(()=>import(`./explore-BHtEpoNN2.js`),[]),"../locales/zh/integrations.json":()=>a(()=>import(`./integrations-C1ThkTC52.js`),[]),"../locales/zh/jira.json":()=>a(()=>import(`./jira-CPpgA-5z2.js`),[]),"../locales/zh/jobs.json":()=>a(()=>import(`./jobs-1GV2-4zd2.js`),[]),"../locales/zh/loops.json":()=>a(()=>import(`./loops-vhJdbcz92.js`),[]),"../locales/zh/mcp.json":()=>a(()=>import(`./mcp-DtbxuH3V2.js`),[]),"../locales/zh/nav.json":()=>a(()=>import(`./nav-BXO7PJJG2.js`),[]),"../locales/zh/settings.json":()=>a(()=>import(`./settings-BoubJhDP2.js`),[]),"../locales/zh/setup.json":()=>a(()=>import(`./setup-BXpw07r-.js`),[]),"../locales/zh/specs.json":()=>a(()=>import(`./specs-CWtKcVDC.js`),[]),"../locales/zh/terminal.json":()=>a(()=>import(`./terminal-WSAvHXoU.js`),[]),"../locales/zh/tickets.json":()=>a(()=>import(`./tickets-BoXom7l8.js`),[])}),Jp={};for(let[e,t]of Object.entries(Kp))Jp[Gp(e)]=t.default;var Yp=Object.keys(Jp),Xp=new Set([`en`]);function Zp(){if(typeof navigator<`u`){let e=navigator.languages&&navigator.languages.length>0?navigator.languages:[navigator.language];for(let t of e){if(!t)continue;let e=t.toLowerCase().split(`-`)[0];if(Wp(e))return e}}return`en`}function Qp(){if(typeof localStorage<`u`)try{let e=localStorage.getItem(Up);if(Wp(e))return e}catch{}return Zp()}ri.use(Ki).init({lng:`en`,fallbackLng:`en`,defaultNS:`common`,ns:Yp,resources:{en:Jp},interpolation:{escapeValue:!1},returnNull:!1});async function $p(e){if(Xp.has(e))return;let t=Object.entries(qp).filter(([t])=>t.includes(`/locales/${e}/`)),n=await Promise.all(t.map(async([e,t])=>[Gp(e),(await t()).default]));for(let[t,r]of n)ri.addResourceBundle(e,t,r,!0,!0);Xp.add(e)}async function em(e){await $p(e),await ri.changeLanguage(e),typeof document<`u`&&(document.documentElement.lang=e)}async function tm(){let e=Qp();if(e!==`en`)try{await em(e)}catch{}}function nm(){return Wp(ri.language)?ri.language:`en`}var rm={en:Xf,es:np,fr:hp,de:Uf,pt:Pp,it:wp,zh:Bp,ja:kp};function im(e){let t=e??ri.language;return rm[Wp(t)?t:`en`]}var am=ri,om=new Map;function sm(e,t){return`${e}:${t}`}function cm(e){if(!e)return;let t=`${e}:`;for(let e of om.keys())e.startsWith(t)&&om.delete(e)}function eee({namespace:e,projectId:t,initialValue:n,fetcher:r,pollInterval:i=0}){let a=t?sm(t,e):null,[o,s]=(0,H.useState)(()=>a&&om.has(a)?om.get(a):n),[c,l]=(0,H.useState)(()=>a?!om.has(a):!0),[u,d]=(0,H.useState)(c),f=(0,H.useRef)(r);f.current=r;let p=(0,H.useRef)(a);return p.current=a,(0,H.useEffect)(()=>{if(!a)return;let e=om.get(a);e===void 0?(s(n),l(!0),d(!0)):(s(e),l(!1),d(!1));let t=!1;async function r(){try{let e=await f.current();if(t)return;om.set(a,e),s(e)}catch{}finally{t||(d(!1),l(!1))}}r();let o;return i>0&&(o=setInterval(r,i)),()=>{t=!0,o&&clearInterval(o)}},[a,i]),{data:o,isLoading:u,isFirstLoad:c,refresh:(0,H.useCallback)(()=>{if(!a)return;let e=a;f.current().then(t=>{om.set(e,t),p.current===e&&s(t)}).catch(()=>{})},[a])}}function lm(e){return e.providers&&e.providers.length>0?e.providers:[e.provider]}var um=(0,H.createContext)(null),dm=`specrails-desktop:activeProjectId`;function fm(e){try{e?localStorage.setItem(dm,e):localStorage.removeItem(dm)}catch{}}function pm(){try{return localStorage.getItem(dm)}catch{return null}}function mm({children:e}){let[t,n]=(0,H.useState)([]),[r,i]=(0,H.useState)(null),[a,s]=(0,H.useState)(!0),[c,l]=(0,H.useState)(!1),[u,d]=(0,H.useState)(new Set),f=(0,H.useRef)(null),p=(0,H.useRef)(new Set),m=(0,H.useCallback)(e=>{fm(e),rf(e),i(t=>(t!==null&&t!==e&&(f.current&&clearTimeout(f.current),l(!0),f.current=setTimeout(()=>l(!1),400)),e))},[]),{registerHandler:h,unregisterHandler:g}=df();(0,H.useEffect)(()=>{async function e(){try{let e=await fetch(`${o}/api/projects`);if(!e.ok)return;let t=await e.json();n(t.projects),t.setupProjectIds&&t.setupProjectIds.length>0&&d(new Set(t.setupProjectIds))}catch{}finally{s(!1)}}e()},[]);let _=(0,H.useCallback)(e=>{let t=e;if(typeof t.type==`string`){if(t.type===`desktop.projects`){if(!Array.isArray(t.projects))return;let e=t.projects;n(e),i(t=>{let n;if(t&&e.find(e=>e.id===t))n=t;else{let t=pm();n=t&&e.find(e=>e.id===t)?t:e.length>0?e[0].id:null}return fm(n),rf(n),n}),s(!1)}else if(t.type===`desktop.project_added`){let e=t.project;n(t=>t.find(t=>t.id===e.id)?t:[...t,e]),p.current.has(e.id)?p.current.delete(e.id):(q.success(am.t(`nav:projects.added`,{name:e.name})),m(e.id))}else if(t.type===`desktop.project_removed`){let e=t.projectId;q.success(am.t(`nav:projects.removed`)),cm(e),n(t=>t.filter(t=>t.id!==e)),i(t=>t===e?(fm(null),rf(null),null):t)}}},[]);(0,H.useLayoutEffect)(()=>(h(`desktop`,_),()=>g(`desktop`)),[_,h,g]);let v=(0,H.useCallback)(async(e,t,r=[`claude`])=>{try{let i={path:e,providers:r.length>0?r:[`claude`]};t&&(i.name=t);let a=await fetch(`/api/projects`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(i)});if(!a.ok){let e=await a.json();throw Error(e.error??`HTTP ${a.status}`)}let o=await a.json();return p.current.add(o.project.id),n(e=>e.find(e=>e.id===o.project.id)?e:[...e,o.project]),m(o.project.id),o}catch(e){throw console.error(`[useDesktop] addProject error:`,e),e}},[m]),y=(0,H.useCallback)(async e=>{try{let t=await fetch(`${o}/api/projects/${e}`,{method:`DELETE`});if(!t.ok){let e=await t.json();throw Error(e.error??`HTTP ${t.status}`)}cm(e),n(t=>t.filter(t=>t.id!==e)),d(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n}),i(t=>t===e?(fm(null),rf(null),null):t)}catch(e){throw console.error(`[useDesktop] removeProject error:`,e),e}},[]),b=(0,H.useCallback)(e=>{d(t=>new Set([...t,e]))},[]),x=(0,H.useCallback)(e=>{d(t=>{let n=new Set(t);return n.delete(e),n})},[]),S=(0,H.useMemo)(()=>({projects:t,activeProjectId:r,setActiveProjectId:m,addProject:v,removeProject:y,isLoading:a,isSwitchingProject:c,setupProjectIds:u,startSetupWizard:b,completeSetupWizard:x}),[t,r,m,v,y,a,c,u,b,x]);return(0,Y.jsx)(um.Provider,{value:S,children:e})}var hm={projects:[],activeProjectId:null,setActiveProjectId:()=>{},addProject:async()=>null,removeProject:async()=>{},isLoading:!1,isSwitchingProject:!1,setupProjectIds:new Set,startSetupWizard:()=>{},completeSetupWizard:()=>{}};function gm(){return(0,H.useContext)(um)??hm}var _m=new Map,vm=2e3;function ym(e){_m.set(e,(_m.get(e)??0)+1)}function bm(e){(_m.get(e)??0)<=0||setTimeout(()=>{let t=(_m.get(e)??0)-1;t<=0?_m.delete(e):_m.set(e,t)},vm)}function xm(e){return e?(_m.get(e)??0)>0:!1}var Sm=3e3,Cm=`
17
17
 
18
18
  ---
19
19
 
@@ -59,11 +59,11 @@ Please change the parent <Route path="${e}"> to <Route path="${e===`/`?`*`:`${e}
59
59
  `},zv=function(){var e=parseInt(document.body.getAttribute(`data-scroll-locked`)||`0`,10);return isFinite(e)?e:0},Bv=function(){H.useEffect(function(){return document.body.setAttribute(Lv,(zv()+1).toString()),function(){var e=zv()-1;e<=0?document.body.removeAttribute(Lv):document.body.setAttribute(Lv,e.toString())}},[])},Vv=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?`margin`:r;Bv();var a=H.useMemo(function(){return Fv(i)},[i]);return H.createElement(Iv,{styles:Rv(a,!t,i,n?``:`!important`)})},Hv=!1;if(typeof window<`u`)try{var Uv=Object.defineProperty({},`passive`,{get:function(){return Hv=!0,!0}});window.addEventListener(`test`,Uv,Uv),window.removeEventListener(`test`,Uv,Uv)}catch{Hv=!1}var Wv=Hv?{passive:!1}:!1,Gv=function(e){return e.tagName===`TEXTAREA`},Kv=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!==`hidden`&&!(n.overflowY===n.overflowX&&!Gv(e)&&n[t]===`visible`)},qv=function(e){return Kv(e,`overflowY`)},Jv=function(e){return Kv(e,`overflowX`)},Yv=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<`u`&&r instanceof ShadowRoot&&(r=r.host),Qv(e,r)){var i=$v(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Xv=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},Zv=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},Qv=function(e,t){return e===`v`?qv(t):Jv(t)},$v=function(e,t){return e===`v`?Xv(t):Zv(t)},ey=function(e,t){return e===`h`&&t===`rtl`?-1:1},ty=function(e,t,n,r,i){var a=ey(e,window.getComputedStyle(t).direction),o=a*r,s=n.target,c=t.contains(s),l=!1,u=o>0,d=0,f=0;do{if(!s)break;var p=$v(e,s),m=p[0],h=p[1]-p[2]-a*m;(m||h)&&Qv(e,s)&&(d+=h,f+=m);var g=s.parentNode;s=g&&g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.host:g}while(!c&&s!==document.body||c&&(t.contains(s)||t===s));return(u&&(i&&Math.abs(d)<1||!i&&o>d)||!u&&(i&&Math.abs(f)<1||!i&&-o>f))&&(l=!0),l},ny=function(e){return`changedTouches`in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},ry=function(e){return[e.deltaX,e.deltaY]},iy=function(e){return e&&`current`in e?e.current:e},ay=function(e,t){return e[0]===t[0]&&e[1]===t[1]},oy=function(e){return`
60
60
  .block-interactivity-${e} {pointer-events: none;}
61
61
  .allow-interactivity-${e} {pointer-events: all;}
62
- `},sy=0,cy=[];function ly(e){var t=H.useRef([]),n=H.useRef([0,0]),r=H.useRef(),i=H.useState(sy++)[0],a=H.useState(jv)[0],o=H.useRef(e);H.useEffect(function(){o.current=e},[e]),H.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=ov([e.lockRef.current],(e.shards||[]).map(iy),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=H.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=ny(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=Yv(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=Yv(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return ty(h,t,e,h===`h`?s:c,!0)},[]),c=H.useCallback(function(e){var n=e;if(!(!cy.length||cy[cy.length-1]!==a)){var r=`deltaY`in n?ry(n):ny(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&ay(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map(iy).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=H.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:uy(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=H.useCallback(function(e){n.current=ny(e),r.current=void 0},[]),d=H.useCallback(function(t){l(t.type,ry(t),t.target,s(t,e.lockRef.current))},[]),f=H.useCallback(function(t){l(t.type,ny(t),t.target,s(t,e.lockRef.current))},[]);H.useEffect(function(){return cy.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,Wv),document.addEventListener(`touchmove`,c,Wv),document.addEventListener(`touchstart`,u,Wv),function(){cy=cy.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,Wv),document.removeEventListener(`touchmove`,c,Wv),document.removeEventListener(`touchstart`,u,Wv)}},[]);var p=e.removeScrollBar,m=e.inert;return H.createElement(H.Fragment,null,m?H.createElement(a,{styles:oy(i)}):null,p?H.createElement(Vv,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function uy(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var dy=bv(xv,ly),fy=H.forwardRef(function(e,t){return H.createElement(Cv,iv({},e,{ref:t,sideCar:dy}))});fy.classNames=Cv.classNames;var py=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},my=new WeakMap,hy=new WeakMap,gy={},_y=0,vy=function(e){return e&&(e.host||vy(e.parentNode))},yy=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=vy(t);return n&&e.contains(n)?n:(console.error(`aria-hidden`,t,`in not contained inside`,e,`. Doing nothing`),null)}).filter(function(e){return!!e})},by=function(e,t,n,r){var i=yy(t,Array.isArray(e)?e:[e]);gy[n]||(gy[n]=new WeakMap);var a=gy[n],o=[],s=new Set,c=new Set(i),l=function(e){!e||s.has(e)||(s.add(e),l(e.parentNode))};i.forEach(l);var u=function(e){!e||c.has(e)||Array.prototype.forEach.call(e.children,function(e){if(s.has(e))u(e);else try{var t=e.getAttribute(r),i=t!==null&&t!==`false`,c=(my.get(e)||0)+1,l=(a.get(e)||0)+1;my.set(e,c),a.set(e,l),o.push(e),c===1&&i&&hy.set(e,!0),l===1&&e.setAttribute(n,`true`),i||e.setAttribute(r,`true`)}catch(t){console.error(`aria-hidden: cannot operate on `,e,t)}})};return u(t),s.clear(),_y++,function(){o.forEach(function(e){var t=my.get(e)-1,i=a.get(e)-1;my.set(e,t),a.set(e,i),t||(hy.has(e)||e.removeAttribute(r),hy.delete(e)),i||e.removeAttribute(n)}),_y--,_y||(my=new WeakMap,my=new WeakMap,hy=new WeakMap,gy={})}},xy=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||py(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),by(r,i,n,`aria-hidden`)):function(){return null}};function dee(e){let t=fee(e),n=H.forwardRef((e,n)=>{let{children:r,...i}=e,a=H.Children.toArray(r),o=a.find(mee);if(o){let e=o.props.children,r=a.map(t=>t===o?H.Children.count(e)>1?H.Children.only(null):H.isValidElement(e)?e.props.children:null:t);return(0,Y.jsx)(t,{...i,ref:n,children:H.isValidElement(e)?H.cloneElement(e,void 0,r):null})}return(0,Y.jsx)(t,{...i,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}function fee(e){let t=H.forwardRef((e,t)=>{let{children:n,...r}=e;if(H.isValidElement(n)){let e=gee(n),i=hee(r,n.props);return n.type!==H.Fragment&&(i.ref=t?Om(t,e):e),H.cloneElement(n,i)}return H.Children.count(n)>1?H.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var pee=Symbol(`radix.slottable`);function mee(e){return H.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===pee}function hee(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function gee(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Sy=`Dialog`,[Cy,_ee]=$g(Sy),[vee,wy]=Cy(Sy),Ty=e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=H.useRef(null),c=H.useRef(null),[l,u]=o_({prop:r,defaultProp:i??!1,onChange:a,caller:Sy});return(0,Y.jsx)(vee,{scope:t,triggerRef:s,contentRef:c,contentId:i_(),titleId:i_(),descriptionId:i_(),open:l,onOpenChange:u,onOpenToggle:H.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})};Ty.displayName=Sy;var Ey=`DialogTrigger`,yee=H.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=wy(Ey,n),a=km(t,i.triggerRef);return(0,Y.jsx)(h_.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.contentId,"data-state":Wy(i.open),...r,ref:a,onClick:Zg(e.onClick,i.onOpenToggle)})});yee.displayName=Ey;var Dy=`DialogPortal`,[bee,Oy]=Cy(Dy,{forceMount:void 0}),ky=e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=wy(Dy,t);return(0,Y.jsx)(bee,{scope:t,forceMount:n,children:H.Children.map(r,e=>(0,Y.jsx)(Z_,{present:n||a.open,children:(0,Y.jsx)(Y_,{asChild:!0,container:i,children:e})}))})};ky.displayName=Dy;var Ay=`DialogOverlay`,jy=H.forwardRef((e,t)=>{let n=Oy(Ay,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=wy(Ay,e.__scopeDialog);return a.modal?(0,Y.jsx)(Z_,{present:r||a.open,children:(0,Y.jsx)(My,{...i,ref:t})}):null});jy.displayName=Ay;var xee=dee(`DialogOverlay.RemoveScroll`),My=H.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=wy(Ay,n);return(0,Y.jsx)(fy,{as:xee,allowPinchZoom:!0,shards:[i.contentRef],children:(0,Y.jsx)(h_.div,{"data-state":Wy(i.open),...r,ref:t,style:{pointerEvents:`auto`,...r.style}})})}),Ny=`DialogContent`,Py=H.forwardRef((e,t)=>{let n=Oy(Ny,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=wy(Ny,e.__scopeDialog);return(0,Y.jsx)(Z_,{present:r||a.open,children:a.modal?(0,Y.jsx)(Fy,{...i,ref:t}):(0,Y.jsx)(Iy,{...i,ref:t})})});Py.displayName=Ny;var Fy=H.forwardRef((e,t)=>{let n=wy(Ny,e.__scopeDialog),r=H.useRef(null),i=km(t,n.contentRef,r);return H.useEffect(()=>{let e=r.current;if(e)return xy(e)},[]),(0,Y.jsx)(Ly,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Zg(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:Zg(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:Zg(e.onFocusOutside,e=>e.preventDefault())})}),Iy=H.forwardRef((e,t)=>{let n=wy(Ny,e.__scopeDialog),r=H.useRef(!1),i=H.useRef(!1);return(0,Y.jsx)(Ly,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),Ly=H.forwardRef((e,t)=>{let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=wy(Ny,n),c=H.useRef(null),l=km(t,c);return nv(),(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(I_,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,Y.jsx)(T_,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionId,"aria-labelledby":s.titleId,"data-state":Wy(s.open),...o,ref:l,onDismiss:()=>s.onOpenChange(!1)})}),(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(qy,{titleId:s.titleId}),(0,Y.jsx)(Yy,{contentRef:c,descriptionId:s.descriptionId})]})]})}),Ry=`DialogTitle`,zy=H.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=wy(Ry,n);return(0,Y.jsx)(h_.h2,{id:i.titleId,...r,ref:t})});zy.displayName=Ry;var By=`DialogDescription`,Vy=H.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=wy(By,n);return(0,Y.jsx)(h_.p,{id:i.descriptionId,...r,ref:t})});Vy.displayName=By;var Hy=`DialogClose`,Uy=H.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=wy(Hy,n);return(0,Y.jsx)(h_.button,{type:`button`,...r,ref:t,onClick:Zg(e.onClick,()=>i.onOpenChange(!1))})});Uy.displayName=Hy;function Wy(e){return e?`open`:`closed`}var Gy=`DialogTitleWarning`,[See,Ky]=Qg(Gy,{contentName:Ny,titleName:Ry,docsSlug:`dialog`}),qy=({titleId:e})=>{let t=Ky(Gy),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
62
+ `},sy=0,cy=[];function ly(e){var t=H.useRef([]),n=H.useRef([0,0]),r=H.useRef(),i=H.useState(sy++)[0],a=H.useState(jv)[0],o=H.useRef(e);H.useEffect(function(){o.current=e},[e]),H.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=ov([e.lockRef.current],(e.shards||[]).map(iy),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=H.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=ny(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=Yv(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=Yv(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return ty(h,t,e,h===`h`?s:c,!0)},[]),c=H.useCallback(function(e){var n=e;if(!(!cy.length||cy[cy.length-1]!==a)){var r=`deltaY`in n?ry(n):ny(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&ay(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map(iy).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=H.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:uy(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=H.useCallback(function(e){n.current=ny(e),r.current=void 0},[]),d=H.useCallback(function(t){l(t.type,ry(t),t.target,s(t,e.lockRef.current))},[]),f=H.useCallback(function(t){l(t.type,ny(t),t.target,s(t,e.lockRef.current))},[]);H.useEffect(function(){return cy.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,Wv),document.addEventListener(`touchmove`,c,Wv),document.addEventListener(`touchstart`,u,Wv),function(){cy=cy.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,Wv),document.removeEventListener(`touchmove`,c,Wv),document.removeEventListener(`touchstart`,u,Wv)}},[]);var p=e.removeScrollBar,m=e.inert;return H.createElement(H.Fragment,null,m?H.createElement(a,{styles:oy(i)}):null,p?H.createElement(Vv,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function uy(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var dy=bv(xv,ly),fy=H.forwardRef(function(e,t){return H.createElement(Cv,iv({},e,{ref:t,sideCar:dy}))});fy.classNames=Cv.classNames;var py=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},my=new WeakMap,hy=new WeakMap,gy={},_y=0,vy=function(e){return e&&(e.host||vy(e.parentNode))},yy=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=vy(t);return n&&e.contains(n)?n:(console.error(`aria-hidden`,t,`in not contained inside`,e,`. Doing nothing`),null)}).filter(function(e){return!!e})},dee=function(e,t,n,r){var i=yy(t,Array.isArray(e)?e:[e]);gy[n]||(gy[n]=new WeakMap);var a=gy[n],o=[],s=new Set,c=new Set(i),l=function(e){!e||s.has(e)||(s.add(e),l(e.parentNode))};i.forEach(l);var u=function(e){!e||c.has(e)||Array.prototype.forEach.call(e.children,function(e){if(s.has(e))u(e);else try{var t=e.getAttribute(r),i=t!==null&&t!==`false`,c=(my.get(e)||0)+1,l=(a.get(e)||0)+1;my.set(e,c),a.set(e,l),o.push(e),c===1&&i&&hy.set(e,!0),l===1&&e.setAttribute(n,`true`),i||e.setAttribute(r,`true`)}catch(t){console.error(`aria-hidden: cannot operate on `,e,t)}})};return u(t),s.clear(),_y++,function(){o.forEach(function(e){var t=my.get(e)-1,i=a.get(e)-1;my.set(e,t),a.set(e,i),t||(hy.has(e)||e.removeAttribute(r),hy.delete(e)),i||e.removeAttribute(n)}),_y--,_y||(my=new WeakMap,my=new WeakMap,hy=new WeakMap,gy={})}},by=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||py(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),dee(r,i,n,`aria-hidden`)):function(){return null}};function fee(e){let t=pee(e),n=H.forwardRef((e,n)=>{let{children:r,...i}=e,a=H.Children.toArray(r),o=a.find(hee);if(o){let e=o.props.children,r=a.map(t=>t===o?H.Children.count(e)>1?H.Children.only(null):H.isValidElement(e)?e.props.children:null:t);return(0,Y.jsx)(t,{...i,ref:n,children:H.isValidElement(e)?H.cloneElement(e,void 0,r):null})}return(0,Y.jsx)(t,{...i,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}function pee(e){let t=H.forwardRef((e,t)=>{let{children:n,...r}=e;if(H.isValidElement(n)){let e=_ee(n),i=gee(r,n.props);return n.type!==H.Fragment&&(i.ref=t?Om(t,e):e),H.cloneElement(n,i)}return H.Children.count(n)>1?H.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var mee=Symbol(`radix.slottable`);function hee(e){return H.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===mee}function gee(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function _ee(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var xy=`Dialog`,[Sy,vee]=$g(xy),[yee,Cy]=Sy(xy),wy=e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=H.useRef(null),c=H.useRef(null),[l,u]=o_({prop:r,defaultProp:i??!1,onChange:a,caller:xy});return(0,Y.jsx)(yee,{scope:t,triggerRef:s,contentRef:c,contentId:i_(),titleId:i_(),descriptionId:i_(),open:l,onOpenChange:u,onOpenToggle:H.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})};wy.displayName=xy;var Ty=`DialogTrigger`,bee=H.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=Cy(Ty,n),a=km(t,i.triggerRef);return(0,Y.jsx)(h_.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.contentId,"data-state":Wy(i.open),...r,ref:a,onClick:Zg(e.onClick,i.onOpenToggle)})});bee.displayName=Ty;var Ey=`DialogPortal`,[xee,Dy]=Sy(Ey,{forceMount:void 0}),Oy=e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=Cy(Ey,t);return(0,Y.jsx)(xee,{scope:t,forceMount:n,children:H.Children.map(r,e=>(0,Y.jsx)(Z_,{present:n||a.open,children:(0,Y.jsx)(Y_,{asChild:!0,container:i,children:e})}))})};Oy.displayName=Ey;var ky=`DialogOverlay`,Ay=H.forwardRef((e,t)=>{let n=Dy(ky,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=Cy(ky,e.__scopeDialog);return a.modal?(0,Y.jsx)(Z_,{present:r||a.open,children:(0,Y.jsx)(My,{...i,ref:t})}):null});Ay.displayName=ky;var jy=fee(`DialogOverlay.RemoveScroll`),My=H.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=Cy(ky,n);return(0,Y.jsx)(fy,{as:jy,allowPinchZoom:!0,shards:[i.contentRef],children:(0,Y.jsx)(h_.div,{"data-state":Wy(i.open),...r,ref:t,style:{pointerEvents:`auto`,...r.style}})})}),Ny=`DialogContent`,Py=H.forwardRef((e,t)=>{let n=Dy(Ny,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=Cy(Ny,e.__scopeDialog);return(0,Y.jsx)(Z_,{present:r||a.open,children:a.modal?(0,Y.jsx)(Fy,{...i,ref:t}):(0,Y.jsx)(Iy,{...i,ref:t})})});Py.displayName=Ny;var Fy=H.forwardRef((e,t)=>{let n=Cy(Ny,e.__scopeDialog),r=H.useRef(null),i=km(t,n.contentRef,r);return H.useEffect(()=>{let e=r.current;if(e)return by(e)},[]),(0,Y.jsx)(Ly,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Zg(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:Zg(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:Zg(e.onFocusOutside,e=>e.preventDefault())})}),Iy=H.forwardRef((e,t)=>{let n=Cy(Ny,e.__scopeDialog),r=H.useRef(!1),i=H.useRef(!1);return(0,Y.jsx)(Ly,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),Ly=H.forwardRef((e,t)=>{let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=Cy(Ny,n),c=H.useRef(null),l=km(t,c);return nv(),(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(I_,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,Y.jsx)(T_,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionId,"aria-labelledby":s.titleId,"data-state":Wy(s.open),...o,ref:l,onDismiss:()=>s.onOpenChange(!1)})}),(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(qy,{titleId:s.titleId}),(0,Y.jsx)(Yy,{contentRef:c,descriptionId:s.descriptionId})]})]})}),Ry=`DialogTitle`,zy=H.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=Cy(Ry,n);return(0,Y.jsx)(h_.h2,{id:i.titleId,...r,ref:t})});zy.displayName=Ry;var By=`DialogDescription`,Vy=H.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=Cy(By,n);return(0,Y.jsx)(h_.p,{id:i.descriptionId,...r,ref:t})});Vy.displayName=By;var Hy=`DialogClose`,Uy=H.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=Cy(Hy,n);return(0,Y.jsx)(h_.button,{type:`button`,...r,ref:t,onClick:Zg(e.onClick,()=>i.onOpenChange(!1))})});Uy.displayName=Hy;function Wy(e){return e?`open`:`closed`}var Gy=`DialogTitleWarning`,[See,Ky]=Qg(Gy,{contentName:Ny,titleName:Ry,docsSlug:`dialog`}),qy=({titleId:e})=>{let t=Ky(Gy),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
63
63
 
64
64
  If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
65
65
 
66
- For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return H.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},Jy=`DialogDescriptionWarning`,Yy=({contentRef:e,descriptionId:t})=>{let n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Ky(Jy).contentName}}.`;return H.useEffect(()=>{let r=e.current?.getAttribute(`aria-describedby`);t&&r&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},Xy=Ty,Zy=ky,Qy=jy,$y=Py,eb=zy,tb=Vy,nb=Uy,rb=[`nw`,`n`,`ne`,`e`,`se`,`s`,`sw`,`w`],ib={nw:{left:!0,top:!0},n:{top:!0},ne:{right:!0,top:!0},e:{right:!0},se:{right:!0,bottom:!0},s:{bottom:!0},sw:{left:!0,bottom:!0},w:{left:!0}};function ab(e){return e===`n`||e===`s`?`horizontal`:`vertical`}function ob(e,t,n){return Math.min(Math.max(e,t),Math.max(t,n))}function sb(e,t,n,r){return{w:ob(e,r.minWidth,n.width-16),h:ob(t,r.minHeight,n.height-16)}}function cb(e,t){let n=ob(e.x,120-e.w,t.width-e.w),r=ob(e.y,0,Math.max(0,t.height-48));return{...e,x:n,y:r}}function lb(e,t,n,r){return cb({...e,x:e.x+t,y:e.y+n},r)}function ub(e,t,n,r,i,a){let o=ib[t],s=e.x+e.w,c=e.y+e.h,l=e.w,u=e.h;o.right&&(l=e.w+n),o.left&&(l=e.w-n),o.bottom&&(u=e.h+r),o.top&&(u=e.h-r);let d=sb(l,u,i,a),f=e.x,p=e.y;return o.left&&(f=s-d.w),o.top&&(p=c-d.h),cb({x:f,y:p,w:d.w,h:d.h},i)}function db(e,t,n,r,i){let a=ib[t],o=a.left||a.right,s=a.top||a.bottom,c=o?n===`min`?i.minWidth:r.width-16:e.w,l=s?n===`min`?i.minHeight:r.height-16:e.h,u=e.x+e.w,d=e.y+e.h,f=sb(c,l,r,i);return cb({x:a.left?u-f.w:e.x,y:a.top?d-f.h:e.y,w:f.w,h:f.h},r)}function fb(e){return{x:e.left,y:e.top,w:e.width,h:e.height}}function pb(e,t){return{w:e.width,h:e.height,x:Math.round((t.width-e.width)/2),y:Math.round((t.height-e.height)/2)}}function mb(e,t){let{x:n,y:r,w:i,h:a}=t,o=Math.max(0,i-24),s=Math.max(0,a-24);switch(e){case`nw`:return{left:n-14/2,top:r-14/2,width:14,height:14};case`ne`:return{left:n+i-14/2,top:r-14/2,width:14,height:14};case`se`:return{left:n+i-14/2,top:r+a-14/2,width:14,height:14};case`sw`:return{left:n-14/2,top:r+a-14/2,width:14,height:14};case`n`:return{left:n+12,top:r-8/2,width:o,height:8};case`s`:return{left:n+12,top:r+a-8/2,width:o,height:8};case`e`:return{left:n+i-8/2,top:r+12,width:8,height:s};case`w`:return{left:n-8/2,top:r+12,width:8,height:s}}}function hb(e,t,n){let r=ib[e],i=r.left||r.right,a=r.top||r.bottom;switch(t){case`ArrowRight`:return i?{dx:n,dy:0}:null;case`ArrowLeft`:return i?{dx:-n,dy:0}:null;case`ArrowDown`:return a?{dx:0,dy:n}:null;case`ArrowUp`:return a?{dx:0,dy:-n}:null;default:return null}}var gb=64;function _b(){return typeof window>`u`?{width:0,height:0}:{width:window.innerWidth,height:window.innerHeight}}var vb=`button, input, textarea, select, a, [role="button"], [contenteditable="true"]`;function yb(e={}){let{enabled:t=!0,allowMove:n=!0,minWidth:r=320,minHeight:i=200,anchorFromCurrentRect:a=!1,persistKey:o}=e,s=(0,H.useRef)(null),[c,l]=(0,H.useState)(null),u=(0,H.useCallback)(e=>{s.current=e,l(e)},[]),[d,f]=(0,H.useState)(()=>{if(!o||typeof window>`u`)return null;try{let e=window.localStorage.getItem(o);if(!e)return null;let t=JSON.parse(e);if([t?.x,t?.y,t?.w,t?.h].every(e=>typeof e==`number`&&Number.isFinite(e))&&t.w>0&&t.h>0)return cb(t,_b())}catch{}return null}),[p,m]=(0,H.useState)(null),[h,g]=(0,H.useState)(()=>typeof window>`u`||window.innerWidth>=900),_=(0,H.useRef)(null),v=(0,H.useRef)(null),y=(0,H.useRef)(!1),b=(0,H.useRef)(null),x=(0,H.useRef)(!1);v.current=d;let S={minWidth:r,minHeight:i},C=t&&h;(0,H.useEffect)(()=>{function e(){let e=window.innerWidth>=900;g(e),e||f(null)}return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),(0,H.useEffect)(()=>{t||f(null)},[t]),(0,H.useEffect)(()=>{if(!(!o||typeof window>`u`||!d))try{window.localStorage.setItem(o,JSON.stringify(d))}catch{}},[d,o]),(0,H.useEffect)(()=>{if(!C||d!==null){m(null);return}let e=s.current;if(!e)return;let t=()=>m(fb(e.getBoundingClientRect()));t();let n;return typeof ResizeObserver<`u`&&(n=new ResizeObserver(t),n.observe(e)),window.addEventListener(`resize`,t),window.addEventListener(`scroll`,t,!0),()=>{n?.disconnect(),window.removeEventListener(`resize`,t),window.removeEventListener(`scroll`,t,!0)}},[C,d,c]);let w=(0,H.useCallback)(e=>{b.current=e,!y.current&&(y.current=!0,requestAnimationFrame(()=>{y.current=!1,b.current&&f(b.current)}))},[]),T=(0,H.useCallback)(e=>{let t=_.current;if(!t)return;let n=_b(),r=e.clientX-t.startX,i=e.clientY-t.startY;w(t.mode===`move`?lb(t.startGeom,r,i,n):ub(t.startGeom,t.position,r,i,n,S))},[w,S.minWidth,S.minHeight]),E=(0,H.useCallback)(()=>{let e=_.current;if(e){try{e.element.releasePointerCapture(e.pointerId)}catch{}_.current=null,x.current=!0,setTimeout(()=>{x.current=!1},0),b.current&&f(b.current),window.removeEventListener(`pointermove`,T),window.removeEventListener(`pointerup`,E),window.removeEventListener(`pointercancel`,E)}},[T]),D=(0,H.useCallback)((e,t)=>{if(!C||e.button!==0)return;let n=s.current;if(!n)return;let r=v.current;if(!r){let e=n.getBoundingClientRect();if(e.width<=0||e.height<=0)return;r=cb(a?fb(e):pb(e,_b()),_b())}v.current=r,b.current=r;let i=t(r);_.current=i;try{i.element.setPointerCapture(i.pointerId)}catch{}f(r),window.addEventListener(`pointermove`,T),window.addEventListener(`pointerup`,E),window.addEventListener(`pointercancel`,E)},[C,T,E,a]),O=(0,H.useCallback)(e=>{if(!n||e.target.closest(vb))return;let t=s.current;t&&e.clientY-t.getBoundingClientRect().top>gb||D(e,t=>({mode:`move`,startX:e.clientX,startY:e.clientY,startGeom:t,pointerId:e.pointerId,element:e.currentTarget}))},[n,D]),k=(0,H.useCallback)(e=>t=>{t.stopPropagation(),D(t,n=>({mode:`resize`,position:e,startX:t.clientX,startY:t.clientY,startGeom:n,pointerId:t.pointerId,element:t.currentTarget}))},[D]),A=(0,H.useCallback)(()=>f(null),[]),j=(0,H.useCallback)(e=>(...t)=>{x.current||e(...t)},[]),M=(0,H.useCallback)(e=>t=>{if(!C)return;if(t.key===`0`){t.preventDefault(),A();return}let n=s.current;if(!n)return;let r=_b(),i=v.current??fb(n.getBoundingClientRect());if(t.key===`Home`||t.key===`End`){t.preventDefault(),f(db(i,e,t.key===`Home`?`min`:`max`,r,S));return}let a=t.shiftKey?64:16,o=hb(e,t.key,a);o&&(t.preventDefault(),f(ub(i,e,o.dx,o.dy,r,S)))},[C,A,S.minWidth,S.minHeight]);(0,H.useEffect)(()=>{if(!d||!h)return;function e(){let e=v.current;e&&f(cb(e,_b()))}return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[d,h]),(0,H.useEffect)(()=>()=>{window.removeEventListener(`pointermove`,T),window.removeEventListener(`pointerup`,E),window.removeEventListener(`pointercancel`,E);let e=_.current;if(e){try{e.element.releasePointerCapture(e.pointerId)}catch{}_.current=null}},[T,E]);let N=C&&d!==null,P=N&&d?{position:`fixed`,left:d.x,top:d.y,width:d.w,height:d.h,maxWidth:`none`,maxHeight:`none`,margin:0,transform:`none`,animation:`none`}:{},F=N?d:p,I=C&&F?rb.map(e=>({position:e,role:`separator`,"aria-orientation":ab(e),tabIndex:0,style:{position:`fixed`,...mb(e,F)},onPointerDown:k(e),onKeyDown:M(e)})):[];return{panelRef:u,panelStyle:P,headerHandleProps:{onPointerDown:O},resizeHandles:I,isFloating:N,enabled:C,reset:A,guardBackdrop:j}}var bb={nw:`cursor-nwse-resize`,n:`cursor-ns-resize`,ne:`cursor-nesw-resize`,e:`cursor-ew-resize`,se:`cursor-nwse-resize`,s:`cursor-ns-resize`,sw:`cursor-nesw-resize`,w:`cursor-ew-resize`};function xb({handles:e}){let{t}=K(`common`);return e.length===0?null:(0,Y.jsx)(Y.Fragment,{children:e.map(e=>(0,Y.jsx)(`div`,{"data-testid":`modal-resize-${e.position}`,role:e.role,"aria-orientation":e[`aria-orientation`],"aria-label":t(`modal.resize.${e.position}`),tabIndex:e.tabIndex,style:e.style,onPointerDown:e.onPointerDown,onKeyDown:e.onKeyDown,className:X(`z-[51] rounded-full bg-transparent transition-colors duration-150`,`hover:bg-accent-primary/20 focus:outline-none focus-visible:bg-accent-primary/30`,bb[e.position])},e.position))})}function Sb(...e){return H.useCallback(t=>{for(let n of e)n&&(typeof n==`function`?n(t):n.current=t)},e)}var Cb=Xy,wb=Zy,Tb=H.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(Qy,{ref:n,className:X(`fixed inset-0 z-50 bg-black/60 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`,e),...t}));Tb.displayName=Qy.displayName;var Eb=()=>{let{t:e}=K(`common`);return(0,Y.jsxs)(nb,{className:`absolute right-4 top-4 z-20 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground`,children:[(0,Y.jsx)(hc,{className:`h-4 w-4`}),(0,Y.jsx)(`span`,{className:`sr-only`,children:e(`actions.close`)})]})},Db=H.forwardRef(({className:e,children:t,showCloseButton:n=!0,movableResizable:r=!1,style:i,...a},o)=>{let{panelRef:s,panelStyle:c,resizeHandles:l}=yb({enabled:r,allowMove:!1}),u=Sb(o,s);return r?(0,Y.jsxs)(wb,{children:[(0,Y.jsx)(Tb,{}),(0,Y.jsxs)($y,{ref:u,style:{...i,...c},className:X(`fixed left-[50%] top-[50%] z-50 grid w-full max-w-2xl max-h-[85vh] translate-x-[-50%] translate-y-[-50%] gap-4 border border-border/30 bg-popover p-6 shadow-xl backdrop-blur-md duration-200 overflow-y-auto data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-xl`,e),...a,children:[t,n&&(0,Y.jsx)(Eb,{})]}),(0,Y.jsx)(xb,{handles:l})]}):(0,Y.jsxs)(wb,{children:[(0,Y.jsx)(Tb,{}),(0,Y.jsxs)($y,{ref:o,style:i,className:X(`fixed left-[50%] top-[50%] z-50 grid w-full max-w-2xl max-h-[85vh] translate-x-[-50%] translate-y-[-50%] gap-4 border border-border/30 bg-popover p-6 shadow-xl backdrop-blur-md duration-200 overflow-y-auto data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-xl`,e),...a,children:[t,n&&(0,Y.jsx)(Eb,{})]})]})});Db.displayName=$y.displayName;var Ob=({className:e,...t})=>(0,Y.jsx)(`div`,{className:X(`flex flex-col space-y-1.5 text-center sm:text-left`,e),...t});Ob.displayName=`DialogHeader`;var kb=({className:e,...t})=>(0,Y.jsx)(`div`,{className:X(`flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2`,e),...t});kb.displayName=`DialogFooter`;var Ab=H.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(eb,{ref:n,className:X(`text-lg font-semibold leading-none tracking-tight`,e),...t}));Ab.displayName=eb.displayName;var jb=H.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(tb,{ref:n,className:X(`text-xs text-muted-foreground`,e),...t}));jb.displayName=tb.displayName;var Mb=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}?.VITE_FEATURE_TERMINAL_PANEL;return typeof e==`string`?e!==`false`:!0})(),Nb=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}?.VITE_FEATURE_AGENTS_SECTION;return typeof e==`string`?e!==`false`:!0})(),Pb=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}?.VITE_FEATURE_CODE_EXPLORER;return typeof e==`string`?e!==`false`:!0})(),Fb=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}?.VITE_FEATURE_JIRA;return typeof e==`string`?e!==`false`:!0})(),Ib=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}?.VITE_FEATURE_MCP;return typeof e==`string`?e!==`false`:!0})(),Lb=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}?.VITE_FEATURE_AGENT_CHAT;return typeof e==`string`?e!==`false`:!0})(),Rb=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}?.VITE_FEATURE_AGENT_MODE;return Lb&&(typeof e==`string`?e!==`false`:!0)})();(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}?.VITE_FEATURE_INTERACTIVE_JOBS;return typeof e==`string`?e!==`false`:!0})();var zb=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}?.VITE_FEATURE_LOOPS_SECTION;return typeof e==`string`?e!==`false`:!0})();async function Bb(e){let t=await e.text(),n=t?JSON.parse(t):{};if(!e.ok)throw Error(n.error||`Request failed (${e.status})`);return n}function Vb(e){return e??af()}var Hb=e=>({method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)}),Ub={getConnection(e){return fetch(`${Vb(e)}/jira/connection`).then(e=>Bb(e))},test(e,t){return fetch(`${Vb(t)}/jira/test`,Hb(e)).then(e=>Bb(e))},discoverProjects(e,t){return fetch(`${Vb(t)}/jira/discover-projects`,Hb(e)).then(e=>Bb(e))},discoverStatuses(e,t){return fetch(`${Vb(t)}/jira/discover-statuses`,Hb(e)).then(e=>Bb(e))},connect(e,t){return fetch(`${Vb(t)}/jira/connect`,Hb(e)).then(e=>Bb(e))},setEnabled(e,t){return fetch(`${Vb(t)}/jira/connection`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:e})}).then(e=>Bb(e))},patchConnection(e,t){return fetch(`${Vb(t)}/jira/connection`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)}).then(e=>Bb(e))},listStatuses(e){return fetch(`${Vb(e)}/jira/statuses`).then(e=>Bb(e))},discardSpec(e,t,n){return fetch(`${Vb(n)}/jira/specs/${e}/discard`,Hb({comment:t})).then(e=>Bb(e))},getSpecDetails(e,t){return fetch(`${Vb(t)}/jira/specs/${e}/details`).then(e=>Bb(e))},disconnect(e){return fetch(`${Vb(e)}/jira/connection`,{method:`DELETE`}).then(e=>Bb(e))},syncNow(e){return fetch(`${Vb(e)}/jira/sync`,{method:`POST`}).then(e=>Bb(e))},resume(e){return fetch(`${Vb(e)}/jira/resume`,{method:`POST`}).then(e=>Bb(e))},listOutbox(e,t){let n=e?`?state=${e}`:``;return fetch(`${Vb(t)}/jira/outbox${n}`).then(e=>Bb(e))},retryOutbox(e,t){return fetch(`${Vb(t)}/jira/outbox/${e}/retry`,{method:`POST`}).then(e=>Bb(e))}};function Wb(){let{activeProjectId:e}=gm(),[t,n]=(0,H.useState)({connected:!1,key:null,discardStatus:null}),[r,i]=(0,H.useState)(!0);return(0,H.useEffect)(()=>{if(!Fb||!e){n({connected:!1,key:null,discardStatus:null}),i(!1);return}let t=!1;return i(!0),Ub.getConnection().then(e=>{if(t)return;let r=!!(e.connected&&e.connection?.enabled);n({connected:r,key:e.connection?.jiraProjectKey??null,discardStatus:r?e.connection?.discardStatus??null:null})}).catch(()=>{t||n({connected:!1,key:null,discardStatus:null})}).finally(()=>{t||i(!1)}),()=>{t=!0}},[e]),{connected:t.connected,jiraProjectKey:t.key,discardStatus:t.discardStatus,loading:r}}var Gb=(0,H.createContext)({discardStatus:null});function Kb({children:e}){let t=Wb(),n=t.connected?t.discardStatus:null,r=(0,H.useMemo)(()=>({discardStatus:n}),[n]);return(0,Y.jsx)(Gb.Provider,{value:r,children:e})}function qb(){return(0,H.useContext)(Gb)}function Jb({open:e,onOpenChange:t,ticket:n,discardStatus:r,onDiscarded:i}){let{t:a}=K(`jira`),[o,s]=(0,H.useState)(``),[c,l]=(0,H.useState)(!1);async function u(){l(!0);try{await Ub.discardSpec(n.id,o.trim()||null),q.success(a(`discard.movedToast`,{status:r,key:n.jira_key??`#${n.id}`})),t(!1),s(``),i?.()}catch(e){q.error(e instanceof Error?e.message:a(`errors.generic`))}finally{l(!1)}}return(0,Y.jsx)(Cb,{open:e,onOpenChange:e=>{c||t(e)},children:(0,Y.jsxs)(Db,{movableResizable:!0,className:`max-w-md`,"data-testid":`jira-discard-dialog`,children:[(0,Y.jsxs)(Ob,{children:[(0,Y.jsx)(Ab,{children:a(`discard.title`,{status:r})}),(0,Y.jsx)(jb,{children:a(`discard.body`,{status:r,key:n.jira_key??`#${n.id}`})})]}),(0,Y.jsxs)(`label`,{className:`block space-y-1`,children:[(0,Y.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:a(`discard.commentLabel`)}),(0,Y.jsx)(`textarea`,{value:o,onChange:e=>s(e.target.value),placeholder:a(`discard.commentPlaceholder`),rows:3,className:`w-full rounded-md border border-border bg-input px-3 py-2 text-xs text-foreground placeholder:text-muted-foreground resize-none`,"data-testid":`jira-discard-comment`})]}),(0,Y.jsxs)(kb,{children:[(0,Y.jsx)(Z,{variant:`outline`,size:`sm`,onClick:()=>t(!1),disabled:c,children:a(`wizard.cancel`)}),(0,Y.jsxs)(Z,{size:`sm`,onClick:u,disabled:c,"data-testid":`jira-discard-confirm`,children:[(0,Y.jsx)(Va,{className:`w-3.5 h-3.5 mr-1.5`}),c?a(`discard.moving`):a(`discard.confirm`,{status:r})]})]})]})})}var Yb=[{value:`todo`,labelKey:`ticketStatus.todo`,icon:(0,Y.jsx)(uo,{className:`w-3.5 h-3.5 text-slate-400 aurora-light:text-muted-foreground`}),className:`text-slate-400 aurora-light:text-muted-foreground`},{value:`done`,labelKey:`ticketStatus.done`,icon:(0,Y.jsx)(co,{className:`w-3.5 h-3.5 text-emerald-400 aurora-light:text-accent-success`}),className:`text-emerald-400 aurora-light:text-accent-success`}],Xb=[{value:`critical`,labelKey:`priority.critical`,icon:(0,Y.jsx)(oo,{className:`w-3.5 h-3.5 text-red-400 aurora-light:text-destructive`}),className:`text-red-400 aurora-light:text-destructive`},{value:`high`,labelKey:`priority.high`,icon:(0,Y.jsx)(Ua,{className:`w-3.5 h-3.5 text-orange-400 aurora-light:text-accent-warning`}),className:`text-orange-400 aurora-light:text-accent-warning`},{value:`medium`,labelKey:`priority.medium`,icon:(0,Y.jsx)(Va,{className:`w-3.5 h-3.5 text-yellow-400 aurora-light:text-accent-warning`}),className:`text-yellow-400 aurora-light:text-accent-warning`},{value:`low`,labelKey:`priority.low`,icon:(0,Y.jsx)(za,{className:`w-3.5 h-3.5 text-slate-400 aurora-light:text-muted-foreground`}),className:`text-slate-400 aurora-light:text-muted-foreground`}];function Zb({position:e,ticket:t,activeSubmenu:n,onSetSubmenu:r,onStatusChange:i,onPriorityChange:a,onDeleteRequest:o,discardLabel:s,onDiscardRequest:c,onClose:l}){let{t:u}=K(`tickets`),d=(0,H.useRef)(null),[f,p]=(0,H.useState)(e);(0,H.useEffect)(()=>{if(!d.current)return;let t=d.current.getBoundingClientRect(),n=window.innerWidth,r=window.innerHeight;p({x:t.right>n?Math.max(0,e.x-t.width):e.x,y:t.bottom>r?Math.max(0,e.y-t.height):e.y})},[e]);let m=(0,H.useCallback)(e=>{e(),l()},[l]);return(0,Y.jsxs)(`div`,{ref:d,role:`menu`,"aria-label":u(`contextMenu.ariaLabel`),style:{left:f.x,top:f.y},className:`fixed z-[200] min-w-[180px] rounded-lg border border-border/50 bg-popover shadow-xl text-xs py-1`,children:[s&&c?(0,Y.jsxs)(`button`,{role:`menuitem`,type:`button`,onClick:()=>{c(),l()},className:`flex w-full items-center gap-2 px-3 py-2 text-left text-accent-info hover:bg-accent-info/10 transition-colors`,"data-testid":`jira-move-to-menuitem`,children:[(0,Y.jsx)(Va,{className:`w-3.5 h-3.5 shrink-0`}),s]}):(0,Y.jsxs)(`button`,{role:`menuitem`,type:`button`,onClick:()=>{o(),l()},className:`flex w-full items-center gap-2 px-3 py-2 text-left text-red-400 aurora-light:text-destructive hover:bg-red-500/10 transition-colors`,children:[(0,Y.jsx)(cc,{className:`w-3.5 h-3.5 shrink-0`}),u(`contextMenu.deleteTicket`)]}),(0,Y.jsx)(`div`,{className:`my-1 h-px bg-border/40`,role:`separator`}),(0,Y.jsxs)(`div`,{role:`menuitem`,tabIndex:-1,"aria-haspopup":`menu`,"aria-expanded":n===`status`,className:X(`relative flex w-full items-center justify-between gap-2 px-3 py-2 cursor-pointer select-none text-foreground/80 hover:bg-accent/50 hover:text-foreground transition-colors`,n===`status`&&`bg-accent/50 text-foreground`),onMouseEnter:()=>r(`status`),onClick:e=>{e.stopPropagation(),r(n===`status`?null:`status`)},children:[(0,Y.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(uo,{className:`w-3.5 h-3.5 shrink-0 text-muted-foreground`}),u(`contextMenu.changeStatus`)]}),(0,Y.jsx)(io,{className:`w-3 h-3 text-muted-foreground`}),n===`status`&&(0,Y.jsx)(`div`,{role:`menu`,"aria-label":u(`contextMenu.statusOptions`),className:`absolute left-full top-0 ml-1 min-w-[150px] rounded-lg border border-border/50 bg-popover shadow-xl py-1 z-[201]`,children:Yb.map(e=>(0,Y.jsxs)(`button`,{role:`menuitem`,type:`button`,onClick:()=>m(()=>i(e.value)),className:X(`flex w-full items-center gap-2 px-3 py-2 text-left hover:bg-accent/50 transition-colors`,e.className,t.status===e.value&&`bg-accent/30 font-semibold`),children:[e.icon,u(e.labelKey)]},e.value))})]}),(0,Y.jsxs)(`div`,{role:`menuitem`,tabIndex:-1,"aria-haspopup":`menu`,"aria-expanded":n===`priority`,className:X(`relative flex w-full items-center justify-between gap-2 px-3 py-2 cursor-pointer select-none text-foreground/80 hover:bg-accent/50 hover:text-foreground transition-colors`,n===`priority`&&`bg-accent/50 text-foreground`),onMouseEnter:()=>r(`priority`),onClick:e=>{e.stopPropagation(),r(n===`priority`?null:`priority`)},children:[(0,Y.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(Io,{className:`w-3.5 h-3.5 shrink-0 text-muted-foreground`}),u(`contextMenu.setPriority`)]}),(0,Y.jsx)(io,{className:`w-3 h-3 text-muted-foreground`}),n===`priority`&&(0,Y.jsx)(`div`,{role:`menu`,"aria-label":u(`contextMenu.priorityOptions`),className:`absolute left-full top-0 ml-1 min-w-[140px] rounded-lg border border-border/50 bg-popover shadow-xl py-1 z-[201]`,children:Xb.map(e=>(0,Y.jsxs)(`button`,{role:`menuitem`,type:`button`,onClick:()=>m(()=>a(e.value)),className:X(`flex w-full items-center gap-2 px-3 py-2 text-left hover:bg-accent/50 transition-colors`,e.className,t.priority===e.value&&`bg-accent/30 font-semibold`),children:[e.icon,u(e.labelKey)]},e.value))})]})]})}function Qb({ticket:e,onDelete:t,onStatusChange:n,onPriorityChange:r,children:i,className:a}){let{t:o}=K(`tickets`),{t:s}=K(`jira`),[c,l]=(0,H.useState)(!1),[u,d]=(0,H.useState)({x:0,y:0}),[f,p]=(0,H.useState)(null),[m,h]=(0,H.useState)(!1),[g,_]=(0,H.useState)(!1),{discardStatus:v}=qb(),y=!!v&&e.source===`jira`&&!!e.jira_key,b=(0,H.useCallback)(()=>{l(!1),p(null)},[]);(0,H.useEffect)(()=>{if(!c)return;function e(e){e.key===`Escape`&&b()}function t(e){e.target.closest(`[role="menu"]`)||b()}return document.addEventListener(`keydown`,e),document.addEventListener(`mousedown`,t),()=>{document.removeEventListener(`keydown`,e),document.removeEventListener(`mousedown`,t)}},[c,b]);function x(e){e.preventDefault(),d({x:e.clientX,y:e.clientY}),p(null),l(!0)}function S(){t(e.id),h(!1)}return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{onContextMenu:x,className:a,"data-ticket-id":e.id,children:i}),c&&(0,sr.createPortal)((0,Y.jsx)(Zb,{position:u,ticket:e,activeSubmenu:f,onSetSubmenu:p,onStatusChange:t=>n(e.id,t),onPriorityChange:t=>r(e.id,t),onDeleteRequest:()=>h(!0),discardLabel:y?s(`discard.moveButton`,{status:v}):void 0,onDiscardRequest:y?()=>_(!0):void 0,onClose:b}),document.body),y&&v&&(0,Y.jsx)(Jb,{open:g,onOpenChange:_,ticket:{id:e.id,title:e.title,jira_key:e.jira_key},discardStatus:v}),(0,Y.jsx)(Cb,{open:m,onOpenChange:h,children:(0,Y.jsxs)(Db,{className:`max-w-sm`,children:[(0,Y.jsxs)(Ob,{children:[(0,Y.jsx)(Ab,{children:o(`deleteDialog.title`)}),(0,Y.jsx)(jb,{children:(0,Y.jsx)(Yi,{t:o,i18nKey:`deleteDialog.body`,values:{id:e.id,title:e.title},components:{strong:(0,Y.jsx)(`span`,{className:`font-semibold text-foreground`})}})})]}),(0,Y.jsxs)(kb,{children:[(0,Y.jsx)(Z,{variant:`outline`,size:`sm`,onClick:()=>h(!1),children:o(`common:actions.cancel`)}),(0,Y.jsxs)(Z,{variant:`destructive`,size:`sm`,onClick:S,children:[(0,Y.jsx)(cc,{className:`w-3.5 h-3.5 mr-1.5`}),o(`common:actions.delete`)]})]})]})})]})}var $b=[`accent-primary`,`accent-info`,`accent-success`,`accent-secondary`,`accent-warning`,`accent-highlight`];function ex(e){let t=2166136261,n=e.toLowerCase();for(let e=0;e<n.length;e+=1)t^=n.charCodeAt(e),t=Math.imul(t,16777619)>>>0;return $b[t%$b.length]}var tx={"accent-primary":`bg-accent-primary/20 text-accent-primary`,"accent-info":`bg-accent-info/20 text-accent-info`,"accent-success":`bg-accent-success/20 text-accent-success`,"accent-secondary":`bg-accent-secondary/20 text-accent-secondary`,"accent-warning":`bg-accent-warning/20 text-accent-warning`,"accent-highlight":`bg-accent-highlight/20 text-accent-highlight`};function nx({tickets:e,active:t,onChange:n,className:r}){let{t:i}=K(`specs`),[a,o]=(0,H.useState)(!1),s=(0,H.useRef)(null),c=(0,H.useRef)(null),l=(0,H.useMemo)(()=>{let t=new Map;for(let n of e)for(let e of n.labels??[]){let n=e.trim();n&&t.set(n,(t.get(n)??0)+1)}return Array.from(t.entries()).sort((e,t)=>t[1]===e[1]?e[0].localeCompare(t[0]):t[1]-e[1])},[e]);(0,H.useEffect)(()=>{if(!a)return;function e(e){c.current?.contains(e.target)||s.current?.contains(e.target)||o(!1)}function t(e){e.key===`Escape`&&o(!1)}return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[a]);function u(e){let r=new Set(t);r.has(e)?r.delete(e):r.add(e),n(r)}function d(){n(new Set)}let f=t.size===0?i(`labelFilter.all`):t.size===1?Array.from(t)[0]:i(`labelFilter.selected`,{count:t.size});return(0,Y.jsxs)(`div`,{className:X(`relative shrink-0`,r),children:[(0,Y.jsxs)(`button`,{ref:s,type:`button`,"aria-haspopup":`listbox`,"aria-expanded":a,"aria-label":i(`labelFilter.ariaLabel`),"data-testid":`spec-label-filter-dropdown`,onClick:()=>o(e=>!e),className:`flex items-center gap-1.5 h-7 px-2 rounded-md text-xs bg-accent-secondary/10 border border-accent-secondary/30 hover:bg-accent-secondary/20 text-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-secondary/50`,children:[(0,Y.jsx)(ic,{className:`w-3 h-3 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`truncate max-w-[120px]`,children:f}),t.size>0&&(0,Y.jsxs)(`span`,{className:`text-[10px] text-muted-foreground/80`,children:[`·\xA0`,t.size]})]}),a&&(0,Y.jsxs)(`div`,{ref:c,role:`listbox`,"aria-multiselectable":`true`,"data-testid":`spec-label-filter-panel`,className:`absolute z-40 left-0 mt-1 w-56 max-h-72 overflow-y-auto rounded-xl border border-border/60 bg-card/95 backdrop-blur shadow-xl shadow-black/30 p-1`,children:[(0,Y.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t.size===0,onClick:d,"data-testid":`spec-label-filter-all`,className:X(`w-full flex items-center gap-2 px-2 py-1.5 rounded-lg text-left text-xs hover:bg-accent-info/10 transition-colors`,t.size===0&&`bg-accent-info/10 text-accent-info`),children:[(0,Y.jsx)(`span`,{className:`inline-flex w-4 h-4 items-center justify-center`,children:t.size===0&&(0,Y.jsx)(to,{className:`w-3 h-3 text-accent-info`})}),(0,Y.jsx)(`span`,{className:`flex-1`,children:i(`labelFilter.all`)}),(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground/70`,children:e.length})]}),l.length===0&&(0,Y.jsx)(`div`,{className:`px-2 py-2 text-[11px] text-muted-foreground/60 italic`,children:i(`labelFilter.empty`)}),l.length>0&&(0,Y.jsx)(`div`,{className:`my-1 h-px bg-border/40`,"aria-hidden":!0}),l.map(([e,n])=>{let r=t.has(e),i=tx[ex(e)]??`bg-muted/40 text-foreground`;return(0,Y.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":r,onClick:()=>u(e),className:X(`w-full flex items-center gap-2 px-2 py-1.5 rounded-lg text-left text-xs hover:bg-muted/30 transition-colors`,r&&`bg-accent-info/5`),children:[(0,Y.jsx)(`span`,{className:`inline-flex w-4 h-4 items-center justify-center`,children:r&&(0,Y.jsx)(to,{className:`w-3 h-3 text-accent-info`})}),(0,Y.jsx)(`span`,{className:X(`inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[10px] font-medium`,i),children:e}),(0,Y.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground/60`,children:n})]},e)})]})]})}function rx({tickets:e,active:t,onChange:n,className:r}){let{t:i}=K(`specs`),[a,o]=(0,H.useState)(!1),s=(0,H.useRef)(null),c=(0,H.useRef)(null),l=(0,H.useMemo)(()=>{let t=new Map;for(let n of e){if(!n.jira_epic_key)continue;let e=t.get(n.jira_epic_key);e?e.count+=1:t.set(n.jira_epic_key,{key:n.jira_epic_key,name:n.jira_epic_name??n.jira_epic_key,count:1})}return Array.from(t.values()).sort((e,t)=>t.count===e.count?e.name.localeCompare(t.name):t.count-e.count)},[e]);(0,H.useEffect)(()=>{if(!a)return;function e(e){c.current?.contains(e.target)||s.current?.contains(e.target)||o(!1)}function t(e){e.key===`Escape`&&o(!1)}return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[a]);function u(e){n(e),o(!1)}let d=t?l.find(e=>e.key===t):null,f=d?d.name:i(`epicFilter.all`);return(0,Y.jsxs)(`div`,{className:X(`relative shrink-0`,r),children:[(0,Y.jsxs)(`button`,{ref:s,type:`button`,"aria-haspopup":`listbox`,"aria-expanded":a,"aria-label":i(`epicFilter.ariaLabel`),"data-testid":`spec-epic-filter-dropdown`,onClick:()=>o(e=>!e),className:`flex items-center gap-1.5 h-7 px-2 rounded-md text-xs bg-accent-highlight/10 border border-accent-highlight/30 hover:bg-accent-highlight/20 text-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-highlight/50`,children:[(0,Y.jsx)(rs,{className:`w-3 h-3 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`truncate max-w-[140px]`,children:f})]}),a&&(0,Y.jsxs)(`div`,{ref:c,role:`listbox`,"data-testid":`spec-epic-filter-panel`,className:`absolute z-40 left-0 mt-1 w-64 max-h-72 overflow-y-auto rounded-xl border border-border/60 bg-card/95 backdrop-blur shadow-xl shadow-black/30 p-1`,children:[(0,Y.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t===null,onClick:()=>u(null),"data-testid":`spec-epic-filter-all`,className:X(`w-full flex items-center gap-2 px-2 py-1.5 rounded-lg text-left text-xs hover:bg-accent-info/10 transition-colors`,t===null&&`bg-accent-info/10 text-accent-info`),children:[(0,Y.jsx)(`span`,{className:`inline-flex w-4 h-4 items-center justify-center`,children:t===null&&(0,Y.jsx)(to,{className:`w-3 h-3 text-accent-info`})}),(0,Y.jsx)(`span`,{className:`flex-1`,children:i(`epicFilter.all`)}),(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground/70`,children:e.length})]}),l.length>0&&(0,Y.jsx)(`div`,{className:`my-1 h-px bg-border/40`,"aria-hidden":!0}),l.map(e=>{let n=t===e.key;return(0,Y.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":n,onClick:()=>u(e.key),className:X(`w-full flex items-center gap-2 px-2 py-1.5 rounded-lg text-left text-xs hover:bg-muted/30 transition-colors`,n&&`bg-accent-info/5`),children:[(0,Y.jsx)(`span`,{className:`inline-flex w-4 h-4 items-center justify-center`,children:n&&(0,Y.jsx)(to,{className:`w-3 h-3 text-accent-info`})}),(0,Y.jsx)(`span`,{className:`font-mono text-[10px] text-accent-highlight shrink-0`,children:e.key}),(0,Y.jsx)(`span`,{className:`truncate text-foreground/80`,children:e.name}),(0,Y.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground/60`,children:e.count})]},e.key)})]})]})}function ix({tickets:e,active:t,onChange:n,className:r}){let{t:i}=K(`specs`),[a,o]=(0,H.useState)(!1),s=(0,H.useRef)(null),c=(0,H.useRef)(null),l=(0,H.useMemo)(()=>{let t=new Map;for(let n of e){if(!n.jira_sprint_id)continue;let e=n.jira_sprint_state===`active`,r=t.get(n.jira_sprint_id);r?(r.count+=1,e&&(r.active=!0)):t.set(n.jira_sprint_id,{id:n.jira_sprint_id,name:n.jira_sprint_name??n.jira_sprint_id,count:1,active:e})}return Array.from(t.values()).sort((e,t)=>e.active===t.active?t.count===e.count?e.name.localeCompare(t.name):t.count-e.count:e.active?-1:1)},[e]);(0,H.useEffect)(()=>{if(!a)return;function e(e){c.current?.contains(e.target)||s.current?.contains(e.target)||o(!1)}function t(e){e.key===`Escape`&&o(!1)}return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[a]);function u(e){n(e),o(!1)}let d=t?l.find(e=>e.id===t):null,f=d?d.name:i(`sprintFilter.all`);return(0,Y.jsxs)(`div`,{className:X(`relative shrink-0`,r),children:[(0,Y.jsxs)(`button`,{ref:s,type:`button`,"aria-haspopup":`listbox`,"aria-expanded":a,"aria-label":i(`sprintFilter.ariaLabel`),"data-testid":`spec-sprint-filter-dropdown`,onClick:()=>o(e=>!e),className:`flex items-center gap-1.5 h-7 px-2 rounded-md text-xs bg-accent-success/10 border border-accent-success/30 hover:bg-accent-success/20 text-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-success/50`,children:[(0,Y.jsx)(sc,{className:`w-3 h-3 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`truncate max-w-[140px]`,children:f})]}),a&&(0,Y.jsxs)(`div`,{ref:c,role:`listbox`,"data-testid":`spec-sprint-filter-panel`,className:`absolute z-40 left-0 mt-1 w-64 max-h-72 overflow-y-auto rounded-xl border border-border/60 bg-card/95 backdrop-blur shadow-xl shadow-black/30 p-1`,children:[(0,Y.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t===null,onClick:()=>u(null),"data-testid":`spec-sprint-filter-all`,className:X(`w-full flex items-center gap-2 px-2 py-1.5 rounded-lg text-left text-xs hover:bg-accent-info/10 transition-colors`,t===null&&`bg-accent-info/10 text-accent-info`),children:[(0,Y.jsx)(`span`,{className:`inline-flex w-4 h-4 items-center justify-center`,children:t===null&&(0,Y.jsx)(to,{className:`w-3 h-3 text-accent-info`})}),(0,Y.jsx)(`span`,{className:`flex-1`,children:i(`sprintFilter.all`)}),(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground/70`,children:e.length})]}),l.length>0&&(0,Y.jsx)(`div`,{className:`my-1 h-px bg-border/40`,"aria-hidden":!0}),l.map(e=>{let n=t===e.id;return(0,Y.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":n,onClick:()=>u(e.id),className:X(`w-full flex items-center gap-2 px-2 py-1.5 rounded-lg text-left text-xs hover:bg-muted/30 transition-colors`,n&&`bg-accent-info/5`),children:[(0,Y.jsx)(`span`,{className:`inline-flex w-4 h-4 items-center justify-center`,children:n&&(0,Y.jsx)(to,{className:`w-3 h-3 text-accent-info`})}),(0,Y.jsx)(`span`,{className:`truncate text-foreground/80`,children:e.name}),e.active&&(0,Y.jsx)(`span`,{"data-testid":`spec-sprint-current-badge`,className:`shrink-0 rounded-full bg-accent-success/15 px-1.5 py-0.5 text-[9px] font-medium uppercase tracking-wide text-accent-success`,children:i(`sprintFilter.current`)}),(0,Y.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground/60`,children:e.count})]},e.id)})]})]})}var ax={draft:{dotClass:`bg-accent-secondary/60`,textClass:`text-accent-secondary`,borderClass:`border-l-[3px] border-dashed border-accent-secondary/50 pl-3`,labelKey:`common:status.draft`,pulsing:!1},todo:{dotClass:`bg-slate-500/70`,textClass:`text-muted-foreground`,borderClass:`border-l-[3px] border-dashed border-slate-500/40 pl-3`,labelKey:`status.todo`,pulsing:!1},in_progress:{dotClass:`bg-blue-400 aurora-light:bg-accent-info`,textClass:`text-foreground font-semibold`,borderClass:`border-l-[3px] border-solid border-blue-500 pl-3`,labelKey:`status.inProgress`,pulsing:!0},on_review:{dotClass:`bg-accent-warning/80`,textClass:`text-accent-warning`,borderClass:`border-l-[3px] border-solid border-accent-warning/60 pl-3`,labelKey:`status.onReview`,pulsing:!1},done:{dotClass:`text-emerald-400 aurora-light:text-accent-success`,textClass:`text-emerald-400/80 aurora-light:text-accent-success`,borderClass:`border-l-[3px] border-solid border-emerald-500 pl-3`,labelKey:`status.done`,pulsing:!1},cancelled:{dotClass:`text-red-400/60 aurora-light:text-destructive/70`,textClass:`text-muted-foreground/50`,borderClass:`pl-3`,labelKey:`status.cancelled`,pulsing:!1}};function ox({status:e,className:t}){let{t:n}=K(`specs`),r=ax[e];return e===`done`?(0,Y.jsx)(to,{className:X(`w-3.5 h-3.5 shrink-0`,r.dotClass,t),"aria-label":n(`status.done`)}):e===`cancelled`?(0,Y.jsx)(hc,{className:X(`w-3.5 h-3.5 shrink-0`,r.dotClass,t),"aria-label":n(`status.cancelled`)}):r.pulsing?(0,Y.jsxs)(`span`,{className:X(`relative flex shrink-0 h-2.5 w-2.5`,t),"aria-label":n(`status.inProgress`),children:[(0,Y.jsx)(`span`,{className:X(`animate-ping absolute inline-flex h-full w-full rounded-full opacity-60`,r.dotClass)}),(0,Y.jsx)(`span`,{className:X(`relative inline-flex rounded-full h-2.5 w-2.5`,r.dotClass)})]}):(0,Y.jsx)(`span`,{className:X(`inline-flex rounded-full h-2.5 w-2.5 shrink-0`,r.dotClass,t),"aria-label":n(r.labelKey)})}function sx({status:e,className:t}){let{t:n}=K(`specs`),r=ax[e];return(0,Y.jsxs)(`span`,{className:X(`inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-[11px] font-medium border`,e===`todo`&&`bg-slate-500/10 border-slate-500/30 text-slate-400 aurora-light:bg-muted aurora-light:border-border aurora-light:text-muted-foreground`,e===`in_progress`&&`bg-blue-500/10 border-blue-500/30 text-blue-400 aurora-light:bg-accent-info/10 aurora-light:border-accent-info/30 aurora-light:text-accent-info`,e===`on_review`&&`bg-accent-warning/10 border-accent-warning/30 text-accent-warning`,e===`done`&&`bg-emerald-500/10 border-emerald-500/30 text-emerald-400 aurora-light:bg-accent-success/10 aurora-light:border-accent-success/30 aurora-light:text-accent-success`,e===`cancelled`&&`bg-red-500/10 border-red-500/30 text-red-400/60 aurora-light:bg-destructive/10 aurora-light:border-destructive/30 aurora-light:text-destructive/70`,t),children:[(0,Y.jsx)(ox,{status:e}),n(r.labelKey)]})}var cx=[`draft`,`todo`,`in_progress`,`on_review`,`done`,`cancelled`],lx=new Set([`draft`,`todo`,`in_progress`,`on_review`]),ux=[`active`,`all`,...cx];function dx(e){return typeof e==`string`&&ux.includes(e)}function fx(e,t){return t===`all`?!0:t===`active`?lx.has(e):e===t}var px=e=>`specrails-desktop:spec-status-filter:${e}`,mx=e=>`specrails-desktop:spec-status-tab:${e}`;function hx(e){if(!e)return`active`;try{let t=localStorage.getItem(px(e));return dx(t)?t:localStorage.getItem(mx(e))===`done`?`done`:`active`}catch{return`active`}}function gx(e,t){if(e)try{localStorage.setItem(px(e),t)}catch{}}var _x={active:`bg-accent-primary/15 border-accent-primary/40 text-accent-primary`,all:`bg-muted/50 border-border text-foreground`,draft:`bg-accent-secondary/15 border-accent-secondary/40 text-accent-secondary`,todo:`bg-slate-500/15 border-slate-500/40 text-slate-400 aurora-light:bg-muted aurora-light:border-border aurora-light:text-muted-foreground`,in_progress:`bg-blue-500/15 border-blue-500/40 text-blue-400 aurora-light:bg-accent-info/10 aurora-light:border-accent-info/30 aurora-light:text-accent-info`,on_review:`bg-accent-warning/15 border-accent-warning/40 text-accent-warning`,done:`bg-emerald-500/15 border-emerald-500/40 text-emerald-400 aurora-light:bg-accent-success/10 aurora-light:border-accent-success/30 aurora-light:text-accent-success`,cancelled:`bg-red-500/10 border-red-500/30 text-red-400/80 aurora-light:bg-destructive/10 aurora-light:border-destructive/30 aurora-light:text-destructive/70`},vx={active:`statusFilter.active`,all:`statusFilter.all`,draft:`common:status.draft`,todo:`status.todo`,in_progress:`status.inProgress`,on_review:`status.onReview`,done:`status.done`,cancelled:`status.cancelled`};function yx({value:e,selected:t,count:n,onClick:r,label:i}){let a=e!==`active`&&e!==`all`;return(0,Y.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t,onClick:r,"data-testid":`specs-status-chip-${e}`,title:i,className:X(`inline-flex items-center gap-1.5 rounded-full border px-2.5 h-6 text-[11px] font-medium whitespace-nowrap shrink-0 transition-all`,t?_x[e]:`border-transparent text-muted-foreground hover:text-foreground hover:bg-muted/40`,!t&&n===0&&`opacity-40`),children:[a&&(0,Y.jsx)(ox,{status:e,className:`w-2 h-2`}),(0,Y.jsx)(`span`,{children:i}),(0,Y.jsx)(`span`,{className:X(`text-[10px] tabular-nums rounded-full px-1 min-w-[16px] text-center`,t?`bg-background/40`:`bg-muted/30 opacity-70`),"data-testid":`specs-status-count-${e}`,children:n})]})}function bx({value:e,onChange:t,counts:n,className:r}){let{t:i}=K(`specs`),a=cx.filter(e=>lx.has(e)).reduce((e,t)=>e+n[t],0),o=cx.reduce((e,t)=>e+n[t],0),s=e=>e===`active`?a:e===`all`?o:n[e];return(0,Y.jsxs)(`div`,{role:`tablist`,"aria-label":i(`statusFilter.ariaLabel`),"data-testid":`specs-status-filter`,className:X(`flex items-center gap-1 min-w-0 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,r),children:[[`active`,`all`].map(n=>(0,Y.jsx)(yx,{value:n,selected:e===n,count:s(n),onClick:()=>t(n),label:i(vx[n])},n)),(0,Y.jsx)(`div`,{className:`h-4 w-px bg-border/50 shrink-0 mx-0.5`,"aria-hidden":!0}),cx.map(n=>(0,Y.jsx)(yx,{value:n,selected:e===n,count:s(n),onClick:()=>t(n),label:i(vx[n])},n))]})}var xx=[...cx,`other`],Sx={draft:`common:status.draft`,todo:`status.todo`,in_progress:`status.inProgress`,on_review:`status.onReview`,done:`status.done`,cancelled:`status.cancelled`};function Cx({tickets:e,active:t,onChange:n,className:r}){let{t:i}=K(`specs`),[a,o]=(0,H.useState)(!1),s=(0,H.useRef)(null),c=(0,H.useRef)(null),{groups:l,total:u}=(0,H.useMemo)(()=>{let t=new Map,n=0;for(let r of e){if(!r.jira_status)continue;n+=1;let e=t.get(r.jira_status);e||(e=new Map,t.set(r.jira_status,e)),e.set(r.status,(e.get(r.status)??0)+1)}let r=[];for(let[e,n]of t){let t=0,i=`other`,a=0,o=!1;for(let e of cx){let r=n.get(e)??0;t+=r,r>a?(i=e,a=r,o=!1):r===a&&r>0&&(o=!0)}r.push({name:e,count:t,logical:o?`other`:i})}let i=new Map;for(let e of xx){let t=r.filter(t=>t.logical===e).sort((e,t)=>t.count===e.count?e.name.localeCompare(t.name):t.count-e.count);t.length>0&&i.set(e,t)}return{groups:i,total:n}},[e]);(0,H.useEffect)(()=>{if(!a)return;function e(e){c.current?.contains(e.target)||s.current?.contains(e.target)||o(!1)}function t(e){e.key===`Escape`&&o(!1)}return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[a]);function d(e){n(e),o(!1)}let f=(0,H.useMemo)(()=>{if(!t)return null;for(let[e,n]of l)if(n.some(e=>e.name===t))return e;return`other`},[t,l]);return(0,Y.jsxs)(`div`,{className:X(`relative shrink-0`,r),children:[(0,Y.jsxs)(`button`,{ref:s,type:`button`,"aria-haspopup":`listbox`,"aria-expanded":a,"aria-label":i(`jiraStatusFilter.ariaLabel`),"data-testid":`spec-jira-status-filter-dropdown`,onClick:()=>o(e=>!e),className:X(`flex items-center gap-1.5 h-6 px-2 rounded-full text-[11px] font-medium border transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-info/50`,t?`bg-accent-info/10 border-accent-info/40 text-accent-info hover:bg-accent-info/20`:`bg-transparent border-border/60 text-muted-foreground hover:text-foreground hover:bg-muted/40`),children:[(0,Y.jsx)(mc,{className:`w-3 h-3`}),t&&f&&f!==`other`&&(0,Y.jsx)(ox,{status:f,className:`w-2 h-2`}),(0,Y.jsx)(`span`,{className:`truncate max-w-[140px]`,children:t??i(`jiraStatusFilter.triggerLabel`)})]}),a&&(0,Y.jsxs)(`div`,{ref:c,role:`listbox`,"data-testid":`spec-jira-status-filter-panel`,className:`absolute z-40 left-0 mt-1 w-64 max-h-80 overflow-y-auto rounded-xl border border-border/60 bg-card/95 backdrop-blur shadow-xl shadow-black/30 p-1`,children:[(0,Y.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t===null,onClick:()=>d(null),"data-testid":`spec-jira-status-filter-all`,className:X(`w-full flex items-center gap-2 px-2 py-1.5 rounded-lg text-left text-xs hover:bg-accent-info/10 transition-colors`,t===null&&`bg-accent-info/10 text-accent-info`),children:[(0,Y.jsx)(`span`,{className:`inline-flex w-4 h-4 items-center justify-center`,children:t===null&&(0,Y.jsx)(to,{className:`w-3 h-3 text-accent-info`})}),(0,Y.jsx)(`span`,{className:`flex-1`,children:i(`jiraStatusFilter.all`)}),(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground/70 tabular-nums`,children:u})]}),xx.map(e=>{let n=l.get(e);if(!n)return null;let r=e===`other`;return(0,Y.jsxs)(`div`,{"data-testid":`spec-jira-status-group-${e}`,children:[(0,Y.jsxs)(`div`,{className:X(`flex items-center gap-1.5 px-2 pt-2 pb-1 text-[10px] font-semibold uppercase tracking-wide`,r?`text-muted-foreground/50`:`text-muted-foreground/80`),"aria-hidden":!0,children:[!r&&(0,Y.jsx)(ox,{status:e,className:`w-2 h-2`}),(0,Y.jsx)(`span`,{children:i(r?`jiraStatusFilter.other`:Sx[e])})]}),n.map(e=>{let n=t===e.name;return(0,Y.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":n,onClick:()=>d(e.name),"data-testid":`spec-jira-status-option-${e.name}`,className:X(`w-full flex items-center gap-2 px-2 py-1.5 rounded-lg text-left text-xs hover:bg-muted/30 transition-colors`,n&&`bg-accent-info/5`,r&&`opacity-70`),children:[(0,Y.jsx)(`span`,{className:`inline-flex w-4 h-4 items-center justify-center`,children:n&&(0,Y.jsx)(to,{className:`w-3 h-3 text-accent-info`})}),(0,Y.jsx)(`span`,{className:`truncate text-foreground/80`,children:e.name}),(0,Y.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground/60 tabular-nums`,children:e.count})]},e.name)})]},e)})]})]})}function wx(e,[t,n]){return Math.min(n,Math.max(t,e))}function Tx(e){let t=Ex(e),n=H.forwardRef((e,n)=>{let{children:r,...i}=e,a=H.Children.toArray(r),o=a.find(Ox);if(o){let e=o.props.children,r=a.map(t=>t===o?H.Children.count(e)>1?H.Children.only(null):H.isValidElement(e)?e.props.children:null:t);return(0,Y.jsx)(t,{...i,ref:n,children:H.isValidElement(e)?H.cloneElement(e,void 0,r):null})}return(0,Y.jsx)(t,{...i,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}function Ex(e){let t=H.forwardRef((e,t)=>{let{children:n,...r}=e;if(H.isValidElement(n)){let e=Ax(n),i=kx(r,n.props);return n.type!==H.Fragment&&(i.ref=t?Om(t,e):e),H.cloneElement(n,i)}return H.Children.count(n)>1?H.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Dx=Symbol(`radix.slottable`);function Ox(e){return H.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===Dx}function kx(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function Ax(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function jx(e){let t=e+`CollectionProvider`,[n,r]=$g(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=e=>{let{scope:t,children:n}=e,r=H.useRef(null),a=H.useRef(new Map).current;return(0,Y.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})};o.displayName=t;let s=e+`CollectionSlot`,c=Tx(s),l=H.forwardRef((e,t)=>{let{scope:n,children:r}=e;return(0,Y.jsx)(c,{ref:km(t,a(s,n).collectionRef),children:r})});l.displayName=s;let u=e+`CollectionItemSlot`,d=`data-radix-collection-item`,f=Tx(u),p=H.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=H.useRef(null),s=km(t,o),c=a(u,n);return H.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,Y.jsx)(f,{[d]:``,ref:s,children:r})});p.displayName=u;function m(t){let n=a(e+`CollectionConsumer`,t);return H.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${d}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return[{Provider:o,Slot:l,ItemSlot:p},m,r]}var Mx=H.createContext(void 0);function Nx(e){let t=H.useContext(Mx);return e||t||`ltr`}var Px=[`top`,`right`,`bottom`,`left`],Fx=Math.min,Ix=Math.max,Lx=Math.round,Rx=Math.floor,zx=e=>({x:e,y:e}),Bx={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function Vx(e,t,n){return Ix(e,Fx(t,n))}function Hx(e,t){return typeof e==`function`?e(t):e}function Ux(e){return e.split(`-`)[0]}function Wx(e){return e.split(`-`)[1]}function Gx(e){return e===`x`?`y`:`x`}function Kx(e){return e===`y`?`height`:`width`}function qx(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function Jx(e){return Gx(qx(e))}function Yx(e,t,n){n===void 0&&(n=!1);let r=Wx(e),i=Jx(e),a=Kx(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=iS(o)),[o,iS(o)]}function Xx(e){let t=iS(e);return[Zx(e),t,Zx(t)]}function Zx(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var Qx=[`left`,`right`],$x=[`right`,`left`],eS=[`top`,`bottom`],tS=[`bottom`,`top`];function nS(e,t,n){switch(e){case`top`:case`bottom`:return n?t?$x:Qx:t?Qx:$x;case`left`:case`right`:return t?eS:tS;default:return[]}}function rS(e,t,n,r){let i=Wx(e),a=nS(Ux(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(Zx)))),a}function iS(e){let t=Ux(e);return Bx[t]+e.slice(t.length)}function aS(e){return{top:0,right:0,bottom:0,left:0,...e}}function oS(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:aS(e)}function sS(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function cS(e,t,n){let{reference:r,floating:i}=e,a=qx(t),o=Jx(t),s=Kx(o),c=Ux(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}switch(Wx(t)){case`start`:p[o]-=f*(n&&l?-1:1);break;case`end`:p[o]+=f*(n&&l?-1:1);break}return p}async function lS(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=Hx(t,e),p=oS(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=sS(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=sS(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var uS=50,dS=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:lS},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=cS(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<uS&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=cS(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},fS=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=Hx(e,t)||{};if(l==null)return{};let d=oS(u),f={x:n,y:r},p=Jx(i),m=Kx(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),C=S?S[y]:0;(!C||!await(o.isElement==null?void 0:o.isElement(S)))&&(C=s.floating[y]||a.floating[m]);let w=b/2-x/2,T=C/2-h[m]/2-1,E=Fx(d[_],T),D=Fx(d[v],T),O=E,k=C-h[m]-D,A=C/2-h[m]/2+w,j=Vx(O,A,k),M=!c.arrow&&Wx(i)!=null&&A!==j&&a.reference[m]/2-(A<O?E:D)-h[m]/2<0,N=M?A<O?A-O:A-k:0;return{[p]:f[p]+N,data:{[p]:j,centerOffset:A-j-N,...M&&{alignmentOffset:N}},reset:M}}}),pS=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=Hx(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=Ux(r),_=qx(o),v=Ux(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[iS(o)]:Xx(o)),x=p!==`none`;!d&&x&&b.push(...rS(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=Yx(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(!(u===`alignment`&&_!==qx(t))||T.every(e=>qx(e.placement)===_?e.overflows[0]>0:!0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=qx(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o;break}if(r!==n)return{reset:{placement:n}}}return{}}}};function mS(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function hS(e){return Px.some(t=>e[t]>=0)}var gS=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=Hx(e,t);switch(i){case`referenceHidden`:{let e=mS(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:hS(e)}}}case`escaped`:{let e=mS(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:hS(e)}}}default:return{}}}}},_S=new Set([`left`,`top`]);async function vS(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=Ux(n),s=Wx(n),c=qx(n)===`y`,l=_S.has(o)?-1:1,u=a&&c?-1:1,d=Hx(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var yS=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await vS(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},bS=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=Hx(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=qx(Ux(i)),p=Gx(f),m=u[p],h=u[f];if(o){let e=p===`y`?`top`:`left`,t=p===`y`?`bottom`:`right`,n=m+d[e],r=m-d[t];m=Vx(n,m,r)}if(s){let e=f===`y`?`top`:`left`,t=f===`y`?`bottom`:`right`,n=h+d[e],r=h-d[t];h=Vx(n,h,r)}let g=c.fn({...t,[p]:m,[f]:h});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[p]:o,[f]:s}}}}}},xS=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=Hx(e,t),u={x:n,y:r},d=qx(i),f=Gx(d),p=u[f],m=u[d],h=Hx(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=_S.has(Ux(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},SS=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){var n,r;let{placement:i,rects:a,platform:o,elements:s}=t,{apply:c=()=>{},...l}=Hx(e,t),u=await o.detectOverflow(t,l),d=Ux(i),f=Wx(i),p=qx(i)===`y`,{width:m,height:h}=a.floating,g,_;d===`top`||d===`bottom`?(g=d,_=f===(await(o.isRTL==null?void 0:o.isRTL(s.floating))?`start`:`end`)?`left`:`right`):(_=d,g=f===`end`?`top`:`bottom`);let v=h-u.top-u.bottom,y=m-u.left-u.right,b=Fx(h-u[g],v),x=Fx(m-u[_],y),S=!t.middlewareData.shift,C=b,w=x;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(w=y),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(C=v),S&&!f){let e=Ix(u.left,0),t=Ix(u.right,0),n=Ix(u.top,0),r=Ix(u.bottom,0);p?w=m-2*(e!==0||t!==0?e+t:Ix(u.left,u.right)):C=h-2*(n!==0||r!==0?n+r:Ix(u.top,u.bottom))}await c({...t,availableWidth:w,availableHeight:C});let T=await o.getDimensions(s.floating);return m!==T.width||h!==T.height?{reset:{rects:!0}}:{}}}};function CS(){return typeof window<`u`}function wS(e){return DS(e)?(e.nodeName||``).toLowerCase():`#document`}function TS(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function ES(e){return((DS(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function DS(e){return CS()?e instanceof Node||e instanceof TS(e).Node:!1}function OS(e){return CS()?e instanceof Element||e instanceof TS(e).Element:!1}function kS(e){return CS()?e instanceof HTMLElement||e instanceof TS(e).HTMLElement:!1}function AS(e){return!CS()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof TS(e).ShadowRoot}function jS(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=HS(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function MS(e){return/^(table|td|th)$/.test(wS(e))}function NS(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var PS=/transform|translate|scale|rotate|perspective|filter/,FS=/paint|layout|strict|content/,IS=e=>!!e&&e!==`none`,LS;function RS(e){let t=OS(e)?HS(e):e;return IS(t.transform)||IS(t.translate)||IS(t.scale)||IS(t.rotate)||IS(t.perspective)||!BS()&&(IS(t.backdropFilter)||IS(t.filter))||PS.test(t.willChange||``)||FS.test(t.contain||``)}function zS(e){let t=WS(e);for(;kS(t)&&!VS(t);){if(RS(t))return t;if(NS(t))return null;t=WS(t)}return null}function BS(){return LS??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),LS}function VS(e){return/^(html|body|#document)$/.test(wS(e))}function HS(e){return TS(e).getComputedStyle(e)}function US(e){return OS(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function WS(e){if(wS(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||AS(e)&&e.host||ES(e);return AS(t)?t.host:t}function GS(e){let t=WS(e);return VS(t)?e.ownerDocument?e.ownerDocument.body:e.body:kS(t)&&jS(t)?t:GS(t)}function KS(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=GS(e),i=r===e.ownerDocument?.body,a=TS(r);if(i){let e=qS(a);return t.concat(a,a.visualViewport||[],jS(r)?r:[],e&&n?KS(e):[])}else return t.concat(r,KS(r,[],n))}function qS(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function JS(e){let t=HS(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=kS(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=Lx(n)!==a||Lx(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function YS(e){return OS(e)?e:e.contextElement}function XS(e){let t=YS(e);if(!kS(t))return zx(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=JS(t),o=(a?Lx(n.width):n.width)/r,s=(a?Lx(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var ZS=zx(0);function QS(e){let t=TS(e);return!BS()||!t.visualViewport?ZS:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function $S(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==TS(e)?!1:t}function eC(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=YS(e),o=zx(1);t&&(r?OS(r)&&(o=XS(r)):o=XS(e));let s=$S(a,n,r)?QS(a):zx(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a){let e=TS(a),t=r&&OS(r)?TS(r):r,n=e,i=qS(n);for(;i&&r&&t!==n;){let e=XS(i),t=i.getBoundingClientRect(),r=HS(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=TS(i),i=qS(n)}}return sS({width:u,height:d,x:c,y:l})}function tC(e,t){let n=US(e).scrollLeft;return t?t.left+n:eC(ES(e)).left+n}function nC(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-tC(e,n),y:n.top+t.scrollTop}}function rC(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=ES(r),s=t?NS(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=zx(1),u=zx(0),d=kS(r);if((d||!d&&!a)&&((wS(r)!==`body`||jS(o))&&(c=US(r)),d)){let e=eC(r);l=XS(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?nC(o,c):zx(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function iC(e){return Array.from(e.getClientRects())}function aC(e){let t=ES(e),n=US(e),r=e.ownerDocument.body,i=Ix(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=Ix(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight),o=-n.scrollLeft+tC(e),s=-n.scrollTop;return HS(r).direction===`rtl`&&(o+=Ix(t.clientWidth,r.clientWidth)-i),{width:i,height:a,x:o,y:s}}var oC=25;function sC(e,t){let n=TS(e),r=ES(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;let e=BS();(!e||e&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}let l=tC(r);if(l<=0){let e=r.ownerDocument,t=e.body,n=getComputedStyle(t),i=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,o=Math.abs(r.clientWidth-t.clientWidth-i);o<=oC&&(a-=o)}else l<=oC&&(a+=l);return{width:a,height:o,x:s,y:c}}function cC(e,t){let n=eC(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=kS(e)?XS(e):zx(1);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function lC(e,t,n){let r;if(t===`viewport`)r=sC(e,n);else if(t===`document`)r=aC(ES(e));else if(OS(t))r=cC(t,n);else{let n=QS(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return sS(r)}function uC(e,t){let n=WS(e);return n===t||!OS(n)||VS(n)?!1:HS(n).position===`fixed`||uC(n,t)}function dC(e,t){let n=t.get(e);if(n)return n;let r=KS(e,[],!1).filter(e=>OS(e)&&wS(e)!==`body`),i=null,a=HS(e).position===`fixed`,o=a?WS(e):e;for(;OS(o)&&!VS(o);){let t=HS(o),n=RS(o);!n&&t.position===`fixed`&&(i=null),(a?!n&&!i:!n&&t.position===`static`&&i&&(i.position===`absolute`||i.position===`fixed`)||jS(o)&&!n&&uC(e,o))?r=r.filter(e=>e!==o):i=t,o=WS(o)}return t.set(e,r),r}function fC(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?NS(t)?[]:dC(t,this._c):[].concat(n),r],o=lC(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=lC(t,a[e],i);s=Ix(n.top,s),c=Fx(n.right,c),l=Fx(n.bottom,l),u=Ix(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function pC(e){let{width:t,height:n}=JS(e);return{width:t,height:n}}function mC(e,t,n){let r=kS(t),i=ES(t),a=n===`fixed`,o=eC(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=zx(0);function l(){c.x=tC(i)}if(r||!r&&!a)if((wS(t)!==`body`||jS(i))&&(s=US(t)),r){let e=eC(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}else i&&l();a&&!r&&i&&l();let u=i&&!r&&!a?nC(i,s):zx(0);return{x:o.left+s.scrollLeft-c.x-u.x,y:o.top+s.scrollTop-c.y-u.y,width:o.width,height:o.height}}function hC(e){return HS(e).position===`static`}function gC(e,t){if(!kS(e)||HS(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return ES(e)===n&&(n=n.ownerDocument.body),n}function _C(e,t){let n=TS(e);if(NS(e))return n;if(!kS(e)){let t=WS(e);for(;t&&!VS(t);){if(OS(t)&&!hC(t))return t;t=WS(t)}return n}let r=gC(e,t);for(;r&&MS(r)&&hC(r);)r=gC(r,t);return r&&VS(r)&&hC(r)&&!RS(r)?n:r||zS(e)||n}var vC=async function(e){let t=this.getOffsetParent||_C,n=this.getDimensions,r=await n(e.floating);return{reference:mC(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function yC(e){return HS(e).direction===`rtl`}var bC={convertOffsetParentRelativeRectToViewportRelativeRect:rC,getDocumentElement:ES,getClippingRect:fC,getOffsetParent:_C,getElementRects:vC,getClientRects:iC,getDimensions:pC,getScale:XS,isElement:OS,isRTL:yC};function xC(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function SC(e,t){let n=null,r,i=ES(e);function a(){var e;clearTimeout(r),(e=n)==null||e.disconnect(),n=null}function o(s,c){s===void 0&&(s=!1),c===void 0&&(c=1),a();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(s||t(),!f||!p)return;let m=Rx(d),h=Rx(i.clientWidth-(u+f)),g=Rx(i.clientHeight-(d+p)),_=Rx(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:Ix(0,Fx(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(n!==c){if(!y)return o();n?o(!1,n):r=setTimeout(()=>{o(!1,1e-7)},1e3)}n===1&&!xC(l,e.getBoundingClientRect())&&o(),y=!1}try{n=new IntersectionObserver(b,{...v,root:i.ownerDocument})}catch{n=new IntersectionObserver(b,v)}n.observe(e)}return o(!0),a}function CC(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=YS(e),u=i||a?[...l?KS(l):[],...t?KS(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n,{passive:!0}),a&&e.addEventListener(`resize`,n)});let d=l&&s?SC(l,n):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?eC(e):null;c&&g();function g(){let t=eC(e);h&&!xC(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var wC=yS,TC=bS,EC=pS,DC=SS,OC=gS,kC=fS,AC=xS,jC=(e,t,n)=>{let r=new Map,i={platform:bC,...n},a={...i.platform,_c:r};return dS(e,t,{...i,platform:a})},MC=typeof document<`u`?H.useLayoutEffect:function(){};function NC(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!NC(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!NC(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function PC(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function FC(e,t){let n=PC(e);return Math.round(t*n)/n}function IC(e){let t=H.useRef(e);return MC(()=>{t.current=e}),t}function LC(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=H.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=H.useState(r);NC(f,r)||p(r);let[m,h]=H.useState(null),[g,_]=H.useState(null),v=H.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=H.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=H.useRef(null),C=H.useRef(null),w=H.useRef(u),T=c!=null,E=IC(c),D=IC(i),O=IC(l),k=H.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),jC(S.current,C.current,e).then(e=>{let t={...e,isPositioned:O.current!==!1};A.current&&!NC(w.current,t)&&(w.current=t,sr.flushSync(()=>{d(t)}))})},[f,t,n,D,O]);MC(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let A=H.useRef(!1);MC(()=>(A.current=!0,()=>{A.current=!1}),[]),MC(()=>{if(b&&(S.current=b),x&&(C.current=x),b&&x){if(E.current)return E.current(b,x,k);k()}},[b,x,k,E,T]);let j=H.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),M=H.useMemo(()=>({reference:b,floating:x}),[b,x]),N=H.useMemo(()=>{let e={position:n,left:0,top:0};if(!M.floating)return e;let t=FC(M.floating,u.x),r=FC(M.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...PC(M.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,M.floating,u.x,u.y]);return H.useMemo(()=>({...u,update:k,refs:j,elements:M,floatingStyles:N}),[u,k,j,M,N])}var RC=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:kC({element:r.current,padding:i}).fn(n):r?kC({element:r,padding:i}).fn(n):{}}}},zC=(e,t)=>{let n=wC(e);return{name:n.name,fn:n.fn,options:[e,t]}},BC=(e,t)=>{let n=TC(e);return{name:n.name,fn:n.fn,options:[e,t]}},VC=(e,t)=>({fn:AC(e).fn,options:[e,t]}),HC=(e,t)=>{let n=EC(e);return{name:n.name,fn:n.fn,options:[e,t]}},UC=(e,t)=>{let n=DC(e);return{name:n.name,fn:n.fn,options:[e,t]}},WC=(e,t)=>{let n=OC(e);return{name:n.name,fn:n.fn,options:[e,t]}},GC=(e,t)=>{let n=RC(e);return{name:n.name,fn:n.fn,options:[e,t]}},KC=`Arrow`,qC=H.forwardRef((e,t)=>{let{children:n,width:r=10,height:i=5,...a}=e;return(0,Y.jsx)(h_.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,Y.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})});qC.displayName=KC;var JC=qC;function YC(e){let[t,n]=H.useState(void 0);return t_(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}else n(void 0)},[e]),t}var XC=`Popper`,[ZC,QC]=$g(XC),[$C,ew]=ZC(XC),tw=e=>{let{__scopePopper:t,children:n}=e,[r,i]=H.useState(null);return(0,Y.jsx)($C,{scope:t,anchor:r,onAnchorChange:i,children:n})};tw.displayName=XC;var nw=`PopperAnchor`,rw=H.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...i}=e,a=ew(nw,n),o=H.useRef(null),s=km(t,o),c=H.useRef(null);return H.useEffect(()=>{let e=c.current;c.current=r?.current||o.current,e!==c.current&&a.onAnchorChange(c.current)}),r?null:(0,Y.jsx)(h_.div,{...i,ref:s})});rw.displayName=nw;var iw=`PopperContent`,[aw,ow]=ZC(iw),sw=H.forwardRef((e,t)=>{let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:o=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:u=0,sticky:d=`partial`,hideWhenDetached:f=!1,updatePositionStrategy:p=`optimized`,onPlaced:m,...h}=e,g=ew(iw,n),[_,v]=H.useState(null),y=km(t,e=>v(e)),[b,x]=H.useState(null),S=YC(b),C=S?.width??0,w=S?.height??0,T=r+(a===`center`?``:`-`+a),E=typeof u==`number`?u:{top:0,right:0,bottom:0,left:0,...u},D=Array.isArray(l)?l:[l],O=D.length>0,k={padding:E,boundary:D.filter(dw),altBoundary:O},{refs:A,floatingStyles:j,placement:M,isPositioned:N,middlewareData:P}=LC({strategy:`fixed`,placement:T,whileElementsMounted:(...e)=>CC(...e,{animationFrame:p===`always`}),elements:{reference:g.anchor},middleware:[zC({mainAxis:i+w,alignmentAxis:o}),c&&BC({mainAxis:!0,crossAxis:!1,limiter:d===`partial`?VC():void 0,...k}),c&&HC({...k}),UC({...k,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)}}),b&&GC({element:b,padding:s}),fw({arrowWidth:C,arrowHeight:w}),f&&WC({strategy:`referenceHidden`,...k})]}),[F,I]=pw(M),L=__(m);t_(()=>{N&&L?.()},[N,L]);let R=P.arrow?.x,z=P.arrow?.y,ee=P.arrow?.centerOffset!==0,[te,B]=H.useState();return t_(()=>{_&&B(window.getComputedStyle(_).zIndex)},[_]),(0,Y.jsx)(`div`,{ref:A.setFloating,"data-radix-popper-content-wrapper":``,style:{...j,transform:N?j.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:te,"--radix-popper-transform-origin":[P.transformOrigin?.x,P.transformOrigin?.y].join(` `),...P.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,Y.jsx)(aw,{scope:n,placedSide:F,onArrowChange:x,arrowX:R,arrowY:z,shouldHideArrow:ee,children:(0,Y.jsx)(h_.div,{"data-side":F,"data-align":I,...h,ref:y,style:{...h.style,animation:N?void 0:`none`}})})})});sw.displayName=iw;var cw=`PopperArrow`,lw={top:`bottom`,right:`left`,bottom:`top`,left:`right`},uw=H.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=ow(cw,n),a=lw[i.placedSide];return(0,Y.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,Y.jsx)(JC,{...r,ref:t,style:{...r.style,display:`block`}})})});uw.displayName=cw;function dw(e){return e!==null}var fw=e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=pw(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}});function pw(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var mw=tw,hw=rw,gw=sw,_w=uw;function vw(e){let t=yw(e),n=H.forwardRef((e,n)=>{let{children:r,...i}=e,a=H.Children.toArray(r),o=a.find(xw);if(o){let e=o.props.children,r=a.map(t=>t===o?H.Children.count(e)>1?H.Children.only(null):H.isValidElement(e)?e.props.children:null:t);return(0,Y.jsx)(t,{...i,ref:n,children:H.isValidElement(e)?H.cloneElement(e,void 0,r):null})}return(0,Y.jsx)(t,{...i,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}function yw(e){let t=H.forwardRef((e,t)=>{let{children:n,...r}=e;if(H.isValidElement(n)){let e=Cw(n),i=Sw(r,n.props);return n.type!==H.Fragment&&(i.ref=t?Om(t,e):e),H.cloneElement(n,i)}return H.Children.count(n)>1?H.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var bw=Symbol(`radix.slottable`);function xw(e){return H.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===bw}function Sw(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function Cw(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function ww(e){let t=H.useRef({value:e,previous:e});return H.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Tw=Object.freeze({position:`absolute`,border:0,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,wordWrap:`normal`}),Ew=`VisuallyHidden`,Dw=H.forwardRef((e,t)=>(0,Y.jsx)(h_.span,{...e,ref:t,style:{...Tw,...e.style}}));Dw.displayName=Ew;var Cee=Dw,wee=[` `,`Enter`,`ArrowUp`,`ArrowDown`],Tee=[` `,`Enter`],Ow=`Select`,[kw,Aw,Eee]=jx(Ow),[jw,Dee]=$g(Ow,[Eee,QC]),Mw=QC(),[Oee,Nw]=jw(Ow),[kee,Aee]=jw(Ow),Pw=e=>{let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:c,dir:l,name:u,autoComplete:d,disabled:f,required:p,form:m}=e,h=Mw(t),[g,_]=H.useState(null),[v,y]=H.useState(null),[b,x]=H.useState(!1),S=Nx(l),[C,w]=o_({prop:r,defaultProp:i??!1,onChange:a,caller:Ow}),[T,E]=o_({prop:o,defaultProp:s,onChange:c,caller:Ow}),D=H.useRef(null),O=g?m||!!g.closest(`form`):!0,[k,A]=H.useState(new Set),j=Array.from(k).map(e=>e.props.value).join(`;`);return(0,Y.jsx)(mw,{...h,children:(0,Y.jsxs)(Oee,{required:p,scope:t,trigger:g,onTriggerChange:_,valueNode:v,onValueNodeChange:y,valueNodeHasChildren:b,onValueNodeHasChildrenChange:x,contentId:i_(),value:T,onValueChange:E,open:C,onOpenChange:w,dir:S,triggerPointerDownPosRef:D,disabled:f,children:[(0,Y.jsx)(kw.Provider,{scope:t,children:(0,Y.jsx)(kee,{scope:e.__scopeSelect,onNativeOptionAdd:H.useCallback(e=>{A(t=>new Set(t).add(e))},[]),onNativeOptionRemove:H.useCallback(e=>{A(t=>{let n=new Set(t);return n.delete(e),n})},[]),children:n})}),O?(0,Y.jsxs)(ST,{"aria-hidden":!0,required:p,tabIndex:-1,name:u,autoComplete:d,value:T,onChange:e=>E(e.target.value),disabled:f,form:m,children:[T===void 0?(0,Y.jsx)(`option`,{value:``}):null,Array.from(k)]},j):null]})})};Pw.displayName=Ow;var Fw=`SelectTrigger`,Iw=H.forwardRef((e,t)=>{let{__scopeSelect:n,disabled:r=!1,...i}=e,a=Mw(n),o=Nw(Fw,n),s=o.disabled||r,c=km(t,o.onTriggerChange),l=Aw(n),u=H.useRef(`touch`),[d,f,p]=wT(e=>{let t=l().filter(e=>!e.disabled),n=TT(t,e,t.find(e=>e.value===o.value));n!==void 0&&o.onValueChange(n.value)}),m=e=>{s||(o.onOpenChange(!0),p()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return(0,Y.jsx)(hw,{asChild:!0,...a,children:(0,Y.jsx)(h_.button,{type:`button`,role:`combobox`,"aria-controls":o.contentId,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":`none`,dir:o.dir,"data-state":o.open?`open`:`closed`,disabled:s,"data-disabled":s?``:void 0,"data-placeholder":CT(o.value)?``:void 0,...i,ref:c,onClick:Zg(i.onClick,e=>{e.currentTarget.focus(),u.current!==`mouse`&&m(e)}),onPointerDown:Zg(i.onPointerDown,e=>{u.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(m(e),e.preventDefault())}),onKeyDown:Zg(i.onKeyDown,e=>{let t=d.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&f(e.key),!(t&&e.key===` `)&&wee.includes(e.key)&&(m(),e.preventDefault())})})})});Iw.displayName=Fw;var Lw=`SelectValue`,Rw=H.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...s}=e,c=Nw(Lw,n),{onValueNodeHasChildrenChange:l}=c,u=a!==void 0,d=km(t,c.onValueNodeChange);return t_(()=>{l(u)},[l,u]),(0,Y.jsx)(h_.span,{...s,ref:d,style:{pointerEvents:`none`},children:CT(c.value)?(0,Y.jsx)(Y.Fragment,{children:o}):a})});Rw.displayName=Lw;var jee=`SelectIcon`,zw=H.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,...i}=e;return(0,Y.jsx)(h_.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})});zw.displayName=jee;var Mee=`SelectPortal`,Bw=e=>(0,Y.jsx)(Y_,{asChild:!0,...e});Bw.displayName=Mee;var Vw=`SelectContent`,Hw=H.forwardRef((e,t)=>{let n=Nw(Vw,e.__scopeSelect),[r,i]=H.useState();if(t_(()=>{i(new DocumentFragment)},[]),!n.open){let t=r;return t?sr.createPortal((0,Y.jsx)(Ww,{scope:e.__scopeSelect,children:(0,Y.jsx)(kw.Slot,{scope:e.__scopeSelect,children:(0,Y.jsx)(`div`,{children:e.children})})}),t):null}return(0,Y.jsx)(Kw,{...e,ref:t})});Hw.displayName=Vw;var Uw=10,[Ww,Gw]=jw(Vw),Nee=`SelectContentImpl`,Pee=vw(`SelectContent.RemoveScroll`),Kw=H.forwardRef((e,t)=>{let{__scopeSelect:n,position:r=`item-aligned`,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g,..._}=e,v=Nw(Vw,n),[y,b]=H.useState(null),[x,S]=H.useState(null),C=km(t,e=>b(e)),[w,T]=H.useState(null),[E,D]=H.useState(null),O=Aw(n),[k,A]=H.useState(!1),j=H.useRef(!1);H.useEffect(()=>{if(y)return xy(y)},[y]),nv();let M=H.useCallback(e=>{let[t,...n]=O().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&x&&(x.scrollTop=0),n===r&&x&&(x.scrollTop=x.scrollHeight),n?.focus(),document.activeElement!==i))return},[O,x]),N=H.useCallback(()=>M([w,y]),[M,w,y]);H.useEffect(()=>{k&&N()},[k,N]);let{onOpenChange:P,triggerPointerDownPosRef:F}=v;H.useEffect(()=>{if(y){let e={x:0,y:0},t=t=>{e={x:Math.abs(Math.round(t.pageX)-(F.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(F.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():y.contains(n.target)||P(!1),document.removeEventListener(`pointermove`,t),F.current=null};return F.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[y,P,F]),H.useEffect(()=>{let e=()=>P(!1);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[P]);let[I,L]=wT(e=>{let t=O().filter(e=>!e.disabled),n=TT(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current.focus())}),R=H.useCallback((e,t,n)=>{let r=!j.current&&!n;(v.value!==void 0&&v.value===t||r)&&(T(e),r&&(j.current=!0))},[v.value]),z=H.useCallback(()=>y?.focus(),[y]),ee=H.useCallback((e,t,n)=>{let r=!j.current&&!n;(v.value!==void 0&&v.value===t||r)&&D(e)},[v.value]),te=r===`popper`?Jw:qw,B=te===Jw?{side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g}:{};return(0,Y.jsx)(Ww,{scope:n,content:y,viewport:x,onViewportChange:S,itemRefCallback:R,selectedItem:w,onItemLeave:z,itemTextRefCallback:ee,focusSelectedItem:N,selectedItemText:E,position:r,isPositioned:k,searchRef:I,children:(0,Y.jsx)(fy,{as:Pee,allowPinchZoom:!0,children:(0,Y.jsx)(I_,{asChild:!0,trapped:v.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:Zg(i,e=>{v.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,Y.jsx)(T_,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:(0,Y.jsx)(te,{role:`listbox`,id:v.contentId,"data-state":v.open?`open`:`closed`,dir:v.dir,onContextMenu:e=>e.preventDefault(),..._,...B,onPlaced:()=>A(!0),ref:C,style:{display:`flex`,flexDirection:`column`,outline:`none`,..._.style},onKeyDown:Zg(_.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&L(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=O().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>M(t)),e.preventDefault()}})})})})})})});Kw.displayName=Nee;var Fee=`SelectItemAlignedPosition`,qw=H.forwardRef((e,t)=>{let{__scopeSelect:n,onPlaced:r,...i}=e,a=Nw(Vw,n),o=Gw(Vw,n),[s,c]=H.useState(null),[l,u]=H.useState(null),d=km(t,e=>u(e)),f=Aw(n),p=H.useRef(!1),m=H.useRef(!0),{viewport:h,selectedItem:g,selectedItemText:_,focusSelectedItem:v}=o,y=H.useCallback(()=>{if(a.trigger&&a.valueNode&&s&&l&&h&&g&&_){let e=a.trigger.getBoundingClientRect(),t=l.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=_.getBoundingClientRect();if(a.dir!==`rtl`){let r=i.left-t.left,a=n.left-r,o=e.left-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-Uw,d=wx(a,[Uw,Math.max(Uw,u-l)]);s.style.minWidth=c+`px`,s.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-Uw,d=wx(a,[Uw,Math.max(Uw,u-l)]);s.style.minWidth=c+`px`,s.style.right=d+`px`}let o=f(),c=window.innerHeight-Uw*2,u=h.scrollHeight,d=window.getComputedStyle(l),m=parseInt(d.borderTopWidth,10),v=parseInt(d.paddingTop,10),y=parseInt(d.borderBottomWidth,10),b=parseInt(d.paddingBottom,10),x=m+v+u+b+y,S=Math.min(g.offsetHeight*5,x),C=window.getComputedStyle(h),w=parseInt(C.paddingTop,10),T=parseInt(C.paddingBottom,10),E=e.top+e.height/2-Uw,D=c-E,O=g.offsetHeight/2,k=g.offsetTop+O,A=m+v+k,j=x-A;if(A<=E){let e=o.length>0&&g===o[o.length-1].ref.current;s.style.bottom=`0px`;let t=l.clientHeight-h.offsetTop-h.offsetHeight,n=A+Math.max(D,O+(e?T:0)+t+y);s.style.height=n+`px`}else{let e=o.length>0&&g===o[0].ref.current;s.style.top=`0px`;let t=Math.max(E,m+h.offsetTop+(e?w:0)+O)+j;s.style.height=t+`px`,h.scrollTop=A-E+h.offsetTop}s.style.margin=`${Uw}px 0`,s.style.minHeight=S+`px`,s.style.maxHeight=c+`px`,r?.(),requestAnimationFrame(()=>p.current=!0)}},[f,a.trigger,a.valueNode,s,l,h,g,_,a.dir,r]);t_(()=>y(),[y]);let[b,x]=H.useState();return t_(()=>{l&&x(window.getComputedStyle(l).zIndex)},[l]),(0,Y.jsx)(Lee,{scope:n,contentWrapper:s,shouldExpandOnScrollRef:p,onScrollButtonChange:H.useCallback(e=>{e&&m.current===!0&&(y(),v?.(),m.current=!1)},[y,v]),children:(0,Y.jsx)(`div`,{ref:c,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:b},children:(0,Y.jsx)(h_.div,{...i,ref:d,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})});qw.displayName=Fee;var Iee=`SelectPopperPosition`,Jw=H.forwardRef((e,t)=>{let{__scopeSelect:n,align:r=`start`,collisionPadding:i=Uw,...a}=e,o=Mw(n);return(0,Y.jsx)(gw,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})});Jw.displayName=Iee;var[Lee,Yw]=jw(Vw,{}),Xw=`SelectViewport`,Zw=H.forwardRef((e,t)=>{let{__scopeSelect:n,nonce:r,...i}=e,a=Gw(Xw,n),o=Yw(Xw,n),s=km(t,a.onViewportChange),c=H.useRef(0);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,Y.jsx)(kw.Slot,{scope:n,children:(0,Y.jsx)(h_.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:s,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:Zg(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=o;if(r?.current&&n){let e=Math.abs(c.current-t.scrollTop);if(e>0){let r=window.innerHeight-Uw*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}c.current=t.scrollTop})})})]})});Zw.displayName=Xw;var Qw=`SelectGroup`,[$w,eT]=jw(Qw),tT=H.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=i_();return(0,Y.jsx)($w,{scope:n,id:i,children:(0,Y.jsx)(h_.div,{role:`group`,"aria-labelledby":i,...r,ref:t})})});tT.displayName=Qw;var nT=`SelectLabel`,rT=H.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=eT(nT,n);return(0,Y.jsx)(h_.div,{id:i.id,...r,ref:t})});rT.displayName=nT;var iT=`SelectItem`,[aT,oT]=jw(iT),sT=H.forwardRef((e,t)=>{let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=Nw(iT,n),c=Gw(iT,n),l=s.value===r,[u,d]=H.useState(a??``),[f,p]=H.useState(!1),m=km(t,e=>c.itemRefCallback?.(e,r,i)),h=i_(),g=H.useRef(`touch`),_=()=>{i||(s.onValueChange(r),s.onOpenChange(!1))};if(r===``)throw Error(`A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.`);return(0,Y.jsx)(aT,{scope:n,value:r,disabled:i,textId:h,isSelected:l,onItemTextChange:H.useCallback(e=>{d(t=>t||(e?.textContent??``).trim())},[]),children:(0,Y.jsx)(kw.ItemSlot,{scope:n,value:r,disabled:i,textValue:u,children:(0,Y.jsx)(h_.div,{role:`option`,"aria-labelledby":h,"data-highlighted":f?``:void 0,"aria-selected":l&&f,"data-state":l?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...o,ref:m,onFocus:Zg(o.onFocus,()=>p(!0)),onBlur:Zg(o.onBlur,()=>p(!1)),onClick:Zg(o.onClick,()=>{g.current!==`mouse`&&_()}),onPointerUp:Zg(o.onPointerUp,()=>{g.current===`mouse`&&_()}),onPointerDown:Zg(o.onPointerDown,e=>{g.current=e.pointerType}),onPointerMove:Zg(o.onPointerMove,e=>{g.current=e.pointerType,i?c.onItemLeave?.():g.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Zg(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:Zg(o.onKeyDown,e=>{c.searchRef?.current!==``&&e.key===` `||(Tee.includes(e.key)&&_(),e.key===` `&&e.preventDefault())})})})})});sT.displayName=iT;var cT=`SelectItemText`,lT=H.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,...a}=e,o=Nw(cT,n),s=Gw(cT,n),c=oT(cT,n),l=Aee(cT,n),[u,d]=H.useState(null),f=km(t,e=>d(e),c.onItemTextChange,e=>s.itemTextRefCallback?.(e,c.value,c.disabled)),p=u?.textContent,m=H.useMemo(()=>(0,Y.jsx)(`option`,{value:c.value,disabled:c.disabled,children:p},c.value),[c.disabled,c.value,p]),{onNativeOptionAdd:h,onNativeOptionRemove:g}=l;return t_(()=>(h(m),()=>g(m)),[h,g,m]),(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(h_.span,{id:c.textId,...a,ref:f}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren?sr.createPortal(a.children,o.valueNode):null]})});lT.displayName=cT;var uT=`SelectItemIndicator`,dT=H.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return oT(uT,n).isSelected?(0,Y.jsx)(h_.span,{"aria-hidden":!0,...r,ref:t}):null});dT.displayName=uT;var fT=`SelectScrollUpButton`,pT=H.forwardRef((e,t)=>{let n=Gw(fT,e.__scopeSelect),r=Yw(fT,e.__scopeSelect),[i,a]=H.useState(!1),o=km(t,r.onScrollButtonChange);return t_(()=>{if(n.viewport&&n.isPositioned){let e=function(){a(t.scrollTop>0)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,Y.jsx)(gT,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null});pT.displayName=fT;var mT=`SelectScrollDownButton`,hT=H.forwardRef((e,t)=>{let n=Gw(mT,e.__scopeSelect),r=Yw(mT,e.__scopeSelect),[i,a]=H.useState(!1),o=km(t,r.onScrollButtonChange);return t_(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight;a(Math.ceil(t.scrollTop)<e)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,Y.jsx)(gT,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null});hT.displayName=mT;var gT=H.forwardRef((e,t)=>{let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=Gw(`SelectScrollButton`,n),o=H.useRef(null),s=Aw(n),c=H.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return H.useEffect(()=>()=>c(),[c]),t_(()=>{s().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[s]),(0,Y.jsx)(h_.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:Zg(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:Zg(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:Zg(i.onPointerLeave,()=>{c()})})}),_T=`SelectSeparator`,vT=H.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return(0,Y.jsx)(h_.div,{"aria-hidden":!0,...r,ref:t})});vT.displayName=_T;var yT=`SelectArrow`,bT=H.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Mw(n),a=Nw(yT,n),o=Gw(yT,n);return a.open&&o.position===`popper`?(0,Y.jsx)(_w,{...i,...r,ref:t}):null});bT.displayName=yT;var xT=`SelectBubbleInput`,ST=H.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{let i=H.useRef(null),a=km(r,i),o=ww(t);return H.useEffect(()=>{let e=i.current;if(!e)return;let n=window.HTMLSelectElement.prototype,r=Object.getOwnPropertyDescriptor(n,`value`).set;if(o!==t&&r){let n=new Event(`change`,{bubbles:!0});r.call(e,t),e.dispatchEvent(n)}},[o,t]),(0,Y.jsx)(h_.select,{...n,style:{...Tw,...n.style},ref:a,defaultValue:t})});ST.displayName=xT;function CT(e){return e===``||e===void 0}function wT(e){let t=__(e),n=H.useRef(``),r=H.useRef(0),i=H.useCallback(e=>{let i=n.current+e;t(i),(function e(t){n.current=t,window.clearTimeout(r.current),t!==``&&(r.current=window.setTimeout(()=>e(``),1e3))})(i)},[t]),a=H.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return H.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}function TT(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=ET(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function ET(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var DT=Pw,OT=Iw,kT=Rw,AT=zw,jT=Bw,MT=Hw,NT=Zw,PT=rT,FT=sT,IT=lT,LT=dT,RT=pT,zT=hT,BT=vT,VT=DT,HT=kT,UT=H.forwardRef(({className:e,children:t,...n},r)=>(0,Y.jsxs)(OT,{ref:r,className:X(`flex h-8 w-full items-center justify-between rounded-lg border border-input bg-background px-3 py-1 text-xs ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1`,e),...n,children:[t,(0,Y.jsx)(AT,{asChild:!0,children:(0,Y.jsx)(no,{className:`h-3 w-3 opacity-50`})})]}));UT.displayName=OT.displayName;var WT=H.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(RT,{ref:n,className:X(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,Y.jsx)(ao,{className:`h-3 w-3`})}));WT.displayName=RT.displayName;var GT=H.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(zT,{ref:n,className:X(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,Y.jsx)(no,{className:`h-3 w-3`})}));GT.displayName=zT.displayName;var KT=H.forwardRef(({className:e,children:t,position:n=`popper`,...r},i)=>(0,Y.jsx)(jT,{children:(0,Y.jsxs)(MT,{ref:i,className:X(`relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border border-border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,...r,children:[(0,Y.jsx)(WT,{}),(0,Y.jsx)(NT,{className:X(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]`),children:t}),(0,Y.jsx)(GT,{})]})}));KT.displayName=MT.displayName;var qT=H.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(PT,{ref:n,className:X(`py-1.5 pl-8 pr-2 text-xs font-semibold`,e),...t}));qT.displayName=PT.displayName;var JT=H.forwardRef(({className:e,children:t,...n},r)=>(0,Y.jsxs)(FT,{ref:r,className:X(`relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-xs outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,e),...n,children:[(0,Y.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,Y.jsx)(LT,{children:(0,Y.jsx)(to,{className:`h-3 w-3`})})}),(0,Y.jsx)(IT,{children:t})]}));JT.displayName=FT.displayName;var YT=H.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(BT,{ref:n,className:X(`-mx-1 my-1 h-px bg-muted`,e),...t}));YT.displayName=BT.displayName;var XT=Symbol(`radix.slottable`);function ZT(e){let t=({children:e})=>(0,Y.jsx)(Y.Fragment,{children:e});return t.displayName=`${e}.Slottable`,t.__radixId=XT,t}var[QT,Ree]=$g(`Tooltip`,[QC]),$T=QC(),eE=`TooltipProvider`,tE=700,nE=`tooltip.open`,[rE,iE]=QT(eE),aE=e=>{let{__scopeTooltip:t,delayDuration:n=tE,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=H.useRef(!0),s=H.useRef(!1),c=H.useRef(0);return H.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,Y.jsx)(rE,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:H.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:H.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:s,onPointerInTransitChange:H.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})};aE.displayName=eE;var oE=`Tooltip`,[sE,cE]=QT(oE),lE=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=iE(oE,e.__scopeTooltip),l=$T(t),[u,d]=H.useState(null),f=i_(),p=H.useRef(0),m=o??c.disableHoverableContent,h=s??c.delayDuration,g=H.useRef(!1),[_,v]=o_({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(nE))):c.onClose(),a?.(e)},caller:oE}),y=H.useMemo(()=>_?g.current?`delayed-open`:`instant-open`:`closed`,[_]),b=H.useCallback(()=>{window.clearTimeout(p.current),p.current=0,g.current=!1,v(!0)},[v]),x=H.useCallback(()=>{window.clearTimeout(p.current),p.current=0,v(!1)},[v]),S=H.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{g.current=!0,v(!0),p.current=0},h)},[h,v]);return H.useEffect(()=>()=>{p.current&&=(window.clearTimeout(p.current),0)},[]),(0,Y.jsx)(mw,{...l,children:(0,Y.jsx)(sE,{scope:t,contentId:f,open:_,stateAttribute:y,trigger:u,onTriggerChange:d,onTriggerEnter:H.useCallback(()=>{c.isOpenDelayedRef.current?S():b()},[c.isOpenDelayedRef,S,b]),onTriggerLeave:H.useCallback(()=>{m?x():(window.clearTimeout(p.current),p.current=0)},[x,m]),onOpen:b,onClose:x,disableHoverableContent:m,children:n})})};lE.displayName=oE;var uE=`TooltipTrigger`,dE=H.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=cE(uE,n),a=iE(uE,n),o=$T(n),s=km(t,H.useRef(null),i.onTriggerChange),c=H.useRef(!1),l=H.useRef(!1),u=H.useCallback(()=>c.current=!1,[]);return H.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,Y.jsx)(hw,{asChild:!0,...o,children:(0,Y.jsx)(h_.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:Zg(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:Zg(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:Zg(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:Zg(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:Zg(e.onBlur,i.onClose),onClick:Zg(e.onClick,i.onClose)})})});dE.displayName=uE;var fE=`TooltipPortal`,[pE,mE]=QT(fE,{forceMount:void 0}),hE=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=cE(fE,t);return(0,Y.jsx)(pE,{scope:t,forceMount:n,children:(0,Y.jsx)(Z_,{present:n||a.open,children:(0,Y.jsx)(Y_,{asChild:!0,container:i,children:r})})})};hE.displayName=fE;var gE=`TooltipContent`,_E=H.forwardRef((e,t)=>{let n=mE(gE,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=cE(gE,e.__scopeTooltip);return(0,Y.jsx)(Z_,{present:r||o.open,children:o.disableHoverableContent?(0,Y.jsx)(SE,{side:i,...a,ref:t}):(0,Y.jsx)(vE,{side:i,...a,ref:t})})}),vE=H.forwardRef((e,t)=>{let n=cE(gE,e.__scopeTooltip),r=iE(gE,e.__scopeTooltip),i=H.useRef(null),a=km(t,i),[o,s]=H.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=H.useCallback(()=>{s(null),d(!1)},[d]),p=H.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=EE(r,TE(r,n.getBoundingClientRect())),a=DE(t.getBoundingClientRect());s(kE([...i,...a])),d(!0)},[d]);return H.useEffect(()=>()=>f(),[f]),H.useEffect(()=>{if(c&&u){let e=e=>p(e,u),t=e=>p(e,c);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),H.useEffect(()=>{if(o){let e=e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!OE(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,Y.jsx)(SE,{...e,ref:a})}),[yE,bE]=QT(oE,{isInside:!1}),xE=ZT(`TooltipContent`),SE=H.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=cE(gE,n),l=$T(n),{onClose:u}=c;return H.useEffect(()=>(document.addEventListener(nE,u),()=>document.removeEventListener(nE,u)),[u]),H.useEffect(()=>{if(c.trigger){let e=e=>{e.target?.contains(c.trigger)&&u()};return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[c.trigger,u]),(0,Y.jsx)(T_,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,Y.jsxs)(gw,{"data-state":c.stateAttribute,...l,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,Y.jsx)(xE,{children:r}),(0,Y.jsx)(yE,{scope:n,isInside:!0,children:(0,Y.jsx)(Cee,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});_E.displayName=gE;var CE=`TooltipArrow`,wE=H.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=$T(n);return bE(CE,n).isInside?null:(0,Y.jsx)(_w,{...i,...r,ref:t})});wE.displayName=CE;function TE(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}function EE(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function DE(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function OE(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function kE(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:+(e.y>t.y)),AE(t)}function AE(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var jE=aE,ME=lE,NE=dE,PE=_E,FE=jE,IE=ME,LE=NE,RE=H.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,Y.jsx)(PE,{ref:r,sideOffset:t,className:X(`z-50 overflow-hidden rounded-md border border-border bg-popover px-2.5 py-1.5 text-xs text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...n}));RE.displayName=PE.displayName;var zE={default:`sortControl.modes.default`,"ticket-id":`sortControl.modes.ticketId`,priority:`sortControl.modes.priority`,"jira-key":`sortControl.modes.jiraKey`};function BE({mode:e,dir:t,onChange:n,showJiraSort:r=!1,className:i}){let{t:a}=K(`specs`),o=e!==`default`;return(0,Y.jsx)(FE,{delayDuration:300,children:(0,Y.jsxs)(`div`,{className:X(`flex items-center gap-1 shrink-0`,i),children:[(0,Y.jsxs)(IE,{children:[(0,Y.jsx)(LE,{asChild:!0,children:(0,Y.jsx)(`div`,{children:(0,Y.jsxs)(VT,{value:e,onValueChange:e=>n(e,t),children:[(0,Y.jsxs)(UT,{"aria-label":a(`sortControl.modeAriaLabel`),className:`h-7 w-auto gap-1.5 px-2 text-xs bg-accent-secondary/10 border-accent-secondary/30 hover:bg-accent-secondary/20`,children:[(0,Y.jsx)(Ra,{className:`w-3 h-3 text-muted-foreground`}),(0,Y.jsx)(HT,{children:a(zE[e])})]}),(0,Y.jsxs)(KT,{children:[(0,Y.jsx)(JT,{value:`default`,children:a(`sortControl.modes.default`)}),(0,Y.jsx)(JT,{value:`ticket-id`,children:a(`sortControl.modes.ticketId`)}),(0,Y.jsx)(JT,{value:`priority`,children:a(`sortControl.modes.priority`)}),(r||e===`jira-key`)&&(0,Y.jsx)(JT,{value:`jira-key`,children:a(`sortControl.modes.jiraKey`)})]})]})})}),(0,Y.jsx)(RE,{children:a(`sortControl.tooltip`,{mode:a(zE[e])})})]}),o&&(0,Y.jsxs)(IE,{children:[(0,Y.jsx)(LE,{asChild:!0,children:(0,Y.jsx)(`button`,{type:`button`,"aria-label":a(`sortControl.toggleDirAriaLabel`),onClick:()=>n(e,t===`asc`?`desc`:`asc`),className:`inline-flex items-center justify-center h-7 w-7 rounded-md border border-accent-secondary/30 bg-accent-secondary/10 hover:bg-accent-secondary/20 text-muted-foreground transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2`,children:t===`asc`?(0,Y.jsx)(Ua,{className:`w-3 h-3`}):(0,Y.jsx)(za,{className:`w-3 h-3`})})}),(0,Y.jsx)(RE,{children:a(t===`asc`?`sortControl.ascending`:`sortControl.descending`)})]})]})})}var VE=[{value:`row`,Icon:ss,labelKey:`viewTier.listView`},{value:`postit`,Icon:nc,labelKey:`viewTier.postitView`}];function HE({tier:e,onChange:t,className:n}){let{t:r}=K(`specs`);return(0,Y.jsx)(FE,{delayDuration:300,children:(0,Y.jsx)(`div`,{role:`radiogroup`,"aria-label":r(`viewTier.ariaLabel`),className:X(`inline-flex items-center rounded-md border border-accent-secondary/30 bg-accent-secondary/10 p-0.5 shrink-0`,n),children:VE.map(({value:n,Icon:i,labelKey:a})=>{let o=e===n;return(0,Y.jsxs)(IE,{children:[(0,Y.jsx)(LE,{asChild:!0,children:(0,Y.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":o,"aria-label":r(a),onClick:()=>t(n),className:X(`inline-flex items-center justify-center h-6 w-6 rounded transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-1`,o?`bg-accent-secondary/40 text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent-secondary/20`),"data-testid":`specs-view-tier-${n}`,children:(0,Y.jsx)(i,{className:`w-3.5 h-3.5`})})}),(0,Y.jsx)(RE,{children:r(a)})]},n)})})})}var UE=`default`,WE=`desc`,GE=e=>`specrails-desktop:spec-sort-mode:${e}`,KE=e=>`specrails-desktop:spec-sort-dir:${e}`;function qE(e){return e===`default`||e===`ticket-id`||e===`priority`||e===`jira-key`}function JE(e){return e===`asc`||e===`desc`}function YE(e){if(!e)return{mode:UE,dir:WE};let t=UE,n=WE;try{let n=localStorage.getItem(GE(e));qE(n)&&(t=n)}catch{}try{let t=localStorage.getItem(KE(e));JE(t)&&(n=t)}catch{}return{mode:t,dir:n}}function XE(e,t,n){if(e)try{localStorage.setItem(GE(e),t),localStorage.setItem(KE(e),n)}catch{}}var ZE={critical:4,high:3,medium:2,low:1,null:0};function QE(e){return e===null?ZE.null:ZE[e]}function $E(e,t,n){return n===`asc`?e.id-t.id:t.id-e.id}function eD(e,t,n){let r=QE(e.priority),i=QE(t.priority),a=n===`asc`?r-i:i-r;return a===0?e.id-t.id:a}function tD(e){let t=e.jira_key;if(!t)return null;let n=/(\d+)\s*$/.exec(t);if(!n)return null;let r=Number.parseInt(n[1],10);return Number.isSafeInteger(r)?r:null}function nD(e,t,n){let r=tD(e),i=tD(t);if(r===null&&i===null)return e.id-t.id;if(r===null)return 1;if(i===null)return-1;let a=n===`asc`?r-i:i-r;return a===0?e.id-t.id:a}function rD(e,t,n){return t===`ticket-id`?[...e].sort((e,t)=>$E(e,t,n)):t===`priority`?[...e].sort((e,t)=>eD(e,t,n)):t===`jira-key`?[...e].sort((e,t)=>nD(e,t,n)):e}var iD=e=>`specrails-desktop:spec-filters:${e}`;function aD(e){return e.labels.size===0&&e.epic===null&&e.sprint===null&&e.jiraStatus===null}function oD(e){return typeof e==`string`&&e.length>0?e:null}function sD(){return{labels:new Set,epic:null,sprint:null,jiraStatus:null}}function cD(e){if(!e)return sD();try{let t=localStorage.getItem(iD(e));if(!t)return sD();let n=JSON.parse(t);if(!n||typeof n!=`object`)return sD();let r=n;return{labels:Array.isArray(r.labels)?new Set(r.labels.filter(e=>typeof e==`string`)):new Set,epic:oD(r.epic),sprint:oD(r.sprint),jiraStatus:oD(r.jiraStatus)}}catch{return sD()}}function lD(e,t){if(e)try{if(aD(t)){localStorage.removeItem(iD(e));return}localStorage.setItem(iD(e),JSON.stringify({labels:[...t.labels],epic:t.epic,sprint:t.sprint,jiraStatus:t.jiraStatus}))}catch{}}function uD(e){let t=Math.floor(e/1e3),n=Math.floor(t/60);return n>0?`${n}:${(t%60).toString().padStart(2,`0`)}`:`${t}s`}var dD=`specrails-desktop:pending-specs`;function fD(){try{return JSON.parse(localStorage.getItem(dD)??`[]`)}catch{return[]}}function pD(e){try{let t=fD().filter(t=>t.id!==e.id);t.push(e),localStorage.setItem(dD,JSON.stringify(t))}catch{}}function mD(e){try{let t=fD().filter(t=>t.id!==e);localStorage.setItem(dD,JSON.stringify(t))}catch{}}var hD=(0,H.createContext)(null),gD=40,_D=3e3;function vD({children:e}){let{registerHandler:t,unregisterHandler:n}=df(),{setActiveProjectId:r}=gm(),i=_t(),[a,s]=(0,H.useState)(null),c=(0,H.useRef)(new Map),l=(0,H.useRef)(new Map),u=(0,H.useRef)(new Set),d=(0,H.useRef)(null),{activeProjectId:f}=gm();(0,H.useEffect)(()=>{d.current=f},[f]);let p=(0,H.useCallback)(e=>{e.timerId=setInterval(()=>{q.loading(`${e.projectName} · ${e.truncated}`,{id:e.toastId,description:am.t(`activity:specGen.generating`,{elapsed:uD(Date.now()-e.startTime)})})},1e3)},[]),m=(0,H.useCallback)(e=>{clearInterval(e.timerId),mD(e.persistId),bm(e.projectId)},[]),h=(0,H.useCallback)((e,t)=>{e.projectId===d.current?(s({ticket:t,projectId:e.projectId}),window.location.pathname!==`/`&&i(`/`)):(yc(e.projectId,`/`),s({ticket:t,projectId:e.projectId}),r(e.projectId))},[r,i]),g=(0,H.useRef)(h);(0,H.useEffect)(()=>{g.current=h},[h]);let _=(0,H.useCallback)((e,t)=>{m(e);let n=uD(Date.now()-e.startTime);q.success(`${e.projectName} · ${t.title||am.t(`activity:specGen.specCreated`)}`,{id:e.toastId,duration:1e4,description:am.t(`activity:specGen.generatedIn`,{elapsed:n}),action:{label:am.t(`activity:specGen.view`),onClick:()=>h(e,t)}})},[m,h]),v=(0,H.useCallback)((e,t)=>{m(e),q.error(`${e.projectName} · ${t??am.t(`activity:specGen.errorGenerating`)}`,{id:e.toastId})},[m]),y=(0,H.useCallback)((e,t)=>{let n=0;async function r(){try{let n=await fetch(`${o}/api/projects/${e.projectId}/tickets`);if(!n.ok)throw Error(`fetch failed`);let r=await n.json(),i=(Array.isArray(r)?r:r.tickets??[]).find(t=>!e.knownTicketIds.has(t.id));if(i){t&&l.current.delete(t),_(e,i);return}}catch{}n++,n<5?setTimeout(r,1e3):(t&&l.current.delete(t),v(e,am.t(`activity:specGen.couldNotFind`)))}r()},[_,v]),b=(0,H.useCallback)(e=>{let t={...e,timerId:0};return u.current.add(e.persistId),ym(e.projectId),p(t),pD({id:e.persistId,knownTicketIds:[...e.knownTicketIds],projectId:e.projectId,projectName:e.projectName,startTime:e.startTime,truncated:e.truncated}),t},[p]),x=(0,H.useCallback)((e,t)=>{let n=b(t);c.current.set(e,n)},[b]),S=(0,H.useCallback)((e,t)=>{let n=b(t);l.current.set(e,n)},[b]),C=(0,H.useCallback)(e=>{let t=e;if(!t||typeof t.type!=`string`||t.type!==`spec_gen_done`&&t.type!==`spec_gen_error`)return;let n=t.requestId;if(!n)return;let r=c.current.get(n);r&&(c.current.delete(n),t.type===`spec_gen_done`?_(r,t.ticket):v(r))},[_,v]),w=(0,H.useCallback)(e=>{let t=e;if(!t||typeof t.type!=`string`)return;let n=t.conversationId;if(!n)return;let r=l.current.get(n);if(r){if(t.type===`chat_error`){l.current.delete(n),v(r);return}t.type===`chat_done`&&y(r,n)}},[y,v]),T=(0,H.useCallback)(e=>{let t=e;if(!t||typeof t.type!=`string`||t.type!==`ticket_created`&&t.type!==`ticket_updated`)return;let n=t.ticket;if(!n)return;let r=t.projectId;for(let[e,t]of l.current.entries())r&&t.projectId!==r||t.knownTicketIds.has(n.id)||y(t,e)},[y]);(0,H.useLayoutEffect)(()=>(t(`_tracker_spec_gen`,C),t(`_tracker_chat_done`,w),t(`_tracker_tickets`,T),()=>{n(`_tracker_spec_gen`),n(`_tracker_chat_done`),n(`_tracker_tickets`)}),[C,w,T,t,n]),(0,H.useEffect)(()=>{let e=fD();if(e.length!==0)for(let t of e){if(u.current.has(t.id))continue;u.current.add(t.id);let e=`spec-restore-${t.id}`,n=new Set(t.knownTicketIds),r=()=>{q.loading(`${t.projectName} · ${t.truncated}`,{id:e,description:am.t(`activity:specGen.generating`,{elapsed:uD(Date.now()-t.startTime)})})};r();let i=setInterval(r,1e3);ym(t.projectId);let a=0,s={toastId:e,truncated:t.truncated,knownTicketIds:n,projectId:t.projectId,projectName:t.projectName,startTime:t.startTime,persistId:t.id,timerId:i};async function c(){try{let r=await fetch(`${o}/api/projects/${t.projectId}/tickets`);if(!r.ok)throw Error();let a=await r.json(),c=(Array.isArray(a)?a:a.tickets??[]).find(e=>!n.has(e.id));if(c){clearInterval(i),mD(t.id),bm(t.projectId);let n=uD(Date.now()-t.startTime);q.success(`${t.projectName} · ${c.title||am.t(`activity:specGen.specCreated`)}`,{id:e,duration:1e4,description:am.t(`activity:specGen.generatedIn`,{elapsed:n}),action:{label:am.t(`activity:specGen.view`),onClick:()=>g.current(s,c)}});return}}catch{}a++,a<gD?setTimeout(c,_D):(clearInterval(i),mD(t.id),bm(t.projectId),q.error(`${t.projectName} · ${am.t(`activity:specGen.couldNotConfirm`)}`,{id:e}))}c()}},[]);let E=(0,H.useCallback)(()=>s(null),[]),D=(0,H.useMemo)(()=>({registerFastSpec:x,registerExploreSpec:S,specToOpen:a,clearSpecToOpen:E}),[x,S,a,E]);return(0,Y.jsx)(hD.Provider,{value:D,children:e})}var yD={registerFastSpec:()=>{},registerExploreSpec:()=>{},specToOpen:null,clearSpecToOpen:()=>{}};function bD(){return(0,H.useContext)(hD)??yD}async function xD(e,t,n){let r=new FormData;r.append(`file`,t);let i=await fetch(`${af()}/tickets/${e}/attachments`,{method:`POST`,body:r,signal:n});if(!i.ok){let e=await i.json().catch(()=>({}));throw Error(e.error??am.t(`attachments:errors.uploadFailed`,{status:i.status}))}return(await i.json()).attachment}async function SD(e,t){let n=await fetch(`${af()}/tickets/${e}/attachments/${t}`,{method:`DELETE`});if(!n.ok&&n.status!==404)throw Error(am.t(`attachments:errors.deleteFailed`,{status:n.status}))}async function CD(e){let t=await fetch(`${af()}/tickets/${e}/attachments`,{method:`DELETE`});if(!t.ok&&t.status!==404)throw Error(am.t(`attachments:errors.bulkDeleteFailed`,{status:t.status}))}async function wD(e){let t=await fetch(`${af()}/tickets/${e}/attachments`);if(!t.ok)throw Error(am.t(`attachments:errors.listFailed`,{status:t.status}));return(await t.json()).attachments}function TD(e,t){return`${af()}/tickets/${e}/attachments/${t}`}async function ED(e,t){let n=await fetch(TD(e,t));if(!n.ok)throw Error(am.t(`attachments:errors.fetchFailed`,{status:n.status}));return n.blob()}var DD=`image/jpeg,image/png,image/gif,image/webp,application/pdf,text/csv,text/plain,application/json,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel,application/sql,application/x-sql,text/sql,text/x-sql,.sql`,OD=new Set(DD.split(`,`).filter(e=>!e.startsWith(`.`))),kD=/\.sql$/i,AD=/\.(png|jpe?g|gif|webp)$/i;function jD(e){return OD.has(e.type)||kD.test(e.name)||AD.test(e.name)}function MD(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function ND(e){return e.startsWith(`image/`)?`🖼`:e===`application/pdf`?`📄`:e===`text/csv`||e.includes(`spreadsheetml`)||e===`application/vnd.ms-excel`?`📊`:e===`application/json`?`{ }`:e===`text/plain`||e.includes(`sql`)?`📝`:`📎`}function PD({attachment:e,uploading:t,onRemove:n,onClick:r,index:i=0,className:a}){let{t:o}=K(`attachments`),[s,c]=(0,H.useState)(!1),[l,u]=(0,H.useState)(!1);(0,H.useEffect)(()=>{let e=Math.min(i*50,250),t=setTimeout(()=>c(!0),e);return()=>clearTimeout(t)},[i]);let d=e?.filename??t?.name??o(`chip.genericFile`),f=e?.mimeType??`application/octet-stream`,p=t?o(`chip.uploading`):e?MD(e.size):``;function m(e){e.stopPropagation(),u(!0),setTimeout(()=>n?.(),180)}return(0,Y.jsxs)(`div`,{role:r?`button`:void 0,tabIndex:r?0:void 0,onClick:r,onKeyDown:e=>r&&e.key===`Enter`&&r(),className:X(`group/chip relative inline-flex items-center gap-2 pl-2 pr-1 py-1.5 rounded-lg border border-border bg-card/70 backdrop-blur-sm text-xs shadow-sm`,`transition-all duration-200 ease-out origin-left`,s&&!l?`opacity-100 scale-100 translate-y-0`:`opacity-0 scale-[0.85] translate-y-1`,l&&`max-w-0 overflow-hidden pl-0 pr-0 py-0 border-transparent ml-0 mr-0`,r&&`cursor-pointer hover:border-primary/50`,t&&`animate-pulse`,a),style:l?{maxWidth:0}:void 0,children:[(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`text-sm leading-none shrink-0 w-5 text-center`,children:ND(f)}),(0,Y.jsxs)(`div`,{className:`flex flex-col min-w-0 mr-1`,children:[(0,Y.jsx)(`span`,{className:`font-medium truncate max-w-[160px] text-foreground`,children:d}),(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground leading-tight`,children:p})]}),n&&!t&&(0,Y.jsx)(`button`,{type:`button`,onClick:m,"aria-label":o(`removeFile`,{name:d}),className:`ml-0.5 w-5 h-5 inline-flex items-center justify-center rounded text-muted-foreground hover:text-destructive hover:bg-destructive/10 transition-colors`,children:`×`})]})}function FD(e){let t=[];for(let n=0;n<e.files.length;n++){let r=e.files.item(n);r&&t.push(r)}return t}function ID(e){return`paste-${new Date().toISOString().slice(0,10)}-${e}.png`}function LD(e){let t=document.createElement(`span`);t.setAttribute(`contenteditable`,`false`),t.dataset.attachmentId=e.id,t.dataset.filename=e.filename,t.className=`inline-flex items-center gap-1 px-1.5 py-0.5 mx-0.5 rounded bg-accent/80 hover:bg-accent text-accent-foreground text-xs font-medium align-baseline select-none border border-border shadow-sm transition-all`;let n=document.createElement(`span`);n.textContent=`@${e.filename}`,n.className=`max-w-[180px] truncate`;let r=document.createElement(`button`);return r.type=`button`,r.setAttribute(`aria-label`,am.t(`attachments:removeFile`,{name:e.filename})),r.dataset.role=`pill-remove`,r.className=`text-accent-foreground/60 hover:text-destructive transition-colors leading-none`,r.textContent=`×`,t.appendChild(n),t.appendChild(r),t}function RD(e){return!!e&&e.nodeType===Node.ELEMENT_NODE}function zD(e,t){if(e.nodeType===Node.TEXT_NODE){t.push(e.nodeValue??``);return}if(e.nodeType!==Node.ELEMENT_NODE)return;let n=e;if(n.dataset.attachmentId&&n.dataset.filename){t.push(`@[${n.dataset.filename}](${n.dataset.attachmentId})`);return}if(n.tagName===`BR`){t.push(`
66
+ For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return H.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},Jy=`DialogDescriptionWarning`,Yy=({contentRef:e,descriptionId:t})=>{let n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Ky(Jy).contentName}}.`;return H.useEffect(()=>{let r=e.current?.getAttribute(`aria-describedby`);t&&r&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},Xy=wy,Zy=Oy,Qy=Ay,$y=Py,eb=zy,tb=Vy,nb=Uy,rb=[`nw`,`n`,`ne`,`e`,`se`,`s`,`sw`,`w`],ib={nw:{left:!0,top:!0},n:{top:!0},ne:{right:!0,top:!0},e:{right:!0},se:{right:!0,bottom:!0},s:{bottom:!0},sw:{left:!0,bottom:!0},w:{left:!0}};function ab(e){return e===`n`||e===`s`?`horizontal`:`vertical`}function ob(e,t,n){return Math.min(Math.max(e,t),Math.max(t,n))}function sb(e,t,n,r){return{w:ob(e,r.minWidth,n.width-16),h:ob(t,r.minHeight,n.height-16)}}function cb(e,t){let n=ob(e.x,120-e.w,t.width-e.w),r=ob(e.y,0,Math.max(0,t.height-48));return{...e,x:n,y:r}}function lb(e,t,n,r){return cb({...e,x:e.x+t,y:e.y+n},r)}function ub(e,t,n,r,i,a){let o=ib[t],s=e.x+e.w,c=e.y+e.h,l=e.w,u=e.h;o.right&&(l=e.w+n),o.left&&(l=e.w-n),o.bottom&&(u=e.h+r),o.top&&(u=e.h-r);let d=sb(l,u,i,a),f=e.x,p=e.y;return o.left&&(f=s-d.w),o.top&&(p=c-d.h),cb({x:f,y:p,w:d.w,h:d.h},i)}function db(e,t,n,r,i){let a=ib[t],o=a.left||a.right,s=a.top||a.bottom,c=o?n===`min`?i.minWidth:r.width-16:e.w,l=s?n===`min`?i.minHeight:r.height-16:e.h,u=e.x+e.w,d=e.y+e.h,f=sb(c,l,r,i);return cb({x:a.left?u-f.w:e.x,y:a.top?d-f.h:e.y,w:f.w,h:f.h},r)}function fb(e){return{x:e.left,y:e.top,w:e.width,h:e.height}}function pb(e,t){return{w:e.width,h:e.height,x:Math.round((t.width-e.width)/2),y:Math.round((t.height-e.height)/2)}}function mb(e,t){let{x:n,y:r,w:i,h:a}=t,o=Math.max(0,i-24),s=Math.max(0,a-24);switch(e){case`nw`:return{left:n-14/2,top:r-14/2,width:14,height:14};case`ne`:return{left:n+i-14/2,top:r-14/2,width:14,height:14};case`se`:return{left:n+i-14/2,top:r+a-14/2,width:14,height:14};case`sw`:return{left:n-14/2,top:r+a-14/2,width:14,height:14};case`n`:return{left:n+12,top:r-8/2,width:o,height:8};case`s`:return{left:n+12,top:r+a-8/2,width:o,height:8};case`e`:return{left:n+i-8/2,top:r+12,width:8,height:s};case`w`:return{left:n-8/2,top:r+12,width:8,height:s}}}function hb(e,t,n){let r=ib[e],i=r.left||r.right,a=r.top||r.bottom;switch(t){case`ArrowRight`:return i?{dx:n,dy:0}:null;case`ArrowLeft`:return i?{dx:-n,dy:0}:null;case`ArrowDown`:return a?{dx:0,dy:n}:null;case`ArrowUp`:return a?{dx:0,dy:-n}:null;default:return null}}var gb=64;function _b(){return typeof window>`u`?{width:0,height:0}:{width:window.innerWidth,height:window.innerHeight}}var vb=`button, input, textarea, select, a, [role="button"], [contenteditable="true"]`;function yb(e={}){let{enabled:t=!0,allowMove:n=!0,minWidth:r=320,minHeight:i=200,anchorFromCurrentRect:a=!1,persistKey:o}=e,s=(0,H.useRef)(null),[c,l]=(0,H.useState)(null),u=(0,H.useCallback)(e=>{s.current=e,l(e)},[]),[d,f]=(0,H.useState)(()=>{if(!o||typeof window>`u`)return null;try{let e=window.localStorage.getItem(o);if(!e)return null;let t=JSON.parse(e);if([t?.x,t?.y,t?.w,t?.h].every(e=>typeof e==`number`&&Number.isFinite(e))&&t.w>0&&t.h>0)return cb(t,_b())}catch{}return null}),[p,m]=(0,H.useState)(null),[h,g]=(0,H.useState)(()=>typeof window>`u`||window.innerWidth>=900),_=(0,H.useRef)(null),v=(0,H.useRef)(null),y=(0,H.useRef)(!1),b=(0,H.useRef)(null),x=(0,H.useRef)(!1);v.current=d;let S={minWidth:r,minHeight:i},C=t&&h;(0,H.useEffect)(()=>{function e(){let e=window.innerWidth>=900;g(e),e||f(null)}return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),(0,H.useEffect)(()=>{t||f(null)},[t]),(0,H.useEffect)(()=>{if(!(!o||typeof window>`u`||!d))try{window.localStorage.setItem(o,JSON.stringify(d))}catch{}},[d,o]),(0,H.useEffect)(()=>{if(!C||d!==null){m(null);return}let e=s.current;if(!e)return;let t=()=>m(fb(e.getBoundingClientRect()));t();let n;return typeof ResizeObserver<`u`&&(n=new ResizeObserver(t),n.observe(e)),window.addEventListener(`resize`,t),window.addEventListener(`scroll`,t,!0),()=>{n?.disconnect(),window.removeEventListener(`resize`,t),window.removeEventListener(`scroll`,t,!0)}},[C,d,c]);let w=(0,H.useCallback)(e=>{b.current=e,!y.current&&(y.current=!0,requestAnimationFrame(()=>{y.current=!1,b.current&&f(b.current)}))},[]),T=(0,H.useCallback)(e=>{let t=_.current;if(!t)return;let n=_b(),r=e.clientX-t.startX,i=e.clientY-t.startY;w(t.mode===`move`?lb(t.startGeom,r,i,n):ub(t.startGeom,t.position,r,i,n,S))},[w,S.minWidth,S.minHeight]),E=(0,H.useCallback)(()=>{let e=_.current;if(e){try{e.element.releasePointerCapture(e.pointerId)}catch{}_.current=null,x.current=!0,setTimeout(()=>{x.current=!1},0),b.current&&f(b.current),window.removeEventListener(`pointermove`,T),window.removeEventListener(`pointerup`,E),window.removeEventListener(`pointercancel`,E)}},[T]),D=(0,H.useCallback)((e,t)=>{if(!C||e.button!==0)return;let n=s.current;if(!n)return;let r=v.current;if(!r){let e=n.getBoundingClientRect();if(e.width<=0||e.height<=0)return;r=cb(a?fb(e):pb(e,_b()),_b())}v.current=r,b.current=r;let i=t(r);_.current=i;try{i.element.setPointerCapture(i.pointerId)}catch{}f(r),window.addEventListener(`pointermove`,T),window.addEventListener(`pointerup`,E),window.addEventListener(`pointercancel`,E)},[C,T,E,a]),O=(0,H.useCallback)(e=>{if(!n||e.target.closest(vb))return;let t=s.current;t&&e.clientY-t.getBoundingClientRect().top>gb||D(e,t=>({mode:`move`,startX:e.clientX,startY:e.clientY,startGeom:t,pointerId:e.pointerId,element:e.currentTarget}))},[n,D]),k=(0,H.useCallback)(e=>t=>{t.stopPropagation(),D(t,n=>({mode:`resize`,position:e,startX:t.clientX,startY:t.clientY,startGeom:n,pointerId:t.pointerId,element:t.currentTarget}))},[D]),A=(0,H.useCallback)(()=>f(null),[]),j=(0,H.useCallback)(e=>(...t)=>{x.current||e(...t)},[]),M=(0,H.useCallback)(e=>t=>{if(!C)return;if(t.key===`0`){t.preventDefault(),A();return}let n=s.current;if(!n)return;let r=_b(),i=v.current??fb(n.getBoundingClientRect());if(t.key===`Home`||t.key===`End`){t.preventDefault(),f(db(i,e,t.key===`Home`?`min`:`max`,r,S));return}let a=t.shiftKey?64:16,o=hb(e,t.key,a);o&&(t.preventDefault(),f(ub(i,e,o.dx,o.dy,r,S)))},[C,A,S.minWidth,S.minHeight]);(0,H.useEffect)(()=>{if(!d||!h)return;function e(){let e=v.current;e&&f(cb(e,_b()))}return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[d,h]),(0,H.useEffect)(()=>()=>{window.removeEventListener(`pointermove`,T),window.removeEventListener(`pointerup`,E),window.removeEventListener(`pointercancel`,E);let e=_.current;if(e){try{e.element.releasePointerCapture(e.pointerId)}catch{}_.current=null}},[T,E]);let N=C&&d!==null,P=N&&d?{position:`fixed`,left:d.x,top:d.y,width:d.w,height:d.h,maxWidth:`none`,maxHeight:`none`,margin:0,transform:`none`,animation:`none`}:{},F=N?d:p,I=C&&F?rb.map(e=>({position:e,role:`separator`,"aria-orientation":ab(e),tabIndex:0,style:{position:`fixed`,...mb(e,F)},onPointerDown:k(e),onKeyDown:M(e)})):[];return{panelRef:u,panelStyle:P,headerHandleProps:{onPointerDown:O},resizeHandles:I,isFloating:N,enabled:C,reset:A,guardBackdrop:j}}var bb={nw:`cursor-nwse-resize`,n:`cursor-ns-resize`,ne:`cursor-nesw-resize`,e:`cursor-ew-resize`,se:`cursor-nwse-resize`,s:`cursor-ns-resize`,sw:`cursor-nesw-resize`,w:`cursor-ew-resize`};function xb({handles:e}){let{t}=K(`common`);return e.length===0?null:(0,Y.jsx)(Y.Fragment,{children:e.map(e=>(0,Y.jsx)(`div`,{"data-testid":`modal-resize-${e.position}`,role:e.role,"aria-orientation":e[`aria-orientation`],"aria-label":t(`modal.resize.${e.position}`),tabIndex:e.tabIndex,style:e.style,onPointerDown:e.onPointerDown,onKeyDown:e.onKeyDown,className:X(`z-[51] rounded-full bg-transparent transition-colors duration-150`,`hover:bg-accent-primary/20 focus:outline-none focus-visible:bg-accent-primary/30`,bb[e.position])},e.position))})}function Sb(...e){return H.useCallback(t=>{for(let n of e)n&&(typeof n==`function`?n(t):n.current=t)},e)}var Cb=Xy,wb=Zy,Tb=H.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(Qy,{ref:n,className:X(`fixed inset-0 z-50 bg-black/60 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`,e),...t}));Tb.displayName=Qy.displayName;var Eb=()=>{let{t:e}=K(`common`);return(0,Y.jsxs)(nb,{className:`absolute right-4 top-4 z-20 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground`,children:[(0,Y.jsx)(hc,{className:`h-4 w-4`}),(0,Y.jsx)(`span`,{className:`sr-only`,children:e(`actions.close`)})]})},Db=H.forwardRef(({className:e,children:t,showCloseButton:n=!0,movableResizable:r=!1,style:i,...a},o)=>{let{panelRef:s,panelStyle:c,resizeHandles:l}=yb({enabled:r,allowMove:!1}),u=Sb(o,s);return r?(0,Y.jsxs)(wb,{children:[(0,Y.jsx)(Tb,{}),(0,Y.jsxs)($y,{ref:u,style:{...i,...c},className:X(`fixed left-[50%] top-[50%] z-50 grid w-full max-w-2xl max-h-[85vh] translate-x-[-50%] translate-y-[-50%] gap-4 border border-border/30 bg-popover p-6 shadow-xl backdrop-blur-md duration-200 overflow-y-auto data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-xl`,e),...a,children:[t,n&&(0,Y.jsx)(Eb,{})]}),(0,Y.jsx)(xb,{handles:l})]}):(0,Y.jsxs)(wb,{children:[(0,Y.jsx)(Tb,{}),(0,Y.jsxs)($y,{ref:o,style:i,className:X(`fixed left-[50%] top-[50%] z-50 grid w-full max-w-2xl max-h-[85vh] translate-x-[-50%] translate-y-[-50%] gap-4 border border-border/30 bg-popover p-6 shadow-xl backdrop-blur-md duration-200 overflow-y-auto data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-xl`,e),...a,children:[t,n&&(0,Y.jsx)(Eb,{})]})]})});Db.displayName=$y.displayName;var Ob=({className:e,...t})=>(0,Y.jsx)(`div`,{className:X(`flex flex-col space-y-1.5 text-center sm:text-left`,e),...t});Ob.displayName=`DialogHeader`;var kb=({className:e,...t})=>(0,Y.jsx)(`div`,{className:X(`flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2`,e),...t});kb.displayName=`DialogFooter`;var Ab=H.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(eb,{ref:n,className:X(`text-lg font-semibold leading-none tracking-tight`,e),...t}));Ab.displayName=eb.displayName;var jb=H.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(tb,{ref:n,className:X(`text-xs text-muted-foreground`,e),...t}));jb.displayName=tb.displayName;var Mb=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}?.VITE_FEATURE_TERMINAL_PANEL;return typeof e==`string`?e!==`false`:!0})(),Nb=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}?.VITE_FEATURE_AGENTS_SECTION;return typeof e==`string`?e!==`false`:!0})(),Pb=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}?.VITE_FEATURE_CODE_EXPLORER;return typeof e==`string`?e!==`false`:!0})(),Fb=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}?.VITE_FEATURE_JIRA;return typeof e==`string`?e!==`false`:!0})(),Ib=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}?.VITE_FEATURE_MCP;return typeof e==`string`?e!==`false`:!0})(),Lb=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}?.VITE_FEATURE_AGENT_CHAT;return typeof e==`string`?e!==`false`:!0})(),Rb=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}?.VITE_FEATURE_AGENT_MODE;return Lb&&(typeof e==`string`?e!==`false`:!0)})();(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}?.VITE_FEATURE_INTERACTIVE_JOBS;return typeof e==`string`?e!==`false`:!0})();var zb=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}?.VITE_FEATURE_LOOPS_SECTION;return typeof e==`string`?e!==`false`:!0})();async function Bb(e){let t=await e.text(),n=t?JSON.parse(t):{};if(!e.ok)throw Error(n.error||`Request failed (${e.status})`);return n}function Vb(e){return e??af()}var Hb=e=>({method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)}),Ub={getConnection(e){return fetch(`${Vb(e)}/jira/connection`).then(e=>Bb(e))},test(e,t){return fetch(`${Vb(t)}/jira/test`,Hb(e)).then(e=>Bb(e))},discoverProjects(e,t){return fetch(`${Vb(t)}/jira/discover-projects`,Hb(e)).then(e=>Bb(e))},discoverStatuses(e,t){return fetch(`${Vb(t)}/jira/discover-statuses`,Hb(e)).then(e=>Bb(e))},connect(e,t){return fetch(`${Vb(t)}/jira/connect`,Hb(e)).then(e=>Bb(e))},setEnabled(e,t){return fetch(`${Vb(t)}/jira/connection`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:e})}).then(e=>Bb(e))},patchConnection(e,t){return fetch(`${Vb(t)}/jira/connection`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)}).then(e=>Bb(e))},listStatuses(e){return fetch(`${Vb(e)}/jira/statuses`).then(e=>Bb(e))},discardSpec(e,t,n){return fetch(`${Vb(n)}/jira/specs/${e}/discard`,Hb({comment:t})).then(e=>Bb(e))},getSpecDetails(e,t){return fetch(`${Vb(t)}/jira/specs/${e}/details`).then(e=>Bb(e))},disconnect(e){return fetch(`${Vb(e)}/jira/connection`,{method:`DELETE`}).then(e=>Bb(e))},syncNow(e){return fetch(`${Vb(e)}/jira/sync`,{method:`POST`}).then(e=>Bb(e))},resume(e){return fetch(`${Vb(e)}/jira/resume`,{method:`POST`}).then(e=>Bb(e))},listOutbox(e,t){let n=e?`?state=${e}`:``;return fetch(`${Vb(t)}/jira/outbox${n}`).then(e=>Bb(e))},retryOutbox(e,t){return fetch(`${Vb(t)}/jira/outbox/${e}/retry`,{method:`POST`}).then(e=>Bb(e))}};function Wb(){let{activeProjectId:e}=gm(),[t,n]=(0,H.useState)({connected:!1,key:null,discardStatus:null}),[r,i]=(0,H.useState)(!0);return(0,H.useEffect)(()=>{if(!Fb||!e){n({connected:!1,key:null,discardStatus:null}),i(!1);return}let t=!1;return i(!0),Ub.getConnection().then(e=>{if(t)return;let r=!!(e.connected&&e.connection?.enabled);n({connected:r,key:e.connection?.jiraProjectKey??null,discardStatus:r?e.connection?.discardStatus??null:null})}).catch(()=>{t||n({connected:!1,key:null,discardStatus:null})}).finally(()=>{t||i(!1)}),()=>{t=!0}},[e]),{connected:t.connected,jiraProjectKey:t.key,discardStatus:t.discardStatus,loading:r}}var Gb=(0,H.createContext)({discardStatus:null});function Kb({children:e}){let t=Wb(),n=t.connected?t.discardStatus:null,r=(0,H.useMemo)(()=>({discardStatus:n}),[n]);return(0,Y.jsx)(Gb.Provider,{value:r,children:e})}function qb(){return(0,H.useContext)(Gb)}function Jb({open:e,onOpenChange:t,ticket:n,discardStatus:r,onDiscarded:i}){let{t:a}=K(`jira`),[o,s]=(0,H.useState)(``),[c,l]=(0,H.useState)(!1);async function u(){l(!0);try{await Ub.discardSpec(n.id,o.trim()||null),q.success(a(`discard.movedToast`,{status:r,key:n.jira_key??`#${n.id}`})),t(!1),s(``),i?.()}catch(e){q.error(e instanceof Error?e.message:a(`errors.generic`))}finally{l(!1)}}return(0,Y.jsx)(Cb,{open:e,onOpenChange:e=>{c||t(e)},children:(0,Y.jsxs)(Db,{movableResizable:!0,className:`max-w-md`,"data-testid":`jira-discard-dialog`,children:[(0,Y.jsxs)(Ob,{children:[(0,Y.jsx)(Ab,{children:a(`discard.title`,{status:r})}),(0,Y.jsx)(jb,{children:a(`discard.body`,{status:r,key:n.jira_key??`#${n.id}`})})]}),(0,Y.jsxs)(`label`,{className:`block space-y-1`,children:[(0,Y.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:a(`discard.commentLabel`)}),(0,Y.jsx)(`textarea`,{value:o,onChange:e=>s(e.target.value),placeholder:a(`discard.commentPlaceholder`),rows:3,className:`w-full rounded-md border border-border bg-input px-3 py-2 text-xs text-foreground placeholder:text-muted-foreground resize-none`,"data-testid":`jira-discard-comment`})]}),(0,Y.jsxs)(kb,{children:[(0,Y.jsx)(Z,{variant:`outline`,size:`sm`,onClick:()=>t(!1),disabled:c,children:a(`wizard.cancel`)}),(0,Y.jsxs)(Z,{size:`sm`,onClick:u,disabled:c,"data-testid":`jira-discard-confirm`,children:[(0,Y.jsx)(Va,{className:`w-3.5 h-3.5 mr-1.5`}),c?a(`discard.moving`):a(`discard.confirm`,{status:r})]})]})]})})}var Yb=[{value:`todo`,labelKey:`ticketStatus.todo`,icon:(0,Y.jsx)(uo,{className:`w-3.5 h-3.5 text-slate-400 aurora-light:text-muted-foreground`}),className:`text-slate-400 aurora-light:text-muted-foreground`},{value:`done`,labelKey:`ticketStatus.done`,icon:(0,Y.jsx)(co,{className:`w-3.5 h-3.5 text-emerald-400 aurora-light:text-accent-success`}),className:`text-emerald-400 aurora-light:text-accent-success`}],Xb=[{value:`critical`,labelKey:`priority.critical`,icon:(0,Y.jsx)(oo,{className:`w-3.5 h-3.5 text-red-400 aurora-light:text-destructive`}),className:`text-red-400 aurora-light:text-destructive`},{value:`high`,labelKey:`priority.high`,icon:(0,Y.jsx)(Ua,{className:`w-3.5 h-3.5 text-orange-400 aurora-light:text-accent-warning`}),className:`text-orange-400 aurora-light:text-accent-warning`},{value:`medium`,labelKey:`priority.medium`,icon:(0,Y.jsx)(Va,{className:`w-3.5 h-3.5 text-yellow-400 aurora-light:text-accent-warning`}),className:`text-yellow-400 aurora-light:text-accent-warning`},{value:`low`,labelKey:`priority.low`,icon:(0,Y.jsx)(za,{className:`w-3.5 h-3.5 text-slate-400 aurora-light:text-muted-foreground`}),className:`text-slate-400 aurora-light:text-muted-foreground`}];function Zb({position:e,ticket:t,activeSubmenu:n,onSetSubmenu:r,onStatusChange:i,onPriorityChange:a,onDeleteRequest:o,discardLabel:s,onDiscardRequest:c,onClose:l}){let{t:u}=K(`tickets`),d=(0,H.useRef)(null),[f,p]=(0,H.useState)(e);(0,H.useEffect)(()=>{if(!d.current)return;let t=d.current.getBoundingClientRect(),n=window.innerWidth,r=window.innerHeight;p({x:t.right>n?Math.max(0,e.x-t.width):e.x,y:t.bottom>r?Math.max(0,e.y-t.height):e.y})},[e]);let m=(0,H.useCallback)(e=>{e(),l()},[l]);return(0,Y.jsxs)(`div`,{ref:d,role:`menu`,"aria-label":u(`contextMenu.ariaLabel`),style:{left:f.x,top:f.y},className:`fixed z-[200] min-w-[180px] rounded-lg border border-border/50 bg-popover shadow-xl text-xs py-1`,children:[s&&c?(0,Y.jsxs)(`button`,{role:`menuitem`,type:`button`,onClick:()=>{c(),l()},className:`flex w-full items-center gap-2 px-3 py-2 text-left text-accent-info hover:bg-accent-info/10 transition-colors`,"data-testid":`jira-move-to-menuitem`,children:[(0,Y.jsx)(Va,{className:`w-3.5 h-3.5 shrink-0`}),s]}):(0,Y.jsxs)(`button`,{role:`menuitem`,type:`button`,onClick:()=>{o(),l()},className:`flex w-full items-center gap-2 px-3 py-2 text-left text-red-400 aurora-light:text-destructive hover:bg-red-500/10 transition-colors`,children:[(0,Y.jsx)(cc,{className:`w-3.5 h-3.5 shrink-0`}),u(`contextMenu.deleteTicket`)]}),(0,Y.jsx)(`div`,{className:`my-1 h-px bg-border/40`,role:`separator`}),(0,Y.jsxs)(`div`,{role:`menuitem`,tabIndex:-1,"aria-haspopup":`menu`,"aria-expanded":n===`status`,className:X(`relative flex w-full items-center justify-between gap-2 px-3 py-2 cursor-pointer select-none text-foreground/80 hover:bg-accent/50 hover:text-foreground transition-colors`,n===`status`&&`bg-accent/50 text-foreground`),onMouseEnter:()=>r(`status`),onClick:e=>{e.stopPropagation(),r(n===`status`?null:`status`)},children:[(0,Y.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(uo,{className:`w-3.5 h-3.5 shrink-0 text-muted-foreground`}),u(`contextMenu.changeStatus`)]}),(0,Y.jsx)(io,{className:`w-3 h-3 text-muted-foreground`}),n===`status`&&(0,Y.jsx)(`div`,{role:`menu`,"aria-label":u(`contextMenu.statusOptions`),className:`absolute left-full top-0 ml-1 min-w-[150px] rounded-lg border border-border/50 bg-popover shadow-xl py-1 z-[201]`,children:Yb.map(e=>(0,Y.jsxs)(`button`,{role:`menuitem`,type:`button`,onClick:()=>m(()=>i(e.value)),className:X(`flex w-full items-center gap-2 px-3 py-2 text-left hover:bg-accent/50 transition-colors`,e.className,t.status===e.value&&`bg-accent/30 font-semibold`),children:[e.icon,u(e.labelKey)]},e.value))})]}),(0,Y.jsxs)(`div`,{role:`menuitem`,tabIndex:-1,"aria-haspopup":`menu`,"aria-expanded":n===`priority`,className:X(`relative flex w-full items-center justify-between gap-2 px-3 py-2 cursor-pointer select-none text-foreground/80 hover:bg-accent/50 hover:text-foreground transition-colors`,n===`priority`&&`bg-accent/50 text-foreground`),onMouseEnter:()=>r(`priority`),onClick:e=>{e.stopPropagation(),r(n===`priority`?null:`priority`)},children:[(0,Y.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(Io,{className:`w-3.5 h-3.5 shrink-0 text-muted-foreground`}),u(`contextMenu.setPriority`)]}),(0,Y.jsx)(io,{className:`w-3 h-3 text-muted-foreground`}),n===`priority`&&(0,Y.jsx)(`div`,{role:`menu`,"aria-label":u(`contextMenu.priorityOptions`),className:`absolute left-full top-0 ml-1 min-w-[140px] rounded-lg border border-border/50 bg-popover shadow-xl py-1 z-[201]`,children:Xb.map(e=>(0,Y.jsxs)(`button`,{role:`menuitem`,type:`button`,onClick:()=>m(()=>a(e.value)),className:X(`flex w-full items-center gap-2 px-3 py-2 text-left hover:bg-accent/50 transition-colors`,e.className,t.priority===e.value&&`bg-accent/30 font-semibold`),children:[e.icon,u(e.labelKey)]},e.value))})]})]})}function Qb({ticket:e,onDelete:t,onStatusChange:n,onPriorityChange:r,children:i,className:a}){let{t:o}=K(`tickets`),{t:s}=K(`jira`),[c,l]=(0,H.useState)(!1),[u,d]=(0,H.useState)({x:0,y:0}),[f,p]=(0,H.useState)(null),[m,h]=(0,H.useState)(!1),[g,_]=(0,H.useState)(!1),{discardStatus:v}=qb(),y=!!v&&e.source===`jira`&&!!e.jira_key,b=(0,H.useCallback)(()=>{l(!1),p(null)},[]);(0,H.useEffect)(()=>{if(!c)return;function e(e){e.key===`Escape`&&b()}function t(e){e.target.closest(`[role="menu"]`)||b()}return document.addEventListener(`keydown`,e),document.addEventListener(`mousedown`,t),()=>{document.removeEventListener(`keydown`,e),document.removeEventListener(`mousedown`,t)}},[c,b]);function x(e){e.preventDefault(),d({x:e.clientX,y:e.clientY}),p(null),l(!0)}function S(){t(e.id),h(!1)}return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{onContextMenu:x,className:a,"data-ticket-id":e.id,children:i}),c&&(0,sr.createPortal)((0,Y.jsx)(Zb,{position:u,ticket:e,activeSubmenu:f,onSetSubmenu:p,onStatusChange:t=>n(e.id,t),onPriorityChange:t=>r(e.id,t),onDeleteRequest:()=>h(!0),discardLabel:y?s(`discard.moveButton`,{status:v}):void 0,onDiscardRequest:y?()=>_(!0):void 0,onClose:b}),document.body),y&&v&&(0,Y.jsx)(Jb,{open:g,onOpenChange:_,ticket:{id:e.id,title:e.title,jira_key:e.jira_key},discardStatus:v}),(0,Y.jsx)(Cb,{open:m,onOpenChange:h,children:(0,Y.jsxs)(Db,{className:`max-w-sm`,children:[(0,Y.jsxs)(Ob,{children:[(0,Y.jsx)(Ab,{children:o(`deleteDialog.title`)}),(0,Y.jsx)(jb,{children:(0,Y.jsx)(Yi,{t:o,i18nKey:`deleteDialog.body`,values:{id:e.id,title:e.title},components:{strong:(0,Y.jsx)(`span`,{className:`font-semibold text-foreground`})}})})]}),(0,Y.jsxs)(kb,{children:[(0,Y.jsx)(Z,{variant:`outline`,size:`sm`,onClick:()=>h(!1),children:o(`common:actions.cancel`)}),(0,Y.jsxs)(Z,{variant:`destructive`,size:`sm`,onClick:S,children:[(0,Y.jsx)(cc,{className:`w-3.5 h-3.5 mr-1.5`}),o(`common:actions.delete`)]})]})]})})]})}var $b=[`accent-primary`,`accent-info`,`accent-success`,`accent-secondary`,`accent-warning`,`accent-highlight`];function ex(e){let t=2166136261,n=e.toLowerCase();for(let e=0;e<n.length;e+=1)t^=n.charCodeAt(e),t=Math.imul(t,16777619)>>>0;return $b[t%$b.length]}var tx={"accent-primary":`bg-accent-primary/20 text-accent-primary`,"accent-info":`bg-accent-info/20 text-accent-info`,"accent-success":`bg-accent-success/20 text-accent-success`,"accent-secondary":`bg-accent-secondary/20 text-accent-secondary`,"accent-warning":`bg-accent-warning/20 text-accent-warning`,"accent-highlight":`bg-accent-highlight/20 text-accent-highlight`};function nx({tickets:e,active:t,onChange:n,className:r}){let{t:i}=K(`specs`),[a,o]=(0,H.useState)(!1),s=(0,H.useRef)(null),c=(0,H.useRef)(null),l=(0,H.useMemo)(()=>{let t=new Map;for(let n of e)for(let e of n.labels??[]){let n=e.trim();n&&t.set(n,(t.get(n)??0)+1)}return Array.from(t.entries()).sort((e,t)=>t[1]===e[1]?e[0].localeCompare(t[0]):t[1]-e[1])},[e]);(0,H.useEffect)(()=>{if(!a)return;function e(e){c.current?.contains(e.target)||s.current?.contains(e.target)||o(!1)}function t(e){e.key===`Escape`&&o(!1)}return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[a]);function u(e){let r=new Set(t);r.has(e)?r.delete(e):r.add(e),n(r)}function d(){n(new Set)}let f=t.size===0?i(`labelFilter.all`):t.size===1?Array.from(t)[0]:i(`labelFilter.selected`,{count:t.size});return(0,Y.jsxs)(`div`,{className:X(`relative shrink-0`,r),children:[(0,Y.jsxs)(`button`,{ref:s,type:`button`,"aria-haspopup":`listbox`,"aria-expanded":a,"aria-label":i(`labelFilter.ariaLabel`),"data-testid":`spec-label-filter-dropdown`,onClick:()=>o(e=>!e),className:`flex items-center gap-1.5 h-7 px-2 rounded-md text-xs bg-accent-secondary/10 border border-accent-secondary/30 hover:bg-accent-secondary/20 text-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-secondary/50`,children:[(0,Y.jsx)(ic,{className:`w-3 h-3 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`truncate max-w-[120px]`,children:f}),t.size>0&&(0,Y.jsxs)(`span`,{className:`text-[10px] text-muted-foreground/80`,children:[`·\xA0`,t.size]})]}),a&&(0,Y.jsxs)(`div`,{ref:c,role:`listbox`,"aria-multiselectable":`true`,"data-testid":`spec-label-filter-panel`,className:`absolute z-40 left-0 mt-1 w-56 max-h-72 overflow-y-auto rounded-xl border border-border/60 bg-card/95 backdrop-blur shadow-xl shadow-black/30 p-1`,children:[(0,Y.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t.size===0,onClick:d,"data-testid":`spec-label-filter-all`,className:X(`w-full flex items-center gap-2 px-2 py-1.5 rounded-lg text-left text-xs hover:bg-accent-info/10 transition-colors`,t.size===0&&`bg-accent-info/10 text-accent-info`),children:[(0,Y.jsx)(`span`,{className:`inline-flex w-4 h-4 items-center justify-center`,children:t.size===0&&(0,Y.jsx)(to,{className:`w-3 h-3 text-accent-info`})}),(0,Y.jsx)(`span`,{className:`flex-1`,children:i(`labelFilter.all`)}),(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground/70`,children:e.length})]}),l.length===0&&(0,Y.jsx)(`div`,{className:`px-2 py-2 text-[11px] text-muted-foreground/60 italic`,children:i(`labelFilter.empty`)}),l.length>0&&(0,Y.jsx)(`div`,{className:`my-1 h-px bg-border/40`,"aria-hidden":!0}),l.map(([e,n])=>{let r=t.has(e),i=tx[ex(e)]??`bg-muted/40 text-foreground`;return(0,Y.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":r,onClick:()=>u(e),className:X(`w-full flex items-center gap-2 px-2 py-1.5 rounded-lg text-left text-xs hover:bg-muted/30 transition-colors`,r&&`bg-accent-info/5`),children:[(0,Y.jsx)(`span`,{className:`inline-flex w-4 h-4 items-center justify-center`,children:r&&(0,Y.jsx)(to,{className:`w-3 h-3 text-accent-info`})}),(0,Y.jsx)(`span`,{className:X(`inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[10px] font-medium`,i),children:e}),(0,Y.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground/60`,children:n})]},e)})]})]})}function rx({tickets:e,active:t,onChange:n,className:r}){let{t:i}=K(`specs`),[a,o]=(0,H.useState)(!1),s=(0,H.useRef)(null),c=(0,H.useRef)(null),l=(0,H.useMemo)(()=>{let t=new Map;for(let n of e){if(!n.jira_epic_key)continue;let e=t.get(n.jira_epic_key);e?e.count+=1:t.set(n.jira_epic_key,{key:n.jira_epic_key,name:n.jira_epic_name??n.jira_epic_key,count:1})}return Array.from(t.values()).sort((e,t)=>t.count===e.count?e.name.localeCompare(t.name):t.count-e.count)},[e]);(0,H.useEffect)(()=>{if(!a)return;function e(e){c.current?.contains(e.target)||s.current?.contains(e.target)||o(!1)}function t(e){e.key===`Escape`&&o(!1)}return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[a]);function u(e){n(e),o(!1)}let d=t?l.find(e=>e.key===t):null,f=d?d.name:i(`epicFilter.all`);return(0,Y.jsxs)(`div`,{className:X(`relative shrink-0`,r),children:[(0,Y.jsxs)(`button`,{ref:s,type:`button`,"aria-haspopup":`listbox`,"aria-expanded":a,"aria-label":i(`epicFilter.ariaLabel`),"data-testid":`spec-epic-filter-dropdown`,onClick:()=>o(e=>!e),className:`flex items-center gap-1.5 h-7 px-2 rounded-md text-xs bg-accent-highlight/10 border border-accent-highlight/30 hover:bg-accent-highlight/20 text-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-highlight/50`,children:[(0,Y.jsx)(rs,{className:`w-3 h-3 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`truncate max-w-[140px]`,children:f})]}),a&&(0,Y.jsxs)(`div`,{ref:c,role:`listbox`,"data-testid":`spec-epic-filter-panel`,className:`absolute z-40 left-0 mt-1 w-64 max-h-72 overflow-y-auto rounded-xl border border-border/60 bg-card/95 backdrop-blur shadow-xl shadow-black/30 p-1`,children:[(0,Y.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t===null,onClick:()=>u(null),"data-testid":`spec-epic-filter-all`,className:X(`w-full flex items-center gap-2 px-2 py-1.5 rounded-lg text-left text-xs hover:bg-accent-info/10 transition-colors`,t===null&&`bg-accent-info/10 text-accent-info`),children:[(0,Y.jsx)(`span`,{className:`inline-flex w-4 h-4 items-center justify-center`,children:t===null&&(0,Y.jsx)(to,{className:`w-3 h-3 text-accent-info`})}),(0,Y.jsx)(`span`,{className:`flex-1`,children:i(`epicFilter.all`)}),(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground/70`,children:e.length})]}),l.length>0&&(0,Y.jsx)(`div`,{className:`my-1 h-px bg-border/40`,"aria-hidden":!0}),l.map(e=>{let n=t===e.key;return(0,Y.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":n,onClick:()=>u(e.key),className:X(`w-full flex items-center gap-2 px-2 py-1.5 rounded-lg text-left text-xs hover:bg-muted/30 transition-colors`,n&&`bg-accent-info/5`),children:[(0,Y.jsx)(`span`,{className:`inline-flex w-4 h-4 items-center justify-center`,children:n&&(0,Y.jsx)(to,{className:`w-3 h-3 text-accent-info`})}),(0,Y.jsx)(`span`,{className:`font-mono text-[10px] text-accent-highlight shrink-0`,children:e.key}),(0,Y.jsx)(`span`,{className:`truncate text-foreground/80`,children:e.name}),(0,Y.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground/60`,children:e.count})]},e.key)})]})]})}function ix({tickets:e,active:t,onChange:n,className:r}){let{t:i}=K(`specs`),[a,o]=(0,H.useState)(!1),s=(0,H.useRef)(null),c=(0,H.useRef)(null),l=(0,H.useMemo)(()=>{let t=new Map;for(let n of e){if(!n.jira_sprint_id)continue;let e=n.jira_sprint_state===`active`,r=t.get(n.jira_sprint_id);r?(r.count+=1,e&&(r.active=!0)):t.set(n.jira_sprint_id,{id:n.jira_sprint_id,name:n.jira_sprint_name??n.jira_sprint_id,count:1,active:e})}return Array.from(t.values()).sort((e,t)=>e.active===t.active?t.count===e.count?e.name.localeCompare(t.name):t.count-e.count:e.active?-1:1)},[e]);(0,H.useEffect)(()=>{if(!a)return;function e(e){c.current?.contains(e.target)||s.current?.contains(e.target)||o(!1)}function t(e){e.key===`Escape`&&o(!1)}return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[a]);function u(e){n(e),o(!1)}let d=t?l.find(e=>e.id===t):null,f=d?d.name:i(`sprintFilter.all`);return(0,Y.jsxs)(`div`,{className:X(`relative shrink-0`,r),children:[(0,Y.jsxs)(`button`,{ref:s,type:`button`,"aria-haspopup":`listbox`,"aria-expanded":a,"aria-label":i(`sprintFilter.ariaLabel`),"data-testid":`spec-sprint-filter-dropdown`,onClick:()=>o(e=>!e),className:`flex items-center gap-1.5 h-7 px-2 rounded-md text-xs bg-accent-success/10 border border-accent-success/30 hover:bg-accent-success/20 text-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-success/50`,children:[(0,Y.jsx)(sc,{className:`w-3 h-3 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`truncate max-w-[140px]`,children:f})]}),a&&(0,Y.jsxs)(`div`,{ref:c,role:`listbox`,"data-testid":`spec-sprint-filter-panel`,className:`absolute z-40 left-0 mt-1 w-64 max-h-72 overflow-y-auto rounded-xl border border-border/60 bg-card/95 backdrop-blur shadow-xl shadow-black/30 p-1`,children:[(0,Y.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t===null,onClick:()=>u(null),"data-testid":`spec-sprint-filter-all`,className:X(`w-full flex items-center gap-2 px-2 py-1.5 rounded-lg text-left text-xs hover:bg-accent-info/10 transition-colors`,t===null&&`bg-accent-info/10 text-accent-info`),children:[(0,Y.jsx)(`span`,{className:`inline-flex w-4 h-4 items-center justify-center`,children:t===null&&(0,Y.jsx)(to,{className:`w-3 h-3 text-accent-info`})}),(0,Y.jsx)(`span`,{className:`flex-1`,children:i(`sprintFilter.all`)}),(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground/70`,children:e.length})]}),l.length>0&&(0,Y.jsx)(`div`,{className:`my-1 h-px bg-border/40`,"aria-hidden":!0}),l.map(e=>{let n=t===e.id;return(0,Y.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":n,onClick:()=>u(e.id),className:X(`w-full flex items-center gap-2 px-2 py-1.5 rounded-lg text-left text-xs hover:bg-muted/30 transition-colors`,n&&`bg-accent-info/5`),children:[(0,Y.jsx)(`span`,{className:`inline-flex w-4 h-4 items-center justify-center`,children:n&&(0,Y.jsx)(to,{className:`w-3 h-3 text-accent-info`})}),(0,Y.jsx)(`span`,{className:`truncate text-foreground/80`,children:e.name}),e.active&&(0,Y.jsx)(`span`,{"data-testid":`spec-sprint-current-badge`,className:`shrink-0 rounded-full bg-accent-success/15 px-1.5 py-0.5 text-[9px] font-medium uppercase tracking-wide text-accent-success`,children:i(`sprintFilter.current`)}),(0,Y.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground/60`,children:e.count})]},e.id)})]})]})}var ax={draft:{dotClass:`bg-accent-secondary/60`,textClass:`text-accent-secondary`,borderClass:`border-l-[3px] border-dashed border-accent-secondary/50 pl-3`,labelKey:`common:status.draft`,pulsing:!1},todo:{dotClass:`bg-slate-500/70`,textClass:`text-muted-foreground`,borderClass:`border-l-[3px] border-dashed border-slate-500/40 pl-3`,labelKey:`status.todo`,pulsing:!1},in_progress:{dotClass:`bg-blue-400 aurora-light:bg-accent-info`,textClass:`text-foreground font-semibold`,borderClass:`border-l-[3px] border-solid border-blue-500 pl-3`,labelKey:`status.inProgress`,pulsing:!0},on_review:{dotClass:`bg-accent-warning/80`,textClass:`text-accent-warning`,borderClass:`border-l-[3px] border-solid border-accent-warning/60 pl-3`,labelKey:`status.onReview`,pulsing:!1},done:{dotClass:`text-emerald-400 aurora-light:text-accent-success`,textClass:`text-emerald-400/80 aurora-light:text-accent-success`,borderClass:`border-l-[3px] border-solid border-emerald-500 pl-3`,labelKey:`status.done`,pulsing:!1},cancelled:{dotClass:`text-red-400/60 aurora-light:text-destructive/70`,textClass:`text-muted-foreground/50`,borderClass:`pl-3`,labelKey:`status.cancelled`,pulsing:!1}};function ox({status:e,className:t}){let{t:n}=K(`specs`),r=ax[e];return e===`done`?(0,Y.jsx)(to,{className:X(`w-3.5 h-3.5 shrink-0`,r.dotClass,t),"aria-label":n(`status.done`)}):e===`cancelled`?(0,Y.jsx)(hc,{className:X(`w-3.5 h-3.5 shrink-0`,r.dotClass,t),"aria-label":n(`status.cancelled`)}):r.pulsing?(0,Y.jsxs)(`span`,{className:X(`relative flex shrink-0 h-2.5 w-2.5`,t),"aria-label":n(`status.inProgress`),children:[(0,Y.jsx)(`span`,{className:X(`animate-ping absolute inline-flex h-full w-full rounded-full opacity-60`,r.dotClass)}),(0,Y.jsx)(`span`,{className:X(`relative inline-flex rounded-full h-2.5 w-2.5`,r.dotClass)})]}):(0,Y.jsx)(`span`,{className:X(`inline-flex rounded-full h-2.5 w-2.5 shrink-0`,r.dotClass,t),"aria-label":n(r.labelKey)})}function sx({status:e,className:t}){let{t:n}=K(`specs`),r=ax[e];return(0,Y.jsxs)(`span`,{className:X(`inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-[11px] font-medium border`,e===`todo`&&`bg-slate-500/10 border-slate-500/30 text-slate-400 aurora-light:bg-muted aurora-light:border-border aurora-light:text-muted-foreground`,e===`in_progress`&&`bg-blue-500/10 border-blue-500/30 text-blue-400 aurora-light:bg-accent-info/10 aurora-light:border-accent-info/30 aurora-light:text-accent-info`,e===`on_review`&&`bg-accent-warning/10 border-accent-warning/30 text-accent-warning`,e===`done`&&`bg-emerald-500/10 border-emerald-500/30 text-emerald-400 aurora-light:bg-accent-success/10 aurora-light:border-accent-success/30 aurora-light:text-accent-success`,e===`cancelled`&&`bg-red-500/10 border-red-500/30 text-red-400/60 aurora-light:bg-destructive/10 aurora-light:border-destructive/30 aurora-light:text-destructive/70`,t),children:[(0,Y.jsx)(ox,{status:e}),n(r.labelKey)]})}var cx=[`draft`,`todo`,`in_progress`,`on_review`,`done`,`cancelled`],lx=new Set([`draft`,`todo`,`in_progress`,`on_review`]),ux=[`active`,`all`,...cx];function dx(e){return typeof e==`string`&&ux.includes(e)}function fx(e,t){return t===`all`?!0:t===`active`?lx.has(e):e===t}var px=e=>`specrails-desktop:spec-status-filter:${e}`,mx=e=>`specrails-desktop:spec-status-tab:${e}`;function hx(e){if(!e)return`active`;try{let t=localStorage.getItem(px(e));return dx(t)?t:localStorage.getItem(mx(e))===`done`?`done`:`active`}catch{return`active`}}function gx(e,t){if(e)try{localStorage.setItem(px(e),t)}catch{}}var _x={active:`bg-accent-primary/15 border-accent-primary/40 text-accent-primary`,all:`bg-muted/50 border-border text-foreground`,draft:`bg-accent-secondary/15 border-accent-secondary/40 text-accent-secondary`,todo:`bg-slate-500/15 border-slate-500/40 text-slate-400 aurora-light:bg-muted aurora-light:border-border aurora-light:text-muted-foreground`,in_progress:`bg-blue-500/15 border-blue-500/40 text-blue-400 aurora-light:bg-accent-info/10 aurora-light:border-accent-info/30 aurora-light:text-accent-info`,on_review:`bg-accent-warning/15 border-accent-warning/40 text-accent-warning`,done:`bg-emerald-500/15 border-emerald-500/40 text-emerald-400 aurora-light:bg-accent-success/10 aurora-light:border-accent-success/30 aurora-light:text-accent-success`,cancelled:`bg-red-500/10 border-red-500/30 text-red-400/80 aurora-light:bg-destructive/10 aurora-light:border-destructive/30 aurora-light:text-destructive/70`},vx={active:`statusFilter.active`,all:`statusFilter.all`,draft:`common:status.draft`,todo:`status.todo`,in_progress:`status.inProgress`,on_review:`status.onReview`,done:`status.done`,cancelled:`status.cancelled`};function yx({value:e,selected:t,count:n,onClick:r,label:i}){let a=e!==`active`&&e!==`all`;return(0,Y.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t,onClick:r,"data-testid":`specs-status-chip-${e}`,title:i,className:X(`inline-flex items-center gap-1.5 rounded-full border px-2.5 h-6 text-[11px] font-medium whitespace-nowrap shrink-0 transition-all`,t?_x[e]:`border-transparent text-muted-foreground hover:text-foreground hover:bg-muted/40`,!t&&n===0&&`opacity-40`),children:[a&&(0,Y.jsx)(ox,{status:e,className:`w-2 h-2`}),(0,Y.jsx)(`span`,{children:i}),(0,Y.jsx)(`span`,{className:X(`text-[10px] tabular-nums rounded-full px-1 min-w-[16px] text-center`,t?`bg-background/40`:`bg-muted/30 opacity-70`),"data-testid":`specs-status-count-${e}`,children:n})]})}function bx({value:e,onChange:t,counts:n,className:r}){let{t:i}=K(`specs`),a=cx.filter(e=>lx.has(e)).reduce((e,t)=>e+n[t],0),o=cx.reduce((e,t)=>e+n[t],0),s=e=>e===`active`?a:e===`all`?o:n[e];return(0,Y.jsxs)(`div`,{role:`tablist`,"aria-label":i(`statusFilter.ariaLabel`),"data-testid":`specs-status-filter`,className:X(`flex items-center gap-1 min-w-0 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,r),children:[[`active`,`all`].map(n=>(0,Y.jsx)(yx,{value:n,selected:e===n,count:s(n),onClick:()=>t(n),label:i(vx[n])},n)),(0,Y.jsx)(`div`,{className:`h-4 w-px bg-border/50 shrink-0 mx-0.5`,"aria-hidden":!0}),cx.map(n=>(0,Y.jsx)(yx,{value:n,selected:e===n,count:s(n),onClick:()=>t(n),label:i(vx[n])},n))]})}var xx=[...cx,`other`],Sx={draft:`common:status.draft`,todo:`status.todo`,in_progress:`status.inProgress`,on_review:`status.onReview`,done:`status.done`,cancelled:`status.cancelled`};function Cx({tickets:e,active:t,onChange:n,className:r}){let{t:i}=K(`specs`),[a,o]=(0,H.useState)(!1),s=(0,H.useRef)(null),c=(0,H.useRef)(null),{groups:l,total:u}=(0,H.useMemo)(()=>{let t=new Map,n=0;for(let r of e){if(!r.jira_status)continue;n+=1;let e=t.get(r.jira_status);e||(e=new Map,t.set(r.jira_status,e)),e.set(r.status,(e.get(r.status)??0)+1)}let r=[];for(let[e,n]of t){let t=0,i=`other`,a=0,o=!1;for(let e of cx){let r=n.get(e)??0;t+=r,r>a?(i=e,a=r,o=!1):r===a&&r>0&&(o=!0)}r.push({name:e,count:t,logical:o?`other`:i})}let i=new Map;for(let e of xx){let t=r.filter(t=>t.logical===e).sort((e,t)=>t.count===e.count?e.name.localeCompare(t.name):t.count-e.count);t.length>0&&i.set(e,t)}return{groups:i,total:n}},[e]);(0,H.useEffect)(()=>{if(!a)return;function e(e){c.current?.contains(e.target)||s.current?.contains(e.target)||o(!1)}function t(e){e.key===`Escape`&&o(!1)}return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[a]);function d(e){n(e),o(!1)}let f=(0,H.useMemo)(()=>{if(!t)return null;for(let[e,n]of l)if(n.some(e=>e.name===t))return e;return`other`},[t,l]);return(0,Y.jsxs)(`div`,{className:X(`relative shrink-0`,r),children:[(0,Y.jsxs)(`button`,{ref:s,type:`button`,"aria-haspopup":`listbox`,"aria-expanded":a,"aria-label":i(`jiraStatusFilter.ariaLabel`),"data-testid":`spec-jira-status-filter-dropdown`,onClick:()=>o(e=>!e),className:X(`flex items-center gap-1.5 h-6 px-2 rounded-full text-[11px] font-medium border transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-info/50`,t?`bg-accent-info/10 border-accent-info/40 text-accent-info hover:bg-accent-info/20`:`bg-transparent border-border/60 text-muted-foreground hover:text-foreground hover:bg-muted/40`),children:[(0,Y.jsx)(mc,{className:`w-3 h-3`}),t&&f&&f!==`other`&&(0,Y.jsx)(ox,{status:f,className:`w-2 h-2`}),(0,Y.jsx)(`span`,{className:`truncate max-w-[140px]`,children:t??i(`jiraStatusFilter.triggerLabel`)})]}),a&&(0,Y.jsxs)(`div`,{ref:c,role:`listbox`,"data-testid":`spec-jira-status-filter-panel`,className:`absolute z-40 left-0 mt-1 w-64 max-h-80 overflow-y-auto rounded-xl border border-border/60 bg-card/95 backdrop-blur shadow-xl shadow-black/30 p-1`,children:[(0,Y.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t===null,onClick:()=>d(null),"data-testid":`spec-jira-status-filter-all`,className:X(`w-full flex items-center gap-2 px-2 py-1.5 rounded-lg text-left text-xs hover:bg-accent-info/10 transition-colors`,t===null&&`bg-accent-info/10 text-accent-info`),children:[(0,Y.jsx)(`span`,{className:`inline-flex w-4 h-4 items-center justify-center`,children:t===null&&(0,Y.jsx)(to,{className:`w-3 h-3 text-accent-info`})}),(0,Y.jsx)(`span`,{className:`flex-1`,children:i(`jiraStatusFilter.all`)}),(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground/70 tabular-nums`,children:u})]}),xx.map(e=>{let n=l.get(e);if(!n)return null;let r=e===`other`;return(0,Y.jsxs)(`div`,{"data-testid":`spec-jira-status-group-${e}`,children:[(0,Y.jsxs)(`div`,{className:X(`flex items-center gap-1.5 px-2 pt-2 pb-1 text-[10px] font-semibold uppercase tracking-wide`,r?`text-muted-foreground/50`:`text-muted-foreground/80`),"aria-hidden":!0,children:[!r&&(0,Y.jsx)(ox,{status:e,className:`w-2 h-2`}),(0,Y.jsx)(`span`,{children:i(r?`jiraStatusFilter.other`:Sx[e])})]}),n.map(e=>{let n=t===e.name;return(0,Y.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":n,onClick:()=>d(e.name),"data-testid":`spec-jira-status-option-${e.name}`,className:X(`w-full flex items-center gap-2 px-2 py-1.5 rounded-lg text-left text-xs hover:bg-muted/30 transition-colors`,n&&`bg-accent-info/5`,r&&`opacity-70`),children:[(0,Y.jsx)(`span`,{className:`inline-flex w-4 h-4 items-center justify-center`,children:n&&(0,Y.jsx)(to,{className:`w-3 h-3 text-accent-info`})}),(0,Y.jsx)(`span`,{className:`truncate text-foreground/80`,children:e.name}),(0,Y.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground/60 tabular-nums`,children:e.count})]},e.name)})]},e)})]})]})}function wx(e,[t,n]){return Math.min(n,Math.max(t,e))}function Tx(e){let t=Ex(e),n=H.forwardRef((e,n)=>{let{children:r,...i}=e,a=H.Children.toArray(r),o=a.find(Ox);if(o){let e=o.props.children,r=a.map(t=>t===o?H.Children.count(e)>1?H.Children.only(null):H.isValidElement(e)?e.props.children:null:t);return(0,Y.jsx)(t,{...i,ref:n,children:H.isValidElement(e)?H.cloneElement(e,void 0,r):null})}return(0,Y.jsx)(t,{...i,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}function Ex(e){let t=H.forwardRef((e,t)=>{let{children:n,...r}=e;if(H.isValidElement(n)){let e=Ax(n),i=kx(r,n.props);return n.type!==H.Fragment&&(i.ref=t?Om(t,e):e),H.cloneElement(n,i)}return H.Children.count(n)>1?H.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Dx=Symbol(`radix.slottable`);function Ox(e){return H.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===Dx}function kx(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function Ax(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function jx(e){let t=e+`CollectionProvider`,[n,r]=$g(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=e=>{let{scope:t,children:n}=e,r=H.useRef(null),a=H.useRef(new Map).current;return(0,Y.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})};o.displayName=t;let s=e+`CollectionSlot`,c=Tx(s),l=H.forwardRef((e,t)=>{let{scope:n,children:r}=e;return(0,Y.jsx)(c,{ref:km(t,a(s,n).collectionRef),children:r})});l.displayName=s;let u=e+`CollectionItemSlot`,d=`data-radix-collection-item`,f=Tx(u),p=H.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=H.useRef(null),s=km(t,o),c=a(u,n);return H.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,Y.jsx)(f,{[d]:``,ref:s,children:r})});p.displayName=u;function m(t){let n=a(e+`CollectionConsumer`,t);return H.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${d}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return[{Provider:o,Slot:l,ItemSlot:p},m,r]}var Mx=H.createContext(void 0);function Nx(e){let t=H.useContext(Mx);return e||t||`ltr`}var Px=[`top`,`right`,`bottom`,`left`],Fx=Math.min,Ix=Math.max,Lx=Math.round,Rx=Math.floor,zx=e=>({x:e,y:e}),Bx={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function Vx(e,t,n){return Ix(e,Fx(t,n))}function Hx(e,t){return typeof e==`function`?e(t):e}function Ux(e){return e.split(`-`)[0]}function Wx(e){return e.split(`-`)[1]}function Gx(e){return e===`x`?`y`:`x`}function Kx(e){return e===`y`?`height`:`width`}function qx(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function Jx(e){return Gx(qx(e))}function Yx(e,t,n){n===void 0&&(n=!1);let r=Wx(e),i=Jx(e),a=Kx(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=iS(o)),[o,iS(o)]}function Xx(e){let t=iS(e);return[Zx(e),t,Zx(t)]}function Zx(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var Qx=[`left`,`right`],$x=[`right`,`left`],eS=[`top`,`bottom`],tS=[`bottom`,`top`];function nS(e,t,n){switch(e){case`top`:case`bottom`:return n?t?$x:Qx:t?Qx:$x;case`left`:case`right`:return t?eS:tS;default:return[]}}function rS(e,t,n,r){let i=Wx(e),a=nS(Ux(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(Zx)))),a}function iS(e){let t=Ux(e);return Bx[t]+e.slice(t.length)}function aS(e){return{top:0,right:0,bottom:0,left:0,...e}}function oS(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:aS(e)}function sS(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function cS(e,t,n){let{reference:r,floating:i}=e,a=qx(t),o=Jx(t),s=Kx(o),c=Ux(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}switch(Wx(t)){case`start`:p[o]-=f*(n&&l?-1:1);break;case`end`:p[o]+=f*(n&&l?-1:1);break}return p}async function lS(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=Hx(t,e),p=oS(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=sS(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=sS(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var uS=50,dS=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:lS},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=cS(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<uS&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=cS(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},fS=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=Hx(e,t)||{};if(l==null)return{};let d=oS(u),f={x:n,y:r},p=Jx(i),m=Kx(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),C=S?S[y]:0;(!C||!await(o.isElement==null?void 0:o.isElement(S)))&&(C=s.floating[y]||a.floating[m]);let w=b/2-x/2,T=C/2-h[m]/2-1,E=Fx(d[_],T),D=Fx(d[v],T),O=E,k=C-h[m]-D,A=C/2-h[m]/2+w,j=Vx(O,A,k),M=!c.arrow&&Wx(i)!=null&&A!==j&&a.reference[m]/2-(A<O?E:D)-h[m]/2<0,N=M?A<O?A-O:A-k:0;return{[p]:f[p]+N,data:{[p]:j,centerOffset:A-j-N,...M&&{alignmentOffset:N}},reset:M}}}),pS=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=Hx(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=Ux(r),_=qx(o),v=Ux(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[iS(o)]:Xx(o)),x=p!==`none`;!d&&x&&b.push(...rS(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=Yx(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(!(u===`alignment`&&_!==qx(t))||T.every(e=>qx(e.placement)===_?e.overflows[0]>0:!0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=qx(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o;break}if(r!==n)return{reset:{placement:n}}}return{}}}};function mS(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function hS(e){return Px.some(t=>e[t]>=0)}var gS=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=Hx(e,t);switch(i){case`referenceHidden`:{let e=mS(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:hS(e)}}}case`escaped`:{let e=mS(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:hS(e)}}}default:return{}}}}},_S=new Set([`left`,`top`]);async function vS(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=Ux(n),s=Wx(n),c=qx(n)===`y`,l=_S.has(o)?-1:1,u=a&&c?-1:1,d=Hx(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var yS=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await vS(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},bS=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=Hx(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=qx(Ux(i)),p=Gx(f),m=u[p],h=u[f];if(o){let e=p===`y`?`top`:`left`,t=p===`y`?`bottom`:`right`,n=m+d[e],r=m-d[t];m=Vx(n,m,r)}if(s){let e=f===`y`?`top`:`left`,t=f===`y`?`bottom`:`right`,n=h+d[e],r=h-d[t];h=Vx(n,h,r)}let g=c.fn({...t,[p]:m,[f]:h});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[p]:o,[f]:s}}}}}},xS=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=Hx(e,t),u={x:n,y:r},d=qx(i),f=Gx(d),p=u[f],m=u[d],h=Hx(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=_S.has(Ux(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},SS=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){var n,r;let{placement:i,rects:a,platform:o,elements:s}=t,{apply:c=()=>{},...l}=Hx(e,t),u=await o.detectOverflow(t,l),d=Ux(i),f=Wx(i),p=qx(i)===`y`,{width:m,height:h}=a.floating,g,_;d===`top`||d===`bottom`?(g=d,_=f===(await(o.isRTL==null?void 0:o.isRTL(s.floating))?`start`:`end`)?`left`:`right`):(_=d,g=f===`end`?`top`:`bottom`);let v=h-u.top-u.bottom,y=m-u.left-u.right,b=Fx(h-u[g],v),x=Fx(m-u[_],y),S=!t.middlewareData.shift,C=b,w=x;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(w=y),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(C=v),S&&!f){let e=Ix(u.left,0),t=Ix(u.right,0),n=Ix(u.top,0),r=Ix(u.bottom,0);p?w=m-2*(e!==0||t!==0?e+t:Ix(u.left,u.right)):C=h-2*(n!==0||r!==0?n+r:Ix(u.top,u.bottom))}await c({...t,availableWidth:w,availableHeight:C});let T=await o.getDimensions(s.floating);return m!==T.width||h!==T.height?{reset:{rects:!0}}:{}}}};function CS(){return typeof window<`u`}function wS(e){return DS(e)?(e.nodeName||``).toLowerCase():`#document`}function TS(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function ES(e){return((DS(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function DS(e){return CS()?e instanceof Node||e instanceof TS(e).Node:!1}function OS(e){return CS()?e instanceof Element||e instanceof TS(e).Element:!1}function kS(e){return CS()?e instanceof HTMLElement||e instanceof TS(e).HTMLElement:!1}function AS(e){return!CS()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof TS(e).ShadowRoot}function jS(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=HS(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function MS(e){return/^(table|td|th)$/.test(wS(e))}function NS(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var PS=/transform|translate|scale|rotate|perspective|filter/,FS=/paint|layout|strict|content/,IS=e=>!!e&&e!==`none`,LS;function RS(e){let t=OS(e)?HS(e):e;return IS(t.transform)||IS(t.translate)||IS(t.scale)||IS(t.rotate)||IS(t.perspective)||!BS()&&(IS(t.backdropFilter)||IS(t.filter))||PS.test(t.willChange||``)||FS.test(t.contain||``)}function zS(e){let t=WS(e);for(;kS(t)&&!VS(t);){if(RS(t))return t;if(NS(t))return null;t=WS(t)}return null}function BS(){return LS??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),LS}function VS(e){return/^(html|body|#document)$/.test(wS(e))}function HS(e){return TS(e).getComputedStyle(e)}function US(e){return OS(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function WS(e){if(wS(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||AS(e)&&e.host||ES(e);return AS(t)?t.host:t}function GS(e){let t=WS(e);return VS(t)?e.ownerDocument?e.ownerDocument.body:e.body:kS(t)&&jS(t)?t:GS(t)}function KS(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=GS(e),i=r===e.ownerDocument?.body,a=TS(r);if(i){let e=qS(a);return t.concat(a,a.visualViewport||[],jS(r)?r:[],e&&n?KS(e):[])}else return t.concat(r,KS(r,[],n))}function qS(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function JS(e){let t=HS(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=kS(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=Lx(n)!==a||Lx(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function YS(e){return OS(e)?e:e.contextElement}function XS(e){let t=YS(e);if(!kS(t))return zx(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=JS(t),o=(a?Lx(n.width):n.width)/r,s=(a?Lx(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var ZS=zx(0);function QS(e){let t=TS(e);return!BS()||!t.visualViewport?ZS:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function $S(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==TS(e)?!1:t}function eC(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=YS(e),o=zx(1);t&&(r?OS(r)&&(o=XS(r)):o=XS(e));let s=$S(a,n,r)?QS(a):zx(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a){let e=TS(a),t=r&&OS(r)?TS(r):r,n=e,i=qS(n);for(;i&&r&&t!==n;){let e=XS(i),t=i.getBoundingClientRect(),r=HS(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=TS(i),i=qS(n)}}return sS({width:u,height:d,x:c,y:l})}function tC(e,t){let n=US(e).scrollLeft;return t?t.left+n:eC(ES(e)).left+n}function nC(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-tC(e,n),y:n.top+t.scrollTop}}function rC(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=ES(r),s=t?NS(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=zx(1),u=zx(0),d=kS(r);if((d||!d&&!a)&&((wS(r)!==`body`||jS(o))&&(c=US(r)),d)){let e=eC(r);l=XS(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?nC(o,c):zx(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function iC(e){return Array.from(e.getClientRects())}function aC(e){let t=ES(e),n=US(e),r=e.ownerDocument.body,i=Ix(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=Ix(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight),o=-n.scrollLeft+tC(e),s=-n.scrollTop;return HS(r).direction===`rtl`&&(o+=Ix(t.clientWidth,r.clientWidth)-i),{width:i,height:a,x:o,y:s}}var oC=25;function sC(e,t){let n=TS(e),r=ES(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;let e=BS();(!e||e&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}let l=tC(r);if(l<=0){let e=r.ownerDocument,t=e.body,n=getComputedStyle(t),i=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,o=Math.abs(r.clientWidth-t.clientWidth-i);o<=oC&&(a-=o)}else l<=oC&&(a+=l);return{width:a,height:o,x:s,y:c}}function cC(e,t){let n=eC(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=kS(e)?XS(e):zx(1);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function lC(e,t,n){let r;if(t===`viewport`)r=sC(e,n);else if(t===`document`)r=aC(ES(e));else if(OS(t))r=cC(t,n);else{let n=QS(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return sS(r)}function uC(e,t){let n=WS(e);return n===t||!OS(n)||VS(n)?!1:HS(n).position===`fixed`||uC(n,t)}function dC(e,t){let n=t.get(e);if(n)return n;let r=KS(e,[],!1).filter(e=>OS(e)&&wS(e)!==`body`),i=null,a=HS(e).position===`fixed`,o=a?WS(e):e;for(;OS(o)&&!VS(o);){let t=HS(o),n=RS(o);!n&&t.position===`fixed`&&(i=null),(a?!n&&!i:!n&&t.position===`static`&&i&&(i.position===`absolute`||i.position===`fixed`)||jS(o)&&!n&&uC(e,o))?r=r.filter(e=>e!==o):i=t,o=WS(o)}return t.set(e,r),r}function fC(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?NS(t)?[]:dC(t,this._c):[].concat(n),r],o=lC(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=lC(t,a[e],i);s=Ix(n.top,s),c=Fx(n.right,c),l=Fx(n.bottom,l),u=Ix(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function pC(e){let{width:t,height:n}=JS(e);return{width:t,height:n}}function mC(e,t,n){let r=kS(t),i=ES(t),a=n===`fixed`,o=eC(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=zx(0);function l(){c.x=tC(i)}if(r||!r&&!a)if((wS(t)!==`body`||jS(i))&&(s=US(t)),r){let e=eC(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}else i&&l();a&&!r&&i&&l();let u=i&&!r&&!a?nC(i,s):zx(0);return{x:o.left+s.scrollLeft-c.x-u.x,y:o.top+s.scrollTop-c.y-u.y,width:o.width,height:o.height}}function hC(e){return HS(e).position===`static`}function gC(e,t){if(!kS(e)||HS(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return ES(e)===n&&(n=n.ownerDocument.body),n}function _C(e,t){let n=TS(e);if(NS(e))return n;if(!kS(e)){let t=WS(e);for(;t&&!VS(t);){if(OS(t)&&!hC(t))return t;t=WS(t)}return n}let r=gC(e,t);for(;r&&MS(r)&&hC(r);)r=gC(r,t);return r&&VS(r)&&hC(r)&&!RS(r)?n:r||zS(e)||n}var vC=async function(e){let t=this.getOffsetParent||_C,n=this.getDimensions,r=await n(e.floating);return{reference:mC(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function yC(e){return HS(e).direction===`rtl`}var bC={convertOffsetParentRelativeRectToViewportRelativeRect:rC,getDocumentElement:ES,getClippingRect:fC,getOffsetParent:_C,getElementRects:vC,getClientRects:iC,getDimensions:pC,getScale:XS,isElement:OS,isRTL:yC};function xC(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function SC(e,t){let n=null,r,i=ES(e);function a(){var e;clearTimeout(r),(e=n)==null||e.disconnect(),n=null}function o(s,c){s===void 0&&(s=!1),c===void 0&&(c=1),a();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(s||t(),!f||!p)return;let m=Rx(d),h=Rx(i.clientWidth-(u+f)),g=Rx(i.clientHeight-(d+p)),_=Rx(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:Ix(0,Fx(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(n!==c){if(!y)return o();n?o(!1,n):r=setTimeout(()=>{o(!1,1e-7)},1e3)}n===1&&!xC(l,e.getBoundingClientRect())&&o(),y=!1}try{n=new IntersectionObserver(b,{...v,root:i.ownerDocument})}catch{n=new IntersectionObserver(b,v)}n.observe(e)}return o(!0),a}function CC(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=YS(e),u=i||a?[...l?KS(l):[],...t?KS(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n,{passive:!0}),a&&e.addEventListener(`resize`,n)});let d=l&&s?SC(l,n):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?eC(e):null;c&&g();function g(){let t=eC(e);h&&!xC(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var wC=yS,TC=bS,EC=pS,DC=SS,OC=gS,kC=fS,AC=xS,jC=(e,t,n)=>{let r=new Map,i={platform:bC,...n},a={...i.platform,_c:r};return dS(e,t,{...i,platform:a})},MC=typeof document<`u`?H.useLayoutEffect:function(){};function NC(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!NC(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!NC(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function PC(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function FC(e,t){let n=PC(e);return Math.round(t*n)/n}function IC(e){let t=H.useRef(e);return MC(()=>{t.current=e}),t}function LC(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=H.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=H.useState(r);NC(f,r)||p(r);let[m,h]=H.useState(null),[g,_]=H.useState(null),v=H.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=H.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=H.useRef(null),C=H.useRef(null),w=H.useRef(u),T=c!=null,E=IC(c),D=IC(i),O=IC(l),k=H.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),jC(S.current,C.current,e).then(e=>{let t={...e,isPositioned:O.current!==!1};A.current&&!NC(w.current,t)&&(w.current=t,sr.flushSync(()=>{d(t)}))})},[f,t,n,D,O]);MC(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let A=H.useRef(!1);MC(()=>(A.current=!0,()=>{A.current=!1}),[]),MC(()=>{if(b&&(S.current=b),x&&(C.current=x),b&&x){if(E.current)return E.current(b,x,k);k()}},[b,x,k,E,T]);let j=H.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),M=H.useMemo(()=>({reference:b,floating:x}),[b,x]),N=H.useMemo(()=>{let e={position:n,left:0,top:0};if(!M.floating)return e;let t=FC(M.floating,u.x),r=FC(M.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...PC(M.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,M.floating,u.x,u.y]);return H.useMemo(()=>({...u,update:k,refs:j,elements:M,floatingStyles:N}),[u,k,j,M,N])}var RC=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:kC({element:r.current,padding:i}).fn(n):r?kC({element:r,padding:i}).fn(n):{}}}},zC=(e,t)=>{let n=wC(e);return{name:n.name,fn:n.fn,options:[e,t]}},BC=(e,t)=>{let n=TC(e);return{name:n.name,fn:n.fn,options:[e,t]}},VC=(e,t)=>({fn:AC(e).fn,options:[e,t]}),HC=(e,t)=>{let n=EC(e);return{name:n.name,fn:n.fn,options:[e,t]}},UC=(e,t)=>{let n=DC(e);return{name:n.name,fn:n.fn,options:[e,t]}},WC=(e,t)=>{let n=OC(e);return{name:n.name,fn:n.fn,options:[e,t]}},GC=(e,t)=>{let n=RC(e);return{name:n.name,fn:n.fn,options:[e,t]}},KC=`Arrow`,qC=H.forwardRef((e,t)=>{let{children:n,width:r=10,height:i=5,...a}=e;return(0,Y.jsx)(h_.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,Y.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})});qC.displayName=KC;var JC=qC;function YC(e){let[t,n]=H.useState(void 0);return t_(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}else n(void 0)},[e]),t}var XC=`Popper`,[ZC,QC]=$g(XC),[$C,ew]=ZC(XC),tw=e=>{let{__scopePopper:t,children:n}=e,[r,i]=H.useState(null);return(0,Y.jsx)($C,{scope:t,anchor:r,onAnchorChange:i,children:n})};tw.displayName=XC;var nw=`PopperAnchor`,rw=H.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...i}=e,a=ew(nw,n),o=H.useRef(null),s=km(t,o),c=H.useRef(null);return H.useEffect(()=>{let e=c.current;c.current=r?.current||o.current,e!==c.current&&a.onAnchorChange(c.current)}),r?null:(0,Y.jsx)(h_.div,{...i,ref:s})});rw.displayName=nw;var iw=`PopperContent`,[aw,ow]=ZC(iw),sw=H.forwardRef((e,t)=>{let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:o=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:u=0,sticky:d=`partial`,hideWhenDetached:f=!1,updatePositionStrategy:p=`optimized`,onPlaced:m,...h}=e,g=ew(iw,n),[_,v]=H.useState(null),y=km(t,e=>v(e)),[b,x]=H.useState(null),S=YC(b),C=S?.width??0,w=S?.height??0,T=r+(a===`center`?``:`-`+a),E=typeof u==`number`?u:{top:0,right:0,bottom:0,left:0,...u},D=Array.isArray(l)?l:[l],O=D.length>0,k={padding:E,boundary:D.filter(dw),altBoundary:O},{refs:A,floatingStyles:j,placement:M,isPositioned:N,middlewareData:P}=LC({strategy:`fixed`,placement:T,whileElementsMounted:(...e)=>CC(...e,{animationFrame:p===`always`}),elements:{reference:g.anchor},middleware:[zC({mainAxis:i+w,alignmentAxis:o}),c&&BC({mainAxis:!0,crossAxis:!1,limiter:d===`partial`?VC():void 0,...k}),c&&HC({...k}),UC({...k,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)}}),b&&GC({element:b,padding:s}),fw({arrowWidth:C,arrowHeight:w}),f&&WC({strategy:`referenceHidden`,...k})]}),[F,I]=pw(M),L=__(m);t_(()=>{N&&L?.()},[N,L]);let R=P.arrow?.x,z=P.arrow?.y,ee=P.arrow?.centerOffset!==0,[te,B]=H.useState();return t_(()=>{_&&B(window.getComputedStyle(_).zIndex)},[_]),(0,Y.jsx)(`div`,{ref:A.setFloating,"data-radix-popper-content-wrapper":``,style:{...j,transform:N?j.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:te,"--radix-popper-transform-origin":[P.transformOrigin?.x,P.transformOrigin?.y].join(` `),...P.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,Y.jsx)(aw,{scope:n,placedSide:F,onArrowChange:x,arrowX:R,arrowY:z,shouldHideArrow:ee,children:(0,Y.jsx)(h_.div,{"data-side":F,"data-align":I,...h,ref:y,style:{...h.style,animation:N?void 0:`none`}})})})});sw.displayName=iw;var cw=`PopperArrow`,lw={top:`bottom`,right:`left`,bottom:`top`,left:`right`},uw=H.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=ow(cw,n),a=lw[i.placedSide];return(0,Y.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,Y.jsx)(JC,{...r,ref:t,style:{...r.style,display:`block`}})})});uw.displayName=cw;function dw(e){return e!==null}var fw=e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=pw(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}});function pw(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var mw=tw,hw=rw,gw=sw,_w=uw;function vw(e){let t=yw(e),n=H.forwardRef((e,n)=>{let{children:r,...i}=e,a=H.Children.toArray(r),o=a.find(xw);if(o){let e=o.props.children,r=a.map(t=>t===o?H.Children.count(e)>1?H.Children.only(null):H.isValidElement(e)?e.props.children:null:t);return(0,Y.jsx)(t,{...i,ref:n,children:H.isValidElement(e)?H.cloneElement(e,void 0,r):null})}return(0,Y.jsx)(t,{...i,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}function yw(e){let t=H.forwardRef((e,t)=>{let{children:n,...r}=e;if(H.isValidElement(n)){let e=Cw(n),i=Sw(r,n.props);return n.type!==H.Fragment&&(i.ref=t?Om(t,e):e),H.cloneElement(n,i)}return H.Children.count(n)>1?H.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var bw=Symbol(`radix.slottable`);function xw(e){return H.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===bw}function Sw(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function Cw(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function ww(e){let t=H.useRef({value:e,previous:e});return H.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Tw=Object.freeze({position:`absolute`,border:0,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,wordWrap:`normal`}),Ew=`VisuallyHidden`,Dw=H.forwardRef((e,t)=>(0,Y.jsx)(h_.span,{...e,ref:t,style:{...Tw,...e.style}}));Dw.displayName=Ew;var Cee=Dw,wee=[` `,`Enter`,`ArrowUp`,`ArrowDown`],Tee=[` `,`Enter`],Ow=`Select`,[kw,Aw,Eee]=jx(Ow),[jw,Dee]=$g(Ow,[Eee,QC]),Mw=QC(),[Oee,Nw]=jw(Ow),[kee,Aee]=jw(Ow),Pw=e=>{let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:c,dir:l,name:u,autoComplete:d,disabled:f,required:p,form:m}=e,h=Mw(t),[g,_]=H.useState(null),[v,y]=H.useState(null),[b,x]=H.useState(!1),S=Nx(l),[C,w]=o_({prop:r,defaultProp:i??!1,onChange:a,caller:Ow}),[T,E]=o_({prop:o,defaultProp:s,onChange:c,caller:Ow}),D=H.useRef(null),O=g?m||!!g.closest(`form`):!0,[k,A]=H.useState(new Set),j=Array.from(k).map(e=>e.props.value).join(`;`);return(0,Y.jsx)(mw,{...h,children:(0,Y.jsxs)(Oee,{required:p,scope:t,trigger:g,onTriggerChange:_,valueNode:v,onValueNodeChange:y,valueNodeHasChildren:b,onValueNodeHasChildrenChange:x,contentId:i_(),value:T,onValueChange:E,open:C,onOpenChange:w,dir:S,triggerPointerDownPosRef:D,disabled:f,children:[(0,Y.jsx)(kw.Provider,{scope:t,children:(0,Y.jsx)(kee,{scope:e.__scopeSelect,onNativeOptionAdd:H.useCallback(e=>{A(t=>new Set(t).add(e))},[]),onNativeOptionRemove:H.useCallback(e=>{A(t=>{let n=new Set(t);return n.delete(e),n})},[]),children:n})}),O?(0,Y.jsxs)(ST,{"aria-hidden":!0,required:p,tabIndex:-1,name:u,autoComplete:d,value:T,onChange:e=>E(e.target.value),disabled:f,form:m,children:[T===void 0?(0,Y.jsx)(`option`,{value:``}):null,Array.from(k)]},j):null]})})};Pw.displayName=Ow;var Fw=`SelectTrigger`,Iw=H.forwardRef((e,t)=>{let{__scopeSelect:n,disabled:r=!1,...i}=e,a=Mw(n),o=Nw(Fw,n),s=o.disabled||r,c=km(t,o.onTriggerChange),l=Aw(n),u=H.useRef(`touch`),[d,f,p]=wT(e=>{let t=l().filter(e=>!e.disabled),n=TT(t,e,t.find(e=>e.value===o.value));n!==void 0&&o.onValueChange(n.value)}),m=e=>{s||(o.onOpenChange(!0),p()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return(0,Y.jsx)(hw,{asChild:!0,...a,children:(0,Y.jsx)(h_.button,{type:`button`,role:`combobox`,"aria-controls":o.contentId,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":`none`,dir:o.dir,"data-state":o.open?`open`:`closed`,disabled:s,"data-disabled":s?``:void 0,"data-placeholder":CT(o.value)?``:void 0,...i,ref:c,onClick:Zg(i.onClick,e=>{e.currentTarget.focus(),u.current!==`mouse`&&m(e)}),onPointerDown:Zg(i.onPointerDown,e=>{u.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(m(e),e.preventDefault())}),onKeyDown:Zg(i.onKeyDown,e=>{let t=d.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&f(e.key),!(t&&e.key===` `)&&wee.includes(e.key)&&(m(),e.preventDefault())})})})});Iw.displayName=Fw;var Lw=`SelectValue`,Rw=H.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...s}=e,c=Nw(Lw,n),{onValueNodeHasChildrenChange:l}=c,u=a!==void 0,d=km(t,c.onValueNodeChange);return t_(()=>{l(u)},[l,u]),(0,Y.jsx)(h_.span,{...s,ref:d,style:{pointerEvents:`none`},children:CT(c.value)?(0,Y.jsx)(Y.Fragment,{children:o}):a})});Rw.displayName=Lw;var jee=`SelectIcon`,zw=H.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,...i}=e;return(0,Y.jsx)(h_.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})});zw.displayName=jee;var Mee=`SelectPortal`,Bw=e=>(0,Y.jsx)(Y_,{asChild:!0,...e});Bw.displayName=Mee;var Vw=`SelectContent`,Hw=H.forwardRef((e,t)=>{let n=Nw(Vw,e.__scopeSelect),[r,i]=H.useState();if(t_(()=>{i(new DocumentFragment)},[]),!n.open){let t=r;return t?sr.createPortal((0,Y.jsx)(Ww,{scope:e.__scopeSelect,children:(0,Y.jsx)(kw.Slot,{scope:e.__scopeSelect,children:(0,Y.jsx)(`div`,{children:e.children})})}),t):null}return(0,Y.jsx)(Kw,{...e,ref:t})});Hw.displayName=Vw;var Uw=10,[Ww,Gw]=jw(Vw),Nee=`SelectContentImpl`,Pee=vw(`SelectContent.RemoveScroll`),Kw=H.forwardRef((e,t)=>{let{__scopeSelect:n,position:r=`item-aligned`,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g,..._}=e,v=Nw(Vw,n),[y,b]=H.useState(null),[x,S]=H.useState(null),C=km(t,e=>b(e)),[w,T]=H.useState(null),[E,D]=H.useState(null),O=Aw(n),[k,A]=H.useState(!1),j=H.useRef(!1);H.useEffect(()=>{if(y)return by(y)},[y]),nv();let M=H.useCallback(e=>{let[t,...n]=O().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&x&&(x.scrollTop=0),n===r&&x&&(x.scrollTop=x.scrollHeight),n?.focus(),document.activeElement!==i))return},[O,x]),N=H.useCallback(()=>M([w,y]),[M,w,y]);H.useEffect(()=>{k&&N()},[k,N]);let{onOpenChange:P,triggerPointerDownPosRef:F}=v;H.useEffect(()=>{if(y){let e={x:0,y:0},t=t=>{e={x:Math.abs(Math.round(t.pageX)-(F.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(F.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():y.contains(n.target)||P(!1),document.removeEventListener(`pointermove`,t),F.current=null};return F.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[y,P,F]),H.useEffect(()=>{let e=()=>P(!1);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[P]);let[I,L]=wT(e=>{let t=O().filter(e=>!e.disabled),n=TT(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current.focus())}),R=H.useCallback((e,t,n)=>{let r=!j.current&&!n;(v.value!==void 0&&v.value===t||r)&&(T(e),r&&(j.current=!0))},[v.value]),z=H.useCallback(()=>y?.focus(),[y]),ee=H.useCallback((e,t,n)=>{let r=!j.current&&!n;(v.value!==void 0&&v.value===t||r)&&D(e)},[v.value]),te=r===`popper`?Jw:qw,B=te===Jw?{side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g}:{};return(0,Y.jsx)(Ww,{scope:n,content:y,viewport:x,onViewportChange:S,itemRefCallback:R,selectedItem:w,onItemLeave:z,itemTextRefCallback:ee,focusSelectedItem:N,selectedItemText:E,position:r,isPositioned:k,searchRef:I,children:(0,Y.jsx)(fy,{as:Pee,allowPinchZoom:!0,children:(0,Y.jsx)(I_,{asChild:!0,trapped:v.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:Zg(i,e=>{v.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,Y.jsx)(T_,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:(0,Y.jsx)(te,{role:`listbox`,id:v.contentId,"data-state":v.open?`open`:`closed`,dir:v.dir,onContextMenu:e=>e.preventDefault(),..._,...B,onPlaced:()=>A(!0),ref:C,style:{display:`flex`,flexDirection:`column`,outline:`none`,..._.style},onKeyDown:Zg(_.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&L(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=O().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>M(t)),e.preventDefault()}})})})})})})});Kw.displayName=Nee;var Fee=`SelectItemAlignedPosition`,qw=H.forwardRef((e,t)=>{let{__scopeSelect:n,onPlaced:r,...i}=e,a=Nw(Vw,n),o=Gw(Vw,n),[s,c]=H.useState(null),[l,u]=H.useState(null),d=km(t,e=>u(e)),f=Aw(n),p=H.useRef(!1),m=H.useRef(!0),{viewport:h,selectedItem:g,selectedItemText:_,focusSelectedItem:v}=o,y=H.useCallback(()=>{if(a.trigger&&a.valueNode&&s&&l&&h&&g&&_){let e=a.trigger.getBoundingClientRect(),t=l.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=_.getBoundingClientRect();if(a.dir!==`rtl`){let r=i.left-t.left,a=n.left-r,o=e.left-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-Uw,d=wx(a,[Uw,Math.max(Uw,u-l)]);s.style.minWidth=c+`px`,s.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-Uw,d=wx(a,[Uw,Math.max(Uw,u-l)]);s.style.minWidth=c+`px`,s.style.right=d+`px`}let o=f(),c=window.innerHeight-Uw*2,u=h.scrollHeight,d=window.getComputedStyle(l),m=parseInt(d.borderTopWidth,10),v=parseInt(d.paddingTop,10),y=parseInt(d.borderBottomWidth,10),b=parseInt(d.paddingBottom,10),x=m+v+u+b+y,S=Math.min(g.offsetHeight*5,x),C=window.getComputedStyle(h),w=parseInt(C.paddingTop,10),T=parseInt(C.paddingBottom,10),E=e.top+e.height/2-Uw,D=c-E,O=g.offsetHeight/2,k=g.offsetTop+O,A=m+v+k,j=x-A;if(A<=E){let e=o.length>0&&g===o[o.length-1].ref.current;s.style.bottom=`0px`;let t=l.clientHeight-h.offsetTop-h.offsetHeight,n=A+Math.max(D,O+(e?T:0)+t+y);s.style.height=n+`px`}else{let e=o.length>0&&g===o[0].ref.current;s.style.top=`0px`;let t=Math.max(E,m+h.offsetTop+(e?w:0)+O)+j;s.style.height=t+`px`,h.scrollTop=A-E+h.offsetTop}s.style.margin=`${Uw}px 0`,s.style.minHeight=S+`px`,s.style.maxHeight=c+`px`,r?.(),requestAnimationFrame(()=>p.current=!0)}},[f,a.trigger,a.valueNode,s,l,h,g,_,a.dir,r]);t_(()=>y(),[y]);let[b,x]=H.useState();return t_(()=>{l&&x(window.getComputedStyle(l).zIndex)},[l]),(0,Y.jsx)(Lee,{scope:n,contentWrapper:s,shouldExpandOnScrollRef:p,onScrollButtonChange:H.useCallback(e=>{e&&m.current===!0&&(y(),v?.(),m.current=!1)},[y,v]),children:(0,Y.jsx)(`div`,{ref:c,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:b},children:(0,Y.jsx)(h_.div,{...i,ref:d,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})});qw.displayName=Fee;var Iee=`SelectPopperPosition`,Jw=H.forwardRef((e,t)=>{let{__scopeSelect:n,align:r=`start`,collisionPadding:i=Uw,...a}=e,o=Mw(n);return(0,Y.jsx)(gw,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})});Jw.displayName=Iee;var[Lee,Yw]=jw(Vw,{}),Xw=`SelectViewport`,Zw=H.forwardRef((e,t)=>{let{__scopeSelect:n,nonce:r,...i}=e,a=Gw(Xw,n),o=Yw(Xw,n),s=km(t,a.onViewportChange),c=H.useRef(0);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,Y.jsx)(kw.Slot,{scope:n,children:(0,Y.jsx)(h_.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:s,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:Zg(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=o;if(r?.current&&n){let e=Math.abs(c.current-t.scrollTop);if(e>0){let r=window.innerHeight-Uw*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}c.current=t.scrollTop})})})]})});Zw.displayName=Xw;var Qw=`SelectGroup`,[$w,eT]=jw(Qw),tT=H.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=i_();return(0,Y.jsx)($w,{scope:n,id:i,children:(0,Y.jsx)(h_.div,{role:`group`,"aria-labelledby":i,...r,ref:t})})});tT.displayName=Qw;var nT=`SelectLabel`,rT=H.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=eT(nT,n);return(0,Y.jsx)(h_.div,{id:i.id,...r,ref:t})});rT.displayName=nT;var iT=`SelectItem`,[aT,oT]=jw(iT),sT=H.forwardRef((e,t)=>{let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=Nw(iT,n),c=Gw(iT,n),l=s.value===r,[u,d]=H.useState(a??``),[f,p]=H.useState(!1),m=km(t,e=>c.itemRefCallback?.(e,r,i)),h=i_(),g=H.useRef(`touch`),_=()=>{i||(s.onValueChange(r),s.onOpenChange(!1))};if(r===``)throw Error(`A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.`);return(0,Y.jsx)(aT,{scope:n,value:r,disabled:i,textId:h,isSelected:l,onItemTextChange:H.useCallback(e=>{d(t=>t||(e?.textContent??``).trim())},[]),children:(0,Y.jsx)(kw.ItemSlot,{scope:n,value:r,disabled:i,textValue:u,children:(0,Y.jsx)(h_.div,{role:`option`,"aria-labelledby":h,"data-highlighted":f?``:void 0,"aria-selected":l&&f,"data-state":l?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...o,ref:m,onFocus:Zg(o.onFocus,()=>p(!0)),onBlur:Zg(o.onBlur,()=>p(!1)),onClick:Zg(o.onClick,()=>{g.current!==`mouse`&&_()}),onPointerUp:Zg(o.onPointerUp,()=>{g.current===`mouse`&&_()}),onPointerDown:Zg(o.onPointerDown,e=>{g.current=e.pointerType}),onPointerMove:Zg(o.onPointerMove,e=>{g.current=e.pointerType,i?c.onItemLeave?.():g.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Zg(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:Zg(o.onKeyDown,e=>{c.searchRef?.current!==``&&e.key===` `||(Tee.includes(e.key)&&_(),e.key===` `&&e.preventDefault())})})})})});sT.displayName=iT;var cT=`SelectItemText`,lT=H.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,...a}=e,o=Nw(cT,n),s=Gw(cT,n),c=oT(cT,n),l=Aee(cT,n),[u,d]=H.useState(null),f=km(t,e=>d(e),c.onItemTextChange,e=>s.itemTextRefCallback?.(e,c.value,c.disabled)),p=u?.textContent,m=H.useMemo(()=>(0,Y.jsx)(`option`,{value:c.value,disabled:c.disabled,children:p},c.value),[c.disabled,c.value,p]),{onNativeOptionAdd:h,onNativeOptionRemove:g}=l;return t_(()=>(h(m),()=>g(m)),[h,g,m]),(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(h_.span,{id:c.textId,...a,ref:f}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren?sr.createPortal(a.children,o.valueNode):null]})});lT.displayName=cT;var uT=`SelectItemIndicator`,dT=H.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return oT(uT,n).isSelected?(0,Y.jsx)(h_.span,{"aria-hidden":!0,...r,ref:t}):null});dT.displayName=uT;var fT=`SelectScrollUpButton`,pT=H.forwardRef((e,t)=>{let n=Gw(fT,e.__scopeSelect),r=Yw(fT,e.__scopeSelect),[i,a]=H.useState(!1),o=km(t,r.onScrollButtonChange);return t_(()=>{if(n.viewport&&n.isPositioned){let e=function(){a(t.scrollTop>0)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,Y.jsx)(gT,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null});pT.displayName=fT;var mT=`SelectScrollDownButton`,hT=H.forwardRef((e,t)=>{let n=Gw(mT,e.__scopeSelect),r=Yw(mT,e.__scopeSelect),[i,a]=H.useState(!1),o=km(t,r.onScrollButtonChange);return t_(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight;a(Math.ceil(t.scrollTop)<e)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,Y.jsx)(gT,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null});hT.displayName=mT;var gT=H.forwardRef((e,t)=>{let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=Gw(`SelectScrollButton`,n),o=H.useRef(null),s=Aw(n),c=H.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return H.useEffect(()=>()=>c(),[c]),t_(()=>{s().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[s]),(0,Y.jsx)(h_.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:Zg(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:Zg(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:Zg(i.onPointerLeave,()=>{c()})})}),_T=`SelectSeparator`,vT=H.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return(0,Y.jsx)(h_.div,{"aria-hidden":!0,...r,ref:t})});vT.displayName=_T;var yT=`SelectArrow`,bT=H.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Mw(n),a=Nw(yT,n),o=Gw(yT,n);return a.open&&o.position===`popper`?(0,Y.jsx)(_w,{...i,...r,ref:t}):null});bT.displayName=yT;var xT=`SelectBubbleInput`,ST=H.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{let i=H.useRef(null),a=km(r,i),o=ww(t);return H.useEffect(()=>{let e=i.current;if(!e)return;let n=window.HTMLSelectElement.prototype,r=Object.getOwnPropertyDescriptor(n,`value`).set;if(o!==t&&r){let n=new Event(`change`,{bubbles:!0});r.call(e,t),e.dispatchEvent(n)}},[o,t]),(0,Y.jsx)(h_.select,{...n,style:{...Tw,...n.style},ref:a,defaultValue:t})});ST.displayName=xT;function CT(e){return e===``||e===void 0}function wT(e){let t=__(e),n=H.useRef(``),r=H.useRef(0),i=H.useCallback(e=>{let i=n.current+e;t(i),(function e(t){n.current=t,window.clearTimeout(r.current),t!==``&&(r.current=window.setTimeout(()=>e(``),1e3))})(i)},[t]),a=H.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return H.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}function TT(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=ET(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function ET(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var DT=Pw,OT=Iw,kT=Rw,AT=zw,jT=Bw,MT=Hw,NT=Zw,PT=rT,FT=sT,IT=lT,LT=dT,RT=pT,zT=hT,BT=vT,VT=DT,HT=kT,UT=H.forwardRef(({className:e,children:t,...n},r)=>(0,Y.jsxs)(OT,{ref:r,className:X(`flex h-8 w-full items-center justify-between rounded-lg border border-input bg-background px-3 py-1 text-xs ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1`,e),...n,children:[t,(0,Y.jsx)(AT,{asChild:!0,children:(0,Y.jsx)(no,{className:`h-3 w-3 opacity-50`})})]}));UT.displayName=OT.displayName;var WT=H.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(RT,{ref:n,className:X(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,Y.jsx)(ao,{className:`h-3 w-3`})}));WT.displayName=RT.displayName;var GT=H.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(zT,{ref:n,className:X(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,Y.jsx)(no,{className:`h-3 w-3`})}));GT.displayName=zT.displayName;var KT=H.forwardRef(({className:e,children:t,position:n=`popper`,...r},i)=>(0,Y.jsx)(jT,{children:(0,Y.jsxs)(MT,{ref:i,className:X(`relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border border-border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,...r,children:[(0,Y.jsx)(WT,{}),(0,Y.jsx)(NT,{className:X(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]`),children:t}),(0,Y.jsx)(GT,{})]})}));KT.displayName=MT.displayName;var qT=H.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(PT,{ref:n,className:X(`py-1.5 pl-8 pr-2 text-xs font-semibold`,e),...t}));qT.displayName=PT.displayName;var JT=H.forwardRef(({className:e,children:t,...n},r)=>(0,Y.jsxs)(FT,{ref:r,className:X(`relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-xs outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,e),...n,children:[(0,Y.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,Y.jsx)(LT,{children:(0,Y.jsx)(to,{className:`h-3 w-3`})})}),(0,Y.jsx)(IT,{children:t})]}));JT.displayName=FT.displayName;var YT=H.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(BT,{ref:n,className:X(`-mx-1 my-1 h-px bg-muted`,e),...t}));YT.displayName=BT.displayName;var XT=Symbol(`radix.slottable`);function ZT(e){let t=({children:e})=>(0,Y.jsx)(Y.Fragment,{children:e});return t.displayName=`${e}.Slottable`,t.__radixId=XT,t}var[QT,Ree]=$g(`Tooltip`,[QC]),$T=QC(),eE=`TooltipProvider`,tE=700,nE=`tooltip.open`,[rE,iE]=QT(eE),aE=e=>{let{__scopeTooltip:t,delayDuration:n=tE,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=H.useRef(!0),s=H.useRef(!1),c=H.useRef(0);return H.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,Y.jsx)(rE,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:H.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:H.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:s,onPointerInTransitChange:H.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})};aE.displayName=eE;var oE=`Tooltip`,[sE,cE]=QT(oE),lE=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=iE(oE,e.__scopeTooltip),l=$T(t),[u,d]=H.useState(null),f=i_(),p=H.useRef(0),m=o??c.disableHoverableContent,h=s??c.delayDuration,g=H.useRef(!1),[_,v]=o_({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(nE))):c.onClose(),a?.(e)},caller:oE}),y=H.useMemo(()=>_?g.current?`delayed-open`:`instant-open`:`closed`,[_]),b=H.useCallback(()=>{window.clearTimeout(p.current),p.current=0,g.current=!1,v(!0)},[v]),x=H.useCallback(()=>{window.clearTimeout(p.current),p.current=0,v(!1)},[v]),S=H.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{g.current=!0,v(!0),p.current=0},h)},[h,v]);return H.useEffect(()=>()=>{p.current&&=(window.clearTimeout(p.current),0)},[]),(0,Y.jsx)(mw,{...l,children:(0,Y.jsx)(sE,{scope:t,contentId:f,open:_,stateAttribute:y,trigger:u,onTriggerChange:d,onTriggerEnter:H.useCallback(()=>{c.isOpenDelayedRef.current?S():b()},[c.isOpenDelayedRef,S,b]),onTriggerLeave:H.useCallback(()=>{m?x():(window.clearTimeout(p.current),p.current=0)},[x,m]),onOpen:b,onClose:x,disableHoverableContent:m,children:n})})};lE.displayName=oE;var uE=`TooltipTrigger`,dE=H.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=cE(uE,n),a=iE(uE,n),o=$T(n),s=km(t,H.useRef(null),i.onTriggerChange),c=H.useRef(!1),l=H.useRef(!1),u=H.useCallback(()=>c.current=!1,[]);return H.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,Y.jsx)(hw,{asChild:!0,...o,children:(0,Y.jsx)(h_.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:Zg(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:Zg(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:Zg(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:Zg(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:Zg(e.onBlur,i.onClose),onClick:Zg(e.onClick,i.onClose)})})});dE.displayName=uE;var fE=`TooltipPortal`,[pE,mE]=QT(fE,{forceMount:void 0}),hE=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=cE(fE,t);return(0,Y.jsx)(pE,{scope:t,forceMount:n,children:(0,Y.jsx)(Z_,{present:n||a.open,children:(0,Y.jsx)(Y_,{asChild:!0,container:i,children:r})})})};hE.displayName=fE;var gE=`TooltipContent`,_E=H.forwardRef((e,t)=>{let n=mE(gE,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=cE(gE,e.__scopeTooltip);return(0,Y.jsx)(Z_,{present:r||o.open,children:o.disableHoverableContent?(0,Y.jsx)(SE,{side:i,...a,ref:t}):(0,Y.jsx)(vE,{side:i,...a,ref:t})})}),vE=H.forwardRef((e,t)=>{let n=cE(gE,e.__scopeTooltip),r=iE(gE,e.__scopeTooltip),i=H.useRef(null),a=km(t,i),[o,s]=H.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=H.useCallback(()=>{s(null),d(!1)},[d]),p=H.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=EE(r,TE(r,n.getBoundingClientRect())),a=DE(t.getBoundingClientRect());s(kE([...i,...a])),d(!0)},[d]);return H.useEffect(()=>()=>f(),[f]),H.useEffect(()=>{if(c&&u){let e=e=>p(e,u),t=e=>p(e,c);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),H.useEffect(()=>{if(o){let e=e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!OE(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,Y.jsx)(SE,{...e,ref:a})}),[yE,bE]=QT(oE,{isInside:!1}),xE=ZT(`TooltipContent`),SE=H.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=cE(gE,n),l=$T(n),{onClose:u}=c;return H.useEffect(()=>(document.addEventListener(nE,u),()=>document.removeEventListener(nE,u)),[u]),H.useEffect(()=>{if(c.trigger){let e=e=>{e.target?.contains(c.trigger)&&u()};return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[c.trigger,u]),(0,Y.jsx)(T_,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,Y.jsxs)(gw,{"data-state":c.stateAttribute,...l,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,Y.jsx)(xE,{children:r}),(0,Y.jsx)(yE,{scope:n,isInside:!0,children:(0,Y.jsx)(Cee,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});_E.displayName=gE;var CE=`TooltipArrow`,wE=H.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=$T(n);return bE(CE,n).isInside?null:(0,Y.jsx)(_w,{...i,...r,ref:t})});wE.displayName=CE;function TE(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}function EE(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function DE(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function OE(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function kE(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:+(e.y>t.y)),AE(t)}function AE(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var jE=aE,ME=lE,NE=dE,PE=_E,FE=jE,IE=ME,LE=NE,RE=H.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,Y.jsx)(PE,{ref:r,sideOffset:t,className:X(`z-50 overflow-hidden rounded-md border border-border bg-popover px-2.5 py-1.5 text-xs text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...n}));RE.displayName=PE.displayName;var zE={default:`sortControl.modes.default`,"ticket-id":`sortControl.modes.ticketId`,priority:`sortControl.modes.priority`,"jira-key":`sortControl.modes.jiraKey`};function BE({mode:e,dir:t,onChange:n,showJiraSort:r=!1,className:i}){let{t:a}=K(`specs`),o=e!==`default`;return(0,Y.jsx)(FE,{delayDuration:300,children:(0,Y.jsxs)(`div`,{className:X(`flex items-center gap-1 shrink-0`,i),children:[(0,Y.jsxs)(IE,{children:[(0,Y.jsx)(LE,{asChild:!0,children:(0,Y.jsx)(`div`,{children:(0,Y.jsxs)(VT,{value:e,onValueChange:e=>n(e,t),children:[(0,Y.jsxs)(UT,{"aria-label":a(`sortControl.modeAriaLabel`),className:`h-7 w-auto gap-1.5 px-2 text-xs bg-accent-secondary/10 border-accent-secondary/30 hover:bg-accent-secondary/20`,children:[(0,Y.jsx)(Ra,{className:`w-3 h-3 text-muted-foreground`}),(0,Y.jsx)(HT,{children:a(zE[e])})]}),(0,Y.jsxs)(KT,{children:[(0,Y.jsx)(JT,{value:`default`,children:a(`sortControl.modes.default`)}),(0,Y.jsx)(JT,{value:`ticket-id`,children:a(`sortControl.modes.ticketId`)}),(0,Y.jsx)(JT,{value:`priority`,children:a(`sortControl.modes.priority`)}),(r||e===`jira-key`)&&(0,Y.jsx)(JT,{value:`jira-key`,children:a(`sortControl.modes.jiraKey`)})]})]})})}),(0,Y.jsx)(RE,{children:a(`sortControl.tooltip`,{mode:a(zE[e])})})]}),o&&(0,Y.jsxs)(IE,{children:[(0,Y.jsx)(LE,{asChild:!0,children:(0,Y.jsx)(`button`,{type:`button`,"aria-label":a(`sortControl.toggleDirAriaLabel`),onClick:()=>n(e,t===`asc`?`desc`:`asc`),className:`inline-flex items-center justify-center h-7 w-7 rounded-md border border-accent-secondary/30 bg-accent-secondary/10 hover:bg-accent-secondary/20 text-muted-foreground transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2`,children:t===`asc`?(0,Y.jsx)(Ua,{className:`w-3 h-3`}):(0,Y.jsx)(za,{className:`w-3 h-3`})})}),(0,Y.jsx)(RE,{children:a(t===`asc`?`sortControl.ascending`:`sortControl.descending`)})]})]})})}var VE=[{value:`row`,Icon:ss,labelKey:`viewTier.listView`},{value:`postit`,Icon:nc,labelKey:`viewTier.postitView`}];function HE({tier:e,onChange:t,className:n}){let{t:r}=K(`specs`);return(0,Y.jsx)(FE,{delayDuration:300,children:(0,Y.jsx)(`div`,{role:`radiogroup`,"aria-label":r(`viewTier.ariaLabel`),className:X(`inline-flex items-center rounded-md border border-accent-secondary/30 bg-accent-secondary/10 p-0.5 shrink-0`,n),children:VE.map(({value:n,Icon:i,labelKey:a})=>{let o=e===n;return(0,Y.jsxs)(IE,{children:[(0,Y.jsx)(LE,{asChild:!0,children:(0,Y.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":o,"aria-label":r(a),onClick:()=>t(n),className:X(`inline-flex items-center justify-center h-6 w-6 rounded transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-1`,o?`bg-accent-secondary/40 text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent-secondary/20`),"data-testid":`specs-view-tier-${n}`,children:(0,Y.jsx)(i,{className:`w-3.5 h-3.5`})})}),(0,Y.jsx)(RE,{children:r(a)})]},n)})})})}var UE=`default`,WE=`desc`,GE=e=>`specrails-desktop:spec-sort-mode:${e}`,KE=e=>`specrails-desktop:spec-sort-dir:${e}`;function qE(e){return e===`default`||e===`ticket-id`||e===`priority`||e===`jira-key`}function JE(e){return e===`asc`||e===`desc`}function YE(e){if(!e)return{mode:UE,dir:WE};let t=UE,n=WE;try{let n=localStorage.getItem(GE(e));qE(n)&&(t=n)}catch{}try{let t=localStorage.getItem(KE(e));JE(t)&&(n=t)}catch{}return{mode:t,dir:n}}function XE(e,t,n){if(e)try{localStorage.setItem(GE(e),t),localStorage.setItem(KE(e),n)}catch{}}var ZE={critical:4,high:3,medium:2,low:1,null:0};function QE(e){return e===null?ZE.null:ZE[e]}function $E(e,t,n){return n===`asc`?e.id-t.id:t.id-e.id}function eD(e,t,n){let r=QE(e.priority),i=QE(t.priority),a=n===`asc`?r-i:i-r;return a===0?e.id-t.id:a}function tD(e){let t=e.jira_key;if(!t)return null;let n=/(\d+)\s*$/.exec(t);if(!n)return null;let r=Number.parseInt(n[1],10);return Number.isSafeInteger(r)?r:null}function nD(e,t,n){let r=tD(e),i=tD(t);if(r===null&&i===null)return e.id-t.id;if(r===null)return 1;if(i===null)return-1;let a=n===`asc`?r-i:i-r;return a===0?e.id-t.id:a}function rD(e,t,n){return t===`ticket-id`?[...e].sort((e,t)=>$E(e,t,n)):t===`priority`?[...e].sort((e,t)=>eD(e,t,n)):t===`jira-key`?[...e].sort((e,t)=>nD(e,t,n)):e}var iD=e=>`specrails-desktop:spec-filters:${e}`;function aD(e){return e.labels.size===0&&e.epic===null&&e.sprint===null&&e.jiraStatus===null}function oD(e){return typeof e==`string`&&e.length>0?e:null}function sD(){return{labels:new Set,epic:null,sprint:null,jiraStatus:null}}function cD(e){if(!e)return sD();try{let t=localStorage.getItem(iD(e));if(!t)return sD();let n=JSON.parse(t);if(!n||typeof n!=`object`)return sD();let r=n;return{labels:Array.isArray(r.labels)?new Set(r.labels.filter(e=>typeof e==`string`)):new Set,epic:oD(r.epic),sprint:oD(r.sprint),jiraStatus:oD(r.jiraStatus)}}catch{return sD()}}function lD(e,t){if(e)try{if(aD(t)){localStorage.removeItem(iD(e));return}localStorage.setItem(iD(e),JSON.stringify({labels:[...t.labels],epic:t.epic,sprint:t.sprint,jiraStatus:t.jiraStatus}))}catch{}}function uD(e){let t=Math.floor(e/1e3),n=Math.floor(t/60);return n>0?`${n}:${(t%60).toString().padStart(2,`0`)}`:`${t}s`}var dD=`specrails-desktop:pending-specs`;function fD(){try{return JSON.parse(localStorage.getItem(dD)??`[]`)}catch{return[]}}function pD(e){try{let t=fD().filter(t=>t.id!==e.id);t.push(e),localStorage.setItem(dD,JSON.stringify(t))}catch{}}function mD(e){try{let t=fD().filter(t=>t.id!==e);localStorage.setItem(dD,JSON.stringify(t))}catch{}}var hD=(0,H.createContext)(null),gD=40,_D=3e3;function vD({children:e}){let{registerHandler:t,unregisterHandler:n}=df(),{setActiveProjectId:r}=gm(),i=_t(),[a,s]=(0,H.useState)(null),c=(0,H.useRef)(new Map),l=(0,H.useRef)(new Map),u=(0,H.useRef)(new Set),d=(0,H.useRef)(null),{activeProjectId:f}=gm();(0,H.useEffect)(()=>{d.current=f},[f]);let p=(0,H.useCallback)(e=>{e.timerId=setInterval(()=>{q.loading(`${e.projectName} · ${e.truncated}`,{id:e.toastId,description:am.t(`activity:specGen.generating`,{elapsed:uD(Date.now()-e.startTime)})})},1e3)},[]),m=(0,H.useCallback)(e=>{clearInterval(e.timerId),mD(e.persistId),bm(e.projectId)},[]),h=(0,H.useCallback)((e,t)=>{e.projectId===d.current?(s({ticket:t,projectId:e.projectId}),window.location.pathname!==`/`&&i(`/`)):(yc(e.projectId,`/`),s({ticket:t,projectId:e.projectId}),r(e.projectId))},[r,i]),g=(0,H.useRef)(h);(0,H.useEffect)(()=>{g.current=h},[h]);let _=(0,H.useCallback)((e,t)=>{m(e);let n=uD(Date.now()-e.startTime);q.success(`${e.projectName} · ${t.title||am.t(`activity:specGen.specCreated`)}`,{id:e.toastId,duration:1e4,description:am.t(`activity:specGen.generatedIn`,{elapsed:n}),action:{label:am.t(`activity:specGen.view`),onClick:()=>h(e,t)}})},[m,h]),v=(0,H.useCallback)((e,t)=>{m(e),q.error(`${e.projectName} · ${t??am.t(`activity:specGen.errorGenerating`)}`,{id:e.toastId})},[m]),y=(0,H.useCallback)((e,t)=>{let n=0;async function r(){try{let n=await fetch(`${o}/api/projects/${e.projectId}/tickets`);if(!n.ok)throw Error(`fetch failed`);let r=await n.json(),i=(Array.isArray(r)?r:r.tickets??[]).find(t=>!e.knownTicketIds.has(t.id));if(i){t&&l.current.delete(t),_(e,i);return}}catch{}n++,n<5?setTimeout(r,1e3):(t&&l.current.delete(t),v(e,am.t(`activity:specGen.couldNotFind`)))}r()},[_,v]),b=(0,H.useCallback)(e=>{let t={...e,timerId:0};return u.current.add(e.persistId),ym(e.projectId),p(t),pD({id:e.persistId,knownTicketIds:[...e.knownTicketIds],projectId:e.projectId,projectName:e.projectName,startTime:e.startTime,truncated:e.truncated}),t},[p]),x=(0,H.useCallback)((e,t)=>{let n=b(t);c.current.set(e,n)},[b]),S=(0,H.useCallback)((e,t)=>{let n=b(t);l.current.set(e,n)},[b]),C=(0,H.useCallback)(e=>{let t=e;if(!t||typeof t.type!=`string`||t.type!==`spec_gen_done`&&t.type!==`spec_gen_error`)return;let n=t.requestId;if(!n)return;let r=c.current.get(n);r&&(c.current.delete(n),t.type===`spec_gen_done`?_(r,t.ticket):v(r))},[_,v]),w=(0,H.useCallback)(e=>{let t=e;if(!t||typeof t.type!=`string`)return;let n=t.conversationId;if(!n)return;let r=l.current.get(n);if(r){if(t.type===`chat_error`){l.current.delete(n),v(r);return}t.type===`chat_done`&&y(r,n)}},[y,v]),T=(0,H.useCallback)(e=>{let t=e;if(!t||typeof t.type!=`string`||t.type!==`ticket_created`&&t.type!==`ticket_updated`)return;let n=t.ticket;if(!n)return;let r=t.projectId;for(let[e,t]of l.current.entries())r&&t.projectId!==r||t.knownTicketIds.has(n.id)||y(t,e)},[y]);(0,H.useLayoutEffect)(()=>(t(`_tracker_spec_gen`,C),t(`_tracker_chat_done`,w),t(`_tracker_tickets`,T),()=>{n(`_tracker_spec_gen`),n(`_tracker_chat_done`),n(`_tracker_tickets`)}),[C,w,T,t,n]),(0,H.useEffect)(()=>{let e=fD();if(e.length!==0)for(let t of e){if(u.current.has(t.id))continue;u.current.add(t.id);let e=`spec-restore-${t.id}`,n=new Set(t.knownTicketIds),r=()=>{q.loading(`${t.projectName} · ${t.truncated}`,{id:e,description:am.t(`activity:specGen.generating`,{elapsed:uD(Date.now()-t.startTime)})})};r();let i=setInterval(r,1e3);ym(t.projectId);let a=0,s={toastId:e,truncated:t.truncated,knownTicketIds:n,projectId:t.projectId,projectName:t.projectName,startTime:t.startTime,persistId:t.id,timerId:i};async function c(){try{let r=await fetch(`${o}/api/projects/${t.projectId}/tickets`);if(!r.ok)throw Error();let a=await r.json(),c=(Array.isArray(a)?a:a.tickets??[]).find(e=>!n.has(e.id));if(c){clearInterval(i),mD(t.id),bm(t.projectId);let n=uD(Date.now()-t.startTime);q.success(`${t.projectName} · ${c.title||am.t(`activity:specGen.specCreated`)}`,{id:e,duration:1e4,description:am.t(`activity:specGen.generatedIn`,{elapsed:n}),action:{label:am.t(`activity:specGen.view`),onClick:()=>g.current(s,c)}});return}}catch{}a++,a<gD?setTimeout(c,_D):(clearInterval(i),mD(t.id),bm(t.projectId),q.error(`${t.projectName} · ${am.t(`activity:specGen.couldNotConfirm`)}`,{id:e}))}c()}},[]);let E=(0,H.useCallback)(()=>s(null),[]),D=(0,H.useMemo)(()=>({registerFastSpec:x,registerExploreSpec:S,specToOpen:a,clearSpecToOpen:E}),[x,S,a,E]);return(0,Y.jsx)(hD.Provider,{value:D,children:e})}var yD={registerFastSpec:()=>{},registerExploreSpec:()=>{},specToOpen:null,clearSpecToOpen:()=>{}};function bD(){return(0,H.useContext)(hD)??yD}async function xD(e,t,n){let r=new FormData;r.append(`file`,t);let i=await fetch(`${af()}/tickets/${e}/attachments`,{method:`POST`,body:r,signal:n});if(!i.ok){let e=await i.json().catch(()=>({}));throw Error(e.error??am.t(`attachments:errors.uploadFailed`,{status:i.status}))}return(await i.json()).attachment}async function SD(e,t){let n=await fetch(`${af()}/tickets/${e}/attachments/${t}`,{method:`DELETE`});if(!n.ok&&n.status!==404)throw Error(am.t(`attachments:errors.deleteFailed`,{status:n.status}))}async function CD(e){let t=await fetch(`${af()}/tickets/${e}/attachments`,{method:`DELETE`});if(!t.ok&&t.status!==404)throw Error(am.t(`attachments:errors.bulkDeleteFailed`,{status:t.status}))}async function wD(e){let t=await fetch(`${af()}/tickets/${e}/attachments`);if(!t.ok)throw Error(am.t(`attachments:errors.listFailed`,{status:t.status}));return(await t.json()).attachments}function TD(e,t){return`${af()}/tickets/${e}/attachments/${t}`}async function ED(e,t){let n=await fetch(TD(e,t));if(!n.ok)throw Error(am.t(`attachments:errors.fetchFailed`,{status:n.status}));return n.blob()}var DD=`image/jpeg,image/png,image/gif,image/webp,application/pdf,text/csv,text/plain,application/json,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel,application/sql,application/x-sql,text/sql,text/x-sql,.sql`,OD=new Set(DD.split(`,`).filter(e=>!e.startsWith(`.`))),kD=/\.sql$/i,AD=/\.(png|jpe?g|gif|webp)$/i;function jD(e){return OD.has(e.type)||kD.test(e.name)||AD.test(e.name)}function MD(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function ND(e){return e.startsWith(`image/`)?`🖼`:e===`application/pdf`?`📄`:e===`text/csv`||e.includes(`spreadsheetml`)||e===`application/vnd.ms-excel`?`📊`:e===`application/json`?`{ }`:e===`text/plain`||e.includes(`sql`)?`📝`:`📎`}function PD({attachment:e,uploading:t,onRemove:n,onClick:r,index:i=0,className:a}){let{t:o}=K(`attachments`),[s,c]=(0,H.useState)(!1),[l,u]=(0,H.useState)(!1);(0,H.useEffect)(()=>{let e=Math.min(i*50,250),t=setTimeout(()=>c(!0),e);return()=>clearTimeout(t)},[i]);let d=e?.filename??t?.name??o(`chip.genericFile`),f=e?.mimeType??`application/octet-stream`,p=t?o(`chip.uploading`):e?MD(e.size):``;function m(e){e.stopPropagation(),u(!0),setTimeout(()=>n?.(),180)}return(0,Y.jsxs)(`div`,{role:r?`button`:void 0,tabIndex:r?0:void 0,onClick:r,onKeyDown:e=>r&&e.key===`Enter`&&r(),className:X(`group/chip relative inline-flex items-center gap-2 pl-2 pr-1 py-1.5 rounded-lg border border-border bg-card/70 backdrop-blur-sm text-xs shadow-sm`,`transition-all duration-200 ease-out origin-left`,s&&!l?`opacity-100 scale-100 translate-y-0`:`opacity-0 scale-[0.85] translate-y-1`,l&&`max-w-0 overflow-hidden pl-0 pr-0 py-0 border-transparent ml-0 mr-0`,r&&`cursor-pointer hover:border-primary/50`,t&&`animate-pulse`,a),style:l?{maxWidth:0}:void 0,children:[(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`text-sm leading-none shrink-0 w-5 text-center`,children:ND(f)}),(0,Y.jsxs)(`div`,{className:`flex flex-col min-w-0 mr-1`,children:[(0,Y.jsx)(`span`,{className:`font-medium truncate max-w-[160px] text-foreground`,children:d}),(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground leading-tight`,children:p})]}),n&&!t&&(0,Y.jsx)(`button`,{type:`button`,onClick:m,"aria-label":o(`removeFile`,{name:d}),className:`ml-0.5 w-5 h-5 inline-flex items-center justify-center rounded text-muted-foreground hover:text-destructive hover:bg-destructive/10 transition-colors`,children:`×`})]})}function FD(e){let t=[];for(let n=0;n<e.files.length;n++){let r=e.files.item(n);r&&t.push(r)}return t}function ID(e){return`paste-${new Date().toISOString().slice(0,10)}-${e}.png`}function LD(e){let t=document.createElement(`span`);t.setAttribute(`contenteditable`,`false`),t.dataset.attachmentId=e.id,t.dataset.filename=e.filename,t.className=`inline-flex items-center gap-1 px-1.5 py-0.5 mx-0.5 rounded bg-accent/80 hover:bg-accent text-accent-foreground text-xs font-medium align-baseline select-none border border-border shadow-sm transition-all`;let n=document.createElement(`span`);n.textContent=`@${e.filename}`,n.className=`max-w-[180px] truncate`;let r=document.createElement(`button`);return r.type=`button`,r.setAttribute(`aria-label`,am.t(`attachments:removeFile`,{name:e.filename})),r.dataset.role=`pill-remove`,r.className=`text-accent-foreground/60 hover:text-destructive transition-colors leading-none`,r.textContent=`×`,t.appendChild(n),t.appendChild(r),t}function RD(e){return!!e&&e.nodeType===Node.ELEMENT_NODE}function zD(e,t){if(e.nodeType===Node.TEXT_NODE){t.push(e.nodeValue??``);return}if(e.nodeType!==Node.ELEMENT_NODE)return;let n=e;if(n.dataset.attachmentId&&n.dataset.filename){t.push(`@[${n.dataset.filename}](${n.dataset.attachmentId})`);return}if(n.tagName===`BR`){t.push(`
67
67
  `);return}if(n.tagName===`DIV`||n.tagName===`P`){t.length&&!t[t.length-1].endsWith(`
68
68
  `)&&t.push(`
69
69
  `),e.childNodes.forEach(e=>zD(e,t));return}e.childNodes.forEach(e=>zD(e,t))}var BD=(0,H.forwardRef)(function({ticketKey:e,placeholder:t,minHeight:n=120,maxHeight:r=320,ariaLabel:i,autoFocus:a,className:o,disabled:s,onAttachmentAdded:c,onAttachmentRemoved:l,onUnsupportedFile:u,onUploadError:d,onChange:f,onSubmit:p,footerExtra:m},h){let{t:g}=K(`attachments`),_=(0,H.useRef)(null),v=(0,H.useRef)(null),y=(0,H.useRef)(null),b=(0,H.useRef)(!1),x=(0,H.useRef)([]),S=(0,H.useRef)(0),C=(0,H.useRef)(0),[w,T]=(0,H.useState)(!1),[E,D]=(0,H.useState)([]),[O,k]=(0,H.useState)([]),[A,j]=(0,H.useState)(!0),M=(0,H.useCallback)(()=>{let e=_.current;e&&j(e.textContent?.trim().length===0&&e.querySelectorAll(`[data-attachment-id]`).length===0),f?.()},[f]),N=(0,H.useCallback)(()=>{let e=window.getSelection();if(!e||e.rangeCount===0)return;let t=_.current;if(!t)return;let n=e.getRangeAt(0);t.contains(n.commonAncestorContainer)&&(y.current=n.cloneRange())},[]),P=(0,H.useCallback)(()=>{let e=_.current;if(!e)return null;let t=window.getSelection();if(!t)return null;let n;return y.current&&e.contains(y.current.commonAncestorContainer)?n=y.current.cloneRange():(n=document.createRange(),n.selectNodeContents(e),n.collapse(!1)),t.removeAllRanges(),t.addRange(n),n},[]),F=(0,H.useCallback)(e=>{if(!_.current)return;let t=P();if(!t)return;let n=LD(e),r=document.createTextNode(` `),i=document.createTextNode(` `);t.deleteContents(),t.insertNode(i),t.insertNode(n),t.insertNode(r);let a=document.createRange();a.setStartAfter(i),a.collapse(!0);let o=window.getSelection();o?.removeAllRanges(),o?.addRange(a),y.current=a.cloneRange(),M()},[M,P]),I=(0,H.useCallback)(e=>{k(t=>t.some(t=>t.id===e.id)?t:[...t,e]),b.current?x.current.push(e):F(e)},[F]),L=(0,H.useCallback)(e=>{let t=_.current;if(!t)return null;let n=t.querySelector(`[data-attachment-id="${CSS.escape(e)}"]`),r=n?.dataset.filename;return n?.remove(),k(t=>t.find(t=>t.id===e)?t.filter(t=>t.id!==e):t),M(),!n&&!r?O.find(t=>t.id===e)||null:{id:e,filename:r??``}},[O,M]),R=(0,H.useCallback)(async t=>{if(!jD(t)){u?.(t);return}let n=`${Date.now()}-${Math.random().toString(36).slice(2,8)}`;D(e=>[...e,{id:n,name:t.name}]);try{let n=await xD(e,t);I(n),c?.(n)}catch(e){let n=e instanceof Error?e:Error(String(e));d?.(n,t)}finally{D(e=>e.filter(e=>e.id!==n))}},[c,u,d,I,e]),z=(0,H.useCallback)(async e=>{N(),await Promise.all(e.map(R))},[N,R]);(0,H.useImperativeHandle)(h,()=>({getPlainText:()=>{let e=_.current;if(!e)return``;let t=[];return e.childNodes.forEach(e=>zD(e,t)),t.join(``).replace(/​/g,``).trim()},getAttachmentIds:()=>{let e=_.current;return e?Array.from(e.querySelectorAll(`[data-attachment-id]`)).map(e=>e.dataset.attachmentId):[]},insertPill:F,focus:()=>_.current?.focus(),resetHeight:()=>{let e=_.current;e&&(e.style.height=``)},clear:()=>{let e=_.current;e&&(e.innerHTML=``,y.current=null,k([]),M())},setPlainText:e=>{let t=_.current;t&&(t.textContent=e,y.current=null,M())}}),[F,M]);let ee=(0,H.useCallback)(e=>{if(!_.current)return;if(e.key===`Enter`&&(e.metaKey||e.ctrlKey)){e.preventDefault(),p?.();return}if(e.key!==`Backspace`&&e.key!==`Delete`)return;let t=window.getSelection();if(!t||t.rangeCount===0)return;let n=t.getRangeAt(0);if(!n.collapsed)return;let r=e.key===`Backspace`?(()=>{let e=n.startContainer;return e.nodeType===Node.TEXT_NODE&&n.startOffset>0?null:RD(e)?e.childNodes[n.startOffset-1]??null:e.previousSibling})():(()=>{let e=n.startContainer;return e.nodeType===Node.TEXT_NODE&&n.startOffset<(e.nodeValue?.length??0)?null:RD(e)?e.childNodes[n.startOffset]??null:e.nextSibling})(),i=RD(r)?r:null;if(i&&i.dataset.attachmentId){e.preventDefault();let t=L(i.dataset.attachmentId);t&&l?.(t)}},[l,p,L]),te=(0,H.useCallback)(e=>{let t=e.clipboardData;if(!t)return;let n=(t.items?Array.from(t.items):[]).find(e=>e.kind===`file`&&e.type.startsWith(`image/`));if(n){let t=n.getAsFile();if(t){e.preventDefault(),S.current+=1,R(t.name&&t.name!==`image.png`?t:new File([t],ID(S.current),{type:t.type}));return}}e.preventDefault();let r=t.getData(`text/plain`);if(!r)return;let i=window.getSelection();if(!i||i.rangeCount===0)return;let a=i.getRangeAt(0);a.deleteContents(),a.insertNode(document.createTextNode(r)),a.collapse(!1),M()},[M,R]),B=(0,H.useCallback)(e=>{let t=e.target;if(t.dataset.role===`pill-remove`){e.preventDefault();let n=t.closest(`[data-attachment-id]`);if(n?.dataset.attachmentId){let e=L(n.dataset.attachmentId);e&&l?.(e)}}},[l,L]),ne=(0,H.useCallback)(()=>M(),[M]),V=(0,H.useCallback)(()=>N(),[N]),re=(0,H.useCallback)(()=>{b.current=!0},[]),U=(0,H.useCallback)(()=>{if(b.current=!1,x.current.length>0){let e=x.current;x.current=[],e.forEach(e=>F(e))}},[F]),ie=(0,H.useCallback)(e=>{e.dataTransfer?.types.includes(`Files`)&&(e.preventDefault(),C.current+=1,T(!0))},[]),ae=(0,H.useCallback)(e=>{e.dataTransfer?.types.includes(`Files`)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`)},[]),W=(0,H.useCallback)(e=>{e.dataTransfer?.types.includes(`Files`)&&(--C.current,C.current<=0&&(C.current=0,T(!1)))},[]),oe=(0,H.useCallback)(e=>{if(!e.dataTransfer?.types.includes(`Files`))return;e.preventDefault(),C.current=0,T(!1);let t=FD(e.dataTransfer);t.length>0&&z(t)},[z]),se=(0,H.useCallback)(()=>{v.current?.click()},[]),ce=(0,H.useCallback)(e=>{let t=e.target.files?Array.from(e.target.files):[];t.length>0&&z(t),e.target.value=``},[z]);return(0,H.useEffect)(()=>{a&&_.current?.focus()},[a]),(0,Y.jsxs)(`div`,{className:X(`relative group`,o),onDragEnter:ie,onDragOver:ae,onDragLeave:W,onDrop:oe,children:[(0,Y.jsx)(`div`,{ref:_,contentEditable:!s,role:`textbox`,"aria-multiline":`true`,"aria-label":i,spellCheck:!0,suppressContentEditableWarning:!0,onInput:ne,onPaste:te,onKeyDown:ee,onClick:B,onBlur:V,onCompositionStart:re,onCompositionEnd:U,"data-empty":A?`true`:`false`,className:X(`w-full rounded-lg border border-border bg-background px-3 py-2 text-sm leading-relaxed`,`outline-none focus:ring-2 focus:ring-primary/40 focus:border-primary/60`,`transition-colors whitespace-pre-wrap break-words`,`data-[empty=true]:before:content-[attr(data-placeholder)]`,`data-[empty=true]:before:text-muted-foreground data-[empty=true]:before:pointer-events-none`,`data-[empty=true]:before:absolute data-[empty=true]:before:top-2 data-[empty=true]:before:left-3`),style:{minHeight:n,maxHeight:r,resize:`vertical`,overflow:`auto`},"data-placeholder":t??``}),(O.length>0||E.length>0)&&(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-1.5 mt-2`,children:[O.map((e,t)=>(0,Y.jsx)(PD,{attachment:e,index:t,onRemove:()=>{let t=L(e.id);t&&l?.(t)}},e.id)),E.map((e,t)=>(0,Y.jsx)(PD,{uploading:{name:e.name},index:O.length+t},e.id))]}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between mt-2 text-[11px] text-muted-foreground`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:se,disabled:s,className:`inline-flex items-center gap-1 px-2 py-1 rounded-md border border-border hover:bg-accent/40 transition-colors disabled:opacity-50`,children:[(0,Y.jsx)(`span`,{"aria-hidden":!0,children:`📎`}),(0,Y.jsx)(`span`,{children:g(`editor.attachFiles`)})]}),m]}),E.length>0&&(0,Y.jsx)(`span`,{className:`animate-pulse`,children:g(`editor.uploadingFiles`,{count:E.length})})]}),(0,Y.jsx)(`input`,{ref:v,type:`file`,multiple:!0,accept:DD,className:`hidden`,onChange:ce}),(0,Y.jsx)(`div`,{"aria-hidden":!0,className:X(`pointer-events-none absolute inset-0 rounded-lg border-2 border-dashed transition-all duration-150`,w?`border-primary bg-primary/10 opacity-100 scale-100`:`border-transparent opacity-0 scale-[0.98]`),children:(0,Y.jsx)(`div`,{className:X(`absolute inset-0 flex items-center justify-center text-sm font-medium text-primary`,w?`opacity-100`:`opacity-0`,`transition-opacity`),children:g(`editor.dropToAddContext`)})})]})});function VD({value:e,allowed:t,loading:n,onChange:r,ariaLabel:i}){let{t:a}=K(`explore`);return(0,Y.jsxs)(VT,{value:e??``,onValueChange:r,disabled:n||t.length===0,children:[(0,Y.jsx)(UT,{className:`h-8 w-[160px] text-xs gap-1.5`,"aria-label":i??a(`modelPicker.ariaLabel`),"data-testid":`spec-model-picker`,children:n?(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-muted-foreground`,children:[(0,Y.jsx)(cs,{className:`w-3 h-3 animate-spin`}),a(`common:states.loading`)]}):(0,Y.jsx)(HT,{placeholder:a(`modelPicker.placeholder`)})}),(0,Y.jsx)(KT,{children:t.map(e=>(0,Y.jsx)(JT,{value:e.value,children:e.label},e.value))})]})}function HD(e,t,n){let[r,i]=(0,H.useState)(null),[a,o]=(0,H.useState)([]),[s,c]=(0,H.useState)(null),[l,u]=(0,H.useState)([]),[d,f]=(0,H.useState)(!1),[p,m]=(0,H.useState)(null);return(0,H.useEffect)(()=>{if(!t||!e)return;let r=!1;f(!0),m(null);let a=n?`?provider=${encodeURIComponent(n)}`:``;return fetch(`${af()}/default-spec-model${a}`).then(async e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{r||(i(typeof e?.model==`string`?e.model:`sonnet`),o(Array.isArray(e?.allowed)&&e.allowed.length>0?e.allowed:[{value:`sonnet`,label:`Claude Sonnet`}]),c(e?.provider??`claude`),u(Array.isArray(e?.providers)&&e.providers.length>0?e.providers:[e?.provider??`claude`]))}).catch(e=>{r||(m(e.message),i(`sonnet`),o([{value:`sonnet`,label:`Claude Sonnet`}]),c(`claude`),u([`claude`]))}).finally(()=>{r||f(!1)}),()=>{r=!0}},[t,e,n]),{model:r,setModel:i,allowed:a,provider:s,providers:l,loading:d,error:p}}function UD(e){return e===`claude`}function WD(e){return e===`claude`||e===`codex`}var GD=new Set([`agents`]);function KD(e,t){return GD.has(t)?e===`claude`:!0}function qD(e,t){return(t&&t.length>0?t:[`claude`]).every(t=>KD(t,e))}function JD(e){return e===`codex`?`Codex`:e===`claude`?`Claude`:e===`gemini`?`Gemini`:e??`Claude`}function YD({value:e,providers:t,onChange:n,disabled:r,ariaLabel:i,className:a}){let{t:o}=K(`addspec`);return!t||t.length<=1?null:(0,Y.jsxs)(VT,{value:e,onValueChange:e=>n(e),disabled:r,children:[(0,Y.jsx)(UT,{className:a??`h-8 w-[130px] text-xs gap-1.5`,"aria-label":i??o(`aiEngine.label`),"data-testid":`ai-engine-selector`,children:(0,Y.jsx)(HT,{placeholder:o(`aiEngine.label`)})}),(0,Y.jsx)(KT,{children:t.map(e=>(0,Y.jsx)(JT,{value:e,children:JD(e)},e))})]})}function XD(e){return{specrails:!0,openspec:!1,full:e===`explore`,mcp:!1,contractRefine:!1,userMcp:!1}}function ZD(e){let t=+!!e.specrails+(e.openspec?2:0)+(e.mcp?2:0)+(e.full?4:0)+(e.contractRefine?4:0);return t===0?`Light`:t<=2?`Medium`:t<=5?`Heavy`:`Deep`}function QD(e){switch(e){case`Light`:return`bg-accent-success text-white hover:bg-accent-success/90`;case`Medium`:return`bg-accent-info text-white hover:bg-accent-info/90`;case`Heavy`:return`bg-accent-warning text-white hover:bg-accent-warning/90`;case`Deep`:return`bg-accent-secondary text-white hover:bg-accent-secondary/90`}}var $D={sonnet:.003,opus:.015,haiku:8e-4,"gpt-5.5":.0015,"gpt-5.4-mini":6e-4,"gpt-5.4":.005};function eO(e,t){let n=0;return e.specrails&&(n+=t.specrailsTicketsTokens??0),e.openspec&&(n+=t.openspecSpecsTokens??0),e.full&&(n+=Math.min(t.codebaseEstimatedTokens??0,5e4)),n}function tO(e,t,n){let r=eO(e,t),i=$D[n]??.003;return r/1e3*i}function nO(e){switch(e){case`Light`:return`~15s`;case`Medium`:return`~30s`;case`Heavy`:return`~60s`;case`Deep`:return`~120s`}}function rO(e){return e.full?`~45s`:`~15s`}function iO({id:e,label:t,hint:n,checked:r,disabled:i,tooltip:a,onChange:o}){return(0,Y.jsxs)(`div`,{title:a,className:`flex items-center justify-between gap-3 px-3 py-2 rounded-md border border-border/40 ${i?`opacity-50 cursor-not-allowed`:`cursor-pointer hover:bg-card/60`}`,children:[(0,Y.jsxs)(`label`,{htmlFor:e,className:`flex flex-col gap-0.5 text-xs`,children:[(0,Y.jsx)(`span`,{className:`font-medium text-foreground`,children:t}),(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:n})]}),(0,Y.jsx)(`button`,{id:e,type:`button`,role:`switch`,"aria-label":t,"aria-checked":r,disabled:i,onClick:()=>o(!r),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 disabled:opacity-50 ${r?`bg-primary`:`bg-input`}`,children:(0,Y.jsx)(`span`,{className:`inline-block h-3.5 w-3.5 rounded-full bg-background shadow-sm transition-transform ${r?`translate-x-4`:`translate-x-0.5`}`})})]})}function aO({scope:e,onChange:t,defaultOpen:n=!1,label:r,showSummary:i=!0}){let{t:a}=K(`addspec`),o=r??a(`contextScope.defaultLabel`),[s,c]=(0,H.useState)(n),l=[e.specrails&&a(`contextScope.tags.specrails`),e.openspec&&a(`contextScope.tags.openspec`),e.full&&a(`contextScope.tags.codebase`),e.mcp&&a(`contextScope.tags.mcp`),e.userMcp&&a(`contextScope.tags.myMcp`),e.contractRefine&&a(`contextScope.tags.contract`)].filter(Boolean),u=l.length===0?a(`contextScope.summaryMinimal`):l.join(`, `),d=ZD(e);return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsxs)(`button`,{type:`button`,"aria-expanded":s,"aria-controls":`ctx-scope-body`,"data-testid":`context-scope-toggle`,onClick:()=>c(e=>!e),className:`flex items-center justify-between gap-2 text-[11px] uppercase tracking-wider text-muted-foreground font-semibold hover:text-foreground transition-colors`,children:[(0,Y.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[s?(0,Y.jsx)(no,{className:`w-3 h-3`}):(0,Y.jsx)(io,{className:`w-3 h-3`}),o]}),!s&&i?(0,Y.jsxs)(`span`,{className:`text-[10px] normal-case tracking-normal text-muted-foreground/80`,children:[u,` · `,d]}):null]}),s?(0,Y.jsxs)(`div`,{id:`ctx-scope-body`,className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:[(0,Y.jsx)(iO,{id:`ctx-specrails`,label:a(`contextScope.checks.specrailsLabel`),hint:`.specrails/local-tickets.json`,checked:e.specrails,onChange:n=>t({...e,specrails:n})}),(0,Y.jsx)(iO,{id:`ctx-openspec`,label:a(`contextScope.checks.openspecLabel`),hint:`openspec/specs/*`,checked:e.openspec,onChange:n=>t({...e,openspec:n})}),(0,Y.jsx)(iO,{id:`ctx-full`,label:a(`contextScope.checks.fullLabel`),hint:`Read · Grep · Glob`,checked:e.full,onChange:n=>t({...e,full:n})}),(0,Y.jsx)(iO,{id:`ctx-mcp`,label:a(`contextScope.checks.mcpLabel`),hint:a(`contextScope.checks.mcpHint`),checked:e.mcp&&!0,disabled:!1,tooltip:void 0,onChange:n=>t({...e,mcp:n})}),(0,Y.jsx)(iO,{id:`ctx-user-mcp`,label:a(`contextScope.checks.userMcpLabel`),hint:a(`contextScope.checks.userMcpHint`),checked:!!e.userMcp&&!0,disabled:!1,tooltip:a(`contextScope.checks.userMcpTooltip`),onChange:n=>t({...e,userMcp:n})}),(0,Y.jsx)(iO,{id:`ctx-contract-refine`,label:a(`contextScope.checks.contractLabel`),hint:a(`contextScope.checks.contractHint`),checked:e.contractRefine,onChange:n=>t({...e,contractRefine:n})})]}):null]})}var oO=[{id:`minimal`,scope:{specrails:!1,openspec:!1,full:!1,mcp:!1,contractRefine:!1}},{id:`light`,scope:{specrails:!0,openspec:!1,full:!1,mcp:!1,contractRefine:!1}},{id:`standard`,scope:{specrails:!0,openspec:!0,full:!1,mcp:!1,contractRefine:!1}},{id:`rich`,scope:{specrails:!0,openspec:!0,full:!0,mcp:!1,contractRefine:!1}},{id:`max`,scope:{specrails:!0,openspec:!0,full:!0,mcp:!1,contractRefine:!0}},{id:`desktop`,scope:{specrails:!0,openspec:!0,full:!0,mcp:!0,contractRefine:!0,userMcp:!0}}];function sO(e,t){return e.specrails===t.specrails&&e.openspec===t.openspec&&e.full===t.full&&e.mcp===t.mcp&&e.contractRefine===t.contractRefine&&(e.userMcp??!1)===(t.userMcp??!1)}function cO(e){return oO.findIndex(t=>sO(t.scope,e))}function lO(e){let t={specrails:1,openspec:1,full:1,contractRefine:1,mcp:1,userMcp:1},n=0;return e.specrails&&(n+=t.specrails),e.openspec&&(n+=t.openspec),e.full&&(n+=t.full),e.contractRefine&&(n+=t.contractRefine),e.mcp&&(n+=t.mcp),e.userMcp&&(n+=t.userMcp),Math.max(0,Math.min(5,n))}function uO(e){return e>=1e3?`~${(e/1e3).toFixed(e>=1e4?0:1)}k tok`:`~${e} tok`}function dO(e){return e<.01?`~$${e.toFixed(4)}`:`~$${e.toFixed(2)}`}function fO({value:e,onChange:t,budget:n=null,budgetError:r=!1,model:i=`sonnet`,maxPresetId:a=`desktop`,onPresetChange:o,smashCapable:s=!0}){let{t:c}=K(`addspec`),l=(0,H.useRef)(null),[u,d]=(0,H.useState)(!1),[f,p]=(0,H.useState)(null),m=Math.max(0,oO.findIndex(e=>e.id===a)),h=oO.slice(0,m+1),g=cO(e),_=g<0,v=g>=0?oO[g]:null,y=Math.min(_?lO(e):g,m);(0,H.useEffect)(()=>{o?.(v?.id??`custom`)},[v,o]);let b=(0,H.useCallback)(e=>{t(oO[Math.max(0,Math.min(m,e))].scope)},[m,t]),x=(0,H.useCallback)(e=>{let t=m;e.key===`ArrowRight`||e.key===`ArrowUp`?(e.preventDefault(),b((g<0?Math.round(y):g)+1)):e.key===`ArrowLeft`||e.key===`ArrowDown`?(e.preventDefault(),b((g<0?Math.round(y):g)-1)):e.key===`Home`?(e.preventDefault(),b(0)):e.key===`End`&&(e.preventDefault(),b(t))},[g,y,m,b]),S=(0,H.useCallback)(e=>{let t=l.current;if(!t)return 0;let n=t.getBoundingClientRect(),r=(e-n.left)/Math.max(1,n.width);return Math.max(0,Math.min(1,r))},[]),C=(0,H.useCallback)(e=>{let t=S(e);return Math.round(t*m)},[m,S]),w=(0,H.useCallback)(e=>{e.preventDefault(),d(!0),p(S(e.clientX)),e.target.setPointerCapture?.(e.pointerId)},[S]),T=(0,H.useCallback)(e=>{u&&p(S(e.clientX))},[u,S]),E=(0,H.useCallback)(e=>{u&&(d(!1),p(null),b(C(e.clientX)))},[u,C,b]),D=(0,H.useMemo)(()=>u&&f!==null?f:m===0?0:y/m,[u,f,m,y]),O=_?c(`contextScope.customMix`):v?c(`contextScope.presetCost.${v.id}`):``,k=ZD(e),A=r||!n?c(`contextScope.estimateUnavailable`,{tier:k}):`${k} · ${uO(eO(e,n))} · ${dO(tO(e,n,i))} · ${nO(k)}`;return(0,Y.jsxs)(`div`,{className:`space-y-2 select-none`,"data-testid":`context-scope-slider`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-[11px] uppercase tracking-wider text-muted-foreground font-semibold`,children:c(`contextScope.heading`)}),_?(0,Y.jsx)(`span`,{className:`rounded-full bg-accent-warning/15 px-2 py-0.5 text-[10px] font-semibold text-accent-warning`,"data-testid":`scope-custom-pill`,children:c(`contextScope.custom`)}):null]}),(0,Y.jsx)(`span`,{className:`text-[11px] font-medium text-foreground`,"data-testid":`context-awareness-tier`,children:k})]}),(0,Y.jsx)(`div`,{className:`flex justify-between text-[10px] font-medium text-muted-foreground`,children:h.map((e,t)=>(0,Y.jsx)(`button`,{type:`button`,onClick:()=>b(t),className:`px-1 cursor-pointer hover:text-foreground transition-colors ${g===t?`text-foreground font-semibold`:``}`,"data-testid":`scope-stop-${e.id}`,children:c(`contextScope.preset.${e.id}`)},e.id))}),(0,Y.jsxs)(`div`,{ref:l,role:`slider`,"aria-valuemin":0,"aria-valuemax":m,"aria-valuenow":g<0?Math.round(y):g,"aria-valuetext":_?c(`contextScope.custom`):v?c(`contextScope.preset.${v.id}`):``,tabIndex:0,onKeyDown:x,onPointerDown:w,onPointerMove:T,onPointerUp:E,className:`relative h-2 rounded-full bg-muted/40 cursor-pointer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,children:[h.map((e,t)=>(0,Y.jsx)(`span`,{className:`absolute top-1/2 -translate-y-1/2 -translate-x-1/2 h-2 w-2 rounded-full bg-muted-foreground/70 pointer-events-none`,style:{left:`${m===0?0:t/m*100}%`}},t)),(0,Y.jsx)(`div`,{className:`absolute left-0 top-0 h-full rounded-full bg-primary/60 pointer-events-none`,style:{width:`${D*100}%`}}),(0,Y.jsx)(`div`,{"data-testid":`scope-thumb`,className:`absolute top-1/2 -translate-y-1/2 -translate-x-1/2 h-4 w-4 rounded-full bg-background border-2 ${_?`border-accent-warning`:`border-primary`} shadow-sm pointer-events-none ${u?``:`transition-[left] duration-150`}`,style:{left:`${D*100}%`}})]}),(0,Y.jsxs)(`p`,{className:`text-[10px] text-muted-foreground`,"data-testid":`scope-cost-line`,children:[O,` · `,A]}),e.contractRefine&&s&&(0,Y.jsxs)(`div`,{className:`flex items-start gap-1.5 rounded-md border border-accent-highlight/40 bg-accent-highlight/10 px-2 py-1.5 text-[10px] text-foreground/80`,"data-testid":`scope-smash-hint`,children:[(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`text-accent-highlight`,children:`⊢→`}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`strong`,{className:`text-accent-highlight`,children:c(`contextScope.smashCapable`)}),` · `,c(`contextScope.smashHint`)]})]})]})}var pO=`specrails-desktop:last-engine:`;function mO(e){return`${pO}${e}`}function hO(e,t,n){if(!e)return n;try{let n=window.localStorage.getItem(mO(e));if(n&&t.includes(n))return n}catch{}return n}function gO(e,t){if(e)try{window.localStorage.setItem(mO(e),t)}catch{}}function _O(e,t,n){let[r,i]=(0,H.useState)({scope:XD(t),loaded:!1}),a=(0,H.useRef)(null);(0,H.useEffect)(()=>{if(!n||!e)return;let s=`${e}:${t}`;if(a.current===s&&r.loaded)return;a.current=s;let c=!1;return(async()=>{if(t===`quick`){c||i({scope:XD(`quick`),loaded:!0});return}let n=XD(t);try{let r=await fetch(`${o}/api/projects/${e}/context-scope-last`);if(r.ok){let e=await r.json();e.scope&&(n={...XD(t),...e.scope})}}catch{}c||i({scope:n,loaded:!0})})(),()=>{c=!0}},[e,n,t]);let s=(0,H.useCallback)(e=>{i(t=>({scope:typeof e==`function`?e(t.scope):e,loaded:t.loaded}))},[]),c=(0,H.useCallback)(async t=>{if(e)try{await fetch(`${o}/api/projects/${e}/context-scope-last`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})}catch{}},[e]);return{scope:r.scope,setScope:s,persist:c,loaded:r.loaded}}function vO(e,t){let[n,r]=(0,H.useState)({data:null,isError:!1}),i=(0,H.useRef)(null);return(0,H.useEffect)(()=>{if(!t||!e||i.current===e&&n.data)return;i.current=e;let a=!1,s=new AbortController,c=setTimeout(()=>s.abort(),5e3);return fetch(`${o}/api/projects/${e}/context-budget`,{signal:s.signal}).then(async e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{a||r({data:e,isError:!1})}).catch(()=>{a||r({data:null,isError:!0})}).finally(()=>clearTimeout(c)),()=>{a=!0,s.abort(),clearTimeout(c)}},[e,t]),n}function yO(e,t){let[n,r]=(0,H.useState)(!1),[i,a]=(0,H.useState)(!1);return(0,H.useEffect)(()=>{if(!t||!e)return;let n=!1;return(async()=>{let t=!1;try{let n=await fetch(`${o}/api/projects/${e}/add-spec-quick-contract-refine-last`);if(n.ok){let e=await n.json();(e.configured===!0||e.configured===void 0)&&(t=e.enabled===!0)}}catch{}n||(r(t),a(!0))})(),()=>{n=!0}},[e,t]),{value:n,setValue:r,loaded:i,persist:(0,H.useCallback)(async t=>{e&&await fetch(`${o}/api/projects/${e}/add-spec-quick-contract-refine-last`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:t})})},[e])}}function bO(){return typeof window<`u`&&`__TAURI_INTERNALS__`in window||typeof window<`u`&&window.location.protocol!==`http:`&&window.location.protocol!==`https:`?`ws://localhost:4200`:`${window.location.protocol===`https:`?`wss:`:`ws:`}//${window.location.host}`}var xO=bO();function SO(){let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}?.VITE_FEATURE_BROWSER_CAPTURE;return typeof e==`string`?e!==`false`:!0}var CO={desktop:{width:1280,height:800},tablet:{width:768,height:1024},mobile:{width:375,height:667}},wO=class extends Error{},TO=class extends Error{};async function EO(e){let t=await fetch(`${af()}/browser/sessions`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({initialUrl:e})});if(t.status===409)throw new wO(`Too many open browser sessions`);if(t.status===502)throw new TO(`The browser failed to launch`);if(!t.ok)throw Error(`Failed to open browser (${t.status})`);return(await t.json()).session}async function DO(e,t,n){let r=await fetch(`${af()}/browser/sessions/${e}/navigate`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:t,url:n})});if(!r.ok)throw Error(`Navigation failed (${r.status})`);return await r.json()}async function OO(e,t,n,r){let i=await fetch(`${af()}/browser/sessions/${e}/capture`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({rect:t,pendingSpecId:n,captureNetwork:r?.captureNetwork??!0})});if(!i.ok)throw Error(await kO(i));return await i.json()}async function kO(e){let t=await e.json().then(e=>e.error).catch(()=>void 0);return t?`Capture failed (${e.status}): ${t}`:`Capture failed (${e.status})`}async function AO(e,t,n,r,i=CO){let a=await fetch(`${af()}/browser/sessions/${e}/capture-breakpoints`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({rect:t,anchorPoint:n,pendingSpecId:r,breakpoints:i})});if(!a.ok)throw Error(await kO(a));return await a.json()}async function jO(e,t,n){let r=new FormData;r.append(`file`,t,n);let i=await fetch(`${af()}/tickets/${e}/attachments`,{method:`POST`,body:r});if(!i.ok)throw Error(`Upload failed (${i.status})`);return(await i.json()).attachment}async function MO(e,t,n){let r=await fetch(`${af()}/browser/sessions/${e}/clipboard`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:t,text:n})});if(!r.ok)throw Error(`Clipboard failed (${r.status})`);return await r.json()}async function NO(e,t,n){let r=await fetch(`${af()}/browser/sessions/${e}/element`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({selector:t,direction:n})});if(!r.ok)throw Error(`Element navigate failed (${r.status})`);return(await r.json()).probe}async function PO(e,t){try{await fetch(`${af()}/browser/sessions/${e}/popup-view`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({target:t})})}catch{}}function FO(e){if(!e||e===`about:blank`)return`…`;try{return new URL(e).hostname||`…`}catch{return`…`}}async function IO(e){try{await fetch(`${af()}/browser/sessions/${e}`,{method:`DELETE`})}catch{}}function LO(e,t){return`${xO||(typeof window<`u`?`${window.location.protocol===`https:`?`wss:`:`ws:`}//${window.location.host}`:`ws://localhost:4200`)}/ws/browser/${e}?projectId=${encodeURIComponent(t)}`}function RO(e,t){let n=LO(e,t),r=c(),i=r?new WebSocket(n,[`specrails-desktop`,r]):new WebSocket(n);return i.binaryType=`arraybuffer`,i}function zO(e,t=e=>requestAnimationFrame(e),n=e=>cancelAnimationFrame(e)){let r=null,i=null,a=null,o=!1,s=()=>{a!=null&&(n(a),a=null);let t=r,o=i;r=null,i=null,t&&(!o||t.x!==o.x||t.y!==o.y)&&e({type:`mouse`,action:`move`,x:t.x,y:t.y}),o&&e({type:`wheel`,x:o.x,y:o.y,deltaX:o.deltaX,deltaY:o.deltaY})},c=()=>{a==null&&!o&&(a=t(()=>{a=null,s()}))};return{move(e,t){o||(r={x:e,y:t},c())},wheel(e,t,n,r){o||(i?(i.x=e,i.y=t,i.deltaX+=n,i.deltaY+=r):i={x:e,y:t,deltaX:n,deltaY:r},c())},flush(){o||s()},dispose(){o||(o=!0,a!=null&&(n(a),a=null),r=null,i=null)}}}function BO(e,t,n){let r=t.width>0?(e.x-t.left)/t.width:0,i=t.height>0?(e.y-t.top)/t.height:0,a=Math.min(Math.max(r,0),1)*n.width,o=Math.min(Math.max(i,0),1)*n.height;return{x:Math.round(a),y:Math.round(o)}}function VO(e,t,n){let r=n.width>0?t.width/n.width:0,i=n.height>0?t.height/n.height:0;return{left:t.left+e.x*r,top:t.top+e.y*i,width:e.width*r,height:e.height*i}}function HO(e,t){return{x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),width:Math.abs(e.x-t.x),height:Math.abs(e.y-t.y)}}function UO(e,t=8){return e.width>=t&&e.height>=t}function WO(e,t){let n=Math.max(1,t.width),r=Math.max(1,t.height),i=Math.max(0,Math.min(e.x,n-1)),a=Math.max(0,Math.min(e.y,r-1)),o=Math.min(n,Math.max(i+1,e.x+e.width)),s=Math.min(r,Math.max(a+1,e.y+e.height));return{x:Math.round(i),y:Math.round(a),width:Math.round(o-i),height:Math.round(s-a)}}function GO(e){return{nodeCount:e.nodes.length,htmlBytes:e.html.length,truncated:e.htmlTruncated,networkCount:e.networkRequests?.length??0}}function KO(e){let t=e.schedule??(e=>requestAnimationFrame(e)),n=e.cancel??(e=>cancelAnimationFrame(e)),r=e.now??(()=>typeof performance<`u`?performance.now():Date.now()),i=e.release??(()=>{}),a={received:0,decoded:0,drawn:0,droppedStale:0,droppedUndrawn:0,decodeMsTotal:0,drawMsTotal:0},o=!1,s=!1,c=null,l=null,u=null,d=()=>{u=null;let t=l;if(l=null,t==null||o){t!=null&&f(t);return}let n=r();try{e.draw(t),a.drawn++,a.drawMsTotal+=r()-n}catch{}finally{f(t)}},f=e=>{try{i(e)}catch{}},p=()=>{u==null&&!o&&(u=t(d))},m=t=>{s=!0;let n=r();e.decode(t).then(e=>{if(o){f(e);return}a.decoded++,a.decodeMsTotal+=r()-n,l!=null&&(a.droppedUndrawn++,f(l)),l=e,p(),h()},()=>{h()})},h=()=>{if(o){s=!1;return}let e=c;c=null,e==null?s=!1:m(e)};return{push(e){if(!o){if(a.received++,s){c!=null&&a.droppedStale++,c=e;return}m(e)}},stats(){return{...a}},dispose(){if(!o){if(o=!0,c=null,u!=null){try{n(u)}catch{}u=null}l!=null&&(f(l),l=null)}}}}var qO=`specrails-desktop:browser-capture-debug`;function JO(){try{return typeof localStorage<`u`&&localStorage.getItem(qO)===`1`}catch{return!1}}function YO(e,t,n){let r=Math.max(1,n),i=t.decoded-e.decoded,a=t.drawn-e.drawn,o=e=>Math.round(e*10)/10;return{fpsReceived:o((t.received-e.received)*1e3/r),fpsDrawn:o(a*1e3/r),droppedStale:t.droppedStale-e.droppedStale,droppedUndrawn:t.droppedUndrawn-e.droppedUndrawn,avgDecodeMs:i>0?o((t.decodeMsTotal-e.decodeMsTotal)/i):0,avgDrawMs:a>0?o((t.drawMsTotal-e.drawMsTotal)/a):0}}function XO(e,t=e=>console.table([e]),n=2e3,r=()=>Date.now()){let i=e(),a=r(),o=setInterval(()=>{let n=e(),o=r();t(YO(i,n,o-a)),i=n,a=o},n);return()=>clearInterval(o)}function ZO(e){let{projectId:t,open:n,initialUrl:r}=e,i=(0,H.useRef)(null),a=(0,H.useRef)(null),o=(0,H.useRef)(null),s=(0,H.useRef)(!1),[c,l]=(0,H.useState)({status:`connecting`,errorMsg:null,url:null,title:null,viewport:{width:1280,height:800},hoverRect:null,hoverSelector:null,hoverPath:null,popup:null});(0,H.useEffect)(()=>{if(!n||!t)return;let e=!1;l(e=>({...e,status:`connecting`,errorMsg:null,popup:null}));let c=KO({decode:e=>createImageBitmap(new Blob([e],{type:`image/jpeg`})),draw:e=>{let t=i.current;t&&(t.width!==e.width&&(t.width=e.width),t.height!==e.height&&(t.height=e.height),t.getContext(`2d`)?.drawImage(e,0,0))},release:e=>e.close()}),u=JO()?XO(()=>c.stats()):null;return(async()=>{try{let n=await EO(r);if(e){IO(n.id);return}o.current=n.id,l(e=>({...e,url:n.url,title:n.title,viewport:{width:n.viewportWidth,height:n.viewportHeight}}));let i=RO(n.id,t);a.current=i,i.onmessage=e=>{if(typeof e.data==`string`){try{let t=JSON.parse(e.data);if(t.type===`ready`)l(e=>({...e,status:`ready`,url:t.url??e.url,title:t.title??e.title,viewport:t.viewport??e.viewport}));else if(t.type===`nav`)l(e=>({...e,url:t.url??e.url,title:t.title??e.title}));else if(t.type===`hover`)l(e=>({...e,hoverRect:t.rect??null,hoverSelector:t.selector??null,hoverPath:t.path??null}));else if(t.type===`popup`){let e=typeof t.count==`number`?t.count:0;l(n=>({...n,popup:e>0?{count:e,active:t.active===!0,url:t.url??null}:null}))}}catch{}return}c.push(e.data)},i.onopen=()=>{e||l(e=>({...e,status:`ready`}))},i.onerror=()=>{e||l(e=>({...e,status:`error`,errorMsg:am.t(`browser:session.connectionError`)}))},i.onclose=()=>{e||l(e=>e.status===`ready`?{...e,status:`error`,errorMsg:am.t(`browser:session.lostConnection`)}:e)}}catch(t){if(e)return;let n=t instanceof wO?am.t(`browser:session.tooManySessions`):t instanceof TO?am.t(`browser:session.launchFailed`):am.t(`browser:session.openFailed`);l(e=>({...e,status:`error`,errorMsg:n}))}})(),()=>{e=!0,u?.(),c.dispose();let t=a.current;if(t){t.onmessage=null,t.onopen=null,t.onerror=null,t.onclose=null;try{t.close()}catch{}}a.current=null;let n=o.current;o.current=null,n&&!s.current&&IO(n)}},[n,t,r]);let u=(0,H.useCallback)(e=>{let t=a.current;if(t&&t.readyState===WebSocket.OPEN)try{t.send(JSON.stringify({type:`input`,event:e}))}catch{}},[]),d=(0,H.useCallback)(async(e,t)=>{let n=o.current;if(n)try{let r=await DO(n,e,t);l(e=>({...e,url:r.url,title:r.title}))}catch{}},[]),f=(0,H.useCallback)(async(e,t,n)=>{let r=o.current;if(!r)throw Error(`No active browser session`);s.current=!0;try{return await OO(r,e,t,n)}finally{s.current=!1}},[]),p=(0,H.useCallback)(async(e,t,n,r)=>{let i=o.current;if(!i)throw Error(`No active browser session`);s.current=!0;try{return await AO(i,e,t,n,r)}finally{s.current=!1}},[]),m=(0,H.useCallback)(async(e,t)=>{let n=o.current;return n?MO(n,e,t):{text:``}},[]),h=(0,H.useCallback)((e,t)=>{let n=Math.max(1,Math.round(e)),r=Math.max(1,Math.round(t));l(e=>({...e,viewport:{width:n,height:r}})),u({type:`resize`,width:n,height:r})},[u]),g=(0,H.useCallback)(e=>{let t=a.current;if(t&&t.readyState===WebSocket.OPEN)try{t.send(JSON.stringify({type:`probe`,x:e.x,y:e.y}))}catch{}},[]),_=(0,H.useCallback)(()=>{l(e=>e.hoverRect||e.hoverPath?{...e,hoverRect:null,hoverSelector:null,hoverPath:null}:e)},[]),v=(0,H.useCallback)(async(e,t)=>{let n=o.current;return n?NO(n,e,t):null},[]),y=(0,H.useCallback)(e=>{let t=o.current;t&&(l(t=>t.popup?{...t,popup:{...t.popup,active:e===`popup`}}:t),PO(t,e))},[]);return{...c,canvasRef:i,forwardInput:u,navigate:d,capture:f,captureBreakpoints:p,clipboard:m,navigateElement:v,setViewport:h,probe:g,clearHover:_,setPopupView:y}}var QO={objects:[],past:[],future:[]};function $O(e,t){switch(t.type){case`add`:return{objects:[...e.objects,t.obj],past:[...e.past,e.objects],future:[]};case`delete`:return e.objects.some(e=>e.id===t.id)?{objects:e.objects.filter(e=>e.id!==t.id),past:[...e.past,e.objects],future:[]}:e;case`undo`:return e.past.length===0?e:{objects:e.past[e.past.length-1],past:e.past.slice(0,-1),future:[e.objects,...e.future]};case`redo`:return e.future.length===0?e:{objects:e.future[0],past:[...e.past,e.objects],future:e.future.slice(1)};case`clear`:return e.objects.length===0?e:{objects:[],past:[...e.past,e.objects],future:[]};default:return e}}function ek(e){let t=e.filter(e=>e.kind===`step`).map(e=>e.n);return t.length===0?1:Math.max(...t)+1}function tk(e,t){return{x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),w:Math.abs(e.x-t.x),h:Math.abs(e.y-t.y)}}function nk(e,t,n=.04){let r=Math.atan2(t.y-e.y,t.x-e.x),i=r-Math.PI/7,a=r+Math.PI/7;return{left:{x:t.x-n*Math.cos(i),y:t.y-n*Math.sin(i)},right:{x:t.x-n*Math.cos(a),y:t.y-n*Math.sin(a)}}}function rk(e,t,n=.01){return Math.abs(e.x-t.x)>=n||Math.abs(e.y-t.y)>=n}function ik(e,t=.05){let n=e=>Math.min(1+t,Math.max(-t,e));return{x:n(e.x),y:n(e.y)}}function ak(e,t,n){return{schemaVersion:1,objects:e,baseWidth:t,baseHeight:n}}var ok=[`#ef4444`,`#f59e0b`,`#3b82f6`,`#22c55e`,`#ffffff`],sk=[{tool:`arrow`,icon:Ha,labelKey:`editor.tools.arrow`,key:`a`},{tool:`box`,icon:tc,labelKey:`editor.tools.box`,key:`r`},{tool:`text`,icon:uc,labelKey:`editor.tools.text`,key:`t`},{tool:`blur`,icon:Eo,labelKey:`editor.tools.blur`,key:`b`},{tool:`step`,icon:Yo,labelKey:`editor.tools.step`,key:`n`}],ck=0,lk=()=>`a${++ck}-${Date.now().toString(36)}`;function uk({result:e,pendingSpecId:t,macOverlay:n,confirmLabel:r,onConfirm:i,onReselect:a,onCancel:o}){let{t:s}=K(`browser`),[c,l]=(0,H.useReducer)($O,QO),[u,d]=(0,H.useState)(`arrow`),[f,p]=(0,H.useState)(ok[0]),[m,h]=(0,H.useState)(null),[g,_]=(0,H.useState)({w:1,h:1}),[v,y]=(0,H.useState)(!1),b=(0,H.useRef)(null),x=c.objects,S=(0,H.useCallback)(()=>{let e=b.current;if(!e)return;let t=e.getBoundingClientRect();t.width>0&&t.height>0&&_({w:t.width,h:t.height})},[]);(0,H.useEffect)(()=>(S(),window.addEventListener(`resize`,S),()=>window.removeEventListener(`resize`,S)),[S]);let C=(0,H.useCallback)((e,t)=>{let n=b.current;if(!n)return{x:0,y:0};let r=n.getBoundingClientRect();return ik({x:r.width>0?(e-r.left)/r.width:0,y:r.height>0?(t-r.top)/r.height:0})},[]),w=(0,H.useCallback)(e=>{if(v)return;e.target.setPointerCapture?.(e.pointerId);let t=C(e.clientX,e.clientY);if(u===`text`){let e=window.prompt(s(`editor.notePrompt`))?.trim();e&&l({type:`add`,obj:{id:lk(),kind:`text`,x:t.x,y:t.y,text:e,color:f}});return}if(u===`step`){l({type:`add`,obj:{id:lk(),kind:`step`,x:t.x,y:t.y,n:ek(x),color:f}});return}h({start:t,cur:t})},[v,u,f,x,C,s]),T=(0,H.useCallback)(e=>{m&&h(t=>t&&{...t,cur:C(e.clientX,e.clientY)})},[m,C]),E=(0,H.useCallback)(()=>{if(!m)return;let{start:e,cur:t}=m;if(h(null),rk(e,t)){if(u===`arrow`)l({type:`add`,obj:{id:lk(),kind:`arrow`,from:e,to:t,color:f}});else if(u===`box`){let n=tk(e,t);l({type:`add`,obj:{id:lk(),kind:`box`,...n,color:f}})}else if(u===`blur`){let n=tk(e,t);l({type:`add`,obj:{id:lk(),kind:`blur`,...n}})}}},[m,u,f]);(0,H.useEffect)(()=>{let e=e=>{if(v)return;let t=e.metaKey||e.ctrlKey;if(t&&e.key.toLowerCase()===`z`){e.preventDefault(),l({type:e.shiftKey?`redo`:`undo`});return}if(t&&e.key===`Enter`){e.preventDefault(),O();return}if(t)return;let n=sk.find(t=>t.key===e.key.toLowerCase());if(n){d(n.tool);return}e.key===`Escape`&&(e.preventDefault(),k())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[v,x,f,u]);let D=(0,H.useCallback)(async()=>{let e=b.current;if(!e||!e.naturalWidth)return null;let t=e.naturalWidth,n=e.naturalHeight,r=document.createElement(`canvas`);r.width=t,r.height=n;let i=r.getContext(`2d`);if(!i)return null;i.drawImage(e,0,0,t,n);for(let r of x)r.kind===`blur`&&(i.save(),i.beginPath(),i.rect(r.x*t,r.y*n,r.w*t,r.h*n),i.clip(),i.filter=`blur(${Math.max(6,t*.012)}px)`,i.drawImage(e,0,0,t,n),i.restore());i.filter=`none`;let a=Math.max(2,t*.004);for(let e of x)if(e.kind===`box`)i.strokeStyle=e.color,i.lineWidth=a,i.strokeRect(e.x*t,e.y*n,e.w*t,e.h*n);else if(e.kind===`arrow`){let r={x:e.from.x*t,y:e.from.y*n},o={x:e.to.x*t,y:e.to.y*n},s=nk(e.from,e.to,.035);i.strokeStyle=e.color,i.lineWidth=a,i.lineCap=`round`,i.beginPath(),i.moveTo(r.x,r.y),i.lineTo(o.x,o.y),i.moveTo(s.left.x*t,s.left.y*n),i.lineTo(o.x,o.y),i.lineTo(s.right.x*t,s.right.y*n),i.stroke()}else if(e.kind===`text`){let r=Math.max(12,n*.03);i.font=`600 ${r}px sans-serif`,i.textBaseline=`top`,i.lineWidth=Math.max(2,r*.18),i.strokeStyle=`rgba(0,0,0,0.55)`,i.strokeText(e.text,e.x*t,e.y*n),i.fillStyle=e.color,i.fillText(e.text,e.x*t,e.y*n)}else if(e.kind===`step`){let r=Math.max(10,n*.025);i.beginPath(),i.arc(e.x*t,e.y*n,r,0,Math.PI*2),i.fillStyle=e.color,i.fill(),i.fillStyle=`#000`,i.font=`700 ${r*1.1}px sans-serif`,i.textAlign=`center`,i.textBaseline=`middle`,i.fillText(String(e.n),e.x*t,e.y*n),i.textAlign=`start`}let o=r.toDataURL(`image/png`),s=await new Promise(e=>r.toBlob(t=>e(t),`image/png`));return s?{blob:s,dataUrl:o}:null},[x]),O=(0,H.useCallback)(async()=>{if(!v){if(x.length===0){i(e);return}y(!0);try{let n=await D(),r=b.current;if(!n||!r){i(e);return}let a=await jO(t,n.blob,`screen-annotated-${Date.now()}.png`);i({...e,rawScreenshot:e.screenshot,screenshot:a,screenshotDataUrl:n.dataUrl,annotations:ak(x,r.naturalWidth,r.naturalHeight)})}catch{i(e)}finally{y(!1)}}},[v,x,D,t,e,i]),k=(0,H.useCallback)(()=>{x.length>0&&!window.confirm(s(`editor.discardConfirm`))||o()},[x.length,o,s]),A=(e,t)=>e*(t===`w`?g.w:g.h),j=m?tk(m.start,m.cur):null;return(0,Y.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col items-center justify-center overflow-hidden p-3 gap-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 rounded-lg border border-border/60 bg-surface/90 px-1.5 py-1 shadow-xl ${n?`ml-[80px]`:``}`,children:[sk.map(({tool:e,icon:t,labelKey:n})=>(0,Y.jsx)(`button`,{type:`button`,title:s(n),"aria-label":s(n),"aria-pressed":u===e,onClick:()=>d(e),className:`h-7 w-7 inline-flex items-center justify-center rounded transition-colors ${u===e?`bg-primary/15 text-primary`:`text-muted-foreground hover:text-foreground hover:bg-card/60`}`,children:(0,Y.jsx)(t,{className:`w-3.5 h-3.5`})},e)),(0,Y.jsx)(`span`,{className:`w-px h-5 bg-border/60 mx-0.5`}),ok.map(e=>(0,Y.jsx)(`button`,{type:`button`,"aria-label":s(`editor.colorLabel`,{color:e}),onClick:()=>p(e),className:`h-5 w-5 rounded-full border transition-transform ${f===e?`scale-110 border-foreground`:`border-border/60`}`,style:{background:e}},e)),(0,Y.jsx)(`span`,{className:`w-px h-5 bg-border/60 mx-0.5`}),(0,Y.jsx)(`button`,{type:`button`,"aria-label":s(`editor.undo`),title:s(`editor.undoTitle`),disabled:c.past.length===0,onClick:()=>l({type:`undo`}),className:`h-7 w-7 inline-flex items-center justify-center rounded text-muted-foreground hover:text-foreground hover:bg-card/60 disabled:opacity-40`,children:(0,Y.jsx)(dc,{className:`w-3.5 h-3.5`})}),(0,Y.jsx)(`button`,{type:`button`,"aria-label":s(`editor.redo`),title:s(`editor.redoTitle`),disabled:c.future.length===0,onClick:()=>l({type:`redo`}),className:`h-7 w-7 inline-flex items-center justify-center rounded text-muted-foreground hover:text-foreground hover:bg-card/60 disabled:opacity-40`,children:(0,Y.jsx)(Ps,{className:`w-3.5 h-3.5`})})]}),(0,Y.jsxs)(`div`,{className:`relative inline-block max-w-full max-h-full`,children:[(0,Y.jsx)(`img`,{ref:b,src:e.screenshotDataUrl,alt:s(`editor.capturedAlt`),onLoad:S,draggable:!1,className:`block max-w-full max-h-full select-none rounded shadow-2xl`}),x.map(e=>e.kind===`blur`?(0,Y.jsx)(`div`,{className:`absolute backdrop-blur-md bg-background-deep/10 border border-border/40 pointer-events-none rounded-sm`,style:{left:`${e.x*100}%`,top:`${e.y*100}%`,width:`${e.w*100}%`,height:`${e.h*100}%`}},e.id):null),m&&u===`blur`&&j&&(0,Y.jsx)(`div`,{className:`absolute backdrop-blur-md bg-background-deep/10 border border-accent-info pointer-events-none rounded-sm`,style:{left:`${j.x*100}%`,top:`${j.y*100}%`,width:`${j.w*100}%`,height:`${j.h*100}%`}}),(0,Y.jsxs)(`svg`,{className:`absolute inset-0 w-full h-full ${u===`text`||u===`step`?`cursor-pointer`:`cursor-crosshair`}`,viewBox:`0 0 ${g.w} ${g.h}`,preserveAspectRatio:`none`,onPointerDown:w,onPointerMove:T,onPointerUp:E,children:[x.map(e=>{if(e.kind===`box`)return(0,Y.jsx)(`rect`,{x:A(e.x,`w`),y:A(e.y,`h`),width:A(e.w,`w`),height:A(e.h,`h`),fill:`none`,stroke:e.color,strokeWidth:Math.max(2,g.w*.004)},e.id);if(e.kind===`arrow`){let t=nk(e.from,e.to,.035),n=Math.max(2,g.w*.004);return(0,Y.jsxs)(`g`,{stroke:e.color,strokeWidth:n,strokeLinecap:`round`,fill:`none`,children:[(0,Y.jsx)(`line`,{x1:A(e.from.x,`w`),y1:A(e.from.y,`h`),x2:A(e.to.x,`w`),y2:A(e.to.y,`h`)}),(0,Y.jsx)(`polyline`,{points:`${A(t.left.x,`w`)},${A(t.left.y,`h`)} ${A(e.to.x,`w`)},${A(e.to.y,`h`)} ${A(t.right.x,`w`)},${A(t.right.y,`h`)}`})]},e.id)}if(e.kind===`text`)return(0,Y.jsx)(`text`,{x:A(e.x,`w`),y:A(e.y,`h`),dominantBaseline:`hanging`,fontSize:Math.max(12,g.h*.03),fontWeight:600,fill:e.color,stroke:`rgba(0,0,0,0.55)`,strokeWidth:1,paintOrder:`stroke`,children:e.text},e.id);if(e.kind===`step`){let t=Math.max(10,g.h*.025);return(0,Y.jsxs)(`g`,{children:[(0,Y.jsx)(`circle`,{cx:A(e.x,`w`),cy:A(e.y,`h`),r:t,fill:e.color}),(0,Y.jsx)(`text`,{x:A(e.x,`w`),y:A(e.y,`h`),textAnchor:`middle`,dominantBaseline:`central`,fontSize:t*1.1,fontWeight:700,fill:`#000`,children:e.n})]},e.id)}return null}),m&&u===`box`&&j&&(0,Y.jsx)(`rect`,{x:A(j.x,`w`),y:A(j.y,`h`),width:A(j.w,`w`),height:A(j.h,`h`),fill:`none`,stroke:f,strokeDasharray:`4 3`,strokeWidth:Math.max(2,g.w*.004)}),m&&u===`arrow`&&(0,Y.jsx)(`line`,{x1:A(m.start.x,`w`),y1:A(m.start.y,`h`),x2:A(m.cur.x,`w`),y2:A(m.cur.y,`h`),stroke:f,strokeWidth:Math.max(2,g.w*.004),strokeLinecap:`round`})]}),v&&(0,Y.jsxs)(`div`,{className:`absolute inset-0 flex items-center justify-center gap-2 bg-background-deep/50 text-sm text-foreground`,children:[(0,Y.jsx)(cs,{className:`w-4 h-4 animate-spin`}),` `,s(`common:states.saving`)]})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsxs)(Z,{size:`sm`,variant:`ghost`,className:`gap-1.5`,onClick:a,disabled:v,children:[(0,Y.jsx)(Ba,{className:`w-3.5 h-3.5`}),` `,s(`editor.reselect`)]}),(0,Y.jsxs)(Z,{size:`sm`,variant:`ghost`,className:`gap-1.5`,onClick:k,disabled:v,children:[(0,Y.jsx)(hc,{className:`w-3.5 h-3.5`}),` `,s(`common:actions.cancel`)]}),(0,Y.jsxs)(Z,{size:`sm`,className:`gap-1.5`,onClick:()=>void O(),disabled:v,"data-testid":`annotation-confirm`,children:[(0,Y.jsx)(to,{className:`w-3.5 h-3.5`}),` `,x.length>0?r??s(`editor.createSpec`):s(`editor.skipContinue`)]})]})]})}function dk(){return typeof window>`u`||!(`__TAURI_INTERNALS__`in window)?!1:/mac/i.test(navigator.platform)}var fk={desktop:{w:1280,h:800},tablet:{w:768,h:1024},mobile:{w:375,h:667}};function pk({open:e,onClose:t,projectId:n,pendingSpecId:r,onCaptured:i,confirmLabel:a}){let{t:o}=K(`browser`),s=ZO({projectId:n,open:e}),{canvasRef:c,viewport:l,status:u,errorMsg:d,url:f,title:p,hoverRect:m,hoverSelector:h,hoverPath:g,popup:_}=s,[v,y]=(0,H.useState)(``),[b,x]=(0,H.useState)(!1),[S,C]=(0,H.useState)(null),[w,T]=(0,H.useState)(!1),[E,D]=(0,H.useState)(`fit`),[O,k]=(0,H.useState)(!0),[A,j]=(0,H.useState)(!1),[M,N]=(0,H.useState)(null),[P,F]=(0,H.useState)(null),[I,L]=(0,H.useState)(null),R=(0,H.useRef)(null),z=(0,H.useRef)(null),ee=(0,H.useRef)(null),te=(0,H.useRef)(s.forwardInput);te.current=s.forwardInput;let B=(0,H.useRef)(null),ne=(0,H.useCallback)(()=>(B.current??=zO(e=>te.current(e)),B.current),[]);(0,H.useEffect)(()=>()=>{B.current?.dispose(),B.current=null},[]);let V=(0,H.useRef)(`fit`),re=(0,H.useRef)(null),U=(0,H.useRef)(0),ie=(0,H.useRef)(null),ae=(0,H.useRef)(null),W=(0,H.useRef)(s.navigateElement);(0,H.useEffect)(()=>{ie.current=I},[I]),(0,H.useEffect)(()=>{ae.current=h},[h]),W.current=s.navigateElement,(0,H.useEffect)(()=>{y(f??``)},[f]);let oe=(0,H.useCallback)(()=>{let e=v.trim();e&&s.navigate(`goto`,e)},[v,s]),se=(0,H.useCallback)(()=>{let e=R.current;if(!e)return;let t=e.getBoundingClientRect();t.width>0&&t.height>0&&s.setViewport(t.width,t.height)},[s]),ce=(0,H.useCallback)(e=>{D(e),V.current=e,e===`fit`?se():s.setViewport(fk[e].w,fk[e].h)},[se,s]);(0,H.useEffect)(()=>{if(!e)return;let t=R.current;if(!t||typeof ResizeObserver>`u`)return;let n=null,r=new ResizeObserver(()=>{V.current===`fit`&&(n&&clearTimeout(n),n=setTimeout(()=>{let e=t.getBoundingClientRect();e.width>0&&e.height>0&&s.setViewport(e.width,e.height)},150))});return r.observe(t),()=>{n&&clearTimeout(n),r.disconnect()}},[e,s]),(0,H.useEffect)(()=>{if(!e)return;let n=e=>{e.key===`Escape`&&(b?(x(!1),C(null),L(null)):t())};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e,b,t]),(0,H.useEffect)(()=>{if(!e||!b)return;let t=e=>{if(e.key!==`ArrowUp`&&e.key!==`ArrowDown`)return;let t=ie.current?.selector??ae.current;t&&(e.preventDefault(),W.current(t,e.key===`ArrowUp`?`parent`:`child`).then(e=>{e&&L(e)}))};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e,b]),(0,H.useEffect)(()=>{_?.active&&b&&(x(!1),C(null),L(null),s.clearHover())},[_?.active,b]);let le=(0,H.useCallback)(()=>{let e=c.current?.getBoundingClientRect()??null;return e&&(re.current={left:e.left,top:e.top,width:e.width,height:e.height}),e},[c]),ue=(0,H.useCallback)((e,t)=>{let n=le();return n?BO({x:e,y:t},{left:n.left,top:n.top,width:n.width,height:n.height},l):{x:0,y:0}},[le,l]),de=(0,H.useCallback)(e=>{if(b)return;let t=ue(e.clientX,e.clientY);ne().move(t.x,t.y)},[b,ue,ne]),fe=e=>e===2?`right`:e===1?`middle`:`left`,pe=(0,H.useCallback)(e=>{if(b)return;let t=ue(e.clientX,e.clientY),n=ne();n.move(t.x,t.y),n.flush(),s.forwardInput({type:`mouse`,action:`down`,x:t.x,y:t.y,button:fe(e.button),clickCount:e.detail||1})},[b,ue,s,ne]),me=(0,H.useCallback)(e=>{if(b)return;let t=ue(e.clientX,e.clientY),n=ne();n.move(t.x,t.y),n.flush(),s.forwardInput({type:`mouse`,action:`up`,x:t.x,y:t.y,button:fe(e.button),clickCount:e.detail||1})},[b,ue,s,ne]),he=(0,H.useCallback)(e=>{if(b)return;let t=ue(e.clientX,e.clientY);ne().wheel(t.x,t.y,e.deltaX,e.deltaY)},[b,ue,ne]),ge=(0,H.useCallback)(e=>{if(b||e.key===`Escape`)return;let t=e.metaKey||e.ctrlKey;if(t&&(e.key===`c`||e.key===`v`||e.key===`x`)){e.preventDefault();let t=e.key;(async()=>{try{if(t===`v`){let e=await navigator.clipboard.readText();e&&await s.clipboard(`paste`,e)}else{let{text:e}=await s.clipboard(t===`x`?`cut`:`copy`);e&&await navigator.clipboard.writeText(e)}}catch{}})();return}let n={type:`key`,action:`down`,key:e.key,code:e.code,text:!t&&e.key.length===1?e.key:void 0};s.forwardInput(n),(e.key===`Tab`||e.key===` `||e.key.startsWith(`Arrow`))&&e.preventDefault()},[b,s]),_e=(0,H.useCallback)(e=>{b||e.key===`Escape`||s.forwardInput({type:`key`,action:`up`,key:e.key,code:e.code})},[b,s]),ve=(0,H.useCallback)(async e=>{let n=WO(e,l);T(!0),F(null);try{if(A){let e={x:n.x+n.width/2,y:n.y+n.height/2};i(await s.captureBreakpoints(n,e,r,CO)),q.success(o(`modal.toast.captured`)),t()}else N(await s.capture(n,r,{captureNetwork:O}))}catch(e){F(e instanceof Error?e.message:String(e)),q.error(o(`modal.toast.captureFailed`))}finally{T(!1),x(!1),C(null),L(null),s.clearHover()}},[s,r,O,A,i,t,o,l]),ye=(0,H.useCallback)(e=>{s.navigateElement(e.selector,`self`).then(e=>{e&&L(e)})},[s]),G=(0,H.useCallback)(e=>{e.target.setPointerCapture?.(e.pointerId),F(null),C({startX:e.clientX,startY:e.clientY,curX:e.clientX,curY:e.clientY})},[]),be=(0,H.useCallback)(e=>{if(S){let t=e.clientX,n=e.clientY;C(e=>e&&{...e,curX:t,curY:n});return}ie.current&&L(null),z.current=ue(e.clientX,e.clientY),ee.current??=requestAnimationFrame(()=>{ee.current=null;let e=typeof performance<`u`?performance.now():Date.now();if(e-U.current<40)return;U.current=e;let t=z.current;t&&s.probe(t)})},[S,ue,s]),xe=(0,H.useCallback)(e=>{let t=ie.current;C(n=>{if(n){let r=HO(ue(n.startX,n.startY),ue(e.clientX,e.clientY));UO(r)?ve(r):t?ve(t.rect):m&&ve(m)}return null})},[ue,m,ve]),Se=(0,H.useCallback)(e=>{e.target===e.currentTarget&&t()},[t]);if(!e||typeof document>`u`)return null;let Ce=S?{left:Math.min(S.startX,S.curX),top:Math.min(S.startY,S.curY),width:Math.abs(S.startX-S.curX),height:Math.abs(S.startY-S.curY)}:null,we=re.current,Te=I?.rect??m,Ee=I?.path??g,De=b&&Te&&!S&&we?VO(Te,we,l):null,Oe=dk();return(0,sr.createPortal)((0,Y.jsx)(`div`,{className:`fixed inset-0 z-[80] bg-background-deep/50 backdrop-blur-sm pointer-events-auto`,onClick:Se,children:(0,Y.jsx)(`div`,{className:`absolute inset-2 flex flex-col border border-border rounded-lg bg-background-deep overflow-hidden`,role:`dialog`,"aria-modal":`true`,"aria-label":o(`modal.dialogLabel`),onClick:e=>e.stopPropagation(),children:M?(0,Y.jsx)(uk,{result:M,pendingSpecId:r,macOverlay:Oe,confirmLabel:a,onConfirm:e=>{i(e),t()},onReselect:()=>{N(null),x(!0)},onCancel:()=>{N(null),t()}}):(0,Y.jsxs)(Y.Fragment,{children:[P&&(0,Y.jsxs)(`div`,{role:`alert`,"data-testid":`capture-error-banner`,className:`flex items-center gap-2 px-3 py-2 text-xs bg-destructive/10 text-destructive border-b border-destructive/30 shrink-0`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:o(`modal.toast.captureFailed`)}),(0,Y.jsx)(`span`,{className:`opacity-80 font-mono truncate`,children:P})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 py-1.5 border-b border-border/50 bg-surface/80 shrink-0 ${Oe?`pr-3`:`px-3`}`,children:[Oe&&(0,Y.jsx)(`div`,{"data-tauri-drag-region":!0,className:`w-20 self-stretch shrink-0`,"aria-hidden":!0}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":o(`common:actions.back`),onClick:()=>s.navigate(`back`),children:(0,Y.jsx)(Ba,{className:`w-4 h-4`})}),(0,Y.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":o(`modal.nav.forward`),onClick:()=>s.navigate(`forward`),children:(0,Y.jsx)(Va,{className:`w-4 h-4`})}),(0,Y.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":o(`modal.nav.reload`),onClick:()=>s.navigate(`reload`),children:(0,Y.jsx)(zs,{className:`w-4 h-4`})})]}),(0,Y.jsxs)(`form`,{className:`flex-1 flex items-center gap-2 min-w-0`,onSubmit:e=>{e.preventDefault(),oe()},children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 flex-1 min-w-0 rounded-md border border-border bg-background px-2.5 py-1`,children:[(0,Y.jsx)(Ko,{className:`w-3.5 h-3.5 text-muted-foreground shrink-0`}),(0,Y.jsx)(`input`,{value:v,onChange:e=>y(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),oe())},placeholder:o(`modal.address.placeholder`),"aria-label":o(`modal.address.label`),className:`flex-1 min-w-0 bg-transparent outline-none text-sm`})]}),(0,Y.jsx)(Z,{type:`submit`,size:`sm`,variant:`secondary`,className:`shrink-0`,disabled:u===`error`,children:o(`modal.address.go`)})]}),(0,Y.jsx)(`div`,{className:`hidden md:flex items-center gap-0.5 rounded-md border border-border/50 p-0.5 shrink-0`,role:`group`,"aria-label":o(`modal.viewport.groupLabel`),children:[[`fit`,us],[`desktop`,hs],[`tablet`,rc],[`mobile`,Zs]].map(([e,t])=>(0,Y.jsx)(`button`,{type:`button`,"aria-label":o(`modal.viewport.presetLabel`,{preset:o(`modal.viewport.${e}`)}),"aria-pressed":E===e,title:o(`modal.viewport.presetTitle`,{preset:o(`modal.viewport.${e}`)}),onClick:()=>ce(e),className:`h-7 w-7 inline-flex items-center justify-center rounded transition-colors ${E===e?`bg-primary/15 text-primary`:`text-muted-foreground hover:text-foreground hover:bg-card/60`}`,children:(0,Y.jsx)(t,{className:`w-3.5 h-3.5`})},e))}),(0,Y.jsxs)(`button`,{type:`button`,"aria-label":o(`modal.network.ariaLabel`),"aria-pressed":O,title:o(O?`modal.network.titleOn`:`modal.network.titleOff`),onClick:()=>k(e=>!e),className:`hidden md:inline-flex items-center gap-1 h-7 px-2 rounded-md border text-[11px] shrink-0 transition-colors ${O?`border-accent-info/40 bg-accent-info/10 text-accent-info`:`border-border/50 text-muted-foreground hover:text-foreground hover:bg-card/60`}`,children:[(0,Y.jsx)(gs,{className:`w-3.5 h-3.5`}),o(`modal.network.button`)]}),(0,Y.jsxs)(`button`,{type:`button`,"aria-label":o(`modal.allSizes.ariaLabel`),"aria-pressed":A,title:o(A?`modal.allSizes.titleOn`:`modal.allSizes.titleOff`),onClick:()=>j(e=>!e),className:`hidden md:inline-flex items-center gap-1 h-7 px-2 rounded-md border text-[11px] shrink-0 transition-colors ${A?`border-accent-highlight/40 bg-accent-highlight/10 text-accent-highlight`:`border-border/50 text-muted-foreground hover:text-foreground hover:bg-card/60`}`,children:[(0,Y.jsx)(Ms,{className:`w-3.5 h-3.5`}),o(`modal.allSizes.button`)]}),(0,Y.jsxs)(Z,{size:`sm`,variant:b?`default`:`secondary`,className:`gap-1.5`,onClick:()=>{x(e=>!e),C(null),L(null),s.clearHover()},disabled:u!==`ready`||w||_?.active===!0,"data-testid":`browser-select-toggle`,children:[(0,Y.jsx)(So,{className:`w-3.5 h-3.5`}),o(b?`modal.select.active`:`modal.select.start`)]}),(0,Y.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":o(`modal.closeBrowser`),onClick:t,children:(0,Y.jsx)(hc,{className:`w-4 h-4`})})]}),(0,Y.jsxs)(`div`,{className:`px-3 py-1 text-[11px] text-muted-foreground truncate shrink-0 flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-full shrink-0 ${u===`ready`?`bg-accent-success`:u===`error`?`bg-destructive`:`bg-accent-warning animate-pulse`}`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`truncate`,children:u===`connecting`?o(`modal.status.connecting`):u===`error`?d??o(`modal.status.unavailable`):p||``})]}),_&&(0,Y.jsxs)(`div`,{"data-testid":`browser-popup-bar`,className:`flex items-center gap-2 px-3 py-1.5 text-xs border-b shrink-0 ${_.active?`bg-accent-info/10 border-accent-info/30 text-accent-info`:`bg-surface/70 border-border/40 text-muted-foreground`}`,children:[(0,Y.jsx)(Oo,{className:`w-3.5 h-3.5 shrink-0`}),_.active?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`truncate font-medium`,children:o(`popup.loginWindow`,{origin:FO(_.url)})}),_.count>1&&(0,Y.jsx)(`span`,{className:`shrink-0 opacity-70`,children:o(`popup.stacked`,{count:_.count-1})}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>s.setPopupView(`root`),className:`ml-auto shrink-0 inline-flex items-center gap-1 h-6 px-2 rounded-md border border-current/30 hover:bg-card/60 transition-colors`,children:[(0,Y.jsx)(Ba,{className:`w-3 h-3`}),o(`popup.backToPage`)]})]}):(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>s.setPopupView(`popup`),className:`inline-flex items-center gap-1 h-6 px-2 rounded-md border border-border/50 hover:bg-card/60 hover:text-foreground transition-colors`,children:[o(`popup.show`),_.count>1&&(0,Y.jsx)(`span`,{className:`opacity-70`,children:o(`popup.stacked`,{count:_.count-1})})]})]}),(0,Y.jsxs)(`div`,{ref:R,className:`relative flex-1 min-h-0 overflow-hidden flex items-center justify-center outline-none`,tabIndex:0,onKeyDown:ge,onKeyUp:_e,children:[u===`error`?(0,Y.jsxs)(`div`,{className:`flex flex-col items-center gap-2 text-center max-w-md px-6`,children:[(0,Y.jsx)(lc,{className:`w-8 h-8 text-accent-warning`}),(0,Y.jsx)(`p`,{className:`text-sm text-foreground/90`,children:d??o(`modal.error.unavailable`)}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:(0,Y.jsx)(Yi,{i18nKey:`modal.error.devHint`,t:o,components:{cmd:(0,Y.jsx)(`code`,{className:`font-mono`})}})})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`canvas`,{ref:c,className:`max-w-full max-h-full block shadow-2xl ${b?`cursor-crosshair`:`cursor-default`}`,onPointerMove:de,onPointerDown:pe,onPointerUp:me,onContextMenu:e=>e.preventDefault(),onWheel:he}),b&&(0,Y.jsx)(`div`,{className:`absolute inset-0 cursor-crosshair`,onPointerDown:G,onPointerMove:be,onPointerUp:xe}),u===`connecting`&&(0,Y.jsxs)(`div`,{className:`absolute inset-0 flex items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,Y.jsx)(cs,{className:`w-4 h-4 animate-spin`}),` `,o(`modal.status.opening`)]}),w&&(0,Y.jsxs)(`div`,{className:`absolute inset-0 flex items-center justify-center gap-2 text-sm text-foreground bg-background-deep/40`,children:[(0,Y.jsx)(cs,{className:`w-4 h-4 animate-spin`}),` `,o(`modal.status.capturing`)]})]}),De&&(0,Y.jsx)(`div`,{className:`fixed border-2 border-accent-info bg-accent-info/10 pointer-events-none z-[81]`,style:{left:De.left,top:De.top,width:De.width,height:De.height}}),Ce&&(0,Y.jsx)(`div`,{className:`fixed border-2 border-accent-primary bg-accent-primary/10 pointer-events-none z-[81]`,style:Ce})]}),b&&Ee&&Ee.length>0&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 px-3 py-1.5 border-t border-border/40 bg-surface/70 shrink-0 overflow-x-auto text-[11px]`,children:[I?(0,Y.jsx)(ls,{className:`w-3 h-3 shrink-0 text-accent-info`}):null,Ee.map((e,t)=>(0,Y.jsxs)(H.Fragment,{children:[t>0&&(0,Y.jsx)(io,{className:`w-3 h-3 text-muted-foreground/50 shrink-0`}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>ye(e),title:e.selector,className:`shrink-0 font-mono px-1 rounded hover:bg-card/60 transition-colors ${t===Ee.length-1?`text-accent-info font-medium`:`text-foreground/70`}`,children:e.label})]},`${e.selector}-${t}`)),(0,Y.jsx)(`span`,{className:`text-muted-foreground/60 shrink-0 ml-auto pl-2 hidden md:inline`,children:o(`modal.breadcrumb.hint`)})]}),b&&(0,Y.jsx)(`div`,{className:`px-3 py-1.5 text-center text-[11px] text-muted-foreground border-t border-border/40 shrink-0`,children:o(`modal.select.hint`)})]})})}),document.body)}function mk(e,t){t.push({type:`punct`,text:`<`});let n=1;e[n]===`/`&&(t.push({type:`punct`,text:`/`}),n++);let r=/^[a-zA-Z][a-zA-Z0-9-]*/.exec(e.slice(n));r&&(t.push({type:`tag`,text:r[0]}),n+=r[0].length);let i=e.slice(n,e.length-1),a=/(\s+)|([a-zA-Z_:][-a-zA-Z0-9_:.]*)|(=)|("[^"]*"|'[^']*')|(\/)/g,o;for(;(o=a.exec(i))!==null;)o[1]?t.push({type:`text`,text:o[1]}):o[2]?t.push({type:`attr`,text:o[2]}):o[3]?t.push({type:`punct`,text:`=`}):o[4]?t.push({type:`value`,text:o[4]}):o[5]&&t.push({type:`punct`,text:`/`});t.push({type:`punct`,text:`>`})}function hk(e){let t=[],n=0;for(;n<e.length;){let r=e.indexOf(`<`,n);if(r===-1){n<e.length&&t.push({type:`text`,text:e.slice(n)});break}r>n&&t.push({type:`text`,text:e.slice(n,r)});let i=e.indexOf(`>`,r);if(i===-1){t.push({type:`text`,text:e.slice(r)});break}mk(e.slice(r,i+1),t),n=i+1}return t}var gk={tag:`text-accent-info`,attr:`text-accent-secondary`,value:`text-accent-success`,punct:`text-muted-foreground`,text:`text-foreground/80`};function _k(e){try{let t=new URL(e);return t.host+t.pathname}catch{return e}}var vk=4e4;function yk({html:e}){let t=(0,H.useMemo)(()=>e.length>vk?null:hk(e),[e]);return t?(0,Y.jsx)(Y.Fragment,{children:t.map((e,t)=>(0,Y.jsx)(`span`,{className:gk[e.type],children:e.text},t))}):(0,Y.jsx)(Y.Fragment,{children:e})}function bk({dom:e,onRemove:t}){let{t:n}=K(`browser`),[r,i]=(0,H.useState)(!1),[a,o]=(0,H.useState)(!1),[s,c]=(0,H.useState)(!1),[l,u]=(0,H.useState)(!1),[d,f]=(0,H.useState)(!1),p=GO(e),m=e.designTokens,h=m?Object.entries(m.anchor):[],g=!!m&&(m.palette.length>0||h.length>0),_=e.networkRequests??[],v=_.length>0,y=(()=>{try{return new URL(e.url).host}catch{return e.url}})();return(0,Y.jsxs)(`div`,{className:`rounded-lg border border-accent-secondary/40 bg-accent-secondary/5 text-xs`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>i(e=>!e),"aria-expanded":r,className:`flex items-center gap-2 flex-1 min-w-0 text-left text-foreground/90 hover:text-foreground transition-colors`,children:[(0,Y.jsx)(io,{className:`w-3.5 h-3.5 shrink-0 transition-transform ${r?`rotate-90`:``}`}),(0,Y.jsx)(ho,{className:`w-3.5 h-3.5 shrink-0 text-accent-secondary`}),(0,Y.jsx)(`span`,{className:`truncate font-medium`,children:n(`domPanel.header`,{title:e.title||y})})]}),(0,Y.jsxs)(`span`,{className:`shrink-0 text-[10px] text-muted-foreground tabular-nums`,children:[n(`domPanel.badge.elements`,{count:p.nodeCount}),e.css?` · CSS`:``,g?` · ${n(`domPanel.badge.tokens`)}`:``,v?` · ${n(`domPanel.badge.requests`,{count:_.length})}`:``,p.truncated?` · ${n(`domPanel.badge.truncated`)}`:``]}),t&&(0,Y.jsx)(`button`,{type:`button`,onClick:t,"aria-label":n(`domPanel.removeLabel`),className:`shrink-0 text-muted-foreground/60 hover:text-destructive transition-colors`,children:(0,Y.jsx)(hc,{className:`w-3.5 h-3.5`})})]}),r&&(0,Y.jsxs)(`div`,{className:`border-t border-accent-secondary/30`,children:[(0,Y.jsx)(`div`,{className:`px-3 py-1.5 text-[10px] text-muted-foreground truncate`,title:e.url,children:e.url}),(0,Y.jsx)(`pre`,{className:`max-h-64 overflow-auto px-3 pb-3 text-[11px] leading-relaxed whitespace-pre-wrap break-words font-mono`,"data-testid":`captured-dom-html`,children:e.html?(0,Y.jsx)(yk,{html:e.html}):n(`domPanel.noMarkup`)}),e.css&&(0,Y.jsxs)(`div`,{className:`border-t border-accent-secondary/30`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>o(e=>!e),"aria-expanded":a,className:`flex items-center gap-2 w-full px-3 py-2 text-left text-foreground/90 hover:text-foreground transition-colors`,children:[(0,Y.jsx)(io,{className:`w-3.5 h-3.5 shrink-0 transition-transform ${a?`rotate-90`:``}`}),(0,Y.jsx)(ys,{className:`w-3.5 h-3.5 shrink-0 text-accent-highlight`}),(0,Y.jsx)(`span`,{className:`font-medium`,children:e.cssTruncated?n(`domPanel.appliedCssTruncated`):n(`domPanel.appliedCss`)})]}),a&&(0,Y.jsx)(`pre`,{className:`max-h-64 overflow-auto px-3 pb-3 text-[11px] leading-relaxed whitespace-pre-wrap break-words font-mono text-accent-success/90`,"data-testid":`captured-dom-css`,children:e.css})]}),g&&m&&(0,Y.jsxs)(`div`,{className:`border-t border-accent-secondary/30`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>c(e=>!e),"aria-expanded":s,className:`flex items-center gap-2 w-full px-3 py-2 text-left text-foreground/90 hover:text-foreground transition-colors`,children:[(0,Y.jsx)(io,{className:`w-3.5 h-3.5 shrink-0 transition-transform ${s?`rotate-90`:``}`}),(0,Y.jsx)(Es,{className:`w-3.5 h-3.5 shrink-0 text-accent-highlight`}),(0,Y.jsx)(`span`,{className:`font-medium`,children:n(`domPanel.designTokens`)})]}),s&&(0,Y.jsxs)(`div`,{className:`px-3 pb-3 space-y-2`,"data-testid":`captured-dom-tokens`,children:[m.palette.length>0&&(0,Y.jsx)(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:m.palette.map((e,t)=>(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded border border-border/50 px-1.5 py-0.5 font-mono text-[10px] text-foreground/80`,children:[(0,Y.jsx)(`span`,{className:`inline-block w-3 h-3 rounded-sm border border-border/40`,style:{background:e},"aria-hidden":!0}),e]},t))}),h.length>0&&(0,Y.jsx)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5 font-mono text-[11px]`,children:h.map(([e,t])=>(0,Y.jsxs)(H.Fragment,{children:[(0,Y.jsx)(`dt`,{className:`text-muted-foreground`,children:e}),(0,Y.jsx)(`dd`,{className:`text-accent-success/90 break-all`,children:t})]},e))}),m.fonts.length>0&&(0,Y.jsxs)(`div`,{className:`text-[11px] text-muted-foreground`,children:[n(`domPanel.fonts`),` `,(0,Y.jsx)(`span`,{className:`font-mono text-foreground/80 break-all`,children:m.fonts.join(`, `)})]}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>{try{navigator.clipboard?.writeText(JSON.stringify(m,null,2)),f(!0),setTimeout(()=>f(!1),1500)}catch{}},className:`text-[10px] text-accent-info hover:underline`,children:n(d?`domPanel.copied`:`domPanel.copyJson`)})]})]}),v&&(0,Y.jsxs)(`div`,{className:`border-t border-accent-secondary/30`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>u(e=>!e),"aria-expanded":l,className:`flex items-center gap-2 w-full px-3 py-2 text-left text-foreground/90 hover:text-foreground transition-colors`,children:[(0,Y.jsx)(io,{className:`w-3.5 h-3.5 shrink-0 transition-transform ${l?`rotate-90`:``}`}),(0,Y.jsx)(gs,{className:`w-3.5 h-3.5 shrink-0 text-accent-info`}),(0,Y.jsx)(`span`,{className:`font-medium`,children:n(`domPanel.network`,{count:_.length})})]}),l&&(0,Y.jsx)(`div`,{className:`max-h-64 overflow-auto px-3 pb-3 space-y-1.5`,"data-testid":`captured-dom-network`,children:_.map((e,t)=>(0,Y.jsxs)(`div`,{className:`font-mono text-[11px] leading-snug`,children:[(0,Y.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-accent-highlight shrink-0`,children:e.method}),(0,Y.jsx)(`span`,{className:`shrink-0 tabular-nums ${e.failed?`text-destructive`:(e.status??0)>=400?`text-accent-warning`:`text-accent-success/90`}`,children:e.failed?`ERR`:e.status??`…`}),(0,Y.jsx)(`span`,{className:`truncate flex-1 text-foreground/80`,title:e.url,children:_k(e.url)}),e.durationMs!=null&&(0,Y.jsxs)(`span`,{className:`shrink-0 text-muted-foreground tabular-nums`,children:[e.durationMs,`ms`]})]}),e.responseShape&&(0,Y.jsxs)(`div`,{className:`pl-4 text-accent-info/80 break-all whitespace-pre-wrap`,children:[`→ `,e.responseShape]})]},t))})]})]})]})}var xk={critical:`bg-destructive/15 text-destructive`,high:`bg-accent-warning/15 text-accent-warning`,medium:`bg-accent-info/15 text-accent-info`,low:`bg-muted text-muted-foreground`},Sk=[`critical`,`high`,`medium`,`low`];function Ck(){return typeof crypto<`u`&&crypto.randomUUID?crypto.randomUUID():`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)})}function wk({open:e,onClose:t,tickets:n,onExploreLaunch:r}){let{t:i}=K(`addspec`),{t:a}=K(`jira`),s=Wb(),{activeProjectId:c,projects:l}=gm(),u=bD(),[d,f]=(0,H.useState)(`quick`),[p,m]=(0,H.useState)(!1),[h,g]=(0,H.useState)(!1),[_,v]=(0,H.useState)(0),[y,b]=(0,H.useState)(()=>Ck()),[x,S]=(0,H.useState)(!1),[C,w]=(0,H.useState)([]),T=SO(),E=(0,H.useRef)(null),D=(0,H.useRef)(!1),O=(0,H.useRef)(!1),[k,A]=(0,H.useState)(``),j=(0,H.useRef)(!1),[M,N]=(0,H.useState)(`medium`),[P,F]=(0,H.useState)([]),[I,L]=(0,H.useState)(null),{model:R,setModel:z,allowed:ee,loading:te,provider:B,providers:ne}=HD(c,e,I);(0,H.useEffect)(()=>{!e||I||ne.length===0||L(hO(c,ne,B??`claude`))},[e,I,ne,B,c]);let V=(0,H.useCallback)(e=>{L(e),gO(c,e)},[c]),re=I??B,{scope:U,setScope:ie,persist:ae}=_O(c,d,e),W=yO(c,e),{data:oe,isError:se}=vO(c,e),ce=(0,H.useMemo)(()=>ZD(U),[U]),le=UD(re);(0,H.useEffect)(()=>{d!==`quick`||!W.loaded||O.current||ie(e=>({...e,contractRefine:W.value}))},[d,W.loaded,W.value,ie]);let ue=(0,H.useCallback)(e=>{O.current=!0,ie(e)},[ie]);(0,H.useEffect)(()=>{O.current=!1},[d]);let de=(0,H.useRef)(c);(0,H.useEffect)(()=>{de.current=c},[c]);let fe=(0,H.useRef)(l);(0,H.useEffect)(()=>{fe.current=l},[l]),(0,H.useEffect)(()=>{e&&(b(Ck()),f(`quick`),m(!1),g(!1),v(0),L(null),S(!1),w([]),A(``),N(`medium`),F([]),D.current=!1,O.current=!1,j.current=!1,setTimeout(()=>{E.current?.resetHeight(),E.current?.focus()},50))},[e]),(0,H.useEffect)(()=>{!e&&!D.current&&_>0&&CD(y).catch(e=>console.warn(`[ProposeSpec] cleanup failed:`,e))},[e]);let pe=(0,H.useMemo)(()=>(h||C.length>0)&&!p,[h,C.length,p]),me=(0,H.useCallback)(e=>{if(e.rawScreenshot&&e.rawScreenshot.id!==e.screenshot.id){let t=de.current;fetch(`${o}/api/projects/${t}/tickets/${y}/attachments/${e.rawScreenshot.id}`,{method:`DELETE`}).catch(()=>{})}let t=e.breakpoints?Object.entries(e.breakpoints).map(([e,t])=>({key:e,attachmentId:t.attachment.id,dataUrl:t.dataUrl,width:t.viewport.width})):void 0;w(n=>[...n,{screenshotId:e.screenshot.id,screenshotName:e.screenshot.filename,screenshotDataUrl:e.screenshotDataUrl,domAttachmentId:e.domAttachment.id,dom:e.dom,breakpoints:t}]),v(e=>e+1+(t?t.length:1))},[y]),he=(0,H.useCallback)(e=>{w(t=>t.filter(t=>t.domAttachmentId!==e.domAttachmentId));let t=new Set([e.screenshotId,e.domAttachmentId,...e.breakpoints?.map(e=>e.attachmentId)??[]]);v(e=>Math.max(0,e-t.size));let n=de.current;for(let e of t)fetch(`${o}/api/projects/${n}/tickets/${y}/attachments/${e}`,{method:`DELETE`}).catch(()=>{})},[y]),ge=(0,H.useCallback)(async()=>{let e=(E.current?.getPlainText().trim()??``)||(C.length>0?`Create a spec based on the captured browser selection (a screenshot and the page DOM are attached for reference).`:``);if(!e)return;let a=C.find(e=>e.breakpoints&&e.breakpoints.length>1);if(a){let t=a.breakpoints.map(e=>`${e.width}px`).join(`, `);e+=`${e?`
@@ -108,7 +108,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
108
108
  `);if(e===-1)return``;t=t.slice(e+1).replace(/^\s+/,``)}if(t.startsWith(`## Spec context`)){let e=t.indexOf(`## Instruction
109
109
 
110
110
  `);if(e!==-1)return t.slice(e+16).trimStart()}return t}function ZR(e){if(!e)return null;let t=new Date(e);return isNaN(t.getTime())?null:t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}function QR({role:e,content:t,streaming:n,timestamp:r,provider:i}){let{t:a}=K(`explore`);if(e===`system`)return null;let o=e===`user`,s=o?XR(t):t;if(!s.trim()&&!n)return null;let c=ZR(r);return(0,Y.jsx)(`div`,{className:`flex ${o?`justify-end`:`justify-start`}`,children:(0,Y.jsxs)(`div`,{className:`max-w-[85%] rounded-lg px-3 py-2 text-sm ${o?`bg-primary/10 text-foreground`:`bg-card/60 border border-border/40`}`,children:[(0,Y.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 mb-1`,children:[(0,Y.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground/60 font-semibold`,children:o?a(`shell.you`):JD(i)}),c&&(0,Y.jsx)(`div`,{className:`text-[10px] text-muted-foreground/50 font-mono tabular-nums`,children:c})]}),o?(0,Y.jsxs)(`div`,{className:`whitespace-pre-wrap break-words`,children:[s,n&&(0,Y.jsx)(`span`,{className:`inline-block w-1 h-3 bg-primary/60 ml-0.5 animate-pulse align-baseline`})]}):(0,Y.jsxs)(`div`,{className:[`prose prose-sm max-w-none break-words`,`text-foreground`,`[&_p]:text-foreground [&_li]:text-foreground`,`[&_p]:my-1.5 [&_ul]:my-1.5 [&_ol]:my-1.5 [&_li]:my-0.5`,`[&_p:first-child]:mt-0 [&_p:last-child]:mb-0`,`[&_strong]:text-accent-primary [&_strong]:font-semibold`,`[&_code]:rounded [&_code]:bg-background/60 [&_code]:px-1 [&_code]:py-0.5 [&_code]:font-mono [&_code]:text-accent-primary [&_code]:text-[12px]`,`[&_pre]:rounded [&_pre]:bg-background/60 [&_pre]:p-2 [&_pre]:my-2`,`[&_pre_code]:bg-transparent [&_pre_code]:p-0`,`[&_a]:text-accent-primary [&_a]:underline`,`[&_h1]:text-foreground [&_h2]:text-foreground [&_h3]:text-foreground`,`[&_h1]:text-base [&_h2]:text-sm [&_h3]:text-sm [&_h1]:font-semibold [&_h2]:font-semibold [&_h3]:font-semibold`].join(` `),children:[(0,Y.jsx)(cI,{remarkPlugins:[KL],children:s}),n&&(0,Y.jsx)(`span`,{className:`inline-block w-1 h-3 bg-primary/60 ml-0.5 animate-pulse align-baseline`})]})]})})}function $R({errorMessage:e,onRetry:t,onClose:n}){let{t:r}=K(`nav`);return(0,Y.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-4 p-8`,children:[(0,Y.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,Y.jsx)(`h2`,{className:`text-base font-semibold`,children:r(`errorBoundary.title`)}),e&&(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground/60 font-mono max-w-md break-words`,children:e})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:t,className:`flex items-center gap-2 px-4 py-2 rounded-md text-sm font-medium bg-primary text-primary-foreground hover:bg-primary/90 transition-colors`,children:[(0,Y.jsx)(Fs,{className:`w-3.5 h-3.5`}),r(`common:actions.retry`)]}),n&&(0,Y.jsxs)(`button`,{type:`button`,onClick:n,className:`flex items-center gap-2 px-4 py-2 rounded-md text-sm font-medium border border-border hover:bg-muted/40 transition-colors`,children:[(0,Y.jsx)(hc,{className:`w-3.5 h-3.5`}),r(`common:actions.close`)]})]})]})}var ez=class extends H.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error(`[ShellErrorBoundary]`,e,t.componentStack)}handleRetry=()=>{this.setState({hasError:!1,error:null})};render(){return this.state.hasError?(0,Y.jsx)($R,{errorMessage:this.state.error?.message??null,onRetry:this.handleRetry,onClose:this.props.onClose}):this.props.children}},tz=`specrails-desktop:active-explore-spec`;function nz(){if(typeof window>`u`)return null;try{let e=window.localStorage.getItem(tz);if(!e)return null;let t=JSON.parse(e);return az(t)?t:null}catch{return null}}function rz(e){if(!(typeof window>`u`))try{window.localStorage.setItem(tz,JSON.stringify(e))}catch{}}function iz(){if(!(typeof window>`u`))try{window.localStorage.removeItem(tz)}catch{}}function az(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.projectId==`string`&&typeof t.idea==`string`&&typeof t.pendingSpecId==`string`&&Array.isArray(t.initialAttachmentIds)&&t.initialAttachmentIds.every(e=>typeof e==`string`)}function oz(e){return!!(e.title?.trim()||e.description?.trim()||e.priority&&e.priority!==`medium`||e.labels&&e.labels.length>0||e.acceptanceCriteria&&e.acceptanceCriteria.some(e=>e.trim()))}function sz(e,t,n){let r=e?.trim();if(r)return r;let i=t?.trim();if(i)return i;let a=n.trim();return a?a.length>60?a.slice(0,57)+`…`:a:am.t(`specs:board.untitledSpec`)}function cz({tickets:e,allTickets:t,doneTickets:n=[],isLoading:r,onTicketClick:i,onTicketCreated:a,onTicketDelete:o,contractRefiningIds:s=new Set,sortMode:c=`default`,sortDir:l=`desc`,onSortChange:u=()=>{},viewTier:d=`postit`,onViewTierChange:f,rails:p=[],onMoveToRail:m,continuableReviewTicketIds:h,onTicketStatusChange:g,onTicketPriorityChange:_}){let{t:v}=K(`specs`),[y,b]=(0,H.useState)(!1);(0,H.useEffect)(()=>{if(!y)return;let e=e=>{e.key===`Escape`&&b(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[y]);let x=(0,H.useCallback)(()=>{y&&b(!1)},[y]),S=(0,H.useCallback)(()=>b(!0),[]),C=(0,H.useCallback)(e=>{o&&o(e.id)},[o]),[w,T]=(0,H.useState)(!1),[E,D]=(0,H.useState)(null),{activeProjectId:O}=gm(),[k,A]=Yn(),[j,M]=(0,H.useState)(()=>cD(O).labels),[N,P]=(0,H.useState)(()=>cD(O).epic),[F,I]=(0,H.useState)(()=>cD(O).sprint),[L,R]=(0,H.useState)(()=>{let e=k.get(`status`);return dx(e)?e:hx(O)}),[z,ee]=(0,H.useState)(()=>k.get(`jiraStatus`)??cD(O).jiraStatus),te=(0,H.useCallback)(e=>{R(e),gx(O,e)},[O]);(0,H.useEffect)(()=>{A(e=>{let t=new URLSearchParams(e);return L===`active`?t.delete(`status`):t.set(`status`,L),z===null?t.delete(`jiraStatus`):t.set(`jiraStatus`,z),t.toString()===e.toString()?e:t},{replace:!0})},[L,z,A]);let{minimize:B}=Vg(),ne=(0,H.useMemo)(()=>{let e=new Map;for(let n of t??[])n.parent_epic_id!=null&&e.set(n.parent_epic_id,(e.get(n.parent_epic_id)??0)+1);return e},[t]),V=(0,H.useMemo)(()=>{let e=new Map;for(let n of t??[])n.is_epic&&e.set(n.id,n.title);return e},[t]),re=(0,H.useMemo)(()=>{let e=new Map;for(let n of t??[])e.set(n.id,n);return e},[t]),U=(0,H.useCallback)(e=>{let t=re.get(e);t&&i(t)},[re,i]),ie=(0,H.useRef)(!1);(0,H.useEffect)(()=>{let e=cD(O);M(e.labels),P(e.epic),I(e.sprint),ie.current&&(R(hx(O)),ee(e.jiraStatus)),ie.current=!0},[O]);let ae=(0,H.useCallback)(e=>{M(e),lD(O,{labels:e,epic:N,sprint:F,jiraStatus:z})},[O,N,F,z]),W=(0,H.useCallback)(e=>{P(e),lD(O,{labels:j,epic:e,sprint:F,jiraStatus:z})},[O,j,F,z]),oe=(0,H.useCallback)(e=>{I(e),lD(O,{labels:j,epic:N,sprint:e,jiraStatus:z})},[O,j,N,z]),se=(0,H.useCallback)(e=>{ee(e),lD(O,{labels:j,epic:N,sprint:F,jiraStatus:e})},[O,j,N,F]),ce=(0,H.useCallback)(e=>!(N!==null&&e.jira_epic_key!==N||F!==null&&e.jira_sprint_id!==F||j.size>0&&!(e.labels??[]).some(e=>j.has(e))),[j,N,F]),le=j.size===0&&N===null&&F===null,ue=(0,H.useMemo)(()=>le?e:e.filter(ce),[e,le,ce]),de=(0,H.useMemo)(()=>le?n:n.filter(ce),[n,le,ce]),fe=(0,H.useMemo)(()=>e.some(e=>e.jira_epic_key)||n.some(e=>e.jira_epic_key),[e,n]),pe=(0,H.useMemo)(()=>e.some(e=>e.jira_sprint_id)||n.some(e=>e.jira_sprint_id),[e,n]),me=(0,H.useMemo)(()=>e.some(e=>e.jira_key)||n.some(e=>e.jira_key),[e,n]),he=(0,H.useMemo)(()=>e.some(e=>e.jira_status)||n.some(e=>e.jira_status),[e,n]),ge=(0,H.useMemo)(()=>{let e={draft:0,todo:0,in_progress:0,on_review:0,done:0,cancelled:0};for(let t of ue)e[t.status]+=1;for(let t of de)e[t.status]+=1;return e},[ue,de]),_e=(0,H.useCallback)(e=>z===null||e.jira_status===z,[z]),ve=(0,H.useMemo)(()=>ue.filter(e=>fx(e.status,L)&&_e(e)),[ue,L,_e]),ye=(0,H.useMemo)(()=>{let e=de.filter(_e);return c===`default`?e:rD(e,c,l)},[de,_e,c,l]),[G,be]=(0,H.useState)({conversationId:null,draftTitle:``,composerText:``,draftOverrides:{}}),xe=(0,H.useRef)(G);xe.current=G;let Se=(0,H.useRef)(E);Se.current=E;let Ce=(0,H.useCallback)(()=>{let e=Se.current;!e||!e.projectId||(B({kind:`explore-spec`,projectId:e.projectId,label:sz(xe.current.draftTitle,e.seedDraftTitle,e.idea),restoreRoute:`/`,params:{initialIdea:e.idea,pendingSpecId:e.pendingSpecId,initialAttachmentIds:e.initialAttachmentIds,resumeConversationId:xe.current.conversationId??e.resumeConversationId,composerText:xe.current.composerText||void 0,draftOverrides:oz(xe.current.draftOverrides)?xe.current.draftOverrides:void 0,editTicket:e.editTicket}}),iz())},[B]);(0,H.useEffect)(()=>{if(!O)return;let e=nz();!e||e.projectId!==O||(be({conversationId:e.resumeConversationId??null,draftTitle:e.seedDraftTitle??``,composerText:e.composerText??``,draftOverrides:e.draftOverrides??{}}),D({projectId:e.projectId,idea:e.idea,pendingSpecId:e.pendingSpecId,initialAttachmentIds:e.initialAttachmentIds,resumeConversationId:e.resumeConversationId,seedDraftTitle:e.seedDraftTitle,seedComposerText:e.composerText,seedDraftOverrides:e.draftOverrides}))},[O]),(0,H.useEffect)(()=>{!E||!O||rz({projectId:O,idea:E.idea,pendingSpecId:E.pendingSpecId,initialAttachmentIds:E.initialAttachmentIds,resumeConversationId:G.conversationId??E.resumeConversationId,seedDraftTitle:G.draftTitle||E.seedDraftTitle,composerText:G.composerText||void 0,draftOverrides:oz(G.draftOverrides)?G.draftOverrides:void 0})},[E,O,G]);let we=(0,H.useCallback)(e=>{Ce(),be({conversationId:null,draftTitle:``,composerText:``,draftOverrides:{}}),O&&D({projectId:O,idea:e.idea,pendingSpecId:e.pendingSpecId,initialAttachmentIds:e.initialAttachmentIds,initialModel:e.model,initialProvider:e.provider,contextScope:e.contextScope})},[Ce,O]);Hg(`explore-spec`,O,e=>{e.kind===`explore-spec`&&(Ce(),be({conversationId:e.params.resumeConversationId??null,draftTitle:e.label,composerText:e.params.composerText??``,draftOverrides:e.params.draftOverrides??{}}),D({projectId:e.projectId,idea:e.params.initialIdea,pendingSpecId:e.params.pendingSpecId,initialAttachmentIds:e.params.initialAttachmentIds,resumeConversationId:e.params.resumeConversationId,seedDraftTitle:e.label,seedComposerText:e.params.composerText,seedDraftOverrides:e.params.draftOverrides,editTicket:e.params.editTicket}))}),(0,H.useEffect)(()=>{function e(e){if(!(e.metaKey||e.ctrlKey)||e.key!==`Enter`)return;let t=e.target?.tagName;t===`INPUT`||t===`TEXTAREA`||e.target?.isContentEditable||(e.preventDefault(),T(!0))}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let{isOver:Te,setNodeRef:Ee}=_d({id:`specs`}),{isOver:De,setNodeRef:Oe}=_d({id:`done-specs`}),ke=L!==`done`,Ae=L===`all`||L===`done`,je=L!==`active`||z!==null;return(0,Y.jsxs)(`div`,{className:`flex flex-col h-full`,onClick:x,children:[(0,Y.jsxs)(`div`,{className:`flex items-center px-4 h-12 border-b border-border/40 shrink-0 gap-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,Y.jsx)(Po,{className:`w-4 h-4 text-muted-foreground`}),(0,Y.jsx)(`h2`,{className:`text-sm font-semibold text-accent-primary`,children:v(`board.title`)}),e.length+n.length>0&&(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground bg-muted/30 rounded-full px-1.5 py-0.5`,children:!le||z!==null?`${ue.filter(_e).length+de.filter(_e).length}/${e.length+n.length}`:e.length+n.length})]}),(0,Y.jsx)(bx,{value:L,onChange:te,counts:ge}),he&&(0,Y.jsx)(Cx,{tickets:[...ue,...de],active:z,onChange:se}),(0,Y.jsx)(`div`,{className:`h-5 w-px bg-border/60 shrink-0`,"aria-hidden":!0}),(0,Y.jsx)(nx,{tickets:[...e,...n],active:j,onChange:ae}),fe&&(0,Y.jsx)(rx,{tickets:[...e,...n],active:N,onChange:W}),pe&&(0,Y.jsx)(ix,{tickets:[...e,...n],active:F,onChange:oe}),(0,Y.jsx)(`div`,{className:`h-5 w-px bg-border/60 shrink-0 ml-auto`,"aria-hidden":!0}),(0,Y.jsx)(BE,{mode:c,dir:l,onChange:u,showJiraSort:me,className:`shrink-0`}),f&&(0,Y.jsx)(`div`,{className:`shrink-0`,children:(0,Y.jsx)(HE,{tier:d,onChange:f})}),(0,Y.jsx)(`div`,{className:`h-5 w-px bg-border/60 shrink-0`,"aria-hidden":!0}),(0,Y.jsxs)(Z,{size:`sm`,variant:`outline`,className:`h-7 text-xs gap-1 shrink-0 border-accent-primary/50 text-accent-primary hover:bg-accent-primary/10 hover:text-accent-primary`,onClick:()=>T(!0),"data-tour":`add-spec-btn`,children:[(0,Y.jsx)(ks,{className:`w-3.5 h-3.5`}),v(`common:actions.add`)]})]}),(0,Y.jsxs)(`div`,{className:`flex-1 overflow-y-auto min-h-0`,children:[ke&&(0,Y.jsx)(`div`,{ref:Ee,"data-tour":`specs-list`,className:`px-4 pt-3 pb-2 space-y-1.5 transition-colors duration-150 ${Te?`bg-primary/[0.04]`:``}`,children:r?(0,Y.jsx)(`div`,{className:`space-y-1.5`,children:[0,1,2].map(e=>(0,Y.jsx)(`div`,{className:`h-10 rounded-lg border border-border/40 bg-card/50 animate-pulse`},e))}):ve.length===0?(0,Y.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-12 text-center transition-colors ${Te?`text-primary/50`:`text-muted-foreground`}`,children:[(0,Y.jsx)(Po,{className:`w-8 h-8 mb-3 opacity-20`}),(0,Y.jsx)(`p`,{className:`text-sm`,children:Te?v(`board.dropHere`):e.length===0?v(`board.emptyNoSpecs`):ue.length===0&&j.size>0?v(`board.emptyNoLabelMatch`):v(je?`board.emptyNoStatusMatch`:`board.emptyNoActiveSpecs`)}),!Te&&e.length===0&&(0,Y.jsx)(`p`,{className:`text-xs mt-1 opacity-60`,children:v(`board.emptyHint`)})]}):d===`postit`&&m?(0,Y.jsx)(Vd,{items:ve.map(e=>e.id),strategy:Ld,children:(0,Y.jsx)(`div`,{"data-testid":`specs-board-postit-grid`,className:`grid gap-3`,style:{gridTemplateColumns:`repeat(auto-fill, minmax(240px, 1fr))`},children:ve.map(e=>(0,Y.jsx)(lz,{ticket:e,onTicketDelete:o,onTicketStatusChange:g,onTicketPriorityChange:_,children:(0,Y.jsx)(Xg,{ticket:e,rails:p,onClick:i,onMoveToRail:m,contractRefining:s.has(e.id),epicChildrenCount:e.is_epic?ne.get(e.id)??0:void 0,parentEpicTitle:e.parent_epic_id==null?null:V.get(e.parent_epic_id)??null,onOpenParentEpic:U,jiggleMode:y,onLongPress:o?S:void 0,onDelete:o?C:void 0,allowOnReviewRailMove:h?.has(e.id)??!1})},e.id))})}):(0,Y.jsx)(Vd,{items:ve.map(e=>e.id),strategy:Ld,children:(0,Y.jsx)(`div`,{"data-testid":`specs-board-list`,"data-tier":`row`,className:`space-y-1.5`,children:ve.map(e=>(0,Y.jsx)(lz,{ticket:e,onTicketDelete:o,onTicketStatusChange:g,onTicketPriorityChange:_,children:(0,Y.jsx)(pg,{ticket:e,onClick:i,contractRefining:s.has(e.id),epicChildrenCount:e.is_epic?ne.get(e.id)??0:void 0,parentEpicTitle:e.parent_epic_id==null?null:V.get(e.parent_epic_id)??null,onOpenParentEpic:U,jiggleMode:y,onLongPress:o?S:void 0,onDelete:o?C:void 0,allowOnReviewDrag:h?.has(e.id)??!1})},e.id))})})}),Ae&&(0,Y.jsx)(`div`,{ref:Oe,"data-testid":`specs-board-done-bucket`,className:`px-4 pt-2 pb-3 space-y-1.5 transition-colors duration-150 ${De?`bg-emerald-500/[0.04] aurora-light:bg-accent-success/10`:``} ${ke?`border-t border-border/30 mt-1`:``}`,children:ye.length===0?(0,Y.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-6 text-center text-muted-foreground`,children:[(0,Y.jsx)(co,{className:`w-6 h-6 mb-2 opacity-15`}),(0,Y.jsx)(`p`,{className:`text-xs opacity-60`,children:De?v(`board.dropToMarkDone`):j.size>0&&n.length>0?v(`board.emptyNoDoneLabelMatch`):z!==null&&de.length>0?v(`board.emptyNoStatusMatch`):v(`board.emptyNoCompleted`)})]}):d===`postit`&&m?(0,Y.jsx)(Vd,{items:ye.map(e=>e.id),strategy:Ld,children:(0,Y.jsx)(`div`,{"data-testid":`specs-board-done-postit-grid`,className:`grid gap-3`,style:{gridTemplateColumns:`repeat(auto-fill, minmax(240px, 1fr))`},children:ye.map(e=>(0,Y.jsx)(lz,{ticket:e,onTicketDelete:o,onTicketStatusChange:g,onTicketPriorityChange:_,children:(0,Y.jsx)(Xg,{ticket:e,rails:p,onClick:i,onMoveToRail:m,contractRefining:s.has(e.id),epicChildrenCount:e.is_epic?ne.get(e.id)??0:void 0,parentEpicTitle:e.parent_epic_id==null?null:V.get(e.parent_epic_id)??null,onOpenParentEpic:U,jiggleMode:y,onLongPress:o?S:void 0,onDelete:o?C:void 0})},e.id))})}):(0,Y.jsx)(Vd,{items:ye.map(e=>e.id),strategy:Ld,children:ye.map(e=>(0,Y.jsx)(lz,{ticket:e,onTicketDelete:o,onTicketStatusChange:g,onTicketPriorityChange:_,children:(0,Y.jsx)(pg,{ticket:e,onClick:i,contractRefining:s.has(e.id),epicChildrenCount:e.is_epic?ne.get(e.id)??0:void 0,parentEpicTitle:e.parent_epic_id==null?null:V.get(e.parent_epic_id)??null,onOpenParentEpic:U,jiggleMode:y,onLongPress:o?S:void 0,onDelete:o?C:void 0})},e.id))})})]}),(0,Y.jsx)(wk,{open:w,onClose:()=>T(!1),tickets:t??e,onExploreLaunch:we}),E&&O&&(0,Y.jsx)(ez,{onClose:()=>D(null),children:(0,Y.jsx)(YR,{initialIdea:E.idea,pendingSpecId:E.pendingSpecId,initialAttachmentIds:E.initialAttachmentIds,initialModel:E.initialModel,initialProvider:E.initialProvider,resumeConversationId:E.resumeConversationId,seedDraftTitle:E.seedDraftTitle,seedComposerText:E.seedComposerText,seedDraftOverrides:E.seedDraftOverrides,editTicket:E.editTicket,contextScope:E.contextScope,onStateChange:e=>be(e),onClose:()=>{CD(E.pendingSpecId).catch(()=>{}),D(null),iz()},onMinimize:(e,t)=>{let n=xe.current;B({kind:`explore-spec`,projectId:E.projectId,label:sz(t,E.seedDraftTitle,E.idea),restoreRoute:`/`,params:{initialIdea:E.idea,pendingSpecId:E.pendingSpecId,initialAttachmentIds:E.initialAttachmentIds,resumeConversationId:e??void 0,composerText:n.composerText||void 0,draftOverrides:oz(n.draftOverrides)?n.draftOverrides:void 0}}),D(null),iz()},onTicketCreated:e=>{D(null),iz(),a?.(e)}},`${E.pendingSpecId}:${E.resumeConversationId??`fresh`}`)})]})}function lz({ticket:e,onTicketDelete:t,onTicketStatusChange:n,onTicketPriorityChange:r,children:i}){return!t||!n||!r?(0,Y.jsx)(Y.Fragment,{children:i}):(0,Y.jsx)(Qb,{ticket:e,onDelete:t,onStatusChange:n,onPriorityChange:r,children:i})}function uz({status:e,activeJobId:t,ticketCount:n,onToggle:r}){let{t:i}=K(`dashboard`),a=_t(),o=n>0;return(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[e===`running`&&t&&(0,Y.jsxs)(Z,{size:`sm`,variant:`ghost`,className:`group h-6 px-2 gap-1 rounded-md border border-accent-info/20 bg-accent-info/5 text-[10px] font-semibold text-accent-info transition-all duration-200 hover:-translate-y-px hover:border-accent-info/50 hover:bg-accent-info/15 hover:text-accent-info hover:shadow-[0_0_14px_hsl(191_97%_77%/0.22)] active:translate-y-0 active:scale-[0.98]`,onClick:()=>a(`/jobs/${t}`),title:i(`railControls.viewJobLog`),children:[(0,Y.jsx)(Hs,{className:`w-3 h-3 transition-transform duration-200 group-hover:scale-110`}),(0,Y.jsx)(`span`,{children:i(`railControls.log`)})]}),(0,Y.jsx)(Z,{size:`sm`,variant:`ghost`,className:`h-5 w-5 p-0 rounded-full transition-all duration-200 ${e===`running`?`text-red-400 aurora-light:text-destructive hover:text-red-300 aurora-light:hover:text-destructive hover:bg-red-400/10 aurora-light:hover:bg-destructive/10`:e===`failed`?`text-amber-400 aurora-light:text-accent-warning hover:text-emerald-300 aurora-light:hover:text-accent-success hover:bg-emerald-400/10 aurora-light:hover:bg-accent-success/10`:o?`text-emerald-400 aurora-light:text-accent-success hover:text-emerald-300 aurora-light:hover:text-accent-success hover:bg-emerald-400/10 aurora-light:hover:bg-accent-success/10`:`text-muted-foreground/30 cursor-not-allowed`}`,onClick:r,disabled:!o&&e!==`running`,title:i(e===`running`?`railControls.stop`:e===`failed`?`railControls.failedRetry`:o?`railControls.play`:`railControls.addSpecsFirst`),children:e===`running`?(0,Y.jsx)(tc,{className:`w-2.5 h-2.5 fill-current`}):e===`failed`?(0,Y.jsx)(lc,{className:`w-2.5 h-2.5`}):(0,Y.jsx)(Ds,{className:`w-2.5 h-2.5 fill-current`})})]})}var dz={implement:`factory:implement`,"batch-implement":`factory:batch`,freestyle:`factory:freestyle`},fz=[{id:`factory:implement`,labelKey:`railControls.implement`},{id:`factory:batch`,labelKey:`railControls.batch`},{id:`factory:freestyle`,labelKey:`railControls.freestyle`,claudeOnly:!0},{id:`factory:sdd-quick-openspec`,labelKey:`railControls.openspec`,requiresLoops:!0}];function pz(e){return e===`loop`?``:dz[e]}function mz(e){return e===`factory:implement`?`implement`:e===`factory:batch`?`batch-implement`:e===`factory:freestyle`?`freestyle`:`loop`}function hz(e,t){return e||pz(t)}var gz=`__legacy__`;function _z({value:e,onChange:t}){let{t:n}=K(`agents`),[r,i]=(0,H.useState)([]),[a,o]=(0,H.useState)(!1);if((0,H.useEffect)(()=>{let e=!1;return fetch(`${af()}/profiles`).then(e=>e.ok?e.json():{profiles:[]}).then(t=>{e||i(Array.isArray(t.profiles)?t.profiles:[])}).catch(()=>{e||i([])}).finally(()=>{e||o(!0)}),()=>{e=!0}},[]),!a||r.length===0)return null;let s=e??gz;return(0,Y.jsxs)(`div`,{className:`inline-flex items-center`,title:n(`railSelectors.profileTitle`),onMouseDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),children:[(0,Y.jsx)(qa,{className:`w-3 h-3 text-muted-foreground mr-1`}),(0,Y.jsxs)(`select`,{value:s,onChange:e=>{let n=e.target.value;t(n===gz?null:n)},className:`h-5 text-[10px] rounded border border-border/50 bg-transparent text-muted-foreground hover:text-foreground pr-4 pl-1 focus:outline-none focus:ring-1 focus:ring-primary/40`,children:[r.map(e=>(0,Y.jsx)(`option`,{value:e.name,children:e.name},e.name)),(0,Y.jsx)(`option`,{value:gz,children:n(`railSelectors.noProfile`)})]})]})}function vz({value:e,providers:t,onChange:n}){let{t:r}=K(`agents`);if(!t||t.length<=1)return null;let i=e??t[0];return(0,Y.jsxs)(`div`,{className:`inline-flex items-center`,title:r(`railSelectors.engineTitle`),onMouseDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),children:[(0,Y.jsx)(xo,{className:`w-3 h-3 text-muted-foreground mr-1`}),(0,Y.jsx)(`select`,{value:i,"aria-label":r(`railSelectors.engineTitle`),"data-testid":`rail-engine-selector`,onChange:e=>n(e.target.value),className:`h-5 text-[10px] rounded border border-border/50 bg-transparent text-muted-foreground hover:text-foreground pr-4 pl-1 focus:outline-none focus:ring-1 focus:ring-primary/40`,children:t.map(e=>(0,Y.jsx)(`option`,{value:e,children:JD(e)},e))})]})}var yz=[`haiku`,`sonnet`,`opus`,`fable`],bz={haiku:`Haiku`,sonnet:`Sonnet`,opus:`Opus`,fable:`Fable`};function xz({value:e,onChange:t}){let{t:n}=K(`agents`),r=e??`sonnet`;return(0,Y.jsxs)(`div`,{className:`inline-flex items-center`,title:n(`railSelectors.modelTitle`),onMouseDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),children:[(0,Y.jsx)(Qs,{className:`w-3 h-3 text-accent-highlight mr-1`}),(0,Y.jsx)(`select`,{value:r,"aria-label":n(`railSelectors.modelTitle`),"data-testid":`rail-model-selector`,onChange:e=>t(e.target.value),className:`h-5 text-[10px] rounded border border-border/50 bg-transparent text-muted-foreground hover:text-foreground pr-4 pl-1 focus:outline-none focus:ring-1 focus:ring-primary/40`,children:yz.map(e=>(0,Y.jsx)(`option`,{value:e,children:bz[e]},e))})]})}var Sz=class extends Error{errors;constructor(e){super(`Loop graph is invalid`),this.name=`LoopPublishError`,this.errors=e}},Cz=`/api`;async function wz(e){if(!e.ok){let t;try{t=await e.json()}catch{t=void 0}if(e.status===422&&t&&typeof t==`object`&&`errors`in t)throw new Sz(t.errors??[]);let n=t&&typeof t==`object`&&`error`in t?String(t.error):`Request failed (${e.status})`;throw Error(n)}return e.json()}async function Tz(e,t,n){return wz(await fetch(`${Cz}${t}`,{method:e,headers:n===void 0?void 0:{"Content-Type":`application/json`},body:n===void 0?void 0:JSON.stringify(n)}))}var Ez={async list(){return(await Tz(`GET`,`/loops`)).loops},async get(e){return(await Tz(`GET`,`/loops/${e}`)).loop},async create(e){return(await Tz(`POST`,`/loops`,e)).loop},async update(e,t){return(await Tz(`PUT`,`/loops/${e}`,t)).loop},async publish(e){return(await Tz(`POST`,`/loops/${e}/publish`)).loop},async unpublish(e){return(await Tz(`POST`,`/loops/${e}/unpublish`)).loop},async duplicate(e,t){return(await Tz(`POST`,`/loops/${e}/duplicate`,t?{name:t}:{})).loop},async remove(e){let t=await fetch(`${Cz}/loops/${e}`,{method:`DELETE`});!t.ok&&t.status!==204&&await wz(t)},async templates(){return(await Tz(`GET`,`/loop-templates`)).templates},async fromTemplate(e,t){return(await Tz(`POST`,`/loops/from-template/${e}`,t?{name:t}:{})).loop},async factoryLoops(){return(await Tz(`GET`,`/loops/factory`)).factoryLoops},async loopCommands(){return(await Tz(`GET`,`/loops/commands`)).commands},async forkFactory(e,t){return(await Tz(`POST`,`/loops/factory/${e}/fork`,t?{name:t}:{})).loop},async loopConstants(){return(await Tz(`GET`,`/loops/constants`)).constants},async createConstant(e,t){return(await Tz(`POST`,`/loops/constants`,{name:e,value:t})).constant},async updateConstant(e,t){return(await Tz(`PUT`,`/loops/constants/${e}`,{value:t})).constant},async deleteConstant(e){await Tz(`DELETE`,`/loops/constants/${e}`)},async importLoops(e){return Tz(`POST`,`/loops/import`,{loops:e})},async previewLoop(e,t){return Tz(`POST`,`/loops/preview`,{graph:e,provider:t})},async runStandalone(e,t,n={}){return wz(await fetch(`/api/projects/${e}/loop-runs`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({loopId:t,...n})}))}},Dz=/\{\{\s*spec\./,Oz=/\{\{\s*cmd:(implement|batch|freestyle)\b/;function kz(e){if(!e)return!1;for(let t of e.nodes){let e=[t.data?.prompt,t.data?.command,t.data?.goal].filter(e=>typeof e==`string`).join(`
111
- `);if(Dz.test(e)||Oz.test(e))return!0}return!1}function Az({value:e,onChange:t,freestyleAvailable:n=!0,loopsEnabled:r=!0}){let{t:i}=K(`dashboard`),[a,o]=(0,H.useState)([]);(0,H.useEffect)(()=>{if(!r)return;let e=!1;return Ez.list().then(t=>{e||o(t.filter(e=>e.status===`published`&&kz(e.graph)))}).catch(()=>{}),()=>{e=!0}},[r]);let s=fz.filter(e=>(n||!e.claudeOnly)&&(r||!e.requiresLoops));return(0,Y.jsxs)(`div`,{className:`inline-flex items-center`,title:i(`railControls.loopTitle`),onMouseDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),children:[(0,Y.jsx)(mc,{className:`w-3 h-3 text-muted-foreground mr-1`}),(0,Y.jsxs)(`select`,{value:e??``,"aria-label":i(`railControls.loop`),"data-testid":`rail-loop-selector`,onChange:e=>t(e.target.value),className:`h-5 text-[10px] rounded border border-border/50 bg-transparent text-muted-foreground hover:text-foreground pr-4 pl-1 focus:outline-none focus:ring-1 focus:ring-primary/40 max-w-[160px]`,children:[(0,Y.jsx)(`option`,{value:``,disabled:!0,children:i(`railControls.pickLoop`)}),(0,Y.jsx)(`optgroup`,{label:i(`railControls.builtInLoops`),children:s.map(e=>(0,Y.jsx)(`option`,{value:e.id,children:i(e.labelKey)},e.id))}),a.length>0&&(0,Y.jsx)(`optgroup`,{label:i(`railControls.customLoops`),children:a.map(e=>(0,Y.jsx)(`option`,{value:e.id,children:e.name},e.id))})]})]})}function jz(e){if(!Number.isFinite(e)||e<0)return`0s`;let t=Math.round(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60),r=t%60;return n<60?`${n}m ${r}s`:`${Math.floor(n/60)}h ${n%60}m`}function Mz({metric:e}){let{t}=K(`dashboard`),[n,r]=(0,H.useState)(()=>Date.now());return(0,H.useEffect)(()=>{let e=window.setInterval(()=>r(Date.now()),1e3);return()=>window.clearInterval(e)},[]),(0,Y.jsxs)(`div`,{className:`mt-1 flex items-center gap-1.5 text-[10px] text-muted-foreground tabular-nums`,"data-testid":`rail-exec-info`,children:[(0,Y.jsx)(`span`,{children:jz(n-e.startedAt)}),(0,Y.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,Y.jsx)(`span`,{children:t(`railControls.execSteps`,{count:e.steps})}),(0,Y.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,Y.jsx)(`span`,{children:t(`railControls.execLines`,{count:e.lines})})]})}var Nz=[`low`,`medium`,`high`];function Pz({value:e,onChange:t}){let{t:n}=K(`dashboard`),r=e??`medium`;return(0,Y.jsxs)(`div`,{className:`inline-flex items-center`,title:n(`railControls.effortTitle`),onMouseDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),children:[(0,Y.jsx)(Vo,{className:`w-3 h-3 text-muted-foreground mr-1`}),(0,Y.jsx)(`select`,{value:r,"aria-label":n(`railControls.effortTitle`),"data-testid":`rail-effort-selector`,onChange:e=>t(e.target.value),className:`h-5 text-[10px] rounded border border-border/50 bg-transparent text-muted-foreground hover:text-foreground pr-4 pl-1 focus:outline-none focus:ring-1 focus:ring-primary/40`,children:Nz.map(e=>(0,Y.jsx)(`option`,{value:e,children:e},e))})]})}function Fz({decision:e,density:t,act:n,checkout:r}){let{t:i}=K(`dashboard`),[a,o]=(0,H.useState)(null),[s,c]=(0,H.useState)(!1),[l,u]=(0,H.useState)(!1),[d,f]=(0,H.useState)(!1),p=e.decision,m=p===`building`&&e.prState===`pr-created`&&!!e.branch;if(p===`building`&&!m||p===`merged`||p===`discarded`)return null;let h=t===`compact`;async function g(t,r){if(!(a||s)){o(t);try{let a=await n(t,r);if(a.status===409){if(a.error===`merge_local_blocked`){q.warning(a.reason===`dirty`?i(`railPr.mergeLocalBlockedDirty`,{base:a.base??e.baseBranch}):i(`railPr.mergeLocalBlockedBranch`,{base:a.base??e.baseBranch,current:a.current??`?`}));return}q.info(i(`railPr.alreadyResolved`));return}if(a.status===502){if(a.error===`merge_failed`){q.error(i(`railPr.mergeLocalFailed`,{detail:a.detail??``}));return}q.error(i(`railPr.ghFailed`,{detail:a.detail??a.error??``}));return}if(!a.ok){q.error(i(`railPr.actionFailed`));return}if(t===`poll-merge`&&a.merged===!1&&q.info(i(`railPr.notMergedYet`)),t===`merge-local`&&a.decision===`merged`&&q.success(i(`railPr.mergedLocally`,{base:e.baseBranch})),t===`create-pr`&&a.decision===`pr_failed`){q.error(a.detail?i(`railPr.prFailedDetail`,{detail:a.detail}):i(`railPr.prFailed`));return}t===`create-pr`&&a.decision===`pr_draft`&&!a.prUrl&&a.detail&&q.error(i(`railPr.createDegraded`,{detail:a.detail}))}finally{o(null)}}}async function _(){if(!(!r||a||s)){c(!0);try{let t=await r();if(!t.ok){q.warning(i(`railPr.checkoutFailed`),{description:t.detail??t.error});return}q.success(i(`railPr.checkoutSuccess`,{branch:e.branch??``}))}finally{c(!1)}}}let v=`inline-flex items-center gap-1 rounded-full font-medium border ${h?`px-1.5 py-0.5 text-[9px]`:`px-2 py-0.5 text-[10px]`}`,y=`inline-flex items-center gap-1 rounded-md font-medium bg-accent-primary text-white hover:bg-accent-primary/90 disabled:opacity-50 disabled:pointer-events-none transition-colors ${h?`px-1.5 py-0.5 text-[9px]`:`px-2 py-0.5 text-[10px]`}`,b=`inline-flex items-center gap-1 rounded-md text-muted-foreground hover:text-destructive hover:bg-destructive/10 disabled:opacity-50 disabled:pointer-events-none transition-colors ${h?`px-1.5 py-0.5 text-[9px]`:`px-2 py-0.5 text-[10px]`}`,x=h?`w-2.5 h-2.5`:`w-3 h-3`,S=(0,Y.jsx)(cs,{className:`${x} animate-spin`,"aria-hidden":!0}),C=a!==null||s,w=i(p===`implementation_failed`?`railPr.implementationFailedHint`:`railPr.discardTooltip`),T=e.prUrl?(0,Y.jsxs)(`a`,{href:e.prUrl,target:`_blank`,rel:`noreferrer`,"data-testid":`rail-pr-link`,title:i(`railPr.openPrTitle`),onClick:e=>e.stopPropagation(),className:`inline-flex items-center gap-1 rounded-md font-mono border border-accent-info/30 bg-accent-info/10 text-accent-info hover:bg-accent-info/20 hover:border-accent-info/60 transition-colors ${h?`px-1 py-0.5 text-[9px]`:`px-1.5 py-0.5 text-[10px]`}`,children:[e.prNumber==null?i(`railPr.prLinkFallback`):`#${e.prNumber}`,(0,Y.jsx)(Oo,{className:h?`w-2 h-2`:`w-2.5 h-2.5`,"aria-hidden":!0})]}):null,E=e.branch?(0,Y.jsx)(`span`,{"data-testid":`rail-pr-branch`,className:`inline-flex min-w-0 max-w-full items-center gap-1 rounded-md font-mono border border-border/60 bg-surface/60 text-foreground/70 ${h?`px-1 py-0.5 text-[9px]`:`px-1.5 py-0.5 text-[10px]`}`,children:(0,Y.jsx)(`span`,{className:`truncate`,children:e.branch})}):null,D=(0,Y.jsxs)(`button`,{type:`button`,"data-testid":`rail-pr-discard`,disabled:C,title:w,onClick:e=>{e.stopPropagation(),u(!0)},className:b,children:[a===`discard`?S:null,i(`railPr.discard`)]}),O=(0,Y.jsxs)(`button`,{type:`button`,"data-testid":`rail-pr-merge-local`,disabled:C,title:i(`railPr.mergeLocalTooltip`,{base:e.baseBranch}),onClick:e=>{e.stopPropagation(),f(!0)},className:`inline-flex items-center gap-1 rounded-md font-medium border border-accent-success/40 bg-accent-success/10 text-accent-success hover:bg-accent-success/20 disabled:opacity-50 disabled:pointer-events-none transition-colors ${h?`px-1.5 py-0.5 text-[9px]`:`px-2 py-0.5 text-[10px]`}`,children:[a===`merge-local`?S:(0,Y.jsx)(Wo,{className:x,"aria-hidden":!0}),i(`railPr.mergeLocal`)]}),k=(e,t,n,r,i,o)=>(0,Y.jsxs)(`button`,{type:`button`,"data-testid":r,disabled:C,title:i,onClick:n=>{n.stopPropagation(),g(e,t)},className:y,children:[a===e?S:o,n]}),A=r&&e.prUrl&&e.branch?(0,Y.jsxs)(`button`,{type:`button`,"data-testid":`rail-pr-checkout`,disabled:C,title:i(`railPr.checkoutTooltip`,{branch:e.branch}),onClick:e=>{e.stopPropagation(),_()},className:`inline-flex items-center gap-1 rounded-md font-medium border border-border/60 text-foreground/70 hover:border-accent-primary/40 hover:bg-accent-primary/10 disabled:opacity-50 disabled:pointer-events-none transition-colors ${h?`px-1.5 py-0.5 text-[9px]`:`px-2 py-0.5 text-[10px]`}`,children:[s?S:(0,Y.jsx)(Ho,{className:x,"aria-hidden":!0}),i(`railPr.checkout`)]}):null,j=null,M=null;return m?(j=(0,Y.jsxs)(`span`,{className:`${v} border-accent-info/30 bg-accent-info/10 text-accent-info`,children:[(0,Y.jsx)(cs,{className:`${x} animate-spin`,"aria-hidden":!0}),i(`railPr.iteratingPr`)]}),M=(0,Y.jsxs)(Y.Fragment,{children:[T,E]})):p===`on_review`?(j=(0,Y.jsxs)(`span`,{className:`${v} border-accent-warning/30 bg-accent-warning/10 text-accent-warning`,children:[(0,Y.jsx)(ko,{className:x,"aria-hidden":!0}),i(`railPr.readyForReview`)]}),M=(0,Y.jsxs)(Y.Fragment,{children:[k(`create-pr`,`on_review`,i(`railPr.createPr`),`rail-pr-create`,i(`railPr.createPrTooltip`,{base:e.baseBranch}),(0,Y.jsx)(Go,{className:x,"aria-hidden":!0})),O,D]})):p===`pr_draft`&&e.prUrl?(j=(0,Y.jsxs)(`span`,{className:`${v} border-accent-info/30 bg-accent-info/10 text-accent-info`,children:[(0,Y.jsx)(Go,{className:x,"aria-hidden":!0}),i(`railPr.draftPr`)]}),M=(0,Y.jsxs)(Y.Fragment,{children:[T,A,k(`publish`,`pr_draft`,i(`railPr.publish`),`rail-pr-publish`,i(`railPr.publishTooltip`)),D]})):p===`pr_draft`?(j=(0,Y.jsxs)(`span`,{className:`${v} border-accent-warning/30 bg-accent-warning/10 text-accent-warning`,title:i(`railPr.branchPushedHint`),children:[(0,Y.jsx)(lc,{className:x,"aria-hidden":!0}),i(`railPr.branchPushed`)]}),M=(0,Y.jsxs)(Y.Fragment,{children:[k(`create-pr`,`pr_draft`,i(`railPr.retryPr`),`rail-pr-create`,i(`railPr.createPrTooltip`,{base:e.baseBranch})),O,D]})):p===`pr_ready`?(j=(0,Y.jsxs)(`span`,{className:`${v} border-accent-success/30 bg-accent-success/10 text-accent-success`,children:[(0,Y.jsx)(Wo,{className:x,"aria-hidden":!0}),i(`railPr.prReady`)]}),M=(0,Y.jsxs)(Y.Fragment,{children:[T,A,k(`poll-merge`,`pr_ready`,i(`railPr.checkMerge`),`rail-pr-poll`,i(`railPr.checkMergeTooltip`)),D]})):p===`pr_failed`?(j=(0,Y.jsxs)(`span`,{className:`${v} border-destructive/30 bg-destructive/10 text-destructive`,children:[(0,Y.jsx)(lc,{className:x,"aria-hidden":!0}),i(`railPr.prFailed`)]}),M=(0,Y.jsxs)(Y.Fragment,{children:[T,A,k(`create-pr`,`pr_failed`,i(`railPr.retry`),`rail-pr-create`,i(`railPr.createPrTooltip`,{base:e.baseBranch})),!e.prUrl&&O,D]})):p===`implementation_failed`&&(j=(0,Y.jsxs)(`span`,{className:`${v} border-destructive/30 bg-destructive/10 text-destructive`,title:i(`railPr.implementationFailedHint`),children:[(0,Y.jsx)(lc,{className:x,"aria-hidden":!0}),i(`railPr.implementationFailed`)]}),M=(0,Y.jsx)(Y.Fragment,{children:D})),(0,Y.jsxs)(`div`,{"data-testid":`rail-pr-strip`,"data-decision":p,className:`flex items-center flex-wrap animate-in fade-in slide-in-from-top-1 duration-200 ${h?`gap-1`:`gap-1.5`}`,onClick:e=>e.stopPropagation(),children:[j,M,(0,Y.jsx)(Cb,{open:d,onOpenChange:f,children:(0,Y.jsxs)(Db,{className:`max-w-sm`,"data-testid":`rail-pr-merge-local-confirm`,children:[(0,Y.jsxs)(Ob,{children:[(0,Y.jsx)(Ab,{children:i(`railPr.mergeLocalConfirmTitle`)}),(0,Y.jsx)(jb,{children:i(`railPr.mergeLocalConfirmBody`,{base:e.baseBranch})})]}),(0,Y.jsxs)(kb,{children:[(0,Y.jsx)(Z,{variant:`outline`,size:`sm`,onClick:()=>f(!1),children:i(`common:actions.cancel`)}),(0,Y.jsx)(Z,{size:`sm`,"data-testid":`rail-pr-merge-local-confirm-btn`,onClick:()=>{f(!1),g(`merge-local`,p)},children:i(`railPr.mergeLocal`)})]})]})}),(0,Y.jsx)(Cb,{open:l,onOpenChange:u,children:(0,Y.jsxs)(Db,{className:`max-w-sm`,"data-testid":`rail-pr-discard-confirm`,children:[(0,Y.jsxs)(Ob,{children:[(0,Y.jsx)(Ab,{children:i(`railPr.discardConfirmTitle`)}),(0,Y.jsx)(jb,{children:i(`railPr.discardConfirmBody`)})]}),(0,Y.jsxs)(kb,{children:[(0,Y.jsx)(Z,{variant:`outline`,size:`sm`,onClick:()=>u(!1),children:i(`common:actions.cancel`)}),(0,Y.jsx)(Z,{variant:`destructive`,size:`sm`,"data-testid":`rail-pr-discard-confirm-btn`,onClick:()=>{u(!1),g(`discard`,p)},children:i(`railPr.discard`)})]})]})})]})}var Iz={claude:[{value:`sonnet`,label:`Claude Sonnet`},{value:`fable`,label:`Claude Fable`},{value:`opus`,label:`Claude Opus`},{value:`haiku`,label:`Claude Haiku`}],codex:[{value:`gpt-5.5`,label:`GPT-5.5`},{value:`gpt-5.4`,label:`GPT-5.4`},{value:`gpt-5.4-mini`,label:`GPT-5.4 Mini`},{value:`gpt-5.3-codex`,label:`GPT-5.3 Codex`}],gemini:[{value:`gemini-3.5-flash`,label:`Gemini 3.5 Flash`},{value:`gemini-3.1-pro-preview`,label:`Gemini 3.1 Pro (preview)`},{value:`gemini-3.1-flash-lite`,label:`Gemini 3.1 Flash Lite`},{value:`gemini-2.5-flash-lite`,label:`Gemini 2.5 Flash Lite`}]};function Lz(e){return e&&Iz[e]||[]}function Rz(e){return Lz(e)[0]?.value??``}var zz=800,Bz=60;function Vz({id:e,label:t,tickets:n,mode:r,status:i,activeJobId:a,profileName:o,aiEngine:s,freestyleModel:c,loopModel:l,providers:u,loopAvailable:d,selectedLoopId:f,reasoningEffort:p,worktreeSummary:m,prDecision:h,onPrDecision:g,onPrCheckout:_,executionMetric:v,jiggleMode:y,dragHandleListeners:b,dragHandleAttributes:x,density:S=`normal`,onModeChange:C,onProfileChange:w,onEngineChange:T,onFreestyleModelChange:E,onLoopModelChange:D,onLoopChange:O,onEffortChange:k,onToggle:A,onTicketClick:j,onDelete:M,onLongPress:N,onRename:P,onTicketMoveToSpecs:F}){let{t:I}=K(`dashboard`),L=(s??u?.[0])!==`codex`,R=(s??u?.[0]??`claude`)===`claude`,z=WD(s??u?.[0]??`claude`),ee=!!T&&i!==`running`&&(u?.length??0)>1,te=!!w&&i!==`running`&&L&&r!==`loop`,B=!!E&&i!==`running`&&r===`freestyle`&&R,ne=!!D&&i!==`running`&&r===`loop`,V=s??u?.[0]??`claude`,re=Lz(V),U=l??Rz(V),ie=ne&&D?(0,Y.jsx)(`select`,{"data-testid":`loop-model-selector`,"aria-label":I(`railSelectors.loopModelTitle`),value:U,onChange:e=>D(e.target.value),className:`h-5 text-[10px] rounded border border-border/50 bg-transparent text-muted-foreground hover:text-foreground pr-4 pl-1 focus:outline-none focus:ring-1 focus:ring-primary/40`,children:re.map(e=>(0,Y.jsx)(`option`,{value:e.value,children:e.label},e.value))}):null,ae=!!O&&i!==`running`,W=ee||B||ne||ae,[oe,se]=(0,H.useState)(null);(0,H.useEffect)(()=>{if(!oe)return;function e(e){e.target?.closest(`[role="menu"]`)||se(null)}function t(e){e.key===`Escape`&&se(null)}return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[oe]);let{isOver:ce,setNodeRef:le}=_d({id:e}),{active:ue}=md(),de=typeof ue?.id==`number`,[fe,pe]=(0,H.useState)(0),[me,he]=(0,H.useState)(!1),[ge,_e]=(0,H.useState)(!1),[ve,ye]=(0,H.useState)(!1),[G,be]=(0,H.useState)(``),xe=(0,H.useRef)(null),Se=(0,H.useRef)(null),Ce=(0,H.useRef)(null),we=(0,H.useRef)(!1),Te=i===`running`,Ee=!Te,De=(0,H.useCallback)(()=>{Ce.current&&=(clearTimeout(Ce.current),null)},[]),Oe=(0,H.useCallback)(()=>{Ee&&(we.current=!1,Ce.current=setTimeout(()=>{we.current=!0,N(),Ce.current=null},zz))},[Ee,N]),ke=(0,H.useCallback)(e=>{let t=e.touches[0];Se.current={x:t.clientX,y:t.clientY},he(!1),_e(!1),Oe()},[Oe]),Ae=(0,H.useCallback)(e=>{if(!Se.current)return;let t=e.touches[0],n=t.clientX-Se.current.x,r=t.clientY-Se.current.y;(Math.abs(n)>10||Math.abs(r)>10)&&De(),Ee&&n<-10&&Math.abs(n)>Math.abs(r)*1.5&&(he(!0),pe(Math.max(n,-150)))},[Ee,De]),je=(0,H.useCallback)(()=>{De(),me&&(fe<-Bz&&Ee?(_e(!0),pe(-80)):(pe(0),_e(!1)),he(!1)),Se.current=null},[fe,me,Ee,De]),Me=(0,H.useCallback)(e=>{e.target.closest(`button`)||Oe()},[Oe]),Ne=(0,H.useCallback)(()=>{De()},[De]),Pe=(0,H.useCallback)(e=>{if(we.current){e.stopPropagation(),we.current=!1;return}ge&&(_e(!1),pe(0))},[ge]),Fe=(0,H.useCallback)(e=>{e.stopPropagation(),_e(!1),pe(0),M()},[M]),Ie=y&&Ee?-(Array.from(e).reduce((e,t)=>e+t.charCodeAt(0),0)*53%400):void 0,Le=Ie===void 0?void 0:{animationDelay:`${Ie}ms`};return S===`compact`?(0,Y.jsxs)(`div`,{ref:le,"data-testid":`rail-row-compact-${e}`,"data-density":`compact`,onMouseDown:Me,onMouseUp:Ne,onMouseLeave:Ne,onClick:Pe,style:Le,className:`group relative flex flex-col gap-1.5 rounded-xl border bg-card p-2.5 transition-all ${ce?`border-accent-info/60 shadow-[0_0_0_1px_hsl(var(--accent-info)/0.35),0_0_14px_hsl(var(--accent-info)/0.18)]`:de?`border-dashed border-accent-info/35`:Te?`border-accent-success/40 shadow-sm`:`border-border/40 hover:border-accent-info/30 hover:shadow-md`} ${y&&Ee?`animate-jiggle`:``}`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,Y.jsx)(`button`,{type:`button`,className:`touch-none cursor-grab active:cursor-grabbing text-muted-foreground/30 hover:text-muted-foreground/70 transition-colors shrink-0`,...b,...x,children:(0,Y.jsx)(Jo,{className:`w-3 h-3`})}),(0,Y.jsx)(`div`,{className:`w-1.5 h-1.5 rounded-full shrink-0 transition-all duration-300 ${Te?`bg-accent-success shadow-[0_0_4px_hsl(var(--accent-success)/0.8)] animate-pulse`:i===`failed`?`bg-accent-warning shadow-[0_0_4px_hsl(var(--accent-warning)/0.6)]`:`bg-muted-foreground/25`}`,"aria-hidden":!0}),ve?(0,Y.jsx)(`form`,{className:`flex items-center gap-0.5 min-w-0 flex-1`,onSubmit:e=>{e.preventDefault();let t=G.trim();t&&P(t),ye(!1)},children:(0,Y.jsx)(`input`,{ref:xe,type:`text`,value:G,onChange:e=>be(e.target.value),onBlur:()=>{let e=G.trim();e&&P(e),ye(!1)},onKeyDown:e=>{e.key===`Escape`&&ye(!1)},className:`flex-1 min-w-0 text-xs font-medium bg-transparent border-b border-accent-info/60 outline-none text-foreground/90 px-0.5`,autoFocus:!0})}):(0,Y.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),be(t.startsWith(`Rail `)?t.slice(5):t),ye(!0),setTimeout(()=>xe.current?.select(),0)},className:`flex-1 min-w-0 text-left text-xs font-medium text-foreground/90 hover:text-foreground truncate`,title:t,children:t})]}),n.length>0&&(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-1`,"data-testid":`rail-row-compact-tickets-${e}`,children:n.map(e=>(0,Y.jsxs)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),j(e)},onMouseDown:t=>{t.button===2&&F&&(t.preventDefault(),t.stopPropagation(),se({ticketId:e.id,x:t.clientX,y:t.clientY}))},onContextMenu:e=>{F&&(e.preventDefault(),e.stopPropagation())},onPointerDown:e=>e.stopPropagation(),title:`#${e.id} ${e.title}`,className:`inline-flex items-center px-1.5 py-0.5 rounded-md text-[10px] font-mono font-medium border border-accent-info/30 bg-accent-info/10 text-accent-info hover:bg-accent-info/20 hover:border-accent-info/60 transition-colors`,children:[`#`,e.id]},e.id))}),oe&&F&&(0,sr.createPortal)((0,Y.jsx)(`div`,{role:`menu`,"data-testid":`rail-row-compact-context-menu-${e}`,className:`fixed z-[200] min-w-[160px] rounded-lg border border-border/60 bg-card/95 backdrop-blur shadow-xl shadow-black/40 p-1`,style:{top:Math.min(oe.y,window.innerHeight-60),left:Math.min(oe.x,window.innerWidth-180)},onPointerDown:e=>e.stopPropagation(),children:(0,Y.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:e=>{e.stopPropagation(),F(oe.ticketId),se(null)},className:`w-full flex items-center gap-2 px-2 py-1.5 rounded-md text-left text-xs text-accent-warning hover:bg-accent-warning/10 transition-colors`,children:[(0,Y.jsx)(Ba,{className:`w-3 h-3`,"aria-hidden":!0}),I(`railRow.moveToSpecs`)]})}),document.body),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[T&&!Te&&(0,Y.jsx)(vz,{value:s??null,providers:u??[],onChange:T}),w&&!Te&&L&&r!==`loop`&&(0,Y.jsx)(_z,{value:o??null,onChange:w}),E&&!Te&&r===`freestyle`&&R&&(0,Y.jsx)(xz,{value:c??null,onChange:E}),ie,O&&!Te&&(0,Y.jsx)(Az,{value:hz(f,r),onChange:O,freestyleAvailable:R,loopsEnabled:d}),k&&!Te&&r===`loop`&&z&&(0,Y.jsx)(Pz,{value:p??null,onChange:k}),(0,Y.jsx)(uz,{mode:r,status:i,activeJobId:a,ticketCount:n.length,freestyleAvailable:R,loopAvailable:d,onModeChange:C,onToggle:A})]}),Te&&v&&(0,Y.jsx)(Mz,{metric:v}),m&&(m.merged>0||m.needsReview>0)&&(0,Y.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 text-[10px]`,"data-testid":`rail-worktree-summary`,children:[m.merged>0&&(0,Y.jsx)(`span`,{className:`text-accent-success`,children:I(`railControls.worktreesMerged`,{count:m.merged})}),m.needsReview>0&&(0,Y.jsx)(`span`,{className:`text-accent-warning`,children:I(`railControls.worktreesNeedsReview`,{count:m.needsReview})})]}),h&&g&&(0,Y.jsx)(`div`,{className:`mt-1`,children:(0,Y.jsx)(Fz,{decision:h,density:`compact`,act:g,checkout:_})}),y&&Ee&&(0,Y.jsx)(`button`,{type:`button`,onClick:Fe,className:`absolute -top-1 -right-1 w-5 h-5 flex items-center justify-center rounded-full bg-destructive text-destructive-foreground shadow-sm hover:opacity-90 transition-opacity`,"aria-label":I(`railRow.deleteRail`,{label:t}),children:(0,Y.jsx)(cc,{className:`w-3 h-3`})})]}):(0,Y.jsxs)(`div`,{className:`relative overflow-hidden rounded-xl`,onClick:Pe,onTouchStart:ke,onTouchMove:Ae,onTouchEnd:je,onMouseDown:Me,onMouseUp:Ne,onMouseLeave:Ne,children:[Ee&&(ge||fe<0)&&(0,Y.jsx)(`div`,{className:`absolute inset-y-0 right-0 w-20 flex items-center justify-center bg-red-500/90 rounded-r-xl z-0`,children:(0,Y.jsxs)(`button`,{type:`button`,onClick:Fe,className:`flex flex-col items-center gap-1 text-white`,children:[(0,Y.jsx)(cc,{className:`w-5 h-5`}),(0,Y.jsx)(`span`,{className:`text-[9px] font-medium`,children:I(`common:actions.delete`)})]})}),(0,Y.jsxs)(`div`,{className:`relative z-10 flex flex-col rounded-xl border overflow-hidden bg-card ${y&&Ee?`animate-jiggle`:``} ${ce?`border-primary/50 shadow-[0_0_0_1px_hsl(var(--primary)/0.25),0_0_12px_hsl(var(--primary)/0.08)]`:`border-border/40 hover:border-border/60`}`,style:{transform:fe<0?`translateX(${fe}px)`:void 0,transition:me?`none`:`transform 0.3s cubic-bezier(0.25, 0.1, 0.25, 1)`,...Ie===void 0?{}:{animationDelay:`${Ie}ms`}},children:[(0,Y.jsxs)(`div`,{className:`flex flex-col border-b border-border/30 bg-gradient-to-r from-muted/30 to-transparent shrink-0`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,Y.jsx)(`button`,{type:`button`,className:`touch-none cursor-grab active:cursor-grabbing text-muted-foreground/30 hover:text-muted-foreground/60 transition-colors -ml-1`,...b,...x,children:(0,Y.jsx)(Jo,{className:`w-3.5 h-3.5`})}),(0,Y.jsx)(`div`,{className:`w-1.5 h-1.5 rounded-full shrink-0 transition-all duration-300 ${i===`running`?`bg-emerald-400 shadow-[0_0_4px_hsl(142_70%_56%/0.8)] animate-pulse`:i===`failed`?`bg-amber-400 shadow-[0_0_4px_hsl(38_92%_50%/0.6)]`:`bg-muted-foreground/25`}`}),ve?(0,Y.jsxs)(`form`,{className:`flex items-center gap-0.5`,onSubmit:e=>{e.preventDefault();let t=G.trim();t&&P(t),ye(!1)},children:[(0,Y.jsx)(`span`,{className:`text-xs font-medium text-foreground/50`,children:`Rail `}),(0,Y.jsx)(`input`,{ref:xe,type:`text`,value:G,onChange:e=>be(e.target.value),onBlur:()=>{let e=G.trim();e&&P(e),ye(!1)},onKeyDown:e=>{e.key===`Escape`&&ye(!1)},className:`w-24 text-xs font-medium bg-transparent border-b border-primary/50 outline-none text-foreground/80 px-0.5`,autoFocus:!0})]}):(0,Y.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),be(t.startsWith(`Rail `)?t.slice(5):t),ye(!0),setTimeout(()=>xe.current?.select(),0)},className:`text-xs font-medium text-foreground/80 hover:text-foreground hover:underline decoration-dotted underline-offset-2 cursor-text transition-colors`,children:t}),n.length>0&&(0,Y.jsx)(`span`,{className:`text-[9px] text-muted-foreground bg-muted/30 rounded-full px-1.5 py-0.5 leading-none`,children:n.length})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[!W&&te&&w&&(0,Y.jsx)(_z,{value:o??null,onChange:w}),(0,Y.jsx)(uz,{mode:r,status:i,activeJobId:a,ticketCount:n.length,freestyleAvailable:R,loopAvailable:d,onModeChange:C,onToggle:A}),y&&Ee&&(0,Y.jsx)(`button`,{type:`button`,onClick:Fe,className:`w-5 h-5 flex items-center justify-center rounded-full bg-red-500 text-white shadow-sm hover:bg-red-600 transition-colors`,children:(0,Y.jsx)(cc,{className:`w-3 h-3`})})]})]}),Te&&v&&(0,Y.jsx)(`div`,{className:`px-3 pb-1`,children:(0,Y.jsx)(Mz,{metric:v})}),m&&(m.merged>0||m.needsReview>0)&&(0,Y.jsxs)(`div`,{className:`px-3 pb-1 flex items-center gap-2 text-[10px]`,children:[m.merged>0&&(0,Y.jsx)(`span`,{className:`text-accent-success`,children:I(`railControls.worktreesMerged`,{count:m.merged})}),m.needsReview>0&&(0,Y.jsx)(`span`,{className:`text-accent-warning`,children:I(`railControls.worktreesNeedsReview`,{count:m.needsReview})})]}),h&&g&&(0,Y.jsx)(`div`,{className:`px-3 pb-1.5`,children:(0,Y.jsx)(Fz,{decision:h,density:`normal`,act:g,checkout:_})}),W&&(0,Y.jsxs)(`div`,{className:`flex items-center flex-wrap gap-x-3 gap-y-1 px-3 py-1.5 border-t border-border/20 bg-background/20`,children:[ee&&T&&(0,Y.jsx)(vz,{value:s??null,providers:u??[],onChange:T}),W&&te&&w&&(0,Y.jsx)(_z,{value:o??null,onChange:w}),B&&E&&(0,Y.jsx)(xz,{value:c??null,onChange:E}),ie,ae&&O&&(0,Y.jsx)(Az,{value:hz(f,r),onChange:O,freestyleAvailable:R,loopsEnabled:d}),r===`loop`&&!Te&&z&&k&&(0,Y.jsx)(Pz,{value:p??null,onChange:k})]})]}),(0,Y.jsx)(`div`,{ref:le,"data-drop-target":de?`available`:void 0,className:`min-h-[56px] px-3 py-2 space-y-1.5 transition-colors duration-150 ${ce?`bg-accent-info/[0.06]`:de?`bg-accent-info/[0.02]`:`bg-card/20`}`,children:n.length===0?(0,Y.jsx)(`div`,{className:`h-10 flex items-center justify-center rounded-lg border border-dashed transition-all duration-150 ${ce?`border-accent-info/60 text-accent-info/80 bg-accent-info/[0.06]`:de?`border-accent-info/35 text-accent-info/60`:`border-border/25 text-muted-foreground/30`}`,children:(0,Y.jsx)(`span`,{className:`text-[10px] select-none`,children:I(ce?`railRow.dropHere`:de?`railRow.dropOnThisRail`:`railRow.dragSpecsHere`)})}):(0,Y.jsx)(Vd,{items:n.map(e=>e.id),strategy:Ld,children:n.map(e=>(0,Y.jsx)(`div`,{onMouseDown:t=>{t.button===2&&F&&(t.preventDefault(),t.stopPropagation(),se({ticketId:e.id,x:t.clientX,y:t.clientY}))},onContextMenu:e=>{F&&(e.preventDefault(),e.stopPropagation())},children:(0,Y.jsx)(pg,{ticket:e,onClick:j,dragDisabled:i===`running`})},e.id))})}),oe&&F&&S===`normal`&&(0,sr.createPortal)((0,Y.jsx)(`div`,{role:`menu`,"data-testid":`rail-row-normal-context-menu-${e}`,className:`fixed z-[200] min-w-[160px] rounded-lg border border-border/60 bg-card/95 backdrop-blur shadow-xl shadow-black/40 p-1`,style:{top:Math.min(oe.y,window.innerHeight-60),left:Math.min(oe.x,window.innerWidth-180)},onPointerDown:e=>e.stopPropagation(),children:(0,Y.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:e=>{e.stopPropagation(),F(oe.ticketId),se(null)},className:`w-full flex items-center gap-2 px-2 py-1.5 rounded-md text-left text-xs text-accent-warning hover:bg-accent-warning/10 transition-colors`,children:[(0,Y.jsx)(Ba,{className:`w-3 h-3`,"aria-hidden":!0}),I(`railRow.moveToSpecs`)]})}),document.body)]})]})}function Hz(e){return`rail-${e+1}`}function Uz(e){let t=/^rail-(\d+)$/.exec(e);if(!t)return null;let n=parseInt(t[1],10);return!Number.isInteger(n)||n<1?null:n-1}function Wz(e,t,n,r){return{...e,[t]:{...e[t]??{},[n]:r}}}function Gz(e){if(!e)return null;let t=Object.values(e);if(t.length===0)return null;let n=0,r=0,i=0;for(let e of t)e===`merged`?n++:e===`needs-review`?r++:e===`failed`&&i++;return{merged:n,needsReview:r,failed:i,reported:t.length}}var Kz=`__rail:`;function qz(e){return`${Kz}${e}`}function Jz(e){return typeof e==`string`&&e.startsWith(`__rail:`)}function Yz(e){return e.slice(7)}function Xz(e,t,n){let r=new Set(n),i=Hz(t),a=e.some(e=>e.id===i);return e.map((e,n)=>(a?e.id===i:n===t)?{...e,status:`idle`,activeJobId:void 0,ticketIds:r.size>0?e.ticketIds.filter(e=>!r.has(e)):[]}:e)}function Zz({railId:e,children:t}){let{attributes:n,listeners:r,setNodeRef:i,transform:a,transition:o,isDragging:s}=Yd({id:qz(e)});return(0,Y.jsx)(`div`,{ref:i,style:{transform:Gc.Translate.toString(a),transition:o,opacity:s?.4:void 0,position:`relative`,zIndex:s?50:void 0},children:t({listeners:r??{},attributes:n,isDragging:s})})}function Qz({rails:e,ticketMap:t,railWorktrees:n,railMetrics:r,railPrDecisions:i,onPrDecision:a,onPrCheckout:o,providers:s,onModeChange:c,onProfileChange:l,onEngineChange:u,onFreestyleModelChange:d,onLoopModelChange:f,loopAvailable:p,onLoopChange:m,onEffortChange:h,onToggle:g,onTicketClick:_,onAddRail:v,onDeleteRail:y,onRenameRail:b,onTicketMoveToSpecs:x,onLaunchAll:S,launchAllCount:C}){let{t:w}=K(`dashboard`),T=e.filter(e=>e.status===`running`).length,[E,D]=(0,H.useState)(!1),O=(0,H.useRef)(null),[k,A]=(0,H.useState)(`normal`);(0,H.useEffect)(()=>{if(typeof ResizeObserver>`u`)return;let e=O.current;if(!e)return;let t=new ResizeObserver(e=>{for(let t of e){let e=t.contentRect.width;A(e<320?`compact`:`normal`)}});return t.observe(e),()=>t.disconnect()},[]);let j=(0,H.useCallback)(()=>{E&&D(!1)},[E]);(0,H.useEffect)(()=>{if(!E)return;let e=e=>{e.key===`Escape`&&D(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[E]);let M=e.map(e=>qz(e.id));return(0,Y.jsxs)(`div`,{ref:O,className:`flex flex-col h-full`,"data-density":k,onClick:j,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between px-4 h-12 border-b border-border/40 shrink-0`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(rs,{className:`w-4 h-4 text-muted-foreground`}),(0,Y.jsx)(`h2`,{className:`text-sm font-semibold text-accent-secondary`,children:w(`railsBoard.title`)}),T>0&&(0,Y.jsx)(`span`,{className:`text-[10px] text-emerald-400 aurora-light:text-accent-success bg-emerald-400/10 aurora-light:bg-accent-success/10 rounded-full px-1.5 py-0.5 font-medium whitespace-nowrap`,children:w(`railsBoard.runningCount`,{count:T})})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[S&&(0,Y.jsxs)(`button`,{type:`button`,disabled:(C??0)===0,onClick:e=>{e.stopPropagation(),S()},title:w(`railsBoard.launchAllTitle`),className:`flex items-center gap-1.5 h-7 px-2.5 text-xs font-semibold rounded-md border border-emerald-400/50 text-emerald-400 aurora-light:text-accent-success aurora-light:border-accent-success/50 bg-gradient-to-r from-emerald-400/10 to-accent-primary/10 hover:from-emerald-400/20 hover:to-accent-primary/20 transition-colors disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:from-emerald-400/10 disabled:hover:to-accent-primary/10`,children:[(0,Y.jsx)(Ls,{className:`w-3.5 h-3.5`}),w(`railsBoard.launchAll`),(C??0)>0&&(0,Y.jsx)(`span`,{className:`text-[10px] font-mono rounded-full bg-emerald-400/15 px-1.5 py-0.5 leading-none`,children:C})]}),(0,Y.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),v()},className:`flex items-center gap-1 h-7 px-2.5 text-xs font-medium rounded-md border border-accent-primary/50 text-accent-primary hover:bg-accent-primary/10 transition-colors`,children:[(0,Y.jsx)(ks,{className:`w-3.5 h-3.5`}),w(`common:actions.add`)]})]})]}),(0,Y.jsx)(`div`,{className:`flex-1 overflow-y-auto px-4 py-3 flex flex-col gap-2.5`,children:(0,Y.jsx)(Vd,{items:M,strategy:Ld,children:e.map((e,v)=>{let S=Uz(e.id)??v;return(0,Y.jsx)(Zz,{railId:e.id,children:({listeners:C,attributes:w})=>(0,Y.jsx)(`div`,{"data-tour":v===0?`rail-1`:void 0,children:(0,Y.jsx)(Vz,{id:e.id,label:e.label,tickets:e.ticketIds.map(e=>t.get(e)).filter(e=>e!==void 0),mode:e.mode,status:e.status,activeJobId:e.activeJobId,profileName:e.profileName??null,aiEngine:e.aiEngine??null,freestyleModel:e.freestyleModel??null,loopModel:e.loopModel??null,worktreeSummary:Gz(n?.[S]),prDecision:i?.get(S)??null,onPrDecision:a?(e,t)=>a(S,e,t):void 0,onPrCheckout:o?()=>o(S):void 0,executionMetric:r?.[S]??null,providers:s,loopAvailable:p,selectedLoopId:e.selectedLoopId??null,reasoningEffort:e.reasoningEffort??null,jiggleMode:E,density:k,dragHandleListeners:C,dragHandleAttributes:w,onModeChange:t=>c(e.id,t),onProfileChange:l?t=>l(e.id,t):void 0,onEngineChange:u?t=>u(e.id,t):void 0,onFreestyleModelChange:d?t=>d(e.id,t):void 0,onLoopModelChange:f?t=>f(e.id,t):void 0,onLoopChange:m?t=>m(e.id,t):void 0,onEffortChange:h?t=>h(e.id,t):void 0,onToggle:()=>g(e.id),onTicketClick:_,onDelete:()=>y(e.id),onLongPress:()=>D(!0),onRename:t=>b(e.id,t),onTicketMoveToSpecs:x})})},e.id)})})})]})}var $z=new Set([`editing`,`writing`,`reading`,`searching`,`running`]);function eB(e){return e.length>40?`${e.slice(0,39)}…`:e}function tB(e){return typeof e!=`string`||e.length===0?``:eB(e.replace(/\\/g,`/`).split(`/`).filter(Boolean).pop()??``)}function nB(e){return typeof e!=`string`||e.length===0?``:eB(e.trim().split(/\s+/)[0]??``)}function rB(e){if(typeof e!=`string`)return``;try{let t=JSON.parse(e)?.command;if(Array.isArray(t))return nB(t.filter(e=>typeof e==`string`).join(` `));if(typeof t==`string`)return nB(t)}catch{}return``}function iB(e,t){let n=t??{},r=tB(n.file_path??n.path);switch(e){case`Edit`:case`MultiEdit`:case`NotebookEdit`:case`Update`:return{step:!0,actionKey:`editing`,actionArg:r};case`Write`:case`create`:return{step:!0,actionKey:`writing`,actionArg:r};case`Read`:return{step:!0,actionKey:`reading`,actionArg:r};case`Grep`:case`Glob`:case`search`:return{step:!0,actionKey:`searching`,actionArg:eB(String(n.pattern??n.query??``))};case`Bash`:case`shell`:return{step:!0,actionKey:`running`,actionArg:nB(n.command)};default:return{step:!0,actionKey:`working`}}}function aB(e){let t=e.event_type,n={};try{let t=JSON.parse(e.payload);t&&typeof t==`object`&&!Array.isArray(t)&&(n=t)}catch{}if(t===`assistant`){let e=n.message?.content;if(Array.isArray(e)){let t=e.filter(e=>e?.type===`tool_use`);if(t.length>0){let e=t[t.length-1];return{...iB(e.name,e.input),stepCount:t.length}}if(e.some(e=>e?.type===`text`))return{step:!0,actionKey:`thinking`}}return{step:!0}}if(t===`tool_use`)return iB(n.name,n.input);if(t===`item.completed`){let e=n.item,t=e?.type;return t===`agent_message`?{step:!0,actionKey:`thinking`}:t===`agent_reasoning`?{step:!0,actionKey:`reasoning`}:t===`function_call`||t===`local_shell_call`||t===`command_execution`?{step:!0,actionKey:`running`,actionArg:nB(e?.command)||rB(e?.arguments)||(typeof e?.name==`string`?eB(e.name):``)||(t===`local_shell_call`?`shell`:``)}:{step:!0}}return{step:!1}}var oB=(0,H.createContext)({});function sB(){return(0,H.useContext)(oB)}function cB({activeProjectId:e,children:t}){let[n,r]=(0,H.useState)(new Map),{registerHandler:i,unregisterHandler:a}=df(),o=(0,H.useRef)(e);(0,H.useEffect)(()=>{o.current=e},[e]),(0,H.useEffect)(()=>{if(r(new Map),!e)return;let t=!1;return fetch(`/api/projects/${e}/rails`).then(e=>e.ok?e.json():null).then(e=>{if(t||!e?.activeLoopRuns)return;let n=new Map;for(let[t,r]of Object.entries(e.activeLoopRuns))r?.loopRunId&&n.set(r.loopRunId,{railIndex:Number(t),startedAt:r.startedAt?new Date(r.startedAt).getTime():Date.now(),steps:r.steps??0,lines:r.lines??0});n.size!==0&&r(e=>{let t=new Map(e);for(let[e,r]of n)t.has(e)||t.set(e,r);return t})}).catch(()=>{}),()=>{t=!0}},[e]);let s=(0,H.useCallback)(e=>{let t=e;if(!(!t||typeof t.type!=`string`)){if(t.type===`loop.run_started`){if(t.projectId!==o.current||!t.loopRunId)return;r(e=>{let n=new Map(e);return n.set(t.loopRunId,{railIndex:t.railIndex??0,startedAt:Date.now(),steps:0,lines:0}),n});return}if(t.type===`loop.run_completed`){r(e=>{if(!t.loopRunId||!e.has(t.loopRunId))return e;let n=new Map(e);return n.delete(t.loopRunId),n});return}if(t.type===`rail.job_started`){if(t.projectId!==o.current||!t.jobId||t.railIndex==null)return;r(e=>{let n=new Map(e);return n.set(t.jobId,{railIndex:t.railIndex,startedAt:Date.now(),steps:0,lines:0}),n});return}if(t.type===`rail.job_completed`||t.type===`rail.job_stopped`){r(e=>{if(!t.jobId||!e.has(t.jobId))return e;let n=new Map(e);return n.delete(t.jobId),n});return}if(t.type===`event`&&t.event_type&&t.jobId){let e=aB({event_type:t.event_type,payload:t.payload??``});if(!e.step)return;r(n=>{let r=n.get(t.jobId);if(!r)return n;let i=new Map(n);return i.set(t.jobId,{...r,steps:r.steps+(e.stepCount??1)}),i});return}t.type===`log`&&t.processId&&r(e=>{let n=e.get(t.processId);if(!n)return e;let r=new Map(e);return r.set(t.processId,{...n,lines:n.lines+1}),r})}},[]);(0,H.useLayoutEffect)(()=>(i(`rail-exec-metrics`,s),()=>a(`rail-exec-metrics`)),[s,i,a]);let c=(0,H.useMemo)(()=>{let e={};for(let t of n.values()){let n=e[t.railIndex];n?(n.startedAt=Math.min(n.startedAt,t.startedAt),n.steps+=t.steps,n.lines+=t.lines):e[t.railIndex]={startedAt:t.startedAt,steps:t.steps,lines:t.lines}}return e},[n]);return(0,Y.jsx)(oB.Provider,{value:c,children:t})}var lB=(0,H.createContext)({decisions:new Map,hydrated:!0,act:async()=>({status:0,ok:!1,error:`no_provider`}),checkout:async()=>({status:0,ok:!1,error:`no_provider`})});function uB(){return(0,H.useContext)(lB)}function dB(e,t){return!e?.id||!e.decision?null:{prDeliveryId:e.id,railIndex:e.railIndex??t,railKey:e.railKey??``,ticketIds:Array.isArray(e.ticketIds)?e.ticketIds:[],baseBranch:e.baseBranch??``,branch:e.branch??null,prUrl:e.prUrl??null,prNumber:e.prNumber??null,prState:e.prState??`none`,decision:e.decision,runIds:Array.isArray(e.runIds)?e.runIds:[],originConversationId:e.originConversationId??null}}var fB=new Set([`merged`,`discarded`]);function pB({activeProjectId:e,children:t}){let{t:n}=K(`dashboard`),[r,i]=(0,H.useState)(new Map),[a,o]=(0,H.useState)(!1),{registerHandler:s,unregisterHandler:c}=df(),l=(0,H.useRef)(e);(0,H.useEffect)(()=>{l.current=e},[e]);let u=(0,H.useRef)(r);(0,H.useEffect)(()=>{u.current=r},[r]);let d=(0,H.useRef)(new Set);(0,H.useEffect)(()=>{if(i(new Map),o(!1),d.current=new Set,!e){o(!0);return}let t=!1;return fetch(`/api/projects/${e}/rails`).then(e=>e.ok?e.json():null).then(e=>{if(t)return;if(!e?.prDeliveries){o(!0);return}let n=new Map;for(let[t,r]of Object.entries(e.prDeliveries)){let e=dB(r,Number(t));e&&!fB.has(e.decision)&&n.set(Number(t),e)}n.size>0&&i(e=>{let t=new Map(e);for(let[e,r]of n)d.current.has(e)||t.set(e,r);return t}),o(!0)}).catch(()=>{t||o(!0)}),()=>{t=!0}},[e]);let f=(0,H.useCallback)(e=>{let t=e;if(!t||t.type!==`rail.pr_state`||t.projectId!==l.current||typeof t.railIndex!=`number`||typeof t.prDeliveryId!=`string`||!t.decision)return;let r=t,a={prDeliveryId:r.prDeliveryId,railIndex:r.railIndex,railKey:r.railKey??``,ticketIds:Array.isArray(r.ticketIds)?r.ticketIds:[],baseBranch:r.baseBranch??``,branch:r.branch??null,prUrl:r.prUrl??null,prNumber:r.prNumber??null,prState:r.prState??`none`,decision:r.decision,runIds:Array.isArray(r.runIds)?r.runIds:[],originConversationId:r.originConversationId??null};if(d.current.add(a.railIndex),fB.has(a.decision)){i(e=>{if(!e.has(a.railIndex))return e;a.decision===`merged`?q.success(n(`railPr.mergedToast`)):q.info(n(`railPr.discardedToast`));let t=new Map(e);return t.delete(a.railIndex),t});return}i(e=>{let t=new Map(e);return t.set(a.railIndex,a),t})},[n]);(0,H.useLayoutEffect)(()=>(s(`rail-pr-decision`,f),()=>c(`rail-pr-decision`)),[f,s,c]);let p=(0,H.useCallback)(async(e,t,n)=>{let r=u.current.get(e),i=l.current;if(!r||!i)return{status:0,ok:!1,error:`no_delivery`};try{let e=await fetch(`/api/projects/${i}/rails/pr-decision`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({prDeliveryId:r.prDeliveryId,action:t,expectedDecision:n})}),a=await e.json().catch(()=>({}));return{...a,status:e.status,ok:e.ok&&a.ok===!0}}catch(e){return{status:0,ok:!1,error:`network`,detail:e.message}}},[]),m=(0,H.useCallback)(async e=>{let t=u.current.get(e),n=l.current;if(!t||!n)return{status:0,ok:!1,error:`no_delivery`};try{let e=await fetch(`/api/projects/${n}/rails/pr-checkout`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({prDeliveryId:t.prDeliveryId})}),r=await e.json().catch(()=>({}));return{...r,status:e.status,ok:e.ok&&r.ok===!0}}catch(e){return{status:0,ok:!1,error:`network`,detail:e.message}}},[]),h=(0,H.useMemo)(()=>({decisions:r,hydrated:a,act:p,checkout:m}),[r,a,p,m]);return(0,Y.jsx)(lB.Provider,{value:h,children:t})}function mB(e){return e?`specrails-desktop:dashboard-split:${e}`:null}function hB(e){let t=mB(e);if(!t)return null;try{let e=localStorage.getItem(t);if(!e)return null;let n=Number.parseInt(e,10);return Number.isFinite(n)&&n>0?n:null}catch{return null}}function gB(e,t){let n=mB(e);if(n)try{localStorage.setItem(n,String(Math.round(t)))}catch{}}function _B(e,t){let n=Math.max(320,t-280);return Math.min(Math.max(e,320),n)}var vB=.7;function yB(e){return _B(Math.round(e*vB),e)}function bB(e,t){let n=yB(t);return Math.abs(e-n)<=48?n:e}function xB(e,t){let[n,r]=(0,H.useState)(()=>typeof window<`u`?window.innerWidth:1200),i=(0,H.useRef)(n),[a,o]=(0,H.useState)(()=>{if(typeof window>`u`)return null;let e=window.innerWidth;return e<900?null:yB(e)}),s=(0,H.useRef)(null),c=(0,H.useRef)(null),l=(0,H.useRef)(null);(0,H.useEffect)(()=>{if(typeof window>`u`)return;let e=t?.current?.clientWidth||window.innerWidth;if(r(e),i.current=e,e<900){o(null);return}o(yB(e))},[e,t]),(0,H.useEffect)(()=>{function n(t){if(r(t),t<900){i.current=t,o(null);return}let n=t-i.current;i.current=t,o(r=>{let i=r??hB(e)??yB(t),a=_B(r!==null&&Number.isFinite(n)?i+n:i,t);return a!==r&&gB(e,a),a})}let a=t?.current;if(a&&typeof ResizeObserver<`u`){let e=new ResizeObserver(e=>{let t=e[0]?.contentRect.width;typeof t==`number`&&n(t)});return e.observe(a),n(a.clientWidth||window.innerWidth),()=>e.disconnect()}function s(){n(window.innerWidth)}return window.addEventListener(`resize`,s),()=>window.removeEventListener(`resize`,s)},[e,t]);let u=(0,H.useCallback)(()=>{if(c.current=null,l.current===null)return;let e=_B(l.current,n);l.current=null,o(e)},[n]),d=(0,H.useCallback)(e=>{if(!s.current)return;let t=e.clientX-s.current.startClientX;l.current=s.current.startLeftWidth+t,c.current===null&&(c.current=requestAnimationFrame(u))},[u]),f=(0,H.useCallback)(t=>{if(!s.current)return;let{pointerId:r,element:i}=s.current;try{i.releasePointerCapture(r)}catch{}s.current=null,window.removeEventListener(`pointermove`,d),window.removeEventListener(`pointerup`,f),window.removeEventListener(`pointercancel`,f),o(t=>{if(t===null)return t;let r=_B(bB(t,n),n);return gB(e,r),r})},[d,e,n]),p=(0,H.useCallback)(e=>{let t=e.nativeEvent??e,n=e.currentTarget??t.target;try{n.setPointerCapture(t.pointerId)}catch{}s.current={pointerId:t.pointerId,element:n,startClientX:t.clientX,startLeftWidth:a??0},window.addEventListener(`pointermove`,d),window.addEventListener(`pointerup`,f),window.addEventListener(`pointercancel`,f)},[d,f,a]),m=(0,H.useCallback)(()=>{if(typeof window>`u`)return;let n=t?.current?.clientWidth||window.innerWidth;if(n<900)return;let r=yB(n);o(r),gB(e,r)},[e,t]);return{leftWidth:a,enabled:a!==null&&n>=900,beginDrag:p,resetToDefault:m}}function SB({leftWidth:e,onPointerDown:t,onReset:n,viewport:r}){let i=(0,H.useCallback)(t=>{let n=t.shiftKey?64:16;t.key===`ArrowLeft`&&(t.preventDefault(),e-n)},[e]);return(0,Y.jsxs)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-valuenow":e,"aria-valuemin":320,"aria-valuemax":Math.max(320,r-280),tabIndex:0,onPointerDown:t,onDoubleClick:n,onKeyDown:i,className:`relative w-1.5 shrink-0 cursor-col-resize group select-none touch-none focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-info/60`,"data-testid":`dashboard-splitter`,children:[(0,Y.jsx)(`div`,{className:`absolute inset-y-0 left-1/2 -translate-x-1/2 w-px bg-border/40 group-hover:bg-accent-info/40 group-focus-visible:bg-accent-info/60 transition-colors`}),(0,Y.jsxs)(`div`,{className:`absolute inset-y-0 left-1/2 -translate-x-1/2 flex flex-col items-center justify-center gap-1 pointer-events-none opacity-0 group-hover:opacity-100 transition-opacity`,children:[(0,Y.jsx)(`div`,{className:`w-1 h-1 rounded-full bg-accent-info/60`}),(0,Y.jsx)(`div`,{className:`w-1 h-1 rounded-full bg-accent-info/60`}),(0,Y.jsx)(`div`,{className:`w-1 h-1 rounded-full bg-accent-info/60`})]})]})}function CB(e,t){return Mf(e,{...t,weekStartsOn:1})}function wB(e,t){let n=jf(e,t?.in),r=n.getFullYear(),i=Df(n,0);i.setFullYear(r+1,0,4),i.setHours(0,0,0,0);let a=CB(i),o=Df(n,0);o.setFullYear(r,0,4),o.setHours(0,0,0,0);let s=CB(o);return n.getTime()>=a.getTime()?r+1:n.getTime()>=s.getTime()?r:r-1}function TB(e){let t=jf(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),e-+n}function EB(e,t){let n=jf(e,t?.in);return n.setHours(0,0,0,0),n}function DB(e,t,n){let[r,i]=Of(n?.in,e,t),a=EB(r),o=EB(i),s=+a-TB(a),c=+o-TB(o);return Math.round((s-c)/bf)}function OB(e,t){let n=wB(e,t),r=Df(t?.in||e,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),CB(r)}function kB(e,t){let n=jf(e)-+jf(t);return n<0?-1:n>0?1:n}function AB(e){return Df(e,Date.now())}function jB(e){return e instanceof Date||typeof e==`object`&&Object.prototype.toString.call(e)===`[object Date]`}function MB(e){return!(!jB(e)&&typeof e!=`number`||isNaN(+jf(e)))}function NB(e,t,n){let[r,i]=Of(n?.in,e,t),a=r.getFullYear()-i.getFullYear(),o=r.getMonth()-i.getMonth();return a*12+o}function PB(e){return t=>{let n=(e?Math[e]:Math.trunc)(t);return n===0?0:n}}function FB(e,t){return jf(e)-+jf(t)}function IB(e,t){let n=jf(e,t?.in);return n.setHours(23,59,59,999),n}function LB(e,t){let n=jf(e,t?.in),r=n.getMonth();return n.setFullYear(n.getFullYear(),r+1,0),n.setHours(23,59,59,999),n}function RB(e,t){let n=jf(e,t?.in);return+IB(n,t)==+LB(n,t)}function zB(e,t,n){let[r,i,a]=Of(n?.in,e,e,t),o=kB(i,a),s=Math.abs(NB(i,a));if(s<1)return 0;i.getMonth()===1&&i.getDate()>27&&i.setDate(30),i.setMonth(i.getMonth()-o*s);let c=kB(i,a)===-o;RB(r)&&s===1&&kB(r,a)===1&&(c=!1);let l=o*(s-+c);return l===0?0:l}function BB(e,t,n){let r=FB(e,t)/1e3;return PB(n?.roundingMethod)(r)}function VB(e,t){let n=jf(e,t?.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}function HB(e,t){let n=jf(e,t?.in);return DB(n,VB(n))+1}function UB(e,t){let n=jf(e,t?.in),r=CB(n)-+OB(n);return Math.round(r/yf)+1}function WB(e,t){let n=jf(e,t?.in),r=n.getFullYear(),i=Af(),a=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??i.firstWeekContainsDate??i.locale?.options?.firstWeekContainsDate??1,o=Df(t?.in||e,0);o.setFullYear(r+1,0,a),o.setHours(0,0,0,0);let s=Mf(o,t),c=Df(t?.in||e,0);c.setFullYear(r,0,a),c.setHours(0,0,0,0);let l=Mf(c,t);return+n>=+s?r+1:+n>=+l?r:r-1}function GB(e,t){let n=Af(),r=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,i=WB(e,t),a=Df(t?.in||e,0);return a.setFullYear(i,0,r),a.setHours(0,0,0,0),Mf(a,t)}function KB(e,t){let n=jf(e,t?.in),r=Mf(n,t)-+GB(n,t);return Math.round(r/yf)+1}function qB(e,t){return(e<0?`-`:``)+Math.abs(e).toString().padStart(t,`0`)}var JB={y(e,t){let n=e.getFullYear(),r=n>0?n:1-n;return qB(t===`yy`?r%100:r,t.length)},M(e,t){let n=e.getMonth();return t===`M`?String(n+1):qB(n+1,2)},d(e,t){return qB(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 qB(e.getHours()%12||12,t.length)},H(e,t){return qB(e.getHours(),t.length)},m(e,t){return qB(e.getMinutes(),t.length)},s(e,t){return qB(e.getSeconds(),t.length)},S(e,t){let n=t.length,r=e.getMilliseconds();return qB(Math.trunc(r*10**(n-3)),t.length)}},YB={am:`am`,pm:`pm`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},XB={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 JB.y(e,t)},Y:function(e,t,n,r){let i=WB(e,r),a=i>0?i:1-i;return t===`YY`?qB(a%100,2):t===`Yo`?n.ordinalNumber(a,{unit:`year`}):qB(a,t.length)},R:function(e,t){return qB(wB(e),t.length)},u:function(e,t){return qB(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 qB(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 qB(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 JB.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 qB(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=KB(e,r);return t===`wo`?n.ordinalNumber(i,{unit:`week`}):qB(i,t.length)},I:function(e,t,n){let r=UB(e);return t===`Io`?n.ordinalNumber(r,{unit:`week`}):qB(r,t.length)},d:function(e,t,n){return t===`do`?n.ordinalNumber(e.getDate(),{unit:`date`}):JB.d(e,t)},D:function(e,t,n){let r=HB(e);return t===`Do`?n.ordinalNumber(r,{unit:`dayOfYear`}):qB(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 qB(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 qB(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 qB(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?YB.noon:r===0?YB.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?YB.evening:r>=12?YB.afternoon:r>=4?YB.morning:YB.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 JB.h(e,t)},H:function(e,t,n){return t===`Ho`?n.ordinalNumber(e.getHours(),{unit:`hour`}):JB.H(e,t)},K:function(e,t,n){let r=e.getHours()%12;return t===`Ko`?n.ordinalNumber(r,{unit:`hour`}):qB(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t===`ko`?n.ordinalNumber(r,{unit:`hour`}):qB(r,t.length)},m:function(e,t,n){return t===`mo`?n.ordinalNumber(e.getMinutes(),{unit:`minute`}):JB.m(e,t)},s:function(e,t,n){return t===`so`?n.ordinalNumber(e.getSeconds(),{unit:`second`}):JB.s(e,t)},S:function(e,t){return JB.S(e,t)},X:function(e,t,n){let r=e.getTimezoneOffset();if(r===0)return`Z`;switch(t){case`X`:return QB(r);case`XXXX`:case`XX`:return $B(r);default:return $B(r,`:`)}},x:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`x`:return QB(r);case`xxxx`:case`xx`:return $B(r);default:return $B(r,`:`)}},O:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`O`:case`OO`:case`OOO`:return`GMT`+ZB(r,`:`);default:return`GMT`+$B(r,`:`)}},z:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`z`:case`zz`:case`zzz`:return`GMT`+ZB(r,`:`);default:return`GMT`+$B(r,`:`)}},t:function(e,t,n){return qB(Math.trunc(e/1e3),t.length)},T:function(e,t,n){return qB(+e,t.length)}};function ZB(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+qB(a,2)}function QB(e,t){return e%60==0?(e>0?`-`:`+`)+qB(Math.abs(e)/60,2):$B(e,t)}function $B(e,t=``){let n=e>0?`-`:`+`,r=Math.abs(e),i=qB(Math.trunc(r/60),2),a=qB(r%60,2);return n+i+t+a}var eV=(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`})}},tV=(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`})}},nV={p:tV,P:(e,t)=>{let n=e.match(/(P+)(p+)?/)||[],r=n[1],i=n[2];if(!i)return eV(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}}`,eV(r,t)).replace(`{{time}}`,tV(i,t))}},rV=/^D+$/,iV=/^Y+$/,aV=[`D`,`DD`,`YY`,`YYYY`];function oV(e){return rV.test(e)}function sV(e){return iV.test(e)}function cV(e,t,n){let r=lV(e,t,n);if(console.warn(r),aV.includes(e))throw RangeError(r)}function lV(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 uV=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,dV=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,fV=/^'([^]*?)'?$/,pV=/''/g,mV=/[a-zA-Z]/;function hV(e,t,n){let r=Af(),i=n?.locale??r.locale??Xf,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=jf(e,n?.in);if(!MB(s))throw RangeError(`Invalid time value`);let c=t.match(dV).map(e=>{let t=e[0];if(t===`p`||t===`P`){let n=nV[t];return n(e,i.formatLong)}return e}).join(``).match(uV).map(e=>{if(e===`''`)return{isToken:!1,value:`'`};let t=e[0];if(t===`'`)return{isToken:!1,value:gV(e)};if(XB[t])return{isToken:!0,value:e};if(t.match(mV))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&&sV(a)||!n?.useAdditionalDayOfYearTokens&&oV(a))&&cV(a,t,String(e));let o=XB[a[0]];return o(s,a,i.localize,l)}).join(``)}function gV(e){let t=e.match(fV);return t?t[1].replace(pV,`'`):e}function _V(e,t,n){let r=Af(),i=n?.locale??r.locale??Xf,a=kB(e,t);if(isNaN(a))throw RangeError(`Invalid time value`);let o=Object.assign({},n,{addSuffix:n?.addSuffix,comparison:a}),[s,c]=Of(n?.in,...a>0?[t,e]:[e,t]),l=BB(c,s),u=(TB(c)-TB(s))/1e3,d=Math.round((l-u)/60),f;if(d<2)return n?.includeSeconds?l<5?i.formatDistance(`lessThanXSeconds`,5,o):l<10?i.formatDistance(`lessThanXSeconds`,10,o):l<20?i.formatDistance(`lessThanXSeconds`,20,o):l<40?i.formatDistance(`halfAMinute`,0,o):l<60?i.formatDistance(`lessThanXMinutes`,1,o):i.formatDistance(`xMinutes`,1,o):d===0?i.formatDistance(`lessThanXMinutes`,1,o):i.formatDistance(`xMinutes`,d,o);if(d<45)return i.formatDistance(`xMinutes`,d,o);if(d<90)return i.formatDistance(`aboutXHours`,1,o);if(d<1440){let e=Math.round(d/60);return i.formatDistance(`aboutXHours`,e,o)}else if(d<2520)return i.formatDistance(`xDays`,1,o);else if(d<43200){let e=Math.round(d/wf);return i.formatDistance(`xDays`,e,o)}else if(d<43200*2)return f=Math.round(d/Cf),i.formatDistance(`aboutXMonths`,f,o);if(f=zB(c,s),f<12){let e=Math.round(d/Cf);return i.formatDistance(`xMonths`,e,o)}else{let e=f%12,t=Math.trunc(f/12);return e<3?i.formatDistance(`aboutXYears`,t,o):e<9?i.formatDistance(`overXYears`,t,o):i.formatDistance(`almostXYears`,t+1,o)}}function vV(e,t){return _V(e,AB(e),t)}function yV(e,t){let n=()=>Df(t?.in,NaN),r=t?.additionalDigits??2,i=wV(e),a;if(i.date){let e=TV(i.date,r);a=EV(e.restDateString,e.year)}if(!a||isNaN(+a))return n();let o=+a,s=0,c;if(i.time&&(s=OV(i.time),isNaN(s)))return n();if(i.timezone){if(c=AV(i.timezone),isNaN(c))return n()}else{let e=new Date(o+s),n=jf(0,t?.in);return n.setFullYear(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()),n.setHours(e.getUTCHours(),e.getUTCMinutes(),e.getUTCSeconds(),e.getUTCMilliseconds()),n}return jf(o+s+c,t?.in)}var bV={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},xV=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,SV=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,CV=/^([+-])(\d{2})(?::?(\d{2}))?$/;function wV(e){let t={},n=e.split(bV.dateTimeDelimiter),r;if(n.length>2)return t;if(/:/.test(n[0])?r=n[0]:(t.date=n[0],r=n[1],bV.timeZoneDelimiter.test(t.date)&&(t.date=e.split(bV.timeZoneDelimiter)[0],r=e.substr(t.date.length,e.length))),r){let e=bV.timezone.exec(r);e?(t.time=r.replace(e[1],``),t.timezone=e[1]):t.time=r}return t}function TV(e,t){let n=RegExp(`^(?:(\\d{4}|[+-]\\d{`+(4+t)+`})|(\\d{2}|[+-]\\d{`+(2+t)+`})$)`),r=e.match(n);if(!r)return{year:NaN,restDateString:``};let i=r[1]?parseInt(r[1]):null,a=r[2]?parseInt(r[2]):null;return{year:a===null?i:a*100,restDateString:e.slice((r[1]||r[2]).length)}}function EV(e,t){if(t===null)return new Date(NaN);let n=e.match(xV);if(!n)return new Date(NaN);let r=!!n[4],i=DV(n[1]),a=DV(n[2])-1,o=DV(n[3]),s=DV(n[4]),c=DV(n[5])-1;if(r)return IV(t,s,c)?jV(t,s,c):new Date(NaN);{let e=new Date(0);return!PV(t,a,o)||!FV(t,i)?new Date(NaN):(e.setUTCFullYear(t,a,Math.max(i,o)),e)}}function DV(e){return e?parseInt(e):1}function OV(e){let t=e.match(SV);if(!t)return NaN;let n=kV(t[1]),r=kV(t[2]),i=kV(t[3]);return LV(n,r,i)?n*Sf+r*xf+i*1e3:NaN}function kV(e){return e&&parseFloat(e.replace(`,`,`.`))||0}function AV(e){if(e===`Z`)return 0;let t=e.match(CV);if(!t)return 0;let n=t[1]===`+`?-1:1,r=parseInt(t[2]),i=t[3]&&parseInt(t[3])||0;return RV(r,i)?n*(r*Sf+i*xf):NaN}function jV(e,t,n){let r=new Date(0);r.setUTCFullYear(e,0,4);let i=r.getUTCDay()||7,a=(t-1)*7+n+1-i;return r.setUTCDate(r.getUTCDate()+a),r}var MV=[31,null,31,30,31,30,31,31,30,31,30,31];function NV(e){return e%400==0||e%4==0&&e%100!=0}function PV(e,t,n){return t>=0&&t<=11&&n>=1&&n<=(MV[t]||(NV(e)?29:28))}function FV(e,t){return t>=1&&t<=(NV(e)?366:365)}function IV(e,t,n){return t>=1&&t<=53&&n>=0&&n<=6}function LV(e,t,n){return e===24?t===0&&n===0:n>=0&&n<60&&t>=0&&t<60&&e>=0&&e<25}function RV(e,t){return t>=0&&t<=59}function zV(){return typeof window<`u`&&window.__TAURI_INTERNALS__!==void 0}function BV(e){return Function(`s`,`return import(s)`)(e).catch(()=>null)}async function VV(e){if(zV()){try{let t=await BV(`@tauri-apps/plugin-opener`);if(t?.revealItemInDir){await t.revealItemInDir(e);return}}catch{}try{await(await BV(`@tauri-apps/api/shell`))?.open?.(e)}catch{}}}async function HV(e){if(zV())try{let t=await a(()=>import(`./dist-js-UjXbEWhN.js`),[]);if(typeof t.open==`function`){await t.open(e);return}}catch(e){console.warn(`[openExternalUrl] tauri shell open failed:`,e)}try{window.open(e,`_blank`,`noopener,noreferrer`)}catch{}}function UV({ticketKey:e,attachment:t,onClose:n}){let{t:r}=K(`attachments`),[i,a]=(0,H.useState)(null),[o,s]=(0,H.useState)(null);if((0,H.useEffect)(()=>{if(!t)return;function e(e){e.key===`Escape`&&n()}document.addEventListener(`keydown`,e);let r=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.removeEventListener(`keydown`,e),document.body.style.overflow=r}},[t,n]),(0,H.useEffect)(()=>{if(!t){a(null),s(null);return}let n=!1;return a(null),s(null),ED(e,t.id).then(e=>{n||a(URL.createObjectURL(e))}).catch(e=>{n||s(e instanceof Error?e.message:r(`errors.loadFailed`))}),()=>{n=!0}},[t,e]),(0,H.useEffect)(()=>()=>{i&&URL.revokeObjectURL(i)},[i]),!t)return null;let c=t.mimeType.startsWith(`image/`),l=t.mimeType===`application/pdf`;return(0,Y.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":r(`lightbox.preview`,{name:t.filename}),className:`fixed inset-0 z-[100] flex flex-col bg-black/85 backdrop-blur-sm animate-in fade-in-0 duration-200`,onClick:n,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b border-white/10 bg-black/40`,onClick:e=>e.stopPropagation(),children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:n,"aria-label":r(`lightbox.backToDesktop`),className:`inline-flex items-center gap-2 px-3 py-1.5 rounded-md text-sm text-white/85 hover:bg-white/10 hover:text-white transition-colors`,children:[(0,Y.jsx)(Ba,{className:`w-4 h-4`}),r(`common:actions.back`)]}),(0,Y.jsxs)(`div`,{className:`flex-1 text-center min-w-0 px-4`,children:[(0,Y.jsx)(`div`,{className:`text-sm font-medium text-white/95 truncate`,children:t.filename}),(0,Y.jsx)(`div`,{className:`text-[11px] text-white/50`,children:t.mimeType})]}),(0,Y.jsxs)(`a`,{href:i??`#`,download:t.filename,onClick:e=>{e.stopPropagation(),i||e.preventDefault()},className:`inline-flex items-center gap-2 px-3 py-1.5 rounded-md text-sm text-white/85 hover:bg-white/10 hover:text-white transition-colors`,"aria-label":r(`lightbox.download`),children:[(0,Y.jsx)(To,{className:`w-4 h-4`}),r(`lightbox.download`)]})]}),(0,Y.jsx)(`div`,{className:X(`flex-1 flex items-center justify-center overflow-auto p-6`),onClick:n,children:o?(0,Y.jsx)(`div`,{onClick:e=>e.stopPropagation(),className:`text-center text-white/80 px-8 py-10 rounded-lg bg-white/5 border border-white/10`,children:(0,Y.jsx)(`p`,{className:`text-sm`,children:r(`lightbox.loadError`,{error:o})})}):i?c?(0,Y.jsx)(`img`,{src:i,alt:t.filename,onClick:e=>e.stopPropagation(),className:`max-h-full max-w-full rounded-lg shadow-2xl animate-in zoom-in-95 duration-200`}):l?(0,Y.jsx)(`iframe`,{src:i,title:t.filename,onClick:e=>e.stopPropagation(),className:`w-full h-full max-w-5xl bg-white rounded-lg shadow-2xl`}):(0,Y.jsxs)(`div`,{onClick:e=>e.stopPropagation(),className:`text-center text-white/80 px-8 py-10 rounded-lg bg-white/5 border border-white/10`,children:[(0,Y.jsx)(`p`,{className:`text-sm mb-3`,children:r(`lightbox.previewUnavailable`)}),(0,Y.jsxs)(`a`,{href:i,download:t.filename,className:`inline-flex items-center gap-2 px-4 py-2 rounded-md bg-white/10 hover:bg-white/20 text-white transition-colors`,children:[(0,Y.jsx)(To,{className:`w-4 h-4`}),r(`lightbox.downloadFile`,{name:t.filename})]})]}):(0,Y.jsx)(`div`,{onClick:e=>e.stopPropagation(),className:`text-center text-white/70 px-8 py-10 rounded-lg bg-white/5 border border-white/10`,children:(0,Y.jsx)(`p`,{className:`text-sm`,children:r(`lightbox.loading`)})})})]})}function WV(e,t){let n=new Set,r=[];for(let i of[...e,...t])n.has(i.id)||(n.add(i.id),r.push(i));return r}function GV(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function KV(e){return e.startsWith(`image/`)?`🖼`:e===`application/pdf`?`📄`:e===`text/csv`||e.includes(`spreadsheetml`)||e===`application/vnd.ms-excel`?`📊`:e===`application/json`?`{ }`:e===`text/plain`||e.includes(`sql`)?`📝`:`📎`}function qV(e){try{return new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})}catch{return e}}function JV({ticketKey:e,attachments:t,onChange:n,className:r}){let{t:i}=K(`attachments`),[a,o]=(0,H.useState)(new Set),[s,c]=(0,H.useState)(null),[l,u]=(0,H.useState)(null);if((0,H.useEffect)(()=>{let r=!1;return wD(e).then(e=>{if(r)return;let i=WV(t,e);i.length!==t.length&&n?.(i)}).catch(()=>{}),()=>{r=!0}},[e]),!t||t.length===0)return null;let d=[...t].sort((e,t)=>e.addedAt<t.addedAt?1:-1);async function f(r){c(null),o(e=>{let t=new Set(e);return t.add(r.id),t});try{await SD(e,r.id),await new Promise(e=>setTimeout(e,160)),n?.(t.filter(e=>e.id!==r.id))}catch(e){c(e instanceof Error?e.message:i(`errors.removeFailed`)),o(e=>{let t=new Set(e);return t.delete(r.id),t})}}return(0,Y.jsxs)(`section`,{className:X(`mt-4`,r),"aria-label":i(`section.ariaLabel`),children:[(0,Y.jsxs)(`header`,{className:`flex items-center justify-between mb-2`,children:[(0,Y.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:i(`section.title`)}),(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:i(`section.fileCount`,{count:d.length})})]}),(0,Y.jsx)(`ul`,{className:`flex flex-col gap-1`,children:d.map(e=>{let t=a.has(e.id);return(0,Y.jsxs)(`li`,{className:X(`flex items-center gap-3 px-2.5 py-2 rounded-md border border-border bg-card/60 hover:bg-card transition-all duration-200`,t&&`opacity-0 scale-95 max-h-0 py-0 border-transparent overflow-hidden`),children:[(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`w-6 text-center text-sm shrink-0`,children:KV(e.mimeType)}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>u(e),className:`flex-1 min-w-0 flex flex-col text-sm text-left hover:text-primary transition-colors`,children:[(0,Y.jsx)(`span`,{className:`font-medium truncate text-foreground`,children:e.filename}),(0,Y.jsxs)(`span`,{className:`text-[11px] text-muted-foreground`,children:[GV(e.size),` · `,qV(e.addedAt)]})]}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>u(e),className:`text-[11px] text-primary hover:underline shrink-0`,children:i(`common:actions.open`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>f(e),"aria-label":i(`removeFile`,{name:e.filename}),disabled:t,className:`w-6 h-6 inline-flex items-center justify-center rounded text-muted-foreground hover:text-destructive hover:bg-destructive/10 transition-colors disabled:opacity-50`,children:`×`})]},e.id)})}),s&&(0,Y.jsx)(`p`,{className:`mt-2 text-xs text-destructive`,children:s}),(0,Y.jsx)(UV,{ticketKey:e,attachment:l,onClose:()=>u(null)})]})}function YV({ticketId:e,onClose:t}){let{t:n}=K(`code`),r=_t(),{activeProjectId:i}=gm(),[a,o]=(0,H.useState)(null);return(0,H.useEffect)(()=>{if(!Pb)return;let t=new AbortController;return o(null),fetch(`${af()}/code/provenance?ticketId=${e}`,{signal:t.signal}).then(e=>e.ok?e.json():[]).then(e=>{o(Array.isArray(e)?e:[])}).catch(e=>{e?.name!==`AbortError`&&o([])}),()=>t.abort()},[e,i]),!Pb||!a||a.length===0?null:(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1.5`,children:n(`ticketFiles.title`)}),(0,Y.jsx)(`ul`,{className:`space-y-1`,children:a.map((e,i)=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{t(),r(`/code?path=${encodeURIComponent(e.path)}`)},className:`w-full text-left flex items-center gap-2 rounded px-2 py-1 text-xs hover:bg-muted/40`,children:[(0,Y.jsx)(e.kind===`created`?No:e.kind===`deleted`?Mo:Po,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,Y.jsx)(`span`,{className:`font-mono truncate flex-1`,children:e.path}),e.jobId&&(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] text-muted-foreground font-mono shrink-0`,title:n(`ticketFiles.jobTitle`,{jobId:e.jobId}),children:[(0,Y.jsx)(Uo,{className:`h-3 w-3`}),e.jobId.length>10?e.jobId.slice(0,10):e.jobId]}),(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground uppercase tracking-wider shrink-0`,children:n(`kind.${e.kind}`)})]})},`${e.path}-${i}`))})]})}var XV={critical:`bg-red-500/15 aurora-light:bg-destructive/10 text-red-400 aurora-light:text-destructive border-red-500/30 aurora-light:border-destructive/30`,high:`bg-orange-500/15 aurora-light:bg-accent-warning/10 text-orange-400 aurora-light:text-accent-warning border-orange-500/30 aurora-light:border-accent-warning/30`,medium:``,low:`bg-gray-500/15 aurora-light:bg-muted text-gray-400 aurora-light:text-muted-foreground border-gray-500/30 aurora-light:border-border`};function ZV(e){try{return vV(new Date(e),{addSuffix:!0,locale:im()})}catch{return e}}function QV({tickets:e,excludeIds:t,onSelect:n}){let{t:r}=K(`tickets`),[i,a]=(0,H.useState)(``),o=(0,H.useMemo)(()=>{let n=new Set(t),r=e.filter(e=>e.status!==`cancelled`&&!n.has(e.id));if(!i.trim())return r;let a=i.toLowerCase();return r.filter(e=>e.title.toLowerCase().includes(a)||e.description.toLowerCase().includes(a))},[e,t,i]);return(0,Y.jsxs)(`div`,{"data-testid":`spec-compare-picker`,className:`h-full flex flex-col rounded-xl bg-card border border-border/40 shadow-2xl shadow-black/50 overflow-hidden`,children:[(0,Y.jsxs)(`div`,{className:`px-4 py-3 border-b border-border/30 flex items-center gap-2`,children:[(0,Y.jsx)(oc,{className:`w-3.5 h-3.5 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`text-xs font-semibold text-foreground`,children:r(`comparePicker.title`)}),(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:r(`comparePicker.count`,{n:o.length})})]}),(0,Y.jsx)(`div`,{className:`px-4 py-2 border-b border-border/20`,children:(0,Y.jsxs)(`div`,{className:`relative`,children:[(0,Y.jsx)(Us,{className:`absolute left-2 top-1/2 -translate-y-1/2 w-3 h-3 text-muted-foreground`}),(0,Y.jsx)(`input`,{type:`text`,value:i,onChange:e=>a(e.target.value),placeholder:r(`comparePicker.searchPlaceholder`),className:`w-full h-7 rounded border border-border bg-input pl-7 pr-2 text-[11px] text-foreground placeholder:text-muted-foreground outline-none focus:border-accent-primary/60`})]})}),(0,Y.jsx)(`div`,{className:`flex-1 overflow-y-auto`,"data-testid":`spec-compare-picker-list`,children:o.length===0?(0,Y.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full text-center px-4 py-8 gap-2`,children:[(0,Y.jsx)(oc,{className:`w-6 h-6 text-muted-foreground/40`}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i.trim()?r(`comparePicker.noMatches`):r(`comparePicker.empty`)})]}):(0,Y.jsx)(`ul`,{className:`divide-y divide-border/10`,children:o.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{type:`button`,"data-testid":`spec-compare-card-${e.id}`,onClick:()=>n(e.id),className:`w-full text-left px-4 py-2.5 hover:bg-accent/30 transition-colors flex items-start gap-2 group`,children:[(0,Y.jsx)(ox,{status:e.status}),(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsxs)(`span`,{className:`text-[10px] font-mono text-muted-foreground`,children:[`#`,e.id]}),e.priority&&XV[e.priority]&&(0,Y.jsx)(`span`,{className:`inline-flex items-center rounded px-1 py-0.5 text-[9px] font-medium border ${XV[e.priority]}`,children:r(`priority.${e.priority}`)})]}),(0,Y.jsx)(`p`,{className:`mt-0.5 text-xs text-foreground truncate group-hover:text-accent-primary transition-colors`,children:e.title||r(`untitled`)}),e.description&&(0,Y.jsx)(`p`,{className:`mt-0.5 text-[10px] text-muted-foreground line-clamp-1`,children:e.description.slice(0,120)}),e.labels&&e.labels.length>0&&(0,Y.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-1`,children:[e.labels.slice(0,3).map(e=>(0,Y.jsx)(`span`,{className:`inline-flex items-center rounded px-1 py-0.5 text-[9px] bg-accent/40 text-foreground/60`,children:e},e)),e.labels.length>3&&(0,Y.jsxs)(`span`,{className:`text-[9px] text-muted-foreground`,children:[`+`,e.labels.length-3]})]}),(0,Y.jsx)(`p`,{className:`mt-1 text-[9px] text-muted-foreground`,children:r(`meta.updatedAgo`,{time:ZV(e.updated_at)})})]})]})},e.id))})})]})}var $V=.25,eH=.75;function tH({state:e,leftTicket:t,rightTicket:n,allTickets:r,allLabels:i,onSave:a,onDelete:o,onOpenTicket:s,onCloseAll:c,onSetCompared:l,onSetRatio:u,onExitSplit:d}){let f=(0,H.useRef)(null),p=(0,H.useRef)(null),[m,h]=(0,H.useState)(!0);(0,H.useEffect)(()=>{let e=setTimeout(()=>h(!1),320);return()=>clearTimeout(e)},[]);let g=(0,H.useCallback)(e=>{if(!p.current)return;let t=window.innerWidth,n=e.clientX/t;u(Math.min(eH,Math.max($V,n)))},[u]),_=(0,H.useCallback)(e=>{if(!p.current)return;let{pointerId:t,element:n}=p.current;try{n.releasePointerCapture(t)}catch{}p.current=null,window.removeEventListener(`pointermove`,g),window.removeEventListener(`pointerup`,_),window.removeEventListener(`pointercancel`,_)},[g]),v=(0,H.useCallback)(e=>{let t=e.currentTarget;try{t.setPointerCapture(e.pointerId)}catch{}p.current={pointerId:e.pointerId,element:t},window.addEventListener(`pointermove`,g),window.addEventListener(`pointerup`,_),window.addEventListener(`pointercancel`,_)},[g,_]);(0,H.useEffect)(()=>()=>{window.removeEventListener(`pointermove`,g),window.removeEventListener(`pointerup`,_),window.removeEventListener(`pointercancel`,_);let e=p.current;if(e){try{e.element.releasePointerCapture(e.pointerId)}catch{}p.current=null}},[g,_]);let y=(0,H.useCallback)(t=>{let n=.04;t.key===`ArrowLeft`?(t.preventDefault(),u(Math.max($V,e.splitRatio-n))):t.key===`ArrowRight`?(t.preventDefault(),u(Math.min(eH,e.splitRatio+n))):t.key===`Home`?(t.preventDefault(),u($V)):t.key===`End`?(t.preventDefault(),u(eH)):t.key===`0`&&(t.preventDefault(),u(.5))},[u,e.splitRatio]),b=e=>{e.target===e.currentTarget&&c()},x=u=>{let d=u===e.originSide,f=u===`left`?t:n;return f?(0,Y.jsx)(tU,{ticket:f,allLabels:i,allTickets:r,onClose:d?c:()=>l(null,u),onOpenTicket:s,onSave:a,onDelete:o,embedded:!0},`${u}-${f.id}`):(0,Y.jsx)(QV,{tickets:r,excludeIds:[t?.id,n?.id].filter(e=>e!=null),onSelect:e=>l(e,u)})},S=(e.splitRatio*100).toFixed(2),C=((1-e.splitRatio)*100).toFixed(2);return(0,Y.jsxs)(`div`,{ref:f,"data-testid":`split-view-shell`,className:`fixed inset-0 z-[68] flex`,onClick:b,children:[(0,Y.jsx)(`div`,{className:`absolute inset-0 bg-black/70 pointer-events-none`,"aria-hidden":!0}),(0,Y.jsxs)(`div`,{className:`relative flex w-full h-full`,style:{transition:m?`opacity 280ms cubic-bezier(0.34, 1.56, 0.64, 1)`:void 0},children:[(0,Y.jsx)(`div`,{"data-testid":`split-panel-left`,className:`relative h-full overflow-hidden`,style:{width:`${S}%`,transition:m?`width 280ms cubic-bezier(0.34, 1.56, 0.64, 1)`:void 0},children:(0,Y.jsx)(`div`,{className:`h-full flex items-center justify-center p-2`,children:(0,Y.jsx)(`div`,{className:`w-full h-full max-h-[95vh]`,children:x(`left`)})})}),(0,Y.jsx)(`div`,{"data-testid":`split-divider`,role:`separator`,"aria-orientation":`vertical`,"aria-valuenow":Math.round(e.splitRatio*100),"aria-valuemin":Math.round($V*100),"aria-valuemax":Math.round(eH*100),tabIndex:0,onPointerDown:v,onKeyDown:y,className:`relative z-10 w-2 cursor-col-resize bg-border/40 hover:bg-accent-primary/40 transition-colors focus:outline-none focus:bg-accent-primary/60`}),(0,Y.jsx)(`div`,{"data-testid":`split-panel-right`,className:`relative h-full overflow-hidden`,style:{width:`${C}%`,transition:m?`width 280ms cubic-bezier(0.34, 1.56, 0.64, 1)`:void 0},children:(0,Y.jsx)(`div`,{className:`h-full flex items-center justify-center p-2`,children:(0,Y.jsx)(`div`,{className:`w-full h-full max-h-[95vh]`,children:x(`right`)})})})]})]})}var nH=.5,rH=.25,iH=.75,aH={leftId:null,rightId:null,originSide:null,splitRatio:nH};function oH(e){return Number.isFinite(e)?Math.min(iH,Math.max(rH,e)):nH}function sH(e,t){switch(t.type){case`openCentered`:return e.originSide!==null&&e.leftId!==t.id&&e.rightId!==t.id?{leftId:t.id,rightId:null,originSide:null,splitRatio:nH}:e.originSide!==null&&(e.leftId===t.id||e.rightId===t.id)?e:{...aH,leftId:t.id};case`closeAll`:return aH;case`enterSplit`:{let n=t.ticketId??e.leftId;return n===null||e.originSide!==null?e:t.side===`left`?{leftId:n,rightId:null,originSide:`left`,splitRatio:nH}:{leftId:null,rightId:n,originSide:`right`,splitRatio:nH}}case`setComparedTicket`:{if(e.originSide===null)return e;let n=e.originSide===`left`?`right`:`left`;return t.side===n?t.side===`left`?{...e,leftId:t.id}:{...e,rightId:t.id}:e}case`exitSplit`:{if(e.originSide===null)return e;let t=e.originSide===`left`?e.leftId:e.rightId;return{...aH,leftId:t}}case`setSplitRatio`:return{...e,splitRatio:oH(t.ratio)};default:return e}}var cH=(0,H.createContext)(null),lH=900;function uH({children:e}){let[t,n]=(0,H.useReducer)(sH,aH),{tickets:r,updateTicket:i,deleteTicket:a}=Em(),{activeProjectId:o,setActiveProjectId:s}=gm(),c=(0,H.useRef)(null);(0,H.useEffect)(()=>{n({type:`closeAll`});let e=c.current;e&&(c.current=null,e.projectId===o&&n({type:`openCentered`,id:e.ticketId}))},[o]);let l=(0,H.useCallback)(e=>n({type:`openCentered`,id:e}),[]),u=(0,H.useCallback)((e,t)=>{if(e===o){n({type:`openCentered`,id:t});return}c.current={projectId:e,ticketId:t},s(e)},[o,s]),d=(0,H.useCallback)(()=>n({type:`closeAll`}),[]),f=(0,H.useCallback)((e,t)=>n({type:`enterSplit`,side:e,ticketId:t}),[]),p=(0,H.useCallback)((e,t)=>n({type:`setComparedTicket`,id:e,side:t}),[]),m=(0,H.useCallback)(()=>n({type:`exitSplit`}),[]),h=(0,H.useCallback)(e=>n({type:`setSplitRatio`,ratio:e}),[]);(0,H.useEffect)(()=>{if(typeof window>`u`)return;function e(){window.innerWidth<lH&&n({type:`exitSplit`})}return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let g=(0,H.useMemo)(()=>{let e=new Set;for(let t of r)for(let n of t.labels??[])e.add(n);return Array.from(e).sort()},[r]),_=t.leftId==null?null:r.find(e=>e.id===t.leftId)??null,v=t.rightId==null?null:r.find(e=>e.id===t.rightId)??null,y=(0,H.useMemo)(()=>({openTicketDetail:l,openTicketDetailInProject:u,closeTicketDetail:d,enterSplit:f,setComparedTicket:p,exitSplit:m,setSplitRatio:h,state:t}),[l,u,d,f,p,m,h,t]),b=t.originSide!==null;return(0,Y.jsxs)(cH.Provider,{value:y,children:[e,!b&&_&&(0,Y.jsx)(tU,{ticket:_,allLabels:g,allTickets:r,onClose:d,onOpenTicket:l,onSave:i,onDelete:e=>{a(e),d()}},_.id),b&&(0,Y.jsx)(tH,{state:t,leftTicket:_,rightTicket:v,allTickets:r,allLabels:g,onSave:i,onDelete:e=>{a(e),d()},onOpenTicket:l,onCloseAll:d,onSetCompared:p,onSetRatio:h,onExitSplit:m})]})}function dH(){return(0,H.useContext)(cH)||{openTicketDetail:()=>{typeof console<`u`&&console.warn(`[TicketDetailModalContext] openTicketDetail called without provider`)},openTicketDetailInProject:()=>{typeof console<`u`&&console.warn(`[TicketDetailModalContext] openTicketDetailInProject called without provider`)},closeTicketDetail:()=>{},enterSplit:()=>{},setComparedTicket:()=>{},exitSplit:()=>{},setSplitRatio:()=>{},state:aH}}var fH={job:`analytics:surfaces.job`,"quick-spec":`analytics:surfaces.quickSpec`,"explore-spec":`analytics:surfaces.exploreSpec`,"ai-edit":`analytics:surfaces.aiEdit`,smash:`analytics:surfaces.smash`,"file-summary":`analytics:surfaces.fileSummary`,loop:`analytics:surfaces.loop`,"chat-sidebar":`analytics:surfaces.chatSidebar`,"spec-launcher":`analytics:surfaces.specLauncher`,proposal:`analytics:surfaces.proposal`,"agent-studio":`analytics:surfaces.agentStudio`,setup:`analytics:surfaces.setup`},pH={bg:`bg-muted/40`,text:`text-muted-foreground`,ring:`ring-border/40`,dot:`bg-muted-foreground`},mH={job:{bg:`bg-accent-info/15`,text:`text-accent-info`,ring:`ring-accent-info/40`,dot:`bg-accent-info`},"quick-spec":{bg:`bg-accent-secondary/15`,text:`text-accent-secondary`,ring:`ring-accent-secondary/40`,dot:`bg-accent-secondary`},"explore-spec":{bg:`bg-accent-highlight/15`,text:`text-accent-highlight`,ring:`ring-accent-highlight/40`,dot:`bg-accent-highlight`},"ai-edit":{bg:`bg-accent-success/15`,text:`text-accent-success`,ring:`ring-accent-success/40`,dot:`bg-accent-success`},smash:{bg:`bg-accent-highlight/15`,text:`text-accent-highlight`,ring:`ring-accent-highlight/40`,dot:`bg-accent-highlight`},"file-summary":{bg:`bg-accent-warning/15`,text:`text-accent-warning`,ring:`ring-accent-warning/40`,dot:`bg-accent-warning`},loop:{bg:`bg-accent-primary/15`,text:`text-accent-primary`,ring:`ring-accent-primary/40`,dot:`bg-accent-primary`},"chat-sidebar":{bg:`bg-accent-info/15`,text:`text-accent-info`,ring:`ring-accent-info/40`,dot:`bg-accent-info`},"spec-launcher":{bg:`bg-accent-secondary/15`,text:`text-accent-secondary`,ring:`ring-accent-secondary/40`,dot:`bg-accent-secondary`},proposal:{bg:`bg-accent-highlight/15`,text:`text-accent-highlight`,ring:`ring-accent-highlight/40`,dot:`bg-accent-highlight`},"agent-studio":{bg:`bg-accent-success/15`,text:`text-accent-success`,ring:`ring-accent-success/40`,dot:`bg-accent-success`},setup:{bg:`bg-accent-primary/15`,text:`text-accent-primary`,ring:`ring-accent-primary/40`,dot:`bg-accent-primary`}};function hH(e,t){return new Proxy(e,{get(e,n,r){return typeof n==`string`&&!(n in e)?t(n):Reflect.get(e,n,r)}})}var gH=hH(Object.defineProperties({},Object.fromEntries(Object.keys(fH).map(e=>[e,{get:()=>am.t(fH[e]),enumerable:!0}]))),e=>e),_H=hH(mH,()=>pH);function vH(e){return e<.005?`$${e.toFixed(4)}`:e<1?`$${e.toFixed(3)}`:`$${e.toFixed(2)}`}function yH(e){return e<1e3?`${e} ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${Math.floor(e/6e4)}m ${Math.floor(e%6e4/1e3)}s`}function bH({ticketId:e}){let{t}=K(`tickets`),[n,r]=(0,H.useState)(null),i=_t(),{activeProjectId:a}=gm(),{closeTicketDetail:o}=dH();if((0,H.useEffect)(()=>{let t=new AbortController;return r(null),fetch(`${af()}/tickets/${e}/spending-summary`,{signal:t.signal}).then(e=>e.ok?e.json():null).then(e=>{e&&r(e)}).catch(()=>{}),()=>t.abort()},[e,a]),!n||!n.bySurface||!n.totalRuns||n.totalRuns===0)return null;let s=Object.entries(n.bySurface).filter(([,e])=>e.count>0).map(([e,n])=>t(`spendingLine.breakdownItem`,{n:n.count,label:gH[e].toLowerCase()})).join(` + `);return(0,Y.jsxs)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),o(),i(`/analytics?ticketId=${e}`)},className:`mt-1.5 group inline-flex items-center gap-1.5 text-[11px] text-muted-foreground hover:text-foreground transition-colors cursor-pointer`,"aria-label":t(`spendingLine.ariaLabel`),children:[(0,Y.jsxs)(`span`,{className:`tabular-nums font-medium text-foreground`,title:(n.estimatedCostUsd??0)>0?t(`spendingLine.estimatedTooltip`):void 0,children:[(n.estimatedCostUsd??0)>0?`~`:``,vH(n.totalCostUsd)]}),(0,Y.jsx)(`span`,{className:`text-muted-foreground/60`,children:`·`}),(0,Y.jsx)(`span`,{className:`tabular-nums`,children:t(`spendingLine.turns`,{count:n.totalTurns})}),(0,Y.jsx)(`span`,{className:`text-muted-foreground/60`,children:`·`}),(0,Y.jsx)(`span`,{className:`tabular-nums`,children:t(`spendingLine.active`,{duration:yH(n.activeDurationMs)})}),s&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground/60`,children:`·`}),(0,Y.jsx)(`span`,{children:s})]}),(0,Y.jsx)(Va,{className:`w-3 h-3 opacity-0 group-hover:opacity-100 transition-opacity`})]})}var xH=/^\d{4}-\d{2}-\d{2}T/;function SH(e){if(xH.test(e))try{return{text:vV(yV(e),{addSuffix:!0,locale:im()}),title:e}}catch{}return{text:e}}function CH({localId:e}){let{t}=K(`jira`),{activeProjectId:n}=gm(),r=Wb(),[i,a]=(0,H.useState)(null);if((0,H.useEffect)(()=>{if(!Fb||!r.connected)return;let t=!1;return a(null),Ub.getSpecDetails(e).then(e=>{t||a(e)}).catch(()=>{t||a(null)}),()=>{t=!0}},[e,n,r.connected]),!Fb||!r.connected||!i)return null;let o=i.development,s=i.fields.length>0,c=o.pullRequests.length>0,l=o.branches.length>0,u=(o.commits?.length??0)>0;return!s&&!c&&!l&&!u?null:(0,Y.jsxs)(`div`,{className:`space-y-4`,"data-testid":`jira-details-panel`,children:[s&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1.5`,children:t(`detail.detailsTitle`)}),(0,Y.jsx)(`div`,{className:`space-y-1.5`,children:i.fields.map((e,t)=>{let n=SH(e.value);return(0,Y.jsxs)(`div`,{className:`text-xs`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground uppercase tracking-wide block`,children:e.label}),e.href?(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{HV(e.href)},className:`inline-flex items-center gap-1 text-accent-info hover:underline text-left`,children:[(0,Y.jsx)(`span`,{className:`truncate`,children:e.value}),(0,Y.jsx)(Oo,{className:`w-3 h-3 shrink-0`})]}):(0,Y.jsx)(`span`,{className:`text-foreground/80 whitespace-pre-line`,title:n.title,children:n.text})]},`${e.label}-${t}`)})})]}),(c||l||u)&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1.5`,children:t(`detail.developmentTitle`)}),c&&(0,Y.jsxs)(`div`,{className:`mb-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground uppercase tracking-wide block mb-1`,children:t(`detail.dev.pullRequests`)}),(0,Y.jsx)(`div`,{className:`space-y-1`,children:o.pullRequests.map(e=>(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{HV(e.url)},className:`w-full flex items-start gap-1.5 text-left text-xs hover:bg-accent-info/10 rounded px-1 py-0.5`,"data-testid":`jira-dev-pr`,children:[(0,Y.jsx)(Go,{className:`w-3 h-3 mt-0.5 shrink-0 text-accent-info`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`truncate text-foreground/80 block`,children:e.title}),(0,Y.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[e.status,e.sourceBranch?` · ${e.sourceBranch} → ${e.destBranch??``}`:``]})]})]},e.url))})]}),l&&(0,Y.jsxs)(`div`,{className:`mb-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground uppercase tracking-wide block mb-1`,children:t(`detail.dev.branches`)}),(0,Y.jsx)(`div`,{className:`space-y-1`,children:o.branches.map(e=>(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{HV(e.url)},className:`w-full flex items-center gap-1.5 text-left text-xs hover:bg-accent-info/10 rounded px-1 py-0.5`,"data-testid":`jira-dev-branch`,children:[(0,Y.jsx)(Ho,{className:`w-3 h-3 shrink-0 text-accent-info`}),(0,Y.jsx)(`span`,{className:`truncate font-mono text-foreground/80`,children:e.name}),e.repo&&(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground truncate`,children:e.repo})]},e.url))})]}),u&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground uppercase tracking-wide block mb-1`,children:t(`detail.dev.commits`)}),(0,Y.jsx)(`div`,{className:`space-y-1`,children:o.commits.map(e=>(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{HV(e.url)},className:`w-full flex items-center gap-1.5 text-left text-xs hover:bg-accent-info/10 rounded px-1 py-0.5`,"data-testid":`jira-dev-commit`,children:[(0,Y.jsx)(Uo,{className:`w-3 h-3 shrink-0 text-accent-info`}),(0,Y.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground shrink-0`,children:e.displayId}),(0,Y.jsx)(`span`,{className:`truncate text-foreground/80`,children:e.message})]},e.url))})]})]})]})}function wH({open:e,url:t,projectId:n,onClose:r}){let{t:i}=K(`browser`),a=ZO({projectId:n,open:e,initialUrl:t}),{canvasRef:o,viewport:s,status:c,errorMsg:l,url:u,title:d,popup:f}=a,[p,m]=(0,H.useState)(t),h=(0,H.useRef)(a.forwardInput);h.current=a.forwardInput;let g=(0,H.useRef)(null),_=(0,H.useCallback)(()=>(g.current??=zO(e=>h.current(e)),g.current),[]);(0,H.useEffect)(()=>()=>{g.current?.dispose(),g.current=null},[]),(0,H.useEffect)(()=>{u&&m(u)},[u]),(0,H.useEffect)(()=>{if(!e)return;let t=e=>{e.key===`Escape`&&r()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e,r]);let v=(0,H.useCallback)((e,t)=>{let n=o.current?.getBoundingClientRect();return n?BO({x:e,y:t},{left:n.left,top:n.top,width:n.width,height:n.height},s):{x:0,y:0}},[o,s]),y=e=>e===2?`right`:e===1?`middle`:`left`,b=(0,H.useCallback)(e=>{let t=v(e.clientX,e.clientY);_().move(t.x,t.y)},[v,_]),x=(0,H.useCallback)(e=>{let t=v(e.clientX,e.clientY),n=_();n.move(t.x,t.y),n.flush(),a.forwardInput({type:`mouse`,action:`down`,x:t.x,y:t.y,button:y(e.button),clickCount:e.detail||1})},[v,a,_]),S=(0,H.useCallback)(e=>{let t=v(e.clientX,e.clientY),n=_();n.move(t.x,t.y),n.flush(),a.forwardInput({type:`mouse`,action:`up`,x:t.x,y:t.y,button:y(e.button),clickCount:e.detail||1})},[v,a,_]),C=(0,H.useCallback)(e=>{let t=v(e.clientX,e.clientY);_().wheel(t.x,t.y,e.deltaX,e.deltaY)},[v,_]),w=(0,H.useCallback)(e=>{if(e.key===`Escape`)return;let t=e.metaKey||e.ctrlKey;if(t&&(e.key===`c`||e.key===`v`||e.key===`x`)){e.preventDefault();let t=e.key;(async()=>{try{if(t===`v`){let e=await navigator.clipboard.readText();e&&await a.clipboard(`paste`,e)}else{let{text:e}=await a.clipboard(t===`x`?`cut`:`copy`);e&&await navigator.clipboard.writeText(e)}}catch{}})();return}let n={type:`key`,action:`down`,key:e.key,code:e.code,text:!t&&e.key.length===1?e.key:void 0};a.forwardInput(n),(e.key===`Tab`||e.key===` `||e.key.startsWith(`Arrow`))&&e.preventDefault()},[a]),T=(0,H.useCallback)(e=>{e.key!==`Escape`&&a.forwardInput({type:`key`,action:`up`,key:e.key,code:e.code})},[a]),E=(0,H.useCallback)(()=>{a.navigate(`goto`,p)},[a,p]);return!e||typeof document>`u`?null:(0,sr.createPortal)((0,Y.jsx)(`div`,{className:`fixed inset-0 z-[80] bg-background-deep/50 backdrop-blur-sm pointer-events-auto`,onClick:e=>{e.target===e.currentTarget&&r()},"data-testid":`webview-modal`,children:(0,Y.jsxs)(`div`,{className:`absolute inset-2 flex flex-col border border-border rounded-lg bg-background-deep overflow-hidden`,role:`dialog`,"aria-modal":`true`,"aria-label":i(`modal.dialogLabel`),onClick:e=>e.stopPropagation(),children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 border-b border-border/50 bg-surface/80 shrink-0`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":i(`common:actions.back`),onClick:()=>a.navigate(`back`),children:(0,Y.jsx)(Ba,{className:`w-4 h-4`})}),(0,Y.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":i(`modal.nav.forward`),onClick:()=>a.navigate(`forward`),children:(0,Y.jsx)(Va,{className:`w-4 h-4`})}),(0,Y.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":i(`modal.nav.reload`),onClick:()=>a.navigate(`reload`),children:(0,Y.jsx)(zs,{className:`w-4 h-4`})})]}),(0,Y.jsxs)(`form`,{className:`flex-1 flex items-center gap-2 min-w-0`,onSubmit:e=>{e.preventDefault(),E()},children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 flex-1 min-w-0 rounded-md border border-border bg-background px-2.5 py-1`,children:[(0,Y.jsx)(Ko,{className:`w-3.5 h-3.5 text-muted-foreground shrink-0`}),(0,Y.jsx)(`input`,{value:p,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),E())},placeholder:i(`modal.address.placeholder`),"aria-label":i(`modal.address.label`),className:`flex-1 min-w-0 bg-transparent outline-none text-sm`})]}),(0,Y.jsx)(Z,{type:`submit`,size:`sm`,variant:`secondary`,className:`shrink-0`,disabled:c===`error`,children:i(`modal.address.go`)})]}),(0,Y.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":i(`modal.closeBrowser`),onClick:r,children:(0,Y.jsx)(hc,{className:`w-4 h-4`})})]}),(0,Y.jsxs)(`div`,{className:`px-3 py-1 text-[11px] text-muted-foreground truncate shrink-0 flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-full shrink-0 ${c===`ready`?`bg-accent-success`:c===`error`?`bg-destructive`:`bg-accent-warning animate-pulse`}`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`truncate`,children:c===`connecting`?i(`modal.status.connecting`):c===`error`?l??i(`modal.status.unavailable`):d||``})]}),f&&(0,Y.jsxs)(`div`,{"data-testid":`webview-popup-bar`,className:`flex items-center gap-2 px-3 py-1.5 text-xs border-b shrink-0 ${f.active?`bg-accent-info/10 border-accent-info/30 text-accent-info`:`bg-surface/70 border-border/40 text-muted-foreground`}`,children:[(0,Y.jsx)(Oo,{className:`w-3.5 h-3.5 shrink-0`}),f.active?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`truncate font-medium`,children:i(`popup.loginWindow`,{origin:FO(f.url)})}),f.count>1&&(0,Y.jsx)(`span`,{className:`shrink-0 opacity-70`,children:i(`popup.stacked`,{count:f.count-1})}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>a.setPopupView(`root`),className:`ml-auto shrink-0 inline-flex items-center gap-1 h-6 px-2 rounded-md border border-current/30 hover:bg-card/60 transition-colors`,children:[(0,Y.jsx)(Ba,{className:`w-3 h-3`}),i(`popup.backToPage`)]})]}):(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>a.setPopupView(`popup`),className:`inline-flex items-center gap-1 h-6 px-2 rounded-md border border-border/50 hover:bg-card/60 hover:text-foreground transition-colors`,children:[i(`popup.show`),f.count>1&&(0,Y.jsx)(`span`,{className:`opacity-70`,children:i(`popup.stacked`,{count:f.count-1})})]})]}),(0,Y.jsx)(`div`,{className:`relative flex-1 min-h-0 overflow-hidden flex items-center justify-center outline-none`,tabIndex:0,onKeyDown:w,onKeyUp:T,children:c===`error`?(0,Y.jsxs)(`div`,{className:`flex flex-col items-center gap-2 text-center max-w-md px-6`,children:[(0,Y.jsx)(lc,{className:`w-8 h-8 text-accent-warning`}),(0,Y.jsx)(`p`,{className:`text-sm text-foreground/90`,children:l??i(`modal.error.unavailable`)})]}):(0,Y.jsx)(`canvas`,{ref:o,className:`max-w-full max-h-full block shadow-2xl cursor-default`,onPointerMove:b,onPointerDown:x,onPointerUp:S,onContextMenu:e=>e.preventDefault(),onWheel:C})})]})}),document.body)}var TH=(0,H.createContext)(null);function EH({children:e}){let{activeProjectId:t}=gm(),[n,r]=(0,H.useState)(null),i=(0,H.useCallback)(e=>r(e),[]),a=SO();return(0,Y.jsxs)(TH.Provider,{value:{openWebView:i,canOpenWebView:a&&!!t},children:[e,a&&n&&t&&(0,Y.jsx)(wH,{open:!0,url:n,projectId:t,onClose:()=>r(null)})]})}function DH(){return(0,H.useContext)(TH)??{openWebView:()=>{},canOpenWebView:!1}}var OH={analyzing:`activity:smash.stage.analyzing`,identifying:`activity:smash.stage.identifying`,ordering:`activity:smash.stage.ordering`},kH=(0,H.createContext)(null);function AH(e){return`smash:${e}`}async function jH(e,t){try{let n=await fetch(`${o}/api/projects/${e}/tickets/${t}/smash`,{method:`POST`});if(n.ok)q.loading(am.t(`activity:smash.retrying`),{id:AH(t)});else{let e=await n.json().catch(()=>({}));q.error(e.reason?am.t(`activity:smash.couldNotRetryWithReason`,{reason:e.reason}):am.t(`activity:smash.couldNotRetry`),{id:AH(t)})}}catch(e){q.error(am.t(`activity:smash.retryFailed`,{message:e.message}),{id:AH(t)})}}async function MH(e,t,n){try{let r=await fetch(`${o}/api/projects/${e}/tickets/${t}/smash/undo`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({smashedAt:n})});if(r.ok)q.success(am.t(`activity:smash.undone`),{id:AH(t),duration:3e3});else{let e=await r.json().catch(()=>({}));q.error(e.reason?am.t(`activity:smash.undoFailedWithReason`,{reason:e.reason}):am.t(`activity:smash.undoFailed`),{id:AH(t)})}}catch(e){q.error(am.t(`activity:smash.undoFailedWithReason`,{reason:e.message}),{id:AH(t)})}}function NH({children:e}){let{registerHandler:t,unregisterHandler:n}=df(),[r,i]=(0,H.useState)({}),a=(0,H.useRef)(new Map),o=(0,H.useRef)(new Map),s=(0,H.useCallback)(e=>{let t=e;if(!t||t.type!==`smash.started`)return;let n=t.ticketId,r=t.runId,o=t.projectId,s=t.timestamp,c=t.ticketTitle;typeof n!=`number`||!r||!o||(a.current.set(n,o),i(e=>({...e,[n]:{ticketId:n,runId:r,stage:`analyzing`,startedAt:s??new Date().toISOString(),ticketTitle:c}})),q.loading(am.t(OH.analyzing),{id:AH(n),description:c?am.t(`activity:smash.onTitled`,{title:c}):am.t(`activity:smash.onThisSpec`)}))},[]),c=(0,H.useCallback)(e=>{let t=e;if(!t||t.type!==`smash.progress`)return;let n=t.ticketId,r=t.stage;if(typeof n!=`number`||!r)return;let a;i(e=>{let t=e[n];return t?(a=t.ticketTitle,{...e,[n]:{...t,stage:r}}):e}),q.loading(am.t(OH[r]),{id:AH(n),description:a?am.t(`activity:smash.onTitled`,{title:a}):am.t(`activity:smash.onThisSpec`)})},[]),l=(0,H.useCallback)(e=>{let t=e;if(!t||t.type!==`smash.completed`)return;let n=t.ticketId,r=t.runId,a=t.projectId,s=t.smashedAt,c=t.childrenIds;typeof n!=`number`||!r||!a||!s||!c||(o.current.set(r,s),i(e=>{let t={...e};return delete t[n],t}),q.success(am.t(`activity:smash.split`,{count:c.length}),{id:AH(n),duration:1e4,action:{label:am.t(`activity:smash.undoAction`),onClick:()=>void MH(a,n,s)}}))},[]),u=(0,H.useCallback)(e=>{let t=e;if(!t||t.type!==`smash.failed`)return;let n=t.ticketId,r=t.projectId,o=t.reason??`unknown`;if(typeof n!=`number`||!r)return;a.current.set(n,r),i(e=>{let t={...e};return delete t[n],t});let s=o===`invalid-output`?am.t(`activity:smash.failReason.invalidOutput`):o===`timeout`?am.t(`activity:smash.failReason.timeout`):o===`model_error`?am.t(`activity:smash.failReason.modelError`):o===`crashed`?am.t(`activity:smash.failReason.crashed`):am.t(`activity:smash.failReason.generic`,{reason:o});q.error(am.t(`activity:smash.couldNotComplete`),{id:AH(n),description:s,action:{label:am.t(`common:actions.retry`),onClick:()=>void jH(r,n)},duration:15e3})},[]),d=(0,H.useCallback)(e=>{let t=e;if(!t||t.type!==`smash.undone`)return;let n=t.ticketId;typeof n==`number`&&(q.dismiss(AH(n)),q.success(am.t(`activity:smash.undone`),{id:AH(n),duration:3e3}))},[]);(0,H.useLayoutEffect)(()=>(t(`_smash_started`,s),t(`_smash_progress`,c),t(`_smash_completed`,l),t(`_smash_failed`,u),t(`_smash_undone`,d),()=>{n(`_smash_started`),n(`_smash_progress`),n(`_smash_completed`),n(`_smash_failed`),n(`_smash_undone`)}),[t,n,s,c,l,u,d]),(0,H.useEffect)(()=>()=>{a.current.clear(),o.current.clear()},[]);let f=(0,H.useMemo)(()=>({inflight:r}),[r]);return(0,Y.jsx)(kH.Provider,{value:f,children:e})}function PH(e){let t=(0,H.useContext)(kH);return!t||e==null?null:t.inflight[e]??null}var FH=150,IH={analyzing:0,identifying:1,ordering:2},LH={analyzing:`smash.stage.analyzing`,identifying:`smash.stage.identifying`,ordering:`smash.stage.ordering`};function RH({stage:e,minDisplayMs:t=FH}){let{t:n}=K(`activity`),[r,i]=(0,H.useState)(e),a=(0,H.useRef)(Date.now()),o=(0,H.useRef)(null);if((0,H.useEffect)(()=>{if(e===r)return;let n=Date.now()-a.current,s=Math.max(0,t-n);return o.current&&clearTimeout(o.current),o.current=setTimeout(()=>{i(e),a.current=Date.now(),o.current=null},s),()=>{o.current&&clearTimeout(o.current)}},[e,r,t]),!r)return null;let s=IH[r];return(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 rounded-md border border-accent-highlight/40 bg-accent-highlight/10 text-sm text-foreground`,role:`status`,"aria-live":`polite`,"data-testid":`smash-status-pills`,children:[(0,Y.jsx)(cs,{className:`h-4 w-4 animate-spin text-accent-highlight`,"aria-hidden":!0}),(0,Y.jsx)(`div`,{className:`flex items-center gap-1.5`,children:[`analyzing`,`identifying`,`ordering`].map(e=>(0,Y.jsx)(`span`,{className:[`inline-block w-1.5 h-1.5 rounded-full transition-all`,IH[e]<=s?`bg-accent-highlight`:`bg-muted`,e===r?`scale-125`:`scale-100`].join(` `),"aria-hidden":!0},e))}),(0,Y.jsx)(`span`,{className:`font-medium`,children:n(LH[r])})]})}var zH={simple:{titleKey:`smashModal.modes.simple.title`,bulletKeys:[`smashModal.modes.simple.bullet1`,`smashModal.modes.simple.bullet2`,`smashModal.modes.simple.bullet3`],etaKey:`smashModal.modes.simple.eta`},full:{titleKey:`smashModal.modes.full.title`,bulletKeys:[`smashModal.modes.full.bullet1`,`smashModal.modes.full.bullet2`,`smashModal.modes.full.bullet3`,`smashModal.modes.full.bullet4`],etaKey:`smashModal.modes.full.eta`}};function BH({open:e,ticketTitle:t,isReSmash:n,childrenCount:r,submitting:i=!1,onCancel:a,onConfirm:o}){let{t:s}=K(`activity`),[c,l]=(0,H.useState)(`simple`),{panelRef:u,panelStyle:d,headerHandleProps:f,resizeHandles:p,isFloating:m,guardBackdrop:h}=yb();return e?(0,Y.jsxs)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center`,role:`dialog`,"aria-modal":`true`,"data-testid":`smash-confirm-modal`,children:[(0,Y.jsx)(`div`,{className:`absolute inset-0 bg-black/60 backdrop-blur-sm`,onClick:h(a)}),(0,Y.jsxs)(`div`,{ref:u,className:`relative w-full max-w-lg m-4 rounded-xl glass-card border border-border/30 animate-in fade-in zoom-in-95 duration-150`,style:d,children:[(0,Y.jsxs)(`div`,{...f,className:`flex items-start justify-between gap-3 px-5 py-4 border-b border-border/30 ${m?`cursor-grab active:cursor-grabbing`:``}`,children:[(0,Y.jsxs)(`div`,{className:`flex items-start gap-2 min-w-0`,children:[(0,Y.jsx)($s,{className:`w-5 h-5 text-accent-highlight shrink-0 mt-0.5`,"aria-hidden":!0}),(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:s(`smashModal.title`)}),(0,Y.jsx)(`p`,{className:`text-[11px] text-muted-foreground truncate`,title:t,children:t})]})]}),(0,Y.jsx)(`button`,{type:`button`,onClick:a,className:`h-7 w-7 flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-surface/50 transition-colors shrink-0`,"aria-label":s(`common:actions.close`),children:(0,Y.jsx)(hc,{className:`w-4 h-4`})})]}),n&&r>0&&(0,Y.jsx)(`div`,{className:`mx-5 mt-4 rounded-md border border-accent-warning/40 bg-accent-warning/10 px-3 py-2 text-xs text-foreground`,children:(0,Y.jsx)(Yi,{t:s,i18nKey:`smashModal.reSmashWarning`,count:r})}),(0,Y.jsxs)(`div`,{className:`px-5 py-4 space-y-3`,children:[(0,Y.jsx)(`p`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground font-medium`,children:s(`smashModal.modePickerLabel`)}),[`simple`,`full`].map(e=>{let t=zH[e],n=c===e;return(0,Y.jsx)(`button`,{type:`button`,onClick:()=>l(e),disabled:i,className:`w-full text-left rounded-lg border px-3 py-3 transition-colors ${n?`border-accent-highlight/60 bg-accent-highlight/10`:`border-border/40 bg-card/40 hover:bg-card/60 hover:border-border/60`}`,"data-testid":`smash-mode-${e}`,children:(0,Y.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Y.jsx)(`div`,{className:`mt-0.5 h-3.5 w-3.5 rounded-full border-2 shrink-0 ${n?`border-accent-highlight bg-accent-highlight`:`border-muted-foreground/60`}`,"aria-hidden":!0}),(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mb-1`,children:[(0,Y.jsxs)(`span`,{className:`flex items-center gap-1.5 text-sm font-semibold text-foreground`,children:[e===`full`&&(0,Y.jsx)(gc,{className:`w-3.5 h-3.5 text-accent-highlight`,"aria-hidden":!0}),s(t.titleKey)]}),(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:s(t.etaKey)})]}),(0,Y.jsx)(`ul`,{className:`space-y-0.5`,children:t.bulletKeys.map(e=>(0,Y.jsxs)(`li`,{className:`text-[11px] text-foreground/70 leading-snug`,children:[`• `,s(e)]},e))})]})]})},e)})]}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-end gap-2 px-5 py-3 border-t border-border/30 bg-surface/20`,children:[(0,Y.jsx)(Z,{variant:`ghost`,size:`sm`,onClick:a,disabled:i,children:s(`common:actions.cancel`)}),(0,Y.jsxs)(Z,{size:`sm`,onClick:()=>o(c),disabled:i,"data-testid":`smash-confirm-modal-continue`,children:[(0,Y.jsx)($s,{className:`w-3.5 h-3.5 mr-1.5`}),s(i?`smashModal.starting`:n?`smashModal.confirmReSmash`:`smashModal.smash`)]})]})]}),(0,Y.jsx)(xb,{handles:p})]}):null}var VH=`## Contract Layer`;function HH(e,t){return!(!t||e.status===`draft`||e.parent_epic_id!=null||!e.description?.includes(VH))}function UH({ticket:e,projectId:t,featureFlagOn:n,childrenCount:r}){let{t:i}=K(`activity`),a=PH(e.id),[s,c]=(0,H.useState)(!1),[l,u]=(0,H.useState)(!1),d=e.is_epic===!0,f=!d&&HH(e,n),p=d&&n,m=d&&r>0,h=(0,H.useCallback)(async n=>{u(!0);try{let r=await fetch(`${o}/api/projects/${t}/tickets/${e.id}/smash`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({mode:n})});if(!r.ok){let e=await r.json().catch(()=>({}));q.error(e.reason?i(`smash.couldNotStartWithReason`,{reason:e.reason}):i(`smash.couldNotStart`));return}c(!1)}catch(e){q.error(i(`smash.smashFailed`,{message:e.message}))}finally{u(!1)}},[t,e.id,i]),g=(0,H.useCallback)(async n=>{if(m){u(!0);try{if(!(await fetch(`${o}/api/projects/${t}/tickets/${e.id}/children`,{method:`DELETE`})).ok){q.error(i(`smash.couldNotDeleteChildren`)),u(!1);return}}catch(e){q.error(i(`smash.deleteFailed`,{message:e.message})),u(!1);return}}await h(n)},[m,h,t,e.id,i]);return!f&&!p?null:a?(0,Y.jsx)(`div`,{className:`flex flex-col gap-2`,"data-testid":`smash-actions-streaming`,children:(0,Y.jsx)(RH,{stage:a.stage})}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(Z,{size:`sm`,variant:`outline`,onClick:()=>c(!0),className:`border-accent-highlight/40 text-accent-highlight hover:bg-accent-highlight/10`,"data-testid":p?`resmash-button`:`smash-button`,children:[(0,Y.jsx)($s,{className:`w-3.5 h-3.5 mr-1.5`}),i(p?`smash.reSmashButton`:`smash.smashButton`)]}),(0,Y.jsx)(BH,{open:s,ticketTitle:e.title,isReSmash:m,childrenCount:r,submitting:l,onCancel:()=>c(!1),onConfirm:g})]})}function WH({epic:e,childExecutionOrder:t,totalChildren:n,onOpenEpic:r}){let{t:i}=K(`activity`);return(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-accent-secondary/30 bg-accent-secondary/10 px-3 py-1.5 text-xs`,"data-testid":`epic-breadcrumb`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:r,className:`text-accent-secondary hover:underline font-medium`,children:[`← `,e.title]}),t!=null&&n>0&&(0,Y.jsx)(`span`,{className:`text-foreground/60`,children:i(`epicChildren.step`,{order:t,total:n})})]})}var GH={critical:`bg-red-400`,high:`bg-orange-400`,medium:`bg-yellow-400`,low:`bg-slate-400`};function KH(e){return e?GH[e]:`bg-muted`}function qH(e){return[...e].sort((e,t)=>{let n=e.execution_order??1/0,r=t.execution_order??1/0;return n===r?e.id-t.id:n-r})}function JH({ticket:e,allTickets:t,onOpenTicket:n}){let{t:r}=K(`activity`),i=e.is_epic===!0,a=e.parent_epic_id!=null;if(!i&&!a)return null;if(i){let i=qH(t.filter(t=>t.parent_epic_id===e.id));return(0,Y.jsx)(YH,{header:r(`family.subSpecsHeader`,{count:i.length}),rows:i,currentId:e.id,onOpenTicket:n,emptyMessage:r(`family.emptySubSpecs`)})}let o=t.find(t=>t.id===e.parent_epic_id)??null,s=qH(t.filter(t=>t.parent_epic_id===e.parent_epic_id)),c=o?[o,...s]:s;return(0,Y.jsx)(YH,{header:r(`family.familyHeader`,{count:s.length}),rows:c,currentId:e.id,onOpenTicket:n,emptyMessage:r(`family.noSiblings`)})}function YH({header:e,rows:t,currentId:n,onOpenTicket:r,emptyMessage:i}){let{t:a}=K(`activity`);return(0,Y.jsxs)(`div`,{"data-testid":`epic-family-sidebar`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1.5`,children:[(0,Y.jsx)($s,{className:`w-3 h-3 text-accent-highlight`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider`,children:e})]}),t.length===0?(0,Y.jsx)(`p`,{className:`text-[10px] text-foreground/50 italic`,children:i}):(0,Y.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:t.map(e=>{let t=e.id===n,i=e.is_epic===!0;return(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{t||r(e.id)},disabled:t,"aria-label":a(i?`family.openParentEpic`:`family.openSubSpec`,{title:e.title}),"aria-current":t?`page`:void 0,className:[`w-full flex items-center gap-1.5 rounded px-1.5 py-1 text-left transition-colors`,t?`bg-accent-highlight/15 cursor-default`:`hover:bg-muted/30 cursor-pointer`].join(` `),"data-testid":`epic-family-row-${e.id}`,children:[i?(0,Y.jsx)(Ua,{className:`w-3 h-3 text-accent-highlight flex-shrink-0`,"aria-hidden":!0}):(0,Y.jsx)(`span`,{className:`text-[9px] tabular-nums text-foreground/40 w-3 text-center flex-shrink-0`,children:e.execution_order??`–`}),(0,Y.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full flex-shrink-0 ${KH(e.priority)}`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`text-[11px] truncate ${t?`text-foreground font-medium`:`text-foreground/80`}`,title:e.title,children:e.title})]})},e.id)})})]})}var XH=900,ZH=.2,QH=[{value:`critical`,labelKey:`priority.critical`,className:`text-red-400`},{value:`high`,labelKey:`priority.high`,className:`text-orange-400`},{value:`medium`,labelKey:`priority.medium`,className:`text-yellow-400`},{value:`low`,labelKey:`priority.low`,className:`text-slate-400`}];function $H(e){return e.jira_epic_key&&e.jira_url?e.jira_url.replace(/\/browse\/[^/]+$/,`/browse/${e.jira_epic_key}`):null}var eU={manual:`source.manual`,"product-backlog":`source.productBacklog`,"propose-spec":`source.proposeSpec`,"get-backlog-specs":`source.getBacklogSpecs`,"free-prompt":`source.freePrompt`};function tU({ticket:e,allLabels:t,allTickets:n,onClose:r,onOpenTicket:i,onSave:a,onDelete:o,rails:s,onMoveToRail:c,onRemoveFromRail:l,embedded:u=!1}){let{t:d}=K(`tickets`),{t:f}=K(`jira`),{activeProjectId:p,projects:m}=gm(),{enterSplit:h,state:g}=dH(),_=g.originSide!==null,v=m.find(e=>e.id===p)?.provider!==`codex`,y=(0,H.useMemo)(()=>(n??[]).filter(t=>t.parent_epic_id===e.id),[n,e.id]),b=(0,H.useMemo)(()=>e.parent_epic_id==null?null:(n??[]).find(t=>t.id===e.parent_epic_id)??null,[n,e.parent_epic_id]),x=(0,H.useMemo)(()=>b?(n??[]).filter(e=>e.parent_epic_id===b.id).length:0,[n,b]),[S,C]=(0,H.useState)(e.title),[w,T]=(0,H.useState)(e.description),[E,D]=(0,H.useState)(e.priority??`medium`),[O,k]=(0,H.useState)([...e.labels??[]]),[A,j]=(0,H.useState)(!1),[M,N]=(0,H.useState)(!1),[P,F]=(0,H.useState)(``),[I,L]=(0,H.useState)(!1),[R,z]=(0,H.useState)(!1),[ee,te]=(0,H.useState)(!1),[B,ne]=(0,H.useState)(!1),[V,re]=(0,H.useState)(!1),U=Wb(),ie=U.connected&&!!U.discardStatus&&e.source===`jira`&&!!e.jira_key,ae=U.connected&&e.source===`jira`&&!!e.jira_key,[W,oe]=(0,H.useState)(e.attachments??[]);(0,H.useEffect)(()=>{oe(e.attachments??[])},[e.attachments,e.id]);let se=(0,H.useRef)(null),ce=(0,H.useRef)(null),le=(0,H.useRef)(null),ue=(0,H.useMemo)(()=>S!==e.title||w!==e.description||E!==e.priority||JSON.stringify(O)!==JSON.stringify(e.labels),[S,w,E,O,e]);(0,H.useEffect)(()=>{A&&se.current?.focus()},[A]),(0,H.useEffect)(()=>{if(M){let e=ce.current;e&&(e.focus(),e.selectionStart=e.value.length)}},[M]),(0,H.useEffect)(()=>{I&&le.current?.focus()},[I]),(0,H.useEffect)(()=>{function e(e){e.key===`Escape`&&!A&&!M&&!R&&r()}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r,A,M,R]);let de=(0,H.useMemo)(()=>{if(!P.trim())return[];let e=P.toLowerCase();return t.filter(t=>t.toLowerCase().includes(e)&&!O.includes(t)).slice(0,5)},[P,t,O]),fe=(0,H.useCallback)(e=>{let t=e.trim();t&&!O.includes(t)&&k(e=>[...e,t]),F(``)},[O]),pe=(0,H.useCallback)(e=>{k(t=>t.filter(t=>t!==e))},[]),me=(0,H.useCallback)(async()=>{let t={};if(S!==e.title&&(t.title=S),w!==e.description&&(t.description=w),E!==e.priority&&(t.priority=E),JSON.stringify(O)!==JSON.stringify(e.labels)&&(t.labels=O),Object.keys(t).length===0){r();return}re(!0);let n=await a(e.id,t);re(!1),n?(q.success(d(`detailModal.toast.updated`)),r()):q.error(d(`detailModal.toast.updateFailed`))},[S,w,E,O,e,a,r,d]),he=(0,H.useCallback)(()=>{o(e.id),z(!1),r()},[e.id,o,r]),[ge,_e]=(0,H.useState)(0),ve=(0,H.useRef)(null),ye=!u&&!_&&typeof window<`u`&&window.innerWidth>=XH,G=(0,H.useCallback)(e=>{ve.current&&_e(e.clientX-ve.current.startX)},[]),be=(0,H.useCallback)(t=>{if(!ve.current)return;let n=t.clientX-ve.current.startX,i=window.innerWidth*ZH;if(window.removeEventListener(`pointermove`,G),window.removeEventListener(`pointerup`,be),window.removeEventListener(`pointercancel`,be),ve.current=null,_e(0),Math.abs(n)>=i){let t=g.leftId===e.id;h(n<0?`left`:`right`,e.id),t||r()}},[h,G,g.leftId,e.id,r]),xe=(0,H.useCallback)(e=>{ye&&e.button===0&&(e.target.closest(`button, input, textarea, select, [contenteditable="true"]`)||(ve.current={startX:e.clientX,pointerId:e.pointerId},window.addEventListener(`pointermove`,G),window.addEventListener(`pointerup`,be),window.addEventListener(`pointercancel`,be)))},[ye,G,be]);(0,H.useEffect)(()=>()=>{ve.current&&(window.removeEventListener(`pointermove`,G),window.removeEventListener(`pointerup`,be),window.removeEventListener(`pointercancel`,be))},[G,be]);let Se=(0,H.useCallback)(()=>{if(!ye)return;let t=g.leftId===e.id;h(`right`,e.id),t||r()},[ye,h,g.leftId,e.id,r]),{panelRef:Ce,panelStyle:we,resizeHandles:Te,guardBackdrop:Ee}=yb({enabled:!u,allowMove:!1}),De=(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{ref:Ce,className:u?`relative w-full h-full rounded-xl bg-card border border-border/40 shadow-2xl shadow-black/50 flex flex-col overflow-hidden`:`relative w-full max-w-[67rem] m-4 rounded-xl bg-card border border-border/40 shadow-2xl shadow-black/50 flex flex-col animate-in fade-in zoom-in-95 duration-200 h-[90vh]`,style:{...ge===0?{transition:`transform 220ms cubic-bezier(0.34, 1.56, 0.64, 1)`}:{transform:`translateX(${ge}px)`,transition:`none`},...we},children:[b&&(0,Y.jsx)(`div`,{className:`px-5 pt-3`,children:(0,Y.jsx)(WH,{epic:b,childExecutionOrder:e.execution_order??null,totalChildren:x,onOpenEpic:()=>i?.(b.id)})}),(0,Y.jsxs)(`div`,{className:`flex items-start justify-between gap-3 px-5 py-4 border-b border-border/30 ${ye?`cursor-grab active:cursor-grabbing`:``}`,onPointerDown:xe,"data-testid":`ticket-modal-header`,children:[(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[A?(0,Y.jsx)(`input`,{ref:se,value:S,onChange:e=>C(e.target.value),onBlur:()=>j(!1),onKeyDown:t=>{t.key===`Enter`&&j(!1),t.key===`Escape`&&(C(e.title),j(!1))},className:`w-full bg-transparent border-b border-accent-primary/50 text-sm font-semibold text-foreground outline-none pb-0.5`}):(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>j(!0),className:`group flex items-center gap-1.5 text-left w-full`,children:[(0,Y.jsx)(`h2`,{className:`text-sm font-semibold text-foreground truncate`,children:S||d(`untitled`)}),(0,Y.jsx)(ws,{className:`w-3 h-3 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity shrink-0`})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 mt-1.5`,children:[(0,Y.jsxs)(`span`,{className:`text-[10px] text-foreground font-mono`,children:[`#`,e.id]}),e.status===`on_review`&&(0,Y.jsx)(`span`,{title:d(`specs:status.onReviewHint`),"data-testid":`ticket-modal-on-review-badge`,children:(0,Y.jsx)(sx,{status:`on_review`})})]}),(0,Y.jsx)(bH,{ticketId:e.id})]}),p&&(0,Y.jsx)(`div`,{className:`shrink-0`,children:(0,Y.jsx)(UH,{ticket:e,projectId:p,featureFlagOn:v,childrenCount:y.length})}),(0,Y.jsx)(rU,{ticket:e,title:S,description:w,priority:E,labels:O,onClose:r}),s&&(c||l)&&(0,Y.jsx)(iU,{ticket:e,rails:s,onMoveToRail:c,onRemoveFromRail:l}),ye&&(0,Y.jsxs)(Z,{variant:`outline`,size:`sm`,className:`shrink-0 mr-1 gap-1.5`,"data-testid":`ticket-modal-compare`,onClick:Se,title:d(`detailModal.compareTooltip`),children:[(0,Y.jsx)(vo,{className:`w-3.5 h-3.5`}),d(`detailModal.compare`)]}),(0,Y.jsx)(`button`,{onClick:r,className:`h-7 w-7 flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-surface/50 transition-colors cursor-pointer shrink-0`,"data-testid":`ticket-modal-close`,children:(0,Y.jsx)(hc,{className:`w-4 h-4`})})]}),(0,Y.jsx)(`div`,{className:`flex-1 overflow-y-auto min-h-0`,children:(0,Y.jsxs)(`div`,{className:`flex flex-col sm:flex-row h-full`,children:[(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0 px-5 py-4 space-y-4 flex flex-col`,children:[(0,Y.jsxs)(`div`,{className:`flex-1 flex flex-col`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider flex items-center gap-1.5`,children:d(`fields.description`)}),!M&&(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>N(!0),className:`text-[10px] text-muted-foreground hover:text-foreground transition-colors flex items-center gap-1`,children:[(0,Y.jsx)(ws,{className:`w-2.5 h-2.5`}),d(`common:actions.edit`)]})]}),M?(0,Y.jsxs)(`div`,{className:`space-y-1.5 flex-1 flex flex-col`,children:[(0,Y.jsx)(`textarea`,{ref:ce,value:w,onChange:e=>T(e.target.value),className:`w-full flex-1 rounded-lg border border-border bg-input px-3 py-2 text-xs text-foreground placeholder:text-muted-foreground resize-none min-h-[300px]`,placeholder:d(`fields.markdownPlaceholder`)}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(Z,{variant:`ghost`,size:`sm`,className:`h-6 text-[10px]`,onClick:()=>N(!1),children:d(`detailModal.doneEditing`)}),(0,Y.jsx)(`span`,{className:`text-[9px] text-muted-foreground`,children:d(`fields.supportsMarkdown`)})]})]}):w?(0,Y.jsx)(cU,{description:w,onEdit:()=>N(!0)}):(0,Y.jsx)(`button`,{type:`button`,onClick:()=>N(!0),className:`w-full rounded-lg border border-dashed border-border/40 bg-muted/10 px-3 py-4 text-xs text-muted-foreground hover:text-foreground hover:bg-muted/20 transition-colors text-center`,children:d(`detailModal.addDescription`)})]}),(0,Y.jsx)(JV,{ticketKey:e.id,attachments:W,onChange:oe}),(0,Y.jsx)(YV,{ticketId:e.id,onClose:r}),e.prerequisites&&e.prerequisites.length>0&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1.5`,children:d(`detailModal.prerequisites`)}),(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.prerequisites.map(e=>(0,Y.jsxs)(`span`,{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[10px] font-mono bg-accent/60 text-foreground/70`,children:[`#`,e]},e))})]})]}),(0,Y.jsxs)(`div`,{className:`sm:w-56 sm:border-l border-t sm:border-t-0 border-border/30 px-4 py-4 space-y-4 bg-muted/5`,children:[e.jira_url&&e.jira_key&&(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{HV(e.jira_url)},"data-testid":`jira-go-to-ticket`,className:`w-full inline-flex items-center justify-center gap-1.5 h-7 rounded border border-accent-info/50 bg-accent-info/10 px-2 text-xs font-medium text-accent-info hover:bg-accent-info/20 transition-colors`,children:[(0,Y.jsx)(Oo,{className:`w-3.5 h-3.5 shrink-0`}),f(`detail.goToTicket`,{key:e.jira_key})]}),e.jira_epic_key&&(0,Y.jsxs)(`div`,{"data-testid":`jira-epic`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1.5`,children:f(`detail.epic`)}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{let t=$H(e);t&&HV(t)},title:e.jira_epic_name??e.jira_epic_key,className:`w-full inline-flex items-center gap-1.5 rounded border border-accent-highlight/40 bg-accent-highlight/5 px-2 py-1.5 text-left text-xs hover:bg-accent-highlight/10 transition-colors`,children:[(0,Y.jsx)(`span`,{className:`font-mono text-accent-highlight shrink-0`,children:e.jira_epic_key}),e.jira_epic_name&&(0,Y.jsx)(`span`,{className:`truncate text-foreground/80`,children:e.jira_epic_name})]})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1.5`,children:d(`fields.priority`)}),(0,Y.jsx)(`select`,{value:E,onChange:e=>D(e.target.value),className:`w-full h-7 rounded border border-border bg-input px-2 text-xs text-foreground`,children:QH.map(e=>(0,Y.jsx)(`option`,{value:e.value,children:d(e.labelKey)},e.value))})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1.5`,children:d(`fields.labels`)}),(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-1 mb-1.5`,children:O.map(e=>(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 rounded px-1.5 py-0.5 text-[10px] font-medium bg-accent/60 text-foreground/70 group`,children:[e,(0,Y.jsx)(`button`,{type:`button`,onClick:()=>pe(e),className:`text-muted-foreground hover:text-foreground opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,Y.jsx)(lo,{className:`w-2.5 h-2.5`})})]},e))}),I?(0,Y.jsxs)(`div`,{className:`relative`,children:[(0,Y.jsx)(`input`,{ref:le,value:P,onChange:e=>F(e.target.value),onKeyDown:e=>{e.key===`Enter`&&P.trim()&&(e.preventDefault(),fe(P)),e.key===`Escape`&&(L(!1),F(``))},onBlur:()=>{P.trim()&&fe(P),L(!1),F(``)},placeholder:d(`detailModal.addLabelPlaceholder`),className:`w-full h-6 rounded border border-border bg-input px-2 text-[10px] text-foreground placeholder:text-muted-foreground`}),de.length>0&&(0,Y.jsx)(`div`,{className:`absolute left-0 right-0 top-full mt-0.5 rounded border border-border/50 bg-popover shadow-lg z-10 py-0.5`,children:de.map(e=>(0,Y.jsx)(`button`,{type:`button`,onMouseDown:t=>{t.preventDefault(),fe(e)},className:`w-full text-left px-2 py-1 text-[10px] hover:bg-accent/50 text-foreground/80`,children:e},e))})]}):(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>L(!0),className:`flex items-center gap-1 text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:[(0,Y.jsx)(ks,{className:`w-2.5 h-2.5`}),d(`detailModal.addLabel`)]})]}),(0,Y.jsx)(JH,{ticket:e,allTickets:n??[],onOpenTicket:e=>i?.(e)}),e.source===`jira`&&e.jira_key&&(0,Y.jsx)(CH,{localId:e.id}),e.metadata?.effort_level&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-0.5`,children:d(`detailModal.effort`)}),(0,Y.jsx)(`span`,{className:`text-xs text-foreground/70`,children:e.metadata.effort_level})]}),e.assignee&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-0.5`,children:d(`detailModal.assignee`)}),(0,Y.jsx)(`span`,{className:`text-xs text-foreground/70`,children:e.assignee})]})]})]})}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-3 border-t border-border/30`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 text-[10px] text-muted-foreground`,children:[(0,Y.jsx)(`span`,{children:d(`meta.createdAgo`,{time:nU(e.created_at)})}),(0,Y.jsx)(`span`,{children:d(`meta.updatedAgo`,{time:nU(e.updated_at)})}),e.source&&(0,Y.jsx)(`span`,{className:`bg-muted/30 rounded px-1.5 py-0.5`,children:eU[e.source]?d(eU[e.source]):e.source})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[ie?(0,Y.jsxs)(Z,{variant:`ghost`,size:`sm`,className:`h-7 text-xs text-accent-info hover:bg-accent-info/10`,onClick:()=>te(!0),"data-testid":`jira-move-to-button`,children:[(0,Y.jsx)(Va,{className:`w-3 h-3 mr-1`}),f(`discard.moveButton`,{status:U.discardStatus})]}):(0,Y.jsxs)(Z,{variant:`ghost`,size:`sm`,className:`h-7 text-xs text-red-400 aurora-light:text-destructive hover:text-red-300 aurora-light:hover:text-destructive hover:bg-red-500/10 aurora-light:hover:bg-destructive/10`,onClick:()=>z(!0),children:[(0,Y.jsx)(cc,{className:`w-3 h-3 mr-1`}),d(`common:actions.delete`)]}),ue&&(0,Y.jsxs)(Z,{size:`sm`,className:`h-7 text-xs`,onClick:()=>{ae?ne(!0):me()},disabled:V||!S.trim(),children:[(0,Y.jsx)(Bs,{className:`w-3 h-3 mr-1`}),d(V?`common:states.saving`:`common:actions.save`)]})]})]})]}),(0,Y.jsx)(Cb,{open:R,onOpenChange:z,children:(0,Y.jsxs)(Db,{className:`max-w-sm`,children:[(0,Y.jsxs)(Ob,{children:[(0,Y.jsx)(Ab,{children:d(`deleteDialog.title`)}),(0,Y.jsx)(jb,{children:(0,Y.jsx)(Yi,{t:d,i18nKey:`deleteDialog.body`,values:{id:e.id,title:e.title},components:{strong:(0,Y.jsx)(`span`,{className:`font-semibold text-foreground`})}})})]}),(0,Y.jsxs)(kb,{children:[(0,Y.jsx)(Z,{variant:`outline`,size:`sm`,onClick:()=>z(!1),children:d(`common:actions.cancel`)}),(0,Y.jsxs)(Z,{variant:`destructive`,size:`sm`,onClick:he,children:[(0,Y.jsx)(cc,{className:`w-3.5 h-3.5 mr-1.5`}),d(`common:actions.delete`)]})]})]})}),ie&&U.discardStatus&&(0,Y.jsx)(Jb,{open:ee,onOpenChange:te,ticket:{id:e.id,title:e.title,jira_key:e.jira_key},discardStatus:U.discardStatus,onDiscarded:r}),(0,Y.jsx)(Cb,{open:B,onOpenChange:ne,children:(0,Y.jsxs)(Db,{className:`max-w-md`,"data-testid":`jira-save-confirm`,children:[(0,Y.jsxs)(Ob,{children:[(0,Y.jsx)(Ab,{children:f(`detail.saveTitle`)}),(0,Y.jsx)(jb,{children:f(`detail.saveBody`,{key:e.jira_key??`#${e.id}`})})]}),(0,Y.jsxs)(kb,{children:[(0,Y.jsx)(Z,{variant:`outline`,size:`sm`,onClick:()=>ne(!1),children:d(`common:actions.cancel`)}),(0,Y.jsxs)(Z,{size:`sm`,onClick:()=>{ne(!1),me()},disabled:V,"data-testid":`jira-save-confirm-btn`,children:[(0,Y.jsx)(Bs,{className:`w-3.5 h-3.5 mr-1.5`}),f(`detail.saveConfirm`)]})]})]})})]});return u?De:(0,Y.jsxs)(`div`,{className:`fixed inset-0 z-[68] flex items-center justify-center`,children:[(0,Y.jsx)(`div`,{className:`absolute inset-0 bg-black/70`,onClick:Ee(r)}),De,(0,Y.jsx)(xb,{handles:Te})]})}function nU(e){try{return vV(new Date(e),{addSuffix:!0,locale:im()})}catch{return e}}function rU({ticket:e,title:t,description:n,priority:r,labels:i,onClose:a}){let{t:o}=K(`tickets`),{triggerResume:s}=Vg(),{activeProjectId:c}=gm(),{closeTicketDetail:l}=dH();return Kg(e)?(0,Y.jsxs)(Z,{variant:`default`,size:`sm`,onClick:()=>{if(!c)return;let{body:u,criteria:d}=Wg(n);s({kind:`explore-spec`,projectId:c,label:t||e.title||o(`detailModal.ticketFallbackLabel`,{id:e.id}),restoreRoute:`/`,params:{initialIdea:``,pendingSpecId:qg(),initialAttachmentIds:[],resumeConversationId:e.origin_conversation_id??void 0,editTicket:{id:e.id,title:t,description:u,labels:i,priority:r,acceptanceCriteria:d,status:e.status}}}),l(),a()},className:`shrink-0 mr-2`,"data-testid":`continue-editing`,children:[(0,Y.jsx)(ds,{className:`w-3.5 h-3.5 mr-1.5`}),o(`detailModal.continueEditing`)]}):null}function iU({ticket:e,rails:t,onMoveToRail:n,onRemoveFromRail:r}){let{t:i}=K(`tickets`),[a,o]=(0,H.useState)(null),s=(0,H.useRef)(null),c=t.find(t=>t.ticketIds.includes(e.id));return c?r?(0,Y.jsxs)(Z,{variant:`outline`,size:`sm`,className:`shrink-0 mr-2 gap-1.5 border-accent-warning/30 text-accent-warning hover:bg-accent-warning/10 hover:text-accent-warning`,"data-testid":`modal-remove-from-rail`,onClick:()=>r(e.id),title:i(`rail.currentlyOn`,{rail:c.label}),children:[(0,Y.jsx)(Ba,{className:`w-3.5 h-3.5`,"aria-hidden":!0}),i(`rail.removeFromRail`)]}):null:n?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(Z,{ref:s,variant:`outline`,size:`sm`,className:`shrink-0 mr-2 gap-1.5 border-accent-info/30 text-accent-info hover:bg-accent-info/10 hover:text-accent-info`,"data-testid":`modal-move-to-rail`,onClick:()=>{s.current&&o(s.current.getBoundingClientRect())},children:[i(`rail.moveToRail`),(0,Y.jsx)(Va,{className:`w-3.5 h-3.5`,"aria-hidden":!0})]}),a&&(0,Y.jsx)(_g,{rails:t,anchorRect:a,onMoveToRail:t=>n(e.id,t),onClose:()=>o(null)})]}):null}var aU=`
111
+ `);if(Dz.test(e)||Oz.test(e))return!0}return!1}function Az({value:e,onChange:t,freestyleAvailable:n=!0,loopsEnabled:r=!0}){let{t:i}=K(`dashboard`),[a,o]=(0,H.useState)([]);(0,H.useEffect)(()=>{if(!r)return;let e=!1;return Ez.list().then(t=>{e||o(t.filter(e=>e.status===`published`&&kz(e.graph)))}).catch(()=>{}),()=>{e=!0}},[r]);let s=fz.filter(e=>(n||!e.claudeOnly)&&(r||!e.requiresLoops));return(0,Y.jsxs)(`div`,{className:`inline-flex items-center`,title:i(`railControls.loopTitle`),onMouseDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),children:[(0,Y.jsx)(mc,{className:`w-3 h-3 text-muted-foreground mr-1`}),(0,Y.jsxs)(`select`,{value:e??``,"aria-label":i(`railControls.loop`),"data-testid":`rail-loop-selector`,onChange:e=>t(e.target.value),className:`h-5 text-[10px] rounded border border-border/50 bg-transparent text-muted-foreground hover:text-foreground pr-4 pl-1 focus:outline-none focus:ring-1 focus:ring-primary/40 max-w-[160px]`,children:[(0,Y.jsx)(`option`,{value:``,disabled:!0,children:i(`railControls.pickLoop`)}),(0,Y.jsx)(`optgroup`,{label:i(`railControls.builtInLoops`),children:s.map(e=>(0,Y.jsx)(`option`,{value:e.id,children:i(e.labelKey)},e.id))}),a.length>0&&(0,Y.jsx)(`optgroup`,{label:i(`railControls.customLoops`),children:a.map(e=>(0,Y.jsx)(`option`,{value:e.id,children:e.name},e.id))})]})]})}function jz(e){if(!Number.isFinite(e)||e<0)return`0s`;let t=Math.round(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60),r=t%60;return n<60?`${n}m ${r}s`:`${Math.floor(n/60)}h ${n%60}m`}function Mz({metric:e}){let{t}=K(`dashboard`),[n,r]=(0,H.useState)(()=>Date.now());return(0,H.useEffect)(()=>{let e=window.setInterval(()=>r(Date.now()),1e3);return()=>window.clearInterval(e)},[]),(0,Y.jsxs)(`div`,{className:`mt-1 flex items-center gap-1.5 text-[10px] text-muted-foreground tabular-nums`,"data-testid":`rail-exec-info`,children:[(0,Y.jsx)(`span`,{children:jz(n-e.startedAt)}),(0,Y.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,Y.jsx)(`span`,{children:t(`railControls.execSteps`,{count:e.steps})}),(0,Y.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,Y.jsx)(`span`,{children:t(`railControls.execLines`,{count:e.lines})})]})}var Nz=[`low`,`medium`,`high`];function Pz({value:e,onChange:t}){let{t:n}=K(`dashboard`),r=e??`medium`;return(0,Y.jsxs)(`div`,{className:`inline-flex items-center`,title:n(`railControls.effortTitle`),onMouseDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),children:[(0,Y.jsx)(Vo,{className:`w-3 h-3 text-muted-foreground mr-1`}),(0,Y.jsx)(`select`,{value:r,"aria-label":n(`railControls.effortTitle`),"data-testid":`rail-effort-selector`,onChange:e=>t(e.target.value),className:`h-5 text-[10px] rounded border border-border/50 bg-transparent text-muted-foreground hover:text-foreground pr-4 pl-1 focus:outline-none focus:ring-1 focus:ring-primary/40`,children:Nz.map(e=>(0,Y.jsx)(`option`,{value:e,children:e},e))})]})}function Fz({decision:e,density:t,act:n,checkout:r}){let{t:i}=K(`dashboard`),[a,o]=(0,H.useState)(null),[s,c]=(0,H.useState)(!1),[l,u]=(0,H.useState)(!1),[d,f]=(0,H.useState)(!1),p=e.decision,m=p===`building`&&e.prState===`pr-created`&&!!e.branch;if(p===`building`&&!m||p===`merged`||p===`discarded`)return null;let h=t===`compact`;async function g(t,r){if(!(a||s)){o(t);try{let a=await n(t,r);if(a.status===409){if(a.error===`merge_local_blocked`){q.warning(a.reason===`dirty`?i(`railPr.mergeLocalBlockedDirty`,{base:a.base??e.baseBranch}):i(`railPr.mergeLocalBlockedBranch`,{base:a.base??e.baseBranch,current:a.current??`?`}));return}q.info(i(`railPr.alreadyResolved`));return}if(a.status===502){if(a.error===`merge_failed`){q.error(i(`railPr.mergeLocalFailed`,{detail:a.detail??``}));return}q.error(i(`railPr.ghFailed`,{detail:a.detail??a.error??``}));return}if(!a.ok){q.error(i(`railPr.actionFailed`));return}if(t===`poll-merge`&&a.merged===!1&&q.info(i(`railPr.notMergedYet`)),t===`merge-local`&&a.decision===`merged`&&q.success(i(`railPr.mergedLocally`,{base:e.baseBranch})),t===`create-pr`&&a.decision===`pr_failed`){q.error(a.detail?i(`railPr.prFailedDetail`,{detail:a.detail}):i(`railPr.prFailed`));return}t===`create-pr`&&a.decision===`pr_draft`&&!a.prUrl&&a.detail&&q.error(i(`railPr.createDegraded`,{detail:a.detail}))}finally{o(null)}}}async function _(){if(!(!r||a||s)){c(!0);try{let t=await r();if(!t.ok){q.warning(i(`railPr.checkoutFailed`),{description:t.detail??t.error});return}q.success(i(`railPr.checkoutSuccess`,{branch:e.branch??``}))}finally{c(!1)}}}let v=`inline-flex items-center gap-1 rounded-full font-medium border ${h?`px-1.5 py-0.5 text-[9px]`:`px-2 py-0.5 text-[10px]`}`,y=`inline-flex items-center gap-1 rounded-md font-medium bg-accent-primary text-white hover:bg-accent-primary/90 disabled:opacity-50 disabled:pointer-events-none transition-colors ${h?`px-1.5 py-0.5 text-[9px]`:`px-2 py-0.5 text-[10px]`}`,b=`inline-flex items-center gap-1 rounded-md text-muted-foreground hover:text-destructive hover:bg-destructive/10 disabled:opacity-50 disabled:pointer-events-none transition-colors ${h?`px-1.5 py-0.5 text-[9px]`:`px-2 py-0.5 text-[10px]`}`,x=h?`w-2.5 h-2.5`:`w-3 h-3`,S=(0,Y.jsx)(cs,{className:`${x} animate-spin`,"aria-hidden":!0}),C=a!==null||s,w=i(p===`implementation_failed`?`railPr.implementationFailedHint`:`railPr.discardTooltip`),T=e.prUrl?(0,Y.jsxs)(`a`,{href:e.prUrl,target:`_blank`,rel:`noreferrer`,"data-testid":`rail-pr-link`,title:i(`railPr.openPrTitle`),onClick:e=>e.stopPropagation(),className:`inline-flex items-center gap-1 rounded-md font-mono border border-accent-info/30 bg-accent-info/10 text-accent-info hover:bg-accent-info/20 hover:border-accent-info/60 transition-colors ${h?`px-1 py-0.5 text-[9px]`:`px-1.5 py-0.5 text-[10px]`}`,children:[e.prNumber==null?i(`railPr.prLinkFallback`):`#${e.prNumber}`,(0,Y.jsx)(Oo,{className:h?`w-2 h-2`:`w-2.5 h-2.5`,"aria-hidden":!0})]}):null,E=e.branch?(0,Y.jsx)(`span`,{"data-testid":`rail-pr-branch`,className:`inline-flex min-w-0 max-w-full items-center gap-1 rounded-md font-mono border border-border/60 bg-surface/60 text-foreground/70 ${h?`px-1 py-0.5 text-[9px]`:`px-1.5 py-0.5 text-[10px]`}`,children:(0,Y.jsx)(`span`,{className:`truncate`,children:e.branch})}):null,D=(0,Y.jsxs)(`button`,{type:`button`,"data-testid":`rail-pr-discard`,disabled:C,title:w,onClick:e=>{e.stopPropagation(),u(!0)},className:b,children:[a===`discard`?S:null,i(`railPr.discard`)]}),O=(0,Y.jsxs)(`button`,{type:`button`,"data-testid":`rail-pr-merge-local`,disabled:C,title:i(`railPr.mergeLocalTooltip`,{base:e.baseBranch}),onClick:e=>{e.stopPropagation(),f(!0)},className:`inline-flex items-center gap-1 rounded-md font-medium border border-accent-success/40 bg-accent-success/10 text-accent-success hover:bg-accent-success/20 disabled:opacity-50 disabled:pointer-events-none transition-colors ${h?`px-1.5 py-0.5 text-[9px]`:`px-2 py-0.5 text-[10px]`}`,children:[a===`merge-local`?S:(0,Y.jsx)(Wo,{className:x,"aria-hidden":!0}),i(`railPr.mergeLocal`)]}),k=(e,t,n,r,i,o)=>(0,Y.jsxs)(`button`,{type:`button`,"data-testid":r,disabled:C,title:i,onClick:n=>{n.stopPropagation(),g(e,t)},className:y,children:[a===e?S:o,n]}),A=r&&e.prUrl&&e.branch?(0,Y.jsxs)(`button`,{type:`button`,"data-testid":`rail-pr-checkout`,disabled:C,title:i(`railPr.checkoutTooltip`,{branch:e.branch}),onClick:e=>{e.stopPropagation(),_()},className:`inline-flex items-center gap-1 rounded-md font-medium border border-border/60 text-foreground/70 hover:border-accent-primary/40 hover:bg-accent-primary/10 disabled:opacity-50 disabled:pointer-events-none transition-colors ${h?`px-1.5 py-0.5 text-[9px]`:`px-2 py-0.5 text-[10px]`}`,children:[s?S:(0,Y.jsx)(Ho,{className:x,"aria-hidden":!0}),i(`railPr.checkout`)]}):null,j=null,M=null;return m?(j=(0,Y.jsxs)(`span`,{className:`${v} border-accent-info/30 bg-accent-info/10 text-accent-info`,children:[(0,Y.jsx)(cs,{className:`${x} animate-spin`,"aria-hidden":!0}),i(`railPr.iteratingPr`)]}),M=(0,Y.jsxs)(Y.Fragment,{children:[T,E]})):p===`on_review`?(j=(0,Y.jsxs)(`span`,{className:`${v} border-accent-warning/30 bg-accent-warning/10 text-accent-warning`,children:[(0,Y.jsx)(ko,{className:x,"aria-hidden":!0}),i(`railPr.readyForReview`)]}),M=(0,Y.jsxs)(Y.Fragment,{children:[k(`create-pr`,`on_review`,i(`railPr.createPr`),`rail-pr-create`,i(`railPr.createPrTooltip`,{base:e.baseBranch}),(0,Y.jsx)(Go,{className:x,"aria-hidden":!0})),O,D]})):p===`pr_draft`&&e.prUrl?(j=(0,Y.jsxs)(`span`,{className:`${v} border-accent-info/30 bg-accent-info/10 text-accent-info`,children:[(0,Y.jsx)(Go,{className:x,"aria-hidden":!0}),i(`railPr.draftPr`)]}),M=(0,Y.jsxs)(Y.Fragment,{children:[T,A,k(`publish`,`pr_draft`,i(`railPr.publish`),`rail-pr-publish`,i(`railPr.publishTooltip`)),D]})):p===`pr_draft`?(j=(0,Y.jsxs)(`span`,{className:`${v} border-accent-warning/30 bg-accent-warning/10 text-accent-warning`,title:i(`railPr.branchPushedHint`),children:[(0,Y.jsx)(lc,{className:x,"aria-hidden":!0}),i(`railPr.branchPushed`)]}),M=(0,Y.jsxs)(Y.Fragment,{children:[k(`create-pr`,`pr_draft`,i(`railPr.retryPr`),`rail-pr-create`,i(`railPr.createPrTooltip`,{base:e.baseBranch})),O,D]})):p===`pr_ready`?(j=(0,Y.jsxs)(`span`,{className:`${v} border-accent-success/30 bg-accent-success/10 text-accent-success`,children:[(0,Y.jsx)(Wo,{className:x,"aria-hidden":!0}),i(`railPr.prReady`)]}),M=(0,Y.jsxs)(Y.Fragment,{children:[T,A,k(`poll-merge`,`pr_ready`,i(`railPr.checkMerge`),`rail-pr-poll`,i(`railPr.checkMergeTooltip`)),D]})):p===`pr_failed`?(j=(0,Y.jsxs)(`span`,{className:`${v} border-destructive/30 bg-destructive/10 text-destructive`,children:[(0,Y.jsx)(lc,{className:x,"aria-hidden":!0}),i(`railPr.prFailed`)]}),M=(0,Y.jsxs)(Y.Fragment,{children:[T,A,k(`create-pr`,`pr_failed`,i(`railPr.retry`),`rail-pr-create`,i(`railPr.createPrTooltip`,{base:e.baseBranch})),!e.prUrl&&O,D]})):p===`implementation_failed`&&(j=(0,Y.jsxs)(`span`,{className:`${v} border-destructive/30 bg-destructive/10 text-destructive`,title:i(`railPr.implementationFailedHint`),children:[(0,Y.jsx)(lc,{className:x,"aria-hidden":!0}),i(`railPr.implementationFailed`)]}),M=(0,Y.jsx)(Y.Fragment,{children:D})),(0,Y.jsxs)(`div`,{"data-testid":`rail-pr-strip`,"data-decision":p,className:`flex items-center flex-wrap animate-in fade-in slide-in-from-top-1 duration-200 ${h?`gap-1`:`gap-1.5`}`,onClick:e=>e.stopPropagation(),children:[j,M,(0,Y.jsx)(Cb,{open:d,onOpenChange:f,children:(0,Y.jsxs)(Db,{className:`max-w-sm`,"data-testid":`rail-pr-merge-local-confirm`,children:[(0,Y.jsxs)(Ob,{children:[(0,Y.jsx)(Ab,{children:i(`railPr.mergeLocalConfirmTitle`)}),(0,Y.jsx)(jb,{children:i(`railPr.mergeLocalConfirmBody`,{base:e.baseBranch})})]}),(0,Y.jsxs)(kb,{children:[(0,Y.jsx)(Z,{variant:`outline`,size:`sm`,onClick:()=>f(!1),children:i(`common:actions.cancel`)}),(0,Y.jsx)(Z,{size:`sm`,"data-testid":`rail-pr-merge-local-confirm-btn`,onClick:()=>{f(!1),g(`merge-local`,p)},children:i(`railPr.mergeLocal`)})]})]})}),(0,Y.jsx)(Cb,{open:l,onOpenChange:u,children:(0,Y.jsxs)(Db,{className:`max-w-sm`,"data-testid":`rail-pr-discard-confirm`,children:[(0,Y.jsxs)(Ob,{children:[(0,Y.jsx)(Ab,{children:i(`railPr.discardConfirmTitle`)}),(0,Y.jsx)(jb,{children:i(`railPr.discardConfirmBody`)})]}),(0,Y.jsxs)(kb,{children:[(0,Y.jsx)(Z,{variant:`outline`,size:`sm`,onClick:()=>u(!1),children:i(`common:actions.cancel`)}),(0,Y.jsx)(Z,{variant:`destructive`,size:`sm`,"data-testid":`rail-pr-discard-confirm-btn`,onClick:()=>{u(!1),g(`discard`,p)},children:i(`railPr.discard`)})]})]})})]})}var Iz={claude:[{value:`sonnet`,label:`Claude Sonnet`},{value:`fable`,label:`Claude Fable`},{value:`opus`,label:`Claude Opus`},{value:`haiku`,label:`Claude Haiku`}],codex:[{value:`gpt-5.5`,label:`GPT-5.5`},{value:`gpt-5.4`,label:`GPT-5.4`},{value:`gpt-5.4-mini`,label:`GPT-5.4 Mini`},{value:`gpt-5.3-codex`,label:`GPT-5.3 Codex`}],gemini:[{value:`gemini-3.5-flash`,label:`Gemini 3.5 Flash`},{value:`gemini-3.1-pro-preview`,label:`Gemini 3.1 Pro (preview)`},{value:`gemini-3.1-flash-lite`,label:`Gemini 3.1 Flash Lite`},{value:`gemini-2.5-flash-lite`,label:`Gemini 2.5 Flash Lite`}]};function Lz(e){return e&&Iz[e]||[]}function Rz(e){return Lz(e)[0]?.value??``}var zz=800,Bz=60;function Vz({id:e,label:t,tickets:n,mode:r,status:i,activeJobId:a,profileName:o,aiEngine:s,freestyleModel:c,loopModel:l,providers:u,loopAvailable:d,selectedLoopId:f,reasoningEffort:p,worktreeSummary:m,prDecision:h,onPrDecision:g,onPrCheckout:_,executionMetric:v,jiggleMode:y,dragHandleListeners:b,dragHandleAttributes:x,density:S=`normal`,onModeChange:C,onProfileChange:w,onEngineChange:T,onFreestyleModelChange:E,onLoopModelChange:D,onLoopChange:O,onEffortChange:k,onToggle:A,onTicketClick:j,onDelete:M,onLongPress:N,onRename:P,onTicketMoveToSpecs:F}){let{t:I}=K(`dashboard`),L=(s??u?.[0])!==`codex`,R=(s??u?.[0]??`claude`)===`claude`,z=WD(s??u?.[0]??`claude`),ee=!!T&&i!==`running`&&(u?.length??0)>1,te=!!w&&i!==`running`&&L&&r!==`loop`,B=!!E&&i!==`running`&&r===`freestyle`&&R,ne=!!D&&i!==`running`&&r===`loop`,V=s??u?.[0]??`claude`,re=Lz(V),U=l??Rz(V),ie=ne&&D?(0,Y.jsx)(`select`,{"data-testid":`loop-model-selector`,"aria-label":I(`railSelectors.loopModelTitle`),value:U,onChange:e=>D(e.target.value),className:`h-5 text-[10px] rounded border border-border/50 bg-transparent text-muted-foreground hover:text-foreground pr-4 pl-1 focus:outline-none focus:ring-1 focus:ring-primary/40`,children:re.map(e=>(0,Y.jsx)(`option`,{value:e.value,children:e.label},e.value))}):null,ae=!!O&&i!==`running`,W=ee||B||ne||ae,[oe,se]=(0,H.useState)(null);(0,H.useEffect)(()=>{if(!oe)return;function e(e){e.target?.closest(`[role="menu"]`)||se(null)}function t(e){e.key===`Escape`&&se(null)}return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[oe]);let{isOver:ce,setNodeRef:le}=_d({id:e}),{active:ue}=md(),de=typeof ue?.id==`number`,[fe,pe]=(0,H.useState)(0),[me,he]=(0,H.useState)(!1),[ge,_e]=(0,H.useState)(!1),[ve,ye]=(0,H.useState)(!1),[G,be]=(0,H.useState)(``),xe=(0,H.useRef)(null),Se=(0,H.useRef)(null),Ce=(0,H.useRef)(null),we=(0,H.useRef)(!1),Te=i===`running`,Ee=!Te,De=(0,H.useCallback)(()=>{Ce.current&&=(clearTimeout(Ce.current),null)},[]),Oe=(0,H.useCallback)(()=>{Ee&&(we.current=!1,Ce.current=setTimeout(()=>{we.current=!0,N(),Ce.current=null},zz))},[Ee,N]),ke=(0,H.useCallback)(e=>{let t=e.touches[0];Se.current={x:t.clientX,y:t.clientY},he(!1),_e(!1),Oe()},[Oe]),Ae=(0,H.useCallback)(e=>{if(!Se.current)return;let t=e.touches[0],n=t.clientX-Se.current.x,r=t.clientY-Se.current.y;(Math.abs(n)>10||Math.abs(r)>10)&&De(),Ee&&n<-10&&Math.abs(n)>Math.abs(r)*1.5&&(he(!0),pe(Math.max(n,-150)))},[Ee,De]),je=(0,H.useCallback)(()=>{De(),me&&(fe<-Bz&&Ee?(_e(!0),pe(-80)):(pe(0),_e(!1)),he(!1)),Se.current=null},[fe,me,Ee,De]),Me=(0,H.useCallback)(e=>{e.target.closest(`button`)||Oe()},[Oe]),Ne=(0,H.useCallback)(()=>{De()},[De]),Pe=(0,H.useCallback)(e=>{if(we.current){e.stopPropagation(),we.current=!1;return}ge&&(_e(!1),pe(0))},[ge]),Fe=(0,H.useCallback)(e=>{e.stopPropagation(),_e(!1),pe(0),M()},[M]),Ie=y&&Ee?-(Array.from(e).reduce((e,t)=>e+t.charCodeAt(0),0)*53%400):void 0,Le=Ie===void 0?void 0:{animationDelay:`${Ie}ms`};return S===`compact`?(0,Y.jsxs)(`div`,{ref:le,"data-testid":`rail-row-compact-${e}`,"data-density":`compact`,onMouseDown:Me,onMouseUp:Ne,onMouseLeave:Ne,onClick:Pe,style:Le,className:`group relative flex flex-col gap-1.5 rounded-xl border bg-card p-2.5 transition-all ${ce?`border-accent-info/60 shadow-[0_0_0_1px_hsl(var(--accent-info)/0.35),0_0_14px_hsl(var(--accent-info)/0.18)]`:de?`border-dashed border-accent-info/35`:Te?`border-accent-success/40 shadow-sm`:`border-border/40 hover:border-accent-info/30 hover:shadow-md`} ${y&&Ee?`animate-jiggle`:``}`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,Y.jsx)(`button`,{type:`button`,className:`touch-none cursor-grab active:cursor-grabbing text-muted-foreground/30 hover:text-muted-foreground/70 transition-colors shrink-0`,...b,...x,children:(0,Y.jsx)(Jo,{className:`w-3 h-3`})}),(0,Y.jsx)(`div`,{className:`w-1.5 h-1.5 rounded-full shrink-0 transition-all duration-300 ${Te?`bg-accent-success shadow-[0_0_4px_hsl(var(--accent-success)/0.8)] animate-pulse`:i===`failed`?`bg-accent-warning shadow-[0_0_4px_hsl(var(--accent-warning)/0.6)]`:`bg-muted-foreground/25`}`,"aria-hidden":!0}),ve?(0,Y.jsx)(`form`,{className:`flex items-center gap-0.5 min-w-0 flex-1`,onSubmit:e=>{e.preventDefault();let t=G.trim();t&&P(t),ye(!1)},children:(0,Y.jsx)(`input`,{ref:xe,type:`text`,value:G,onChange:e=>be(e.target.value),onBlur:()=>{let e=G.trim();e&&P(e),ye(!1)},onKeyDown:e=>{e.key===`Escape`&&ye(!1)},className:`flex-1 min-w-0 text-xs font-medium bg-transparent border-b border-accent-info/60 outline-none text-foreground/90 px-0.5`,autoFocus:!0})}):(0,Y.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),be(t.startsWith(`Rail `)?t.slice(5):t),ye(!0),setTimeout(()=>xe.current?.select(),0)},className:`flex-1 min-w-0 text-left text-xs font-medium text-foreground/90 hover:text-foreground truncate`,title:t,children:t})]}),n.length>0&&(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-1`,"data-testid":`rail-row-compact-tickets-${e}`,children:n.map(e=>(0,Y.jsxs)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),j(e)},onMouseDown:t=>{t.button===2&&F&&(t.preventDefault(),t.stopPropagation(),se({ticketId:e.id,x:t.clientX,y:t.clientY}))},onContextMenu:e=>{F&&(e.preventDefault(),e.stopPropagation())},onPointerDown:e=>e.stopPropagation(),title:`#${e.id} ${e.title}`,className:`inline-flex items-center px-1.5 py-0.5 rounded-md text-[10px] font-mono font-medium border border-accent-info/30 bg-accent-info/10 text-accent-info hover:bg-accent-info/20 hover:border-accent-info/60 transition-colors`,children:[`#`,e.id]},e.id))}),oe&&F&&(0,sr.createPortal)((0,Y.jsx)(`div`,{role:`menu`,"data-testid":`rail-row-compact-context-menu-${e}`,className:`fixed z-[200] min-w-[160px] rounded-lg border border-border/60 bg-card/95 backdrop-blur shadow-xl shadow-black/40 p-1`,style:{top:Math.min(oe.y,window.innerHeight-60),left:Math.min(oe.x,window.innerWidth-180)},onPointerDown:e=>e.stopPropagation(),children:(0,Y.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:e=>{e.stopPropagation(),F(oe.ticketId),se(null)},className:`w-full flex items-center gap-2 px-2 py-1.5 rounded-md text-left text-xs text-accent-warning hover:bg-accent-warning/10 transition-colors`,children:[(0,Y.jsx)(Ba,{className:`w-3 h-3`,"aria-hidden":!0}),I(`railRow.moveToSpecs`)]})}),document.body),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[T&&!Te&&(0,Y.jsx)(vz,{value:s??null,providers:u??[],onChange:T}),w&&!Te&&L&&r!==`loop`&&(0,Y.jsx)(_z,{value:o??null,onChange:w}),E&&!Te&&r===`freestyle`&&R&&(0,Y.jsx)(xz,{value:c??null,onChange:E}),ie,O&&!Te&&(0,Y.jsx)(Az,{value:hz(f,r),onChange:O,freestyleAvailable:R,loopsEnabled:d}),k&&!Te&&r===`loop`&&z&&(0,Y.jsx)(Pz,{value:p??null,onChange:k}),(0,Y.jsx)(uz,{mode:r,status:i,activeJobId:a,ticketCount:n.length,freestyleAvailable:R,loopAvailable:d,onModeChange:C,onToggle:A})]}),Te&&v&&(0,Y.jsx)(Mz,{metric:v}),m&&(m.merged>0||m.needsReview>0)&&(0,Y.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 text-[10px]`,"data-testid":`rail-worktree-summary`,children:[m.merged>0&&(0,Y.jsx)(`span`,{className:`text-accent-success`,children:I(`railControls.worktreesMerged`,{count:m.merged})}),m.needsReview>0&&(0,Y.jsx)(`span`,{className:`text-accent-warning`,children:I(`railControls.worktreesNeedsReview`,{count:m.needsReview})})]}),h&&g&&(0,Y.jsx)(`div`,{className:`mt-1`,children:(0,Y.jsx)(Fz,{decision:h,density:`compact`,act:g,checkout:_})}),y&&Ee&&(0,Y.jsx)(`button`,{type:`button`,onClick:Fe,className:`absolute -top-1 -right-1 w-5 h-5 flex items-center justify-center rounded-full bg-destructive text-destructive-foreground shadow-sm hover:opacity-90 transition-opacity`,"aria-label":I(`railRow.deleteRail`,{label:t}),children:(0,Y.jsx)(cc,{className:`w-3 h-3`})})]}):(0,Y.jsxs)(`div`,{className:`relative overflow-hidden rounded-xl`,onClick:Pe,onTouchStart:ke,onTouchMove:Ae,onTouchEnd:je,onMouseDown:Me,onMouseUp:Ne,onMouseLeave:Ne,children:[Ee&&(ge||fe<0)&&(0,Y.jsx)(`div`,{className:`absolute inset-y-0 right-0 w-20 flex items-center justify-center bg-red-500/90 rounded-r-xl z-0`,children:(0,Y.jsxs)(`button`,{type:`button`,onClick:Fe,className:`flex flex-col items-center gap-1 text-white`,children:[(0,Y.jsx)(cc,{className:`w-5 h-5`}),(0,Y.jsx)(`span`,{className:`text-[9px] font-medium`,children:I(`common:actions.delete`)})]})}),(0,Y.jsxs)(`div`,{className:`relative z-10 flex flex-col rounded-xl border overflow-hidden bg-card ${y&&Ee?`animate-jiggle`:``} ${ce?`border-primary/50 shadow-[0_0_0_1px_hsl(var(--primary)/0.25),0_0_12px_hsl(var(--primary)/0.08)]`:`border-border/40 hover:border-border/60`}`,style:{transform:fe<0?`translateX(${fe}px)`:void 0,transition:me?`none`:`transform 0.3s cubic-bezier(0.25, 0.1, 0.25, 1)`,...Ie===void 0?{}:{animationDelay:`${Ie}ms`}},children:[(0,Y.jsxs)(`div`,{className:`flex flex-col border-b border-border/30 bg-gradient-to-r from-muted/30 to-transparent shrink-0`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,Y.jsx)(`button`,{type:`button`,className:`touch-none cursor-grab active:cursor-grabbing text-muted-foreground/30 hover:text-muted-foreground/60 transition-colors -ml-1`,...b,...x,children:(0,Y.jsx)(Jo,{className:`w-3.5 h-3.5`})}),(0,Y.jsx)(`div`,{className:`w-1.5 h-1.5 rounded-full shrink-0 transition-all duration-300 ${i===`running`?`bg-emerald-400 shadow-[0_0_4px_hsl(142_70%_56%/0.8)] animate-pulse`:i===`failed`?`bg-amber-400 shadow-[0_0_4px_hsl(38_92%_50%/0.6)]`:`bg-muted-foreground/25`}`}),ve?(0,Y.jsxs)(`form`,{className:`flex items-center gap-0.5`,onSubmit:e=>{e.preventDefault();let t=G.trim();t&&P(t),ye(!1)},children:[(0,Y.jsx)(`span`,{className:`text-xs font-medium text-foreground/50`,children:`Rail `}),(0,Y.jsx)(`input`,{ref:xe,type:`text`,value:G,onChange:e=>be(e.target.value),onBlur:()=>{let e=G.trim();e&&P(e),ye(!1)},onKeyDown:e=>{e.key===`Escape`&&ye(!1)},className:`w-24 text-xs font-medium bg-transparent border-b border-primary/50 outline-none text-foreground/80 px-0.5`,autoFocus:!0})]}):(0,Y.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),be(t.startsWith(`Rail `)?t.slice(5):t),ye(!0),setTimeout(()=>xe.current?.select(),0)},className:`text-xs font-medium text-foreground/80 hover:text-foreground hover:underline decoration-dotted underline-offset-2 cursor-text transition-colors`,children:t}),n.length>0&&(0,Y.jsx)(`span`,{className:`text-[9px] text-muted-foreground bg-muted/30 rounded-full px-1.5 py-0.5 leading-none`,children:n.length})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[!W&&te&&w&&(0,Y.jsx)(_z,{value:o??null,onChange:w}),(0,Y.jsx)(uz,{mode:r,status:i,activeJobId:a,ticketCount:n.length,freestyleAvailable:R,loopAvailable:d,onModeChange:C,onToggle:A}),y&&Ee&&(0,Y.jsx)(`button`,{type:`button`,onClick:Fe,className:`w-5 h-5 flex items-center justify-center rounded-full bg-red-500 text-white shadow-sm hover:bg-red-600 transition-colors`,children:(0,Y.jsx)(cc,{className:`w-3 h-3`})})]})]}),Te&&v&&(0,Y.jsx)(`div`,{className:`px-3 pb-1`,children:(0,Y.jsx)(Mz,{metric:v})}),m&&(m.merged>0||m.needsReview>0)&&(0,Y.jsxs)(`div`,{className:`px-3 pb-1 flex items-center gap-2 text-[10px]`,children:[m.merged>0&&(0,Y.jsx)(`span`,{className:`text-accent-success`,children:I(`railControls.worktreesMerged`,{count:m.merged})}),m.needsReview>0&&(0,Y.jsx)(`span`,{className:`text-accent-warning`,children:I(`railControls.worktreesNeedsReview`,{count:m.needsReview})})]}),h&&g&&(0,Y.jsx)(`div`,{className:`px-3 pb-1.5`,children:(0,Y.jsx)(Fz,{decision:h,density:`normal`,act:g,checkout:_})}),W&&(0,Y.jsxs)(`div`,{className:`flex items-center flex-wrap gap-x-3 gap-y-1 px-3 py-1.5 border-t border-border/20 bg-background/20`,children:[ee&&T&&(0,Y.jsx)(vz,{value:s??null,providers:u??[],onChange:T}),W&&te&&w&&(0,Y.jsx)(_z,{value:o??null,onChange:w}),B&&E&&(0,Y.jsx)(xz,{value:c??null,onChange:E}),ie,ae&&O&&(0,Y.jsx)(Az,{value:hz(f,r),onChange:O,freestyleAvailable:R,loopsEnabled:d}),r===`loop`&&!Te&&z&&k&&(0,Y.jsx)(Pz,{value:p??null,onChange:k})]})]}),(0,Y.jsx)(`div`,{ref:le,"data-drop-target":de?`available`:void 0,className:`min-h-[56px] px-3 py-2 space-y-1.5 transition-colors duration-150 ${ce?`bg-accent-info/[0.06]`:de?`bg-accent-info/[0.02]`:`bg-card/20`}`,children:n.length===0?(0,Y.jsx)(`div`,{className:`h-10 flex items-center justify-center rounded-lg border border-dashed transition-all duration-150 ${ce?`border-accent-info/60 text-accent-info/80 bg-accent-info/[0.06]`:de?`border-accent-info/35 text-accent-info/60`:`border-border/25 text-muted-foreground/30`}`,children:(0,Y.jsx)(`span`,{className:`text-[10px] select-none`,children:I(ce?`railRow.dropHere`:de?`railRow.dropOnThisRail`:`railRow.dragSpecsHere`)})}):(0,Y.jsx)(Vd,{items:n.map(e=>e.id),strategy:Ld,children:n.map(e=>(0,Y.jsx)(`div`,{onMouseDown:t=>{t.button===2&&F&&(t.preventDefault(),t.stopPropagation(),se({ticketId:e.id,x:t.clientX,y:t.clientY}))},onContextMenu:e=>{F&&(e.preventDefault(),e.stopPropagation())},children:(0,Y.jsx)(pg,{ticket:e,onClick:j,dragDisabled:i===`running`})},e.id))})}),oe&&F&&S===`normal`&&(0,sr.createPortal)((0,Y.jsx)(`div`,{role:`menu`,"data-testid":`rail-row-normal-context-menu-${e}`,className:`fixed z-[200] min-w-[160px] rounded-lg border border-border/60 bg-card/95 backdrop-blur shadow-xl shadow-black/40 p-1`,style:{top:Math.min(oe.y,window.innerHeight-60),left:Math.min(oe.x,window.innerWidth-180)},onPointerDown:e=>e.stopPropagation(),children:(0,Y.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:e=>{e.stopPropagation(),F(oe.ticketId),se(null)},className:`w-full flex items-center gap-2 px-2 py-1.5 rounded-md text-left text-xs text-accent-warning hover:bg-accent-warning/10 transition-colors`,children:[(0,Y.jsx)(Ba,{className:`w-3 h-3`,"aria-hidden":!0}),I(`railRow.moveToSpecs`)]})}),document.body)]})]})}function Hz(e){return`rail-${e+1}`}function Uz(e){let t=/^rail-(\d+)$/.exec(e);if(!t)return null;let n=parseInt(t[1],10);return!Number.isInteger(n)||n<1?null:n-1}function Wz(e,t,n,r){return{...e,[t]:{...e[t]??{},[n]:r}}}function Gz(e){if(!e)return null;let t=Object.values(e);if(t.length===0)return null;let n=0,r=0,i=0;for(let e of t)e===`merged`?n++:e===`needs-review`?r++:e===`failed`&&i++;return{merged:n,needsReview:r,failed:i,reported:t.length}}var Kz=`__rail:`;function qz(e){return`${Kz}${e}`}function Jz(e){return typeof e==`string`&&e.startsWith(`__rail:`)}function Yz(e){return e.slice(7)}function Xz(e,t,n){let r=new Set(n),i=Hz(t),a=e.some(e=>e.id===i);return e.map((e,n)=>(a?e.id===i:n===t)?{...e,status:`idle`,activeJobId:void 0,ticketIds:r.size>0?e.ticketIds.filter(e=>!r.has(e)):[]}:e)}function Zz({railId:e,children:t}){let{attributes:n,listeners:r,setNodeRef:i,transform:a,transition:o,isDragging:s}=Yd({id:qz(e)});return(0,Y.jsx)(`div`,{ref:i,style:{transform:Gc.Translate.toString(a),transition:o,opacity:s?.4:void 0,position:`relative`,zIndex:s?50:void 0},children:t({listeners:r??{},attributes:n,isDragging:s})})}function Qz({rails:e,ticketMap:t,railWorktrees:n,railMetrics:r,railPrDecisions:i,onPrDecision:a,onPrCheckout:o,providers:s,onModeChange:c,onProfileChange:l,onEngineChange:u,onFreestyleModelChange:d,onLoopModelChange:f,loopAvailable:p,onLoopChange:m,onEffortChange:h,onToggle:g,onTicketClick:_,onAddRail:v,onDeleteRail:y,onRenameRail:b,onTicketMoveToSpecs:x,onLaunchAll:S,launchAllCount:C}){let{t:w}=K(`dashboard`),T=e.filter(e=>e.status===`running`).length,[E,D]=(0,H.useState)(!1),O=(0,H.useRef)(null),[k,A]=(0,H.useState)(`normal`);(0,H.useEffect)(()=>{if(typeof ResizeObserver>`u`)return;let e=O.current;if(!e)return;let t=new ResizeObserver(e=>{for(let t of e){let e=t.contentRect.width;A(e<320?`compact`:`normal`)}});return t.observe(e),()=>t.disconnect()},[]);let j=(0,H.useCallback)(()=>{E&&D(!1)},[E]);(0,H.useEffect)(()=>{if(!E)return;let e=e=>{e.key===`Escape`&&D(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[E]);let M=e.map(e=>qz(e.id));return(0,Y.jsxs)(`div`,{ref:O,className:`flex flex-col h-full`,"data-density":k,onClick:j,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between px-4 h-12 border-b border-border/40 shrink-0`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(rs,{className:`w-4 h-4 text-muted-foreground`}),(0,Y.jsx)(`h2`,{className:`text-sm font-semibold text-accent-secondary`,children:w(`railsBoard.title`)}),T>0&&(0,Y.jsx)(`span`,{className:`text-[10px] text-emerald-400 aurora-light:text-accent-success bg-emerald-400/10 aurora-light:bg-accent-success/10 rounded-full px-1.5 py-0.5 font-medium whitespace-nowrap`,children:w(`railsBoard.runningCount`,{count:T})})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[S&&(0,Y.jsxs)(`button`,{type:`button`,disabled:(C??0)===0,onClick:e=>{e.stopPropagation(),S()},title:w(`railsBoard.launchAllTitle`),className:`flex items-center gap-1.5 h-7 px-2.5 text-xs font-semibold rounded-md border border-emerald-400/50 text-emerald-400 aurora-light:text-accent-success aurora-light:border-accent-success/50 bg-gradient-to-r from-emerald-400/10 to-accent-primary/10 hover:from-emerald-400/20 hover:to-accent-primary/20 transition-colors disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:from-emerald-400/10 disabled:hover:to-accent-primary/10`,children:[(0,Y.jsx)(Ls,{className:`w-3.5 h-3.5`}),w(`railsBoard.launchAll`),(C??0)>0&&(0,Y.jsx)(`span`,{className:`text-[10px] font-mono rounded-full bg-emerald-400/15 px-1.5 py-0.5 leading-none`,children:C})]}),(0,Y.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),v()},className:`flex items-center gap-1 h-7 px-2.5 text-xs font-medium rounded-md border border-accent-primary/50 text-accent-primary hover:bg-accent-primary/10 transition-colors`,children:[(0,Y.jsx)(ks,{className:`w-3.5 h-3.5`}),w(`common:actions.add`)]})]})]}),(0,Y.jsx)(`div`,{className:`flex-1 overflow-y-auto px-4 py-3 flex flex-col gap-2.5`,children:(0,Y.jsx)(Vd,{items:M,strategy:Ld,children:e.map((e,v)=>{let S=Uz(e.id)??v;return(0,Y.jsx)(Zz,{railId:e.id,children:({listeners:C,attributes:w})=>(0,Y.jsx)(`div`,{"data-tour":v===0?`rail-1`:void 0,children:(0,Y.jsx)(Vz,{id:e.id,label:e.label,tickets:e.ticketIds.map(e=>t.get(e)).filter(e=>e!==void 0),mode:e.mode,status:e.status,activeJobId:e.activeJobId,profileName:e.profileName??null,aiEngine:e.aiEngine??null,freestyleModel:e.freestyleModel??null,loopModel:e.loopModel??null,worktreeSummary:Gz(n?.[S]),prDecision:i?.get(S)??null,onPrDecision:a?(e,t)=>a(S,e,t):void 0,onPrCheckout:o?()=>o(S):void 0,executionMetric:r?.[S]??null,providers:s,loopAvailable:p,selectedLoopId:e.selectedLoopId??null,reasoningEffort:e.reasoningEffort??null,jiggleMode:E,density:k,dragHandleListeners:C,dragHandleAttributes:w,onModeChange:t=>c(e.id,t),onProfileChange:l?t=>l(e.id,t):void 0,onEngineChange:u?t=>u(e.id,t):void 0,onFreestyleModelChange:d?t=>d(e.id,t):void 0,onLoopModelChange:f?t=>f(e.id,t):void 0,onLoopChange:m?t=>m(e.id,t):void 0,onEffortChange:h?t=>h(e.id,t):void 0,onToggle:()=>g(e.id),onTicketClick:_,onDelete:()=>y(e.id),onLongPress:()=>D(!0),onRename:t=>b(e.id,t),onTicketMoveToSpecs:x})})},e.id)})})})]})}var $z=new Set([`editing`,`writing`,`reading`,`searching`,`running`]);function eB(e){return e.length>40?`${e.slice(0,39)}…`:e}function tB(e){return typeof e!=`string`||e.length===0?``:eB(e.replace(/\\/g,`/`).split(`/`).filter(Boolean).pop()??``)}function nB(e){return typeof e!=`string`||e.length===0?``:eB(e.trim().split(/\s+/)[0]??``)}function rB(e){if(typeof e!=`string`)return``;try{let t=JSON.parse(e)?.command;if(Array.isArray(t))return nB(t.filter(e=>typeof e==`string`).join(` `));if(typeof t==`string`)return nB(t)}catch{}return``}function iB(e,t){let n=t??{},r=tB(n.file_path??n.path);switch(e){case`Edit`:case`MultiEdit`:case`NotebookEdit`:case`Update`:return{step:!0,actionKey:`editing`,actionArg:r};case`Write`:case`create`:return{step:!0,actionKey:`writing`,actionArg:r};case`Read`:return{step:!0,actionKey:`reading`,actionArg:r};case`Grep`:case`Glob`:case`search`:return{step:!0,actionKey:`searching`,actionArg:eB(String(n.pattern??n.query??``))};case`Bash`:case`shell`:return{step:!0,actionKey:`running`,actionArg:nB(n.command)};default:return{step:!0,actionKey:`working`}}}function aB(e){let t=e.event_type,n={};try{let t=JSON.parse(e.payload);t&&typeof t==`object`&&!Array.isArray(t)&&(n=t)}catch{}if(t===`assistant`){let e=n.message?.content;if(Array.isArray(e)){let t=e.filter(e=>e?.type===`tool_use`);if(t.length>0){let e=t[t.length-1];return{...iB(e.name,e.input),stepCount:t.length}}if(e.some(e=>e?.type===`text`))return{step:!0,actionKey:`thinking`}}return{step:!0}}if(t===`tool_use`)return iB(n.name,n.input);if(t===`item.completed`){let e=n.item,t=e?.type;return t===`agent_message`?{step:!0,actionKey:`thinking`}:t===`agent_reasoning`?{step:!0,actionKey:`reasoning`}:t===`function_call`||t===`local_shell_call`||t===`command_execution`?{step:!0,actionKey:`running`,actionArg:nB(e?.command)||rB(e?.arguments)||(typeof e?.name==`string`?eB(e.name):``)||(t===`local_shell_call`?`shell`:``)}:{step:!0}}return{step:!1}}var oB=(0,H.createContext)({});function sB(){return(0,H.useContext)(oB)}function cB({activeProjectId:e,children:t}){let[n,r]=(0,H.useState)(new Map),{registerHandler:i,unregisterHandler:a}=df(),o=(0,H.useRef)(e);(0,H.useEffect)(()=>{o.current=e},[e]),(0,H.useEffect)(()=>{if(r(new Map),!e)return;let t=!1;return fetch(`/api/projects/${e}/rails`).then(e=>e.ok?e.json():null).then(e=>{if(t||!e?.activeLoopRuns)return;let n=new Map;for(let[t,r]of Object.entries(e.activeLoopRuns))r?.loopRunId&&n.set(r.loopRunId,{railIndex:Number(t),startedAt:r.startedAt?new Date(r.startedAt).getTime():Date.now(),steps:r.steps??0,lines:r.lines??0});n.size!==0&&r(e=>{let t=new Map(e);for(let[e,r]of n)t.has(e)||t.set(e,r);return t})}).catch(()=>{}),()=>{t=!0}},[e]);let s=(0,H.useCallback)(e=>{let t=e;if(!(!t||typeof t.type!=`string`)){if(t.type===`loop.run_started`){if(t.projectId!==o.current||!t.loopRunId)return;r(e=>{let n=new Map(e);return n.set(t.loopRunId,{railIndex:t.railIndex??0,startedAt:Date.now(),steps:0,lines:0}),n});return}if(t.type===`loop.run_completed`){r(e=>{if(!t.loopRunId||!e.has(t.loopRunId))return e;let n=new Map(e);return n.delete(t.loopRunId),n});return}if(t.type===`rail.job_started`){if(t.projectId!==o.current||!t.jobId||t.railIndex==null)return;r(e=>{let n=new Map(e);return n.set(t.jobId,{railIndex:t.railIndex,startedAt:Date.now(),steps:0,lines:0}),n});return}if(t.type===`rail.job_completed`||t.type===`rail.job_stopped`){r(e=>{if(!t.jobId||!e.has(t.jobId))return e;let n=new Map(e);return n.delete(t.jobId),n});return}if(t.type===`event`&&t.event_type&&t.jobId){let e=aB({event_type:t.event_type,payload:t.payload??``});if(!e.step)return;r(n=>{let r=n.get(t.jobId);if(!r)return n;let i=new Map(n);return i.set(t.jobId,{...r,steps:r.steps+(e.stepCount??1)}),i});return}t.type===`log`&&t.processId&&r(e=>{let n=e.get(t.processId);if(!n)return e;let r=new Map(e);return r.set(t.processId,{...n,lines:n.lines+1}),r})}},[]);(0,H.useLayoutEffect)(()=>(i(`rail-exec-metrics`,s),()=>a(`rail-exec-metrics`)),[s,i,a]);let c=(0,H.useMemo)(()=>{let e={};for(let t of n.values()){let n=e[t.railIndex];n?(n.startedAt=Math.min(n.startedAt,t.startedAt),n.steps+=t.steps,n.lines+=t.lines):e[t.railIndex]={startedAt:t.startedAt,steps:t.steps,lines:t.lines}}return e},[n]);return(0,Y.jsx)(oB.Provider,{value:c,children:t})}var lB=(0,H.createContext)({decisions:new Map,hydrated:!0,act:async()=>({status:0,ok:!1,error:`no_provider`}),checkout:async()=>({status:0,ok:!1,error:`no_provider`})});function uB(){return(0,H.useContext)(lB)}function dB(e,t){return!e?.id||!e.decision?null:{prDeliveryId:e.id,railIndex:e.railIndex??t,railKey:e.railKey??``,ticketIds:Array.isArray(e.ticketIds)?e.ticketIds:[],baseBranch:e.baseBranch??``,branch:e.branch??null,prUrl:e.prUrl??null,prNumber:e.prNumber??null,prState:e.prState??`none`,decision:e.decision,runIds:Array.isArray(e.runIds)?e.runIds:[],originConversationId:e.originConversationId??null}}var fB=new Set([`merged`,`discarded`]);function pB({activeProjectId:e,children:t}){let{t:n}=K(`dashboard`),[r,i]=(0,H.useState)(new Map),[a,o]=(0,H.useState)(!1),{registerHandler:s,unregisterHandler:c}=df(),l=(0,H.useRef)(e);(0,H.useEffect)(()=>{l.current=e},[e]);let u=(0,H.useRef)(r);(0,H.useEffect)(()=>{u.current=r},[r]);let d=(0,H.useRef)(new Set);(0,H.useEffect)(()=>{if(i(new Map),o(!1),d.current=new Set,!e){o(!0);return}let t=!1;return fetch(`/api/projects/${e}/rails`).then(e=>e.ok?e.json():null).then(e=>{if(t)return;if(!e?.prDeliveries){o(!0);return}let n=new Map;for(let[t,r]of Object.entries(e.prDeliveries)){let e=dB(r,Number(t));e&&!fB.has(e.decision)&&n.set(Number(t),e)}n.size>0&&i(e=>{let t=new Map(e);for(let[e,r]of n)d.current.has(e)||t.set(e,r);return t}),o(!0)}).catch(()=>{t||o(!0)}),()=>{t=!0}},[e]);let f=(0,H.useCallback)(e=>{let t=e;if(!t||t.type!==`rail.pr_state`||t.projectId!==l.current||typeof t.railIndex!=`number`||typeof t.prDeliveryId!=`string`||!t.decision)return;let r=t,a={prDeliveryId:r.prDeliveryId,railIndex:r.railIndex,railKey:r.railKey??``,ticketIds:Array.isArray(r.ticketIds)?r.ticketIds:[],baseBranch:r.baseBranch??``,branch:r.branch??null,prUrl:r.prUrl??null,prNumber:r.prNumber??null,prState:r.prState??`none`,decision:r.decision,runIds:Array.isArray(r.runIds)?r.runIds:[],originConversationId:r.originConversationId??null};if(d.current.add(a.railIndex),fB.has(a.decision)){i(e=>{if(!e.has(a.railIndex))return e;a.decision===`merged`?q.success(n(`railPr.mergedToast`)):q.info(n(`railPr.discardedToast`));let t=new Map(e);return t.delete(a.railIndex),t});return}i(e=>{let t=new Map(e);return t.set(a.railIndex,a),t})},[n]);(0,H.useLayoutEffect)(()=>(s(`rail-pr-decision`,f),()=>c(`rail-pr-decision`)),[f,s,c]);let p=(0,H.useCallback)(async(e,t,n)=>{let r=u.current.get(e),i=l.current;if(!r||!i)return{status:0,ok:!1,error:`no_delivery`};try{let e=await fetch(`/api/projects/${i}/rails/pr-decision`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({prDeliveryId:r.prDeliveryId,action:t,expectedDecision:n})}),a=await e.json().catch(()=>({}));return{...a,status:e.status,ok:e.ok&&a.ok===!0}}catch(e){return{status:0,ok:!1,error:`network`,detail:e.message}}},[]),m=(0,H.useCallback)(async e=>{let t=u.current.get(e),n=l.current;if(!t||!n)return{status:0,ok:!1,error:`no_delivery`};try{let e=await fetch(`/api/projects/${n}/rails/pr-checkout`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({prDeliveryId:t.prDeliveryId})}),r=await e.json().catch(()=>({}));return{...r,status:e.status,ok:e.ok&&r.ok===!0}}catch(e){return{status:0,ok:!1,error:`network`,detail:e.message}}},[]),h=(0,H.useMemo)(()=>({decisions:r,hydrated:a,act:p,checkout:m}),[r,a,p,m]);return(0,Y.jsx)(lB.Provider,{value:h,children:t})}function mB(e){return e?`specrails-desktop:dashboard-split:${e}`:null}function hB(e){let t=mB(e);if(!t)return null;try{let e=localStorage.getItem(t);if(!e)return null;let n=Number.parseInt(e,10);return Number.isFinite(n)&&n>0?n:null}catch{return null}}function gB(e,t){let n=mB(e);if(n)try{localStorage.setItem(n,String(Math.round(t)))}catch{}}function _B(e,t){let n=Math.max(320,t-280);return Math.min(Math.max(e,320),n)}var vB=.7;function yB(e){return _B(Math.round(e*vB),e)}function bB(e,t){let n=yB(t);return Math.abs(e-n)<=48?n:e}function xB(e,t){let[n,r]=(0,H.useState)(()=>typeof window<`u`?window.innerWidth:1200),i=(0,H.useRef)(n),[a,o]=(0,H.useState)(()=>{if(typeof window>`u`)return null;let e=window.innerWidth;return e<900?null:yB(e)}),s=(0,H.useRef)(null),c=(0,H.useRef)(null),l=(0,H.useRef)(null);(0,H.useEffect)(()=>{if(typeof window>`u`)return;let e=t?.current?.clientWidth||window.innerWidth;if(r(e),i.current=e,e<900){o(null);return}o(yB(e))},[e,t]),(0,H.useEffect)(()=>{function n(t){if(r(t),t<900){i.current=t,o(null);return}let n=t-i.current;i.current=t,o(r=>{let i=r??hB(e)??yB(t),a=_B(r!==null&&Number.isFinite(n)?i+n:i,t);return a!==r&&gB(e,a),a})}let a=t?.current;if(a&&typeof ResizeObserver<`u`){let e=new ResizeObserver(e=>{let t=e[0]?.contentRect.width;typeof t==`number`&&n(t)});return e.observe(a),n(a.clientWidth||window.innerWidth),()=>e.disconnect()}function s(){n(window.innerWidth)}return window.addEventListener(`resize`,s),()=>window.removeEventListener(`resize`,s)},[e,t]);let u=(0,H.useCallback)(()=>{if(c.current=null,l.current===null)return;let e=_B(l.current,n);l.current=null,o(e)},[n]),d=(0,H.useCallback)(e=>{if(!s.current)return;let t=e.clientX-s.current.startClientX;l.current=s.current.startLeftWidth+t,c.current===null&&(c.current=requestAnimationFrame(u))},[u]),f=(0,H.useCallback)(t=>{if(!s.current)return;let{pointerId:r,element:i}=s.current;try{i.releasePointerCapture(r)}catch{}s.current=null,window.removeEventListener(`pointermove`,d),window.removeEventListener(`pointerup`,f),window.removeEventListener(`pointercancel`,f),o(t=>{if(t===null)return t;let r=_B(bB(t,n),n);return gB(e,r),r})},[d,e,n]),p=(0,H.useCallback)(e=>{let t=e.nativeEvent??e,n=e.currentTarget??t.target;try{n.setPointerCapture(t.pointerId)}catch{}s.current={pointerId:t.pointerId,element:n,startClientX:t.clientX,startLeftWidth:a??0},window.addEventListener(`pointermove`,d),window.addEventListener(`pointerup`,f),window.addEventListener(`pointercancel`,f)},[d,f,a]),m=(0,H.useCallback)(()=>{if(typeof window>`u`)return;let n=t?.current?.clientWidth||window.innerWidth;if(n<900)return;let r=yB(n);o(r),gB(e,r)},[e,t]);return{leftWidth:a,enabled:a!==null&&n>=900,beginDrag:p,resetToDefault:m}}function SB({leftWidth:e,onPointerDown:t,onReset:n,viewport:r}){let i=(0,H.useCallback)(t=>{let n=t.shiftKey?64:16;t.key===`ArrowLeft`&&(t.preventDefault(),e-n)},[e]);return(0,Y.jsxs)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-valuenow":e,"aria-valuemin":320,"aria-valuemax":Math.max(320,r-280),tabIndex:0,onPointerDown:t,onDoubleClick:n,onKeyDown:i,className:`relative w-1.5 shrink-0 cursor-col-resize group select-none touch-none focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-info/60`,"data-testid":`dashboard-splitter`,children:[(0,Y.jsx)(`div`,{className:`absolute inset-y-0 left-1/2 -translate-x-1/2 w-px bg-border/40 group-hover:bg-accent-info/40 group-focus-visible:bg-accent-info/60 transition-colors`}),(0,Y.jsxs)(`div`,{className:`absolute inset-y-0 left-1/2 -translate-x-1/2 flex flex-col items-center justify-center gap-1 pointer-events-none opacity-0 group-hover:opacity-100 transition-opacity`,children:[(0,Y.jsx)(`div`,{className:`w-1 h-1 rounded-full bg-accent-info/60`}),(0,Y.jsx)(`div`,{className:`w-1 h-1 rounded-full bg-accent-info/60`}),(0,Y.jsx)(`div`,{className:`w-1 h-1 rounded-full bg-accent-info/60`})]})]})}function CB(e,t){return Mf(e,{...t,weekStartsOn:1})}function wB(e,t){let n=jf(e,t?.in),r=n.getFullYear(),i=Df(n,0);i.setFullYear(r+1,0,4),i.setHours(0,0,0,0);let a=CB(i),o=Df(n,0);o.setFullYear(r,0,4),o.setHours(0,0,0,0);let s=CB(o);return n.getTime()>=a.getTime()?r+1:n.getTime()>=s.getTime()?r:r-1}function TB(e){let t=jf(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),e-+n}function EB(e,t){let n=jf(e,t?.in);return n.setHours(0,0,0,0),n}function DB(e,t,n){let[r,i]=Of(n?.in,e,t),a=EB(r),o=EB(i),s=+a-TB(a),c=+o-TB(o);return Math.round((s-c)/bf)}function OB(e,t){let n=wB(e,t),r=Df(t?.in||e,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),CB(r)}function kB(e,t){let n=jf(e)-+jf(t);return n<0?-1:n>0?1:n}function AB(e){return Df(e,Date.now())}function jB(e){return e instanceof Date||typeof e==`object`&&Object.prototype.toString.call(e)===`[object Date]`}function MB(e){return!(!jB(e)&&typeof e!=`number`||isNaN(+jf(e)))}function NB(e,t,n){let[r,i]=Of(n?.in,e,t),a=r.getFullYear()-i.getFullYear(),o=r.getMonth()-i.getMonth();return a*12+o}function PB(e){return t=>{let n=(e?Math[e]:Math.trunc)(t);return n===0?0:n}}function FB(e,t){return jf(e)-+jf(t)}function IB(e,t){let n=jf(e,t?.in);return n.setHours(23,59,59,999),n}function LB(e,t){let n=jf(e,t?.in),r=n.getMonth();return n.setFullYear(n.getFullYear(),r+1,0),n.setHours(23,59,59,999),n}function RB(e,t){let n=jf(e,t?.in);return+IB(n,t)==+LB(n,t)}function zB(e,t,n){let[r,i,a]=Of(n?.in,e,e,t),o=kB(i,a),s=Math.abs(NB(i,a));if(s<1)return 0;i.getMonth()===1&&i.getDate()>27&&i.setDate(30),i.setMonth(i.getMonth()-o*s);let c=kB(i,a)===-o;RB(r)&&s===1&&kB(r,a)===1&&(c=!1);let l=o*(s-+c);return l===0?0:l}function BB(e,t,n){let r=FB(e,t)/1e3;return PB(n?.roundingMethod)(r)}function VB(e,t){let n=jf(e,t?.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}function HB(e,t){let n=jf(e,t?.in);return DB(n,VB(n))+1}function UB(e,t){let n=jf(e,t?.in),r=CB(n)-+OB(n);return Math.round(r/yf)+1}function WB(e,t){let n=jf(e,t?.in),r=n.getFullYear(),i=Af(),a=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??i.firstWeekContainsDate??i.locale?.options?.firstWeekContainsDate??1,o=Df(t?.in||e,0);o.setFullYear(r+1,0,a),o.setHours(0,0,0,0);let s=Mf(o,t),c=Df(t?.in||e,0);c.setFullYear(r,0,a),c.setHours(0,0,0,0);let l=Mf(c,t);return+n>=+s?r+1:+n>=+l?r:r-1}function GB(e,t){let n=Af(),r=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,i=WB(e,t),a=Df(t?.in||e,0);return a.setFullYear(i,0,r),a.setHours(0,0,0,0),Mf(a,t)}function KB(e,t){let n=jf(e,t?.in),r=Mf(n,t)-+GB(n,t);return Math.round(r/yf)+1}function qB(e,t){return(e<0?`-`:``)+Math.abs(e).toString().padStart(t,`0`)}var JB={y(e,t){let n=e.getFullYear(),r=n>0?n:1-n;return qB(t===`yy`?r%100:r,t.length)},M(e,t){let n=e.getMonth();return t===`M`?String(n+1):qB(n+1,2)},d(e,t){return qB(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 qB(e.getHours()%12||12,t.length)},H(e,t){return qB(e.getHours(),t.length)},m(e,t){return qB(e.getMinutes(),t.length)},s(e,t){return qB(e.getSeconds(),t.length)},S(e,t){let n=t.length,r=e.getMilliseconds();return qB(Math.trunc(r*10**(n-3)),t.length)}},YB={am:`am`,pm:`pm`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},XB={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 JB.y(e,t)},Y:function(e,t,n,r){let i=WB(e,r),a=i>0?i:1-i;return t===`YY`?qB(a%100,2):t===`Yo`?n.ordinalNumber(a,{unit:`year`}):qB(a,t.length)},R:function(e,t){return qB(wB(e),t.length)},u:function(e,t){return qB(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 qB(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 qB(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 JB.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 qB(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=KB(e,r);return t===`wo`?n.ordinalNumber(i,{unit:`week`}):qB(i,t.length)},I:function(e,t,n){let r=UB(e);return t===`Io`?n.ordinalNumber(r,{unit:`week`}):qB(r,t.length)},d:function(e,t,n){return t===`do`?n.ordinalNumber(e.getDate(),{unit:`date`}):JB.d(e,t)},D:function(e,t,n){let r=HB(e);return t===`Do`?n.ordinalNumber(r,{unit:`dayOfYear`}):qB(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 qB(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 qB(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 qB(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?YB.noon:r===0?YB.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?YB.evening:r>=12?YB.afternoon:r>=4?YB.morning:YB.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 JB.h(e,t)},H:function(e,t,n){return t===`Ho`?n.ordinalNumber(e.getHours(),{unit:`hour`}):JB.H(e,t)},K:function(e,t,n){let r=e.getHours()%12;return t===`Ko`?n.ordinalNumber(r,{unit:`hour`}):qB(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t===`ko`?n.ordinalNumber(r,{unit:`hour`}):qB(r,t.length)},m:function(e,t,n){return t===`mo`?n.ordinalNumber(e.getMinutes(),{unit:`minute`}):JB.m(e,t)},s:function(e,t,n){return t===`so`?n.ordinalNumber(e.getSeconds(),{unit:`second`}):JB.s(e,t)},S:function(e,t){return JB.S(e,t)},X:function(e,t,n){let r=e.getTimezoneOffset();if(r===0)return`Z`;switch(t){case`X`:return QB(r);case`XXXX`:case`XX`:return $B(r);default:return $B(r,`:`)}},x:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`x`:return QB(r);case`xxxx`:case`xx`:return $B(r);default:return $B(r,`:`)}},O:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`O`:case`OO`:case`OOO`:return`GMT`+ZB(r,`:`);default:return`GMT`+$B(r,`:`)}},z:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`z`:case`zz`:case`zzz`:return`GMT`+ZB(r,`:`);default:return`GMT`+$B(r,`:`)}},t:function(e,t,n){return qB(Math.trunc(e/1e3),t.length)},T:function(e,t,n){return qB(+e,t.length)}};function ZB(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+qB(a,2)}function QB(e,t){return e%60==0?(e>0?`-`:`+`)+qB(Math.abs(e)/60,2):$B(e,t)}function $B(e,t=``){let n=e>0?`-`:`+`,r=Math.abs(e),i=qB(Math.trunc(r/60),2),a=qB(r%60,2);return n+i+t+a}var eV=(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`})}},tV=(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`})}},nV={p:tV,P:(e,t)=>{let n=e.match(/(P+)(p+)?/)||[],r=n[1],i=n[2];if(!i)return eV(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}}`,eV(r,t)).replace(`{{time}}`,tV(i,t))}},rV=/^D+$/,iV=/^Y+$/,aV=[`D`,`DD`,`YY`,`YYYY`];function oV(e){return rV.test(e)}function sV(e){return iV.test(e)}function cV(e,t,n){let r=lV(e,t,n);if(console.warn(r),aV.includes(e))throw RangeError(r)}function lV(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 uV=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,dV=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,fV=/^'([^]*?)'?$/,pV=/''/g,mV=/[a-zA-Z]/;function hV(e,t,n){let r=Af(),i=n?.locale??r.locale??Xf,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=jf(e,n?.in);if(!MB(s))throw RangeError(`Invalid time value`);let c=t.match(dV).map(e=>{let t=e[0];if(t===`p`||t===`P`){let n=nV[t];return n(e,i.formatLong)}return e}).join(``).match(uV).map(e=>{if(e===`''`)return{isToken:!1,value:`'`};let t=e[0];if(t===`'`)return{isToken:!1,value:gV(e)};if(XB[t])return{isToken:!0,value:e};if(t.match(mV))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&&sV(a)||!n?.useAdditionalDayOfYearTokens&&oV(a))&&cV(a,t,String(e));let o=XB[a[0]];return o(s,a,i.localize,l)}).join(``)}function gV(e){let t=e.match(fV);return t?t[1].replace(pV,`'`):e}function _V(e,t,n){let r=Af(),i=n?.locale??r.locale??Xf,a=kB(e,t);if(isNaN(a))throw RangeError(`Invalid time value`);let o=Object.assign({},n,{addSuffix:n?.addSuffix,comparison:a}),[s,c]=Of(n?.in,...a>0?[t,e]:[e,t]),l=BB(c,s),u=(TB(c)-TB(s))/1e3,d=Math.round((l-u)/60),f;if(d<2)return n?.includeSeconds?l<5?i.formatDistance(`lessThanXSeconds`,5,o):l<10?i.formatDistance(`lessThanXSeconds`,10,o):l<20?i.formatDistance(`lessThanXSeconds`,20,o):l<40?i.formatDistance(`halfAMinute`,0,o):l<60?i.formatDistance(`lessThanXMinutes`,1,o):i.formatDistance(`xMinutes`,1,o):d===0?i.formatDistance(`lessThanXMinutes`,1,o):i.formatDistance(`xMinutes`,d,o);if(d<45)return i.formatDistance(`xMinutes`,d,o);if(d<90)return i.formatDistance(`aboutXHours`,1,o);if(d<1440){let e=Math.round(d/60);return i.formatDistance(`aboutXHours`,e,o)}else if(d<2520)return i.formatDistance(`xDays`,1,o);else if(d<43200){let e=Math.round(d/wf);return i.formatDistance(`xDays`,e,o)}else if(d<43200*2)return f=Math.round(d/Cf),i.formatDistance(`aboutXMonths`,f,o);if(f=zB(c,s),f<12){let e=Math.round(d/Cf);return i.formatDistance(`xMonths`,e,o)}else{let e=f%12,t=Math.trunc(f/12);return e<3?i.formatDistance(`aboutXYears`,t,o):e<9?i.formatDistance(`overXYears`,t,o):i.formatDistance(`almostXYears`,t+1,o)}}function vV(e,t){return _V(e,AB(e),t)}function yV(e,t){let n=()=>Df(t?.in,NaN),r=t?.additionalDigits??2,i=wV(e),a;if(i.date){let e=TV(i.date,r);a=EV(e.restDateString,e.year)}if(!a||isNaN(+a))return n();let o=+a,s=0,c;if(i.time&&(s=OV(i.time),isNaN(s)))return n();if(i.timezone){if(c=AV(i.timezone),isNaN(c))return n()}else{let e=new Date(o+s),n=jf(0,t?.in);return n.setFullYear(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()),n.setHours(e.getUTCHours(),e.getUTCMinutes(),e.getUTCSeconds(),e.getUTCMilliseconds()),n}return jf(o+s+c,t?.in)}var bV={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},xV=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,SV=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,CV=/^([+-])(\d{2})(?::?(\d{2}))?$/;function wV(e){let t={},n=e.split(bV.dateTimeDelimiter),r;if(n.length>2)return t;if(/:/.test(n[0])?r=n[0]:(t.date=n[0],r=n[1],bV.timeZoneDelimiter.test(t.date)&&(t.date=e.split(bV.timeZoneDelimiter)[0],r=e.substr(t.date.length,e.length))),r){let e=bV.timezone.exec(r);e?(t.time=r.replace(e[1],``),t.timezone=e[1]):t.time=r}return t}function TV(e,t){let n=RegExp(`^(?:(\\d{4}|[+-]\\d{`+(4+t)+`})|(\\d{2}|[+-]\\d{`+(2+t)+`})$)`),r=e.match(n);if(!r)return{year:NaN,restDateString:``};let i=r[1]?parseInt(r[1]):null,a=r[2]?parseInt(r[2]):null;return{year:a===null?i:a*100,restDateString:e.slice((r[1]||r[2]).length)}}function EV(e,t){if(t===null)return new Date(NaN);let n=e.match(xV);if(!n)return new Date(NaN);let r=!!n[4],i=DV(n[1]),a=DV(n[2])-1,o=DV(n[3]),s=DV(n[4]),c=DV(n[5])-1;if(r)return IV(t,s,c)?jV(t,s,c):new Date(NaN);{let e=new Date(0);return!PV(t,a,o)||!FV(t,i)?new Date(NaN):(e.setUTCFullYear(t,a,Math.max(i,o)),e)}}function DV(e){return e?parseInt(e):1}function OV(e){let t=e.match(SV);if(!t)return NaN;let n=kV(t[1]),r=kV(t[2]),i=kV(t[3]);return LV(n,r,i)?n*Sf+r*xf+i*1e3:NaN}function kV(e){return e&&parseFloat(e.replace(`,`,`.`))||0}function AV(e){if(e===`Z`)return 0;let t=e.match(CV);if(!t)return 0;let n=t[1]===`+`?-1:1,r=parseInt(t[2]),i=t[3]&&parseInt(t[3])||0;return RV(r,i)?n*(r*Sf+i*xf):NaN}function jV(e,t,n){let r=new Date(0);r.setUTCFullYear(e,0,4);let i=r.getUTCDay()||7,a=(t-1)*7+n+1-i;return r.setUTCDate(r.getUTCDate()+a),r}var MV=[31,null,31,30,31,30,31,31,30,31,30,31];function NV(e){return e%400==0||e%4==0&&e%100!=0}function PV(e,t,n){return t>=0&&t<=11&&n>=1&&n<=(MV[t]||(NV(e)?29:28))}function FV(e,t){return t>=1&&t<=(NV(e)?366:365)}function IV(e,t,n){return t>=1&&t<=53&&n>=0&&n<=6}function LV(e,t,n){return e===24?t===0&&n===0:n>=0&&n<60&&t>=0&&t<60&&e>=0&&e<25}function RV(e,t){return t>=0&&t<=59}function zV(){return typeof window<`u`&&window.__TAURI_INTERNALS__!==void 0}function BV(e){return Function(`s`,`return import(s)`)(e).catch(()=>null)}async function VV(e){if(zV()){try{let t=await BV(`@tauri-apps/plugin-opener`);if(t?.revealItemInDir){await t.revealItemInDir(e);return}}catch{}try{await(await BV(`@tauri-apps/api/shell`))?.open?.(e)}catch{}}}async function HV(e){if(zV())try{let t=await a(()=>import(`./dist-js-CgpP6tKI.js`),[]);if(typeof t.open==`function`){await t.open(e);return}}catch(e){console.warn(`[openExternalUrl] tauri shell open failed:`,e)}try{window.open(e,`_blank`,`noopener,noreferrer`)}catch{}}function UV({ticketKey:e,attachment:t,onClose:n}){let{t:r}=K(`attachments`),[i,a]=(0,H.useState)(null),[o,s]=(0,H.useState)(null);if((0,H.useEffect)(()=>{if(!t)return;function e(e){e.key===`Escape`&&n()}document.addEventListener(`keydown`,e);let r=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.removeEventListener(`keydown`,e),document.body.style.overflow=r}},[t,n]),(0,H.useEffect)(()=>{if(!t){a(null),s(null);return}let n=!1;return a(null),s(null),ED(e,t.id).then(e=>{n||a(URL.createObjectURL(e))}).catch(e=>{n||s(e instanceof Error?e.message:r(`errors.loadFailed`))}),()=>{n=!0}},[t,e]),(0,H.useEffect)(()=>()=>{i&&URL.revokeObjectURL(i)},[i]),!t)return null;let c=t.mimeType.startsWith(`image/`),l=t.mimeType===`application/pdf`;return(0,Y.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":r(`lightbox.preview`,{name:t.filename}),className:`fixed inset-0 z-[100] flex flex-col bg-black/85 backdrop-blur-sm animate-in fade-in-0 duration-200`,onClick:n,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b border-white/10 bg-black/40`,onClick:e=>e.stopPropagation(),children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:n,"aria-label":r(`lightbox.backToDesktop`),className:`inline-flex items-center gap-2 px-3 py-1.5 rounded-md text-sm text-white/85 hover:bg-white/10 hover:text-white transition-colors`,children:[(0,Y.jsx)(Ba,{className:`w-4 h-4`}),r(`common:actions.back`)]}),(0,Y.jsxs)(`div`,{className:`flex-1 text-center min-w-0 px-4`,children:[(0,Y.jsx)(`div`,{className:`text-sm font-medium text-white/95 truncate`,children:t.filename}),(0,Y.jsx)(`div`,{className:`text-[11px] text-white/50`,children:t.mimeType})]}),(0,Y.jsxs)(`a`,{href:i??`#`,download:t.filename,onClick:e=>{e.stopPropagation(),i||e.preventDefault()},className:`inline-flex items-center gap-2 px-3 py-1.5 rounded-md text-sm text-white/85 hover:bg-white/10 hover:text-white transition-colors`,"aria-label":r(`lightbox.download`),children:[(0,Y.jsx)(To,{className:`w-4 h-4`}),r(`lightbox.download`)]})]}),(0,Y.jsx)(`div`,{className:X(`flex-1 flex items-center justify-center overflow-auto p-6`),onClick:n,children:o?(0,Y.jsx)(`div`,{onClick:e=>e.stopPropagation(),className:`text-center text-white/80 px-8 py-10 rounded-lg bg-white/5 border border-white/10`,children:(0,Y.jsx)(`p`,{className:`text-sm`,children:r(`lightbox.loadError`,{error:o})})}):i?c?(0,Y.jsx)(`img`,{src:i,alt:t.filename,onClick:e=>e.stopPropagation(),className:`max-h-full max-w-full rounded-lg shadow-2xl animate-in zoom-in-95 duration-200`}):l?(0,Y.jsx)(`iframe`,{src:i,title:t.filename,onClick:e=>e.stopPropagation(),className:`w-full h-full max-w-5xl bg-white rounded-lg shadow-2xl`}):(0,Y.jsxs)(`div`,{onClick:e=>e.stopPropagation(),className:`text-center text-white/80 px-8 py-10 rounded-lg bg-white/5 border border-white/10`,children:[(0,Y.jsx)(`p`,{className:`text-sm mb-3`,children:r(`lightbox.previewUnavailable`)}),(0,Y.jsxs)(`a`,{href:i,download:t.filename,className:`inline-flex items-center gap-2 px-4 py-2 rounded-md bg-white/10 hover:bg-white/20 text-white transition-colors`,children:[(0,Y.jsx)(To,{className:`w-4 h-4`}),r(`lightbox.downloadFile`,{name:t.filename})]})]}):(0,Y.jsx)(`div`,{onClick:e=>e.stopPropagation(),className:`text-center text-white/70 px-8 py-10 rounded-lg bg-white/5 border border-white/10`,children:(0,Y.jsx)(`p`,{className:`text-sm`,children:r(`lightbox.loading`)})})})]})}function WV(e,t){let n=new Set,r=[];for(let i of[...e,...t])n.has(i.id)||(n.add(i.id),r.push(i));return r}function GV(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function KV(e){return e.startsWith(`image/`)?`🖼`:e===`application/pdf`?`📄`:e===`text/csv`||e.includes(`spreadsheetml`)||e===`application/vnd.ms-excel`?`📊`:e===`application/json`?`{ }`:e===`text/plain`||e.includes(`sql`)?`📝`:`📎`}function qV(e){try{return new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})}catch{return e}}function JV({ticketKey:e,attachments:t,onChange:n,className:r}){let{t:i}=K(`attachments`),[a,o]=(0,H.useState)(new Set),[s,c]=(0,H.useState)(null),[l,u]=(0,H.useState)(null);if((0,H.useEffect)(()=>{let r=!1;return wD(e).then(e=>{if(r)return;let i=WV(t,e);i.length!==t.length&&n?.(i)}).catch(()=>{}),()=>{r=!0}},[e]),!t||t.length===0)return null;let d=[...t].sort((e,t)=>e.addedAt<t.addedAt?1:-1);async function f(r){c(null),o(e=>{let t=new Set(e);return t.add(r.id),t});try{await SD(e,r.id),await new Promise(e=>setTimeout(e,160)),n?.(t.filter(e=>e.id!==r.id))}catch(e){c(e instanceof Error?e.message:i(`errors.removeFailed`)),o(e=>{let t=new Set(e);return t.delete(r.id),t})}}return(0,Y.jsxs)(`section`,{className:X(`mt-4`,r),"aria-label":i(`section.ariaLabel`),children:[(0,Y.jsxs)(`header`,{className:`flex items-center justify-between mb-2`,children:[(0,Y.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:i(`section.title`)}),(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:i(`section.fileCount`,{count:d.length})})]}),(0,Y.jsx)(`ul`,{className:`flex flex-col gap-1`,children:d.map(e=>{let t=a.has(e.id);return(0,Y.jsxs)(`li`,{className:X(`flex items-center gap-3 px-2.5 py-2 rounded-md border border-border bg-card/60 hover:bg-card transition-all duration-200`,t&&`opacity-0 scale-95 max-h-0 py-0 border-transparent overflow-hidden`),children:[(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`w-6 text-center text-sm shrink-0`,children:KV(e.mimeType)}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>u(e),className:`flex-1 min-w-0 flex flex-col text-sm text-left hover:text-primary transition-colors`,children:[(0,Y.jsx)(`span`,{className:`font-medium truncate text-foreground`,children:e.filename}),(0,Y.jsxs)(`span`,{className:`text-[11px] text-muted-foreground`,children:[GV(e.size),` · `,qV(e.addedAt)]})]}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>u(e),className:`text-[11px] text-primary hover:underline shrink-0`,children:i(`common:actions.open`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>f(e),"aria-label":i(`removeFile`,{name:e.filename}),disabled:t,className:`w-6 h-6 inline-flex items-center justify-center rounded text-muted-foreground hover:text-destructive hover:bg-destructive/10 transition-colors disabled:opacity-50`,children:`×`})]},e.id)})}),s&&(0,Y.jsx)(`p`,{className:`mt-2 text-xs text-destructive`,children:s}),(0,Y.jsx)(UV,{ticketKey:e,attachment:l,onClose:()=>u(null)})]})}function YV({ticketId:e,onClose:t}){let{t:n}=K(`code`),r=_t(),{activeProjectId:i}=gm(),[a,o]=(0,H.useState)(null);return(0,H.useEffect)(()=>{if(!Pb)return;let t=new AbortController;return o(null),fetch(`${af()}/code/provenance?ticketId=${e}`,{signal:t.signal}).then(e=>e.ok?e.json():[]).then(e=>{o(Array.isArray(e)?e:[])}).catch(e=>{e?.name!==`AbortError`&&o([])}),()=>t.abort()},[e,i]),!Pb||!a||a.length===0?null:(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1.5`,children:n(`ticketFiles.title`)}),(0,Y.jsx)(`ul`,{className:`space-y-1`,children:a.map((e,i)=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{t(),r(`/code?path=${encodeURIComponent(e.path)}`)},className:`w-full text-left flex items-center gap-2 rounded px-2 py-1 text-xs hover:bg-muted/40`,children:[(0,Y.jsx)(e.kind===`created`?No:e.kind===`deleted`?Mo:Po,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,Y.jsx)(`span`,{className:`font-mono truncate flex-1`,children:e.path}),e.jobId&&(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] text-muted-foreground font-mono shrink-0`,title:n(`ticketFiles.jobTitle`,{jobId:e.jobId}),children:[(0,Y.jsx)(Uo,{className:`h-3 w-3`}),e.jobId.length>10?e.jobId.slice(0,10):e.jobId]}),(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground uppercase tracking-wider shrink-0`,children:n(`kind.${e.kind}`)})]})},`${e.path}-${i}`))})]})}var XV={critical:`bg-red-500/15 aurora-light:bg-destructive/10 text-red-400 aurora-light:text-destructive border-red-500/30 aurora-light:border-destructive/30`,high:`bg-orange-500/15 aurora-light:bg-accent-warning/10 text-orange-400 aurora-light:text-accent-warning border-orange-500/30 aurora-light:border-accent-warning/30`,medium:``,low:`bg-gray-500/15 aurora-light:bg-muted text-gray-400 aurora-light:text-muted-foreground border-gray-500/30 aurora-light:border-border`};function ZV(e){try{return vV(new Date(e),{addSuffix:!0,locale:im()})}catch{return e}}function QV({tickets:e,excludeIds:t,onSelect:n}){let{t:r}=K(`tickets`),[i,a]=(0,H.useState)(``),o=(0,H.useMemo)(()=>{let n=new Set(t),r=e.filter(e=>e.status!==`cancelled`&&!n.has(e.id));if(!i.trim())return r;let a=i.toLowerCase();return r.filter(e=>e.title.toLowerCase().includes(a)||e.description.toLowerCase().includes(a))},[e,t,i]);return(0,Y.jsxs)(`div`,{"data-testid":`spec-compare-picker`,className:`h-full flex flex-col rounded-xl bg-card border border-border/40 shadow-2xl shadow-black/50 overflow-hidden`,children:[(0,Y.jsxs)(`div`,{className:`px-4 py-3 border-b border-border/30 flex items-center gap-2`,children:[(0,Y.jsx)(oc,{className:`w-3.5 h-3.5 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`text-xs font-semibold text-foreground`,children:r(`comparePicker.title`)}),(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:r(`comparePicker.count`,{n:o.length})})]}),(0,Y.jsx)(`div`,{className:`px-4 py-2 border-b border-border/20`,children:(0,Y.jsxs)(`div`,{className:`relative`,children:[(0,Y.jsx)(Us,{className:`absolute left-2 top-1/2 -translate-y-1/2 w-3 h-3 text-muted-foreground`}),(0,Y.jsx)(`input`,{type:`text`,value:i,onChange:e=>a(e.target.value),placeholder:r(`comparePicker.searchPlaceholder`),className:`w-full h-7 rounded border border-border bg-input pl-7 pr-2 text-[11px] text-foreground placeholder:text-muted-foreground outline-none focus:border-accent-primary/60`})]})}),(0,Y.jsx)(`div`,{className:`flex-1 overflow-y-auto`,"data-testid":`spec-compare-picker-list`,children:o.length===0?(0,Y.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full text-center px-4 py-8 gap-2`,children:[(0,Y.jsx)(oc,{className:`w-6 h-6 text-muted-foreground/40`}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i.trim()?r(`comparePicker.noMatches`):r(`comparePicker.empty`)})]}):(0,Y.jsx)(`ul`,{className:`divide-y divide-border/10`,children:o.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{type:`button`,"data-testid":`spec-compare-card-${e.id}`,onClick:()=>n(e.id),className:`w-full text-left px-4 py-2.5 hover:bg-accent/30 transition-colors flex items-start gap-2 group`,children:[(0,Y.jsx)(ox,{status:e.status}),(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsxs)(`span`,{className:`text-[10px] font-mono text-muted-foreground`,children:[`#`,e.id]}),e.priority&&XV[e.priority]&&(0,Y.jsx)(`span`,{className:`inline-flex items-center rounded px-1 py-0.5 text-[9px] font-medium border ${XV[e.priority]}`,children:r(`priority.${e.priority}`)})]}),(0,Y.jsx)(`p`,{className:`mt-0.5 text-xs text-foreground truncate group-hover:text-accent-primary transition-colors`,children:e.title||r(`untitled`)}),e.description&&(0,Y.jsx)(`p`,{className:`mt-0.5 text-[10px] text-muted-foreground line-clamp-1`,children:e.description.slice(0,120)}),e.labels&&e.labels.length>0&&(0,Y.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-1`,children:[e.labels.slice(0,3).map(e=>(0,Y.jsx)(`span`,{className:`inline-flex items-center rounded px-1 py-0.5 text-[9px] bg-accent/40 text-foreground/60`,children:e},e)),e.labels.length>3&&(0,Y.jsxs)(`span`,{className:`text-[9px] text-muted-foreground`,children:[`+`,e.labels.length-3]})]}),(0,Y.jsx)(`p`,{className:`mt-1 text-[9px] text-muted-foreground`,children:r(`meta.updatedAgo`,{time:ZV(e.updated_at)})})]})]})},e.id))})})]})}var $V=.25,eH=.75;function tH({state:e,leftTicket:t,rightTicket:n,allTickets:r,allLabels:i,onSave:a,onDelete:o,onOpenTicket:s,onCloseAll:c,onSetCompared:l,onSetRatio:u,onExitSplit:d}){let f=(0,H.useRef)(null),p=(0,H.useRef)(null),[m,h]=(0,H.useState)(!0);(0,H.useEffect)(()=>{let e=setTimeout(()=>h(!1),320);return()=>clearTimeout(e)},[]);let g=(0,H.useCallback)(e=>{if(!p.current)return;let t=window.innerWidth,n=e.clientX/t;u(Math.min(eH,Math.max($V,n)))},[u]),_=(0,H.useCallback)(e=>{if(!p.current)return;let{pointerId:t,element:n}=p.current;try{n.releasePointerCapture(t)}catch{}p.current=null,window.removeEventListener(`pointermove`,g),window.removeEventListener(`pointerup`,_),window.removeEventListener(`pointercancel`,_)},[g]),v=(0,H.useCallback)(e=>{let t=e.currentTarget;try{t.setPointerCapture(e.pointerId)}catch{}p.current={pointerId:e.pointerId,element:t},window.addEventListener(`pointermove`,g),window.addEventListener(`pointerup`,_),window.addEventListener(`pointercancel`,_)},[g,_]);(0,H.useEffect)(()=>()=>{window.removeEventListener(`pointermove`,g),window.removeEventListener(`pointerup`,_),window.removeEventListener(`pointercancel`,_);let e=p.current;if(e){try{e.element.releasePointerCapture(e.pointerId)}catch{}p.current=null}},[g,_]);let y=(0,H.useCallback)(t=>{let n=.04;t.key===`ArrowLeft`?(t.preventDefault(),u(Math.max($V,e.splitRatio-n))):t.key===`ArrowRight`?(t.preventDefault(),u(Math.min(eH,e.splitRatio+n))):t.key===`Home`?(t.preventDefault(),u($V)):t.key===`End`?(t.preventDefault(),u(eH)):t.key===`0`&&(t.preventDefault(),u(.5))},[u,e.splitRatio]),b=e=>{e.target===e.currentTarget&&c()},x=u=>{let d=u===e.originSide,f=u===`left`?t:n;return f?(0,Y.jsx)(tU,{ticket:f,allLabels:i,allTickets:r,onClose:d?c:()=>l(null,u),onOpenTicket:s,onSave:a,onDelete:o,embedded:!0},`${u}-${f.id}`):(0,Y.jsx)(QV,{tickets:r,excludeIds:[t?.id,n?.id].filter(e=>e!=null),onSelect:e=>l(e,u)})},S=(e.splitRatio*100).toFixed(2),C=((1-e.splitRatio)*100).toFixed(2);return(0,Y.jsxs)(`div`,{ref:f,"data-testid":`split-view-shell`,className:`fixed inset-0 z-[68] flex`,onClick:b,children:[(0,Y.jsx)(`div`,{className:`absolute inset-0 bg-black/70 pointer-events-none`,"aria-hidden":!0}),(0,Y.jsxs)(`div`,{className:`relative flex w-full h-full`,style:{transition:m?`opacity 280ms cubic-bezier(0.34, 1.56, 0.64, 1)`:void 0},children:[(0,Y.jsx)(`div`,{"data-testid":`split-panel-left`,className:`relative h-full overflow-hidden`,style:{width:`${S}%`,transition:m?`width 280ms cubic-bezier(0.34, 1.56, 0.64, 1)`:void 0},children:(0,Y.jsx)(`div`,{className:`h-full flex items-center justify-center p-2`,children:(0,Y.jsx)(`div`,{className:`w-full h-full max-h-[95vh]`,children:x(`left`)})})}),(0,Y.jsx)(`div`,{"data-testid":`split-divider`,role:`separator`,"aria-orientation":`vertical`,"aria-valuenow":Math.round(e.splitRatio*100),"aria-valuemin":Math.round($V*100),"aria-valuemax":Math.round(eH*100),tabIndex:0,onPointerDown:v,onKeyDown:y,className:`relative z-10 w-2 cursor-col-resize bg-border/40 hover:bg-accent-primary/40 transition-colors focus:outline-none focus:bg-accent-primary/60`}),(0,Y.jsx)(`div`,{"data-testid":`split-panel-right`,className:`relative h-full overflow-hidden`,style:{width:`${C}%`,transition:m?`width 280ms cubic-bezier(0.34, 1.56, 0.64, 1)`:void 0},children:(0,Y.jsx)(`div`,{className:`h-full flex items-center justify-center p-2`,children:(0,Y.jsx)(`div`,{className:`w-full h-full max-h-[95vh]`,children:x(`right`)})})})]})]})}var nH=.5,rH=.25,iH=.75,aH={leftId:null,rightId:null,originSide:null,splitRatio:nH};function oH(e){return Number.isFinite(e)?Math.min(iH,Math.max(rH,e)):nH}function sH(e,t){switch(t.type){case`openCentered`:return e.originSide!==null&&e.leftId!==t.id&&e.rightId!==t.id?{leftId:t.id,rightId:null,originSide:null,splitRatio:nH}:e.originSide!==null&&(e.leftId===t.id||e.rightId===t.id)?e:{...aH,leftId:t.id};case`closeAll`:return aH;case`enterSplit`:{let n=t.ticketId??e.leftId;return n===null||e.originSide!==null?e:t.side===`left`?{leftId:n,rightId:null,originSide:`left`,splitRatio:nH}:{leftId:null,rightId:n,originSide:`right`,splitRatio:nH}}case`setComparedTicket`:{if(e.originSide===null)return e;let n=e.originSide===`left`?`right`:`left`;return t.side===n?t.side===`left`?{...e,leftId:t.id}:{...e,rightId:t.id}:e}case`exitSplit`:{if(e.originSide===null)return e;let t=e.originSide===`left`?e.leftId:e.rightId;return{...aH,leftId:t}}case`setSplitRatio`:return{...e,splitRatio:oH(t.ratio)};default:return e}}var cH=(0,H.createContext)(null),lH=900;function uH({children:e}){let[t,n]=(0,H.useReducer)(sH,aH),{tickets:r,updateTicket:i,deleteTicket:a}=Em(),{activeProjectId:o,setActiveProjectId:s}=gm(),c=(0,H.useRef)(null);(0,H.useEffect)(()=>{n({type:`closeAll`});let e=c.current;e&&(c.current=null,e.projectId===o&&n({type:`openCentered`,id:e.ticketId}))},[o]);let l=(0,H.useCallback)(e=>n({type:`openCentered`,id:e}),[]),u=(0,H.useCallback)((e,t)=>{if(e===o){n({type:`openCentered`,id:t});return}c.current={projectId:e,ticketId:t},s(e)},[o,s]),d=(0,H.useCallback)(()=>n({type:`closeAll`}),[]),f=(0,H.useCallback)((e,t)=>n({type:`enterSplit`,side:e,ticketId:t}),[]),p=(0,H.useCallback)((e,t)=>n({type:`setComparedTicket`,id:e,side:t}),[]),m=(0,H.useCallback)(()=>n({type:`exitSplit`}),[]),h=(0,H.useCallback)(e=>n({type:`setSplitRatio`,ratio:e}),[]);(0,H.useEffect)(()=>{if(typeof window>`u`)return;function e(){window.innerWidth<lH&&n({type:`exitSplit`})}return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let g=(0,H.useMemo)(()=>{let e=new Set;for(let t of r)for(let n of t.labels??[])e.add(n);return Array.from(e).sort()},[r]),_=t.leftId==null?null:r.find(e=>e.id===t.leftId)??null,v=t.rightId==null?null:r.find(e=>e.id===t.rightId)??null,y=(0,H.useMemo)(()=>({openTicketDetail:l,openTicketDetailInProject:u,closeTicketDetail:d,enterSplit:f,setComparedTicket:p,exitSplit:m,setSplitRatio:h,state:t}),[l,u,d,f,p,m,h,t]),b=t.originSide!==null;return(0,Y.jsxs)(cH.Provider,{value:y,children:[e,!b&&_&&(0,Y.jsx)(tU,{ticket:_,allLabels:g,allTickets:r,onClose:d,onOpenTicket:l,onSave:i,onDelete:e=>{a(e),d()}},_.id),b&&(0,Y.jsx)(tH,{state:t,leftTicket:_,rightTicket:v,allTickets:r,allLabels:g,onSave:i,onDelete:e=>{a(e),d()},onOpenTicket:l,onCloseAll:d,onSetCompared:p,onSetRatio:h,onExitSplit:m})]})}function dH(){return(0,H.useContext)(cH)||{openTicketDetail:()=>{typeof console<`u`&&console.warn(`[TicketDetailModalContext] openTicketDetail called without provider`)},openTicketDetailInProject:()=>{typeof console<`u`&&console.warn(`[TicketDetailModalContext] openTicketDetailInProject called without provider`)},closeTicketDetail:()=>{},enterSplit:()=>{},setComparedTicket:()=>{},exitSplit:()=>{},setSplitRatio:()=>{},state:aH}}var fH={job:`analytics:surfaces.job`,"quick-spec":`analytics:surfaces.quickSpec`,"explore-spec":`analytics:surfaces.exploreSpec`,"ai-edit":`analytics:surfaces.aiEdit`,smash:`analytics:surfaces.smash`,"file-summary":`analytics:surfaces.fileSummary`,loop:`analytics:surfaces.loop`,"chat-sidebar":`analytics:surfaces.chatSidebar`,"spec-launcher":`analytics:surfaces.specLauncher`,proposal:`analytics:surfaces.proposal`,"agent-studio":`analytics:surfaces.agentStudio`,setup:`analytics:surfaces.setup`},pH={bg:`bg-muted/40`,text:`text-muted-foreground`,ring:`ring-border/40`,dot:`bg-muted-foreground`},mH={job:{bg:`bg-accent-info/15`,text:`text-accent-info`,ring:`ring-accent-info/40`,dot:`bg-accent-info`},"quick-spec":{bg:`bg-accent-secondary/15`,text:`text-accent-secondary`,ring:`ring-accent-secondary/40`,dot:`bg-accent-secondary`},"explore-spec":{bg:`bg-accent-highlight/15`,text:`text-accent-highlight`,ring:`ring-accent-highlight/40`,dot:`bg-accent-highlight`},"ai-edit":{bg:`bg-accent-success/15`,text:`text-accent-success`,ring:`ring-accent-success/40`,dot:`bg-accent-success`},smash:{bg:`bg-accent-highlight/15`,text:`text-accent-highlight`,ring:`ring-accent-highlight/40`,dot:`bg-accent-highlight`},"file-summary":{bg:`bg-accent-warning/15`,text:`text-accent-warning`,ring:`ring-accent-warning/40`,dot:`bg-accent-warning`},loop:{bg:`bg-accent-primary/15`,text:`text-accent-primary`,ring:`ring-accent-primary/40`,dot:`bg-accent-primary`},"chat-sidebar":{bg:`bg-accent-info/15`,text:`text-accent-info`,ring:`ring-accent-info/40`,dot:`bg-accent-info`},"spec-launcher":{bg:`bg-accent-secondary/15`,text:`text-accent-secondary`,ring:`ring-accent-secondary/40`,dot:`bg-accent-secondary`},proposal:{bg:`bg-accent-highlight/15`,text:`text-accent-highlight`,ring:`ring-accent-highlight/40`,dot:`bg-accent-highlight`},"agent-studio":{bg:`bg-accent-success/15`,text:`text-accent-success`,ring:`ring-accent-success/40`,dot:`bg-accent-success`},setup:{bg:`bg-accent-primary/15`,text:`text-accent-primary`,ring:`ring-accent-primary/40`,dot:`bg-accent-primary`}};function hH(e,t){return new Proxy(e,{get(e,n,r){return typeof n==`string`&&!(n in e)?t(n):Reflect.get(e,n,r)}})}var gH=hH(Object.defineProperties({},Object.fromEntries(Object.keys(fH).map(e=>[e,{get:()=>am.t(fH[e]),enumerable:!0}]))),e=>e),_H=hH(mH,()=>pH);function vH(e){return e<.005?`$${e.toFixed(4)}`:e<1?`$${e.toFixed(3)}`:`$${e.toFixed(2)}`}function yH(e){return e<1e3?`${e} ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${Math.floor(e/6e4)}m ${Math.floor(e%6e4/1e3)}s`}function bH({ticketId:e}){let{t}=K(`tickets`),[n,r]=(0,H.useState)(null),i=_t(),{activeProjectId:a}=gm(),{closeTicketDetail:o}=dH();if((0,H.useEffect)(()=>{let t=new AbortController;return r(null),fetch(`${af()}/tickets/${e}/spending-summary`,{signal:t.signal}).then(e=>e.ok?e.json():null).then(e=>{e&&r(e)}).catch(()=>{}),()=>t.abort()},[e,a]),!n||!n.bySurface||!n.totalRuns||n.totalRuns===0)return null;let s=Object.entries(n.bySurface).filter(([,e])=>e.count>0).map(([e,n])=>t(`spendingLine.breakdownItem`,{n:n.count,label:gH[e].toLowerCase()})).join(` + `);return(0,Y.jsxs)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),o(),i(`/analytics?ticketId=${e}`)},className:`mt-1.5 group inline-flex items-center gap-1.5 text-[11px] text-muted-foreground hover:text-foreground transition-colors cursor-pointer`,"aria-label":t(`spendingLine.ariaLabel`),children:[(0,Y.jsxs)(`span`,{className:`tabular-nums font-medium text-foreground`,title:(n.estimatedCostUsd??0)>0?t(`spendingLine.estimatedTooltip`):void 0,children:[(n.estimatedCostUsd??0)>0?`~`:``,vH(n.totalCostUsd)]}),(0,Y.jsx)(`span`,{className:`text-muted-foreground/60`,children:`·`}),(0,Y.jsx)(`span`,{className:`tabular-nums`,children:t(`spendingLine.turns`,{count:n.totalTurns})}),(0,Y.jsx)(`span`,{className:`text-muted-foreground/60`,children:`·`}),(0,Y.jsx)(`span`,{className:`tabular-nums`,children:t(`spendingLine.active`,{duration:yH(n.activeDurationMs)})}),s&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground/60`,children:`·`}),(0,Y.jsx)(`span`,{children:s})]}),(0,Y.jsx)(Va,{className:`w-3 h-3 opacity-0 group-hover:opacity-100 transition-opacity`})]})}var xH=/^\d{4}-\d{2}-\d{2}T/;function SH(e){if(xH.test(e))try{return{text:vV(yV(e),{addSuffix:!0,locale:im()}),title:e}}catch{}return{text:e}}function CH({localId:e}){let{t}=K(`jira`),{activeProjectId:n}=gm(),r=Wb(),[i,a]=(0,H.useState)(null);if((0,H.useEffect)(()=>{if(!Fb||!r.connected)return;let t=!1;return a(null),Ub.getSpecDetails(e).then(e=>{t||a(e)}).catch(()=>{t||a(null)}),()=>{t=!0}},[e,n,r.connected]),!Fb||!r.connected||!i)return null;let o=i.development,s=i.fields.length>0,c=o.pullRequests.length>0,l=o.branches.length>0,u=(o.commits?.length??0)>0;return!s&&!c&&!l&&!u?null:(0,Y.jsxs)(`div`,{className:`space-y-4`,"data-testid":`jira-details-panel`,children:[s&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1.5`,children:t(`detail.detailsTitle`)}),(0,Y.jsx)(`div`,{className:`space-y-1.5`,children:i.fields.map((e,t)=>{let n=SH(e.value);return(0,Y.jsxs)(`div`,{className:`text-xs`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground uppercase tracking-wide block`,children:e.label}),e.href?(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{HV(e.href)},className:`inline-flex items-center gap-1 text-accent-info hover:underline text-left`,children:[(0,Y.jsx)(`span`,{className:`truncate`,children:e.value}),(0,Y.jsx)(Oo,{className:`w-3 h-3 shrink-0`})]}):(0,Y.jsx)(`span`,{className:`text-foreground/80 whitespace-pre-line`,title:n.title,children:n.text})]},`${e.label}-${t}`)})})]}),(c||l||u)&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1.5`,children:t(`detail.developmentTitle`)}),c&&(0,Y.jsxs)(`div`,{className:`mb-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground uppercase tracking-wide block mb-1`,children:t(`detail.dev.pullRequests`)}),(0,Y.jsx)(`div`,{className:`space-y-1`,children:o.pullRequests.map(e=>(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{HV(e.url)},className:`w-full flex items-start gap-1.5 text-left text-xs hover:bg-accent-info/10 rounded px-1 py-0.5`,"data-testid":`jira-dev-pr`,children:[(0,Y.jsx)(Go,{className:`w-3 h-3 mt-0.5 shrink-0 text-accent-info`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`truncate text-foreground/80 block`,children:e.title}),(0,Y.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[e.status,e.sourceBranch?` · ${e.sourceBranch} → ${e.destBranch??``}`:``]})]})]},e.url))})]}),l&&(0,Y.jsxs)(`div`,{className:`mb-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground uppercase tracking-wide block mb-1`,children:t(`detail.dev.branches`)}),(0,Y.jsx)(`div`,{className:`space-y-1`,children:o.branches.map(e=>(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{HV(e.url)},className:`w-full flex items-center gap-1.5 text-left text-xs hover:bg-accent-info/10 rounded px-1 py-0.5`,"data-testid":`jira-dev-branch`,children:[(0,Y.jsx)(Ho,{className:`w-3 h-3 shrink-0 text-accent-info`}),(0,Y.jsx)(`span`,{className:`truncate font-mono text-foreground/80`,children:e.name}),e.repo&&(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground truncate`,children:e.repo})]},e.url))})]}),u&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground uppercase tracking-wide block mb-1`,children:t(`detail.dev.commits`)}),(0,Y.jsx)(`div`,{className:`space-y-1`,children:o.commits.map(e=>(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{HV(e.url)},className:`w-full flex items-center gap-1.5 text-left text-xs hover:bg-accent-info/10 rounded px-1 py-0.5`,"data-testid":`jira-dev-commit`,children:[(0,Y.jsx)(Uo,{className:`w-3 h-3 shrink-0 text-accent-info`}),(0,Y.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground shrink-0`,children:e.displayId}),(0,Y.jsx)(`span`,{className:`truncate text-foreground/80`,children:e.message})]},e.url))})]})]})]})}function wH({open:e,url:t,projectId:n,onClose:r}){let{t:i}=K(`browser`),a=ZO({projectId:n,open:e,initialUrl:t}),{canvasRef:o,viewport:s,status:c,errorMsg:l,url:u,title:d,popup:f}=a,[p,m]=(0,H.useState)(t),h=(0,H.useRef)(a.forwardInput);h.current=a.forwardInput;let g=(0,H.useRef)(null),_=(0,H.useCallback)(()=>(g.current??=zO(e=>h.current(e)),g.current),[]);(0,H.useEffect)(()=>()=>{g.current?.dispose(),g.current=null},[]),(0,H.useEffect)(()=>{u&&m(u)},[u]),(0,H.useEffect)(()=>{if(!e)return;let t=e=>{e.key===`Escape`&&r()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e,r]);let v=(0,H.useCallback)((e,t)=>{let n=o.current?.getBoundingClientRect();return n?BO({x:e,y:t},{left:n.left,top:n.top,width:n.width,height:n.height},s):{x:0,y:0}},[o,s]),y=e=>e===2?`right`:e===1?`middle`:`left`,b=(0,H.useCallback)(e=>{let t=v(e.clientX,e.clientY);_().move(t.x,t.y)},[v,_]),x=(0,H.useCallback)(e=>{let t=v(e.clientX,e.clientY),n=_();n.move(t.x,t.y),n.flush(),a.forwardInput({type:`mouse`,action:`down`,x:t.x,y:t.y,button:y(e.button),clickCount:e.detail||1})},[v,a,_]),S=(0,H.useCallback)(e=>{let t=v(e.clientX,e.clientY),n=_();n.move(t.x,t.y),n.flush(),a.forwardInput({type:`mouse`,action:`up`,x:t.x,y:t.y,button:y(e.button),clickCount:e.detail||1})},[v,a,_]),C=(0,H.useCallback)(e=>{let t=v(e.clientX,e.clientY);_().wheel(t.x,t.y,e.deltaX,e.deltaY)},[v,_]),w=(0,H.useCallback)(e=>{if(e.key===`Escape`)return;let t=e.metaKey||e.ctrlKey;if(t&&(e.key===`c`||e.key===`v`||e.key===`x`)){e.preventDefault();let t=e.key;(async()=>{try{if(t===`v`){let e=await navigator.clipboard.readText();e&&await a.clipboard(`paste`,e)}else{let{text:e}=await a.clipboard(t===`x`?`cut`:`copy`);e&&await navigator.clipboard.writeText(e)}}catch{}})();return}let n={type:`key`,action:`down`,key:e.key,code:e.code,text:!t&&e.key.length===1?e.key:void 0};a.forwardInput(n),(e.key===`Tab`||e.key===` `||e.key.startsWith(`Arrow`))&&e.preventDefault()},[a]),T=(0,H.useCallback)(e=>{e.key!==`Escape`&&a.forwardInput({type:`key`,action:`up`,key:e.key,code:e.code})},[a]),E=(0,H.useCallback)(()=>{a.navigate(`goto`,p)},[a,p]);return!e||typeof document>`u`?null:(0,sr.createPortal)((0,Y.jsx)(`div`,{className:`fixed inset-0 z-[80] bg-background-deep/50 backdrop-blur-sm pointer-events-auto`,onClick:e=>{e.target===e.currentTarget&&r()},"data-testid":`webview-modal`,children:(0,Y.jsxs)(`div`,{className:`absolute inset-2 flex flex-col border border-border rounded-lg bg-background-deep overflow-hidden`,role:`dialog`,"aria-modal":`true`,"aria-label":i(`modal.dialogLabel`),onClick:e=>e.stopPropagation(),children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 border-b border-border/50 bg-surface/80 shrink-0`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":i(`common:actions.back`),onClick:()=>a.navigate(`back`),children:(0,Y.jsx)(Ba,{className:`w-4 h-4`})}),(0,Y.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":i(`modal.nav.forward`),onClick:()=>a.navigate(`forward`),children:(0,Y.jsx)(Va,{className:`w-4 h-4`})}),(0,Y.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":i(`modal.nav.reload`),onClick:()=>a.navigate(`reload`),children:(0,Y.jsx)(zs,{className:`w-4 h-4`})})]}),(0,Y.jsxs)(`form`,{className:`flex-1 flex items-center gap-2 min-w-0`,onSubmit:e=>{e.preventDefault(),E()},children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 flex-1 min-w-0 rounded-md border border-border bg-background px-2.5 py-1`,children:[(0,Y.jsx)(Ko,{className:`w-3.5 h-3.5 text-muted-foreground shrink-0`}),(0,Y.jsx)(`input`,{value:p,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),E())},placeholder:i(`modal.address.placeholder`),"aria-label":i(`modal.address.label`),className:`flex-1 min-w-0 bg-transparent outline-none text-sm`})]}),(0,Y.jsx)(Z,{type:`submit`,size:`sm`,variant:`secondary`,className:`shrink-0`,disabled:c===`error`,children:i(`modal.address.go`)})]}),(0,Y.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":i(`modal.closeBrowser`),onClick:r,children:(0,Y.jsx)(hc,{className:`w-4 h-4`})})]}),(0,Y.jsxs)(`div`,{className:`px-3 py-1 text-[11px] text-muted-foreground truncate shrink-0 flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-full shrink-0 ${c===`ready`?`bg-accent-success`:c===`error`?`bg-destructive`:`bg-accent-warning animate-pulse`}`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`truncate`,children:c===`connecting`?i(`modal.status.connecting`):c===`error`?l??i(`modal.status.unavailable`):d||``})]}),f&&(0,Y.jsxs)(`div`,{"data-testid":`webview-popup-bar`,className:`flex items-center gap-2 px-3 py-1.5 text-xs border-b shrink-0 ${f.active?`bg-accent-info/10 border-accent-info/30 text-accent-info`:`bg-surface/70 border-border/40 text-muted-foreground`}`,children:[(0,Y.jsx)(Oo,{className:`w-3.5 h-3.5 shrink-0`}),f.active?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`truncate font-medium`,children:i(`popup.loginWindow`,{origin:FO(f.url)})}),f.count>1&&(0,Y.jsx)(`span`,{className:`shrink-0 opacity-70`,children:i(`popup.stacked`,{count:f.count-1})}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>a.setPopupView(`root`),className:`ml-auto shrink-0 inline-flex items-center gap-1 h-6 px-2 rounded-md border border-current/30 hover:bg-card/60 transition-colors`,children:[(0,Y.jsx)(Ba,{className:`w-3 h-3`}),i(`popup.backToPage`)]})]}):(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>a.setPopupView(`popup`),className:`inline-flex items-center gap-1 h-6 px-2 rounded-md border border-border/50 hover:bg-card/60 hover:text-foreground transition-colors`,children:[i(`popup.show`),f.count>1&&(0,Y.jsx)(`span`,{className:`opacity-70`,children:i(`popup.stacked`,{count:f.count-1})})]})]}),(0,Y.jsx)(`div`,{className:`relative flex-1 min-h-0 overflow-hidden flex items-center justify-center outline-none`,tabIndex:0,onKeyDown:w,onKeyUp:T,children:c===`error`?(0,Y.jsxs)(`div`,{className:`flex flex-col items-center gap-2 text-center max-w-md px-6`,children:[(0,Y.jsx)(lc,{className:`w-8 h-8 text-accent-warning`}),(0,Y.jsx)(`p`,{className:`text-sm text-foreground/90`,children:l??i(`modal.error.unavailable`)})]}):(0,Y.jsx)(`canvas`,{ref:o,className:`max-w-full max-h-full block shadow-2xl cursor-default`,onPointerMove:b,onPointerDown:x,onPointerUp:S,onContextMenu:e=>e.preventDefault(),onWheel:C})})]})}),document.body)}var TH=(0,H.createContext)(null);function EH({children:e}){let{activeProjectId:t}=gm(),[n,r]=(0,H.useState)(null),i=(0,H.useCallback)(e=>r(e),[]),a=SO();return(0,Y.jsxs)(TH.Provider,{value:{openWebView:i,canOpenWebView:a&&!!t},children:[e,a&&n&&t&&(0,Y.jsx)(wH,{open:!0,url:n,projectId:t,onClose:()=>r(null)})]})}function DH(){return(0,H.useContext)(TH)??{openWebView:()=>{},canOpenWebView:!1}}var OH={analyzing:`activity:smash.stage.analyzing`,identifying:`activity:smash.stage.identifying`,ordering:`activity:smash.stage.ordering`},kH=(0,H.createContext)(null);function AH(e){return`smash:${e}`}async function jH(e,t){try{let n=await fetch(`${o}/api/projects/${e}/tickets/${t}/smash`,{method:`POST`});if(n.ok)q.loading(am.t(`activity:smash.retrying`),{id:AH(t)});else{let e=await n.json().catch(()=>({}));q.error(e.reason?am.t(`activity:smash.couldNotRetryWithReason`,{reason:e.reason}):am.t(`activity:smash.couldNotRetry`),{id:AH(t)})}}catch(e){q.error(am.t(`activity:smash.retryFailed`,{message:e.message}),{id:AH(t)})}}async function MH(e,t,n){try{let r=await fetch(`${o}/api/projects/${e}/tickets/${t}/smash/undo`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({smashedAt:n})});if(r.ok)q.success(am.t(`activity:smash.undone`),{id:AH(t),duration:3e3});else{let e=await r.json().catch(()=>({}));q.error(e.reason?am.t(`activity:smash.undoFailedWithReason`,{reason:e.reason}):am.t(`activity:smash.undoFailed`),{id:AH(t)})}}catch(e){q.error(am.t(`activity:smash.undoFailedWithReason`,{reason:e.message}),{id:AH(t)})}}function NH({children:e}){let{registerHandler:t,unregisterHandler:n}=df(),[r,i]=(0,H.useState)({}),a=(0,H.useRef)(new Map),o=(0,H.useRef)(new Map),s=(0,H.useCallback)(e=>{let t=e;if(!t||t.type!==`smash.started`)return;let n=t.ticketId,r=t.runId,o=t.projectId,s=t.timestamp,c=t.ticketTitle;typeof n!=`number`||!r||!o||(a.current.set(n,o),i(e=>({...e,[n]:{ticketId:n,runId:r,stage:`analyzing`,startedAt:s??new Date().toISOString(),ticketTitle:c}})),q.loading(am.t(OH.analyzing),{id:AH(n),description:c?am.t(`activity:smash.onTitled`,{title:c}):am.t(`activity:smash.onThisSpec`)}))},[]),c=(0,H.useCallback)(e=>{let t=e;if(!t||t.type!==`smash.progress`)return;let n=t.ticketId,r=t.stage;if(typeof n!=`number`||!r)return;let a;i(e=>{let t=e[n];return t?(a=t.ticketTitle,{...e,[n]:{...t,stage:r}}):e}),q.loading(am.t(OH[r]),{id:AH(n),description:a?am.t(`activity:smash.onTitled`,{title:a}):am.t(`activity:smash.onThisSpec`)})},[]),l=(0,H.useCallback)(e=>{let t=e;if(!t||t.type!==`smash.completed`)return;let n=t.ticketId,r=t.runId,a=t.projectId,s=t.smashedAt,c=t.childrenIds;typeof n!=`number`||!r||!a||!s||!c||(o.current.set(r,s),i(e=>{let t={...e};return delete t[n],t}),q.success(am.t(`activity:smash.split`,{count:c.length}),{id:AH(n),duration:1e4,action:{label:am.t(`activity:smash.undoAction`),onClick:()=>void MH(a,n,s)}}))},[]),u=(0,H.useCallback)(e=>{let t=e;if(!t||t.type!==`smash.failed`)return;let n=t.ticketId,r=t.projectId,o=t.reason??`unknown`;if(typeof n!=`number`||!r)return;a.current.set(n,r),i(e=>{let t={...e};return delete t[n],t});let s=o===`invalid-output`?am.t(`activity:smash.failReason.invalidOutput`):o===`timeout`?am.t(`activity:smash.failReason.timeout`):o===`model_error`?am.t(`activity:smash.failReason.modelError`):o===`crashed`?am.t(`activity:smash.failReason.crashed`):am.t(`activity:smash.failReason.generic`,{reason:o});q.error(am.t(`activity:smash.couldNotComplete`),{id:AH(n),description:s,action:{label:am.t(`common:actions.retry`),onClick:()=>void jH(r,n)},duration:15e3})},[]),d=(0,H.useCallback)(e=>{let t=e;if(!t||t.type!==`smash.undone`)return;let n=t.ticketId;typeof n==`number`&&(q.dismiss(AH(n)),q.success(am.t(`activity:smash.undone`),{id:AH(n),duration:3e3}))},[]);(0,H.useLayoutEffect)(()=>(t(`_smash_started`,s),t(`_smash_progress`,c),t(`_smash_completed`,l),t(`_smash_failed`,u),t(`_smash_undone`,d),()=>{n(`_smash_started`),n(`_smash_progress`),n(`_smash_completed`),n(`_smash_failed`),n(`_smash_undone`)}),[t,n,s,c,l,u,d]),(0,H.useEffect)(()=>()=>{a.current.clear(),o.current.clear()},[]);let f=(0,H.useMemo)(()=>({inflight:r}),[r]);return(0,Y.jsx)(kH.Provider,{value:f,children:e})}function PH(e){let t=(0,H.useContext)(kH);return!t||e==null?null:t.inflight[e]??null}var FH=150,IH={analyzing:0,identifying:1,ordering:2},LH={analyzing:`smash.stage.analyzing`,identifying:`smash.stage.identifying`,ordering:`smash.stage.ordering`};function RH({stage:e,minDisplayMs:t=FH}){let{t:n}=K(`activity`),[r,i]=(0,H.useState)(e),a=(0,H.useRef)(Date.now()),o=(0,H.useRef)(null);if((0,H.useEffect)(()=>{if(e===r)return;let n=Date.now()-a.current,s=Math.max(0,t-n);return o.current&&clearTimeout(o.current),o.current=setTimeout(()=>{i(e),a.current=Date.now(),o.current=null},s),()=>{o.current&&clearTimeout(o.current)}},[e,r,t]),!r)return null;let s=IH[r];return(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 rounded-md border border-accent-highlight/40 bg-accent-highlight/10 text-sm text-foreground`,role:`status`,"aria-live":`polite`,"data-testid":`smash-status-pills`,children:[(0,Y.jsx)(cs,{className:`h-4 w-4 animate-spin text-accent-highlight`,"aria-hidden":!0}),(0,Y.jsx)(`div`,{className:`flex items-center gap-1.5`,children:[`analyzing`,`identifying`,`ordering`].map(e=>(0,Y.jsx)(`span`,{className:[`inline-block w-1.5 h-1.5 rounded-full transition-all`,IH[e]<=s?`bg-accent-highlight`:`bg-muted`,e===r?`scale-125`:`scale-100`].join(` `),"aria-hidden":!0},e))}),(0,Y.jsx)(`span`,{className:`font-medium`,children:n(LH[r])})]})}var zH={simple:{titleKey:`smashModal.modes.simple.title`,bulletKeys:[`smashModal.modes.simple.bullet1`,`smashModal.modes.simple.bullet2`,`smashModal.modes.simple.bullet3`],etaKey:`smashModal.modes.simple.eta`},full:{titleKey:`smashModal.modes.full.title`,bulletKeys:[`smashModal.modes.full.bullet1`,`smashModal.modes.full.bullet2`,`smashModal.modes.full.bullet3`,`smashModal.modes.full.bullet4`],etaKey:`smashModal.modes.full.eta`}};function BH({open:e,ticketTitle:t,isReSmash:n,childrenCount:r,submitting:i=!1,onCancel:a,onConfirm:o}){let{t:s}=K(`activity`),[c,l]=(0,H.useState)(`simple`),{panelRef:u,panelStyle:d,headerHandleProps:f,resizeHandles:p,isFloating:m,guardBackdrop:h}=yb();return e?(0,Y.jsxs)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center`,role:`dialog`,"aria-modal":`true`,"data-testid":`smash-confirm-modal`,children:[(0,Y.jsx)(`div`,{className:`absolute inset-0 bg-black/60 backdrop-blur-sm`,onClick:h(a)}),(0,Y.jsxs)(`div`,{ref:u,className:`relative w-full max-w-lg m-4 rounded-xl glass-card border border-border/30 animate-in fade-in zoom-in-95 duration-150`,style:d,children:[(0,Y.jsxs)(`div`,{...f,className:`flex items-start justify-between gap-3 px-5 py-4 border-b border-border/30 ${m?`cursor-grab active:cursor-grabbing`:``}`,children:[(0,Y.jsxs)(`div`,{className:`flex items-start gap-2 min-w-0`,children:[(0,Y.jsx)($s,{className:`w-5 h-5 text-accent-highlight shrink-0 mt-0.5`,"aria-hidden":!0}),(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:s(`smashModal.title`)}),(0,Y.jsx)(`p`,{className:`text-[11px] text-muted-foreground truncate`,title:t,children:t})]})]}),(0,Y.jsx)(`button`,{type:`button`,onClick:a,className:`h-7 w-7 flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-surface/50 transition-colors shrink-0`,"aria-label":s(`common:actions.close`),children:(0,Y.jsx)(hc,{className:`w-4 h-4`})})]}),n&&r>0&&(0,Y.jsx)(`div`,{className:`mx-5 mt-4 rounded-md border border-accent-warning/40 bg-accent-warning/10 px-3 py-2 text-xs text-foreground`,children:(0,Y.jsx)(Yi,{t:s,i18nKey:`smashModal.reSmashWarning`,count:r})}),(0,Y.jsxs)(`div`,{className:`px-5 py-4 space-y-3`,children:[(0,Y.jsx)(`p`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground font-medium`,children:s(`smashModal.modePickerLabel`)}),[`simple`,`full`].map(e=>{let t=zH[e],n=c===e;return(0,Y.jsx)(`button`,{type:`button`,onClick:()=>l(e),disabled:i,className:`w-full text-left rounded-lg border px-3 py-3 transition-colors ${n?`border-accent-highlight/60 bg-accent-highlight/10`:`border-border/40 bg-card/40 hover:bg-card/60 hover:border-border/60`}`,"data-testid":`smash-mode-${e}`,children:(0,Y.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Y.jsx)(`div`,{className:`mt-0.5 h-3.5 w-3.5 rounded-full border-2 shrink-0 ${n?`border-accent-highlight bg-accent-highlight`:`border-muted-foreground/60`}`,"aria-hidden":!0}),(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mb-1`,children:[(0,Y.jsxs)(`span`,{className:`flex items-center gap-1.5 text-sm font-semibold text-foreground`,children:[e===`full`&&(0,Y.jsx)(gc,{className:`w-3.5 h-3.5 text-accent-highlight`,"aria-hidden":!0}),s(t.titleKey)]}),(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:s(t.etaKey)})]}),(0,Y.jsx)(`ul`,{className:`space-y-0.5`,children:t.bulletKeys.map(e=>(0,Y.jsxs)(`li`,{className:`text-[11px] text-foreground/70 leading-snug`,children:[`• `,s(e)]},e))})]})]})},e)})]}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-end gap-2 px-5 py-3 border-t border-border/30 bg-surface/20`,children:[(0,Y.jsx)(Z,{variant:`ghost`,size:`sm`,onClick:a,disabled:i,children:s(`common:actions.cancel`)}),(0,Y.jsxs)(Z,{size:`sm`,onClick:()=>o(c),disabled:i,"data-testid":`smash-confirm-modal-continue`,children:[(0,Y.jsx)($s,{className:`w-3.5 h-3.5 mr-1.5`}),s(i?`smashModal.starting`:n?`smashModal.confirmReSmash`:`smashModal.smash`)]})]})]}),(0,Y.jsx)(xb,{handles:p})]}):null}var VH=`## Contract Layer`;function HH(e,t){return!(!t||e.status===`draft`||e.parent_epic_id!=null||!e.description?.includes(VH))}function UH({ticket:e,projectId:t,featureFlagOn:n,childrenCount:r}){let{t:i}=K(`activity`),a=PH(e.id),[s,c]=(0,H.useState)(!1),[l,u]=(0,H.useState)(!1),d=e.is_epic===!0,f=!d&&HH(e,n),p=d&&n,m=d&&r>0,h=(0,H.useCallback)(async n=>{u(!0);try{let r=await fetch(`${o}/api/projects/${t}/tickets/${e.id}/smash`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({mode:n})});if(!r.ok){let e=await r.json().catch(()=>({}));q.error(e.reason?i(`smash.couldNotStartWithReason`,{reason:e.reason}):i(`smash.couldNotStart`));return}c(!1)}catch(e){q.error(i(`smash.smashFailed`,{message:e.message}))}finally{u(!1)}},[t,e.id,i]),g=(0,H.useCallback)(async n=>{if(m){u(!0);try{if(!(await fetch(`${o}/api/projects/${t}/tickets/${e.id}/children`,{method:`DELETE`})).ok){q.error(i(`smash.couldNotDeleteChildren`)),u(!1);return}}catch(e){q.error(i(`smash.deleteFailed`,{message:e.message})),u(!1);return}}await h(n)},[m,h,t,e.id,i]);return!f&&!p?null:a?(0,Y.jsx)(`div`,{className:`flex flex-col gap-2`,"data-testid":`smash-actions-streaming`,children:(0,Y.jsx)(RH,{stage:a.stage})}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(Z,{size:`sm`,variant:`outline`,onClick:()=>c(!0),className:`border-accent-highlight/40 text-accent-highlight hover:bg-accent-highlight/10`,"data-testid":p?`resmash-button`:`smash-button`,children:[(0,Y.jsx)($s,{className:`w-3.5 h-3.5 mr-1.5`}),i(p?`smash.reSmashButton`:`smash.smashButton`)]}),(0,Y.jsx)(BH,{open:s,ticketTitle:e.title,isReSmash:m,childrenCount:r,submitting:l,onCancel:()=>c(!1),onConfirm:g})]})}function WH({epic:e,childExecutionOrder:t,totalChildren:n,onOpenEpic:r}){let{t:i}=K(`activity`);return(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-accent-secondary/30 bg-accent-secondary/10 px-3 py-1.5 text-xs`,"data-testid":`epic-breadcrumb`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:r,className:`text-accent-secondary hover:underline font-medium`,children:[`← `,e.title]}),t!=null&&n>0&&(0,Y.jsx)(`span`,{className:`text-foreground/60`,children:i(`epicChildren.step`,{order:t,total:n})})]})}var GH={critical:`bg-red-400`,high:`bg-orange-400`,medium:`bg-yellow-400`,low:`bg-slate-400`};function KH(e){return e?GH[e]:`bg-muted`}function qH(e){return[...e].sort((e,t)=>{let n=e.execution_order??1/0,r=t.execution_order??1/0;return n===r?e.id-t.id:n-r})}function JH({ticket:e,allTickets:t,onOpenTicket:n}){let{t:r}=K(`activity`),i=e.is_epic===!0,a=e.parent_epic_id!=null;if(!i&&!a)return null;if(i){let i=qH(t.filter(t=>t.parent_epic_id===e.id));return(0,Y.jsx)(YH,{header:r(`family.subSpecsHeader`,{count:i.length}),rows:i,currentId:e.id,onOpenTicket:n,emptyMessage:r(`family.emptySubSpecs`)})}let o=t.find(t=>t.id===e.parent_epic_id)??null,s=qH(t.filter(t=>t.parent_epic_id===e.parent_epic_id)),c=o?[o,...s]:s;return(0,Y.jsx)(YH,{header:r(`family.familyHeader`,{count:s.length}),rows:c,currentId:e.id,onOpenTicket:n,emptyMessage:r(`family.noSiblings`)})}function YH({header:e,rows:t,currentId:n,onOpenTicket:r,emptyMessage:i}){let{t:a}=K(`activity`);return(0,Y.jsxs)(`div`,{"data-testid":`epic-family-sidebar`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1.5`,children:[(0,Y.jsx)($s,{className:`w-3 h-3 text-accent-highlight`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider`,children:e})]}),t.length===0?(0,Y.jsx)(`p`,{className:`text-[10px] text-foreground/50 italic`,children:i}):(0,Y.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:t.map(e=>{let t=e.id===n,i=e.is_epic===!0;return(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{t||r(e.id)},disabled:t,"aria-label":a(i?`family.openParentEpic`:`family.openSubSpec`,{title:e.title}),"aria-current":t?`page`:void 0,className:[`w-full flex items-center gap-1.5 rounded px-1.5 py-1 text-left transition-colors`,t?`bg-accent-highlight/15 cursor-default`:`hover:bg-muted/30 cursor-pointer`].join(` `),"data-testid":`epic-family-row-${e.id}`,children:[i?(0,Y.jsx)(Ua,{className:`w-3 h-3 text-accent-highlight flex-shrink-0`,"aria-hidden":!0}):(0,Y.jsx)(`span`,{className:`text-[9px] tabular-nums text-foreground/40 w-3 text-center flex-shrink-0`,children:e.execution_order??`–`}),(0,Y.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full flex-shrink-0 ${KH(e.priority)}`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`text-[11px] truncate ${t?`text-foreground font-medium`:`text-foreground/80`}`,title:e.title,children:e.title})]})},e.id)})})]})}var XH=900,ZH=.2,QH=[{value:`critical`,labelKey:`priority.critical`,className:`text-red-400`},{value:`high`,labelKey:`priority.high`,className:`text-orange-400`},{value:`medium`,labelKey:`priority.medium`,className:`text-yellow-400`},{value:`low`,labelKey:`priority.low`,className:`text-slate-400`}];function $H(e){return e.jira_epic_key&&e.jira_url?e.jira_url.replace(/\/browse\/[^/]+$/,`/browse/${e.jira_epic_key}`):null}var eU={manual:`source.manual`,"product-backlog":`source.productBacklog`,"propose-spec":`source.proposeSpec`,"get-backlog-specs":`source.getBacklogSpecs`,"free-prompt":`source.freePrompt`};function tU({ticket:e,allLabels:t,allTickets:n,onClose:r,onOpenTicket:i,onSave:a,onDelete:o,rails:s,onMoveToRail:c,onRemoveFromRail:l,embedded:u=!1}){let{t:d}=K(`tickets`),{t:f}=K(`jira`),{activeProjectId:p,projects:m}=gm(),{enterSplit:h,state:g}=dH(),_=g.originSide!==null,v=m.find(e=>e.id===p)?.provider!==`codex`,y=(0,H.useMemo)(()=>(n??[]).filter(t=>t.parent_epic_id===e.id),[n,e.id]),b=(0,H.useMemo)(()=>e.parent_epic_id==null?null:(n??[]).find(t=>t.id===e.parent_epic_id)??null,[n,e.parent_epic_id]),x=(0,H.useMemo)(()=>b?(n??[]).filter(e=>e.parent_epic_id===b.id).length:0,[n,b]),[S,C]=(0,H.useState)(e.title),[w,T]=(0,H.useState)(e.description),[E,D]=(0,H.useState)(e.priority??`medium`),[O,k]=(0,H.useState)([...e.labels??[]]),[A,j]=(0,H.useState)(!1),[M,N]=(0,H.useState)(!1),[P,F]=(0,H.useState)(``),[I,L]=(0,H.useState)(!1),[R,z]=(0,H.useState)(!1),[ee,te]=(0,H.useState)(!1),[B,ne]=(0,H.useState)(!1),[V,re]=(0,H.useState)(!1),U=Wb(),ie=U.connected&&!!U.discardStatus&&e.source===`jira`&&!!e.jira_key,ae=U.connected&&e.source===`jira`&&!!e.jira_key,[W,oe]=(0,H.useState)(e.attachments??[]);(0,H.useEffect)(()=>{oe(e.attachments??[])},[e.attachments,e.id]);let se=(0,H.useRef)(null),ce=(0,H.useRef)(null),le=(0,H.useRef)(null),ue=(0,H.useMemo)(()=>S!==e.title||w!==e.description||E!==e.priority||JSON.stringify(O)!==JSON.stringify(e.labels),[S,w,E,O,e]);(0,H.useEffect)(()=>{A&&se.current?.focus()},[A]),(0,H.useEffect)(()=>{if(M){let e=ce.current;e&&(e.focus(),e.selectionStart=e.value.length)}},[M]),(0,H.useEffect)(()=>{I&&le.current?.focus()},[I]),(0,H.useEffect)(()=>{function e(e){e.key===`Escape`&&!A&&!M&&!R&&r()}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r,A,M,R]);let de=(0,H.useMemo)(()=>{if(!P.trim())return[];let e=P.toLowerCase();return t.filter(t=>t.toLowerCase().includes(e)&&!O.includes(t)).slice(0,5)},[P,t,O]),fe=(0,H.useCallback)(e=>{let t=e.trim();t&&!O.includes(t)&&k(e=>[...e,t]),F(``)},[O]),pe=(0,H.useCallback)(e=>{k(t=>t.filter(t=>t!==e))},[]),me=(0,H.useCallback)(async()=>{let t={};if(S!==e.title&&(t.title=S),w!==e.description&&(t.description=w),E!==e.priority&&(t.priority=E),JSON.stringify(O)!==JSON.stringify(e.labels)&&(t.labels=O),Object.keys(t).length===0){r();return}re(!0);let n=await a(e.id,t);re(!1),n?(q.success(d(`detailModal.toast.updated`)),r()):q.error(d(`detailModal.toast.updateFailed`))},[S,w,E,O,e,a,r,d]),he=(0,H.useCallback)(()=>{o(e.id),z(!1),r()},[e.id,o,r]),[ge,_e]=(0,H.useState)(0),ve=(0,H.useRef)(null),ye=!u&&!_&&typeof window<`u`&&window.innerWidth>=XH,G=(0,H.useCallback)(e=>{ve.current&&_e(e.clientX-ve.current.startX)},[]),be=(0,H.useCallback)(t=>{if(!ve.current)return;let n=t.clientX-ve.current.startX,i=window.innerWidth*ZH;if(window.removeEventListener(`pointermove`,G),window.removeEventListener(`pointerup`,be),window.removeEventListener(`pointercancel`,be),ve.current=null,_e(0),Math.abs(n)>=i){let t=g.leftId===e.id;h(n<0?`left`:`right`,e.id),t||r()}},[h,G,g.leftId,e.id,r]),xe=(0,H.useCallback)(e=>{ye&&e.button===0&&(e.target.closest(`button, input, textarea, select, [contenteditable="true"]`)||(ve.current={startX:e.clientX,pointerId:e.pointerId},window.addEventListener(`pointermove`,G),window.addEventListener(`pointerup`,be),window.addEventListener(`pointercancel`,be)))},[ye,G,be]);(0,H.useEffect)(()=>()=>{ve.current&&(window.removeEventListener(`pointermove`,G),window.removeEventListener(`pointerup`,be),window.removeEventListener(`pointercancel`,be))},[G,be]);let Se=(0,H.useCallback)(()=>{if(!ye)return;let t=g.leftId===e.id;h(`right`,e.id),t||r()},[ye,h,g.leftId,e.id,r]),{panelRef:Ce,panelStyle:we,resizeHandles:Te,guardBackdrop:Ee}=yb({enabled:!u,allowMove:!1}),De=(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{ref:Ce,className:u?`relative w-full h-full rounded-xl bg-card border border-border/40 shadow-2xl shadow-black/50 flex flex-col overflow-hidden`:`relative w-full max-w-[67rem] m-4 rounded-xl bg-card border border-border/40 shadow-2xl shadow-black/50 flex flex-col animate-in fade-in zoom-in-95 duration-200 h-[90vh]`,style:{...ge===0?{transition:`transform 220ms cubic-bezier(0.34, 1.56, 0.64, 1)`}:{transform:`translateX(${ge}px)`,transition:`none`},...we},children:[b&&(0,Y.jsx)(`div`,{className:`px-5 pt-3`,children:(0,Y.jsx)(WH,{epic:b,childExecutionOrder:e.execution_order??null,totalChildren:x,onOpenEpic:()=>i?.(b.id)})}),(0,Y.jsxs)(`div`,{className:`flex items-start justify-between gap-3 px-5 py-4 border-b border-border/30 ${ye?`cursor-grab active:cursor-grabbing`:``}`,onPointerDown:xe,"data-testid":`ticket-modal-header`,children:[(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[A?(0,Y.jsx)(`input`,{ref:se,value:S,onChange:e=>C(e.target.value),onBlur:()=>j(!1),onKeyDown:t=>{t.key===`Enter`&&j(!1),t.key===`Escape`&&(C(e.title),j(!1))},className:`w-full bg-transparent border-b border-accent-primary/50 text-sm font-semibold text-foreground outline-none pb-0.5`}):(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>j(!0),className:`group flex items-center gap-1.5 text-left w-full`,children:[(0,Y.jsx)(`h2`,{className:`text-sm font-semibold text-foreground truncate`,children:S||d(`untitled`)}),(0,Y.jsx)(ws,{className:`w-3 h-3 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity shrink-0`})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 mt-1.5`,children:[(0,Y.jsxs)(`span`,{className:`text-[10px] text-foreground font-mono`,children:[`#`,e.id]}),e.status===`on_review`&&(0,Y.jsx)(`span`,{title:d(`specs:status.onReviewHint`),"data-testid":`ticket-modal-on-review-badge`,children:(0,Y.jsx)(sx,{status:`on_review`})})]}),(0,Y.jsx)(bH,{ticketId:e.id})]}),p&&(0,Y.jsx)(`div`,{className:`shrink-0`,children:(0,Y.jsx)(UH,{ticket:e,projectId:p,featureFlagOn:v,childrenCount:y.length})}),(0,Y.jsx)(rU,{ticket:e,title:S,description:w,priority:E,labels:O,onClose:r}),s&&(c||l)&&(0,Y.jsx)(iU,{ticket:e,rails:s,onMoveToRail:c,onRemoveFromRail:l}),ye&&(0,Y.jsxs)(Z,{variant:`outline`,size:`sm`,className:`shrink-0 mr-1 gap-1.5`,"data-testid":`ticket-modal-compare`,onClick:Se,title:d(`detailModal.compareTooltip`),children:[(0,Y.jsx)(vo,{className:`w-3.5 h-3.5`}),d(`detailModal.compare`)]}),(0,Y.jsx)(`button`,{onClick:r,className:`h-7 w-7 flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-surface/50 transition-colors cursor-pointer shrink-0`,"data-testid":`ticket-modal-close`,children:(0,Y.jsx)(hc,{className:`w-4 h-4`})})]}),(0,Y.jsx)(`div`,{className:`flex-1 overflow-y-auto min-h-0`,children:(0,Y.jsxs)(`div`,{className:`flex flex-col sm:flex-row h-full`,children:[(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0 px-5 py-4 space-y-4 flex flex-col`,children:[(0,Y.jsxs)(`div`,{className:`flex-1 flex flex-col`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider flex items-center gap-1.5`,children:d(`fields.description`)}),!M&&(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>N(!0),className:`text-[10px] text-muted-foreground hover:text-foreground transition-colors flex items-center gap-1`,children:[(0,Y.jsx)(ws,{className:`w-2.5 h-2.5`}),d(`common:actions.edit`)]})]}),M?(0,Y.jsxs)(`div`,{className:`space-y-1.5 flex-1 flex flex-col`,children:[(0,Y.jsx)(`textarea`,{ref:ce,value:w,onChange:e=>T(e.target.value),className:`w-full flex-1 rounded-lg border border-border bg-input px-3 py-2 text-xs text-foreground placeholder:text-muted-foreground resize-none min-h-[300px]`,placeholder:d(`fields.markdownPlaceholder`)}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(Z,{variant:`ghost`,size:`sm`,className:`h-6 text-[10px]`,onClick:()=>N(!1),children:d(`detailModal.doneEditing`)}),(0,Y.jsx)(`span`,{className:`text-[9px] text-muted-foreground`,children:d(`fields.supportsMarkdown`)})]})]}):w?(0,Y.jsx)(cU,{description:w,onEdit:()=>N(!0)}):(0,Y.jsx)(`button`,{type:`button`,onClick:()=>N(!0),className:`w-full rounded-lg border border-dashed border-border/40 bg-muted/10 px-3 py-4 text-xs text-muted-foreground hover:text-foreground hover:bg-muted/20 transition-colors text-center`,children:d(`detailModal.addDescription`)})]}),(0,Y.jsx)(JV,{ticketKey:e.id,attachments:W,onChange:oe}),(0,Y.jsx)(YV,{ticketId:e.id,onClose:r}),e.prerequisites&&e.prerequisites.length>0&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1.5`,children:d(`detailModal.prerequisites`)}),(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.prerequisites.map(e=>(0,Y.jsxs)(`span`,{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[10px] font-mono bg-accent/60 text-foreground/70`,children:[`#`,e]},e))})]})]}),(0,Y.jsxs)(`div`,{className:`sm:w-56 sm:border-l border-t sm:border-t-0 border-border/30 px-4 py-4 space-y-4 bg-muted/5`,children:[e.jira_url&&e.jira_key&&(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{HV(e.jira_url)},"data-testid":`jira-go-to-ticket`,className:`w-full inline-flex items-center justify-center gap-1.5 h-7 rounded border border-accent-info/50 bg-accent-info/10 px-2 text-xs font-medium text-accent-info hover:bg-accent-info/20 transition-colors`,children:[(0,Y.jsx)(Oo,{className:`w-3.5 h-3.5 shrink-0`}),f(`detail.goToTicket`,{key:e.jira_key})]}),e.jira_epic_key&&(0,Y.jsxs)(`div`,{"data-testid":`jira-epic`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1.5`,children:f(`detail.epic`)}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{let t=$H(e);t&&HV(t)},title:e.jira_epic_name??e.jira_epic_key,className:`w-full inline-flex items-center gap-1.5 rounded border border-accent-highlight/40 bg-accent-highlight/5 px-2 py-1.5 text-left text-xs hover:bg-accent-highlight/10 transition-colors`,children:[(0,Y.jsx)(`span`,{className:`font-mono text-accent-highlight shrink-0`,children:e.jira_epic_key}),e.jira_epic_name&&(0,Y.jsx)(`span`,{className:`truncate text-foreground/80`,children:e.jira_epic_name})]})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1.5`,children:d(`fields.priority`)}),(0,Y.jsx)(`select`,{value:E,onChange:e=>D(e.target.value),className:`w-full h-7 rounded border border-border bg-input px-2 text-xs text-foreground`,children:QH.map(e=>(0,Y.jsx)(`option`,{value:e.value,children:d(e.labelKey)},e.value))})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1.5`,children:d(`fields.labels`)}),(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-1 mb-1.5`,children:O.map(e=>(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 rounded px-1.5 py-0.5 text-[10px] font-medium bg-accent/60 text-foreground/70 group`,children:[e,(0,Y.jsx)(`button`,{type:`button`,onClick:()=>pe(e),className:`text-muted-foreground hover:text-foreground opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,Y.jsx)(lo,{className:`w-2.5 h-2.5`})})]},e))}),I?(0,Y.jsxs)(`div`,{className:`relative`,children:[(0,Y.jsx)(`input`,{ref:le,value:P,onChange:e=>F(e.target.value),onKeyDown:e=>{e.key===`Enter`&&P.trim()&&(e.preventDefault(),fe(P)),e.key===`Escape`&&(L(!1),F(``))},onBlur:()=>{P.trim()&&fe(P),L(!1),F(``)},placeholder:d(`detailModal.addLabelPlaceholder`),className:`w-full h-6 rounded border border-border bg-input px-2 text-[10px] text-foreground placeholder:text-muted-foreground`}),de.length>0&&(0,Y.jsx)(`div`,{className:`absolute left-0 right-0 top-full mt-0.5 rounded border border-border/50 bg-popover shadow-lg z-10 py-0.5`,children:de.map(e=>(0,Y.jsx)(`button`,{type:`button`,onMouseDown:t=>{t.preventDefault(),fe(e)},className:`w-full text-left px-2 py-1 text-[10px] hover:bg-accent/50 text-foreground/80`,children:e},e))})]}):(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>L(!0),className:`flex items-center gap-1 text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:[(0,Y.jsx)(ks,{className:`w-2.5 h-2.5`}),d(`detailModal.addLabel`)]})]}),(0,Y.jsx)(JH,{ticket:e,allTickets:n??[],onOpenTicket:e=>i?.(e)}),e.source===`jira`&&e.jira_key&&(0,Y.jsx)(CH,{localId:e.id}),e.metadata?.effort_level&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-0.5`,children:d(`detailModal.effort`)}),(0,Y.jsx)(`span`,{className:`text-xs text-foreground/70`,children:e.metadata.effort_level})]}),e.assignee&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-0.5`,children:d(`detailModal.assignee`)}),(0,Y.jsx)(`span`,{className:`text-xs text-foreground/70`,children:e.assignee})]})]})]})}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-3 border-t border-border/30`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 text-[10px] text-muted-foreground`,children:[(0,Y.jsx)(`span`,{children:d(`meta.createdAgo`,{time:nU(e.created_at)})}),(0,Y.jsx)(`span`,{children:d(`meta.updatedAgo`,{time:nU(e.updated_at)})}),e.source&&(0,Y.jsx)(`span`,{className:`bg-muted/30 rounded px-1.5 py-0.5`,children:eU[e.source]?d(eU[e.source]):e.source})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[ie?(0,Y.jsxs)(Z,{variant:`ghost`,size:`sm`,className:`h-7 text-xs text-accent-info hover:bg-accent-info/10`,onClick:()=>te(!0),"data-testid":`jira-move-to-button`,children:[(0,Y.jsx)(Va,{className:`w-3 h-3 mr-1`}),f(`discard.moveButton`,{status:U.discardStatus})]}):(0,Y.jsxs)(Z,{variant:`ghost`,size:`sm`,className:`h-7 text-xs text-red-400 aurora-light:text-destructive hover:text-red-300 aurora-light:hover:text-destructive hover:bg-red-500/10 aurora-light:hover:bg-destructive/10`,onClick:()=>z(!0),children:[(0,Y.jsx)(cc,{className:`w-3 h-3 mr-1`}),d(`common:actions.delete`)]}),ue&&(0,Y.jsxs)(Z,{size:`sm`,className:`h-7 text-xs`,onClick:()=>{ae?ne(!0):me()},disabled:V||!S.trim(),children:[(0,Y.jsx)(Bs,{className:`w-3 h-3 mr-1`}),d(V?`common:states.saving`:`common:actions.save`)]})]})]})]}),(0,Y.jsx)(Cb,{open:R,onOpenChange:z,children:(0,Y.jsxs)(Db,{className:`max-w-sm`,children:[(0,Y.jsxs)(Ob,{children:[(0,Y.jsx)(Ab,{children:d(`deleteDialog.title`)}),(0,Y.jsx)(jb,{children:(0,Y.jsx)(Yi,{t:d,i18nKey:`deleteDialog.body`,values:{id:e.id,title:e.title},components:{strong:(0,Y.jsx)(`span`,{className:`font-semibold text-foreground`})}})})]}),(0,Y.jsxs)(kb,{children:[(0,Y.jsx)(Z,{variant:`outline`,size:`sm`,onClick:()=>z(!1),children:d(`common:actions.cancel`)}),(0,Y.jsxs)(Z,{variant:`destructive`,size:`sm`,onClick:he,children:[(0,Y.jsx)(cc,{className:`w-3.5 h-3.5 mr-1.5`}),d(`common:actions.delete`)]})]})]})}),ie&&U.discardStatus&&(0,Y.jsx)(Jb,{open:ee,onOpenChange:te,ticket:{id:e.id,title:e.title,jira_key:e.jira_key},discardStatus:U.discardStatus,onDiscarded:r}),(0,Y.jsx)(Cb,{open:B,onOpenChange:ne,children:(0,Y.jsxs)(Db,{className:`max-w-md`,"data-testid":`jira-save-confirm`,children:[(0,Y.jsxs)(Ob,{children:[(0,Y.jsx)(Ab,{children:f(`detail.saveTitle`)}),(0,Y.jsx)(jb,{children:f(`detail.saveBody`,{key:e.jira_key??`#${e.id}`})})]}),(0,Y.jsxs)(kb,{children:[(0,Y.jsx)(Z,{variant:`outline`,size:`sm`,onClick:()=>ne(!1),children:d(`common:actions.cancel`)}),(0,Y.jsxs)(Z,{size:`sm`,onClick:()=>{ne(!1),me()},disabled:V,"data-testid":`jira-save-confirm-btn`,children:[(0,Y.jsx)(Bs,{className:`w-3.5 h-3.5 mr-1.5`}),f(`detail.saveConfirm`)]})]})]})})]});return u?De:(0,Y.jsxs)(`div`,{className:`fixed inset-0 z-[68] flex items-center justify-center`,children:[(0,Y.jsx)(`div`,{className:`absolute inset-0 bg-black/70`,onClick:Ee(r)}),De,(0,Y.jsx)(xb,{handles:Te})]})}function nU(e){try{return vV(new Date(e),{addSuffix:!0,locale:im()})}catch{return e}}function rU({ticket:e,title:t,description:n,priority:r,labels:i,onClose:a}){let{t:o}=K(`tickets`),{triggerResume:s}=Vg(),{activeProjectId:c}=gm(),{closeTicketDetail:l}=dH();return Kg(e)?(0,Y.jsxs)(Z,{variant:`default`,size:`sm`,onClick:()=>{if(!c)return;let{body:u,criteria:d}=Wg(n);s({kind:`explore-spec`,projectId:c,label:t||e.title||o(`detailModal.ticketFallbackLabel`,{id:e.id}),restoreRoute:`/`,params:{initialIdea:``,pendingSpecId:qg(),initialAttachmentIds:[],resumeConversationId:e.origin_conversation_id??void 0,editTicket:{id:e.id,title:t,description:u,labels:i,priority:r,acceptanceCriteria:d,status:e.status}}}),l(),a()},className:`shrink-0 mr-2`,"data-testid":`continue-editing`,children:[(0,Y.jsx)(ds,{className:`w-3.5 h-3.5 mr-1.5`}),o(`detailModal.continueEditing`)]}):null}function iU({ticket:e,rails:t,onMoveToRail:n,onRemoveFromRail:r}){let{t:i}=K(`tickets`),[a,o]=(0,H.useState)(null),s=(0,H.useRef)(null),c=t.find(t=>t.ticketIds.includes(e.id));return c?r?(0,Y.jsxs)(Z,{variant:`outline`,size:`sm`,className:`shrink-0 mr-2 gap-1.5 border-accent-warning/30 text-accent-warning hover:bg-accent-warning/10 hover:text-accent-warning`,"data-testid":`modal-remove-from-rail`,onClick:()=>r(e.id),title:i(`rail.currentlyOn`,{rail:c.label}),children:[(0,Y.jsx)(Ba,{className:`w-3.5 h-3.5`,"aria-hidden":!0}),i(`rail.removeFromRail`)]}):null:n?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(Z,{ref:s,variant:`outline`,size:`sm`,className:`shrink-0 mr-2 gap-1.5 border-accent-info/30 text-accent-info hover:bg-accent-info/10 hover:text-accent-info`,"data-testid":`modal-move-to-rail`,onClick:()=>{s.current&&o(s.current.getBoundingClientRect())},children:[i(`rail.moveToRail`),(0,Y.jsx)(Va,{className:`w-3.5 h-3.5`,"aria-hidden":!0})]}),a&&(0,Y.jsx)(_g,{rails:t,anchorRect:a,onMoveToRail:t=>n(e.id,t),onClose:()=>o(null)})]}):null}var aU=`
112
112
 
113
113
  ---
114
114
 
@@ -139,10 +139,10 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
139
139
  `),()=>{s.current?.removeAttribute(`data-motion-pop-id`),b.contains(y)&&b.removeChild(y)}},[t]),(0,Y.jsx)(F3,{isPresent:t,childRef:s,sizeRef:c,pop:a,children:a===!1?e:H.cloneElement(e,{ref:u})})}var L3=({children:e,initial:t,isPresent:n,onExitComplete:r,custom:i,presenceAffectsLayout:a,mode:o,anchorX:s,anchorY:c,root:l})=>{let u=XY(R3),d=(0,H.useId)(),f=(0,H.useRef)(n),p=(0,H.useRef)(r);ZY(()=>{f.current=n,p.current=r});let m=!0,h=(0,H.useMemo)(()=>(m=!1,{id:d,initial:t,isPresent:n,custom:i,onExitComplete:e=>{u.set(e,!0);for(let e of u.values())if(!e)return;r&&r()},register:e=>(u.set(e,!1),()=>{u.delete(e),!f.current&&!u.size&&p.current?.()})}),[n,u,r]);return a&&m&&(h={...h}),(0,H.useMemo)(()=>{u.forEach((e,t)=>u.set(t,!1))},[n]),H.useEffect(()=>{!n&&!u.size&&r&&r()},[n]),e=(0,Y.jsx)(I3,{pop:o===`popLayout`,isPresent:n,anchorX:s,anchorY:c,root:l,children:e}),(0,Y.jsx)(QY.Provider,{value:h,children:e})};function R3(){return new Map}function z3(e=!0){let t=(0,H.useContext)(QY);if(t===null)return[!0,null];let{isPresent:n,onExitComplete:r,register:i}=t,a=(0,H.useId)();(0,H.useEffect)(()=>{if(e)return i(a)},[e]);let o=(0,H.useCallback)(()=>e&&r&&r(a),[a,r,e]);return!n&&r?[!1,o]:[!0]}var B3=e=>e.key||``;function V3(e){let t=[];return H.Children.forEach(e,e=>{(0,H.isValidElement)(e)&&t.push(e)}),t}var H3=({children:e,custom:t,initial:n=!0,onExitComplete:r,presenceAffectsLayout:i=!0,mode:a=`sync`,propagate:o=!1,anchorX:s=`left`,anchorY:c=`top`,root:l})=>{let[u,d]=z3(o),f=(0,H.useMemo)(()=>V3(e),[e]),p=o&&!u?[]:f.map(B3),m=(0,H.useRef)(!0),h=(0,H.useRef)(f),g=XY(()=>new Map),_=(0,H.useRef)(new Set),[v,y]=(0,H.useState)(f),[b,x]=(0,H.useState)(f);ZY(()=>{m.current=!1,h.current=f;for(let e=0;e<b.length;e++){let t=B3(b[e]);p.includes(t)?(g.delete(t),_.current.delete(t)):g.get(t)!==!0&&g.set(t,!1)}},[b,p.length,p.join(`-`)]);let S=[];if(f!==v){let e=[...f];for(let t=0;t<b.length;t++){let n=b[t],r=B3(n);p.includes(r)||(e.splice(t,0,n),S.push(n))}return a===`wait`&&S.length&&(e=S),x(V3(e)),y(f),null}let{forceRender:C}=(0,H.useContext)(YY);return(0,Y.jsx)(Y.Fragment,{children:b.map(e=>{let v=B3(e),y=o&&!u?!1:f===b||p.includes(v);return(0,Y.jsx)(L3,{isPresent:y,initial:!m.current||n?void 0:!1,custom:t,presenceAffectsLayout:i,mode:a,root:l,onExitComplete:y?void 0:()=>{if(_.current.has(v))return;if(g.has(v))_.current.add(v),g.set(v,!0);else return;let e=!0;g.forEach(t=>{t||(e=!1)}),e&&(C?.(),x(h.current),o&&d?.(),r&&r())},anchorX:s,anchorY:c,children:e},v)})})},U3=(0,H.createContext)({strict:!1}),W3={animation:[`animate`,`variants`,`whileHover`,`whileTap`,`exit`,`whileInView`,`whileFocus`,`whileDrag`],exit:[`exit`],drag:[`drag`,`dragControls`],focus:[`whileFocus`],hover:[`whileHover`,`onHoverStart`,`onHoverEnd`],tap:[`whileTap`,`onTap`,`onTapStart`,`onTapCancel`],pan:[`onPan`,`onPanStart`,`onPanSessionStart`,`onPanEnd`],inView:[`whileInView`,`onViewportEnter`,`onViewportLeave`],layout:[`layout`,`layoutId`]},G3=!1;function K3(){if(G3)return;let e={};for(let t in W3)e[t]={isEnabled:e=>W3[t].some(t=>!!e[t])};Y0(e),G3=!0}function q3(){return K3(),X0()}function J3(e){let t=q3();for(let n in e)t[n]={...t[n],...e[n]};Y0(t)}var Y3=new Set(`animate.exit.variants.initial.style.values.variants.transition.transformTemplate.custom.inherit.onBeforeLayoutMeasure.onAnimationStart.onAnimationComplete.onUpdate.onDragStart.onDrag.onDragEnd.onMeasureDragConstraints.onDirectionLock.onDragTransitionEnd._dragX._dragY.onHoverStart.onHoverEnd.onViewportEnter.onViewportLeave.globalTapTarget.propagate.ignoreStrict.viewport`.split(`.`));function X3(e){return e.startsWith(`while`)||e.startsWith(`drag`)&&e!==`draggable`||e.startsWith(`layout`)||e.startsWith(`onTap`)||e.startsWith(`onPan`)||e.startsWith(`onLayout`)||Y3.has(e)}var Z3=r({default:()=>Q3}),Q3,$3=n((()=>{throw Q3={},Error(`Could not resolve "@emotion/is-prop-valid" imported by "framer-motion". Is it installed?`)})),e6=e=>!X3(e);function t6(e){typeof e==`function`&&(e6=t=>t.startsWith(`on`)?!X3(t):e(t))}try{t6(($3(),t(Z3)).default)}catch{}function n6(e,t,n){let r={};for(let i in e)i===`values`&&typeof e.values==`object`||f1(e[i])||(e6(i)||n===!0&&X3(i)||!t&&!X3(i)||e.draggable&&i.startsWith(`onDrag`))&&(r[i]=e[i]);return r}function r6({children:e,isValidProp:t,...n}){t&&t6(t);let r=(0,H.useContext)(j3);n={...r,...n},n.transition=G$(n.transition,r.transition),n.isStatic=XY(()=>n.isStatic);let i=(0,H.useMemo)(()=>n,[JSON.stringify(n.transition),n.transformPagePoint,n.reducedMotion,n.skipAnimations]);return(0,Y.jsx)(j3.Provider,{value:i,children:e})}var i6=(0,H.createContext)({});function a6(e,t){if(B0(e)){let{initial:t,animate:n}=e;return{initial:t===!1||L0(t)?t:void 0,animate:L0(n)?n:void 0}}return e.inherit===!1?{}:t}function o6(e){let{initial:t,animate:n}=a6(e,(0,H.useContext)(i6));return(0,H.useMemo)(()=>({initial:t,animate:n}),[s6(t),s6(n)])}function s6(e){return Array.isArray(e)?e.join(` `):e}var c6=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function l6(e,t,n){for(let r in t)!f1(t[r])&&!A2(r,n)&&(e[r]=t[r])}function u6({transformTemplate:e},t){return(0,H.useMemo)(()=>{let n=c6();return w2(n,t,e),Object.assign({},n.vars,n.style)},[t])}function d6(e,t){let n=e.style||{},r={};return l6(r,n,e),Object.assign(r,u6(e,t)),r}function f6(e,t){let n={},r=d6(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout=`none`,r.touchAction=e.drag===!0?`none`:`pan-${e.drag===`x`?`y`:`x`}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=r,n}var p6=()=>({...c6(),attrs:{}});function m6(e,t,n,r){let i=(0,H.useMemo)(()=>{let n=p6();return R2(n,t,B2(r),e.transformTemplate,e.style),{...n.attrs,style:{...n.style}}},[t]);if(e.style){let t={};l6(t,e.style,e),i.style={...t,...i.style}}return i}var h6=[`animate`,`circle`,`defs`,`desc`,`ellipse`,`g`,`image`,`line`,`filter`,`marker`,`mask`,`metadata`,`path`,`pattern`,`polygon`,`polyline`,`rect`,`stop`,`switch`,`symbol`,`svg`,`text`,`tspan`,`use`,`view`];function g6(e){return typeof e!=`string`||e.includes(`-`)?!1:!!(h6.indexOf(e)>-1||/[A-Z]/u.test(e))}function _6(e,t,n,{latestValues:r},i,a=!1,o){let s=(o??g6(e)?m6:f6)(t,r,i,e),c=n6(t,typeof e==`string`,a),l=e===H.Fragment?{}:{...c,...s,ref:n},{children:u}=t,d=(0,H.useMemo)(()=>f1(u)?u.get():u,[u]);return(0,H.createElement)(e,{...l,children:d})}function v6({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,i){return{latestValues:y6(n,r,i,e),renderState:t()}}function y6(e,t,n,r){let i={},a=r(e,{});for(let e in a)i[e]=K4(a[e]);let{initial:o,animate:s}=e,c=B0(e),l=V0(e);t&&l&&!c&&e.inherit!==!1&&(o===void 0&&(o=t.initial),s===void 0&&(s=t.animate));let u=n?n.initial===!1:!1;u||=o===!1;let d=u?s:o;if(d&&typeof d!=`boolean`&&!I0(d)){let t=Array.isArray(d)?d:[d];for(let n=0;n<t.length;n++){let r=a1(e,t[n]);if(r){let{transitionEnd:e,transition:t,...n}=r;for(let e in n){let t=n[e];if(Array.isArray(t)){let e=u?t.length-1:0;t=t[e]}t!==null&&(i[e]=t)}for(let t in e)i[t]=e[t]}}}return i}var b6=e=>(t,n)=>{let r=(0,H.useContext)(i6),i=(0,H.useContext)(QY),a=()=>v6(e,t,r,i);return n?a():XY(a)},x6=b6({scrapeMotionValuesFromProps:j2,createRenderState:c6}),S6=b6({scrapeMotionValuesFromProps:H2,createRenderState:p6}),C6=Symbol.for(`motionComponentSymbol`);function w6(e,t,n){let r=(0,H.useRef)(n);(0,H.useInsertionEffect)(()=>{r.current=n});let i=(0,H.useRef)(null);return(0,H.useCallback)(n=>{n&&e.onMount?.(n),t&&(n?t.mount(n):t.unmount());let a=r.current;if(typeof a==`function`)if(n){let e=a(n);typeof e==`function`&&(i.current=e)}else i.current?(i.current(),i.current=null):a(n);else a&&(a.current=n)},[t])}var T6=(0,H.createContext)({});function E6(e){return e&&typeof e==`object`&&Object.prototype.hasOwnProperty.call(e,`current`)}function D6(e,t,n,r,i,a){let{visualElement:o}=(0,H.useContext)(i6),s=(0,H.useContext)(U3),c=(0,H.useContext)(QY),l=(0,H.useContext)(j3),u=l.reducedMotion,d=l.skipAnimations,f=(0,H.useRef)(null),p=(0,H.useRef)(!1);r||=s.renderer,!f.current&&r&&(f.current=r(e,{visualState:t,parent:o,props:n,presenceContext:c,blockInitialAnimation:c?c.initial===!1:!1,reducedMotionConfig:u,skipAnimations:d,isSVG:a}),p.current&&f.current&&(f.current.manuallyAnimateOnMount=!0));let m=f.current,h=(0,H.useContext)(T6);m&&!m.projection&&i&&(m.type===`html`||m.type===`svg`)&&O6(f.current,n,i,h);let g=(0,H.useRef)(!1);(0,H.useInsertionEffect)(()=>{m&&g.current&&m.update(n,c)});let _=n[g1],v=(0,H.useRef)(!!_&&typeof window<`u`&&!window.MotionHandoffIsComplete?.(_)&&window.MotionHasOptimisedAnimation?.(_));return ZY(()=>{p.current=!0,m&&(g.current=!0,window.MotionIsMounted=!0,m.updateFeatures(),m.scheduleRenderMicrotask(),v.current&&m.animationState&&m.animationState.animateChanges())}),(0,H.useEffect)(()=>{m&&(!v.current&&m.animationState&&m.animationState.animateChanges(),v.current&&=(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(_)}),!1),m.enteringChildren=void 0)}),m}function O6(e,t,n,r){let{layoutId:i,layout:a,drag:o,dragConstraints:s,layoutScroll:c,layoutRoot:l,layoutAnchor:u,layoutCrossfade:d}=t;e.projection=new n(e.latestValues,t[`data-framer-portal-id`]?void 0:k6(e.parent)),e.projection.setOptions({layoutId:i,layout:a,alwaysMeasureLayout:!!o||s&&E6(s),visualElement:e,animationType:typeof a==`string`?a:`both`,initialPromotionConfig:r,crossfade:d,layoutScroll:c,layoutRoot:l,layoutAnchor:u})}function k6(e){if(e)return e.options.allowProjection===!1?k6(e.parent):e.projection}function A6(e,{forwardMotionProps:t=!1,type:n}={},r,i){r&&J3(r);let a=n?n===`svg`:g6(e),o=a?S6:x6;function s(n,s){let c,l={...(0,H.useContext)(j3),...n,layoutId:j6(n)},{isStatic:u}=l,d=o6(n),f=o(n,u);if(!u&&typeof window<`u`){M6(l,r);let t=N6(l);c=t.MeasureLayout,d.visualElement=D6(e,f,l,i,t.ProjectionNode,a)}return(0,Y.jsxs)(i6.Provider,{value:d,children:[c&&d.visualElement?(0,Y.jsx)(c,{visualElement:d.visualElement,...l}):null,_6(e,n,w6(f,d.visualElement,s),f,u,t,a)]})}s.displayName=`motion.${typeof e==`string`?e:`create(${e.displayName??e.name??``})`}`;let c=(0,H.forwardRef)(s);return c[C6]=e,c}function j6({layoutId:e}){let t=(0,H.useContext)(YY).id;return t&&e!==void 0?t+`-`+e:e}function M6(e,t){(0,H.useContext)(U3).strict}function N6(e){let{drag:t,layout:n}=q3();if(!t&&!n)return{};let r={...t,...n};return{MeasureLayout:t?.isEnabled(e)||n?.isEnabled(e)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function P6(e,t){if(typeof Proxy>`u`)return A6;let n=new Map,r=(n,r)=>A6(n,r,e,t);return new Proxy((e,t)=>r(e,t),{get:(i,a)=>a===`create`?r:(n.has(a)||n.set(a,A6(a,void 0,e,t)),n.get(a))})}var F6=(e,t)=>t.isSVG??g6(e)?new U2(t):new N2(t,{allowProjection:e!==H.Fragment}),I6=class extends $0{constructor(e){super(e),e.animationState||=X2(e)}updateAnimationControlsSubscription(){let{animate:e}=this.node.getProps();I0(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){let{animate:e}=this.node.getProps(),{animate:t}=this.node.prevProps||{};e!==t&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}},L6=0,R6={animation:{Feature:I6},exit:{Feature:class extends $0{constructor(){super(...arguments),this.id=L6++,this.isExitComplete=!1}update(){if(!this.node.presenceContext)return;let{isPresent:e,onExitComplete:t}=this.node.presenceContext,{isPresent:n}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===n)return;if(e&&n===!1){if(this.isExitComplete){let{initial:e,custom:t}=this.node.getProps();if(typeof e==`string`||typeof e==`object`&&e&&!Array.isArray(e)){let n=o1(this.node,e,t);if(n){let{transition:e,transitionEnd:t,...r}=n;for(let e in r)this.node.getValue(e)?.jump(r[e])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive(`exit`,!1);this.isExitComplete=!1;return}let r=this.node.animationState.setActive(`exit`,!e);t&&!e&&r.then(()=>{this.isExitComplete=!0,t(this.id)})}mount(){let{register:e,onExitComplete:t}=this.node.presenceContext||{};t&&t(this.id),e&&(this.unmount=e(this.id))}unmount(){}}}};function z6(e){return{point:{x:e.pageX,y:e.pageY}}}var B6=e=>t=>e0(t)&&e(t,z6(t));function V6(e,t,n,r){return H4(e,t,B6(n),r)}var H6=({current:e})=>e?e.ownerDocument.defaultView:null,U6=(e,t)=>Math.abs(e-t);function W6(e,t){let n=U6(e.x,t.x),r=U6(e.y,t.y);return Math.sqrt(n**2+r**2)}var G6=new Set([`auto`,`scroll`]),K6=class{constructor(e,t,{transformPagePoint:n,contextWindow:r=window,dragSnapToOrigin:i=!1,distanceThreshold:a=3,element:o}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=e=>{this.handleScroll(e.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=q6(this.lastRawMoveEventInfo,this.transformPagePoint));let e=Y6(this.lastMoveEventInfo,this.history),t=this.startEvent!==null,n=W6(e.offset,{x:0,y:0})>=this.distanceThreshold;if(!t&&!n)return;let{point:r}=e,{timestamp:i}=HX;this.history.push({...r,timestamp:i});let{onStart:a,onMove:o}=this.handlers;t||(a&&a(this.lastMoveEvent,e),this.startEvent=this.lastMoveEvent),o&&o(this.lastMoveEvent,e)},this.handlePointerMove=(e,t)=>{this.lastMoveEvent=e,this.lastRawMoveEventInfo=t,this.lastMoveEventInfo=q6(t,this.transformPagePoint),BX.update(this.updatePoint,!0)},this.handlePointerUp=(e,t)=>{this.end();let{onEnd:n,onSessionEnd:r,resumeAnimation:i}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&i&&i(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;let a=Y6(e.type===`pointercancel`?this.lastMoveEventInfo:q6(t,this.transformPagePoint),this.history);this.startEvent&&n&&n(e,a),r&&r(e,a)},!e0(e))return;this.dragSnapToOrigin=i,this.handlers=t,this.transformPagePoint=n,this.distanceThreshold=a,this.contextWindow=r||window;let s=q6(z6(e),this.transformPagePoint),{point:c}=s,{timestamp:l}=HX;this.history=[{...c,timestamp:l}];let{onSessionStart:u}=t;u&&u(e,Y6(s,this.history));let d={passive:!0,capture:!0};this.removeListeners=cX(V6(this.contextWindow,`pointermove`,this.handlePointerMove,d),V6(this.contextWindow,`pointerup`,this.handlePointerUp,d),V6(this.contextWindow,`pointercancel`,this.handlePointerUp,d)),o&&this.startScrollTracking(o)}startScrollTracking(e){let t=e.parentElement;for(;t;){let e=getComputedStyle(t);(G6.has(e.overflowX)||G6.has(e.overflowY))&&this.scrollPositions.set(t,{x:t.scrollLeft,y:t.scrollTop}),t=t.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener(`scroll`,this.onElementScroll,{capture:!0}),window.addEventListener(`scroll`,this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener(`scroll`,this.onElementScroll,{capture:!0}),window.removeEventListener(`scroll`,this.onWindowScroll)}}handleScroll(e){let t=this.scrollPositions.get(e);if(!t)return;let n=e===window,r=n?{x:window.scrollX,y:window.scrollY}:{x:e.scrollLeft,y:e.scrollTop},i={x:r.x-t.x,y:r.y-t.y};i.x===0&&i.y===0||(n?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=i.x,this.lastMoveEventInfo.point.y+=i.y):this.history.length>0&&(this.history[0].x-=i.x,this.history[0].y-=i.y),this.scrollPositions.set(e,r),BX.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),VX(this.updatePoint)}};function q6(e,t){return t?{point:t(e.point)}:e}function J6(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Y6({point:e},t){return{point:e,delta:J6(e,Z6(t)),offset:J6(e,X6(t)),velocity:Q6(t,.1)}}function X6(e){return e[0]}function Z6(e){return e[e.length-1]}function Q6(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null,i=Z6(e);for(;n>=0&&(r=e[n],!(i.timestamp-r.timestamp>dX(t)));)n--;if(!r)return{x:0,y:0};r===e[0]&&e.length>2&&i.timestamp-r.timestamp>dX(t)*2&&(r=e[1]);let a=fX(i.timestamp-r.timestamp);if(a===0)return{x:0,y:0};let o={x:(i.x-r.x)/a,y:(i.y-r.y)/a};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function $6(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?VZ(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?VZ(n,e,r.max):Math.min(e,n)),e}function e8(e,t,n){return{min:t===void 0?void 0:e.min+t,max:n===void 0?void 0:e.max+n-(e.max-e.min)}}function t8(e,{top:t,left:n,bottom:r,right:i}){return{x:e8(e.x,n,i),y:e8(e.y,t,r)}}function n8(e,t){let n=t.min-e.min,r=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,r]=[r,n]),{min:n,max:r}}function r8(e,t){return{x:n8(e.x,t.x),y:n8(e.y,t.y)}}function i8(e,t){let n=.5,r=l4(e),i=l4(t);return i>r?n=lX(t.min,t.max-r,e.min):r>i&&(n=lX(e.min,e.max-i,t.min)),tX(0,1,n)}function a8(e,t){let n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}var o8=.35;function s8(e=o8){return e===!1?e=0:e===!0&&(e=o8),{x:c8(e,`left`,`right`),y:c8(e,`top`,`bottom`)}}function c8(e,t,n){return{min:l8(e,t),max:l8(e,n)}}function l8(e,t){return typeof e==`number`?e:e[t]||0}var u8=new WeakMap,d8=class{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=P0(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:t=!1,distanceThreshold:n}={}){let{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;let i=e=>{t&&this.snapToCursor(z6(e).point),this.stopAnimation()},a=(e,t)=>{let{drag:n,dragPropagation:r,onDragStart:i}=this.getProps();if(n&&!r&&(this.openDragLock&&this.openDragLock(),this.openDragLock=Y1(n),!this.openDragLock))return;this.latestPointerEvent=e,this.latestPanInfo=t,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),j4(e=>{let t=this.getAxisMotionValue(e).get()||0;if(hZ.test(t)){let{projection:n}=this.visualElement;if(n&&n.layout){let r=n.layout.layoutBox[e];r&&(t=l4(r)*(parseFloat(t)/100))}}this.originPoint[e]=t}),i&&BX.update(()=>i(e,t),!1,!0),m1(this.visualElement,`transform`);let{animationState:a}=this.visualElement;a&&a.setActive(`whileDrag`,!0)},o=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t;let{dragPropagation:n,dragDirectionLock:r,onDirectionLock:i,onDrag:a}=this.getProps();if(!n&&!this.openDragLock)return;let{offset:o}=t;if(r&&this.currentDirection===null){this.currentDirection=h8(o),this.currentDirection!==null&&i&&i(this.currentDirection);return}this.updateAxis(`x`,t.point,o),this.updateAxis(`y`,t.point,o),this.visualElement.render(),a&&BX.update(()=>a(e,t),!1,!0)},s=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t,this.stop(e,t),this.latestPointerEvent=null,this.latestPanInfo=null},c=()=>{let{dragSnapToOrigin:e}=this.getProps();(e||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:l}=this.getProps();this.panSession=new K6(e,{onSessionStart:i,onStart:a,onMove:o,onSessionEnd:s,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:l,distanceThreshold:n,contextWindow:H6(this.visualElement),element:this.visualElement.current})}stop(e,t){let n=e||this.latestPointerEvent,r=t||this.latestPanInfo,i=this.isDragging;if(this.cancel(),!i||!r||!n)return;let{velocity:a}=r;this.startAnimation(a);let{onDragEnd:o}=this.getProps();o&&BX.postRender(()=>o(n,r))}cancel(){this.isDragging=!1;let{projection:e,animationState:t}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.endPanSession();let{dragPropagation:n}=this.getProps();!n&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),t&&t.setActive(`whileDrag`,!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(e,t,n){let{drag:r}=this.getProps();if(!n||!m8(e,r,this.currentDirection))return;let i=this.getAxisMotionValue(e),a=this.originPoint[e]+n[e];this.constraints&&this.constraints[e]&&(a=$6(a,this.constraints[e],this.elastic[e])),i.set(a)}resolveConstraints(){let{dragConstraints:e,dragElastic:t}=this.getProps(),n=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,r=this.constraints;e&&E6(e)?this.constraints||=this.resolveRefConstraints():e&&n?this.constraints=t8(n.layoutBox,e):this.constraints=!1,this.elastic=s8(t),r!==this.constraints&&!E6(e)&&n&&this.constraints&&!this.hasMutatedConstraints&&j4(e=>{this.constraints!==!1&&this.getAxisMotionValue(e)&&(this.constraints[e]=a8(n.layoutBox[e],this.constraints[e]))})}resolveRefConstraints(){let{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!e||!E6(e))return!1;let n=e.current,{projection:r}=this.visualElement;if(!r||!r.layout)return!1;r.root&&(r.root.scroll=void 0,r.root.updateScroll());let i=b2(n,r.root,this.visualElement.getTransformPagePoint()),a=r8(r.layout.layoutBox,i);if(t){let e=t(t2(a));this.hasMutatedConstraints=!!e,e&&(a=e2(e))}return a}startAnimation(e){let{drag:t,dragMomentum:n,dragElastic:r,dragTransition:i,dragSnapToOrigin:a,onDragTransitionEnd:o}=this.getProps(),s=this.constraints||{},c=j4(o=>{if(!m8(o,t,this.currentDirection))return;let c=s&&s[o]||{};(a===!0||a===o)&&(c={min:0,max:0});let l=r?200:1e6,u=r?40:1e7,d={type:`inertia`,velocity:n?e[o]:0,bounceStiffness:l,bounceDamping:u,timeConstant:750,restDelta:1,restSpeed:10,...i,...c};return this.startAxisValueAnimation(o,d)});return Promise.all(c).then(o)}startAxisValueAnimation(e,t){let n=this.getAxisMotionValue(e);return m1(this.visualElement,e),n.start(e1(e,n,0,t,this.visualElement,!1))}stopAnimation(){j4(e=>this.getAxisMotionValue(e).stop())}getAxisMotionValue(e){let t=`_drag${e.toUpperCase()}`;return this.visualElement.getProps()[t]||this.visualElement.getValue(e,this.visualElement.latestValues[e]??0)}snapToCursor(e){j4(t=>{let{drag:n}=this.getProps();if(!m8(t,n,this.currentDirection))return;let{projection:r}=this.visualElement,i=this.getAxisMotionValue(t);if(r&&r.layout){let{min:n,max:a}=r.layout.layoutBox[t],o=i.get()||0;i.set(e[t]-VZ(n,a,.5)+o)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;let{drag:e,dragConstraints:t}=this.getProps(),{projection:n}=this.visualElement;if(!E6(t)||!n||!this.constraints)return;this.stopAnimation();let r={x:0,y:0};j4(e=>{let t=this.getAxisMotionValue(e);if(t&&this.constraints!==!1){let n=t.get();r[e]=i8({min:n,max:n},this.constraints[e])}});let{transformTemplate:i}=this.visualElement.getProps();this.visualElement.current.style.transform=i?i({},``):`none`,n.root&&n.root.updateScroll(),n.updateLayout(),this.constraints=!1,this.resolveConstraints(),j4(t=>{if(!m8(t,e,null))return;let n=this.getAxisMotionValue(t),{min:i,max:a}=this.constraints[t];n.set(VZ(i,a,r[t]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;u8.set(this.visualElement,this);let e=this.visualElement.current,t=V6(e,`pointerdown`,t=>{let{drag:n,dragListener:r=!0}=this.getProps(),i=t.target,a=i!==e&&i0(i);n&&r&&!a&&this.start(t)}),n,r=()=>{let{dragConstraints:t}=this.getProps();E6(t)&&t.current&&(this.constraints=this.resolveRefConstraints(),n||=p8(e,t.current,()=>this.scalePositionWithinConstraints()))},{projection:i}=this.visualElement,a=i.addEventListener(`measure`,r);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),BX.read(r);let o=H4(window,`resize`,()=>this.scalePositionWithinConstraints()),s=i.addEventListener(`didUpdate`,(({delta:e,hasLayoutChanged:t})=>{this.isDragging&&t&&(j4(t=>{let n=this.getAxisMotionValue(t);n&&(this.originPoint[t]+=e[t].translate,n.set(n.get()+e[t].translate))}),this.visualElement.render())}));return()=>{o(),t(),a(),s&&s(),n&&n()}}getProps(){let e=this.visualElement.getProps(),{drag:t=!1,dragDirectionLock:n=!1,dragPropagation:r=!1,dragConstraints:i=!1,dragElastic:a=o8,dragMomentum:o=!0}=e;return{...e,drag:t,dragDirectionLock:n,dragPropagation:r,dragConstraints:i,dragElastic:a,dragMomentum:o}}};function f8(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function p8(e,t,n){let r=E0(e,f8(n)),i=E0(t,f8(n));return()=>{r(),i()}}function m8(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function h8(e,t=10){let n=null;return Math.abs(e.y)>t?n=`y`:Math.abs(e.x)>t&&(n=`x`),n}var g8=class extends $0{constructor(e){super(e),this.removeGroupControls=sX,this.removeListeners=sX,this.controls=new d8(e)}mount(){let{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||sX}update(){let{dragControls:e}=this.node.getProps(),{dragControls:t}=this.node.prevProps||{};e!==t&&(this.removeGroupControls(),e&&(this.removeGroupControls=e.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}},_8=e=>(t,n)=>{e&&BX.update(()=>e(t,n),!1,!0)},v8=class extends $0{constructor(){super(...arguments),this.removePointerDownListener=sX}onPointerDown(e){this.session=new K6(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:H6(this.node)})}createPanHandlers(){let{onPanSessionStart:e,onPanStart:t,onPan:n,onPanEnd:r}=this.node.getProps();return{onSessionStart:_8(e),onStart:_8(t),onMove:_8(n),onEnd:(e,t)=>{delete this.session,r&&BX.postRender(()=>r(e,t))}}}mount(){this.removePointerDownListener=V6(this.node.current,`pointerdown`,e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}},y8=!1,b8=class extends H.Component{componentDidMount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n,layoutId:r}=this.props,{projection:i}=e;i&&(t.group&&t.group.add(i),n&&n.register&&r&&n.register(i),y8&&i.root.didUpdate(),i.addEventListener(`animationComplete`,()=>{this.safeToRemove()}),i.setOptions({...i.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),J4.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){let{layoutDependency:t,visualElement:n,drag:r,isPresent:i}=this.props,{projection:a}=n;return a?(a.isPresent=i,e.layoutDependency!==t&&a.setOptions({...a.options,layoutDependency:t}),y8=!0,r||e.layoutDependency!==t||t===void 0||e.isPresent!==i?a.willUpdate():this.safeToRemove(),e.isPresent!==i&&(i?a.promote():a.relegate()||BX.postRender(()=>{let e=a.getStack();(!e||!e.members.length)&&this.safeToRemove()})),null):null}componentDidUpdate(){let{visualElement:e,layoutAnchor:t}=this.props,{projection:n}=e;n&&(n.options.layoutAnchor=t,n.root.didUpdate(),K1.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n}=this.props,{projection:r}=e;y8=!0,r&&(r.scheduleCheckAfterUnmount(),t&&t.group&&t.group.remove(r),n&&n.deregister&&n.deregister(r))}safeToRemove(){let{safeToRemove:e}=this.props;e&&e()}render(){return null}};function x8(e){let[t,n]=z3(),r=(0,H.useContext)(YY);return(0,Y.jsx)(b8,{...e,layoutGroup:r,switchLayoutGroup:(0,H.useContext)(T6),isPresent:t,safeToRemove:n})}var S8={pan:{Feature:v8},drag:{Feature:g8,ProjectionNode:A3,MeasureLayout:x8}};function C8(e,t,n){let{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive(`whileHover`,n===`Start`);let i=r[`onHover`+n];i&&BX.postRender(()=>i(t,z6(t)))}var w8=class extends $0{mount(){let{current:e}=this.node;e&&(this.unmount=Q1(e,(e,t)=>(C8(this.node,t,`Start`),e=>C8(this.node,e,`End`))))}unmount(){}},T8=class extends $0{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(`:focus-visible`)}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive(`whileFocus`,!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive(`whileFocus`,!1),this.isActive=!1)}mount(){this.unmount=cX(H4(this.node.current,`focus`,()=>this.onFocus()),H4(this.node.current,`blur`,()=>this.onBlur()))}unmount(){}};function E8(e,t,n){let{props:r}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&r.whileTap&&e.animationState.setActive(`whileTap`,n===`Start`);let i=r[`onTap`+(n===`End`?``:n)];i&&BX.postRender(()=>i(t,z6(t)))}var D8=class extends $0{mount(){let{current:e}=this.node;if(!e)return;let{globalTapTarget:t,propagate:n}=this.node.props;this.unmount=d0(e,(e,t)=>(E8(this.node,t,`Start`),(e,{success:t})=>E8(this.node,e,t?`End`:`Cancel`)),{useGlobalTarget:t,stopPropagation:n?.tap===!1})}unmount(){}},O8=new WeakMap,k8=new WeakMap,A8=e=>{let t=O8.get(e.target);t&&t(e)},j8=e=>{e.forEach(A8)};function M8({root:e,...t}){let n=e||document;k8.has(n)||k8.set(n,{});let r=k8.get(n),i=JSON.stringify(t);return r[i]||(r[i]=new IntersectionObserver(j8,{root:e,...t})),r[i]}function N8(e,t,n){let r=M8(t);return O8.set(e,n),r.observe(e),()=>{O8.delete(e),r.unobserve(e)}}var P8={some:0,all:1},F8=class extends $0{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.stopObserver?.();let{viewport:e={}}=this.node.getProps(),{root:t,margin:n,amount:r=`some`,once:i}=e,a={root:t?t.current:void 0,rootMargin:n,threshold:typeof r==`number`?r:P8[r]},o=e=>{let{isIntersecting:t}=e;if(this.isInView===t||(this.isInView=t,i&&!t&&this.hasEnteredView))return;t&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive(`whileInView`,t);let{onViewportEnter:n,onViewportLeave:r}=this.node.getProps(),a=t?n:r;a&&a(e)};this.stopObserver=N8(this.node.current,a,o)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>`u`)return;let{props:e,prevProps:t}=this.node;[`amount`,`margin`,`root`].some(I8(e,t))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}};function I8({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}var L8={inView:{Feature:F8},tap:{Feature:D8},focus:{Feature:T8},hover:{Feature:w8}},R8={layout:{ProjectionNode:A3,MeasureLayout:x8}},z8=P6({...R6,...L8,...S8,...R8},F6);function B8(e){let t=XY(()=>W$(e)),{isStatic:n}=(0,H.useContext)(j3);if(n){let[,n]=(0,H.useState)(e);(0,H.useEffect)(()=>t.on(`change`,n),[])}return t}var V8=z8;async function H8(e){if(e.startsWith(`factory:`)){let t=await fetch(`${o}/api/loops/factory`);if(!t.ok)return null;let n=((await t.json()).loops??[]).find(t=>t.id===e);return n?{id:n.id,name:n.name,description:n.description,status:null,graph:n.graph,locked:!0}:null}let t=await fetch(`${o}/api/loops/${encodeURIComponent(e)}`);if(!t.ok)return null;let n=(await t.json()).loop;return n?{id:n.id,name:n.name,description:n.description,status:n.status,graph:n.graph,locked:!1}:null}async function U8(e,t){let n=await fetch(`${o}/api/projects/${e}/git/pull-requests/${t}`);if(!n.ok)return null;let r=await n.json();return typeof r.url==`string`&&r.url?r.url:null}function W8(){let{t:e}=K(`agent`),{openTicketDetailInProject:t}=dH(),[n,r]=(0,H.useState)(null),[i,a]=(0,H.useState)(null),s=(0,H.useCallback)(()=>r(null),[]),c=(0,H.useCallback)(()=>a(null),[]);return{openRef:(0,H.useCallback)(async(n,i)=>{try{if(i.kind===`ticket`){if(!(await fetch(`${o}/api/projects/${n}/tickets/${i.ticketId}`)).ok){q.info(e(`refs.ticketNotFound`,{id:i.ticketId}));return}t(n,i.ticketId)}else if(i.kind===`pull-request`){let t=i.prUrl??await U8(n,i.prNumber);if(!t){q.info(e(`refs.pullRequestNotFound`,{id:i.prNumber}));return}await HV(t)}else if(i.kind===`loop`){let t=await H8(i.loopId);if(!t){q.info(e(`refs.loopNotFound`));return}a(t)}else{if((await fetch(`${o}/api/projects/${n}/jobs/${i.jobId}`)).ok){r({projectId:n,jobId:i.jobId});return}let t=await H8(i.jobId);if(t){a(t);return}q.info(e(`refs.jobNotFound`))}}catch{q.info(e(`refs.lookupFailed`))}},[t,e]),jobRef:n,closeJobRef:s,loopRef:i,closeLoopRef:c}}function G8(e){if(e.startsWith(`mcp__`)){let t=e.split(`__`).pop()?.replace(/^specrails_/,``)??``;return t?`MCP · ${t}`:`MCP Tool`}return{Bash:`Terminal`,Read:`Reading`,Grep:`Searching`,Glob:`Searching`,Write:`Editing`,Edit:`Editing`,NotebookEdit:`Editing`,WebFetch:`Web`,WebSearch:`Web`,Task:`Agent`}[e]??e}var K8=new Set([`<unnamed>`,`<missing>`,``]);function q8({tool:e}){let{t}=K(`agent`),n=e&&!K8.has(e)?G8(e):t(`thinking`);return(0,Y.jsxs)(`div`,{className:`inline-flex items-center gap-2 rounded-full border border-border/50 bg-surface/60 px-3 py-1 text-xs font-medium text-foreground/80`,children:[(0,Y.jsx)(cs,{className:`h-3 w-3 animate-spin text-accent-info`}),(0,Y.jsx)(H3,{mode:`wait`,initial:!1,children:(0,Y.jsx)(V8.span,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.16,ease:`easeOut`},children:n},n)})]})}var J8=2,Y8=8,X8=80,Z8="```options";function Q8(e){let t=e.replace(/^[^\S\n]*\n?/,``).replace(/\s*(?:```)?\s*$/,``),n;try{n=JSON.parse(t)}catch{return null}if(!Array.isArray(n)||n.length<J8||n.length>Y8)return null;let r=[];for(let e of n){if(typeof e!=`string`)return null;let t=e.trim();if(!t||t.length>X8)return null;r.push(t)}return r}function $8(e){let t=e.indexOf(Z8);for(;t!==-1;){if(t===0||e[t-1]!=="`"){let n=Q8(e.slice(t+10));if(n)return{body:e.slice(0,t).replace(/\s+$/,``),options:n}}t=e.indexOf(Z8,t+1)}return{body:e,options:null}}var e5=/```spec-draft[^\S\n]*\n([\s\S]*?)\n[^\S\n]*```/g,t5="```spec-draft",n5=new Set([`low`,`medium`,`high`,`critical`]);function r5(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function i5(e){let t;try{t=JSON.parse(e)}catch{return null}if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t,r={title:typeof n.title==`string`?n.title:yg.title,description:typeof n.description==`string`?n.description:yg.description,labels:r5(n.labels),priority:typeof n.priority==`string`&&n5.has(n.priority)?n.priority:yg.priority,acceptanceCriteria:r5(n.acceptanceCriteria)};return!r.title.trim()&&!r.description.trim()?null:r}function a5(e){return e.replace(/\n{3,}/g,`
140
140
 
141
141
  `).trim()}function o5(e,t=!1){if(!e.includes(t5))return{body:e,draft:null,pending:!1};let n=null,r=``,i=0;e5.lastIndex=0;let a;for(;(a=e5.exec(e))!==null;){r+=e.slice(i,a.index),i=a.index+a[0].length;let t=i5(a[1]);t&&(n=t)}r+=e.slice(i);let o=!1,s=r.indexOf(t5);if(s!==-1){let e=i5(r.slice(s+13).replace(/^[^\S\n]*\n?/,``).replace(/\s*(?:```)?\s*$/,``));e?(n=e,r=r.slice(0,s)):t&&(r=r.slice(0,s),o=!0)}return{body:a5(r),draft:n,pending:o}}var s5={critical:`border-destructive/35 bg-destructive/15 text-destructive`,high:`border-accent-warning/35 bg-accent-warning/15 text-accent-warning`,medium:`border-accent-info/35 bg-accent-info/15 text-accent-info`,low:`border-border/60 bg-surface/70 text-foreground/60`},c5=X(`text-xs leading-6 text-foreground/85`,`[&_p]:my-2 [&_p:first-child]:mt-0 [&_p:last-child]:mb-0`,`[&_h2]:mt-3 [&_h2]:mb-1 [&_h2]:text-[11px] [&_h2]:font-semibold [&_h2]:uppercase [&_h2]:tracking-wider [&_h2]:text-foreground/60 [&_h2:first-child]:mt-0`,`[&_h3]:mt-2 [&_h3]:mb-1 [&_h3]:text-xs [&_h3]:font-semibold`,`[&_ul]:my-1.5 [&_ul]:list-disc [&_ul]:pl-4 [&_ol]:my-1.5 [&_ol]:list-decimal [&_ol]:pl-4 [&_li]:my-0.5`,`[&_code]:rounded [&_code]:bg-surface [&_code]:px-1 [&_code]:py-0.5 [&_code]:font-mono [&_code]:text-[0.85em] [&_code]:text-accent-info`,`[&_pre]:my-1.5 [&_pre]:overflow-x-auto [&_pre]:rounded-lg [&_pre]:bg-surface [&_pre]:p-2`,`[&_strong]:font-semibold`);function l5({draft:e}){let{t}=K(`agent`),[n,r]=(0,H.useState)(!1),i=e.description.trim().length>0,a=e.acceptanceCriteria;return(0,Y.jsxs)(`div`,{"data-testid":`agent-spec-draft-card`,className:`my-1 overflow-hidden rounded-xl border border-accent-primary/25 bg-card/80 shadow-lg backdrop-blur`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-border/40 bg-accent-primary/[0.06] px-3.5 py-2`,children:[(0,Y.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-widest text-accent-primary/90`,children:[(0,Y.jsx)(Qs,{className:`h-3 w-3`}),t(`specDraft.heading`)]}),(0,Y.jsx)(`span`,{className:X(`rounded-full border px-2 py-0.5 text-[10px] font-medium uppercase tracking-wide`,s5[e.priority]),children:t(`explore:priority.${e.priority}`)})]}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2.5 px-3.5 py-3`,children:[(0,Y.jsx)(`div`,{className:`text-sm font-semibold leading-snug text-foreground`,children:e.title.trim()||t(`specDraft.untitled`)}),e.labels.length>0&&(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.labels.map((e,t)=>(0,Y.jsx)(`span`,{className:`rounded-full border border-border/60 bg-surface/70 px-2 py-0.5 text-[10px] text-foreground/70`,children:e},`${t}-${e}`))}),i&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`div`,{className:X(`relative`,!n&&`max-h-28 overflow-hidden`),children:[(0,Y.jsx)(`div`,{className:c5,children:(0,Y.jsx)(cI,{remarkPlugins:[KL],children:e.description})}),!n&&(0,Y.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-x-0 bottom-0 h-10 bg-gradient-to-t from-card to-transparent`})]}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>r(e=>!e),"data-agent-interactive":!0,className:`mt-1 flex items-center gap-1 text-[11px] text-accent-info transition-colors hover:text-foreground`,children:[n?(0,Y.jsx)(ao,{className:`h-3 w-3`}):(0,Y.jsx)(no,{className:`h-3 w-3`}),t(n?`specDraft.collapse`:`specDraft.expand`)]})]}),a.length>0&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`div`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-wider text-foreground/50`,children:[t(`specDraft.acceptanceCriteria`),` · `,a.length]}),(0,Y.jsx)(`ul`,{className:`flex flex-col gap-1`,children:a.map((e,t)=>(0,Y.jsxs)(`li`,{className:`flex items-start gap-1.5 text-xs leading-5 text-foreground/85`,children:[(0,Y.jsx)(co,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-accent-success/80`}),(0,Y.jsx)(`span`,{children:e})]},`${t}-${e}`))})]})]})]})}function u5(){let{t:e}=K(`agent`);return(0,Y.jsxs)(`span`,{"data-testid":`agent-spec-draft-pending`,className:`inline-flex w-fit items-center gap-1.5 rounded-full border border-accent-primary/25 bg-accent-primary/10 px-2.5 py-1 text-[11px] text-accent-primary/90`,children:[(0,Y.jsx)(Qs,{className:`h-3 w-3 animate-pulse`}),e(`specDraft.drafting`)]})}var d5=`#agentref:`;function f5(e){return e.kind===`ticket`?`${d5}ticket:${e.ticketId}`:e.kind===`pull-request`?`${d5}pr:${e.prNumber}${e.prUrl?`:${encodeURIComponent(e.prUrl)}`:``}`:e.kind===`loop`?`${d5}loop:${e.loopId}`:`${d5}job:${e.jobId}`}function p5(e){if(!e||!e.startsWith(d5))return null;let t=e.slice(10);if(t.startsWith(`ticket:`)){let e=Number.parseInt(t.slice(7),10);return Number.isInteger(e)&&e>0?{kind:`ticket`,ticketId:e}:null}if(t.startsWith(`pr:`)){let[,e,n]=/^pr:(\d+)(?::(.+))?$/.exec(t)??[],r=Number.parseInt(e??``,10);if(!Number.isInteger(r)||r<=0)return null;let i=n?decodeURIComponent(n):void 0;return i?{kind:`pull-request`,prNumber:r,prUrl:i}:{kind:`pull-request`,prNumber:r}}if(t.startsWith(`job:`)){let e=t.slice(4);return h5.test(e)?{kind:`job`,jobId:e}:null}if(t.startsWith(`loop:`)){let e=t.slice(5);return _5.test(e)||h5.test(e)?{kind:`loop`,loopId:e}:null}return null}var m5=`[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}`,h5=RegExp(`^${m5}$`),g5=`factory:(?:implement|batch|freestyle)`,_5=RegExp(`^${g5}$`),v5=/\b(jobs?|runs?|loops?|rails?|ejecuci[oó]n(?:es)?|trabajos?|bucles?)\b|(?:loop|job|run)[a-z]*id/i;function y5(e){let t=new Set;for(let n of e.split(`
142
- `)){if(!v5.test(n))continue;let e=new RegExp(m5,`g`),r;for(;(r=e.exec(n))!==null;)t.add(r[0].toLowerCase())}return t}var b5=/[\w#&$-]/,x5=/[\w-]/;function S5(e,t){let n=/\b(?:PR|pull request)\s*#?(\d{1,10})\b/gi,r;for(;(r=n.exec(e))!==null;){let n=e[r.index-1],i=e[r.index+r[0].length];if(n!==void 0&&b5.test(n)||i!==void 0&&x5.test(i))continue;let a=Number.parseInt(r[1],10);!Number.isInteger(a)||a<=0||t.push({start:r.index,end:r.index+r[0].length,segment:{kind:`pull-request`,prNumber:a,label:`PR #${a}`}})}let i=/https?:\/\/[^\s<>)]+\/pull\/(\d{1,10})(?:[/?#][^\s<>)]*)?/gi,a;for(;(a=i.exec(e))!==null;){let e=Number.parseInt(a[1],10);if(!Number.isInteger(e)||e<=0)continue;let n=a[0].replace(/[.,;:!?…]+$/u,``);t.push({start:a.index,end:a.index+n.length,segment:{kind:`pull-request`,prNumber:e,prUrl:n,label:`PR #${e}`}})}}function C5(e){if(!e)return null;let t=/^https?:\/\/[^\s<>)]+\/pull\/(\d{1,10})(?:[/?#][^\s<>)]*)?$/i.exec(e);if(!t)return null;let n=Number.parseInt(t[1],10);return!Number.isInteger(n)||n<=0?null:{prNumber:n,prUrl:e}}function w5(e,t){let n=/#(\d{1,6})/g,r;for(;(r=n.exec(e))!==null;){let n=e[r.index-1],i=r.index+r[0].length,a=e[i];if(n!==void 0&&b5.test(n)||a!==void 0&&x5.test(a))continue;let o=Number.parseInt(r[1],10);if(!Number.isInteger(o)||o<=0)continue;let s=i,c=`#${o}`,l=/^([ \t]*[—–][ \t]*)([^\n#]{1,80})/.exec(e.slice(s));if(l){let e=l[2].replace(/[\s.,;:!?…]+$/u,``);e.length>0&&(s+=l[1].length+e.length,c=`#${o} — ${e}`)}t.push({start:r.index,end:s,segment:{kind:`ticket`,ticketId:o,label:c}})}}function T5(e,t,n){let r=new RegExp(m5,`g`),i;for(;(i=r.exec(e))!==null;){let r=e[i.index-1],a=e[i.index+i[0].length];if(r!==void 0&&b5.test(r)||a!==void 0&&x5.test(a))continue;let o=i[0].toLowerCase();t.has(o)&&n.push({start:i.index,end:i.index+i[0].length,segment:{kind:`job`,jobId:o,label:`${o.slice(0,8)}…`}})}}function E5(e,t){let n=new RegExp(g5,`g`),r;for(;(r=n.exec(e))!==null;){let n=e[r.index-1],i=e[r.index+r[0].length];n!==void 0&&b5.test(n)||i!==void 0&&x5.test(i)||t.push({start:r.index,end:r.index+r[0].length,segment:{kind:`loop`,loopId:r[0],label:r[0]}})}}function D5(e,t){let n=[];if(S5(e,n),w5(e,n),T5(e,t,n),E5(e,n),n.length===0)return[{kind:`text`,text:e}];n.sort((e,t)=>e.start-t.start);let r=[],i=0;for(let t of n)t.start<i||(t.start>i&&r.push({kind:`text`,text:e.slice(i,t.start)}),r.push(t.segment),i=t.end);return i<e.length&&r.push({kind:`text`,text:e.slice(i)}),r}var O5=new Set([`code`,`inlineCode`,`link`,`linkReference`,`image`,`imageReference`,`definition`,`html`]);function k5(e){return e.kind===`text`?{type:`text`,value:e.text}:{type:`link`,url:f5(e.kind===`ticket`?{kind:`ticket`,ticketId:e.ticketId}:e.kind===`pull-request`?{kind:`pull-request`,prNumber:e.prNumber,prUrl:e.prUrl}:e.kind===`loop`?{kind:`loop`,loopId:e.loopId}:{kind:`job`,jobId:e.jobId}),children:[{type:`text`,value:e.label}]}}function A5(e,t){let n=e.children;if(n)for(let e=n.length-1;e>=0;e--){let r=n[e];if(r.type===`inlineCode`&&typeof r.value==`string`){let i=r.value.trim();if(h5.test(i)&&t.has(i.toLowerCase())){let t=i.toLowerCase();n.splice(e,1,k5({kind:`job`,jobId:t,label:`${t.slice(0,8)}…`}))}else _5.test(i)&&n.splice(e,1,k5({kind:`loop`,loopId:i,label:i}));continue}if(r.type===`link`&&typeof r.url==`string`){let t=C5(r.url);t&&n.splice(e,1,k5({kind:`pull-request`,prNumber:t.prNumber,prUrl:t.prUrl,label:`PR #${t.prNumber}`}));continue}if(!O5.has(r.type))if(r.type===`text`&&typeof r.value==`string`){let i=D5(r.value,t);i.some(e=>e.kind!==`text`)&&n.splice(e,1,...i.map(k5))}else A5(r,t)}}function j5(){return(e,t)=>{A5(e,y5(t==null?``:String(t)))}}function M5({refTarget:e,onOpen:t,children:n}){let{t:r}=K(`agent`),i=e.kind===`ticket`?r(`refs.openTicket`,{id:e.ticketId}):e.kind===`pull-request`?r(`refs.openPullRequest`,{id:e.prNumber}):e.kind===`loop`?r(`refs.openLoop`,{id:e.loopId}):r(`refs.openJob`,{id:e.jobId.slice(0,8)}),a=e.kind===`ticket`?oc:e.kind===`pull-request`?Go:e.kind===`loop`?Is:Xa;return(0,Y.jsxs)(`button`,{type:`button`,"data-agent-interactive":!0,"data-testid":`agent-ref-chip`,"data-ref-kind":e.kind,onClick:n=>{n.stopPropagation(),t(e)},title:i,"aria-label":i,className:X(`inline-flex max-w-full cursor-pointer items-center gap-1 rounded-full border px-1.5 align-baseline font-mono text-[0.82em] leading-[1.45] transition-all`,`hover:-translate-y-px hover:shadow-sm`,e.kind===`ticket`?`border-accent-primary/35 bg-accent-primary/10 text-accent-primary hover:border-accent-primary/60 hover:bg-accent-primary/15`:e.kind===`pull-request`?`border-accent-success/35 bg-accent-success/10 text-accent-success hover:border-accent-success/60 hover:bg-accent-success/15`:e.kind===`loop`?`border-accent-highlight/35 bg-accent-highlight/10 text-accent-highlight hover:border-accent-highlight/60 hover:bg-accent-highlight/15`:`border-accent-info/35 bg-accent-info/10 text-accent-info hover:border-accent-info/60 hover:bg-accent-info/15`),children:[(0,Y.jsx)(a,{className:`h-3 w-3 shrink-0 opacity-70`}),(0,Y.jsx)(`span`,{className:`max-w-[280px] truncate`,children:n})]})}var N5=X(`text-sm leading-7 text-foreground`,`[&_p]:my-3.5 [&_p:first-child]:mt-0 [&_p:last-child]:mb-0`,`[&_h1]:mt-5 [&_h1]:mb-2 [&_h1]:text-base [&_h1]:font-semibold`,`[&_h2]:mt-5 [&_h2]:mb-2 [&_h2]:text-[15px] [&_h2]:font-semibold`,`[&_h3]:mt-4 [&_h3]:mb-1.5 [&_h3]:text-sm [&_h3]:font-semibold`,`[&_strong]:font-semibold [&_strong]:text-foreground`,`[&_em]:italic`,`[&_a]:text-accent-info [&_a]:underline [&_a]:underline-offset-2`,`[&_ul]:my-3 [&_ul]:list-disc [&_ul]:pl-5 [&_ol]:my-3 [&_ol]:list-decimal [&_ol]:pl-5 [&_li]:my-1`,`[&_code]:rounded [&_code]:bg-surface [&_code]:px-1 [&_code]:py-0.5 [&_code]:font-mono [&_code]:text-[0.85em] [&_code]:text-accent-info`,`[&_pre]:my-2 [&_pre]:overflow-x-auto [&_pre]:rounded-lg [&_pre]:bg-surface [&_pre]:p-3`,`[&_pre_code]:bg-transparent [&_pre_code]:p-0 [&_pre_code]:text-foreground`,`[&_blockquote]:my-2 [&_blockquote]:border-l-2 [&_blockquote]:border-accent-primary/40 [&_blockquote]:pl-3 [&_blockquote]:text-foreground/80`,`[&_hr]:my-3 [&_hr]:border-border/60`,`[&_table]:my-2 [&_table]:w-full [&_table]:border-collapse [&_table]:overflow-hidden [&_table]:rounded-lg`,`[&_th]:border [&_th]:border-border [&_th]:bg-surface [&_th]:px-2.5 [&_th]:py-1.5 [&_th]:text-left [&_th]:font-semibold`,`[&_td]:border [&_td]:border-border [&_td]:px-2.5 [&_td]:py-1.5`,`[&_tr:nth-child(even)]:bg-surface/40`);function P5({text:e,timestampIso:t}){let{t:n}=K(`agent`),[r,i]=(0,H.useState)(!1);return(0,Y.jsx)(`button`,{type:`button`,onClick:async()=>{try{let n=e;if(t){let r=dY(t);r&&(n=`[${hV(r,`yyyy-MM-dd HH:mm:ss`)}]\n${e}`)}await navigator.clipboard.writeText(n),i(!0),setTimeout(()=>i(!1),1500)}catch{}},"aria-label":n(`copy`),title:n(`copy`),className:`rounded-md p-1 text-foreground/40 opacity-0 transition-opacity hover:bg-surface hover:text-foreground group-hover:opacity-100`,"data-agent-interactive":!0,children:r?(0,Y.jsx)(to,{className:`h-3 w-3 text-accent-success`}):(0,Y.jsx)(bo,{className:`h-3 w-3`})})}function F5({iso:e}){if(!e)return null;let t=dY(e);if(!t)return null;let n=im();return(0,Y.jsx)(`time`,{dateTime:t.toISOString(),title:hV(t,`PPpp`,{locale:n}),className:`shrink-0 select-none font-mono text-[10px] leading-none tabular-nums tracking-tight text-foreground/25 transition-colors duration-200 group-hover:text-foreground/50`,children:hV(t,`yyyy-MM-dd HH:mm:ss`)})}function I5(e){return!Number.isFinite(e)||e<0?``:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function L5(e){return e.mimeType.startsWith(`image/`)||/\.(png|jpe?g|gif|webp|bmp|svg)$/i.test(e.filename)}function R5({conversationId:e,attachment:t,onClose:n}){let{t:r}=K(`agent`),[i,a]=(0,H.useState)(null),[o,s]=(0,H.useState)(null);if((0,H.useEffect)(()=>{if(!t)return;let e=e=>{e.key===`Escape`&&n()};document.addEventListener(`keydown`,e);let r=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.removeEventListener(`keydown`,e),document.body.style.overflow=r}},[t,n]),(0,H.useEffect)(()=>{if(!t){a(null),s(null);return}let n=!1;return a(null),s(null),IY(e,t.id).then(e=>{n||a(URL.createObjectURL(e))}).catch(e=>{n||s(e instanceof Error?e.message:r(`attachment.loadFailed`))}),()=>{n=!0}},[t,e,r]),(0,H.useEffect)(()=>()=>{i&&URL.revokeObjectURL(i)},[i]),!t)return null;let c=L5(t),l=r(`attachment.download`),u=i?(0,Y.jsxs)(`a`,{href:i,download:t.filename,onClick:e=>e.stopPropagation(),className:`inline-flex items-center justify-center gap-2 rounded-lg bg-accent-primary px-3 py-2 text-sm font-medium text-white transition-opacity hover:opacity-90`,"data-agent-interactive":!0,children:[(0,Y.jsx)(To,{className:`h-4 w-4`}),l]}):(0,Y.jsxs)(`button`,{type:`button`,disabled:!0,className:`inline-flex items-center justify-center gap-2 rounded-lg bg-accent-primary px-3 py-2 text-sm font-medium text-white opacity-45`,children:[o?(0,Y.jsx)(To,{className:`h-4 w-4`}):(0,Y.jsx)(cs,{className:`h-4 w-4 animate-spin`}),l]});return(0,sr.createPortal)((0,Y.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":c?r(`attachment.previewTitle`,{name:t.filename}):r(`attachment.downloadTitle`),className:`fixed inset-0 z-[100] flex items-center justify-center bg-black/80 p-4 backdrop-blur-sm animate-in fade-in-0 duration-150`,onClick:n,children:c?(0,Y.jsxs)(`div`,{className:`flex h-full w-full flex-col overflow-hidden`,onClick:e=>e.stopPropagation(),children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-white/10 bg-black/30 px-3 py-2 text-white`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:n,"aria-label":r(`close`),className:`inline-flex items-center gap-2 rounded-lg px-2.5 py-1.5 text-sm text-white/75 transition-colors hover:bg-white/10 hover:text-white`,"data-agent-interactive":!0,children:[(0,Y.jsx)(Ba,{className:`h-4 w-4`}),r(`close`)]}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1 text-center`,children:[(0,Y.jsx)(`div`,{className:`truncate text-sm font-medium text-white/95`,children:t.filename}),(0,Y.jsx)(`div`,{className:`text-[11px] text-white/45`,children:I5(t.size)||t.mimeType})]}),u]}),(0,Y.jsx)(`div`,{className:`flex flex-1 items-center justify-center overflow-auto p-6`,children:o?(0,Y.jsx)(`div`,{className:`rounded-xl border border-white/10 bg-white/5 px-8 py-7 text-center text-sm text-white/80`,children:r(`attachment.loadError`,{error:o})}):i?(0,Y.jsx)(`img`,{src:i,alt:t.filename,className:`max-h-full max-w-full rounded-xl object-contain shadow-2xl animate-in zoom-in-95 duration-150`}):(0,Y.jsxs)(`div`,{className:`inline-flex items-center gap-2 rounded-xl border border-white/10 bg-white/5 px-5 py-3 text-sm text-white/70`,children:[(0,Y.jsx)(cs,{className:`h-4 w-4 animate-spin`}),r(`attachment.loading`)]})})]}):(0,Y.jsxs)(`div`,{className:`w-full max-w-sm rounded-2xl border border-border/70 bg-card p-4 text-foreground shadow-2xl`,onClick:e=>e.stopPropagation(),children:[(0,Y.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Y.jsx)(`div`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-xl border border-border/70 bg-surface/70`,children:(0,Y.jsx)(Fo,{className:`h-5 w-5 text-accent-primary`})}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`h2`,{className:`text-sm font-semibold`,children:r(`attachment.downloadTitle`)}),(0,Y.jsx)(`p`,{className:`mt-1 truncate text-xs font-medium text-foreground/70`,children:t.filename}),(0,Y.jsx)(`p`,{className:`mt-0.5 text-[11px] text-foreground/45`,children:[I5(t.size),t.mimeType].filter(Boolean).join(` · `)})]})]}),(0,Y.jsx)(`p`,{className:`mt-4 text-sm leading-6 text-foreground/70`,children:r(`attachment.downloadPrompt`)}),o&&(0,Y.jsxs)(`div`,{className:`mt-3 flex items-start gap-2 rounded-lg border border-destructive/25 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:[(0,Y.jsx)(oo,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,Y.jsx)(`span`,{children:r(`attachment.loadError`,{error:o})})]}),(0,Y.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:n,className:`rounded-lg border border-border/70 bg-surface/70 px-3 py-2 text-sm text-foreground/75 transition-colors hover:bg-surface hover:text-foreground`,"data-agent-interactive":!0,children:r(`attachment.cancelDownload`)}),u]})]})}),document.body)}function z5({conversationId:e,attachments:t}){let{t:n}=K(`agent`),[r,i]=(0,H.useState)(null);return!e||!t||t.length===0?null:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5 border-t border-border/40 pt-2`,children:t.map(e=>{let t=L5(e),r=t?$o:Po;return(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>i(e),title:e.filename,"aria-label":n(t?`attachment.openPreview`:`attachment.openDownload`,{name:e.filename}),className:`inline-flex max-w-[12rem] items-center gap-1.5 rounded-lg border border-border/60 bg-background/45 px-2 py-1 text-left text-[11px] text-foreground/75 transition-colors hover:border-accent-primary/45 hover:bg-accent-primary/10 hover:text-foreground`,"data-agent-interactive":!0,children:[(0,Y.jsx)(r,{className:`h-3.5 w-3.5 shrink-0 text-accent-primary`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.filename}),e.size>0&&(0,Y.jsx)(`span`,{className:`shrink-0 text-[10px] text-foreground/35`,children:I5(e.size)})]},e.id)})}),(0,Y.jsx)(R5,{conversationId:e,attachment:r,onClose:()=>i(null)})]})}function B5(e){return e===`project`||e===`alias`?Ya:e===`spec`?Po:e===`job`?qa:e===`trace`?Yo:e===`conversation`?qa:e===`file`?Ss:e===`pr`?Go:e===`action`?Qs:Wa}function V5(e){return e===`action`?`border-accent-highlight/30 bg-accent-highlight/10 text-accent-highlight`:e===`job`||e===`trace`?`border-accent-info/30 bg-accent-info/10 text-accent-info`:e===`spec`?`border-accent-highlight/30 bg-accent-highlight/10 text-accent-highlight`:e===`project`||e===`alias`?`border-accent-primary/30 bg-accent-primary/10 text-accent-primary`:`border-border/60 bg-surface/70 text-foreground/80`}function H5({refItem:e}){let t=B5(e.kind);return(0,Y.jsxs)(`span`,{title:[e.label,e.scope?.projectName,e.status].filter(Boolean).join(` · `)||e.token,className:X(`mx-0.5 inline-flex max-w-[16rem] translate-y-[2px] items-center gap-1 rounded-full border px-2 py-0.5 text-[11px] font-medium leading-4 shadow-sm shadow-black/5`,V5(e.kind)),"data-agent-context-token":e.kind,children:[(0,Y.jsx)(t,{className:`h-3 w-3 shrink-0`}),(0,Y.jsx)(`span`,{className:`truncate`,children:e.label||e.token})]})}function U5({content:e,contextRefs:t}){if(!t||t.length===0)return(0,Y.jsx)(Y.Fragment,{children:e});let n=[],r=0,i=0,a=new Set,o=t.map((t,n)=>({ref:t,originalIndex:n,index:t.token?e.indexOf(t.token):-1})).filter(e=>e.index>=0).sort((e,t)=>e.index-t.index||e.originalIndex-t.originalIndex);for(let t of o){let o=e.indexOf(t.ref.token,r);o<r||o===-1||(o>r&&n.push(e.slice(r,o)),n.push((0,Y.jsx)(H5,{refItem:t.ref},`${t.ref.kind}:${t.ref.id}:${o}:${t.originalIndex}`)),r=o+t.ref.token.length,a.add(t.originalIndex),i++)}r<e.length&&n.push(e.slice(r));let s=t.filter((e,t)=>!a.has(t));return s.length===0?(0,Y.jsx)(Y.Fragment,{children:i?n:e}):(0,Y.jsxs)(Y.Fragment,{children:[s.map((e,t)=>(0,Y.jsx)(H5,{refItem:e},`unmatched:${e.kind}:${e.id}:${t}`)),e.trim()&&(0,Y.jsx)(`span`,{className:`mx-0.5`}),i?n:e]})}function W5({role:e,content:t,createdAt:n,streaming:r,isLast:i,onPickOption:a,refsProjectId:o,onOpenRef:s,contextRefs:c,attachments:l,conversationId:u}){let d=e===`user`,{openWebView:f,canOpenWebView:p}=DH(),m=!d&&!r&&!!o&&!!s,h=(0,H.useMemo)(()=>m?[KL,j5]:[KL],[m]),g=(0,H.useMemo)(()=>({a:({href:e,children:t})=>{let n=p5(e);return n&&s?(0,Y.jsx)(M5,{refTarget:n,onOpen:s,children:t}):(0,Y.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,"data-agent-interactive":!0,onClick:t=>{p&&typeof e==`string`&&/^https?:\/\//i.test(e)&&(t.preventDefault(),t.stopPropagation(),f(e))},children:t})}}),[f,p,s]);if(d)return(0,Y.jsxs)(`div`,{className:`group flex flex-col items-end gap-0.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-start justify-end gap-1`,children:[(0,Y.jsx)(P5,{text:t,timestampIso:n}),(0,Y.jsxs)(`div`,{className:`max-w-[85%] whitespace-pre-wrap rounded-2xl rounded-br-sm border border-border/50 bg-foreground/[0.06] px-3.5 py-2 text-sm text-foreground`,children:[(0,Y.jsx)(U5,{content:t,contextRefs:c}),(0,Y.jsx)(z5,{conversationId:u,attachments:l})]})]}),n&&(0,Y.jsx)(`div`,{className:`pr-1.5`,children:(0,Y.jsx)(F5,{iso:n})})]});let{body:_,options:v}=$8(t),{body:y,draft:b,pending:x}=o5(_,r),S=!!v&&!!i&&!r&&!!a;return(0,Y.jsxs)(`div`,{className:`group flex flex-col gap-1`,children:[(0,Y.jsx)(`div`,{className:X(`max-w-full`,N5),children:(0,Y.jsx)(cI,{remarkPlugins:h,components:g,children:y})}),b&&(0,Y.jsx)(l5,{draft:b}),x&&(0,Y.jsx)(u5,{}),S&&(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-1.5 pt-1`,children:v.map((e,t)=>(0,Y.jsx)(`button`,{type:`button`,onClick:()=>a?.(e),className:`rounded-full border border-border/60 bg-surface/70 px-3 py-1 text-xs text-foreground/80 transition-colors hover:border-accent-primary/45 hover:bg-accent-primary/15 hover:text-foreground`,"data-agent-interactive":!0,children:e},`${t}-${e}`))}),!r&&(y.trim()||n)&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[y.trim()&&(0,Y.jsx)(P5,{text:y,timestampIso:n}),n&&(0,Y.jsx)(F5,{iso:n})]})]})}var G5=(0,H.createContext)(null);function K5({children:e}){let[t,n]=(0,H.useState)(!1),[r,i]=(0,H.useState)(!1),[a,o]=(0,H.useState)(!1),[s,c]=(0,H.useState)(!1),[l,u]=(0,H.useState)([]),d=(0,H.useCallback)(()=>n(!0),[]),f=(0,H.useCallback)(()=>n(!1),[]),p=(0,H.useCallback)(()=>n(e=>!e),[]),m=(0,H.useCallback)(()=>i(!0),[]),h=(0,H.useCallback)(()=>i(!1),[]),g=(0,H.useCallback)(()=>i(e=>!e),[]),_=(0,H.useCallback)(()=>o(!0),[]),v=(0,H.useCallback)(()=>o(!1),[]),y=(0,H.useCallback)(()=>o(e=>!e),[]),b=(0,H.useCallback)(()=>c(!0),[]),x=(0,H.useCallback)(()=>c(!1),[]),S=(0,H.useCallback)(e=>{u(t=>[...t,e])},[]),C=(0,H.useCallback)(()=>{let e=[];return u(t=>(e=t,t.length?[]:t)),e},[]),w=(0,H.useMemo)(()=>({codePaneOpen:t,openCodePane:d,closeCodePane:f,toggleCodePane:p,jobsPaneOpen:r,openJobsPane:m,closeJobsPane:h,toggleJobsPane:g,integrationsModalOpen:a,openIntegrationsModal:_,closeIntegrationsModal:v,toggleIntegrationsModal:y,browserOpen:s,openBrowser:b,closeBrowser:x,pendingCaptures:l,queueCapture:S,consumePendingCaptures:C}),[t,d,f,p,r,m,h,g,a,_,v,y,s,b,x,l,S,C]);return(0,Y.jsx)(G5.Provider,{value:w,children:e})}var q5={codePaneOpen:!1,openCodePane:()=>{},closeCodePane:()=>{},toggleCodePane:()=>{},jobsPaneOpen:!1,openJobsPane:()=>{},closeJobsPane:()=>{},toggleJobsPane:()=>{},integrationsModalOpen:!1,openIntegrationsModal:()=>{},closeIntegrationsModal:()=>{},toggleIntegrationsModal:()=>{},browserOpen:!1,openBrowser:()=>{},closeBrowser:()=>{},pendingCaptures:[],queueCapture:()=>{},consumePendingCaptures:()=>[]};function J5(){return(0,H.useContext)(G5)??q5}var Y5=(0,H.createContext)(null),X5=new Set([`exited`,`killed`,`failed`]),sne=8e3;function cne({children:e}){let{registerHandler:t,unregisterHandler:n}=df(),{active:r,draftPinnedProjectId:i}=N7(),{activeProjectId:a}=gm(),s=r?.pinned_project_id??i??a,c=r?.id??null,[l,u]=(0,H.useState)([]),d=(0,H.useRef)(new Map),f=(0,H.useCallback)(e=>{let t=d.current.get(e);t&&window.clearTimeout(t),d.current.delete(e)},[]),p=(0,H.useCallback)(e=>{let t=e;if(t.type===`background_process.started`&&t.process){f(t.process.pid),u(e=>e.some(e=>e.pid===t.process.pid)?e:[...e,t.process]);return}if(t.type===`background_process.exited`&&t.process){let e=t.process;if(f(e.pid),e.status===`killed`){u(t=>t.filter(t=>t.pid!==e.pid));return}let n={...e,completedAt:Date.now()};u(t=>t.some(t=>t.pid===e.pid)?t.map(t=>t.pid===e.pid?n:t):[...t,n]);let r=window.setTimeout(()=>{u(t=>t.filter(t=>t.pid!==e.pid)),d.current.delete(e.pid)},sne);d.current.set(e.pid,r)}},[f]);(0,H.useEffect)(()=>(t(`background-processes`,p),()=>n(`background-processes`)),[p,t,n]),(0,H.useEffect)(()=>{if(!s||!c)return;let e=!0;return(async()=>{try{let t=new URLSearchParams({chatId:c}),n=await fetch(`${o}/api/projects/${encodeURIComponent(s)}/background-processes?${t.toString()}`);if(!n.ok)return;let r=await n.json();if(!e||!Array.isArray(r.processes)||r.processes.length===0)return;u(e=>{let t=new Map(e.map(e=>[e.pid,e]));for(let e of r.processes??[])t.set(e.pid,e);return Array.from(t.values())})}catch{}})(),()=>{e=!1}},[c,s]),(0,H.useEffect)(()=>()=>{for(let e of d.current.values())window.clearTimeout(e);d.current.clear()},[]);let m=(0,H.useMemo)(()=>l.filter(e=>e.projectId===s&&e.chatId===c&&(!X5.has(e.status)||e.status!==`killed`&&e.completedAt!==void 0)),[l,s,c]),h=(0,H.useCallback)(async e=>{!s||!c||await fetch(`${o}/api/projects/${encodeURIComponent(s)}/background-processes/${encodeURIComponent(String(e))}?chatId=${encodeURIComponent(c)}`,{method:`DELETE`})},[c,s]),g=(0,H.useMemo)(()=>({processes:m,kill:h}),[m,h]);return(0,Y.jsx)(Y5.Provider,{value:g,children:e})}function lne(){return(0,H.useContext)(Y5)||{processes:[],kill:async()=>void 0}}var une=new Set([`@`,`#`,`/`]),dne=/[\s()[\]{}<>"']/;function fne(e,t=e.length){let n=Math.max(0,Math.min(t,e.length));for(let t=n-1;t>=0;t--){let r=e[t];if(r===`
143
- `||r===` `||r===` `)break;if(!une.has(r))continue;let i=t===0?``:e[t-1];if(i&&!dne.test(i))continue;let a=e.slice(t+1,n);if(/[()[\]{}<>"']/.test(a))return null;let o=r;return{trigger:o,mode:o===`@`?`reference`:o===`#`?`trace`:`action`,query:a,start:t,end:n}}return null}function Z5(e){return`${e.kind}:${e.id}`}function pne(e){return{kind:e.kind,id:e.id,label:e.label,token:e.token,scope:{projectId:e.projectId??null,projectName:e.projectName??null},status:e.status??null,metadata:e.metadata}}function Q5(e,t){return t?e.find(e=>e.id===t)?.name??null:null}function $5(e){return{kind:`project`,id:e.id,label:e.name,token:`@${e.name}`,detail:e.path,projectId:e.id,projectName:e.name,metadata:{slug:e.slug,path:e.path}}}function e7(e,t,n){return{kind:`spec`,id:String(e.id),label:e.title,token:`@${e.title}`,detail:n?`${n} / #${e.id}`:`#${e.id}`,status:e.status,projectId:t,projectName:n,metadata:{ticketId:e.id,priority:e.priority,labels:e.labels,shortSummary:e.short_summary??null}}}function t7(e,t,n){let r=e.id.slice(0,8);return{kind:`job`,id:e.id,label:r,token:`#${r}`,detail:n?`${n} / ${e.command}`:e.command,status:e.status,projectId:t,projectName:n,metadata:{command:e.command,startedAt:e.started_at,costUsd:e.total_cost_usd??null}}}function mne(e,t){let n=e.title||`Untitled mission`;return{kind:`conversation`,id:e.id,label:n,token:`@${n}`,detail:t?`Mission / ${t}`:`Mission`,projectId:e.pinned_project_id,projectName:t,metadata:{provider:e.provider}}}function hne(e,t){let n=t.trim().toLowerCase();return n?[e.title,e.subtitle,e.detail,e.group,...e.keywords??[]].filter(Boolean).join(` `).toLowerCase().includes(n):!0}function gne(e){let t=new Set,n=[];for(let r of e)t.has(r.id)||(t.add(r.id),n.push(r));return n}function _ne(e,t){return gne(e).filter(e=>hne(e,t)).slice(0,12)}function vne(e){let t=Q5(e.projects,e.pinnedProjectId),n=e.pinnedProjectId?e.projects.find(t=>t.id===e.pinnedProjectId)??null:null,r=[];if(n&&r.push({id:`alias:current-project:${n.id}`,mode:`reference`,title:`@current`,subtitle:n.name,detail:`Pinned project`,group:`Current`,icon:`alias`,chip:{...$5(n),kind:`alias`,id:`current:${n.id}`,token:`@current`},keywords:[`this`,`project`,n.name]}),e.activeConversation){let n=mne(e.activeConversation,t);r.push({id:`conversation:${e.activeConversation.id}`,mode:`reference`,title:n.label,subtitle:n.detail,detail:`Current mission`,group:`Created here`,icon:`conversation`,chip:n,keywords:[`mission`,`conversation`,`last`]})}for(let t of e.chips)r.push({id:`chip:${Z5(t)}`,mode:`reference`,title:t.label,subtitle:t.detail,detail:`Already in context`,group:`Current context`,icon:t.kind,chip:t});let i=e.tickets.map(n=>{let r=e7(n,e.pinnedProjectId,t),i=n.status===`on_review`||n.status===`in_progress`||n.status===`draft`;return{id:`spec:${r.projectId??`home`}:${n.id}`,mode:`reference`,title:n.title,subtitle:`Spec #${n.id}${n.status?` · ${n.status}`:``}`,detail:r.detail,group:i?`Active in project`:`Specs`,icon:`spec`,chip:r,keywords:[String(n.id),n.priority??``,...n.labels??[]]}});r.push(...i);let a=e.jobs.slice(0,8).map(n=>{let r=t7(n,e.pinnedProjectId,t);return{id:`job:${r.projectId??`home`}:${n.id}`,mode:`reference`,title:r.label,subtitle:`Job · ${n.status}`,detail:n.command,group:n.status===`running`||n.status===`failed`?`Needs attention`:`Recent jobs`,icon:`job`,chip:r,keywords:[n.id,n.command,n.status]}});r.push(...a);for(let t of e.projects){let n=$5(t);r.push({id:`project:${t.id}`,mode:`reference`,title:t.name,subtitle:`Project`,detail:t.path,group:t.id===e.activeProjectId?`Current app project`:`Projects`,icon:`project`,chip:n,keywords:[t.slug,t.path]})}return r}function yne(e){let t=Q5(e.projects,e.pinnedProjectId),n=[];for(let r of e.jobs){let i=t7(r,e.pinnedProjectId,t);n.push({id:`trace:job:${r.id}`,mode:`trace`,title:i.label,subtitle:`${r.status} · ${r.command}`,detail:t??void 0,group:r.status===`failed`||r.status===`running`?`Active traces`:`Recent traces`,icon:`job`,chip:{...i,kind:`trace`},keywords:[r.id,r.command,r.status,`failed`,`running`,`deploy`,`run`]})}for(let r of e.tickets){let i=e7(r,e.pinnedProjectId,t);n.push({id:`trace:spec:${r.id}`,mode:`trace`,title:`#${r.id}`,subtitle:`${r.title} · ${r.status}`,detail:t??void 0,group:`IDs`,icon:`spec`,chip:{...i,kind:`trace`,token:`#${r.id}`},keywords:[String(r.id),r.title,r.status]})}return n}var bne=[{id:`action:create-spec`,mode:`action`,title:`Create spec`,subtitle:`Turn this into a structured spec`,group:`Create`,icon:`action`,insertText:`/create spec`,tierLevel:2,risk:`cost`,keywords:[`new ticket quick add`]},{id:`action:explore-spec`,mode:`action`,title:`Explore spec`,subtitle:`Refine a fuzzy idea first`,group:`Refine`,icon:`action`,insertText:`/explore spec`,tierLevel:2,risk:`cost`,keywords:[`discovery draft requirements`]},{id:`action:update-spec`,mode:`action`,title:`Update spec`,subtitle:`Edit the selected spec`,group:`Refine`,icon:`action`,insertText:`/update spec`,tierLevel:1,keywords:[`edit ticket`]},{id:`action:assign-rail`,mode:`action`,title:`Assign to rail`,subtitle:`Put selected specs on a rail`,group:`Execute`,icon:`action`,insertText:`/assign to rail`,tierLevel:1,keywords:[`tickets rail`]},{id:`action:launch-rail`,mode:`action`,title:`Launch rail`,subtitle:`Run the selected rail or spec`,group:`Execute`,icon:`action`,insertText:`/launch rail`,tierLevel:2,risk:`cost`,keywords:[`run implement`]},{id:`action:launch-all`,mode:`action`,title:`Launch all eligible rails`,subtitle:`Start every ready rail in parallel`,group:`Execute`,icon:`action`,insertText:`/launch all eligible rails`,tierLevel:2,risk:`cost`,keywords:[`all rails run`]},{id:`action:status`,mode:`action`,title:`Show status`,subtitle:`Summarize the current workbench`,group:`Review`,icon:`action`,insertText:`/status`,tierLevel:0,keywords:[`state overview`]},{id:`action:diagnose`,mode:`action`,title:`Diagnose`,subtitle:`Inspect git, jobs, setup, Jira, and failures`,group:`Review`,icon:`action`,insertText:`/diagnose`,tierLevel:0,keywords:[`debug health failed`]},{id:`action:compare`,mode:`action`,title:`Compare`,subtitle:`Compare selected specs, jobs, diffs, or costs`,group:`Review`,icon:`action`,insertText:`/compare`,tierLevel:0,keywords:[`diff versus`]},{id:`action:summarize`,mode:`action`,title:`Summarize`,subtitle:`Condense selected context`,group:`Review`,icon:`action`,insertText:`/summarize`,tierLevel:0,keywords:[`recap`]},{id:`action:save-as-spec`,mode:`action`,title:`Save as spec`,subtitle:`Capture the selected context as durable work`,group:`Create`,icon:`action`,insertText:`/save as spec`,tierLevel:1,keywords:[`persist capture`]},{id:`action:generate-report`,mode:`action`,title:`Generate report`,subtitle:`Create a written artifact from selected context`,group:`Create`,icon:`action`,insertText:`/generate report`,tierLevel:1,keywords:[`document export`]},{id:`action:show-spend`,mode:`action`,title:`Show spend`,subtitle:`Review cost and budget impact`,group:`Review`,icon:`action`,insertText:`/show spend`,tierLevel:0,keywords:[`cost budget analytics`]},{id:`action:search`,mode:`action`,title:`Search current project`,subtitle:`Find specs, jobs, files, or context`,group:`Navigate`,icon:`action`,insertText:`/search`,tierLevel:0,keywords:[`find`]},{id:`action:search-all`,mode:`action`,title:`Search all projects`,subtitle:`Fan out across registered projects`,group:`Navigate`,icon:`action`,insertText:`/search all projects`,tierLevel:0,keywords:[`global home`]},{id:`action:open`,mode:`action`,title:`Open item`,subtitle:`Open the selected object in Specrails`,group:`Navigate`,icon:`action`,insertText:`/open`,tierLevel:0,keywords:[`navigate`]},{id:`action:wait`,mode:`action`,title:`Wait for result`,subtitle:`Follow a running job or trace`,group:`Review`,icon:`action`,insertText:`/wait for result`,tierLevel:0,keywords:[`watch running`]},{id:`action:show-diff`,mode:`action`,title:`Show diff`,subtitle:`Inspect changes from the selected job`,group:`Review`,icon:`action`,insertText:`/show diff`,tierLevel:0,keywords:[`files changes`]},{id:`action:diagnostic`,mode:`action`,title:`Export diagnostic`,subtitle:`Collect job telemetry and logs`,group:`Review`,icon:`action`,insertText:`/export diagnostic`,tierLevel:0,keywords:[`zip logs telemetry`]},{id:`action:cancel-job`,mode:`action`,title:`Cancel job`,subtitle:`Stop or delete a selected job`,group:`Clean up`,icon:`action`,insertText:`/cancel job`,tierLevel:3,risk:`destructive`,keywords:[`stop kill`]},{id:`action:refine-contract`,mode:`action`,title:`Refine contract`,subtitle:`Add or refresh the Contract Layer`,group:`Refine`,icon:`action`,insertText:`/refine contract`,tierLevel:2,risk:`cost`,keywords:[`contract`]},{id:`action:split-epic`,mode:`action`,title:`Split epic`,subtitle:`Decompose a large spec into children`,group:`Refine`,icon:`action`,insertText:`/split epic`,tierLevel:2,risk:`cost`,keywords:[`smash children`]},{id:`action:files-touched`,mode:`action`,title:`Show files touched`,subtitle:`Inspect provenance for selected work`,group:`Review`,icon:`action`,insertText:`/show files touched`,tierLevel:0,keywords:[`provenance`]},{id:`action:connect-jira`,mode:`action`,title:`Connect Jira`,subtitle:`Start the Jira connection flow`,group:`Integrate`,icon:`action`,insertText:`/connect Jira`,tierLevel:1,keywords:[`integration`]},{id:`action:sync-jira`,mode:`action`,title:`Sync Jira`,subtitle:`Refresh Jira-backed specs`,group:`Integrate`,icon:`action`,insertText:`/sync Jira`,tierLevel:1,keywords:[`integration`]},{id:`action:install-plugin`,mode:`action`,title:`Install plugin`,subtitle:`Preview and install an integration`,group:`Integrate`,icon:`action`,insertText:`/install plugin`,tierLevel:1,keywords:[`mcp integration`]},{id:`action:set-budget`,mode:`action`,title:`Set budget`,subtitle:`Adjust spend guardrails`,group:`Configure`,icon:`action`,insertText:`/set budget`,tierLevel:1,keywords:[`cost limit`]}];function n7(e,t,n){let r=new Set(t.map(e=>e.kind)),i=0;return t.length===0&&([`action:create-spec`,`action:search`,`action:status`,`action:diagnose`,`action:show-spend`].includes(e.id)&&(i+=40),n.pinnedProjectId&&e.id===`action:launch-all`&&(i+=30)),r.has(`project`)&&[`action:status`,`action:search`,`action:launch-all`,`action:show-spend`,`action:sync-jira`,`action:install-plugin`].includes(e.id)&&(i+=50),r.has(`spec`)&&[`action:update-spec`,`action:assign-rail`,`action:launch-rail`,`action:refine-contract`,`action:split-epic`,`action:files-touched`,`action:show-spend`].includes(e.id)&&(i+=70),(r.has(`job`)||r.has(`trace`))&&[`action:open`,`action:wait`,`action:compare`,`action:show-diff`,`action:diagnostic`,`action:cancel-job`].includes(e.id)&&(i+=80),r.has(`file`)&&[`action:summarize`,`action:show-diff`,`action:files-touched`].includes(e.id)&&(i+=60),i}function xne(e){return[...bne].sort((t,n)=>n7(n,e.chips,e)-n7(t,e.chips,e)).map(e=>({...e,chip:{kind:`action`,id:e.id,label:e.title,token:e.insertText??`/${e.title.toLowerCase()}`,detail:e.subtitle,metadata:{tierLevel:e.tierLevel,risk:e.risk??null}}}))}function Sne(e,t){return e===`reference`?vne(t):e===`trace`?yne(t):xne(t)}function Cne(e,t){let n=t.trim();if(!n)return[];let r=n.slice(0,80),i=[{id:`fallback:search-all:${e}:${r}`,mode:e,title:`Search all Specrails`,subtitle:`Find "${r}" across every project`,group:`No matches`,icon:`action`,insertText:`/search all projects ${r}`,tierLevel:0,keywords:[`fallback global search all`]},{id:`fallback:ask-agent:${e}:${r}`,mode:e,title:`Ask agent about "${r}"`,subtitle:`Keep the wording and let the agent resolve it`,group:`No matches`,icon:`action`,insertText:r,tierLevel:0,keywords:[`fallback ask agent clarify`]}];return e===`trace`?i.splice(1,0,{id:`fallback:archived:${e}:${r}`,mode:e,title:`Include archived results`,subtitle:`Search completed, canceled, and old traces for "${r}"`,group:`No matches`,icon:`action`,insertText:`/search all projects archived ${r}`,tierLevel:0,keywords:[`fallback archived old completed canceled`]}):i.splice(1,0,{id:`fallback:create-spec:${e}:${r}`,mode:e,title:`Create "${r}"`,subtitle:`Turn this unmatched reference into a spec`,group:`No matches`,icon:`action`,insertText:`/create spec ${r}`,tierLevel:2,risk:`cost`,keywords:[`fallback create new spec`]}),i}function wne(e,t,n){let r=n.insertText??n.chip?.token??n.title,i=t?.start??e.length,a=t?.end??e.length,o=e.slice(0,i),s=e.slice(a),c=o&&!/\s$/.test(o)?` `:``,l=s&&!/^\s/.test(s)?` `:``;return{text:`${o}${c}${r}${l}${s}`,caret:o.length+c.length+r.length+l.length}}function r7({pinnedProjectId:e,onSelect:t}){let{t:n}=K(`agent`),{projects:r}=gm(),[i,a]=(0,H.useState)(!1),[o,s]=(0,H.useState)(``),c=(0,H.useRef)(null);(0,H.useEffect)(()=>{if(!i)return;let e=e=>{c.current&&!c.current.contains(e.target)&&a(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[i]);let l=r.find(t=>t.id===e)??null,u=(0,H.useMemo)(()=>{let e=o.trim().toLowerCase();return e?r.filter(t=>t.name.toLowerCase().includes(e)):r},[r,o]),d=e=>{t(e),a(!1),s(``)};return(0,Y.jsxs)(`div`,{className:`relative`,ref:c,"data-agent-interactive":!0,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>a(e=>!e),className:`flex items-center gap-1.5 rounded-md px-1.5 py-1 text-sm font-medium text-foreground hover:bg-surface/70`,children:[l?(0,Y.jsx)(Bo,{className:`h-3.5 w-3.5 text-accent-primary`}):(0,Y.jsx)(Qo,{className:`h-3.5 w-3.5 text-foreground/70`}),(0,Y.jsx)(`span`,{className:`max-w-[160px] truncate`,children:l?l.name:n(`project.home`)}),(0,Y.jsx)(no,{className:`h-3.5 w-3.5 text-foreground/50`})]}),(0,Y.jsx)(H3,{children:i&&(0,Y.jsxs)(V8.div,{initial:{opacity:0,y:-6,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-6,scale:.98},transition:{duration:.16,ease:`easeOut`},className:`absolute left-0 top-full z-10 mt-1 w-64 overflow-hidden rounded-xl border border-border/60 bg-card/95 shadow-2xl backdrop-blur-xl`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/50 px-3 py-2`,children:[(0,Y.jsx)(Us,{className:`h-3.5 w-3.5 text-foreground/40`}),(0,Y.jsx)(`input`,{autoFocus:!0,value:o,onChange:e=>s(e.target.value),placeholder:n(`project.searchPlaceholder`),className:`w-full bg-transparent text-sm text-foreground outline-none placeholder:text-foreground/40`})]}),(0,Y.jsxs)(`div`,{className:`max-h-72 overflow-y-auto py-1`,children:[(0,Y.jsx)(`div`,{className:`px-3 py-1 text-[11px] uppercase tracking-wide text-foreground/40`,children:n(`project.recents`)}),(0,Y.jsx)(i7,{icon:(0,Y.jsx)(Qo,{className:`h-4 w-4`}),label:n(`project.home`),active:!e,onClick:()=>d(null),index:0}),u.map((t,n)=>(0,Y.jsx)(i7,{icon:(0,Y.jsx)(Bo,{className:`h-4 w-4 text-accent-primary`}),label:t.name,active:t.id===e,onClick:()=>d(t.id),index:n+1},t.id))]})]})})]})}function i7({icon:e,label:t,active:n,onClick:r,index:i}){return(0,Y.jsxs)(V8.button,{type:`button`,onClick:r,initial:{opacity:0,x:-6},animate:{opacity:1,x:0},transition:{duration:.14,delay:Math.min(i*.03,.18)},className:`flex w-full items-center gap-2.5 px-3 py-1.5 text-left text-sm text-foreground hover:bg-surface/70`,children:[e,(0,Y.jsx)(`span`,{className:`flex-1 truncate`,children:t}),n&&(0,Y.jsx)(to,{className:`h-3.5 w-3.5 text-accent-primary`})]})}var a7=[{level:0,key:`observe`,icon:ko,tone:`text-foreground/70`,bar:`bg-accent-info`},{level:1,key:`edit`,icon:ws,tone:`text-accent-info`,bar:`bg-accent-info`},{level:2,key:`operate`,icon:gc,tone:`text-accent-warning`,bar:`bg-accent-warning`},{level:3,key:`autonomous`,icon:Lo,tone:`text-destructive`,bar:`bg-destructive`}];function Tne({level:e,onCycle:t}){let{t:n}=K(`agent`),r=a7[e],i=r.icon;return(0,Y.jsxs)(`button`,{type:`button`,onClick:t,title:n(`tier.${r.key}.desc`),"aria-label":`${n(`tier.${r.key}.name`)} — ${n(`tier.cycleHint`)}`,className:`group flex items-center gap-1.5 rounded-full border border-border/60 bg-surface/70 px-2.5 py-1 text-xs font-medium ${r.tone} transition-colors hover:bg-surface`,"data-agent-interactive":!0,children:[(0,Y.jsxs)(V8.span,{initial:{scale:.8},animate:{scale:[1,1.18,1]},transition:{duration:.28,ease:`easeOut`},className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(i,{className:`h-3.5 w-3.5`}),n(`tier.${r.key}.name`)]},e),(0,Y.jsx)(`span`,{className:`ml-1 flex gap-0.5`,"aria-hidden":!0,children:a7.map(t=>(0,Y.jsx)(`span`,{className:`h-1 w-2 rounded-full transition-colors duration-200 ${t.level<=e?r.bar:`bg-border/50`}`},t.level))})]})}function Ene({provider:e,model:t,onSelect:n}){let{t:r}=K(`agent`),[i,a]=(0,H.useState)([]);return(0,H.useEffect)(()=>{let t=!0;return EY(e).then(e=>{t&&a(e.models)}).catch(()=>{t&&a([])}),()=>{t=!1}},[e]),(0,Y.jsx)(`select`,{value:t??i.find(e=>e.default)?.value??i[0]?.value??``,onChange:e=>n(e.target.value),"aria-label":r(`model.label`),"data-agent-interactive":!0,className:`rounded-lg border border-border/60 bg-surface/70 px-2.5 py-1 text-xs text-foreground outline-none hover:bg-surface`,children:i.map(e=>(0,Y.jsx)(`option`,{value:e.value,children:e.label},e.value))})}function Dne({projectId:e}){let{t}=K(`agent`),{isStreaming:n}=N7(),[r,i]=(0,H.useState)(null),[a,s]=(0,H.useState)(!1),[c,l]=(0,H.useState)(!1),[u,d]=(0,H.useState)(``),f=(0,H.useRef)(null),p=`${o}/api/projects/${e}/git`,m=(0,H.useCallback)(async()=>{try{let e=await fetch(p);if(!e.ok)return;i(await e.json())}catch{}},[p]);(0,H.useEffect)(()=>{i(null),m()},[m]);let h=(0,H.useRef)(n);(0,H.useEffect)(()=>{h.current&&!n&&m(),h.current=n},[n,m]),(0,H.useEffect)(()=>{if(!c)return;let e=e=>{f.current&&!f.current.contains(e.target)&&l(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[c]);let g=(0,H.useCallback)(async e=>{if(l(!1),d(``),!(!e||e===r?.branch)){s(!0);try{let n=await fetch(`${p}/checkout`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({branch:e})}),r=await n.json().catch(()=>({}));if(!n.ok){q.error(t(`git.switchFailed`),{description:r.error}),m();return}i(r),q.success(t(`git.switched`,{branch:e}))}catch{q.error(t(`git.switchFailed`)),m()}finally{s(!1)}}},[p,r?.branch,t,m]),_=(0,H.useMemo)(()=>{if(!r)return[];let e=u.trim().toLowerCase();return e?r.branches.filter(t=>t.toLowerCase().includes(e)):r.branches},[r,u]);if(!r?.git)return null;let v=a||n,y=r.detached?t(`git.detached`):r.branch??t(`git.detached`),b=new Map((r.worktrees??[]).filter(e=>!e.isMain&&e.branch).map(e=>[e.branch,e])),x=_.filter(e=>!b.has(e)),S=_.filter(e=>b.has(e)),C=async e=>{l(!1),d(``);try{await navigator.clipboard.writeText(e.path),q.success(t(`git.worktreePathCopied`),{description:e.path})}catch{q.info?.(e.path)}};return(0,Y.jsxs)(`div`,{ref:f,className:`relative mt-1.5 flex min-w-0 items-center gap-2 px-1 text-[11px] text-foreground/50`,"data-agent-interactive":!0,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{v||l(e=>!e)},disabled:v,"aria-label":t(`git.branch`),"aria-expanded":c,title:t(v&&n?`git.lockedWhileWorking`:`git.branch`),className:`flex max-w-[220px] shrink-0 items-center gap-1.5 rounded-md border border-border/50 bg-surface/60 px-1.5 py-0.5 text-[11px] text-foreground transition-colors hover:bg-surface disabled:opacity-50`,children:[a?(0,Y.jsx)(cs,{className:`h-3 w-3 shrink-0 animate-spin text-accent-primary/70`}):(0,Y.jsx)(Ho,{className:`h-3 w-3 shrink-0 text-accent-primary/70`}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate`,children:y}),(0,Y.jsx)(no,{className:`h-3 w-3 shrink-0 text-foreground/40`})]}),(0,Y.jsx)(H3,{children:c&&(0,Y.jsxs)(V8.div,{initial:{opacity:0,y:6,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:6,scale:.98},transition:{duration:.16,ease:`easeOut`},className:`absolute bottom-full left-0 z-20 mb-1 w-72 overflow-hidden rounded-xl border border-border/60 bg-card/95 shadow-2xl backdrop-blur-xl`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/50 px-3 py-2`,children:[(0,Y.jsx)(Us,{className:`h-3.5 w-3.5 text-foreground/40`}),(0,Y.jsx)(`input`,{autoFocus:!0,value:u,onChange:e=>d(e.target.value),placeholder:t(`git.searchPlaceholder`),"aria-label":t(`git.searchPlaceholder`),className:`w-full bg-transparent text-sm text-foreground outline-none placeholder:text-foreground/40`})]}),(0,Y.jsxs)(`div`,{className:`max-h-64 overflow-y-auto py-1`,role:`listbox`,"aria-label":t(`git.branch`),children:[_.length===0&&(0,Y.jsx)(`div`,{className:`px-3 py-2 text-xs text-foreground/40`,children:t(`git.noMatches`)}),x.map((e,t)=>(0,Y.jsxs)(V8.button,{type:`button`,role:`option`,"aria-selected":e===r.branch,onClick:()=>void g(e),initial:{opacity:0,x:-6},animate:{opacity:1,x:0},transition:{duration:.14,delay:Math.min(t*.02,.16)},className:`flex w-full items-center gap-2.5 px-3 py-1.5 text-left text-sm text-foreground hover:bg-surface/70`,children:[(0,Y.jsx)(Ho,{className:`h-3.5 w-3.5 shrink-0 text-accent-primary/70`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs`,children:e}),e===r.branch&&(0,Y.jsx)(to,{className:`h-3.5 w-3.5 shrink-0 text-accent-primary`})]},e)),S.length>0&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`mt-1 border-t border-border/50 px-3 pb-0.5 pt-1.5 text-[10px] uppercase tracking-wide text-foreground/40`,children:t(`git.worktrees`)}),S.map((e,n)=>{let r=b.get(e);return(0,Y.jsxs)(V8.button,{type:`button`,role:`option`,"aria-selected":!1,onClick:()=>void C(r),initial:{opacity:0,x:-6},animate:{opacity:1,x:0},transition:{duration:.14,delay:Math.min(n*.02,.16)},title:t(`git.copyWorktreePath`),className:`group flex w-full items-center gap-2.5 px-3 py-1.5 text-left text-sm text-foreground hover:bg-surface/70`,children:[(0,Y.jsx)(Ro,{className:`h-3.5 w-3.5 shrink-0 text-accent-secondary/80`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block truncate font-mono text-xs`,children:e}),(0,Y.jsx)(`span`,{className:`block truncate text-[10px] text-foreground/40`,children:r.path})]}),(0,Y.jsx)(bo,{className:`h-3 w-3 shrink-0 text-foreground/30 opacity-0 transition-opacity group-hover:opacity-100`})]},e)})]})]})]})}),r.dirty&&(0,Y.jsx)(`span`,{title:t(`git.dirty`),"aria-label":t(`git.dirty`),className:`h-1.5 w-1.5 shrink-0 rounded-full bg-accent-warning`}),r.lastCommit&&(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,title:`${r.lastCommit.hash} · ${r.lastCommit.subject}`,children:[(0,Y.jsx)(`span`,{className:`font-mono text-foreground/40`,children:r.lastCommit.hash}),` · `,r.lastCommit.subject]})]})}var One={reference:Wa,trace:Yo,action:Qs},o7={project:Ya,spec:Po,job:qa,trace:Yo,conversation:qa,file:Ss,alias:Wa,pr:Go,action:Qs};function kne(e){return e===`reference`?`@`:e===`trace`?`#`:`/`}function Ane(e){return e===`spec`?`border-accent-highlight/30 bg-accent-highlight/10 text-accent-highlight`:e===`job`||e===`trace`?`border-accent-info/30 bg-accent-info/10 text-accent-info`:e===`action`?`border-accent-highlight/30 bg-accent-highlight/10 text-accent-highlight`:e===`project`||e===`alias`?`border-accent-primary/30 bg-accent-primary/10 text-accent-primary`:`border-border/60 bg-surface/70 text-foreground/80`}function jne({chips:e,onRemove:t}){let{t:n}=K(`agent`);return e.length===0?null:(0,Y.jsx)(Y.Fragment,{children:e.map(e=>{let r=o7[e.kind]??Wa;return(0,Y.jsxs)(`span`,{title:[e.label,e.detail,e.projectName,e.status].filter(Boolean).join(` · `),className:`inline-flex max-w-[240px] items-center gap-1.5 rounded-full border px-2 py-0.5 text-[11px] ${Ane(e.kind)}`,children:[(0,Y.jsx)(r,{className:`h-3 w-3 shrink-0`}),(0,Y.jsx)(`span`,{className:`truncate font-medium`,children:e.label}),e.status&&(0,Y.jsx)(`span`,{className:`text-foreground/40`,children:e.status}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>t(e),"aria-label":n(`palette.remove`,{label:e.label}),className:`rounded-sm text-foreground/45 hover:bg-background/60 hover:text-foreground`,children:(0,Y.jsx)(hc,{className:`h-3 w-3`})})]},`${e.kind}:${e.id}`)})})}function Mne({items:e,mode:t,query:n,activeIndex:r,onActiveIndexChange:i,onSelect:a}){let{t:o}=K(`agent`),s=One[t],c=``;return(0,Y.jsxs)(`div`,{"data-testid":`agent-context-palette`,className:`absolute bottom-[calc(100%+0.5rem)] left-0 right-0 z-30 overflow-hidden rounded-lg border border-border/70 bg-background/95 shadow-xl shadow-black/15 backdrop-blur`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/60 px-2.5 py-2`,children:[(0,Y.jsx)(`span`,{className:`inline-flex h-6 w-6 items-center justify-center rounded-md bg-surface text-foreground/70`,children:(0,Y.jsx)(s,{className:`h-3.5 w-3.5`})}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`div`,{className:`text-xs font-medium text-foreground`,children:[kne(t),` `,o(`palette.mode.${t}.title`)]}),(0,Y.jsx)(`div`,{className:`truncate text-[11px] text-foreground/45`,children:n?o(`palette.filtering`,{query:n}):o(`palette.mode.${t}.hint`)})]}),(0,Y.jsx)(`div`,{className:`hidden text-[10px] text-foreground/35 sm:block`,children:o(`palette.keyboard`)})]}),e.length===0?(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-3 text-xs text-foreground/55`,children:[(0,Y.jsx)(Us,{className:`h-3.5 w-3.5 text-foreground/35`}),(0,Y.jsx)(`span`,{children:n?o(`palette.noMatchesFor`,{query:n}):o(`palette.noMatches`)})]}):(0,Y.jsx)(`div`,{className:`max-h-[19rem] overflow-y-auto py-1`,children:e.map((e,t)=>{let n=o7[e.icon]??Qs,o=e.group!==c;c=e.group;let s=t===r;return(0,Y.jsxs)(`div`,{children:[o&&(0,Y.jsx)(`div`,{className:`px-3 pb-1 pt-2 text-[10px] font-medium uppercase tracking-wide text-foreground/35`,children:e.group}),(0,Y.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":s,onMouseEnter:()=>i(t),onMouseDown:e=>e.preventDefault(),onClick:()=>a(e),className:`flex w-full items-center gap-2 px-2.5 py-2 text-left transition-colors ${s?`bg-accent-primary/10 text-foreground`:`text-foreground/80 hover:bg-surface/70`}`,children:[(0,Y.jsx)(`span`,{className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md ${s?`bg-background text-accent-primary`:`bg-surface text-foreground/50`}`,children:(0,Y.jsx)(n,{className:`h-3.5 w-3.5`})}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e.title}),e.risk&&(0,Y.jsx)(`span`,{className:`shrink-0 rounded-sm border border-border/60 px-1 py-0.5 text-[10px] uppercase text-foreground/45`,children:e.risk})]}),(e.subtitle||e.detail)&&(0,Y.jsxs)(`span`,{className:`mt-0.5 block truncate text-[11px] text-foreground/45`,children:[e.subtitle,e.subtitle&&e.detail?` · `:``,e.detail]})]})]})]},e.id)})})]})}function Nne({open:e,canAttach:t,uploading:n,onToggle:r,onClose:i,onOpenMode:a,onAttachFile:o}){let{t:s}=K(`agent`),c=(0,H.useRef)(null);return(0,H.useEffect)(()=>{if(!e)return;let t=e=>{let t=e.target;t instanceof Node&&c.current?.contains(t)||i()},n=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),i())};return document.addEventListener(`pointerdown`,t,!0),document.addEventListener(`keydown`,n,!0),()=>{document.removeEventListener(`pointerdown`,t,!0),document.removeEventListener(`keydown`,n,!0)}},[e,i]),(0,Y.jsxs)(`div`,{ref:c,className:`relative mb-1`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:r,"aria-label":s(`palette.addContextAction`),title:s(`palette.addContextAction`),"data-agent-interactive":!0,className:`rounded-md p-1 text-foreground/50 hover:bg-surface hover:text-foreground disabled:opacity-50`,children:(0,Y.jsx)(ks,{className:`h-4 w-4`})}),e&&(0,Y.jsxs)(`div`,{className:`absolute bottom-8 left-0 z-40 w-64 overflow-hidden rounded-lg border border-border/70 bg-background/95 py-1 shadow-xl shadow-black/15 backdrop-blur`,children:[(0,Y.jsxs)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>a(`reference`),className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-surface`,children:[(0,Y.jsx)(Wa,{className:`h-4 w-4 text-accent-primary`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block font-medium`,children:s(`palette.plus.reference`)}),(0,Y.jsx)(`span`,{className:`block truncate text-[11px] text-foreground/45`,children:s(`palette.plus.referenceHint`)})]})]}),(0,Y.jsxs)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>a(`trace`),className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-surface`,children:[(0,Y.jsx)(Yo,{className:`h-4 w-4 text-accent-info`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block font-medium`,children:s(`palette.plus.trace`)}),(0,Y.jsx)(`span`,{className:`block truncate text-[11px] text-foreground/45`,children:s(`palette.plus.traceHint`)})]})]}),(0,Y.jsxs)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>a(`action`),className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-surface`,children:[(0,Y.jsx)(Qs,{className:`h-4 w-4 text-accent-highlight`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block font-medium`,children:s(`palette.plus.action`)}),(0,Y.jsx)(`span`,{className:`block truncate text-[11px] text-foreground/45`,children:s(`palette.plus.actionHint`)})]})]}),(0,Y.jsx)(`div`,{className:`my-1 border-t border-border/60`}),(0,Y.jsxs)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:o,disabled:!t||n,className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-surface disabled:cursor-not-allowed disabled:opacity-45`,children:[(0,Y.jsx)(Ss,{className:`h-4 w-4 text-foreground/50`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block font-medium`,children:s(`palette.plus.fileAttachment`)}),(0,Y.jsx)(`span`,{className:`block truncate text-[11px] text-foreground/45`,children:s(`palette.plus.fileAttachmentHint`)})]})]}),(0,Y.jsxs)(`button`,{type:`button`,disabled:!0,className:`flex w-full cursor-not-allowed items-center gap-2 px-3 py-2 text-left text-sm opacity-45`,children:[(0,Y.jsx)(Za,{className:`h-4 w-4 text-foreground/50`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block font-medium`,children:s(`palette.plus.browserCapture`)}),(0,Y.jsx)(`span`,{className:`block truncate text-[11px] text-foreground/45`,children:s(`palette.plus.browserCaptureHint`)})]})]})]})]})}var Pne={"accent-primary":`border-accent-primary/40 bg-accent-primary/10 text-accent-primary`,"accent-info":`border-accent-info/40 bg-accent-info/10 text-accent-info`,"accent-highlight":`border-accent-highlight/40 bg-accent-highlight/10 text-accent-highlight`};function Fne({process:e,accentVariant:t,onKill:n}){let[r,i]=(0,H.useState)(Date.now());(0,H.useEffect)(()=>{let e=window.setInterval(()=>i(Date.now()),1e3);return()=>window.clearInterval(e)},[]);let a=jz(r-e.startedAt),o=e.status===`exited`||e.status===`failed`||e.status===`killed`;return(0,Y.jsx)(FE,{delayDuration:150,children:(0,Y.jsxs)(IE,{children:[(0,Y.jsx)(LE,{asChild:!0,children:(0,Y.jsxs)(`span`,{"data-testid":`background-process-chip`,className:`group inline-flex max-w-[220px] items-center gap-1.5 rounded-full border px-2 py-0.5 text-[11px] transition-colors ${Pne[t]}`,children:[(0,Y.jsx)(ac,{className:`h-3 w-3 shrink-0 ${o?``:`animate-pulse`}`}),(0,Y.jsx)(`span`,{className:e.status===`failed`?`shrink-0 font-medium text-destructive`:`shrink-0 text-foreground/60`,children:e.status}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate font-medium`,children:e.command}),!o&&(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Kill ${e.command}`,title:`Kill ${e.command}`,onClick:t=>{t.preventDefault(),t.stopPropagation(),n(e.pid)},className:`rounded-sm p-0.5 opacity-70 transition-opacity hover:bg-background/60 hover:opacity-100 group-hover:opacity-100`,children:(0,Y.jsx)(hc,{className:`h-3 w-3`})})]})}),(0,Y.jsx)(RE,{children:o?`${e.status} after ${a}`:a})]})})}var Ine=[`claude`,`codex`,`gemini`];function Lne(e,t){if(!t)return{text:e,caret:e.length};let n=e.slice(0,t.start),r=e.slice(t.end);/\s$/.test(n)&&/^\s/.test(r)&&(r=r.replace(/^\s+/,``));let i=n&&r&&!/\s$/.test(n)&&!/^\s/.test(r)?` `:``;return{text:`${n}${i}${r}`,caret:n.length+i.length}}var s7=new Map,c7=new Map,l7=`__new-mission__`;function u7({autoFocus:e=!1,hideProjectSelector:t=!1}){let{t:n}=K(`agent`),{active:r,messages:i,conversations:a,isStreaming:s,providersReady:c,draftPinnedProjectId:l,draftProvider:u,draftModel:d,draftTierLevel:f,draftEffort:p,setEffort:m,send:h,abort:g,cycleTier:_,setProvider:v,setModel:y,setPinnedProject:b,materializeDraftConversation:x,queuedMessages:S,editQueuedMessage:C,wasQueueConsumed:w}=N7(),{pendingCaptures:T,consumePendingCaptures:E}=J5(),{processes:D,kill:O}=lne(),{projects:k,activeProjectId:A}=gm(),j=r?.id??l7,[M,N]=(0,H.useState)(()=>s7.get(j)??``),P=e=>{N(e),e?s7.set(j,e):s7.delete(j)},[F,I]=(0,H.useState)(null),[L,R]=(0,H.useState)(()=>c7.get(j)??[]),z=(0,H.useRef)(j);z.current=j;let ee=(e,t)=>{let n=c7.get(e)??[],r=typeof t==`function`?t(n):t;r.length>0?c7.set(e,r):c7.delete(e);let i=z.current;(i===e||i===l7&&e!==l7)&&R(r)},[te,B]=(0,H.useState)(!1),ne=(0,H.useRef)(null),V=(0,H.useRef)(null),[re,U]=(0,H.useState)([]),[ie,ae]=(0,H.useState)(null),[W,oe]=(0,H.useState)(0),[se,ce]=(0,H.useState)(!1),[le,ue]=(0,H.useState)([]),[de,fe]=(0,H.useState)([]),pe=F!==null,me=(0,H.useMemo)(()=>i.filter(e=>e.role===`user`).map(e=>e.content),[i]),[he,ge]=(0,H.useState)(null),_e=(0,H.useRef)(``),ve=(0,H.useRef)(``),ye=he===null?-1:S.findIndex(e=>e.queueId===he),G=ye>=0?S[ye]:null,be=he!==null,xe=c===!1,Se=!xe,Ce=r?.provider??u,we=r?r.pinned_project_id:l,Te=we,Ee=(0,H.useMemo)(()=>({projects:k,conversations:a,activeConversation:r,pinnedProjectId:Te,activeProjectId:A,tickets:le,jobs:de,chips:re}),[k,a,r,Te,A,le,de,re]),De=(0,H.useMemo)(()=>ie?Sne(ie.mode,Ee):[],[ie,Ee]),Oe=(0,H.useMemo)(()=>{if(!ie)return[];let e=_ne(De,ie.query);return e.length>0?e:Cne(ie.mode,ie.query)},[De,ie]),ke=ie!==null&&!be,Ae=M.trim().length>0||re.length>0,je=[`accent-primary`,`accent-info`,`accent-highlight`],Me=r?.id??null;(0,H.useEffect)(()=>{R(c7.get(Me??l7)??[]),I(null),ae(null),ce(!1),U([]),ge(null),N(s7.get(Me??l7)??``)},[Me]),(0,H.useEffect)(()=>{if(!Te){ue([]),fe([]);return}let e=!0;return(async()=>{try{let[t,n]=await Promise.all([fetch(`${o}/api/projects/${encodeURIComponent(Te)}/tickets`),fetch(`${o}/api/projects/${encodeURIComponent(Te)}/jobs?limit=25`)]),r=await t.json(),i=await n.json();if(!e)return;ue(Array.isArray(r.tickets)?r.tickets:[]),fe(Array.isArray(i.jobs)?i.jobs:[])}catch{if(!e)return;ue([]),fe([])}})(),()=>{e=!1}},[Te]),(0,H.useEffect)(()=>{oe(0)},[ie?.mode,ie?.query]),(0,H.useEffect)(()=>{W>=Oe.length&&oe(Math.max(0,Oe.length-1))},[W,Oe.length]),(0,H.useEffect)(()=>{if(T.length===0)return;let e=E();e.length&&ee(j,t=>[...t,...e])},[T,E,j]);let[Ne,Pe]=(0,H.useState)(!0),[Fe,Ie]=(0,H.useState)([]);(0,H.useEffect)(()=>{let e=!0;return EY(Ce).then(t=>{e&&(Pe(t.supportsImageInput),Ie(t.efforts))}).catch(()=>{}),()=>{e=!1}},[Ce]);let Le=(r?r.reasoning_effort:p)??`medium`,Re=e=>{let t=s7.get(l7);t&&(s7.has(e)||s7.set(e,t),s7.delete(l7),N(s7.get(e)??t));let n=c7.get(l7);n?.length&&(ee(e,[...c7.get(e)??[],...n]),c7.delete(l7))},ze=async e=>{if(e.length===0)return;B(!0);let t=r;if(!t)try{t=await x(),Re(t.id)}catch(e){q.error(e instanceof Error?e.message:n(`workspace.uploadFailed`)),B(!1);return}for(let r of e){if(!Ne&&r.type.startsWith(`image/`)){q.error(n(`imagesUnsupported`));continue}try{let e=await NY(t.id,r);ee(t.id,t=>[...t,e])}catch(e){q.error(e instanceof Error?e.message:n(`workspace.uploadFailed`))}}B(!1)},Be=e=>{ee(j,t=>t.filter(t=>t.id!==e)),r&&LY(r.id,e)},Ve=(e,t)=>{let n=fne(e,t);ae(n),n&&ce(!1)},He=e=>e===`reference`?`@`:e===`trace`?`#`:`/`,Ue=e=>{requestAnimationFrame(()=>{V.current?.focus(),V.current?.setSelectionRange(e,e)})},We=e=>{if(be)return;let t=He(e),n=V.current,r=n?.selectionStart??M.length,i=n?.selectionEnd??r;P(`${M.slice(0,r)}${t}${M.slice(i)}`),I(null),ce(!1),ae({mode:e,trigger:t,query:``,start:r,end:r+1}),Ue(r+1)},Ge=e=>{let t=e.chip?Lne(M,ie):wne(M,ie,e);P(t.text),I(null),ae(null),ce(!1),e.chip&&U(t=>t.some(t=>Z5(t)===Z5(e.chip))?t:[...t,e.chip]),Ue(t.caret)},Ke=e=>{let t=Z5(e);U(e=>e.filter(e=>Z5(e)!==t))},qe=e=>{let t=S[e];t&&(ge(t.queueId),ve.current=t.text,N(t.text))},Je=e=>{_e.current=pe?``:M,I(null),qe(e)},Ye=(e,t)=>{ge(null),e===`keep`?P(t??M):N(_e.current)},Xe=async()=>{let e=G,t=M.trim();if(!(!e||!t))try{await C(e.queueId,t)===`saved`?Ye(`restore`):(q.info(n(`queueEdit.dispatched`)),Ye(`keep`))}catch{q.error(n(`queueEdit.saveFailed`))}};(0,H.useEffect)(()=>{if(he===null||S.some(e=>e.queueId===he))return;let e=M!==ve.current;w(he)&&q.info(n(`queueEdit.dispatched`)),Ye(e?`keep`:`restore`)},[he,S]);let Ze=()=>{if(xe||!Ae)return;let e=M.trim()||re.map(e=>e.token).join(` `),t={...L.length?{attachmentIds:L.map(e=>e.id)}:{},...re.length?{contextRefs:re.map(pne)}:{}};h(e,L.length||re.length?t:void 0),P(``),ee(j,[]),U([]),ae(null),ce(!1),I(null)},Qe=e=>{if(me[e]===void 0){I(null);return}I(e),P(me[e])};return(0,Y.jsxs)(`div`,{className:`shrink-0`,children:[(0,Y.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:[r===null&&!t&&(0,Y.jsx)(r7,{pinnedProjectId:l,onSelect:e=>void b(e)}),(0,Y.jsx)(`select`,{value:Ce,onChange:e=>void v(e.target.value),"data-agent-interactive":!0,"aria-label":n(`provider.label`),className:`rounded-md border border-border/50 bg-surface/60 px-2 py-1 text-xs text-foreground outline-none hover:bg-surface`,children:Ine.map(e=>(0,Y.jsx)(`option`,{value:e,children:n(`provider.${e}`)},e))}),(0,Y.jsx)(Ene,{provider:Ce,model:r?r.model:d,onSelect:e=>void y(e)}),Fe.length>0&&(0,Y.jsx)(`select`,{value:Le,onChange:e=>void m(e.target.value),"data-agent-interactive":!0,"aria-label":n(`effort.label`),title:n(`effort.label`),className:`rounded-md border border-border/50 bg-surface/60 px-2 py-1 text-xs text-foreground outline-none hover:bg-surface`,children:Fe.map(e=>(0,Y.jsx)(`option`,{value:e,children:n(`effort.${e}`)},e))}),(0,Y.jsx)(`div`,{className:`ml-auto`,children:(0,Y.jsx)(Tne,{level:r?.tier_level??f,onCycle:()=>void _()})})]}),be&&G&&(0,Y.jsxs)(`div`,{"data-testid":`queue-edit-chip`,className:`mb-1 flex items-center gap-1.5 rounded-md border border-accent-highlight/30 bg-accent-highlight/10 px-2 py-1 text-[11px] text-accent-highlight`,children:[(0,Y.jsx)(ws,{className:`h-3 w-3 shrink-0`}),(0,Y.jsx)(`span`,{className:`font-medium`,children:n(`queueEdit.editing`,{n:ye+1,m:S.length})}),(0,Y.jsx)(`span`,{className:`truncate text-foreground/45`,children:n(`queueEdit.hint`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>Ye(`restore`),"aria-label":n(`queueEdit.cancel`),title:n(`queueEdit.cancel`),className:`ml-auto rounded-sm p-0.5 text-foreground/50 hover:bg-muted hover:text-foreground`,children:(0,Y.jsx)(hc,{className:`h-3 w-3`})})]}),pe&&(0,Y.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 px-1 text-[11px] text-foreground/50`,children:[(0,Y.jsx)(Zo,{className:`h-3 w-3`}),n(`history.hint`)]}),L.length>0&&(0,Y.jsx)(`div`,{className:`mb-1.5 flex flex-wrap gap-1.5`,children:L.map(e=>(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-border/60 bg-surface/70 px-2 py-0.5 text-[11px] text-foreground/80`,children:[(0,Y.jsx)(Ss,{className:`h-3 w-3 text-accent-primary`}),(0,Y.jsx)(`span`,{className:`max-w-[160px] truncate`,children:e.filename}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>Be(e.id),"aria-label":n(`close`),className:`rounded-sm hover:bg-muted`,children:(0,Y.jsx)(hc,{className:`h-3 w-3`})})]},e.id))}),D.length>0&&(0,Y.jsx)(`div`,{className:`mb-1.5 flex flex-wrap gap-1.5`,children:D.map((e,t)=>(0,Y.jsx)(Fne,{process:e,accentVariant:je[t%je.length],onKill:e=>void O(e)},e.pid))}),(0,Y.jsxs)(`div`,{className:`relative flex items-end gap-2 rounded-xl border bg-background/60 px-3 py-2 ${be?`border-accent-highlight/50`:pe?`border-accent-info/40`:`border-border/60`}`,onDragOver:e=>{Se&&e.preventDefault()},onDrop:e=>{if(!Se)return;e.preventDefault();let t=Array.from(e.dataTransfer.files);t.length&&ze(t)},children:[ke&&(0,Y.jsx)(Mne,{items:Oe,mode:ie.mode,query:ie.query,activeIndex:W,onActiveIndexChange:oe,onSelect:Ge}),Se&&(0,Y.jsx)(Y.Fragment,{children:(0,Y.jsx)(`input`,{ref:ne,type:`file`,multiple:!0,hidden:!0,onChange:e=>{let t=Array.from(e.target.files??[]);t.length&&ze(t),e.target.value=``}})}),(0,Y.jsx)(Nne,{open:se,canAttach:Se,uploading:te,onToggle:()=>{ce(e=>!e),ae(null)},onClose:()=>ce(!1),onOpenMode:We,onAttachFile:()=>{ce(!1),ne.current?.click()}}),(0,Y.jsxs)(`div`,{className:`flex min-h-[3.25rem] flex-1 flex-wrap items-start gap-1.5`,children:[!be&&(0,Y.jsx)(jne,{chips:re,onRemove:Ke}),(0,Y.jsx)(`textarea`,{ref:V,value:M,autoFocus:e,onChange:e=>{if(be){N(e.target.value);return}pe&&I(null),P(e.target.value),Ve(e.target.value,e.target.selectionStart??e.target.value.length)},onClick:e=>Ve(e.currentTarget.value,e.currentTarget.selectionStart??e.currentTarget.value.length),onKeyDown:e=>{if(e.key===`Tab`&&e.shiftKey){e.preventDefault(),e.stopPropagation(),_();return}if(ke){if(e.key===`ArrowDown`){e.preventDefault(),Oe.length>0&&oe(e=>Math.min(Oe.length-1,e+1));return}if(e.key===`ArrowUp`){e.preventDefault(),Oe.length>0&&oe(e=>Math.max(0,e-1));return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault();let t=Oe[W]??Oe[0];t&&Ge(t);return}if(e.key===`Escape`){e.preventDefault(),ae(null);return}}if(e.key===`Backspace`&&M.length===0&&re.length>0&&!be){e.preventDefault(),U(e=>e.slice(0,-1));return}if(e.key===`Enter`&&!e.shiftKey){e.preventDefault(),be?Xe():Ze();return}if(e.key===`Escape`&&be){e.preventDefault(),e.stopPropagation(),Ye(`restore`);return}let t=e.currentTarget,n=t.selectionStart===0&&t.selectionEnd===0,r=t.selectionStart===M.length&&t.selectionEnd===M.length;if(e.key===`ArrowUp`){if(be){G!==null&&M===G.text&&n&&ye>0&&(e.preventDefault(),qe(ye-1));return}if(S.length>0){n&&(e.preventDefault(),Je(S.length-1));return}!pe&&M===``&&me.length>0?(e.preventDefault(),Qe(me.length-1)):pe&&(e.preventDefault(),Qe(Math.max(0,F-1)));return}if(e.key===`ArrowDown`){if(be){G!==null&&M===G.text&&r&&(e.preventDefault(),ye<S.length-1?qe(ye+1):Ye(`restore`));return}if(S.length>0)return;pe&&(e.preventDefault(),F<me.length-1?Qe(F+1):(I(null),P(``)));return}(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&pe&&I(null)},onPaste:e=>{if(!Se)return;let t=Array.from(e.clipboardData.files);t.length&&(e.preventDefault(),ze(t))},rows:2,disabled:xe,placeholder:re.length>0?``:n(xe?`noProvider.placeholder`:s?`queue.placeholder`:`composerPlaceholder`),"data-agent-interactive":!0,title:be?n(`queueEdit.hint`):pe?n(`history.hint`):void 0,className:`min-h-[3.25rem] max-h-64 min-w-[12rem] flex-1 resize-y bg-transparent text-sm outline-none placeholder:text-foreground/40 disabled:opacity-60 ${pe?`italic text-foreground/50`:`text-foreground`}`})]}),be?(0,Y.jsx)(`button`,{type:`button`,onClick:()=>void Xe(),disabled:xe||!M.trim(),"aria-label":n(`queueEdit.save`),title:n(`queueEdit.save`),className:`rounded-lg bg-accent-highlight p-1.5 text-white transition-opacity hover:opacity-90 disabled:opacity-40`,children:(0,Y.jsx)(to,{className:`h-4 w-4`})}):s&&!Ae?(0,Y.jsx)(`button`,{type:`button`,onClick:()=>void g(),"aria-label":n(`stop`),title:n(`stop`),className:`rounded-lg bg-destructive p-1.5 text-white transition-colors hover:opacity-90`,children:(0,Y.jsx)(tc,{className:`h-4 w-4`,fill:`currentColor`})}):s?(0,Y.jsxs)(`button`,{type:`button`,onClick:Ze,disabled:xe,"aria-label":n(`queue.send`),title:n(`queue.sendHint`),className:`relative rounded-lg bg-accent-info p-1.5 text-white transition-colors hover:opacity-90`,children:[(0,Y.jsx)(Ws,{className:`h-4 w-4`}),(0,Y.jsx)(`span`,{className:`absolute -right-1 -top-1 flex h-3.5 w-3.5 items-center justify-center rounded-full bg-background ring-1 ring-border`,children:(0,Y.jsx)(po,{className:`h-2.5 w-2.5 text-accent-info`})})]}):(0,Y.jsx)(`button`,{type:`button`,onClick:Ze,disabled:xe||!Ae,"aria-label":n(`send`),className:`rounded-lg bg-accent-primary p-1.5 text-white transition-opacity disabled:opacity-40`,children:(0,Y.jsx)(Ws,{className:`h-4 w-4`})})]}),we&&(0,Y.jsx)(Dne,{projectId:we})]})}var Rne=e=>e===`running`||e===`queued`;function zne(e){let t=Math.max(0,Math.floor(e/1e3));if(t<60)return`${t}s`;let n=Math.floor(t/60);return n<60?`${n}m${String(t%60).padStart(2,`0`)}s`:`${Math.floor(n/60)}h ${n%60}m`}function Bne(){try{return df()}catch{return null}}var d7=e=>{if(!e)return null;let t=new Date(e).getTime();return Number.isFinite(t)?t:null};function Vne(e,t,n){let{live:r}=n,[i,a]=(0,H.useState)(!1),[s,c]=(0,H.useState)(null),[l,u]=(0,H.useState)(null),[d,f]=(0,H.useState)(null),[p,m]=(0,H.useState)(null),[h,g]=(0,H.useState)(null),[_,v]=(0,H.useState)(!1),[y,b]=(0,H.useState)(null),[x,S]=(0,H.useState)(()=>Date.now());(0,H.useEffect)(()=>{let n=!1;return fetch(`${o}/api/projects/${e}/jobs/${t}`).then(e=>e.ok?e.json():null).then(e=>{if(n)return;let t=e?.job;t&&(c(typeof t.status==`string`?t.status:null),u(d7(t.started_at)),f(d7(t.finished_at)),typeof t.total_cost_usd==`number`&&m(t.total_cost_usd),typeof t.num_turns==`number`&&g(t.num_turns),v(t.loopPaused===!0),b(typeof t.loopPauseReason==`string`?t.loopPauseReason:null)),a(!0)}).catch(()=>{n||a(!0)}),()=>{n=!0}},[e,t,r]);let C=Rne(s)&&d===null,w=Bne(),T=(0,H.useId)();return(0,H.useEffect)(()=>{if(!w||!r)return;let e=`run-vitals-${t}-${T}`;return w.registerHandler(e,e=>{let n=e;if(n?.type===`loop.run_paused`&&n.loopRunId===t){v(!0),b(typeof n.reason==`string`?n.reason:null),c(`running`),f(null);return}if((n?.type===`loop.run_resumed`||n?.type===`loop.run_completed`)&&n.loopRunId===t){v(!1),b(null);return}n?.jobId===t&&(n.type===`job.turn_done`?(typeof n.totals?.total_cost_usd==`number`&&m(n.totals.total_cost_usd),typeof n.totals?.num_turns==`number`&&g(n.totals.num_turns)):n.type===`job.finalized`&&(typeof n.totals?.total_cost_usd==`number`&&m(n.totals.total_cost_usd),typeof n.totals?.num_turns==`number`&&g(n.totals.num_turns),typeof n.status==`string`&&c(n.status),v(!1),b(null),f(d7(n.timestamp)??Date.now())))}),()=>w.unregisterHandler(e)},[w,r,t,T]),(0,H.useEffect)(()=>{if(!r||!C||l===null)return;let e=setInterval(()=>S(Date.now()),1e3);return()=>clearInterval(e)},[r,C,l]),{status:s,paused:_,pausedReason:y,running:C,elapsedMs:l===null?null:Math.max(0,(d??x)-l),costUsd:p,numTurns:h,loaded:i}}function Hne(e){return e.command.startsWith(`loop:`)?`loop-run`:e.interactive?`interactive`:`job`}var Une=15e3;function Wne(e){if(typeof AbortSignal<`u`&&typeof AbortSignal.timeout==`function`)return AbortSignal.timeout(e)}async function f7(e){let{projectId:t,jobId:n,timeoutMs:r=Une}=e,i=t?`${o}/api/projects/${t}`:af(),a;try{a=await fetch(`${i}/jobs/${n}`,{method:`DELETE`,signal:Wne(r)})}catch(e){let t=e;return{ok:!1,error:t?.name===`TimeoutError`||t?.name===`AbortError`?`Request timed out after ${Math.round(r/1e3)}s`:t?.message||String(e),httpStatus:null}}if(a.ok){let e=`canceled`;try{let t=await a.json();t&&typeof t.status==`string`&&(e=t.status)}catch{}return{ok:!0,status:e}}let s=typeof a.status==`number`?a.status:null,c=s==null?``:` (HTTP ${s})`,l=``;try{typeof a.text==`function`?l=await a.text():typeof a.json==`function`&&(l=JSON.stringify(await a.json()))}catch{}let u=l.slice(0,200).trim();try{let e=JSON.parse(l);e&&typeof e.error==`string`&&e.error&&(u=e.error)}catch{}let d=typeof a.statusText==`string`?a.statusText:``;return{ok:!1,error:u?`${u}${c}`:`HTTP ${s??`?`}${d?` ${d}`:``}`,httpStatus:s}}var Gne=(0,H.lazy)(()=>a(()=>import(`./JobDetailModal-CJI7qRkm.js`).then(e=>({default:e.JobDetailModal})),__vite__mapDeps([27,1,28,29,30,31]))),Kne={building:Ho,on_review:Ho,pr_draft:Go,pr_ready:Go,implementation_failed:lc,pr_failed:lc,merged:Wo,discarded:lo},qne={building:`text-accent-primary/70`,on_review:`text-accent-primary`,pr_draft:`text-accent-info`,pr_ready:`text-accent-info`,implementation_failed:`text-destructive`,pr_failed:`text-destructive`,merged:`text-accent-success`,discarded:`text-foreground/40`};function Jne(e){let t=/\/pull\/(\d+)/.exec(e);return t?`#${t[1]}`:null}function Yne({projectId:e,runId:t,ticketLabel:n,live:r,onOpen:i,onVitals:a}){let{t:o}=K(`agent`),s=Vne(e,t,{live:r}),c=n??t.slice(0,8),l=s.elapsedMs==null?null:zne(s.elapsedMs),u=s.costUsd!=null&&s.costUsd>0,d=(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`opacity-40`,children:`·`});return(0,H.useEffect)(()=>{a?.(t,{paused:s.paused,pausedReason:s.pausedReason})},[a,t,s.paused,s.pausedReason]),(0,Y.jsxs)(`button`,{type:`button`,"data-agent-interactive":!0,"data-testid":`pr-run-log-chip`,onClick:e=>{e.stopPropagation(),i(t)},title:o(`prCard.viewLog`,{ref:c}),"aria-label":o(`prCard.viewLog`,{ref:c}),className:X(`inline-flex max-w-full cursor-pointer items-center gap-1 rounded-full border px-1.5 py-px align-baseline font-mono text-[0.82em] leading-[1.45] transition-all`,s.paused?`border-accent-warning/45 bg-accent-warning/10 text-accent-warning hover:-translate-y-px hover:border-accent-warning/65 hover:bg-accent-warning/15 hover:shadow-sm`:`border-accent-info/35 bg-accent-info/10 text-accent-info hover:-translate-y-px hover:border-accent-info/60 hover:bg-accent-info/15 hover:shadow-sm`),children:[(s.paused||s.running&&r)&&(0,Y.jsx)(`span`,{"aria-hidden":!0,className:X(`h-1.5 w-1.5 shrink-0 animate-pulse rounded-full`,s.paused?`bg-accent-warning`:`bg-accent-info`)}),(0,Y.jsx)(`span`,{className:`max-w-[160px] truncate`,children:c}),d,(0,Y.jsx)(Hs,{className:`h-3 w-3 shrink-0 opacity-70`}),l&&(0,Y.jsxs)(Y.Fragment,{children:[d,(0,Y.jsx)(`span`,{className:`tabular-nums`,"aria-label":o(`prCard.runElapsedAria`,{elapsed:l}),children:l})]}),u&&(0,Y.jsxs)(Y.Fragment,{children:[d,(0,Y.jsxs)(`span`,{className:`tabular-nums`,"aria-label":o(`prCard.runCostAria`,{cost:`$${s.costUsd.toFixed(2)}`}),children:[`$`,s.costUsd.toFixed(2)]})]})]})}function p7({envelope:e}){let{t}=K(`agent`),{projects:n}=gm(),{openWebView:r,canOpenWebView:i}=DH(),{openRef:a}=W8(),[o,s]=(0,H.useState)(null),[c,l]=(0,H.useState)(!1),[u,d]=(0,H.useState)(!1),f=(0,H.useRef)(null),[p,m]=(0,H.useState)(null),[h,g]=(0,H.useState)({}),[_,v]=(0,H.useState)(null),{decision:y,prUrl:b,prState:x}=e,S=n.find(t=>t.id===e.projectId)?.name??e.projectId,C=y===`pr_draft`&&!b,w=y===`building`&&x===`pr-created`&&!!e.branch,T=e.prNumber?`#${e.prNumber}`:b?Jne(b):null,E=y===`merged`||y===`discarded`;(0,H.useEffect)(()=>{s(null),d(!1)},[y,b]),(0,H.useEffect)(()=>()=>{f.current&&clearTimeout(f.current)},[]);let D=(0,H.useCallback)((e,t)=>{g(n=>{let r=n[e];return r?.paused===t.paused&&r?.pausedReason===t.pausedReason?n:{...n,[e]:t}})},[]),O=async n=>{if(!_){v(n);try{let r=await f7({projectId:e.projectId,jobId:n,kind:`loop-run`});r.ok?q.info(t(`prCard.stopExecutionSent`)):q.error(t(`prCard.stopExecutionFailed`),{description:r.error})}finally{v(null)}}},k=async n=>{if(!c){s(n);try{let r=await WY(e.projectId,{prDeliveryId:e.prDeliveryId,action:n,expectedDecision:y});r.kind===`stale`?q.info(t(`prCard.alreadyResolved`)):r.kind===`blocked`?q.warning(r.reason===`dirty`?t(`prCard.mergeLocalBlockedDirty`,{base:r.base||e.baseBranch}):t(`prCard.mergeLocalBlockedBranch`,{base:r.base||e.baseBranch,current:r.current??`?`})):r.kind===`failed`?q.error(t(`prCard.actionFailed`),{description:r.detail}):n===`poll-merge`&&!r.merged?q.info(t(`prCard.notMergedYet`)):n===`merge-local`&&r.kind===`ok`&&r.decision===`merged`&&q.success(t(`prCard.mergedLocally`,{base:e.baseBranch}))}catch(e){q.error(t(`prCard.actionFailed`),{description:e instanceof Error?e.message:void 0})}finally{s(null)}}},A=async()=>{if(!(o||c)){l(!0);try{let n=await GY(e.projectId,e.prDeliveryId);n.kind===`ok`?q.success(t(`prCard.checkoutSuccess`,{branch:e.branch??``})):q.warning(t(`prCard.checkoutFailed`),{description:n.detail})}catch(e){q.error(t(`prCard.checkoutFailed`),{description:e instanceof Error?e.message:void 0})}finally{l(!1)}}},j=()=>{if(!u){d(!0),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>d(!1),3e3);return}f.current&&clearTimeout(f.current),d(!1),k(`discard`)},M=(e,t)=>{i&&(e.preventDefault(),e.stopPropagation(),r(t))},N=e.ticketIds.length>0&&(0,Y.jsx)(Y.Fragment,{children:e.ticketIds.map(t=>(0,Y.jsxs)(M5,{refTarget:{kind:`ticket`,ticketId:t},onOpen:t=>void a(e.projectId,t),children:[`#`,t]},t))}),P=e.runIds??[],F=t=>P.length===1&&e.ticketIds.length>1?e.ticketIds.map(e=>`#${e}`).join(` `):e.ticketIds[t]==null?null:`#${e.ticketIds[t]}`,I=P.find(e=>h[e]?.paused)??null,L=I?h[I]?.pausedReason??null:null,R=P.length>0&&(0,Y.jsx)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-1.5`,"data-testid":`pr-run-log-chips`,children:P.map((t,n)=>(0,Y.jsx)(Yne,{projectId:e.projectId,runId:t,ticketLabel:F(n),live:y===`building`,onOpen:m,onVitals:D},t))}),z=y===`building`&&I!==null,ee=I?F(P.indexOf(I))??I.slice(0,8):null,te=p&&(0,Y.jsx)(H.Suspense,{fallback:null,children:(0,Y.jsx)(Gne,{jobId:p,projectId:e.projectId,onClose:()=>m(null)})});if(y===`building`)return(0,Y.jsxs)(`div`,{"data-testid":`agent-pr-decision-card`,className:`rounded-xl border border-border/60 bg-card/80 px-3.5 py-2.5 text-xs text-foreground/60 shadow-lg backdrop-blur-xl`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[z?(0,Y.jsx)(lc,{className:`h-3.5 w-3.5 text-accent-warning`}):w?(0,Y.jsx)(Go,{className:`h-3.5 w-3.5 text-accent-info`}):(0,Y.jsx)(cs,{className:`h-3.5 w-3.5 animate-spin text-accent-primary/70`}),(0,Y.jsx)(`span`,{className:X(!w&&!z&&`animate-pulse`,z&&`text-accent-warning`),children:t(z?`prCard.title.paused`:w?`prCard.title.buildingExistingPr`:`prCard.title.building`)})]}),N&&(0,Y.jsx)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-1.5 pl-[22px]`,children:N}),w&&(0,Y.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-1.5 pl-[22px]`,children:[b?(0,Y.jsxs)(`a`,{href:b,target:`_blank`,rel:`noreferrer`,onClick:e=>M(e,b),title:b,"data-agent-interactive":!0,className:`inline-flex items-center gap-1 rounded-full border border-accent-info/40 bg-accent-info/10 px-2 py-0.5 font-mono text-[11px] text-accent-info transition-colors hover:border-accent-info/60 hover:bg-accent-info/15`,children:[(0,Y.jsx)(Go,{className:`h-3 w-3`}),T??t(`prCard.openPr`),(0,Y.jsx)(Oo,{className:`h-2.5 w-2.5 opacity-60`})]}):(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-accent-info/40 bg-accent-info/10 px-2 py-0.5 font-mono text-[11px] text-accent-info`,children:[(0,Y.jsx)(Go,{className:`h-3 w-3`}),T??t(`prCard.existingPr`)]}),(0,Y.jsxs)(`span`,{title:t(`git.branch`),className:`inline-flex min-w-0 max-w-full items-center gap-1 rounded-full border border-border/60 bg-surface/60 px-2 py-0.5 font-mono text-[11px] text-foreground/70`,children:[(0,Y.jsx)(Ho,{className:`h-3 w-3 shrink-0 text-accent-primary/70`}),(0,Y.jsx)(`span`,{className:`truncate`,children:e.branch})]})]}),z&&I&&(0,Y.jsxs)(`div`,{className:`mt-2 flex min-w-0 flex-wrap items-center gap-1.5 rounded-md border border-accent-warning/35 bg-accent-warning/10 px-2 py-1.5 text-[11px] text-accent-warning`,"data-testid":`pr-run-paused-actions`,children:[(0,Y.jsx)(lc,{className:`h-3.5 w-3.5 shrink-0`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,title:L??void 0,children:[ee?t(`prCard.pausedForRun`,{ref:ee}):t(`prCard.paused`),L?`: ${L}`:``]}),(0,Y.jsxs)(`button`,{type:`button`,"data-agent-interactive":!0,onClick:e=>{e.stopPropagation(),m(I)},className:`inline-flex items-center gap-1 rounded-md border border-accent-warning/40 bg-surface/70 px-2 py-0.5 font-medium text-accent-warning transition-colors hover:bg-accent-warning/15`,children:[(0,Y.jsx)(Ds,{className:`h-3 w-3`}),t(`prCard.resume`)]}),(0,Y.jsxs)(`button`,{type:`button`,"data-agent-interactive":!0,disabled:_===I,onClick:e=>{e.stopPropagation(),O(I)},className:`inline-flex items-center gap-1 rounded-md border border-destructive/40 bg-destructive/10 px-2 py-0.5 font-medium text-destructive transition-colors hover:bg-destructive/15 disabled:cursor-default disabled:opacity-60`,children:[_===I?(0,Y.jsx)(cs,{className:`h-3 w-3 animate-spin`}):(0,Y.jsx)(tc,{className:`h-3 w-3`}),t(`prCard.stopExecution`)]})]}),R&&(0,Y.jsx)(`div`,{className:`pl-[22px]`,children:R}),(0,Y.jsx)(`p`,{className:`mt-1 pl-[22px] text-[11px] leading-4 text-foreground/40`,children:t(w?`prCard.buildingExistingPrHint`:`prCard.buildingHint`)}),te]});let B=Kne[y],ne=t(C?`prCard.title.pr_draft_degraded`:`prCard.title.${y}`),V=X(`inline-flex items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs transition-colors disabled:cursor-default disabled:opacity-60`,u?`border-destructive/50 bg-destructive/10 font-medium text-destructive hover:bg-destructive/20`:`border-border/60 text-foreground/70 hover:border-destructive/40 hover:bg-destructive/10 hover:text-destructive`),re=o!==null||c,U=(0,Y.jsx)(cs,{className:`h-3 w-3 animate-spin`}),ie=(e,t)=>(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>void k(e),disabled:re,"data-agent-interactive":!0,className:`inline-flex items-center gap-1.5 rounded-md bg-accent-primary px-2.5 py-1 text-xs font-medium text-white transition-colors hover:bg-accent-primary/90 disabled:cursor-default disabled:opacity-60`,children:[o===e&&U,t]}),ae=b&&e.branch&&(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>void A(),disabled:re,"data-testid":`agent-pr-checkout`,"data-agent-interactive":!0,title:t(`prCard.checkoutTooltip`,{branch:e.branch}),className:`inline-flex items-center gap-1 rounded-md border border-border/60 px-2 py-1 text-[11px] font-medium text-foreground/70 transition-colors hover:border-accent-primary/40 hover:bg-accent-primary/10 disabled:pointer-events-none disabled:opacity-50`,children:[c?U:(0,Y.jsx)(Ho,{className:`h-3 w-3`}),t(`prCard.checkout`)]}),W=(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>void k(`merge-local`),disabled:re,"data-testid":`agent-pr-merge-local`,"data-agent-interactive":!0,title:t(`prCard.mergeLocalTooltip`,{base:e.baseBranch}),className:`inline-flex items-center gap-1 rounded-md border border-accent-success/40 bg-accent-success/10 px-2 py-1 text-[11px] font-medium text-accent-success transition-colors hover:bg-accent-success/20 disabled:pointer-events-none disabled:opacity-50`,children:[o===`merge-local`&&U,t(`prCard.mergeLocal`)]}),oe=(0,Y.jsxs)(`button`,{type:`button`,onClick:j,disabled:re,"data-agent-interactive":!0,className:V,children:[o===`discard`&&U,t(u?`prCard.confirmDiscard`:`prCard.discard`)]}),se=b&&(0,Y.jsxs)(`a`,{href:b,target:`_blank`,rel:`noreferrer`,onClick:e=>M(e,b),title:b,"data-agent-interactive":!0,className:`inline-flex items-center gap-1 rounded-full border border-border/60 bg-surface/60 px-2 py-0.5 font-mono text-[11px] text-accent-info transition-colors hover:border-accent-info/50 hover:bg-accent-info/10`,children:[(0,Y.jsx)(Go,{className:`h-3 w-3`}),T??t(`prCard.openPr`),(0,Y.jsx)(Oo,{className:`h-2.5 w-2.5 opacity-60`})]});return(0,Y.jsxs)(`div`,{"data-testid":`agent-pr-decision-card`,className:X(`rounded-xl border border-border/60 bg-card/80 px-3.5 py-3 shadow-lg backdrop-blur-xl`,y===`merged`&&`border-accent-success/30`,y===`discarded`&&`opacity-70`),children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(B,{className:X(`h-4 w-4 shrink-0`,qne[y])}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-foreground`,children:ne}),(0,Y.jsx)(`span`,{className:`max-w-[140px] shrink-0 truncate text-[11px] text-foreground/50`,title:S,children:S}),(0,Y.jsx)(`span`,{className:`shrink-0 rounded-full border border-border/60 bg-surface/60 px-2 py-0.5 text-[10px] font-medium uppercase tracking-wide text-foreground/60`,children:t(`prCard.rail`,{index:e.railIndex+1})})]}),(0,Y.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5`,children:[(0,Y.jsxs)(`span`,{title:t(`prCard.base`),className:`inline-flex items-center gap-1 rounded-full border border-border/60 bg-surface/60 px-2 py-0.5 font-mono text-[11px] text-foreground/70`,children:[(0,Y.jsx)(Ho,{className:`h-3 w-3 text-accent-primary/70`}),`→ `,e.baseBranch]}),(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-border/60 bg-surface/60 px-2 py-0.5 text-[11px] text-foreground/70`,children:[(0,Y.jsx)(oc,{className:`h-3 w-3 text-accent-secondary/80`}),t(`prCard.specCount`,{count:e.ticketIds.length})]}),N,se]}),R,!E&&!b&&(x===`pushed`||x===`local-only`)&&(0,Y.jsxs)(`p`,{className:`mt-2 flex items-start gap-1.5 text-[11px] leading-4 text-accent-warning`,children:[(0,Y.jsx)(lc,{className:`mt-px h-3 w-3 shrink-0`}),t(x===`local-only`?`prCard.degraded.localOnly`:`prCard.degraded.pushed`)]}),(0,Y.jsx)(H3,{mode:`wait`,initial:!1,children:(0,Y.jsxs)(V8.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.2,ease:`easeOut`},className:`mt-2.5`,children:[y===`on_review`&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[ie(`create-pr`,t(`prCard.createPr`)),W,oe]}),y===`pr_draft`&&!C&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[ae,ie(`publish`,t(`prCard.publish`)),oe]}),C&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[ie(`create-pr`,t(`prCard.retryPr`)),W,oe]}),y===`pr_ready`&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[ae,ie(`poll-merge`,t(`prCard.checkMerge`)),oe]}),y===`pr_failed`&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[ae,ie(`create-pr`,t(`prCard.retry`)),!b&&W,oe]}),y===`implementation_failed`&&(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[(0,Y.jsxs)(`p`,{className:`flex items-start gap-1.5 text-[11px] leading-4 text-destructive`,children:[(0,Y.jsx)(lc,{className:`mt-px h-3 w-3 shrink-0`}),t(`prCard.implementationFailedNote`)]}),(0,Y.jsx)(`div`,{className:`flex items-center gap-1.5`,children:oe})]}),y===`merged`&&(0,Y.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs font-medium text-accent-success`,children:[(0,Y.jsx)(co,{className:`h-3.5 w-3.5`}),t(`prCard.mergedNote`)]}),y===`discarded`&&(0,Y.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs text-foreground/50`,children:[(0,Y.jsx)(lo,{className:`h-3.5 w-3.5`}),t(`prCard.discardedNote`)]})]},`${y}-${b??``}`)}),te]})}var Xne={building:`border-accent-primary/40 bg-accent-primary/10 text-accent-primary`,on_review:`border-accent-primary/40 bg-accent-primary/10 text-accent-primary`,pr_draft:`border-accent-info/40 bg-accent-info/10 text-accent-info`,pr_ready:`border-accent-info/40 bg-accent-info/10 text-accent-info`,implementation_failed:`border-destructive/40 bg-destructive/10 text-destructive`,pr_failed:`border-destructive/40 bg-destructive/10 text-destructive`,merged:`border-accent-success/40 bg-accent-success/10 text-accent-success`,discarded:`border-border/60 bg-surface/60 text-foreground/50`};function m7({decision:e}){let{t}=K(`agent`);return(0,Y.jsx)(`span`,{"data-testid":`pr-decision-pill`,className:X(`inline-flex shrink-0 items-center rounded-full border px-1.5 py-px text-[10px] font-medium uppercase tracking-wide`,Xne[e]),children:t(`prCard.pinned.state.${e}`)})}var h7=e=>`specrails-desktop:agent-pr-dock-collapsed:${e}`,g7=e=>`specrails-desktop:agent-pr-dock-card-collapsed:${e}`;function _7(e){try{return sessionStorage.getItem(h7(e))===`1`}catch{return!1}}function Zne(e,t){try{t?sessionStorage.setItem(h7(e),`1`):sessionStorage.removeItem(h7(e))}catch{}}function v7(e){try{let t=sessionStorage.getItem(g7(e)),n=t?JSON.parse(t):[];return new Set(Array.isArray(n)?n.filter(e=>typeof e==`string`):[])}catch{return new Set}}function Qne(e,t){try{t.size===0?sessionStorage.removeItem(g7(e)):sessionStorage.setItem(g7(e),JSON.stringify([...t]))}catch{}}function $ne({pinned:e,conversationId:t,inline:n}){let{t:r}=K(`agent`),[i,a]=(0,H.useState)(()=>_7(t)),[o,s]=(0,H.useState)(()=>v7(t));if((0,H.useEffect)(()=>{a(_7(t)),s(v7(t))},[t]),e.length===0)return null;let c=e[e.length-1],l=e=>{Zne(t,e),a(e)},u=e=>{s(n=>{let r=new Set(n);return r.has(e)?r.delete(e):r.add(e),Qne(t,r),r})},d=e=>{let t=r(`prCard.rail`,{index:e.railIndex+1}),n=e.ticketIds.map(e=>`#${e}`).join(` `);return n?`${t} · ${n}`:t};return(0,Y.jsx)(V8.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,y:8},transition:{duration:.2,ease:`easeOut`},"data-testid":`agent-pr-pinned-dock`,className:X(`shrink-0`,n?`px-4 pb-2`:`px-3 pb-2`),children:(0,Y.jsx)(`div`,{className:X(n&&`mx-auto w-full max-w-[680px]`),children:i?(0,Y.jsxs)(`button`,{type:`button`,"data-testid":`agent-pr-dock-expand`,"data-agent-interactive":!0,onClick:()=>l(!1),"aria-label":r(`prCard.pinned.expand`),title:r(`prCard.pinned.expand`),className:`flex w-full items-center gap-2 rounded-xl border border-border/60 bg-card/80 px-3 py-1.5 text-xs text-foreground/70 shadow-lg backdrop-blur-xl transition-colors hover:border-accent-primary/40 hover:bg-surface/60`,children:[(0,Y.jsx)(Ts,{className:`h-3.5 w-3.5 shrink-0 text-accent-primary/70`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:r(`prCard.pinned.collapsed`,{count:e.length})}),(0,Y.jsx)(m7,{decision:c.envelope.decision}),(0,Y.jsx)(ao,{className:`h-3.5 w-3.5 shrink-0 opacity-60`})]}):(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between px-1`,children:[(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] font-medium uppercase tracking-wide text-foreground/45`,children:[(0,Y.jsx)(Ts,{className:`h-3 w-3 text-accent-primary/60`}),r(`prCard.pinned.label`),e.length>1&&(0,Y.jsx)(`span`,{className:`rounded-full border border-border/60 bg-surface/60 px-1.5 py-px text-[9px] tabular-nums text-foreground/55`,children:e.length})]}),(0,Y.jsx)(`button`,{type:`button`,"data-testid":`agent-pr-dock-collapse`,"data-agent-interactive":!0,onClick:()=>l(!0),"aria-label":r(`prCard.pinned.collapse`),title:r(`prCard.pinned.collapse`),className:`rounded p-0.5 text-foreground/45 transition-colors hover:bg-surface hover:text-foreground`,children:(0,Y.jsx)(no,{className:`h-3.5 w-3.5`})})]}),(0,Y.jsx)(`div`,{"data-testid":`agent-pr-dock-stack`,className:`max-h-[45vh] space-y-1.5 overflow-y-auto overscroll-contain`,children:e.map(e=>{let t=e.envelope.prDeliveryId,n=o.has(t);return(0,Y.jsxs)(`div`,{"data-testid":`agent-pr-dock-card`,className:`space-y-1`,children:[(0,Y.jsxs)(`button`,{type:`button`,"data-testid":`agent-pr-dock-card-toggle`,"data-agent-interactive":!0,onClick:()=>u(t),"aria-expanded":!n,"aria-label":r(n?`prCard.pinned.expandCard`:`prCard.pinned.collapseCard`),title:r(n?`prCard.pinned.expandCard`:`prCard.pinned.collapseCard`),className:X(`flex w-full items-center gap-2 rounded-lg border px-2.5 py-1 text-[11px] text-foreground/70 transition-colors`,n?`border-border/60 bg-card/80 shadow backdrop-blur-xl hover:border-accent-primary/40 hover:bg-surface/70`:`border-transparent bg-transparent hover:bg-surface/50`),children:[(0,Y.jsx)(Go,{className:`h-3 w-3 shrink-0 text-accent-primary/70`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left font-medium`,children:d(e.envelope)}),(0,Y.jsx)(m7,{decision:e.envelope.decision}),n?(0,Y.jsx)(ao,{className:`h-3 w-3 shrink-0 opacity-60`}):(0,Y.jsx)(no,{className:`h-3 w-3 shrink-0 opacity-60`})]}),!n&&(0,Y.jsx)(p7,{envelope:e.envelope})]},e.messageId)})})]})})})}function ere(e){return e?e.charAt(0).toUpperCase()+e.slice(1):`Unknown`}function y7(e,t,n,r){let i=e.title?.trim()||`Untitled mission`,a=r?.exportedAt??new Date().toISOString(),o=[`Mission: ${i}`,`Mission ID: ${e.id}`];return n?.name&&o.push(`Project: ${n.name}`),n?.path&&o.push(`Project path: ${n.path}`),o.push(`Exported at: ${a}`,``,`Messages:`),t.length===0?(o.push(`No messages loaded.`),o.join(`
142
+ `)){if(!v5.test(n))continue;let e=new RegExp(m5,`g`),r;for(;(r=e.exec(n))!==null;)t.add(r[0].toLowerCase())}return t}var b5=/[\w#&$-]/,x5=/[\w-]/;function S5(e,t){let n=/\b(?:PR|pull request)\s*#?(\d{1,10})\b/gi,r;for(;(r=n.exec(e))!==null;){let n=e[r.index-1],i=e[r.index+r[0].length];if(n!==void 0&&b5.test(n)||i!==void 0&&x5.test(i))continue;let a=Number.parseInt(r[1],10);!Number.isInteger(a)||a<=0||t.push({start:r.index,end:r.index+r[0].length,segment:{kind:`pull-request`,prNumber:a,label:`PR #${a}`}})}let i=/https?:\/\/[^\s<>)]+\/pull\/(\d{1,10})(?:[/?#][^\s<>)]*)?/gi,a;for(;(a=i.exec(e))!==null;){let e=Number.parseInt(a[1],10);if(!Number.isInteger(e)||e<=0)continue;let n=a[0].replace(/[.,;:!?…]+$/u,``);t.push({start:a.index,end:a.index+n.length,segment:{kind:`pull-request`,prNumber:e,prUrl:n,label:`PR #${e}`}})}}function C5(e){if(!e)return null;let t=/^https?:\/\/[^\s<>)]+\/pull\/(\d{1,10})(?:[/?#][^\s<>)]*)?$/i.exec(e);if(!t)return null;let n=Number.parseInt(t[1],10);return!Number.isInteger(n)||n<=0?null:{prNumber:n,prUrl:e}}function w5(e,t){let n=/#(\d{1,6})/g,r;for(;(r=n.exec(e))!==null;){let n=e[r.index-1],i=r.index+r[0].length,a=e[i];if(n!==void 0&&b5.test(n)||a!==void 0&&x5.test(a))continue;let o=Number.parseInt(r[1],10);if(!Number.isInteger(o)||o<=0)continue;let s=i,c=`#${o}`,l=/^([ \t]*[—–][ \t]*)([^\n#]{1,80})/.exec(e.slice(s));if(l){let e=l[2].replace(/[\s.,;:!?…]+$/u,``);e.length>0&&(s+=l[1].length+e.length,c=`#${o} — ${e}`)}t.push({start:r.index,end:s,segment:{kind:`ticket`,ticketId:o,label:c}})}}function T5(e,t,n){let r=new RegExp(m5,`g`),i;for(;(i=r.exec(e))!==null;){let r=e[i.index-1],a=e[i.index+i[0].length];if(r!==void 0&&b5.test(r)||a!==void 0&&x5.test(a))continue;let o=i[0].toLowerCase();t.has(o)&&n.push({start:i.index,end:i.index+i[0].length,segment:{kind:`job`,jobId:o,label:`${o.slice(0,8)}…`}})}}function E5(e,t){let n=new RegExp(g5,`g`),r;for(;(r=n.exec(e))!==null;){let n=e[r.index-1],i=e[r.index+r[0].length];n!==void 0&&b5.test(n)||i!==void 0&&x5.test(i)||t.push({start:r.index,end:r.index+r[0].length,segment:{kind:`loop`,loopId:r[0],label:r[0]}})}}function D5(e,t){let n=[];if(S5(e,n),w5(e,n),T5(e,t,n),E5(e,n),n.length===0)return[{kind:`text`,text:e}];n.sort((e,t)=>e.start-t.start);let r=[],i=0;for(let t of n)t.start<i||(t.start>i&&r.push({kind:`text`,text:e.slice(i,t.start)}),r.push(t.segment),i=t.end);return i<e.length&&r.push({kind:`text`,text:e.slice(i)}),r}var O5=new Set([`code`,`inlineCode`,`link`,`linkReference`,`image`,`imageReference`,`definition`,`html`]);function k5(e){return e.kind===`text`?{type:`text`,value:e.text}:{type:`link`,url:f5(e.kind===`ticket`?{kind:`ticket`,ticketId:e.ticketId}:e.kind===`pull-request`?{kind:`pull-request`,prNumber:e.prNumber,prUrl:e.prUrl}:e.kind===`loop`?{kind:`loop`,loopId:e.loopId}:{kind:`job`,jobId:e.jobId}),children:[{type:`text`,value:e.label}]}}function A5(e,t){let n=e.children;if(n)for(let e=n.length-1;e>=0;e--){let r=n[e];if(r.type===`inlineCode`&&typeof r.value==`string`){let i=r.value.trim();if(h5.test(i)&&t.has(i.toLowerCase())){let t=i.toLowerCase();n.splice(e,1,k5({kind:`job`,jobId:t,label:`${t.slice(0,8)}…`}))}else _5.test(i)&&n.splice(e,1,k5({kind:`loop`,loopId:i,label:i}));continue}if(r.type===`link`&&typeof r.url==`string`){let t=C5(r.url);t&&n.splice(e,1,k5({kind:`pull-request`,prNumber:t.prNumber,prUrl:t.prUrl,label:`PR #${t.prNumber}`}));continue}if(!O5.has(r.type))if(r.type===`text`&&typeof r.value==`string`){let i=D5(r.value,t);i.some(e=>e.kind!==`text`)&&n.splice(e,1,...i.map(k5))}else A5(r,t)}}function j5(){return(e,t)=>{A5(e,y5(t==null?``:String(t)))}}function M5({refTarget:e,onOpen:t,children:n}){let{t:r}=K(`agent`),i=e.kind===`ticket`?r(`refs.openTicket`,{id:e.ticketId}):e.kind===`pull-request`?r(`refs.openPullRequest`,{id:e.prNumber}):e.kind===`loop`?r(`refs.openLoop`,{id:e.loopId}):r(`refs.openJob`,{id:e.jobId.slice(0,8)}),a=e.kind===`ticket`?oc:e.kind===`pull-request`?Go:e.kind===`loop`?Is:Xa;return(0,Y.jsxs)(`button`,{type:`button`,"data-agent-interactive":!0,"data-testid":`agent-ref-chip`,"data-ref-kind":e.kind,onClick:n=>{n.stopPropagation(),t(e)},title:i,"aria-label":i,className:X(`inline-flex max-w-full cursor-pointer items-center gap-1 rounded-full border px-1.5 align-baseline font-mono text-[0.82em] leading-[1.45] transition-all`,`hover:-translate-y-px hover:shadow-sm`,e.kind===`ticket`?`border-accent-primary/35 bg-accent-primary/10 text-accent-primary hover:border-accent-primary/60 hover:bg-accent-primary/15`:e.kind===`pull-request`?`border-accent-success/35 bg-accent-success/10 text-accent-success hover:border-accent-success/60 hover:bg-accent-success/15`:e.kind===`loop`?`border-accent-highlight/35 bg-accent-highlight/10 text-accent-highlight hover:border-accent-highlight/60 hover:bg-accent-highlight/15`:`border-accent-info/35 bg-accent-info/10 text-accent-info hover:border-accent-info/60 hover:bg-accent-info/15`),children:[(0,Y.jsx)(a,{className:`h-3 w-3 shrink-0 opacity-70`}),(0,Y.jsx)(`span`,{className:`max-w-[280px] truncate`,children:n})]})}var N5=X(`text-sm leading-7 text-foreground`,`[&_p]:my-3.5 [&_p:first-child]:mt-0 [&_p:last-child]:mb-0`,`[&_h1]:mt-5 [&_h1]:mb-2 [&_h1]:text-base [&_h1]:font-semibold`,`[&_h2]:mt-5 [&_h2]:mb-2 [&_h2]:text-[15px] [&_h2]:font-semibold`,`[&_h3]:mt-4 [&_h3]:mb-1.5 [&_h3]:text-sm [&_h3]:font-semibold`,`[&_strong]:font-semibold [&_strong]:text-foreground`,`[&_em]:italic`,`[&_a]:text-accent-info [&_a]:underline [&_a]:underline-offset-2`,`[&_ul]:my-3 [&_ul]:list-disc [&_ul]:pl-5 [&_ol]:my-3 [&_ol]:list-decimal [&_ol]:pl-5 [&_li]:my-1`,`[&_code]:rounded [&_code]:bg-surface [&_code]:px-1 [&_code]:py-0.5 [&_code]:font-mono [&_code]:text-[0.85em] [&_code]:text-accent-info`,`[&_pre]:my-2 [&_pre]:overflow-x-auto [&_pre]:rounded-lg [&_pre]:bg-surface [&_pre]:p-3`,`[&_pre_code]:bg-transparent [&_pre_code]:p-0 [&_pre_code]:text-foreground`,`[&_blockquote]:my-2 [&_blockquote]:border-l-2 [&_blockquote]:border-accent-primary/40 [&_blockquote]:pl-3 [&_blockquote]:text-foreground/80`,`[&_hr]:my-3 [&_hr]:border-border/60`,`[&_table]:my-2 [&_table]:w-full [&_table]:border-collapse [&_table]:overflow-hidden [&_table]:rounded-lg`,`[&_th]:border [&_th]:border-border [&_th]:bg-surface [&_th]:px-2.5 [&_th]:py-1.5 [&_th]:text-left [&_th]:font-semibold`,`[&_td]:border [&_td]:border-border [&_td]:px-2.5 [&_td]:py-1.5`,`[&_tr:nth-child(even)]:bg-surface/40`);function P5({text:e,timestampIso:t}){let{t:n}=K(`agent`),[r,i]=(0,H.useState)(!1);return(0,Y.jsx)(`button`,{type:`button`,onClick:async()=>{try{let n=e;if(t){let r=dY(t);r&&(n=`[${hV(r,`yyyy-MM-dd HH:mm:ss`)}]\n${e}`)}await navigator.clipboard.writeText(n),i(!0),setTimeout(()=>i(!1),1500)}catch{}},"aria-label":n(`copy`),title:n(`copy`),className:`rounded-md p-1 text-foreground/40 opacity-0 transition-opacity hover:bg-surface hover:text-foreground group-hover:opacity-100`,"data-agent-interactive":!0,children:r?(0,Y.jsx)(to,{className:`h-3 w-3 text-accent-success`}):(0,Y.jsx)(bo,{className:`h-3 w-3`})})}function F5({iso:e}){if(!e)return null;let t=dY(e);if(!t)return null;let n=im();return(0,Y.jsx)(`time`,{dateTime:t.toISOString(),title:hV(t,`PPpp`,{locale:n}),className:`shrink-0 select-none font-mono text-[10px] leading-none tabular-nums tracking-tight text-foreground/25 transition-colors duration-200 group-hover:text-foreground/50`,children:hV(t,`yyyy-MM-dd HH:mm:ss`)})}function I5(e){return!Number.isFinite(e)||e<0?``:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function L5(e){return e.mimeType.startsWith(`image/`)||/\.(png|jpe?g|gif|webp|bmp|svg)$/i.test(e.filename)}function R5({conversationId:e,attachment:t,onClose:n}){let{t:r}=K(`agent`),[i,a]=(0,H.useState)(null),[o,s]=(0,H.useState)(null);if((0,H.useEffect)(()=>{if(!t)return;let e=e=>{e.key===`Escape`&&n()};document.addEventListener(`keydown`,e);let r=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.removeEventListener(`keydown`,e),document.body.style.overflow=r}},[t,n]),(0,H.useEffect)(()=>{if(!t){a(null),s(null);return}let n=!1;return a(null),s(null),IY(e,t.id).then(e=>{n||a(URL.createObjectURL(e))}).catch(e=>{n||s(e instanceof Error?e.message:r(`attachment.loadFailed`))}),()=>{n=!0}},[t,e,r]),(0,H.useEffect)(()=>()=>{i&&URL.revokeObjectURL(i)},[i]),!t)return null;let c=L5(t),l=r(`attachment.download`),u=i?(0,Y.jsxs)(`a`,{href:i,download:t.filename,onClick:e=>e.stopPropagation(),className:`inline-flex items-center justify-center gap-2 rounded-lg bg-accent-primary px-3 py-2 text-sm font-medium text-white transition-opacity hover:opacity-90`,"data-agent-interactive":!0,children:[(0,Y.jsx)(To,{className:`h-4 w-4`}),l]}):(0,Y.jsxs)(`button`,{type:`button`,disabled:!0,className:`inline-flex items-center justify-center gap-2 rounded-lg bg-accent-primary px-3 py-2 text-sm font-medium text-white opacity-45`,children:[o?(0,Y.jsx)(To,{className:`h-4 w-4`}):(0,Y.jsx)(cs,{className:`h-4 w-4 animate-spin`}),l]});return(0,sr.createPortal)((0,Y.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":c?r(`attachment.previewTitle`,{name:t.filename}):r(`attachment.downloadTitle`),className:`fixed inset-0 z-[100] flex items-center justify-center bg-black/80 p-4 backdrop-blur-sm animate-in fade-in-0 duration-150`,onClick:n,children:c?(0,Y.jsxs)(`div`,{className:`flex h-full w-full flex-col overflow-hidden`,onClick:e=>e.stopPropagation(),children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-white/10 bg-black/30 px-3 py-2 text-white`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:n,"aria-label":r(`close`),className:`inline-flex items-center gap-2 rounded-lg px-2.5 py-1.5 text-sm text-white/75 transition-colors hover:bg-white/10 hover:text-white`,"data-agent-interactive":!0,children:[(0,Y.jsx)(Ba,{className:`h-4 w-4`}),r(`close`)]}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1 text-center`,children:[(0,Y.jsx)(`div`,{className:`truncate text-sm font-medium text-white/95`,children:t.filename}),(0,Y.jsx)(`div`,{className:`text-[11px] text-white/45`,children:I5(t.size)||t.mimeType})]}),u]}),(0,Y.jsx)(`div`,{className:`flex flex-1 items-center justify-center overflow-auto p-6`,children:o?(0,Y.jsx)(`div`,{className:`rounded-xl border border-white/10 bg-white/5 px-8 py-7 text-center text-sm text-white/80`,children:r(`attachment.loadError`,{error:o})}):i?(0,Y.jsx)(`img`,{src:i,alt:t.filename,className:`max-h-full max-w-full rounded-xl object-contain shadow-2xl animate-in zoom-in-95 duration-150`}):(0,Y.jsxs)(`div`,{className:`inline-flex items-center gap-2 rounded-xl border border-white/10 bg-white/5 px-5 py-3 text-sm text-white/70`,children:[(0,Y.jsx)(cs,{className:`h-4 w-4 animate-spin`}),r(`attachment.loading`)]})})]}):(0,Y.jsxs)(`div`,{className:`w-full max-w-sm rounded-2xl border border-border/70 bg-card p-4 text-foreground shadow-2xl`,onClick:e=>e.stopPropagation(),children:[(0,Y.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Y.jsx)(`div`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-xl border border-border/70 bg-surface/70`,children:(0,Y.jsx)(Fo,{className:`h-5 w-5 text-accent-primary`})}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`h2`,{className:`text-sm font-semibold`,children:r(`attachment.downloadTitle`)}),(0,Y.jsx)(`p`,{className:`mt-1 truncate text-xs font-medium text-foreground/70`,children:t.filename}),(0,Y.jsx)(`p`,{className:`mt-0.5 text-[11px] text-foreground/45`,children:[I5(t.size),t.mimeType].filter(Boolean).join(` · `)})]})]}),(0,Y.jsx)(`p`,{className:`mt-4 text-sm leading-6 text-foreground/70`,children:r(`attachment.downloadPrompt`)}),o&&(0,Y.jsxs)(`div`,{className:`mt-3 flex items-start gap-2 rounded-lg border border-destructive/25 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:[(0,Y.jsx)(oo,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,Y.jsx)(`span`,{children:r(`attachment.loadError`,{error:o})})]}),(0,Y.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:n,className:`rounded-lg border border-border/70 bg-surface/70 px-3 py-2 text-sm text-foreground/75 transition-colors hover:bg-surface hover:text-foreground`,"data-agent-interactive":!0,children:r(`attachment.cancelDownload`)}),u]})]})}),document.body)}function z5({conversationId:e,attachments:t}){let{t:n}=K(`agent`),[r,i]=(0,H.useState)(null);return!e||!t||t.length===0?null:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5 border-t border-border/40 pt-2`,children:t.map(e=>{let t=L5(e),r=t?$o:Po;return(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>i(e),title:e.filename,"aria-label":n(t?`attachment.openPreview`:`attachment.openDownload`,{name:e.filename}),className:`inline-flex max-w-[12rem] items-center gap-1.5 rounded-lg border border-border/60 bg-background/45 px-2 py-1 text-left text-[11px] text-foreground/75 transition-colors hover:border-accent-primary/45 hover:bg-accent-primary/10 hover:text-foreground`,"data-agent-interactive":!0,children:[(0,Y.jsx)(r,{className:`h-3.5 w-3.5 shrink-0 text-accent-primary`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.filename}),e.size>0&&(0,Y.jsx)(`span`,{className:`shrink-0 text-[10px] text-foreground/35`,children:I5(e.size)})]},e.id)})}),(0,Y.jsx)(R5,{conversationId:e,attachment:r,onClose:()=>i(null)})]})}function B5(e){return e===`project`||e===`alias`?Ya:e===`spec`?Po:e===`job`?qa:e===`trace`?Yo:e===`conversation`?qa:e===`file`?Ss:e===`pr`?Go:e===`action`?Qs:Wa}function V5(e){return e===`action`?`border-accent-highlight/30 bg-accent-highlight/10 text-accent-highlight`:e===`job`||e===`trace`?`border-accent-info/30 bg-accent-info/10 text-accent-info`:e===`spec`?`border-accent-highlight/30 bg-accent-highlight/10 text-accent-highlight`:e===`project`||e===`alias`?`border-accent-primary/30 bg-accent-primary/10 text-accent-primary`:`border-border/60 bg-surface/70 text-foreground/80`}function H5({refItem:e}){let t=B5(e.kind);return(0,Y.jsxs)(`span`,{title:[e.label,e.scope?.projectName,e.status].filter(Boolean).join(` · `)||e.token,className:X(`mx-0.5 inline-flex max-w-[16rem] translate-y-[2px] items-center gap-1 rounded-full border px-2 py-0.5 text-[11px] font-medium leading-4 shadow-sm shadow-black/5`,V5(e.kind)),"data-agent-context-token":e.kind,children:[(0,Y.jsx)(t,{className:`h-3 w-3 shrink-0`}),(0,Y.jsx)(`span`,{className:`truncate`,children:e.label||e.token})]})}function U5({content:e,contextRefs:t}){if(!t||t.length===0)return(0,Y.jsx)(Y.Fragment,{children:e});let n=[],r=0,i=0,a=new Set,o=t.map((t,n)=>({ref:t,originalIndex:n,index:t.token?e.indexOf(t.token):-1})).filter(e=>e.index>=0).sort((e,t)=>e.index-t.index||e.originalIndex-t.originalIndex);for(let t of o){let o=e.indexOf(t.ref.token,r);o<r||o===-1||(o>r&&n.push(e.slice(r,o)),n.push((0,Y.jsx)(H5,{refItem:t.ref},`${t.ref.kind}:${t.ref.id}:${o}:${t.originalIndex}`)),r=o+t.ref.token.length,a.add(t.originalIndex),i++)}r<e.length&&n.push(e.slice(r));let s=t.filter((e,t)=>!a.has(t));return s.length===0?(0,Y.jsx)(Y.Fragment,{children:i?n:e}):(0,Y.jsxs)(Y.Fragment,{children:[s.map((e,t)=>(0,Y.jsx)(H5,{refItem:e},`unmatched:${e.kind}:${e.id}:${t}`)),e.trim()&&(0,Y.jsx)(`span`,{className:`mx-0.5`}),i?n:e]})}function W5({role:e,content:t,createdAt:n,streaming:r,isLast:i,onPickOption:a,refsProjectId:o,onOpenRef:s,contextRefs:c,attachments:l,conversationId:u}){let d=e===`user`,{openWebView:f,canOpenWebView:p}=DH(),m=!d&&!r&&!!o&&!!s,h=(0,H.useMemo)(()=>m?[KL,j5]:[KL],[m]),g=(0,H.useMemo)(()=>({a:({href:e,children:t})=>{let n=p5(e);return n&&s?(0,Y.jsx)(M5,{refTarget:n,onOpen:s,children:t}):(0,Y.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,"data-agent-interactive":!0,onClick:t=>{p&&typeof e==`string`&&/^https?:\/\//i.test(e)&&(t.preventDefault(),t.stopPropagation(),f(e))},children:t})}}),[f,p,s]);if(d)return(0,Y.jsxs)(`div`,{className:`group flex flex-col items-end gap-0.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-start justify-end gap-1`,children:[(0,Y.jsx)(P5,{text:t,timestampIso:n}),(0,Y.jsxs)(`div`,{className:`max-w-[85%] whitespace-pre-wrap rounded-2xl rounded-br-sm border border-border/50 bg-foreground/[0.06] px-3.5 py-2 text-sm text-foreground`,children:[(0,Y.jsx)(U5,{content:t,contextRefs:c}),(0,Y.jsx)(z5,{conversationId:u,attachments:l})]})]}),n&&(0,Y.jsx)(`div`,{className:`pr-1.5`,children:(0,Y.jsx)(F5,{iso:n})})]});let{body:_,options:v}=$8(t),{body:y,draft:b,pending:x}=o5(_,r),S=!!v&&!!i&&!r&&!!a;return(0,Y.jsxs)(`div`,{className:`group flex flex-col gap-1`,children:[(0,Y.jsx)(`div`,{className:X(`max-w-full`,N5),children:(0,Y.jsx)(cI,{remarkPlugins:h,components:g,children:y})}),b&&(0,Y.jsx)(l5,{draft:b}),x&&(0,Y.jsx)(u5,{}),S&&(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-1.5 pt-1`,children:v.map((e,t)=>(0,Y.jsx)(`button`,{type:`button`,onClick:()=>a?.(e),className:`rounded-full border border-border/60 bg-surface/70 px-3 py-1 text-xs text-foreground/80 transition-colors hover:border-accent-primary/45 hover:bg-accent-primary/15 hover:text-foreground`,"data-agent-interactive":!0,children:e},`${t}-${e}`))}),!r&&(y.trim()||n)&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[y.trim()&&(0,Y.jsx)(P5,{text:y,timestampIso:n}),n&&(0,Y.jsx)(F5,{iso:n})]})]})}var G5=(0,H.createContext)(null);function K5({children:e}){let[t,n]=(0,H.useState)(!1),[r,i]=(0,H.useState)(!1),[a,o]=(0,H.useState)(!1),[s,c]=(0,H.useState)([]),l=(0,H.useCallback)(()=>n(!0),[]),u=(0,H.useCallback)(()=>n(!1),[]),d=(0,H.useCallback)(()=>n(e=>!e),[]),f=(0,H.useCallback)(()=>i(!0),[]),p=(0,H.useCallback)(()=>i(!1),[]),m=(0,H.useCallback)(()=>i(e=>!e),[]),h=(0,H.useCallback)(()=>o(!0),[]),g=(0,H.useCallback)(()=>o(!1),[]),_=(0,H.useCallback)(e=>{c(t=>[...t,e])},[]),v=(0,H.useCallback)(()=>{let e=[];return c(t=>(e=t,t.length?[]:t)),e},[]),y=(0,H.useMemo)(()=>({codePaneOpen:t,openCodePane:l,closeCodePane:u,toggleCodePane:d,jobsPaneOpen:r,openJobsPane:f,closeJobsPane:p,toggleJobsPane:m,browserOpen:a,openBrowser:h,closeBrowser:g,pendingCaptures:s,queueCapture:_,consumePendingCaptures:v}),[t,l,u,d,r,f,p,m,a,h,g,s,_,v]);return(0,Y.jsx)(G5.Provider,{value:y,children:e})}var q5={codePaneOpen:!1,openCodePane:()=>{},closeCodePane:()=>{},toggleCodePane:()=>{},jobsPaneOpen:!1,openJobsPane:()=>{},closeJobsPane:()=>{},toggleJobsPane:()=>{},browserOpen:!1,openBrowser:()=>{},closeBrowser:()=>{},pendingCaptures:[],queueCapture:()=>{},consumePendingCaptures:()=>[]};function J5(){return(0,H.useContext)(G5)??q5}var Y5=(0,H.createContext)(null),X5=new Set([`exited`,`killed`,`failed`]),sne=8e3;function cne({children:e}){let{registerHandler:t,unregisterHandler:n}=df(),{active:r,draftPinnedProjectId:i}=N7(),{activeProjectId:a}=gm(),s=r?.pinned_project_id??i??a,c=r?.id??null,[l,u]=(0,H.useState)([]),d=(0,H.useRef)(new Map),f=(0,H.useCallback)(e=>{let t=d.current.get(e);t&&window.clearTimeout(t),d.current.delete(e)},[]),p=(0,H.useCallback)(e=>{let t=e;if(t.type===`background_process.started`&&t.process){f(t.process.pid),u(e=>e.some(e=>e.pid===t.process.pid)?e:[...e,t.process]);return}if(t.type===`background_process.exited`&&t.process){let e=t.process;if(f(e.pid),e.status===`killed`){u(t=>t.filter(t=>t.pid!==e.pid));return}let n={...e,completedAt:Date.now()};u(t=>t.some(t=>t.pid===e.pid)?t.map(t=>t.pid===e.pid?n:t):[...t,n]);let r=window.setTimeout(()=>{u(t=>t.filter(t=>t.pid!==e.pid)),d.current.delete(e.pid)},sne);d.current.set(e.pid,r)}},[f]);(0,H.useEffect)(()=>(t(`background-processes`,p),()=>n(`background-processes`)),[p,t,n]),(0,H.useEffect)(()=>{if(!s||!c)return;let e=!0;return(async()=>{try{let t=new URLSearchParams({chatId:c}),n=await fetch(`${o}/api/projects/${encodeURIComponent(s)}/background-processes?${t.toString()}`);if(!n.ok)return;let r=await n.json();if(!e||!Array.isArray(r.processes)||r.processes.length===0)return;u(e=>{let t=new Map(e.map(e=>[e.pid,e]));for(let e of r.processes??[])t.set(e.pid,e);return Array.from(t.values())})}catch{}})(),()=>{e=!1}},[c,s]),(0,H.useEffect)(()=>()=>{for(let e of d.current.values())window.clearTimeout(e);d.current.clear()},[]);let m=(0,H.useMemo)(()=>l.filter(e=>e.projectId===s&&e.chatId===c&&(!X5.has(e.status)||e.status!==`killed`&&e.completedAt!==void 0)),[l,s,c]),h=(0,H.useCallback)(async e=>{!s||!c||await fetch(`${o}/api/projects/${encodeURIComponent(s)}/background-processes/${encodeURIComponent(String(e))}?chatId=${encodeURIComponent(c)}`,{method:`DELETE`})},[c,s]),g=(0,H.useMemo)(()=>({processes:m,kill:h}),[m,h]);return(0,Y.jsx)(Y5.Provider,{value:g,children:e})}function lne(){return(0,H.useContext)(Y5)||{processes:[],kill:async()=>void 0}}var une=new Set([`@`,`#`,`/`]),dne=/[\s()[\]{}<>"']/;function fne(e,t=e.length){let n=Math.max(0,Math.min(t,e.length));for(let t=n-1;t>=0;t--){let r=e[t];if(r===`
143
+ `||r===` `||r===` `)break;if(!une.has(r))continue;let i=t===0?``:e[t-1];if(i&&!dne.test(i))continue;let a=e.slice(t+1,n);if(/[()[\]{}<>"']/.test(a))return null;let o=r;return{trigger:o,mode:o===`@`?`reference`:o===`#`?`trace`:`action`,query:a,start:t,end:n}}return null}function Z5(e){return`${e.kind}:${e.id}`}function pne(e){return{kind:e.kind,id:e.id,label:e.label,token:e.token,scope:{projectId:e.projectId??null,projectName:e.projectName??null},status:e.status??null,metadata:e.metadata}}function Q5(e,t){return t?e.find(e=>e.id===t)?.name??null:null}function $5(e){return{kind:`project`,id:e.id,label:e.name,token:`@${e.name}`,detail:e.path,projectId:e.id,projectName:e.name,metadata:{slug:e.slug,path:e.path}}}function e7(e,t,n){return{kind:`spec`,id:String(e.id),label:e.title,token:`@${e.title}`,detail:n?`${n} / #${e.id}`:`#${e.id}`,status:e.status,projectId:t,projectName:n,metadata:{ticketId:e.id,priority:e.priority,labels:e.labels,shortSummary:e.short_summary??null}}}function t7(e,t,n){let r=e.id.slice(0,8);return{kind:`job`,id:e.id,label:r,token:`#${r}`,detail:n?`${n} / ${e.command}`:e.command,status:e.status,projectId:t,projectName:n,metadata:{command:e.command,startedAt:e.started_at,costUsd:e.total_cost_usd??null}}}function mne(e,t){let n=e.title||`Untitled mission`;return{kind:`conversation`,id:e.id,label:n,token:`@${n}`,detail:t?`Mission / ${t}`:`Mission`,projectId:e.pinned_project_id,projectName:t,metadata:{provider:e.provider}}}function hne(e,t){let n=t.trim().toLowerCase();return n?[e.title,e.subtitle,e.detail,e.group,...e.keywords??[]].filter(Boolean).join(` `).toLowerCase().includes(n):!0}function gne(e){let t=new Set,n=[];for(let r of e)t.has(r.id)||(t.add(r.id),n.push(r));return n}function _ne(e,t){return gne(e).filter(e=>hne(e,t)).slice(0,12)}function vne(e){let t=Q5(e.projects,e.pinnedProjectId),n=e.pinnedProjectId?e.projects.find(t=>t.id===e.pinnedProjectId)??null:null,r=[];if(n&&r.push({id:`alias:current-project:${n.id}`,mode:`reference`,title:`@current`,subtitle:n.name,detail:`Pinned project`,group:`Current`,icon:`alias`,chip:{...$5(n),kind:`alias`,id:`current:${n.id}`,token:`@current`},keywords:[`this`,`project`,n.name]}),e.activeConversation){let n=mne(e.activeConversation,t);r.push({id:`conversation:${e.activeConversation.id}`,mode:`reference`,title:n.label,subtitle:n.detail,detail:`Current mission`,group:`Created here`,icon:`conversation`,chip:n,keywords:[`mission`,`conversation`,`last`]})}for(let t of e.chips)r.push({id:`chip:${Z5(t)}`,mode:`reference`,title:t.label,subtitle:t.detail,detail:`Already in context`,group:`Current context`,icon:t.kind,chip:t});let i=e.tickets.map(n=>{let r=e7(n,e.pinnedProjectId,t),i=n.status===`on_review`||n.status===`in_progress`||n.status===`draft`;return{id:`spec:${r.projectId??`home`}:${n.id}`,mode:`reference`,title:n.title,subtitle:`Spec #${n.id}${n.status?` · ${n.status}`:``}`,detail:r.detail,group:i?`Active in project`:`Specs`,icon:`spec`,chip:r,keywords:[String(n.id),n.priority??``,...n.labels??[]]}});r.push(...i);let a=e.jobs.slice(0,8).map(n=>{let r=t7(n,e.pinnedProjectId,t);return{id:`job:${r.projectId??`home`}:${n.id}`,mode:`reference`,title:r.label,subtitle:`Job · ${n.status}`,detail:n.command,group:n.status===`running`||n.status===`failed`?`Needs attention`:`Recent jobs`,icon:`job`,chip:r,keywords:[n.id,n.command,n.status]}});r.push(...a);for(let t of e.projects){let n=$5(t);r.push({id:`project:${t.id}`,mode:`reference`,title:t.name,subtitle:`Project`,detail:t.path,group:t.id===e.activeProjectId?`Current app project`:`Projects`,icon:`project`,chip:n,keywords:[t.slug,t.path]})}return r}function yne(e){let t=Q5(e.projects,e.pinnedProjectId),n=[];for(let r of e.jobs){let i=t7(r,e.pinnedProjectId,t);n.push({id:`trace:job:${r.id}`,mode:`trace`,title:i.label,subtitle:`${r.status} · ${r.command}`,detail:t??void 0,group:r.status===`failed`||r.status===`running`?`Active traces`:`Recent traces`,icon:`job`,chip:{...i,kind:`trace`},keywords:[r.id,r.command,r.status,`failed`,`running`,`deploy`,`run`]})}for(let r of e.tickets){let i=e7(r,e.pinnedProjectId,t);n.push({id:`trace:spec:${r.id}`,mode:`trace`,title:`#${r.id}`,subtitle:`${r.title} · ${r.status}`,detail:t??void 0,group:`IDs`,icon:`spec`,chip:{...i,kind:`trace`,token:`#${r.id}`},keywords:[String(r.id),r.title,r.status]})}return n}var bne=[{id:`action:create-spec`,mode:`action`,title:`Create spec`,subtitle:`Turn this into a structured spec`,group:`Create`,icon:`action`,insertText:`/create spec`,tierLevel:2,risk:`cost`,keywords:[`new ticket quick add`]},{id:`action:explore-spec`,mode:`action`,title:`Explore spec`,subtitle:`Refine a fuzzy idea first`,group:`Refine`,icon:`action`,insertText:`/explore spec`,tierLevel:2,risk:`cost`,keywords:[`discovery draft requirements`]},{id:`action:update-spec`,mode:`action`,title:`Update spec`,subtitle:`Edit the selected spec`,group:`Refine`,icon:`action`,insertText:`/update spec`,tierLevel:1,keywords:[`edit ticket`]},{id:`action:assign-rail`,mode:`action`,title:`Assign to rail`,subtitle:`Put selected specs on a rail`,group:`Execute`,icon:`action`,insertText:`/assign to rail`,tierLevel:1,keywords:[`tickets rail`]},{id:`action:launch-rail`,mode:`action`,title:`Launch rail`,subtitle:`Run the selected rail or spec`,group:`Execute`,icon:`action`,insertText:`/launch rail`,tierLevel:2,risk:`cost`,keywords:[`run implement`]},{id:`action:launch-all`,mode:`action`,title:`Launch all eligible rails`,subtitle:`Start every ready rail in parallel`,group:`Execute`,icon:`action`,insertText:`/launch all eligible rails`,tierLevel:2,risk:`cost`,keywords:[`all rails run`]},{id:`action:status`,mode:`action`,title:`Show status`,subtitle:`Summarize the current workbench`,group:`Review`,icon:`action`,insertText:`/status`,tierLevel:0,keywords:[`state overview`]},{id:`action:diagnose`,mode:`action`,title:`Diagnose`,subtitle:`Inspect git, jobs, setup, Jira, and failures`,group:`Review`,icon:`action`,insertText:`/diagnose`,tierLevel:0,keywords:[`debug health failed`]},{id:`action:compare`,mode:`action`,title:`Compare`,subtitle:`Compare selected specs, jobs, diffs, or costs`,group:`Review`,icon:`action`,insertText:`/compare`,tierLevel:0,keywords:[`diff versus`]},{id:`action:summarize`,mode:`action`,title:`Summarize`,subtitle:`Condense selected context`,group:`Review`,icon:`action`,insertText:`/summarize`,tierLevel:0,keywords:[`recap`]},{id:`action:save-as-spec`,mode:`action`,title:`Save as spec`,subtitle:`Capture the selected context as durable work`,group:`Create`,icon:`action`,insertText:`/save as spec`,tierLevel:1,keywords:[`persist capture`]},{id:`action:generate-report`,mode:`action`,title:`Generate report`,subtitle:`Create a written artifact from selected context`,group:`Create`,icon:`action`,insertText:`/generate report`,tierLevel:1,keywords:[`document export`]},{id:`action:show-spend`,mode:`action`,title:`Show spend`,subtitle:`Review cost and budget impact`,group:`Review`,icon:`action`,insertText:`/show spend`,tierLevel:0,keywords:[`cost budget analytics`]},{id:`action:search`,mode:`action`,title:`Search current project`,subtitle:`Find specs, jobs, files, or context`,group:`Navigate`,icon:`action`,insertText:`/search`,tierLevel:0,keywords:[`find`]},{id:`action:search-all`,mode:`action`,title:`Search all projects`,subtitle:`Fan out across registered projects`,group:`Navigate`,icon:`action`,insertText:`/search all projects`,tierLevel:0,keywords:[`global home`]},{id:`action:open`,mode:`action`,title:`Open item`,subtitle:`Open the selected object in Specrails`,group:`Navigate`,icon:`action`,insertText:`/open`,tierLevel:0,keywords:[`navigate`]},{id:`action:wait`,mode:`action`,title:`Wait for result`,subtitle:`Follow a running job or trace`,group:`Review`,icon:`action`,insertText:`/wait for result`,tierLevel:0,keywords:[`watch running`]},{id:`action:show-diff`,mode:`action`,title:`Show diff`,subtitle:`Inspect changes from the selected job`,group:`Review`,icon:`action`,insertText:`/show diff`,tierLevel:0,keywords:[`files changes`]},{id:`action:diagnostic`,mode:`action`,title:`Export diagnostic`,subtitle:`Collect job telemetry and logs`,group:`Review`,icon:`action`,insertText:`/export diagnostic`,tierLevel:0,keywords:[`zip logs telemetry`]},{id:`action:cancel-job`,mode:`action`,title:`Cancel job`,subtitle:`Stop or delete a selected job`,group:`Clean up`,icon:`action`,insertText:`/cancel job`,tierLevel:3,risk:`destructive`,keywords:[`stop kill`]},{id:`action:refine-contract`,mode:`action`,title:`Refine contract`,subtitle:`Add or refresh the Contract Layer`,group:`Refine`,icon:`action`,insertText:`/refine contract`,tierLevel:2,risk:`cost`,keywords:[`contract`]},{id:`action:split-epic`,mode:`action`,title:`Split epic`,subtitle:`Decompose a large spec into children`,group:`Refine`,icon:`action`,insertText:`/split epic`,tierLevel:2,risk:`cost`,keywords:[`smash children`]},{id:`action:files-touched`,mode:`action`,title:`Show files touched`,subtitle:`Inspect provenance for selected work`,group:`Review`,icon:`action`,insertText:`/show files touched`,tierLevel:0,keywords:[`provenance`]},{id:`action:connect-jira`,mode:`action`,title:`Connect Jira`,subtitle:`Start the Jira connection flow`,group:`Integrate`,icon:`action`,insertText:`/connect Jira`,tierLevel:1,keywords:[`integration`]},{id:`action:sync-jira`,mode:`action`,title:`Sync Jira`,subtitle:`Refresh Jira-backed specs`,group:`Integrate`,icon:`action`,insertText:`/sync Jira`,tierLevel:1,keywords:[`integration`]},{id:`action:install-plugin`,mode:`action`,title:`Install plugin`,subtitle:`Preview and install an integration`,group:`Integrate`,icon:`action`,insertText:`/install plugin`,tierLevel:1,keywords:[`mcp integration`]},{id:`action:set-budget`,mode:`action`,title:`Set budget`,subtitle:`Adjust spend guardrails`,group:`Configure`,icon:`action`,insertText:`/set budget`,tierLevel:1,keywords:[`cost limit`]}];function n7(e,t,n){let r=new Set(t.map(e=>e.kind)),i=0;return t.length===0&&([`action:create-spec`,`action:search`,`action:status`,`action:diagnose`,`action:show-spend`].includes(e.id)&&(i+=40),n.pinnedProjectId&&e.id===`action:launch-all`&&(i+=30)),r.has(`project`)&&[`action:status`,`action:search`,`action:launch-all`,`action:show-spend`,`action:sync-jira`,`action:install-plugin`].includes(e.id)&&(i+=50),r.has(`spec`)&&[`action:update-spec`,`action:assign-rail`,`action:launch-rail`,`action:refine-contract`,`action:split-epic`,`action:files-touched`,`action:show-spend`].includes(e.id)&&(i+=70),(r.has(`job`)||r.has(`trace`))&&[`action:open`,`action:wait`,`action:compare`,`action:show-diff`,`action:diagnostic`,`action:cancel-job`].includes(e.id)&&(i+=80),r.has(`file`)&&[`action:summarize`,`action:show-diff`,`action:files-touched`].includes(e.id)&&(i+=60),i}function xne(e){return[...bne].sort((t,n)=>n7(n,e.chips,e)-n7(t,e.chips,e)).map(e=>({...e,chip:{kind:`action`,id:e.id,label:e.title,token:e.insertText??`/${e.title.toLowerCase()}`,detail:e.subtitle,metadata:{tierLevel:e.tierLevel,risk:e.risk??null}}}))}function Sne(e,t){return e===`reference`?vne(t):e===`trace`?yne(t):xne(t)}function Cne(e,t){let n=t.trim();if(!n)return[];let r=n.slice(0,80),i=[{id:`fallback:search-all:${e}:${r}`,mode:e,title:`Search all Specrails`,subtitle:`Find "${r}" across every project`,group:`No matches`,icon:`action`,insertText:`/search all projects ${r}`,tierLevel:0,keywords:[`fallback global search all`]},{id:`fallback:ask-agent:${e}:${r}`,mode:e,title:`Ask agent about "${r}"`,subtitle:`Keep the wording and let the agent resolve it`,group:`No matches`,icon:`action`,insertText:r,tierLevel:0,keywords:[`fallback ask agent clarify`]}];return e===`trace`?i.splice(1,0,{id:`fallback:archived:${e}:${r}`,mode:e,title:`Include archived results`,subtitle:`Search completed, canceled, and old traces for "${r}"`,group:`No matches`,icon:`action`,insertText:`/search all projects archived ${r}`,tierLevel:0,keywords:[`fallback archived old completed canceled`]}):i.splice(1,0,{id:`fallback:create-spec:${e}:${r}`,mode:e,title:`Create "${r}"`,subtitle:`Turn this unmatched reference into a spec`,group:`No matches`,icon:`action`,insertText:`/create spec ${r}`,tierLevel:2,risk:`cost`,keywords:[`fallback create new spec`]}),i}function wne(e,t,n){let r=n.insertText??n.chip?.token??n.title,i=t?.start??e.length,a=t?.end??e.length,o=e.slice(0,i),s=e.slice(a),c=o&&!/\s$/.test(o)?` `:``,l=s&&!/^\s/.test(s)?` `:``;return{text:`${o}${c}${r}${l}${s}`,caret:o.length+c.length+r.length+l.length}}function r7({pinnedProjectId:e,onSelect:t}){let{t:n}=K(`agent`),{projects:r}=gm(),[i,a]=(0,H.useState)(!1),[o,s]=(0,H.useState)(``),c=(0,H.useRef)(null);(0,H.useEffect)(()=>{if(!i)return;let e=e=>{c.current&&!c.current.contains(e.target)&&a(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[i]);let l=r.find(t=>t.id===e)??null,u=(0,H.useMemo)(()=>{let e=o.trim().toLowerCase();return e?r.filter(t=>t.name.toLowerCase().includes(e)):r},[r,o]),d=e=>{t(e),a(!1),s(``)};return(0,Y.jsxs)(`div`,{className:`relative`,ref:c,"data-agent-interactive":!0,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>a(e=>!e),className:`flex items-center gap-1.5 rounded-md px-1.5 py-1 text-sm font-medium text-foreground hover:bg-surface/70`,children:[l?(0,Y.jsx)(Bo,{className:`h-3.5 w-3.5 text-accent-primary`}):(0,Y.jsx)(Qo,{className:`h-3.5 w-3.5 text-foreground/70`}),(0,Y.jsx)(`span`,{className:`max-w-[160px] truncate`,children:l?l.name:n(`project.home`)}),(0,Y.jsx)(no,{className:`h-3.5 w-3.5 text-foreground/50`})]}),(0,Y.jsx)(H3,{children:i&&(0,Y.jsxs)(V8.div,{initial:{opacity:0,y:-6,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-6,scale:.98},transition:{duration:.16,ease:`easeOut`},className:`absolute left-0 top-full z-10 mt-1 w-64 overflow-hidden rounded-xl border border-border/60 bg-card/95 shadow-2xl backdrop-blur-xl`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/50 px-3 py-2`,children:[(0,Y.jsx)(Us,{className:`h-3.5 w-3.5 text-foreground/40`}),(0,Y.jsx)(`input`,{autoFocus:!0,value:o,onChange:e=>s(e.target.value),placeholder:n(`project.searchPlaceholder`),className:`w-full bg-transparent text-sm text-foreground outline-none placeholder:text-foreground/40`})]}),(0,Y.jsxs)(`div`,{className:`max-h-72 overflow-y-auto py-1`,children:[(0,Y.jsx)(`div`,{className:`px-3 py-1 text-[11px] uppercase tracking-wide text-foreground/40`,children:n(`project.recents`)}),(0,Y.jsx)(i7,{icon:(0,Y.jsx)(Qo,{className:`h-4 w-4`}),label:n(`project.home`),active:!e,onClick:()=>d(null),index:0}),u.map((t,n)=>(0,Y.jsx)(i7,{icon:(0,Y.jsx)(Bo,{className:`h-4 w-4 text-accent-primary`}),label:t.name,active:t.id===e,onClick:()=>d(t.id),index:n+1},t.id))]})]})})]})}function i7({icon:e,label:t,active:n,onClick:r,index:i}){return(0,Y.jsxs)(V8.button,{type:`button`,onClick:r,initial:{opacity:0,x:-6},animate:{opacity:1,x:0},transition:{duration:.14,delay:Math.min(i*.03,.18)},className:`flex w-full items-center gap-2.5 px-3 py-1.5 text-left text-sm text-foreground hover:bg-surface/70`,children:[e,(0,Y.jsx)(`span`,{className:`flex-1 truncate`,children:t}),n&&(0,Y.jsx)(to,{className:`h-3.5 w-3.5 text-accent-primary`})]})}var a7=[{level:0,key:`observe`,icon:ko,tone:`text-foreground/70`,bar:`bg-accent-info`},{level:1,key:`edit`,icon:ws,tone:`text-accent-info`,bar:`bg-accent-info`},{level:2,key:`operate`,icon:gc,tone:`text-accent-warning`,bar:`bg-accent-warning`},{level:3,key:`autonomous`,icon:Lo,tone:`text-destructive`,bar:`bg-destructive`}];function Tne({level:e,onCycle:t}){let{t:n}=K(`agent`),r=a7[e],i=r.icon;return(0,Y.jsxs)(`button`,{type:`button`,onClick:t,title:n(`tier.${r.key}.desc`),"aria-label":`${n(`tier.${r.key}.name`)} — ${n(`tier.cycleHint`)}`,className:`group flex items-center gap-1.5 rounded-full border border-border/60 bg-surface/70 px-2.5 py-1 text-xs font-medium ${r.tone} transition-colors hover:bg-surface`,"data-agent-interactive":!0,children:[(0,Y.jsxs)(V8.span,{initial:{scale:.8},animate:{scale:[1,1.18,1]},transition:{duration:.28,ease:`easeOut`},className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(i,{className:`h-3.5 w-3.5`}),n(`tier.${r.key}.name`)]},e),(0,Y.jsx)(`span`,{className:`ml-1 flex gap-0.5`,"aria-hidden":!0,children:a7.map(t=>(0,Y.jsx)(`span`,{className:`h-1 w-2 rounded-full transition-colors duration-200 ${t.level<=e?r.bar:`bg-border/50`}`},t.level))})]})}function Ene({provider:e,model:t,onSelect:n}){let{t:r}=K(`agent`),[i,a]=(0,H.useState)([]);return(0,H.useEffect)(()=>{let t=!0;return EY(e).then(e=>{t&&a(e.models)}).catch(()=>{t&&a([])}),()=>{t=!1}},[e]),(0,Y.jsx)(`select`,{value:t??i.find(e=>e.default)?.value??i[0]?.value??``,onChange:e=>n(e.target.value),"aria-label":r(`model.label`),"data-agent-interactive":!0,className:`rounded-lg border border-border/60 bg-surface/70 px-2.5 py-1 text-xs text-foreground outline-none hover:bg-surface`,children:i.map(e=>(0,Y.jsx)(`option`,{value:e.value,children:e.label},e.value))})}function Dne({projectId:e}){let{t}=K(`agent`),{isStreaming:n}=N7(),[r,i]=(0,H.useState)(null),[a,s]=(0,H.useState)(!1),[c,l]=(0,H.useState)(!1),[u,d]=(0,H.useState)(``),f=(0,H.useRef)(null),p=`${o}/api/projects/${e}/git`,m=(0,H.useCallback)(async()=>{try{let e=await fetch(p);if(!e.ok)return;i(await e.json())}catch{}},[p]);(0,H.useEffect)(()=>{i(null),m()},[m]);let h=(0,H.useRef)(n);(0,H.useEffect)(()=>{h.current&&!n&&m(),h.current=n},[n,m]),(0,H.useEffect)(()=>{if(!c)return;let e=e=>{f.current&&!f.current.contains(e.target)&&l(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[c]);let g=(0,H.useCallback)(async e=>{if(l(!1),d(``),!(!e||e===r?.branch)){s(!0);try{let n=await fetch(`${p}/checkout`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({branch:e})}),r=await n.json().catch(()=>({}));if(!n.ok){q.error(t(`git.switchFailed`),{description:r.error}),m();return}i(r),q.success(t(`git.switched`,{branch:e}))}catch{q.error(t(`git.switchFailed`)),m()}finally{s(!1)}}},[p,r?.branch,t,m]),_=(0,H.useMemo)(()=>{if(!r)return[];let e=u.trim().toLowerCase();return e?r.branches.filter(t=>t.toLowerCase().includes(e)):r.branches},[r,u]);if(!r?.git)return null;let v=a||n,y=r.detached?t(`git.detached`):r.branch??t(`git.detached`),b=new Map((r.worktrees??[]).filter(e=>!e.isMain&&e.branch).map(e=>[e.branch,e])),x=_.filter(e=>!b.has(e)),S=_.filter(e=>b.has(e)),C=async e=>{l(!1),d(``);try{await navigator.clipboard.writeText(e.path),q.success(t(`git.worktreePathCopied`),{description:e.path})}catch{q.info?.(e.path)}};return(0,Y.jsxs)(`div`,{ref:f,className:`relative mt-1.5 flex min-w-0 items-center gap-2 px-1 text-[11px] text-foreground/50`,"data-agent-interactive":!0,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{v||l(e=>!e)},disabled:v,"aria-label":t(`git.branch`),"aria-expanded":c,title:t(v&&n?`git.lockedWhileWorking`:`git.branch`),className:`flex max-w-[220px] shrink-0 items-center gap-1.5 rounded-md border border-border/50 bg-surface/60 px-1.5 py-0.5 text-[11px] text-foreground transition-colors hover:bg-surface disabled:opacity-50`,children:[a?(0,Y.jsx)(cs,{className:`h-3 w-3 shrink-0 animate-spin text-accent-primary/70`}):(0,Y.jsx)(Ho,{className:`h-3 w-3 shrink-0 text-accent-primary/70`}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate`,children:y}),(0,Y.jsx)(no,{className:`h-3 w-3 shrink-0 text-foreground/40`})]}),(0,Y.jsx)(H3,{children:c&&(0,Y.jsxs)(V8.div,{initial:{opacity:0,y:6,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:6,scale:.98},transition:{duration:.16,ease:`easeOut`},className:`absolute bottom-full left-0 z-20 mb-1 w-72 overflow-hidden rounded-xl border border-border/60 bg-card/95 shadow-2xl backdrop-blur-xl`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/50 px-3 py-2`,children:[(0,Y.jsx)(Us,{className:`h-3.5 w-3.5 text-foreground/40`}),(0,Y.jsx)(`input`,{autoFocus:!0,value:u,onChange:e=>d(e.target.value),placeholder:t(`git.searchPlaceholder`),"aria-label":t(`git.searchPlaceholder`),className:`w-full bg-transparent text-sm text-foreground outline-none placeholder:text-foreground/40`})]}),(0,Y.jsxs)(`div`,{className:`max-h-64 overflow-y-auto py-1`,role:`listbox`,"aria-label":t(`git.branch`),children:[_.length===0&&(0,Y.jsx)(`div`,{className:`px-3 py-2 text-xs text-foreground/40`,children:t(`git.noMatches`)}),x.map((e,t)=>(0,Y.jsxs)(V8.button,{type:`button`,role:`option`,"aria-selected":e===r.branch,onClick:()=>void g(e),initial:{opacity:0,x:-6},animate:{opacity:1,x:0},transition:{duration:.14,delay:Math.min(t*.02,.16)},className:`flex w-full items-center gap-2.5 px-3 py-1.5 text-left text-sm text-foreground hover:bg-surface/70`,children:[(0,Y.jsx)(Ho,{className:`h-3.5 w-3.5 shrink-0 text-accent-primary/70`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs`,children:e}),e===r.branch&&(0,Y.jsx)(to,{className:`h-3.5 w-3.5 shrink-0 text-accent-primary`})]},e)),S.length>0&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`mt-1 border-t border-border/50 px-3 pb-0.5 pt-1.5 text-[10px] uppercase tracking-wide text-foreground/40`,children:t(`git.worktrees`)}),S.map((e,n)=>{let r=b.get(e);return(0,Y.jsxs)(V8.button,{type:`button`,role:`option`,"aria-selected":!1,onClick:()=>void C(r),initial:{opacity:0,x:-6},animate:{opacity:1,x:0},transition:{duration:.14,delay:Math.min(n*.02,.16)},title:t(`git.copyWorktreePath`),className:`group flex w-full items-center gap-2.5 px-3 py-1.5 text-left text-sm text-foreground hover:bg-surface/70`,children:[(0,Y.jsx)(Ro,{className:`h-3.5 w-3.5 shrink-0 text-accent-secondary/80`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block truncate font-mono text-xs`,children:e}),(0,Y.jsx)(`span`,{className:`block truncate text-[10px] text-foreground/40`,children:r.path})]}),(0,Y.jsx)(bo,{className:`h-3 w-3 shrink-0 text-foreground/30 opacity-0 transition-opacity group-hover:opacity-100`})]},e)})]})]})]})}),r.dirty&&(0,Y.jsx)(`span`,{title:t(`git.dirty`),"aria-label":t(`git.dirty`),className:`h-1.5 w-1.5 shrink-0 rounded-full bg-accent-warning`}),r.lastCommit&&(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,title:`${r.lastCommit.hash} · ${r.lastCommit.subject}`,children:[(0,Y.jsx)(`span`,{className:`font-mono text-foreground/40`,children:r.lastCommit.hash}),` · `,r.lastCommit.subject]})]})}var One={reference:Wa,trace:Yo,action:Qs},o7={project:Ya,spec:Po,job:qa,trace:Yo,conversation:qa,file:Ss,alias:Wa,pr:Go,action:Qs};function kne(e){return e===`reference`?`@`:e===`trace`?`#`:`/`}function Ane(e){return e===`spec`?`border-accent-highlight/30 bg-accent-highlight/10 text-accent-highlight`:e===`job`||e===`trace`?`border-accent-info/30 bg-accent-info/10 text-accent-info`:e===`action`?`border-accent-highlight/30 bg-accent-highlight/10 text-accent-highlight`:e===`project`||e===`alias`?`border-accent-primary/30 bg-accent-primary/10 text-accent-primary`:`border-border/60 bg-surface/70 text-foreground/80`}function jne({chips:e,onRemove:t}){let{t:n}=K(`agent`);return e.length===0?null:(0,Y.jsx)(Y.Fragment,{children:e.map(e=>{let r=o7[e.kind]??Wa;return(0,Y.jsxs)(`span`,{title:[e.label,e.detail,e.projectName,e.status].filter(Boolean).join(` · `),className:`inline-flex max-w-[240px] items-center gap-1.5 rounded-full border px-2 py-0.5 text-[11px] ${Ane(e.kind)}`,children:[(0,Y.jsx)(r,{className:`h-3 w-3 shrink-0`}),(0,Y.jsx)(`span`,{className:`truncate font-medium`,children:e.label}),e.status&&(0,Y.jsx)(`span`,{className:`text-foreground/40`,children:e.status}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>t(e),"aria-label":n(`palette.remove`,{label:e.label}),className:`rounded-sm text-foreground/45 hover:bg-background/60 hover:text-foreground`,children:(0,Y.jsx)(hc,{className:`h-3 w-3`})})]},`${e.kind}:${e.id}`)})})}function Mne({items:e,mode:t,query:n,activeIndex:r,onActiveIndexChange:i,onSelect:a}){let{t:o}=K(`agent`),s=One[t],c=``;return(0,Y.jsxs)(`div`,{"data-testid":`agent-context-palette`,className:`absolute bottom-[calc(100%+0.5rem)] left-0 right-0 z-30 overflow-hidden rounded-lg border border-border/70 bg-background/95 shadow-xl shadow-black/15 backdrop-blur`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/60 px-2.5 py-2`,children:[(0,Y.jsx)(`span`,{className:`inline-flex h-6 w-6 items-center justify-center rounded-md bg-surface text-foreground/70`,children:(0,Y.jsx)(s,{className:`h-3.5 w-3.5`})}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`div`,{className:`text-xs font-medium text-foreground`,children:[kne(t),` `,o(`palette.mode.${t}.title`)]}),(0,Y.jsx)(`div`,{className:`truncate text-[11px] text-foreground/45`,children:n?o(`palette.filtering`,{query:n}):o(`palette.mode.${t}.hint`)})]}),(0,Y.jsx)(`div`,{className:`hidden text-[10px] text-foreground/35 sm:block`,children:o(`palette.keyboard`)})]}),e.length===0?(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-3 text-xs text-foreground/55`,children:[(0,Y.jsx)(Us,{className:`h-3.5 w-3.5 text-foreground/35`}),(0,Y.jsx)(`span`,{children:n?o(`palette.noMatchesFor`,{query:n}):o(`palette.noMatches`)})]}):(0,Y.jsx)(`div`,{className:`max-h-[19rem] overflow-y-auto py-1`,children:e.map((e,t)=>{let n=o7[e.icon]??Qs,o=e.group!==c;c=e.group;let s=t===r;return(0,Y.jsxs)(`div`,{children:[o&&(0,Y.jsx)(`div`,{className:`px-3 pb-1 pt-2 text-[10px] font-medium uppercase tracking-wide text-foreground/35`,children:e.group}),(0,Y.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":s,onMouseEnter:()=>i(t),onMouseDown:e=>e.preventDefault(),onClick:()=>a(e),className:`flex w-full items-center gap-2 px-2.5 py-2 text-left transition-colors ${s?`bg-accent-primary/10 text-foreground`:`text-foreground/80 hover:bg-surface/70`}`,children:[(0,Y.jsx)(`span`,{className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md ${s?`bg-background text-accent-primary`:`bg-surface text-foreground/50`}`,children:(0,Y.jsx)(n,{className:`h-3.5 w-3.5`})}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e.title}),e.risk&&(0,Y.jsx)(`span`,{className:`shrink-0 rounded-sm border border-border/60 px-1 py-0.5 text-[10px] uppercase text-foreground/45`,children:e.risk})]}),(e.subtitle||e.detail)&&(0,Y.jsxs)(`span`,{className:`mt-0.5 block truncate text-[11px] text-foreground/45`,children:[e.subtitle,e.subtitle&&e.detail?` · `:``,e.detail]})]})]})]},e.id)})})]})}function Nne({open:e,canAttach:t,uploading:n,onToggle:r,onClose:i,onOpenMode:a,onAttachFile:o}){let{t:s}=K(`agent`),c=(0,H.useRef)(null);return(0,H.useEffect)(()=>{if(!e)return;let t=e=>{let t=e.target;t instanceof Node&&c.current?.contains(t)||i()},n=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),i())};return document.addEventListener(`pointerdown`,t,!0),document.addEventListener(`keydown`,n,!0),()=>{document.removeEventListener(`pointerdown`,t,!0),document.removeEventListener(`keydown`,n,!0)}},[e,i]),(0,Y.jsxs)(`div`,{ref:c,className:`relative mb-1`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:r,"aria-label":s(`palette.addContextAction`),title:s(`palette.addContextAction`),"data-agent-interactive":!0,className:`rounded-md p-1 text-foreground/50 hover:bg-surface hover:text-foreground disabled:opacity-50`,children:(0,Y.jsx)(ks,{className:`h-4 w-4`})}),e&&(0,Y.jsxs)(`div`,{className:`absolute bottom-8 left-0 z-40 w-64 overflow-hidden rounded-lg border border-border/70 bg-background/95 py-1 shadow-xl shadow-black/15 backdrop-blur`,children:[(0,Y.jsxs)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>a(`reference`),className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-surface`,children:[(0,Y.jsx)(Wa,{className:`h-4 w-4 text-accent-primary`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block font-medium`,children:s(`palette.plus.reference`)}),(0,Y.jsx)(`span`,{className:`block truncate text-[11px] text-foreground/45`,children:s(`palette.plus.referenceHint`)})]})]}),(0,Y.jsxs)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>a(`trace`),className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-surface`,children:[(0,Y.jsx)(Yo,{className:`h-4 w-4 text-accent-info`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block font-medium`,children:s(`palette.plus.trace`)}),(0,Y.jsx)(`span`,{className:`block truncate text-[11px] text-foreground/45`,children:s(`palette.plus.traceHint`)})]})]}),(0,Y.jsxs)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>a(`action`),className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-surface`,children:[(0,Y.jsx)(Qs,{className:`h-4 w-4 text-accent-highlight`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block font-medium`,children:s(`palette.plus.action`)}),(0,Y.jsx)(`span`,{className:`block truncate text-[11px] text-foreground/45`,children:s(`palette.plus.actionHint`)})]})]}),(0,Y.jsx)(`div`,{className:`my-1 border-t border-border/60`}),(0,Y.jsxs)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:o,disabled:!t||n,className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-surface disabled:cursor-not-allowed disabled:opacity-45`,children:[(0,Y.jsx)(Ss,{className:`h-4 w-4 text-foreground/50`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block font-medium`,children:s(`palette.plus.fileAttachment`)}),(0,Y.jsx)(`span`,{className:`block truncate text-[11px] text-foreground/45`,children:s(`palette.plus.fileAttachmentHint`)})]})]}),(0,Y.jsxs)(`button`,{type:`button`,disabled:!0,className:`flex w-full cursor-not-allowed items-center gap-2 px-3 py-2 text-left text-sm opacity-45`,children:[(0,Y.jsx)(Za,{className:`h-4 w-4 text-foreground/50`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block font-medium`,children:s(`palette.plus.browserCapture`)}),(0,Y.jsx)(`span`,{className:`block truncate text-[11px] text-foreground/45`,children:s(`palette.plus.browserCaptureHint`)})]})]})]})]})}var Pne={"accent-primary":`border-accent-primary/40 bg-accent-primary/10 text-accent-primary`,"accent-info":`border-accent-info/40 bg-accent-info/10 text-accent-info`,"accent-highlight":`border-accent-highlight/40 bg-accent-highlight/10 text-accent-highlight`};function Fne({process:e,accentVariant:t,onKill:n}){let[r,i]=(0,H.useState)(Date.now());(0,H.useEffect)(()=>{let e=window.setInterval(()=>i(Date.now()),1e3);return()=>window.clearInterval(e)},[]);let a=jz(r-e.startedAt),o=e.status===`exited`||e.status===`failed`||e.status===`killed`;return(0,Y.jsx)(FE,{delayDuration:150,children:(0,Y.jsxs)(IE,{children:[(0,Y.jsx)(LE,{asChild:!0,children:(0,Y.jsxs)(`span`,{"data-testid":`background-process-chip`,className:`group inline-flex max-w-[220px] items-center gap-1.5 rounded-full border px-2 py-0.5 text-[11px] transition-colors ${Pne[t]}`,children:[(0,Y.jsx)(ac,{className:`h-3 w-3 shrink-0 ${o?``:`animate-pulse`}`}),(0,Y.jsx)(`span`,{className:e.status===`failed`?`shrink-0 font-medium text-destructive`:`shrink-0 text-foreground/60`,children:e.status}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate font-medium`,children:e.command}),!o&&(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Kill ${e.command}`,title:`Kill ${e.command}`,onClick:t=>{t.preventDefault(),t.stopPropagation(),n(e.pid)},className:`rounded-sm p-0.5 opacity-70 transition-opacity hover:bg-background/60 hover:opacity-100 group-hover:opacity-100`,children:(0,Y.jsx)(hc,{className:`h-3 w-3`})})]})}),(0,Y.jsx)(RE,{children:o?`${e.status} after ${a}`:a})]})})}var Ine=[`claude`,`codex`,`gemini`];function Lne(e,t){if(!t)return{text:e,caret:e.length};let n=e.slice(0,t.start),r=e.slice(t.end);/\s$/.test(n)&&/^\s/.test(r)&&(r=r.replace(/^\s+/,``));let i=n&&r&&!/\s$/.test(n)&&!/^\s/.test(r)?` `:``;return{text:`${n}${i}${r}`,caret:n.length+i.length}}var s7=new Map,c7=new Map,l7=`__new-mission__`;function u7({autoFocus:e=!1,hideProjectSelector:t=!1}){let{t:n}=K(`agent`),{active:r,messages:i,conversations:a,isStreaming:s,providersReady:c,draftPinnedProjectId:l,draftProvider:u,draftModel:d,draftTierLevel:f,draftEffort:p,setEffort:m,send:h,abort:g,cycleTier:_,setProvider:v,setModel:y,setPinnedProject:b,materializeDraftConversation:x,queuedMessages:S,editQueuedMessage:C,wasQueueConsumed:w}=N7(),{pendingCaptures:T,consumePendingCaptures:E}=J5(),{processes:D,kill:O}=lne(),{projects:k,activeProjectId:A}=gm(),j=r?.id??l7,[M,N]=(0,H.useState)(()=>s7.get(j)??``),P=e=>{N(e),e?s7.set(j,e):s7.delete(j)},[F,I]=(0,H.useState)(null),[L,R]=(0,H.useState)(()=>c7.get(j)??[]),z=(0,H.useRef)(j);z.current=j;let ee=(e,t)=>{let n=c7.get(e)??[],r=typeof t==`function`?t(n):t;r.length>0?c7.set(e,r):c7.delete(e);let i=z.current;(i===e||i===l7&&e!==l7)&&R(r)},[te,B]=(0,H.useState)(!1),ne=(0,H.useRef)(null),V=(0,H.useRef)(null),[re,U]=(0,H.useState)([]),[ie,ae]=(0,H.useState)(null),[W,oe]=(0,H.useState)(0),[se,ce]=(0,H.useState)(!1),[le,ue]=(0,H.useState)([]),[de,fe]=(0,H.useState)([]),pe=F!==null,me=(0,H.useMemo)(()=>i.filter(e=>e.role===`user`).map(e=>e.content),[i]),[he,ge]=(0,H.useState)(null),_e=(0,H.useRef)(``),ve=(0,H.useRef)(``),ye=he===null?-1:S.findIndex(e=>e.queueId===he),G=ye>=0?S[ye]:null,be=he!==null,xe=c===!1,Se=!xe,Ce=r?.provider??u,we=r?r.pinned_project_id:l,Te=we,Ee=(0,H.useMemo)(()=>({projects:k,conversations:a,activeConversation:r,pinnedProjectId:Te,activeProjectId:A,tickets:le,jobs:de,chips:re}),[k,a,r,Te,A,le,de,re]),De=(0,H.useMemo)(()=>ie?Sne(ie.mode,Ee):[],[ie,Ee]),Oe=(0,H.useMemo)(()=>{if(!ie)return[];let e=_ne(De,ie.query);return e.length>0?e:Cne(ie.mode,ie.query)},[De,ie]),ke=ie!==null&&!be,Ae=M.trim().length>0||re.length>0,je=[`accent-primary`,`accent-info`,`accent-highlight`],Me=r?.id??null;(0,H.useEffect)(()=>{R(c7.get(Me??l7)??[]),I(null),ae(null),ce(!1),U([]),ge(null),N(s7.get(Me??l7)??``)},[Me]),(0,H.useEffect)(()=>{if(!Te){ue([]),fe([]);return}let e=!0;return(async()=>{try{let[t,n]=await Promise.all([fetch(`${o}/api/projects/${encodeURIComponent(Te)}/tickets`),fetch(`${o}/api/projects/${encodeURIComponent(Te)}/jobs?limit=25`)]),r=await t.json(),i=await n.json();if(!e)return;ue(Array.isArray(r.tickets)?r.tickets:[]),fe(Array.isArray(i.jobs)?i.jobs:[])}catch{if(!e)return;ue([]),fe([])}})(),()=>{e=!1}},[Te]),(0,H.useEffect)(()=>{oe(0)},[ie?.mode,ie?.query]),(0,H.useEffect)(()=>{W>=Oe.length&&oe(Math.max(0,Oe.length-1))},[W,Oe.length]),(0,H.useEffect)(()=>{if(T.length===0)return;let e=E();e.length&&ee(j,t=>[...t,...e])},[T,E,j]);let[Ne,Pe]=(0,H.useState)(!0),[Fe,Ie]=(0,H.useState)([]);(0,H.useEffect)(()=>{let e=!0;return EY(Ce).then(t=>{e&&(Pe(t.supportsImageInput),Ie(t.efforts))}).catch(()=>{}),()=>{e=!1}},[Ce]);let Le=(r?r.reasoning_effort:p)??`medium`,Re=e=>{let t=s7.get(l7);t&&(s7.has(e)||s7.set(e,t),s7.delete(l7),N(s7.get(e)??t));let n=c7.get(l7);n?.length&&(ee(e,[...c7.get(e)??[],...n]),c7.delete(l7))},ze=async e=>{if(e.length===0)return;B(!0);let t=r;if(!t)try{t=await x(),Re(t.id)}catch(e){q.error(e instanceof Error?e.message:n(`workspace.uploadFailed`)),B(!1);return}for(let r of e){if(!Ne&&r.type.startsWith(`image/`)){q.error(n(`imagesUnsupported`));continue}try{let e=await NY(t.id,r);ee(t.id,t=>[...t,e])}catch(e){q.error(e instanceof Error?e.message:n(`workspace.uploadFailed`))}}B(!1)},Be=e=>{ee(j,t=>t.filter(t=>t.id!==e)),r&&LY(r.id,e)},Ve=(e,t)=>{let n=fne(e,t);ae(n),n&&ce(!1)},He=e=>e===`reference`?`@`:e===`trace`?`#`:`/`,Ue=e=>{requestAnimationFrame(()=>{V.current?.focus(),V.current?.setSelectionRange(e,e)})},We=e=>{if(be)return;let t=He(e),n=V.current,r=n?.selectionStart??M.length,i=n?.selectionEnd??r;P(`${M.slice(0,r)}${t}${M.slice(i)}`),I(null),ce(!1),ae({mode:e,trigger:t,query:``,start:r,end:r+1}),Ue(r+1)},Ge=e=>{let t=e.chip?Lne(M,ie):wne(M,ie,e);P(t.text),I(null),ae(null),ce(!1),e.chip&&U(t=>t.some(t=>Z5(t)===Z5(e.chip))?t:[...t,e.chip]),Ue(t.caret)},Ke=e=>{let t=Z5(e);U(e=>e.filter(e=>Z5(e)!==t))},qe=e=>{let t=S[e];t&&(ge(t.queueId),ve.current=t.text,N(t.text))},Je=e=>{_e.current=pe?``:M,I(null),qe(e)},Ye=(e,t)=>{ge(null),e===`keep`?P(t??M):N(_e.current)},Xe=async()=>{let e=G,t=M.trim();if(!(!e||!t))try{await C(e.queueId,t)===`saved`?Ye(`restore`):(q.info(n(`queueEdit.dispatched`)),Ye(`keep`))}catch{q.error(n(`queueEdit.saveFailed`))}};(0,H.useEffect)(()=>{if(he===null||S.some(e=>e.queueId===he))return;let e=M!==ve.current;w(he)&&q.info(n(`queueEdit.dispatched`)),Ye(e?`keep`:`restore`)},[he,S]);let Ze=()=>{if(xe||!Ae)return;let e=M.trim()||re.map(e=>e.token).join(` `),t={...L.length?{attachmentIds:L.map(e=>e.id)}:{},...re.length?{contextRefs:re.map(pne)}:{}};h(e,L.length||re.length?t:void 0),P(``),ee(j,[]),U([]),ae(null),ce(!1),I(null)},Qe=e=>{if(me[e]===void 0){I(null);return}I(e),P(me[e])};return(0,Y.jsxs)(`div`,{className:`shrink-0`,children:[(0,Y.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:[r===null&&!t&&(0,Y.jsx)(r7,{pinnedProjectId:l,onSelect:e=>void b(e)}),(0,Y.jsx)(`select`,{value:Ce,onChange:e=>void v(e.target.value),"data-agent-interactive":!0,"aria-label":n(`provider.label`),className:`rounded-md border border-border/50 bg-surface/60 px-2 py-1 text-xs text-foreground outline-none hover:bg-surface`,children:Ine.map(e=>(0,Y.jsx)(`option`,{value:e,children:n(`provider.${e}`)},e))}),(0,Y.jsx)(Ene,{provider:Ce,model:r?r.model:d,onSelect:e=>void y(e)}),Fe.length>0&&(0,Y.jsx)(`select`,{value:Le,onChange:e=>void m(e.target.value),"data-agent-interactive":!0,"aria-label":n(`effort.label`),title:n(`effort.label`),className:`rounded-md border border-border/50 bg-surface/60 px-2 py-1 text-xs text-foreground outline-none hover:bg-surface`,children:Fe.map(e=>(0,Y.jsx)(`option`,{value:e,children:n(`effort.${e}`)},e))}),(0,Y.jsx)(`div`,{className:`ml-auto`,children:(0,Y.jsx)(Tne,{level:r?.tier_level??f,onCycle:()=>void _()})})]}),be&&G&&(0,Y.jsxs)(`div`,{"data-testid":`queue-edit-chip`,className:`mb-1 flex items-center gap-1.5 rounded-md border border-accent-highlight/30 bg-accent-highlight/10 px-2 py-1 text-[11px] text-accent-highlight`,children:[(0,Y.jsx)(ws,{className:`h-3 w-3 shrink-0`}),(0,Y.jsx)(`span`,{className:`font-medium`,children:n(`queueEdit.editing`,{n:ye+1,m:S.length})}),(0,Y.jsx)(`span`,{className:`truncate text-foreground/45`,children:n(`queueEdit.hint`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>Ye(`restore`),"aria-label":n(`queueEdit.cancel`),title:n(`queueEdit.cancel`),className:`ml-auto rounded-sm p-0.5 text-foreground/50 hover:bg-muted hover:text-foreground`,children:(0,Y.jsx)(hc,{className:`h-3 w-3`})})]}),pe&&(0,Y.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 px-1 text-[11px] text-foreground/50`,children:[(0,Y.jsx)(Zo,{className:`h-3 w-3`}),n(`history.hint`)]}),L.length>0&&(0,Y.jsx)(`div`,{className:`mb-1.5 flex flex-wrap gap-1.5`,children:L.map(e=>(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-border/60 bg-surface/70 px-2 py-0.5 text-[11px] text-foreground/80`,children:[(0,Y.jsx)(Ss,{className:`h-3 w-3 text-accent-primary`}),(0,Y.jsx)(`span`,{className:`max-w-[160px] truncate`,children:e.filename}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>Be(e.id),"aria-label":n(`close`),className:`rounded-sm hover:bg-muted`,children:(0,Y.jsx)(hc,{className:`h-3 w-3`})})]},e.id))}),D.length>0&&(0,Y.jsx)(`div`,{className:`mb-1.5 flex flex-wrap gap-1.5`,children:D.map((e,t)=>(0,Y.jsx)(Fne,{process:e,accentVariant:je[t%je.length],onKill:e=>void O(e)},e.pid))}),(0,Y.jsxs)(`div`,{className:`relative flex items-end gap-2 rounded-xl border bg-background/60 px-3 py-2 ${be?`border-accent-highlight/50`:pe?`border-accent-info/40`:`border-border/60`}`,onDragOver:e=>{Se&&e.preventDefault()},onDrop:e=>{if(!Se)return;e.preventDefault();let t=Array.from(e.dataTransfer.files);t.length&&ze(t)},children:[ke&&(0,Y.jsx)(Mne,{items:Oe,mode:ie.mode,query:ie.query,activeIndex:W,onActiveIndexChange:oe,onSelect:Ge}),Se&&(0,Y.jsx)(Y.Fragment,{children:(0,Y.jsx)(`input`,{ref:ne,type:`file`,multiple:!0,hidden:!0,onChange:e=>{let t=Array.from(e.target.files??[]);t.length&&ze(t),e.target.value=``}})}),(0,Y.jsx)(Nne,{open:se,canAttach:Se,uploading:te,onToggle:()=>{ce(e=>!e),ae(null)},onClose:()=>ce(!1),onOpenMode:We,onAttachFile:()=>{ce(!1),ne.current?.click()}}),(0,Y.jsxs)(`div`,{className:`flex min-h-[3.25rem] flex-1 flex-wrap items-start gap-1.5`,children:[!be&&(0,Y.jsx)(jne,{chips:re,onRemove:Ke}),(0,Y.jsx)(`textarea`,{ref:V,value:M,autoFocus:e,onChange:e=>{if(be){N(e.target.value);return}pe&&I(null),P(e.target.value),Ve(e.target.value,e.target.selectionStart??e.target.value.length)},onClick:e=>Ve(e.currentTarget.value,e.currentTarget.selectionStart??e.currentTarget.value.length),onKeyDown:e=>{if(e.key===`Tab`&&e.shiftKey){e.preventDefault(),e.stopPropagation(),_();return}if(ke){if(e.key===`ArrowDown`){e.preventDefault(),Oe.length>0&&oe(e=>Math.min(Oe.length-1,e+1));return}if(e.key===`ArrowUp`){e.preventDefault(),Oe.length>0&&oe(e=>Math.max(0,e-1));return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault();let t=Oe[W]??Oe[0];t&&Ge(t);return}if(e.key===`Escape`){e.preventDefault(),ae(null);return}}if(e.key===`Backspace`&&M.length===0&&re.length>0&&!be){e.preventDefault(),U(e=>e.slice(0,-1));return}if(e.key===`Enter`&&!e.shiftKey){e.preventDefault(),be?Xe():Ze();return}if(e.key===`Escape`&&be){e.preventDefault(),e.stopPropagation(),Ye(`restore`);return}let t=e.currentTarget,n=t.selectionStart===0&&t.selectionEnd===0,r=t.selectionStart===M.length&&t.selectionEnd===M.length;if(e.key===`ArrowUp`){if(be){G!==null&&M===G.text&&n&&ye>0&&(e.preventDefault(),qe(ye-1));return}if(S.length>0){n&&(e.preventDefault(),Je(S.length-1));return}!pe&&M===``&&me.length>0?(e.preventDefault(),Qe(me.length-1)):pe&&(e.preventDefault(),Qe(Math.max(0,F-1)));return}if(e.key===`ArrowDown`){if(be){G!==null&&M===G.text&&r&&(e.preventDefault(),ye<S.length-1?qe(ye+1):Ye(`restore`));return}if(S.length>0)return;pe&&(e.preventDefault(),F<me.length-1?Qe(F+1):(I(null),P(``)));return}(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&pe&&I(null)},onPaste:e=>{if(!Se)return;let t=Array.from(e.clipboardData.files);t.length&&(e.preventDefault(),ze(t))},rows:2,disabled:xe,placeholder:re.length>0?``:n(xe?`noProvider.placeholder`:s?`queue.placeholder`:`composerPlaceholder`),"data-agent-interactive":!0,title:be?n(`queueEdit.hint`):pe?n(`history.hint`):void 0,className:`min-h-[3.25rem] max-h-64 min-w-[12rem] flex-1 resize-y bg-transparent text-sm outline-none placeholder:text-foreground/40 disabled:opacity-60 ${pe?`italic text-foreground/50`:`text-foreground`}`})]}),be?(0,Y.jsx)(`button`,{type:`button`,onClick:()=>void Xe(),disabled:xe||!M.trim(),"aria-label":n(`queueEdit.save`),title:n(`queueEdit.save`),className:`rounded-lg bg-accent-highlight p-1.5 text-white transition-opacity hover:opacity-90 disabled:opacity-40`,children:(0,Y.jsx)(to,{className:`h-4 w-4`})}):s&&!Ae?(0,Y.jsx)(`button`,{type:`button`,onClick:()=>void g(),"aria-label":n(`stop`),title:n(`stop`),className:`rounded-lg bg-destructive p-1.5 text-white transition-colors hover:opacity-90`,children:(0,Y.jsx)(tc,{className:`h-4 w-4`,fill:`currentColor`})}):s?(0,Y.jsxs)(`button`,{type:`button`,onClick:Ze,disabled:xe,"aria-label":n(`queue.send`),title:n(`queue.sendHint`),className:`relative rounded-lg bg-accent-info p-1.5 text-white transition-colors hover:opacity-90`,children:[(0,Y.jsx)(Ws,{className:`h-4 w-4`}),(0,Y.jsx)(`span`,{className:`absolute -right-1 -top-1 flex h-3.5 w-3.5 items-center justify-center rounded-full bg-background ring-1 ring-border`,children:(0,Y.jsx)(po,{className:`h-2.5 w-2.5 text-accent-info`})})]}):(0,Y.jsx)(`button`,{type:`button`,onClick:Ze,disabled:xe||!Ae,"aria-label":n(`send`),className:`rounded-lg bg-accent-primary p-1.5 text-white transition-opacity disabled:opacity-40`,children:(0,Y.jsx)(Ws,{className:`h-4 w-4`})})]}),we&&(0,Y.jsx)(Dne,{projectId:we})]})}var Rne=e=>e===`running`||e===`queued`;function zne(e){let t=Math.max(0,Math.floor(e/1e3));if(t<60)return`${t}s`;let n=Math.floor(t/60);return n<60?`${n}m${String(t%60).padStart(2,`0`)}s`:`${Math.floor(n/60)}h ${n%60}m`}function Bne(){try{return df()}catch{return null}}var d7=e=>{if(!e)return null;let t=new Date(e).getTime();return Number.isFinite(t)?t:null};function Vne(e,t,n){let{live:r}=n,[i,a]=(0,H.useState)(!1),[s,c]=(0,H.useState)(null),[l,u]=(0,H.useState)(null),[d,f]=(0,H.useState)(null),[p,m]=(0,H.useState)(null),[h,g]=(0,H.useState)(null),[_,v]=(0,H.useState)(!1),[y,b]=(0,H.useState)(null),[x,S]=(0,H.useState)(()=>Date.now());(0,H.useEffect)(()=>{let n=!1;return fetch(`${o}/api/projects/${e}/jobs/${t}`).then(e=>e.ok?e.json():null).then(e=>{if(n)return;let t=e?.job;t&&(c(typeof t.status==`string`?t.status:null),u(d7(t.started_at)),f(d7(t.finished_at)),typeof t.total_cost_usd==`number`&&m(t.total_cost_usd),typeof t.num_turns==`number`&&g(t.num_turns),v(t.loopPaused===!0),b(typeof t.loopPauseReason==`string`?t.loopPauseReason:null)),a(!0)}).catch(()=>{n||a(!0)}),()=>{n=!0}},[e,t,r]);let C=Rne(s)&&d===null,w=Bne(),T=(0,H.useId)();return(0,H.useEffect)(()=>{if(!w||!r)return;let e=`run-vitals-${t}-${T}`;return w.registerHandler(e,e=>{let n=e;if(n?.type===`loop.run_paused`&&n.loopRunId===t){v(!0),b(typeof n.reason==`string`?n.reason:null),c(`running`),f(null);return}if((n?.type===`loop.run_resumed`||n?.type===`loop.run_completed`)&&n.loopRunId===t){v(!1),b(null);return}n?.jobId===t&&(n.type===`job.turn_done`?(typeof n.totals?.total_cost_usd==`number`&&m(n.totals.total_cost_usd),typeof n.totals?.num_turns==`number`&&g(n.totals.num_turns)):n.type===`job.finalized`&&(typeof n.totals?.total_cost_usd==`number`&&m(n.totals.total_cost_usd),typeof n.totals?.num_turns==`number`&&g(n.totals.num_turns),typeof n.status==`string`&&c(n.status),v(!1),b(null),f(d7(n.timestamp)??Date.now())))}),()=>w.unregisterHandler(e)},[w,r,t,T]),(0,H.useEffect)(()=>{if(!r||!C||l===null)return;let e=setInterval(()=>S(Date.now()),1e3);return()=>clearInterval(e)},[r,C,l]),{status:s,paused:_,pausedReason:y,running:C,elapsedMs:l===null?null:Math.max(0,(d??x)-l),costUsd:p,numTurns:h,loaded:i}}function Hne(e){return e.command.startsWith(`loop:`)?`loop-run`:e.interactive?`interactive`:`job`}var Une=15e3;function Wne(e){if(typeof AbortSignal<`u`&&typeof AbortSignal.timeout==`function`)return AbortSignal.timeout(e)}async function f7(e){let{projectId:t,jobId:n,timeoutMs:r=Une}=e,i=t?`${o}/api/projects/${t}`:af(),a;try{a=await fetch(`${i}/jobs/${n}`,{method:`DELETE`,signal:Wne(r)})}catch(e){let t=e;return{ok:!1,error:t?.name===`TimeoutError`||t?.name===`AbortError`?`Request timed out after ${Math.round(r/1e3)}s`:t?.message||String(e),httpStatus:null}}if(a.ok){let e=`canceled`;try{let t=await a.json();t&&typeof t.status==`string`&&(e=t.status)}catch{}return{ok:!0,status:e}}let s=typeof a.status==`number`?a.status:null,c=s==null?``:` (HTTP ${s})`,l=``;try{typeof a.text==`function`?l=await a.text():typeof a.json==`function`&&(l=JSON.stringify(await a.json()))}catch{}let u=l.slice(0,200).trim();try{let e=JSON.parse(l);e&&typeof e.error==`string`&&e.error&&(u=e.error)}catch{}let d=typeof a.statusText==`string`?a.statusText:``;return{ok:!1,error:u?`${u}${c}`:`HTTP ${s??`?`}${d?` ${d}`:``}`,httpStatus:s}}var Gne=(0,H.lazy)(()=>a(()=>import(`./JobDetailModal-D-BeqsJ6.js`).then(e=>({default:e.JobDetailModal})),__vite__mapDeps([27,1,28,29,30,31]))),Kne={building:Ho,on_review:Ho,pr_draft:Go,pr_ready:Go,implementation_failed:lc,pr_failed:lc,merged:Wo,discarded:lo},qne={building:`text-accent-primary/70`,on_review:`text-accent-primary`,pr_draft:`text-accent-info`,pr_ready:`text-accent-info`,implementation_failed:`text-destructive`,pr_failed:`text-destructive`,merged:`text-accent-success`,discarded:`text-foreground/40`};function Jne(e){let t=/\/pull\/(\d+)/.exec(e);return t?`#${t[1]}`:null}function Yne({projectId:e,runId:t,ticketLabel:n,live:r,onOpen:i,onVitals:a}){let{t:o}=K(`agent`),s=Vne(e,t,{live:r}),c=n??t.slice(0,8),l=s.elapsedMs==null?null:zne(s.elapsedMs),u=s.costUsd!=null&&s.costUsd>0,d=(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`opacity-40`,children:`·`});return(0,H.useEffect)(()=>{a?.(t,{paused:s.paused,pausedReason:s.pausedReason})},[a,t,s.paused,s.pausedReason]),(0,Y.jsxs)(`button`,{type:`button`,"data-agent-interactive":!0,"data-testid":`pr-run-log-chip`,onClick:e=>{e.stopPropagation(),i(t)},title:o(`prCard.viewLog`,{ref:c}),"aria-label":o(`prCard.viewLog`,{ref:c}),className:X(`inline-flex max-w-full cursor-pointer items-center gap-1 rounded-full border px-1.5 py-px align-baseline font-mono text-[0.82em] leading-[1.45] transition-all`,s.paused?`border-accent-warning/45 bg-accent-warning/10 text-accent-warning hover:-translate-y-px hover:border-accent-warning/65 hover:bg-accent-warning/15 hover:shadow-sm`:`border-accent-info/35 bg-accent-info/10 text-accent-info hover:-translate-y-px hover:border-accent-info/60 hover:bg-accent-info/15 hover:shadow-sm`),children:[(s.paused||s.running&&r)&&(0,Y.jsx)(`span`,{"aria-hidden":!0,className:X(`h-1.5 w-1.5 shrink-0 animate-pulse rounded-full`,s.paused?`bg-accent-warning`:`bg-accent-info`)}),(0,Y.jsx)(`span`,{className:`max-w-[160px] truncate`,children:c}),d,(0,Y.jsx)(Hs,{className:`h-3 w-3 shrink-0 opacity-70`}),l&&(0,Y.jsxs)(Y.Fragment,{children:[d,(0,Y.jsx)(`span`,{className:`tabular-nums`,"aria-label":o(`prCard.runElapsedAria`,{elapsed:l}),children:l})]}),u&&(0,Y.jsxs)(Y.Fragment,{children:[d,(0,Y.jsxs)(`span`,{className:`tabular-nums`,"aria-label":o(`prCard.runCostAria`,{cost:`$${s.costUsd.toFixed(2)}`}),children:[`$`,s.costUsd.toFixed(2)]})]})]})}function p7({envelope:e}){let{t}=K(`agent`),{projects:n}=gm(),{openWebView:r,canOpenWebView:i}=DH(),{openRef:a}=W8(),[o,s]=(0,H.useState)(null),[c,l]=(0,H.useState)(!1),[u,d]=(0,H.useState)(!1),f=(0,H.useRef)(null),[p,m]=(0,H.useState)(null),[h,g]=(0,H.useState)({}),[_,v]=(0,H.useState)(null),{decision:y,prUrl:b,prState:x}=e,S=n.find(t=>t.id===e.projectId)?.name??e.projectId,C=y===`pr_draft`&&!b,w=y===`building`&&x===`pr-created`&&!!e.branch,T=e.prNumber?`#${e.prNumber}`:b?Jne(b):null,E=y===`merged`||y===`discarded`;(0,H.useEffect)(()=>{s(null),d(!1)},[y,b]),(0,H.useEffect)(()=>()=>{f.current&&clearTimeout(f.current)},[]);let D=(0,H.useCallback)((e,t)=>{g(n=>{let r=n[e];return r?.paused===t.paused&&r?.pausedReason===t.pausedReason?n:{...n,[e]:t}})},[]),O=async n=>{if(!_){v(n);try{let r=await f7({projectId:e.projectId,jobId:n,kind:`loop-run`});r.ok?q.info(t(`prCard.stopExecutionSent`)):q.error(t(`prCard.stopExecutionFailed`),{description:r.error})}finally{v(null)}}},k=async n=>{if(!c){s(n);try{let r=await WY(e.projectId,{prDeliveryId:e.prDeliveryId,action:n,expectedDecision:y});r.kind===`stale`?q.info(t(`prCard.alreadyResolved`)):r.kind===`blocked`?q.warning(r.reason===`dirty`?t(`prCard.mergeLocalBlockedDirty`,{base:r.base||e.baseBranch}):t(`prCard.mergeLocalBlockedBranch`,{base:r.base||e.baseBranch,current:r.current??`?`})):r.kind===`failed`?q.error(t(`prCard.actionFailed`),{description:r.detail}):n===`poll-merge`&&!r.merged?q.info(t(`prCard.notMergedYet`)):n===`merge-local`&&r.kind===`ok`&&r.decision===`merged`&&q.success(t(`prCard.mergedLocally`,{base:e.baseBranch}))}catch(e){q.error(t(`prCard.actionFailed`),{description:e instanceof Error?e.message:void 0})}finally{s(null)}}},A=async()=>{if(!(o||c)){l(!0);try{let n=await GY(e.projectId,e.prDeliveryId);n.kind===`ok`?q.success(t(`prCard.checkoutSuccess`,{branch:e.branch??``})):q.warning(t(`prCard.checkoutFailed`),{description:n.detail})}catch(e){q.error(t(`prCard.checkoutFailed`),{description:e instanceof Error?e.message:void 0})}finally{l(!1)}}},j=()=>{if(!u){d(!0),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>d(!1),3e3);return}f.current&&clearTimeout(f.current),d(!1),k(`discard`)},M=(e,t)=>{i&&(e.preventDefault(),e.stopPropagation(),r(t))},N=e.ticketIds.length>0&&(0,Y.jsx)(Y.Fragment,{children:e.ticketIds.map(t=>(0,Y.jsxs)(M5,{refTarget:{kind:`ticket`,ticketId:t},onOpen:t=>void a(e.projectId,t),children:[`#`,t]},t))}),P=e.runIds??[],F=t=>P.length===1&&e.ticketIds.length>1?e.ticketIds.map(e=>`#${e}`).join(` `):e.ticketIds[t]==null?null:`#${e.ticketIds[t]}`,I=P.find(e=>h[e]?.paused)??null,L=I?h[I]?.pausedReason??null:null,R=P.length>0&&(0,Y.jsx)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-1.5`,"data-testid":`pr-run-log-chips`,children:P.map((t,n)=>(0,Y.jsx)(Yne,{projectId:e.projectId,runId:t,ticketLabel:F(n),live:y===`building`,onOpen:m,onVitals:D},t))}),z=y===`building`&&I!==null,ee=I?F(P.indexOf(I))??I.slice(0,8):null,te=p&&(0,Y.jsx)(H.Suspense,{fallback:null,children:(0,Y.jsx)(Gne,{jobId:p,projectId:e.projectId,onClose:()=>m(null)})});if(y===`building`)return(0,Y.jsxs)(`div`,{"data-testid":`agent-pr-decision-card`,className:`rounded-xl border border-border/60 bg-card/80 px-3.5 py-2.5 text-xs text-foreground/60 shadow-lg backdrop-blur-xl`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[z?(0,Y.jsx)(lc,{className:`h-3.5 w-3.5 text-accent-warning`}):w?(0,Y.jsx)(Go,{className:`h-3.5 w-3.5 text-accent-info`}):(0,Y.jsx)(cs,{className:`h-3.5 w-3.5 animate-spin text-accent-primary/70`}),(0,Y.jsx)(`span`,{className:X(!w&&!z&&`animate-pulse`,z&&`text-accent-warning`),children:t(z?`prCard.title.paused`:w?`prCard.title.buildingExistingPr`:`prCard.title.building`)})]}),N&&(0,Y.jsx)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-1.5 pl-[22px]`,children:N}),w&&(0,Y.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-1.5 pl-[22px]`,children:[b?(0,Y.jsxs)(`a`,{href:b,target:`_blank`,rel:`noreferrer`,onClick:e=>M(e,b),title:b,"data-agent-interactive":!0,className:`inline-flex items-center gap-1 rounded-full border border-accent-info/40 bg-accent-info/10 px-2 py-0.5 font-mono text-[11px] text-accent-info transition-colors hover:border-accent-info/60 hover:bg-accent-info/15`,children:[(0,Y.jsx)(Go,{className:`h-3 w-3`}),T??t(`prCard.openPr`),(0,Y.jsx)(Oo,{className:`h-2.5 w-2.5 opacity-60`})]}):(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-accent-info/40 bg-accent-info/10 px-2 py-0.5 font-mono text-[11px] text-accent-info`,children:[(0,Y.jsx)(Go,{className:`h-3 w-3`}),T??t(`prCard.existingPr`)]}),(0,Y.jsxs)(`span`,{title:t(`git.branch`),className:`inline-flex min-w-0 max-w-full items-center gap-1 rounded-full border border-border/60 bg-surface/60 px-2 py-0.5 font-mono text-[11px] text-foreground/70`,children:[(0,Y.jsx)(Ho,{className:`h-3 w-3 shrink-0 text-accent-primary/70`}),(0,Y.jsx)(`span`,{className:`truncate`,children:e.branch})]})]}),z&&I&&(0,Y.jsxs)(`div`,{className:`mt-2 flex min-w-0 flex-wrap items-center gap-1.5 rounded-md border border-accent-warning/35 bg-accent-warning/10 px-2 py-1.5 text-[11px] text-accent-warning`,"data-testid":`pr-run-paused-actions`,children:[(0,Y.jsx)(lc,{className:`h-3.5 w-3.5 shrink-0`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,title:L??void 0,children:[ee?t(`prCard.pausedForRun`,{ref:ee}):t(`prCard.paused`),L?`: ${L}`:``]}),(0,Y.jsxs)(`button`,{type:`button`,"data-agent-interactive":!0,onClick:e=>{e.stopPropagation(),m(I)},className:`inline-flex items-center gap-1 rounded-md border border-accent-warning/40 bg-surface/70 px-2 py-0.5 font-medium text-accent-warning transition-colors hover:bg-accent-warning/15`,children:[(0,Y.jsx)(Ds,{className:`h-3 w-3`}),t(`prCard.resume`)]}),(0,Y.jsxs)(`button`,{type:`button`,"data-agent-interactive":!0,disabled:_===I,onClick:e=>{e.stopPropagation(),O(I)},className:`inline-flex items-center gap-1 rounded-md border border-destructive/40 bg-destructive/10 px-2 py-0.5 font-medium text-destructive transition-colors hover:bg-destructive/15 disabled:cursor-default disabled:opacity-60`,children:[_===I?(0,Y.jsx)(cs,{className:`h-3 w-3 animate-spin`}):(0,Y.jsx)(tc,{className:`h-3 w-3`}),t(`prCard.stopExecution`)]})]}),R&&(0,Y.jsx)(`div`,{className:`pl-[22px]`,children:R}),(0,Y.jsx)(`p`,{className:`mt-1 pl-[22px] text-[11px] leading-4 text-foreground/40`,children:t(w?`prCard.buildingExistingPrHint`:`prCard.buildingHint`)}),te]});let B=Kne[y],ne=t(C?`prCard.title.pr_draft_degraded`:`prCard.title.${y}`),V=X(`inline-flex items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs transition-colors disabled:cursor-default disabled:opacity-60`,u?`border-destructive/50 bg-destructive/10 font-medium text-destructive hover:bg-destructive/20`:`border-border/60 text-foreground/70 hover:border-destructive/40 hover:bg-destructive/10 hover:text-destructive`),re=o!==null||c,U=(0,Y.jsx)(cs,{className:`h-3 w-3 animate-spin`}),ie=(e,t)=>(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>void k(e),disabled:re,"data-agent-interactive":!0,className:`inline-flex items-center gap-1.5 rounded-md bg-accent-primary px-2.5 py-1 text-xs font-medium text-white transition-colors hover:bg-accent-primary/90 disabled:cursor-default disabled:opacity-60`,children:[o===e&&U,t]}),ae=b&&e.branch&&(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>void A(),disabled:re,"data-testid":`agent-pr-checkout`,"data-agent-interactive":!0,title:t(`prCard.checkoutTooltip`,{branch:e.branch}),className:`inline-flex items-center gap-1 rounded-md border border-border/60 px-2 py-1 text-[11px] font-medium text-foreground/70 transition-colors hover:border-accent-primary/40 hover:bg-accent-primary/10 disabled:pointer-events-none disabled:opacity-50`,children:[c?U:(0,Y.jsx)(Ho,{className:`h-3 w-3`}),t(`prCard.checkout`)]}),W=(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>void k(`merge-local`),disabled:re,"data-testid":`agent-pr-merge-local`,"data-agent-interactive":!0,title:t(`prCard.mergeLocalTooltip`,{base:e.baseBranch}),className:`inline-flex items-center gap-1 rounded-md border border-accent-success/40 bg-accent-success/10 px-2 py-1 text-[11px] font-medium text-accent-success transition-colors hover:bg-accent-success/20 disabled:pointer-events-none disabled:opacity-50`,children:[o===`merge-local`&&U,t(`prCard.mergeLocal`)]}),oe=(0,Y.jsxs)(`button`,{type:`button`,onClick:j,disabled:re,"data-agent-interactive":!0,className:V,children:[o===`discard`&&U,t(u?`prCard.confirmDiscard`:`prCard.discard`)]}),se=b&&(0,Y.jsxs)(`a`,{href:b,target:`_blank`,rel:`noreferrer`,onClick:e=>M(e,b),title:b,"data-agent-interactive":!0,className:`inline-flex items-center gap-1 rounded-full border border-border/60 bg-surface/60 px-2 py-0.5 font-mono text-[11px] text-accent-info transition-colors hover:border-accent-info/50 hover:bg-accent-info/10`,children:[(0,Y.jsx)(Go,{className:`h-3 w-3`}),T??t(`prCard.openPr`),(0,Y.jsx)(Oo,{className:`h-2.5 w-2.5 opacity-60`})]});return(0,Y.jsxs)(`div`,{"data-testid":`agent-pr-decision-card`,className:X(`rounded-xl border border-border/60 bg-card/80 px-3.5 py-3 shadow-lg backdrop-blur-xl`,y===`merged`&&`border-accent-success/30`,y===`discarded`&&`opacity-70`),children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(B,{className:X(`h-4 w-4 shrink-0`,qne[y])}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-foreground`,children:ne}),(0,Y.jsx)(`span`,{className:`max-w-[140px] shrink-0 truncate text-[11px] text-foreground/50`,title:S,children:S}),(0,Y.jsx)(`span`,{className:`shrink-0 rounded-full border border-border/60 bg-surface/60 px-2 py-0.5 text-[10px] font-medium uppercase tracking-wide text-foreground/60`,children:t(`prCard.rail`,{index:e.railIndex+1})})]}),(0,Y.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5`,children:[(0,Y.jsxs)(`span`,{title:t(`prCard.base`),className:`inline-flex items-center gap-1 rounded-full border border-border/60 bg-surface/60 px-2 py-0.5 font-mono text-[11px] text-foreground/70`,children:[(0,Y.jsx)(Ho,{className:`h-3 w-3 text-accent-primary/70`}),`→ `,e.baseBranch]}),(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-border/60 bg-surface/60 px-2 py-0.5 text-[11px] text-foreground/70`,children:[(0,Y.jsx)(oc,{className:`h-3 w-3 text-accent-secondary/80`}),t(`prCard.specCount`,{count:e.ticketIds.length})]}),N,se]}),R,!E&&!b&&(x===`pushed`||x===`local-only`)&&(0,Y.jsxs)(`p`,{className:`mt-2 flex items-start gap-1.5 text-[11px] leading-4 text-accent-warning`,children:[(0,Y.jsx)(lc,{className:`mt-px h-3 w-3 shrink-0`}),t(x===`local-only`?`prCard.degraded.localOnly`:`prCard.degraded.pushed`)]}),(0,Y.jsx)(H3,{mode:`wait`,initial:!1,children:(0,Y.jsxs)(V8.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.2,ease:`easeOut`},className:`mt-2.5`,children:[y===`on_review`&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[ie(`create-pr`,t(`prCard.createPr`)),W,oe]}),y===`pr_draft`&&!C&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[ae,ie(`publish`,t(`prCard.publish`)),oe]}),C&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[ie(`create-pr`,t(`prCard.retryPr`)),W,oe]}),y===`pr_ready`&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[ae,ie(`poll-merge`,t(`prCard.checkMerge`)),oe]}),y===`pr_failed`&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[ae,ie(`create-pr`,t(`prCard.retry`)),!b&&W,oe]}),y===`implementation_failed`&&(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[(0,Y.jsxs)(`p`,{className:`flex items-start gap-1.5 text-[11px] leading-4 text-destructive`,children:[(0,Y.jsx)(lc,{className:`mt-px h-3 w-3 shrink-0`}),t(`prCard.implementationFailedNote`)]}),(0,Y.jsx)(`div`,{className:`flex items-center gap-1.5`,children:oe})]}),y===`merged`&&(0,Y.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs font-medium text-accent-success`,children:[(0,Y.jsx)(co,{className:`h-3.5 w-3.5`}),t(`prCard.mergedNote`)]}),y===`discarded`&&(0,Y.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs text-foreground/50`,children:[(0,Y.jsx)(lo,{className:`h-3.5 w-3.5`}),t(`prCard.discardedNote`)]})]},`${y}-${b??``}`)}),te]})}var Xne={building:`border-accent-primary/40 bg-accent-primary/10 text-accent-primary`,on_review:`border-accent-primary/40 bg-accent-primary/10 text-accent-primary`,pr_draft:`border-accent-info/40 bg-accent-info/10 text-accent-info`,pr_ready:`border-accent-info/40 bg-accent-info/10 text-accent-info`,implementation_failed:`border-destructive/40 bg-destructive/10 text-destructive`,pr_failed:`border-destructive/40 bg-destructive/10 text-destructive`,merged:`border-accent-success/40 bg-accent-success/10 text-accent-success`,discarded:`border-border/60 bg-surface/60 text-foreground/50`};function m7({decision:e}){let{t}=K(`agent`);return(0,Y.jsx)(`span`,{"data-testid":`pr-decision-pill`,className:X(`inline-flex shrink-0 items-center rounded-full border px-1.5 py-px text-[10px] font-medium uppercase tracking-wide`,Xne[e]),children:t(`prCard.pinned.state.${e}`)})}var h7=e=>`specrails-desktop:agent-pr-dock-collapsed:${e}`,g7=e=>`specrails-desktop:agent-pr-dock-card-collapsed:${e}`;function _7(e){try{return sessionStorage.getItem(h7(e))===`1`}catch{return!1}}function Zne(e,t){try{t?sessionStorage.setItem(h7(e),`1`):sessionStorage.removeItem(h7(e))}catch{}}function v7(e){try{let t=sessionStorage.getItem(g7(e)),n=t?JSON.parse(t):[];return new Set(Array.isArray(n)?n.filter(e=>typeof e==`string`):[])}catch{return new Set}}function Qne(e,t){try{t.size===0?sessionStorage.removeItem(g7(e)):sessionStorage.setItem(g7(e),JSON.stringify([...t]))}catch{}}function $ne({pinned:e,conversationId:t,inline:n}){let{t:r}=K(`agent`),[i,a]=(0,H.useState)(()=>_7(t)),[o,s]=(0,H.useState)(()=>v7(t));if((0,H.useEffect)(()=>{a(_7(t)),s(v7(t))},[t]),e.length===0)return null;let c=e[e.length-1],l=e=>{Zne(t,e),a(e)},u=e=>{s(n=>{let r=new Set(n);return r.has(e)?r.delete(e):r.add(e),Qne(t,r),r})},d=e=>{let t=r(`prCard.rail`,{index:e.railIndex+1}),n=e.ticketIds.map(e=>`#${e}`).join(` `);return n?`${t} · ${n}`:t};return(0,Y.jsx)(V8.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,y:8},transition:{duration:.2,ease:`easeOut`},"data-testid":`agent-pr-pinned-dock`,className:X(`shrink-0`,n?`px-4 pb-2`:`px-3 pb-2`),children:(0,Y.jsx)(`div`,{className:X(n&&`mx-auto w-full max-w-[680px]`),children:i?(0,Y.jsxs)(`button`,{type:`button`,"data-testid":`agent-pr-dock-expand`,"data-agent-interactive":!0,onClick:()=>l(!1),"aria-label":r(`prCard.pinned.expand`),title:r(`prCard.pinned.expand`),className:`flex w-full items-center gap-2 rounded-xl border border-border/60 bg-card/80 px-3 py-1.5 text-xs text-foreground/70 shadow-lg backdrop-blur-xl transition-colors hover:border-accent-primary/40 hover:bg-surface/60`,children:[(0,Y.jsx)(Ts,{className:`h-3.5 w-3.5 shrink-0 text-accent-primary/70`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:r(`prCard.pinned.collapsed`,{count:e.length})}),(0,Y.jsx)(m7,{decision:c.envelope.decision}),(0,Y.jsx)(ao,{className:`h-3.5 w-3.5 shrink-0 opacity-60`})]}):(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between px-1`,children:[(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] font-medium uppercase tracking-wide text-foreground/45`,children:[(0,Y.jsx)(Ts,{className:`h-3 w-3 text-accent-primary/60`}),r(`prCard.pinned.label`),e.length>1&&(0,Y.jsx)(`span`,{className:`rounded-full border border-border/60 bg-surface/60 px-1.5 py-px text-[9px] tabular-nums text-foreground/55`,children:e.length})]}),(0,Y.jsx)(`button`,{type:`button`,"data-testid":`agent-pr-dock-collapse`,"data-agent-interactive":!0,onClick:()=>l(!0),"aria-label":r(`prCard.pinned.collapse`),title:r(`prCard.pinned.collapse`),className:`rounded p-0.5 text-foreground/45 transition-colors hover:bg-surface hover:text-foreground`,children:(0,Y.jsx)(no,{className:`h-3.5 w-3.5`})})]}),(0,Y.jsx)(`div`,{"data-testid":`agent-pr-dock-stack`,className:`max-h-[45vh] space-y-1.5 overflow-y-auto overscroll-contain`,children:e.map(e=>{let t=e.envelope.prDeliveryId,n=o.has(t);return(0,Y.jsxs)(`div`,{"data-testid":`agent-pr-dock-card`,className:`space-y-1`,children:[(0,Y.jsxs)(`button`,{type:`button`,"data-testid":`agent-pr-dock-card-toggle`,"data-agent-interactive":!0,onClick:()=>u(t),"aria-expanded":!n,"aria-label":r(n?`prCard.pinned.expandCard`:`prCard.pinned.collapseCard`),title:r(n?`prCard.pinned.expandCard`:`prCard.pinned.collapseCard`),className:X(`flex w-full items-center gap-2 rounded-lg border px-2.5 py-1 text-[11px] text-foreground/70 transition-colors`,n?`border-border/60 bg-card/80 shadow backdrop-blur-xl hover:border-accent-primary/40 hover:bg-surface/70`:`border-transparent bg-transparent hover:bg-surface/50`),children:[(0,Y.jsx)(Go,{className:`h-3 w-3 shrink-0 text-accent-primary/70`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left font-medium`,children:d(e.envelope)}),(0,Y.jsx)(m7,{decision:e.envelope.decision}),n?(0,Y.jsx)(ao,{className:`h-3 w-3 shrink-0 opacity-60`}):(0,Y.jsx)(no,{className:`h-3 w-3 shrink-0 opacity-60`})]}),!n&&(0,Y.jsx)(p7,{envelope:e.envelope})]},e.messageId)})})]})})})}function ere(e){return e?e.charAt(0).toUpperCase()+e.slice(1):`Unknown`}function y7(e,t,n,r){let i=e.title?.trim()||`Untitled mission`,a=r?.exportedAt??new Date().toISOString(),o=[`Mission: ${i}`,`Mission ID: ${e.id}`];return n?.name&&o.push(`Project: ${n.name}`),n?.path&&o.push(`Project path: ${n.path}`),o.push(`Exported at: ${a}`,``,`Messages:`),t.length===0?(o.push(`No messages loaded.`),o.join(`
144
144
  `)):(t.forEach((e,t)=>{t>0&&o.push(``),o.push(`[${e.created_at}] ${ere(e.role)}`,e.content)}),o.join(`
145
- `))}function tre(e,t){let n=(e??``).normalize(`NFKD`).replace(/[\u0300-\u036f]/g,``).toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``),r=t.trim()||`mission`;return`${n||r}.txt`}function nre(){let{t:e}=K(`agent`),{active:t,messages:n,renameConversation:r,deleteConversation:i,startNewConversation:a,favoriteConversationIds:o,toggleFavoriteConversation:s}=N7(),{projects:c}=gm(),[l,u]=(0,H.useState)(!1),[d,f]=(0,H.useState)(!1),[p,m]=(0,H.useState)(``),[h,g]=(0,H.useState)(null),[_,v]=(0,H.useState)(!1),y=(0,H.useRef)(null),b=(0,H.useRef)(null),x=t?.pinned_project_id?c.find(e=>e.id===t.pinned_project_id)??null:null,S=t?.title?.trim()||e(`header.untitled`),C=t?o.has(t.id):!1;(0,H.useEffect)(()=>{if(!l)return;let e=e=>{y.current&&!y.current.contains(e.target)&&u(!1)},t=e=>{e.key===`Escape`&&u(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[l]),(0,H.useEffect)(()=>{l||v(!1)},[l]),(0,H.useEffect)(()=>{d&&(b.current?.focus(),b.current?.select())},[d]);let w=(0,H.useCallback)(()=>{m(t?.title??``),f(!0),u(!1)},[t?.title]),T=(0,H.useCallback)(async()=>{if(t&&(f(!1),(t.title??``)!==p.trim()))try{await r(t.id,p)}catch{q.error(e(`header.renameFailed`))}},[t,p,r,e]),E=(0,H.useCallback)(async(t,n)=>{u(!1);try{await navigator.clipboard.writeText(t),g(n),setTimeout(()=>g(e=>e===n?null:e),1400)}catch{q.error(e(`header.copyFailed`))}},[e]),D=(0,H.useCallback)(async()=>{if(t){u(!1);try{await navigator.clipboard.writeText(y7(t,n,x)),g(`transcript`),q.success(e(`header.copyTranscriptSuccess`,{defaultValue:`Transcript copied`})),setTimeout(()=>g(e=>e===`transcript`?null:e),1400)}catch{q.error(e(`header.copyTranscriptFailed`,{defaultValue:`Could not copy transcript`}))}}},[t,n,x,e]),O=(0,H.useCallback)(()=>{if(t){u(!1);try{let r=y7(t,n,x),i=new Blob([r],{type:`text/plain;charset=utf-8`}),a=URL.createObjectURL(i),o=document.createElement(`a`);o.href=a,o.download=tre(t.title,t.id),document.body.appendChild(o),o.click(),o.remove(),URL.revokeObjectURL(a),q.success(e(`header.exportTranscriptSuccess`,{defaultValue:`Transcript export started`}))}catch{q.error(e(`header.exportTranscriptFailed`,{defaultValue:`Could not export transcript`}))}}},[t,n,x,e]),k=(0,H.useCallback)(async()=>{if(t){u(!1),v(!1);try{await i(t.id),a(t.pinned_project_id)}catch{q.error(e(`header.deleteFailed`))}}},[t,i,a,e]),A=(0,H.useCallback)(()=>{t&&(s(t.id),u(!1))},[t,s]);if(!t)return null;let j=[{id:`name`,label:e(`header.copyName`),value:t.title??S},{id:`id`,label:e(`header.copyId`),value:t.id},...x?[{id:`project`,label:e(`header.copyProject`),value:x.name},{id:`path`,label:e(`header.copyProjectPath`),value:x.path}]:[]];return(0,Y.jsxs)(`div`,{ref:y,"data-agent-interactive":!0,className:`relative flex h-12 shrink-0 items-center gap-2 border-b border-border px-4`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5 text-sm`,children:[x&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`max-w-[42%] shrink-0 truncate font-mono text-[12px] text-foreground/35`,title:x.path,children:x.path}),(0,Y.jsx)(io,{className:`h-3.5 w-3.5 shrink-0 text-foreground/25`,"aria-hidden":!0})]}),d?(0,Y.jsx)(`input`,{ref:b,value:p,onChange:e=>m(e.target.value),onBlur:()=>void T(),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),T()):e.key===`Escape`&&(e.preventDefault(),f(!1))},placeholder:e(`header.renamePlaceholder`),className:`min-w-0 flex-1 rounded-md border border-accent-primary/40 bg-surface/60 px-2 py-0.5 text-sm text-foreground outline-none focus:border-accent-primary/70`,maxLength:200}):(0,Y.jsx)(`button`,{type:`button`,onDoubleClick:w,title:e(`header.renameHint`),className:`min-w-0 flex-1 truncate text-left font-medium text-foreground/85`,children:S})]}),(0,Y.jsx)(`button`,{type:`button`,"data-testid":`agent-conv-menu-trigger`,"aria-label":e(`header.menu`),"aria-haspopup":`menu`,"aria-expanded":l,onClick:()=>u(e=>!e),className:X(`flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-foreground/45 transition-colors hover:bg-surface hover:text-foreground/80`,l&&`bg-surface text-foreground/80`),children:(0,Y.jsx)(Do,{className:`h-4 w-4`})}),(0,Y.jsx)(H3,{children:l&&(0,Y.jsx)(V8.div,{role:`menu`,"data-testid":`agent-conv-menu`,initial:{opacity:0,y:-4,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-4,scale:.98},transition:{duration:.14,ease:`easeOut`},className:`absolute right-3 top-11 z-50 min-w-[220px] overflow-hidden rounded-xl border border-border/50 bg-card/95 p-1 shadow-2xl backdrop-blur-xl`,children:_?(0,Y.jsxs)(`div`,{className:`p-2`,"data-testid":`agent-conv-delete-confirm`,children:[(0,Y.jsx)(`p`,{className:`px-1 pb-2.5 text-xs leading-relaxed text-foreground/70`,children:e(`header.deleteConfirm`)}),(0,Y.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,Y.jsx)(`button`,{type:`button`,"data-testid":`agent-conv-delete-confirm-btn`,onClick:()=>void k(),className:`flex-1 rounded-lg bg-destructive/90 px-2.5 py-1.5 text-xs font-medium text-white transition-colors hover:bg-destructive`,children:e(`header.delete`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>v(!1),className:`flex-1 rounded-lg border border-border/60 px-2.5 py-1.5 text-xs text-foreground/80 transition-colors hover:bg-surface/80`,children:e(`common:actions.cancel`)})]})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`agent-conv-rename`,onClick:w,className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-sm text-foreground/85 transition-colors hover:bg-surface/80`,children:[(0,Y.jsx)(ws,{className:`h-3.5 w-3.5 shrink-0 text-foreground/50`}),e(`header.rename`)]}),(0,Y.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`agent-conv-favorite`,onClick:A,className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-sm text-foreground/85 transition-colors hover:bg-surface/80`,children:[(0,Y.jsx)(Xo,{className:X(`h-3.5 w-3.5 shrink-0`,C?`text-accent-primary`:`text-foreground/50`),fill:C?`currentColor`:`none`}),e(C?`header.removeFavorite`:`header.addFavorite`)]}),(0,Y.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`agent-conv-delete`,onClick:()=>v(!0),className:`group/del flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-sm text-foreground/85 transition-colors hover:bg-destructive/10 hover:text-destructive`,children:[(0,Y.jsx)(cc,{className:`h-3.5 w-3.5 shrink-0 text-foreground/50 group-hover/del:text-destructive`}),e(`header.delete`)]}),(0,Y.jsx)(`div`,{className:`my-1 h-px bg-border/50`}),(0,Y.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`agent-conv-copy-transcript`,onClick:()=>void D(),className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-sm text-foreground/85 transition-colors hover:bg-surface/80`,children:[h===`transcript`?(0,Y.jsx)(to,{className:`h-3.5 w-3.5 shrink-0 text-accent-success`}):(0,Y.jsx)(bo,{className:`h-3.5 w-3.5 shrink-0 text-foreground/50`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:e(`header.copyTranscript`,{defaultValue:`Copy transcript`})})]}),(0,Y.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`agent-conv-export-transcript`,onClick:O,className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-sm text-foreground/85 transition-colors hover:bg-surface/80`,children:[(0,Y.jsx)(To,{className:`h-3.5 w-3.5 shrink-0 text-foreground/50`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:e(`header.exportTranscript`,{defaultValue:`Export transcript (.txt)`})})]}),j.map(e=>e===`divider`?null:(0,Y.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`agent-conv-copy-${e.id}`,onClick:()=>void E(e.value,e.id),className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-sm text-foreground/85 transition-colors hover:bg-surface/80`,children:[h===e.id?(0,Y.jsx)(to,{className:`h-3.5 w-3.5 shrink-0 text-accent-success`}):(0,Y.jsx)(bo,{className:`h-3.5 w-3.5 shrink-0 text-foreground/50`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:e.label})]},e.id))]})})})]})}var rre=new Set([`building`,`on_review`,`pr_draft`,`implementation_failed`,`pr_failed`]);function b7(e){return rre.has(e)}function ire(e){let t=new Map,n=[];for(let r of e){if(r.role!==`system`)continue;let e=UY(r.content);e&&(t.set(r.id,e),b7(e.decision)&&n.push({messageId:r.id,envelope:e}))}return{byMessageId:t,pinned:n}}var are=(0,H.lazy)(()=>a(()=>import(`./JobDetailModal-CJI7qRkm.js`).then(e=>({default:e.JobDetailModal})),__vite__mapDeps([27,1,28,29,30,31]))),ore=(0,H.lazy)(()=>a(()=>import(`./LoopPreviewModal-CwpKcv0Y.js`).then(e=>({default:e.LoopPreviewModal})),__vite__mapDeps([32,1,30,33]))),x7=new Set;function S7({variant:e}){let{t}=K(`agent`),{active:n,messages:r,streamingText:i,isStreaming:a,liveTools:o,queuedMessages:s,mcpEnabled:c,enablingMcp:l,enableMcpServer:u,providersReady:d,cycleTier:f,send:p}=N7(),m=(0,H.useRef)(null),h=hR(i,a),{openRef:g,jobRef:_,closeJobRef:v,loopRef:y,closeLoopRef:b}=W8(),x=n?.pinned_project_id??null,[S,C]=(0,H.useState)(new Map),w=(0,H.useMemo)(()=>{let e=new Set;for(let t of r)for(let n of t.attachment_ids??[])e.add(n);return[...e].sort()},[r]).join(`\0`);(0,H.useEffect)(()=>{let e=w?w.split(`\0`):[];if(!n?.id||e.length===0){C(new Map);return}let t=!1,r=new Set(e);return PY(n.id).then(e=>{t||C(new Map(e.filter(e=>r.has(e.id)).map(e=>[e.id,e])))}).catch(()=>{t||C(new Map)}),()=>{t=!0}},[n?.id,w]);let T=(0,H.useMemo)(()=>x?e=>{g(x,e)}:void 0,[x,g]),E=BU().id===`code-rain`?t(`emptyTitleCodeRain`):t(`emptyTitle`),D=(0,H.useMemo)(()=>ire(r),[r]),O=(0,H.useRef)(!0),k=()=>{let e=m.current;e&&(O.current=e.scrollHeight-e.scrollTop-e.clientHeight<48)};(0,H.useEffect)(()=>{O.current&&m.current?.scrollTo?.({top:m.current.scrollHeight,behavior:`auto`})},[r.length,h,o.length,s.length]);let A=e=>{e.shiftKey&&(e.key===`Tab`||e.code===`Tab`)&&(e.preventDefault(),e.stopPropagation(),f())},j=e===`inline`,M=j?`mx-auto flex w-full max-w-[820px] flex-1 flex-col overflow-hidden`:`flex flex-1 flex-col overflow-hidden`;return(0,Y.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden `,onKeyDown:A,children:[d===!1&&(0,Y.jsxs)(`div`,{className:`flex items-start gap-2 border-b border-border/50 bg-accent-warning/10 px-3 py-2 text-xs text-foreground`,children:[(0,Y.jsx)(_s,{className:`mt-0.5 h-4 w-4 shrink-0 text-accent-warning`}),(0,Y.jsxs)(`div`,{className:`flex-1`,children:[(0,Y.jsx)(`p`,{className:`font-medium`,children:t(`noProvider.title`)}),(0,Y.jsx)(`p`,{className:`mt-0.5 text-foreground/70`,children:t(`noProvider.body`)})]})]}),d!==!1&&!c&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/50 bg-accent-warning/10 px-3 py-2 text-xs text-foreground`,children:[(0,Y.jsx)(Js,{className:`h-4 w-4 shrink-0 text-accent-warning`}),(0,Y.jsx)(`span`,{className:`flex-1`,children:t(`degraded.body`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>void u(),disabled:l,className:`rounded-md bg-accent-primary px-2 py-1 text-xs font-medium text-white disabled:opacity-60`,children:t(l?`degraded.enabling`:`degraded.enable`)})]}),j&&n&&(0,Y.jsx)(nre,{}),(0,Y.jsxs)(`div`,{className:M,children:[(0,Y.jsxs)(V8.div,{ref:m,onScroll:k,initial:j?{opacity:0,y:8}:!1,animate:{opacity:1,y:0},transition:{duration:.35,ease:`easeOut`},className:`flex-1 space-y-5 overflow-y-auto px-4 py-4`,children:[r.length===0&&!a&&(0,Y.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center text-center text-foreground/50`,children:[(0,Y.jsx)(qa,{className:`mb-2 h-8 w-8 text-accent-primary/60`}),(0,Y.jsx)(`p`,{className:`text-sm font-medium text-foreground/70`,children:E}),(0,Y.jsx)(`p`,{className:`mt-1 max-w-[280px] text-xs`,children:t(`emptyHint`)})]}),r.map((e,n)=>{if(e.role===`system`){let n=D.byMessageId.get(e.id);return n?b7(n.decision)?(0,Y.jsxs)(`div`,{"data-testid":`agent-pr-pinned-marker`,className:`flex items-center gap-2 rounded-lg border border-border/40 bg-surface/30 px-3 py-1.5 text-[11px] text-foreground/45 backdrop-blur-sm`,children:[(0,Y.jsx)(Ts,{className:`h-3 w-3 shrink-0 text-accent-primary/50`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t(`prCard.pinned.marker`)}),(0,Y.jsx)(m7,{decision:n.decision})]},e.id):(0,Y.jsx)(p7,{envelope:n},e.id):(x7.has(e.id)||(x7.add(e.id),console.warn(`[agent-chat] skipping unrenderable system message ${e.id}`)),null)}return(0,Y.jsx)(W5,{role:e.role,content:e.content,createdAt:e.created_at,isLast:!a&&n===r.length-1,onPickOption:e=>void p(e),refsProjectId:x,onOpenRef:T,contextRefs:e.context_refs,conversationId:e.conversation_id,attachments:(e.attachment_ids??[]).map(e=>S.get(e)).filter(e=>!!e)},e.id)}),a&&(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[h&&(0,Y.jsx)(W5,{role:`assistant`,content:h,streaming:!0}),(0,Y.jsx)(q8,{tool:o.length?o[o.length-1].tool:null})]}),s.length>0&&(0,Y.jsx)(`div`,{className:`space-y-2`,"data-testid":`agent-queued-messages`,children:s.map(e=>(0,Y.jsx)(`div`,{className:`flex justify-end`,children:(0,Y.jsxs)(`div`,{className:`max-w-[85%] whitespace-pre-wrap rounded-2xl rounded-br-sm border border-dashed border-border/70 bg-foreground/[0.03] px-3.5 py-2 text-sm text-foreground/60`,children:[(0,Y.jsxs)(`span`,{className:`mb-0.5 flex items-center justify-end gap-1 text-[10px] font-medium uppercase tracking-wide text-foreground/45`,children:[(0,Y.jsx)(po,{className:`h-3 w-3`}),t(`queue.queued`)]}),(0,Y.jsx)(U5,{content:e.text,contextRefs:e.contextRefs})]})},e.queueId))})]}),(0,Y.jsx)(H3,{initial:!1,children:n&&D.pinned.length>0&&(0,Y.jsx)($ne,{pinned:D.pinned,conversationId:n.id,inline:j},`agent-pr-pinned-dock`)}),j?(0,Y.jsx)(`div`,{className:`shrink-0 px-4 pb-4`,children:(0,Y.jsx)(V8.div,{layoutId:`agent-composer-dock`,transition:{layout:{type:`spring`,stiffness:350,damping:34}},className:`mx-auto w-full max-w-[680px] rounded-2xl border border-border/60 bg-card/90 p-3 shadow-2xl backdrop-blur-xl`,children:(0,Y.jsx)(u7,{})})}):(0,Y.jsx)(`div`,{className:`shrink-0 border-t border-border/50 bg-surface/30 p-3`,children:(0,Y.jsx)(u7,{hideProjectSelector:!0})})]}),_&&(0,Y.jsx)(H.Suspense,{fallback:null,children:(0,Y.jsx)(are,{jobId:_.jobId,projectId:_.projectId,onClose:v})}),y&&(0,Y.jsx)(H.Suspense,{fallback:null,children:(0,Y.jsx)(ore,{loop:y,onClose:b})})]})}var sre=8,cre=3e3;function lre(){let{t:e}=K(`agent`),{conversations:t,active:n,selectConversation:r,deleteConversation:i,startNewConversation:a,streamingConversationIds:o,liveByConversation:s}=N7(),[c,l]=(0,H.useState)(!1),[u,d]=(0,H.useState)(``),[f,p]=(0,H.useState)(0),[m,h]=(0,H.useState)(null),g=(0,H.useRef)(null),_=(0,H.useRef)(null),v=(0,H.useRef)(null),y=(0,H.useMemo)(()=>{let e=e=>{let t=Date.parse(e.updated_at);return Number.isNaN(t)?0:t};return[...t].sort((t,n)=>e(n)-e(t))},[t]),b=t.length>sre,x=(0,H.useMemo)(()=>{let t=u.trim().toLowerCase();if(!t)return y;let n=e(`mission.untitled`).toLowerCase();return y.filter(e=>(e.title?.trim().toLowerCase()||n).includes(t))},[y,u,e]),S=x.length+1,C=(0,H.useCallback)(()=>{g.current&&clearTimeout(g.current),g.current=null,h(null)},[]);(0,H.useEffect)(()=>()=>{g.current&&clearTimeout(g.current)},[]),(0,H.useEffect)(()=>{if(!c)return;let e=e=>{_.current&&!_.current.contains(e.target)&&T()};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[c]);let w=()=>{let e=n?y.findIndex(e=>e.id===n.id):-1;p(e>=0?e+1:0),l(!0)},T=()=>{l(!1),d(``),C()},E=e=>{e!==n?.id&&r(e),T()},D=()=>{a(null),T()},O=e=>{g.current&&clearTimeout(g.current),h(e),g.current=setTimeout(()=>{h(null),g.current=null},cre)},k=async t=>{C();let a=n?.id===t,o=y.find(e=>e.id!==t)??null;try{await i(t),a&&o&&await r(o.id)}catch{q.error(e(`mission.deleteFailed`))}},A=()=>{if(f===0)D();else{let e=x[f-1];e&&E(e.id)}},j=e=>{if(!c){e.key===`ArrowDown`&&(e.preventDefault(),w());return}if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=e.key===`ArrowDown`?1:-1;p(e=>(e+t+S)%S)}else e.key===`Home`?(e.preventDefault(),p(0)):e.key===`End`?(e.preventDefault(),p(S-1)):e.key===`Enter`?(e.preventDefault(),A()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),m?C():(T(),v.current?.focus()))},M=n?.title?.trim()||e(`mission.untitled`);return(0,Y.jsxs)(`div`,{className:`relative min-w-0`,ref:_,"data-agent-interactive":!0,onKeyDown:j,children:[(0,Y.jsxs)(`button`,{ref:v,type:`button`,"data-testid":`mission-trigger`,onClick:()=>c?T():w(),"aria-haspopup":`listbox`,"aria-expanded":c,"aria-controls":`agent-mission-listbox`,title:e(`mission.label`),className:`flex min-w-0 items-center gap-1.5 rounded-md px-1.5 py-1 text-sm font-medium text-foreground hover:bg-surface/70`,children:[(0,Y.jsx)(fs,{className:`h-3.5 w-3.5 shrink-0 text-accent-primary`}),(0,Y.jsx)(`span`,{className:`min-w-0 max-w-[150px] truncate`,children:M}),(0,Y.jsx)(no,{className:`h-3.5 w-3.5 shrink-0 text-foreground/50`})]}),(0,Y.jsx)(H3,{children:c&&(0,Y.jsxs)(V8.div,{initial:{opacity:0,y:-6,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-6,scale:.98},transition:{duration:.16,ease:`easeOut`},className:`absolute left-0 top-full z-10 mt-1 w-72 overflow-hidden rounded-xl border border-border/60 bg-card/95 shadow-2xl backdrop-blur-xl`,children:[b&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/50 px-3 py-2`,children:[(0,Y.jsx)(Us,{className:`h-3.5 w-3.5 text-foreground/40`}),(0,Y.jsx)(`input`,{autoFocus:!0,value:u,onChange:e=>{d(e.target.value),p(0)},placeholder:e(`mission.searchPlaceholder`),className:`w-full bg-transparent text-sm text-foreground outline-none placeholder:text-foreground/40`})]}),(0,Y.jsxs)(`div`,{id:`agent-mission-listbox`,role:`listbox`,"aria-label":e(`mission.label`),"aria-activedescendant":`agent-mission-opt-${f}`,className:`max-h-72 overflow-y-auto py-1`,children:[(0,Y.jsxs)(V8.div,{id:`agent-mission-opt-0`,role:`option`,"aria-selected":!1,tabIndex:-1,"data-testid":`mission-new`,onClick:D,onMouseEnter:()=>p(0),initial:{opacity:0,x:-6},animate:{opacity:1,x:0},transition:{duration:.14},className:`flex w-full cursor-pointer items-center gap-2.5 px-3 py-1.5 text-left text-sm font-medium text-foreground ${f===0?`bg-surface/70`:`hover:bg-surface/70`}`,children:[(0,Y.jsx)(ks,{className:`h-4 w-4 text-accent-primary`}),(0,Y.jsx)(`span`,{className:`flex-1 truncate`,children:e(`mission.new`)})]}),x.length>0&&(0,Y.jsx)(`div`,{className:`mx-3 my-1 h-px bg-border/50`,"aria-hidden":!0}),x.length===0&&u.trim()!==``&&(0,Y.jsx)(`div`,{className:`px-3 py-2 text-xs text-foreground/40`,children:e(`mission.noMatches`)}),x.map((e,t)=>(0,Y.jsx)(ure,{conversation:e,index:t+1,highlighted:f===t+1,activeId:n?.id??null,streaming:o.has(e.id),queuedCount:s.get(e.id)?.queued.length??0,confirming:m===e.id,onHover:()=>p(t+1),onSelect:()=>E(e.id),onArmDelete:()=>O(e.id),onConfirmDelete:()=>void k(e.id),onCancelDelete:C},e.id))]})]})})]})}function ure({conversation:e,index:t,highlighted:n,activeId:r,streaming:i,queuedCount:a,confirming:o,onHover:s,onSelect:c,onArmDelete:l,onConfirmDelete:u,onCancelDelete:d}){let{t:f}=K(`agent`),p=e.title?.trim()||f(`mission.untitled`),m=e.id===r;return o?(0,Y.jsxs)(`div`,{id:`agent-mission-opt-${t}`,role:`option`,"aria-selected":m,"data-testid":`mission-row-${e.id}`,className:`flex w-full items-center gap-2 bg-destructive/10 px-3 py-1.5 text-sm`,children:[(0,Y.jsx)(cc,{className:`h-3.5 w-3.5 shrink-0 text-destructive`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-destructive`,children:f(i?`mission.deleteLiveConfirm`:`mission.deleteConfirm`)}),(0,Y.jsx)(`button`,{type:`button`,"data-testid":`mission-confirm-yes`,onClick:e=>{e.stopPropagation(),u()},"aria-label":f(`mission.confirmDelete`),className:`rounded-md p-1 text-destructive hover:bg-destructive/20`,children:(0,Y.jsx)(to,{className:`h-3.5 w-3.5`})}),(0,Y.jsx)(`button`,{type:`button`,"data-testid":`mission-confirm-no`,onClick:e=>{e.stopPropagation(),d()},"aria-label":f(`mission.cancelDelete`),className:`rounded-md p-1 text-foreground/60 hover:bg-surface`,children:(0,Y.jsx)(hc,{className:`h-3.5 w-3.5`})})]}):(0,Y.jsxs)(V8.div,{id:`agent-mission-opt-${t}`,role:`option`,"aria-selected":m,tabIndex:-1,"data-testid":`mission-row-${e.id}`,onClick:c,onMouseEnter:s,initial:{opacity:0,x:-6},animate:{opacity:1,x:0},transition:{duration:.14,delay:Math.min(t*.03,.18)},className:`group flex w-full cursor-pointer items-center gap-2 px-3 py-1.5 text-left text-sm text-foreground ${n?`bg-surface/70`:`hover:bg-surface/70`}`,children:[(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:p}),(0,Y.jsx)(`span`,{className:`shrink-0 tabular-nums text-xs text-foreground/40`,title:pY(e.updated_at),children:fY(e.updated_at)}),i&&(0,Y.jsxs)(`span`,{"data-testid":`mission-live-${e.id}`,"aria-label":f(`mission.working`),className:`relative flex h-1.5 w-1.5 shrink-0`,children:[(0,Y.jsx)(`span`,{className:`absolute inline-flex h-full w-full animate-ping rounded-full bg-accent-primary opacity-60`}),(0,Y.jsx)(`span`,{className:`relative inline-flex h-1.5 w-1.5 rounded-full bg-accent-primary`})]}),a>0&&(0,Y.jsx)(`span`,{"data-testid":`mission-queued-${e.id}`,"aria-label":f(`mission.queuedBadge`,{n:a}),title:f(`mission.queuedBadge`,{n:a}),className:`shrink-0 rounded-full border border-border/60 bg-surface px-1.5 text-[9px] font-semibold leading-4 text-foreground/60`,children:a}),m&&(0,Y.jsx)(to,{className:`h-3.5 w-3.5 shrink-0 text-accent-primary`}),(0,Y.jsx)(`button`,{type:`button`,"data-testid":`mission-delete-${e.id}`,onClick:e=>{e.stopPropagation(),l()},"aria-label":f(`mission.delete`,{title:p}),className:`shrink-0 rounded-md p-0.5 text-foreground/50 opacity-0 transition-opacity hover:bg-surface hover:text-destructive focus-visible:opacity-100 group-focus-within:opacity-100 group-hover:opacity-100`,children:(0,Y.jsx)(cc,{className:`h-3.5 w-3.5`})})]})}function dre(){let{t:e}=K(`agent`),{minimize:t,startNewConversation:n,cycleTier:r,active:i,draftPinnedProjectId:a,setPinnedProject:o}=N7(),[s,c]=(0,H.useState)(!1),l=e=>{e.shiftKey&&(e.key===`Tab`||e.code===`Tab`)&&(e.preventDefault(),r())},{panelRef:u,panelStyle:d,headerHandleProps:f,resizeHandles:p}=yb({enabled:!0,allowMove:!0,minWidth:400,minHeight:420,anchorFromCurrentRect:!0,persistKey:`specrails-desktop:agent-panel-geom`});return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(V8.div,{ref:u,initial:{opacity:0,scale:.85,y:8},animate:{opacity:1,scale:1,y:0},transition:{duration:.22,ease:[.34,1.56,.64,1]},style:s?{position:`fixed`,inset:12,width:`auto`,height:`auto`,maxWidth:`none`,maxHeight:`none`}:d,role:`dialog`,"aria-label":e(`title`),onKeyDown:l,className:`fixed z-[60] flex flex-col overflow-hidden rounded-2xl border border-border/60 bg-card/90 shadow-2xl backdrop-blur-xl ${s?``:`bottom-4 right-4 h-[78vh] max-h-[94vh] w-[520px] max-w-[92vw]`}`,children:[(0,Y.jsxs)(`div`,{...s?{}:f,onDoubleClick:()=>c(e=>!e),className:`flex shrink-0 items-center gap-2 border-b border-border/50 bg-surface/40 px-3 py-2 ${s?``:`cursor-grab`}`,children:[(0,Y.jsx)(qa,{className:`h-4 w-4 shrink-0 text-accent-primary`}),(0,Y.jsx)(`span`,{className:`shrink-0 text-sm font-medium text-foreground/80`,children:e(`title`)}),(0,Y.jsx)(r7,{pinnedProjectId:i?i.pinned_project_id:a,onSelect:e=>void o(e)}),(0,Y.jsx)(`div`,{className:`h-4 w-px shrink-0 bg-border/60`,"aria-hidden":!0}),(0,Y.jsx)(lre,{}),(0,Y.jsxs)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:()=>n(null),title:e(`newConversation`),"data-agent-interactive":!0,className:`rounded-md p-1 text-foreground/60 hover:bg-surface hover:text-foreground`,children:(0,Y.jsx)(ks,{className:`h-4 w-4`})}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>c(e=>!e),"aria-label":e(s?`restore`:`maximize`),title:e(s?`restore`:`maximize`),"data-agent-interactive":!0,className:`rounded-md p-1 text-foreground/60 hover:bg-surface hover:text-foreground`,children:s?(0,Y.jsx)(ps,{className:`h-4 w-4`}):(0,Y.jsx)(us,{className:`h-4 w-4`})}),(0,Y.jsx)(`button`,{type:`button`,onClick:t,"aria-label":e(`minimize`),title:e(`minimize`),"data-agent-interactive":!0,className:`rounded-md p-1 text-foreground/60 hover:bg-surface hover:text-foreground`,children:(0,Y.jsx)(hc,{className:`h-4 w-4`})})]})]}),(0,Y.jsx)(S7,{variant:`floating`})]}),!s&&(0,Y.jsx)(`div`,{className:`pointer-events-none fixed inset-0 z-[61] [&>*]:pointer-events-auto`,children:(0,Y.jsx)(xb,{handles:p})})]})}var C7=`specrails-desktop:agent-bubble-pos`,w7=56,T7=12;function fre(){try{let e=localStorage.getItem(C7);if(!e)return null;let t=JSON.parse(e);if(typeof t?.left==`number`&&typeof t?.top==`number`)return t}catch{}return null}function E7(e){let t=Math.max(T7,window.innerWidth-w7-T7),n=Math.max(T7,window.innerHeight-w7-T7);return{left:Math.min(Math.max(T7,e.left),t),top:Math.min(Math.max(T7,e.top),n)}}function pre(){return{left:Math.round(window.innerWidth/2-w7/2),top:window.innerHeight-w7-20}}function mre(){let{t:e}=K(`agent`),{open:t,isStreaming:n,active:r}=N7(),[i,a]=(0,H.useState)(!1),[o,s]=(0,H.useState)(()=>E7(fre()??pre())),c=B8(0),l=B8(0),u=(0,H.useRef)(!1);(0,H.useEffect)(()=>{let e=()=>s(e=>E7(e));return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let d=(0,H.useCallback)(e=>{try{localStorage.setItem(C7,JSON.stringify(e))}catch{}},[]);return(0,Y.jsxs)(V8.button,{type:`button`,onClick:()=>{if(u.current){u.current=!1;return}t()},onHoverStart:()=>a(!0),onHoverEnd:()=>a(!1),"aria-label":e(`trigger`),title:`${e(`trigger`)} (⌘⇧A)`,drag:!0,dragMomentum:!1,dragElastic:0,style:{position:`fixed`,left:o.left,top:o.top,x:c,y:l},onDragStart:()=>{u.current=!0},onDragEnd:()=>{let e=E7({left:o.left+c.get(),top:o.top+l.get()});c.set(0),l.set(0),s(e),d(e),setTimeout(()=>{u.current=!1},0)},initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},transition:{type:`spring`,stiffness:420,damping:28},whileHover:{scale:1.06},whileTap:{scale:.94},whileDrag:{scale:1.1,cursor:`grabbing`},className:`z-[60] flex h-14 items-center gap-2 rounded-full border border-border/60 bg-card/85 px-3 shadow-2xl backdrop-blur-xl cursor-grab`,children:[(0,Y.jsxs)(`span`,{className:`relative flex h-9 w-9 items-center justify-center rounded-full bg-accent-primary/15`,children:[(0,Y.jsx)(qa,{className:`h-5 w-5 text-accent-primary`}),n&&(0,Y.jsx)(V8.span,{className:`absolute inset-0 rounded-full ring-2 ring-accent-success`,animate:{opacity:[.8,.2,.8],scale:[1,1.18,1]},transition:{duration:1.4,repeat:1/0,ease:`easeInOut`}})]}),(0,Y.jsx)(H3,{initial:!1,children:(i||n)&&(0,Y.jsx)(V8.span,{initial:{opacity:0,width:0,marginRight:0},animate:{opacity:1,width:`auto`,marginRight:4},exit:{opacity:0,width:0,marginRight:0},transition:{duration:.18,ease:`easeOut`},className:`overflow-hidden whitespace-nowrap text-sm font-medium text-foreground`,children:n?e(`thinking`):r?.title||e(`trigger`)})})]})}var D7={streamingText:``,isStreaming:!1,liveTools:[],queued:[]},O7=`specrails-desktop:favorite-agent-conversations`;function hre(){try{let e=localStorage.getItem(O7);if(!e)return new Set;let t=JSON.parse(e);return Array.isArray(t)?new Set(t.filter(e=>typeof e==`string`)):new Set}catch{return new Set}}function k7(e){try{localStorage.setItem(O7,JSON.stringify([...e]))}catch{}}function A7(e,t){let n=new Set(t.map(e=>e.id));return new Set([...e].filter(e=>n.has(e)))}var j7=(0,H.createContext)(null),gre=0,M7=0;function _re({children:e}){let{registerHandler:t,unregisterHandler:n}=df(),{uiMode:r}=hq(),{setActiveProjectId:i}=gm(),[a,o]=(0,H.useState)(`hidden`),[s,c]=(0,H.useState)([]),[l,u]=(0,H.useState)(null),[d,f]=(0,H.useState)([]),[p,m]=(0,H.useState)(hre),[h,g]=(0,H.useState)(new Set),[_,v]=(0,H.useState)(new Map),[y,b]=(0,H.useState)(!0),[x,S]=(0,H.useState)(!1),[C,w]=(0,H.useState)(null),[T,E]=(0,H.useState)(null),D=(0,H.useRef)(null);D.current=T;let[O,k]=(0,H.useState)(`claude`),[A,j]=(0,H.useState)(null),[M,N]=(0,H.useState)(0),[P,F]=(0,H.useState)(null),I=(0,H.useRef)({provider:`claude`,model:null,tierLevel:0,effort:null});I.current={provider:O,model:A,tierLevel:M,effort:P};let L=(0,H.useRef)(null);L.current=l?.id??null;let R=(0,H.useRef)(_);R.current=_;let z=(0,H.useRef)(new Set),ee=(0,H.useRef)(null),te=(0,H.useCallback)((e,t)=>{v(n=>{let r=t(n.get(e)??D7),i=new Map(n);return r===null||!r.isStreaming&&!r.streamingText&&r.liveTools.length===0&&r.queued.length===0?i.delete(e):i.set(e,r),i})},[]),B=(0,H.useCallback)(e=>{let t=typeof document<`u`&&document.visibilityState===`hidden`;e===L.current&&!t||g(t=>{if(t.has(e))return t;let n=new Set(t);return n.add(e),n})},[]),ne=(0,H.useCallback)(e=>{g(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]);(0,H.useEffect)(()=>{if(!Lb||typeof document>`u`)return;let e=()=>{if(document.visibilityState!==`visible`)return;let e=L.current;e&&ne(e)};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[ne]);let V=(l?_.get(l.id):void 0)??D7,re=V.streamingText,U=V.isStreaming,ie=V.liveTools,ae=V.queued,W=(0,H.useMemo)(()=>{let e=new Set;for(let[t,n]of _)n.isStreaming&&e.add(t);return e},[_]),oe=(0,H.useCallback)(async()=>{try{let e=await DY();c(e),m(t=>{let n=A7(t,e);return n.size===t.size?t:(k7(n),n)})}catch{}},[]),se=(0,H.useCallback)(async()=>{try{b((await qY()).enabled)}catch{b(!1)}},[]),ce=(0,H.useCallback)(async()=>{try{w((await KY()).any)}catch{w(!0)}},[]);(0,H.useEffect)(()=>Lb?(t(`agent-chat`,e=>{let t=e;if(typeof t.type!=`string`||!t.type.startsWith(`agent_`))return;if(t.type===`agent_title`&&t.conversationId){let e=t.title??null;c(n=>n.map(n=>n.id===t.conversationId?{...n,title:e}:n)),u(n=>n&&n.id===t.conversationId?{...n,title:e}:n);return}let n=t.conversationId;if(!n)return;let r=n===L.current;if(t.type===`agent_stream`)B(n),te(n,e=>({...e,isStreaming:!0,streamingText:e.streamingText+(t.delta??``)}));else if(t.type===`agent_tool`)te(n,e=>({...e,isStreaming:!0,liveTools:[...e.liveTools,{id:`t${gre++}`,tool:t.tool??`tool`}]}));else if(t.type===`agent_done`){B(n);let e=t.fullText??``;r&&f(t=>{let r=t[t.length-1];return r&&r.role===`assistant`&&r.content===e&&!r.id.startsWith(`local-`)?t:[...t,{id:`local-${Date.now()}`,conversation_id:n,role:`assistant`,content:e,created_at:new Date().toISOString()}]}),te(n,e=>({...D7,queued:e.queued}))}else if(t.type===`agent_error`){B(n),te(n,e=>({...D7,queued:e.queued}));let e=t.error||`The agent turn failed.`;q.error(e),r&&f(t=>[...t,{id:`err-${Date.now()}`,conversation_id:n,role:`assistant`,content:`⚠️ ${e}`,created_at:new Date().toISOString()}])}else if(t.type===`agent_queued`)te(n,e=>t.queueId&&e.queued.some(e=>e.queueId===t.queueId)?e:{...e,queued:[...e.queued,{queueId:t.queueId??`srv-${M7++}`,text:t.text??``,contextRefs:t.contextRefs}]});else if(t.type===`agent_dequeued`)t.queueId&&z.current.add(t.queueId),te(n,e=>{let n=t.queueId?e.queued.findIndex(e=>e.queueId===t.queueId):0,r=n===-1?0:n;return{...e,queued:e.queued.filter((e,t)=>t!==r),isStreaming:!0,streamingText:``,liveTools:[]}}),r&&t.text&&f(e=>[...e,{id:`local-u-${Date.now()}`,conversation_id:n,role:`user`,content:t.text,context_refs:t.contextRefs??[],created_at:new Date().toISOString()}]);else if(t.type===`agent_queue_cleared`)te(n,e=>({...e,queued:[]}));else if(t.type===`agent_queue_edited`)te(n,e=>({...e,queued:e.queued.map(e=>t.queueId&&e.queueId===t.queueId?{...e,text:t.text??e.text,contextRefs:t.contextRefs??e.contextRefs}:e)}));else if(t.type===`agent_pr_decision`&&(B(n),r)){let t=HY(e);if(t){let e=JSON.stringify(t);f(r=>{let i=r.findIndex(e=>e.role===`system`&&UY(e.content)?.prDeliveryId===t.prDeliveryId);if(i>=0){if(r[i].content===e)return r;let t=[...r];return t[i]={...t[i],content:e},t}return[...r,{id:`prd-${t.prDeliveryId}`,conversation_id:n,role:`system`,content:e,created_at:new Date().toISOString()}]})}}}),()=>n(`agent-chat`)):void 0,[t,n,te,B]);let le=(0,H.useCallback)(async e=>{let{conversation:t,messages:n}=await kY(e);u(t),f(n),ne(e)},[ne]),ue=(0,H.useCallback)(async()=>{if(l)return l;let e=await DY();if(c(e),m(t=>{let n=A7(t,e);return n.size===t.size?t:(k7(n),n)}),e.length>0)return await le(e[0].id),e[0];let t=await OY({});return c(e=>[t,...e]),u(t),f([]),t},[l,le]),de=(0,H.useCallback)(()=>{o(`open`),oe(),se(),ce(),ue()},[oe,se,ce,ue]),fe=(0,H.useCallback)(()=>o(`hidden`),[]),pe=(0,H.useCallback)(()=>o(`minimized`),[]),me=(0,H.useCallback)(()=>{o(e=>e===`open`?`minimized`:`open`),a!==`open`&&(oe(),se(),ce(),ue())},[a,oe,se,ce,ue]),he=(0,H.useCallback)(async()=>{if(l)return l;if(ee.current)return ee.current;let e=OY({pinnedProjectId:D.current,provider:I.current.provider,model:I.current.model,tierLevel:I.current.tierLevel,reasoningEffort:I.current.effort}).then(e=>(c(t=>[e,...t]),u(e),f([]),e)).finally(()=>{ee.current=null});return ee.current=e,e},[l]),ge=(0,H.useCallback)(async(e,t)=>{let n=e.trim();if(!n)return;let r=l??await he(),i=`q-${Date.now()}-${M7++}`,a=new Date().toISOString();c(e=>[{...e.find(e=>e.id===r.id)??r,updated_at:a},...e.filter(e=>e.id!==r.id)]),u(e=>e&&e.id===r.id?{...e,updated_at:a}:e);let o={id:`local-u-${Date.now()}`,conversation_id:r.id,role:`user`,content:n,attachment_ids:t?.attachmentIds??[],context_refs:t?.contextRefs??[],created_at:a},s=R.current.get(r.id)?.isStreaming===!0;s?te(r.id,e=>({...e,queued:[...e.queued,{queueId:i,text:n,contextRefs:t?.contextRefs}]})):(f(e=>[...e,o]),te(r.id,e=>({...e,isStreaming:!0,streamingText:``,liveTools:[]})));let d=t?.attachmentIds&&t.attachmentIds.length?{ids:t.attachmentIds}:void 0;try{let e=t?.contextRefs&&t.contextRefs.length?t.contextRefs:void 0,a=(await MY(r.id,n,{tierLevel:r.tier_level,attachments:d,queueId:i,contextRefs:e}))?.queued===!0;a&&!s?(f(e=>e.filter(e=>e.id!==o.id)),z.current.has(i)||te(r.id,e=>e.queued.some(e=>e.queueId===i)?e:{...e,queued:[...e.queued,{queueId:i,text:n,contextRefs:t?.contextRefs}]})):!a&&s&&(te(r.id,e=>({...e,queued:e.queued.filter(e=>e.queueId!==i),isStreaming:!0})),f(e=>[...e,o]))}catch(e){s?te(r.id,e=>({...e,queued:e.queued.filter(e=>e.queueId!==i)})):te(r.id,e=>({...e,isStreaming:!1,streamingText:``,liveTools:[]})),q.error(e instanceof Error?e.message:`Failed to send message.`)}},[l,he,te]),_e=(0,H.useCallback)(async()=>{l&&(te(l.id,()=>null),await RY(l.id))},[l,te]),ve=(0,H.useCallback)(async(e,t)=>{let n=l;if(!n)return`conflict`;let r=await zY(n.id,e,t);return r===`saved`&&te(n.id,n=>({...n,queued:n.queued.map(n=>n.queueId===e?{...n,text:t}:n)})),r},[l,te]),ye=(0,H.useCallback)(e=>z.current.has(e),[]),G=(0,H.useCallback)(async e=>{if(!l)return;let t=await AY(l.id,e);u(t),c(e=>e.map(e=>e.id===t.id?t:e))},[l]),be=(0,H.useCallback)(async e=>{l?await G({tierLevel:e}):N(e)},[l,G]),xe=(0,H.useCallback)(async()=>{await be(((l?.tier_level??M)+1)%4)},[l,M,be]),Se=(0,H.useCallback)(async e=>{l?await G({provider:e}):(k(e),j(null),F(null))},[l,G]),Ce=(0,H.useCallback)(async e=>{l?await G({model:e}):j(e)},[l,G]),we=(0,H.useCallback)(async e=>{l?await G({reasoningEffort:e}):F(e)},[l,G]),Te=(0,H.useCallback)(async e=>{l?await G({pinnedProjectId:e}):E(e),!l&&e&&r===`agent`&&i(e)},[l,G,r,i]),Ee=(0,H.useCallback)(e=>{u(null),f([]),E(e??null),k(`claude`),j(null),N(0),F(null)},[]),De=(0,H.useCallback)(async e=>{let t=await OY({pinnedProjectId:e===void 0?l?.pinned_project_id??null:e});c(e=>[t,...e]),u(t),f([])},[l]),Oe=(0,H.useCallback)(async e=>{await le(e)},[le]),ke=(0,H.useCallback)(async e=>{await jY(e),c(t=>t.filter(t=>t.id!==e)),m(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),k7(n),n}),te(e,()=>null),L.current===e&&(u(null),f([]))},[te]),Ae=(0,H.useCallback)(async(e,t)=>{let n=t.trim()||null,r;c(t=>t.map(t=>t.id===e?(r=t.title,{...t,title:n}):t)),u(t=>t&&t.id===e?{...t,title:n}:t);try{await AY(e,{title:n})}catch(t){throw c(t=>t.map(t=>t.id===e?{...t,title:r??null}:t)),u(t=>t&&t.id===e?{...t,title:r??null}:t),t}},[]),je=(0,H.useCallback)(e=>{m(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),k7(n),n})},[]),Me=(0,H.useCallback)(async()=>{S(!0);try{await JY(),await se()}finally{S(!1)}},[se]),Ne=(0,H.useMemo)(()=>({visibility:a,open:de,close:fe,minimize:pe,toggle:me,conversations:s,active:l,messages:d,streamingText:re,isStreaming:U,liveTools:ie,queuedMessages:ae,streamingConversationIds:W,liveByConversation:_,unreadConversationIds:h,favoriteConversationIds:p,mcpEnabled:y,enablingMcp:x,enableMcpServer:Me,providersReady:C,send:ge,abort:_e,editQueuedMessage:ve,wasQueueConsumed:ye,cycleTier:xe,setTier:be,setProvider:Se,setModel:Ce,setPinnedProject:Te,newConversation:De,startNewConversation:Ee,materializeDraftConversation:he,draftPinnedProjectId:T,draftProvider:O,draftModel:A,draftTierLevel:M,draftEffort:P,setEffort:we,selectConversation:Oe,deleteConversation:ke,renameConversation:Ae,toggleFavoriteConversation:je,refreshConversations:oe}),[a,de,fe,pe,me,s,l,d,re,U,ie,ae,W,_,h,p,y,x,Me,C,ge,_e,ve,ye,xe,be,Se,Ce,Te,De,Ee,he,T,O,A,M,P,we,Oe,ke,Ae,je,oe]),Pe=Lb&&r!==`agent`;return(0,Y.jsxs)(j7.Provider,{value:Ne,children:[e,Pe&&a===`open`&&(0,Y.jsx)(dre,{}),Pe&&a!==`open`&&(0,Y.jsx)(mre,{})]})}var vre={visibility:`hidden`,open:()=>{},close:()=>{},minimize:()=>{},toggle:()=>{},conversations:[],active:null,messages:[],streamingText:``,isStreaming:!1,liveTools:[],queuedMessages:[],streamingConversationIds:new Set,unreadConversationIds:new Set,liveByConversation:new Map,favoriteConversationIds:new Set,mcpEnabled:!0,enablingMcp:!1,enableMcpServer:async()=>{},providersReady:!0,send:async()=>{},abort:async()=>{},editQueuedMessage:async()=>`conflict`,wasQueueConsumed:()=>!1,cycleTier:async()=>{},setTier:async()=>{},setProvider:async()=>{},setModel:async()=>{},setPinnedProject:async()=>{},newConversation:async()=>{},startNewConversation:()=>{},materializeDraftConversation:async()=>{throw Error(`AgentChatProvider is not mounted`)},draftPinnedProjectId:null,draftProvider:`claude`,draftModel:null,draftTierLevel:0,draftEffort:null,setEffort:async()=>{},selectConversation:async()=>{},deleteConversation:async()=>{},renameConversation:async()=>{},toggleFavoriteConversation:()=>{},refreshConversations:async()=>{}};function N7(){return(0,H.useContext)(j7)??vre}var yre=(0,H.lazy)(()=>a(()=>import(`./ProjectSettingsDialog-M9zGQo0l.js`).then(e=>({default:e.ProjectSettingsDialog})),__vite__mapDeps([34,1]))),P7=`specrails-desktop:agentTreeExpanded`;function bre(){try{let e=localStorage.getItem(P7);if(!e)return new Set;let t=JSON.parse(e);return Array.isArray(t)?new Set(t.filter(e=>typeof e==`string`)):new Set}catch{return new Set}}function F7(e){try{localStorage.setItem(P7,JSON.stringify([...e]))}catch{}}function xre(){window.dispatchEvent(new KeyboardEvent(`keydown`,{key:`k`,metaKey:!0,ctrlKey:!0,bubbles:!0}))}var I7=`__home__`,L7=`__favorites__`;function R7({conversation:e,active:t,expanded:n,streaming:r=!1,unread:i=!1,favorite:a=!1,onSelect:o,onToggleFavorite:s,onDelete:c}){let{t:l}=K(`agent`),u=e.title?.trim()||l(`untitled`),[d,f]=(0,H.useState)(!1),p=(0,H.useRef)(null),[m,h]=(0,H.useState)(!1),g=(0,H.useRef)(r);(0,H.useEffect)(()=>{if(g.current&&!r){h(!0);let e=setTimeout(()=>h(!1),900);return g.current=r,()=>clearTimeout(e)}g.current=r},[r]),(0,H.useEffect)(()=>()=>{p.current&&clearTimeout(p.current)},[]);function _(e){e.stopPropagation(),d?(p.current&&clearTimeout(p.current),f(!1),c()):(f(!0),p.current=setTimeout(()=>{f(!1),p.current=null},3e3))}function v(e){e.stopPropagation(),s?.()}function y(e){e.target===e.currentTarget&&(e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),o()))}return(0,Y.jsxs)(`div`,{role:`button`,tabIndex:0,onClick:o,onKeyDown:y,className:X(`group relative flex items-center gap-2 w-full h-7 rounded-md transition-colors`,n?`pl-7 pr-2`:`px-0 justify-center`,t?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),title:n?void 0:u,"aria-current":t?`true`:void 0,children:[(0,Y.jsx)(ds,{className:X(`w-3.5 h-3.5 flex-shrink-0`,t&&`text-accent-primary`,r&&!i&&`text-accent-primary animate-pulse`,i&&`text-destructive conversation-unread-glow`)}),n&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{className:`relative text-[11px] truncate flex-1 text-left`,children:[u,(r||m)&&(0,Y.jsx)(`span`,{"aria-hidden":!0,className:X(`title-shimmer pointer-events-none absolute inset-0 truncate transition-opacity duration-700`,r?`opacity-100`:`opacity-0`),children:u})]}),(0,Y.jsx)(`span`,{className:X(`flex-shrink-0 text-[10px] tabular-nums text-muted-foreground/45`,d?`hidden`:`group-hover:hidden`),title:pY(e.updated_at),children:fY(e.updated_at)}),(0,Y.jsx)(`button`,{type:`button`,onClick:v,className:X(`flex-shrink-0 items-center justify-center rounded-sm transition-colors hover:bg-muted`,a?`flex w-3.5 h-3.5 text-accent-primary hover:text-accent-primary`:`hidden group-hover:flex w-3.5 h-3.5 text-muted-foreground/60 hover:text-accent-primary`),"aria-label":l(a?`removeFavoriteConversation`:`addFavoriteConversation`,{title:u}),title:l(a?`removeFavoriteConversation`:`addFavoriteConversation`,{title:u}),children:(0,Y.jsx)(Xo,{className:`w-2.5 h-2.5`,fill:a?`currentColor`:`none`})}),(0,Y.jsx)(`button`,{type:`button`,onClick:_,className:X(`flex-shrink-0 items-center justify-center rounded-sm transition-colors hover:bg-muted`,d?`flex px-1 h-4 text-[10px] text-destructive bg-destructive/10 hover:bg-destructive/20`:`hidden group-hover:flex w-3.5 h-3.5 text-muted-foreground/60 hover:text-foreground`),"aria-label":l(d?`confirmDeleteConversation`:`deleteConversation`,{title:u}),children:d?l(`confirmShort`):(0,Y.jsx)(hc,{className:`w-2.5 h-2.5`})})]})]})}function Sre({project:e,isActive:t,expanded:n,onSelect:r,onRemove:i,agentMode:a=!1,hasTree:o=!1,treeOpen:s=!1,onToggleTree:c,conversations:l=[],activeConversationId:u=null,streamingConversationIds:d,unreadConversationIds:f,onSelectConversation:p,onToggleConversationFavorite:m,onDeleteConversation:h,onOpenProjectSettings:g}){let{t:_}=K(`nav`),[v,y]=(0,H.useState)(!1),b=(0,H.useRef)(null);(0,H.useEffect)(()=>()=>{b.current&&clearTimeout(b.current)},[]);function x(e){e.stopPropagation(),v?(b.current&&clearTimeout(b.current),y(!1),i()):(y(!0),b.current=setTimeout(()=>{y(!1),b.current=null},3e3))}function S(e){e.target===e.currentTarget&&(e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),r()))}let C=a&&o&&n,w=(0,Y.jsx)(zo,{className:X(`flex-shrink-0 w-4 h-4`,t&&`text-accent-primary`)});return(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`div`,{role:`button`,tabIndex:0,onClick:r,onKeyDown:S,className:X(`group relative flex items-center gap-2 w-full h-8 rounded-md transition-colors`,n?`px-2`:`px-0 justify-center`,t?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),title:n?void 0:e.name,"aria-current":t?`page`:void 0,children:[C?(0,Y.jsxs)(`span`,{className:`relative flex h-4 w-4 flex-shrink-0 items-center justify-center`,children:[(0,Y.jsx)(`span`,{className:`flex transition-opacity group-hover:opacity-0 group-focus-within:opacity-0`,children:w}),(0,Y.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c?.()},className:`absolute inset-0 hidden items-center justify-center rounded-sm hover:bg-muted group-hover:flex group-focus-within:flex`,"aria-label":_(s?`projects.collapse`:`projects.expand`,{name:e.name}),"aria-expanded":s,children:s?(0,Y.jsx)(no,{className:`w-3.5 h-3.5`}):(0,Y.jsx)(io,{className:`w-3.5 h-3.5`})})]}):w,n&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`text-xs truncate flex-1 text-left`,children:e.name}),g&&(0,Y.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),g()},className:X(`flex-shrink-0 flex items-center justify-center rounded-sm transition-all w-3.5 h-3.5`,`opacity-0 group-hover:opacity-50 hover:!opacity-100 hover:bg-muted`),"aria-label":_(`projects.settings`,{name:e.name}),title:_(`projects.settings`,{name:e.name}),children:(0,Y.jsx)(qs,{className:`w-2.5 h-2.5`})}),(0,Y.jsx)(`button`,{type:`button`,onClick:x,className:X(`flex-shrink-0 flex items-center justify-center rounded-sm transition-all`,`opacity-0 group-hover:opacity-50 hover:!opacity-100 hover:bg-muted`,v?`opacity-100 px-1 h-4 text-[10px] text-destructive bg-destructive/10 hover:bg-destructive/20`:`w-3.5 h-3.5`),"aria-label":_(v?`projects.confirmRemove`:`projects.remove`,{name:e.name}),children:v?_(`projects.confirmShort`):(0,Y.jsx)(hc,{className:`w-2.5 h-2.5`})})]})]}),a&&s&&n&&l.length>0&&(0,Y.jsx)(`div`,{className:`mt-0.5 space-y-0.5`,children:l.map(e=>(0,Y.jsx)(R7,{conversation:e,active:e.id===u,streaming:d?.has(e.id)??!1,unread:f?.has(e.id)??!1,expanded:n,onSelect:()=>p?.(e.id),onToggleFavorite:()=>m?.(e.id),onDelete:()=>h?.(e.id)},e.id))})]})}var Cre={"pinned-open":`sidebarPin.left.pinnedOpen`,"pinned-collapsed":`sidebarPin.left.pinnedCollapsed`,unpinned:`sidebarPin.left.unpinned`};function wre({onAddProject:e,onOpenLoops:t,onOpenPlugins:n,onOpenAnalytics:r,onOpenDocs:i,onOpenSettings:a}){let{t:o}=K(`nav`),{t:s}=K(`agent`),{projects:c,activeProjectId:l,setActiveProjectId:u,removeProject:d}=gm(),f=_t(),p=mt(),m=p.pathname.startsWith(`/loops`),h=p.pathname.startsWith(`/plugins`),g=m||h||p.pathname.startsWith(`/docs`),{leftMode:_,cycleLeftMode:v}=CY(),{uiMode:y,toggleUiMode:b}=hq(),x=N7(),S=y===`agent`,C=(0,H.useMemo)(()=>{let e=new Map,t=new Set(c.map(e=>e.id));for(let n of x.conversations){if(x.favoriteConversationIds.has(n.id))continue;let r=n.pinned_project_id&&t.has(n.pinned_project_id)?n.pinned_project_id:I7,i=e.get(r);i?i.push(n):e.set(r,[n])}return e},[x.conversations,x.favoriteConversationIds,c]),w=(0,H.useMemo)(()=>x.conversations.filter(e=>x.favoriteConversationIds.has(e.id)),[x.conversations,x.favoriteConversationIds]),T=C.get(I7)??[],[E,D]=(0,H.useState)(bre),O=E.has(L7),[k,A]=(0,H.useState)(!1);(0,H.useEffect)(()=>{!S||!l||D(e=>{if(e.has(l))return e;let t=new Set(e);return t.add(l),F7(t),t})},[S,l]);let j=e=>{D(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),F7(n),n})},M=e=>{x.selectConversation(e),g&&f(`/`)},N=e=>{x.deleteConversation(e).catch(()=>{})},P=e=>{x.toggleFavoriteConversation(e)};function F(e){if(S){u(e),j(e);return}if(e===l){g&&f(`/`);return}u(e)}let[I,L]=(0,H.useState)(!1),R=_===`pinned-open`||_===`unpinned`&&I,z=cY(`left-arc`,{side:`left`,defaultWidth:240,min:200,max:460,collapsedWidth:44,expanded:R}),ee=_!==`unpinned`,te=o(Cre[_]),B=[{label:o(`arcSidebar.docs`),icon:Ka,action:i},{label:o(`arcSidebar.analytics`),icon:$a,action:r},{label:o(`arcSidebar.settings`),icon:qs,action:a}];async function ne(e){try{await d(e.id)}catch{}}return(0,Y.jsxs)(`div`,{ref:z.panelRef,className:X(`relative flex flex-col h-full border-r border-border bg-background flex-shrink-0 overflow-hidden`,`transition-[width] duration-200 ease-in-out`),onMouseEnter:()=>{_===`unpinned`&&L(!0)},onMouseLeave:()=>{_===`unpinned`&&!z.dragging&&L(!1)},children:[R&&(0,Y.jsx)(lY,{side:`left`,dragging:z.dragging,width:z.width,min:200,max:460,label:o(`arcSidebar.resize`,{defaultValue:`Resize sidebar`}),onPointerDown:z.onGripPointerDown,onKeyDown:z.onGripKeyDown}),(0,Y.jsxs)(`div`,{className:X(`flex items-center h-12 border-b border-border flex-shrink-0`,R?`px-3 justify-between`:`justify-center`),children:[R&&(0,Y.jsx)(`span`,{className:`font-mono text-sm font-bold whitespace-nowrap overflow-hidden text-accent-primary`,children:o(`arcSidebar.desktopTitle`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:v,className:X(`flex items-center justify-center w-7 h-7 rounded-md transition-colors flex-shrink-0`,ee?`text-foreground bg-muted`:`text-muted-foreground/40 hover:text-muted-foreground hover:bg-muted/50`),"aria-label":te,title:o(`sidebarPin.withShortcut`,{label:te,shortcut:`⌥⌘B`}),children:(0,Y.jsx)(bs,{className:`w-4 h-4`})})]}),Rb&&(0,Y.jsxs)(`div`,{className:`py-2 px-1.5 space-y-0.5 border-b border-border`,children:[S&&(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{x.startNewConversation(l),g&&f(`/`)},className:X(`flex items-center gap-2 w-full h-8 rounded-md transition-colors`,`bg-accent-primary/15 text-accent-primary hover:bg-accent-primary/25`,R?`px-2`:`px-0 justify-center`),"aria-label":s(`newAgent`),title:R?void 0:s(`newAgent`),children:[(0,Y.jsx)(ks,{className:`w-4 h-4 flex-shrink-0`}),R&&(0,Y.jsx)(`span`,{className:`text-xs whitespace-nowrap`,children:s(`newAgent`)})]}),(0,Y.jsxs)(`button`,{type:`button`,onClick:b,className:X(`flex items-center gap-2 w-full h-8 rounded-md transition-colors`,`text-muted-foreground hover:text-foreground hover:bg-muted/50`,R?`px-2`:`px-0 justify-center`),"aria-label":s(S?`switchToKanban`:`switchToAgent`),title:s(S?`switchToKanban`:`switchToAgent`),children:[S?(0,Y.jsx)(is,{className:`w-4 h-4 flex-shrink-0`}):(0,Y.jsx)(qa,{className:`w-4 h-4 flex-shrink-0 text-accent-primary`}),R&&(0,Y.jsx)(`span`,{className:`min-w-0 truncate text-xs`,children:s(S?`switchToKanban`:`switchToAgent`)})]}),S&&(0,Y.jsxs)(`button`,{type:`button`,onClick:xre,className:X(`flex items-center gap-2 w-full h-8 rounded-md transition-colors`,`text-muted-foreground hover:text-foreground hover:bg-muted/50`,R?`px-2`:`px-0 justify-center`),"aria-label":s(`search`),title:R?void 0:s(`search`),children:[(0,Y.jsx)(Us,{className:`w-4 h-4 flex-shrink-0`}),R&&(0,Y.jsx)(`span`,{className:`text-xs whitespace-nowrap`,children:s(`search`)})]})]}),zb&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`py-2 px-1.5`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:t,className:X(`flex items-center gap-2 w-full h-8 rounded-md transition-colors`,R?`px-2`:`px-0 justify-center`,m?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),"aria-label":o(`arcSidebar.loops`),"aria-current":m?`page`:void 0,title:R?void 0:o(`arcSidebar.loops`),children:[(0,Y.jsx)(mc,{className:X(`w-4 h-4 flex-shrink-0`,m&&`text-accent-primary`)}),R&&(0,Y.jsx)(`span`,{className:`text-xs whitespace-nowrap`,children:o(`arcSidebar.loops`)})]}),(0,Y.jsxs)(`button`,{type:`button`,onClick:n,className:X(`mt-0.5 flex items-center gap-2 w-full h-8 rounded-md transition-colors`,R?`px-2`:`px-0 justify-center`,h?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),"aria-label":o(`arcSidebar.plugins`),"aria-current":h?`page`:void 0,title:R?void 0:o(`arcSidebar.plugins`),children:[(0,Y.jsx)(As,{className:X(`w-4 h-4 flex-shrink-0`,h&&`text-accent-primary`)}),R&&(0,Y.jsx)(`span`,{className:`text-xs whitespace-nowrap`,children:o(`arcSidebar.plugins`)})]})]}),(0,Y.jsx)(`div`,{className:`border-t border-border`,"aria-hidden":!0})]}),(0,Y.jsxs)(`div`,{className:`flex-1 overflow-y-auto py-2 px-1.5 space-y-0.5`,children:[S&&w.length>0&&(0,Y.jsxs)(`div`,{className:`mb-2 space-y-0.5 border-b border-border/70 pb-2`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>j(L7),className:X(`group flex items-center gap-2 w-full h-8 rounded-md transition-colors`,`text-muted-foreground hover:text-foreground hover:bg-muted/50`,R?`px-2`:`px-0 justify-center`),"aria-label":s(`favoriteMissions`),"aria-expanded":O,title:R?void 0:s(`favoriteMissions`),children:[R?(0,Y.jsxs)(`span`,{className:`relative flex h-4 w-4 flex-shrink-0 items-center justify-center`,children:[(0,Y.jsx)(Xo,{className:`h-4 w-4 fill-current text-accent-primary transition-opacity group-hover:opacity-0 group-focus-visible:opacity-0`}),(0,Y.jsx)(`span`,{className:`absolute inset-0 hidden items-center justify-center group-hover:flex group-focus-visible:flex`,children:O?(0,Y.jsx)(no,{className:`w-3.5 h-3.5`}):(0,Y.jsx)(io,{className:`w-3.5 h-3.5`})})]}):(0,Y.jsx)(Xo,{className:`w-4 h-4 flex-shrink-0 fill-current text-accent-primary`}),R&&(0,Y.jsx)(`span`,{className:`text-xs truncate flex-1 text-left`,children:s(`favoriteMissions`)})]}),O&&R&&(0,Y.jsx)(`div`,{className:`mt-0.5 space-y-0.5`,children:w.map(e=>(0,Y.jsx)(R7,{conversation:e,active:e.id===x.active?.id,streaming:x.streamingConversationIds.has(e.id),unread:x.unreadConversationIds.has(e.id),favorite:!0,expanded:R,onSelect:()=>M(e.id),onToggleFavorite:()=>P(e.id),onDelete:()=>N(e.id)},e.id))})]}),S&&T.length>0&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>j(I7),className:X(`group flex items-center gap-2 w-full h-8 rounded-md transition-colors`,`text-muted-foreground hover:text-foreground hover:bg-muted/50`,R?`px-2`:`px-0 justify-center`),"aria-label":s(`home`),"aria-expanded":E.has(I7),title:R?void 0:s(`home`),children:[R?(0,Y.jsxs)(`span`,{className:`relative flex h-4 w-4 flex-shrink-0 items-center justify-center`,children:[(0,Y.jsx)(Qo,{className:`h-4 w-4 transition-opacity group-hover:opacity-0 group-focus-visible:opacity-0`}),(0,Y.jsx)(`span`,{className:`absolute inset-0 hidden items-center justify-center group-hover:flex group-focus-visible:flex`,children:E.has(I7)?(0,Y.jsx)(no,{className:`w-3.5 h-3.5`}):(0,Y.jsx)(io,{className:`w-3.5 h-3.5`})})]}):(0,Y.jsx)(Qo,{className:`w-4 h-4 flex-shrink-0`}),R&&(0,Y.jsx)(`span`,{className:`text-xs truncate flex-1 text-left`,children:s(`home`)})]}),E.has(I7)&&R&&(0,Y.jsx)(`div`,{className:`mt-0.5 space-y-0.5`,children:T.map(e=>(0,Y.jsx)(R7,{conversation:e,active:e.id===x.active?.id,streaming:x.streamingConversationIds.has(e.id),unread:x.unreadConversationIds.has(e.id),expanded:R,onSelect:()=>M(e.id),onToggleFavorite:()=>P(e.id),onDelete:()=>N(e.id)},e.id))})]}),c.map(e=>{let t=C.get(e.id)??[];return(0,Y.jsx)(Sre,{project:e,isActive:e.id===l&&!g,expanded:R,onSelect:()=>F(e.id),onRemove:()=>ne(e),agentMode:S,hasTree:t.length>0,treeOpen:E.has(e.id),onToggleTree:()=>j(e.id),conversations:t,activeConversationId:x.active?.id??null,streamingConversationIds:x.streamingConversationIds,unreadConversationIds:x.unreadConversationIds,onSelectConversation:M,onToggleConversationFavorite:P,onDeleteConversation:N,onOpenProjectSettings:S?()=>{u(e.id),A(!0)}:void 0},e.id)}),(0,Y.jsxs)(`button`,{type:`button`,onClick:e,className:X(`flex items-center gap-2 w-full h-8 rounded-md transition-colors`,`text-muted-foreground hover:text-foreground hover:bg-muted/50`,R?`px-2`:`px-0 justify-center`),"aria-label":o(`projects.addProject`),title:R?void 0:o(`projects.addProject`),children:[(0,Y.jsx)(ks,{className:`w-4 h-4 flex-shrink-0`}),R&&(0,Y.jsx)(`span`,{className:`text-xs whitespace-nowrap`,children:o(`projects.addProject`)})]})]}),(0,Y.jsx)(`div`,{className:`border-t border-border py-2 px-1.5 space-y-0.5`,children:B.map(({label:e,icon:t,action:n})=>(0,Y.jsxs)(`button`,{type:`button`,onClick:n,className:X(`flex items-center gap-2 w-full h-8 rounded-md transition-colors`,`text-muted-foreground hover:text-foreground hover:bg-muted/50`,R?`px-2`:`px-0 justify-center`),"aria-label":e,title:R?void 0:e,children:[(0,Y.jsx)(t,{className:`w-4 h-4 flex-shrink-0`}),R&&(0,Y.jsx)(`span`,{className:`text-xs whitespace-nowrap`,children:e})]},e))}),k&&(0,Y.jsx)(H.Suspense,{fallback:null,children:(0,Y.jsx)(yre,{open:!0,onClose:()=>A(!1)})})]})}var Tre={"pinned-open":`sidebarPin.right.pinnedOpen`,"pinned-collapsed":`sidebarPin.right.pinnedCollapsed`,unpinned:`sidebarPin.right.unpinned`};function Ere(){let{t:e}=K(`nav`),{rightMode:t,cycleRightMode:n}=CY(),{projects:r,activeProjectId:i}=gm(),[a,o]=(0,H.useState)(!1),s=t===`pinned-open`||t===`unpinned`&&a,c=t!==`unpinned`,l=e(Tre[t]),u=r.find(e=>e.id===i),d=u?lm(u):[`claude`],f=Nb&&qD(`agents`,d),p=[{to:`/`,end:!0,icon:as,label:e(`rightSidebar.dashboard`)},{to:`/jobs`,end:!1,icon:Xa,label:e(`rightSidebar.jobs`)},{to:`/analytics`,end:!1,icon:Qa,label:e(`rightSidebar.analytics`)},...f?[{to:`/agents`,end:!1,icon:qa,label:e(`rightSidebar.agents`)}]:[],...Pb?[{to:`/code`,end:!1,icon:ho,label:e(`rightSidebar.code`)}]:[],{to:`/settings`,end:!1,icon:qs,label:e(`rightSidebar.settings`)}];return(0,Y.jsxs)(`div`,{className:X(`relative flex flex-col h-full border-l border-border bg-background flex-shrink-0`,`transition-all duration-200 ease-in-out overflow-hidden`,s?`w-44`:`w-11`),onMouseEnter:()=>{t===`unpinned`&&o(!0)},onMouseLeave:()=>{t===`unpinned`&&o(!1)},children:[(0,Y.jsxs)(`div`,{className:X(`flex items-center h-12 border-b border-border flex-shrink-0`,s?`px-3 justify-between`:`justify-center`),children:[s&&(0,Y.jsx)(`span`,{className:`font-mono text-sm font-bold whitespace-nowrap overflow-hidden text-accent-secondary`,children:e(`rightSidebar.projectTitle`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:n,className:X(`flex items-center justify-center w-7 h-7 rounded-md transition-colors`,c?`text-foreground bg-muted`:`text-muted-foreground/40 hover:text-muted-foreground hover:bg-muted/50`),"aria-label":l,title:e(`sidebarPin.withShortcut`,{label:l,shortcut:`⌘B`}),children:(0,Y.jsx)(xs,{className:`w-4 h-4`})})]}),(0,Y.jsx)(`nav`,{className:`flex-1 py-2 px-1.5 space-y-0.5`,children:p.map(({to:e,end:t,icon:n,label:r})=>(0,Y.jsxs)(Hn,{to:e,end:t,className:({isActive:e})=>X(`flex items-center gap-2 w-full h-8 rounded-md transition-colors`,s?`px-2`:`px-0 justify-center`,e?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),title:s?void 0:r,children:[(0,Y.jsx)(n,{className:`w-4 h-4 flex-shrink-0`}),s&&(0,Y.jsx)(`span`,{className:`text-xs truncate`,children:r})]},e))})]})}function Dre(e){return{darwin:{title:`macOS`,intro:e(`setup:instructions.darwin.intro`),commands:[{label:e(`setup:instructions.darwin.installNodeGit`),command:`brew install node git`}],links:[{label:e(`setup:instructions.links.nodeOfficial`),url:`https://nodejs.org/en/download`},{label:e(`setup:instructions.links.gitOfficial`),url:`https://git-scm.com/downloads`},{label:`Homebrew`,url:`https://brew.sh`}]},win32:{title:`Windows`,intro:e(`setup:instructions.win32.intro`),commands:[{label:e(`setup:instructions.win32.installNode`),command:`winget install OpenJS.NodeJS.LTS`},{label:e(`setup:instructions.win32.installGit`),command:`winget install Git.Git`}],links:[{label:e(`setup:instructions.links.nodeOfficial`),url:`https://nodejs.org/en/download`},{label:e(`setup:instructions.links.gitWindows`),url:`https://git-scm.com/download/win`}],note:e(`setup:instructions.win32.note`)},linux:{title:`Linux`,intro:e(`setup:instructions.linux.intro`),commands:[{label:e(`setup:instructions.linux.debian`),command:`sudo apt install -y nodejs npm git`},{label:e(`setup:instructions.linux.fedora`),command:`sudo dnf install -y nodejs npm git`}],links:[{label:e(`setup:instructions.links.nodeOfficial`),url:`https://nodejs.org/en/download`},{label:e(`setup:instructions.links.gitOfficial`),url:`https://git-scm.com/downloads`}]}}}var Ore=[`darwin`,`win32`,`linux`];async function kre(e){try{if(navigator.clipboard&&typeof navigator.clipboard.writeText==`function`)return await navigator.clipboard.writeText(e),!0}catch{}try{let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select();let n=document.execCommand(`copy`);return document.body.removeChild(t),n}catch{return!1}}function Are({command:e}){let{t}=K(`setup`),[n,r]=(0,H.useState)(!1);return(0,Y.jsx)(Z,{type:`button`,variant:`ghost`,size:`sm`,onClick:async()=>{await kre(e)&&(r(!0),window.setTimeout(()=>r(!1),1500))},className:`h-7 px-2 gap-1.5 text-[11px]`,"data-testid":`install-copy-button`,children:n?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(to,{className:`w-3 h-3`}),t(`common:actions.copied`)]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(bo,{className:`w-3 h-3`}),t(`common:actions.copy`)]})})}function z7({platform:e,primary:t}){let{t:n}=K(`setup`),r=Dre(n)[e];return(0,Y.jsxs)(`section`,{"data-testid":`install-section-${e}`,className:X(`rounded-lg border px-3 py-3`,t?`border-border/40 bg-background/40`:`border-border/20 bg-background/20`),children:[(0,Y.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:r.title}),r.intro&&(0,Y.jsx)(`p`,{className:`mt-1 text-[11px] text-muted-foreground`,children:r.intro}),(0,Y.jsx)(`div`,{className:`mt-2 space-y-2`,children:r.commands.map(e=>(0,Y.jsxs)(`div`,{className:`rounded-md border border-border/30 bg-background/60 px-2 py-2`,children:[(0,Y.jsx)(`p`,{className:`text-[11px] text-muted-foreground mb-1`,children:e.label}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Y.jsx)(`code`,{className:`text-xs text-foreground font-mono break-all`,children:e.command}),(0,Y.jsx)(Are,{command:e.command})]})]},e.command))}),r.links.length>0&&(0,Y.jsx)(`ul`,{className:`mt-2 flex flex-wrap gap-x-3 gap-y-1`,children:r.links.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-[11px] text-accent-info hover:underline`,children:[e.label,(0,Y.jsx)(Oo,{className:`w-3 h-3`})]})},e.url))}),r.note&&(0,Y.jsx)(`p`,{className:`mt-2 text-[11px] text-accent-highlight`,children:r.note})]})}function jre(){let{t:e}=K(`setup`),[t,n]=(0,H.useState)(`idle`);return(0,Y.jsxs)(Z,{type:`button`,variant:`ghost`,size:`sm`,onClick:async()=>{n(`copying`);try{let e=await fetch(`${o}/api/setup-prerequisites?diagnostic=1`);if(!e.ok)throw Error(`HTTP ${e.status}`);let t=await e.json();await navigator.clipboard.writeText(JSON.stringify(t,null,2)),n(`copied`),setTimeout(()=>n(`idle`),1800)}catch{n(`error`),setTimeout(()=>n(`idle`),2400)}},disabled:t===`copying`,className:`gap-1.5 text-[11px]`,"data-testid":`copy-diagnostics-button`,children:[t===`copied`?(0,Y.jsx)(to,{className:`w-3 h-3 text-accent-success`}):(0,Y.jsx)(fo,{className:`w-3 h-3`}),e(t===`copied`?`instructions.diagnostics.copied`:t===`error`?`instructions.diagnostics.failed`:`instructions.diagnostics.copy`)]})}function Mre({open:e,onClose:t,status:n,onRecheck:r,isRechecking:i}){let{t:a}=K(`setup`),[o,s]=(0,H.useState)(!1),c=n?.platform??`darwin`,l=Ore.filter(e=>e!==c);return n?.missingRequired?.some(e=>e.error===`corrupted-bundle`)??!1?(0,Y.jsx)(Cb,{open:e,onOpenChange:e=>{e||t()},children:(0,Y.jsxs)(Db,{movableResizable:!0,className:`max-w-xl`,"data-testid":`install-modal-corrupted-bundle`,children:[(0,Y.jsxs)(Ob,{children:[(0,Y.jsx)(Ab,{children:a(`instructions.corrupted.title`)}),(0,Y.jsx)(jb,{children:a(`instructions.corrupted.description`)})]}),(0,Y.jsx)(`p`,{className:`text-sm text-foreground`,children:a(`instructions.corrupted.body`)}),(0,Y.jsx)(`div`,{className:`flex justify-end mt-2`,children:(0,Y.jsx)(Z,{type:`button`,variant:`ghost`,size:`sm`,onClick:t,"data-testid":`install-corrupted-close-button`,children:a(`common:actions.close`)})})]})}):(0,Y.jsx)(Cb,{open:e,onOpenChange:e=>{e||t()},children:(0,Y.jsxs)(Db,{movableResizable:!0,className:`max-w-xl`,children:[(0,Y.jsxs)(Ob,{children:[(0,Y.jsx)(Ab,{children:a(`instructions.title`)}),(0,Y.jsx)(jb,{children:a(`instructions.description`)})]}),(0,Y.jsxs)(`div`,{className:`space-y-3`,children:[(0,Y.jsx)(z7,{platform:c,primary:!0}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>s(e=>!e),className:`text-[11px] text-muted-foreground hover:text-foreground underline-offset-2 hover:underline`,"data-testid":`install-toggle-others`,children:a(o?`instructions.hideOtherPlatforms`:`instructions.showOtherPlatforms`)}),o&&(0,Y.jsx)(`div`,{className:`space-y-3`,children:l.map(e=>(0,Y.jsx)(z7,{platform:e,primary:!1},e))})]}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mt-2`,children:[(0,Y.jsx)(jre,{}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(Z,{type:`button`,variant:`ghost`,size:`sm`,onClick:t,children:a(`common:actions.close`)}),(0,Y.jsxs)(Z,{type:`button`,variant:`default`,size:`sm`,onClick:r,disabled:i,className:`gap-1.5`,"data-testid":`install-recheck-button`,children:[(0,Y.jsx)(Fs,{className:X(`w-3 h-3`,i&&`animate-spin`)}),a(`instructions.recheck`)]})]})]})]})})}var Nre=typeof window<`u`&&`__TAURI_INTERNALS__`in window,B7=[`claude`,`codex`,`gemini`],Pre={claude:{icon:`🤖`,label:`Claude`},codex:{icon:`⚡`,label:`Codex`},gemini:{icon:`✨`,label:`Gemini`}};function V7(e){let t=B7.filter(t=>t in e),n=Object.keys(e).filter(e=>!B7.includes(e));return[...t,...n]}function Fre({open:e,onClose:t}){let[n,r]=(0,H.useState)(new Set([`claude`])),[i,o]=(0,H.useState)(``),[s,c]=(0,H.useState)(``),[l,u]=(0,H.useState)(!1),[d,f]=(0,H.useState)({claude:!0,codex:!1}),[p,m]=(0,H.useState)(!1),{t:h}=K(`setup`),{addProject:g,startSetupWizard:_,setActiveProjectId:v}=gm(),{status:y,isLoading:b,error:x,recheck:S}=vJ(),C=(0,H.useMemo)(()=>{if(!y||y.ok)return null;let e=y.missingRequired.map(e=>e.label);return e.length===0?null:h(`addProject.toolsRequired`,{tools:e.join(`, `),count:e.length})},[y,h]),w=y!==null&&!y.ok&&!x;(0,H.useEffect)(()=>{e&&fetch(`/api/available-providers`).then(e=>e.json()).then(e=>{let t={};for(let[n,r]of Object.entries(e))n!==`tiers`&&(t[n]=!!r);f(t);let n=new Set;for(let e of V7(t))t[e]&&n.add(e);n.size===0&&n.add(`claude`),r(n)}).catch(()=>{})},[e]);function T(e){r(t=>{let n=new Set(t);if(n.has(e)){if(n.size===1)return t;n.delete(e)}else n.add(e);return n})}let E=V7(d).filter(e=>n.has(e)&&d[e]);async function D(){let e=i.trim();if(!e){q.error(h(`addProject.errors.pathRequired`));return}if(E.length===0){q.error(h(`addProject.errors.selectProvider`));return}u(!0);try{let t=await g(e,s.trim()||void 0,E);if(!t)return;let{project:n}=t;t.has_specrails===!1?(O(),v(n.id),_(n.id)):(q.success(h(`addProject.toasts.registered`,{name:n.name})),O())}catch(e){q.error(h(`addProject.errors.addFailed`),{description:e.message})}finally{u(!1)}}function O(){o(``),c(``),t()}function k(e){e||O()}let A=!Object.values(d).some(Boolean);return(0,Y.jsx)(Cb,{open:e,onOpenChange:k,children:(0,Y.jsxs)(Db,{movableResizable:!0,className:`max-w-md`,children:[(0,Y.jsxs)(Ob,{children:[(0,Y.jsxs)(Ab,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(zo,{className:`w-4 h-4`}),h(`addProject.title`)]}),(0,Y.jsx)(jb,{children:h(`addProject.description`)})]}),A&&(0,Y.jsx)(`p`,{className:`text-xs text-destructive bg-destructive/10 rounded-md p-2`,children:h(`addProject.noProviderDetected`)}),(0,Y.jsx)(bJ,{status:y,isLoading:b,error:x,onMoreInfo:()=>m(!0),onRefresh:S}),(0,Y.jsxs)(`div`,{className:`space-y-4 py-2`,children:[(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsxs)(`label`,{className:`text-xs font-medium`,children:[h(`addProject.pathLabel`),` `,(0,Y.jsx)(`span`,{className:`text-destructive`,children:`*`})]}),(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(_W,{placeholder:h(`addProject.pathPlaceholder`),value:i,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&D()},autoFocus:!0,className:`flex-1`}),Nre&&(0,Y.jsx)(Z,{type:`button`,variant:`outline`,size:`icon`,className:`shrink-0`,title:h(`addProject.browseForFolder`),onClick:async()=>{try{let{open:e}=await a(async()=>{let{open:e}=await import(`./dist-js-BTAcxhPb.js`);return{open:e}},[]),t=await e({directory:!0,multiple:!1,title:h(`addProject.selectProjectFolder`)});typeof t==`string`&&t&&(o(t),s||c(t.split(`/`).filter(Boolean).pop()??``))}catch{}},children:(0,Y.jsx)(zo,{className:`w-4 h-4`})})]}),(0,Y.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:h(`addProject.pathHint`)})]}),(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsxs)(`label`,{className:`text-xs font-medium`,children:[h(`addProject.nameLabel`),` `,(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:h(`addProject.optional`)})]}),(0,Y.jsx)(_W,{placeholder:h(`addProject.namePlaceholder`),value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&D()}}),(0,Y.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:h(`addProject.nameHint`)})]}),(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:h(`addProject.providersLabel`)}),(0,Y.jsx)(`div`,{className:`flex gap-2`,children:V7(d).map(e=>{let{icon:t,label:r}=Pre[e]??{icon:`•`,label:e},i=d[e],a=n.has(e)&&i;return(0,Y.jsxs)(`button`,{type:`button`,role:`checkbox`,"aria-checked":a,disabled:!i,onClick:()=>T(e),"data-testid":`provider-toggle-${e}`,className:X(`flex items-center gap-1.5 rounded-md border px-3 py-1.5 text-left transition-colors text-xs`,`focus:outline-none focus-visible:ring-1 focus-visible:ring-ring`,a?`border-accent-primary/60 bg-accent-primary/10 text-foreground`:`border-border/30 text-muted-foreground hover:border-border/60`,!i&&`opacity-40 cursor-not-allowed`),children:[(0,Y.jsx)(`span`,{className:X(`inline-flex h-3.5 w-3.5 items-center justify-center rounded-sm border text-[9px] leading-none`,a?`border-accent-primary bg-accent-primary text-background`:`border-border/50`),"aria-hidden":!0,children:a?`✓`:``}),(0,Y.jsx)(`span`,{children:t}),(0,Y.jsx)(`span`,{className:`font-medium`,children:r}),!i&&(0,Y.jsx)(`span`,{className:`text-[9px] text-muted-foreground/60`,children:h(`addProject.notFound`)})]},e)})}),(0,Y.jsx)(`p`,{className:`text-[9px] text-muted-foreground/70`,children:E.length>1?h(`addProject.multiProviderHint`):h(`addProject.singleProviderHint`)})]})]}),(0,Y.jsxs)(kb,{children:[(0,Y.jsx)(Z,{variant:`outline`,size:`sm`,onClick:t,disabled:l,children:h(`common:actions.cancel`)}),(0,Y.jsx)(Z,{size:`sm`,onClick:D,disabled:l||!i.trim()||A||E.length===0||w||b,title:w?C??void 0:void 0,"data-testid":`add-project-submit`,children:h(l?`addProject.adding`:`addProject.submit`)})]}),(0,Y.jsx)(Mre,{open:p,onClose:()=>m(!1),status:y,onRecheck:S,isRechecking:b})]})})}var H7=1,Ire=.9,Lre=.8,Rre=.17,U7=.1,W7=.999,zre=.9999,Bre=.99,Vre=/[\\\/_+.#"@\[\(\{&]/,Hre=/[\\\/_+.#"@\[\(\{&]/g,Ure=/[\s-]/,G7=/[\s-]/g;function K7(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?H7:Bre;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=K7(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=H7:Vre.test(e.charAt(l-1))?(d*=Lre,p=e.slice(i,l-1).match(Hre),p&&i>0&&(d*=W7**+p.length)):Ure.test(e.charAt(l-1))?(d*=Ire,m=e.slice(i,l-1).match(G7),m&&i>0&&(d*=W7**+m.length)):(d*=Rre,i>0&&(d*=W7**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=zre)),(d<U7&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=K7(e,t,n,r,l+1,a+2,o),f*U7>d&&(d=f*U7)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function q7(e){return e.toLowerCase().replace(G7,` `)}function Wre(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,K7(e,t,q7(e),q7(t),0,0,{})}var J7=`[cmdk-group=""]`,Y7=`[cmdk-group-items=""]`,Gre=`[cmdk-group-heading=""]`,X7=`[cmdk-item=""]`,Z7=`${X7}:not([aria-disabled="true"])`,Q7=`cmdk-item-select`,$7=`data-value`,Kre=(e,t,n)=>Wre(e,t,n),e9=H.createContext(void 0),t9=()=>H.useContext(e9),n9=H.createContext(void 0),r9=()=>H.useContext(n9),i9=H.createContext(void 0),a9=H.forwardRef((e,t)=>{let n=l9(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=l9(()=>new Set),i=l9(()=>new Map),a=l9(()=>new Map),o=l9(()=>new Set),s=s9(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,v=i_(),y=i_(),b=i_(),x=H.useRef(null),S=rie();c9(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,C.emit()}},[u]),c9(()=>{S(6,k)},[]);let C=H.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)O(),E(),S(1,D);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(b);e?e.focus():(i=document.getElementById(v))==null||i.focus()}if(S(7,()=>{n.current.selectedItemId=A()?.id,C.emit()}),r||S(5,k),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}C.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),w=H.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,T(t,r)),S(2,()=>{E(),C.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),S(3,()=>{O(),E(),n.current.value||D(),C.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=A();S(4,()=>{O(),t?.getAttribute(`id`)===e&&D(),C.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:v,inputId:b,labelId:y,listInnerRef:x}),[]);function T(e,t){let r=s.current?.filter??Kre;return e?r(e,n.current.search,t):0}function E(){if(!n.current.search||s.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=x.current;j().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(Y7);t?t.appendChild(e.parentElement===t?e:e.closest(`${Y7} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${Y7} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=x.current?.querySelector(`${J7}[${$7}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function D(){let e=j().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute($7);C.setState(`value`,e||void 0)}function O(){if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=T(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function k(){var e;let t=A();t&&(t.parentElement?.firstChild===t&&((e=t.closest(J7)?.querySelector(Gre))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function A(){return x.current?.querySelector(`${X7}[aria-selected="true"]`)}function j(){return Array.from(x.current?.querySelectorAll(Z7)||[])}function M(e){let t=j()[e];t&&C.setState(`value`,t.getAttribute($7))}function N(e){var t;let n=A(),r=j(),i=r.findIndex(e=>e===n),a=r[i+e];(t=s.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&C.setState(`value`,a.getAttribute($7))}function P(e){let t=A()?.closest(J7),n;for(;t&&!n;)t=e>0?tie(t,J7):nie(t,J7),n=t?.querySelector(Z7);n?C.setState(`value`,n.getAttribute($7)):N(e)}let F=()=>M(j().length-1),I=e=>{e.preventDefault(),e.metaKey?F():e.altKey?P(1):N(1)},L=e=>{e.preventDefault(),e.metaKey?M(0):e.altKey?P(-1):N(-1)};return H.createElement(h_.div,{ref:t,tabIndex:-1,..._,"cmdk-root":``,onKeyDown:e=>{var t;(t=_.onKeyDown)==null||t.call(_,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:g&&e.ctrlKey&&I(e);break;case`ArrowDown`:I(e);break;case`p`:case`k`:g&&e.ctrlKey&&L(e);break;case`ArrowUp`:L(e);break;case`Home`:e.preventDefault(),M(0);break;case`End`:e.preventDefault(),F();break;case`Enter`:{e.preventDefault();let t=A();if(t){let e=new Event(Q7);t.dispatchEvent(e)}}}}},H.createElement(`label`,{"cmdk-label":``,htmlFor:w.inputId,id:w.labelId,style:aie},c),f9(e,e=>H.createElement(n9.Provider,{value:C},H.createElement(e9.Provider,{value:w},e))))}),qre=H.forwardRef((e,t)=>{let n=i_(),r=H.useRef(null),i=H.useContext(i9),a=t9(),o=s9(e),s=o.current?.forceMount??i?.forceMount;c9(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=d9(n,r,[e.value,e.children,r],e.keywords),l=r9(),u=u9(e=>e.value&&e.value===c.current),d=u9(e=>s||a.filter()===!1?!0:e.search?e.filtered.items.get(n)>0:!0);H.useEffect(()=>{let t=r.current;if(!(!t||e.disabled))return t.addEventListener(Q7,f),()=>t.removeEventListener(Q7,f)},[d,e.onSelect,e.disabled]);function f(){var e,t;p(),(t=(e=o.current).onSelect)==null||t.call(e,c.current)}function p(){l.setState(`value`,c.current,!0)}if(!d)return null;let{disabled:m,value:h,onSelect:g,forceMount:_,keywords:v,...y}=e;return H.createElement(h_.div,{ref:Om(r,t),...y,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!m,"aria-selected":!!u,"data-disabled":!!m,"data-selected":!!u,onPointerMove:m||a.getDisablePointerSelection()?void 0:p,onClick:m?void 0:f},e.children)}),Jre=H.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=i_(),s=H.useRef(null),c=H.useRef(null),l=i_(),u=t9(),d=u9(e=>i||u.filter()===!1?!0:e.search?e.filtered.groups.has(o):!0);c9(()=>u.group(o),[]),d9(o,s,[e.value,e.heading,c]);let f=H.useMemo(()=>({id:o,forceMount:i}),[i]);return H.createElement(h_.div,{ref:Om(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:d?void 0:!0},n&&H.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),f9(e,e=>H.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},H.createElement(i9.Provider,{value:f},e))))}),Yre=H.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=H.useRef(null),a=u9(e=>!e.search);return!n&&!a?null:H.createElement(h_.div,{ref:Om(i,t),...r,"cmdk-separator":``,role:`separator`})}),Xre=H.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=r9(),o=u9(e=>e.search),s=u9(e=>e.selectedItemId),c=t9();return H.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),H.createElement(h_.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":s,id:c.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),Zre=H.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=H.useRef(null),o=H.useRef(null),s=u9(e=>e.selectedItemId),c=t9();return H.useEffect(()=>{if(o.current&&a.current){let e=o.current,t=a.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),H.createElement(h_.div,{ref:Om(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},f9(e,e=>H.createElement(`div`,{ref:Om(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),Qre=H.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return H.createElement(Xy,{open:n,onOpenChange:r},H.createElement(Zy,{container:o},H.createElement(Qy,{"cmdk-overlay":``,className:i}),H.createElement($y,{"aria-label":e.label,"cmdk-dialog":``,className:a},H.createElement(a9,{ref:t,...s}))))}),$re=H.forwardRef((e,t)=>u9(e=>e.filtered.count===0)?H.createElement(h_.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),eie=H.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return H.createElement(h_.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},f9(e,e=>H.createElement(`div`,{"aria-hidden":!0},e)))}),o9=Object.assign(a9,{List:Zre,Item:qre,Input:Xre,Group:Jre,Separator:Yre,Dialog:Qre,Empty:$re,Loading:eie});function tie(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function nie(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function s9(e){let t=H.useRef(e);return c9(()=>{t.current=e}),t}var c9=typeof window>`u`?H.useEffect:H.useLayoutEffect;function l9(e){let t=H.useRef();return t.current===void 0&&(t.current=e()),t}function u9(e){let t=r9(),n=()=>e(t.snapshot());return H.useSyncExternalStore(t.subscribe,n,n)}function d9(e,t,n,r=[]){let i=H.useRef(),a=t9();return c9(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute($7,s),i.current=s}),i}var rie=()=>{let[e,t]=H.useState(),n=l9(()=>new Map);return c9(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function iie(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function f9({asChild:e,children:t},n){return e&&H.isValidElement(t)?H.cloneElement(iie(t),{ref:t.ref},n(t.props.children)):n(t)}var aie={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`};function oie({onOpenSettings:e,onOpenAnalytics:t,onOpenDocs:n}){let{t:r}=K(`commands`),[i,a]=(0,H.useState)(!1),[o,s]=(0,H.useState)([]),[c,l]=(0,H.useState)([]),{projects:u,activeProjectId:d,setActiveProjectId:f}=gm(),{leftMode:p,rightMode:m,cycleLeftMode:h,cycleRightMode:g}=CY(),_=r(p===`pinned-open`?`palette.sidebar.collapseLeftKeepPinned`:p===`pinned-collapsed`?`palette.sidebar.unpinLeft`:`palette.sidebar.pinLeftOpen`),v=r(m===`pinned-open`?`palette.sidebar.collapseRightKeepPinned`:m===`pinned-collapsed`?`palette.sidebar.unpinRight`:`palette.sidebar.pinRightOpen`),y=_t(),b=(0,H.useRef)(!1);(0,H.useEffect)(()=>{function e(e){e.key===`k`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),a(e=>!e))}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),(0,H.useEffect)(()=>{if(!i){b.current=!1;return}if(b.current)return;b.current=!0;async function e(){try{let[e,t]=await Promise.all([fetch(`${af()}/config`),fetch(`${af()}/jobs?limit=10`)]);e.ok&&s((await e.json()).commands),t.ok&&l((await t.json()).jobs)}catch{}}e()},[i]);let x=(0,H.useCallback)(e=>{f(e),a(!1)},[f]),S=(0,H.useCallback)(async e=>{a(!1);try{let t=await fetch(`${af()}/spawn`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({command:`/specrails:${e}`})}),n=await t.json();if(!t.ok)throw Error(n.error??r(`errors.spawnFailed`));q.success(r(`toasts.queued`,{name:e})),y(`/jobs/${n.jobId}`)}catch(e){q.error(e instanceof Error?e.message:r(`errors.spawnFailed`))}},[y,r]),C=(0,H.useCallback)(e=>{a(!1),y(`/jobs/${e}`)},[y]),w=(0,H.useCallback)(e=>{a(!1),y(e)},[y]),T=(0,H.useCallback)(e=>{e&&(a(!1),e())},[]),E=`flex items-center gap-3 px-3 py-2 rounded-lg cursor-pointer text-sm data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground`;return(0,Y.jsxs)(o9.Dialog,{open:i,onOpenChange:a,label:r(`palette.label`),className:X(`fixed left-[50%] top-[50%] z-50 w-full max-w-lg translate-x-[-50%] translate-y-[-50%]`,`border border-border/30 bg-popover shadow-2xl backdrop-blur-md rounded-xl overflow-hidden`),children:[(0,Y.jsx)(`span`,{className:`sr-only`,children:r(`palette.label`)}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 px-3 border-b border-border/30`,children:[(0,Y.jsx)(Us,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,Y.jsx)(o9.Input,{placeholder:r(`palette.searchPlaceholder`),className:`flex-1 h-11 bg-transparent text-sm outline-none placeholder:text-muted-foreground/50`}),(0,Y.jsx)(`kbd`,{className:`hidden sm:inline-flex items-center gap-0.5 rounded border border-border/50 bg-muted/30 px-1.5 py-0.5 text-[10px] text-muted-foreground font-mono`,children:`esc`})]}),(0,Y.jsxs)(o9.List,{className:`max-h-80 overflow-y-auto p-2`,children:[(0,Y.jsx)(o9.Empty,{className:`py-8 text-center text-sm text-muted-foreground`,children:r(`palette.noResults`)}),u.length>0&&(0,Y.jsx)(o9.Group,{heading:r(`palette.groups.projects`),children:u.map(e=>(0,Y.jsxs)(o9.Item,{value:e.name,keywords:[e.slug],onSelect:()=>x(e.id),className:X(E,e.id===d&&`text-accent-primary`),children:[(0,Y.jsx)(zo,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,Y.jsx)(`span`,{className:`flex-1 truncate`,children:e.name}),e.id===d&&(0,Y.jsx)(`span`,{className:`text-[10px] text-accent-primary font-medium`,children:r(`palette.activeBadge`)})]},e.id))}),o.length>0&&(0,Y.jsx)(o9.Group,{heading:r(`palette.groups.spec`),children:o.map(e=>(0,Y.jsxs)(o9.Item,{value:e.name,keywords:[e.slug,e.description??``],onSelect:()=>S(e.slug),className:E,children:[(0,Y.jsx)(gc,{className:`w-4 h-4 text-accent-info shrink-0`}),(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Y.jsx)(`span`,{className:`truncate`,children:e.name}),e.description&&(0,Y.jsx)(`span`,{className:`text-[11px] text-muted-foreground/60 ml-2 truncate`,children:e.description})]})]},e.id))}),c.length>0&&(0,Y.jsx)(o9.Group,{heading:r(`palette.groups.jobs`),children:c.map(e=>(0,Y.jsxs)(o9.Item,{value:`${e.command} ${e.id}`,keywords:[e.status],onSelect:()=>C(e.id),className:E,children:[(0,Y.jsx)(Xa,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,Y.jsx)(`span`,{className:`flex-1 truncate`,children:e.command}),(0,Y.jsx)(`span`,{className:X(`text-[10px] font-medium`,e.status===`completed`&&`text-accent-success`,e.status===`failed`&&`text-destructive`,e.status===`running`&&`text-accent-info`,e.status===`queued`&&`text-muted-foreground`),children:r(`common:status.${e.status}`,{defaultValue:e.status})})]},e.id))}),(0,Y.jsxs)(o9.Group,{heading:r(`palette.groups.navigation`),children:[(0,Y.jsxs)(o9.Item,{value:r(`palette.nav.dashboard`),keywords:[`home`],onSelect:()=>w(`/`),className:E,children:[(0,Y.jsx)(as,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,Y.jsx)(`span`,{children:r(`palette.nav.dashboard`)})]}),t&&(0,Y.jsxs)(o9.Item,{value:r(`palette.nav.desktopAnalytics`),keywords:[`cross-project`,`desktop`],onSelect:()=>T(t),className:E,children:[(0,Y.jsx)(eo,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,Y.jsx)(`span`,{children:r(`palette.nav.desktopAnalytics`)})]}),(0,Y.jsxs)(o9.Item,{value:r(`palette.nav.projectAnalytics`),keywords:[`metrics`],onSelect:()=>w(`/analytics`),className:E,children:[(0,Y.jsx)(Qa,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,Y.jsx)(`span`,{children:r(`palette.nav.projectAnalytics`)})]}),(0,Y.jsxs)(o9.Item,{value:r(`palette.nav.activityFeed`),keywords:[`log`],onSelect:()=>w(`/activity`),className:E,children:[(0,Y.jsx)(La,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,Y.jsx)(`span`,{children:r(`palette.nav.activityFeed`)})]}),(0,Y.jsxs)(o9.Item,{value:r(`palette.nav.desktopSettings`),keywords:[`configuration`],onSelect:()=>e?T(e):w(`/settings`),className:E,children:[(0,Y.jsx)(qs,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,Y.jsx)(`span`,{children:r(`palette.nav.desktopSettings`)})]}),(0,Y.jsxs)(o9.Item,{value:r(`palette.nav.docs`),keywords:[`documentation`],onSelect:()=>n?T(n):w(`/docs`),className:E,children:[(0,Y.jsx)(Po,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,Y.jsx)(`span`,{children:r(`palette.nav.docs`)})]}),(0,Y.jsxs)(o9.Item,{value:_,keywords:[`sidebar`,`panel`,`left`,`pin`,`collapse`,`unpin`,`cycle`],onSelect:()=>{h(),a(!1)},className:E,children:[(0,Y.jsx)(bs,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,Y.jsx)(`span`,{children:_})]}),(0,Y.jsxs)(o9.Item,{value:v,keywords:[`sidebar`,`panel`,`right`,`nav`,`pin`,`collapse`,`unpin`,`cycle`],onSelect:()=>{g(),a(!1)},className:E,children:[(0,Y.jsx)(xs,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,Y.jsx)(`span`,{children:v})]})]})]}),(0,Y.jsx)(`div`,{className:`flex items-center justify-between px-3 py-2 border-t border-border/30 text-[10px] text-muted-foreground/50`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`kbd`,{className:`font-mono`,children:`↑↓`}),` `,r(`palette.footer.navigate`)]}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`kbd`,{className:`font-mono`,children:`↵`}),` `,r(`palette.footer.select`)]}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`kbd`,{className:`font-mono`,children:`esc`}),` `,r(`palette.footer.close`)]})]})})]})}var sie=`
145
+ `))}function tre(e,t){let n=(e??``).normalize(`NFKD`).replace(/[\u0300-\u036f]/g,``).toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``),r=t.trim()||`mission`;return`${n||r}.txt`}function nre(){let{t:e}=K(`agent`),{active:t,messages:n,renameConversation:r,deleteConversation:i,startNewConversation:a,favoriteConversationIds:o,toggleFavoriteConversation:s}=N7(),{projects:c}=gm(),[l,u]=(0,H.useState)(!1),[d,f]=(0,H.useState)(!1),[p,m]=(0,H.useState)(``),[h,g]=(0,H.useState)(null),[_,v]=(0,H.useState)(!1),y=(0,H.useRef)(null),b=(0,H.useRef)(null),x=t?.pinned_project_id?c.find(e=>e.id===t.pinned_project_id)??null:null,S=t?.title?.trim()||e(`header.untitled`),C=t?o.has(t.id):!1;(0,H.useEffect)(()=>{if(!l)return;let e=e=>{y.current&&!y.current.contains(e.target)&&u(!1)},t=e=>{e.key===`Escape`&&u(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[l]),(0,H.useEffect)(()=>{l||v(!1)},[l]),(0,H.useEffect)(()=>{d&&(b.current?.focus(),b.current?.select())},[d]);let w=(0,H.useCallback)(()=>{m(t?.title??``),f(!0),u(!1)},[t?.title]),T=(0,H.useCallback)(async()=>{if(t&&(f(!1),(t.title??``)!==p.trim()))try{await r(t.id,p)}catch{q.error(e(`header.renameFailed`))}},[t,p,r,e]),E=(0,H.useCallback)(async(t,n)=>{u(!1);try{await navigator.clipboard.writeText(t),g(n),setTimeout(()=>g(e=>e===n?null:e),1400)}catch{q.error(e(`header.copyFailed`))}},[e]),D=(0,H.useCallback)(async()=>{if(t){u(!1);try{await navigator.clipboard.writeText(y7(t,n,x)),g(`transcript`),q.success(e(`header.copyTranscriptSuccess`,{defaultValue:`Transcript copied`})),setTimeout(()=>g(e=>e===`transcript`?null:e),1400)}catch{q.error(e(`header.copyTranscriptFailed`,{defaultValue:`Could not copy transcript`}))}}},[t,n,x,e]),O=(0,H.useCallback)(()=>{if(t){u(!1);try{let r=y7(t,n,x),i=new Blob([r],{type:`text/plain;charset=utf-8`}),a=URL.createObjectURL(i),o=document.createElement(`a`);o.href=a,o.download=tre(t.title,t.id),document.body.appendChild(o),o.click(),o.remove(),URL.revokeObjectURL(a),q.success(e(`header.exportTranscriptSuccess`,{defaultValue:`Transcript export started`}))}catch{q.error(e(`header.exportTranscriptFailed`,{defaultValue:`Could not export transcript`}))}}},[t,n,x,e]),k=(0,H.useCallback)(async()=>{if(t){u(!1),v(!1);try{await i(t.id),a(t.pinned_project_id)}catch{q.error(e(`header.deleteFailed`))}}},[t,i,a,e]),A=(0,H.useCallback)(()=>{t&&(s(t.id),u(!1))},[t,s]);if(!t)return null;let j=[{id:`name`,label:e(`header.copyName`),value:t.title??S},{id:`id`,label:e(`header.copyId`),value:t.id},...x?[{id:`project`,label:e(`header.copyProject`),value:x.name},{id:`path`,label:e(`header.copyProjectPath`),value:x.path}]:[]];return(0,Y.jsxs)(`div`,{ref:y,"data-agent-interactive":!0,className:`relative flex h-12 shrink-0 items-center gap-2 border-b border-border px-4`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5 text-sm`,children:[x&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`max-w-[42%] shrink-0 truncate font-mono text-[12px] text-foreground/35`,title:x.path,children:x.path}),(0,Y.jsx)(io,{className:`h-3.5 w-3.5 shrink-0 text-foreground/25`,"aria-hidden":!0})]}),d?(0,Y.jsx)(`input`,{ref:b,value:p,onChange:e=>m(e.target.value),onBlur:()=>void T(),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),T()):e.key===`Escape`&&(e.preventDefault(),f(!1))},placeholder:e(`header.renamePlaceholder`),className:`min-w-0 flex-1 rounded-md border border-accent-primary/40 bg-surface/60 px-2 py-0.5 text-sm text-foreground outline-none focus:border-accent-primary/70`,maxLength:200}):(0,Y.jsx)(`button`,{type:`button`,onDoubleClick:w,title:e(`header.renameHint`),className:`min-w-0 flex-1 truncate text-left font-medium text-foreground/85`,children:S})]}),(0,Y.jsx)(`button`,{type:`button`,"data-testid":`agent-conv-menu-trigger`,"aria-label":e(`header.menu`),"aria-haspopup":`menu`,"aria-expanded":l,onClick:()=>u(e=>!e),className:X(`flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-foreground/45 transition-colors hover:bg-surface hover:text-foreground/80`,l&&`bg-surface text-foreground/80`),children:(0,Y.jsx)(Do,{className:`h-4 w-4`})}),(0,Y.jsx)(H3,{children:l&&(0,Y.jsx)(V8.div,{role:`menu`,"data-testid":`agent-conv-menu`,initial:{opacity:0,y:-4,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-4,scale:.98},transition:{duration:.14,ease:`easeOut`},className:`absolute right-3 top-11 z-50 min-w-[220px] overflow-hidden rounded-xl border border-border/50 bg-card/95 p-1 shadow-2xl backdrop-blur-xl`,children:_?(0,Y.jsxs)(`div`,{className:`p-2`,"data-testid":`agent-conv-delete-confirm`,children:[(0,Y.jsx)(`p`,{className:`px-1 pb-2.5 text-xs leading-relaxed text-foreground/70`,children:e(`header.deleteConfirm`)}),(0,Y.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,Y.jsx)(`button`,{type:`button`,"data-testid":`agent-conv-delete-confirm-btn`,onClick:()=>void k(),className:`flex-1 rounded-lg bg-destructive/90 px-2.5 py-1.5 text-xs font-medium text-white transition-colors hover:bg-destructive`,children:e(`header.delete`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>v(!1),className:`flex-1 rounded-lg border border-border/60 px-2.5 py-1.5 text-xs text-foreground/80 transition-colors hover:bg-surface/80`,children:e(`common:actions.cancel`)})]})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`agent-conv-rename`,onClick:w,className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-sm text-foreground/85 transition-colors hover:bg-surface/80`,children:[(0,Y.jsx)(ws,{className:`h-3.5 w-3.5 shrink-0 text-foreground/50`}),e(`header.rename`)]}),(0,Y.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`agent-conv-favorite`,onClick:A,className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-sm text-foreground/85 transition-colors hover:bg-surface/80`,children:[(0,Y.jsx)(Xo,{className:X(`h-3.5 w-3.5 shrink-0`,C?`text-accent-primary`:`text-foreground/50`),fill:C?`currentColor`:`none`}),e(C?`header.removeFavorite`:`header.addFavorite`)]}),(0,Y.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`agent-conv-delete`,onClick:()=>v(!0),className:`group/del flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-sm text-foreground/85 transition-colors hover:bg-destructive/10 hover:text-destructive`,children:[(0,Y.jsx)(cc,{className:`h-3.5 w-3.5 shrink-0 text-foreground/50 group-hover/del:text-destructive`}),e(`header.delete`)]}),(0,Y.jsx)(`div`,{className:`my-1 h-px bg-border/50`}),(0,Y.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`agent-conv-copy-transcript`,onClick:()=>void D(),className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-sm text-foreground/85 transition-colors hover:bg-surface/80`,children:[h===`transcript`?(0,Y.jsx)(to,{className:`h-3.5 w-3.5 shrink-0 text-accent-success`}):(0,Y.jsx)(bo,{className:`h-3.5 w-3.5 shrink-0 text-foreground/50`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:e(`header.copyTranscript`,{defaultValue:`Copy transcript`})})]}),(0,Y.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`agent-conv-export-transcript`,onClick:O,className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-sm text-foreground/85 transition-colors hover:bg-surface/80`,children:[(0,Y.jsx)(To,{className:`h-3.5 w-3.5 shrink-0 text-foreground/50`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:e(`header.exportTranscript`,{defaultValue:`Export transcript (.txt)`})})]}),j.map(e=>e===`divider`?null:(0,Y.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`agent-conv-copy-${e.id}`,onClick:()=>void E(e.value,e.id),className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-sm text-foreground/85 transition-colors hover:bg-surface/80`,children:[h===e.id?(0,Y.jsx)(to,{className:`h-3.5 w-3.5 shrink-0 text-accent-success`}):(0,Y.jsx)(bo,{className:`h-3.5 w-3.5 shrink-0 text-foreground/50`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:e.label})]},e.id))]})})})]})}var rre=new Set([`building`,`on_review`,`pr_draft`,`implementation_failed`,`pr_failed`]);function b7(e){return rre.has(e)}function ire(e){let t=new Map,n=[];for(let r of e){if(r.role!==`system`)continue;let e=UY(r.content);e&&(t.set(r.id,e),b7(e.decision)&&n.push({messageId:r.id,envelope:e}))}return{byMessageId:t,pinned:n}}var are=(0,H.lazy)(()=>a(()=>import(`./JobDetailModal-D-BeqsJ6.js`).then(e=>({default:e.JobDetailModal})),__vite__mapDeps([27,1,28,29,30,31]))),ore=(0,H.lazy)(()=>a(()=>import(`./LoopPreviewModal-Dw4UgoLu.js`).then(e=>({default:e.LoopPreviewModal})),__vite__mapDeps([32,1,30,33]))),x7=new Set;function S7({variant:e}){let{t}=K(`agent`),{active:n,messages:r,streamingText:i,isStreaming:a,liveTools:o,queuedMessages:s,mcpEnabled:c,enablingMcp:l,enableMcpServer:u,providersReady:d,cycleTier:f,send:p}=N7(),m=(0,H.useRef)(null),h=hR(i,a),{openRef:g,jobRef:_,closeJobRef:v,loopRef:y,closeLoopRef:b}=W8(),x=n?.pinned_project_id??null,[S,C]=(0,H.useState)(new Map),w=(0,H.useMemo)(()=>{let e=new Set;for(let t of r)for(let n of t.attachment_ids??[])e.add(n);return[...e].sort()},[r]).join(`\0`);(0,H.useEffect)(()=>{let e=w?w.split(`\0`):[];if(!n?.id||e.length===0){C(new Map);return}let t=!1,r=new Set(e);return PY(n.id).then(e=>{t||C(new Map(e.filter(e=>r.has(e.id)).map(e=>[e.id,e])))}).catch(()=>{t||C(new Map)}),()=>{t=!0}},[n?.id,w]);let T=(0,H.useMemo)(()=>x?e=>{g(x,e)}:void 0,[x,g]),E=BU().id===`code-rain`?t(`emptyTitleCodeRain`):t(`emptyTitle`),D=(0,H.useMemo)(()=>ire(r),[r]),O=(0,H.useRef)(!0),k=()=>{let e=m.current;e&&(O.current=e.scrollHeight-e.scrollTop-e.clientHeight<48)};(0,H.useEffect)(()=>{O.current&&m.current?.scrollTo?.({top:m.current.scrollHeight,behavior:`auto`})},[r.length,h,o.length,s.length]);let A=e=>{e.shiftKey&&(e.key===`Tab`||e.code===`Tab`)&&(e.preventDefault(),e.stopPropagation(),f())},j=e===`inline`,M=j?`mx-auto flex w-full max-w-[820px] flex-1 flex-col overflow-hidden`:`flex flex-1 flex-col overflow-hidden`;return(0,Y.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden `,onKeyDown:A,children:[d===!1&&(0,Y.jsxs)(`div`,{className:`flex items-start gap-2 border-b border-border/50 bg-accent-warning/10 px-3 py-2 text-xs text-foreground`,children:[(0,Y.jsx)(_s,{className:`mt-0.5 h-4 w-4 shrink-0 text-accent-warning`}),(0,Y.jsxs)(`div`,{className:`flex-1`,children:[(0,Y.jsx)(`p`,{className:`font-medium`,children:t(`noProvider.title`)}),(0,Y.jsx)(`p`,{className:`mt-0.5 text-foreground/70`,children:t(`noProvider.body`)})]})]}),d!==!1&&!c&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/50 bg-accent-warning/10 px-3 py-2 text-xs text-foreground`,children:[(0,Y.jsx)(Js,{className:`h-4 w-4 shrink-0 text-accent-warning`}),(0,Y.jsx)(`span`,{className:`flex-1`,children:t(`degraded.body`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>void u(),disabled:l,className:`rounded-md bg-accent-primary px-2 py-1 text-xs font-medium text-white disabled:opacity-60`,children:t(l?`degraded.enabling`:`degraded.enable`)})]}),j&&n&&(0,Y.jsx)(nre,{}),(0,Y.jsxs)(`div`,{className:M,children:[(0,Y.jsxs)(V8.div,{ref:m,onScroll:k,initial:j?{opacity:0,y:8}:!1,animate:{opacity:1,y:0},transition:{duration:.35,ease:`easeOut`},className:`flex-1 space-y-5 overflow-y-auto px-4 py-4`,children:[r.length===0&&!a&&(0,Y.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center text-center text-foreground/50`,children:[(0,Y.jsx)(qa,{className:`mb-2 h-8 w-8 text-accent-primary/60`}),(0,Y.jsx)(`p`,{className:`text-sm font-medium text-foreground/70`,children:E}),(0,Y.jsx)(`p`,{className:`mt-1 max-w-[280px] text-xs`,children:t(`emptyHint`)})]}),r.map((e,n)=>{if(e.role===`system`){let n=D.byMessageId.get(e.id);return n?b7(n.decision)?(0,Y.jsxs)(`div`,{"data-testid":`agent-pr-pinned-marker`,className:`flex items-center gap-2 rounded-lg border border-border/40 bg-surface/30 px-3 py-1.5 text-[11px] text-foreground/45 backdrop-blur-sm`,children:[(0,Y.jsx)(Ts,{className:`h-3 w-3 shrink-0 text-accent-primary/50`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t(`prCard.pinned.marker`)}),(0,Y.jsx)(m7,{decision:n.decision})]},e.id):(0,Y.jsx)(p7,{envelope:n},e.id):(x7.has(e.id)||(x7.add(e.id),console.warn(`[agent-chat] skipping unrenderable system message ${e.id}`)),null)}return(0,Y.jsx)(W5,{role:e.role,content:e.content,createdAt:e.created_at,isLast:!a&&n===r.length-1,onPickOption:e=>void p(e),refsProjectId:x,onOpenRef:T,contextRefs:e.context_refs,conversationId:e.conversation_id,attachments:(e.attachment_ids??[]).map(e=>S.get(e)).filter(e=>!!e)},e.id)}),a&&(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[h&&(0,Y.jsx)(W5,{role:`assistant`,content:h,streaming:!0}),(0,Y.jsx)(q8,{tool:o.length?o[o.length-1].tool:null})]}),s.length>0&&(0,Y.jsx)(`div`,{className:`space-y-2`,"data-testid":`agent-queued-messages`,children:s.map(e=>(0,Y.jsx)(`div`,{className:`flex justify-end`,children:(0,Y.jsxs)(`div`,{className:`max-w-[85%] whitespace-pre-wrap rounded-2xl rounded-br-sm border border-dashed border-border/70 bg-foreground/[0.03] px-3.5 py-2 text-sm text-foreground/60`,children:[(0,Y.jsxs)(`span`,{className:`mb-0.5 flex items-center justify-end gap-1 text-[10px] font-medium uppercase tracking-wide text-foreground/45`,children:[(0,Y.jsx)(po,{className:`h-3 w-3`}),t(`queue.queued`)]}),(0,Y.jsx)(U5,{content:e.text,contextRefs:e.contextRefs})]})},e.queueId))})]}),(0,Y.jsx)(H3,{initial:!1,children:n&&D.pinned.length>0&&(0,Y.jsx)($ne,{pinned:D.pinned,conversationId:n.id,inline:j},`agent-pr-pinned-dock`)}),j?(0,Y.jsx)(`div`,{className:`shrink-0 px-4 pb-4`,children:(0,Y.jsx)(V8.div,{layoutId:`agent-composer-dock`,transition:{layout:{type:`spring`,stiffness:350,damping:34}},className:`mx-auto w-full max-w-[680px] rounded-2xl border border-border/60 bg-card/90 p-3 shadow-2xl backdrop-blur-xl`,children:(0,Y.jsx)(u7,{})})}):(0,Y.jsx)(`div`,{className:`shrink-0 border-t border-border/50 bg-surface/30 p-3`,children:(0,Y.jsx)(u7,{hideProjectSelector:!0})})]}),_&&(0,Y.jsx)(H.Suspense,{fallback:null,children:(0,Y.jsx)(are,{jobId:_.jobId,projectId:_.projectId,onClose:v})}),y&&(0,Y.jsx)(H.Suspense,{fallback:null,children:(0,Y.jsx)(ore,{loop:y,onClose:b})})]})}var sre=8,cre=3e3;function lre(){let{t:e}=K(`agent`),{conversations:t,active:n,selectConversation:r,deleteConversation:i,startNewConversation:a,streamingConversationIds:o,liveByConversation:s}=N7(),[c,l]=(0,H.useState)(!1),[u,d]=(0,H.useState)(``),[f,p]=(0,H.useState)(0),[m,h]=(0,H.useState)(null),g=(0,H.useRef)(null),_=(0,H.useRef)(null),v=(0,H.useRef)(null),y=(0,H.useMemo)(()=>{let e=e=>{let t=Date.parse(e.updated_at);return Number.isNaN(t)?0:t};return[...t].sort((t,n)=>e(n)-e(t))},[t]),b=t.length>sre,x=(0,H.useMemo)(()=>{let t=u.trim().toLowerCase();if(!t)return y;let n=e(`mission.untitled`).toLowerCase();return y.filter(e=>(e.title?.trim().toLowerCase()||n).includes(t))},[y,u,e]),S=x.length+1,C=(0,H.useCallback)(()=>{g.current&&clearTimeout(g.current),g.current=null,h(null)},[]);(0,H.useEffect)(()=>()=>{g.current&&clearTimeout(g.current)},[]),(0,H.useEffect)(()=>{if(!c)return;let e=e=>{_.current&&!_.current.contains(e.target)&&T()};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[c]);let w=()=>{let e=n?y.findIndex(e=>e.id===n.id):-1;p(e>=0?e+1:0),l(!0)},T=()=>{l(!1),d(``),C()},E=e=>{e!==n?.id&&r(e),T()},D=()=>{a(null),T()},O=e=>{g.current&&clearTimeout(g.current),h(e),g.current=setTimeout(()=>{h(null),g.current=null},cre)},k=async t=>{C();let a=n?.id===t,o=y.find(e=>e.id!==t)??null;try{await i(t),a&&o&&await r(o.id)}catch{q.error(e(`mission.deleteFailed`))}},A=()=>{if(f===0)D();else{let e=x[f-1];e&&E(e.id)}},j=e=>{if(!c){e.key===`ArrowDown`&&(e.preventDefault(),w());return}if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=e.key===`ArrowDown`?1:-1;p(e=>(e+t+S)%S)}else e.key===`Home`?(e.preventDefault(),p(0)):e.key===`End`?(e.preventDefault(),p(S-1)):e.key===`Enter`?(e.preventDefault(),A()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),m?C():(T(),v.current?.focus()))},M=n?.title?.trim()||e(`mission.untitled`);return(0,Y.jsxs)(`div`,{className:`relative min-w-0`,ref:_,"data-agent-interactive":!0,onKeyDown:j,children:[(0,Y.jsxs)(`button`,{ref:v,type:`button`,"data-testid":`mission-trigger`,onClick:()=>c?T():w(),"aria-haspopup":`listbox`,"aria-expanded":c,"aria-controls":`agent-mission-listbox`,title:e(`mission.label`),className:`flex min-w-0 items-center gap-1.5 rounded-md px-1.5 py-1 text-sm font-medium text-foreground hover:bg-surface/70`,children:[(0,Y.jsx)(fs,{className:`h-3.5 w-3.5 shrink-0 text-accent-primary`}),(0,Y.jsx)(`span`,{className:`min-w-0 max-w-[150px] truncate`,children:M}),(0,Y.jsx)(no,{className:`h-3.5 w-3.5 shrink-0 text-foreground/50`})]}),(0,Y.jsx)(H3,{children:c&&(0,Y.jsxs)(V8.div,{initial:{opacity:0,y:-6,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-6,scale:.98},transition:{duration:.16,ease:`easeOut`},className:`absolute left-0 top-full z-10 mt-1 w-72 overflow-hidden rounded-xl border border-border/60 bg-card/95 shadow-2xl backdrop-blur-xl`,children:[b&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/50 px-3 py-2`,children:[(0,Y.jsx)(Us,{className:`h-3.5 w-3.5 text-foreground/40`}),(0,Y.jsx)(`input`,{autoFocus:!0,value:u,onChange:e=>{d(e.target.value),p(0)},placeholder:e(`mission.searchPlaceholder`),className:`w-full bg-transparent text-sm text-foreground outline-none placeholder:text-foreground/40`})]}),(0,Y.jsxs)(`div`,{id:`agent-mission-listbox`,role:`listbox`,"aria-label":e(`mission.label`),"aria-activedescendant":`agent-mission-opt-${f}`,className:`max-h-72 overflow-y-auto py-1`,children:[(0,Y.jsxs)(V8.div,{id:`agent-mission-opt-0`,role:`option`,"aria-selected":!1,tabIndex:-1,"data-testid":`mission-new`,onClick:D,onMouseEnter:()=>p(0),initial:{opacity:0,x:-6},animate:{opacity:1,x:0},transition:{duration:.14},className:`flex w-full cursor-pointer items-center gap-2.5 px-3 py-1.5 text-left text-sm font-medium text-foreground ${f===0?`bg-surface/70`:`hover:bg-surface/70`}`,children:[(0,Y.jsx)(ks,{className:`h-4 w-4 text-accent-primary`}),(0,Y.jsx)(`span`,{className:`flex-1 truncate`,children:e(`mission.new`)})]}),x.length>0&&(0,Y.jsx)(`div`,{className:`mx-3 my-1 h-px bg-border/50`,"aria-hidden":!0}),x.length===0&&u.trim()!==``&&(0,Y.jsx)(`div`,{className:`px-3 py-2 text-xs text-foreground/40`,children:e(`mission.noMatches`)}),x.map((e,t)=>(0,Y.jsx)(ure,{conversation:e,index:t+1,highlighted:f===t+1,activeId:n?.id??null,streaming:o.has(e.id),queuedCount:s.get(e.id)?.queued.length??0,confirming:m===e.id,onHover:()=>p(t+1),onSelect:()=>E(e.id),onArmDelete:()=>O(e.id),onConfirmDelete:()=>void k(e.id),onCancelDelete:C},e.id))]})]})})]})}function ure({conversation:e,index:t,highlighted:n,activeId:r,streaming:i,queuedCount:a,confirming:o,onHover:s,onSelect:c,onArmDelete:l,onConfirmDelete:u,onCancelDelete:d}){let{t:f}=K(`agent`),p=e.title?.trim()||f(`mission.untitled`),m=e.id===r;return o?(0,Y.jsxs)(`div`,{id:`agent-mission-opt-${t}`,role:`option`,"aria-selected":m,"data-testid":`mission-row-${e.id}`,className:`flex w-full items-center gap-2 bg-destructive/10 px-3 py-1.5 text-sm`,children:[(0,Y.jsx)(cc,{className:`h-3.5 w-3.5 shrink-0 text-destructive`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-destructive`,children:f(i?`mission.deleteLiveConfirm`:`mission.deleteConfirm`)}),(0,Y.jsx)(`button`,{type:`button`,"data-testid":`mission-confirm-yes`,onClick:e=>{e.stopPropagation(),u()},"aria-label":f(`mission.confirmDelete`),className:`rounded-md p-1 text-destructive hover:bg-destructive/20`,children:(0,Y.jsx)(to,{className:`h-3.5 w-3.5`})}),(0,Y.jsx)(`button`,{type:`button`,"data-testid":`mission-confirm-no`,onClick:e=>{e.stopPropagation(),d()},"aria-label":f(`mission.cancelDelete`),className:`rounded-md p-1 text-foreground/60 hover:bg-surface`,children:(0,Y.jsx)(hc,{className:`h-3.5 w-3.5`})})]}):(0,Y.jsxs)(V8.div,{id:`agent-mission-opt-${t}`,role:`option`,"aria-selected":m,tabIndex:-1,"data-testid":`mission-row-${e.id}`,onClick:c,onMouseEnter:s,initial:{opacity:0,x:-6},animate:{opacity:1,x:0},transition:{duration:.14,delay:Math.min(t*.03,.18)},className:`group flex w-full cursor-pointer items-center gap-2 px-3 py-1.5 text-left text-sm text-foreground ${n?`bg-surface/70`:`hover:bg-surface/70`}`,children:[(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:p}),(0,Y.jsx)(`span`,{className:`shrink-0 tabular-nums text-xs text-foreground/40`,title:pY(e.updated_at),children:fY(e.updated_at)}),i&&(0,Y.jsxs)(`span`,{"data-testid":`mission-live-${e.id}`,"aria-label":f(`mission.working`),className:`relative flex h-1.5 w-1.5 shrink-0`,children:[(0,Y.jsx)(`span`,{className:`absolute inline-flex h-full w-full animate-ping rounded-full bg-accent-primary opacity-60`}),(0,Y.jsx)(`span`,{className:`relative inline-flex h-1.5 w-1.5 rounded-full bg-accent-primary`})]}),a>0&&(0,Y.jsx)(`span`,{"data-testid":`mission-queued-${e.id}`,"aria-label":f(`mission.queuedBadge`,{n:a}),title:f(`mission.queuedBadge`,{n:a}),className:`shrink-0 rounded-full border border-border/60 bg-surface px-1.5 text-[9px] font-semibold leading-4 text-foreground/60`,children:a}),m&&(0,Y.jsx)(to,{className:`h-3.5 w-3.5 shrink-0 text-accent-primary`}),(0,Y.jsx)(`button`,{type:`button`,"data-testid":`mission-delete-${e.id}`,onClick:e=>{e.stopPropagation(),l()},"aria-label":f(`mission.delete`,{title:p}),className:`shrink-0 rounded-md p-0.5 text-foreground/50 opacity-0 transition-opacity hover:bg-surface hover:text-destructive focus-visible:opacity-100 group-focus-within:opacity-100 group-hover:opacity-100`,children:(0,Y.jsx)(cc,{className:`h-3.5 w-3.5`})})]})}function dre(){let{t:e}=K(`agent`),{minimize:t,startNewConversation:n,cycleTier:r,active:i,draftPinnedProjectId:a,setPinnedProject:o}=N7(),[s,c]=(0,H.useState)(!1),l=e=>{e.shiftKey&&(e.key===`Tab`||e.code===`Tab`)&&(e.preventDefault(),r())},{panelRef:u,panelStyle:d,headerHandleProps:f,resizeHandles:p}=yb({enabled:!0,allowMove:!0,minWidth:400,minHeight:420,anchorFromCurrentRect:!0,persistKey:`specrails-desktop:agent-panel-geom`});return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(V8.div,{ref:u,initial:{opacity:0,scale:.85,y:8},animate:{opacity:1,scale:1,y:0},transition:{duration:.22,ease:[.34,1.56,.64,1]},style:s?{position:`fixed`,inset:12,width:`auto`,height:`auto`,maxWidth:`none`,maxHeight:`none`}:d,role:`dialog`,"aria-label":e(`title`),onKeyDown:l,className:`fixed z-[60] flex flex-col overflow-hidden rounded-2xl border border-border/60 bg-card/90 shadow-2xl backdrop-blur-xl ${s?``:`bottom-4 right-4 h-[78vh] max-h-[94vh] w-[520px] max-w-[92vw]`}`,children:[(0,Y.jsxs)(`div`,{...s?{}:f,onDoubleClick:()=>c(e=>!e),className:`flex shrink-0 items-center gap-2 border-b border-border/50 bg-surface/40 px-3 py-2 ${s?``:`cursor-grab`}`,children:[(0,Y.jsx)(qa,{className:`h-4 w-4 shrink-0 text-accent-primary`}),(0,Y.jsx)(`span`,{className:`shrink-0 text-sm font-medium text-foreground/80`,children:e(`title`)}),(0,Y.jsx)(r7,{pinnedProjectId:i?i.pinned_project_id:a,onSelect:e=>void o(e)}),(0,Y.jsx)(`div`,{className:`h-4 w-px shrink-0 bg-border/60`,"aria-hidden":!0}),(0,Y.jsx)(lre,{}),(0,Y.jsxs)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:()=>n(null),title:e(`newConversation`),"data-agent-interactive":!0,className:`rounded-md p-1 text-foreground/60 hover:bg-surface hover:text-foreground`,children:(0,Y.jsx)(ks,{className:`h-4 w-4`})}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>c(e=>!e),"aria-label":e(s?`restore`:`maximize`),title:e(s?`restore`:`maximize`),"data-agent-interactive":!0,className:`rounded-md p-1 text-foreground/60 hover:bg-surface hover:text-foreground`,children:s?(0,Y.jsx)(ps,{className:`h-4 w-4`}):(0,Y.jsx)(us,{className:`h-4 w-4`})}),(0,Y.jsx)(`button`,{type:`button`,onClick:t,"aria-label":e(`minimize`),title:e(`minimize`),"data-agent-interactive":!0,className:`rounded-md p-1 text-foreground/60 hover:bg-surface hover:text-foreground`,children:(0,Y.jsx)(hc,{className:`h-4 w-4`})})]})]}),(0,Y.jsx)(S7,{variant:`floating`})]}),!s&&(0,Y.jsx)(`div`,{className:`pointer-events-none fixed inset-0 z-[61] [&>*]:pointer-events-auto`,children:(0,Y.jsx)(xb,{handles:p})})]})}var C7=`specrails-desktop:agent-bubble-pos`,w7=56,T7=12;function fre(){try{let e=localStorage.getItem(C7);if(!e)return null;let t=JSON.parse(e);if(typeof t?.left==`number`&&typeof t?.top==`number`)return t}catch{}return null}function E7(e){let t=Math.max(T7,window.innerWidth-w7-T7),n=Math.max(T7,window.innerHeight-w7-T7);return{left:Math.min(Math.max(T7,e.left),t),top:Math.min(Math.max(T7,e.top),n)}}function pre(){return{left:Math.round(window.innerWidth/2-w7/2),top:window.innerHeight-w7-20}}function mre(){let{t:e}=K(`agent`),{open:t,isStreaming:n,active:r}=N7(),[i,a]=(0,H.useState)(!1),[o,s]=(0,H.useState)(()=>E7(fre()??pre())),c=B8(0),l=B8(0),u=(0,H.useRef)(!1);(0,H.useEffect)(()=>{let e=()=>s(e=>E7(e));return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let d=(0,H.useCallback)(e=>{try{localStorage.setItem(C7,JSON.stringify(e))}catch{}},[]);return(0,Y.jsxs)(V8.button,{type:`button`,onClick:()=>{if(u.current){u.current=!1;return}t()},onHoverStart:()=>a(!0),onHoverEnd:()=>a(!1),"aria-label":e(`trigger`),title:`${e(`trigger`)} (⌘⇧A)`,drag:!0,dragMomentum:!1,dragElastic:0,style:{position:`fixed`,left:o.left,top:o.top,x:c,y:l},onDragStart:()=>{u.current=!0},onDragEnd:()=>{let e=E7({left:o.left+c.get(),top:o.top+l.get()});c.set(0),l.set(0),s(e),d(e),setTimeout(()=>{u.current=!1},0)},initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},transition:{type:`spring`,stiffness:420,damping:28},whileHover:{scale:1.06},whileTap:{scale:.94},whileDrag:{scale:1.1,cursor:`grabbing`},className:`z-[60] flex h-14 items-center gap-2 rounded-full border border-border/60 bg-card/85 px-3 shadow-2xl backdrop-blur-xl cursor-grab`,children:[(0,Y.jsxs)(`span`,{className:`relative flex h-9 w-9 items-center justify-center rounded-full bg-accent-primary/15`,children:[(0,Y.jsx)(qa,{className:`h-5 w-5 text-accent-primary`}),n&&(0,Y.jsx)(V8.span,{className:`absolute inset-0 rounded-full ring-2 ring-accent-success`,animate:{opacity:[.8,.2,.8],scale:[1,1.18,1]},transition:{duration:1.4,repeat:1/0,ease:`easeInOut`}})]}),(0,Y.jsx)(H3,{initial:!1,children:(i||n)&&(0,Y.jsx)(V8.span,{initial:{opacity:0,width:0,marginRight:0},animate:{opacity:1,width:`auto`,marginRight:4},exit:{opacity:0,width:0,marginRight:0},transition:{duration:.18,ease:`easeOut`},className:`overflow-hidden whitespace-nowrap text-sm font-medium text-foreground`,children:n?e(`thinking`):r?.title||e(`trigger`)})})]})}var D7={streamingText:``,isStreaming:!1,liveTools:[],queued:[]},O7=`specrails-desktop:favorite-agent-conversations`;function hre(){try{let e=localStorage.getItem(O7);if(!e)return new Set;let t=JSON.parse(e);return Array.isArray(t)?new Set(t.filter(e=>typeof e==`string`)):new Set}catch{return new Set}}function k7(e){try{localStorage.setItem(O7,JSON.stringify([...e]))}catch{}}function A7(e,t){let n=new Set(t.map(e=>e.id));return new Set([...e].filter(e=>n.has(e)))}var j7=(0,H.createContext)(null),gre=0,M7=0;function _re({children:e}){let{registerHandler:t,unregisterHandler:n}=df(),{uiMode:r}=hq(),{setActiveProjectId:i}=gm(),[a,o]=(0,H.useState)(`hidden`),[s,c]=(0,H.useState)([]),[l,u]=(0,H.useState)(null),[d,f]=(0,H.useState)([]),[p,m]=(0,H.useState)(hre),[h,g]=(0,H.useState)(new Set),[_,v]=(0,H.useState)(new Map),[y,b]=(0,H.useState)(!0),[x,S]=(0,H.useState)(!1),[C,w]=(0,H.useState)(null),[T,E]=(0,H.useState)(null),D=(0,H.useRef)(null);D.current=T;let[O,k]=(0,H.useState)(`claude`),[A,j]=(0,H.useState)(null),[M,N]=(0,H.useState)(0),[P,F]=(0,H.useState)(null),I=(0,H.useRef)({provider:`claude`,model:null,tierLevel:0,effort:null});I.current={provider:O,model:A,tierLevel:M,effort:P};let L=(0,H.useRef)(null);L.current=l?.id??null;let R=(0,H.useRef)(_);R.current=_;let z=(0,H.useRef)(new Set),ee=(0,H.useRef)(null),te=(0,H.useCallback)((e,t)=>{v(n=>{let r=t(n.get(e)??D7),i=new Map(n);return r===null||!r.isStreaming&&!r.streamingText&&r.liveTools.length===0&&r.queued.length===0?i.delete(e):i.set(e,r),i})},[]),B=(0,H.useCallback)(e=>{let t=typeof document<`u`&&document.visibilityState===`hidden`;e===L.current&&!t||g(t=>{if(t.has(e))return t;let n=new Set(t);return n.add(e),n})},[]),ne=(0,H.useCallback)(e=>{g(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]);(0,H.useEffect)(()=>{if(!Lb||typeof document>`u`)return;let e=()=>{if(document.visibilityState!==`visible`)return;let e=L.current;e&&ne(e)};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[ne]);let V=(l?_.get(l.id):void 0)??D7,re=V.streamingText,U=V.isStreaming,ie=V.liveTools,ae=V.queued,W=(0,H.useMemo)(()=>{let e=new Set;for(let[t,n]of _)n.isStreaming&&e.add(t);return e},[_]),oe=(0,H.useCallback)(async()=>{try{let e=await DY();c(e),m(t=>{let n=A7(t,e);return n.size===t.size?t:(k7(n),n)})}catch{}},[]),se=(0,H.useCallback)(async()=>{try{b((await qY()).enabled)}catch{b(!1)}},[]),ce=(0,H.useCallback)(async()=>{try{w((await KY()).any)}catch{w(!0)}},[]);(0,H.useEffect)(()=>Lb?(t(`agent-chat`,e=>{let t=e;if(typeof t.type!=`string`||!t.type.startsWith(`agent_`))return;if(t.type===`agent_title`&&t.conversationId){let e=t.title??null;c(n=>n.map(n=>n.id===t.conversationId?{...n,title:e}:n)),u(n=>n&&n.id===t.conversationId?{...n,title:e}:n);return}let n=t.conversationId;if(!n)return;let r=n===L.current;if(t.type===`agent_stream`)B(n),te(n,e=>({...e,isStreaming:!0,streamingText:e.streamingText+(t.delta??``)}));else if(t.type===`agent_tool`)te(n,e=>({...e,isStreaming:!0,liveTools:[...e.liveTools,{id:`t${gre++}`,tool:t.tool??`tool`}]}));else if(t.type===`agent_done`){B(n);let e=t.fullText??``;r&&f(t=>{let r=t[t.length-1];return r&&r.role===`assistant`&&r.content===e&&!r.id.startsWith(`local-`)?t:[...t,{id:`local-${Date.now()}`,conversation_id:n,role:`assistant`,content:e,created_at:new Date().toISOString()}]}),te(n,e=>({...D7,queued:e.queued}))}else if(t.type===`agent_error`){B(n),te(n,e=>({...D7,queued:e.queued}));let e=t.error||`The agent turn failed.`;q.error(e),r&&f(t=>[...t,{id:`err-${Date.now()}`,conversation_id:n,role:`assistant`,content:`⚠️ ${e}`,created_at:new Date().toISOString()}])}else if(t.type===`agent_queued`)te(n,e=>t.queueId&&e.queued.some(e=>e.queueId===t.queueId)?e:{...e,queued:[...e.queued,{queueId:t.queueId??`srv-${M7++}`,text:t.text??``,contextRefs:t.contextRefs}]});else if(t.type===`agent_dequeued`)t.queueId&&z.current.add(t.queueId),te(n,e=>{let n=t.queueId?e.queued.findIndex(e=>e.queueId===t.queueId):0,r=n===-1?0:n;return{...e,queued:e.queued.filter((e,t)=>t!==r),isStreaming:!0,streamingText:``,liveTools:[]}}),r&&t.text&&f(e=>[...e,{id:`local-u-${Date.now()}`,conversation_id:n,role:`user`,content:t.text,context_refs:t.contextRefs??[],created_at:new Date().toISOString()}]);else if(t.type===`agent_queue_cleared`)te(n,e=>({...e,queued:[]}));else if(t.type===`agent_queue_edited`)te(n,e=>({...e,queued:e.queued.map(e=>t.queueId&&e.queueId===t.queueId?{...e,text:t.text??e.text,contextRefs:t.contextRefs??e.contextRefs}:e)}));else if(t.type===`agent_pr_decision`&&(B(n),r)){let t=HY(e);if(t){let e=JSON.stringify(t);f(r=>{let i=r.findIndex(e=>e.role===`system`&&UY(e.content)?.prDeliveryId===t.prDeliveryId);if(i>=0){if(r[i].content===e)return r;let t=[...r];return t[i]={...t[i],content:e},t}return[...r,{id:`prd-${t.prDeliveryId}`,conversation_id:n,role:`system`,content:e,created_at:new Date().toISOString()}]})}}}),()=>n(`agent-chat`)):void 0,[t,n,te,B]);let le=(0,H.useCallback)(async e=>{let{conversation:t,messages:n}=await kY(e);u(t),f(n),ne(e)},[ne]),ue=(0,H.useCallback)(async()=>{if(l)return l;let e=await DY();if(c(e),m(t=>{let n=A7(t,e);return n.size===t.size?t:(k7(n),n)}),e.length>0)return await le(e[0].id),e[0];let t=await OY({});return c(e=>[t,...e]),u(t),f([]),t},[l,le]),de=(0,H.useCallback)(()=>{o(`open`),oe(),se(),ce(),ue()},[oe,se,ce,ue]),fe=(0,H.useCallback)(()=>o(`hidden`),[]),pe=(0,H.useCallback)(()=>o(`minimized`),[]),me=(0,H.useCallback)(()=>{o(e=>e===`open`?`minimized`:`open`),a!==`open`&&(oe(),se(),ce(),ue())},[a,oe,se,ce,ue]),he=(0,H.useCallback)(async()=>{if(l)return l;if(ee.current)return ee.current;let e=OY({pinnedProjectId:D.current,provider:I.current.provider,model:I.current.model,tierLevel:I.current.tierLevel,reasoningEffort:I.current.effort}).then(e=>(c(t=>[e,...t]),u(e),f([]),e)).finally(()=>{ee.current=null});return ee.current=e,e},[l]),ge=(0,H.useCallback)(async(e,t)=>{let n=e.trim();if(!n)return;let r=l??await he(),i=`q-${Date.now()}-${M7++}`,a=new Date().toISOString();c(e=>[{...e.find(e=>e.id===r.id)??r,updated_at:a},...e.filter(e=>e.id!==r.id)]),u(e=>e&&e.id===r.id?{...e,updated_at:a}:e);let o={id:`local-u-${Date.now()}`,conversation_id:r.id,role:`user`,content:n,attachment_ids:t?.attachmentIds??[],context_refs:t?.contextRefs??[],created_at:a},s=R.current.get(r.id)?.isStreaming===!0;s?te(r.id,e=>({...e,queued:[...e.queued,{queueId:i,text:n,contextRefs:t?.contextRefs}]})):(f(e=>[...e,o]),te(r.id,e=>({...e,isStreaming:!0,streamingText:``,liveTools:[]})));let d=t?.attachmentIds&&t.attachmentIds.length?{ids:t.attachmentIds}:void 0;try{let e=t?.contextRefs&&t.contextRefs.length?t.contextRefs:void 0,a=(await MY(r.id,n,{tierLevel:r.tier_level,attachments:d,queueId:i,contextRefs:e}))?.queued===!0;a&&!s?(f(e=>e.filter(e=>e.id!==o.id)),z.current.has(i)||te(r.id,e=>e.queued.some(e=>e.queueId===i)?e:{...e,queued:[...e.queued,{queueId:i,text:n,contextRefs:t?.contextRefs}]})):!a&&s&&(te(r.id,e=>({...e,queued:e.queued.filter(e=>e.queueId!==i),isStreaming:!0})),f(e=>[...e,o]))}catch(e){s?te(r.id,e=>({...e,queued:e.queued.filter(e=>e.queueId!==i)})):te(r.id,e=>({...e,isStreaming:!1,streamingText:``,liveTools:[]})),q.error(e instanceof Error?e.message:`Failed to send message.`)}},[l,he,te]),_e=(0,H.useCallback)(async()=>{l&&(te(l.id,()=>null),await RY(l.id))},[l,te]),ve=(0,H.useCallback)(async(e,t)=>{let n=l;if(!n)return`conflict`;let r=await zY(n.id,e,t);return r===`saved`&&te(n.id,n=>({...n,queued:n.queued.map(n=>n.queueId===e?{...n,text:t}:n)})),r},[l,te]),ye=(0,H.useCallback)(e=>z.current.has(e),[]),G=(0,H.useCallback)(async e=>{if(!l)return;let t=await AY(l.id,e);u(t),c(e=>e.map(e=>e.id===t.id?t:e))},[l]),be=(0,H.useCallback)(async e=>{l?await G({tierLevel:e}):N(e)},[l,G]),xe=(0,H.useCallback)(async()=>{await be(((l?.tier_level??M)+1)%4)},[l,M,be]),Se=(0,H.useCallback)(async e=>{l?await G({provider:e}):(k(e),j(null),F(null))},[l,G]),Ce=(0,H.useCallback)(async e=>{l?await G({model:e}):j(e)},[l,G]),we=(0,H.useCallback)(async e=>{l?await G({reasoningEffort:e}):F(e)},[l,G]),Te=(0,H.useCallback)(async e=>{l?await G({pinnedProjectId:e}):E(e),!l&&e&&r===`agent`&&i(e)},[l,G,r,i]),Ee=(0,H.useCallback)(e=>{u(null),f([]),E(e??null),k(`claude`),j(null),N(0),F(null)},[]),De=(0,H.useCallback)(async e=>{let t=await OY({pinnedProjectId:e===void 0?l?.pinned_project_id??null:e});c(e=>[t,...e]),u(t),f([])},[l]),Oe=(0,H.useCallback)(async e=>{await le(e)},[le]),ke=(0,H.useCallback)(async e=>{await jY(e),c(t=>t.filter(t=>t.id!==e)),m(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),k7(n),n}),te(e,()=>null),L.current===e&&(u(null),f([]))},[te]),Ae=(0,H.useCallback)(async(e,t)=>{let n=t.trim()||null,r;c(t=>t.map(t=>t.id===e?(r=t.title,{...t,title:n}):t)),u(t=>t&&t.id===e?{...t,title:n}:t);try{await AY(e,{title:n})}catch(t){throw c(t=>t.map(t=>t.id===e?{...t,title:r??null}:t)),u(t=>t&&t.id===e?{...t,title:r??null}:t),t}},[]),je=(0,H.useCallback)(e=>{m(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),k7(n),n})},[]),Me=(0,H.useCallback)(async()=>{S(!0);try{await JY(),await se()}finally{S(!1)}},[se]),Ne=(0,H.useMemo)(()=>({visibility:a,open:de,close:fe,minimize:pe,toggle:me,conversations:s,active:l,messages:d,streamingText:re,isStreaming:U,liveTools:ie,queuedMessages:ae,streamingConversationIds:W,liveByConversation:_,unreadConversationIds:h,favoriteConversationIds:p,mcpEnabled:y,enablingMcp:x,enableMcpServer:Me,providersReady:C,send:ge,abort:_e,editQueuedMessage:ve,wasQueueConsumed:ye,cycleTier:xe,setTier:be,setProvider:Se,setModel:Ce,setPinnedProject:Te,newConversation:De,startNewConversation:Ee,materializeDraftConversation:he,draftPinnedProjectId:T,draftProvider:O,draftModel:A,draftTierLevel:M,draftEffort:P,setEffort:we,selectConversation:Oe,deleteConversation:ke,renameConversation:Ae,toggleFavoriteConversation:je,refreshConversations:oe}),[a,de,fe,pe,me,s,l,d,re,U,ie,ae,W,_,h,p,y,x,Me,C,ge,_e,ve,ye,xe,be,Se,Ce,Te,De,Ee,he,T,O,A,M,P,we,Oe,ke,Ae,je,oe]),Pe=Lb&&r!==`agent`;return(0,Y.jsxs)(j7.Provider,{value:Ne,children:[e,Pe&&a===`open`&&(0,Y.jsx)(dre,{}),Pe&&a!==`open`&&(0,Y.jsx)(mre,{})]})}var vre={visibility:`hidden`,open:()=>{},close:()=>{},minimize:()=>{},toggle:()=>{},conversations:[],active:null,messages:[],streamingText:``,isStreaming:!1,liveTools:[],queuedMessages:[],streamingConversationIds:new Set,unreadConversationIds:new Set,liveByConversation:new Map,favoriteConversationIds:new Set,mcpEnabled:!0,enablingMcp:!1,enableMcpServer:async()=>{},providersReady:!0,send:async()=>{},abort:async()=>{},editQueuedMessage:async()=>`conflict`,wasQueueConsumed:()=>!1,cycleTier:async()=>{},setTier:async()=>{},setProvider:async()=>{},setModel:async()=>{},setPinnedProject:async()=>{},newConversation:async()=>{},startNewConversation:()=>{},materializeDraftConversation:async()=>{throw Error(`AgentChatProvider is not mounted`)},draftPinnedProjectId:null,draftProvider:`claude`,draftModel:null,draftTierLevel:0,draftEffort:null,setEffort:async()=>{},selectConversation:async()=>{},deleteConversation:async()=>{},renameConversation:async()=>{},toggleFavoriteConversation:()=>{},refreshConversations:async()=>{}};function N7(){return(0,H.useContext)(j7)??vre}var yre=(0,H.lazy)(()=>a(()=>import(`./ProjectSettingsDialog-BlTlRtGI.js`).then(e=>({default:e.ProjectSettingsDialog})),__vite__mapDeps([34,1]))),P7=`specrails-desktop:agentTreeExpanded`;function bre(){try{let e=localStorage.getItem(P7);if(!e)return new Set;let t=JSON.parse(e);return Array.isArray(t)?new Set(t.filter(e=>typeof e==`string`)):new Set}catch{return new Set}}function F7(e){try{localStorage.setItem(P7,JSON.stringify([...e]))}catch{}}function xre(){window.dispatchEvent(new KeyboardEvent(`keydown`,{key:`k`,metaKey:!0,ctrlKey:!0,bubbles:!0}))}var I7=`__home__`,L7=`__favorites__`;function R7({conversation:e,active:t,expanded:n,streaming:r=!1,unread:i=!1,favorite:a=!1,onSelect:o,onToggleFavorite:s,onDelete:c}){let{t:l}=K(`agent`),u=e.title?.trim()||l(`untitled`),[d,f]=(0,H.useState)(!1),p=(0,H.useRef)(null),[m,h]=(0,H.useState)(!1),g=(0,H.useRef)(r);(0,H.useEffect)(()=>{if(g.current&&!r){h(!0);let e=setTimeout(()=>h(!1),900);return g.current=r,()=>clearTimeout(e)}g.current=r},[r]),(0,H.useEffect)(()=>()=>{p.current&&clearTimeout(p.current)},[]);function _(e){e.stopPropagation(),d?(p.current&&clearTimeout(p.current),f(!1),c()):(f(!0),p.current=setTimeout(()=>{f(!1),p.current=null},3e3))}function v(e){e.stopPropagation(),s?.()}function y(e){e.target===e.currentTarget&&(e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),o()))}return(0,Y.jsxs)(`div`,{role:`button`,tabIndex:0,onClick:o,onKeyDown:y,className:X(`group relative flex items-center gap-2 w-full h-7 rounded-md transition-colors`,n?`pl-7 pr-2`:`px-0 justify-center`,t?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),title:n?void 0:u,"aria-current":t?`true`:void 0,children:[(0,Y.jsx)(ds,{className:X(`w-3.5 h-3.5 flex-shrink-0`,t&&`text-accent-primary`,r&&!i&&`text-accent-primary animate-pulse`,i&&`text-destructive conversation-unread-glow`)}),n&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{className:`relative text-[11px] truncate flex-1 text-left`,children:[u,(r||m)&&(0,Y.jsx)(`span`,{"aria-hidden":!0,className:X(`title-shimmer pointer-events-none absolute inset-0 truncate transition-opacity duration-700`,r?`opacity-100`:`opacity-0`),children:u})]}),(0,Y.jsx)(`span`,{className:X(`flex-shrink-0 text-[10px] tabular-nums text-muted-foreground/45`,d?`hidden`:`group-hover:hidden`),title:pY(e.updated_at),children:fY(e.updated_at)}),(0,Y.jsx)(`button`,{type:`button`,onClick:v,className:X(`flex-shrink-0 items-center justify-center rounded-sm transition-colors hover:bg-muted`,a?`flex w-3.5 h-3.5 text-accent-primary hover:text-accent-primary`:`hidden group-hover:flex w-3.5 h-3.5 text-muted-foreground/60 hover:text-accent-primary`),"aria-label":l(a?`removeFavoriteConversation`:`addFavoriteConversation`,{title:u}),title:l(a?`removeFavoriteConversation`:`addFavoriteConversation`,{title:u}),children:(0,Y.jsx)(Xo,{className:`w-2.5 h-2.5`,fill:a?`currentColor`:`none`})}),(0,Y.jsx)(`button`,{type:`button`,onClick:_,className:X(`flex-shrink-0 items-center justify-center rounded-sm transition-colors hover:bg-muted`,d?`flex px-1 h-4 text-[10px] text-destructive bg-destructive/10 hover:bg-destructive/20`:`hidden group-hover:flex w-3.5 h-3.5 text-muted-foreground/60 hover:text-foreground`),"aria-label":l(d?`confirmDeleteConversation`:`deleteConversation`,{title:u}),children:d?l(`confirmShort`):(0,Y.jsx)(hc,{className:`w-2.5 h-2.5`})})]})]})}function Sre({project:e,isActive:t,expanded:n,onSelect:r,onRemove:i,agentMode:a=!1,hasTree:o=!1,treeOpen:s=!1,onToggleTree:c,conversations:l=[],activeConversationId:u=null,streamingConversationIds:d,unreadConversationIds:f,onSelectConversation:p,onToggleConversationFavorite:m,onDeleteConversation:h,onOpenProjectSettings:g}){let{t:_}=K(`nav`),[v,y]=(0,H.useState)(!1),b=(0,H.useRef)(null);(0,H.useEffect)(()=>()=>{b.current&&clearTimeout(b.current)},[]);function x(e){e.stopPropagation(),v?(b.current&&clearTimeout(b.current),y(!1),i()):(y(!0),b.current=setTimeout(()=>{y(!1),b.current=null},3e3))}function S(e){e.target===e.currentTarget&&(e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),r()))}let C=a&&o&&n,w=(0,Y.jsx)(zo,{className:X(`flex-shrink-0 w-4 h-4`,t&&`text-accent-primary`)});return(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`div`,{role:`button`,tabIndex:0,onClick:r,onKeyDown:S,className:X(`group relative flex items-center gap-2 w-full h-8 rounded-md transition-colors`,n?`px-2`:`px-0 justify-center`,t?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),title:n?void 0:e.name,"aria-current":t?`page`:void 0,children:[C?(0,Y.jsxs)(`span`,{className:`relative flex h-4 w-4 flex-shrink-0 items-center justify-center`,children:[(0,Y.jsx)(`span`,{className:`flex transition-opacity group-hover:opacity-0 group-focus-within:opacity-0`,children:w}),(0,Y.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c?.()},className:`absolute inset-0 hidden items-center justify-center rounded-sm hover:bg-muted group-hover:flex group-focus-within:flex`,"aria-label":_(s?`projects.collapse`:`projects.expand`,{name:e.name}),"aria-expanded":s,children:s?(0,Y.jsx)(no,{className:`w-3.5 h-3.5`}):(0,Y.jsx)(io,{className:`w-3.5 h-3.5`})})]}):w,n&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`text-xs truncate flex-1 text-left`,children:e.name}),g&&(0,Y.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),g()},className:X(`flex-shrink-0 flex items-center justify-center rounded-sm transition-all w-3.5 h-3.5`,`opacity-0 group-hover:opacity-50 hover:!opacity-100 hover:bg-muted`),"aria-label":_(`projects.settings`,{name:e.name}),title:_(`projects.settings`,{name:e.name}),children:(0,Y.jsx)(qs,{className:`w-2.5 h-2.5`})}),(0,Y.jsx)(`button`,{type:`button`,onClick:x,className:X(`flex-shrink-0 flex items-center justify-center rounded-sm transition-all`,`opacity-0 group-hover:opacity-50 hover:!opacity-100 hover:bg-muted`,v?`opacity-100 px-1 h-4 text-[10px] text-destructive bg-destructive/10 hover:bg-destructive/20`:`w-3.5 h-3.5`),"aria-label":_(v?`projects.confirmRemove`:`projects.remove`,{name:e.name}),children:v?_(`projects.confirmShort`):(0,Y.jsx)(hc,{className:`w-2.5 h-2.5`})})]})]}),a&&s&&n&&l.length>0&&(0,Y.jsx)(`div`,{className:`mt-0.5 space-y-0.5`,children:l.map(e=>(0,Y.jsx)(R7,{conversation:e,active:e.id===u,streaming:d?.has(e.id)??!1,unread:f?.has(e.id)??!1,expanded:n,onSelect:()=>p?.(e.id),onToggleFavorite:()=>m?.(e.id),onDelete:()=>h?.(e.id)},e.id))})]})}var Cre={"pinned-open":`sidebarPin.left.pinnedOpen`,"pinned-collapsed":`sidebarPin.left.pinnedCollapsed`,unpinned:`sidebarPin.left.unpinned`};function wre({onAddProject:e,onOpenLoops:t,onOpenPlugins:n,onOpenAnalytics:r,onOpenDocs:i,onOpenSettings:a}){let{t:o}=K(`nav`),{t:s}=K(`agent`),{projects:c,activeProjectId:l,setActiveProjectId:u,removeProject:d}=gm(),f=_t(),p=mt(),m=p.pathname.startsWith(`/loops`),h=p.pathname.startsWith(`/plugins`),g=m||h||p.pathname.startsWith(`/docs`),{leftMode:_,cycleLeftMode:v}=CY(),{uiMode:y,toggleUiMode:b}=hq(),x=N7(),S=y===`agent`,C=(0,H.useMemo)(()=>{let e=new Map,t=new Set(c.map(e=>e.id));for(let n of x.conversations){if(x.favoriteConversationIds.has(n.id))continue;let r=n.pinned_project_id&&t.has(n.pinned_project_id)?n.pinned_project_id:I7,i=e.get(r);i?i.push(n):e.set(r,[n])}return e},[x.conversations,x.favoriteConversationIds,c]),w=(0,H.useMemo)(()=>x.conversations.filter(e=>x.favoriteConversationIds.has(e.id)),[x.conversations,x.favoriteConversationIds]),T=C.get(I7)??[],[E,D]=(0,H.useState)(bre),O=E.has(L7),[k,A]=(0,H.useState)(!1);(0,H.useEffect)(()=>{!S||!l||D(e=>{if(e.has(l))return e;let t=new Set(e);return t.add(l),F7(t),t})},[S,l]);let j=e=>{D(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),F7(n),n})},M=e=>{x.selectConversation(e),g&&f(`/`)},N=e=>{x.deleteConversation(e).catch(()=>{})},P=e=>{x.toggleFavoriteConversation(e)};function F(e){if(S){u(e),j(e);return}if(e===l){g&&f(`/`);return}u(e)}let[I,L]=(0,H.useState)(!1),R=_===`pinned-open`||_===`unpinned`&&I,z=cY(`left-arc`,{side:`left`,defaultWidth:240,min:200,max:460,collapsedWidth:44,expanded:R}),ee=_!==`unpinned`,te=o(Cre[_]),B=[{label:o(`arcSidebar.docs`),icon:Ka,action:i},{label:o(`arcSidebar.analytics`),icon:$a,action:r},{label:o(`arcSidebar.settings`),icon:qs,action:a}];async function ne(e){try{await d(e.id)}catch{}}return(0,Y.jsxs)(`div`,{ref:z.panelRef,className:X(`relative flex flex-col h-full border-r border-border bg-background flex-shrink-0 overflow-hidden`,`transition-[width] duration-200 ease-in-out`),onMouseEnter:()=>{_===`unpinned`&&L(!0)},onMouseLeave:()=>{_===`unpinned`&&!z.dragging&&L(!1)},children:[R&&(0,Y.jsx)(lY,{side:`left`,dragging:z.dragging,width:z.width,min:200,max:460,label:o(`arcSidebar.resize`,{defaultValue:`Resize sidebar`}),onPointerDown:z.onGripPointerDown,onKeyDown:z.onGripKeyDown}),(0,Y.jsxs)(`div`,{className:X(`flex items-center h-12 border-b border-border flex-shrink-0`,R?`px-3 justify-between`:`justify-center`),children:[R&&(0,Y.jsx)(`span`,{className:`font-mono text-sm font-bold whitespace-nowrap overflow-hidden text-accent-primary`,children:o(`arcSidebar.desktopTitle`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:v,className:X(`flex items-center justify-center w-7 h-7 rounded-md transition-colors flex-shrink-0`,ee?`text-foreground bg-muted`:`text-muted-foreground/40 hover:text-muted-foreground hover:bg-muted/50`),"aria-label":te,title:o(`sidebarPin.withShortcut`,{label:te,shortcut:`⌥⌘B`}),children:(0,Y.jsx)(bs,{className:`w-4 h-4`})})]}),Rb&&(0,Y.jsxs)(`div`,{className:`py-2 px-1.5 space-y-0.5 border-b border-border`,children:[S&&(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{x.startNewConversation(l),g&&f(`/`)},className:X(`flex items-center gap-2 w-full h-8 rounded-md transition-colors`,`bg-accent-primary/15 text-accent-primary hover:bg-accent-primary/25`,R?`px-2`:`px-0 justify-center`),"aria-label":s(`newAgent`),title:R?void 0:s(`newAgent`),children:[(0,Y.jsx)(ks,{className:`w-4 h-4 flex-shrink-0`}),R&&(0,Y.jsx)(`span`,{className:`text-xs whitespace-nowrap`,children:s(`newAgent`)})]}),(0,Y.jsxs)(`button`,{type:`button`,onClick:b,className:X(`flex items-center gap-2 w-full h-8 rounded-md transition-colors`,`text-muted-foreground hover:text-foreground hover:bg-muted/50`,R?`px-2`:`px-0 justify-center`),"aria-label":s(S?`switchToKanban`:`switchToAgent`),title:s(S?`switchToKanban`:`switchToAgent`),children:[S?(0,Y.jsx)(is,{className:`w-4 h-4 flex-shrink-0`}):(0,Y.jsx)(qa,{className:`w-4 h-4 flex-shrink-0 text-accent-primary`}),R&&(0,Y.jsx)(`span`,{className:`min-w-0 truncate text-xs`,children:s(S?`switchToKanban`:`switchToAgent`)})]}),S&&(0,Y.jsxs)(`button`,{type:`button`,onClick:xre,className:X(`flex items-center gap-2 w-full h-8 rounded-md transition-colors`,`text-muted-foreground hover:text-foreground hover:bg-muted/50`,R?`px-2`:`px-0 justify-center`),"aria-label":s(`search`),title:R?void 0:s(`search`),children:[(0,Y.jsx)(Us,{className:`w-4 h-4 flex-shrink-0`}),R&&(0,Y.jsx)(`span`,{className:`text-xs whitespace-nowrap`,children:s(`search`)})]})]}),zb&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`py-2 px-1.5`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:t,className:X(`flex items-center gap-2 w-full h-8 rounded-md transition-colors`,R?`px-2`:`px-0 justify-center`,m?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),"aria-label":o(`arcSidebar.loops`),"aria-current":m?`page`:void 0,title:R?void 0:o(`arcSidebar.loops`),children:[(0,Y.jsx)(mc,{className:X(`w-4 h-4 flex-shrink-0`,m&&`text-accent-primary`)}),R&&(0,Y.jsx)(`span`,{className:`text-xs whitespace-nowrap`,children:o(`arcSidebar.loops`)})]}),(0,Y.jsxs)(`button`,{type:`button`,onClick:n,className:X(`mt-0.5 flex items-center gap-2 w-full h-8 rounded-md transition-colors`,R?`px-2`:`px-0 justify-center`,h?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),"aria-label":o(`arcSidebar.plugins`),"aria-current":h?`page`:void 0,title:R?void 0:o(`arcSidebar.plugins`),children:[(0,Y.jsx)(As,{className:X(`w-4 h-4 flex-shrink-0`,h&&`text-accent-primary`)}),R&&(0,Y.jsx)(`span`,{className:`text-xs whitespace-nowrap`,children:o(`arcSidebar.plugins`)})]})]}),(0,Y.jsx)(`div`,{className:`border-t border-border`,"aria-hidden":!0})]}),(0,Y.jsxs)(`div`,{className:`flex-1 overflow-y-auto py-2 px-1.5 space-y-0.5`,children:[S&&w.length>0&&(0,Y.jsxs)(`div`,{className:`mb-2 space-y-0.5 border-b border-border/70 pb-2`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>j(L7),className:X(`group flex items-center gap-2 w-full h-8 rounded-md transition-colors`,`text-muted-foreground hover:text-foreground hover:bg-muted/50`,R?`px-2`:`px-0 justify-center`),"aria-label":s(`favoriteMissions`),"aria-expanded":O,title:R?void 0:s(`favoriteMissions`),children:[R?(0,Y.jsxs)(`span`,{className:`relative flex h-4 w-4 flex-shrink-0 items-center justify-center`,children:[(0,Y.jsx)(Xo,{className:`h-4 w-4 fill-current text-accent-primary transition-opacity group-hover:opacity-0 group-focus-visible:opacity-0`}),(0,Y.jsx)(`span`,{className:`absolute inset-0 hidden items-center justify-center group-hover:flex group-focus-visible:flex`,children:O?(0,Y.jsx)(no,{className:`w-3.5 h-3.5`}):(0,Y.jsx)(io,{className:`w-3.5 h-3.5`})})]}):(0,Y.jsx)(Xo,{className:`w-4 h-4 flex-shrink-0 fill-current text-accent-primary`}),R&&(0,Y.jsx)(`span`,{className:`text-xs truncate flex-1 text-left`,children:s(`favoriteMissions`)})]}),O&&R&&(0,Y.jsx)(`div`,{className:`mt-0.5 space-y-0.5`,children:w.map(e=>(0,Y.jsx)(R7,{conversation:e,active:e.id===x.active?.id,streaming:x.streamingConversationIds.has(e.id),unread:x.unreadConversationIds.has(e.id),favorite:!0,expanded:R,onSelect:()=>M(e.id),onToggleFavorite:()=>P(e.id),onDelete:()=>N(e.id)},e.id))})]}),S&&T.length>0&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>j(I7),className:X(`group flex items-center gap-2 w-full h-8 rounded-md transition-colors`,`text-muted-foreground hover:text-foreground hover:bg-muted/50`,R?`px-2`:`px-0 justify-center`),"aria-label":s(`home`),"aria-expanded":E.has(I7),title:R?void 0:s(`home`),children:[R?(0,Y.jsxs)(`span`,{className:`relative flex h-4 w-4 flex-shrink-0 items-center justify-center`,children:[(0,Y.jsx)(Qo,{className:`h-4 w-4 transition-opacity group-hover:opacity-0 group-focus-visible:opacity-0`}),(0,Y.jsx)(`span`,{className:`absolute inset-0 hidden items-center justify-center group-hover:flex group-focus-visible:flex`,children:E.has(I7)?(0,Y.jsx)(no,{className:`w-3.5 h-3.5`}):(0,Y.jsx)(io,{className:`w-3.5 h-3.5`})})]}):(0,Y.jsx)(Qo,{className:`w-4 h-4 flex-shrink-0`}),R&&(0,Y.jsx)(`span`,{className:`text-xs truncate flex-1 text-left`,children:s(`home`)})]}),E.has(I7)&&R&&(0,Y.jsx)(`div`,{className:`mt-0.5 space-y-0.5`,children:T.map(e=>(0,Y.jsx)(R7,{conversation:e,active:e.id===x.active?.id,streaming:x.streamingConversationIds.has(e.id),unread:x.unreadConversationIds.has(e.id),expanded:R,onSelect:()=>M(e.id),onToggleFavorite:()=>P(e.id),onDelete:()=>N(e.id)},e.id))})]}),c.map(e=>{let t=C.get(e.id)??[];return(0,Y.jsx)(Sre,{project:e,isActive:e.id===l&&!g,expanded:R,onSelect:()=>F(e.id),onRemove:()=>ne(e),agentMode:S,hasTree:t.length>0,treeOpen:E.has(e.id),onToggleTree:()=>j(e.id),conversations:t,activeConversationId:x.active?.id??null,streamingConversationIds:x.streamingConversationIds,unreadConversationIds:x.unreadConversationIds,onSelectConversation:M,onToggleConversationFavorite:P,onDeleteConversation:N,onOpenProjectSettings:S?()=>{u(e.id),A(!0)}:void 0},e.id)}),(0,Y.jsxs)(`button`,{type:`button`,onClick:e,className:X(`flex items-center gap-2 w-full h-8 rounded-md transition-colors`,`text-muted-foreground hover:text-foreground hover:bg-muted/50`,R?`px-2`:`px-0 justify-center`),"aria-label":o(`projects.addProject`),title:R?void 0:o(`projects.addProject`),children:[(0,Y.jsx)(ks,{className:`w-4 h-4 flex-shrink-0`}),R&&(0,Y.jsx)(`span`,{className:`text-xs whitespace-nowrap`,children:o(`projects.addProject`)})]})]}),(0,Y.jsx)(`div`,{className:`border-t border-border py-2 px-1.5 space-y-0.5`,children:B.map(({label:e,icon:t,action:n})=>(0,Y.jsxs)(`button`,{type:`button`,onClick:n,className:X(`flex items-center gap-2 w-full h-8 rounded-md transition-colors`,`text-muted-foreground hover:text-foreground hover:bg-muted/50`,R?`px-2`:`px-0 justify-center`),"aria-label":e,title:R?void 0:e,children:[(0,Y.jsx)(t,{className:`w-4 h-4 flex-shrink-0`}),R&&(0,Y.jsx)(`span`,{className:`text-xs whitespace-nowrap`,children:e})]},e))}),k&&(0,Y.jsx)(H.Suspense,{fallback:null,children:(0,Y.jsx)(yre,{open:!0,onClose:()=>A(!1)})})]})}var Tre={"pinned-open":`sidebarPin.right.pinnedOpen`,"pinned-collapsed":`sidebarPin.right.pinnedCollapsed`,unpinned:`sidebarPin.right.unpinned`};function Ere(){let{t:e}=K(`nav`),{rightMode:t,cycleRightMode:n}=CY(),{projects:r,activeProjectId:i}=gm(),[a,o]=(0,H.useState)(!1),s=t===`pinned-open`||t===`unpinned`&&a,c=t!==`unpinned`,l=e(Tre[t]),u=r.find(e=>e.id===i),d=u?lm(u):[`claude`],f=Nb&&qD(`agents`,d),p=[{to:`/`,end:!0,icon:as,label:e(`rightSidebar.dashboard`)},{to:`/jobs`,end:!1,icon:Xa,label:e(`rightSidebar.jobs`)},{to:`/analytics`,end:!1,icon:Qa,label:e(`rightSidebar.analytics`)},...f?[{to:`/agents`,end:!1,icon:qa,label:e(`rightSidebar.agents`)}]:[],...Pb?[{to:`/code`,end:!1,icon:ho,label:e(`rightSidebar.code`)}]:[],{to:`/settings`,end:!1,icon:qs,label:e(`rightSidebar.settings`)}];return(0,Y.jsxs)(`div`,{className:X(`relative flex flex-col h-full border-l border-border bg-background flex-shrink-0`,`transition-all duration-200 ease-in-out overflow-hidden`,s?`w-44`:`w-11`),onMouseEnter:()=>{t===`unpinned`&&o(!0)},onMouseLeave:()=>{t===`unpinned`&&o(!1)},children:[(0,Y.jsxs)(`div`,{className:X(`flex items-center h-12 border-b border-border flex-shrink-0`,s?`px-3 justify-between`:`justify-center`),children:[s&&(0,Y.jsx)(`span`,{className:`font-mono text-sm font-bold whitespace-nowrap overflow-hidden text-accent-secondary`,children:e(`rightSidebar.projectTitle`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:n,className:X(`flex items-center justify-center w-7 h-7 rounded-md transition-colors`,c?`text-foreground bg-muted`:`text-muted-foreground/40 hover:text-muted-foreground hover:bg-muted/50`),"aria-label":l,title:e(`sidebarPin.withShortcut`,{label:l,shortcut:`⌘B`}),children:(0,Y.jsx)(xs,{className:`w-4 h-4`})})]}),(0,Y.jsx)(`nav`,{className:`flex-1 py-2 px-1.5 space-y-0.5`,children:p.map(({to:e,end:t,icon:n,label:r})=>(0,Y.jsxs)(Hn,{to:e,end:t,className:({isActive:e})=>X(`flex items-center gap-2 w-full h-8 rounded-md transition-colors`,s?`px-2`:`px-0 justify-center`,e?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),title:s?void 0:r,children:[(0,Y.jsx)(n,{className:`w-4 h-4 flex-shrink-0`}),s&&(0,Y.jsx)(`span`,{className:`text-xs truncate`,children:r})]},e))})]})}function Dre(e){return{darwin:{title:`macOS`,intro:e(`setup:instructions.darwin.intro`),commands:[{label:e(`setup:instructions.darwin.installNodeGit`),command:`brew install node git`}],links:[{label:e(`setup:instructions.links.nodeOfficial`),url:`https://nodejs.org/en/download`},{label:e(`setup:instructions.links.gitOfficial`),url:`https://git-scm.com/downloads`},{label:`Homebrew`,url:`https://brew.sh`}]},win32:{title:`Windows`,intro:e(`setup:instructions.win32.intro`),commands:[{label:e(`setup:instructions.win32.installNode`),command:`winget install OpenJS.NodeJS.LTS`},{label:e(`setup:instructions.win32.installGit`),command:`winget install Git.Git`}],links:[{label:e(`setup:instructions.links.nodeOfficial`),url:`https://nodejs.org/en/download`},{label:e(`setup:instructions.links.gitWindows`),url:`https://git-scm.com/download/win`}],note:e(`setup:instructions.win32.note`)},linux:{title:`Linux`,intro:e(`setup:instructions.linux.intro`),commands:[{label:e(`setup:instructions.linux.debian`),command:`sudo apt install -y nodejs npm git`},{label:e(`setup:instructions.linux.fedora`),command:`sudo dnf install -y nodejs npm git`}],links:[{label:e(`setup:instructions.links.nodeOfficial`),url:`https://nodejs.org/en/download`},{label:e(`setup:instructions.links.gitOfficial`),url:`https://git-scm.com/downloads`}]}}}var Ore=[`darwin`,`win32`,`linux`];async function kre(e){try{if(navigator.clipboard&&typeof navigator.clipboard.writeText==`function`)return await navigator.clipboard.writeText(e),!0}catch{}try{let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select();let n=document.execCommand(`copy`);return document.body.removeChild(t),n}catch{return!1}}function Are({command:e}){let{t}=K(`setup`),[n,r]=(0,H.useState)(!1);return(0,Y.jsx)(Z,{type:`button`,variant:`ghost`,size:`sm`,onClick:async()=>{await kre(e)&&(r(!0),window.setTimeout(()=>r(!1),1500))},className:`h-7 px-2 gap-1.5 text-[11px]`,"data-testid":`install-copy-button`,children:n?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(to,{className:`w-3 h-3`}),t(`common:actions.copied`)]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(bo,{className:`w-3 h-3`}),t(`common:actions.copy`)]})})}function z7({platform:e,primary:t}){let{t:n}=K(`setup`),r=Dre(n)[e];return(0,Y.jsxs)(`section`,{"data-testid":`install-section-${e}`,className:X(`rounded-lg border px-3 py-3`,t?`border-border/40 bg-background/40`:`border-border/20 bg-background/20`),children:[(0,Y.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:r.title}),r.intro&&(0,Y.jsx)(`p`,{className:`mt-1 text-[11px] text-muted-foreground`,children:r.intro}),(0,Y.jsx)(`div`,{className:`mt-2 space-y-2`,children:r.commands.map(e=>(0,Y.jsxs)(`div`,{className:`rounded-md border border-border/30 bg-background/60 px-2 py-2`,children:[(0,Y.jsx)(`p`,{className:`text-[11px] text-muted-foreground mb-1`,children:e.label}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Y.jsx)(`code`,{className:`text-xs text-foreground font-mono break-all`,children:e.command}),(0,Y.jsx)(Are,{command:e.command})]})]},e.command))}),r.links.length>0&&(0,Y.jsx)(`ul`,{className:`mt-2 flex flex-wrap gap-x-3 gap-y-1`,children:r.links.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-[11px] text-accent-info hover:underline`,children:[e.label,(0,Y.jsx)(Oo,{className:`w-3 h-3`})]})},e.url))}),r.note&&(0,Y.jsx)(`p`,{className:`mt-2 text-[11px] text-accent-highlight`,children:r.note})]})}function jre(){let{t:e}=K(`setup`),[t,n]=(0,H.useState)(`idle`);return(0,Y.jsxs)(Z,{type:`button`,variant:`ghost`,size:`sm`,onClick:async()=>{n(`copying`);try{let e=await fetch(`${o}/api/setup-prerequisites?diagnostic=1`);if(!e.ok)throw Error(`HTTP ${e.status}`);let t=await e.json();await navigator.clipboard.writeText(JSON.stringify(t,null,2)),n(`copied`),setTimeout(()=>n(`idle`),1800)}catch{n(`error`),setTimeout(()=>n(`idle`),2400)}},disabled:t===`copying`,className:`gap-1.5 text-[11px]`,"data-testid":`copy-diagnostics-button`,children:[t===`copied`?(0,Y.jsx)(to,{className:`w-3 h-3 text-accent-success`}):(0,Y.jsx)(fo,{className:`w-3 h-3`}),e(t===`copied`?`instructions.diagnostics.copied`:t===`error`?`instructions.diagnostics.failed`:`instructions.diagnostics.copy`)]})}function Mre({open:e,onClose:t,status:n,onRecheck:r,isRechecking:i}){let{t:a}=K(`setup`),[o,s]=(0,H.useState)(!1),c=n?.platform??`darwin`,l=Ore.filter(e=>e!==c);return n?.missingRequired?.some(e=>e.error===`corrupted-bundle`)??!1?(0,Y.jsx)(Cb,{open:e,onOpenChange:e=>{e||t()},children:(0,Y.jsxs)(Db,{movableResizable:!0,className:`max-w-xl`,"data-testid":`install-modal-corrupted-bundle`,children:[(0,Y.jsxs)(Ob,{children:[(0,Y.jsx)(Ab,{children:a(`instructions.corrupted.title`)}),(0,Y.jsx)(jb,{children:a(`instructions.corrupted.description`)})]}),(0,Y.jsx)(`p`,{className:`text-sm text-foreground`,children:a(`instructions.corrupted.body`)}),(0,Y.jsx)(`div`,{className:`flex justify-end mt-2`,children:(0,Y.jsx)(Z,{type:`button`,variant:`ghost`,size:`sm`,onClick:t,"data-testid":`install-corrupted-close-button`,children:a(`common:actions.close`)})})]})}):(0,Y.jsx)(Cb,{open:e,onOpenChange:e=>{e||t()},children:(0,Y.jsxs)(Db,{movableResizable:!0,className:`max-w-xl`,children:[(0,Y.jsxs)(Ob,{children:[(0,Y.jsx)(Ab,{children:a(`instructions.title`)}),(0,Y.jsx)(jb,{children:a(`instructions.description`)})]}),(0,Y.jsxs)(`div`,{className:`space-y-3`,children:[(0,Y.jsx)(z7,{platform:c,primary:!0}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>s(e=>!e),className:`text-[11px] text-muted-foreground hover:text-foreground underline-offset-2 hover:underline`,"data-testid":`install-toggle-others`,children:a(o?`instructions.hideOtherPlatforms`:`instructions.showOtherPlatforms`)}),o&&(0,Y.jsx)(`div`,{className:`space-y-3`,children:l.map(e=>(0,Y.jsx)(z7,{platform:e,primary:!1},e))})]}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mt-2`,children:[(0,Y.jsx)(jre,{}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(Z,{type:`button`,variant:`ghost`,size:`sm`,onClick:t,children:a(`common:actions.close`)}),(0,Y.jsxs)(Z,{type:`button`,variant:`default`,size:`sm`,onClick:r,disabled:i,className:`gap-1.5`,"data-testid":`install-recheck-button`,children:[(0,Y.jsx)(Fs,{className:X(`w-3 h-3`,i&&`animate-spin`)}),a(`instructions.recheck`)]})]})]})]})})}var Nre=typeof window<`u`&&`__TAURI_INTERNALS__`in window,B7=[`claude`,`codex`,`gemini`],Pre={claude:{icon:`🤖`,label:`Claude`},codex:{icon:`⚡`,label:`Codex`},gemini:{icon:`✨`,label:`Gemini`}};function V7(e){let t=B7.filter(t=>t in e),n=Object.keys(e).filter(e=>!B7.includes(e));return[...t,...n]}function Fre({open:e,onClose:t}){let[n,r]=(0,H.useState)(new Set([`claude`])),[i,o]=(0,H.useState)(``),[s,c]=(0,H.useState)(``),[l,u]=(0,H.useState)(!1),[d,f]=(0,H.useState)({claude:!0,codex:!1}),[p,m]=(0,H.useState)(!1),{t:h}=K(`setup`),{addProject:g,startSetupWizard:_,setActiveProjectId:v}=gm(),{status:y,isLoading:b,error:x,recheck:S}=vJ(),C=(0,H.useMemo)(()=>{if(!y||y.ok)return null;let e=y.missingRequired.map(e=>e.label);return e.length===0?null:h(`addProject.toolsRequired`,{tools:e.join(`, `),count:e.length})},[y,h]),w=y!==null&&!y.ok&&!x;(0,H.useEffect)(()=>{e&&fetch(`/api/available-providers`).then(e=>e.json()).then(e=>{let t={};for(let[n,r]of Object.entries(e))n!==`tiers`&&(t[n]=!!r);f(t);let n=new Set;for(let e of V7(t))t[e]&&n.add(e);n.size===0&&n.add(`claude`),r(n)}).catch(()=>{})},[e]);function T(e){r(t=>{let n=new Set(t);if(n.has(e)){if(n.size===1)return t;n.delete(e)}else n.add(e);return n})}let E=V7(d).filter(e=>n.has(e)&&d[e]);async function D(){let e=i.trim();if(!e){q.error(h(`addProject.errors.pathRequired`));return}if(E.length===0){q.error(h(`addProject.errors.selectProvider`));return}u(!0);try{let t=await g(e,s.trim()||void 0,E);if(!t)return;let{project:n}=t;t.has_specrails===!1?(O(),v(n.id),_(n.id)):(q.success(h(`addProject.toasts.registered`,{name:n.name})),O())}catch(e){q.error(h(`addProject.errors.addFailed`),{description:e.message})}finally{u(!1)}}function O(){o(``),c(``),t()}function k(e){e||O()}let A=!Object.values(d).some(Boolean);return(0,Y.jsx)(Cb,{open:e,onOpenChange:k,children:(0,Y.jsxs)(Db,{movableResizable:!0,className:`max-w-md`,children:[(0,Y.jsxs)(Ob,{children:[(0,Y.jsxs)(Ab,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(zo,{className:`w-4 h-4`}),h(`addProject.title`)]}),(0,Y.jsx)(jb,{children:h(`addProject.description`)})]}),A&&(0,Y.jsx)(`p`,{className:`text-xs text-destructive bg-destructive/10 rounded-md p-2`,children:h(`addProject.noProviderDetected`)}),(0,Y.jsx)(bJ,{status:y,isLoading:b,error:x,onMoreInfo:()=>m(!0),onRefresh:S}),(0,Y.jsxs)(`div`,{className:`space-y-4 py-2`,children:[(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsxs)(`label`,{className:`text-xs font-medium`,children:[h(`addProject.pathLabel`),` `,(0,Y.jsx)(`span`,{className:`text-destructive`,children:`*`})]}),(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(_W,{placeholder:h(`addProject.pathPlaceholder`),value:i,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&D()},autoFocus:!0,className:`flex-1`}),Nre&&(0,Y.jsx)(Z,{type:`button`,variant:`outline`,size:`icon`,className:`shrink-0`,title:h(`addProject.browseForFolder`),onClick:async()=>{try{let{open:e}=await a(async()=>{let{open:e}=await import(`./dist-js-DHiN-A_E.js`);return{open:e}},[]),t=await e({directory:!0,multiple:!1,title:h(`addProject.selectProjectFolder`)});typeof t==`string`&&t&&(o(t),s||c(t.split(`/`).filter(Boolean).pop()??``))}catch{}},children:(0,Y.jsx)(zo,{className:`w-4 h-4`})})]}),(0,Y.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:h(`addProject.pathHint`)})]}),(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsxs)(`label`,{className:`text-xs font-medium`,children:[h(`addProject.nameLabel`),` `,(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:h(`addProject.optional`)})]}),(0,Y.jsx)(_W,{placeholder:h(`addProject.namePlaceholder`),value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&D()}}),(0,Y.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:h(`addProject.nameHint`)})]}),(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:h(`addProject.providersLabel`)}),(0,Y.jsx)(`div`,{className:`flex gap-2`,children:V7(d).map(e=>{let{icon:t,label:r}=Pre[e]??{icon:`•`,label:e},i=d[e],a=n.has(e)&&i;return(0,Y.jsxs)(`button`,{type:`button`,role:`checkbox`,"aria-checked":a,disabled:!i,onClick:()=>T(e),"data-testid":`provider-toggle-${e}`,className:X(`flex items-center gap-1.5 rounded-md border px-3 py-1.5 text-left transition-colors text-xs`,`focus:outline-none focus-visible:ring-1 focus-visible:ring-ring`,a?`border-accent-primary/60 bg-accent-primary/10 text-foreground`:`border-border/30 text-muted-foreground hover:border-border/60`,!i&&`opacity-40 cursor-not-allowed`),children:[(0,Y.jsx)(`span`,{className:X(`inline-flex h-3.5 w-3.5 items-center justify-center rounded-sm border text-[9px] leading-none`,a?`border-accent-primary bg-accent-primary text-background`:`border-border/50`),"aria-hidden":!0,children:a?`✓`:``}),(0,Y.jsx)(`span`,{children:t}),(0,Y.jsx)(`span`,{className:`font-medium`,children:r}),!i&&(0,Y.jsx)(`span`,{className:`text-[9px] text-muted-foreground/60`,children:h(`addProject.notFound`)})]},e)})}),(0,Y.jsx)(`p`,{className:`text-[9px] text-muted-foreground/70`,children:E.length>1?h(`addProject.multiProviderHint`):h(`addProject.singleProviderHint`)})]})]}),(0,Y.jsxs)(kb,{children:[(0,Y.jsx)(Z,{variant:`outline`,size:`sm`,onClick:t,disabled:l,children:h(`common:actions.cancel`)}),(0,Y.jsx)(Z,{size:`sm`,onClick:D,disabled:l||!i.trim()||A||E.length===0||w||b,title:w?C??void 0:void 0,"data-testid":`add-project-submit`,children:h(l?`addProject.adding`:`addProject.submit`)})]}),(0,Y.jsx)(Mre,{open:p,onClose:()=>m(!1),status:y,onRecheck:S,isRechecking:b})]})})}var H7=1,Ire=.9,Lre=.8,Rre=.17,U7=.1,W7=.999,zre=.9999,Bre=.99,Vre=/[\\\/_+.#"@\[\(\{&]/,Hre=/[\\\/_+.#"@\[\(\{&]/g,Ure=/[\s-]/,G7=/[\s-]/g;function K7(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?H7:Bre;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=K7(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=H7:Vre.test(e.charAt(l-1))?(d*=Lre,p=e.slice(i,l-1).match(Hre),p&&i>0&&(d*=W7**+p.length)):Ure.test(e.charAt(l-1))?(d*=Ire,m=e.slice(i,l-1).match(G7),m&&i>0&&(d*=W7**+m.length)):(d*=Rre,i>0&&(d*=W7**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=zre)),(d<U7&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=K7(e,t,n,r,l+1,a+2,o),f*U7>d&&(d=f*U7)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function q7(e){return e.toLowerCase().replace(G7,` `)}function Wre(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,K7(e,t,q7(e),q7(t),0,0,{})}var J7=`[cmdk-group=""]`,Y7=`[cmdk-group-items=""]`,Gre=`[cmdk-group-heading=""]`,X7=`[cmdk-item=""]`,Z7=`${X7}:not([aria-disabled="true"])`,Q7=`cmdk-item-select`,$7=`data-value`,Kre=(e,t,n)=>Wre(e,t,n),e9=H.createContext(void 0),t9=()=>H.useContext(e9),n9=H.createContext(void 0),r9=()=>H.useContext(n9),i9=H.createContext(void 0),a9=H.forwardRef((e,t)=>{let n=l9(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=l9(()=>new Set),i=l9(()=>new Map),a=l9(()=>new Map),o=l9(()=>new Set),s=s9(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,v=i_(),y=i_(),b=i_(),x=H.useRef(null),S=rie();c9(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,C.emit()}},[u]),c9(()=>{S(6,k)},[]);let C=H.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)O(),E(),S(1,D);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(b);e?e.focus():(i=document.getElementById(v))==null||i.focus()}if(S(7,()=>{n.current.selectedItemId=A()?.id,C.emit()}),r||S(5,k),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}C.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),w=H.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,T(t,r)),S(2,()=>{E(),C.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),S(3,()=>{O(),E(),n.current.value||D(),C.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=A();S(4,()=>{O(),t?.getAttribute(`id`)===e&&D(),C.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:v,inputId:b,labelId:y,listInnerRef:x}),[]);function T(e,t){let r=s.current?.filter??Kre;return e?r(e,n.current.search,t):0}function E(){if(!n.current.search||s.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=x.current;j().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(Y7);t?t.appendChild(e.parentElement===t?e:e.closest(`${Y7} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${Y7} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=x.current?.querySelector(`${J7}[${$7}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function D(){let e=j().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute($7);C.setState(`value`,e||void 0)}function O(){if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=T(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function k(){var e;let t=A();t&&(t.parentElement?.firstChild===t&&((e=t.closest(J7)?.querySelector(Gre))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function A(){return x.current?.querySelector(`${X7}[aria-selected="true"]`)}function j(){return Array.from(x.current?.querySelectorAll(Z7)||[])}function M(e){let t=j()[e];t&&C.setState(`value`,t.getAttribute($7))}function N(e){var t;let n=A(),r=j(),i=r.findIndex(e=>e===n),a=r[i+e];(t=s.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&C.setState(`value`,a.getAttribute($7))}function P(e){let t=A()?.closest(J7),n;for(;t&&!n;)t=e>0?tie(t,J7):nie(t,J7),n=t?.querySelector(Z7);n?C.setState(`value`,n.getAttribute($7)):N(e)}let F=()=>M(j().length-1),I=e=>{e.preventDefault(),e.metaKey?F():e.altKey?P(1):N(1)},L=e=>{e.preventDefault(),e.metaKey?M(0):e.altKey?P(-1):N(-1)};return H.createElement(h_.div,{ref:t,tabIndex:-1,..._,"cmdk-root":``,onKeyDown:e=>{var t;(t=_.onKeyDown)==null||t.call(_,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:g&&e.ctrlKey&&I(e);break;case`ArrowDown`:I(e);break;case`p`:case`k`:g&&e.ctrlKey&&L(e);break;case`ArrowUp`:L(e);break;case`Home`:e.preventDefault(),M(0);break;case`End`:e.preventDefault(),F();break;case`Enter`:{e.preventDefault();let t=A();if(t){let e=new Event(Q7);t.dispatchEvent(e)}}}}},H.createElement(`label`,{"cmdk-label":``,htmlFor:w.inputId,id:w.labelId,style:aie},c),f9(e,e=>H.createElement(n9.Provider,{value:C},H.createElement(e9.Provider,{value:w},e))))}),qre=H.forwardRef((e,t)=>{let n=i_(),r=H.useRef(null),i=H.useContext(i9),a=t9(),o=s9(e),s=o.current?.forceMount??i?.forceMount;c9(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=d9(n,r,[e.value,e.children,r],e.keywords),l=r9(),u=u9(e=>e.value&&e.value===c.current),d=u9(e=>s||a.filter()===!1?!0:e.search?e.filtered.items.get(n)>0:!0);H.useEffect(()=>{let t=r.current;if(!(!t||e.disabled))return t.addEventListener(Q7,f),()=>t.removeEventListener(Q7,f)},[d,e.onSelect,e.disabled]);function f(){var e,t;p(),(t=(e=o.current).onSelect)==null||t.call(e,c.current)}function p(){l.setState(`value`,c.current,!0)}if(!d)return null;let{disabled:m,value:h,onSelect:g,forceMount:_,keywords:v,...y}=e;return H.createElement(h_.div,{ref:Om(r,t),...y,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!m,"aria-selected":!!u,"data-disabled":!!m,"data-selected":!!u,onPointerMove:m||a.getDisablePointerSelection()?void 0:p,onClick:m?void 0:f},e.children)}),Jre=H.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=i_(),s=H.useRef(null),c=H.useRef(null),l=i_(),u=t9(),d=u9(e=>i||u.filter()===!1?!0:e.search?e.filtered.groups.has(o):!0);c9(()=>u.group(o),[]),d9(o,s,[e.value,e.heading,c]);let f=H.useMemo(()=>({id:o,forceMount:i}),[i]);return H.createElement(h_.div,{ref:Om(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:d?void 0:!0},n&&H.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),f9(e,e=>H.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},H.createElement(i9.Provider,{value:f},e))))}),Yre=H.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=H.useRef(null),a=u9(e=>!e.search);return!n&&!a?null:H.createElement(h_.div,{ref:Om(i,t),...r,"cmdk-separator":``,role:`separator`})}),Xre=H.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=r9(),o=u9(e=>e.search),s=u9(e=>e.selectedItemId),c=t9();return H.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),H.createElement(h_.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":s,id:c.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),Zre=H.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=H.useRef(null),o=H.useRef(null),s=u9(e=>e.selectedItemId),c=t9();return H.useEffect(()=>{if(o.current&&a.current){let e=o.current,t=a.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),H.createElement(h_.div,{ref:Om(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},f9(e,e=>H.createElement(`div`,{ref:Om(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),Qre=H.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return H.createElement(Xy,{open:n,onOpenChange:r},H.createElement(Zy,{container:o},H.createElement(Qy,{"cmdk-overlay":``,className:i}),H.createElement($y,{"aria-label":e.label,"cmdk-dialog":``,className:a},H.createElement(a9,{ref:t,...s}))))}),$re=H.forwardRef((e,t)=>u9(e=>e.filtered.count===0)?H.createElement(h_.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),eie=H.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return H.createElement(h_.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},f9(e,e=>H.createElement(`div`,{"aria-hidden":!0},e)))}),o9=Object.assign(a9,{List:Zre,Item:qre,Input:Xre,Group:Jre,Separator:Yre,Dialog:Qre,Empty:$re,Loading:eie});function tie(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function nie(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function s9(e){let t=H.useRef(e);return c9(()=>{t.current=e}),t}var c9=typeof window>`u`?H.useEffect:H.useLayoutEffect;function l9(e){let t=H.useRef();return t.current===void 0&&(t.current=e()),t}function u9(e){let t=r9(),n=()=>e(t.snapshot());return H.useSyncExternalStore(t.subscribe,n,n)}function d9(e,t,n,r=[]){let i=H.useRef(),a=t9();return c9(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute($7,s),i.current=s}),i}var rie=()=>{let[e,t]=H.useState(),n=l9(()=>new Map);return c9(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function iie(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function f9({asChild:e,children:t},n){return e&&H.isValidElement(t)?H.cloneElement(iie(t),{ref:t.ref},n(t.props.children)):n(t)}var aie={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`};function oie({onOpenSettings:e,onOpenAnalytics:t,onOpenDocs:n}){let{t:r}=K(`commands`),[i,a]=(0,H.useState)(!1),[o,s]=(0,H.useState)([]),[c,l]=(0,H.useState)([]),{projects:u,activeProjectId:d,setActiveProjectId:f}=gm(),{leftMode:p,rightMode:m,cycleLeftMode:h,cycleRightMode:g}=CY(),_=r(p===`pinned-open`?`palette.sidebar.collapseLeftKeepPinned`:p===`pinned-collapsed`?`palette.sidebar.unpinLeft`:`palette.sidebar.pinLeftOpen`),v=r(m===`pinned-open`?`palette.sidebar.collapseRightKeepPinned`:m===`pinned-collapsed`?`palette.sidebar.unpinRight`:`palette.sidebar.pinRightOpen`),y=_t(),b=(0,H.useRef)(!1);(0,H.useEffect)(()=>{function e(e){e.key===`k`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),a(e=>!e))}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),(0,H.useEffect)(()=>{if(!i){b.current=!1;return}if(b.current)return;b.current=!0;async function e(){try{let[e,t]=await Promise.all([fetch(`${af()}/config`),fetch(`${af()}/jobs?limit=10`)]);e.ok&&s((await e.json()).commands),t.ok&&l((await t.json()).jobs)}catch{}}e()},[i]);let x=(0,H.useCallback)(e=>{f(e),a(!1)},[f]),S=(0,H.useCallback)(async e=>{a(!1);try{let t=await fetch(`${af()}/spawn`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({command:`/specrails:${e}`})}),n=await t.json();if(!t.ok)throw Error(n.error??r(`errors.spawnFailed`));q.success(r(`toasts.queued`,{name:e})),y(`/jobs/${n.jobId}`)}catch(e){q.error(e instanceof Error?e.message:r(`errors.spawnFailed`))}},[y,r]),C=(0,H.useCallback)(e=>{a(!1),y(`/jobs/${e}`)},[y]),w=(0,H.useCallback)(e=>{a(!1),y(e)},[y]),T=(0,H.useCallback)(e=>{e&&(a(!1),e())},[]),E=`flex items-center gap-3 px-3 py-2 rounded-lg cursor-pointer text-sm data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground`;return(0,Y.jsxs)(o9.Dialog,{open:i,onOpenChange:a,label:r(`palette.label`),className:X(`fixed left-[50%] top-[50%] z-50 w-full max-w-lg translate-x-[-50%] translate-y-[-50%]`,`border border-border/30 bg-popover shadow-2xl backdrop-blur-md rounded-xl overflow-hidden`),children:[(0,Y.jsx)(`span`,{className:`sr-only`,children:r(`palette.label`)}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 px-3 border-b border-border/30`,children:[(0,Y.jsx)(Us,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,Y.jsx)(o9.Input,{placeholder:r(`palette.searchPlaceholder`),className:`flex-1 h-11 bg-transparent text-sm outline-none placeholder:text-muted-foreground/50`}),(0,Y.jsx)(`kbd`,{className:`hidden sm:inline-flex items-center gap-0.5 rounded border border-border/50 bg-muted/30 px-1.5 py-0.5 text-[10px] text-muted-foreground font-mono`,children:`esc`})]}),(0,Y.jsxs)(o9.List,{className:`max-h-80 overflow-y-auto p-2`,children:[(0,Y.jsx)(o9.Empty,{className:`py-8 text-center text-sm text-muted-foreground`,children:r(`palette.noResults`)}),u.length>0&&(0,Y.jsx)(o9.Group,{heading:r(`palette.groups.projects`),children:u.map(e=>(0,Y.jsxs)(o9.Item,{value:e.name,keywords:[e.slug],onSelect:()=>x(e.id),className:X(E,e.id===d&&`text-accent-primary`),children:[(0,Y.jsx)(zo,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,Y.jsx)(`span`,{className:`flex-1 truncate`,children:e.name}),e.id===d&&(0,Y.jsx)(`span`,{className:`text-[10px] text-accent-primary font-medium`,children:r(`palette.activeBadge`)})]},e.id))}),o.length>0&&(0,Y.jsx)(o9.Group,{heading:r(`palette.groups.spec`),children:o.map(e=>(0,Y.jsxs)(o9.Item,{value:e.name,keywords:[e.slug,e.description??``],onSelect:()=>S(e.slug),className:E,children:[(0,Y.jsx)(gc,{className:`w-4 h-4 text-accent-info shrink-0`}),(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Y.jsx)(`span`,{className:`truncate`,children:e.name}),e.description&&(0,Y.jsx)(`span`,{className:`text-[11px] text-muted-foreground/60 ml-2 truncate`,children:e.description})]})]},e.id))}),c.length>0&&(0,Y.jsx)(o9.Group,{heading:r(`palette.groups.jobs`),children:c.map(e=>(0,Y.jsxs)(o9.Item,{value:`${e.command} ${e.id}`,keywords:[e.status],onSelect:()=>C(e.id),className:E,children:[(0,Y.jsx)(Xa,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,Y.jsx)(`span`,{className:`flex-1 truncate`,children:e.command}),(0,Y.jsx)(`span`,{className:X(`text-[10px] font-medium`,e.status===`completed`&&`text-accent-success`,e.status===`failed`&&`text-destructive`,e.status===`running`&&`text-accent-info`,e.status===`queued`&&`text-muted-foreground`),children:r(`common:status.${e.status}`,{defaultValue:e.status})})]},e.id))}),(0,Y.jsxs)(o9.Group,{heading:r(`palette.groups.navigation`),children:[(0,Y.jsxs)(o9.Item,{value:r(`palette.nav.dashboard`),keywords:[`home`],onSelect:()=>w(`/`),className:E,children:[(0,Y.jsx)(as,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,Y.jsx)(`span`,{children:r(`palette.nav.dashboard`)})]}),t&&(0,Y.jsxs)(o9.Item,{value:r(`palette.nav.desktopAnalytics`),keywords:[`cross-project`,`desktop`],onSelect:()=>T(t),className:E,children:[(0,Y.jsx)(eo,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,Y.jsx)(`span`,{children:r(`palette.nav.desktopAnalytics`)})]}),(0,Y.jsxs)(o9.Item,{value:r(`palette.nav.projectAnalytics`),keywords:[`metrics`],onSelect:()=>w(`/analytics`),className:E,children:[(0,Y.jsx)(Qa,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,Y.jsx)(`span`,{children:r(`palette.nav.projectAnalytics`)})]}),(0,Y.jsxs)(o9.Item,{value:r(`palette.nav.activityFeed`),keywords:[`log`],onSelect:()=>w(`/activity`),className:E,children:[(0,Y.jsx)(La,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,Y.jsx)(`span`,{children:r(`palette.nav.activityFeed`)})]}),(0,Y.jsxs)(o9.Item,{value:r(`palette.nav.desktopSettings`),keywords:[`configuration`],onSelect:()=>e?T(e):w(`/settings`),className:E,children:[(0,Y.jsx)(qs,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,Y.jsx)(`span`,{children:r(`palette.nav.desktopSettings`)})]}),(0,Y.jsxs)(o9.Item,{value:r(`palette.nav.docs`),keywords:[`documentation`],onSelect:()=>n?T(n):w(`/docs`),className:E,children:[(0,Y.jsx)(Po,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,Y.jsx)(`span`,{children:r(`palette.nav.docs`)})]}),(0,Y.jsxs)(o9.Item,{value:_,keywords:[`sidebar`,`panel`,`left`,`pin`,`collapse`,`unpin`,`cycle`],onSelect:()=>{h(),a(!1)},className:E,children:[(0,Y.jsx)(bs,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,Y.jsx)(`span`,{children:_})]}),(0,Y.jsxs)(o9.Item,{value:v,keywords:[`sidebar`,`panel`,`right`,`nav`,`pin`,`collapse`,`unpin`,`cycle`],onSelect:()=>{g(),a(!1)},className:E,children:[(0,Y.jsx)(xs,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,Y.jsx)(`span`,{children:v})]})]})]}),(0,Y.jsx)(`div`,{className:`flex items-center justify-between px-3 py-2 border-t border-border/30 text-[10px] text-muted-foreground/50`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`kbd`,{className:`font-mono`,children:`↑↓`}),` `,r(`palette.footer.navigate`)]}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`kbd`,{className:`font-mono`,children:`↵`}),` `,r(`palette.footer.select`)]}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`kbd`,{className:`font-mono`,children:`esc`}),` `,r(`palette.footer.close`)]})]})})]})}var sie=`
146
146
 
147
147
  ---
148
148
 
@@ -155,4 +155,4 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
155
155
  `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||=this._coreBrowserService.window.requestAnimationFrame((()=>this._refresh())),d.isLinux&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!!(n&&r&&t)&&this._areCoordsInSelection(t,n,r)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!(!n||!r)&&this._areCoordsInSelection([e,t],n,r)}_areCoordsInSelection(e,t,n){return e[1]>t[1]&&e[1]<n[1]||t[1]===n[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<n[0]||t[1]<n[1]&&e[1]===n[1]&&e[0]<n[0]||t[1]<n[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){let n=this._linkifier.currentLink?.link?.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=(0,f.getRangeLength)(n,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let r=this._getMouseBufferCoords(e);return!!r&&(this._selectWordAt(r,t),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=(0,a.getCoordsRelativeToElement)(this._coreBrowserService.window,e,this._screenElement)[1],n=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=n?0:(t>n&&(t-=n),t=Math.min(Math.max(t,-50),50),t/=50,t/Math.abs(t)+Math.round(14*t))}shouldForceSelection(e){return d.isMac?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,(e.button!==2||!this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener(`mousemove`,this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener(`mouseup`,this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval((()=>this._dragScroll()),50)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener(`mousemove`,this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener(`mouseup`,this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(d.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd)return void this.refresh(!0);this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let n=this._bufferService.buffer;if(this._model.selectionEnd[1]<n.lines.length){let e=n.lines.get(this._model.selectionEnd[1]);e&&e.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}t&&t[0]===this._model.selectionEnd[0]&&t[1]===this._model.selectionEnd[1]||this.refresh(!0)}_dragScroll(){if(this._model.selectionEnd&&this._model.selectionStart&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<500&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let t=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(t&&t[0]!==void 0&&t[1]!==void 0){let e=(0,o.moveToCellSequence)(t[0]-1,t[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(e,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,n=!(!e||!t||e[0]===t[0]&&e[1]===t[1]);n?e&&t&&(this._oldSelectionStart&&this._oldSelectionEnd&&e[0]===this._oldSelectionStart[0]&&e[1]===this._oldSelectionStart[1]&&t[0]===this._oldSelectionEnd[0]&&t[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(e,t,n)):this._oldHasSelection&&this._fireOnSelectionChange(e,t,n)}_fireOnSelectionChange(e,t,n){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=n,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim((e=>this._handleTrim(e)))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let r=0;t>=r;r++){let i=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:i>1&&t!==r&&(n+=i-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,r=!0){if(e[0]>=this._bufferService.cols)return;let i=this._bufferService.buffer,a=i.lines.get(e[1]);if(!a)return;let o=i.translateBufferLineToString(e[1],!1),s=this._convertViewportColToCharacterIndex(a,e[0]),c=s,l=e[0]-s,u=0,d=0,f=0,p=0;if(o.charAt(s)===` `){for(;s>0&&o.charAt(s-1)===` `;)s--;for(;c<o.length&&o.charAt(c+1)===` `;)c++}else{let t=e[0],n=e[0];a.getWidth(t)===0&&(u++,t--),a.getWidth(n)===2&&(d++,n++);let r=a.getString(n).length;for(r>1&&(p+=r-1,c+=r-1);t>0&&s>0&&!this._isCharWordSeparator(a.loadCell(t-1,this._workCell));){a.loadCell(t-1,this._workCell);let e=this._workCell.getChars().length;this._workCell.getWidth()===0?(u++,t--):e>1&&(f+=e-1,s-=e-1),s--,t--}for(;n<a.length&&c+1<o.length&&!this._isCharWordSeparator(a.loadCell(n+1,this._workCell));){a.loadCell(n+1,this._workCell);let e=this._workCell.getChars().length;this._workCell.getWidth()===2?(d++,n++):e>1&&(p+=e-1,c+=e-1),c++,n++}}c++;let m=s+l-u+f,h=Math.min(this._bufferService.cols,c-s+u+d-f-p);if(t||o.slice(s,c).trim()!==``){if(n&&m===0&&a.getCodePoint(0)!==32){let t=i.lines.get(e[1]-1);if(t&&a.isWrapped&&t.getCodePoint(this._bufferService.cols-1)!==32){let t=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(t){let e=this._bufferService.cols-t.start;m-=e,h+=e}}}if(r&&m+h===this._bufferService.cols&&a.getCodePoint(this._bufferService.cols-1)!==32){let t=i.lines.get(e[1]+1);if(t?.isWrapped&&t.getCodePoint(0)!==32){let t=this._getWordAt([0,e[1]+1],!1,!1,!0);t&&(h+=t.length)}}return{start:m,length:h}}}_selectWordAt(e,t){let n=this._getWordAt(e,t);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let n=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,n]}}_isCharWordSeparator(e){return e.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),n={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=(0,f.getRangeLength)(n,this._bufferService.cols)}};t.SelectionService=g=r([i(3,m.IBufferService),i(4,m.ICoreService),i(5,c.IMouseService),i(6,m.IOptionsService),i(7,c.IRenderService),i(8,c.ICoreBrowserService)],g)},4725:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.ILinkProviderService=t.IThemeService=t.ICharacterJoinerService=t.ISelectionService=t.IRenderService=t.IMouseService=t.ICoreBrowserService=t.ICharSizeService=void 0;let r=n(8343);t.ICharSizeService=(0,r.createDecorator)(`CharSizeService`),t.ICoreBrowserService=(0,r.createDecorator)(`CoreBrowserService`),t.IMouseService=(0,r.createDecorator)(`MouseService`),t.IRenderService=(0,r.createDecorator)(`RenderService`),t.ISelectionService=(0,r.createDecorator)(`SelectionService`),t.ICharacterJoinerService=(0,r.createDecorator)(`CharacterJoinerService`),t.IThemeService=(0,r.createDecorator)(`ThemeService`),t.ILinkProviderService=(0,r.createDecorator)(`LinkProviderService`)},6731:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,`__esModule`,{value:!0}),t.ThemeService=t.DEFAULT_ANSI_COLORS=void 0;let a=n(7239),o=n(8055),s=n(8460),c=n(844),l=n(2585),u=o.css.toColor(`#ffffff`),d=o.css.toColor(`#000000`),f=o.css.toColor(`#ffffff`),p=o.css.toColor(`#000000`),m={css:`rgba(255, 255, 255, 0.3)`,rgba:4294967117};t.DEFAULT_ANSI_COLORS=Object.freeze((()=>{let e=[o.css.toColor(`#2e3436`),o.css.toColor(`#cc0000`),o.css.toColor(`#4e9a06`),o.css.toColor(`#c4a000`),o.css.toColor(`#3465a4`),o.css.toColor(`#75507b`),o.css.toColor(`#06989a`),o.css.toColor(`#d3d7cf`),o.css.toColor(`#555753`),o.css.toColor(`#ef2929`),o.css.toColor(`#8ae234`),o.css.toColor(`#fce94f`),o.css.toColor(`#729fcf`),o.css.toColor(`#ad7fa8`),o.css.toColor(`#34e2e2`),o.css.toColor(`#eeeeec`)],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let r=t[n/36%6|0],i=t[n/6%6|0],a=t[n%6];e.push({css:o.channels.toCss(r,i,a),rgba:o.channels.toRgba(r,i,a)})}for(let t=0;t<24;t++){let n=8+10*t;e.push({css:o.channels.toCss(n,n,n),rgba:o.channels.toRgba(n,n,n)})}return e})());let h=t.ThemeService=class extends c.Disposable{get colors(){return this._colors}constructor(e){super(),this._optionsService=e,this._contrastCache=new a.ColorContrastCache,this._halfContrastCache=new a.ColorContrastCache,this._onChangeColors=this.register(new s.EventEmitter),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:u,background:d,cursor:f,cursorAccent:p,selectionForeground:void 0,selectionBackgroundTransparent:m,selectionBackgroundOpaque:o.color.blend(d,m),selectionInactiveBackgroundTransparent:m,selectionInactiveBackgroundOpaque:o.color.blend(d,m),ansi:t.DEFAULT_ANSI_COLORS.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this.register(this._optionsService.onSpecificOptionChange(`minimumContrastRatio`,(()=>this._contrastCache.clear()))),this.register(this._optionsService.onSpecificOptionChange(`theme`,(()=>this._setTheme(this._optionsService.rawOptions.theme))))}_setTheme(e={}){let n=this._colors;if(n.foreground=g(e.foreground,u),n.background=g(e.background,d),n.cursor=g(e.cursor,f),n.cursorAccent=g(e.cursorAccent,p),n.selectionBackgroundTransparent=g(e.selectionBackground,m),n.selectionBackgroundOpaque=o.color.blend(n.background,n.selectionBackgroundTransparent),n.selectionInactiveBackgroundTransparent=g(e.selectionInactiveBackground,n.selectionBackgroundTransparent),n.selectionInactiveBackgroundOpaque=o.color.blend(n.background,n.selectionInactiveBackgroundTransparent),n.selectionForeground=e.selectionForeground?g(e.selectionForeground,o.NULL_COLOR):void 0,n.selectionForeground===o.NULL_COLOR&&(n.selectionForeground=void 0),o.color.isOpaque(n.selectionBackgroundTransparent)&&(n.selectionBackgroundTransparent=o.color.opacity(n.selectionBackgroundTransparent,.3)),o.color.isOpaque(n.selectionInactiveBackgroundTransparent)&&(n.selectionInactiveBackgroundTransparent=o.color.opacity(n.selectionInactiveBackgroundTransparent,.3)),n.ansi=t.DEFAULT_ANSI_COLORS.slice(),n.ansi[0]=g(e.black,t.DEFAULT_ANSI_COLORS[0]),n.ansi[1]=g(e.red,t.DEFAULT_ANSI_COLORS[1]),n.ansi[2]=g(e.green,t.DEFAULT_ANSI_COLORS[2]),n.ansi[3]=g(e.yellow,t.DEFAULT_ANSI_COLORS[3]),n.ansi[4]=g(e.blue,t.DEFAULT_ANSI_COLORS[4]),n.ansi[5]=g(e.magenta,t.DEFAULT_ANSI_COLORS[5]),n.ansi[6]=g(e.cyan,t.DEFAULT_ANSI_COLORS[6]),n.ansi[7]=g(e.white,t.DEFAULT_ANSI_COLORS[7]),n.ansi[8]=g(e.brightBlack,t.DEFAULT_ANSI_COLORS[8]),n.ansi[9]=g(e.brightRed,t.DEFAULT_ANSI_COLORS[9]),n.ansi[10]=g(e.brightGreen,t.DEFAULT_ANSI_COLORS[10]),n.ansi[11]=g(e.brightYellow,t.DEFAULT_ANSI_COLORS[11]),n.ansi[12]=g(e.brightBlue,t.DEFAULT_ANSI_COLORS[12]),n.ansi[13]=g(e.brightMagenta,t.DEFAULT_ANSI_COLORS[13]),n.ansi[14]=g(e.brightCyan,t.DEFAULT_ANSI_COLORS[14]),n.ansi[15]=g(e.brightWhite,t.DEFAULT_ANSI_COLORS[15]),e.extendedAnsi){let r=Math.min(n.ansi.length-16,e.extendedAnsi.length);for(let i=0;i<r;i++)n.ansi[i+16]=g(e.extendedAnsi[i],t.DEFAULT_ANSI_COLORS[i+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e!==void 0)switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}else for(let e=0;e<this._restoreColors.ansi.length;++e)this._colors.ansi[e]=this._restoreColors.ansi[e]}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};function g(e,t){if(e!==void 0)try{return o.css.toColor(e)}catch{}return t}t.ThemeService=h=r([i(0,l.IOptionsService)],h)},6349:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.CircularList=void 0;let r=n(8460),i=n(844);class a extends i.Disposable{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this.register(new r.EventEmitter),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this.register(new r.EventEmitter),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this.register(new r.EventEmitter),this.onTrim=this.onTrimEmitter.event,this._array=Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=Array(e);for(let n=0;n<Math.min(e,this.length);n++)t[n]=this._array[this._getCyclicIndex(n)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw Error(`Can only recycle when the buffer is full`);return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...n){if(t){for(let n=e;n<this._length-t;n++)this._array[this._getCyclicIndex(n)]=this._array[this._getCyclicIndex(n+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let t=this._length-1;t>=e;t--)this._array[this._getCyclicIndex(t+n.length)]=this._array[this._getCyclicIndex(t)];for(let t=0;t<n.length;t++)this._array[this._getCyclicIndex(e+t)]=n[t];if(n.length&&this.onInsertEmitter.fire({index:e,amount:n.length}),this._length+n.length>this._maxLength){let e=this._length+n.length-this._maxLength;this._startIndex+=e,this._length=this._maxLength,this.onTrimEmitter.fire(e)}else this._length+=n.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,n){if(!(t<=0)){if(e<0||e>=this._length)throw Error(`start argument out of range`);if(e+n<0)throw Error(`Cannot shift elements in list beyond index 0`);if(n>0){for(let r=t-1;r>=0;r--)this.set(e+r+n,this.get(e+r));let r=e+t+n-this._length;if(r>0)for(this._length+=r;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let r=0;r<t;r++)this.set(e+r+n,this.get(e+r))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}}t.CircularList=a},1439:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.clone=void 0,t.clone=function e(t,n=5){if(typeof t!=`object`)return t;let r=Array.isArray(t)?[]:{};for(let i in t)r[i]=n<=1?t[i]:t[i]&&e(t[i],n-1);return r}},8055:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.contrastRatio=t.toPaddedHex=t.rgba=t.rgb=t.css=t.color=t.channels=t.NULL_COLOR=void 0;let n=0,r=0,i=0,a=0;var o,s,c,l,u;function d(e){let t=e.toString(16);return t.length<2?`0`+t:t}function f(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}t.NULL_COLOR={css:`#00000000`,rgba:0},function(e){e.toCss=function(e,t,n,r){return r===void 0?`#${d(e)}${d(t)}${d(n)}`:`#${d(e)}${d(t)}${d(n)}${d(r)}`},e.toRgba=function(e,t,n,r=255){return(e<<24|t<<16|n<<8|r)>>>0},e.toColor=function(t,n,r,i){return{css:e.toCss(t,n,r,i),rgba:e.toRgba(t,n,r,i)}}}(o||(t.channels=o={})),function(e){function t(e,t){return a=Math.round(255*t),[n,r,i]=u.toChannels(e.rgba),{css:o.toCss(n,r,i,a),rgba:o.toRgba(n,r,i,a)}}e.blend=function(e,t){if(a=(255&t.rgba)/255,a===1)return{css:t.css,rgba:t.rgba};let s=t.rgba>>24&255,c=t.rgba>>16&255,l=t.rgba>>8&255,u=e.rgba>>24&255,d=e.rgba>>16&255,f=e.rgba>>8&255;return n=u+Math.round((s-u)*a),r=d+Math.round((c-d)*a),i=f+Math.round((l-f)*a),{css:o.toCss(n,r,i),rgba:o.toRgba(n,r,i)}},e.isOpaque=function(e){return(255&e.rgba)==255},e.ensureContrastRatio=function(e,t,n){let r=u.ensureContrastRatio(e.rgba,t.rgba,n);if(r)return o.toColor(r>>24&255,r>>16&255,r>>8&255)},e.opaque=function(e){let t=(255|e.rgba)>>>0;return[n,r,i]=u.toChannels(t),{css:o.toCss(n,r,i),rgba:t}},e.opacity=t,e.multiplyOpacity=function(e,n){return a=255&e.rgba,t(e,a*n/255)},e.toColorRGB=function(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]}}(s||(t.color=s={})),function(e){let t,s;try{let e=document.createElement(`canvas`);e.width=1,e.height=1;let n=e.getContext(`2d`,{willReadFrequently:!0});n&&(t=n,t.globalCompositeOperation=`copy`,s=t.createLinearGradient(0,0,1,1))}catch{}e.toColor=function(e){if(e.match(/#[\da-f]{3,8}/i))switch(e.length){case 4:return n=parseInt(e.slice(1,2).repeat(2),16),r=parseInt(e.slice(2,3).repeat(2),16),i=parseInt(e.slice(3,4).repeat(2),16),o.toColor(n,r,i);case 5:return n=parseInt(e.slice(1,2).repeat(2),16),r=parseInt(e.slice(2,3).repeat(2),16),i=parseInt(e.slice(3,4).repeat(2),16),a=parseInt(e.slice(4,5).repeat(2),16),o.toColor(n,r,i,a);case 7:return{css:e,rgba:(parseInt(e.slice(1),16)<<8|255)>>>0};case 9:return{css:e,rgba:parseInt(e.slice(1),16)>>>0}}let c=e.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(c)return n=parseInt(c[1]),r=parseInt(c[2]),i=parseInt(c[3]),a=Math.round(255*(c[5]===void 0?1:parseFloat(c[5]))),o.toColor(n,r,i,a);if(!t||!s||(t.fillStyle=s,t.fillStyle=e,typeof t.fillStyle!=`string`)||(t.fillRect(0,0,1,1),[n,r,i,a]=t.getImageData(0,0,1,1).data,a!==255))throw Error(`css.toColor: Unsupported css format`);return{rgba:o.toRgba(n,r,i,a),css:e}}}(c||(t.css=c={})),function(e){function t(e,t,n){let r=e/255,i=t/255,a=n/255;return .2126*(r<=.03928?r/12.92:((r+.055)/1.055)**2.4)+.7152*(i<=.03928?i/12.92:((i+.055)/1.055)**2.4)+.0722*(a<=.03928?a/12.92:((a+.055)/1.055)**2.4)}e.relativeLuminance=function(e){return t(e>>16&255,e>>8&255,255&e)},e.relativeLuminance2=t}(l||(t.rgb=l={})),function(e){function t(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,u=f(l.relativeLuminance2(o,s,c),l.relativeLuminance2(r,i,a));for(;u<n&&(o>0||s>0||c>0);)o-=Math.max(0,Math.ceil(.1*o)),s-=Math.max(0,Math.ceil(.1*s)),c-=Math.max(0,Math.ceil(.1*c)),u=f(l.relativeLuminance2(o,s,c),l.relativeLuminance2(r,i,a));return(o<<24|s<<16|c<<8|255)>>>0}function s(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,u=f(l.relativeLuminance2(o,s,c),l.relativeLuminance2(r,i,a));for(;u<n&&(o<255||s<255||c<255);)o=Math.min(255,o+Math.ceil(.1*(255-o))),s=Math.min(255,s+Math.ceil(.1*(255-s))),c=Math.min(255,c+Math.ceil(.1*(255-c))),u=f(l.relativeLuminance2(o,s,c),l.relativeLuminance2(r,i,a));return(o<<24|s<<16|c<<8|255)>>>0}e.blend=function(e,t){if(a=(255&t)/255,a===1)return t;let s=t>>24&255,c=t>>16&255,l=t>>8&255,u=e>>24&255,d=e>>16&255,f=e>>8&255;return n=u+Math.round((s-u)*a),r=d+Math.round((c-d)*a),i=f+Math.round((l-f)*a),o.toRgba(n,r,i)},e.ensureContrastRatio=function(e,n,r){let i=l.relativeLuminance(e>>8),a=l.relativeLuminance(n>>8);if(f(i,a)<r){if(a<i){let a=t(e,n,r),o=f(i,l.relativeLuminance(a>>8));if(o<r){let t=s(e,n,r);return o>f(i,l.relativeLuminance(t>>8))?a:t}return a}let o=s(e,n,r),c=f(i,l.relativeLuminance(o>>8));if(c<r){let a=t(e,n,r);return c>f(i,l.relativeLuminance(a>>8))?o:a}return o}},e.reduceLuminance=t,e.increaseLuminance=s,e.toChannels=function(e){return[e>>24&255,e>>16&255,e>>8&255,255&e]}}(u||(t.rgba=u={})),t.toPaddedHex=d,t.contrastRatio=f},8969:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.CoreTerminal=void 0;let r=n(844),i=n(2585),a=n(4348),o=n(7866),s=n(744),c=n(7302),l=n(6975),u=n(8460),d=n(1753),f=n(1480),p=n(7994),m=n(9282),h=n(5435),g=n(5981),_=n(2660),v=!1;class y extends r.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new u.EventEmitter),this._onScroll.event((e=>{this._onScrollApi?.fire(e.position)}))),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}constructor(e){super(),this._windowsWrappingHeuristics=this.register(new r.MutableDisposable),this._onBinary=this.register(new u.EventEmitter),this.onBinary=this._onBinary.event,this._onData=this.register(new u.EventEmitter),this.onData=this._onData.event,this._onLineFeed=this.register(new u.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onResize=this.register(new u.EventEmitter),this.onResize=this._onResize.event,this._onWriteParsed=this.register(new u.EventEmitter),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this.register(new u.EventEmitter),this._instantiationService=new a.InstantiationService,this.optionsService=this.register(new c.OptionsService(e)),this._instantiationService.setService(i.IOptionsService,this.optionsService),this._bufferService=this.register(this._instantiationService.createInstance(s.BufferService)),this._instantiationService.setService(i.IBufferService,this._bufferService),this._logService=this.register(this._instantiationService.createInstance(o.LogService)),this._instantiationService.setService(i.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(l.CoreService)),this._instantiationService.setService(i.ICoreService,this.coreService),this.coreMouseService=this.register(this._instantiationService.createInstance(d.CoreMouseService)),this._instantiationService.setService(i.ICoreMouseService,this.coreMouseService),this.unicodeService=this.register(this._instantiationService.createInstance(f.UnicodeService)),this._instantiationService.setService(i.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(p.CharsetService),this._instantiationService.setService(i.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(_.OscLinkService),this._instantiationService.setService(i.IOscLinkService,this._oscLinkService),this._inputHandler=this.register(new h.InputHandler(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this.register((0,u.forwardEvent)(this._inputHandler.onLineFeed,this._onLineFeed)),this.register(this._inputHandler),this.register((0,u.forwardEvent)(this._bufferService.onResize,this._onResize)),this.register((0,u.forwardEvent)(this.coreService.onData,this._onData)),this.register((0,u.forwardEvent)(this.coreService.onBinary,this._onBinary)),this.register(this.coreService.onRequestScrollToBottom((()=>this.scrollToBottom()))),this.register(this.coreService.onUserInput((()=>this._writeBuffer.handleUserInput()))),this.register(this.optionsService.onMultipleOptionChange([`windowsMode`,`windowsPty`],(()=>this._handleWindowsPtyOptionChange()))),this.register(this._bufferService.onScroll((e=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this.register(this._inputHandler.onScroll((e=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this._writeBuffer=this.register(new g.WriteBuffer(((e,t)=>this._inputHandler.parse(e,t)))),this.register((0,u.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=i.LogLevelEnum.WARN&&!v&&(this._logService.warn(`writeSync is unreliable and will be removed soon.`),v=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,s.MINIMUM_COLS),t=Math.max(t,s.MINIMUM_ROWS),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t,n){this._bufferService.scrollLines(e,t,n)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend===`conpty`&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(m.updateWindowsModeWrappedState.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:`H`},(()=>((0,m.updateWindowsModeWrappedState)(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=(0,r.toDisposable)((()=>{for(let t of e)t.dispose()}))}}}t.CoreTerminal=y},8460:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.runAndSubscribe=t.forwardEvent=t.EventEmitter=void 0,t.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||=e=>(this._listeners.push(e),{dispose:()=>{if(!this._disposed){for(let t=0;t<this._listeners.length;t++)if(this._listeners[t]===e)return void this._listeners.splice(t,1)}}}),this._event}fire(e,t){let n=[];for(let e=0;e<this._listeners.length;e++)n.push(this._listeners[e]);for(let r=0;r<n.length;r++)n[r].call(void 0,e,t)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},t.forwardEvent=function(e,t){return e((e=>t.fire(e)))},t.runAndSubscribe=function(e,t){return t(void 0),e((e=>t(e)))}},5435:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,`__esModule`,{value:!0}),t.InputHandler=t.WindowsOptionsReportType=void 0;let a=n(2584),o=n(7116),s=n(2015),c=n(844),l=n(482),u=n(8437),d=n(8460),f=n(643),p=n(511),m=n(3734),h=n(2585),g=n(1480),_=n(6242),v=n(6351),y=n(5941),b={"(":0,")":1,"*":2,"+":3,"-":1,".":2},x=131072;function S(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var C;(function(e){e[e.GET_WIN_SIZE_PIXELS=0]=`GET_WIN_SIZE_PIXELS`,e[e.GET_CELL_SIZE_PIXELS=1]=`GET_CELL_SIZE_PIXELS`})(C||(t.WindowsOptionsReportType=C={}));let w=0;class T extends c.Disposable{getAttrData(){return this._curAttrData}constructor(e,t,n,r,i,c,f,m,h=new s.EscapeSequenceParser){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=r,this._optionsService=i,this._oscLinkService=c,this._coreMouseService=f,this._unicodeService=m,this._parser=h,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new l.StringToUtf32,this._utf8Decoder=new l.Utf8ToUtf32,this._workCell=new p.CellData,this._windowTitle=``,this._iconName=``,this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=u.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=u.DEFAULT_ATTR_DATA.clone(),this._onRequestBell=this.register(new d.EventEmitter),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this.register(new d.EventEmitter),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this.register(new d.EventEmitter),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this.register(new d.EventEmitter),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this.register(new d.EventEmitter),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this.register(new d.EventEmitter),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this.register(new d.EventEmitter),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this.register(new d.EventEmitter),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this.register(new d.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this.register(new d.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onScroll=this.register(new d.EventEmitter),this.onScroll=this._onScroll.event,this._onTitleChange=this.register(new d.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onColor=this.register(new d.EventEmitter),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this.register(this._parser),this._dirtyRowTracker=new E(this._bufferService),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((e=>this._activeBuffer=e.activeBuffer))),this._parser.setCsiHandlerFallback(((e,t)=>{this._logService.debug(`Unknown CSI code: `,{identifier:this._parser.identToString(e),params:t.toArray()})})),this._parser.setEscHandlerFallback((e=>{this._logService.debug(`Unknown ESC code: `,{identifier:this._parser.identToString(e)})})),this._parser.setExecuteHandlerFallback((e=>{this._logService.debug(`Unknown EXECUTE code: `,{code:e})})),this._parser.setOscHandlerFallback(((e,t,n)=>{this._logService.debug(`Unknown OSC code: `,{identifier:e,action:t,data:n})})),this._parser.setDcsHandlerFallback(((e,t,n)=>{t===`HOOK`&&(n=n.toArray()),this._logService.debug(`Unknown DCS code: `,{identifier:this._parser.identToString(e),action:t,payload:n})})),this._parser.setPrintHandler(((e,t,n)=>this.print(e,t,n))),this._parser.registerCsiHandler({final:`@`},(e=>this.insertChars(e))),this._parser.registerCsiHandler({intermediates:` `,final:`@`},(e=>this.scrollLeft(e))),this._parser.registerCsiHandler({final:`A`},(e=>this.cursorUp(e))),this._parser.registerCsiHandler({intermediates:` `,final:`A`},(e=>this.scrollRight(e))),this._parser.registerCsiHandler({final:`B`},(e=>this.cursorDown(e))),this._parser.registerCsiHandler({final:`C`},(e=>this.cursorForward(e))),this._parser.registerCsiHandler({final:`D`},(e=>this.cursorBackward(e))),this._parser.registerCsiHandler({final:`E`},(e=>this.cursorNextLine(e))),this._parser.registerCsiHandler({final:`F`},(e=>this.cursorPrecedingLine(e))),this._parser.registerCsiHandler({final:`G`},(e=>this.cursorCharAbsolute(e))),this._parser.registerCsiHandler({final:`H`},(e=>this.cursorPosition(e))),this._parser.registerCsiHandler({final:`I`},(e=>this.cursorForwardTab(e))),this._parser.registerCsiHandler({final:`J`},(e=>this.eraseInDisplay(e,!1))),this._parser.registerCsiHandler({prefix:`?`,final:`J`},(e=>this.eraseInDisplay(e,!0))),this._parser.registerCsiHandler({final:`K`},(e=>this.eraseInLine(e,!1))),this._parser.registerCsiHandler({prefix:`?`,final:`K`},(e=>this.eraseInLine(e,!0))),this._parser.registerCsiHandler({final:`L`},(e=>this.insertLines(e))),this._parser.registerCsiHandler({final:`M`},(e=>this.deleteLines(e))),this._parser.registerCsiHandler({final:`P`},(e=>this.deleteChars(e))),this._parser.registerCsiHandler({final:`S`},(e=>this.scrollUp(e))),this._parser.registerCsiHandler({final:`T`},(e=>this.scrollDown(e))),this._parser.registerCsiHandler({final:`X`},(e=>this.eraseChars(e))),this._parser.registerCsiHandler({final:`Z`},(e=>this.cursorBackwardTab(e))),this._parser.registerCsiHandler({final:"`"},(e=>this.charPosAbsolute(e))),this._parser.registerCsiHandler({final:`a`},(e=>this.hPositionRelative(e))),this._parser.registerCsiHandler({final:`b`},(e=>this.repeatPrecedingCharacter(e))),this._parser.registerCsiHandler({final:`c`},(e=>this.sendDeviceAttributesPrimary(e))),this._parser.registerCsiHandler({prefix:`>`,final:`c`},(e=>this.sendDeviceAttributesSecondary(e))),this._parser.registerCsiHandler({final:`d`},(e=>this.linePosAbsolute(e))),this._parser.registerCsiHandler({final:`e`},(e=>this.vPositionRelative(e))),this._parser.registerCsiHandler({final:`f`},(e=>this.hVPosition(e))),this._parser.registerCsiHandler({final:`g`},(e=>this.tabClear(e))),this._parser.registerCsiHandler({final:`h`},(e=>this.setMode(e))),this._parser.registerCsiHandler({prefix:`?`,final:`h`},(e=>this.setModePrivate(e))),this._parser.registerCsiHandler({final:`l`},(e=>this.resetMode(e))),this._parser.registerCsiHandler({prefix:`?`,final:`l`},(e=>this.resetModePrivate(e))),this._parser.registerCsiHandler({final:`m`},(e=>this.charAttributes(e))),this._parser.registerCsiHandler({final:`n`},(e=>this.deviceStatus(e))),this._parser.registerCsiHandler({prefix:`?`,final:`n`},(e=>this.deviceStatusPrivate(e))),this._parser.registerCsiHandler({intermediates:`!`,final:`p`},(e=>this.softReset(e))),this._parser.registerCsiHandler({intermediates:` `,final:`q`},(e=>this.setCursorStyle(e))),this._parser.registerCsiHandler({final:`r`},(e=>this.setScrollRegion(e))),this._parser.registerCsiHandler({final:`s`},(e=>this.saveCursor(e))),this._parser.registerCsiHandler({final:`t`},(e=>this.windowOptions(e))),this._parser.registerCsiHandler({final:`u`},(e=>this.restoreCursor(e))),this._parser.registerCsiHandler({intermediates:`'`,final:`}`},(e=>this.insertColumns(e))),this._parser.registerCsiHandler({intermediates:`'`,final:`~`},(e=>this.deleteColumns(e))),this._parser.registerCsiHandler({intermediates:`"`,final:`q`},(e=>this.selectProtected(e))),this._parser.registerCsiHandler({intermediates:`$`,final:`p`},(e=>this.requestMode(e,!0))),this._parser.registerCsiHandler({prefix:`?`,intermediates:`$`,final:`p`},(e=>this.requestMode(e,!1))),this._parser.setExecuteHandler(a.C0.BEL,(()=>this.bell())),this._parser.setExecuteHandler(a.C0.LF,(()=>this.lineFeed())),this._parser.setExecuteHandler(a.C0.VT,(()=>this.lineFeed())),this._parser.setExecuteHandler(a.C0.FF,(()=>this.lineFeed())),this._parser.setExecuteHandler(a.C0.CR,(()=>this.carriageReturn())),this._parser.setExecuteHandler(a.C0.BS,(()=>this.backspace())),this._parser.setExecuteHandler(a.C0.HT,(()=>this.tab())),this._parser.setExecuteHandler(a.C0.SO,(()=>this.shiftOut())),this._parser.setExecuteHandler(a.C0.SI,(()=>this.shiftIn())),this._parser.setExecuteHandler(a.C1.IND,(()=>this.index())),this._parser.setExecuteHandler(a.C1.NEL,(()=>this.nextLine())),this._parser.setExecuteHandler(a.C1.HTS,(()=>this.tabSet())),this._parser.registerOscHandler(0,new _.OscHandler((e=>(this.setTitle(e),this.setIconName(e),!0)))),this._parser.registerOscHandler(1,new _.OscHandler((e=>this.setIconName(e)))),this._parser.registerOscHandler(2,new _.OscHandler((e=>this.setTitle(e)))),this._parser.registerOscHandler(4,new _.OscHandler((e=>this.setOrReportIndexedColor(e)))),this._parser.registerOscHandler(8,new _.OscHandler((e=>this.setHyperlink(e)))),this._parser.registerOscHandler(10,new _.OscHandler((e=>this.setOrReportFgColor(e)))),this._parser.registerOscHandler(11,new _.OscHandler((e=>this.setOrReportBgColor(e)))),this._parser.registerOscHandler(12,new _.OscHandler((e=>this.setOrReportCursorColor(e)))),this._parser.registerOscHandler(104,new _.OscHandler((e=>this.restoreIndexedColor(e)))),this._parser.registerOscHandler(110,new _.OscHandler((e=>this.restoreFgColor(e)))),this._parser.registerOscHandler(111,new _.OscHandler((e=>this.restoreBgColor(e)))),this._parser.registerOscHandler(112,new _.OscHandler((e=>this.restoreCursorColor(e)))),this._parser.registerEscHandler({final:`7`},(()=>this.saveCursor())),this._parser.registerEscHandler({final:`8`},(()=>this.restoreCursor())),this._parser.registerEscHandler({final:`D`},(()=>this.index())),this._parser.registerEscHandler({final:`E`},(()=>this.nextLine())),this._parser.registerEscHandler({final:`H`},(()=>this.tabSet())),this._parser.registerEscHandler({final:`M`},(()=>this.reverseIndex())),this._parser.registerEscHandler({final:`=`},(()=>this.keypadApplicationMode())),this._parser.registerEscHandler({final:`>`},(()=>this.keypadNumericMode())),this._parser.registerEscHandler({final:`c`},(()=>this.fullReset())),this._parser.registerEscHandler({final:`n`},(()=>this.setgLevel(2))),this._parser.registerEscHandler({final:`o`},(()=>this.setgLevel(3))),this._parser.registerEscHandler({final:`|`},(()=>this.setgLevel(3))),this._parser.registerEscHandler({final:`}`},(()=>this.setgLevel(2))),this._parser.registerEscHandler({final:`~`},(()=>this.setgLevel(1))),this._parser.registerEscHandler({intermediates:`%`,final:`@`},(()=>this.selectDefaultCharset())),this._parser.registerEscHandler({intermediates:`%`,final:`G`},(()=>this.selectDefaultCharset()));for(let e in o.CHARSETS)this._parser.registerEscHandler({intermediates:`(`,final:e},(()=>this.selectCharset(`(`+e))),this._parser.registerEscHandler({intermediates:`)`,final:e},(()=>this.selectCharset(`)`+e))),this._parser.registerEscHandler({intermediates:`*`,final:e},(()=>this.selectCharset(`*`+e))),this._parser.registerEscHandler({intermediates:`+`,final:e},(()=>this.selectCharset(`+`+e))),this._parser.registerEscHandler({intermediates:`-`,final:e},(()=>this.selectCharset(`-`+e))),this._parser.registerEscHandler({intermediates:`.`,final:e},(()=>this.selectCharset(`.`+e))),this._parser.registerEscHandler({intermediates:`/`,final:e},(()=>this.selectCharset(`/`+e)));this._parser.registerEscHandler({intermediates:`#`,final:`8`},(()=>this.screenAlignmentPattern())),this._parser.setErrorHandler((e=>(this._logService.error(`Parsing error: `,e),e))),this._parser.registerDcsHandler({intermediates:`$`,final:`q`},new v.DcsHandler(((e,t)=>this.requestStatusString(e,t))))}_preserveStack(e,t,n,r){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=n,this._parseStack.position=r}_logSlowResolvingAsync(e){this._logService.logLevel<=h.LogLevelEnum.WARN&&Promise.race([e,new Promise(((e,t)=>setTimeout((()=>t(`#SLOW_TIMEOUT`)),5e3)))]).catch((e=>{if(e!==`#SLOW_TIMEOUT`)throw e;console.warn(`async parser handler taking longer than 5000 ms`)}))}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,r=this._activeBuffer.x,i=this._activeBuffer.y,a=0,o=this._parseStack.paused;if(o){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;r=this._parseStack.cursorStartX,i=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>x&&(a=this._parseStack.position+x)}if(this._logService.logLevel<=h.LogLevelEnum.DEBUG&&this._logService.debug(`parsing data`+(typeof e==`string`?` "${e}"`:` "${Array.prototype.map.call(e,(e=>String.fromCharCode(e))).join(``)}"`),typeof e==`string`?e.split(``).map((e=>e.charCodeAt(0))):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<x&&(this._parseBuffer=new Uint32Array(Math.min(e.length,x))),o||this._dirtyRowTracker.clearRange(),e.length>x)for(let t=a;t<e.length;t+=x){let a=t+x<e.length?t+x:e.length,o=typeof e==`string`?this._stringDecoder.decode(e.substring(t,a),this._parseBuffer):this._utf8Decoder.decode(e.subarray(t,a),this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,o))return this._preserveStack(r,i,o,t),this._logSlowResolvingAsync(n),n}else if(!o){let t=typeof e==`string`?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,t))return this._preserveStack(r,i,t,0),this._logSlowResolvingAsync(n),n}this._activeBuffer.x===r&&this._activeBuffer.y===i||this._onCursorMove.fire();let s=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),c=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);c<this._bufferService.rows&&this._onRequestRefreshRows.fire(Math.min(c,this._bufferService.rows-1),Math.min(s,this._bufferService.rows-1))}print(e,t,n){let r,i,a=this._charsetService.charset,o=this._optionsService.rawOptions.screenReaderMode,s=this._bufferService.cols,c=this._coreService.decPrivateModes.wraparound,d=this._coreService.modes.insertMode,p=this._curAttrData,m=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&n-t>0&&m.getWidth(this._activeBuffer.x-1)===2&&m.setCellFromCodepoint(this._activeBuffer.x-1,0,1,p);let h=this._parser.precedingJoinState;for(let _=t;_<n;++_){if(r=e[_],r<127&&a){let e=a[String.fromCharCode(r)];e&&(r=e.charCodeAt(0))}let t=this._unicodeService.charProperties(r,h);i=g.UnicodeService.extractWidth(t);let n=g.UnicodeService.extractShouldJoin(t),v=n?g.UnicodeService.extractWidth(h):0;if(h=t,o&&this._onA11yChar.fire((0,l.stringFromCodePoint)(r)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+i-v>s){if(c){let e=m,t=this._activeBuffer.x-v;for(this._activeBuffer.x=v,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),m=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),v>0&&m instanceof u.BufferLine&&m.copyCellsFrom(e,t,0,v,!1);t<s;)e.setCellFromCodepoint(t++,0,1,p)}else if(this._activeBuffer.x=s-1,i===2)continue}if(n&&this._activeBuffer.x){let e=m.getWidth(this._activeBuffer.x-1)?1:2;m.addCodepointToCell(this._activeBuffer.x-e,r,i);for(let e=i-v;--e>=0;)m.setCellFromCodepoint(this._activeBuffer.x++,0,0,p)}else if(d&&(m.insertCells(this._activeBuffer.x,i-v,this._activeBuffer.getNullCell(p)),m.getWidth(s-1)===2&&m.setCellFromCodepoint(s-1,f.NULL_CELL_CODE,f.NULL_CELL_WIDTH,p)),m.setCellFromCodepoint(this._activeBuffer.x++,r,i,p),i>0)for(;--i;)m.setCellFromCodepoint(this._activeBuffer.x++,0,0,p)}this._parser.precedingJoinState=h,this._activeBuffer.x<s&&n-t>0&&m.getWidth(this._activeBuffer.x)===0&&!m.hasContent(this._activeBuffer.x)&&m.setCellFromCodepoint(this._activeBuffer.x,0,1,p),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final!==`t`||e.prefix||e.intermediates?this._parser.registerCsiHandler(e,t):this._parser.registerCsiHandler(e,(e=>!S(e.params[0],this._optionsService.rawOptions.windowOptions)||t(e)))}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new v.DcsHandler(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new _.OscHandler(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),t!==2&&t!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,n,r=!1,i=!1){let a=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);a.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),i),r&&(a.isWrapped=!1)}_resetBufferLine(e,t=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),n.isWrapped=!1)}eraseInDisplay(e,t=!1){let n;switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);n<this._bufferService.rows;n++)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(n);break;case 1:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 2:for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 3:let e=this._activeBuffer.lines.length-this._bufferService.rows;e>0&&(this._activeBuffer.lines.trimStart(e),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-e,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-e,0),this._onScroll.fire(0))}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-r+1;for(;t--;)this._activeBuffer.lines.splice(i-1,1),this._activeBuffer.lines.splice(n,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r;for(r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-r;t--;)this._activeBuffer.lines.splice(n,1),this._activeBuffer.lines.splice(r,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(u.DEFAULT_ATTR_DATA));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let n=e.params[0]||1,r=g.UnicodeService.extractWidth(t),i=this._activeBuffer.x-r,a=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(i),o=new Uint32Array(a.length*n),s=0;for(let e=0;e<a.length;){let t=a.codePointAt(e)||0;o[s++]=t,e+=t>65535?2:1}let c=s;for(let e=1;e<n;++e)o.copyWithin(c,0,s),c+=s;return this.print(o,0,c),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is(`xterm`)||this._is(`rxvt-unicode`)||this._is(`screen`)?this._coreService.triggerDataEvent(a.C0.ESC+`[?1;2c`):this._is(`linux`)&&this._coreService.triggerDataEvent(a.C0.ESC+`[?6c`)),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is(`xterm`)?this._coreService.triggerDataEvent(a.C0.ESC+`[>0;276;0c`):this._is(`rxvt-unicode`)?this._coreService.triggerDataEvent(a.C0.ESC+`[>85;95;0c`):this._is(`linux`)?this._coreService.triggerDataEvent(e.params[0]+`c`):this._is(`screen`)&&this._coreService.triggerDataEvent(a.C0.ESC+`[>83;40003;0c`)),!0}_is(e){return(this._optionsService.rawOptions.termName+``).indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,o.DEFAULT_CHARSET),this._charsetService.setgCharset(1,o.DEFAULT_CHARSET),this._charsetService.setgCharset(2,o.DEFAULT_CHARSET),this._charsetService.setgCharset(3,o.DEFAULT_CHARSET);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug(`Serial port requested application keypad.`),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol=`X10`;break;case 1e3:this._coreMouseService.activeProtocol=`VT200`;break;case 1002:this._coreMouseService.activeProtocol=`DRAG`;break;case 1003:this._coreMouseService.activeProtocol=`ANY`;break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug(`DECSET 1005 not supported (see #2507)`);break;case 1006:this._coreMouseService.activeEncoding=`SGR`;break;case 1015:this._logService.debug(`DECSET 1015 not supported (see #2507)`);break;case 1016:this._coreMouseService.activeEncoding=`SGR_PIXELS`;break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug(`Switching back to normal keypad.`),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol=`NONE`;break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug(`DECRST 1005 not supported (see #2507)`);break;case 1006:case 1016:this._coreMouseService.activeEncoding=`DEFAULT`;break;case 1015:this._logService.debug(`DECRST 1015 not supported (see #2507)`);break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1}return!0}requestMode(e,t){let n=this._coreService.decPrivateModes,{activeProtocol:r,activeEncoding:i}=this._coreMouseService,o=this._coreService,{buffers:s,cols:c}=this._bufferService,{active:l,alt:u}=s,d=this._optionsService.rawOptions,f=e=>e?1:2,p=e.params[0];return m=p,h=t?p===2?4:p===4?f(o.modes.insertMode):p===12?3:p===20?f(d.convertEol):0:p===1?f(n.applicationCursorKeys):p===3?d.windowOptions.setWinLines?c===80?2:+(c===132):0:p===6?f(n.origin):p===7?f(n.wraparound):p===8?3:p===9?f(r===`X10`):p===12?f(d.cursorBlink):p===25?f(!o.isCursorHidden):p===45?f(n.reverseWraparound):p===66?f(n.applicationKeypad):p===67?4:p===1e3?f(r===`VT200`):p===1002?f(r===`DRAG`):p===1003?f(r===`ANY`):p===1004?f(n.sendFocus):p===1005?4:p===1006?f(i===`SGR`):p===1015?4:p===1016?f(i===`SGR_PIXELS`):p===1048?1:p===47||p===1047||p===1049?f(l===u):p===2004?f(n.bracketedPasteMode):0,o.triggerDataEvent(`${a.C0.ESC}[${t?``:`?`}${m};${h}$y`),!0;var m,h}_updateAttrColor(e,t,n,r,i){return t===2?(e|=50331648,e&=-16777216,e|=m.AttributeData.fromColorRGB([n,r,i])):t===5&&(e&=-50331904,e|=33554432|255&n),e}_extractColor(e,t,n){let r=[0,0,-1,0,0,0],i=0,a=0;do{if(r[a+i]=e.params[t+a],e.hasSubParams(t+a)){let n=e.getSubParams(t+a),o=0;do r[1]===5&&(i=1),r[a+o+1+i]=n[o];while(++o<n.length&&o+a+1+i<r.length);break}if(r[1]===5&&a+i>=2||r[1]===2&&a+i>=5)break;r[1]&&(i=1)}while(++a+t<e.length&&a+i<r.length);for(let e=2;e<r.length;++e)r[e]===-1&&(r[e]=0);switch(r[0]){case 38:n.fg=this._updateAttrColor(n.fg,r[1],r[3],r[4],r[5]);break;case 48:n.bg=this._updateAttrColor(n.bg,r[1],r[3],r[4],r[5]);break;case 58:n.extended=n.extended.clone(),n.extended.underlineColor=this._updateAttrColor(n.extended.underlineColor,r[1],r[3],r[4],r[5])}return a}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=u.DEFAULT_ATTR_DATA.fg,e.bg=u.DEFAULT_ATTR_DATA.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,n,r=this._curAttrData;for(let i=0;i<t;i++)n=e.params[i],n>=30&&n<=37?(r.fg&=-50331904,r.fg|=16777216|n-30):n>=40&&n<=47?(r.bg&=-50331904,r.bg|=16777216|n-40):n>=90&&n<=97?(r.fg&=-50331904,r.fg|=16777224|n-90):n>=100&&n<=107?(r.bg&=-50331904,r.bg|=16777224|n-100):n===0?this._processSGR0(r):n===1?r.fg|=134217728:n===3?r.bg|=67108864:n===4?(r.fg|=268435456,this._processUnderline(e.hasSubParams(i)?e.getSubParams(i)[0]:1,r)):n===5?r.fg|=536870912:n===7?r.fg|=67108864:n===8?r.fg|=1073741824:n===9?r.fg|=2147483648:n===2?r.bg|=134217728:n===21?this._processUnderline(2,r):n===22?(r.fg&=-134217729,r.bg&=-134217729):n===23?r.bg&=-67108865:n===24?(r.fg&=-268435457,this._processUnderline(0,r)):n===25?r.fg&=-536870913:n===27?r.fg&=-67108865:n===28?r.fg&=-1073741825:n===29?r.fg&=2147483647:n===39?(r.fg&=-67108864,r.fg|=16777215&u.DEFAULT_ATTR_DATA.fg):n===49?(r.bg&=-67108864,r.bg|=16777215&u.DEFAULT_ATTR_DATA.bg):n===38||n===48||n===58?i+=this._extractColor(e,i,r):n===53?r.bg|=1073741824:n===55?r.bg&=-1073741825:n===59?(r.extended=r.extended.clone(),r.extended.underlineColor=-1,r.updateExtended()):n===100?(r.fg&=-67108864,r.fg|=16777215&u.DEFAULT_ATTR_DATA.fg,r.bg&=-67108864,r.bg|=16777215&u.DEFAULT_ATTR_DATA.bg):this._logService.debug(`Unknown SGR attribute: %d.`,n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${a.C0.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${a.C0.ESC}[${e};${t}R`)}return!0}deviceStatusPrivate(e){if(e.params[0]===6){let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${a.C0.ESC}[?${e};${t}R`)}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=u.DEFAULT_ATTR_DATA.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.params[0]||1;switch(t){case 1:case 2:this._optionsService.options.cursorStyle=`block`;break;case 3:case 4:this._optionsService.options.cursorStyle=`underline`;break;case 5:case 6:this._optionsService.options.cursorStyle=`bar`}let n=t%2==1;return this._optionsService.options.cursorBlink=n,!0}setScrollRegion(e){let t=e.params[0]||1,n;return(e.length<2||(n=e.params[1])>this._bufferService.rows||n===0)&&(n=this._bufferService.rows),n>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(e){if(!S(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(C.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(C.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${a.C0.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:t!==0&&t!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),t!==0&&t!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:t!==0&&t!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),t!==0&&t!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],n=e.split(`;`);for(;n.length>1;){let e=n.shift(),r=n.shift();if(/^\d+$/.exec(e)){let n=parseInt(e);if(D(n))if(r===`?`)t.push({type:0,index:n});else{let e=(0,y.parseColor)(r);e&&t.push({type:1,index:n,color:e})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.split(`;`);return!(t.length<2)&&(t[1]?this._createHyperlink(t[0],t[1]):!t[0]&&this._finishHyperlink())}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(`:`),r,i=n.findIndex((e=>e.startsWith(`id=`)));return i!==-1&&(r=n[i].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:r,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let n=e.split(`;`);for(let e=0;e<n.length&&!(t>=this._specialColors.length);++e,++t)if(n[e]===`?`)this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let r=(0,y.parseColor)(n[e]);r&&this._onColor.fire([{type:1,index:this._specialColors[t],color:r}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],n=e.split(`;`);for(let e=0;e<n.length;++e)if(/^\d+$/.exec(n[e])){let r=parseInt(n[e]);D(r)&&t.push({type:2,index:r})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug(`Serial port requested application keypad.`),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug(`Switching back to normal keypad.`),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,o.DEFAULT_CHARSET),!0}selectCharset(e){return e.length===2?(e[0]===`/`||this._charsetService.setgCharset(b[e[0]],o.CHARSETS[e[1]]||o.DEFAULT_CHARSET),!0):(this.selectDefaultCharset(),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=u.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=u.DEFAULT_ATTR_DATA.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new p.CellData;e.content=4194373,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let n=this._activeBuffer.ybase+this._activeBuffer.y+t,r=this._activeBuffer.lines.get(n);r&&(r.fill(e),r.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let n=this._bufferService.buffer,r=this._optionsService.rawOptions;return(e=>(this._coreService.triggerDataEvent(`${a.C0.ESC}${e}${a.C0.ESC}\\`),!0))(e===`"q`?`P1$r${+!!this._curAttrData.isProtected()}"q`:e===`"p`?`P1$r61;1"p`:e===`r`?`P1$r${n.scrollTop+1};${n.scrollBottom+1}r`:e===`m`?`P1$r0m`:e===` q`?`P1$r${{block:2,underline:4,bar:6}[r.cursorStyle]-+!!r.cursorBlink} q`:`P0$r`)}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}}t.InputHandler=T;let E=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(w=e,e=t,t=w),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function D(e){return 0<=e&&e<256}E=r([i(0,h.IBufferService)],E)},844:(e,t)=>{function n(e){for(let t of e)t.dispose();e.length=0}Object.defineProperty(t,`__esModule`,{value:!0}),t.getDisposeArrayDisposable=t.disposeArray=t.toDisposable=t.MutableDisposable=t.Disposable=void 0,t.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(let e of this._disposables)e.dispose();this._disposables.length=0}register(e){return this._disposables.push(e),e}unregister(e){let t=this._disposables.indexOf(e);t!==-1&&this._disposables.splice(t,1)}},t.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}},t.toDisposable=function(e){return{dispose:e}},t.disposeArray=n,t.getDisposeArrayDisposable=function(e){return{dispose:()=>n(e)}}},1505:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.FourKeyMap=t.TwoKeyMap=void 0;class n{constructor(){this._data={}}set(e,t,n){this._data[e]||(this._data[e]={}),this._data[e][t]=n}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}}t.TwoKeyMap=n,t.FourKeyMap=class{constructor(){this._data=new n}set(e,t,r,i,a){this._data.get(e,t)||this._data.set(e,t,new n),this._data.get(e,t).set(r,i,a)}get(e,t,n,r){return this._data.get(e,t)?.get(n,r)}clear(){this._data.clear()}}},6114:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.isChromeOS=t.isLinux=t.isWindows=t.isIphone=t.isIpad=t.isMac=t.getSafariVersion=t.isSafari=t.isLegacyEdge=t.isFirefox=t.isNode=void 0,t.isNode=typeof process<`u`&&`title`in process;let n=t.isNode?`node`:navigator.userAgent,r=t.isNode?`node`:navigator.platform;t.isFirefox=n.includes(`Firefox`),t.isLegacyEdge=n.includes(`Edge`),t.isSafari=/^((?!chrome|android).)*safari/i.test(n),t.getSafariVersion=function(){if(!t.isSafari)return 0;let e=n.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])},t.isMac=[`Macintosh`,`MacIntel`,`MacPPC`,`Mac68K`].includes(r),t.isIpad=r===`iPad`,t.isIphone=r===`iPhone`,t.isWindows=[`Windows`,`Win16`,`Win32`,`WinCE`].includes(r),t.isLinux=r.indexOf(`Linux`)>=0,t.isChromeOS=/\bCrOS\b/.test(n)},6106:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.SortedList=void 0;let n=0;t.SortedList=class{constructor(e){this._getKey=e,this._array=[]}clear(){this._array.length=0}insert(e){this._array.length===0?this._array.push(e):(n=this._search(this._getKey(e)),this._array.splice(n,0,e))}delete(e){if(this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(n=this._search(t),n===-1)||this._getKey(this._array[n])!==t)return!1;do if(this._array[n]===e)return this._array.splice(n,1),!0;while(++n<this._array.length&&this._getKey(this._array[n])===t);return!1}*getKeyIterator(e){if(this._array.length!==0&&(n=this._search(e),!(n<0||n>=this._array.length)&&this._getKey(this._array[n])===e))do yield this._array[n];while(++n<this._array.length&&this._getKey(this._array[n])===e)}forEachByKey(e,t){if(this._array.length!==0&&(n=this._search(e),!(n<0||n>=this._array.length)&&this._getKey(this._array[n])===e))do t(this._array[n]);while(++n<this._array.length&&this._getKey(this._array[n])===e)}values(){return[...this._array].values()}_search(e){let t=0,n=this._array.length-1;for(;n>=t;){let r=t+n>>1,i=this._getKey(this._array[r]);if(i>e)n=r-1;else{if(!(i<e)){for(;r>0&&this._getKey(this._array[r-1])===e;)r--;return r}t=r+1}}return t}}},7226:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.DebouncedIdleTask=t.IdleTaskQueue=t.PriorityTaskQueue=void 0;let r=n(6114);class i{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&=(this._cancelCallback(this._idleCallback),void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||=this._requestCallback(this._process.bind(this))}_process(e){this._idleCallback=void 0;let t=0,n=0,r=e.timeRemaining(),i=0;for(;this._i<this._tasks.length;){if(t=Date.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,Date.now()-t),n=Math.max(t,n),i=e.timeRemaining(),1.5*n>i)return r-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-t))}ms`),void this._start();r=i}this.clear()}}class a extends i{_requestCallback(e){return setTimeout((()=>e(this._createDeadline(16))))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=Date.now()+e;return{timeRemaining:()=>Math.max(0,t-Date.now())}}}t.PriorityTaskQueue=a,t.IdleTaskQueue=!r.isNode&&`requestIdleCallback`in window?class extends i{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}}:a,t.DebouncedIdleTask=class{constructor(){this._queue=new t.IdleTaskQueue}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}}},9282:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.updateWindowsModeWrappedState=void 0;let r=n(643);t.updateWindowsModeWrappedState=function(e){let t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&t&&(n.isWrapped=t[r.CHAR_DATA_CODE_INDEX]!==r.NULL_CELL_CODE&&t[r.CHAR_DATA_CODE_INDEX]!==r.WHITESPACE_CELL_CODE)}},3734:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.ExtendedAttrs=t.AttributeData=void 0;class n{constructor(){this.fg=0,this.bg=0,this.extended=new r}static toColorRGB(e){return[e>>>16&255,e>>>8&255,255&e]}static fromColorRGB(e){return(255&e[0])<<16|(255&e[1])<<8|255&e[2]}clone(){let e=new n;return e.fg=this.fg,e.bg=this.bg,e.extended=this.extended.clone(),e}isInverse(){return 67108864&this.fg}isBold(){return 134217728&this.fg}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:268435456&this.fg}isBlink(){return 536870912&this.fg}isInvisible(){return 1073741824&this.fg}isItalic(){return 67108864&this.bg}isDim(){return 134217728&this.bg}isStrikethrough(){return 2147483648&this.fg}isProtected(){return 536870912&this.bg}isOverline(){return 1073741824&this.bg}getFgColorMode(){return 50331648&this.fg}getBgColorMode(){return 50331648&this.bg}isFgRGB(){return(50331648&this.fg)==50331648}isBgRGB(){return(50331648&this.bg)==50331648}isFgPalette(){return(50331648&this.fg)==16777216||(50331648&this.fg)==33554432}isBgPalette(){return(50331648&this.bg)==16777216||(50331648&this.bg)==33554432}isFgDefault(){return(50331648&this.fg)==0}isBgDefault(){return(50331648&this.bg)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}}getBgColor(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}}hasExtendedAttrs(){return 268435456&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(268435456&this.bg&&~this.extended.underlineColor)switch(50331648&this.extended.underlineColor){case 16777216:case 33554432:return 255&this.extended.underlineColor;case 50331648:return 16777215&this.extended.underlineColor;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return 268435456&this.bg&&~this.extended.underlineColor?50331648&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==16777216||(50331648&this.extended.underlineColor)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==0:this.isFgDefault()}getUnderlineStyle(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}}t.AttributeData=n;class r{get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(e){this._ext&=-67108864,this._ext|=67108863&e}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(3758096384&this._ext)>>29;return e<0?4294967288^e:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}clone(){return new r(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}t.ExtendedAttrs=r},9092:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.Buffer=t.MAX_BUFFER_SIZE=void 0;let r=n(6349),i=n(7226),a=n(3734),o=n(8437),s=n(4634),c=n(511),l=n(643),u=n(4863),d=n(7116);t.MAX_BUFFER_SIZE=4294967295,t.Buffer=class{constructor(e,t,n){this._hasScrollback=e,this._optionsService=t,this._bufferService=n,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=o.DEFAULT_ATTR_DATA.clone(),this.savedCharset=d.DEFAULT_CHARSET,this.markers=[],this._nullCell=c.CellData.fromCharData([0,l.NULL_CELL_CHAR,l.NULL_CELL_WIDTH,l.NULL_CELL_CODE]),this._whitespaceCell=c.CellData.fromCharData([0,l.WHITESPACE_CELL_CHAR,l.WHITESPACE_CELL_WIDTH,l.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new i.IdleTaskQueue,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new r.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new a.ExtendedAttrs),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new a.ExtendedAttrs),this._whitespaceCell}getBlankLine(e,t){return new o.BufferLine(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let n=e+this._optionsService.rawOptions.scrollback;return n>t.MAX_BUFFER_SIZE?t.MAX_BUFFER_SIZE:n}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=o.DEFAULT_ATTR_DATA);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new r.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(o.DEFAULT_ATTR_DATA),r=0,i=this._getCorrectBufferLength(t);if(i>this.lines.maxLength&&(this.lines.maxLength=i),this.lines.length>0){if(this._cols<e)for(let t=0;t<this.lines.length;t++)r+=+this.lines.get(t).resize(e,n);let a=0;if(this._rows<t)for(let r=this._rows;r<t;r++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new o.BufferLine(e,n)):this.ybase>0&&this.lines.length<=this.ybase+this.y+a+1?(this.ybase--,a++,this.ydisp>0&&this.ydisp--):this.lines.push(new o.BufferLine(e,n)));else for(let e=this._rows;e>t;e--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(i<this.lines.maxLength){let e=this.lines.length-i;e>0&&(this.lines.trimStart(e),this.ybase=Math.max(this.ybase-e,0),this.ydisp=Math.max(this.ydisp-e,0),this.savedY=Math.max(this.savedY-e,0)),this.lines.maxLength=i}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),a&&(this.y+=a),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let t=0;t<this.lines.length;t++)r+=+this.lines.get(t).resize(e,n);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),r>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue((()=>this._batchedMemoryCleanup())))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend===`conpty`&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let n=(0,s.reflowLargerGetLinesToRemove)(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(o.DEFAULT_ATTR_DATA));if(n.length>0){let r=(0,s.reflowLargerCreateNewLayout)(this.lines,n);(0,s.reflowLargerApplyNewLayout)(this.lines,r.layout),this._reflowLargerAdjustViewport(e,t,r.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let r=this.getNullCell(o.DEFAULT_ATTR_DATA),i=n;for(;i-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new o.BufferLine(e,r))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-n,0)}_reflowSmaller(e,t){let n=this.getNullCell(o.DEFAULT_ATTR_DATA),r=[],i=0;for(let a=this.lines.length-1;a>=0;a--){let c=this.lines.get(a);if(!c||!c.isWrapped&&c.getTrimmedLength()<=e)continue;let l=[c];for(;c.isWrapped&&a>0;)c=this.lines.get(--a),l.unshift(c);let u=this.ybase+this.y;if(u>=a&&u<a+l.length)continue;let d=l[l.length-1].getTrimmedLength(),f=(0,s.reflowSmallerGetNewLineLengths)(l,this._cols,e),p=f.length-l.length,m;m=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+p):Math.max(0,this.lines.length-this.lines.maxLength+p);let h=[];for(let e=0;e<p;e++){let e=this.getBlankLine(o.DEFAULT_ATTR_DATA,!0);h.push(e)}h.length>0&&(r.push({start:a+l.length+i,newLines:h}),i+=h.length),l.push(...h);let g=f.length-1,_=f[g];_===0&&(g--,_=f[g]);let v=l.length-p-1,y=d;for(;v>=0;){let e=Math.min(y,_);if(l[g]===void 0)break;if(l[g].copyCellsFrom(l[v],y-e,_-e,e,!0),_-=e,_===0&&(g--,_=f[g]),y-=e,y===0){v--;let e=Math.max(v,0);y=(0,s.getWrappedLineTrimmedLength)(l,e,this._cols)}}for(let t=0;t<l.length;t++)f[t]<e&&l[t].setCell(f[t],n);let b=p-m;for(;b-- >0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+i)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+p,this.ybase+t-1)}if(r.length>0){let e=[],t=[];for(let e=0;e<this.lines.length;e++)t.push(this.lines.get(e));let n=this.lines.length,a=n-1,o=0,s=r[o];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+i);let c=0;for(let l=Math.min(this.lines.maxLength-1,n+i-1);l>=0;l--)if(s&&s.start>a+c){for(let e=s.newLines.length-1;e>=0;e--)this.lines.set(l--,s.newLines[e]);l++,e.push({index:a+1,amount:s.newLines.length}),c+=s.newLines.length,s=r[++o]}else this.lines.set(l,t[a--]);let l=0;for(let t=e.length-1;t>=0;t--)e[t].index+=l,this.lines.onInsertEmitter.fire(e[t]),l+=e[t].amount;let u=Math.max(0,n+i-this.lines.maxLength);u>0&&this.lines.onTrimEmitter.fire(u)}}translateBufferLineToString(e,t,n=0,r){let i=this.lines.get(e);return i?i.translateToString(t,n,r):``}getWrappedRangeForLine(e){let t=e,n=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;n+1<this.lines.length&&this.lines.get(n+1).isWrapped;)n++;return{first:t,last:n}}setupTabStops(e){for(e==null?(this.tabs={},e=0):this.tabs[e]||(e=this.prevStop(e));e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e??=this.x;!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e??=this.x;!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose(),this.markers.splice(e--,1);this._isClearing=!1}addMarker(e){let t=new u.Marker(e);return this.markers.push(t),t.register(this.lines.onTrim((e=>{t.line-=e,t.line<0&&t.dispose()}))),t.register(this.lines.onInsert((e=>{t.line>=e.index&&(t.line+=e.amount)}))),t.register(this.lines.onDelete((e=>{t.line>=e.index&&t.line<e.index+e.amount&&t.dispose(),t.line>e.index&&(t.line-=e.amount)}))),t.register(t.onDispose((()=>this._removeMarker(t)))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}}},8437:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.BufferLine=t.DEFAULT_ATTR_DATA=void 0;let r=n(3734),i=n(511),a=n(643),o=n(482);t.DEFAULT_ATTR_DATA=Object.freeze(new r.AttributeData);let s=0;class c{constructor(e,t,n=!1){this.isWrapped=n,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*e);let r=t||i.CellData.fromCharData([0,a.NULL_CELL_CHAR,a.NULL_CELL_WIDTH,a.NULL_CELL_CODE]);for(let t=0;t<e;++t)this.setCell(t,r);this.length=e}get(e){let t=this._data[3*e+0],n=2097151&t;return[this._data[3*e+1],2097152&t?this._combined[e]:n?(0,o.stringFromCodePoint)(n):``,t>>22,2097152&t?this._combined[e].charCodeAt(this._combined[e].length-1):n]}set(e,t){this._data[3*e+1]=t[a.CHAR_DATA_ATTR_INDEX],t[a.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[e]=t[1],this._data[3*e+0]=2097152|e|t[a.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*e+0]=t[a.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|t[a.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(e){return this._data[3*e+0]>>22}hasWidth(e){return 12582912&this._data[3*e+0]}getFg(e){return this._data[3*e+1]}getBg(e){return this._data[3*e+2]}hasContent(e){return 4194303&this._data[3*e+0]}getCodePoint(e){let t=this._data[3*e+0];return 2097152&t?this._combined[e].charCodeAt(this._combined[e].length-1):2097151&t}isCombined(e){return 2097152&this._data[3*e+0]}getString(e){let t=this._data[3*e+0];return 2097152&t?this._combined[e]:2097151&t?(0,o.stringFromCodePoint)(2097151&t):``}isProtected(e){return 536870912&this._data[3*e+2]}loadCell(e,t){return s=3*e,t.content=this._data[s+0],t.fg=this._data[s+1],t.bg=this._data[s+2],2097152&t.content&&(t.combinedData=this._combined[e]),268435456&t.bg&&(t.extended=this._extendedAttrs[e]),t}setCell(e,t){2097152&t.content&&(this._combined[e]=t.combinedData),268435456&t.bg&&(this._extendedAttrs[e]=t.extended),this._data[3*e+0]=t.content,this._data[3*e+1]=t.fg,this._data[3*e+2]=t.bg}setCellFromCodepoint(e,t,n,r){268435456&r.bg&&(this._extendedAttrs[e]=r.extended),this._data[3*e+0]=t|n<<22,this._data[3*e+1]=r.fg,this._data[3*e+2]=r.bg}addCodepointToCell(e,t,n){let r=this._data[3*e+0];2097152&r?this._combined[e]+=(0,o.stringFromCodePoint)(t):2097151&r?(this._combined[e]=(0,o.stringFromCodePoint)(2097151&r)+(0,o.stringFromCodePoint)(t),r&=-2097152,r|=2097152):r=t|1<<22,n&&(r&=-12582913,r|=n<<22),this._data[3*e+0]=r}insertCells(e,t,n){if((e%=this.length)&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length-e){let r=new i.CellData;for(let n=this.length-e-t-1;n>=0;--n)this.setCell(e+t+n,this.loadCell(e+n,r));for(let r=0;r<t;++r)this.setCell(e+r,n)}else for(let t=e;t<this.length;++t)this.setCell(t,n);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,n)}deleteCells(e,t,n){if(e%=this.length,t<this.length-e){let r=new i.CellData;for(let n=0;n<this.length-e-t;++n)this.setCell(e+n,this.loadCell(e+t+n,r));for(let e=this.length-t;e<this.length;++e)this.setCell(e,n)}else for(let t=e;t<this.length;++t)this.setCell(t,n);e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),this.getWidth(e)!==0||this.hasContent(e)||this.setCellFromCodepoint(e,0,1,n)}replaceCells(e,t,n,r=!1){if(r)for(e&&this.getWidth(e-1)===2&&!this.isProtected(e-1)&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length&&this.getWidth(t-1)===2&&!this.isProtected(t)&&this.setCellFromCodepoint(t,0,1,n);e<t&&e<this.length;)this.isProtected(e)||this.setCell(e,n),e++;else for(e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t,0,1,n);e<t&&e<this.length;)this.setCell(e++,n)}resize(e,t){if(e===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;let n=3*e;if(e>this.length){if(this._data.buffer.byteLength>=4*n)this._data=new Uint32Array(this._data.buffer,0,n);else{let e=new Uint32Array(n);e.set(this._data),this._data=e}for(let n=this.length;n<e;++n)this.setCell(n,t)}else{this._data=this._data.subarray(0,n);let t=Object.keys(this._combined);for(let n=0;n<t.length;n++){let r=parseInt(t[n],10);r>=e&&delete this._combined[r]}let r=Object.keys(this._extendedAttrs);for(let t=0;t<r.length;t++){let n=parseInt(r[t],10);n>=e&&delete this._extendedAttrs[n]}}return this.length=e,4*n*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){let e=new Uint32Array(this._data.length);return e.set(this._data),this._data=e,1}return 0}fill(e,t=!1){if(t)for(let t=0;t<this.length;++t)this.isProtected(t)||this.setCell(t,e);else{this._combined={},this._extendedAttrs={};for(let t=0;t<this.length;++t)this.setCell(t,e)}}copyFrom(e){this.length===e.length?this._data.set(e._data):this._data=new Uint32Array(e._data),this.length=e.length,this._combined={};for(let t in e._combined)this._combined[t]=e._combined[t];this._extendedAttrs={};for(let t in e._extendedAttrs)this._extendedAttrs[t]=e._extendedAttrs[t];this.isWrapped=e.isWrapped}clone(){let e=new c(0);e._data=new Uint32Array(this._data),e.length=this.length;for(let t in this._combined)e._combined[t]=this._combined[t];for(let t in this._extendedAttrs)e._extendedAttrs[t]=this._extendedAttrs[t];return e.isWrapped=this.isWrapped,e}getTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(4194303&this._data[3*e+0])return e+(this._data[3*e+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(4194303&this._data[3*e+0]||50331648&this._data[3*e+2])return e+(this._data[3*e+0]>>22);return 0}copyCellsFrom(e,t,n,r,i){let a=e._data;if(i)for(let i=r-1;i>=0;i--){for(let e=0;e<3;e++)this._data[3*(n+i)+e]=a[3*(t+i)+e];268435456&a[3*(t+i)+2]&&(this._extendedAttrs[n+i]=e._extendedAttrs[t+i])}else for(let i=0;i<r;i++){for(let e=0;e<3;e++)this._data[3*(n+i)+e]=a[3*(t+i)+e];268435456&a[3*(t+i)+2]&&(this._extendedAttrs[n+i]=e._extendedAttrs[t+i])}let o=Object.keys(e._combined);for(let r=0;r<o.length;r++){let i=parseInt(o[r],10);i>=t&&(this._combined[i-t+n]=e._combined[i])}}translateToString(e,t,n,r){t??=0,n??=this.length,e&&(n=Math.min(n,this.getTrimmedLength())),r&&(r.length=0);let i=``;for(;t<n;){let e=this._data[3*t+0],n=2097151&e,s=2097152&e?this._combined[t]:n?(0,o.stringFromCodePoint)(n):a.WHITESPACE_CELL_CHAR;if(i+=s,r)for(let e=0;e<s.length;++e)r.push(t);t+=e>>22||1}return r&&r.push(t),i}}t.BufferLine=c},4841:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.getRangeLength=void 0,t.getRangeLength=function(e,t){if(e.start.y>e.end.y)throw Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}},4634:(e,t)=>{function n(e,t,n){if(t===e.length-1)return e[t].getTrimmedLength();let r=!e[t].hasContent(n-1)&&e[t].getWidth(n-1)===1,i=e[t+1].getWidth(0)===2;return r&&i?n-1:n}Object.defineProperty(t,`__esModule`,{value:!0}),t.getWrappedLineTrimmedLength=t.reflowSmallerGetNewLineLengths=t.reflowLargerApplyNewLayout=t.reflowLargerCreateNewLayout=t.reflowLargerGetLinesToRemove=void 0,t.reflowLargerGetLinesToRemove=function(e,t,r,i,a){let o=[];for(let s=0;s<e.length-1;s++){let c=s,l=e.get(++c);if(!l.isWrapped)continue;let u=[e.get(s)];for(;c<e.length&&l.isWrapped;)u.push(l),l=e.get(++c);if(i>=s&&i<c){s+=u.length-1;continue}let d=0,f=n(u,d,t),p=1,m=0;for(;p<u.length;){let e=n(u,p,t),i=e-m,o=r-f,s=Math.min(i,o);u[d].copyCellsFrom(u[p],m,f,s,!1),f+=s,f===r&&(d++,f=0),m+=s,m===e&&(p++,m=0),f===0&&d!==0&&u[d-1].getWidth(r-1)===2&&(u[d].copyCellsFrom(u[d-1],r-1,f++,1,!1),u[d-1].setCell(r-1,a))}u[d].replaceCells(f,r,a);let h=0;for(let e=u.length-1;e>0&&(e>d||u[e].getTrimmedLength()===0);e--)h++;h>0&&(o.push(s+u.length-h),o.push(h)),s+=u.length-1}return o},t.reflowLargerCreateNewLayout=function(e,t){let n=[],r=0,i=t[r],a=0;for(let o=0;o<e.length;o++)if(i===o){let n=t[++r];e.onDeleteEmitter.fire({index:o-a,amount:n}),o+=n-1,a+=n,i=t[++r]}else n.push(o);return{layout:n,countRemoved:a}},t.reflowLargerApplyNewLayout=function(e,t){let n=[];for(let r=0;r<t.length;r++)n.push(e.get(t[r]));for(let t=0;t<n.length;t++)e.set(t,n[t]);e.length=t.length},t.reflowSmallerGetNewLineLengths=function(e,t,r){let i=[],a=e.map(((r,i)=>n(e,i,t))).reduce(((e,t)=>e+t)),o=0,s=0,c=0;for(;c<a;){if(a-c<r){i.push(a-c);break}o+=r;let l=n(e,s,t);o>l&&(o-=l,s++);let u=e[s].getWidth(o-1)===2;u&&o--;let d=u?r-1:r;i.push(d),c+=d}return i},t.getWrappedLineTrimmedLength=n},5295:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.BufferSet=void 0;let r=n(8460),i=n(844),a=n(9092);class o extends i.Disposable{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this.register(new r.EventEmitter),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this.register(this._optionsService.onSpecificOptionChange(`scrollback`,(()=>this.resize(this._bufferService.cols,this._bufferService.rows)))),this.register(this._optionsService.onSpecificOptionChange(`tabStopWidth`,(()=>this.setupTabStops())))}reset(){this._normal=new a.Buffer(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new a.Buffer(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}}t.BufferSet=o},511:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.CellData=void 0;let r=n(482),i=n(643),a=n(3734);class o extends a.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new a.ExtendedAttrs,this.combinedData=``}static fromCharData(e){let t=new o;return t.setFromCharData(e),t}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,r.stringFromCodePoint)(2097151&this.content):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(e){this.fg=e[i.CHAR_DATA_ATTR_INDEX],this.bg=0;let t=!1;if(e[i.CHAR_DATA_CHAR_INDEX].length>2)t=!0;else if(e[i.CHAR_DATA_CHAR_INDEX].length===2){let n=e[i.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[i.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=r&&r<=57343?this.content=1024*(n-55296)+r-56320+65536|e[i.CHAR_DATA_WIDTH_INDEX]<<22:t=!0}else t=!0}else this.content=e[i.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|e[i.CHAR_DATA_WIDTH_INDEX]<<22;t&&(this.combinedData=e[i.CHAR_DATA_CHAR_INDEX],this.content=2097152|e[i.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}t.CellData=o},643:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.WHITESPACE_CELL_CODE=t.WHITESPACE_CELL_WIDTH=t.WHITESPACE_CELL_CHAR=t.NULL_CELL_CODE=t.NULL_CELL_WIDTH=t.NULL_CELL_CHAR=t.CHAR_DATA_CODE_INDEX=t.CHAR_DATA_WIDTH_INDEX=t.CHAR_DATA_CHAR_INDEX=t.CHAR_DATA_ATTR_INDEX=t.DEFAULT_EXT=t.DEFAULT_ATTR=t.DEFAULT_COLOR=void 0,t.DEFAULT_COLOR=0,t.DEFAULT_ATTR=256|t.DEFAULT_COLOR<<9,t.DEFAULT_EXT=0,t.CHAR_DATA_ATTR_INDEX=0,t.CHAR_DATA_CHAR_INDEX=1,t.CHAR_DATA_WIDTH_INDEX=2,t.CHAR_DATA_CODE_INDEX=3,t.NULL_CELL_CHAR=``,t.NULL_CELL_WIDTH=1,t.NULL_CELL_CODE=0,t.WHITESPACE_CELL_CHAR=` `,t.WHITESPACE_CELL_WIDTH=1,t.WHITESPACE_CELL_CODE=32},4863:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.Marker=void 0;let r=n(8460),i=n(844);class a{get id(){return this._id}constructor(e){this.line=e,this.isDisposed=!1,this._disposables=[],this._id=a._nextId++,this._onDispose=this.register(new r.EventEmitter),this.onDispose=this._onDispose.event}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),(0,i.disposeArray)(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}}t.Marker=a,a._nextId=1},7116:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.DEFAULT_CHARSET=t.CHARSETS=void 0,t.CHARSETS={},t.DEFAULT_CHARSET=t.CHARSETS.B,t.CHARSETS[0]={"`":`◆`,a:`▒`,b:`␉`,c:`␌`,d:`␍`,e:`␊`,f:`°`,g:`±`,h:`␤`,i:`␋`,j:`┘`,k:`┐`,l:`┌`,m:`└`,n:`┼`,o:`⎺`,p:`⎻`,q:`─`,r:`⎼`,s:`⎽`,t:`├`,u:`┤`,v:`┴`,w:`┬`,x:`│`,y:`≤`,z:`≥`,"{":`π`,"|":`≠`,"}":`£`,"~":`·`},t.CHARSETS.A={"#":`£`},t.CHARSETS.B=void 0,t.CHARSETS[4]={"#":`£`,"@":`¾`,"[":`ij`,"\\":`½`,"]":`|`,"{":`¨`,"|":`f`,"}":`¼`,"~":`´`},t.CHARSETS.C=t.CHARSETS[5]={"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},t.CHARSETS.R={"#":`£`,"@":`à`,"[":`°`,"\\":`ç`,"]":`§`,"{":`é`,"|":`ù`,"}":`è`,"~":`¨`},t.CHARSETS.Q={"@":`à`,"[":`â`,"\\":`ç`,"]":`ê`,"^":`î`,"`":`ô`,"{":`é`,"|":`ù`,"}":`è`,"~":`û`},t.CHARSETS.K={"@":`§`,"[":`Ä`,"\\":`Ö`,"]":`Ü`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`ß`},t.CHARSETS.Y={"#":`£`,"@":`§`,"[":`°`,"\\":`ç`,"]":`é`,"`":`ù`,"{":`à`,"|":`ò`,"}":`è`,"~":`ì`},t.CHARSETS.E=t.CHARSETS[6]={"@":`Ä`,"[":`Æ`,"\\":`Ø`,"]":`Å`,"^":`Ü`,"`":`ä`,"{":`æ`,"|":`ø`,"}":`å`,"~":`ü`},t.CHARSETS.Z={"#":`£`,"@":`§`,"[":`¡`,"\\":`Ñ`,"]":`¿`,"{":`°`,"|":`ñ`,"}":`ç`},t.CHARSETS.H=t.CHARSETS[7]={"@":`É`,"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},t.CHARSETS[`=`]={"#":`ù`,"@":`à`,"[":`é`,"\\":`ç`,"]":`ê`,"^":`î`,_:`è`,"`":`ô`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`û`}},2584:(e,t)=>{var n,r,i;Object.defineProperty(t,`__esModule`,{value:!0}),t.C1_ESCAPED=t.C1=t.C0=void 0,function(e){e.NUL=`\0`,e.SOH=``,e.STX=``,e.ETX=``,e.EOT=``,e.ENQ=``,e.ACK=``,e.BEL=`\x07`,e.BS=`\b`,e.HT=` `,e.LF=`
156
156
  `,e.VT=`\v`,e.FF=`\f`,e.CR=`\r`,e.SO=``,e.SI=``,e.DLE=``,e.DC1=``,e.DC2=``,e.DC3=``,e.DC4=``,e.NAK=``,e.SYN=``,e.ETB=``,e.CAN=``,e.EM=``,e.SUB=``,e.ESC=`\x1B`,e.FS=``,e.GS=``,e.RS=``,e.US=``,e.SP=` `,e.DEL=``}(n||(t.C0=n={})),function(e){e.PAD=`€`,e.HOP=``,e.BPH=`‚`,e.NBH=`ƒ`,e.IND=`„`,e.NEL=`…`,e.SSA=`†`,e.ESA=`‡`,e.HTS=`ˆ`,e.HTJ=`‰`,e.VTS=`Š`,e.PLD=`‹`,e.PLU=`Œ`,e.RI=``,e.SS2=`Ž`,e.SS3=``,e.DCS=``,e.PU1=`‘`,e.PU2=`’`,e.STS=`“`,e.CCH=`”`,e.MW=`•`,e.SPA=`–`,e.EPA=`—`,e.SOS=`˜`,e.SGCI=`™`,e.SCI=`š`,e.CSI=`›`,e.ST=`œ`,e.OSC=``,e.PM=`ž`,e.APC=`Ÿ`}(r||(t.C1=r={})),function(e){e.ST=`${n.ESC}\\`}(i||(t.C1_ESCAPED=i={}))},7399:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.evaluateKeyboardEvent=void 0;let r=n(2584),i={48:[`0`,`)`],49:[`1`,`!`],50:[`2`,`@`],51:[`3`,`#`],52:[`4`,`$`],53:[`5`,`%`],54:[`6`,`^`],55:[`7`,`&`],56:[`8`,`*`],57:[`9`,`(`],186:[`;`,`:`],187:[`=`,`+`],188:[`,`,`<`],189:[`-`,`_`],190:[`.`,`>`],191:[`/`,`?`],192:["`",`~`],219:[`[`,`{`],220:[`\\`,`|`],221:[`]`,`}`],222:[`'`,`"`]};t.evaluateKeyboardEvent=function(e,t,n,a){let o={type:0,cancel:!1,key:void 0},s=!!e.shiftKey|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key===`UIKeyInputUpArrow`?o.key=t?r.C0.ESC+`OA`:r.C0.ESC+`[A`:e.key===`UIKeyInputLeftArrow`?o.key=t?r.C0.ESC+`OD`:r.C0.ESC+`[D`:e.key===`UIKeyInputRightArrow`?o.key=t?r.C0.ESC+`OC`:r.C0.ESC+`[C`:e.key===`UIKeyInputDownArrow`&&(o.key=t?r.C0.ESC+`OB`:r.C0.ESC+`[B`);break;case 8:o.key=e.ctrlKey?`\b`:r.C0.DEL,e.altKey&&(o.key=r.C0.ESC+o.key);break;case 9:if(e.shiftKey){o.key=r.C0.ESC+`[Z`;break}o.key=r.C0.HT,o.cancel=!0;break;case 13:o.key=e.altKey?r.C0.ESC+r.C0.CR:r.C0.CR,o.cancel=!0;break;case 27:o.key=r.C0.ESC,e.altKey&&(o.key=r.C0.ESC+r.C0.ESC),o.cancel=!0;break;case 37:if(e.metaKey)break;s?(o.key=r.C0.ESC+`[1;`+(s+1)+`D`,o.key===r.C0.ESC+`[1;3D`&&(o.key=r.C0.ESC+(n?`b`:`[1;5D`))):o.key=t?r.C0.ESC+`OD`:r.C0.ESC+`[D`;break;case 39:if(e.metaKey)break;s?(o.key=r.C0.ESC+`[1;`+(s+1)+`C`,o.key===r.C0.ESC+`[1;3C`&&(o.key=r.C0.ESC+(n?`f`:`[1;5C`))):o.key=t?r.C0.ESC+`OC`:r.C0.ESC+`[C`;break;case 38:if(e.metaKey)break;s?(o.key=r.C0.ESC+`[1;`+(s+1)+`A`,n||o.key!==r.C0.ESC+`[1;3A`||(o.key=r.C0.ESC+`[1;5A`)):o.key=t?r.C0.ESC+`OA`:r.C0.ESC+`[A`;break;case 40:if(e.metaKey)break;s?(o.key=r.C0.ESC+`[1;`+(s+1)+`B`,n||o.key!==r.C0.ESC+`[1;3B`||(o.key=r.C0.ESC+`[1;5B`)):o.key=t?r.C0.ESC+`OB`:r.C0.ESC+`[B`;break;case 45:e.shiftKey||e.ctrlKey||(o.key=r.C0.ESC+`[2~`);break;case 46:o.key=s?r.C0.ESC+`[3;`+(s+1)+`~`:r.C0.ESC+`[3~`;break;case 36:o.key=s?r.C0.ESC+`[1;`+(s+1)+`H`:t?r.C0.ESC+`OH`:r.C0.ESC+`[H`;break;case 35:o.key=s?r.C0.ESC+`[1;`+(s+1)+`F`:t?r.C0.ESC+`OF`:r.C0.ESC+`[F`;break;case 33:e.shiftKey?o.type=2:e.ctrlKey?o.key=r.C0.ESC+`[5;`+(s+1)+`~`:o.key=r.C0.ESC+`[5~`;break;case 34:e.shiftKey?o.type=3:e.ctrlKey?o.key=r.C0.ESC+`[6;`+(s+1)+`~`:o.key=r.C0.ESC+`[6~`;break;case 112:o.key=s?r.C0.ESC+`[1;`+(s+1)+`P`:r.C0.ESC+`OP`;break;case 113:o.key=s?r.C0.ESC+`[1;`+(s+1)+`Q`:r.C0.ESC+`OQ`;break;case 114:o.key=s?r.C0.ESC+`[1;`+(s+1)+`R`:r.C0.ESC+`OR`;break;case 115:o.key=s?r.C0.ESC+`[1;`+(s+1)+`S`:r.C0.ESC+`OS`;break;case 116:o.key=s?r.C0.ESC+`[15;`+(s+1)+`~`:r.C0.ESC+`[15~`;break;case 117:o.key=s?r.C0.ESC+`[17;`+(s+1)+`~`:r.C0.ESC+`[17~`;break;case 118:o.key=s?r.C0.ESC+`[18;`+(s+1)+`~`:r.C0.ESC+`[18~`;break;case 119:o.key=s?r.C0.ESC+`[19;`+(s+1)+`~`:r.C0.ESC+`[19~`;break;case 120:o.key=s?r.C0.ESC+`[20;`+(s+1)+`~`:r.C0.ESC+`[20~`;break;case 121:o.key=s?r.C0.ESC+`[21;`+(s+1)+`~`:r.C0.ESC+`[21~`;break;case 122:o.key=s?r.C0.ESC+`[23;`+(s+1)+`~`:r.C0.ESC+`[23~`;break;case 123:o.key=s?r.C0.ESC+`[24;`+(s+1)+`~`:r.C0.ESC+`[24~`;break;default:if(!e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)if(n&&!a||!e.altKey||e.metaKey)!n||e.altKey||e.ctrlKey||e.shiftKey||!e.metaKey?e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?o.key=e.key:e.key&&e.ctrlKey&&(e.key===`_`&&(o.key=r.C0.US),e.key===`@`&&(o.key=r.C0.NUL)):e.keyCode===65&&(o.type=1);else{let t=i[e.keyCode]?.[+!!e.shiftKey];if(t)o.key=r.C0.ESC+t;else if(e.keyCode>=65&&e.keyCode<=90){let t=e.ctrlKey?e.keyCode-64:e.keyCode+32,n=String.fromCharCode(t);e.shiftKey&&(n=n.toUpperCase()),o.key=r.C0.ESC+n}else if(e.keyCode===32)o.key=r.C0.ESC+(e.ctrlKey?r.C0.NUL:` `);else if(e.key===`Dead`&&e.code.startsWith(`Key`)){let t=e.code.slice(3,4);e.shiftKey||(t=t.toLowerCase()),o.key=r.C0.ESC+t,o.cancel=!0}}else e.keyCode>=65&&e.keyCode<=90?o.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?o.key=r.C0.NUL:e.keyCode>=51&&e.keyCode<=55?o.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?o.key=r.C0.DEL:e.keyCode===219?o.key=r.C0.ESC:e.keyCode===220?o.key=r.C0.FS:e.keyCode===221&&(o.key=r.C0.GS)}return o}},482:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.Utf8ToUtf32=t.StringToUtf32=t.utf32ToString=t.stringFromCodePoint=void 0,t.stringFromCodePoint=function(e){return e>65535?(e-=65536,String.fromCharCode(55296+(e>>10))+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)},t.utf32ToString=function(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode(55296+(t>>10))+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r},t.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=1024*(this._interim-55296)+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=1024*(i-55296)+o-56320+65536:(t[r++]=i,t[r++]=o)}else i!==65279&&(t[r++]=i)}return r}},t.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r,i,a,o,s=0,c=0,l=0;if(this.interim[0]){let r=!1,i=this.interim[0];i&=(224&i)==192?31:(240&i)==224?15:7;let a,o=0;for(;(a=63&this.interim[++o])&&o<4;)i<<=6,i|=a;let c=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(a=e[l++],(192&a)!=128){l--,r=!0;break}this.interim[o++]=a,i<<=6,i|=63&a}r||(c===2?i<128?l--:t[s++]=i:c===3?i<2048||i>=55296&&i<=57343||i===65279||(t[s++]=i):i<65536||i>1114111||(t[s++]=i)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;!(!(d<u)||128&(r=e[d])||128&(i=e[d+1])||128&(a=e[d+2])||128&(o=e[d+3]));)t[s++]=r,t[s++]=i,t[s++]=a,t[s++]=o,d+=4;if(r=e[d++],r<128)t[s++]=r;else if((224&r)==192){if(d>=n)return this.interim[0]=r,s;if(i=e[d++],(192&i)!=128){d--;continue}if(c=(31&r)<<6|63&i,c<128){d--;continue}t[s++]=c}else if((240&r)==224){if(d>=n)return this.interim[0]=r,s;if(i=e[d++],(192&i)!=128){d--;continue}if(d>=n)return this.interim[0]=r,this.interim[1]=i,s;if(a=e[d++],(192&a)!=128){d--;continue}if(c=(15&r)<<12|(63&i)<<6|63&a,c<2048||c>=55296&&c<=57343||c===65279)continue;t[s++]=c}else if((248&r)==240){if(d>=n)return this.interim[0]=r,s;if(i=e[d++],(192&i)!=128){d--;continue}if(d>=n)return this.interim[0]=r,this.interim[1]=i,s;if(a=e[d++],(192&a)!=128){d--;continue}if(d>=n)return this.interim[0]=r,this.interim[1]=i,this.interim[2]=a,s;if(o=e[d++],(192&o)!=128){d--;continue}if(c=(7&r)<<18|(63&i)<<12|(63&a)<<6|63&o,c<65536||c>1114111)continue;t[s++]=c}}return s}}},225:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.UnicodeV6=void 0;let r=n(1480),i=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],a=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],o;t.UnicodeV6=class{constructor(){if(this.version=`6`,!o){o=new Uint8Array(65536),o.fill(1),o[0]=0,o.fill(0,1,32),o.fill(0,127,160),o.fill(2,4352,4448),o[9001]=2,o[9002]=2,o.fill(2,11904,42192),o[12351]=1,o.fill(2,44032,55204),o.fill(2,63744,64256),o.fill(2,65040,65050),o.fill(2,65072,65136),o.fill(2,65280,65377),o.fill(2,65504,65511);for(let e=0;e<i.length;++e)o.fill(0,i[e][0],i[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?o[e]:function(e,t){let n,r=0,i=t.length-1;if(e<t[0][0]||e>t[i][1])return!1;for(;i>=r;)if(n=r+i>>1,e>t[n][1])r=n+1;else{if(!(e<t[n][0]))return!0;i=n-1}return!1}(e,a)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),i=n===0&&t!==0;if(i){let e=r.UnicodeService.extractWidth(t);e===0?i=!1:e>n&&(n=e)}return r.UnicodeService.createPropertyValue(0,n,i)}}},5981:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.WriteBuffer=void 0;let r=n(8460),i=n(844);class a extends i.Disposable{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this.register(new r.EventEmitter),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t)return void(this._syncCalls=0);if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let n;for(this._isSyncWriting=!0;n=this._writeBuffer.shift();){this._action(n);let e=this._callbacks.shift();e&&e()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>5e7)throw Error(`write data discarded, use flow control to avoid losing data`);if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput)return this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),void this._innerWrite();setTimeout((()=>this._innerWrite()))}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let n=e||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){let e=this._writeBuffer[this._bufferOffset],r=this._action(e,t);if(r){r.catch((e=>(queueMicrotask((()=>{throw e})),Promise.resolve(!1)))).then(e=>Date.now()-n>=12?setTimeout((()=>this._innerWrite(0,e))):this._innerWrite(n,e));return}let i=this._callbacks[this._bufferOffset];if(i&&i(),this._bufferOffset++,this._pendingData-=e.length,Date.now()-n>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout((()=>this._innerWrite()))):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}}t.WriteBuffer=a},5941:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.toRgbString=t.parseColor=void 0;let n=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,r=/^[\da-f]+$/;function i(e,t){let n=e.toString(16),r=n.length<2?`0`+n:n;switch(t){case 4:return n[0];case 8:return r;case 12:return(r+r).slice(0,3);default:return r+r}}t.parseColor=function(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf(`rgb:`)===0){t=t.slice(4);let e=n.exec(t);if(e){let t=e[1]?15:e[4]?255:e[7]?4095:65535;return[Math.round(parseInt(e[1]||e[4]||e[7]||e[10],16)/t*255),Math.round(parseInt(e[2]||e[5]||e[8]||e[11],16)/t*255),Math.round(parseInt(e[3]||e[6]||e[9]||e[12],16)/t*255)]}}else if(t.indexOf(`#`)===0&&(t=t.slice(1),r.exec(t)&&[3,6,9,12].includes(t.length))){let e=t.length/3,n=[0,0,0];for(let r=0;r<3;++r){let i=parseInt(t.slice(e*r,e*r+e),16);n[r]=e===1?i<<4:e===2?i:e===3?i>>4:i>>8}return n}},t.toRgbString=function(e,t=16){let[n,r,a]=e;return`rgb:${i(n,t)}/${i(r,t)}/${i(a,t)}`}},5770:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.PAYLOAD_LIMIT=void 0,t.PAYLOAD_LIMIT=1e7},6351:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.DcsHandler=t.DcsParser=void 0;let r=n(482),i=n(8742),a=n(5770),o=[];t.DcsParser=class{constructor(){this._handlers=Object.create(null),this._active=o,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=o}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=o,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||o,this._active.length)for(let e=this._active.length-1;e>=0;e--)this._active[e].hook(t);else this._handlerFb(this._ident,`HOOK`,t)}put(e,t,n){if(this._active.length)for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n);else this._handlerFb(this._ident,`PUT`,(0,r.utf32ToString)(e,t,n))}unhook(e,t=!0){if(this._active.length){let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&!1===n){for(;r>=0&&(n=this._active[r].unhook(e),!0!==n);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}else this._handlerFb(this._ident,`UNHOOK`,e);this._active=o,this._ident=0}};let s=new i.Params;s.addParam(0),t.DcsHandler=class{constructor(e){this._handler=e,this._data=``,this._params=s,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():s,this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=(0,r.utf32ToString)(e,t,n),this._data.length>a.PAYLOAD_LIMIT&&(this._data=``,this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then((e=>(this._params=s,this._data=``,this._hitLimit=!1,e)));return this._params=s,this._data=``,this._hitLimit=!1,t}}},2015:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.EscapeSequenceParser=t.VT500_TRANSITION_TABLE=t.TransitionTable=void 0;let r=n(844),i=n(8742),a=n(6242),o=n(6351);class s{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,r){this.table[t<<8|e]=n<<4|r}addMany(e,t,n,r){for(let i=0;i<e.length;i++)this.table[t<<8|e[i]]=n<<4|r}}t.TransitionTable=s,t.VT500_TRANSITION_TABLE=function(){let e=new s(4095),t=Array.apply(null,Array(256)).map(((e,t)=>t)),n=(e,n)=>t.slice(e,n),r=n(32,127),i=n(0,24);i.push(25),i.push.apply(i,n(28,32));let a=n(0,14),o;for(o in e.setDefault(1,0),e.addMany(r,0,2,0),a)e.addMany([24,26,153,154],o,3,0),e.addMany(n(128,144),o,3,0),e.addMany(n(144,152),o,3,0),e.add(156,o,0,0),e.add(27,o,11,1),e.add(157,o,4,8),e.addMany([152,158,159],o,0,7),e.add(155,o,11,3),e.add(144,o,11,9);return e.addMany(i,0,3,0),e.addMany(i,1,3,1),e.add(127,1,0,1),e.addMany(i,8,0,8),e.addMany(i,3,3,3),e.add(127,3,0,3),e.addMany(i,4,3,4),e.add(127,4,0,4),e.addMany(i,6,3,6),e.addMany(i,5,3,5),e.add(127,5,0,5),e.addMany(i,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(r,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(n(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(r,7,0,7),e.addMany(i,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(i,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(i,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(i,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(i,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(i,13,13,13),e.addMany(r,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(160,0,2,0),e.add(160,8,5,8),e.add(160,6,0,6),e.add(160,11,0,11),e.add(160,13,13,13),e}();class c extends r.Disposable{constructor(e=t.VT500_TRANSITION_TABLE){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new i.Params,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(e,t,n)=>{},this._executeHandlerFb=e=>{},this._csiHandlerFb=(e,t)=>{},this._escHandlerFb=e=>{},this._errorHandlerFb=e=>e,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this.register((0,r.toDisposable)((()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)}))),this._oscParser=this.register(new a.OscParser),this._dcsParser=this.register(new o.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:`\\`},(()=>!0))}_identifier(e,t=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw Error(`only one byte as prefix supported`);if(n=e.prefix.charCodeAt(0),n&&60>n||n>63)throw Error(`prefix must be in range 0x3c .. 0x3f`)}if(e.intermediates){if(e.intermediates.length>2)throw Error(`only two bytes as intermediates are supported`);for(let t=0;t<e.intermediates.length;++t){let r=e.intermediates.charCodeAt(t);if(32>r||r>47)throw Error(`intermediate must be in range 0x20 .. 0x2f`);n<<=8,n|=r}}if(e.final.length!==1)throw Error(`final must be a single byte`);let r=e.final.charCodeAt(0);if(t[0]>r||r>t[1])throw Error(`final must be in range ${t[0]} .. ${t[1]}`);return n<<=8,n|=r,n}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(255&e)),e>>=8;return t.reverse().join(``)}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let r=this._escHandlers[n];return r.push(t),{dispose:()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let r=this._csiHandlers[n];return r.push(t),{dispose:()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,n,r,i){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=r,this._parseStack.chunkPos=i}parse(e,t,n){let r,i=0,a=0,o=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,o=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,Error(`improper continuation due to previous async handler, giving up parsing`);let t=this._parseStack.handlers,a=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(!1===n&&a>-1){for(;a>=0&&(r=t[a](this._params),!0!==r);a--)if(r instanceof Promise)return this._parseStack.handlerPos=a,r}this._parseStack.handlers=[];break;case 4:if(!1===n&&a>-1){for(;a>=0&&(r=t[a](),!0!==r);a--)if(r instanceof Promise)return this._parseStack.handlerPos=a,r}this._parseStack.handlers=[];break;case 6:if(i=e[this._parseStack.chunkPos],r=this._dcsParser.unhook(i!==24&&i!==26,n),r)return r;i===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(i=e[this._parseStack.chunkPos],r=this._oscParser.end(i!==24&&i!==26,n),r)return r;i===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,o=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=15&this._parseStack.transition}for(let n=o;n<t;++n){switch(i=e[n],a=this._transitions.table[this.currentState<<8|(i<160?i:160)],a>>4){case 2:for(let r=n+1;;++r){if(r>=t||(i=e[r])<32||i>126&&i<160){this._printHandler(e,n,r),n=r-1;break}if(++r>=t||(i=e[r])<32||i>126&&i<160){this._printHandler(e,n,r),n=r-1;break}if(++r>=t||(i=e[r])<32||i>126&&i<160){this._printHandler(e,n,r),n=r-1;break}if(++r>=t||(i=e[r])<32||i>126&&i<160){this._printHandler(e,n,r),n=r-1;break}}break;case 3:this._executeHandlers[i]?this._executeHandlers[i]():this._executeHandlerFb(i),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:n,code:i,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let o=this._csiHandlers[this._collect<<8|i],s=o?o.length-1:-1;for(;s>=0&&(r=o[s](this._params),!0!==r);s--)if(r instanceof Promise)return this._preserveStack(3,o,s,a,n),r;s<0&&this._csiHandlerFb(this._collect<<8|i,this._params),this.precedingJoinState=0;break;case 8:do switch(i){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(i-48)}while(++n<t&&(i=e[n])>47&&i<60);n--;break;case 9:this._collect<<=8,this._collect|=i;break;case 10:let c=this._escHandlers[this._collect<<8|i],l=c?c.length-1:-1;for(;l>=0&&(r=c[l](),!0!==r);l--)if(r instanceof Promise)return this._preserveStack(4,c,l,a,n),r;l<0&&this._escHandlerFb(this._collect<<8|i),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|i,this._params);break;case 13:for(let r=n+1;;++r)if(r>=t||(i=e[r])===24||i===26||i===27||i>127&&i<160){this._dcsParser.put(e,n,r),n=r-1;break}break;case 14:if(r=this._dcsParser.unhook(i!==24&&i!==26),r)return this._preserveStack(6,[],0,a,n),r;i===27&&(a|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let r=n+1;;r++)if(r>=t||(i=e[r])<32||i>127&&i<160){this._oscParser.put(e,n,r),n=r-1;break}break;case 6:if(r=this._oscParser.end(i!==24&&i!==26),r)return this._preserveStack(5,[],0,a,n),r;i===27&&(a|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=15&a}}}t.EscapeSequenceParser=c},6242:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.OscHandler=t.OscParser=void 0;let r=n(5770),i=n(482),a=[];t.OscParser=class{constructor(){this._state=0,this._active=a,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=a}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=a,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||a,this._active.length)for(let e=this._active.length-1;e>=0;e--)this._active[e].start();else this._handlerFb(this._id,`START`)}_put(e,t,n){if(this._active.length)for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n);else this._handlerFb(this._id,`PUT`,(0,i.utf32ToString)(e,t,n))}start(){this.reset(),this._state=1}put(e,t,n){if(this._state!==3){if(this._state===1)for(;t<n;){let n=e[t++];if(n===59){this._state=2,this._start();break}if(n<48||57<n)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+n-48}this._state===2&&n-t>0&&this._put(e,t,n)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&!1===n){for(;r>=0&&(n=this._active[r].end(e),!0!==n);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}else this._handlerFb(this._id,`END`,e);this._active=a,this._id=-1,this._state=0}}},t.OscHandler=class{constructor(e){this._handler=e,this._data=``,this._hitLimit=!1}start(){this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=(0,i.utf32ToString)(e,t,n),this._data.length>r.PAYLOAD_LIMIT&&(this._data=``,this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then((e=>(this._data=``,this._hitLimit=!1,e)));return this._data=``,this._hitLimit=!1,t}}},8742:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.Params=void 0;let n=2147483647;class r{static fromArray(e){let t=new r;if(!e.length)return t;for(let n=+!!Array.isArray(e[0]);n<e.length;++n){let r=e[n];if(Array.isArray(r))for(let e=0;e<r.length;++e)t.addSubParam(r[e]);else t.addParam(r)}return t}constructor(e=32,t=32){if(this.maxLength=e,this.maxSubParamsLength=t,t>256)throw Error(`maxSubParamsLength must not be greater than 256`);this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(t),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}clone(){let e=new r(this.maxLength,this.maxSubParamsLength);return e.params.set(this.params),e.length=this.length,e._subParams.set(this._subParams),e._subParamsLength=this._subParamsLength,e._subParamsIdx.set(this._subParamsIdx),e._rejectDigits=this._rejectDigits,e._rejectSubDigits=this._rejectSubDigits,e._digitIsSub=this._digitIsSub,e}toArray(){let e=[];for(let t=0;t<this.length;++t){e.push(this.params[t]);let n=this._subParamsIdx[t]>>8,r=255&this._subParamsIdx[t];r-n>0&&e.push(Array.prototype.slice.call(this._subParams,n,r))}return e}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(e){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(e<-1)throw Error(`values lesser than -1 are not allowed`);this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=e>n?n:e}}addSubParam(e){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(e<-1)throw Error(`values lesser than -1 are not allowed`);this._subParams[this._subParamsLength++]=e>n?n:e,this._subParamsIdx[this.length-1]++}}hasSubParams(e){return(255&this._subParamsIdx[e])-(this._subParamsIdx[e]>>8)>0}getSubParams(e){let t=this._subParamsIdx[e]>>8,n=255&this._subParamsIdx[e];return n-t>0?this._subParams.subarray(t,n):null}getSubParamsAll(){let e={};for(let t=0;t<this.length;++t){let n=this._subParamsIdx[t]>>8,r=255&this._subParamsIdx[t];r-n>0&&(e[t]=this._subParams.slice(n,r))}return e}addDigit(e){let t;if(this._rejectDigits||!(t=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let r=this._digitIsSub?this._subParams:this.params,i=r[t-1];r[t-1]=~i?Math.min(10*i+e,n):e}}t.Params=r},5741:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.AddonManager=void 0,t.AddonManager=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n<this._addons.length;n++)if(this._addons[n]===e){t=n;break}if(t===-1)throw Error(`Could not dispose an addon that has not been loaded`);e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}}},8771:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.BufferApiView=void 0;let r=n(3785),i=n(511);t.BufferApiView=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new r.BufferLineApiView(t)}getNullCell(){return new i.CellData}}},3785:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.BufferLineApiView=void 0;let r=n(511);t.BufferLineApiView=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new r.CellData)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}}},8285:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.BufferNamespaceApi=void 0;let r=n(8771),i=n(8460),a=n(844);class o extends a.Disposable{constructor(e){super(),this._core=e,this._onBufferChange=this.register(new i.EventEmitter),this.onBufferChange=this._onBufferChange.event,this._normal=new r.BufferApiView(this._core.buffers.normal,`normal`),this._alternate=new r.BufferApiView(this._core.buffers.alt,`alternate`),this._core.buffers.onBufferActivate((()=>this._onBufferChange.fire(this.active)))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw Error(`Active buffer is neither normal nor alternate`)}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}}t.BufferNamespaceApi=o},7975:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.ParserApi=void 0,t.ParserApi=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,(e=>t(e.toArray())))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,((e,n)=>t(e,n.toArray())))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}}},7090:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.UnicodeApi=void 0,t.UnicodeApi=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}}},744:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,`__esModule`,{value:!0}),t.BufferService=t.MINIMUM_ROWS=t.MINIMUM_COLS=void 0;let a=n(8460),o=n(844),s=n(5295),c=n(2585);t.MINIMUM_COLS=2,t.MINIMUM_ROWS=1;let l=t.BufferService=class extends o.Disposable{get buffer(){return this.buffers.active}constructor(e){super(),this.isUserScrolling=!1,this._onResize=this.register(new a.EventEmitter),this.onResize=this._onResize.event,this._onScroll=this.register(new a.EventEmitter),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,t.MINIMUM_COLS),this.rows=Math.max(e.rawOptions.rows||0,t.MINIMUM_ROWS),this.buffers=this.register(new s.BufferSet(e,this))}resize(e,t){this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,r;r=this._cachedBlankLine,r&&r.length===this.cols&&r.getFg(0)===e.fg&&r.getBg(0)===e.bg||(r=n.getBlankLine(e,t),this._cachedBlankLine=r),r.isWrapped=t;let i=n.ybase+n.scrollTop,a=n.ybase+n.scrollBottom;if(n.scrollTop===0){let e=n.lines.isFull;a===n.lines.length-1?e?n.lines.recycle().copyFrom(r):n.lines.push(r.clone()):n.lines.splice(a+1,0,r.clone()),e?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let e=a-i+1;n.lines.shiftElements(i+1,e-1,-1),n.lines.set(a,r.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,t,n){let r=this.buffer;if(e<0){if(r.ydisp===0)return;this.isUserScrolling=!0}else e+r.ydisp>=r.ybase&&(this.isUserScrolling=!1);let i=r.ydisp;r.ydisp=Math.max(Math.min(r.ydisp+e,r.ybase),0),i!==r.ydisp&&(t||this._onScroll.fire(r.ydisp))}};t.BufferService=l=r([i(0,c.IOptionsService)],l)},7994:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.CharsetService=void 0,t.CharsetService=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}}},1753:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,`__esModule`,{value:!0}),t.CoreMouseService=void 0;let a=n(2585),o=n(8460),s=n(844),c={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button!==4&&e.action===1&&(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>e.action!==32||e.button!==3},ANY:{events:31,restrict:e=>!0}};function l(e,t){let n=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(n|=64,n|=e.action):(n|=3&e.button,4&e.button&&(n|=64),8&e.button&&(n|=128),e.action===32?n|=32:e.action!==0||t||(n|=3)),n}let u=String.fromCharCode,d={DEFAULT:e=>{let t=[l(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?``:`${u(t[0])}${u(t[1])}${u(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`[<${l(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`[<${l(e,!0)};${e.x};${e.y}${t}`}},f=t.CoreMouseService=class extends s.Disposable{constructor(e,t){super(),this._bufferService=e,this._coreService=t,this._protocols={},this._encodings={},this._activeProtocol=``,this._activeEncoding=``,this._lastEvent=null,this._onProtocolChange=this.register(new o.EventEmitter),this.onProtocolChange=this._onProtocolChange.event;for(let e of Object.keys(c))this.addProtocol(e,c[e]);for(let e of Object.keys(d))this.addEncoding(e,d[e]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol=`NONE`,this.activeEncoding=`DEFAULT`,this._lastEvent=null}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding===`SGR_PIXELS`))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding===`DEFAULT`?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(1&e),up:!!(2&e),drag:!!(4&e),move:!!(8&e),wheel:!!(16&e)}}_equalEvents(e,t,n){if(n){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return e.button===t.button&&e.action===t.action&&e.ctrl===t.ctrl&&e.alt===t.alt&&e.shift===t.shift}};t.CoreMouseService=f=r([i(0,a.IBufferService),i(1,a.ICoreService)],f)},6975:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,`__esModule`,{value:!0}),t.CoreService=void 0;let a=n(1439),o=n(8460),s=n(844),c=n(2585),l=Object.freeze({insertMode:!1}),u=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0}),d=t.CoreService=class extends s.Disposable{constructor(e,t,n){super(),this._bufferService=e,this._logService=t,this._optionsService=n,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this.register(new o.EventEmitter),this.onData=this._onData.event,this._onUserInput=this.register(new o.EventEmitter),this.onUserInput=this._onUserInput.event,this._onBinary=this.register(new o.EventEmitter),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this.register(new o.EventEmitter),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=(0,a.clone)(l),this.decPrivateModes=(0,a.clone)(u)}reset(){this.modes=(0,a.clone)(l),this.decPrivateModes=(0,a.clone)(u)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let n=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&n.ybase!==n.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`,(()=>e.split(``).map((e=>e.charCodeAt(0))))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`,(()=>e.split(``).map((e=>e.charCodeAt(0))))),this._onBinary.fire(e))}};t.CoreService=d=r([i(0,c.IBufferService),i(1,c.ILogService),i(2,c.IOptionsService)],d)},9074:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.DecorationService=void 0;let r=n(8055),i=n(8460),a=n(844),o=n(6106),s=0,c=0;class l extends a.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new o.SortedList((e=>e?.marker.line)),this._onDecorationRegistered=this.register(new i.EventEmitter),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this.register(new i.EventEmitter),this.onDecorationRemoved=this._onDecorationRemoved.event,this.register((0,a.toDisposable)((()=>this.reset())))}registerDecoration(e){if(e.marker.isDisposed)return;let t=new u(e);if(t){let e=t.marker.onDispose((()=>t.dispose()));t.onDispose((()=>{t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),e.dispose())})),this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,n){let r=0,i=0;for(let a of this._decorations.getKeyIterator(t))r=a.options.x??0,i=r+(a.options.width??1),e>=r&&e<i&&(!n||(a.options.layer??`bottom`)===n)&&(yield a)}forEachDecorationAtCell(e,t,n,r){this._decorations.forEachByKey(t,(t=>{s=t.options.x??0,c=s+(t.options.width??1),e>=s&&e<c&&(!n||(t.options.layer??`bottom`)===n)&&r(t)}))}}t.DecorationService=l;class u extends a.Disposable{get isDisposed(){return this._isDisposed}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=r.css.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=r.css.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}constructor(e){super(),this.options=e,this.onRenderEmitter=this.register(new i.EventEmitter),this.onRender=this.onRenderEmitter.event,this._onDispose=this.register(new i.EventEmitter),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position=`full`)}dispose(){this._onDispose.fire(),super.dispose()}}},4348:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.InstantiationService=t.ServiceCollection=void 0;let r=n(2585),i=n(8343);class a{constructor(...e){this._entries=new Map;for(let[t,n]of e)this.set(t,n)}set(e,t){let n=this._entries.get(e);return this._entries.set(e,t),n}forEach(e){for(let[t,n]of this._entries.entries())e(t,n)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}}t.ServiceCollection=a,t.InstantiationService=class{constructor(){this._services=new a,this._services.set(r.IInstantiationService,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=(0,i.getServiceDependencies)(e).sort(((e,t)=>e.index-t.index)),r=[];for(let t of n){let n=this._services.get(t.id);if(!n)throw Error(`[createInstance] ${e.name} depends on UNKNOWN service ${t.id}.`);r.push(n)}let a=n.length>0?n[0].index:t.length;if(t.length!==a)throw Error(`[createInstance] First service dependency of ${e.name} at position ${a+1} conflicts with ${t.length} static arguments`);return new e(...t,...r)}}},7866:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,`__esModule`,{value:!0}),t.traceCall=t.setTraceLogger=t.LogService=void 0;let a=n(844),o=n(2585),s={trace:o.LogLevelEnum.TRACE,debug:o.LogLevelEnum.DEBUG,info:o.LogLevelEnum.INFO,warn:o.LogLevelEnum.WARN,error:o.LogLevelEnum.ERROR,off:o.LogLevelEnum.OFF},c,l=t.LogService=class extends a.Disposable{get logLevel(){return this._logLevel}constructor(e){super(),this._optionsService=e,this._logLevel=o.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange(`logLevel`,(()=>this._updateLogLevel()))),c=this}_updateLogLevel(){this._logLevel=s[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]==`function`&&(e[t]=e[t]())}_log(e,t,n){this._evalLazyOptionalParams(n),e.call(console,(this._optionsService.options.logger?``:`xterm.js: `)+t,...n)}trace(e,...t){this._logLevel<=o.LogLevelEnum.TRACE&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,t)}debug(e,...t){this._logLevel<=o.LogLevelEnum.DEBUG&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,t)}info(e,...t){this._logLevel<=o.LogLevelEnum.INFO&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,t)}warn(e,...t){this._logLevel<=o.LogLevelEnum.WARN&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,t)}error(e,...t){this._logLevel<=o.LogLevelEnum.ERROR&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,t)}};t.LogService=l=r([i(0,o.IOptionsService)],l),t.setTraceLogger=function(e){c=e},t.traceCall=function(e,t,n){if(typeof n.value!=`function`)throw Error(`not supported`);let r=n.value;n.value=function(...e){if(c.logLevel!==o.LogLevelEnum.TRACE)return r.apply(this,e);c.trace(`GlyphRenderer#${r.name}(${e.map((e=>JSON.stringify(e))).join(`, `)})`);let t=r.apply(this,e);return c.trace(`GlyphRenderer#${r.name} return`,t),t}}},7302:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.OptionsService=t.DEFAULT_OPTIONS=void 0;let r=n(8460),i=n(844);t.DEFAULT_OPTIONS={cols:80,rows:24,cursorBlink:!1,cursorStyle:`block`,cursorWidth:1,cursorInactiveStyle:`outline`,customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:`alt`,fastScrollSensitivity:5,fontFamily:`courier-new, courier, monospace`,fontSize:15,fontWeight:`normal`,fontWeightBold:`bold`,ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:`info`,logger:null,scrollback:1e3,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},rescaleOverlappingGlyphs:!1,rightClickSelectsWord:n(6114).isMac,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:` ()[]{}',"\``,altClickMovesCursor:!0,convertEol:!1,termName:`xterm`,cancelEvents:!1,overviewRulerWidth:0};let a=[`normal`,`bold`,`100`,`200`,`300`,`400`,`500`,`600`,`700`,`800`,`900`];class o extends i.Disposable{constructor(e){super(),this._onOptionChange=this.register(new r.EventEmitter),this.onOptionChange=this._onOptionChange.event;let n={...t.DEFAULT_OPTIONS};for(let t in e)if(t in n)try{let r=e[t];n[t]=this._sanitizeAndValidateOption(t,r)}catch(e){console.error(e)}this.rawOptions=n,this.options={...n},this._setupOptions(),this.register((0,i.toDisposable)((()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null})))}onSpecificOptionChange(e,t){return this.onOptionChange((n=>{n===e&&t(this.rawOptions[e])}))}onMultipleOptionChange(e,t){return this.onOptionChange((n=>{e.indexOf(n)!==-1&&t()}))}_setupOptions(){let e=e=>{if(!(e in t.DEFAULT_OPTIONS))throw Error(`No option with key "${e}"`);return this.rawOptions[e]},n=(e,n)=>{if(!(e in t.DEFAULT_OPTIONS))throw Error(`No option with key "${e}"`);n=this._sanitizeAndValidateOption(e,n),this.rawOptions[e]!==n&&(this.rawOptions[e]=n,this._onOptionChange.fire(e))};for(let t in this.rawOptions){let r={get:e.bind(this,t),set:n.bind(this,t)};Object.defineProperty(this.options,t,r)}}_sanitizeAndValidateOption(e,n){switch(e){case`cursorStyle`:if(n||=t.DEFAULT_OPTIONS[e],!function(e){return e===`block`||e===`underline`||e===`bar`}(n))throw Error(`"${n}" is not a valid value for ${e}`);break;case`wordSeparator`:n||=t.DEFAULT_OPTIONS[e];break;case`fontWeight`:case`fontWeightBold`:if(typeof n==`number`&&1<=n&&n<=1e3)break;n=a.includes(n)?n:t.DEFAULT_OPTIONS[e];break;case`cursorWidth`:n=Math.floor(n);case`lineHeight`:case`tabStopWidth`:if(n<1)throw Error(`${e} cannot be less than 1, value: ${n}`);break;case`minimumContrastRatio`:n=Math.max(1,Math.min(21,Math.round(10*n)/10));break;case`scrollback`:if((n=Math.min(n,4294967295))<0)throw Error(`${e} cannot be less than 0, value: ${n}`);break;case`fastScrollSensitivity`:case`scrollSensitivity`:if(n<=0)throw Error(`${e} cannot be less than or equal to 0, value: ${n}`);break;case`rows`:case`cols`:if(!n&&n!==0)throw Error(`${e} must be numeric, value: ${n}`);break;case`windowsPty`:n??={}}return n}}t.OptionsService=o},2660:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,`__esModule`,{value:!0}),t.OscLinkService=void 0;let a=n(2585),o=t.OscLinkService=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let n=t.addMarker(t.ybase+t.y),r={data:e,id:this._nextId++,lines:[n]};return n.onDispose((()=>this._removeMarkerFromLink(r,n))),this._dataByLinkId.set(r.id,r),r.id}let n=e,r=this._getEntryIdKey(n),i=this._entriesWithId.get(r);if(i)return this.addLineToLink(i.id,t.ybase+t.y),i.id;let a=t.addMarker(t.ybase+t.y),o={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[a]};return a.onDispose((()=>this._removeMarkerFromLink(o,a))),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every((e=>e.line!==t))){let e=this._bufferService.buffer.addMarker(t);n.lines.push(e),e.onDispose((()=>this._removeMarkerFromLink(n,e)))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let n=e.lines.indexOf(t);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};t.OscLinkService=o=r([i(0,a.IBufferService)],o)},8343:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.createDecorator=t.getServiceDependencies=t.serviceRegistry=void 0;let n=`di$target`,r=`di$dependencies`;t.serviceRegistry=new Map,t.getServiceDependencies=function(e){return e[r]||[]},t.createDecorator=function(e){if(t.serviceRegistry.has(e))return t.serviceRegistry.get(e);let i=function(e,t,a){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);(function(e,t,i){t[n]===t?t[r].push({id:e,index:i}):(t[r]=[{id:e,index:i}],t[n]=t)})(i,e,a)};return i.toString=()=>e,t.serviceRegistry.set(e,i),i}},2585:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.IDecorationService=t.IUnicodeService=t.IOscLinkService=t.IOptionsService=t.ILogService=t.LogLevelEnum=t.IInstantiationService=t.ICharsetService=t.ICoreService=t.ICoreMouseService=t.IBufferService=void 0;let r=n(8343);var i;t.IBufferService=(0,r.createDecorator)(`BufferService`),t.ICoreMouseService=(0,r.createDecorator)(`CoreMouseService`),t.ICoreService=(0,r.createDecorator)(`CoreService`),t.ICharsetService=(0,r.createDecorator)(`CharsetService`),t.IInstantiationService=(0,r.createDecorator)(`InstantiationService`),function(e){e[e.TRACE=0]=`TRACE`,e[e.DEBUG=1]=`DEBUG`,e[e.INFO=2]=`INFO`,e[e.WARN=3]=`WARN`,e[e.ERROR=4]=`ERROR`,e[e.OFF=5]=`OFF`}(i||(t.LogLevelEnum=i={})),t.ILogService=(0,r.createDecorator)(`LogService`),t.IOptionsService=(0,r.createDecorator)(`OptionsService`),t.IOscLinkService=(0,r.createDecorator)(`OscLinkService`),t.IUnicodeService=(0,r.createDecorator)(`UnicodeService`),t.IDecorationService=(0,r.createDecorator)(`DecorationService`)},1480:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.UnicodeService=void 0;let r=n(8460),i=n(225);class a{static extractShouldJoin(e){return(1&e)!=0}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,t,n=!1){return(16777215&e)<<3|(3&t)<<1|!!n}constructor(){this._providers=Object.create(null),this._active=``,this._onChange=new r.EventEmitter,this.onChange=this._onChange.event;let e=new i.UnicodeV6;this.register(e),this._active=e.version,this._activeProvider=e}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(e){if(!this._providers[e])throw Error(`unknown Unicode version "${e}"`);this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)}register(e){this._providers[e.version]=e}wcwidth(e){return this._activeProvider.wcwidth(e)}getStringCellWidth(e){let t=0,n=0,r=e.length;for(let i=0;i<r;++i){let o=e.charCodeAt(i);if(55296<=o&&o<=56319){if(++i>=r)return t+this.wcwidth(o);let n=e.charCodeAt(i);56320<=n&&n<=57343?o=1024*(o-55296)+n-56320+65536:t+=this.wcwidth(n)}let s=this.charProperties(o,n),c=a.extractWidth(s);a.extractShouldJoin(s)&&(c-=a.extractWidth(n)),t+=c,n=s}return t}charProperties(e,t){return this._activeProvider.charProperties(e,t)}}t.UnicodeService=a}},t={};function n(r){var i=t[r];if(i!==void 0)return i.exports;var a=t[r]={exports:{}};return e[r].call(a.exports,a,a.exports,n),a.exports}var r={};return(()=>{var e=r;Object.defineProperty(e,`__esModule`,{value:!0}),e.Terminal=void 0;let t=n(9042),i=n(3236),a=n(844),o=n(5741),s=n(8285),c=n(7975),l=n(7090),u=[`cols`,`rows`];class d extends a.Disposable{constructor(e){super(),this._core=this.register(new i.Terminal(e)),this._addonManager=this.register(new o.AddonManager),this._publicOptions={...this._core.options};let t=e=>this._core.options[e],n=(e,t)=>{this._checkReadonlyOptions(e),this._core.options[e]=t};for(let e in this._core.options){let r={get:t.bind(this,e),set:n.bind(this,e)};Object.defineProperty(this._publicOptions,e,r)}}_checkReadonlyOptions(e){if(u.includes(e))throw Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw Error(`You must set the allowProposedApi option to true to use proposed API`)}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||=new c.ParserApi(this._core),this._parser}get unicode(){return this._checkProposedApi(),new l.UnicodeApi(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||=this.register(new s.BufferNamespaceApi(this._core)),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t=`none`;switch(this._core.coreMouseService.activeProtocol){case`X10`:t=`x10`;break;case`VT200`:t=`vt200`;break;case`DRAG`:t=`drag`;break;case`ANY`:t=`any`}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
157
157
  `,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return t}_verifyIntegers(...e){for(let t of e)if(t===1/0||isNaN(t)||t%1!=0)throw Error(`This API only accepts integers`)}_verifyPositiveIntegers(...e){for(let t of e)if(t&&(t===1/0||isNaN(t)||t%1!=0||t<0))throw Error(`This API only accepts positive integers`)}}e.Terminal=d})(),r})()))})),gie=i(((e,t)=>{(function(n,r){typeof e==`object`&&typeof t==`object`?t.exports=r():typeof define==`function`&&define.amd?define([],r):typeof e==`object`?e.FitAddon=r():n.FitAddon=r()})(self,(()=>(()=>{var e={};return(()=>{var t=e;Object.defineProperty(t,`__esModule`,{value:!0}),t.FitAddon=void 0,t.FitAddon=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;this._terminal.rows===e.rows&&this._terminal.cols===e.cols||(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core,t=e._renderService.dimensions;if(t.css.cell.width===0||t.css.cell.height===0)return;let n=this._terminal.options.scrollback===0?0:e.viewport.scrollBarWidth,r=window.getComputedStyle(this._terminal.element.parentElement),i=parseInt(r.getPropertyValue(`height`)),a=Math.max(0,parseInt(r.getPropertyValue(`width`))),o=window.getComputedStyle(this._terminal.element),s=i-(parseInt(o.getPropertyValue(`padding-top`))+parseInt(o.getPropertyValue(`padding-bottom`))),c=a-(parseInt(o.getPropertyValue(`padding-right`))+parseInt(o.getPropertyValue(`padding-left`)))-n;return{cols:Math.max(2,Math.floor(c/t.css.cell.width)),rows:Math.max(1,Math.floor(s/t.css.cell.height))}}}})(),e})()))})),_ie=i(((e,t)=>{(function(n,r){typeof e==`object`&&typeof t==`object`?t.exports=r():typeof define==`function`&&define.amd?define([],r):typeof e==`object`?e.WebLinksAddon=r():n.WebLinksAddon=r()})(self,(()=>(()=>{var e={6:(e,t)=>{function n(e){try{let t=new URL(e),n=t.password&&t.username?`${t.protocol}//${t.username}:${t.password}@${t.host}`:t.username?`${t.protocol}//${t.username}@${t.host}`:`${t.protocol}//${t.host}`;return e.toLocaleLowerCase().startsWith(n.toLocaleLowerCase())}catch{return!1}}Object.defineProperty(t,`__esModule`,{value:!0}),t.LinkComputer=t.WebLinkProvider=void 0,t.WebLinkProvider=class{constructor(e,t,n,r={}){this._terminal=e,this._regex=t,this._handler=n,this._options=r}provideLinks(e,t){let n=r.computeLink(e,this._regex,this._terminal,this._handler);t(this._addCallbacks(n))}_addCallbacks(e){return e.map((e=>(e.leave=this._options.leave,e.hover=(t,n)=>{if(this._options.hover){let{range:r}=e;this._options.hover(t,n,r)}},e)))}};class r{static computeLink(e,t,i,a){let o=new RegExp(t.source,(t.flags||``)+`g`),[s,c]=r._getWindowedLineStrings(e-1,i),l=s.join(``),u,d=[];for(;u=o.exec(l);){let e=u[0];if(!n(e))continue;let[t,o]=r._mapStrIdx(i,c,0,u.index),[s,l]=r._mapStrIdx(i,t,o,e.length);if(t===-1||o===-1||s===-1||l===-1)continue;let f={start:{x:o+1,y:t+1},end:{x:l,y:s+1}};d.push({range:f,text:e,activate:a})}return d}static _getWindowedLineStrings(e,t){let n,r=e,i=e,a=0,o=``,s=[];if(n=t.buffer.active.getLine(e)){let e=n.translateToString(!0);if(n.isWrapped&&e[0]!==` `){for(a=0;(n=t.buffer.active.getLine(--r))&&a<2048&&(o=n.translateToString(!0),a+=o.length,s.push(o),n.isWrapped&&o.indexOf(` `)===-1););s.reverse()}for(s.push(e),a=0;(n=t.buffer.active.getLine(++i))&&n.isWrapped&&a<2048&&(o=n.translateToString(!0),a+=o.length,s.push(o),o.indexOf(` `)===-1););}return[s,r]}static _mapStrIdx(e,t,n,r){let i=e.buffer.active,a=i.getNullCell(),o=n;for(;r;){let e=i.getLine(t);if(!e)return[-1,-1];for(let n=o;n<e.length;++n){e.getCell(n,a);let o=a.getChars();if(a.getWidth()&&(r-=o.length||1,n===e.length-1&&o===``)){let e=i.getLine(t+1);e&&e.isWrapped&&(e.getCell(0,a),a.getWidth()===2&&(r+=1))}if(r<0)return[t,n]}t++,o=0}return[t,o]}}t.LinkComputer=r}},t={};function n(r){var i=t[r];if(i!==void 0)return i.exports;var a=t[r]={exports:{}};return e[r](a,a.exports,n),a.exports}var r={};return(()=>{var e=r;Object.defineProperty(e,`__esModule`,{value:!0}),e.WebLinksAddon=void 0;let t=n(6),i=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function a(e,t){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}e.WebLinksAddon=class{constructor(e=a,t={}){this._handler=e,this._options=t}activate(e){this._terminal=e;let n=this._options,r=n.urlRegex||i;this._linkProvider=this._terminal.registerLinkProvider(new t.WebLinkProvider(this._terminal,r,this._handler,n))}dispose(){this._linkProvider?.dispose()}}})(),r})()))})),vie=i(((e,t)=>{(function(n,r){typeof e==`object`&&typeof t==`object`?t.exports=r():typeof define==`function`&&define.amd?define([],r):typeof e==`object`?e.SearchAddon=r():n.SearchAddon=r()})(self,(()=>(()=>{var e={345:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.runAndSubscribe=t.forwardEvent=t.EventEmitter=void 0,t.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||=e=>(this._listeners.push(e),{dispose:()=>{if(!this._disposed){for(let t=0;t<this._listeners.length;t++)if(this._listeners[t]===e)return void this._listeners.splice(t,1)}}}),this._event}fire(e,t){let n=[];for(let e=0;e<this._listeners.length;e++)n.push(this._listeners[e]);for(let r=0;r<n.length;r++)n[r].call(void 0,e,t)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},t.forwardEvent=function(e,t){return e((e=>t.fire(e)))},t.runAndSubscribe=function(e,t){return t(void 0),e((e=>t(e)))}},859:(e,t)=>{function n(e){for(let t of e)t.dispose();e.length=0}Object.defineProperty(t,`__esModule`,{value:!0}),t.getDisposeArrayDisposable=t.disposeArray=t.toDisposable=t.MutableDisposable=t.Disposable=void 0,t.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(let e of this._disposables)e.dispose();this._disposables.length=0}register(e){return this._disposables.push(e),e}unregister(e){let t=this._disposables.indexOf(e);t!==-1&&this._disposables.splice(t,1)}},t.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}},t.toDisposable=function(e){return{dispose:e}},t.disposeArray=n,t.getDisposeArrayDisposable=function(e){return{dispose:()=>n(e)}}}},t={};function n(r){var i=t[r];if(i!==void 0)return i.exports;var a=t[r]={exports:{}};return e[r](a,a.exports,n),a.exports}var r={};return(()=>{var e=r;Object.defineProperty(e,`__esModule`,{value:!0}),e.SearchAddon=void 0;let t=n(345),i=n(859),a=` ~!@#$%^&*()+\`-=[]{}|\\;:"',./<>?`;class o extends i.Disposable{constructor(e){super(),this._highlightedLines=new Set,this._highlightDecorations=[],this._selectedDecoration=this.register(new i.MutableDisposable),this._linesCacheTimeoutId=0,this._linesCacheDisposables=new i.MutableDisposable,this._onDidChangeResults=this.register(new t.EventEmitter),this.onDidChangeResults=this._onDidChangeResults.event,this._highlightLimit=e?.highlightLimit??1e3}activate(e){this._terminal=e,this.register(this._terminal.onWriteParsed((()=>this._updateMatches()))),this.register(this._terminal.onResize((()=>this._updateMatches()))),this.register((0,i.toDisposable)((()=>this.clearDecorations())))}_updateMatches(){this._highlightTimeout&&window.clearTimeout(this._highlightTimeout),this._cachedSearchTerm&&this._lastSearchOptions?.decorations&&(this._highlightTimeout=setTimeout((()=>{let e=this._cachedSearchTerm;this._cachedSearchTerm=void 0,this.findPrevious(e,{...this._lastSearchOptions,incremental:!0,noScroll:!0})}),200))}clearDecorations(e){this._selectedDecoration.clear(),(0,i.disposeArray)(this._highlightDecorations),this._highlightDecorations=[],this._highlightedLines.clear(),e||(this._cachedSearchTerm=void 0)}clearActiveDecoration(){this._selectedDecoration.clear()}findNext(e,t){if(!this._terminal)throw Error(`Cannot use addon until it has been loaded`);let n=!this._lastSearchOptions||this._didOptionsChange(this._lastSearchOptions,t);this._lastSearchOptions=t,t?.decorations&&(this._cachedSearchTerm===void 0||e!==this._cachedSearchTerm||n)&&this._highlightAllMatches(e,t);let r=this._findNextAndSelect(e,t);return this._fireResults(t),this._cachedSearchTerm=e,r}_highlightAllMatches(e,t){if(!this._terminal)throw Error(`Cannot use addon until it has been loaded`);if(!e||e.length===0)return void this.clearDecorations();t||={},this.clearDecorations(!0);let n=[],r,i=this._find(e,0,0,t);for(;i&&(r?.row!==i.row||r?.col!==i.col)&&!(n.length>=this._highlightLimit);)r=i,n.push(r),i=this._find(e,r.col+r.term.length>=this._terminal.cols?r.row+1:r.row,r.col+r.term.length>=this._terminal.cols?0:r.col+1,t);for(let e of n){let n=this._createResultDecoration(e,t.decorations);n&&(this._highlightedLines.add(n.marker.line),this._highlightDecorations.push({decoration:n,match:e,dispose(){n.dispose()}}))}}_find(e,t,n,r){if(!this._terminal||!e||e.length===0)return this._terminal?.clearSelection(),void this.clearDecorations();if(n>this._terminal.cols)throw Error(`Invalid col: ${n} to search in terminal of ${this._terminal.cols} cols`);let i;this._initLinesCache();let a={startRow:t,startCol:n};if(i=this._findInLine(e,a,r),!i)for(let n=t+1;n<this._terminal.buffer.active.baseY+this._terminal.rows&&(a.startRow=n,a.startCol=0,i=this._findInLine(e,a,r),!i);n++);return i}_findNextAndSelect(e,t){if(!this._terminal||!e||e.length===0)return this._terminal?.clearSelection(),this.clearDecorations(),!1;let n=this._terminal.getSelectionPosition();this._terminal.clearSelection();let r=0,i=0;n&&(this._cachedSearchTerm===e?(r=n.end.x,i=n.end.y):(r=n.start.x,i=n.start.y)),this._initLinesCache();let a={startRow:i,startCol:r},o=this._findInLine(e,a,t);if(!o)for(let n=i+1;n<this._terminal.buffer.active.baseY+this._terminal.rows&&(a.startRow=n,a.startCol=0,o=this._findInLine(e,a,t),!o);n++);if(!o&&i!==0)for(let n=0;n<i&&(a.startRow=n,a.startCol=0,o=this._findInLine(e,a,t),!o);n++);return!o&&n&&(a.startRow=n.start.y,a.startCol=0,o=this._findInLine(e,a,t)),this._selectResult(o,t?.decorations,t?.noScroll)}findPrevious(e,t){if(!this._terminal)throw Error(`Cannot use addon until it has been loaded`);let n=!this._lastSearchOptions||this._didOptionsChange(this._lastSearchOptions,t);this._lastSearchOptions=t,t?.decorations&&(this._cachedSearchTerm===void 0||e!==this._cachedSearchTerm||n)&&this._highlightAllMatches(e,t);let r=this._findPreviousAndSelect(e,t);return this._fireResults(t),this._cachedSearchTerm=e,r}_didOptionsChange(e,t){return!!t&&(e.caseSensitive!==t.caseSensitive||e.regex!==t.regex||e.wholeWord!==t.wholeWord)}_fireResults(e){if(e?.decorations){let e=-1;if(this._selectedDecoration.value){let t=this._selectedDecoration.value.match;for(let n=0;n<this._highlightDecorations.length;n++){let r=this._highlightDecorations[n].match;if(r.row===t.row&&r.col===t.col&&r.size===t.size){e=n;break}}}this._onDidChangeResults.fire({resultIndex:e,resultCount:this._highlightDecorations.length})}}_findPreviousAndSelect(e,t){if(!this._terminal)throw Error(`Cannot use addon until it has been loaded`);if(!this._terminal||!e||e.length===0)return this._terminal?.clearSelection(),this.clearDecorations(),!1;let n=this._terminal.getSelectionPosition();this._terminal.clearSelection();let r=this._terminal.buffer.active.baseY+this._terminal.rows-1,i=this._terminal.cols;this._initLinesCache();let a={startRow:r,startCol:i},o;if(n&&(a.startRow=r=n.start.y,a.startCol=i=n.start.x,this._cachedSearchTerm!==e&&(o=this._findInLine(e,a,t,!1),o||(a.startRow=r=n.end.y,a.startCol=i=n.end.x))),o||=this._findInLine(e,a,t,!0),!o){a.startCol=Math.max(a.startCol,this._terminal.cols);for(let n=r-1;n>=0&&(a.startRow=n,o=this._findInLine(e,a,t,!0),!o);n--);}if(!o&&r!==this._terminal.buffer.active.baseY+this._terminal.rows-1)for(let n=this._terminal.buffer.active.baseY+this._terminal.rows-1;n>=r&&(a.startRow=n,o=this._findInLine(e,a,t,!0),!o);n--);return this._selectResult(o,t?.decorations,t?.noScroll)}_initLinesCache(){let e=this._terminal;this._linesCache||(this._linesCache=Array(e.buffer.active.length),this._linesCacheDisposables.value=(0,i.getDisposeArrayDisposable)([e.onLineFeed((()=>this._destroyLinesCache())),e.onCursorMove((()=>this._destroyLinesCache())),e.onResize((()=>this._destroyLinesCache()))])),window.clearTimeout(this._linesCacheTimeoutId),this._linesCacheTimeoutId=window.setTimeout((()=>this._destroyLinesCache()),15e3)}_destroyLinesCache(){this._linesCache=void 0,this._linesCacheDisposables.clear(),this._linesCacheTimeoutId&&=(window.clearTimeout(this._linesCacheTimeoutId),0)}_isWholeWord(e,t,n){return(e===0||a.includes(t[e-1]))&&(e+n.length===t.length||a.includes(t[e+n.length]))}_findInLine(e,t,n={},r=!1){let i=this._terminal,a=t.startRow,o=t.startCol;if(i.buffer.active.getLine(a)?.isWrapped)return r?void(t.startCol+=i.cols):(t.startRow--,t.startCol+=i.cols,this._findInLine(e,t,n));let s=this._linesCache?.[a];s||(s=this._translateBufferLineToStringWithWrap(a,!0),this._linesCache&&(this._linesCache[a]=s));let[c,l]=s,u=this._bufferColsToStringOffset(a,o),d=n.caseSensitive?e:e.toLowerCase(),f=n.caseSensitive?c:c.toLowerCase(),p=-1;if(n.regex){let t=RegExp(d,`g`),n;if(r)for(;n=t.exec(f.slice(0,u));)p=t.lastIndex-n[0].length,e=n[0],t.lastIndex-=e.length-1;else n=t.exec(f.slice(u)),n&&n[0].length>0&&(p=u+(t.lastIndex-n[0].length),e=n[0])}else r?u-d.length>=0&&(p=f.lastIndexOf(d,u-d.length)):p=f.indexOf(d,u);if(p>=0){if(n.wholeWord&&!this._isWholeWord(p,f,e))return;let t=0;for(;t<l.length-1&&p>=l[t+1];)t++;let r=t;for(;r<l.length-1&&p+e.length>=l[r+1];)r++;let o=p-l[t],s=p+e.length-l[r],c=this._stringLengthToBufferSize(a+t,o);return{term:e,col:c,row:a+t,size:this._stringLengthToBufferSize(a+r,s)-c+i.cols*(r-t)}}}_stringLengthToBufferSize(e,t){let n=this._terminal.buffer.active.getLine(e);if(!n)return 0;for(let e=0;e<t;e++){let r=n.getCell(e);if(!r)break;let i=r.getChars();i.length>1&&(t-=i.length-1);let a=n.getCell(e+1);a&&a.getWidth()===0&&t++}return t}_bufferColsToStringOffset(e,t){let n=this._terminal,r=e,i=0,a=n.buffer.active.getLine(r);for(;t>0&&a;){for(let e=0;e<t&&e<n.cols;e++){let t=a.getCell(e);if(!t)break;t.getWidth()&&(i+=t.getCode()===0?1:t.getChars().length)}if(r++,a=n.buffer.active.getLine(r),a&&!a.isWrapped)break;t-=n.cols}return i}_translateBufferLineToStringWithWrap(e,t){let n=this._terminal,r=[],i=[0],a=n.buffer.active.getLine(e);for(;a;){let o=n.buffer.active.getLine(e+1),s=!!o&&o.isWrapped,c=a.translateToString(!s&&t);if(s&&o){let e=a.getCell(a.length-1);e&&e.getCode()===0&&e.getWidth()===1&&o.getCell(0)?.getWidth()===2&&(c=c.slice(0,-1))}if(r.push(c),!s)break;i.push(i[i.length-1]+c.length),e++,a=o}return[r.join(``),i]}_selectResult(e,t,n){let r=this._terminal;if(this._selectedDecoration.clear(),!e)return r.clearSelection(),!1;if(r.select(e.col,e.row,e.size),t){let n=r.registerMarker(-r.buffer.active.baseY-r.buffer.active.cursorY+e.row);if(n){let a=r.registerDecoration({marker:n,x:e.col,width:e.size,backgroundColor:t.activeMatchBackground,layer:`top`,overviewRulerOptions:{color:t.activeMatchColorOverviewRuler}});if(a){let r=[];r.push(n),r.push(a.onRender((e=>this._applyStyles(e,t.activeMatchBorder,!0)))),r.push(a.onDispose((()=>(0,i.disposeArray)(r)))),this._selectedDecoration.value={decoration:a,match:e,dispose(){a.dispose()}}}}}if(!n&&(e.row>=r.buffer.active.viewportY+r.rows||e.row<r.buffer.active.viewportY)){let t=e.row-r.buffer.active.viewportY;t-=Math.floor(r.rows/2),r.scrollLines(t)}return!0}_applyStyles(e,t,n){e.classList.contains(`xterm-find-result-decoration`)||(e.classList.add(`xterm-find-result-decoration`),t&&(e.style.outline=`1px solid ${t}`)),n&&e.classList.add(`xterm-find-active-result-decoration`)}_createResultDecoration(e,t){let n=this._terminal,r=n.registerMarker(-n.buffer.active.baseY-n.buffer.active.cursorY+e.row);if(!r)return;let a=n.registerDecoration({marker:r,x:e.col,width:e.size,backgroundColor:t.matchBackground,overviewRulerOptions:this._highlightedLines.has(r.line)?void 0:{color:t.matchOverviewRuler,position:`center`}});if(a){let e=[];e.push(r),e.push(a.onRender((e=>this._applyStyles(e,t.matchBorder,!1)))),e.push(a.onDispose((()=>(0,i.disposeArray)(e))))}return a}}e.SearchAddon=o})(),r})()))})),yie=i(((e,t)=>{(function(n,r){typeof e==`object`&&typeof t==`object`?t.exports=r():typeof define==`function`&&define.amd?define([],r):typeof e==`object`?e.Unicode11Addon=r():n.Unicode11Addon=r()})(e,(()=>(()=>{var e={433:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.UnicodeV11=void 0;let r=n(938),i=[[768,879],[1155,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1541],[1552,1562],[1564,1564],[1611,1631],[1648,1648],[1750,1757],[1759,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2045,2045],[2070,2073],[2075,2083],[2085,2087],[2089,2093],[2137,2139],[2259,2306],[2362,2362],[2364,2364],[2369,2376],[2381,2381],[2385,2391],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2558,2558],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2641,2641],[2672,2673],[2677,2677],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2810,2815],[2817,2817],[2876,2876],[2879,2879],[2881,2884],[2893,2893],[2902,2902],[2914,2915],[2946,2946],[3008,3008],[3021,3021],[3072,3072],[3076,3076],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3170,3171],[3201,3201],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3328,3329],[3387,3388],[3393,3396],[3405,3405],[3426,3427],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3981,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4151],[4153,4154],[4157,4158],[4184,4185],[4190,4192],[4209,4212],[4226,4226],[4229,4230],[4237,4237],[4253,4253],[4448,4607],[4957,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6158],[6277,6278],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6683,6683],[6742,6742],[6744,6750],[6752,6752],[6754,6754],[6757,6764],[6771,6780],[6783,6783],[6832,6846],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7040,7041],[7074,7077],[7080,7081],[7083,7085],[7142,7142],[7144,7145],[7149,7149],[7151,7153],[7212,7219],[7222,7223],[7376,7378],[7380,7392],[7394,7400],[7405,7405],[7412,7412],[7416,7417],[7616,7673],[7675,7679],[8203,8207],[8234,8238],[8288,8292],[8294,8303],[8400,8432],[11503,11505],[11647,11647],[11744,11775],[12330,12333],[12441,12442],[42607,42610],[42612,42621],[42654,42655],[42736,42737],[43010,43010],[43014,43014],[43019,43019],[43045,43046],[43204,43205],[43232,43249],[43263,43263],[43302,43309],[43335,43345],[43392,43394],[43443,43443],[43446,43449],[43452,43453],[43493,43493],[43561,43566],[43569,43570],[43573,43574],[43587,43587],[43596,43596],[43644,43644],[43696,43696],[43698,43700],[43703,43704],[43710,43711],[43713,43713],[43756,43757],[43766,43766],[44005,44005],[44008,44008],[44013,44013],[64286,64286],[65024,65039],[65056,65071],[65279,65279],[65529,65531]],a=[[66045,66045],[66272,66272],[66422,66426],[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[68325,68326],[68900,68903],[69446,69456],[69633,69633],[69688,69702],[69759,69761],[69811,69814],[69817,69818],[69821,69821],[69837,69837],[69888,69890],[69927,69931],[69933,69940],[70003,70003],[70016,70017],[70070,70078],[70089,70092],[70191,70193],[70196,70196],[70198,70199],[70206,70206],[70367,70367],[70371,70378],[70400,70401],[70459,70460],[70464,70464],[70502,70508],[70512,70516],[70712,70719],[70722,70724],[70726,70726],[70750,70750],[70835,70840],[70842,70842],[70847,70848],[70850,70851],[71090,71093],[71100,71101],[71103,71104],[71132,71133],[71219,71226],[71229,71229],[71231,71232],[71339,71339],[71341,71341],[71344,71349],[71351,71351],[71453,71455],[71458,71461],[71463,71467],[71727,71735],[71737,71738],[72148,72151],[72154,72155],[72160,72160],[72193,72202],[72243,72248],[72251,72254],[72263,72263],[72273,72278],[72281,72283],[72330,72342],[72344,72345],[72752,72758],[72760,72765],[72767,72767],[72850,72871],[72874,72880],[72882,72883],[72885,72886],[73009,73014],[73018,73018],[73020,73021],[73023,73029],[73031,73031],[73104,73105],[73109,73109],[73111,73111],[73459,73460],[78896,78904],[92912,92916],[92976,92982],[94031,94031],[94095,94098],[113821,113822],[113824,113827],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[121344,121398],[121403,121452],[121461,121461],[121476,121476],[121499,121503],[121505,121519],[122880,122886],[122888,122904],[122907,122913],[122915,122916],[122918,122922],[123184,123190],[123628,123631],[125136,125142],[125252,125258],[917505,917505],[917536,917631],[917760,917999]],o=[[4352,4447],[8986,8987],[9001,9002],[9193,9196],[9200,9200],[9203,9203],[9725,9726],[9748,9749],[9800,9811],[9855,9855],[9875,9875],[9889,9889],[9898,9899],[9917,9918],[9924,9925],[9934,9934],[9940,9940],[9962,9962],[9970,9971],[9973,9973],[9978,9978],[9981,9981],[9989,9989],[9994,9995],[10024,10024],[10060,10060],[10062,10062],[10067,10069],[10071,10071],[10133,10135],[10160,10160],[10175,10175],[11035,11036],[11088,11088],[11093,11093],[11904,11929],[11931,12019],[12032,12245],[12272,12283],[12288,12329],[12334,12350],[12353,12438],[12443,12543],[12549,12591],[12593,12686],[12688,12730],[12736,12771],[12784,12830],[12832,12871],[12880,19903],[19968,42124],[42128,42182],[43360,43388],[44032,55203],[63744,64255],[65040,65049],[65072,65106],[65108,65126],[65128,65131],[65281,65376],[65504,65510]],s=[[94176,94179],[94208,100343],[100352,101106],[110592,110878],[110928,110930],[110948,110951],[110960,111355],[126980,126980],[127183,127183],[127374,127374],[127377,127386],[127488,127490],[127504,127547],[127552,127560],[127568,127569],[127584,127589],[127744,127776],[127789,127797],[127799,127868],[127870,127891],[127904,127946],[127951,127955],[127968,127984],[127988,127988],[127992,128062],[128064,128064],[128066,128252],[128255,128317],[128331,128334],[128336,128359],[128378,128378],[128405,128406],[128420,128420],[128507,128591],[128640,128709],[128716,128716],[128720,128722],[128725,128725],[128747,128748],[128756,128762],[128992,129003],[129293,129393],[129395,129398],[129402,129442],[129445,129450],[129454,129482],[129485,129535],[129648,129651],[129656,129658],[129664,129666],[129680,129685],[131072,196605],[196608,262141]],c;function l(e,t){let n,r=0,i=t.length-1;if(e<t[0][0]||e>t[i][1])return!1;for(;i>=r;)if(n=r+i>>1,e>t[n][1])r=n+1;else{if(!(e<t[n][0]))return!0;i=n-1}return!1}t.UnicodeV11=class{constructor(){if(this.version=`11`,!c){c=new Uint8Array(65536),c.fill(1),c[0]=0,c.fill(0,1,32),c.fill(0,127,160);for(let e=0;e<i.length;++e)c.fill(0,i[e][0],i[e][1]+1);for(let e=0;e<o.length;++e)c.fill(2,o[e][0],o[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?c[e]:l(e,a)?0:l(e,s)?2:1}charProperties(e,t){let n=this.wcwidth(e),i=n===0&&t!==0;if(i){let e=r.UnicodeService.extractWidth(t);e===0?i=!1:e>n&&(n=e)}return r.UnicodeService.createPropertyValue(0,n,i)}}},345:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.runAndSubscribe=t.forwardEvent=t.EventEmitter=void 0,t.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||=e=>(this._listeners.push(e),{dispose:()=>{if(!this._disposed){for(let t=0;t<this._listeners.length;t++)if(this._listeners[t]===e)return void this._listeners.splice(t,1)}}}),this._event}fire(e,t){let n=[];for(let e=0;e<this._listeners.length;e++)n.push(this._listeners[e]);for(let r=0;r<n.length;r++)n[r].call(void 0,e,t)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},t.forwardEvent=function(e,t){return e((e=>t.fire(e)))},t.runAndSubscribe=function(e,t){return t(void 0),e((e=>t(e)))}},490:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.UnicodeV6=void 0;let r=n(938),i=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],a=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],o;t.UnicodeV6=class{constructor(){if(this.version=`6`,!o){o=new Uint8Array(65536),o.fill(1),o[0]=0,o.fill(0,1,32),o.fill(0,127,160),o.fill(2,4352,4448),o[9001]=2,o[9002]=2,o.fill(2,11904,42192),o[12351]=1,o.fill(2,44032,55204),o.fill(2,63744,64256),o.fill(2,65040,65050),o.fill(2,65072,65136),o.fill(2,65280,65377),o.fill(2,65504,65511);for(let e=0;e<i.length;++e)o.fill(0,i[e][0],i[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?o[e]:function(e,t){let n,r=0,i=t.length-1;if(e<t[0][0]||e>t[i][1])return!1;for(;i>=r;)if(n=r+i>>1,e>t[n][1])r=n+1;else{if(!(e<t[n][0]))return!0;i=n-1}return!1}(e,a)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),i=n===0&&t!==0;if(i){let e=r.UnicodeService.extractWidth(t);e===0?i=!1:e>n&&(n=e)}return r.UnicodeService.createPropertyValue(0,n,i)}}},938:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.UnicodeService=void 0;let r=n(345),i=n(490);class a{static extractShouldJoin(e){return(1&e)!=0}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,t,n=!1){return(16777215&e)<<3|(3&t)<<1|!!n}constructor(){this._providers=Object.create(null),this._active=``,this._onChange=new r.EventEmitter,this.onChange=this._onChange.event;let e=new i.UnicodeV6;this.register(e),this._active=e.version,this._activeProvider=e}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(e){if(!this._providers[e])throw Error(`unknown Unicode version "${e}"`);this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)}register(e){this._providers[e.version]=e}wcwidth(e){return this._activeProvider.wcwidth(e)}getStringCellWidth(e){let t=0,n=0,r=e.length;for(let i=0;i<r;++i){let o=e.charCodeAt(i);if(55296<=o&&o<=56319){if(++i>=r)return t+this.wcwidth(o);let n=e.charCodeAt(i);56320<=n&&n<=57343?o=1024*(o-55296)+n-56320+65536:t+=this.wcwidth(n)}let s=this.charProperties(o,n),c=a.extractWidth(s);a.extractShouldJoin(s)&&(c-=a.extractWidth(n)),t+=c,n=s}return t}charProperties(e,t){return this._activeProvider.charProperties(e,t)}}t.UnicodeService=a}},t={};function n(r){var i=t[r];if(i!==void 0)return i.exports;var a=t[r]={exports:{}};return e[r](a,a.exports,n),a.exports}var r={};return(()=>{var e=r;Object.defineProperty(e,`__esModule`,{value:!0}),e.Unicode11Addon=void 0;let t=n(433);e.Unicode11Addon=class{activate(e){e.unicode.register(new t.UnicodeV11)}dispose(){}}})(),r})()))})),bie=hie(),xie=gie(),Sie=_ie(),Cie=vie(),wie=yie(),h9=new Map,g9=new Map;function _9(e){let t=h9.get(e);return t||(t={openPreExec:null,completed:[],cwd:null,promptRows:[]},h9.set(e,t)),t}function Tie(e){let t=g9.get(e);if(!t)return;let n=_9(e);for(let e of t)try{e(n)}catch{}}function Eie(e,t,n){let r=_9(e);switch(t.kind){case`prompt-start`:r.promptRows.push({ts:t.ts,row:n?.row??null,exitCode:null}),r.promptRows.length>1e3&&r.promptRows.shift();break;case`pre-exec`:r.openPreExec={startedAt:t.ts};break;case`post-exec`:{let e=t.payload?.exitCode??null,n=r.openPreExec?.startedAt??t.ts;r.completed.push({startedAt:n,finishedAt:t.ts,exitCode:e});let i=r.promptRows[r.promptRows.length-1];i&&(i.exitCode=e),r.openPreExec=null,r.completed.length>1e3&&r.completed.shift();break}case`cwd`:r.cwd=t.payload?.path??null;break}Tie(e)}function v9(e,t){let n=g9.get(e);return n||(n=new Set,g9.set(e,n)),n.add(t),()=>{n.delete(t)}}function y9(e){return _9(e)}function b9(e){h9.delete(e),g9.delete(e)}var x9=new Map,Die=5e3;function Oie(){return typeof document<`u`&&!document.hasFocus()}async function kie(e,t){let n=`${e}:${t.command??``}`,r=Date.now();if(r-(x9.get(n)??0)<Die)return;x9.set(n,r);let i=t.command?am.t(`terminal:notifications.commandFinishedNamed`,{command:Aie(t.command,50)}):am.t(`terminal:notifications.commandFinished`),a=am.t(`terminal:notifications.finishedBody`,{code:t.exitCode??`?`,elapsed:jie(t.elapsedMs)});if(zV())try{let e=await BV(`@tauri-apps/plugin-notification`);if(e?.sendNotification){let t=await e.isPermissionGranted?.()??!0;if(t||=await e.requestPermission?.()===`granted`,t){await e.sendNotification({title:i,body:a});return}}}catch{}try{if(typeof Notification>`u`||Notification.permission===`default`&&await Notification.requestPermission().catch(()=>`denied`)!==`granted`||Notification.permission!==`granted`)return;new Notification(i,{body:a})}catch{}}function Aie(e,t){return e.length<=t?e:e.slice(0,t-1)+`…`}function jie(e){if(e<6e4)return am.t(`terminal:duration.seconds`,{seconds:(e/1e3).toFixed(1)});let t=Math.floor(e/6e4),n=Math.floor(e%6e4/1e3);return am.t(`terminal:duration.minutesSeconds`,{minutes:t,seconds:n})}async function Mie(e,t){await $(`plugin:clipboard-manager|write_text`,{label:t?.label,text:e})}async function Nie(){return await $(`plugin:clipboard-manager|read_text`)}async function S9(){if(zV())try{let e=await Nie();return typeof e==`string`?e:null}catch{return null}try{if(typeof navigator<`u`&&navigator.clipboard?.readText)return await navigator.clipboard.readText()||null}catch{}return null}async function C9(e){if(zV())try{return await Mie(e),!0}catch{return!1}try{if(typeof navigator<`u`&&navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}return!1}var w9=(0,H.createContext)(null);function T9(e){return`specrails-desktop:terminal-panel:${e}`}function E9(e){try{let t=localStorage.getItem(T9(e));if(!t)return null;let n=JSON.parse(t);if(!n)return null;let r=n.visibility,i=n.userHeight;return r!==`hidden`&&r!==`restored`&&r!==`maximized`||typeof i!=`number`||!Number.isFinite(i)?null:{visibility:r,userHeight:i}}catch{return null}}function Pie(e,t){try{localStorage.setItem(T9(e),JSON.stringify(t))}catch{}}function D9(e){return{visibility:e?.visibility??`hidden`,userHeight:e?.userHeight??320,sessions:[],activeId:null}}function Fie(){let e=document.getElementById(`specrails-terminal-host`);return e||(e=document.createElement(`div`),e.id=`specrails-terminal-host`,e.style.position=`fixed`,e.style.left=`0`,e.style.top=`0`,e.style.width=`0`,e.style.height=`0`,e.style.overflow=`hidden`,e.style.visibility=`hidden`,e.style.pointerEvents=`none`,e.setAttribute(`aria-hidden`,`true`),document.body.appendChild(e),e)}function Iie({children:e,activeProjectId:t}){let[n,r]=(0,H.useState)({}),i=(0,H.useRef)(n);i.current=n;let a=(0,H.useRef)(new Map),s=(0,H.useRef)(new Map),c=(0,H.useRef)(null);(0,H.useEffect)(()=>(c.current=Fie(),()=>{for(let e of a.current.values())j9(e);a.current.clear(),s.current.clear()}),[]);let l=zU()?.theme??null;(0,H.useEffect)(()=>{if(l)for(let e of a.current.values())try{e.term.options.theme=l.xterm}catch{}},[l]);let u=(0,H.useCallback)((e,t)=>{r(n=>{let r=n[e]??D9(E9(e)),i=t(r);return i===r?n:((i.visibility!==r.visibility||i.userHeight!==r.userHeight)&&Pie(e,{visibility:i.visibility,userHeight:i.userHeight}),{...n,[e]:i})})},[]),d=(0,H.useCallback)(e=>{r(t=>t[e]?t:{...t,[e]:D9(E9(e))})},[]),f=(0,H.useCallback)(e=>i.current[e]??D9(E9(e)),[]),p=(0,H.useCallback)((e,t)=>{u(e,e=>e.visibility===t?e:{...e,visibility:t})},[u]),m=(0,H.useCallback)(e=>{u(e,e=>({...e,visibility:e.visibility===`hidden`?`restored`:`hidden`}))},[u]),h=(0,H.useCallback)((e,t)=>{u(e,e=>e.userHeight===t?e:{...e,userHeight:t})},[u]),g=(0,H.useCallback)((e,t)=>{u(e,e=>e.activeId===t?e:{...e,activeId:t})},[u]),_=(0,H.useRef)(t);_.current=t,(0,H.useEffect)(()=>{if(!t)return;d(t);let e=!1;return(async()=>{try{let n=await fetch(`${o}/api/projects/${t}/terminals`);if(!n.ok)return;let r=await n.json();if(e)return;u(t,e=>{let t=new Set(r.sessions.map(e=>e.id));for(let n of e.sessions.map(e=>e.id))if(!t.has(n)){let e=a.current.get(n);e&&(j9(e),a.current.delete(n),s.current.delete(n),b9(n))}let n=r.sessions.map(t=>{let n=e.sessions.find(e=>e.id===t.id);return n?{...n,...t}:t}),i=n.find(t=>t.id===e.activeId)?.id??n[0]?.id??null;for(let e of n)a.current.has(e.id)||A9(e.projectId,e.id,e.cols,e.rows,a.current,s.current,c.current);return{...e,sessions:n,activeId:i}})}catch{}})(),()=>{e=!0}},[t,d,u]);let v=(0,H.useCallback)(async(e,t)=>{let n=t?.cols??80,r=t?.rows??24;try{let i=await fetch(`${o}/api/projects/${e}/terminals`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({cols:n,rows:r,name:t?.name})});if(!i.ok){let e=``;try{e=(await i.json())?.error??``}catch{}return q.error(e===`terminal_limit_exceeded`?am.t(`terminal:errors.limitReached`,{max:10}):e===`terminal_spawn_failed`?am.t(`terminal:errors.spawnFailed`):e===`terminal_name_invalid`?am.t(`terminal:errors.invalidName`):am.t(`terminal:errors.openFailed`)),null}let l=(await i.json()).session;return A9(e,l.id,l.cols,l.rows,a.current,s.current,c.current,vW,void 0,void 0,!0),u(e,e=>({...e,sessions:[...e.sessions,l],activeId:l.id})),l}catch{return q.error(am.t(`terminal:errors.serverUnreachable`)),null}},[u]),y=(0,H.useCallback)(async(e,t,n)=>{let r=await v(e,n);if(!r)return null;let i=a.current.get(r.id);if(!i)return r;let o=()=>{let e=i.ws;if(e)try{e.send(new TextEncoder().encode(t))}catch{}};return i.ws&&i.ws.readyState===WebSocket.OPEN?setTimeout(o,50):i.ws&&i.ws.addEventListener(`open`,()=>setTimeout(o,50),{once:!0}),r},[]),b=(0,H.useCallback)((e,t)=>{let n=a.current.get(e);if(!n?.ws||n.ws.readyState!==WebSocket.OPEN)return!1;try{n.ws.send(new TextEncoder().encode(t));try{n.term.focus()}catch{}return!0}catch{return!1}},[]),x=(0,H.useCallback)(async(e,t,n)=>{try{let r=await fetch(`${o}/api/projects/${e}/terminals/${t}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:n})});if(!r.ok)return!1;let i=await r.json();return u(e,e=>({...e,sessions:e.sessions.map(e=>e.id===t?{...e,name:i.session.name}:e)})),!0}catch{return!1}},[u]),S=(0,H.useCallback)(async(e,t)=>{let n=a.current.get(t);n&&(j9(n),a.current.delete(t),s.current.delete(t),b9(t)),u(e,e=>{let n=e.sessions.filter(e=>e.id!==t),r=e.activeId===t?n[0]?.id??null:e.activeId;return{...e,sessions:n,activeId:r}});try{await fetch(`${o}/api/projects/${e}/terminals/${t}`,{method:`DELETE`})}catch{}},[u]),C=(0,H.useCallback)(e=>{let t=i.current[e];if(!t?.activeId)return;let n=a.current.get(t.activeId);if(n?.attached)try{n.term.focus()}catch{}},[]),w=(0,H.useCallback)(e=>{for(let[t,n]of s.current.entries()){if(n!==e)continue;let r=a.current.get(t);r&&(j9(r),a.current.delete(t)),s.current.delete(t)}r(t=>{if(!t[e])return t;let{[e]:n,...r}=t;return r});try{localStorage.removeItem(T9(e))}catch{}},[]),T=(0,H.useCallback)(e=>a.current.get(e)?.container??null,[]),E=(0,H.useCallback)(e=>{let t=a.current.get(e);if(!t)return;let n=!t.term.element||t.term.element.parentElement!==t.container;if(t.attached=!0,n){try{t.term.open(t.container)}catch{}let e=t.settings.renderMode;(e===`webgl`||e===`auto`&&Uie())&&!t.webgl&&Hie(t.term).then(e=>{e&&(t.webgl=e)})}try{t.fit.fit()}catch{}try{t.term.focus()}catch{}let r=t.term.cols,i=t.term.rows;if(t.ws&&t.ws.readyState===WebSocket.OPEN)try{t.ws.send(JSON.stringify({type:`resize`,cols:r,rows:i}))}catch{}},[]),D=(0,H.useCallback)(e=>{let t=a.current.get(e);if(!(!t||!t.attached)){try{t.fit.fit()}catch{}if(t.ws&&t.ws.readyState===WebSocket.OPEN)try{t.ws.send(JSON.stringify({type:`resize`,cols:t.term.cols,rows:t.term.rows}))}catch{}}},[]),O=(0,H.useCallback)((e,t)=>{let n=a.current.get(e);return n?(n.markListeners.add(t),()=>{n.markListeners.delete(t)}):()=>{}},[]),k=(0,H.useCallback)(e=>a.current.get(e)?.currentCwd??null,[]),A=(0,H.useCallback)(e=>a.current.get(e)?.search??null,[]),j=(0,H.useCallback)(e=>a.current.get(e)?.term??null,[]),M=(0,H.useCallback)((e,t)=>{let n=a.current.get(e);return n?(n.openSearchListeners.add(t),()=>{n.openSearchListeners.delete(t)}):()=>{}},[]),N=(0,H.useMemo)(()=>({states:n,getState:f,ensureProject:d,setVisibility:p,togglePanel:m,setUserHeight:h,setActive:g,create:v,createAndType:y,writeToSession:b,rename:x,kill:S,focusActive:C,disposeProject:w,getContainer:T,notifyAdopted:E,refitActive:D,subscribeMarks:O,getCwd:k,getSearchAddon:A,subscribeOpenSearch:M,getTerminalInstance:j}),[n,f,d,p,m,h,g,v,y,b,x,S,C,w,T,E,D,O,k,A,M,j]);return(0,Y.jsx)(w9.Provider,{value:N,children:e})}var Lie={states:{},getState:e=>D9(null),ensureProject:()=>{},setVisibility:()=>{},togglePanel:()=>{},setUserHeight:()=>{},setActive:()=>{},create:async()=>null,createAndType:async()=>null,writeToSession:()=>!1,rename:async()=>!1,kill:async()=>{},focusActive:()=>{},disposeProject:()=>{},getContainer:()=>null,notifyAdopted:()=>{},refitActive:()=>{},subscribeMarks:()=>()=>{},getCwd:()=>null,getSearchAddon:()=>null,subscribeOpenSearch:()=>()=>{},getTerminalInstance:()=>null};function O9(){return(0,H.useContext)(w9)??Lie}function Rie(e){let t=O9();return e?t.states[e]??D9(E9(e)):D9(null)}function k9(e,t,n,r,i){let a=e.get(t);if(!a)return;let o=a.term.options.fontSize??vW.fontSize,s;if(r===`reset`)s=a.settings.fontSize,i&&i(n,{fontSize:null});else{let e=o+r;if(e<8||e>32)return;s=yW(e),i&&i(n,{fontSize:s})}if(s!==o)try{a.term.options.fontSize=s,a.fit.fit()}catch{}}function zie(e,t,n){let r=e.get(t);if(!r)return;let{promptRows:i}=y9(t);if(i.length===0)return;let a=r.term.buffer.active.viewportY,o=null;if(n===`prev`)for(let e=i.length-1;e>=0;e--){let t=i[e].row;if(t!=null&&t<a){o=t;break}}else for(let e of i){let t=e.row;if(t!=null&&t>a){o=t;break}}if(o!=null)try{r.term.scrollToLine(o)}catch{}}function A9(e,t,n,r,i,a,o,s=vW,l,u,d=!1){let f=i.get(t);if(f)return f;let p=document.createElement(`div`);p.style.width=`100%`,p.style.height=`100%`,p.className=`specrails-xterm-container`;let m=new bie.Terminal({cols:n,rows:r,fontFamily:s.fontFamily,fontSize:s.fontSize,theme:AU().xterm,cursorBlink:!0,scrollback:1e4,allowProposedApi:!0}),h=new xie.FitAddon,g=new Sie.WebLinksAddon,_=new Cie.SearchAddon;m.loadAddon(h),m.loadAddon(g),m.loadAddon(_),m.attachCustomKeyEventHandler(n=>{if(n.type!==`keydown`||!(typeof navigator<`u`&&/Mac/i.test(navigator.platform||``)?n.metaKey:n.ctrlKey))return!0;let r=n.key;if(r===`c`||r===`C`){let e=m.getSelection();return e.length===0?!0:(C9(e),n.preventDefault(),!1)}if(r===`v`||r===`V`)return S9().then(e=>{if(e)try{m.paste(e)}catch{}}),n.preventDefault(),!1;if(r===`k`||r===`K`){try{m.clear()}catch{}return n.preventDefault(),!1}if(r===`f`||r===`F`){n.preventDefault();let e=i.get(t);if(e)for(let t of e.openSearchListeners)try{t()}catch{}return!1}return r===`=`||r===`+`?(n.preventDefault(),k9(i,t,e,1,u),!1):r===`-`||r===`_`?(n.preventDefault(),k9(i,t,e,-1,u),!1):r===`0`?(n.preventDefault(),k9(i,t,e,`reset`,u),!1):r===`ArrowUp`||r===`ArrowDown`?(n.preventDefault(),zie(i,t,r===`ArrowUp`?`prev`:`next`),!1):!0});try{let e=new wie.Unicode11Addon;m.loadAddon(e),m.unicode.activeVersion=`11`}catch{}s.imageRendering&&Bie(m),Vie(m),o&&o.appendChild(p);let v=`${xO||(typeof window<`u`?`${window.location.protocol===`https:`?`wss:`:`ws:`}//${window.location.host}`:`ws://localhost:4200`)}/ws/terminal/${t}?projectId=${encodeURIComponent(e)}`,y=c(),b=y?new WebSocket(v,[`specrails-desktop`,y]):new WebSocket(v);b.binaryType=`arraybuffer`;let x=[];b.onmessage=e=>{if(typeof e.data==`string`){try{let n=JSON.parse(e.data);if(n?.type===`ready`)return;if(n?.type===`exit`){let e=i.get(t);e&&S(e,n.code??null,!!n.early);return}if(n?.type===`mark`&&typeof n.kind==`string`&&typeof n.ts==`number`){let e=i.get(t);if(e){n.kind===`cwd`&&n.payload?.path&&(e.currentCwd=n.payload.path);let r={type:`mark`,kind:n.kind,payload:n.payload,ts:n.ts,sessionId:t},i=e.term.buffer.active,a=n.kind===`prompt-start`?i.cursorY+i.viewportY:null,o=n.kind===`post-exec`?y9(t).openPreExec?.startedAt??null:null;if(Eie(t,n,{row:a}),n.kind===`post-exec`&&o!=null&&Oie()){let r=n.ts-o,i=e.settings.longCommandThresholdMs;e.settings.notifyOnCompletion&&r>=i&&kie(t,{command:null,exitCode:n.payload?.exitCode??null,elapsedMs:r})}for(let t of e.markListeners)try{t(r)}catch{}l&&l(r)}}}catch{}return}let n=i.get(t);n&&(n.gotData=!0);let r=new Uint8Array(e.data);try{m.write(r)}catch{}};let S=(e,t,n)=>{if(!e.exitShown){e.exitShown=!0;try{let n=t===null?am.t(`terminal:session.processExited`):am.t(`terminal:session.processExitedWithCode`,{code:t});e.term.write(`\r\n\x1b[2m${n}\x1b[0m\r\n`)}catch{}n&&!e.gotUserInput&&q.error(am.t(`terminal:errors.exitedImmediately`))}};b.onclose=e=>{let n=i.get(t);if(!n||n.disposing||n.exitShown)return;let r=(typeof e?.reason==`string`?e.reason:``)===`pty_exit_early`,a=n.openedAt>0&&Date.now()-n.openedAt<3e3&&!n.gotData&&!n.gotUserInput;S(n,null,r||a)};let C=m.onData(e=>{let n=i.get(t);if(n&&(n.gotUserInput=!0),b.readyState===WebSocket.OPEN)try{b.send(new TextEncoder().encode(e))}catch{}});x.push(()=>C.dispose());let w=null,T=()=>{if(p.isConnected){try{h.fit()}catch{return}if(b.readyState===WebSocket.OPEN)try{b.send(JSON.stringify({type:`resize`,cols:m.cols,rows:m.rows}))}catch{}}},E=()=>{w&&clearTimeout(w),w=setTimeout(()=>{w=null,T()},120)};b.onopen=()=>{let e=i.get(t);e&&(e.openedAt=Date.now()),T()};let D=new ResizeObserver(E);D.observe(p),x.push(()=>{w&&clearTimeout(w),D.disconnect()});let O={term:m,fit:h,webLinks:g,search:_,webgl:null,settings:s,container:p,ws:b,attached:!1,disposers:x,openedAt:0,gotData:!1,gotUserInput:!1,disposing:!1,exitShown:!1,currentCwd:null,markListeners:new Set,openSearchListeners:new Set};return i.set(t,O),a.set(t,e),O}async function Bie(t){try{let n=(await a(()=>import(`./addon-image-CwoZj17F.js`).then(t=>e(t.default,1)),__vite__mapDeps([35,1]))).ImageAddon,r=new n({pixelLimit:8e6});t.loadAddon(r)}catch{}}async function Vie(t){try{let n=(await a(()=>import(`./addon-ligatures-CWDrED80.js`).then(t=>e(t.default,1)),__vite__mapDeps([36,1]))).LigaturesAddon;t.loadAddon(new n)}catch{}}async function Hie(t){try{let n=(await a(()=>import(`./addon-webgl-DMbGeI_u.js`).then(t=>e(t.default,1)),__vite__mapDeps([37,1]))).WebglAddon,r=new n;return r.onContextLoss(()=>{try{r.dispose()}catch{}}),t.loadAddon(r),r}catch{return null}}function Uie(){try{let e=document.createElement(`canvas`);return!!(e.getContext(`webgl2`)||e.getContext(`experimental-webgl2`))}catch{return!1}}function j9(e){e.disposing=!0;for(let t of e.disposers)try{t()}catch{}e.disposers=[],e.markListeners.clear(),e.openSearchListeners.clear();try{e.ws?.close(1e3,`client_dispose`)}catch{}e.ws=null;try{e.webgl?.dispose()}catch{}e.webgl=null;try{e.term.dispose()}catch{}try{e.container.remove()}catch{}}var M9={jobs:[],activeJobId:null,paused:!1};function N9(e){let[t,n]=(0,H.useState)([]),[r,i]=(0,H.useState)({}),[a,o]=(0,H.useState)(``),[s,c]=(0,H.useState)([]),[l,u]=(0,H.useState)([]),[d,f]=(0,H.useState)(M9),p=(0,H.useRef)(e);p.current=e;let m=(0,H.useRef)(new Map),h=(0,H.useRef)(void 0);(0,H.useEffect)(()=>{if(h.current&&h.current,h.current=e,e){let t=m.current.get(e);t?(n(t.phaseDefinitions),i(t.phases),o(t.projectName),u(t.recentJobs),f(t.queueState)):(n([]),i({}),o(``),u([]),f(M9))}c([])},[e]);let g=(0,H.useCallback)(e=>{let t=e,r=p.current;if(!(r&&t.projectId&&t.projectId!==r))if(t.type===`init`){let e=t.projectName??``,a=t.phaseDefinitions??[],s={};for(let e of a)s[e.key]=t.phases?.[e.key]??`idle`;let l=t.recentJobs??[],d=t.queue??M9;o(e),n(a),i(s),c(t.logBuffer??[]),u(l),f(d),r&&m.current.set(r,{phaseDefinitions:a,phases:s,projectName:e,recentJobs:l,queueState:d})}else t.type===`phase`?i(e=>({...e,[t.phase]:t.state})):t.type===`log`?c(e=>[...e,{source:t.source,line:t.line,timestamp:t.timestamp,processId:t.processId}]):t.type===`queue`&&f({jobs:t.jobs??[],activeJobId:t.activeJobId??null,paused:t.paused??!1})},[]),{registerHandler:_,unregisterHandler:v,connectionStatus:y}=df();return(0,H.useLayoutEffect)(()=>(_(`pipeline`,g),()=>v(`pipeline`)),[g,_,v]),(0,H.useEffect)(()=>{if(!e)return;let t=!1;async function r(){try{let e=await fetch(`${af()}/state`);if(t||!e.ok)return;let r=await e.json();if(t)return;if(r.projectName&&o(r.projectName),r.phaseDefinitions){n(r.phaseDefinitions);let e={};for(let t of r.phaseDefinitions)e[t.key]=r.phases?.[t.key]??`idle`;i(e)}r.recentJobs&&u(r.recentJobs),r.queue&&f(r.queue)}catch{}}return r(),()=>{t=!0}},[e]),{phases:r,phaseDefinitions:t,projectName:a,logLines:s,connectionStatus:y,recentJobs:l,queueState:d}}function P9(){return new L9(tq(),window.__TAURI_INTERNALS__.metadata.currentWebview.label,{skip:!0})}async function F9(){return $(`plugin:webview|get_all_webviews`).then(e=>e.map(e=>new L9(new iq(e.windowLabel,{skip:!0}),e.label,{skip:!0})))}var I9=[`tauri://created`,`tauri://error`],L9=class{constructor(e,t,n){this.window=e,this.label=t,this.listeners=Object.create(null),n?.skip||$(`plugin:webview|create_webview`,{windowLabel:e.label,options:{...n,label:t}}).then(async()=>this.emit(`tauri://created`)).catch(async e=>this.emit(`tauri://error`,e))}static async getByLabel(e){return(await F9()).find(t=>t.label===e)??null}static getCurrent(){return P9()}static async getAll(){return F9()}async listen(e,t){return this._handleTauriEvent(e,t)?()=>{let n=this.listeners[e];n.splice(n.indexOf(t),1)}:JK(e,t,{target:{kind:`Webview`,label:this.label}})}async once(e,t){return this._handleTauriEvent(e,t)?()=>{let n=this.listeners[e];n.splice(n.indexOf(t),1)}:YK(e,t,{target:{kind:`Webview`,label:this.label}})}async emit(e,t){if(I9.includes(e)){for(let n of this.listeners[e]||[])n({event:e,id:-1,payload:t});return}return XK(e,t)}async emitTo(e,t,n){if(I9.includes(t)){for(let e of this.listeners[t]||[])e({event:t,id:-1,payload:n});return}return ZK(e,t,n)}_handleTauriEvent(e,t){return I9.includes(e)?(e in this.listeners?this.listeners[e].push(t):this.listeners[e]=[t],!0):!1}async position(){return $(`plugin:webview|webview_position`,{label:this.label}).then(e=>new WK(e))}async size(){return $(`plugin:webview|webview_size`,{label:this.label}).then(e=>new VK(e))}async close(){return $(`plugin:webview|webview_close`,{label:this.label})}async setSize(e){return $(`plugin:webview|set_webview_size`,{label:this.label,value:e instanceof HK?e:new HK(e)})}async setPosition(e){return $(`plugin:webview|set_webview_position`,{label:this.label,value:e instanceof GK?e:new GK(e)})}async setFocus(){return $(`plugin:webview|set_webview_focus`,{label:this.label})}async setAutoResize(e){return $(`plugin:webview|set_webview_auto_resize`,{label:this.label,value:e})}async hide(){return $(`plugin:webview|webview_hide`,{label:this.label})}async show(){return $(`plugin:webview|webview_show`,{label:this.label})}async setZoom(e){return $(`plugin:webview|set_webview_zoom`,{label:this.label,value:e})}async reparent(e){return $(`plugin:webview|reparent`,{label:this.label,window:typeof e==`string`?e:e.label})}async clearAllBrowsingData(){return $(`plugin:webview|clear_all_browsing_data`)}async setBackgroundColor(e){return $(`plugin:webview|set_webview_background_color`,{color:e})}async onDragDropEvent(e){let t=await this.listen(KK.DRAG_ENTER,t=>{e({...t,payload:{type:`enter`,paths:t.payload.paths,position:new WK(t.payload.position)}})}),n=await this.listen(KK.DRAG_OVER,t=>{e({...t,payload:{type:`over`,position:new WK(t.payload.position)}})}),r=await this.listen(KK.DRAG_DROP,t=>{e({...t,payload:{type:`drop`,paths:t.payload.paths,position:new WK(t.payload.position)}})}),i=await this.listen(KK.DRAG_LEAVE,t=>{e({...t,payload:{type:`leave`}})});return()=>{t(),r(),n(),i()}}};function Wie(e){return`'${e.replace(/'/g,`'\\''`)}'`}function Gie(e){return`"${e.replace(/\^/g,`^^`).replace(/%/g,`^%`).replace(/"/g,`""`)}"`}function Kie(e){return`'${e.replace(/'/g,`''`)}'`}function qie(e,t,n=`powershell`){return t?n===`cmd`?Gie(e):Kie(e):Wie(e)}function R9(e,t,n=`powershell`){return e.map(e=>qie(e,t,n)).join(` `)}async function Jie(e){if(!zV())return{dispose:()=>{}};try{let t=[],n=``,r=0,i=typeof navigator<`u`&&/Win/i.test(navigator.platform||``),a=t=>{let a=t.payload;if(!a||a.type!==`drop`)return;let o=a.paths;if(!o||o.length===0)return;let s=a.position;if(!s)return;let c=`${o.join(`\0`)}@${s.x},${s.y}`,l=Date.now();if(c===n&&l-r<250)return;n=c,r=l;let u=e();if(!u||!Yie(s,u.viewportEl.getBoundingClientRect(),window.devicePixelRatio||1))return;let d=R9(o,i);try{u.writeText(d)}catch{}},o=z9((()=>{try{return P9()}catch{return null}})());o&&t.push(await o(a));let s=z9((()=>{try{return tq()}catch{return null}})());return s&&t.push(await s(a)),t.length===0?{dispose:()=>{}}:{dispose:()=>{for(let e of t)try{e()}catch{}}}}catch{return{dispose:()=>{}}}}function z9(e){let t=e?.onDragDropEvent;return typeof t==`function`?t.bind(e):null}function Yie(e,t,n){if(B9(e.x,e.y,t))return!0;let r=Number.isFinite(n)&&n>0?n:1;return B9(e.x/r,e.y/r,t)}function B9(e,t,n){return e>=n.left&&e<=n.right&&t>=n.top&&t<=n.bottom}function Xie({x:e,y:t,label:n,onSelect:r,onClose:i}){let a=(0,H.useRef)(null);return(0,H.useEffect)(()=>{let e=e=>{a.current&&!a.current.contains(e.target)&&i()},t=e=>{e.key===`Escape`&&i()};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[i]),(0,Y.jsx)(`div`,{ref:a,role:`menu`,"data-shortcut-context-menu":!0,style:{position:`fixed`,left:typeof window<`u`&&e+220>window.innerWidth?e-220:e,top:typeof window<`u`&&t+60>window.innerHeight?t-60:t,minWidth:200},className:`bg-[#1f1f29] border border-[#44475a] rounded-md shadow-lg py-1 z-50 text-sm`,children:(0,Y.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{r(),i()},className:`w-full text-left px-3 py-1.5 text-[#f8f8f2] hover:bg-[#44475a]`,children:n})})}function Zie({x:e,y:t,providers:n,onSelect:r,onClose:i}){let{t:a}=K(`terminal`),o=(0,H.useRef)(null);(0,H.useEffect)(()=>{let e=e=>{o.current&&!o.current.contains(e.target)&&i()},t=e=>{e.key===`Escape`&&i()};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[i]);let s=typeof window<`u`&&e+200>window.innerWidth?e-200:e,c=8+n.length*32;return(0,Y.jsx)(`div`,{ref:o,role:`menu`,"data-cli-launch-menu":!0,style:{position:`fixed`,left:s,top:typeof window<`u`&&t+c>window.innerHeight?t-c:t,minWidth:180},className:`bg-[#1f1f29] border border-[#44475a] rounded-md shadow-lg py-1 z-50 text-sm`,children:n.map(e=>(0,Y.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{r(e),i()},className:`w-full text-left px-3 py-1.5 text-[#f8f8f2] hover:bg-[#44475a]`,children:a(`cliMenu.open`,{name:JD(e)})},e))})}var V9=(0,H.forwardRef)(function({isOpen:e,className:t,...n},r){let{t:i}=K(`terminal`);return(0,Y.jsx)(`button`,{ref:r,type:`button`,"aria-label":i(e?`panelChevron.collapse`:`panelChevron.expand`),"aria-expanded":e,className:X(`panel-chevron`,`inline-flex items-center justify-center`,`h-5 w-6 mr-1.5`,`rounded text-muted-foreground`,`hover:bg-border/40 hover:text-foreground`,`focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent-primary/60`,`transition-colors duration-120`,t),...n,children:(0,Y.jsxs)(`svg`,{width:`14`,height:`10`,viewBox:`0 0 14 10`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,Y.jsx)(`rect`,{x:`1`,y:`1`,width:`12`,height:`8`,rx:`1.5`}),e?(0,Y.jsx)(`path`,{d:`M5 3.5 L7 5.5 L9 3.5`}):(0,Y.jsx)(`path`,{d:`M5 6.5 L7 4.5 L9 6.5`})]})})});function Qie({visibility:e,canCreate:t,hasActive:n,provider:r=`claude`,providers:i,onCreate:a,onOpenCli:o,onOpenBrowser:s,onPasteScript:c,pasteScriptDisabled:l,onConfigureBrowser:u,onConfigureScript:d,onKillActive:f,onToggleMaximize:p,onCollapse:m}){let{t:h}=K(`terminal`),g=!!i&&i.length>1,_=JD(r),v=h(`topBar.maxTerminals`,{max:10}),y=t?g?h(`topBar.openCliMulti`):h(`topBar.openCli`,{cli:_}):v;return(0,Y.jsxs)(`div`,{className:X(`flex items-center justify-between h-7 px-2 shrink-0`,`bg-background/95 backdrop-blur-sm`,`border-b border-border/40`,`text-[10px] uppercase tracking-wide text-muted-foreground select-none`),children:[(0,Y.jsx)(`div`,{className:`flex items-center gap-2 pl-1`,children:(0,Y.jsx)(`span`,{className:`font-medium text-foreground`,children:h(`topBar.title`)})}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,Y.jsx)(H9,{label:y,disabled:!t,onClick:e=>o(e?{x:e.clientX,y:e.clientY}:void 0),children:(0,Y.jsx)(Qs,{className:`h-3.5 w-3.5`})}),(0,Y.jsx)(H9,{label:h(`topBar.openInBrowser`),onClick:s,onContextMenu:e=>{e.preventDefault(),u({x:e.clientX,y:e.clientY})},children:(0,Y.jsx)(Ko,{className:`h-3.5 w-3.5`})}),(0,Y.jsx)(H9,{label:h(l?`topBar.pasteScriptNoActive`:`topBar.pasteScript`),disabled:l,onClick:c,onContextMenu:e=>{e.preventDefault(),d({x:e.clientX,y:e.clientY})},children:(0,Y.jsx)(ho,{className:`h-3.5 w-3.5`})}),(0,Y.jsx)(H9,{label:t?h(`topBar.newTerminal`):v,disabled:!t,onClick:a,children:(0,Y.jsx)(ks,{className:`h-3.5 w-3.5`})}),(0,Y.jsx)(H9,{label:h(`topBar.killActive`),disabled:!n,onClick:f,children:(0,Y.jsx)(cc,{className:`h-3.5 w-3.5`})}),(0,Y.jsx)(H9,{label:h(e===`maximized`?`topBar.restorePanel`:`topBar.maximizePanel`),onClick:p,children:e===`maximized`?(0,Y.jsx)(ps,{className:`h-3.5 w-3.5`}):(0,Y.jsx)(us,{className:`h-3.5 w-3.5`})}),(0,Y.jsx)(V9,{isOpen:!0,onClick:m})]})]})}function H9({label:e,disabled:t,onClick:n,onContextMenu:r,children:i}){return(0,Y.jsx)(`button`,{type:`button`,onClick:e=>n(e),onContextMenu:r,disabled:t,title:e,"aria-label":e,className:X(`inline-flex items-center justify-center h-5 w-6 rounded`,`text-muted-foreground transition-colors duration-120`,t?`opacity-40 cursor-not-allowed`:`hover:bg-border/40 hover:text-foreground`,`focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent-primary/60`),children:i})}function $ie({sessions:e,activeId:t,onActivate:n,onRename:r,onKill:i}){return(0,Y.jsx)(`aside`,{className:X(`w-44 shrink-0 border-l border-border/40 bg-background/70`,`overflow-y-auto`),children:(0,Y.jsx)(`ul`,{className:`py-1`,children:e.map(e=>(0,Y.jsx)(eae,{session:e,active:e.id===t,onActivate:()=>n(e.id),onRename:t=>r(e.id,t),onKill:()=>i(e.id)},e.id))})})}function eae({session:e,active:t,onActivate:n,onRename:r,onKill:i}){let{t:a}=K(`terminal`),[o,s]=(0,H.useState)(!1),[c,l]=(0,H.useState)(e.name),u=(0,H.useRef)(null);(0,H.useEffect)(()=>{o&&(l(e.name),queueMicrotask(()=>{u.current?.focus(),u.current?.select()}))},[o,e.name]);function d(){let t=c.trim();t&&t!==e.name&&r(t),s(!1)}function f(){s(!0)}function p(){s(!1),l(e.name)}return(0,Y.jsx)(`li`,{className:`relative group px-1`,children:(0,Y.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-pressed":t,onClick:()=>{o||n()},onKeyDown:e=>{o||(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),n())},onDoubleClick:f,className:X(`flex items-center gap-2 px-2 py-1.5 rounded-md text-xs cursor-pointer select-none`,`transition-colors duration-120`,t?`bg-border/40 text-foreground border-l-2 border-accent-primary/70 pl-[calc(0.5rem-2px)]`:`text-muted-foreground hover:bg-border/20 hover:text-foreground`),children:[(0,Y.jsx)(ac,{className:`h-3 w-3 shrink-0`}),o?(0,Y.jsx)(`input`,{ref:u,value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),d()),e.key===`Escape`&&(e.preventDefault(),p())},onBlur:d,onClick:e=>e.stopPropagation(),maxLength:64,className:X(`flex-1 min-w-0 bg-background/60 border border-border/40 rounded px-1`,`text-xs text-foreground outline-none focus:ring-1 focus:ring-accent-primary/60`)}):(0,Y.jsx)(`span`,{className:`flex-1 truncate`,children:e.name}),!o&&(0,Y.jsx)(`button`,{type:`button`,"aria-label":a(`sidebar.rename`,{name:e.name}),title:a(`sidebar.rename`,{name:e.name}),onClick:e=>{e.stopPropagation(),f()},className:X(`inline-flex items-center justify-center h-4 w-4 rounded`,`text-muted-foreground opacity-0 group-hover:opacity-100`,`hover:bg-border/40 hover:text-foreground`,`transition-opacity duration-120`,t&&`opacity-70`),children:(0,Y.jsx)(ws,{className:`h-3 w-3`})}),(0,Y.jsx)(`button`,{type:`button`,"aria-label":a(`sidebar.close`,{name:e.name}),title:a(`sidebar.close`,{name:e.name}),onClick:e=>{e.stopPropagation(),i()},className:X(`inline-flex items-center justify-center h-4 w-4 rounded`,`text-muted-foreground opacity-0 group-hover:opacity-100`,`hover:bg-destructive/20 hover:text-destructive`,`transition-opacity duration-120`,t&&`opacity-70`),children:(0,Y.jsx)(hc,{className:`h-3 w-3`})})]})})}function tae({search:e,onClose:t}){let{t:n}=K(`terminal`),r=(0,H.useRef)(null),[i,a]=(0,H.useState)(``),[o,s]=(0,H.useState)(!1),[c,l]=(0,H.useState)(!1),[u,d]=(0,H.useState)(!1),[f,p]=(0,H.useState)(null);(0,H.useEffect)(()=>(r.current?.focus(),()=>{try{e.clearDecorations()}catch{}}),[e]),(0,H.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.preventDefault(),t())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);function m(){return{caseSensitive:o,regex:c,wholeWord:u,decorations:{matchBackground:`#bd93f9`,matchOverviewRuler:`#bd93f9`,activeMatchBackground:`#ff79c6`,activeMatchColorOverviewRuler:`#ff79c6`}}}function h(){if(i)try{e.findNext(i,m())}catch{}}function g(){if(i)try{e.findPrevious(i,m())}catch{}}return(0,H.useEffect)(()=>{let t=()=>{};try{let n=e.onDidChangeResults(e=>{if(!e){p(null);return}p({current:e.resultIndex+1,total:e.resultCount})});t=()=>{try{n.dispose()}catch{}}}catch{}return t},[e]),(0,Y.jsxs)(`div`,{className:`absolute top-2 right-2 flex items-center gap-1 bg-[#1f1f29] border border-[#44475a] rounded-md shadow-lg px-2 py-1 z-30`,role:`search`,"data-terminal-search-overlay":!0,children:[(0,Y.jsx)(`input`,{ref:r,value:i,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.shiftKey?g():h())},placeholder:n(`search.placeholder`),className:`bg-transparent text-sm outline-none text-[#f8f8f2] placeholder:text-[#6272a4] w-48`}),f&&(0,Y.jsxs)(`span`,{className:`text-xs text-[#6272a4] tabular-nums`,children:[f.current,`/`,f.total]}),(0,Y.jsx)(`button`,{type:`button`,title:n(`search.previous`),onClick:g,className:`text-[#f8f8f2] hover:text-white p-1`,children:(0,Y.jsx)(ao,{size:14})}),(0,Y.jsx)(`button`,{type:`button`,title:n(`search.next`),onClick:h,className:`text-[#f8f8f2] hover:text-white p-1`,children:(0,Y.jsx)(no,{size:14})}),(0,Y.jsx)(U9,{label:`Aa`,title:n(`search.matchCase`),active:o,onToggle:()=>s(e=>!e)}),(0,Y.jsx)(U9,{label:`.*`,title:n(`search.regex`),active:c,onToggle:()=>l(e=>!e)}),(0,Y.jsx)(U9,{label:`W`,title:n(`search.wholeWord`),active:u,onToggle:()=>d(e=>!e)}),(0,Y.jsx)(`button`,{type:`button`,title:n(`search.close`),onClick:t,className:`text-[#f8f8f2] hover:text-white p-1`,children:(0,Y.jsx)(hc,{size:14})})]})}function U9({label:e,title:t,active:n,onToggle:r}){return(0,Y.jsx)(`button`,{type:`button`,title:t,onClick:r,className:`text-xs px-1.5 py-0.5 rounded font-mono ${n?`bg-[#6272a4] text-white`:`text-[#f8f8f2] hover:bg-[#44475a]`}`,children:e})}function nae({x:e,y:t,term:n,cwd:r,hasReveal:i,onClose:a,onOpenSearch:o,onReveal:s,onSaveScrollback:c}){let{t:l}=K(`terminal`),u=(0,H.useRef)(null);(0,H.useEffect)(()=>{let e=e=>{u.current&&!u.current.contains(e.target)&&a()},t=e=>{e.key===`Escape`&&a()};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[a]);let d=typeof window<`u`&&e+220>window.innerWidth?e-220:e,f=typeof window<`u`&&t+260>window.innerHeight?t-260:t,p=n.getSelection(),m=p.length>0;function h(){m&&(C9(p),a())}function g(){S9().then(e=>{if(e)try{n.paste(e)}catch{}}),a()}function _(){try{n.selectAll()}catch{}a()}function v(){try{n.clear()}catch{}a()}function y(){o(),a()}function b(){c(),a()}function x(){r&&s(r),a()}return(0,Y.jsxs)(`div`,{ref:u,role:`menu`,"data-terminal-context-menu":!0,style:{position:`fixed`,left:d,top:f,minWidth:200},className:`bg-[#1f1f29] border border-[#44475a] rounded-md shadow-lg py-1 z-50 text-sm`,children:[(0,Y.jsx)(W9,{onClick:h,disabled:!m,label:l(`common:actions.copy`),shortcut:`⌘C`}),(0,Y.jsx)(W9,{onClick:g,label:l(`contextMenu.paste`),shortcut:`⌘V`}),(0,Y.jsx)(W9,{onClick:_,label:l(`contextMenu.selectAll`),shortcut:`⌘A`}),(0,Y.jsx)(G9,{}),(0,Y.jsx)(W9,{onClick:v,label:l(`contextMenu.clear`),shortcut:`⌘K`}),(0,Y.jsx)(W9,{onClick:y,label:l(`contextMenu.search`),shortcut:`⌘F`}),(0,Y.jsx)(W9,{onClick:b,label:l(`contextMenu.saveScrollback`)}),r&&i&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(G9,{}),(0,Y.jsx)(W9,{onClick:x,label:l(`contextMenu.openPath`,{path:rae(r,40)})})]})]})}function W9({onClick:e,label:t,shortcut:n,disabled:r}){return(0,Y.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{r||e()},disabled:r,className:`w-full text-left px-3 py-1.5 flex justify-between items-center ${r?`text-[#6272a4] cursor-not-allowed`:`text-[#f8f8f2] hover:bg-[#44475a]`}`,children:[(0,Y.jsx)(`span`,{children:t}),n&&(0,Y.jsx)(`span`,{className:`text-xs text-[#6272a4] tabular-nums`,children:n})]})}function G9(){return(0,Y.jsx)(`div`,{className:`my-1 border-t border-[#44475a]`})}function rae(e,t){return e.length<=t?e:`…`+e.slice(e.length-t+1)}async function iae(e,t=`terminal-scrollback.txt`){let n=e.buffer.active,r=[];for(let e=0;e<n.length;e++){let t=n.getLine(e);t&&r.push(t.translateToString(!0))}let i=r.join(`
158
- `);if(zV())try{let e=await(await a(()=>import(`./dist-js-BTAcxhPb.js`),[])).save({defaultPath:t});if(!e)return;try{let t=await BV(`@tauri-apps/plugin-fs`);if(t?.writeTextFile){await t.writeTextFile(e,i);return}}catch{}try{await(await BV(`@tauri-apps/api/fs`))?.writeTextFile?.({path:e,contents:i})}catch{}return}catch{}try{let e=new Blob([i],{type:`text/plain;charset=utf-8`}),n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n)}catch{}}function aae({sessionId:e}){let[t,n]=(0,H.useState)(()=>y9(e));return(0,H.useEffect)(()=>v9(e,n),[e]),t.promptRows.length===0?null:(0,Y.jsx)(`div`,{"aria-hidden":`true`,"data-prompt-gutter":!0,className:`absolute left-0 top-0 bottom-0 w-1 pointer-events-none z-10`,children:(0,Y.jsx)(`div`,{className:`absolute top-0 left-0 bottom-0 w-full`,style:{backgroundImage:`linear-gradient(to bottom, rgba(189,147,249,0.2), rgba(189,147,249,0.05))`}})})}function oae({sessionId:e}){let{t}=K(`terminal`),[n,r]=(0,H.useState)(y9(e).openPreExec?.startedAt??null),[i,a]=(0,H.useState)(Date.now());if((0,H.useEffect)(()=>v9(e,e=>r(e.openPreExec?.startedAt??null)),[e]),(0,H.useEffect)(()=>{if(n==null)return;let e=setInterval(()=>a(Date.now()),1e3);return()=>clearInterval(e)},[n]),n==null)return null;let o=i-n;return o<500?null:(0,Y.jsx)(`div`,{className:`absolute top-2 left-2 px-2 py-0.5 rounded text-xs font-mono bg-[#44475a] text-[#f8f8f2] z-10 pointer-events-none`,children:sae(o,t)})}function sae(e,t){return e<6e4?t(`terminal:duration.seconds`,{seconds:(e/1e3).toFixed(1)}):t(`terminal:duration.minutesSeconds`,{minutes:Math.floor(e/6e4),seconds:Math.floor(e%6e4/1e3)})}function cae({activeId:e}){let t=(0,H.useRef)(null),n=O9(),[r,i]=(0,H.useState)(!1),[a,o]=(0,H.useState)(null),s=zV();(0,H.useEffect)(()=>{if(e)return n.subscribeOpenSearch(e,()=>i(!0))},[e,n]),(0,H.useEffect)(()=>{i(!1),o(null)},[e]);let c=e?n.getSearchAddon(e):null,l=e?n.getTerminalInstance(e):null,u=e?n.getCwd(e):null,[d,f]=(0,H.useState)(!1),p=(0,H.useCallback)(t=>{if(!t)return!1;if(e&&n.writeToSession(e,t))return!0;if(!l)return!1;try{return l.paste(t),!0}catch{return!1}},[e,n,l]),m=(0,H.useCallback)(e=>{if(!l||!e||e.length===0)return!1;let t=Array.from(e).map(e=>K9(e)).filter(e=>!!e);return t.length===0?!1:p(R9(t,typeof navigator<`u`&&/Win/i.test(navigator.platform||``)))},[l,p]),h=(0,H.useCallback)(e=>{if(e.preventDefault(),!e.shiftKey&&l){let e=l.modes?.mouseTrackingMode;if(e&&e!==`none`)return}o({x:e.clientX,y:e.clientY})},[l]),g=(0,H.useCallback)(e=>{if(!l)return;if(e.clipboardData.files&&e.clipboardData.files.length>0){let t=Array.from(e.clipboardData.files).map(e=>K9(e)).filter(e=>!!e);if(t.length>0){e.preventDefault(),e.stopPropagation(),p(R9(t,typeof navigator<`u`&&/Win/i.test(navigator.platform||``)));return}}let t=e.clipboardData.getData(`text/plain`);t&&(e.preventDefault(),e.stopPropagation(),p(t))},[l,p]),_=(0,H.useCallback)(e=>{if(!l)return;let t=l.getSelection();t&&(e.clipboardData.setData(`text/plain`,t),e.preventDefault(),e.stopPropagation())},[l]),v=(0,H.useCallback)(e=>{if(l&&(typeof navigator<`u`&&/Mac/i.test(navigator.platform||``)?e.metaKey:e.ctrlKey)&&(e.key===`c`||e.key===`C`)){let t=l.getSelection();if(!t)return;e.preventDefault(),e.stopPropagation(),C9(t)}},[l]);return(0,H.useEffect)(()=>{let r=t.current;if(!r||!e)return;let i=n.getContainer(e);if(i)return r.appendChild(i),n.notifyAdopted(e),()=>{let e=document.getElementById(`specrails-terminal-host`);e&&i.parentElement===r&&e.appendChild(i)}},[e,n]),(0,H.useEffect)(()=>{let r=t.current;if(!r||!e)return;let i=[],a=r.parentElement;for(;a&&a!==document.body;)(a.tagName.toLowerCase()===`aside`||a.matches(`[data-sidebar]`))&&i.push(a),a=a.parentElement;if(i.length===0)return;let o=t=>{let r=t;r.propertyName!==`width`&&r.propertyName!==`height`||n.refitActive(e)};return i.forEach(e=>e.addEventListener(`transitionend`,o)),()=>{i.forEach(e=>e.removeEventListener(`transitionend`,o))}},[e,n]),(0,Y.jsxs)(`div`,{ref:t,className:`flex-1 min-w-0 bg-background px-2 py-1 relative ${d?`outline outline-2 outline-accent-primary outline-offset-[-2px]`:``}`,role:`presentation`,"data-terminal-viewport":!0,onContextMenu:h,onPasteCapture:g,onCopyCapture:_,onKeyDownCapture:v,tabIndex:-1,onDragEnter:e=>{q9(e.dataTransfer)&&(e.preventDefault(),e.stopPropagation(),f(!0))},onDragOver:e=>{q9(e.dataTransfer)&&(e.preventDefault(),e.stopPropagation(),f(!0))},onDragLeave:()=>f(!1),onDrop:e=>{q9(e.dataTransfer)&&(e.preventDefault(),e.stopPropagation(),m(e.dataTransfer.files)),f(!1)},children:[e&&(0,Y.jsx)(aae,{sessionId:e}),e&&(0,Y.jsx)(oae,{sessionId:e}),r&&c&&(0,Y.jsx)(tae,{search:c,onClose:()=>i(!1)}),a&&l&&(0,Y.jsx)(nae,{x:a.x,y:a.y,term:l,cwd:u,hasReveal:s,onClose:()=>o(null),onOpenSearch:()=>i(!0),onReveal:e=>{VV(e)},onSaveScrollback:()=>{l&&iae(l)}})]})}function K9(e){let t=e.path;return typeof t==`string`&&t.length>0?t:null}function q9(e){return e?Array.from(e.types).includes(`Files`):!1}function J9({height:e,maxHeight:t,onHeightCommit:n,onHeightPreview:r,minHeight:i=120}){let{t:a}=K(`terminal`),o=(0,H.useRef)(!1),s=(0,H.useRef)(0),c=(0,H.useRef)(e),l=(0,H.useRef)(!1),u=(0,H.useRef)(e),d=(0,H.useCallback)(e=>e<i?i:e>t?t:Math.round(e),[i,t]);(0,H.useEffect)(()=>{function e(e){if(!o.current)return;let t=s.current-e.clientY;u.current=d(c.current+t),l.current||(l.current=!0,requestAnimationFrame(()=>{l.current=!1,r?.(u.current)}))}function t(){o.current&&(o.current=!1,document.body.style.userSelect=``,document.body.style.cursor=``,n(u.current))}return window.addEventListener(`pointermove`,e),window.addEventListener(`pointerup`,t),window.addEventListener(`pointercancel`,t),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,t),window.removeEventListener(`pointercancel`,t)}},[d,n,r]);function f(t){o.current=!0,s.current=t.clientY,c.current=e,u.current=e,document.body.style.userSelect=`none`,document.body.style.cursor=`row-resize`;let n=t.target;if(typeof n.setPointerCapture==`function`)try{n.setPointerCapture(t.pointerId)}catch{}}return(0,Y.jsx)(`div`,{role:`separator`,"aria-orientation":`horizontal`,"aria-label":a(`dragHandle.resize`),onPointerDown:f,className:X(`absolute top-0 left-0 right-0 h-1`,`cursor-row-resize`,`bg-transparent hover:bg-accent-primary/40`,`transition-colors duration-120`,`z-10`)})}function lae({onCreate:e}){let{t}=K(`terminal`);return(0,Y.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-center px-6 bg-background-deep`,children:(0,Y.jsxs)(`div`,{className:`flex flex-col items-center gap-3 text-muted-foreground`,children:[(0,Y.jsx)(ac,{className:`h-8 w-8 opacity-50`}),(0,Y.jsx)(`p`,{className:`text-xs`,children:t(`emptyState.noTerminals`)}),(0,Y.jsxs)(`button`,{type:`button`,onClick:e,className:`inline-flex items-center gap-1.5 px-2.5 py-1.5 rounded-md text-xs bg-border/30 hover:bg-border/50 hover:text-foreground transition-colors`,children:[(0,Y.jsx)(ks,{className:`h-3 w-3`}),` `,t(`emptyState.newTerminal`)]})]})})}var uae=300;function dae({projectId:e,provider:t=`claude`,providers:n,state:r,viewportHeight:i,statusBarHeight:a}){let o=O9(),{t:s}=K(`terminal`),c=_t(),l=(0,H.useRef)(null),[u,d]=(0,H.useState)(null),[f,p]=(0,H.useState)(vW),[m,h]=(0,H.useState)(null),[g,_]=(0,H.useState)(null),v=(0,H.useRef)(a===0&&r.visibility!==`hidden`),[y,b]=(0,H.useState)(()=>r.visibility===`hidden`?`hidden`:v.current?`opening`:`open`),x=(0,H.useRef)(!1),S=n&&n.length>0?n:[t],C=S.length>1,w=(0,H.useCallback)(async(t=()=>!1)=>{try{let n=await fetch(`/api/projects/${e}/terminal-settings`);if(!n.ok)return;let r=await n.json();!t()&&r?.resolved&&p(r.resolved)}catch{}},[e]);(0,H.useEffect)(()=>{let e=!1;return w(()=>e),()=>{e=!0}},[w]),(0,H.useEffect)(()=>{let t=t=>{let n=t.detail;n?.mode===`project`&&n.projectId!==e||w()};return window.addEventListener(bW,t),()=>window.removeEventListener(bW,t)},[w,e]);let T=Math.max(120,i-a-40),E=Math.min(Math.max(r.userHeight||320,120),T),D=r.visibility===`maximized`?Math.max(120,i-a):u??E,O=y===`open`,k=O?D:0,A=a===0,j=r.sessions.length<10,M=r.activeId!==null;(0,H.useEffect)(()=>{let e=null,t=null,n=null,i=()=>{b(`opening`),t=requestAnimationFrame(()=>{n=requestAnimationFrame(()=>b(`open`))})};return x.current?(r.visibility===`hidden`?(b(`closing`),e=setTimeout(()=>b(`hidden`),uae)):i(),()=>{e&&clearTimeout(e),t!==null&&cancelAnimationFrame(t),n!==null&&cancelAnimationFrame(n)}):(x.current=!0,v.current&&i(),()=>{t!==null&&cancelAnimationFrame(t),n!==null&&cancelAnimationFrame(n)})},[r.visibility]),(0,H.useEffect)(()=>{let e=!1,t=null;return Jie(()=>{let e=l.current,t=r.activeId;return!e||!t||r.visibility===`hidden`?null:{viewportEl:e,writeText:e=>{if(o.writeToSession(t,e))return!0;let n=o.getTerminalInstance(t);try{return n?.paste(e),!!n}catch{return!1}}}}).then(n=>{e?n.dispose():t=n}),()=>{e=!0,t?.dispose()}},[r.activeId,r.visibility,o]);let N=(0,H.useCallback)(()=>{j&&o.create(e)},[j,e,o]),P=(0,H.useCallback)(t=>{if(!j)return;let n=t||`claude`,i=RegExp(`^${n} \\(\\d+\\)$`),a=r.sessions.filter(e=>e.name===n||i.test(e.name)),s=a.length===0?n:`${n} (${a.length+1})`;o.createAndType(e,`${n}\n`,{name:s})},[j,e,r.sessions,o]),F=(0,H.useCallback)(e=>{if(j){if(C&&e){_(e);return}P(t)}},[j,C,t,P]),I=(0,H.useCallback)(()=>{HV(f.browserShortcutUrl)},[f.browserShortcutUrl]),L=(0,H.useCallback)(()=>{r.activeId&&f.quickScript&&o.writeToSession(r.activeId,f.quickScript)},[f.quickScript,r.activeId,o]),R=(0,H.useCallback)(e=>{h({...e,kind:`browser`})},[]),z=(0,H.useCallback)(e=>{h({...e,kind:`script`})},[]),ee=(0,H.useCallback)(e=>{c(`/settings${e===`browser`?`#terminal-browser-shortcut-url`:`#terminal-quick-script`}`)},[c]),te=(0,H.useCallback)(()=>{r.activeId&&o.kill(e,r.activeId)},[e,r.activeId,o]),B=(0,H.useCallback)(()=>{o.setVisibility(e,r.visibility===`maximized`?`restored`:`maximized`)},[e,r.visibility,o]),ne=(0,H.useCallback)(()=>{o.setVisibility(e,`hidden`)},[e,o]);return(0,H.useEffect)(()=>{d(null)},[r.visibility]),y===`hidden`?null:(0,Y.jsxs)(`div`,{ref:l,className:X(`relative flex flex-col shrink-0 overflow-hidden origin-bottom transform-gpu bg-background/95`,`border-t border-border/40`,`transition-[height,opacity,transform,clip-path] duration-300 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none`),style:{height:k,opacity:+!!O,transform:O?`translateY(0) scaleY(1)`:`translateY(${A?14:8}px) scaleY(${A?.96:.985})`,clipPath:O?`inset(0 0 0 0)`:`inset(100% 0 0 0)`},"data-testid":`terminal-bottom-panel`,children:[(0,Y.jsx)(J9,{height:E,maxHeight:T,onHeightPreview:e=>d(e),onHeightCommit:t=>{d(null),o.setUserHeight(e,t),r.visibility===`maximized`&&o.setVisibility(e,`restored`)}}),(0,Y.jsx)(Qie,{visibility:r.visibility,canCreate:j,hasActive:M,provider:t,providers:S,onCreate:N,onOpenCli:F,onOpenBrowser:I,onPasteScript:L,pasteScriptDisabled:!M||!f.quickScript,onConfigureBrowser:R,onConfigureScript:z,onKillActive:te,onToggleMaximize:B,onCollapse:ne}),m&&(0,Y.jsx)(Xie,{x:m.x,y:m.y,label:m.kind===`browser`?s(`shortcutMenu.configureBrowserUrl`):s(`shortcutMenu.editQuickScript`),onSelect:()=>ee(m.kind),onClose:()=>h(null)}),g&&(0,Y.jsx)(Zie,{x:g.x,y:g.y,providers:S,onSelect:e=>P(e),onClose:()=>_(null)}),(0,Y.jsx)(`div`,{className:`flex-1 flex min-h-0`,children:r.sessions.length===0?(0,Y.jsx)(lae,{onCreate:N}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(cae,{activeId:r.activeId}),(0,Y.jsx)($ie,{sessions:r.sessions,activeId:r.activeId,onActivate:t=>o.setActive(e,t),onRename:(t,n)=>void o.rename(e,t,n),onKill:t=>void o.kill(e,t)})]})})]})}function fae({connectionStatus:e,rightSlot:t,minimal:n=!1}){let{t:r}=K(`nav`),{t:i}=K(`analytics`),[a,o]=(0,H.useState)(null),[s,c]=(0,H.useState)(!1),l=(0,H.useRef)(`connecting`),u=(0,H.useRef)(!0);(0,H.useEffect)(()=>{let t=l.current;if(e===`connected`&&!u.current&&t!==`connected`){q.success(r(`statusBar.connectionRestored`)),c(!0);let e=setTimeout(()=>c(!1),2e3);return()=>clearTimeout(e)}u.current&&e===`connected`&&(u.current=!1),l.current=e},[e]),(0,H.useEffect)(()=>{u.current&&=!1},[]),(0,H.useEffect)(()=>{if(n)return;async function e(){try{let e=await fetch(`${af()}/stats`);e.ok&&o(await e.json())}catch{}}e();let t=setInterval(e,3e4);return()=>clearInterval(t)},[e,n]);let d=!n||e!==`connected`||s;return(0,Y.jsxs)(`footer`,{className:`h-7 flex items-center justify-between px-4 border-t border-border/30 bg-background/80 backdrop-blur-sm text-[10px] text-muted-foreground`,children:[(0,Y.jsxs)(`div`,{className:X(`flex items-center gap-1.5 transition-opacity duration-300`,!d&&`opacity-0`),"aria-hidden":!d||void 0,children:[(0,Y.jsx)(`span`,{className:X(`w-1.5 h-1.5 rounded-full transition-colors`,e===`connected`&&!s&&`bg-accent-success`,e===`connected`&&s&&`bg-accent-info animate-pulse`,e===`connecting`&&`bg-accent-warning animate-[pulse_0.75s_ease-in-out_infinite]`,e===`disconnected`&&`bg-destructive`)}),(0,Y.jsxs)(`span`,{className:X(`transition-colors`,e===`connected`&&!s&&`text-accent-success`,e===`connected`&&s&&`text-accent-info`,e===`connecting`&&`text-accent-warning`,e===`disconnected`&&`text-destructive`),children:[e===`connected`&&!s&&r(`statusBar.connected`),e===`connected`&&s&&r(`statusBar.syncing`),e===`connecting`&&r(`statusBar.reconnecting`),e===`disconnected`&&r(`statusBar.disconnected`)]})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!n&&a&&a.totalCostUsd>0&&(()=>{let e=a.includesEstimated??((a.estimatedCostUsd??0)>0||(a.estimatedCostToday??0)>0);return(0,Y.jsxs)(`span`,{"data-estimated":e?`true`:void 0,title:e?i(`desktop.statusBarEstimatedTooltip`):void 0,children:[e?`~`:``,`$`,a.totalCostUsd.toFixed(2)]})})(),t]})]})}var pae={"pinned-open":`sidebarPin.right.pinnedOpen`,"pinned-collapsed":`sidebarPin.right.pinnedCollapsed`,unpinned:`sidebarPin.right.unpinned`};function mae(){let{t:e}=K(`agent`),{t}=K(`nav`),{rightMode:n,cycleRightMode:r}=CY(),{projects:i,activeProjectId:a}=gm(),o=O9(),s=J5(),{active:c}=N7(),[l,u]=(0,H.useState)(!1),d=n===`pinned-open`||n===`unpinned`&&l,f=cY(`right-workspace`,{side:`right`,defaultWidth:208,min:180,max:460,collapsedWidth:44,expanded:d}),p=n!==`unpinned`,m=t(pae[n]),h=!a,g=i.find(e=>e.id===a),_=qD(`integrations`,g?lm(g):[`claude`]),v=[{key:`jobs`,icon:Xa,label:e(`workspace.jobs`),onClick:()=>s.toggleJobsPane(),disabled:h,disabledTitle:e(`workspace.requiresProject`)},...SO()?[{key:`browser`,icon:Ko,label:e(`workspace.browser`),onClick:()=>s.openBrowser(),disabled:h||!c,disabledTitle:e(h?`workspace.requiresProject`:`workspace.requiresConversation`)}]:[],...Mb?[{key:`terminal`,icon:ec,label:e(`workspace.terminal`),onClick:()=>a&&o.togglePanel(a),disabled:h,disabledTitle:e(`workspace.requiresProject`)}]:[],...Pb?[{key:`files`,icon:Ao,label:e(`workspace.files`),onClick:()=>s.toggleCodePane(),disabled:h,disabledTitle:e(`workspace.requiresProject`)}]:[],..._?[{key:`integrations`,icon:As,label:t(`rightSidebar.integrations`),onClick:()=>s.toggleIntegrationsModal(),disabled:h,disabledTitle:e(`workspace.requiresProject`)}]:[]];return(0,Y.jsxs)(`div`,{ref:f.panelRef,className:X(`relative flex flex-col h-full border-l border-border bg-background flex-shrink-0 overflow-hidden`,`transition-[width] duration-200 ease-in-out`),onMouseEnter:()=>{n===`unpinned`&&u(!0)},onMouseLeave:()=>{n===`unpinned`&&!f.dragging&&u(!1)},children:[d&&(0,Y.jsx)(lY,{side:`right`,dragging:f.dragging,width:f.width,min:180,max:460,label:t(`sidebarPin.resize`,{defaultValue:`Resize sidebar`}),onPointerDown:f.onGripPointerDown,onKeyDown:f.onGripKeyDown}),(0,Y.jsxs)(`div`,{className:X(`flex items-center h-12 border-b border-border flex-shrink-0`,d?`px-3 justify-between`:`justify-center`),children:[d&&(0,Y.jsx)(`span`,{className:`font-mono text-sm font-bold whitespace-nowrap overflow-hidden text-accent-secondary`,children:e(`workspace.title`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:r,className:X(`flex items-center justify-center w-7 h-7 rounded-md transition-colors`,p?`text-foreground bg-muted`:`text-muted-foreground/40 hover:text-muted-foreground hover:bg-muted/50`),"aria-label":m,title:t(`sidebarPin.withShortcut`,{label:m,shortcut:`⌘B`}),children:(0,Y.jsx)(xs,{className:`w-4 h-4`})})]}),(0,Y.jsx)(`nav`,{className:`flex-1 py-2 px-1.5 space-y-0.5`,children:v.map(({key:e,icon:t,label:n,onClick:r,disabled:i,disabledTitle:a})=>(0,Y.jsxs)(`button`,{type:`button`,onClick:r,disabled:i,className:X(`flex items-center gap-2 w-full h-8 rounded-md transition-colors`,d?`px-2`:`px-0 justify-center`,i?`text-muted-foreground/40 cursor-not-allowed`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),title:i?a:d?void 0:n,children:[(0,Y.jsx)(t,{className:`w-4 h-4 flex-shrink-0`}),d&&(0,Y.jsx)(`span`,{className:`text-xs truncate`,children:n})]},e))})]})}var hae=(0,H.lazy)(()=>a(()=>import(`./AgentModeCodePane-DLltTOqp.js`).then(e=>({default:e.AgentModeCodePane})),__vite__mapDeps([38,1,39]))),gae=(0,H.lazy)(()=>a(()=>import(`./AgentModeJobsPane-Dp5YvmW0.js`).then(e=>({default:e.AgentModeJobsPane})),__vite__mapDeps([40,1,27,28,29,30,31,41]))),_ae=(0,H.lazy)(()=>a(()=>import(`./AgentBrowserCapture-CpZ-dd8O.js`).then(e=>({default:e.AgentBrowserCapture})),__vite__mapDeps([42,1]))),vae=(0,H.lazy)(()=>a(()=>import(`./AgentIntegrationsModal-DO1pN_Ez.js`).then(e=>({default:e.AgentIntegrationsModal})),__vite__mapDeps([43,1,44,31])));function yae(){let{t:e}=K(`agent`),{active:t,refreshConversations:n}=N7(),{codePaneOpen:r,jobsPaneOpen:i,browserOpen:a,integrationsModalOpen:o,closeIntegrationsModal:s}=J5(),{activeProjectId:c}=gm(),l=BU(),u=l.id===`galaxy`,d=l.id===`code-rain`?e(`emptyTitleCodeRain`):e(`emptyTitle`);(0,H.useEffect)(()=>{n()},[n]);let f=r&&!!c,p=i&&!!c,m=o&&!!c;return(0,Y.jsx)(r6,{reducedMotion:`user`,children:(0,Y.jsxs)(`div`,{"data-agent-mode-surface":!0,className:`relative z-0 flex h-full w-full overflow-hidden bg-background`,children:[u&&(0,Y.jsx)(JU,{}),(0,Y.jsxs)(`div`,{className:`relative flex h-full min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,Y.jsx)(V8.div,{"aria-hidden":!0,className:`pointer-events-none absolute inset-0 z-0`,animate:{opacity:+(t===null)},transition:{duration:.5,ease:`easeOut`},style:{background:`radial-gradient(60% 55% at 50% 45%, color-mix(in srgb, var(--color-accent-primary) 13%, transparent), transparent 70%)`}}),t===null?(0,Y.jsx)(`div`,{className:`relative z-10 flex h-full w-full items-center justify-center px-6`,children:(0,Y.jsxs)(V8.div,{layoutId:`agent-composer-dock`,initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.28,ease:[.34,1.56,.64,1],layout:{type:`spring`,stiffness:350,damping:34}},className:`w-full max-w-[680px] rounded-2xl border border-border/60 bg-card/90 p-4 shadow-2xl backdrop-blur-xl`,children:[(0,Y.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 px-1`,children:[(0,Y.jsx)(qa,{className:`h-4 w-4 text-accent-primary`}),(0,Y.jsx)(`span`,{className:`text-sm font-medium text-foreground/80`,children:d})]}),(0,Y.jsx)(u7,{autoFocus:!0})]})}):(0,Y.jsx)(`div`,{className:`relative z-10 flex min-h-0 flex-1 flex-col overflow-hidden`,children:(0,Y.jsx)(S7,{variant:`inline`})})]}),p&&(0,Y.jsx)(H.Suspense,{fallback:(0,Y.jsx)(`div`,{className:`w-[480px] border-l border-border`}),children:(0,Y.jsx)(gae,{projectId:c})}),f&&(0,Y.jsx)(H.Suspense,{fallback:(0,Y.jsx)(`div`,{className:`w-[520px] border-l border-border`}),children:(0,Y.jsx)(hae,{projectId:c,conversationId:t?.id??`__home__`})}),a&&c&&(0,Y.jsx)(H.Suspense,{fallback:null,children:(0,Y.jsx)(_ae,{projectId:c,conversationId:t?.id??null})}),m&&(0,Y.jsx)(H.Suspense,{fallback:null,children:(0,Y.jsx)(vae,{onClose:s})})]})})}function bae(){let{state:e,openTicketDetail:t,enterSplit:n,setComparedTicket:r}=dH(),{tickets:i}=Em(),a=mt(),o=_t(),s=(0,H.useRef)(!1);(0,H.useEffect)(()=>{if(s.current||i.length===0||new URLSearchParams(a.search).get(`compare`)&&typeof window<`u`&&window.innerWidth<900)return;s.current=!0;let e=new URLSearchParams(a.search),c=e.get(`compare`),l=e.get(`compareSide`);if(!c)return;let u=Number.parseInt(c,10),d=l===`right`?`right`:`left`;if(!i.some(e=>e.id===u)){let e=new URLSearchParams(a.search);e.delete(`compare`),e.delete(`compareSide`);let t=e.toString();o({pathname:a.pathname,search:t?`?${t}`:``},{replace:!0});return}let f=e.get(`compareOrigin`);if(f){let e=Number.parseInt(f,10);if(i.some(t=>t.id===e)){t(e),n(d),r(u,d===`left`?`right`:`left`);return}}t(u)},[i,a.search,a.pathname,o,t,n,r]),(0,H.useEffect)(()=>{if(!s.current)return;let t=new URLSearchParams(a.search),n=t.has(`compare`);if(e.originSide===null){if(n){t.delete(`compare`),t.delete(`compareSide`),t.delete(`compareOrigin`);let e=t.toString();o({pathname:a.pathname,search:e?`?${e}`:``},{replace:!0})}return}let r=e.originSide===`left`?e.leftId:e.rightId,i=e.originSide===`left`?e.rightId:e.leftId;if(r==null||e.originSide==null)return;let c=new URLSearchParams(a.search);c.set(`compareSide`,e.originSide),c.set(`compareOrigin`,String(r)),i==null?c.delete(`compare`):c.set(`compare`,String(i));let l=c.toString();l!==(a.search.startsWith(`?`)?a.search.slice(1):a.search)&&o({pathname:a.pathname,search:l?`?${l}`:``},{replace:!0})},[e,a.search,a.pathname,o])}function xae(e){return e.startsWith(`/loops`)?`loops`:e.startsWith(`/plugins`)?`plugins`:null}function Sae({uiMode:e,pathname:t,loopsOpen:n,pluginsOpen:r}){if(e===`agent`){let e=xae(t);return e?{kind:`modalize`,surface:e,backgroundPath:`/`}:null}return n?{kind:`route`,surface:`loops`,path:`/loops`}:r?{kind:`route`,surface:`plugins`,path:`/plugins`}:null}var Cae=(0,H.lazy)(()=>a(()=>import(`./JobDetailPage-DwA9bbwx.js`),__vite__mapDeps([45,1,28,29,30,31,41]))),wae=(0,H.lazy)(()=>a(()=>import(`./JobsPage-BDIyFfd5.js`),__vite__mapDeps([46,1,47,41]))),Tae=(0,H.lazy)(()=>a(()=>import(`./AnalyticsPage-C4Ik95FX.js`),__vite__mapDeps([48,1,49,50,51,47]))),Eae=(0,H.lazy)(()=>a(()=>import(`./ActivityFeedPage-Be-6L0Ld.js`),__vite__mapDeps([52,1]))),Dae=(0,H.lazy)(()=>a(()=>import(`./AgentsPage-ehHuVUds.js`),__vite__mapDeps([53,1]))),Oae=(0,H.lazy)(()=>a(()=>import(`./CodePage-D4OCMfxL.js`),__vite__mapDeps([54,1,39]))),kae=(0,H.lazy)(()=>a(()=>import(`./IntegrationsPage-CCb2YuyJ.js`),[])),Y9=(0,H.lazy)(()=>a(()=>import(`./PluginsPage-BBGTBpGh.js`),__vite__mapDeps([44,1,31]))),Aae=(0,H.lazy)(()=>a(()=>import(`./DesktopAnalyticsPage-2Xf-52x2.js`),__vite__mapDeps([55,1,49,50,51]))),X9=(0,H.lazy)(()=>a(()=>import(`./DocsPage-1vEk7XbH.js`),__vite__mapDeps([56,1,29,57,58]))),jae=(0,H.lazy)(()=>a(()=>import(`./DocsDialog-CHihLjWd.js`),__vite__mapDeps([59,1,29,57,58]))),Z9=(0,H.lazy)(()=>a(()=>import(`./LoopsPage-BO0Pa8oz.js`),__vite__mapDeps([60,1,61,33,30]))),Mae=(0,H.lazy)(()=>a(()=>import(`./LoopBuilderPage-CpBaW59t.js`),__vite__mapDeps([62,1,51,30,61,63]))),Nae=28;function Q9({surface:e,onClose:t}){let{t:n}=K(`nav`),r=n(e===`loops`?`arcSidebar.loops`:`arcSidebar.plugins`);return(0,Y.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center justify-between gap-3 border-b border-border bg-popover/95 px-3`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`grid h-7 w-7 shrink-0 place-items-center rounded-md border border-accent-primary/20 bg-accent-primary/10 text-accent-primary`,children:(0,Y.jsx)(e===`loops`?mc:As,{className:`h-3.5 w-3.5`})}),(0,Y.jsx)(`span`,{className:`truncate text-xs font-medium text-foreground`,children:r})]}),(0,Y.jsx)(`div`,{className:`flex shrink-0 items-center`,children:(0,Y.jsx)(`button`,{type:`button`,onClick:t,className:`grid h-7 w-7 place-items-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:ring-offset-popover`,"aria-label":n(`common:actions.close`),children:(0,Y.jsx)(hc,{className:`h-4 w-4`})})})]})}var Pae=new Set([`/settings`,`/loops`,`/plugins`]);function $9(e){return Pae.has(e)||e.startsWith(`/loops`)||e.startsWith(`/plugins`)||e.startsWith(`/docs`)}var Fae=`specrails-desktop:routeMemory`;try{localStorage.removeItem(Fae)}catch{}function Iae(e){let t=mt(),n=_t(),r=(0,H.useRef)(new Map),i=(0,H.useRef)(null),a=(0,H.useRef)(!1);(0,H.useEffect)(()=>{vc((e,t)=>{r.current.set(e,t)})},[]),(0,H.useEffect)(()=>{a.current||(a.current=!0,t.pathname!==`/`&&n(`/`,{replace:!0}))},[]),(0,H.useEffect)(()=>{if(i.current&&i.current!==e&&!$9(t.pathname)&&r.current.set(i.current,t.pathname),e&&e!==i.current){let i=r.current.get(e),a=i&&!$9(i)?i:`/`;t.pathname!==a&&n(a,{replace:!0})}i.current=e},[e,t.pathname,n]),(0,H.useEffect)(()=>{e&&t.pathname!==`/`&&!$9(t.pathname)&&r.current.set(e,t.pathname)},[e,t.pathname])}function Lae(){let{t:e}=K(`common`),{projects:t,activeProjectId:n,isLoading:r,isSwitchingProject:i,setupProjectIds:a,completeSetupWizard:o,setActiveProjectId:s}=gm(),{cycleLeftMode:c,cycleRightMode:l}=CY(),u=_t(),d=mt(),f=O9(),p=N7(),{startNewConversation:m}=p,{uiMode:h}=hq();bae();let[g,_]=(0,H.useState)(!1),[v,y]=(0,H.useState)(!1),[b,x]=(0,H.useState)(!1),[S,C]=(0,H.useState)(!1),[w,T]=(0,H.useState)(!1),[E,D]=(0,H.useState)(!1),O=(0,H.useCallback)(()=>D(!1),[]),[k,A]=(0,H.useState)(()=>!WJ());Iae(n),die();let{cheatsheetOpen:j,setCheatsheetOpen:M,openCheatsheet:N}=PK(),P=[`/`,`/jobs`,`/analytics`,...Nb?[`/agents`]:[],...Pb?[`/code`]:[],`/integrations`,`/settings`];NK({onOpenCheatsheet:N,onToggleLeftSidebar:c,onToggleRightSidebar:l,onSwitchProject:e=>{let n=t[e-1];n&&s(n.id)},onSwitchProjectPage:e=>{let t=P[e-1];t&&u(t)},onToggleTerminalPanel:Mb?()=>{n&&(f.togglePanel(n),f.getState(n).visibility===`hidden`?queueMicrotask(()=>f.focusActive(n)):f.focusActive(n))}:void 0,onToggleAgentChat:Lb&&h!==`agent`?()=>p.toggle():void 0}),wK({setActiveProjectId:s,projectsById:(0,H.useMemo)(()=>new Map(t.map(e=>[e.id,e.name])),[t])});let F=t.find(e=>e.id===n),I=n!==null&&a.has(n),L=d.pathname.startsWith(`/loops`),R=d.pathname.startsWith(`/plugins`),z=d.pathname.startsWith(`/docs`)||h!==`agent`&&(L||R);(0,H.useLayoutEffect)(()=>{let e=Sae({uiMode:h,pathname:d.pathname,loopsOpen:S,pluginsOpen:w});if(e){if(e.kind===`modalize`){e.surface===`loops`?(T(!1),C(!0)):(C(!1),T(!0)),m(n),d.pathname!==e.backgroundPath&&u(e.backgroundPath,{replace:!0});return}C(!1),T(!1),d.pathname!==e.path&&u(e.path,{replace:!0})}},[n,d.pathname,S,u,w,m,h]);let{connectionStatus:ee}=N9(),te=Rie(n),B=h===`agent`?0:Nae,ne=(0,H.useRef)(null),[V,re]=(0,H.useState)(typeof window<`u`?window.innerHeight:820);(0,H.useLayoutEffect)(()=>{if(!Mb)return;let e=ne.current;if(!e)return;let t=()=>re(e.clientHeight);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[r]),(0,H.useEffect)(()=>{!Mb||!n||f.ensureProject(n)},[n,f]);let U=Mb&&h===`kanban`&&te.visibility===`hidden`?(0,Y.jsx)(V9,{isOpen:!1,onClick:()=>n&&f.setVisibility(n,`restored`)}):null;return r?(0,Y.jsxs)(`div`,{className:`flex h-full`,children:[(0,Y.jsx)(`div`,{className:`w-11 border-r border-border bg-card/50 animate-pulse flex-shrink-0`}),(0,Y.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`states.loading`)})})]}):(0,Y.jsxs)(`div`,{className:`flex h-full overflow-hidden font-sans`,children:[(0,Y.jsx)(wre,{onAddProject:()=>_(!0),onOpenLoops:()=>{h===`agent`?C(!0):u(`/loops`)},onOpenPlugins:()=>{h===`agent`?T(!0):u(`/plugins`)},onOpenAnalytics:()=>x(!0),onOpenDocs:()=>D(!0),onOpenSettings:()=>y(!0)}),(0,Y.jsxs)(`div`,{ref:ne,className:`flex flex-col flex-1 overflow-hidden`,children:[i&&(0,Y.jsx)(`div`,{className:`h-0.5 w-full bg-accent-primary/70 animate-pulse shrink-0`,"data-testid":`project-switching-bar`}),(0,Y.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:I&&F?(0,Y.jsx)(VJ,{project:F,onComplete:()=>o(F.id),onSkip:()=>o(F.id)},F.id):h===`agent`&&!z?(0,Y.jsx)(yae,{}):(0,Y.jsx)(H.Suspense,{fallback:(0,Y.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`states.loading`)})}),children:(0,Y.jsxs)(Yt,{children:[(0,Y.jsx)(qt,{path:`/docs`,element:(0,Y.jsx)(X9,{})}),(0,Y.jsx)(qt,{path:`/docs/:category/:slug`,element:(0,Y.jsx)(X9,{})}),zb&&(0,Y.jsx)(qt,{path:`/loops`,element:(0,Y.jsx)(Z9,{})}),zb&&(0,Y.jsx)(qt,{path:`/loops/:id/edit`,element:(0,Y.jsx)(Mae,{})}),(0,Y.jsx)(qt,{path:`/plugins`,element:(0,Y.jsx)(Y9,{})}),t.length===0?(0,Y.jsx)(qt,{path:`*`,element:(0,Y.jsx)(Zq,{onAddProject:()=>_(!0)})}):F?(0,Y.jsxs)(qt,{element:(0,Y.jsx)(Xq,{projectName:F.name,children:(0,Y.jsx)(Jq,{project:F})},F.id),children:[(0,Y.jsx)(qt,{path:`/`,element:(0,Y.jsx)(uW,{})}),(0,Y.jsx)(qt,{path:`/jobs`,element:(0,Y.jsx)(wae,{})}),(0,Y.jsx)(qt,{path:`/jobs/:id`,element:(0,Y.jsx)(Cae,{})}),(0,Y.jsx)(qt,{path:`/analytics`,element:(0,Y.jsx)(Tae,{})}),(0,Y.jsx)(qt,{path:`/activity`,element:(0,Y.jsx)(Eae,{})}),(0,Y.jsx)(qt,{path:`/agents`,element:(0,Y.jsx)(Dae,{})}),(0,Y.jsx)(qt,{path:`/code`,element:Pb?(0,Y.jsx)(Oae,{}):(0,Y.jsx)(Gt,{to:`/`,replace:!0})}),(0,Y.jsx)(qt,{path:`/integrations`,element:(0,Y.jsx)(kae,{})}),(0,Y.jsx)(qt,{path:`/settings`,element:(0,Y.jsx)(IW,{})}),(0,Y.jsx)(qt,{path:`*`,element:(0,Y.jsx)(Gt,{to:`/`,replace:!0})})]}):(0,Y.jsx)(qt,{path:`*`,element:(0,Y.jsx)(Zq,{onAddProject:()=>_(!0)})})]})})}),Mb&&n&&F&&(0,Y.jsx)(dae,{projectId:n,provider:F.provider,providers:lm(F),state:te,viewportHeight:V,statusBarHeight:B}),h!==`agent`&&(0,Y.jsx)(fae,{connectionStatus:ee,rightSlot:U})]}),h===`agent`?!I&&!z&&(0,Y.jsx)(mae,{}):F&&!I&&!z&&(0,Y.jsx)(Ere,{}),(0,Y.jsx)(Fre,{open:g,onClose:()=>_(!1)}),(0,Y.jsx)(OK,{open:v,onClose:()=>y(!1),onOpenOnboarding:()=>{y(!1),A(!0)}}),(0,Y.jsx)(Cb,{open:b,onOpenChange:x,children:(0,Y.jsx)(Db,{className:`max-w-5xl max-h-[90vh] overflow-hidden p-0 flex flex-col`,children:(0,Y.jsx)(`div`,{className:`flex-1 overflow-auto`,children:(0,Y.jsx)(H.Suspense,{fallback:(0,Y.jsx)(`div`,{className:`flex items-center justify-center h-40`,children:(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`states.loading`)})}),children:(0,Y.jsx)(Aae,{})})})})}),(0,Y.jsx)(Cb,{open:S,onOpenChange:C,children:(0,Y.jsxs)(Db,{showCloseButton:!1,className:`max-w-[96vw] w-[96vw] h-[92vh] max-h-[92vh] overflow-hidden p-0 flex flex-col`,children:[(0,Y.jsx)(Ab,{className:`sr-only`,children:e(`nav:arcSidebar.loops`)}),(0,Y.jsx)(jb,{className:`sr-only`,children:e(`nav:globalSurfaceModal.loopsDescription`)}),(0,Y.jsx)(Q9,{surface:`loops`,onClose:()=>C(!1)}),(0,Y.jsx)(`div`,{className:`flex-1 overflow-auto`,children:(0,Y.jsx)(H.Suspense,{fallback:(0,Y.jsx)(`div`,{className:`flex items-center justify-center h-40`,children:(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`states.loading`)})}),children:(0,Y.jsx)(Z9,{})})})]})}),(0,Y.jsx)(Cb,{open:w,onOpenChange:T,children:(0,Y.jsxs)(Db,{showCloseButton:!1,className:`max-w-[96vw] w-[96vw] h-[92vh] max-h-[92vh] overflow-hidden p-0 flex flex-col`,children:[(0,Y.jsx)(Ab,{className:`sr-only`,children:e(`nav:arcSidebar.plugins`)}),(0,Y.jsx)(jb,{className:`sr-only`,children:e(`nav:globalSurfaceModal.pluginsDescription`)}),(0,Y.jsx)(Q9,{surface:`plugins`,onClose:()=>T(!1)}),(0,Y.jsx)(`div`,{className:`flex-1 overflow-auto`,children:(0,Y.jsx)(H.Suspense,{fallback:(0,Y.jsx)(`div`,{className:`flex items-center justify-center h-40`,children:(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`states.loading`)})}),children:(0,Y.jsx)(Y9,{})})})]})}),(0,Y.jsx)(H.Suspense,{fallback:null,children:(0,Y.jsx)(jae,{open:E,onClose:O})}),(0,Y.jsx)(oie,{onOpenSettings:()=>y(!0),onOpenAnalytics:()=>x(!0),onOpenDocs:()=>D(!0)}),(0,Y.jsx)(zK,{open:j,onOpenChange:M}),(0,Y.jsx)(aY,{open:k,onClose:()=>A(!1)})]})}function Rae({children:e}){let{activeProjectId:t}=gm();return(0,Y.jsx)(Iie,{activeProjectId:t,children:e})}function zae({children:e}){let{activeProjectId:t}=gm();return(0,Y.jsx)(cB,{activeProjectId:t,children:e})}function Bae({children:e}){let{activeProjectId:t}=gm();return(0,Y.jsx)(pB,{activeProjectId:t,children:e})}function Vae(){return(0,Y.jsx)(`span`,{"aria-hidden":!0,style:{display:`none`}})}function Hae(){let{theme:e}=RU(),t=e.previewSwatches.accents[0],n=e.status.completed,r=e.status.failed,i=e.status.canceled,a=e.status.running;return(0,Y.jsx)(ka,{position:`bottom-right`,className:`specrails-toaster`,theme:e.scheme,gap:8,closeButton:!0,visibleToasts:6,icons:{loading:(0,Y.jsx)(Vae,{})},style:{"--accent":t,"--toast-success-border":`color-mix(in srgb, ${n} 38%, transparent)`,"--toast-error-border":`color-mix(in srgb, ${r} 38%, transparent)`,"--toast-warning-border":`color-mix(in srgb, ${i} 38%, transparent)`,"--toast-info-border":`color-mix(in srgb, ${a} 38%, transparent)`},toastOptions:{unstyled:!0,classNames:{toast:`glass-card border border-border/30 text-foreground text-xs p-3 rounded-lg flex items-start gap-2 w-[356px] max-w-[356px] overflow-hidden shadow-lg`,content:`flex-1 min-w-0 flex flex-col gap-0.5`,icon:`shrink-0 mt-[2px] flex items-center justify-center`,title:`font-medium text-sm`,description:`text-muted-foreground mt-0.5`,actionButton:`text-[11px] px-2.5 py-1 rounded-md bg-accent-primary text-white hover:bg-accent-primary/90 whitespace-nowrap shrink-0 self-start`,cancelButton:`text-[11px] px-2.5 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-accent/50 whitespace-nowrap shrink-0 self-start`,closeButton:`text-muted-foreground hover:text-foreground rounded-md p-0.5`,success:`border-l-4 border-l-[var(--toast-success-border)]`,error:`border-l-4 border-l-[var(--toast-error-border)]`,warning:`border-l-4 border-l-[var(--toast-warning-border)]`,info:`border-l-4 border-l-[var(--toast-info-border)]`,loading:``}}})}function Uae(){return AG(),mie(),(0,Y.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,height:`100vh`,overflow:`hidden`},children:(0,Y.jsx)(`div`,{style:{flex:1,overflow:`hidden`,display:`flex`,flexDirection:`column`},children:(0,Y.jsx)(uf,{url:xO,children:(0,Y.jsx)(LU,{children:(0,Y.jsxs)(UW,{children:[(0,Y.jsx)(qq,{}),(0,Y.jsx)(mm,{children:(0,Y.jsxs)(pq,{children:[(0,Y.jsx)(bq,{}),(0,Y.jsx)(vD,{children:(0,Y.jsx)(lie,{children:(0,Y.jsx)(NH,{children:(0,Y.jsx)(SY,{children:(0,Y.jsx)(Rae,{children:(0,Y.jsx)(zae,{children:(0,Y.jsx)(Bae,{children:(0,Y.jsx)(Bg,{children:(0,Y.jsx)(_re,{children:(0,Y.jsx)(cne,{children:(0,Y.jsx)(K5,{children:(0,Y.jsx)(uH,{children:(0,Y.jsxs)(EH,{children:[(0,Y.jsx)(Lae,{}),(0,Y.jsx)(Hae,{})]})})})})})})})})})})})})})]})})]})})})})})}async function Wae(){await l(),s(),await tm(),(0,or.createRoot)(document.getElementById(`root`)).render((0,Y.jsx)(H.StrictMode,{children:(0,Y.jsx)(Rn,{children:(0,Y.jsx)(Uae,{})})}));let e=document.getElementById(`specrails-splash`);e&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{e.classList.add(`is-hidden`),setTimeout(()=>e.remove(),300)})})}Wae();export{yb as $,ps as $t,Sz as A,to as An,cc as At,JD as B,J as Bn,Gs as Bt,vV as C,uo as Cn,sl as Ct,Rz as D,ao as Dn,mc as Dt,aB as E,oo as En,hc as Et,uF as F,Ha as Fn,Qs as Ft,LE as G,Vn as Gn,Is as Gt,IE as H,K as Hn,Bs as Ht,$P as I,Va as In,Xs as It,jb as J,xt as Jn,ks as Jt,Cb as K,Gt as Kn,Fs as Kt,Dk as L,Ba as Ln,Ys as Lt,ez as M,Xa as Mn,ic as Mt,KL as N,Ka as Nn,tc as Nt,Lz as O,io as On,fc as Ot,cI as P,Ua as Pn,ec as Pt,xb as Q,ms as Qt,pk as R,za as Rn,qs as Rt,dH as S,fo as Sn,ol as St,$z as T,co as Tn,gc as Tt,RE as U,Zi as Un,zs as Ut,WD as V,q as Vn,Us as Vt,FE as W,Yi as Wn,Rs as Wt,Ob as X,ne as Xn,Ts as Xt,kb as Y,Yn,Ds as Yt,Ab as Z,z as Zn,ws as Zt,CW as _,ko as _n,Ld as _t,f5 as a,Qo as an,lm as at,_H as b,bo as bn,fu as bt,W8 as c,Uo as cn,im as ct,iG as d,zo as dn,sf as dt,us as en,Vg as et,$ as f,Io as fn,af as ft,MW as g,Mo as gn,Yd as gt,DW as h,No as hn,$d as ht,J5 as i,es as in,X as it,Ez as j,Qa as jn,ac as jt,kz as k,no as kn,lc as kt,NY as l,Ho as ln,am as lt,PW as m,Po as mn,Ad as mt,f7 as n,cs as nn,ug as nt,p5 as o,Zo as on,gm as ot,FW as p,Fo as pn,Vd as pt,Db as q,_t as qn,As as qt,Hne as r,os as rn,Z as rt,D5 as s,Jo as sn,eee as st,N9 as t,ls as tn,Hg as tt,CJ as u,Bo as un,df as ut,_W as v,Oo as vn,ld as vt,hV as w,lo as wn,Gc as wt,gH as x,po as xn,gl as xt,BU as y,To as yn,su as yt,xO as z,La as zn,Ks as zt};
158
+ `);if(zV())try{let e=await(await a(()=>import(`./dist-js-DHiN-A_E.js`),[])).save({defaultPath:t});if(!e)return;try{let t=await BV(`@tauri-apps/plugin-fs`);if(t?.writeTextFile){await t.writeTextFile(e,i);return}}catch{}try{await(await BV(`@tauri-apps/api/fs`))?.writeTextFile?.({path:e,contents:i})}catch{}return}catch{}try{let e=new Blob([i],{type:`text/plain;charset=utf-8`}),n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n)}catch{}}function aae({sessionId:e}){let[t,n]=(0,H.useState)(()=>y9(e));return(0,H.useEffect)(()=>v9(e,n),[e]),t.promptRows.length===0?null:(0,Y.jsx)(`div`,{"aria-hidden":`true`,"data-prompt-gutter":!0,className:`absolute left-0 top-0 bottom-0 w-1 pointer-events-none z-10`,children:(0,Y.jsx)(`div`,{className:`absolute top-0 left-0 bottom-0 w-full`,style:{backgroundImage:`linear-gradient(to bottom, rgba(189,147,249,0.2), rgba(189,147,249,0.05))`}})})}function oae({sessionId:e}){let{t}=K(`terminal`),[n,r]=(0,H.useState)(y9(e).openPreExec?.startedAt??null),[i,a]=(0,H.useState)(Date.now());if((0,H.useEffect)(()=>v9(e,e=>r(e.openPreExec?.startedAt??null)),[e]),(0,H.useEffect)(()=>{if(n==null)return;let e=setInterval(()=>a(Date.now()),1e3);return()=>clearInterval(e)},[n]),n==null)return null;let o=i-n;return o<500?null:(0,Y.jsx)(`div`,{className:`absolute top-2 left-2 px-2 py-0.5 rounded text-xs font-mono bg-[#44475a] text-[#f8f8f2] z-10 pointer-events-none`,children:sae(o,t)})}function sae(e,t){return e<6e4?t(`terminal:duration.seconds`,{seconds:(e/1e3).toFixed(1)}):t(`terminal:duration.minutesSeconds`,{minutes:Math.floor(e/6e4),seconds:Math.floor(e%6e4/1e3)})}function cae({activeId:e}){let t=(0,H.useRef)(null),n=O9(),[r,i]=(0,H.useState)(!1),[a,o]=(0,H.useState)(null),s=zV();(0,H.useEffect)(()=>{if(e)return n.subscribeOpenSearch(e,()=>i(!0))},[e,n]),(0,H.useEffect)(()=>{i(!1),o(null)},[e]);let c=e?n.getSearchAddon(e):null,l=e?n.getTerminalInstance(e):null,u=e?n.getCwd(e):null,[d,f]=(0,H.useState)(!1),p=(0,H.useCallback)(t=>{if(!t)return!1;if(e&&n.writeToSession(e,t))return!0;if(!l)return!1;try{return l.paste(t),!0}catch{return!1}},[e,n,l]),m=(0,H.useCallback)(e=>{if(!l||!e||e.length===0)return!1;let t=Array.from(e).map(e=>K9(e)).filter(e=>!!e);return t.length===0?!1:p(R9(t,typeof navigator<`u`&&/Win/i.test(navigator.platform||``)))},[l,p]),h=(0,H.useCallback)(e=>{if(e.preventDefault(),!e.shiftKey&&l){let e=l.modes?.mouseTrackingMode;if(e&&e!==`none`)return}o({x:e.clientX,y:e.clientY})},[l]),g=(0,H.useCallback)(e=>{if(!l)return;if(e.clipboardData.files&&e.clipboardData.files.length>0){let t=Array.from(e.clipboardData.files).map(e=>K9(e)).filter(e=>!!e);if(t.length>0){e.preventDefault(),e.stopPropagation(),p(R9(t,typeof navigator<`u`&&/Win/i.test(navigator.platform||``)));return}}let t=e.clipboardData.getData(`text/plain`);t&&(e.preventDefault(),e.stopPropagation(),p(t))},[l,p]),_=(0,H.useCallback)(e=>{if(!l)return;let t=l.getSelection();t&&(e.clipboardData.setData(`text/plain`,t),e.preventDefault(),e.stopPropagation())},[l]),v=(0,H.useCallback)(e=>{if(l&&(typeof navigator<`u`&&/Mac/i.test(navigator.platform||``)?e.metaKey:e.ctrlKey)&&(e.key===`c`||e.key===`C`)){let t=l.getSelection();if(!t)return;e.preventDefault(),e.stopPropagation(),C9(t)}},[l]);return(0,H.useEffect)(()=>{let r=t.current;if(!r||!e)return;let i=n.getContainer(e);if(i)return r.appendChild(i),n.notifyAdopted(e),()=>{let e=document.getElementById(`specrails-terminal-host`);e&&i.parentElement===r&&e.appendChild(i)}},[e,n]),(0,H.useEffect)(()=>{let r=t.current;if(!r||!e)return;let i=[],a=r.parentElement;for(;a&&a!==document.body;)(a.tagName.toLowerCase()===`aside`||a.matches(`[data-sidebar]`))&&i.push(a),a=a.parentElement;if(i.length===0)return;let o=t=>{let r=t;r.propertyName!==`width`&&r.propertyName!==`height`||n.refitActive(e)};return i.forEach(e=>e.addEventListener(`transitionend`,o)),()=>{i.forEach(e=>e.removeEventListener(`transitionend`,o))}},[e,n]),(0,Y.jsxs)(`div`,{ref:t,className:`flex-1 min-w-0 bg-background px-2 py-1 relative ${d?`outline outline-2 outline-accent-primary outline-offset-[-2px]`:``}`,role:`presentation`,"data-terminal-viewport":!0,onContextMenu:h,onPasteCapture:g,onCopyCapture:_,onKeyDownCapture:v,tabIndex:-1,onDragEnter:e=>{q9(e.dataTransfer)&&(e.preventDefault(),e.stopPropagation(),f(!0))},onDragOver:e=>{q9(e.dataTransfer)&&(e.preventDefault(),e.stopPropagation(),f(!0))},onDragLeave:()=>f(!1),onDrop:e=>{q9(e.dataTransfer)&&(e.preventDefault(),e.stopPropagation(),m(e.dataTransfer.files)),f(!1)},children:[e&&(0,Y.jsx)(aae,{sessionId:e}),e&&(0,Y.jsx)(oae,{sessionId:e}),r&&c&&(0,Y.jsx)(tae,{search:c,onClose:()=>i(!1)}),a&&l&&(0,Y.jsx)(nae,{x:a.x,y:a.y,term:l,cwd:u,hasReveal:s,onClose:()=>o(null),onOpenSearch:()=>i(!0),onReveal:e=>{VV(e)},onSaveScrollback:()=>{l&&iae(l)}})]})}function K9(e){let t=e.path;return typeof t==`string`&&t.length>0?t:null}function q9(e){return e?Array.from(e.types).includes(`Files`):!1}function J9({height:e,maxHeight:t,onHeightCommit:n,onHeightPreview:r,minHeight:i=120}){let{t:a}=K(`terminal`),o=(0,H.useRef)(!1),s=(0,H.useRef)(0),c=(0,H.useRef)(e),l=(0,H.useRef)(!1),u=(0,H.useRef)(e),d=(0,H.useCallback)(e=>e<i?i:e>t?t:Math.round(e),[i,t]);(0,H.useEffect)(()=>{function e(e){if(!o.current)return;let t=s.current-e.clientY;u.current=d(c.current+t),l.current||(l.current=!0,requestAnimationFrame(()=>{l.current=!1,r?.(u.current)}))}function t(){o.current&&(o.current=!1,document.body.style.userSelect=``,document.body.style.cursor=``,n(u.current))}return window.addEventListener(`pointermove`,e),window.addEventListener(`pointerup`,t),window.addEventListener(`pointercancel`,t),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,t),window.removeEventListener(`pointercancel`,t)}},[d,n,r]);function f(t){o.current=!0,s.current=t.clientY,c.current=e,u.current=e,document.body.style.userSelect=`none`,document.body.style.cursor=`row-resize`;let n=t.target;if(typeof n.setPointerCapture==`function`)try{n.setPointerCapture(t.pointerId)}catch{}}return(0,Y.jsx)(`div`,{role:`separator`,"aria-orientation":`horizontal`,"aria-label":a(`dragHandle.resize`),onPointerDown:f,className:X(`absolute top-0 left-0 right-0 h-1`,`cursor-row-resize`,`bg-transparent hover:bg-accent-primary/40`,`transition-colors duration-120`,`z-10`)})}function lae({onCreate:e}){let{t}=K(`terminal`);return(0,Y.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-center px-6 bg-background-deep`,children:(0,Y.jsxs)(`div`,{className:`flex flex-col items-center gap-3 text-muted-foreground`,children:[(0,Y.jsx)(ac,{className:`h-8 w-8 opacity-50`}),(0,Y.jsx)(`p`,{className:`text-xs`,children:t(`emptyState.noTerminals`)}),(0,Y.jsxs)(`button`,{type:`button`,onClick:e,className:`inline-flex items-center gap-1.5 px-2.5 py-1.5 rounded-md text-xs bg-border/30 hover:bg-border/50 hover:text-foreground transition-colors`,children:[(0,Y.jsx)(ks,{className:`h-3 w-3`}),` `,t(`emptyState.newTerminal`)]})]})})}var uae=300;function dae({projectId:e,provider:t=`claude`,providers:n,state:r,viewportHeight:i,statusBarHeight:a}){let o=O9(),{t:s}=K(`terminal`),c=_t(),l=(0,H.useRef)(null),[u,d]=(0,H.useState)(null),[f,p]=(0,H.useState)(vW),[m,h]=(0,H.useState)(null),[g,_]=(0,H.useState)(null),v=(0,H.useRef)(a===0&&r.visibility!==`hidden`),[y,b]=(0,H.useState)(()=>r.visibility===`hidden`?`hidden`:v.current?`opening`:`open`),x=(0,H.useRef)(!1),S=n&&n.length>0?n:[t],C=S.length>1,w=(0,H.useCallback)(async(t=()=>!1)=>{try{let n=await fetch(`/api/projects/${e}/terminal-settings`);if(!n.ok)return;let r=await n.json();!t()&&r?.resolved&&p(r.resolved)}catch{}},[e]);(0,H.useEffect)(()=>{let e=!1;return w(()=>e),()=>{e=!0}},[w]),(0,H.useEffect)(()=>{let t=t=>{let n=t.detail;n?.mode===`project`&&n.projectId!==e||w()};return window.addEventListener(bW,t),()=>window.removeEventListener(bW,t)},[w,e]);let T=Math.max(120,i-a-40),E=Math.min(Math.max(r.userHeight||320,120),T),D=r.visibility===`maximized`?Math.max(120,i-a):u??E,O=y===`open`,k=O?D:0,A=a===0,j=r.sessions.length<10,M=r.activeId!==null;(0,H.useEffect)(()=>{let e=null,t=null,n=null,i=()=>{b(`opening`),t=requestAnimationFrame(()=>{n=requestAnimationFrame(()=>b(`open`))})};return x.current?(r.visibility===`hidden`?(b(`closing`),e=setTimeout(()=>b(`hidden`),uae)):i(),()=>{e&&clearTimeout(e),t!==null&&cancelAnimationFrame(t),n!==null&&cancelAnimationFrame(n)}):(x.current=!0,v.current&&i(),()=>{t!==null&&cancelAnimationFrame(t),n!==null&&cancelAnimationFrame(n)})},[r.visibility]),(0,H.useEffect)(()=>{let e=!1,t=null;return Jie(()=>{let e=l.current,t=r.activeId;return!e||!t||r.visibility===`hidden`?null:{viewportEl:e,writeText:e=>{if(o.writeToSession(t,e))return!0;let n=o.getTerminalInstance(t);try{return n?.paste(e),!!n}catch{return!1}}}}).then(n=>{e?n.dispose():t=n}),()=>{e=!0,t?.dispose()}},[r.activeId,r.visibility,o]);let N=(0,H.useCallback)(()=>{j&&o.create(e)},[j,e,o]),P=(0,H.useCallback)(t=>{if(!j)return;let n=t||`claude`,i=RegExp(`^${n} \\(\\d+\\)$`),a=r.sessions.filter(e=>e.name===n||i.test(e.name)),s=a.length===0?n:`${n} (${a.length+1})`;o.createAndType(e,`${n}\n`,{name:s})},[j,e,r.sessions,o]),F=(0,H.useCallback)(e=>{if(j){if(C&&e){_(e);return}P(t)}},[j,C,t,P]),I=(0,H.useCallback)(()=>{HV(f.browserShortcutUrl)},[f.browserShortcutUrl]),L=(0,H.useCallback)(()=>{r.activeId&&f.quickScript&&o.writeToSession(r.activeId,f.quickScript)},[f.quickScript,r.activeId,o]),R=(0,H.useCallback)(e=>{h({...e,kind:`browser`})},[]),z=(0,H.useCallback)(e=>{h({...e,kind:`script`})},[]),ee=(0,H.useCallback)(e=>{c(`/settings${e===`browser`?`#terminal-browser-shortcut-url`:`#terminal-quick-script`}`)},[c]),te=(0,H.useCallback)(()=>{r.activeId&&o.kill(e,r.activeId)},[e,r.activeId,o]),B=(0,H.useCallback)(()=>{o.setVisibility(e,r.visibility===`maximized`?`restored`:`maximized`)},[e,r.visibility,o]),ne=(0,H.useCallback)(()=>{o.setVisibility(e,`hidden`)},[e,o]);return(0,H.useEffect)(()=>{d(null)},[r.visibility]),y===`hidden`?null:(0,Y.jsxs)(`div`,{ref:l,className:X(`relative flex flex-col shrink-0 overflow-hidden origin-bottom transform-gpu bg-background/95`,`border-t border-border/40`,`transition-[height,opacity,transform,clip-path] duration-300 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none`),style:{height:k,opacity:+!!O,transform:O?`translateY(0) scaleY(1)`:`translateY(${A?14:8}px) scaleY(${A?.96:.985})`,clipPath:O?`inset(0 0 0 0)`:`inset(100% 0 0 0)`},"data-testid":`terminal-bottom-panel`,children:[(0,Y.jsx)(J9,{height:E,maxHeight:T,onHeightPreview:e=>d(e),onHeightCommit:t=>{d(null),o.setUserHeight(e,t),r.visibility===`maximized`&&o.setVisibility(e,`restored`)}}),(0,Y.jsx)(Qie,{visibility:r.visibility,canCreate:j,hasActive:M,provider:t,providers:S,onCreate:N,onOpenCli:F,onOpenBrowser:I,onPasteScript:L,pasteScriptDisabled:!M||!f.quickScript,onConfigureBrowser:R,onConfigureScript:z,onKillActive:te,onToggleMaximize:B,onCollapse:ne}),m&&(0,Y.jsx)(Xie,{x:m.x,y:m.y,label:m.kind===`browser`?s(`shortcutMenu.configureBrowserUrl`):s(`shortcutMenu.editQuickScript`),onSelect:()=>ee(m.kind),onClose:()=>h(null)}),g&&(0,Y.jsx)(Zie,{x:g.x,y:g.y,providers:S,onSelect:e=>P(e),onClose:()=>_(null)}),(0,Y.jsx)(`div`,{className:`flex-1 flex min-h-0`,children:r.sessions.length===0?(0,Y.jsx)(lae,{onCreate:N}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(cae,{activeId:r.activeId}),(0,Y.jsx)($ie,{sessions:r.sessions,activeId:r.activeId,onActivate:t=>o.setActive(e,t),onRename:(t,n)=>void o.rename(e,t,n),onKill:t=>void o.kill(e,t)})]})})]})}function fae({connectionStatus:e,rightSlot:t,minimal:n=!1}){let{t:r}=K(`nav`),{t:i}=K(`analytics`),[a,o]=(0,H.useState)(null),[s,c]=(0,H.useState)(!1),l=(0,H.useRef)(`connecting`),u=(0,H.useRef)(!0);(0,H.useEffect)(()=>{let t=l.current;if(e===`connected`&&!u.current&&t!==`connected`){q.success(r(`statusBar.connectionRestored`)),c(!0);let e=setTimeout(()=>c(!1),2e3);return()=>clearTimeout(e)}u.current&&e===`connected`&&(u.current=!1),l.current=e},[e]),(0,H.useEffect)(()=>{u.current&&=!1},[]),(0,H.useEffect)(()=>{if(n)return;async function e(){try{let e=await fetch(`${af()}/stats`);e.ok&&o(await e.json())}catch{}}e();let t=setInterval(e,3e4);return()=>clearInterval(t)},[e,n]);let d=!n||e!==`connected`||s;return(0,Y.jsxs)(`footer`,{className:`h-7 flex items-center justify-between px-4 border-t border-border/30 bg-background/80 backdrop-blur-sm text-[10px] text-muted-foreground`,children:[(0,Y.jsxs)(`div`,{className:X(`flex items-center gap-1.5 transition-opacity duration-300`,!d&&`opacity-0`),"aria-hidden":!d||void 0,children:[(0,Y.jsx)(`span`,{className:X(`w-1.5 h-1.5 rounded-full transition-colors`,e===`connected`&&!s&&`bg-accent-success`,e===`connected`&&s&&`bg-accent-info animate-pulse`,e===`connecting`&&`bg-accent-warning animate-[pulse_0.75s_ease-in-out_infinite]`,e===`disconnected`&&`bg-destructive`)}),(0,Y.jsxs)(`span`,{className:X(`transition-colors`,e===`connected`&&!s&&`text-accent-success`,e===`connected`&&s&&`text-accent-info`,e===`connecting`&&`text-accent-warning`,e===`disconnected`&&`text-destructive`),children:[e===`connected`&&!s&&r(`statusBar.connected`),e===`connected`&&s&&r(`statusBar.syncing`),e===`connecting`&&r(`statusBar.reconnecting`),e===`disconnected`&&r(`statusBar.disconnected`)]})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!n&&a&&a.totalCostUsd>0&&(()=>{let e=a.includesEstimated??((a.estimatedCostUsd??0)>0||(a.estimatedCostToday??0)>0);return(0,Y.jsxs)(`span`,{"data-estimated":e?`true`:void 0,title:e?i(`desktop.statusBarEstimatedTooltip`):void 0,children:[e?`~`:``,`$`,a.totalCostUsd.toFixed(2)]})})(),t]})]})}var pae={"pinned-open":`sidebarPin.right.pinnedOpen`,"pinned-collapsed":`sidebarPin.right.pinnedCollapsed`,unpinned:`sidebarPin.right.unpinned`};function mae(){let{t:e}=K(`agent`),{t}=K(`nav`),{rightMode:n,cycleRightMode:r}=CY(),{activeProjectId:i}=gm(),a=O9(),o=J5(),{active:s}=N7(),[c,l]=(0,H.useState)(!1),u=n===`pinned-open`||n===`unpinned`&&c,d=cY(`right-workspace`,{side:`right`,defaultWidth:208,min:180,max:460,collapsedWidth:44,expanded:u}),f=n!==`unpinned`,p=t(pae[n]),m=!i,h=[{key:`jobs`,icon:Xa,label:e(`workspace.jobs`),onClick:()=>o.toggleJobsPane(),disabled:m,disabledTitle:e(`workspace.requiresProject`)},...SO()?[{key:`browser`,icon:Ko,label:e(`workspace.browser`),onClick:()=>o.openBrowser(),disabled:m||!s,disabledTitle:e(m?`workspace.requiresProject`:`workspace.requiresConversation`)}]:[],...Mb?[{key:`terminal`,icon:ec,label:e(`workspace.terminal`),onClick:()=>i&&a.togglePanel(i),disabled:m,disabledTitle:e(`workspace.requiresProject`)}]:[],...Pb?[{key:`files`,icon:Ao,label:e(`workspace.files`),onClick:()=>o.toggleCodePane(),disabled:m,disabledTitle:e(`workspace.requiresProject`)}]:[]];return(0,Y.jsxs)(`div`,{ref:d.panelRef,className:X(`relative flex flex-col h-full border-l border-border bg-background flex-shrink-0 overflow-hidden`,`transition-[width] duration-200 ease-in-out`),onMouseEnter:()=>{n===`unpinned`&&l(!0)},onMouseLeave:()=>{n===`unpinned`&&!d.dragging&&l(!1)},children:[u&&(0,Y.jsx)(lY,{side:`right`,dragging:d.dragging,width:d.width,min:180,max:460,label:t(`sidebarPin.resize`,{defaultValue:`Resize sidebar`}),onPointerDown:d.onGripPointerDown,onKeyDown:d.onGripKeyDown}),(0,Y.jsxs)(`div`,{className:X(`flex items-center h-12 border-b border-border flex-shrink-0`,u?`px-3 justify-between`:`justify-center`),children:[u&&(0,Y.jsx)(`span`,{className:`font-mono text-sm font-bold whitespace-nowrap overflow-hidden text-accent-secondary`,children:e(`workspace.title`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:r,className:X(`flex items-center justify-center w-7 h-7 rounded-md transition-colors`,f?`text-foreground bg-muted`:`text-muted-foreground/40 hover:text-muted-foreground hover:bg-muted/50`),"aria-label":p,title:t(`sidebarPin.withShortcut`,{label:p,shortcut:`⌘B`}),children:(0,Y.jsx)(xs,{className:`w-4 h-4`})})]}),(0,Y.jsx)(`nav`,{className:`flex-1 py-2 px-1.5 space-y-0.5`,children:h.map(({key:e,icon:t,label:n,onClick:r,disabled:i,disabledTitle:a})=>(0,Y.jsxs)(`button`,{type:`button`,onClick:r,disabled:i,className:X(`flex items-center gap-2 w-full h-8 rounded-md transition-colors`,u?`px-2`:`px-0 justify-center`,i?`text-muted-foreground/40 cursor-not-allowed`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),title:i?a:u?void 0:n,children:[(0,Y.jsx)(t,{className:`w-4 h-4 flex-shrink-0`}),u&&(0,Y.jsx)(`span`,{className:`text-xs truncate`,children:n})]},e))})]})}var hae=(0,H.lazy)(()=>a(()=>import(`./AgentModeCodePane-GZc8bNGT.js`).then(e=>({default:e.AgentModeCodePane})),__vite__mapDeps([38,1,39]))),gae=(0,H.lazy)(()=>a(()=>import(`./AgentModeJobsPane-DWtQqj3k.js`).then(e=>({default:e.AgentModeJobsPane})),__vite__mapDeps([40,1,27,28,29,30,31,41]))),_ae=(0,H.lazy)(()=>a(()=>import(`./AgentBrowserCapture-BUHPHNSN.js`).then(e=>({default:e.AgentBrowserCapture})),__vite__mapDeps([42,1])));function vae(){let{t:e}=K(`agent`),{active:t,refreshConversations:n}=N7(),{codePaneOpen:r,jobsPaneOpen:i,browserOpen:a}=J5(),{activeProjectId:o}=gm(),s=BU(),c=s.id===`galaxy`,l=s.id===`code-rain`?e(`emptyTitleCodeRain`):e(`emptyTitle`);(0,H.useEffect)(()=>{n()},[n]);let u=r&&!!o,d=i&&!!o;return(0,Y.jsx)(r6,{reducedMotion:`user`,children:(0,Y.jsxs)(`div`,{"data-agent-mode-surface":!0,className:`relative z-0 flex h-full w-full overflow-hidden bg-background`,children:[c&&(0,Y.jsx)(JU,{}),(0,Y.jsxs)(`div`,{className:`relative flex h-full min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,Y.jsx)(V8.div,{"aria-hidden":!0,className:`pointer-events-none absolute inset-0 z-0`,animate:{opacity:+(t===null)},transition:{duration:.5,ease:`easeOut`},style:{background:`radial-gradient(60% 55% at 50% 45%, color-mix(in srgb, var(--color-accent-primary) 13%, transparent), transparent 70%)`}}),t===null?(0,Y.jsx)(`div`,{className:`relative z-10 flex h-full w-full items-center justify-center px-6`,children:(0,Y.jsxs)(V8.div,{layoutId:`agent-composer-dock`,initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.28,ease:[.34,1.56,.64,1],layout:{type:`spring`,stiffness:350,damping:34}},className:`w-full max-w-[680px] rounded-2xl border border-border/60 bg-card/90 p-4 shadow-2xl backdrop-blur-xl`,children:[(0,Y.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 px-1`,children:[(0,Y.jsx)(qa,{className:`h-4 w-4 text-accent-primary`}),(0,Y.jsx)(`span`,{className:`text-sm font-medium text-foreground/80`,children:l})]}),(0,Y.jsx)(u7,{autoFocus:!0})]})}):(0,Y.jsx)(`div`,{className:`relative z-10 flex min-h-0 flex-1 flex-col overflow-hidden`,children:(0,Y.jsx)(S7,{variant:`inline`})})]}),d&&(0,Y.jsx)(H.Suspense,{fallback:(0,Y.jsx)(`div`,{className:`w-[480px] border-l border-border`}),children:(0,Y.jsx)(gae,{projectId:o})}),u&&(0,Y.jsx)(H.Suspense,{fallback:(0,Y.jsx)(`div`,{className:`w-[520px] border-l border-border`}),children:(0,Y.jsx)(hae,{projectId:o,conversationId:t?.id??`__home__`})}),a&&o&&(0,Y.jsx)(H.Suspense,{fallback:null,children:(0,Y.jsx)(_ae,{projectId:o,conversationId:t?.id??null})})]})})}function yae(){let{state:e,openTicketDetail:t,enterSplit:n,setComparedTicket:r}=dH(),{tickets:i}=Em(),a=mt(),o=_t(),s=(0,H.useRef)(!1);(0,H.useEffect)(()=>{if(s.current||i.length===0||new URLSearchParams(a.search).get(`compare`)&&typeof window<`u`&&window.innerWidth<900)return;s.current=!0;let e=new URLSearchParams(a.search),c=e.get(`compare`),l=e.get(`compareSide`);if(!c)return;let u=Number.parseInt(c,10),d=l===`right`?`right`:`left`;if(!i.some(e=>e.id===u)){let e=new URLSearchParams(a.search);e.delete(`compare`),e.delete(`compareSide`);let t=e.toString();o({pathname:a.pathname,search:t?`?${t}`:``},{replace:!0});return}let f=e.get(`compareOrigin`);if(f){let e=Number.parseInt(f,10);if(i.some(t=>t.id===e)){t(e),n(d),r(u,d===`left`?`right`:`left`);return}}t(u)},[i,a.search,a.pathname,o,t,n,r]),(0,H.useEffect)(()=>{if(!s.current)return;let t=new URLSearchParams(a.search),n=t.has(`compare`);if(e.originSide===null){if(n){t.delete(`compare`),t.delete(`compareSide`),t.delete(`compareOrigin`);let e=t.toString();o({pathname:a.pathname,search:e?`?${e}`:``},{replace:!0})}return}let r=e.originSide===`left`?e.leftId:e.rightId,i=e.originSide===`left`?e.rightId:e.leftId;if(r==null||e.originSide==null)return;let c=new URLSearchParams(a.search);c.set(`compareSide`,e.originSide),c.set(`compareOrigin`,String(r)),i==null?c.delete(`compare`):c.set(`compare`,String(i));let l=c.toString();l!==(a.search.startsWith(`?`)?a.search.slice(1):a.search)&&o({pathname:a.pathname,search:l?`?${l}`:``},{replace:!0})},[e,a.search,a.pathname,o])}function bae(e){return e.startsWith(`/loops`)?`loops`:e.startsWith(`/plugins`)?`plugins`:null}function xae({uiMode:e,pathname:t,loopsOpen:n,pluginsOpen:r}){if(e===`agent`){let e=bae(t);return e?{kind:`modalize`,surface:e,backgroundPath:`/`}:null}return n?{kind:`route`,surface:`loops`,path:`/loops`}:r?{kind:`route`,surface:`plugins`,path:`/plugins`}:null}var Sae=(0,H.lazy)(()=>a(()=>import(`./JobDetailPage-DwdozwLO.js`),__vite__mapDeps([43,1,28,29,30,31,41]))),Cae=(0,H.lazy)(()=>a(()=>import(`./JobsPage-BDkinklt.js`),__vite__mapDeps([44,1,45,41]))),wae=(0,H.lazy)(()=>a(()=>import(`./AnalyticsPage-CZW8c77k.js`),__vite__mapDeps([46,1,47,48,49,45]))),Tae=(0,H.lazy)(()=>a(()=>import(`./ActivityFeedPage-D8RKRRoM.js`),__vite__mapDeps([50,1]))),Eae=(0,H.lazy)(()=>a(()=>import(`./AgentsPage-CKPtHkRP.js`),__vite__mapDeps([51,1]))),Dae=(0,H.lazy)(()=>a(()=>import(`./CodePage-CQ-uKETG.js`),__vite__mapDeps([52,1,39]))),Oae=(0,H.lazy)(()=>a(()=>import(`./IntegrationsPage-B72WxJ3Z.js`),[])),Y9=(0,H.lazy)(()=>a(()=>import(`./PluginsPage-wdC-qa40.js`),__vite__mapDeps([53,1,31]))),kae=(0,H.lazy)(()=>a(()=>import(`./DesktopAnalyticsPage-Bgo4SyCH.js`),__vite__mapDeps([54,1,47,48,49]))),X9=(0,H.lazy)(()=>a(()=>import(`./DocsPage-CmcOkK19.js`),__vite__mapDeps([55,1,29,56,57]))),Aae=(0,H.lazy)(()=>a(()=>import(`./DocsDialog-DxpWw_La.js`),__vite__mapDeps([58,1,29,56,57]))),Z9=(0,H.lazy)(()=>a(()=>import(`./LoopsPage-D7ac4M24.js`),__vite__mapDeps([59,1,60,33,30]))),jae=(0,H.lazy)(()=>a(()=>import(`./LoopBuilderPage-CclJ3VZA.js`),__vite__mapDeps([61,1,49,30,60,62]))),Mae=28;function Q9({surface:e,onClose:t}){let{t:n}=K(`nav`),r=n(e===`loops`?`arcSidebar.loops`:`arcSidebar.plugins`);return(0,Y.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center justify-between gap-3 border-b border-border bg-popover/95 px-3`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`grid h-7 w-7 shrink-0 place-items-center rounded-md border border-accent-primary/20 bg-accent-primary/10 text-accent-primary`,children:(0,Y.jsx)(e===`loops`?mc:As,{className:`h-3.5 w-3.5`})}),(0,Y.jsx)(`span`,{className:`truncate text-xs font-medium text-foreground`,children:r})]}),(0,Y.jsx)(`div`,{className:`flex shrink-0 items-center`,children:(0,Y.jsx)(`button`,{type:`button`,onClick:t,className:`grid h-7 w-7 place-items-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:ring-offset-popover`,"aria-label":n(`common:actions.close`),children:(0,Y.jsx)(hc,{className:`h-4 w-4`})})})]})}var Nae=new Set([`/settings`,`/loops`,`/plugins`]);function $9(e){return Nae.has(e)||e.startsWith(`/loops`)||e.startsWith(`/plugins`)||e.startsWith(`/docs`)}var Pae=`specrails-desktop:routeMemory`;try{localStorage.removeItem(Pae)}catch{}function Fae(e){let t=mt(),n=_t(),r=(0,H.useRef)(new Map),i=(0,H.useRef)(null),a=(0,H.useRef)(!1);(0,H.useEffect)(()=>{vc((e,t)=>{r.current.set(e,t)})},[]),(0,H.useEffect)(()=>{a.current||(a.current=!0,t.pathname!==`/`&&n(`/`,{replace:!0}))},[]),(0,H.useEffect)(()=>{if(i.current&&i.current!==e&&!$9(t.pathname)&&r.current.set(i.current,t.pathname),e&&e!==i.current){let i=r.current.get(e),a=i&&!$9(i)?i:`/`;t.pathname!==a&&n(a,{replace:!0})}i.current=e},[e,t.pathname,n]),(0,H.useEffect)(()=>{e&&t.pathname!==`/`&&!$9(t.pathname)&&r.current.set(e,t.pathname)},[e,t.pathname])}function Iae(){let{t:e}=K(`common`),{projects:t,activeProjectId:n,isLoading:r,isSwitchingProject:i,setupProjectIds:a,completeSetupWizard:o,setActiveProjectId:s}=gm(),{cycleLeftMode:c,cycleRightMode:l}=CY(),u=_t(),d=mt(),f=O9(),p=N7(),{startNewConversation:m}=p,{uiMode:h}=hq();yae();let[g,_]=(0,H.useState)(!1),[v,y]=(0,H.useState)(!1),[b,x]=(0,H.useState)(!1),[S,C]=(0,H.useState)(!1),[w,T]=(0,H.useState)(!1),[E,D]=(0,H.useState)(!1),O=(0,H.useCallback)(()=>D(!1),[]),[k,A]=(0,H.useState)(()=>!WJ());Fae(n),die();let{cheatsheetOpen:j,setCheatsheetOpen:M,openCheatsheet:N}=PK(),P=[`/`,`/jobs`,`/analytics`,...Nb?[`/agents`]:[],...Pb?[`/code`]:[],`/integrations`,`/settings`];NK({onOpenCheatsheet:N,onToggleLeftSidebar:c,onToggleRightSidebar:l,onSwitchProject:e=>{let n=t[e-1];n&&s(n.id)},onSwitchProjectPage:e=>{let t=P[e-1];t&&u(t)},onToggleTerminalPanel:Mb?()=>{n&&(f.togglePanel(n),f.getState(n).visibility===`hidden`?queueMicrotask(()=>f.focusActive(n)):f.focusActive(n))}:void 0,onToggleAgentChat:Lb&&h!==`agent`?()=>p.toggle():void 0}),wK({setActiveProjectId:s,projectsById:(0,H.useMemo)(()=>new Map(t.map(e=>[e.id,e.name])),[t])});let F=t.find(e=>e.id===n),I=n!==null&&a.has(n),L=d.pathname.startsWith(`/loops`),R=d.pathname.startsWith(`/plugins`),z=d.pathname.startsWith(`/docs`)||h!==`agent`&&(L||R);(0,H.useLayoutEffect)(()=>{let e=xae({uiMode:h,pathname:d.pathname,loopsOpen:S,pluginsOpen:w});if(e){if(e.kind===`modalize`){e.surface===`loops`?(T(!1),C(!0)):(C(!1),T(!0)),m(n),d.pathname!==e.backgroundPath&&u(e.backgroundPath,{replace:!0});return}C(!1),T(!1),d.pathname!==e.path&&u(e.path,{replace:!0})}},[n,d.pathname,S,u,w,m,h]);let{connectionStatus:ee}=N9(),te=Rie(n),B=h===`agent`?0:Mae,ne=(0,H.useRef)(null),[V,re]=(0,H.useState)(typeof window<`u`?window.innerHeight:820);(0,H.useLayoutEffect)(()=>{if(!Mb)return;let e=ne.current;if(!e)return;let t=()=>re(e.clientHeight);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[r]),(0,H.useEffect)(()=>{!Mb||!n||f.ensureProject(n)},[n,f]);let U=Mb&&h===`kanban`&&te.visibility===`hidden`?(0,Y.jsx)(V9,{isOpen:!1,onClick:()=>n&&f.setVisibility(n,`restored`)}):null;return r?(0,Y.jsxs)(`div`,{className:`flex h-full`,children:[(0,Y.jsx)(`div`,{className:`w-11 border-r border-border bg-card/50 animate-pulse flex-shrink-0`}),(0,Y.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`states.loading`)})})]}):(0,Y.jsxs)(`div`,{className:`flex h-full overflow-hidden font-sans`,children:[(0,Y.jsx)(wre,{onAddProject:()=>_(!0),onOpenLoops:()=>{h===`agent`?C(!0):u(`/loops`)},onOpenPlugins:()=>{h===`agent`?T(!0):u(`/plugins`)},onOpenAnalytics:()=>x(!0),onOpenDocs:()=>D(!0),onOpenSettings:()=>y(!0)}),(0,Y.jsxs)(`div`,{ref:ne,className:`flex flex-col flex-1 overflow-hidden`,children:[i&&(0,Y.jsx)(`div`,{className:`h-0.5 w-full bg-accent-primary/70 animate-pulse shrink-0`,"data-testid":`project-switching-bar`}),(0,Y.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:I&&F?(0,Y.jsx)(VJ,{project:F,onComplete:()=>o(F.id),onSkip:()=>o(F.id)},F.id):h===`agent`&&!z?(0,Y.jsx)(vae,{}):(0,Y.jsx)(H.Suspense,{fallback:(0,Y.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`states.loading`)})}),children:(0,Y.jsxs)(Yt,{children:[(0,Y.jsx)(qt,{path:`/docs`,element:(0,Y.jsx)(X9,{})}),(0,Y.jsx)(qt,{path:`/docs/:category/:slug`,element:(0,Y.jsx)(X9,{})}),zb&&(0,Y.jsx)(qt,{path:`/loops`,element:(0,Y.jsx)(Z9,{})}),zb&&(0,Y.jsx)(qt,{path:`/loops/:id/edit`,element:(0,Y.jsx)(jae,{})}),(0,Y.jsx)(qt,{path:`/plugins`,element:(0,Y.jsx)(Y9,{})}),t.length===0?(0,Y.jsx)(qt,{path:`*`,element:(0,Y.jsx)(Zq,{onAddProject:()=>_(!0)})}):F?(0,Y.jsxs)(qt,{element:(0,Y.jsx)(Xq,{projectName:F.name,children:(0,Y.jsx)(Jq,{project:F})},F.id),children:[(0,Y.jsx)(qt,{path:`/`,element:(0,Y.jsx)(uW,{})}),(0,Y.jsx)(qt,{path:`/jobs`,element:(0,Y.jsx)(Cae,{})}),(0,Y.jsx)(qt,{path:`/jobs/:id`,element:(0,Y.jsx)(Sae,{})}),(0,Y.jsx)(qt,{path:`/analytics`,element:(0,Y.jsx)(wae,{})}),(0,Y.jsx)(qt,{path:`/activity`,element:(0,Y.jsx)(Tae,{})}),(0,Y.jsx)(qt,{path:`/agents`,element:(0,Y.jsx)(Eae,{})}),(0,Y.jsx)(qt,{path:`/code`,element:Pb?(0,Y.jsx)(Dae,{}):(0,Y.jsx)(Gt,{to:`/`,replace:!0})}),(0,Y.jsx)(qt,{path:`/integrations`,element:(0,Y.jsx)(Oae,{})}),(0,Y.jsx)(qt,{path:`/settings`,element:(0,Y.jsx)(IW,{})}),(0,Y.jsx)(qt,{path:`*`,element:(0,Y.jsx)(Gt,{to:`/`,replace:!0})})]}):(0,Y.jsx)(qt,{path:`*`,element:(0,Y.jsx)(Zq,{onAddProject:()=>_(!0)})})]})})}),Mb&&n&&F&&(0,Y.jsx)(dae,{projectId:n,provider:F.provider,providers:lm(F),state:te,viewportHeight:V,statusBarHeight:B}),h!==`agent`&&(0,Y.jsx)(fae,{connectionStatus:ee,rightSlot:U})]}),h===`agent`?!I&&!z&&(0,Y.jsx)(mae,{}):F&&!I&&!z&&(0,Y.jsx)(Ere,{}),(0,Y.jsx)(Fre,{open:g,onClose:()=>_(!1)}),(0,Y.jsx)(OK,{open:v,onClose:()=>y(!1),onOpenOnboarding:()=>{y(!1),A(!0)}}),(0,Y.jsx)(Cb,{open:b,onOpenChange:x,children:(0,Y.jsx)(Db,{className:`max-w-5xl max-h-[90vh] overflow-hidden p-0 flex flex-col`,children:(0,Y.jsx)(`div`,{className:`flex-1 overflow-auto`,children:(0,Y.jsx)(H.Suspense,{fallback:(0,Y.jsx)(`div`,{className:`flex items-center justify-center h-40`,children:(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`states.loading`)})}),children:(0,Y.jsx)(kae,{})})})})}),(0,Y.jsx)(Cb,{open:S,onOpenChange:C,children:(0,Y.jsxs)(Db,{showCloseButton:!1,className:`max-w-[96vw] w-[96vw] h-[92vh] max-h-[92vh] overflow-hidden p-0 flex flex-col`,children:[(0,Y.jsx)(Ab,{className:`sr-only`,children:e(`nav:arcSidebar.loops`)}),(0,Y.jsx)(jb,{className:`sr-only`,children:e(`nav:globalSurfaceModal.loopsDescription`)}),(0,Y.jsx)(Q9,{surface:`loops`,onClose:()=>C(!1)}),(0,Y.jsx)(`div`,{className:`flex-1 overflow-auto`,children:(0,Y.jsx)(H.Suspense,{fallback:(0,Y.jsx)(`div`,{className:`flex items-center justify-center h-40`,children:(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`states.loading`)})}),children:(0,Y.jsx)(Z9,{})})})]})}),(0,Y.jsx)(Cb,{open:w,onOpenChange:T,children:(0,Y.jsxs)(Db,{showCloseButton:!1,className:`max-w-[96vw] w-[96vw] h-[92vh] max-h-[92vh] overflow-hidden p-0 flex flex-col`,children:[(0,Y.jsx)(Ab,{className:`sr-only`,children:e(`nav:arcSidebar.plugins`)}),(0,Y.jsx)(jb,{className:`sr-only`,children:e(`nav:globalSurfaceModal.pluginsDescription`)}),(0,Y.jsx)(Q9,{surface:`plugins`,onClose:()=>T(!1)}),(0,Y.jsx)(`div`,{className:`flex-1 overflow-auto`,children:(0,Y.jsx)(H.Suspense,{fallback:(0,Y.jsx)(`div`,{className:`flex items-center justify-center h-40`,children:(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`states.loading`)})}),children:(0,Y.jsx)(Y9,{})})})]})}),(0,Y.jsx)(H.Suspense,{fallback:null,children:(0,Y.jsx)(Aae,{open:E,onClose:O})}),(0,Y.jsx)(oie,{onOpenSettings:()=>y(!0),onOpenAnalytics:()=>x(!0),onOpenDocs:()=>D(!0)}),(0,Y.jsx)(zK,{open:j,onOpenChange:M}),(0,Y.jsx)(aY,{open:k,onClose:()=>A(!1)})]})}function Lae({children:e}){let{activeProjectId:t}=gm();return(0,Y.jsx)(Iie,{activeProjectId:t,children:e})}function Rae({children:e}){let{activeProjectId:t}=gm();return(0,Y.jsx)(cB,{activeProjectId:t,children:e})}function zae({children:e}){let{activeProjectId:t}=gm();return(0,Y.jsx)(pB,{activeProjectId:t,children:e})}function Bae(){return(0,Y.jsx)(`span`,{"aria-hidden":!0,style:{display:`none`}})}function Vae(){let{theme:e}=RU(),t=e.previewSwatches.accents[0],n=e.status.completed,r=e.status.failed,i=e.status.canceled,a=e.status.running;return(0,Y.jsx)(ka,{position:`bottom-right`,className:`specrails-toaster`,theme:e.scheme,gap:8,closeButton:!0,visibleToasts:6,icons:{loading:(0,Y.jsx)(Bae,{})},style:{"--accent":t,"--toast-success-border":`color-mix(in srgb, ${n} 38%, transparent)`,"--toast-error-border":`color-mix(in srgb, ${r} 38%, transparent)`,"--toast-warning-border":`color-mix(in srgb, ${i} 38%, transparent)`,"--toast-info-border":`color-mix(in srgb, ${a} 38%, transparent)`},toastOptions:{unstyled:!0,classNames:{toast:`glass-card border border-border/30 text-foreground text-xs p-3 rounded-lg flex items-start gap-2 w-[356px] max-w-[356px] overflow-hidden shadow-lg`,content:`flex-1 min-w-0 flex flex-col gap-0.5`,icon:`shrink-0 mt-[2px] flex items-center justify-center`,title:`font-medium text-sm`,description:`text-muted-foreground mt-0.5`,actionButton:`text-[11px] px-2.5 py-1 rounded-md bg-accent-primary text-white hover:bg-accent-primary/90 whitespace-nowrap shrink-0 self-start`,cancelButton:`text-[11px] px-2.5 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-accent/50 whitespace-nowrap shrink-0 self-start`,closeButton:`text-muted-foreground hover:text-foreground rounded-md p-0.5`,success:`border-l-4 border-l-[var(--toast-success-border)]`,error:`border-l-4 border-l-[var(--toast-error-border)]`,warning:`border-l-4 border-l-[var(--toast-warning-border)]`,info:`border-l-4 border-l-[var(--toast-info-border)]`,loading:``}}})}function Hae(){return AG(),mie(),(0,Y.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,height:`100vh`,overflow:`hidden`},children:(0,Y.jsx)(`div`,{style:{flex:1,overflow:`hidden`,display:`flex`,flexDirection:`column`},children:(0,Y.jsx)(uf,{url:xO,children:(0,Y.jsx)(LU,{children:(0,Y.jsxs)(UW,{children:[(0,Y.jsx)(qq,{}),(0,Y.jsx)(mm,{children:(0,Y.jsxs)(pq,{children:[(0,Y.jsx)(bq,{}),(0,Y.jsx)(vD,{children:(0,Y.jsx)(lie,{children:(0,Y.jsx)(NH,{children:(0,Y.jsx)(SY,{children:(0,Y.jsx)(Lae,{children:(0,Y.jsx)(Rae,{children:(0,Y.jsx)(zae,{children:(0,Y.jsx)(Bg,{children:(0,Y.jsx)(_re,{children:(0,Y.jsx)(cne,{children:(0,Y.jsx)(K5,{children:(0,Y.jsx)(uH,{children:(0,Y.jsxs)(EH,{children:[(0,Y.jsx)(Iae,{}),(0,Y.jsx)(Vae,{})]})})})})})})})})})})})})})]})})]})})})})})}async function Uae(){await l(),s(),await tm(),(0,or.createRoot)(document.getElementById(`root`)).render((0,Y.jsx)(H.StrictMode,{children:(0,Y.jsx)(Rn,{children:(0,Y.jsx)(Hae,{})})}));let e=document.getElementById(`specrails-splash`);e&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{e.classList.add(`is-hidden`),setTimeout(()=>e.remove(),300)})})}Uae();export{Ab as $,z as $n,ws as $t,kz as A,io as An,fc as At,xO as B,za as Bn,qs as Bt,dH as C,po as Cn,gl as Ct,aB as D,co as Dn,gc as Dt,$z as E,lo as En,Gc as Et,cI as F,Ka as Fn,tc as Ft,FE as G,Zi as Gn,zs as Gt,WD as H,J as Hn,Gs as Ht,uF as I,Ua as In,ec as It,Cb as J,Gt as Jn,Fs as Jt,LE as K,Yi as Kn,Rs as Kt,$P as L,Ha as Ln,Qs as Lt,Ez as M,to as Mn,cc as Mt,ez as N,Qa as Nn,ac as Nt,Rz as O,oo as On,hc as Ot,KL as P,Xa as Pn,ic as Pt,Ob as Q,ne as Qn,Ts as Qt,Dk as R,Va as Rn,Xs as Rt,gH as S,bo as Sn,fu as St,hV as T,uo as Tn,sl as Tt,IE as U,q as Un,Us as Ut,JD as V,La as Vn,Ks as Vt,RE as W,K as Wn,Bs as Wt,jb as X,xt as Xn,ks as Xt,Db as Y,_t as Yn,As as Yt,kb as Z,Yn as Zn,Ds as Zt,MW as _,No as _n,$d as _t,f5 as a,os as an,Z as at,BU as b,Oo as bn,ld as bt,W8 as c,Zo as cn,gm as ct,iG as d,Ho as dn,am as dt,ms as en,xb as et,$ as f,Bo as fn,df as ft,DW as g,Po as gn,Ad as gt,PW as h,Fo as hn,Vd as ht,J5 as i,cs as in,ug as it,Sz as j,no as jn,lc as jt,Lz as k,ao as kn,mc as kt,NY as l,Jo as ln,eee as lt,OW as m,Io as mn,af as mt,f7 as n,us as nn,Vg as nt,p5 as o,es as on,X as ot,FW as p,zo as pn,sf as pt,Ub as q,Vn as qn,Is as qt,Hne as r,ls as rn,Hg as rt,D5 as s,Qo as sn,lm as st,N9 as t,ps as tn,yb as tt,CJ as u,Uo as un,im as ut,CW as v,Mo as vn,Yd as vt,vV as w,fo as wn,ol as wt,_H as x,To as xn,su as xt,_W as y,ko as yn,Ld as yt,pk as z,Ba as zn,Ys as zt};