@codeyam/codeyam-cli 0.1.7 → 0.1.9

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 (576) 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 +9 -9
  4. package/analyzer-template/packages/ai/package.json +1 -1
  5. package/analyzer-template/packages/ai/src/lib/astScopes/astScopeAnalyzer.ts +34 -3
  6. package/analyzer-template/packages/ai/src/lib/completionCall.ts +14 -2
  7. package/analyzer-template/packages/ai/src/lib/dataStructure/ScopeDataStructure.ts +27 -0
  8. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/coercePrimitivesToArraysBySchema.ts +62 -0
  9. package/analyzer-template/packages/ai/src/lib/generateEntityScenarioData.ts +78 -2
  10. package/analyzer-template/packages/ai/src/lib/generateExecutionFlows.ts +0 -33
  11. package/analyzer-template/packages/analyze/src/lib/ProjectAnalyzer.ts +19 -7
  12. package/analyzer-template/packages/analyze/src/lib/asts/index.ts +7 -2
  13. package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities.ts +9 -1
  14. package/analyzer-template/packages/analyze/src/lib/files/analyze/dependencyResolver.ts +0 -6
  15. package/analyzer-template/packages/analyze/src/lib/files/analyze/findOrCreateEntity.ts +12 -0
  16. package/analyzer-template/packages/analyze/src/lib/files/scenarios/TransformationTracer.ts +65 -28
  17. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateDataStructure.ts +83 -0
  18. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.ts +0 -98
  19. package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.ts +23 -4
  20. package/analyzer-template/packages/aws/package.json +2 -2
  21. package/analyzer-template/packages/database/index.ts +1 -0
  22. package/analyzer-template/packages/database/package.json +3 -3
  23. package/analyzer-template/packages/database/src/lib/kysely/db.ts +8 -0
  24. package/analyzer-template/packages/database/src/lib/kysely/tables/editorScenariosTable.ts +93 -0
  25. package/analyzer-template/packages/database/src/lib/loadCommits.ts +31 -20
  26. package/analyzer-template/packages/database/src/lib/loadEntities.ts +0 -6
  27. package/analyzer-template/packages/database/src/lib/loadReadyToBeCapturedAnalyses.ts +0 -5
  28. package/analyzer-template/packages/database/src/lib/updateCommitMetadata.ts +94 -143
  29. package/analyzer-template/packages/database/src/lib/updateFreshAnalysisStatus.ts +58 -42
  30. package/analyzer-template/packages/database/src/lib/updateFreshAnalysisStatusWithScenarios.ts +81 -65
  31. package/analyzer-template/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.ts +29 -1
  32. package/analyzer-template/packages/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.ts +33 -5
  33. package/analyzer-template/packages/github/dist/database/index.d.ts +1 -0
  34. package/analyzer-template/packages/github/dist/database/index.d.ts.map +1 -1
  35. package/analyzer-template/packages/github/dist/database/index.js +1 -0
  36. package/analyzer-template/packages/github/dist/database/index.js.map +1 -1
  37. package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.d.ts +2 -0
  38. package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.d.ts.map +1 -1
  39. package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.js +5 -0
  40. package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.js.map +1 -1
  41. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.d.ts +25 -0
  42. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.d.ts.map +1 -0
  43. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.js +76 -0
  44. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.js.map +1 -0
  45. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/scenariosTable.d.ts +5 -0
  46. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/scenariosTable.d.ts.map +1 -1
  47. package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.d.ts.map +1 -1
  48. package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.js +23 -13
  49. package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.js.map +1 -1
  50. package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.d.ts.map +1 -1
  51. package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.js +0 -6
  52. package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.js.map +1 -1
  53. package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.d.ts.map +1 -1
  54. package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.js +1 -4
  55. package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.js.map +1 -1
  56. package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.d.ts.map +1 -1
  57. package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.js +76 -90
  58. package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.js.map +1 -1
  59. package/analyzer-template/packages/github/dist/database/src/lib/updateFreshAnalysisStatus.d.ts.map +1 -1
  60. package/analyzer-template/packages/github/dist/database/src/lib/updateFreshAnalysisStatus.js +41 -30
  61. package/analyzer-template/packages/github/dist/database/src/lib/updateFreshAnalysisStatus.js.map +1 -1
  62. package/analyzer-template/packages/github/dist/database/src/lib/updateFreshAnalysisStatusWithScenarios.d.ts.map +1 -1
  63. package/analyzer-template/packages/github/dist/database/src/lib/updateFreshAnalysisStatusWithScenarios.js +68 -57
  64. package/analyzer-template/packages/github/dist/database/src/lib/updateFreshAnalysisStatusWithScenarios.js.map +1 -1
  65. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.d.ts.map +1 -1
  66. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js +29 -1
  67. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js.map +1 -1
  68. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.d.ts.map +1 -1
  69. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js +33 -5
  70. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js.map +1 -1
  71. package/analyzer-template/packages/github/dist/types/src/enums/ProjectFramework.d.ts +2 -0
  72. package/analyzer-template/packages/github/dist/types/src/enums/ProjectFramework.d.ts.map +1 -1
  73. package/analyzer-template/packages/github/dist/types/src/enums/ProjectFramework.js +2 -0
  74. package/analyzer-template/packages/github/dist/types/src/enums/ProjectFramework.js.map +1 -1
  75. package/analyzer-template/packages/github/dist/types/src/types/ProjectMetadata.d.ts +1 -0
  76. package/analyzer-template/packages/github/dist/types/src/types/ProjectMetadata.d.ts.map +1 -1
  77. package/analyzer-template/packages/github/dist/types/src/types/Scenario.d.ts +10 -0
  78. package/analyzer-template/packages/github/dist/types/src/types/Scenario.d.ts.map +1 -1
  79. package/analyzer-template/packages/github/package.json +1 -1
  80. package/analyzer-template/packages/types/src/enums/ProjectFramework.ts +2 -0
  81. package/analyzer-template/packages/types/src/types/ProjectMetadata.ts +1 -0
  82. package/analyzer-template/packages/types/src/types/Scenario.ts +10 -0
  83. package/analyzer-template/packages/ui-components/package.json +1 -1
  84. package/analyzer-template/packages/utils/dist/types/src/enums/ProjectFramework.d.ts +2 -0
  85. package/analyzer-template/packages/utils/dist/types/src/enums/ProjectFramework.d.ts.map +1 -1
  86. package/analyzer-template/packages/utils/dist/types/src/enums/ProjectFramework.js +2 -0
  87. package/analyzer-template/packages/utils/dist/types/src/enums/ProjectFramework.js.map +1 -1
  88. package/analyzer-template/packages/utils/dist/types/src/types/ProjectMetadata.d.ts +1 -0
  89. package/analyzer-template/packages/utils/dist/types/src/types/ProjectMetadata.d.ts.map +1 -1
  90. package/analyzer-template/packages/utils/dist/types/src/types/Scenario.d.ts +10 -0
  91. package/analyzer-template/packages/utils/dist/types/src/types/Scenario.d.ts.map +1 -1
  92. package/analyzer-template/playwright/captureFromUrl.ts +89 -82
  93. package/analyzer-template/project/constructMockCode.ts +136 -43
  94. package/analyzer-template/project/reconcileMockDataKeys.ts +19 -14
  95. package/analyzer-template/project/start.ts +3 -0
  96. package/analyzer-template/project/startScenarioCapture.ts +9 -0
  97. package/analyzer-template/project/writeClientLogRoute.ts +125 -0
  98. package/analyzer-template/project/writeMockDataTsx.ts +17 -0
  99. package/analyzer-template/project/writeScenarioComponents.ts +36 -7
  100. package/analyzer-template/tsconfig.json +13 -1
  101. package/background/src/lib/virtualized/project/constructMockCode.js +115 -34
  102. package/background/src/lib/virtualized/project/constructMockCode.js.map +1 -1
  103. package/background/src/lib/virtualized/project/reconcileMockDataKeys.js +17 -11
  104. package/background/src/lib/virtualized/project/reconcileMockDataKeys.js.map +1 -1
  105. package/background/src/lib/virtualized/project/start.js +2 -0
  106. package/background/src/lib/virtualized/project/start.js.map +1 -1
  107. package/background/src/lib/virtualized/project/startScenarioCapture.js +5 -0
  108. package/background/src/lib/virtualized/project/startScenarioCapture.js.map +1 -1
  109. package/background/src/lib/virtualized/project/writeClientLogRoute.js +110 -0
  110. package/background/src/lib/virtualized/project/writeClientLogRoute.js.map +1 -0
  111. package/background/src/lib/virtualized/project/writeMockDataTsx.js +12 -0
  112. package/background/src/lib/virtualized/project/writeMockDataTsx.js.map +1 -1
  113. package/background/src/lib/virtualized/project/writeScenarioComponents.js +29 -7
  114. package/background/src/lib/virtualized/project/writeScenarioComponents.js.map +1 -1
  115. package/codeyam-cli/scripts/apply-setup.js +208 -11
  116. package/codeyam-cli/scripts/apply-setup.js.map +1 -1
  117. package/codeyam-cli/src/__tests__/memory-scripts/filter-session.test.js +196 -0
  118. package/codeyam-cli/src/__tests__/memory-scripts/filter-session.test.js.map +1 -0
  119. package/codeyam-cli/src/__tests__/memory-scripts/read-json-field.test.js +114 -0
  120. package/codeyam-cli/src/__tests__/memory-scripts/read-json-field.test.js.map +1 -0
  121. package/codeyam-cli/src/__tests__/memory-scripts/ripgrep-fallback.test.js +149 -0
  122. package/codeyam-cli/src/__tests__/memory-scripts/ripgrep-fallback.test.js.map +1 -0
  123. package/codeyam-cli/src/cli.js +2 -0
  124. package/codeyam-cli/src/cli.js.map +1 -1
  125. package/codeyam-cli/src/commands/__tests__/editor.stepDispatch.test.js +45 -0
  126. package/codeyam-cli/src/commands/__tests__/editor.stepDispatch.test.js.map +1 -0
  127. package/codeyam-cli/src/commands/__tests__/init.gitignore.test.js +101 -47
  128. package/codeyam-cli/src/commands/__tests__/init.gitignore.test.js.map +1 -1
  129. package/codeyam-cli/src/commands/analyze.js +17 -7
  130. package/codeyam-cli/src/commands/analyze.js.map +1 -1
  131. package/codeyam-cli/src/commands/default.js +14 -2
  132. package/codeyam-cli/src/commands/default.js.map +1 -1
  133. package/codeyam-cli/src/commands/editor.js +3215 -0
  134. package/codeyam-cli/src/commands/editor.js.map +1 -0
  135. package/codeyam-cli/src/commands/init.js +107 -45
  136. package/codeyam-cli/src/commands/init.js.map +1 -1
  137. package/codeyam-cli/src/data/techStacks.js +77 -0
  138. package/codeyam-cli/src/data/techStacks.js.map +1 -0
  139. package/codeyam-cli/src/utils/__tests__/analyzerFinalization.test.js +144 -0
  140. package/codeyam-cli/src/utils/__tests__/analyzerFinalization.test.js.map +1 -0
  141. package/codeyam-cli/src/utils/__tests__/backgroundServer.test.js +46 -0
  142. package/codeyam-cli/src/utils/__tests__/backgroundServer.test.js.map +1 -0
  143. package/codeyam-cli/src/utils/__tests__/devServerState.test.js +134 -0
  144. package/codeyam-cli/src/utils/__tests__/devServerState.test.js.map +1 -0
  145. package/codeyam-cli/src/utils/__tests__/editorApi.test.js +127 -0
  146. package/codeyam-cli/src/utils/__tests__/editorApi.test.js.map +1 -0
  147. package/codeyam-cli/src/utils/__tests__/editorAudit.test.js +855 -0
  148. package/codeyam-cli/src/utils/__tests__/editorAudit.test.js.map +1 -0
  149. package/codeyam-cli/src/utils/__tests__/editorCapture.test.js +93 -0
  150. package/codeyam-cli/src/utils/__tests__/editorCapture.test.js.map +1 -0
  151. package/codeyam-cli/src/utils/__tests__/editorDevServer.test.js +304 -0
  152. package/codeyam-cli/src/utils/__tests__/editorDevServer.test.js.map +1 -0
  153. package/codeyam-cli/src/utils/__tests__/editorEntityChangeStatus.test.js +121 -0
  154. package/codeyam-cli/src/utils/__tests__/editorEntityChangeStatus.test.js.map +1 -0
  155. package/codeyam-cli/src/utils/__tests__/editorImageVerifier.test.js +294 -0
  156. package/codeyam-cli/src/utils/__tests__/editorImageVerifier.test.js.map +1 -0
  157. package/codeyam-cli/src/utils/__tests__/editorJournal.test.js +542 -0
  158. package/codeyam-cli/src/utils/__tests__/editorJournal.test.js.map +1 -0
  159. package/codeyam-cli/src/utils/__tests__/editorLoaderHelpers.test.js +520 -0
  160. package/codeyam-cli/src/utils/__tests__/editorLoaderHelpers.test.js.map +1 -0
  161. package/codeyam-cli/src/utils/__tests__/editorMockState.test.js +270 -0
  162. package/codeyam-cli/src/utils/__tests__/editorMockState.test.js.map +1 -0
  163. package/codeyam-cli/src/utils/__tests__/editorPreloadHelpers.test.js +217 -0
  164. package/codeyam-cli/src/utils/__tests__/editorPreloadHelpers.test.js.map +1 -0
  165. package/codeyam-cli/src/utils/__tests__/editorPreview.test.js +339 -0
  166. package/codeyam-cli/src/utils/__tests__/editorPreview.test.js.map +1 -0
  167. package/codeyam-cli/src/utils/__tests__/editorProxySession.test.js +153 -0
  168. package/codeyam-cli/src/utils/__tests__/editorProxySession.test.js.map +1 -0
  169. package/codeyam-cli/src/utils/__tests__/editorScenarioLookup.test.js +139 -0
  170. package/codeyam-cli/src/utils/__tests__/editorScenarioLookup.test.js.map +1 -0
  171. package/codeyam-cli/src/utils/__tests__/editorScenarioSwitch.test.js +221 -0
  172. package/codeyam-cli/src/utils/__tests__/editorScenarioSwitch.test.js.map +1 -0
  173. package/codeyam-cli/src/utils/__tests__/editorScenarios.test.js +855 -0
  174. package/codeyam-cli/src/utils/__tests__/editorScenarios.test.js.map +1 -0
  175. package/codeyam-cli/src/utils/__tests__/editorSeedAdapter.test.js +213 -0
  176. package/codeyam-cli/src/utils/__tests__/editorSeedAdapter.test.js.map +1 -0
  177. package/codeyam-cli/src/utils/__tests__/entityChangeStatus.test.js +1742 -0
  178. package/codeyam-cli/src/utils/__tests__/entityChangeStatus.test.js.map +1 -0
  179. package/codeyam-cli/src/utils/__tests__/git.editor.test.js +134 -0
  180. package/codeyam-cli/src/utils/__tests__/git.editor.test.js.map +1 -0
  181. package/codeyam-cli/src/utils/__tests__/journalCaptureStabilization.test.js +107 -0
  182. package/codeyam-cli/src/utils/__tests__/journalCaptureStabilization.test.js.map +1 -0
  183. package/codeyam-cli/src/utils/__tests__/parseRegisterArg.test.js +101 -0
  184. package/codeyam-cli/src/utils/__tests__/parseRegisterArg.test.js.map +1 -0
  185. package/codeyam-cli/src/utils/__tests__/pathIgnoring.test.js +9 -0
  186. package/codeyam-cli/src/utils/__tests__/pathIgnoring.test.js.map +1 -1
  187. package/codeyam-cli/src/utils/__tests__/project.test.js +65 -0
  188. package/codeyam-cli/src/utils/__tests__/project.test.js.map +1 -0
  189. package/codeyam-cli/src/utils/__tests__/scenarioCoverage.test.js +227 -0
  190. package/codeyam-cli/src/utils/__tests__/scenarioCoverage.test.js.map +1 -0
  191. package/codeyam-cli/src/utils/__tests__/scenarioMarkers.test.js +121 -0
  192. package/codeyam-cli/src/utils/__tests__/scenarioMarkers.test.js.map +1 -0
  193. package/codeyam-cli/src/utils/__tests__/scenariosManifest.test.js +300 -0
  194. package/codeyam-cli/src/utils/__tests__/scenariosManifest.test.js.map +1 -0
  195. package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js +50 -4
  196. package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js.map +1 -1
  197. package/codeyam-cli/src/utils/__tests__/templateConsistency.test.js +51 -0
  198. package/codeyam-cli/src/utils/__tests__/templateConsistency.test.js.map +1 -0
  199. package/codeyam-cli/src/utils/__tests__/webappDetection.test.js +142 -0
  200. package/codeyam-cli/src/utils/__tests__/webappDetection.test.js.map +1 -0
  201. package/codeyam-cli/src/utils/analyzer.js +9 -0
  202. package/codeyam-cli/src/utils/analyzer.js.map +1 -1
  203. package/codeyam-cli/src/utils/analyzerFinalization.js +96 -0
  204. package/codeyam-cli/src/utils/analyzerFinalization.js.map +1 -0
  205. package/codeyam-cli/src/utils/backgroundServer.js +104 -12
  206. package/codeyam-cli/src/utils/backgroundServer.js.map +1 -1
  207. package/codeyam-cli/src/utils/buildFlags.js +4 -0
  208. package/codeyam-cli/src/utils/buildFlags.js.map +1 -0
  209. package/codeyam-cli/src/utils/database.js +37 -2
  210. package/codeyam-cli/src/utils/database.js.map +1 -1
  211. package/codeyam-cli/src/utils/devModeEvents.js +40 -0
  212. package/codeyam-cli/src/utils/devModeEvents.js.map +1 -0
  213. package/codeyam-cli/src/utils/devServerState.js +71 -0
  214. package/codeyam-cli/src/utils/devServerState.js.map +1 -0
  215. package/codeyam-cli/src/utils/editorApi.js +73 -0
  216. package/codeyam-cli/src/utils/editorApi.js.map +1 -0
  217. package/codeyam-cli/src/utils/editorAudit.js +176 -0
  218. package/codeyam-cli/src/utils/editorAudit.js.map +1 -0
  219. package/codeyam-cli/src/utils/editorCapture.js +102 -0
  220. package/codeyam-cli/src/utils/editorCapture.js.map +1 -0
  221. package/codeyam-cli/src/utils/editorDevServer.js +197 -0
  222. package/codeyam-cli/src/utils/editorDevServer.js.map +1 -0
  223. package/codeyam-cli/src/utils/editorEntityChangeStatus.js +44 -0
  224. package/codeyam-cli/src/utils/editorEntityChangeStatus.js.map +1 -0
  225. package/codeyam-cli/src/utils/editorImageVerifier.js +155 -0
  226. package/codeyam-cli/src/utils/editorImageVerifier.js.map +1 -0
  227. package/codeyam-cli/src/utils/editorJournal.js +225 -0
  228. package/codeyam-cli/src/utils/editorJournal.js.map +1 -0
  229. package/codeyam-cli/src/utils/editorLoaderHelpers.js +113 -0
  230. package/codeyam-cli/src/utils/editorLoaderHelpers.js.map +1 -0
  231. package/codeyam-cli/src/utils/editorMockState.js +248 -0
  232. package/codeyam-cli/src/utils/editorMockState.js.map +1 -0
  233. package/codeyam-cli/src/utils/editorPreloadHelpers.js +135 -0
  234. package/codeyam-cli/src/utils/editorPreloadHelpers.js.map +1 -0
  235. package/codeyam-cli/src/utils/editorPreview.js +132 -0
  236. package/codeyam-cli/src/utils/editorPreview.js.map +1 -0
  237. package/codeyam-cli/src/utils/editorScenarioSwitch.js +112 -0
  238. package/codeyam-cli/src/utils/editorScenarioSwitch.js.map +1 -0
  239. package/codeyam-cli/src/utils/editorScenarios.js +332 -0
  240. package/codeyam-cli/src/utils/editorScenarios.js.map +1 -0
  241. package/codeyam-cli/src/utils/editorSeedAdapter.js +173 -0
  242. package/codeyam-cli/src/utils/editorSeedAdapter.js.map +1 -0
  243. package/codeyam-cli/src/utils/entityChangeStatus.js +349 -0
  244. package/codeyam-cli/src/utils/entityChangeStatus.js.map +1 -0
  245. package/codeyam-cli/src/utils/entityChangeStatus.server.js +158 -0
  246. package/codeyam-cli/src/utils/entityChangeStatus.server.js.map +1 -0
  247. package/codeyam-cli/src/utils/fileMetadata.js +5 -0
  248. package/codeyam-cli/src/utils/fileMetadata.js.map +1 -1
  249. package/codeyam-cli/src/utils/fileWatcher.js +25 -9
  250. package/codeyam-cli/src/utils/fileWatcher.js.map +1 -1
  251. package/codeyam-cli/src/utils/git.js +103 -0
  252. package/codeyam-cli/src/utils/git.js.map +1 -1
  253. package/codeyam-cli/src/utils/install-skills.js +55 -13
  254. package/codeyam-cli/src/utils/install-skills.js.map +1 -1
  255. package/codeyam-cli/src/utils/interactiveSyncWatcher.js +126 -0
  256. package/codeyam-cli/src/utils/interactiveSyncWatcher.js.map +1 -0
  257. package/codeyam-cli/src/utils/parseRegisterArg.js +31 -0
  258. package/codeyam-cli/src/utils/parseRegisterArg.js.map +1 -0
  259. package/codeyam-cli/src/utils/pathIgnoring.js +19 -7
  260. package/codeyam-cli/src/utils/pathIgnoring.js.map +1 -1
  261. package/codeyam-cli/src/utils/project.js +15 -5
  262. package/codeyam-cli/src/utils/project.js.map +1 -1
  263. package/codeyam-cli/src/utils/queue/__tests__/heartbeat.test.js +11 -11
  264. package/codeyam-cli/src/utils/queue/__tests__/heartbeat.test.js.map +1 -1
  265. package/codeyam-cli/src/utils/queue/__tests__/manager.test.js +22 -0
  266. package/codeyam-cli/src/utils/queue/__tests__/manager.test.js.map +1 -1
  267. package/codeyam-cli/src/utils/queue/heartbeat.js +13 -5
  268. package/codeyam-cli/src/utils/queue/heartbeat.js.map +1 -1
  269. package/codeyam-cli/src/utils/queue/job.js +70 -1
  270. package/codeyam-cli/src/utils/queue/job.js.map +1 -1
  271. package/codeyam-cli/src/utils/queue/manager.js +7 -6
  272. package/codeyam-cli/src/utils/queue/manager.js.map +1 -1
  273. package/codeyam-cli/src/utils/scenarioCoverage.js +75 -0
  274. package/codeyam-cli/src/utils/scenarioCoverage.js.map +1 -0
  275. package/codeyam-cli/src/utils/scenarioMarkers.js +134 -0
  276. package/codeyam-cli/src/utils/scenarioMarkers.js.map +1 -0
  277. package/codeyam-cli/src/utils/scenariosManifest.js +159 -0
  278. package/codeyam-cli/src/utils/scenariosManifest.js.map +1 -0
  279. package/codeyam-cli/src/utils/serverState.js +57 -2
  280. package/codeyam-cli/src/utils/serverState.js.map +1 -1
  281. package/codeyam-cli/src/utils/setupClaudeCodeSettings.js +82 -11
  282. package/codeyam-cli/src/utils/setupClaudeCodeSettings.js.map +1 -1
  283. package/codeyam-cli/src/utils/simulationGateMiddleware.js +8 -1
  284. package/codeyam-cli/src/utils/simulationGateMiddleware.js.map +1 -1
  285. package/codeyam-cli/src/utils/slugUtils.js +25 -0
  286. package/codeyam-cli/src/utils/slugUtils.js.map +1 -0
  287. package/codeyam-cli/src/utils/syncMocksMiddleware.js +2 -2
  288. package/codeyam-cli/src/utils/syncMocksMiddleware.js.map +1 -1
  289. package/codeyam-cli/src/utils/testRunner.js +158 -0
  290. package/codeyam-cli/src/utils/testRunner.js.map +1 -0
  291. package/codeyam-cli/src/utils/webappDetection.js +35 -2
  292. package/codeyam-cli/src/utils/webappDetection.js.map +1 -1
  293. package/codeyam-cli/src/webserver/__tests__/clientErrors.test.js +40 -0
  294. package/codeyam-cli/src/webserver/__tests__/clientErrors.test.js.map +1 -0
  295. package/codeyam-cli/src/webserver/__tests__/editorProxy.test.js +567 -0
  296. package/codeyam-cli/src/webserver/__tests__/editorProxy.test.js.map +1 -0
  297. package/codeyam-cli/src/webserver/app/lib/clientErrors.js +65 -0
  298. package/codeyam-cli/src/webserver/app/lib/clientErrors.js.map +1 -0
  299. package/codeyam-cli/src/webserver/app/lib/database.js +41 -27
  300. package/codeyam-cli/src/webserver/app/lib/database.js.map +1 -1
  301. package/codeyam-cli/src/webserver/app/lib/dbNotifier.js.map +1 -1
  302. package/codeyam-cli/src/webserver/app/lib/git.js +397 -0
  303. package/codeyam-cli/src/webserver/app/lib/git.js.map +1 -0
  304. package/codeyam-cli/src/webserver/backgroundServer.js +108 -18
  305. package/codeyam-cli/src/webserver/backgroundServer.js.map +1 -1
  306. package/codeyam-cli/src/webserver/build/client/assets/{CopyButton-CtmbP4Gl.js → CopyButton-BPXZwM4t.js} +1 -1
  307. package/codeyam-cli/src/webserver/build/client/assets/{EntityItem-DlMph_Hm.js → EntityItem-BcgbViKV.js} +3 -3
  308. package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeBadge-B-0PjGOU.js → EntityTypeBadge-g3saevPb.js} +1 -1
  309. package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeIcon-DN9eiJAO.js → EntityTypeIcon-CQIG2qda.js} +9 -9
  310. package/codeyam-cli/src/webserver/build/client/assets/InlineSpinner-Bu6c6aDe.js +1 -0
  311. package/codeyam-cli/src/webserver/build/client/assets/{InteractivePreview-rE_fI2h2.js → InteractivePreview-DYFW3lDD.js} +3 -3
  312. package/codeyam-cli/src/webserver/build/client/assets/{LibraryFunctionPreview-CnatsCw2.js → LibraryFunctionPreview-DLeucoVX.js} +1 -1
  313. package/codeyam-cli/src/webserver/build/client/assets/{LoadingDots-CSP6DZrh.js → LoadingDots-BU_OAEMP.js} +1 -1
  314. package/codeyam-cli/src/webserver/build/client/assets/{LogViewer-CMK8Q7yk.js → LogViewer-ceAyBX-H.js} +1 -1
  315. package/codeyam-cli/src/webserver/build/client/assets/{ReportIssueModal-TCV_HBjy.js → ReportIssueModal-BzHcG7SE.js} +3 -3
  316. package/codeyam-cli/src/webserver/build/client/assets/{SafeScreenshot-CG2uh31y.js → SafeScreenshot-BED4B6sP.js} +1 -1
  317. package/codeyam-cli/src/webserver/build/client/assets/{ScenarioViewer-CU_TDYd8.js → ScenarioViewer-Bd-hxofb.js} +3 -3
  318. package/codeyam-cli/src/webserver/build/client/assets/Spinner-Bb5uFQ5V.js +34 -0
  319. package/codeyam-cli/src/webserver/build/client/assets/{TruncatedFilePath-D7IoaWUW.js → TruncatedFilePath-C8OKAR5x.js} +1 -1
  320. package/codeyam-cli/src/webserver/build/client/assets/ViewportInspectBar-oAf2Kqsf.js +1 -0
  321. package/codeyam-cli/src/webserver/build/client/assets/{_index-B8z7mjR-.js → _index-DLxKhri3.js} +3 -3
  322. package/codeyam-cli/src/webserver/build/client/assets/{activity.(_tab)-DZu78RI1.js → activity.(_tab)-BcY3q6nt.js} +6 -6
  323. package/codeyam-cli/src/webserver/build/client/assets/addon-canvas-DpzMmAy5.js +1 -0
  324. package/codeyam-cli/src/webserver/build/client/assets/addon-fit-YJmn1quW.js +12 -0
  325. package/codeyam-cli/src/webserver/build/client/assets/addon-web-links-Duc5hnl7.js +1 -0
  326. package/codeyam-cli/src/webserver/build/client/assets/addon-webgl-DI8QOUvO.js +58 -0
  327. package/codeyam-cli/src/webserver/build/client/assets/{agent-transcripts-Dm5RS9il.js → agent-transcripts-Bni3iiUj.js} +5 -5
  328. package/codeyam-cli/src/webserver/build/client/assets/api.dev-mode-events-l0sNRNKZ.js +1 -0
  329. package/codeyam-cli/src/webserver/build/client/assets/api.editor-audit-l0sNRNKZ.js +1 -0
  330. package/codeyam-cli/src/webserver/build/client/assets/api.editor-capture-scenario-l0sNRNKZ.js +1 -0
  331. package/codeyam-cli/src/webserver/build/client/assets/api.editor-client-errors-l0sNRNKZ.js +1 -0
  332. package/codeyam-cli/src/webserver/build/client/assets/api.editor-commit-l0sNRNKZ.js +1 -0
  333. package/codeyam-cli/src/webserver/build/client/assets/api.editor-dev-server-l0sNRNKZ.js +1 -0
  334. package/codeyam-cli/src/webserver/build/client/assets/api.editor-entity-status-l0sNRNKZ.js +1 -0
  335. package/codeyam-cli/src/webserver/build/client/assets/api.editor-file-diff-l0sNRNKZ.js +1 -0
  336. package/codeyam-cli/src/webserver/build/client/assets/api.editor-file-l0sNRNKZ.js +1 -0
  337. package/codeyam-cli/src/webserver/build/client/assets/api.editor-journal-entry-l0sNRNKZ.js +1 -0
  338. package/codeyam-cli/src/webserver/build/client/assets/api.editor-journal-image._-l0sNRNKZ.js +1 -0
  339. package/codeyam-cli/src/webserver/build/client/assets/api.editor-journal-l0sNRNKZ.js +1 -0
  340. package/codeyam-cli/src/webserver/build/client/assets/api.editor-journal-screenshot-l0sNRNKZ.js +1 -0
  341. package/codeyam-cli/src/webserver/build/client/assets/api.editor-journal-update-l0sNRNKZ.js +1 -0
  342. package/codeyam-cli/src/webserver/build/client/assets/api.editor-load-commit-l0sNRNKZ.js +1 -0
  343. package/codeyam-cli/src/webserver/build/client/assets/api.editor-project-info-l0sNRNKZ.js +1 -0
  344. package/codeyam-cli/src/webserver/build/client/assets/api.editor-refresh-l0sNRNKZ.js +1 -0
  345. package/codeyam-cli/src/webserver/build/client/assets/api.editor-register-scenario-l0sNRNKZ.js +1 -0
  346. package/codeyam-cli/src/webserver/build/client/assets/api.editor-scenario-coverage-l0sNRNKZ.js +1 -0
  347. package/codeyam-cli/src/webserver/build/client/assets/api.editor-scenario-data-l0sNRNKZ.js +1 -0
  348. package/codeyam-cli/src/webserver/build/client/assets/api.editor-scenario-image._-l0sNRNKZ.js +1 -0
  349. package/codeyam-cli/src/webserver/build/client/assets/api.editor-scenarios-l0sNRNKZ.js +1 -0
  350. package/codeyam-cli/src/webserver/build/client/assets/api.editor-switch-scenario-l0sNRNKZ.js +1 -0
  351. package/codeyam-cli/src/webserver/build/client/assets/api.editor-test-results-l0sNRNKZ.js +1 -0
  352. package/codeyam-cli/src/webserver/build/client/assets/{book-open-Bp5FLkd4.js → book-open-BYOypzCa.js} +2 -2
  353. package/codeyam-cli/src/webserver/build/client/assets/{chevron-down-DQJA9f4o.js → chevron-down-C_Pmso5S.js} +2 -2
  354. package/codeyam-cli/src/webserver/build/client/assets/{chunk-JZWAC4HX-7VptmeIr.js → chunk-JZWAC4HX-C4pqxYJB.js} +1 -1
  355. package/codeyam-cli/src/webserver/build/client/assets/{circle-check-B6C4LY9o.js → circle-check-BVMi9VA5.js} +2 -2
  356. package/codeyam-cli/src/webserver/build/client/assets/{copy-6nzYCu0G.js → copy-n2FB0_Sw.js} +3 -3
  357. package/codeyam-cli/src/webserver/build/client/assets/createLucideIcon-CC6AbExI.js +41 -0
  358. package/codeyam-cli/src/webserver/build/client/assets/dev.empty-BsDh6TSF.js +1 -0
  359. package/codeyam-cli/src/webserver/build/client/assets/editor-PBc_6L9R.js +10 -0
  360. package/codeyam-cli/src/webserver/build/client/assets/editorPreview-4FzHlcNn.js +41 -0
  361. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha._-C6PQhwY5.js → entity._sha._-BsDXNp45.js} +9 -9
  362. package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.dev-BgAqUtTZ.js +6 -0
  363. package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.fullscreen-Bmshgrij.js +6 -0
  364. package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-p9hhkjJM.js +6 -0
  365. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha_.edit._scenarioId-C7ysA4Jq.js → entity._sha_.edit._scenarioId-BMvVHNXU.js} +2 -2
  366. package/codeyam-cli/src/webserver/build/client/assets/{entry.client-CU6EUArK.js → entry.client-DTvKq3TY.js} +1 -1
  367. package/codeyam-cli/src/webserver/build/client/assets/{fileTableUtils-EWpfFU4X.js → fileTableUtils-cPo8LiG3.js} +1 -1
  368. package/codeyam-cli/src/webserver/build/client/assets/{files-CrxAoWIL.js → files-BZrlFE1F.js} +1 -1
  369. package/codeyam-cli/src/webserver/build/client/assets/git-DdZcvjGh.js +1 -0
  370. package/codeyam-cli/src/webserver/build/client/assets/globals-B8vTTNy2.css +1 -0
  371. package/codeyam-cli/src/webserver/build/client/assets/{index-7-1FmlHo.js → index-10oVnAAH.js} +1 -1
  372. package/codeyam-cli/src/webserver/build/client/assets/{index-DuYcwYp_.js → index-BcvgDzbZ.js} +1 -1
  373. package/codeyam-cli/src/webserver/build/client/assets/index-yHOVb4rc.js +15 -0
  374. package/codeyam-cli/src/webserver/build/client/assets/{labs-CPPVOSWB.js → labs-Zk7ryIM1.js} +1 -1
  375. package/codeyam-cli/src/webserver/build/client/assets/{loader-circle-BnDcD54R.js → loader-circle-DaAZ_H2w.js} +2 -2
  376. package/codeyam-cli/src/webserver/build/client/assets/manifest-65850841.js +1 -0
  377. package/codeyam-cli/src/webserver/build/client/assets/memory-9gnxSZlb.js +101 -0
  378. package/codeyam-cli/src/webserver/build/client/assets/{pause-DhQX2g22.js → pause-f5-1lKBt.js} +3 -3
  379. package/codeyam-cli/src/webserver/build/client/assets/root-BwX8YgFb.js +67 -0
  380. package/codeyam-cli/src/webserver/build/client/assets/{search-DborVoKD.js → search-Di64LWVb.js} +2 -2
  381. package/codeyam-cli/src/webserver/build/client/assets/{settings-BWunYSXt.js → settings-0OrEMU6J.js} +1 -1
  382. package/codeyam-cli/src/webserver/build/client/assets/{simulations-BtrtCYJg.js → simulations-DWT-CvLy.js} +1 -1
  383. package/codeyam-cli/src/webserver/build/client/assets/{terminal-Bs4NC-VZ.js → terminal-Br7MOqts.js} +3 -3
  384. package/codeyam-cli/src/webserver/build/client/assets/{triangle-alert-DTf3Jojp.js → triangle-alert-BLdiCuG-.js} +2 -2
  385. package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-BE43Hjti.js +1 -0
  386. package/codeyam-cli/src/webserver/build/client/assets/useLastLogLine-C14nCb1q.js +2 -0
  387. package/codeyam-cli/src/webserver/build/client/assets/{useReportContext-BsQb6rFd.js → useReportContext-O-jkvSPx.js} +1 -1
  388. package/codeyam-cli/src/webserver/build/client/assets/{useToast-BOur3mUv.js → useToast-9FIWuYfK.js} +1 -1
  389. package/codeyam-cli/src/webserver/build/client/assets/xterm-BqvuqXEL.js +27 -0
  390. package/codeyam-cli/src/webserver/build/server/assets/index-DEEQf4pi.js +1 -0
  391. package/codeyam-cli/src/webserver/build/server/assets/init-CkWmyFY2.js +10 -0
  392. package/codeyam-cli/src/webserver/build/server/assets/server-build-BHi-9O8W.js +439 -0
  393. package/codeyam-cli/src/webserver/build/server/index.js +1 -1
  394. package/codeyam-cli/src/webserver/build-info.json +5 -5
  395. package/codeyam-cli/src/webserver/devServer.js +39 -5
  396. package/codeyam-cli/src/webserver/devServer.js.map +1 -1
  397. package/codeyam-cli/src/webserver/editorProxy.js +877 -0
  398. package/codeyam-cli/src/webserver/editorProxy.js.map +1 -0
  399. package/codeyam-cli/src/webserver/scripts/codeyam-preload.mjs +414 -0
  400. package/codeyam-cli/src/webserver/scripts/journalCapture.ts +230 -0
  401. package/codeyam-cli/src/webserver/server.js +258 -1
  402. package/codeyam-cli/src/webserver/server.js.map +1 -1
  403. package/codeyam-cli/src/webserver/terminalServer.js +726 -0
  404. package/codeyam-cli/src/webserver/terminalServer.js.map +1 -0
  405. package/codeyam-cli/templates/chrome-extension-react/EXTENSION_SETUP.md +75 -0
  406. package/codeyam-cli/templates/chrome-extension-react/README.md +46 -0
  407. package/codeyam-cli/templates/chrome-extension-react/gitignore +15 -0
  408. package/codeyam-cli/templates/chrome-extension-react/index.html +12 -0
  409. package/codeyam-cli/templates/chrome-extension-react/package.json +27 -0
  410. package/codeyam-cli/templates/chrome-extension-react/popup.html +12 -0
  411. package/codeyam-cli/templates/chrome-extension-react/public/manifest.json +15 -0
  412. package/codeyam-cli/templates/chrome-extension-react/src/background/service-worker.ts +7 -0
  413. package/codeyam-cli/templates/chrome-extension-react/src/globals.css +6 -0
  414. package/codeyam-cli/templates/chrome-extension-react/src/lib/storage.ts +37 -0
  415. package/codeyam-cli/templates/chrome-extension-react/src/popup/App.tsx +12 -0
  416. package/codeyam-cli/templates/chrome-extension-react/src/popup/main.tsx +10 -0
  417. package/codeyam-cli/templates/chrome-extension-react/tsconfig.json +24 -0
  418. package/codeyam-cli/templates/chrome-extension-react/vite.config.ts +41 -0
  419. package/codeyam-cli/templates/codeyam-editor-claude.md +147 -0
  420. package/codeyam-cli/templates/editor-step-hook.py +236 -0
  421. package/codeyam-cli/templates/expo-react-native/MOBILE_SETUP.md +89 -0
  422. package/codeyam-cli/templates/expo-react-native/README.md +41 -0
  423. package/codeyam-cli/templates/expo-react-native/app/(tabs)/_layout.tsx +33 -0
  424. package/codeyam-cli/templates/expo-react-native/app/(tabs)/index.tsx +12 -0
  425. package/codeyam-cli/templates/expo-react-native/app/(tabs)/settings.tsx +12 -0
  426. package/codeyam-cli/templates/expo-react-native/app/_layout.tsx +12 -0
  427. package/codeyam-cli/templates/expo-react-native/app.json +18 -0
  428. package/codeyam-cli/templates/expo-react-native/babel.config.js +9 -0
  429. package/codeyam-cli/templates/expo-react-native/gitignore +12 -0
  430. package/codeyam-cli/templates/expo-react-native/global.css +3 -0
  431. package/codeyam-cli/templates/expo-react-native/lib/storage.ts +32 -0
  432. package/codeyam-cli/templates/expo-react-native/metro.config.js +6 -0
  433. package/codeyam-cli/templates/expo-react-native/nativewind-env.d.ts +1 -0
  434. package/codeyam-cli/templates/expo-react-native/package.json +38 -0
  435. package/codeyam-cli/templates/expo-react-native/tailwind.config.js +10 -0
  436. package/codeyam-cli/templates/expo-react-native/tsconfig.json +10 -0
  437. package/codeyam-cli/templates/isolation-route/next-app.tsx.template +80 -0
  438. package/codeyam-cli/templates/isolation-route/next-pages.tsx.template +79 -0
  439. package/codeyam-cli/templates/isolation-route/vite-react.tsx.template +78 -0
  440. package/codeyam-cli/templates/msw/browser-setup.ts.template +47 -0
  441. package/codeyam-cli/templates/msw/handler-router.ts.template +47 -0
  442. package/codeyam-cli/templates/msw/server-setup.ts.template +52 -0
  443. package/codeyam-cli/templates/nextjs-prisma-sqlite/AUTH_PATTERNS.md +308 -0
  444. package/codeyam-cli/templates/nextjs-prisma-sqlite/AUTH_UPGRADE.md +304 -0
  445. package/codeyam-cli/templates/nextjs-prisma-sqlite/DATABASE.md +126 -0
  446. package/codeyam-cli/templates/nextjs-prisma-sqlite/FEATURE_PATTERNS.md +37 -0
  447. package/codeyam-cli/templates/nextjs-prisma-sqlite/README.md +53 -0
  448. package/codeyam-cli/templates/nextjs-prisma-sqlite/app/api/todos/route.ts +17 -0
  449. package/codeyam-cli/templates/nextjs-prisma-sqlite/app/codeyam-isolate/layout.tsx +12 -0
  450. package/codeyam-cli/templates/nextjs-prisma-sqlite/app/globals.css +26 -0
  451. package/codeyam-cli/templates/nextjs-prisma-sqlite/app/layout.tsx +34 -0
  452. package/codeyam-cli/templates/nextjs-prisma-sqlite/app/lib/prisma.ts +24 -0
  453. package/codeyam-cli/templates/nextjs-prisma-sqlite/app/page.tsx +10 -0
  454. package/codeyam-cli/templates/nextjs-prisma-sqlite/env +4 -0
  455. package/codeyam-cli/templates/nextjs-prisma-sqlite/eslint.config.mjs +11 -0
  456. package/codeyam-cli/templates/nextjs-prisma-sqlite/gitignore +64 -0
  457. package/codeyam-cli/templates/nextjs-prisma-sqlite/next.config.ts +14 -0
  458. package/codeyam-cli/templates/nextjs-prisma-sqlite/package.json +39 -0
  459. package/codeyam-cli/templates/nextjs-prisma-sqlite/postcss.config.mjs +7 -0
  460. package/codeyam-cli/templates/nextjs-prisma-sqlite/prisma/schema.prisma +27 -0
  461. package/codeyam-cli/templates/nextjs-prisma-sqlite/prisma/seed.ts +40 -0
  462. package/codeyam-cli/templates/nextjs-prisma-sqlite/prisma.config.ts +12 -0
  463. package/codeyam-cli/templates/nextjs-prisma-sqlite/seed-adapter.ts +92 -0
  464. package/codeyam-cli/templates/nextjs-prisma-sqlite/tsconfig.json +34 -0
  465. package/codeyam-cli/templates/nextjs-prisma-sqlite/vitest.config.ts +13 -0
  466. package/codeyam-cli/templates/nextjs-prisma-supabase/README.md +52 -0
  467. package/codeyam-cli/templates/nextjs-prisma-supabase/SUPABASE_SETUP.md +104 -0
  468. package/codeyam-cli/templates/nextjs-prisma-supabase/app/api/todos/route.ts +17 -0
  469. package/codeyam-cli/templates/nextjs-prisma-supabase/app/globals.css +26 -0
  470. package/codeyam-cli/templates/nextjs-prisma-supabase/app/layout.tsx +34 -0
  471. package/codeyam-cli/templates/nextjs-prisma-supabase/app/lib/prisma.ts +20 -0
  472. package/codeyam-cli/templates/nextjs-prisma-supabase/app/lib/supabase.ts +12 -0
  473. package/codeyam-cli/templates/nextjs-prisma-supabase/app/page.tsx +10 -0
  474. package/codeyam-cli/templates/nextjs-prisma-supabase/env +9 -0
  475. package/codeyam-cli/templates/nextjs-prisma-supabase/eslint.config.mjs +11 -0
  476. package/codeyam-cli/templates/nextjs-prisma-supabase/gitignore +40 -0
  477. package/codeyam-cli/templates/nextjs-prisma-supabase/next.config.ts +11 -0
  478. package/codeyam-cli/templates/nextjs-prisma-supabase/package.json +37 -0
  479. package/codeyam-cli/templates/nextjs-prisma-supabase/postcss.config.mjs +7 -0
  480. package/codeyam-cli/templates/nextjs-prisma-supabase/prisma/schema.prisma +27 -0
  481. package/codeyam-cli/templates/nextjs-prisma-supabase/prisma/seed.ts +39 -0
  482. package/codeyam-cli/templates/nextjs-prisma-supabase/prisma.config.ts +12 -0
  483. package/codeyam-cli/templates/nextjs-prisma-supabase/tsconfig.json +34 -0
  484. package/codeyam-cli/templates/skills/codeyam-dev-mode/SKILL.md +237 -0
  485. package/codeyam-cli/templates/skills/codeyam-editor/SKILL.md +148 -0
  486. package/codeyam-cli/templates/{codeyam-memory.md → skills/codeyam-memory/SKILL.md} +215 -0
  487. package/codeyam-cli/templates/skills/codeyam-memory/scripts/holistic-analysis/deprecated-prompt.md +100 -0
  488. package/codeyam-cli/templates/skills/codeyam-memory/scripts/holistic-analysis/detect-deprecated-patterns.mjs +139 -0
  489. package/codeyam-cli/templates/skills/codeyam-memory/scripts/holistic-analysis/find-exports.mjs +52 -0
  490. package/codeyam-cli/templates/skills/codeyam-memory/scripts/holistic-analysis/misleading-api-prompt.md +117 -0
  491. package/codeyam-cli/templates/skills/codeyam-memory/scripts/lib/read-json-field.mjs +61 -0
  492. package/codeyam-cli/templates/skills/codeyam-memory/scripts/lib/ripgrep-fallback.mjs +155 -0
  493. package/codeyam-cli/templates/skills/codeyam-memory/scripts/session-mining/analyze-prompt.md +46 -0
  494. package/codeyam-cli/templates/skills/codeyam-memory/scripts/session-mining/cleanup.mjs +13 -0
  495. package/codeyam-cli/templates/skills/codeyam-memory/scripts/session-mining/filter-session.mjs +95 -0
  496. package/codeyam-cli/templates/skills/codeyam-memory/scripts/session-mining/preprocess.mjs +160 -0
  497. package/package.json +17 -10
  498. package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js +22 -4
  499. package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js.map +1 -1
  500. package/packages/ai/src/lib/completionCall.js +10 -2
  501. package/packages/ai/src/lib/completionCall.js.map +1 -1
  502. package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js +21 -0
  503. package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js.map +1 -1
  504. package/packages/ai/src/lib/dataStructure/helpers/coercePrimitivesToArraysBySchema.js +54 -0
  505. package/packages/ai/src/lib/dataStructure/helpers/coercePrimitivesToArraysBySchema.js.map +1 -0
  506. package/packages/ai/src/lib/dataStructure/helpers/stripNullableMarkers.js +34 -0
  507. package/packages/ai/src/lib/dataStructure/helpers/stripNullableMarkers.js.map +1 -0
  508. package/packages/ai/src/lib/generateEntityScenarioData.js +57 -2
  509. package/packages/ai/src/lib/generateEntityScenarioData.js.map +1 -1
  510. package/packages/ai/src/lib/generateExecutionFlows.js +0 -11
  511. package/packages/ai/src/lib/generateExecutionFlows.js.map +1 -1
  512. package/packages/analyze/src/lib/ProjectAnalyzer.js +13 -4
  513. package/packages/analyze/src/lib/ProjectAnalyzer.js.map +1 -1
  514. package/packages/analyze/src/lib/asts/index.js +4 -2
  515. package/packages/analyze/src/lib/asts/index.js.map +1 -1
  516. package/packages/analyze/src/lib/files/analyze/analyzeEntities.js +8 -1
  517. package/packages/analyze/src/lib/files/analyze/analyzeEntities.js.map +1 -1
  518. package/packages/analyze/src/lib/files/analyze/dependencyResolver.js +0 -5
  519. package/packages/analyze/src/lib/files/analyze/dependencyResolver.js.map +1 -1
  520. package/packages/analyze/src/lib/files/analyze/findOrCreateEntity.js +9 -0
  521. package/packages/analyze/src/lib/files/analyze/findOrCreateEntity.js.map +1 -1
  522. package/packages/analyze/src/lib/files/scenarios/TransformationTracer.js +54 -27
  523. package/packages/analyze/src/lib/files/scenarios/TransformationTracer.js.map +1 -1
  524. package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js +65 -0
  525. package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js.map +1 -1
  526. package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js +0 -40
  527. package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js.map +1 -1
  528. package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js +18 -4
  529. package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js.map +1 -1
  530. package/packages/database/index.js +1 -0
  531. package/packages/database/index.js.map +1 -1
  532. package/packages/database/src/lib/kysely/db.js +5 -0
  533. package/packages/database/src/lib/kysely/db.js.map +1 -1
  534. package/packages/database/src/lib/kysely/tables/editorScenariosTable.js +76 -0
  535. package/packages/database/src/lib/kysely/tables/editorScenariosTable.js.map +1 -0
  536. package/packages/database/src/lib/loadCommits.js +23 -13
  537. package/packages/database/src/lib/loadCommits.js.map +1 -1
  538. package/packages/database/src/lib/loadEntities.js +0 -6
  539. package/packages/database/src/lib/loadEntities.js.map +1 -1
  540. package/packages/database/src/lib/loadReadyToBeCapturedAnalyses.js +1 -4
  541. package/packages/database/src/lib/loadReadyToBeCapturedAnalyses.js.map +1 -1
  542. package/packages/database/src/lib/updateCommitMetadata.js +76 -90
  543. package/packages/database/src/lib/updateCommitMetadata.js.map +1 -1
  544. package/packages/database/src/lib/updateFreshAnalysisStatus.js +41 -30
  545. package/packages/database/src/lib/updateFreshAnalysisStatus.js.map +1 -1
  546. package/packages/database/src/lib/updateFreshAnalysisStatusWithScenarios.js +68 -57
  547. package/packages/database/src/lib/updateFreshAnalysisStatusWithScenarios.js.map +1 -1
  548. package/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js +29 -1
  549. package/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js.map +1 -1
  550. package/packages/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js +33 -5
  551. package/packages/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js.map +1 -1
  552. package/packages/types/src/enums/ProjectFramework.js +2 -0
  553. package/packages/types/src/enums/ProjectFramework.js.map +1 -1
  554. package/scripts/npm-post-install.cjs +34 -0
  555. package/codeyam-cli/src/webserver/build/client/assets/InlineSpinner-C1rIyZdV.js +0 -34
  556. package/codeyam-cli/src/webserver/build/client/assets/createLucideIcon-D-QUFOwe.js +0 -21
  557. package/codeyam-cli/src/webserver/build/client/assets/dev.empty-DmzSmblj.js +0 -1
  558. package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.fullscreen-DVTcUnur.js +0 -6
  559. package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-BVgNO76F.js +0 -6
  560. package/codeyam-cli/src/webserver/build/client/assets/git-BldHtKeW.js +0 -15
  561. package/codeyam-cli/src/webserver/build/client/assets/globals-CLmFdUae.css +0 -1
  562. package/codeyam-cli/src/webserver/build/client/assets/manifest-717e346a.js +0 -1
  563. package/codeyam-cli/src/webserver/build/client/assets/memory-0wMU4KXe.js +0 -93
  564. package/codeyam-cli/src/webserver/build/client/assets/root-DqfSDjyQ.js +0 -62
  565. package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-D_bDZyDU.js +0 -1
  566. package/codeyam-cli/src/webserver/build/client/assets/useLastLogLine-DZp6rrQD.js +0 -2
  567. package/codeyam-cli/src/webserver/build/server/assets/index-B8jmgmn2.js +0 -1
  568. package/codeyam-cli/src/webserver/build/server/assets/server-build-9OU4lmvL.js +0 -285
  569. package/scripts/finalize-analyzer.cjs +0 -13
  570. /package/codeyam-cli/templates/{codeyam-diagnose.md → commands/codeyam-diagnose.md} +0 -0
  571. /package/codeyam-cli/templates/{codeyam-debug.md → skills/codeyam-debug/SKILL.md} +0 -0
  572. /package/codeyam-cli/templates/{codeyam-new-rule.md → skills/codeyam-new-rule/SKILL.md} +0 -0
  573. /package/codeyam-cli/templates/{codeyam-setup.md → skills/codeyam-setup/SKILL.md} +0 -0
  574. /package/codeyam-cli/templates/{codeyam-sim.md → skills/codeyam-sim/SKILL.md} +0 -0
  575. /package/codeyam-cli/templates/{codeyam-test.md → skills/codeyam-test/SKILL.md} +0 -0
  576. /package/codeyam-cli/templates/{codeyam-verify.md → skills/codeyam-verify/SKILL.md} +0 -0
