@codeyam/codeyam-cli 0.1.11 → 0.1.13

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 (214) hide show
  1. package/analyzer-template/.build-info.json +8 -8
  2. package/analyzer-template/log.txt +3 -3
  3. package/analyzer-template/package.json +2 -2
  4. package/analyzer-template/packages/ai/package.json +1 -1
  5. package/analyzer-template/packages/aws/package.json +1 -1
  6. package/analyzer-template/packages/database/package.json +1 -1
  7. package/analyzer-template/packages/database/src/lib/kysely/tables/editorScenariosTable.ts +42 -16
  8. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.d.ts +3 -1
  9. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.d.ts.map +1 -1
  10. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.js +44 -16
  11. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.js.map +1 -1
  12. package/codeyam-cli/src/cli.js +9 -0
  13. package/codeyam-cli/src/cli.js.map +1 -1
  14. package/codeyam-cli/src/commands/__tests__/editor.isolateArgs.test.js +51 -0
  15. package/codeyam-cli/src/commands/__tests__/editor.isolateArgs.test.js.map +1 -0
  16. package/codeyam-cli/src/commands/__tests__/editor.stepDispatch.test.js +11 -0
  17. package/codeyam-cli/src/commands/__tests__/editor.stepDispatch.test.js.map +1 -1
  18. package/codeyam-cli/src/commands/editor.js +1360 -201
  19. package/codeyam-cli/src/commands/editor.js.map +1 -1
  20. package/codeyam-cli/src/commands/editorIsolateArgs.js +25 -0
  21. package/codeyam-cli/src/commands/editorIsolateArgs.js.map +1 -0
  22. package/codeyam-cli/src/commands/telemetry.js +37 -0
  23. package/codeyam-cli/src/commands/telemetry.js.map +1 -0
  24. package/codeyam-cli/src/utils/__tests__/editorAudit.test.js +893 -1
  25. package/codeyam-cli/src/utils/__tests__/editorAudit.test.js.map +1 -1
  26. package/codeyam-cli/src/utils/__tests__/editorBroadcastViewport.test.js +76 -0
  27. package/codeyam-cli/src/utils/__tests__/editorBroadcastViewport.test.js.map +1 -0
  28. package/codeyam-cli/src/utils/__tests__/editorDeleteScenario.test.js +100 -0
  29. package/codeyam-cli/src/utils/__tests__/editorDeleteScenario.test.js.map +1 -0
  30. package/codeyam-cli/src/utils/__tests__/editorEntityChangeStatus.test.js +76 -3
  31. package/codeyam-cli/src/utils/__tests__/editorEntityChangeStatus.test.js.map +1 -1
  32. package/codeyam-cli/src/utils/__tests__/editorEntityHelpers.test.js +261 -0
  33. package/codeyam-cli/src/utils/__tests__/editorEntityHelpers.test.js.map +1 -0
  34. package/codeyam-cli/src/utils/__tests__/editorLoaderHelpers.test.js +75 -1
  35. package/codeyam-cli/src/utils/__tests__/editorLoaderHelpers.test.js.map +1 -1
  36. package/codeyam-cli/src/utils/__tests__/editorMigration.test.js +435 -0
  37. package/codeyam-cli/src/utils/__tests__/editorMigration.test.js.map +1 -0
  38. package/codeyam-cli/src/utils/__tests__/editorScenarios.test.js +441 -17
  39. package/codeyam-cli/src/utils/__tests__/editorScenarios.test.js.map +1 -1
  40. package/codeyam-cli/src/utils/__tests__/editorSeedAdapter.test.js +67 -0
  41. package/codeyam-cli/src/utils/__tests__/editorSeedAdapter.test.js.map +1 -1
  42. package/codeyam-cli/src/utils/__tests__/editorSeedAdapterPrismaValidation.test.js +143 -0
  43. package/codeyam-cli/src/utils/__tests__/editorSeedAdapterPrismaValidation.test.js.map +1 -0
  44. package/codeyam-cli/src/utils/__tests__/editorSessionFilter.test.js +66 -0
  45. package/codeyam-cli/src/utils/__tests__/editorSessionFilter.test.js.map +1 -0
  46. package/codeyam-cli/src/utils/__tests__/editorShouldRevalidate.test.js +53 -0
  47. package/codeyam-cli/src/utils/__tests__/editorShouldRevalidate.test.js.map +1 -0
  48. package/codeyam-cli/src/utils/__tests__/entityChangeStatus.test.js +67 -9
  49. package/codeyam-cli/src/utils/__tests__/entityChangeStatus.test.js.map +1 -1
  50. package/codeyam-cli/src/utils/__tests__/routePatternMatching.test.js +118 -0
  51. package/codeyam-cli/src/utils/__tests__/routePatternMatching.test.js.map +1 -0
  52. package/codeyam-cli/src/utils/__tests__/scenariosManifest.test.js +40 -1
  53. package/codeyam-cli/src/utils/__tests__/scenariosManifest.test.js.map +1 -1
  54. package/codeyam-cli/src/utils/__tests__/telemetry.test.js +159 -0
  55. package/codeyam-cli/src/utils/__tests__/telemetry.test.js.map +1 -0
  56. package/codeyam-cli/src/utils/analysisRunner.js +3 -1
  57. package/codeyam-cli/src/utils/analysisRunner.js.map +1 -1
  58. package/codeyam-cli/src/utils/editorAudit.js +145 -0
  59. package/codeyam-cli/src/utils/editorAudit.js.map +1 -1
  60. package/codeyam-cli/src/utils/editorBroadcastViewport.js +26 -0
  61. package/codeyam-cli/src/utils/editorBroadcastViewport.js.map +1 -0
  62. package/codeyam-cli/src/utils/editorDeleteScenario.js +67 -0
  63. package/codeyam-cli/src/utils/editorDeleteScenario.js.map +1 -0
  64. package/codeyam-cli/src/utils/editorEntityChangeStatus.js +13 -7
  65. package/codeyam-cli/src/utils/editorEntityChangeStatus.js.map +1 -1
  66. package/codeyam-cli/src/utils/editorEntityHelpers.js +129 -0
  67. package/codeyam-cli/src/utils/editorEntityHelpers.js.map +1 -0
  68. package/codeyam-cli/src/utils/editorLoaderHelpers.js +40 -1
  69. package/codeyam-cli/src/utils/editorLoaderHelpers.js.map +1 -1
  70. package/codeyam-cli/src/utils/editorMigration.js +224 -0
  71. package/codeyam-cli/src/utils/editorMigration.js.map +1 -0
  72. package/codeyam-cli/src/utils/editorScenarios.js +163 -2
  73. package/codeyam-cli/src/utils/editorScenarios.js.map +1 -1
  74. package/codeyam-cli/src/utils/editorSeedAdapter.js +253 -4
  75. package/codeyam-cli/src/utils/editorSeedAdapter.js.map +1 -1
  76. package/codeyam-cli/src/utils/editorShouldRevalidate.js +21 -0
  77. package/codeyam-cli/src/utils/editorShouldRevalidate.js.map +1 -0
  78. package/codeyam-cli/src/utils/entityChangeStatus.js +19 -2
  79. package/codeyam-cli/src/utils/entityChangeStatus.js.map +1 -1
  80. package/codeyam-cli/src/utils/entityChangeStatus.server.js +7 -3
  81. package/codeyam-cli/src/utils/entityChangeStatus.server.js.map +1 -1
  82. package/codeyam-cli/src/utils/fileWatcher.js +38 -0
  83. package/codeyam-cli/src/utils/fileWatcher.js.map +1 -1
  84. package/codeyam-cli/src/utils/install-skills.js +9 -0
  85. package/codeyam-cli/src/utils/install-skills.js.map +1 -1
  86. package/codeyam-cli/src/utils/routePatternMatching.js +129 -0
  87. package/codeyam-cli/src/utils/routePatternMatching.js.map +1 -0
  88. package/codeyam-cli/src/utils/scenarioCoverage.js +8 -9
  89. package/codeyam-cli/src/utils/scenarioCoverage.js.map +1 -1
  90. package/codeyam-cli/src/utils/scenariosManifest.js +18 -10
  91. package/codeyam-cli/src/utils/scenariosManifest.js.map +1 -1
  92. package/codeyam-cli/src/utils/telemetry.js +106 -0
  93. package/codeyam-cli/src/utils/telemetry.js.map +1 -0
  94. package/codeyam-cli/src/utils/telemetryMiddleware.js +22 -0
  95. package/codeyam-cli/src/utils/telemetryMiddleware.js.map +1 -0
  96. package/codeyam-cli/src/webserver/__tests__/buildPtyEnv.test.js +35 -0
  97. package/codeyam-cli/src/webserver/__tests__/buildPtyEnv.test.js.map +1 -0
  98. package/codeyam-cli/src/webserver/__tests__/editorProxy.test.js +61 -0
  99. package/codeyam-cli/src/webserver/__tests__/editorProxy.test.js.map +1 -1
  100. package/codeyam-cli/src/webserver/app/types/editor.js +8 -0
  101. package/codeyam-cli/src/webserver/app/types/editor.js.map +1 -0
  102. package/codeyam-cli/src/webserver/backgroundServer.js +18 -4
  103. package/codeyam-cli/src/webserver/backgroundServer.js.map +1 -1
  104. package/codeyam-cli/src/webserver/build/client/assets/CopyButton-CzTDWkF2.js +1 -0
  105. package/codeyam-cli/src/webserver/build/client/assets/{EntityItem-BcgbViKV.js → EntityItem-BFbq6iFk.js} +3 -3
  106. package/codeyam-cli/src/webserver/build/client/assets/EntityTypeBadge-CQgyEGV-.js +1 -0
  107. package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeIcon-CQIG2qda.js → EntityTypeIcon-B6OMi58N.js} +1 -1
  108. package/codeyam-cli/src/webserver/build/client/assets/InlineSpinner-DuYodzo1.js +1 -0
  109. package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-CXo9EeCl.js +25 -0
  110. package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-DYCNb2It.js +3 -0
  111. package/codeyam-cli/src/webserver/build/client/assets/{LoadingDots-BU_OAEMP.js → LoadingDots-By5zI316.js} +1 -1
  112. package/codeyam-cli/src/webserver/build/client/assets/{LogViewer-ceAyBX-H.js → LogViewer-CZgY3sxX.js} +3 -3
  113. package/codeyam-cli/src/webserver/build/client/assets/{ReportIssueModal-BzHcG7SE.js → ReportIssueModal-CnYYwRDw.js} +2 -2
  114. package/codeyam-cli/src/webserver/build/client/assets/SafeScreenshot-CDoF7ZpU.js +1 -0
  115. package/codeyam-cli/src/webserver/build/client/assets/{ScenarioViewer-TSD3C211.js → ScenarioViewer-DrnfvaLL.js} +3 -3
  116. package/codeyam-cli/src/webserver/build/client/assets/Spinner-Df3UCi8k.js +34 -0
  117. package/codeyam-cli/src/webserver/build/client/assets/TruncatedFilePath-CK7-NaPZ.js +1 -0
  118. package/codeyam-cli/src/webserver/build/client/assets/ViewportInspectBar-DRKR9T0U.js +1 -0
  119. package/codeyam-cli/src/webserver/build/client/assets/{_index-DLxKhri3.js → _index-ClR-g3tY.js} +2 -2
  120. package/codeyam-cli/src/webserver/build/client/assets/{activity.(_tab)-BcY3q6nt.js → activity.(_tab)-DTH6ydEA.js} +3 -3
  121. package/codeyam-cli/src/webserver/build/client/assets/{addon-web-links-Duc5hnl7.js → addon-web-links-74hnHF59.js} +1 -1
  122. package/codeyam-cli/src/webserver/build/client/assets/{agent-transcripts-Bni3iiUj.js → agent-transcripts-B8CYhCO9.js} +3 -3
  123. package/codeyam-cli/src/webserver/build/client/assets/api.editor-rename-scenario-l0sNRNKZ.js +1 -0
  124. package/codeyam-cli/src/webserver/build/client/assets/api.editor-save-seed-state-l0sNRNKZ.js +1 -0
  125. package/codeyam-cli/src/webserver/build/client/assets/api.editor-scenario-prompt-l0sNRNKZ.js +1 -0
  126. package/codeyam-cli/src/webserver/build/client/assets/{book-open-BYOypzCa.js → book-open-CLaoh4ac.js} +1 -1
  127. package/codeyam-cli/src/webserver/build/client/assets/{chevron-down-C_Pmso5S.js → chevron-down-BZ2DZxbW.js} +1 -1
  128. package/codeyam-cli/src/webserver/build/client/assets/{chunk-JZWAC4HX-C4pqxYJB.js → chunk-JZWAC4HX-BBXArFPl.js} +13 -21
  129. package/codeyam-cli/src/webserver/build/client/assets/{circle-check-BVMi9VA5.js → circle-check-CT4unAk-.js} +1 -1
  130. package/codeyam-cli/src/webserver/build/client/assets/{copy-n2FB0_Sw.js → copy-zK0B6Nu-.js} +1 -1
  131. package/codeyam-cli/src/webserver/build/client/assets/{createLucideIcon-CC6AbExI.js → createLucideIcon-DJB0YQJL.js} +1 -1
  132. package/codeyam-cli/src/webserver/build/client/assets/dev.empty-CkXFP_i-.js +1 -0
  133. package/codeyam-cli/src/webserver/build/client/assets/editor._tab-DPw7NZHc.js +1 -0
  134. package/codeyam-cli/src/webserver/build/client/assets/editor.entity.(_sha)-CjC3_6JI.js +58 -0
  135. package/codeyam-cli/src/webserver/build/client/assets/editorPreview-DBa7T2FK.js +41 -0
  136. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha._-DwCV5__E.js → entity._sha._-BqAN7hyG.js} +2 -2
  137. package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.dev-BOi8kpwd.js +6 -0
  138. package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.fullscreen-Dg1NhIms.js +6 -0
  139. package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-CJX6kkkV.js +6 -0
  140. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha_.edit._scenarioId-BMvVHNXU.js → entity._sha_.edit._scenarioId-BhVjZhKg.js} +2 -2
  141. package/codeyam-cli/src/webserver/build/client/assets/{entry.client-DTvKq3TY.js → entry.client-_gzKltPN.js} +6 -6
  142. package/codeyam-cli/src/webserver/build/client/assets/fileTableUtils-Daa96Fr1.js +1 -0
  143. package/codeyam-cli/src/webserver/build/client/assets/files-CV_17tZS.js +1 -0
  144. package/codeyam-cli/src/webserver/build/client/assets/git-D-YXmMbR.js +1 -0
  145. package/codeyam-cli/src/webserver/build/client/assets/globals-DRvOjyO3.css +1 -0
  146. package/codeyam-cli/src/webserver/build/client/assets/{index-yHOVb4rc.js → index-Blo6EK8G.js} +1 -1
  147. package/codeyam-cli/src/webserver/build/client/assets/{index-10oVnAAH.js → index-BsX0F-9C.js} +1 -1
  148. package/codeyam-cli/src/webserver/build/client/assets/{index-BcvgDzbZ.js → index-CCrgCshv.js} +1 -1
  149. package/codeyam-cli/src/webserver/build/client/assets/jsx-runtime-D_zvdyIk.js +9 -0
  150. package/codeyam-cli/src/webserver/build/client/assets/labs-Byazq8Pv.js +1 -0
  151. package/codeyam-cli/src/webserver/build/client/assets/{loader-circle-DaAZ_H2w.js → loader-circle-DVQ0oHR7.js} +1 -1
  152. package/codeyam-cli/src/webserver/build/client/assets/manifest-75b1b319.js +1 -0
  153. package/codeyam-cli/src/webserver/build/client/assets/{memory-9gnxSZlb.js → memory-b-VmA2Vj.js} +2 -2
  154. package/codeyam-cli/src/webserver/build/client/assets/{pause-f5-1lKBt.js → pause-DGcndCAa.js} +1 -1
  155. package/codeyam-cli/src/webserver/build/client/assets/{root-DBjt6o04.js → root-F-k2uYj5.js} +15 -15
  156. package/codeyam-cli/src/webserver/build/client/assets/{search-Di64LWVb.js → search-C0Uw0bcK.js} +1 -1
  157. package/codeyam-cli/src/webserver/build/client/assets/settings-OoNgHIfW.js +1 -0
  158. package/codeyam-cli/src/webserver/build/client/assets/simulations-Bcemfu8a.js +1 -0
  159. package/codeyam-cli/src/webserver/build/client/assets/{terminal-Br7MOqts.js → terminal-BgMmG7R9.js} +1 -1
  160. package/codeyam-cli/src/webserver/build/client/assets/{triangle-alert-BLdiCuG-.js → triangle-alert-Cs87hJYK.js} +1 -1
  161. package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-BR3Rs7JY.js +1 -0
  162. package/codeyam-cli/src/webserver/build/client/assets/{useLastLogLine-C14nCb1q.js → useLastLogLine-BxxP_XF9.js} +1 -1
  163. package/codeyam-cli/src/webserver/build/client/assets/useReportContext-BermyNU5.js +1 -0
  164. package/codeyam-cli/src/webserver/build/client/assets/useToast-a_QN_W9_.js +1 -0
  165. package/codeyam-cli/src/webserver/build/server/assets/analysisRunner-lv2ooewK.js +13 -0
  166. package/codeyam-cli/src/webserver/build/server/assets/{index-DsZjKspK.js → index-Im3Smyei.js} +1 -1
  167. package/codeyam-cli/src/webserver/build/server/assets/init-BjuAFKGM.js +10 -0
  168. package/codeyam-cli/src/webserver/build/server/assets/progress-CHTtrxFG.js +1 -0
  169. package/codeyam-cli/src/webserver/build/server/assets/server-build-CNjF0B9B.js +551 -0
  170. package/codeyam-cli/src/webserver/build/server/index.js +1 -1
  171. package/codeyam-cli/src/webserver/build-info.json +5 -5
  172. package/codeyam-cli/src/webserver/editorProxy.js +112 -13
  173. package/codeyam-cli/src/webserver/editorProxy.js.map +1 -1
  174. package/codeyam-cli/src/webserver/mockStateEvents.js +28 -0
  175. package/codeyam-cli/src/webserver/mockStateEvents.js.map +1 -0
  176. package/codeyam-cli/src/webserver/server.js +41 -0
  177. package/codeyam-cli/src/webserver/server.js.map +1 -1
  178. package/codeyam-cli/src/webserver/terminalServer.js +74 -8
  179. package/codeyam-cli/src/webserver/terminalServer.js.map +1 -1
  180. package/codeyam-cli/templates/editor-step-hook.py +104 -20
  181. package/codeyam-cli/templates/nextjs-prisma-sqlite/seed-adapter.ts +42 -7
  182. package/codeyam-cli/templates/seed-adapters/supabase.ts +282 -0
  183. package/codeyam-cli/templates/skills/codeyam-editor/SKILL.md +62 -0
  184. package/package.json +2 -1
  185. package/packages/database/src/lib/kysely/tables/editorScenariosTable.js +44 -16
  186. package/packages/database/src/lib/kysely/tables/editorScenariosTable.js.map +1 -1
  187. package/codeyam-cli/src/webserver/build/client/assets/CopyButton-BPXZwM4t.js +0 -1
  188. package/codeyam-cli/src/webserver/build/client/assets/EntityTypeBadge-g3saevPb.js +0 -1
  189. package/codeyam-cli/src/webserver/build/client/assets/InlineSpinner-Bu6c6aDe.js +0 -1
  190. package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-DYFW3lDD.js +0 -25
  191. package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-DLeucoVX.js +0 -3
  192. package/codeyam-cli/src/webserver/build/client/assets/SafeScreenshot-BED4B6sP.js +0 -1
  193. package/codeyam-cli/src/webserver/build/client/assets/Spinner-Bb5uFQ5V.js +0 -34
  194. package/codeyam-cli/src/webserver/build/client/assets/TruncatedFilePath-C8OKAR5x.js +0 -1
  195. package/codeyam-cli/src/webserver/build/client/assets/ViewportInspectBar-oAf2Kqsf.js +0 -1
  196. package/codeyam-cli/src/webserver/build/client/assets/dev.empty-Ii3inc0_.js +0 -1
  197. package/codeyam-cli/src/webserver/build/client/assets/editor-16o0AIFV.js +0 -15
  198. package/codeyam-cli/src/webserver/build/client/assets/editorPreview-7Uga8I59.js +0 -41
  199. package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.dev-BwKcai0j.js +0 -6
  200. package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.fullscreen-CHMiAog3.js +0 -6
  201. package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-p9hhkjJM.js +0 -6
  202. package/codeyam-cli/src/webserver/build/client/assets/fileTableUtils-cPo8LiG3.js +0 -1
  203. package/codeyam-cli/src/webserver/build/client/assets/files-BZrlFE1F.js +0 -1
  204. package/codeyam-cli/src/webserver/build/client/assets/git-DdZcvjGh.js +0 -1
  205. package/codeyam-cli/src/webserver/build/client/assets/globals-CQPR0pFR.css +0 -1
  206. package/codeyam-cli/src/webserver/build/client/assets/labs-Zk7ryIM1.js +0 -1
  207. package/codeyam-cli/src/webserver/build/client/assets/manifest-76e7b62c.js +0 -1
  208. package/codeyam-cli/src/webserver/build/client/assets/settings-0OrEMU6J.js +0 -1
  209. package/codeyam-cli/src/webserver/build/client/assets/simulations-DWT-CvLy.js +0 -1
  210. package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-C-_hOl_g.js +0 -1
  211. package/codeyam-cli/src/webserver/build/client/assets/useReportContext-O-jkvSPx.js +0 -1
  212. package/codeyam-cli/src/webserver/build/client/assets/useToast-9FIWuYfK.js +0 -1
  213. package/codeyam-cli/src/webserver/build/server/assets/init-DdqKD2p4.js +0 -10
  214. package/codeyam-cli/src/webserver/build/server/assets/server-build-CKKeWtVK.js +0 -444
