@shepai/cli 1.153.0 → 1.154.0-pr480.e648d12

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 (232) hide show
  1. package/apis/json-schema/AgentType.yaml +1 -0
  2. package/dist/packages/core/src/domain/generated/output.d.ts +1 -0
  3. package/dist/packages/core/src/domain/generated/output.d.ts.map +1 -1
  4. package/dist/packages/core/src/domain/generated/output.js +1 -0
  5. package/dist/packages/core/src/infrastructure/di/container.d.ts.map +1 -1
  6. package/dist/packages/core/src/infrastructure/di/container.js +4 -0
  7. package/dist/packages/core/src/infrastructure/services/agents/common/agent-executor-factory.service.d.ts.map +1 -1
  8. package/dist/packages/core/src/infrastructure/services/agents/common/agent-executor-factory.service.js +22 -0
  9. package/dist/packages/core/src/infrastructure/services/agents/common/agent-validator.service.d.ts.map +1 -1
  10. package/dist/packages/core/src/infrastructure/services/agents/common/agent-validator.service.js +1 -0
  11. package/dist/packages/core/src/infrastructure/services/agents/common/executors/codex-cli-executor.service.d.ts +65 -0
  12. package/dist/packages/core/src/infrastructure/services/agents/common/executors/codex-cli-executor.service.d.ts.map +1 -0
  13. package/dist/packages/core/src/infrastructure/services/agents/common/executors/codex-cli-executor.service.js +655 -0
  14. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/nodes/prompts/merge-prompts.d.ts.map +1 -1
  15. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/nodes/prompts/merge-prompts.js +4 -1
  16. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/nodes/prompts/pr-branding.d.ts +5 -0
  17. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/nodes/prompts/pr-branding.d.ts.map +1 -0
  18. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/nodes/prompts/pr-branding.js +4 -0
  19. package/dist/packages/core/src/infrastructure/services/agents/sessions/codex-cli-session.repository.d.ts +62 -0
  20. package/dist/packages/core/src/infrastructure/services/agents/sessions/codex-cli-session.repository.d.ts.map +1 -0
  21. package/dist/packages/core/src/infrastructure/services/agents/sessions/codex-cli-session.repository.js +353 -0
  22. package/dist/packages/core/src/infrastructure/services/git/git-fork.service.d.ts.map +1 -1
  23. package/dist/packages/core/src/infrastructure/services/git/git-fork.service.js +3 -1
  24. package/dist/packages/core/src/infrastructure/services/git/git-pr.service.d.ts.map +1 -1
  25. package/dist/packages/core/src/infrastructure/services/git/git-pr.service.js +2 -1
  26. package/dist/packages/core/src/infrastructure/services/git/pr-branding.d.ts +17 -0
  27. package/dist/packages/core/src/infrastructure/services/git/pr-branding.d.ts.map +1 -0
  28. package/dist/packages/core/src/infrastructure/services/git/pr-branding.js +31 -0
  29. package/dist/src/presentation/tui/prompts/agent-select.prompt.d.ts +6 -2
  30. package/dist/src/presentation/tui/prompts/agent-select.prompt.d.ts.map +1 -1
  31. package/dist/src/presentation/tui/prompts/agent-select.prompt.js +7 -2
  32. package/dist/src/presentation/web/app/actions/get-all-agent-models.d.ts.map +1 -1
  33. package/dist/src/presentation/web/app/actions/get-all-agent-models.js +4 -2
  34. package/dist/src/presentation/web/components/common/feature-drawer-tabs/event-log-viewer.d.ts.map +1 -1
  35. package/dist/src/presentation/web/components/common/feature-drawer-tabs/event-log-viewer.js +26 -1
  36. package/dist/src/presentation/web/components/common/feature-drawer-tabs/event-log-viewer.stories.d.ts +2 -0
  37. package/dist/src/presentation/web/components/common/feature-drawer-tabs/event-log-viewer.stories.d.ts.map +1 -1
  38. package/dist/src/presentation/web/components/common/feature-drawer-tabs/event-log-viewer.stories.js +21 -0
  39. package/dist/src/presentation/web/components/common/feature-node/agent-type-icons.d.ts +1 -1
  40. package/dist/src/presentation/web/components/common/feature-node/agent-type-icons.d.ts.map +1 -1
  41. package/dist/src/presentation/web/components/common/feature-node/agent-type-icons.js +2 -0
  42. package/dist/src/presentation/web/components/common/feature-node/agent-type-icons.stories.d.ts.map +1 -1
  43. package/dist/src/presentation/web/components/common/feature-node/agent-type-icons.stories.js +1 -0
  44. package/dist/src/presentation/web/components/features/settings/AgentModelPicker/AgentModelPicker.stories.d.ts +1 -0
  45. package/dist/src/presentation/web/components/features/settings/AgentModelPicker/AgentModelPicker.stories.d.ts.map +1 -1
  46. package/dist/src/presentation/web/components/features/settings/AgentModelPicker/AgentModelPicker.stories.js +7 -0
  47. package/dist/src/presentation/web/components/features/settings/agent-settings-section.d.ts.map +1 -1
  48. package/dist/src/presentation/web/components/features/settings/agent-settings-section.js +1 -0
  49. package/dist/src/presentation/web/components/features/settings/agent-settings-section.stories.d.ts +1 -0
  50. package/dist/src/presentation/web/components/features/settings/agent-settings-section.stories.d.ts.map +1 -1
  51. package/dist/src/presentation/web/components/features/settings/agent-settings-section.stories.js +8 -0
  52. package/dist/src/presentation/web/lib/parse-log-line.d.ts +1 -1
  53. package/dist/src/presentation/web/lib/parse-log-line.d.ts.map +1 -1
  54. package/dist/src/presentation/web/lib/parse-log-line.js +1 -1
  55. package/dist/tsconfig.build.tsbuildinfo +1 -1
  56. package/package.json +1 -1
  57. package/web/.next/BUILD_ID +1 -1
  58. package/web/.next/build-manifest.json +2 -2
  59. package/web/.next/fallback-build-manifest.json +2 -2
  60. package/web/.next/prerender-manifest.json +3 -3
  61. package/web/.next/required-server-files.js +3 -3
  62. package/web/.next/required-server-files.json +3 -3
  63. package/web/.next/server/app/(dashboard)/@drawer/adopt/page/server-reference-manifest.json +28 -28
  64. package/web/.next/server/app/(dashboard)/@drawer/adopt/page.js.nft.json +1 -1
  65. package/web/.next/server/app/(dashboard)/@drawer/adopt/page_client-reference-manifest.js +1 -1
  66. package/web/.next/server/app/(dashboard)/@drawer/chat/page/server-reference-manifest.json +26 -26
  67. package/web/.next/server/app/(dashboard)/@drawer/chat/page.js.nft.json +1 -1
  68. package/web/.next/server/app/(dashboard)/@drawer/chat/page_client-reference-manifest.js +1 -1
  69. package/web/.next/server/app/(dashboard)/@drawer/create/page/server-reference-manifest.json +29 -29
  70. package/web/.next/server/app/(dashboard)/@drawer/create/page.js.nft.json +1 -1
  71. package/web/.next/server/app/(dashboard)/@drawer/create/page_client-reference-manifest.js +1 -1
  72. package/web/.next/server/app/(dashboard)/@drawer/feature/[featureId]/[tab]/page/server-reference-manifest.json +36 -36
  73. package/web/.next/server/app/(dashboard)/@drawer/feature/[featureId]/[tab]/page.js.nft.json +1 -1
  74. package/web/.next/server/app/(dashboard)/@drawer/feature/[featureId]/[tab]/page_client-reference-manifest.js +1 -1
  75. package/web/.next/server/app/(dashboard)/@drawer/feature/[featureId]/page/server-reference-manifest.json +36 -36
  76. package/web/.next/server/app/(dashboard)/@drawer/feature/[featureId]/page.js.nft.json +1 -1
  77. package/web/.next/server/app/(dashboard)/@drawer/feature/[featureId]/page_client-reference-manifest.js +1 -1
  78. package/web/.next/server/app/(dashboard)/@drawer/repository/[repositoryId]/[tab]/page/server-reference-manifest.json +26 -26
  79. package/web/.next/server/app/(dashboard)/@drawer/repository/[repositoryId]/[tab]/page.js.nft.json +1 -1
  80. package/web/.next/server/app/(dashboard)/@drawer/repository/[repositoryId]/[tab]/page_client-reference-manifest.js +1 -1
  81. package/web/.next/server/app/(dashboard)/@drawer/repository/[repositoryId]/page/server-reference-manifest.json +26 -26
  82. package/web/.next/server/app/(dashboard)/@drawer/repository/[repositoryId]/page.js.nft.json +1 -1
  83. package/web/.next/server/app/(dashboard)/@drawer/repository/[repositoryId]/page_client-reference-manifest.js +1 -1
  84. package/web/.next/server/app/(dashboard)/chat/page/server-reference-manifest.json +26 -26
  85. package/web/.next/server/app/(dashboard)/chat/page.js.nft.json +1 -1
  86. package/web/.next/server/app/(dashboard)/chat/page_client-reference-manifest.js +1 -1
  87. package/web/.next/server/app/(dashboard)/create/page/server-reference-manifest.json +29 -29
  88. package/web/.next/server/app/(dashboard)/create/page.js.nft.json +1 -1
  89. package/web/.next/server/app/(dashboard)/create/page_client-reference-manifest.js +1 -1
  90. package/web/.next/server/app/(dashboard)/feature/[featureId]/[tab]/page/server-reference-manifest.json +36 -36
  91. package/web/.next/server/app/(dashboard)/feature/[featureId]/[tab]/page.js.nft.json +1 -1
  92. package/web/.next/server/app/(dashboard)/feature/[featureId]/[tab]/page_client-reference-manifest.js +1 -1
  93. package/web/.next/server/app/(dashboard)/feature/[featureId]/page/server-reference-manifest.json +36 -36
  94. package/web/.next/server/app/(dashboard)/feature/[featureId]/page.js.nft.json +1 -1
  95. package/web/.next/server/app/(dashboard)/feature/[featureId]/page_client-reference-manifest.js +1 -1
  96. package/web/.next/server/app/(dashboard)/page/server-reference-manifest.json +26 -26
  97. package/web/.next/server/app/(dashboard)/page.js.nft.json +1 -1
  98. package/web/.next/server/app/(dashboard)/page_client-reference-manifest.js +1 -1
  99. package/web/.next/server/app/(dashboard)/repository/[repositoryId]/[tab]/page/server-reference-manifest.json +26 -26
  100. package/web/.next/server/app/(dashboard)/repository/[repositoryId]/[tab]/page.js.nft.json +1 -1
  101. package/web/.next/server/app/(dashboard)/repository/[repositoryId]/[tab]/page_client-reference-manifest.js +1 -1
  102. package/web/.next/server/app/(dashboard)/repository/[repositoryId]/page/server-reference-manifest.json +26 -26
  103. package/web/.next/server/app/(dashboard)/repository/[repositoryId]/page.js.nft.json +1 -1
  104. package/web/.next/server/app/(dashboard)/repository/[repositoryId]/page_client-reference-manifest.js +1 -1
  105. package/web/.next/server/app/_global-error.html +2 -2
  106. package/web/.next/server/app/_global-error.rsc +1 -1
  107. package/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  108. package/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  109. package/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  110. package/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  111. package/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  112. package/web/.next/server/app/_not-found/page/server-reference-manifest.json +5 -5
  113. package/web/.next/server/app/_not-found/page.js.nft.json +1 -1
  114. package/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  115. package/web/.next/server/app/api/attachments/preview/route.js.nft.json +1 -1
  116. package/web/.next/server/app/api/evidence/route.js.nft.json +1 -1
  117. package/web/.next/server/app/api/graph-data/route.js.nft.json +1 -1
  118. package/web/.next/server/app/api/interactive/chat/[featureId]/messages/route.js.nft.json +1 -1
  119. package/web/.next/server/app/settings/page/server-reference-manifest.json +8 -8
  120. package/web/.next/server/app/settings/page.js.nft.json +1 -1
  121. package/web/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  122. package/web/.next/server/app/skills/page/server-reference-manifest.json +10 -10
  123. package/web/.next/server/app/skills/page.js.nft.json +1 -1
  124. package/web/.next/server/app/skills/page_client-reference-manifest.js +1 -1
  125. package/web/.next/server/app/tools/page/server-reference-manifest.json +10 -10
  126. package/web/.next/server/app/tools/page.js.nft.json +1 -1
  127. package/web/.next/server/app/tools/page_client-reference-manifest.js +1 -1
  128. package/web/.next/server/app/version/page/server-reference-manifest.json +5 -5
  129. package/web/.next/server/app/version/page.js.nft.json +1 -1
  130. package/web/.next/server/app/version/page_client-reference-manifest.js +1 -1
  131. package/web/.next/server/chunks/[root-of-the-server]__6565a045._.js +1 -1
  132. package/web/.next/server/chunks/[root-of-the-server]__a402b567._.js +1 -1
  133. package/web/.next/server/chunks/[root-of-the-server]__beda892a._.js +1 -1
  134. package/web/.next/server/chunks/[root-of-the-server]__beda892a._.js.map +1 -1
  135. package/web/.next/server/chunks/[root-of-the-server]__cd67a84c._.js +1 -1
  136. package/web/.next/server/chunks/[root-of-the-server]__cd67a84c._.js.map +1 -1
  137. package/web/.next/server/chunks/ssr/744ca_web_components_common_control-center-drawer_create-drawer-client_tsx_5e26fc0a._.js +1 -1
  138. package/web/.next/server/chunks/ssr/744ca_web_components_common_control-center-drawer_create-drawer-client_tsx_5e26fc0a._.js.map +1 -1
  139. package/web/.next/server/chunks/ssr/744ca_web_components_common_control-center-drawer_feature-drawer-client_tsx_e9755fc8._.js +3 -3
  140. package/web/.next/server/chunks/ssr/744ca_web_components_common_control-center-drawer_feature-drawer-client_tsx_e9755fc8._.js.map +1 -1
  141. package/web/.next/server/chunks/ssr/[root-of-the-server]__0b150ddf._.js.map +1 -1
  142. package/web/.next/server/chunks/ssr/[root-of-the-server]__17ed7ed1._.js +1 -1
  143. package/web/.next/server/chunks/ssr/[root-of-the-server]__17ed7ed1._.js.map +1 -1
  144. package/web/.next/server/chunks/ssr/[root-of-the-server]__28d0d265._.js +2 -2
  145. package/web/.next/server/chunks/ssr/[root-of-the-server]__28d0d265._.js.map +1 -1
  146. package/web/.next/server/chunks/ssr/[root-of-the-server]__357d99f9._.js +1 -1
  147. package/web/.next/server/chunks/ssr/[root-of-the-server]__42bf1807._.js +1 -1
  148. package/web/.next/server/chunks/ssr/[root-of-the-server]__42bf1807._.js.map +1 -1
  149. package/web/.next/server/chunks/ssr/[root-of-the-server]__56b70465._.js +1 -1
  150. package/web/.next/server/chunks/ssr/[root-of-the-server]__56b70465._.js.map +1 -1
  151. package/web/.next/server/chunks/ssr/[root-of-the-server]__88f7e8e6._.js +1 -1
  152. package/web/.next/server/chunks/ssr/[root-of-the-server]__88f7e8e6._.js.map +1 -1
  153. package/web/.next/server/chunks/ssr/[root-of-the-server]__8b0aac03._.js +1 -1
  154. package/web/.next/server/chunks/ssr/[root-of-the-server]__8b0aac03._.js.map +1 -1
  155. package/web/.next/server/chunks/ssr/[root-of-the-server]__c30f1f82._.js +1 -1
  156. package/web/.next/server/chunks/ssr/[root-of-the-server]__c30f1f82._.js.map +1 -1
  157. package/web/.next/server/chunks/ssr/[root-of-the-server]__f80bfc75._.js +1 -1
  158. package/web/.next/server/chunks/ssr/[root-of-the-server]__f80bfc75._.js.map +1 -1
  159. package/web/.next/server/chunks/ssr/[root-of-the-server]__f8dd4422._.js +1 -1
  160. package/web/.next/server/chunks/ssr/[root-of-the-server]__f8dd4422._.js.map +1 -1
  161. package/web/.next/server/chunks/ssr/_05c23ad9._.js +1 -1
  162. package/web/.next/server/chunks/ssr/_05c23ad9._.js.map +1 -1
  163. package/web/.next/server/chunks/ssr/_16eb4fec._.js +1 -1
  164. package/web/.next/server/chunks/ssr/_16eb4fec._.js.map +1 -1
  165. package/web/.next/server/chunks/ssr/_3a0b989f._.js +2 -2
  166. package/web/.next/server/chunks/ssr/_3a0b989f._.js.map +1 -1
  167. package/web/.next/server/chunks/ssr/_56b9d60f._.js +1 -1
  168. package/web/.next/server/chunks/ssr/_56b9d60f._.js.map +1 -1
  169. package/web/.next/server/chunks/ssr/_5f69c13f._.js +1 -1
  170. package/web/.next/server/chunks/ssr/_5f69c13f._.js.map +1 -1
  171. package/web/.next/server/chunks/ssr/_7c5b97c6._.js +1 -1
  172. package/web/.next/server/chunks/ssr/_7c5b97c6._.js.map +1 -1
  173. package/web/.next/server/chunks/ssr/_82c57f10._.js +1 -1
  174. package/web/.next/server/chunks/ssr/_82c57f10._.js.map +1 -1
  175. package/web/.next/server/chunks/ssr/_8401cafd._.js +3 -0
  176. package/web/.next/server/chunks/ssr/{_d9337063._.js.map → _8401cafd._.js.map} +1 -1
  177. package/web/.next/server/chunks/ssr/_9495d50b._.js +1 -1
  178. package/web/.next/server/chunks/ssr/_9495d50b._.js.map +1 -1
  179. package/web/.next/server/chunks/ssr/{_75a563a9._.js → _9ae7a653._.js} +2 -2
  180. package/web/.next/server/chunks/ssr/{_75a563a9._.js.map → _9ae7a653._.js.map} +1 -1
  181. package/web/.next/server/chunks/ssr/_a0e3f7e4._.js +1 -1
  182. package/web/.next/server/chunks/ssr/_a0e3f7e4._.js.map +1 -1
  183. package/web/.next/server/chunks/ssr/_ac4a3873._.js +1 -1
  184. package/web/.next/server/chunks/ssr/{_65e76c9a._.js → _b959e656._.js} +2 -2
  185. package/web/.next/server/chunks/ssr/{_65e76c9a._.js.map → _b959e656._.js.map} +1 -1
  186. package/web/.next/server/chunks/ssr/_ca0aa7f0._.js +1 -1
  187. package/web/.next/server/chunks/ssr/_ca0aa7f0._.js.map +1 -1
  188. package/web/.next/server/chunks/ssr/_cb5a021e._.js +1 -1
  189. package/web/.next/server/chunks/ssr/_cb5a021e._.js.map +1 -1
  190. package/web/.next/server/chunks/ssr/_d4b20e29._.js.map +1 -1
  191. package/web/.next/server/chunks/ssr/_d86175ae._.js +1 -1
  192. package/web/.next/server/chunks/ssr/_d86175ae._.js.map +1 -1
  193. package/web/.next/server/chunks/ssr/_d8bedf13._.js +1 -1
  194. package/web/.next/server/chunks/ssr/_d8bedf13._.js.map +1 -1
  195. package/web/.next/server/chunks/ssr/_fa7efce3._.js +2 -2
  196. package/web/.next/server/chunks/ssr/_fa7efce3._.js.map +1 -1
  197. package/web/.next/server/chunks/ssr/b1a17_presentation_web_components_features_settings_settings-page-client_tsx_6ed9d5f8._.js +1 -1
  198. package/web/.next/server/chunks/ssr/b1a17_presentation_web_components_features_settings_settings-page-client_tsx_6ed9d5f8._.js.map +1 -1
  199. package/web/.next/server/chunks/ssr/src_presentation_web__next-internal_server_app_skills_page_actions_cdc632e3.js +1 -1
  200. package/web/.next/server/chunks/ssr/src_presentation_web__next-internal_server_app_skills_page_actions_cdc632e3.js.map +1 -1
  201. package/web/.next/server/chunks/ssr/src_presentation_web__next-internal_server_app_tools_page_actions_39ca0924.js +1 -1
  202. package/web/.next/server/chunks/ssr/src_presentation_web__next-internal_server_app_tools_page_actions_39ca0924.js.map +1 -1
  203. package/web/.next/server/chunks/ssr/src_presentation_web_app_actions_open-ide_ts_baaca5d5._.js +1 -1
  204. package/web/.next/server/chunks/ssr/src_presentation_web_components_357e3eb0._.js +1 -1
  205. package/web/.next/server/chunks/ssr/src_presentation_web_components_357e3eb0._.js.map +1 -1
  206. package/web/.next/server/chunks/ssr/src_presentation_web_components_features_control-center_7ac3562e._.js +1 -1
  207. package/web/.next/server/chunks/ssr/src_presentation_web_components_features_control-center_7ac3562e._.js.map +1 -1
  208. package/web/.next/server/pages/500.html +2 -2
  209. package/web/.next/server/server-reference-manifest.js +1 -1
  210. package/web/.next/server/server-reference-manifest.json +45 -45
  211. package/web/.next/static/chunks/{9c45b599460d0f60.js → 2201b69bab7f5c23.js} +1 -1
  212. package/web/.next/static/chunks/{58adaad3bab50e74.js → 2491f2aaffeeef95.js} +2 -2
  213. package/web/.next/static/chunks/{51df7b00bbb7d365.js → 34331406b85a7f88.js} +1 -1
  214. package/web/.next/static/chunks/{11074feeacea0319.js → 37bf276f01b6ed2f.js} +1 -1
  215. package/web/.next/static/chunks/{a0101660264c178b.js → 392e09fb07ed3645.js} +2 -2
  216. package/web/.next/static/chunks/{ebdef1415f61f021.js → 3e0f9071bbd21632.js} +1 -1
  217. package/web/.next/static/chunks/3e7df10f4565829a.js +5 -0
  218. package/web/.next/static/chunks/{34417fd25d41b914.js → 3f1a01541ae3b89b.js} +1 -1
  219. package/web/.next/static/chunks/8590bd2e69b24b9e.css +1 -0
  220. package/web/.next/static/chunks/{2a54cf0384becb8f.js → a94b6582730a0415.js} +1 -1
  221. package/web/.next/static/chunks/{634f6f485b81464a.js → d2c957a8a3ede6c9.js} +1 -1
  222. package/web/.next/static/chunks/e24859c0ac035932.js +1 -0
  223. package/web/.next/static/chunks/fdda1d8b67c4c0ee.js +1 -0
  224. package/web/public/icons/agents/openai.svg +3 -0
  225. package/web/.next/server/chunks/ssr/_d9337063._.js +0 -3
  226. package/web/.next/static/chunks/18abd4f8b9c216a3.js +0 -1
  227. package/web/.next/static/chunks/8bbc916241b4c141.js +0 -1
  228. package/web/.next/static/chunks/b70bc188ac05a8be.js +0 -5
  229. package/web/.next/static/chunks/c86594475dcb03d5.css +0 -1
  230. /package/web/.next/static/{zY7W9Btxu_CXSFrwelXeS → q5DI6MeYtBkAF8Og8Qst0}/_buildManifest.js +0 -0
  231. /package/web/.next/static/{zY7W9Btxu_CXSFrwelXeS → q5DI6MeYtBkAF8Og8Qst0}/_clientMiddlewareManifest.json +0 -0
  232. /package/web/.next/static/{zY7W9Btxu_CXSFrwelXeS → q5DI6MeYtBkAF8Og8Qst0}/_ssgManifest.js +0 -0
