@codeyam/codeyam-cli 0.1.10 → 0.1.12
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 +7 -7
- package/analyzer-template/log.txt +3 -3
- package/analyzer-template/package.json +2 -2
- package/analyzer-template/packages/ai/package.json +1 -1
- package/analyzer-template/packages/aws/package.json +1 -1
- package/analyzer-template/packages/database/package.json +1 -1
- package/analyzer-template/packages/database/src/lib/kysely/tables/editorScenariosTable.ts +42 -16
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.d.ts +3 -1
- 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 +44 -16
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.js.map +1 -1
- package/codeyam-cli/src/commands/__tests__/editor.stepDispatch.test.js +11 -0
- package/codeyam-cli/src/commands/__tests__/editor.stepDispatch.test.js.map +1 -1
- package/codeyam-cli/src/commands/editor.js +1214 -217
- package/codeyam-cli/src/commands/editor.js.map +1 -1
- package/codeyam-cli/src/commands/init.js +1 -0
- package/codeyam-cli/src/commands/init.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/editorAudit.test.js +893 -1
- package/codeyam-cli/src/utils/__tests__/editorAudit.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/editorBroadcastViewport.test.js +76 -0
- package/codeyam-cli/src/utils/__tests__/editorBroadcastViewport.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorDeleteScenario.test.js +100 -0
- package/codeyam-cli/src/utils/__tests__/editorDeleteScenario.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorEntityChangeStatus.test.js +6 -3
- package/codeyam-cli/src/utils/__tests__/editorEntityChangeStatus.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/editorEntityHelpers.test.js +261 -0
- package/codeyam-cli/src/utils/__tests__/editorEntityHelpers.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorLoaderHelpers.test.js +75 -1
- package/codeyam-cli/src/utils/__tests__/editorLoaderHelpers.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/editorMigration.test.js +435 -0
- package/codeyam-cli/src/utils/__tests__/editorMigration.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorScenarios.test.js +441 -17
- package/codeyam-cli/src/utils/__tests__/editorScenarios.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/editorSeedAdapter.test.js +67 -0
- package/codeyam-cli/src/utils/__tests__/editorSeedAdapter.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/editorSeedAdapterPrismaValidation.test.js +143 -0
- package/codeyam-cli/src/utils/__tests__/editorSeedAdapterPrismaValidation.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorSessionFilter.test.js +66 -0
- package/codeyam-cli/src/utils/__tests__/editorSessionFilter.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorShouldRevalidate.test.js +53 -0
- package/codeyam-cli/src/utils/__tests__/editorShouldRevalidate.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/entityChangeStatus.test.js +125 -10
- package/codeyam-cli/src/utils/__tests__/entityChangeStatus.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/routePatternMatching.test.js +118 -0
- package/codeyam-cli/src/utils/__tests__/routePatternMatching.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/scenariosManifest.test.js +40 -1
- package/codeyam-cli/src/utils/__tests__/scenariosManifest.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js +1 -0
- package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js.map +1 -1
- package/codeyam-cli/src/utils/analysisRunner.js +3 -1
- package/codeyam-cli/src/utils/analysisRunner.js.map +1 -1
- package/codeyam-cli/src/utils/editorAudit.js +145 -0
- package/codeyam-cli/src/utils/editorAudit.js.map +1 -1
- package/codeyam-cli/src/utils/editorBroadcastViewport.js +26 -0
- package/codeyam-cli/src/utils/editorBroadcastViewport.js.map +1 -0
- package/codeyam-cli/src/utils/editorDeleteScenario.js +67 -0
- package/codeyam-cli/src/utils/editorDeleteScenario.js.map +1 -0
- package/codeyam-cli/src/utils/editorEntityChangeStatus.js +1 -1
- package/codeyam-cli/src/utils/editorEntityChangeStatus.js.map +1 -1
- package/codeyam-cli/src/utils/editorEntityHelpers.js +129 -0
- package/codeyam-cli/src/utils/editorEntityHelpers.js.map +1 -0
- package/codeyam-cli/src/utils/editorLoaderHelpers.js +40 -1
- package/codeyam-cli/src/utils/editorLoaderHelpers.js.map +1 -1
- package/codeyam-cli/src/utils/editorMigration.js +224 -0
- package/codeyam-cli/src/utils/editorMigration.js.map +1 -0
- package/codeyam-cli/src/utils/editorScenarios.js +163 -2
- package/codeyam-cli/src/utils/editorScenarios.js.map +1 -1
- package/codeyam-cli/src/utils/editorSeedAdapter.js +253 -4
- package/codeyam-cli/src/utils/editorSeedAdapter.js.map +1 -1
- package/codeyam-cli/src/utils/editorShouldRevalidate.js +21 -0
- package/codeyam-cli/src/utils/editorShouldRevalidate.js.map +1 -0
- package/codeyam-cli/src/utils/entityChangeStatus.js +19 -2
- package/codeyam-cli/src/utils/entityChangeStatus.js.map +1 -1
- package/codeyam-cli/src/utils/entityChangeStatus.server.js +41 -3
- package/codeyam-cli/src/utils/entityChangeStatus.server.js.map +1 -1
- package/codeyam-cli/src/utils/fileWatcher.js +38 -0
- package/codeyam-cli/src/utils/fileWatcher.js.map +1 -1
- package/codeyam-cli/src/utils/install-skills.js +9 -0
- package/codeyam-cli/src/utils/install-skills.js.map +1 -1
- package/codeyam-cli/src/utils/routePatternMatching.js +129 -0
- package/codeyam-cli/src/utils/routePatternMatching.js.map +1 -0
- package/codeyam-cli/src/utils/scenarioCoverage.js +8 -9
- package/codeyam-cli/src/utils/scenarioCoverage.js.map +1 -1
- package/codeyam-cli/src/utils/scenariosManifest.js +18 -10
- package/codeyam-cli/src/utils/scenariosManifest.js.map +1 -1
- package/codeyam-cli/src/utils/setupClaudeCodeSettings.js +1 -0
- package/codeyam-cli/src/utils/setupClaudeCodeSettings.js.map +1 -1
- package/codeyam-cli/src/webserver/__tests__/buildPtyEnv.test.js +35 -0
- package/codeyam-cli/src/webserver/__tests__/buildPtyEnv.test.js.map +1 -0
- package/codeyam-cli/src/webserver/__tests__/editorProxy.test.js +33 -0
- package/codeyam-cli/src/webserver/__tests__/editorProxy.test.js.map +1 -1
- package/codeyam-cli/src/webserver/app/types/editor.js +8 -0
- package/codeyam-cli/src/webserver/app/types/editor.js.map +1 -0
- package/codeyam-cli/src/webserver/backgroundServer.js +18 -4
- package/codeyam-cli/src/webserver/backgroundServer.js.map +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/CopyButton-CzTDWkF2.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{EntityItem-BcgbViKV.js → EntityItem-BFbq6iFk.js} +3 -3
- package/codeyam-cli/src/webserver/build/client/assets/EntityTypeBadge-CQgyEGV-.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeIcon-CQIG2qda.js → EntityTypeIcon-B6OMi58N.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/InlineSpinner-DuYodzo1.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-CXo9EeCl.js +25 -0
- package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-DYCNb2It.js +3 -0
- package/codeyam-cli/src/webserver/build/client/assets/{LoadingDots-BU_OAEMP.js → LoadingDots-By5zI316.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{LogViewer-ceAyBX-H.js → LogViewer-CZgY3sxX.js} +3 -3
- package/codeyam-cli/src/webserver/build/client/assets/{ReportIssueModal-BzHcG7SE.js → ReportIssueModal-CnYYwRDw.js} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/SafeScreenshot-CDoF7ZpU.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{ScenarioViewer-TSD3C211.js → ScenarioViewer-DrnfvaLL.js} +3 -3
- package/codeyam-cli/src/webserver/build/client/assets/Spinner-Df3UCi8k.js +34 -0
- package/codeyam-cli/src/webserver/build/client/assets/TruncatedFilePath-CK7-NaPZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/ViewportInspectBar-DRKR9T0U.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{_index-DLxKhri3.js → _index-ClR-g3tY.js} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/{activity.(_tab)-BcY3q6nt.js → activity.(_tab)-DTH6ydEA.js} +3 -3
- package/codeyam-cli/src/webserver/build/client/assets/{addon-web-links-Duc5hnl7.js → addon-web-links-74hnHF59.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{agent-transcripts-Bni3iiUj.js → agent-transcripts-B8CYhCO9.js} +3 -3
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-rename-scenario-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-save-seed-state-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-scenario-prompt-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-session-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{book-open-BYOypzCa.js → book-open-CLaoh4ac.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{chevron-down-C_Pmso5S.js → chevron-down-BZ2DZxbW.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{chunk-JZWAC4HX-C4pqxYJB.js → chunk-JZWAC4HX-BBXArFPl.js} +13 -21
- package/codeyam-cli/src/webserver/build/client/assets/{circle-check-BVMi9VA5.js → circle-check-CT4unAk-.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{copy-n2FB0_Sw.js → copy-zK0B6Nu-.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{createLucideIcon-CC6AbExI.js → createLucideIcon-DJB0YQJL.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/dev.empty-CkXFP_i-.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/editor._tab-DPw7NZHc.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/editor.entity.(_sha)-DmBK1JBK.js +58 -0
- package/codeyam-cli/src/webserver/build/client/assets/editorPreview-DBa7T2FK.js +41 -0
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha._-DwCV5__E.js → entity._sha._-BqAN7hyG.js} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.dev-BOi8kpwd.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.fullscreen-Dg1NhIms.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-CJX6kkkV.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha_.edit._scenarioId-BMvVHNXU.js → entity._sha_.edit._scenarioId-BhVjZhKg.js} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/{entry.client-DTvKq3TY.js → entry.client-_gzKltPN.js} +6 -6
- package/codeyam-cli/src/webserver/build/client/assets/fileTableUtils-Daa96Fr1.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/files-CV_17tZS.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/git-D-YXmMbR.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/globals-CGrDAxj0.css +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{index-yHOVb4rc.js → index-Blo6EK8G.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{index-10oVnAAH.js → index-BsX0F-9C.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{index-BcvgDzbZ.js → index-CCrgCshv.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/jsx-runtime-D_zvdyIk.js +9 -0
- package/codeyam-cli/src/webserver/build/client/assets/labs-Byazq8Pv.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{loader-circle-DaAZ_H2w.js → loader-circle-DVQ0oHR7.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/manifest-b3f77062.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{memory-9gnxSZlb.js → memory-b-VmA2Vj.js} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/{pause-f5-1lKBt.js → pause-DGcndCAa.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{root-BWAyuj0r.js → root-D5Zi3U2Z.js} +4 -4
- package/codeyam-cli/src/webserver/build/client/assets/{search-Di64LWVb.js → search-C0Uw0bcK.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/settings-OoNgHIfW.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/simulations-Bcemfu8a.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{terminal-Br7MOqts.js → terminal-BgMmG7R9.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{triangle-alert-BLdiCuG-.js → triangle-alert-Cs87hJYK.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-BR3Rs7JY.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{useLastLogLine-C14nCb1q.js → useLastLogLine-BxxP_XF9.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/useReportContext-BermyNU5.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/useToast-a_QN_W9_.js +1 -0
- package/codeyam-cli/src/webserver/build/server/assets/analysisRunner-yTyb36j3.js +13 -0
- package/codeyam-cli/src/webserver/build/server/assets/{index-ChX0hPcu.js → index-Cr7d_IsG.js} +1 -1
- package/codeyam-cli/src/webserver/build/server/assets/init-M_wqNAfu.js +10 -0
- package/codeyam-cli/src/webserver/build/server/assets/progress-CHTtrxFG.js +1 -0
- package/codeyam-cli/src/webserver/build/server/assets/server-build-_ybRgrlc.js +551 -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 +93 -11
- package/codeyam-cli/src/webserver/editorProxy.js.map +1 -1
- package/codeyam-cli/src/webserver/mockStateEvents.js +28 -0
- package/codeyam-cli/src/webserver/mockStateEvents.js.map +1 -0
- package/codeyam-cli/src/webserver/server.js +9 -0
- package/codeyam-cli/src/webserver/server.js.map +1 -1
- package/codeyam-cli/src/webserver/terminalServer.js +105 -9
- package/codeyam-cli/src/webserver/terminalServer.js.map +1 -1
- package/codeyam-cli/templates/editor-step-hook.py +104 -20
- package/codeyam-cli/templates/nextjs-prisma-sqlite/seed-adapter.ts +42 -7
- package/codeyam-cli/templates/seed-adapters/supabase.ts +282 -0
- package/codeyam-cli/templates/skills/codeyam-editor/SKILL.md +62 -0
- package/package.json +1 -1
- package/packages/database/src/lib/kysely/tables/editorScenariosTable.js +44 -16
- package/packages/database/src/lib/kysely/tables/editorScenariosTable.js.map +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/CopyButton-BPXZwM4t.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/EntityTypeBadge-g3saevPb.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/InlineSpinner-Bu6c6aDe.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-DYFW3lDD.js +0 -25
- package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-DLeucoVX.js +0 -3
- package/codeyam-cli/src/webserver/build/client/assets/SafeScreenshot-BED4B6sP.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/Spinner-Bb5uFQ5V.js +0 -34
- package/codeyam-cli/src/webserver/build/client/assets/TruncatedFilePath-C8OKAR5x.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/ViewportInspectBar-oAf2Kqsf.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/dev.empty-Ii3inc0_.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/editor-COWCNVyV.js +0 -10
- package/codeyam-cli/src/webserver/build/client/assets/editorPreview-CNB06EIa.js +0 -41
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.dev-CXSi2aeZ.js +0 -6
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.fullscreen-CHMiAog3.js +0 -6
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-p9hhkjJM.js +0 -6
- package/codeyam-cli/src/webserver/build/client/assets/fileTableUtils-cPo8LiG3.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/files-BZrlFE1F.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/git-DdZcvjGh.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/globals-phvmGvat.css +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/labs-Zk7ryIM1.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/manifest-6134dc40.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/settings-0OrEMU6J.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/simulations-DWT-CvLy.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-C-_hOl_g.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/useReportContext-O-jkvSPx.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/useToast-9FIWuYfK.js +0 -1
- package/codeyam-cli/src/webserver/build/server/assets/init-kSNsMjj8.js +0 -10
- package/codeyam-cli/src/webserver/build/server/assets/server-build-Bm2xIhmh.js +0 -439
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{w as t,d as r}from"./chunk-JZWAC4HX-BBXArFPl.js";import{j as e}from"./jsx-runtime-D_zvdyIk.js";import{S as i}from"./ScenarioViewer-DrnfvaLL.js";import{W as n}from"./InteractivePreview-CXo9EeCl.js";import"./ViewportInspectBar-DRKR9T0U.js";import"./useCustomSizes-BR3Rs7JY.js";import"./LogViewer-CZgY3sxX.js";import"./SafeScreenshot-CDoF7ZpU.js";import"./useLastLogLine-BxxP_XF9.js";import"./Spinner-Df3UCi8k.js";import"./preload-helper-ckwbz45p.js";import"./ReportIssueModal-CnYYwRDw.js";import"./createLucideIcon-DJB0YQJL.js";import"./circle-check-CT4unAk-.js";import"./triangle-alert-Cs87hJYK.js";import"./copy-zK0B6Nu-.js";import"./scenarioStatus-B_8jpV3e.js";import"./InlineSpinner-DuYodzo1.js";const S=()=>[{title:"Empty State - CodeYam"},{name:"description",content:"Simulations empty state development view"}],L=t(function(){r();const s={sha:"mock-sha",name:"Dashboard",filePath:"codeyam-cli/src/webserver/app/routes/_index.tsx",entityType:"visual"};return e.jsx(n,{children:e.jsxs("div",{className:"h-screen bg-[#F8F7F6] flex flex-col overflow-hidden",children:[e.jsx("header",{className:"bg-white border-b border-gray-200 shrink-0 relative h-[54px]",children:e.jsxs("div",{className:"flex items-center h-full px-6 gap-6",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("svg",{width:"17",height:"17",viewBox:"0 0 17 17",fill:"none",className:"shrink-0",children:e.jsx("path",{d:"M13 8.5H4M4 8.5L8.5 4M4 8.5L8.5 13",stroke:"#005c75",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),e.jsx("h1",{className:"text-lg font-semibold text-black m-0 leading-[26px] shrink-0",children:"Dashboard"}),e.jsx("span",{className:"text-xs text-[#626262] font-mono whitespace-nowrap overflow-hidden text-ellipsis min-w-0",children:"codeyam-cli/src/webserver/app/routes/_index.tsx"})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2 px-[15px] py-0 h-[26px] bg-[#efefef] border border-[#e1e1e1] rounded",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-[#626262]"}),e.jsx("span",{className:"text-xs font-semibold text-[#626262]",children:"Not analyzed"})]}),e.jsx("button",{className:"px-[15px] py-0 h-[26px] bg-[#005c75] text-white rounded text-xs font-semibold border-none cursor-pointer hover:bg-[#004a5e] transition-colors",children:"Analyze"})]}),e.jsxs("div",{className:"flex items-center gap-1 text-[10px] text-[#626262] ml-auto",children:[e.jsx("span",{className:"leading-[22px]",children:"Next Entity"}),e.jsx("svg",{width:"17",height:"17",viewBox:"0 0 17 17",fill:"none",className:"shrink-0",children:e.jsx("path",{d:"M4 8.5H13M13 8.5L8.5 4M13 8.5L8.5 13",stroke:"#005c75",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]})]})}),e.jsx("div",{className:"bg-[#efefef] border-b border-[#efefef] shrink-0",children:e.jsxs("div",{className:"flex items-center gap-3 h-11 px-[15px]",children:[e.jsxs("div",{className:"px-4 flex items-center justify-center gap-3 shrink-0 text-sm rounded bg-[#343434] text-[#efefef] font-semibold h-8",children:["Scenarios",e.jsx("span",{className:"px-2 py-0.5 rounded-[9px] text-xs font-semibold bg-[#cbf3fa] text-[#005c75] min-w-[25px] text-center",children:"0"})]}),e.jsxs("div",{className:"px-4 flex items-center justify-center gap-3 shrink-0 text-sm rounded-[9px] text-[#3e3e3e] font-normal",children:["Related Entities",e.jsx("span",{className:"px-2 py-0.5 rounded-[9px] text-xs font-semibold bg-[#e1e1e1] text-[#3e3e3e] min-w-[25px] text-center",children:"5"})]}),e.jsx("div",{className:"px-4 shrink-0 text-sm text-[#3e3e3e] font-normal",children:"Code"}),e.jsx("div",{className:"px-4 shrink-0 text-sm text-[#3e3e3e] font-normal",children:"Data Structure"}),e.jsx("div",{className:"px-4 shrink-0 text-sm text-[#3e3e3e] font-normal",children:"History"})]})}),e.jsxs("div",{className:"flex flex-1 gap-0 min-h-0",children:[e.jsx("div",{className:"w-[165px] bg-[#e1e1e1] border-r border-[#c7c7c7] flex items-center justify-center shrink-0",children:e.jsx("span",{className:"text-xs font-medium text-[#8e8e8e] leading-5",children:"No Scenarios"})}),e.jsx(i,{selectedScenario:null,analysis:void 0,entity:s,viewMode:"screenshot",cacheBuster:Date.now(),hasScenarios:!1,isAnalyzing:!1,projectSlug:null,hasAnApiKey:!0})]})]})})});export{L as default,S as meta};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{w as t}from"./chunk-JZWAC4HX-BBXArFPl.js";const n=t(function(){return null});export{n as default};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-Blo6EK8G.js","assets/jsx-runtime-D_zvdyIk.js","assets/chunk-JZWAC4HX-BBXArFPl.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var xs=Object.defineProperty;var ps=(t,s,a)=>s in t?xs(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a;var yt=(t,s,a)=>ps(t,typeof s!="symbol"?s+"":s,a);import{r as i,w as hs,u as us,b as fs,a as gs,c as js,O as bs}from"./chunk-JZWAC4HX-BBXArFPl.js";import{j as e}from"./jsx-runtime-D_zvdyIk.js";import{u as ys,C as vs}from"./useCustomSizes-BR3Rs7JY.js";import{g as Ns,s as ws,r as qe,b as Ye,c as Ss,l as ks,d as Cs,e as Ps,f as Es,a as Ms,T as Is,D as Ts}from"./editorPreview-DBa7T2FK.js";import{C as he}from"./CopyButton-CzTDWkF2.js";import{_ as Xe}from"./preload-helper-ckwbz45p.js";import{c as Rs}from"./cy-logo-cli-DcX-ZS3p.js";import{u as $s,S as vt}from"./Spinner-Df3UCi8k.js";import"./copy-zK0B6Nu-.js";import"./createLucideIcon-DJB0YQJL.js";import"./useLastLogLine-BxxP_XF9.js";function Ee(t){var l;if(!t.startsWith("app/")&&!t.startsWith("("))return"/";const a=t.replace(/^app\//,"").split("/"),n=a.pop(),c=((l=n.match(/\.(tsx?|jsx?|js)$/))==null?void 0:l[0])||"",r=n.slice(0,-c.length);let o;return r==="page"||r==="index"?o=a:o=[...a,r],o=o.filter(m=>!m.startsWith("(")),o.length===0?"/":"/"+o.join("/")}function Me(t){return t==="/"?"Home":t.replace(/^\//,"").split("/").map(a=>a.startsWith("[")?a:a.charAt(0).toUpperCase()+a.slice(1)).join(" / ")}function _e(t){if(!t||t==="/")return"Home";const s=t.split("?")[0].replace(/^\//,"");if(!s)return"Home";const a=s.split("/")[0].replace(/\.[^.]+$/,"");return a.charAt(0).toUpperCase()+a.slice(1)}function _t(t){return t?t.includes("/isolated-components"):!1}function As(t,s){return!s||Object.keys(s).length===0?t:t.filter(a=>s[a.name])}const Ae=[{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 _s(t){if(!t)return Ae;const s=Object.entries(t).map(([n,c])=>({name:n,width:c.width,height:c.height})),a=new Set(s.map(n=>n.name));return[...s,...Ae.filter(n=>!a.has(n.name))]}function Ls({featureName:t,editorStep:s,editorStepLabel:a,onContinue:n}){const c=i.useCallback(r=>{r.key==="Enter"&&(r.preventDefault(),n())},[n]);return i.useEffect(()=>(window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)),[c]),e.jsx("div",{className:"flex items-center justify-center h-full bg-[#1e1e1e] text-[#d4d4d4]",children:e.jsxs("div",{className:"max-w-md w-full mx-4 p-6 bg-[#252526] border border-[#3d3d3d] rounded-lg",children:[e.jsx("h2",{className:"text-lg font-semibold mb-3 text-white",children:"Resume Previous Session?"}),e.jsx("p",{className:"text-sm text-[#999] mb-4",children:"An editor session is still in progress:"}),e.jsxs("div",{className:"bg-[#1e1e1e] rounded p-3 mb-5 text-sm",children:[t&&e.jsxs("div",{className:"mb-1",children:[e.jsx("span",{className:"text-[#999]",children:"Feature:"})," ",e.jsx("span",{className:"text-white",children:t})]}),s!=null&&a&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[#999]",children:"Step:"})," ",e.jsxs("span",{className:"text-white",children:[s," (",a,")"]})]})]}),e.jsx("button",{onClick:n,className:"w-full px-4 py-2 text-sm rounded transition-colors cursor-pointer bg-[#005c75] text-white font-medium hover:bg-[#004d63] ring-2 ring-white/50",children:"Continue Session"})]})})}function Qe(t){const[s,a]=i.useState(null),[n,c]=i.useState(!1),r=i.useCallback(()=>{t&&(c(!0),fetch(`/api/editor-test-results?testFile=${encodeURIComponent(t)}`).then(o=>o.json()).then(o=>{a(o),c(!1)}).catch(()=>{a({testFilePath:t,status:"error",testCases:[],errorMessage:"Failed to fetch test results"}),c(!1)}))},[t]);return i.useEffect(()=>{t&&r()},[t,r]),{results:s,isRunning:n,runTests:r}}function Le({scenarioId:t,updatedAt:s,alt:a,className:n="",imgClassName:c=""}){const[r,o]=i.useState(!1),l=`/api/editor-scenario-image/${t}.png${s?`?v=${encodeURIComponent(s)}`:""}`;return i.useEffect(()=>{o(!1)},[t]),r?e.jsx("div",{className:`flex items-center justify-center ${n}`,children:e.jsx("span",{className:"text-[8px] text-gray-500",children:"No img"})}):e.jsx("div",{className:n,children:e.jsx("img",{src:l,alt:a,className:c,loading:"lazy",onError:()=>o(!0)})})}function Ce({scenarioId:t,updatedAt:s,hasScreenshot:a,imgSrc:n,name:c,isActive:r,onSelect:o}){const l=t&&a,m=!t&&n;return e.jsxs("button",{onClick:o,className:"flex flex-col items-center gap-1 cursor-pointer group",title:c,children:[e.jsx("div",{className:`w-32 h-32 rounded overflow-hidden border-2 transition-all bg-[#1a1a1a] ${r?"border-[#005c75] ring-1 ring-[#005c75]":"border-transparent hover:border-[#4d4d4d]"}`,children:l?e.jsx(Le,{scenarioId:t,updatedAt:s,alt:c,className:"w-full h-full",imgClassName:"w-full h-full object-contain"}):m?e.jsx("img",{src:n,alt:c,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 ${r?"text-white":"text-gray-500 group-hover:text-gray-300"}`,children:c})]})}function Ke({testFile:t,entityName:s}){const{results:a,isRunning:n,runTests:c}=Qe(t);if(n&&!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 r=s?a.testCases.filter(m=>m.fullName.startsWith(s)):a.testCases,o=r.length>0?r:a.testCases;if(o.length===0)return null;const l=s?`${s} > `:"";return e.jsxs("div",{className:"px-2 pt-1 space-y-0.5",children:[o.map(m=>{var y;const v=l&&m.fullName.startsWith(l)?m.fullName.slice(l.length):m.fullName;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[m.status==="passed"?e.jsx("span",{className:"text-green-400 text-[10px]",children:"✓"}):m.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] ${m.status==="passed"?"text-green-400":m.status==="failed"?"text-red-400":"text-gray-500"}`,children:v})]}),m.status==="failed"&&((y=m.failureMessages)==null?void 0:y.map((S,g)=>e.jsx("div",{className:"pl-4 text-[9px] text-red-300/70 truncate max-w-full",title:S,children:S.split(`
|
|
3
|
+
`)[0]},g)))]},m.fullName)}),e.jsx("button",{onClick:c,disabled:n,className:"mt-1 text-[10px] text-[#00a0c4] hover:text-[#00c4ee] transition-colors cursor-pointer disabled:opacity-50 bg-transparent border-none p-0",children:n?"Running...":"Re-run"})]})}function oe({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(he,{content:t,icon:!0,iconSize:10,className:"shrink-0 text-gray-500 hover:text-gray-300 transition-colors"})]}):null}function Ds({scenarios:t,projectRoot:s,activeScenarioId:a,onScenarioSelect:n,zoomComponent:c,focusedEntity:r,onZoomChange:o,analyzedEntities:l=[],glossaryFunctions:m=[],activeAnalyzedScenarioId:v,onAnalyzedScenarioSelect:y,entityImports:S,pageFilePaths:g={}}){const{pageGroups:I,componentGroups:f}=i.useMemo(()=>{var h;const p=new Map,x=new Map;for(const w of t)if(w.componentName){const k=x.get(w.componentName)||[];k.push(w),x.set(w.componentName,k)}else if(_t(w.url)){const k=(h=w.url)==null?void 0:h.match(/[?&]c=([^&]+)/),T=k?decodeURIComponent(k[1]):"Isolated",A=x.get(T)||[];A.push(w),x.set(T,A)}else{const k=w.pageFilePath?Me(Ee(w.pageFilePath)):_e(w.url),T=p.get(k)||[];T.push(w),p.set(k,T)}const b=new Map([...x.entries()].sort(([w],[k])=>w.localeCompare(k)));return{pageGroups:p,componentGroups:b}},[t]),B=i.useMemo(()=>{const p=new Set((l||[]).filter(b=>b.entityType==="visual").map(b=>b.name)),x=new Map;for(const[b,h]of f)p.has(b)||x.set(b,h);return x},[f,l]),{visualEntities:O,libraryEntities:L}=i.useMemo(()=>{const p=l.filter(b=>b.entityType==="visual").sort((b,h)=>b.name.localeCompare(h.name)),x=l.filter(b=>b.entityType==="library"||b.entityType==="functionCall").sort((b,h)=>b.name.localeCompare(h.name));return{visualEntities:p,libraryEntities:x}},[l]),D=i.useMemo(()=>{const p=new Set(L.map(x=>x.name));return m.filter(x=>!p.has(x.name)).sort((x,b)=>x.name.localeCompare(b.name))},[m,L]),_=l.some(p=>p.isAnalyzing),N=i.useRef(null),M=i.useRef(0),U=i.useCallback(()=>{N.current&&(M.current=N.current.scrollTop)},[]);if(i.useEffect(()=>{N.current&&M.current>0&&(N.current.scrollTop=M.current)}),t.length===0&&l.length===0&&D.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(c&&r){const p=r.name,x=r.filePath,b=r.sha,h=t.filter(C=>C.componentName===p||C.componentPath===x||!C.componentName&&(C.pageFilePath===x||b&&C.entitySha===b)),w=new Set((S==null?void 0:S[p])||[]),k=w.size>0,T=k?O.filter(C=>w.has(C.name)):[],A=k?L.filter(C=>w.has(C.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:()=>o(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:r.displayName})}),e.jsx("div",{className:"flex flex-wrap gap-2 px-2",children:h.length===0?e.jsx("div",{className:"px-3 py-2 text-xs text-gray-500",children:"No scenarios for this component"}):h.map(C=>e.jsx(Ce,{scenarioId:C.id,updatedAt:C.updatedAt,hasScreenshot:!!C.screenshotPath,name:C.name,isActive:C.id===a,onSelect:()=>n(C)},C.id))}),T.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"})}),T.map(C=>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:()=>o(C.name),className:"text-[11px] font-medium text-gray-400 truncate cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:C.name})}),e.jsx(oe,{filePath:C.filePath,projectRoot:s}),(C.scenarios.length>0||C.pendingScenarios.length>0)&&e.jsx("div",{className:"flex flex-wrap gap-2 px-2 pt-1",children:C.scenarios.map(q=>e.jsx(Ce,{imgSrc:q.screenshotPath?`/api/screenshot/${q.screenshotPath}`:null,name:q.name,isActive:q.id===v,onSelect:()=>y==null?void 0:y({analysisId:C.analysisId,scenarioId:q.id,scenarioName:q.name,entitySha:C.sha,entityName:C.name})},q.id))})]},C.sha))]}),A.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"})}),A.map(C=>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:C.name})}),e.jsx(oe,{filePath:C.filePath,projectRoot:s}),C.testFile&&e.jsx(Ke,{testFile:C.testFile,entityName:C.name})]},C.sha))]})]})})}return e.jsx("div",{ref:N,onScroll:U,className:"flex-1 overflow-auto",children:e.jsxs("div",{className:"p-3 space-y-3",children:[I.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"})}),[...I.entries()].sort(([p],[x])=>p==="Home"?-1:x==="Home"?1:p.localeCompare(x)).map(([p,x])=>{var b,h;return 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:p})}),(((b=x[0])==null?void 0:b.pageFilePath)||g[p])&&e.jsx(oe,{filePath:((h=x[0])==null?void 0:h.pageFilePath)||g[p],projectRoot:s}),e.jsx("div",{className:"flex flex-wrap gap-2 pt-1",children:x.map(w=>e.jsx(Ce,{scenarioId:w.id,updatedAt:w.updatedAt,hasScreenshot:!!w.screenshotPath,name:w.name,isActive:w.id===a&&!v,onSelect:()=>n(w)},w.id))})]},p)})]}),B.size>0&&e.jsxs("div",{className:"pt-2 mt-1 border-t border-[#3d3d3d]",children:[e.jsx("div",{className:"px-2 py-1",children:e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Components"})}),[...B.entries()].map(([p,x])=>{var b;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:()=>o(p),className:"text-[11px] font-medium text-gray-400 truncate cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:p})}),((b=x[0])==null?void 0:b.componentPath)&&e.jsx(oe,{filePath:x[0].componentPath,projectRoot:s}),e.jsx("div",{className:"flex flex-wrap gap-2 px-2 pt-1",children:x.map(h=>e.jsx(Ce,{scenarioId:h.id,updatedAt:h.updatedAt,hasScreenshot:!!h.screenshotPath,name:h.name,isActive:h.id===a&&!v,onSelect:()=>n(h)},h.id))})]},p)})]}),O.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"}),_&&t.length===0&&l.every(p=>p.scenarioCount===0)&&e.jsx("span",{className:"ml-2 text-[10px] text-gray-500",children:"— Entities are being analyzed..."})]}),O.map(p=>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:()=>o(p.name),className:"text-[11px] font-medium text-gray-400 truncate cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:p.name}),p.isAnalyzing&&p.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(oe,{filePath:p.filePath,projectRoot:s}),(p.scenarios.length>0||p.pendingScenarios.length>0)&&e.jsxs("div",{className:"flex flex-wrap gap-2 px-2 pt-1",children:[p.scenarios.map(x=>e.jsx(Ce,{imgSrc:x.screenshotPath?`/api/screenshot/${x.screenshotPath}`:null,name:x.name,isActive:x.id===v,onSelect:()=>y==null?void 0:y({analysisId:p.analysisId,scenarioId:x.id,scenarioName:x.name,entitySha:p.sha,entityName:p.name})},x.id)),p.pendingScenarios.map(x=>e.jsx("div",{className:"px-2.5 py-1 bg-[#2a2a2a] text-gray-400 text-[10px] rounded-full",title:x,children:x},x))]})]},p.sha))]}),(L.length>0||D.length>0)&&e.jsxs("div",{className:`pt-2 mt-1 ${O.length>0?"":"border-t border-[#3d3d3d]"}`,children:[e.jsx("div",{className:"px-2 py-1",children:e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Functions"})}),L.map(p=>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:p.name}),p.isAnalyzing&&p.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(oe,{filePath:p.filePath,projectRoot:s}),p.testFile?e.jsx(Ke,{testFile:p.testFile,entityName:p.name}):e.jsx("div",{className:"px-2 pt-1",children:e.jsx("span",{className:"text-[10px] text-gray-500",children:"No test file"})})]},p.sha)),D.map(p=>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:p.name})}),e.jsx(oe,{filePath:p.filePath,projectRoot:s}),e.jsx(Ke,{testFile:p.testFile,entityName:p.name})]},p.name))]})]})})}function Fs(t,s,a=new Date){const n={"1d":1,"3d":3,"7d":7,"30d":30}[s],c=new Date(a);c.setDate(c.getDate()-n);const r=c.toISOString().split("T")[0],o=t.filter(S=>S.date>=r),l=new Set(o.map(S=>S.commitSha).filter(Boolean)),m=new Map;for(const S of o)if(S.scenarioScreenshots)for(const g of S.scenarioScreenshots){m.has(g.name)||m.set(g.name,[]);const I=m.get(g.name);I.some(f=>f.path===g.path)||I.push({path:g.path,time:S.time})}for(const S of m.values())S.sort((g,I)=>g.time.localeCompare(I.time));const v=[],y=new Map;for(const[S,g]of m){const I=S.indexOf(" - ");if(I!==-1){const f=S.slice(0,I);y.has(f)||y.set(f,[]),y.get(f).push({name:S,screenshots:g})}else v.push({name:S,screenshots:g})}return{commitCount:l.size,entryCount:o.length,appScenarios:v,componentGroups:y,totalScenarios:m.size}}function Bs(t){const s=new Map;for(const a of[...t].reverse()){const n=s.get(a.date)||[];n.push(a),s.set(a.date,n)}return s}function Os(t){const s=new Map;for(const a of t){let n;if("componentName"in a&&a.componentName)n=a.componentName;else if("componentName"in a&&a.componentName===null)n="App";else{const r=a.name.indexOf(" - ");n=r!==-1?a.name.slice(0,r):"App"}const c=s.get(n)||[];c.push(a),s.set(n,c)}return[...s.entries()].sort(([a],[n])=>a==="App"?-1:n==="App"?1:a.localeCompare(n))}const Nt=120;function Lt({text:t,theme:s}){const[a,n]=i.useState(!1),c=t.length>Nt,r=c&&!a?t.slice(0,Nt)+"…":t,o=s==="light";return e.jsxs("div",{className:`px-4 py-2 ${o?"border-b border-gray-200 bg-gray-50":"border-b border-[#3d3d3d] bg-[#252525]"}`,children:[e.jsx("span",{className:"text-[9px] font-semibold uppercase tracking-wider text-gray-500",children:"User Prompt"}),e.jsxs("p",{className:`text-[11px] mt-0.5 mb-0 leading-relaxed ${o?"text-gray-600":"text-gray-400"}`,children:[r,c&&e.jsx("button",{onClick:()=>n(!a),className:`ml-1 text-[11px] font-medium bg-transparent border-none p-0 cursor-pointer ${o?"text-blue-500 hover:text-blue-700":"text-[#00a0c4] hover:text-[#00c0e8]"}`,children:a?"Show less":"Read more…"})]})]})}function wt({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 zs({testFile:t,entityName:s}){const{results:a,isRunning:n,runTests:c}=Qe(t);if(n&&!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 r=s?a.testCases.filter(m=>m.fullName.startsWith(s)):a.testCases,o=r.length>0?r:a.testCases;if(o.length===0)return null;const l=s?`${s} > `:"";return e.jsxs("div",{className:"pt-1 space-y-0.5",children:[o.map(m=>{var y;const v=l&&m.fullName.startsWith(l)?m.fullName.slice(l.length):m.fullName;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[m.status==="passed"?e.jsx("span",{className:"text-green-400 text-[10px]",children:"✓"}):m.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] ${m.status==="passed"?"text-green-400":m.status==="failed"?"text-red-400":"text-gray-500"}`,children:v})]}),m.status==="failed"&&((y=m.failureMessages)==null?void 0:y.map((S,g)=>e.jsx("div",{className:"pl-4 text-[9px] text-red-400/70 truncate max-w-full",title:S,children:S.split(`
|
|
4
|
+
`)[0]},g)))]},m.fullName)}),e.jsx("button",{onClick:c,disabled:n,className:"mt-1 text-[10px] text-[#00a0c4] hover:text-[#38bdf8] transition-colors cursor-pointer disabled:opacity-50 bg-transparent border-none p-0",children:n?"Running...":"Re-run"})]})}const Ws={added:"text-green-400",untracked:"text-green-400",modified:"text-blue-400",renamed:"text-purple-400"};function Us({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 ${Ws[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 Hs={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 Js(t){try{return new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}}function Vs(t){try{return new Date(t+"T00:00:00").toLocaleDateString([],{weekday:"long",month:"long",day:"numeric"})}catch{return t}}const Gs=[{value:"1d",label:"1 Day"},{value:"3d",label:"3 Days"},{value:"7d",label:"1 Week"},{value:"30d",label:"1 Month"}];function qs({entries:t,onScreenshotClick:s}){const[a,n]=i.useState(!1),[c,r]=i.useState("7d"),o=i.useMemo(()=>Fs(t,c),[t,c]);return e.jsxs("div",{className:"bg-[#2d2d2d] rounded-lg overflow-hidden",children:[e.jsxs("button",{onClick:()=>n(!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:Gs.map(l=>e.jsx("button",{onClick:()=>r(l.value),className:`px-2.5 py-1 text-[10px] font-medium rounded transition-colors cursor-pointer border ${c===l.value?"bg-[#005c75] text-white border-[#005c75]":"bg-transparent text-gray-400 border-[#4d4d4d] hover:text-white hover:border-[#005c75]"}`,children:l.label},l.value))}),e.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-gray-400",children:[e.jsxs("span",{children:[e.jsx("span",{className:"text-white font-medium",children:o.commitCount})," ",o.commitCount===1?"commit":"commits"]}),e.jsx("span",{className:"text-[#3d3d3d]",children:"|"}),e.jsxs("span",{children:[e.jsx("span",{className:"text-white font-medium",children:o.totalScenarios})," ",o.totalScenarios===1?"scenario changed":"scenarios changed"]}),e.jsx("span",{className:"text-[#3d3d3d]",children:"|"}),e.jsxs("span",{children:[e.jsx("span",{className:"text-white font-medium",children:o.entryCount})," ",o.entryCount===1?"entry":"entries"]})]}),o.totalScenarios===0?e.jsx("p",{className:"text-[11px] text-gray-500 italic m-0",children:"No scenario changes in this period."}):e.jsxs("div",{className:"space-y-3",children:[o.appScenarios.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("span",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider",children:"Application"}),o.appScenarios.map(l=>e.jsx(St,{scenario:l,onScreenshotClick:s},l.name))]}),o.componentGroups.size>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("span",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider",children:"Components"}),[...o.componentGroups.entries()].sort(([l],[m])=>l.localeCompare(m)).map(([l,m])=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("span",{className:"text-[10px] font-medium text-gray-400",children:l}),m.map(v=>e.jsx(St,{scenario:v,onScreenshotClick:s},v.name))]},l))]})]})]})]})}function St({scenario:t,onScreenshotClick:s}){const a=t.name.indexOf(" - "),n=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:n}),e.jsx("div",{className:"flex items-center gap-1 overflow-x-auto",children:t.screenshots.map((c,r)=>e.jsxs("div",{className:"flex items-center shrink-0",children:[r>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(c.time).toLocaleDateString()})`,onClick:()=>s==null?void 0:s({screenshotUrl:`/api/editor-journal-image/${c.path.replace("screenshots/","")}`,commitSha:null,commitMessage:null,scenarioName:t.name}),children:e.jsx("img",{src:`/api/editor-journal-image/${c.path.replace("screenshots/","")}`,alt:t.name,className:"max-w-full max-h-full object-contain",loading:"lazy"})})]},c.path))})]})}function Ys({isActive:t,onScreenshotClick:s,glossaryFunctions:a=[]}){const[n,c]=i.useState([]),[r,o]=i.useState(!0),[l,m]=i.useState(new Set),v=i.useCallback(g=>{m(I=>{const f=new Set(I);return f.has(g)?f.delete(g):f.add(g),f})},[]),y=i.useCallback(async()=>{try{const g=await fetch("/api/editor-journal");if(g.ok){const I=await g.json();c(I.entries||[])}}catch{}finally{o(!1)}},[]);if(i.useEffect(()=>{y()},[y]),i.useEffect(()=>{t&&y()},[t,y]),i.useEffect(()=>{if(!t)return;const g=setInterval(()=>void y(),5e3);return()=>clearInterval(g)},[t,y]),r)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(n.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 S=Bs(n);return e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsx(qs,{entries:n,onScreenshotClick:s}),[...S.entries()].map(([g,I])=>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:Vs(g)})}),e.jsx("div",{className:"space-y-2",children:I.map((f,B)=>{const O=Hs[f.type]||{label:f.type,color:"bg-gray-600"},L=`${f.time}-${B}`,D=l.has(L);return e.jsxs("div",{className:"bg-[#2d2d2d] rounded-lg overflow-hidden",children:[e.jsxs("div",{className:`p-3 space-y-2 ${D?"":"max-h-[300px] overflow-y-auto"}`,children:[e.jsx("div",{className:"flex items-start gap-2 cursor-pointer",onClick:()=>v(L),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:f.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:Js(f.time)}),f.featureName&&e.jsx("span",{className:"text-[10px] text-gray-500 italic truncate",title:f.featureName,children:f.featureName})]})}),f.userPrompt&&e.jsx(Lt,{text:f.userPrompt,theme:"dark"}),e.jsx("p",{className:"text-xs text-gray-400 leading-relaxed",children:f.description}),f.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/${f.screenshot.replace("screenshots/","")}`,commitSha:f.commitSha,commitMessage:f.commitMessage,scenarioName:f.title}),children:e.jsx("img",{src:`/api/editor-journal-image/${f.screenshot.replace("screenshots/","")}`,alt:f.title,className:"max-w-full max-h-full object-contain",loading:"lazy"})}),f.scenarioScreenshots&&f.scenarioScreenshots.length>0&&(()=>{const _=Os(f.scenarioScreenshots),N=f.entityChangeStatus,M=_.filter(([h])=>h==="App").flatMap(([,h])=>h),U=_.filter(([h])=>h!=="App"),p=new Map;for(const h of M){const w=h,k=w.pageFilePath?Me(Ee(w.pageFilePath)):_e(w.url??null),T=p.get(k)||[];T.push(h),p.set(k,T)}const x=[...p.entries()],b=h=>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/${h.path.replace("screenshots/","")}`,commitSha:f.commitSha,commitMessage:f.commitMessage,scenarioName:h.name}),children:e.jsx("img",{src:`/api/editor-journal-image/${h.path.replace("screenshots/","")}`,alt:h.name,title:h.name,className:"max-w-full max-h-full object-contain",loading:"lazy"})},h.path);return e.jsxs("div",{className:"space-y-2",children:[x.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"}),x.map(([h,w])=>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:h}),(N==null?void 0:N[h])&&e.jsx(wt,{status:N[h]})]}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-0.5",children:w.map(b)})]},h))]}),U.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("span",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider",children:"Components"}),U.map(([h,w])=>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:h}),(N==null?void 0:N[h])&&e.jsx(wt,{status:N[h]})]}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-0.5",children:w.map(b)})]},h))]})]})})(),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(_=>e.jsxs("div",{children:[e.jsx("span",{className:"text-[11px] font-medium text-gray-200",children:_.name}),e.jsx("span",{className:"text-[9px] text-gray-500 truncate block",children:_.filePath}),_.testFile?e.jsx(zs,{testFile:_.testFile,entityName:_.name}):e.jsx("div",{className:"pt-1",children:e.jsx("span",{className:"text-[10px] text-gray-500",children:"No test file"})})]},_.name))})]}),f.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:f.commitSha.slice(0,7)}),e.jsx("span",{className:"text-gray-500 truncate",children:f.commitMessage})]}),D&&f.modifiedFiles&&f.modifiedFiles.length>0&&e.jsx(Us,{files:f.modifiedFiles})]}),e.jsxs("button",{onClick:()=>v(L),className:"w-full py-1.5 text-[10px] text-gray-500 hover:text-gray-300 border-t border-[#3d3d3d] transition-colors cursor-pointer",children:["——— ",D?"Collapse":"Expand"," ———"]})]},L)})})]},g))]})})}function Ks({prompt:t,height:s=300,onClose:a}){const n=i.useRef(null),c=i.useRef(null),r=i.useRef(null),o=i.useRef(!1),l=i.useRef(t);return i.useEffect(()=>{const m=n.current;if(!m)return;let v=!1,y=null;async function S(){const[g,I]=await Promise.all([Xe(()=>import("./xterm-BqvuqXEL.js"),[]),Xe(()=>import("./addon-fit-YJmn1quW.js"),[])]);if(v)return;{let p=document.getElementById("xterm-css");p||(p=document.createElement("style"),p.id="xterm-css",document.head.appendChild(p)),p.textContent=`
|
|
5
|
+
.xterm { cursor: text; position: relative; user-select: none; -ms-user-select: none; -webkit-user-select: none; }
|
|
6
|
+
.xterm.focus, .xterm:focus { outline: none; }
|
|
7
|
+
.xterm .xterm-helpers { position: absolute; top: 0; z-index: 5; }
|
|
8
|
+
.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; caret-color: transparent !important; clip-path: inset(100%) !important; }
|
|
9
|
+
.xterm .composition-view { background: #000; color: #FFF; display: none; position: absolute; white-space: nowrap; z-index: 1; }
|
|
10
|
+
.xterm .composition-view.active { display: block; }
|
|
11
|
+
.xterm .xterm-viewport { background-color: #000; overflow-y: scroll; cursor: default; position: absolute; right: 0; left: 0; top: 0; bottom: 0; }
|
|
12
|
+
.xterm .xterm-screen { position: relative; }
|
|
13
|
+
.xterm .xterm-screen canvas { position: absolute; left: 0; top: 0; }
|
|
14
|
+
.xterm .xterm-scroll-area { visibility: hidden; }
|
|
15
|
+
.xterm-char-measure-element { display: inline-block; visibility: hidden; position: absolute; top: 0; left: -9999em; line-height: normal; }
|
|
16
|
+
.xterm.enable-mouse-events { cursor: default; }
|
|
17
|
+
.xterm.xterm-cursor-pointer, .xterm .xterm-cursor-pointer { cursor: pointer; }
|
|
18
|
+
.xterm.column-select.focus { cursor: crosshair; }
|
|
19
|
+
.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; }
|
|
20
|
+
.xterm .xterm-accessibility-tree:not(.debug) *::selection { color: transparent; }
|
|
21
|
+
.xterm .xterm-accessibility-tree { user-select: text; white-space: pre; }
|
|
22
|
+
.xterm .live-region { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
|
|
23
|
+
.xterm-dim { opacity: 1 !important; }
|
|
24
|
+
.xterm-underline-1 { text-decoration: underline; }
|
|
25
|
+
.xterm-underline-2 { text-decoration: double underline; }
|
|
26
|
+
.xterm-underline-3 { text-decoration: wavy underline; }
|
|
27
|
+
.xterm-underline-4 { text-decoration: dotted underline; }
|
|
28
|
+
.xterm-underline-5 { text-decoration: dashed underline; }
|
|
29
|
+
.xterm-overline { text-decoration: overline; }
|
|
30
|
+
.xterm-strikethrough { text-decoration: line-through; }
|
|
31
|
+
.xterm-screen .xterm-decoration-container .xterm-decoration { z-index: 6; position: absolute; }
|
|
32
|
+
.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer { z-index: 7; }
|
|
33
|
+
.xterm-decoration-overview-ruler { z-index: 8; position: absolute; top: 0; right: 0; pointer-events: none; }
|
|
34
|
+
.xterm-decoration-top { z-index: 2; position: relative; }
|
|
35
|
+
`}const f=new g.Terminal({theme:{background:"#1a1a1a",foreground:"#d4d4d4",cursor:"#d4d4d4",selectionBackground:"#264f78"},fontSize:12,fontFamily:"'IBM Plex Mono', 'Menlo', 'Monaco', monospace",cursorBlink:!0,scrollback:5e3,allowProposedApi:!0}),B=new I.FitAddon;f.loadAddon(B),f.open(m),requestAnimationFrame(()=>{try{B.fit()}catch{}}),r.current=f;let O=null;try{const p=await fetch("/api/editor-scenario-prompt",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:l.current})});p.ok&&(O=(await p.json()).promptFile)}catch{}if(v)return;const L=window.location.protocol==="https:"?"wss:":"ws:",D=window.location.host,_=new URLSearchParams;_.set("entityName","inline-claude");const N=`${L}//${D}/ws/terminal?${_.toString()}`,M=new WebSocket(N);c.current=M,M.onopen=()=>{M.send(JSON.stringify({type:"resize",cols:f.cols,rows:f.rows}))};let U=!1;M.onmessage=p=>{try{const x=JSON.parse(p.data);if(x.type==="session-id"&&!U){U=!0,setTimeout(()=>{const b=O?`claude "Read the file at '${O.replace(/'/g,"'\\''")}' for your instructions."`:"claude";M.send(JSON.stringify({type:"input",data:b+"\r"}))},300);return}if(x.type==="output"&&x.data){f.write(x.data);return}}catch{f.write(p.data)}},M.onclose=()=>{o.current||f.write(`\r
|
|
36
|
+
\x1B[90m--- Session ended ---\x1B[0m\r
|
|
37
|
+
`)},M.onerror=()=>{f.write(`\r
|
|
38
|
+
\x1B[31mConnection error\x1B[0m\r
|
|
39
|
+
`)},f.onData(p=>{M.readyState===WebSocket.OPEN&&M.send(JSON.stringify({type:"input",data:p}))}),y=new ResizeObserver(()=>{try{B.fit(),M.readyState===WebSocket.OPEN&&M.send(JSON.stringify({type:"resize",cols:f.cols,rows:f.rows}))}catch{}}),y.observe(m)}return S(),()=>{var g,I;v=!0,o.current=!0,y==null||y.disconnect(),((g=c.current)==null?void 0:g.readyState)===WebSocket.OPEN&&c.current.close(),(I=r.current)==null||I.dispose()}},[]),e.jsxs("div",{className:"border-t border-[#2d2d2d]",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 bg-[#1e1e1e]",children:[e.jsx("span",{className:"text-[10px] font-medium text-[#00a0c4]",children:"Claude"}),a&&e.jsx("button",{onClick:a,className:"text-gray-500 hover:text-gray-300 text-[10px] bg-transparent border-none cursor-pointer",children:"Close"})]}),e.jsx("div",{ref:n,style:{height:s,background:"#1a1a1a",padding:"4px 0",position:"relative",overflow:"hidden"}})]})}const kt=()=>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 Xs(t,s){if(t.length<=s)return t;const a=s-2;return[t[0],"ellipsis",...t.slice(t.length-a)]}function Ct({items:t,onNavigate:s}){if(t.length===0)return null;const a=Xs(t,4);return e.jsx("nav",{className:"flex items-center gap-1 text-xs min-w-0",children:a.map((n,c)=>{if(n==="ellipsis")return e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(kt,{}),e.jsx("span",{className:"text-gray-500",children:"..."})]},"ellipsis");const r=c===a.length-1;return e.jsxs("span",{className:"flex items-center gap-1 min-w-0",children:[c>0&&e.jsx(kt,{}),r?e.jsx("span",{className:"text-white font-medium truncate",children:n.name}):e.jsx("button",{onClick:()=>s(n.componentName,n.entitySha),className:"text-gray-400 hover:text-white transition-colors cursor-pointer bg-transparent border-none p-0 truncate",children:n.name})]},n.componentName||"app")})})}function Qs(t,s,a,n){var m;const c=n.length>0?n.map(v=>`- "${v.name}" (ID: ${v.id})${v.url?` — URL: ${v.url}`:""}`).join(`
|
|
40
|
+
`):"(no scenarios yet)",r=s.endsWith("/page.tsx")||s.endsWith("/page.js"),o=((m=n.find(v=>v.url))==null?void 0:m.url)||"/",l=[`You are helping edit scenarios for the "${t}" entity in a CodeYam project.`,"","## Entity",`- **Name:** ${t}`,`- **File:** ${s}`,`- **Type:** ${r?"Page (application scenario with seed data)":"Component (component scenario with mock props)"}`,"","## Existing Scenarios",c,""];return r?l.push("## How Seed Data Works","","Application scenarios use `seed` data to populate the database before the page is captured.","The seed is a JSON object where each key is a Prisma model name in camelCase singular (matching the Prisma client accessor name) and the value is an array of records.","","### Seed Key Naming Convention","The key must be the camelCase singular form of the Prisma model name:",'- `model User` → key `"user"`','- `model BlogPost` → key `"blogPost"`','- `model Feedback` → key `"feedback"`',"",'**WARNING:** Do NOT use plural forms like "users", "blogPosts", or "feedbacks" — the seed adapter will silently fail to match them.',"","To understand the data models, read the Prisma schema at `prisma/schema.prisma`.","To see examples of existing seed data, look at `.codeyam/editor-scenarios/*.seed.json` files.","",`Also read the source file at \`${s}\` to understand what data the page queries and renders.`,"","## Registering a Scenario","","For small seed data, pass it inline:","```",`codeyam editor register '{"name":"Scenario Name","type":"application","url":"${o}","dimensions":["Laptop"],"seed":{"user":[...],"feedback":[...]}}'`,"```","","For large seed data, write it to a temp file and use @file syntax:","```","# Write JSON to a temp file","cat > .codeyam/tmp/scenario.json << 'SCENARIO_EOF'",`{"name":"Scenario Name","type":"application","url":"${o}","dimensions":["Laptop"],"seed":{"user":[...],"feedback":[...]}}`,"SCENARIO_EOF","codeyam editor register @.codeyam/tmp/scenario.json","```"):l.push("## Registering a Scenario","",`Read the source file at \`${s}\` to understand what props the component expects.`,"","```",`codeyam editor register '{"name":"Scenario Name","type":"component","componentName":"${t}","componentPath":"${s}","dimensions":["Laptop"],"mockData":{"propName":"value"}}'`,"```"),l.push("","## Deleting a Scenario","","To delete a scenario, use its ID from the list above:","```","codeyam editor delete <scenarioId>","```","","## Validating Seed Data","","Before registering, you can validate seed data structure and check that keys match Prisma models:","```",`codeyam editor validate-seed '{"user":[...]}'`,"```"),l.push("","## Important","- DO NOT take any action until the user tells you what they want","- Start by briefly listing the existing scenarios",'- Then ask: "Would you like to modify an existing scenario or add a new one?"',"- Wait for the user's answer before proceeding",'- Keep scenario names descriptive: "Empty State", "With Comments", "Admin View", etc.',`- Each scenario should capture a distinct, meaningful state of the ${r?"page":"component"}`),l.join(`
|
|
41
|
+
`)}function Dt(t){var c,r;const s=new Map,a=new Map;for(const o of t)if(o.componentName){const l=a.get(o.componentName)||[];l.push(o),a.set(o.componentName,l)}else if(_t(o.url)){const l=(c=o.url)==null?void 0:c.match(/[?&]c=([^&]+)/),m=l?decodeURIComponent(l[1]):"Isolated",v=a.get(m)||[];v.push(o),a.set(m,v)}else{const l=o.displayName||((r=o.pageFilePath)!=null&&r.startsWith("app/")?Me(Ee(o.pageFilePath)):_e(o.url)),m=s.get(l)||[];m.push(o),s.set(l,m)}const n=new Map([...a.entries()].sort(([o],[l])=>o.localeCompare(l)));return{pageGroups:s,componentGroups:n}}function Zs(t,s){var n,c;const a=new Map;for(const[r,o]of t){const l=(n=o.find(m=>m.entitySha))==null?void 0:n.entitySha;l&&a.set(r,l)}for(const[r,o]of s){const l=(c=o.find(m=>m.entitySha))==null?void 0:c.entitySha;l&&a.set(r,l)}return a}function ea(t,s,a,n){if(s.has(t))return!0;const c=a.find(r=>r.sha===t);return c?n.has(c.name):!1}function ta(t,s,a,n){const c=[];for(const[r,o]of t){const l=a.get(r);l?n(l)||c.push({name:r,scenarios:o,reason:"incomplete"}):c.push({name:r,scenarios:o,reason:"missing"})}for(const[r,o]of s){const l=a.get(r);l?n(l)||c.push({name:r,scenarios:o,reason:"incomplete"}):c.push({name:r,scenarios:o,reason:"missing"})}return c}function sa(t,s,a){if(!t)return null;const n=s.find(r=>r.sha===t);if(!n)return null;const c=a.find(r=>r.entitySha===t);return{sha:t,name:n.name,filePath:n.filePath,entityType:n.entityType,displayName:(c==null?void 0:c.displayName)||n.name}}function Ft(t,s){const a=s.some(c=>!c.componentName),n=s.map(c=>`'${c.id}'`).join(", ");return a?[`### Page: "${t}" (${s.length} scenario(s))`,"","Step A: Find the source file that renders this page by running:",' find src app -name "App.tsx" -o -name "App.jsx" -o -name "page.tsx" -o -name "page.jsx" -o -name "index.tsx" 2>/dev/null',"","Pick the file that is the main app entry point or the page component for this route. Confirm it exists with `cat <filepath> | head -5`.","","Step B: Set page_file_path on all scenarios for this page (replace PAGE_FILE_PATH with the path from Step A):",` sqlite3 .codeyam/db.sqlite3 "UPDATE editor_scenarios SET page_file_path = 'PAGE_FILE_PATH' WHERE id IN (${n});"`,"","Step C: Get the entity SHA (after running analyze-imports in the shared step above):",` sqlite3 .codeyam/db.sqlite3 "SELECT sha FROM entities WHERE file_path = 'PAGE_FILE_PATH' ORDER BY created_at DESC LIMIT 1;"`,"","If no rows appear, the path was wrong — go back to Step A.","","Step D: Set entity_sha and display_name on all scenarios (replace ENTITY_SHA with the SHA from Step C):",` sqlite3 .codeyam/db.sqlite3 "UPDATE editor_scenarios SET entity_sha = 'ENTITY_SHA', display_name = '${t}' WHERE id IN (${n});"`].join(`
|
|
42
|
+
`):[`### Component: "${t}" (${s.length} scenario(s))`,"","Step A: Get the entity SHA (after running analyze-imports in the shared step above):",` sqlite3 .codeyam/db.sqlite3 "SELECT sha FROM entities WHERE name = '${t}' ORDER BY created_at DESC LIMIT 1;"`,"","If no rows appear, check that .codeyam/glossary.json contains an entry for this component.","","Step B: Set entity_sha and display_name on all scenarios (replace ENTITY_SHA with the SHA from Step A):",` sqlite3 .codeyam/db.sqlite3 "UPDATE editor_scenarios SET entity_sha = 'ENTITY_SHA', display_name = '${t}' WHERE id IN (${n});"`].join(`
|
|
43
|
+
`)}function Pt({name:t,scenarios:s,reason:a="missing"}){var r,o;const n=((r=s[0])==null?void 0:r.componentPath)||((o=s[0])==null?void 0:o.pageFilePath)||null,c=a==="incomplete"?[`The "${t}" entity exists but has not been fully analyzed — its components and functions cannot be displayed.`,"","Follow these steps:","",`Step 1: Check if "${t}" is in the glossary:`,` cat .codeyam/glossary.json | grep "${t}"`,"","If not found, add an entry to .codeyam/glossary.json:",` { "name": "${t}", "filePath": "${n||"FILL_IN_PATH"}", "description": "...", "returnType": "JSX.Element" }`,"","Step 2: Run: codeyam editor analyze-imports","","Step 3: Reload the editor page and verify components/functions appear."].join(`
|
|
44
|
+
`):[`The "${t}" ${s.some(l=>!l.componentName)?"page":"component"} is missing entity data in the CodeYam database. Its scenarios are hidden until this is fixed.`,"","IMPORTANT: Do NOT re-register scenarios — that would overwrite their screenshots. Only update the database directly.","","Follow these steps EXACTLY:","","Step 1: Run: codeyam editor analyze-imports","","Step 2: Fix this entity:","",Ft(t,s),"","Step 3: Reload the editor page in the browser and verify the scenarios appear."].join(`
|
|
45
|
+
`);return e.jsx(he,{content:c,label:"Copy Fix Prompt",copiedLabel:"Copied!",className:"text-[9px] text-amber-400 hover:text-amber-300 bg-transparent border border-amber-400/30 rounded px-1.5 py-0.5 cursor-pointer transition-colors ml-2"})}function aa({brokenEntities:t}){if(t.length===0)return null;const s=t.reduce((r,o)=>r+o.scenarios.length,0),a=t.filter(r=>r.reason==="incomplete"),n=t.filter(r=>r.reason==="missing"),c=[`${t.length} entities are missing data in the CodeYam database. ${s} total scenario(s) are hidden until this is fixed.`,"","IMPORTANT: Do NOT re-register scenarios — that would overwrite their screenshots. Only update the database directly.","","Follow these steps EXACTLY:","",...a.length>0?["## Step 1: Add missing entries to the glossary","","Read `.codeyam/glossary.json` and check if these entities have entries. For each one that is missing, add an entry:","",...a.map(r=>{var l,m;const o=((l=r.scenarios[0])==null?void 0:l.componentPath)||((m=r.scenarios[0])==null?void 0:m.pageFilePath)||"FILL_IN_PATH";return`- "${r.name}" (filePath: "${o}")`}),"",'Each glossary entry needs: name, filePath, description, returnType (use "JSX.Element" for components/pages).',""]:["## Step 1: No glossary changes needed",""],"## Step 2: Run import analysis"," codeyam editor analyze-imports","",...n.length>0?["## Step 3: Fix missing entity associations","",...n.map(r=>Ft(r.name,r.scenarios)),""]:[],`## Step ${n.length>0?"4":"3"}: Reload the editor page in the browser and verify all scenarios appear.`].join(`
|
|
46
|
+
`);return e.jsxs("div",{className:"mb-3 p-2 rounded border border-amber-400/30 bg-amber-400/5",children:[e.jsxs("p",{className:"text-[10px] text-amber-400/80 m-0 leading-relaxed",children:[t.length," ",t.length===1?"entity is":"entities are"," missing data (",s," hidden scenario",s!==1?"s":"","). Copy this prompt into Claude to fix them all at once."]}),e.jsx("div",{className:"mt-1.5",children:e.jsx(he,{content:c,label:"Copy Fix All Prompt",copiedLabel:"Copied!",className:"text-[9px] text-amber-400 hover:text-amber-300 bg-transparent border border-amber-400/30 rounded px-1.5 py-0.5 cursor-pointer transition-colors"})})]})}function na({scenarios:t,entityName:s,entityFilePath:a,entityType:n,onSwitchToBuild:c,onScenarioSelect:r}){const[o,l]=i.useState(!1),[m,v]=i.useState(null),[y,S]=i.useState(""),[g,I]=i.useState(!1),[f,B]=i.useState(null),[O,L]=i.useState(!1),D=i.useCallback(async N=>{if(!(!y.trim()||g)){I(!0);try{(await fetch("/api/editor-rename-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioId:N,name:y.trim()})})).ok&&v(null)}catch{}finally{I(!1)}}},[y,g]),_=i.useCallback(async N=>{if(confirm(`Delete scenario "${N.name}"?`)){B(N.id);try{const M=N.screenshotPaths?Object.values(N.screenshotPaths):N.screenshotPath?[N.screenshotPath]:[];await fetch("/api/delete-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioId:N.id,screenshotPaths:M})})}catch{}finally{B(null)}}},[]);return o?e.jsxs("div",{className:"border border-[#3d3d3d] rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 bg-[#1e1e1e]",children:[e.jsx("span",{className:"text-xs font-medium text-gray-400",children:"Edit Scenarios"}),e.jsx("button",{onClick:()=>{l(!1),v(null)},className:"text-gray-500 hover:text-gray-300 text-xs bg-transparent border-none cursor-pointer",children:"Close"})]}),e.jsx("div",{className:"divide-y divide-[#2d2d2d]",children:t.map(N=>e.jsxs("div",{className:"px-3 py-2 flex items-center gap-2 hover:bg-[#252525] cursor-pointer transition-colors",style:{opacity:f===N.id?.4:1},onClick:()=>{m!==N.id&&r(N)},children:[N.screenshotPath?e.jsx(Le,{scenarioId:N.id,updatedAt:N.updatedAt,alt:"",className:"rounded w-[40px] h-[40px] shrink-0 overflow-hidden",imgClassName:"w-full h-full object-cover"}):e.jsx("div",{className:"rounded bg-[#1e1e1e]",style:{width:40,height:40,flexShrink:0}}),m===N.id?e.jsxs("form",{className:"flex-1 flex items-center gap-1.5 min-w-0",onSubmit:M=>{M.preventDefault(),D(N.id)},children:[e.jsx("input",{type:"text",value:y,onChange:M=>S(M.target.value),className:"flex-1 px-2 py-1 text-xs bg-[#1e1e1e] text-white border border-[#3d3d3d] rounded outline-none focus:border-[#005c75] min-w-0",autoFocus:!0,disabled:g}),e.jsx("button",{type:"submit",disabled:g||!y.trim(),className:"px-2 py-1 text-[10px] bg-[#005c75] text-white rounded hover:bg-[#004d63] disabled:opacity-40 cursor-pointer border-none",children:g?"...":"Save"}),e.jsx("button",{type:"button",onClick:()=>v(null),className:"px-2 py-1 text-[10px] text-gray-400 hover:text-white cursor-pointer bg-transparent border-none",children:"Cancel"})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"flex-1 text-xs text-gray-300 truncate min-w-0",children:N.name}),e.jsx("button",{onClick:M=>{M.stopPropagation(),v(N.id),S(N.name)},className:"text-[10px] text-gray-500 hover:text-gray-300 cursor-pointer bg-transparent border-none px-1",title:"Rename",children:"Rename"}),e.jsx("button",{onClick:M=>{M.stopPropagation(),_(N)},disabled:f===N.id,className:"text-[10px] text-red-400/60 hover:text-red-400 cursor-pointer bg-transparent border-none px-1",title:"Delete",children:"Delete"})]})]},N.id))}),O?e.jsx(Ks,{prompt:Qs(s,a,n,t),height:500,onClose:()=>L(!1)}):e.jsx("div",{className:"px-3 py-2.5 bg-[#1e1e1e] border-t border-[#2d2d2d] flex justify-center",children:e.jsx("button",{onClick:()=>L(!0),className:"px-5 py-2 text-xs font-medium text-white cursor-pointer bg-[#005c75] hover:bg-[#004d63] border-none rounded-md transition-colors",children:"Modify with Claude"})})]}):e.jsx("div",{className:"flex justify-center",children:e.jsx("button",{onClick:()=>l(!0),className:"px-5 py-2 text-xs font-medium text-gray-300 hover:text-white transition-colors cursor-pointer bg-[#2a2a2a] hover:bg-[#333] border border-[#4a4a4a] hover:border-[#666] rounded-md",children:"Edit Scenarios"})})}function pe({scenarioId:t,updatedAt:s,hasScreenshot:a,imgSrc:n,name:c,isActive:r,onSelect:o}){const l=t&&a,m=!t&&n;return e.jsxs("button",{onClick:o,className:"flex flex-col items-center gap-1 cursor-pointer group w-full",title:c,children:[e.jsx("div",{className:`w-full aspect-square rounded overflow-hidden border-2 transition-all bg-[#1a1a1a] ${r?"border-[#005c75] ring-1 ring-[#005c75]":"border-transparent hover:border-[#4d4d4d]"}`,children:l?e.jsx(Le,{scenarioId:t,updatedAt:s,alt:c,className:"w-full h-full",imgClassName:"w-full h-full object-contain"}):m?e.jsx("img",{src:n,alt:c,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 ${r?"text-white":"text-gray-500 group-hover:text-gray-300"}`,children:c})]})}function Pe({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(he,{content:t,icon:!0,iconSize:10,className:"shrink-0 text-gray-500 hover:text-gray-300 transition-colors"})]}):null}function ra({hasProject:t,scenarios:s,analyzedEntities:a,allEntities:n=[],glossaryFunctions:c=[],glossaryEntries:r=[],projectRoot:o,activeScenarioId:l,onScenarioSelect:m,onAnalyzedScenarioSelect:v,onSwitchToBuild:y,zoomComponent:S,focusedEntity:g,onZoomChange:I,entityImports:f,pageFilePaths:B={},projectTitle:O,projectDescription:L,migrationMode:D="none",migrationState:_,onStartMigration:N,breadcrumbItems:M=[]}){var ee;const{pageGroups:U,componentGroups:p}=i.useMemo(()=>Dt(s),[s]),x=i.useMemo(()=>Zs(U,p),[U,p]),b=i.useMemo(()=>new Set(a.map(E=>E.sha)),[a]),h=i.useMemo(()=>new Set(Object.keys(f||{})),[f]),w=i.useCallback(E=>ea(E,b,n,h),[b,n,h]),k=i.useMemo(()=>ta(U,p,x,w),[U,p,x,w]),T=i.useMemo(()=>a.filter(E=>E.entityType==="visual").sort((E,R)=>E.name.localeCompare(R.name)),[a]),A=i.useMemo(()=>{const E=new Map;for(const R of c)E.set(R.name,R);return E},[c]),C=i.useRef(null),q=i.useRef(0),ue=i.useCallback(()=>{C.current&&(q.current=C.current.scrollTop)},[]);i.useEffect(()=>{C.current&&q.current>0&&(C.current.scrollTop=q.current)});const fe=(g==null?void 0:g.sha)??"overview";if(!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:y,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(D==="candidate")return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-5 px-8 text-center max-w-[420px]",children:[e.jsx("h2",{className:"text-lg font-medium text-white font-['IBM_Plex_Sans'] m-0",children:"Migrate Your Project"}),e.jsx("p",{className:"text-sm text-gray-400 m-0 font-['IBM_Plex_Sans'] leading-relaxed",children:"It looks like you have an existing project. Claude can survey your codebase and systematically migrate it — deconstructing pages into clean components, extracting functions with tests, and creating scenarios. One page per session."}),e.jsx("button",{onClick:N,className:"px-6 py-3 bg-[#005c75] text-white text-sm font-medium rounded-lg hover:bg-[#004d63] transition-colors cursor-pointer",children:"Get Started"}),e.jsx("button",{onClick:y,className:"text-xs text-gray-500 hover:text-gray-300 bg-transparent border-none p-0 cursor-pointer underline",children:"Skip — build a new feature instead"})]})});if(D==="active"&&_){const E=_.pages||[],R=E.filter($=>$.status==="complete").length,J=E.length,V=J>0?Math.round(R/J*100):0;return e.jsxs("div",{className:"flex-1 flex flex-col overflow-auto p-4",children:[e.jsx("h2",{className:"text-lg font-medium text-white font-['IBM_Plex_Sans'] m-0 mb-3",children:"Project Migration"}),e.jsxs("div",{className:"mb-4",children:[e.jsx("div",{className:"flex items-center gap-2 mb-1",children:e.jsxs("span",{className:"text-xs text-gray-400 font-['IBM_Plex_Sans']",children:[R,"/",J," pages (",V,"%)"]})}),e.jsx("div",{className:"w-full h-1.5 bg-[#2d2d2d] rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-[#005c75] rounded-full transition-all",style:{width:`${V}%`}})})]}),e.jsx("div",{className:"space-y-1.5",children:E.map(($,se)=>{const ne=$.status==="complete"?"✓":$.status==="in-progress"?"→":"○",G=$.status==="complete"?"text-green-400":$.status==="in-progress"?"text-cyan-400":"text-gray-600";return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`text-xs ${G} w-3 text-center`,children:ne}),e.jsx("span",{className:`text-xs font-['IBM_Plex_Sans'] ${$.status==="in-progress"?"text-white font-medium":$.status==="complete"?"text-gray-400":"text-gray-600"}`,children:$.name}),e.jsx("span",{className:"text-[10px] text-gray-600",children:$.route}),$.status==="complete"&&e.jsxs("span",{className:"text-[10px] text-gray-600",children:[($.extractedComponents||[]).length,"c"," ",($.extractedFunctions||[]).length,"f"," ",$.scenarioCount||0,"s"]})]},se)})}),(_.sharedComponents||[]).length>0&&e.jsxs("div",{className:"mt-4",children:[e.jsx("h3",{className:"text-xs font-medium text-gray-400 font-['IBM_Plex_Sans'] mb-1.5",children:"Shared Components"}),(_.sharedComponents||[]).map(($,se)=>e.jsxs("div",{className:"text-[10px] text-gray-500 mb-0.5",children:[$.name," ",e.jsxs("span",{className:"text-gray-600",children:["— used in: ",($.usedInPages||[]).join(", ")]})]},se))]}),e.jsx("div",{className:"mt-4",children:e.jsx("button",{onClick:y,className:"px-4 py-2 bg-[#005c75] text-white text-xs font-medium rounded-lg hover:bg-[#004d63] transition-colors cursor-pointer",children:"Continue in Chat"})})]})}if(!(s.length>0||T.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:[O?e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"text-lg font-medium text-white font-['IBM_Plex_Sans'] m-0",children:O}),L&&e.jsx("p",{className:"text-sm text-gray-400 m-0 font-['IBM_Plex_Sans'] leading-relaxed",children:L})]}):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:y,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(g){const E=g.filePath,R=g.name,J=a.some(u=>u.sha===g.sha||u.filePath===E),V=!!((ee=f==null?void 0:f[R])!=null&&ee.length);if(!J&&!V){s.some(F=>F.componentName===R&&F.entitySha===g.sha);const u=s.filter(F=>F.entitySha===g.sha),W=[`The "${g.displayName}" entity (${E}) exists in the database but has not been fully analyzed. Its components and functions cannot be shown until it has import metadata.`,"","Follow these steps:","",`Step 1: Add "${R}" to the glossary if it's not already there:`,` Check: cat .codeyam/glossary.json | grep "${R}"`,"",` If not found, add an entry with name "${R}" and filePath "${E}" to .codeyam/glossary.json`,"","Step 2: Run import analysis:"," codeyam editor analyze-imports","","Step 3: Reload the editor page and verify components/functions appear."].join(`
|
|
47
|
+
`);return e.jsx("div",{ref:C,onScroll:ue,className:"flex-1 overflow-auto",children:e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsx(Ct,{items:M,onNavigate:I}),e.jsx("h2",{className:"text-sm font-semibold text-white m-0 font-['IBM_Plex_Sans'] uppercase tracking-wider",children:g.displayName}),E&&e.jsx(Pe,{filePath:E,projectRoot:o}),e.jsxs("div",{className:"py-2",children:[e.jsx("p",{className:"text-[11px] text-amber-400/80 m-0 leading-relaxed",children:"This entity has not been fully analyzed. Its components and functions cannot be displayed. Please copy and paste this prompt into Claude to fix the data."}),e.jsx("div",{className:"mt-2",children:e.jsx(he,{content:W,label:"Copy Fix Prompt",copiedLabel:"Copied!",className:"text-[10px] text-amber-400 hover:text-amber-300 bg-transparent border border-amber-400/30 rounded px-2 py-1 cursor-pointer transition-colors"})})]}),u.length>0&&e.jsx("div",{className:"grid grid-cols-3 gap-2",children:u.map(F=>e.jsx(pe,{scenarioId:F.id,updatedAt:F.updatedAt,hasScreenshot:!!F.screenshotPath,name:F.name,isActive:F.id===l,onSelect:()=>m(F)},F.id))})]})},fe)}const $=g.sha,se=s.filter(u=>!u.componentName&&(u.pageFilePath===E||$&&u.entitySha===$)),ne=s.filter(u=>u.componentName===R||u.componentPath===E),G=T.find(u=>u.filePath===E||u.name===R),le=A.get(R)||c.find(u=>u.filePath===E),ae=[...se,...ne],re=new Set((f==null?void 0:f[R])||[]),je=V?[...p.entries()].filter(([u])=>re.has(u)):[],Ie=V?T.filter(u=>re.has(u.name)&&!je.some(([W])=>W===u.name)):[],Te=V?r.filter(u=>re.has(u.name)&&u.returnType!=="JSX.Element"&&u.returnType!=="React.ReactNode").map(u=>({name:u.name,filePath:u.filePath,description:u.description||"",testFile:u.testFile,feature:u.feature})):[],be=je.length>0||Ie.length>0,Z=Te.length>0,Y=be||Z;return e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsx(Ct,{items:M,onNavigate:I}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold text-white m-0 font-['IBM_Plex_Sans'] uppercase tracking-wider",children:g.displayName}),g.filePath&&e.jsx(Pe,{filePath:g.filePath,projectRoot:o})]}),ae.length>0&&e.jsx("div",{className:"grid grid-cols-3 gap-2",children:ae.map(u=>e.jsx(pe,{scenarioId:u.id,updatedAt:u.updatedAt,hasScreenshot:!!u.screenshotPath,name:u.name,isActive:u.id===l,onSelect:()=>m(u)},u.id))}),G&&(G.scenarios.length>0||G.pendingScenarios.length>0)&&e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[G.scenarios.map(u=>e.jsx(pe,{imgSrc:u.screenshotPath?`/api/screenshot/${u.screenshotPath}`:null,name:u.name,isActive:!1,onSelect:()=>v({analysisId:G.analysisId,scenarioId:u.id,scenarioName:u.name,entitySha:G.sha,entityName:G.name})},u.id)),G.pendingScenarios.map(u=>e.jsx("div",{className:"px-2.5 py-1 bg-[#2a2a2a] text-gray-400 text-[10px] rounded-full",title:u,children:u},u))]}),le&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[10px] text-gray-500",children:"Tests:"}),e.jsx(Pe,{filePath:le.testFile,projectRoot:o})]}),ae.length===0&&!G&&!le&&e.jsx("div",{className:"text-xs text-gray-500",children:"No scenarios for this entity"}),ae.length>0&&e.jsx(na,{scenarios:ae,entityName:g.displayName,entityFilePath:g.filePath,entityType:g.entityType,onSwitchToBuild:y,onScenarioSelect:m}),Y&&e.jsxs("div",{className:"pt-3 mt-2 border-t border-[#3d3d3d] space-y-3",children:[be&&e.jsxs("div",{children:[e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Components"}),je.map(([u,W])=>e.jsx("div",{className:"mt-3",children:x.has(u)?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"py-1",children:e.jsx("button",{onClick:()=>I(u,x.get(u)),className:"text-[11px] font-medium text-gray-400 cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:u})}),W.length>0&&e.jsx("div",{className:"grid grid-cols-3 gap-2 pt-1",children:W.map(F=>e.jsx(pe,{scenarioId:F.id,updatedAt:F.updatedAt,hasScreenshot:!!F.screenshotPath,name:F.name,isActive:F.id===l,onSelect:()=>m(F)},F.id))})]}):e.jsxs("div",{className:"py-2",children:[e.jsx("span",{className:"text-[11px] font-medium text-gray-500",children:u}),e.jsx("p",{className:"text-[10px] text-amber-400/80 m-0 mt-1.5 leading-relaxed",children:"There is data missing that is required to show the scenarios for this component. Please copy and paste this prompt into Claude to ask Claude to fix the data."}),e.jsx("div",{className:"mt-1.5",children:e.jsx(Pt,{name:u,scenarios:W})})]})},u)),Ie.map(u=>e.jsxs("div",{className:"mt-3",children:[e.jsx("div",{className:"py-1",children:e.jsx("button",{onClick:()=>I(u.name,u.sha),className:"text-[11px] font-medium text-gray-400 cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:u.name})}),(u.scenarios.length>0||u.pendingScenarios.length>0)&&e.jsxs("div",{className:"grid grid-cols-3 gap-2 pt-1",children:[u.scenarios.map(W=>e.jsx(pe,{imgSrc:W.screenshotPath?`/api/screenshot/${W.screenshotPath}`:null,name:W.name,isActive:!1,onSelect:()=>v({analysisId:u.analysisId,scenarioId:W.id,scenarioName:W.name,entitySha:u.sha,entityName:u.name})},W.id)),u.pendingScenarios.map(W=>e.jsx("div",{className:"px-2.5 py-1 bg-[#2a2a2a] text-gray-400 text-[10px] rounded-full",title:W,children:W},W))]})]},u.sha))]}),Z&&e.jsxs("div",{children:[e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Functions"}),Te.map(u=>e.jsxs("div",{className:"mt-2",children:[e.jsx("div",{className:"py-1",children:e.jsx("button",{onClick:()=>I(u.name,x.get(u.name)),className:"text-[11px] font-medium text-gray-400 cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:u.name})}),e.jsx(Pe,{filePath:u.filePath,projectRoot:o}),u.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:u.testFile})]})]},u.name))]})]})]})})}return e.jsx("div",{ref:C,onScroll:ue,className:"flex-1 overflow-auto",children:e.jsxs("div",{className:"p-4 space-y-4",children:[O&&e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-white m-0 font-['IBM_Plex_Sans']",children:O}),L&&e.jsx("p",{className:"text-xs text-gray-400 m-0 mt-1 font-['IBM_Plex_Sans'] leading-relaxed",children:L})]}),k.length>1&&e.jsx(aa,{brokenEntities:k}),U.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:y,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:y,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:y,className:"text-[#00a0c4] hover:text-[#00c4eb] bg-transparent border-none p-0 cursor-pointer underline font-inherit text-inherit",children:"create a new page"})]}),[...U.entries()].sort(([E],[R])=>E==="Home"?-1:R==="Home"?1:E.localeCompare(R)).map(([E,R])=>{var J,V;return e.jsx("div",{className:"mt-2",children:x.has(E)&&w(x.get(E))?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"py-1",children:e.jsx("button",{onClick:()=>I(E,x.get(E)),className:"text-[11px] font-medium text-gray-400 cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:E})}),(((J=R[0])==null?void 0:J.pageFilePath)||B[E])&&e.jsx(Pe,{filePath:((V=R[0])==null?void 0:V.pageFilePath)||B[E],projectRoot:o}),e.jsx("div",{className:"grid grid-cols-3 gap-2 pt-1",children:R.map($=>e.jsx(pe,{scenarioId:$.id,updatedAt:$.updatedAt,hasScreenshot:!!$.screenshotPath,name:$.name,isActive:$.id===l,onSelect:()=>m($)},$.id))})]}):e.jsxs("div",{className:"py-2",children:[e.jsx("span",{className:"text-[11px] font-medium text-gray-500",children:E}),e.jsx("p",{className:"text-[10px] text-amber-400/80 m-0 mt-1.5 leading-relaxed",children:"There is data missing that is required to show the scenarios for this page. Please copy and paste this prompt into Claude to ask Claude to fix the data."}),e.jsx("div",{className:"mt-1.5",children:e.jsx(Pt,{name:E,scenarios:R,reason:x.has(E)?"incomplete":"missing"})})]})},E)})]})]})},fe)}const Et={new:0,edited:1,impacted:2};function Mt({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],n=s&&(t.status==="edited"||t.status==="impacted");return e.jsx("button",{onClick:n?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 ${n?"cursor-pointer hover:opacity-80 transition-opacity":"cursor-default"}`,children:a.label})}function It({filePath:t}){const[s,a]=i.useState(null),[n,c]=i.useState(!0),[r,o]=i.useState(null);return i.useEffect(()=>{Xe(()=>import("./index-Blo6EK8G.js"),__vite__mapDeps([0,1,2])).then(l=>{o(()=>l.default)})},[]),i.useEffect(()=>{c(!0),fetch(`/api/editor-file-diff?path=${encodeURIComponent(t)}`).then(l=>l.json()).then(l=>{a({oldContent:l.oldContent,newContent:l.newContent})}).catch(()=>{a(null)}).finally(()=>c(!1))},[t]),n?e.jsx("div",{className:"p-2 text-[10px] text-gray-400",children:"Loading diff..."}):!s||!r?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(r,{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 Tt({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:n,updatedAt:c}){const r=i.useRef(null);return i.useEffect(()=>{a&&r.current&&r.current.scrollIntoView({block:"nearest",behavior:"smooth"})},[a]),e.jsxs("button",{ref:r,onClick:n,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:e.jsx(Le,{scenarioId:t,updatedAt:c,alt:s,className:"w-full h-full bg-white",imgClassName:"w-full h-full object-contain bg-white"})}),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 ia({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(he,{content:t,icon:!0,iconSize:10,className:"shrink-0 text-gray-400 hover:text-gray-600 transition-colors"})]}):null}function oa({testFile:t,entityName:s}){const{results:a,isRunning:n,runTests:c}=Qe(t);if(n&&!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 r=s?a.testCases.filter(m=>m.fullName.startsWith(s)):a.testCases,o=r.length>0?r:a.testCases;if(o.length===0)return null;const l=s?`${s} > `:"";return e.jsxs("div",{className:"pt-1 space-y-0.5",children:[o.map(m=>{var y;const v=l&&m.fullName.startsWith(l)?m.fullName.slice(l.length):m.fullName;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[m.status==="passed"?e.jsx("span",{className:"text-green-600 text-[10px]",children:"✓"}):m.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] ${m.status==="passed"?"text-green-600":m.status==="failed"?"text-red-500":"text-gray-400"}`,children:v})]}),m.status==="failed"&&((y=m.failureMessages)==null?void 0:y.map((S,g)=>e.jsx("div",{className:"pl-4 text-[9px] text-red-400 truncate max-w-full",title:S,children:S.split(`
|
|
48
|
+
`)[0]},g)))]},m.fullName)}),e.jsx("button",{onClick:c,disabled:n,className:"mt-1 text-[10px] text-[#0ea5e9] hover:text-[#38bdf8] transition-colors cursor-pointer disabled:opacity-50 bg-transparent border-none p-0",children:n?"Running...":"Re-run"})]})}function $t(t){const s=t.indexOf(" - ");return s!==-1?t.slice(s+3):t}function At(t,s){return!s||Object.keys(s).length===0?t:[...t].sort(([a],[n])=>{var l,m;const c=((l=s[a])==null?void 0:l.status)||"impacted",r=((m=s[n])==null?void 0:m.status)||"impacted",o=(Et[c]??2)-(Et[r]??2);return o!==0?o:a.localeCompare(n)})}function la({scenarios:t,allScenarios:s=[],glossaryFunctions:a=[],projectRoot:n,activeScenarioId:c,onScenarioSelect:r,onClose:o,entityChangeStatus:l={},modifiedFiles:m=[],featureName:v,userPrompt:y}){const S=i.useMemo(()=>{if(s.length===0||Object.keys(l).length===0)return t;const x=new Set(t.map(h=>h.id)),b=s.filter(h=>{var k,T;if(x.has(h.id))return!1;const w=h.componentName||h.displayName||((k=h.pageFilePath)!=null&&k.startsWith("app/")?Me(Ee(h.pageFilePath)):_e(h.url));return((T=l[w])==null?void 0:T.status)==="impacted"});return b.length===0?t:[...t,...b]},[t,s,l]),g=i.useMemo(()=>Object.entries(l).filter(([,x])=>x.status==="new"||x.status==="edited").map(([x,b])=>({name:x,status:b.status})),[l]),[I,f]=i.useState(null),B=i.useCallback(x=>{f(b=>b===x?null:x)},[]),{pageGroups:O,componentGroups:L}=i.useMemo(()=>Dt(S),[S]),D=i.useMemo(()=>At([...O.entries()],l),[O,l]),_=i.useMemo(()=>At([...L.entries()],l),[L,l]),N=D,M=_,U=i.useMemo(()=>As(a,l),[a,l]),p=i.useMemo(()=>{const x=[];for(const[,b]of N)x.push(...b);for(const[,b]of M)x.push(...b);return x},[N,M]);return i.useEffect(()=>{if(p.length===0)return;const x=b=>{var T;if(b.key!=="ArrowLeft"&&b.key!=="ArrowRight")return;const h=(T=b.target)==null?void 0:T.tagName;if(h==="INPUT"||h==="TEXTAREA"||h==="SELECT")return;b.preventDefault();const w=p.findIndex(A=>A.id===c);let k;b.key==="ArrowLeft"?k=w<=0?p.length-1:w-1:k=w>=p.length-1?0:w+1,r(p[k])};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[p,c,r]),S.length===0&&a.length===0?e.jsxs("div",{className:"h-full bg-white flex items-center justify-center relative",children:[e.jsx("button",{onClick:o,className:"absolute top-2 right-3 text-gray-400 hover:text-gray-700 text-lg leading-none cursor-pointer bg-transparent border-none",title:"Close results",children:"×"}),e.jsx("span",{className:"text-sm text-gray-400",children:"No scenarios registered yet"})]}):e.jsxs("div",{className:"h-full bg-white flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 border-b border-gray-200 shrink-0",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Working Session Results"}),v&&e.jsx("div",{className:"text-[11px] text-gray-400 truncate",title:v,children:v})]}),e.jsx("button",{onClick:o,className:"text-gray-400 hover:text-gray-700 text-lg leading-none cursor-pointer bg-transparent border-none shrink-0",title:"Close results",children:"×"})]}),y&&e.jsx(Lt,{text:y,theme:"light"}),e.jsx("div",{className:"flex-1 overflow-auto p-4",children:e.jsxs("div",{className:"space-y-5",children:[N.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:N.map(([x,b])=>{var T;const h=l[x],w=I===x,k=(T=b[0])==null?void 0:T.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:x}),h&&e.jsx(Mt,{status:h,onClick:()=>B(x)})]}),w&&(h==null?void 0:h.status)==="edited"&&k&&e.jsx(It,{filePath:k}),w&&(h==null?void 0:h.status)==="impacted"&&e.jsx(Tt,{impactedBy:h.impactedBy,changedEntities:g}),e.jsx("div",{className:"flex flex-wrap gap-3",children:b.map(A=>e.jsx(Rt,{scenarioId:A.id,name:$t(A.name),isActive:A.id===c,onSelect:()=>r(A),updatedAt:A.updatedAt},A.id))})]},x)})})]}),M.length>0&&e.jsxs("div",{className:N.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:M.map(([x,b])=>{var T;const h=l[x],w=I===x,k=(T=b[0])==null?void 0:T.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:x}),h&&e.jsx(Mt,{status:h,onClick:()=>B(x)})]}),w&&(h==null?void 0:h.status)==="edited"&&k&&e.jsx(It,{filePath:k}),w&&(h==null?void 0:h.status)==="impacted"&&e.jsx(Tt,{impactedBy:h.impactedBy,changedEntities:g}),e.jsx("div",{className:"flex flex-wrap gap-3",children:b.map(A=>e.jsx(Rt,{scenarioId:A.id,name:$t(A.name),isActive:A.id===c,onSelect:()=>r(A),updatedAt:A.updatedAt},A.id))})]},x)})})]}),U.length>0&&e.jsxs("div",{className:N.length>0||M.length>0?"pt-3 border-t border-gray-200":"",children:[e.jsx("div",{className:"mb-2",children:e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Functions"})}),e.jsx("div",{className:"space-y-2 pl-1",children:U.map(x=>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:x.name})}),e.jsx(ia,{filePath:x.filePath,projectRoot:n}),x.testFile?e.jsx(oa,{testFile:x.testFile,entityName:x.name}):e.jsx("div",{className:"pt-1",children:e.jsx("span",{className:"text-[10px] text-gray-400",children:"No test file"})})]},x.name))})]}),m.length>0&&e.jsxs("div",{className:N.length>0||M.length>0||U.length>0?"pt-3 border-t border-gray-200":"",children:[e.jsx("div",{className:"mb-2",children:e.jsxs("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:["Modified Files (",m.length,")"]})}),e.jsx("div",{className:"space-y-0.5 pl-1 max-h-[200px] overflow-auto",children:m.map(x=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:`text-[9px] font-bold uppercase w-[14px] text-center ${x.status==="added"||x.status==="untracked"?"text-green-600":x.status==="modified"?"text-blue-600":x.status==="renamed"?"text-purple-600":"text-gray-400"}`,children:x.status==="added"||x.status==="untracked"?"A":x.status==="modified"?"M":x.status==="renamed"?"R":"?"}),e.jsx("span",{className:"text-[10px] text-gray-500 truncate font-mono",children:x.path})]},x.path))})]})]})})]})}const ca=[{key:"app",label:"App"},{key:"build",label:"Build"},{key:"data",label:"Structure"},{key:"journal",label:"Journal"}];function da({activeTab:t,onTabChange:s,buildIdle:a,panelLayout:n,onToggleExpand:c}){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:Rs,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:ca.map(r=>e.jsxs("button",{onClick:()=>s(r.key),className:`px-2.5 py-1 text-xs font-medium rounded-md transition-colors cursor-pointer ${t===r.key?"bg-[#7a4444] text-white":"text-gray-300 hover:text-white"}`,children:[r.label,r.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"})]},r.key))}),c&&e.jsx("button",{onClick:c,className:"p-1.5 rounded text-gray-400 hover:text-white transition-colors cursor-pointer",title:n==="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:n==="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 ma({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(xa,{commitSha:t.commitSha,onLoadCommit:a})})]})}function xa({commitSha:t,onLoadCommit:s}){const[a,n]=i.useState(!1),[c,r]=i.useState(null);return e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>{n(!0),r(null),s(t).then(o=>{o.success||r(o.error||"Failed to load commit")}).catch(o=>{r(o instanceof Error?o.message:"Network error")}).finally(()=>n(!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"}),c&&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:c})]})}function pa({analysisId:t,scenarioId:s,scenarioName:a,entityName:n,projectSlug:c,onStateChange:r}){const{interactiveServerUrl:o,isStarting:l,isLoading:m}=$s({analysisId:t,scenarioId:s,scenarioName:a,entityName:n,projectSlug:c,enabled:!0});return i.useEffect(()=>{r(o,l||m)},[o,l,m,r]),null}function ha({onSaveToCurrent:t,onSaveAsNew:s,onDismiss:a,isSaving:n}){return e.jsxs("div",{className:"flex items-center justify-between px-4 py-1.5 bg-emerald-900/60 border-b border-emerald-700/50 text-emerald-200 text-xs",children:[e.jsx("span",{className:"font-medium",children:"Data modified."}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:t,disabled:n,className:"px-2.5 py-0.5 bg-emerald-600 hover:bg-emerald-500 disabled:opacity-50 text-white text-xs font-medium rounded transition-colors cursor-pointer disabled:cursor-not-allowed",children:n?"Saving...":"Save to Scenario"}),e.jsx("button",{onClick:s,disabled:n,className:"px-2.5 py-0.5 bg-emerald-800 hover:bg-emerald-700 disabled:opacity-50 text-emerald-200 text-xs font-medium rounded transition-colors cursor-pointer disabled:cursor-not-allowed",children:"Save as New"}),e.jsx("button",{onClick:a,disabled:n,className:"text-emerald-400 hover:text-emerald-200 disabled:opacity-50 transition-colors cursor-pointer disabled:cursor-not-allowed",title:"Dismiss",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]})}function ua(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 fa(t){const[s,a]=i.useState({url:null,proxyUrl:null,isStarting:!1,error:null,canStartServer:!0,autoStartAttempted:!1}),n=i.useRef(s);n.current=s,i.useEffect(()=>{let o=!1,l=null;const m=async()=>{try{const v=await fetch("/api/editor-dev-server");if(o)return;const y=await v.json(),S=ua(n.current,y),{shouldAutoStart:g,...I}=S;if(a(I),g&&!(t!=null&&t.skipAutoStart))try{const f=await fetch("/api/editor-dev-server",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"start"})});if(o)return;f.ok?a(B=>({...B,isStarting:!0})):a(B=>({...B,canStartServer:!1}))}catch{}}catch{}};return m(),l=setInterval(()=>void m(),2e3),()=>{o=!0,l&&clearInterval(l)}},[s.url]);const c=i.useCallback(()=>{a(o=>({...o,error:null,isStarting:!0})),fetch("/api/editor-dev-server",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"restart"})}).catch(()=>{})},[]),r=i.useCallback(()=>{a(o=>({...o,error:null,isStarting:!0})),fetch("/api/editor-dev-server",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"start"})}).catch(()=>{})},[]);return{devServerUrl:s.url,proxyUrl:s.proxyUrl,isStarting:s.isStarting,error:s.error,canStartServer:s.canStartServer,retryServer:c,startServer:r}}function ga(t){const s=i.useRef(null),a=i.useRef(null);i.useEffect(()=>{if(typeof document>"u")return;a.current||(a.current=document.createElement("canvas"),a.current.width=64,a.current.height=64);const n=document.querySelector('link[rel="icon"]');if(!n)return;if(s.current||(s.current=n.href),!t){n.href=s.current;return}const c=new Image;c.crossOrigin="anonymous",c.onload=()=>{const r=a.current,o=r.getContext("2d");o.clearRect(0,0,64,64);const l=56,m=(64-l)/2;o.drawImage(c,m,m,l,l);const v=12,y=64-v-1,S=v+1;o.beginPath(),o.arc(y,S,v+3,0,2*Math.PI),o.fillStyle="#ffffff",o.fill(),o.beginPath(),o.arc(y,S,v,0,2*Math.PI),o.fillStyle="#ef4444",o.fill(),n.href=r.toDataURL("image/png")},c.src=s.current},[t]),i.useEffect(()=>()=>{if(typeof document>"u")return;const n=document.querySelector('link[rel="icon"]');n&&s.current&&(n.href=s.current)},[])}function Ta({currentUrl:t,nextUrl:s,formMethod:a,defaultShouldRevalidate:n}){return a||t.pathname===s.pathname?n:t.pathname.startsWith("/editor")&&s.pathname.startsWith("/editor")?!1:n}const Ra=()=>[{title:"Editor - CodeYam"},{name:"description",content:"CodeYam Code + Data Editor"}];class ja extends i.Component{constructor(){super(...arguments);yt(this,"state",{error:null,errorInfo:null})}static getDerivedStateFromError(a){return{error:a,errorInfo:null}}componentDidCatch(a,n){console.error("[EditorErrorBoundary] Error:",a.message),console.error("[EditorErrorBoundary] Component stack:",n.componentStack),console.error("[EditorErrorBoundary] Loader snapshot:",JSON.stringify(this.props.loaderSnapshot,null,2)),this.setState({errorInfo:n})}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 $a=hs(function(){const{projectSlug:s,projectRoot:a,hasProject:n,scenarios:c,allScenarios:r,analyzedEntities:o,allEntities:l,glossaryFunctions:m,glossaryEntries:v,entityImports:y,pageFilePaths:S,entityChangeStatus:g,modifiedFiles:I,featureName:f,userPrompt:B,projectTitle:O,projectDescription:L,defaultScreenSize:D,screenSizes:_,editorStep:N,editorStepLabel:M,claudeSessionId:U,focusedEntitySha:p,newerEntitySha:x,focusedEntity:b,migrationMode:h,migrationState:w}=us(),[k,T]=fs(),A=gs(),C=i.useRef(null),q=i.useRef(null),ue=i.useRef(null),[fe,ge]=i.useState(p);i.useEffect(()=>{ge(p)},[p]);const ee=i.useMemo(()=>sa(fe,l,r),[fe,l,r]),E=(ee==null?void 0:ee.displayName)??void 0,R=k.get("scenario")||void 0,[J,V]=i.useState(()=>E?[E]:[]),$=i.useRef(null),se=i.useRef([]),ne=i.useRef(null);i.useEffect(()=>{var H;const d=R||((H=Ns(r))==null?void 0:H.id);if(!ws(d,$.current))return;const j=r.find(Q=>Q.id===d);if(!j)return;$.current=d;const P=qe(j,se.current,ne.current);P&&ce(P);const z=Ye(j.name);fetch("/api/editor-switch-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioSlug:z,scenarioId:j.id,scenarioName:j.name,scenarioType:j.type})}).catch(()=>{})},[R,r]),i.useEffect(()=>{const d=new BroadcastChannel("codeyam-editor");return d.onmessage=j=>{var P;if(((P=j.data)==null?void 0:P.type)==="switch-scenario"&&j.data.scenarioId){const z=j.data.scenarioId,H=r.find(xe=>xe.id===z);if(!H)return;$.current=z;const Q=new URLSearchParams(k);Q.set("scenario",z),Q.delete("zoom"),T(Q),u(null),F(null),ie(null),ve(!0);const ke=Ye(H.name);fetch("/api/editor-switch-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioSlug:ke,scenarioId:z,scenarioType:H.type})}).then(()=>{Z(!1),$e(xe=>xe+1)}).catch(()=>{ve(!1)})}},()=>d.close()},[k,T,r]),i.useEffect(()=>{if(k.get("ref")!=="link"||!R)return;const d=new BroadcastChannel("codeyam-editor");d.postMessage({type:"switch-scenario",scenarioId:R}),d.close(),window.close()},[]);const{devServerUrl:G,proxyUrl:le,isStarting:ae,error:re,canStartServer:je,retryServer:Ie,startServer:Te}=fa({skipAutoStart:h==="candidate"||h==="active"}),[be,Z]=i.useState(!1),[Y,u]=i.useState(null),[W,F]=i.useState(null),[De,Ze]=i.useState(!1),[Fe,ie]=i.useState(null),Bt=i.useCallback(async d=>{const P=await(await fetch("/api/editor-load-commit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({commitSha:d})})).json();return P.success&&(ie(null),Z(!1)),P},[]),Ot=i.useCallback((d,j)=>{F(P=>(d&&d!==P&&Z(!1),d)),!j&&d&&Z(!0),Ze(j)},[]),et=i.useCallback(d=>{ie(null),u(P=>(P&&P.analysisId===d.analysisId||(F(null),$e(H=>H+1)),d)),Ze(!0),Z(!1);const j=new URLSearchParams(k);j.delete("scenario"),j.delete("zoom"),T(j)},[k,T]),[K,ce]=i.useState(D?{name:D.name,width:D.width,height:D.height}:{name:"Desktop",width:1440,height:900}),[tt,st]=i.useState(!1),at=D?{name:D.name,width:D.width,height:D.height}:null;ne.current=at;const nt=js(),X=i.useMemo(()=>{const d=nt.pathname.split("/").filter(Boolean),j=d[d.length-1];return j==="build"||j==="journal"?j:j==="structure"?"data":"app"},[nt.pathname]),te=i.useCallback(d=>{ge(null),V([]);const j=d==="app"?"":`/${d==="data"?"structure":d}`,P=k.get("scenario"),z=P?`?scenario=${P}`:"";A(`/editor${j}${z}`)},[A,k]),zt=i.useCallback(()=>{te("build"),de(!0)},[te]),Wt=i.useCallback(()=>{te("build"),de(!0),setTimeout(()=>{var d;(d=C.current)==null||d.sendInput("codeyam editor migrate")},300)},[te]),[Ut,de]=i.useState(X==="build"),Ht=!!(f&&N),[Re,Jt]=i.useState(Ht?"pending":"no-session");i.useEffect(()=>{Re==="pending"&&(te("build"),de(!0))},[Re,te]);const Vt=i.useCallback(()=>{Jt("continue")},[]),[Be,Oe]=i.useState(!1),[Gt,rt]=i.useState(!1),qt=i.useCallback(d=>{Oe(d),d&&rt(!1)},[]);ga(Be);const[ye,it]=i.useState("split"),[ze,ot]=i.useState(!1),Yt=i.useCallback(()=>{ot(!0),te("build"),de(!0)},[te]),lt=i.useCallback(()=>{ot(!1)},[]),Kt=i.useCallback(d=>{ce(d),fetch("/api/editor-project-info",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({defaultScreenSize:d,skipBroadcast:!0})})},[]),[ct,dt]=i.useState(Ss);i.useEffect(()=>{const d=ks();dt(d),d.systemNotification&&typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission()},[]);const Xt=i.useCallback(d=>{dt(d),Cs(d)},[]);i.useEffect(()=>{if(X==="build"){Oe(!1);const d=setTimeout(()=>{var j,P;(j=C.current)==null||j.scrollToBottom(),(P=C.current)==null||P.focus()},50);return()=>clearTimeout(d)}},[X]),i.useEffect(()=>{function d(){!document.hidden&&X==="build"&&Oe(!1)}return document.addEventListener("visibilitychange",d),()=>document.removeEventListener("visibilitychange",d)},[X]);const[We,Qt]=i.useState(null);i.useEffect(()=>{const d=ue.current;if(!d)return;const j=new ResizeObserver(P=>{const z=P[0];z&&Qt({width:z.contentRect.width,height:z.contentRect.height})});return j.observe(d),()=>j.disconnect()},[]);const me=i.useMemo(()=>We?Ps(We,K):1,[We,K]),[Ue,$e]=i.useState(0),[mt,He]=i.useState(null),[xt,ve]=i.useState(!1),[Zt,Ne]=i.useState(!1),[es,pt]=i.useState(!1),ts=i.useCallback(()=>{Ne(!0)},[]);i.useEffect(()=>{const d=j=>{var P;((P=j.data)==null?void 0:P.type)==="codeyam-localstorage-changed"&&Ne(!0)};return window.addEventListener("message",d),()=>window.removeEventListener("message",d)},[]);const ht=i.useCallback(async d=>{pt(!0);try{let j;const P=q.current;P!=null&&P.contentWindow&&(j=await new Promise(Q=>{const ke=setTimeout(()=>Q(void 0),2e3),xe=jt=>{var bt;((bt=jt.data)==null?void 0:bt.type)==="codeyam-localstorage-state"&&(clearTimeout(ke),window.removeEventListener("message",xe),Q(jt.data.data))};window.addEventListener("message",xe),P.contentWindow.postMessage({type:"codeyam-get-localstorage"},"*")}));const H=await(await fetch("/api/editor-save-seed-state",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:d,localStorage:j})})).json();H.success?Ne(!1):console.error("[editor] Save seed state failed:",H.error)}catch(j){console.error("[editor] Save seed state error:",j)}finally{pt(!1)}},[]),ss=i.useCallback((d,j)=>{if(He(d||null),j){const P=new URLSearchParams(k);P.set("scenario",j),$.current=j,T(P);const z=r.find(H=>H.id===j);if(z){const H=qe(z,se.current,ne.current);H&&ce(H)}}ie(null),Z(!1),$e(P=>P+1)},[k,T,r]),{customSizes:Je,addCustomSize:as,removeCustomSize:ns}=ys(s),Ve=i.useMemo(()=>_s(_),[_]),Ge=i.useMemo(()=>[...Ve,...Je],[Ve,Je]);se.current=Ge;const ut=i.useMemo(()=>{const d=new Map;for(const j of l){d.set(j.name,j.sha);const P=Me(Ee(j.filePath));P!==j.name&&d.set(P,j.sha)}return d},[l]),rs=i.useMemo(()=>{const d=[{name:"App"}];for(const j of J)d.push({name:j,componentName:j,entitySha:ut.get(j)});return d},[J,ut]),ft=i.useCallback((d,j)=>{if(!d){V([]),ge(null);const Q=k.get("scenario"),ke=Q?`?scenario=${Q}`:"";A(`/editor${ke}`);return}if(!j){console.error(`[editor] No entity SHA for "${d}" — entity missing from database`);return}const P=J.indexOf(d);P>=0?V(J.slice(0,P+1)):V([...J,d]);const z=r.find(Q=>Q.entitySha===j);ge(j);const H=z?`?scenario=${z.id}`:"";A(`/editor/entity/${j}${H}`)},[A,r,J,k]),we=i.useCallback(d=>{u(null),F(null),ie(null),He(null);const j=qe(d,Ge,at);j&&ce(j),$.current=d.id;const P=new URLSearchParams(k);P.set("scenario",d.id),T(P),ve(!0),Ne(!1);const z=Ye(d.name);fetch("/api/editor-switch-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioSlug:z,scenarioId:d.id,scenarioType:d.type,skipBroadcast:!0})}).then(()=>{Z(!1),$e(H=>H+1)}).catch(()=>{ve(!1)})},[k,T,Ge]),is=i.useCallback(d=>{if(!d.commitSha){const j=r.find(P=>P.name===d.scenarioName);if(j){we(j);return}}ie(d)},[r,we]),os=d=>{const j={name:d.name,width:d.width,height:d.height};ce(j),fetch("/api/editor-project-info",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({defaultScreenSize:j,skipBroadcast:!0})})},ls=(d,j,P)=>{as(d,j,P)},cs=d=>{ce(d),fetch("/api/editor-project-info",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({defaultScreenSize:d,skipBroadcast:!0})})},ds=()=>{Y||Z(!0),ve(!1)},Se=i.useMemo(()=>Es({activeAnalyzedScenario:!!Y,analyzedPreviewUrl:W,activeScenarioId:R||null,scenarios:r,proxyUrl:le,devServerUrl:G,zoomComponent:E||null}),[le,G,E,R,r,Y,W]),gt=i.useMemo(()=>{const d=Ms(Se,mt);if(!d)return null;const j=d.includes("?")?"&":"?";return`${d}${j}__cb=${Ue}`},[Se,mt,Ue]),ms=i.useMemo(()=>({projectSlug:s,hasProject:n,scenarioCount:c==null?void 0:c.length,allScenarioCount:r==null?void 0:r.length,analyzedEntityCount:o==null?void 0:o.length,glossaryFunctionCount:m==null?void 0:m.length,entityChangeStatusKeys:g?Object.keys(g):[],featureName:f}),[s,n,c,r,o,m,g,f]);return e.jsxs(e.Fragment,{children:[e.jsx(ja,{loaderSnapshot:ms,children:e.jsxs("div",{className:"fixed inset-0 bg-[#2d2d2d] flex flex-col",children:[Y&&e.jsx(pa,{analysisId:Y.analysisId,scenarioId:Y.scenarioId,scenarioName:Y.scenarioName,entityName:Y.entityName,projectSlug:s,onStateChange:Ot},Y.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:ye==="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:()=>it(d=>d==="preview-only"?"split":"preview-only"),className:"p-1.5 rounded text-gray-500 hover:text-gray-300 transition-colors cursor-pointer",title:ye==="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:[Ae.map(d=>e.jsxs("button",{onClick:()=>os(d),className:`p-1.5 rounded transition-colors cursor-pointer ${K.name===d.name?"text-white bg-[#555]":"text-gray-500 hover:text-gray-300"}`,title:`${d.name} (${d.width}×${d.height})`,children:[d.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"})]}),d.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"})]}),d.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"})]}),d.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"})]})]},d.name)),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>st(d=>!d),className:`flex items-center gap-1.5 px-2 py-1 rounded transition-colors cursor-pointer ${tt||!Ae.some(d=>d.name===K.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:[K.width," ×"," ",K.height??900]})]}),tt&&e.jsx(vs,{currentWidth:K.width,currentHeight:K.height??900,devicePresets:Ve,customSizes:Je,onApply:cs,onSave:ls,onRemove:ns,onClose:()=>st(!1)})]})]})}),e.jsx("div",{className:"ml-auto flex items-center gap-1 shrink-0 z-10",children:e.jsx("button",{onClick:()=>{const d=gt||Se;d&&window.open(d,"_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"})]})})})]}),Zt&&e.jsx(ha,{onSaveToCurrent:()=>void ht("overwrite"),onSaveAsNew:()=>void ht("new"),onDismiss:()=>Ne(!1),isSaving:es}),e.jsx("div",{ref:ue,className:"flex-1 flex items-center justify-center overflow-hidden p-8",style:Fe?{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:`
|
|
49
|
+
linear-gradient(45deg, #333 25%, transparent 25%),
|
|
50
|
+
linear-gradient(-45deg, #333 25%, transparent 25%),
|
|
51
|
+
linear-gradient(45deg, transparent 75%, #333 75%),
|
|
52
|
+
linear-gradient(-45deg, transparent 75%, #333 75%)
|
|
53
|
+
`,backgroundSize:"16px 16px",backgroundPosition:"0 0, 0 8px, 8px -8px, -8px 0px",backgroundColor:"#2d2d2d"},children:Fe?e.jsx(ma,{preview:Fe,onDismiss:()=>ie(null),onLoadCommit:Bt}):Se?e.jsx("div",{style:{width:`${K.width*me}px`,height:`${(K.height??900)*me}px`},children:e.jsxs("div",{className:"relative bg-white origin-top-left",style:{width:`${K.width}px`,height:`${K.height??900}px`,transform:me<1?`scale(${me})`:void 0},children:[!be&&!xt&&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(vt,{})}),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"})]})]})}),xt&&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:q,src:gt||Se,className:"w-full h-full border-none",title:"Editor preview",onLoad:ds,style:{opacity:be?1:0}},Ue)]})}):e.jsx("div",{className:"bg-[#2a2a2a] rounded-lg flex flex-col items-center justify-center",style:{width:`${K.width*me}px`,height:`${(K.height??900)*me}px`},children:re?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:re}),e.jsx("button",{onClick:Ie,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"})]}):ae||De?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mb-4",children:e.jsx(vt,{})}),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:De?"Starting Interactive Mode":"Starting Dev Server"}),e.jsx("p",{className:"text-sm text-gray-400 leading-5 m-0 font-['IBM_Plex_Sans']",children:De?"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 ${ye==="editor-only"?"w-full max-w-none min-w-0":"w-[50%] min-w-[400px] max-w-[800px]"}`,style:ye==="preview-only"?{display:"none"}:void 0,children:[x&&ee&&e.jsxs("div",{className:"px-3 py-2 text-xs flex items-center justify-between",style:{background:"#2a1f00",borderBottom:"1px solid #3d2e00",color:"#f0c040"},children:[e.jsxs("span",{children:["Viewing an older version of"," ",e.jsx("strong",{children:ee.name}),". A newer version exists."]}),e.jsx("a",{href:`/editor/entity/${x}`,className:"px-2 py-0.5 rounded text-xs",style:{background:"#3d2e00",color:"#f0c040",textDecoration:"none"},children:"View latest"})]}),e.jsx(da,{activeTab:X,onTabChange:d=>{te(d),d==="build"&&de(!0)},buildIdle:Be,panelLayout:ye,onToggleExpand:()=>it(d=>d==="editor-only"?"split":"editor-only")}),e.jsxs("div",{className:"flex-1 overflow-hidden relative",children:[Be&&X!=="build"&&!Gt&&e.jsxs("div",{className:"absolute top-3 left-1/2 -translate-x-1/2 z-50 animate-[slideDown_0.3s_ease-out]",children:[e.jsx("style",{children:`
|
|
54
|
+
@keyframes slideDown {
|
|
55
|
+
from { transform: translate(-50%, -100%); opacity: 0; }
|
|
56
|
+
to { transform: translate(-50%, 0); opacity: 1; }
|
|
57
|
+
}
|
|
58
|
+
`}),e.jsxs("div",{className:"flex items-center gap-1 bg-amber-50 border-2 border-amber-300 rounded-lg shadow-lg",children:[e.jsxs("button",{onClick:()=>{te("build"),de(!0)},className:"flex items-center gap-2 px-4 py-2 cursor-pointer hover:bg-amber-100 transition-colors rounded-l-md",children:[e.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-amber-400 animate-pulse"}),e.jsx("span",{className:"text-sm font-medium text-amber-900",children:"Claude is waiting for you"}),e.jsx("span",{className:"text-xs text-amber-600 ml-1",children:"Go to Build"})]}),e.jsx("button",{onClick:d=>{d.stopPropagation(),rt(!0)},className:"px-2 py-2 cursor-pointer hover:bg-amber-100 transition-colors rounded-r-md text-amber-400 hover:text-amber-600","aria-label":"Dismiss",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:e.jsx("path",{d:"M3 3l8 8M11 3l-8 8"})})})]})]}),Ut&&e.jsxs("div",{className:"absolute inset-0 flex flex-col overflow-hidden",style:{visibility:X==="build"?"visible":"hidden"},children:[e.jsx("div",{className:ze?"flex-1 min-h-0":"flex-1",style:ze?{flex:"1 1 50%"}:void 0,children:Re==="pending"?e.jsx(Ls,{featureName:f,editorStep:N,editorStepLabel:M,onContinue:Vt}):e.jsx(Is,{ref:C,entityName:"Editor",projectSlug:s,entityFilePath:null,scenarioName:null,onRefreshPreview:ss,onShowResults:Yt,onHideResults:lt,onSetViewport:Kt,onDataMutationForwarded:ts,editorMode:!0,onIdleChange:qt,notificationSettings:ct,buildTabActive:X==="build",claudeStartMode:Re==="continue"?"resume":"fresh",claudeSessionId:U})}),ze&&e.jsx("div",{style:{flex:"1 1 50%"},className:"min-h-0 border-t-2 border-gray-300",children:e.jsx(la,{scenarios:c,allScenarios:r,glossaryFunctions:m,projectRoot:a,activeScenarioId:R,onScenarioSelect:we,onClose:lt,entityChangeStatus:g,modifiedFiles:I,featureName:f,userPrompt:B})})]}),e.jsx("div",{className:"absolute inset-0 flex flex-col overflow-hidden",style:{visibility:X==="app"?"visible":"hidden"},children:e.jsx(ra,{hasProject:n,scenarios:r,analyzedEntities:o,allEntities:l,glossaryFunctions:m,glossaryEntries:v,projectRoot:a,activeScenarioId:R,onScenarioSelect:we,onAnalyzedScenarioSelect:et,onSwitchToBuild:zt,zoomComponent:E,focusedEntity:ee,onZoomChange:ft,entityImports:y,pageFilePaths:S,projectTitle:O,projectDescription:L,breadcrumbItems:rs,migrationMode:h,migrationState:w,onStartMigration:Wt})}),e.jsx("div",{className:"absolute inset-0 flex flex-col overflow-hidden",style:{visibility:X==="data"?"visible":"hidden"},children:e.jsx(Ds,{scenarios:r,projectRoot:a,activeScenarioId:R,onScenarioSelect:we,zoomComponent:E,focusedEntity:ee,onZoomChange:ft,analyzedEntities:[],glossaryFunctions:m,activeAnalyzedScenarioId:Y==null?void 0:Y.scenarioId,onAnalyzedScenarioSelect:et,entityImports:y,pageFilePaths:S})}),e.jsx("div",{className:"absolute inset-0 flex flex-col overflow-hidden",style:{visibility:X==="journal"?"visible":"hidden"},children:e.jsx(Ys,{isActive:X==="journal",onScreenshotClick:is,glossaryFunctions:m})})]}),e.jsx(Ts,{serverUrl:G,isStarting:ae,projectSlug:s,devServerError:re,onStartServer:je?Te:void 0,notificationSettings:ct,onChangeNotificationSettings:Xt})]})]})]})}),e.jsx(bs,{})]})});export{$a as default,Ra as meta,Ta as shouldRevalidate};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/addon-web-links-74hnHF59.js","assets/chunk-JZWAC4HX-BBXArFPl.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var xe=Object.defineProperty;var he=(r,e,o)=>e in r?xe(r,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):r[e]=o;var G=(r,e,o)=>he(r,typeof e!="symbol"?e+"":e,o);import{j as l}from"./jsx-runtime-D_zvdyIk.js";import{r as u}from"./chunk-JZWAC4HX-BBXArFPl.js";import{_ as V}from"./preload-helper-ckwbz45p.js";const P={sound:"soft-double-tap",systemNotification:!0},ye=[{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"}],ie="codeyam-editor-notifications";function _e(){try{const r=localStorage.getItem(ie);if(!r)return P;const e=JSON.parse(r);return typeof e=="string"?e==="true"?P:{...P,sound:"off",systemNotification:!1}:{...P,...e}}catch{return P}}function Oe(r){localStorage.setItem(ie,JSON.stringify(r))}function se(r){var e;if(r!=="off")try{const o=new AudioContext,a={"soft-double-tap":t=>{[0,.12].forEach(n=>{const i=t.createOscillator(),g=t.createGain();i.connect(g),g.connect(t.destination),i.type="sine",i.frequency.value=392,g.gain.setValueAtTime(.25,t.currentTime+n),g.gain.exponentialRampToValueAtTime(.01,t.currentTime+n+.1),i.start(t.currentTime+n),i.stop(t.currentTime+n+.1)})},"gentle-chime":t=>{const n=t.createOscillator(),i=t.createGain();n.connect(i),i.connect(t.destination),n.type="sine",n.frequency.setValueAtTime(523,t.currentTime),n.frequency.setValueAtTime(659,t.currentTime+.15),i.gain.setValueAtTime(.3,t.currentTime),i.gain.exponentialRampToValueAtTime(.01,t.currentTime+.4),n.start(),n.stop(t.currentTime+.4)},"warm-ding":t=>{const n=t.createOscillator(),i=t.createGain();n.connect(i),i.connect(t.destination),n.type="sine",n.frequency.value=330,i.gain.setValueAtTime(.35,t.currentTime),i.gain.exponentialRampToValueAtTime(.01,t.currentTime+.6),n.start(),n.stop(t.currentTime+.6)},"mellow-two-tone":t=>{const n=t.createOscillator(),i=t.createGain();n.connect(i),i.connect(t.destination),n.type="sine",n.frequency.setValueAtTime(294,t.currentTime),n.frequency.setValueAtTime(440,t.currentTime+.18),i.gain.setValueAtTime(.3,t.currentTime),i.gain.exponentialRampToValueAtTime(.01,t.currentTime+.5),n.start(),n.stop(t.currentTime+.5)},"triangle-bell":t=>{const n=t.createOscillator(),i=t.createGain();n.connect(i),i.connect(t.destination),n.type="triangle",n.frequency.value=523,i.gain.setValueAtTime(.4,t.currentTime),i.gain.exponentialRampToValueAtTime(.01,t.currentTime+.8),n.start(),n.stop(t.currentTime+.8)}};(e=a[r])==null||e.call(a,o)}catch{}}function Re({serverUrl:r,isStarting:e,projectSlug:o,devServerError:a,onStartServer:t,notificationSettings:n,onChangeNotificationSettings:i}){const[g,S]=u.useState(null),[m,w]=u.useState(!1),E=u.useRef(null),A=u.useRef(null);u.useEffect(()=>{if(!o)return;const x=new EventSource("/api/dev-mode-events");return x.onmessage=_=>{try{const j=JSON.parse(_.data);j.type==="file-synced"&&(S(j.fileName),A.current&&clearTimeout(A.current),A.current=setTimeout(()=>{S(null)},5e3))}catch{}},()=>{x.close(),A.current&&clearTimeout(A.current)}},[o]),u.useEffect(()=>{if(!m)return;function x(_){E.current&&!E.current.contains(_.target)&&w(!1)}return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[m]);let N;a?N="error":e?N="starting":r?N="running":N="stopped";const k={starting:"bg-yellow-400",running:"bg-green-400",stopped:"bg-gray-400",error:"bg-red-400"},I={starting:"Starting...",running:r||"Running",stopped:"Stopped",error:"Error"},R=n&&(n.sound!=="off"||n.systemNotification);return l.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:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("div",{className:`w-2 h-2 rounded-full ${k[N]}`}),l.jsxs("span",{className:"text-gray-400",children:["Server:"," ",l.jsx("span",{className:"text-gray-300",children:I[N]})]}),(N==="stopped"||N==="error")&&t&&l.jsx("button",{onClick:t,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"})]}),l.jsx("div",{className:"w-px h-3 bg-[#3d3d3d]"}),g&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"#4ade80",strokeWidth:"2",children:l.jsx("path",{d:"M20 6L9 17l-5-5"})}),l.jsxs("span",{className:"text-green-400",children:["Synced: ",g]})]}),l.jsx("div",{className:"w-px h-3 bg-[#3d3d3d]"})]}),l.jsx("div",{className:"flex-1"}),i&&n&&l.jsxs("div",{className:"relative",ref:E,children:[l.jsx("button",{onClick:()=>w(!m),className:`text-[11px] rounded transition-colors cursor-pointer ${R?"text-green-400 hover:text-green-300":"text-gray-500 hover:text-gray-300"}`,children:R?"Notifications On":"Notifications Off"}),m&&l.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:[l.jsxs("div",{children:[l.jsx("div",{className:"text-[11px] text-gray-400 mb-1.5",children:"Notification sound"}),l.jsx("div",{className:"flex flex-col gap-0.5",children:ye.map(x=>l.jsx("button",{onClick:()=>{i({...n,sound:x.id}),x.id!=="off"&&se(x.id)},className:`text-left text-[11px] px-2 py-1 rounded cursor-pointer transition-colors ${n.sound===x.id?"bg-[#444] text-white":"text-gray-300 hover:bg-[#3a3a3a]"}`,children:x.label},x.id))})]}),l.jsxs("div",{className:"border-t border-[#4d4d4d] pt-2",children:[l.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:n.systemNotification,onChange:x=>{const _=x.target.checked;i({...n,systemNotification:_}),_&&typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission()},className:"accent-green-500"}),l.jsx("span",{className:"text-[11px] text-gray-300",children:"System notification"})]}),l.jsx("div",{className:"text-[10px] text-gray-500 mt-1 ml-5",children:"Shows when tab is not visible"})]})]})]})]})}async function ge(r,e){try{const{WebglAddon:a}=await V(async()=>{const{WebglAddon:n}=await import("./addon-webgl-DI8QOUvO.js").then(i=>i.a);return{WebglAddon:n}},[]),t=new a;return t.onContextLoss(()=>{e==null||e("webgl","canvas",new Error("WebGL context lost")),t.dispose(),oe(r).then(n=>{n||e==null||e("canvas","dom",new Error("Canvas fallback failed after context loss"))})}),r.loadAddon(t),{type:"webgl",dispose:()=>t.dispose()}}catch(a){e==null||e("webgl","canvas",a)}const o=await oe(r);return o||(e==null||e("canvas","dom",new Error("Canvas addon failed")),{type:"dom",dispose:()=>{}})}async function oe(r){try{const{CanvasAddon:e}=await V(async()=>{const{CanvasAddon:a}=await import("./addon-canvas-DpzMmAy5.js").then(t=>t.a);return{CanvasAddon:a}},[]),o=new e;return r.loadAddon(o),{type:"canvas",dispose:()=>o.dispose()}}catch{return null}}class we{constructor(e,o){G(this,"deferred",!1);G(this,"actions");G(this,"env");this.actions=e,this.env=o}onIdle(e,o){return o&&this.env.hasBrowserFocus()?(this.deferred=!0,"deferred"):(this.deferred=!1,this.notify(e))}onBuildTabChange(e,o){return!e&&this.deferred?(this.deferred=!1,this.notify(o),!0):!1}onActive(){this.deferred=!1}onUserEngagement(){const e=this.deferred;return this.deferred=!1,e}get isDeferred(){return this.deferred}notify(e){const o=!!(e!=null&&e.sound)&&e.sound!=="off";return o&&this.actions.playSound(e.sound),!this.env.hasBrowserFocus()&&(e!=null&&e.systemNotification)&&this.env.hasNotificationPermission()&&this.actions.showSystemNotification(),o?"played":"played-no-sound"}}const ve=`
|
|
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; caret-color: transparent !important; clip-path: inset(100%) !important; }
|
|
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 be(){let r=document.getElementById("xterm-css");r||(r=document.createElement("style"),r.id="xterm-css",document.head.appendChild(r)),r.textContent=ve}const je=u.forwardRef(function({entityName:e,entityType:o,entitySha:a,entityFilePath:t,scenarioName:n,scenarioDescription:i,analysisId:g,projectSlug:S,onRefreshPreview:m,onShowResults:w,onHideResults:E,onSetViewport:A,editorMode:N,onIdleChange:k,notificationSettings:I,buildTabActive:R,claudeStartMode:x,claudeSessionId:_,onDataMutationForwarded:j},ce){const J=u.useRef(null),z=u.useRef(null),$=u.useRef(null),B=u.useRef(null),q=u.useRef(null),H=u.useRef(!1),M=u.useRef(0),X=u.useRef(!1),v=u.useRef(k);v.current=k;const K=u.useRef(I);K.current=I;const Q=u.useRef(R);Q.current=R;const O=u.useRef(null),L=u.useRef(null);L.current||(L.current=new we({playSound:c=>se(c),showSystemNotification:()=>{O.current&&O.current.close();const c=new Notification("Claude is ready for you",{body:"Claude has finished and is waiting for your input.",tag:"claude-idle"});c.onclick=()=>{window.focus(),c.close()},O.current=c}},{hasBrowserFocus:()=>document.hasFocus(),hasNotificationPermission:()=>typeof Notification<"u"&&Notification.permission==="granted"}));function ae(){O.current&&(O.current.close(),O.current=null)}function Y(){var c,p;ae(),(c=v.current)==null||c.call(v,!1),(p=L.current)==null||p.onUserEngagement()}u.useEffect(()=>{function c(){Y()}function p(){document.hidden||Y()}return window.addEventListener("focus",c),document.addEventListener("visibilitychange",p),()=>{window.removeEventListener("focus",c),document.removeEventListener("visibilitychange",p)}},[]),u.useEffect(()=>{var c;(c=L.current)==null||c.onBuildTabChange(!!R,K.current)},[R]);const le=u.useCallback(()=>{var c;(c=$.current)==null||c.focus()},[]);return u.useImperativeHandle(ce,()=>({sendInput(c){const p=B.current;p&&p.readyState===WebSocket.OPEN&&(p.send(JSON.stringify({type:"input",data:c})),setTimeout(()=>{p.readyState===WebSocket.OPEN&&p.send(JSON.stringify({type:"input",data:"\r"}))},100))},focus(){var c;(c=$.current)==null||c.focus()},scrollToBottom(){var p;const c=(p=J.current)==null?void 0:p.querySelector(".xterm-viewport");c&&(c.scrollTop=c.scrollHeight)}})),u.useEffect(()=>{const c=J.current;if(!c)return;let p=!1;return be(),Promise.all([V(()=>import("./xterm-BqvuqXEL.js"),[]),V(()=>import("./addon-fit-YJmn1quW.js"),[]),V(()=>import("./addon-web-links-74hnHF59.js").then(W=>W.a),__vite__mapDeps([0,1]))]).then(([W,ue,de])=>{if(p)return;const d=new W.Terminal({cursorBlink:!1,cursorInactiveStyle:"none",scrollback:5e3,fontSize:13,fontFamily:"'IBM Plex Mono', 'Menlo', 'Monaco', monospace",theme:{background:"#1e1e1e",foreground:"#d4d4d4",cursor:"#1e1e1e",selectionBackground:"#264f78"},linkHandler:{activate(f,s){try{const y=new URL(s),b=y.searchParams.get("scenario");if(b&&y.pathname.startsWith("/editor")){const T=new BroadcastChannel("codeyam-editor");T.postMessage({type:"switch-scenario",scenarioId:b}),T.close();return}}catch{}window.open(s,"_blank")}}}),U=new ue.FitAddon;d.loadAddon(U),d.loadAddon(new de.WebLinksAddon),d.open(c),d.write("\x1B[?25l");let D=null;ge(d,(f,s,y)=>{console.warn(`[Terminal] Renderer fallback: ${f} → ${s}`,y)}).then(f=>{if(p){f.dispose();return}console.log(`[Terminal] Using ${f.type} renderer`),D=f.dispose}),requestAnimationFrame(()=>{try{U.fit()}catch{}}),$.current=d,d.focus(),setTimeout(()=>d.focus(),100),setTimeout(()=>d.focus(),500);const fe=window.location.protocol==="https:"?"wss:":"ws:",me=window.location.host;function pe(f){const s=new URLSearchParams;return s.set("entityName",e),o&&s.set("entityType",o),a&&s.set("entitySha",a),t&&s.set("entityFilePath",t),n&&s.set("scenarioName",n),i&&s.set("scenarioDescription",i),g&&s.set("analysisId",g),S&&s.set("projectSlug",S),N&&s.set("editorMode","true"),f&&s.set("reconnectId",f),x&&s.set("claudeStartMode",x),_&&s.set("claudeSessionId",_),`${fe}//${me}/ws/terminal?${s.toString()}`}function Z(f){const s=pe(f),y=new WebSocket(s);B.current=y,y.onopen=()=>{M.current=0,X.current=!1,y.send(JSON.stringify({type:"resize",cols:d.cols,rows:d.rows}))},y.onmessage=b=>{var T,ee,te,re,ne;try{const h=JSON.parse(b.data);if(h.type==="session-id"){q.current=h.sessionId;return}if(h.type==="refresh-preview"){m==null||m(h.path,h.scenarioId);return}if(h.type==="show-results"){w==null||w();return}if(h.type==="hide-results"){E==null||E();return}if(h.type==="data-mutation-forwarded"){j==null||j();return}if(h.type==="set-viewport"){A==null||A({name:h.name,width:h.width,height:h.height});return}if(h.type==="claude-idle"){(T=v.current)==null||T.call(v,!0),(ee=L.current)==null||ee.onIdle(K.current,Q.current??!1);return}if(h.type==="claude-active"){(te=v.current)==null||te.call(v,!1),(re=L.current)==null||re.onActive(),O.current&&(O.current.close(),O.current=null);return}h.type==="output"&&(d.write(h.data),(ne=v.current)==null||ne.call(v,!1))}catch{d.write(b.data)}},y.onclose=()=>{if(H.current){d.write(`\r
|
|
34
|
+
\x1B[90m[Terminal session ended]\x1B[0m\r
|
|
35
|
+
`);return}const b=M.current;if(b<5&&q.current){const T=1e3*Math.pow(2,Math.min(b,3));M.current=b+1,d.write(`\r
|
|
36
|
+
\x1B[33m[Reconnecting...]\x1B[0m\r
|
|
37
|
+
`),setTimeout(()=>{H.current||Z(q.current)},T)}else X.current?d.write(`\r
|
|
38
|
+
\x1B[90m[Terminal session ended]\x1B[0m\r
|
|
39
|
+
`):(X.current=!0,d.write(`\r
|
|
40
|
+
\x1B[33m[Starting new session...]\x1B[0m\r
|
|
41
|
+
`),q.current=null,M.current=0,Z())},y.onerror=()=>{}}Z(),d.onData(f=>{const s=B.current;s&&s.readyState===WebSocket.OPEN&&s.send(JSON.stringify({type:"input",data:f})),Y()});let C=null;const F=new ResizeObserver(()=>{C&&clearTimeout(C),C=setTimeout(()=>{let f;try{f=U.proposeDimensions()}catch{return}if(!f||f.cols===d.cols&&f.rows===d.rows)return;const s=c.querySelector(".xterm-viewport");let y,b=!0;s&&(y=s.scrollTop,b=s.scrollTop+s.clientHeight>=s.scrollHeight-10),U.fit(),s&&y!==void 0&&(b?s.scrollTop=s.scrollHeight:s.scrollTop=y);const T=B.current;T&&T.readyState===WebSocket.OPEN&&T.send(JSON.stringify({type:"resize",cols:d.cols,rows:d.rows}))},150)});F.observe(c),z.current=()=>{var f;C&&clearTimeout(C),F.disconnect(),H.current=!0,(f=B.current)==null||f.close(),B.current=null,D==null||D(),d.dispose(),$.current=null}}),()=>{var W;p=!0,(W=z.current)==null||W.call(z),z.current=null}},[]),l.jsx("div",{ref:J,onClick:le,className:"w-full h-full relative overflow-hidden",style:{padding:"4px 0 0 8px"}})});function Te(r){return r.replace(/[^a-zA-Z0-9_]+/g,"_")}function Be(r){const{activeAnalyzedScenario:e,analyzedPreviewUrl:o,activeScenarioId:a,scenarios:t,proxyUrl:n,devServerUrl:i,zoomComponent:g}=r;if(e&&o)return o;if(e&&!o)return null;if(a){const m=t.find(w=>w.id===a);if(m!=null&&m.url){const w=n||i;return w?m.url.startsWith("/")?`${w}${m.url}`:m.url:null}}const S=n||i;if(!S)return null;if(g&&a){const m=t.find(E=>E.id===a),w=m?Te(m.name):"Default";return`${S}/__codeyam__/${g}/${w}`}return S}function Le(r,e){if(!r||!e)return r;try{const o=new URL(r),a=e.indexOf("?");return a>=0?(o.pathname=e.slice(0,a),o.search=e.slice(a)):(o.pathname=e,o.search=""),o.href}catch{return r}}function We(r,e){return r?r!==e:!1}function ze(r){if(r.length!==0)return r.find(e=>e.type==="application")||r[0]}function Ce(r,e,o){if(!r.viewportWidth||!r.viewportHeight)return o??null;const a=e.find(t=>t.width===r.viewportWidth&&t.height===r.viewportHeight);return{name:(a==null?void 0:a.name)||"Custom",width:r.viewportWidth,height:r.viewportHeight}}function Pe(r,e){const o=e.width,a=e.height??900,t=r.width,n=r.height;return o<=t&&a<=n?1:Math.min(t/o,n/a)}export{Re as D,je as T,Le as a,Te as b,P as c,Oe as d,Pe as e,Be as f,ze as g,_e as l,Ce as r,We as s};
|