@codeyam/codeyam-cli 0.1.8 → 0.1.10
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.
- package/analyzer-template/.build-info.json +8 -8
- package/analyzer-template/log.txt +3 -3
- package/analyzer-template/package.json +4 -4
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlows.ts +0 -33
- package/analyzer-template/packages/analyze/src/lib/ProjectAnalyzer.ts +13 -7
- package/analyzer-template/packages/analyze/src/lib/asts/index.ts +7 -2
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.ts +0 -98
- package/analyzer-template/packages/aws/package.json +1 -1
- package/analyzer-template/packages/database/src/lib/kysely/tables/editorScenariosTable.ts +76 -0
- package/analyzer-template/packages/database/src/lib/loadEntities.ts +0 -6
- package/analyzer-template/packages/database/src/lib/updateCommitMetadata.ts +0 -65
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.d.ts +7 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.js +76 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.js +0 -6
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.js +0 -25
- package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.js.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/enums/ProjectFramework.d.ts +2 -0
- package/analyzer-template/packages/github/dist/types/src/enums/ProjectFramework.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/enums/ProjectFramework.js +2 -0
- package/analyzer-template/packages/github/dist/types/src/enums/ProjectFramework.js.map +1 -1
- package/analyzer-template/packages/types/src/enums/ProjectFramework.ts +2 -0
- package/analyzer-template/packages/ui-components/package.json +1 -1
- package/analyzer-template/packages/utils/dist/types/src/enums/ProjectFramework.d.ts +2 -0
- package/analyzer-template/packages/utils/dist/types/src/enums/ProjectFramework.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/enums/ProjectFramework.js +2 -0
- package/analyzer-template/packages/utils/dist/types/src/enums/ProjectFramework.js.map +1 -1
- package/codeyam-cli/src/__tests__/memory-scripts/filter-session.test.js +196 -0
- package/codeyam-cli/src/__tests__/memory-scripts/filter-session.test.js.map +1 -0
- package/codeyam-cli/src/__tests__/memory-scripts/read-json-field.test.js +114 -0
- package/codeyam-cli/src/__tests__/memory-scripts/read-json-field.test.js.map +1 -0
- package/codeyam-cli/src/__tests__/memory-scripts/ripgrep-fallback.test.js +149 -0
- package/codeyam-cli/src/__tests__/memory-scripts/ripgrep-fallback.test.js.map +1 -0
- package/codeyam-cli/src/commands/__tests__/editor.stepDispatch.test.js +45 -0
- package/codeyam-cli/src/commands/__tests__/editor.stepDispatch.test.js.map +1 -0
- package/codeyam-cli/src/commands/__tests__/init.gitignore.test.js +101 -47
- package/codeyam-cli/src/commands/__tests__/init.gitignore.test.js.map +1 -1
- package/codeyam-cli/src/commands/default.js +3 -46
- package/codeyam-cli/src/commands/default.js.map +1 -1
- package/codeyam-cli/src/commands/editor.js +1793 -257
- package/codeyam-cli/src/commands/editor.js.map +1 -1
- package/codeyam-cli/src/commands/init.js +67 -34
- package/codeyam-cli/src/commands/init.js.map +1 -1
- package/codeyam-cli/src/data/techStacks.js +77 -0
- package/codeyam-cli/src/data/techStacks.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/analyzerFinalization.test.js +173 -0
- package/codeyam-cli/src/utils/__tests__/analyzerFinalization.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/backgroundServer.test.js +46 -0
- package/codeyam-cli/src/utils/__tests__/backgroundServer.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/devServerState.test.js +134 -0
- package/codeyam-cli/src/utils/__tests__/devServerState.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorApi.test.js +137 -0
- package/codeyam-cli/src/utils/__tests__/editorApi.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorAudit.test.js +742 -1
- package/codeyam-cli/src/utils/__tests__/editorAudit.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/editorCapture.test.js +93 -0
- package/codeyam-cli/src/utils/__tests__/editorCapture.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorDevServer.test.js +181 -3
- package/codeyam-cli/src/utils/__tests__/editorDevServer.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/editorEntityChangeStatus.test.js +121 -0
- package/codeyam-cli/src/utils/__tests__/editorEntityChangeStatus.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorImageVerifier.test.js +294 -0
- package/codeyam-cli/src/utils/__tests__/editorImageVerifier.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorJournal.test.js +249 -2
- package/codeyam-cli/src/utils/__tests__/editorJournal.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/editorLoaderHelpers.test.js +520 -0
- package/codeyam-cli/src/utils/__tests__/editorLoaderHelpers.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorPreloadHelpers.test.js +118 -1
- package/codeyam-cli/src/utils/__tests__/editorPreloadHelpers.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/editorPreview.test.js +209 -3
- package/codeyam-cli/src/utils/__tests__/editorPreview.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/editorProxySession.test.js +153 -0
- package/codeyam-cli/src/utils/__tests__/editorProxySession.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorScenarioLookup.test.js +139 -0
- package/codeyam-cli/src/utils/__tests__/editorScenarioLookup.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorScenarioSwitch.test.js +221 -0
- package/codeyam-cli/src/utils/__tests__/editorScenarioSwitch.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorScenarios.test.js +985 -2
- package/codeyam-cli/src/utils/__tests__/editorScenarios.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/editorSeedAdapter.test.js +213 -0
- package/codeyam-cli/src/utils/__tests__/editorSeedAdapter.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/entityChangeStatus.test.js +1742 -0
- package/codeyam-cli/src/utils/__tests__/entityChangeStatus.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/journalCaptureStabilization.test.js +107 -0
- package/codeyam-cli/src/utils/__tests__/journalCaptureStabilization.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/parseRegisterArg.test.js +129 -0
- package/codeyam-cli/src/utils/__tests__/parseRegisterArg.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/scenarioCoverage.test.js +227 -0
- package/codeyam-cli/src/utils/__tests__/scenarioCoverage.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/scenariosManifest.test.js +454 -0
- package/codeyam-cli/src/utils/__tests__/scenariosManifest.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js +25 -5
- package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/templateConsistency.test.js +51 -0
- package/codeyam-cli/src/utils/__tests__/templateConsistency.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/webappDetection.test.js +142 -0
- package/codeyam-cli/src/utils/__tests__/webappDetection.test.js.map +1 -0
- package/codeyam-cli/src/utils/analyzer.js +9 -0
- package/codeyam-cli/src/utils/analyzer.js.map +1 -1
- package/codeyam-cli/src/utils/analyzerFinalization.js +100 -0
- package/codeyam-cli/src/utils/analyzerFinalization.js.map +1 -0
- package/codeyam-cli/src/utils/backgroundServer.js +94 -18
- package/codeyam-cli/src/utils/backgroundServer.js.map +1 -1
- package/codeyam-cli/src/utils/database.js +37 -2
- package/codeyam-cli/src/utils/database.js.map +1 -1
- package/codeyam-cli/src/utils/devServerState.js +71 -0
- package/codeyam-cli/src/utils/devServerState.js.map +1 -0
- package/codeyam-cli/src/utils/editorApi.js +79 -0
- package/codeyam-cli/src/utils/editorApi.js.map +1 -0
- package/codeyam-cli/src/utils/editorAudit.js +135 -7
- package/codeyam-cli/src/utils/editorAudit.js.map +1 -1
- package/codeyam-cli/src/utils/editorCapture.js +102 -0
- package/codeyam-cli/src/utils/editorCapture.js.map +1 -0
- package/codeyam-cli/src/utils/editorDevServer.js +100 -1
- package/codeyam-cli/src/utils/editorDevServer.js.map +1 -1
- package/codeyam-cli/src/utils/editorEntityChangeStatus.js +44 -0
- package/codeyam-cli/src/utils/editorEntityChangeStatus.js.map +1 -0
- package/codeyam-cli/src/utils/editorImageVerifier.js +155 -0
- package/codeyam-cli/src/utils/editorImageVerifier.js.map +1 -0
- package/codeyam-cli/src/utils/editorJournal.js +92 -4
- package/codeyam-cli/src/utils/editorJournal.js.map +1 -1
- package/codeyam-cli/src/utils/editorLoaderHelpers.js +113 -0
- package/codeyam-cli/src/utils/editorLoaderHelpers.js.map +1 -0
- package/codeyam-cli/src/utils/editorMockState.js +1 -1
- package/codeyam-cli/src/utils/editorPreloadHelpers.js +72 -1
- package/codeyam-cli/src/utils/editorPreloadHelpers.js.map +1 -1
- package/codeyam-cli/src/utils/editorPreview.js +72 -1
- package/codeyam-cli/src/utils/editorPreview.js.map +1 -1
- package/codeyam-cli/src/utils/editorScenarioSwitch.js +112 -0
- package/codeyam-cli/src/utils/editorScenarioSwitch.js.map +1 -0
- package/codeyam-cli/src/utils/editorScenarios.js +331 -0
- package/codeyam-cli/src/utils/editorScenarios.js.map +1 -1
- package/codeyam-cli/src/utils/editorSeedAdapter.js +173 -0
- package/codeyam-cli/src/utils/editorSeedAdapter.js.map +1 -0
- package/codeyam-cli/src/utils/entityChangeStatus.js +349 -0
- package/codeyam-cli/src/utils/entityChangeStatus.js.map +1 -0
- package/codeyam-cli/src/utils/entityChangeStatus.server.js +158 -0
- package/codeyam-cli/src/utils/entityChangeStatus.server.js.map +1 -0
- package/codeyam-cli/src/utils/install-skills.js +1 -1
- package/codeyam-cli/src/utils/install-skills.js.map +1 -1
- package/codeyam-cli/src/utils/parseRegisterArg.js +31 -0
- package/codeyam-cli/src/utils/parseRegisterArg.js.map +1 -0
- package/codeyam-cli/src/utils/progress.js +2 -2
- package/codeyam-cli/src/utils/progress.js.map +1 -1
- package/codeyam-cli/src/utils/scenarioCoverage.js +75 -0
- package/codeyam-cli/src/utils/scenarioCoverage.js.map +1 -0
- package/codeyam-cli/src/utils/scenariosManifest.js +241 -0
- package/codeyam-cli/src/utils/scenariosManifest.js.map +1 -0
- package/codeyam-cli/src/utils/serverState.js +30 -0
- package/codeyam-cli/src/utils/serverState.js.map +1 -1
- package/codeyam-cli/src/utils/setupClaudeCodeSettings.js +46 -16
- package/codeyam-cli/src/utils/setupClaudeCodeSettings.js.map +1 -1
- package/codeyam-cli/src/utils/simulationGateMiddleware.js +8 -1
- package/codeyam-cli/src/utils/simulationGateMiddleware.js.map +1 -1
- package/codeyam-cli/src/utils/slugUtils.js +25 -0
- package/codeyam-cli/src/utils/slugUtils.js.map +1 -0
- package/codeyam-cli/src/utils/syncMocksMiddleware.js +2 -2
- package/codeyam-cli/src/utils/syncMocksMiddleware.js.map +1 -1
- package/codeyam-cli/src/utils/webappDetection.js +21 -0
- package/codeyam-cli/src/utils/webappDetection.js.map +1 -1
- package/codeyam-cli/src/webserver/__tests__/clientErrors.test.js +40 -0
- package/codeyam-cli/src/webserver/__tests__/clientErrors.test.js.map +1 -0
- package/codeyam-cli/src/webserver/__tests__/editorProxy.test.js +567 -0
- package/codeyam-cli/src/webserver/__tests__/editorProxy.test.js.map +1 -0
- package/codeyam-cli/src/webserver/__tests__/idleDetector.test.js +146 -0
- package/codeyam-cli/src/webserver/__tests__/idleDetector.test.js.map +1 -0
- package/codeyam-cli/src/webserver/app/lib/clientErrors.js +65 -0
- package/codeyam-cli/src/webserver/app/lib/clientErrors.js.map +1 -0
- package/codeyam-cli/src/webserver/app/lib/git.js +397 -0
- package/codeyam-cli/src/webserver/app/lib/git.js.map +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{CopyButton-DmJveP3T.js → CopyButton-BPXZwM4t.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{EntityItem-C76mRRiF.js → EntityItem-BcgbViKV.js} +3 -3
- package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeIcon-CobE682z.js → EntityTypeIcon-CQIG2qda.js} +9 -9
- package/codeyam-cli/src/webserver/build/client/assets/{ReportIssueModal-djPLI-WV.js → ReportIssueModal-BzHcG7SE.js} +3 -3
- package/codeyam-cli/src/webserver/build/client/assets/{ScenarioViewer-B76aig_2.js → ScenarioViewer-TSD3C211.js} +3 -3
- package/codeyam-cli/src/webserver/build/client/assets/ViewportInspectBar-oAf2Kqsf.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{_index-C96V0n15.js → _index-DLxKhri3.js} +3 -3
- package/codeyam-cli/src/webserver/build/client/assets/{activity.(_tab)-BpKzcsJz.js → activity.(_tab)-BcY3q6nt.js} +6 -6
- package/codeyam-cli/src/webserver/build/client/assets/addon-canvas-DpzMmAy5.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/addon-fit-YJmn1quW.js +12 -0
- package/codeyam-cli/src/webserver/build/client/assets/addon-webgl-DI8QOUvO.js +58 -0
- package/codeyam-cli/src/webserver/build/client/assets/{agent-transcripts-D9hemwl6.js → agent-transcripts-Bni3iiUj.js} +5 -5
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-file-diff-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-file-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-project-info-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-scenario-coverage-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{book-open-D_nMCFmP.js → book-open-BYOypzCa.js} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/{chevron-down-BH2h1Ea2.js → chevron-down-C_Pmso5S.js} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/{circle-check-DyIKORY6.js → circle-check-BVMi9VA5.js} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/{copy-NDbZjXao.js → copy-n2FB0_Sw.js} +3 -3
- package/codeyam-cli/src/webserver/build/client/assets/createLucideIcon-CC6AbExI.js +41 -0
- package/codeyam-cli/src/webserver/build/client/assets/dev.empty-Ii3inc0_.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/editor-COWCNVyV.js +10 -0
- package/codeyam-cli/src/webserver/build/client/assets/editorPreview-CNB06EIa.js +41 -0
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha._-CrjR3zZW.js → entity._sha._-DwCV5__E.js} +3 -3
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.dev-CXSi2aeZ.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.fullscreen-CHMiAog3.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/{files-DO4CZ16O.js → files-BZrlFE1F.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/git-DdZcvjGh.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/globals-phvmGvat.css +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/index-yHOVb4rc.js +15 -0
- package/codeyam-cli/src/webserver/build/client/assets/{loader-circle-BAXYRVEO.js → loader-circle-DaAZ_H2w.js} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/manifest-6134dc40.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/memory-9gnxSZlb.js +101 -0
- package/codeyam-cli/src/webserver/build/client/assets/{pause-DTAcYxBt.js → pause-f5-1lKBt.js} +3 -3
- package/codeyam-cli/src/webserver/build/client/assets/root-BWAyuj0r.js +67 -0
- package/codeyam-cli/src/webserver/build/client/assets/{search-fKo7v0Zo.js → search-Di64LWVb.js} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/{settings-DfuTtcJP.js → settings-0OrEMU6J.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{simulations-B3aOzpCZ.js → simulations-DWT-CvLy.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{terminal-BG4heKCG.js → terminal-Br7MOqts.js} +3 -3
- package/codeyam-cli/src/webserver/build/client/assets/{triangle-alert-DtSmdtM4.js → triangle-alert-BLdiCuG-.js} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-C-_hOl_g.js +1 -0
- package/codeyam-cli/src/webserver/build/client/sound-test.html +98 -0
- package/codeyam-cli/src/webserver/build/server/assets/index-ChX0hPcu.js +1 -0
- package/codeyam-cli/src/webserver/build/server/assets/init-kSNsMjj8.js +10 -0
- package/codeyam-cli/src/webserver/build/server/assets/server-build-Bm2xIhmh.js +439 -0
- package/codeyam-cli/src/webserver/build/server/index.js +1 -1
- package/codeyam-cli/src/webserver/build-info.json +5 -5
- package/codeyam-cli/src/webserver/editorProxy.js +487 -50
- package/codeyam-cli/src/webserver/editorProxy.js.map +1 -1
- package/codeyam-cli/src/webserver/idleDetector.js +73 -0
- package/codeyam-cli/src/webserver/idleDetector.js.map +1 -0
- package/codeyam-cli/src/webserver/public/sound-test.html +98 -0
- package/codeyam-cli/src/webserver/scripts/codeyam-preload.mjs +242 -3
- package/codeyam-cli/src/webserver/scripts/journalCapture.ts +94 -4
- package/codeyam-cli/src/webserver/server.js +90 -16
- package/codeyam-cli/src/webserver/server.js.map +1 -1
- package/codeyam-cli/src/webserver/terminalServer.js +71 -34
- package/codeyam-cli/src/webserver/terminalServer.js.map +1 -1
- package/codeyam-cli/templates/chrome-extension-react/EXTENSION_SETUP.md +75 -0
- package/codeyam-cli/templates/chrome-extension-react/README.md +46 -0
- package/codeyam-cli/templates/chrome-extension-react/gitignore +15 -0
- package/codeyam-cli/templates/chrome-extension-react/index.html +12 -0
- package/codeyam-cli/templates/chrome-extension-react/package.json +27 -0
- package/codeyam-cli/templates/chrome-extension-react/popup.html +12 -0
- package/codeyam-cli/templates/chrome-extension-react/public/manifest.json +15 -0
- package/codeyam-cli/templates/chrome-extension-react/src/background/service-worker.ts +7 -0
- package/codeyam-cli/templates/chrome-extension-react/src/globals.css +6 -0
- package/codeyam-cli/templates/chrome-extension-react/src/lib/storage.ts +37 -0
- package/codeyam-cli/templates/chrome-extension-react/src/popup/App.tsx +12 -0
- package/codeyam-cli/templates/chrome-extension-react/src/popup/main.tsx +10 -0
- package/codeyam-cli/templates/chrome-extension-react/tsconfig.json +24 -0
- package/codeyam-cli/templates/chrome-extension-react/vite.config.ts +41 -0
- package/codeyam-cli/templates/codeyam-editor-claude.md +84 -5
- package/codeyam-cli/templates/editor-step-hook.py +98 -8
- package/codeyam-cli/templates/expo-react-native/MOBILE_SETUP.md +89 -0
- package/codeyam-cli/templates/expo-react-native/README.md +41 -0
- package/codeyam-cli/templates/expo-react-native/app/(tabs)/_layout.tsx +33 -0
- package/codeyam-cli/templates/expo-react-native/app/(tabs)/index.tsx +12 -0
- package/codeyam-cli/templates/expo-react-native/app/(tabs)/settings.tsx +12 -0
- package/codeyam-cli/templates/expo-react-native/app/_layout.tsx +12 -0
- package/codeyam-cli/templates/expo-react-native/app.json +18 -0
- package/codeyam-cli/templates/expo-react-native/babel.config.js +9 -0
- package/codeyam-cli/templates/expo-react-native/gitignore +12 -0
- package/codeyam-cli/templates/expo-react-native/global.css +3 -0
- package/codeyam-cli/templates/expo-react-native/lib/storage.ts +32 -0
- package/codeyam-cli/templates/expo-react-native/metro.config.js +6 -0
- package/codeyam-cli/templates/expo-react-native/nativewind-env.d.ts +1 -0
- package/codeyam-cli/templates/expo-react-native/package.json +38 -0
- package/codeyam-cli/templates/expo-react-native/tailwind.config.js +10 -0
- package/codeyam-cli/templates/expo-react-native/tsconfig.json +10 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/AUTH_PATTERNS.md +308 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/AUTH_UPGRADE.md +304 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/DATABASE.md +126 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/FEATURE_PATTERNS.md +37 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/README.md +53 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/app/codeyam-isolate/layout.tsx +12 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/app/lib/prisma.ts +9 -4
- package/codeyam-cli/templates/nextjs-prisma-sqlite/env +4 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/gitignore +21 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/package.json +5 -1
- package/codeyam-cli/templates/nextjs-prisma-sqlite/prisma/seed.ts +4 -1
- package/codeyam-cli/templates/nextjs-prisma-sqlite/seed-adapter.ts +92 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/vitest.config.ts +13 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/README.md +52 -0
- package/codeyam-cli/templates/{nextjs-prisma-sqlite/PRISMA_SETUP.md → nextjs-prisma-supabase/SUPABASE_SETUP.md} +37 -17
- package/codeyam-cli/templates/nextjs-prisma-supabase/app/api/todos/route.ts +17 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/app/globals.css +26 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/app/layout.tsx +34 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/app/lib/prisma.ts +20 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/app/lib/supabase.ts +12 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/app/page.tsx +10 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/env +9 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/eslint.config.mjs +11 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/gitignore +40 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/next.config.ts +11 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/package.json +37 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/postcss.config.mjs +7 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/prisma/schema.prisma +27 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/prisma/seed.ts +39 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/prisma.config.ts +12 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/tsconfig.json +34 -0
- package/codeyam-cli/templates/skills/codeyam-dev-mode/SKILL.md +2 -2
- package/codeyam-cli/templates/skills/codeyam-editor/SKILL.md +97 -17
- package/codeyam-cli/templates/skills/codeyam-memory/SKILL.md +10 -10
- package/codeyam-cli/templates/skills/codeyam-memory/scripts/holistic-analysis/detect-deprecated-patterns.mjs +139 -0
- package/codeyam-cli/templates/skills/codeyam-memory/scripts/holistic-analysis/find-exports.mjs +52 -0
- package/codeyam-cli/templates/skills/codeyam-memory/scripts/lib/read-json-field.mjs +61 -0
- package/codeyam-cli/templates/skills/codeyam-memory/scripts/lib/ripgrep-fallback.mjs +155 -0
- package/codeyam-cli/templates/skills/codeyam-memory/scripts/session-mining/cleanup.mjs +13 -0
- package/codeyam-cli/templates/skills/codeyam-memory/scripts/session-mining/filter-session.mjs +95 -0
- package/codeyam-cli/templates/skills/codeyam-memory/scripts/session-mining/preprocess.mjs +160 -0
- package/package.json +14 -9
- package/packages/ai/src/lib/generateExecutionFlows.js +0 -11
- package/packages/ai/src/lib/generateExecutionFlows.js.map +1 -1
- package/packages/analyze/src/lib/ProjectAnalyzer.js +10 -4
- package/packages/analyze/src/lib/ProjectAnalyzer.js.map +1 -1
- package/packages/analyze/src/lib/asts/index.js +4 -2
- package/packages/analyze/src/lib/asts/index.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js +0 -40
- package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js.map +1 -1
- package/packages/database/src/lib/kysely/tables/editorScenariosTable.js +76 -0
- package/packages/database/src/lib/kysely/tables/editorScenariosTable.js.map +1 -1
- package/packages/database/src/lib/loadEntities.js +0 -6
- package/packages/database/src/lib/loadEntities.js.map +1 -1
- package/packages/database/src/lib/updateCommitMetadata.js +0 -25
- package/packages/database/src/lib/updateCommitMetadata.js.map +1 -1
- package/packages/types/src/enums/ProjectFramework.js +2 -0
- package/packages/types/src/enums/ProjectFramework.js.map +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/Terminal-Dnj5CY9R.js +0 -41
- package/codeyam-cli/src/webserver/build/client/assets/addon-fit-CUXOrorO.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/createLucideIcon-CMT1jU2q.js +0 -21
- package/codeyam-cli/src/webserver/build/client/assets/dev.empty-BiM6z3Do.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/editor-D1DAKXtT.js +0 -8
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.dev-DkzqFzFj.js +0 -6
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.fullscreen-C28BiQzt.js +0 -6
- package/codeyam-cli/src/webserver/build/client/assets/git-CFCTYk9I.js +0 -15
- package/codeyam-cli/src/webserver/build/client/assets/globals-B17TBSS6.css +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/manifest-a632de18.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/memory-Dg0mvYrI.js +0 -96
- package/codeyam-cli/src/webserver/build/client/assets/root-DUKqhFlb.js +0 -67
- package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-ByhSyh0W.js +0 -1
- package/codeyam-cli/src/webserver/build/server/assets/index-HfLydfDq.js +0 -1
- package/codeyam-cli/src/webserver/build/server/assets/server-build-CUu_F-oo.js +0 -366
- package/codeyam-cli/templates/skills/codeyam-memory/scripts/holistic-analysis/detect-deprecated-patterns.sh +0 -108
- package/codeyam-cli/templates/skills/codeyam-memory/scripts/holistic-analysis/find-exports.sh +0 -69
- package/codeyam-cli/templates/skills/codeyam-memory/scripts/session-mining/cleanup.sh +0 -12
- package/codeyam-cli/templates/skills/codeyam-memory/scripts/session-mining/filter.jq +0 -45
- package/codeyam-cli/templates/skills/codeyam-memory/scripts/session-mining/preprocess.sh +0 -139
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-yHOVb4rc.js","assets/chunk-JZWAC4HX-C4pqxYJB.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var Mt=Object.defineProperty;var It=(t,s,a)=>s in t?Mt(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a;var qe=(t,s,a)=>It(t,typeof s!="symbol"?s+"":s,a);import{r as n,j as e,w as Et,u as Rt,b as $t}from"./chunk-JZWAC4HX-C4pqxYJB.js";import{u as Tt,C as Lt}from"./useCustomSizes-C-_hOl_g.js";import{g as Bt,s as At,r as Me,b as ce,c as _t,l as Dt,d as Ot,e as Ut,f as zt,a as Ft,T as Wt,D as Ht}from"./editorPreview-CNB06EIa.js";import{C as Ee}from"./CopyButton-BPXZwM4t.js";import{_ as Gt}from"./preload-helper-ckwbz45p.js";import{c as Jt}from"./cy-logo-cli-DcX-ZS3p.js";import{u as Vt,S as Ke}from"./Spinner-Bb5uFQ5V.js";import"./copy-n2FB0_Sw.js";import"./createLucideIcon-CC6AbExI.js";import"./useLastLogLine-C14nCb1q.js";const xe=[{name:"Desktop",width:1440,height:900},{name:"Laptop",width:1024,height:768},{name:"Tablet",width:768,height:1024},{name:"Mobile",width:375,height:667}];function Yt(t){if(!t)return xe;const s=Object.entries(t).map(([i,h])=>({name:i,width:h.width,height:h.height})),a=new Set(s.map(i=>i.name));return[...s,...xe.filter(i=>!a.has(i.name))]}function Re(t){const[s,a]=n.useState(null),[i,h]=n.useState(!1),d=n.useCallback(()=>{t&&(h(!0),fetch(`/api/editor-test-results?testFile=${encodeURIComponent(t)}`).then(c=>c.json()).then(c=>{a(c),h(!1)}).catch(()=>{a({testFilePath:t,status:"error",testCases:[],errorMessage:"Failed to fetch test results"}),h(!1)}))},[t]);return n.useEffect(()=>{t&&d()},[t,d]),{results:s,isRunning:i,runTests:d}}function Q(t){if(!t||t==="/")return"Home";const s=t.split("?")[0].replace(/^\//,"");if(!s)return"Home";const a=s.split("/")[0];return a.charAt(0).toUpperCase()+a.slice(1)}function $e(t){return t?t.includes("/isolated-components"):!1}function qt(t,s){return!s||Object.keys(s).length===0?t:t.filter(a=>s[a.name])}function ne({imgSrc:t,name:s,isActive:a,onSelect:i}){return e.jsxs("button",{onClick:i,className:"flex flex-col items-center gap-1 cursor-pointer group",title:s,children:[e.jsx("div",{className:`w-32 h-32 rounded overflow-hidden border-2 transition-all bg-[#1a1a1a] ${a?"border-[#005c75] ring-1 ring-[#005c75]":"border-transparent hover:border-[#4d4d4d]"}`,children:t?e.jsx("img",{src:t,alt:s,className:"w-full h-full object-contain",loading:"lazy"}):e.jsx("div",{className:"w-full h-full bg-[#1a1a1a] flex items-center justify-center",children:e.jsx("span",{className:"text-[8px] text-gray-600",children:"No img"})})}),e.jsx("span",{className:`text-[10px] leading-tight text-center truncate w-32 ${a?"text-white":"text-gray-500 group-hover:text-gray-300"}`,children:s})]})}function Ie({testFile:t,entityName:s}){const{results:a,isRunning:i,runTests:h}=Re(t);if(i&&!a)return e.jsxs("div",{className:"px-2 pt-1 flex items-center gap-1.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[#005c75] animate-pulse"}),e.jsx("span",{className:"text-[10px] text-gray-400",children:"Running tests..."})]});if(!a)return null;if(a.status==="error")return e.jsx("div",{className:"px-2 pt-1",children:e.jsx("span",{className:"text-[10px] text-red-400",children:a.errorMessage})});const d=s?a.testCases.filter(u=>u.fullName.startsWith(s)):a.testCases,c=d.length>0?d:a.testCases;if(c.length===0)return null;const x=s?`${s} > `:"";return e.jsxs("div",{className:"px-2 pt-1 space-y-0.5",children:[c.map(u=>{var S;const k=x&&u.fullName.startsWith(x)?u.fullName.slice(x.length):u.fullName;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[u.status==="passed"?e.jsx("span",{className:"text-green-400 text-[10px]",children:"✓"}):u.status==="failed"?e.jsx("span",{className:"text-red-400 text-[10px]",children:"✗"}):e.jsx("span",{className:"text-gray-500 text-[10px]",children:"—"}),e.jsx("span",{className:`text-[10px] ${u.status==="passed"?"text-green-400":u.status==="failed"?"text-red-400":"text-gray-500"}`,children:k})]}),u.status==="failed"&&((S=u.failureMessages)==null?void 0:S.map((N,w)=>e.jsx("div",{className:"pl-4 text-[9px] text-red-300/70 truncate max-w-full",title:N,children:N.split(`
|
|
3
|
+
`)[0]},w)))]},u.fullName)}),e.jsx("button",{onClick:h,disabled:i,className:"mt-1 text-[10px] text-[#00a0c4] hover:text-[#00c4ee] transition-colors cursor-pointer disabled:opacity-50 bg-transparent border-none p-0",children:i?"Running...":"Re-run"})]})}function Y({filePath:t}){return t?e.jsxs("div",{className:"flex items-center gap-1 px-2 mt-0.5",children:[e.jsxs("a",{href:`/api/editor-file?path=${encodeURIComponent(t)}`,target:"_blank",rel:"noopener noreferrer",title:"Open file",className:"flex items-center gap-1 text-gray-500 hover:text-gray-300 transition-colors min-w-0",children:[e.jsx("span",{className:"text-[9px] truncate",children:t}),e.jsx("svg",{className:"shrink-0",width:"10",height:"10",viewBox:"0 0 12 12",fill:"none",children:e.jsx("path",{d:"M4.5 1.5H2.5C1.95 1.5 1.5 1.95 1.5 2.5V9.5C1.5 10.05 1.95 10.5 2.5 10.5H9.5C10.05 10.5 10.5 10.05 10.5 9.5V7.5M7.5 1.5H10.5M10.5 1.5V4.5M10.5 1.5L5 7",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})})]}),e.jsx(Ee,{content:t,icon:!0,iconSize:10,className:"shrink-0 text-gray-500 hover:text-gray-300 transition-colors"})]}):null}function Kt({scenarios:t,projectRoot:s,activeScenarioId:a,onScenarioSelect:i,zoomComponent:h,onZoomChange:d,analyzedEntities:c=[],glossaryFunctions:x=[],activeAnalyzedScenarioId:u,onAnalyzedScenarioSelect:k,entityImports:S,pageFilePaths:N={}}){const{pageGroups:w,componentGroups:E}=n.useMemo(()=>{var m;const f=new Map,l=new Map;for(const p of t)if(p.componentName){const o=l.get(p.componentName)||[];o.push(p),l.set(p.componentName,o)}else if($e(p.url)){const o=(m=p.url)==null?void 0:m.match(/[?&]c=([^&]+)/),y=o?decodeURIComponent(o[1]):"Isolated",C=l.get(y)||[];C.push(p),l.set(y,C)}else{const o=Q(p.url),y=f.get(o)||[];y.push(p),f.set(o,y)}const j=new Map([...l.entries()].sort(([p],[o])=>p.localeCompare(o)));return{pageGroups:f,componentGroups:j}},[t]),v=n.useMemo(()=>{const f=new Set((c||[]).filter(j=>j.entityType==="visual").map(j=>j.name)),l=new Map;for(const[j,m]of E)f.has(j)||l.set(j,m);return l},[E,c]),{visualEntities:D,libraryEntities:O}=n.useMemo(()=>{const f=c.filter(j=>j.entityType==="visual").sort((j,m)=>j.name.localeCompare(m.name)),l=c.filter(j=>j.entityType==="library"||j.entityType==="functionCall").sort((j,m)=>j.name.localeCompare(m.name));return{visualEntities:f,libraryEntities:l}},[c]),R=n.useMemo(()=>{const f=new Set(O.map(l=>l.name));return x.filter(l=>!f.has(l.name)).sort((l,j)=>l.name.localeCompare(j.name))},[x,O]),z=c.some(f=>f.isAnalyzing),P=n.useRef(null),I=n.useRef(0),_=n.useCallback(()=>{P.current&&(I.current=P.current.scrollTop)},[]);if(n.useEffect(()=>{P.current&&I.current>0&&(P.current.scrollTop=I.current)}),t.length===0&&c.length===0&&R.length===0)return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center text-gray-500 px-8",children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"No scenarios yet"}),e.jsx("p",{className:"text-xs",children:"Scenarios will appear here as Claude creates them alongside your code. Each scenario represents a different state of your app's data."})]})});if(h){const f=E.get(h)||[],l=new Set((S==null?void 0:S[h])||[]),j=l.size>0,m=j?D.filter(o=>l.has(o.name)):[],p=j?O.filter(o=>l.has(o.name)):[];return e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsxs("div",{className:"p-3 space-y-1",children:[e.jsxs("button",{onClick:()=>d(void 0),className:"w-full flex items-center gap-2 px-3 py-1.5 text-xs text-gray-400 hover:text-white transition-colors cursor-pointer",children:[e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",className:"shrink-0",children:e.jsx("path",{d:"M7.5 9L4.5 6L7.5 3",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),"All scenarios"]}),e.jsx("div",{className:"px-3 py-1.5",children:e.jsx("span",{className:"text-xs font-semibold text-white uppercase tracking-wider",children:h})}),e.jsx("div",{className:"flex flex-wrap gap-2 px-2",children:f.length===0?e.jsx("div",{className:"px-3 py-2 text-xs text-gray-500",children:"No scenarios for this component"}):f.map(o=>e.jsx(ne,{imgSrc:o.screenshotPath?`/api/editor-scenario-image/${o.id}.png${o.updatedAt?`?v=${encodeURIComponent(o.updatedAt)}`:""}`:null,name:o.name,isActive:o.id===a,onSelect:()=>i(o)},o.id))}),m.length>0&&e.jsxs("div",{className:"pt-2 mt-1 border-t border-[#3d3d3d]",children:[e.jsx("div",{className:"px-2 py-1",children:e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Components"})}),m.map(o=>e.jsxs("div",{className:"mt-2",children:[e.jsx("div",{className:"flex items-center gap-2 px-2 py-1",children:e.jsx("button",{onClick:()=>d(o.name),className:"text-[11px] font-medium text-gray-400 truncate cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:o.name})}),e.jsx(Y,{filePath:o.filePath,projectRoot:s}),(o.scenarios.length>0||o.pendingScenarios.length>0)&&e.jsx("div",{className:"flex flex-wrap gap-2 px-2 pt-1",children:o.scenarios.map(y=>e.jsx(ne,{imgSrc:y.screenshotPath?`/api/screenshot/${y.screenshotPath}`:null,name:y.name,isActive:y.id===u,onSelect:()=>k==null?void 0:k({analysisId:o.analysisId,scenarioId:y.id,scenarioName:y.name,entitySha:o.sha,entityName:o.name})},y.id))})]},o.sha))]}),p.length>0&&e.jsxs("div",{className:"pt-2 mt-1",children:[e.jsx("div",{className:"px-2 py-1",children:e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Functions"})}),p.map(o=>e.jsxs("div",{className:"mt-2",children:[e.jsx("div",{className:"px-2 py-1",children:e.jsx("span",{className:"text-[11px] font-medium text-gray-300",children:o.name})}),e.jsx(Y,{filePath:o.filePath,projectRoot:s}),o.testFile&&e.jsx(Ie,{testFile:o.testFile,entityName:o.name})]},o.sha))]})]})})}return e.jsx("div",{ref:P,onScroll:_,className:"flex-1 overflow-auto",children:e.jsxs("div",{className:"p-3 space-y-3",children:[w.size>0&&e.jsxs("div",{children:[e.jsx("div",{className:"px-2 py-1",children:e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Application"})}),[...w.entries()].sort(([f],[l])=>f==="Home"?-1:l==="Home"?1:f.localeCompare(l)).map(([f,l])=>e.jsxs("div",{className:"px-2 pt-1",children:[e.jsx("div",{className:"py-0.5",children:e.jsx("span",{className:"text-[11px] font-medium text-gray-400",children:f})}),N[f]&&e.jsx(Y,{filePath:N[f],projectRoot:s}),e.jsx("div",{className:"flex flex-wrap gap-2 pt-1",children:l.map(j=>e.jsx(ne,{imgSrc:j.screenshotPath?`/api/editor-scenario-image/${j.id}.png${j.updatedAt?`?v=${encodeURIComponent(j.updatedAt)}`:""}`:null,name:j.name,isActive:j.id===a&&!u,onSelect:()=>i(j)},j.id))})]},f))]}),v.size>0&&e.jsxs("div",{className:"pt-2 mt-1 border-t border-[#3d3d3d]",children:[e.jsx("div",{className:"px-2 py-1",children:e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Components"})}),[...v.entries()].map(([f,l])=>{var j;return e.jsxs("div",{className:"mt-2",children:[e.jsx("div",{className:"flex items-center justify-between px-2 py-1",children:e.jsx("button",{onClick:()=>d(f),className:"text-[11px] font-medium text-gray-400 truncate cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:f})}),((j=l[0])==null?void 0:j.componentPath)&&e.jsx(Y,{filePath:l[0].componentPath,projectRoot:s}),e.jsx("div",{className:"flex flex-wrap gap-2 px-2 pt-1",children:l.map(m=>e.jsx(ne,{imgSrc:m.screenshotPath?`/api/editor-scenario-image/${m.id}.png${m.updatedAt?`?v=${encodeURIComponent(m.updatedAt)}`:""}`:null,name:m.name,isActive:m.id===a&&!u,onSelect:()=>i(m)},m.id))})]},f)})]}),D.length>0&&e.jsxs("div",{className:"pt-2 mt-1 border-t border-[#3d3d3d]",children:[e.jsxs("div",{className:"px-2 py-1",children:[e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Components"}),z&&t.length===0&&c.every(f=>f.scenarioCount===0)&&e.jsx("span",{className:"ml-2 text-[10px] text-gray-500",children:"— Entities are being analyzed..."})]}),D.map(f=>e.jsxs("div",{className:"mt-2",children:[e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1",children:[e.jsx("button",{onClick:()=>d(f.name),className:"text-[11px] font-medium text-gray-400 truncate cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:f.name}),f.isAnalyzing&&f.scenarioCount===0&&e.jsxs("span",{className:"flex items-center gap-1.5 text-[10px] text-gray-400",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[#005c75] animate-pulse"}),"Analyzing..."]})]}),e.jsx(Y,{filePath:f.filePath,projectRoot:s}),(f.scenarios.length>0||f.pendingScenarios.length>0)&&e.jsxs("div",{className:"flex flex-wrap gap-2 px-2 pt-1",children:[f.scenarios.map(l=>e.jsx(ne,{imgSrc:l.screenshotPath?`/api/screenshot/${l.screenshotPath}`:null,name:l.name,isActive:l.id===u,onSelect:()=>k==null?void 0:k({analysisId:f.analysisId,scenarioId:l.id,scenarioName:l.name,entitySha:f.sha,entityName:f.name})},l.id)),f.pendingScenarios.map(l=>e.jsx("div",{className:"px-2.5 py-1 bg-[#2a2a2a] text-gray-400 text-[10px] rounded-full",title:l,children:l},l))]})]},f.sha))]}),(O.length>0||R.length>0)&&e.jsxs("div",{className:`pt-2 mt-1 ${D.length>0?"":"border-t border-[#3d3d3d]"}`,children:[e.jsx("div",{className:"px-2 py-1",children:e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Functions"})}),O.map(f=>e.jsxs("div",{className:"mt-2",children:[e.jsxs("div",{className:"px-2 py-1",children:[e.jsx("span",{className:"text-[11px] font-medium text-gray-300",children:f.name}),f.isAnalyzing&&f.scenarioCount===0&&e.jsxs("span",{className:"ml-2 inline-flex items-center gap-1.5 text-[10px] text-gray-400",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[#005c75] animate-pulse"}),"Analyzing..."]})]}),e.jsx(Y,{filePath:f.filePath,projectRoot:s}),f.testFile?e.jsx(Ie,{testFile:f.testFile,entityName:f.name}):e.jsx("div",{className:"px-2 pt-1",children:e.jsx("span",{className:"text-[10px] text-gray-500",children:"No test file"})})]},f.sha)),R.map(f=>e.jsxs("div",{className:"mt-2",children:[e.jsx("div",{className:"px-2 py-1",children:e.jsx("span",{className:"text-[11px] font-medium text-gray-300",children:f.name})}),e.jsx(Y,{filePath:f.filePath,projectRoot:s}),e.jsx(Ie,{testFile:f.testFile,entityName:f.name})]},f.name))]})]})})}function Xt(t,s,a=new Date){const i={"1d":1,"3d":3,"7d":7,"30d":30}[s],h=new Date(a);h.setDate(h.getDate()-i);const d=h.toISOString().split("T")[0],c=t.filter(N=>N.date>=d),x=new Set(c.map(N=>N.commitSha).filter(Boolean)),u=new Map;for(const N of c)if(N.scenarioScreenshots)for(const w of N.scenarioScreenshots){u.has(w.name)||u.set(w.name,[]);const E=u.get(w.name);E.some(v=>v.path===w.path)||E.push({path:w.path,time:N.time})}for(const N of u.values())N.sort((w,E)=>w.time.localeCompare(E.time));const k=[],S=new Map;for(const[N,w]of u){const E=N.indexOf(" - ");if(E!==-1){const v=N.slice(0,E);S.has(v)||S.set(v,[]),S.get(v).push({name:N,screenshots:w})}else k.push({name:N,screenshots:w})}return{commitCount:x.size,entryCount:c.length,appScenarios:k,componentGroups:S,totalScenarios:u.size}}function Qt(t){const s=new Map;for(const a of[...t].reverse()){const i=s.get(a.date)||[];i.push(a),s.set(a.date,i)}return s}function Zt(t){const s=new Map;for(const a of t){let i;if("componentName"in a&&a.componentName)i=a.componentName;else if("componentName"in a&&a.componentName===null)i="App";else{const d=a.name.indexOf(" - ");i=d!==-1?a.name.slice(0,d):"App"}const h=s.get(i)||[];h.push(a),s.set(i,h)}return[...s.entries()].sort(([a],[i])=>a==="App"?-1:i==="App"?1:a.localeCompare(i))}const Xe=120;function ot({text:t,theme:s}){const[a,i]=n.useState(!1),h=t.length>Xe,d=h&&!a?t.slice(0,Xe)+"…":t,c=s==="light";return e.jsxs("div",{className:`px-4 py-2 ${c?"border-b border-gray-200 bg-gray-50":"border-b border-[#3d3d3d] bg-[#252525]"}`,children:[e.jsx("span",{className:"text-[9px] font-semibold uppercase tracking-wider text-gray-500",children:"User Prompt"}),e.jsxs("p",{className:`text-[11px] mt-0.5 mb-0 leading-relaxed ${c?"text-gray-600":"text-gray-400"}`,children:[d,h&&e.jsx("button",{onClick:()=>i(!a),className:`ml-1 text-[11px] font-medium bg-transparent border-none p-0 cursor-pointer ${c?"text-blue-500 hover:text-blue-700":"text-[#00a0c4] hover:text-[#00c0e8]"}`,children:a?"Show less":"Read more…"})]})]})}function Qe({status:t}){const s={new:{label:"New",bg:"bg-green-900/40",text:"text-green-400",border:"border-green-700/50"},edited:{label:"Edited",bg:"bg-blue-900/40",text:"text-blue-400",border:"border-blue-700/50"},impacted:{label:"Impacted",bg:"bg-amber-900/40",text:"text-amber-400",border:"border-amber-700/50"}}[t.status];return e.jsx("span",{className:`${s.bg} ${s.text} ${s.border} border text-[8px] font-bold px-1 py-0 rounded-full uppercase tracking-wider`,children:s.label})}function es({testFile:t,entityName:s}){const{results:a,isRunning:i,runTests:h}=Re(t);if(i&&!a)return e.jsxs("div",{className:"pt-1 flex items-center gap-1.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[#00a0c4] animate-pulse"}),e.jsx("span",{className:"text-[10px] text-gray-500",children:"Running tests..."})]});if(!a)return null;if(a.status==="error")return e.jsx("div",{className:"pt-1",children:e.jsx("span",{className:"text-[10px] text-red-400",children:a.errorMessage})});const d=s?a.testCases.filter(u=>u.fullName.startsWith(s)):a.testCases,c=d.length>0?d:a.testCases;if(c.length===0)return null;const x=s?`${s} > `:"";return e.jsxs("div",{className:"pt-1 space-y-0.5",children:[c.map(u=>{var S;const k=x&&u.fullName.startsWith(x)?u.fullName.slice(x.length):u.fullName;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[u.status==="passed"?e.jsx("span",{className:"text-green-400 text-[10px]",children:"✓"}):u.status==="failed"?e.jsx("span",{className:"text-red-400 text-[10px]",children:"✗"}):e.jsx("span",{className:"text-gray-500 text-[10px]",children:"—"}),e.jsx("span",{className:`text-[10px] ${u.status==="passed"?"text-green-400":u.status==="failed"?"text-red-400":"text-gray-500"}`,children:k})]}),u.status==="failed"&&((S=u.failureMessages)==null?void 0:S.map((N,w)=>e.jsx("div",{className:"pl-4 text-[9px] text-red-400/70 truncate max-w-full",title:N,children:N.split(`
|
|
4
|
+
`)[0]},w)))]},u.fullName)}),e.jsx("button",{onClick:h,disabled:i,className:"mt-1 text-[10px] text-[#00a0c4] hover:text-[#38bdf8] transition-colors cursor-pointer disabled:opacity-50 bg-transparent border-none p-0",children:i?"Running...":"Re-run"})]})}const ts={added:"text-green-400",untracked:"text-green-400",modified:"text-blue-400",renamed:"text-purple-400"};function ss({files:t}){return e.jsxs("div",{className:"border-t border-[#3d3d3d] pt-2 mt-1",children:[e.jsxs("span",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider",children:["Modified Files (",t.length,")"]}),e.jsx("div",{className:"mt-1 space-y-0.5 max-h-[150px] overflow-auto",children:t.map(s=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:`text-[9px] font-bold uppercase w-[14px] text-center ${ts[s.status]||"text-gray-500"}`,children:s.status==="added"||s.status==="untracked"?"A":s.status==="modified"?"M":s.status==="renamed"?"R":"?"}),e.jsx("span",{className:"text-[10px] text-gray-400 truncate font-mono",children:s.path})]},s.path))})]})}const as={feature:{label:"Feature",color:"bg-[#005c75]"},fix:{label:"Fix",color:"bg-amber-700"},refactor:{label:"Refactor",color:"bg-purple-700"},scaffold:{label:"Scaffold",color:"bg-green-700"},data:{label:"Data",color:"bg-blue-700"},milestone:{label:"Milestone",color:"bg-yellow-600"}};function ns(t){try{return new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}}function rs(t){try{return new Date(t+"T00:00:00").toLocaleDateString([],{weekday:"long",month:"long",day:"numeric"})}catch{return t}}const is=[{value:"1d",label:"1 Day"},{value:"3d",label:"3 Days"},{value:"7d",label:"1 Week"},{value:"30d",label:"1 Month"}];function ls({entries:t,onScreenshotClick:s}){const[a,i]=n.useState(!1),[h,d]=n.useState("7d"),c=n.useMemo(()=>Xt(t,h),[t,h]);return e.jsxs("div",{className:"bg-[#2d2d2d] rounded-lg overflow-hidden",children:[e.jsxs("button",{onClick:()=>i(!a),className:"w-full flex items-center justify-between px-3 py-2.5 cursor-pointer bg-transparent border-none text-left hover:bg-[#333] transition-colors",children:[e.jsx("span",{className:"text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"Timeframe Summary"}),e.jsx("span",{className:`text-gray-500 text-[10px] transition-transform ${a?"rotate-180":""}`,children:"▼"})]}),a&&e.jsxs("div",{className:"px-3 pb-3 space-y-3 border-t border-[#3d3d3d]",children:[e.jsx("div",{className:"flex gap-1 pt-2.5",children:is.map(x=>e.jsx("button",{onClick:()=>d(x.value),className:`px-2.5 py-1 text-[10px] font-medium rounded transition-colors cursor-pointer border ${h===x.value?"bg-[#005c75] text-white border-[#005c75]":"bg-transparent text-gray-400 border-[#4d4d4d] hover:text-white hover:border-[#005c75]"}`,children:x.label},x.value))}),e.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-gray-400",children:[e.jsxs("span",{children:[e.jsx("span",{className:"text-white font-medium",children:c.commitCount})," ",c.commitCount===1?"commit":"commits"]}),e.jsx("span",{className:"text-[#3d3d3d]",children:"|"}),e.jsxs("span",{children:[e.jsx("span",{className:"text-white font-medium",children:c.totalScenarios})," ",c.totalScenarios===1?"scenario changed":"scenarios changed"]}),e.jsx("span",{className:"text-[#3d3d3d]",children:"|"}),e.jsxs("span",{children:[e.jsx("span",{className:"text-white font-medium",children:c.entryCount})," ",c.entryCount===1?"entry":"entries"]})]}),c.totalScenarios===0?e.jsx("p",{className:"text-[11px] text-gray-500 italic m-0",children:"No scenario changes in this period."}):e.jsxs("div",{className:"space-y-3",children:[c.appScenarios.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("span",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider",children:"Application"}),c.appScenarios.map(x=>e.jsx(Ze,{scenario:x,onScreenshotClick:s},x.name))]}),c.componentGroups.size>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("span",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider",children:"Components"}),[...c.componentGroups.entries()].sort(([x],[u])=>x.localeCompare(u)).map(([x,u])=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("span",{className:"text-[10px] font-medium text-gray-400",children:x}),u.map(k=>e.jsx(Ze,{scenario:k,onScreenshotClick:s},k.name))]},x))]})]})]})]})}function Ze({scenario:t,onScreenshotClick:s}){const a=t.name.indexOf(" - "),i=a!==-1?t.name.slice(a+3):t.name;return e.jsxs("div",{className:"pl-2",children:[e.jsx("span",{className:"text-[10px] text-gray-500 block mb-1",children:i}),e.jsx("div",{className:"flex items-center gap-1 overflow-x-auto",children:t.screenshots.map((h,d)=>e.jsxs("div",{className:"flex items-center shrink-0",children:[d>0&&e.jsx("span",{className:"text-[8px] text-gray-600 mx-0.5",children:"→"}),e.jsx("button",{type:"button",className:"w-16 h-16 rounded overflow-hidden border border-[#3d3d3d] hover:border-[#00a0c4] bg-[#1e1e1e] shrink-0 flex items-center justify-center cursor-pointer transition-colors",title:`${t.name} (${new Date(h.time).toLocaleDateString()})`,onClick:()=>s==null?void 0:s({screenshotUrl:`/api/editor-journal-image/${h.path.replace("screenshots/","")}`,commitSha:null,commitMessage:null,scenarioName:t.name}),children:e.jsx("img",{src:`/api/editor-journal-image/${h.path.replace("screenshots/","")}`,alt:t.name,className:"max-w-full max-h-full object-contain",loading:"lazy"})})]},h.path))})]})}function os({isActive:t,onScreenshotClick:s,glossaryFunctions:a=[]}){const[i,h]=n.useState([]),[d,c]=n.useState(!0),[x,u]=n.useState(new Set),k=n.useCallback(w=>{u(E=>{const v=new Set(E);return v.has(w)?v.delete(w):v.add(w),v})},[]),S=n.useCallback(async()=>{try{const w=await fetch("/api/editor-journal");if(w.ok){const E=await w.json();h(E.entries||[])}}catch{}finally{c(!1)}},[]);if(n.useEffect(()=>{S()},[S]),n.useEffect(()=>{t&&S()},[t,S]),n.useEffect(()=>{if(!t)return;const w=setInterval(()=>void S(),5e3);return()=>clearInterval(w)},[t,S]),d)return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx("span",{className:"text-gray-500 text-sm",children:"Loading journal..."})});if(i.length===0)return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center text-gray-500 px-8",children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"No journal entries yet"}),e.jsx("p",{className:"text-xs",children:"Journal entries will appear as you build. Claude records features, screenshots, and commits as the project evolves."})]})});const N=Qt(i);return e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsx(ls,{entries:i,onScreenshotClick:s}),[...N.entries()].map(([w,E])=>e.jsxs("div",{children:[e.jsx("div",{className:"px-3 py-1.5 sticky top-0 bg-[#1e1e1e] z-10",children:e.jsx("span",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider",children:rs(w)})}),e.jsx("div",{className:"space-y-2",children:E.map((v,D)=>{const O=as[v.type]||{label:v.type,color:"bg-gray-600"},R=`${v.time}-${D}`,z=x.has(R);return e.jsxs("div",{className:"bg-[#2d2d2d] rounded-lg overflow-hidden",children:[e.jsxs("div",{className:`p-3 space-y-2 ${z?"":"max-h-[300px] overflow-y-auto"}`,children:[e.jsx("div",{className:"flex items-start gap-2 cursor-pointer",onClick:()=>k(R),children:e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-white truncate",children:v.title}),e.jsx("span",{className:`${O.color} text-white text-[9px] font-bold px-1.5 py-0.5 rounded uppercase tracking-wider shrink-0`,children:O.label})]}),e.jsx("span",{className:"text-[10px] text-gray-500",children:ns(v.time)}),v.featureName&&e.jsx("span",{className:"text-[10px] text-gray-500 italic truncate",title:v.featureName,children:v.featureName})]})}),v.userPrompt&&e.jsx(ot,{text:v.userPrompt,theme:"dark"}),e.jsx("p",{className:"text-xs text-gray-400 leading-relaxed",children:v.description}),v.screenshot&&e.jsx("button",{type:"button",className:"rounded overflow-hidden border border-[#3d3d3d] hover:border-[#00a0c4] bg-[#1e1e1e] flex items-center justify-center p-1 cursor-pointer transition-colors w-full",onClick:()=>s==null?void 0:s({screenshotUrl:`/api/editor-journal-image/${v.screenshot.replace("screenshots/","")}`,commitSha:v.commitSha,commitMessage:v.commitMessage,scenarioName:v.title}),children:e.jsx("img",{src:`/api/editor-journal-image/${v.screenshot.replace("screenshots/","")}`,alt:v.title,className:"max-w-full max-h-full object-contain",loading:"lazy"})}),v.scenarioScreenshots&&v.scenarioScreenshots.length>0&&(()=>{const P=Zt(v.scenarioScreenshots),I=v.entityChangeStatus,_=P.filter(([p])=>p==="App").flatMap(([,p])=>p),f=P.filter(([p])=>p!=="App"),l=new Map;for(const p of _){const o=Q(p.url??null),y=l.get(o)||[];y.push(p),l.set(o,y)}const j=[...l.entries()],m=p=>e.jsx("button",{type:"button",className:"w-[4.5rem] h-[4.5rem] rounded overflow-hidden border border-[#3d3d3d] hover:border-[#00a0c4] bg-[#1e1e1e] shrink-0 flex items-center justify-center cursor-pointer transition-colors",onClick:()=>s==null?void 0:s({screenshotUrl:`/api/editor-journal-image/${p.path.replace("screenshots/","")}`,commitSha:v.commitSha,commitMessage:v.commitMessage,scenarioName:p.name}),children:e.jsx("img",{src:`/api/editor-journal-image/${p.path.replace("screenshots/","")}`,alt:p.name,title:p.name,className:"max-w-full max-h-full object-contain",loading:"lazy"})},p.path);return e.jsxs("div",{className:"space-y-2",children:[j.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("span",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider",children:"Application"}),j.map(([p,o])=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[10px] font-medium text-gray-400",children:p}),(I==null?void 0:I[p])&&e.jsx(Qe,{status:I[p]})]}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-0.5",children:o.map(m)})]},p))]}),f.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("span",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider",children:"Components"}),f.map(([p,o])=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[10px] font-medium text-gray-400",children:p}),(I==null?void 0:I[p])&&e.jsx(Qe,{status:I[p]})]}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-0.5",children:o.map(m)})]},p))]})]})})(),a.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("span",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider",children:"Functions"}),e.jsx("div",{className:"space-y-2",children:a.map(P=>e.jsxs("div",{children:[e.jsx("span",{className:"text-[11px] font-medium text-gray-200",children:P.name}),e.jsx("span",{className:"text-[9px] text-gray-500 truncate block",children:P.filePath}),P.testFile?e.jsx(es,{testFile:P.testFile,entityName:P.name}):e.jsx("div",{className:"pt-1",children:e.jsx("span",{className:"text-[10px] text-gray-500",children:"No test file"})})]},P.name))})]}),v.commitSha&&e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px]",children:[e.jsx("span",{className:"font-mono text-[#00a0c4] bg-[#00a0c4]/10 px-1.5 py-0.5 rounded",children:v.commitSha.slice(0,7)}),e.jsx("span",{className:"text-gray-500 truncate",children:v.commitMessage})]}),z&&v.modifiedFiles&&v.modifiedFiles.length>0&&e.jsx(ss,{files:v.modifiedFiles})]}),e.jsxs("button",{onClick:()=>k(R),className:"w-full py-1.5 text-[10px] text-gray-500 hover:text-gray-300 border-t border-[#3d3d3d] transition-colors cursor-pointer",children:["——— ",z?"Collapse":"Expand"," ———"]})]},R)})})]},w))]})})}const et=()=>e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",className:"text-gray-500 shrink-0",children:e.jsx("path",{d:"M4.5 3L7.5 6L4.5 9",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})});function cs(t,s){if(t.length<=s)return t;const a=s-2;return[t[0],"ellipsis",...t.slice(t.length-a)]}function ds({items:t,onNavigate:s}){if(t.length===0)return null;const a=cs(t,4);return e.jsx("nav",{className:"flex items-center gap-1 text-xs min-w-0",children:a.map((i,h)=>{if(i==="ellipsis")return e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(et,{}),e.jsx("span",{className:"text-gray-500",children:"..."})]},"ellipsis");const d=h===a.length-1;return e.jsxs("span",{className:"flex items-center gap-1 min-w-0",children:[h>0&&e.jsx(et,{}),d?e.jsx("span",{className:"text-white font-medium truncate",children:i.name}):e.jsx("button",{onClick:()=>s(i.componentName),className:"text-gray-400 hover:text-white transition-colors cursor-pointer bg-transparent border-none p-0 truncate",children:i.name})]},i.componentName||"app")})})}function re({imgSrc:t,name:s,isActive:a,onSelect:i}){return e.jsxs("button",{onClick:i,className:"flex flex-col items-center gap-1 cursor-pointer group w-full",title:s,children:[e.jsx("div",{className:`w-full aspect-square rounded overflow-hidden border-2 transition-all bg-[#1a1a1a] ${a?"border-[#005c75] ring-1 ring-[#005c75]":"border-transparent hover:border-[#4d4d4d]"}`,children:t?e.jsx("img",{src:t,alt:s,className:"w-full h-full object-contain",loading:"lazy"}):e.jsx("div",{className:"w-full h-full bg-[#1a1a1a] flex items-center justify-center",children:e.jsx("span",{className:"text-[8px] text-gray-600",children:"No img"})})}),e.jsx("span",{className:`text-[10px] leading-tight text-center truncate w-full ${a?"text-white":"text-gray-500 group-hover:text-gray-300"}`,children:s})]})}function de({filePath:t}){return t?e.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[e.jsxs("a",{href:`/api/editor-file?path=${encodeURIComponent(t)}`,target:"_blank",rel:"noopener noreferrer",title:"Open file",className:"flex items-center gap-1 text-gray-500 hover:text-gray-300 transition-colors min-w-0",children:[e.jsx("span",{className:"text-[9px] truncate",children:t}),e.jsx("svg",{className:"shrink-0",width:"10",height:"10",viewBox:"0 0 12 12",fill:"none",children:e.jsx("path",{d:"M4.5 1.5H2.5C1.95 1.5 1.5 1.95 1.5 2.5V9.5C1.5 10.05 1.95 10.5 2.5 10.5H9.5C10.05 10.5 10.5 10.05 10.5 9.5V7.5M7.5 1.5H10.5M10.5 1.5V4.5M10.5 1.5L5 7",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})})]}),e.jsx(Ee,{content:t,icon:!0,iconSize:10,className:"shrink-0 text-gray-500 hover:text-gray-300 transition-colors"})]}):null}function xs({hasProject:t,scenarios:s,analyzedEntities:a,glossaryFunctions:i=[],glossaryEntries:h=[],projectRoot:d,activeScenarioId:c,onScenarioSelect:x,onAnalyzedScenarioSelect:u,onSwitchToBuild:k,zoomComponent:S,onZoomChange:N,entityImports:w,pageFilePaths:E={},projectTitle:v,projectDescription:D,breadcrumbItems:O=[]}){const{pageGroups:R,componentGroups:z}=n.useMemo(()=>{var y;const m=new Map,p=new Map;for(const C of s)if(C.componentName){const A=p.get(C.componentName)||[];A.push(C),p.set(C.componentName,A)}else if($e(C.url)){const A=(y=C.url)==null?void 0:y.match(/[?&]c=([^&]+)/),F=A?decodeURIComponent(A[1]):"Isolated",H=p.get(F)||[];H.push(C),p.set(F,H)}else{const A=Q(C.url),F=m.get(A)||[];F.push(C),m.set(A,F)}const o=new Map([...p.entries()].sort(([C],[A])=>C.localeCompare(A)));return{pageGroups:m,componentGroups:o}},[s]),P=n.useMemo(()=>a.filter(m=>m.entityType==="visual").sort((m,p)=>m.name.localeCompare(p.name)),[a]),I=n.useMemo(()=>{const m=new Map;for(const p of i)m.set(p.name,p);return m},[i]),_=n.useRef(null),f=n.useRef(0),l=n.useCallback(()=>{_.current&&(f.current=_.current.scrollTop)},[]);if(n.useEffect(()=>{_.current&&f.current>0&&(_.current.scrollTop=f.current)}),!t)return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx("h2",{className:"text-lg font-medium text-white font-['IBM_Plex_Sans'] m-0",children:"Ready to build something?"}),e.jsx("button",{onClick:k,className:"px-6 py-3 bg-[#005c75] text-white text-sm font-medium rounded-lg hover:bg-[#004d63] transition-colors cursor-pointer",children:"Start Building"})]})});if(!(s.length>0||P.length>0))return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-4 px-8 text-center",children:[v?e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"text-lg font-medium text-white font-['IBM_Plex_Sans'] m-0",children:v}),D&&e.jsx("p",{className:"text-sm text-gray-400 m-0 font-['IBM_Plex_Sans'] leading-relaxed",children:D})]}):e.jsx("h2",{className:"text-lg font-medium text-white font-['IBM_Plex_Sans'] m-0",children:"Your project is ready"}),e.jsx("p",{className:"text-sm text-gray-400 m-0 font-['IBM_Plex_Sans'] leading-relaxed",children:"Describe what you want to build in the Chat and your pages and components will appear here."}),e.jsx("button",{onClick:k,className:"px-6 py-3 bg-[#005c75] text-white text-sm font-medium rounded-lg hover:bg-[#004d63] transition-colors cursor-pointer",children:"Start Building"})]})});if(S){const m=R.get(S)||[],p=z.get(S)||[],o=P.find(g=>g.name===S),y=I.get(S),C=[...m,...p],A=new Set((w==null?void 0:w[S])||[]),F=A.size>0,H=F?[...z.entries()].filter(([g])=>A.has(g)):[],Z=F?P.filter(g=>A.has(g.name)&&!H.some(([T])=>T===g.name)):[],q=F?h.filter(g=>A.has(g.name)&&g.returnType!=="JSX.Element"&&g.returnType!=="React.ReactNode").map(g=>({name:g.name,filePath:g.filePath,description:g.description||"",testFile:g.testFile,feature:g.feature})):[],ie=H.length>0||Z.length>0,le=q.length>0,me=ie||le;return e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsx(ds,{items:O,onNavigate:N}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold text-white m-0 font-['IBM_Plex_Sans'] uppercase tracking-wider",children:S}),(()=>{const g=(y==null?void 0:y.filePath)||(o==null?void 0:o.filePath)||E[S];return g?e.jsx(de,{filePath:g,projectRoot:d}):null})()]}),C.length>0&&e.jsx("div",{className:"grid grid-cols-3 gap-2",children:C.map(g=>e.jsx(re,{imgSrc:g.screenshotPath?`/api/editor-scenario-image/${g.id}.png${g.updatedAt?`?v=${encodeURIComponent(g.updatedAt)}`:""}`:null,name:g.name,isActive:g.id===c,onSelect:()=>x(g)},g.id))}),o&&(o.scenarios.length>0||o.pendingScenarios.length>0)&&e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[o.scenarios.map(g=>e.jsx(re,{imgSrc:g.screenshotPath?`/api/screenshot/${g.screenshotPath}`:null,name:g.name,isActive:!1,onSelect:()=>u({analysisId:o.analysisId,scenarioId:g.id,scenarioName:g.name,entitySha:o.sha,entityName:o.name})},g.id)),o.pendingScenarios.map(g=>e.jsx("div",{className:"px-2.5 py-1 bg-[#2a2a2a] text-gray-400 text-[10px] rounded-full",title:g,children:g},g))]}),y&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[10px] text-gray-500",children:"Tests:"}),e.jsx(de,{filePath:y.testFile,projectRoot:d})]}),C.length===0&&!o&&!y&&e.jsx("div",{className:"text-xs text-gray-500",children:"No scenarios for this entity"}),me&&e.jsxs("div",{className:"pt-3 mt-2 border-t border-[#3d3d3d] space-y-3",children:[ie&&e.jsxs("div",{children:[e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Components"}),H.map(([g,T])=>e.jsxs("div",{className:"mt-3",children:[e.jsx("div",{className:"py-1",children:e.jsx("button",{onClick:()=>N(g),className:"text-[11px] font-medium text-gray-400 cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:g})}),T.length>0&&e.jsx("div",{className:"grid grid-cols-3 gap-2 pt-1",children:T.map(L=>e.jsx(re,{imgSrc:L.screenshotPath?`/api/editor-scenario-image/${L.id}.png${L.updatedAt?`?v=${encodeURIComponent(L.updatedAt)}`:""}`:null,name:L.name,isActive:L.id===c,onSelect:()=>x(L)},L.id))})]},g)),Z.map(g=>e.jsxs("div",{className:"mt-3",children:[e.jsx("div",{className:"py-1",children:e.jsx("button",{onClick:()=>N(g.name),className:"text-[11px] font-medium text-gray-400 cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:g.name})}),(g.scenarios.length>0||g.pendingScenarios.length>0)&&e.jsxs("div",{className:"grid grid-cols-3 gap-2 pt-1",children:[g.scenarios.map(T=>e.jsx(re,{imgSrc:T.screenshotPath?`/api/screenshot/${T.screenshotPath}`:null,name:T.name,isActive:!1,onSelect:()=>u({analysisId:g.analysisId,scenarioId:T.id,scenarioName:T.name,entitySha:g.sha,entityName:g.name})},T.id)),g.pendingScenarios.map(T=>e.jsx("div",{className:"px-2.5 py-1 bg-[#2a2a2a] text-gray-400 text-[10px] rounded-full",title:T,children:T},T))]})]},g.sha))]}),le&&e.jsxs("div",{children:[e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Functions"}),q.map(g=>e.jsxs("div",{className:"mt-2",children:[e.jsx("div",{className:"py-1",children:e.jsx("button",{onClick:()=>N(g.name),className:"text-[11px] font-medium text-gray-400 cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:g.name})}),e.jsx(de,{filePath:g.filePath,projectRoot:d}),g.testFile&&e.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[e.jsx("span",{className:"text-[9px] text-gray-600",children:"test:"}),e.jsx("span",{className:"text-[9px] text-gray-500 truncate",children:g.testFile})]})]},g.name))]})]})]})})}return e.jsx("div",{ref:_,onScroll:l,className:"flex-1 overflow-auto",children:e.jsxs("div",{className:"p-4 space-y-4",children:[v&&e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-white m-0 font-['IBM_Plex_Sans']",children:v}),D&&e.jsx("p",{className:"text-xs text-gray-400 m-0 mt-1 font-['IBM_Plex_Sans'] leading-relaxed",children:D})]}),R.size>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Application"}),e.jsx("button",{onClick:k,className:"px-2.5 py-1 text-[10px] font-medium text-gray-400 bg-[#2a2a2a] border border-[#4d4d4d] rounded hover:bg-[#333] hover:text-white hover:border-[#005c75] transition-colors cursor-pointer",children:"+ New Page"})]}),e.jsxs("p",{className:"text-[11px] text-gray-500 m-0 mt-1.5 font-['IBM_Plex_Sans'] leading-relaxed",children:["Select a page scenario below and switch to"," ",e.jsx("button",{onClick:k,className:"text-[#00a0c4] hover:text-[#00c4eb] bg-transparent border-none p-0 cursor-pointer underline font-inherit text-inherit",children:"Build"})," ","to change or enhance an existing page or"," ",e.jsx("button",{onClick:k,className:"text-[#00a0c4] hover:text-[#00c4eb] bg-transparent border-none p-0 cursor-pointer underline font-inherit text-inherit",children:"create a new page"})]}),[...R.entries()].sort(([m],[p])=>m==="Home"?-1:p==="Home"?1:m.localeCompare(p)).map(([m,p])=>e.jsxs("div",{className:"mt-2",children:[e.jsx("div",{className:"py-1",children:e.jsx("button",{onClick:()=>N(m),className:"text-[11px] font-medium text-gray-400 cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:m})}),E[m]&&e.jsx(de,{filePath:E[m],projectRoot:d}),e.jsx("div",{className:"grid grid-cols-3 gap-2 pt-1",children:p.map(o=>e.jsx(re,{imgSrc:o.screenshotPath?`/api/editor-scenario-image/${o.id}.png${o.updatedAt?`?v=${encodeURIComponent(o.updatedAt)}`:""}`:null,name:o.name,isActive:o.id===c,onSelect:()=>x(o)},o.id))})]},m))]})]})})}const tt={new:0,edited:1,impacted:2};function st({status:t,onClick:s}){const a={new:{label:"New",bg:"bg-green-100",text:"text-green-700",border:"border-green-200"},edited:{label:"Edited",bg:"bg-blue-100",text:"text-blue-700",border:"border-blue-200"},impacted:{label:"Impacted",bg:"bg-amber-100",text:"text-amber-700",border:"border-amber-200"}}[t.status],i=s&&(t.status==="edited"||t.status==="impacted");return e.jsx("button",{onClick:i?s:void 0,className:`${a.bg} ${a.text} ${a.border} border text-[9px] font-bold px-1.5 py-0.5 rounded-full uppercase tracking-wider shrink-0 ${i?"cursor-pointer hover:opacity-80 transition-opacity":"cursor-default"}`,children:a.label})}function at({filePath:t}){const[s,a]=n.useState(null),[i,h]=n.useState(!0),[d,c]=n.useState(null);return n.useEffect(()=>{Gt(()=>import("./index-yHOVb4rc.js"),__vite__mapDeps([0,1])).then(x=>{c(()=>x.default)})},[]),n.useEffect(()=>{h(!0),fetch(`/api/editor-file-diff?path=${encodeURIComponent(t)}`).then(x=>x.json()).then(x=>{a({oldContent:x.oldContent,newContent:x.newContent})}).catch(()=>{a(null)}).finally(()=>h(!1))},[t]),i?e.jsx("div",{className:"p-2 text-[10px] text-gray-400",children:"Loading diff..."}):!s||!d?e.jsx("div",{className:"p-2 text-[10px] text-gray-400",children:"Could not load diff"}):e.jsx("div",{className:"mt-2 border border-gray-200 rounded-lg overflow-hidden max-h-[300px] overflow-auto text-xs",children:e.jsx(d,{oldValue:s.oldContent,newValue:s.newContent,splitView:!1,useDarkTheme:!1,showDiffOnly:!0,styles:{contentText:{fontSize:"11px",lineHeight:"1.4"},line:{padding:"1px 8px",fontSize:"11px"}}})})}function nt({impactedBy:t,changedEntities:s}){return e.jsx("div",{className:"mt-2 bg-amber-50 border border-amber-200 rounded-lg p-2.5",children:t&&t.length>0?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-[10px] font-semibold text-amber-700 uppercase tracking-wider",children:"Re-captured because these dependencies changed"}),e.jsx("ul",{className:"mt-1.5 space-y-1",children:t.map(a=>e.jsxs("li",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:`text-[9px] font-bold px-1 py-0 rounded-full uppercase tracking-wider border ${a.changeType==="new"?"bg-green-100 text-green-700 border-green-200":"bg-blue-100 text-blue-700 border-blue-200"}`,children:a.changeType==="new"?"New":"Edited"}),e.jsx("span",{className:"text-[11px] font-medium text-amber-800",children:a.name}),e.jsx("span",{className:"text-[9px] text-amber-500 truncate",children:a.filePath})]},a.filePath))})]}):s&&s.length>0?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-[10px] font-semibold text-amber-700 uppercase tracking-wider",children:"Unchanged — these entities were modified in this session"}),e.jsx("ul",{className:"mt-1.5 space-y-1",children:s.map(a=>e.jsxs("li",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:`text-[9px] font-bold px-1 py-0 rounded-full uppercase tracking-wider border ${a.status==="new"?"bg-green-100 text-green-700 border-green-200":"bg-blue-100 text-blue-700 border-blue-200"}`,children:a.status==="new"?"New":"Edited"}),e.jsx("span",{className:"text-[11px] font-medium text-amber-800",children:a.name})]},a.name))})]}):e.jsx("span",{className:"text-[10px] text-amber-600",children:"This component was re-captured because a dependency changed"})})}function rt({scenarioId:t,name:s,isActive:a,onSelect:i,updatedAt:h}){const[d,c]=n.useState(!1);n.useEffect(()=>{c(!1)},[t]);const x=`/api/editor-scenario-image/${t}.png${h?`?v=${encodeURIComponent(h)}`:""}`;return e.jsxs("button",{onClick:i,className:"flex flex-col items-center gap-1.5 cursor-pointer group",title:s,children:[e.jsx("div",{className:`w-32 h-32 rounded-lg overflow-hidden border-2 transition-all ${a?"border-[#0ea5e9] ring-2 ring-[#0ea5e9]/40 shadow-lg shadow-[#0ea5e9]/20":"border-gray-200 hover:border-gray-400 shadow-sm"}`,children:d?e.jsx("div",{className:"w-full h-full bg-gray-100 flex items-center justify-center",children:e.jsx("span",{className:"text-[9px] text-gray-400",children:"No preview"})}):e.jsx("img",{src:x,alt:s,className:"w-full h-full object-contain bg-white",loading:"lazy",onError:()=>c(!0)})}),e.jsx("span",{className:`text-[11px] leading-tight text-center truncate w-32 font-medium ${a?"text-gray-900":"text-gray-600 group-hover:text-gray-900"}`,children:s})]})}function ms({filePath:t}){return t?e.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[e.jsxs("a",{href:`/api/editor-file?path=${encodeURIComponent(t)}`,target:"_blank",rel:"noopener noreferrer",title:"Open file",className:"flex items-center gap-1 text-gray-400 hover:text-gray-600 transition-colors min-w-0",children:[e.jsx("span",{className:"text-[9px] truncate",children:t}),e.jsx("svg",{className:"shrink-0",width:"10",height:"10",viewBox:"0 0 12 12",fill:"none",children:e.jsx("path",{d:"M4.5 1.5H2.5C1.95 1.5 1.5 1.95 1.5 2.5V9.5C1.5 10.05 1.95 10.5 2.5 10.5H9.5C10.05 10.5 10.5 10.05 10.5 9.5V7.5M7.5 1.5H10.5M10.5 1.5V4.5M10.5 1.5L5 7",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})})]}),e.jsx(Ee,{content:t,icon:!0,iconSize:10,className:"shrink-0 text-gray-400 hover:text-gray-600 transition-colors"})]}):null}function ps({testFile:t,entityName:s}){const{results:a,isRunning:i,runTests:h}=Re(t);if(i&&!a)return e.jsxs("div",{className:"pt-1 flex items-center gap-1.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[#0ea5e9] animate-pulse"}),e.jsx("span",{className:"text-[10px] text-gray-400",children:"Running tests..."})]});if(!a)return null;if(a.status==="error")return e.jsx("div",{className:"pt-1",children:e.jsx("span",{className:"text-[10px] text-red-500",children:a.errorMessage})});const d=s?a.testCases.filter(u=>u.fullName.startsWith(s)):a.testCases,c=d.length>0?d:a.testCases;if(c.length===0)return null;const x=s?`${s} > `:"";return e.jsxs("div",{className:"pt-1 space-y-0.5",children:[c.map(u=>{var S;const k=x&&u.fullName.startsWith(x)?u.fullName.slice(x.length):u.fullName;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[u.status==="passed"?e.jsx("span",{className:"text-green-600 text-[10px]",children:"✓"}):u.status==="failed"?e.jsx("span",{className:"text-red-500 text-[10px]",children:"✗"}):e.jsx("span",{className:"text-gray-400 text-[10px]",children:"—"}),e.jsx("span",{className:`text-[10px] ${u.status==="passed"?"text-green-600":u.status==="failed"?"text-red-500":"text-gray-400"}`,children:k})]}),u.status==="failed"&&((S=u.failureMessages)==null?void 0:S.map((N,w)=>e.jsx("div",{className:"pl-4 text-[9px] text-red-400 truncate max-w-full",title:N,children:N.split(`
|
|
5
|
+
`)[0]},w)))]},u.fullName)}),e.jsx("button",{onClick:h,disabled:i,className:"mt-1 text-[10px] text-[#0ea5e9] hover:text-[#38bdf8] transition-colors cursor-pointer disabled:opacity-50 bg-transparent border-none p-0",children:i?"Running...":"Re-run"})]})}function it(t){const s=t.indexOf(" - ");return s!==-1?t.slice(s+3):t}function lt(t,s){return!s||Object.keys(s).length===0?t:[...t].sort(([a],[i])=>{var x,u;const h=((x=s[a])==null?void 0:x.status)||"impacted",d=((u=s[i])==null?void 0:u.status)||"impacted",c=(tt[h]??2)-(tt[d]??2);return c!==0?c:a.localeCompare(i)})}function us({scenarios:t,allScenarios:s=[],glossaryFunctions:a=[],projectRoot:i,activeScenarioId:h,onScenarioSelect:d,onClose:c,entityChangeStatus:x={},modifiedFiles:u=[],featureName:k,userPrompt:S}){const N=n.useMemo(()=>{if(s.length===0||Object.keys(x).length===0)return t;const l=new Set(t.map(m=>m.id)),j=s.filter(m=>{var o;if(l.has(m.id))return!1;const p=m.componentName||Q(m.url);return((o=x[p])==null?void 0:o.status)==="impacted"});return j.length===0?t:[...t,...j]},[t,s,x]),w=n.useMemo(()=>Object.entries(x).filter(([,l])=>l.status==="new"||l.status==="edited").map(([l,j])=>({name:l,status:j.status})),[x]),[E,v]=n.useState(null),D=n.useCallback(l=>{v(j=>j===l?null:l)},[]),{pageGroups:O,componentGroups:R}=n.useMemo(()=>{var m;const l=new Map,j=new Map;for(const p of N)if(p.componentName){const o=j.get(p.componentName)||[];o.push(p),j.set(p.componentName,o)}else if($e(p.url)){const o=(m=p.url)==null?void 0:m.match(/[?&]c=([^&]+)/),y=o?decodeURIComponent(o[1]):"Isolated",C=j.get(y)||[];C.push(p),j.set(y,C)}else{const o=Q(p.url),y=l.get(o)||[];y.push(p),l.set(o,y)}return{pageGroups:l,componentGroups:j}},[N]),z=n.useMemo(()=>lt([...O.entries()],x),[O,x]),P=n.useMemo(()=>lt([...R.entries()],x),[R,x]),I=z,_=P,f=n.useMemo(()=>qt(a,x),[a,x]);return N.length===0&&a.length===0?e.jsxs("div",{className:"h-full bg-white flex items-center justify-center relative",children:[e.jsx("button",{onClick:c,className:"absolute top-2 right-3 text-gray-400 hover:text-gray-700 text-lg leading-none cursor-pointer bg-transparent border-none",title:"Close results",children:"×"}),e.jsx("span",{className:"text-sm text-gray-400",children:"No scenarios registered yet"})]}):e.jsxs("div",{className:"h-full bg-white flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 border-b border-gray-200 shrink-0",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Working Session Results"}),k&&e.jsx("div",{className:"text-[11px] text-gray-400 truncate",title:k,children:k})]}),e.jsx("button",{onClick:c,className:"text-gray-400 hover:text-gray-700 text-lg leading-none cursor-pointer bg-transparent border-none shrink-0",title:"Close results",children:"×"})]}),S&&e.jsx(ot,{text:S,theme:"light"}),e.jsx("div",{className:"flex-1 overflow-auto p-4",children:e.jsxs("div",{className:"space-y-5",children:[I.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"mb-2",children:e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Application"})}),e.jsx("div",{className:"space-y-3 pl-1",children:I.map(([l,j])=>{var y;const m=x[l],p=E===l,o=(y=j[0])==null?void 0:y.componentPath;return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1.5 flex items-center gap-2",children:[e.jsx("span",{className:"text-[11px] font-medium text-gray-600",children:l}),m&&e.jsx(st,{status:m,onClick:()=>D(l)})]}),p&&(m==null?void 0:m.status)==="edited"&&o&&e.jsx(at,{filePath:o}),p&&(m==null?void 0:m.status)==="impacted"&&e.jsx(nt,{impactedBy:m.impactedBy,changedEntities:w}),e.jsx("div",{className:"flex flex-wrap gap-3",children:j.map(C=>e.jsx(rt,{scenarioId:C.id,name:it(C.name),isActive:C.id===h,onSelect:()=>d(C),updatedAt:C.updatedAt},C.id))})]},l)})})]}),_.length>0&&e.jsxs("div",{className:I.length>0?"pt-3 border-t border-gray-200":"",children:[e.jsx("div",{className:"mb-2",children:e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Components"})}),e.jsx("div",{className:"space-y-3 pl-1",children:_.map(([l,j])=>{var y;const m=x[l],p=E===l,o=(y=j[0])==null?void 0:y.componentPath;return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1.5 flex items-center gap-2",children:[e.jsx("span",{className:"text-[11px] font-medium text-gray-600",children:l}),m&&e.jsx(st,{status:m,onClick:()=>D(l)})]}),p&&(m==null?void 0:m.status)==="edited"&&o&&e.jsx(at,{filePath:o}),p&&(m==null?void 0:m.status)==="impacted"&&e.jsx(nt,{impactedBy:m.impactedBy,changedEntities:w}),e.jsx("div",{className:"flex flex-wrap gap-3",children:j.map(C=>e.jsx(rt,{scenarioId:C.id,name:it(C.name),isActive:C.id===h,onSelect:()=>d(C),updatedAt:C.updatedAt},C.id))})]},l)})})]}),f.length>0&&e.jsxs("div",{className:I.length>0||_.length>0?"pt-3 border-t border-gray-200":"",children:[e.jsx("div",{className:"mb-2",children:e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Functions"})}),e.jsx("div",{className:"space-y-2 pl-1",children:f.map(l=>e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{className:"text-[11px] font-medium text-gray-700",children:l.name})}),e.jsx(ms,{filePath:l.filePath,projectRoot:i}),l.testFile?e.jsx(ps,{testFile:l.testFile,entityName:l.name}):e.jsx("div",{className:"pt-1",children:e.jsx("span",{className:"text-[10px] text-gray-400",children:"No test file"})})]},l.name))})]}),u.length>0&&e.jsxs("div",{className:I.length>0||_.length>0||f.length>0?"pt-3 border-t border-gray-200":"",children:[e.jsx("div",{className:"mb-2",children:e.jsxs("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:["Modified Files (",u.length,")"]})}),e.jsx("div",{className:"space-y-0.5 pl-1 max-h-[200px] overflow-auto",children:u.map(l=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:`text-[9px] font-bold uppercase w-[14px] text-center ${l.status==="added"||l.status==="untracked"?"text-green-600":l.status==="modified"?"text-blue-600":l.status==="renamed"?"text-purple-600":"text-gray-400"}`,children:l.status==="added"||l.status==="untracked"?"A":l.status==="modified"?"M":l.status==="renamed"?"R":"?"}),e.jsx("span",{className:"text-[10px] text-gray-500 truncate font-mono",children:l.path})]},l.path))})]})]})})]})}const hs=[{key:"app",label:"App"},{key:"build",label:"Build"},{key:"data",label:"Structure"},{key:"journal",label:"Journal"}];function fs({activeTab:t,onTabChange:s,buildIdle:a,zoomComponent:i,breadcrumbItems:h,onBreadcrumbNavigate:d,panelLayout:c,onToggleExpand:x}){return e.jsxs("div",{className:"bg-[#3d3d3d] h-10 flex items-center px-3 gap-3 shrink-0 z-20 border-b border-[#2d2d2d]",children:[e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx("img",{src:Jt,alt:"CodeYam",className:"h-5 brightness-0 invert"}),e.jsx("span",{className:"text-white font-medium text-xs whitespace-nowrap",children:"Codeyam Editor"})]}),e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx("div",{className:"flex items-center gap-0.5 bg-[#4a3232] rounded-lg p-0.5",children:hs.map(u=>e.jsxs("button",{onClick:()=>s(u.key),className:`px-2.5 py-1 text-xs font-medium rounded-md transition-colors cursor-pointer ${t===u.key?"bg-[#7a4444] text-white":"text-gray-300 hover:text-white"}`,children:[u.label,u.key==="build"&&a&&t!=="build"&&e.jsx("span",{className:"ml-1 inline-block w-1.5 h-1.5 rounded-full bg-amber-400 animate-pulse"})]},u.key))}),x&&e.jsx("button",{onClick:x,className:"p-1.5 rounded text-gray-400 hover:text-white transition-colors cursor-pointer",title:c==="editor-only"?"Show preview":"Hide preview",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:c==="editor-only"?e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),e.jsx("path",{d:"M9 3v18"}),e.jsx("path",{d:"M16 15l-3-3 3-3"})]}):e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),e.jsx("path",{d:"M9 3v18"}),e.jsx("path",{d:"M14 9l3 3-3 3"})]})})})]})]})}function gs({preview:t,onDismiss:s,onLoadCommit:a}){return e.jsxs("div",{className:"flex flex-col items-center gap-6 max-w-[700px] w-full",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("h2",{className:"text-lg font-semibold text-[#333] m-0 font-['IBM_Plex_Sans']",children:"Journal Screenshot"}),e.jsx("p",{className:"text-sm text-[#888] mt-1 m-0 font-['IBM_Plex_Sans']",children:"This is a snapshot from a previous version — not a live preview"})]}),e.jsx("div",{className:"rounded-lg overflow-hidden border-2 border-[#ccc] shadow-md max-w-full w-fit",children:e.jsx("img",{src:t.screenshotUrl,alt:t.scenarioName,className:"max-w-full h-auto block"})}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-[#666]",children:[t.commitSha&&e.jsx("span",{className:"font-mono text-xs text-[#00a0c4] bg-[#00a0c4]/15 px-2 py-0.5 rounded",children:t.commitSha.slice(0,7)}),e.jsxs("span",{className:"truncate",children:[t.scenarioName,t.commitMessage&&` — ${t.commitMessage}`]})]}),e.jsx("div",{className:"flex items-center gap-3",children:t.commitSha&&a&&e.jsx(js,{commitSha:t.commitSha,onLoadCommit:a})})]})}function js({commitSha:t,onLoadCommit:s}){const[a,i]=n.useState(!1),[h,d]=n.useState(null);return e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>{i(!0),d(null),s(t).then(c=>{c.success||d(c.error||"Failed to load commit")}).catch(c=>{d(c instanceof Error?c.message:"Network error")}).finally(()=>i(!1))},disabled:a,className:"bg-[#005c75] hover:bg-[#004d63] disabled:opacity-50 text-white text-sm font-medium px-4 py-1.5 rounded transition-colors cursor-pointer",children:a?"Reverting...":"Revert to this code and load this version"}),h&&e.jsx("div",{className:"bg-red-50 border border-red-200 rounded px-4 py-2 text-sm text-red-600 w-full text-center",children:h})]})}function vs({analysisId:t,scenarioId:s,scenarioName:a,entityName:i,projectSlug:h,onStateChange:d}){const{interactiveServerUrl:c,isStarting:x,isLoading:u}=Vt({analysisId:t,scenarioId:s,scenarioName:a,entityName:i,projectSlug:h,enabled:!0});return n.useEffect(()=>{d(c,x||u)},[c,x,u,d]),null}function bs(t,s){return s.status==="error"?{url:null,proxyUrl:null,isStarting:!1,error:s.errorMessage||"Dev server crashed",canStartServer:t.canStartServer,autoStartAttempted:t.autoStartAttempted,shouldAutoStart:!1}:s.url?{url:s.url,proxyUrl:s.proxyUrl||null,isStarting:!1,error:null,canStartServer:!0,autoStartAttempted:t.autoStartAttempted,shouldAutoStart:!1}:s.status==="starting"?{...t,isStarting:!0,error:null,canStartServer:!0,shouldAutoStart:!1}:s.status==="stopped"?t.url?{...t,url:null,isStarting:!1,shouldAutoStart:!1}:t.autoStartAttempted?{...t,isStarting:!1,shouldAutoStart:!1}:{...t,autoStartAttempted:!0,shouldAutoStart:!0}:{...t,shouldAutoStart:!1}}function Ns(){const[t,s]=n.useState({url:null,proxyUrl:null,isStarting:!1,error:null,canStartServer:!0,autoStartAttempted:!1}),a=n.useRef(t);a.current=t,n.useEffect(()=>{let d=!1,c=null;const x=async()=>{try{const u=await fetch("/api/editor-dev-server");if(d)return;const k=await u.json(),S=bs(a.current,k),{shouldAutoStart:N,...w}=S;if(s(w),N)try{const E=await fetch("/api/editor-dev-server",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"start"})});if(d)return;E.ok?s(v=>({...v,isStarting:!0})):s(v=>({...v,canStartServer:!1}))}catch{}}catch{}};return x(),c=setInterval(()=>void x(),2e3),()=>{d=!0,c&&clearInterval(c)}},[t.url]);const i=n.useCallback(()=>{s(d=>({...d,error:null,isStarting:!0})),fetch("/api/editor-dev-server",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"restart"})}).catch(()=>{})},[]),h=n.useCallback(()=>{s(d=>({...d,error:null,isStarting:!0})),fetch("/api/editor-dev-server",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"start"})}).catch(()=>{})},[]);return{devServerUrl:t.url,proxyUrl:t.proxyUrl,isStarting:t.isStarting,error:t.error,canStartServer:t.canStartServer,retryServer:i,startServer:h}}function ys(t){const s=n.useRef(null),a=n.useRef(null);n.useEffect(()=>{if(typeof document>"u")return;a.current||(a.current=document.createElement("canvas"),a.current.width=64,a.current.height=64);const i=document.querySelector('link[rel="icon"]');if(!i)return;if(s.current||(s.current=i.href),!t){i.href=s.current;return}const h=new Image;h.crossOrigin="anonymous",h.onload=()=>{const d=a.current,c=d.getContext("2d");c.clearRect(0,0,64,64),c.drawImage(h,0,0,64,64);const x=18,u=64-x,k=x;c.beginPath(),c.arc(u,k,x+3,0,2*Math.PI),c.fillStyle="#ffffff",c.fill(),c.beginPath(),c.arc(u,k,x,0,2*Math.PI),c.fillStyle="#ef4444",c.fill(),i.href=d.toDataURL("image/png")},h.src=s.current},[t]),n.useEffect(()=>()=>{if(typeof document>"u")return;const i=document.querySelector('link[rel="icon"]');i&&s.current&&(i.href=s.current)},[])}const Bs=()=>[{title:"Editor - CodeYam"},{name:"description",content:"CodeYam Code + Data Editor"}];class ws extends n.Component{constructor(){super(...arguments);qe(this,"state",{error:null,errorInfo:null})}static getDerivedStateFromError(a){return{error:a,errorInfo:null}}componentDidCatch(a,i){console.error("[EditorErrorBoundary] Error:",a.message),console.error("[EditorErrorBoundary] Component stack:",i.componentStack),console.error("[EditorErrorBoundary] Loader snapshot:",JSON.stringify(this.props.loaderSnapshot,null,2)),this.setState({errorInfo:i})}render(){var a;return this.state.error?e.jsx("div",{className:"fixed inset-0 bg-[#1e1e1e] flex items-center justify-center p-8",children:e.jsxs("div",{className:"max-w-[600px] w-full space-y-4",children:[e.jsx("h2",{className:"text-lg font-semibold text-red-400 font-['IBM_Plex_Sans'] m-0",children:"Something went wrong"}),e.jsx("pre",{className:"text-xs text-gray-300 bg-[#2d2d2d] p-3 rounded overflow-auto max-h-[120px]",children:this.state.error.message}),((a=this.state.errorInfo)==null?void 0:a.componentStack)&&e.jsxs("details",{className:"text-xs text-gray-500",children:[e.jsx("summary",{className:"cursor-pointer hover:text-gray-300 transition-colors",children:"Component stack"}),e.jsx("pre",{className:"mt-2 bg-[#2d2d2d] p-3 rounded overflow-auto max-h-[200px] text-yellow-300",children:this.state.errorInfo.componentStack})]}),e.jsx("p",{className:"text-xs text-gray-500 m-0",children:"Full diagnostics are in the browser console."}),e.jsx("button",{onClick:()=>window.location.reload(),className:"px-4 py-2 bg-[#005c75] text-white text-sm rounded hover:bg-[#004d63] transition-colors cursor-pointer",children:"Reload"})]})}):this.props.children}}const As=Et(function(){const{projectSlug:s,projectRoot:a,hasProject:i,scenarios:h,allScenarios:d,analyzedEntities:c,glossaryFunctions:x,glossaryEntries:u,entityImports:k,pageFilePaths:S,entityChangeStatus:N,modifiedFiles:w,featureName:E,userPrompt:v,projectTitle:D,projectDescription:O,defaultScreenSize:R,screenSizes:z}=Rt(),[P,I]=$t(),_=n.useRef(null),f=n.useRef(null),l=n.useRef(null),j=P.get("zoom")||void 0,m=P.get("scenario")||void 0,[p,o]=n.useState(()=>{if(typeof window>"u")return[];const r=new URLSearchParams(window.location.search).get("zoom");return r?[r]:[]}),y=n.useRef(null),C=n.useRef([]),A=n.useRef(null);n.useEffect(()=>{var B;const r=m||((B=Bt(d))==null?void 0:B.id);if(!At(r,y.current))return;const b=d.find(V=>V.id===r);if(!b)return;y.current=r;const M=Me(b,C.current,A.current);M&&K(M);const $=ce(b.name);fetch("/api/editor-switch-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioSlug:$,scenarioId:b.id,scenarioName:b.name,scenarioType:b.type})}).catch(()=>{})},[m,d]),n.useEffect(()=>{const r=new BroadcastChannel("codeyam-editor");return r.onmessage=b=>{var M;if(((M=b.data)==null?void 0:M.type)==="switch-scenario"&&b.data.scenarioId){const $=b.data.scenarioId,B=d.find(Pe=>Pe.id===$);if(!B)return;y.current=$;const V=new URLSearchParams(P);V.set("scenario",$),V.delete("zoom"),I(V),pe(null),oe(null),G(null),J(!0);const Pt=ce(B.name);fetch("/api/editor-switch-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioSlug:Pt,scenarioId:$,scenarioType:B.type})}).then(()=>{te(Pe=>Pe+1)}).catch(()=>{J(!1)})}},()=>r.close()},[P,I,d]),n.useEffect(()=>{if(P.get("ref")!=="link"||!m)return;const r=new BroadcastChannel("codeyam-editor");r.postMessage({type:"switch-scenario",scenarioId:m}),r.close(),window.close()},[]);const{devServerUrl:F,proxyUrl:H,isStarting:Z,error:q,canStartServer:ie,retryServer:le,startServer:me}=Ns(),[g,T]=n.useState(!1),[L,pe]=n.useState(null),[Te,oe]=n.useState(null),[ue,Le]=n.useState(!1),[he,G]=n.useState(null),ct=n.useCallback(async r=>{const M=await(await fetch("/api/editor-load-commit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({commitSha:r})})).json();return M.success&&(G(null),T(!1)),M},[]),dt=n.useCallback((r,b)=>{oe(M=>(r&&r!==M&&T(!1),r)),!b&&r&&T(!0),Le(b)},[]),Be=n.useCallback(r=>{G(null),pe(M=>(M&&M.analysisId===r.analysisId||(oe(null),te(B=>B+1)),r)),Le(!0),T(!1);const b=new URLSearchParams(P);b.delete("scenario"),b.delete("zoom"),I(b)},[P,I]),[U,K]=n.useState(R?{name:R.name,width:R.width,height:R.height}:{name:"Desktop",width:1440,height:900}),[Ae,_e]=n.useState(!1),De=R?{name:R.name,width:R.width,height:R.height}:null;A.current=De;const[W,fe]=n.useState("app"),xt=n.useCallback(()=>{fe("build"),ge(!0)},[]),[mt,ge]=n.useState(!1),[Oe,je]=n.useState(!1),pt=n.useCallback(r=>{je(r)},[]);ys(Oe);const[ee,Ue]=n.useState("split"),[ve,ze]=n.useState(!1),ut=n.useCallback(()=>{ze(!0),fe("build"),ge(!0)},[]),Fe=n.useCallback(()=>{ze(!1)},[]),ht=n.useCallback(r=>{K(r),fetch("/api/editor-project-info",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({defaultScreenSize:r,skipBroadcast:!0})})},[]),[We,He]=n.useState(_t);n.useEffect(()=>{const r=Dt();He(r),r.systemNotification&&typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission()},[]);const ft=n.useCallback(r=>{He(r),Ot(r)},[]);n.useEffect(()=>{if(W==="build"){je(!1);const r=setTimeout(()=>{var b,M;(b=_.current)==null||b.scrollToBottom(),(M=_.current)==null||M.focus()},50);return()=>clearTimeout(r)}},[W]),n.useEffect(()=>{function r(){!document.hidden&&W==="build"&&je(!1)}return document.addEventListener("visibilitychange",r),()=>document.removeEventListener("visibilitychange",r)},[W]);const[be,gt]=n.useState(null);n.useEffect(()=>{const r=l.current;if(!r)return;const b=new ResizeObserver(M=>{const $=M[0];$&>({width:$.contentRect.width,height:$.contentRect.height})});return b.observe(r),()=>b.disconnect()},[]);const X=n.useMemo(()=>be?Ut(be,U):1,[be,U]),[Ne,te]=n.useState(0),[Ge,ye]=n.useState(null),[Je,J]=n.useState(!1),jt=n.useCallback((r,b)=>{if(ye(r||null),b){const M=new URLSearchParams(P);M.set("scenario",b),y.current=b,I(M);const $=d.find(B=>B.id===b);if($){const B=Me($,C.current,A.current);B&&K(B)}}G(null),te(M=>M+1)},[P,I,d]),{customSizes:we,addCustomSize:vt,removeCustomSize:bt}=Tt(s),Se=n.useMemo(()=>Yt(z),[z]),ke=n.useMemo(()=>[...Se,...we],[Se,we]);C.current=ke;const Ve=n.useMemo(()=>{const r=[{name:"App"}];for(const b of p)r.push({name:b,componentName:b});return r},[p]),Ce=n.useCallback(r=>{const b=new URLSearchParams(P);if(r){b.set("zoom",r);const M=p.indexOf(r);M>=0?o(p.slice(0,M+1)):o([...p,r]);const $=d.find(B=>B.componentName===r||B.componentName===null&&Q(B.url)===r);if($){b.set("scenario",$.id),y.current=$.id,J(!0);const B=ce($.name);fetch("/api/editor-switch-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioSlug:B,scenarioId:$.id,scenarioType:$.type})}).then(()=>{te(V=>V+1)}).catch(()=>{J(!1)})}else b.delete("scenario")}else b.delete("zoom"),b.delete("scenario"),o([]);I(b)},[P,I,d,p]),se=n.useCallback(r=>{pe(null),oe(null),G(null),ye(null);const b=Me(r,ke,De);b&&K(b),y.current=r.id;const M=new URLSearchParams(P);M.set("scenario",r.id),I(M),J(!0);const $=ce(r.name);fetch("/api/editor-switch-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioSlug:$,scenarioId:r.id,scenarioType:r.type,skipBroadcast:!0})}).then(()=>{te(B=>B+1)}).catch(()=>{J(!1)})},[P,I,ke]),Nt=n.useCallback(r=>{if(!r.commitSha){const b=d.find(M=>M.name===r.scenarioName);if(b){se(b);return}}G(r)},[d,se]),yt=r=>{const b={name:r.name,width:r.width,height:r.height};K(b),fetch("/api/editor-project-info",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({defaultScreenSize:b,skipBroadcast:!0})})},wt=(r,b,M)=>{vt(r,b,M)},St=r=>{K(r),fetch("/api/editor-project-info",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({defaultScreenSize:r,skipBroadcast:!0})})},kt=()=>{L||T(!0),J(!1)},ae=n.useMemo(()=>zt({activeAnalyzedScenario:!!L,analyzedPreviewUrl:Te,activeScenarioId:m||null,scenarios:d,proxyUrl:H,devServerUrl:F,zoomComponent:j||null}),[H,F,j,m,d,L,Te]),Ye=n.useMemo(()=>{const r=Ft(ae,Ge);if(!r)return null;const b=r.includes("?")?"&":"?";return`${r}${b}__cb=${Ne}`},[ae,Ge,Ne]),Ct=n.useMemo(()=>({projectSlug:s,hasProject:i,scenarioCount:h==null?void 0:h.length,allScenarioCount:d==null?void 0:d.length,analyzedEntityCount:c==null?void 0:c.length,glossaryFunctionCount:x==null?void 0:x.length,entityChangeStatusKeys:N?Object.keys(N):[],featureName:E}),[s,i,h,d,c,x,N,E]);return e.jsx(ws,{loaderSnapshot:Ct,children:e.jsxs("div",{className:"fixed inset-0 bg-[#2d2d2d] flex flex-col",children:[L&&e.jsx(vs,{analysisId:L.analysisId,scenarioId:L.scenarioId,scenarioName:L.scenarioName,entityName:L.entityName,projectSlug:s,onStateChange:dt},L.analysisId),e.jsxs("div",{className:"flex-1 flex min-h-0",children:[e.jsxs("div",{className:"flex-1 flex flex-col min-w-0",style:ee==="editor-only"?{display:"none"}:void 0,children:[e.jsxs("div",{className:"bg-[#2d2d2d] border-b border-[#3d3d3d] shrink-0 z-10 h-10 flex items-center px-4 relative",children:[e.jsx("div",{className:"flex items-center gap-1 shrink-0 z-10",children:e.jsx("button",{onClick:()=>Ue(r=>r==="preview-only"?"split":"preview-only"),className:"p-1.5 rounded text-gray-500 hover:text-gray-300 transition-colors cursor-pointer",title:ee==="preview-only"?"Show sidebar":"Hide sidebar",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),e.jsx("path",{d:"M9 3v18"})]})})}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center gap-1 pointer-events-none",children:e.jsxs("div",{className:"flex items-center gap-1 pointer-events-auto",children:[xe.map(r=>e.jsxs("button",{onClick:()=>yt(r),className:`p-1.5 rounded transition-colors cursor-pointer ${U.name===r.name?"text-white bg-[#555]":"text-gray-500 hover:text-gray-300"}`,title:`${r.name} (${r.width}×${r.height})`,children:[r.name==="Desktop"&&e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2"}),e.jsx("path",{d:"M8 21h8M12 17v4"})]}),r.name==="Laptop"&&e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M4 6a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v8H4V6z"}),e.jsx("path",{d:"M2 18h20"})]}),r.name==="Tablet"&&e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"5",y:"2",width:"14",height:"20",rx:"2"}),e.jsx("path",{d:"M12 18h.01"})]}),r.name==="Mobile"&&e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"7",y:"2",width:"10",height:"20",rx:"2"}),e.jsx("path",{d:"M12 18h.01"})]})]},r.name)),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>_e(r=>!r),className:`flex items-center gap-1.5 px-2 py-1 rounded transition-colors cursor-pointer ${Ae||!xe.some(r=>r.name===U.name)?"text-white bg-[#555]":"text-gray-400 hover:text-gray-200 hover:bg-[#444]"}`,title:"Custom dimensions",children:[e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M17 3a2.83 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"})}),e.jsxs("span",{className:"text-xs font-mono",children:[U.width," ×"," ",U.height??900]})]}),Ae&&e.jsx(Lt,{currentWidth:U.width,currentHeight:U.height??900,devicePresets:Se,customSizes:we,onApply:St,onSave:wt,onRemove:bt,onClose:()=>_e(!1)})]})]})}),e.jsx("div",{className:"ml-auto flex items-center gap-1 shrink-0 z-10",children:e.jsx("button",{onClick:()=>{const r=Ye||ae;r&&window.open(r,"_blank")},className:"p-1.5 rounded text-gray-500 hover:text-gray-300 transition-colors cursor-pointer",title:"Open preview in new window",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),e.jsx("polyline",{points:"15 3 21 3 21 9"}),e.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]})})})]}),e.jsx("div",{ref:l,className:"flex-1 flex items-center justify-center overflow-hidden p-8",style:he?{backgroundColor:"#f5f0e8",backgroundImage:"repeating-linear-gradient(0deg, transparent, transparent 19px, #e8e0d0 19px, #e8e0d0 20px), repeating-linear-gradient(90deg, transparent, transparent 19px, #e8e0d0 19px, #e8e0d0 20px)"}:{backgroundImage:`
|
|
6
|
+
linear-gradient(45deg, #333 25%, transparent 25%),
|
|
7
|
+
linear-gradient(-45deg, #333 25%, transparent 25%),
|
|
8
|
+
linear-gradient(45deg, transparent 75%, #333 75%),
|
|
9
|
+
linear-gradient(-45deg, transparent 75%, #333 75%)
|
|
10
|
+
`,backgroundSize:"16px 16px",backgroundPosition:"0 0, 0 8px, 8px -8px, -8px 0px",backgroundColor:"#2d2d2d"},children:he?e.jsx(gs,{preview:he,onDismiss:()=>G(null),onLoadCommit:ct}):ae?e.jsx("div",{style:{width:`${U.width*X}px`,height:`${(U.height??900)*X}px`},children:e.jsxs("div",{className:"relative bg-white origin-top-left",style:{width:`${U.width}px`,height:`${U.height??900}px`,transform:X<1?`scale(${X})`:void 0},children:[!g&&!Je&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-10",children:e.jsxs("div",{className:"flex flex-col items-center justify-center gap-6 bg-[#2a2a2a] rounded-lg p-8 w-[500px] h-[300px]",children:[e.jsx("div",{className:"mb-4",children:e.jsx(Ke,{})}),e.jsxs("div",{className:"flex flex-col gap-3 text-center",children:[e.jsx("h2",{className:"text-xl font-medium text-gray-200 leading-[28px] m-0 font-['IBM_Plex_Sans']",children:"Loading Preview"}),e.jsx("p",{className:"text-sm text-gray-400 leading-5 m-0 font-['IBM_Plex_Sans']",children:"Waiting for the app to render"})]})]})}),Je&&e.jsx("div",{className:"absolute inset-0 z-20 flex items-center justify-center",style:{backgroundColor:"rgba(0, 0, 0, 0.25)",backdropFilter:"blur(1px)",transition:"opacity 200ms ease-out"},children:e.jsxs("div",{className:"flex flex-col items-center gap-3 animate-pulse",children:[e.jsx("svg",{className:"w-6 h-6 text-white/80 animate-spin",viewBox:"0 0 24 24",fill:"none",children:e.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeDasharray:"50 100"})}),e.jsx("span",{className:"text-white/70 text-xs font-['IBM_Plex_Sans']",children:"Switching scenario"})]})}),e.jsx("iframe",{ref:f,src:Ye||ae,className:"w-full h-full border-none",title:"Editor preview",onLoad:kt,style:{opacity:g?1:0}},Ne)]})}):e.jsx("div",{className:"bg-[#2a2a2a] rounded-lg flex flex-col items-center justify-center",style:{width:`${U.width*X}px`,height:`${(U.height??900)*X}px`},children:q?e.jsxs("div",{className:"flex flex-col gap-4 text-center px-8 max-w-[600px]",children:[e.jsx("h2",{className:"text-xl font-medium text-red-400 leading-[28px] m-0 font-['IBM_Plex_Sans']",children:"Dev Server Failed"}),e.jsx("pre",{className:"text-xs text-left bg-[#1e1e1e] text-gray-300 p-4 rounded overflow-auto max-h-[300px] w-full font-mono whitespace-pre-wrap",children:q}),e.jsx("button",{onClick:le,className:"mx-auto px-4 py-2 bg-[#005c75] text-white text-sm font-medium rounded hover:bg-[#004d63] transition-colors cursor-pointer",children:"Retry"})]}):Z||ue?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mb-4",children:e.jsx(Ke,{})}),e.jsxs("div",{className:"flex flex-col gap-3 text-center",children:[e.jsx("h2",{className:"text-xl font-medium text-gray-200 leading-[28px] m-0 font-['IBM_Plex_Sans']",children:ue?"Starting Interactive Mode":"Starting Dev Server"}),e.jsx("p",{className:"text-sm text-gray-400 leading-5 m-0 font-['IBM_Plex_Sans']",children:ue?"Loading component preview...":"Your dev server is starting up..."})]})]}):e.jsxs("div",{className:"flex flex-col gap-3 text-center px-8",children:[e.jsx("h2",{className:"text-xl font-medium text-gray-200 leading-[28px] m-0 font-['IBM_Plex_Sans']",children:"Live Preview"}),e.jsx("p",{className:"text-sm text-gray-500 leading-5 m-0 font-['IBM_Plex_Sans']",children:"Describe what you want to build in the Build tab"})]})})})]}),e.jsxs("aside",{className:`bg-[#1e1e1e] border-r border-[#3d3d3d] shrink-0 flex flex-col overflow-hidden order-first ${ee==="editor-only"?"w-full max-w-none min-w-0":"w-[50%] min-w-[400px] max-w-[800px]"}`,style:ee==="preview-only"?{display:"none"}:void 0,children:[e.jsx(fs,{activeTab:W,onTabChange:r=>{fe(r),r==="build"&&ge(!0)},buildIdle:Oe,zoomComponent:j,breadcrumbItems:Ve,onBreadcrumbNavigate:Ce,panelLayout:ee,onToggleExpand:()=>Ue(r=>r==="editor-only"?"split":"editor-only")}),e.jsxs("div",{className:"flex-1 overflow-hidden relative",children:[mt&&e.jsxs("div",{className:"absolute inset-0 flex flex-col overflow-hidden",style:{visibility:W==="build"?"visible":"hidden"},children:[e.jsx("div",{className:ve?"flex-1 min-h-0":"flex-1",style:ve?{flex:"1 1 50%"}:void 0,children:e.jsx(Wt,{ref:_,entityName:"Editor",projectSlug:s,entityFilePath:null,scenarioName:null,onRefreshPreview:jt,onShowResults:ut,onHideResults:Fe,onSetViewport:ht,editorMode:!0,onIdleChange:pt,notificationSettings:We})}),ve&&e.jsx("div",{style:{flex:"1 1 50%"},className:"min-h-0 border-t-2 border-gray-300",children:e.jsx(us,{scenarios:h,allScenarios:d,glossaryFunctions:x,projectRoot:a,activeScenarioId:m,onScenarioSelect:se,onClose:Fe,entityChangeStatus:N,modifiedFiles:w,featureName:E,userPrompt:v})})]}),e.jsx("div",{className:"absolute inset-0 flex flex-col overflow-hidden",style:{visibility:W==="app"?"visible":"hidden"},children:e.jsx(xs,{hasProject:i,scenarios:d,analyzedEntities:c,glossaryFunctions:x,glossaryEntries:u,projectRoot:a,activeScenarioId:m,onScenarioSelect:se,onAnalyzedScenarioSelect:Be,onSwitchToBuild:xt,zoomComponent:j,onZoomChange:Ce,entityImports:k,pageFilePaths:S,projectTitle:D,projectDescription:O,breadcrumbItems:Ve})}),e.jsx("div",{className:"absolute inset-0 flex flex-col overflow-hidden",style:{visibility:W==="data"?"visible":"hidden"},children:e.jsx(Kt,{scenarios:d,projectRoot:a,activeScenarioId:m,onScenarioSelect:se,zoomComponent:j,onZoomChange:Ce,analyzedEntities:[],glossaryFunctions:x,activeAnalyzedScenarioId:L==null?void 0:L.scenarioId,onAnalyzedScenarioSelect:Be,entityImports:k,pageFilePaths:S})}),e.jsx("div",{className:"absolute inset-0 flex flex-col overflow-hidden",style:{visibility:W==="journal"?"visible":"hidden"},children:e.jsx(os,{isActive:W==="journal",onScreenshotClick:Nt,glossaryFunctions:x})})]}),e.jsx(Ht,{serverUrl:F,isStarting:Z,projectSlug:s,devServerError:q,onStartServer:ie?me:void 0,notificationSettings:We,onChangeNotificationSettings:ft})]})]})]})})});export{As as default,Bs as meta};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/addon-web-links-Duc5hnl7.js","assets/chunk-JZWAC4HX-C4pqxYJB.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as u,j as a}from"./chunk-JZWAC4HX-C4pqxYJB.js";import{_ as B}from"./preload-helper-ckwbz45p.js";const C={sound:"soft-double-tap",systemNotification:!0},ce=[{id:"soft-double-tap",label:"Soft double tap"},{id:"gentle-chime",label:"Gentle chime"},{id:"warm-ding",label:"Warm ding"},{id:"mellow-two-tone",label:"Mellow two-tone"},{id:"triangle-bell",label:"Triangle bell"},{id:"off",label:"No sound"}],F="codeyam-editor-notifications";function pe(){try{const r=localStorage.getItem(F);if(!r)return C;const n=JSON.parse(r);return typeof n=="string"?n==="true"?C:{...C,sound:"off",systemNotification:!1}:{...C,...n}}catch{return C}}function xe(r){localStorage.setItem(F,JSON.stringify(r))}function ee(r){var n;if(r!=="off")try{const c=new AudioContext,s={"soft-double-tap":e=>{[0,.12].forEach(t=>{const o=e.createOscillator(),y=e.createGain();o.connect(y),y.connect(e.destination),o.type="sine",o.frequency.value=392,y.gain.setValueAtTime(.25,e.currentTime+t),y.gain.exponentialRampToValueAtTime(.01,e.currentTime+t+.1),o.start(e.currentTime+t),o.stop(e.currentTime+t+.1)})},"gentle-chime":e=>{const t=e.createOscillator(),o=e.createGain();t.connect(o),o.connect(e.destination),t.type="sine",t.frequency.setValueAtTime(523,e.currentTime),t.frequency.setValueAtTime(659,e.currentTime+.15),o.gain.setValueAtTime(.3,e.currentTime),o.gain.exponentialRampToValueAtTime(.01,e.currentTime+.4),t.start(),t.stop(e.currentTime+.4)},"warm-ding":e=>{const t=e.createOscillator(),o=e.createGain();t.connect(o),o.connect(e.destination),t.type="sine",t.frequency.value=330,o.gain.setValueAtTime(.35,e.currentTime),o.gain.exponentialRampToValueAtTime(.01,e.currentTime+.6),t.start(),t.stop(e.currentTime+.6)},"mellow-two-tone":e=>{const t=e.createOscillator(),o=e.createGain();t.connect(o),o.connect(e.destination),t.type="sine",t.frequency.setValueAtTime(294,e.currentTime),t.frequency.setValueAtTime(440,e.currentTime+.18),o.gain.setValueAtTime(.3,e.currentTime),o.gain.exponentialRampToValueAtTime(.01,e.currentTime+.5),t.start(),t.stop(e.currentTime+.5)},"triangle-bell":e=>{const t=e.createOscillator(),o=e.createGain();t.connect(o),o.connect(e.destination),t.type="triangle",t.frequency.value=523,o.gain.setValueAtTime(.4,e.currentTime),o.gain.exponentialRampToValueAtTime(.01,e.currentTime+.8),t.start(),t.stop(e.currentTime+.8)}};(n=s[r])==null||n.call(s,c)}catch{}}function he({serverUrl:r,isStarting:n,projectSlug:c,devServerError:s,onStartServer:e,notificationSettings:t,onChangeNotificationSettings:o}){const[y,A]=u.useState(null),[f,w]=u.useState(!1),E=u.useRef(null),_=u.useRef(null);u.useEffect(()=>{if(!c)return;const p=new EventSource("/api/dev-mode-events");return p.onmessage=v=>{try{const R=JSON.parse(v.data);R.type==="file-synced"&&(A(R.fileName),_.current&&clearTimeout(_.current),_.current=setTimeout(()=>{A(null)},5e3))}catch{}},()=>{p.close(),_.current&&clearTimeout(_.current)}},[c]),u.useEffect(()=>{if(!f)return;function p(v){E.current&&!E.current.contains(v.target)&&w(!1)}return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[f]);let N;s?N="error":n?N="starting":r?N="running":N="stopped";const V={starting:"bg-yellow-400",running:"bg-green-400",stopped:"bg-gray-400",error:"bg-red-400"},k={starting:"Starting...",running:r||"Running",stopped:"Stopped",error:"Error"},P=t&&(t.sound!=="off"||t.systemNotification);return a.jsxs("div",{className:"bg-[#1e1e1e] border-t border-[#3d3d3d] h-7 flex items-center px-4 gap-4 shrink-0 text-xs font-mono",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:`w-2 h-2 rounded-full ${V[N]}`}),a.jsxs("span",{className:"text-gray-400",children:["Server:"," ",a.jsx("span",{className:"text-gray-300",children:k[N]})]}),(N==="stopped"||N==="error")&&e&&a.jsx("button",{onClick:e,className:"ml-1 px-2.5 py-0.5 bg-[#005c75] hover:bg-[#007a9a] text-white text-[11px] font-medium rounded transition-colors cursor-pointer border-none leading-tight",children:"Start Server"})]}),a.jsx("div",{className:"w-px h-3 bg-[#3d3d3d]"}),y&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"#4ade80",strokeWidth:"2",children:a.jsx("path",{d:"M20 6L9 17l-5-5"})}),a.jsxs("span",{className:"text-green-400",children:["Synced: ",y]})]}),a.jsx("div",{className:"w-px h-3 bg-[#3d3d3d]"})]}),a.jsx("div",{className:"flex-1"}),o&&t&&a.jsxs("div",{className:"relative",ref:E,children:[a.jsx("button",{onClick:()=>w(!f),className:`text-[11px] rounded transition-colors cursor-pointer ${P?"text-green-400 hover:text-green-300":"text-gray-500 hover:text-gray-300"}`,children:P?"Notifications On":"Notifications Off"}),f&&a.jsxs("div",{className:"absolute bottom-full right-0 mb-2 w-56 bg-[#2d2d2d] border border-[#4d4d4d] rounded-lg shadow-xl p-3 flex flex-col gap-3 z-50",children:[a.jsxs("div",{children:[a.jsx("div",{className:"text-[11px] text-gray-400 mb-1.5",children:"Notification sound"}),a.jsx("div",{className:"flex flex-col gap-0.5",children:ce.map(p=>a.jsx("button",{onClick:()=>{o({...t,sound:p.id}),p.id!=="off"&&ee(p.id)},className:`text-left text-[11px] px-2 py-1 rounded cursor-pointer transition-colors ${t.sound===p.id?"bg-[#444] text-white":"text-gray-300 hover:bg-[#3a3a3a]"}`,children:p.label},p.id))})]}),a.jsxs("div",{className:"border-t border-[#4d4d4d] pt-2",children:[a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:t.systemNotification,onChange:p=>{const v=p.target.checked;o({...t,systemNotification:v}),v&&typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission()},className:"accent-green-500"}),a.jsx("span",{className:"text-[11px] text-gray-300",children:"System notification"})]}),a.jsx("div",{className:"text-[10px] text-gray-500 mt-1 ml-5",children:"Shows when tab is not visible"})]})]})]})]})}async function ae(r,n){try{const{WebglAddon:s}=await B(async()=>{const{WebglAddon:t}=await import("./addon-webgl-DI8QOUvO.js").then(o=>o.a);return{WebglAddon:t}},[]),e=new s;return e.onContextLoss(()=>{n==null||n("webgl","canvas",new Error("WebGL context lost")),e.dispose(),Q(r).then(t=>{t||n==null||n("canvas","dom",new Error("Canvas fallback failed after context loss"))})}),r.loadAddon(e),{type:"webgl",dispose:()=>e.dispose()}}catch(s){n==null||n("webgl","canvas",s)}const c=await Q(r);return c||(n==null||n("canvas","dom",new Error("Canvas addon failed")),{type:"dom",dispose:()=>{}})}async function Q(r){try{const{CanvasAddon:n}=await B(async()=>{const{CanvasAddon:s}=await import("./addon-canvas-DpzMmAy5.js").then(e=>e.a);return{CanvasAddon:s}},[]),c=new n;return r.loadAddon(c),{type:"canvas",dispose:()=>c.dispose()}}catch{return null}}const le=`
|
|
3
|
+
.xterm { cursor: text; position: relative; user-select: none; -ms-user-select: none; -webkit-user-select: none; }
|
|
4
|
+
.xterm.focus, .xterm:focus { outline: none; }
|
|
5
|
+
.xterm .xterm-helpers { position: absolute; top: 0; z-index: 5; }
|
|
6
|
+
.xterm .xterm-helper-textarea { padding: 0; border: 0; margin: 0; position: absolute; opacity: 0; left: -9999em; top: 0; width: 0; height: 0; z-index: -5; white-space: nowrap; overflow: hidden; resize: none; }
|
|
7
|
+
.xterm .composition-view { background: #000; color: #FFF; display: none; position: absolute; white-space: nowrap; z-index: 1; }
|
|
8
|
+
.xterm .composition-view.active { display: block; }
|
|
9
|
+
.xterm .xterm-viewport { background-color: #000; overflow-y: scroll; cursor: default; position: absolute; right: 0; left: 0; top: 0; bottom: 0; }
|
|
10
|
+
.xterm .xterm-screen { position: relative; }
|
|
11
|
+
.xterm .xterm-screen canvas { position: absolute; left: 0; top: 0; }
|
|
12
|
+
.xterm .xterm-scroll-area { visibility: hidden; }
|
|
13
|
+
.xterm-char-measure-element { display: inline-block; visibility: hidden; position: absolute; top: 0; left: -9999em; line-height: normal; }
|
|
14
|
+
.xterm.enable-mouse-events { cursor: default; }
|
|
15
|
+
.xterm.xterm-cursor-pointer, .xterm .xterm-cursor-pointer { cursor: pointer; }
|
|
16
|
+
.xterm.column-select.focus { cursor: crosshair; }
|
|
17
|
+
.xterm .xterm-accessibility:not(.debug), .xterm .xterm-message { position: absolute; left: 0; top: 0; bottom: 0; right: 0; z-index: 10; color: transparent; pointer-events: none; }
|
|
18
|
+
.xterm .xterm-accessibility-tree:not(.debug) *::selection { color: transparent; }
|
|
19
|
+
.xterm .xterm-accessibility-tree { user-select: text; white-space: pre; }
|
|
20
|
+
.xterm .live-region { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
|
|
21
|
+
.xterm-dim { opacity: 1 !important; }
|
|
22
|
+
.xterm-underline-1 { text-decoration: underline; }
|
|
23
|
+
.xterm-underline-2 { text-decoration: double underline; }
|
|
24
|
+
.xterm-underline-3 { text-decoration: wavy underline; }
|
|
25
|
+
.xterm-underline-4 { text-decoration: dotted underline; }
|
|
26
|
+
.xterm-underline-5 { text-decoration: dashed underline; }
|
|
27
|
+
.xterm-overline { text-decoration: overline; }
|
|
28
|
+
.xterm-strikethrough { text-decoration: line-through; }
|
|
29
|
+
.xterm-screen .xterm-decoration-container .xterm-decoration { z-index: 6; position: absolute; }
|
|
30
|
+
.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer { z-index: 7; }
|
|
31
|
+
.xterm-decoration-overview-ruler { z-index: 8; position: absolute; top: 0; right: 0; pointer-events: none; }
|
|
32
|
+
.xterm-decoration-top { z-index: 2; position: relative; }
|
|
33
|
+
`;function ue(){if(document.getElementById("xterm-css"))return;const r=document.createElement("style");r.id="xterm-css",r.textContent=le,document.head.appendChild(r)}const ge=u.forwardRef(function({entityName:n,entityType:c,entitySha:s,entityFilePath:e,scenarioName:t,scenarioDescription:o,analysisId:y,projectSlug:A,onRefreshPreview:f,onShowResults:w,onHideResults:E,onSetViewport:_,editorMode:N,onIdleChange:V,notificationSettings:k},P){const p=u.useRef(null),v=u.useRef(null),R=u.useRef(null),L=u.useRef(null),$=u.useRef(null),I=u.useRef(!1),M=u.useRef(0),G=u.useRef(!1),S=u.useRef(V);S.current=V;const X=u.useRef(k);X.current=k;const O=u.useRef(null);function J(){O.current&&(O.current.close(),O.current=null)}u.useEffect(()=>{function m(){J()}function x(){document.hidden||J()}return window.addEventListener("focus",m),document.addEventListener("visibilitychange",x),()=>{window.removeEventListener("focus",m),document.removeEventListener("visibilitychange",x)}},[]);const te=u.useCallback(()=>{var m;(m=R.current)==null||m.focus()},[]);return u.useImperativeHandle(P,()=>({sendInput(m){const x=L.current;x&&x.readyState===WebSocket.OPEN&&(x.send(JSON.stringify({type:"input",data:m})),setTimeout(()=>{x.readyState===WebSocket.OPEN&&x.send(JSON.stringify({type:"input",data:"\r"}))},100))},focus(){var m;(m=R.current)==null||m.focus()},scrollToBottom(){var x;const m=(x=p.current)==null?void 0:x.querySelector(".xterm-viewport");m&&(m.scrollTop=m.scrollHeight)}})),u.useEffect(()=>{const m=p.current;if(!m)return;let x=!1;return ue(),Promise.all([B(()=>import("./xterm-BqvuqXEL.js"),[]),B(()=>import("./addon-fit-YJmn1quW.js"),[]),B(()=>import("./addon-web-links-Duc5hnl7.js").then(W=>W.a),__vite__mapDeps([0,1]))]).then(([W,re,ne])=>{if(x)return;const l=new W.Terminal({cursorBlink:!0,scrollback:5e3,fontSize:13,fontFamily:"'IBM Plex Mono', 'Menlo', 'Monaco', monospace",theme:{background:"#1e1e1e",foreground:"#d4d4d4",cursor:"#d4d4d4",selectionBackground:"#264f78"},linkHandler:{activate(d,i){try{const h=new URL(i),b=h.searchParams.get("scenario");if(b&&h.pathname==="/editor"){const T=new BroadcastChannel("codeyam-editor");T.postMessage({type:"switch-scenario",scenarioId:b}),T.close();return}}catch{}window.open(i,"_blank")}}}),q=new re.FitAddon;l.loadAddon(q),l.loadAddon(new ne.WebLinksAddon),l.open(m);let D=null;ae(l,(d,i,h)=>{console.warn(`[Terminal] Renderer fallback: ${d} → ${i}`,h)}).then(d=>{if(x){d.dispose();return}console.log(`[Terminal] Using ${d.type} renderer`),D=d.dispose}),requestAnimationFrame(()=>{try{q.fit()}catch{}}),R.current=l,l.focus(),setTimeout(()=>l.focus(),100),setTimeout(()=>l.focus(),500);const oe=window.location.protocol==="https:"?"wss:":"ws:",ie=window.location.host;function se(d){const i=new URLSearchParams;return i.set("entityName",n),c&&i.set("entityType",c),s&&i.set("entitySha",s),e&&i.set("entityFilePath",e),t&&i.set("scenarioName",t),o&&i.set("scenarioDescription",o),y&&i.set("analysisId",y),A&&i.set("projectSlug",A),N&&i.set("editorMode","true"),d&&i.set("reconnectId",d),`${oe}//${ie}/ws/terminal?${i.toString()}`}function H(d){const i=se(d),h=new WebSocket(i);L.current=h,h.onopen=()=>{M.current=0,G.current=!1,h.send(JSON.stringify({type:"resize",cols:l.cols,rows:l.rows}))},h.onmessage=b=>{var T,Y,Z;try{const g=JSON.parse(b.data);if(g.type==="session-id"){$.current=g.sessionId;return}if(g.type==="refresh-preview"){f==null||f(g.path,g.scenarioId);return}if(g.type==="show-results"){w==null||w();return}if(g.type==="hide-results"){E==null||E();return}if(g.type==="set-viewport"){_==null||_({name:g.name,width:g.width,height:g.height});return}if(g.type==="claude-idle"){(T=S.current)==null||T.call(S,!0);const j=X.current;if(j!=null&&j.sound&&j.sound!=="off"&&ee(j.sound),!document.hasFocus()&&(j!=null&&j.systemNotification)&&typeof Notification<"u"&&Notification.permission==="granted"){O.current&&O.current.close();const U=new Notification("Claude is ready for you",{body:"Claude has finished and is waiting for your input.",tag:"claude-idle"});U.onclick=()=>{window.focus(),U.close()},O.current=U}return}if(g.type==="claude-active"){(Y=S.current)==null||Y.call(S,!1),O.current&&(O.current.close(),O.current=null);return}g.type==="output"&&(l.write(g.data),(Z=S.current)==null||Z.call(S,!1))}catch{l.write(b.data)}},h.onclose=()=>{if(I.current){l.write(`\r
|
|
34
|
+
\x1B[90m[Terminal session ended]\x1B[0m\r
|
|
35
|
+
`);return}const b=M.current;if(b<5&&$.current){const T=1e3*Math.pow(2,Math.min(b,3));M.current=b+1,l.write(`\r
|
|
36
|
+
\x1B[33m[Reconnecting...]\x1B[0m\r
|
|
37
|
+
`),setTimeout(()=>{I.current||H($.current)},T)}else G.current?l.write(`\r
|
|
38
|
+
\x1B[90m[Terminal session ended]\x1B[0m\r
|
|
39
|
+
`):(G.current=!0,l.write(`\r
|
|
40
|
+
\x1B[33m[Starting new session...]\x1B[0m\r
|
|
41
|
+
`),$.current=null,M.current=0,H())},h.onerror=()=>{}}H(),l.onData(d=>{const i=L.current;i&&i.readyState===WebSocket.OPEN&&i.send(JSON.stringify({type:"input",data:d})),J()});let z=null;const K=new ResizeObserver(()=>{z&&clearTimeout(z),z=setTimeout(()=>{let d;try{d=q.proposeDimensions()}catch{return}if(!d||d.cols===l.cols&&d.rows===l.rows)return;const i=m.querySelector(".xterm-viewport");let h,b=!0;i&&(h=i.scrollTop,b=i.scrollTop+i.clientHeight>=i.scrollHeight-10),q.fit(),i&&h!==void 0&&(b?i.scrollTop=i.scrollHeight:i.scrollTop=h);const T=L.current;T&&T.readyState===WebSocket.OPEN&&T.send(JSON.stringify({type:"resize",cols:l.cols,rows:l.rows}))},150)});K.observe(m),v.current=()=>{var d;z&&clearTimeout(z),K.disconnect(),I.current=!0,(d=L.current)==null||d.close(),L.current=null,D==null||D(),l.dispose(),R.current=null}}),()=>{var W;x=!0,(W=v.current)==null||W.call(v),v.current=null}},[]),a.jsx("div",{ref:p,onClick:te,className:"w-full h-full",style:{padding:"4px 0 0 8px"}})});function de(r){return r.replace(/[^a-zA-Z0-9_]+/g,"_")}function ye(r){const{activeAnalyzedScenario:n,analyzedPreviewUrl:c,activeScenarioId:s,scenarios:e,proxyUrl:t,devServerUrl:o,zoomComponent:y}=r;if(n&&c)return c;if(n&&!c)return null;if(s){const f=e.find(w=>w.id===s);if(f!=null&&f.url){const w=t||o;return w?f.url.startsWith("/")?`${w}${f.url}`:f.url:null}}const A=t||o;if(!A)return null;if(y&&s){const f=e.find(E=>E.id===s),w=f?de(f.name):"Default";return`${A}/__codeyam__/${y}/${w}`}return A}function we(r,n){if(!r||!n)return r;try{const c=new URL(r),s=n.indexOf("?");return s>=0?(c.pathname=n.slice(0,s),c.search=n.slice(s)):(c.pathname=n,c.search=""),c.href}catch{return r}}function ve(r,n){return r?r!==n:!1}function be(r){if(r.length!==0)return r.find(n=>n.type==="application")||r[0]}function Te(r,n,c){if(!r.viewportWidth||!r.viewportHeight)return c??null;const s=n.find(e=>e.width===r.viewportWidth&&e.height===r.viewportHeight);return{name:(s==null?void 0:s.name)||"Custom",width:r.viewportWidth,height:r.viewportHeight}}function Ne(r,n){const c=n.width,s=n.height??900,e=r.width,t=r.height;return c<=e&&s<=t?1:Math.min(e/c,t/s)}export{he as D,ge as T,we as a,de as b,C as c,xe as d,Ne as e,ye as f,be as g,pe as l,Te as r,ve as s};
|