@@ -1,15 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-yHOVb4rc.js","assets/chunk-JZWAC4HX-C4pqxYJB.js"])))=>i.map(i=>d[i]);
2
- var Dt=Object.defineProperty;var _t=(t,s,n)=>s in t?Dt(t,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[s]=n;var et=(t,s,n)=>_t(t,typeof s!="symbol"?s+"":s,n);import{r as a,j as e,w as Ot,u as Ft,b as Ut}from"./chunk-JZWAC4HX-C4pqxYJB.js";import{u as zt,C as Wt}from"./useCustomSizes-C-_hOl_g.js";import{g as Jt,s as Gt,r as Te,b as he,c as Ht,l as Vt,d as Kt,e as Yt,f as qt,a as Xt,T as Qt,D as Zt}from"./editorPreview-7Uga8I59.js";import{C as Ae}from"./CopyButton-BPXZwM4t.js";import{_ as es}from"./preload-helper-ckwbz45p.js";import{c as ts}from"./cy-logo-cli-DcX-ZS3p.js";import{u as ss,S as tt}from"./Spinner-Bb5uFQ5V.js";import"./copy-n2FB0_Sw.js";import"./createLucideIcon-CC6AbExI.js";import"./useLastLogLine-C14nCb1q.js";const ge=[{name:"Desktop",width:1440,height:900},{name:"Laptop",width:1024,height:768},{name:"Tablet",width:768,height:1024},{name:"Mobile",width:375,height:667}];function ns(t){if(!t)return ge;const s=Object.entries(t).map(([l,h])=>({name:l,width:h.width,height:h.height})),n=new Set(s.map(l=>l.name));return[...s,...ge.filter(l=>!n.has(l.name))]}function as({featureName:t,editorStep:s,editorStepLabel:n,onContinue:l,onStartFresh:h,onReview:c}){const[o,p]=a.useState("resume"),[x,k]=a.useState(0),S=a.useCallback(()=>{p("fresh-options"),k(0)},[]),y=a.useCallback(L=>{L.key==="ArrowLeft"||L.key==="ArrowRight"||L.key==="Tab"?(L.preventDefault(),k(I=>I===0?1:0)):L.key==="Enter"&&(L.preventDefault(),o==="resume"?x===0?l():S():x===0?h():c())},[o,x,l,h,c,S]);a.useEffect(()=>(window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)),[y]);const w="flex-1 px-4 py-2 text-sm rounded transition-colors cursor-pointer",M="ring-2 ring-white/50",b="bg-[#005c75] text-white font-medium hover:bg-[#004d63]",B="bg-[#3d3d3d] text-[#d4d4d4] hover:bg-[#4d4d4d]";return e.jsx("div",{className:"flex items-center justify-center h-full bg-[#1e1e1e] text-[#d4d4d4]",children:e.jsx("div",{className:"max-w-md w-full mx-4 p-6 bg-[#252526] border border-[#3d3d3d] rounded-lg",children:o==="resume"?e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"text-lg font-semibold mb-3 text-white",children:"Resume Previous Session?"}),e.jsx("p",{className:"text-sm text-[#999] mb-4",children:"An editor session is still in progress:"}),e.jsxs("div",{className:"bg-[#1e1e1e] rounded p-3 mb-5 text-sm",children:[t&&e.jsxs("div",{className:"mb-1",children:[e.jsx("span",{className:"text-[#999]",children:"Feature:"})," ",e.jsx("span",{className:"text-white",children:t})]}),s!=null&&n&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[#999]",children:"Step:"})," ",e.jsxs("span",{className:"text-white",children:[s," (",n,")"]})]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{onClick:l,className:`${w} ${b} ${x===0?M:""}`,children:"Continue Session"}),e.jsx("button",{onClick:S,className:`${w} ${B} ${x===1?M:""}`,children:"Start Over"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"text-lg font-semibold mb-3 text-white",children:"What would you like to do?"}),e.jsx("p",{className:"text-sm text-[#999] mb-5",children:"The previous session will be cleared."}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{onClick:h,className:`${w} ${b} ${x===0?M:""}`,children:"Build Next Feature"}),e.jsx("button",{onClick:c,className:`${w} ${B} ${x===1?M:""}`,children:"Review What's Built"})]})]})})})}function Be(t){const[s,n]=a.useState(null),[l,h]=a.useState(!1),c=a.useCallback(()=>{t&&(h(!0),fetch(`/api/editor-test-results?testFile=${encodeURIComponent(t)}`).then(o=>o.json()).then(o=>{n(o),h(!1)}).catch(()=>{n({testFilePath:t,status:"error",testCases:[],errorMessage:"Failed to fetch test results"}),h(!1)}))},[t]);return a.useEffect(()=>{t&&c()},[t,c]),{results:s,isRunning:l,runTests:c}}function te(t){if(!t||t==="/")return"Home";const s=t.split("?")[0].replace(/^\//,"");if(!s)return"Home";const n=s.split("/")[0];return n.charAt(0).toUpperCase()+n.slice(1)}function De(t){return t?t.includes("/isolated-components"):!1}function rs(t,s){return!s||Object.keys(s).length===0?t:t.filter(n=>s[n.name])}function xe({imgSrc:t,name:s,isActive:n,onSelect:l}){return e.jsxs("button",{onClick:l,className:"flex flex-col items-center gap-1 cursor-pointer group",title:s,children:[e.jsx("div",{className:`w-32 h-32 rounded overflow-hidden border-2 transition-all bg-[#1a1a1a] ${n?"border-[#005c75] ring-1 ring-[#005c75]":"border-transparent hover:border-[#4d4d4d]"}`,children:t?e.jsx("img",{src:t,alt:s,className:"w-full h-full object-contain",loading:"lazy"}):e.jsx("div",{className:"w-full h-full bg-[#1a1a1a] flex items-center justify-center",children:e.jsx("span",{className:"text-[8px] text-gray-600",children:"No img"})})}),e.jsx("span",{className:`text-[10px] leading-tight text-center truncate w-32 ${n?"text-white":"text-gray-500 group-hover:text-gray-300"}`,children:s})]})}function Le({testFile:t,entityName:s}){const{results:n,isRunning:l,runTests:h}=Be(t);if(l&&!n)return e.jsxs("div",{className:"px-2 pt-1 flex items-center gap-1.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[#005c75] animate-pulse"}),e.jsx("span",{className:"text-[10px] text-gray-400",children:"Running tests..."})]});if(!n)return null;if(n.status==="error")return e.jsx("div",{className:"px-2 pt-1",children:e.jsx("span",{className:"text-[10px] text-red-400",children:n.errorMessage})});const c=s?n.testCases.filter(x=>x.fullName.startsWith(s)):n.testCases,o=c.length>0?c:n.testCases;if(o.length===0)return null;const p=s?`${s} > `:"";return e.jsxs("div",{className:"px-2 pt-1 space-y-0.5",children:[o.map(x=>{var S;const k=p&&x.fullName.startsWith(p)?x.fullName.slice(p.length):x.fullName;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[x.status==="passed"?e.jsx("span",{className:"text-green-400 text-[10px]",children:"✓"}):x.status==="failed"?e.jsx("span",{className:"text-red-400 text-[10px]",children:"✗"}):e.jsx("span",{className:"text-gray-500 text-[10px]",children:"—"}),e.jsx("span",{className:`text-[10px] ${x.status==="passed"?"text-green-400":x.status==="failed"?"text-red-400":"text-gray-500"}`,children:k})]}),x.status==="failed"&&((S=x.failureMessages)==null?void 0:S.map((y,w)=>e.jsx("div",{className:"pl-4 text-[9px] text-red-300/70 truncate max-w-full",title:y,children:y.split(`
3
- `)[0]},w)))]},x.fullName)}),e.jsx("button",{onClick:h,disabled:l,className:"mt-1 text-[10px] text-[#00a0c4] hover:text-[#00c4ee] transition-colors cursor-pointer disabled:opacity-50 bg-transparent border-none p-0",children:l?"Running...":"Re-run"})]})}function Y({filePath:t}){return t?e.jsxs("div",{className:"flex items-center gap-1 px-2 mt-0.5",children:[e.jsxs("a",{href:`/api/editor-file?path=${encodeURIComponent(t)}`,target:"_blank",rel:"noopener noreferrer",title:"Open file",className:"flex items-center gap-1 text-gray-500 hover:text-gray-300 transition-colors min-w-0",children:[e.jsx("span",{className:"text-[9px] truncate",children:t}),e.jsx("svg",{className:"shrink-0",width:"10",height:"10",viewBox:"0 0 12 12",fill:"none",children:e.jsx("path",{d:"M4.5 1.5H2.5C1.95 1.5 1.5 1.95 1.5 2.5V9.5C1.5 10.05 1.95 10.5 2.5 10.5H9.5C10.05 10.5 10.5 10.05 10.5 9.5V7.5M7.5 1.5H10.5M10.5 1.5V4.5M10.5 1.5L5 7",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})})]}),e.jsx(Ae,{content:t,icon:!0,iconSize:10,className:"shrink-0 text-gray-500 hover:text-gray-300 transition-colors"})]}):null}function is({scenarios:t,projectRoot:s,activeScenarioId:n,onScenarioSelect:l,zoomComponent:h,onZoomChange:c,analyzedEntities:o=[],glossaryFunctions:p=[],activeAnalyzedScenarioId:x,onAnalyzedScenarioSelect:k,entityImports:S,pageFilePaths:y={}}){const{pageGroups:w,componentGroups:M}=a.useMemo(()=>{var f;const u=new Map,g=new Map;for(const m of t)if(m.componentName){const i=g.get(m.componentName)||[];i.push(m),g.set(m.componentName,i)}else if(De(m.url)){const i=(f=m.url)==null?void 0:f.match(/[?&]c=([^&]+)/),v=i?decodeURIComponent(i[1]):"Isolated",C=g.get(v)||[];C.push(m),g.set(v,C)}else{const i=te(m.url),v=u.get(i)||[];v.push(m),u.set(i,v)}const d=new Map([...g.entries()].sort(([m],[i])=>m.localeCompare(i)));return{pageGroups:u,componentGroups:d}},[t]),b=a.useMemo(()=>{const u=new Set((o||[]).filter(d=>d.entityType==="visual").map(d=>d.name)),g=new Map;for(const[d,f]of M)u.has(d)||g.set(d,f);return g},[M,o]),{visualEntities:B,libraryEntities:L}=a.useMemo(()=>{const u=o.filter(d=>d.entityType==="visual").sort((d,f)=>d.name.localeCompare(f.name)),g=o.filter(d=>d.entityType==="library"||d.entityType==="functionCall").sort((d,f)=>d.name.localeCompare(f.name));return{visualEntities:u,libraryEntities:g}},[o]),I=a.useMemo(()=>{const u=new Set(L.map(g=>g.name));return p.filter(g=>!u.has(g.name)).sort((g,d)=>g.name.localeCompare(d.name))},[p,L]),U=o.some(u=>u.isAnalyzing),R=a.useRef(null),$=a.useRef(0),D=a.useCallback(()=>{R.current&&($.current=R.current.scrollTop)},[]);if(a.useEffect(()=>{R.current&&$.current>0&&(R.current.scrollTop=$.current)}),t.length===0&&o.length===0&&I.length===0)return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center text-gray-500 px-8",children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"No scenarios yet"}),e.jsx("p",{className:"text-xs",children:"Scenarios will appear here as Claude creates them alongside your code. Each scenario represents a different state of your app's data."})]})});if(h){const u=M.get(h)||[],g=new Set((S==null?void 0:S[h])||[]),d=g.size>0,f=d?B.filter(i=>g.has(i.name)):[],m=d?L.filter(i=>g.has(i.name)):[];return e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsxs("div",{className:"p-3 space-y-1",children:[e.jsxs("button",{onClick:()=>c(void 0),className:"w-full flex items-center gap-2 px-3 py-1.5 text-xs text-gray-400 hover:text-white transition-colors cursor-pointer",children:[e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",className:"shrink-0",children:e.jsx("path",{d:"M7.5 9L4.5 6L7.5 3",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),"All scenarios"]}),e.jsx("div",{className:"px-3 py-1.5",children:e.jsx("span",{className:"text-xs font-semibold text-white uppercase tracking-wider",children:h})}),e.jsx("div",{className:"flex flex-wrap gap-2 px-2",children:u.length===0?e.jsx("div",{className:"px-3 py-2 text-xs text-gray-500",children:"No scenarios for this component"}):u.map(i=>e.jsx(xe,{imgSrc:i.screenshotPath?`/api/editor-scenario-image/${i.id}.png${i.updatedAt?`?v=${encodeURIComponent(i.updatedAt)}`:""}`:null,name:i.name,isActive:i.id===n,onSelect:()=>l(i)},i.id))}),f.length>0&&e.jsxs("div",{className:"pt-2 mt-1 border-t border-[#3d3d3d]",children:[e.jsx("div",{className:"px-2 py-1",children:e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Components"})}),f.map(i=>e.jsxs("div",{className:"mt-2",children:[e.jsx("div",{className:"flex items-center gap-2 px-2 py-1",children:e.jsx("button",{onClick:()=>c(i.name),className:"text-[11px] font-medium text-gray-400 truncate cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:i.name})}),e.jsx(Y,{filePath:i.filePath,projectRoot:s}),(i.scenarios.length>0||i.pendingScenarios.length>0)&&e.jsx("div",{className:"flex flex-wrap gap-2 px-2 pt-1",children:i.scenarios.map(v=>e.jsx(xe,{imgSrc:v.screenshotPath?`/api/screenshot/${v.screenshotPath}`:null,name:v.name,isActive:v.id===x,onSelect:()=>k==null?void 0:k({analysisId:i.analysisId,scenarioId:v.id,scenarioName:v.name,entitySha:i.sha,entityName:i.name})},v.id))})]},i.sha))]}),m.length>0&&e.jsxs("div",{className:"pt-2 mt-1",children:[e.jsx("div",{className:"px-2 py-1",children:e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Functions"})}),m.map(i=>e.jsxs("div",{className:"mt-2",children:[e.jsx("div",{className:"px-2 py-1",children:e.jsx("span",{className:"text-[11px] font-medium text-gray-300",children:i.name})}),e.jsx(Y,{filePath:i.filePath,projectRoot:s}),i.testFile&&e.jsx(Le,{testFile:i.testFile,entityName:i.name})]},i.sha))]})]})})}return e.jsx("div",{ref:R,onScroll:D,className:"flex-1 overflow-auto",children:e.jsxs("div",{className:"p-3 space-y-3",children:[w.size>0&&e.jsxs("div",{children:[e.jsx("div",{className:"px-2 py-1",children:e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Application"})}),[...w.entries()].sort(([u],[g])=>u==="Home"?-1:g==="Home"?1:u.localeCompare(g)).map(([u,g])=>e.jsxs("div",{className:"px-2 pt-1",children:[e.jsx("div",{className:"py-0.5",children:e.jsx("span",{className:"text-[11px] font-medium text-gray-400",children:u})}),y[u]&&e.jsx(Y,{filePath:y[u],projectRoot:s}),e.jsx("div",{className:"flex flex-wrap gap-2 pt-1",children:g.map(d=>e.jsx(xe,{imgSrc:d.screenshotPath?`/api/editor-scenario-image/${d.id}.png${d.updatedAt?`?v=${encodeURIComponent(d.updatedAt)}`:""}`:null,name:d.name,isActive:d.id===n&&!x,onSelect:()=>l(d)},d.id))})]},u))]}),b.size>0&&e.jsxs("div",{className:"pt-2 mt-1 border-t border-[#3d3d3d]",children:[e.jsx("div",{className:"px-2 py-1",children:e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Components"})}),[...b.entries()].map(([u,g])=>{var d;return e.jsxs("div",{className:"mt-2",children:[e.jsx("div",{className:"flex items-center justify-between px-2 py-1",children:e.jsx("button",{onClick:()=>c(u),className:"text-[11px] font-medium text-gray-400 truncate cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:u})}),((d=g[0])==null?void 0:d.componentPath)&&e.jsx(Y,{filePath:g[0].componentPath,projectRoot:s}),e.jsx("div",{className:"flex flex-wrap gap-2 px-2 pt-1",children:g.map(f=>e.jsx(xe,{imgSrc:f.screenshotPath?`/api/editor-scenario-image/${f.id}.png${f.updatedAt?`?v=${encodeURIComponent(f.updatedAt)}`:""}`:null,name:f.name,isActive:f.id===n&&!x,onSelect:()=>l(f)},f.id))})]},u)})]}),B.length>0&&e.jsxs("div",{className:"pt-2 mt-1 border-t border-[#3d3d3d]",children:[e.jsxs("div",{className:"px-2 py-1",children:[e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Components"}),U&&t.length===0&&o.every(u=>u.scenarioCount===0)&&e.jsx("span",{className:"ml-2 text-[10px] text-gray-500",children:"— Entities are being analyzed..."})]}),B.map(u=>e.jsxs("div",{className:"mt-2",children:[e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1",children:[e.jsx("button",{onClick:()=>c(u.name),className:"text-[11px] font-medium text-gray-400 truncate cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:u.name}),u.isAnalyzing&&u.scenarioCount===0&&e.jsxs("span",{className:"flex items-center gap-1.5 text-[10px] text-gray-400",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[#005c75] animate-pulse"}),"Analyzing..."]})]}),e.jsx(Y,{filePath:u.filePath,projectRoot:s}),(u.scenarios.length>0||u.pendingScenarios.length>0)&&e.jsxs("div",{className:"flex flex-wrap gap-2 px-2 pt-1",children:[u.scenarios.map(g=>e.jsx(xe,{imgSrc:g.screenshotPath?`/api/screenshot/${g.screenshotPath}`:null,name:g.name,isActive:g.id===x,onSelect:()=>k==null?void 0:k({analysisId:u.analysisId,scenarioId:g.id,scenarioName:g.name,entitySha:u.sha,entityName:u.name})},g.id)),u.pendingScenarios.map(g=>e.jsx("div",{className:"px-2.5 py-1 bg-[#2a2a2a] text-gray-400 text-[10px] rounded-full",title:g,children:g},g))]})]},u.sha))]}),(L.length>0||I.length>0)&&e.jsxs("div",{className:`pt-2 mt-1 ${B.length>0?"":"border-t border-[#3d3d3d]"}`,children:[e.jsx("div",{className:"px-2 py-1",children:e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Functions"})}),L.map(u=>e.jsxs("div",{className:"mt-2",children:[e.jsxs("div",{className:"px-2 py-1",children:[e.jsx("span",{className:"text-[11px] font-medium text-gray-300",children:u.name}),u.isAnalyzing&&u.scenarioCount===0&&e.jsxs("span",{className:"ml-2 inline-flex items-center gap-1.5 text-[10px] text-gray-400",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[#005c75] animate-pulse"}),"Analyzing..."]})]}),e.jsx(Y,{filePath:u.filePath,projectRoot:s}),u.testFile?e.jsx(Le,{testFile:u.testFile,entityName:u.name}):e.jsx("div",{className:"px-2 pt-1",children:e.jsx("span",{className:"text-[10px] text-gray-500",children:"No test file"})})]},u.sha)),I.map(u=>e.jsxs("div",{className:"mt-2",children:[e.jsx("div",{className:"px-2 py-1",children:e.jsx("span",{className:"text-[11px] font-medium text-gray-300",children:u.name})}),e.jsx(Y,{filePath:u.filePath,projectRoot:s}),e.jsx(Le,{testFile:u.testFile,entityName:u.name})]},u.name))]})]})})}function ls(t,s,n=new Date){const l={"1d":1,"3d":3,"7d":7,"30d":30}[s],h=new Date(n);h.setDate(h.getDate()-l);const c=h.toISOString().split("T")[0],o=t.filter(y=>y.date>=c),p=new Set(o.map(y=>y.commitSha).filter(Boolean)),x=new Map;for(const y of o)if(y.scenarioScreenshots)for(const w of y.scenarioScreenshots){x.has(w.name)||x.set(w.name,[]);const M=x.get(w.name);M.some(b=>b.path===w.path)||M.push({path:w.path,time:y.time})}for(const y of x.values())y.sort((w,M)=>w.time.localeCompare(M.time));const k=[],S=new Map;for(const[y,w]of x){const M=y.indexOf(" - ");if(M!==-1){const b=y.slice(0,M);S.has(b)||S.set(b,[]),S.get(b).push({name:y,screenshots:w})}else k.push({name:y,screenshots:w})}return{commitCount:p.size,entryCount:o.length,appScenarios:k,componentGroups:S,totalScenarios:x.size}}function os(t){const s=new Map;for(const n of[...t].reverse()){const l=s.get(n.date)||[];l.push(n),s.set(n.date,l)}return s}function cs(t){const s=new Map;for(const n of t){let l;if("componentName"in n&&n.componentName)l=n.componentName;else if("componentName"in n&&n.componentName===null)l="App";else{const c=n.name.indexOf(" - ");l=c!==-1?n.name.slice(0,c):"App"}const h=s.get(l)||[];h.push(n),s.set(l,h)}return[...s.entries()].sort(([n],[l])=>n==="App"?-1:l==="App"?1:n.localeCompare(l))}const st=120;function pt({text:t,theme:s}){const[n,l]=a.useState(!1),h=t.length>st,c=h&&!n?t.slice(0,st)+"…":t,o=s==="light";return e.jsxs("div",{className:`px-4 py-2 ${o?"border-b border-gray-200 bg-gray-50":"border-b border-[#3d3d3d] bg-[#252525]"}`,children:[e.jsx("span",{className:"text-[9px] font-semibold uppercase tracking-wider text-gray-500",children:"User Prompt"}),e.jsxs("p",{className:`text-[11px] mt-0.5 mb-0 leading-relaxed ${o?"text-gray-600":"text-gray-400"}`,children:[c,h&&e.jsx("button",{onClick:()=>l(!n),className:`ml-1 text-[11px] font-medium bg-transparent border-none p-0 cursor-pointer ${o?"text-blue-500 hover:text-blue-700":"text-[#00a0c4] hover:text-[#00c0e8]"}`,children:n?"Show less":"Read more…"})]})]})}function nt({status:t}){const s={new:{label:"New",bg:"bg-green-900/40",text:"text-green-400",border:"border-green-700/50"},edited:{label:"Edited",bg:"bg-blue-900/40",text:"text-blue-400",border:"border-blue-700/50"},impacted:{label:"Impacted",bg:"bg-amber-900/40",text:"text-amber-400",border:"border-amber-700/50"}}[t.status];return e.jsx("span",{className:`${s.bg} ${s.text} ${s.border} border text-[8px] font-bold px-1 py-0 rounded-full uppercase tracking-wider`,children:s.label})}function ds({testFile:t,entityName:s}){const{results:n,isRunning:l,runTests:h}=Be(t);if(l&&!n)return e.jsxs("div",{className:"pt-1 flex items-center gap-1.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[#00a0c4] animate-pulse"}),e.jsx("span",{className:"text-[10px] text-gray-500",children:"Running tests..."})]});if(!n)return null;if(n.status==="error")return e.jsx("div",{className:"pt-1",children:e.jsx("span",{className:"text-[10px] text-red-400",children:n.errorMessage})});const c=s?n.testCases.filter(x=>x.fullName.startsWith(s)):n.testCases,o=c.length>0?c:n.testCases;if(o.length===0)return null;const p=s?`${s} > `:"";return e.jsxs("div",{className:"pt-1 space-y-0.5",children:[o.map(x=>{var S;const k=p&&x.fullName.startsWith(p)?x.fullName.slice(p.length):x.fullName;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[x.status==="passed"?e.jsx("span",{className:"text-green-400 text-[10px]",children:"✓"}):x.status==="failed"?e.jsx("span",{className:"text-red-400 text-[10px]",children:"✗"}):e.jsx("span",{className:"text-gray-500 text-[10px]",children:"—"}),e.jsx("span",{className:`text-[10px] ${x.status==="passed"?"text-green-400":x.status==="failed"?"text-red-400":"text-gray-500"}`,children:k})]}),x.status==="failed"&&((S=x.failureMessages)==null?void 0:S.map((y,w)=>e.jsx("div",{className:"pl-4 text-[9px] text-red-400/70 truncate max-w-full",title:y,children:y.split(`
4
- `)[0]},w)))]},x.fullName)}),e.jsx("button",{onClick:h,disabled:l,className:"mt-1 text-[10px] text-[#00a0c4] hover:text-[#38bdf8] transition-colors cursor-pointer disabled:opacity-50 bg-transparent border-none p-0",children:l?"Running...":"Re-run"})]})}const xs={added:"text-green-400",untracked:"text-green-400",modified:"text-blue-400",renamed:"text-purple-400"};function ms({files:t}){return e.jsxs("div",{className:"border-t border-[#3d3d3d] pt-2 mt-1",children:[e.jsxs("span",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider",children:["Modified Files (",t.length,")"]}),e.jsx("div",{className:"mt-1 space-y-0.5 max-h-[150px] overflow-auto",children:t.map(s=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:`text-[9px] font-bold uppercase w-[14px] text-center ${xs[s.status]||"text-gray-500"}`,children:s.status==="added"||s.status==="untracked"?"A":s.status==="modified"?"M":s.status==="renamed"?"R":"?"}),e.jsx("span",{className:"text-[10px] text-gray-400 truncate font-mono",children:s.path})]},s.path))})]})}const ps={feature:{label:"Feature",color:"bg-[#005c75]"},fix:{label:"Fix",color:"bg-amber-700"},refactor:{label:"Refactor",color:"bg-purple-700"},scaffold:{label:"Scaffold",color:"bg-green-700"},data:{label:"Data",color:"bg-blue-700"},milestone:{label:"Milestone",color:"bg-yellow-600"}};function us(t){try{return new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}}function hs(t){try{return new Date(t+"T00:00:00").toLocaleDateString([],{weekday:"long",month:"long",day:"numeric"})}catch{return t}}const fs=[{value:"1d",label:"1 Day"},{value:"3d",label:"3 Days"},{value:"7d",label:"1 Week"},{value:"30d",label:"1 Month"}];function gs({entries:t,onScreenshotClick:s}){const[n,l]=a.useState(!1),[h,c]=a.useState("7d"),o=a.useMemo(()=>ls(t,h),[t,h]);return e.jsxs("div",{className:"bg-[#2d2d2d] rounded-lg overflow-hidden",children:[e.jsxs("button",{onClick:()=>l(!n),className:"w-full flex items-center justify-between px-3 py-2.5 cursor-pointer bg-transparent border-none text-left hover:bg-[#333] transition-colors",children:[e.jsx("span",{className:"text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"Timeframe Summary"}),e.jsx("span",{className:`text-gray-500 text-[10px] transition-transform ${n?"rotate-180":""}`,children:"▼"})]}),n&&e.jsxs("div",{className:"px-3 pb-3 space-y-3 border-t border-[#3d3d3d]",children:[e.jsx("div",{className:"flex gap-1 pt-2.5",children:fs.map(p=>e.jsx("button",{onClick:()=>c(p.value),className:`px-2.5 py-1 text-[10px] font-medium rounded transition-colors cursor-pointer border ${h===p.value?"bg-[#005c75] text-white border-[#005c75]":"bg-transparent text-gray-400 border-[#4d4d4d] hover:text-white hover:border-[#005c75]"}`,children:p.label},p.value))}),e.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-gray-400",children:[e.jsxs("span",{children:[e.jsx("span",{className:"text-white font-medium",children:o.commitCount})," ",o.commitCount===1?"commit":"commits"]}),e.jsx("span",{className:"text-[#3d3d3d]",children:"|"}),e.jsxs("span",{children:[e.jsx("span",{className:"text-white font-medium",children:o.totalScenarios})," ",o.totalScenarios===1?"scenario changed":"scenarios changed"]}),e.jsx("span",{className:"text-[#3d3d3d]",children:"|"}),e.jsxs("span",{children:[e.jsx("span",{className:"text-white font-medium",children:o.entryCount})," ",o.entryCount===1?"entry":"entries"]})]}),o.totalScenarios===0?e.jsx("p",{className:"text-[11px] text-gray-500 italic m-0",children:"No scenario changes in this period."}):e.jsxs("div",{className:"space-y-3",children:[o.appScenarios.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("span",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider",children:"Application"}),o.appScenarios.map(p=>e.jsx(at,{scenario:p,onScreenshotClick:s},p.name))]}),o.componentGroups.size>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("span",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider",children:"Components"}),[...o.componentGroups.entries()].sort(([p],[x])=>p.localeCompare(x)).map(([p,x])=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("span",{className:"text-[10px] font-medium text-gray-400",children:p}),x.map(k=>e.jsx(at,{scenario:k,onScreenshotClick:s},k.name))]},p))]})]})]})]})}function at({scenario:t,onScreenshotClick:s}){const n=t.name.indexOf(" - "),l=n!==-1?t.name.slice(n+3):t.name;return e.jsxs("div",{className:"pl-2",children:[e.jsx("span",{className:"text-[10px] text-gray-500 block mb-1",children:l}),e.jsx("div",{className:"flex items-center gap-1 overflow-x-auto",children:t.screenshots.map((h,c)=>e.jsxs("div",{className:"flex items-center shrink-0",children:[c>0&&e.jsx("span",{className:"text-[8px] text-gray-600 mx-0.5",children:"→"}),e.jsx("button",{type:"button",className:"w-16 h-16 rounded overflow-hidden border border-[#3d3d3d] hover:border-[#00a0c4] bg-[#1e1e1e] shrink-0 flex items-center justify-center cursor-pointer transition-colors",title:`${t.name} (${new Date(h.time).toLocaleDateString()})`,onClick:()=>s==null?void 0:s({screenshotUrl:`/api/editor-journal-image/${h.path.replace("screenshots/","")}`,commitSha:null,commitMessage:null,scenarioName:t.name}),children:e.jsx("img",{src:`/api/editor-journal-image/${h.path.replace("screenshots/","")}`,alt:t.name,className:"max-w-full max-h-full object-contain",loading:"lazy"})})]},h.path))})]})}function js({isActive:t,onScreenshotClick:s,glossaryFunctions:n=[]}){const[l,h]=a.useState([]),[c,o]=a.useState(!0),[p,x]=a.useState(new Set),k=a.useCallback(w=>{x(M=>{const b=new Set(M);return b.has(w)?b.delete(w):b.add(w),b})},[]),S=a.useCallback(async()=>{try{const w=await fetch("/api/editor-journal");if(w.ok){const M=await w.json();h(M.entries||[])}}catch{}finally{o(!1)}},[]);if(a.useEffect(()=>{S()},[S]),a.useEffect(()=>{t&&S()},[t,S]),a.useEffect(()=>{if(!t)return;const w=setInterval(()=>void S(),5e3);return()=>clearInterval(w)},[t,S]),c)return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx("span",{className:"text-gray-500 text-sm",children:"Loading journal..."})});if(l.length===0)return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center text-gray-500 px-8",children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"No journal entries yet"}),e.jsx("p",{className:"text-xs",children:"Journal entries will appear as you build. Claude records features, screenshots, and commits as the project evolves."})]})});const y=os(l);return e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsx(gs,{entries:l,onScreenshotClick:s}),[...y.entries()].map(([w,M])=>e.jsxs("div",{children:[e.jsx("div",{className:"px-3 py-1.5 sticky top-0 bg-[#1e1e1e] z-10",children:e.jsx("span",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider",children:hs(w)})}),e.jsx("div",{className:"space-y-2",children:M.map((b,B)=>{const L=ps[b.type]||{label:b.type,color:"bg-gray-600"},I=`${b.time}-${B}`,U=p.has(I);return e.jsxs("div",{className:"bg-[#2d2d2d] rounded-lg overflow-hidden",children:[e.jsxs("div",{className:`p-3 space-y-2 ${U?"":"max-h-[300px] overflow-y-auto"}`,children:[e.jsx("div",{className:"flex items-start gap-2 cursor-pointer",onClick:()=>k(I),children:e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-white truncate",children:b.title}),e.jsx("span",{className:`${L.color} text-white text-[9px] font-bold px-1.5 py-0.5 rounded uppercase tracking-wider shrink-0`,children:L.label})]}),e.jsx("span",{className:"text-[10px] text-gray-500",children:us(b.time)}),b.featureName&&e.jsx("span",{className:"text-[10px] text-gray-500 italic truncate",title:b.featureName,children:b.featureName})]})}),b.userPrompt&&e.jsx(pt,{text:b.userPrompt,theme:"dark"}),e.jsx("p",{className:"text-xs text-gray-400 leading-relaxed",children:b.description}),b.screenshot&&e.jsx("button",{type:"button",className:"rounded overflow-hidden border border-[#3d3d3d] hover:border-[#00a0c4] bg-[#1e1e1e] flex items-center justify-center p-1 cursor-pointer transition-colors w-full",onClick:()=>s==null?void 0:s({screenshotUrl:`/api/editor-journal-image/${b.screenshot.replace("screenshots/","")}`,commitSha:b.commitSha,commitMessage:b.commitMessage,scenarioName:b.title}),children:e.jsx("img",{src:`/api/editor-journal-image/${b.screenshot.replace("screenshots/","")}`,alt:b.title,className:"max-w-full max-h-full object-contain",loading:"lazy"})}),b.scenarioScreenshots&&b.scenarioScreenshots.length>0&&(()=>{const R=cs(b.scenarioScreenshots),$=b.entityChangeStatus,D=R.filter(([m])=>m==="App").flatMap(([,m])=>m),u=R.filter(([m])=>m!=="App"),g=new Map;for(const m of D){const i=te(m.url??null),v=g.get(i)||[];v.push(m),g.set(i,v)}const d=[...g.entries()],f=m=>e.jsx("button",{type:"button",className:"w-[4.5rem] h-[4.5rem] rounded overflow-hidden border border-[#3d3d3d] hover:border-[#00a0c4] bg-[#1e1e1e] shrink-0 flex items-center justify-center cursor-pointer transition-colors",onClick:()=>s==null?void 0:s({screenshotUrl:`/api/editor-journal-image/${m.path.replace("screenshots/","")}`,commitSha:b.commitSha,commitMessage:b.commitMessage,scenarioName:m.name}),children:e.jsx("img",{src:`/api/editor-journal-image/${m.path.replace("screenshots/","")}`,alt:m.name,title:m.name,className:"max-w-full max-h-full object-contain",loading:"lazy"})},m.path);return e.jsxs("div",{className:"space-y-2",children:[d.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("span",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider",children:"Application"}),d.map(([m,i])=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[10px] font-medium text-gray-400",children:m}),($==null?void 0:$[m])&&e.jsx(nt,{status:$[m]})]}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-0.5",children:i.map(f)})]},m))]}),u.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("span",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider",children:"Components"}),u.map(([m,i])=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[10px] font-medium text-gray-400",children:m}),($==null?void 0:$[m])&&e.jsx(nt,{status:$[m]})]}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-0.5",children:i.map(f)})]},m))]})]})})(),n.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("span",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider",children:"Functions"}),e.jsx("div",{className:"space-y-2",children:n.map(R=>e.jsxs("div",{children:[e.jsx("span",{className:"text-[11px] font-medium text-gray-200",children:R.name}),e.jsx("span",{className:"text-[9px] text-gray-500 truncate block",children:R.filePath}),R.testFile?e.jsx(ds,{testFile:R.testFile,entityName:R.name}):e.jsx("div",{className:"pt-1",children:e.jsx("span",{className:"text-[10px] text-gray-500",children:"No test file"})})]},R.name))})]}),b.commitSha&&e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px]",children:[e.jsx("span",{className:"font-mono text-[#00a0c4] bg-[#00a0c4]/10 px-1.5 py-0.5 rounded",children:b.commitSha.slice(0,7)}),e.jsx("span",{className:"text-gray-500 truncate",children:b.commitMessage})]}),U&&b.modifiedFiles&&b.modifiedFiles.length>0&&e.jsx(ms,{files:b.modifiedFiles})]}),e.jsxs("button",{onClick:()=>k(I),className:"w-full py-1.5 text-[10px] text-gray-500 hover:text-gray-300 border-t border-[#3d3d3d] transition-colors cursor-pointer",children:["——— ",U?"Collapse":"Expand"," ———"]})]},I)})})]},w))]})})}const rt=()=>e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",className:"text-gray-500 shrink-0",children:e.jsx("path",{d:"M4.5 3L7.5 6L4.5 9",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})});function bs(t,s){if(t.length<=s)return t;const n=s-2;return[t[0],"ellipsis",...t.slice(t.length-n)]}function vs({items:t,onNavigate:s}){if(t.length===0)return null;const n=bs(t,4);return e.jsx("nav",{className:"flex items-center gap-1 text-xs min-w-0",children:n.map((l,h)=>{if(l==="ellipsis")return e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(rt,{}),e.jsx("span",{className:"text-gray-500",children:"..."})]},"ellipsis");const c=h===n.length-1;return e.jsxs("span",{className:"flex items-center gap-1 min-w-0",children:[h>0&&e.jsx(rt,{}),c?e.jsx("span",{className:"text-white font-medium truncate",children:l.name}):e.jsx("button",{onClick:()=>s(l.componentName),className:"text-gray-400 hover:text-white transition-colors cursor-pointer bg-transparent border-none p-0 truncate",children:l.name})]},l.componentName||"app")})})}function me({imgSrc:t,name:s,isActive:n,onSelect:l}){return e.jsxs("button",{onClick:l,className:"flex flex-col items-center gap-1 cursor-pointer group w-full",title:s,children:[e.jsx("div",{className:`w-full aspect-square rounded overflow-hidden border-2 transition-all bg-[#1a1a1a] ${n?"border-[#005c75] ring-1 ring-[#005c75]":"border-transparent hover:border-[#4d4d4d]"}`,children:t?e.jsx("img",{src:t,alt:s,className:"w-full h-full object-contain",loading:"lazy"}):e.jsx("div",{className:"w-full h-full bg-[#1a1a1a] flex items-center justify-center",children:e.jsx("span",{className:"text-[8px] text-gray-600",children:"No img"})})}),e.jsx("span",{className:`text-[10px] leading-tight text-center truncate w-full ${n?"text-white":"text-gray-500 group-hover:text-gray-300"}`,children:s})]})}function fe({filePath:t}){return t?e.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[e.jsxs("a",{href:`/api/editor-file?path=${encodeURIComponent(t)}`,target:"_blank",rel:"noopener noreferrer",title:"Open file",className:"flex items-center gap-1 text-gray-500 hover:text-gray-300 transition-colors min-w-0",children:[e.jsx("span",{className:"text-[9px] truncate",children:t}),e.jsx("svg",{className:"shrink-0",width:"10",height:"10",viewBox:"0 0 12 12",fill:"none",children:e.jsx("path",{d:"M4.5 1.5H2.5C1.95 1.5 1.5 1.95 1.5 2.5V9.5C1.5 10.05 1.95 10.5 2.5 10.5H9.5C10.05 10.5 10.5 10.05 10.5 9.5V7.5M7.5 1.5H10.5M10.5 1.5V4.5M10.5 1.5L5 7",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})})]}),e.jsx(Ae,{content:t,icon:!0,iconSize:10,className:"shrink-0 text-gray-500 hover:text-gray-300 transition-colors"})]}):null}function Ns({hasProject:t,scenarios:s,analyzedEntities:n,glossaryFunctions:l=[],glossaryEntries:h=[],projectRoot:c,activeScenarioId:o,onScenarioSelect:p,onAnalyzedScenarioSelect:x,onSwitchToBuild:k,zoomComponent:S,onZoomChange:y,entityImports:w,pageFilePaths:M={},projectTitle:b,projectDescription:B,breadcrumbItems:L=[]}){const{pageGroups:I,componentGroups:U}=a.useMemo(()=>{var v;const f=new Map,m=new Map;for(const C of s)if(C.componentName){const P=m.get(C.componentName)||[];P.push(C),m.set(C.componentName,P)}else if(De(C.url)){const P=(v=C.url)==null?void 0:v.match(/[?&]c=([^&]+)/),_=P?decodeURIComponent(P[1]):"Isolated",J=m.get(_)||[];J.push(C),m.set(_,J)}else{const P=te(C.url),_=f.get(P)||[];_.push(C),f.set(P,_)}const i=new Map([...m.entries()].sort(([C],[P])=>C.localeCompare(P)));return{pageGroups:f,componentGroups:i}},[s]),R=a.useMemo(()=>n.filter(f=>f.entityType==="visual").sort((f,m)=>f.name.localeCompare(m.name)),[n]),$=a.useMemo(()=>{const f=new Map;for(const m of l)f.set(m.name,m);return f},[l]),D=a.useRef(null),u=a.useRef(0),g=a.useCallback(()=>{D.current&&(u.current=D.current.scrollTop)},[]);if(a.useEffect(()=>{D.current&&u.current>0&&(D.current.scrollTop=u.current)}),!t)return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx("h2",{className:"text-lg font-medium text-white font-['IBM_Plex_Sans'] m-0",children:"Ready to build something?"}),e.jsx("button",{onClick:k,className:"px-6 py-3 bg-[#005c75] text-white text-sm font-medium rounded-lg hover:bg-[#004d63] transition-colors cursor-pointer",children:"Start Building"})]})});if(!(s.length>0||R.length>0))return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-4 px-8 text-center",children:[b?e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"text-lg font-medium text-white font-['IBM_Plex_Sans'] m-0",children:b}),B&&e.jsx("p",{className:"text-sm text-gray-400 m-0 font-['IBM_Plex_Sans'] leading-relaxed",children:B})]}):e.jsx("h2",{className:"text-lg font-medium text-white font-['IBM_Plex_Sans'] m-0",children:"Your project is ready"}),e.jsx("p",{className:"text-sm text-gray-400 m-0 font-['IBM_Plex_Sans'] leading-relaxed",children:"Describe what you want to build in the Chat and your pages and components will appear here."}),e.jsx("button",{onClick:k,className:"px-6 py-3 bg-[#005c75] text-white text-sm font-medium rounded-lg hover:bg-[#004d63] transition-colors cursor-pointer",children:"Start Building"})]})});if(S){const f=I.get(S)||[],m=U.get(S)||[],i=R.find(j=>j.name===S),v=$.get(S),C=[...f,...m],P=new Set((w==null?void 0:w[S])||[]),_=P.size>0,J=_?[...U.entries()].filter(([j])=>P.has(j)):[],q=_?R.filter(j=>P.has(j.name)&&!J.some(([O])=>O===j.name)):[],X=_?h.filter(j=>P.has(j.name)&&j.returnType!=="JSX.Element"&&j.returnType!=="React.ReactNode").map(j=>({name:j.name,filePath:j.filePath,description:j.description||"",testFile:j.testFile,feature:j.feature})):[],se=J.length>0||q.length>0,ne=X.length>0,ae=se||ne;return e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsx(vs,{items:L,onNavigate:y}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold text-white m-0 font-['IBM_Plex_Sans'] uppercase tracking-wider",children:S}),(()=>{const j=(v==null?void 0:v.filePath)||(i==null?void 0:i.filePath)||M[S];return j?e.jsx(fe,{filePath:j,projectRoot:c}):null})()]}),C.length>0&&e.jsx("div",{className:"grid grid-cols-3 gap-2",children:C.map(j=>e.jsx(me,{imgSrc:j.screenshotPath?`/api/editor-scenario-image/${j.id}.png${j.updatedAt?`?v=${encodeURIComponent(j.updatedAt)}`:""}`:null,name:j.name,isActive:j.id===o,onSelect:()=>p(j)},j.id))}),i&&(i.scenarios.length>0||i.pendingScenarios.length>0)&&e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[i.scenarios.map(j=>e.jsx(me,{imgSrc:j.screenshotPath?`/api/screenshot/${j.screenshotPath}`:null,name:j.name,isActive:!1,onSelect:()=>x({analysisId:i.analysisId,scenarioId:j.id,scenarioName:j.name,entitySha:i.sha,entityName:i.name})},j.id)),i.pendingScenarios.map(j=>e.jsx("div",{className:"px-2.5 py-1 bg-[#2a2a2a] text-gray-400 text-[10px] rounded-full",title:j,children:j},j))]}),v&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[10px] text-gray-500",children:"Tests:"}),e.jsx(fe,{filePath:v.testFile,projectRoot:c})]}),C.length===0&&!i&&!v&&e.jsx("div",{className:"text-xs text-gray-500",children:"No scenarios for this entity"}),ae&&e.jsxs("div",{className:"pt-3 mt-2 border-t border-[#3d3d3d] space-y-3",children:[se&&e.jsxs("div",{children:[e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Components"}),J.map(([j,O])=>e.jsxs("div",{className:"mt-3",children:[e.jsx("div",{className:"py-1",children:e.jsx("button",{onClick:()=>y(j),className:"text-[11px] font-medium text-gray-400 cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:j})}),O.length>0&&e.jsx("div",{className:"grid grid-cols-3 gap-2 pt-1",children:O.map(G=>e.jsx(me,{imgSrc:G.screenshotPath?`/api/editor-scenario-image/${G.id}.png${G.updatedAt?`?v=${encodeURIComponent(G.updatedAt)}`:""}`:null,name:G.name,isActive:G.id===o,onSelect:()=>p(G)},G.id))})]},j)),q.map(j=>e.jsxs("div",{className:"mt-3",children:[e.jsx("div",{className:"py-1",children:e.jsx("button",{onClick:()=>y(j.name),className:"text-[11px] font-medium text-gray-400 cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:j.name})}),(j.scenarios.length>0||j.pendingScenarios.length>0)&&e.jsxs("div",{className:"grid grid-cols-3 gap-2 pt-1",children:[j.scenarios.map(O=>e.jsx(me,{imgSrc:O.screenshotPath?`/api/screenshot/${O.screenshotPath}`:null,name:O.name,isActive:!1,onSelect:()=>x({analysisId:j.analysisId,scenarioId:O.id,scenarioName:O.name,entitySha:j.sha,entityName:j.name})},O.id)),j.pendingScenarios.map(O=>e.jsx("div",{className:"px-2.5 py-1 bg-[#2a2a2a] text-gray-400 text-[10px] rounded-full",title:O,children:O},O))]})]},j.sha))]}),ne&&e.jsxs("div",{children:[e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Functions"}),X.map(j=>e.jsxs("div",{className:"mt-2",children:[e.jsx("div",{className:"py-1",children:e.jsx("button",{onClick:()=>y(j.name),className:"text-[11px] font-medium text-gray-400 cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:j.name})}),e.jsx(fe,{filePath:j.filePath,projectRoot:c}),j.testFile&&e.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[e.jsx("span",{className:"text-[9px] text-gray-600",children:"test:"}),e.jsx("span",{className:"text-[9px] text-gray-500 truncate",children:j.testFile})]})]},j.name))]})]})]})})}return e.jsx("div",{ref:D,onScroll:g,className:"flex-1 overflow-auto",children:e.jsxs("div",{className:"p-4 space-y-4",children:[b&&e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-white m-0 font-['IBM_Plex_Sans']",children:b}),B&&e.jsx("p",{className:"text-xs text-gray-400 m-0 mt-1 font-['IBM_Plex_Sans'] leading-relaxed",children:B})]}),I.size>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Application"}),e.jsx("button",{onClick:k,className:"px-2.5 py-1 text-[10px] font-medium text-gray-400 bg-[#2a2a2a] border border-[#4d4d4d] rounded hover:bg-[#333] hover:text-white hover:border-[#005c75] transition-colors cursor-pointer",children:"+ New Page"})]}),e.jsxs("p",{className:"text-[11px] text-gray-500 m-0 mt-1.5 font-['IBM_Plex_Sans'] leading-relaxed",children:["Select a page scenario below and switch to"," ",e.jsx("button",{onClick:k,className:"text-[#00a0c4] hover:text-[#00c4eb] bg-transparent border-none p-0 cursor-pointer underline font-inherit text-inherit",children:"Build"})," ","to change or enhance an existing page or"," ",e.jsx("button",{onClick:k,className:"text-[#00a0c4] hover:text-[#00c4eb] bg-transparent border-none p-0 cursor-pointer underline font-inherit text-inherit",children:"create a new page"})]}),[...I.entries()].sort(([f],[m])=>f==="Home"?-1:m==="Home"?1:f.localeCompare(m)).map(([f,m])=>e.jsxs("div",{className:"mt-2",children:[e.jsx("div",{className:"py-1",children:e.jsx("button",{onClick:()=>y(f),className:"text-[11px] font-medium text-gray-400 cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:f})}),M[f]&&e.jsx(fe,{filePath:M[f],projectRoot:c}),e.jsx("div",{className:"grid grid-cols-3 gap-2 pt-1",children:m.map(i=>e.jsx(me,{imgSrc:i.screenshotPath?`/api/editor-scenario-image/${i.id}.png${i.updatedAt?`?v=${encodeURIComponent(i.updatedAt)}`:""}`:null,name:i.name,isActive:i.id===o,onSelect:()=>p(i)},i.id))})]},f))]})]})})}const it={new:0,edited:1,impacted:2};function lt({status:t,onClick:s}){const n={new:{label:"New",bg:"bg-green-100",text:"text-green-700",border:"border-green-200"},edited:{label:"Edited",bg:"bg-blue-100",text:"text-blue-700",border:"border-blue-200"},impacted:{label:"Impacted",bg:"bg-amber-100",text:"text-amber-700",border:"border-amber-200"}}[t.status],l=s&&(t.status==="edited"||t.status==="impacted");return e.jsx("button",{onClick:l?s:void 0,className:`${n.bg} ${n.text} ${n.border} border text-[9px] font-bold px-1.5 py-0.5 rounded-full uppercase tracking-wider shrink-0 ${l?"cursor-pointer hover:opacity-80 transition-opacity":"cursor-default"}`,children:n.label})}function ot({filePath:t}){const[s,n]=a.useState(null),[l,h]=a.useState(!0),[c,o]=a.useState(null);return a.useEffect(()=>{es(()=>import("./index-yHOVb4rc.js"),__vite__mapDeps([0,1])).then(p=>{o(()=>p.default)})},[]),a.useEffect(()=>{h(!0),fetch(`/api/editor-file-diff?path=${encodeURIComponent(t)}`).then(p=>p.json()).then(p=>{n({oldContent:p.oldContent,newContent:p.newContent})}).catch(()=>{n(null)}).finally(()=>h(!1))},[t]),l?e.jsx("div",{className:"p-2 text-[10px] text-gray-400",children:"Loading diff..."}):!s||!c?e.jsx("div",{className:"p-2 text-[10px] text-gray-400",children:"Could not load diff"}):e.jsx("div",{className:"mt-2 border border-gray-200 rounded-lg overflow-hidden max-h-[300px] overflow-auto text-xs",children:e.jsx(c,{oldValue:s.oldContent,newValue:s.newContent,splitView:!1,useDarkTheme:!1,showDiffOnly:!0,styles:{contentText:{fontSize:"11px",lineHeight:"1.4"},line:{padding:"1px 8px",fontSize:"11px"}}})})}function ct({impactedBy:t,changedEntities:s}){return e.jsx("div",{className:"mt-2 bg-amber-50 border border-amber-200 rounded-lg p-2.5",children:t&&t.length>0?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-[10px] font-semibold text-amber-700 uppercase tracking-wider",children:"Re-captured because these dependencies changed"}),e.jsx("ul",{className:"mt-1.5 space-y-1",children:t.map(n=>e.jsxs("li",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:`text-[9px] font-bold px-1 py-0 rounded-full uppercase tracking-wider border ${n.changeType==="new"?"bg-green-100 text-green-700 border-green-200":"bg-blue-100 text-blue-700 border-blue-200"}`,children:n.changeType==="new"?"New":"Edited"}),e.jsx("span",{className:"text-[11px] font-medium text-amber-800",children:n.name}),e.jsx("span",{className:"text-[9px] text-amber-500 truncate",children:n.filePath})]},n.filePath))})]}):s&&s.length>0?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-[10px] font-semibold text-amber-700 uppercase tracking-wider",children:"Unchanged — these entities were modified in this session"}),e.jsx("ul",{className:"mt-1.5 space-y-1",children:s.map(n=>e.jsxs("li",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:`text-[9px] font-bold px-1 py-0 rounded-full uppercase tracking-wider border ${n.status==="new"?"bg-green-100 text-green-700 border-green-200":"bg-blue-100 text-blue-700 border-blue-200"}`,children:n.status==="new"?"New":"Edited"}),e.jsx("span",{className:"text-[11px] font-medium text-amber-800",children:n.name})]},n.name))})]}):e.jsx("span",{className:"text-[10px] text-amber-600",children:"This component was re-captured because a dependency changed"})})}function dt({scenarioId:t,name:s,isActive:n,onSelect:l,updatedAt:h}){const[c,o]=a.useState(!1),p=a.useRef(null);a.useEffect(()=>{o(!1)},[t]),a.useEffect(()=>{n&&p.current&&p.current.scrollIntoView({block:"nearest",behavior:"smooth"})},[n]);const x=`/api/editor-scenario-image/${t}.png${h?`?v=${encodeURIComponent(h)}`:""}`;return e.jsxs("button",{ref:p,onClick:l,className:"flex flex-col items-center gap-1.5 cursor-pointer group",title:s,children:[e.jsx("div",{className:`w-32 h-32 rounded-lg overflow-hidden border-2 transition-all ${n?"border-[#0ea5e9] ring-2 ring-[#0ea5e9]/40 shadow-lg shadow-[#0ea5e9]/20":"border-gray-200 hover:border-gray-400 shadow-sm"}`,children:c?e.jsx("div",{className:"w-full h-full bg-gray-100 flex items-center justify-center",children:e.jsx("span",{className:"text-[9px] text-gray-400",children:"No preview"})}):e.jsx("img",{src:x,alt:s,className:"w-full h-full object-contain bg-white",loading:"lazy",onError:()=>o(!0)})}),e.jsx("span",{className:`text-[11px] leading-tight text-center truncate w-32 font-medium ${n?"text-gray-900":"text-gray-600 group-hover:text-gray-900"}`,children:s})]})}function ys({filePath:t}){return t?e.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[e.jsxs("a",{href:`/api/editor-file?path=${encodeURIComponent(t)}`,target:"_blank",rel:"noopener noreferrer",title:"Open file",className:"flex items-center gap-1 text-gray-400 hover:text-gray-600 transition-colors min-w-0",children:[e.jsx("span",{className:"text-[9px] truncate",children:t}),e.jsx("svg",{className:"shrink-0",width:"10",height:"10",viewBox:"0 0 12 12",fill:"none",children:e.jsx("path",{d:"M4.5 1.5H2.5C1.95 1.5 1.5 1.95 1.5 2.5V9.5C1.5 10.05 1.95 10.5 2.5 10.5H9.5C10.05 10.5 10.5 10.05 10.5 9.5V7.5M7.5 1.5H10.5M10.5 1.5V4.5M10.5 1.5L5 7",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})})]}),e.jsx(Ae,{content:t,icon:!0,iconSize:10,className:"shrink-0 text-gray-400 hover:text-gray-600 transition-colors"})]}):null}function ws({testFile:t,entityName:s}){const{results:n,isRunning:l,runTests:h}=Be(t);if(l&&!n)return e.jsxs("div",{className:"pt-1 flex items-center gap-1.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[#0ea5e9] animate-pulse"}),e.jsx("span",{className:"text-[10px] text-gray-400",children:"Running tests..."})]});if(!n)return null;if(n.status==="error")return e.jsx("div",{className:"pt-1",children:e.jsx("span",{className:"text-[10px] text-red-500",children:n.errorMessage})});const c=s?n.testCases.filter(x=>x.fullName.startsWith(s)):n.testCases,o=c.length>0?c:n.testCases;if(o.length===0)return null;const p=s?`${s} > `:"";return e.jsxs("div",{className:"pt-1 space-y-0.5",children:[o.map(x=>{var S;const k=p&&x.fullName.startsWith(p)?x.fullName.slice(p.length):x.fullName;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[x.status==="passed"?e.jsx("span",{className:"text-green-600 text-[10px]",children:"✓"}):x.status==="failed"?e.jsx("span",{className:"text-red-500 text-[10px]",children:"✗"}):e.jsx("span",{className:"text-gray-400 text-[10px]",children:"—"}),e.jsx("span",{className:`text-[10px] ${x.status==="passed"?"text-green-600":x.status==="failed"?"text-red-500":"text-gray-400"}`,children:k})]}),x.status==="failed"&&((S=x.failureMessages)==null?void 0:S.map((y,w)=>e.jsx("div",{className:"pl-4 text-[9px] text-red-400 truncate max-w-full",title:y,children:y.split(`
5
- `)[0]},w)))]},x.fullName)}),e.jsx("button",{onClick:h,disabled:l,className:"mt-1 text-[10px] text-[#0ea5e9] hover:text-[#38bdf8] transition-colors cursor-pointer disabled:opacity-50 bg-transparent border-none p-0",children:l?"Running...":"Re-run"})]})}function xt(t){const s=t.indexOf(" - ");return s!==-1?t.slice(s+3):t}function mt(t,s){return!s||Object.keys(s).length===0?t:[...t].sort(([n],[l])=>{var p,x;const h=((p=s[n])==null?void 0:p.status)||"impacted",c=((x=s[l])==null?void 0:x.status)||"impacted",o=(it[h]??2)-(it[c]??2);return o!==0?o:n.localeCompare(l)})}function Ss({scenarios:t,allScenarios:s=[],glossaryFunctions:n=[],projectRoot:l,activeScenarioId:h,onScenarioSelect:c,onClose:o,entityChangeStatus:p={},modifiedFiles:x=[],featureName:k,userPrompt:S}){const y=a.useMemo(()=>{if(s.length===0||Object.keys(p).length===0)return t;const d=new Set(t.map(m=>m.id)),f=s.filter(m=>{var v;if(d.has(m.id))return!1;const i=m.componentName||te(m.url);return((v=p[i])==null?void 0:v.status)==="impacted"});return f.length===0?t:[...t,...f]},[t,s,p]),w=a.useMemo(()=>Object.entries(p).filter(([,d])=>d.status==="new"||d.status==="edited").map(([d,f])=>({name:d,status:f.status})),[p]),[M,b]=a.useState(null),B=a.useCallback(d=>{b(f=>f===d?null:d)},[]),{pageGroups:L,componentGroups:I}=a.useMemo(()=>{var m;const d=new Map,f=new Map;for(const i of y)if(i.componentName){const v=f.get(i.componentName)||[];v.push(i),f.set(i.componentName,v)}else if(De(i.url)){const v=(m=i.url)==null?void 0:m.match(/[?&]c=([^&]+)/),C=v?decodeURIComponent(v[1]):"Isolated",P=f.get(C)||[];P.push(i),f.set(C,P)}else{const v=te(i.url),C=d.get(v)||[];C.push(i),d.set(v,C)}return{pageGroups:d,componentGroups:f}},[y]),U=a.useMemo(()=>mt([...L.entries()],p),[L,p]),R=a.useMemo(()=>mt([...I.entries()],p),[I,p]),$=U,D=R,u=a.useMemo(()=>rs(n,p),[n,p]),g=a.useMemo(()=>{const d=[];for(const[,f]of $)d.push(...f);for(const[,f]of D)d.push(...f);return d},[$,D]);return a.useEffect(()=>{if(g.length===0)return;const d=f=>{var P;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(f.key))return;const i=(P=f.target)==null?void 0:P.tagName;if(i==="INPUT"||i==="TEXTAREA"||i==="SELECT")return;f.preventDefault();const v=g.findIndex(_=>_.id===h);let C;f.key==="ArrowLeft"||f.key==="ArrowUp"?C=v<=0?g.length-1:v-1:C=v>=g.length-1?0:v+1,c(g[C])};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[g,h,c]),y.length===0&&n.length===0?e.jsxs("div",{className:"h-full bg-white flex items-center justify-center relative",children:[e.jsx("button",{onClick:o,className:"absolute top-2 right-3 text-gray-400 hover:text-gray-700 text-lg leading-none cursor-pointer bg-transparent border-none",title:"Close results",children:"×"}),e.jsx("span",{className:"text-sm text-gray-400",children:"No scenarios registered yet"})]}):e.jsxs("div",{className:"h-full bg-white flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 border-b border-gray-200 shrink-0",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Working Session Results"}),k&&e.jsx("div",{className:"text-[11px] text-gray-400 truncate",title:k,children:k})]}),e.jsx("button",{onClick:o,className:"text-gray-400 hover:text-gray-700 text-lg leading-none cursor-pointer bg-transparent border-none shrink-0",title:"Close results",children:"×"})]}),S&&e.jsx(pt,{text:S,theme:"light"}),e.jsx("div",{className:"flex-1 overflow-auto p-4",children:e.jsxs("div",{className:"space-y-5",children:[$.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"mb-2",children:e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Application"})}),e.jsx("div",{className:"space-y-3 pl-1",children:$.map(([d,f])=>{var C;const m=p[d],i=M===d,v=(C=f[0])==null?void 0:C.componentPath;return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1.5 flex items-center gap-2",children:[e.jsx("span",{className:"text-[11px] font-medium text-gray-600",children:d}),m&&e.jsx(lt,{status:m,onClick:()=>B(d)})]}),i&&(m==null?void 0:m.status)==="edited"&&v&&e.jsx(ot,{filePath:v}),i&&(m==null?void 0:m.status)==="impacted"&&e.jsx(ct,{impactedBy:m.impactedBy,changedEntities:w}),e.jsx("div",{className:"flex flex-wrap gap-3",children:f.map(P=>e.jsx(dt,{scenarioId:P.id,name:xt(P.name),isActive:P.id===h,onSelect:()=>c(P),updatedAt:P.updatedAt},P.id))})]},d)})})]}),D.length>0&&e.jsxs("div",{className:$.length>0?"pt-3 border-t border-gray-200":"",children:[e.jsx("div",{className:"mb-2",children:e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Components"})}),e.jsx("div",{className:"space-y-3 pl-1",children:D.map(([d,f])=>{var C;const m=p[d],i=M===d,v=(C=f[0])==null?void 0:C.componentPath;return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1.5 flex items-center gap-2",children:[e.jsx("span",{className:"text-[11px] font-medium text-gray-600",children:d}),m&&e.jsx(lt,{status:m,onClick:()=>B(d)})]}),i&&(m==null?void 0:m.status)==="edited"&&v&&e.jsx(ot,{filePath:v}),i&&(m==null?void 0:m.status)==="impacted"&&e.jsx(ct,{impactedBy:m.impactedBy,changedEntities:w}),e.jsx("div",{className:"flex flex-wrap gap-3",children:f.map(P=>e.jsx(dt,{scenarioId:P.id,name:xt(P.name),isActive:P.id===h,onSelect:()=>c(P),updatedAt:P.updatedAt},P.id))})]},d)})})]}),u.length>0&&e.jsxs("div",{className:$.length>0||D.length>0?"pt-3 border-t border-gray-200":"",children:[e.jsx("div",{className:"mb-2",children:e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Functions"})}),e.jsx("div",{className:"space-y-2 pl-1",children:u.map(d=>e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{className:"text-[11px] font-medium text-gray-700",children:d.name})}),e.jsx(ys,{filePath:d.filePath,projectRoot:l}),d.testFile?e.jsx(ws,{testFile:d.testFile,entityName:d.name}):e.jsx("div",{className:"pt-1",children:e.jsx("span",{className:"text-[10px] text-gray-400",children:"No test file"})})]},d.name))})]}),x.length>0&&e.jsxs("div",{className:$.length>0||D.length>0||u.length>0?"pt-3 border-t border-gray-200":"",children:[e.jsx("div",{className:"mb-2",children:e.jsxs("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:["Modified Files (",x.length,")"]})}),e.jsx("div",{className:"space-y-0.5 pl-1 max-h-[200px] overflow-auto",children:x.map(d=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:`text-[9px] font-bold uppercase w-[14px] text-center ${d.status==="added"||d.status==="untracked"?"text-green-600":d.status==="modified"?"text-blue-600":d.status==="renamed"?"text-purple-600":"text-gray-400"}`,children:d.status==="added"||d.status==="untracked"?"A":d.status==="modified"?"M":d.status==="renamed"?"R":"?"}),e.jsx("span",{className:"text-[10px] text-gray-500 truncate font-mono",children:d.path})]},d.path))})]})]})})]})}const ks=[{key:"app",label:"App"},{key:"build",label:"Build"},{key:"data",label:"Structure"},{key:"journal",label:"Journal"}];function Cs({activeTab:t,onTabChange:s,buildIdle:n,zoomComponent:l,breadcrumbItems:h,onBreadcrumbNavigate:c,panelLayout:o,onToggleExpand:p}){return e.jsxs("div",{className:"bg-[#3d3d3d] h-10 flex items-center px-3 gap-3 shrink-0 z-20 border-b border-[#2d2d2d]",children:[e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx("img",{src:ts,alt:"CodeYam",className:"h-5 brightness-0 invert"}),e.jsx("span",{className:"text-white font-medium text-xs whitespace-nowrap",children:"Codeyam Editor"})]}),e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx("div",{className:"flex items-center gap-0.5 bg-[#4a3232] rounded-lg p-0.5",children:ks.map(x=>e.jsxs("button",{onClick:()=>s(x.key),className:`px-2.5 py-1 text-xs font-medium rounded-md transition-colors cursor-pointer ${t===x.key?"bg-[#7a4444] text-white":"text-gray-300 hover:text-white"}`,children:[x.label,x.key==="build"&&n&&t!=="build"&&e.jsx("span",{className:"ml-1 inline-block w-1.5 h-1.5 rounded-full bg-amber-400 animate-pulse"})]},x.key))}),p&&e.jsx("button",{onClick:p,className:"p-1.5 rounded text-gray-400 hover:text-white transition-colors cursor-pointer",title:o==="editor-only"?"Show preview":"Hide preview",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:o==="editor-only"?e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),e.jsx("path",{d:"M9 3v18"}),e.jsx("path",{d:"M16 15l-3-3 3-3"})]}):e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),e.jsx("path",{d:"M9 3v18"}),e.jsx("path",{d:"M14 9l3 3-3 3"})]})})})]})]})}function Ps({preview:t,onDismiss:s,onLoadCommit:n}){return e.jsxs("div",{className:"flex flex-col items-center gap-6 max-w-[700px] w-full",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("h2",{className:"text-lg font-semibold text-[#333] m-0 font-['IBM_Plex_Sans']",children:"Journal Screenshot"}),e.jsx("p",{className:"text-sm text-[#888] mt-1 m-0 font-['IBM_Plex_Sans']",children:"This is a snapshot from a previous version — not a live preview"})]}),e.jsx("div",{className:"rounded-lg overflow-hidden border-2 border-[#ccc] shadow-md max-w-full w-fit",children:e.jsx("img",{src:t.screenshotUrl,alt:t.scenarioName,className:"max-w-full h-auto block"})}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-[#666]",children:[t.commitSha&&e.jsx("span",{className:"font-mono text-xs text-[#00a0c4] bg-[#00a0c4]/15 px-2 py-0.5 rounded",children:t.commitSha.slice(0,7)}),e.jsxs("span",{className:"truncate",children:[t.scenarioName,t.commitMessage&&` — ${t.commitMessage}`]})]}),e.jsx("div",{className:"flex items-center gap-3",children:t.commitSha&&n&&e.jsx(Ms,{commitSha:t.commitSha,onLoadCommit:n})})]})}function Ms({commitSha:t,onLoadCommit:s}){const[n,l]=a.useState(!1),[h,c]=a.useState(null);return e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>{l(!0),c(null),s(t).then(o=>{o.success||c(o.error||"Failed to load commit")}).catch(o=>{c(o instanceof Error?o.message:"Network error")}).finally(()=>l(!1))},disabled:n,className:"bg-[#005c75] hover:bg-[#004d63] disabled:opacity-50 text-white text-sm font-medium px-4 py-1.5 rounded transition-colors cursor-pointer",children:n?"Reverting...":"Revert to this code and load this version"}),h&&e.jsx("div",{className:"bg-red-50 border border-red-200 rounded px-4 py-2 text-sm text-red-600 w-full text-center",children:h})]})}function Es({analysisId:t,scenarioId:s,scenarioName:n,entityName:l,projectSlug:h,onStateChange:c}){const{interactiveServerUrl:o,isStarting:p,isLoading:x}=ss({analysisId:t,scenarioId:s,scenarioName:n,entityName:l,projectSlug:h,enabled:!0});return a.useEffect(()=>{c(o,p||x)},[o,p,x,c]),null}function Is(t,s){return s.status==="error"?{url:null,proxyUrl:null,isStarting:!1,error:s.errorMessage||"Dev server crashed",canStartServer:t.canStartServer,autoStartAttempted:t.autoStartAttempted,shouldAutoStart:!1}:s.url?{url:s.url,proxyUrl:s.proxyUrl||null,isStarting:!1,error:null,canStartServer:!0,autoStartAttempted:t.autoStartAttempted,shouldAutoStart:!1}:s.status==="starting"?{...t,isStarting:!0,error:null,canStartServer:!0,shouldAutoStart:!1}:s.status==="stopped"?t.url?{...t,url:null,isStarting:!1,shouldAutoStart:!1}:t.autoStartAttempted?{...t,isStarting:!1,shouldAutoStart:!1}:{...t,autoStartAttempted:!0,shouldAutoStart:!0}:{...t,shouldAutoStart:!1}}function Rs(){const[t,s]=a.useState({url:null,proxyUrl:null,isStarting:!1,error:null,canStartServer:!0,autoStartAttempted:!1}),n=a.useRef(t);n.current=t,a.useEffect(()=>{let c=!1,o=null;const p=async()=>{try{const x=await fetch("/api/editor-dev-server");if(c)return;const k=await x.json(),S=Is(n.current,k),{shouldAutoStart:y,...w}=S;if(s(w),y)try{const M=await fetch("/api/editor-dev-server",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"start"})});if(c)return;M.ok?s(b=>({...b,isStarting:!0})):s(b=>({...b,canStartServer:!1}))}catch{}}catch{}};return p(),o=setInterval(()=>void p(),2e3),()=>{c=!0,o&&clearInterval(o)}},[t.url]);const l=a.useCallback(()=>{s(c=>({...c,error:null,isStarting:!0})),fetch("/api/editor-dev-server",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"restart"})}).catch(()=>{})},[]),h=a.useCallback(()=>{s(c=>({...c,error:null,isStarting:!0})),fetch("/api/editor-dev-server",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"start"})}).catch(()=>{})},[]);return{devServerUrl:t.url,proxyUrl:t.proxyUrl,isStarting:t.isStarting,error:t.error,canStartServer:t.canStartServer,retryServer:l,startServer:h}}function $s(t){const s=a.useRef(null),n=a.useRef(null);a.useEffect(()=>{if(typeof document>"u")return;n.current||(n.current=document.createElement("canvas"),n.current.width=64,n.current.height=64);const l=document.querySelector('link[rel="icon"]');if(!l)return;if(s.current||(s.current=l.href),!t){l.href=s.current;return}const h=new Image;h.crossOrigin="anonymous",h.onload=()=>{const c=n.current,o=c.getContext("2d");o.clearRect(0,0,64,64),o.drawImage(h,0,0,64,64);const p=18,x=64-p,k=p;o.beginPath(),o.arc(x,k,p+3,0,2*Math.PI),o.fillStyle="#ffffff",o.fill(),o.beginPath(),o.arc(x,k,p,0,2*Math.PI),o.fillStyle="#ef4444",o.fill(),l.href=c.toDataURL("image/png")},h.src=s.current},[t]),a.useEffect(()=>()=>{if(typeof document>"u")return;const l=document.querySelector('link[rel="icon"]');l&&s.current&&(l.href=s.current)},[])}const Gs=()=>[{title:"Editor - CodeYam"},{name:"description",content:"CodeYam Code + Data Editor"}];class Ts extends a.Component{constructor(){super(...arguments);et(this,"state",{error:null,errorInfo:null})}static getDerivedStateFromError(n){return{error:n,errorInfo:null}}componentDidCatch(n,l){console.error("[EditorErrorBoundary] Error:",n.message),console.error("[EditorErrorBoundary] Component stack:",l.componentStack),console.error("[EditorErrorBoundary] Loader snapshot:",JSON.stringify(this.props.loaderSnapshot,null,2)),this.setState({errorInfo:l})}render(){var n;return this.state.error?e.jsx("div",{className:"fixed inset-0 bg-[#1e1e1e] flex items-center justify-center p-8",children:e.jsxs("div",{className:"max-w-[600px] w-full space-y-4",children:[e.jsx("h2",{className:"text-lg font-semibold text-red-400 font-['IBM_Plex_Sans'] m-0",children:"Something went wrong"}),e.jsx("pre",{className:"text-xs text-gray-300 bg-[#2d2d2d] p-3 rounded overflow-auto max-h-[120px]",children:this.state.error.message}),((n=this.state.errorInfo)==null?void 0:n.componentStack)&&e.jsxs("details",{className:"text-xs text-gray-500",children:[e.jsx("summary",{className:"cursor-pointer hover:text-gray-300 transition-colors",children:"Component stack"}),e.jsx("pre",{className:"mt-2 bg-[#2d2d2d] p-3 rounded overflow-auto max-h-[200px] text-yellow-300",children:this.state.errorInfo.componentStack})]}),e.jsx("p",{className:"text-xs text-gray-500 m-0",children:"Full diagnostics are in the browser console."}),e.jsx("button",{onClick:()=>window.location.reload(),className:"px-4 py-2 bg-[#005c75] text-white text-sm rounded hover:bg-[#004d63] transition-colors cursor-pointer",children:"Reload"})]})}):this.props.children}}const Hs=Ot(function(){const{projectSlug:s,projectRoot:n,hasProject:l,scenarios:h,allScenarios:c,analyzedEntities:o,glossaryFunctions:p,glossaryEntries:x,entityImports:k,pageFilePaths:S,entityChangeStatus:y,modifiedFiles:w,featureName:M,userPrompt:b,projectTitle:B,projectDescription:L,defaultScreenSize:I,screenSizes:U,editorStep:R,editorStepLabel:$,claudeSessionId:D}=Ft(),[u,g]=Ut(),d=a.useRef(null),f=a.useRef(null),m=a.useRef(null),i=u.get("zoom")||void 0,v=u.get("scenario")||void 0,[C,P]=a.useState(()=>{if(typeof window>"u")return[];const r=new URLSearchParams(window.location.search).get("zoom");return r?[r]:[]}),_=a.useRef(null),J=a.useRef([]),q=a.useRef(null);a.useEffect(()=>{var A;const r=v||((A=Jt(c))==null?void 0:A.id);if(!Gt(r,_.current))return;const N=c.find(K=>K.id===r);if(!N)return;_.current=r;const E=Te(N,J.current,q.current);E&&Q(E);const T=he(N.name);fetch("/api/editor-switch-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioSlug:T,scenarioId:N.id,scenarioName:N.name,scenarioType:N.type})}).catch(()=>{})},[v,c]),a.useEffect(()=>{const r=new BroadcastChannel("codeyam-editor");return r.onmessage=N=>{var E;if(((E=N.data)==null?void 0:E.type)==="switch-scenario"&&N.data.scenarioId){const T=N.data.scenarioId,A=c.find($e=>$e.id===T);if(!A)return;_.current=T;const K=new URLSearchParams(u);K.set("scenario",T),K.delete("zoom"),g(K),je(null),pe(null),H(null),V(!0);const Bt=he(A.name);fetch("/api/editor-switch-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioSlug:Bt,scenarioId:T,scenarioType:A.type})}).then(()=>{oe($e=>$e+1)}).catch(()=>{V(!1)})}},()=>r.close()},[u,g,c]),a.useEffect(()=>{if(u.get("ref")!=="link"||!v)return;const r=new BroadcastChannel("codeyam-editor");r.postMessage({type:"switch-scenario",scenarioId:v}),r.close(),window.close()},[]);const{devServerUrl:X,proxyUrl:se,isStarting:ne,error:ae,canStartServer:j,retryServer:O,startServer:G}=Rs(),[_e,re]=a.useState(!1),[z,je]=a.useState(null),[Oe,pe]=a.useState(null),[be,Fe]=a.useState(!1),[ve,H]=a.useState(null),ut=a.useCallback(async r=>{const E=await(await fetch("/api/editor-load-commit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({commitSha:r})})).json();return E.success&&(H(null),re(!1)),E},[]),ht=a.useCallback((r,N)=>{pe(E=>(r&&r!==E&&re(!1),r)),!N&&r&&re(!0),Fe(N)},[]),Ue=a.useCallback(r=>{H(null),je(E=>(E&&E.analysisId===r.analysisId||(pe(null),oe(A=>A+1)),r)),Fe(!0),re(!1);const N=new URLSearchParams(u);N.delete("scenario"),N.delete("zoom"),g(N)},[u,g]),[F,Q]=a.useState(I?{name:I.name,width:I.width,height:I.height}:{name:"Desktop",width:1440,height:900}),[ze,We]=a.useState(!1),Je=I?{name:I.name,width:I.width,height:I.height}:null;q.current=Je;const[W,Z]=a.useState("app"),ft=a.useCallback(()=>{Z("build"),ie(!0)},[]),[gt,ie]=a.useState(!1),jt=!!(M&&R),[ue,Ne]=a.useState(jt?"pending":"no-session");a.useEffect(()=>{ue==="pending"&&(Z("build"),ie(!0))},[ue]);const bt=a.useCallback(()=>{Ne("continue")},[]),vt=a.useCallback(()=>{fetch("/api/editor-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"clear"})}).catch(()=>{}),Ne("fresh")},[]),Nt=a.useCallback(()=>{fetch("/api/editor-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"clear"})}).catch(()=>{}),Ne("fresh"),Z("app")},[]),[ye,we]=a.useState(!1),yt=a.useCallback(r=>{we(r)},[]);$s(ye);const[le,Ge]=a.useState("split"),[Se,He]=a.useState(!1),wt=a.useCallback(()=>{He(!0),Z("build"),ie(!0)},[]),Ve=a.useCallback(()=>{He(!1)},[]),St=a.useCallback(r=>{Q(r),fetch("/api/editor-project-info",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({defaultScreenSize:r,skipBroadcast:!0})})},[]),[Ke,Ye]=a.useState(Ht);a.useEffect(()=>{const r=Vt();Ye(r),r.systemNotification&&typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission()},[]);const kt=a.useCallback(r=>{Ye(r),Kt(r)},[]);a.useEffect(()=>{if(W==="build"){we(!1);const r=setTimeout(()=>{var N,E;(N=d.current)==null||N.scrollToBottom(),(E=d.current)==null||E.focus()},50);return()=>clearTimeout(r)}},[W]),a.useEffect(()=>{function r(){!document.hidden&&W==="build"&&we(!1)}return document.addEventListener("visibilitychange",r),()=>document.removeEventListener("visibilitychange",r)},[W]);const[ke,Ct]=a.useState(null);a.useEffect(()=>{const r=m.current;if(!r)return;const N=new ResizeObserver(E=>{const T=E[0];T&&Ct({width:T.contentRect.width,height:T.contentRect.height})});return N.observe(r),()=>N.disconnect()},[]);const ee=a.useMemo(()=>ke?Yt(ke,F):1,[ke,F]),[Ce,oe]=a.useState(0),[qe,Pe]=a.useState(null),[Xe,V]=a.useState(!1),Pt=a.useCallback((r,N)=>{if(Pe(r||null),N){const E=new URLSearchParams(u);E.set("scenario",N),_.current=N,g(E);const T=c.find(A=>A.id===N);if(T){const A=Te(T,J.current,q.current);A&&Q(A)}}H(null),oe(E=>E+1)},[u,g,c]),{customSizes:Me,addCustomSize:Mt,removeCustomSize:Et}=zt(s),Ee=a.useMemo(()=>ns(U),[U]),Ie=a.useMemo(()=>[...Ee,...Me],[Ee,Me]);J.current=Ie;const Qe=a.useMemo(()=>{const r=[{name:"App"}];for(const N of C)r.push({name:N,componentName:N});return r},[C]),Re=a.useCallback(r=>{const N=new URLSearchParams(u);if(r){N.set("zoom",r);const E=C.indexOf(r);E>=0?P(C.slice(0,E+1)):P([...C,r]);const T=c.find(A=>A.componentName===r||A.componentName===null&&te(A.url)===r);if(T){N.set("scenario",T.id),_.current=T.id,V(!0);const A=he(T.name);fetch("/api/editor-switch-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioSlug:A,scenarioId:T.id,scenarioType:T.type})}).then(()=>{oe(K=>K+1)}).catch(()=>{V(!1)})}else N.delete("scenario")}else N.delete("zoom"),N.delete("scenario"),P([]);g(N)},[u,g,c,C]),ce=a.useCallback(r=>{je(null),pe(null),H(null),Pe(null);const N=Te(r,Ie,Je);N&&Q(N),_.current=r.id;const E=new URLSearchParams(u);E.set("scenario",r.id),g(E),V(!0);const T=he(r.name);fetch("/api/editor-switch-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioSlug:T,scenarioId:r.id,scenarioType:r.type,skipBroadcast:!0})}).then(()=>{oe(A=>A+1)}).catch(()=>{V(!1)})},[u,g,Ie]),It=a.useCallback(r=>{if(!r.commitSha){const N=c.find(E=>E.name===r.scenarioName);if(N){ce(N);return}}H(r)},[c,ce]),Rt=r=>{const N={name:r.name,width:r.width,height:r.height};Q(N),fetch("/api/editor-project-info",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({defaultScreenSize:N,skipBroadcast:!0})})},$t=(r,N,E)=>{Mt(r,N,E)},Tt=r=>{Q(r),fetch("/api/editor-project-info",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({defaultScreenSize:r,skipBroadcast:!0})})},Lt=()=>{z||re(!0),V(!1)},de=a.useMemo(()=>qt({activeAnalyzedScenario:!!z,analyzedPreviewUrl:Oe,activeScenarioId:v||null,scenarios:c,proxyUrl:se,devServerUrl:X,zoomComponent:i||null}),[se,X,i,v,c,z,Oe]),Ze=a.useMemo(()=>{const r=Xt(de,qe);if(!r)return null;const N=r.includes("?")?"&":"?";return`${r}${N}__cb=${Ce}`},[de,qe,Ce]),At=a.useMemo(()=>({projectSlug:s,hasProject:l,scenarioCount:h==null?void 0:h.length,allScenarioCount:c==null?void 0:c.length,analyzedEntityCount:o==null?void 0:o.length,glossaryFunctionCount:p==null?void 0:p.length,entityChangeStatusKeys:y?Object.keys(y):[],featureName:M}),[s,l,h,c,o,p,y,M]);return e.jsx(Ts,{loaderSnapshot:At,children:e.jsxs("div",{className:"fixed inset-0 bg-[#2d2d2d] flex flex-col",children:[z&&e.jsx(Es,{analysisId:z.analysisId,scenarioId:z.scenarioId,scenarioName:z.scenarioName,entityName:z.entityName,projectSlug:s,onStateChange:ht},z.analysisId),e.jsxs("div",{className:"flex-1 flex min-h-0",children:[e.jsxs("div",{className:"flex-1 flex flex-col min-w-0",style:le==="editor-only"?{display:"none"}:void 0,children:[e.jsxs("div",{className:"bg-[#2d2d2d] border-b border-[#3d3d3d] shrink-0 z-10 h-10 flex items-center px-4 relative",children:[e.jsx("div",{className:"flex items-center gap-1 shrink-0 z-10",children:e.jsx("button",{onClick:()=>Ge(r=>r==="preview-only"?"split":"preview-only"),className:"p-1.5 rounded text-gray-500 hover:text-gray-300 transition-colors cursor-pointer",title:le==="preview-only"?"Show sidebar":"Hide sidebar",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),e.jsx("path",{d:"M9 3v18"})]})})}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center gap-1 pointer-events-none",children:e.jsxs("div",{className:"flex items-center gap-1 pointer-events-auto",children:[ge.map(r=>e.jsxs("button",{onClick:()=>Rt(r),className:`p-1.5 rounded transition-colors cursor-pointer ${F.name===r.name?"text-white bg-[#555]":"text-gray-500 hover:text-gray-300"}`,title:`${r.name} (${r.width}×${r.height})`,children:[r.name==="Desktop"&&e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2"}),e.jsx("path",{d:"M8 21h8M12 17v4"})]}),r.name==="Laptop"&&e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M4 6a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v8H4V6z"}),e.jsx("path",{d:"M2 18h20"})]}),r.name==="Tablet"&&e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"5",y:"2",width:"14",height:"20",rx:"2"}),e.jsx("path",{d:"M12 18h.01"})]}),r.name==="Mobile"&&e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"7",y:"2",width:"10",height:"20",rx:"2"}),e.jsx("path",{d:"M12 18h.01"})]})]},r.name)),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>We(r=>!r),className:`flex items-center gap-1.5 px-2 py-1 rounded transition-colors cursor-pointer ${ze||!ge.some(r=>r.name===F.name)?"text-white bg-[#555]":"text-gray-400 hover:text-gray-200 hover:bg-[#444]"}`,title:"Custom dimensions",children:[e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M17 3a2.83 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"})}),e.jsxs("span",{className:"text-xs font-mono",children:[F.width," ×"," ",F.height??900]})]}),ze&&e.jsx(Wt,{currentWidth:F.width,currentHeight:F.height??900,devicePresets:Ee,customSizes:Me,onApply:Tt,onSave:$t,onRemove:Et,onClose:()=>We(!1)})]})]})}),e.jsx("div",{className:"ml-auto flex items-center gap-1 shrink-0 z-10",children:e.jsx("button",{onClick:()=>{const r=Ze||de;r&&window.open(r,"_blank")},className:"p-1.5 rounded text-gray-500 hover:text-gray-300 transition-colors cursor-pointer",title:"Open preview in new window",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),e.jsx("polyline",{points:"15 3 21 3 21 9"}),e.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]})})})]}),e.jsx("div",{ref:m,className:"flex-1 flex items-center justify-center overflow-hidden p-8",style:ve?{backgroundColor:"#f5f0e8",backgroundImage:"repeating-linear-gradient(0deg, transparent, transparent 19px, #e8e0d0 19px, #e8e0d0 20px), repeating-linear-gradient(90deg, transparent, transparent 19px, #e8e0d0 19px, #e8e0d0 20px)"}:{backgroundImage:`
6
- linear-gradient(45deg, #333 25%, transparent 25%),
7
- linear-gradient(-45deg, #333 25%, transparent 25%),
8
- linear-gradient(45deg, transparent 75%, #333 75%),
9
- linear-gradient(-45deg, transparent 75%, #333 75%)
10
- `,backgroundSize:"16px 16px",backgroundPosition:"0 0, 0 8px, 8px -8px, -8px 0px",backgroundColor:"#2d2d2d"},children:ve?e.jsx(Ps,{preview:ve,onDismiss:()=>H(null),onLoadCommit:ut}):de?e.jsx("div",{style:{width:`${F.width*ee}px`,height:`${(F.height??900)*ee}px`},children:e.jsxs("div",{className:"relative bg-white origin-top-left",style:{width:`${F.width}px`,height:`${F.height??900}px`,transform:ee<1?`scale(${ee})`:void 0},children:[!_e&&!Xe&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-10",children:e.jsxs("div",{className:"flex flex-col items-center justify-center gap-6 bg-[#2a2a2a] rounded-lg p-8 w-[500px] h-[300px]",children:[e.jsx("div",{className:"mb-4",children:e.jsx(tt,{})}),e.jsxs("div",{className:"flex flex-col gap-3 text-center",children:[e.jsx("h2",{className:"text-xl font-medium text-gray-200 leading-[28px] m-0 font-['IBM_Plex_Sans']",children:"Loading Preview"}),e.jsx("p",{className:"text-sm text-gray-400 leading-5 m-0 font-['IBM_Plex_Sans']",children:"Waiting for the app to render"})]})]})}),Xe&&e.jsx("div",{className:"absolute inset-0 z-20 flex items-center justify-center",style:{backgroundColor:"rgba(0, 0, 0, 0.25)",backdropFilter:"blur(1px)",transition:"opacity 200ms ease-out"},children:e.jsxs("div",{className:"flex flex-col items-center gap-3 animate-pulse",children:[e.jsx("svg",{className:"w-6 h-6 text-white/80 animate-spin",viewBox:"0 0 24 24",fill:"none",children:e.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeDasharray:"50 100"})}),e.jsx("span",{className:"text-white/70 text-xs font-['IBM_Plex_Sans']",children:"Switching scenario"})]})}),e.jsx("iframe",{ref:f,src:Ze||de,className:"w-full h-full border-none",title:"Editor preview",onLoad:Lt,style:{opacity:_e?1:0}},Ce)]})}):e.jsx("div",{className:"bg-[#2a2a2a] rounded-lg flex flex-col items-center justify-center",style:{width:`${F.width*ee}px`,height:`${(F.height??900)*ee}px`},children:ae?e.jsxs("div",{className:"flex flex-col gap-4 text-center px-8 max-w-[600px]",children:[e.jsx("h2",{className:"text-xl font-medium text-red-400 leading-[28px] m-0 font-['IBM_Plex_Sans']",children:"Dev Server Failed"}),e.jsx("pre",{className:"text-xs text-left bg-[#1e1e1e] text-gray-300 p-4 rounded overflow-auto max-h-[300px] w-full font-mono whitespace-pre-wrap",children:ae}),e.jsx("button",{onClick:O,className:"mx-auto px-4 py-2 bg-[#005c75] text-white text-sm font-medium rounded hover:bg-[#004d63] transition-colors cursor-pointer",children:"Retry"})]}):ne||be?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mb-4",children:e.jsx(tt,{})}),e.jsxs("div",{className:"flex flex-col gap-3 text-center",children:[e.jsx("h2",{className:"text-xl font-medium text-gray-200 leading-[28px] m-0 font-['IBM_Plex_Sans']",children:be?"Starting Interactive Mode":"Starting Dev Server"}),e.jsx("p",{className:"text-sm text-gray-400 leading-5 m-0 font-['IBM_Plex_Sans']",children:be?"Loading component preview...":"Your dev server is starting up..."})]})]}):e.jsxs("div",{className:"flex flex-col gap-3 text-center px-8",children:[e.jsx("h2",{className:"text-xl font-medium text-gray-200 leading-[28px] m-0 font-['IBM_Plex_Sans']",children:"Live Preview"}),e.jsx("p",{className:"text-sm text-gray-500 leading-5 m-0 font-['IBM_Plex_Sans']",children:"Describe what you want to build in the Build tab"})]})})})]}),e.jsxs("aside",{className:`bg-[#1e1e1e] border-r border-[#3d3d3d] shrink-0 flex flex-col overflow-hidden order-first ${le==="editor-only"?"w-full max-w-none min-w-0":"w-[50%] min-w-[400px] max-w-[800px]"}`,style:le==="preview-only"?{display:"none"}:void 0,children:[e.jsx(Cs,{activeTab:W,onTabChange:r=>{Z(r),r==="build"&&ie(!0)},buildIdle:ye,zoomComponent:i,breadcrumbItems:Qe,onBreadcrumbNavigate:Re,panelLayout:le,onToggleExpand:()=>Ge(r=>r==="editor-only"?"split":"editor-only")}),e.jsxs("div",{className:"flex-1 overflow-hidden relative",children:[ye&&W!=="build"&&e.jsxs("div",{className:"absolute top-3 left-1/2 -translate-x-1/2 z-50 animate-[slideDown_0.3s_ease-out]",children:[e.jsx("style",{children:`
11
- @keyframes slideDown {
12
- from { transform: translate(-50%, -100%); opacity: 0; }
13
- to { transform: translate(-50%, 0); opacity: 1; }
14
- }
15
- `}),e.jsxs("button",{onClick:()=>{Z("build"),ie(!0)},className:"flex items-center gap-2 px-4 py-2 bg-amber-50 border-2 border-amber-300 rounded-lg shadow-lg cursor-pointer hover:bg-amber-100 transition-colors",children:[e.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-amber-400 animate-pulse"}),e.jsx("span",{className:"text-sm font-medium text-amber-900",children:"Claude is waiting for you"}),e.jsx("span",{className:"text-xs text-amber-600 ml-1",children:"Go to Build"})]})]}),gt&&e.jsxs("div",{className:"absolute inset-0 flex flex-col overflow-hidden",style:{visibility:W==="build"?"visible":"hidden"},children:[e.jsx("div",{className:Se?"flex-1 min-h-0":"flex-1",style:Se?{flex:"1 1 50%"}:void 0,children:ue==="pending"?e.jsx(as,{featureName:M,editorStep:R,editorStepLabel:$,onContinue:bt,onStartFresh:vt,onReview:Nt}):e.jsx(Qt,{ref:d,entityName:"Editor",projectSlug:s,entityFilePath:null,scenarioName:null,onRefreshPreview:Pt,onShowResults:wt,onHideResults:Ve,onSetViewport:St,editorMode:!0,onIdleChange:yt,notificationSettings:Ke,buildTabActive:W==="build",claudeStartMode:ue==="continue"?"resume":"fresh",claudeSessionId:D})}),Se&&e.jsx("div",{style:{flex:"1 1 50%"},className:"min-h-0 border-t-2 border-gray-300",children:e.jsx(Ss,{scenarios:h,allScenarios:c,glossaryFunctions:p,projectRoot:n,activeScenarioId:v,onScenarioSelect:ce,onClose:Ve,entityChangeStatus:y,modifiedFiles:w,featureName:M,userPrompt:b})})]}),e.jsx("div",{className:"absolute inset-0 flex flex-col overflow-hidden",style:{visibility:W==="app"?"visible":"hidden"},children:e.jsx(Ns,{hasProject:l,scenarios:c,analyzedEntities:o,glossaryFunctions:p,glossaryEntries:x,projectRoot:n,activeScenarioId:v,onScenarioSelect:ce,onAnalyzedScenarioSelect:Ue,onSwitchToBuild:ft,zoomComponent:i,onZoomChange:Re,entityImports:k,pageFilePaths:S,projectTitle:B,projectDescription:L,breadcrumbItems:Qe})}),e.jsx("div",{className:"absolute inset-0 flex flex-col overflow-hidden",style:{visibility:W==="data"?"visible":"hidden"},children:e.jsx(is,{scenarios:c,projectRoot:n,activeScenarioId:v,onScenarioSelect:ce,zoomComponent:i,onZoomChange:Re,analyzedEntities:[],glossaryFunctions:p,activeAnalyzedScenarioId:z==null?void 0:z.scenarioId,onAnalyzedScenarioSelect:Ue,entityImports:k,pageFilePaths:S})}),e.jsx("div",{className:"absolute inset-0 flex flex-col overflow-hidden",style:{visibility:W==="journal"?"visible":"hidden"},children:e.jsx(js,{isActive:W==="journal",onScreenshotClick:It,glossaryFunctions:p})})]}),e.jsx(Zt,{serverUrl:X,isStarting:ne,projectSlug:s,devServerError:ae,onStartServer:j?G:void 0,notificationSettings:Ke,onChangeNotificationSettings:kt})]})]})]})})});export{Hs as default,Gs as meta};
@@ -1,41 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/addon-web-links-Duc5hnl7.js","assets/chunk-JZWAC4HX-C4pqxYJB.js"])))=>i.map(i=>d[i]);
2
- import{r as l,j as a}from"./chunk-JZWAC4HX-C4pqxYJB.js";import{_ as V}from"./preload-helper-ckwbz45p.js";const B={sound:"soft-double-tap",systemNotification:!0},de=[{id:"soft-double-tap",label:"Soft double tap"},{id:"gentle-chime",label:"Gentle chime"},{id:"warm-ding",label:"Warm ding"},{id:"mellow-two-tone",label:"Mellow two-tone"},{id:"triangle-bell",label:"Triangle bell"},{id:"off",label:"No sound"}],ne="codeyam-editor-notifications";function ye(){try{const r=localStorage.getItem(ne);if(!r)return B;const n=JSON.parse(r);return typeof n=="string"?n==="true"?B:{...B,sound:"off",systemNotification:!1}:{...B,...n}}catch{return B}}function we(r){localStorage.setItem(ne,JSON.stringify(r))}function oe(r){var n;if(r!=="off")try{const c=new AudioContext,s={"soft-double-tap":e=>{[0,.12].forEach(t=>{const o=e.createOscillator(),y=e.createGain();o.connect(y),y.connect(e.destination),o.type="sine",o.frequency.value=392,y.gain.setValueAtTime(.25,e.currentTime+t),y.gain.exponentialRampToValueAtTime(.01,e.currentTime+t+.1),o.start(e.currentTime+t),o.stop(e.currentTime+t+.1)})},"gentle-chime":e=>{const t=e.createOscillator(),o=e.createGain();t.connect(o),o.connect(e.destination),t.type="sine",t.frequency.setValueAtTime(523,e.currentTime),t.frequency.setValueAtTime(659,e.currentTime+.15),o.gain.setValueAtTime(.3,e.currentTime),o.gain.exponentialRampToValueAtTime(.01,e.currentTime+.4),t.start(),t.stop(e.currentTime+.4)},"warm-ding":e=>{const t=e.createOscillator(),o=e.createGain();t.connect(o),o.connect(e.destination),t.type="sine",t.frequency.value=330,o.gain.setValueAtTime(.35,e.currentTime),o.gain.exponentialRampToValueAtTime(.01,e.currentTime+.6),t.start(),t.stop(e.currentTime+.6)},"mellow-two-tone":e=>{const t=e.createOscillator(),o=e.createGain();t.connect(o),o.connect(e.destination),t.type="sine",t.frequency.setValueAtTime(294,e.currentTime),t.frequency.setValueAtTime(440,e.currentTime+.18),o.gain.setValueAtTime(.3,e.currentTime),o.gain.exponentialRampToValueAtTime(.01,e.currentTime+.5),t.start(),t.stop(e.currentTime+.5)},"triangle-bell":e=>{const t=e.createOscillator(),o=e.createGain();t.connect(o),o.connect(e.destination),t.type="triangle",t.frequency.value=523,o.gain.setValueAtTime(.4,e.currentTime),o.gain.exponentialRampToValueAtTime(.01,e.currentTime+.8),t.start(),t.stop(e.currentTime+.8)}};(n=s[r])==null||n.call(s,c)}catch{}}function ve({serverUrl:r,isStarting:n,projectSlug:c,devServerError:s,onStartServer:e,notificationSettings:t,onChangeNotificationSettings:o}){const[y,S]=l.useState(null),[f,w]=l.useState(!1),A=l.useRef(null),E=l.useRef(null);l.useEffect(()=>{if(!c)return;const p=new EventSource("/api/dev-mode-events");return p.onmessage=_=>{try{const $=JSON.parse(_.data);$.type==="file-synced"&&(S($.fileName),E.current&&clearTimeout(E.current),E.current=setTimeout(()=>{S(null)},5e3))}catch{}},()=>{p.close(),E.current&&clearTimeout(E.current)}},[c]),l.useEffect(()=>{if(!f)return;function p(_){A.current&&!A.current.contains(_.target)&&w(!1)}return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[f]);let T;s?T="error":n?T="starting":r?T="running":T="stopped";const k={starting:"bg-yellow-400",running:"bg-green-400",stopped:"bg-gray-400",error:"bg-red-400"},P={starting:"Starting...",running:r||"Running",stopped:"Stopped",error:"Error"},W=t&&(t.sound!=="off"||t.systemNotification);return a.jsxs("div",{className:"bg-[#1e1e1e] border-t border-[#3d3d3d] h-7 flex items-center px-4 gap-4 shrink-0 text-xs font-mono",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:`w-2 h-2 rounded-full ${k[T]}`}),a.jsxs("span",{className:"text-gray-400",children:["Server:"," ",a.jsx("span",{className:"text-gray-300",children:P[T]})]}),(T==="stopped"||T==="error")&&e&&a.jsx("button",{onClick:e,className:"ml-1 px-2.5 py-0.5 bg-[#005c75] hover:bg-[#007a9a] text-white text-[11px] font-medium rounded transition-colors cursor-pointer border-none leading-tight",children:"Start Server"})]}),a.jsx("div",{className:"w-px h-3 bg-[#3d3d3d]"}),y&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"#4ade80",strokeWidth:"2",children:a.jsx("path",{d:"M20 6L9 17l-5-5"})}),a.jsxs("span",{className:"text-green-400",children:["Synced: ",y]})]}),a.jsx("div",{className:"w-px h-3 bg-[#3d3d3d]"})]}),a.jsx("div",{className:"flex-1"}),o&&t&&a.jsxs("div",{className:"relative",ref:A,children:[a.jsx("button",{onClick:()=>w(!f),className:`text-[11px] rounded transition-colors cursor-pointer ${W?"text-green-400 hover:text-green-300":"text-gray-500 hover:text-gray-300"}`,children:W?"Notifications On":"Notifications Off"}),f&&a.jsxs("div",{className:"absolute bottom-full right-0 mb-2 w-56 bg-[#2d2d2d] border border-[#4d4d4d] rounded-lg shadow-xl p-3 flex flex-col gap-3 z-50",children:[a.jsxs("div",{children:[a.jsx("div",{className:"text-[11px] text-gray-400 mb-1.5",children:"Notification sound"}),a.jsx("div",{className:"flex flex-col gap-0.5",children:de.map(p=>a.jsx("button",{onClick:()=>{o({...t,sound:p.id}),p.id!=="off"&&oe(p.id)},className:`text-left text-[11px] px-2 py-1 rounded cursor-pointer transition-colors ${t.sound===p.id?"bg-[#444] text-white":"text-gray-300 hover:bg-[#3a3a3a]"}`,children:p.label},p.id))})]}),a.jsxs("div",{className:"border-t border-[#4d4d4d] pt-2",children:[a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:t.systemNotification,onChange:p=>{const _=p.target.checked;o({...t,systemNotification:_}),_&&typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission()},className:"accent-green-500"}),a.jsx("span",{className:"text-[11px] text-gray-300",children:"System notification"})]}),a.jsx("div",{className:"text-[10px] text-gray-500 mt-1 ml-5",children:"Shows when tab is not visible"})]})]})]})]})}async function me(r,n){try{const{WebglAddon:s}=await V(async()=>{const{WebglAddon:t}=await import("./addon-webgl-DI8QOUvO.js").then(o=>o.a);return{WebglAddon:t}},[]),e=new s;return e.onContextLoss(()=>{n==null||n("webgl","canvas",new Error("WebGL context lost")),e.dispose(),re(r).then(t=>{t||n==null||n("canvas","dom",new Error("Canvas fallback failed after context loss"))})}),r.loadAddon(e),{type:"webgl",dispose:()=>e.dispose()}}catch(s){n==null||n("webgl","canvas",s)}const c=await re(r);return c||(n==null||n("canvas","dom",new Error("Canvas addon failed")),{type:"dom",dispose:()=>{}})}async function re(r){try{const{CanvasAddon:n}=await V(async()=>{const{CanvasAddon:s}=await import("./addon-canvas-DpzMmAy5.js").then(e=>e.a);return{CanvasAddon:s}},[]),c=new n;return r.loadAddon(c),{type:"canvas",dispose:()=>c.dispose()}}catch{return null}}const fe=`
3
- .xterm { cursor: text; position: relative; user-select: none; -ms-user-select: none; -webkit-user-select: none; }
4
- .xterm.focus, .xterm:focus { outline: none; }
5
- .xterm .xterm-helpers { position: absolute; top: 0; z-index: 5; }
6
- .xterm .xterm-helper-textarea { padding: 0; border: 0; margin: 0; position: absolute; opacity: 0; left: -9999em; top: 0; width: 0; height: 0; z-index: -5; white-space: nowrap; overflow: hidden; resize: none; }
7
- .xterm .composition-view { background: #000; color: #FFF; display: none; position: absolute; white-space: nowrap; z-index: 1; }
8
- .xterm .composition-view.active { display: block; }
9
- .xterm .xterm-viewport { background-color: #000; overflow-y: scroll; cursor: default; position: absolute; right: 0; left: 0; top: 0; bottom: 0; }
10
- .xterm .xterm-screen { position: relative; }
11
- .xterm .xterm-screen canvas { position: absolute; left: 0; top: 0; }
12
- .xterm .xterm-scroll-area { visibility: hidden; }
13
- .xterm-char-measure-element { display: inline-block; visibility: hidden; position: absolute; top: 0; left: -9999em; line-height: normal; }
14
- .xterm.enable-mouse-events { cursor: default; }
15
- .xterm.xterm-cursor-pointer, .xterm .xterm-cursor-pointer { cursor: pointer; }
16
- .xterm.column-select.focus { cursor: crosshair; }
17
- .xterm .xterm-accessibility:not(.debug), .xterm .xterm-message { position: absolute; left: 0; top: 0; bottom: 0; right: 0; z-index: 10; color: transparent; pointer-events: none; }
18
- .xterm .xterm-accessibility-tree:not(.debug) *::selection { color: transparent; }
19
- .xterm .xterm-accessibility-tree { user-select: text; white-space: pre; }
20
- .xterm .live-region { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
21
- .xterm-dim { opacity: 1 !important; }
22
- .xterm-underline-1 { text-decoration: underline; }
23
- .xterm-underline-2 { text-decoration: double underline; }
24
- .xterm-underline-3 { text-decoration: wavy underline; }
25
- .xterm-underline-4 { text-decoration: dotted underline; }
26
- .xterm-underline-5 { text-decoration: dashed underline; }
27
- .xterm-overline { text-decoration: overline; }
28
- .xterm-strikethrough { text-decoration: line-through; }
29
- .xterm-screen .xterm-decoration-container .xterm-decoration { z-index: 6; position: absolute; }
30
- .xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer { z-index: 7; }
31
- .xterm-decoration-overview-ruler { z-index: 8; position: absolute; top: 0; right: 0; pointer-events: none; }
32
- .xterm-decoration-top { z-index: 2; position: relative; }
33
- `;function pe(){if(document.getElementById("xterm-css"))return;const r=document.createElement("style");r.id="xterm-css",r.textContent=fe,document.head.appendChild(r)}const be=l.forwardRef(function({entityName:n,entityType:c,entitySha:s,entityFilePath:e,scenarioName:t,scenarioDescription:o,analysisId:y,projectSlug:S,onRefreshPreview:f,onShowResults:w,onHideResults:A,onSetViewport:E,editorMode:T,onIdleChange:k,notificationSettings:P,buildTabActive:W,claudeStartMode:p,claudeSessionId:_},$){const J=l.useRef(null),z=l.useRef(null),M=l.useRef(null),j=l.useRef(null),q=l.useRef(null),H=l.useRef(!1),D=l.useRef(0),U=l.useRef(!1),N=l.useRef(k);N.current=k;const Z=l.useRef(P);Z.current=P;const Q=l.useRef(W);Q.current=W;const O=l.useRef(null);function X(){O.current&&(O.current.close(),O.current=null)}l.useEffect(()=>{function m(){X()}function x(){document.hidden||X()}return window.addEventListener("focus",m),document.addEventListener("visibilitychange",x),()=>{window.removeEventListener("focus",m),document.removeEventListener("visibilitychange",x)}},[]);const ie=l.useCallback(()=>{var m;(m=M.current)==null||m.focus()},[]);return l.useImperativeHandle($,()=>({sendInput(m){const x=j.current;x&&x.readyState===WebSocket.OPEN&&(x.send(JSON.stringify({type:"input",data:m})),setTimeout(()=>{x.readyState===WebSocket.OPEN&&x.send(JSON.stringify({type:"input",data:"\r"}))},100))},focus(){var m;(m=M.current)==null||m.focus()},scrollToBottom(){var x;const m=(x=J.current)==null?void 0:x.querySelector(".xterm-viewport");m&&(m.scrollTop=m.scrollHeight)}})),l.useEffect(()=>{const m=J.current;if(!m)return;let x=!1;return pe(),Promise.all([V(()=>import("./xterm-BqvuqXEL.js"),[]),V(()=>import("./addon-fit-YJmn1quW.js"),[]),V(()=>import("./addon-web-links-Duc5hnl7.js").then(L=>L.a),__vite__mapDeps([0,1]))]).then(([L,se,ce])=>{if(x)return;const u=new L.Terminal({cursorBlink:!0,scrollback:5e3,fontSize:13,fontFamily:"'IBM Plex Mono', 'Menlo', 'Monaco', monospace",theme:{background:"#1e1e1e",foreground:"#d4d4d4",cursor:"#d4d4d4",selectionBackground:"#264f78"},linkHandler:{activate(d,i){try{const h=new URL(i),v=h.searchParams.get("scenario");if(v&&h.pathname==="/editor"){const b=new BroadcastChannel("codeyam-editor");b.postMessage({type:"switch-scenario",scenarioId:v}),b.close();return}}catch{}window.open(i,"_blank")}}}),I=new se.FitAddon;u.loadAddon(I),u.loadAddon(new ce.WebLinksAddon),u.open(m);let G=null;me(u,(d,i,h)=>{console.warn(`[Terminal] Renderer fallback: ${d} → ${i}`,h)}).then(d=>{if(x){d.dispose();return}console.log(`[Terminal] Using ${d.type} renderer`),G=d.dispose}),requestAnimationFrame(()=>{try{I.fit()}catch{}}),M.current=u,u.focus(),setTimeout(()=>u.focus(),100),setTimeout(()=>u.focus(),500);const ae=window.location.protocol==="https:"?"wss:":"ws:",le=window.location.host;function ue(d){const i=new URLSearchParams;return i.set("entityName",n),c&&i.set("entityType",c),s&&i.set("entitySha",s),e&&i.set("entityFilePath",e),t&&i.set("scenarioName",t),o&&i.set("scenarioDescription",o),y&&i.set("analysisId",y),S&&i.set("projectSlug",S),T&&i.set("editorMode","true"),d&&i.set("reconnectId",d),p&&i.set("claudeStartMode",p),_&&i.set("claudeSessionId",_),`${ae}//${le}/ws/terminal?${i.toString()}`}function K(d){const i=ue(d),h=new WebSocket(i);j.current=h,h.onopen=()=>{D.current=0,U.current=!1,h.send(JSON.stringify({type:"resize",cols:u.cols,rows:u.rows}))},h.onmessage=v=>{var b,ee,te;try{const g=JSON.parse(v.data);if(g.type==="session-id"){q.current=g.sessionId;return}if(g.type==="refresh-preview"){f==null||f(g.path,g.scenarioId);return}if(g.type==="show-results"){w==null||w();return}if(g.type==="hide-results"){A==null||A();return}if(g.type==="set-viewport"){E==null||E({name:g.name,width:g.width,height:g.height});return}if(g.type==="claude-idle"){(b=N.current)==null||b.call(N,!0);const R=Z.current;if(Q.current)return;if(R!=null&&R.sound&&R.sound!=="off"&&oe(R.sound),!document.hasFocus()&&(R!=null&&R.systemNotification)&&typeof Notification<"u"&&Notification.permission==="granted"){O.current&&O.current.close();const Y=new Notification("Claude is ready for you",{body:"Claude has finished and is waiting for your input.",tag:"claude-idle"});Y.onclick=()=>{window.focus(),Y.close()},O.current=Y}return}if(g.type==="claude-active"){(ee=N.current)==null||ee.call(N,!1),O.current&&(O.current.close(),O.current=null);return}g.type==="output"&&(u.write(g.data),(te=N.current)==null||te.call(N,!1))}catch{u.write(v.data)}},h.onclose=()=>{if(H.current){u.write(`\r
34
- \x1B[90m[Terminal session ended]\x1B[0m\r
35
- `);return}const v=D.current;if(v<5&&q.current){const b=1e3*Math.pow(2,Math.min(v,3));D.current=v+1,u.write(`\r
36
- \x1B[33m[Reconnecting...]\x1B[0m\r
37
- `),setTimeout(()=>{H.current||K(q.current)},b)}else U.current?u.write(`\r
38
- \x1B[90m[Terminal session ended]\x1B[0m\r
39
- `):(U.current=!0,u.write(`\r
40
- \x1B[33m[Starting new session...]\x1B[0m\r
41
- `),q.current=null,D.current=0,K())},h.onerror=()=>{}}K(),u.onData(d=>{const i=j.current;i&&i.readyState===WebSocket.OPEN&&i.send(JSON.stringify({type:"input",data:d})),X()});let C=null;const F=new ResizeObserver(()=>{C&&clearTimeout(C),C=setTimeout(()=>{let d;try{d=I.proposeDimensions()}catch{return}if(!d||d.cols===u.cols&&d.rows===u.rows)return;const i=m.querySelector(".xterm-viewport");let h,v=!0;i&&(h=i.scrollTop,v=i.scrollTop+i.clientHeight>=i.scrollHeight-10),I.fit(),i&&h!==void 0&&(v?i.scrollTop=i.scrollHeight:i.scrollTop=h);const b=j.current;b&&b.readyState===WebSocket.OPEN&&b.send(JSON.stringify({type:"resize",cols:u.cols,rows:u.rows}))},150)});F.observe(m),z.current=()=>{var d;C&&clearTimeout(C),F.disconnect(),H.current=!0,(d=j.current)==null||d.close(),j.current=null,G==null||G(),u.dispose(),M.current=null}}),()=>{var L;x=!0,(L=z.current)==null||L.call(z),z.current=null}},[]),a.jsx("div",{ref:J,onClick:ie,className:"w-full h-full",style:{padding:"4px 0 0 8px"}})});function xe(r){return r.replace(/[^a-zA-Z0-9_]+/g,"_")}function Te(r){const{activeAnalyzedScenario:n,analyzedPreviewUrl:c,activeScenarioId:s,scenarios:e,proxyUrl:t,devServerUrl:o,zoomComponent:y}=r;if(n&&c)return c;if(n&&!c)return null;if(s){const f=e.find(w=>w.id===s);if(f!=null&&f.url){const w=t||o;return w?f.url.startsWith("/")?`${w}${f.url}`:f.url:null}}const S=t||o;if(!S)return null;if(y&&s){const f=e.find(A=>A.id===s),w=f?xe(f.name):"Default";return`${S}/__codeyam__/${y}/${w}`}return S}function Ne(r,n){if(!r||!n)return r;try{const c=new URL(r),s=n.indexOf("?");return s>=0?(c.pathname=n.slice(0,s),c.search=n.slice(s)):(c.pathname=n,c.search=""),c.href}catch{return r}}function Se(r,n){return r?r!==n:!1}function Ae(r){if(r.length!==0)return r.find(n=>n.type==="application")||r[0]}function Ee(r,n,c){if(!r.viewportWidth||!r.viewportHeight)return c??null;const s=n.find(e=>e.width===r.viewportWidth&&e.height===r.viewportHeight);return{name:(s==null?void 0:s.name)||"Custom",width:r.viewportWidth,height:r.viewportHeight}}function _e(r,n){const c=n.width,s=n.height??900,e=r.width,t=r.height;return c<=e&&s<=t?1:Math.min(e/c,t/s)}export{ve as D,be as T,Ne as a,xe as b,B as c,we as d,_e as e,Te as f,Ae as g,ye as l,Ee as r,Se as s};
@@ -1,6 +0,0 @@
1
- import{a as V,j as e,w as re,u as oe,r as i}from"./chunk-JZWAC4HX-C4pqxYJB.js";import{u as le,S as W}from"./Spinner-Bb5uFQ5V.js";import{u as ce}from"./useLastLogLine-C14nCb1q.js";import{V as de}from"./ViewportInspectBar-oAf2Kqsf.js";import{u as he,S as xe}from"./useCustomSizes-C-_hOl_g.js";import{c as me}from"./cy-logo-cli-DcX-ZS3p.js";import{I as E}from"./InlineSpinner-Bu6c6aDe.js";import{a as ue,T as pe,D as ge}from"./editorPreview-7Uga8I59.js";import{S as fe}from"./SafeScreenshot-BED4B6sP.js";import"./preload-helper-ckwbz45p.js";function ve({scenarios:w,currentScenarioId:r,entitySha:s,cacheBuster:l}){const c=V();return w.length===0?e.jsx("div",{className:"flex-1 flex items-center justify-center p-8",children:e.jsx("p",{className:"text-gray-500 text-sm",children:"No scenarios found"})}):e.jsx("div",{className:"flex-1 overflow-y-auto p-3 space-y-3",children:w.map(o=>{var j,u;const g=o.id===r,f=(u=(j=o.metadata)==null?void 0:j.screenshotPaths)==null?void 0:u[0];return e.jsxs("button",{onClick:()=>{c(`/entity/${s}/scenarios/${o.id}/dev`)},className:`w-full text-left rounded-lg overflow-hidden border transition-colors cursor-pointer flex ${g?"border-[#005c75] bg-[#1a3a44]":"border-[#3d3d3d] bg-[#252525] hover:border-[#555]"}`,children:[e.jsx("div",{className:"w-24 h-20 shrink-0 bg-[#1a1a1a]",children:e.jsx(fe,{screenshotPath:f,cacheBuster:l,alt:o.name,className:"w-full h-full object-cover object-top"})}),e.jsxs("div",{className:"p-2.5 min-w-0 flex-1",children:[e.jsxs("div",{className:"text-white text-sm font-medium truncate",children:[g&&e.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-[#005c75] mr-1.5 relative top-[-1px]"}),o.name]}),o.description&&e.jsx("div",{className:"text-gray-400 text-xs mt-1 line-clamp-2",children:o.description})]})]},o.id)})})}const I=[{name:"Mobile",width:375,height:667},{name:"Tablet",width:768,height:1024},{name:"Laptop",width:1024,height:768},{name:"Desktop",width:1440,height:900}],Me=re(function(){const{entity:r,scenario:s,analysis:l,projectSlug:c}=oe(),o=V(),g=i.useRef(null),f=i.useRef(null),[j,u]=i.useState(null),[A,M]=i.useState(1440),[n,N]=i.useState({name:"Desktop",width:1440,height:900}),[H,y]=i.useState(!1),[S,U]=i.useState(null),[d,k]=i.useState("chat"),[F,q]=i.useState(0),[D,$]=i.useState(null),K=i.useCallback(t=>{$(t||null),q(a=>a+1)},[]),{customSizes:_,addCustomSize:Y}=he(c),v=i.useMemo(()=>[...I,..._],[_]),{interactiveServerUrl:h,isStarting:C,isLoading:z,showIframe:B,iframeKey:G,onIframeLoad:J}=le({analysisId:l==null?void 0:l.id,scenarioId:s==null?void 0:s.id,scenarioName:s==null?void 0:s.name,projectSlug:c,enabled:!0,refreshTrigger:F}),O=i.useMemo(()=>ue(h,D),[h,D]),{lastLine:b}=ce(c,C||z),Q=()=>{o(`/entity/${r.sha}`)},X=(t,a)=>{M(t);const m=v.find(T=>T.width===t&&T.height===a);u(m||null),N({name:(m==null?void 0:m.name)||"Custom",width:t,height:a})},R=t=>{u(t),M(t.width),N({name:t.name,width:t.width,height:t.height})},Z=t=>{Y(t,n.width,n.height??900),y(!1),N(a=>({...a,name:t}))},ee=()=>{var a;k("chat"),(a=f.current)==null||a.sendInput("Create a new scenario for this entity based on the work we've just done. Create a name and description that reflects what the live preview is showing. Use the scenario data you've changed to create a new scenario in the database. If the data structure was fixed in any way you need to update that in the database as well and backfill all existing scenarios, then save to the database and capture a screenshot. Remember the database is at `.codeyam/db.sqlite3`, the scenarios table has all scenarios and the analyses table contains the scenariosDataStructure is its metadata.")},x=((l==null?void 0:l.scenarios)||[]).filter(t=>{var a;return!((a=t.metadata)!=null&&a.sameAsDefault)}),p=x.findIndex(t=>t.id===(s==null?void 0:s.id)),te=p+1,se=x.length,L=p>0,P=p<x.length-1,ae=()=>{if(L){const t=x[p-1];o(`/entity/${r.sha}/scenarios/${t.id}/dev`)}},ne=()=>{if(P){const t=x[p+1];o(`/entity/${r.sha}/scenarios/${t.id}/dev`)}},ie=C||z||!B;return e.jsxs("div",{className:"fixed inset-0 bg-[#2d2d2d] flex flex-col",children:[e.jsxs("div",{className:"bg-[#3d3d3d] h-12 flex items-center px-4 gap-4 shrink-0 z-20",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[e.jsx("img",{src:me,alt:"CodeYam",className:"h-6 brightness-0 invert"}),e.jsx("span",{className:"text-white font-medium text-sm whitespace-nowrap",children:r.name}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx("button",{onClick:ae,disabled:!L,className:`${L?"text-white hover:text-gray-300":"text-gray-600 cursor-not-allowed"} transition-colors`,"aria-label":"Previous scenario",children:e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:e.jsx("path",{d:"M12.5 15L7.5 10L12.5 5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}),e.jsxs("span",{className:"text-gray-400 text-sm",children:[te,"/",se]}),e.jsx("button",{onClick:ne,disabled:!P,className:`${P?"text-white hover:text-gray-300":"text-gray-600 cursor-not-allowed"} transition-colors`,"aria-label":"Next scenario",children:e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:e.jsx("path",{d:"M7.5 15L12.5 10L7.5 5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-2 min-w-0",children:[e.jsx("span",{className:"text-white font-semibold text-xs whitespace-nowrap shrink-0",children:s==null?void 0:s.name}),(s==null?void 0:s.description)&&e.jsxs("div",{className:"relative group min-w-0",children:[e.jsx("span",{className:"text-gray-400 text-xs truncate block",children:s.description}),e.jsx("div",{className:"absolute left-0 top-full mt-1 hidden group-hover:block z-50 bg-black text-white text-xs px-3 py-2 rounded shadow-lg max-w-md",children:s.description})]})]}),e.jsx("span",{className:"bg-[#005c75] text-white text-[10px] font-bold px-2 py-0.5 rounded uppercase tracking-wider ml-2",children:"Dev Mode"})]}),e.jsx("button",{onClick:Q,className:"text-white hover:text-gray-300 transition-colors ml-4","aria-label":"Close dev mode",children:e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:e.jsx("path",{d:"M15 5L5 15M5 5L15 15",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})})]}),e.jsxs("div",{className:"flex-1 flex min-h-0",children:[e.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[e.jsxs("div",{className:"bg-[#e5e7eb] border-b border-[rgba(0,0,0,0.1)] shrink-0 z-10 h-6 flex items-center justify-center relative",children:[e.jsx("div",{className:"absolute inset-0 flex justify-center",children:e.jsx("div",{style:{maxWidth:`${I[I.length-1].width}px`,width:"100%"},children:e.jsx(de,{currentViewportWidth:A,currentPresetName:n.name,onDevicePresetClick:R,devicePresets:v,hideLabel:!0,onHoverChange:U,lightMode:!0})})}),e.jsxs("div",{className:"relative z-10 flex items-center gap-2",children:[e.jsxs("div",{className:"relative w-28 h-5",children:[e.jsxs("div",{className:"absolute inset-0 bg-white text-gray-900 text-xs px-2 rounded flex items-center justify-between pointer-events-none border border-gray-300",children:[e.jsx("span",{className:"leading-none",children:(S==null?void 0:S.name)||n.name}),e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 12 12",fill:"none",className:"shrink-0",children:e.jsx("path",{d:"M3 4.5L6 7.5L9 4.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),e.jsxs("select",{value:n.name,onChange:t=>{const a=v.find(m=>m.name===t.target.value);a&&R(a)},className:"relative w-full h-full opacity-0 cursor-pointer",children:[v.map(t=>e.jsx("option",{value:t.name,children:t.name},t.name)),n.name==="Custom"&&e.jsx("option",{value:"Custom",children:"Custom"})]})]}),e.jsx("input",{type:"number",value:n.width,onChange:t=>{const a=parseInt(t.target.value,10);!isNaN(a)&&a>0&&X(a,n.height??900)},className:"bg-white text-gray-900 text-xs px-1 rounded border border-gray-300 outline-none w-16 text-center h-5 leading-none",min:"200",max:"3840"}),e.jsx("span",{className:"text-gray-400 text-xs h-5 flex items-center leading-none",children:"x"}),e.jsx("span",{className:"bg-gray-100 text-gray-600 text-xs px-1 rounded w-14 text-center h-5 flex items-center justify-center leading-none",children:n.height??900}),n.name==="Custom"&&e.jsx("button",{onClick:()=>y(!0),className:"bg-white text-gray-900 text-xs px-2 rounded h-5 flex items-center leading-none border border-gray-300 hover:bg-gray-50 transition-colors",children:"Save"})]})]}),e.jsx("div",{className:"flex-1 flex items-center justify-center overflow-auto p-8",style:{backgroundImage:`
2
- linear-gradient(45deg, #ebebeb 25%, transparent 25%),
3
- linear-gradient(-45deg, #ebebeb 25%, transparent 25%),
4
- linear-gradient(45deg, transparent 75%, #ebebeb 75%),
5
- linear-gradient(-45deg, transparent 75%, #ebebeb 75%)
6
- `,backgroundSize:"16px 16px",backgroundPosition:"0 0, 0 8px, 8px -8px, -8px 0px",backgroundColor:"#fafafa"},children:h?e.jsxs("div",{className:"relative bg-white w-full h-full",style:{maxWidth:`${n.width}px`,maxHeight:`${n.height}px`},children:[ie&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-10",children:e.jsxs("div",{className:"flex flex-col items-center justify-center gap-6 bg-white rounded-lg p-8 shadow-sm w-[500px] h-[300px]",children:[e.jsx("div",{className:"mb-4",children:e.jsx(W,{})}),e.jsxs("div",{className:"flex flex-col gap-3 text-center",children:[e.jsx("h2",{className:"text-xl font-medium text-black leading-[28px] m-0 font-['IBM_Plex_Sans']",children:"Loading Preview"}),e.jsx("p",{className:"text-sm text-[#666] leading-5 m-0 font-['IBM_Plex_Sans']",children:"Waiting for the dev server to be ready"}),b&&e.jsxs("p",{className:"text-xs font-mono text-[#005c75] text-center leading-5 m-0 mt-3 font-['IBM_Plex_Mono'] uppercase",children:[e.jsx(E,{}),b]})]})]})}),e.jsx("iframe",{ref:g,src:O||h,className:"w-full h-full border-none",title:`Dev mode preview: ${s==null?void 0:s.name}`,onLoad:J,style:{opacity:B?1:0}},G)]}):e.jsxs("div",{className:"flex flex-col items-center justify-center gap-6 w-[500px] h-[300px] bg-white rounded-lg p-8 shadow-sm",children:[e.jsx("div",{className:"mb-4",children:e.jsx(W,{})}),e.jsxs("div",{className:"flex flex-col gap-3 text-center",children:[e.jsx("h2",{className:"text-xl font-medium text-black leading-[28px] m-0 font-['IBM_Plex_Sans']",children:"Starting Dev Mode"}),e.jsx("p",{className:"text-sm text-[#666] leading-5 m-0 font-['IBM_Plex_Sans']",children:"Setting up a sandboxed environment with live preview"}),b&&e.jsxs("p",{className:"text-xs font-mono text-[#005c75] text-center leading-5 m-0 mt-3 font-['IBM_Plex_Mono'] uppercase",children:[e.jsx(E,{}),b]})]})]})})]}),e.jsxs("aside",{className:"w-[50%] min-w-[400px] max-w-[800px] bg-[#1e1e1e] border-l border-[#3d3d3d] shrink-0 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"border-b border-[#3d3d3d] px-4 shrink-0 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-0",children:[e.jsxs("button",{onClick:()=>k("chat"),className:`px-3 py-2 text-xs font-medium transition-colors relative cursor-pointer ${d==="chat"?"text-white":"text-gray-500 hover:text-gray-300"}`,children:["Chat",d==="chat"&&e.jsx("span",{className:"absolute bottom-0 left-3 right-3 h-0.5 bg-[#005c75]"})]}),e.jsxs("button",{onClick:()=>k("scenarios"),className:`px-3 py-2 text-xs font-medium transition-colors relative cursor-pointer ${d==="scenarios"?"text-white":"text-gray-500 hover:text-gray-300"}`,children:["Scenarios",d==="scenarios"&&e.jsx("span",{className:"absolute bottom-0 left-3 right-3 h-0.5 bg-[#005c75]"})]})]}),d==="chat"&&e.jsx("button",{onClick:ee,disabled:!h,className:"px-3 py-1 text-[11px] font-medium rounded bg-[#005c75] text-white hover:bg-[#004a5c] transition-colors disabled:bg-gray-600 disabled:text-gray-400 disabled:cursor-not-allowed cursor-pointer",children:"Save Scenario"})]}),e.jsx("div",{style:{display:d==="chat"?"flex":"none"},className:"flex-1 overflow-hidden flex-col",children:e.jsx(pe,{ref:f,entityName:r.name,entityType:r.entityType,entitySha:r.sha,entityFilePath:r.filePath||r.localFilePath,scenarioName:s==null?void 0:s.name,scenarioDescription:s==null?void 0:s.description,analysisId:l==null?void 0:l.id,projectSlug:c,onRefreshPreview:K})}),d==="scenarios"&&e.jsx(ve,{scenarios:x,currentScenarioId:s==null?void 0:s.id,entitySha:r.sha,cacheBuster:0})]})]}),e.jsx(ge,{serverUrl:h,isStarting:C,projectSlug:c}),H&&e.jsx(xe,{width:n.width,height:n.height??900,onSave:Z,onCancel:()=>y(!1)})]})});export{Me as default};
@@ -1,6 +0,0 @@
1
- import{w as X,u as Z,a as ee,b as te,r as i,j as e}from"./chunk-JZWAC4HX-C4pqxYJB.js";import{u as se,S as z}from"./Spinner-Bb5uFQ5V.js";import{u as ne}from"./useLastLogLine-C14nCb1q.js";import{V as ae}from"./ViewportInspectBar-oAf2Kqsf.js";import{u as ie,S as re}from"./useCustomSizes-C-_hOl_g.js";import{c as oe}from"./cy-logo-cli-DcX-ZS3p.js";import{I as B}from"./InlineSpinner-Bu6c6aDe.js";const N=[{name:"Mobile",width:375,height:667},{name:"Tablet",width:768,height:1024},{name:"Laptop",width:1024,height:768},{name:"Desktop",width:1920,height:1080}],fe=X(function(){const{entity:o,scenario:s,analysis:l,projectSlug:p}=Z(),f=ee();te();const[ce,y]=i.useState(null),[E,k]=i.useState(1920),[a,v]=i.useState({name:"Desktop",width:1920,height:1080}),[W,b]=i.useState(!1),[w,D]=i.useState(null),{customSizes:C,addCustomSize:R}=ie(p),h=i.useMemo(()=>[...N,...C],[C]),x=i.useRef(null),[H,U]=i.useState(1),m=i.useCallback(()=>{if(!x.current)return;const t=32,n=x.current.clientWidth-t,r=x.current.clientHeight-t,_=a.width,g=a.height??900,Q=Math.min(1,n/_,r/g);U(Q)},[a.width,a.height]);i.useEffect(()=>(m(),window.addEventListener("resize",m),()=>window.removeEventListener("resize",m)),[m]);const{interactiveServerUrl:L,isStarting:I,isLoading:M,showIframe:P,iframeKey:V,onIframeLoad:T}=se({analysisId:l==null?void 0:l.id,scenarioId:s==null?void 0:s.id,scenarioName:s==null?void 0:s.name,projectSlug:p,enabled:!0}),{lastLine:u}=ne(p,I||M),A=()=>{f(`/entity/${o.sha}`)},F=(t,n)=>{k(t);const r=h.find(g=>g.width===t&&g.height===n);y(r||null),v({name:(r==null?void 0:r.name)||"Custom",width:t,height:n})},$=t=>{y(t),k(t.width),v({name:t.name,width:t.width,height:t.height})},K=t=>{R(t,a.width,a.height??900),b(!1),v(n=>({...n,name:t}))},c=((l==null?void 0:l.scenarios)||[]).filter(t=>{var n;return!((n=t.metadata)!=null&&n.sameAsDefault)}),d=c.findIndex(t=>t.id===(s==null?void 0:s.id)),O=d+1,Y=c.length,j=d>0,S=d<c.length-1,q=()=>{if(j){const t=c[d-1],n=encodeURIComponent(`/entity/${o.sha}/scenarios/${t.id}/fullscreen`);f(`/entity/${o.sha}/scenarios/${t.id}/fullscreen?from=${n}`)}},G=()=>{if(S){const t=c[d+1],n=encodeURIComponent(`/entity/${o.sha}/scenarios/${t.id}/fullscreen`);f(`/entity/${o.sha}/scenarios/${t.id}/fullscreen?from=${n}`)}},J=I||M||!P;return e.jsxs("div",{className:"fixed inset-0 bg-[#2d2d2d] flex flex-col",children:[e.jsxs("div",{className:"bg-[#3d3d3d] h-12 flex items-center px-4 gap-4 shrink-0 z-20",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[e.jsx("img",{src:oe,alt:"CodeYam",className:"h-6 brightness-0 invert"}),e.jsx("span",{className:"text-white font-medium text-sm whitespace-nowrap",children:o.name}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx("button",{onClick:q,disabled:!j,className:`${j?"text-white hover:text-gray-300":"text-gray-600 cursor-not-allowed"} transition-colors`,"aria-label":"Previous scenario",children:e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:e.jsx("path",{d:"M12.5 15L7.5 10L12.5 5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}),e.jsxs("span",{className:"text-gray-400 text-sm",children:[O,"/",Y]}),e.jsx("button",{onClick:G,disabled:!S,className:`${S?"text-white hover:text-gray-300":"text-gray-600 cursor-not-allowed"} transition-colors`,"aria-label":"Next scenario",children:e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:e.jsx("path",{d:"M7.5 15L12.5 10L7.5 5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-2 min-w-0",children:[e.jsx("span",{className:"text-white font-semibold text-xs whitespace-nowrap shrink-0",children:s==null?void 0:s.name}),(s==null?void 0:s.description)&&e.jsxs("div",{className:"relative group min-w-0",children:[e.jsx("span",{className:"text-gray-400 text-xs truncate block",children:s.description}),e.jsx("div",{className:"absolute left-0 top-full mt-1 hidden group-hover:block z-50 bg-black text-white text-xs px-3 py-2 rounded shadow-lg max-w-md",children:s.description})]})]})]}),e.jsx("button",{onClick:A,className:"text-white hover:text-gray-300 transition-colors ml-4","aria-label":"Close fullscreen",children:e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:e.jsx("path",{d:"M15 5L5 15M5 5L15 15",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})})]}),e.jsxs("div",{className:"bg-[#e5e7eb] border-b border-[rgba(0,0,0,0.1)] shrink-0 z-10 h-6 flex items-center justify-center relative",children:[e.jsx("div",{className:"absolute inset-0 flex justify-center",children:e.jsx("div",{style:{maxWidth:`${N[N.length-1].width}px`,width:"100%"},children:e.jsx(ae,{currentViewportWidth:E,currentPresetName:a.name,onDevicePresetClick:$,devicePresets:h,hideLabel:!0,onHoverChange:D,lightMode:!0})})}),e.jsxs("div",{className:"relative z-10 flex items-center gap-2",children:[e.jsxs("div",{className:"relative w-28 h-5",children:[e.jsxs("div",{className:"absolute inset-0 bg-white text-gray-900 text-xs px-2 rounded flex items-center justify-between pointer-events-none border border-gray-300",children:[e.jsx("span",{className:"leading-none",children:(w==null?void 0:w.name)||a.name}),e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 12 12",fill:"none",className:"shrink-0",children:e.jsx("path",{d:"M3 4.5L6 7.5L9 4.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),e.jsxs("select",{value:a.name,onChange:t=>{const n=h.find(r=>r.name===t.target.value);n&&$(n)},className:"relative w-full h-full opacity-0 cursor-pointer",children:[h.map(t=>e.jsx("option",{value:t.name,children:t.name},t.name)),a.name==="Custom"&&e.jsx("option",{value:"Custom",children:"Custom"})]})]}),e.jsx("input",{type:"number",value:a.width,onChange:t=>{const n=parseInt(t.target.value,10);!isNaN(n)&&n>0&&F(n,a.height??900)},className:"bg-white text-gray-900 text-xs px-1 rounded border border-gray-300 outline-none w-16 text-center h-5 leading-none",min:"200",max:"3840"}),e.jsx("span",{className:"text-gray-400 text-xs h-5 flex items-center leading-none",children:"×"}),e.jsx("span",{className:"bg-gray-100 text-gray-600 text-xs px-1 rounded w-14 text-center h-5 flex items-center justify-center leading-none",children:a.height??900}),a.name==="Custom"&&e.jsx("button",{onClick:()=>b(!0),className:"bg-white text-gray-900 text-xs px-2 rounded h-5 flex items-center leading-none border border-gray-300 hover:bg-gray-50 transition-colors",children:"Save"})]})]}),e.jsx("div",{ref:x,className:"flex-1 flex items-center justify-center overflow-hidden p-4",style:{backgroundImage:`
2
- linear-gradient(45deg, #ebebeb 25%, transparent 25%),
3
- linear-gradient(-45deg, #ebebeb 25%, transparent 25%),
4
- linear-gradient(45deg, transparent 75%, #ebebeb 75%),
5
- linear-gradient(-45deg, transparent 75%, #ebebeb 75%)
6
- `,backgroundSize:"16px 16px",backgroundPosition:"0 0, 0 8px, 8px -8px, -8px 0px",backgroundColor:"#fafafa"},children:L?e.jsxs("div",{className:"relative bg-white",style:{width:`${a.width}px`,height:`${a.height??900}px`,transform:`scale(${H})`,transformOrigin:"center center"},children:[J&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-10",children:e.jsxs("div",{className:"flex flex-col items-center justify-center gap-6 bg-white rounded-lg p-8 shadow-sm w-[500px] h-[300px]",children:[e.jsx("div",{className:"mb-4",children:e.jsx(z,{})}),e.jsxs("div",{className:"flex flex-col gap-3 text-center",children:[e.jsx("h2",{className:"text-xl font-medium text-black leading-[28px] m-0 font-['IBM_Plex_Sans']",children:"Starting Interactive Mode"}),e.jsx("p",{className:"text-sm text-[#666] leading-5 m-0 font-['IBM_Plex_Sans']",children:"Setting up a sandboxed environment for your component"}),u&&e.jsxs("p",{className:"text-xs font-mono text-[#005c75] text-center leading-5 m-0 mt-3 font-['IBM_Plex_Mono'] uppercase",children:[e.jsx(B,{}),u]})]})]})}),e.jsx("iframe",{src:L,className:"w-full h-full border-none",title:`Interactive preview: ${s==null?void 0:s.name}`,onLoad:T,style:{opacity:P?1:0}},V)]}):e.jsxs("div",{className:"flex flex-col items-center justify-center gap-6 w-[500px] h-[300px] bg-white rounded-lg p-8 shadow-sm",children:[e.jsx("div",{className:"mb-4",children:e.jsx(z,{})}),e.jsxs("div",{className:"flex flex-col gap-3 text-center",children:[e.jsx("h2",{className:"text-xl font-medium text-black leading-[28px] m-0 font-['IBM_Plex_Sans']",children:"Starting Interactive Mode"}),e.jsx("p",{className:"text-sm text-[#666] leading-5 m-0 font-['IBM_Plex_Sans']",children:"Setting up a sandboxed environment for your component"}),u&&e.jsxs("p",{className:"text-xs font-mono text-[#005c75] text-center leading-5 m-0 mt-3 font-['IBM_Plex_Mono'] uppercase",children:[e.jsx(B,{}),u]})]})]})}),W&&e.jsx(re,{width:a.width,height:a.height??900,onSave:K,onCancel:()=>b(!1)})]})});export{fe as default};
@@ -1,6 +0,0 @@
1
- import{r as a,j as e,w as Z,u as ee,a as te,L as v}from"./chunk-JZWAC4HX-C4pqxYJB.js";import{W as se,u as re,I as ae}from"./InteractivePreview-DYFW3lDD.js";import{u as ne}from"./Spinner-Bb5uFQ5V.js";import{c as oe}from"./executionFlowCoverage-BWhdfn70.js";import"./preload-helper-ckwbz45p.js";import"./useLastLogLine-C14nCb1q.js";import"./InlineSpinner-Bu6c6aDe.js";function ie({executionFlows:t,selections:r,onChange:n,disabled:i=!1}){const x=a.useCallback(s=>r.some(o=>o.flowId===s),[r]),p=a.useCallback(s=>{x(s.id)?n(r.filter(o=>o.flowId!==s.id)):n([...r,{flowId:s.id,flowName:s.name}])},[r,n,x]);return t.length===0?e.jsx("div",{className:"text-sm text-gray-500 py-2",children:"No execution flows found."}):e.jsx("div",{className:"space-y-3",children:t.map(s=>{const o=x(s.id),I=s.usedInScenarios.length>0;return e.jsxs("div",{className:"border-b border-gray-100 pb-3 last:border-0 last:pb-0",children:[e.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:o,onChange:()=>p(s),disabled:i,className:"mt-0.5 h-4 w-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-mono text-sm font-medium text-gray-900",children:s.name}),!I&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 bg-amber-100 text-amber-700 rounded",children:"uncovered"}),s.blocksOtherFlows&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 bg-purple-100 text-purple-700 rounded",children:"blocking"}),s.impact==="high"&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 bg-red-100 text-red-700 rounded",children:"high impact"})]}),s.description&&e.jsx("p",{className:"text-xs text-gray-500 mt-0.5 m-0",children:s.description})]})]}),o&&s.requiredValues.length>0&&e.jsxs("div",{className:"ml-6 mt-2 p-2 bg-gray-50 rounded text-xs",children:[e.jsx("span",{className:"text-gray-700 font-medium",children:"Required values:"}),e.jsx("ul",{className:"m-0 mt-1 pl-4 space-y-0.5",children:s.requiredValues.map((h,E)=>e.jsxs("li",{className:"text-gray-600",children:[e.jsx("code",{className:"bg-gray-100 px-1 rounded",children:h.attributePath})," ",e.jsx("span",{className:"text-gray-400",children:h.comparison})," ",e.jsx("code",{className:"bg-gray-100 px-1 rounded",children:h.value})]},E))})]})]},s.id)})})}const ge=({data:t})=>[{title:t!=null&&t.entity?`Create Scenario - ${t.entity.name} - CodeYam`:"Create Scenario - CodeYam"},{name:"description",content:"Create a new scenario"}];function ce(){var W;const{analysis:t,defaultScenario:r,entity:n,entitySha:i,projectSlug:x}=ee(),p=te(),{iframeRef:s}=re(),[o,I]=a.useState(""),[h,E]=a.useState(400),[b,P]=a.useState(!1),[U,R]=a.useState(!1),[G,$]=a.useState(!1),[M,L]=a.useState(null),[F,l]=a.useState(null),[d,H]=a.useState([]),D=a.useMemo(()=>{var c;return!((c=t==null?void 0:t.metadata)!=null&&c.executionFlows)||!(t!=null&&t.scenarios)?[]:oe(t.metadata.executionFlows,t.scenarios).executionFlows},[t]),{interactiveServerUrl:y,isStarting:J,isLoading:_,showIframe:q,iframeKey:B,onIframeLoad:V}=ne({analysisId:t==null?void 0:t.id,scenarioId:r==null?void 0:r.id,scenarioName:r==null?void 0:r.name,projectSlug:x,enabled:!0}),Y=a.useCallback(async()=>{var m,c,T,z;if(!o.trim()&&d.length===0){L("Please describe how you want to change the scenario or select execution flows");return}R(!0),L(null),l("Generating scenario with AI...");try{const u=await fetch("/api/generate-scenario-data",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({description:o,existingScenarios:t.scenarios,scenariosDataStructure:(m=t.metadata)==null?void 0:m.scenariosDataStructure,flowSelections:d.length>0?d:void 0})}),N=await u.json();if(!u.ok||!N.success)throw new Error(N.error||"Failed to generate scenario data");console.log("[CreateScenario] AI generated scenario:",N.data);const g=N.data;if(!g.name||!g.data)throw new Error("AI response missing required fields (name or data)");l("Saving new scenario..."),$(!0);const X={name:g.name,description:g.description||o,metadata:{data:g.data,interactiveExamplePath:(c=r.metadata)==null?void 0:c.interactiveExamplePath}},Q=[...t.scenarios||[],X],O=await fetch("/api/save-scenarios",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({analysis:t,scenarios:Q})}),C=await O.json();if(!O.ok||!C.success)throw new Error(C.error||"Failed to save scenario");console.log("[CreateScenario] Scenario saved:",C);const f=(z=(T=C.analysis)==null?void 0:T.scenarios)==null?void 0:z.find(k=>k.name===g.name);if(!(f!=null&&f.id)){console.warn("[CreateScenario] Could not find saved scenario ID, navigating to entity page"),l("Scenario created! Redirecting..."),setTimeout(()=>void p(`/entity/${i}`),1e3);return}if(y){l("Capturing screenshot...");const k=await fetch("/api/capture-screenshot",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({serverUrl:y,scenarioId:f.id,projectId:t.projectId,viewportWidth:1440})}),A=await k.json();!k.ok||!A.success?(console.error("[CreateScenario] Capture failed:",A),l("Scenario created! (Screenshot capture failed)")):l("Scenario created and captured!")}else l("Scenario created!");setTimeout(()=>{p(`/entity/${i}/scenarios/${f.id}`)},1e3)}catch(u){console.error("[CreateScenario] Error:",u),L(u instanceof Error?u.message:String(u)),l(null)}finally{R(!1),$(!1)}},[o,d,t,r,i,y,p]),j=U||G,K=a.useCallback(()=>{P(!0)},[]),w=a.useCallback(m=>{if(!b)return;const c=m.clientX;c>=250&&c<=600&&E(c)},[b]),S=a.useCallback(()=>{P(!1)},[]);return a.useEffect(()=>(b?(document.addEventListener("mousemove",w),document.addEventListener("mouseup",S)):(document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",S)),()=>{document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",S)}),[b,w,S]),e.jsxs("div",{className:"h-screen bg-white flex flex-col overflow-hidden",children:[e.jsx("header",{className:"bg-white border-b border-gray-200 shrink-0 relative h-[54px]",children:e.jsxs("div",{className:"flex items-end h-full px-6 gap-6",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1 pb-[14px]",children:[e.jsx("button",{onClick:()=>void p(`/entity/${i}`),className:"no-underline shrink-0 bg-transparent border-none cursor-pointer p-0 flex items-center",title:"Back",children:e.jsx("svg",{width:"17",height:"17",viewBox:"0 0 17 17",fill:"none",children:e.jsx("path",{d:"M13 8.5H4M4 8.5L8.5 4M4 8.5L8.5 13",stroke:"#005c75",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),e.jsx("h1",{className:"text-base font-semibold text-black m-0 leading-[20px] shrink-0",children:n==null?void 0:n.name}),e.jsx("span",{className:"text-xs text-[#9e9e9e] font-mono font-normal whitespace-nowrap overflow-hidden text-ellipsis min-w-0",title:n==null?void 0:n.filePath,children:n==null?void 0:n.filePath})]}),e.jsxs("div",{className:"flex items-end gap-8 shrink-0",children:[e.jsx(v,{to:`/entity/${i}/scenarios`,className:"relative pb-[17px] px-2 text-sm transition-colors cursor-pointer no-underline font-medium border-b-2",style:{color:"#005C75",borderColor:"#005C75"},children:e.jsxs("span",{className:"flex items-center gap-2",children:["Scenarios",e.jsx("span",{className:"inline-flex items-center justify-center px-2 py-0.5 text-xs font-semibold rounded-full bg-[#cbf3fa] text-[#005c75]",children:((W=t==null?void 0:t.scenarios)==null?void 0:W.length)||0})]})}),e.jsx(v,{to:`/entity/${i}/related`,className:"relative pb-[17px] px-2 text-sm transition-colors cursor-pointer no-underline font-normal hover:text-gray-700",style:{color:"#9ca3af"},children:"Related Entities"}),e.jsx(v,{to:`/entity/${i}/code`,className:"relative pb-[17px] px-2 text-sm transition-colors cursor-pointer no-underline font-normal hover:text-gray-700",style:{color:"#9ca3af"},children:"Code"}),e.jsx(v,{to:`/entity/${i}/data`,className:"relative pb-[17px] px-2 text-sm transition-colors cursor-pointer no-underline font-normal hover:text-gray-700",style:{color:"#9ca3af"},children:"Data Structure"}),e.jsx(v,{to:`/entity/${i}/history`,className:"relative pb-[17px] px-2 text-sm transition-colors cursor-pointer no-underline font-normal hover:text-gray-700",style:{color:"#9ca3af"},children:"History"})]})]})}),e.jsxs("div",{className:"flex flex-1 gap-0 min-h-0 relative",children:[e.jsxs("aside",{className:"bg-white border-r border-gray-200 overflow-y-auto shrink-0 p-6 flex flex-col",style:{width:`${h}px`},children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 mb-2",children:"Default Scenario Preview"}),e.jsx("p",{className:"text-sm text-gray-600 leading-relaxed",children:"The preview on the right shows the Default Scenario. Select execution flows and/or describe how you'd like to change it."})]}),D.length>0&&e.jsxs("details",{className:"mb-4 border border-gray-200 rounded-lg",children:[e.jsxs("summary",{className:"px-3 py-2 text-sm font-medium text-gray-700 cursor-pointer hover:bg-gray-50 rounded-lg",children:["Select Execution Flows"," ",d.length>0&&e.jsxs("span",{className:"text-blue-600",children:["(",d.length," selected)"]})]}),e.jsx("div",{className:"px-3 pb-3 pt-1 border-t border-gray-100",children:e.jsx(ie,{executionFlows:D,selections:d,onChange:H,disabled:j})})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{htmlFor:"prompt",className:"block text-sm font-medium text-gray-700 mb-2",children:"Describe your scenario"}),e.jsx("textarea",{id:"prompt",value:o,onChange:m=>I(m.target.value),placeholder:"e.g., Show an empty state with no items...",className:"w-full h-32 px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-1 focus:ring-blue-500 focus:border-blue-500 text-sm resize-none",disabled:j})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("button",{onClick:()=>void Y(),disabled:j||!o.trim()&&d.length===0,className:"w-full px-4 py-2 bg-blue-600 text-white rounded-lg text-sm font-medium cursor-pointer transition-colors hover:bg-blue-700 disabled:bg-gray-400 disabled:cursor-not-allowed",children:j?"Creating...":"Create Scenario"}),F&&e.jsx("div",{className:"text-xs text-blue-600 bg-blue-50 px-2 py-1.5 rounded",children:F}),M&&e.jsx("div",{className:"text-xs text-red-600 bg-red-50 px-2 py-1.5 rounded",children:M})]})]}),e.jsxs("div",{onMouseDown:K,style:{width:"20px",position:"absolute",top:0,left:`${h-10}px`,bottom:0,cursor:"col-resize",touchAction:"none",userSelect:"none",zIndex:100,pointerEvents:"auto"},children:[e.jsx("div",{style:{position:"absolute",left:"10px",top:0,bottom:0,width:"1px",background:b?"#005c75":"rgba(0,0,0,0.1)",transition:"background 0.15s ease"}}),e.jsx("div",{style:{position:"absolute",top:"50%",left:"10px",transform:"translate(-50%, -50%)",width:"8px",height:"40px",background:"#fff",border:"1px solid rgba(0,0,0,0.15)",borderRadius:"4px",cursor:"col-resize"}})]}),e.jsx("main",{className:"flex-1 overflow-auto flex items-center justify-center min-w-0",style:{backgroundImage:`
2
- linear-gradient(45deg, #ebebeb 25%, transparent 25%),
3
- linear-gradient(-45deg, #ebebeb 25%, transparent 25%),
4
- linear-gradient(45deg, transparent 75%, #ebebeb 75%),
5
- linear-gradient(-45deg, transparent 75%, #ebebeb 75%)
6
- `,backgroundSize:"16px 16px",backgroundPosition:"0 0, 0 8px, 8px -8px, -8px 0px",backgroundColor:"#fafafa"},children:e.jsx(ae,{scenarioId:r.id||r.name,scenarioName:r.name,iframeUrl:y,isStarting:J,isLoading:_,showIframe:q,iframeKey:B,onIframeLoad:V,projectSlug:x,defaultWidth:1440,defaultHeight:900})})]})]})}const be=Z(function(){return e.jsx(se,{children:e.jsx(ce,{})})});export{be as default,ge as meta};
@@ -1 +0,0 @@
1
- import{j as l}from"./chunk-JZWAC4HX-C4pqxYJB.js";function C(e){switch(e){case"queued":return{text:"Queued",bgColor:"#cbf3fa",textColor:"#3098b4",icon:l.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#3098b4",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("circle",{cx:"12",cy:"12",r:"10"}),l.jsx("polyline",{points:"12,6 12,12 16,14"})]})};case"analyzing":return{text:"Analyzing...",bgColor:"#ffdbf6",textColor:"#ff2ab5",icon:l.jsxs("svg",{width:"8",height:"8",viewBox:"0 0 9 9",fill:"none",className:"animate-spin",children:[l.jsx("circle",{cx:"4.5",cy:"4.5",r:"3.5",stroke:"#FFF4FC",strokeWidth:"1",fill:"none"}),l.jsx("path",{d:"M4.5 1C2.57 1 1 2.57 1 4.5C1 5.6 1.5 6.58 2.28 7.23",stroke:"#FF2AB5",strokeWidth:"1",strokeLinecap:"round",fill:"none"})]})};case"up-to-date":return{text:"Up to date",bgColor:"#e8ffe6",textColor:"#00925d",icon:null};case"incomplete":return{text:"Incomplete",bgColor:"#fdf9c9",textColor:"#c69538",icon:null};case"out-of-date":return{text:"Out of date",bgColor:"#fdf9c9",textColor:"#c69538",icon:null};case"not-analyzed":return{text:"Not analyzed",bgColor:"#f9f9f9",textColor:"#646464",icon:null}}}function A(e){if(!e)return"Never";const o=new Date(e),c=new Date;if(o.getDate()===c.getDate()&&o.getMonth()===c.getMonth()&&o.getFullYear()===c.getFullYear()){const t=o.getHours(),f=o.getMinutes(),u=t>=12?"pm":"am",d=t%12||12,i=f.toString().padStart(2,"0");return`Today, ${d}:${i} ${u}`}return o.toLocaleString("en-US",{month:"numeric",day:"numeric",year:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!0})}function b(e,o=[],c=!1){var h,g;if(o.some(n=>{var a,s;return!!((a=n.entityShas)!=null&&a.includes(e.sha)||(s=n.entities)!=null&&s.some(r=>r.sha===e.sha))}))return c?"analyzing":"queued";if(!e.analyses||e.analyses.length===0)return"not-analyzed";const t=e.analyses[0];if(!(((h=t.status)==null?void 0:h.scenarios)&&t.status.scenarios.length>0&&t.status.scenarios.some(n=>n.screenshotFinishedAt||n.finishedAt))||t.entitySha!==e.sha)return"not-analyzed";const u=t.createdAt?new Date(t.createdAt).getTime():0,d=(g=e.metadata)!=null&&g.editedAt?new Date(e.metadata.editedAt).getTime():0,i=t.scenarios||[],p=i.some(n=>{var a,s,r;return((s=(a=n.metadata)==null?void 0:a.screenshotPaths)==null?void 0:s[0])||((r=n.metadata)==null?void 0:r.executionResult)});return u>=d?i.length>0&&p?i.every(a=>{var s,r,m;return((r=(s=a.metadata)==null?void 0:s.screenshotPaths)==null?void 0:r[0])||((m=a.metadata)==null?void 0:m.executionResult)})?"up-to-date":"incomplete":i.length>0?"incomplete":"not-analyzed":"out-of-date"}export{C as a,A as f,b as g};
@@ -1 +0,0 @@
1
- import{b as ne,r as u,j as e,w as le,u as ce,f as de}from"./chunk-JZWAC4HX-C4pqxYJB.js";import{u as me}from"./useReportContext-O-jkvSPx.js";import{C as pe,a as he,F as fe,b as xe,E as ue,S as ye,u as ge}from"./EntityItem-BcgbViKV.js";import{g as T}from"./fileTableUtils-cPo8LiG3.js";import{C as ae}from"./chevron-down-C_Pmso5S.js";import{S as ve}from"./search-Di64LWVb.js";import"./createLucideIcon-CC6AbExI.js";import"./useToast-9FIWuYfK.js";import"./TruncatedFilePath-C8OKAR5x.js";import"./SafeScreenshot-BED4B6sP.js";import"./LibraryFunctionPreview-DLeucoVX.js";import"./scenarioStatus-B_8jpV3e.js";import"./triangle-alert-BLdiCuG-.js";import"./EntityTypeIcon-CQIG2qda.js";import"./EntityTypeBadge-g3saevPb.js";function be({entities:Q,page:N,itemsPerPage:b=50,currentRun:L,filter:S,entityType:_,queueState:o,isEntityPending:U,pendingEntityKeys:w,onGenerateSimulation:k,onGenerateAllSimulations:D,totalFilesCount:H,totalEntitiesCount:J,uncommittedFilesCount:W,showOnlyUncommitted:j,onToggleUncommitted:V}){const[I,X]=ne(),[B,M]=u.useState(new Set),[A,y]=u.useState(""),[g,x]=u.useState(!1),[E,$]=u.useState("all"),[z,Y]=u.useState("desc"),P=_||"all",R=u.useMemo(()=>{let s=Q;return P!=="all"&&(s=s.filter(i=>i.entityType===P)),S==="analyzed"&&(s=s.filter(i=>i.analyses&&i.analyses.length>0)),s},[Q,P,S]),te=u.useMemo(()=>{const s=new Map,i=new Map,p=new Map;R.forEach(a=>{var r,c;const t=`${a.filePath}::${a.name}`,n=i.get(t);if(!n)i.set(t,a),p.set(t,[]);else{const d=((r=n.metadata)==null?void 0:r.editedAt)||n.createdAt||"",l=((c=a.metadata)==null?void 0:c.editedAt)||a.createdAt||"";let m=!1;if(l>d)m=!0;else if(l===d){const h=n.createdAt||"";m=(a.createdAt||"")>h}m?(p.get(t).push(n),i.set(t,a)):p.get(t).push(a)}}),i.forEach((a,t)=>{var r;if(!(a.analyses&&a.analyses.length>0)&&((r=a.metadata)!=null&&r.previousVersionWithAnalyses)){const d=(p.get(t)||[]).find(l=>{var m;return l.sha===((m=a.metadata)==null?void 0:m.previousVersionWithAnalyses)});d&&d.analyses&&d.analyses.length>0&&(a.analyses=d.analyses)}}),Array.from(i.values()).sort((a,t)=>{var c,d,l,m;const n=!((c=a.metadata)!=null&&c.notExported)&&!((d=a.metadata)!=null&&d.namedExport),r=!((l=t.metadata)!=null&&l.notExported)&&!((m=t.metadata)!=null&&m.namedExport);return n&&!r?-1:!n&&r?1:0}).forEach(a=>{var d,l,m,h,f;const t=a.filePath??"No File Path";s.has(t)||s.set(t,{filePath:t,entities:[],totalCount:0,uncommittedCount:0,lastUpdated:null,previewScreenshots:[],previewScreenshotErrors:[],previewLibraryScenarios:[],state:"up-to-date",simulationCount:0});const n=s.get(t);n.entities.push(a),n.totalCount++,(d=a.metadata)!=null&&d.isUncommitted&&n.uncommittedCount++;const r=((h=(m=(l=a.analyses)==null?void 0:l[0])==null?void 0:m.scenarios)==null?void 0:h.length)||0;n.simulationCount+=r;const c=((f=a.metadata)==null?void 0:f.editedAt)||a.updatedAt;c&&(!n.lastUpdated||new Date(c)>new Date(n.lastUpdated))&&(n.lastUpdated=c)});const q=(o==null?void 0:o.jobs)||[],ee=a=>{const t=`${a.filePath||""}::${a.name}`;return(w==null?void 0:w.includes(t))||!1};s.forEach(a=>{const t=a.entities.map(n=>ee(n)?"queued":T(n,q));t.includes("analyzing")||t.includes("queued")?a.state="analyzing":t.includes("incomplete")?a.state="incomplete":t.includes("out-of-date")?a.state="out-of-date":t.includes("not-analyzed")?a.state="not-analyzed":a.state="up-to-date"}),s.forEach(a=>{var t,n,r,c,d;for(const l of a.entities){if(a.previewScreenshots.length+a.previewLibraryScenarios.length>=3)break;const h=((n=(t=l.analyses)==null?void 0:t[0])==null?void 0:n.scenarios)||[];if(l.entityType==="library"){const f=h.find(v=>{var F,O;return((F=v.metadata)==null?void 0:F.executionResult)||((O=v.metadata)==null?void 0:O.error)});f&&a.previewLibraryScenarios.push({scenario:f,entitySha:l.sha})}else{const f=h.find(v=>{var F,O;return(O=(F=v.metadata)==null?void 0:F.screenshotPaths)==null?void 0:O[0]});if(f){const v=(c=(r=f.metadata)==null?void 0:r.screenshotPaths)==null?void 0:c[0],F=!!((d=f.metadata)!=null&&d.error);v&&!a.previewScreenshots.includes(v)&&(a.previewScreenshots.push(v),a.previewScreenshotErrors.push(F))}}}});const G=Array.from(s.values());return G.sort((a,t)=>{if(S==="analyzed"){const c=Math.max(...a.entities.filter(l=>{var m,h;return(h=(m=l.analyses)==null?void 0:m[0])==null?void 0:h.createdAt}).map(l=>new Date(l.analyses[0].createdAt).getTime()),0),d=Math.max(...t.entities.filter(l=>{var m,h;return(h=(m=l.analyses)==null?void 0:m[0])==null?void 0:h.createdAt}).map(l=>new Date(l.analyses[0].createdAt).getTime()),0);return z==="desc"?d-c:c-d}if(a.uncommittedCount>0&&t.uncommittedCount===0)return-1;if(a.uncommittedCount===0&&t.uncommittedCount>0)return 1;const n=a.lastUpdated?new Date(a.lastUpdated).getTime():0,r=t.lastUpdated?new Date(t.lastUpdated).getTime():0;return z==="desc"?r-n:n-r}),G},[R,S,z,o,w]),C=u.useMemo(()=>{let s=te;if(E!=="all"&&(s=s.filter(i=>i.state===E)),A.trim()){const i=A.toLowerCase();s=s.filter(p=>p.filePath.toLowerCase().includes(i))}return s},[te,A,E]),se=(N-1)*b,oe=se+b,Z=C.slice(se,oe),K=Math.ceil(C.length/b),re=s=>{M(i=>{const p=new Set(i);return p.has(s)?p.delete(s):p.add(s),p})},ie=()=>{Y(s=>s==="desc"?"asc":"desc")};return e.jsxs("div",{children:[e.jsxs("div",{className:"bg-white border-b border-gray-200 rounded-t-lg px-5 py-4 mb-3",children:[e.jsx("div",{className:"text-[11px] text-gray-500 mb-2 uppercase",children:"Filters"}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("div",{className:"relative w-[130px]",children:[e.jsxs("select",{value:P,onChange:s=>{const i=s.target.value,p=new URLSearchParams(I);i==="all"?p.delete("entityType"):p.set("entityType",i),p.set("page","1"),X(p)},className:"appearance-none bg-gray-50 border border-gray-200 rounded px-[10px] pr-6 text-[13px] h-[39px] w-full cursor-pointer focus:outline-none focus:ring-0 focus:border-2 focus:border-[#005c75] hover:border-gray-300 transition-colors",children:[e.jsx("option",{value:"all",children:"All Types"}),e.jsx("option",{value:"visual",children:"Visual"}),e.jsx("option",{value:"library",children:"Library"})]}),e.jsx(ae,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-3 h-3 text-gray-500 pointer-events-none"})]}),e.jsxs("div",{className:"relative w-[130px]",children:[e.jsxs("select",{value:E,onChange:s=>$(s.target.value),className:"appearance-none bg-gray-50 border border-gray-200 rounded px-[10px] pr-6 text-[13px] h-[39px] w-full cursor-pointer focus:outline-none focus:ring-0 focus:border-2 focus:border-[#005c75] hover:border-gray-300 transition-colors",children:[e.jsx("option",{value:"all",children:"All States"}),e.jsx("option",{value:"analyzing",children:"Analyzing..."}),e.jsx("option",{value:"up-to-date",children:"Up to date"}),e.jsx("option",{value:"incomplete",children:"Incomplete"}),e.jsx("option",{value:"out-of-date",children:"Out of date"}),e.jsx("option",{value:"not-analyzed",children:"Not analyzed"})]}),e.jsx(ae,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-3 h-3 text-gray-500 pointer-events-none"})]}),e.jsxs("div",{className:"flex-1 relative",children:[e.jsx(ve,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),e.jsx("input",{type:"text",placeholder:"Search component",value:A,onChange:s=>y(s.target.value),className:"w-full bg-gray-50 border border-gray-200 rounded pl-9 pr-[10px] text-[13px] h-[39px] placeholder:text-gray-400 focus:outline-none focus:ring-0 focus:border-2 focus:border-[#005c75] transition-colors"})]})]})]}),H!==void 0&&J!==void 0&&W!==void 0&&e.jsx("div",{className:"mb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center",children:[e.jsxs("span",{className:"font-mono uppercase",style:{fontSize:"11px",color:"#8b8b8b",fontWeight:500,letterSpacing:"0.05em"},children:[e.jsx("span",{style:{color:"#000000"},children:C.length})," ",C.length===1?"file":"files"]}),e.jsxs("div",{className:"relative group inline-flex items-center ml-1.5",children:[e.jsx("svg",{className:"w-3 h-3 text-gray-400 cursor-help",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsx("div",{className:"absolute left-0 top-full mt-2 hidden group-hover:block z-50 w-80",children:e.jsxs("div",{className:"bg-gray-900 text-white text-xs rounded-lg px-3 py-2 shadow-lg",children:["In CodeYam, an entity is a discrete, analyzable unit of code that can be independently simulated and tested.",e.jsx("div",{className:"absolute -top-1 left-4 w-2 h-2 bg-gray-900 transform rotate-45"})]})})]}),e.jsx("span",{className:"font-mono uppercase",style:{fontSize:"11px",color:"#d1d5db",fontWeight:500,letterSpacing:"0.05em",marginLeft:"8px"},children:"|"}),e.jsxs("span",{className:"font-mono uppercase",style:{fontSize:"11px",color:"#8b8b8b",fontWeight:500,letterSpacing:"0.05em",marginLeft:"8px"},children:[e.jsx("span",{style:{color:"#000000"},children:C.reduce((s,i)=>s+i.totalCount,0)})," ",C.reduce((s,i)=>s+i.totalCount,0)===1?"entity":"entities"]}),e.jsx("span",{className:"font-mono uppercase",style:{fontSize:"11px",color:"#d1d5db",fontWeight:500,letterSpacing:"0.05em",marginLeft:"8px"},children:"|"}),j?e.jsxs("button",{onClick:V,className:"flex items-center gap-2 text-[#005c75] underline hover:text-[#004a5e] transition-colors ml-2 font-mono uppercase cursor-pointer",style:{fontSize:"11px",fontWeight:500,letterSpacing:"0.05em"},children:[C.filter(s=>s.uncommittedCount>0).length," ","uncommitted"," ",C.filter(s=>s.uncommittedCount>0).length===1?"file":"files",e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M6 18L18 6M6 6l12 12"})})]}):e.jsxs("button",{onClick:V,className:"text-[#005c75] underline hover:text-[#004a5e] transition-colors ml-2 font-mono uppercase",style:{fontSize:"11px",fontWeight:500,letterSpacing:"0.05em"},children:[W," uncommitted"," ",W===1?"file":"files"]})]}),Z.length>0&&e.jsxs("div",{className:"flex gap-6",children:[e.jsxs("button",{onClick:()=>{M(new Set(Z.map(s=>s.filePath))),x(!0)},className:"text-[#005c75] hover:bg-[#E6F5F8] hover:text-[#003d4f] font-mono uppercase transition-all cursor-pointer px-3 py-1 rounded flex items-center gap-1.5",style:{fontSize:"11px",fontWeight:500,letterSpacing:"0.05em"},children:[e.jsx(pe,{className:"w-3.5 h-3.5"}),"Expand All"]}),e.jsxs("button",{onClick:()=>{M(new Set),x(!1)},className:"text-[#005c75] hover:bg-[#E6F5F8] hover:text-[#003d4f] font-mono uppercase transition-all cursor-pointer px-3 py-1 rounded flex items-center gap-1.5",style:{fontSize:"11px",fontWeight:500,letterSpacing:"0.05em"},children:[e.jsx(he,{className:"w-3.5 h-3.5"}),"Collapse All"]})]})]})}),e.jsx(fe,{showActions:!0,sortOrder:z,onSortChange:ie}),e.jsx("div",{className:"flex flex-col gap-[3px]",children:Z.map(s=>{const i=B.has(s.filePath),q=s.entities.filter(t=>(t.entityType==="visual"||t.entityType==="library")&&(T(t,(o==null?void 0:o.jobs)||[])==="not-analyzed"||T(t,(o==null?void 0:o.jobs)||[])==="out-of-date"||T(t,(o==null?void 0:o.jobs)||[])==="incomplete")).length>0,ee=t=>{var n;return((n=L==null?void 0:L.currentEntityShas)==null?void 0:n.includes(t))||!1},G=t=>{var n;return U!=null&&U(t)?!0:((n=o==null?void 0:o.jobs)==null?void 0:n.some(r=>{var c;return(c=r.entityShas)==null?void 0:c.includes(t.sha)}))||!1},a=t=>{k==null||k(t)};return e.jsx(xe,{filePath:s.filePath,isExpanded:i,onToggle:()=>re(s.filePath),simulationPreviews:e.jsx(ye,{entities:s.entities,maxPreviews:1}),entityCount:s.totalCount,state:s.state,lastModified:s.lastUpdated,uncommittedCount:s.uncommittedCount,isUncommitted:s.uncommittedCount>0,actionButton:q?e.jsx("button",{onClick:t=>{t.stopPropagation();const n=s.entities.filter(r=>(r.entityType==="visual"||r.entityType==="library")&&(T(r,(o==null?void 0:o.jobs)||[])==="not-analyzed"||T(r,(o==null?void 0:o.jobs)||[])==="out-of-date"||T(r,(o==null?void 0:o.jobs)||[])==="incomplete"));D==null||D(n)},className:"bg-[#005c75] text-white rounded text-[12px] font-['IBM_Plex_Sans'] font-normal hover:bg-[#004a5e] transition-colors cursor-pointer px-[15px] py-0 h-[28px]",children:s.state==="out-of-date"?"Re-analyze":"Analyze"}):void 0,children:s.entities.sort((t,n)=>{var m,h,f,v;const r=!((m=t.metadata)!=null&&m.notExported)&&!((h=t.metadata)!=null&&h.namedExport),c=!((f=n.metadata)!=null&&f.notExported)&&!((v=n.metadata)!=null&&v.namedExport);if(r&&!c)return-1;if(!r&&c)return 1;const d=t.entityType==="visual"||t.entityType==="library",l=n.entityType==="visual"||n.entityType==="library";return d&&!l?-1:!d&&l?1:t.name.localeCompare(n.name)}).map(t=>e.jsx(ue,{entity:t,isActivelyAnalyzing:ee(t.sha),isQueued:G(t),onGenerateSimulation:a},t.sha))},s.filePath)})}),K>1&&e.jsxs("div",{className:"flex justify-center items-center gap-4 mt-6 p-4",children:[N>1&&e.jsx("a",{href:`?${new URLSearchParams({...Object.fromEntries(I),page:String(N-1)}).toString()}`,className:"no-underline font-medium hover:underline",style:{color:"#005C75"},children:"← Previous"}),e.jsxs("span",{children:["Page ",N," of ",K]}),N<K&&e.jsx("a",{href:`?${new URLSearchParams({...Object.fromEntries(I),page:String(N+1)}).toString()}`,className:"no-underline font-medium hover:underline",style:{color:"#005C75"},children:"Next →"})]})]})}const De=()=>[{title:"Files & Entities - CodeYam"},{name:"description",content:"Browse your codebase files and entities"}],We=le(function(){var B,M,A;const{entities:N,currentCommit:b,page:L,filter:S,entityType:_,queueState:o,error:U}=ce();de(),ne();const[w,k]=u.useState(!1);me({source:"files-page"});const{handleGenerateSimulation:D,handleGenerateAllSimulations:H,isEntityPending:J,pendingEntityKeys:W}=ge((M=(B=b==null?void 0:b.metadata)==null?void 0:B.currentRun)==null?void 0:M.currentEntityShas,o),j=N||[],V=u.useMemo(()=>{const y=new Set([]);for(const g of j)y.add(g.filePath??"No File Path");return Array.from(y)},[j]),I=u.useMemo(()=>{let y=j;return w&&(y=y.filter(g=>{var x;return(x=g.metadata)==null?void 0:x.isUncommitted})),y.sort((g,x)=>{var E,$,z,Y,P,R;return(E=g.metadata)!=null&&E.isUncommitted&&!(($=x.metadata)!=null&&$.isUncommitted)?-1:!((z=g.metadata)!=null&&z.isUncommitted)&&((Y=x.metadata)!=null&&Y.isUncommitted)?1:new Date(((P=x.metadata)==null?void 0:P.editedAt)||0).getTime()-new Date(((R=g.metadata)==null?void 0:R.editedAt)||0).getTime()})},[j,w]),X=u.useMemo(()=>{var g;const y=new Set([]);for(const x of j)(g=x.metadata)!=null&&g.isUncommitted&&y.add(x.filePath??"No File Path");return Array.from(y)},[j]);return U?e.jsx("div",{className:"bg-[#F8F7F6] min-h-screen",children:e.jsxs("div",{className:"px-12 py-6 font-sans",children:[e.jsx("h1",{className:"text-[28px] font-semibold text-gray-900",children:"Error"}),e.jsx("p",{className:"text-base text-gray-500",children:U})]})}):j.length===0?e.jsx("div",{className:"bg-[#f9f9f9] min-h-screen",children:e.jsxs("div",{className:"px-20 py-12 font-sans",children:[e.jsxs("div",{className:"mb-8",children:[e.jsx("h1",{className:"text-[28px] font-semibold text-gray-900 mb-2",children:"Files & Entities"}),e.jsx("p",{className:"text-[15px] text-gray-500",children:"This is a list of all the files in your app."})]}),e.jsx("div",{className:"bg-white rounded-lg border border-gray-200 p-12 text-center",children:e.jsxs("div",{className:"max-w-md mx-auto",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900 mb-3",children:"No entities found"}),e.jsxs("p",{className:"text-[15px] text-gray-600 mb-6",children:["Your project hasn't been analyzed yet. Run"," ",e.jsx("code",{className:"px-2 py-1 bg-gray-100 rounded text-sm font-mono",children:"codeyam analyze"})," ","to extract entities from your codebase."]}),e.jsx("p",{className:"text-sm text-gray-500",children:"Entities include React components, functions, and other analyzable code elements."})]})})]})}):e.jsx("div",{className:"bg-[#f9f9f9] min-h-screen",children:e.jsxs("div",{className:"px-20 py-12 font-sans",children:[e.jsxs("div",{className:"mb-8",children:[e.jsx("h1",{className:"text-[28px] font-semibold text-gray-900 mb-2",children:"Files & Entities"}),e.jsx("p",{className:"text-[15px] text-gray-500",children:"This is a list of all the files in your app."})]}),e.jsx(be,{entities:I,page:L,itemsPerPage:50,currentRun:(A=b==null?void 0:b.metadata)==null?void 0:A.currentRun,filter:S,entityType:_,queueState:o,isEntityPending:J,pendingEntityKeys:W,onGenerateSimulation:D,onGenerateAllSimulations:H,totalFilesCount:V.length,totalEntitiesCount:j.length,uncommittedFilesCount:X.length,showOnlyUncommitted:w,onToggleUncommitted:()=>k(!w)})]})})});export{We as default,De as meta};
@@ -1 +0,0 @@
1
- import{r as S,d as ie,j as e,w as ve,u as we,b as Ne}from"./chunk-JZWAC4HX-C4pqxYJB.js";import{u as Se}from"./useReportContext-O-jkvSPx.js";import{F as re,b as le,E as ce,S as de,u as Ce,C as ke,a as Be}from"./EntityItem-BcgbViKV.js";import{L as Ae}from"./LogViewer-ceAyBX-H.js";import Me from"./index-yHOVb4rc.js";import{g as pe}from"./fileTableUtils-cPo8LiG3.js";import"./createLucideIcon-CC6AbExI.js";import"./useToast-9FIWuYfK.js";import"./TruncatedFilePath-C8OKAR5x.js";import"./SafeScreenshot-BED4B6sP.js";import"./LibraryFunctionPreview-DLeucoVX.js";import"./scenarioStatus-B_8jpV3e.js";import"./triangle-alert-BLdiCuG-.js";import"./EntityTypeIcon-CQIG2qda.js";import"./EntityTypeBadge-g3saevPb.js";function Te(o,l,h=10){var u;const t=new Map,s=c=>c.entityType==="visual"||c.entityType==="library";for(const c of o)s(c)&&t.set(c.sha,{entity:c,depth:0});const n=new Map;for(const c of l){const x=(u=c.metadata)==null?void 0:u.importedBy;if(x)for(const y of Object.keys(x))for(const m of Object.keys(x[y])){const{shas:B}=x[y][m];for(const T of B)n.has(c.sha)||n.set(c.sha,new Set),n.get(c.sha).add(T)}}const i=[],a=new Set;for(const c of o)i.push({sha:c.sha,depth:0}),a.add(c.sha);for(;i.length>0;){const{sha:c,depth:x}=i.shift();if(x>=h)continue;const y=n.get(c);if(y)for(const m of y){if(a.has(m))continue;a.add(m);const B=l.find(T=>T.sha===m);if(B){if(s(B)){const T=x+1,F=t.get(m);(!F||T<F.depth)&&t.set(m,{entity:B,depth:T})}i.push({sha:m,depth:x+1})}}}return Array.from(t.values()).sort((c,x)=>c.depth!==x.depth?c.depth-x.depth:c.entity.name.localeCompare(x.entity.name))}function W(o){const l=new Map;for(const t of o)l.has(t.name)||l.set(t.name,[]),l.get(t.name).push(t);const h=[];for(const t of l.values())if(t.length===1)h.push(t[0]);else{const s=t.sort((n,i)=>{var c,x;const a=((c=n.metadata)==null?void 0:c.editedAt)||n.createdAt||"";return(((x=i.metadata)==null?void 0:x.editedAt)||i.createdAt||"").localeCompare(a)});h.push(s[0])}return h}function Fe(o,l){const h=new Map,t=new Set(o.map(s=>s.path));for(const s of o)s.status==="renamed"&&s.oldPath&&t.add(s.oldPath);for(const s of o){const n=l.filter(u=>u.filePath===s.path||s.status==="renamed"&&s.oldPath&&u.filePath===s.oldPath),i=n.filter(u=>{var c,x;return t.has(u.filePath)&&((c=u.metadata)==null?void 0:c.isUncommitted)&&!((x=u.metadata)!=null&&x.isSuperseded)}),a=W(i);h.set(s.path,{status:s,entities:n,editedEntities:a})}return h}function ze(o,l,h){const t=new Map;if(!h){for(const n of o)if(n.status==="deleted")t.set(n.path,{status:n,entities:[]});else{const i=l.filter(u=>u.filePath===n.path||n.status==="renamed"&&n.oldPath&&u.filePath===n.oldPath),a=W(i);t.set(n.path,{status:n,entities:a})}return t}const s=new Map;for(const n of h.fileComparisons){const i=new Set;for(const a of n.newEntities)i.add(a.name);for(const a of n.modifiedEntities)i.add(a.name);for(const a of n.deletedEntities)i.add(a.name);i.size>0&&s.set(n.filePath,i)}for(const n of o){const i=s.get(n.path);if(n.status==="deleted")t.set(n.path,{status:n,entities:[]});else{const a=i?l.filter(c=>(c.filePath===n.path||n.status==="renamed"&&n.oldPath&&c.filePath===n.oldPath)&&i.has(c.name)):[],u=W(a);t.set(n.path,{status:n,entities:u})}}return t}function De(o,l){const h=new Map,t=Ee(o,l);for(const s of t){const i=Te([s],l).filter(({depth:a})=>a>0);h.set(s.sha,i)}return h}function Ee(o,l){const h=new Set(o.map(s=>s.path));for(const s of o)s.status==="renamed"&&s.oldPath&&h.add(s.oldPath);const t=l.filter(s=>{var n,i;return h.has(s.filePath)&&((n=s.metadata)==null?void 0:n.isUncommitted)&&!((i=s.metadata)!=null&&i.isSuperseded)});return W(t)}function Pe(o,l,h){const[t,s]=S.useState(()=>new Set),[n,i]=S.useState(()=>new Set),a=S.useRef([]),u=S.useRef([]);return S.useEffect(()=>{(l.length!==a.current.length||l.some((F,A)=>F!==a.current[A]))&&(a.current=l,s(F=>{const A=new Set;return l.forEach(z=>{F.has(z)&&A.add(z)}),A}))},[l]),S.useEffect(()=>{(h.length!==u.current.length||h.some((F,A)=>F!==u.current[A]))&&(u.current=h,i(F=>{const A=new Set;return h.forEach(z=>{F.has(z)&&A.add(z)}),A}))},[h]),{expandedUncommitted:t,expandedBranch:n,setExpandedUncommitted:s,setExpandedBranch:i,toggleFile:(T,F,A)=>{A(z=>{const D=new Set(z);return D.has(T)?D.delete(T):D.add(T),D})},expandAllUncommitted:()=>{s(new Set(l))},collapseAllUncommitted:()=>{s(new Set)},expandAllBranch:()=>{i(new Set(h))},collapseAllBranch:()=>{i(new Set)}}}function Ie(o,l,h){const[t,s]=S.useState(null),[n,i]=S.useState(null),a=ie();S.useEffect(()=>{var y,m;((y=a.data)==null?void 0:y.oldContent)!==void 0&&((m=a.data)==null?void 0:m.newContent)!==void 0&&i({oldContent:a.data.oldContent,newContent:a.data.newContent,fileName:a.data.fileName})},[a.data]);const u=y=>{s({type:"file",path:y}),i(null);const m=new FormData;m.append("actionType","getDiff"),m.append("filePath",y),m.append("diffType","branch"),m.append("baseBranch",o),m.append("currentBranch",l||""),a.submit(m,{method:"post"})},c=(y,m)=>{s({type:"entity",path:y,entitySha:m}),i(null);const B=new FormData;B.append("actionType","getDiff"),B.append("filePath",y),B.append("diffType","branch"),B.append("baseBranch",o),B.append("currentBranch",l||""),B.append("entitySha",m),a.submit(B,{method:"post"})},x=()=>{s(null),i(null)};return{diffView:t,diffContent:n,isLoading:a.state==="loading"||a.state==="submitting",handleShowFileDiff:u,handleShowEntityDiff:c,handleCloseDiff:x}}function _e({diffView:o,diffContent:l,isLoading:h,entities:t,onClose:s}){var c;const[n,i]=S.useState(!1),[a,u]=S.useState(!1);return S.useEffect(()=>{u(!0)},[]),e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center p-8 z-50",children:e.jsxs("div",{className:"bg-white rounded-xl shadow-2xl max-w-6xl w-full max-h-[90vh] flex flex-col",children:[e.jsxs("div",{className:"p-6 border-b border-[#e1e1e1] flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-['IBM_Plex_Sans'] text-2xl font-semibold text-[#232323]",children:o.type==="file"?"File Diff":"Entity Diff"}),e.jsx("p",{className:"font-['IBM_Plex_Mono'] text-sm text-[#8e8e8e] mt-1",children:o.path}),o.type==="entity"&&o.entitySha&&e.jsxs("p",{className:"font-['IBM_Plex_Mono'] text-sm text-[#8e8e8e]",children:["Entity:"," ",((c=t.find(x=>x.sha===o.entitySha))==null?void 0:c.name)||o.entitySha]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:()=>i(!n),className:"px-3 py-1.5 bg-[#efefef] text-[#3e3e3e] rounded-lg font-['IBM_Plex_Sans'] text-sm font-semibold hover:bg-[#e1e1e1] transition-colors cursor-pointer",title:n?"Show changes only":"Show full file",children:n?"Show Changes Only":"Show Full File"}),e.jsx("button",{onClick:s,className:"text-[#8e8e8e] hover:text-[#626262] transition-colors cursor-pointer",children:e.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),e.jsx("div",{className:"flex-1 overflow-auto",children:h?e.jsx("div",{className:"p-6 text-center",children:e.jsx("div",{className:"text-[#8e8e8e]",children:"Loading diff..."})}):l?e.jsx("div",{className:"diff-viewer-wrapper",children:a&&e.jsx(Me,{oldValue:l.oldContent,newValue:l.newContent,splitView:!0,useDarkTheme:!1,showDiffOnly:!n,extraLinesSurroundingDiff:4,styles:{variables:{light:{diffViewerBackground:"#fff",diffViewerColor:"#212529",addedBackground:"#e6ffed",addedColor:"#24292e",removedBackground:"#ffeef0",removedColor:"#24292e",wordAddedBackground:"#acf2bd",wordRemovedBackground:"#fdb8c0",addedGutterBackground:"#cdffd8",removedGutterBackground:"#ffdce0",gutterBackground:"#f6f8fa",gutterBackgroundDark:"#f3f4f6",highlightBackground:"#fffbdd",highlightGutterBackground:"#fff5b1"}},contentText:{fontSize:"12px",lineHeight:"1.5"},line:{padding:"2px 10px",fontSize:"12px","&:hover":{background:"#f8f9fa"}},splitView:{display:"flex",width:"100%"},diffContainer:{width:"50%",overflowX:"auto"}}})}):e.jsx("div",{className:"p-6 text-center",children:e.jsx("div",{className:"text-[#8e8e8e]",children:"No diff available"})})}),e.jsx("div",{className:"p-6 border-t border-[#e1e1e1] flex justify-end gap-3",children:e.jsx("button",{onClick:s,className:"px-4 py-2 bg-[#efefef] text-[#3e3e3e] rounded-lg font-['IBM_Plex_Sans'] font-semibold hover:bg-[#e1e1e1] transition-colors cursor-pointer",children:"Close"})})]})})}function Le({files:o,currentBranch:l,defaultBranch:h,baseBranch:t,allBranches:s,expandedFiles:n,isEntityBeingAnalyzed:i,isEntityQueued:a,sortOrder:u,onToggleFile:c,onBranchChange:x,onGenerateSimulation:y,onSortChange:m,onAnalyzeAll:B,analyzeAllDisabled:T,analyzeAllText:F}){const A=o.flatMap(([v,{entities:M}])=>{const f=M.filter(g=>i(g.sha)||a(g)).map(g=>g.sha);return f.length>0?[{entityShas:f}]:[]}),z=v=>{const M=v.map(f=>pe(f,A));return M.includes("analyzing")||M.includes("queued")?"analyzing":M.includes("out-of-date")?"out-of-date":M.includes("not-analyzed")?"not-analyzed":"up-to-date"},D=S.useMemo(()=>[...o].sort((v,M)=>{const f=v[1].entities.reduce((C,k)=>{var N;const j=((N=k.metadata)==null?void 0:N.editedAt)||k.updatedAt;return j?C?new Date(j)>new Date(C)?j:C:j:C},null),g=M[1].entities.reduce((C,k)=>{var N;const j=((N=k.metadata)==null?void 0:N.editedAt)||k.updatedAt;return j?C?new Date(j)>new Date(C)?j:C:j:C},null);if(!f&&!g)return 0;if(!f)return 1;if(!g)return-1;const b=new Date(f).getTime(),w=new Date(g).getTime();return u==="desc"?w-b:b-w}),[o,u]);return e.jsx("div",{children:o.length>0?e.jsxs("div",{children:[e.jsx(re,{showActions:!0,sortOrder:u,onSortChange:m,onAnalyzeAll:B,analyzeAllDisabled:T,analyzeAllText:F}),e.jsx("div",{className:"flex flex-col gap-[3px]",children:D.map(([v,{status:M,entities:f,isUncommitted:g}])=>{const b=n.has(v),w=z(f),C=f.reduce((d,p)=>{var P;const E=((P=p.metadata)==null?void 0:P.editedAt)||p.updatedAt;return E?d?new Date(E)>new Date(d)?E:d:E:d},null),j=f.filter(d=>d.entityType==="visual"||d.entityType==="library").length===0;let N;return j?N=e.jsx("span",{className:"text-[12px] text-gray-400",children:"Not Analyzable"}):w==="analyzing"?N=e.jsxs("span",{className:"text-[13px] px-2 rounded inline-flex items-center gap-1.5 whitespace-nowrap",style:{backgroundColor:"#ffdbf6",color:"#ff2ab5",height:"26px"},children:[e.jsxs("svg",{width:"8",height:"8",viewBox:"0 0 9 9",fill:"none",className:"animate-spin",children:[e.jsx("circle",{cx:"4.5",cy:"4.5",r:"3.5",stroke:"#FFF4FC",strokeWidth:"1",fill:"none"}),e.jsx("path",{d:"M4.5 1C2.57 1 1 2.57 1 4.5C1 5.6 1.5 6.58 2.28 7.23",stroke:"#FF2AB5",strokeWidth:"1",strokeLinecap:"round",fill:"none"})]}),"Analyzing..."]}):w==="up-to-date"?N=e.jsx("span",{className:"text-[13px] px-2 rounded inline-flex items-center gap-1.5 whitespace-nowrap",style:{backgroundColor:"#e8ffe6",color:"#00925d",height:"26px"},children:"Up to date"}):w==="out-of-date"?N=e.jsx("button",{onClick:d=>{d.stopPropagation(),f.filter(p=>(p.entityType==="visual"||p.entityType==="library")&&!i(p.sha)&&!a(p)).forEach(p=>y(p))},className:"bg-[#005c75] text-white rounded text-[12px] font-['IBM_Plex_Sans'] font-normal hover:bg-[#004a5e] transition-colors px-[15px] py-0 h-[28px]",children:"Re-Analyze"}):w==="not-analyzed"&&(N=e.jsx("button",{onClick:d=>{d.stopPropagation(),f.filter(p=>(p.entityType==="visual"||p.entityType==="library")&&!i(p.sha)&&!a(p)).forEach(p=>y(p))},className:"bg-[#005c75] text-white rounded text-[12px] font-['IBM_Plex_Sans'] font-normal hover:bg-[#004a5e] transition-colors px-[15px] py-0 h-[28px]",children:"Analyze File"})),e.jsx(le,{filePath:v,isExpanded:b,onToggle:()=>c(v),fileStatus:M,isUncommitted:g,simulationPreviews:e.jsx(de,{entities:f,maxPreviews:1}),entityCount:f.length,state:w,lastModified:C,isNotAnalyzable:j,actionButton:N,children:f.sort((d,p)=>{const E=d.entityType==="visual"||d.entityType==="library",P=p.entityType==="visual"||p.entityType==="library";return E&&!P?-1:!E&&P?1:0}).map(d=>e.jsx(ce,{entity:d,isActivelyAnalyzing:i(d.sha),isQueued:a(d),onGenerateSimulation:y},d.sha))},v)})})]}):e.jsxs("div",{className:"bg-[#efefef] rounded-[10px] flex flex-col items-center justify-center text-center",style:{height:"190px"},children:[e.jsx("p",{className:"font-['IBM_Plex_Sans'] font-medium text-[16px] text-[#3e3e3e] leading-[24px] mb-2",children:"No Changes"}),e.jsx("p",{className:"font-['IBM_Plex_Sans'] font-normal text-[14px] text-[#3e3e3e] leading-[18px]",children:"No files have been modified in this branch."})]})})}function Ue({files:o,entityImpactMap:l,expandedFiles:h,isEntityBeingAnalyzed:t,isEntityQueued:s,projectSlug:n,baseBranch:i,currentBranch:a,sortOrder:u,onToggleFile:c,onShowFileDiff:x,onGenerateSimulation:y,onSortChange:m,onAnalyzeAll:B,analyzeAllDisabled:T,analyzeAllText:F}){const A=S.useMemo(()=>{const v=[];return o.forEach(([M,{editedEntities:f}])=>{const g=f.filter(b=>t(b.sha)||s(b)).map(b=>b.sha);g.length>0&&v.push({entityShas:g})}),v},[o,t,s]),z=S.useMemo(()=>{const v=new Map;return o.forEach(([M,{editedEntities:f}])=>{const g=f.map(k=>pe(k,A));let b;g.includes("analyzing")||g.includes("queued")?b="analyzing":g.includes("out-of-date")?b="out-of-date":g.includes("not-analyzed")?b="not-analyzed":b="up-to-date";const w=f.reduce((k,j)=>{var d;const N=((d=j.metadata)==null?void 0:d.editedAt)||j.updatedAt;return N&&(!k||new Date(N)>new Date(k))?N:k},null),C=f.filter(k=>k.entityType==="visual"||k.entityType==="library").length;v.set(M,{state:b,lastModified:w,analyzableCount:C})}),v},[o,A]),D=S.useMemo(()=>[...o].sort((v,M)=>{const f=z.get(v[0]),g=z.get(M[0]),b=f==null?void 0:f.lastModified,w=g==null?void 0:g.lastModified;if(!b&&!w)return 0;if(!b)return 1;if(!w)return-1;const C=new Date(b).getTime(),k=new Date(w).getTime();return u==="desc"?k-C:C-k}),[o,z,u]);return o.length===0?e.jsxs("div",{className:"bg-[#efefef] rounded-[10px] flex flex-col items-center justify-center text-center",style:{height:"190px"},children:[e.jsx("p",{className:"font-['IBM_Plex_Sans'] font-medium text-[16px] text-[#3e3e3e] leading-[24px] mb-2",children:"No Uncommitted Changes"}),e.jsx("p",{className:"font-['IBM_Plex_Sans'] font-normal text-[14px] text-[#3e3e3e] leading-[18px]",children:"If you edit a file in your project, it will show up here."})]}):e.jsxs("div",{children:[e.jsx(re,{showActions:!0,sortOrder:u,onSortChange:m,onAnalyzeAll:B,analyzeAllDisabled:T,analyzeAllText:F}),e.jsx("div",{className:"flex flex-col gap-[3px]",children:D.map(([v,{status:M,editedEntities:f}])=>{const g=h.has(v),b=z.get(v),{state:w,lastModified:C,analyzableCount:k}=b,j=k===0;let N;return j?N=e.jsx("span",{className:"text-[12px] text-gray-400",children:"Not Analyzable"}):w==="analyzing"?N=e.jsxs("span",{className:"text-[13px] px-2 rounded inline-flex items-center gap-1.5 whitespace-nowrap",style:{backgroundColor:"#ffdbf6",color:"#ff2ab5",height:"26px"},children:[e.jsxs("svg",{width:"8",height:"8",viewBox:"0 0 9 9",fill:"none",className:"animate-spin",children:[e.jsx("circle",{cx:"4.5",cy:"4.5",r:"3.5",stroke:"#FFF4FC",strokeWidth:"1",fill:"none"}),e.jsx("path",{d:"M4.5 1C2.57 1 1 2.57 1 4.5C1 5.6 1.5 6.58 2.28 7.23",stroke:"#FF2AB5",strokeWidth:"1",strokeLinecap:"round",fill:"none"})]}),"Analyzing..."]}):w==="up-to-date"?N=e.jsx("span",{className:"text-[13px] px-2 rounded inline-flex items-center gap-1.5 whitespace-nowrap",style:{backgroundColor:"#e8ffe6",color:"#00925d",height:"26px"},children:"Up to date"}):w==="out-of-date"?N=e.jsx("button",{onClick:d=>{d.stopPropagation(),f.filter(p=>(p.entityType==="visual"||p.entityType==="library")&&!t(p.sha)&&!s(p)).forEach(p=>y(p))},className:"bg-[#005c75] text-white rounded text-[12px] font-['IBM_Plex_Sans'] font-normal hover:bg-[#004a5e] transition-colors px-[15px] py-0 h-[28px]",children:"Re-Analyze"}):w==="not-analyzed"&&(N=e.jsx("button",{onClick:d=>{d.stopPropagation(),f.filter(p=>(p.entityType==="visual"||p.entityType==="library")&&!t(p.sha)&&!s(p)).forEach(p=>y(p))},className:"bg-[#005c75] text-white rounded text-[12px] font-['IBM_Plex_Sans'] font-normal hover:bg-[#004a5e] transition-colors px-[15px] py-0 h-[28px]",children:"Analyze File"})),e.jsx(le,{filePath:v,isExpanded:g,onToggle:()=>c(v),fileStatus:M,simulationPreviews:e.jsx(de,{entities:f,maxPreviews:1}),entityCount:f.length,state:w,lastModified:C,isNotAnalyzable:j,isUncommitted:!0,actionButton:N,children:f.sort((d,p)=>{const E=d.entityType==="visual"||d.entityType==="library",P=p.entityType==="visual"||p.entityType==="library";return E&&!P?-1:!E&&P?1:0}).map(d=>e.jsx(ce,{entity:d,isActivelyAnalyzing:t(d.sha),isQueued:s(d),onGenerateSimulation:y},d.sha))},v)})})]})}function We({activeTab:o,onTabChange:l,uncommittedCount:h,branchCount:t}){return e.jsx("div",{className:"border-b border-gray-200",children:e.jsxs("nav",{className:"flex gap-8 items-center",children:[e.jsxs("button",{onClick:()=>l("branch"),className:`relative pb-3 px-2 text-sm font-medium transition-colors cursor-pointer ${o==="branch"?"text-primary-100":"text-gray-500 hover:text-gray-700"}`,children:[e.jsxs("span",{className:"flex items-center gap-2",children:["Branch Changes",t>0&&e.jsx("span",{className:`inline-flex items-center justify-center px-2 py-0.5 text-xs font-semibold rounded-full ${o==="branch"?"bg-[#cbf3fa] text-[#005c75]":"bg-[#e1e1e1] text-[#3e3e3e]"}`,children:t})]}),o==="branch"&&e.jsx("span",{className:"absolute -bottom-px left-0 right-0 h-0.5 bg-primary-100"})]}),e.jsxs("button",{onClick:()=>l("uncommitted"),className:`relative pb-3 px-2 text-sm font-medium transition-colors cursor-pointer ${o==="uncommitted"?"text-primary-100":"text-gray-500 hover:text-gray-700"}`,children:[e.jsxs("span",{className:"flex items-center gap-2",children:["Uncommitted Changes",h>0&&e.jsx("span",{className:`inline-flex items-center justify-center px-2 py-0.5 text-xs font-semibold rounded-full ${o==="uncommitted"?"bg-[#cbf3fa] text-[#005c75]":"bg-[#e1e1e1] text-[#3e3e3e]"}`,children:h})]}),o==="uncommitted"&&e.jsx("span",{className:"absolute -bottom-px left-0 right-0 h-0.5 bg-primary-100"})]})]})})}const nt=()=>[{title:"Git - CodeYam"},{name:"description",content:"Git status and impact analysis"}],st=ve(function(){var se,ae;const{entities:l,gitStatus:h,currentBranch:t,actualCurrentBranch:s,defaultBranch:n,allBranches:i,baseBranch:a,branchDiff:u,currentCommit:c,projectSlug:x,queueState:y}=we();Se({source:"git-page"});const[m,B]=Ne(),[T,F]=S.useState(null),[A,z]=S.useState("desc"),[D,v]=S.useState("branch"),M=m.get("expanded")==="true",f=()=>{z(r=>r==="desc"?"asc":"desc")},g=ie(),b=g.data;S.useEffect(()=>{t&&a&&t!==a&&g.state==="idle"&&!b&&g.load(`/api/branch-entity-diff?base=${encodeURIComponent(a)}&compare=${encodeURIComponent(t)}`)},[t,a,g,b]);const w=S.useMemo(()=>{const r=Fe(h,l);return Array.from(r.entries()).sort((I,_)=>I[0].localeCompare(_[0]))},[h,l]),C=S.useMemo(()=>{const r=ze(u,l,b);return Array.from(r.entries()).sort((I,_)=>I[0].localeCompare(_[0]))},[u,l,b]),k=S.useMemo(()=>De(h,l),[h,l]),j=S.useMemo(()=>D==="uncommitted"?w:C,[D,w,C]),N=S.useMemo(()=>j.map(([r])=>r),[j]),{expandedUncommitted:d,setExpandedUncommitted:p,toggleFile:E,expandAllUncommitted:P,collapseAllUncommitted:he}=Pe(M,N,[]),{diffView:$,diffContent:fe,isLoading:ue,handleShowFileDiff:me,handleCloseDiff:xe}=Ie(a,t),L=(se=c==null?void 0:c.metadata)==null?void 0:se.currentRun,Y=new Set((L==null?void 0:L.currentEntityShas)||[]),G=new Set(y.jobs.flatMap(r=>r.entityShas||[])),V=new Set(((ae=y.currentlyExecuting)==null?void 0:ae.entityShas)||[]),{isAnalyzing:H,handleGenerateSimulation:J,handleGenerateAllSimulations:ge,isEntityBeingAnalyzed:O,isEntityPending:X}=Ce(L==null?void 0:L.currentEntityShas,y),K=r=>X(r)||G.has(r.sha)||V.has(r.sha),ye=r=>{r===(s||t)?m.delete("viewBranch"):m.set("viewBranch",r),B(m)},Z=r=>{r===n?m.delete("compare"):m.set("compare",r),B(m)},Q=()=>{const I=j.flatMap(([_,oe])=>oe.editedEntities||oe.entities||[]).filter(_=>!Y.has(_.sha)&&!G.has(_.sha)&&!V.has(_.sha)&&!X(_));ge(I)},be=w.length,je=C.length,R=j.flatMap(([r,I])=>I.editedEntities||I.entities||[]),U=R.filter(r=>r.entityType==="visual"||r.entityType==="library"),q=U.length>0&&U.every(r=>Y.has(r.sha)),ee=U.length>0&&!q&&U.every(r=>G.has(r.sha)||V.has(r.sha)),te=H||q||ee,ne=q?"Analyzing...":ee?"Queued...":H?"Analyzing...":"Analyze All";return e.jsx("div",{className:"bg-[#F8F7F6] min-h-screen",children:e.jsxs("div",{className:"px-20 py-12",children:[e.jsxs("div",{className:"mb-8",children:[e.jsx("h1",{className:"text-[28px] font-semibold text-gray-900 mb-2",children:"Git Changes"}),e.jsxs("p",{className:"text-[15px] text-gray-500",children:["This is a list of all the files that are affected by your local changes. ",e.jsx("strong",{children:"Analyze a file to get simulations."})]})]}),e.jsx("div",{className:"mb-6",children:e.jsx(We,{activeTab:D,onTabChange:v,uncommittedCount:be,branchCount:je})}),t&&D==="branch"&&e.jsx("div",{className:"bg-white border-b border-gray-200 rounded-t-lg px-5 py-4 mb-3",children:t===n?e.jsxs("div",{className:"text-gray-700",children:["You are currently on the primary branch,"," ",e.jsx("span",{className:"text-cyblack-75",children:n}),"."]}):e.jsxs("div",{className:"flex gap-6 items-center",children:[e.jsxs("div",{className:"shrink-0",children:[e.jsx("div",{className:"text-[11px] text-gray-500 mb-2 uppercase",children:"Changes in Branch:"}),i.length>0?e.jsxs("div",{className:"relative w-50",children:[e.jsx("select",{value:t,onChange:r=>ye(r.target.value),className:"appearance-none bg-gray-50 border border-gray-200 rounded px-2.5 pr-6 text-[13px] h-9.75 w-full cursor-pointer focus:outline-none focus:ring-0 focus:border-2 focus:border-[#005c75] hover:border-gray-300 transition-colors",children:i.map(r=>e.jsx("option",{value:r,children:r},r))}),e.jsx("svg",{className:"absolute right-2 top-1/2 -translate-y-1/2 w-3 h-3 text-gray-500 pointer-events-none",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}):e.jsx("span",{className:"text-gray-900 font-medium text-[12px]",children:t})]}),e.jsxs("div",{className:"flex-shrink-0",children:[e.jsx("div",{className:"text-[11px] text-gray-500 mb-2 uppercase",children:"Compared To:"}),e.jsxs("div",{className:"relative w-[200px]",children:[e.jsx("select",{value:a,onChange:r=>Z(r.target.value),className:"appearance-none bg-gray-50 border border-gray-200 rounded px-[10px] pr-6 text-[13px] h-[39px] w-full cursor-pointer focus:outline-none focus:ring-0 focus:border-2 focus:border-[#005c75] hover:border-gray-300 transition-colors",children:i.filter(r=>r!==t).map(r=>e.jsx("option",{value:r,children:r},r))}),e.jsx("svg",{className:"absolute right-2 top-1/2 -translate-y-1/2 w-3 h-3 text-gray-500 pointer-events-none",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]})]}),e.jsx("div",{className:"flex-1 mt-6",children:e.jsxs("div",{className:"relative flex items-center",children:[e.jsx("svg",{className:"absolute left-3 w-4 h-4 text-gray-400 pointer-events-none",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),e.jsx("input",{type:"text",placeholder:"Search component",className:"w-full bg-gray-50 border border-gray-200 rounded pl-9 pr-[10px] text-[13px] h-[39px] placeholder:text-gray-400 focus:outline-none focus:ring-0 focus:border-2 focus:border-[#005c75] transition-colors"})]})})]})}),e.jsx("div",{className:"mb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center",children:[e.jsxs("span",{className:"font-mono uppercase",style:{fontSize:"11px",color:"#8b8b8b",fontWeight:500,letterSpacing:"0.05em"},children:[e.jsx("span",{style:{color:"#000000"},children:j.length})," ","modified ",j.length===1?"file":"files"]}),e.jsxs("div",{className:"relative group inline-flex items-center ml-1.5",children:[e.jsx("svg",{className:"w-3 h-3 text-gray-400 cursor-help",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsx("div",{className:"absolute left-0 top-full mt-2 hidden group-hover:block z-50 w-80",children:e.jsxs("div",{className:"bg-gray-900 text-white text-xs rounded-lg px-3 py-2 shadow-lg",children:["In CodeYam, an entity is a discrete, analyzable unit of code that can be independently simulated and tested.",e.jsx("div",{className:"absolute -top-1 left-4 w-2 h-2 bg-gray-900 transform rotate-45"})]})})]}),e.jsx("span",{className:"font-mono uppercase",style:{fontSize:"11px",color:"#d1d5db",fontWeight:500,letterSpacing:"0.05em",marginLeft:"8px"},children:"|"}),e.jsxs("span",{className:"font-mono uppercase",style:{fontSize:"11px",color:"#8b8b8b",fontWeight:500,letterSpacing:"0.05em",marginLeft:"8px"},children:[e.jsx("span",{style:{color:"#000000"},children:R.length})," ",R.length===1?"entity":"entities"]})]}),j.length>0&&e.jsxs("div",{className:"flex gap-6",children:[e.jsxs("button",{onClick:P,className:"text-[#005c75] hover:bg-[#E6F5F8] hover:text-[#003d4f] font-mono uppercase transition-all cursor-pointer px-3 py-1 rounded flex items-center gap-1.5",style:{fontSize:"11px",fontWeight:500,letterSpacing:"0.05em"},children:[e.jsx(ke,{className:"w-3.5 h-3.5"}),"Expand All"]}),e.jsxs("button",{onClick:he,className:"text-[#005c75] hover:bg-[#E6F5F8] hover:text-[#003d4f] font-mono uppercase transition-all cursor-pointer px-3 py-1 rounded flex items-center gap-1.5",style:{fontSize:"11px",fontWeight:500,letterSpacing:"0.05em"},children:[e.jsx(Be,{className:"w-3.5 h-3.5"}),"Collapse All"]})]})]})}),e.jsxs("div",{className:"overflow-hidden",children:[D==="branch"&&t&&e.jsx(Le,{files:C,currentBranch:t,defaultBranch:n,baseBranch:a,allBranches:i,expandedFiles:d,isEntityBeingAnalyzed:O,isEntityQueued:K,sortOrder:A,onToggleFile:r=>E(r,d,p),onBranchChange:Z,onGenerateSimulation:J,onSortChange:f,onAnalyzeAll:Q,analyzeAllDisabled:te,analyzeAllText:ne}),D==="uncommitted"&&e.jsx(Ue,{files:w,entityImpactMap:k,expandedFiles:d,isEntityBeingAnalyzed:O,isEntityQueued:K,projectSlug:x,baseBranch:a,currentBranch:t,sortOrder:A,onToggleFile:r=>E(r,d,p),onShowFileDiff:me,onGenerateSimulation:J,onSortChange:f,onAnalyzeAll:Q,analyzeAllDisabled:te,analyzeAllText:ne})]}),$&&e.jsx(_e,{diffView:$,diffContent:fe,isLoading:ue,entities:l,onClose:xe}),T&&x&&e.jsx(Ae,{projectSlug:x,onClose:()=>F(null)})]})})});export{st as default,nt as meta};