@@ -1 +0,0 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,17840,e=>{"use strict";var t=e.i(79054),r=e.i(31406),n=e.i(60112),a=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),o=a((e,t)=>{var r=Object.defineProperty,n=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),a=(e,t,n)=>{let a;return(a="symbol"!=typeof t?t+"":t)in e?r(e,a,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[a]=n},o=n((e,t)=>{function r(e,t){e[t]?e[t]++:e[t]=1}function n(e,t){--e[t]||delete e[t]}function o(e,t,r,n){var a=""+t,o=""+r;if(!e&&a>o){var s=a;a=o,o=s}return a+"\x01"+o+"\x01"+(void 0===n?"\0":n)}function s(e,t){return o(e,t.v,t.w,t.name)}t.exports=class{constructor(e){a(this,"_isDirected",!0),a(this,"_isMultigraph",!1),a(this,"_isCompound",!1),a(this,"_label"),a(this,"_defaultNodeLabelFn",()=>{}),a(this,"_defaultEdgeLabelFn",()=>{}),a(this,"_nodes",{}),a(this,"_in",{}),a(this,"_preds",{}),a(this,"_out",{}),a(this,"_sucs",{}),a(this,"_edgeObjs",{}),a(this,"_edgeLabels",{}),a(this,"_nodeCount",0),a(this,"_edgeCount",0),a(this,"_parent"),a(this,"_children"),e&&(this._isDirected=!Object.hasOwn(e,"directed")||e.directed,this._isMultigraph=!!Object.hasOwn(e,"multigraph")&&e.multigraph,this._isCompound=!!Object.hasOwn(e,"compound")&&e.compound),this._isCompound&&(this._parent={},this._children={},this._children["\0"]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(e){return this._label=e,this}graph(){return this._label}setDefaultNodeLabel(e){return this._defaultNodeLabelFn=e,"function"!=typeof e&&(this._defaultNodeLabelFn=()=>e),this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){var e=this;return this.nodes().filter(t=>0===Object.keys(e._in[t]).length)}sinks(){var e=this;return this.nodes().filter(t=>0===Object.keys(e._out[t]).length)}setNodes(e,t){var r=arguments,n=this;return e.forEach(function(e){r.length>1?n.setNode(e,t):n.setNode(e)}),this}setNode(e,t){return Object.hasOwn(this._nodes,e)?arguments.length>1&&(this._nodes[e]=t):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]="\0",this._children[e]={},this._children["\0"][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount),this}node(e){return this._nodes[e]}hasNode(e){return Object.hasOwn(this._nodes,e)}removeNode(e){var t=this;if(Object.hasOwn(this._nodes,e)){var r=e=>t.removeEdge(t._edgeObjs[e]);delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],this.children(e).forEach(function(e){t.setParent(e)}),delete this._children[e]),Object.keys(this._in[e]).forEach(r),delete this._in[e],delete this._preds[e],Object.keys(this._out[e]).forEach(r),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this}setParent(e,t){if(!this._isCompound)throw Error("Cannot set parent in a non-compound graph");if(void 0===t)t="\0";else{t+="";for(var r=t;void 0!==r;r=this.parent(r))if(r===e)throw Error("Setting "+t+" as parent of "+e+" would create a cycle");this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}parent(e){if(this._isCompound){var t=this._parent[e];if("\0"!==t)return t}}children(e="\0"){if(this._isCompound){var t=this._children[e];if(t)return Object.keys(t)}else{if("\0"===e)return this.nodes();if(this.hasNode(e))return[]}}predecessors(e){var t=this._preds[e];if(t)return Object.keys(t)}successors(e){var t=this._sucs[e];if(t)return Object.keys(t)}neighbors(e){var t=this.predecessors(e);if(t){let n=new Set(t);for(var r of this.successors(e))n.add(r);return Array.from(n.values())}}isLeaf(e){return 0===(this.isDirected()?this.successors(e):this.neighbors(e)).length}filterNodes(e){var t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph());var r=this;Object.entries(this._nodes).forEach(function([r,n]){e(r)&&t.setNode(r,n)}),Object.values(this._edgeObjs).forEach(function(e){t.hasNode(e.v)&&t.hasNode(e.w)&&t.setEdge(e,r.edge(e))});var n={};return this._isCompound&&t.nodes().forEach(e=>t.setParent(e,function e(a){var o=r.parent(a);return void 0===o||t.hasNode(o)?(n[a]=o,o):o in n?n[o]:e(o)}(e))),t}setDefaultEdgeLabel(e){return this._defaultEdgeLabelFn=e,"function"!=typeof e&&(this._defaultEdgeLabelFn=()=>e),this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(e,t){var r=this,n=arguments;return e.reduce(function(e,a){return n.length>1?r.setEdge(e,a,t):r.setEdge(e,a),a}),this}setEdge(){var e,t,n,a,s=!1,i=arguments[0];"object"==typeof i&&null!==i&&"v"in i?(e=i.v,t=i.w,n=i.name,2==arguments.length&&(a=arguments[1],s=!0)):(e=i,t=arguments[1],n=arguments[3],arguments.length>2&&(a=arguments[2],s=!0)),e=""+e,t=""+t,void 0!==n&&(n=""+n);var l=o(this._isDirected,e,t,n);if(Object.hasOwn(this._edgeLabels,l))return s&&(this._edgeLabels[l]=a),this;if(void 0!==n&&!this._isMultigraph)throw Error("Cannot set a named edge when isMultigraph = false");this.setNode(e),this.setNode(t),this._edgeLabels[l]=s?a:this._defaultEdgeLabelFn(e,t,n);var d=function(e,t,r,n){var a=""+t,o=""+r;if(!e&&a>o){var s=a;a=o,o=s}var i={v:a,w:o};return n&&(i.name=n),i}(this._isDirected,e,t,n);return e=d.v,t=d.w,Object.freeze(d),this._edgeObjs[l]=d,r(this._preds[t],e),r(this._sucs[e],t),this._in[t][l]=d,this._out[e][l]=d,this._edgeCount++,this}edge(e,t,r){var n=1==arguments.length?s(this._isDirected,arguments[0]):o(this._isDirected,e,t,r);return this._edgeLabels[n]}edgeAsObj(){let e=this.edge(...arguments);return"object"!=typeof e?{label:e}:e}hasEdge(e,t,r){var n=1==arguments.length?s(this._isDirected,arguments[0]):o(this._isDirected,e,t,r);return Object.hasOwn(this._edgeLabels,n)}removeEdge(e,t,r){var a=1==arguments.length?s(this._isDirected,arguments[0]):o(this._isDirected,e,t,r),i=this._edgeObjs[a];return i&&(e=i.v,t=i.w,delete this._edgeLabels[a],delete this._edgeObjs[a],n(this._preds[t],e),n(this._sucs[e],t),delete this._in[t][a],delete this._out[e][a],this._edgeCount--),this}inEdges(e,t){return this.isDirected()?this.filterEdges(this._in[e],e,t):this.nodeEdges(e,t)}outEdges(e,t){return this.isDirected()?this.filterEdges(this._out[e],e,t):this.nodeEdges(e,t)}nodeEdges(e,t){if(e in this._nodes)return this.filterEdges({...this._in[e],...this._out[e]},e,t)}filterEdges(e,t,r){if(e){var n=Object.values(e);return r?n.filter(function(e){return e.v===t&&e.w===r||e.v===r&&e.w===t}):n}}}}),s=n((e,t)=>{t.exports="3.0.2"}),i=n((e,t)=>{t.exports={Graph:o(),version:s()}}),l=n((e,t)=>{var r=o();t.exports={write:function(e){var t,r,n={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:(t=e).nodes().map(function(e){var r=t.node(e),n=t.parent(e),a={v:e};return void 0!==r&&(a.value=r),void 0!==n&&(a.parent=n),a}),edges:(r=e).edges().map(function(e){var t=r.edge(e),n={v:e.v,w:e.w};return void 0!==e.name&&(n.name=e.name),void 0!==t&&(n.value=t),n})};return void 0!==e.graph()&&(n.value=structuredClone(e.graph())),n},read:function(e){var t=new r(e.options).setGraph(e.value);return e.nodes.forEach(function(e){t.setNode(e.v,e.value),e.parent&&t.setParent(e.v,e.parent)}),e.edges.forEach(function(e){t.setEdge({v:e.v,w:e.w,name:e.name},e.value)}),t}}}),d=n((e,t)=>{t.exports=function(e,t,n,a){return function(e,t,r,n){var a={},o=!0,s=0,i=e.nodes(),l=function(e){var t=r(e);a[e.v].distance+t<a[e.w].distance&&(a[e.w]={distance:a[e.v].distance+t,predecessor:e.v},o=!0)},d=function(){i.forEach(function(e){n(e).forEach(function(t){var r=t.v===e?t.v:t.w,n=r===t.v?t.w:t.v;l({v:r,w:n})})})};i.forEach(function(e){a[e]={distance:e===t?0:1/0}});for(var c=i.length,u=1;u<c&&(o=!1,s++,d(),o);u++);if(s===c-1&&(o=!1,d(),o))throw Error("The graph contains a negative weight cycle");return a}(e,String(t),n||r,a||function(t){return e.outEdges(t)})};var r=()=>1}),c=n((e,t)=>{t.exports=function(e){var t,r={},n=[];return e.nodes().forEach(function(a){t=[],function n(a){Object.hasOwn(r,a)||(r[a]=!0,t.push(a),e.successors(a).forEach(n),e.predecessors(a).forEach(n))}(a),t.length&&n.push(t)}),n}}),u=n((e,t)=>{t.exports=class{constructor(){a(this,"_arr",[]),a(this,"_keyIndices",{})}size(){return this._arr.length}keys(){return this._arr.map(function(e){return e.key})}has(e){return Object.hasOwn(this._keyIndices,e)}priority(e){var t=this._keyIndices[e];if(void 0!==t)return this._arr[t].priority}min(){if(0===this.size())throw Error("Queue underflow");return this._arr[0].key}add(e,t){var r=this._keyIndices;if(!Object.hasOwn(r,e=String(e))){var n=this._arr,a=n.length;return r[e]=a,n.push({key:e,priority:t}),this._decrease(a),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);var e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key}decrease(e,t){var r=this._keyIndices[e];if(t>this._arr[r].priority)throw Error("New priority is greater than current priority. Key: "+e+" Old: "+this._arr[r].priority+" New: "+t);this._arr[r].priority=t,this._decrease(r)}_heapify(e){var t=this._arr,r=2*e,n=r+1,a=e;r<t.length&&(a=t[r].priority<t[a].priority?r:a,n<t.length&&(a=t[n].priority<t[a].priority?n:a),a!==e&&(this._swap(e,a),this._heapify(a)))}_decrease(e){for(var t,r=this._arr,n=r[e].priority;0!==e&&!(r[t=e>>1].priority<n);)this._swap(e,t),e=t}_swap(e,t){var r=this._arr,n=this._keyIndices,a=r[e],o=r[t];r[e]=o,r[t]=a,n[o.key]=e,n[a.key]=t}}}),h=n((e,t)=>{var r=u();t.exports=function(e,t,a,o){return function(e,t,n,a){var o,s,i={},l=new r,d=function(e){var t=e.v!==o?e.v:e.w,r=i[t],a=n(e),d=s.distance+a;if(a<0)throw Error("dijkstra does not allow negative edge weights. Bad edge: "+e+" Weight: "+a);d<r.distance&&(r.distance=d,r.predecessor=o,l.decrease(t,d))};for(e.nodes().forEach(function(e){var r=e===t?0:1/0;i[e]={distance:r},l.add(e,r)});l.size()>0&&(s=i[o=l.removeMin()]).distance!==1/0;)a(o).forEach(d);return i}(e,String(t),a||n,o||function(t){return e.outEdges(t)})};var n=()=>1}),p=n((e,t)=>{var r=h();t.exports=function(e,t,n){return e.nodes().reduce(function(a,o){return a[o]=r(e,o,t,n),a},{})}}),f=n((e,t)=>{t.exports=function(e,t,r){if(void 0!==e[t].predecessor)throw Error("Invalid source vertex");if(void 0===e[r].predecessor&&r!==t)throw Error("Invalid destination vertex");return{weight:e[r].distance,path:function(e,t,r){for(var n=[],a=r;a!==t;)n.push(a),a=e[a].predecessor;return n.push(t),n.reverse()}(e,t,r)}}}),g=n((e,t)=>{t.exports=function(e){var t=0,r=[],n={},a=[];return e.nodes().forEach(function(o){Object.hasOwn(n,o)||function o(s){var i=n[s]={onStack:!0,lowlink:t,index:t++};if(r.push(s),e.successors(s).forEach(function(e){Object.hasOwn(n,e)?n[e].onStack&&(i.lowlink=Math.min(i.lowlink,n[e].index)):(o(e),i.lowlink=Math.min(i.lowlink,n[e].lowlink))}),i.lowlink===i.index){var l,d=[];do n[l=r.pop()].onStack=!1,d.push(l);while(s!==l)a.push(d)}}(o)}),a}}),m=n((e,t)=>{var r=g();t.exports=function(e){return r(e).filter(function(t){return t.length>1||1===t.length&&e.hasEdge(t[0],t[0])})}}),x=n((e,t)=>{t.exports=function(e,t,n){var a,o,s,i,l;return a=e,o=t||r,s=n||function(t){return e.outEdges(t)},i={},(l=a.nodes()).forEach(function(e){i[e]={},i[e][e]={distance:0},l.forEach(function(t){e!==t&&(i[e][t]={distance:1/0})}),s(e).forEach(function(t){var r=t.v===e?t.w:t.v,n=o(t);i[e][r]={distance:n,predecessor:e}})}),l.forEach(function(e){var t=i[e];l.forEach(function(r){var n=i[r];l.forEach(function(r){var a=n[e],o=t[r],s=n[r],i=a.distance+o.distance;i<s.distance&&(s.distance=i,s.predecessor=o.predecessor)})})}),i};var r=()=>1}),v=n((e,t)=>{function r(e){var t={},r={},a=[];if(e.sinks().forEach(function o(s){if(Object.hasOwn(r,s))throw new n;Object.hasOwn(t,s)||(r[s]=!0,t[s]=!0,e.predecessors(s).forEach(o),delete r[s],a.push(s))}),Object.keys(t).length!==e.nodeCount())throw new n;return a}var n=class extends Error{constructor(){super(...arguments)}};t.exports=r,r.CycleException=n}),b=n((e,t)=>{var r=v();t.exports=function(e){try{r(e)}catch(e){if(e instanceof r.CycleException)return!1;throw e}return!0}}),y=n((e,t)=>{t.exports=function(e,t,r,n,a){Array.isArray(t)||(t=[t]);var o=(e.isDirected()?e.successors:e.neighbors).bind(e),s={};return t.forEach(function(t){if(!e.hasNode(t))throw Error("Graph does not have node: "+t);a=function e(t,r,n,a,o,s,i){return Object.hasOwn(a,r)||(a[r]=!0,n||(i=s(i,r)),o(r).forEach(function(r){i=e(t,r,n,a,o,s,i)}),n&&(i=s(i,r))),i}(e,t,"post"===r,s,o,n,a)}),a}}),w=n((e,t)=>{var r=y();t.exports=function(e,t,n){return r(e,t,n,function(e,t){return e.push(t),e},[])}}),k=n((e,t)=>{var r=w();t.exports=function(e,t){return r(e,t,"post")}}),j=n((e,t)=>{var r=w();t.exports=function(e,t){return r(e,t,"pre")}}),E=n((e,t)=>{var r=o(),n=u();t.exports=function(e,t){var a,o=new r,s={},i=new n;function l(e){var r=e.v===a?e.w:e.v,n=i.priority(r);if(void 0!==n){var o=t(e);o<n&&(s[r]=a,i.decrease(r,o))}}if(0===e.nodeCount())return o;e.nodes().forEach(function(e){i.add(e,1/0),o.setNode(e)}),i.decrease(e.nodes()[0],0);for(var d=!1;i.size()>0;){if(Object.hasOwn(s,a=i.removeMin()))o.setEdge(a,s[a]);else{if(d)throw Error("Input graph is not connected: "+e);d=!0}e.nodeEdges(a).forEach(l)}return o}}),N=n((e,t)=>{var r=h(),n=d();t.exports=function(e,t,a,o){return function(e,t,a,o){if(void 0===a)return r(e,t,a,o);for(var s=!1,i=e.nodes(),l=0;l<i.length;l++){for(var d=o(i[l]),c=0;c<d.length;c++){var u=d[c],h=u.v===i[l]?u.v:u.w,p=h===u.v?u.w:u.v;0>a({v:h,w:p})&&(s=!0)}if(s)return n(e,t,a,o)}return r(e,t,a,o)}(e,t,a,o||function(t){return e.outEdges(t)})}}),C=n((e,t)=>{t.exports={bellmanFord:d(),components:c(),dijkstra:h(),dijkstraAll:p(),extractPath:f(),findCycles:m(),floydWarshall:x(),isAcyclic:b(),postorder:k(),preorder:j(),prim:E(),shortestPaths:N(),reduce:y(),tarjan:g(),topsort:v()}}),_=i();t.exports={Graph:_.Graph,json:l(),alg:C(),version:_.version}}),s=a((e,t)=>{function r(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function n(e,t){if("_next"!==e&&"_prev"!==e)return t}t.exports=class{constructor(){let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return r(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&r(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t}toString(){let e=[],t=this._sentinel,r=t._prev;for(;r!==t;)e.push(JSON.stringify(r,n)),r=r._prev;return"["+e.join(", ")+"]"}}}),i=a((e,t)=>{var r=o().Graph,n=s();t.exports=function(e,t){var o,s;let d,c,u,h,p;if(1>=e.nodeCount())return[];let f=(o=e,s=t||a,d=new r,c=0,u=0,o.nodes().forEach(e=>{d.setNode(e,{v:e,in:0,out:0})}),o.edges().forEach(e=>{let t=d.edge(e.v,e.w)||0,r=s(e);d.setEdge(e.v,e.w,t+r),u=Math.max(u,d.node(e.v).out+=r),c=Math.max(c,d.node(e.w).in+=r)}),h=(function(e){let t=[];for(let r=0;r<e;r++)t.push(r);return t})(u+c+3).map(()=>new n),p=c+1,d.nodes().forEach(e=>{l(h,p,d.node(e))}),{graph:d,buckets:h,zeroIdx:p});return(function(e,t,r){let n=[],a=t[t.length-1],o=t[0],s;for(;e.nodeCount();){for(;s=o.dequeue();)i(e,t,r,s);for(;s=a.dequeue();)i(e,t,r,s);if(e.nodeCount()){for(let a=t.length-2;a>0;--a)if(s=t[a].dequeue()){n=n.concat(i(e,t,r,s,!0));break}}}return n})(f.graph,f.buckets,f.zeroIdx).flatMap(t=>e.outEdges(t.v,t.w))};var a=()=>1;function i(e,t,r,n,a){let o=a?[]:void 0;return e.inEdges(n.v).forEach(n=>{let s=e.edge(n),i=e.node(n.v);a&&o.push({v:n.v,w:n.w}),i.out-=s,l(t,r,i)}),e.outEdges(n.v).forEach(n=>{let a=e.edge(n),o=n.w,s=e.node(o);s.in-=a,l(t,r,s)}),e.removeNode(n.v),o}function l(e,t,r){r.out?r.in?e[r.out-r.in+t].enqueue(r):e[e.length-1].enqueue(r):e[0].enqueue(r)}}),l=a((e,t)=>{var r=o().Graph;function n(e,t,r,n){for(var a=n;e.hasNode(a);)a=l(n);return r.dummy=t,e.setNode(a,r),a}t.exports={addBorderNode:function(e,t,r,a){let o={width:0,height:0};return arguments.length>=4&&(o.rank=r,o.order=a),n(e,"border",o,t)},addDummyNode:n,applyWithChunking:a,asNonCompoundGraph:function(e){let t=new r({multigraph:e.isMultigraph()}).setGraph(e.graph());return e.nodes().forEach(r=>{e.children(r).length||t.setNode(r,e.node(r))}),e.edges().forEach(r=>{t.setEdge(r,e.edge(r))}),t},buildLayerMatrix:function(e){let t=d(s(e)+1).map(()=>[]);return e.nodes().forEach(r=>{let n=e.node(r),a=n.rank;void 0!==a&&(t[a][n.order]=r)}),t},intersectRect:function(e,t){let r,n,a=e.x,o=e.y,s=t.x-a,i=t.y-o,l=e.width/2,d=e.height/2;if(!s&&!i)throw Error("Not possible to find intersection inside of the rectangle");return Math.abs(i)*l>Math.abs(s)*d?(i<0&&(d=-d),r=d*s/i,n=d):(s<0&&(l=-l),r=l,n=l*i/s),{x:a+r,y:o+n}},mapValues:function(e,t){let r=t;return"string"==typeof t&&(r=e=>e[t]),Object.entries(e).reduce((e,[t,n])=>(e[t]=r(n,t),e),{})},maxRank:s,normalizeRanks:function(e){let t=a(Math.min,e.nodes().map(t=>{let r=e.node(t).rank;return void 0===r?Number.MAX_VALUE:r}));e.nodes().forEach(r=>{let n=e.node(r);Object.hasOwn(n,"rank")&&(n.rank-=t)})},notime:function(e,t){return t()},partition:function(e,t){let r={lhs:[],rhs:[]};return e.forEach(e=>{t(e)?r.lhs.push(e):r.rhs.push(e)}),r},pick:function(e,t){let r={};for(let n of t)void 0!==e[n]&&(r[n]=e[n]);return r},predecessorWeights:function(e){let t=e.nodes().map(t=>{let r={};return e.inEdges(t).forEach(t=>{r[t.v]=(r[t.v]||0)+e.edge(t).weight}),r});return c(e.nodes(),t)},range:d,removeEmptyRanks:function(e){let t=a(Math.min,e.nodes().map(t=>e.node(t).rank).filter(e=>void 0!==e)),r=[];e.nodes().forEach(n=>{let a=e.node(n).rank-t;r[a]||(r[a]=[]),r[a].push(n)});let n=0,o=e.graph().nodeRankFactor;Array.from(r).forEach((t,r)=>{void 0===t&&r%o!=0?--n:void 0!==t&&n&&t.forEach(t=>e.node(t).rank+=n)})},simplify:function(e){let t=new r().setGraph(e.graph());return e.nodes().forEach(r=>t.setNode(r,e.node(r))),e.edges().forEach(r=>{let n=t.edge(r.v,r.w)||{weight:0,minlen:1},a=e.edge(r);t.setEdge(r.v,r.w,{weight:n.weight+a.weight,minlen:Math.max(n.minlen,a.minlen)})}),t},successorWeights:function(e){let t=e.nodes().map(t=>{let r={};return e.outEdges(t).forEach(t=>{r[t.w]=(r[t.w]||0)+e.edge(t).weight}),r});return c(e.nodes(),t)},time:function(e,t){let r=Date.now();try{return t()}finally{console.log(e+" time: "+(Date.now()-r)+"ms")}},uniqueId:l,zipObject:c};function a(e,t){if(!(t.length>65535))return e.apply(null,t);{let r=function(e,t=65535){let r=[];for(let n=0;n<e.length;n+=t){let a=e.slice(n,n+t);r.push(a)}return r}(t);return e.apply(null,r.map(t=>e.apply(null,t)))}}function s(e){return a(Math.max,e.nodes().map(t=>{let r=e.node(t).rank;return void 0===r?5e-324:r}))}var i=0;function l(e){return e+""+ ++i}function d(e,t,r=1){null==t&&(t=e,e=0);let n=e=>e<t;r<0&&(n=e=>t<e);let a=[];for(let t=e;n(t);t+=r)a.push(t);return a}function c(e,t){return e.reduce((e,r,n)=>(e[r]=t[n],e),{})}}),d=a((e,t)=>{var r=i(),n=l().uniqueId;t.exports={run:function(e){var t,a;let o,s,i;("greedy"===e.graph().acyclicer?r(e,(t=e,e=>t.edge(e).weight)):(o=[],s={},i={},(a=e).nodes().forEach(function e(t){Object.hasOwn(i,t)||(i[t]=!0,s[t]=!0,a.outEdges(t).forEach(t=>{Object.hasOwn(s,t.w)?o.push(t):e(t.w)}),delete s[t])}),o)).forEach(t=>{let r=e.edge(t);e.removeEdge(t),r.forwardName=t.name,r.reversed=!0,e.setEdge(t.w,t.v,r,n("rev"))})},undo:function(e){e.edges().forEach(t=>{let r=e.edge(t);if(r.reversed){e.removeEdge(t);let n=r.forwardName;delete r.reversed,delete r.forwardName,e.setEdge(t.w,t.v,r,n)}})}}}),c=a((e,t)=>{var r=l();t.exports={run:function(e){e.graph().dummyChains=[],e.edges().forEach(t=>(function(e,t){let n,a,o,s=t.v,i=e.node(s).rank,l=t.w,d=e.node(l).rank,c=t.name,u=e.edge(t),h=u.labelRank;if(d!==i+1){for(e.removeEdge(t),o=0,++i;i<d;++o,++i)u.points=[],a={width:0,height:0,edgeLabel:u,edgeObj:t,rank:i},n=r.addDummyNode(e,"edge",a,"_d"),i===h&&(a.width=u.width,a.height=u.height,a.dummy="edge-label",a.labelpos=u.labelpos),e.setEdge(s,n,{weight:u.weight},c),0===o&&e.graph().dummyChains.push(n),s=n;e.setEdge(s,l,{weight:u.weight},c)}})(e,t))},undo:function(e){e.graph().dummyChains.forEach(t=>{let r=e.node(t),n=r.edgeLabel,a;for(e.setEdge(r.edgeObj,n);r.dummy;)a=e.successors(t)[0],e.removeNode(t),n.points.push({x:r.x,y:r.y}),"edge-label"===r.dummy&&(n.x=r.x,n.y=r.y,n.width=r.width,n.height=r.height),t=a,r=e.node(t)})}}}),u=a((e,t)=>{var{applyWithChunking:r}=l();t.exports={longestPath:function(e){var t={};e.sources().forEach(function n(a){var o=e.node(a);if(Object.hasOwn(t,a))return o.rank;t[a]=!0;var s=r(Math.min,e.outEdges(a).map(t=>null==t?1/0:n(t.w)-e.edge(t).minlen));return s===1/0&&(s=0),o.rank=s})},slack:function(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}}}),h=a((e,t)=>{var r=o().Graph,n=u().slack;t.exports=function(e){var t,a,o,s,i=new r({directed:!1}),l=e.nodes()[0],d=e.nodeCount();for(i.setNode(l,{});t=i,a=e,t.nodes().forEach(function e(r){a.nodeEdges(r).forEach(o=>{var s=o.v,i=r===s?o.w:s;t.hasNode(i)||n(a,o)||(t.setNode(i,{}),t.setEdge(r,i,{}),e(i))})}),t.nodeCount()<d;)o=function(e,t){return t.edges().reduce((r,a)=>{let o=1/0;return e.hasNode(a.v)!==e.hasNode(a.w)&&(o=n(t,a)),o<r[0]?[o,a]:r},[1/0,null])[1]}(i,e),s=i.hasNode(o.v)?n(e,o):-n(e,o),function(e,t,r){e.nodes().forEach(e=>t.node(e).rank+=r)}(i,e,s);return i}}),p=a((e,t)=>{var r=h(),n=u().slack,a=u().longestPath,s=o().alg.preorder,i=o().alg.postorder,d=l().simplify;function c(e){a(e=d(e));var t,n,o=r(e);for(g(o),p(o,e);t=m(o);)n=x(o,e,t),v(o,e,t,n)}function p(e,t){var r=i(e,e.nodes());(r=r.slice(0,r.length-1)).forEach(r=>{var n,a,o,s;return n=e,a=t,o=r,s=n.node(o).parent,void(n.edge(o,s).cutvalue=f(n,a,o))})}function f(e,t,r){var n=e.node(r).parent,a=!0,o=t.edge(r,n),s=0;return o||(a=!1,o=t.edge(n,r)),s=o.weight,t.nodeEdges(r).forEach(o=>{var i=o.v===r,l=i?o.w:o.v;if(l!==n){var d,c,u,h=i===a,p=t.edge(o).weight;if(s+=h?p:-p,d=e,c=r,u=l,d.hasEdge(c,u)){var f=e.edge(r,l).cutvalue;s+=h?-f:f}}}),s}function g(e,t){arguments.length<2&&(t=e.nodes()[0]),function e(t,r,n,a,o){var s=n,i=t.node(a);return r[a]=!0,t.neighbors(a).forEach(o=>{Object.hasOwn(r,o)||(n=e(t,r,n,o,a))}),i.low=s,i.lim=n++,o?i.parent=o:delete i.parent,n}(e,{},1,t)}function m(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function x(e,t,r){var a=r.v,o=r.w;t.hasEdge(a,o)||(a=r.w,o=r.v);var s=e.node(a),i=e.node(o),l=s,d=!1;return s.lim>i.lim&&(l=i,d=!0),t.edges().filter(t=>d===b(e,e.node(t.v),l)&&d!==b(e,e.node(t.w),l)).reduce((e,r)=>n(t,r)<n(t,e)?r:e)}function v(e,t,r,n){var a,o,i,l,d=r.v,c=r.w;e.removeEdge(d,c),e.setEdge(n.v,n.w,{}),g(e),p(e,t),a=e,o=t,i=a.nodes().find(e=>!o.node(e).parent),(l=(l=s(a,i)).slice(1)).forEach(e=>{var t=a.node(e).parent,r=o.edge(e,t),n=!1;r||(r=o.edge(t,e),n=!0),o.node(e).rank=o.node(t).rank+(n?r.minlen:-r.minlen)})}function b(e,t,r){return r.low<=t.lim&&t.lim<=r.lim}t.exports=c,c.initLowLimValues=g,c.initCutValues=p,c.calcCutValue=f,c.leaveEdge=m,c.enterEdge=x,c.exchangeEdges=v}),f=a((e,t)=>{var r=u().longestPath,n=h(),a=p();t.exports=function(e){var t,s=e.graph().ranker;if(s instanceof Function)return s(e);switch(e.graph().ranker){case"network-simplex":default:a(e);break;case"tight-tree":r(t=e),n(t);break;case"longest-path":o(e);case"none":}};var o=r}),g=a((e,t)=>{t.exports=function(e){var t;let r,n,a=(r={},n=0,(t=e).children().forEach(function e(a){let o=n;t.children(a).forEach(e),r[a]={low:o,lim:n++}}),r);e.graph().dummyChains.forEach(t=>{let r=e.node(t),n=r.edgeObj,o=function(e,t,r,n){let a=[],o=[],s=Math.min(t[r].low,t[n].low),i=Math.max(t[r].lim,t[n].lim),l,d;l=r;do a.push(l=e.parent(l));while(l&&(t[l].low>s||i>t[l].lim))for(d=l,l=n;(l=e.parent(l))!==d;)o.push(l);return{path:a.concat(o.reverse()),lca:d}}(e,a,n.v,n.w),s=o.path,i=o.lca,l=0,d=s[0],c=!0;for(;t!==n.w;){if(r=e.node(t),c){for(;(d=s[l])!==i&&e.node(d).maxRank<r.rank;)l++;d===i&&(c=!1)}if(!c){for(;l<s.length-1&&e.node(d=s[l+1]).minRank<=r.rank;)l++;d=s[l]}e.setParent(t,d),t=e.successors(t)[0]}})}}),m=a((e,t)=>{var r=l();t.exports={run:function(e){var t,n,a;let o=r.addDummyNode(e,"root",{},"_root"),s=(n={},(t=e).children().forEach(e=>(function e(r,a){var o=t.children(r);o&&o.length&&o.forEach(t=>e(t,a+1)),n[r]=a})(e,1)),n),i=Object.values(s),l=r.applyWithChunking(Math.max,i)-1,d=2*l+1;e.graph().nestingRoot=o,e.edges().forEach(t=>e.edge(t).minlen*=d);let c=(a=e).edges().reduce((e,t)=>e+a.edge(t).weight,0)+1;e.children().forEach(t=>(function e(t,n,a,o,s,i,l){let d=t.children(l);if(!d.length){l!==n&&t.setEdge(n,l,{weight:0,minlen:a});return}let c=r.addBorderNode(t,"_bt"),u=r.addBorderNode(t,"_bb"),h=t.node(l);t.setParent(c,l),h.borderTop=c,t.setParent(u,l),h.borderBottom=u,d.forEach(r=>{e(t,n,a,o,s,i,r);let d=t.node(r),h=d.borderTop?d.borderTop:r,p=d.borderBottom?d.borderBottom:r,f=d.borderTop?o:2*o,g=h!==p?1:s-i[l]+1;t.setEdge(c,h,{weight:f,minlen:g,nestingEdge:!0}),t.setEdge(p,u,{weight:f,minlen:g,nestingEdge:!0})}),t.parent(l)||t.setEdge(n,c,{weight:0,minlen:s+i[l]})})(e,o,d,c,l,s,t)),e.graph().nodeRankFactor=d},cleanup:function(e){var t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(t=>{e.edge(t).nestingEdge&&e.removeEdge(t)})}}}),x=a((e,t)=>{var r=l();function n(e,t,n,a,o,s){let i=o[t][s-1],l=r.addDummyNode(e,"border",{width:0,height:0,rank:s,borderType:t},n);o[t][s]=l,e.setParent(l,a),i&&e.setEdge(i,l,{weight:1})}t.exports=function(e){e.children().forEach(function t(r){let a=e.children(r),o=e.node(r);if(a.length&&a.forEach(t),Object.hasOwn(o,"minRank")){o.borderLeft=[],o.borderRight=[];for(let t=o.minRank,a=o.maxRank+1;t<a;++t)n(e,"borderLeft","_bl",r,o,t),n(e,"borderRight","_br",r,o,t)}})}}),v=a((e,t)=>{function r(e){e.nodes().forEach(t=>n(e.node(t))),e.edges().forEach(t=>n(e.edge(t)))}function n(e){let t=e.width;e.width=e.height,e.height=t}function a(e){e.y=-e.y}function o(e){let t=e.x;e.x=e.y,e.y=t}t.exports={adjust:function(e){let t=e.graph().rankdir.toLowerCase();("lr"===t||"rl"===t)&&r(e)},undo:function(e){var t,n;let s=e.graph().rankdir.toLowerCase();("bt"===s||"rl"===s)&&((t=e).nodes().forEach(e=>a(t.node(e))),t.edges().forEach(e=>{let r=t.edge(e);r.points.forEach(a),Object.hasOwn(r,"y")&&a(r)})),("lr"===s||"rl"===s)&&((n=e).nodes().forEach(e=>o(n.node(e))),n.edges().forEach(e=>{let t=n.edge(e);t.points.forEach(o),Object.hasOwn(t,"x")&&o(t)}),r(e))}}}),b=a((e,t)=>{var r=l();t.exports=function(e){let t={},n=e.nodes().filter(t=>!e.children(t).length),a=n.map(t=>e.node(t).rank),o=r.applyWithChunking(Math.max,a),s=r.range(o+1).map(()=>[]);return n.sort((t,r)=>e.node(t).rank-e.node(r).rank).forEach(function r(n){t[n]||(t[n]=!0,s[e.node(n).rank].push(n),e.successors(n).forEach(r))}),s}}),y=a((e,t)=>{var r=l().zipObject;t.exports=function(e,t){let n=0;for(let a=1;a<t.length;++a)n+=function(e,t,n){let a=r(n,n.map((e,t)=>t)),o=t.flatMap(t=>e.outEdges(t).map(t=>({pos:a[t.w],weight:e.edge(t).weight})).sort((e,t)=>e.pos-t.pos)),s=1;for(;s<n.length;)s<<=1;let i=2*s-1;s-=1;let l=Array(i).fill(0),d=0;return o.forEach(e=>{let t=e.pos+s;l[t]+=e.weight;let r=0;for(;t>0;)t%2&&(r+=l[t+1]),t=t-1>>1,l[t]+=e.weight;d+=e.weight*r}),d}(e,t[a-1],t[a]);return n}}),w=a((e,t)=>{t.exports=function(e,t=[]){return t.map(t=>{let r=e.inEdges(t);if(!r.length)return{v:t};{let n=r.reduce((t,r)=>{let n=e.edge(r),a=e.node(r.v);return{sum:t.sum+n.weight*a.order,weight:t.weight+n.weight}},{sum:0,weight:0});return{v:t,barycenter:n.sum/n.weight,weight:n.weight}}})}}),k=a((e,t)=>{var r=l();t.exports=function(e,t){let n={};return e.forEach((e,t)=>{let r=n[e.v]={indegree:0,in:[],out:[],vs:[e.v],i:t};void 0!==e.barycenter&&(r.barycenter=e.barycenter,r.weight=e.weight)}),t.edges().forEach(e=>{let t=n[e.v],r=n[e.w];void 0!==t&&void 0!==r&&(r.indegree++,t.out.push(n[e.w]))}),function(e){let t=[];for(;e.length;){let r=e.pop();t.push(r),r.in.reverse().forEach(function(e){return t=>{t.merged||(void 0===t.barycenter||void 0===e.barycenter||t.barycenter>=e.barycenter)&&function(e,t){let r=0,n=0;e.weight&&(r+=e.barycenter*e.weight,n+=e.weight),t.weight&&(r+=t.barycenter*t.weight,n+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=r/n,e.weight=n,e.i=Math.min(t.i,e.i),t.merged=!0}(e,t)}}(r)),r.out.forEach(function(t){return r=>{r.in.push(t),0==--r.indegree&&e.push(r)}}(r))}return t.filter(e=>!e.merged).map(e=>r.pick(e,["vs","i","barycenter","weight"]))}(Object.values(n).filter(e=>!e.indegree))}}),j=a((e,t)=>{var r=l();function n(e,t,r){let n;for(;t.length&&(n=t[t.length-1]).i<=r;)t.pop(),e.push(n.vs),r++;return r}t.exports=function(e,t){var a;let o=r.partition(e,e=>Object.hasOwn(e,"barycenter")),s=o.lhs,i=o.rhs.sort((e,t)=>t.i-e.i),l=[],d=0,c=0,u=0;s.sort((a=!!t,(e,t)=>e.barycenter<t.barycenter?-1:e.barycenter>t.barycenter?1:a?t.i-e.i:e.i-t.i)),u=n(l,i,u),s.forEach(e=>{u+=e.vs.length,l.push(e.vs),d+=e.barycenter*e.weight,c+=e.weight,u=n(l,i,u)});let h={vs:l.flat(!0)};return c&&(h.barycenter=d/c,h.weight=c),h}}),E=a((e,t)=>{var r=w(),n=k(),a=j();t.exports=function e(t,o,s,i){var l,d;let c=t.children(o),u=t.node(o),h=u?u.borderLeft:void 0,p=u?u.borderRight:void 0,f={};h&&(c=c.filter(e=>e!==h&&e!==p));let g=r(t,c);g.forEach(r=>{if(t.children(r.v).length){var n,a;let o=e(t,r.v,s,i);f[r.v]=o,Object.hasOwn(o,"barycenter")&&(n=r,a=o,void 0!==n.barycenter?(n.barycenter=(n.barycenter*n.weight+a.barycenter*a.weight)/(n.weight+a.weight),n.weight+=a.weight):(n.barycenter=a.barycenter,n.weight=a.weight))}});let m=n(g,s);l=m,d=f,l.forEach(e=>{e.vs=e.vs.flatMap(e=>d[e]?d[e].vs:e)});let x=a(m,i);if(h&&(x.vs=[h,x.vs,p].flat(!0),t.predecessors(h).length)){let e=t.node(t.predecessors(h)[0]),r=t.node(t.predecessors(p)[0]);Object.hasOwn(x,"barycenter")||(x.barycenter=0,x.weight=0),x.barycenter=(x.barycenter*x.weight+e.order+r.order)/(x.weight+2),x.weight+=2}return x}}),N=a((e,t)=>{var r=o().Graph,n=l();t.exports=function(e,t,a,o){o||(o=e.nodes());let s=function(e){for(var t;e.hasNode(t=n.uniqueId("_root")););return t}(e),i=new r({compound:!0}).setGraph({root:s}).setDefaultNodeLabel(t=>e.node(t));return o.forEach(r=>{let n=e.node(r),o=e.parent(r);(n.rank===t||n.minRank<=t&&t<=n.maxRank)&&(i.setNode(r),i.setParent(r,o||s),e[a](r).forEach(t=>{let n=t.v===r?t.w:t.v,a=i.edge(n,r),o=void 0!==a?a.weight:0;i.setEdge(n,r,{weight:e.edge(t).weight+o})}),Object.hasOwn(n,"minRank")&&i.setNode(r,{borderLeft:n.borderLeft[t],borderRight:n.borderRight[t]}))}),i}}),C=a((e,t)=>{t.exports=function(e,t,r){let n={},a;r.forEach(r=>{let o=e.parent(r),s,i;for(;o;){if((s=e.parent(o))?(i=n[s],n[s]=o):(i=a,a=o),i&&i!==o)return void t.setEdge(i,o);o=s}})}}),_=a((e,t)=>{var r=b(),n=y(),a=E(),s=N(),i=C(),d=o().Graph,c=l();function u(e,t,r){let n=new Map,a=(e,t)=>{n.has(e)||n.set(e,[]),n.get(e).push(t)};for(let t of e.nodes()){let r=e.node(t);if("number"==typeof r.rank&&a(r.rank,t),"number"==typeof r.minRank&&"number"==typeof r.maxRank)for(let e=r.minRank;e<=r.maxRank;e++)e!==r.rank&&a(e,t)}return t.map(function(t){return s(e,t,r,n.get(t)||[])})}function h(e,t){Object.values(t).forEach(t=>t.forEach((t,r)=>e.node(t).order=r))}t.exports=function e(t,o={}){if("function"==typeof o.customOrder)return void o.customOrder(t,e);let s=c.maxRank(t),l=u(t,c.range(1,s+1),"inEdges"),p=u(t,c.range(s-1,-1,-1),"outEdges"),f=r(t);if(h(t,f),o.disableOptimalOrderHeuristic)return;let g=1/0,m,x=o.constraints||[];for(let e=0,r=0;r<4;++e,++r){(function(e,t,r){let n=new d;e.forEach(function(e){r.forEach(e=>n.setEdge(e.left,e.right));let o=e.graph().root,s=a(e,o,n,t);s.vs.forEach((t,r)=>e.node(t).order=r),i(e,n,s.vs)})})(e%2?l:p,e%4>=2,x),f=c.buildLayerMatrix(t);let o=n(t,f);o<g?(r=0,m=Object.assign({},f),g=o):o===g&&(m=structuredClone(f))}h(t,m)}}),S=a((e,t)=>{var r=o().Graph,n=l();function a(e,t){let r={};return t.length&&t.reduce(function(t,n){let a=0,o=0,s=t.length,l=n[n.length-1];return n.forEach((t,d)=>{let c=function(e,t){if(e.node(t).dummy)return e.predecessors(t).find(t=>e.node(t).dummy)}(e,t),u=c?e.node(c).order:s;(c||t===l)&&(n.slice(o,d+1).forEach(t=>{e.predecessors(t).forEach(n=>{let o=e.node(n),s=o.order;(s<a||u<s)&&!(o.dummy&&e.node(t).dummy)&&i(r,n,t)})}),o=d+1,a=u)}),n}),r}function s(e,t){let r={};function a(t,a,o,s,l){let d;n.range(a,o).forEach(n=>{d=t[n],e.node(d).dummy&&e.predecessors(d).forEach(t=>{let n=e.node(t);n.dummy&&(n.order<s||n.order>l)&&i(r,t,d)})})}return t.length&&t.reduce(function(t,r){let n=-1,o,s=0;return r.forEach((i,l)=>{if("border"===e.node(i).dummy){let t=e.predecessors(i);t.length&&(o=e.node(t[0]).order,a(r,s,l,n,o),s=l,n=o)}a(r,s,r.length,o,t.length)}),r}),r}function i(e,t,r){if(t>r){let e=t;t=r,r=e}let n=e[t];n||(e[t]=n={}),n[r]=!0}function d(e,t,r){if(t>r){let e=t;t=r,r=e}return!!e[t]&&Object.hasOwn(e[t],r)}function c(e,t,r,n){let a={},o={},s={};return t.forEach(e=>{e.forEach((e,t)=>{a[e]=e,o[e]=e,s[e]=t})}),t.forEach(e=>{let t=-1;e.forEach(e=>{let i=n(e);if(i.length){let n=((i=i.sort((e,t)=>s[e]-s[t])).length-1)/2;for(let l=Math.floor(n),c=Math.ceil(n);l<=c;++l){let n=i[l];o[e]===e&&t<s[n]&&!d(r,e,n)&&(o[n]=e,o[e]=a[e]=a[n],t=s[n])}}})}),{root:a,align:o}}function u(e,t,n,a,o){var s,i,l,d,c,u,h;let p,f,g,m={},x=(s=e,i=t,l=n,d=o,p=new r,g=(c=(f=s.graph()).nodesep,u=f.edgesep,h=d,(e,t,r)=>{let n=e.node(t),a=e.node(r),o,s;if(o=0+n.width/2,Object.hasOwn(n,"labelpos"))switch(n.labelpos.toLowerCase()){case"l":s=-n.width/2;break;case"r":s=n.width/2}if(s&&(o+=h?s:-s),s=0,o+=(n.dummy?u:c)/2,o+=(a.dummy?u:c)/2,o+=a.width/2,Object.hasOwn(a,"labelpos"))switch(a.labelpos.toLowerCase()){case"l":s=a.width/2;break;case"r":s=-a.width/2}return s&&(o+=h?s:-s),s=0,o}),i.forEach(e=>{let t;e.forEach(e=>{let r=l[e];if(p.setNode(r),t){var n=l[t],a=p.edge(n,r);p.setEdge(n,r,Math.max(g(s,e,t),a||0))}t=e})}),p),v=o?"borderLeft":"borderRight";function b(e,t){let r=x.nodes().slice(),n={},a=r.pop();for(;a;){if(n[a])e(a);else for(let e of(n[a]=!0,r.push(a),t(a)))r.push(e);a=r.pop()}}return b(function(e){m[e]=x.inEdges(e).reduce((e,t)=>Math.max(e,m[t.v]+x.edge(t)),0)},x.predecessors.bind(x)),b(function(t){let r=x.outEdges(t).reduce((e,t)=>Math.min(e,m[t.w]-x.edge(t)),1/0),n=e.node(t);r!==1/0&&n.borderType!==v&&(m[t]=Math.max(m[t],r))},x.successors.bind(x)),Object.keys(a).forEach(e=>m[e]=m[n[e]]),m}function h(e,t){return Object.values(t).reduce((t,r)=>{let n=-1/0,a=1/0;Object.entries(r).forEach(([t,r])=>{var o,s;let i=(o=e,s=t,o.node(s).width/2);n=Math.max(r+i,n),a=Math.min(r-i,a)});let o=n-a;return o<t[0]&&(t=[o,r]),t},[1/0,null])[1]}function p(e,t){let r=Object.values(t),a=n.applyWithChunking(Math.min,r),o=n.applyWithChunking(Math.max,r);["u","d"].forEach(r=>{["l","r"].forEach(s=>{let i=r+s,l=e[i];if(l===t)return;let d=Object.values(l),c=a-n.applyWithChunking(Math.min,d);"l"!==s&&(c=o-n.applyWithChunking(Math.max,d)),c&&(e[i]=n.mapValues(l,e=>e+c))})})}function f(e,t){return n.mapValues(e.ul,(r,n)=>{if(t)return e[t.toLowerCase()][n];{let t=Object.values(e).map(e=>e[n]).sort((e,t)=>e-t);return(t[1]+t[2])/2}})}t.exports={positionX:function(e){let t=n.buildLayerMatrix(e),r=Object.assign(a(e,t),s(e,t)),o={},i;["u","d"].forEach(a=>{i="u"===a?t:Object.values(t).reverse(),["l","r"].forEach(t=>{"r"===t&&(i=i.map(e=>Object.values(e).reverse()));let s=("u"===a?e.predecessors:e.successors).bind(e),l=c(e,i,r,s),d=u(e,i,l.root,l.align,"r"===t);"r"===t&&(d=n.mapValues(d,e=>-e)),o[a+t]=d})});let l=h(e,o);return p(o,l),f(o,e.graph().align)},findType1Conflicts:a,findType2Conflicts:s,addConflict:i,hasConflict:d,verticalAlignment:c,horizontalCompaction:u,alignCoordinates:p,findSmallestWidthAlignment:h,balance:f}}),O=a((e,t)=>{var r=l(),n=S().positionX;t.exports=function(e){var t;let a,o,s,i;t=e=r.asNonCompoundGraph(e),a=r.buildLayerMatrix(t),o=t.graph().ranksep,s=t.graph().rankalign,i=0,a.forEach(e=>{let r=e.reduce((e,r)=>{let n=t.node(r).height;return e>n?e:n},0);e.forEach(e=>{let n=t.node(e);"top"===s?n.y=i+n.height/2:"bottom"===s?n.y=i+r-n.height/2:n.y=i+r/2}),i+=r+o}),Object.entries(n(e)).forEach(([t,r])=>e.node(t).x=r)}}),R=a((e,t)=>{var r=d(),n=c(),a=f(),s=l().normalizeRanks,i=g(),u=l().removeEmptyRanks,h=m(),p=x(),b=v(),y=_(),w=O(),k=l(),j=o().Graph;t.exports=function(e,t={}){let o=t.debugTiming?k.time:k.notime;return o("layout",()=>{let l=o(" buildLayoutGraph",()=>{var t;let r,n;return t=e,r=new j({multigraph:!0,compound:!0}),n=L(t.graph()),r.setGraph(Object.assign({},N,T(n,E),k.pick(n,C))),t.nodes().forEach(e=>{let n=T(L(t.node(e)),S);Object.keys(R).forEach(e=>{void 0===n[e]&&(n[e]=R[e])}),r.setNode(e,n),r.setParent(e,t.parent(e))}),t.edges().forEach(e=>{let n=L(t.edge(e));r.setEdge(e,Object.assign({},P,T(n,M),k.pick(n,F)))}),r});return o(" runLayout",()=>{var e,d,c;return e=l,d=o,c=t,void(d(" makeSpaceForEdgeLabels",()=>{var t;let r;return r=(t=e).graph(),void(r.ranksep/=2,t.edges().forEach(e=>{let n=t.edge(e);n.minlen*=2,"c"!==n.labelpos.toLowerCase()&&("TB"===r.rankdir||"BT"===r.rankdir?n.width+=n.labeloffset:n.height+=n.labeloffset)}))}),d(" removeSelfEdges",()=>{var t;(t=e).edges().forEach(e=>{if(e.v===e.w){var r=t.node(e.v);r.selfEdges||(r.selfEdges=[]),r.selfEdges.push({e:e,label:t.edge(e)}),t.removeEdge(e)}})}),d(" acyclic",()=>r.run(e)),d(" nestingGraph.run",()=>h.run(e)),d(" rank",()=>a(k.asNonCompoundGraph(e))),d(" injectEdgeLabelProxies",()=>{var t;(t=e).edges().forEach(e=>{let r=t.edge(e);if(r.width&&r.height){let r=t.node(e.v),n={rank:(t.node(e.w).rank-r.rank)/2+r.rank,e:e};k.addDummyNode(t,"edge-proxy",n,"_ep")}})}),d(" removeEmptyRanks",()=>u(e)),d(" nestingGraph.cleanup",()=>h.cleanup(e)),d(" normalizeRanks",()=>s(e)),d(" assignRankMinMax",()=>{var t;let r;return r=0,void((t=e).nodes().forEach(e=>{let n=t.node(e);n.borderTop&&(n.minRank=t.node(n.borderTop).rank,n.maxRank=t.node(n.borderBottom).rank,r=Math.max(r,n.maxRank))}),t.graph().maxRank=r)}),d(" removeEdgeLabelProxies",()=>{var t;(t=e).nodes().forEach(e=>{let r=t.node(e);"edge-proxy"===r.dummy&&(t.edge(r.e).labelRank=r.rank,t.removeNode(e))})}),d(" normalize.run",()=>n.run(e)),d(" parentDummyChains",()=>i(e)),d(" addBorderSegments",()=>p(e)),d(" order",()=>y(e,c)),d(" insertSelfEdges",()=>{var t;return t=e,void k.buildLayerMatrix(t).forEach(e=>{var r=0;e.forEach((e,n)=>{var a=t.node(e);a.order=n+r,(a.selfEdges||[]).forEach(e=>{k.addDummyNode(t,"selfedge",{width:e.label.width,height:e.label.height,rank:a.rank,order:n+ ++r,e:e.e,label:e.label},"_se")}),delete a.selfEdges})})}),d(" adjustCoordinateSystem",()=>b.adjust(e)),d(" position",()=>w(e)),d(" positionSelfEdges",()=>{var t;(t=e).nodes().forEach(e=>{var r=t.node(e);if("selfedge"===r.dummy){var n=t.node(r.e.v),a=n.x+n.width/2,o=n.y,s=r.x-a,i=n.height/2;t.setEdge(r.e,r.label),t.removeNode(e),r.label.points=[{x:a+2*s/3,y:o-i},{x:a+5*s/6,y:o-i},{x:a+s,y:o},{x:a+5*s/6,y:o+i},{x:a+2*s/3,y:o+i}],r.label.x=r.x,r.label.y=r.y}})}),d(" removeBorderNodes",()=>{var t;(t=e).nodes().forEach(e=>{if(t.children(e).length){let r=t.node(e),n=t.node(r.borderTop),a=t.node(r.borderBottom),o=t.node(r.borderLeft[r.borderLeft.length-1]),s=t.node(r.borderRight[r.borderRight.length-1]);r.width=Math.abs(s.x-o.x),r.height=Math.abs(a.y-n.y),r.x=o.x+r.width/2,r.y=n.y+r.height/2}}),t.nodes().forEach(e=>{"border"===t.node(e).dummy&&t.removeNode(e)})}),d(" normalize.undo",()=>n.undo(e)),d(" fixupEdgeLabelCoords",()=>{var t;(t=e).edges().forEach(e=>{let r=t.edge(e);if(Object.hasOwn(r,"x"))switch(("l"===r.labelpos||"r"===r.labelpos)&&(r.width-=r.labeloffset),r.labelpos){case"l":r.x-=r.width/2+r.labeloffset;break;case"r":r.x+=r.width/2+r.labeloffset}})}),d(" undoCoordinateSystem",()=>b.undo(e)),d(" translateGraph",()=>(function(e){let t=1/0,r=0,n=1/0,a=0,o=e.graph(),s=o.marginx||0,i=o.marginy||0;function l(e){let o=e.x,s=e.y,i=e.width,l=e.height;t=Math.min(t,o-i/2),r=Math.max(r,o+i/2),n=Math.min(n,s-l/2),a=Math.max(a,s+l/2)}e.nodes().forEach(t=>l(e.node(t))),e.edges().forEach(t=>{let r=e.edge(t);Object.hasOwn(r,"x")&&l(r)}),t-=s,n-=i,e.nodes().forEach(r=>{let a=e.node(r);a.x-=t,a.y-=n}),e.edges().forEach(r=>{let a=e.edge(r);a.points.forEach(e=>{e.x-=t,e.y-=n}),Object.hasOwn(a,"x")&&(a.x-=t),Object.hasOwn(a,"y")&&(a.y-=n)}),o.width=r-t+s,o.height=a-n+i})(e)),d(" assignNodeIntersects",()=>{var t;(t=e).edges().forEach(e=>{let r=t.edge(e),n=t.node(e.v),a=t.node(e.w),o,s;r.points?(o=r.points[0],s=r.points[r.points.length-1]):(r.points=[],o=a,s=n),r.points.unshift(k.intersectRect(n,o)),r.points.push(k.intersectRect(a,s))})}),d(" reversePoints",()=>{var t;(t=e).edges().forEach(e=>{let r=t.edge(e);r.reversed&&r.points.reverse()})}),d(" acyclic.undo",()=>r.undo(e)))}),o(" updateInputGraph",()=>{var t,r;return t=e,r=l,void(t.nodes().forEach(e=>{let n=t.node(e),a=r.node(e);n&&(n.x=a.x,n.y=a.y,n.order=a.order,n.rank=a.rank,r.children(e).length&&(n.width=a.width,n.height=a.height))}),t.edges().forEach(e=>{let n=t.edge(e),a=r.edge(e);n.points=a.points,Object.hasOwn(a,"x")&&(n.x=a.x,n.y=a.y)}),t.graph().width=r.graph().width,t.graph().height=r.graph().height)}),l})};var E=["nodesep","edgesep","ranksep","marginx","marginy"],N={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb",rankalign:"center"},C=["acyclicer","ranker","rankdir","align","rankalign"],S=["width","height","rank"],R={width:0,height:0},M=["minlen","weight","width","height","labeloffset"],P={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},F=["labelpos"];function T(e,t){return k.mapValues(k.pick(e,t),Number)}function L(e){var t={};return e&&Object.entries(e).forEach(([e,r])=>{"string"==typeof e&&(e=e.toLowerCase()),t[e]=r}),t}}),M=a((e,t)=>{var r=l(),n=o().Graph;t.exports={debugOrdering:function(e){let t=r.buildLayerMatrix(e),a=new n({compound:!0,multigraph:!0}).setGraph({});return e.nodes().forEach(t=>{a.setNode(t,{label:t}),a.setParent(t,"layer"+e.node(t).rank)}),e.edges().forEach(e=>a.setEdge(e.v,e.w,{},e.name)),t.forEach((e,t)=>{a.setNode("layer"+t,{rank:"same"}),e.reduce((e,t)=>(a.setEdge(e,t,{style:"invis"}),t))}),a}}}),P=a((e,t)=>{t.exports="2.0.4"});let F=a((e,t)=>{t.exports={graphlib:o(),layout:R(),debug:M(),util:{time:l().time,notime:l().notime},version:P()}})(),T={direction:"LR",ranksep:200,nodesep:30},L={featureNode:{width:388,height:140},repositoryNode:{width:400,height:140}};function A(e,t){let r=e.data;return r&&"number"==typeof r.width&&"number"==typeof r.height?{width:r.width,height:r.height}:L[e.type??""]??t}function D(e,t,r={}){let{direction:n="TB",nodeSize:a={width:172,height:36},ranksep:o=80,nodesep:s=30}=r;if(0===e.length)return{nodes:[],edges:[]};let i=new F.graphlib.Graph({multigraph:!0});i.setDefaultEdgeLabel(()=>({})),i.setGraph({rankdir:n,ranksep:o,nodesep:s});let l=new Set;for(let e of t)l.add(e.source),l.add(e.target);let d=e.filter(e=>l.has(e.id)),c=e.filter(e=>!l.has(e.id));for(let e of d){let t=A(e,a);i.setNode(e.id,{width:t.width,height:t.height})}for(let e of t)i.hasNode(e.source)&&i.hasNode(e.target)&&i.setEdge(e.source,e.target,{},e.id);F.layout(i);let{targetPosition:u,sourcePosition:h}=function(e){switch(e){case"LR":return{targetPosition:"left",sourcePosition:"right"};case"RL":return{targetPosition:"right",sourcePosition:"left"};case"BT":return{targetPosition:"bottom",sourcePosition:"top"};default:return{targetPosition:"top",sourcePosition:"bottom"}}}(n),p="LR"===n||"RL"===n,f=new Map;for(let e of d){let t=i.node(e.id),r=A(e,a);f.set(e.id,{cx:t.x,cy:t.y,w:r.width,h:r.height})}let g=0;for(let e of f.values()){g=p?e.cx:e.cy;break}for(let e of c){let t=A(e,a);f.set(e.id,{cx:p?g:0,cy:p?0:g,w:t.width,h:t.height})}let m=new Map;for(let e of t)f.has(e.source)&&f.has(e.target)&&(m.has(e.source)||m.set(e.source,[]),m.get(e.source).push(e.target));let x=new Map;for(let t=0;t<e.length;t++)x.set(e[t].id,t);for(let[,e]of m)e.sort((e,t)=>(x.get(e)??0)-(x.get(t)??0));let v=new Set;for(let e of m.values())for(let t of e)v.add(t);let b=[...[...l].filter(e=>f.has(e)&&!v.has(e)),...c.map(e=>e.id)];b.sort((e,t)=>(x.get(e)??0)-(x.get(t)??0));let y=new Map;for(let e of b)!function e(t){if(y.has(t))return y.get(t);let r=f.get(t),n=p?r.h:r.w,a=m.get(t);if(!a||0===a.length)return y.set(t,n),n;let o=0;for(let t of a)o+=e(t);let i=Math.max(n,o+=(a.length-1)*s);return y.set(t,i),i}(e);let w=0;for(let e of b){let t=y.get(e)??0;!function e(t,r){let n=f.get(t);p?n.cy=r:n.cx=r;let a=m.get(t);if(!a||0===a.length)return;let o=0;for(let e of a)o+=y.get(e)??0;let i=r-(o+=(a.length-1)*s)/2;for(let t of a){let r=y.get(t)??0;e(t,i+r/2),i+=r+s}}(e,w+t/2),w+=t+s}let k=[];for(let t of e){let e=f.get(t.id);e&&k.push({...t,targetPosition:u,sourcePosition:h,position:{x:e.cx-e.w/2,y:e.cy-e.h/2}})}return{nodes:k,edges:[...t]}}var I=e.i(21023);let $=(0,I.createServerReference)("40d25d386c9839e0e98db7bcdff2c1cfb2f6f129cf",I.callServer,void 0,I.findSourceMapURL,"archiveFeature"),z=(0,I.createServerReference)("7849ca9082c69328c4f9b602d25bb67b875b47aeb9",I.callServer,void 0,I.findSourceMapURL,"deleteFeature");var B=e.i(50294),G=e.i(2895);let U=(0,I.createServerReference)("40aee8c11a6cb7ef9cff8723ab0e399eb671a0b95d",I.callServer,void 0,I.findSourceMapURL,"stopFeature"),q=(0,I.createServerReference)("40924b985776c3236d835de5481bd4009abd73950c",I.callServer,void 0,I.findSourceMapURL,"unarchiveFeature");var H=e.i(9773);let W=(0,I.createServerReference)("406b12a6f2fe5778aa1bb3c29a8fb9cd324f2c1ab4",I.callServer,void 0,I.findSourceMapURL,"deleteRepository"),V=(0,I.createServerReference)("40d6b88b9fc86f47f6e2fc48a26a023feb3c9184e9",I.callServer,void 0,I.findSourceMapURL,"getFeatureMetadata");var X=e.i(39443),J=e.i(8361),K=e.i(18354),Y=e.i(99045);function Z(e,t){let r=new Map;for(let e of t)"dependencyEdge"===e.type&&r.set(e.target,e.source);let n=new Map,a=new Map;for(let t of e)"featureNode"===t.type?n.set(t.id,{nodeId:t.id,data:t.data,parentNodeId:r.get(t.id)}):"repositoryNode"===t.type&&a.set(t.id,{nodeId:t.id,data:t.data});return{featureMap:n,repoMap:a}}function Q(e,t){return(void 0===t.state||t.state===e.state)&&(void 0===t.lifecycle||t.lifecycle===e.lifecycle)&&(void 0===t.name||t.name===e.name)&&(void 0===t.description||t.description===e.description)}function ee(e,t){if(e.size!==t.size)return!1;for(let[r,n]of e){let e=t.get(r);if(!e||n.parentNodeId!==e.parentNodeId||n.data!==e.data&&JSON.stringify(n.data)!==JSON.stringify(e.data))return!1}return!0}let et=(0,K.createLogger)("[Polling]"),er=0,en=0;function ea(e,a){let o=(0,r.useRouter)(),s=(0,J.useSoundAction)("delete"),i=(0,J.useSoundAction)("create"),[l,d]=(0,t.useState)(!1),{nodes:c,edges:u,reconcile:h,updateFeature:p,addPendingFeature:f,removeFeature:g,restoreFeature:m,addRepository:x,removeRepository:v,replaceRepository:b,getFeatureRepositoryPath:y,getRepositoryData:w,getRepoMapSize:k,setCallbacks:j,beginMutation:E,endMutation:N,isMutating:C}=function(e,r,n=!1){let a=(0,t.useMemo)(()=>Z(e,r),[]),[o,s]=(0,t.useState)(a.featureMap),[i,l]=(0,t.useState)(a.repoMap),[d,c]=(0,t.useState)(new Map),u=(0,t.useRef)(new Map),h=(0,t.useRef)(new Set),p=(0,t.useRef)(0),f=(0,t.useRef)(new Set),g=(0,t.useRef)(new Set),m=(0,t.useRef)({}),x=(0,t.useMemo)(()=>({onNodeAction:e=>m.current.onNodeAction?.(e),onNodeSettings:e=>m.current.onNodeSettings?.(e),onFeatureDelete:(e,t,r,n)=>m.current.onFeatureDelete?.(e,t,r,n),onRepositoryAdd:e=>m.current.onRepositoryAdd?.(e),onRepositoryClick:e=>m.current.onRepositoryClick?.(e),onRepositoryDelete:e=>m.current.onRepositoryDelete?.(e),onRetryFeature:e=>m.current.onRetryFeature?.(e),onStartFeature:e=>m.current.onStartFeature?.(e),onArchiveFeature:e=>m.current.onArchiveFeature?.(e),onUnarchiveFeature:e=>m.current.onUnarchiveFeature?.(e)}),[]),v=(0,t.useRef)(o);v.current=o;let b=(0,t.useRef)(i);b.current=i;let y=(0,t.useMemo)(()=>{if(n)return o;let e=new Map;for(let[t,r]of o)"archived"!==r.data.state&&e.set(t,r);return e.size===o.size?o:e},[o,n]),w=(0,t.useMemo)(()=>(function(e,t,r,n){let a=[],o=[],s=e=>e.replace(/\\/g,"/"),i=new Map;for(let[e,r]of t)r.data.repositoryPath&&i.set(s(r.data.repositoryPath),e);let l=new Map;for(let[e,r]of[...t.entries()].sort((e,t)=>{let r=e[1].data.createdAt,n=t[1].data.createdAt;return("number"!=typeof r||Number.isNaN(r)?1/0:r)-("number"!=typeof n||Number.isNaN(n)?1/0:n)})){let t={...r.data,...n?.onRepositoryAdd&&{onAdd:()=>n.onRepositoryAdd(e)},...n?.onRepositoryClick&&{onClick:()=>n.onRepositoryClick(e)},...n?.onRepositoryDelete&&{onDelete:n.onRepositoryDelete}};a.push({id:e,type:"repositoryNode",position:{x:0,y:0},data:t})}for(let[t,d,c]of[...[...e.entries()].map(([e,t])=>[e,t,!1]),...[...r.entries()].filter(([t])=>!e.has(t)).map(([e,t])=>[e,t,!0])]){let u="creating"===d.data.state||c,h={...d.data,...!u&&n?.onNodeAction&&{onAction:()=>n.onNodeAction(t)},...!u&&n?.onNodeSettings&&{onSettings:()=>n.onNodeSettings(t)},...!u&&n?.onFeatureDelete&&{onDelete:n.onFeatureDelete},...!u&&"error"===d.data.state&&n?.onRetryFeature&&{onRetry:n.onRetryFeature},...!u&&"pending"===d.data.state&&n?.onStartFeature&&{onStart:n.onStartFeature},...!u&&("running"===d.data.state||"action-required"===d.data.state)&&n?.onStopFeature&&{onStop:n.onStopFeature},...!u&&"archived"!==d.data.state&&"deleting"!==d.data.state&&n?.onArchiveFeature&&{onArchive:n.onArchiveFeature},...!u&&"archived"===d.data.state&&n?.onUnarchiveFeature&&{onUnarchive:n.onUnarchiveFeature}};if(a.push({id:t,type:"featureNode",position:{x:0,y:0},data:h}),d.parentNodeId&&(e.has(d.parentNodeId)||r.has(d.parentNodeId)))o.push({id:`dep-${d.parentNodeId}-${t}`,source:d.parentNodeId,target:t,type:"dependencyEdge"});else{let e=s(d.data.repositoryPath),r=i.get(e)??function(e){if(l.has(e))return l.get(e);let t=`virtual-repo-${e}`,r=e.split("/").filter(Boolean).at(-1)??e;return a.push({id:t,type:"repositoryNode",position:{x:0,y:0},data:{name:r,repositoryPath:e}}),l.set(e,t),t}(e);o.push({id:`edge-${r}-${t}`,source:r,target:t,style:{strokeDasharray:"5 5"}})}}let d=new Set;for(let e of o)"dependencyEdge"===e.type&&d.add(e.source);let c=o.length>0;for(let e of a){let t=e.data;t.showHandles=c,"featureNode"===e.type&&(t.hasChildren=d.has(e.id))}return{nodes:a,edges:o}})(y,i,d,x),[y,i,d,x]),k=(0,t.useRef)({key:"",positions:new Map}),{nodes:j,edges:E}=(0,t.useMemo)(()=>{let e=w.nodes.map(e=>e.id).sort().join(","),t=w.edges.map(e=>`${e.source}-${e.target}`).sort().join(","),r=`${e}|${t}`;if(r!==k.current.key){let e=D(w.nodes,w.edges,T),t=new Map;for(let r of e.nodes)t.set(r.id,{position:r.position,targetPosition:r.targetPosition,sourcePosition:r.sourcePosition});let n=k.current.positions;if(n.size>0){let r=0,a=0;for(let[e,o]of t){let t=n.get(e);if(t){r=t.position.x-o.position.x,a=t.position.y-o.position.y;break}}if(0!==r||0!==a){for(let e of t.values())e.position={x:e.position.x+r,y:e.position.y+a};for(let t of e.nodes)t.position={x:t.position.x+r,y:t.position.y+a}}}return k.current={key:r,positions:t},e}let{positions:n}=k.current;return{nodes:w.nodes.map(e=>{let t=n.get(e.id);return t?{...e,...t}:e}),edges:w.edges}},[w]),N=(0,t.useCallback)((e,t)=>{if(p.current>0)return;let{featureMap:r,repoMap:n}=Z(e,t),a=new Set([...r.values()].map(e=>`${e.data.name}\0${e.data.repositoryPath}`));s(e=>{let t=[...e.entries()].filter(([,e])=>"creating"===e.data.state),n=new Map(r);for(let[e,r]of t){let t=`${r.data.name}\0${r.data.repositoryPath}`;a.has(t)||n.set(e,r)}let o=new Set;for(let[t,r]of e)"deleting"===r.data.state&&(n.has(t)?n.set(t,{...n.get(t),data:{...n.get(t).data,state:"deleting"}}):g.current.has(t)||(n.set(t,r),o.add(t)));for(let[e,t]of(g.current=o,u.current)){let r=n.get(e);r&&(n.set(e,{...r,data:{...r.data,...t}}),u.current.delete(e))}return ee(e,n)?e:n}),c(e=>{if(0===e.size)return e;let t=!1,r=new Map(e);for(let[n,o]of e){let e=`${o.data.name}\0${o.data.repositoryPath}`;a.has(e)&&(r.delete(n),t=!0)}return t?r:e}),l(e=>{let t=new Map(n),r=new Set([...n.values()].map(e=>e.data.repositoryPath));for(let[n,a]of e){if(t.has(n)||r.has(a.data.repositoryPath)){h.current.delete(n);continue}(n.startsWith("repo-temp-")||h.current.has(n))&&t.set(n,a)}return ee(e,t)?e:t})},[]),C=(0,t.useCallback)((e,t)=>{s(r=>{let n=r.get(e);if(!n)return u.current.set(e,{...u.current.get(e),...t}),r;if(u.current.delete(e),Q(n.data,t))return r;let a=new Map(r);return a.set(e,{...n,data:{...n.data,...t}}),a}),c(r=>{let n=r.get(e);if(!n||Q(n.data,t))return r;let a=new Map(r);return a.set(e,{...n,data:{...n.data,...t}}),a})},[]),_=(0,t.useCallback)((e,t,r)=>{c(n=>{let a=new Map(n);return a.set(e,{nodeId:e,data:t,parentNodeId:r}),a})},[]),S=(0,t.useCallback)(e=>{c(t=>{if(!t.has(e))return t;let r=new Map(t);return r.delete(e),r})},[]),O=(0,t.useCallback)(e=>{s(t=>{if(!t.has(e))return t;let r=new Map(t);return r.delete(e),r})},[]),R=(0,t.useCallback)((e,t)=>{s(r=>{let n=new Map(r);return n.set(e,t),n})},[]),M=(0,t.useCallback)((e,t)=>{h.current.add(e),l(r=>{let n=new Map(r);return n.set(e,{nodeId:e,data:t}),n})},[]),P=(0,t.useCallback)(e=>{h.current.delete(e),l(t=>{if(!t.has(e))return t;let r=new Map(t);return r.delete(e),r})},[]),F=(0,t.useCallback)((e,t,r)=>{h.current.delete(e),h.current.add(t),l(n=>{if(!n.has(e))return n;let a=new Map(n);return a.delete(e),a.set(t,{nodeId:t,data:r}),a})},[]),L=(0,t.useCallback)(e=>v.current.get(e)?.data.repositoryPath,[]),A=(0,t.useCallback)(e=>b.current.get(e)?.data,[]),I=(0,t.useCallback)(()=>b.current.size,[]),$=(0,t.useCallback)(e=>{m.current=e},[]),z=(0,t.useCallback)(()=>{p.current++},[]),B=(0,t.useCallback)((e=3e3)=>{let t=setTimeout(()=>{p.current=Math.max(0,p.current-1),f.current.delete(t)},e);f.current.add(t)},[]),G=(0,t.useCallback)(()=>p.current>0,[]);return(0,t.useEffect)(()=>{let e=f.current;return()=>{for(let t of e)clearTimeout(t);e.clear()}},[]),{nodes:j,edges:E,reconcile:N,updateFeature:C,addPendingFeature:_,removePendingFeature:S,removeFeature:O,restoreFeature:R,addRepository:M,removeRepository:P,replaceRepository:F,getFeatureRepositoryPath:L,getRepositoryData:A,getRepoMapSize:I,setCallbacks:$,beginMutation:z,endMutation:B,isMutating:G}}(e,a,l),_=(0,t.useRef)(c),S=(0,t.useRef)(u);(0,t.useEffect)(()=>{_.current=c,S.current=u},[c,u]);let O=(0,t.useMemo)(()=>e.map(e=>e.id).sort().join(","),[e]),R=(0,t.useMemo)(()=>e.filter(e=>"featureNode"===e.type).map(e=>{let t=e.data;return`${e.id}:${t.state}:${t.lifecycle}`}).sort().join(","),[e]),M=(0,t.useRef)("");(0,t.useEffect)(()=>{let t=`${O}|${R}`;t!==M.current&&(M.current=t,h(e,a))},[O,R,e,a,h]);let P=(0,t.useRef)(new Map),{events:F}=(0,X.useAgentEventsContext)();(0,t.useEffect)(()=>{let t=P.current;for(let r of e){if("featureNode"!==r.type)continue;let e=r.data,a=t.get(r.id);void 0!==a&&a!==e.state&&(F.some(t=>t.featureId===e.featureId&&(0,Y.mapEventTypeToState)(t.eventType)===e.state)||("done"===e.state?n.toast.success(e.name,{description:"Feature completed!"}):"action-required"===e.state?n.toast.warning(e.name,{description:"Waiting for your approval",action:{label:"Review",onClick:()=>o.push(`/feature/${e.featureId}`)}}):"error"===e.state&&n.toast.error(e.name,{description:e.errorMessage??"Agent failed"}))),t.set(r.id,e.state)}},[R,e,F,o]);let L=(0,t.useRef)(0);(0,t.useEffect)(()=>{if(L.current>F.length&&(L.current=0),F.length<=L.current)return;let e=F.slice(L.current);for(let{featureId:t,state:r,lifecycle:n}of(L.current=F.length,(0,Y.resolveSseEventUpdates)(e)))if(void 0!==r||void 0!==n){let e=`feat-${t}`,a=_.current.find(t=>t.id===e),o=a?a.data.state:void 0;if("deleting"===o||"error"===r&&C()&&"running"===o)continue;p(e,{...void 0!==r&&{state:r},...void 0!==n&&{lifecycle:n}})}},[F,p,C]),(0,t.useEffect)(()=>{let e=e=>{let{featureId:t}=e.detail;E(),p(`feat-${t}`,{state:"running"}),N()};return window.addEventListener("shep:feature-approved",e),()=>window.removeEventListener("shep:feature-approved",e)},[p,E,N]);let A=(0,t.useRef)(new Set),I=(0,t.useRef)(0);(0,t.useEffect)(()=>{if(I.current>F.length&&(I.current=0),F.length<=I.current)return;let e=F.slice(I.current);for(let t of(I.current=F.length,e)){if("Feature metadata updated"!==t.message||A.current.has(t.featureId))continue;A.current.add(t.featureId);let e=`feat-${t.featureId}`;V(t.featureId).then(t=>{t&&p(e,{name:t.name,description:t.description})}).catch(()=>{})}},[F,p]),(0,t.useEffect)(()=>{et.debug("polling enabled (15000ms interval)");let e=setInterval(async()=>{if(!document.hidden&&!C())try{let e=await fetch("/api/graph-data");if(!e.ok)throw Error(`status ${e.status}`);let{nodes:t,edges:r}=await e.json();h(t,r)}catch{et.warn("poll fetch failed — will retry next interval")}},15e3);return()=>{et.debug("polling disabled"),clearInterval(e)}},[h,C]);let K=(0,t.useCallback)(e=>{},[]),ea=(0,t.useCallback)(e=>{},[]),eo=(0,t.useCallback)((e,t,r)=>{let n=t?.featureId?`feat-${t.featureId}`:`feature-${Date.now()}-${er++}`,a={name:t?.name??"New Feature",description:t?.description??"Describe what this feature does",featureId:t?.featureId??`#${n.slice(-4)}`,lifecycle:"requirements",state:t?.state??"running",progress:0,repositoryPath:t?.repositoryPath??"",branch:t?.branch??""};return f(n,a,"dependencyEdge"===r&&e?e:void 0),n},[f]),es=(0,t.useCallback)(e=>{let t=`feat-${e}`;E(),p(t,{state:"running"}),(0,B.resumeFeature)(e).then(e=>{e.error?(p(t,{state:"error"}),n.toast.error(e.error)):n.toast.success("Feature resumed")}).catch(()=>{p(t,{state:"error"}),n.toast.error("Failed to resume feature")}).finally(()=>N())},[p,E,N]),ei=(0,t.useCallback)(e=>{let t=`feat-${e}`;E(),p(t,{state:"running"}),(0,G.startFeature)(e).then(e=>{e.error?(p(t,{state:"pending"}),n.toast.error(e.error)):n.toast.success("Feature started")}).catch(()=>{p(t,{state:"pending"}),n.toast.error("Failed to start feature")}).finally(()=>N())},[p,E,N]),el=(0,t.useCallback)(e=>{E(),U(e).then(e=>{e.error?n.toast.error(e.error):n.toast.success("Agent stopped")}).catch(()=>{n.toast.error("Failed to stop agent")}).finally(()=>N())},[E,N]),ed=(0,t.useCallback)(e=>{let t=`feat-${e}`;E(),p(t,{state:"archived"}),$(e).then(e=>{e.error?(p(t,{state:"done"}),n.toast.error(e.error)):n.toast.success("Feature archived")}).catch(()=>{p(t,{state:"done"}),n.toast.error("Failed to archive feature")}).finally(()=>N())},[p,E,N]),ec=(0,t.useCallback)(e=>{let t=`feat-${e}`;E(),p(t,{state:"done"}),q(e).then(e=>{e.error?(p(t,{state:"archived"}),n.toast.error(e.error)):n.toast.success("Feature unarchived")}).catch(()=>{p(t,{state:"archived"}),n.toast.error("Failed to unarchive feature")}).finally(()=>N())},[p,E,N]),eu=(0,t.useCallback)((e,t,r,a)=>{let i=`feat-${e}`,l=[];if(!0===r){let e=[i];for(;e.length>0;){let t=e.shift();for(let r of S.current)"dependencyEdge"===r.type&&r.source===t&&(l.push(r.target),e.push(r.target))}}let d=new Map;for(let e of[i,...l]){let t=_.current.find(t=>t.id===e);t&&d.set(e,t.data.state)}for(let e of(E(),p(i,{state:"deleting"}),l))p(e,{state:"deleting"});s.play(),o.push("/"),z(e,t,r,a).then(e=>{if(e.error){for(let[e,t]of d)t&&p(e,{state:t});n.toast.error(e.error)}else for(let e of(g(i),l))g(e)}).catch(()=>{for(let[e,t]of d)t&&p(e,{state:t});n.toast.error("Failed to delete feature")}).finally(()=>N())},[o,s,p,g,E,N]),eh=(0,t.useCallback)(async e=>{let t=`repo-${e}`,r=new Set(S.current.filter(e=>e.source===t).map(e=>e.target)),a=w(t),o=new Map;for(let e of r){let t=_.current.find(t=>t.id===e);t&&o.set(e,{nodeId:e,data:t.data})}let i=()=>{for(let[e,r]of(a&&x(t,a),o))m(e,r)};for(let e of(E(),v(t),r))g(e);try{let t=await W(e);if(!t.success){n.toast.error(t.error??"Failed to remove repository"),i();return}s.play()}catch{n.toast.error("Failed to remove repository"),i()}finally{N()}},[s,v,g,x,m,w,E,N]),ep=(0,t.useCallback)(e=>{let t=D(_.current,S.current,{...T,direction:e});h(t.nodes,t.edges)},[h]);return{nodes:c,edges:u,onNodesChange:K,handleConnect:ea,handleAddRepository:(0,t.useCallback)(e=>{let t=0===k(),r=`repo-temp-${++en}`,a=e.replace(/[\\/]+$/,"").split(/[\\/]/).pop()??e;return E(),x(r,{name:a,repositoryPath:e,id:r,createdAt:Date.now(),gitInfoStatus:"loading"}),(0,H.addRepository)({path:e,name:a}).then(e=>{if(e.error){v(r),n.toast.error(e.error);return}let t=e.repository;b(r,`repo-${t.id}`,{name:t.name,repositoryPath:t.path,id:t.id,createdAt:t.createdAt instanceof Date?t.createdAt.getTime():Number(t.createdAt)}),i.play()}).catch(()=>{v(r),n.toast.error("Failed to add repository")}).finally(()=>N()),{wasEmpty:t,repoPath:e}},[x,v,b,i,k,E,N]),handleArchiveFeature:ed,handleLayout:ep,handleDeleteFeature:eu,handleRetryFeature:es,handleStartFeature:ei,handleStopFeature:el,handleUnarchiveFeature:ec,handleDeleteRepository:eh,createFeatureNode:eo,showArchived:l,setShowArchived:d,getFeatureRepositoryPath:y,getRepositoryData:w,setCallbacks:j}}e.s(["useControlCenterState",()=>ea],17840)},48246,e=>{"use strict";var t=e.i(20314),r=e.i(53271),n=e.i(92786),a=e.i(79054),o=e.i(31406),s=e.i(53756),i=e.i(91925),l=e.i(3645);let d=(0,l.default)("github",[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]]);var c=e.i(49228),u=e.i(3214),h=e.i(31777),p=e.i(35364);e.i(54793);var f=e.i(7729);e.i(47506);var g=e.i(89313),m=e.i(92002),x=e.i(8986),v=e.i(38573),b=e.i(19933),y=e.i(67669),w=e.i(24042),k=e.i(6910),j=e.i(48923),E=e.i(7311),N=e.i(94365),C=e.i(38227),_=e.i(48109);e.i(81803);var S=e.i(72714),O=e.i(2287),R=e.i(2828),M=e.i(8537),P=e.i(75921),F=e.i(76852),T=e.i(57779),L=e.i(80554),A=e.i(80519);function D({data:e,selected:n}){let s=(0,o.useRouter)(),i=(0,P.useFeatureFlags)(),[l,f]=(0,a.useState)(!1),g=e.id?`repo-${e.id}`:`repo-${e.name}`,D=(0,L.useTurnStatus)(g),I=(0,F.useRepositoryActions)(e.repositoryPath?{repositoryId:e.id,repositoryPath:e.repositoryPath}:null),$=(0,M.useDeployAction)(e.repositoryPath?{targetId:e.repositoryPath,targetType:"repository",repositoryPath:e.repositoryPath}:null),z="Booting"===$.status||"Ready"===$.status,B=(0,a.useCallback)((t,r)=>{if(!e.repositoryPath)return;let n=t.preview?t.preview.slice(0,200):"Unknown conversation",a=["Continue work from a previous agent session.","","## Session Context",`- Session ID: ${t.id}`,`- Messages: ${t.messageCount}`,t.lastMessageAt?`- Last active: ${t.lastMessageAt}`:"",`- Conversation file: ${r}`,"","## Session Preview",`> ${n}`,"","## Instructions","1. Read the full conversation history from the file above",`2. Analyze the current state of the repository — what was done, what remains`,"3. Create or update spec files to accurately reflect the current state and remaining work","4. Continue implementing any unfinished work from the conversation"].filter(Boolean).join("\n"),o=new URLSearchParams({repo:e.repositoryPath,prompt:a});s.push(`/create?${o.toString()}`)},[e.repositoryPath,s]);return(0,t.jsxs)("div",{className:(0,h.cn)("group relative",e.onDelete&&e.id&&"pl-10"),children:[e.showHandles?(0,t.jsx)(r.Handle,{type:"target",position:m.Position.Left,isConnectable:!1,className:"opacity-0!",style:{top:70}}):null,e.onDelete&&e.id?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"absolute top-1/2 left-0 -translate-y-1/2 opacity-0 transition-opacity group-hover:opacity-100",children:(0,t.jsx)(R.TooltipProvider,{children:(0,t.jsxs)(R.Tooltip,{children:[(0,t.jsx)(R.TooltipTrigger,{asChild:!0,children:(0,t.jsx)("button",{"aria-label":"Remove repository","data-testid":"repository-node-delete-button",onClick:e=>{e.stopPropagation(),f(!0)},className:"bg-card text-muted-foreground hover:border-destructive hover:text-destructive flex h-7 w-7 cursor-pointer items-center justify-center rounded-full border shadow-sm transition-colors",children:(0,t.jsx)(y.Trash2,{className:"h-3.5 w-3.5"})})}),(0,t.jsx)(R.TooltipContent,{children:"Remove repository"})]})})}),(0,t.jsx)(O.Dialog,{open:l,onOpenChange:f,children:(0,t.jsxs)(O.DialogContent,{className:"max-w-xs",children:[(0,t.jsxs)(O.DialogHeader,{children:[(0,t.jsx)(O.DialogTitle,{children:"Remove repository?"}),(0,t.jsxs)(O.DialogDescription,{children:["This will remove ",(0,t.jsx)("strong",{children:e.name})," and all its features from your workspace. The repository files on disk won't be affected."]})]}),(0,t.jsxs)(O.DialogFooter,{className:"grid grid-cols-2 gap-2 sm:flex-none",children:[(0,t.jsx)(O.DialogClose,{asChild:!0,children:(0,t.jsx)(p.Button,{variant:"outline",children:"Cancel"})}),(0,t.jsx)(p.Button,{variant:"destructive",onClick:()=>{f(!1),e.onDelete?.(e.id)},children:"Remove"})]})]})})]}):null,(0,t.jsxs)("div",{role:"button",tabIndex:0,"data-testid":"repository-node-card","data-repo-name":e.name,onClick:t=>{t.stopPropagation(),e.onClick?.()},onKeyDown:t=>{("Enter"===t.key||" "===t.key)&&(t.preventDefault(),t.stopPropagation(),e.onClick?.())},className:(0,h.cn)("nodrag bg-card flex w-[26rem] cursor-pointer flex-col overflow-hidden rounded-xl border shadow-sm transition-[border-color,box-shadow] duration-200 dark:bg-neutral-800/80",n&&"border-blue-400 dark:border-amber-500/60"),children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 px-4 py-3",children:[(0,t.jsx)(d,{className:"text-muted-foreground h-5 w-5 shrink-0"}),(0,t.jsx)("span",{"data-testid":"repository-node-name",className:"min-w-0 truncate text-sm font-medium",children:e.name}),(0,t.jsxs)("div",{className:(0,h.cn)("flex shrink-0 items-center gap-2",(e.repositoryPath??e.onAdd)&&"ml-auto"),onClick:e=>e.stopPropagation(),children:[e.repositoryPath?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(R.TooltipProvider,{children:(0,t.jsxs)(R.Tooltip,{children:[(0,t.jsx)(R.TooltipTrigger,{asChild:!0,children:(0,t.jsx)("span",{className:"flex items-center",children:(0,t.jsx)(S.ActionButton,{label:"Open in IDE",onClick:I.openInIde,loading:I.ideLoading,error:!!I.ideError,icon:x.Code2,iconOnly:!0,variant:"ghost",size:"icon-xs"})})}),(0,t.jsx)(R.TooltipContent,{children:"Open in IDE"})]})}),(0,t.jsx)(R.TooltipProvider,{children:(0,t.jsxs)(R.Tooltip,{children:[(0,t.jsx)(R.TooltipTrigger,{asChild:!0,children:(0,t.jsx)("span",{className:"flex items-center",children:(0,t.jsx)(S.ActionButton,{label:"Open in Shell",onClick:I.openInShell,loading:I.shellLoading,error:!!I.shellError,icon:v.Terminal,iconOnly:!0,variant:"ghost",size:"icon-xs"})})}),(0,t.jsx)(R.TooltipContent,{children:"Open in Shell"})]})}),(0,t.jsx)(R.TooltipProvider,{children:(0,t.jsxs)(R.Tooltip,{children:[(0,t.jsx)(R.TooltipTrigger,{asChild:!0,children:(0,t.jsx)("span",{className:"flex items-center",children:(0,t.jsx)(S.ActionButton,{label:"Open Folder",onClick:I.openFolder,loading:I.folderLoading,error:!!I.folderError,icon:b.FolderOpen,iconOnly:!0,variant:"ghost",size:"icon-xs"})})}),(0,t.jsx)(R.TooltipContent,{children:"Open Folder"})]})}),(0,t.jsx)(R.TooltipProvider,{children:(0,t.jsxs)(R.Tooltip,{children:[(0,t.jsx)(R.TooltipTrigger,{asChild:!0,children:(0,t.jsxs)(p.Button,{variant:"ghost",size:"icon-xs","aria-label":"Chat with agent",onClick:t=>{t.stopPropagation(),e.id&&s.push(`/repository/${e.id}/chat`)},className:"nodrag relative cursor-pointer text-violet-500 hover:text-violet-600 dark:text-violet-400 dark:hover:text-violet-300",children:[(0,t.jsx)(_.MessageSquare,{className:"h-3 w-3"}),(0,t.jsx)(T.ChatDotIndicator,{status:D})]})}),(0,t.jsx)(R.TooltipContent,{children:"Chat with agent"})]})}),(0,t.jsx)(A.FeatureSessionsDropdown,{repositoryPath:e.repositoryPath,includeWorktrees:!0,onCreateFromSession:B})]}):null,e.onAdd?(0,t.jsx)("div",{className:"ml-1.5"}):null,e.onAdd?(0,t.jsx)(R.TooltipProvider,{children:(0,t.jsxs)(R.Tooltip,{children:[(0,t.jsx)(R.TooltipTrigger,{asChild:!0,children:(0,t.jsxs)("button",{"aria-label":"New feature","data-testid":"repository-node-add-button",onClick:t=>{t.stopPropagation(),e.onAdd?.()},className:(0,h.cn)("flex h-6 shrink-0 cursor-pointer items-center gap-0.5 rounded bg-blue-500 px-1.5 text-[11px] font-bold text-white transition-colors hover:bg-blue-600 dark:bg-amber-500 dark:hover:bg-amber-400",e.pulseAdd&&"animate-pulse-cta"),children:[(0,t.jsx)(u.Plus,{className:"h-3 w-3"}),(0,t.jsx)("span",{className:"translate-y-px",children:"New"})]})}),(0,t.jsx)(R.TooltipContent,{side:"top",children:"New feature"})]})}):null]})]}),e.branch?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{"data-testid":"repository-node-git-info",className:"text-muted-foreground border-border/50 border-t px-4 py-2",children:(0,t.jsxs)("div",{className:"flex items-center gap-3 text-xs",children:[(0,t.jsxs)("span",{className:"flex items-center gap-1 truncate","data-testid":"repository-node-branch",children:[(0,t.jsx)(c.GitBranch,{className:"h-3 w-3 shrink-0"}),(0,t.jsx)("span",{className:"truncate",children:e.branch})]}),null!=e.behindCount&&e.behindCount>0?(0,t.jsxs)("span",{className:"flex shrink-0 items-center gap-1 whitespace-nowrap text-amber-500","data-testid":"repository-node-behind",children:[(0,t.jsx)(E.ArrowDown,{className:"h-3 w-3 shrink-0"}),e.behindCount," behind"]}):null]})}),e.commitMessage?(0,t.jsx)("div",{"data-testid":"repository-node-commit-info",className:"text-muted-foreground border-border/50 border-t px-4 py-2",children:(0,t.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,t.jsx)(j.GitCommitHorizontal,{className:"h-3 w-3 shrink-0"}),(0,t.jsx)("span",{className:"min-w-0 truncate","data-testid":"repository-node-commit-message",children:e.commitMessage}),e.committer?(0,t.jsxs)("span",{className:"text-muted-foreground/70 ml-auto flex shrink-0 items-center gap-1","data-testid":"repository-node-committer",children:[(0,t.jsx)(N.User,{className:"h-3 w-3 shrink-0"}),(0,t.jsx)("span",{children:e.committer})]}):null]})}):null]}):"not-a-repo"===e.gitInfoStatus?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{"data-testid":"repository-node-not-repo",className:"text-muted-foreground border-border/50 border-t px-4 py-2",children:(0,t.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,t.jsx)(b.FolderOpen,{className:"h-3 w-3 shrink-0"}),(0,t.jsx)("span",{className:"min-w-0 truncate opacity-60",children:e.repositoryPath??"Unknown path"})]})}),(0,t.jsx)("div",{className:"text-muted-foreground border-border/50 border-t px-4 py-2",children:(0,t.jsxs)("div",{className:"flex items-center gap-2 text-xs opacity-40",children:[(0,t.jsx)(c.GitBranch,{className:"h-3 w-3 shrink-0"}),(0,t.jsx)("span",{children:"Not a git repository"})]})})]}):"ready"!==e.gitInfoStatus?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{"data-testid":"repository-node-git-loading",className:"border-border/50 border-t px-4 py-2",children:(0,t.jsxs)("div",{className:"flex h-4 items-center gap-2 text-xs",children:[(0,t.jsx)(c.GitBranch,{className:"text-muted-foreground h-3 w-3 shrink-0"}),(0,t.jsx)("span",{className:"bg-muted h-3 w-20 animate-pulse rounded"})]})}),(0,t.jsx)("div",{className:"border-border/50 border-t px-4 py-2",children:(0,t.jsxs)("div",{className:"flex h-4 items-center gap-2 text-xs",children:[(0,t.jsx)(j.GitCommitHorizontal,{className:"text-muted-foreground h-3 w-3 shrink-0"}),(0,t.jsx)("span",{className:"bg-muted h-3 w-36 animate-pulse rounded"})]})})]}):null,i.envDeploy&&e.repositoryPath?(0,t.jsx)("div",{"data-testid":"repository-node-dev-preview",className:"border-border/50 border-t px-4 py-2",onClick:e=>e.stopPropagation(),children:(0,t.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[$.deployError?(0,t.jsx)("span",{className:"truncate text-xs text-red-500",children:$.deployError}):z?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"mr-0.5 inline-block h-2 w-2 shrink-0 rounded-full bg-green-500"}),$.url?(0,t.jsx)("a",{href:$.url,target:"_blank",rel:"noopener noreferrer",className:"truncate text-green-700 hover:underline dark:text-green-400",children:$.url}):(0,t.jsx)("span",{className:"text-muted-foreground",children:"Starting..."})]}):(0,t.jsxs)("span",{className:"text-muted-foreground",children:["Run",(0,t.jsx)("span",{className:"text-muted-foreground/50 ml-2 text-[10px]",children:"start local environment"})]}),(0,t.jsx)(R.TooltipProvider,{children:(0,t.jsxs)(R.Tooltip,{children:[(0,t.jsx)(R.TooltipTrigger,{asChild:!0,children:(0,t.jsx)("span",{className:(0,h.cn)("ml-auto flex items-center",!z&&!$.deployError&&"[&_button]:text-green-600 [&_button]:hover:text-green-700 dark:[&_button]:text-green-400 dark:[&_button]:hover:text-green-300"),children:(0,t.jsx)(S.ActionButton,{label:$.deployError?"Retry":z?"Stop Dev Server":"Start Dev Server",onClick:z?$.stop:$.deploy,loading:$.deployLoading||$.stopLoading,error:!1,icon:$.deployError?C.RotateCcw:z?k.Square:w.Play,iconOnly:!0,variant:"ghost",size:"icon-xs"})})}),(0,t.jsx)(R.TooltipContent,{children:z?"Stop Dev Server":"Start Dev Server"})]})})]})}):null]}),e.onAdd||e.showHandles?(0,t.jsx)(r.Handle,{type:"source",position:m.Position.Right,isConnectable:!e.showHandles,className:"opacity-0!",style:{top:70}}):null]})}function I(e){let[n]=(0,m.getBezierPath)({sourceX:e.sourceX,sourceY:e.sourceY,targetX:e.targetX,targetY:e.targetY,sourcePosition:e.sourcePosition,targetPosition:e.targetPosition});return(0,t.jsx)(r.BaseEdge,{id:e.id,path:n,style:{strokeDasharray:"5 5"}})}e.i(1650),e.i(45811),e.i(25235);let $={x:30,y:30,zoom:.85};function z({nodes:e,edges:n,selectedFeatureId:o,selectedRepository:s,defaultViewport:i,onNodesChange:l,onAddFeature:d,onConnect:c,onNodeClick:m,onPaneClick:x,onCanvasDrag:v,onMoveEnd:b,toolbar:y,emptyState:w}){let k=(0,a.useMemo)(()=>({featureNode:g.FeatureNode,repositoryNode:D}),[]),j=(0,a.useMemo)(()=>({dependencyEdge:I}),[]),E=(0,a.useMemo)(()=>{let t=null!=o,r=null!=s&&(null!=s.id||null!=s.path);return t||r?e.map(e=>{if(t&&"featureNode"===e.type&&e.data.featureId===o)return{...e,selected:!0};if(r&&"repositoryNode"===e.type){let t=e.data,r=null!=s.id&&(e.id===s.id||t.id===s.id),n=null!=s.path&&t.repositoryPath===s.path;if(r||n)return{...e,selected:!0}}return e}):e},[e,o,s]),N=0===e.length,[C,_]=(0,a.useState)(N),[S,O]=(0,a.useState)(!1),R=(0,a.useRef)(N);(0,a.useEffect)(()=>{if(R.current&&!N){O(!0);let e=setTimeout(()=>{_(!1),O(!1)},300);return R.current=N,()=>clearTimeout(e)}!R.current&&N&&_(!0),R.current=N},[N]);let M=N&&!w?(0,t.jsx)(f.EmptyState,{title:"No features yet",description:"Get started by creating your first feature.",action:(0,t.jsxs)(p.Button,{onClick:d,children:[(0,t.jsx)(u.Plus,{className:"mr-2 h-4 w-4"}),"New Feature"]})}):null,P=w??M;return(0,t.jsxs)("div",{"data-testid":N?"features-canvas-empty":"features-canvas","data-no-drawer-close":!0,className:"dark:bg-background pointer-events-auto relative h-full w-full bg-[#f6f7f8]",children:[(0,t.jsxs)(r.ReactFlow,{nodes:E,edges:n,nodeTypes:k,edgeTypes:j,onConnect:c,onNodesChange:l,onNodeClick:m,onPaneClick:x,onMoveStart:v,onMoveEnd:b,defaultViewport:i??$,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,proOptions:{hideAttribution:!0},className:"[&_.react-flow__pane]:!cursor-default",children:[(0,t.jsx)(r.Background,{variant:r.BackgroundVariant.Dots,gap:24,size:1,color:"#b8bcc4",className:"dark:[&_circle]:!fill-white/[0.1]"}),!N&&y?(0,t.jsx)(r.Panel,{position:"top-right",className:"!mt-3 !mr-3",children:y}):null]}),C&&P?(0,t.jsx)("div",{className:(0,h.cn)("pointer-events-none absolute inset-0 z-10 flex items-center justify-center transition-opacity duration-300",S?"opacity-0":"animate-in fade-in opacity-100 duration-200"),children:(0,t.jsx)("div",{className:"pointer-events-auto h-full w-full",children:P})}):null]})}var B=e.i(87889);let G=(0,l.default)("eye-off",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]),U=(0,l.default)("zoom-in",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]),q=(0,l.default)("zoom-out",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]),H=(0,l.default)("maximize",[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]]);function W({showArchived:e,onToggleArchived:n,onResetViewport:o}){let{zoomIn:s,zoomOut:i,fitView:l,setViewport:d}=(0,r.useReactFlow)(),c=(0,a.useCallback)(()=>{s({duration:200})},[s]),u=(0,a.useCallback)(()=>{i({duration:200})},[i]),h=(0,a.useCallback)(()=>{l({duration:400,padding:.3})},[l]),p=(0,a.useCallback)(()=>{o&&d(o(),{duration:400})},[o,d]);return(0,t.jsxs)("div",{className:"bg-background flex items-center gap-1 rounded-xl border px-2 py-1.5 shadow-md dark:bg-neutral-900",children:[(0,t.jsx)(V,{onClick:n,title:e?"Hide archived":"Show archived",active:e,label:e?"Hide Archived":"Show Archived",children:e?(0,t.jsx)(B.Eye,{className:"h-4 w-4"}):(0,t.jsx)(G,{className:"h-4 w-4"})}),(0,t.jsx)("div",{className:"bg-border mx-1 h-5 w-px"}),(0,t.jsx)(V,{onClick:u,title:"Zoom out",children:(0,t.jsx)(q,{className:"h-4 w-4"})}),(0,t.jsx)(V,{onClick:c,title:"Zoom in",children:(0,t.jsx)(U,{className:"h-4 w-4"})}),(0,t.jsx)(V,{onClick:h,title:"Fit view",children:(0,t.jsx)(H,{className:"h-4 w-4"})}),o?(0,t.jsx)(V,{onClick:p,title:"Reset view",children:(0,t.jsx)(C.RotateCcw,{className:"h-4 w-4"})}):null]})}function V({children:e,onClick:r,title:n,label:a,active:o}){return(0,t.jsxs)("button",{type:"button",onClick:r,title:n,className:(0,h.cn)("inline-flex items-center gap-1.5 rounded-lg px-2 py-1.5 text-xs font-medium transition-colors","hover:bg-accent hover:text-accent-foreground",o?"text-primary bg-primary/10":"text-muted-foreground"),children:[e,a?(0,t.jsx)("span",{children:a}):null]})}var X=e.i(83428),J=e.i(60253);function K({actions:e,className:r,style:n}){let[o,s]=(0,a.useState)(!1);return(0,a.useEffect)(()=>{if(o)return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e);function e(e){"Escape"===e.key&&s(!1)}},[o]),(0,t.jsxs)(t.Fragment,{children:[o?(0,t.jsx)("div",{"data-testid":"fab-overlay",className:"fixed inset-0 z-40",onClick:()=>s(!1),"aria-hidden":"true"}):null,(0,t.jsxs)("div",{"data-testid":"floating-action-button",className:(0,h.cn)("relative z-50",r),style:n,children:[(0,t.jsx)("div",{className:(0,h.cn)("absolute bottom-[calc(100%+24px)] left-0 flex flex-col items-start gap-2",!o&&"pointer-events-none"),"data-testid":"fab-actions",children:e.map((r,n)=>{let a=(e.length-1-n)*50;return(0,t.jsxs)("button",{"data-testid":`fab-action-${r.id}`,"aria-label":r.label,disabled:r.disabled??r.loading,className:(0,h.cn)("flex h-10 items-center gap-2.5 rounded-full px-4","bg-background text-foreground shadow-md","border-border border","hover:bg-accent hover:text-accent-foreground","disabled:pointer-events-none disabled:opacity-50","text-sm font-medium whitespace-nowrap",o?"translate-y-0 opacity-100":"pointer-events-none translate-y-0 opacity-0"),style:{transition:`opacity ${o?250:120}ms ease-out ${o?a:0}ms, transform ${o?250:120}ms ease-out ${o?a:0}ms`},onClick:()=>{r.onClick(),s(!1)},children:[(0,t.jsx)("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center",children:r.loading?(0,t.jsx)(X.Loader2,{className:"h-4 w-4 animate-spin"}):r.icon}),(0,t.jsx)("span",{children:r.label})]},r.id)})}),(0,t.jsxs)(p.Button,{size:"icon","data-testid":"fab-trigger","aria-label":o?"Close actions":"Create new",className:(0,h.cn)("relative h-14 w-14 rounded-full shadow-lg","bg-indigo-500 text-white hover:bg-indigo-400 dark:bg-indigo-500 dark:hover:bg-indigo-400","transition-all duration-200 hover:scale-105 hover:shadow-xl active:scale-95"),onClick:()=>s(e=>!e),children:[(0,t.jsx)(u.Plus,{className:(0,h.cn)("absolute h-7 w-7 stroke-[2.5] transition-all",o?"scale-0 rotate-90 opacity-0":"scale-100 rotate-0 opacity-100"),style:{transitionDuration:"250ms"}}),(0,t.jsx)(J.X,{className:(0,h.cn)("absolute h-6 w-6 stroke-[2.5] transition-all",o?"scale-100 rotate-0 opacity-100":"scale-0 -rotate-90 opacity-0"),style:{transitionDuration:"250ms"}})]})]})]})}var Y=e.i(5147),Z=e.i(8361),Q=e.i(30153);let ee="shep-canvas-viewport",et={x:30,y:30,zoom:.85};var er=e.i(57638),en=e.i(33548),ea=e.i(23925),eo=e.i(35e3),es=e.i(79687),ei=e.i(99105),el=e.i(30702),ed=e.i(78521);e.i(13322);var ec=e.i(61201),eu=e.i(21023);let eh=(0,eu.createServerReference)("00573234df94c1cd9ee9027a3d56d60d331f23e49e",eu.callServer,void 0,eu.findSourceMapURL,"isAgentSetupComplete"),ep=(0,eu.createServerReference)("008a5c1b09e01b2ef435bcec451f2dc8f4808e2fff",eu.callServer,void 0,eu.findSourceMapURL,"checkAgentAuth"),ef=(0,eu.createServerReference)("00f6f61c001fb8e7b0468abd54f36931d2a20c3913",eu.callServer,void 0,eu.findSourceMapURL,"checkToolStatus");var eg=e.i(11345),em=e.i(58481),ex=e.i(21026),ev=e.i(20947),eb=e.i(86782),ey=e.i(29847);let ew=["select-agent","select-model"];function ek({onComplete:e,className:r}){let[n,o]=(0,a.useState)([]),[s,i]=(0,a.useState)(!0),[l,d]=(0,a.useState)("select-agent"),[c,u]=(0,a.useState)(null),[p,f]=(0,a.useState)(!1),[g,m]=(0,a.useState)(!1),[x,v]=(0,a.useState)(!0),b=(0,a.useRef)(void 0);(0,a.useEffect)(()=>{(0,ex.getAllAgentModels)().then(o).finally(()=>i(!1))},[]);let y=c?n.find(e=>e.agentType===c):null,w=(0,a.useCallback)((e,t)=>{m(!0),v(!1),b.current&&clearTimeout(b.current),b.current=setTimeout(()=>{t?.(),d(e),requestAnimationFrame(()=>{v(!0),m(!1)})},150)},[]);(0,a.useEffect)(()=>()=>{b.current&&clearTimeout(b.current)},[]);let k=(0,a.useCallback)(async(t,r)=>{f(!0);try{await (0,ev.updateAgentAndModel)(t,r),v(!1),b.current&&clearTimeout(b.current),b.current=setTimeout(()=>{e()},200)}catch{f(!1)}},[e]),j=(0,a.useCallback)(e=>{let t=n.find(t=>t.agentType===e);t&&t.models.length>0?w("select-model",()=>{u(e)}):k(e,null)},[n,w,k]),E=(0,a.useCallback)(e=>{c&&k(c,e)},[c,k]),N=(0,a.useCallback)(()=>{"select-model"===l&&w("select-agent",()=>{u(null)})},[l,w]);if(s)return(0,t.jsxs)("div",{"data-testid":"welcome-agent-setup",className:(0,h.cn)("flex flex-col items-center justify-center gap-4",r),children:[(0,t.jsx)(X.Loader2,{className:"text-muted-foreground h-5 w-5 animate-spin"}),(0,t.jsx)("p",{className:"text-muted-foreground text-sm",children:"Loading agents…"})]});let C=ew.indexOf(l),_="select-agent"===l?"Choose your agent":"Pick a model",S="select-agent"===l?"Select the AI coding agent you want Shep to use.":y?`Choose which ${y.label} model to run.`:"";return(0,t.jsxs)("div",{"data-testid":"welcome-agent-setup",className:(0,h.cn)("flex w-full flex-col items-center",r),children:[(0,t.jsx)("div",{className:"mb-8 flex w-full max-w-xs items-center gap-1.5",children:ew.map((e,r)=>(0,t.jsx)("div",{className:(0,h.cn)("h-[3px] flex-1 rounded-full transition-colors duration-300",r<=C?"bg-foreground/60":"bg-muted")},e))}),(0,t.jsxs)("div",{className:(0,h.cn)("flex w-full flex-col items-center transition-opacity duration-200",x&&!g?"opacity-100":"opacity-0"),children:[(0,t.jsx)("h1",{className:"text-foreground/90 text-center text-5xl font-extralight tracking-tight",children:_}),(0,t.jsx)("p",{className:"text-muted-foreground mt-3 text-center text-lg leading-relaxed font-light",children:S}),"select-agent"===l&&(0,t.jsxs)("div",{"data-testid":"gh-cli-notice",className:"mt-5 flex items-start gap-2 rounded-lg border border-amber-200 bg-amber-50 px-4 py-3 dark:border-amber-900 dark:bg-amber-950/40",children:[(0,t.jsx)(em.AlertTriangle,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-500"}),(0,t.jsxs)("p",{className:"text-sm leading-relaxed text-amber-800 dark:text-amber-300",children:[(0,t.jsx)("span",{className:"font-medium",children:"GitHub CLI (gh)"})," is required for full CI/CD self-healing capabilities."," ",(0,t.jsx)("a",{href:"https://cli.github.com/",target:"_blank",rel:"noopener noreferrer",className:"underline underline-offset-2 hover:text-amber-900 dark:hover:text-amber-200",children:"Install it here"}),"."]})]}),(0,t.jsxs)("div",{className:"mt-8 flex w-full flex-col items-center",children:["select-agent"===l&&(0,t.jsx)("div",{"data-testid":"agent-list",className:"grid w-full max-w-lg gap-3",style:{gridTemplateColumns:`repeat(${Math.min(n.length,4)}, minmax(0, 1fr))`},children:n.map(e=>{let r=(0,eb.getAgentTypeIcon)(e.agentType);return(0,t.jsxs)("button",{type:"button",disabled:p,"data-testid":`agent-option-${e.agentType}`,className:"border-border hover:bg-accent hover:border-foreground/20 flex cursor-pointer flex-col items-center gap-3 rounded-2xl border px-4 py-5 transition-all duration-150 active:scale-[0.97] disabled:opacity-50",onClick:()=>j(e.agentType),children:[(0,t.jsx)(r,{className:"text-foreground/70 h-7 w-7"}),(0,t.jsx)("span",{className:"text-sm font-medium",children:e.label})]},e.agentType)})}),"select-model"===l&&y?(0,t.jsxs)("div",{"data-testid":"model-list",className:"flex w-full max-w-lg flex-col items-center gap-4",children:[(0,t.jsxs)("button",{type:"button",disabled:p,className:"text-muted-foreground hover:text-foreground flex cursor-pointer items-center gap-1.5 self-start text-sm transition-colors",onClick:N,children:[(0,t.jsx)(eg.ChevronLeft,{className:"h-4 w-4"}),"Back"]}),(0,t.jsx)("div",{className:"grid w-full gap-3",style:{gridTemplateColumns:`repeat(${Math.min(y.models.length,3)}, minmax(0, 1fr))`},children:y.models.map(e=>{let r=(0,ey.getModelMeta)(e.id);return(0,t.jsxs)("button",{type:"button",disabled:p,"data-testid":`model-option-${e.id}`,className:"border-border hover:bg-accent hover:border-foreground/20 flex cursor-pointer flex-col items-center gap-2 rounded-2xl border px-4 py-5 text-center transition-all duration-150 active:scale-[0.97] disabled:opacity-50",onClick:()=>E(e.id),children:[(0,t.jsx)("span",{className:"text-sm font-medium",children:r.displayName||e.displayName}),(0,t.jsx)("span",{className:"text-muted-foreground text-xs leading-tight",children:r.description||e.description})]},e.id)})})]}):null]})]})]})}let ej=["cd ~/my-repo",'shep feat new "sleek dashboard"'];function eE({onRepositorySelect:e,className:r}){let[n,o]=(0,a.useState)(!1),[s,i]=(0,a.useState)(!1),[l,d]=(0,a.useState)(!1),[c,u]=(0,a.useState)(null),[p,f]=(0,a.useState)(null),[g,m]=(0,a.useState)(!1),[x,y]=(0,a.useState)(null),{reactFileManager:w}=(0,P.useFeatureFlags)();async function k(){if(!s){if(w)return void d(!0);i(!0);try{let t=await (0,ed.pickFolder)();t&&e?.(t)}catch{d(!0)}finally{i(!1)}}}(0,a.useEffect)(()=>{eh().then(e=>{u(e)})},[]),(0,a.useEffect)(()=>{c&&(ep().then(f),ef().then(y))},[c]);let j=(0,a.useCallback)(async()=>{await navigator.clipboard.writeText(ej.join("\n")),o(!0),setTimeout(()=>o(!1),2e3)},[]),E=(0,a.useCallback)(()=>{u(!0)},[]),N=(0,a.useCallback)(()=>{f(null),ep().then(f)},[]);return null===c?null:(0,t.jsxs)("div",{"data-testid":"control-center-empty-state",className:(0,h.cn)("relative flex h-full w-full flex-col items-center justify-center px-8",r),children:[c?(0,t.jsxs)("div",{className:"animate-in fade-in flex w-full max-w-md flex-col items-center duration-300",children:[(0,t.jsx)("h1",{className:"text-foreground/90 text-center text-5xl font-extralight tracking-tight",children:"Add a project"}),(0,t.jsxs)("p",{className:"text-muted-foreground mt-3 text-center text-lg leading-relaxed font-light",children:["Add your project folder to unlock feature creation.",(0,t.jsx)("br",{}),"Describe what you need — Shep handles the rest."]}),(0,t.jsxs)("div",{className:"mt-8 flex w-full flex-col gap-3",children:[(0,t.jsx)(eN,{status:p,onRetry:N}),(0,t.jsx)(eC,{label:"Git",status:x?.git??null,missingHint:"Required for all phases"}),(0,t.jsx)(eC,{label:"GitHub CLI",status:x?.gh??null,missingHint:"Required for pull requests"})]}),(0,t.jsxs)("button",{type:"button","data-testid":"empty-state-add-repository",onClick:k,disabled:s,className:"bg-foreground text-background hover:bg-foreground/90 mt-10 flex w-full cursor-pointer items-center justify-center gap-2.5 rounded-xl px-6 py-4 text-base font-medium shadow-lg transition-all duration-200 hover:shadow-xl active:scale-[0.98] disabled:cursor-wait disabled:opacity-50",children:[s?(0,t.jsx)(X.Loader2,{className:"h-5 w-5 animate-spin"}):(0,t.jsx)(b.FolderOpen,{className:"h-5 w-5"}),s?"Opening…":"Choose a Folder"]}),(0,t.jsx)("p",{className:"text-muted-foreground/60 mt-3 text-center text-sm",children:"Any folder works — git will be initialized automatically if needed."})]}):(0,t.jsx)(ek,{onComplete:E}),c?(0,t.jsxs)("div",{className:"absolute bottom-8 flex flex-col items-center",style:{animationDelay:"400ms",animationDuration:"600ms",animationFillMode:"both"},children:[(0,t.jsxs)("button",{type:"button",onClick:()=>m(!g),className:"text-muted-foreground hover:text-foreground flex cursor-pointer items-center gap-1.5 transition-colors duration-200",children:[(0,t.jsx)(v.Terminal,{className:"h-3.5 w-3.5"}),(0,t.jsx)("span",{className:"text-sm",children:"or use the CLI"}),(0,t.jsx)(ei.ChevronDown,{className:(0,h.cn)("h-3.5 w-3.5 transition-transform duration-200",g?"":"rotate-180")})]}),g?(0,t.jsx)("div",{className:"animate-in fade-in slide-in-from-top-1 mt-3 w-80 duration-200",children:(0,t.jsxs)("div",{"data-testid":"cli-code-block",className:"relative rounded-xl bg-zinc-900 px-5 py-4 font-mono text-[13px] leading-relaxed text-zinc-400",children:[(0,t.jsx)("button",{type:"button","data-testid":"cli-code-block-copy",onClick:j,className:"absolute top-3 right-3 cursor-pointer rounded-md p-1.5 text-zinc-600 transition-colors hover:bg-zinc-800 hover:text-zinc-300","aria-label":"Copy commands",children:n?(0,t.jsx)(ea.Check,{className:"h-3.5 w-3.5 text-emerald-400"}):(0,t.jsx)(en.Copy,{className:"h-3.5 w-3.5"})}),(0,t.jsx)("div",{className:"space-y-1",children:ej.map(e=>(0,t.jsxs)("div",{className:"whitespace-nowrap",children:[(0,t.jsx)("span",{className:"text-zinc-600 select-none",children:"$ "}),(0,t.jsx)("span",{className:"text-zinc-300",children:e})]},e))})]})}):null]}):null,(0,t.jsx)(ec.ReactFileManagerDialog,{open:l,onOpenChange:e=>{e||d(!1)},onSelect:function(t){t&&e?.(t),d(!1)}})]})}function eN({status:e,onRetry:r}){return e?e.installed&&e.authenticated?(0,t.jsx)(e_,{icon:(0,t.jsx)(eo.CheckCircle2,{className:"h-4 w-4 text-emerald-500"}),children:(0,t.jsxs)("span",{className:"text-sm text-emerald-600 dark:text-emerald-400",children:[e.label," ready"]})}):e.installed?(0,t.jsxs)(e_,{icon:(0,t.jsx)(es.AlertCircle,{className:"h-4 w-4 text-amber-500"}),children:[(0,t.jsxs)("span",{className:"text-sm font-medium text-amber-600 dark:text-amber-400",children:[e.label," needs authentication"]}),e.authCommand?(0,t.jsx)(eS,{command:e.authCommand}):null,(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[e.binaryName?(0,t.jsxs)("button",{type:"button","data-testid":"auth-banner-open-terminal",onClick:async()=>{try{let t="claude-code"===e.agentType?"claude-code":e.agentType;await fetch(`/api/tools/${t}/launch`,{method:"POST"})}catch{}},className:"flex items-center gap-1 text-xs font-medium text-amber-600 underline underline-offset-2 hover:text-amber-800 dark:text-amber-400",children:[(0,t.jsx)(v.Terminal,{className:"h-3 w-3"}),"Open ",e.label]}):null,(0,t.jsx)("button",{type:"button",onClick:r,className:"text-xs text-amber-600 underline underline-offset-2 hover:text-amber-800 dark:text-amber-400",children:"Re-check"})]})]}):(0,t.jsxs)(e_,{icon:(0,t.jsx)(es.AlertCircle,{className:"h-4 w-4 text-amber-500"}),children:[(0,t.jsxs)("span",{className:"text-sm font-medium text-amber-600 dark:text-amber-400",children:[e.label," not installed"]}),e.installCommand?(0,t.jsx)(eS,{command:e.installCommand}):null,(0,t.jsx)("button",{type:"button",onClick:r,className:"text-xs text-amber-600 underline underline-offset-2 hover:text-amber-800 dark:text-amber-400",children:"Re-check"})]}):(0,t.jsx)(e_,{icon:(0,t.jsx)(X.Loader2,{className:"text-muted-foreground/50 h-4 w-4 animate-spin"}),children:(0,t.jsx)("span",{className:"text-muted-foreground/50 text-sm",children:"Checking setup…"})})}function eC({label:e,status:r,missingHint:n}){return r?r.installed?(0,t.jsx)(e_,{icon:(0,t.jsx)(eo.CheckCircle2,{className:"h-4 w-4 text-emerald-500"}),children:(0,t.jsxs)("span",{className:"flex items-baseline gap-2",children:[(0,t.jsxs)("span",{className:"text-sm text-emerald-600 dark:text-emerald-400",children:[e," ready"]}),r.version?(0,t.jsxs)("span",{className:"text-muted-foreground/40 text-xs",children:["v",r.version]}):null]})}):(0,t.jsxs)(e_,{icon:(0,t.jsx)(es.AlertCircle,{className:"h-4 w-4 text-amber-500"}),children:[(0,t.jsxs)("span",{className:"text-sm font-medium text-amber-600 dark:text-amber-400",children:[e," not found"]}),(0,t.jsx)("span",{className:"text-muted-foreground/50 text-xs",children:n}),r.installCommand?(0,t.jsx)(eS,{command:r.installCommand}):null,r.installUrl?(0,t.jsxs)("a",{href:r.installUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-amber-600 underline underline-offset-2 hover:text-amber-800 dark:text-amber-400",children:["Docs ",(0,t.jsx)(el.ExternalLink,{className:"h-3 w-3"})]}):null]}):(0,t.jsx)(e_,{icon:(0,t.jsx)(X.Loader2,{className:"text-muted-foreground/50 h-4 w-4 animate-spin"}),children:(0,t.jsxs)("span",{className:"text-muted-foreground/50 text-sm",children:["Checking ",e,"…"]})})}function e_({icon:e,children:r}){return(0,t.jsxs)("div",{className:"animate-in fade-in flex items-start gap-2.5",children:[(0,t.jsx)("div",{className:"mt-0.5 shrink-0",children:e}),(0,t.jsx)("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:r})]})}function eS({command:e}){let[r,n]=(0,a.useState)(!1);return(0,t.jsxs)("button",{type:"button",onClick:async()=>{await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),2e3)},className:"group/cmd flex cursor-pointer items-center justify-between gap-2 rounded-md bg-zinc-100 py-1 pr-2 pl-2.5 text-left transition-colors hover:bg-zinc-200 dark:bg-zinc-800 dark:hover:bg-zinc-700",children:[(0,t.jsx)("code",{className:"min-w-0 truncate text-[11px] leading-relaxed text-zinc-600 dark:text-zinc-300",children:e}),r?(0,t.jsx)(ea.Check,{className:"h-3 w-3 shrink-0 text-emerald-500"}):(0,t.jsx)(en.Copy,{className:"h-3 w-3 shrink-0 text-zinc-400 opacity-0 transition-opacity group-hover/cmd:opacity-100"})]})}var eO=e.i(17840);let eR={maxZoom:1,padding:.5,duration:500};function eM({initialNodes:e,initialEdges:n}){let l,u,h,p,f,g,m=(0,o.useRouter)(),x=(0,o.usePathname)(),v=(l=(0,o.usePathname)().match(/^\/feature\/([^/]+)/),l?.[1]??null),b=(u=(0,o.usePathname)(),h=(0,o.useSearchParams)(),p=u.match(/^\/repository\/([^/]+)/),{id:p?.[1]??null,path:u.startsWith("/create")?h.get("repo"):null}),y=(0,Z.useSoundAction)("click"),{guardedNavigate:w}=(0,Q.useDrawerCloseGuard)(),{fitView:k}=(0,r.useReactFlow)(),j=(0,a.useRef)(null),{defaultViewport:E,onMoveEnd:N,resetViewport:C}=(f=(0,a.useRef)(function(){try{let e=localStorage.getItem(ee);if(null==e)return et;let t=JSON.parse(e);return!(null==t||"object"!=typeof t||Array.isArray(t))&&"number"==typeof t.x&&"number"==typeof t.y&&"number"==typeof t.zoom&&Number.isFinite(t.x)&&Number.isFinite(t.y)&&Number.isFinite(t.zoom)&&t.zoom>0?t:et}catch{return et}}()).current,g=(0,a.useRef)(null),(0,a.useEffect)(()=>()=>{null!=g.current&&clearTimeout(g.current)},[]),{defaultViewport:f,onMoveEnd:(0,a.useCallback)(e=>{null!=g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{try{localStorage.setItem(ee,JSON.stringify(e))}catch{}},500)},[]),resetViewport:(0,a.useCallback)(()=>{try{localStorage.removeItem(ee)}catch{}return et},[])}),{nodes:_,edges:S,onNodesChange:O,handleConnect:R,handleAddRepository:M,handleArchiveFeature:F,handleDeleteFeature:T,handleRetryFeature:L,handleStartFeature:A,handleStopFeature:D,handleUnarchiveFeature:I,handleDeleteRepository:$,createFeatureNode:B,showArchived:G,setShowArchived:U,setCallbacks:q}=(0,eO.useControlCenterState)(e,n),{setFeatures:H,setHasRepositories:V}=(0,Y.useSidebarFeaturesContext)(),X=(0,a.useMemo)(()=>_.filter(e=>"featureNode"===e.type),[_]),J=(0,a.useMemo)(()=>X.map(e=>{let t=e.data;return`${t.featureId}:${t.state}:${t.name}`}).sort().join(","),[X]);(0,a.useEffect)(()=>{H(X.map(e=>{let t=e.data,r=(0,Y.mapNodeStateToSidebarStatus)(t.state);return r?{featureId:t.featureId,name:t.name,status:r,...null!=t.startedAt&&{startedAt:t.startedAt},...null!=t.runtime&&{duration:t.runtime},...t.agentType&&{agentType:t.agentType},...t.modelId&&{modelId:t.modelId}}:null}).filter(Boolean))},[J,X,H]);let K=(0,a.useCallback)((e,t)=>{if("featureNode"===t.type){let r=t.data;"creating"!==r.state&&"deleting"!==r.state&&e.target.closest('[data-testid="feature-node-card"]')&&w(()=>{y.play(),m.push(`/feature/${r.featureId}`)})}},[m,y,w]),er=(0,a.useCallback)(()=>{y.play(),m.push("/create")},[m,y]),en=(0,a.useCallback)(e=>{y.play();let t=_.find(t=>t.id===e),r=t?.data?.repositoryPath;r?m.push(`/create?repo=${encodeURIComponent(r)}`):m.push("/create")},[_,m,y]),ea=(0,a.useCallback)(e=>{let t=e.startsWith("feat-")?e.slice(5):e,r=S.find(t=>t.target===e),n=r?_.find(e=>e.id===r.source):null,a=n?.data?.repositoryPath;y.play();let o=new URLSearchParams;a&&o.set("repo",a),o.set("parent",t),m.push(`/create?${o.toString()}`)},[_,S,m,y]),eo=(0,a.useCallback)(e=>{let t=_.find(t=>t.id===e);if(t?.type==="repositoryNode"){let e=t.data;e.id&&w(()=>m.push(`/repository/${e.id}`))}},[_,m,w]),es=(0,a.useCallback)(()=>{"/"!==x&&w(()=>m.push("/"))},[m,x,w]),ei=(0,a.useCallback)(e=>{setTimeout(()=>{k(eR),j.current=setTimeout(()=>{w(()=>m.push(`/create?repo=${encodeURIComponent(e)}`))},600)},0)},[k,w,m]),el=(0,a.useCallback)(e=>{let{wasEmpty:t,repoPath:r}=M(e);t&&ei(r)},[M,ei]);(0,a.useEffect)(()=>{let e=e=>{el(e.detail.path)};return window.addEventListener("shep:add-repository",e),()=>{window.removeEventListener("shep:add-repository",e),null!=j.current&&clearTimeout(j.current)}},[el]),(0,a.useEffect)(()=>{let e=e=>{let t=e.detail;if(t.parentId)return void B(`feat-${t.parentId}`,{state:"creating",featureId:t.featureId,name:t.name,description:t.description,repositoryPath:t.repositoryPath},"dependencyEdge");let r=_.find(e=>"repositoryNode"===e.type&&e.data.repositoryPath===t.repositoryPath);B(r?.id??null,{state:"running",featureId:t.featureId,name:t.name,description:t.description,repositoryPath:t.repositoryPath})};return window.addEventListener("shep:feature-created",e),()=>window.removeEventListener("shep:feature-created",e)},[_,B]),(0,a.useEffect)(()=>{let e=e=>{let{featureId:t,cleanup:r,cascadeDelete:n,closePr:a}=e.detail;T(t,r,n,a)};return window.addEventListener("shep:feature-delete-requested",e),()=>window.removeEventListener("shep:feature-delete-requested",e)},[T]),(0,a.useEffect)(()=>{let e=e=>{let{featureId:t}=e.detail;F(t)};return window.addEventListener("shep:feature-archive-requested",e),()=>window.removeEventListener("shep:feature-archive-requested",e)},[F]),(0,a.useEffect)(()=>{let e=e=>{let{featureId:t}=e.detail;I(t)};return window.addEventListener("shep:feature-unarchive-requested",e),()=>window.removeEventListener("shep:feature-unarchive-requested",e)},[I]),(0,a.useEffect)(()=>{q({onNodeAction:ea,onFeatureDelete:T,onRetryFeature:L,onStartFeature:A,onStopFeature:D,onArchiveFeature:F,onUnarchiveFeature:I,onRepositoryAdd:en,onRepositoryClick:eo,onRepositoryDelete:$})},[q,ea,F,T,L,A,D,I,en,eo,$]);let ed=(0,a.useCallback)((e,t)=>{N(t)},[N]),ec=_.some(e=>"repositoryNode"===e.type);(0,a.useEffect)(()=>{V(ec)},[ec,V]);let[eu,eh]=(0,a.useState)(ec),ep=(0,a.useRef)(null);(0,a.useEffect)(()=>(ec?(ep.current&&(clearTimeout(ep.current),ep.current=null),eh(!0)):eu&&(C(),ep.current=setTimeout(()=>{eh(!1),ep.current=null},500)),()=>{ep.current&&clearTimeout(ep.current)}),[ec,eu,C]);let ef=x.startsWith("/create"),eg=(0,a.useMemo)(()=>{let e=_.filter(e=>"repositoryNode"===e.type),t=_.some(e=>"featureNode"===e.type);return 1!==e.length||t||ef?_:_.map(e=>"repositoryNode"===e.type?{...e,data:{...e.data,pulseAdd:!0}}:e)},[_,ef]),em=(0,a.useCallback)(()=>{window.dispatchEvent(new CustomEvent("shep:pick-folder"))},[]),ex=(0,P.useFeatureFlags)(),ev=(0,a.useMemo)(()=>{let e=[{id:"new-feature",label:"New Feature",icon:(0,t.jsx)(s.Sparkles,{className:"h-4 w-4"}),onClick:()=>{y.play(),w(()=>m.push("/create"))}},{id:"add-local-repo",label:"Local Folder",icon:(0,t.jsx)(i.FolderPlus,{className:"h-4 w-4"}),onClick:em}];return ex.adoptBranch&&e.push({id:"adopt-branch",label:"Adopt Branch",icon:(0,t.jsx)(c.GitBranch,{className:"h-4 w-4"}),onClick:()=>{w(()=>m.push("/adopt"))}}),ex.githubImport&&e.push({id:"add-github-repo",label:"From GitHub",icon:(0,t.jsx)(d,{className:"h-4 w-4"}),onClick:()=>{window.dispatchEvent(new CustomEvent("shep:open-github-import"))}}),e},[y,w,m,em,ex.adoptBranch,ex.githubImport]),eb=(0,t.jsx)(W,{showArchived:G,onToggleArchived:()=>U(!G),onResetViewport:C});return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(z,{nodes:eu?eg:[],edges:eu?S:[],selectedFeatureId:v,selectedRepository:b,defaultViewport:E,onNodesChange:O,onConnect:R,onAddFeature:er,onNodeClick:K,onPaneClick:es,onMoveEnd:ed,toolbar:eb,emptyState:(0,t.jsx)(eE,{onRepositorySelect:el})}),eu?(0,t.jsx)(eP,{actions:ev}):null]})}function eP({actions:e}){let{state:r}=(0,er.useSidebar)();return(0,t.jsx)(K,{actions:e,className:"!fixed bottom-6",style:{left:"expanded"===r?"calc(var(--sidebar-width) + 32px)":"calc(var(--sidebar-width-icon) + 32px)",transition:"left 200ms ease-in-out"}})}function eF({initialNodes:e,initialEdges:a,drawer:o}){return(0,t.jsxs)("div",{"data-testid":"control-center",className:"h-full w-full",children:[(0,t.jsx)(n.SessionsProvider,{children:(0,t.jsx)(r.ReactFlowProvider,{children:(0,t.jsx)(eM,{initialNodes:e,initialEdges:a})})}),(0,t.jsx)("div",{children:o},"drawer")]})}e.s(["ControlCenter",()=>eF],48246)}]);
@@ -1,5 +0,0 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,36986,e=>{"use strict";var t=e.i(20314),s=e.i(79054),a=e.i(31406),r=e.i(60112),n=e.i(83428),l=e.i(67669),i=e.i(24042),o=e.i(6910),d=e.i(33548),c=e.i(23925),u=e.i(8986),m=e.i(30702),x=e.i(37260),p=e.i(83299),h=e.i(21023);let f=(0,h.createServerReference)("604e68cfdc8c247175745d288173dd518d7bdf6f4a",h.callServer,void 0,h.findSourceMapURL,"approveFeature");var g=e.i(50294),j=e.i(2895);let b=(0,h.createServerReference)("707838e632f96a7ffb17caa7c248fc9809f98a91c6",h.callServer,void 0,h.findSourceMapURL,"rejectFeature"),v=(0,h.createServerReference)("401c5269236f5a3f61666133048eb1615d03ccfee8",h.callServer,void 0,h.findSourceMapURL,"getFeatureArtifact"),N=(0,h.createServerReference)("408a26e947dff59cca317e0d7469b528e94dfa8ab5",h.callServer,void 0,h.findSourceMapURL,"getResearchArtifact"),y=(0,h.createServerReference)("40b8c4a117b3fb4c733730ef4713b981cb92a0b124",h.callServer,void 0,h.findSourceMapURL,"getMergeReviewData");var w=e.i(75921),k=e.i(8361),C=e.i(30153),S=e.i(8537),M=e.i(39443);e.i(1650);var R=e.i(11495);e.i(99348);var T=e.i(5259),I=e.i(35364),A=e.i(2828);e.i(31566);var P=e.i(65104);e.i(81803);var $=e.i(72714),E=e.i(38573),L=e.i(19933),z=e.i(99105),D=e.i(51251),F=e.i(70646);function q({actions:e,repositoryPath:a,worktreePath:r,showSpecs:l}){let[i,o]=(0,s.useState)(!1),m=e.ideLoading||e.shellLoading||e.folderLoading||e.specsLoading,x=e.ideError??e.shellError??e.folderError??e.specsError;return(0,t.jsxs)(F.DropdownMenu,{modal:!1,children:[(0,t.jsx)(F.DropdownMenuTrigger,{asChild:!0,children:(0,t.jsxs)(I.Button,{variant:"outline",size:"sm",className:"gap-1.5",disabled:m,children:[m?(0,t.jsx)(n.Loader2,{className:"size-4 animate-spin"}):x?(0,t.jsx)(D.CircleAlert,{className:"text-destructive size-4"}):(0,t.jsx)(L.FolderOpen,{className:"size-4"}),"Open",(0,t.jsx)(z.ChevronDown,{className:"size-3 opacity-60"})]})}),(0,t.jsxs)(F.DropdownMenuContent,{align:"start",className:"w-48",children:[(0,t.jsx)(F.DropdownMenuLabel,{children:"Open in"}),(0,t.jsxs)(F.DropdownMenuItem,{onClick:e.openInIde,disabled:e.ideLoading,className:"gap-2",children:[e.ideLoading?(0,t.jsx)(n.Loader2,{className:"size-4 animate-spin"}):e.ideError?(0,t.jsx)(D.CircleAlert,{className:"text-destructive size-4"}):(0,t.jsx)(u.Code2,{className:"size-4"}),"IDE"]}),(0,t.jsxs)(F.DropdownMenuItem,{onClick:e.openInShell,disabled:e.shellLoading,className:"gap-2",children:[e.shellLoading?(0,t.jsx)(n.Loader2,{className:"size-4 animate-spin"}):e.shellError?(0,t.jsx)(D.CircleAlert,{className:"text-destructive size-4"}):(0,t.jsx)(E.Terminal,{className:"size-4"}),"Terminal"]}),(0,t.jsxs)(F.DropdownMenuItem,{onClick:e.openFolder,disabled:e.folderLoading,className:"gap-2",children:[e.folderLoading?(0,t.jsx)(n.Loader2,{className:"size-4 animate-spin"}):e.folderError?(0,t.jsx)(D.CircleAlert,{className:"text-destructive size-4"}):(0,t.jsx)(L.FolderOpen,{className:"size-4"}),"Folder"]}),(0,t.jsxs)(F.DropdownMenuItem,{onClick:e.openSpecsFolder,disabled:e.specsLoading||!l,className:"gap-2",children:[e.specsLoading?(0,t.jsx)(n.Loader2,{className:"size-4 animate-spin"}):e.specsError?(0,t.jsx)(D.CircleAlert,{className:"text-destructive size-4"}):(0,t.jsx)(L.FolderOpen,{className:"size-4"}),"Specs Folder"]}),(0,t.jsx)(F.DropdownMenuSeparator,{}),(0,t.jsxs)(F.DropdownMenuItem,{onClick:()=>{navigator.clipboard.writeText(r??a),o(!0),setTimeout(()=>o(!1),2e3)},className:"gap-2",children:[i?(0,t.jsx)(c.Check,{className:"size-4 text-green-600"}):(0,t.jsx)(d.Copy,{className:"size-4"}),i?"Copied!":"Copy path"]})]})]})}var B=e.i(79687),O=e.i(68304),U=e.i(25235);let W=(0,h.createServerReference)("40dea24dfa075697255511fa03c466c971302bfd11",h.callServer,void 0,h.findSourceMapURL,"getFeaturePhaseTimings"),H=(0,h.createServerReference)("40b2bc0c63ee457bf5900894dfe141f10e11b8989f",h.callServer,void 0,h.findSourceMapURL,"getFeaturePlan");var V=e.i(11345),G=e.i(76016),_=e.i(31777),K=e.i(81846),Q=e.i(16868),J=e.i(3645);let Z=(0,J.default)("send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);var X=e.i(58481),Y=e.i(48306);e.i(50032);var ee=e.i(86254),et=e.i(42076);let es=new Set([".png",".jpg",".jpeg",".gif",".webp",".svg",".bmp",".ico",".pdf",".doc",".docx",".xls",".xlsx",".ppt",".pptx",".txt",".md",".csv",".json",".yaml",".yml",".xml",".ts",".tsx",".js",".jsx",".py",".rb",".go",".rs",".java",".c",".cpp",".h",".hpp",".cs",".swift",".kt",".html",".css",".scss",".less",".sh",".bash",".zsh",".fish",".toml",".ini",".cfg",".conf",".env",".zip",".tar",".gz",".log"]);function ea({onReject:e,onApprove:a,approveLabel:r,approveVariant:n="default",revisionPlaceholder:l,isProcessing:i=!1,isRejecting:o=!1,children:d,chatInput:u,onChatInputChange:m}){let x="warning"===n,p=x?X.AlertTriangle:c.Check,h=x?"bg-orange-500/85":"bg-blue-500/85",[f,g]=(0,s.useState)(""),j=u??f,b=m??g,v=(0,k.useSoundAction)("approve"),N=i||o,[y,w]=(0,s.useState)([]),[C,S]=(0,s.useState)(!1),[M,R]=(0,s.useState)(null),[T,P]=(0,s.useState)(!1),[$,E]=(0,s.useState)(!1),[L,z]=(0,s.useState)(!1),D=j.trim().length>0,F=D?T||$&&L:!T,q=(0,s.useRef)(0),B=(0,s.useRef)(crypto.randomUUID()),O=(0,s.useRef)(null);(0,s.useEffect)(()=>{function e(e){("Control"===e.key||"Meta"===e.key)&&E(!0),"Shift"===e.key&&z(!0)}function t(e){("Control"===e.key||"Meta"===e.key)&&E(!1),"Shift"===e.key&&z(!1)}function s(){E(!1),z(!1)}return window.addEventListener("keydown",e),window.addEventListener("keyup",t),window.addEventListener("blur",s),()=>{window.removeEventListener("keydown",e),window.removeEventListener("keyup",t),window.removeEventListener("blur",s)}},[]);let U=(0,s.useCallback)(async e=>{for(let t of(R(null),e)){if(t.size>0xa00000)return void R(`"${t.name}" exceeds 10 MB limit`);let e=function(e){let t=e.lastIndexOf(".");return t>=0?e.slice(t).toLowerCase():""}(t.name);if(e&&!es.has(e))return void R(`File type "${e}" is not allowed`)}for(let t of e){let e=crypto.randomUUID();w(s=>[...s,{id:e,name:t.name,size:t.size,mimeType:t.type||"application/octet-stream",path:"",loading:!0}]);try{let s=new FormData;s.append("file",t),s.append("sessionId",B.current);let a=await fetch("/api/attachments/upload",{method:"POST",body:s});if(!a.ok){let t=await a.json().catch(()=>({error:"Upload failed"}));w(t=>t.filter(t=>t.id!==e)),R(t.error??"Upload failed");return}let r=await a.json();w(t=>t.some(t=>t.id!==e&&t.path===r.path)?t.filter(t=>t.id!==e):t.map(t=>t.id===e?{...r,id:e,loading:!1}:t))}catch{w(t=>t.filter(t=>t.id!==e)),R("Upload failed")}}},[]),W=(0,s.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),q.current+=1,1===q.current&&S(!0)},[]),H=(0,s.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),q.current-=1,0===q.current&&S(!1)},[]),G=(0,s.useCallback)(e=>{e.preventDefault(),e.stopPropagation()},[]),K=(0,s.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),q.current=0,S(!1);let t=Array.from(e.dataTransfer.files);t.length>0&&U(t)},[U]),J=(0,s.useCallback)(e=>{let t=e.clipboardData?.items;if(!t)return;let s=[];for(let e of Array.from(t))if("file"===e.kind){let t=e.getAsFile();t&&s.push(t)}s.length>0&&(e.preventDefault(),U(s))},[U]),ea=(0,s.useCallback)(async()=>{try{let e=await (0,et.pickFiles)();e&&w(t=>{let s=new Set(t.map(e=>e.path)),a=e.filter(e=>!s.has(e.path)).map(e=>({id:crypto.randomUUID(),name:e.name,size:e.size,mimeType:"application/octet-stream",path:e.path}));return a.length>0?[...t,...a]:t})}catch{}},[]),er=(0,s.useCallback)(e=>{w(t=>t.filter(t=>t.id!==e))},[]),en=(0,s.useCallback)((e,t)=>{w(s=>s.map(s=>s.id===e?{...s,notes:t}:s))},[]),el=(0,s.useCallback)(()=>{b(""),w([]),R(null)},[b]),ei=(0,s.useCallback)(e=>{(e.ctrlKey||e.metaKey)&&"Enter"===e.key&&(e.preventDefault(),O.current?.requestSubmit())},[]),eo="u">typeof navigator&&/Mac/i.test(navigator.userAgent)?"⌘":"Ctrl";return(0,t.jsxs)("div",{className:"border-border shrink-0 border-t",children:[d,e?(0,t.jsx)(A.TooltipProvider,{delayDuration:400,children:(0,t.jsx)("form",{ref:O,onSubmit:function(t){t.preventDefault();let s=j.trim();if(F)v.play(),a(),el();else{if(!s||!e)return;e(s,y.filter(e=>!e.loading)),el()}},className:"p-3",children:(0,t.jsx)("div",{role:"region","aria-label":"File drop zone","data-drag-over":C?"true":"false",onDragEnter:W,onDragLeave:H,onDragOver:G,onDrop:K,className:(0,_.cn)("rounded-md border-2 border-transparent transition-colors",C&&"border-primary/50 bg-primary/5"),children:(0,t.jsxs)("div",{className:"border-input focus-within:ring-ring/50 focus-within:border-ring flex flex-col overflow-hidden rounded-md border shadow-xs transition-[color,box-shadow] focus-within:ring-[3px]",children:[(0,t.jsx)(Y.Textarea,{placeholder:l??"Ask AI to revise...","aria-label":l??"Ask AI to revise...",disabled:N,value:j,onChange:e=>b(e.target.value),onKeyDown:ei,onPaste:J,rows:1,className:"max-h-[35dvh] min-h-9 flex-1 resize-none overflow-y-auto rounded-none border-0 py-2 shadow-none focus-visible:ring-0","data-testid":"drawer-chat-input"}),y.length>0&&(0,t.jsx)("div",{className:"flex flex-wrap items-center gap-1.5 px-3 py-2",children:y.map(e=>(0,t.jsx)(ee.AttachmentChip,{name:e.name,size:e.size,mimeType:e.mimeType,path:e.path,onRemove:()=>er(e.id),disabled:N,loading:e.loading,notes:e.notes,onNotesChange:t=>en(e.id,t)},e.id))}),M?(0,t.jsx)("p",{className:"text-destructive px-3 pb-2 text-xs",children:M}):null,(0,t.jsxs)("div",{className:"border-input flex items-center gap-2 border-t px-3 py-1.5",children:[(0,t.jsxs)("span",{className:"text-muted-foreground flex-1 truncate text-[11px]",children:[(0,t.jsxs)("kbd",{className:"bg-muted rounded px-1 py-0.5 font-mono text-[10px]",children:[eo,"+Enter"]})," ",D?"reject":"approve"]}),(0,t.jsxs)(A.Tooltip,{children:[(0,t.jsx)(A.TooltipTrigger,{asChild:!0,children:(0,t.jsx)("button",{type:"button",onClick:ea,disabled:N,"aria-label":"Attach files",className:"text-muted-foreground hover:text-foreground cursor-pointer rounded p-1 transition-colors",children:(0,t.jsx)(Q.PaperclipIcon,{className:"h-4 w-4"})})}),(0,t.jsx)(A.TooltipContent,{side:"top",children:"Attach files"})]}),(0,t.jsx)("div",{onMouseLeave:()=>P(!1),children:(0,t.jsxs)(A.Tooltip,{children:[(0,t.jsx)(A.TooltipTrigger,{asChild:!0,children:(0,t.jsxs)("button",{type:"submit",disabled:N,"data-testid":"drawer-action-submit",className:(0,_.cn)("relative flex h-9 min-w-[12rem] cursor-pointer items-center overflow-hidden rounded-md border pr-10 pl-4 text-sm font-medium whitespace-nowrap transition-colors","disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50",F?`${x?"border-orange-400/60":"border-blue-400/60"} text-white`:D&&$&&!L?"border-primary bg-muted ring-primary/30 shadow-sm ring-1":"border-border bg-muted/50 hover:bg-muted shadow-sm"),children:[(0,t.jsx)("div",{className:(0,_.cn)("pointer-events-none absolute inset-0 transition-transform duration-300 ease-in-out",h),style:{transform:F?"translateX(0)":"translateX(100%)"}}),(0,t.jsxs)("span",{className:(0,_.cn)("absolute inset-0 z-10 flex items-center justify-center gap-2 pr-8 transition-opacity duration-300",F?"opacity-0":"opacity-100"),children:[(0,t.jsx)(Z,{className:"h-4 w-4 shrink-0"}),"Reject"]}),(0,t.jsxs)("span",{className:(0,_.cn)("absolute inset-0 z-10 flex items-center justify-center gap-2 text-white transition-opacity duration-300",F?"opacity-100":"opacity-0"),children:[(0,t.jsx)(p,{className:"h-4 w-4 shrink-0"}),r]}),(0,t.jsx)("span",{className:(0,_.cn)(`border-input/60 absolute inset-y-0 right-0 z-20 flex w-8 cursor-pointer items-center justify-center rounded-r-[5px] border-l ${h} transition-opacity duration-300`,!D&&!T&&"pointer-events-none opacity-0"),onMouseEnter:()=>P(!0),children:(0,t.jsx)(V.ChevronLeft,{className:"h-4 w-4 text-white"})})]})}),x?null:(0,t.jsx)(A.TooltipContent,{side:"top",children:F?r:"Send revision feedback"})]})})]})]})})})}):(0,t.jsx)("div",{className:"flex items-center gap-2 px-4 pb-4",children:(0,t.jsx)(I.Button,{type:"button",className:"flex-1",disabled:N,onClick:()=>{v.play(),a()},children:r})})]})}function er({data:e,selections:a,onSelect:r,onApprove:n,onReject:l,isProcessing:i=!1,isRejecting:o=!1,showHeader:d=!1,chatInput:c,onChatInputChange:u}){let{question:m,context:x,questions:p,finalAction:h}=e,[f,g]=(0,s.useState)(0),j=(0,k.useSoundAction)("select"),b=(0,k.useSoundAction)("navigate"),v=p.length,N=f===v-1,y=p[f],w=(0,s.useMemo)(()=>Object.keys(a).length,[a]),C=(0,s.useCallback)((e,t)=>{j.play(),r(e,t),N||setTimeout(()=>g(e=>e+1),250)},[r,N,j]);return 0===v?null:(0,t.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:[(0,t.jsxs)("div",{className:"flex-1 space-y-4 overflow-y-auto p-4",children:[d?(0,t.jsxs)("div",{className:"border-border flex items-start gap-3 border-b pb-3",children:[(0,t.jsx)("div",{className:"mt-1.5 h-2 w-2 shrink-0 rounded-full bg-amber-500"}),(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsx)("h3",{className:"text-foreground mb-1.5 text-sm font-bold",children:m}),(0,t.jsx)("p",{className:"text-muted-foreground text-xs leading-relaxed",children:x})]})]}):null,(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsxs)("label",{className:"text-foreground min-w-0 flex-1 text-sm font-semibold",children:[f+1,". ",y.question]}),(0,t.jsx)("div",{className:"mt-1.5 flex shrink-0 gap-1",children:p.map((e,s)=>(0,t.jsx)("button",{type:"button","aria-label":`Go to question ${s+1}`,className:(0,_.cn)("h-1.5 rounded-full transition-all duration-200",s===f?"bg-primary w-4":"w-1.5",s!==f&&a[e.id]?"bg-primary/50":"",s===f||a[e.id]?"":"bg-muted-foreground/25"),onClick:()=>{b.play(),g(s)}},e.id))})]}),(0,t.jsx)("div",{className:"space-y-2",children:y.options.map((e,s)=>{let r=a[y.id]===e.id,n=String.fromCharCode(65+s);return(0,t.jsx)("button",{type:"button",className:(0,_.cn)("border-border w-full overflow-hidden rounded-md border px-3 py-3 text-left text-xs transition-all","hover:border-primary/70 hover:bg-primary/5 group",r&&"border-primary bg-primary/5",e.isNew&&"animate-option-highlight"),disabled:i,onClick:()=>C(y.id,e.id),children:(0,t.jsxs)("div",{className:"flex items-start gap-2",children:[(0,t.jsxs)("span",{className:"text-muted-foreground mt-0.5 font-mono text-xs",children:[n,"."]}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsx)("div",{className:"text-foreground mb-0.5 text-xs font-semibold wrap-break-word",children:e.label}),(0,t.jsx)("div",{className:"text-muted-foreground text-xs leading-snug",children:e.rationale})]}),e.recommended||e.isNew?(0,t.jsx)("div",{className:"shrink-0 pt-0.5",children:e.recommended?(0,t.jsx)(K.Badge,{className:"px-1.5 py-0 text-[10px] whitespace-nowrap",children:"AI Recommended"}):(0,t.jsx)(K.Badge,{className:"border-transparent bg-emerald-600 px-1.5 py-0 text-[10px] whitespace-nowrap text-white hover:bg-emerald-600/80",children:"New"})}):null]})},e.id)})})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between pt-2",children:[(0,t.jsxs)(I.Button,{type:"button",variant:"ghost",size:"sm",disabled:0===f||i,onClick:()=>{b.play(),g(e=>e-1)},children:[(0,t.jsx)(V.ChevronLeft,{className:"mr-1 h-4 w-4"}),"Previous"]}),N?null:(0,t.jsxs)(I.Button,{type:"button",variant:"ghost",size:"sm",disabled:i,onClick:()=>{b.play(),g(e=>e+1)},children:[a[y.id]?"Next":"Skip",(0,t.jsx)(G.ChevronRight,{className:"ml-1 h-4 w-4"})]})]})]}),(0,t.jsx)(ea,{onReject:l,onApprove:()=>n(h.id),approveLabel:h.label,revisionPlaceholder:"Ask AI to refine requirements...",isProcessing:i,isRejecting:o,chatInput:c,onChatInputChange:u,children:(0,t.jsx)("div",{className:(0,_.cn)("bg-muted h-1.5 overflow-hidden",w>0&&w<v||i?"opacity-100":"opacity-0","transition-opacity duration-200"),"data-testid":"progress-bar-container",children:i?(0,t.jsx)("div",{className:"bg-primary animate-indeterminate-progress h-full w-1/3"}):(0,t.jsx)("div",{className:"bg-primary h-full transition-all duration-300",style:{width:`${v>0?w/v*100:0}%`},"data-testid":"progress-bar"})})})]})}var en=e.i(427);let el=(0,J.default)("git-compare-arrows",[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M12 6h5a2 2 0 0 1 2 2v7",key:"1yj91y"}],["path",{d:"m15 9-3-3 3-3",key:"1lwv8l"}],["circle",{cx:"19",cy:"18",r:"3",key:"1qljk2"}],["path",{d:"M12 18H7a2 2 0 0 1-2-2V9",key:"16sdep"}],["path",{d:"m9 15 3 3-3 3",key:"1m3kbl"}]]),ei=(0,J.default)("layers",[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]]),eo={p:({children:e})=>(0,t.jsx)("p",{className:"text-muted-foreground mb-2 text-xs leading-relaxed last:mb-0",children:e}),strong:({children:e})=>(0,t.jsx)("strong",{className:"text-foreground font-semibold",children:e}),em:({children:e})=>(0,t.jsx)("em",{className:"italic",children:e}),code:({children:e,className:s})=>s?(0,t.jsx)("code",{className:`${s} text-[11px]`,children:e}):(0,t.jsx)("code",{className:"bg-muted text-foreground rounded-md px-1.5 py-0.5 font-mono text-[11px]",children:e}),pre:({children:e})=>(0,t.jsx)("pre",{className:"bg-muted my-2 overflow-x-auto rounded-lg border p-3",children:e}),ul:({children:e})=>(0,t.jsx)("ul",{className:"text-muted-foreground mb-2 list-disc space-y-1 pl-4 text-xs",children:e}),ol:({children:e})=>(0,t.jsx)("ol",{className:"text-muted-foreground mb-2 list-decimal space-y-1 pl-4 text-xs",children:e}),li:({children:e})=>(0,t.jsx)("li",{className:"leading-relaxed",children:e}),a:({children:e,href:s})=>(0,t.jsx)("a",{href:s,className:"text-primary underline underline-offset-2",target:"_blank",rel:"noopener noreferrer",children:e})};function ed({decision:e,index:a}){let[r,n]=(0,s.useState)(!1),l=(0,k.useSoundAction)("expand"),i=(0,k.useSoundAction)("collapse");return(0,t.jsxs)("div",{className:"border-border rounded-lg border",children:[(0,t.jsxs)("div",{className:"space-y-3 px-4 py-3",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,t.jsxs)("div",{className:"flex items-start gap-2.5",children:[(0,t.jsx)("span",{className:"bg-primary text-primary-foreground flex h-6 w-6 shrink-0 items-center justify-center rounded-full text-xs font-bold",children:a+1}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("h3",{className:"text-foreground text-sm leading-tight font-semibold",children:e.title}),(0,t.jsx)("p",{className:"text-muted-foreground mt-0.5 text-xs",children:e.chosen})]})]}),"decisionName"in e&&e.decisionName?(0,t.jsx)(K.Badge,{variant:"secondary",className:"bg-primary/10 text-primary shrink-0",children:e.decisionName}):null]}),e.rationale?(0,t.jsx)(en.default,{components:eo,children:e.rationale}):null]}),e.rejected.length>0?(0,t.jsxs)("div",{className:"border-border border-t",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>{r?i.play():l.play(),n(e=>!e)},className:"text-muted-foreground hover:bg-muted/50 flex w-full items-center gap-1.5 px-4 py-3 text-xs font-medium transition-colors",children:[(0,t.jsx)(G.ChevronRight,{className:`h-3.5 w-3.5 transition-transform ${r?"rotate-90":""}`}),(0,t.jsx)(ei,{className:"h-3.5 w-3.5"}),"Other Options Considered (",e.rejected.length,")"]}),r?(0,t.jsx)("div",{className:"space-y-1.5 px-4 pb-3",children:e.rejected.map(e=>(0,t.jsx)("div",{className:"bg-primary/5 rounded-md px-3 py-2",children:(0,t.jsx)("span",{className:"text-foreground text-xs",children:e})},e))}):null]}):null]})}function ec({data:e}){let{summary:s,decisions:a}=e;return 0===a.length?null:(0,t.jsxs)("div",{className:"space-y-4 p-4",children:[(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)("div",{className:"mt-1.5 h-2.5 w-2.5 shrink-0 rounded-full bg-blue-500"}),(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsx)("h2",{className:"text-foreground text-sm font-bold",children:"Technical Implementation Plan Review"}),s?(0,t.jsx)("p",{className:"text-muted-foreground mt-1 text-xs leading-relaxed",children:s}):null]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2 pt-1",children:[(0,t.jsx)(el,{className:"text-primary h-4 w-4"}),(0,t.jsx)("h3",{className:"text-foreground text-sm font-bold",children:"Technical Decisions"})]}),a.map((e,s)=>(0,t.jsx)(ed,{decision:e,index:s},e.title))]})}var eu=e.i(41698);function em({item:e,index:s}){return(0,t.jsx)("div",{className:"border-border rounded-lg border",children:(0,t.jsx)("div",{className:"space-y-2 px-4 py-3",children:(0,t.jsxs)("div",{className:"flex items-start gap-2.5",children:[(0,t.jsx)("span",{className:"bg-primary text-primary-foreground flex h-6 w-6 shrink-0 items-center justify-center rounded-full text-xs font-bold",children:s+1}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsx)("h3",{className:"text-foreground text-sm leading-tight font-semibold",children:e.question}),(0,t.jsxs)("div",{className:"mt-1 flex items-center gap-2",children:[(0,t.jsx)("p",{className:"text-muted-foreground min-w-0 truncate text-xs",children:e.selectedOption}),e.wasRecommended?(0,t.jsx)(K.Badge,{className:"shrink-0 px-1.5 py-0 text-[10px] whitespace-nowrap",children:"AI Recommended"}):null]})]})]})})})}function ex({data:e}){let{questions:s}=e;return 0===s.length?null:(0,t.jsxs)("div",{className:"space-y-4 p-4",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(eu.ClipboardList,{className:"text-primary h-4 w-4"}),(0,t.jsx)("h3",{className:"text-foreground text-sm font-bold",children:"Product Decisions"})]}),s.map((e,s)=>(0,t.jsx)(em,{item:e,index:s},e.question))]})}let ep=(0,J.default)("file-diff",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M9 10h6",key:"9gxzsh"}],["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"M9 17h6",key:"r8uit2"}]]);var eh=e.i(48923),ef=e.i(49228);let eg=(0,J.default)("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]),ej=(0,J.default)("camera",[["path",{d:"M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z",key:"18u6gg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]]);var eb=e.i(70471);let ev=(0,J.default)("monitor-play",[["path",{d:"M15.033 9.44a.647.647 0 0 1 0 1.12l-4.065 2.352a.645.645 0 0 1-.968-.56V7.648a.645.645 0 0 1 .967-.56z",key:"vbtd3f"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",key:"x3v2xh"}]]);var eN=e.i(81181),ey=e.i(35e3),ew=e.i(30090),ew=ew,ek=e.i(17406);function eC({status:e}){switch(e){case ek.CiStatus.Success:return(0,t.jsxs)(K.Badge,{className:"border-transparent bg-green-50 text-green-700 hover:bg-green-50",children:[(0,t.jsx)(ey.CheckCircle2,{className:"mr-1 h-3.5 w-3.5"}),"Passing"]});case ek.CiStatus.Pending:return(0,t.jsxs)(K.Badge,{className:"border-transparent bg-yellow-50 text-yellow-700 hover:bg-yellow-50",children:[(0,t.jsx)(n.Loader2,{className:"mr-1 h-3.5 w-3.5 animate-spin"}),"Pending"]});case ek.CiStatus.Failure:return(0,t.jsxs)(K.Badge,{className:"border-transparent bg-red-50 text-red-700 hover:bg-red-50",children:[(0,t.jsx)(ew.default,{className:"mr-1 h-3.5 w-3.5"}),"Failing"]})}}let eS=(0,J.default)("file-plus",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M9 15h6",key:"cctwl0"}],["path",{d:"M12 18v-6",key:"17g6i2"}]]),eM=(0,J.default)("file-minus",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M9 15h6",key:"cctwl0"}]]),eR=(0,J.default)("file-pen",[["path",{d:"M12.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v9.34",key:"o6klzx"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10.378 12.622a1 1 0 0 1 3 3.003L8.36 20.637a2 2 0 0 1-.854.506l-2.867.837a.5.5 0 0 1-.62-.62l.836-2.869a2 2 0 0 1 .506-.853z",key:"zhnas1"}]]),eT={added:{icon:eS,label:"A",className:"text-green-600"},modified:{icon:eR,label:"M",className:"text-amber-600"},deleted:{icon:eM,label:"D",className:"text-red-600"},renamed:{icon:eR,label:"R",className:"text-blue-600"}};function eI({status:e}){let s=eT[e],a=s.icon;return(0,t.jsx)(a,{className:(0,_.cn)("h-3.5 w-3.5 shrink-0",s.className)})}function eA({hunk:e}){return(0,t.jsxs)("div",{className:"border-border border-t first:border-t-0",children:[(0,t.jsx)("div",{className:"bg-muted/50 text-muted-foreground px-3 py-1 font-mono text-[10px]",children:e.header}),(0,t.jsx)("div",{className:"font-mono text-[11px] leading-[18px]",children:e.lines.map(e=>(0,t.jsxs)("div",{className:(0,_.cn)("flex","added"===e.type&&"bg-green-50 dark:bg-green-950/30","removed"===e.type&&"bg-red-50 dark:bg-red-950/30"),children:[(0,t.jsx)("span",{className:"text-muted-foreground w-10 shrink-0 px-1 text-right text-[10px] select-none",children:e.oldNumber??""}),(0,t.jsx)("span",{className:"text-muted-foreground w-10 shrink-0 px-1 text-right text-[10px] select-none",children:e.newNumber??""}),(0,t.jsx)("span",{className:(0,_.cn)("w-4 shrink-0 text-center select-none","added"===e.type&&"text-green-700 dark:text-green-400","removed"===e.type&&"text-red-700 dark:text-red-400"),children:"added"===e.type?"+":"removed"===e.type?"-":" "}),(0,t.jsx)("span",{className:"min-w-0 flex-1 pr-2 break-all whitespace-pre-wrap",children:e.content})]},`${e.type}-${e.oldNumber??""}-${e.newNumber??""}`))})]})}function eP({file:e}){let[a,r]=(0,s.useState)(!1),n=e.path.split("/").pop()??e.path,l=e.path.includes("/")?e.path.slice(0,e.path.lastIndexOf("/")):"";return(0,t.jsxs)("div",{className:"border-border border-b last:border-b-0",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>r(!a),className:"hover:bg-muted/50 flex w-full items-center gap-2 px-3 py-2 text-left",children:[(0,t.jsx)(G.ChevronRight,{className:(0,_.cn)("text-muted-foreground h-3 w-3 shrink-0 transition-transform duration-150",a&&"rotate-90")}),(0,t.jsx)(eI,{status:e.status}),(0,t.jsx)("span",{className:"text-foreground min-w-0 flex-1 truncate text-xs",children:l?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("span",{className:"text-muted-foreground",children:[l,"/"]}),n]}):n}),e.oldPath?(0,t.jsxs)("span",{className:"text-muted-foreground truncate text-[10px]",children:["← ",e.oldPath.split("/").pop()]}):null,(0,t.jsxs)("span",{className:"shrink-0 text-[10px]",children:[e.additions>0?(0,t.jsxs)("span",{className:"text-green-600",children:["+",e.additions]}):null,e.additions>0&&e.deletions>0?" ":null,e.deletions>0?(0,t.jsxs)("span",{className:"text-red-600",children:["-",e.deletions]}):null]})]}),a&&e.hunks.length>0?(0,t.jsx)("div",{className:"border-border overflow-x-auto border-t",children:e.hunks.map(e=>(0,t.jsx)(eA,{hunk:e},e.header))}):null]})}function e$({fileDiffs:e}){return 0===e.length?null:(0,t.jsxs)("div",{className:"border-border rounded-lg border",children:[(0,t.jsx)("div",{className:"px-4 py-3",children:(0,t.jsxs)("div",{className:"mb-2 flex items-center gap-2",children:[(0,t.jsx)(eb.FileText,{className:"text-muted-foreground h-4 w-4"}),(0,t.jsx)("span",{className:"text-foreground text-xs font-semibold",children:"Changed Files"}),(0,t.jsxs)("span",{className:"text-muted-foreground text-[10px]",children:["(",e.length,")"]})]})}),(0,t.jsx)("div",{className:"border-border border-t",children:e.map(e=>(0,t.jsx)(eP,{file:e},`${e.status}-${e.path}`))})]})}let eE={Screenshot:ej,Video:ev,TestOutput:eb.FileText,TerminalRecording:E.Terminal},eL=new Set([".png",".jpg",".jpeg",".gif",".webp",".svg",".bmp"]),ez=new Set([".mp4",".webm",".mov"]);function eD({evidence:e}){var a,r;let n,[l,i]=(0,s.useState)(!0),o=eE[e.type]??ej,d=(n=(a=e.relativePath).lastIndexOf("."))>=0?a.slice(n).toLowerCase():"",c=(r=e.relativePath,`/api/evidence?path=${encodeURIComponent(r)}`),u="Screenshot"===e.type||eL.has(d),m="Video"===e.type||ez.has(d),x="TestOutput"===e.type||"TerminalRecording"===e.type;return(0,t.jsxs)("li",{className:"border-border rounded-md border",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>i(!l),className:"flex w-full cursor-pointer items-center gap-2.5 px-3 py-2.5 text-left",children:[l?(0,t.jsx)(z.ChevronDown,{className:"text-muted-foreground h-3 w-3 shrink-0"}):(0,t.jsx)(G.ChevronRight,{className:"text-muted-foreground h-3 w-3 shrink-0"}),(0,t.jsx)(o,{className:"text-muted-foreground h-3.5 w-3.5 shrink-0"}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"text-foreground text-xs font-medium",children:e.description}),e.taskRef?(0,t.jsxs)("span",{className:"text-muted-foreground ml-1.5 text-[10px]",children:["(",e.taskRef,")"]}):null]}),(0,t.jsx)("a",{href:c,download:!0,onClick:e=>e.stopPropagation(),className:"text-muted-foreground hover:text-foreground shrink-0 rounded p-1 transition-colors","aria-label":"Download",children:(0,t.jsx)(eN.Download,{className:"h-3 w-3"})})]}),l&&c?(0,t.jsx)("div",{className:"border-border border-t px-3 py-2.5",children:u?(0,t.jsx)("img",{src:c,alt:e.description,className:"max-h-80 w-full rounded-md border object-contain",loading:"lazy"}):m?(0,t.jsx)("video",{src:c,controls:!0,className:"max-h-80 w-full rounded-md border",preload:"metadata",children:(0,t.jsx)("track",{kind:"captions"})}):x?(0,t.jsx)(eF,{url:c}):(0,t.jsx)("p",{className:"text-muted-foreground truncate font-mono text-[10px]",children:e.relativePath})}):null,null]})}function eF({url:e}){let[a,r]=(0,s.useState)(null),[n,l]=(0,s.useState)(!1);return n?a?(0,t.jsx)("pre",{className:"bg-muted/50 max-h-60 overflow-auto rounded-md p-3 font-mono text-[11px] leading-relaxed",children:a}):(0,t.jsx)("p",{className:"text-muted-foreground text-[10px]",children:"Unable to load preview"}):(fetch(e).then(e=>e.ok?e.text():Promise.reject(Error("Failed"))).then(e=>{let t=e.split("\n");r(t.length>100?`${t.slice(0,100).join("\n")}
2
- ...`:e)}).catch(()=>r(null)).finally(()=>l(!0)),(0,t.jsx)("div",{className:"bg-muted/50 h-16 animate-pulse rounded-md"}))}function eq({evidence:e}){return(0,t.jsx)("div",{className:"border-border rounded-lg border",children:(0,t.jsxs)("div",{className:"px-4 py-3",children:[(0,t.jsxs)("div",{className:"mb-3 flex items-center gap-2",children:[(0,t.jsx)(ej,{className:"text-muted-foreground h-4 w-4"}),(0,t.jsx)("span",{className:"text-foreground text-xs font-semibold",children:"Evidence"}),(0,t.jsx)(K.Badge,{variant:"secondary",className:"text-[10px]",children:e.length})]}),(0,t.jsx)("ul",{className:"space-y-2",children:e.map(e=>(0,t.jsx)(eD,{evidence:e},`${e.type}-${e.relativePath}`))})]})})}function eB({data:e,readOnly:s=!1,onApprove:a,onReject:r,isProcessing:n=!1,isRejecting:l=!1,chatInput:i,onChatInputChange:o}){let{pr:d,diffSummary:c,fileDiffs:u,branch:x,warning:p,evidence:h,hideCiStatus:f}=e,g=d?.mergeable===!1,j=g&&r?()=>r("Resolve merge conflicts",[]):a;return(0,t.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:[(0,t.jsxs)("div",{className:"flex-1 space-y-4 overflow-y-auto p-4",children:[(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)("div",{className:"mt-1.5 h-2.5 w-2.5 shrink-0 rounded-full bg-emerald-500"}),(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsx)("h2",{className:"text-foreground text-sm font-bold",children:s?"Merge History":"Merge Review"}),(0,t.jsx)("p",{className:"text-muted-foreground mt-1 text-xs leading-relaxed",children:s?"This feature was merged. Review the pull request details and evidence below.":d?"Review the pull request details and approve to merge.":"Review the changes and approve to merge."})]})]}),x?(0,t.jsx)("div",{className:"border-border rounded-lg border",children:(0,t.jsxs)("div",{className:"flex items-center gap-2 px-4 py-3",children:[(0,t.jsx)(ef.GitBranch,{className:"text-muted-foreground h-4 w-4 shrink-0"}),(0,t.jsx)(K.Badge,{variant:"secondary",className:"font-mono text-[11px]",children:x.source}),(0,t.jsx)(eg,{className:"text-muted-foreground h-3.5 w-3.5 shrink-0"}),(0,t.jsx)(K.Badge,{variant:"outline",className:"font-mono text-[11px]",children:x.target})]})}):null,d?(0,t.jsx)("div",{className:"border-border rounded-lg border",children:(0,t.jsxs)("div",{className:"space-y-3 px-4 py-3",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("a",{href:d.url,target:"_blank",rel:"noopener noreferrer",className:"text-primary flex items-center gap-1.5 text-sm font-semibold underline underline-offset-2",children:["PR #",d.number,(0,t.jsx)(m.ExternalLink,{className:"h-3.5 w-3.5"})]}),(0,t.jsx)(K.Badge,{variant:"outline",className:"text-xs",children:d.status})]}),!1===d.mergeable?(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{className:"text-muted-foreground text-xs font-medium",children:"Merge Status"}),(0,t.jsxs)(K.Badge,{className:"border-transparent bg-orange-50 text-orange-700 hover:bg-orange-50",children:[(0,t.jsx)(X.AlertTriangle,{className:"mr-1 h-3.5 w-3.5"}),"Conflicts"]})]}):null,d.ciStatus&&!0!==f?(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{className:"text-muted-foreground text-xs font-medium",children:"CI Status"}),(0,t.jsx)(eC,{status:d.ciStatus})]}):null,d.commitHash?(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{className:"text-muted-foreground text-xs font-medium",children:"Commit"}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)(eh.GitCommitHorizontal,{className:"text-muted-foreground h-3.5 w-3.5"}),(0,t.jsx)("code",{className:"bg-muted text-foreground rounded-md px-1.5 py-0.5 font-mono text-[11px]",children:d.commitHash.slice(0,7)})]})]}):null]})}):null,c?(0,t.jsx)("div",{className:"border-border rounded-lg border",children:(0,t.jsxs)("div",{className:"px-4 py-3",children:[(0,t.jsxs)("div",{className:"mb-3 flex items-center gap-2",children:[(0,t.jsx)(ep,{className:"text-muted-foreground h-4 w-4"}),(0,t.jsx)("span",{className:"text-foreground text-xs font-semibold",children:"Changes"})]}),(0,t.jsxs)("div",{className:"grid grid-cols-4 gap-3",children:[(0,t.jsxs)("div",{className:"text-center",children:[(0,t.jsx)("div",{className:"text-foreground text-sm font-bold",children:c.filesChanged}),(0,t.jsx)("div",{className:"text-muted-foreground text-[10px]",children:"files"})]}),(0,t.jsxs)("div",{className:"text-center",children:[(0,t.jsxs)("div",{className:"text-sm font-bold text-green-600",children:["+",c.additions]}),(0,t.jsx)("div",{className:"text-muted-foreground text-[10px]",children:"additions"})]}),(0,t.jsxs)("div",{className:"text-center",children:[(0,t.jsxs)("div",{className:"text-sm font-bold text-red-600",children:["-",c.deletions]}),(0,t.jsx)("div",{className:"text-muted-foreground text-[10px]",children:"deletions"})]}),(0,t.jsxs)("div",{className:"text-center",children:[(0,t.jsx)("div",{className:"text-foreground text-sm font-bold",children:c.commitCount}),(0,t.jsx)("div",{className:"text-muted-foreground text-[10px]",children:"commits"})]})]})]})}):p?(0,t.jsx)("div",{className:"border-border rounded-lg border",children:(0,t.jsxs)("div",{className:"flex items-center gap-2 px-4 py-3",children:[(0,t.jsx)(X.AlertTriangle,{className:"text-muted-foreground h-4 w-4 shrink-0"}),(0,t.jsx)("span",{className:"text-muted-foreground text-xs",children:p})]})}):null,h&&h.length>0?(0,t.jsx)(eq,{evidence:h}):null,u&&u.length>0?(0,t.jsx)(e$,{fileDiffs:u}):null]}),!s&&(0,t.jsx)(ea,{onReject:r,onApprove:j,approveLabel:g?"Resolve Conflicts":"Approve Merge",approveVariant:g?"warning":"default",revisionPlaceholder:"Ask AI to revise before merging...",isProcessing:n,isRejecting:l,chatInput:i,onChatInputChange:o})]})}let eO=(0,J.default)("file-search",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["circle",{cx:"11.5",cy:"14.5",r:"2.5",key:"1bq0ko"}],["path",{d:"M13.3 16.3 15 18",key:"2quom7"}]]);var eU=e.i(38227);let eW=(0,J.default)("shield-check",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);var eH=e.i(60253),eV=e.i(53360),eG=e.i(2287),e_=e.i(28267),eK=e.i(80436);let eQ=(0,J.default)("image-off",[["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}],["path",{d:"M10.41 10.41a2 2 0 1 1-2.83-2.83",key:"1bzlo9"}],["line",{x1:"13.5",x2:"6",y1:"13.5",y2:"21",key:"1q0aeu"}],["line",{x1:"18",x2:"21",y1:"12",y2:"15",key:"5mozeu"}],["path",{d:"M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59",key:"mmje98"}],["path",{d:"M21 15V5a2 2 0 0 0-2-2H9",key:"43el77"}]]),eJ=new Set([".png",".jpg",".jpeg",".gif",".svg",".webp",".ico",".bmp"]);function eZ(e){let t=e.lastIndexOf(".");return t>=0&&eJ.has(e.slice(t).toLowerCase())}function eX(e){let t=e.lastIndexOf(".")>=0?e.slice(e.lastIndexOf(".")):"",s=eZ(e)?`image/${t.slice(1).replace("jpg","jpeg")}`:"",a=new URLSearchParams({path:e,...s&&{mimeType:s}});return`/api/attachments/preview?${a.toString()}`}let eY=/(?:^|\s)@(\/[^\s]+)/g;function e0({text:e,attachmentPaths:s}){let a=function(e){let t=[],s=0;for(let a of e.matchAll(eY)){let r=a.index,n=r+(a[0].length-a[0].trimStart().length);n>s&&t.push({type:"text",value:e.slice(s,n)}),t.push({type:"attachment",path:a[1]}),s=r+a[0].length}return s<e.length&&t.push({type:"text",value:e.slice(s)}),t}(e),r=a.some(e=>"attachment"===e.type),n=s?.filter(Boolean)??[];return r||0!==n.length?(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[a.map(e=>{if("text"===e.type){let s=e.value.trim();return s?(0,t.jsx)("span",{className:"text-sm leading-relaxed",children:s},`text-${s.slice(0,40)}`):null}return(0,t.jsx)(e1,{path:e.path},`att-${e.path}`)}),n.map(e=>(0,t.jsx)(e1,{path:e},`extra-${e}`))]}):(0,t.jsx)("span",{className:"text-sm leading-relaxed",children:e})}function e1({path:e}){let a=e.split("/").pop()??e,[r,n]=(0,s.useState)(!1);return eZ(e)?r?(0,t.jsxs)("div",{"data-testid":"inline-attachment-image-error",className:"text-muted-foreground flex items-center gap-2 rounded-md border px-3 py-2 text-sm",children:[(0,t.jsx)(eQ,{className:"h-4 w-4 shrink-0"}),(0,t.jsx)("span",{className:"truncate",children:a})]}):(0,t.jsxs)(eG.Dialog,{children:[(0,t.jsx)(eG.DialogTrigger,{asChild:!0,children:(0,t.jsx)("img",{src:eX(e),alt:a,"data-testid":"inline-attachment-image",onError:()=>n(!0),className:"max-h-48 max-w-full cursor-pointer rounded-md border object-contain transition-opacity hover:opacity-80"})}),(0,t.jsxs)(eG.DialogContent,{className:"max-w-3xl gap-0 overflow-hidden border-0 p-0 [&>button:last-child]:!cursor-pointer [&>button:last-child]:!rounded-full [&>button:last-child]:!bg-black/70 [&>button:last-child]:!p-1.5 [&>button:last-child]:!text-white [&>button:last-child]:!opacity-100 [&>button:last-child]:!shadow-lg [&>button:last-child]:!backdrop-blur-md [&>button:last-child]:hover:!bg-black/90",children:[(0,t.jsx)(e_.VisuallyHidden.Root,{children:(0,t.jsxs)(eG.DialogTitle,{children:["Preview: ",a]})}),(0,t.jsx)("div",{className:"relative bg-black/90",children:(0,t.jsx)("img",{src:eX(e),alt:a,className:"h-auto max-h-[70vh] w-full object-contain"})}),(0,t.jsxs)("div",{className:"bg-background flex items-center gap-3 px-4 py-3",children:[(0,t.jsx)("div",{className:"flex min-w-0 flex-1 flex-col",children:(0,t.jsx)("span",{className:"truncate text-sm font-medium",children:a})}),(0,t.jsx)("a",{href:eX(e),download:a,className:"text-muted-foreground hover:text-foreground shrink-0 cursor-pointer rounded p-1.5 transition-colors","aria-label":`Download ${a}`,children:(0,t.jsx)(eK.DownloadIcon,{className:"h-4 w-4"})})]})]})]}):(0,t.jsx)("a",{href:eX(e),download:a,"data-testid":"inline-attachment-file",className:"text-primary text-sm underline underline-offset-2",children:a})}let e2=(0,e.i(94237).cva)("inline-block shrink-0",{variants:{size:{sm:"size-5",md:"size-8",lg:"size-12"}},defaultVariants:{size:"md"}}),e5=[{r:9,spline:"0.12 0 0.04 1",opacity:1},{r:8.2,spline:"0.16 0 0.08 1",opacity:.95},{r:7.4,spline:"0.20 0 0.12 1",opacity:.9},{r:6.6,spline:"0.25 0 0.16 1",opacity:.84},{r:5.8,spline:"0.30 0 0.20 1",opacity:.76},{r:5,spline:"0.36 0 0.25 1",opacity:.67},{r:4.2,spline:"0.42 0 0.31 1",opacity:.56},{r:3.4,spline:"0.48 0 0.37 1",opacity:.44},{r:2.6,spline:"0.55 0 0.44 1",opacity:.32},{r:1.8,spline:"0.62 0 0.52 1",opacity:.2},{r:1,spline:"0.70 0 0.60 1",opacity:.1}];function e3({className:e,size:s="md",duration:a=5,...r}){return(0,t.jsxs)("svg",{"data-slot":"comet-spinner",role:"status","aria-label":"Loading",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 100 100",className:(0,_.cn)(e2({size:s}),e),...r,children:[(0,t.jsx)("defs",{children:(0,t.jsxs)("filter",{id:"comet-gooey",x:"-100%",y:"-100%",width:"300%",height:"300%",colorInterpolationFilters:"sRGB",children:[(0,t.jsx)("feGaussianBlur",{in:"SourceGraphic",stdDeviation:"2.5"}),(0,t.jsx)("feColorMatrix",{mode:"matrix",values:"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 50 -30",result:"goo"})]})}),(0,t.jsxs)("g",{filter:"url(#comet-gooey)",children:[(0,t.jsx)("animateTransform",{attributeName:"transform",type:"rotate",from:"0 50 50",to:"360 50 50",dur:`${a}s`,repeatCount:"indefinite"}),e5.map(e=>(0,t.jsxs)("g",{children:[(0,t.jsx)("animateTransform",{attributeName:"transform",type:"rotate",calcMode:"spline",values:"0 50 50;360 50 50",keyTimes:"0;1",keySplines:e.spline,dur:"1s",repeatCount:"indefinite"}),(0,t.jsx)("circle",{cx:"50",cy:"18",r:e.r,fill:"currentColor",opacity:e.opacity})]},e.r)),(0,t.jsxs)("circle",{cx:"50",cy:"50",r:"4",fill:"currentColor",opacity:"0.15",children:[(0,t.jsx)("animate",{attributeName:"r",values:"3;5;3",dur:"2s",repeatCount:"indefinite"}),(0,t.jsx)("animate",{attributeName:"opacity",values:"0.1;0.25;0.1",dur:"2s",repeatCount:"indefinite"})]})]})]})}e.i(47506);var e4=e.i(2929),e6=e.i(86782),e8=e.i(29847);function e9(e){if(0===e)return"0s";let t=Math.floor(e/1e3);if(0===t)return"<1s";let s=Math.floor(t/3600),a=Math.floor(t%3600/60),r=t%60;return s>0?`${s}h ${a}m`:a>0?`${a}m ${r}s`:`${r}s`}let e7=(0,J.default)("git-merge",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 21V9a9 9 0 0 0 9 9",key:"7kw0sc"}]]);var te=e.i(59311);function tt({syncStatus:e,syncLoading:s,syncError:a,onRefreshSync:r,onRebaseOnMain:n,rebaseLoading:l,rebaseError:i}){let o=null!=e&&e.behind>0,d=e?.behind===0,c=e?.baseBranch??"main";return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(U.Separator,{}),(0,t.jsxs)("div",{"data-testid":"branch-sync-status",className:"flex flex-col gap-3 p-4",children:[(0,t.jsx)("div",{className:"text-muted-foreground text-xs font-semibold tracking-wider",children:"BRANCH SYNC"}),(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("div",{className:"flex items-center gap-2",children:s&&!e?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(e3,{size:"sm",className:"shrink-0"}),(0,t.jsx)("span",{className:"text-muted-foreground text-sm",children:"Checking..."})]}):a?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(X.AlertTriangle,{className:"h-4 w-4 shrink-0 text-red-500"}),(0,t.jsx)("span",{className:"text-sm text-red-600",children:a})]}):l?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(e3,{size:"sm",className:"shrink-0"}),(0,t.jsxs)("span",{className:"text-sm",children:["Rebasing on"," ",(0,t.jsx)("code",{className:"bg-muted rounded px-1 py-0.5 font-mono text-xs",children:c}),"..."]})]}):o?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(X.AlertTriangle,{className:"h-4 w-4 shrink-0 text-orange-500"}),(0,t.jsxs)("span",{className:"text-sm",children:[e.behind," commit",1===e.behind?"":"s"," behind"," ",(0,t.jsx)("code",{className:"bg-muted rounded px-1 py-0.5 font-mono text-xs",children:c}),e.ahead>0?(0,t.jsxs)("span",{className:"text-muted-foreground ml-1",children:["· ",e.ahead," ahead"]}):null]})]}):d?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ey.CheckCircle2,{className:"h-4 w-4 shrink-0 text-green-500"}),(0,t.jsxs)("span",{className:"text-sm",children:["Up to date with"," ",(0,t.jsx)("code",{className:"bg-muted rounded px-1 py-0.5 font-mono text-xs",children:c}),e.ahead>0?(0,t.jsxs)("span",{className:"text-muted-foreground ml-1",children:["· ",e.ahead," ahead"]}):null]})]}):null}),(e||a)&&!l?(0,t.jsx)("button",{"data-testid":"sync-refresh-button",onClick:r,disabled:s,className:"text-muted-foreground hover:text-foreground inline-flex items-center rounded p-1 transition-colors disabled:opacity-50","aria-label":"Refresh sync status",children:(0,t.jsx)(te.RefreshCw,{className:`h-3.5 w-3.5 ${s?"animate-spin":""}`})}):null]}),o&&!l?(0,t.jsx)($.ActionButton,{label:"Rebase on Main",onClick:n,loading:!1,error:!!i,icon:e7,variant:"outline",size:"sm"}):null,i?(0,t.jsx)("p",{className:"text-destructive text-xs",children:i}):null]})]})}function ts({data:e,syncStatus:s,syncLoading:a,syncError:r,onRefreshSync:n,onRebaseOnMain:l,rebaseLoading:i,rebaseError:d}){let c="maintain"===e.lifecycle;return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{"data-testid":"feature-drawer-status",className:"flex flex-col gap-3 p-4",children:[(0,t.jsx)("div",{className:"text-muted-foreground text-xs font-semibold tracking-wider",children:e4.lifecycleDisplayLabels[e.lifecycle]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(ta,{data:e}),"error"===e.state&&e.onRetry?(0,t.jsxs)("button",{"data-testid":"feature-drawer-retry-button",onClick:()=>e.onRetry(e.featureId),className:"flex shrink-0 cursor-pointer items-center gap-1.5 rounded-full bg-red-50 px-3 py-1.5 text-sm font-medium text-red-700 transition-colors hover:bg-red-100",children:[(0,t.jsx)(eU.RotateCcw,{className:"h-3.5 w-3.5"}),"Retry"]}):null,("running"===e.state||"action-required"===e.state)&&e.onStop?(0,t.jsxs)("button",{"data-testid":"feature-drawer-stop-button",onClick:()=>e.onStop(e.featureId),className:"flex shrink-0 cursor-pointer items-center gap-1.5 rounded-full bg-red-50 px-3 py-1.5 text-sm font-medium text-red-700 transition-colors hover:bg-red-100",children:[(0,t.jsx)(o.Square,{className:"h-3.5 w-3.5"}),"Stop"]}):null]}),!c&&e.progress>0?(0,t.jsxs)("div",{"data-testid":"feature-drawer-progress",className:"flex flex-col gap-1",children:[(0,t.jsxs)("div",{className:"text-muted-foreground flex items-center justify-between text-xs",children:[(0,t.jsx)("span",{children:"Progress"}),(0,t.jsxs)("span",{children:[e.progress,"%"]})]}),(0,t.jsx)("div",{className:"bg-muted h-2 w-full overflow-hidden rounded-full",children:(0,t.jsx)("div",{className:(0,_.cn)("h-full rounded-full transition-all",e4.featureNodeStateConfig[e.state].progressClass),style:{width:`${e.progress}%`}})})]}):null,c&&e.pr?(0,t.jsx)(tl,{pr:e.pr,hideCiStatus:e.hideCiStatus}):null]}),(0,t.jsx)(tr,{data:e}),!c&&e.pr?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(U.Separator,{}),(0,t.jsx)("div",{className:"p-4",children:(0,t.jsx)(tl,{pr:e.pr,hideCiStatus:e.hideCiStatus})})]}):null,(0,t.jsx)(ti,{data:e}),l&&e.branch&&n?(0,t.jsx)(tt,{syncStatus:s??null,syncLoading:a??!1,syncError:r??null,onRefreshSync:n,onRebaseOnMain:l,rebaseLoading:i??!1,rebaseError:d??null}):null,(0,t.jsx)(tc,{data:e})]})}function ta({data:e}){let s=e4.featureNodeStateConfig[e.state],a=s.icon;return(0,t.jsxs)("div",{className:(0,_.cn)("flex items-center gap-2 rounded-full px-3 py-1.5 text-sm font-medium",s.badgeBgClass,s.badgeClass),children:["running"===e.state?(0,t.jsx)(e3,{size:"sm",className:"shrink-0"}):(0,t.jsx)(a,{className:"h-4 w-4 shrink-0"}),(0,t.jsx)("span",{children:s.label})]})}function tr({data:e}){var s;let a,r,n,l,i,o=!!e.summary&&!(e.userQuery&&e.summary?.trim()===e.userQuery.trim());return e.branch||e.oneLiner||o||e.userQuery||e.createdAt?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(U.Separator,{}),(0,t.jsxs)("div",{"data-testid":"feature-drawer-info",className:"flex flex-col gap-3 p-4",children:[e.branch?(0,t.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,t.jsx)("span",{className:"text-muted-foreground text-xs font-medium",children:"Branch"}),(0,t.jsxs)("span",{className:"flex items-center gap-1.5 text-sm",children:[(0,t.jsx)(ef.GitBranch,{className:"text-muted-foreground h-3.5 w-3.5 shrink-0"}),(0,t.jsx)("code",{className:"bg-muted rounded px-1 py-0.5 font-mono text-xs",children:e.branch}),e.baseBranch?(0,t.jsxs)("span",{className:"text-muted-foreground text-xs",children:["from ",e.baseBranch]}):null]})]}):null,e.oneLiner?(0,t.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,t.jsx)("span",{className:"text-muted-foreground text-xs font-medium",children:"One-Liner"}),(0,t.jsx)("span",{className:"text-sm leading-relaxed",children:e.oneLiner})]}):null,e.userQuery?(0,t.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,t.jsx)("span",{className:"text-muted-foreground text-xs font-medium",children:"User Query"}),(0,t.jsx)(e0,{text:e.userQuery})]}):null,o?(0,t.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,t.jsx)("span",{className:"text-muted-foreground text-xs font-medium",children:"Summary"}),(0,t.jsx)("span",{className:"text-sm leading-relaxed",children:e.summary})]}):null,e.createdAt?(0,t.jsx)(tu,{label:"Created",value:(s=e.createdAt,a=Date.now(),(i=Math.floor((l=Math.floor((n=Math.floor(Math.floor((a-(r="string"==typeof s?new Date(s).getTime():s))/1e3)/60))/60))/24))>30?new Date(r).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}):i>0?`${i} day${1===i?"":"s"} ago`:l>0?`${l} hour${1===l?"":"s"} ago`:n>0?`${n} minute${1===n?"":"s"} ago`:"just now")}):null]})]}):null}let tn={[ek.PrStatus.Open]:"border-transparent bg-blue-50 text-blue-700 hover:bg-blue-50",[ek.PrStatus.Merged]:"border-transparent bg-purple-50 text-purple-700 hover:bg-purple-50",[ek.PrStatus.Closed]:"border-transparent bg-red-50 text-red-700 hover:bg-red-50"};function tl({pr:e,hideCiStatus:s}){return(0,t.jsx)("div",{"data-testid":"feature-drawer-pr",children:(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"text-primary flex items-center gap-1.5 text-sm font-semibold underline underline-offset-2",children:["PR #",e.number,(0,t.jsx)(m.ExternalLink,{className:"h-3.5 w-3.5"})]}),(0,t.jsx)(K.Badge,{className:tn[e.status],children:e.status})]}),e.ciStatus&&!0!==s?(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{className:"text-muted-foreground text-xs font-medium",children:"CI Status"}),(0,t.jsx)(eC,{status:e.ciStatus})]}):null,!1===e.mergeable?(0,t.jsxs)("div",{"data-testid":"pr-merge-conflict",className:"flex items-center justify-between",children:[(0,t.jsx)("span",{className:"text-muted-foreground text-xs font-medium",children:"Merge Status"}),(0,t.jsxs)(K.Badge,{className:"border-transparent bg-orange-50 text-orange-700 hover:bg-orange-50",children:[(0,t.jsx)(X.AlertTriangle,{className:"mr-1 h-3.5 w-3.5"}),"Conflicts"]})]}):null,e.commitHash?(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{className:"text-muted-foreground text-xs font-medium",children:"Commit"}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)(eh.GitCommitHorizontal,{className:"text-muted-foreground h-3.5 w-3.5"}),(0,t.jsx)("code",{className:"bg-muted text-foreground rounded-md px-1.5 py-0.5 font-mono text-[11px]",children:e.commitHash.slice(0,7)})]})]}):null]})})}function ti({data:e}){let a=function(e){let[t,a]=(0,s.useState)(null),r=(0,s.useRef)(null);return(0,s.useEffect)(()=>e?(a(e9(Math.max(0,Date.now()-e))),r.current=setInterval(()=>{a(e9(Math.max(0,Date.now()-e)))},1e3),()=>{r.current&&(clearInterval(r.current),r.current=null)}):void a(null),[e]),t}("running"===e.state||"action-required"===e.state?e.startedAt:void 0);return e.fastMode??e.agentType??e.runtime??a??e.blockedBy??e.errorMessage?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(U.Separator,{}),(0,t.jsxs)("div",{"data-testid":"feature-drawer-details",className:"flex flex-col gap-3 p-4",children:[e.fastMode?(0,t.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,t.jsx)("span",{className:"text-muted-foreground text-xs font-medium",children:"Mode"}),(0,t.jsxs)("span",{className:"flex items-center gap-2 text-sm",children:[(0,t.jsx)(eV.Zap,{className:"h-4 w-4 shrink-0 text-amber-500"}),"Fast Mode"]})]}):null,e.agentType?(0,t.jsx)(to,{agentType:e.agentType}):null,e.runtime?(0,t.jsx)(tu,{label:"Runtime",value:e.runtime}):null,!e.runtime&&a?(0,t.jsx)(tu,{label:"Running for",value:a}):null,e.blockedBy?(0,t.jsx)(tu,{label:"Blocked by",value:e.blockedBy}):null,e.errorMessage?(0,t.jsx)(tu,{label:"Error",value:e.errorMessage}):null]})]}):null}function to({agentType:e}){let s=(0,e6.getAgentTypeIcon)(e),a=e6.agentTypeLabels[e]??e;return(0,t.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,t.jsx)("span",{className:"text-muted-foreground text-xs font-medium",children:"Agent"}),(0,t.jsxs)("span",{className:"flex items-center gap-2 text-sm",children:[(0,t.jsx)(s,{className:"h-4 w-4 shrink-0"}),a]})]})}function td({enabled:e,label:s}){return(0,t.jsxs)("span",{className:(0,_.cn)("inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs font-medium",e?"bg-emerald-50 text-emerald-700":"bg-muted text-muted-foreground"),children:[e?(0,t.jsx)(c.Check,{className:"h-3 w-3"}):(0,t.jsx)(eH.X,{className:"h-3 w-3"}),s]})}function tc({data:e}){return null!=e.approvalGates||null!=e.push||null!=e.openPr||null!=e.ciWatchEnabled||null!=e.enableEvidence||null!=e.forkAndPr||null!=e.commitSpecs||e.modelId?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(U.Separator,{}),(0,t.jsxs)("div",{"data-testid":"feature-drawer-settings",className:"flex flex-col gap-3 p-4",children:[(0,t.jsx)("span",{className:"text-muted-foreground text-xs font-semibold tracking-wider",children:"SETTINGS"}),e.modelId?(0,t.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,t.jsx)("span",{className:"text-muted-foreground text-xs font-medium",children:"Model"}),(0,t.jsx)("span",{className:"text-sm",children:(0,e8.getModelMeta)(e.modelId).displayName||e.modelId})]}):null,e.approvalGates?(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxs)("span",{className:"text-muted-foreground flex items-center gap-1 text-xs font-medium",children:[(0,t.jsx)(eW,{className:"h-3 w-3"}),"Auto-Approve"]}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-1.5",children:[(0,t.jsx)(td,{enabled:e.approvalGates.allowPrd,label:"PRD"}),(0,t.jsx)(td,{enabled:e.approvalGates.allowPlan,label:"Plan"}),(0,t.jsx)(td,{enabled:e.approvalGates.allowMerge,label:"Merge"})]})]}):null,null!=e.enableEvidence?(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxs)("span",{className:"text-muted-foreground flex items-center gap-1 text-xs font-medium",children:[(0,t.jsx)(eO,{className:"h-3 w-3"}),"Evidence"]}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-1.5",children:[(0,t.jsx)(td,{enabled:e.enableEvidence,label:"Collect"}),null!=e.commitEvidence?(0,t.jsx)(td,{enabled:e.commitEvidence,label:"Add to PR"}):null]})]}):null,null!=e.push||null!=e.openPr||null!=e.ciWatchEnabled||null!=e.commitSpecs||null!=e.forkAndPr?(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxs)("span",{className:"text-muted-foreground flex items-center gap-1 text-xs font-medium",children:[(0,t.jsx)(ef.GitBranch,{className:"h-3 w-3"}),"Git"]}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-1.5",children:[null!=e.push?(0,t.jsx)(td,{enabled:e.push,label:"Push"}):null,null!=e.openPr?(0,t.jsx)(td,{enabled:e.openPr,label:"PR"}):null,null!=e.ciWatchEnabled?(0,t.jsx)(td,{enabled:e.ciWatchEnabled,label:"Watch"}):null,null!=e.commitSpecs?(0,t.jsx)(td,{enabled:e.commitSpecs,label:"Commit Specs"}):null,null!=e.forkAndPr?(0,t.jsx)(td,{enabled:e.forkAndPr,label:"Fork & PR"}):null]})]}):null]})]}):null}function tu({label:e,value:s}){return(0,t.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,t.jsx)("span",{className:"text-muted-foreground text-xs font-medium",children:e}),(0,t.jsx)("span",{className:"text-sm",children:s})]})}var tm=e.i(55016);let tx=(0,J.default)("dollar-sign",[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]]);var ew=ew,tp=e.i(94819),th=e.i(48109),tf=e.i(58860);let tg=(0,J.default)("arrow-down-to-line",[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]]),tj=(0,J.default)("arrow-up-from-line",[["path",{d:"m18 9-6-6-6 6",key:"kcunyi"}],["path",{d:"M12 3v14",key:"7cf3v8"}],["path",{d:"M5 21h14",key:"11awu3"}]]);function tb(e,t){if(null!=e.durationMs&&e.durationMs>0)return e.durationMs;if(!e.completedAt&&e.startedAt){let s=new Date(e.startedAt).getTime();if(!Number.isNaN(s))return Math.max(0,t-s)}return 0}function tv(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function tN(e){let t=e instanceof Date?e:new Date(String(e));return Number.isNaN(t.getTime())?"":t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function ty(e){return e>=1?`$${e.toFixed(2)}`:e>=.01?`$${e.toFixed(3)}`:`$${e.toFixed(4)}`}let tw={analyze:"Analyzing",requirements:"Requirements",research:"Researching",plan:"Planning",implement:"Implementing",rebase:"Rebasing","fast-implement":"Fast Implement",evidence:"Evidence",validate:"Validating",repair:"Repairing",merge:"Merging"},tk={"run:started":{label:"started",colorClass:"text-blue-600",bgClass:"bg-blue-50 dark:bg-blue-950/30",icon:i.Play},"run:resumed":{label:"resumed",colorClass:"text-blue-600",bgClass:"bg-blue-50 dark:bg-blue-950/30",icon:eU.RotateCcw},"run:completed":{label:"completed",colorClass:"text-emerald-600",bgClass:"bg-emerald-50 dark:bg-emerald-950/30",icon:ey.CheckCircle2},"run:failed":{label:"failed",colorClass:"text-red-600",bgClass:"bg-red-50 dark:bg-red-950/30",icon:ew.default},"run:stopped":{label:"stopped",colorClass:"text-amber-600",bgClass:"bg-amber-50 dark:bg-amber-950/30",icon:o.Square},"run:crashed":{label:"crashed",colorClass:"text-red-600",bgClass:"bg-red-50 dark:bg-red-950/30",icon:ew.default},"run:rejected":{label:"rejected",colorClass:"text-orange-600",bgClass:"bg-orange-50 dark:bg-orange-950/30",icon:tp.Ban}};function tC(e){return e.startsWith("run:")}function tS({timings:e,loading:a,error:r,rejectionFeedback:l}){let i=function(e){let[t,a]=(0,s.useState)(Date.now),r=(0,s.useRef)(null);return(0,s.useEffect)(()=>(e&&e.some(e=>!e.phase.startsWith("run:")&&!e.completedAt&&e.startedAt)&&(r.current=setInterval(()=>a(Date.now()),1e3)),()=>{r.current&&(clearInterval(r.current),r.current=null)}),[e]),t}(e);if(a)return(0,t.jsx)("div",{"data-testid":"activity-tab-loading",className:"flex items-center justify-center p-8",children:(0,t.jsx)(n.Loader2,{className:"text-muted-foreground h-6 w-6 animate-spin"})});if(r)return(0,t.jsxs)("div",{className:"flex items-center gap-2 p-4 text-base text-red-600",children:[(0,t.jsx)(B.AlertCircle,{className:"h-4 w-4 shrink-0"}),(0,t.jsx)("span",{children:r})]});if(!e||0===e.length)return(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center gap-2 p-8",children:[(0,t.jsx)(tm.Clock,{className:"text-muted-foreground h-8 w-8"}),(0,t.jsx)("p",{className:"text-muted-foreground text-base",children:"No activity recorded yet"})]});let o=e.filter(e=>!tC(e.phase)),d=Math.max(...o.map(e=>tb(e,i)),...o.map(e=>e.approvalWaitMs??0),0),c=function(e,t){if(!e.length)return[];let s=e.filter(e=>"run:rejected"===e.phase).length,a=t?.length??0,r=e;if(a>s){r=[...e];let n=e[e.length-1].agentRunId;for(let e=s;e<a;e++){let a=t[e];e>s&&r.push({agentRunId:n,phase:"run:resumed",startedAt:a.timestamp??`synthetic-resumed-${e}`}),r.push({agentRunId:n,phase:"run:rejected",startedAt:a.timestamp??`synthetic-${e}`})}}let n=[],l=[],i=0;for(let e of r)if(l.push(e),"run:rejected"===e.phase){let e=t?.[i];n.push({number:n.length+1,timings:l,rejectionMessage:e?.message,rejectionAttachments:e?.attachments}),l=[],i++}return l.length>0&&n.push({number:n.length+1,timings:l}),n}(e,l),u=c.length>1,m=o.reduce((e,t)=>e+tb(t,i),0),x=o.reduce((e,t)=>e+(t.approvalWaitMs??0),0),p=o.reduce((e,t)=>e+(t.inputTokens??0),0),h=o.reduce((e,t)=>e+(t.outputTokens??0),0),f=o.reduce((e,t)=>e+(t.costUsd??0),0);return(0,t.jsxs)("div",{className:"flex flex-col gap-3 p-4",children:[(0,t.jsx)("div",{"data-testid":"activity-timings",className:"flex flex-col gap-3",children:c.map(e=>(0,t.jsx)(tM,{iteration:e,showHeader:u,maxDurationMs:d,now:i},e.number))}),m>0?(0,t.jsx)(tA,{totalExecMs:m,totalWaitMs:x,totalInputTokens:p,totalOutputTokens:h,totalCostUsd:f}):null]})}function tM({iteration:e,showHeader:s,maxDurationMs:a,now:r}){let n=function(e){let t=[...e.timings].reverse().find(e=>tC(e.phase));if(!t)return null;switch(t.phase){case"run:rejected":return{label:"Rejected",colorClass:"text-orange-600",dotClass:"bg-orange-500"};case"run:completed":return{label:"Completed",colorClass:"text-emerald-600",dotClass:"bg-emerald-500"};case"run:failed":return{label:"Failed",colorClass:"text-red-600",dotClass:"bg-red-500"};case"run:crashed":return{label:"Crashed",colorClass:"text-red-600",dotClass:"bg-red-500"};case"run:stopped":return{label:"Stopped",colorClass:"text-amber-600",dotClass:"bg-amber-500"};default:return null}}(e);return(0,t.jsxs)("div",{"data-testid":`iteration-${e.number}`,className:"border-border/50 bg-card/50 flex flex-col overflow-hidden rounded-lg border",children:[s?(0,t.jsxs)("div",{className:"bg-muted/30 border-border/50 flex items-center justify-between border-b px-3 py-1.5",children:[(0,t.jsxs)("span",{className:"text-muted-foreground text-sm font-semibold tracking-wide",children:["Iteration ",e.number]}),n?(0,t.jsxs)("span",{className:`flex items-center gap-1 text-xs font-medium ${n.colorClass}`,children:[(0,t.jsx)("span",{className:`inline-block h-1.5 w-1.5 rounded-full ${n.dotClass}`}),n.label]}):null]}):null,(0,t.jsxs)("div",{className:"relative flex flex-col",children:[(0,t.jsx)("div",{className:"bg-border/60 absolute top-4 bottom-4 left-[21.5px] w-px"}),e.timings.map((s,n)=>{if(tC(s.phase)){let a,r="run:rejected"===s.phase,l="run:failed"===s.phase||"run:crashed"===s.phase||"run:stopped"===s.phase;if(r)a=e.rejectionMessage;else if(l){let t=[...e.timings].reverse().find(e=>!tC(e.phase)&&e.errorMessage);a=t?.errorMessage??s.errorMessage}return(0,t.jsx)(tR,{timing:s,message:a,attachments:r?e.rejectionAttachments:void 0,isFirst:0===n,isLast:n===e.timings.length-1},`${s.agentRunId}-${s.phase}-${s.startedAt}`)}return(0,t.jsx)(tT,{timing:s,maxDurationMs:a,now:r},`${s.agentRunId}-${s.phase}-${s.startedAt}`)})]})]})}function tR({timing:e,message:s,attachments:a,isFirst:r,isLast:n}){let l,i=tk[e.phase];if(!i)return null;let o=a&&a.length>0,d=i.icon;return(0,t.jsxs)("div",{className:`relative flex flex-col gap-1 px-3 ${r?"pt-2":"pt-1"} ${n?"pb-2":"pb-1"}`,children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("div",{className:`relative z-10 flex h-5 w-5 shrink-0 items-center justify-center rounded-full ${i.bgClass}`,children:(0,t.jsx)(d,{className:`h-3 w-3 ${i.colorClass}`})}),(0,t.jsx)("span",{className:`text-sm font-medium ${i.colorClass}`,children:i.label}),e.startedAt&&!("string"==typeof e.startedAt&&e.startedAt.startsWith("synthetic"))?(0,t.jsx)("span",{className:"text-muted-foreground/60 ml-auto text-xs tabular-nums",children:tN(String(e.startedAt))}):null]}),s?(l="run:failed"===e.phase||"run:crashed"===e.phase||"run:stopped"===e.phase,(0,t.jsxs)("div",{className:`ml-[26px] flex items-start gap-1.5 rounded-md px-2 py-1.5 ${l?"bg-red-50/50 dark:bg-red-950/20":"bg-orange-50/50 dark:bg-orange-950/20"}`,children:[l?(0,t.jsx)(B.AlertCircle,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-red-400"}):(0,t.jsx)(th.MessageSquare,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-orange-400"}),(0,t.jsxs)("span",{"data-testid":l?"error-message-text":"rejection-feedback-text",className:"text-muted-foreground text-xs leading-relaxed italic",children:["— ",s]})]})):null,o?(0,t.jsx)("div",{"data-testid":"rejection-feedback-attachments",className:"ml-[26px]",children:(0,t.jsx)(e0,{text:"",attachmentPaths:a})}):null]})}function tT({timing:e,maxDurationMs:a,now:r}){let n=e.phase.includes(":")?e.phase.split(":")[0]:e.phase,l=e.phase.includes(":")?e.phase.split(":")[1]:null,i=null!==l,o=l?.startsWith("phase-")??!1,u=tw[n]??n,m=o?`Phase ${l.replace("phase-","")}`:null!==l?`${u} #${l}`:u,x=tb(e,r),p=!e.completedAt&&!!e.startedAt,h=p?15:2,f=a>0?Math.max(h,x/a*100):h,g=e.completedAt?o?"bg-emerald-400":i?"bg-amber-500":"bg-emerald-500":"bg-blue-500",j=null!=e.inputTokens||null!=e.outputTokens?(e.inputTokens??0)+(e.outputTokens??0):null,[b,v]=(0,s.useState)(!1),N=(0,s.useCallback)(()=>{e.prompt&&navigator.clipboard.writeText(e.prompt).then(()=>{v(!0),setTimeout(()=>v(!1),1500)})},[e.prompt]);return(0,t.jsxs)("div",{className:`group/phase relative flex flex-col gap-0.5 px-3 py-1.5 ${i?"ml-4":""}`,children:[(0,t.jsxs)("div",{"data-testid":`timing-bar-${e.phase}`,className:"flex items-center gap-2",children:[(0,t.jsx)("div",{className:"relative z-10 flex h-5 w-5 shrink-0 items-center justify-center",children:(0,t.jsx)("div",{className:`rounded-full ${p?"h-3 w-3 animate-pulse":"h-2.5 w-2.5"} ${p?"bg-blue-500":e.completedAt?"bg-emerald-500":"bg-muted-foreground/30"}`})}),(0,t.jsx)("span",{className:`w-28 shrink-0 truncate text-sm font-medium ${i?"text-muted-foreground":"text-foreground/80"}`,children:m}),e.prompt?(0,t.jsx)("button",{type:"button",onClick:N,className:"text-muted-foreground/50 hover:text-foreground/70 -ml-1 shrink-0 opacity-0 transition-opacity group-hover/phase:opacity-100",title:"Copy prompt to clipboard",children:b?(0,t.jsx)(c.Check,{className:"h-3.5 w-3.5 text-emerald-500"}):(0,t.jsx)(d.Copy,{className:"h-3.5 w-3.5"})}):null,(0,t.jsx)("div",{className:`bg-muted relative min-w-0 flex-1 overflow-hidden rounded-full ${i?"h-1.5":"h-2"}`,children:p?(0,t.jsx)("div",{className:"absolute inset-0 rounded-full bg-blue-500/30",style:{backgroundImage:"linear-gradient(90deg, transparent 0%, rgb(59 130 246) 50%, transparent 100%)",backgroundSize:"200% 100%",animation:"shimmer 1.5s ease-in-out infinite"}}):(0,t.jsx)("div",{className:`h-full rounded-full transition-all duration-300 ${g}`,style:{width:`${Math.min(f,100)}%`}})}),(0,t.jsx)("span",{className:"text-muted-foreground w-14 shrink-0 text-right text-sm font-medium tabular-nums",children:e9(x)})]}),(0,t.jsxs)("div",{className:"ml-[28px] flex items-center gap-3 text-xs",children:[e.startedAt?(0,t.jsx)("span",{className:"text-muted-foreground/60 tabular-nums",children:tN(e.startedAt)}):null,null!=j&&j>0?(0,t.jsxs)("span",{className:"text-muted-foreground/70 inline-flex items-center gap-0.5",children:[(0,t.jsx)(eV.Zap,{className:"h-3 w-3 opacity-50"}),tv(j)]}):null,null!=e.costUsd&&e.costUsd>0?(0,t.jsxs)("span",{className:"text-muted-foreground/70 inline-flex items-center gap-0.5",children:[(0,t.jsx)(tx,{className:"h-3 w-3 opacity-50"}),ty(e.costUsd)]}):null]}),null!=e.approvalWaitMs&&e.approvalWaitMs>0?(0,t.jsx)(tI,{timing:e,maxDurationMs:a}):null]})}function tI({timing:e,maxDurationMs:s}){let a=e.approvalWaitMs??0,r=s>0?Math.max(2,a/s*100):2;return(0,t.jsxs)("div",{"data-testid":`approval-wait-${e.phase}`,className:"ml-[26px] flex items-center gap-2 rounded-md bg-amber-50/50 px-1.5 py-1 dark:bg-amber-950/20",children:[(0,t.jsx)(tf.Timer,{className:"h-3.5 w-3.5 shrink-0 text-amber-500"}),(0,t.jsx)("span",{className:"text-muted-foreground w-16 shrink-0 text-xs",children:"approval"}),(0,t.jsx)("div",{className:"bg-muted h-1.5 min-w-0 flex-1 overflow-hidden rounded-full",children:(0,t.jsx)("div",{className:"h-full rounded-full bg-amber-500",style:{width:`${Math.min(r,100)}%`}})}),(0,t.jsx)("span",{className:"text-muted-foreground w-14 shrink-0 text-right text-xs tabular-nums",children:e9(a)})]})}function tA({totalExecMs:e,totalWaitMs:s,totalInputTokens:a,totalOutputTokens:r,totalCostUsd:n}){let l=a+r;return(0,t.jsxs)("div",{"data-testid":"activity-summary",className:"border-border bg-card/30 flex flex-col gap-2 rounded-lg border p-3",children:[(0,t.jsx)("div",{className:"text-muted-foreground mb-1 text-xs font-semibold tracking-wider uppercase",children:"Summary"}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-x-4 gap-y-3",children:[(0,t.jsx)(tP,{icon:tm.Clock,label:"Execution",value:e9(e)}),(0,t.jsx)(tP,{icon:tf.Timer,label:"Wait",value:s>0?e9(s):"n/a"}),(0,t.jsx)(tP,{icon:tm.Clock,label:"Wall-clock",value:s>0?e9(e+s):e9(e)}),(0,t.jsx)(tP,{icon:tx,label:"Cost",value:n>0?ty(n):"n/a"}),(0,t.jsxs)("div",{className:"col-span-2 flex flex-col gap-0.5",children:[(0,t.jsxs)("span",{className:"text-muted-foreground flex items-center gap-1 text-xs",children:[(0,t.jsx)(eV.Zap,{className:"h-3 w-3 opacity-40"}),"Tokens"]}),l>0?(0,t.jsxs)("span",{className:"flex items-center gap-2.5 text-sm tabular-nums",children:[(0,t.jsx)("span",{children:tv(l)}),(0,t.jsxs)("span",{className:"text-muted-foreground flex items-center gap-3 text-xs",title:"Input tokens / Output tokens",children:[(0,t.jsxs)("span",{className:"flex items-center gap-0.5",children:[(0,t.jsx)(tg,{className:"h-3 w-3 text-blue-500 opacity-60"}),tv(a)]}),(0,t.jsxs)("span",{className:"flex items-center gap-0.5",children:[(0,t.jsx)(tj,{className:"h-3 w-3 text-emerald-500 opacity-60"}),tv(r)]})]})]}):(0,t.jsx)("span",{className:"text-muted-foreground/40 text-sm italic tabular-nums",children:"n/a"})]})]})]})}function tP({icon:e,label:s,value:a,className:r=""}){let n="n/a"===a;return(0,t.jsxs)("div",{className:`flex flex-col gap-0.5 ${r}`,children:[(0,t.jsxs)("span",{className:"text-muted-foreground flex items-center gap-1 text-xs",children:[(0,t.jsx)(e,{className:"h-3 w-3 opacity-40"}),s]}),(0,t.jsx)("span",{className:`text-sm tabular-nums ${n?"text-muted-foreground/40 italic":""}`,children:a})]})}var t$=e.i(7311),tE=e.i(44229);let tL=(0,J.default)("coins",[["circle",{cx:"8",cy:"8",r:"6",key:"3yglwk"}],["path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18",key:"t5s6rm"}],["path",{d:"M7 6h1v4",key:"1obek4"}],["path",{d:"m16.71 13.88.7.71-2.82 2.82",key:"1rbuyh"}]]),tz=(0,J.default)("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]),tD=(0,J.default)("file-code",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]]),tF=/^\[(\d{4}-\d{2}-\d{2}T[\d:.]+Z?)\]\s+(?:\[([^\]]+)\]\s+)?(?:\[([^\]|]+)(?:\|([^\]]+))?\]\s+)?(.*)$/,tq=/^\[(tool|text|result|tokens|raw|WORKER)\]\s*(.*)/;function tB(e){let t=e.match(tF);if(!t)return{timestamp:null,phase:null,agent:null,model:null,tag:"raw",message:e,raw:e};let[,s,a,r,n,l]=t,i=null,o=null,d=null,c=l??"";if(null!=r&&null!=a)if(a.includes("|")){let[e,t]=a.split("|");o=e,d=t??null,c=`[${r}] ${l??""}`}else i=a,o=r,d=n??null;else if(null!=a)if(a.includes("|")){let[e,t]=a.split("|");o=e,d=t??null}else i=a;let u=c.match(tq),m="info";return u&&(m=u[1].toLowerCase(),c=u[2]),{timestamp:s??null,phase:i,agent:o,model:d,tag:m,message:c.trim(),raw:e}}function tO({content:e}){let a=(0,s.useMemo)(()=>e?e.split("\n").filter(e=>e.trim().length>0).map(tB):[],[e]);return 0===a.length?null:(0,t.jsx)("div",{className:"flex flex-col",children:a.map((e,s)=>(0,t.jsx)(tU,{line:e},s))})}function tU({line:e}){switch(e.tag){case"tool":return(0,t.jsx)(tV,{line:e});case"text":return(0,t.jsx)(t_,{line:e});case"result":return(0,t.jsx)(tK,{line:e});case"tokens":return(0,t.jsx)(tQ,{line:e});case"worker":return(0,t.jsx)(tJ,{line:e});case"info":return(0,t.jsx)(tZ,{line:e});default:return(0,t.jsx)(tX,{line:e})}}function tW({value:e}){if(!e)return null;let s=e.replace(/^.*T/,"").replace("Z",""),a=s.split(":"),r=a.length>=3?`${a[1]}:${a[2].split(".")[0]}`:s;return(0,t.jsx)("span",{className:"text-muted-foreground/60 w-11 shrink-0 font-mono text-[10px]",children:r})}function tH({phase:e}){return e?(0,t.jsx)("span",{className:"bg-muted text-muted-foreground w-20 shrink-0 truncate rounded px-1.5 py-0.5 font-mono text-[10px] font-medium",title:e,children:e}):(0,t.jsx)("span",{className:"w-20 shrink-0"})}function tV({line:e}){var s;let a,{toolName:r,args:n}=-1===(a=(s=e.message).indexOf(" "))?{toolName:s,args:""}:{toolName:s.slice(0,a),args:s.slice(a+1)},l=function(e,t){try{let s=JSON.parse(t);if("Read"===e&&s.file_path||"Write"===e&&s.file_path||"Edit"===e&&s.file_path)return s.file_path;if("Glob"===e&&s.pattern||"Grep"===e&&s.pattern)return s.pattern;if("Bash"===e&&s.command)return s.command;if("Task"===e&&s.description)return s.description}catch{if(t.length>0)return t}return null}(r,n);return(0,t.jsxs)("div",{className:"hover:bg-muted/50 flex items-start gap-2 border-b border-transparent px-3 py-1.5 transition-colors",children:[(0,t.jsx)(tW,{value:e.timestamp}),(0,t.jsx)(tH,{phase:e.phase}),(0,t.jsxs)("div",{className:"flex min-w-0 flex-1 items-start gap-1.5",children:[(0,t.jsx)(tG,{toolName:r}),(0,t.jsx)("span",{className:"text-xs font-semibold text-violet-600 dark:text-violet-400",children:r}),l?(0,t.jsx)("span",{className:"text-muted-foreground min-w-0 font-mono text-xs break-all",children:l}):null]})]})}function tG({toolName:e}){let s=e.toLowerCase();return"bash"===s?(0,t.jsx)(E.Terminal,{className:"mt-0.5 h-3 w-3 shrink-0 text-violet-500"}):"read"===s||"glob"===s||"grep"===s?(0,t.jsx)(eb.FileText,{className:"mt-0.5 h-3 w-3 shrink-0 text-violet-500"}):"write"===s||"edit"===s?(0,t.jsx)(tD,{className:"mt-0.5 h-3 w-3 shrink-0 text-violet-500"}):(0,t.jsx)(E.Terminal,{className:"mt-0.5 h-3 w-3 shrink-0 text-violet-500"})}function t_({line:e}){return(0,t.jsxs)("div",{className:"hover:bg-muted/50 flex items-start gap-2 px-3 py-1.5 transition-colors",children:[(0,t.jsx)(tW,{value:e.timestamp}),(0,t.jsx)(tH,{phase:e.phase}),(0,t.jsxs)("div",{className:"flex min-w-0 flex-1 items-start gap-1.5",children:[(0,t.jsx)(th.MessageSquare,{className:"mt-0.5 h-3 w-3 shrink-0 text-blue-500"}),(0,t.jsx)("span",{className:"text-foreground/80 min-w-0 text-xs leading-relaxed",children:e.message})]})]})}function tK({line:e}){var s;let a,r,{chars:n}=(a=(s=e.message).match(/^(\d+)\s+chars/),r=s.match(/session=(\S+)/),{chars:a?parseInt(a[1],10):0,sessionId:r?r[1]:null});return(0,t.jsxs)("div",{className:"hover:bg-muted/50 flex items-start gap-2 px-3 py-1.5 transition-colors",children:[(0,t.jsx)(tW,{value:e.timestamp}),(0,t.jsx)(tH,{phase:e.phase}),(0,t.jsxs)("div",{className:"flex min-w-0 flex-1 items-start gap-1.5",children:[(0,t.jsx)(ey.CheckCircle2,{className:"mt-0.5 h-3 w-3 shrink-0 text-emerald-500"}),(0,t.jsxs)("span",{className:"text-xs font-medium text-emerald-600 dark:text-emerald-400",children:["Result: ",n.toLocaleString()," chars"]})]})]})}function tQ({line:e}){let s,{inputTokens:a,outputTokens:r}=(s=e.message.match(/^(\d+)\s+in\s*\/\s*(\d+)\s+out/))?{inputTokens:parseInt(s[1],10),outputTokens:parseInt(s[2],10)}:{inputTokens:0,outputTokens:0};return(0,t.jsxs)("div",{className:"hover:bg-muted/50 flex items-start gap-2 px-3 py-1.5 transition-colors",children:[(0,t.jsx)(tW,{value:e.timestamp}),(0,t.jsx)(tH,{phase:e.phase}),(0,t.jsxs)("div",{className:"flex min-w-0 flex-1 items-start gap-1.5",children:[(0,t.jsx)(tL,{className:"mt-0.5 h-3 w-3 shrink-0 text-amber-500"}),(0,t.jsxs)("span",{className:"text-muted-foreground text-xs",children:[(0,t.jsx)("span",{className:"text-amber-600 dark:text-amber-400",children:a.toLocaleString()})," in / ",(0,t.jsx)("span",{className:"text-amber-600 dark:text-amber-400",children:r.toLocaleString()})," out"]})]})]})}function tJ({line:e}){return(0,t.jsxs)("div",{className:"hover:bg-muted/50 flex items-start gap-2 bg-zinc-50 px-3 py-1.5 transition-colors dark:bg-zinc-900/50",children:[(0,t.jsx)(tW,{value:e.timestamp}),(0,t.jsx)(tH,{phase:e.phase}),(0,t.jsxs)("div",{className:"flex min-w-0 flex-1 items-start gap-1.5",children:[(0,t.jsx)(tz,{className:"mt-0.5 h-3 w-3 shrink-0 text-zinc-500"}),(0,t.jsx)("span",{className:"text-muted-foreground text-xs font-medium break-all",children:e.message})]})]})}function tZ({line:e}){return(0,t.jsxs)("div",{className:"hover:bg-muted/50 flex items-start gap-2 px-3 py-1.5 transition-colors",children:[(0,t.jsx)(tW,{value:e.timestamp}),(0,t.jsx)(tH,{phase:e.phase}),(0,t.jsx)("span",{className:"text-muted-foreground min-w-0 text-xs break-all",children:e.message})]})}function tX({line:e}){return(0,t.jsx)("div",{className:"px-3 py-0.5",children:(0,t.jsx)("span",{className:"text-muted-foreground/70 font-mono text-[11px] break-all whitespace-pre-wrap",children:e.raw})})}function tY({content:e,isConnected:a,error:r}){let n=(0,s.useRef)(null),[l,i]=(0,s.useState)(!0),[o,d]=(0,s.useState)("structured"),c=(0,s.useCallback)(()=>{let e=n.current;e&&i(e.scrollHeight-e.scrollTop-e.clientHeight<40)},[]),u=(0,s.useCallback)(()=>{let e=n.current;e&&(e.scrollTop=e.scrollHeight,i(!0))},[]);return((0,s.useEffect)(()=>{l&&n.current&&(n.current.scrollTop=n.current.scrollHeight)},[e,l]),r)?(0,t.jsxs)("div",{className:"flex items-center gap-2 p-4 text-sm text-red-600",children:[(0,t.jsx)(B.AlertCircle,{className:"h-4 w-4 shrink-0"}),(0,t.jsx)("span",{children:r})]}):e?(0,t.jsxs)("div",{className:"flex h-full flex-col","data-testid":"log-tab",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 border-b px-3 py-1.5",children:[(0,t.jsx)("span",{className:`h-2 w-2 rounded-full ${a?"bg-emerald-500":"bg-zinc-400"}`}),(0,t.jsx)("span",{className:"text-muted-foreground text-xs",children:a?"Live":"Disconnected"}),(0,t.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[(0,t.jsx)("button",{type:"button",onClick:()=>d("structured"),className:`rounded p-1 transition-colors ${"structured"===o?"bg-muted text-foreground":"text-muted-foreground hover:text-foreground"}`,title:"Structured view",children:(0,t.jsx)(eb.FileText,{className:"h-3.5 w-3.5"})}),(0,t.jsx)("button",{type:"button",onClick:()=>d("raw"),className:`rounded p-1 transition-colors ${"raw"===o?"bg-muted text-foreground":"text-muted-foreground hover:text-foreground"}`,title:"Raw view",children:(0,t.jsx)(tE.Code,{className:"h-3.5 w-3.5"})}),l?null:(0,t.jsxs)("button",{type:"button",onClick:u,className:"text-muted-foreground hover:text-foreground ml-1 flex items-center gap-1 text-xs",children:[(0,t.jsx)(t$.ArrowDown,{className:"h-3 w-3"}),"Jump to bottom"]})]})]}),(0,t.jsx)("div",{ref:n,onScroll:c,className:`flex-1 overflow-y-auto ${"raw"===o?"bg-zinc-950 p-3 font-mono text-xs leading-relaxed break-all whitespace-pre-wrap text-zinc-300":"bg-background"}`,children:"structured"===o?(0,t.jsx)(tO,{content:e}):e})]}):(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center gap-2 p-8",children:[(0,t.jsx)(E.Terminal,{className:"text-muted-foreground h-8 w-8"}),(0,t.jsx)("p",{className:"text-muted-foreground text-sm",children:"No log output yet"}),a?(0,t.jsx)("p",{className:"text-muted-foreground text-xs",children:"Waiting for log data..."}):null]})}let t0=(0,J.default)("list-todo",[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["rect",{x:"3",y:"4",width:"6",height:"6",rx:"1",key:"cif1o7"}]]);var t1=e.i(95812),t2=e.i(87889);let t5=(0,J.default)("circle-dashed",[["path",{d:"M10.1 2.182a10 10 0 0 1 3.8 0",key:"5ilxe3"}],["path",{d:"M13.9 21.818a10 10 0 0 1-3.8 0",key:"11zvb9"}],["path",{d:"M17.609 3.721a10 10 0 0 1 2.69 2.7",key:"1iw5b2"}],["path",{d:"M2.182 13.9a10 10 0 0 1 0-3.8",key:"c0bmvh"}],["path",{d:"M20.279 17.609a10 10 0 0 1-2.7 2.69",key:"1ruxm7"}],["path",{d:"M21.818 10.1a10 10 0 0 1 0 3.8",key:"qkgqxc"}],["path",{d:"M3.721 6.391a10 10 0 0 1 2.7-2.69",key:"1mcia2"}],["path",{d:"M6.391 20.279a10 10 0 0 1-2.69-2.7",key:"1fvljs"}]]),t3={Todo:{icon:t1.Circle,colorClass:"text-muted-foreground",borderClass:"border-border",label:"Todo"},"Work in Progress":{icon:n.Loader2,colorClass:"text-blue-600",borderClass:"border-blue-200",spinning:!0,label:"In Progress"},Done:{icon:c.Check,colorClass:"text-emerald-600",borderClass:"border-emerald-200",label:"Done"},Review:{icon:t2.Eye,colorClass:"text-amber-600",borderClass:"border-amber-200",label:"Review"}},t4={icon:t1.Circle,colorClass:"text-muted-foreground",borderClass:"border-border",label:"Unknown"};function t6({tasks:e}){return 0===e.length?(0,t.jsx)("div",{className:"flex flex-col items-center justify-center gap-2 py-4",children:(0,t.jsx)("p",{className:"text-muted-foreground text-sm",children:"No tasks defined yet"})}):(0,t.jsxs)("div",{"data-testid":"task-progress-view",className:"flex flex-col gap-3",children:[(0,t.jsx)(t8,{tasks:e}),(0,t.jsx)("div",{"data-testid":"task-progress-list",className:"flex flex-col gap-2",children:e.map((e,s)=>(0,t.jsx)(t7,{task:e,index:s},e.title||`task-${s}`))})]})}function t8({tasks:e}){let a=(0,s.useMemo)(()=>{let t=e.filter(e=>"Done"===e.state).length,s=e.filter(e=>"Work in Progress"===e.state).length,a=e.filter(e=>"Review"===e.state).length,r=e.filter(e=>"Done"!==e.state&&"Work in Progress"!==e.state&&"Review"!==e.state).length,n=e.length,l=n>0?Math.round(t/n*100):0;return{done:t,wip:s,review:a,todo:r,total:n,percent:l}},[e]);return(0,t.jsxs)("div",{"data-testid":"task-progress-summary",className:"flex flex-col gap-2",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{className:"text-muted-foreground text-xs font-medium",children:"Task Progress"}),(0,t.jsxs)("span",{className:"text-muted-foreground text-xs",children:[a.done," of ",a.total," done"]})]}),(0,t.jsx)("div",{className:"bg-muted h-2 w-full overflow-hidden rounded-full",children:(0,t.jsx)("div",{"data-testid":"task-progress-bar",className:"h-full rounded-full bg-emerald-500 transition-all",style:{width:`${a.percent}%`}})}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-3",children:[a.done>0?(0,t.jsx)(t9,{icon:c.Check,label:"Done",count:a.done,className:"text-emerald-600"}):null,a.wip>0?(0,t.jsx)(t9,{icon:n.Loader2,label:"In Progress",count:a.wip,className:"text-blue-600"}):null,a.review>0?(0,t.jsx)(t9,{icon:t2.Eye,label:"Review",count:a.review,className:"text-amber-600"}):null,a.todo>0?(0,t.jsx)(t9,{icon:t1.Circle,label:"Todo",count:a.todo,className:"text-muted-foreground"}):null]})]})}function t9({icon:e,label:s,count:a,className:r}){return(0,t.jsxs)("span",{className:(0,_.cn)("flex items-center gap-1 text-xs",r),children:[(0,t.jsx)(e,{className:"h-3 w-3"}),a," ",s]})}function t7({task:e,index:a}){let[r,n]=(0,s.useState)(!1),l=t3[e.state]??t4,i=l.icon,o=e.actionItems.length>0,d=(0,s.useCallback)(()=>{o&&n(e=>!e)},[o]);return(0,t.jsxs)("div",{"data-testid":`task-card-${a}`,className:(0,_.cn)("rounded-lg border",l.borderClass),children:[(0,t.jsxs)("button",{type:"button",onClick:d,disabled:!o,className:(0,_.cn)("flex w-full items-start gap-2 px-3 py-2.5 text-left",o&&"hover:bg-muted/50 cursor-pointer transition-colors"),children:[(0,t.jsx)(i,{className:(0,_.cn)("mt-0.5 h-4 w-4 shrink-0",l.colorClass,l.spinning&&"animate-spin")}),(0,t.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[(0,t.jsx)("span",{className:(0,_.cn)("text-sm font-medium",l.colorClass),children:e.title}),e.description?(0,t.jsx)("span",{className:"text-muted-foreground text-xs",children:e.description}):null]}),o?(0,t.jsx)(G.ChevronRight,{className:(0,_.cn)("text-muted-foreground mt-0.5 h-4 w-4 shrink-0 transition-transform",r&&"rotate-90")}):null]}),r&&o?(0,t.jsx)("div",{className:"border-t px-3 py-2.5",children:(0,t.jsx)("div",{className:"flex flex-col gap-2",children:e.actionItems.map((e,s)=>(0,t.jsx)(se,{item:e},e.name||`ai-${s}`))})}):null]})}function se({item:e}){let s=e.acceptanceCriteria.length,a=e.acceptanceCriteria.filter(e=>e.verified).length,r=s>0&&a===s;return(0,t.jsxs)("div",{"data-testid":"action-item",className:"flex flex-col gap-1.5",children:[(0,t.jsxs)("div",{className:"flex items-start gap-2",children:[r?(0,t.jsx)(ey.CheckCircle2,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-emerald-600"}):(0,t.jsx)(t5,{className:"text-muted-foreground mt-0.5 h-3.5 w-3.5 shrink-0"}),(0,t.jsxs)("div",{className:"flex min-w-0 flex-col gap-0.5",children:[(0,t.jsx)("span",{className:"text-xs font-medium",children:e.name}),e.description?(0,t.jsx)("span",{className:"text-muted-foreground text-[11px]",children:e.description}):null]}),s>0?(0,t.jsxs)("span",{className:"text-muted-foreground ml-auto shrink-0 text-[11px]",children:[a,"/",s]}):null]}),s>0?(0,t.jsx)("div",{className:"ml-5.5 flex flex-col gap-1",children:e.acceptanceCriteria.map((e,s)=>(0,t.jsx)(st,{criterion:e},e.description||`ac-${s}`))}):null]})}function st({criterion:e}){return(0,t.jsxs)("div",{"data-testid":"acceptance-criterion",className:"flex items-start gap-1.5",children:[e.verified?(0,t.jsx)(c.Check,{className:"mt-0.5 h-3 w-3 shrink-0 text-emerald-600"}):(0,t.jsx)(t1.Circle,{className:"text-muted-foreground mt-0.5 h-3 w-3 shrink-0"}),(0,t.jsx)("span",{className:(0,_.cn)("text-[11px]",e.verified?"text-muted-foreground line-through":"text-foreground"),children:e.description})]})}let ss={Requirements:"border-transparent bg-blue-50 text-blue-700 hover:bg-blue-50",ClarificationRequired:"border-transparent bg-amber-50 text-amber-700 hover:bg-amber-50",Ready:"border-transparent bg-green-50 text-green-700 hover:bg-green-50"};function sa({plan:e,loading:s,error:a}){return s?(0,t.jsx)("div",{"data-testid":"plan-tab-loading",className:"flex items-center justify-center p-8",children:(0,t.jsx)(n.Loader2,{className:"text-muted-foreground h-6 w-6 animate-spin"})}):a?(0,t.jsxs)("div",{className:"flex items-center gap-2 p-4 text-sm text-red-600",children:[(0,t.jsx)(B.AlertCircle,{className:"h-4 w-4 shrink-0"}),(0,t.jsx)("span",{children:a})]}):e?(0,t.jsxs)("div",{className:"flex flex-col gap-4 p-4",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"text-muted-foreground text-xs font-medium",children:"Plan State"}),(0,t.jsx)(K.Badge,{className:ss[e.state]??"border-transparent bg-gray-50 text-gray-700",children:e.state})]}),e.overview?(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("span",{className:"text-muted-foreground text-xs font-medium",children:"Overview"}),(0,t.jsx)("p",{className:"text-sm leading-relaxed",children:e.overview})]}):null,(0,t.jsx)(t6,{tasks:e.tasks})]}):(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center gap-2 p-8",children:[(0,t.jsx)(t0,{className:"text-muted-foreground h-8 w-8"}),(0,t.jsx)("p",{className:"text-muted-foreground text-sm",children:"No plan created yet"})]})}var sr=e.i(28112);function sn(){return{data:null,loading:!1,error:null}}let sl=[{key:"overview",label:"Overview"},{key:"activity",label:"Activity"},{key:"log",label:"Log"},{key:"plan",label:"Plan"},{key:"prd-review",label:"PRD Review"},{key:"tech-decisions",label:"Tech Decisions"},{key:"product-decisions",label:"Product"},{key:"merge-review",label:"Merge Review"},{key:"chat",label:"Chat"}],si={activity:async function(e){let t=await W(e);if("error"in t)throw Error(t.error);return{timings:t.timings,rejectionFeedback:t.rejectionFeedback}},plan:async function(e){let t=await H(e);if("error"in t)throw Error(t.error);return t.plan}};function so({featureName:e,headerContent:r,featureNode:l,featureId:i,initialTab:o,urlTab:d,prdData:c,prdSelections:u,onPrdSelect:m,onPrdApprove:x,onPrdReject:p,isPrdLoading:h,techData:f,onTechApprove:g,onTechReject:j,isTechLoading:b,productData:v,mergeData:N,onMergeApprove:y,onMergeReject:w,isMergeLoading:k,syncStatus:C,syncLoading:S,syncError:M,onRefreshSync:R,onRebaseOnMain:T,rebaseLoading:I,rebaseError:A,isRejecting:P,chatInput:$,onChatInputChange:E,sseEvents:L,interactiveAgentEnabled:z=!0}){let D=(0,a.usePathname)(),F=(0,s.useMemo)(()=>(function(e,t=!0){let s=["overview","activity"];return e.hasAgentRun&&s.push("log"),e.hasPlan&&s.push("plan"),"requirements"===e.lifecycle&&"action-required"===e.state&&s.push("prd-review"),"implementation"===e.lifecycle&&"action-required"===e.state&&s.push("tech-decisions","product-decisions"),"review"===e.lifecycle&&("action-required"===e.state||"error"===e.state)&&s.push("merge-review"),"maintain"===e.lifecycle&&e.pr&&s.push("merge-review"),t&&s.push("chat"),s})(l,z),[l,z]),q=(0,s.useMemo)(()=>sl.filter(e=>F.includes(e.key)).map(e=>"merge-review"===e.key&&"maintain"===l.lifecycle?{...e,label:"Merge History"}:e),[F,l.lifecycle]),W=(0,s.useMemo)(()=>{let e=D.match(/^(\/feature\/[^/]+)/);return e?e[1]:D},[D]),H=(0,s.useMemo)(()=>d&&F.includes(d)?d:o&&F.includes(o)?o:"overview",[]),[V,G]=(0,s.useState)(H),_=function(e){let[t,a]=(0,s.useState)(""),[r,n]=(0,s.useState)(!1),[l,i]=(0,s.useState)(null),o=(0,s.useRef)(null),d=(0,s.useCallback)(()=>{o.current&&(o.current.close(),o.current=null),n(!1)},[]);return(0,s.useEffect)(()=>{if(!e){a(""),n(!1),i(null);return}a(""),i(null);let t=new EventSource(`/api/feature-logs?featureId=${e}`);return o.current=t,t.onopen=()=>{n(!0)},t.addEventListener("initial",e=>{a(JSON.parse(e.data).content)}),t.addEventListener("log",e=>{let t=JSON.parse(e.data);a(e=>e+t.content)}),t.addEventListener("error",e=>{try{let t=JSON.parse(e.data);i(t.error)}catch{i(e.data?String(e.data):"Log stream unavailable")}}),t.onerror=()=>{n(!1)},()=>{t.close(),o.current=null}},[e,d]),{content:t,isConnected:r,error:l}}("log"===V?i:null),{tabs:K,fetchTab:Q,refreshTab:J}=function(e,t){let a=Object.keys(t),[r,n]=(0,s.useState)(()=>{let e={};for(let t of a)e[t]=sn();return e}),l=(0,s.useRef)(t);l.current=t;let i=(0,s.useRef)(e);i.current=e;let o=(0,s.useRef)(!0);(0,s.useEffect)(()=>(o.current=!0,()=>{o.current=!1}),[]);let d=(0,s.useRef)(e);(0,s.useEffect)(()=>{d.current!==e&&(d.current=e,n(e=>{let t={};for(let s of Object.keys(e))t[s]=sn();return t}))},[e]);let c=(0,s.useCallback)(async e=>{let t=l.current[e],s=i.current;if(t){o.current&&n(t=>t[e]?.data!==null?t:{...t,[e]:{...t[e],loading:!0,error:null}});try{let a=await t(s);o.current&&n(t=>({...t,[e]:{data:a,loading:!1,error:null}}))}catch(t){o.current&&n(s=>{let a=t instanceof Error?t.message:"Failed to fetch tab data",r=s[e]?.data??null;return{...s,[e]:{data:r,loading:!1,error:r?null:a}}})}}},[]),u=(0,s.useCallback)(async e=>{let t=r[e];t&&null!==t.data||t&&t.loading||await c(e)},[r,c]);return{tabs:r,fetchTab:u,refreshTab:(0,s.useCallback)(async e=>{await c(e)},[c])}}(i,si),Z=(0,s.useRef)(!1);(0,s.useEffect)(()=>{if(!Z.current)return;Z.current=!1;let e="overview"===V?W:`${W}/${V}`;e!==D&&window.history.pushState(null,"",e)},[V,W,D]);let X=(0,s.useRef)(D);(0,s.useEffect)(()=>{if(X.current===D||(X.current=D,Z.current))return;let e=D.split("/"),t=e.length>=4?e[3]:void 0,s=t&&F.includes(t)?t:"overview";s!==V&&(G(s),("activity"===s||"plan"===s)&&Q(s))},[D]);let Y=(0,s.useRef)(!1);(0,s.useEffect)(()=>{if(!Y.current&&(Y.current=!0,!d&&"overview"!==H)){let e=`${W}/${H}`;e!==D&&window.history.replaceState(null,"",e)}},[]);let ee=(0,s.useRef)(!1);(0,s.useEffect)(()=>{ee.current||(ee.current=!0,("activity"===V||"plan"===V)&&Q(V))},[V,Q]);let et=(0,s.useRef)(i);(0,s.useEffect)(()=>{et.current!==i&&(et.current=i,G("overview"))},[i]);let es=(0,s.useRef)(o);(0,s.useEffect)(()=>{if(es.current!==o&&o&&F.includes(o)){es.current=o,G(o),("activity"===o||"plan"===o)&&Q(o);let e="overview"===o?W:`${W}/${o}`;e!==window.location.pathname&&window.history.replaceState(null,"",e)}},[o,F,W,Q]),(0,s.useEffect)(()=>{F.includes(V)||(G("overview"),window.location.pathname!==W&&window.history.replaceState(null,"",W))},[F,V,W]);let ea=(0,s.useRef)(V);ea.current=V;let en=(0,s.useRef)(0);(0,s.useEffect)(()=>{if(!L||0===L.length||(en.current>L.length&&(en.current=0),L.length<=en.current))return;let e=L.slice(en.current);if(en.current=L.length,!e.some(e=>e.featureId===i))return;J("activity");let t=ea.current;"plan"===t&&J(t)},[L,i,J]);let el="running"===l.state||"creating"===l.state;(0,s.useEffect)(()=>{if(!el)return;let e=setInterval(()=>{J("activity")},5e3);return()=>clearInterval(e)},[el,J]);let ei=(0,s.useCallback)(e=>{Z.current=!0,G(e),("activity"===e||"plan"===e)&&Q(e)},[Q]);return(0,t.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",children:(0,t.jsxs)(O.Tabs,{value:V,onValueChange:ei,className:"flex min-h-0 flex-1 flex-col",children:[(0,t.jsxs)("div",{className:"shrink-0 px-4 pt-4 pb-3","data-testid":"feature-drawer-header",children:[(0,t.jsxs)("div",{className:"flex items-baseline gap-4 pr-6",children:[e?(0,t.jsx)("h2",{className:"text-foreground min-w-0 shrink truncate text-base font-semibold tracking-tight",children:e}):null,(0,t.jsx)(O.TabsList,{className:"h-auto shrink-0 gap-0.5 rounded-none border-0 bg-transparent p-0",children:q.map(e=>(0,t.jsx)(O.TabsTrigger,{value:e.key,className:"text-muted-foreground hover:text-foreground data-[state=active]:text-foreground data-[state=active]:border-primary h-auto rounded-none border-b-2 border-transparent bg-transparent px-2 py-0.5 text-[12px] font-medium shadow-none transition-colors data-[state=active]:bg-transparent data-[state=active]:shadow-none",children:e.label},e.key))})]}),r]}),(0,t.jsx)(U.Separator,{}),(0,t.jsx)(O.TabsContent,{value:"overview",className:"mt-0 flex-1 overflow-y-auto",children:(0,t.jsx)(ts,{data:l,syncStatus:C,syncLoading:S,syncError:M,onRefreshSync:R,onRebaseOnMain:T,rebaseLoading:I,rebaseError:A})}),(0,t.jsx)(O.TabsContent,{value:"activity",className:"mt-0 flex-1 overflow-y-auto",children:(0,t.jsx)(tS,{timings:K.activity.data?.timings??null,loading:K.activity.loading,error:K.activity.error,rejectionFeedback:K.activity.data?.rejectionFeedback})}),(0,t.jsx)(O.TabsContent,{value:"log",className:"mt-0 flex-1 overflow-hidden",children:(0,t.jsx)(tY,{content:_.content,isConnected:_.isConnected,error:_.error})}),(0,t.jsx)(O.TabsContent,{value:"plan",className:"mt-0 flex-1 overflow-y-auto",children:(0,t.jsx)(sa,{plan:K.plan.data,loading:K.plan.loading,error:K.plan.error})}),F.includes("prd-review")?(0,t.jsx)(O.TabsContent,{value:"prd-review",className:"mt-0 flex min-h-0 flex-1 flex-col",children:c?(0,t.jsx)(er,{data:c,selections:u??{},onSelect:m??(()=>void 0),onApprove:x??(()=>void 0),onReject:p,isProcessing:h,isRejecting:P,chatInput:$,onChatInputChange:E}):(0,t.jsx)("div",{className:"flex items-center justify-center p-8",children:(0,t.jsx)(n.Loader2,{className:"text-muted-foreground h-6 w-6 animate-spin"})})}):null,F.includes("tech-decisions")?(0,t.jsx)(O.TabsContent,{value:"tech-decisions",className:"mt-0 flex min-h-0 flex-1 flex-col",children:f?(0,t.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:[(0,t.jsx)("div",{className:"flex-1 overflow-y-auto",children:(0,t.jsx)(ec,{data:f})}),(0,t.jsx)(sd,{onApprove:g??(()=>void 0),onReject:j,isProcessing:b,isRejecting:P,chatInput:$,onChatInputChange:E})]}):(0,t.jsx)("div",{className:"flex items-center justify-center p-8",children:(0,t.jsx)(n.Loader2,{className:"text-muted-foreground h-6 w-6 animate-spin"})})}):null,F.includes("product-decisions")?(0,t.jsx)(O.TabsContent,{value:"product-decisions",className:"mt-0 flex-1 overflow-y-auto",children:null===v?(0,t.jsx)("div",{className:"flex items-center justify-center p-8",children:(0,t.jsx)(n.Loader2,{className:"text-muted-foreground h-6 w-6 animate-spin"})}):v?(0,t.jsx)(ex,{data:v}):(0,t.jsx)("p",{className:"text-muted-foreground p-4 text-center text-sm",children:"No product decisions available."})}):null,F.includes("merge-review")?(0,t.jsx)(O.TabsContent,{value:"merge-review",className:"mt-0 flex min-h-0 flex-1 flex-col",children:N?(0,t.jsx)(eB,{data:N,readOnly:"maintain"===l.lifecycle,onApprove:y??(()=>void 0),onReject:w,isProcessing:k,isRejecting:P,chatInput:$,onChatInputChange:E}):(0,t.jsx)("div",{className:"flex items-center justify-center p-8",children:k?(0,t.jsx)(n.Loader2,{className:"text-muted-foreground h-6 w-6 animate-spin"}):(0,t.jsxs)("div",{className:"text-muted-foreground flex flex-col items-center gap-2 text-sm",children:[(0,t.jsx)(B.AlertCircle,{className:"h-6 w-6"}),(0,t.jsx)("span",{children:"Merge review data unavailable"})]})})}):null,F.includes("chat")?(0,t.jsx)(O.TabsContent,{value:"chat",className:"mt-0 flex min-h-0 flex-1 flex-col overflow-hidden",children:(0,t.jsx)(sr.ChatTab,{featureId:i,worktreePath:l.worktreePath})}):null]})})}function sd({onApprove:e,onReject:s,isProcessing:a,isRejecting:r,chatInput:n,onChatInputChange:l}){return(0,t.jsx)(ea,{onReject:s,onApprove:e,approveLabel:"Approve Plan",revisionPlaceholder:"Ask AI to revise the plan...",isProcessing:a,isRejecting:r,chatInput:n,onChatInputChange:l})}var sc=e.i(64125),su=e.i(99112),sm=e.i(20608);let sx=(0,h.createServerReference)("400b67482a20837b695ad98ad9e85d1c98a19aec25",h.callServer,void 0,h.findSourceMapURL,"rebaseFeature");var sp=e.i(99045);function sh(e){return"requirements"===e.lifecycle&&"action-required"===e.state?"prd-review":"implementation"===e.lifecycle&&"action-required"===e.state?"tech-decisions":"review"===e.lifecycle&&("action-required"===e.state||"error"===e.state)?"merge-review":"overview"}function sf(e,t,a,n,l,i){let[o,d]=(0,s.useState)(!1),c=(0,s.useRef)(a),u=(0,s.useRef)(n);return c.current=a,u.current=n,(0,s.useEffect)(()=>{if(u.current(),!e)return;let s=!1;return d(!0),t(e).then(e=>{s||c.current(e)}).catch(()=>{!s&&l&&r.toast.error(l)}).finally(()=>{s||d(!1)}),()=>{s=!0}},[e,t,l,i]),o}let sg=(0,h.createServerReference)("40cca14e740beb75127b9ace131151d017cfefb180",h.callServer,void 0,h.findSourceMapURL,"getFeatureDrawerData"),sj=(0,h.createServerReference)("404515f25d0e9dc4537ab14f4a59cacdd61ba3c280",h.callServer,void 0,h.findSourceMapURL,"getBranchSyncStatus"),sb=new Map;function sv({view:e,urlTab:h,interactiveAgentEnabled:E=!0}){var L;let z,D,F,B,O,U=(0,w.useFeatureFlags)(),W=(0,a.useRouter)(),H=(0,k.useSoundAction)("reject"),[V,G]=(0,s.useState)(e);(0,s.useEffect)(()=>{G(e)},[e]);let _="feature"===V.type?V.node:null,{events:K}=(0,M.useAgentEventsContext)(),Q=(0,s.useRef)(0);(0,s.useEffect)(()=>{if(Q.current>K.length&&(Q.current=0),!_||K.length<=Q.current)return;let e=K.slice(Q.current);for(let t of(Q.current=K.length,(0,sp.resolveSseEventUpdates)(e)))t.featureId===_.featureId&&"deleting"!==_.state&&(void 0!==t.state||void 0!==t.lifecycle)&&G(e=>{if("feature"!==e.type)return e;let s={...e.node,...void 0!==t.state&&{state:t.state},...void 0!==t.lifecycle&&{lifecycle:t.lifecycle}};return{...e,node:s,initialTab:sh(s)}})},[K,_]);let J=(0,a.usePathname)().startsWith("/feature/");L=_?.featureId??null,z=(0,s.useRef)(J),D=(0,s.useRef)(!1),F=(0,s.useCallback)(async()=>{if(L&&!D.current){D.current=!0;try{let e=await sg(L);if(!e)return;G(t=>(function(e,t){if("feature"!==e.type)return e;let s={...e.node,...t},a=s.state!==e.node.state||s.lifecycle!==e.node.lifecycle;return{...e,node:s,initialTab:a?sh(s):e.initialTab}})(t,e))}catch{}finally{D.current=!1}}},[L,G]),B=(0,s.useRef)(!1),(0,s.useEffect)(()=>{!J||z.current&&B.current||(B.current=!0,F()),z.current=J},[J,F]),(0,s.useEffect)(()=>{if(!J||!L)return;let e=setInterval(()=>{F()},15e3);return()=>clearInterval(e)},[J,L,F]);let Z=(0,s.useCallback)(()=>{W.push("/")},[W]),[X,Y]=(0,s.useState)(""),[ee,et]=(0,s.useState)(null),[es,ea]=(0,s.useState)({}),[er,en]=(0,s.useState)({}),[el,ei]=(0,s.useState)(null),[eo,ed]=(0,s.useState)(void 0),[ec,eu]=(0,s.useState)(null),[em,ex]=(0,s.useState)(!1),[ep,eh]=(0,s.useState)(!1),[ef,eg]=(0,s.useState)(!1),ej=`${_?.featureId}:${_?.state}`,eb=(0,s.useRef)(ej);(0,s.useEffect)(()=>{ej!==eb.current&&(eb.current=ej,eg(!1))},[ej]);let[ev,eN]=(0,s.useState)(!1),ey=(0,s.useRef)(!1),ew="feature"===V.type?V.initialTab:void 0;(0,s.useEffect)(()=>{Y("")},[ew]);let ek=(0,s.useRef)(0),eC=(0,s.useRef)(_?.state),eS=(0,s.useRef)(_?.lifecycle);(_?.state!==eC.current||_?.lifecycle!==eS.current)&&(eC.current=_?.state,eS.current=_?.lifecycle,ek.current+=1);let eM=ek.current,eR=sf(_?.lifecycle==="requirements"&&_?.state==="action-required"?_.featureId:null,v,e=>{if(e.error)return void r.toast.error(e.error);if(e.questionnaire){et(e.questionnaire);let t={};for(let s of e.questionnaire.questions){let e=s.options.find(e=>e.recommended);e&&(t[s.id]=e.id)}ea(t),en(t)}},()=>{ea({}),en({}),et(null)},"Failed to load questionnaire",eM),eT=_?.lifecycle==="implementation"&&_?.state==="action-required"?_.featureId:null,eI=sf(eT,N,e=>{e.error?r.toast.error(e.error):e.techDecisions&&ei(e.techDecisions)},()=>ei(null),"Failed to load tech decisions",eM),eA=sf(eT,v,e=>{e.productDecisions&&ed(e.productDecisions)},()=>ed(void 0),void 0,eM),eP=sf(_?.lifecycle==="review"&&(_?.state==="action-required"||_?.state==="error")||_?.lifecycle==="maintain"&&_?.pr?_.featureId:null,y,e=>{"error"in e?r.toast.error(e.error):eu(e)},()=>eu(null),"Failed to load merge review data",eM),e$=X.trim().length>0,eE=_?.lifecycle==="requirements"&&_?.state==="action-required"&&Object.keys(er).some(e=>er[e]!==es[e]),eL=(0,s.useCallback)(()=>{Y(""),ea({...er})},[er]),{attemptClose:ez}=(0,C.useGuardedDrawerClose)({open:J,isDirty:e$||eE,onClose:Z,onReset:eL}),eD=(0,s.useCallback)(async(e,t,s=[],a)=>{if(_?.featureId){ey.current=!0,eN(!0);try{let n=s.map(e=>e.path).filter(Boolean),l=s.filter(e=>e.notes?.trim()),i=l.length>0?`${e}
3
-
4
- Image notes:
5
- ${l.map(e=>`- @${e.path}: ${e.notes.trim()}`).join("\n")}`:e,o=await b(_.featureId,i,n);if(!o.rejected)return void r.toast.error(o.error??`Failed to reject ${t.toLowerCase()}`);H.play(),Y(""),r.toast.success(`${t} rejected — agent re-iterating (iteration ${o.iteration})`),o.iterationWarning&&r.toast.warning(`Iteration ${o.iteration} — consider approving or adjusting feedback to avoid excessive iterations`),window.dispatchEvent(new CustomEvent("shep:feature-approved",{detail:{featureId:_.featureId}})),Z(),a?.()}finally{ey.current=!1,eN(!1)}}},[_,Z,H]),eF=(0,s.useCallback)((e,t)=>eD(e,"Requirements",t,()=>ea({})),[eD]),eq=(0,s.useCallback)((e,t)=>eD(e,"Plan",t),[eD]),eB=(0,s.useCallback)((e,t)=>eD(e,"Merge",t),[eD]),eO=(0,s.useCallback)(async e=>{if(!_?.featureId)return;let t=await f(_.featureId);t.approved?(Y(""),r.toast.success(`${e} approved — agent resuming`),window.dispatchEvent(new CustomEvent("shep:feature-approved",{detail:{featureId:_.featureId}})),Z()):r.toast.error(t.error??`Failed to approve ${e.toLowerCase()}`)},[_,Z]),eU=(0,s.useCallback)(async e=>{let t;if("feature"!==V.type||!_)return;if(ee){let e=[];for(let[t,s]of Object.entries(es)){let a=ee.questions.find(e=>e.id===t),r=a?.options.find(e=>e.id===s);a&&r&&e.push({questionId:a.question,selectedOption:r.label})}t={approved:!0,changedSelections:e}}let s=await f(_.featureId,t);s.approved?(Y(""),r.toast.success("Requirements approved — agent resuming"),window.dispatchEvent(new CustomEvent("shep:feature-approved",{detail:{featureId:_.featureId}})),ea({}),Z()):r.toast.error(s.error??"Failed to approve requirements")},[V,_,ee,es,Z]),eW=(0,s.useCallback)(()=>eO("Plan"),[eO]),eH=(0,s.useCallback)(()=>eO("Merge"),[eO]),eV=(0,s.useCallback)(async(e,t,s,a)=>{ex(!0),eh(!1),window.dispatchEvent(new CustomEvent("shep:feature-delete-requested",{detail:{featureId:e,cleanup:t,cascadeDelete:s,closePr:a}})),W.push("/")},[W]),eG=(0,s.useCallback)(e=>{eg(!0),window.dispatchEvent(new CustomEvent("shep:feature-archive-requested",{detail:{featureId:e}})),W.push("/")},[W]),e_=(0,s.useCallback)(e=>{eg(!0),window.dispatchEvent(new CustomEvent("shep:feature-unarchive-requested",{detail:{featureId:e}})),W.push("/")},[W]),eK=(0,s.useCallback)(async e=>{let t=await (0,g.resumeFeature)(e);t.error?r.toast.error(t.error):(r.toast.success("Feature resumed — agent restarting"),window.dispatchEvent(new CustomEvent("shep:feature-approved",{detail:{featureId:e}})),G(e=>"feature"!==e.type?e:{...e,node:{...e.node,state:"running"}}))},[]),eQ=(0,s.useCallback)(async e=>{let t=await (0,j.startFeature)(e);t.error?r.toast.error(t.error):(r.toast.success("Feature started"),G(e=>"feature"!==e.type?e:{...e,node:{...e.node,state:"running"}}))},[]),eJ=_?.repositoryPath&&_?.branch?{featureId:_.featureId,repositoryPath:_.repositoryPath,branch:_.branch,worktreePath:_.worktreePath,specPath:_.specPath}:null,eZ=function(e){let[t,a]=(0,s.useState)(!1),[r,n]=(0,s.useState)(!1),[l,i]=(0,s.useState)(!1),[o,d]=(0,s.useState)(!1),[c,u]=(0,s.useState)(!1),[m,x]=(0,s.useState)(null),[p,h]=(0,s.useState)(null),[f,g]=(0,s.useState)(null),[j,b]=(0,s.useState)(null),[v,N]=(0,s.useState)(null),y=(0,s.useRef)(null),w=(0,s.useRef)(null),k=(0,s.useRef)(null),C=(0,s.useRef)(null),S=(0,s.useRef)(null);(0,s.useEffect)(()=>{let e=[y,w,k,C,S];return()=>{for(let t of e)t.current&&clearTimeout(t.current)}},[]);let M=(0,s.useCallback)(async(t,s,a,r,n)=>{if(e&&!n){r.current&&clearTimeout(r.current),s(!0),a(null);try{let s=await t({repositoryPath:e.repositoryPath,branch:e.branch});if(!s.success){let e=s.error??"An unexpected error occurred";a(e),r.current=setTimeout(()=>a(null),5e3)}}catch(e){a(e instanceof Error?e.message:"An unexpected error occurred"),r.current=setTimeout(()=>a(null),5e3)}finally{s(!1)}}},[e]);return{openInIde:(0,s.useCallback)(()=>M(sc.openIde,a,x,y,t),[M,t]),openInShell:(0,s.useCallback)(()=>M(su.openShell,n,h,w,r),[M,r]),openFolder:(0,s.useCallback)(async()=>{if(e&&!l){k.current&&clearTimeout(k.current),i(!0),g(null);try{let t=e.worktreePath??e.repositoryPath,s=await (0,sm.openFolder)(t);if(!s.success){let e=s.error??"An unexpected error occurred";g(e),k.current=setTimeout(()=>g(null),5e3)}}catch(e){g(e instanceof Error?e.message:"An unexpected error occurred"),k.current=setTimeout(()=>g(null),5e3)}finally{i(!1)}}},[e,l]),openSpecsFolder:(0,s.useCallback)(async()=>{if(e?.specPath&&!o){C.current&&clearTimeout(C.current),d(!0),b(null);try{let t=await (0,sm.openFolder)(e.specPath);if(!t.success){let e=t.error??"An unexpected error occurred";b(e),C.current=setTimeout(()=>b(null),5e3)}}catch(e){b(e instanceof Error?e.message:"An unexpected error occurred"),C.current=setTimeout(()=>b(null),5e3)}finally{d(!1)}}},[e,o]),rebaseOnMain:(0,s.useCallback)(async()=>{if(e?.featureId&&!c){S.current&&clearTimeout(S.current),u(!0),N(null);try{let t=await sx(e.featureId);if(!t.success){let e=t.error??"An unexpected error occurred";N(e),S.current=setTimeout(()=>N(null),5e3)}}catch(e){N(e instanceof Error?e.message:"An unexpected error occurred"),S.current=setTimeout(()=>N(null),5e3)}finally{u(!1)}}},[e,c]),ideLoading:t,shellLoading:r,folderLoading:l,specsLoading:o,rebaseLoading:c,ideError:m,shellError:p,folderError:f,specsError:j,rebaseError:v}}(eJ),eX=U.gitRebaseSync&&_?.branch&&_?.remoteUrl?_.featureId:null,{data:eY,loading:e0,error:e1,refresh:e2}=function(e){let[t,a]=(0,s.useState)(()=>{if(!e)return null;let t=sb.get(e);return t?t.data:null}),[r,n]=(0,s.useState)(!1),[l,i]=(0,s.useState)(null),o=(0,s.useRef)(e);o.current=e;let d=(0,s.useCallback)(async e=>{n(!0),i(null);try{let t=await sj(e);if(o.current!==e)return;if(t.success&&t.data){let s=t.data;sb.set(e,{data:s,timestamp:Date.now()}),a(s)}else i(t.error??"Failed to check sync status")}catch{if(o.current!==e)return;i("Failed to check sync status")}finally{o.current===e&&n(!1)}},[]);return(0,s.useEffect)(()=>{if(!e){a(null),i(null);return}let t=sb.get(e);t&&(a(t.data),Date.now()-t.timestamp<3e4)||d(e)},[e,d]),{data:t,loading:r,error:l,refresh:(0,s.useCallback)(()=>{e&&d(e)},[e,d])}}(eX),e5=(0,s.useRef)(eZ.rebaseLoading);(0,s.useEffect)(()=>{!e5.current||eZ.rebaseLoading||eZ.rebaseError||e2(),e5.current=eZ.rebaseLoading},[eZ.rebaseLoading,eZ.rebaseError,e2]);let e3=_?.repositoryPath&&_.branch?{targetId:_.featureId,targetType:"feature",repositoryPath:_.repositoryPath,branch:_.branch}:null,e4=(0,S.useDeployAction)(e3),e6="Booting"===e4.status||"Ready"===e4.status,[e8,e9]=(0,s.useState)(!1),e7=(0,s.useCallback)(()=>{_?.featureId&&(navigator.clipboard.writeText(_.featureId),e9(!0),setTimeout(()=>e9(!1),2e3))},[_?.featureId]);if(_){let e=_.featureId.slice(0,8),s=_.repositoryName??_.repositoryPath.split("/").filter(Boolean).at(-1)??"";O=(0,t.jsxs)(t.Fragment,{children:[s?(0,t.jsxs)("div",{className:"flex items-center gap-1.5 pt-0.5",children:[(0,t.jsx)(u.Code2,{className:"text-muted-foreground size-3.5 shrink-0"}),_.remoteUrl?(0,t.jsxs)("a",{href:_.remoteUrl,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground inline-flex items-center gap-1 text-xs transition-colors","data-testid":"feature-drawer-repo-link",children:[s,(0,t.jsx)(m.ExternalLink,{className:"size-3"})]}):(0,t.jsx)("span",{className:"text-muted-foreground text-xs",children:s})]}):null,eJ?(0,t.jsxs)("div",{className:"flex items-center gap-2 pt-1","data-testid":"feature-drawer-actions",children:[_?.state!=="done"?(0,t.jsx)(q,{actions:eZ,repositoryPath:eJ.repositoryPath,worktreePath:eJ.worktreePath,showSpecs:!!eJ.specPath}):null,_?.state!=="done"&&U.envDeploy&&e3?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(A.TooltipProvider,{children:(0,t.jsxs)(A.Tooltip,{children:[(0,t.jsx)(A.TooltipTrigger,{asChild:!0,children:(0,t.jsx)("span",{children:(0,t.jsx)($.ActionButton,{label:e6?"Stop Dev Server":"Start Dev Server",onClick:e6?e4.stop:e4.deploy,loading:e4.deployLoading||e4.stopLoading,error:!!e4.deployError,icon:e6?o.Square:i.Play,iconOnly:!0,variant:"outline",size:"icon-sm"})})}),(0,t.jsx)(A.TooltipContent,{children:e6?"Stop Dev Server":"Start Dev Server"})]})}),e6?(0,t.jsx)(T.DeploymentStatusBadge,{status:e4.status,url:e4.url,targetId:e3?.targetId}):null]}):null,(0,t.jsxs)("div",{className:"ml-auto flex items-center gap-1.5",children:[(0,t.jsx)("code",{className:"bg-muted text-muted-foreground rounded px-1.5 py-0.5 font-mono text-xs",children:e}),(0,t.jsx)("button",{type:"button",onClick:e7,className:"text-muted-foreground hover:text-foreground inline-flex items-center rounded p-0.5 transition-colors","aria-label":"Copy feature ID","data-testid":"feature-drawer-copy-id",children:e8?(0,t.jsx)(c.Check,{className:"size-3.5 text-green-600"}):(0,t.jsx)(d.Copy,{className:"size-3.5"})})]}),_.featureId?(0,t.jsxs)(t.Fragment,{children:["archived"===_.state?(0,t.jsx)(A.TooltipProvider,{children:(0,t.jsxs)(A.Tooltip,{children:[(0,t.jsx)(A.TooltipTrigger,{asChild:!0,children:(0,t.jsx)(I.Button,{variant:"ghost",size:"icon-sm","aria-label":"Unarchive feature",disabled:ef,className:"text-muted-foreground hover:text-primary","data-testid":"feature-drawer-unarchive",onClick:()=>e_(_.featureId),children:ef?(0,t.jsx)(n.Loader2,{className:"size-4 animate-spin"}):(0,t.jsx)(p.ArchiveRestore,{className:"size-4"})})}),(0,t.jsx)(A.TooltipContent,{children:"Unarchive feature"})]})}):"deleting"!==_.state?(0,t.jsx)(A.TooltipProvider,{children:(0,t.jsxs)(A.Tooltip,{children:[(0,t.jsx)(A.TooltipTrigger,{asChild:!0,children:(0,t.jsx)(I.Button,{variant:"ghost",size:"icon-sm","aria-label":"Archive feature",disabled:ef,className:"text-muted-foreground hover:text-foreground","data-testid":"feature-drawer-archive",onClick:()=>eG(_.featureId),children:ef?(0,t.jsx)(n.Loader2,{className:"size-4 animate-spin"}):(0,t.jsx)(x.Archive,{className:"size-4"})})}),(0,t.jsx)(A.TooltipContent,{children:"Archive feature"})]})}):null,(0,t.jsx)(I.Button,{variant:"ghost",size:"icon-sm","aria-label":"Delete feature",disabled:em,className:"text-muted-foreground hover:text-destructive","data-testid":"feature-drawer-delete",onClick:()=>eh(!0),children:em?(0,t.jsx)(n.Loader2,{className:"size-4 animate-spin"}):(0,t.jsx)(l.Trash2,{className:"size-4"})}),(0,t.jsx)(P.DeleteFeatureDialog,{open:ep,onOpenChange:eh,onConfirm:(e,t,s)=>eV(_.featureId,e,t,s),isDeleting:em,featureName:_.name,featureId:_.featureId,hasChildren:_.hasChildren,hasOpenPr:!!_.pr&&"Open"===_.pr.status})]}):null]}):null]})}let te=null;if("feature"===V.type&&_){let e={..._,..."error"===_.state&&{onRetry:eK},..."pending"===_.state&&{onStart:eQ}};te=(0,t.jsx)(so,{featureName:_.name,headerContent:O,featureNode:e,featureId:_.featureId,initialTab:V.initialTab,urlTab:h,sseEvents:K,prdData:ee,prdSelections:es,onPrdSelect:(e,t)=>ea(s=>({...s,[e]:t})),onPrdApprove:eU,onPrdReject:eF,isPrdLoading:eR,techData:el,onTechApprove:eW,onTechReject:eq,isTechLoading:eI,productData:eA?null:eo,mergeData:ec,onMergeApprove:eH,onMergeReject:eB,isMergeLoading:eP,syncStatus:eX?eY:void 0,syncLoading:e0,syncError:e1,onRefreshSync:eX?e2:void 0,onRebaseOnMain:eX?eZ.rebaseOnMain:void 0,rebaseLoading:eZ.rebaseLoading,rebaseError:eZ.rebaseError,isRejecting:ev,chatInput:X,onChatInputChange:Y,interactiveAgentEnabled:E})}return(0,t.jsx)(R.BaseDrawer,{open:J,onClose:ez,size:"lg",modal:!1,"data-testid":"feature"===V.type?"feature-drawer":"repository-drawer",children:te})}e.s(["FeatureDrawerClient",()=>sv],36986)}]);