@codeyam/codeyam-cli 0.1.9 → 0.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/analyzer-template/.build-info.json +8 -8
  2. package/analyzer-template/log.txt +3 -3
  3. package/analyzer-template/packages/database/src/lib/kysely/tables/editorScenariosTable.ts +45 -0
  4. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.d.ts +2 -0
  5. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.d.ts.map +1 -1
  6. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.js +45 -0
  7. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.js.map +1 -1
  8. package/codeyam-cli/src/commands/editor.js +236 -76
  9. package/codeyam-cli/src/commands/editor.js.map +1 -1
  10. package/codeyam-cli/src/commands/init.js +1 -0
  11. package/codeyam-cli/src/commands/init.js.map +1 -1
  12. package/codeyam-cli/src/utils/__tests__/analyzerFinalization.test.js +29 -0
  13. package/codeyam-cli/src/utils/__tests__/analyzerFinalization.test.js.map +1 -1
  14. package/codeyam-cli/src/utils/__tests__/editorApi.test.js +18 -8
  15. package/codeyam-cli/src/utils/__tests__/editorApi.test.js.map +1 -1
  16. package/codeyam-cli/src/utils/__tests__/editorAudit.test.js +133 -1
  17. package/codeyam-cli/src/utils/__tests__/editorAudit.test.js.map +1 -1
  18. package/codeyam-cli/src/utils/__tests__/editorPreview.test.js +14 -0
  19. package/codeyam-cli/src/utils/__tests__/editorPreview.test.js.map +1 -1
  20. package/codeyam-cli/src/utils/__tests__/editorScenarios.test.js +205 -1
  21. package/codeyam-cli/src/utils/__tests__/editorScenarios.test.js.map +1 -1
  22. package/codeyam-cli/src/utils/__tests__/entityChangeStatus.test.js +58 -1
  23. package/codeyam-cli/src/utils/__tests__/entityChangeStatus.test.js.map +1 -1
  24. package/codeyam-cli/src/utils/__tests__/parseRegisterArg.test.js +30 -2
  25. package/codeyam-cli/src/utils/__tests__/parseRegisterArg.test.js.map +1 -1
  26. package/codeyam-cli/src/utils/__tests__/scenariosManifest.test.js +155 -1
  27. package/codeyam-cli/src/utils/__tests__/scenariosManifest.test.js.map +1 -1
  28. package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js +1 -0
  29. package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js.map +1 -1
  30. package/codeyam-cli/src/utils/analyzerFinalization.js +5 -1
  31. package/codeyam-cli/src/utils/analyzerFinalization.js.map +1 -1
  32. package/codeyam-cli/src/utils/editorApi.js +11 -5
  33. package/codeyam-cli/src/utils/editorApi.js.map +1 -1
  34. package/codeyam-cli/src/utils/editorAudit.js +34 -0
  35. package/codeyam-cli/src/utils/editorAudit.js.map +1 -1
  36. package/codeyam-cli/src/utils/editorPreview.js +9 -4
  37. package/codeyam-cli/src/utils/editorPreview.js.map +1 -1
  38. package/codeyam-cli/src/utils/editorScenarios.js +64 -9
  39. package/codeyam-cli/src/utils/editorScenarios.js.map +1 -1
  40. package/codeyam-cli/src/utils/entityChangeStatus.server.js +34 -0
  41. package/codeyam-cli/src/utils/entityChangeStatus.server.js.map +1 -1
  42. package/codeyam-cli/src/utils/parseRegisterArg.js.map +1 -1
  43. package/codeyam-cli/src/utils/progress.js +2 -2
  44. package/codeyam-cli/src/utils/progress.js.map +1 -1
  45. package/codeyam-cli/src/utils/scenariosManifest.js +82 -0
  46. package/codeyam-cli/src/utils/scenariosManifest.js.map +1 -1
  47. package/codeyam-cli/src/utils/setupClaudeCodeSettings.js +1 -0
  48. package/codeyam-cli/src/utils/setupClaudeCodeSettings.js.map +1 -1
  49. package/codeyam-cli/src/webserver/__tests__/idleDetector.test.js +146 -0
  50. package/codeyam-cli/src/webserver/__tests__/idleDetector.test.js.map +1 -0
  51. package/codeyam-cli/src/webserver/build/client/assets/{ScenarioViewer-Bd-hxofb.js → ScenarioViewer-TSD3C211.js} +1 -1
  52. package/codeyam-cli/src/webserver/build/client/assets/api.editor-session-l0sNRNKZ.js +1 -0
  53. package/codeyam-cli/src/webserver/build/client/assets/{dev.empty-BsDh6TSF.js → dev.empty-Ii3inc0_.js} +1 -1
  54. package/codeyam-cli/src/webserver/build/client/assets/editor-16o0AIFV.js +15 -0
  55. package/codeyam-cli/src/webserver/build/client/assets/editorPreview-7Uga8I59.js +41 -0
  56. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha._-BsDXNp45.js → entity._sha._-DwCV5__E.js} +1 -1
  57. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha.scenarios._scenarioId.dev-BgAqUtTZ.js → entity._sha.scenarios._scenarioId.dev-BwKcai0j.js} +1 -1
  58. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha.scenarios._scenarioId.fullscreen-Bmshgrij.js → entity._sha.scenarios._scenarioId.fullscreen-CHMiAog3.js} +1 -1
  59. package/codeyam-cli/src/webserver/build/client/assets/globals-CQPR0pFR.css +1 -0
  60. package/codeyam-cli/src/webserver/build/client/assets/{manifest-65850841.js → manifest-76e7b62c.js} +1 -1
  61. package/codeyam-cli/src/webserver/build/client/assets/{root-BwX8YgFb.js → root-DBjt6o04.js} +4 -4
  62. package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-C-_hOl_g.js +1 -0
  63. package/codeyam-cli/src/webserver/build/client/sound-test.html +98 -0
  64. package/codeyam-cli/src/webserver/build/server/assets/{index-DEEQf4pi.js → index-DsZjKspK.js} +1 -1
  65. package/codeyam-cli/src/webserver/build/server/assets/init-DdqKD2p4.js +10 -0
  66. package/codeyam-cli/src/webserver/build/server/assets/server-build-CKKeWtVK.js +444 -0
  67. package/codeyam-cli/src/webserver/build/server/index.js +1 -1
  68. package/codeyam-cli/src/webserver/build-info.json +5 -5
  69. package/codeyam-cli/src/webserver/idleDetector.js +73 -0
  70. package/codeyam-cli/src/webserver/idleDetector.js.map +1 -0
  71. package/codeyam-cli/src/webserver/public/sound-test.html +98 -0
  72. package/codeyam-cli/src/webserver/server.js +46 -4
  73. package/codeyam-cli/src/webserver/server.js.map +1 -1
  74. package/codeyam-cli/src/webserver/terminalServer.js +65 -26
  75. package/codeyam-cli/src/webserver/terminalServer.js.map +1 -1
  76. package/codeyam-cli/templates/codeyam-editor-claude.md +1 -1
  77. package/codeyam-cli/templates/editor-step-hook.py +3 -2
  78. package/codeyam-cli/templates/skills/codeyam-editor/SKILL.md +10 -9
  79. package/package.json +1 -1
  80. package/packages/database/src/lib/kysely/tables/editorScenariosTable.js +45 -0
  81. package/packages/database/src/lib/kysely/tables/editorScenariosTable.js.map +1 -1
  82. package/codeyam-cli/src/webserver/build/client/assets/editor-PBc_6L9R.js +0 -10
  83. package/codeyam-cli/src/webserver/build/client/assets/editorPreview-4FzHlcNn.js +0 -41
  84. package/codeyam-cli/src/webserver/build/client/assets/globals-B8vTTNy2.css +0 -1
  85. package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-BE43Hjti.js +0 -1
  86. package/codeyam-cli/src/webserver/build/server/assets/init-CkWmyFY2.js +0 -10
  87. package/codeyam-cli/src/webserver/build/server/assets/server-build-BHi-9O8W.js +0 -439
@@ -32,7 +32,7 @@ A **scenario** is a named set of data that drives how the app renders. Scenarios
32
32
 
