@shepai/cli 1.98.0 → 1.99.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (272) hide show
  1. package/apis/json-schema/Evidence.yaml +25 -0
  2. package/apis/json-schema/EvidenceType.yaml +9 -0
  3. package/apis/json-schema/WorkflowConfig.yaml +10 -0
  4. package/dist/packages/core/src/domain/factories/settings-defaults.factory.d.ts.map +1 -1
  5. package/dist/packages/core/src/domain/factories/settings-defaults.factory.js +2 -0
  6. package/dist/packages/core/src/domain/generated/output.d.ts +39 -0
  7. package/dist/packages/core/src/domain/generated/output.d.ts.map +1 -1
  8. package/dist/packages/core/src/domain/generated/output.js +7 -0
  9. package/dist/packages/core/src/infrastructure/persistence/sqlite/mappers/settings.mapper.d.ts +2 -0
  10. package/dist/packages/core/src/infrastructure/persistence/sqlite/mappers/settings.mapper.d.ts.map +1 -1
  11. package/dist/packages/core/src/infrastructure/persistence/sqlite/mappers/settings.mapper.js +5 -0
  12. package/dist/packages/core/src/infrastructure/persistence/sqlite/migrations.d.ts.map +1 -1
  13. package/dist/packages/core/src/infrastructure/persistence/sqlite/migrations.js +14 -0
  14. package/dist/packages/core/src/infrastructure/repositories/sqlite-settings.repository.d.ts.map +1 -1
  15. package/dist/packages/core/src/infrastructure/repositories/sqlite-settings.repository.js +7 -3
  16. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/fast-feature-agent-graph.d.ts +12 -5
  17. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/fast-feature-agent-graph.d.ts.map +1 -1
  18. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/fast-feature-agent-graph.js +9 -8
  19. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/feature-agent-graph.d.ts +18 -1
  20. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/feature-agent-graph.d.ts.map +1 -1
  21. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/feature-agent-graph.js +1 -1
  22. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/nodes/evidence-output-parser.d.ts +15 -0
  23. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/nodes/evidence-output-parser.d.ts.map +1 -0
  24. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/nodes/evidence-output-parser.js +48 -0
  25. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/nodes/evidence.node.d.ts +28 -0
  26. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/nodes/evidence.node.d.ts.map +1 -0
  27. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/nodes/evidence.node.js +98 -0
  28. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/nodes/fast-implement.node.d.ts.map +1 -1
  29. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/nodes/fast-implement.node.js +69 -1
  30. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/nodes/implement.node.d.ts.map +1 -1
  31. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/nodes/implement.node.js +68 -3
  32. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/nodes/merge/merge.node.d.ts.map +1 -1
  33. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/nodes/merge/merge.node.js +5 -1
  34. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/nodes/prompts/evidence-prompts.d.ts +19 -0
  35. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/nodes/prompts/evidence-prompts.d.ts.map +1 -0
  36. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/nodes/prompts/evidence-prompts.js +197 -0
  37. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/nodes/prompts/merge-prompts.d.ts +17 -1
  38. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/nodes/prompts/merge-prompts.d.ts.map +1 -1
  39. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/nodes/prompts/merge-prompts.js +72 -2
  40. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/state.d.ts +2 -1
  41. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/state.d.ts.map +1 -1
  42. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/state.js +5 -0
  43. package/dist/src/presentation/web/app/actions/get-merge-review-data.d.ts.map +1 -1
  44. package/dist/src/presentation/web/app/actions/get-merge-review-data.js +36 -3
  45. package/dist/src/presentation/web/app/actions/get-workflow-defaults.d.ts +2 -0
  46. package/dist/src/presentation/web/app/actions/get-workflow-defaults.d.ts.map +1 -1
  47. package/dist/src/presentation/web/app/actions/get-workflow-defaults.js +2 -0
  48. package/dist/src/presentation/web/app/api/evidence/route.d.ts +8 -0
  49. package/dist/src/presentation/web/app/api/evidence/route.d.ts.map +1 -0
  50. package/dist/src/presentation/web/app/api/evidence/route.js +50 -0
  51. package/dist/src/presentation/web/components/common/feature-create-drawer/feature-create-drawer.d.ts +2 -0
  52. package/dist/src/presentation/web/components/common/feature-create-drawer/feature-create-drawer.d.ts.map +1 -1
  53. package/dist/src/presentation/web/components/common/feature-create-drawer/feature-create-drawer.js +27 -3
  54. package/dist/src/presentation/web/components/common/feature-create-drawer/feature-create-drawer.stories.d.ts.map +1 -1
  55. package/dist/src/presentation/web/components/common/feature-create-drawer/feature-create-drawer.stories.js +2 -0
  56. package/dist/src/presentation/web/components/common/merge-review/merge-review-config.d.ts +12 -0
  57. package/dist/src/presentation/web/components/common/merge-review/merge-review-config.d.ts.map +1 -1
  58. package/dist/src/presentation/web/components/common/merge-review/merge-review.d.ts.map +1 -1
  59. package/dist/src/presentation/web/components/common/merge-review/merge-review.js +63 -3
  60. package/dist/src/presentation/web/components/common/merge-review/merge-review.stories.d.ts +2 -0
  61. package/dist/src/presentation/web/components/common/merge-review/merge-review.stories.d.ts.map +1 -1
  62. package/dist/src/presentation/web/components/common/merge-review/merge-review.stories.js +38 -0
  63. package/dist/src/presentation/web/components/features/settings/settings-page-client.d.ts.map +1 -1
  64. package/dist/src/presentation/web/components/features/settings/settings-page-client.js +27 -5
  65. package/dist/src/presentation/web/components/features/settings/settings-page-client.stories.d.ts +1 -0
  66. package/dist/src/presentation/web/components/features/settings/settings-page-client.stories.d.ts.map +1 -1
  67. package/dist/src/presentation/web/components/features/settings/settings-page-client.stories.js +14 -0
  68. package/dist/src/presentation/web/components/features/settings/workflow-settings-section.stories.d.ts.map +1 -1
  69. package/dist/src/presentation/web/components/features/settings/workflow-settings-section.stories.js +6 -0
  70. package/dist/tsconfig.build.tsbuildinfo +1 -1
  71. package/package.json +1 -1
  72. package/web/.next/BUILD_ID +1 -1
  73. package/web/.next/app-path-routes-manifest.json +1 -0
  74. package/web/.next/build-manifest.json +2 -2
  75. package/web/.next/fallback-build-manifest.json +2 -2
  76. package/web/.next/prerender-manifest.json +3 -3
  77. package/web/.next/required-server-files.js +2 -2
  78. package/web/.next/required-server-files.json +2 -2
  79. package/web/.next/routes-manifest.json +6 -0
  80. package/web/.next/server/app/(dashboard)/@drawer/create/page/server-reference-manifest.json +20 -20
  81. package/web/.next/server/app/(dashboard)/@drawer/create/page.js +1 -1
  82. package/web/.next/server/app/(dashboard)/@drawer/create/page.js.nft.json +1 -1
  83. package/web/.next/server/app/(dashboard)/@drawer/create/page_client-reference-manifest.js +1 -1
  84. package/web/.next/server/app/(dashboard)/@drawer/feature/[featureId]/[tab]/page/server-reference-manifest.json +25 -25
  85. package/web/.next/server/app/(dashboard)/@drawer/feature/[featureId]/[tab]/page.js +1 -1
  86. package/web/.next/server/app/(dashboard)/@drawer/feature/[featureId]/[tab]/page.js.nft.json +1 -1
  87. package/web/.next/server/app/(dashboard)/@drawer/feature/[featureId]/[tab]/page_client-reference-manifest.js +1 -1
  88. package/web/.next/server/app/(dashboard)/@drawer/feature/[featureId]/page/server-reference-manifest.json +25 -25
  89. package/web/.next/server/app/(dashboard)/@drawer/feature/[featureId]/page.js +1 -1
  90. package/web/.next/server/app/(dashboard)/@drawer/feature/[featureId]/page.js.nft.json +1 -1
  91. package/web/.next/server/app/(dashboard)/@drawer/feature/[featureId]/page_client-reference-manifest.js +1 -1
  92. package/web/.next/server/app/(dashboard)/@drawer/repository/[repositoryId]/page/server-reference-manifest.json +18 -18
  93. package/web/.next/server/app/(dashboard)/@drawer/repository/[repositoryId]/page.js +1 -1
  94. package/web/.next/server/app/(dashboard)/@drawer/repository/[repositoryId]/page.js.nft.json +1 -1
  95. package/web/.next/server/app/(dashboard)/@drawer/repository/[repositoryId]/page_client-reference-manifest.js +1 -1
  96. package/web/.next/server/app/(dashboard)/create/page/server-reference-manifest.json +20 -20
  97. package/web/.next/server/app/(dashboard)/create/page.js +1 -1
  98. package/web/.next/server/app/(dashboard)/create/page.js.nft.json +1 -1
  99. package/web/.next/server/app/(dashboard)/create/page_client-reference-manifest.js +1 -1
  100. package/web/.next/server/app/(dashboard)/feature/[featureId]/[tab]/page/server-reference-manifest.json +25 -25
  101. package/web/.next/server/app/(dashboard)/feature/[featureId]/[tab]/page.js +1 -1
  102. package/web/.next/server/app/(dashboard)/feature/[featureId]/[tab]/page.js.nft.json +1 -1
  103. package/web/.next/server/app/(dashboard)/feature/[featureId]/[tab]/page_client-reference-manifest.js +1 -1
  104. package/web/.next/server/app/(dashboard)/feature/[featureId]/page/server-reference-manifest.json +25 -25
  105. package/web/.next/server/app/(dashboard)/feature/[featureId]/page.js +1 -1
  106. package/web/.next/server/app/(dashboard)/feature/[featureId]/page.js.nft.json +1 -1
  107. package/web/.next/server/app/(dashboard)/feature/[featureId]/page_client-reference-manifest.js +1 -1
  108. package/web/.next/server/app/(dashboard)/page/server-reference-manifest.json +18 -18
  109. package/web/.next/server/app/(dashboard)/page.js +1 -1
  110. package/web/.next/server/app/(dashboard)/page.js.nft.json +1 -1
  111. package/web/.next/server/app/(dashboard)/page_client-reference-manifest.js +1 -1
  112. package/web/.next/server/app/(dashboard)/repository/[repositoryId]/page/server-reference-manifest.json +18 -18
  113. package/web/.next/server/app/(dashboard)/repository/[repositoryId]/page.js +1 -1
  114. package/web/.next/server/app/(dashboard)/repository/[repositoryId]/page.js.nft.json +1 -1
  115. package/web/.next/server/app/(dashboard)/repository/[repositoryId]/page_client-reference-manifest.js +1 -1
  116. package/web/.next/server/app/_global-error/page.js +1 -1
  117. package/web/.next/server/app/_global-error/page.js.nft.json +1 -1
  118. package/web/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  119. package/web/.next/server/app/_global-error.html +2 -2
  120. package/web/.next/server/app/_global-error.rsc +1 -1
  121. package/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  122. package/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  123. package/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  124. package/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  125. package/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  126. package/web/.next/server/app/_not-found/page/server-reference-manifest.json +1 -1
  127. package/web/.next/server/app/_not-found/page.js +1 -1
  128. package/web/.next/server/app/_not-found/page.js.nft.json +1 -1
  129. package/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  130. package/web/.next/server/app/api/attachments/preview/route.js +1 -1
  131. package/web/.next/server/app/api/attachments/preview/route.js.nft.json +1 -1
  132. package/web/.next/server/app/api/attachments/upload-from-path/route.js +1 -1
  133. package/web/.next/server/app/api/attachments/upload-from-path/route.js.nft.json +1 -1
  134. package/web/.next/server/app/api/evidence/route/app-paths-manifest.json +3 -0
  135. package/web/.next/server/app/api/evidence/route/build-manifest.json +11 -0
  136. package/web/.next/server/app/api/evidence/route/server-reference-manifest.json +4 -0
  137. package/web/.next/server/app/api/evidence/route.js +7 -0
  138. package/web/.next/server/app/api/evidence/route.js.map +5 -0
  139. package/web/.next/server/app/api/evidence/route.js.nft.json +1 -0
  140. package/web/.next/server/app/api/evidence/route_client-reference-manifest.js +2 -0
  141. package/web/.next/server/app/api/feature-logs/route.js +1 -1
  142. package/web/.next/server/app/api/feature-logs/route.js.nft.json +1 -1
  143. package/web/.next/server/app/settings/page/server-reference-manifest.json +5 -5
  144. package/web/.next/server/app/settings/page.js +1 -1
  145. package/web/.next/server/app/settings/page.js.nft.json +1 -1
  146. package/web/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  147. package/web/.next/server/app/skills/page/server-reference-manifest.json +6 -6
  148. package/web/.next/server/app/skills/page.js +1 -1
  149. package/web/.next/server/app/skills/page.js.nft.json +1 -1
  150. package/web/.next/server/app/skills/page_client-reference-manifest.js +1 -1
  151. package/web/.next/server/app/tools/page/server-reference-manifest.json +6 -6
  152. package/web/.next/server/app/tools/page.js +1 -1
  153. package/web/.next/server/app/tools/page.js.nft.json +1 -1
  154. package/web/.next/server/app/tools/page_client-reference-manifest.js +1 -1
  155. package/web/.next/server/app/version/page/server-reference-manifest.json +1 -1
  156. package/web/.next/server/app/version/page.js +1 -1
  157. package/web/.next/server/app/version/page.js.nft.json +1 -1
  158. package/web/.next/server/app/version/page_client-reference-manifest.js +1 -1
  159. package/web/.next/server/app-paths-manifest.json +1 -0
  160. package/web/.next/server/chunks/403f9_next_dist_esm_build_templates_app-route_4d623b8e.js +2 -2
  161. package/web/.next/server/chunks/403f9_next_dist_esm_build_templates_app-route_4d623b8e.js.map +1 -1
  162. package/web/.next/server/chunks/[root-of-the-server]__7d63f9a4._.js +3 -0
  163. package/web/.next/server/chunks/[root-of-the-server]__7d63f9a4._.js.map +1 -0
  164. package/web/.next/server/chunks/{[root-of-the-server]__52c318d1._.js → [root-of-the-server]__91d44424._.js} +2 -2
  165. package/web/.next/server/chunks/[root-of-the-server]__a1c7c02a._.js +3 -0
  166. package/web/.next/server/chunks/[root-of-the-server]__a1c7c02a._.js.map +1 -0
  167. package/web/.next/server/chunks/{[root-of-the-server]__a5879003._.js → [root-of-the-server]__db04ed44._.js} +2 -2
  168. package/web/.next/server/chunks/b1a17_presentation_web__next-internal_server_app_api_evidence_route_actions_38aa6e60.js +3 -0
  169. package/web/.next/server/chunks/b1a17_presentation_web__next-internal_server_app_api_evidence_route_actions_38aa6e60.js.map +1 -0
  170. package/web/.next/server/chunks/ssr/744ca_web_components_common_control-center-drawer_create-drawer-client_tsx_5e26fc0a._.js +1 -1
  171. package/web/.next/server/chunks/ssr/744ca_web_components_common_control-center-drawer_create-drawer-client_tsx_5e26fc0a._.js.map +1 -1
  172. package/web/.next/server/chunks/ssr/8ba4b_server_app_(dashboard)_@drawer_repository_[repositoryId]_page_actions_c757eb00.js +1 -1
  173. package/web/.next/server/chunks/ssr/8ba4b_server_app_(dashboard)_@drawer_repository_[repositoryId]_page_actions_c757eb00.js.map +1 -1
  174. package/web/.next/server/chunks/ssr/8ba4b_server_app_(dashboard)_repository_[repositoryId]_page_actions_7eb49631.js +1 -1
  175. package/web/.next/server/chunks/ssr/8ba4b_server_app_(dashboard)_repository_[repositoryId]_page_actions_7eb49631.js.map +1 -1
  176. package/web/.next/server/chunks/ssr/[root-of-the-server]__11033878._.js +1 -1
  177. package/web/.next/server/chunks/ssr/[root-of-the-server]__11033878._.js.map +1 -1
  178. package/web/.next/server/chunks/ssr/[root-of-the-server]__19fb0bfe._.js +1 -1
  179. package/web/.next/server/chunks/ssr/[root-of-the-server]__19fb0bfe._.js.map +1 -1
  180. package/web/.next/server/chunks/ssr/{[root-of-the-server]__8d9536c4._.js → [root-of-the-server]__248ee887._.js} +2 -2
  181. package/web/.next/server/chunks/ssr/[root-of-the-server]__24dd0927._.js +2 -2
  182. package/web/.next/server/chunks/ssr/[root-of-the-server]__357d99f9._.js +1 -1
  183. package/web/.next/server/chunks/ssr/[root-of-the-server]__3d6f6b0e._.js +1 -1
  184. package/web/.next/server/chunks/ssr/[root-of-the-server]__3d6f6b0e._.js.map +1 -1
  185. package/web/.next/server/chunks/ssr/[root-of-the-server]__42020c54._.js +1 -1
  186. package/web/.next/server/chunks/ssr/[root-of-the-server]__42020c54._.js.map +1 -1
  187. package/web/.next/server/chunks/ssr/[root-of-the-server]__4af0afe0._.js +3 -0
  188. package/web/.next/server/chunks/ssr/[root-of-the-server]__5d87af2e._.js +1 -1
  189. package/web/.next/server/chunks/ssr/[root-of-the-server]__845a9d2a._.js +1 -1
  190. package/web/.next/server/chunks/ssr/[root-of-the-server]__845a9d2a._.js.map +1 -1
  191. package/web/.next/server/chunks/ssr/[root-of-the-server]__89e8a5cc._.js +2 -2
  192. package/web/.next/server/chunks/ssr/[root-of-the-server]__89e8a5cc._.js.map +1 -1
  193. package/web/.next/server/chunks/ssr/{[root-of-the-server]__f8210f45._.js → [root-of-the-server]__9bc1434f._.js} +2 -2
  194. package/web/.next/server/chunks/ssr/[root-of-the-server]__9cb60e1e._.js +1 -1
  195. package/web/.next/server/chunks/ssr/[root-of-the-server]__9cb60e1e._.js.map +1 -1
  196. package/web/.next/server/chunks/ssr/[root-of-the-server]__aad040c0._.js +2 -1
  197. package/web/.next/server/chunks/ssr/[root-of-the-server]__aad040c0._.js.map +1 -1
  198. package/web/.next/server/chunks/ssr/{[root-of-the-server]__f1a05100._.js → [root-of-the-server]__b062b383._.js} +2 -2
  199. package/web/.next/server/chunks/ssr/[root-of-the-server]__fdc75809._.js +1 -1
  200. package/web/.next/server/chunks/ssr/[root-of-the-server]__fdc75809._.js.map +1 -1
  201. package/web/.next/server/chunks/ssr/_135edb9c._.js +1 -1
  202. package/web/.next/server/chunks/ssr/_135edb9c._.js.map +1 -1
  203. package/web/.next/server/chunks/ssr/_1bb131c4._.js.map +1 -1
  204. package/web/.next/server/chunks/ssr/{_1718c38f._.js → _3fafea0f._.js} +2 -2
  205. package/web/.next/server/chunks/ssr/{_1718c38f._.js.map → _3fafea0f._.js.map} +1 -1
  206. package/web/.next/server/chunks/ssr/{_5e112f82._.js → _60e203af._.js} +2 -2
  207. package/web/.next/server/chunks/ssr/{_5e112f82._.js.map → _60e203af._.js.map} +1 -1
  208. package/web/.next/server/chunks/ssr/_6a83bd29._.js +3 -0
  209. package/web/.next/server/chunks/ssr/{7f428_lucide-react_dist_esm_icons_2b65878f._.js.map → _6a83bd29._.js.map} +1 -1
  210. package/web/.next/server/chunks/ssr/_6e08ce21._.js.map +1 -1
  211. package/web/.next/server/chunks/ssr/_8dacd1e7._.js +1 -1
  212. package/web/.next/server/chunks/ssr/_8dacd1e7._.js.map +1 -1
  213. package/web/.next/server/chunks/ssr/{_17237ac7._.js → _cb93a788._.js} +2 -2
  214. package/web/.next/server/chunks/ssr/{_17237ac7._.js.map → _cb93a788._.js.map} +1 -1
  215. package/web/.next/server/chunks/ssr/_cc77a143._.js +1 -1
  216. package/web/.next/server/chunks/ssr/_cc77a143._.js.map +1 -1
  217. package/web/.next/server/chunks/ssr/_eca4aa07._.js +3 -0
  218. package/web/.next/server/chunks/ssr/{_b6866f30._.js.map → _eca4aa07._.js.map} +1 -1
  219. package/web/.next/server/chunks/ssr/b1a17_presentation_web_components_features_settings_settings-page-client_tsx_6ed9d5f8._.js +1 -1
  220. package/web/.next/server/chunks/ssr/b1a17_presentation_web_components_features_settings_settings-page-client_tsx_6ed9d5f8._.js.map +1 -1
  221. package/web/.next/server/chunks/ssr/src_presentation_web_3c53a23d._.js +2 -2
  222. package/web/.next/server/chunks/ssr/src_presentation_web_3c53a23d._.js.map +1 -1
  223. package/web/.next/server/chunks/ssr/src_presentation_web__next-internal_server_app_(dashboard)_page_actions_befd865a.js +1 -1
  224. package/web/.next/server/chunks/ssr/src_presentation_web__next-internal_server_app_(dashboard)_page_actions_befd865a.js.map +1 -1
  225. package/web/.next/server/chunks/ssr/src_presentation_web__next-internal_server_app_skills_page_actions_1fa8042e.js +1 -1
  226. package/web/.next/server/chunks/ssr/src_presentation_web__next-internal_server_app_skills_page_actions_1fa8042e.js.map +1 -1
  227. package/web/.next/server/chunks/ssr/src_presentation_web__next-internal_server_app_tools_page_actions_24684200.js +1 -1
  228. package/web/.next/server/chunks/ssr/src_presentation_web__next-internal_server_app_tools_page_actions_24684200.js.map +1 -1
  229. package/web/.next/server/chunks/ssr/src_presentation_web_components_bf50c527._.js +1 -1
  230. package/web/.next/server/chunks/ssr/src_presentation_web_components_bf50c527._.js.map +1 -1
  231. package/web/.next/server/chunks/ssr/src_presentation_web_components_de814675._.js +1 -1
  232. package/web/.next/server/chunks/ssr/src_presentation_web_components_de814675._.js.map +1 -1
  233. package/web/.next/server/chunks/ssr/src_presentation_web_components_e599bb8c._.js +1 -1
  234. package/web/.next/server/chunks/ssr/src_presentation_web_components_features_control-center_7ac3562e._.js +1 -1
  235. package/web/.next/server/chunks/ssr/src_presentation_web_components_features_control-center_7ac3562e._.js.map +1 -1
  236. package/web/.next/server/chunks/ssr/src_presentation_web_ec8c7a4f._.js +2 -2
  237. package/web/.next/server/chunks/ssr/src_presentation_web_ec8c7a4f._.js.map +1 -1
  238. package/web/.next/server/pages/500.html +2 -2
  239. package/web/.next/server/server-reference-manifest.js +1 -1
  240. package/web/.next/server/server-reference-manifest.json +30 -30
  241. package/web/.next/static/chunks/{d95cd4b81c8d7580.js → 133cef90b3975d8f.js} +1 -1
  242. package/web/.next/static/chunks/{9284ea43640fc469.js → 17c31f43cf41eda4.js} +1 -1
  243. package/web/.next/static/chunks/{3418f7926955f058.js → 24e64b7a634794ad.js} +1 -1
  244. package/web/.next/static/chunks/{feb21651203a4855.js → 356b41f959ceb6dc.js} +1 -1
  245. package/web/.next/static/chunks/{550b849dcc7c1df1.js → 43ac66e5699a245a.js} +1 -1
  246. package/web/.next/static/chunks/4d4019cbe85eaedc.css +1 -0
  247. package/web/.next/static/chunks/{550acf01d8003f3a.js → 6b3282453b0bdc6e.js} +1 -1
  248. package/web/.next/static/chunks/71f3fb72d47e709b.js +1 -0
  249. package/web/.next/static/chunks/761b0946d122beec.js +1 -0
  250. package/web/.next/static/chunks/{5dc83c75c3acefb3.js → d1f5da71a9abf369.js} +1 -1
  251. package/web/.next/static/chunks/{bd6df3bba696a007.js → e01c63f00ba7ec95.js} +2 -2
  252. package/web/.next/static/chunks/e24a024affc634d9.js +1 -0
  253. package/web/.next/static/chunks/e7d1e440160f9fc2.js +2 -0
  254. package/web/.next/server/chunks/[root-of-the-server]__0b10355c._.js +0 -3
  255. package/web/.next/server/chunks/[root-of-the-server]__0b10355c._.js.map +0 -1
  256. package/web/.next/server/chunks/ssr/7f428_lucide-react_dist_esm_icons_2b65878f._.js +0 -3
  257. package/web/.next/server/chunks/ssr/[root-of-the-server]__b65f78cf._.js +0 -3
  258. package/web/.next/server/chunks/ssr/_b6866f30._.js +0 -3
  259. package/web/.next/static/chunks/197b047efa3501c8.js +0 -1
  260. package/web/.next/static/chunks/71d785d1de4b86f6.css +0 -1
  261. package/web/.next/static/chunks/8a3eff27cccf331f.js +0 -1
  262. package/web/.next/static/chunks/8bd300e88a189928.js +0 -1
  263. package/web/.next/static/chunks/f7794f1941c8c867.js +0 -1
  264. /package/web/.next/server/chunks/{[root-of-the-server]__52c318d1._.js.map → [root-of-the-server]__91d44424._.js.map} +0 -0
  265. /package/web/.next/server/chunks/{[root-of-the-server]__a5879003._.js.map → [root-of-the-server]__db04ed44._.js.map} +0 -0
  266. /package/web/.next/server/chunks/ssr/{[root-of-the-server]__8d9536c4._.js.map → [root-of-the-server]__248ee887._.js.map} +0 -0
  267. /package/web/.next/server/chunks/ssr/{[root-of-the-server]__b65f78cf._.js.map → [root-of-the-server]__4af0afe0._.js.map} +0 -0
  268. /package/web/.next/server/chunks/ssr/{[root-of-the-server]__f8210f45._.js.map → [root-of-the-server]__9bc1434f._.js.map} +0 -0
  269. /package/web/.next/server/chunks/ssr/{[root-of-the-server]__f1a05100._.js.map → [root-of-the-server]__b062b383._.js.map} +0 -0
  270. /package/web/.next/static/{HxY7oDPQaoJ0BmVeVLer5 → kPS64EVb81p_02U5q_c7b}/_buildManifest.js +0 -0
  271. /package/web/.next/static/{HxY7oDPQaoJ0BmVeVLer5 → kPS64EVb81p_02U5q_c7b}/_clientMiddlewareManifest.json +0 -0
  272. /package/web/.next/static/{HxY7oDPQaoJ0BmVeVLer5 → kPS64EVb81p_02U5q_c7b}/_ssgManifest.js +0 -0