@@ -0,0 +1,6 @@
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-BE43Hjti.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-4FzHlcNn.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};
@@ -0,0 +1,6 @@
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-BE43Hjti.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};
@@ -0,0 +1,6 @@
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,5 +1,5 @@
1
- import{j as e,r as l,w as Y,u as K,a as Q,L as z}from"./chunk-JZWAC4HX-7VptmeIr.js";import{W as X,u as Z,I as ee}from"./InteractivePreview-rE_fI2h2.js";import{u as te}from"./InlineSpinner-C1rIyZdV.js";import"./preload-helper-ckwbz45p.js";import"./useLastLogLine-DZp6rrQD.js";function U(t,n,r){if(Array.isArray(t)){if(!isNaN(parseInt(n)))return t[parseInt(n)];for(const s of t)if(s.name===n||s.title===n||s.id===n)return s}return t[n]}function q(t){return t&&(typeof t=="object"||Array.isArray(t))}function re(t){return Array.isArray(t)?t.length:void 0}function ne(t){const{data:n,structure:r}=t;if(!(!n&&!r)){if(Array.isArray(r))return Array.isArray(n)?n.map((s,d)=>d.toString()):[];if(typeof r=="object")return[...new Set([...Object.keys(n),...Object.keys(r)])].sort((d,o)=>{const p=q(n[d]),c=q(n[o]);return p&&!c?1:!p&&c?-1:d.localeCompare(o)});if(typeof n=="object")return Object.keys(n).sort((d,o)=>d.localeCompare(o))}}function se({scenarioFormData:t,handleInputChange:n}){return e.jsxs("div",{className:"p-3 flex flex-col gap-3",children:[e.jsxs("div",{className:"grid w-full max-w-sm items-center gap-1.5",children:[e.jsx("label",{htmlFor:"name",className:"text-sm font-medium text-gray-700",children:"Name"}),e.jsx("input",{type:"text",id:"name",placeholder:"Name",name:"name",value:t.name,onChange:n,required:!0,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),e.jsxs("div",{className:"grid w-full gap-1.5 pt-2",children:[e.jsx("label",{htmlFor:"description",className:"text-sm font-medium text-gray-700",children:"Description"}),e.jsx("textarea",{placeholder:"Type your message here.",id:"description",name:"description",value:t.description,onChange:n,required:!0,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 min-h-[100px]"})]}),e.jsx("button",{type:"submit",className:"mt-3 w-full px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 font-medium",children:"Save Name & Description"})]})}function ae({path:t,namedPath:n,isArray:r,count:s,onClick:d}){const o=l.useCallback(()=>{d&&d(t)},[d,t]);return e.jsxs("div",{className:"bg-blue-50 p-3 rounded-lg flex items-center justify-between cursor-pointer group hover:bg-blue-100 transition-colors border border-blue-200",onClick:o,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[r&&e.jsx("svg",{className:"w-4 h-4 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})}),e.jsxs("div",{className:"capitalize font-medium text-gray-900",children:[n[n.length-1],s!==void 0&&` (${s})`]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[r&&e.jsx("svg",{className:"w-5 h-5 text-red-500 opacity-0 group-hover:opacity-100 transition-opacity",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})}),e.jsx("svg",{className:"w-4 h-4 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})]})]})}var V=(t=>(t.STRING="string",t.NUMBER="number",t.BOOLEAN="boolean",t.UNION="union",t.OBJECT="object",t.ARRAY="array",t))(V||{});const oe=({name:t,value:n,options:r,onChange:s})=>{const d=l.useCallback(o=>{s({target:{name:t,value:o.target.value}})},[t,s]);return e.jsx("select",{name:t,value:n,onChange:d,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",children:r.map((o,p)=>e.jsx("option",{value:o.trim(),children:o.trim()},p))})},ie=({name:t,value:n,onChange:r})=>{const s=l.useCallback(d=>{const o=d.target.checked;r({target:{name:t,value:o}})},[t,r]);return e.jsx("label",{className:"flex items-center gap-2 cursor-pointer",children:e.jsx("input",{type:"checkbox",name:t,checked:n,onChange:s,className:`w-10 h-6 rounded-full appearance-none cursor-pointer transition-colors relative
1
+ import{j as e,r as l,w as Y,u as K,a as Q,L as z}from"./chunk-JZWAC4HX-C4pqxYJB.js";import{W as X,u as Z,I as ee}from"./InteractivePreview-DYFW3lDD.js";import{u as te}from"./Spinner-Bb5uFQ5V.js";import"./preload-helper-ckwbz45p.js";import"./useLastLogLine-C14nCb1q.js";import"./InlineSpinner-Bu6c6aDe.js";function U(t,n,r){if(Array.isArray(t)){if(!isNaN(parseInt(n)))return t[parseInt(n)];for(const s of t)if(s.name===n||s.title===n||s.id===n)return s}return t[n]}function q(t){return t&&(typeof t=="object"||Array.isArray(t))}function re(t){return Array.isArray(t)?t.length:void 0}function ne(t){const{data:n,structure:r}=t;if(!(!n&&!r)){if(Array.isArray(r))return Array.isArray(n)?n.map((s,d)=>d.toString()):[];if(typeof r=="object")return[...new Set([...Object.keys(n),...Object.keys(r)])].sort((d,o)=>{const p=q(n[d]),c=q(n[o]);return p&&!c?1:!p&&c?-1:d.localeCompare(o)});if(typeof n=="object")return Object.keys(n).sort((d,o)=>d.localeCompare(o))}}function se({scenarioFormData:t,handleInputChange:n}){return e.jsxs("div",{className:"p-3 flex flex-col gap-3",children:[e.jsxs("div",{className:"grid w-full max-w-sm items-center gap-1.5",children:[e.jsx("label",{htmlFor:"name",className:"text-sm font-medium text-gray-700",children:"Name"}),e.jsx("input",{type:"text",id:"name",placeholder:"Name",name:"name",value:t.name,onChange:n,required:!0,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),e.jsxs("div",{className:"grid w-full gap-1.5 pt-2",children:[e.jsx("label",{htmlFor:"description",className:"text-sm font-medium text-gray-700",children:"Description"}),e.jsx("textarea",{placeholder:"Type your message here.",id:"description",name:"description",value:t.description,onChange:n,required:!0,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 min-h-[100px]"})]}),e.jsx("button",{type:"submit",className:"mt-3 w-full px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 font-medium",children:"Save Name & Description"})]})}function ae({path:t,namedPath:n,isArray:r,count:s,onClick:d}){const o=l.useCallback(()=>{d&&d(t)},[d,t]);return e.jsxs("div",{className:"bg-blue-50 p-3 rounded-lg flex items-center justify-between cursor-pointer group hover:bg-blue-100 transition-colors border border-blue-200",onClick:o,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[r&&e.jsx("svg",{className:"w-4 h-4 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})}),e.jsxs("div",{className:"capitalize font-medium text-gray-900",children:[n[n.length-1],s!==void 0&&` (${s})`]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[r&&e.jsx("svg",{className:"w-5 h-5 text-red-500 opacity-0 group-hover:opacity-100 transition-opacity",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})}),e.jsx("svg",{className:"w-4 h-4 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})]})]})}var V=(t=>(t.STRING="string",t.NUMBER="number",t.BOOLEAN="boolean",t.UNION="union",t.OBJECT="object",t.ARRAY="array",t))(V||{});const oe=({name:t,value:n,options:r,onChange:s})=>{const d=l.useCallback(o=>{s({target:{name:t,value:o.target.value}})},[t,s]);return e.jsx("select",{name:t,value:n,onChange:d,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",children:r.map((o,p)=>e.jsx("option",{value:o.trim(),children:o.trim()},p))})},ie=({name:t,value:n,onChange:r})=>{const s=l.useCallback(d=>{const o=d.target.checked;r({target:{name:t,value:o}})},[t,r]);return e.jsx("label",{className:"flex items-center gap-2 cursor-pointer",children:e.jsx("input",{type:"checkbox",name:t,checked:n,onChange:s,className:`w-10 h-6 rounded-full appearance-none cursor-pointer transition-colors relative
2
2
  bg-gray-300 checked:bg-blue-600
3
3
  after:content-[''] after:absolute after:top-1 after:left-1 after:w-4 after:h-4
4
4
  after:bg-white after:rounded-full after:transition-transform
5
- checked:after:translate-x-4`})})};function le({dataType:t,path:n,value:r,onChange:s}){const d=l.useMemo(()=>n[n.length-1],[n]),o=l.useMemo(()=>n.join("-"),[n]),p=l.useCallback(j=>{s(n,j.target.value)},[s,n]),c=l.useCallback(j=>{s(n,j.target.value)},[s,n]);return e.jsxs("div",{className:"grid w-full max-w-sm items-center gap-1.5",children:[e.jsx("label",{htmlFor:o,className:"capitalize text-sm font-medium text-gray-700",children:d==="~~codeyam-code~~"?"Dynamic Field":d}),t.includes("|")?e.jsx(oe,{name:o,value:r,options:t.split("|"),onChange:p}):t===V.BOOLEAN?e.jsx(ie,{name:o,value:r??!1,onChange:c}):e.jsx("input",{id:o,name:o,type:"text",value:JSON.stringify(r??"").replace(/"/g,""),onChange:p,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"},`Input-${o}`)]})}const ce="Default Scenario";function de({analysis:t,scenarioName:n,dataItem:r,onResult:s,onGenerateData:d}){const[o,p]=l.useState(!1),[c,j]=l.useState(""),k=l.useCallback(async()=>{if(!d){console.error("onGenerateData prop is required for AI data generation");return}p(!0);try{const u=t.scenarios.find(b=>b.name===n);if(!u)throw new Error("Scenario not found");const A=t.scenarios.find(b=>b.name===ce),I=await d(c,r);if(!I){console.error("Error getting AI guess for scenario data"),p(!1);return}const w=(b,v)=>{const L=Object.assign({},b);return x(b)&&x(v)&&Object.keys(v).forEach(N=>{x(v[N])?N in b?L[N]=w(b[N],v[N]):Object.assign(L,{[N]:v[N]}):Object.assign(L,{[N]:v[N]})}),L},x=b=>b&&typeof b=="object"&&!Array.isArray(b);u.metadata.data=w(w((A==null?void 0:A.metadata.data)||{},u.metadata.data),I.data||{}),s(u),p(!1),j("")}catch(u){console.error("Error generating AI data:",u),p(!1)}},[t,c,r,n,s,d]),g=l.useCallback(u=>{j(u.target.value)},[]);return e.jsxs("div",{className:"w-full p-3 flex flex-col gap-2 rounded-lg border-2 border-blue-200 text-sm bg-blue-50",children:[e.jsx("div",{className:"font-medium text-gray-700",children:"Describe the data changes to the AI"}),e.jsx("textarea",{className:"peer w-full h-16 p-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"Type your message here.",onChange:g,value:c}),e.jsx("button",{type:"button",disabled:o,className:`w-full px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-400 disabled:cursor-not-allowed font-medium ${c.length>0?"flex":"hidden peer-focus-within:flex"} items-center justify-center gap-2`,onClick:()=>void k(),children:o?e.jsxs(e.Fragment,{children:[e.jsxs("svg",{className:"animate-spin h-4 w-4 text-white",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"Please wait"]}):"Generate Data"})]})}function ue({namedPath:t,path:n,last:r,onClick:s}){const d=l.useCallback(()=>s(r?n.slice(0,-1):n),[r,n,s]);return e.jsx("div",{className:"capitalize cursor-pointer hover:text-blue-600 transition-colors",onClick:d,children:t[t.length-1]})}function me({dataItem:t,onClick:n}){const r=l.useCallback(()=>n([]),[n]),s=l.useMemo(()=>t.namedPath.length>=2?t.namedPath.length-2:0,[t]);return e.jsxs("div",{className:"text-sm flex items-center gap-2 py-3 px-2 border-b border-t border-gray-300 bg-gray-50",children:[e.jsx("svg",{className:"w-4 h-4 cursor-pointer hover:text-blue-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",onClick:r,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})}),t.namedPath.length>2&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{children:"..."}),e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})]}),t.namedPath.slice(s).map((d,o)=>e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(ue,{namedPath:t.namedPath.slice(0,o+s+1),path:t.path.slice(0,o+s+1),last:o+s===t.namedPath.length-1,onClick:n}),o+s<t.namedPath.length-1&&e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})]},`path-${d}-${o+s}`))]})}function F({analysis:t,scenarioName:n,dataItem:r,onClick:s,onChange:d,onAIResult:o,onGenerateData:p,saveFeedback:c}){const j=l.useMemo(()=>r.data,[r]),k=l.useMemo(()=>ne(r),[r]);return e.jsxs("div",{className:"w-full flex flex-col gap-6 px-3 mt-3",children:[r.path.length>0&&e.jsx(me,{dataItem:r,onClick:s}),e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(de,{analysis:t,scenarioName:n,dataItem:r,onResult:o,onGenerateData:p}),k==null?void 0:k.map((g,u)=>{var I;if(q(j[g])){let w=g;isNaN(Number(g))||(w=j[g].name??j[g].title??j[g].id??`${r.path[r.path.length-1].replace(/s$/,"")} ${parseInt(g)+1}`);const x=[...r.path,g],b=[...r.namedPath,w];return e.jsx(ae,{path:x,namedPath:b,isArray:Array.isArray(j),count:re(j[g]),onClick:s},`data-${g}-${u}`)}if(g==="id")return null;const A=[...r.path,g];return e.jsx(le,{dataType:((I=r.structure)==null?void 0:I[g])??"string",path:A,value:j[g],onChange:d},`InputField-${A.join("-")}`)})]}),e.jsx("input",{type:"hidden",name:"recapture",id:"recapture-input",value:"false"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"submit",onClick:()=>{const g=document.getElementById("recapture-input");g&&(g.value="false")},disabled:c==null?void 0:c.isSaving,className:"flex-1 px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 font-medium disabled:opacity-50 disabled:cursor-not-allowed",children:c!=null&&c.isSaving?"Saving...":"Save Changes"}),e.jsx("button",{type:"submit",onClick:()=>{const g=document.getElementById("recapture-input");g&&(g.value="true")},disabled:c==null?void 0:c.isSaving,className:"flex-1 px-4 py-2 bg-gray-100 text-gray-700 border border-gray-300 rounded-md hover:bg-gray-200 focus:outline-none focus:ring-2 focus:ring-blue-500 font-medium disabled:opacity-50 disabled:cursor-not-allowed",children:"Save & Recapture"})]}),(c==null?void 0:c.message)&&!(c!=null&&c.isSaving)&&e.jsx("div",{className:`mt-3 p-3 rounded-md text-sm font-medium ${c.isError?"bg-red-50 text-red-700 border border-red-200":"bg-green-50 text-green-700 border border-green-200"}`,children:c.message})]})}function H({title:t,children:n,defaultOpen:r=!1,borderT:s=!1,borderB:d=!1}){const[o,p]=l.useState(r),c=[];return s&&c.push("border-t"),d&&c.push("border-b"),e.jsxs("div",{className:`${c.join(" ")} border-gray-300`,children:[e.jsxs("button",{type:"button",onClick:()=>p(!o),className:"w-full px-4 py-3 flex items-center justify-between bg-gray-50 hover:bg-gray-100 transition-colors text-left font-semibold text-gray-900",children:[e.jsx("span",{children:t}),e.jsx("svg",{className:`transition-transform ${o?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",style:{width:"20px",height:"20px",minWidth:"20px",minHeight:"20px",maxWidth:"20px",maxHeight:"20px",flexShrink:0},children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),o&&e.jsx("div",{className:"px-4 py-3",children:n})]})}const ge=({currentScenario:t,defaultScenario:n,dataStructure:r,analysis:s,shouldCreateNewScenario:d,onSave:o,onNavigate:p,iframeRef:c,onGenerateData:j,saveFeedback:k})=>{const g=l.useCallback((i,a)=>{const h=Object.assign({},i),f=m=>m&&typeof m=="object"&&!Array.isArray(m);return f(i)&&f(a)&&Object.keys(a).forEach(m=>{f(a[m])?m in i?h[m]=g(i[m],a[m]):Object.assign(h,{[m]:a[m]}):Object.assign(h,{[m]:a[m]})}),h},[]),[u,A]=l.useState({name:t.name,description:t.description,data:g(n.metadata.data,t.metadata.data)}),[I,w]=l.useState(null),x=l.useMemo(()=>({...u.data}),[u]),b=l.useMemo(()=>({...x.mockData?{"Retrieved Data":x.mockData}:{},...x.argumentsData?{"Function Arguments":x.argumentsData}:{}}),[x]),v=l.useMemo(()=>{const i={...r.arguments?{"Function Arguments":r.arguments}:{},...r.dataForMocks?{"Retrieved Data":r.dataForMocks}:{}};return Object.keys(i).reduce((a,h)=>{if(h.includes(".")){const[f,m]=h.split(".");a[f]||(a[f]={}),a[f][m]=i[h]}else a[h]=i[h];return a},{})},[r]),L=l.useCallback(async i=>{i.preventDefault();const a=i.target.querySelector('input[name="recapture"]'),h=(a==null?void 0:a.value)==="true",f={mockData:u.data.mockData??{},argumentsData:u.data.argumentsData??[]};console.log("[ScenarioEditor] Saving scenario data:",{scenarioName:u.name,shouldRecapture:h,dataToSave:f,rawFormData:u.data,iframePayload:{arguments:x.argumentsData??[],...x.mockData??{}}}),console.log("[ScenarioEditor] Full dataToSave JSON:",JSON.stringify(f,null,2).substring(0,1e3));const m=s==null?void 0:s.scenarios.map(S=>!d&&S.name===t.name?{...S,name:u.name,description:u.description,metadata:{...S.metadata,data:f}}:S);d&&m.push({name:u.name,description:u.description,metadata:{data:f,interactiveExamplePath:s==null?void 0:s.scenarios[0].metadata.interactiveExamplePath}}),console.log("[ScenarioEditor] Updated scenarios to save:",m),o&&await o(m,{recapture:h}),p&&p(u.name)},[s,t.name,u,x,d,o,p]),N=l.useCallback(i=>{A(a=>({...a,[i.target.name]:i.target.value}))},[]),M=l.useCallback(i=>{w(a=>{if(!a)return null;for(const h of[{arguments:i.metadata.data.argumentsData},i.metadata.data.mockData]){let f=h;for(const m of a.path)if(f=U(f,m),!f)break;f&&(a.data=f)}return{...a}}),A({name:i.name,description:i.description,data:i.metadata.data})},[]),W=l.useCallback((i,a)=>{A(h=>{for(const f of[{"Function Arguments":h.data.argumentsData},{"Retrieved Data":h.data.mockData}]){let m=f;for(const S of i.slice(0,-1))if(m=U(m,S),!m)break;if(m){const S=m[i[i.length-1]];w(C=>C?(C.namedPath[C.namedPath.length-1]===S&&(C.namedPath[C.namedPath.length-1]=a.toString()),C.data[i[i.length-1]]=a,{...C}):null),m[i[i.length-1]]=a}}return{...h}})},[]),J=l.useCallback(i=>{var m,S,C;if(i.length===0){w(null);return}let a=b;const h=[];let f=v;for(const E of i){if(h.push(isNaN(parseInt(E))?E:((m=a[E])==null?void 0:m.name)??((S=a[E])==null?void 0:S.title)??((C=a[E])==null?void 0:C.id)??E),a=U(a,E),!a){console.log("Data not found",a,E),w(null);return}Array.isArray(f)?f=f[0]:f=f[E]}w({path:i,namedPath:h,data:a,structure:f})},[b,v]);return l.useEffect(()=>{const i=a=>{var h;a.data.type==="codeyam-log"&&((h=a.data.data)!=null&&h.includes("Error"))&&console.error("[ScenarioEditor] Error from iframe:",a.data.data)};return window.addEventListener("message",i),()=>window.removeEventListener("message",i)},[]),l.useEffect(()=>{var i;if((i=c==null?void 0:c.current)!=null&&i.contentWindow){const a={arguments:x.argumentsData??[],...x.mockData??{}},h={type:"codeyam-override-data",name:t.name,data:JSON.stringify(a)};console.log("[ScenarioEditor] → SENDING codeyam-override-data:",{type:h.type,name:h.name,dataPreview:JSON.stringify(a).substring(0,200)+"...",fullData:a}),c.current.contentWindow.postMessage(h,"*")}},[x,t,c]),e.jsx("form",{method:"post",onSubmit:i=>void L(i),children:I?e.jsx(F,{analysis:s,scenarioName:u.name,dataItem:I,onClick:J,onChange:W,onAIResult:M,onGenerateData:j,saveFeedback:k}):e.jsxs(e.Fragment,{children:[e.jsx(H,{title:"Edit Name and Description",borderT:!0,children:e.jsx(se,{scenarioFormData:u,handleInputChange:N})}),t.metadata.data&&e.jsx(H,{title:"Edit Scenario Data",defaultOpen:!0,borderT:!0,borderB:!0,children:e.jsx(F,{analysis:s,scenarioName:u.name,dataItem:{path:[],namedPath:[],data:b,structure:v},onClick:J,onChange:W,onAIResult:M,onGenerateData:j,saveFeedback:k})})]})})},ye=({data:t})=>[{title:t!=null&&t.scenario?`Edit ${t.scenario.name} - CodeYam`:"Edit Scenario - CodeYam"},{name:"description",content:"Edit scenario data"}];function he(){var E,_,G;const t=K(),n=t.analysis,r=t.scenario,s=t.defaultScenario,d=t.entitySha,o=t.projectSlug,p=Q(),{iframeRef:c}=Z(),[j,k]=l.useState(!1),[g,u]=l.useState(null),[A,I]=l.useState(null),[w,x]=l.useState(!1),[b,v]=l.useState(!1),[L,N]=l.useState(null),{interactiveServerUrl:M,isStarting:W,isLoading:J,showIframe:i,iframeKey:a,onIframeLoad:h}=te({analysisId:n==null?void 0:n.id,scenarioId:r==null?void 0:r.id,scenarioName:r==null?void 0:r.name,projectSlug:o,enabled:!0}),f=l.useCallback(async(P,y)=>{k(!0),u(null),I(null),console.log("[EditScenario] Starting save with options:",y),console.log("[EditScenario] Scenarios to save:",P);try{const D={analysis:n,scenarios:P};console.log("[EditScenario] Sending to /api/save-scenarios:",{analysisId:n.id,scenarioCount:P.length,scenarioNames:P.map(R=>R.name)});const T=await fetch("/api/save-scenarios",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(D)}),B=await T.json();if(console.log("[EditScenario] API response:",B),!T.ok||!B.success)throw new Error(B.error||"Failed to save scenarios");if(console.log("[EditScenario] Scenarios saved successfully"),y!=null&&y.recapture&&r.id&&M){console.log("[EditScenario] ========== DIRECT CAPTURE START =========="),console.log("[EditScenario] Taking screenshot from running server",{scenarioId:r.id,projectId:n.projectId,serverUrl:M}),u("Changes saved. Capturing screenshot...");const R={serverUrl:M,scenarioId:r.id,projectId:n.projectId,viewportWidth:1440};console.log("[EditScenario] Capture request body:",R);const $=await fetch("/api/capture-screenshot",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(R)});console.log("[EditScenario] Capture response status:",$.status);const O=await $.json();if(console.log("[EditScenario] Capture response body:",O),!$.ok||!O.success)throw console.error("[EditScenario] Capture failed:",O),new Error(O.error||"Failed to capture screenshot");console.log("[EditScenario] Screenshot captured successfully:",O),console.log("[EditScenario] ========== DIRECT CAPTURE COMPLETE =========="),u("Recapture successful")}else if(y!=null&&y.recapture&&!M){console.log("[EditScenario] No running server, using queued recapture");const R=new FormData;R.append("analysisId",n.id||""),R.append("scenarioId",r.id||"");const $=await fetch("/api/recapture-scenario",{method:"POST",body:R}),O=await $.json();if(!$.ok||!O.success)throw new Error(O.error||"Failed to trigger recapture");console.log("Recapture queued:",O),I(O.jobId),u("Changes saved. Screenshot recapture queued.")}else u("Changes saved successfully.")}catch(D){console.error("Error saving scenarios:",D),u(`Error: ${D instanceof Error?D.message:String(D)}`)}finally{k(!1)}},[n,r.id,M]),m=l.useCallback(P=>{},[]),S=l.useCallback(async(P,y)=>{var B;const D=await fetch("/api/generate-scenario-data",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({description:P,existingScenarios:n.scenarios,scenariosDataStructure:(B=n.metadata)==null?void 0:B.scenariosDataStructure,editingMockName:r.name,editingMockData:y==null?void 0:y.data})}),T=await D.json();if(!D.ok||!T.success)throw new Error(T.error||"Failed to generate scenario data");return T.data},[n,r.name]),C=l.useCallback(async()=>{var P;if(!r.id){N("Cannot delete scenario without ID");return}x(!0),N(null);try{const y=await fetch("/api/delete-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioId:r.id,screenshotPaths:((P=r.metadata)==null?void 0:P.screenshotPaths)||[]})}),D=await y.json();if(!y.ok||!D.success)throw new Error(D.error||"Failed to delete scenario");p(`/entity/${d}`)}catch(y){console.error("[EditScenario] Error deleting scenario:",y),N(y instanceof Error?y.message:"Failed to delete scenario"),v(!1)}finally{x(!1)}},[r.id,(E=r.metadata)==null?void 0:E.screenshotPaths,d,p]);return e.jsxs("div",{className:"h-screen bg-gray-50 flex flex-col",children:[e.jsxs("header",{className:"bg-white border-b border-gray-200 px-8 py-6 shrink-0",children:[e.jsx("div",{className:"mb-4",children:e.jsxs(z,{to:`/entity/${d}`,className:"text-blue-600 no-underline text-sm font-medium transition-colors hover:text-blue-700 hover:underline",children:["← Back to ",(_=n.entity)==null?void 0:_.name]})}),e.jsxs("h1",{className:"text-[32px] font-bold text-gray-900 m-0 mb-3",children:["Edit Scenario: ",r.name]}),r.description&&e.jsx("p",{className:"text-gray-600 text-[15px] leading-relaxed m-0",children:r.description})]}),e.jsxs("div",{className:"flex flex-1 gap-0 min-h-0",children:[e.jsxs("aside",{className:"w-[400px] bg-white border-r border-gray-200 overflow-y-auto shrink-0",children:[e.jsx(ge,{currentScenario:r,defaultScenario:s,dataStructure:((G=n.metadata)==null?void 0:G.scenariosDataStructure)||{},analysis:n,shouldCreateNewScenario:!1,onSave:f,onNavigate:m,iframeRef:c,onGenerateData:S,saveFeedback:{isSaving:j,message:g,isError:(g==null?void 0:g.startsWith("Error"))??!1}}),g==="Recapture successful"&&e.jsx("div",{className:"px-4 pb-4",children:e.jsx(z,{to:`/entity/${d}`,className:"text-blue-600 hover:text-blue-700 hover:underline text-sm",children:"View updated screenshot on entity page →"})}),e.jsxs("div",{className:"border-t border-gray-200 p-4 mt-4",children:[e.jsx("div",{className:"text-sm text-gray-600 mb-3",children:"Permanently remove this scenario and its screenshots."}),b?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"text-sm text-red-600 font-medium",children:['Are you sure you want to delete "',r.name,'"?']}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>void C(),disabled:w,className:"flex-1 px-4 py-2 bg-red-600 text-white rounded-md text-sm font-medium hover:bg-red-700 disabled:bg-red-400 disabled:cursor-not-allowed transition-colors",children:w?"Deleting...":"Yes, Delete"}),e.jsx("button",{onClick:()=>v(!1),disabled:w,className:"flex-1 px-4 py-2 bg-gray-100 text-gray-700 border border-gray-300 rounded-md text-sm font-medium hover:bg-gray-200 disabled:opacity-50 transition-colors",children:"Cancel"})]})]}):e.jsx("button",{onClick:()=>v(!0),className:"w-full px-4 py-2 bg-red-50 text-red-600 border border-red-200 rounded-md text-sm font-medium hover:bg-red-100 transition-colors",children:"Delete Scenario"}),L&&e.jsx("div",{className:"mt-3 text-sm text-red-600 bg-red-50 px-3 py-2 rounded-md",children:L})]})]}),e.jsx("main",{className:"flex-1 bg-gray-100 overflow-auto flex flex-col min-w-0",children:e.jsx(ee,{scenarioId:r.id||r.name,scenarioName:r.name,iframeUrl:M,isStarting:W,isLoading:J,showIframe:i,iframeKey:a,onIframeLoad:h,projectSlug:o,defaultWidth:1440,defaultHeight:900})})]})]})}const we=Y(function(){return e.jsx(X,{children:e.jsx(he,{})})});export{we as default,ye as meta};
5
+ checked:after:translate-x-4`})})};function le({dataType:t,path:n,value:r,onChange:s}){const d=l.useMemo(()=>n[n.length-1],[n]),o=l.useMemo(()=>n.join("-"),[n]),p=l.useCallback(j=>{s(n,j.target.value)},[s,n]),c=l.useCallback(j=>{s(n,j.target.value)},[s,n]);return e.jsxs("div",{className:"grid w-full max-w-sm items-center gap-1.5",children:[e.jsx("label",{htmlFor:o,className:"capitalize text-sm font-medium text-gray-700",children:d==="~~codeyam-code~~"?"Dynamic Field":d}),t.includes("|")?e.jsx(oe,{name:o,value:r,options:t.split("|"),onChange:p}):t===V.BOOLEAN?e.jsx(ie,{name:o,value:r??!1,onChange:c}):e.jsx("input",{id:o,name:o,type:"text",value:JSON.stringify(r??"").replace(/"/g,""),onChange:p,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"},`Input-${o}`)]})}const ce="Default Scenario";function de({analysis:t,scenarioName:n,dataItem:r,onResult:s,onGenerateData:d}){const[o,p]=l.useState(!1),[c,j]=l.useState(""),k=l.useCallback(async()=>{if(!d){console.error("onGenerateData prop is required for AI data generation");return}p(!0);try{const u=t.scenarios.find(b=>b.name===n);if(!u)throw new Error("Scenario not found");const A=t.scenarios.find(b=>b.name===ce),I=await d(c,r);if(!I){console.error("Error getting AI guess for scenario data"),p(!1);return}const w=(b,v)=>{const L=Object.assign({},b);return x(b)&&x(v)&&Object.keys(v).forEach(N=>{x(v[N])?N in b?L[N]=w(b[N],v[N]):Object.assign(L,{[N]:v[N]}):Object.assign(L,{[N]:v[N]})}),L},x=b=>b&&typeof b=="object"&&!Array.isArray(b);u.metadata.data=w(w((A==null?void 0:A.metadata.data)||{},u.metadata.data),I.data||{}),s(u),p(!1),j("")}catch(u){console.error("Error generating AI data:",u),p(!1)}},[t,c,r,n,s,d]),g=l.useCallback(u=>{j(u.target.value)},[]);return e.jsxs("div",{className:"w-full p-3 flex flex-col gap-2 rounded-lg border-2 border-blue-200 text-sm bg-blue-50",children:[e.jsx("div",{className:"font-medium text-gray-700",children:"Describe the data changes to the AI"}),e.jsx("textarea",{className:"peer w-full h-16 p-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"Type your message here.",onChange:g,value:c}),e.jsx("button",{type:"button",disabled:o,className:`w-full px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-400 disabled:cursor-not-allowed font-medium ${c.length>0?"flex":"hidden peer-focus-within:flex"} items-center justify-center gap-2`,onClick:()=>void k(),children:o?e.jsxs(e.Fragment,{children:[e.jsxs("svg",{className:"animate-spin h-4 w-4 text-white",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"Please wait"]}):"Generate Data"})]})}function ue({namedPath:t,path:n,last:r,onClick:s}){const d=l.useCallback(()=>s(r?n.slice(0,-1):n),[r,n,s]);return e.jsx("div",{className:"capitalize cursor-pointer hover:text-blue-600 transition-colors",onClick:d,children:t[t.length-1]})}function me({dataItem:t,onClick:n}){const r=l.useCallback(()=>n([]),[n]),s=l.useMemo(()=>t.namedPath.length>=2?t.namedPath.length-2:0,[t]);return e.jsxs("div",{className:"text-sm flex items-center gap-2 py-3 px-2 border-b border-t border-gray-300 bg-gray-50",children:[e.jsx("svg",{className:"w-4 h-4 cursor-pointer hover:text-blue-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",onClick:r,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})}),t.namedPath.length>2&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{children:"..."}),e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})]}),t.namedPath.slice(s).map((d,o)=>e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(ue,{namedPath:t.namedPath.slice(0,o+s+1),path:t.path.slice(0,o+s+1),last:o+s===t.namedPath.length-1,onClick:n}),o+s<t.namedPath.length-1&&e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})]},`path-${d}-${o+s}`))]})}function F({analysis:t,scenarioName:n,dataItem:r,onClick:s,onChange:d,onAIResult:o,onGenerateData:p,saveFeedback:c}){const j=l.useMemo(()=>r.data,[r]),k=l.useMemo(()=>ne(r),[r]);return e.jsxs("div",{className:"w-full flex flex-col gap-6 px-3 mt-3",children:[r.path.length>0&&e.jsx(me,{dataItem:r,onClick:s}),e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(de,{analysis:t,scenarioName:n,dataItem:r,onResult:o,onGenerateData:p}),k==null?void 0:k.map((g,u)=>{var I;if(q(j[g])){let w=g;isNaN(Number(g))||(w=j[g].name??j[g].title??j[g].id??`${r.path[r.path.length-1].replace(/s$/,"")} ${parseInt(g)+1}`);const x=[...r.path,g],b=[...r.namedPath,w];return e.jsx(ae,{path:x,namedPath:b,isArray:Array.isArray(j),count:re(j[g]),onClick:s},`data-${g}-${u}`)}if(g==="id")return null;const A=[...r.path,g];return e.jsx(le,{dataType:((I=r.structure)==null?void 0:I[g])??"string",path:A,value:j[g],onChange:d},`InputField-${A.join("-")}`)})]}),e.jsx("input",{type:"hidden",name:"recapture",id:"recapture-input",value:"false"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"submit",onClick:()=>{const g=document.getElementById("recapture-input");g&&(g.value="false")},disabled:c==null?void 0:c.isSaving,className:"flex-1 px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 font-medium disabled:opacity-50 disabled:cursor-not-allowed",children:c!=null&&c.isSaving?"Saving...":"Save Changes"}),e.jsx("button",{type:"submit",onClick:()=>{const g=document.getElementById("recapture-input");g&&(g.value="true")},disabled:c==null?void 0:c.isSaving,className:"flex-1 px-4 py-2 bg-gray-100 text-gray-700 border border-gray-300 rounded-md hover:bg-gray-200 focus:outline-none focus:ring-2 focus:ring-blue-500 font-medium disabled:opacity-50 disabled:cursor-not-allowed",children:"Save & Recapture"})]}),(c==null?void 0:c.message)&&!(c!=null&&c.isSaving)&&e.jsx("div",{className:`mt-3 p-3 rounded-md text-sm font-medium ${c.isError?"bg-red-50 text-red-700 border border-red-200":"bg-green-50 text-green-700 border border-green-200"}`,children:c.message})]})}function H({title:t,children:n,defaultOpen:r=!1,borderT:s=!1,borderB:d=!1}){const[o,p]=l.useState(r),c=[];return s&&c.push("border-t"),d&&c.push("border-b"),e.jsxs("div",{className:`${c.join(" ")} border-gray-300`,children:[e.jsxs("button",{type:"button",onClick:()=>p(!o),className:"w-full px-4 py-3 flex items-center justify-between bg-gray-50 hover:bg-gray-100 transition-colors text-left font-semibold text-gray-900",children:[e.jsx("span",{children:t}),e.jsx("svg",{className:`transition-transform ${o?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",style:{width:"20px",height:"20px",minWidth:"20px",minHeight:"20px",maxWidth:"20px",maxHeight:"20px",flexShrink:0},children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),o&&e.jsx("div",{className:"px-4 py-3",children:n})]})}const ge=({currentScenario:t,defaultScenario:n,dataStructure:r,analysis:s,shouldCreateNewScenario:d,onSave:o,onNavigate:p,iframeRef:c,onGenerateData:j,saveFeedback:k})=>{const g=l.useCallback((i,a)=>{const h=Object.assign({},i),f=m=>m&&typeof m=="object"&&!Array.isArray(m);return f(i)&&f(a)&&Object.keys(a).forEach(m=>{f(a[m])?m in i?h[m]=g(i[m],a[m]):Object.assign(h,{[m]:a[m]}):Object.assign(h,{[m]:a[m]})}),h},[]),[u,A]=l.useState({name:t.name,description:t.description,data:g(n.metadata.data,t.metadata.data)}),[I,w]=l.useState(null),x=l.useMemo(()=>({...u.data}),[u]),b=l.useMemo(()=>({...x.mockData?{"Retrieved Data":x.mockData}:{},...x.argumentsData?{"Function Arguments":x.argumentsData}:{}}),[x]),v=l.useMemo(()=>{const i={...r.arguments?{"Function Arguments":r.arguments}:{},...r.dataForMocks?{"Retrieved Data":r.dataForMocks}:{}};return Object.keys(i).reduce((a,h)=>{if(h.includes(".")){const[f,m]=h.split(".");a[f]||(a[f]={}),a[f][m]=i[h]}else a[h]=i[h];return a},{})},[r]),L=l.useCallback(async i=>{i.preventDefault();const a=i.target.querySelector('input[name="recapture"]'),h=(a==null?void 0:a.value)==="true",f={mockData:u.data.mockData??{},argumentsData:u.data.argumentsData??[]};console.log("[ScenarioEditor] Saving scenario data:",{scenarioName:u.name,shouldRecapture:h,dataToSave:f,rawFormData:u.data,iframePayload:{arguments:x.argumentsData??[],...x.mockData??{}}}),console.log("[ScenarioEditor] Full dataToSave JSON:",JSON.stringify(f,null,2).substring(0,1e3));const m=s==null?void 0:s.scenarios.map(S=>!d&&S.name===t.name?{...S,name:u.name,description:u.description,metadata:{...S.metadata,data:f}}:S);d&&m.push({name:u.name,description:u.description,metadata:{data:f,interactiveExamplePath:s==null?void 0:s.scenarios[0].metadata.interactiveExamplePath}}),console.log("[ScenarioEditor] Updated scenarios to save:",m),o&&await o(m,{recapture:h}),p&&p(u.name)},[s,t.name,u,x,d,o,p]),N=l.useCallback(i=>{A(a=>({...a,[i.target.name]:i.target.value}))},[]),M=l.useCallback(i=>{w(a=>{if(!a)return null;for(const h of[{arguments:i.metadata.data.argumentsData},i.metadata.data.mockData]){let f=h;for(const m of a.path)if(f=U(f,m),!f)break;f&&(a.data=f)}return{...a}}),A({name:i.name,description:i.description,data:i.metadata.data})},[]),W=l.useCallback((i,a)=>{A(h=>{for(const f of[{"Function Arguments":h.data.argumentsData},{"Retrieved Data":h.data.mockData}]){let m=f;for(const S of i.slice(0,-1))if(m=U(m,S),!m)break;if(m){const S=m[i[i.length-1]];w(C=>C?(C.namedPath[C.namedPath.length-1]===S&&(C.namedPath[C.namedPath.length-1]=a.toString()),C.data[i[i.length-1]]=a,{...C}):null),m[i[i.length-1]]=a}}return{...h}})},[]),J=l.useCallback(i=>{var m,S,C;if(i.length===0){w(null);return}let a=b;const h=[];let f=v;for(const E of i){if(h.push(isNaN(parseInt(E))?E:((m=a[E])==null?void 0:m.name)??((S=a[E])==null?void 0:S.title)??((C=a[E])==null?void 0:C.id)??E),a=U(a,E),!a){console.log("Data not found",a,E),w(null);return}Array.isArray(f)?f=f[0]:f=f[E]}w({path:i,namedPath:h,data:a,structure:f})},[b,v]);return l.useEffect(()=>{const i=a=>{var h;a.data.type==="codeyam-log"&&((h=a.data.data)!=null&&h.includes("Error"))&&console.error("[ScenarioEditor] Error from iframe:",a.data.data)};return window.addEventListener("message",i),()=>window.removeEventListener("message",i)},[]),l.useEffect(()=>{var i;if((i=c==null?void 0:c.current)!=null&&i.contentWindow){const a={arguments:x.argumentsData??[],...x.mockData??{}},h={type:"codeyam-override-data",name:t.name,data:JSON.stringify(a)};console.log("[ScenarioEditor] → SENDING codeyam-override-data:",{type:h.type,name:h.name,dataPreview:JSON.stringify(a).substring(0,200)+"...",fullData:a}),c.current.contentWindow.postMessage(h,"*")}},[x,t,c]),e.jsx("form",{method:"post",onSubmit:i=>void L(i),children:I?e.jsx(F,{analysis:s,scenarioName:u.name,dataItem:I,onClick:J,onChange:W,onAIResult:M,onGenerateData:j,saveFeedback:k}):e.jsxs(e.Fragment,{children:[e.jsx(H,{title:"Edit Name and Description",borderT:!0,children:e.jsx(se,{scenarioFormData:u,handleInputChange:N})}),t.metadata.data&&e.jsx(H,{title:"Edit Scenario Data",defaultOpen:!0,borderT:!0,borderB:!0,children:e.jsx(F,{analysis:s,scenarioName:u.name,dataItem:{path:[],namedPath:[],data:b,structure:v},onClick:J,onChange:W,onAIResult:M,onGenerateData:j,saveFeedback:k})})]})})},we=({data:t})=>[{title:t!=null&&t.scenario?`Edit ${t.scenario.name} - CodeYam`:"Edit Scenario - CodeYam"},{name:"description",content:"Edit scenario data"}];function he(){var E,_,G;const t=K(),n=t.analysis,r=t.scenario,s=t.defaultScenario,d=t.entitySha,o=t.projectSlug,p=Q(),{iframeRef:c}=Z(),[j,k]=l.useState(!1),[g,u]=l.useState(null),[A,I]=l.useState(null),[w,x]=l.useState(!1),[b,v]=l.useState(!1),[L,N]=l.useState(null),{interactiveServerUrl:M,isStarting:W,isLoading:J,showIframe:i,iframeKey:a,onIframeLoad:h}=te({analysisId:n==null?void 0:n.id,scenarioId:r==null?void 0:r.id,scenarioName:r==null?void 0:r.name,projectSlug:o,enabled:!0}),f=l.useCallback(async(P,y)=>{k(!0),u(null),I(null),console.log("[EditScenario] Starting save with options:",y),console.log("[EditScenario] Scenarios to save:",P);try{const D={analysis:n,scenarios:P};console.log("[EditScenario] Sending to /api/save-scenarios:",{analysisId:n.id,scenarioCount:P.length,scenarioNames:P.map(R=>R.name)});const T=await fetch("/api/save-scenarios",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(D)}),B=await T.json();if(console.log("[EditScenario] API response:",B),!T.ok||!B.success)throw new Error(B.error||"Failed to save scenarios");if(console.log("[EditScenario] Scenarios saved successfully"),y!=null&&y.recapture&&r.id&&M){console.log("[EditScenario] ========== DIRECT CAPTURE START =========="),console.log("[EditScenario] Taking screenshot from running server",{scenarioId:r.id,projectId:n.projectId,serverUrl:M}),u("Changes saved. Capturing screenshot...");const R={serverUrl:M,scenarioId:r.id,projectId:n.projectId,viewportWidth:1440};console.log("[EditScenario] Capture request body:",R);const $=await fetch("/api/capture-screenshot",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(R)});console.log("[EditScenario] Capture response status:",$.status);const O=await $.json();if(console.log("[EditScenario] Capture response body:",O),!$.ok||!O.success)throw console.error("[EditScenario] Capture failed:",O),new Error(O.error||"Failed to capture screenshot");console.log("[EditScenario] Screenshot captured successfully:",O),console.log("[EditScenario] ========== DIRECT CAPTURE COMPLETE =========="),u("Recapture successful")}else if(y!=null&&y.recapture&&!M){console.log("[EditScenario] No running server, using queued recapture");const R=new FormData;R.append("analysisId",n.id||""),R.append("scenarioId",r.id||"");const $=await fetch("/api/recapture-scenario",{method:"POST",body:R}),O=await $.json();if(!$.ok||!O.success)throw new Error(O.error||"Failed to trigger recapture");console.log("Recapture queued:",O),I(O.jobId),u("Changes saved. Screenshot recapture queued.")}else u("Changes saved successfully.")}catch(D){console.error("Error saving scenarios:",D),u(`Error: ${D instanceof Error?D.message:String(D)}`)}finally{k(!1)}},[n,r.id,M]),m=l.useCallback(P=>{},[]),S=l.useCallback(async(P,y)=>{var B;const D=await fetch("/api/generate-scenario-data",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({description:P,existingScenarios:n.scenarios,scenariosDataStructure:(B=n.metadata)==null?void 0:B.scenariosDataStructure,editingMockName:r.name,editingMockData:y==null?void 0:y.data})}),T=await D.json();if(!D.ok||!T.success)throw new Error(T.error||"Failed to generate scenario data");return T.data},[n,r.name]),C=l.useCallback(async()=>{var P;if(!r.id){N("Cannot delete scenario without ID");return}x(!0),N(null);try{const y=await fetch("/api/delete-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioId:r.id,screenshotPaths:((P=r.metadata)==null?void 0:P.screenshotPaths)||[]})}),D=await y.json();if(!y.ok||!D.success)throw new Error(D.error||"Failed to delete scenario");p(`/entity/${d}`)}catch(y){console.error("[EditScenario] Error deleting scenario:",y),N(y instanceof Error?y.message:"Failed to delete scenario"),v(!1)}finally{x(!1)}},[r.id,(E=r.metadata)==null?void 0:E.screenshotPaths,d,p]);return e.jsxs("div",{className:"h-screen bg-gray-50 flex flex-col",children:[e.jsxs("header",{className:"bg-white border-b border-gray-200 px-8 py-6 shrink-0",children:[e.jsx("div",{className:"mb-4",children:e.jsxs(z,{to:`/entity/${d}`,className:"text-blue-600 no-underline text-sm font-medium transition-colors hover:text-blue-700 hover:underline",children:["← Back to ",(_=n.entity)==null?void 0:_.name]})}),e.jsxs("h1",{className:"text-[32px] font-bold text-gray-900 m-0 mb-3",children:["Edit Scenario: ",r.name]}),r.description&&e.jsx("p",{className:"text-gray-600 text-[15px] leading-relaxed m-0",children:r.description})]}),e.jsxs("div",{className:"flex flex-1 gap-0 min-h-0",children:[e.jsxs("aside",{className:"w-[400px] bg-white border-r border-gray-200 overflow-y-auto shrink-0",children:[e.jsx(ge,{currentScenario:r,defaultScenario:s,dataStructure:((G=n.metadata)==null?void 0:G.scenariosDataStructure)||{},analysis:n,shouldCreateNewScenario:!1,onSave:f,onNavigate:m,iframeRef:c,onGenerateData:S,saveFeedback:{isSaving:j,message:g,isError:(g==null?void 0:g.startsWith("Error"))??!1}}),g==="Recapture successful"&&e.jsx("div",{className:"px-4 pb-4",children:e.jsx(z,{to:`/entity/${d}`,className:"text-blue-600 hover:text-blue-700 hover:underline text-sm",children:"View updated screenshot on entity page →"})}),e.jsxs("div",{className:"border-t border-gray-200 p-4 mt-4",children:[e.jsx("div",{className:"text-sm text-gray-600 mb-3",children:"Permanently remove this scenario and its screenshots."}),b?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"text-sm text-red-600 font-medium",children:['Are you sure you want to delete "',r.name,'"?']}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>void C(),disabled:w,className:"flex-1 px-4 py-2 bg-red-600 text-white rounded-md text-sm font-medium hover:bg-red-700 disabled:bg-red-400 disabled:cursor-not-allowed transition-colors",children:w?"Deleting...":"Yes, Delete"}),e.jsx("button",{onClick:()=>v(!1),disabled:w,className:"flex-1 px-4 py-2 bg-gray-100 text-gray-700 border border-gray-300 rounded-md text-sm font-medium hover:bg-gray-200 disabled:opacity-50 transition-colors",children:"Cancel"})]})]}):e.jsx("button",{onClick:()=>v(!0),className:"w-full px-4 py-2 bg-red-50 text-red-600 border border-red-200 rounded-md text-sm font-medium hover:bg-red-100 transition-colors",children:"Delete Scenario"}),L&&e.jsx("div",{className:"mt-3 text-sm text-red-600 bg-red-50 px-3 py-2 rounded-md",children:L})]})]}),e.jsx("main",{className:"flex-1 bg-gray-100 overflow-auto flex flex-col min-w-0",children:e.jsx(ee,{scenarioId:r.id||r.name,scenarioName:r.name,iframeUrl:M,isStarting:W,isLoading:J,showIframe:i,iframeKey:a,onIframeLoad:h,projectSlug:o,defaultWidth:1440,defaultHeight:900})})]})]})}const Ne=Y(function(){return e.jsx(X,{children:e.jsx(he,{})})});export{Ne as default,we as meta};
@@ -1,4 +1,4 @@
1
- import{g as Zd,m as jd,s as xd,E as Vd,N as Ld,R as Ul,k as Kd,r as Ml,l as sy,n as rd,F as Jd,o as wd,p as Wd,q as Fd,t as $d,v as kd,x as Id,y as Pd,z as lh,A as th,B as ah,C as uh,j as iy}from"./chunk-JZWAC4HX-7VptmeIr.js";import{r as oy}from"./index-7-1FmlHo.js";var ei={exports:{}},he={},ni={exports:{}},fi={};/**
1
+ import{h as Zd,m as jd,s as xd,E as Vd,N as Ld,R as Ul,l as Kd,r as Ml,n as sy,o as rd,F as Jd,p as wd,q as Wd,t as Fd,v as $d,x as kd,y as Id,z as Pd,A as lh,B as th,C as ah,D as uh,j as iy}from"./chunk-JZWAC4HX-C4pqxYJB.js";import{r as oy}from"./index-10oVnAAH.js";var ei={exports:{}},he={},ni={exports:{}},fi={};/**
2
2
  * @license React
3
3
  * scheduler.production.js
4
4
  *
@@ -1 +1 @@
1
- import{j as l}from"./chunk-JZWAC4HX-7VptmeIr.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
+ 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 +1 @@
1
- import{b as ne,r as u,j as e,w as le,u as ce,f as de}from"./chunk-JZWAC4HX-7VptmeIr.js";import{u as me}from"./useReportContext-BsQb6rFd.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-DlMph_Hm.js";import{g as T}from"./fileTableUtils-EWpfFU4X.js";import{C as ae}from"./chevron-down-DQJA9f4o.js";import{S as ve}from"./search-DborVoKD.js";import"./createLucideIcon-D-QUFOwe.js";import"./useToast-BOur3mUv.js";import"./TruncatedFilePath-D7IoaWUW.js";import"./SafeScreenshot-CG2uh31y.js";import"./LibraryFunctionPreview-CnatsCw2.js";import"./scenarioStatus-B_8jpV3e.js";import"./triangle-alert-DTf3Jojp.js";import"./EntityTypeIcon-DN9eiJAO.js";import"./EntityTypeBadge-B-0PjGOU.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
+ 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};
@@ -0,0 +1 @@
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};