@codeyam/codeyam-cli 0.1.0-staging.8778565 → 0.1.0-staging.8b51541
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/packages/database/src/lib/kysely/tables/editorScenariosTable.ts +56 -0
- package/analyzer-template/packages/database/src/lib/loadEntities.ts +0 -6
- package/analyzer-template/packages/database/src/lib/updateCommitMetadata.ts +0 -65
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.d.ts +3 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.js +56 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.js +0 -6
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.js +0 -25
- package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.js.map +1 -1
- package/codeyam-cli/src/commands/__tests__/editor.stepDispatch.test.js +45 -0
- package/codeyam-cli/src/commands/__tests__/editor.stepDispatch.test.js.map +1 -0
- package/codeyam-cli/src/commands/__tests__/init.gitignore.test.js +101 -47
- package/codeyam-cli/src/commands/__tests__/init.gitignore.test.js.map +1 -1
- package/codeyam-cli/src/commands/editor.js +799 -211
- package/codeyam-cli/src/commands/editor.js.map +1 -1
- package/codeyam-cli/src/commands/init.js +68 -34
- package/codeyam-cli/src/commands/init.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/analyzerFinalization.test.js +173 -0
- package/codeyam-cli/src/utils/__tests__/analyzerFinalization.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorApi.test.js +18 -8
- package/codeyam-cli/src/utils/__tests__/editorApi.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/editorAudit.test.js +353 -1
- package/codeyam-cli/src/utils/__tests__/editorAudit.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/editorLoaderHelpers.test.js +128 -1
- package/codeyam-cli/src/utils/__tests__/editorLoaderHelpers.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/editorPreview.test.js +88 -1
- package/codeyam-cli/src/utils/__tests__/editorPreview.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/editorProxySession.test.js +47 -1
- package/codeyam-cli/src/utils/__tests__/editorProxySession.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/editorScenarios.test.js +785 -1
- package/codeyam-cli/src/utils/__tests__/editorScenarios.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/entityChangeStatus.test.js +63 -1
- package/codeyam-cli/src/utils/__tests__/entityChangeStatus.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/parseRegisterArg.test.js +30 -2
- package/codeyam-cli/src/utils/__tests__/parseRegisterArg.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/scenarioCoverage.test.js +227 -0
- package/codeyam-cli/src/utils/__tests__/scenarioCoverage.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/scenariosManifest.test.js +426 -218
- 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/analyzer.js +9 -0
- package/codeyam-cli/src/utils/analyzer.js.map +1 -1
- package/codeyam-cli/src/utils/analyzerFinalization.js +100 -0
- package/codeyam-cli/src/utils/analyzerFinalization.js.map +1 -0
- package/codeyam-cli/src/utils/backgroundServer.js +2 -8
- package/codeyam-cli/src/utils/backgroundServer.js.map +1 -1
- package/codeyam-cli/src/utils/database.js +37 -2
- package/codeyam-cli/src/utils/database.js.map +1 -1
- package/codeyam-cli/src/utils/editorApi.js +11 -5
- package/codeyam-cli/src/utils/editorApi.js.map +1 -1
- package/codeyam-cli/src/utils/editorAudit.js +51 -0
- package/codeyam-cli/src/utils/editorAudit.js.map +1 -1
- package/codeyam-cli/src/utils/editorLoaderHelpers.js +32 -0
- package/codeyam-cli/src/utils/editorLoaderHelpers.js.map +1 -1
- package/codeyam-cli/src/utils/editorPreview.js +31 -0
- package/codeyam-cli/src/utils/editorPreview.js.map +1 -1
- package/codeyam-cli/src/utils/editorScenarios.js +261 -0
- package/codeyam-cli/src/utils/editorScenarios.js.map +1 -1
- package/codeyam-cli/src/utils/entityChangeStatus.js +4 -2
- package/codeyam-cli/src/utils/entityChangeStatus.js.map +1 -1
- package/codeyam-cli/src/utils/entityChangeStatus.server.js +34 -0
- package/codeyam-cli/src/utils/entityChangeStatus.server.js.map +1 -1
- package/codeyam-cli/src/utils/parseRegisterArg.js.map +1 -1
- package/codeyam-cli/src/utils/progress.js +2 -2
- package/codeyam-cli/src/utils/progress.js.map +1 -1
- package/codeyam-cli/src/utils/scenarioCoverage.js +75 -0
- package/codeyam-cli/src/utils/scenarioCoverage.js.map +1 -0
- package/codeyam-cli/src/utils/scenariosManifest.js +204 -75
- 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/utils/simulationGateMiddleware.js +8 -1
- package/codeyam-cli/src/utils/simulationGateMiddleware.js.map +1 -1
- package/codeyam-cli/src/utils/slugUtils.js +25 -0
- package/codeyam-cli/src/utils/slugUtils.js.map +1 -0
- package/codeyam-cli/src/utils/syncMocksMiddleware.js +2 -2
- package/codeyam-cli/src/utils/syncMocksMiddleware.js.map +1 -1
- package/codeyam-cli/src/webserver/__tests__/clientErrors.test.js +40 -0
- package/codeyam-cli/src/webserver/__tests__/clientErrors.test.js.map +1 -0
- package/codeyam-cli/src/webserver/__tests__/editorProxy.test.js +157 -0
- package/codeyam-cli/src/webserver/__tests__/editorProxy.test.js.map +1 -1
- package/codeyam-cli/src/webserver/__tests__/idleDetector.test.js +146 -0
- package/codeyam-cli/src/webserver/__tests__/idleDetector.test.js.map +1 -0
- package/codeyam-cli/src/webserver/app/lib/clientErrors.js +65 -0
- package/codeyam-cli/src/webserver/app/lib/clientErrors.js.map +1 -0
- package/codeyam-cli/src/webserver/app/lib/git.js +3 -2
- package/codeyam-cli/src/webserver/app/lib/git.js.map +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{ScenarioViewer-0DY_NKil.js → ScenarioViewer-TSD3C211.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-scenario-coverage-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/{dev.empty-Csi0_PMl.js → dev.empty-Ii3inc0_.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/editor-16o0AIFV.js +15 -0
- package/codeyam-cli/src/webserver/build/client/assets/editorPreview-7Uga8I59.js +41 -0
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha._-BF4oLwaE.js → entity._sha._-DwCV5__E.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha.scenarios._scenarioId.dev-C7YX6r3H.js → entity._sha.scenarios._scenarioId.dev-BwKcai0j.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.fullscreen-CHMiAog3.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/globals-CQPR0pFR.css +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/manifest-76e7b62c.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/memory-9gnxSZlb.js +101 -0
- package/codeyam-cli/src/webserver/build/client/assets/{root-ClvYBUSA.js → root-DBjt6o04.js} +3 -3
- package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-C-_hOl_g.js +1 -0
- package/codeyam-cli/src/webserver/build/client/sound-test.html +98 -0
- package/codeyam-cli/src/webserver/build/server/assets/index-DsZjKspK.js +1 -0
- package/codeyam-cli/src/webserver/build/server/assets/init-DdqKD2p4.js +10 -0
- package/codeyam-cli/src/webserver/build/server/assets/server-build-CKKeWtVK.js +444 -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 +99 -7
- package/codeyam-cli/src/webserver/editorProxy.js.map +1 -1
- package/codeyam-cli/src/webserver/idleDetector.js +73 -0
- package/codeyam-cli/src/webserver/idleDetector.js.map +1 -0
- package/codeyam-cli/src/webserver/public/sound-test.html +98 -0
- package/codeyam-cli/src/webserver/server.js +46 -4
- package/codeyam-cli/src/webserver/server.js.map +1 -1
- package/codeyam-cli/src/webserver/terminalServer.js +68 -29
- package/codeyam-cli/src/webserver/terminalServer.js.map +1 -1
- package/codeyam-cli/templates/chrome-extension-react/README.md +46 -0
- package/codeyam-cli/templates/chrome-extension-react/package.json +1 -0
- package/codeyam-cli/templates/codeyam-editor-claude.md +84 -5
- package/codeyam-cli/templates/editor-step-hook.py +14 -8
- package/codeyam-cli/templates/expo-react-native/README.md +41 -0
- package/codeyam-cli/templates/expo-react-native/package.json +1 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/DATABASE.md +14 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/README.md +53 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/package.json +1 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/README.md +52 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/package.json +1 -0
- package/codeyam-cli/templates/skills/codeyam-dev-mode/SKILL.md +1 -1
- package/codeyam-cli/templates/skills/codeyam-editor/SKILL.md +14 -10
- package/package.json +1 -1
- package/packages/database/src/lib/kysely/tables/editorScenariosTable.js +56 -0
- package/packages/database/src/lib/kysely/tables/editorScenariosTable.js.map +1 -1
- package/packages/database/src/lib/loadEntities.js +0 -6
- package/packages/database/src/lib/loadEntities.js.map +1 -1
- package/packages/database/src/lib/updateCommitMetadata.js +0 -25
- package/packages/database/src/lib/updateCommitMetadata.js.map +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/editor-DgN1LTTt.js +0 -10
- package/codeyam-cli/src/webserver/build/client/assets/editorPreview-BLQMSKZa.js +0 -41
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.fullscreen-CF164ouH.js +0 -6
- package/codeyam-cli/src/webserver/build/client/assets/globals-BkWJ_UNc.css +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/manifest-c26eb85b.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/memory-Bl2rpw8u.js +0 -96
- package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-CrAK28Bc.js +0 -1
- package/codeyam-cli/src/webserver/build/server/assets/index-DflIr5SD.js +0 -1
- package/codeyam-cli/src/webserver/build/server/assets/server-build-OhKy839M.js +0 -416
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Project Name
|
|
2
|
+
|
|
3
|
+
Brief description of what this app does.
|
|
4
|
+
|
|
5
|
+
## Setup
|
|
6
|
+
|
|
7
|
+
Run the setup script to install dependencies, initialize the database, and seed it with demo data:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm run setup
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Development
|
|
14
|
+
|
|
15
|
+
Start the dev server:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm run dev
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Open [http://localhost:3000](http://localhost:3000) in your browser.
|
|
22
|
+
|
|
23
|
+
## Using CodeYam Editor
|
|
24
|
+
|
|
25
|
+
This project was built with [CodeYam](https://codeyam.com). To launch the editor:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
codeyam editor
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
The editor provides a live preview alongside a Claude Code terminal for iterating on the app.
|
|
32
|
+
|
|
33
|
+
## Database
|
|
34
|
+
|
|
35
|
+
This project uses SQLite via Prisma. Common commands:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npm run db:push # Apply schema changes and generate Prisma client
|
|
39
|
+
npm run db:seed # Seed the database with demo data
|
|
40
|
+
npm run db:reset # Reset database: drop, recreate, and re-seed
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Scripts
|
|
44
|
+
|
|
45
|
+
| Script | Description |
|
|
46
|
+
| ------------------ | -------------------------------------------- |
|
|
47
|
+
| `npm run setup` | One-line project setup (install + db + seed) |
|
|
48
|
+
| `npm run dev` | Start the development server |
|
|
49
|
+
| `npm run build` | Build for production |
|
|
50
|
+
| `npm run test` | Run tests |
|
|
51
|
+
| `npm run db:push` | Apply Prisma schema changes |
|
|
52
|
+
| `npm run db:seed` | Seed the database |
|
|
53
|
+
| `npm run db:reset` | Reset and re-seed the database |
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Project Name
|
|
2
|
+
|
|
3
|
+
Brief description of what this app does.
|
|
4
|
+
|
|
5
|
+
## Setup
|
|
6
|
+
|
|
7
|
+
Run the setup script to install dependencies, initialize the database, and seed it with demo data:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm run setup
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Development
|
|
14
|
+
|
|
15
|
+
Start the dev server:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm run dev
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Open [http://localhost:3000](http://localhost:3000) in your browser.
|
|
22
|
+
|
|
23
|
+
## Using CodeYam Editor
|
|
24
|
+
|
|
25
|
+
This project was built with [CodeYam](https://codeyam.com). To launch the editor:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
codeyam editor
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
The editor provides a live preview alongside a Claude Code terminal for iterating on the app.
|
|
32
|
+
|
|
33
|
+
## Database
|
|
34
|
+
|
|
35
|
+
This project uses Supabase (PostgreSQL) via Prisma. Common commands:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npm run db:push # Apply schema changes and generate Prisma client
|
|
39
|
+
npm run db:seed # Seed the database with demo data
|
|
40
|
+
npm run db:reset # Reset database (runs prisma migrate reset)
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Scripts
|
|
44
|
+
|
|
45
|
+
| Script | Description |
|
|
46
|
+
| ------------------ | -------------------------------------------- |
|
|
47
|
+
| `npm run setup` | One-line project setup (install + db + seed) |
|
|
48
|
+
| `npm run dev` | Start the development server |
|
|
49
|
+
| `npm run build` | Build for production |
|
|
50
|
+
| `npm run db:push` | Apply Prisma schema changes |
|
|
51
|
+
| `npm run db:seed` | Seed the database |
|
|
52
|
+
| `npm run db:reset` | Reset the database |
|
|
@@ -53,7 +53,7 @@ Then present a **concise** overview to the user:
|
|
|
53
53
|
|
|
54
54
|
1. **Component Summary** — 2-3 sentences on what the component does and the current scenario being previewed.
|
|
55
55
|
|
|
56
|
-
2. **Suggested Tests** — Compare the component's code paths (conditionals, edge cases, visual states) against the existing scenarios from the database. Recommend 2-4 specific ways to test the component that are **not yet covered** by saved scenarios. Focus on interesting visual states — e.g. "What does this look like with a very long title?", "What happens when the list is empty?", "How does the error state render?". Be specific to this component, not generic.
|
|
56
|
+
2. **Suggested Tests** — Compare the component's code paths (conditionals, edge cases, visual states) against the existing scenarios from the database. Recommend 2-4 specific ways to test the component that are **not yet covered** by saved scenarios. Focus on interesting visual states — e.g. "What does this look like with a very long title?", "What happens when the list is empty?", "How does the error state render?". Also suggest ways to enrich the _existing_ scenario's data to better exercise the component (more realistic content, populated optional fields, diverse values). Be specific to this component, not generic.
|
|
57
57
|
|
|
58
58
|
Keep it brief — no tables, no exhaustive attribute lists. The user can see the preview and wants actionable suggestions, not a data dump.
|
|
59
59
|
|
|
@@ -44,7 +44,7 @@ codeyam editor 13 → Present summary, get final approval
|
|
|
44
44
|
When the user asks for changes — whether through the menu, a direct request, or even a question that implies a change (e.g., "Can the cards have images?") — you MUST run `codeyam editor change` **before** making any modifications. This includes:
|
|
45
45
|
|
|
46
46
|
- Code changes (components, routes, lib functions, styles)
|
|
47
|
-
- Scenario data updates (seed data, mock data)
|
|
47
|
+
- Scenario data updates (seed data, localStorage data, mock data)
|
|
48
48
|
- Style adjustments (CSS, Tailwind classes, layout tweaks)
|
|
49
49
|
- Even small fixes (typos, color tweaks, spacing)
|
|
50
50
|
|
|
@@ -83,13 +83,13 @@ The user is watching the live preview panel while you work. A static preview mak
|
|
|
83
83
|
**How to refresh:**
|
|
84
84
|
|
|
85
85
|
```
|
|
86
|
-
codeyam editor preview
|
|
86
|
+
codeyam editor preview '{"dimension":"<name from screenSizes>"}'
|
|
87
87
|
```
|
|
88
88
|
|
|
89
89
|
Navigate to a specific path or switch scenario:
|
|
90
90
|
|
|
91
91
|
```
|
|
92
|
-
codeyam editor preview '{"path":"/drinks/1"}'
|
|
92
|
+
codeyam editor preview '{"path":"/drinks/1","dimension":"<name from screenSizes>"}'
|
|
93
93
|
codeyam editor preview '{"scenarioId":"abc-123"}'
|
|
94
94
|
```
|
|
95
95
|
|
|
@@ -105,12 +105,16 @@ When a collaborator clones the repo and runs `codeyam editor`, scenarios are aut
|
|
|
105
105
|
|
|
106
106
|
```bash
|
|
107
107
|
# Register component scenario (auto-captures screenshot)
|
|
108
|
-
|
|
108
|
+
# ALWAYS include "dimensions" — use the project's default screen size name from setup
|
|
109
|
+
codeyam editor register '{"name":"DrinkCard - Default","componentName":"DrinkCard","componentPath":"app/components/DrinkCard.tsx","url":"/isolated-components/DrinkCard?s=Default","dimensions":["<name from screenSizes>"],"mockData":{"routes":{"/api/...":{"body":[...]}}}}'
|
|
109
110
|
|
|
110
|
-
# Register app scenario with seed data (ALWAYS include "url"
|
|
111
|
-
codeyam editor register '{"name":"Full Catalog","type":"application","url":"/","seed":{"drinks":[...]}}'
|
|
111
|
+
# Register app scenario with seed data (ALWAYS include "url" and "dimensions")
|
|
112
|
+
codeyam editor register '{"name":"Full Catalog","type":"application","url":"/","dimensions":["<name from screenSizes>"],"seed":{"drinks":[...]}}'
|
|
112
113
|
|
|
113
|
-
#
|
|
114
|
+
# Register app scenario with localStorage (for apps using client-side storage instead of a database)
|
|
115
|
+
codeyam editor register '{"name":"Full Library","type":"application","url":"/","dimensions":["<name from screenSizes>"],"localStorage":{"articles":[...],"collections":[...]}}'
|
|
116
|
+
|
|
117
|
+
# For large seed/localStorage data, write JSON to a temp file and use @ prefix:
|
|
114
118
|
codeyam editor register @/tmp/scenario-data.json
|
|
115
119
|
|
|
116
120
|
# Journal entry (one per feature, references scenario names)
|
|
@@ -119,9 +123,9 @@ codeyam editor journal '{"title":"...","type":"feature","description":"..."}'
|
|
|
119
123
|
# Update journal with commit info
|
|
120
124
|
codeyam editor journal-update '{"time":"...","commitSha":"...","commitMessage":"..."}'
|
|
121
125
|
|
|
122
|
-
# Refresh preview / navigate / switch scenario
|
|
123
|
-
codeyam editor preview
|
|
124
|
-
codeyam editor preview '{"path":"/drinks/1"}'
|
|
126
|
+
# Refresh preview / navigate / switch scenario (ALWAYS include "dimension")
|
|
127
|
+
codeyam editor preview '{"dimension":"<name from screenSizes>"}'
|
|
128
|
+
codeyam editor preview '{"path":"/drinks/1","dimension":"<name from screenSizes>"}'
|
|
125
129
|
codeyam editor preview '{"scenarioId":"abc-123"}'
|
|
126
130
|
|
|
127
131
|
# Show/hide results panel
|
package/package.json
CHANGED
|
@@ -11,6 +11,9 @@ const editorScenariosSchema = {
|
|
|
11
11
|
screenshot_path: schemaField(),
|
|
12
12
|
viewport_width: schemaField(),
|
|
13
13
|
viewport_height: schemaField(),
|
|
14
|
+
dimension: schemaField(),
|
|
15
|
+
dimensions: schemaField(),
|
|
16
|
+
screenshot_paths: schemaField(),
|
|
14
17
|
created_at: schemaField(),
|
|
15
18
|
updated_at: schemaField(),
|
|
16
19
|
};
|
|
@@ -61,5 +64,58 @@ export async function createEditorScenariosTable(db) {
|
|
|
61
64
|
// Column already exists — expected for fresh databases
|
|
62
65
|
}
|
|
63
66
|
}
|
|
67
|
+
// Named dimension column (e.g. "Mobile", "Desktop")
|
|
68
|
+
try {
|
|
69
|
+
await db.schema
|
|
70
|
+
.alterTable('editor_scenarios')
|
|
71
|
+
.addColumn('dimension', 'varchar')
|
|
72
|
+
.execute();
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
// Column already exists — expected for fresh databases
|
|
76
|
+
}
|
|
77
|
+
// Multi-dimension support: JSON array of dimension names and map of screenshot paths
|
|
78
|
+
for (const col of ['dimensions', 'screenshot_paths']) {
|
|
79
|
+
try {
|
|
80
|
+
await db.schema
|
|
81
|
+
.alterTable('editor_scenarios')
|
|
82
|
+
.addColumn(col, 'text')
|
|
83
|
+
.execute();
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
// Column already exists — expected for fresh databases
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
// Backfill: wrap existing single dimension into dimensions array,
|
|
90
|
+
// and existing screenshot_path into screenshot_paths object
|
|
91
|
+
try {
|
|
92
|
+
const rows = await db
|
|
93
|
+
.selectFrom('editor_scenarios')
|
|
94
|
+
.select(['id', 'dimension', 'screenshot_path'])
|
|
95
|
+
.execute();
|
|
96
|
+
for (const row of rows) {
|
|
97
|
+
const r = row;
|
|
98
|
+
if (r.dimension && !r.dimensions) {
|
|
99
|
+
await db
|
|
100
|
+
.updateTable('editor_scenarios')
|
|
101
|
+
.set({ dimensions: JSON.stringify([r.dimension]) })
|
|
102
|
+
.where('id', '=', r.id)
|
|
103
|
+
.execute();
|
|
104
|
+
}
|
|
105
|
+
if (r.screenshot_path && !r.screenshot_paths) {
|
|
106
|
+
const dimName = r.dimension || 'Default';
|
|
107
|
+
await db
|
|
108
|
+
.updateTable('editor_scenarios')
|
|
109
|
+
.set({
|
|
110
|
+
screenshot_paths: JSON.stringify({ [dimName]: r.screenshot_path }),
|
|
111
|
+
})
|
|
112
|
+
.where('id', '=', r.id)
|
|
113
|
+
.execute();
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
// Backfill is best-effort — columns may not exist yet on first run
|
|
119
|
+
}
|
|
64
120
|
}
|
|
65
121
|
//# sourceMappingURL=editorScenariosTable.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editorScenariosTable.js","sourceRoot":"","sources":["../../../../../../../../packages/database/src/lib/kysely/tables/editorScenariosTable.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE3D,MAAM,qBAAqB,GAAG;IAC5B,EAAE,EAAE,WAAW,EAAqB;IACpC,UAAU,EAAE,WAAW,EAAU;IACjC,IAAI,EAAE,WAAW,EAAU;IAC3B,WAAW,EAAE,WAAW,EAAiB;IACzC,cAAc,EAAE,WAAW,EAAiB;IAC5C,cAAc,EAAE,WAAW,EAAiB;IAC5C,GAAG,EAAE,WAAW,EAAiB;IACjC,IAAI,EAAE,WAAW,EAAiB;IAClC,eAAe,EAAE,WAAW,EAAiB;IAC7C,cAAc,EAAE,WAAW,EAAiB;IAC5C,eAAe,EAAE,WAAW,EAAiB;IAC7C,UAAU,EAAE,WAAW,EAAqB;IAC5C,UAAU,EAAE,WAAW,EAAqB;CACpC,CAAC;AAMX,MAAM,CAAC,MAAM,2BAA2B,GAAG,MAAM,CAAC,IAAI,CACpD,qBAAqB,CACY,CAAC;AAEpC,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,EAAe;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B,CAAU,EAAE,CAAC;QACjE,IAAI,CAAC;YACH,MAAM,EAAE,CAAC,MAAM;iBACZ,UAAU,CAAC,kBAAkB,CAAC;iBAC9B,SAAS,CAAC,GAAG,EAAE,SAAS,CAAC;iBACzB,OAAO,EAAE,CAAC;QACf,CAAC;QAAC,MAAM,CAAC;YACP,uDAAuD;QACzD,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
1
|
+
{"version":3,"file":"editorScenariosTable.js","sourceRoot":"","sources":["../../../../../../../../packages/database/src/lib/kysely/tables/editorScenariosTable.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE3D,MAAM,qBAAqB,GAAG;IAC5B,EAAE,EAAE,WAAW,EAAqB;IACpC,UAAU,EAAE,WAAW,EAAU;IACjC,IAAI,EAAE,WAAW,EAAU;IAC3B,WAAW,EAAE,WAAW,EAAiB;IACzC,cAAc,EAAE,WAAW,EAAiB;IAC5C,cAAc,EAAE,WAAW,EAAiB;IAC5C,GAAG,EAAE,WAAW,EAAiB;IACjC,IAAI,EAAE,WAAW,EAAiB;IAClC,eAAe,EAAE,WAAW,EAAiB;IAC7C,cAAc,EAAE,WAAW,EAAiB;IAC5C,eAAe,EAAE,WAAW,EAAiB;IAC7C,SAAS,EAAE,WAAW,EAAiB;IACvC,UAAU,EAAE,WAAW,EAAiB;IACxC,gBAAgB,EAAE,WAAW,EAAiB;IAC9C,UAAU,EAAE,WAAW,EAAqB;IAC5C,UAAU,EAAE,WAAW,EAAqB;CACpC,CAAC;AAMX,MAAM,CAAC,MAAM,2BAA2B,GAAG,MAAM,CAAC,IAAI,CACpD,qBAAqB,CACY,CAAC;AAEpC,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,EAAe;IAEf,MAAM,EAAE,CAAC,MAAM;SACZ,WAAW,CAAC,kBAAkB,CAAC;SAC/B,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,GAA4B,EAA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,OAAO,EAAE,CAAC;YACf,CAAC;YACD,IAAI,CAAC,CAAC,eAAe,IAAI,CAAC,CAAC,CAAC,gBAAgB,EAAE,CAAC;gBAC7C,MAAM,OAAO,GAAG,CAAC,CAAC,SAAS,IAAI,SAAS,CAAC;gBACzC,MAAM,EAAE;qBACL,WAAW,CAAC,kBAAkB,CAAC;qBAC/B,GAAG,CAAC;oBACH,gBAAgB,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,eAAe,EAAE,CAAC;iBACnE,CAAC;qBACD,KAAK,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC;qBACtB,OAAO,EAAE,CAAC;YACf,CAAC;QACH,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,mEAAmE;IACrE,CAAC;AACH,CAAC"}
|
|
@@ -59,12 +59,6 @@ export default async function loadEntities({ projectId, branchId, fileIds, fileP
|
|
|
59
59
|
.$if(!!fileIds, (qb) => qb.where('entities.file_id', 'in', fileIds));
|
|
60
60
|
const entities = await query.execute();
|
|
61
61
|
if (!entities || entities.length === 0) {
|
|
62
|
-
console.log('Load Entities: No entities found', {
|
|
63
|
-
projectId,
|
|
64
|
-
fileIds,
|
|
65
|
-
filePaths,
|
|
66
|
-
shas,
|
|
67
|
-
});
|
|
68
62
|
return null;
|
|
69
63
|
}
|
|
70
64
|
return entities.map(dbToEntity);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadEntities.js","sourceRoot":"","sources":["../../../../../../packages/database/src/lib/loadEntities.ts"],"names":[],"mappings":"AACA,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAa1C,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,YAAY,CAAC,EACzC,SAAS,EACT,QAAQ,EACR,OAAO,EACP,SAAS,EACT,KAAK,EACL,IAAI,EACJ,eAAe,GACE;IAC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+
{"version":3,"file":"loadEntities.js","sourceRoot":"","sources":["../../../../../../packages/database/src/lib/loadEntities.ts"],"names":[],"mappings":"AACA,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAa1C,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,YAAY,CAAC,EACzC,SAAS,EACT,QAAQ,EACR,OAAO,EACP,SAAS,EACT,KAAK,EACL,IAAI,EACJ,eAAe,GACE;IACjB,IACE,CAAC,OAAO,IAAI,OAAO,CAAC,MAAM,IAAI,CAAC,CAAC;QAChC,CAAC,SAAS,IAAI,SAAS,CAAC,MAAM,IAAI,CAAC,CAAC;QACpC,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC,CAAC;QAC5B,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC,EAC1B,CAAC;QACD,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,IAAI,IAAI,IAAI,IAAI,CAAC,MAAM,GAAG,EAAE,EAAE,CAAC;QAC7B,MAAM,WAAW,GAAa,EAAE,CAAC;QACjC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC;YACzC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;YACpC,MAAM,aAAa,GAAG,MAAM,YAAY,CAAC;gBACvC,SAAS;gBACT,QAAQ;gBACR,OAAO;gBACP,SAAS;gBACT,KAAK;gBACL,IAAI,EAAE,KAAK;gBACX,eAAe;aAChB,CAAC,CAAC;YAEH,IAAI,aAAa,EAAE,CAAC;gBAClB,WAAW,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC,CAAC;YACrC,CAAC;QACH,CAAC;QACD,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,MAAM,EAAE,GAAG,WAAW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aAC5D,GAAG,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,kBAAkB,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;QAEvE,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC;QAEvC,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvC,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAClC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,GAAG,CAAC,+BAA+B,EAAE,KAAK,EAAE;YAClD,SAAS;YACT,OAAO;YACP,SAAS;YACT,IAAI;SACL,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -26,13 +26,6 @@ export default async function updateCommitMetadata({ commitId, commitSha, metada
|
|
|
26
26
|
// if the convenience parameter for latest run was supplied, merge it in
|
|
27
27
|
if (runStatusUpdate) {
|
|
28
28
|
runStatusUpdate.lastUpdatedAt ?? (runStatusUpdate.lastUpdatedAt = new Date().toISOString());
|
|
29
|
-
if (runStatusUpdate.currentEntityShas !== undefined) {
|
|
30
|
-
console.log(`[updateCommitMetadata] Updating currentRun.currentEntityShas`);
|
|
31
|
-
console.log(`[updateCommitMetadata] Commit SHA: ${commitSha}`);
|
|
32
|
-
console.log(`[updateCommitMetadata] Previous entity SHAs:`, currentMetadata.currentRun?.currentEntityShas);
|
|
33
|
-
console.log(`[updateCommitMetadata] New entity SHAs:`, runStatusUpdate.currentEntityShas);
|
|
34
|
-
console.log(`[updateCommitMetadata] Archive flag:`, archiveCurrentRun);
|
|
35
|
-
}
|
|
36
29
|
metadataUpdate = deepMerge(metadataUpdate ?? {}, {
|
|
37
30
|
currentRun: runStatusUpdate,
|
|
38
31
|
});
|
|
@@ -46,32 +39,14 @@ export default async function updateCommitMetadata({ commitId, commitSha, metada
|
|
|
46
39
|
: currentMetadata;
|
|
47
40
|
// Archive current run if requested
|
|
48
41
|
if (archiveCurrentRun && updatedMetadata.currentRun) {
|
|
49
|
-
console.log(`[updateCommitMetadata] ========================================`);
|
|
50
|
-
console.log(`[updateCommitMetadata] ARCHIVING CURRENT RUN`);
|
|
51
|
-
console.log(`[updateCommitMetadata] Commit SHA: ${commitSha}`);
|
|
52
|
-
console.log(`[updateCommitMetadata] Current run entity SHAs:`, updatedMetadata.currentRun.currentEntityShas);
|
|
53
|
-
console.log(`[updateCommitMetadata] Current run PIDs: analyzer=${updatedMetadata.currentRun.analyzerPid}, capture=${updatedMetadata.currentRun.capturePid}`);
|
|
54
|
-
console.log(`[updateCommitMetadata] Current run completed: analyses=${updatedMetadata.currentRun.analysesCompleted}, captures=${updatedMetadata.currentRun.capturesCompleted}`);
|
|
55
|
-
console.log(`[updateCommitMetadata] Historical runs before archiving: ${updatedMetadata.historicalRuns?.length || 0}`);
|
|
56
42
|
const runToArchive = {
|
|
57
43
|
...updatedMetadata.currentRun,
|
|
58
44
|
archivedAt: new Date().toISOString(),
|
|
59
45
|
};
|
|
60
|
-
console.log(`[updateCommitMetadata] Run to archive:`, JSON.stringify(runToArchive, null, 2));
|
|
61
46
|
updatedMetadata.historicalRuns = [
|
|
62
47
|
...(updatedMetadata.historicalRuns || []),
|
|
63
48
|
runToArchive,
|
|
64
49
|
];
|
|
65
|
-
console.log(`[updateCommitMetadata] Historical runs after archiving: ${updatedMetadata.historicalRuns.length}`);
|
|
66
|
-
console.log(`[updateCommitMetadata] All historical runs:`, JSON.stringify(updatedMetadata.historicalRuns.map((r) => ({
|
|
67
|
-
entityShas: r.currentEntityShas,
|
|
68
|
-
archivedAt: r.archivedAt,
|
|
69
|
-
completed: {
|
|
70
|
-
analyses: r.analysesCompleted,
|
|
71
|
-
captures: r.capturesCompleted,
|
|
72
|
-
},
|
|
73
|
-
})), null, 2));
|
|
74
|
-
console.log(`[updateCommitMetadata] ========================================`);
|
|
75
50
|
}
|
|
76
51
|
// Allow callback to perform complex atomic updates
|
|
77
52
|
if (updateCallback) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateCommitMetadata.js","sourceRoot":"","sources":["../../../../../../packages/database/src/lib/updateCommitMetadata.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,SAAS,EAAc,MAAM,mBAAmB,CAAC;AAW1D,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,oBAAoB,CAAC,EACjD,QAAQ,EACR,SAAS,EACT,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,cAAc,GACW;IACzB,MAAM,WAAW,GAAG,CAAC,CAAC;IACtB,MAAM,aAAa,GAAG,GAAG,CAAC;IAE1B,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,IAAI,WAAW,EAAE,OAAO,EAAE,EAAE,CAAC;QACxD,IAAI,CAAC;YACH,OAAO,MAAM,WAAW,EAAE;iBACvB,WAAW,EAAE;iBACb,OAAO,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;gBACrB,gFAAgF;gBAChF,iFAAiF;gBACjF,MAAM,MAAM,GAAG,MAAM,GAAG;qBACrB,UAAU,CAAC,SAAS,CAAC;qBACrB,MAAM,CAAC,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;qBAC1B,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,EAAO,EAAE,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;qBAC3D,GAAG,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,EAAO,EAAE,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC;qBAC9D,gBAAgB,EAAE,CAAC;gBAEtB,IAAI,CAAC,MAAM,EAAE,CAAC;oBACZ,MAAM,CACJ,iDAAiD,QAAQ,YAAY,CACtE,CAAC;oBACF,OAAO,IAAI,CAAC;gBACd,CAAC;gBAED,+EAA+E;gBAC/E,MAAM,eAAe,GAAmB,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC;gBAE9D,wEAAwE;gBACxE,IAAI,eAAe,EAAE,CAAC;oBACpB,eAAe,CAAC,aAAa,KAA7B,eAAe,CAAC,aAAa,GAAK,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAC;oBAE3D,
|
|
1
|
+
{"version":3,"file":"updateCommitMetadata.js","sourceRoot":"","sources":["../../../../../../packages/database/src/lib/updateCommitMetadata.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,SAAS,EAAc,MAAM,mBAAmB,CAAC;AAW1D,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,oBAAoB,CAAC,EACjD,QAAQ,EACR,SAAS,EACT,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,cAAc,GACW;IACzB,MAAM,WAAW,GAAG,CAAC,CAAC;IACtB,MAAM,aAAa,GAAG,GAAG,CAAC;IAE1B,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,IAAI,WAAW,EAAE,OAAO,EAAE,EAAE,CAAC;QACxD,IAAI,CAAC;YACH,OAAO,MAAM,WAAW,EAAE;iBACvB,WAAW,EAAE;iBACb,OAAO,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;gBACrB,gFAAgF;gBAChF,iFAAiF;gBACjF,MAAM,MAAM,GAAG,MAAM,GAAG;qBACrB,UAAU,CAAC,SAAS,CAAC;qBACrB,MAAM,CAAC,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;qBAC1B,GAA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,EAAE,KAAK,CAAC,CAAC,CAAC;gBAC3D,SAAS;YACX,CAAC;YAED,MAAM,CACJ,wEAAwE,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC,UAAU,OAAO,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,EAAE,EACnI,KAAK,CACN,CAAC;YACF,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-yHOVb4rc.js","assets/chunk-JZWAC4HX-C4pqxYJB.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
var pt=Object.defineProperty;var ht=(t,s,a)=>s in t?pt(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a;var Le=(t,s,a)=>ht(t,typeof s!="symbol"?s+"":s,a);import{r as n,j as e,w as ut,u as ft,b as gt}from"./chunk-JZWAC4HX-C4pqxYJB.js";import{u as jt,S as bt}from"./useCustomSizes-CrAK28Bc.js";import{s as Nt,g as ie,c as vt,b as yt,a as wt,T as St,D as kt}from"./editorPreview-BLQMSKZa.js";import{C as Ne}from"./CopyButton-BPXZwM4t.js";import{_ as Ct}from"./preload-helper-ckwbz45p.js";import{c as Mt}from"./cy-logo-cli-DcX-ZS3p.js";import{u as Pt,S as $e}from"./Spinner-Bb5uFQ5V.js";import"./copy-n2FB0_Sw.js";import"./createLucideIcon-CC6AbExI.js";import"./useLastLogLine-C14nCb1q.js";function ve(t){const[s,a]=n.useState(null),[c,g]=n.useState(!1),d=n.useCallback(()=>{t&&(g(!0),fetch(`/api/editor-test-results?testFile=${encodeURIComponent(t)}`).then(o=>o.json()).then(o=>{a(o),g(!1)}).catch(()=>{a({testFilePath:t,status:"error",testCases:[],errorMessage:"Failed to fetch test results"}),g(!1)}))},[t]);return n.useEffect(()=>{t&&d()},[t,d]),{results:s,isRunning:c,runTests:d}}function se(t){if(!t||t==="/")return"Home";const a=t.split("?")[0].replace(/^\//,"").split("/")[0];return a.charAt(0).toUpperCase()+a.slice(1)}function ye(t){return t?t.includes("/isolated-components"):!1}function Et(t,s){return!s||Object.keys(s).length===0?t:t.filter(a=>s[a.name])}function ee({imgSrc:t,name:s,isActive:a,onSelect:c}){return e.jsxs("button",{onClick:c,className:"flex flex-col items-center gap-1 cursor-pointer group",title:s,children:[e.jsx("div",{className:`w-32 h-32 rounded overflow-hidden border-2 transition-all bg-[#1a1a1a] ${a?"border-[#005c75] ring-1 ring-[#005c75]":"border-transparent hover:border-[#4d4d4d]"}`,children:t?e.jsx("img",{src:t,alt:s,className:"w-full h-full object-contain",loading:"lazy"}):e.jsx("div",{className:"w-full h-full bg-[#1a1a1a] flex items-center justify-center",children:e.jsx("span",{className:"text-[8px] text-gray-600",children:"No img"})})}),e.jsx("span",{className:`text-[10px] leading-tight text-center truncate w-32 ${a?"text-white":"text-gray-500 group-hover:text-gray-300"}`,children:s})]})}function je({testFile:t,entityName:s}){const{results:a,isRunning:c,runTests:g}=ve(t);if(c&&!a)return e.jsxs("div",{className:"px-2 pt-1 flex items-center gap-1.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[#005c75] animate-pulse"}),e.jsx("span",{className:"text-[10px] text-gray-400",children:"Running tests..."})]});if(!a)return null;if(a.status==="error")return e.jsx("div",{className:"px-2 pt-1",children:e.jsx("span",{className:"text-[10px] text-red-400",children:a.errorMessage})});const d=s?a.testCases.filter(m=>m.fullName.startsWith(s)):a.testCases,o=d.length>0?d:a.testCases;if(o.length===0)return null;const h=s?`${s} > `:"";return e.jsxs("div",{className:"px-2 pt-1 space-y-0.5",children:[o.map(m=>{var y;const S=h&&m.fullName.startsWith(h)?m.fullName.slice(h.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:S})]}),m.status==="failed"&&((y=m.failureMessages)==null?void 0:y.map((w,v)=>e.jsx("div",{className:"pl-4 text-[9px] text-red-300/70 truncate max-w-full",title:w,children:w.split(`
|
|
3
|
-
`)[0]},v)))]},m.fullName)}),e.jsx("button",{onClick:g,disabled:c,className:"mt-1 text-[10px] text-[#00a0c4] hover:text-[#00c4ee] transition-colors cursor-pointer disabled:opacity-50 bg-transparent border-none p-0",children:c?"Running...":"Re-run"})]})}function J({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(Ne,{content:t,icon:!0,iconSize:10,className:"shrink-0 text-gray-500 hover:text-gray-300 transition-colors"})]}):null}function It({scenarios:t,projectRoot:s,activeScenarioId:a,onScenarioSelect:c,zoomComponent:g,onZoomChange:d,analyzedEntities:o=[],glossaryFunctions:h=[],activeAnalyzedScenarioId:m,onAnalyzedScenarioSelect:S,entityImports:y,pageFilePaths:w={}}){const{pageGroups:v,componentGroups:M}=n.useMemo(()=>{var u;const p=new Map,r=new Map;for(const f of t)if(f.componentName){const i=r.get(f.componentName)||[];i.push(f),r.set(f.componentName,i)}else if(ye(f.url)){const i=(u=f.url)==null?void 0:u.match(/[?&]c=([^&]+)/),N=i?decodeURIComponent(i[1]):"Isolated",E=r.get(N)||[];E.push(f),r.set(N,E)}else{const i=se(f.url),N=p.get(i)||[];N.push(f),p.set(i,N)}const x=new Map([...r.entries()].sort(([f],[i])=>f.localeCompare(i)));return{pageGroups:p,componentGroups:x}},[t]),j=n.useMemo(()=>{const p=new Set((o||[]).filter(x=>x.entityType==="visual").map(x=>x.name)),r=new Map;for(const[x,u]of M)p.has(x)||r.set(x,u);return r},[M,o]),{visualEntities:A,libraryEntities:B}=n.useMemo(()=>{const p=o.filter(x=>x.entityType==="visual").sort((x,u)=>x.name.localeCompare(u.name)),r=o.filter(x=>x.entityType==="library"||x.entityType==="functionCall").sort((x,u)=>x.name.localeCompare(u.name));return{visualEntities:p,libraryEntities:r}},[o]),P=n.useMemo(()=>{const p=new Set(B.map(r=>r.name));return h.filter(r=>!p.has(r.name)).sort((r,x)=>r.name.localeCompare(x.name))},[h,B]),R=o.some(p=>p.isAnalyzing),I=n.useRef(null),T=n.useRef(0),F=n.useCallback(()=>{I.current&&(T.current=I.current.scrollTop)},[]);if(n.useEffect(()=>{I.current&&T.current>0&&(I.current.scrollTop=T.current)}),t.length===0&&o.length===0&&P.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(g){const p=M.get(g)||[],r=new Set((y==null?void 0:y[g])||[]),x=r.size>0,u=x?A.filter(i=>r.has(i.name)):[],f=x?B.filter(i=>r.has(i.name)):[];return e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsxs("div",{className:"p-3 space-y-1",children:[e.jsxs("button",{onClick:()=>d(void 0),className:"w-full flex items-center gap-2 px-3 py-1.5 text-xs text-gray-400 hover:text-white transition-colors cursor-pointer",children:[e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",className:"shrink-0",children:e.jsx("path",{d:"M7.5 9L4.5 6L7.5 3",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),"All scenarios"]}),e.jsx("div",{className:"px-3 py-1.5",children:e.jsx("span",{className:"text-xs font-semibold text-white uppercase tracking-wider",children:g})}),e.jsx("div",{className:"flex flex-wrap gap-2 px-2",children:p.length===0?e.jsx("div",{className:"px-3 py-2 text-xs text-gray-500",children:"No scenarios for this component"}):p.map(i=>e.jsx(ee,{imgSrc:i.screenshotPath?`/api/editor-scenario-image/${i.id}.png`:null,name:i.name,isActive:i.id===a,onSelect:()=>c(i)},i.id))}),u.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"})}),u.map(i=>e.jsxs("div",{className:"mt-2",children:[e.jsx("div",{className:"flex items-center gap-2 px-2 py-1",children:e.jsx("button",{onClick:()=>d(i.name),className:"text-[11px] font-medium text-gray-400 truncate cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:i.name})}),e.jsx(J,{filePath:i.filePath,projectRoot:s}),(i.scenarios.length>0||i.pendingScenarios.length>0)&&e.jsx("div",{className:"flex flex-wrap gap-2 px-2 pt-1",children:i.scenarios.map(N=>e.jsx(ee,{imgSrc:N.screenshotPath?`/api/screenshot/${N.screenshotPath}`:null,name:N.name,isActive:N.id===m,onSelect:()=>S==null?void 0:S({analysisId:i.analysisId,scenarioId:N.id,scenarioName:N.name,entitySha:i.sha,entityName:i.name})},N.id))})]},i.sha))]}),f.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"})}),f.map(i=>e.jsxs("div",{className:"mt-2",children:[e.jsx("div",{className:"px-2 py-1",children:e.jsx("span",{className:"text-[11px] font-medium text-gray-300",children:i.name})}),e.jsx(J,{filePath:i.filePath,projectRoot:s}),i.testFile&&e.jsx(je,{testFile:i.testFile,entityName:i.name})]},i.sha))]})]})})}return e.jsx("div",{ref:I,onScroll:F,className:"flex-1 overflow-auto",children:e.jsxs("div",{className:"p-3 space-y-3",children:[v.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"})}),[...v.entries()].sort(([p],[r])=>p==="Home"?-1:r==="Home"?1:p.localeCompare(r)).map(([p,r])=>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})}),w[p]&&e.jsx(J,{filePath:w[p],projectRoot:s}),e.jsx("div",{className:"flex flex-wrap gap-2 pt-1",children:r.map(x=>e.jsx(ee,{imgSrc:x.screenshotPath?`/api/editor-scenario-image/${x.id}.png`:null,name:x.name,isActive:x.id===a&&!m,onSelect:()=>c(x)},x.id))})]},p))]}),j.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"})}),[...j.entries()].map(([p,r])=>{var x;return e.jsxs("div",{className:"mt-2",children:[e.jsx("div",{className:"flex items-center justify-between px-2 py-1",children:e.jsx("button",{onClick:()=>d(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})}),((x=r[0])==null?void 0:x.componentPath)&&e.jsx(J,{filePath:r[0].componentPath,projectRoot:s}),e.jsx("div",{className:"flex flex-wrap gap-2 px-2 pt-1",children:r.map(u=>e.jsx(ee,{imgSrc:u.screenshotPath?`/api/editor-scenario-image/${u.id}.png`:null,name:u.name,isActive:u.id===a&&!m,onSelect:()=>c(u)},u.id))})]},p)})]}),A.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"}),R&&t.length===0&&o.every(p=>p.scenarioCount===0)&&e.jsx("span",{className:"ml-2 text-[10px] text-gray-500",children:"— Entities are being analyzed..."})]}),A.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:()=>d(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(J,{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(r=>e.jsx(ee,{imgSrc:r.screenshotPath?`/api/screenshot/${r.screenshotPath}`:null,name:r.name,isActive:r.id===m,onSelect:()=>S==null?void 0:S({analysisId:p.analysisId,scenarioId:r.id,scenarioName:r.name,entitySha:p.sha,entityName:p.name})},r.id)),p.pendingScenarios.map(r=>e.jsx("div",{className:"px-2.5 py-1 bg-[#2a2a2a] text-gray-400 text-[10px] rounded-full",title:r,children:r},r))]})]},p.sha))]}),(B.length>0||P.length>0)&&e.jsxs("div",{className:`pt-2 mt-1 ${A.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"})}),B.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(J,{filePath:p.filePath,projectRoot:s}),p.testFile?e.jsx(je,{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)),P.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(J,{filePath:p.filePath,projectRoot:s}),e.jsx(je,{testFile:p.testFile,entityName:p.name})]},p.name))]})]})})}function Tt(t,s,a=new Date){const c={"1d":1,"3d":3,"7d":7,"30d":30}[s],g=new Date(a);g.setDate(g.getDate()-c);const d=g.toISOString().split("T")[0],o=t.filter(w=>w.date>=d),h=new Set(o.map(w=>w.commitSha).filter(Boolean)),m=new Map;for(const w of o)if(w.scenarioScreenshots)for(const v of w.scenarioScreenshots){m.has(v.name)||m.set(v.name,[]);const M=m.get(v.name);M.some(j=>j.path===v.path)||M.push({path:v.path,time:w.time})}for(const w of m.values())w.sort((v,M)=>v.time.localeCompare(M.time));const S=[],y=new Map;for(const[w,v]of m){const M=w.indexOf(" - ");if(M!==-1){const j=w.slice(0,M);y.has(j)||y.set(j,[]),y.get(j).push({name:w,screenshots:v})}else S.push({name:w,screenshots:v})}return{commitCount:h.size,entryCount:o.length,appScenarios:S,componentGroups:y,totalScenarios:m.size}}function Rt(t){const s=new Map;for(const a of[...t].reverse()){const c=s.get(a.date)||[];c.push(a),s.set(a.date,c)}return s}function Lt(t){const s=new Map;for(const a of t){let c;if("componentName"in a&&a.componentName)c=a.componentName;else if("componentName"in a&&a.componentName===null)c="App";else{const d=a.name.indexOf(" - ");c=d!==-1?a.name.slice(0,d):"App"}const g=s.get(c)||[];g.push(a),s.set(c,g)}return[...s.entries()].sort(([a],[c])=>a==="App"?-1:c==="App"?1:a.localeCompare(c))}const Be=120;function He({text:t,theme:s}){const[a,c]=n.useState(!1),g=t.length>Be,d=g&&!a?t.slice(0,Be)+"…":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:[d,g&&e.jsx("button",{onClick:()=>c(!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 _e({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 $t({testFile:t,entityName:s}){const{results:a,isRunning:c,runTests:g}=ve(t);if(c&&!a)return e.jsxs("div",{className:"pt-1 flex items-center gap-1.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[#00a0c4] animate-pulse"}),e.jsx("span",{className:"text-[10px] text-gray-500",children:"Running tests..."})]});if(!a)return null;if(a.status==="error")return e.jsx("div",{className:"pt-1",children:e.jsx("span",{className:"text-[10px] text-red-400",children:a.errorMessage})});const d=s?a.testCases.filter(m=>m.fullName.startsWith(s)):a.testCases,o=d.length>0?d:a.testCases;if(o.length===0)return null;const h=s?`${s} > `:"";return e.jsxs("div",{className:"pt-1 space-y-0.5",children:[o.map(m=>{var y;const S=h&&m.fullName.startsWith(h)?m.fullName.slice(h.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:S})]}),m.status==="failed"&&((y=m.failureMessages)==null?void 0:y.map((w,v)=>e.jsx("div",{className:"pl-4 text-[9px] text-red-400/70 truncate max-w-full",title:w,children:w.split(`
|
|
4
|
-
`)[0]},v)))]},m.fullName)}),e.jsx("button",{onClick:g,disabled:c,className:"mt-1 text-[10px] text-[#00a0c4] hover:text-[#38bdf8] transition-colors cursor-pointer disabled:opacity-50 bg-transparent border-none p-0",children:c?"Running...":"Re-run"})]})}const Bt={added:"text-green-400",untracked:"text-green-400",modified:"text-blue-400",renamed:"text-purple-400"};function _t({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 ${Bt[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 At={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 Dt(t){try{return new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}}function Ft(t){try{return new Date(t+"T00:00:00").toLocaleDateString([],{weekday:"long",month:"long",day:"numeric"})}catch{return t}}const Ot=[{value:"1d",label:"1 Day"},{value:"3d",label:"3 Days"},{value:"7d",label:"1 Week"},{value:"30d",label:"1 Month"}];function zt({entries:t,onScreenshotClick:s}){const[a,c]=n.useState(!1),[g,d]=n.useState("7d"),o=n.useMemo(()=>Tt(t,g),[t,g]);return e.jsxs("div",{className:"bg-[#2d2d2d] rounded-lg overflow-hidden",children:[e.jsxs("button",{onClick:()=>c(!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:Ot.map(h=>e.jsx("button",{onClick:()=>d(h.value),className:`px-2.5 py-1 text-[10px] font-medium rounded transition-colors cursor-pointer border ${g===h.value?"bg-[#005c75] text-white border-[#005c75]":"bg-transparent text-gray-400 border-[#4d4d4d] hover:text-white hover:border-[#005c75]"}`,children:h.label},h.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(h=>e.jsx(Ae,{scenario:h,onScreenshotClick:s},h.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(([h],[m])=>h.localeCompare(m)).map(([h,m])=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("span",{className:"text-[10px] font-medium text-gray-400",children:h}),m.map(S=>e.jsx(Ae,{scenario:S,onScreenshotClick:s},S.name))]},h))]})]})]})]})}function Ae({scenario:t,onScreenshotClick:s}){const a=t.name.indexOf(" - "),c=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:c}),e.jsx("div",{className:"flex items-center gap-1 overflow-x-auto",children:t.screenshots.map((g,d)=>e.jsxs("div",{className:"flex items-center shrink-0",children:[d>0&&e.jsx("span",{className:"text-[8px] text-gray-600 mx-0.5",children:"→"}),e.jsx("button",{type:"button",className:"w-16 h-16 rounded overflow-hidden border border-[#3d3d3d] hover:border-[#00a0c4] bg-[#1e1e1e] shrink-0 flex items-center justify-center cursor-pointer transition-colors",title:`${t.name} (${new Date(g.time).toLocaleDateString()})`,onClick:()=>s==null?void 0:s({screenshotUrl:`/api/editor-journal-image/${g.path.replace("screenshots/","")}`,commitSha:null,commitMessage:null,scenarioName:t.name}),children:e.jsx("img",{src:`/api/editor-journal-image/${g.path.replace("screenshots/","")}`,alt:t.name,className:"max-w-full max-h-full object-contain",loading:"lazy"})})]},g.path))})]})}function Ut({isActive:t,onScreenshotClick:s,glossaryFunctions:a=[]}){const[c,g]=n.useState([]),[d,o]=n.useState(!0),[h,m]=n.useState(new Set),S=n.useCallback(v=>{m(M=>{const j=new Set(M);return j.has(v)?j.delete(v):j.add(v),j})},[]),y=n.useCallback(async()=>{try{const v=await fetch("/api/editor-journal");if(v.ok){const M=await v.json();g(M.entries||[])}}catch{}finally{o(!1)}},[]);if(n.useEffect(()=>{y()},[y]),n.useEffect(()=>{t&&y()},[t,y]),n.useEffect(()=>{if(!t)return;const v=setInterval(()=>void y(),5e3);return()=>clearInterval(v)},[t,y]),d)return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx("span",{className:"text-gray-500 text-sm",children:"Loading journal..."})});if(c.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 w=Rt(c);return e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsx(zt,{entries:c,onScreenshotClick:s}),[...w.entries()].map(([v,M])=>e.jsxs("div",{children:[e.jsx("div",{className:"px-3 py-1.5 sticky top-0 bg-[#1e1e1e] z-10",children:e.jsx("span",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider",children:Ft(v)})}),e.jsx("div",{className:"space-y-2",children:M.map((j,A)=>{const B=At[j.type]||{label:j.type,color:"bg-gray-600"},P=`${j.time}-${A}`,R=h.has(P);return e.jsxs("div",{className:"bg-[#2d2d2d] rounded-lg overflow-hidden",children:[e.jsxs("div",{className:`p-3 space-y-2 ${R?"":"max-h-[300px] overflow-y-auto"}`,children:[e.jsx("div",{className:"flex items-start gap-2 cursor-pointer",onClick:()=>S(P),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:j.title}),e.jsx("span",{className:`${B.color} text-white text-[9px] font-bold px-1.5 py-0.5 rounded uppercase tracking-wider shrink-0`,children:B.label})]}),e.jsx("span",{className:"text-[10px] text-gray-500",children:Dt(j.time)}),j.featureName&&e.jsx("span",{className:"text-[10px] text-gray-500 italic truncate",title:j.featureName,children:j.featureName})]})}),j.userPrompt&&e.jsx(He,{text:j.userPrompt,theme:"dark"}),e.jsx("p",{className:"text-xs text-gray-400 leading-relaxed",children:j.description}),j.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/${j.screenshot.replace("screenshots/","")}`,commitSha:j.commitSha,commitMessage:j.commitMessage,scenarioName:j.title}),children:e.jsx("img",{src:`/api/editor-journal-image/${j.screenshot.replace("screenshots/","")}`,alt:j.title,className:"max-w-full max-h-full object-contain",loading:"lazy"})}),j.scenarioScreenshots&&j.scenarioScreenshots.length>0&&(()=>{const I=Lt(j.scenarioScreenshots),T=j.entityChangeStatus,F=I.filter(([f])=>f==="App").flatMap(([,f])=>f),p=I.filter(([f])=>f!=="App"),r=new Map;for(const f of F){const i=se(f.url??null),N=r.get(i)||[];N.push(f),r.set(i,N)}const x=[...r.entries()],u=f=>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/${f.path.replace("screenshots/","")}`,commitSha:j.commitSha,commitMessage:j.commitMessage,scenarioName:f.name}),children:e.jsx("img",{src:`/api/editor-journal-image/${f.path.replace("screenshots/","")}`,alt:f.name,title:f.name,className:"max-w-full max-h-full object-contain",loading:"lazy"})},f.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(([f,i])=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[10px] font-medium text-gray-400",children:f}),(T==null?void 0:T[f])&&e.jsx(_e,{status:T[f]})]}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-0.5",children:i.map(u)})]},f))]}),p.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"}),p.map(([f,i])=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[10px] font-medium text-gray-400",children:f}),(T==null?void 0:T[f])&&e.jsx(_e,{status:T[f]})]}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-0.5",children:i.map(u)})]},f))]})]})})(),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(I=>e.jsxs("div",{children:[e.jsx("span",{className:"text-[11px] font-medium text-gray-200",children:I.name}),e.jsx("span",{className:"text-[9px] text-gray-500 truncate block",children:I.filePath}),I.testFile?e.jsx($t,{testFile:I.testFile,entityName:I.name}):e.jsx("div",{className:"pt-1",children:e.jsx("span",{className:"text-[10px] text-gray-500",children:"No test file"})})]},I.name))})]}),j.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:j.commitSha.slice(0,7)}),e.jsx("span",{className:"text-gray-500 truncate",children:j.commitMessage})]}),R&&j.modifiedFiles&&j.modifiedFiles.length>0&&e.jsx(_t,{files:j.modifiedFiles})]}),e.jsxs("button",{onClick:()=>S(P),className:"w-full py-1.5 text-[10px] text-gray-500 hover:text-gray-300 border-t border-[#3d3d3d] transition-colors cursor-pointer",children:["——— ",R?"Collapse":"Expand"," ———"]})]},P)})})]},v))]})})}function te({imgSrc:t,name:s,isActive:a,onSelect:c}){return e.jsxs("button",{onClick:c,className:"flex flex-col items-center gap-1 cursor-pointer group w-full",title:s,children:[e.jsx("div",{className:`w-full aspect-square rounded overflow-hidden border-2 transition-all bg-[#1a1a1a] ${a?"border-[#005c75] ring-1 ring-[#005c75]":"border-transparent hover:border-[#4d4d4d]"}`,children:t?e.jsx("img",{src:t,alt:s,className:"w-full h-full object-contain",loading:"lazy"}):e.jsx("div",{className:"w-full h-full bg-[#1a1a1a] flex items-center justify-center",children:e.jsx("span",{className:"text-[8px] text-gray-600",children:"No img"})})}),e.jsx("span",{className:`text-[10px] leading-tight text-center truncate w-full ${a?"text-white":"text-gray-500 group-hover:text-gray-300"}`,children:s})]})}function le({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(Ne,{content:t,icon:!0,iconSize:10,className:"shrink-0 text-gray-500 hover:text-gray-300 transition-colors"})]}):null}function Wt({hasProject:t,scenarios:s,analyzedEntities:a,glossaryFunctions:c=[],projectRoot:g,activeScenarioId:d,onScenarioSelect:o,onAnalyzedScenarioSelect:h,onSwitchToBuild:m,zoomComponent:S,onZoomChange:y,entityImports:w,pageFilePaths:v={},projectTitle:M,projectDescription:j}){const{pageGroups:A,componentGroups:B}=n.useMemo(()=>{var f;const r=new Map,x=new Map;for(const i of s)if(i.componentName){const N=x.get(i.componentName)||[];N.push(i),x.set(i.componentName,N)}else if(ye(i.url)){const N=(f=i.url)==null?void 0:f.match(/[?&]c=([^&]+)/),E=N?decodeURIComponent(N[1]):"Isolated",U=x.get(E)||[];U.push(i),x.set(E,U)}else{const N=se(i.url),E=r.get(N)||[];E.push(i),r.set(N,E)}const u=new Map([...x.entries()].sort(([i],[N])=>i.localeCompare(N)));return{pageGroups:r,componentGroups:u}},[s]),P=n.useMemo(()=>a.filter(r=>r.entityType==="visual").sort((r,x)=>r.name.localeCompare(x.name)),[a]),R=n.useMemo(()=>{const r=new Map;for(const x of c)r.set(x.name,x);return r},[c]),I=n.useRef(null),T=n.useRef(0),F=n.useCallback(()=>{I.current&&(T.current=I.current.scrollTop)},[]);if(n.useEffect(()=>{I.current&&T.current>0&&(I.current.scrollTop=T.current)}),!t)return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx("h2",{className:"text-lg font-medium text-white font-['IBM_Plex_Sans'] m-0",children:"Ready to build something?"}),e.jsx("button",{onClick:m,className:"px-6 py-3 bg-[#005c75] text-white text-sm font-medium rounded-lg hover:bg-[#004d63] transition-colors cursor-pointer",children:"Start Building"})]})});if(!(s.length>0||P.length>0))return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-4 px-8 text-center",children:[M?e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"text-lg font-medium text-white font-['IBM_Plex_Sans'] m-0",children:M}),j&&e.jsx("p",{className:"text-sm text-gray-400 m-0 font-['IBM_Plex_Sans'] leading-relaxed",children:j})]}):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:m,className:"px-6 py-3 bg-[#005c75] text-white text-sm font-medium rounded-lg hover:bg-[#004d63] transition-colors cursor-pointer",children:"Start Building"})]})});if(S){const r=A.get(S)||[],x=B.get(S)||[],u=P.find(b=>b.name===S),f=R.get(S),i=[...r,...x],N=new Set((w==null?void 0:w[S])||[]),E=N.size>0,U=E?[...B.entries()].filter(([b])=>N.has(b)):[],ae=E?P.filter(b=>N.has(b.name)&&!U.some(([L])=>L===b.name)):[],K=E?c.filter(b=>N.has(b.name)):[],W=U.length>0||ae.length>0,D=K.length>0,q=W||D;return e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsxs("button",{onClick:()=>y(void 0),className:"flex items-center gap-2 text-xs text-gray-400 hover:text-white transition-colors cursor-pointer bg-transparent border-none p-0",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"]}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold text-white m-0 font-['IBM_Plex_Sans'] uppercase tracking-wider",children:S}),f&&e.jsx(le,{filePath:f.filePath,projectRoot:g})]}),i.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:i.map(b=>e.jsx(te,{imgSrc:b.screenshotPath?`/api/editor-scenario-image/${b.id}.png`:null,name:b.name,isActive:b.id===d,onSelect:()=>o(b)},b.id))}),u&&(u.scenarios.length>0||u.pendingScenarios.length>0)&&e.jsxs("div",{className:"flex flex-wrap gap-2",children:[u.scenarios.map(b=>e.jsx(te,{imgSrc:b.screenshotPath?`/api/screenshot/${b.screenshotPath}`:null,name:b.name,isActive:!1,onSelect:()=>h({analysisId:u.analysisId,scenarioId:b.id,scenarioName:b.name,entitySha:u.sha,entityName:u.name})},b.id)),u.pendingScenarios.map(b=>e.jsx("div",{className:"px-2.5 py-1 bg-[#2a2a2a] text-gray-400 text-[10px] rounded-full",title:b,children:b},b))]}),f&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[10px] text-gray-500",children:"Tests:"}),e.jsx(le,{filePath:f.testFile,projectRoot:g})]}),i.length===0&&!u&&!f&&e.jsx("div",{className:"text-xs text-gray-500",children:"No scenarios for this entity"}),q&&e.jsxs("div",{className:"pt-3 mt-2 border-t border-[#3d3d3d] space-y-3",children:[W&&e.jsxs("div",{children:[e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Components"}),U.map(([b,L])=>e.jsxs("div",{className:"mt-3",children:[e.jsx("div",{className:"py-1",children:e.jsx("button",{onClick:()=>y(b),className:"text-[11px] font-medium text-gray-400 cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:b})}),L.length>0&&e.jsx("div",{className:"grid grid-cols-3 gap-2 pt-1",children:L.map(O=>e.jsx(te,{imgSrc:O.screenshotPath?`/api/editor-scenario-image/${O.id}.png`:null,name:O.name,isActive:O.id===d,onSelect:()=>o(O)},O.id))})]},b)),ae.map(b=>e.jsxs("div",{className:"mt-3",children:[e.jsx("div",{className:"py-1",children:e.jsx("button",{onClick:()=>y(b.name),className:"text-[11px] font-medium text-gray-400 cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:b.name})}),(b.scenarios.length>0||b.pendingScenarios.length>0)&&e.jsxs("div",{className:"grid grid-cols-3 gap-2 pt-1",children:[b.scenarios.map(L=>e.jsx(te,{imgSrc:L.screenshotPath?`/api/screenshot/${L.screenshotPath}`:null,name:L.name,isActive:!1,onSelect:()=>h({analysisId:b.analysisId,scenarioId:L.id,scenarioName:L.name,entitySha:b.sha,entityName:b.name})},L.id)),b.pendingScenarios.map(L=>e.jsx("div",{className:"px-2.5 py-1 bg-[#2a2a2a] text-gray-400 text-[10px] rounded-full",title:L,children:L},L))]})]},b.sha))]}),D&&e.jsxs("div",{children:[e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Functions"}),K.map(b=>e.jsxs("div",{className:"mt-2",children:[e.jsx("div",{className:"py-1",children:e.jsx("button",{onClick:()=>y(b.name),className:"text-[11px] font-medium text-gray-400 cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:b.name})}),e.jsx(le,{filePath:b.filePath,projectRoot:g}),b.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:b.testFile})]})]},b.name))]})]})]})})}return e.jsx("div",{ref:I,onScroll:F,className:"flex-1 overflow-auto",children:e.jsxs("div",{className:"p-4 space-y-4",children:[M&&e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-white m-0 font-['IBM_Plex_Sans']",children:M}),j&&e.jsx("p",{className:"text-xs text-gray-400 m-0 mt-1 font-['IBM_Plex_Sans'] leading-relaxed",children:j})]}),A.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:m,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:m,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:m,className:"text-[#00a0c4] hover:text-[#00c4eb] bg-transparent border-none p-0 cursor-pointer underline font-inherit text-inherit",children:"create a new page"})]}),[...A.entries()].sort(([r],[x])=>r==="Home"?-1:x==="Home"?1:r.localeCompare(x)).map(([r,x])=>e.jsxs("div",{className:"mt-2",children:[e.jsx("div",{className:"py-1",children:e.jsx("button",{onClick:()=>y(r),className:"text-[11px] font-medium text-gray-400 cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:r})}),v[r]&&e.jsx(le,{filePath:v[r],projectRoot:g}),e.jsx("div",{className:"grid grid-cols-3 gap-2 pt-1",children:x.map(u=>e.jsx(te,{imgSrc:u.screenshotPath?`/api/editor-scenario-image/${u.id}.png`:null,name:u.name,isActive:u.id===d,onSelect:()=>o(u)},u.id))})]},r))]})]})})}const De={new:0,edited:1,impacted:2};function Fe({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],c=s&&(t.status==="edited"||t.status==="impacted");return e.jsx("button",{onClick:c?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 ${c?"cursor-pointer hover:opacity-80 transition-opacity":"cursor-default"}`,children:a.label})}function Oe({filePath:t}){const[s,a]=n.useState(null),[c,g]=n.useState(!0),[d,o]=n.useState(null);return n.useEffect(()=>{Ct(()=>import("./index-yHOVb4rc.js"),__vite__mapDeps([0,1])).then(h=>{o(()=>h.default)})},[]),n.useEffect(()=>{g(!0),fetch(`/api/editor-file-diff?path=${encodeURIComponent(t)}`).then(h=>h.json()).then(h=>{a({oldContent:h.oldContent,newContent:h.newContent})}).catch(()=>{a(null)}).finally(()=>g(!1))},[t]),c?e.jsx("div",{className:"p-2 text-[10px] text-gray-400",children:"Loading diff..."}):!s||!d?e.jsx("div",{className:"p-2 text-[10px] text-gray-400",children:"Could not load diff"}):e.jsx("div",{className:"mt-2 border border-gray-200 rounded-lg overflow-hidden max-h-[300px] overflow-auto text-xs",children:e.jsx(d,{oldValue:s.oldContent,newValue:s.newContent,splitView:!1,useDarkTheme:!1,showDiffOnly:!0,styles:{contentText:{fontSize:"11px",lineHeight:"1.4"},line:{padding:"1px 8px",fontSize:"11px"}}})})}function ze({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 Ue({scenarioId:t,name:s,isActive:a,onSelect:c}){const[g,d]=n.useState(!1);return n.useEffect(()=>{d(!1)},[t]),e.jsxs("button",{onClick:c,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:g?e.jsx("div",{className:"w-full h-full bg-gray-100 flex items-center justify-center",children:e.jsx("span",{className:"text-[9px] text-gray-400",children:"No preview"})}):e.jsx("img",{src:`/api/editor-scenario-image/${t}.png`,alt:s,className:"w-full h-full object-contain bg-white",loading:"lazy",onError:()=>d(!0)})}),e.jsx("span",{className:`text-[11px] leading-tight text-center truncate w-32 font-medium ${a?"text-gray-900":"text-gray-600 group-hover:text-gray-900"}`,children:s})]})}function Gt({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(Ne,{content:t,icon:!0,iconSize:10,className:"shrink-0 text-gray-400 hover:text-gray-600 transition-colors"})]}):null}function Ht({testFile:t,entityName:s}){const{results:a,isRunning:c,runTests:g}=ve(t);if(c&&!a)return e.jsxs("div",{className:"pt-1 flex items-center gap-1.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[#0ea5e9] animate-pulse"}),e.jsx("span",{className:"text-[10px] text-gray-400",children:"Running tests..."})]});if(!a)return null;if(a.status==="error")return e.jsx("div",{className:"pt-1",children:e.jsx("span",{className:"text-[10px] text-red-500",children:a.errorMessage})});const d=s?a.testCases.filter(m=>m.fullName.startsWith(s)):a.testCases,o=d.length>0?d:a.testCases;if(o.length===0)return null;const h=s?`${s} > `:"";return e.jsxs("div",{className:"pt-1 space-y-0.5",children:[o.map(m=>{var y;const S=h&&m.fullName.startsWith(h)?m.fullName.slice(h.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:S})]}),m.status==="failed"&&((y=m.failureMessages)==null?void 0:y.map((w,v)=>e.jsx("div",{className:"pl-4 text-[9px] text-red-400 truncate max-w-full",title:w,children:w.split(`
|
|
5
|
-
`)[0]},v)))]},m.fullName)}),e.jsx("button",{onClick:g,disabled:c,className:"mt-1 text-[10px] text-[#0ea5e9] hover:text-[#38bdf8] transition-colors cursor-pointer disabled:opacity-50 bg-transparent border-none p-0",children:c?"Running...":"Re-run"})]})}function We(t){const s=t.indexOf(" - ");return s!==-1?t.slice(s+3):t}function Ge(t,s){return!s||Object.keys(s).length===0?t:[...t].sort(([a],[c])=>{var h,m;const g=((h=s[a])==null?void 0:h.status)||"impacted",d=((m=s[c])==null?void 0:m.status)||"impacted",o=(De[g]??2)-(De[d]??2);return o!==0?o:a.localeCompare(c)})}function Vt({scenarios:t,allScenarios:s=[],glossaryFunctions:a=[],projectRoot:c,activeScenarioId:g,onScenarioSelect:d,onClose:o,entityChangeStatus:h={},modifiedFiles:m=[],featureName:S,userPrompt:y}){const w=n.useMemo(()=>{if(s.length===0||Object.keys(h).length===0)return t;const r=new Set(t.map(u=>u.id)),x=s.filter(u=>{var i;if(r.has(u.id))return!1;const f=u.componentName||se(u.url);return((i=h[f])==null?void 0:i.status)==="impacted"});return x.length===0?t:[...t,...x]},[t,s,h]),v=n.useMemo(()=>Object.entries(h).filter(([,r])=>r.status==="new"||r.status==="edited").map(([r,x])=>({name:r,status:x.status})),[h]),[M,j]=n.useState(null),A=n.useCallback(r=>{j(x=>x===r?null:r)},[]),{pageGroups:B,componentGroups:P}=n.useMemo(()=>{var u;const r=new Map,x=new Map;for(const f of w)if(f.componentName){const i=x.get(f.componentName)||[];i.push(f),x.set(f.componentName,i)}else if(ye(f.url)){const i=(u=f.url)==null?void 0:u.match(/[?&]c=([^&]+)/),N=i?decodeURIComponent(i[1]):"Isolated",E=x.get(N)||[];E.push(f),x.set(N,E)}else{const i=se(f.url),N=r.get(i)||[];N.push(f),r.set(i,N)}return{pageGroups:r,componentGroups:x}},[w]),R=n.useMemo(()=>Ge([...B.entries()],h),[B,h]),I=n.useMemo(()=>Ge([...P.entries()],h),[P,h]),T=R,F=I,p=n.useMemo(()=>Et(a,h),[a,h]);return w.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"}),S&&e.jsx("div",{className:"text-[11px] text-gray-400 truncate",title:S,children:S})]}),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(He,{text:y,theme:"light"}),e.jsx("div",{className:"flex-1 overflow-auto p-4",children:e.jsxs("div",{className:"space-y-5",children:[T.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:T.map(([r,x])=>{var N;const u=h[r],f=M===r,i=(N=x[0])==null?void 0:N.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:r}),u&&e.jsx(Fe,{status:u,onClick:()=>A(r)})]}),f&&(u==null?void 0:u.status)==="edited"&&i&&e.jsx(Oe,{filePath:i}),f&&(u==null?void 0:u.status)==="impacted"&&e.jsx(ze,{impactedBy:u.impactedBy,changedEntities:v}),e.jsx("div",{className:"flex flex-wrap gap-3",children:x.map(E=>e.jsx(Ue,{scenarioId:E.id,name:We(E.name),isActive:E.id===g,onSelect:()=>d(E)},E.id))})]},r)})})]}),F.length>0&&e.jsxs("div",{className:T.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:F.map(([r,x])=>{var N;const u=h[r],f=M===r,i=(N=x[0])==null?void 0:N.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:r}),u&&e.jsx(Fe,{status:u,onClick:()=>A(r)})]}),f&&(u==null?void 0:u.status)==="edited"&&i&&e.jsx(Oe,{filePath:i}),f&&(u==null?void 0:u.status)==="impacted"&&e.jsx(ze,{impactedBy:u.impactedBy,changedEntities:v}),e.jsx("div",{className:"flex flex-wrap gap-3",children:x.map(E=>e.jsx(Ue,{scenarioId:E.id,name:We(E.name),isActive:E.id===g,onSelect:()=>d(E)},E.id))})]},r)})})]}),p.length>0&&e.jsxs("div",{className:T.length>0||F.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:p.map(r=>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:r.name})}),e.jsx(Gt,{filePath:r.filePath,projectRoot:c}),r.testFile?e.jsx(Ht,{testFile:r.testFile,entityName:r.name}):e.jsx("div",{className:"pt-1",children:e.jsx("span",{className:"text-[10px] text-gray-400",children:"No test file"})})]},r.name))})]}),m.length>0&&e.jsxs("div",{className:T.length>0||F.length>0||p.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(r=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:`text-[9px] font-bold uppercase w-[14px] text-center ${r.status==="added"||r.status==="untracked"?"text-green-600":r.status==="modified"?"text-blue-600":r.status==="renamed"?"text-purple-600":"text-gray-400"}`,children:r.status==="added"||r.status==="untracked"?"A":r.status==="modified"?"M":r.status==="renamed"?"R":"?"}),e.jsx("span",{className:"text-[10px] text-gray-500 truncate font-mono",children:r.path})]},r.path))})]})]})})]})}function Jt({items:t,onNavigate:s}){return t.length===0?null:e.jsx("nav",{className:"flex items-center gap-1 text-xs",children:t.map((a,c)=>{const g=c===t.length-1;return e.jsxs("span",{className:"flex items-center gap-1",children:[c>0&&e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",className:"text-gray-500",children:e.jsx("path",{d:"M4.5 3L7.5 6L4.5 9",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),g?e.jsx("span",{className:"text-white font-medium",children:a.name}):e.jsx("button",{onClick:()=>s(a.componentName),className:"text-gray-400 hover:text-white transition-colors cursor-pointer",children:a.name})]},a.componentName||"app")})})}const Yt=[{key:"app",label:"App"},{key:"build",label:"Build"},{key:"data",label:"Structure"},{key:"journal",label:"Journal"}];function Kt({activeTab:t,onTabChange:s,buildIdle:a,zoomComponent:c,breadcrumbItems:g,onBreadcrumbNavigate:d}){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:Mt,alt:"CodeYam",className:"h-5 brightness-0 invert"}),e.jsx("span",{className:"text-white font-medium text-xs whitespace-nowrap",children:"Codeyam Editor"}),c&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-px h-3.5 bg-gray-600"}),e.jsx(Jt,{items:g,onNavigate:d})]})]}),e.jsx("div",{className:"flex-1"}),e.jsx("div",{className:"flex items-center gap-0.5 bg-[#4a3232] rounded-lg p-0.5 shrink-0",children:Yt.map(o=>e.jsxs("button",{onClick:()=>s(o.key),className:`px-2.5 py-1 text-xs font-medium rounded-md transition-colors cursor-pointer ${t===o.key?"bg-[#7a4444] text-white":"text-gray-300 hover:text-white"}`,children:[o.label,o.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"})]},o.key))})]})}function qt({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(Qt,{commitSha:t.commitSha,onLoadCommit:a})})]})}function Qt({commitSha:t,onLoadCommit:s}){const[a,c]=n.useState(!1),[g,d]=n.useState(null);return e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>{c(!0),d(null),s(t).then(o=>{o.success||d(o.error||"Failed to load commit")}).catch(o=>{d(o instanceof Error?o.message:"Network error")}).finally(()=>c(!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"}),g&&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:g})]})}function Xt({analysisId:t,scenarioId:s,scenarioName:a,entityName:c,projectSlug:g,onStateChange:d}){const{interactiveServerUrl:o,isStarting:h,isLoading:m}=Pt({analysisId:t,scenarioId:s,scenarioName:a,entityName:c,projectSlug:g,enabled:!0});return n.useEffect(()=>{d(o,h||m)},[o,h,m,d]),null}function Zt(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 es(){const[t,s]=n.useState({url:null,proxyUrl:null,isStarting:!1,error:null,canStartServer:!0,autoStartAttempted:!1}),a=n.useRef(t);a.current=t,n.useEffect(()=>{let d=!1,o=null;const h=async()=>{try{const m=await fetch("/api/editor-dev-server");if(d)return;const S=await m.json(),y=Zt(a.current,S),{shouldAutoStart:w,...v}=y;if(s(v),w)try{const M=await fetch("/api/editor-dev-server",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"start"})});if(d)return;M.ok?s(j=>({...j,isStarting:!0})):s(j=>({...j,canStartServer:!1}))}catch{}}catch{}};return h(),o=setInterval(()=>void h(),2e3),()=>{d=!0,o&&clearInterval(o)}},[t.url]);const c=n.useCallback(()=>{s(d=>({...d,error:null,isStarting:!0})),fetch("/api/editor-dev-server",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"restart"})}).catch(()=>{})},[]),g=n.useCallback(()=>{s(d=>({...d,error:null,isStarting:!0})),fetch("/api/editor-dev-server",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"start"})}).catch(()=>{})},[]);return{devServerUrl:t.url,proxyUrl:t.proxyUrl,isStarting:t.isStarting,error:t.error,canStartServer:t.canStartServer,retryServer:c,startServer:g}}const ps=()=>[{title:"Editor - CodeYam"},{name:"description",content:"CodeYam Code + Data Editor"}];class ts extends n.Component{constructor(){super(...arguments);Le(this,"state",{error:null,errorInfo:null})}static getDerivedStateFromError(a){return{error:a,errorInfo:null}}componentDidCatch(a,c){console.error("[EditorErrorBoundary] Error:",a.message),console.error("[EditorErrorBoundary] Component stack:",c.componentStack),console.error("[EditorErrorBoundary] Loader snapshot:",JSON.stringify(this.props.loaderSnapshot,null,2)),this.setState({errorInfo:c})}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 be=[{name:"Desktop",width:1440,height:900},{name:"Laptop",width:1024,height:768},{name:"Tablet",width:768,height:1024},{name:"Mobile",width:375,height:667}],hs=ut(function(){const{projectSlug:s,projectRoot:a,hasProject:c,scenarios:g,allScenarios:d,analyzedEntities:o,glossaryFunctions:h,entityImports:m,pageFilePaths:S,entityChangeStatus:y,modifiedFiles:w,featureName:v,userPrompt:M,projectTitle:j,projectDescription:A,defaultScreenSize:B}=ft(),[P,R]=gt(),I=n.useRef(null),T=n.useRef(null),F=n.useRef(null),p=P.get("zoom")||void 0,r=P.get("scenario")||void 0,x=n.useRef(null);n.useEffect(()=>{if(!Nt(r,x.current))return;const l=d.find(C=>C.id===r);if(!l)return;x.current=r;const k=ie(l.name);fetch("/api/editor-switch-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioSlug:k,scenarioId:l.id,scenarioName:l.name,scenarioType:l.type})}).catch(()=>{})},[r,d]),n.useEffect(()=>{const l=new BroadcastChannel("codeyam-editor");return l.onmessage=k=>{var C;if(((C=k.data)==null?void 0:C.type)==="switch-scenario"&&k.data.scenarioId){const $=k.data.scenarioId,z=d.find(ge=>ge.id===$);if(!z)return;x.current=$;const fe=new URLSearchParams(P);fe.set("scenario",$),fe.delete("zoom"),R(fe),q(null),L(null),H(null),V(!0);const mt=ie(z.name);fetch("/api/editor-switch-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioSlug:mt,scenarioId:$,scenarioType:z.type})}).then(()=>{Q(ge=>ge+1)}).catch(()=>{V(!1)})}},()=>l.close()},[P,R,d]),n.useEffect(()=>{if(P.get("ref")!=="link"||!r)return;const l=new BroadcastChannel("codeyam-editor");l.postMessage({type:"switch-scenario",scenarioId:r}),l.close(),window.close()},[]);const{devServerUrl:u,proxyUrl:f,isStarting:i,error:N,canStartServer:E,retryServer:U,startServer:ae}=es(),[K,W]=n.useState(!1),[D,q]=n.useState(null),[b,L]=n.useState(null),[O,we]=n.useState(!1),[oe,H]=n.useState(null),Ve=n.useCallback(async l=>{const C=await(await fetch("/api/editor-load-commit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({commitSha:l})})).json();return C.success&&(H(null),W(!1)),C},[]),Je=n.useCallback((l,k)=>{L(C=>(l&&l!==C&&W(!1),l)),!k&&l&&W(!0),we(k)},[]),Se=n.useCallback(l=>{H(null),q(C=>(C&&C.analysisId===l.analysisId||(L(null),Q(z=>z+1)),l)),we(!0),W(!1);const k=new URLSearchParams(P);k.delete("scenario"),k.delete("zoom"),R(k)},[P,R]),[_,re]=n.useState(B?{name:B.name,width:B.width,height:B.height}:{name:"Desktop",width:1440,height:900}),[Ye,ce]=n.useState(!1),[G,de]=n.useState("app"),Ke=n.useCallback(()=>{de("build"),xe(!0)},[]),[qe,xe]=n.useState(!1),[Qe,ke]=n.useState(!1),Xe=n.useCallback(l=>{ke(l)},[]),[me,Ce]=n.useState(!1),Ze=n.useCallback(()=>{Ce(!0),de("build"),xe(!0)},[]),Me=n.useCallback(()=>{Ce(!1)},[]),et=n.useCallback(l=>{re(l)},[]),[ne,pe]=n.useState(!1),tt=n.useCallback(()=>{if(ne){pe(!1);return}typeof Notification<"u"&&Notification.permission==="default"?Notification.requestPermission().then(l=>{l==="granted"&&pe(!0)}):pe(!0)},[ne]);n.useEffect(()=>{if(G==="build"){ke(!1);const l=setTimeout(()=>{var k,C;(k=I.current)==null||k.scrollToBottom(),(C=I.current)==null||C.focus()},50);return()=>clearTimeout(l)}},[G]);const[he,st]=n.useState(null);n.useEffect(()=>{const l=F.current;if(!l)return;const k=new ResizeObserver(C=>{const $=C[0];$&&st({width:$.contentRect.width,height:$.contentRect.height})});return k.observe(l),()=>k.disconnect()},[]);const Y=n.useMemo(()=>he?vt(he,_):1,[he,_]),[at,Q]=n.useState(0),[Pe,Ee]=n.useState(null),[Ie,V]=n.useState(!1),rt=n.useCallback((l,k)=>{if(Ee(l||null),k){const C=new URLSearchParams(P);C.set("scenario",k),x.current=k,R(C)}H(null),Q(C=>C+1)},[P,R]),{customSizes:Te,addCustomSize:nt}=jt(s);n.useMemo(()=>[...be,...Te],[Te]);const it=n.useMemo(()=>{const l=[{name:"App"}];return p&&l.push({name:p,componentName:p}),l},[p]),ue=n.useCallback(l=>{const k=new URLSearchParams(P);if(l){k.set("zoom",l);const C=d.find($=>$.componentName===l||$.componentName===null&&l==="Home");if(C){k.set("scenario",C.id),x.current=C.id,V(!0);const $=ie(C.name);fetch("/api/editor-switch-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioSlug:$,scenarioId:C.id,scenarioType:C.type})}).then(()=>{Q(z=>z+1)}).catch(()=>{V(!1)})}else k.delete("scenario")}else k.delete("zoom"),k.delete("scenario");R(k)},[P,R,d]),X=n.useCallback(l=>{if(q(null),L(null),H(null),l.viewportWidth&&l.viewportHeight){const $=be.find(z=>z.width===l.viewportWidth&&z.height===l.viewportHeight);re({name:($==null?void 0:$.name)||"Custom",width:l.viewportWidth,height:l.viewportHeight})}x.current=l.id;const k=new URLSearchParams(P);k.set("scenario",l.id),R(k),V(!0);const C=ie(l.name);fetch("/api/editor-switch-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioSlug:C,scenarioId:l.id,scenarioType:l.type})}).then(()=>{Q($=>$+1)}).catch(()=>{V(!1)})},[P,R]),lt=n.useCallback(l=>{if(!l.commitSha){const k=d.find(C=>C.name===l.scenarioName);if(k){X(k);return}}H(l)},[d,X]),ot=l=>{re({name:l.name,width:l.width,height:l.height})},ct=l=>{nt(l,_.width,_.height??900),ce(!1),re(k=>({...k,name:l}))},dt=()=>{D||W(!0),V(!1)},Z=n.useMemo(()=>yt({activeAnalyzedScenario:!!D,analyzedPreviewUrl:b,activeScenarioId:r||null,scenarios:d,proxyUrl:f,devServerUrl:u,zoomComponent:p||null}),[f,u,p,r,d,D,b]),Re=n.useMemo(()=>wt(Z,Pe),[Z,Pe]),xt=n.useMemo(()=>({projectSlug:s,hasProject:c,scenarioCount:g==null?void 0:g.length,allScenarioCount:d==null?void 0:d.length,analyzedEntityCount:o==null?void 0:o.length,glossaryFunctionCount:h==null?void 0:h.length,entityChangeStatusKeys:y?Object.keys(y):[],featureName:v}),[s,c,g,d,o,h,y,v]);return e.jsx(ts,{loaderSnapshot:xt,children:e.jsxs("div",{className:"fixed inset-0 bg-[#2d2d2d] flex flex-col",children:[D&&e.jsx(Xt,{analysisId:D.analysisId,scenarioId:D.scenarioId,scenarioName:D.scenarioName,entityName:D.entityName,projectSlug:s,onStateChange:Je},D.analysisId),e.jsxs("div",{className:"flex-1 flex min-h-0",children:[e.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[e.jsx("div",{className:"bg-[#2d2d2d] border-b border-[#3d3d3d] shrink-0 z-10 h-10 flex items-center px-4 gap-1",children:e.jsxs("div",{className:"flex-1 flex items-center justify-center gap-1",children:[be.map(l=>e.jsxs("button",{onClick:()=>ot(l),className:`p-1.5 rounded transition-colors cursor-pointer ${_.name===l.name?"text-white bg-[#555]":"text-gray-500 hover:text-gray-300"}`,title:`${l.name} (${l.width}×${l.height})`,children:[l.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"})]}),l.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"})]}),l.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"})]}),l.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"})]})]},l.name)),e.jsx("button",{onClick:()=>ce(!0),className:`p-1.5 rounded transition-colors cursor-pointer ${_.name==="Custom"?"text-white bg-[#555]":"text-gray-500 hover:text-gray-300"}`,title:"Custom dimensions",children:e.jsx("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:"M17 3a2.83 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"})})}),e.jsx("div",{className:"w-px h-4 bg-[#3d3d3d] mx-1"}),e.jsxs("span",{className:"text-gray-400 text-xs font-mono",children:[_.width," × ",_.height??900]}),e.jsx("div",{className:"w-px h-4 bg-[#3d3d3d] mx-1"}),e.jsx("button",{onClick:()=>{const l=Re||Z;l&&window.open(l,"_blank")},className:"p-1.5 rounded text-gray-500 hover:text-gray-300 transition-colors cursor-pointer",title:"Open preview in new window",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),e.jsx("polyline",{points:"15 3 21 3 21 9"}),e.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]})})]})}),e.jsx("div",{ref:F,className:"flex-1 flex items-center justify-center overflow-hidden p-8",style:oe?{backgroundColor:"#f5f0e8",backgroundImage:"repeating-linear-gradient(0deg, transparent, transparent 19px, #e8e0d0 19px, #e8e0d0 20px), repeating-linear-gradient(90deg, transparent, transparent 19px, #e8e0d0 19px, #e8e0d0 20px)"}:{backgroundImage:`
|
|
6
|
-
linear-gradient(45deg, #333 25%, transparent 25%),
|
|
7
|
-
linear-gradient(-45deg, #333 25%, transparent 25%),
|
|
8
|
-
linear-gradient(45deg, transparent 75%, #333 75%),
|
|
9
|
-
linear-gradient(-45deg, transparent 75%, #333 75%)
|
|
10
|
-
`,backgroundSize:"16px 16px",backgroundPosition:"0 0, 0 8px, 8px -8px, -8px 0px",backgroundColor:"#2d2d2d"},children:oe?e.jsx(qt,{preview:oe,onDismiss:()=>H(null),onLoadCommit:Ve}):Z?e.jsx("div",{style:{width:`${_.width*Y}px`,height:`${(_.height??900)*Y}px`},children:e.jsxs("div",{className:"relative bg-white origin-top-left",style:{width:`${_.width}px`,height:`${_.height??900}px`,transform:Y<1?`scale(${Y})`:void 0},children:[!K&&!Ie&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-10",children:e.jsxs("div",{className:"flex flex-col items-center justify-center gap-6 bg-[#2a2a2a] rounded-lg p-8 w-[500px] h-[300px]",children:[e.jsx("div",{className:"mb-4",children:e.jsx($e,{})}),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"})]})]})}),Ie&&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:T,src:Re||Z,className:"w-full h-full border-none",title:"Editor preview",onLoad:dt,style:{opacity:K?1:0}},at)]})}):e.jsx("div",{className:"bg-[#2a2a2a] rounded-lg flex flex-col items-center justify-center",style:{width:`${_.width*Y}px`,height:`${(_.height??900)*Y}px`},children:N?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:N}),e.jsx("button",{onClick:U,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"})]}):i||O?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mb-4",children:e.jsx($e,{})}),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:O?"Starting Interactive Mode":"Starting Dev Server"}),e.jsx("p",{className:"text-sm text-gray-400 leading-5 m-0 font-['IBM_Plex_Sans']",children:O?"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:"w-[50%] min-w-[400px] max-w-[800px] bg-[#1e1e1e] border-r border-[#3d3d3d] shrink-0 flex flex-col overflow-hidden order-first",children:[e.jsx(Kt,{activeTab:G,onTabChange:l=>{de(l),l==="build"&&xe(!0)},buildIdle:Qe,zoomComponent:p,breadcrumbItems:it,onBreadcrumbNavigate:ue}),e.jsxs("div",{className:"flex-1 overflow-hidden relative",children:[qe&&e.jsxs("div",{className:"absolute inset-0 flex flex-col overflow-hidden",style:{visibility:G==="build"?"visible":"hidden"},children:[e.jsx("div",{className:me?"flex-1 min-h-0":"flex-1",style:me?{flex:"1 1 50%"}:void 0,children:e.jsx(St,{ref:I,entityName:"Editor",projectSlug:s,entityFilePath:null,scenarioName:null,onRefreshPreview:rt,onShowResults:Ze,onHideResults:Me,onSetViewport:et,editorMode:!0,onIdleChange:Xe,notificationsEnabled:ne})}),me&&e.jsx("div",{style:{flex:"1 1 50%"},className:"min-h-0 border-t-2 border-gray-300",children:e.jsx(Vt,{scenarios:g,allScenarios:d,glossaryFunctions:h,projectRoot:a,activeScenarioId:r,onScenarioSelect:X,onClose:Me,entityChangeStatus:y,modifiedFiles:w,featureName:v,userPrompt:M})})]}),e.jsx("div",{className:"absolute inset-0 flex flex-col overflow-hidden",style:{visibility:G==="app"?"visible":"hidden"},children:e.jsx(Wt,{hasProject:c,scenarios:d,analyzedEntities:o,glossaryFunctions:h,projectRoot:a,activeScenarioId:r,onScenarioSelect:X,onAnalyzedScenarioSelect:Se,onSwitchToBuild:Ke,zoomComponent:p,onZoomChange:ue,entityImports:m,pageFilePaths:S,projectTitle:j,projectDescription:A})}),e.jsx("div",{className:"absolute inset-0 flex flex-col overflow-hidden",style:{visibility:G==="data"?"visible":"hidden"},children:e.jsx(It,{scenarios:d,projectRoot:a,activeScenarioId:r,onScenarioSelect:X,zoomComponent:p,onZoomChange:ue,analyzedEntities:[],glossaryFunctions:h,activeAnalyzedScenarioId:D==null?void 0:D.scenarioId,onAnalyzedScenarioSelect:Se,entityImports:m,pageFilePaths:S})}),e.jsx("div",{className:"absolute inset-0 flex flex-col overflow-hidden",style:{visibility:G==="journal"?"visible":"hidden"},children:e.jsx(Ut,{isActive:G==="journal",onScreenshotClick:lt,glossaryFunctions:h})})]}),e.jsx(kt,{serverUrl:u,isStarting:i,projectSlug:s,devServerError:N,onStartServer:E?ae:void 0,notificationsEnabled:ne,onToggleNotifications:tt})]})]}),Ye&&e.jsx(bt,{width:_.width,height:_.height??900,onSave:ct,onCancel:()=>ce(!1)})]})})});export{hs as default,ps as meta};
|