33
33
  ```bash
34
34
  # Small inline JSON:
35
- codeyam editor register '{"name":"TaskCard - Default","componentName":"TaskCard","url":"/isolated-components/TaskCard?s=Default"}'
35
+ codeyam editor register '{"name":"TaskCard - Default","componentName":"TaskCard","url":"/isolated-components/TaskCard?s=Default","dimensions":["<name from screenSizes>"]}'
36
36
 
37
37
  # Large JSON — use the Write tool to write to .codeyam/tmp/scenario.json, then:
38
38
  codeyam editor register @.codeyam/tmp/scenario.json
@@ -94,11 +94,12 @@ def main():
94
94
  # Detect event early so we can capture the user prompt even before state exists
95
95
  event_type, event_data = detect_event()
96
96
 
97
- # Capture the very first user prompt (before state file may exist).
97
+ # Capture the very first real user prompt (before state file may exist).
98
98
  # Save to a separate file so it persists across state transitions.
99
+ # Skip slash commands (e.g. /codeyam-editor) — they aren't user prompts.
99
100
  if event_type == "user_prompt" and not os.path.exists(prompt_path):
100
101
  prompt_text = event_data.get("prompt", "").strip()
101
- if prompt_text:
102
+ if prompt_text and not prompt_text.startswith("/"):
102
103
  try:
103
104
  os.makedirs(os.path.dirname(prompt_path), exist_ok=True)
104
105
  with open(prompt_path, "w") as f:
@@ -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,13 +105,14 @@ 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
- codeyam editor register '{"name":"DrinkCard - Default","componentName":"DrinkCard","componentPath":"app/components/DrinkCard.tsx","url":"/isolated-components/DrinkCard?s=Default","mockData":{"routes":{"/api/...":{"body":[...]}}}}'
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" the page to screenshot)
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)
114
- codeyam editor register '{"name":"Full Library","type":"application","url":"/","localStorage":{"articles":[...],"collections":[...]}}'
115
+ codeyam editor register '{"name":"Full Library","type":"application","url":"/","dimensions":["<name from screenSizes>"],"localStorage":{"articles":[...],"collections":[...]}}'
115
116
 
116
117
  # For large seed/localStorage data, write JSON to a temp file and use @ prefix:
117
118
  codeyam editor register @/tmp/scenario-data.json
@@ -122,9 +123,9 @@ codeyam editor journal '{"title":"...","type":"feature","description":"..."}'
122
123
  # Update journal with commit info
123
124
  codeyam editor journal-update '{"time":"...","commitSha":"...","commitMessage":"..."}'
124
125
 
125
- # Refresh preview / navigate / switch scenario
126
- codeyam editor preview
127
- 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>"}'
128
129
  codeyam editor preview '{"scenarioId":"abc-123"}'
129
130
 
130
131
  # Show/hide results panel
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codeyam/codeyam-cli",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "description": "Local development CLI for CodeYam analysis",
5
5
  "type": "module",
6
6
  "bin": {
@@ -12,6 +12,8 @@ const editorScenariosSchema = {
12
12
  viewport_width: schemaField(),
13
13
  viewport_height: schemaField(),
14
14
  dimension: schemaField(),
15
+ dimensions: schemaField(),
16
+ screenshot_paths: schemaField(),
15
17
  created_at: schemaField(),
16
18
  updated_at: schemaField(),
17
19
  };
@@ -72,5 +74,48 @@ export async function createEditorScenariosTable(db) {
72
74
  catch {
73
75
  // Column already exists — expected for fresh databases
74
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
+ }
75
120
  }
76
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":"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"}
1
+ {"version":3,"file":"editorScenariosTable.js","sourceRoot":"","sources":["../../../../../../../../packages/database/src/lib/kysely/tables/editorScenariosTable.ts"],"names":[],"mappings":"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"}
@@ -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 kt=Object.defineProperty;var Ct=(t,s,a)=>s in t?kt(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a;var He=(t,s,a)=>Ct(t,typeof s!="symbol"?s+"":s,a);import{r,j as e,w as Pt,u as Mt,b as It}from"./chunk-JZWAC4HX-C4pqxYJB.js";import{u as Et,C as $t}from"./useCustomSizes-BE43Hjti.js";import{g as Rt,s as Tt,r as Je,b as xe,c as Lt,d as Bt,a as At,T as _t,D as Dt}from"./editorPreview-4FzHlcNn.js";import{C as Me}from"./CopyButton-BPXZwM4t.js";import{_ as Ot}from"./preload-helper-ckwbz45p.js";import{c as Ut}from"./cy-logo-cli-DcX-ZS3p.js";import{u as Ft,S as Ge}from"./Spinner-Bb5uFQ5V.js";import"./copy-n2FB0_Sw.js";import"./createLucideIcon-CC6AbExI.js";import"./useLastLogLine-C14nCb1q.js";function Ie(t){const[s,a]=r.useState(null),[x,g]=r.useState(!1),d=r.useCallback(()=>{t&&(g(!0),fetch(`/api/editor-test-results?testFile=${encodeURIComponent(t)}`).then(m=>m.json()).then(m=>{a(m),g(!1)}).catch(()=>{a({testFilePath:t,status:"error",testCases:[],errorMessage:"Failed to fetch test results"}),g(!1)}))},[t]);return r.useEffect(()=>{t&&d()},[t,d]),{results:s,isRunning:x,runTests:d}}function X(t){if(!t||t==="/")return"Home";const s=t.split("?")[0].replace(/^\//,"");if(!s)return"Home";const a=s.split("/")[0];return a.charAt(0).toUpperCase()+a.slice(1)}function Ee(t){return t?t.includes("/isolated-components"):!1}function zt(t,s){return!s||Object.keys(s).length===0?t:t.filter(a=>s[a.name])}function ae({imgSrc:t,name:s,isActive:a,onSelect:x}){return e.jsxs("button",{onClick:x,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 Ce({testFile:t,entityName:s}){const{results:a,isRunning:x,runTests:g}=Ie(t);if(x&&!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(h=>h.fullName.startsWith(s)):a.testCases,m=d.length>0?d:a.testCases;if(m.length===0)return null;const p=s?`${s} > `:"";return e.jsxs("div",{className:"px-2 pt-1 space-y-0.5",children:[m.map(h=>{var S;const C=p&&h.fullName.startsWith(p)?h.fullName.slice(p.length):h.fullName;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[h.status==="passed"?e.jsx("span",{className:"text-green-400 text-[10px]",children:"✓"}):h.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] ${h.status==="passed"?"text-green-400":h.status==="failed"?"text-red-400":"text-gray-500"}`,children:C})]}),h.status==="failed"&&((S=h.failureMessages)==null?void 0:S.map((N,w)=>e.jsx("div",{className:"pl-4 text-[9px] text-red-300/70 truncate max-w-full",title:N,children:N.split(`
3
- `)[0]},w)))]},h.fullName)}),e.jsx("button",{onClick:g,disabled:x,className:"mt-1 text-[10px] text-[#00a0c4] hover:text-[#00c4ee] transition-colors cursor-pointer disabled:opacity-50 bg-transparent border-none p-0",children:x?"Running...":"Re-run"})]})}function Y({filePath:t}){return t?e.jsxs("div",{className:"flex items-center gap-1 px-2 mt-0.5",children:[e.jsxs("a",{href:`/api/editor-file?path=${encodeURIComponent(t)}`,target:"_blank",rel:"noopener noreferrer",title:"Open file",className:"flex items-center gap-1 text-gray-500 hover:text-gray-300 transition-colors min-w-0",children:[e.jsx("span",{className:"text-[9px] truncate",children:t}),e.jsx("svg",{className:"shrink-0",width:"10",height:"10",viewBox:"0 0 12 12",fill:"none",children:e.jsx("path",{d:"M4.5 1.5H2.5C1.95 1.5 1.5 1.95 1.5 2.5V9.5C1.5 10.05 1.95 10.5 2.5 10.5H9.5C10.05 10.5 10.5 10.05 10.5 9.5V7.5M7.5 1.5H10.5M10.5 1.5V4.5M10.5 1.5L5 7",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})})]}),e.jsx(Me,{content:t,icon:!0,iconSize:10,className:"shrink-0 text-gray-500 hover:text-gray-300 transition-colors"})]}):null}function Wt({scenarios:t,projectRoot:s,activeScenarioId:a,onScenarioSelect:x,zoomComponent:g,onZoomChange:d,analyzedEntities:m=[],glossaryFunctions:p=[],activeAnalyzedScenarioId:h,onAnalyzedScenarioSelect:C,entityImports:S,pageFilePaths:N={}}){const{pageGroups:w,componentGroups:E}=r.useMemo(()=>{var o;const u=new Map,i=new Map;for(const c of t)if(c.componentName){const l=i.get(c.componentName)||[];l.push(c),i.set(c.componentName,l)}else if(Ee(c.url)){const l=(o=c.url)==null?void 0:o.match(/[?&]c=([^&]+)/),y=l?decodeURIComponent(l[1]):"Isolated",k=i.get(y)||[];k.push(c),i.set(y,k)}else{const l=X(c.url),y=u.get(l)||[];y.push(c),u.set(l,y)}const j=new Map([...i.entries()].sort(([c],[l])=>c.localeCompare(l)));return{pageGroups:u,componentGroups:j}},[t]),v=r.useMemo(()=>{const u=new Set((m||[]).filter(j=>j.entityType==="visual").map(j=>j.name)),i=new Map;for(const[j,o]of E)u.has(j)||i.set(j,o);return i},[E,m]),{visualEntities:A,libraryEntities:D}=r.useMemo(()=>{const u=m.filter(j=>j.entityType==="visual").sort((j,o)=>j.name.localeCompare(o.name)),i=m.filter(j=>j.entityType==="library"||j.entityType==="functionCall").sort((j,o)=>j.name.localeCompare(o.name));return{visualEntities:u,libraryEntities:i}},[m]),R=r.useMemo(()=>{const u=new Set(D.map(i=>i.name));return p.filter(i=>!u.has(i.name)).sort((i,j)=>i.name.localeCompare(j.name))},[p,D]),O=m.some(u=>u.isAnalyzing),M=r.useRef(null),I=r.useRef(0),B=r.useCallback(()=>{M.current&&(I.current=M.current.scrollTop)},[]);if(r.useEffect(()=>{M.current&&I.current>0&&(M.current.scrollTop=I.current)}),t.length===0&&m.length===0&&R.length===0)return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center text-gray-500 px-8",children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"No scenarios yet"}),e.jsx("p",{className:"text-xs",children:"Scenarios will appear here as Claude creates them alongside your code. Each scenario represents a different state of your app's data."})]})});if(g){const u=E.get(g)||[],i=new Set((S==null?void 0:S[g])||[]),j=i.size>0,o=j?A.filter(l=>i.has(l.name)):[],c=j?D.filter(l=>i.has(l.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:u.length===0?e.jsx("div",{className:"px-3 py-2 text-xs text-gray-500",children:"No scenarios for this component"}):u.map(l=>e.jsx(ae,{imgSrc:l.screenshotPath?`/api/editor-scenario-image/${l.id}.png${l.updatedAt?`?v=${encodeURIComponent(l.updatedAt)}`:""}`:null,name:l.name,isActive:l.id===a,onSelect:()=>x(l)},l.id))}),o.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"})}),o.map(l=>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(l.name),className:"text-[11px] font-medium text-gray-400 truncate cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:l.name})}),e.jsx(Y,{filePath:l.filePath,projectRoot:s}),(l.scenarios.length>0||l.pendingScenarios.length>0)&&e.jsx("div",{className:"flex flex-wrap gap-2 px-2 pt-1",children:l.scenarios.map(y=>e.jsx(ae,{imgSrc:y.screenshotPath?`/api/screenshot/${y.screenshotPath}`:null,name:y.name,isActive:y.id===h,onSelect:()=>C==null?void 0:C({analysisId:l.analysisId,scenarioId:y.id,scenarioName:y.name,entitySha:l.sha,entityName:l.name})},y.id))})]},l.sha))]}),c.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"})}),c.map(l=>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:l.name})}),e.jsx(Y,{filePath:l.filePath,projectRoot:s}),l.testFile&&e.jsx(Ce,{testFile:l.testFile,entityName:l.name})]},l.sha))]})]})})}return e.jsx("div",{ref:M,onScroll:B,className:"flex-1 overflow-auto",children:e.jsxs("div",{className:"p-3 space-y-3",children:[w.size>0&&e.jsxs("div",{children:[e.jsx("div",{className:"px-2 py-1",children:e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Application"})}),[...w.entries()].sort(([u],[i])=>u==="Home"?-1:i==="Home"?1:u.localeCompare(i)).map(([u,i])=>e.jsxs("div",{className:"px-2 pt-1",children:[e.jsx("div",{className:"py-0.5",children:e.jsx("span",{className:"text-[11px] font-medium text-gray-400",children:u})}),N[u]&&e.jsx(Y,{filePath:N[u],projectRoot:s}),e.jsx("div",{className:"flex flex-wrap gap-2 pt-1",children:i.map(j=>e.jsx(ae,{imgSrc:j.screenshotPath?`/api/editor-scenario-image/${j.id}.png${j.updatedAt?`?v=${encodeURIComponent(j.updatedAt)}`:""}`:null,name:j.name,isActive:j.id===a&&!h,onSelect:()=>x(j)},j.id))})]},u))]}),v.size>0&&e.jsxs("div",{className:"pt-2 mt-1 border-t border-[#3d3d3d]",children:[e.jsx("div",{className:"px-2 py-1",children:e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Components"})}),[...v.entries()].map(([u,i])=>{var j;return e.jsxs("div",{className:"mt-2",children:[e.jsx("div",{className:"flex items-center justify-between px-2 py-1",children:e.jsx("button",{onClick:()=>d(u),className:"text-[11px] font-medium text-gray-400 truncate cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:u})}),((j=i[0])==null?void 0:j.componentPath)&&e.jsx(Y,{filePath:i[0].componentPath,projectRoot:s}),e.jsx("div",{className:"flex flex-wrap gap-2 px-2 pt-1",children:i.map(o=>e.jsx(ae,{imgSrc:o.screenshotPath?`/api/editor-scenario-image/${o.id}.png${o.updatedAt?`?v=${encodeURIComponent(o.updatedAt)}`:""}`:null,name:o.name,isActive:o.id===a&&!h,onSelect:()=>x(o)},o.id))})]},u)})]}),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"}),O&&t.length===0&&m.every(u=>u.scenarioCount===0)&&e.jsx("span",{className:"ml-2 text-[10px] text-gray-500",children:"— Entities are being analyzed..."})]}),A.map(u=>e.jsxs("div",{className:"mt-2",children:[e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1",children:[e.jsx("button",{onClick:()=>d(u.name),className:"text-[11px] font-medium text-gray-400 truncate cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:u.name}),u.isAnalyzing&&u.scenarioCount===0&&e.jsxs("span",{className:"flex items-center gap-1.5 text-[10px] text-gray-400",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[#005c75] animate-pulse"}),"Analyzing..."]})]}),e.jsx(Y,{filePath:u.filePath,projectRoot:s}),(u.scenarios.length>0||u.pendingScenarios.length>0)&&e.jsxs("div",{className:"flex flex-wrap gap-2 px-2 pt-1",children:[u.scenarios.map(i=>e.jsx(ae,{imgSrc:i.screenshotPath?`/api/screenshot/${i.screenshotPath}`:null,name:i.name,isActive:i.id===h,onSelect:()=>C==null?void 0:C({analysisId:u.analysisId,scenarioId:i.id,scenarioName:i.name,entitySha:u.sha,entityName:u.name})},i.id)),u.pendingScenarios.map(i=>e.jsx("div",{className:"px-2.5 py-1 bg-[#2a2a2a] text-gray-400 text-[10px] rounded-full",title:i,children:i},i))]})]},u.sha))]}),(D.length>0||R.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"})}),D.map(u=>e.jsxs("div",{className:"mt-2",children:[e.jsxs("div",{className:"px-2 py-1",children:[e.jsx("span",{className:"text-[11px] font-medium text-gray-300",children:u.name}),u.isAnalyzing&&u.scenarioCount===0&&e.jsxs("span",{className:"ml-2 inline-flex items-center gap-1.5 text-[10px] text-gray-400",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[#005c75] animate-pulse"}),"Analyzing..."]})]}),e.jsx(Y,{filePath:u.filePath,projectRoot:s}),u.testFile?e.jsx(Ce,{testFile:u.testFile,entityName:u.name}):e.jsx("div",{className:"px-2 pt-1",children:e.jsx("span",{className:"text-[10px] text-gray-500",children:"No test file"})})]},u.sha)),R.map(u=>e.jsxs("div",{className:"mt-2",children:[e.jsx("div",{className:"px-2 py-1",children:e.jsx("span",{className:"text-[11px] font-medium text-gray-300",children:u.name})}),e.jsx(Y,{filePath:u.filePath,projectRoot:s}),e.jsx(Ce,{testFile:u.testFile,entityName:u.name})]},u.name))]})]})})}function Ht(t,s,a=new Date){const x={"1d":1,"3d":3,"7d":7,"30d":30}[s],g=new Date(a);g.setDate(g.getDate()-x);const d=g.toISOString().split("T")[0],m=t.filter(N=>N.date>=d),p=new Set(m.map(N=>N.commitSha).filter(Boolean)),h=new Map;for(const N of m)if(N.scenarioScreenshots)for(const w of N.scenarioScreenshots){h.has(w.name)||h.set(w.name,[]);const E=h.get(w.name);E.some(v=>v.path===w.path)||E.push({path:w.path,time:N.time})}for(const N of h.values())N.sort((w,E)=>w.time.localeCompare(E.time));const C=[],S=new Map;for(const[N,w]of h){const E=N.indexOf(" - ");if(E!==-1){const v=N.slice(0,E);S.has(v)||S.set(v,[]),S.get(v).push({name:N,screenshots:w})}else C.push({name:N,screenshots:w})}return{commitCount:p.size,entryCount:m.length,appScenarios:C,componentGroups:S,totalScenarios:h.size}}function Jt(t){const s=new Map;for(const a of[...t].reverse()){const x=s.get(a.date)||[];x.push(a),s.set(a.date,x)}return s}function Gt(t){const s=new Map;for(const a of t){let x;if("componentName"in a&&a.componentName)x=a.componentName;else if("componentName"in a&&a.componentName===null)x="App";else{const d=a.name.indexOf(" - ");x=d!==-1?a.name.slice(0,d):"App"}const g=s.get(x)||[];g.push(a),s.set(x,g)}return[...s.entries()].sort(([a],[x])=>a==="App"?-1:x==="App"?1:a.localeCompare(x))}const Ve=120;function rt({text:t,theme:s}){const[a,x]=r.useState(!1),g=t.length>Ve,d=g&&!a?t.slice(0,Ve)+"…":t,m=s==="light";return e.jsxs("div",{className:`px-4 py-2 ${m?"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 ${m?"text-gray-600":"text-gray-400"}`,children:[d,g&&e.jsx("button",{onClick:()=>x(!a),className:`ml-1 text-[11px] font-medium bg-transparent border-none p-0 cursor-pointer ${m?"text-blue-500 hover:text-blue-700":"text-[#00a0c4] hover:text-[#00c0e8]"}`,children:a?"Show less":"Read more…"})]})]})}function Ye({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 Vt({testFile:t,entityName:s}){const{results:a,isRunning:x,runTests:g}=Ie(t);if(x&&!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(h=>h.fullName.startsWith(s)):a.testCases,m=d.length>0?d:a.testCases;if(m.length===0)return null;const p=s?`${s} > `:"";return e.jsxs("div",{className:"pt-1 space-y-0.5",children:[m.map(h=>{var S;const C=p&&h.fullName.startsWith(p)?h.fullName.slice(p.length):h.fullName;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[h.status==="passed"?e.jsx("span",{className:"text-green-400 text-[10px]",children:"✓"}):h.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] ${h.status==="passed"?"text-green-400":h.status==="failed"?"text-red-400":"text-gray-500"}`,children:C})]}),h.status==="failed"&&((S=h.failureMessages)==null?void 0:S.map((N,w)=>e.jsx("div",{className:"pl-4 text-[9px] text-red-400/70 truncate max-w-full",title:N,children:N.split(`
4
- `)[0]},w)))]},h.fullName)}),e.jsx("button",{onClick:g,disabled:x,className:"mt-1 text-[10px] text-[#00a0c4] hover:text-[#38bdf8] transition-colors cursor-pointer disabled:opacity-50 bg-transparent border-none p-0",children:x?"Running...":"Re-run"})]})}const Yt={added:"text-green-400",untracked:"text-green-400",modified:"text-blue-400",renamed:"text-purple-400"};function Kt({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 ${Yt[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 qt={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 Xt(t){try{return new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}}function Qt(t){try{return new Date(t+"T00:00:00").toLocaleDateString([],{weekday:"long",month:"long",day:"numeric"})}catch{return t}}const Zt=[{value:"1d",label:"1 Day"},{value:"3d",label:"3 Days"},{value:"7d",label:"1 Week"},{value:"30d",label:"1 Month"}];function es({entries:t,onScreenshotClick:s}){const[a,x]=r.useState(!1),[g,d]=r.useState("7d"),m=r.useMemo(()=>Ht(t,g),[t,g]);return e.jsxs("div",{className:"bg-[#2d2d2d] rounded-lg overflow-hidden",children:[e.jsxs("button",{onClick:()=>x(!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:Zt.map(p=>e.jsx("button",{onClick:()=>d(p.value),className:`px-2.5 py-1 text-[10px] font-medium rounded transition-colors cursor-pointer border ${g===p.value?"bg-[#005c75] text-white border-[#005c75]":"bg-transparent text-gray-400 border-[#4d4d4d] hover:text-white hover:border-[#005c75]"}`,children:p.label},p.value))}),e.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-gray-400",children:[e.jsxs("span",{children:[e.jsx("span",{className:"text-white font-medium",children:m.commitCount})," ",m.commitCount===1?"commit":"commits"]}),e.jsx("span",{className:"text-[#3d3d3d]",children:"|"}),e.jsxs("span",{children:[e.jsx("span",{className:"text-white font-medium",children:m.totalScenarios})," ",m.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:m.entryCount})," ",m.entryCount===1?"entry":"entries"]})]}),m.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:[m.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"}),m.appScenarios.map(p=>e.jsx(Ke,{scenario:p,onScreenshotClick:s},p.name))]}),m.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"}),[...m.componentGroups.entries()].sort(([p],[h])=>p.localeCompare(h)).map(([p,h])=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("span",{className:"text-[10px] font-medium text-gray-400",children:p}),h.map(C=>e.jsx(Ke,{scenario:C,onScreenshotClick:s},C.name))]},p))]})]})]})]})}function Ke({scenario:t,onScreenshotClick:s}){const a=t.name.indexOf(" - "),x=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:x}),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 ts({isActive:t,onScreenshotClick:s,glossaryFunctions:a=[]}){const[x,g]=r.useState([]),[d,m]=r.useState(!0),[p,h]=r.useState(new Set),C=r.useCallback(w=>{h(E=>{const v=new Set(E);return v.has(w)?v.delete(w):v.add(w),v})},[]),S=r.useCallback(async()=>{try{const w=await fetch("/api/editor-journal");if(w.ok){const E=await w.json();g(E.entries||[])}}catch{}finally{m(!1)}},[]);if(r.useEffect(()=>{S()},[S]),r.useEffect(()=>{t&&S()},[t,S]),r.useEffect(()=>{if(!t)return;const w=setInterval(()=>void S(),5e3);return()=>clearInterval(w)},[t,S]),d)return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx("span",{className:"text-gray-500 text-sm",children:"Loading journal..."})});if(x.length===0)return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center text-gray-500 px-8",children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"No journal entries yet"}),e.jsx("p",{className:"text-xs",children:"Journal entries will appear as you build. Claude records features, screenshots, and commits as the project evolves."})]})});const N=Jt(x);return e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsx(es,{entries:x,onScreenshotClick:s}),[...N.entries()].map(([w,E])=>e.jsxs("div",{children:[e.jsx("div",{className:"px-3 py-1.5 sticky top-0 bg-[#1e1e1e] z-10",children:e.jsx("span",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider",children:Qt(w)})}),e.jsx("div",{className:"space-y-2",children:E.map((v,A)=>{const D=qt[v.type]||{label:v.type,color:"bg-gray-600"},R=`${v.time}-${A}`,O=p.has(R);return e.jsxs("div",{className:"bg-[#2d2d2d] rounded-lg overflow-hidden",children:[e.jsxs("div",{className:`p-3 space-y-2 ${O?"":"max-h-[300px] overflow-y-auto"}`,children:[e.jsx("div",{className:"flex items-start gap-2 cursor-pointer",onClick:()=>C(R),children:e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-white truncate",children:v.title}),e.jsx("span",{className:`${D.color} text-white text-[9px] font-bold px-1.5 py-0.5 rounded uppercase tracking-wider shrink-0`,children:D.label})]}),e.jsx("span",{className:"text-[10px] text-gray-500",children:Xt(v.time)}),v.featureName&&e.jsx("span",{className:"text-[10px] text-gray-500 italic truncate",title:v.featureName,children:v.featureName})]})}),v.userPrompt&&e.jsx(rt,{text:v.userPrompt,theme:"dark"}),e.jsx("p",{className:"text-xs text-gray-400 leading-relaxed",children:v.description}),v.screenshot&&e.jsx("button",{type:"button",className:"rounded overflow-hidden border border-[#3d3d3d] hover:border-[#00a0c4] bg-[#1e1e1e] flex items-center justify-center p-1 cursor-pointer transition-colors w-full",onClick:()=>s==null?void 0:s({screenshotUrl:`/api/editor-journal-image/${v.screenshot.replace("screenshots/","")}`,commitSha:v.commitSha,commitMessage:v.commitMessage,scenarioName:v.title}),children:e.jsx("img",{src:`/api/editor-journal-image/${v.screenshot.replace("screenshots/","")}`,alt:v.title,className:"max-w-full max-h-full object-contain",loading:"lazy"})}),v.scenarioScreenshots&&v.scenarioScreenshots.length>0&&(()=>{const M=Gt(v.scenarioScreenshots),I=v.entityChangeStatus,B=M.filter(([c])=>c==="App").flatMap(([,c])=>c),u=M.filter(([c])=>c!=="App"),i=new Map;for(const c of B){const l=X(c.url??null),y=i.get(l)||[];y.push(c),i.set(l,y)}const j=[...i.entries()],o=c=>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/${c.path.replace("screenshots/","")}`,commitSha:v.commitSha,commitMessage:v.commitMessage,scenarioName:c.name}),children:e.jsx("img",{src:`/api/editor-journal-image/${c.path.replace("screenshots/","")}`,alt:c.name,title:c.name,className:"max-w-full max-h-full object-contain",loading:"lazy"})},c.path);return e.jsxs("div",{className:"space-y-2",children:[j.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("span",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider",children:"Application"}),j.map(([c,l])=>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:c}),(I==null?void 0:I[c])&&e.jsx(Ye,{status:I[c]})]}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-0.5",children:l.map(o)})]},c))]}),u.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("span",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider",children:"Components"}),u.map(([c,l])=>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:c}),(I==null?void 0:I[c])&&e.jsx(Ye,{status:I[c]})]}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-0.5",children:l.map(o)})]},c))]})]})})(),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(M=>e.jsxs("div",{children:[e.jsx("span",{className:"text-[11px] font-medium text-gray-200",children:M.name}),e.jsx("span",{className:"text-[9px] text-gray-500 truncate block",children:M.filePath}),M.testFile?e.jsx(Vt,{testFile:M.testFile,entityName:M.name}):e.jsx("div",{className:"pt-1",children:e.jsx("span",{className:"text-[10px] text-gray-500",children:"No test file"})})]},M.name))})]}),v.commitSha&&e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px]",children:[e.jsx("span",{className:"font-mono text-[#00a0c4] bg-[#00a0c4]/10 px-1.5 py-0.5 rounded",children:v.commitSha.slice(0,7)}),e.jsx("span",{className:"text-gray-500 truncate",children:v.commitMessage})]}),O&&v.modifiedFiles&&v.modifiedFiles.length>0&&e.jsx(Kt,{files:v.modifiedFiles})]}),e.jsxs("button",{onClick:()=>C(R),className:"w-full py-1.5 text-[10px] text-gray-500 hover:text-gray-300 border-t border-[#3d3d3d] transition-colors cursor-pointer",children:["——— ",O?"Collapse":"Expand"," ———"]})]},R)})})]},w))]})})}const qe=()=>e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",className:"text-gray-500 shrink-0",children:e.jsx("path",{d:"M4.5 3L7.5 6L4.5 9",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})});function ss(t,s){if(t.length<=s)return t;const a=s-2;return[t[0],"ellipsis",...t.slice(t.length-a)]}function as({items:t,onNavigate:s}){if(t.length===0)return null;const a=ss(t,4);return e.jsx("nav",{className:"flex items-center gap-1 text-xs min-w-0",children:a.map((x,g)=>{if(x==="ellipsis")return e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(qe,{}),e.jsx("span",{className:"text-gray-500",children:"..."})]},"ellipsis");const d=g===a.length-1;return e.jsxs("span",{className:"flex items-center gap-1 min-w-0",children:[g>0&&e.jsx(qe,{}),d?e.jsx("span",{className:"text-white font-medium truncate",children:x.name}):e.jsx("button",{onClick:()=>s(x.componentName),className:"text-gray-400 hover:text-white transition-colors cursor-pointer bg-transparent border-none p-0 truncate",children:x.name})]},x.componentName||"app")})})}function re({imgSrc:t,name:s,isActive:a,onSelect:x}){return e.jsxs("button",{onClick:x,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 me({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(Me,{content:t,icon:!0,iconSize:10,className:"shrink-0 text-gray-500 hover:text-gray-300 transition-colors"})]}):null}function rs({hasProject:t,scenarios:s,analyzedEntities:a,glossaryFunctions:x=[],glossaryEntries:g=[],projectRoot:d,activeScenarioId:m,onScenarioSelect:p,onAnalyzedScenarioSelect:h,onSwitchToBuild:C,zoomComponent:S,onZoomChange:N,entityImports:w,pageFilePaths:E={},projectTitle:v,projectDescription:A,breadcrumbItems:D=[]}){const{pageGroups:R,componentGroups:O}=r.useMemo(()=>{var y;const o=new Map,c=new Map;for(const k of s)if(k.componentName){const L=c.get(k.componentName)||[];L.push(k),c.set(k.componentName,L)}else if(Ee(k.url)){const L=(y=k.url)==null?void 0:y.match(/[?&]c=([^&]+)/),F=L?decodeURIComponent(L[1]):"Isolated",W=c.get(F)||[];W.push(k),c.set(F,W)}else{const L=X(k.url),F=o.get(L)||[];F.push(k),o.set(L,F)}const l=new Map([...c.entries()].sort(([k],[L])=>k.localeCompare(L)));return{pageGroups:o,componentGroups:l}},[s]),M=r.useMemo(()=>a.filter(o=>o.entityType==="visual").sort((o,c)=>o.name.localeCompare(c.name)),[a]),I=r.useMemo(()=>{const o=new Map;for(const c of x)o.set(c.name,c);return o},[x]),B=r.useRef(null),u=r.useRef(0),i=r.useCallback(()=>{B.current&&(u.current=B.current.scrollTop)},[]);if(r.useEffect(()=>{B.current&&u.current>0&&(B.current.scrollTop=u.current)}),!t)return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx("h2",{className:"text-lg font-medium text-white font-['IBM_Plex_Sans'] m-0",children:"Ready to build something?"}),e.jsx("button",{onClick:C,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||M.length>0))return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-4 px-8 text-center",children:[v?e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"text-lg font-medium text-white font-['IBM_Plex_Sans'] m-0",children:v}),A&&e.jsx("p",{className:"text-sm text-gray-400 m-0 font-['IBM_Plex_Sans'] leading-relaxed",children:A})]}):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:C,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 o=R.get(S)||[],c=O.get(S)||[],l=M.find(f=>f.name===S),y=I.get(S),k=[...o,...c],L=new Set((w==null?void 0:w[S])||[]),F=L.size>0,W=F?[...O.entries()].filter(([f])=>L.has(f)):[],K=F?M.filter(f=>L.has(f.name)&&!W.some(([$])=>$===f.name)):[],ne=F?g.filter(f=>L.has(f.name)&&f.returnType!=="JSX.Element"&&f.returnType!=="React.ReactNode").map(f=>({name:f.name,filePath:f.filePath,description:f.description||"",testFile:f.testFile,feature:f.feature})):[],ie=W.length>0||K.length>0,le=ne.length>0,oe=ie||le;return e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsx(as,{items:D,onNavigate:N}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold text-white m-0 font-['IBM_Plex_Sans'] uppercase tracking-wider",children:S}),(()=>{const f=(y==null?void 0:y.filePath)||(l==null?void 0:l.filePath)||E[S];return f?e.jsx(me,{filePath:f,projectRoot:d}):null})()]}),k.length>0&&e.jsx("div",{className:"grid grid-cols-3 gap-2",children:k.map(f=>e.jsx(re,{imgSrc:f.screenshotPath?`/api/editor-scenario-image/${f.id}.png${f.updatedAt?`?v=${encodeURIComponent(f.updatedAt)}`:""}`:null,name:f.name,isActive:f.id===m,onSelect:()=>p(f)},f.id))}),l&&(l.scenarios.length>0||l.pendingScenarios.length>0)&&e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[l.scenarios.map(f=>e.jsx(re,{imgSrc:f.screenshotPath?`/api/screenshot/${f.screenshotPath}`:null,name:f.name,isActive:!1,onSelect:()=>h({analysisId:l.analysisId,scenarioId:f.id,scenarioName:f.name,entitySha:l.sha,entityName:l.name})},f.id)),l.pendingScenarios.map(f=>e.jsx("div",{className:"px-2.5 py-1 bg-[#2a2a2a] text-gray-400 text-[10px] rounded-full",title:f,children:f},f))]}),y&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[10px] text-gray-500",children:"Tests:"}),e.jsx(me,{filePath:y.testFile,projectRoot:d})]}),k.length===0&&!l&&!y&&e.jsx("div",{className:"text-xs text-gray-500",children:"No scenarios for this entity"}),oe&&e.jsxs("div",{className:"pt-3 mt-2 border-t border-[#3d3d3d] space-y-3",children:[ie&&e.jsxs("div",{children:[e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Components"}),W.map(([f,$])=>e.jsxs("div",{className:"mt-3",children:[e.jsx("div",{className:"py-1",children:e.jsx("button",{onClick:()=>N(f),className:"text-[11px] font-medium text-gray-400 cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:f})}),$.length>0&&e.jsx("div",{className:"grid grid-cols-3 gap-2 pt-1",children:$.map(z=>e.jsx(re,{imgSrc:z.screenshotPath?`/api/editor-scenario-image/${z.id}.png${z.updatedAt?`?v=${encodeURIComponent(z.updatedAt)}`:""}`:null,name:z.name,isActive:z.id===m,onSelect:()=>p(z)},z.id))})]},f)),K.map(f=>e.jsxs("div",{className:"mt-3",children:[e.jsx("div",{className:"py-1",children:e.jsx("button",{onClick:()=>N(f.name),className:"text-[11px] font-medium text-gray-400 cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:f.name})}),(f.scenarios.length>0||f.pendingScenarios.length>0)&&e.jsxs("div",{className:"grid grid-cols-3 gap-2 pt-1",children:[f.scenarios.map($=>e.jsx(re,{imgSrc:$.screenshotPath?`/api/screenshot/${$.screenshotPath}`:null,name:$.name,isActive:!1,onSelect:()=>h({analysisId:f.analysisId,scenarioId:$.id,scenarioName:$.name,entitySha:f.sha,entityName:f.name})},$.id)),f.pendingScenarios.map($=>e.jsx("div",{className:"px-2.5 py-1 bg-[#2a2a2a] text-gray-400 text-[10px] rounded-full",title:$,children:$},$))]})]},f.sha))]}),le&&e.jsxs("div",{children:[e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Functions"}),ne.map(f=>e.jsxs("div",{className:"mt-2",children:[e.jsx("div",{className:"py-1",children:e.jsx("button",{onClick:()=>N(f.name),className:"text-[11px] font-medium text-gray-400 cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:f.name})}),e.jsx(me,{filePath:f.filePath,projectRoot:d}),f.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:f.testFile})]})]},f.name))]})]})]})})}return e.jsx("div",{ref:B,onScroll:i,className:"flex-1 overflow-auto",children:e.jsxs("div",{className:"p-4 space-y-4",children:[v&&e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-white m-0 font-['IBM_Plex_Sans']",children:v}),A&&e.jsx("p",{className:"text-xs text-gray-400 m-0 mt-1 font-['IBM_Plex_Sans'] leading-relaxed",children:A})]}),R.size>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Application"}),e.jsx("button",{onClick:C,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:C,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:C,className:"text-[#00a0c4] hover:text-[#00c4eb] bg-transparent border-none p-0 cursor-pointer underline font-inherit text-inherit",children:"create a new page"})]}),[...R.entries()].sort(([o],[c])=>o==="Home"?-1:c==="Home"?1:o.localeCompare(c)).map(([o,c])=>e.jsxs("div",{className:"mt-2",children:[e.jsx("div",{className:"py-1",children:e.jsx("button",{onClick:()=>N(o),className:"text-[11px] font-medium text-gray-400 cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:o})}),E[o]&&e.jsx(me,{filePath:E[o],projectRoot:d}),e.jsx("div",{className:"grid grid-cols-3 gap-2 pt-1",children:c.map(l=>e.jsx(re,{imgSrc:l.screenshotPath?`/api/editor-scenario-image/${l.id}.png${l.updatedAt?`?v=${encodeURIComponent(l.updatedAt)}`:""}`:null,name:l.name,isActive:l.id===m,onSelect:()=>p(l)},l.id))})]},o))]})]})})}const Xe={new:0,edited:1,impacted:2};function Qe({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],x=s&&(t.status==="edited"||t.status==="impacted");return e.jsx("button",{onClick:x?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 ${x?"cursor-pointer hover:opacity-80 transition-opacity":"cursor-default"}`,children:a.label})}function Ze({filePath:t}){const[s,a]=r.useState(null),[x,g]=r.useState(!0),[d,m]=r.useState(null);return r.useEffect(()=>{Ot(()=>import("./index-yHOVb4rc.js"),__vite__mapDeps([0,1])).then(p=>{m(()=>p.default)})},[]),r.useEffect(()=>{g(!0),fetch(`/api/editor-file-diff?path=${encodeURIComponent(t)}`).then(p=>p.json()).then(p=>{a({oldContent:p.oldContent,newContent:p.newContent})}).catch(()=>{a(null)}).finally(()=>g(!1))},[t]),x?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 et({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 tt({scenarioId:t,name:s,isActive:a,onSelect:x,updatedAt:g}){const[d,m]=r.useState(!1);r.useEffect(()=>{m(!1)},[t]);const p=`/api/editor-scenario-image/${t}.png${g?`?v=${encodeURIComponent(g)}`:""}`;return e.jsxs("button",{onClick:x,className:"flex flex-col items-center gap-1.5 cursor-pointer group",title:s,children:[e.jsx("div",{className:`w-32 h-32 rounded-lg overflow-hidden border-2 transition-all ${a?"border-[#0ea5e9] ring-2 ring-[#0ea5e9]/40 shadow-lg shadow-[#0ea5e9]/20":"border-gray-200 hover:border-gray-400 shadow-sm"}`,children:d?e.jsx("div",{className:"w-full h-full bg-gray-100 flex items-center justify-center",children:e.jsx("span",{className:"text-[9px] text-gray-400",children:"No preview"})}):e.jsx("img",{src:p,alt:s,className:"w-full h-full object-contain bg-white",loading:"lazy",onError:()=>m(!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 ns({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(Me,{content:t,icon:!0,iconSize:10,className:"shrink-0 text-gray-400 hover:text-gray-600 transition-colors"})]}):null}function is({testFile:t,entityName:s}){const{results:a,isRunning:x,runTests:g}=Ie(t);if(x&&!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(h=>h.fullName.startsWith(s)):a.testCases,m=d.length>0?d:a.testCases;if(m.length===0)return null;const p=s?`${s} > `:"";return e.jsxs("div",{className:"pt-1 space-y-0.5",children:[m.map(h=>{var S;const C=p&&h.fullName.startsWith(p)?h.fullName.slice(p.length):h.fullName;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[h.status==="passed"?e.jsx("span",{className:"text-green-600 text-[10px]",children:"✓"}):h.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] ${h.status==="passed"?"text-green-600":h.status==="failed"?"text-red-500":"text-gray-400"}`,children:C})]}),h.status==="failed"&&((S=h.failureMessages)==null?void 0:S.map((N,w)=>e.jsx("div",{className:"pl-4 text-[9px] text-red-400 truncate max-w-full",title:N,children:N.split(`
5
- `)[0]},w)))]},h.fullName)}),e.jsx("button",{onClick:g,disabled:x,className:"mt-1 text-[10px] text-[#0ea5e9] hover:text-[#38bdf8] transition-colors cursor-pointer disabled:opacity-50 bg-transparent border-none p-0",children:x?"Running...":"Re-run"})]})}function st(t){const s=t.indexOf(" - ");return s!==-1?t.slice(s+3):t}function at(t,s){return!s||Object.keys(s).length===0?t:[...t].sort(([a],[x])=>{var p,h;const g=((p=s[a])==null?void 0:p.status)||"impacted",d=((h=s[x])==null?void 0:h.status)||"impacted",m=(Xe[g]??2)-(Xe[d]??2);return m!==0?m:a.localeCompare(x)})}function ls({scenarios:t,allScenarios:s=[],glossaryFunctions:a=[],projectRoot:x,activeScenarioId:g,onScenarioSelect:d,onClose:m,entityChangeStatus:p={},modifiedFiles:h=[],featureName:C,userPrompt:S}){const N=r.useMemo(()=>{if(s.length===0||Object.keys(p).length===0)return t;const i=new Set(t.map(o=>o.id)),j=s.filter(o=>{var l;if(i.has(o.id))return!1;const c=o.componentName||X(o.url);return((l=p[c])==null?void 0:l.status)==="impacted"});return j.length===0?t:[...t,...j]},[t,s,p]),w=r.useMemo(()=>Object.entries(p).filter(([,i])=>i.status==="new"||i.status==="edited").map(([i,j])=>({name:i,status:j.status})),[p]),[E,v]=r.useState(null),A=r.useCallback(i=>{v(j=>j===i?null:i)},[]),{pageGroups:D,componentGroups:R}=r.useMemo(()=>{var o;const i=new Map,j=new Map;for(const c of N)if(c.componentName){const l=j.get(c.componentName)||[];l.push(c),j.set(c.componentName,l)}else if(Ee(c.url)){const l=(o=c.url)==null?void 0:o.match(/[?&]c=([^&]+)/),y=l?decodeURIComponent(l[1]):"Isolated",k=j.get(y)||[];k.push(c),j.set(y,k)}else{const l=X(c.url),y=i.get(l)||[];y.push(c),i.set(l,y)}return{pageGroups:i,componentGroups:j}},[N]),O=r.useMemo(()=>at([...D.entries()],p),[D,p]),M=r.useMemo(()=>at([...R.entries()],p),[R,p]),I=O,B=M,u=r.useMemo(()=>zt(a,p),[a,p]);return N.length===0&&a.length===0?e.jsxs("div",{className:"h-full bg-white flex items-center justify-center relative",children:[e.jsx("button",{onClick:m,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"}),C&&e.jsx("div",{className:"text-[11px] text-gray-400 truncate",title:C,children:C})]}),e.jsx("button",{onClick:m,className:"text-gray-400 hover:text-gray-700 text-lg leading-none cursor-pointer bg-transparent border-none shrink-0",title:"Close results",children:"×"})]}),S&&e.jsx(rt,{text:S,theme:"light"}),e.jsx("div",{className:"flex-1 overflow-auto p-4",children:e.jsxs("div",{className:"space-y-5",children:[I.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"mb-2",children:e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Application"})}),e.jsx("div",{className:"space-y-3 pl-1",children:I.map(([i,j])=>{var y;const o=p[i],c=E===i,l=(y=j[0])==null?void 0:y.componentPath;return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1.5 flex items-center gap-2",children:[e.jsx("span",{className:"text-[11px] font-medium text-gray-600",children:i}),o&&e.jsx(Qe,{status:o,onClick:()=>A(i)})]}),c&&(o==null?void 0:o.status)==="edited"&&l&&e.jsx(Ze,{filePath:l}),c&&(o==null?void 0:o.status)==="impacted"&&e.jsx(et,{impactedBy:o.impactedBy,changedEntities:w}),e.jsx("div",{className:"flex flex-wrap gap-3",children:j.map(k=>e.jsx(tt,{scenarioId:k.id,name:st(k.name),isActive:k.id===g,onSelect:()=>d(k),updatedAt:k.updatedAt},k.id))})]},i)})})]}),B.length>0&&e.jsxs("div",{className:I.length>0?"pt-3 border-t border-gray-200":"",children:[e.jsx("div",{className:"mb-2",children:e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Components"})}),e.jsx("div",{className:"space-y-3 pl-1",children:B.map(([i,j])=>{var y;const o=p[i],c=E===i,l=(y=j[0])==null?void 0:y.componentPath;return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1.5 flex items-center gap-2",children:[e.jsx("span",{className:"text-[11px] font-medium text-gray-600",children:i}),o&&e.jsx(Qe,{status:o,onClick:()=>A(i)})]}),c&&(o==null?void 0:o.status)==="edited"&&l&&e.jsx(Ze,{filePath:l}),c&&(o==null?void 0:o.status)==="impacted"&&e.jsx(et,{impactedBy:o.impactedBy,changedEntities:w}),e.jsx("div",{className:"flex flex-wrap gap-3",children:j.map(k=>e.jsx(tt,{scenarioId:k.id,name:st(k.name),isActive:k.id===g,onSelect:()=>d(k),updatedAt:k.updatedAt},k.id))})]},i)})})]}),u.length>0&&e.jsxs("div",{className:I.length>0||B.length>0?"pt-3 border-t border-gray-200":"",children:[e.jsx("div",{className:"mb-2",children:e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Functions"})}),e.jsx("div",{className:"space-y-2 pl-1",children:u.map(i=>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:i.name})}),e.jsx(ns,{filePath:i.filePath,projectRoot:x}),i.testFile?e.jsx(is,{testFile:i.testFile,entityName:i.name}):e.jsx("div",{className:"pt-1",children:e.jsx("span",{className:"text-[10px] text-gray-400",children:"No test file"})})]},i.name))})]}),h.length>0&&e.jsxs("div",{className:I.length>0||B.length>0||u.length>0?"pt-3 border-t border-gray-200":"",children:[e.jsx("div",{className:"mb-2",children:e.jsxs("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:["Modified Files (",h.length,")"]})}),e.jsx("div",{className:"space-y-0.5 pl-1 max-h-[200px] overflow-auto",children:h.map(i=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:`text-[9px] font-bold uppercase w-[14px] text-center ${i.status==="added"||i.status==="untracked"?"text-green-600":i.status==="modified"?"text-blue-600":i.status==="renamed"?"text-purple-600":"text-gray-400"}`,children:i.status==="added"||i.status==="untracked"?"A":i.status==="modified"?"M":i.status==="renamed"?"R":"?"}),e.jsx("span",{className:"text-[10px] text-gray-500 truncate font-mono",children:i.path})]},i.path))})]})]})})]})}const os=[{key:"app",label:"App"},{key:"build",label:"Build"},{key:"data",label:"Structure"},{key:"journal",label:"Journal"}];function cs({activeTab:t,onTabChange:s,buildIdle:a,zoomComponent:x,breadcrumbItems:g,onBreadcrumbNavigate:d,panelLayout:m,onToggleExpand:p}){return e.jsxs("div",{className:"bg-[#3d3d3d] h-10 flex items-center px-3 gap-3 shrink-0 z-20 border-b border-[#2d2d2d]",children:[e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx("img",{src:Ut,alt:"CodeYam",className:"h-5 brightness-0 invert"}),e.jsx("span",{className:"text-white font-medium text-xs whitespace-nowrap",children:"Codeyam Editor"})]}),e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx("div",{className:"flex items-center gap-0.5 bg-[#4a3232] rounded-lg p-0.5",children:os.map(h=>e.jsxs("button",{onClick:()=>s(h.key),className:`px-2.5 py-1 text-xs font-medium rounded-md transition-colors cursor-pointer ${t===h.key?"bg-[#7a4444] text-white":"text-gray-300 hover:text-white"}`,children:[h.label,h.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"})]},h.key))}),p&&e.jsx("button",{onClick:p,className:"p-1.5 rounded text-gray-400 hover:text-white transition-colors cursor-pointer",title:m==="editor-only"?"Show preview":"Hide preview",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:m==="editor-only"?e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),e.jsx("path",{d:"M9 3v18"}),e.jsx("path",{d:"M16 15l-3-3 3-3"})]}):e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),e.jsx("path",{d:"M9 3v18"}),e.jsx("path",{d:"M14 9l3 3-3 3"})]})})})]})]})}function ds({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(xs,{commitSha:t.commitSha,onLoadCommit:a})})]})}function xs({commitSha:t,onLoadCommit:s}){const[a,x]=r.useState(!1),[g,d]=r.useState(null);return e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>{x(!0),d(null),s(t).then(m=>{m.success||d(m.error||"Failed to load commit")}).catch(m=>{d(m instanceof Error?m.message:"Network error")}).finally(()=>x(!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 ms({analysisId:t,scenarioId:s,scenarioName:a,entityName:x,projectSlug:g,onStateChange:d}){const{interactiveServerUrl:m,isStarting:p,isLoading:h}=Ft({analysisId:t,scenarioId:s,scenarioName:a,entityName:x,projectSlug:g,enabled:!0});return r.useEffect(()=>{d(m,p||h)},[m,p,h,d]),null}function ps(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 hs(){const[t,s]=r.useState({url:null,proxyUrl:null,isStarting:!1,error:null,canStartServer:!0,autoStartAttempted:!1}),a=r.useRef(t);a.current=t,r.useEffect(()=>{let d=!1,m=null;const p=async()=>{try{const h=await fetch("/api/editor-dev-server");if(d)return;const C=await h.json(),S=ps(a.current,C),{shouldAutoStart:N,...w}=S;if(s(w),N)try{const E=await fetch("/api/editor-dev-server",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"start"})});if(d)return;E.ok?s(v=>({...v,isStarting:!0})):s(v=>({...v,canStartServer:!1}))}catch{}}catch{}};return p(),m=setInterval(()=>void p(),2e3),()=>{d=!0,m&&clearInterval(m)}},[t.url]);const x=r.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=r.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:x,startServer:g}}const Ps=()=>[{title:"Editor - CodeYam"},{name:"description",content:"CodeYam Code + Data Editor"}];class us extends r.Component{constructor(){super(...arguments);He(this,"state",{error:null,errorInfo:null})}static getDerivedStateFromError(a){return{error:a,errorInfo:null}}componentDidCatch(a,x){console.error("[EditorErrorBoundary] Error:",a.message),console.error("[EditorErrorBoundary] Component stack:",x.componentStack),console.error("[EditorErrorBoundary] Loader snapshot:",JSON.stringify(this.props.loaderSnapshot,null,2)),this.setState({errorInfo:x})}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 Pe=[{name:"Desktop",width:1440,height:900},{name:"Laptop",width:1024,height:768},{name:"Tablet",width:768,height:1024},{name:"Mobile",width:375,height:667}],Ms=Pt(function(){const{projectSlug:s,projectRoot:a,hasProject:x,scenarios:g,allScenarios:d,analyzedEntities:m,glossaryFunctions:p,glossaryEntries:h,entityImports:C,pageFilePaths:S,entityChangeStatus:N,modifiedFiles:w,featureName:E,userPrompt:v,projectTitle:A,projectDescription:D,defaultScreenSize:R,screenSizes:O}=Mt(),[M,I]=It(),B=r.useRef(null),u=r.useRef(null),i=r.useRef(null),j=M.get("zoom")||void 0,o=M.get("scenario")||void 0,[c,l]=r.useState(()=>{if(typeof window>"u")return[];const n=new URLSearchParams(window.location.search).get("zoom");return n?[n]:[]}),y=r.useRef(null),k=r.useRef([]);r.useEffect(()=>{var _;const n=o||((_=Rt(d))==null?void 0:_.id);if(!Tt(n,y.current))return;const b=d.find(V=>V.id===n);if(!b)return;y.current=n;const P=Je(b,k.current);P&&Q(P);const T=xe(b.name);fetch("/api/editor-switch-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioSlug:T,scenarioId:b.id,scenarioName:b.name,scenarioType:b.type})}).catch(()=>{})},[o,d]),r.useEffect(()=>{const n=new BroadcastChannel("codeyam-editor");return n.onmessage=b=>{var P;if(((P=b.data)==null?void 0:P.type)==="switch-scenario"&&b.data.scenarioId){const T=b.data.scenarioId,_=d.find(ke=>ke.id===T);if(!_)return;y.current=T;const V=new URLSearchParams(M);V.set("scenario",T),V.delete("zoom"),I(V),z(null),ce(null),J(null),G(!0);const St=xe(_.name);fetch("/api/editor-switch-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioSlug:St,scenarioId:T,scenarioType:_.type})}).then(()=>{ee(ke=>ke+1)}).catch(()=>{G(!1)})}},()=>n.close()},[M,I,d]),r.useEffect(()=>{if(M.get("ref")!=="link"||!o)return;const n=new BroadcastChannel("codeyam-editor");n.postMessage({type:"switch-scenario",scenarioId:o}),n.close(),window.close()},[]);const{devServerUrl:L,proxyUrl:F,isStarting:W,error:K,canStartServer:ne,retryServer:ie,startServer:le}=hs(),[oe,f]=r.useState(!1),[$,z]=r.useState(null),[$e,ce]=r.useState(null),[pe,Re]=r.useState(!1),[he,J]=r.useState(null),nt=r.useCallback(async n=>{const P=await(await fetch("/api/editor-load-commit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({commitSha:n})})).json();return P.success&&(J(null),f(!1)),P},[]),it=r.useCallback((n,b)=>{ce(P=>(n&&n!==P&&f(!1),n)),!b&&n&&f(!0),Re(b)},[]),Te=r.useCallback(n=>{J(null),z(P=>(P&&P.analysisId===n.analysisId||(ce(null),ee(_=>_+1)),n)),Re(!0),f(!1);const b=new URLSearchParams(M);b.delete("scenario"),b.delete("zoom"),I(b)},[M,I]),[U,Q]=r.useState(R?{name:R.name,width:R.width,height:R.height}:{name:"Desktop",width:1440,height:900}),[Le,Be]=r.useState(!1),[H,ue]=r.useState("app"),lt=r.useCallback(()=>{ue("build"),fe(!0)},[]),[ot,fe]=r.useState(!1),[ct,Ae]=r.useState(!1),dt=r.useCallback(n=>{Ae(n)},[]),[Z,_e]=r.useState("split"),[ge,De]=r.useState(!1),xt=r.useCallback(()=>{De(!0),ue("build"),fe(!0)},[]),Oe=r.useCallback(()=>{De(!1)},[]),mt=r.useCallback(n=>{Q(n),fetch("/api/editor-project-info",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({defaultScreenSize:n,skipBroadcast:!0})})},[]),[de,je]=r.useState(!1),pt=r.useCallback(()=>{if(de){je(!1);return}typeof Notification<"u"&&Notification.permission==="default"?Notification.requestPermission().then(n=>{n==="granted"&&je(!0)}):je(!0)},[de]);r.useEffect(()=>{if(H==="build"){Ae(!1);const n=setTimeout(()=>{var b,P;(b=B.current)==null||b.scrollToBottom(),(P=B.current)==null||P.focus()},50);return()=>clearTimeout(n)}},[H]);const[ve,ht]=r.useState(null);r.useEffect(()=>{const n=i.current;if(!n)return;const b=new ResizeObserver(P=>{const T=P[0];T&&ht({width:T.contentRect.width,height:T.contentRect.height})});return b.observe(n),()=>b.disconnect()},[]);const q=r.useMemo(()=>ve?Lt(ve,U):1,[ve,U]),[be,ee]=r.useState(0),[Ue,Ne]=r.useState(null),[Fe,G]=r.useState(!1),ut=r.useCallback((n,b)=>{if(Ne(n||null),b){const P=new URLSearchParams(M);P.set("scenario",b),y.current=b,I(P)}J(null),ee(P=>P+1)},[M,I]),{customSizes:ye,addCustomSize:ft,removeCustomSize:gt}=Et(s),we=r.useMemo(()=>[...O?Object.entries(O).map(([b,P])=>({name:b,width:P.width,height:P.height})):Pe,...ye],[O,ye]);k.current=we;const ze=r.useMemo(()=>{const n=[{name:"App"}];for(const b of c)n.push({name:b,componentName:b});return n},[c]),Se=r.useCallback(n=>{const b=new URLSearchParams(M);if(n){b.set("zoom",n);const P=c.indexOf(n);P>=0?l(c.slice(0,P+1)):l([...c,n]);const T=d.find(_=>_.componentName===n||_.componentName===null&&X(_.url)===n);if(T){b.set("scenario",T.id),y.current=T.id,G(!0);const _=xe(T.name);fetch("/api/editor-switch-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioSlug:_,scenarioId:T.id,scenarioType:T.type})}).then(()=>{ee(V=>V+1)}).catch(()=>{G(!1)})}else b.delete("scenario")}else b.delete("zoom"),b.delete("scenario"),l([]);I(b)},[M,I,d,c]),te=r.useCallback(n=>{z(null),ce(null),J(null),Ne(null);const b=Je(n,we);b&&Q(b),y.current=n.id;const P=new URLSearchParams(M);P.set("scenario",n.id),I(P),G(!0);const T=xe(n.name);fetch("/api/editor-switch-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioSlug:T,scenarioId:n.id,scenarioType:n.type,skipBroadcast:!0})}).then(()=>{ee(_=>_+1)}).catch(()=>{G(!1)})},[M,I,we]),jt=r.useCallback(n=>{if(!n.commitSha){const b=d.find(P=>P.name===n.scenarioName);if(b){te(b);return}}J(n)},[d,te]),vt=n=>{const b={name:n.name,width:n.width,height:n.height};Q(b),fetch("/api/editor-project-info",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({defaultScreenSize:b,skipBroadcast:!0})})},bt=(n,b,P)=>{ft(n,b,P)},Nt=n=>{Q(n),fetch("/api/editor-project-info",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({defaultScreenSize:n,skipBroadcast:!0})})},yt=()=>{$||f(!0),G(!1)},se=r.useMemo(()=>Bt({activeAnalyzedScenario:!!$,analyzedPreviewUrl:$e,activeScenarioId:o||null,scenarios:d,proxyUrl:F,devServerUrl:L,zoomComponent:j||null}),[F,L,j,o,d,$,$e]),We=r.useMemo(()=>{const n=At(se,Ue);if(!n)return null;const b=n.includes("?")?"&":"?";return`${n}${b}__cb=${be}`},[se,Ue,be]),wt=r.useMemo(()=>({projectSlug:s,hasProject:x,scenarioCount:g==null?void 0:g.length,allScenarioCount:d==null?void 0:d.length,analyzedEntityCount:m==null?void 0:m.length,glossaryFunctionCount:p==null?void 0:p.length,entityChangeStatusKeys:N?Object.keys(N):[],featureName:E}),[s,x,g,d,m,p,N,E]);return e.jsx(us,{loaderSnapshot:wt,children:e.jsxs("div",{className:"fixed inset-0 bg-[#2d2d2d] flex flex-col",children:[$&&e.jsx(ms,{analysisId:$.analysisId,scenarioId:$.scenarioId,scenarioName:$.scenarioName,entityName:$.entityName,projectSlug:s,onStateChange:it},$.analysisId),e.jsxs("div",{className:"flex-1 flex min-h-0",children:[e.jsxs("div",{className:"flex-1 flex flex-col min-w-0",style:Z==="editor-only"?{display:"none"}:void 0,children:[e.jsxs("div",{className:"bg-[#2d2d2d] border-b border-[#3d3d3d] shrink-0 z-10 h-10 flex items-center px-4 gap-1",children:[e.jsx("button",{onClick:()=>_e(n=>n==="preview-only"?"split":"preview-only"),className:"p-1.5 rounded text-gray-500 hover:text-gray-300 transition-colors cursor-pointer shrink-0",title:Z==="preview-only"?"Show sidebar":"Hide sidebar",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),e.jsx("path",{d:"M9 3v18"})]})}),e.jsx("div",{className:"w-px h-4 bg-[#3d3d3d] mx-1"}),e.jsxs("div",{className:"flex-1 flex items-center justify-center gap-1",children:[Pe.map(n=>e.jsxs("button",{onClick:()=>vt(n),className:`p-1.5 rounded transition-colors cursor-pointer ${U.name===n.name?"text-white bg-[#555]":"text-gray-500 hover:text-gray-300"}`,title:`${n.name} (${n.width}×${n.height})`,children:[n.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"})]}),n.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"})]}),n.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"})]}),n.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"})]})]},n.name)),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>Be(n=>!n),className:`flex items-center gap-1.5 px-2 py-1 rounded transition-colors cursor-pointer ${Le||!Pe.some(n=>n.name===U.name)?"text-white bg-[#555]":"text-gray-400 hover:text-gray-200 hover:bg-[#444]"}`,title:"Custom dimensions",children:[e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M17 3a2.83 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"})}),e.jsxs("span",{className:"text-xs font-mono",children:[U.width," × ",U.height??900]})]}),Le&&e.jsx($t,{currentWidth:U.width,currentHeight:U.height??900,customSizes:ye,onApply:Nt,onSave:bt,onRemove:gt,onClose:()=>Be(!1)})]}),e.jsx("div",{className:"w-px h-4 bg-[#3d3d3d] mx-1"}),e.jsx("button",{onClick:()=>{const n=We||se;n&&window.open(n,"_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:i,className:"flex-1 flex items-center justify-center overflow-hidden p-8",style:he?{backgroundColor:"#f5f0e8",backgroundImage:"repeating-linear-gradient(0deg, transparent, transparent 19px, #e8e0d0 19px, #e8e0d0 20px), repeating-linear-gradient(90deg, transparent, transparent 19px, #e8e0d0 19px, #e8e0d0 20px)"}:{backgroundImage:`
6
- linear-gradient(45deg, #333 25%, transparent 25%),
7
- linear-gradient(-45deg, #333 25%, transparent 25%),
8
- linear-gradient(45deg, transparent 75%, #333 75%),
9
- linear-gradient(-45deg, transparent 75%, #333 75%)
10
- `,backgroundSize:"16px 16px",backgroundPosition:"0 0, 0 8px, 8px -8px, -8px 0px",backgroundColor:"#2d2d2d"},children:he?e.jsx(ds,{preview:he,onDismiss:()=>J(null),onLoadCommit:nt}):se?e.jsx("div",{style:{width:`${U.width*q}px`,height:`${(U.height??900)*q}px`},children:e.jsxs("div",{className:"relative bg-white origin-top-left",style:{width:`${U.width}px`,height:`${U.height??900}px`,transform:q<1?`scale(${q})`:void 0},children:[!oe&&!Fe&&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(Ge,{})}),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"})]})]})}),Fe&&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:u,src:We||se,className:"w-full h-full border-none",title:"Editor preview",onLoad:yt,style:{opacity:oe?1:0}},be)]})}):e.jsx("div",{className:"bg-[#2a2a2a] rounded-lg flex flex-col items-center justify-center",style:{width:`${U.width*q}px`,height:`${(U.height??900)*q}px`},children:K?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:K}),e.jsx("button",{onClick:ie,className:"mx-auto px-4 py-2 bg-[#005c75] text-white text-sm font-medium rounded hover:bg-[#004d63] transition-colors cursor-pointer",children:"Retry"})]}):W||pe?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mb-4",children:e.jsx(Ge,{})}),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:pe?"Starting Interactive Mode":"Starting Dev Server"}),e.jsx("p",{className:"text-sm text-gray-400 leading-5 m-0 font-['IBM_Plex_Sans']",children:pe?"Loading component preview...":"Your dev server is starting up..."})]})]}):e.jsxs("div",{className:"flex flex-col gap-3 text-center px-8",children:[e.jsx("h2",{className:"text-xl font-medium text-gray-200 leading-[28px] m-0 font-['IBM_Plex_Sans']",children:"Live Preview"}),e.jsx("p",{className:"text-sm text-gray-500 leading-5 m-0 font-['IBM_Plex_Sans']",children:"Describe what you want to build in the Build tab"})]})})})]}),e.jsxs("aside",{className:`bg-[#1e1e1e] border-r border-[#3d3d3d] shrink-0 flex flex-col overflow-hidden order-first ${Z==="editor-only"?"w-full max-w-none min-w-0":"w-[50%] min-w-[400px] max-w-[800px]"}`,style:Z==="preview-only"?{display:"none"}:void 0,children:[e.jsx(cs,{activeTab:H,onTabChange:n=>{ue(n),n==="build"&&fe(!0)},buildIdle:ct,zoomComponent:j,breadcrumbItems:ze,onBreadcrumbNavigate:Se,panelLayout:Z,onToggleExpand:()=>_e(n=>n==="editor-only"?"split":"editor-only")}),e.jsxs("div",{className:"flex-1 overflow-hidden relative",children:[ot&&e.jsxs("div",{className:"absolute inset-0 flex flex-col overflow-hidden",style:{visibility:H==="build"?"visible":"hidden"},children:[e.jsx("div",{className:ge?"flex-1 min-h-0":"flex-1",style:ge?{flex:"1 1 50%"}:void 0,children:e.jsx(_t,{ref:B,entityName:"Editor",projectSlug:s,entityFilePath:null,scenarioName:null,onRefreshPreview:ut,onShowResults:xt,onHideResults:Oe,onSetViewport:mt,editorMode:!0,onIdleChange:dt,notificationsEnabled:de})}),ge&&e.jsx("div",{style:{flex:"1 1 50%"},className:"min-h-0 border-t-2 border-gray-300",children:e.jsx(ls,{scenarios:g,allScenarios:d,glossaryFunctions:p,projectRoot:a,activeScenarioId:o,onScenarioSelect:te,onClose:Oe,entityChangeStatus:N,modifiedFiles:w,featureName:E,userPrompt:v})})]}),e.jsx("div",{className:"absolute inset-0 flex flex-col overflow-hidden",style:{visibility:H==="app"?"visible":"hidden"},children:e.jsx(rs,{hasProject:x,scenarios:d,analyzedEntities:m,glossaryFunctions:p,glossaryEntries:h,projectRoot:a,activeScenarioId:o,onScenarioSelect:te,onAnalyzedScenarioSelect:Te,onSwitchToBuild:lt,zoomComponent:j,onZoomChange:Se,entityImports:C,pageFilePaths:S,projectTitle:A,projectDescription:D,breadcrumbItems:ze})}),e.jsx("div",{className:"absolute inset-0 flex flex-col overflow-hidden",style:{visibility:H==="data"?"visible":"hidden"},children:e.jsx(Wt,{scenarios:d,projectRoot:a,activeScenarioId:o,onScenarioSelect:te,zoomComponent:j,onZoomChange:Se,analyzedEntities:[],glossaryFunctions:p,activeAnalyzedScenarioId:$==null?void 0:$.scenarioId,onAnalyzedScenarioSelect:Te,entityImports:C,pageFilePaths:S})}),e.jsx("div",{className:"absolute inset-0 flex flex-col overflow-hidden",style:{visibility:H==="journal"?"visible":"hidden"},children:e.jsx(ts,{isActive:H==="journal",onScreenshotClick:jt,glossaryFunctions:p})})]}),e.jsx(Dt,{serverUrl:L,isStarting:W,projectSlug:s,devServerError:K,onStartServer:ne?le:void 0,notificationsEnabled:de,onToggleNotifications:pt})]})]})]})})});export{Ms as default,Ps as meta};
@@ -1,41 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/addon-web-links-Duc5hnl7.js","assets/chunk-JZWAC4HX-C4pqxYJB.js"])))=>i.map(i=>d[i]);
2
- import{r as d,j as u}from"./chunk-JZWAC4HX-C4pqxYJB.js";import{_ as O}from"./preload-helper-ckwbz45p.js";function se({serverUrl:e,isStarting:t,projectSlug:n,devServerError:o,onStartServer:l,notificationsEnabled:f,onToggleNotifications:y}){const[b,v]=d.useState(null),c=d.useRef(null);d.useEffect(()=>{if(!n)return;const j=new EventSource("/api/dev-mode-events");return j.onmessage=W=>{try{const A=JSON.parse(W.data);A.type==="file-synced"&&(v(A.fileName),c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{v(null)},5e3))}catch{}},()=>{j.close(),c.current&&clearTimeout(c.current)}},[n]);let a;o?a="error":t?a="starting":e?a="running":a="stopped";const _={starting:"bg-yellow-400",running:"bg-green-400",stopped:"bg-gray-400",error:"bg-red-400"},E={starting:"Starting...",running:e||"Running",stopped:"Stopped",error:"Error"};return u.jsxs("div",{className:"bg-[#1e1e1e] border-t border-[#3d3d3d] h-7 flex items-center px-4 gap-4 shrink-0 text-xs font-mono",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("div",{className:`w-2 h-2 rounded-full ${_[a]}`}),u.jsxs("span",{className:"text-gray-400",children:["Server:"," ",u.jsx("span",{className:"text-gray-300",children:E[a]})]}),(a==="stopped"||a==="error")&&l&&u.jsx("button",{onClick:l,className:"ml-1 px-2.5 py-0.5 bg-[#005c75] hover:bg-[#007a9a] text-white text-[11px] font-medium rounded transition-colors cursor-pointer border-none leading-tight",children:"Start Server"})]}),u.jsx("div",{className:"w-px h-3 bg-[#3d3d3d]"}),b&&u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"#4ade80",strokeWidth:"2",children:u.jsx("path",{d:"M20 6L9 17l-5-5"})}),u.jsxs("span",{className:"text-green-400",children:["Synced: ",b]})]}),u.jsx("div",{className:"w-px h-3 bg-[#3d3d3d]"})]}),u.jsx("div",{className:"flex-1"}),y&&u.jsx("button",{onClick:y,className:`text-[11px] rounded transition-colors cursor-pointer ${f?"text-green-400 hover:text-green-300":"text-gray-500 hover:text-gray-300"}`,title:f?"Click to turn off notifications":"Click to get notified when Claude finishes",children:f?"Notifications On":"Notifications Off"})]})}async function ee(e,t){try{const{WebglAddon:o}=await O(async()=>{const{WebglAddon:f}=await import("./addon-webgl-DI8QOUvO.js").then(y=>y.a);return{WebglAddon:f}},[]),l=new o;return l.onContextLoss(()=>{t==null||t("webgl","canvas",new Error("WebGL context lost")),l.dispose(),V(e).then(f=>{f||t==null||t("canvas","dom",new Error("Canvas fallback failed after context loss"))})}),e.loadAddon(l),{type:"webgl",dispose:()=>l.dispose()}}catch(o){t==null||t("webgl","canvas",o)}const n=await V(e);return n||(t==null||t("canvas","dom",new Error("Canvas addon failed")),{type:"dom",dispose:()=>{}})}async function V(e){try{const{CanvasAddon:t}=await O(async()=>{const{CanvasAddon:o}=await import("./addon-canvas-DpzMmAy5.js").then(l=>l.a);return{CanvasAddon:o}},[]),n=new t;return e.loadAddon(n),{type:"canvas",dispose:()=>n.dispose()}}catch{return null}}const te=`
3
- .xterm { cursor: text; position: relative; user-select: none; -ms-user-select: none; -webkit-user-select: none; }
4
- .xterm.focus, .xterm:focus { outline: none; }
5
- .xterm .xterm-helpers { position: absolute; top: 0; z-index: 5; }
6
- .xterm .xterm-helper-textarea { padding: 0; border: 0; margin: 0; position: absolute; opacity: 0; left: -9999em; top: 0; width: 0; height: 0; z-index: -5; white-space: nowrap; overflow: hidden; resize: none; }
7
- .xterm .composition-view { background: #000; color: #FFF; display: none; position: absolute; white-space: nowrap; z-index: 1; }
8
- .xterm .composition-view.active { display: block; }
9
- .xterm .xterm-viewport { background-color: #000; overflow-y: scroll; cursor: default; position: absolute; right: 0; left: 0; top: 0; bottom: 0; }
10
- .xterm .xterm-screen { position: relative; }
11
- .xterm .xterm-screen canvas { position: absolute; left: 0; top: 0; }
12
- .xterm .xterm-scroll-area { visibility: hidden; }
13
- .xterm-char-measure-element { display: inline-block; visibility: hidden; position: absolute; top: 0; left: -9999em; line-height: normal; }
14
- .xterm.enable-mouse-events { cursor: default; }
15
- .xterm.xterm-cursor-pointer, .xterm .xterm-cursor-pointer { cursor: pointer; }
16
- .xterm.column-select.focus { cursor: crosshair; }
17
- .xterm .xterm-accessibility:not(.debug), .xterm .xterm-message { position: absolute; left: 0; top: 0; bottom: 0; right: 0; z-index: 10; color: transparent; pointer-events: none; }
18
- .xterm .xterm-accessibility-tree:not(.debug) *::selection { color: transparent; }
19
- .xterm .xterm-accessibility-tree { user-select: text; white-space: pre; }
20
- .xterm .live-region { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
21
- .xterm-dim { opacity: 1 !important; }
22
- .xterm-underline-1 { text-decoration: underline; }
23
- .xterm-underline-2 { text-decoration: double underline; }
24
- .xterm-underline-3 { text-decoration: wavy underline; }
25
- .xterm-underline-4 { text-decoration: dotted underline; }
26
- .xterm-underline-5 { text-decoration: dashed underline; }
27
- .xterm-overline { text-decoration: overline; }
28
- .xterm-strikethrough { text-decoration: line-through; }
29
- .xterm-screen .xterm-decoration-container .xterm-decoration { z-index: 6; position: absolute; }
30
- .xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer { z-index: 7; }
31
- .xterm-decoration-overview-ruler { z-index: 8; position: absolute; top: 0; right: 0; pointer-events: none; }
32
- .xterm-decoration-top { z-index: 2; position: relative; }
33
- `;function re(){if(document.getElementById("xterm-css"))return;const e=document.createElement("style");e.id="xterm-css",e.textContent=te,document.head.appendChild(e)}const ce=d.forwardRef(function({entityName:t,entityType:n,entitySha:o,entityFilePath:l,scenarioName:f,scenarioDescription:y,analysisId:b,projectSlug:v,onRefreshPreview:c,onShowResults:a,onHideResults:_,onSetViewport:E,editorMode:j,onIdleChange:W,notificationsEnabled:A},X){const M=d.useRef(null),R=d.useRef(null),z=d.useRef(null),N=d.useRef(null),B=d.useRef(null),P=d.useRef(!1),L=d.useRef(0),D=d.useRef(!1),S=d.useRef(W);S.current=W;const I=d.useRef(A);I.current=A;const G=d.useCallback(()=>{var m;(m=z.current)==null||m.focus()},[]);return d.useImperativeHandle(X,()=>({sendInput(m){const h=N.current;h&&h.readyState===WebSocket.OPEN&&(h.send(JSON.stringify({type:"input",data:m})),setTimeout(()=>{h.readyState===WebSocket.OPEN&&h.send(JSON.stringify({type:"input",data:"\r"}))},100))},focus(){var m;(m=z.current)==null||m.focus()},scrollToBottom(){var h;const m=(h=M.current)==null?void 0:h.querySelector(".xterm-viewport");m&&(m.scrollTop=m.scrollHeight)}})),d.useEffect(()=>{const m=M.current;if(!m)return;let h=!1;return re(),Promise.all([O(()=>import("./xterm-BqvuqXEL.js"),[]),O(()=>import("./addon-fit-YJmn1quW.js"),[]),O(()=>import("./addon-web-links-Duc5hnl7.js").then(T=>T.a),__vite__mapDeps([0,1]))]).then(([T,Z,K])=>{if(h)return;const i=new T.Terminal({cursorBlink:!0,scrollback:5e3,fontSize:13,fontFamily:"'IBM Plex Mono', 'Menlo', 'Monaco', monospace",theme:{background:"#1e1e1e",foreground:"#d4d4d4",cursor:"#d4d4d4",selectionBackground:"#264f78"},linkHandler:{activate(s,r){try{const p=new URL(r),w=p.searchParams.get("scenario");if(w&&p.pathname==="/editor"){const g=new BroadcastChannel("codeyam-editor");g.postMessage({type:"switch-scenario",scenarioId:w}),g.close();return}}catch{}window.open(r,"_blank")}}}),$=new Z.FitAddon;i.loadAddon($),i.loadAddon(new K.WebLinksAddon),i.open(m);let k=null;ee(i,(s,r,p)=>{console.warn(`[Terminal] Renderer fallback: ${s} → ${r}`,p)}).then(s=>{if(h){s.dispose();return}console.log(`[Terminal] Using ${s.type} renderer`),k=s.dispose}),requestAnimationFrame(()=>{try{$.fit()}catch{}}),z.current=i,i.focus(),setTimeout(()=>i.focus(),100),setTimeout(()=>i.focus(),500);const Q=window.location.protocol==="https:"?"wss:":"ws:",Y=window.location.host;function F(s){const r=new URLSearchParams;return r.set("entityName",t),n&&r.set("entityType",n),o&&r.set("entitySha",o),l&&r.set("entityFilePath",l),f&&r.set("scenarioName",f),y&&r.set("scenarioDescription",y),b&&r.set("analysisId",b),v&&r.set("projectSlug",v),j&&r.set("editorMode","true"),s&&r.set("reconnectId",s),`${Q}//${Y}/ws/terminal?${r.toString()}`}function H(s){const r=F(s),p=new WebSocket(r);N.current=p,p.onopen=()=>{L.current=0,D.current=!1,p.send(JSON.stringify({type:"resize",cols:i.cols,rows:i.rows}))},p.onmessage=w=>{var g,U;try{const x=JSON.parse(w.data);if(x.type==="session-id"){B.current=x.sessionId;return}if(x.type==="refresh-preview"){c==null||c(x.path,x.scenarioId);return}if(x.type==="show-results"){a==null||a();return}if(x.type==="hide-results"){_==null||_();return}if(x.type==="set-viewport"){E==null||E({name:x.name,width:x.width,height:x.height});return}if(x.type==="claude-idle"){if(console.log("[Terminal] Received claude-idle, notifications:",I.current,"permission:",typeof Notification<"u"?Notification.permission:"N/A"),(g=S.current)==null||g.call(S,!0),I.current&&typeof Notification<"u"&&Notification.permission==="granted"){const q=new Notification("Claude is ready for you",{body:"Claude has finished and is waiting for your input.",tag:"claude-idle"});q.onclick=()=>{window.focus(),q.close()}}return}x.type==="output"&&(i.write(x.data),(U=S.current)==null||U.call(S,!1))}catch{i.write(w.data)}},p.onclose=()=>{if(P.current){i.write(`\r
34
- \x1B[90m[Terminal session ended]\x1B[0m\r
35
- `);return}const w=L.current;if(w<5&&B.current){const g=1e3*Math.pow(2,Math.min(w,3));L.current=w+1,i.write(`\r
36
- \x1B[33m[Reconnecting...]\x1B[0m\r
37
- `),setTimeout(()=>{P.current||H(B.current)},g)}else D.current?i.write(`\r
38
- \x1B[90m[Terminal session ended]\x1B[0m\r
39
- `):(D.current=!0,i.write(`\r
40
- \x1B[33m[Starting new session...]\x1B[0m\r
41
- `),B.current=null,L.current=0,H())},p.onerror=()=>{}}H(),i.onData(s=>{const r=N.current;r&&r.readyState===WebSocket.OPEN&&r.send(JSON.stringify({type:"input",data:s}))});let C=null;const J=new ResizeObserver(()=>{C&&clearTimeout(C),C=setTimeout(()=>{let s;try{s=$.proposeDimensions()}catch{return}if(!s||s.cols===i.cols&&s.rows===i.rows)return;const r=m.querySelector(".xterm-viewport");let p,w=!0;r&&(p=r.scrollTop,w=r.scrollTop+r.clientHeight>=r.scrollHeight-10),$.fit(),r&&p!==void 0&&(w?r.scrollTop=r.scrollHeight:r.scrollTop=p);const g=N.current;g&&g.readyState===WebSocket.OPEN&&g.send(JSON.stringify({type:"resize",cols:i.cols,rows:i.rows}))},150)});J.observe(m),R.current=()=>{var s;C&&clearTimeout(C),J.disconnect(),P.current=!0,(s=N.current)==null||s.close(),N.current=null,k==null||k(),i.dispose(),z.current=null}}),()=>{var T;h=!0,(T=R.current)==null||T.call(R),R.current=null}},[]),u.jsx("div",{ref:M,onClick:G,className:"w-full h-full",style:{padding:"4px 0 0 8px"}})});function ne(e){return e.replace(/[^a-zA-Z0-9_]+/g,"_")}function ae(e){const{activeAnalyzedScenario:t,analyzedPreviewUrl:n,activeScenarioId:o,scenarios:l,proxyUrl:f,devServerUrl:y,zoomComponent:b}=e;if(t&&n)return n;if(t&&!n)return null;if(o){const c=l.find(a=>a.id===o);if(c!=null&&c.url){const a=f||y;return a?c.url.startsWith("/")?`${a}${c.url}`:c.url:null}}const v=f||y;if(!v)return null;if(b&&o){const c=l.find(_=>_.id===o),a=c?ne(c.name):"Default";return`${v}/__codeyam__/${b}/${a}`}return v}function le(e,t){if(!e||!t)return e;try{const n=new URL(e),o=t.indexOf("?");return o>=0?(n.pathname=t.slice(0,o),n.search=t.slice(o)):(n.pathname=t,n.search=""),n.href}catch{return e}}function ue(e,t){return e?e!==t:!1}function de(e){if(e.length!==0)return e.find(t=>t.type==="application")||e[0]}function fe(e,t){if(!e.viewportWidth||!e.viewportHeight)return null;const n=t.find(o=>o.width===e.viewportWidth&&o.height===e.viewportHeight);return{name:(n==null?void 0:n.name)||"Custom",width:e.viewportWidth,height:e.viewportHeight}}function me(e,t){const n=t.width,o=t.height??900,l=e.width,f=e.height;return n<=l&&o<=f?1:Math.min(l/n,f/o)}export{se as D,ce as T,le as a,ne as b,me as c,ae as d,de as g,fe as r,ue as s};