@@ -1 +1 @@
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),o=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),a=o((e,t)=>{var r=Object.defineProperty,n=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),o=(e,t,n)=>{let o;return(o="symbol"!=typeof t?t+"":t)in e?r(e,o,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[o]=n},a=n((e,t)=>{function r(e,t){e[t]?e[t]++:e[t]=1}function n(e,t){--e[t]||delete e[t]}function a(e,t,r,n){var o=""+t,a=""+r;if(!e&&o>a){var s=o;o=a,a=s}return o+"\x01"+a+"\x01"+(void 0===n?"\0":n)}function s(e,t){return a(e,t.v,t.w,t.name)}t.exports=class{constructor(e){o(this,"_isDirected",!0),o(this,"_isMultigraph",!1),o(this,"_isCompound",!1),o(this,"_label"),o(this,"_defaultNodeLabelFn",()=>{}),o(this,"_defaultEdgeLabelFn",()=>{}),o(this,"_nodes",{}),o(this,"_in",{}),o(this,"_preds",{}),o(this,"_out",{}),o(this,"_sucs",{}),o(this,"_edgeObjs",{}),o(this,"_edgeLabels",{}),o(this,"_nodeCount",0),o(this,"_edgeCount",0),o(this,"_parent"),o(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(o){var a=r.parent(o);return void 0===a||t.hasNode(a)?(n[o]=a,a):a in n?n[a]:e(a)}(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,o){return n.length>1?r.setEdge(e,o,t):r.setEdge(e,o),o}),this}setEdge(){var e,t,n,o,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&&(o=arguments[1],s=!0)):(e=i,t=arguments[1],n=arguments[3],arguments.length>2&&(o=arguments[2],s=!0)),e=""+e,t=""+t,void 0!==n&&(n=""+n);var l=a(this._isDirected,e,t,n);if(Object.hasOwn(this._edgeLabels,l))return s&&(this._edgeLabels[l]=o),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?o:this._defaultEdgeLabelFn(e,t,n);var d=function(e,t,r,n){var o=""+t,a=""+r;if(!e&&o>a){var s=o;o=a,a=s}var i={v:o,w:a};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]):a(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]):a(this._isDirected,e,t,r);return Object.hasOwn(this._edgeLabels,n)}removeEdge(e,t,r){var o=1==arguments.length?s(this._isDirected,arguments[0]):a(this._isDirected,e,t,r),i=this._edgeObjs[o];return i&&(e=i.v,t=i.w,delete this._edgeLabels[o],delete this._edgeObjs[o],n(this._preds[t],e),n(this._sucs[e],t),delete this._in[t][o],delete this._out[e][o],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:a(),version:s()}}),l=n((e,t)=>{var r=a();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),o={v:e};return void 0!==r&&(o.value=r),void 0!==n&&(o.parent=n),o}),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,o){return function(e,t,r,n){var o={},a=!0,s=0,i=e.nodes(),l=function(e){var t=r(e);o[e.v].distance+t<o[e.w].distance&&(o[e.w]={distance:o[e.v].distance+t,predecessor:e.v},a=!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){o[e]={distance:e===t?0:1/0}});for(var c=i.length,u=1;u<c&&(a=!1,s++,d(),a);u++);if(s===c-1&&(a=!1,d(),a))throw Error("The graph contains a negative weight cycle");return o}(e,String(t),n||r,o||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(o){t=[],function n(o){Object.hasOwn(r,o)||(r[o]=!0,t.push(o),e.successors(o).forEach(n),e.predecessors(o).forEach(n))}(o),t.length&&n.push(t)}),n}}),u=n((e,t)=>{t.exports=class{constructor(){o(this,"_arr",[]),o(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,o=n.length;return r[e]=o,n.push({key:e,priority:t}),this._decrease(o),!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,o=e;r<t.length&&(o=t[r].priority<t[o].priority?r:o,n<t.length&&(o=t[n].priority<t[o].priority?n:o),o!==e&&(this._swap(e,o),this._heapify(o)))}_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,o=r[e],a=r[t];r[e]=a,r[t]=o,n[a.key]=e,n[o.key]=t}}}),h=n((e,t)=>{var r=u();t.exports=function(e,t,o,a){return function(e,t,n,o){var a,s,i={},l=new r,d=function(e){var t=e.v!==a?e.v:e.w,r=i[t],o=n(e),d=s.distance+o;if(o<0)throw Error("dijkstra does not allow negative edge weights. Bad edge: "+e+" Weight: "+o);d<r.distance&&(r.distance=d,r.predecessor=a,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[a=l.removeMin()]).distance!==1/0;)o(a).forEach(d);return i}(e,String(t),o||n,a||function(t){return e.outEdges(t)})};var n=()=>1}),f=n((e,t)=>{var r=h();t.exports=function(e,t,n){return e.nodes().reduce(function(o,a){return o[a]=r(e,a,t,n),o},{})}}),p=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=[],o=r;o!==t;)n.push(o),o=e[o].predecessor;return n.push(t),n.reverse()}(e,t,r)}}}),g=n((e,t)=>{t.exports=function(e){var t=0,r=[],n={},o=[];return e.nodes().forEach(function(a){Object.hasOwn(n,a)||function a(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)):(a(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)o.push(d)}}(a)}),o}}),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 o,a,s,i,l;return o=e,a=t||r,s=n||function(t){return e.outEdges(t)},i={},(l=o.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=a(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 o=n[e],a=t[r],s=n[r],i=o.distance+a.distance;i<s.distance&&(s.distance=i,s.predecessor=a.predecessor)})})}),i};var r=()=>1}),v=n((e,t)=>{function r(e){var t={},r={},o=[];if(e.sinks().forEach(function a(s){if(Object.hasOwn(r,s))throw new n;Object.hasOwn(t,s)||(r[s]=!0,t[s]=!0,e.predecessors(s).forEach(a),delete r[s],o.push(s))}),Object.keys(t).length!==e.nodeCount())throw new n;return o}var n=class extends Error{constructor(){super(...arguments)}};t.exports=r,r.CycleException=n}),y=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}}),b=n((e,t)=>{t.exports=function(e,t,r,n,o){Array.isArray(t)||(t=[t]);var a=(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);o=function e(t,r,n,o,a,s,i){return Object.hasOwn(o,r)||(o[r]=!0,n||(i=s(i,r)),a(r).forEach(function(r){i=e(t,r,n,o,a,s,i)}),n&&(i=s(i,r))),i}(e,t,"post"===r,s,a,n,o)}),o}}),w=n((e,t)=>{var r=b();t.exports=function(e,t,n){return r(e,t,n,function(e,t){return e.push(t),e},[])}}),j=n((e,t)=>{var r=w();t.exports=function(e,t){return r(e,t,"post")}}),k=n((e,t)=>{var r=w();t.exports=function(e,t){return r(e,t,"pre")}}),E=n((e,t)=>{var r=a(),n=u();t.exports=function(e,t){var o,a=new r,s={},i=new n;function l(e){var r=e.v===o?e.w:e.v,n=i.priority(r);if(void 0!==n){var a=t(e);a<n&&(s[r]=o,i.decrease(r,a))}}if(0===e.nodeCount())return a;e.nodes().forEach(function(e){i.add(e,1/0),a.setNode(e)}),i.decrease(e.nodes()[0],0);for(var d=!1;i.size()>0;){if(Object.hasOwn(s,o=i.removeMin()))a.setEdge(o,s[o]);else{if(d)throw Error("Input graph is not connected: "+e);d=!0}e.nodeEdges(o).forEach(l)}return a}}),N=n((e,t)=>{var r=h(),n=d();t.exports=function(e,t,o,a){return function(e,t,o,a){if(void 0===o)return r(e,t,o,a);for(var s=!1,i=e.nodes(),l=0;l<i.length;l++){for(var d=a(i[l]),c=0;c<d.length;c++){var u=d[c],h=u.v===i[l]?u.v:u.w,f=h===u.v?u.w:u.v;0>o({v:h,w:f})&&(s=!0)}if(s)return n(e,t,o,a)}return r(e,t,o,a)}(e,t,o,a||function(t){return e.outEdges(t)})}}),C=n((e,t)=>{t.exports={bellmanFord:d(),components:c(),dijkstra:h(),dijkstraAll:f(),extractPath:p(),findCycles:m(),floydWarshall:x(),isAcyclic:y(),postorder:j(),preorder:k(),prim:E(),shortestPaths:N(),reduce:b(),tarjan:g(),topsort:v()}}),_=i();t.exports={Graph:_.Graph,json:l(),alg:C(),version:_.version}}),s=o((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=o((e,t)=>{var r=a().Graph,n=s();t.exports=function(e,t){var a,s;let d,c,u,h,f;if(1>=e.nodeCount())return[];let p=(a=e,s=t||o,d=new r,c=0,u=0,a.nodes().forEach(e=>{d.setNode(e,{v:e,in:0,out:0})}),a.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),f=c+1,d.nodes().forEach(e=>{l(h,f,d.node(e))}),{graph:d,buckets:h,zeroIdx:f});return(function(e,t,r){let n=[],o=t[t.length-1],a=t[0],s;for(;e.nodeCount();){for(;s=a.dequeue();)i(e,t,r,s);for(;s=o.dequeue();)i(e,t,r,s);if(e.nodeCount()){for(let o=t.length-2;o>0;--o)if(s=t[o].dequeue()){n=n.concat(i(e,t,r,s,!0));break}}}return n})(p.graph,p.buckets,p.zeroIdx).flatMap(t=>e.outEdges(t.v,t.w))};var o=()=>1;function i(e,t,r,n,o){let a=o?[]:void 0;return e.inEdges(n.v).forEach(n=>{let s=e.edge(n),i=e.node(n.v);o&&a.push({v:n.v,w:n.w}),i.out-=s,l(t,r,i)}),e.outEdges(n.v).forEach(n=>{let o=e.edge(n),a=n.w,s=e.node(a);s.in-=o,l(t,r,s)}),e.removeNode(n.v),a}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=o((e,t)=>{var r=a().Graph;function n(e,t,r,n){for(var o=n;e.hasNode(o);)o=l(n);return r.dummy=t,e.setNode(o,r),o}t.exports={addBorderNode:function(e,t,r,o){let a={width:0,height:0};return arguments.length>=4&&(a.rank=r,a.order=o),n(e,"border",a,t)},addDummyNode:n,applyWithChunking:o,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),o=n.rank;void 0!==o&&(t[o][n.order]=r)}),t},intersectRect:function(e,t){let r,n,o=e.x,a=e.y,s=t.x-o,i=t.y-a,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:o+r,y:a+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=o(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=o(Math.min,e.nodes().map(t=>e.node(t).rank).filter(e=>void 0!==e)),r=[];e.nodes().forEach(n=>{let o=e.node(n).rank-t;r[o]||(r[o]=[]),r[o].push(n)});let n=0,a=e.graph().nodeRankFactor;Array.from(r).forEach((t,r)=>{void 0===t&&r%a!=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},o=e.edge(r);t.setEdge(r.v,r.w,{weight:n.weight+o.weight,minlen:Math.max(n.minlen,o.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 o(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 o=e.slice(n,n+t);r.push(o)}return r}(t);return e.apply(null,r.map(t=>e.apply(null,t)))}}function s(e){return o(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 o=[];for(let t=e;n(t);t+=r)o.push(t);return o}function c(e,t){return e.reduce((e,r,n)=>(e[r]=t[n],e),{})}}),d=o((e,t)=>{var r=i(),n=l().uniqueId;t.exports={run:function(e){var t,o;let a,s,i;("greedy"===e.graph().acyclicer?r(e,(t=e,e=>t.edge(e).weight)):(a=[],s={},i={},(o=e).nodes().forEach(function e(t){Object.hasOwn(i,t)||(i[t]=!0,s[t]=!0,o.outEdges(t).forEach(t=>{Object.hasOwn(s,t.w)?a.push(t):e(t.w)}),delete s[t])}),a)).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=o((e,t)=>{var r=l();t.exports={run:function(e){e.graph().dummyChains=[],e.edges().forEach(t=>(function(e,t){let n,o,a,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),a=0,++i;i<d;++a,++i)u.points=[],o={width:0,height:0,edgeLabel:u,edgeObj:t,rank:i},n=r.addDummyNode(e,"edge",o,"_d"),i===h&&(o.width=u.width,o.height=u.height,o.dummy="edge-label",o.labelpos=u.labelpos),e.setEdge(s,n,{weight:u.weight},c),0===a&&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,o;for(e.setEdge(r.edgeObj,n);r.dummy;)o=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=o,r=e.node(t)})}}}),u=o((e,t)=>{var{applyWithChunking:r}=l();t.exports={longestPath:function(e){var t={};e.sources().forEach(function n(o){var a=e.node(o);if(Object.hasOwn(t,o))return a.rank;t[o]=!0;var s=r(Math.min,e.outEdges(o).map(t=>null==t?1/0:n(t.w)-e.edge(t).minlen));return s===1/0&&(s=0),a.rank=s})},slack:function(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}}}),h=o((e,t)=>{var r=a().Graph,n=u().slack;t.exports=function(e){var t,o,a,s,i=new r({directed:!1}),l=e.nodes()[0],d=e.nodeCount();for(i.setNode(l,{});t=i,o=e,t.nodes().forEach(function e(r){o.nodeEdges(r).forEach(a=>{var s=a.v,i=r===s?a.w:s;t.hasNode(i)||n(o,a)||(t.setNode(i,{}),t.setEdge(r,i,{}),e(i))})}),t.nodeCount()<d;)a=function(e,t){return t.edges().reduce((r,o)=>{let a=1/0;return e.hasNode(o.v)!==e.hasNode(o.w)&&(a=n(t,o)),a<r[0]?[a,o]:r},[1/0,null])[1]}(i,e),s=i.hasNode(a.v)?n(e,a):-n(e,a),function(e,t,r){e.nodes().forEach(e=>t.node(e).rank+=r)}(i,e,s);return i}}),f=o((e,t)=>{var r=h(),n=u().slack,o=u().longestPath,s=a().alg.preorder,i=a().alg.postorder,d=l().simplify;function c(e){o(e=d(e));var t,n,a=r(e);for(g(a),f(a,e);t=m(a);)n=x(a,e,t),v(a,e,t,n)}function f(e,t){var r=i(e,e.nodes());(r=r.slice(0,r.length-1)).forEach(r=>{var n,o,a,s;return n=e,o=t,a=r,s=n.node(a).parent,void(n.edge(a,s).cutvalue=p(n,o,a))})}function p(e,t,r){var n=e.node(r).parent,o=!0,a=t.edge(r,n),s=0;return a||(o=!1,a=t.edge(n,r)),s=a.weight,t.nodeEdges(r).forEach(a=>{var i=a.v===r,l=i?a.w:a.v;if(l!==n){var d,c,u,h=i===o,f=t.edge(a).weight;if(s+=h?f:-f,d=e,c=r,u=l,d.hasEdge(c,u)){var p=e.edge(r,l).cutvalue;s+=h?-p:p}}}),s}function g(e,t){arguments.length<2&&(t=e.nodes()[0]),function e(t,r,n,o,a){var s=n,i=t.node(o);return r[o]=!0,t.neighbors(o).forEach(a=>{Object.hasOwn(r,a)||(n=e(t,r,n,a,o))}),i.low=s,i.lim=n++,a?i.parent=a: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 o=r.v,a=r.w;t.hasEdge(o,a)||(o=r.w,a=r.v);var s=e.node(o),i=e.node(a),l=s,d=!1;return s.lim>i.lim&&(l=i,d=!0),t.edges().filter(t=>d===y(e,e.node(t.v),l)&&d!==y(e,e.node(t.w),l)).reduce((e,r)=>n(t,r)<n(t,e)?r:e)}function v(e,t,r,n){var o,a,i,l,d=r.v,c=r.w;e.removeEdge(d,c),e.setEdge(n.v,n.w,{}),g(e),f(e,t),o=e,a=t,i=o.nodes().find(e=>!a.node(e).parent),(l=(l=s(o,i)).slice(1)).forEach(e=>{var t=o.node(e).parent,r=a.edge(e,t),n=!1;r||(r=a.edge(t,e),n=!0),a.node(e).rank=a.node(t).rank+(n?r.minlen:-r.minlen)})}function y(e,t,r){return r.low<=t.lim&&t.lim<=r.lim}t.exports=c,c.initLowLimValues=g,c.initCutValues=f,c.calcCutValue=p,c.leaveEdge=m,c.enterEdge=x,c.exchangeEdges=v}),p=o((e,t)=>{var r=u().longestPath,n=h(),o=f();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:o(e);break;case"tight-tree":r(t=e),n(t);break;case"longest-path":a(e);case"none":}};var a=r}),g=o((e,t)=>{t.exports=function(e){var t;let r,n,o=(r={},n=0,(t=e).children().forEach(function e(o){let a=n;t.children(o).forEach(e),r[o]={low:a,lim:n++}}),r);e.graph().dummyChains.forEach(t=>{let r=e.node(t),n=r.edgeObj,a=function(e,t,r,n){let o=[],a=[],s=Math.min(t[r].low,t[n].low),i=Math.max(t[r].lim,t[n].lim),l,d;l=r;do o.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;)a.push(l);return{path:o.concat(a.reverse()),lca:d}}(e,o,n.v,n.w),s=a.path,i=a.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=o((e,t)=>{var r=l();t.exports={run:function(e){var t,n,o;let a=r.addDummyNode(e,"root",{},"_root"),s=(n={},(t=e).children().forEach(e=>(function e(r,o){var a=t.children(r);a&&a.length&&a.forEach(t=>e(t,o+1)),n[r]=o})(e,1)),n),i=Object.values(s),l=r.applyWithChunking(Math.max,i)-1,d=2*l+1;e.graph().nestingRoot=a,e.edges().forEach(t=>e.edge(t).minlen*=d);let c=(o=e).edges().reduce((e,t)=>e+o.edge(t).weight,0)+1;e.children().forEach(t=>(function e(t,n,o,a,s,i,l){let d=t.children(l);if(!d.length){l!==n&&t.setEdge(n,l,{weight:0,minlen:o});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,o,a,s,i,r);let d=t.node(r),h=d.borderTop?d.borderTop:r,f=d.borderBottom?d.borderBottom:r,p=d.borderTop?a:2*a,g=h!==f?1:s-i[l]+1;t.setEdge(c,h,{weight:p,minlen:g,nestingEdge:!0}),t.setEdge(f,u,{weight:p,minlen:g,nestingEdge:!0})}),t.parent(l)||t.setEdge(n,c,{weight:0,minlen:s+i[l]})})(e,a,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=o((e,t)=>{var r=l();function n(e,t,n,o,a,s){let i=a[t][s-1],l=r.addDummyNode(e,"border",{width:0,height:0,rank:s,borderType:t},n);a[t][s]=l,e.setParent(l,o),i&&e.setEdge(i,l,{weight:1})}t.exports=function(e){e.children().forEach(function t(r){let o=e.children(r),a=e.node(r);if(o.length&&o.forEach(t),Object.hasOwn(a,"minRank")){a.borderLeft=[],a.borderRight=[];for(let t=a.minRank,o=a.maxRank+1;t<o;++t)n(e,"borderLeft","_bl",r,a,t),n(e,"borderRight","_br",r,a,t)}})}}),v=o((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 o(e){e.y=-e.y}function a(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=>o(t.node(e))),t.edges().forEach(e=>{let r=t.edge(e);r.points.forEach(o),Object.hasOwn(r,"y")&&o(r)})),("lr"===s||"rl"===s)&&((n=e).nodes().forEach(e=>a(n.node(e))),n.edges().forEach(e=>{let t=n.edge(e);t.points.forEach(a),Object.hasOwn(t,"x")&&a(t)}),r(e))}}}),y=o((e,t)=>{var r=l();t.exports=function(e){let t={},n=e.nodes().filter(t=>!e.children(t).length),o=n.map(t=>e.node(t).rank),a=r.applyWithChunking(Math.max,o),s=r.range(a+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}}),b=o((e,t)=>{var r=l().zipObject;t.exports=function(e,t){let n=0;for(let o=1;o<t.length;++o)n+=function(e,t,n){let o=r(n,n.map((e,t)=>t)),a=t.flatMap(t=>e.outEdges(t).map(t=>({pos:o[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 a.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[o-1],t[o]);return n}}),w=o((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),o=e.node(r.v);return{sum:t.sum+n.weight*o.order,weight:t.weight+n.weight}},{sum:0,weight:0});return{v:t,barycenter:n.sum/n.weight,weight:n.weight}}})}}),j=o((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))}}),k=o((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 o;let a=r.partition(e,e=>Object.hasOwn(e,"barycenter")),s=a.lhs,i=a.rhs.sort((e,t)=>t.i-e.i),l=[],d=0,c=0,u=0;s.sort((o=!!t,(e,t)=>e.barycenter<t.barycenter?-1:e.barycenter>t.barycenter?1:o?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=o((e,t)=>{var r=w(),n=j(),o=k();t.exports=function e(t,a,s,i){var l,d;let c=t.children(a),u=t.node(a),h=u?u.borderLeft:void 0,f=u?u.borderRight:void 0,p={};h&&(c=c.filter(e=>e!==h&&e!==f));let g=r(t,c);g.forEach(r=>{if(t.children(r.v).length){var n,o;let a=e(t,r.v,s,i);p[r.v]=a,Object.hasOwn(a,"barycenter")&&(n=r,o=a,void 0!==n.barycenter?(n.barycenter=(n.barycenter*n.weight+o.barycenter*o.weight)/(n.weight+o.weight),n.weight+=o.weight):(n.barycenter=o.barycenter,n.weight=o.weight))}});let m=n(g,s);l=m,d=p,l.forEach(e=>{e.vs=e.vs.flatMap(e=>d[e]?d[e].vs:e)});let x=o(m,i);if(h&&(x.vs=[h,x.vs,f].flat(!0),t.predecessors(h).length)){let e=t.node(t.predecessors(h)[0]),r=t.node(t.predecessors(f)[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=o((e,t)=>{var r=a().Graph,n=l();t.exports=function(e,t,o,a){a||(a=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 a.forEach(r=>{let n=e.node(r),a=e.parent(r);(n.rank===t||n.minRank<=t&&t<=n.maxRank)&&(i.setNode(r),i.setParent(r,a||s),e[o](r).forEach(t=>{let n=t.v===r?t.w:t.v,o=i.edge(n,r),a=void 0!==o?o.weight:0;i.setEdge(n,r,{weight:e.edge(t).weight+a})}),Object.hasOwn(n,"minRank")&&i.setNode(r,{borderLeft:n.borderLeft[t],borderRight:n.borderRight[t]}))}),i}}),C=o((e,t)=>{t.exports=function(e,t,r){let n={},o;r.forEach(r=>{let a=e.parent(r),s,i;for(;a;){if((s=e.parent(a))?(i=n[s],n[s]=a):(i=o,o=a),i&&i!==a)return void t.setEdge(i,a);a=s}})}}),_=o((e,t)=>{var r=y(),n=b(),o=E(),s=N(),i=C(),d=a().Graph,c=l();function u(e,t,r){let n=new Map,o=(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&&o(r.rank,t),"number"==typeof r.minRank&&"number"==typeof r.maxRank)for(let e=r.minRank;e<=r.maxRank;e++)e!==r.rank&&o(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,a={}){if("function"==typeof a.customOrder)return void a.customOrder(t,e);let s=c.maxRank(t),l=u(t,c.range(1,s+1),"inEdges"),f=u(t,c.range(s-1,-1,-1),"outEdges"),p=r(t);if(h(t,p),a.disableOptimalOrderHeuristic)return;let g=1/0,m,x=a.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 a=e.graph().root,s=o(e,a,n,t);s.vs.forEach((t,r)=>e.node(t).order=r),i(e,n,s.vs)})})(e%2?l:f,e%4>=2,x),p=c.buildLayerMatrix(t);let a=n(t,p);a<g?(r=0,m=Object.assign({},p),g=a):a===g&&(m=structuredClone(p))}h(t,m)}}),O=o((e,t)=>{var r=a().Graph,n=l();function o(e,t){let r={};return t.length&&t.reduce(function(t,n){let o=0,a=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(a,d+1).forEach(t=>{e.predecessors(t).forEach(n=>{let a=e.node(n),s=a.order;(s<o||u<s)&&!(a.dummy&&e.node(t).dummy)&&i(r,n,t)})}),a=d+1,o=u)}),n}),r}function s(e,t){let r={};function o(t,o,a,s,l){let d;n.range(o,a).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,a,s=0;return r.forEach((i,l)=>{if("border"===e.node(i).dummy){let t=e.predecessors(i);t.length&&(a=e.node(t[0]).order,o(r,s,l,n,a),s=l,n=a)}o(r,s,r.length,a,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 o={},a={},s={};return t.forEach(e=>{e.forEach((e,t)=>{o[e]=e,a[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];a[e]===e&&t<s[n]&&!d(r,e,n)&&(a[n]=e,a[e]=o[e]=o[n],t=s[n])}}})}),{root:o,align:a}}function u(e,t,n,o,a){var s,i,l,d,c,u,h;let f,p,g,m={},x=(s=e,i=t,l=n,d=a,f=new r,g=(c=(p=s.graph()).nodesep,u=p.edgesep,h=d,(e,t,r)=>{let n=e.node(t),o=e.node(r),a,s;if(a=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&&(a+=h?s:-s),s=0,a+=(n.dummy?u:c)/2,a+=(o.dummy?u:c)/2,a+=o.width/2,Object.hasOwn(o,"labelpos"))switch(o.labelpos.toLowerCase()){case"l":s=o.width/2;break;case"r":s=-o.width/2}return s&&(a+=h?s:-s),s=0,a}),i.forEach(e=>{let t;e.forEach(e=>{let r=l[e];if(f.setNode(r),t){var n=l[t],o=f.edge(n,r);f.setEdge(n,r,Math.max(g(s,e,t),o||0))}t=e})}),f),v=a?"borderLeft":"borderRight";function y(e,t){let r=x.nodes().slice(),n={},o=r.pop();for(;o;){if(n[o])e(o);else for(let e of(n[o]=!0,r.push(o),t(o)))r.push(e);o=r.pop()}}return y(function(e){m[e]=x.inEdges(e).reduce((e,t)=>Math.max(e,m[t.v]+x.edge(t)),0)},x.predecessors.bind(x)),y(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(o).forEach(e=>m[e]=m[n[e]]),m}function h(e,t){return Object.values(t).reduce((t,r)=>{let n=-1/0,o=1/0;Object.entries(r).forEach(([t,r])=>{var a,s;let i=(a=e,s=t,a.node(s).width/2);n=Math.max(r+i,n),o=Math.min(r-i,o)});let a=n-o;return a<t[0]&&(t=[a,r]),t},[1/0,null])[1]}function f(e,t){let r=Object.values(t),o=n.applyWithChunking(Math.min,r),a=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=o-n.applyWithChunking(Math.min,d);"l"!==s&&(c=a-n.applyWithChunking(Math.max,d)),c&&(e[i]=n.mapValues(l,e=>e+c))})})}function p(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(o(e,t),s(e,t)),a={},i;["u","d"].forEach(o=>{i="u"===o?t:Object.values(t).reverse(),["l","r"].forEach(t=>{"r"===t&&(i=i.map(e=>Object.values(e).reverse()));let s=("u"===o?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)),a[o+t]=d})});let l=h(e,a);return f(a,l),p(a,e.graph().align)},findType1Conflicts:o,findType2Conflicts:s,addConflict:i,hasConflict:d,verticalAlignment:c,horizontalCompaction:u,alignCoordinates:f,findSmallestWidthAlignment:h,balance:p}}),M=o((e,t)=>{var r=l(),n=O().positionX;t.exports=function(e){var t;let o,a,s,i;t=e=r.asNonCompoundGraph(e),o=r.buildLayerMatrix(t),a=t.graph().ranksep,s=t.graph().rankalign,i=0,o.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+a}),Object.entries(n(e)).forEach(([t,r])=>e.node(t).x=r)}}),R=o((e,t)=>{var r=d(),n=c(),o=p(),s=l().normalizeRanks,i=g(),u=l().removeEmptyRanks,h=m(),f=x(),y=v(),b=_(),w=M(),j=l(),k=a().Graph;t.exports=function(e,t={}){let a=t.debugTiming?j.time:j.notime;return a("layout",()=>{let l=a(" buildLayoutGraph",()=>{var t;let r,n;return t=e,r=new k({multigraph:!0,compound:!0}),n=I(t.graph()),r.setGraph(Object.assign({},N,T(n,E),j.pick(n,C))),t.nodes().forEach(e=>{let n=T(I(t.node(e)),O);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=I(t.edge(e));r.setEdge(e,Object.assign({},P,T(n,S),j.pick(n,L)))}),r});return a(" runLayout",()=>{var e,d,c;return e=l,d=a,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",()=>o(j.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};j.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",()=>f(e)),d(" order",()=>b(e,c)),d(" insertSelfEdges",()=>{var t;return t=e,void j.buildLayerMatrix(t).forEach(e=>{var r=0;e.forEach((e,n)=>{var o=t.node(e);o.order=n+r,(o.selfEdges||[]).forEach(e=>{j.addDummyNode(t,"selfedge",{width:e.label.width,height:e.label.height,rank:o.rank,order:n+ ++r,e:e.e,label:e.label},"_se")}),delete o.selfEdges})})}),d(" adjustCoordinateSystem",()=>y.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),o=n.x+n.width/2,a=n.y,s=r.x-o,i=n.height/2;t.setEdge(r.e,r.label),t.removeNode(e),r.label.points=[{x:o+2*s/3,y:a-i},{x:o+5*s/6,y:a-i},{x:o+s,y:a},{x:o+5*s/6,y:a+i},{x:o+2*s/3,y:a+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),o=t.node(r.borderBottom),a=t.node(r.borderLeft[r.borderLeft.length-1]),s=t.node(r.borderRight[r.borderRight.length-1]);r.width=Math.abs(s.x-a.x),r.height=Math.abs(o.y-n.y),r.x=a.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",()=>y.undo(e)),d(" translateGraph",()=>(function(e){let t=1/0,r=0,n=1/0,o=0,a=e.graph(),s=a.marginx||0,i=a.marginy||0;function l(e){let a=e.x,s=e.y,i=e.width,l=e.height;t=Math.min(t,a-i/2),r=Math.max(r,a+i/2),n=Math.min(n,s-l/2),o=Math.max(o,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 o=e.node(r);o.x-=t,o.y-=n}),e.edges().forEach(r=>{let o=e.edge(r);o.points.forEach(e=>{e.x-=t,e.y-=n}),Object.hasOwn(o,"x")&&(o.x-=t),Object.hasOwn(o,"y")&&(o.y-=n)}),a.width=r-t+s,a.height=o-n+i})(e)),d(" assignNodeIntersects",()=>{var t;(t=e).edges().forEach(e=>{let r=t.edge(e),n=t.node(e.v),o=t.node(e.w),a,s;r.points?(a=r.points[0],s=r.points[r.points.length-1]):(r.points=[],a=o,s=n),r.points.unshift(j.intersectRect(n,a)),r.points.push(j.intersectRect(o,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)))}),a(" updateInputGraph",()=>{var t,r;return t=e,r=l,void(t.nodes().forEach(e=>{let n=t.node(e),o=r.node(e);n&&(n.x=o.x,n.y=o.y,n.order=o.order,n.rank=o.rank,r.children(e).length&&(n.width=o.width,n.height=o.height))}),t.edges().forEach(e=>{let n=t.edge(e),o=r.edge(e);n.points=o.points,Object.hasOwn(o,"x")&&(n.x=o.x,n.y=o.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"],O=["width","height","rank"],R={width:0,height:0},S=["minlen","weight","width","height","labeloffset"],P={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},L=["labelpos"];function T(e,t){return j.mapValues(j.pick(e,t),Number)}function I(e){var t={};return e&&Object.entries(e).forEach(([e,r])=>{"string"==typeof e&&(e=e.toLowerCase()),t[e]=r}),t}}),S=o((e,t)=>{var r=l(),n=a().Graph;t.exports={debugOrdering:function(e){let t=r.buildLayerMatrix(e),o=new n({compound:!0,multigraph:!0}).setGraph({});return e.nodes().forEach(t=>{o.setNode(t,{label:t}),o.setParent(t,"layer"+e.node(t).rank)}),e.edges().forEach(e=>o.setEdge(e.v,e.w,{},e.name)),t.forEach((e,t)=>{o.setNode("layer"+t,{rank:"same"}),e.reduce((e,t)=>(o.setEdge(e,t,{style:"invis"}),t))}),o}}}),P=o((e,t)=>{t.exports="2.0.4"});let L=o((e,t)=>{t.exports={graphlib:a(),layout:R(),debug:S(),util:{time:l().time,notime:l().notime},version:P()}})(),T={direction:"LR",ranksep:200,nodesep:15},I={featureNode:{width:288,height:140},repositoryNode:{width:328,height:50}};function D(e,t){let r=e.data;return r&&"number"==typeof r.width&&"number"==typeof r.height?{width:r.width,height:r.height}:I[e.type??""]??t}function A(e,t,r={}){let{direction:n="TB",nodeSize:o={width:172,height:36},ranksep:a=80,nodesep:s=30}=r;if(0===e.length)return{nodes:[],edges:[]};let i=new L.graphlib.Graph({multigraph:!0});i.setDefaultEdgeLabel(()=>({})),i.setGraph({rankdir:n,ranksep:a,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=D(e,o);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);L.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),f="LR"===n||"RL"===n,p=new Map;for(let e of d){let t=i.node(e.id),r=D(e,o);p.set(e.id,{cx:t.x,cy:t.y,w:r.width,h:r.height})}let g=new Map;for(let e of t)p.has(e.source)&&p.has(e.target)&&(g.has(e.source)||g.set(e.source,[]),g.get(e.source).push(e.target));let m=new Map;for(let e=0;e<d.length;e++)m.set(d[e].id,e);for(let[,e]of g)e.sort((e,t)=>(m.get(e)??0)-(m.get(t)??0));let x=new Set;for(let e of g.values())for(let t of e)x.add(t);let v=[...new Set(p.keys())].filter(e=>!x.has(e)),y=new Map;for(let e of v)!function e(t){if(y.has(t))return y.get(t);let r=p.get(t),n=f?r.h:r.w,o=g.get(t);if(!o||0===o.length)return y.set(t,n),n;let a=0;for(let t of o)a+=e(t);let i=Math.max(n,a+=(o.length-1)*s);return y.set(t,i),i}(e);let b=0;for(let e of v){let t=y.get(e)??0;!function e(t,r){let n=p.get(t);f?n.cy=r:n.cx=r;let o=g.get(t);if(!o||0===o.length)return;let a=0;for(let e of o)a+=y.get(e)??0;let i=r-(a+=(o.length-1)*s)/2;for(let t of o){let r=y.get(t)??0;e(t,i+r/2),i+=r+s}}(e,b+t/2),b+=t+s}let w=[];for(let e of d){let t=p.get(e.id);w.push({...e,targetPosition:u,sourcePosition:h,position:{x:t.cx-t.w/2,y:t.cy-t.h/2}})}if(c.length>0){let e=0,t=1/0;for(let r of w){let n=D(r,o);e=Math.max(e,r.position.y+n.height),t=Math.min(t,r.position.x)}t===1/0&&(t=0);for(let r=0;r<c.length;r++){let n=c[r],a=D(n,o);w.push({...n,targetPosition:u,sourcePosition:h,position:{x:t,y:e+30+r*(a.height+20)}})}}return{nodes:w,edges:[...t]}}var F=e.i(4999),$=e.i(21023);let z=(0,$.createServerReference)("40468732a06f3692685849ce590d5af1bc4bdd73f6",$.callServer,void 0,$.findSourceMapURL,"addRepository"),B=(0,$.createServerReference)("40f639a8cce95ea78c94c8ed200bdedadb33f8df6a",$.callServer,void 0,$.findSourceMapURL,"deleteRepository"),G=(0,$.createServerReference)("40d771fce73fe8e209b803ba8856cf7b8089bdae07",$.callServer,void 0,$.findSourceMapURL,"getFeatureMetadata"),q=(0,$.createServerReference)("008e94b1e6058da6b55065382f48d7aa1b80bee348",$.callServer,void 0,$.findSourceMapURL,"fetchGraphData");var W=e.i(39443),V=e.i(8361),U=e.i(18354),H=e.i(99045);function X(e,t){let r=new Map;for(let e of t)"dependencyEdge"===e.type&&r.set(e.target,e.source);let n=new Map,o=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&&o.set(t.id,{nodeId:t.id,data:t.data});return{featureMap:n,repoMap:o}}function K(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)}let Y=(0,U.createLogger)("[Polling]"),J=0,Q=0;function Z(e,o){let a=(0,r.useRouter)(),s=(0,V.useSoundAction)("delete"),i=(0,V.useSoundAction)("create"),{nodes:l,edges:d,reconcile:c,updateFeature:u,addPendingFeature:h,removeFeature:f,restoreFeature:p,addRepository:g,removeRepository:m,replaceRepository:x,getFeatureRepositoryPath:v,getRepositoryData:y,getRepoMapSize:b,setCallbacks:w}=function(e,r){let n=(0,t.useMemo)(()=>X(e,r),[]),[o,a]=(0,t.useState)(n.featureMap),[s,i]=(0,t.useState)(n.repoMap),[l,d]=(0,t.useState)(new Map),c=(0,t.useRef)(new Map),u=(0,t.useRef)(new Set),h=(0,t.useRef)({}),f=(0,t.useMemo)(()=>({onNodeAction:e=>h.current.onNodeAction?.(e),onNodeSettings:e=>h.current.onNodeSettings?.(e),onFeatureDelete:e=>h.current.onFeatureDelete?.(e),onRepositoryAdd:e=>h.current.onRepositoryAdd?.(e),onRepositoryClick:e=>h.current.onRepositoryClick?.(e),onRepositoryDelete:e=>h.current.onRepositoryDelete?.(e)}),[]),p=(0,t.useRef)(o);p.current=o;let g=(0,t.useRef)(s);g.current=s;let m=(0,t.useMemo)(()=>(function(e,t,r,n){let o=[],a=[],s=new Map;for(let[e,r]of t)r.data.repositoryPath&&s.set(r.data.repositoryPath,e);let i=new Map;for(let[e,r]of t){let t={...r.data,...n?.onRepositoryAdd&&{onAdd:()=>n.onRepositoryAdd(e)},...n?.onRepositoryClick&&{onClick:()=>n.onRepositoryClick(e)},...n?.onRepositoryDelete&&{onDelete:n.onRepositoryDelete}};o.push({id:e,type:"repositoryNode",position:{x:0,y:0},data:t})}for(let[t,l,d]of[...[...e.entries()].map(([e,t])=>[e,t,!1]),...[...r.entries()].filter(([t])=>!e.has(t)).map(([e,t])=>[e,t,!0])]){let e="creating"===l.data.state||d,r={...l.data,...!e&&n?.onNodeAction&&{onAction:()=>n.onNodeAction(t)},...!e&&n?.onNodeSettings&&{onSettings:()=>n.onNodeSettings(t)},...!e&&n?.onFeatureDelete&&{onDelete:n.onFeatureDelete}};if(o.push({id:t,type:"featureNode",position:{x:0,y:0},data:r}),l.parentNodeId)a.push({id:`dep-${l.parentNodeId}-${t}`,source:l.parentNodeId,target:t,type:"dependencyEdge"});else{let e=l.data.repositoryPath,r=s.get(e)??function(e){if(i.has(e))return i.get(e);let t=`virtual-repo-${e}`,r=e.split("/").filter(Boolean).at(-1)??e;return o.push({id:t,type:"repositoryNode",position:{x:0,y:0},data:{name:r,repositoryPath:e}}),i.set(e,t),t}(e);a.push({id:`edge-${r}-${t}`,source:r,target:t,style:{strokeDasharray:"5 5"}})}}let l=a.length>0;for(let e of o)e.data.showHandles=l;return{nodes:o,edges:a}})(o,s,l,f),[o,s,l,f]),x=(0,t.useRef)({key:"",positions:new Map}),{nodes:v,edges:y}=(0,t.useMemo)(()=>{let e=m.nodes.map(e=>e.id).sort().join(","),t=m.edges.map(e=>`${e.source}-${e.target}`).sort().join(","),r=`${e}|${t}`;if(r!==x.current.key){let e=A(m.nodes,m.edges,T),t=new Map;for(let r of e.nodes)t.set(r.id,{position:r.position,targetPosition:r.targetPosition,sourcePosition:r.sourcePosition});return x.current={key:r,positions:t},e}let{positions:n}=x.current;return{nodes:m.nodes.map(e=>{let t=n.get(e.id);return t?{...e,...t}:e}),edges:m.edges}},[m]),b=(0,t.useCallback)((e,t)=>{let{featureMap:r,repoMap:n}=X(e,t),o=new Set([...r.values()].map(e=>`${e.data.name}\0${e.data.repositoryPath}`));a(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}`;o.has(t)||n.set(e,r)}let a=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"}}):u.current.has(t)||(n.set(t,r),a.add(t)));for(let[e,t]of(u.current=a,c.current)){let r=n.get(e);r&&(n.set(e,{...r,data:{...r.data,...t}}),c.current.delete(e))}return n}),d(e=>{if(0===e.size)return e;let t=!1,r=new Map(e);for(let[n,a]of e){let e=`${a.data.name}\0${a.data.repositoryPath}`;o.has(e)&&(r.delete(n),t=!0)}return t?r:e}),i(n)},[]),w=(0,t.useCallback)((e,t)=>{a(r=>{let n=r.get(e);if(!n)return c.current.set(e,{...c.current.get(e),...t}),r;if(c.current.delete(e),K(n.data,t))return r;let o=new Map(r);return o.set(e,{...n,data:{...n.data,...t}}),o}),d(r=>{let n=r.get(e);if(!n||K(n.data,t))return r;let o=new Map(r);return o.set(e,{...n,data:{...n.data,...t}}),o})},[]),j=(0,t.useCallback)((e,t,r)=>{d(n=>{let o=new Map(n);return o.set(e,{nodeId:e,data:t,parentNodeId:r}),o})},[]),k=(0,t.useCallback)(e=>{d(t=>{if(!t.has(e))return t;let r=new Map(t);return r.delete(e),r})},[]),E=(0,t.useCallback)(e=>{a(t=>{if(!t.has(e))return t;let r=new Map(t);return r.delete(e),r})},[]),N=(0,t.useCallback)((e,t)=>{a(r=>{let n=new Map(r);return n.set(e,t),n})},[]),C=(0,t.useCallback)((e,t)=>{i(r=>{let n=new Map(r);return n.set(e,{nodeId:e,data:t}),n})},[]),_=(0,t.useCallback)(e=>{i(t=>{if(!t.has(e))return t;let r=new Map(t);return r.delete(e),r})},[]),O=(0,t.useCallback)((e,t,r)=>{i(n=>{if(!n.has(e))return n;let o=new Map(n);return o.delete(e),o.set(t,{nodeId:t,data:r}),o})},[]),M=(0,t.useCallback)(e=>p.current.get(e)?.data.repositoryPath,[]),R=(0,t.useCallback)(e=>g.current.get(e)?.data,[]);return{nodes:v,edges:y,reconcile:b,updateFeature:w,addPendingFeature:j,removePendingFeature:k,removeFeature:E,restoreFeature:N,addRepository:C,removeRepository:_,replaceRepository:O,getFeatureRepositoryPath:M,getRepositoryData:R,getRepoMapSize:(0,t.useCallback)(()=>g.current.size,[]),setCallbacks:(0,t.useCallback)(e=>{h.current=e},[])}}(e,o),j=(0,t.useRef)(l),k=(0,t.useRef)(d);(0,t.useEffect)(()=>{j.current=l,k.current=d},[l,d]);let E=(0,t.useMemo)(()=>e.map(e=>e.id).sort().join(","),[e]),N=(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]),C=(0,t.useRef)("");(0,t.useEffect)(()=>{let t=`${E}|${N}`;t!==C.current&&(C.current=t,c(e,o))},[E,N,e,o,c]);let _=(0,t.useRef)(new Map),{events:O}=(0,W.useAgentEventsContext)();(0,t.useEffect)(()=>{let t=_.current;for(let r of e){if("featureNode"!==r.type)continue;let e=r.data,o=t.get(r.id);void 0!==o&&o!==e.state&&(O.some(t=>t.featureId===e.featureId&&(0,H.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:()=>a.push(`/feature/${e.featureId}`)}}):"error"===e.state&&n.toast.error(e.name,{description:e.errorMessage??"Agent failed"}))),t.set(r.id,e.state)}},[N,e,O,a]);let M=(0,t.useRef)(0);(0,t.useEffect)(()=>{if(M.current>O.length&&(M.current=0),O.length<=M.current)return;let e=O.slice(M.current);for(let{featureId:t,state:r,lifecycle:n}of(M.current=O.length,(0,H.resolveSseEventUpdates)(e)))if(void 0!==r||void 0!==n){let e=`feat-${t}`,o=j.current.find(t=>t.id===e);if(o&&"deleting"===o.data.state)continue;u(e,{...void 0!==r&&{state:r},...void 0!==n&&{lifecycle:n}})}},[O,u]),(0,t.useEffect)(()=>{let e=e=>{let{featureId:t}=e.detail;u(`feat-${t}`,{state:"running"})};return window.addEventListener("shep:feature-approved",e),()=>window.removeEventListener("shep:feature-approved",e)},[u]);let R=(0,t.useRef)(new Set),S=(0,t.useRef)(0);(0,t.useEffect)(()=>{if(S.current>O.length&&(S.current=0),O.length<=S.current)return;let e=O.slice(S.current);for(let t of(S.current=O.length,e)){if("Feature metadata updated"!==t.message||R.current.has(t.featureId))continue;R.current.add(t.featureId);let e=`feat-${t.featureId}`;G(t.featureId).then(t=>{t&&u(e,{name:t.name,description:t.description})}).catch(()=>{})}},[O,u]),(0,t.useEffect)(()=>{Y.debug("polling enabled (3000ms interval)");let e=setInterval(async()=>{try{let{nodes:e,edges:t}=await q();c(e,t)}catch{Y.warn("poll fetch failed — will retry next interval")}},3e3);return()=>{Y.debug("polling disabled"),clearInterval(e)}},[c]);let P=(0,t.useCallback)(e=>{},[]),L=(0,t.useCallback)(e=>{},[]),I=(0,t.useCallback)((e,t,r)=>{let n=t?.featureId?`feat-${t.featureId}`:`feature-${Date.now()}-${J++}`,o={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 h(n,o,"dependencyEdge"===r&&e?e:void 0),n},[h]),D=(0,t.useCallback)((e,t)=>{let r=`feat-${e}`,o=[],i=[r];for(;i.length>0;){let e=i.shift();for(let t of k.current)"dependencyEdge"===t.type&&t.source===e&&(o.push(t.target),i.push(t.target))}let l=new Map;for(let e of[r,...o]){let t=j.current.find(t=>t.id===e);t&&l.set(e,t.data.state)}for(let e of(u(r,{state:"deleting"}),o))u(e,{state:"deleting"});s.play(),n.toast.success("Deleting feature…"),a.push("/"),(0,F.deleteFeature)(e,t).then(e=>{if(e.error){for(let[e,t]of l)t&&u(e,{state:t});n.toast.error(e.error)}else for(let e of(f(r),o))f(e)}).catch(()=>{for(let[e,t]of l)t&&u(e,{state:t});n.toast.error("Failed to delete feature")})},[a,s,u,f]),$=(0,t.useCallback)(async e=>{let t=`repo-${e}`,r=new Set(k.current.filter(e=>e.source===t).map(e=>e.target)),o=y(t),a=new Map;for(let e of r){let t=j.current.find(t=>t.id===e);t&&a.set(e,{nodeId:e,data:t.data})}let i=()=>{for(let[e,r]of(o&&g(t,o),a))p(e,r)};for(let e of(m(t),r))f(e);try{let t=await B(e);if(!t.success){n.toast.error(t.error??"Failed to remove repository"),i();return}s.play(),n.toast.success("Repository removed")}catch{n.toast.error("Failed to remove repository"),i()}},[s,m,f,g,p,y]),U=(0,t.useCallback)(e=>{let t=A(j.current,k.current,{...T,direction:e});c(t.nodes,t.edges)},[c]);return{nodes:l,edges:d,onNodesChange:P,handleConnect:L,handleAddRepository:(0,t.useCallback)(e=>{let t=0===b(),r=`repo-temp-${++Q}`,o=e.replace(/[\\/]+$/,"").split(/[\\/]/).pop()??e;return g(r,{name:o,repositoryPath:e,id:r}),z({path:e,name:o}).then(e=>{if(e.error){m(r),n.toast.error(e.error);return}let t=e.repository;x(r,`repo-${t.id}`,{name:t.name,repositoryPath:t.path,id:t.id}),i.play()}).catch(()=>{m(r),n.toast.error("Failed to add repository")}),{wasEmpty:t,repoPath:e}},[g,m,x,i,b]),handleLayout:U,handleDeleteFeature:D,handleDeleteRepository:$,createFeatureNode:I,getFeatureRepositoryPath:v,getRepositoryData:y,setCallbacks:w}}e.s(["useControlCenterState",()=>Z],17840)},48246,e=>{"use strict";var t=e.i(20314),r=e.i(53271),n=e.i(79054),o=e.i(31406),a=e.i(3214),s=e.i(3645);let i=(0,s.default)("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);var l=e.i(35364);e.i(54793);var d=e.i(7729);e.i(47506);var c=e.i(89313),u=e.i(92002);let h=(0,s.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 f=e.i(8986),p=e.i(38573),g=e.i(19933),m=e.i(67669),x=e.i(24042),v=e.i(64970),y=e.i(31777);e.i(81803);var b=e.i(72714),w=e.i(2287),j=e.i(2828);e.i(99348);var k=e.i(17466),E=e.i(8537),N=e.i(75921),C=e.i(76852);function _({data:e}){let o=(0,N.useFeatureFlags)(),[s,i]=(0,n.useState)(!1),d=(0,C.useRepositoryActions)(e.repositoryPath?{repositoryPath:e.repositoryPath}:null),c=(0,E.useDeployAction)(e.repositoryPath?{targetId:e.repositoryPath,targetType:"repository",repositoryPath:e.repositoryPath}:null),_="Booting"===c.status||"Ready"===c.status;return(0,t.jsxs)("div",{className:(0,y.cn)("group relative",e.onDelete&&e.id&&"pl-10"),children:[e.showHandles?(0,t.jsx)(r.Handle,{type:"target",position:u.Position.Left,isConnectable:!1,className:"opacity-0!"}):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)(j.TooltipProvider,{children:(0,t.jsxs)(j.Tooltip,{children:[(0,t.jsx)(j.TooltipTrigger,{asChild:!0,children:(0,t.jsx)("button",{"aria-label":"Remove repository","data-testid":"repository-node-delete-button",onClick:e=>{e.stopPropagation(),i(!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)(m.Trash2,{className:"h-3.5 w-3.5"})})}),(0,t.jsx)(j.TooltipContent,{children:"Remove repository"})]})})}),(0,t.jsx)(w.Dialog,{open:s,onOpenChange:i,children:(0,t.jsxs)(w.DialogContent,{className:"max-w-xs",children:[(0,t.jsxs)(w.DialogHeader,{children:[(0,t.jsx)(w.DialogTitle,{children:"Remove repository?"}),(0,t.jsxs)(w.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)(w.DialogFooter,{className:"grid grid-cols-2 gap-2 sm:flex-none",children:[(0,t.jsx)(w.DialogClose,{asChild:!0,children:(0,t.jsx)(l.Button,{variant:"outline",children:"Cancel"})}),(0,t.jsx)(l.Button,{variant:"destructive",onClick:()=>{i(!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:"nodrag bg-card flex min-w-[18rem] cursor-pointer items-center gap-3 rounded-full border px-4 py-3 shadow-sm",children:[(0,t.jsx)(h,{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,y.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)(j.TooltipProvider,{children:(0,t.jsxs)(j.Tooltip,{children:[(0,t.jsx)(j.TooltipTrigger,{asChild:!0,children:(0,t.jsx)("span",{className:"flex items-center",children:(0,t.jsx)(b.ActionButton,{label:"Open in IDE",onClick:d.openInIde,loading:d.ideLoading,error:!!d.ideError,icon:f.Code2,iconOnly:!0,variant:"ghost",size:"icon-xs"})})}),(0,t.jsx)(j.TooltipContent,{children:"Open in IDE"})]})}),(0,t.jsx)(j.TooltipProvider,{children:(0,t.jsxs)(j.Tooltip,{children:[(0,t.jsx)(j.TooltipTrigger,{asChild:!0,children:(0,t.jsx)("span",{className:"flex items-center",children:(0,t.jsx)(b.ActionButton,{label:"Open in Shell",onClick:d.openInShell,loading:d.shellLoading,error:!!d.shellError,icon:p.Terminal,iconOnly:!0,variant:"ghost",size:"icon-xs"})})}),(0,t.jsx)(j.TooltipContent,{children:"Open in Shell"})]})}),(0,t.jsx)(j.TooltipProvider,{children:(0,t.jsxs)(j.Tooltip,{children:[(0,t.jsx)(j.TooltipTrigger,{asChild:!0,children:(0,t.jsx)("span",{className:"flex items-center",children:(0,t.jsx)(b.ActionButton,{label:"Open Folder",onClick:d.openFolder,loading:d.folderLoading,error:!!d.folderError,icon:g.FolderOpen,iconOnly:!0,variant:"ghost",size:"icon-xs"})})}),(0,t.jsx)(j.TooltipContent,{children:"Open Folder"})]})}),o.envDeploy?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(j.TooltipProvider,{children:(0,t.jsxs)(j.Tooltip,{children:[(0,t.jsx)(j.TooltipTrigger,{asChild:!0,children:(0,t.jsx)("span",{className:"flex items-center",children:(0,t.jsx)(b.ActionButton,{label:_?"Stop Dev Server":"Start Dev Server",onClick:_?c.stop:c.deploy,loading:c.deployLoading||c.stopLoading,error:!!c.deployError,icon:_?v.Square:x.Play,iconOnly:!0,variant:"ghost",size:"icon-xs"})})}),(0,t.jsx)(j.TooltipContent,{children:_?"Stop Dev Server":"Start Dev Server"})]})}),_?(0,t.jsx)(k.DeploymentStatusBadge,{status:c.status,url:c.url,targetId:e.repositoryPath}):null]}):null]}):null,e.onAdd?(0,t.jsx)(j.TooltipProvider,{children:(0,t.jsxs)(j.Tooltip,{children:[(0,t.jsx)(j.TooltipTrigger,{asChild:!0,children:(0,t.jsx)("button",{"aria-label":"Add feature","data-testid":"repository-node-add-button",onClick:t=>{t.stopPropagation(),e.onAdd?.()},className:(0,y.cn)("text-muted-foreground hover:bg-accent dark:hover:bg-accent/50 flex h-6 w-6 shrink-0 cursor-pointer items-center justify-center rounded-full transition-colors hover:text-blue-500",e.pulseAdd&&"animate-pulse-cta bg-blue-100 text-blue-500 dark:bg-blue-900/40"),children:(0,t.jsx)(a.Plus,{className:"h-3.5 w-3.5"})})}),(0,t.jsx)(j.TooltipContent,{children:"Add feature"})]})}):null]})]}),e.onAdd||e.showHandles?(0,t.jsx)(r.Handle,{type:"source",position:u.Position.Right,isConnectable:!e.showHandles,className:"opacity-0!"}):null]})}function O(e){let[n]=(0,u.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 M={x:30,y:30,zoom:.85};function R({onResetViewport:e}){let{setViewport:o}=(0,r.useReactFlow)(),a=(0,n.useCallback)(()=>{o(e(),{duration:400})},[e,o]);return(0,t.jsx)(r.ControlButton,{onClick:a,title:"Reset view","aria-label":"Reset view",children:(0,t.jsx)(i,{style:{fill:"none"}})})}function S({nodes:e,edges:o,selectedFeatureId:s,defaultViewport:i,onNodesChange:u,onAddFeature:h,onConnect:f,onNodeClick:p,onPaneClick:g,onCanvasDrag:m,onMoveEnd:x,onResetViewport:v,toolbar:y,emptyState:b}){let w=(0,n.useMemo)(()=>({featureNode:c.FeatureNode,repositoryNode:_}),[]),j=(0,n.useMemo)(()=>({dependencyEdge:O}),[]),k=(0,n.useMemo)(()=>null==s?e:e.map(e=>"featureNode"===e.type&&e.data.featureId===s?{...e,selected:!0}:e),[e,s]);return 0===e.length?b?(0,t.jsx)("div",{"data-testid":"features-canvas-empty",className:"h-full w-full",children:b}):(0,t.jsx)("div",{"data-testid":"features-canvas-empty",children:(0,t.jsx)(d.EmptyState,{title:"No features yet",description:"Get started by creating your first feature.",action:(0,t.jsxs)(l.Button,{onClick:h,children:[(0,t.jsx)(a.Plus,{className:"mr-2 h-4 w-4"}),"New Feature"]})})}):(0,t.jsx)("div",{"data-testid":"features-canvas","data-no-drawer-close":!0,className:"pointer-events-auto h-full w-full",children:(0,t.jsxs)(r.ReactFlow,{nodes:k,edges:o,nodeTypes:w,edgeTypes:j,onConnect:f,onNodesChange:u,onNodeClick:p,onPaneClick:g,onMoveStart:m,onMoveEnd:x,defaultViewport:i??M,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,proOptions:{hideAttribution:!0},children:[(0,t.jsx)(r.Background,{}),(0,t.jsx)(r.Controls,{showInteractive:!1,children:v?(0,t.jsx)(R,{onResetViewport:v}):null}),y]})})}var P=e.i(5147),L=e.i(8361),T=e.i(30153);let I="shep-canvas-viewport",D={x:30,y:30,zoom:.85},A=(0,s.default)("square-terminal",[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]]);var F=e.i(33548),$=e.i(23925),z=e.i(83428),B=e.i(78521),G=e.i(21023);let q=(0,G.createServerReference)("00f9eecd4ae202b92ad3cfec2ebd15c27a741af981",G.callServer,void 0,G.findSourceMapURL,"isAgentSetupComplete");var W=e.i(76016),V=e.i(11345),U=e.i(81181),H=e.i(35e3),X=e.i(95812),K=e.i(79687),Y=e.i(26370),J=e.i(30702),Q=e.i(97438);let Z=(0,G.createServerReference)("40a46eee420754c544f7b46a28e3bf2c9a2b5e36a6",G.callServer,void 0,G.findSourceMapURL,"checkAgentTool");var ee=e.i(48538),et=e.i(86782),er=e.i(29847),en=e.i(32983);let eo=["select-agent","select-model","check-tool","authenticate"];function ea({onComplete:e,className:r}){let o,a,[s,i]=(0,n.useState)([]),[l,d]=(0,n.useState)(!0),[c,u]=(0,n.useState)("select-agent"),[h,f]=(0,n.useState)(null),[p,g]=(0,n.useState)(null),[m,x]=(0,n.useState)(null),[v,b]=(0,n.useState)(!1),[w,j]=(0,n.useState)(!1),[k,E]=(0,n.useState)(!1),[N,C]=(0,n.useState)(!0),_=(0,n.useRef)(void 0);(0,n.useEffect)(()=>{(0,Q.getAllAgentModels)().then(i).finally(()=>d(!1))},[]);let O=h?s.find(e=>e.agentType===h):null,M=(0,n.useCallback)((e,t)=>{E(!0),C(!1),_.current&&clearTimeout(_.current),_.current=setTimeout(()=>{t?.(),u(e),requestAnimationFrame(()=>{C(!0),E(!1)})},150)},[]);(0,n.useEffect)(()=>()=>{_.current&&clearTimeout(_.current)},[]);let R=(0,n.useCallback)(e=>{let t=s.find(t=>t.agentType===e);t&&t.models.length>0?M("select-model",()=>{f(e)}):M("check-tool",()=>{f(e),g("")})},[s,M]),S=(0,n.useCallback)(e=>{M("check-tool",()=>{g(e)})},[M]),P=(0,n.useCallback)(()=>{M("authenticate")},[M]),L=(0,n.useCallback)(()=>{"select-model"===c?M("select-agent",()=>{f(null)}):"check-tool"===c?O&&O.models.length>0?M("select-model",()=>{g(null)}):M("select-agent",()=>{f(null)}):"authenticate"===c&&(m&&!m.installed&&m.toolId?M("check-tool"):O&&O.models.length>0?M("select-model",()=>{g(null)}):M("select-agent",()=>{f(null)}))},[c,O,m,M]);(0,n.useEffect)(()=>{"check-tool"===c&&h&&(b(!0),Z(h).then(e=>{x(e),(e.installed||!e.toolId)&&M("authenticate")}).finally(()=>b(!1)))},[c,h,M]);let T=(0,n.useCallback)(async()=>{if(h){j(!0);try{await (0,ee.updateAgentAndModel)(h,p??null),e()}finally{j(!1)}}},[h,p,e]);if(l)return(0,t.jsxs)("div",{"data-testid":"welcome-agent-setup",className:(0,y.cn)("flex flex-col items-center justify-center gap-3",r),children:[(0,t.jsx)(z.Loader2,{className:"text-muted-foreground h-4 w-4 animate-spin"}),(0,t.jsx)("p",{className:"text-muted-foreground text-xs",children:"Loading agents…"})]});let I=eo.indexOf(c);return(0,t.jsxs)("div",{"data-testid":"welcome-agent-setup",className:(0,y.cn)("flex flex-col items-center gap-4","w-72",r),children:[(0,t.jsx)("div",{className:"flex flex-col items-center gap-1",children:(0,t.jsxs)("div",{className:"text-muted-foreground flex items-center gap-2",children:["select-agent"===c&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(Y.Bot,{className:"h-3.5 w-3.5"}),(0,t.jsx)("span",{className:"text-[10px] font-semibold tracking-widest uppercase",children:"Choose your agent"})]}),"select-model"===c&&O?(o=(0,et.getAgentTypeIcon)(O.agentType),(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(o,{className:"h-3.5 w-3.5"}),(0,t.jsxs)("span",{className:"text-[10px] font-semibold tracking-widest uppercase",children:[O.label," — Pick a model"]})]})):null,"check-tool"===c&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(Y.Bot,{className:"h-3.5 w-3.5"}),(0,t.jsx)("span",{className:"text-[10px] font-semibold tracking-widest uppercase",children:"Verifying setup"})]}),"authenticate"===c&&O?(a=(0,et.getAgentTypeIcon)(O.agentType),(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(a,{className:"h-3.5 w-3.5"}),(0,t.jsx)("span",{className:"text-[10px] font-semibold tracking-widest uppercase",children:"Authenticate"})]})):null]})}),(0,t.jsx)("div",{className:"flex w-32 items-center gap-1",children:eo.map((e,r)=>(0,t.jsx)("div",{className:(0,y.cn)("h-0.5 flex-1 rounded-full transition-colors duration-300",r<=I?"bg-foreground/60":"bg-muted")},e))}),(0,t.jsxs)("div",{className:(0,y.cn)("flex w-full flex-col items-center transition-opacity duration-150",N&&!k?"opacity-100":"opacity-0"),children:["select-agent"===c&&(0,t.jsx)("div",{"data-testid":"agent-list",className:"flex w-full flex-col gap-1.5",children:s.map(e=>{let r=(0,et.getAgentTypeIcon)(e.agentType);return(0,t.jsxs)("button",{type:"button","data-testid":`agent-option-${e.agentType}`,className:"border-border hover:border-foreground/40 flex w-full cursor-pointer items-center gap-2.5 rounded-md border border-dashed px-4 py-2.5 transition-colors",onClick:()=>R(e.agentType),children:[(0,t.jsx)(r,{className:"text-muted-foreground h-4 w-4 shrink-0"}),(0,t.jsx)("span",{className:"flex-1 text-left text-xs font-medium",children:e.label}),(0,t.jsx)(W.ChevronRight,{className:"text-muted-foreground h-3 w-3"})]},e.agentType)})}),"select-model"===c&&O?(0,t.jsxs)("div",{"data-testid":"model-list",className:"flex w-full flex-col gap-1.5",children:[(0,t.jsxs)("button",{type:"button",className:"text-muted-foreground hover:text-foreground mb-0.5 flex cursor-pointer items-center gap-1 self-start text-[10px] font-medium transition-colors",onClick:L,children:[(0,t.jsx)(V.ChevronLeft,{className:"h-3 w-3"}),"Back"]}),(0,t.jsx)("div",{className:"flex max-h-48 w-full flex-col gap-1.5 overflow-y-auto",children:O.models.map(e=>{let r=(0,er.getModelMeta)(e.id);return(0,t.jsxs)("button",{type:"button","data-testid":`model-option-${e.id}`,className:"border-border hover:border-foreground/40 flex w-full cursor-pointer items-center gap-2.5 rounded-md border border-dashed px-4 py-2.5 text-left transition-colors",onClick:()=>S(e.id),children:[(0,t.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[(0,t.jsx)("span",{className:"text-xs font-medium",children:r.displayName||e.displayName}),(0,t.jsx)("span",{className:"text-muted-foreground text-[10px] leading-tight",children:r.description||e.description})]}),(0,t.jsx)(W.ChevronRight,{className:"text-muted-foreground h-3 w-3 shrink-0"})]},e.id)})})]}):null,"check-tool"===c&&(0,t.jsx)(es,{toolStatus:m,checking:v,saving:!1,onConfirm:P,onBack:L,onToolInstalled:()=>{h&&(b(!0),Z(h).then(x).finally(()=>b(!1)))}}),"authenticate"===c&&m?(0,t.jsx)(el,{toolStatus:m,agentLabel:O?.label??h??"Agent",saving:w,onConfirm:T,onBack:L}):null]})]})}function es({toolStatus:e,checking:r,saving:n,onConfirm:o,onBack:a,onToolInstalled:s}){return r||!e?(0,t.jsxs)("div",{className:"flex flex-col items-center gap-2 py-4",children:[(0,t.jsx)(z.Loader2,{className:"text-muted-foreground h-4 w-4 animate-spin"}),(0,t.jsx)("p",{className:"text-muted-foreground text-[10px]",children:"Checking tool availability…"})]}):e.toolId?e.installed?(0,t.jsxs)("div",{className:"flex w-full flex-col items-center gap-3",children:[(0,t.jsxs)("div",{className:"text-muted-foreground flex items-center gap-1.5",children:[(0,t.jsx)(H.CheckCircle2,{className:"h-3.5 w-3.5"}),(0,t.jsxs)("span",{className:"text-xs",children:[e.tool?.name??e.toolId," is installed"]})]}),(0,t.jsx)(ei,{saving:n,onConfirm:o,onBack:a})]}):(0,t.jsx)(ed,{toolStatus:e,saving:n,onConfirm:o,onBack:a,onInstalled:s}):(0,t.jsxs)("div",{className:"flex w-full flex-col items-center gap-3",children:[(0,t.jsxs)("div",{className:"text-muted-foreground flex items-center gap-1.5",children:[(0,t.jsx)(H.CheckCircle2,{className:"h-3.5 w-3.5"}),(0,t.jsx)("span",{className:"text-xs",children:"No additional tools required"})]}),(0,t.jsx)(ei,{saving:n,onConfirm:o,onBack:a})]})}function ei({saving:e,onConfirm:r,onBack:n,label:o="Continue"}){return(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsxs)("button",{type:"button",className:"text-muted-foreground hover:text-foreground cursor-pointer text-[10px] transition-colors",onClick:n,children:[(0,t.jsx)(V.ChevronLeft,{className:"mr-0.5 inline h-3 w-3"}),"Back"]}),(0,t.jsxs)("button",{type:"button","data-testid":"agent-setup-confirm",disabled:e,className:"border-border hover:border-foreground/40 flex cursor-pointer items-center gap-1.5 rounded-md border border-dashed px-4 py-2 text-xs font-medium transition-colors disabled:opacity-50",onClick:r,children:[e?(0,t.jsx)(z.Loader2,{className:"h-3 w-3 animate-spin"}):(0,t.jsx)($.Check,{className:"h-3 w-3"}),o]})]})}function el({toolStatus:e,agentLabel:r,saving:o,onConfirm:a,onBack:s}){let[i,l]=(0,n.useState)(!1),[d,c]=(0,n.useState)(!1),u=(0,n.useCallback)(async()=>{if(e.toolId){l(!0);try{(await fetch(`/api/tools/${e.toolId}/launch`,{method:"POST"})).ok&&c(!0)}finally{l(!1)}}},[e.toolId]);return e.toolId?(0,t.jsxs)("div",{className:"flex w-full flex-col items-center gap-3",children:[(0,t.jsxs)("p",{className:"text-muted-foreground text-center text-[10px] leading-relaxed",children:["Open ",r," in a terminal to sign in.",(0,t.jsx)("br",{}),"Follow the prompts, then come back here."]}),(0,t.jsxs)("button",{type:"button","data-testid":"agent-setup-launch",disabled:i,onClick:u,className:"border-border hover:border-foreground/40 flex w-full cursor-pointer items-center gap-2.5 rounded-md border border-dashed px-4 py-2.5 transition-colors disabled:opacity-50",children:[i?(0,t.jsx)(z.Loader2,{className:"text-muted-foreground h-4 w-4 animate-spin"}):(0,t.jsx)(p.Terminal,{className:"text-muted-foreground h-4 w-4"}),(0,t.jsx)("span",{className:"flex-1 text-left text-xs font-medium",children:d?"Open again":`Open ${r}`}),(0,t.jsx)(J.ExternalLink,{className:"text-muted-foreground h-3 w-3"})]}),d?(0,t.jsx)("p",{className:"text-muted-foreground text-[10px]",children:"Terminal opened — complete sign-in there"}):null,e.binaryName?(0,t.jsxs)("div",{className:"flex w-full flex-col gap-1",children:[(0,t.jsx)("p",{className:"text-muted-foreground text-[10px]",children:"Or run manually in any terminal:"}),(0,t.jsxs)("div",{className:"w-full rounded-md bg-zinc-900 px-3 py-1.5 font-mono text-[11px] text-zinc-300",children:[(0,t.jsx)("span",{className:"text-zinc-500 select-none",children:"$ "}),e.binaryName]})]}):null,(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsxs)("button",{type:"button",className:"text-muted-foreground hover:text-foreground cursor-pointer text-[10px] transition-colors",onClick:s,children:[(0,t.jsx)(V.ChevronLeft,{className:"mr-0.5 inline h-3 w-3"}),"Back"]}),(0,t.jsxs)("button",{type:"button","data-testid":"agent-setup-confirm",disabled:o,className:"border-border hover:border-foreground/40 flex cursor-pointer items-center gap-1.5 rounded-md border border-dashed px-4 py-2 text-xs font-medium transition-colors disabled:opacity-50",onClick:a,children:[o?(0,t.jsx)(z.Loader2,{className:"h-3 w-3 animate-spin"}):(0,t.jsx)($.Check,{className:"h-3 w-3"}),d?"Done":"Skip"]})]})]}):(0,t.jsxs)("div",{className:"flex w-full flex-col items-center gap-3",children:[(0,t.jsx)("p",{className:"text-muted-foreground text-[10px]",children:"No authentication required"}),(0,t.jsx)(ei,{saving:o,onConfirm:a,onBack:s,label:"Done"})]})}function ed({toolStatus:e,saving:r,onConfirm:o,onBack:a,onInstalled:s}){let i=e.toolId??"",{logs:l,status:d,startInstall:c}=(0,en.useToolInstallStream)(i),u="done"===d,h="error"===d;return(0,n.useEffect)(()=>{u&&s()},[u,s]),(0,t.jsxs)("div",{className:"flex w-full flex-col items-center gap-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[u?(0,t.jsx)(H.CheckCircle2,{className:"text-muted-foreground h-3.5 w-3.5"}):h?(0,t.jsx)(K.AlertCircle,{className:"text-destructive h-3.5 w-3.5"}):(0,t.jsx)(X.Circle,{className:"text-muted-foreground h-3.5 w-3.5"}),(0,t.jsxs)("span",{className:"text-xs",children:[e.tool?.name??i," ",u?"installed":h?"install failed":"is not installed"]})]}),e.tool?.installCommand&&"idle"===d?(0,t.jsxs)("div",{className:"w-full rounded-md bg-zinc-900 px-3 py-2 font-mono text-[11px] text-zinc-300",children:[(0,t.jsx)("span",{className:"text-zinc-500 select-none",children:"$ "}),e.tool.installCommand]}):null,("streaming"===d||u||h)&&l.length>0?(0,t.jsxs)("div",{className:"max-h-28 w-full overflow-auto rounded-md bg-zinc-900 px-3 py-2 font-mono text-[10px] leading-relaxed text-zinc-400",children:[l.map((e,r)=>(0,t.jsx)("div",{className:"break-all whitespace-pre-wrap",children:e},r)),u?(0,t.jsx)("div",{className:"text-muted-foreground mt-1",children:"Installation complete"}):null,h?(0,t.jsx)("div",{className:"text-destructive mt-1",children:"Installation failed — try manually"}):null]}):null,(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsxs)("button",{type:"button",className:"text-muted-foreground hover:text-foreground cursor-pointer text-[10px] transition-colors",onClick:a,children:[(0,t.jsx)(V.ChevronLeft,{className:"mr-0.5 inline h-3 w-3"}),"Back"]}),!u&&e.tool?.autoInstall?(0,t.jsxs)("button",{type:"button","data-testid":"agent-setup-install",disabled:"streaming"===d,className:"border-border hover:border-foreground/40 flex cursor-pointer items-center gap-1.5 rounded-md border border-dashed px-4 py-2 text-xs font-medium transition-colors disabled:opacity-50",onClick:c,children:["streaming"===d?(0,t.jsx)(z.Loader2,{className:"h-3 w-3 animate-spin"}):(0,t.jsx)(U.Download,{className:"h-3 w-3"}),"streaming"===d?"Installing…":"Install"]}):null,u?(0,t.jsxs)("button",{type:"button","data-testid":"agent-setup-confirm",disabled:r,className:"border-border hover:border-foreground/40 flex cursor-pointer items-center gap-1.5 rounded-md border border-dashed px-4 py-2 text-xs font-medium transition-colors disabled:opacity-50",onClick:o,children:[r?(0,t.jsx)(z.Loader2,{className:"h-3 w-3 animate-spin"}):(0,t.jsx)($.Check,{className:"h-3 w-3"}),"Continue"]}):null]})]})}let ec=["cd ~/my-repo",'shep feat new "sleek dashboard"'];function eu({onRepositorySelect:e,className:r}){let[o,s]=(0,n.useState)(!1),[i,l]=(0,n.useState)(!1),[d,c]=(0,n.useState)(!1);async function u(){if(!i){l(!0);try{let t=await (0,B.pickFolder)();t&&e?.(t)}finally{l(!1)}}}(0,n.useEffect)(()=>{q().then(e=>{e&&c(!0)})},[]);let f=(0,n.useCallback)(async()=>{await navigator.clipboard.writeText(ec.join("\n")),s(!0),setTimeout(()=>s(!1),2e3)},[]),p=(0,n.useCallback)(()=>{c(!0)},[]);return(0,t.jsxs)("div",{"data-testid":"control-center-empty-state",className:(0,y.cn)("relative h-full w-full",r),children:[(0,t.jsx)("div",{className:"absolute inset-0 [background-image:radial-gradient(circle,_var(--color-border)_1px,_transparent_1px)] [background-size:24px_24px]"}),(0,t.jsxs)("div",{className:"absolute top-8 left-8 z-10",children:[(0,t.jsx)("h1",{className:"text-4xl font-bold tracking-tight",children:"Features"}),(0,t.jsx)("p",{className:"text-muted-foreground text-3xl font-light",children:"Control Center"})]}),(0,t.jsx)("div",{className:"relative z-10 flex h-full items-center justify-center",children:(0,t.jsx)("div",{className:"flex w-72 flex-col items-center gap-4",children:d?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"text-muted-foreground flex items-center gap-2",children:[(0,t.jsx)(h,{className:"h-3.5 w-3.5"}),(0,t.jsx)("span",{className:"text-[10px] font-semibold tracking-widest uppercase",children:"Repositories"})]}),(0,t.jsxs)("button",{type:"button","data-testid":"empty-state-add-repository",onClick:u,disabled:i,className:"border-border hover:border-foreground/40 flex w-full cursor-pointer items-center gap-2.5 rounded-md border border-dashed px-4 py-2.5 transition-colors disabled:cursor-wait disabled:opacity-50",children:[i?(0,t.jsx)(z.Loader2,{className:"text-muted-foreground h-4 w-4 animate-spin"}):(0,t.jsx)(a.Plus,{className:"text-muted-foreground h-4 w-4"}),(0,t.jsx)("span",{className:"text-xs font-medium",children:i?"Opening…":"Add Repository"})]}),(0,t.jsxs)("div",{className:"text-muted-foreground flex items-center gap-2",children:[(0,t.jsx)("div",{className:"bg-border h-px w-10"}),(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[(0,t.jsx)(A,{className:"h-3 w-3"}),(0,t.jsx)("span",{className:"text-[10px] font-semibold tracking-widest uppercase",children:"Or via CLI"})]}),(0,t.jsx)("div",{className:"bg-border h-px w-10"})]}),(0,t.jsxs)("div",{"data-testid":"cli-code-block",className:"relative w-full rounded-md bg-zinc-900 px-3 py-2 font-mono text-[11px] text-zinc-300",children:[(0,t.jsx)("button",{type:"button","data-testid":"cli-code-block-copy",onClick:f,className:"absolute top-2 right-2 cursor-pointer rounded p-1 text-zinc-500 transition-colors hover:bg-zinc-800 hover:text-zinc-300","aria-label":"Copy commands",children:o?(0,t.jsx)($.Check,{className:"h-3 w-3"}):(0,t.jsx)(F.Copy,{className:"h-3 w-3"})}),(0,t.jsx)("div",{className:"space-y-0.5",children:ec.map(e=>(0,t.jsxs)("div",{className:"whitespace-nowrap",children:[(0,t.jsx)("span",{className:"text-zinc-500 select-none",children:"$ "}),(0,t.jsx)("span",{children:e})]},e))})]}),(0,t.jsx)("p",{className:"text-muted-foreground text-[10px]",children:"Feature will appear on canvas once created"})]}):(0,t.jsx)(ea,{onComplete:p})})})]})}var eh=e.i(17840);let ef={maxZoom:1,padding:.5,duration:500};function ep({initialNodes:e,initialEdges:a}){let s,i,l,d=(0,o.useRouter)(),c=(0,o.usePathname)(),u=(s=(0,o.usePathname)().match(/^\/feature\/([^/]+)/),s?.[1]??null),h=(0,L.useSoundAction)("click"),{guardedNavigate:f}=(0,T.useDrawerCloseGuard)(),{fitView:p}=(0,r.useReactFlow)(),g=(0,n.useRef)(null),{defaultViewport:m,onMoveEnd:x,resetViewport:v}=(i=(0,n.useRef)(function(){try{let e=localStorage.getItem(I);if(null==e)return D;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:D}catch{return D}}()).current,l=(0,n.useRef)(null),(0,n.useEffect)(()=>()=>{null!=l.current&&clearTimeout(l.current)},[]),{defaultViewport:i,onMoveEnd:(0,n.useCallback)(e=>{null!=l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{try{localStorage.setItem(I,JSON.stringify(e))}catch{}},500)},[]),resetViewport:(0,n.useCallback)(()=>{try{localStorage.removeItem(I)}catch{}return D},[])}),{nodes:y,edges:b,onNodesChange:w,handleConnect:j,handleAddRepository:k,handleDeleteFeature:E,handleDeleteRepository:N,createFeatureNode:C,setCallbacks:_}=(0,eh.useControlCenterState)(e,a),{setFeatures:O}=(0,P.useSidebarFeaturesContext)(),M=(0,n.useMemo)(()=>y.filter(e=>"featureNode"===e.type),[y]),R=(0,n.useMemo)(()=>M.map(e=>{let t=e.data;return`${t.featureId}:${t.state}:${t.name}`}).sort().join(","),[M]);(0,n.useEffect)(()=>{O(M.map(e=>{let t=e.data,r=(0,P.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))},[R,M,O]);let A=(0,n.useCallback)((e,t)=>{if("featureNode"===t.type){let e=t.data;"creating"!==e.state&&f(()=>{h.play(),d.push(`/feature/${e.featureId}`)})}},[d,h,f]),F=(0,n.useCallback)(()=>{h.play(),d.push("/create")},[d,h]),$=(0,n.useCallback)(e=>{h.play();let t=y.find(t=>t.id===e),r=t?.data?.repositoryPath;r?d.push(`/create?repo=${encodeURIComponent(r)}`):d.push("/create")},[y,d,h]),z=(0,n.useCallback)(e=>{let t=e.startsWith("feat-")?e.slice(5):e,r=b.find(t=>t.target===e),n=r?y.find(e=>e.id===r.source):null,o=n?.data?.repositoryPath;h.play();let a=new URLSearchParams;o&&a.set("repo",o),a.set("parent",t),d.push(`/create?${a.toString()}`)},[y,b,d,h]),B=(0,n.useCallback)(e=>{let t=y.find(t=>t.id===e);if(t?.type==="repositoryNode"){let e=t.data;e.id&&f(()=>d.push(`/repository/${e.id}`))}},[y,d,f]),G=(0,n.useCallback)(()=>{"/"!==c&&f(()=>d.push("/"))},[d,c,f]);(0,n.useEffect)(()=>{let e=e=>{let{wasEmpty:t,repoPath:r}=k(e.detail.path);t&&setTimeout(()=>{p(ef),g.current=setTimeout(()=>{f(()=>d.push(`/create?repo=${encodeURIComponent(r)}`))},600)},0)};return window.addEventListener("shep:add-repository",e),()=>{window.removeEventListener("shep:add-repository",e),null!=g.current&&clearTimeout(g.current)}},[k,p,f,d]),(0,n.useEffect)(()=>{let e=e=>{let t=e.detail;if(t.parentId)return void C(`feat-${t.parentId}`,{state:"creating",featureId:t.featureId,name:t.name,description:t.description,repositoryPath:t.repositoryPath},"dependencyEdge");let r=y.find(e=>"repositoryNode"===e.type&&e.data.repositoryPath===t.repositoryPath);C(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)},[y,C]),(0,n.useEffect)(()=>{_({onNodeAction:z,onFeatureDelete:E,onRepositoryAdd:$,onRepositoryClick:B,onRepositoryDelete:N})},[_,z,E,$,B,N]);let q=(0,n.useCallback)((e,t)=>{x(t)},[x]),W=y.some(e=>"repositoryNode"===e.type),V=c.startsWith("/create"),U=(0,n.useMemo)(()=>{let e=y.filter(e=>"repositoryNode"===e.type),t=y.some(e=>"featureNode"===e.type);return 1!==e.length||t||V?y:y.map(e=>"repositoryNode"===e.type?{...e,data:{...e.data,pulseAdd:!0}}:e)},[y,V]);return W?(0,t.jsx)(S,{nodes:U,edges:b,selectedFeatureId:u,defaultViewport:m,onNodesChange:w,onConnect:j,onAddFeature:F,onNodeClick:A,onPaneClick:G,onMoveEnd:q,onResetViewport:v,emptyState:(0,t.jsx)(eu,{onRepositorySelect:k})}):(0,t.jsx)(eu,{onRepositorySelect:k})}function eg({initialNodes:e,initialEdges:n,drawer:o}){return(0,t.jsxs)("div",{"data-testid":"control-center",className:"h-full w-full",children:[(0,t.jsx)(r.ReactFlowProvider,{children:(0,t.jsx)(ep,{initialNodes:e,initialEdges:n})}),(0,t.jsx)("div",{children:o},"drawer")]})}e.s(["ControlCenter",()=>eg],48246)}]);
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),o=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),a=o((e,t)=>{var r=Object.defineProperty,n=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),o=(e,t,n)=>{let o;return(o="symbol"!=typeof t?t+"":t)in e?r(e,o,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[o]=n},a=n((e,t)=>{function r(e,t){e[t]?e[t]++:e[t]=1}function n(e,t){--e[t]||delete e[t]}function a(e,t,r,n){var o=""+t,a=""+r;if(!e&&o>a){var s=o;o=a,a=s}return o+"\x01"+a+"\x01"+(void 0===n?"\0":n)}function s(e,t){return a(e,t.v,t.w,t.name)}t.exports=class{constructor(e){o(this,"_isDirected",!0),o(this,"_isMultigraph",!1),o(this,"_isCompound",!1),o(this,"_label"),o(this,"_defaultNodeLabelFn",()=>{}),o(this,"_defaultEdgeLabelFn",()=>{}),o(this,"_nodes",{}),o(this,"_in",{}),o(this,"_preds",{}),o(this,"_out",{}),o(this,"_sucs",{}),o(this,"_edgeObjs",{}),o(this,"_edgeLabels",{}),o(this,"_nodeCount",0),o(this,"_edgeCount",0),o(this,"_parent"),o(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(o){var a=r.parent(o);return void 0===a||t.hasNode(a)?(n[o]=a,a):a in n?n[a]:e(a)}(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,o){return n.length>1?r.setEdge(e,o,t):r.setEdge(e,o),o}),this}setEdge(){var e,t,n,o,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&&(o=arguments[1],s=!0)):(e=i,t=arguments[1],n=arguments[3],arguments.length>2&&(o=arguments[2],s=!0)),e=""+e,t=""+t,void 0!==n&&(n=""+n);var l=a(this._isDirected,e,t,n);if(Object.hasOwn(this._edgeLabels,l))return s&&(this._edgeLabels[l]=o),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?o:this._defaultEdgeLabelFn(e,t,n);var d=function(e,t,r,n){var o=""+t,a=""+r;if(!e&&o>a){var s=o;o=a,a=s}var i={v:o,w:a};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]):a(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]):a(this._isDirected,e,t,r);return Object.hasOwn(this._edgeLabels,n)}removeEdge(e,t,r){var o=1==arguments.length?s(this._isDirected,arguments[0]):a(this._isDirected,e,t,r),i=this._edgeObjs[o];return i&&(e=i.v,t=i.w,delete this._edgeLabels[o],delete this._edgeObjs[o],n(this._preds[t],e),n(this._sucs[e],t),delete this._in[t][o],delete this._out[e][o],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:a(),version:s()}}),l=n((e,t)=>{var r=a();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),o={v:e};return void 0!==r&&(o.value=r),void 0!==n&&(o.parent=n),o}),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,o){return function(e,t,r,n){var o={},a=!0,s=0,i=e.nodes(),l=function(e){var t=r(e);o[e.v].distance+t<o[e.w].distance&&(o[e.w]={distance:o[e.v].distance+t,predecessor:e.v},a=!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){o[e]={distance:e===t?0:1/0}});for(var c=i.length,u=1;u<c&&(a=!1,s++,d(),a);u++);if(s===c-1&&(a=!1,d(),a))throw Error("The graph contains a negative weight cycle");return o}(e,String(t),n||r,o||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(o){t=[],function n(o){Object.hasOwn(r,o)||(r[o]=!0,t.push(o),e.successors(o).forEach(n),e.predecessors(o).forEach(n))}(o),t.length&&n.push(t)}),n}}),u=n((e,t)=>{t.exports=class{constructor(){o(this,"_arr",[]),o(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,o=n.length;return r[e]=o,n.push({key:e,priority:t}),this._decrease(o),!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,o=e;r<t.length&&(o=t[r].priority<t[o].priority?r:o,n<t.length&&(o=t[n].priority<t[o].priority?n:o),o!==e&&(this._swap(e,o),this._heapify(o)))}_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,o=r[e],a=r[t];r[e]=a,r[t]=o,n[a.key]=e,n[o.key]=t}}}),h=n((e,t)=>{var r=u();t.exports=function(e,t,o,a){return function(e,t,n,o){var a,s,i={},l=new r,d=function(e){var t=e.v!==a?e.v:e.w,r=i[t],o=n(e),d=s.distance+o;if(o<0)throw Error("dijkstra does not allow negative edge weights. Bad edge: "+e+" Weight: "+o);d<r.distance&&(r.distance=d,r.predecessor=a,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[a=l.removeMin()]).distance!==1/0;)o(a).forEach(d);return i}(e,String(t),o||n,a||function(t){return e.outEdges(t)})};var n=()=>1}),f=n((e,t)=>{var r=h();t.exports=function(e,t,n){return e.nodes().reduce(function(o,a){return o[a]=r(e,a,t,n),o},{})}}),p=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=[],o=r;o!==t;)n.push(o),o=e[o].predecessor;return n.push(t),n.reverse()}(e,t,r)}}}),g=n((e,t)=>{t.exports=function(e){var t=0,r=[],n={},o=[];return e.nodes().forEach(function(a){Object.hasOwn(n,a)||function a(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)):(a(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)o.push(d)}}(a)}),o}}),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 o,a,s,i,l;return o=e,a=t||r,s=n||function(t){return e.outEdges(t)},i={},(l=o.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=a(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 o=n[e],a=t[r],s=n[r],i=o.distance+a.distance;i<s.distance&&(s.distance=i,s.predecessor=a.predecessor)})})}),i};var r=()=>1}),v=n((e,t)=>{function r(e){var t={},r={},o=[];if(e.sinks().forEach(function a(s){if(Object.hasOwn(r,s))throw new n;Object.hasOwn(t,s)||(r[s]=!0,t[s]=!0,e.predecessors(s).forEach(a),delete r[s],o.push(s))}),Object.keys(t).length!==e.nodeCount())throw new n;return o}var n=class extends Error{constructor(){super(...arguments)}};t.exports=r,r.CycleException=n}),y=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}}),b=n((e,t)=>{t.exports=function(e,t,r,n,o){Array.isArray(t)||(t=[t]);var a=(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);o=function e(t,r,n,o,a,s,i){return Object.hasOwn(o,r)||(o[r]=!0,n||(i=s(i,r)),a(r).forEach(function(r){i=e(t,r,n,o,a,s,i)}),n&&(i=s(i,r))),i}(e,t,"post"===r,s,a,n,o)}),o}}),w=n((e,t)=>{var r=b();t.exports=function(e,t,n){return r(e,t,n,function(e,t){return e.push(t),e},[])}}),j=n((e,t)=>{var r=w();t.exports=function(e,t){return r(e,t,"post")}}),k=n((e,t)=>{var r=w();t.exports=function(e,t){return r(e,t,"pre")}}),E=n((e,t)=>{var r=a(),n=u();t.exports=function(e,t){var o,a=new r,s={},i=new n;function l(e){var r=e.v===o?e.w:e.v,n=i.priority(r);if(void 0!==n){var a=t(e);a<n&&(s[r]=o,i.decrease(r,a))}}if(0===e.nodeCount())return a;e.nodes().forEach(function(e){i.add(e,1/0),a.setNode(e)}),i.decrease(e.nodes()[0],0);for(var d=!1;i.size()>0;){if(Object.hasOwn(s,o=i.removeMin()))a.setEdge(o,s[o]);else{if(d)throw Error("Input graph is not connected: "+e);d=!0}e.nodeEdges(o).forEach(l)}return a}}),N=n((e,t)=>{var r=h(),n=d();t.exports=function(e,t,o,a){return function(e,t,o,a){if(void 0===o)return r(e,t,o,a);for(var s=!1,i=e.nodes(),l=0;l<i.length;l++){for(var d=a(i[l]),c=0;c<d.length;c++){var u=d[c],h=u.v===i[l]?u.v:u.w,f=h===u.v?u.w:u.v;0>o({v:h,w:f})&&(s=!0)}if(s)return n(e,t,o,a)}return r(e,t,o,a)}(e,t,o,a||function(t){return e.outEdges(t)})}}),C=n((e,t)=>{t.exports={bellmanFord:d(),components:c(),dijkstra:h(),dijkstraAll:f(),extractPath:p(),findCycles:m(),floydWarshall:x(),isAcyclic:y(),postorder:j(),preorder:k(),prim:E(),shortestPaths:N(),reduce:b(),tarjan:g(),topsort:v()}}),_=i();t.exports={Graph:_.Graph,json:l(),alg:C(),version:_.version}}),s=o((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=o((e,t)=>{var r=a().Graph,n=s();t.exports=function(e,t){var a,s;let d,c,u,h,f;if(1>=e.nodeCount())return[];let p=(a=e,s=t||o,d=new r,c=0,u=0,a.nodes().forEach(e=>{d.setNode(e,{v:e,in:0,out:0})}),a.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),f=c+1,d.nodes().forEach(e=>{l(h,f,d.node(e))}),{graph:d,buckets:h,zeroIdx:f});return(function(e,t,r){let n=[],o=t[t.length-1],a=t[0],s;for(;e.nodeCount();){for(;s=a.dequeue();)i(e,t,r,s);for(;s=o.dequeue();)i(e,t,r,s);if(e.nodeCount()){for(let o=t.length-2;o>0;--o)if(s=t[o].dequeue()){n=n.concat(i(e,t,r,s,!0));break}}}return n})(p.graph,p.buckets,p.zeroIdx).flatMap(t=>e.outEdges(t.v,t.w))};var o=()=>1;function i(e,t,r,n,o){let a=o?[]:void 0;return e.inEdges(n.v).forEach(n=>{let s=e.edge(n),i=e.node(n.v);o&&a.push({v:n.v,w:n.w}),i.out-=s,l(t,r,i)}),e.outEdges(n.v).forEach(n=>{let o=e.edge(n),a=n.w,s=e.node(a);s.in-=o,l(t,r,s)}),e.removeNode(n.v),a}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=o((e,t)=>{var r=a().Graph;function n(e,t,r,n){for(var o=n;e.hasNode(o);)o=l(n);return r.dummy=t,e.setNode(o,r),o}t.exports={addBorderNode:function(e,t,r,o){let a={width:0,height:0};return arguments.length>=4&&(a.rank=r,a.order=o),n(e,"border",a,t)},addDummyNode:n,applyWithChunking:o,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),o=n.rank;void 0!==o&&(t[o][n.order]=r)}),t},intersectRect:function(e,t){let r,n,o=e.x,a=e.y,s=t.x-o,i=t.y-a,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:o+r,y:a+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=o(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=o(Math.min,e.nodes().map(t=>e.node(t).rank).filter(e=>void 0!==e)),r=[];e.nodes().forEach(n=>{let o=e.node(n).rank-t;r[o]||(r[o]=[]),r[o].push(n)});let n=0,a=e.graph().nodeRankFactor;Array.from(r).forEach((t,r)=>{void 0===t&&r%a!=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},o=e.edge(r);t.setEdge(r.v,r.w,{weight:n.weight+o.weight,minlen:Math.max(n.minlen,o.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 o(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 o=e.slice(n,n+t);r.push(o)}return r}(t);return e.apply(null,r.map(t=>e.apply(null,t)))}}function s(e){return o(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 o=[];for(let t=e;n(t);t+=r)o.push(t);return o}function c(e,t){return e.reduce((e,r,n)=>(e[r]=t[n],e),{})}}),d=o((e,t)=>{var r=i(),n=l().uniqueId;t.exports={run:function(e){var t,o;let a,s,i;("greedy"===e.graph().acyclicer?r(e,(t=e,e=>t.edge(e).weight)):(a=[],s={},i={},(o=e).nodes().forEach(function e(t){Object.hasOwn(i,t)||(i[t]=!0,s[t]=!0,o.outEdges(t).forEach(t=>{Object.hasOwn(s,t.w)?a.push(t):e(t.w)}),delete s[t])}),a)).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=o((e,t)=>{var r=l();t.exports={run:function(e){e.graph().dummyChains=[],e.edges().forEach(t=>(function(e,t){let n,o,a,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),a=0,++i;i<d;++a,++i)u.points=[],o={width:0,height:0,edgeLabel:u,edgeObj:t,rank:i},n=r.addDummyNode(e,"edge",o,"_d"),i===h&&(o.width=u.width,o.height=u.height,o.dummy="edge-label",o.labelpos=u.labelpos),e.setEdge(s,n,{weight:u.weight},c),0===a&&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,o;for(e.setEdge(r.edgeObj,n);r.dummy;)o=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=o,r=e.node(t)})}}}),u=o((e,t)=>{var{applyWithChunking:r}=l();t.exports={longestPath:function(e){var t={};e.sources().forEach(function n(o){var a=e.node(o);if(Object.hasOwn(t,o))return a.rank;t[o]=!0;var s=r(Math.min,e.outEdges(o).map(t=>null==t?1/0:n(t.w)-e.edge(t).minlen));return s===1/0&&(s=0),a.rank=s})},slack:function(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}}}),h=o((e,t)=>{var r=a().Graph,n=u().slack;t.exports=function(e){var t,o,a,s,i=new r({directed:!1}),l=e.nodes()[0],d=e.nodeCount();for(i.setNode(l,{});t=i,o=e,t.nodes().forEach(function e(r){o.nodeEdges(r).forEach(a=>{var s=a.v,i=r===s?a.w:s;t.hasNode(i)||n(o,a)||(t.setNode(i,{}),t.setEdge(r,i,{}),e(i))})}),t.nodeCount()<d;)a=function(e,t){return t.edges().reduce((r,o)=>{let a=1/0;return e.hasNode(o.v)!==e.hasNode(o.w)&&(a=n(t,o)),a<r[0]?[a,o]:r},[1/0,null])[1]}(i,e),s=i.hasNode(a.v)?n(e,a):-n(e,a),function(e,t,r){e.nodes().forEach(e=>t.node(e).rank+=r)}(i,e,s);return i}}),f=o((e,t)=>{var r=h(),n=u().slack,o=u().longestPath,s=a().alg.preorder,i=a().alg.postorder,d=l().simplify;function c(e){o(e=d(e));var t,n,a=r(e);for(g(a),f(a,e);t=m(a);)n=x(a,e,t),v(a,e,t,n)}function f(e,t){var r=i(e,e.nodes());(r=r.slice(0,r.length-1)).forEach(r=>{var n,o,a,s;return n=e,o=t,a=r,s=n.node(a).parent,void(n.edge(a,s).cutvalue=p(n,o,a))})}function p(e,t,r){var n=e.node(r).parent,o=!0,a=t.edge(r,n),s=0;return a||(o=!1,a=t.edge(n,r)),s=a.weight,t.nodeEdges(r).forEach(a=>{var i=a.v===r,l=i?a.w:a.v;if(l!==n){var d,c,u,h=i===o,f=t.edge(a).weight;if(s+=h?f:-f,d=e,c=r,u=l,d.hasEdge(c,u)){var p=e.edge(r,l).cutvalue;s+=h?-p:p}}}),s}function g(e,t){arguments.length<2&&(t=e.nodes()[0]),function e(t,r,n,o,a){var s=n,i=t.node(o);return r[o]=!0,t.neighbors(o).forEach(a=>{Object.hasOwn(r,a)||(n=e(t,r,n,a,o))}),i.low=s,i.lim=n++,a?i.parent=a: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 o=r.v,a=r.w;t.hasEdge(o,a)||(o=r.w,a=r.v);var s=e.node(o),i=e.node(a),l=s,d=!1;return s.lim>i.lim&&(l=i,d=!0),t.edges().filter(t=>d===y(e,e.node(t.v),l)&&d!==y(e,e.node(t.w),l)).reduce((e,r)=>n(t,r)<n(t,e)?r:e)}function v(e,t,r,n){var o,a,i,l,d=r.v,c=r.w;e.removeEdge(d,c),e.setEdge(n.v,n.w,{}),g(e),f(e,t),o=e,a=t,i=o.nodes().find(e=>!a.node(e).parent),(l=(l=s(o,i)).slice(1)).forEach(e=>{var t=o.node(e).parent,r=a.edge(e,t),n=!1;r||(r=a.edge(t,e),n=!0),a.node(e).rank=a.node(t).rank+(n?r.minlen:-r.minlen)})}function y(e,t,r){return r.low<=t.lim&&t.lim<=r.lim}t.exports=c,c.initLowLimValues=g,c.initCutValues=f,c.calcCutValue=p,c.leaveEdge=m,c.enterEdge=x,c.exchangeEdges=v}),p=o((e,t)=>{var r=u().longestPath,n=h(),o=f();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:o(e);break;case"tight-tree":r(t=e),n(t);break;case"longest-path":a(e);case"none":}};var a=r}),g=o((e,t)=>{t.exports=function(e){var t;let r,n,o=(r={},n=0,(t=e).children().forEach(function e(o){let a=n;t.children(o).forEach(e),r[o]={low:a,lim:n++}}),r);e.graph().dummyChains.forEach(t=>{let r=e.node(t),n=r.edgeObj,a=function(e,t,r,n){let o=[],a=[],s=Math.min(t[r].low,t[n].low),i=Math.max(t[r].lim,t[n].lim),l,d;l=r;do o.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;)a.push(l);return{path:o.concat(a.reverse()),lca:d}}(e,o,n.v,n.w),s=a.path,i=a.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=o((e,t)=>{var r=l();t.exports={run:function(e){var t,n,o;let a=r.addDummyNode(e,"root",{},"_root"),s=(n={},(t=e).children().forEach(e=>(function e(r,o){var a=t.children(r);a&&a.length&&a.forEach(t=>e(t,o+1)),n[r]=o})(e,1)),n),i=Object.values(s),l=r.applyWithChunking(Math.max,i)-1,d=2*l+1;e.graph().nestingRoot=a,e.edges().forEach(t=>e.edge(t).minlen*=d);let c=(o=e).edges().reduce((e,t)=>e+o.edge(t).weight,0)+1;e.children().forEach(t=>(function e(t,n,o,a,s,i,l){let d=t.children(l);if(!d.length){l!==n&&t.setEdge(n,l,{weight:0,minlen:o});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,o,a,s,i,r);let d=t.node(r),h=d.borderTop?d.borderTop:r,f=d.borderBottom?d.borderBottom:r,p=d.borderTop?a:2*a,g=h!==f?1:s-i[l]+1;t.setEdge(c,h,{weight:p,minlen:g,nestingEdge:!0}),t.setEdge(f,u,{weight:p,minlen:g,nestingEdge:!0})}),t.parent(l)||t.setEdge(n,c,{weight:0,minlen:s+i[l]})})(e,a,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=o((e,t)=>{var r=l();function n(e,t,n,o,a,s){let i=a[t][s-1],l=r.addDummyNode(e,"border",{width:0,height:0,rank:s,borderType:t},n);a[t][s]=l,e.setParent(l,o),i&&e.setEdge(i,l,{weight:1})}t.exports=function(e){e.children().forEach(function t(r){let o=e.children(r),a=e.node(r);if(o.length&&o.forEach(t),Object.hasOwn(a,"minRank")){a.borderLeft=[],a.borderRight=[];for(let t=a.minRank,o=a.maxRank+1;t<o;++t)n(e,"borderLeft","_bl",r,a,t),n(e,"borderRight","_br",r,a,t)}})}}),v=o((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 o(e){e.y=-e.y}function a(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=>o(t.node(e))),t.edges().forEach(e=>{let r=t.edge(e);r.points.forEach(o),Object.hasOwn(r,"y")&&o(r)})),("lr"===s||"rl"===s)&&((n=e).nodes().forEach(e=>a(n.node(e))),n.edges().forEach(e=>{let t=n.edge(e);t.points.forEach(a),Object.hasOwn(t,"x")&&a(t)}),r(e))}}}),y=o((e,t)=>{var r=l();t.exports=function(e){let t={},n=e.nodes().filter(t=>!e.children(t).length),o=n.map(t=>e.node(t).rank),a=r.applyWithChunking(Math.max,o),s=r.range(a+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}}),b=o((e,t)=>{var r=l().zipObject;t.exports=function(e,t){let n=0;for(let o=1;o<t.length;++o)n+=function(e,t,n){let o=r(n,n.map((e,t)=>t)),a=t.flatMap(t=>e.outEdges(t).map(t=>({pos:o[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 a.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[o-1],t[o]);return n}}),w=o((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),o=e.node(r.v);return{sum:t.sum+n.weight*o.order,weight:t.weight+n.weight}},{sum:0,weight:0});return{v:t,barycenter:n.sum/n.weight,weight:n.weight}}})}}),j=o((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))}}),k=o((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 o;let a=r.partition(e,e=>Object.hasOwn(e,"barycenter")),s=a.lhs,i=a.rhs.sort((e,t)=>t.i-e.i),l=[],d=0,c=0,u=0;s.sort((o=!!t,(e,t)=>e.barycenter<t.barycenter?-1:e.barycenter>t.barycenter?1:o?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=o((e,t)=>{var r=w(),n=j(),o=k();t.exports=function e(t,a,s,i){var l,d;let c=t.children(a),u=t.node(a),h=u?u.borderLeft:void 0,f=u?u.borderRight:void 0,p={};h&&(c=c.filter(e=>e!==h&&e!==f));let g=r(t,c);g.forEach(r=>{if(t.children(r.v).length){var n,o;let a=e(t,r.v,s,i);p[r.v]=a,Object.hasOwn(a,"barycenter")&&(n=r,o=a,void 0!==n.barycenter?(n.barycenter=(n.barycenter*n.weight+o.barycenter*o.weight)/(n.weight+o.weight),n.weight+=o.weight):(n.barycenter=o.barycenter,n.weight=o.weight))}});let m=n(g,s);l=m,d=p,l.forEach(e=>{e.vs=e.vs.flatMap(e=>d[e]?d[e].vs:e)});let x=o(m,i);if(h&&(x.vs=[h,x.vs,f].flat(!0),t.predecessors(h).length)){let e=t.node(t.predecessors(h)[0]),r=t.node(t.predecessors(f)[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=o((e,t)=>{var r=a().Graph,n=l();t.exports=function(e,t,o,a){a||(a=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 a.forEach(r=>{let n=e.node(r),a=e.parent(r);(n.rank===t||n.minRank<=t&&t<=n.maxRank)&&(i.setNode(r),i.setParent(r,a||s),e[o](r).forEach(t=>{let n=t.v===r?t.w:t.v,o=i.edge(n,r),a=void 0!==o?o.weight:0;i.setEdge(n,r,{weight:e.edge(t).weight+a})}),Object.hasOwn(n,"minRank")&&i.setNode(r,{borderLeft:n.borderLeft[t],borderRight:n.borderRight[t]}))}),i}}),C=o((e,t)=>{t.exports=function(e,t,r){let n={},o;r.forEach(r=>{let a=e.parent(r),s,i;for(;a;){if((s=e.parent(a))?(i=n[s],n[s]=a):(i=o,o=a),i&&i!==a)return void t.setEdge(i,a);a=s}})}}),_=o((e,t)=>{var r=y(),n=b(),o=E(),s=N(),i=C(),d=a().Graph,c=l();function u(e,t,r){let n=new Map,o=(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&&o(r.rank,t),"number"==typeof r.minRank&&"number"==typeof r.maxRank)for(let e=r.minRank;e<=r.maxRank;e++)e!==r.rank&&o(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,a={}){if("function"==typeof a.customOrder)return void a.customOrder(t,e);let s=c.maxRank(t),l=u(t,c.range(1,s+1),"inEdges"),f=u(t,c.range(s-1,-1,-1),"outEdges"),p=r(t);if(h(t,p),a.disableOptimalOrderHeuristic)return;let g=1/0,m,x=a.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 a=e.graph().root,s=o(e,a,n,t);s.vs.forEach((t,r)=>e.node(t).order=r),i(e,n,s.vs)})})(e%2?l:f,e%4>=2,x),p=c.buildLayerMatrix(t);let a=n(t,p);a<g?(r=0,m=Object.assign({},p),g=a):a===g&&(m=structuredClone(p))}h(t,m)}}),O=o((e,t)=>{var r=a().Graph,n=l();function o(e,t){let r={};return t.length&&t.reduce(function(t,n){let o=0,a=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(a,d+1).forEach(t=>{e.predecessors(t).forEach(n=>{let a=e.node(n),s=a.order;(s<o||u<s)&&!(a.dummy&&e.node(t).dummy)&&i(r,n,t)})}),a=d+1,o=u)}),n}),r}function s(e,t){let r={};function o(t,o,a,s,l){let d;n.range(o,a).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,a,s=0;return r.forEach((i,l)=>{if("border"===e.node(i).dummy){let t=e.predecessors(i);t.length&&(a=e.node(t[0]).order,o(r,s,l,n,a),s=l,n=a)}o(r,s,r.length,a,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 o={},a={},s={};return t.forEach(e=>{e.forEach((e,t)=>{o[e]=e,a[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];a[e]===e&&t<s[n]&&!d(r,e,n)&&(a[n]=e,a[e]=o[e]=o[n],t=s[n])}}})}),{root:o,align:a}}function u(e,t,n,o,a){var s,i,l,d,c,u,h;let f,p,g,m={},x=(s=e,i=t,l=n,d=a,f=new r,g=(c=(p=s.graph()).nodesep,u=p.edgesep,h=d,(e,t,r)=>{let n=e.node(t),o=e.node(r),a,s;if(a=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&&(a+=h?s:-s),s=0,a+=(n.dummy?u:c)/2,a+=(o.dummy?u:c)/2,a+=o.width/2,Object.hasOwn(o,"labelpos"))switch(o.labelpos.toLowerCase()){case"l":s=o.width/2;break;case"r":s=-o.width/2}return s&&(a+=h?s:-s),s=0,a}),i.forEach(e=>{let t;e.forEach(e=>{let r=l[e];if(f.setNode(r),t){var n=l[t],o=f.edge(n,r);f.setEdge(n,r,Math.max(g(s,e,t),o||0))}t=e})}),f),v=a?"borderLeft":"borderRight";function y(e,t){let r=x.nodes().slice(),n={},o=r.pop();for(;o;){if(n[o])e(o);else for(let e of(n[o]=!0,r.push(o),t(o)))r.push(e);o=r.pop()}}return y(function(e){m[e]=x.inEdges(e).reduce((e,t)=>Math.max(e,m[t.v]+x.edge(t)),0)},x.predecessors.bind(x)),y(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(o).forEach(e=>m[e]=m[n[e]]),m}function h(e,t){return Object.values(t).reduce((t,r)=>{let n=-1/0,o=1/0;Object.entries(r).forEach(([t,r])=>{var a,s;let i=(a=e,s=t,a.node(s).width/2);n=Math.max(r+i,n),o=Math.min(r-i,o)});let a=n-o;return a<t[0]&&(t=[a,r]),t},[1/0,null])[1]}function f(e,t){let r=Object.values(t),o=n.applyWithChunking(Math.min,r),a=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=o-n.applyWithChunking(Math.min,d);"l"!==s&&(c=a-n.applyWithChunking(Math.max,d)),c&&(e[i]=n.mapValues(l,e=>e+c))})})}function p(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(o(e,t),s(e,t)),a={},i;["u","d"].forEach(o=>{i="u"===o?t:Object.values(t).reverse(),["l","r"].forEach(t=>{"r"===t&&(i=i.map(e=>Object.values(e).reverse()));let s=("u"===o?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)),a[o+t]=d})});let l=h(e,a);return f(a,l),p(a,e.graph().align)},findType1Conflicts:o,findType2Conflicts:s,addConflict:i,hasConflict:d,verticalAlignment:c,horizontalCompaction:u,alignCoordinates:f,findSmallestWidthAlignment:h,balance:p}}),M=o((e,t)=>{var r=l(),n=O().positionX;t.exports=function(e){var t;let o,a,s,i;t=e=r.asNonCompoundGraph(e),o=r.buildLayerMatrix(t),a=t.graph().ranksep,s=t.graph().rankalign,i=0,o.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+a}),Object.entries(n(e)).forEach(([t,r])=>e.node(t).x=r)}}),R=o((e,t)=>{var r=d(),n=c(),o=p(),s=l().normalizeRanks,i=g(),u=l().removeEmptyRanks,h=m(),f=x(),y=v(),b=_(),w=M(),j=l(),k=a().Graph;t.exports=function(e,t={}){let a=t.debugTiming?j.time:j.notime;return a("layout",()=>{let l=a(" buildLayoutGraph",()=>{var t;let r,n;return t=e,r=new k({multigraph:!0,compound:!0}),n=I(t.graph()),r.setGraph(Object.assign({},N,T(n,E),j.pick(n,C))),t.nodes().forEach(e=>{let n=T(I(t.node(e)),O);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=I(t.edge(e));r.setEdge(e,Object.assign({},P,T(n,S),j.pick(n,L)))}),r});return a(" runLayout",()=>{var e,d,c;return e=l,d=a,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",()=>o(j.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};j.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",()=>f(e)),d(" order",()=>b(e,c)),d(" insertSelfEdges",()=>{var t;return t=e,void j.buildLayerMatrix(t).forEach(e=>{var r=0;e.forEach((e,n)=>{var o=t.node(e);o.order=n+r,(o.selfEdges||[]).forEach(e=>{j.addDummyNode(t,"selfedge",{width:e.label.width,height:e.label.height,rank:o.rank,order:n+ ++r,e:e.e,label:e.label},"_se")}),delete o.selfEdges})})}),d(" adjustCoordinateSystem",()=>y.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),o=n.x+n.width/2,a=n.y,s=r.x-o,i=n.height/2;t.setEdge(r.e,r.label),t.removeNode(e),r.label.points=[{x:o+2*s/3,y:a-i},{x:o+5*s/6,y:a-i},{x:o+s,y:a},{x:o+5*s/6,y:a+i},{x:o+2*s/3,y:a+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),o=t.node(r.borderBottom),a=t.node(r.borderLeft[r.borderLeft.length-1]),s=t.node(r.borderRight[r.borderRight.length-1]);r.width=Math.abs(s.x-a.x),r.height=Math.abs(o.y-n.y),r.x=a.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",()=>y.undo(e)),d(" translateGraph",()=>(function(e){let t=1/0,r=0,n=1/0,o=0,a=e.graph(),s=a.marginx||0,i=a.marginy||0;function l(e){let a=e.x,s=e.y,i=e.width,l=e.height;t=Math.min(t,a-i/2),r=Math.max(r,a+i/2),n=Math.min(n,s-l/2),o=Math.max(o,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 o=e.node(r);o.x-=t,o.y-=n}),e.edges().forEach(r=>{let o=e.edge(r);o.points.forEach(e=>{e.x-=t,e.y-=n}),Object.hasOwn(o,"x")&&(o.x-=t),Object.hasOwn(o,"y")&&(o.y-=n)}),a.width=r-t+s,a.height=o-n+i})(e)),d(" assignNodeIntersects",()=>{var t;(t=e).edges().forEach(e=>{let r=t.edge(e),n=t.node(e.v),o=t.node(e.w),a,s;r.points?(a=r.points[0],s=r.points[r.points.length-1]):(r.points=[],a=o,s=n),r.points.unshift(j.intersectRect(n,a)),r.points.push(j.intersectRect(o,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)))}),a(" updateInputGraph",()=>{var t,r;return t=e,r=l,void(t.nodes().forEach(e=>{let n=t.node(e),o=r.node(e);n&&(n.x=o.x,n.y=o.y,n.order=o.order,n.rank=o.rank,r.children(e).length&&(n.width=o.width,n.height=o.height))}),t.edges().forEach(e=>{let n=t.edge(e),o=r.edge(e);n.points=o.points,Object.hasOwn(o,"x")&&(n.x=o.x,n.y=o.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"],O=["width","height","rank"],R={width:0,height:0},S=["minlen","weight","width","height","labeloffset"],P={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},L=["labelpos"];function T(e,t){return j.mapValues(j.pick(e,t),Number)}function I(e){var t={};return e&&Object.entries(e).forEach(([e,r])=>{"string"==typeof e&&(e=e.toLowerCase()),t[e]=r}),t}}),S=o((e,t)=>{var r=l(),n=a().Graph;t.exports={debugOrdering:function(e){let t=r.buildLayerMatrix(e),o=new n({compound:!0,multigraph:!0}).setGraph({});return e.nodes().forEach(t=>{o.setNode(t,{label:t}),o.setParent(t,"layer"+e.node(t).rank)}),e.edges().forEach(e=>o.setEdge(e.v,e.w,{},e.name)),t.forEach((e,t)=>{o.setNode("layer"+t,{rank:"same"}),e.reduce((e,t)=>(o.setEdge(e,t,{style:"invis"}),t))}),o}}}),P=o((e,t)=>{t.exports="2.0.4"});let L=o((e,t)=>{t.exports={graphlib:a(),layout:R(),debug:S(),util:{time:l().time,notime:l().notime},version:P()}})(),T={direction:"LR",ranksep:200,nodesep:15},I={featureNode:{width:288,height:140},repositoryNode:{width:328,height:50}};function D(e,t){let r=e.data;return r&&"number"==typeof r.width&&"number"==typeof r.height?{width:r.width,height:r.height}:I[e.type??""]??t}function A(e,t,r={}){let{direction:n="TB",nodeSize:o={width:172,height:36},ranksep:a=80,nodesep:s=30}=r;if(0===e.length)return{nodes:[],edges:[]};let i=new L.graphlib.Graph({multigraph:!0});i.setDefaultEdgeLabel(()=>({})),i.setGraph({rankdir:n,ranksep:a,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=D(e,o);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);L.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),f="LR"===n||"RL"===n,p=new Map;for(let e of d){let t=i.node(e.id),r=D(e,o);p.set(e.id,{cx:t.x,cy:t.y,w:r.width,h:r.height})}let g=new Map;for(let e of t)p.has(e.source)&&p.has(e.target)&&(g.has(e.source)||g.set(e.source,[]),g.get(e.source).push(e.target));let m=new Map;for(let e=0;e<d.length;e++)m.set(d[e].id,e);for(let[,e]of g)e.sort((e,t)=>(m.get(e)??0)-(m.get(t)??0));let x=new Set;for(let e of g.values())for(let t of e)x.add(t);let v=[...new Set(p.keys())].filter(e=>!x.has(e)),y=new Map;for(let e of v)!function e(t){if(y.has(t))return y.get(t);let r=p.get(t),n=f?r.h:r.w,o=g.get(t);if(!o||0===o.length)return y.set(t,n),n;let a=0;for(let t of o)a+=e(t);let i=Math.max(n,a+=(o.length-1)*s);return y.set(t,i),i}(e);let b=0;for(let e of v){let t=y.get(e)??0;!function e(t,r){let n=p.get(t);f?n.cy=r:n.cx=r;let o=g.get(t);if(!o||0===o.length)return;let a=0;for(let e of o)a+=y.get(e)??0;let i=r-(a+=(o.length-1)*s)/2;for(let t of o){let r=y.get(t)??0;e(t,i+r/2),i+=r+s}}(e,b+t/2),b+=t+s}let w=[];for(let e of d){let t=p.get(e.id);w.push({...e,targetPosition:u,sourcePosition:h,position:{x:t.cx-t.w/2,y:t.cy-t.h/2}})}if(c.length>0){let e=0,t=1/0;for(let r of w){let n=D(r,o);e=Math.max(e,r.position.y+n.height),t=Math.min(t,r.position.x)}t===1/0&&(t=0);for(let r=0;r<c.length;r++){let n=c[r],a=D(n,o);w.push({...n,targetPosition:u,sourcePosition:h,position:{x:t,y:e+30+r*(a.height+20)}})}}return{nodes:w,edges:[...t]}}var F=e.i(84315),$=e.i(21023);let z=(0,$.createServerReference)("406a455a97a31351e183ad42403ffe2872bc580b77",$.callServer,void 0,$.findSourceMapURL,"addRepository"),B=(0,$.createServerReference)("40fccde6a871c42ac2b4dc5d038c9bfa3c484e720f",$.callServer,void 0,$.findSourceMapURL,"deleteRepository"),G=(0,$.createServerReference)("40039a8162630e709dccfa20710a5b80967ea01a5b",$.callServer,void 0,$.findSourceMapURL,"getFeatureMetadata"),q=(0,$.createServerReference)("0018047e6d84aa060c66d29180464026af0ad357fc",$.callServer,void 0,$.findSourceMapURL,"fetchGraphData");var W=e.i(39443),V=e.i(8361),U=e.i(18354),H=e.i(99045);function X(e,t){let r=new Map;for(let e of t)"dependencyEdge"===e.type&&r.set(e.target,e.source);let n=new Map,o=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&&o.set(t.id,{nodeId:t.id,data:t.data});return{featureMap:n,repoMap:o}}function K(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)}let Y=(0,U.createLogger)("[Polling]"),J=0,Q=0;function Z(e,o){let a=(0,r.useRouter)(),s=(0,V.useSoundAction)("delete"),i=(0,V.useSoundAction)("create"),{nodes:l,edges:d,reconcile:c,updateFeature:u,addPendingFeature:h,removeFeature:f,restoreFeature:p,addRepository:g,removeRepository:m,replaceRepository:x,getFeatureRepositoryPath:v,getRepositoryData:y,getRepoMapSize:b,setCallbacks:w}=function(e,r){let n=(0,t.useMemo)(()=>X(e,r),[]),[o,a]=(0,t.useState)(n.featureMap),[s,i]=(0,t.useState)(n.repoMap),[l,d]=(0,t.useState)(new Map),c=(0,t.useRef)(new Map),u=(0,t.useRef)(new Set),h=(0,t.useRef)({}),f=(0,t.useMemo)(()=>({onNodeAction:e=>h.current.onNodeAction?.(e),onNodeSettings:e=>h.current.onNodeSettings?.(e),onFeatureDelete:e=>h.current.onFeatureDelete?.(e),onRepositoryAdd:e=>h.current.onRepositoryAdd?.(e),onRepositoryClick:e=>h.current.onRepositoryClick?.(e),onRepositoryDelete:e=>h.current.onRepositoryDelete?.(e)}),[]),p=(0,t.useRef)(o);p.current=o;let g=(0,t.useRef)(s);g.current=s;let m=(0,t.useMemo)(()=>(function(e,t,r,n){let o=[],a=[],s=new Map;for(let[e,r]of t)r.data.repositoryPath&&s.set(r.data.repositoryPath,e);let i=new Map;for(let[e,r]of t){let t={...r.data,...n?.onRepositoryAdd&&{onAdd:()=>n.onRepositoryAdd(e)},...n?.onRepositoryClick&&{onClick:()=>n.onRepositoryClick(e)},...n?.onRepositoryDelete&&{onDelete:n.onRepositoryDelete}};o.push({id:e,type:"repositoryNode",position:{x:0,y:0},data:t})}for(let[t,l,d]of[...[...e.entries()].map(([e,t])=>[e,t,!1]),...[...r.entries()].filter(([t])=>!e.has(t)).map(([e,t])=>[e,t,!0])]){let e="creating"===l.data.state||d,r={...l.data,...!e&&n?.onNodeAction&&{onAction:()=>n.onNodeAction(t)},...!e&&n?.onNodeSettings&&{onSettings:()=>n.onNodeSettings(t)},...!e&&n?.onFeatureDelete&&{onDelete:n.onFeatureDelete}};if(o.push({id:t,type:"featureNode",position:{x:0,y:0},data:r}),l.parentNodeId)a.push({id:`dep-${l.parentNodeId}-${t}`,source:l.parentNodeId,target:t,type:"dependencyEdge"});else{let e=l.data.repositoryPath,r=s.get(e)??function(e){if(i.has(e))return i.get(e);let t=`virtual-repo-${e}`,r=e.split("/").filter(Boolean).at(-1)??e;return o.push({id:t,type:"repositoryNode",position:{x:0,y:0},data:{name:r,repositoryPath:e}}),i.set(e,t),t}(e);a.push({id:`edge-${r}-${t}`,source:r,target:t,style:{strokeDasharray:"5 5"}})}}let l=a.length>0;for(let e of o)e.data.showHandles=l;return{nodes:o,edges:a}})(o,s,l,f),[o,s,l,f]),x=(0,t.useRef)({key:"",positions:new Map}),{nodes:v,edges:y}=(0,t.useMemo)(()=>{let e=m.nodes.map(e=>e.id).sort().join(","),t=m.edges.map(e=>`${e.source}-${e.target}`).sort().join(","),r=`${e}|${t}`;if(r!==x.current.key){let e=A(m.nodes,m.edges,T),t=new Map;for(let r of e.nodes)t.set(r.id,{position:r.position,targetPosition:r.targetPosition,sourcePosition:r.sourcePosition});return x.current={key:r,positions:t},e}let{positions:n}=x.current;return{nodes:m.nodes.map(e=>{let t=n.get(e.id);return t?{...e,...t}:e}),edges:m.edges}},[m]),b=(0,t.useCallback)((e,t)=>{let{featureMap:r,repoMap:n}=X(e,t),o=new Set([...r.values()].map(e=>`${e.data.name}\0${e.data.repositoryPath}`));a(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}`;o.has(t)||n.set(e,r)}let a=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"}}):u.current.has(t)||(n.set(t,r),a.add(t)));for(let[e,t]of(u.current=a,c.current)){let r=n.get(e);r&&(n.set(e,{...r,data:{...r.data,...t}}),c.current.delete(e))}return n}),d(e=>{if(0===e.size)return e;let t=!1,r=new Map(e);for(let[n,a]of e){let e=`${a.data.name}\0${a.data.repositoryPath}`;o.has(e)&&(r.delete(n),t=!0)}return t?r:e}),i(n)},[]),w=(0,t.useCallback)((e,t)=>{a(r=>{let n=r.get(e);if(!n)return c.current.set(e,{...c.current.get(e),...t}),r;if(c.current.delete(e),K(n.data,t))return r;let o=new Map(r);return o.set(e,{...n,data:{...n.data,...t}}),o}),d(r=>{let n=r.get(e);if(!n||K(n.data,t))return r;let o=new Map(r);return o.set(e,{...n,data:{...n.data,...t}}),o})},[]),j=(0,t.useCallback)((e,t,r)=>{d(n=>{let o=new Map(n);return o.set(e,{nodeId:e,data:t,parentNodeId:r}),o})},[]),k=(0,t.useCallback)(e=>{d(t=>{if(!t.has(e))return t;let r=new Map(t);return r.delete(e),r})},[]),E=(0,t.useCallback)(e=>{a(t=>{if(!t.has(e))return t;let r=new Map(t);return r.delete(e),r})},[]),N=(0,t.useCallback)((e,t)=>{a(r=>{let n=new Map(r);return n.set(e,t),n})},[]),C=(0,t.useCallback)((e,t)=>{i(r=>{let n=new Map(r);return n.set(e,{nodeId:e,data:t}),n})},[]),_=(0,t.useCallback)(e=>{i(t=>{if(!t.has(e))return t;let r=new Map(t);return r.delete(e),r})},[]),O=(0,t.useCallback)((e,t,r)=>{i(n=>{if(!n.has(e))return n;let o=new Map(n);return o.delete(e),o.set(t,{nodeId:t,data:r}),o})},[]),M=(0,t.useCallback)(e=>p.current.get(e)?.data.repositoryPath,[]),R=(0,t.useCallback)(e=>g.current.get(e)?.data,[]);return{nodes:v,edges:y,reconcile:b,updateFeature:w,addPendingFeature:j,removePendingFeature:k,removeFeature:E,restoreFeature:N,addRepository:C,removeRepository:_,replaceRepository:O,getFeatureRepositoryPath:M,getRepositoryData:R,getRepoMapSize:(0,t.useCallback)(()=>g.current.size,[]),setCallbacks:(0,t.useCallback)(e=>{h.current=e},[])}}(e,o),j=(0,t.useRef)(l),k=(0,t.useRef)(d);(0,t.useEffect)(()=>{j.current=l,k.current=d},[l,d]);let E=(0,t.useMemo)(()=>e.map(e=>e.id).sort().join(","),[e]),N=(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]),C=(0,t.useRef)("");(0,t.useEffect)(()=>{let t=`${E}|${N}`;t!==C.current&&(C.current=t,c(e,o))},[E,N,e,o,c]);let _=(0,t.useRef)(new Map),{events:O}=(0,W.useAgentEventsContext)();(0,t.useEffect)(()=>{let t=_.current;for(let r of e){if("featureNode"!==r.type)continue;let e=r.data,o=t.get(r.id);void 0!==o&&o!==e.state&&(O.some(t=>t.featureId===e.featureId&&(0,H.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:()=>a.push(`/feature/${e.featureId}`)}}):"error"===e.state&&n.toast.error(e.name,{description:e.errorMessage??"Agent failed"}))),t.set(r.id,e.state)}},[N,e,O,a]);let M=(0,t.useRef)(0);(0,t.useEffect)(()=>{if(M.current>O.length&&(M.current=0),O.length<=M.current)return;let e=O.slice(M.current);for(let{featureId:t,state:r,lifecycle:n}of(M.current=O.length,(0,H.resolveSseEventUpdates)(e)))if(void 0!==r||void 0!==n){let e=`feat-${t}`,o=j.current.find(t=>t.id===e);if(o&&"deleting"===o.data.state)continue;u(e,{...void 0!==r&&{state:r},...void 0!==n&&{lifecycle:n}})}},[O,u]),(0,t.useEffect)(()=>{let e=e=>{let{featureId:t}=e.detail;u(`feat-${t}`,{state:"running"})};return window.addEventListener("shep:feature-approved",e),()=>window.removeEventListener("shep:feature-approved",e)},[u]);let R=(0,t.useRef)(new Set),S=(0,t.useRef)(0);(0,t.useEffect)(()=>{if(S.current>O.length&&(S.current=0),O.length<=S.current)return;let e=O.slice(S.current);for(let t of(S.current=O.length,e)){if("Feature metadata updated"!==t.message||R.current.has(t.featureId))continue;R.current.add(t.featureId);let e=`feat-${t.featureId}`;G(t.featureId).then(t=>{t&&u(e,{name:t.name,description:t.description})}).catch(()=>{})}},[O,u]),(0,t.useEffect)(()=>{Y.debug("polling enabled (3000ms interval)");let e=setInterval(async()=>{try{let{nodes:e,edges:t}=await q();c(e,t)}catch{Y.warn("poll fetch failed — will retry next interval")}},3e3);return()=>{Y.debug("polling disabled"),clearInterval(e)}},[c]);let P=(0,t.useCallback)(e=>{},[]),L=(0,t.useCallback)(e=>{},[]),I=(0,t.useCallback)((e,t,r)=>{let n=t?.featureId?`feat-${t.featureId}`:`feature-${Date.now()}-${J++}`,o={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 h(n,o,"dependencyEdge"===r&&e?e:void 0),n},[h]),D=(0,t.useCallback)((e,t)=>{let r=`feat-${e}`,o=[],i=[r];for(;i.length>0;){let e=i.shift();for(let t of k.current)"dependencyEdge"===t.type&&t.source===e&&(o.push(t.target),i.push(t.target))}let l=new Map;for(let e of[r,...o]){let t=j.current.find(t=>t.id===e);t&&l.set(e,t.data.state)}for(let e of(u(r,{state:"deleting"}),o))u(e,{state:"deleting"});s.play(),n.toast.success("Deleting feature…"),a.push("/"),(0,F.deleteFeature)(e,t).then(e=>{if(e.error){for(let[e,t]of l)t&&u(e,{state:t});n.toast.error(e.error)}else for(let e of(f(r),o))f(e)}).catch(()=>{for(let[e,t]of l)t&&u(e,{state:t});n.toast.error("Failed to delete feature")})},[a,s,u,f]),$=(0,t.useCallback)(async e=>{let t=`repo-${e}`,r=new Set(k.current.filter(e=>e.source===t).map(e=>e.target)),o=y(t),a=new Map;for(let e of r){let t=j.current.find(t=>t.id===e);t&&a.set(e,{nodeId:e,data:t.data})}let i=()=>{for(let[e,r]of(o&&g(t,o),a))p(e,r)};for(let e of(m(t),r))f(e);try{let t=await B(e);if(!t.success){n.toast.error(t.error??"Failed to remove repository"),i();return}s.play(),n.toast.success("Repository removed")}catch{n.toast.error("Failed to remove repository"),i()}},[s,m,f,g,p,y]),U=(0,t.useCallback)(e=>{let t=A(j.current,k.current,{...T,direction:e});c(t.nodes,t.edges)},[c]);return{nodes:l,edges:d,onNodesChange:P,handleConnect:L,handleAddRepository:(0,t.useCallback)(e=>{let t=0===b(),r=`repo-temp-${++Q}`,o=e.replace(/[\\/]+$/,"").split(/[\\/]/).pop()??e;return g(r,{name:o,repositoryPath:e,id:r}),z({path:e,name:o}).then(e=>{if(e.error){m(r),n.toast.error(e.error);return}let t=e.repository;x(r,`repo-${t.id}`,{name:t.name,repositoryPath:t.path,id:t.id}),i.play()}).catch(()=>{m(r),n.toast.error("Failed to add repository")}),{wasEmpty:t,repoPath:e}},[g,m,x,i,b]),handleLayout:U,handleDeleteFeature:D,handleDeleteRepository:$,createFeatureNode:I,getFeatureRepositoryPath:v,getRepositoryData:y,setCallbacks:w}}e.s(["useControlCenterState",()=>Z],17840)},48246,e=>{"use strict";var t=e.i(20314),r=e.i(53271),n=e.i(79054),o=e.i(31406),a=e.i(3214),s=e.i(3645);let i=(0,s.default)("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);var l=e.i(35364);e.i(54793);var d=e.i(7729);e.i(47506);var c=e.i(89313),u=e.i(92002);let h=(0,s.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 f=e.i(8986),p=e.i(38573),g=e.i(19933),m=e.i(67669),x=e.i(24042),v=e.i(64970),y=e.i(31777);e.i(81803);var b=e.i(72714),w=e.i(2287),j=e.i(2828);e.i(99348);var k=e.i(17466),E=e.i(8537),N=e.i(75921),C=e.i(76852);function _({data:e}){let o=(0,N.useFeatureFlags)(),[s,i]=(0,n.useState)(!1),d=(0,C.useRepositoryActions)(e.repositoryPath?{repositoryPath:e.repositoryPath}:null),c=(0,E.useDeployAction)(e.repositoryPath?{targetId:e.repositoryPath,targetType:"repository",repositoryPath:e.repositoryPath}:null),_="Booting"===c.status||"Ready"===c.status;return(0,t.jsxs)("div",{className:(0,y.cn)("group relative",e.onDelete&&e.id&&"pl-10"),children:[e.showHandles?(0,t.jsx)(r.Handle,{type:"target",position:u.Position.Left,isConnectable:!1,className:"opacity-0!"}):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)(j.TooltipProvider,{children:(0,t.jsxs)(j.Tooltip,{children:[(0,t.jsx)(j.TooltipTrigger,{asChild:!0,children:(0,t.jsx)("button",{"aria-label":"Remove repository","data-testid":"repository-node-delete-button",onClick:e=>{e.stopPropagation(),i(!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)(m.Trash2,{className:"h-3.5 w-3.5"})})}),(0,t.jsx)(j.TooltipContent,{children:"Remove repository"})]})})}),(0,t.jsx)(w.Dialog,{open:s,onOpenChange:i,children:(0,t.jsxs)(w.DialogContent,{className:"max-w-xs",children:[(0,t.jsxs)(w.DialogHeader,{children:[(0,t.jsx)(w.DialogTitle,{children:"Remove repository?"}),(0,t.jsxs)(w.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)(w.DialogFooter,{className:"grid grid-cols-2 gap-2 sm:flex-none",children:[(0,t.jsx)(w.DialogClose,{asChild:!0,children:(0,t.jsx)(l.Button,{variant:"outline",children:"Cancel"})}),(0,t.jsx)(l.Button,{variant:"destructive",onClick:()=>{i(!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:"nodrag bg-card flex min-w-[18rem] cursor-pointer items-center gap-3 rounded-full border px-4 py-3 shadow-sm",children:[(0,t.jsx)(h,{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,y.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)(j.TooltipProvider,{children:(0,t.jsxs)(j.Tooltip,{children:[(0,t.jsx)(j.TooltipTrigger,{asChild:!0,children:(0,t.jsx)("span",{className:"flex items-center",children:(0,t.jsx)(b.ActionButton,{label:"Open in IDE",onClick:d.openInIde,loading:d.ideLoading,error:!!d.ideError,icon:f.Code2,iconOnly:!0,variant:"ghost",size:"icon-xs"})})}),(0,t.jsx)(j.TooltipContent,{children:"Open in IDE"})]})}),(0,t.jsx)(j.TooltipProvider,{children:(0,t.jsxs)(j.Tooltip,{children:[(0,t.jsx)(j.TooltipTrigger,{asChild:!0,children:(0,t.jsx)("span",{className:"flex items-center",children:(0,t.jsx)(b.ActionButton,{label:"Open in Shell",onClick:d.openInShell,loading:d.shellLoading,error:!!d.shellError,icon:p.Terminal,iconOnly:!0,variant:"ghost",size:"icon-xs"})})}),(0,t.jsx)(j.TooltipContent,{children:"Open in Shell"})]})}),(0,t.jsx)(j.TooltipProvider,{children:(0,t.jsxs)(j.Tooltip,{children:[(0,t.jsx)(j.TooltipTrigger,{asChild:!0,children:(0,t.jsx)("span",{className:"flex items-center",children:(0,t.jsx)(b.ActionButton,{label:"Open Folder",onClick:d.openFolder,loading:d.folderLoading,error:!!d.folderError,icon:g.FolderOpen,iconOnly:!0,variant:"ghost",size:"icon-xs"})})}),(0,t.jsx)(j.TooltipContent,{children:"Open Folder"})]})}),o.envDeploy?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(j.TooltipProvider,{children:(0,t.jsxs)(j.Tooltip,{children:[(0,t.jsx)(j.TooltipTrigger,{asChild:!0,children:(0,t.jsx)("span",{className:"flex items-center",children:(0,t.jsx)(b.ActionButton,{label:_?"Stop Dev Server":"Start Dev Server",onClick:_?c.stop:c.deploy,loading:c.deployLoading||c.stopLoading,error:!!c.deployError,icon:_?v.Square:x.Play,iconOnly:!0,variant:"ghost",size:"icon-xs"})})}),(0,t.jsx)(j.TooltipContent,{children:_?"Stop Dev Server":"Start Dev Server"})]})}),_?(0,t.jsx)(k.DeploymentStatusBadge,{status:c.status,url:c.url,targetId:e.repositoryPath}):null]}):null]}):null,e.onAdd?(0,t.jsx)(j.TooltipProvider,{children:(0,t.jsxs)(j.Tooltip,{children:[(0,t.jsx)(j.TooltipTrigger,{asChild:!0,children:(0,t.jsx)("button",{"aria-label":"Add feature","data-testid":"repository-node-add-button",onClick:t=>{t.stopPropagation(),e.onAdd?.()},className:(0,y.cn)("text-muted-foreground hover:bg-accent dark:hover:bg-accent/50 flex h-6 w-6 shrink-0 cursor-pointer items-center justify-center rounded-full transition-colors hover:text-blue-500",e.pulseAdd&&"animate-pulse-cta bg-blue-100 text-blue-500 dark:bg-blue-900/40"),children:(0,t.jsx)(a.Plus,{className:"h-3.5 w-3.5"})})}),(0,t.jsx)(j.TooltipContent,{children:"Add feature"})]})}):null]})]}),e.onAdd||e.showHandles?(0,t.jsx)(r.Handle,{type:"source",position:u.Position.Right,isConnectable:!e.showHandles,className:"opacity-0!"}):null]})}function O(e){let[n]=(0,u.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 M={x:30,y:30,zoom:.85};function R({onResetViewport:e}){let{setViewport:o}=(0,r.useReactFlow)(),a=(0,n.useCallback)(()=>{o(e(),{duration:400})},[e,o]);return(0,t.jsx)(r.ControlButton,{onClick:a,title:"Reset view","aria-label":"Reset view",children:(0,t.jsx)(i,{style:{fill:"none"}})})}function S({nodes:e,edges:o,selectedFeatureId:s,defaultViewport:i,onNodesChange:u,onAddFeature:h,onConnect:f,onNodeClick:p,onPaneClick:g,onCanvasDrag:m,onMoveEnd:x,onResetViewport:v,toolbar:y,emptyState:b}){let w=(0,n.useMemo)(()=>({featureNode:c.FeatureNode,repositoryNode:_}),[]),j=(0,n.useMemo)(()=>({dependencyEdge:O}),[]),k=(0,n.useMemo)(()=>null==s?e:e.map(e=>"featureNode"===e.type&&e.data.featureId===s?{...e,selected:!0}:e),[e,s]);return 0===e.length?b?(0,t.jsx)("div",{"data-testid":"features-canvas-empty",className:"h-full w-full",children:b}):(0,t.jsx)("div",{"data-testid":"features-canvas-empty",children:(0,t.jsx)(d.EmptyState,{title:"No features yet",description:"Get started by creating your first feature.",action:(0,t.jsxs)(l.Button,{onClick:h,children:[(0,t.jsx)(a.Plus,{className:"mr-2 h-4 w-4"}),"New Feature"]})})}):(0,t.jsx)("div",{"data-testid":"features-canvas","data-no-drawer-close":!0,className:"pointer-events-auto h-full w-full",children:(0,t.jsxs)(r.ReactFlow,{nodes:k,edges:o,nodeTypes:w,edgeTypes:j,onConnect:f,onNodesChange:u,onNodeClick:p,onPaneClick:g,onMoveStart:m,onMoveEnd:x,defaultViewport:i??M,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,proOptions:{hideAttribution:!0},children:[(0,t.jsx)(r.Background,{}),(0,t.jsx)(r.Controls,{showInteractive:!1,children:v?(0,t.jsx)(R,{onResetViewport:v}):null}),y]})})}var P=e.i(5147),L=e.i(8361),T=e.i(30153);let I="shep-canvas-viewport",D={x:30,y:30,zoom:.85},A=(0,s.default)("square-terminal",[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]]);var F=e.i(33548),$=e.i(23925),z=e.i(83428),B=e.i(78521),G=e.i(21023);let q=(0,G.createServerReference)("00bd9bced113d109a251dc2da346e8434455c68f3e",G.callServer,void 0,G.findSourceMapURL,"isAgentSetupComplete");var W=e.i(76016),V=e.i(11345),U=e.i(81181),H=e.i(35e3),X=e.i(95812),K=e.i(79687),Y=e.i(26370),J=e.i(30702),Q=e.i(88996);let Z=(0,G.createServerReference)("40c691eeec5d87bb16fd4fb5efea434e01fc3a25c0",G.callServer,void 0,G.findSourceMapURL,"checkAgentTool");var ee=e.i(95848),et=e.i(86782),er=e.i(29847),en=e.i(32983);let eo=["select-agent","select-model","check-tool","authenticate"];function ea({onComplete:e,className:r}){let o,a,[s,i]=(0,n.useState)([]),[l,d]=(0,n.useState)(!0),[c,u]=(0,n.useState)("select-agent"),[h,f]=(0,n.useState)(null),[p,g]=(0,n.useState)(null),[m,x]=(0,n.useState)(null),[v,b]=(0,n.useState)(!1),[w,j]=(0,n.useState)(!1),[k,E]=(0,n.useState)(!1),[N,C]=(0,n.useState)(!0),_=(0,n.useRef)(void 0);(0,n.useEffect)(()=>{(0,Q.getAllAgentModels)().then(i).finally(()=>d(!1))},[]);let O=h?s.find(e=>e.agentType===h):null,M=(0,n.useCallback)((e,t)=>{E(!0),C(!1),_.current&&clearTimeout(_.current),_.current=setTimeout(()=>{t?.(),u(e),requestAnimationFrame(()=>{C(!0),E(!1)})},150)},[]);(0,n.useEffect)(()=>()=>{_.current&&clearTimeout(_.current)},[]);let R=(0,n.useCallback)(e=>{let t=s.find(t=>t.agentType===e);t&&t.models.length>0?M("select-model",()=>{f(e)}):M("check-tool",()=>{f(e),g("")})},[s,M]),S=(0,n.useCallback)(e=>{M("check-tool",()=>{g(e)})},[M]),P=(0,n.useCallback)(()=>{M("authenticate")},[M]),L=(0,n.useCallback)(()=>{"select-model"===c?M("select-agent",()=>{f(null)}):"check-tool"===c?O&&O.models.length>0?M("select-model",()=>{g(null)}):M("select-agent",()=>{f(null)}):"authenticate"===c&&(m&&!m.installed&&m.toolId?M("check-tool"):O&&O.models.length>0?M("select-model",()=>{g(null)}):M("select-agent",()=>{f(null)}))},[c,O,m,M]);(0,n.useEffect)(()=>{"check-tool"===c&&h&&(b(!0),Z(h).then(e=>{x(e),(e.installed||!e.toolId)&&M("authenticate")}).finally(()=>b(!1)))},[c,h,M]);let T=(0,n.useCallback)(async()=>{if(h){j(!0);try{await (0,ee.updateAgentAndModel)(h,p??null),e()}finally{j(!1)}}},[h,p,e]);if(l)return(0,t.jsxs)("div",{"data-testid":"welcome-agent-setup",className:(0,y.cn)("flex flex-col items-center justify-center gap-3",r),children:[(0,t.jsx)(z.Loader2,{className:"text-muted-foreground h-4 w-4 animate-spin"}),(0,t.jsx)("p",{className:"text-muted-foreground text-xs",children:"Loading agents…"})]});let I=eo.indexOf(c);return(0,t.jsxs)("div",{"data-testid":"welcome-agent-setup",className:(0,y.cn)("flex flex-col items-center gap-4","w-72",r),children:[(0,t.jsx)("div",{className:"flex flex-col items-center gap-1",children:(0,t.jsxs)("div",{className:"text-muted-foreground flex items-center gap-2",children:["select-agent"===c&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(Y.Bot,{className:"h-3.5 w-3.5"}),(0,t.jsx)("span",{className:"text-[10px] font-semibold tracking-widest uppercase",children:"Choose your agent"})]}),"select-model"===c&&O?(o=(0,et.getAgentTypeIcon)(O.agentType),(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(o,{className:"h-3.5 w-3.5"}),(0,t.jsxs)("span",{className:"text-[10px] font-semibold tracking-widest uppercase",children:[O.label," — Pick a model"]})]})):null,"check-tool"===c&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(Y.Bot,{className:"h-3.5 w-3.5"}),(0,t.jsx)("span",{className:"text-[10px] font-semibold tracking-widest uppercase",children:"Verifying setup"})]}),"authenticate"===c&&O?(a=(0,et.getAgentTypeIcon)(O.agentType),(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(a,{className:"h-3.5 w-3.5"}),(0,t.jsx)("span",{className:"text-[10px] font-semibold tracking-widest uppercase",children:"Authenticate"})]})):null]})}),(0,t.jsx)("div",{className:"flex w-32 items-center gap-1",children:eo.map((e,r)=>(0,t.jsx)("div",{className:(0,y.cn)("h-0.5 flex-1 rounded-full transition-colors duration-300",r<=I?"bg-foreground/60":"bg-muted")},e))}),(0,t.jsxs)("div",{className:(0,y.cn)("flex w-full flex-col items-center transition-opacity duration-150",N&&!k?"opacity-100":"opacity-0"),children:["select-agent"===c&&(0,t.jsx)("div",{"data-testid":"agent-list",className:"flex w-full flex-col gap-1.5",children:s.map(e=>{let r=(0,et.getAgentTypeIcon)(e.agentType);return(0,t.jsxs)("button",{type:"button","data-testid":`agent-option-${e.agentType}`,className:"border-border hover:border-foreground/40 flex w-full cursor-pointer items-center gap-2.5 rounded-md border border-dashed px-4 py-2.5 transition-colors",onClick:()=>R(e.agentType),children:[(0,t.jsx)(r,{className:"text-muted-foreground h-4 w-4 shrink-0"}),(0,t.jsx)("span",{className:"flex-1 text-left text-xs font-medium",children:e.label}),(0,t.jsx)(W.ChevronRight,{className:"text-muted-foreground h-3 w-3"})]},e.agentType)})}),"select-model"===c&&O?(0,t.jsxs)("div",{"data-testid":"model-list",className:"flex w-full flex-col gap-1.5",children:[(0,t.jsxs)("button",{type:"button",className:"text-muted-foreground hover:text-foreground mb-0.5 flex cursor-pointer items-center gap-1 self-start text-[10px] font-medium transition-colors",onClick:L,children:[(0,t.jsx)(V.ChevronLeft,{className:"h-3 w-3"}),"Back"]}),(0,t.jsx)("div",{className:"flex max-h-48 w-full flex-col gap-1.5 overflow-y-auto",children:O.models.map(e=>{let r=(0,er.getModelMeta)(e.id);return(0,t.jsxs)("button",{type:"button","data-testid":`model-option-${e.id}`,className:"border-border hover:border-foreground/40 flex w-full cursor-pointer items-center gap-2.5 rounded-md border border-dashed px-4 py-2.5 text-left transition-colors",onClick:()=>S(e.id),children:[(0,t.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[(0,t.jsx)("span",{className:"text-xs font-medium",children:r.displayName||e.displayName}),(0,t.jsx)("span",{className:"text-muted-foreground text-[10px] leading-tight",children:r.description||e.description})]}),(0,t.jsx)(W.ChevronRight,{className:"text-muted-foreground h-3 w-3 shrink-0"})]},e.id)})})]}):null,"check-tool"===c&&(0,t.jsx)(es,{toolStatus:m,checking:v,saving:!1,onConfirm:P,onBack:L,onToolInstalled:()=>{h&&(b(!0),Z(h).then(x).finally(()=>b(!1)))}}),"authenticate"===c&&m?(0,t.jsx)(el,{toolStatus:m,agentLabel:O?.label??h??"Agent",saving:w,onConfirm:T,onBack:L}):null]})]})}function es({toolStatus:e,checking:r,saving:n,onConfirm:o,onBack:a,onToolInstalled:s}){return r||!e?(0,t.jsxs)("div",{className:"flex flex-col items-center gap-2 py-4",children:[(0,t.jsx)(z.Loader2,{className:"text-muted-foreground h-4 w-4 animate-spin"}),(0,t.jsx)("p",{className:"text-muted-foreground text-[10px]",children:"Checking tool availability…"})]}):e.toolId?e.installed?(0,t.jsxs)("div",{className:"flex w-full flex-col items-center gap-3",children:[(0,t.jsxs)("div",{className:"text-muted-foreground flex items-center gap-1.5",children:[(0,t.jsx)(H.CheckCircle2,{className:"h-3.5 w-3.5"}),(0,t.jsxs)("span",{className:"text-xs",children:[e.tool?.name??e.toolId," is installed"]})]}),(0,t.jsx)(ei,{saving:n,onConfirm:o,onBack:a})]}):(0,t.jsx)(ed,{toolStatus:e,saving:n,onConfirm:o,onBack:a,onInstalled:s}):(0,t.jsxs)("div",{className:"flex w-full flex-col items-center gap-3",children:[(0,t.jsxs)("div",{className:"text-muted-foreground flex items-center gap-1.5",children:[(0,t.jsx)(H.CheckCircle2,{className:"h-3.5 w-3.5"}),(0,t.jsx)("span",{className:"text-xs",children:"No additional tools required"})]}),(0,t.jsx)(ei,{saving:n,onConfirm:o,onBack:a})]})}function ei({saving:e,onConfirm:r,onBack:n,label:o="Continue"}){return(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsxs)("button",{type:"button",className:"text-muted-foreground hover:text-foreground cursor-pointer text-[10px] transition-colors",onClick:n,children:[(0,t.jsx)(V.ChevronLeft,{className:"mr-0.5 inline h-3 w-3"}),"Back"]}),(0,t.jsxs)("button",{type:"button","data-testid":"agent-setup-confirm",disabled:e,className:"border-border hover:border-foreground/40 flex cursor-pointer items-center gap-1.5 rounded-md border border-dashed px-4 py-2 text-xs font-medium transition-colors disabled:opacity-50",onClick:r,children:[e?(0,t.jsx)(z.Loader2,{className:"h-3 w-3 animate-spin"}):(0,t.jsx)($.Check,{className:"h-3 w-3"}),o]})]})}function el({toolStatus:e,agentLabel:r,saving:o,onConfirm:a,onBack:s}){let[i,l]=(0,n.useState)(!1),[d,c]=(0,n.useState)(!1),u=(0,n.useCallback)(async()=>{if(e.toolId){l(!0);try{(await fetch(`/api/tools/${e.toolId}/launch`,{method:"POST"})).ok&&c(!0)}finally{l(!1)}}},[e.toolId]);return e.toolId?(0,t.jsxs)("div",{className:"flex w-full flex-col items-center gap-3",children:[(0,t.jsxs)("p",{className:"text-muted-foreground text-center text-[10px] leading-relaxed",children:["Open ",r," in a terminal to sign in.",(0,t.jsx)("br",{}),"Follow the prompts, then come back here."]}),(0,t.jsxs)("button",{type:"button","data-testid":"agent-setup-launch",disabled:i,onClick:u,className:"border-border hover:border-foreground/40 flex w-full cursor-pointer items-center gap-2.5 rounded-md border border-dashed px-4 py-2.5 transition-colors disabled:opacity-50",children:[i?(0,t.jsx)(z.Loader2,{className:"text-muted-foreground h-4 w-4 animate-spin"}):(0,t.jsx)(p.Terminal,{className:"text-muted-foreground h-4 w-4"}),(0,t.jsx)("span",{className:"flex-1 text-left text-xs font-medium",children:d?"Open again":`Open ${r}`}),(0,t.jsx)(J.ExternalLink,{className:"text-muted-foreground h-3 w-3"})]}),d?(0,t.jsx)("p",{className:"text-muted-foreground text-[10px]",children:"Terminal opened — complete sign-in there"}):null,e.binaryName?(0,t.jsxs)("div",{className:"flex w-full flex-col gap-1",children:[(0,t.jsx)("p",{className:"text-muted-foreground text-[10px]",children:"Or run manually in any terminal:"}),(0,t.jsxs)("div",{className:"w-full rounded-md bg-zinc-900 px-3 py-1.5 font-mono text-[11px] text-zinc-300",children:[(0,t.jsx)("span",{className:"text-zinc-500 select-none",children:"$ "}),e.binaryName]})]}):null,(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsxs)("button",{type:"button",className:"text-muted-foreground hover:text-foreground cursor-pointer text-[10px] transition-colors",onClick:s,children:[(0,t.jsx)(V.ChevronLeft,{className:"mr-0.5 inline h-3 w-3"}),"Back"]}),(0,t.jsxs)("button",{type:"button","data-testid":"agent-setup-confirm",disabled:o,className:"border-border hover:border-foreground/40 flex cursor-pointer items-center gap-1.5 rounded-md border border-dashed px-4 py-2 text-xs font-medium transition-colors disabled:opacity-50",onClick:a,children:[o?(0,t.jsx)(z.Loader2,{className:"h-3 w-3 animate-spin"}):(0,t.jsx)($.Check,{className:"h-3 w-3"}),d?"Done":"Skip"]})]})]}):(0,t.jsxs)("div",{className:"flex w-full flex-col items-center gap-3",children:[(0,t.jsx)("p",{className:"text-muted-foreground text-[10px]",children:"No authentication required"}),(0,t.jsx)(ei,{saving:o,onConfirm:a,onBack:s,label:"Done"})]})}function ed({toolStatus:e,saving:r,onConfirm:o,onBack:a,onInstalled:s}){let i=e.toolId??"",{logs:l,status:d,startInstall:c}=(0,en.useToolInstallStream)(i),u="done"===d,h="error"===d;return(0,n.useEffect)(()=>{u&&s()},[u,s]),(0,t.jsxs)("div",{className:"flex w-full flex-col items-center gap-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[u?(0,t.jsx)(H.CheckCircle2,{className:"text-muted-foreground h-3.5 w-3.5"}):h?(0,t.jsx)(K.AlertCircle,{className:"text-destructive h-3.5 w-3.5"}):(0,t.jsx)(X.Circle,{className:"text-muted-foreground h-3.5 w-3.5"}),(0,t.jsxs)("span",{className:"text-xs",children:[e.tool?.name??i," ",u?"installed":h?"install failed":"is not installed"]})]}),e.tool?.installCommand&&"idle"===d?(0,t.jsxs)("div",{className:"w-full rounded-md bg-zinc-900 px-3 py-2 font-mono text-[11px] text-zinc-300",children:[(0,t.jsx)("span",{className:"text-zinc-500 select-none",children:"$ "}),e.tool.installCommand]}):null,("streaming"===d||u||h)&&l.length>0?(0,t.jsxs)("div",{className:"max-h-28 w-full overflow-auto rounded-md bg-zinc-900 px-3 py-2 font-mono text-[10px] leading-relaxed text-zinc-400",children:[l.map((e,r)=>(0,t.jsx)("div",{className:"break-all whitespace-pre-wrap",children:e},r)),u?(0,t.jsx)("div",{className:"text-muted-foreground mt-1",children:"Installation complete"}):null,h?(0,t.jsx)("div",{className:"text-destructive mt-1",children:"Installation failed — try manually"}):null]}):null,(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsxs)("button",{type:"button",className:"text-muted-foreground hover:text-foreground cursor-pointer text-[10px] transition-colors",onClick:a,children:[(0,t.jsx)(V.ChevronLeft,{className:"mr-0.5 inline h-3 w-3"}),"Back"]}),!u&&e.tool?.autoInstall?(0,t.jsxs)("button",{type:"button","data-testid":"agent-setup-install",disabled:"streaming"===d,className:"border-border hover:border-foreground/40 flex cursor-pointer items-center gap-1.5 rounded-md border border-dashed px-4 py-2 text-xs font-medium transition-colors disabled:opacity-50",onClick:c,children:["streaming"===d?(0,t.jsx)(z.Loader2,{className:"h-3 w-3 animate-spin"}):(0,t.jsx)(U.Download,{className:"h-3 w-3"}),"streaming"===d?"Installing…":"Install"]}):null,u?(0,t.jsxs)("button",{type:"button","data-testid":"agent-setup-confirm",disabled:r,className:"border-border hover:border-foreground/40 flex cursor-pointer items-center gap-1.5 rounded-md border border-dashed px-4 py-2 text-xs font-medium transition-colors disabled:opacity-50",onClick:o,children:[r?(0,t.jsx)(z.Loader2,{className:"h-3 w-3 animate-spin"}):(0,t.jsx)($.Check,{className:"h-3 w-3"}),"Continue"]}):null]})]})}let ec=["cd ~/my-repo",'shep feat new "sleek dashboard"'];function eu({onRepositorySelect:e,className:r}){let[o,s]=(0,n.useState)(!1),[i,l]=(0,n.useState)(!1),[d,c]=(0,n.useState)(!1);async function u(){if(!i){l(!0);try{let t=await (0,B.pickFolder)();t&&e?.(t)}finally{l(!1)}}}(0,n.useEffect)(()=>{q().then(e=>{e&&c(!0)})},[]);let f=(0,n.useCallback)(async()=>{await navigator.clipboard.writeText(ec.join("\n")),s(!0),setTimeout(()=>s(!1),2e3)},[]),p=(0,n.useCallback)(()=>{c(!0)},[]);return(0,t.jsxs)("div",{"data-testid":"control-center-empty-state",className:(0,y.cn)("relative h-full w-full",r),children:[(0,t.jsx)("div",{className:"absolute inset-0 [background-image:radial-gradient(circle,_var(--color-border)_1px,_transparent_1px)] [background-size:24px_24px]"}),(0,t.jsxs)("div",{className:"absolute top-8 left-8 z-10",children:[(0,t.jsx)("h1",{className:"text-4xl font-bold tracking-tight",children:"Features"}),(0,t.jsx)("p",{className:"text-muted-foreground text-3xl font-light",children:"Control Center"})]}),(0,t.jsx)("div",{className:"relative z-10 flex h-full items-center justify-center",children:(0,t.jsx)("div",{className:"flex w-72 flex-col items-center gap-4",children:d?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"text-muted-foreground flex items-center gap-2",children:[(0,t.jsx)(h,{className:"h-3.5 w-3.5"}),(0,t.jsx)("span",{className:"text-[10px] font-semibold tracking-widest uppercase",children:"Repositories"})]}),(0,t.jsxs)("button",{type:"button","data-testid":"empty-state-add-repository",onClick:u,disabled:i,className:"border-border hover:border-foreground/40 flex w-full cursor-pointer items-center gap-2.5 rounded-md border border-dashed px-4 py-2.5 transition-colors disabled:cursor-wait disabled:opacity-50",children:[i?(0,t.jsx)(z.Loader2,{className:"text-muted-foreground h-4 w-4 animate-spin"}):(0,t.jsx)(a.Plus,{className:"text-muted-foreground h-4 w-4"}),(0,t.jsx)("span",{className:"text-xs font-medium",children:i?"Opening…":"Add Repository"})]}),(0,t.jsxs)("div",{className:"text-muted-foreground flex items-center gap-2",children:[(0,t.jsx)("div",{className:"bg-border h-px w-10"}),(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[(0,t.jsx)(A,{className:"h-3 w-3"}),(0,t.jsx)("span",{className:"text-[10px] font-semibold tracking-widest uppercase",children:"Or via CLI"})]}),(0,t.jsx)("div",{className:"bg-border h-px w-10"})]}),(0,t.jsxs)("div",{"data-testid":"cli-code-block",className:"relative w-full rounded-md bg-zinc-900 px-3 py-2 font-mono text-[11px] text-zinc-300",children:[(0,t.jsx)("button",{type:"button","data-testid":"cli-code-block-copy",onClick:f,className:"absolute top-2 right-2 cursor-pointer rounded p-1 text-zinc-500 transition-colors hover:bg-zinc-800 hover:text-zinc-300","aria-label":"Copy commands",children:o?(0,t.jsx)($.Check,{className:"h-3 w-3"}):(0,t.jsx)(F.Copy,{className:"h-3 w-3"})}),(0,t.jsx)("div",{className:"space-y-0.5",children:ec.map(e=>(0,t.jsxs)("div",{className:"whitespace-nowrap",children:[(0,t.jsx)("span",{className:"text-zinc-500 select-none",children:"$ "}),(0,t.jsx)("span",{children:e})]},e))})]}),(0,t.jsx)("p",{className:"text-muted-foreground text-[10px]",children:"Feature will appear on canvas once created"})]}):(0,t.jsx)(ea,{onComplete:p})})})]})}var eh=e.i(17840);let ef={maxZoom:1,padding:.5,duration:500};function ep({initialNodes:e,initialEdges:a}){let s,i,l,d=(0,o.useRouter)(),c=(0,o.usePathname)(),u=(s=(0,o.usePathname)().match(/^\/feature\/([^/]+)/),s?.[1]??null),h=(0,L.useSoundAction)("click"),{guardedNavigate:f}=(0,T.useDrawerCloseGuard)(),{fitView:p}=(0,r.useReactFlow)(),g=(0,n.useRef)(null),{defaultViewport:m,onMoveEnd:x,resetViewport:v}=(i=(0,n.useRef)(function(){try{let e=localStorage.getItem(I);if(null==e)return D;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:D}catch{return D}}()).current,l=(0,n.useRef)(null),(0,n.useEffect)(()=>()=>{null!=l.current&&clearTimeout(l.current)},[]),{defaultViewport:i,onMoveEnd:(0,n.useCallback)(e=>{null!=l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{try{localStorage.setItem(I,JSON.stringify(e))}catch{}},500)},[]),resetViewport:(0,n.useCallback)(()=>{try{localStorage.removeItem(I)}catch{}return D},[])}),{nodes:y,edges:b,onNodesChange:w,handleConnect:j,handleAddRepository:k,handleDeleteFeature:E,handleDeleteRepository:N,createFeatureNode:C,setCallbacks:_}=(0,eh.useControlCenterState)(e,a),{setFeatures:O}=(0,P.useSidebarFeaturesContext)(),M=(0,n.useMemo)(()=>y.filter(e=>"featureNode"===e.type),[y]),R=(0,n.useMemo)(()=>M.map(e=>{let t=e.data;return`${t.featureId}:${t.state}:${t.name}`}).sort().join(","),[M]);(0,n.useEffect)(()=>{O(M.map(e=>{let t=e.data,r=(0,P.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))},[R,M,O]);let A=(0,n.useCallback)((e,t)=>{if("featureNode"===t.type){let e=t.data;"creating"!==e.state&&f(()=>{h.play(),d.push(`/feature/${e.featureId}`)})}},[d,h,f]),F=(0,n.useCallback)(()=>{h.play(),d.push("/create")},[d,h]),$=(0,n.useCallback)(e=>{h.play();let t=y.find(t=>t.id===e),r=t?.data?.repositoryPath;r?d.push(`/create?repo=${encodeURIComponent(r)}`):d.push("/create")},[y,d,h]),z=(0,n.useCallback)(e=>{let t=e.startsWith("feat-")?e.slice(5):e,r=b.find(t=>t.target===e),n=r?y.find(e=>e.id===r.source):null,o=n?.data?.repositoryPath;h.play();let a=new URLSearchParams;o&&a.set("repo",o),a.set("parent",t),d.push(`/create?${a.toString()}`)},[y,b,d,h]),B=(0,n.useCallback)(e=>{let t=y.find(t=>t.id===e);if(t?.type==="repositoryNode"){let e=t.data;e.id&&f(()=>d.push(`/repository/${e.id}`))}},[y,d,f]),G=(0,n.useCallback)(()=>{"/"!==c&&f(()=>d.push("/"))},[d,c,f]);(0,n.useEffect)(()=>{let e=e=>{let{wasEmpty:t,repoPath:r}=k(e.detail.path);t&&setTimeout(()=>{p(ef),g.current=setTimeout(()=>{f(()=>d.push(`/create?repo=${encodeURIComponent(r)}`))},600)},0)};return window.addEventListener("shep:add-repository",e),()=>{window.removeEventListener("shep:add-repository",e),null!=g.current&&clearTimeout(g.current)}},[k,p,f,d]),(0,n.useEffect)(()=>{let e=e=>{let t=e.detail;if(t.parentId)return void C(`feat-${t.parentId}`,{state:"creating",featureId:t.featureId,name:t.name,description:t.description,repositoryPath:t.repositoryPath},"dependencyEdge");let r=y.find(e=>"repositoryNode"===e.type&&e.data.repositoryPath===t.repositoryPath);C(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)},[y,C]),(0,n.useEffect)(()=>{_({onNodeAction:z,onFeatureDelete:E,onRepositoryAdd:$,onRepositoryClick:B,onRepositoryDelete:N})},[_,z,E,$,B,N]);let q=(0,n.useCallback)((e,t)=>{x(t)},[x]),W=y.some(e=>"repositoryNode"===e.type),V=c.startsWith("/create"),U=(0,n.useMemo)(()=>{let e=y.filter(e=>"repositoryNode"===e.type),t=y.some(e=>"featureNode"===e.type);return 1!==e.length||t||V?y:y.map(e=>"repositoryNode"===e.type?{...e,data:{...e.data,pulseAdd:!0}}:e)},[y,V]);return W?(0,t.jsx)(S,{nodes:U,edges:b,selectedFeatureId:u,defaultViewport:m,onNodesChange:w,onConnect:j,onAddFeature:F,onNodeClick:A,onPaneClick:G,onMoveEnd:q,onResetViewport:v,emptyState:(0,t.jsx)(eu,{onRepositorySelect:k})}):(0,t.jsx)(eu,{onRepositorySelect:k})}function eg({initialNodes:e,initialEdges:n,drawer:o}){return(0,t.jsxs)("div",{"data-testid":"control-center",className:"h-full w-full",children:[(0,t.jsx)(r.ReactFlowProvider,{children:(0,t.jsx)(ep,{initialNodes:e,initialEdges:n})}),(0,t.jsx)("div",{children:o},"drawer")]})}e.s(["ControlCenter",()=>eg],48246)}]);