@codeyam/codeyam-cli 0.1.28 → 0.1.30

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 (109) hide show
  1. package/analyzer-template/.build-info.json +6 -6
  2. package/analyzer-template/log.txt +3 -3
  3. package/analyzer-template/package.json +2 -2
  4. package/analyzer-template/packages/aws/package.json +5 -5
  5. package/analyzer-template/packages/database/package.json +1 -1
  6. package/codeyam-cli/src/commands/__tests__/init.gitignore.test.js +38 -3
  7. package/codeyam-cli/src/commands/__tests__/init.gitignore.test.js.map +1 -1
  8. package/codeyam-cli/src/commands/editor.js +307 -5
  9. package/codeyam-cli/src/commands/editor.js.map +1 -1
  10. package/codeyam-cli/src/commands/init.js +19 -0
  11. package/codeyam-cli/src/commands/init.js.map +1 -1
  12. package/codeyam-cli/src/utils/__tests__/editorAudit.test.js +136 -0
  13. package/codeyam-cli/src/utils/__tests__/editorAudit.test.js.map +1 -1
  14. package/codeyam-cli/src/utils/__tests__/editorProxySession.test.js +98 -1
  15. package/codeyam-cli/src/utils/__tests__/editorProxySession.test.js.map +1 -1
  16. package/codeyam-cli/src/utils/__tests__/editorRoadmap.test.js +398 -0
  17. package/codeyam-cli/src/utils/__tests__/editorRoadmap.test.js.map +1 -0
  18. package/codeyam-cli/src/utils/designSystemShowcase.js +810 -0
  19. package/codeyam-cli/src/utils/designSystemShowcase.js.map +1 -0
  20. package/codeyam-cli/src/utils/editorAudit.js +6 -1
  21. package/codeyam-cli/src/utils/editorAudit.js.map +1 -1
  22. package/codeyam-cli/src/utils/editorRoadmap.js +301 -0
  23. package/codeyam-cli/src/utils/editorRoadmap.js.map +1 -0
  24. package/codeyam-cli/src/utils/editorScenarios.js +10 -0
  25. package/codeyam-cli/src/utils/editorScenarios.js.map +1 -1
  26. package/codeyam-cli/src/utils/install-skills.js +27 -6
  27. package/codeyam-cli/src/utils/install-skills.js.map +1 -1
  28. package/codeyam-cli/src/webserver/__tests__/api.interactive-switch-scenario.test.js +1 -0
  29. package/codeyam-cli/src/webserver/__tests__/api.interactive-switch-scenario.test.js.map +1 -1
  30. package/codeyam-cli/src/webserver/__tests__/editorProxy.test.js +115 -0
  31. package/codeyam-cli/src/webserver/__tests__/editorProxy.test.js.map +1 -1
  32. package/codeyam-cli/src/webserver/app/lib/database.js.map +1 -1
  33. package/codeyam-cli/src/webserver/build/client/assets/{CopyButton-CLe80MMu.js → CopyButton-DTBZZfSk.js} +1 -1
  34. package/codeyam-cli/src/webserver/build/client/assets/{EntityItem-Crt_KN_U.js → EntityItem-BxclONWq.js} +1 -1
  35. package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeIcon-CD7lGABo.js → EntityTypeIcon-BsnEOJZ_.js} +1 -1
  36. package/codeyam-cli/src/webserver/build/client/assets/{InlineSpinner-CgTNOhnu.js → InlineSpinner-ByaELMbv.js} +1 -1
  37. package/codeyam-cli/src/webserver/build/client/assets/{InteractivePreview-DtYTSPL2.js → InteractivePreview-6WjVfhxX.js} +2 -2
  38. package/codeyam-cli/src/webserver/build/client/assets/{LibraryFunctionPreview-D3s1MFkb.js → LibraryFunctionPreview-ChX-Hp7W.js} +1 -1
  39. package/codeyam-cli/src/webserver/build/client/assets/{LogViewer-CM5zg40N.js → LogViewer-C-9zQdXg.js} +1 -1
  40. package/codeyam-cli/src/webserver/build/client/assets/{MiniClaudeChat-CQENLSrF.js → MiniClaudeChat-BusrvT2F.js} +1 -1
  41. package/codeyam-cli/src/webserver/build/client/assets/{ReportIssueModal-C2PLkej3.js → ReportIssueModal-DQsceHVv.js} +1 -1
  42. package/codeyam-cli/src/webserver/build/client/assets/{SafeScreenshot-DanvyBPb.js → SafeScreenshot-DThcm_9M.js} +1 -1
  43. package/codeyam-cli/src/webserver/build/client/assets/{ScenarioViewer-CefgqbCr.js → ScenarioViewer-Cl4oOA3A.js} +1 -1
  44. package/codeyam-cli/src/webserver/build/client/assets/{Spinner-Bc8BG-Lw.js → Spinner-CIil5-gb.js} +1 -1
  45. package/codeyam-cli/src/webserver/build/client/assets/{ViewportInspectBar-BA_Ry-rs.js → ViewportInspectBar-BqkA9zyZ.js} +1 -1
  46. package/codeyam-cli/src/webserver/build/client/assets/{_index-C1YkzTAV.js → _index-DnOgyseQ.js} +1 -1
  47. package/codeyam-cli/src/webserver/build/client/assets/{activity.(_tab)-yH46LLUz.js → activity.(_tab)-DqM9hbNE.js} +1 -1
  48. package/codeyam-cli/src/webserver/build/client/assets/{addon-web-links-CHx25PAe.js → addon-web-links-C58dYPwR.js} +1 -1
  49. package/codeyam-cli/src/webserver/build/client/assets/{agent-transcripts-Bg3e7q4S.js → agent-transcripts-B8NCeOrm.js} +1 -1
  50. package/codeyam-cli/src/webserver/build/client/assets/api.editor-roadmap-l0sNRNKZ.js +1 -0
  51. package/codeyam-cli/src/webserver/build/client/assets/{book-open-CL-lMgHh.js → book-open-BFSIqZgO.js} +1 -1
  52. package/codeyam-cli/src/webserver/build/client/assets/{chevron-down-GmAjGS9-.js → chevron-down-B9fDzFVh.js} +1 -1
  53. package/codeyam-cli/src/webserver/build/client/assets/chunk-UVKPFVEO-Bmq2apuh.js +43 -0
  54. package/codeyam-cli/src/webserver/build/client/assets/{circle-check-DFcQkN5j.js → circle-check-DLPObLUx.js} +1 -1
  55. package/codeyam-cli/src/webserver/build/client/assets/{copy-C6iF61Xs.js → copy-DXEmO0TD.js} +1 -1
  56. package/codeyam-cli/src/webserver/build/client/assets/{createLucideIcon-4ImjHTVC.js → createLucideIcon-BwyFiRot.js} +1 -1
  57. package/codeyam-cli/src/webserver/build/client/assets/{dev.empty-CRepiabR.js → dev.empty-iRhRIFlp.js} +1 -1
  58. package/codeyam-cli/src/webserver/build/client/assets/editor._tab-BZPBzV73.js +1 -0
  59. package/codeyam-cli/src/webserver/build/client/assets/editor.entity.(_sha)-CsYVRiNH.js +147 -0
  60. package/codeyam-cli/src/webserver/build/client/assets/{editorPreview-CluPkvXJ.js → editorPreview-C6fEYHrh.js} +6 -6
  61. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha._-DYJRGiDI.js → entity._sha._-Ce1s4OQ1.js} +1 -1
  62. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha.scenarios._scenarioId.dev-wdiwx5-Z.js → entity._sha.scenarios._scenarioId.dev-C8AyYgYT.js} +1 -1
  63. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha.scenarios._scenarioId.fullscreen-BrkN-40Y.js → entity._sha.scenarios._scenarioId.fullscreen-DziaVQX1.js} +1 -1
  64. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha_.create-scenario-DxfhekTZ.js → entity._sha_.create-scenario-BTcpgIpC.js} +1 -1
  65. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha_.edit._scenarioId-CRXJWmpB.js → entity._sha_.edit._scenarioId-D_O_ajfZ.js} +1 -1
  66. package/codeyam-cli/src/webserver/build/client/assets/{entry.client-SuW9syRS.js → entry.client-j1Vi0bco.js} +6 -6
  67. package/codeyam-cli/src/webserver/build/client/assets/{files-D-xGrg29.js → files-kuny2Q_s.js} +1 -1
  68. package/codeyam-cli/src/webserver/build/client/assets/{git-Bq_fbXP5.js → git-DgCZPMie.js} +1 -1
  69. package/codeyam-cli/src/webserver/build/client/assets/globals-Gp2o-NMc.css +1 -0
  70. package/codeyam-cli/src/webserver/build/client/assets/{index-Bp1l4hSv.js → index-BliGSSpl.js} +1 -1
  71. package/codeyam-cli/src/webserver/build/client/assets/{index-DE3jI_dv.js → index-SqjQKTdH.js} +1 -1
  72. package/codeyam-cli/src/webserver/build/client/assets/{index-CWV9XZiG.js → index-vyrZD2g4.js} +1 -1
  73. package/codeyam-cli/src/webserver/build/client/assets/{labs-B_IX45ih.js → labs-c3yLxSEp.js} +1 -1
  74. package/codeyam-cli/src/webserver/build/client/assets/{loader-circle-De-7qQ2u.js → loader-circle-D-q28GLF.js} +1 -1
  75. package/codeyam-cli/src/webserver/build/client/assets/manifest-ef0f624d.js +1 -0
  76. package/codeyam-cli/src/webserver/build/client/assets/{memory-Cx2xEx7s.js → memory-CEWIUC4t.js} +1 -1
  77. package/codeyam-cli/src/webserver/build/client/assets/{pause-CFxEKL1u.js → pause-BP6fitdh.js} +1 -1
  78. package/codeyam-cli/src/webserver/build/client/assets/{root-dKFRTYcy.js → root-Didv9PLi.js} +5 -5
  79. package/codeyam-cli/src/webserver/build/client/assets/{search-BdBb5aqc.js → search-BooqacKS.js} +1 -1
  80. package/codeyam-cli/src/webserver/build/client/assets/{settings-DdE-Untf.js → settings-BM0nbryO.js} +1 -1
  81. package/codeyam-cli/src/webserver/build/client/assets/{simulations-DSCdE99u.js → simulations-ovy6FjRY.js} +1 -1
  82. package/codeyam-cli/src/webserver/build/client/assets/{terminal-CrplD4b1.js → terminal-DHemCJIs.js} +1 -1
  83. package/codeyam-cli/src/webserver/build/client/assets/{triangle-alert-DqJ0j69l.js → triangle-alert-D87ekDl8.js} +1 -1
  84. package/codeyam-cli/src/webserver/build/client/assets/{useCustomSizes-DhXHbEjP.js → useCustomSizes-Dk0Tciqg.js} +1 -1
  85. package/codeyam-cli/src/webserver/build/client/assets/{useLastLogLine-D9QZKaLJ.js → useLastLogLine-C8QvIe05.js} +1 -1
  86. package/codeyam-cli/src/webserver/build/client/assets/{useReportContext-Cy5Qg_UR.js → useReportContext-jkCytuYz.js} +1 -1
  87. package/codeyam-cli/src/webserver/build/client/assets/{useToast-5HR2j9ZE.js → useToast-BgqkixU9.js} +1 -1
  88. package/codeyam-cli/src/webserver/build/server/assets/{analysisRunner-OLsM110H.js → analysisRunner-BKMsxwqe.js} +1 -1
  89. package/codeyam-cli/src/webserver/build/server/assets/{index-WHdB6WTN.js → index-CvuvIPEn.js} +1 -1
  90. package/codeyam-cli/src/webserver/build/server/assets/init-B3gVLAAJ.js +14 -0
  91. package/codeyam-cli/src/webserver/build/server/assets/{server-build-DZbLY6O_.js → server-build-B4LxStYP.js} +183 -132
  92. package/codeyam-cli/src/webserver/build/server/index.js +1 -1
  93. package/codeyam-cli/src/webserver/build-info.json +5 -5
  94. package/codeyam-cli/src/webserver/editorProxy.js +77 -4
  95. package/codeyam-cli/src/webserver/editorProxy.js.map +1 -1
  96. package/codeyam-cli/src/webserver/server.js +67 -0
  97. package/codeyam-cli/src/webserver/server.js.map +1 -1
  98. package/codeyam-cli/src/webserver/terminalServer.js +21 -0
  99. package/codeyam-cli/src/webserver/terminalServer.js.map +1 -1
  100. package/codeyam-cli/templates/codeyam-editor-gemini.md +59 -0
  101. package/codeyam-cli/templates/editor-step-hook.py +4 -4
  102. package/codeyam-cli/templates/seed-adapters/supabase.ts +42 -53
  103. package/package.json +1 -1
  104. package/codeyam-cli/src/webserver/build/client/assets/chunk-JZWAC4HX-BAdwhyCx.js +0 -43
  105. package/codeyam-cli/src/webserver/build/client/assets/editor._tab-Gbk_i5Js.js +0 -1
  106. package/codeyam-cli/src/webserver/build/client/assets/editor.entity.(_sha)-CRxPi2BB.js +0 -96
  107. package/codeyam-cli/src/webserver/build/client/assets/globals-BsGHu8WX.css +0 -1
  108. package/codeyam-cli/src/webserver/build/client/assets/manifest-9032538f.js +0 -1
  109. package/codeyam-cli/src/webserver/build/server/assets/init-DbSiZoE6.js +0 -10
@@ -0,0 +1,147 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-SqjQKTdH.js","assets/jsx-runtime-D_zvdyIk.js","assets/chunk-UVKPFVEO-Bmq2apuh.js"])))=>i.map(i=>d[i]);
2
+ var qr=Object.defineProperty;var Vr=(t,s,r)=>s in t?qr(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r;var Es=(t,s,r)=>Vr(t,typeof s!="symbol"?s+"":s,r);import{r as a,f as Xr,w as Qr,u as Zr,i as en,b as tn,a as sn,c as rn,O as nn}from"./chunk-UVKPFVEO-Bmq2apuh.js";import{j as e}from"./jsx-runtime-D_zvdyIk.js";import{u as an,C as on}from"./useCustomSizes-Dk0Tciqg.js";import{g as ct,s as ln,r as It,b as Ke,c as cn,l as dn,d as xn,e as Ds,f as un,a as hn,T as pn,D as mn}from"./editorPreview-C6fEYHrh.js";import{C as Pe}from"./CopyButton-DTBZZfSk.js";import{M as De}from"./MiniClaudeChat-BusrvT2F.js";import{_ as fn}from"./preload-helper-ckwbz45p.js";import{c as gn}from"./cy-logo-cli-Coe5NhbS.js";import{u as bn,S as At}from"./Spinner-CIil5-gb.js";import"./copy-DXEmO0TD.js";import"./createLucideIcon-BwyFiRot.js";import"./useLastLogLine-C8QvIe05.js";function Ye(t){var d;if(!t.startsWith("app/")&&!t.startsWith("("))return"/";const r=t.replace(/^app\//,"").split("/"),n=r.pop(),l=((d=n.match(/\.(tsx?|jsx?|js)$/))==null?void 0:d[0])||"",i=n.slice(0,-l.length);let o;return i==="page"||i==="index"?o=r:o=[...r,i],o=o.filter(c=>!c.startsWith("(")),o.length===0?"/":"/"+o.join("/")}function qe(t){return t==="/"?"Home":t.replace(/^\//,"").split("/").map(r=>r.startsWith("[")?r:r.charAt(0).toUpperCase()+r.slice(1)).join(" / ")}function ft(t){if(!t||t==="/")return"Home";const s=t.split("?")[0].replace(/^\//,"");if(!s)return"Home";const r=s.split("/")[0].replace(/\.[^.]+$/,"");return r.charAt(0).toUpperCase()+r.slice(1)}function Vs(t){return t?t.includes("/isolated-components")||t.includes("/codeyam-isolate"):!1}function jn(t,s){return!s||Object.keys(s).length===0?t:t.filter(r=>s[r.name])}function pt(t){const s=t.name.toLowerCase();if(t.name==="Desktop"||t.name==="Full HD"||t.name==="HD")return"desktop";if(t.name==="Laptop"||t.name==="Small Laptop")return"laptop";if(t.name==="Tablet")return"tablet";if(t.name==="Mobile"||s.includes("iphone")||s.includes("pixel")||s.includes("galaxy")||s.includes("phone"))return"mobile";if(s.includes("ipad")||s.includes("tablet"))return"tablet";if(s.includes("laptop"))return"laptop";if(s.includes("desktop"))return"desktop";const r=t.height>t.width;return r&&t.width>=700?"tablet":r?"mobile":t.width>1200?"desktop":"laptop"}const yn=[{name:"Desktop",width:1440,height:900},{name:"Laptop",width:1024,height:768},{name:"Tablet",width:768,height:1024},{name:"Mobile",width:375,height:667}],vn=[{name:"iPhone 16",width:393,height:852},{name:"iPhone 16 Pro Max",width:430,height:932},{name:"iPhone SE",width:375,height:667},{name:"Pixel 8",width:412,height:915},{name:"iPad mini",width:744,height:1133}],Xs=[{category:"Desktop",presets:[{name:"Full HD",width:1920,height:1080},{name:"Desktop",width:1440,height:900},{name:"HD",width:1280,height:720}]},{category:"Laptop",presets:[{name:"Laptop",width:1366,height:768},{name:"Small Laptop",width:1024,height:768}]},{category:"Tablet",presets:[{name:'iPad Pro 12.9"',width:1024,height:1366},{name:"iPad Air",width:820,height:1180},{name:"Tablet",width:768,height:1024},{name:"iPad mini",width:744,height:1133}]},{category:"Mobile",presets:[{name:"iPhone 16 Pro Max",width:430,height:932},{name:"iPhone 16",width:393,height:852},{name:"iPhone 14",width:390,height:844},{name:"Mobile",width:375,height:667},{name:"Pixel 8",width:412,height:915},{name:"Galaxy S",width:360,height:800}]}];function Qs(t,s){if(t&&Object.keys(t).length>0&&Object.values(t).some(d=>"default"in d))return Object.entries(t).map(([d,c])=>({name:d,width:c.width,height:c.height}));const r=(s==null?void 0:s.includes("mobile-app"))??!1,n=r?vn:yn,l=n.map(d=>{const c=t==null?void 0:t[d.name];return c?{...d,width:c.width,height:c.height}:d});if(!t||r)return l;const i=new Set(n.map(d=>d.name)),o=Object.entries(t).filter(([d])=>!i.has(d)).map(([d,c])=>({name:d,width:c.width,height:c.height}));return[...l,...o]}const dt={width:24,height:76};function Nn({width:t,height:s,enabled:r=!0,children:n}){if(!r)return e.jsx(e.Fragment,{children:n});const l=12,i=48,o=28,d=t+l*2,c=s+i+o;return e.jsxs("div",{style:{width:`${d}px`,height:`${c}px`,background:"#1a1a1a",borderRadius:"44px",padding:`${i}px ${l}px ${o}px`,position:"relative",boxShadow:"0 0 0 1px rgba(255,255,255,0.08), 0 8px 32px rgba(0,0,0,0.4)"},children:[e.jsx("div",{style:{position:"absolute",top:"14px",left:"50%",transform:"translateX(-50%)",width:"100px",height:"24px",background:"#000",borderRadius:"12px"}}),e.jsx("div",{style:{width:`${t}px`,height:`${s}px`,borderRadius:"6px",overflow:"hidden",position:"relative"},children:n}),e.jsx("div",{style:{position:"absolute",bottom:"10px",left:"50%",transform:"translateX(-50%)",width:"120px",height:"4px",background:"rgba(255,255,255,0.25)",borderRadius:"2px"}})]})}function wn({featureName:t,editorStep:s,editorStepLabel:r,onContinue:n,onStartFresh:l}){const i=a.useCallback(o=>{o.key==="Enter"&&(o.preventDefault(),n())},[n]);return a.useEffect(()=>(window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)),[i]),e.jsx("div",{className:"flex items-center justify-center h-full bg-[#1e1e1e] text-[#d4d4d4]",children:e.jsxs("div",{className:"max-w-md w-full mx-4 p-6 bg-[#252526] border border-[#3d3d3d] rounded-lg",children:[e.jsx("h2",{className:"text-lg font-semibold mb-3 text-white",children:"Resume Previous Session?"}),e.jsx("p",{className:"text-sm text-[#999] mb-4",children:"An editor session is still in progress:"}),e.jsxs("div",{className:"bg-[#1e1e1e] rounded p-3 mb-5 text-sm",children:[t&&e.jsxs("div",{className:"mb-1",children:[e.jsx("span",{className:"text-[#999]",children:"Feature:"})," ",e.jsx("span",{className:"text-white",children:t})]}),s!=null&&r&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[#999]",children:"Step:"})," ",e.jsxs("span",{className:"text-white",children:[s," (",r,")"]})]})]}),e.jsx("button",{onClick:n,className:"w-full px-4 py-2 text-sm rounded transition-colors cursor-pointer bg-[#005c75] text-white font-medium hover:bg-[#004d63] ring-2 ring-white/50",children:"Continue Session"}),l&&e.jsx("button",{onClick:l,className:"w-full mt-2 px-4 py-2 text-sm rounded transition-colors cursor-pointer bg-transparent text-[#999] hover:text-white hover:bg-[#3d3d3d] border border-[#3d3d3d]",children:"Start Fresh"})]})})}function kn({onStartNextFeature:t,onContinueInSession:s}){const r=a.useCallback(n=>{n.key==="Enter"&&(n.preventDefault(),t())},[t]);return a.useEffect(()=>(window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)),[r]),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-[#1e1e1e]/90 z-10",children:e.jsxs("div",{className:"max-w-md w-full mx-4 p-6 bg-[#252526] border border-[#3d3d3d] rounded-lg",children:[e.jsx("h2",{className:"text-lg font-semibold mb-3 text-white",children:"Feature Complete!"}),e.jsx("p",{className:"text-sm text-[#999] mb-5",children:"Your feature has been pushed. What would you like to do next?"}),e.jsx("button",{onClick:t,className:"w-full px-4 py-2 text-sm rounded transition-colors cursor-pointer bg-[#005c75] text-white font-medium hover:bg-[#004d63] ring-2 ring-white/50",children:"Start Next Feature"}),e.jsx("button",{onClick:s,className:"w-full mt-2 px-4 py-2 text-sm rounded transition-colors cursor-pointer bg-transparent text-[#999] hover:text-white hover:bg-[#3d3d3d] border border-[#3d3d3d]",children:"Continue in Current Session"}),e.jsx("p",{className:"text-xs text-[#666] mt-3 text-center",children:"Press Enter to start a new feature with a fresh context"})]})})}const Sn={1:"Plan",2:"Prepare",3:"Prototype",4:"Verify Prototype",5:"Confirm",6:"Deconstruct",7:"Extract",8:"Glossary",9:"Analyze",10:"App Scenarios",11:"User Scenarios",12:"Verify",13:"Journal",14:"Review",15:"Present",16:"Commit",17:"Finalize",18:"Push"},Cn={1:"Plan the feature and confirm the approach with the user before writing any code.",2:"Prepare the project environment and dependencies for prototyping.",3:"Build a working prototype quickly to validate the concept.",4:"Verify the prototype works correctly and fix any issues.",5:"Confirm the prototype looks right and get user approval to proceed.",6:"Read the code and plan all component and function extractions.",7:"Extract components and functions via TDD — components first, then functions.",8:"Record all extracted functions and components in the glossary.",9:"Analyze imports and verify all components are captured correctly.",10:"Create app-level scenarios that show full pages with realistic data.",11:"Create user-persona scenarios that exercise the app from different perspectives.",12:"Review all screenshots and check for visual errors or regressions.",13:"Create or update the journal entry documenting what was built.",14:"Final review of screenshots, audit for completeness.",15:"Present a summary of all work to the user for approval.",16:"Commit all changes to git.",17:"Update the journal with final details and amend the commit.",18:"Push the branch to the remote repository."},Fn={1:"Survey",2:"App Scenarios",3:"Component Scenarios",4:"Preview",5:"Discuss",6:"Decompose",7:"Extract",8:"Recapture",9:"Journal",10:"Present"},En={1:"Survey the existing codebase to understand pages, components, and dependencies.",2:"Create app-level scenarios showing full pages with realistic data.",3:"Create component-level scenarios for isolated component previews.",4:"Preview all captured scenarios and verify they look correct.",5:"Discuss the migration plan and prioritize which pages to decompose.",6:"Plan the decomposition of pages into clean, reusable components.",7:"Extract components and functions with tests via TDD.",8:"Recapture scenarios after extraction to verify nothing broke.",9:"Document the migration progress in a journal entry.",10:"Present the migration results for review and approval."},Dn=18,Pn=10;function Tn({projectTitle:t,featureName:s,editorStep:r,editorStepLabel:n,migrationMode:l}){const[i,o]=a.useState(!1),[d,c]=a.useState(null),b=a.useRef(null);a.useEffect(()=>{if(!i)return;const C=I=>{b.current&&!b.current.contains(I.target)&&o(!1)};return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[i]);const p=s&&r!=null,h=l==="active",g=h?Fn:Sn,M=h?En:Cn,w=h?Pn:Dn,u=p?n||g[r]||"?":null,y=s||"New Working Session";return e.jsxs("div",{className:"h-8 shrink-0 flex items-center justify-between px-3 bg-[#2a2a2a] border-b border-[#333] text-xs select-none",children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:"text-[#888] truncate",children:t||"New Project"}),e.jsx("span",{className:"text-[#555]",children:">"}),e.jsx("span",{className:"text-[#ccc] font-medium truncate",children:y})]}),p&&e.jsxs("div",{className:"relative",ref:b,children:[e.jsxs("button",{onClick:()=>o(C=>!C),className:"flex items-center gap-1.5 text-[#ccc] hover:text-white transition-colors cursor-pointer",children:[e.jsx("span",{className:"text-[#555]",children:"::"}),e.jsxs("span",{children:["Step ",r,e.jsxs("span",{className:"text-[#888]",children:[" / ",w]}),":"," ",u]}),e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",className:`transition-transform ${i?"rotate-180":""}`,children:e.jsx("path",{d:"M2 4l3 3 3-3"})})]}),i&&e.jsx("div",{className:"absolute right-0 top-full mt-1 w-48 bg-[#2d2d2d] border border-[#444] rounded-lg shadow-lg z-30 py-1",children:Array.from({length:w},(C,I)=>I+1).map(C=>{const I=C===r,$=C<r,B=d===C,H=M[C];return e.jsxs("div",{onClick:()=>c(B?null:C),className:"cursor-pointer",children:[e.jsxs("div",{className:`w-full px-3 py-1 flex items-center gap-2 text-left transition-colors hover:bg-[#383838] ${I?"text-cygreen font-medium":$?"text-[#ccc]":"text-[#999]"}`,children:[e.jsxs("span",{className:"w-5 text-right tabular-nums shrink-0",children:[C,"."]}),e.jsx("span",{className:"flex-1",children:g[C]||`Step ${C}`}),H&&e.jsx("svg",{width:"8",height:"8",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",className:`shrink-0 opacity-40 transition-transform ${B?"rotate-180":""}`,children:e.jsx("path",{d:"M2 4l3 3 3-3"})})]}),B&&H&&e.jsx("div",{className:"px-3 pb-1.5 pl-10",children:e.jsx("p",{className:"text-[10px] text-[#888] m-0 leading-relaxed",children:H})})]},C)})})]})]})}function Ht(t,s){const[r,n]=a.useState(s??null),[l,i]=a.useState(!1),[o,d]=a.useState((s==null?void 0:s.stale)??!1),c=a.useCallback(()=>{t&&(i(!0),fetch(`/api/editor-test-results?testFile=${encodeURIComponent(t)}`).then(b=>b.json()).then(b=>{n(b),d(!1),i(!1)}).catch(()=>{n({testFilePath:t,status:"error",testCases:[],errorMessage:"Failed to fetch test results"}),d(!1),i(!1)}))},[t]);return{results:r,isRunning:l,runTests:c,stale:o}}function ze({scenarioId:t,screenshotPath:s,updatedAt:r,alt:n,className:l="",imgClassName:i=""}){const[o,d]=a.useState(!1),b=`/api/editor-scenario-image/${s?s.replace(/^screenshots\//,""):`${t}.png`}${r?`?v=${encodeURIComponent(r)}`:""}`;return a.useEffect(()=>{d(!1)},[t,s]),o?e.jsx("div",{className:`flex items-center justify-center ${l}`,children:e.jsx("span",{className:"text-[8px] text-gray-500",children:"No img"})}):e.jsx("div",{className:l,children:e.jsx("img",{src:b,alt:n,className:i,loading:"lazy",onError:()=>d(!0)})})}function Se(t){return t.flatMap(s=>{const r=s.screenshotPaths;return r&&Object.keys(r).length>1?Object.entries(r).map(([n,l])=>({scenario:s,dimensionLabel:n,screenshotPath:l,key:`${s.id}--${n}`})):[{scenario:s,dimensionLabel:null,screenshotPath:s.screenshotPath,key:s.id}]})}function Je({scenarioId:t,screenshotPath:s,updatedAt:r,hasScreenshot:n,imgSrc:l,name:i,dimensionLabel:o,isActive:d,onSelect:c}){const b=t&&n,p=!t&&l;return e.jsxs("button",{onClick:c,className:"flex flex-col items-center gap-1 cursor-pointer group w-full",title:o?`${i} (${o})`:i,children:[e.jsxs("div",{className:`w-full aspect-[16/10] rounded overflow-hidden border-2 transition-all bg-[#1a1a1a] relative ${d?"border-[#D7FF63]/40 ring-1 ring-[#D7FF63]/20":"border-transparent hover:border-[#4d4d4d]"}`,children:[b?e.jsx(ze,{scenarioId:t,screenshotPath:s,updatedAt:r,alt:o?`${i} (${o})`:i,className:"w-full h-full",imgClassName:"w-full h-full object-contain"}):p?e.jsx("img",{src:l,alt:i,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"})}),o&&e.jsx("span",{className:"absolute bottom-1 right-1 text-[8px] font-medium bg-black/60 text-white px-1 py-0.5 rounded",children:o})]}),e.jsx("span",{className:`text-[10px] leading-tight text-center truncate w-full ${d?"text-white":"text-gray-500 group-hover:text-gray-300"}`,children:o?`${i} (${o})`:i})]})}function Rt({testFile:t,entityName:s,cachedResult:r}){const{results:n,isRunning:l,runTests:i,stale:o}=Ht(t,r);if(l&&!n)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(!n)return null;if(n.status==="error")return e.jsx("div",{className:"px-2 pt-1",children:e.jsx("span",{className:"text-[10px] text-red-400",children:n.errorMessage})});const d=s?n.testCases.filter(p=>p.fullName.startsWith(s)):n.testCases,c=d.length>0?d:n.testCases;if(c.length===0)return null;const b=s?`${s} > `:"";return e.jsxs("div",{className:"px-2 pt-1 space-y-0.5",children:[c.map(p=>{var g;const h=b&&p.fullName.startsWith(b)?p.fullName.slice(b.length):p.fullName;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[p.status==="passed"?e.jsx("span",{className:"text-green-400 text-[10px]",children:"✓"}):p.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] ${p.status==="passed"?"text-green-400":p.status==="failed"?"text-red-400":"text-gray-500"}`,children:h})]}),p.status==="failed"&&((g=p.failureMessages)==null?void 0:g.map((M,w)=>e.jsx("div",{className:"pl-4 text-[9px] text-red-300/70 truncate max-w-full",title:M,children:M.split(`
3
+ `)[0]},w)))]},p.fullName)}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("button",{onClick:i,disabled:l,className:"text-[10px] text-[#00a0c4] hover:text-[#00c4ee] transition-colors cursor-pointer disabled:opacity-50 bg-transparent border-none p-0",children:l?"Running...":o?"Re-run (stale)":"Re-run"}),o&&!l&&e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 shrink-0",title:"Source or test file changed since last run"})]})]})}function Ge({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(Pe,{content:t,icon:!0,iconSize:10,className:"shrink-0 text-gray-500 hover:text-gray-300 transition-colors"})]}):null}function $n({scenarios:t,projectRoot:s,activeScenarioId:r,onScenarioSelect:n,zoomComponent:l,focusedEntity:i,onZoomChange:o,analyzedEntities:d=[],glossaryFunctions:c=[],cachedTestResults:b={},activeAnalyzedScenarioId:p,onAnalyzedScenarioSelect:h,entityImports:g,pageFilePaths:M={},onSwitchToBuild:w,entityShaMap:u,structureTab:y="application",onStructureTabChange:C}){const[I,$]=a.useState(""),[B,H]=a.useState(y),P=C?y:B,J=C||H,{pageGroups:_,componentGroups:O}=a.useMemo(()=>{var A;const f=new Map,S=new Map;for(const R of t)if(R.componentName){const Y=S.get(R.componentName)||[];Y.push(R),S.set(R.componentName,Y)}else if(Vs(R.url)){const Y=(A=R.url)==null?void 0:A.match(/[?&]c=([^&]+)/),Z=Y?decodeURIComponent(Y[1]):"Isolated",se=S.get(Z)||[];se.push(R),S.set(Z,se)}else{const Y=R.pageFilePath?qe(Ye(R.pageFilePath)):ft(R.url),Z=f.get(Y)||[];Z.push(R),f.set(Y,Z)}const j=new Map([...S.entries()].sort(([R],[Y])=>R.localeCompare(Y)));return{pageGroups:f,componentGroups:j}},[t]),E=a.useMemo(()=>{const f=new Set((d||[]).filter(j=>j.entityType==="visual").map(j=>j.name)),S=new Map;for(const[j,A]of O)f.has(j)||S.set(j,A);return S},[O,d]),{visualEntities:v,libraryEntities:L}=a.useMemo(()=>{const f=d.filter(j=>j.entityType==="visual").sort((j,A)=>j.name.localeCompare(A.name)),S=d.filter(j=>j.entityType==="library"||j.entityType==="functionCall").sort((j,A)=>j.name.localeCompare(A.name));return{visualEntities:f,libraryEntities:S}},[d]),W=a.useMemo(()=>{const f=new Set(L.map(S=>S.name));return c.filter(S=>!f.has(S.name)).sort((S,j)=>S.name.localeCompare(j.name))},[c,L]),U=d.some(f=>f.isAnalyzing),k=a.useRef(null),F=a.useRef(0),D=a.useCallback(()=>{k.current&&(F.current=k.current.scrollTop)},[]);if(a.useEffect(()=>{k.current&&F.current>0&&(k.current.scrollTop=F.current)}),t.length===0&&d.length===0&&W.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(l&&i){const f=i.name,S=i.filePath,j=i.sha,A=t.filter(K=>K.componentName===f||K.componentPath===S||!K.componentName&&(K.pageFilePath===S||j&&K.entitySha===j)),R=new Set((g==null?void 0:g[f])||[]),Y=R.size>0,Z=Y?v.filter(K=>R.has(K.name)):[],se=Y?L.filter(K=>R.has(K.name)):[];return e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsxs("div",{className:"p-3 space-y-1",children:[e.jsxs("button",{onClick:()=>o(void 0),className:"w-full flex items-center gap-2 px-3 py-1.5 text-xs text-gray-400 hover:text-white transition-colors cursor-pointer",children:[e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",className:"shrink-0",children:e.jsx("path",{d:"M7.5 9L4.5 6L7.5 3",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),"All scenarios"]}),e.jsx("div",{className:"px-3 py-1.5",children:e.jsx("span",{className:"text-xs font-semibold text-white uppercase tracking-wider",children:i.displayName})}),e.jsx("div",{className:"flex flex-wrap gap-2 px-2",children:A.length===0?e.jsx("div",{className:"px-3 py-2 text-xs text-gray-500",children:"No scenarios for this component"}):Se(A).map(({scenario:K,dimensionLabel:ae,screenshotPath:pe,key:ie})=>e.jsx(Je,{scenarioId:K.id,screenshotPath:pe,updatedAt:K.updatedAt,hasScreenshot:!!pe,name:K.name,dimensionLabel:ae,isActive:K.id===r,onSelect:()=>n(K,ae??void 0)},ie))}),Z.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"})}),Z.map(K=>e.jsxs("div",{className:"mt-2",children:[e.jsx("div",{className:"flex items-center gap-2 px-2 py-1",children:e.jsx("button",{onClick:()=>o(K.name),className:"text-[11px] font-medium text-gray-400 truncate cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:K.name})}),e.jsx(Ge,{filePath:K.filePath,projectRoot:s}),(K.scenarios.length>0||K.pendingScenarios.length>0)&&e.jsx("div",{className:"flex flex-wrap gap-2 px-2 pt-1",children:K.scenarios.map(ae=>e.jsx(Je,{imgSrc:ae.screenshotPath?`/api/screenshot/${ae.screenshotPath}`:null,name:ae.name,isActive:ae.id===p,onSelect:()=>h==null?void 0:h({analysisId:K.analysisId,scenarioId:ae.id,scenarioName:ae.name,entitySha:K.sha,entityName:K.name})},ae.id))})]},K.sha))]}),se.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"})}),se.map(K=>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:K.name})}),e.jsx(Ge,{filePath:K.filePath,projectRoot:s}),K.testFile&&e.jsx(Rt,{testFile:K.testFile,entityName:K.name,cachedResult:b[K.testFile]})]},K.sha))]})]})})}return e.jsx("div",{ref:k,onScroll:D,className:"flex-1 overflow-auto font-['IBM_Plex_Sans']",children:e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3 font-['IBM_Plex_Mono']",children:[e.jsx("button",{onClick:()=>J("application"),className:`text-xs font-bold uppercase tracking-wider shrink-0 bg-transparent border-none cursor-pointer p-0 transition-colors ${P==="application"?"text-white":"text-gray-500 hover:text-gray-300"}`,children:"Application"}),e.jsx("button",{onClick:()=>J("components"),className:`text-xs font-bold uppercase tracking-wider shrink-0 bg-transparent border-none cursor-pointer p-0 transition-colors ${P==="components"?"text-white":"text-gray-500 hover:text-gray-300"}`,children:"Components"}),e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:"relative",style:{width:170},children:[e.jsxs("svg",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-500",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("path",{d:"M21 21l-4.35-4.35"})]}),e.jsx("input",{type:"text",placeholder:"SEARCH...",value:I,onChange:f=>$(f.target.value),className:"w-full pl-9 pr-3 py-2 text-xs bg-[#2a2a2a] border border-[#3d3d3d] rounded-md text-gray-300 placeholder-gray-600 outline-none focus:border-[#D7FF63]/50 transition-colors tracking-wider"})]}),w&&e.jsxs("button",{onClick:w,className:"flex items-center gap-1.5 px-4 py-2 text-xs font-semibold text-[#1e1e1e] bg-[#D7FF63] rounded-md hover:bg-[#D7FF63]/80 transition-colors cursor-pointer shrink-0 uppercase tracking-wider",children:[e.jsx("span",{children:"+"})," New Feature"]})]}),e.jsx("div",{className:"border-b border-[#2d2d2d]"}),P==="application"&&_.size>0&&e.jsx("div",{children:[..._.entries()].sort(([f],[S])=>f==="Home"?-1:S==="Home"?1:f.localeCompare(S)).filter(([f])=>I.trim()?f.toLowerCase().includes(I.trim().toLowerCase()):!0).map(([f,S])=>{const j=S.some(A=>A.id===r&&!p);return e.jsxs("div",{className:"mt-3",children:[e.jsxs("div",{className:"flex items-center gap-1.5 py-1",children:[e.jsxs("button",{onClick:()=>o(f,u==null?void 0:u.get(f)),className:`flex items-center gap-1.5 text-sm font-normal cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0 ${j?"text-[#D7FF63]":"text-gray-300"}`,children:[f,e.jsxs("span",{className:`text-xs ${j?"text-[#D7FF63]/60":"text-gray-500"}`,children:["(",S.length,")"]}),e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 12 12",fill:"none",className:j?"text-[#D7FF63]/60":"text-gray-500",children:e.jsx("path",{d:"M4.5 3L7.5 6L4.5 9",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),j&&e.jsxs("div",{className:"flex items-center gap-1 ml-auto",children:[e.jsx("button",{onClick:()=>o(f,u==null?void 0:u.get(f)),className:"p-1.5 rounded-md bg-[#3d3d3d] hover:bg-[#4d4d4d] text-gray-300 hover:text-white transition-colors cursor-pointer border-none",title:"Edit scenarios",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),e.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})}),w&&e.jsx("button",{onClick:w,className:"p-1.5 rounded-md bg-[#3d3d3d] hover:bg-[#4d4d4d] text-gray-300 hover:text-white transition-colors cursor-pointer border-none",title:"Add scenario",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),e.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})})]})]}),e.jsx("div",{className:"grid grid-cols-3 gap-2 pt-1",children:Se(S).map(({scenario:A,dimensionLabel:R,screenshotPath:Y,key:Z})=>e.jsx(Je,{scenarioId:A.id,screenshotPath:Y,updatedAt:A.updatedAt,hasScreenshot:!!Y,name:A.name,dimensionLabel:R,isActive:A.id===r&&!p,onSelect:()=>n(A,R??void 0)},Z))})]},f)})}),P==="components"&&E.size>0&&e.jsx("div",{children:[...E.entries()].filter(([f])=>I.trim()?f.toLowerCase().includes(I.trim().toLowerCase()):!0).map(([f,S])=>{const j=S.some(A=>A.id===r&&!p);return e.jsxs("div",{className:"mt-3",children:[e.jsxs("div",{className:"flex items-center gap-1.5 py-1",children:[e.jsxs("button",{onClick:()=>o(f,u==null?void 0:u.get(f)),className:`flex items-center gap-1.5 text-sm font-normal cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0 ${j?"text-[#D7FF63]":"text-gray-300"}`,children:[f,e.jsxs("span",{className:`text-xs ${j?"text-[#D7FF63]/60":"text-gray-500"}`,children:["(",S.length,")"]}),e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 12 12",fill:"none",className:j?"text-[#D7FF63]/60":"text-gray-500",children:e.jsx("path",{d:"M4.5 3L7.5 6L4.5 9",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),j&&e.jsxs("div",{className:"flex items-center gap-1 ml-auto",children:[e.jsx("button",{onClick:()=>o(f,u==null?void 0:u.get(f)),className:"p-1.5 rounded-md bg-[#3d3d3d] hover:bg-[#4d4d4d] text-gray-300 hover:text-white transition-colors cursor-pointer border-none",title:"Edit scenarios",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),e.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})}),w&&e.jsx("button",{onClick:w,className:"p-1.5 rounded-md bg-[#3d3d3d] hover:bg-[#4d4d4d] text-gray-300 hover:text-white transition-colors cursor-pointer border-none",title:"Add scenario",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),e.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})})]})]}),e.jsx("div",{className:"grid grid-cols-3 gap-2 pt-1",children:Se(S).map(({scenario:A,dimensionLabel:R,screenshotPath:Y,key:Z})=>e.jsx(Je,{scenarioId:A.id,screenshotPath:Y,updatedAt:A.updatedAt,hasScreenshot:!!Y,name:A.name,dimensionLabel:R,isActive:A.id===r&&!p,onSelect:()=>n(A,R??void 0)},Z))})]},f)})}),v.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"}),U&&t.length===0&&d.every(f=>f.scenarioCount===0)&&e.jsx("span",{className:"ml-2 text-[10px] text-gray-500",children:"— Entities are being analyzed..."})]}),v.map(f=>e.jsxs("div",{className:"mt-2",children:[e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1",children:[e.jsx("button",{onClick:()=>o(f.name),className:"text-[11px] font-medium text-gray-400 truncate cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:f.name}),f.isAnalyzing&&f.scenarioCount===0&&e.jsxs("span",{className:"flex items-center gap-1.5 text-[10px] text-gray-400",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[#005c75] animate-pulse"}),"Analyzing..."]})]}),e.jsx(Ge,{filePath:f.filePath,projectRoot:s}),(f.scenarios.length>0||f.pendingScenarios.length>0)&&e.jsxs("div",{className:"flex flex-wrap gap-2 px-2 pt-1",children:[f.scenarios.map(S=>e.jsx(Je,{imgSrc:S.screenshotPath?`/api/screenshot/${S.screenshotPath}`:null,name:S.name,isActive:S.id===p,onSelect:()=>h==null?void 0:h({analysisId:f.analysisId,scenarioId:S.id,scenarioName:S.name,entitySha:f.sha,entityName:f.name})},S.id)),f.pendingScenarios.map(S=>e.jsx("div",{className:"px-2.5 py-1 bg-[#2a2a2a] text-gray-400 text-[10px] rounded-full",title:S,children:S},S))]})]},f.sha))]}),(L.length>0||W.length>0)&&e.jsxs("div",{className:`pt-2 mt-1 ${v.length>0?"":"border-t border-[#3d3d3d]"}`,children:[e.jsx("div",{className:"px-2 py-1",children:e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Functions"})}),L.map(f=>e.jsxs("div",{className:"mt-2",children:[e.jsxs("div",{className:"px-2 py-1",children:[e.jsx("span",{className:"text-[11px] font-medium text-gray-300",children:f.name}),f.isAnalyzing&&f.scenarioCount===0&&e.jsxs("span",{className:"ml-2 inline-flex items-center gap-1.5 text-[10px] text-gray-400",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[#005c75] animate-pulse"}),"Analyzing..."]})]}),e.jsx(Ge,{filePath:f.filePath,projectRoot:s}),f.testFile?e.jsx(Rt,{testFile:f.testFile,entityName:f.name,cachedResult:b[f.testFile]}):e.jsx("div",{className:"px-2 pt-1",children:e.jsx("span",{className:"text-[10px] text-gray-500",children:"No test file"})})]},f.sha)),W.map(f=>e.jsxs("div",{className:"mt-2",children:[e.jsx("div",{className:"px-2 py-1",children:e.jsx("span",{className:"text-[11px] font-medium text-gray-300",children:f.name})}),e.jsx(Ge,{filePath:f.filePath,projectRoot:s}),e.jsx(Rt,{testFile:f.testFile,entityName:f.name,cachedResult:b[f.testFile]})]},f.name))]})]})})}function Zs(t){const s={};for(const[r,n]of Object.entries(t))if(typeof n=="string")try{const l=JSON.parse(n);Array.isArray(l)?s[r]=l:typeof l=="object"&&l!==null&&(s[r]=[l])}catch{}else Array.isArray(n)&&(s[r]=n);return s}function er(t,s){return t.length===0||s.length===0?!1:t.filter(n=>s.includes(n)).length>=Math.min(t.length,s.length)*.5}function Ln(t,s){const{_metadata:r,...n}=s,l=n.localStorage&&typeof n.localStorage=="object"&&!Array.isArray(n.localStorage)?Zs(n.localStorage):{},i={};if(n.seed&&typeof n.seed=="object"&&!Array.isArray(n.seed))for(const[h,g]of Object.entries(n.seed))Array.isArray(g)&&(i[h]=g);const o={},d=[],c=new Set,b=new Set,p=new Set;for(const h of t){const g=h.fields.filter(C=>!C.isRelation),M=g.map(C=>C.name),w=h.name.charAt(0).toLowerCase()+h.name.slice(1);let u=null,y=[];for(const C of[h.name,w,`${w}s`])if(C in n&&Array.isArray(n[C])){u=C,y=n[C],b.add(C);break}if(!u){for(const C of[h.name,w,`${w}s`])if(C in i){u=C,y=i[C],p.add(C),C in l&&c.add(C);break}}if(!u){for(const C of[h.name,w,`${w}s`])if(C in l){u=w,y=l[C],c.add(C);break}}if(!u){for(const[C,I]of Object.entries(l))if(!c.has(C)&&I.length>0&&er(M,Object.keys(I[0]))){u=w,y=I,c.add(C);break}}u||(u=w),o[u]=y,d.push({label:h.name,dataKey:u,schemaFields:g.map(C=>({name:C.name,type:C.type,isId:C.isId}))})}for(const[h,g]of Object.entries(n))h==="_metadata"||h==="localStorage"||h==="seed"||h==="type"||b.has(h)||Array.isArray(g)&&(o[h]=g,d.push({label:h,dataKey:h}));for(const[h,g]of Object.entries(i))p.has(h)||(o[h]=g,d.push({label:h,dataKey:h}));for(const[h,g]of Object.entries(l))c.has(h)||(o[h]=g,d.push({label:h,dataKey:h}));return{data:o,tabs:d}}function Mn(t){return t==null?"null":typeof t=="number"?Number.isInteger(t)?"int4":"float":typeof t=="boolean"?"bool":typeof t=="object"?Array.isArray(t)?"array":"json":"text"}function In(t,s){return t.length>0?Object.keys(t[0]):s?s.map(r=>r.name):[]}function An(t,s,r){const n=new Map((r||[]).map(i=>[i.name,i.type])),l={};for(const i of t)l[i]=n.get(i)||(s.length>0?Mn(s[0][i]):"text");return l}function Rn(t,s){var r;return((r=s==null?void 0:s.find(n=>n.isId))==null?void 0:r.name)||t.find(n=>n==="id")||null}function On(t,s){const{_metadata:r,...n}=s,l=n.localStorage&&typeof n.localStorage=="object"&&!Array.isArray(n.localStorage)?Zs(n.localStorage):{},i={};if(n.seed&&typeof n.seed=="object"&&!Array.isArray(n.seed))for(const[h,g]of Object.entries(n.seed))Array.isArray(g)&&(i[h]=g);const o={},d=[],c=new Set,b=new Set,p=new Set;for(const h of t){const g=h.name.charAt(0).toLowerCase()+h.name.slice(1),M=h.fields.map(y=>y.name);let w=null,u=[];for(const y of[h.name,g,`${g}s`])if(y in n&&Array.isArray(n[y])){w=y,u=n[y],b.add(y);break}if(!w){for(const y of[h.name,g,`${g}s`])if(y in i){w=y,u=i[y],p.add(y),y in l&&c.add(y);break}}if(!w){for(const y of[h.name,g,`${g}s`])if(y in l){w=g,u=l[y],c.add(y);break}}if(!w){for(const[y,C]of Object.entries(l))if(!c.has(y)&&C.length>0&&er(M,Object.keys(C[0]))){w=g,u=C,c.add(y);break}}w||(w=g),o[w]=u,d.push({label:h.name,dataKey:w,category:h.category,description:h.description,schemaFields:h.fields.map(y=>({name:y.name,type:y.type,isId:y.isId??!1}))})}for(const[h,g]of Object.entries(n))h==="_metadata"||h==="localStorage"||h==="seed"||h==="type"||b.has(h)||Array.isArray(g)&&(o[h]=g,d.push({label:h,dataKey:h}));for(const[h,g]of Object.entries(i))p.has(h)||(o[h]=g,d.push({label:h,dataKey:h}));for(const[h,g]of Object.entries(l))c.has(h)||(o[h]=g,d.push({label:h,dataKey:h}));return{data:o,tabs:d}}function Ut(t){var l,i;const s=new Map,r=new Map;for(const o of t)if(o.componentName){const d=r.get(o.componentName)||[];d.push(o),r.set(o.componentName,d)}else if(Vs(o.url)){const d=(l=o.url)==null?void 0:l.match(/[?&]c=([^&]+)/),c=d?decodeURIComponent(d[1]):"Isolated",b=r.get(c)||[];b.push(o),r.set(c,b)}else{const d=o.displayName||((i=o.pageFilePath)!=null&&i.startsWith("app/")?qe(Ye(o.pageFilePath)):ft(o.url)),c=s.get(d)||[];c.push(o),s.set(d,c)}const n=new Map([...r.entries()].sort(([o],[d])=>o.localeCompare(d)));return{pageGroups:s,componentGroups:n}}function tr(t,s){var n,l;const r=new Map;for(const[i,o]of t){const d=(n=o.find(c=>c.entitySha))==null?void 0:n.entitySha;d&&r.set(i,d)}for(const[i,o]of s){const d=(l=o.find(c=>c.entitySha))==null?void 0:l.entitySha;d&&r.set(i,d)}return r}function Bn(t){const s=new Set;for(const[r,n]of Object.entries(t)){s.add(r);for(const l of n)s.add(l)}return s}function _n(t,s,r,n){if(s.has(t))return!0;const l=r.find(i=>i.sha===t);return l?n.has(l.name):!1}function Wn(t,s,r,n){const l=[];for(const[i,o]of t){const d=r.get(i);d?n(d)||l.push({name:i,scenarios:o,reason:"incomplete"}):l.push({name:i,scenarios:o,reason:"missing"})}for(const[i,o]of s){const d=r.get(i);d?n(d)||l.push({name:i,scenarios:o,reason:"incomplete"}):l.push({name:i,scenarios:o,reason:"missing"})}return l}function Ps(t,s,r){if(!t)return null;const n=s.find(l=>l.sha===t);return n?{sha:t,name:n.name,filePath:n.filePath,entityType:n.entityType,displayName:n.name}:null}const Ts=120;function sr({text:t,theme:s}){const[r,n]=a.useState(!1),l=t.length>Ts,i=l&&!r?t.slice(0,Ts)+"…":t,o=s==="light";return e.jsxs("div",{className:`px-4 py-2 ${o?"border-b border-gray-200 bg-gray-50":"border-b border-[#3d3d3d] bg-[#252525]"}`,children:[e.jsx("span",{className:"text-[9px] font-semibold uppercase tracking-wider text-gray-500",children:"User Prompt"}),e.jsxs("p",{className:`text-[11px] mt-0.5 mb-0 leading-relaxed ${o?"text-gray-600":"text-gray-400"}`,children:[i,l&&e.jsx("button",{onClick:()=>n(!r),className:`ml-1 text-[11px] font-medium bg-transparent border-none p-0 cursor-pointer ${o?"text-blue-500 hover:text-blue-700":"text-[#00a0c4] hover:text-[#00c0e8]"}`,children:r?"Show less":"Read more…"})]})]})}const $s={new:0,edited:1,impacted:2};function Ls({status:t,onClick:s}){const r={new:{label:"New",bg:"bg-green-100",text:"text-green-700",border:"border-green-200"},edited:{label:"Edited",bg:"bg-blue-100",text:"text-blue-700",border:"border-blue-200"},impacted:{label:"Impacted",bg:"bg-amber-100",text:"text-amber-700",border:"border-amber-200"}}[t.status],n=s&&(t.status==="edited"||t.status==="impacted");return e.jsx("button",{onClick:n?s:void 0,className:`${r.bg} ${r.text} ${r.border} border text-[9px] font-bold px-1.5 py-0.5 rounded-full uppercase tracking-wider shrink-0 ${n?"cursor-pointer hover:opacity-80 transition-opacity":"cursor-default"}`,children:r.label})}function Ms({filePath:t}){const[s,r]=a.useState(null),[n,l]=a.useState(!0),[i,o]=a.useState(null);return a.useEffect(()=>{fn(()=>import("./index-SqjQKTdH.js"),__vite__mapDeps([0,1,2])).then(d=>{o(()=>d.default)})},[]),a.useEffect(()=>{l(!0),fetch(`/api/editor-file-diff?path=${encodeURIComponent(t)}`).then(d=>d.json()).then(d=>{r({oldContent:d.oldContent,newContent:d.newContent})}).catch(()=>{r(null)}).finally(()=>l(!1))},[t]),n?e.jsx("div",{className:"p-2 text-[10px] text-gray-400",children:"Loading diff..."}):!s||!i?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(i,{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 Is({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(r=>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 ${r.changeType==="new"?"bg-green-100 text-green-700 border-green-200":"bg-blue-100 text-blue-700 border-blue-200"}`,children:r.changeType==="new"?"New":"Edited"}),e.jsx("span",{className:"text-[11px] font-medium text-amber-800",children:r.name}),e.jsx("span",{className:"text-[9px] text-amber-500 truncate",children:r.filePath})]},r.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(r=>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 ${r.status==="new"?"bg-green-100 text-green-700 border-green-200":"bg-blue-100 text-blue-700 border-blue-200"}`,children:r.status==="new"?"New":"Edited"}),e.jsx("span",{className:"text-[11px] font-medium text-amber-800",children:r.name})]},r.name))})]}):e.jsx("span",{className:"text-[10px] text-amber-600",children:"This component was re-captured because a dependency changed"})})}function As({scenarioId:t,screenshotPath:s,name:r,dimensionLabel:n,isActive:l,onSelect:i,updatedAt:o}){const d=a.useRef(null);return a.useEffect(()=>{l&&d.current&&d.current.scrollIntoView({block:"nearest",behavior:"smooth"})},[l]),e.jsxs("button",{ref:d,onClick:i,className:"flex flex-col items-center gap-1.5 cursor-pointer group",title:n?`${r} (${n})`:r,children:[e.jsxs("div",{className:`w-32 h-32 rounded-lg overflow-hidden border-2 transition-all relative ${l?"border-[#0ea5e9] ring-2 ring-[#0ea5e9]/40 shadow-lg shadow-[#0ea5e9]/20":"border-gray-200 hover:border-gray-400 shadow-sm"}`,children:[e.jsx(ze,{scenarioId:t,screenshotPath:s,updatedAt:o,alt:n?`${r} (${n})`:r,className:"w-full h-full bg-white",imgClassName:"w-full h-full object-contain bg-white"}),n&&e.jsx("span",{className:"absolute bottom-1 right-1 text-[9px] font-medium bg-black/60 text-white px-1.5 py-0.5 rounded",children:n})]}),e.jsx("span",{className:`text-[11px] leading-tight text-center truncate w-32 font-medium ${l?"text-gray-900":"text-gray-600 group-hover:text-gray-900"}`,children:n?`${r} (${n})`:r})]})}function zn({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(Pe,{content:t,icon:!0,iconSize:10,className:"shrink-0 text-gray-400 hover:text-gray-600 transition-colors"})]}):null}function Wt({testFile:t,entityName:s,cachedResult:r}){const{results:n,isRunning:l,runTests:i,stale:o}=Ht(t,r);if(l&&!n)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(!n)return null;if(n.status==="error")return e.jsx("div",{className:"pt-1",children:e.jsx("span",{className:"text-[10px] text-red-500",children:n.errorMessage})});const d=s?n.testCases.filter(p=>p.fullName.startsWith(s)):n.testCases,c=d.length>0?d:n.testCases;if(c.length===0)return null;const b=s?`${s} > `:"";return e.jsxs("div",{className:"pt-1 space-y-0.5",children:[c.map(p=>{var g;const h=b&&p.fullName.startsWith(b)?p.fullName.slice(b.length):p.fullName;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[p.status==="passed"?e.jsx("span",{className:"text-green-600 text-[10px]",children:"✓"}):p.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] ${p.status==="passed"?"text-green-600":p.status==="failed"?"text-red-500":"text-gray-400"}`,children:h})]}),p.status==="failed"&&((g=p.failureMessages)==null?void 0:g.map((M,w)=>e.jsx("div",{className:"pl-4 text-[9px] text-red-400 truncate max-w-full",title:M,children:M.split(`
4
+ `)[0]},w)))]},p.fullName)}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("button",{onClick:i,disabled:l,className:"text-[10px] text-[#0ea5e9] hover:text-[#38bdf8] transition-colors cursor-pointer disabled:opacity-50 bg-transparent border-none p-0",children:l?"Running...":o?"Re-run (stale)":"Re-run"}),o&&!l&&e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 shrink-0",title:"Source or test file changed since last run"})]})]})}function Rs(t){const s=t.indexOf(" - ");return s!==-1?t.slice(s+3):t}function Os(t,s){return!s||Object.keys(s).length===0?t:[...t].sort(([r],[n])=>{var d,c;const l=((d=s[r])==null?void 0:d.status)||"impacted",i=((c=s[n])==null?void 0:c.status)||"impacted",o=($s[l]??2)-($s[i]??2);return o!==0?o:r.localeCompare(n)})}function Hn({scenarios:t,allScenarios:s=[],glossaryFunctions:r=[],cachedTestResults:n={},projectRoot:l,activeScenarioId:i,onScenarioSelect:o,onClose:d,entityChangeStatus:c={},modifiedFiles:b=[],featureName:p,userPrompt:h}){const g=a.useMemo(()=>{if(s.length===0||Object.keys(c).length===0)return t;const E=new Set(t.map(L=>L.id)),v=s.filter(L=>{var U,k;if(E.has(L.id))return!1;const W=L.componentName||L.displayName||((U=L.pageFilePath)!=null&&U.startsWith("app/")?qe(Ye(L.pageFilePath)):ft(L.url));return((k=c[W])==null?void 0:k.status)==="impacted"});return v.length===0?t:[...t,...v]},[t,s,c]),M=a.useMemo(()=>Object.entries(c).filter(([,E])=>E.status==="new"||E.status==="edited").map(([E,v])=>({name:E,status:v.status})),[c]),[w,u]=a.useState(null),y=a.useCallback(E=>{u(v=>v===E?null:E)},[]),{pageGroups:C,componentGroups:I}=a.useMemo(()=>Ut(g),[g]),$=a.useMemo(()=>Os([...C.entries()],c),[C,c]),B=a.useMemo(()=>Os([...I.entries()],c),[I,c]),H=$,P=B,J=a.useMemo(()=>jn(r,c),[r,c]),_=a.useMemo(()=>{const E=[];for(const[,v]of H)E.push(...v);for(const[,v]of P)E.push(...v);return E},[H,P]),O=a.useRef(!1);return a.useEffect(()=>{O.current||_.length!==0&&(O.current=!0,console.log("[ResultsPanel] Auto-selecting first scenario: %s",_[0].name),o(_[0]))},[_,o]),a.useEffect(()=>{if(_.length===0)return;const E=v=>{if(v.key!=="ArrowLeft"&&v.key!=="ArrowRight")return;const L=v.target,W=L==null?void 0:L.tagName;if(W==="INPUT"||W==="SELECT"||W==="TEXTAREA"&&!L.classList.contains("xterm-helper-textarea"))return;v.preventDefault();const U=_.findIndex(F=>F.id===i);let k;v.key==="ArrowLeft"?k=U<=0?_.length-1:U-1:k=U>=_.length-1?0:U+1,o(_[k])};return document.addEventListener("keydown",E),()=>document.removeEventListener("keydown",E)},[_,i,o]),g.length===0&&r.length===0?e.jsxs("div",{className:"h-full bg-white flex items-center justify-center relative",children:[e.jsx("button",{onClick:d,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"}),p&&e.jsx("div",{className:"text-[11px] text-gray-400 truncate",title:p,children:p})]}),e.jsx("button",{onClick:d,className:"text-gray-400 hover:text-gray-700 text-lg leading-none cursor-pointer bg-transparent border-none shrink-0",title:"Close results",children:"×"})]}),h&&e.jsx(sr,{text:h,theme:"light"}),e.jsx("div",{className:"flex-1 overflow-auto p-4",children:e.jsxs("div",{className:"space-y-5",children:[H.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:H.map(([E,v])=>{var k;const L=c[E],W=w===E,U=(k=v[0])==null?void 0:k.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:E}),L&&e.jsx(Ls,{status:L,onClick:()=>y(E)})]}),W&&(L==null?void 0:L.status)==="edited"&&U&&e.jsx(Ms,{filePath:U}),W&&(L==null?void 0:L.status)==="impacted"&&e.jsx(Is,{impactedBy:L.impactedBy,changedEntities:M}),e.jsx("div",{className:"flex flex-wrap gap-3",children:Se(v).map(({scenario:F,dimensionLabel:D,screenshotPath:f,key:S})=>e.jsx(As,{scenarioId:F.id,screenshotPath:f,name:Rs(F.name),dimensionLabel:D,isActive:F.id===i,onSelect:()=>o(F,D??void 0),updatedAt:F.updatedAt},S))})]},E)})})]}),P.length>0&&e.jsxs("div",{className:H.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:P.map(([E,v])=>{var k;const L=c[E],W=w===E,U=(k=v[0])==null?void 0:k.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:E}),L&&e.jsx(Ls,{status:L,onClick:()=>y(E)})]}),W&&(L==null?void 0:L.status)==="edited"&&U&&e.jsx(Ms,{filePath:U}),W&&(L==null?void 0:L.status)==="impacted"&&e.jsx(Is,{impactedBy:L.impactedBy,changedEntities:M}),e.jsx("div",{className:"flex flex-wrap gap-3",children:Se(v).map(({scenario:F,dimensionLabel:D,screenshotPath:f,key:S})=>e.jsx(As,{scenarioId:F.id,screenshotPath:f,name:Rs(F.name),dimensionLabel:D,isActive:F.id===i,onSelect:()=>o(F,D??void 0),updatedAt:F.updatedAt},S))})]},E)})})]}),J.length>0&&e.jsxs("div",{className:H.length>0||P.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:J.map(E=>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:E.name})}),e.jsx(zn,{filePath:E.filePath,projectRoot:l}),E.testFile?e.jsx(Wt,{testFile:E.testFile,entityName:E.name,cachedResult:n[E.testFile]}):e.jsx("div",{className:"pt-1",children:e.jsx("span",{className:"text-[10px] text-gray-400",children:"No test file"})})]},E.name))})]}),b.length>0&&e.jsxs("div",{className:H.length>0||P.length>0||J.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 (",b.length,")"]})}),e.jsx("div",{className:"space-y-0.5 pl-1 max-h-[200px] overflow-auto",children:b.map(E=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:`text-[9px] font-bold uppercase w-[14px] text-center ${E.status==="added"||E.status==="untracked"?"text-green-600":E.status==="modified"?"text-blue-600":E.status==="renamed"?"text-purple-600":"text-gray-400"}`,children:E.status==="added"||E.status==="untracked"?"A":E.status==="modified"?"M":E.status==="renamed"?"R":"?"}),e.jsx("span",{className:"text-[10px] text-gray-500 truncate font-mono",children:E.path})]},E.path))})]})]})})]})}function Bs(t,s,r,n){var c;const l=n.length>0?n.map(b=>`- "${b.name}" (ID: ${b.id})${b.url?` — URL: ${b.url}`:""}`).join(`
5
+ `):"(no scenarios yet)",i=s.endsWith("/page.tsx")||s.endsWith("/page.js"),o=((c=n.find(b=>b.url))==null?void 0:c.url)||"/",d=[`You are helping edit scenarios for the "${t}" entity in a CodeYam project.`,"","## Entity",`- **Name:** ${t}`,`- **File:** ${s}`,`- **Type:** ${i?"Page (application scenario with seed data)":"Component (component scenario with mock props)"}`,"","## Existing Scenarios",l,""];return i?d.push("## How Seed Data Works","","Application scenarios use `seed` data to populate the database before the page is captured.","The seed is a JSON object where each key is a Prisma model name in camelCase singular (matching the Prisma client accessor name) and the value is an array of records.","","### Seed Key Naming Convention","The key must be the camelCase singular form of the Prisma model name:",'- `model User` → key `"user"`','- `model BlogPost` → key `"blogPost"`','- `model Feedback` → key `"feedback"`',"",'**WARNING:** Do NOT use plural forms like "users", "blogPosts", or "feedbacks" — the seed adapter will silently fail to match them.',"","To understand the data models, read the Prisma schema at `prisma/schema.prisma`.","To see examples of existing seed data, look at `.codeyam/editor-scenarios/*.seed.json` files.","",`Also read the source file at \`${s}\` to understand what data the page queries and renders.`,"","## Registering a Scenario","","For small seed data, pass it inline:","```",`codeyam editor register '{"name":"Scenario Name","type":"application","url":"${o}","dimensions":["Laptop"],"seed":{"user":[...],"feedback":[...]}}'`,"```","","For large seed data, write it to a temp file and use @file syntax:","```","# Write JSON to a temp file","cat > .codeyam/tmp/scenario.json << 'SCENARIO_EOF'",`{"name":"Scenario Name","type":"application","url":"${o}","dimensions":["Laptop"],"seed":{"user":[...],"feedback":[...]}}`,"SCENARIO_EOF","codeyam editor register @.codeyam/tmp/scenario.json","```"):d.push("## Registering a Scenario","",`Read the source file at \`${s}\` to understand what props the component expects.`,"","```",`codeyam editor register '{"name":"Scenario Name","type":"component","componentName":"${t}","componentPath":"${s}","dimensions":["Laptop"],"mockData":{"propName":"value"}}'`,"```"),d.push("","## Deleting a Scenario","","To delete a scenario, use its ID from the list above:","```","codeyam editor delete <scenarioId>","```","","## Validating Seed Data","","Before registering, you can validate seed data structure and check that keys match Prisma models:","```",`codeyam editor validate-seed '{"user":[...]}'`,"```"),d.push("","## Recapturing Scenarios After Code Changes","",`If the user asks you to modify the code for this ${i?"page":"component"} (CSS, layout, logic, etc.), you MUST re-register all existing scenarios after the code change so their screenshots are updated.`,"","Re-registering a scenario with the same name overwrites it and captures a fresh screenshot.","","To recapture, re-register each existing scenario using `codeyam editor register` with its current configuration. You can read the scenario JSON files in `.codeyam/editor-scenarios/` to get the exact registration data for each scenario."),d.push("","## Important","- DO NOT take any action until the user tells you what they want","- Start by briefly listing the existing scenarios",'- Then ask: "Would you like to modify an existing scenario or add a new one?"',"- Wait for the user's answer before proceeding",'- Keep scenario names descriptive: "Empty State", "With Comments", "Admin View", etc.',`- Each scenario should capture a distinct, meaningful state of the ${i?"page":"component"}`),d.join(`
6
+ `)}function rr(t,s){var l;const r=s.some(i=>!i.componentName),n=s.map(i=>`'${i.id}'`).join(", ");if(r){const i=((l=s.find(d=>d.url))==null?void 0:l.url)||null,o=s.map(d=>`.codeyam/editor-scenarios/${d.id}.json`).join(", ");return[`### Page: "${t}" (${s.length} scenario(s))`,...i?["",`Scenario URL: \`${i}\``]:[],"",...i?["Step A: Find the source file that renders this page. In Next.js App Router, URLs map to page.tsx files:"," - `/` → `app/page.tsx`"," - `/about` → `app/about/page.tsx`"," - `/c/my-slug` → `app/c/[slug]/page.tsx` (dynamic segment)","",`Based on the URL \`${i}\`, find the corresponding page.tsx file. Confirm it exists with \`cat <filepath> | head -5\`.`]:["Step A: Find the source file that renders this page by running:",' find src app -name "App.tsx" -o -name "App.jsx" -o -name "page.tsx" -o -name "page.jsx" -o -name "index.tsx" 2>/dev/null',"","Pick the file that is the main app entry point or the page component for this route. Confirm it exists with `cat <filepath> | head -5`."],"","Step B: Set page_file_path on all scenarios for this page (replace PAGE_FILE_PATH with the path from Step A):",` sqlite3 .codeyam/db.sqlite3 "UPDATE editor_scenarios SET page_file_path = 'PAGE_FILE_PATH' WHERE id IN (${n});"`,"","Step C: Get the entity SHA (after running analyze-imports in the shared step above):",` sqlite3 .codeyam/db.sqlite3 "SELECT sha FROM entities WHERE file_path = 'PAGE_FILE_PATH' ORDER BY created_at DESC LIMIT 1;"`,"","If no rows appear, the path was wrong — go back to Step A.","","Step D: Set entity_sha and display_name on all scenarios (replace ENTITY_SHA with the SHA from Step C):",` sqlite3 .codeyam/db.sqlite3 "UPDATE editor_scenarios SET entity_sha = 'ENTITY_SHA', display_name = '${t}' WHERE id IN (${n});"`,"","Step E: Add pageFilePath to the scenario JSON files so this fix persists across clones.",`For each file (${o}), read it and add \`"pageFilePath": "PAGE_FILE_PATH"\` to the \`_metadata\` object (after the \`"type"\` field). Then commit the updated JSON files.`].join(`
7
+ `)}else return[`### Component: "${t}" (${s.length} scenario(s))`,"","Step A: Get the entity SHA (after running analyze-imports in the shared step above):",` sqlite3 .codeyam/db.sqlite3 "SELECT sha FROM entities WHERE name = '${t}' ORDER BY created_at DESC LIMIT 1;"`,"","If no rows appear, check that .codeyam/glossary.json contains an entry for this component.","","Step B: Set entity_sha and display_name on all scenarios (replace ENTITY_SHA with the SHA from Step A):",` sqlite3 .codeyam/db.sqlite3 "UPDATE editor_scenarios SET entity_sha = 'ENTITY_SHA', display_name = '${t}' WHERE id IN (${n});"`].join(`
8
+ `)}function mt({scenarioId:t,screenshotPath:s,updatedAt:r,hasScreenshot:n,imgSrc:l,name:i,dimensionLabel:o,isActive:d,onSelect:c}){const b=t&&n,p=!t&&l;return e.jsxs("button",{onClick:c,className:"flex flex-col items-center gap-1 cursor-pointer group w-full",title:o?`${i} (${o})`:i,children:[e.jsxs("div",{className:`w-full aspect-[16/10] rounded overflow-hidden border-2 transition-all bg-[#1a1a1a] relative ${d?"border-[#D7FF63]/40 ring-1 ring-[#D7FF63]/20":"border-transparent hover:border-[#4d4d4d]"}`,children:[b?e.jsx(ze,{scenarioId:t,screenshotPath:s,updatedAt:r,alt:o?`${i} (${o})`:i,className:"w-full h-full",imgClassName:"w-full h-full object-contain"}):p?e.jsx("img",{src:l,alt:i,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"})}),o&&e.jsx("span",{className:"absolute bottom-1 right-1 text-[8px] font-medium bg-black/60 text-white px-1 py-0.5 rounded",children:o})]}),e.jsx("span",{className:`text-[10px] leading-tight text-center truncate w-full ${d?"text-white":"text-gray-500 group-hover:text-gray-300"}`,children:o?`${i} (${o})`:i})]})}function xt({filePath:t}){return t?e.jsxs("div",{className:"flex items-center gap-1.5 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.5 text-gray-500 hover:text-gray-300 transition-colors min-w-0",children:[e.jsx("span",{className:"text-sm truncate font-['IBM_Plex_Mono']",children:t}),e.jsx("svg",{className:"shrink-0",width:"12",height:"12",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(Pe,{content:t,icon:!0,iconSize:12,className:"shrink-0 text-gray-500 hover:text-gray-300 transition-colors"})]}):null}function nr({name:t,scenarios:s,reason:r="missing"}){var i,o;const n=((i=s[0])==null?void 0:i.componentPath)||((o=s[0])==null?void 0:o.pageFilePath)||null,l=r==="incomplete"?[`The "${t}" entity exists but has not been fully analyzed — its components and functions cannot be displayed.`,"","Follow these steps:","",`Step 1: Check if "${t}" is in the glossary:`,` cat .codeyam/glossary.json | grep "${t}"`,"","If not found, add an entry to .codeyam/glossary.json:",` { "name": "${t}", "filePath": "${n||"FILL_IN_PATH"}", "description": "...", "returnType": "JSX.Element" }`,"","Step 2: Run: codeyam editor analyze-imports","","Step 3: Reload the editor page and verify components/functions appear."].join(`
9
+ `):[`The "${t}" ${s.some(d=>!d.componentName)?"page":"component"} is missing entity data in the CodeYam database. Its scenarios are hidden until this is fixed.`,"","IMPORTANT: Do NOT re-register scenarios — that would overwrite their screenshots. Instead, update the database and scenario JSON files directly.","","Follow these steps EXACTLY:","","Step 1: Run: codeyam editor analyze-imports","","Step 2: Fix this entity:","",rr(t,s),"","Step 3: Reload the editor page in the browser and verify the scenarios appear."].join(`
10
+ `);return e.jsx(Pe,{content:l,label:"Copy Fix Prompt",copiedLabel:"Copied!",className:"text-[10px] text-[#E0D400] hover:text-[#E0D400]/80 bg-transparent border border-[#E0D400]/30 rounded px-2 py-0.5 cursor-pointer transition-colors ml-2"})}function Un({brokenEntities:t}){const[s,r]=a.useState(!1),n=a.useCallback(c=>{navigator.clipboard.writeText(c).then(()=>{r(!0),setTimeout(()=>r(!1),2e3)})},[]);if(t.length===0)return null;const l=t.reduce((c,b)=>c+b.scenarios.length,0),i=t.filter(c=>c.reason==="incomplete"),o=t.filter(c=>c.reason==="missing"),d=[`${t.length} entities are missing data in the CodeYam database. ${l} total scenario(s) are hidden until this is fixed.`,"","IMPORTANT: Do NOT re-register scenarios — that would overwrite their screenshots. Instead, update the database and scenario JSON files directly.","","Follow these steps EXACTLY:","",...i.length>0?["## Step 1: Add missing entries to the glossary","","Read `.codeyam/glossary.json` and check if these entities have entries. For each one that is missing, add an entry:","",...i.map(c=>{var p,h;const b=((p=c.scenarios[0])==null?void 0:p.componentPath)||((h=c.scenarios[0])==null?void 0:h.pageFilePath)||"FILL_IN_PATH";return`- "${c.name}" (filePath: "${b}")`}),"",'Each glossary entry needs: name, filePath, description, returnType (use "JSX.Element" for components/pages).',""]:["## Step 1: No glossary changes needed",""],"## Step 2: Run import analysis"," codeyam editor analyze-imports","",...o.length>0?["## Step 3: Fix missing entity associations","",...o.map(c=>rr(c.name,c.scenarios)),""]:[],`## Step ${o.length>0?"4":"3"}: Reload the editor page in the browser and verify all scenarios appear. Then commit the updated scenario JSON files so the fix persists across clones.`].join(`
11
+ `);return e.jsx("div",{className:"p-4 rounded-lg border border-[#E0D400]/40 bg-[#E0D400]/8",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"#E0D400",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),e.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),e.jsxs("p",{className:"flex-1 min-w-0 text-sm text-[#E0D400]/90 m-0 leading-snug font-['IBM_Plex_Sans']",children:[t.length," ",t.length===1?"entity is":"entities are"," missing data, resulting in ",l," hidden scenario",l!==1?"s":"","."," ",e.jsx("button",{type:"button",className:"font-bold underline bg-transparent border-none text-[#E0D400] cursor-pointer p-0 text-sm inline hover:text-[#E0D400]/70 transition-colors",onClick:()=>n(d),children:s?e.jsxs("span",{className:"inline-flex items-center gap-1",children:["Copied",e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",className:"inline",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})})]}):"Copy this prompt"})," ","into Claude to fix them all at once."]}),e.jsx(Pe,{content:d,label:e.jsxs("span",{className:"flex items-center gap-2",children:["COPY PROMPT",e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),e.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})]}),copiedLabel:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"invisible",children:"COPY PROMPT"}),e.jsx("span",{className:"absolute inset-0 flex items-center justify-center",children:"COPIED!"}),e.jsx("span",{className:"invisible",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",children:e.jsx("rect",{x:"9",y:"9",width:"13",height:"13"})})})]}),className:"relative text-xs font-semibold text-[#1e1e1e] bg-[#E0D400] hover:bg-[#E0D400]/80 border-none rounded px-4 py-2 cursor-pointer transition-colors shrink-0 tracking-wide font-['IBM_Plex_Mono']"})]})})}function ar({focusedEntity:t,breadcrumbItems:s,onZoomChange:r,projectRoot:n,scenarios:l,analyzedEntities:i,activeScenarioId:o,onScenarioSelect:d,onAnalyzedScenarioSelect:c,onSwitchToBuild:b,entityImports:p,glossaryFunctions:h,cachedTestResults:g={},glossaryEntries:M,entityShaMap:w,componentGroups:u,visualEntities:y,isEntityComplete:C,onReseedPreview:I}){var Q;const $=t.filePath,B=t.name,[H,P]=a.useState("scenarios"),[J,_]=a.useState(null),[O,E]=a.useState(""),[v,L]=a.useState(!1),[W,U]=a.useState(null),[k,F]=a.useState(!1),[D,f]=a.useState(!1),[S,j]=a.useState(null);a.useEffect(()=>{P("scenarios"),_(null),F(!1),f(!1),j(null)},[t.sha]);const A=a.useMemo(()=>{const m=new Map;for(const z of h)m.set(z.name,z);return m},[h]),R=i.some(m=>m.sha===t.sha||m.filePath===$),Y=!!((Q=p==null?void 0:p[B])!=null&&Q.length),Z=a.useCallback(async m=>{if(!(!O.trim()||v)){L(!0);try{(await fetch("/api/editor-rename-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioId:m,name:O.trim()})})).ok&&_(null)}catch{}finally{L(!1)}}},[O,v]),se=a.useCallback(async m=>{if(confirm(`Delete scenario "${m.name}"?`)){U(m.id);try{const z=m.screenshotPaths?Object.values(m.screenshotPaths):m.screenshotPath?[m.screenshotPath]:[];await fetch("/api/delete-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioId:m.id,screenshotPaths:z})})}catch{}finally{U(null)}}},[]);if(!R&&!Y){const m=l.filter(G=>G.entitySha===t.sha),z=[`The "${t.displayName}" entity (${$}) exists in the database but has not been fully analyzed. Its components and functions cannot be shown until it has import metadata.`,"","Follow these steps:","",`Step 1: Add "${B}" to the glossary if it's not already there:`,` Check: cat .codeyam/glossary.json | grep "${B}"`,"",` If not found, add an entry with name "${B}" and filePath "${$}" to .codeyam/glossary.json`,"","Step 2: Run import analysis:"," codeyam editor analyze-imports","","Step 3: Reload the editor page and verify components/functions appear."].join(`
12
+ `);return e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>{if(s.length>1){const G=s[s.length-2];r(G.componentName,G.entitySha)}else r()},className:"text-gray-400 hover:text-white transition-colors cursor-pointer bg-transparent border-none p-0 shrink-0 text-lg",title:"Go back",children:"←"}),e.jsx("h2",{className:"text-lg font-medium text-white m-0 font-['IBM_Plex_Sans']",children:t.displayName})]}),$&&e.jsx(xt,{filePath:$,projectRoot:n}),e.jsxs("div",{className:"py-2",children:[e.jsx("p",{className:"text-[11px] text-amber-400/80 m-0 leading-relaxed",children:"This entity has not been fully analyzed. Its components and functions cannot be displayed. Please copy and paste this prompt into Claude to fix the data."}),e.jsx("div",{className:"mt-2",children:e.jsx(Pe,{content:z,label:"Copy Fix Prompt",copiedLabel:"Copied!",className:"text-[10px] text-amber-400 hover:text-amber-300 bg-transparent border border-amber-400/30 rounded px-2 py-1 cursor-pointer transition-colors"})})]}),m.length>0&&e.jsx("div",{className:"grid grid-cols-3 gap-2",children:Se(m).map(({scenario:G,dimensionLabel:X,screenshotPath:de,key:ye})=>e.jsx(mt,{scenarioId:G.id,screenshotPath:de,updatedAt:G.updatedAt,hasScreenshot:!!de,name:G.name,dimensionLabel:X,isActive:G.id===o,onSelect:()=>d(G,X??void 0)},ye))})]})})}const K=t.sha,ae=l.filter(m=>!m.componentName&&(m.pageFilePath===$||K&&m.entitySha===K)),pe=l.filter(m=>m.componentName===B||m.componentPath===$),ie=y.find(m=>m.filePath===$||m.name===B),le=A.get(B)||h.find(m=>m.filePath===$),me=[...ae,...pe],Te=a.useMemo(()=>{const m=[];if(m.push(`# Create a New Scenario for "${t.displayName}"`),m.push(""),m.push(`**Entity**: ${t.displayName}`),m.push(`**Type**: ${t.entityType}`),m.push(`**File**: ${$}`),m.push(""),me.length>0){m.push("## Existing Scenarios");for(const z of me)m.push(`- **${z.name}**${z.url?` — URL: ${z.url}`:""}`);m.push("")}return m.push("## Your Task"),m.push("Ask the user what scenario they would like to create. Offer two options:"),m.push("1. **Describe a scenario** — the user tells you what they want and you create it"),m.push("2. **Analyze gaps** — you review the existing scenarios and source code to suggest scenarios that would improve coverage"),m.push(""),m.push("Once you know what scenario to create, use the `codeyam editor register` CLI command to register it. Write the scenario JSON to `.codeyam/tmp/scenario.json` first, then run `codeyam editor register @.codeyam/tmp/scenario.json`."),m.join(`
13
+ `)},[t.displayName,t.entityType,$,me]),ge=new Set((p==null?void 0:p[B])||[]),ce=Y?[...u.entries()].filter(([m])=>ge.has(m)):[],be=Y?y.filter(m=>ge.has(m.name)&&!ce.some(([z])=>z===m.name)):[],ne=Y?M.filter(m=>ge.has(m.name)&&m.returnType!=="JSX.Element"&&m.returnType!=="React.ReactNode").map(m=>({name:m.name,filePath:m.filePath,description:m.description||"",testFile:m.testFile,feature:m.feature})):[],je=ce.length>0||be.length>0,V=ne.length>0;return e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsxs("div",{className:"p-5",children:[e.jsxs("div",{className:"mb-5",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("button",{onClick:()=>{if(s.length>1){const m=s[s.length-2];r(m.componentName,m.entitySha)}else r()},className:"text-gray-400 hover:text-white transition-colors cursor-pointer bg-transparent border-none p-0 shrink-0 text-xl",title:"Go back",children:"←"}),e.jsx("h2",{className:"text-xl font-medium text-white m-0 font-['IBM_Plex_Sans']",children:t.displayName})]}),t.filePath&&e.jsx("div",{className:"mt-1.5 ml-7",children:e.jsx(xt,{filePath:t.filePath,projectRoot:n})})]}),e.jsx("div",{className:"-mx-5 px-5 border-t border-b border-[#3d3d3d] flex items-center gap-6",children:[["scenarios","Scenarios"],["components","Components"],["functions","Functions"],["data-structure","Data Structure"]].map(([m,z])=>e.jsx("button",{onClick:()=>P(m),className:`text-xs font-normal uppercase tracking-wider transition-colors bg-transparent border-none cursor-pointer px-0 font-['IBM_Plex_Mono'] border-b-2 leading-none ${H===m?"text-[#D7FF63] border-b-[#D7FF63]":"text-gray-500 hover:text-gray-300 border-b-transparent"}`,style:{marginBottom:-1,paddingTop:16,paddingBottom:14},children:z},m))}),H==="scenarios"&&e.jsxs("div",{className:"space-y-3 mt-5",children:[me.map(m=>{const z=m.id===o,G=J===m.id;return e.jsxs("div",{children:[e.jsxs("div",{onClick:()=>{G||d(m)},className:`flex items-center gap-4 p-3 rounded-lg cursor-pointer transition-colors ${z?"bg-[#1a2e1a] border border-[#D7FF63]/40":"bg-[#252525] hover:bg-[#2a2a2a] border border-transparent"}`,style:{opacity:W===m.id?.4:1},children:[m.screenshotPaths&&Object.keys(m.screenshotPaths).length>1?e.jsx("div",{className:"flex gap-2 shrink-0",children:Object.entries(m.screenshotPaths).map(([X,de])=>e.jsxs("div",{className:"relative",children:[e.jsx(ze,{scenarioId:m.id,screenshotPath:de,updatedAt:m.updatedAt,alt:X,className:"rounded w-[120px] h-[75px] overflow-hidden border border-[#3d3d3d]",imgClassName:"w-full h-full object-cover"}),e.jsx("span",{className:"absolute bottom-1 right-1 text-[8px] font-medium bg-black/60 text-white px-1 py-0.5 rounded",children:X})]},X))}):m.screenshotPath?e.jsx(ze,{scenarioId:m.id,screenshotPath:m.screenshotPath,updatedAt:m.updatedAt,alt:"",className:"rounded w-[160px] h-[100px] shrink-0 overflow-hidden border border-[#3d3d3d]",imgClassName:"w-full h-full object-cover"}):e.jsx("div",{className:"rounded bg-[#1a1a1a] w-[160px] h-[100px] shrink-0 flex items-center justify-center border border-[#3d3d3d]",children:e.jsx("span",{className:"text-[10px] text-gray-600",children:"No image"})}),e.jsx("div",{className:"flex-1 min-w-0",children:G?e.jsxs("form",{className:"flex items-center gap-1.5",onSubmit:X=>{X.preventDefault(),Z(m.id)},onClick:X=>X.stopPropagation(),children:[e.jsx("input",{type:"text",value:O,onChange:X=>E(X.target.value),className:"flex-1 px-2 py-1 text-xs bg-[#1e1e1e] text-white border border-[#3d3d3d] rounded outline-none focus:border-[#005c75] min-w-0",autoFocus:!0,disabled:v}),e.jsx("button",{type:"submit",disabled:v||!O.trim(),className:"px-2 py-1 text-[10px] bg-[#005c75] text-white rounded hover:bg-[#004d63] disabled:opacity-40 cursor-pointer border-none",children:v?"...":"Save"}),e.jsx("button",{type:"button",onClick:()=>_(null),className:"px-2 py-1 text-[10px] text-gray-400 hover:text-white cursor-pointer bg-transparent border-none",children:"Cancel"})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-xs text-gray-300 truncate block",children:m.name}),z&&e.jsxs("div",{className:"flex items-center gap-3 mt-1.5",children:[e.jsx("button",{onClick:X=>{X.stopPropagation(),j(S===m.id?null:m.id)},className:"text-[10px] text-[#D7FF63] hover:text-[#D7FF63]/70 cursor-pointer bg-transparent border-none p-0",children:"View Data"}),e.jsx("button",{onClick:X=>{X.stopPropagation(),f(!1),F(!0)},className:"text-[10px] text-gray-400 hover:text-white cursor-pointer bg-transparent border-none p-0",children:"Edit with Claude"}),e.jsx("button",{onClick:X=>{X.stopPropagation(),_(m.id),E(m.name)},className:"text-[10px] text-gray-400 hover:text-white cursor-pointer bg-transparent border-none p-0",children:"Rename"}),e.jsx("button",{onClick:X=>{X.stopPropagation(),se(m)},disabled:W===m.id,className:"text-[10px] text-red-400/60 hover:text-red-400 cursor-pointer bg-transparent border-none p-0",children:"Delete"})]})]})})]}),S===m.id&&e.jsx(Kn,{scenarioId:m.id,onClose:()=>j(null),editPrompt:Bs(t.displayName,t.filePath,t.entityType,me),onReseedPreview:I})]},m.id)}),ie&&(ie.scenarios.length>0||ie.pendingScenarios.length>0)&&e.jsxs("div",{className:"space-y-1 mt-2",children:[ie.scenarios.map(m=>e.jsxs("div",{onClick:()=>c({analysisId:ie.analysisId,scenarioId:m.id,scenarioName:m.name,entitySha:ie.sha,entityName:ie.name}),className:"flex items-center gap-3 p-2 rounded cursor-pointer transition-colors hover:bg-[#252525] border border-transparent",children:[m.screenshotPath?e.jsx("img",{src:`/api/screenshot/${m.screenshotPath}`,alt:m.name,className:"rounded w-[48px] h-[48px] shrink-0 object-cover",loading:"lazy"}):e.jsx("div",{className:"rounded bg-[#1a1a1a] w-[48px] h-[48px] shrink-0 flex items-center justify-center",children:e.jsx("span",{className:"text-[8px] text-gray-600",children:"No img"})}),e.jsx("span",{className:"text-xs text-gray-300 truncate",children:m.name})]},m.id)),ie.pendingScenarios.map(m=>e.jsxs("div",{className:"flex items-center gap-3 p-2",children:[e.jsx("div",{className:"rounded bg-[#1a1a1a] w-[48px] h-[48px] shrink-0 flex items-center justify-center",children:e.jsx("span",{className:"text-[8px] text-gray-600",children:"..."})}),e.jsx("span",{className:"text-xs text-gray-500 truncate",children:m})]},m))]}),me.length===0&&!ie&&!le&&e.jsx("div",{className:"text-xs text-gray-500 py-2",children:"No scenarios for this entity"}),e.jsxs("button",{onClick:()=>{F(!1),f(!0)},className:"flex items-center gap-2.5 mt-4 text-xs text-[#D7FF63] hover:text-[#D7FF63]/70 bg-transparent border-none cursor-pointer p-0 font-normal uppercase tracking-wider font-['IBM_Plex_Mono'] transition-colors",children:[e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"16"}),e.jsx("line",{x1:"8",y1:"12",x2:"16",y2:"12"})]}),"Create New Scenario"]}),D&&e.jsx("div",{className:"mt-2 border border-[#3d3d3d] rounded-lg overflow-hidden",children:e.jsx(De,{prompt:Te,height:500,onClose:()=>f(!1)})}),k&&me.length>0&&e.jsx("div",{className:"mt-2 border border-[#3d3d3d] rounded-lg overflow-hidden",children:e.jsx(De,{prompt:Bs(t.displayName,t.filePath,t.entityType,me),height:500,onClose:()=>F(!1)})})]}),H==="components"&&e.jsx("div",{className:"space-y-3",children:je?e.jsxs(e.Fragment,{children:[ce.map(([m,z])=>e.jsx("div",{children:w.has(m)?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"py-1",children:e.jsx("button",{onClick:()=>r(m,w.get(m)),className:"text-[11px] font-medium text-gray-400 cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:m})}),z.length>0&&e.jsx("div",{className:"grid grid-cols-3 gap-2 pt-1",children:Se(z).map(({scenario:G,dimensionLabel:X,screenshotPath:de,key:ye})=>e.jsx(mt,{scenarioId:G.id,screenshotPath:de,updatedAt:G.updatedAt,hasScreenshot:!!de,name:G.name,dimensionLabel:X,isActive:G.id===o,onSelect:()=>d(G,X??void 0)},ye))})]}):e.jsxs("div",{className:"py-2",children:[e.jsx("span",{className:"text-[11px] font-medium text-gray-500",children:m}),e.jsx("p",{className:"text-[10px] text-amber-400/80 m-0 mt-1.5 leading-relaxed",children:"There is data missing that is required to show the scenarios for this component. Please copy and paste this prompt into Claude to ask Claude to fix the data."}),e.jsx("div",{className:"mt-1.5",children:e.jsx(nr,{name:m,scenarios:z})})]})},m)),be.map(m=>e.jsxs("div",{children:[e.jsx("div",{className:"py-1",children:e.jsx("button",{onClick:()=>r(m.name,m.sha),className:"text-[11px] font-medium text-gray-400 cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:m.name})}),(m.scenarios.length>0||m.pendingScenarios.length>0)&&e.jsxs("div",{className:"grid grid-cols-3 gap-2 pt-1",children:[m.scenarios.map(z=>e.jsx(mt,{imgSrc:z.screenshotPath?`/api/screenshot/${z.screenshotPath}`:null,name:z.name,isActive:!1,onSelect:()=>c({analysisId:m.analysisId,scenarioId:z.id,scenarioName:z.name,entitySha:m.sha,entityName:m.name})},z.id)),m.pendingScenarios.map(z=>e.jsx("div",{className:"px-2.5 py-1 bg-[#2a2a2a] text-gray-400 text-[10px] rounded-full",title:z,children:z},z))]})]},m.sha))]}):e.jsx("div",{className:"text-xs text-gray-500 py-2",children:"No component dependencies"})}),H==="functions"&&e.jsxs("div",{className:"space-y-3",children:[le&&le.testFile&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[10px] text-gray-500",children:"Tests:"}),e.jsx(xt,{filePath:le.testFile,projectRoot:n})]}),e.jsx(Wt,{testFile:le.testFile,entityName:B,cachedResult:g[le.testFile]})]}),V?e.jsx("div",{children:ne.map(m=>e.jsxs("div",{className:"mt-2",children:[e.jsx("div",{className:"py-1",children:e.jsx("button",{onClick:()=>r(m.name,w.get(m.name)),className:"text-[11px] font-medium text-gray-400 cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:m.name})}),e.jsx(xt,{filePath:m.filePath,projectRoot:n}),m.testFile&&e.jsxs("div",{className:"mt-0.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[9px] text-gray-600",children:"test:"}),e.jsx("span",{className:"text-[9px] text-gray-500 truncate",children:m.testFile})]}),e.jsx(Wt,{testFile:m.testFile,entityName:m.name,cachedResult:g[m.testFile]})]})]},m.name))}):le!=null&&le.testFile?null:e.jsx("div",{className:"text-xs text-gray-500 py-2",children:"No function dependencies"})]}),H==="data-structure"&&e.jsx(Jn,{})]})})}function Kn({scenarioId:t,onClose:s,editPrompt:r,onReseedPreview:n}){const[l,i]=a.useState(null),[o,d]=a.useState([]),[c,b]=a.useState(!0),[p,h]=a.useState(null),[g,M]=a.useState(null),[w,u]=a.useState(!1),[y,C]=a.useState(null),[I,$]=a.useState(""),[B,H]=a.useState(""),[P,J]=a.useState(0),[_,O]=a.useState(!1),[E,v]=a.useState(!1),L=a.useRef(null);if(a.useEffect(()=>{b(!0),h(null),Promise.all([fetch("/api/editor-schema").then(j=>j.json()).catch(()=>({models:[]})),fetch(`/api/editor-scenario-data?scenarioId=${t}`).then(j=>j.json())]).then(([j,A])=>{const R=j.source==="explicit"?On(j.dataStructures||[],A):Ln(j.models||[],A);i(R.data),d(R.tabs),R.tabs.length>0&&!g&&M(R.tabs[0].dataKey)}).catch(()=>h("Failed to load scenario data")).finally(()=>b(!1))},[t,P]),c)return e.jsx("div",{className:"mt-1 mb-1 border border-[#3d3d3d] rounded-lg p-4 text-xs text-gray-400",children:"Loading mock data..."});if(p||!l)return e.jsx("div",{className:"mt-1 mb-1 border border-[#3d3d3d] rounded-lg p-4 text-xs text-red-400",children:p||"No data available"});if(o.length===0)return e.jsxs("div",{className:"mt-1 mb-1 border border-[#3d3d3d] rounded-lg p-4 text-xs text-gray-500",children:["No mock data found for this scenario.",e.jsx("button",{onClick:s,className:"ml-2 text-gray-400 hover:text-white bg-transparent border-none cursor-pointer text-[10px]",children:"Dismiss"})]});const W=o.find(j=>j.dataKey===g)||o[0],U=g?l[g]||[]:[],k=In(U,W.schemaFields),F=An(k,U,W.schemaFields),D=Rn(k,W.schemaFields);return e.jsxs("div",{className:"mt-1 mb-1 border border-[#3d3d3d] rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1.5 bg-[#252525] border-b border-[#3d3d3d] flex-wrap",children:[o.map(j=>{const A=g===j.dataKey,R=j.category==="datastore"?A?"text-[#D7FF63] bg-[#D7FF63]/15 border-[#D7FF63]/40":"text-[#D7FF63]/60 bg-transparent border-transparent hover:text-[#D7FF63]/80":j.category==="mock-api"?A?"text-blue-400 bg-blue-400/15 border-blue-400/40":"text-blue-400/60 bg-transparent border-transparent hover:text-blue-400/80":A?"text-white bg-[#3d3d3d] border-[#4d4d4d]":"text-gray-500 bg-transparent border-transparent hover:text-gray-300";return e.jsx("button",{onClick:()=>M(j.dataKey),className:`px-2.5 py-0.5 text-[10px] font-semibold uppercase tracking-wider rounded cursor-pointer border transition-colors ${R}`,children:j.label},j.dataKey)}),e.jsx("div",{className:"flex-1"}),e.jsx("button",{onClick:s,className:"w-5 h-5 flex items-center justify-center text-gray-500 hover:text-white bg-[#3d3d3d] hover:bg-[#4d4d4d] rounded-full border-none cursor-pointer text-xs transition-colors",title:"Close",children:"×"})]}),(W.description||W.category)&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-[#1e1e1e] border-b border-[#2d2d2d]",children:[W.category&&e.jsx("span",{className:`text-[9px] rounded px-1.5 py-0 border ${W.category==="datastore"?"text-[#D7FF63]/80 bg-[#D7FF63]/10 border-[#D7FF63]/30":W.category==="mock-api"?"text-blue-400/80 bg-blue-400/10 border-blue-400/30":"text-gray-400 bg-gray-700/30 border-gray-600/30"}`,children:W.category==="mock-api"?"API Mock":W.category}),W.description&&e.jsx("span",{className:"text-[10px] text-gray-500",children:W.description})]}),k.length===0?e.jsx("div",{className:"px-3 py-4 text-[10px] text-gray-500 text-center",children:"No columns defined for this table"}):e.jsx("div",{className:"overflow-x-auto max-h-[300px] overflow-y-auto",children:e.jsxs("table",{className:"w-full text-[10px] border-collapse table-fixed",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-[#1e1e1e] sticky top-0 z-10",children:[e.jsx("th",{className:"text-right text-gray-600 font-normal px-2 py-1.5 border-b border-[#3d3d3d] w-8",children:"#"}),k.map(j=>e.jsxs("th",{className:"text-left px-2 py-1.5 border-b border-[#3d3d3d] whitespace-nowrap overflow-hidden",children:[j===D&&e.jsx("span",{className:"inline-block text-[8px] font-bold text-white bg-[#D7FF63] rounded px-1 py-0 mr-1.5 align-middle",children:"PK"}),e.jsx("span",{className:"text-gray-300 font-medium",children:j}),e.jsx("span",{className:"text-gray-600 font-normal ml-1",children:F[j]})]},j))]})}),e.jsx("tbody",{children:U.map((j,A)=>e.jsxs("tr",{className:"border-b border-[#2d2d2d] hover:bg-[#252525] group/row",children:[e.jsx("td",{className:"text-right text-gray-600 px-2 py-1.5 w-8 select-none",children:A+1}),k.map(R=>e.jsxs("td",{className:`px-2 py-1.5 overflow-hidden relative group/cell ${R===D?"text-[#D7FF63] font-medium":"text-gray-300"}`,title:String(j[R]??""),children:[e.jsx("span",{className:"truncate block whitespace-nowrap",children:j[R]===null?e.jsx("span",{className:"text-gray-600 italic",children:"null"}):typeof j[R]=="object"?e.jsx("span",{className:"text-gray-500",children:JSON.stringify(j[R])}):typeof j[R]=="number"?e.jsx("span",{className:"text-amber-400",children:String(j[R])}):String(j[R])}),e.jsx("button",{onClick:Y=>{Y.stopPropagation(),C({row:A,col:R});const Z=j[R]===null?"":typeof j[R]=="object"?JSON.stringify(j[R]):String(j[R]);$(Z),H(Z)},className:"absolute right-1 top-1/2 -translate-y-1/2 opacity-0 group-hover/cell:opacity-100 text-gray-500 hover:text-white bg-[#252525] border border-[#4d4d4d] rounded cursor-pointer p-0.5 transition-opacity",title:"Edit",children:e.jsxs("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),e.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})})]},R))]},A))})]})}),y&&e.jsxs("div",{className:"border-t border-[#3d3d3d] bg-[#1e1e1e] px-3 py-2",children:[e.jsx("div",{className:"flex items-center gap-2 mb-1.5",children:e.jsxs("span",{className:"text-[10px] text-gray-400",children:["Editing"," ",e.jsx("strong",{className:"text-gray-200",children:y.col})," in row ",y.row+1]})}),e.jsx("textarea",{value:I,onChange:j=>{const A=j.target.value;$(A),L.current&&clearTimeout(L.current),L.current=setTimeout(()=>{S(W.dataKey,y.row,y.col,A)},600)},className:"w-full px-2 py-1.5 text-[11px] bg-[#252525] text-white border border-[#4d4d4d] rounded outline-none focus:border-[#D7FF63]/50 resize-y min-h-[60px] max-h-[200px] font-mono",autoFocus:!0,rows:I.length>100?4:2,onKeyDown:j=>{j.key==="Escape"&&f(),j.key==="Enter"&&(j.metaKey||j.ctrlKey)&&(L.current&&clearTimeout(L.current),S(W.dataKey,y.row,y.col,I),C(null))}}),e.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[e.jsx("button",{onClick:()=>{L.current&&clearTimeout(L.current),S(W.dataKey,y.row,y.col,I),C(null)},className:"px-3 py-1 text-[10px] font-medium text-[#1e1e1e] bg-[#D7FF63] rounded cursor-pointer border-none hover:bg-[#D7FF63]/80 transition-colors",children:"Save"}),e.jsx("button",{onClick:()=>f(),className:"px-3 py-1 text-[10px] text-gray-400 hover:text-white bg-transparent border-none cursor-pointer",children:"Cancel"}),e.jsxs("span",{className:"text-[9px] text-gray-600 ml-auto",children:["⌘","+Enter to save, Esc to cancel"]})]})]}),_&&!y&&e.jsxs("div",{className:"border-t border-[#3d3d3d] bg-amber-500/5 px-3 py-2 flex items-center gap-2",children:[e.jsx("span",{className:"text-[10px] text-amber-400/80",children:"Data modified — recapture to update the screenshot"}),e.jsx("div",{className:"flex-1"}),e.jsx("button",{onClick:()=>{v(!0),Promise.resolve().then(()=>(n&&n(),new Promise(j=>setTimeout(j,2e3)))).then(()=>fetch("/api/editor-capture-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioId:t})})).then(()=>O(!1)).catch(()=>{}).finally(()=>v(!1))},disabled:E,className:"px-3 py-1 text-[10px] font-medium text-white bg-amber-600 rounded cursor-pointer border-none hover:bg-amber-500 disabled:opacity-50 transition-colors",children:E?"Recapturing...":"Recapture Screenshot"})]}),r&&e.jsxs("div",{className:"border-t border-[#3d3d3d]",children:[e.jsx("div",{className:"flex justify-center py-2",children:e.jsx("button",{onClick:()=>u(!w),className:"px-3 py-1 text-[10px] font-medium text-[#D7FF63] border border-[#D7FF63]/40 rounded cursor-pointer transition-colors hover:bg-[#D7FF63]/10 bg-transparent",children:w?"Hide Claude":"Edit with Claude"})}),w&&e.jsx("div",{className:"border-t border-[#3d3d3d]",children:e.jsx(De,{prompt:r,height:400,onClose:()=>{u(!1),J(j=>j+1)}})})]})]});function f(){if(L.current&&clearTimeout(L.current),!!y){if(I!==B){if(l&&g){const j=l[g];if(j&&j[y.row]){let A=B;B===""?A="":B==="null"?A=null:B==="true"?A=!0:B==="false"?A=!1:isNaN(Number(B))||(A=Number(B));const R=[...j];R[y.row]={...R[y.row],[y.col]:A},i({...l,[g]:R})}}fetch("/api/editor-save-scenario-data",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioId:t,table:W.dataKey,rowIndex:y.row,column:y.col,value:B})}).then(()=>{n&&n()}).catch(()=>{})}C(null),O(!1)}}async function S(j,A,R,Y){if(l&&g){const Z=l[g];if(Z&&Z[A]){let se=Y;Y==="null"?se=null:Y==="true"?se=!0:Y==="false"?se=!1:Y!==""&&!isNaN(Number(Y))&&(se=Number(Y));const K=[...Z];K[A]={...K[A],[R]:se},i({...l,[g]:K})}}O(!0);try{await fetch("/api/editor-save-scenario-data",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioId:t,table:j,rowIndex:A,column:R,value:Y})}),n&&n()}catch{}}}function Jn(){const[t,s]=a.useState([]),[r,n]=a.useState([]),[l,i]=a.useState(!0),[o,d]=a.useState(null),[c,b]=a.useState(!1),[p,h]=a.useState(null);if(a.useEffect(()=>{fetch("/api/editor-schema").then(u=>u.json()).then(u=>{var y,C;h(u.source||null),u.source==="explicit"?(n(u.dataStructures||[]),((y=u.dataStructures)==null?void 0:y.length)>0&&d(u.dataStructures[0].name)):(s(u.models||[]),((C=u.models)==null?void 0:C.length)>0&&d(u.models[0].name))}).catch(()=>{}).finally(()=>i(!1))},[]),l)return e.jsx("div",{className:"text-xs text-gray-400 py-4",children:"Loading schema..."});if(!(p==="explicit"?r.length>0:t.length>0))return e.jsx("div",{className:"text-xs text-gray-500 py-4",children:"No data structure found. Use the chat below to have Claude analyze your codebase and generate one."});const M=p==="explicit"?qn(r):Yn(t,p);return p==="explicit"?e.jsxs("div",{className:"space-y-2",children:[r.map(u=>{const y=o===u.name,C=u.category==="datastore"?"text-[#D7FF63]/80 bg-[#D7FF63]/10 border border-[#D7FF63]/30":u.category==="mock-api"?"text-blue-400/80 bg-blue-400/10 border border-blue-400/30":"text-gray-400 bg-gray-700/30 border border-gray-600/30";return e.jsxs("div",{className:"border border-[#3d3d3d] rounded-lg overflow-hidden",children:[e.jsxs("button",{onClick:()=>d(y?null:u.name),className:"w-full flex items-center gap-2 px-3 py-2 bg-[#252525] text-left cursor-pointer border-none transition-colors hover:bg-[#2a2a2a]",children:[e.jsx("svg",{className:`text-gray-500 transition-transform shrink-0 ${y?"rotate-90":""}`,width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M9 18l6-6-6-6"})}),e.jsx("span",{className:"text-xs font-semibold text-gray-200",children:u.name}),u.order===1&&e.jsx("span",{className:"text-[9px] text-amber-400/70",children:"Primary"}),e.jsx("span",{className:`text-[9px] rounded px-1.5 py-0 ${C}`,children:u.category==="mock-api"?"API Mock":u.category}),e.jsxs("span",{className:"text-[10px] text-gray-500",children:[u.fields.length," fields"]})]}),y&&e.jsxs("div",{className:"border-t border-[#3d3d3d]",children:[u.description&&e.jsx("div",{className:"px-3 py-1.5 text-[10px] text-gray-400 border-b border-[#2d2d2d]",children:u.description}),e.jsx("table",{className:"w-full text-[10px]",children:e.jsx("tbody",{children:u.fields.map(I=>e.jsxs("tr",{className:"border-b border-[#2d2d2d] last:border-b-0",children:[e.jsxs("td",{className:"px-3 py-1.5 text-gray-300 font-medium w-1/3",children:[I.isId&&e.jsx("span",{className:"text-amber-400 mr-1",title:"Primary key",children:"•"}),I.name]}),e.jsx("td",{className:"px-3 py-1.5 text-gray-500",children:I.type}),e.jsx("td",{className:"px-3 py-1.5 text-gray-600 w-16 text-right",children:I.required===!1?"optional":""})]},I.name))})})]})]},u.name)}),e.jsx("div",{className:"flex justify-center pt-2",children:e.jsx("button",{onClick:()=>b(!c),className:"px-4 py-1.5 text-[11px] font-medium text-[#D7FF63] border border-[#D7FF63]/40 rounded-lg cursor-pointer transition-colors hover:bg-[#D7FF63]/10 bg-transparent",children:c?"Hide Chat":"Chat with Claude about the Data Structure"})}),c&&e.jsx("div",{className:"border border-[#3d3d3d] rounded-lg overflow-hidden",children:e.jsx(De,{prompt:M,height:500,onClose:()=>b(!1)})})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(Gn,{prompt:`Analyze this codebase and generate a .codeyam/data-structure.json file that describes the app's data structures.
14
+
15
+ The file should be a JSON array where each entry has:
16
+ - "name": display name for the data structure
17
+ - "description": what this data represents and how it's used
18
+ - "category": either "datastore" (persisted data like DB tables, localStorage) or "mock-api" (mocked external API responses)
19
+ - "order": integer for display order (1 = primary/most important)
20
+ - "fields": array of { "name", "type", "isId" (boolean), "required" (boolean) }
21
+
22
+ Look at:
23
+ - Database schemas (prisma/schema.prisma, SQLite, etc.)
24
+ - TypeScript interfaces/types used for stored data
25
+ - localStorage usage patterns
26
+ - API response types that need mocking
27
+ - Do NOT include types that are only used as component props
28
+
29
+ Write the file to .codeyam/data-structure.json.`}),t.map(u=>{const y=o===u.name,C=u.fields.filter($=>$.isRelation),I=u.fields.filter($=>!$.isRelation);return e.jsxs("div",{className:"border border-[#3d3d3d] rounded-lg overflow-hidden",children:[e.jsxs("button",{onClick:()=>d(y?null:u.name),className:"w-full flex items-center gap-2 px-3 py-2 bg-[#252525] text-left cursor-pointer border-none transition-colors hover:bg-[#2a2a2a]",children:[e.jsx("svg",{className:`text-gray-500 transition-transform ${y?"rotate-90":""}`,width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M9 18l6-6-6-6"})}),e.jsx("span",{className:"text-xs font-semibold text-gray-200",children:u.name}),e.jsxs("span",{className:"text-[10px] text-gray-500",children:[I.length," fields"]}),C.length>0&&e.jsxs("span",{className:"text-[10px] text-[#D7FF63]/70",children:[C.length," relation",C.length>1?"s":""]})]}),y&&e.jsx("div",{className:"border-t border-[#3d3d3d]",children:e.jsx("table",{className:"w-full text-[10px]",children:e.jsxs("tbody",{children:[I.map($=>e.jsxs("tr",{className:"border-b border-[#2d2d2d] last:border-b-0",children:[e.jsxs("td",{className:"px-3 py-1.5 text-gray-300 font-medium w-1/3",children:[$.isId&&e.jsx("span",{className:"text-amber-400 mr-1",title:"Primary key",children:"•"}),$.name]}),e.jsxs("td",{className:"px-3 py-1.5 text-gray-500",children:[$.type,$.isOptional&&"?",$.isList&&"[]"]})]},$.name)),C.length>0&&e.jsx("tr",{children:e.jsxs("td",{colSpan:2,className:"px-3 py-1.5 border-t border-[#3d3d3d]",children:[e.jsx("span",{className:"text-[9px] text-gray-500 uppercase tracking-wider",children:"Relations"}),e.jsx("div",{className:"mt-1 flex flex-wrap gap-1.5",children:C.map($=>e.jsx("button",{onClick:()=>d($.relatedModel??null),className:"text-[10px] text-[#D7FF63] hover:text-[#D7FF63]/80 bg-[#D7FF63]/10 border border-[#D7FF63]/30 rounded px-1.5 py-0.5 cursor-pointer transition-colors",children:$.isList?`${$.relatedModel}[]`:$.relatedModel},$.name))})]})})]})})})]},u.name)}),e.jsx("div",{className:"flex justify-center pt-2",children:e.jsx("button",{onClick:()=>b(!c),className:"px-4 py-1.5 text-[11px] font-medium text-[#D7FF63] border border-[#D7FF63]/40 rounded-lg cursor-pointer transition-colors hover:bg-[#D7FF63]/10 bg-transparent",children:c?"Hide Chat":"Chat with Claude about the Data Structure"})}),c&&e.jsx("div",{className:"border border-[#3d3d3d] rounded-lg overflow-hidden",children:e.jsx(De,{prompt:M,height:500,onClose:()=>b(!1)})})]})}function Gn({prompt:t}){const[s,r]=a.useState(!1),[n,l]=a.useState(()=>typeof window>"u"?!1:localStorage.getItem("codeyam-ds-migration-dismissed")==="1");return n?null:e.jsxs("div",{className:"relative border border-amber-500/30 bg-amber-500/5 rounded-lg p-3 pr-8",children:[e.jsx("button",{onClick:()=>{l(!0),localStorage.setItem("codeyam-ds-migration-dismissed","1")},className:"absolute top-2 right-2 text-gray-500 hover:text-white bg-transparent border-none cursor-pointer p-0.5",title:"Dismiss",children:e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:e.jsx("path",{d:"M2 2l8 8M10 2l-8 8"})})}),e.jsx("p",{className:"text-[11px] text-amber-400/90 m-0 font-['IBM_Plex_Sans'] leading-relaxed",children:"This data structure was auto-detected. For better results, ask Claude to generate an explicit data structure config."}),e.jsx("button",{onClick:()=>{navigator.clipboard.writeText(t),r(!0),setTimeout(()=>r(!1),2e3)},className:"mt-2 px-3 py-1 text-[10px] font-medium text-amber-400 border border-amber-500/40 rounded cursor-pointer transition-colors hover:bg-amber-500/10 bg-transparent",children:s?"Copied!":"Copy prompt for Claude"})]})}function Yn(t,s){const r=t.map(l=>{const i=l.fields.map(o=>{let d=` ${o.name}: ${o.type}`;return o.isList&&(d+="[]"),o.isOptional&&(d+=" (optional)"),o.isId&&(d+=" [PK]"),o.isRelation&&(d+=` → ${o.relatedModel}`),d}).join(`
30
+ `);return`${l.name}:
31
+ ${i}`}).join(`
32
+
33
+ `);return`You are helping the user understand and modify the data structure of their application.
34
+
35
+ ${s==="prisma"?"The data structure is defined in `prisma/schema.prisma`.":s==="typescript"?"The data structure is defined via TypeScript interfaces in the `src/` directory.":"The data structure was inferred from the project."}
36
+
37
+ Here is the current data structure:
38
+
39
+ ${r}
40
+
41
+ Wait for the user to tell you what they want to do. They might want to:
42
+ - Add new models/tables
43
+ - Add or modify fields on existing models
44
+ - Understand relationships between models
45
+ - Get advice on data modeling
46
+ - Generate or modify seed data for scenarios
47
+
48
+ When making changes:
49
+ ${s==="prisma"?"- Edit `prisma/schema.prisma` directly":"- Edit the TypeScript interface files in `src/`"}
50
+ - After schema changes, update any affected scenario seed data
51
+ - Explain the impact of changes on existing data
52
+
53
+ Do NOT start making changes until the user tells you what they want.`}function qn(t){return`You are helping the user understand and modify the data structure of their application.
54
+
55
+ The data structure is explicitly defined in \`.codeyam/data-structure.json\`.
56
+
57
+ Here is the current data structure:
58
+
59
+ ${t.map(r=>{const n=r.category==="datastore"?"[datastore]":r.category==="mock-api"?"[mock-api]":`[${r.category}]`,l=r.fields.map(o=>{let d=` ${o.name}: ${o.type}`;return o.isId&&(d+=" [PK]"),o.required===!1&&(d+=" (optional)"),d}).join(`
60
+ `),i=r.description?` ${r.description}`:"";return`${r.name} ${n}${i?`
61
+ ${i}`:""}
62
+ ${l}`}).join(`
63
+
64
+ `)}
65
+
66
+ Each data structure has:
67
+ - **name**: display name
68
+ - **description**: what this data represents
69
+ - **category**: "datastore" (persisted data) or "mock-api" (mocked external API)
70
+ - **order**: display order (1 = primary)
71
+ - **fields**: array of { name, type, isId, required }
72
+
73
+ Wait for the user to tell you what they want to do. They might want to:
74
+ - Add new data structures (tables, API mocks)
75
+ - Add or modify fields
76
+ - Change categories or descriptions
77
+ - Understand how data flows through the app
78
+
79
+ When making changes:
80
+ - Edit \`.codeyam/data-structure.json\` directly
81
+ - Keep the file as a JSON array sorted by order
82
+ - Update descriptions to reflect changes
83
+ - After data structure changes, update affected scenario seed data
84
+
85
+ Do NOT start making changes until the user tells you what they want.`}function Vn(t,s,r=new Date){const n={"1d":1,"3d":3,"7d":7,"30d":30}[s],l=new Date(r);l.setDate(l.getDate()-n);const i=l.toISOString().split("T")[0],o=t.filter(h=>h.date>=i),d=new Set(o.map(h=>h.commitSha).filter(Boolean)),c=new Map;for(const h of o)if(h.scenarioScreenshots)for(const g of h.scenarioScreenshots){c.has(g.name)||c.set(g.name,[]);const M=c.get(g.name);M.some(w=>w.path===g.path)||M.push({path:g.path,time:h.time})}for(const h of c.values())h.sort((g,M)=>g.time.localeCompare(M.time));const b=[],p=new Map;for(const[h,g]of c){const M=h.indexOf(" - ");if(M!==-1){const w=h.slice(0,M);p.has(w)||p.set(w,[]),p.get(w).push({name:h,screenshots:g})}else b.push({name:h,screenshots:g})}return{commitCount:d.size,entryCount:o.length,appScenarios:b,componentGroups:p,totalScenarios:c.size}}function Xn(t){const s=new Map;for(const r of[...t].reverse()){const n=s.get(r.date)||[];n.push(r),s.set(r.date,n)}return s}function Qn(t){const s=new Map;for(const r of t){let n;if("componentName"in r&&r.componentName)n=r.componentName;else if("componentName"in r&&r.componentName===null)n="App";else{const i=r.name.indexOf(" - ");n=i!==-1?r.name.slice(0,i):"App"}const l=s.get(n)||[];l.push(r),s.set(n,l)}return[...s.entries()].sort(([r],[n])=>r==="App"?-1:n==="App"?1:r.localeCompare(n))}function _s({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 Zn({testFile:t,entityName:s,cachedResult:r}){const{results:n,isRunning:l,runTests:i,stale:o}=Ht(t,r);if(l&&!n)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(!n)return null;if(n.status==="error")return e.jsx("div",{className:"pt-1",children:e.jsx("span",{className:"text-[10px] text-red-400",children:n.errorMessage})});const d=s?n.testCases.filter(p=>p.fullName.startsWith(s)):n.testCases,c=d.length>0?d:n.testCases;if(c.length===0)return null;const b=s?`${s} > `:"";return e.jsxs("div",{className:"pt-1 space-y-0.5",children:[c.map(p=>{var g;const h=b&&p.fullName.startsWith(b)?p.fullName.slice(b.length):p.fullName;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[p.status==="passed"?e.jsx("span",{className:"text-green-400 text-[10px]",children:"✓"}):p.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] ${p.status==="passed"?"text-green-400":p.status==="failed"?"text-red-400":"text-gray-500"}`,children:h})]}),p.status==="failed"&&((g=p.failureMessages)==null?void 0:g.map((M,w)=>e.jsx("div",{className:"pl-4 text-[9px] text-red-400/70 truncate max-w-full",title:M,children:M.split(`
86
+ `)[0]},w)))]},p.fullName)}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("button",{onClick:i,disabled:l,className:"text-[10px] text-[#00a0c4] hover:text-[#38bdf8] transition-colors cursor-pointer disabled:opacity-50 bg-transparent border-none p-0",children:l?"Running...":o?"Re-run (stale)":"Re-run"}),o&&!l&&e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 shrink-0",title:"Source or test file changed since last run"})]})]})}const ea={added:"text-green-400",untracked:"text-green-400",modified:"text-blue-400",renamed:"text-purple-400"};function ta({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 ${ea[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 sa={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 ra(t){try{return new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}}function na(t){try{return new Date(t+"T00:00:00").toLocaleDateString([],{weekday:"long",month:"long",day:"numeric"})}catch{return t}}const aa=[{value:"1d",label:"1 Day"},{value:"3d",label:"3 Days"},{value:"7d",label:"1 Week"},{value:"30d",label:"1 Month"}];function ia({entries:t,onScreenshotClick:s}){const[r,n]=a.useState(!1),[l,i]=a.useState("7d"),o=a.useMemo(()=>Vn(t,l),[t,l]);return e.jsxs("div",{className:"bg-[#2d2d2d] rounded-lg overflow-hidden",children:[e.jsxs("button",{onClick:()=>n(!r),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 ${r?"rotate-180":""}`,children:"▼"})]}),r&&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:aa.map(d=>e.jsx("button",{onClick:()=>i(d.value),className:`px-2.5 py-1 text-[10px] font-medium rounded transition-colors cursor-pointer border ${l===d.value?"bg-[#005c75] text-white border-[#005c75]":"bg-transparent text-gray-400 border-[#4d4d4d] hover:text-white hover:border-[#005c75]"}`,children:d.label},d.value))}),e.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-gray-400",children:[e.jsxs("span",{children:[e.jsx("span",{className:"text-white font-medium",children:o.commitCount})," ",o.commitCount===1?"commit":"commits"]}),e.jsx("span",{className:"text-[#3d3d3d]",children:"|"}),e.jsxs("span",{children:[e.jsx("span",{className:"text-white font-medium",children:o.totalScenarios})," ",o.totalScenarios===1?"scenario changed":"scenarios changed"]}),e.jsx("span",{className:"text-[#3d3d3d]",children:"|"}),e.jsxs("span",{children:[e.jsx("span",{className:"text-white font-medium",children:o.entryCount})," ",o.entryCount===1?"entry":"entries"]})]}),o.totalScenarios===0?e.jsx("p",{className:"text-[11px] text-gray-500 italic m-0",children:"No scenario changes in this period."}):e.jsxs("div",{className:"space-y-3",children:[o.appScenarios.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("span",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider",children:"Application"}),o.appScenarios.map(d=>e.jsx(Ws,{scenario:d,onScreenshotClick:s},d.name))]}),o.componentGroups.size>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("span",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider",children:"Components"}),[...o.componentGroups.entries()].sort(([d],[c])=>d.localeCompare(c)).map(([d,c])=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("span",{className:"text-[10px] font-medium text-gray-400",children:d}),c.map(b=>e.jsx(Ws,{scenario:b,onScreenshotClick:s},b.name))]},d))]})]})]})]})}function Ws({scenario:t,onScreenshotClick:s}){const r=t.name.indexOf(" - "),n=r!==-1?t.name.slice(r+3):t.name;return e.jsxs("div",{className:"pl-2",children:[e.jsx("span",{className:"text-[10px] text-gray-500 block mb-1",children:n}),e.jsx("div",{className:"flex items-center gap-1 overflow-x-auto",children:t.screenshots.map((l,i)=>e.jsxs("div",{className:"flex items-center shrink-0",children:[i>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(l.time).toLocaleDateString()})`,onClick:()=>s==null?void 0:s({screenshotUrl:`/api/editor-journal-image/${l.path.replace("screenshots/","")}`,commitSha:null,commitMessage:null,scenarioName:t.name}),children:e.jsx("img",{src:`/api/editor-journal-image/${l.path.replace("screenshots/","")}`,alt:t.name,className:"max-w-full max-h-full object-contain",loading:"lazy"})})]},l.path))})]})}function oa({isActive:t,onScreenshotClick:s,glossaryFunctions:r=[],cachedTestResults:n={}}){const[l,i]=a.useState([]),[o,d]=a.useState(!0),[c,b]=a.useState(new Set),p=a.useCallback(M=>{b(w=>{const u=new Set(w);return u.has(M)?u.delete(M):u.add(M),u})},[]),h=a.useCallback(async()=>{try{const M=await fetch("/api/editor-journal");if(M.ok){const w=await M.json();i(w.entries||[])}}catch{}finally{d(!1)}},[]);if(a.useEffect(()=>{h()},[h]),a.useEffect(()=>{t&&h()},[t,h]),a.useEffect(()=>{if(!t)return;const M=setInterval(()=>void h(),5e3);return()=>clearInterval(M)},[t,h]),o)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(l.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 g=Xn(l);return e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsx(ia,{entries:l,onScreenshotClick:s}),[...g.entries()].map(([M,w])=>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:na(M)})}),e.jsx("div",{className:"space-y-2",children:w.map((u,y)=>{const C=sa[u.type]||{label:u.type,color:"bg-gray-600"},I=`${u.time}-${y}`,$=c.has(I);return e.jsxs("div",{className:"bg-[#2d2d2d] rounded-lg overflow-hidden",children:[e.jsxs("div",{className:`p-3 space-y-2 ${$?"":"max-h-[300px] overflow-y-auto"}`,children:[e.jsx("div",{className:"flex items-start gap-2 cursor-pointer",onClick:()=>p(I),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:u.title}),e.jsx("span",{className:`${C.color} text-white text-[9px] font-bold px-1.5 py-0.5 rounded uppercase tracking-wider shrink-0`,children:C.label})]}),e.jsx("span",{className:"text-[10px] text-gray-500",children:ra(u.time)}),u.featureName&&e.jsx("span",{className:"text-[10px] text-gray-500 italic truncate",title:u.featureName,children:u.featureName})]})}),u.userPrompt&&e.jsx(sr,{text:u.userPrompt,theme:"dark"}),e.jsx("p",{className:"text-xs text-gray-400 leading-relaxed",children:u.description}),u.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/${u.screenshot.replace("screenshots/","")}`,commitSha:u.commitSha,commitMessage:u.commitMessage,scenarioName:u.title}),children:e.jsx("img",{src:`/api/editor-journal-image/${u.screenshot.replace("screenshots/","")}`,alt:u.title,className:"max-w-full max-h-full object-contain",loading:"lazy"})}),u.scenarioScreenshots&&u.scenarioScreenshots.length>0&&(()=>{const B=Qn(u.scenarioScreenshots),H=u.entityChangeStatus,P=B.filter(([v])=>v==="App").flatMap(([,v])=>v),J=B.filter(([v])=>v!=="App"),_=new Map;for(const v of P){const L=v,W=L.pageFilePath?qe(Ye(L.pageFilePath)):ft(L.url??null),U=_.get(W)||[];U.push(v),_.set(W,U)}const O=[..._.entries()],E=v=>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/${v.path.replace("screenshots/","")}`,commitSha:u.commitSha,commitMessage:u.commitMessage,scenarioName:v.name}),children:e.jsx("img",{src:`/api/editor-journal-image/${v.path.replace("screenshots/","")}`,alt:v.name,title:v.name,className:"max-w-full max-h-full object-contain",loading:"lazy"})},v.path);return e.jsxs("div",{className:"space-y-2",children:[O.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"}),O.map(([v,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:v}),(H==null?void 0:H[v])&&e.jsx(_s,{status:H[v]})]}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-0.5",children:L.map(E)})]},v))]}),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:"Components"}),J.map(([v,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:v}),(H==null?void 0:H[v])&&e.jsx(_s,{status:H[v]})]}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-0.5",children:L.map(E)})]},v))]})]})})(),r.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:r.map(B=>e.jsxs("div",{children:[e.jsx("span",{className:"text-[11px] font-medium text-gray-200",children:B.name}),e.jsx("span",{className:"text-[9px] text-gray-500 truncate block",children:B.filePath}),B.testFile?e.jsx(Zn,{testFile:B.testFile,entityName:B.name,cachedResult:n[B.testFile]}):e.jsx("div",{className:"pt-1",children:e.jsx("span",{className:"text-[10px] text-gray-500",children:"No test file"})})]},B.name))})]}),u.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:u.commitSha.slice(0,7)}),e.jsx("span",{className:"text-gray-500 truncate",children:u.commitMessage})]}),$&&u.modifiedFiles&&u.modifiedFiles.length>0&&e.jsx(ta,{files:u.modifiedFiles})]}),e.jsxs("button",{onClick:()=>p(I),className:"w-full py-1.5 text-[10px] text-gray-500 hover:text-gray-300 border-t border-[#3d3d3d] transition-colors cursor-pointer",children:["——— ",$?"Collapse":"Expand"," ———"]})]},I)})})]},M))]})})}const la=()=>e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#D7FF63",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M20 6L9 17l-5-5"})});function Ot({title:t,completedCount:s,totalCount:r,subtitle:n,onClick:l,secondaryAction:i,previewTasks:o}){const d=r>0&&s>=r;return e.jsxs("button",{type:"button",onClick:l,className:"bg-[#2a2a2a] border border-[#3d3d3d] rounded-lg p-3 flex flex-col gap-1.5 cursor-pointer hover:border-[#555] transition-colors text-left",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-white",children:t}),d?e.jsx(la,{}):r>0?e.jsxs("span",{className:"text-xs text-gray-500",children:["(",s,"/",r,")"]}):null]}),n&&e.jsx("p",{className:"text-xs text-gray-400 m-0 leading-snug",children:n}),o&&o.length>0&&e.jsx("div",{className:"flex flex-col gap-1 mt-0.5",children:o.map(c=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:`text-[11px] truncate flex-1 ${c.completed?"text-gray-300":"text-gray-500"}`,children:c.label}),c.completed&&e.jsx("span",{className:"shrink-0 w-3.5 h-3.5 rounded-full bg-green-600 flex items-center justify-center",children:e.jsx("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M20 6L9 17l-5-5"})})})]},c.label))}),i&&e.jsx("span",{role:"link",onClick:c=>{c.stopPropagation(),i.onClick()},className:"text-xs text-[#D7FF63]/70 hover:text-[#D7FF63] text-left truncate mt-0.5",children:i.label})]})}function ca({onNavigateToRoadmap:t,onSwitchToBuild:s}){const[r,n]=a.useState(null),l=a.useCallback(()=>{fetch("/api/editor-roadmap").then(g=>g.json()).then(g=>n(g)).catch(()=>{})},[]);if(a.useEffect(()=>{l()},[l]),!r)return null;const i=r.plan.filter(g=>g.completed).length,o=r.plan.length,d=r.deploy.filter(g=>g.completed).length,c=r.deploy.length,b=r.buildSessionCount===1?"1 working session":`${r.buildSessionCount} working sessions`,p=r.featureName&&r.editorStepLabel?`${r.featureName} — ${r.editorStepLabel}`:r.featureName?r.featureName:null,h=g=>{const M=[...g].reverse().find(u=>u.completed),w=g.filter(u=>!u.completed);if(M){const u=[{label:M.label,completed:!0}];return w.length>0&&u.push({label:w[0].label,completed:!1}),u}return w.slice(0,2).map(u=>({label:u.label,completed:!1}))};return e.jsxs("div",{children:[e.jsx("span",{className:"text-xs font-bold text-gray-400 uppercase tracking-wider font-['IBM_Plex_Mono']",children:"Roadmap"}),e.jsxs("div",{className:"grid grid-cols-3 gap-3 mt-2",children:[e.jsx(Ot,{title:"Plan",completedCount:i,totalCount:o,onClick:t,previewTasks:h(r.plan)}),e.jsx(Ot,{title:"Build",completedCount:r.buildSessionCount,totalCount:0,subtitle:b,onClick:t,secondaryAction:p?{label:p,onClick:s}:void 0}),e.jsx(Ot,{title:"Deploy",completedCount:d,totalCount:c,onClick:t,previewTasks:h(r.deploy)})]})]})}function zt(t){return{name:da(t),description:xa(t),colors:ua(t),fonts:ha(t),typographyScale:pa(t),radiusTokens:ma(t)}}function da(t){const s=t.match(/^# (.+)$/m);return s?s[1].trim():"Design System"}function xa(t){const s=t.match(/^> (.+)$/m);return s?s[1].trim():""}function ua(t){const s=[],r=Kt(t,"Colors");if(!r)return s;const n=ba(r);for(const{heading:l,content:i}of n){const o=ir(i);for(const d of o){const c=/--([a-zA-Z0-9_-]+):\s*([^;]+);(?:\s*\/\*\s*(.+?)\s*\*\/)?/g;let b;for(;(b=c.exec(d))!==null;){const p=b[2].trim();ja(p)&&s.push({name:b[1],value:p,group:l,...b[3]?{comment:b[3]}:{}})}}}return s}function ha(t){const s=t.match(/\*\*Font stack:\*\*\s*`([^`]+)`(?:\s*\([^)]*\))?(?:,\s*`([^`]+)`)?/);if(!s)return[];const r=[];if(s[1]){const l=Bt(s[1]);l&&r.push(l)}if(s[2]){const l=Bt(s[2]);l&&!r.includes(l)&&r.push(l)}const n=t.match(/\*\*Font stack:\*\*\s*`[^`]+`[^`]*`[^`]+`[^`]*`([^`]+)`/);if(n){const l=Bt(n[1]);l&&!r.includes(l)&&r.push(l)}return r}function Bt(t){return t.split(",")[0].trim().replace(/'/g,"")||null}function pa(t){const s=[],r=Kt(t,"Typography");if(!r)return s;const n=r.split(`
87
+ `).filter(l=>l.startsWith("|"));if(n.length<3)return s;for(let l=2;l<n.length;l++){const i=n[l].split("|").map(o=>o.trim()).filter(Boolean);i.length>=3&&s.push({style:i[0],size:i[1],weight:i[2],notes:i.slice(3).join(" | ")})}return s}function ma(t){const s=[],r=Kt(t,"Spacing");if(!r)return s;const n=ir(r);for(const l of n){const i=/--radius-([a-zA-Z0-9_-]+):\s*([^;]+);(?:\s*\/\*\s*(.+?)\s*\*\/)?/g;let o;for(;(o=i.exec(l))!==null;)s.push({name:`radius-${o[1]}`,value:o[2].trim(),...o[3]?{comment:o[3]}:{}})}return s}function fa(t,s,r){const n=s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),l=new RegExp(`(--${n}:\\s*)([^;]+)(;.*)`,"g");return t.replace(l,`$1${r}$3`)}function ga(t,s){return t.replace(/(\*\*Font stack:\*\*\s*`)([^`]+)(`)/,`$1${s}$3`)}function Kt(t,s){const n=new RegExp(`^## .*${s}.*$`,"im").exec(t);if(!n)return null;const l=n.index+n[0].length,i=t.indexOf(`
88
+ ## `,l);return i===-1?t.slice(l):t.slice(l,i)}function ba(t){const s=[],r=t.split(/^### /m);for(let n=0;n<r.length;n++){if(n===0){const i=r[n].trim();i&&s.push({heading:"General",content:i});continue}const l=r[n].indexOf(`
89
+ `);l===-1?s.push({heading:r[n].trim(),content:""}):s.push({heading:r[n].slice(0,l).trim(),content:r[n].slice(l+1)})}return s}function ir(t){const s=[],r=/```css\n([\s\S]*?)```/g;let n;for(;(n=r.exec(t))!==null;)s.push(n[1]);return s}function ja(t){return!!(t.startsWith("#")||t.startsWith("rgb")||t.startsWith("hsl")||t.startsWith("var(--"))}const zs=[{key:"languages",label:"Languages"},{key:"frameworks",label:"Frameworks"},{key:"databases",label:"Databases"},{key:"services",label:"External Services"},{key:"libraries",label:"Key Libraries"},{key:"infrastructure",label:"Infrastructure"}];function Hs({todo:t,expanded:s,onToggle:r,onRemove:n,children:l}){return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 py-1.5 group cursor-pointer",onClick:r,children:[e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:`shrink-0 text-gray-500 transition-transform ${s?"rotate-90":""}`,children:e.jsx("path",{d:"M3 1l4 4-4 4"})}),e.jsxs("span",{className:`text-sm flex-1 ${t.completed?"text-white":"text-gray-500"}`,children:[t.label,t.autoDetect&&!t.userCreated&&e.jsx("span",{className:"text-[10px] text-gray-600 ml-1.5",children:"(auto)"})]}),t.completed&&e.jsx("span",{className:"shrink-0 w-5 h-5 rounded-full bg-green-600 flex items-center justify-center",children:e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M20 6L9 17l-5-5"})})}),t.userCreated&&n&&e.jsx("button",{type:"button",onClick:i=>{i.stopPropagation(),n()},className:"opacity-0 group-hover:opacity-100 text-gray-600 hover:text-red-400 bg-transparent border-none cursor-pointer p-0 transition-opacity",title:"Remove",children:e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:e.jsx("path",{d:"M2 2l8 8M10 2l-8 8"})})})]}),s&&l]})}function Us({title:t,completedCount:s,totalCount:r}){const n=r>0&&s>=r;return e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("h3",{className:"text-sm font-medium text-white m-0",children:t}),n?e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#D7FF63",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M20 6L9 17l-5-5"})}):r>0?e.jsxs("span",{className:"text-xs text-gray-500",children:[s,"/",r]}):null]})}const ya={feature:"bg-[#005c75]",fix:"bg-amber-700",refactor:"bg-purple-700",scaffold:"bg-green-700",data:"bg-blue-700",milestone:"bg-yellow-600"};function va(t){try{return new Date(t).toLocaleDateString([],{month:"short",day:"numeric"})}catch{return""}}function Na({designSystem:t,onEdit:s}){const r=t.colors.filter(n=>n.value.startsWith("#")).slice(0,10);return e.jsxs("div",{className:"mt-1 mb-2 bg-[#222] rounded-lg p-3 border border-[#333]",children:[e.jsx("div",{className:"text-xs font-medium text-gray-200 mb-2",children:t.name}),r.length>0&&e.jsx("div",{className:"flex gap-1.5 mb-2 flex-wrap",children:r.map(n=>e.jsx("div",{className:"w-5 h-5 rounded border border-[#444]",style:{backgroundColor:n.value},title:`--${n.name}: ${n.value}`},`${n.group}-${n.name}`))}),t.fonts.length>0&&e.jsxs("div",{className:"text-[10px] text-gray-500 mb-2",children:["Font: ",t.fonts.join(", ")]}),s&&e.jsx("button",{type:"button",onClick:s,className:"text-[11px] text-[#D7FF63] hover:text-[#D7FF63]/70 bg-transparent border-none p-0 cursor-pointer transition-colors font-medium",children:"View & Edit >"})]})}function Ks({projectTitle:t,projectDescription:s,onSave:r,onEditNavigate:n,defaultEditing:l=!1}){const[i,o]=a.useState(l),[d,c]=a.useState(t||""),[b,p]=a.useState(s||""),[h,g]=a.useState(!1);a.useEffect(()=>{c(t||""),p(s||"")},[t,s]);const M=()=>{g(!0),r(d,b),g(!1),o(!1)},w=()=>{c(t||""),p(s||""),o(!1)};return i?e.jsx("div",{className:"mt-1 mb-2 bg-[#222] rounded-lg p-3 border border-[#333]",children:e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-[10px] font-semibold text-gray-500 uppercase tracking-wider mb-1",children:"Project Name"}),e.jsx("input",{type:"text",value:d,onChange:u=>c(u.target.value),placeholder:"My App",className:"w-full px-2.5 py-1.5 text-sm bg-[#2a2a2a] border border-[#3d3d3d] rounded-md text-gray-200 placeholder-gray-600 outline-none focus:border-[#D7FF63]/50 transition-colors"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[10px] font-semibold text-gray-500 uppercase tracking-wider mb-1",children:"Description"}),e.jsx("textarea",{value:b,onChange:u=>p(u.target.value),placeholder:"A brief description of your project...",rows:2,className:"w-full px-2.5 py-1.5 text-sm bg-[#2a2a2a] border border-[#3d3d3d] rounded-md text-gray-200 placeholder-gray-600 outline-none focus:border-[#D7FF63]/50 transition-colors resize-none"})]}),e.jsxs("div",{className:"flex gap-2 pt-0.5",children:[e.jsx("button",{type:"button",onClick:M,disabled:h,className:"px-3 py-1 text-[11px] text-[#1e1e1e] bg-[#D7FF63] rounded-md hover:bg-[#D7FF63]/80 transition-colors cursor-pointer font-medium disabled:opacity-50",children:h?"Saving...":"Save"}),e.jsx("button",{type:"button",onClick:w,className:"px-3 py-1 text-[11px] text-gray-400 bg-transparent border border-[#3d3d3d] rounded-md hover:text-white hover:border-[#555] transition-colors cursor-pointer",children:"Cancel"})]})]})}):e.jsxs("div",{className:"mt-1 mb-2 bg-[#222] rounded-lg p-3 border border-[#333]",children:[t?e.jsx("div",{className:"text-xs font-medium text-gray-200 mb-0.5",children:t}):e.jsx("div",{className:"text-xs text-gray-500 italic mb-0.5",children:"No name set"}),s&&e.jsx("div",{className:"text-[11px] text-gray-400 leading-relaxed",children:s}),e.jsx("button",{type:"button",onClick:n??(()=>o(!0)),className:"text-[11px] text-[#D7FF63] hover:text-[#D7FF63]/70 bg-transparent border-none p-0 mt-1.5 cursor-pointer transition-colors font-medium",children:"Edit >"})]})}function wa({techStack:t,onNavigate:s}){if(!(t&&zs.some(({key:o})=>t[o]&&t[o].length>0)))return e.jsxs("div",{className:"mt-1 mb-2 bg-[#222] rounded-lg p-3 border border-[#333]",children:[e.jsx("div",{className:"text-xs text-gray-400 mb-2",children:"No tech stack configured yet"}),s&&e.jsx("button",{type:"button",onClick:s,className:"px-3 py-1.5 text-[11px] font-medium text-[#1e1e1e] bg-[#D7FF63] rounded-md hover:bg-[#D7FF63]/80 transition-colors cursor-pointer",children:"Set up with Claude >"})]});const n=[];for(const{key:o}of zs){const d=t[o];if(d)for(const c of d)n.push(c)}const l=n.slice(0,5),i=n.length-5;return e.jsxs("div",{className:"mt-1 mb-2 bg-[#222] rounded-lg p-3 border border-[#333]",children:[e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[l.map((o,d)=>e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-gray-300 bg-[#2a2a2a] px-2 py-0.5 rounded",children:[o.name,o.version&&e.jsxs("span",{className:"text-[10px] text-gray-500",children:["v",o.version]})]},d)),i>0&&e.jsxs("span",{className:"text-[10px] text-gray-500 self-center",children:["+",i," more"]})]}),s&&e.jsx("button",{type:"button",onClick:s,className:"text-[11px] text-[#D7FF63] hover:text-[#D7FF63]/70 bg-transparent border-none p-0 mt-2 cursor-pointer transition-colors font-medium",children:"View all >"})]})}function _t({iconType:t,size:s=14,className:r=""}){const n={width:s,height:s,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",className:r};switch(t){case"desktop":return e.jsxs("svg",{...n,children:[e.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2"}),e.jsx("path",{d:"M8 21h8M12 17v4"})]});case"laptop":return e.jsxs("svg",{...n,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"})]});case"tablet":return e.jsxs("svg",{...n,children:[e.jsx("rect",{x:"5",y:"2",width:"14",height:"20",rx:"2"}),e.jsx("path",{d:"M12 18h.01"})]});case"mobile":return e.jsxs("svg",{...n,children:[e.jsx("rect",{x:"7",y:"2",width:"10",height:"20",rx:"2"}),e.jsx("path",{d:"M12 18h.01"})]})}}function Js({open:t,size:s=12}){return t?e.jsxs("svg",{width:s,height:s,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),e.jsx("circle",{cx:"12",cy:"12",r:"3"})]}):e.jsxs("svg",{width:s,height:s,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94"}),e.jsx("path",{d:"M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19"}),e.jsx("path",{d:"M14.12 14.12a3 3 0 1 1-4.24-4.24"}),e.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]})}const ka=new Set(Xs.flatMap(t=>t.presets.map(s=>s.name)));function Gs({screenSizes:t,projectScreenSizes:s,defaultScreenSize:r,appFormats:n,onSave:l,onEditNavigate:i,defaultEditing:o=!1}){const d=a.useMemo(()=>Qs(t,n),[t,n]),c=a.useMemo(()=>{if(t){for(const[F,D]of Object.entries(t))if(D.default)return F}return(r==null?void 0:r.name)||""},[t,r]),[b,p]=a.useState(o),[h,g]=a.useState({}),[M,w]=a.useState(new Set),[u,y]=a.useState(""),[C,I]=a.useState(""),[$,B]=a.useState(""),[H,P]=a.useState(""),J=()=>{const F={};for(const S of d)F[S.name]={width:S.width,height:S.height};g(F);const D=new Set,f=s||t;if(f)for(const S of Object.keys(f)){const j=f[S];(s||!j||!("default"in j))&&D.add(S)}w(D),y(c),I(""),B(""),P(""),p(!0)};a.useEffect(()=>{o&&J()},[]);const _=(F,D,f)=>{g(S=>{const j={...S};if(j[F]){if(delete j[F],w(A=>{const R=new Set(A);return R.delete(F),R}),F===u){const A=Object.keys(j);y(A[0]||"")}}else j[F]={width:D,height:f},Object.keys(S).length===0&&y(F);return j})},O=F=>{w(D=>{const f=new Set(D);return f.has(F)?f.delete(F):f.add(F),f})},E=F=>{h[F]&&y(F)},v=()=>{const F=C.trim(),D=parseInt($,10),f=parseInt(H,10);!F||isNaN(D)||isNaN(f)||D<=0||f<=0||(g(S=>(Object.keys(S).length===0&&y(F),{...S,[F]:{width:D,height:f}})),I(""),B(""),P(""))},L=F=>{g(D=>{const f={...D};return delete f[F],F===u&&y(Object.keys(f)[0]||""),f}),w(D=>{const f=new Set(D);return f.delete(F),f})},W=()=>{const F={};for(const[f,S]of Object.entries(h))F[f]={width:S.width,height:S.height,...f===u?{default:!0}:{}};const D={};for(const f of M)h[f]&&(D[f]={...h[f]});l(F,D),p(!1)};if(b){const F=Object.entries(h).filter(([D])=>!ka.has(D));return e.jsxs("div",{className:"mt-1 mb-2 bg-[#222] rounded-lg p-3 border border-[#333]",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2 px-0.5",children:[e.jsx("div",{className:"w-3.5"}),e.jsx("div",{className:"w-3.5"}),e.jsx("span",{className:"text-[9px] font-semibold text-gray-600 uppercase tracking-wider flex-1",children:"Size"}),e.jsx("span",{className:"text-[9px] font-semibold text-gray-600 uppercase tracking-wider w-[72px] text-right",children:"Dimensions"}),e.jsx("span",{className:"text-[9px] font-semibold text-gray-600 uppercase tracking-wider w-[50px] text-center",title:"Include in project screenshot sizes",children:"Project"}),e.jsx("span",{className:"text-[9px] font-semibold text-gray-600 uppercase tracking-wider w-[54px] text-center",children:"Default"})]}),e.jsxs("div",{className:"space-y-3",children:[Xs.map(D=>e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider mb-1.5",children:D.category}),e.jsx("div",{className:"space-y-0.5",children:D.presets.map(f=>{const S=!!h[f.name],j=u===f.name,A=M.has(f.name),R=pt(f);return e.jsxs("div",{className:"flex items-center gap-2 py-0.5",children:[e.jsx("button",{type:"button",onClick:()=>_(f.name,f.width,f.height),className:`w-3.5 h-3.5 rounded-sm border flex items-center justify-center shrink-0 cursor-pointer transition-colors ${S?"bg-[#D7FF63] border-[#D7FF63]":"bg-transparent border-[#555] hover:border-[#888]"}`,children:S&&e.jsx("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"#1e1e1e",strokeWidth:"3.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M20 6L9 17l-5-5"})})}),e.jsx(_t,{iconType:R,size:14,className:S?"text-gray-300":"text-gray-600"}),e.jsx("span",{className:`text-xs flex-1 ${S?"text-gray-300":"text-gray-500"}`,children:f.name}),e.jsxs("span",{className:"text-[10px] text-gray-500 tabular-nums w-[72px] text-right",children:[f.width," × ",f.height]}),e.jsx("div",{className:"w-[50px] flex justify-center",children:S?e.jsx("button",{type:"button",onClick:()=>O(f.name),className:`p-1 rounded cursor-pointer transition-colors ${A?"text-[#D7FF63] hover:text-[#D7FF63]/70":"text-gray-600 hover:text-gray-400"}`,title:A?"In project screenshots":"Not in project screenshots",children:e.jsx(Js,{open:A})}):e.jsx("span",{className:"w-3"})}),e.jsx("div",{className:"w-[54px] flex justify-center",children:S?e.jsx("button",{type:"button",onClick:()=>E(f.name),className:`text-[10px] px-1.5 py-0.5 rounded border cursor-pointer transition-colors ${j?"text-[#1e1e1e] bg-[#D7FF63] border-[#D7FF63]":"text-gray-500 bg-transparent border-[#444] hover:border-[#666] hover:text-gray-300"}`,title:j?"Default size":"Set as default",children:j?"★":"☆"}):e.jsx("span",{className:"w-3"})})]},f.name)})})]},D.category)),F.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider mb-1.5",children:"Custom"}),e.jsx("div",{className:"space-y-0.5",children:F.map(([D,f])=>{const S=u===D,j=M.has(D),A=pt({name:D,width:f.width,height:f.height});return e.jsxs("div",{className:"flex items-center gap-2 py-0.5",children:[e.jsx("div",{className:"w-3.5"}),e.jsx(_t,{iconType:A,size:14,className:"text-gray-300"}),e.jsx("span",{className:"text-xs text-gray-300 flex-1",children:D}),e.jsxs("span",{className:"text-[10px] text-gray-500 tabular-nums w-[72px] text-right",children:[f.width," × ",f.height]}),e.jsx("div",{className:"w-[50px] flex justify-center",children:e.jsx("button",{type:"button",onClick:()=>O(D),className:`p-1 rounded cursor-pointer transition-colors ${j?"text-[#D7FF63] hover:text-[#D7FF63]/70":"text-gray-600 hover:text-gray-400"}`,title:j?"In project screenshots":"Not in project screenshots",children:e.jsx(Js,{open:j})})}),e.jsx("div",{className:"w-[54px] flex justify-center",children:e.jsx("button",{type:"button",onClick:()=>E(D),className:`text-[10px] px-1.5 py-0.5 rounded border cursor-pointer transition-colors ${S?"text-[#1e1e1e] bg-[#D7FF63] border-[#D7FF63]":"text-gray-500 bg-transparent border-[#444] hover:border-[#666] hover:text-gray-300"}`,title:S?"Default size":"Set as default",children:S?"★":"☆"})}),e.jsx("button",{type:"button",onClick:()=>L(D),className:"text-gray-600 hover:text-red-400 bg-transparent border-none p-0.5 cursor-pointer transition-colors text-xs leading-none",children:"×"})]},D)})})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider mb-1.5",children:"Add Custom Size"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("input",{type:"text",value:C,onChange:D=>I(D.target.value),placeholder:"Name",className:"flex-1 min-w-0 px-2 py-1 text-xs bg-[#2a2a2a] border border-[#3d3d3d] rounded text-gray-200 placeholder-gray-600 outline-none focus:border-[#D7FF63]/50 transition-colors"}),e.jsx("input",{type:"number",value:$,onChange:D=>B(D.target.value),placeholder:"W",className:"w-14 px-2 py-1 text-xs bg-[#2a2a2a] border border-[#3d3d3d] rounded text-gray-200 placeholder-gray-600 outline-none focus:border-[#D7FF63]/50 transition-colors"}),e.jsx("span",{className:"text-[10px] text-gray-500",children:"×"}),e.jsx("input",{type:"number",value:H,onChange:D=>P(D.target.value),placeholder:"H",className:"w-14 px-2 py-1 text-xs bg-[#2a2a2a] border border-[#3d3d3d] rounded text-gray-200 placeholder-gray-600 outline-none focus:border-[#D7FF63]/50 transition-colors"}),e.jsx("button",{type:"button",onClick:v,className:"text-[10px] text-[#D7FF63] hover:text-[#D7FF63]/70 bg-transparent border-none p-0 cursor-pointer transition-colors font-medium",children:"+ Add"})]})]})]}),e.jsxs("div",{className:"flex gap-2 pt-2.5",children:[e.jsx("button",{type:"button",onClick:W,className:"px-3 py-1 text-[11px] text-[#1e1e1e] bg-[#D7FF63] rounded-md hover:bg-[#D7FF63]/80 transition-colors cursor-pointer font-medium",children:"Save"}),e.jsx("button",{type:"button",onClick:()=>p(!1),className:"px-3 py-1 text-[11px] text-gray-400 bg-transparent border border-[#3d3d3d] rounded-md hover:text-white hover:border-[#555] transition-colors cursor-pointer",children:"Cancel"})]})]})}if(d.length===0)return e.jsxs("div",{className:"mt-1 mb-2 bg-[#222] rounded-lg p-3 border border-[#333]",children:[e.jsx("div",{className:"text-xs text-gray-500 italic",children:"No screen sizes configured"}),e.jsx("button",{type:"button",onClick:i??J,className:"text-[11px] text-[#D7FF63] hover:text-[#D7FF63]/70 bg-transparent border-none p-0 mt-1.5 cursor-pointer transition-colors font-medium",children:"Edit >"})]});const U=F=>c===F,k=F=>{var D;return!!((D=s||t)!=null&&D[F])};return e.jsxs("div",{className:"mt-1 mb-2 bg-[#222] rounded-lg p-3 border border-[#333]",children:[e.jsx("div",{className:"flex flex-wrap gap-1.5",children:d.map(F=>{const D=pt(F);return e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs bg-[#2a2a2a] px-2 py-1 rounded text-gray-300",children:[e.jsx(_t,{iconType:D,size:12,className:"text-gray-400"}),F.name,e.jsxs("span",{className:"text-[10px] text-gray-500",children:[F.width,"×",F.height]}),U(F.name)&&e.jsx("span",{className:"text-[10px] text-[#D7FF63]",children:"★"}),k(F.name)&&e.jsx("span",{className:"text-[10px] text-[#D7FF63]",title:"Project screenshot size",children:"P"})]},F.name)})}),e.jsx("button",{type:"button",onClick:i??J,className:"text-[11px] text-[#D7FF63] hover:text-[#D7FF63]/70 bg-transparent border-none p-0 mt-2 cursor-pointer transition-colors font-medium",children:"Edit >"})]})}function Sa({onBack:t,onSwitchToBuild:s,onSwitchToHistory:r,onNavigateToDesignSystem:n,onNavigateToTechStack:l,expandedTasks:i,onExpandedTasksChange:o}){const{revalidate:d}=Xr(),[c,b]=a.useState(null),[p,h]=a.useState(!1),[g,M]=a.useState(null),w=a.useCallback(()=>{fetch("/api/editor-roadmap").then(k=>k.json()).then(k=>b(k)).catch(()=>{})},[]);a.useEffect(()=>{w()},[w]);const u=(c==null?void 0:c.plan.some(k=>k.id==="plan-design-system"&&k.completed))??!1;a.useEffect(()=>{if(!u){M(null);return}fetch("/api/editor-design-system").then(k=>k.json()).then(k=>{k.exists&&k.content?M(zt(k.content)):M(null)}).catch(()=>M(null))},[u]);const y=a.useCallback(k=>{h(!0),fetch("/api/editor-roadmap",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(k)}).then(F=>F.json()).then(()=>w()).catch(()=>{}).finally(()=>h(!1))},[w]),C=a.useCallback((k,F)=>{fetch("/api/editor-project-info",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectTitle:k,projectDescription:F})}).then(()=>w()).catch(()=>{})},[w]),I=a.useCallback((k,F)=>{fetch("/api/editor-project-info",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({screenSizes:k,projectScreenSizes:F})}).then(()=>{w(),d()}).catch(()=>{})},[w,d]),$=a.useCallback((k,F)=>{if(!c)return;const D=c[k].filter(f=>f.id!==F);b({...c,[k]:D}),y({[k]:D})},[c,y]),[B,H]=a.useState(null),P=a.useRef(null),J=a.useRef(0),_=a.useCallback(k=>{const F=new Set(i);F.has(k)?F.delete(k):F.add(k),o(F)},[i,o]),O=a.useCallback(k=>{P.current&&(J.current=P.current.scrollTop),H(k)},[]),E=a.useCallback(()=>{H(null),requestAnimationFrame(()=>{P.current&&(P.current.scrollTop=J.current)})},[]);if(!c)return e.jsx("div",{className:"flex-1 flex items-center justify-center font-['IBM_Plex_Sans']",children:e.jsx("span",{className:"text-sm text-gray-500",children:"Loading roadmap..."})});const v=c.plan.filter(k=>k.completed).length,L=c.deploy.filter(k=>k.completed).length,W=c.buildSessionCount===1?"1 working session completed":`${c.buildSessionCount} working sessions completed`,U=B&&([...c.plan,...c.deploy].find(k=>k.id===B)??null);if(U){const k=U.id==="plan-project-name"&&U.completed?e.jsx(Ks,{projectTitle:c.projectTitle,projectDescription:c.projectDescription,onSave:C,defaultEditing:!0}):U.id==="plan-screen-sizes"&&U.completed?e.jsx(Gs,{screenSizes:c.screenSizes,projectScreenSizes:c.projectScreenSizes,defaultScreenSize:c.defaultScreenSize,appFormats:c.appFormats,onSave:I,defaultEditing:!0}):null;return e.jsx("div",{className:"flex-1 overflow-auto font-['IBM_Plex_Sans']",children:e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("button",{type:"button",onClick:E,className:"flex items-center gap-1.5 text-xs text-gray-500 hover:text-white bg-transparent border-none p-0 cursor-pointer transition-colors",children:[e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M15 18l-6-6 6-6"})}),"Back to Roadmap"]}),e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("h2",{className:"text-lg font-medium text-white mt-0 mb-0",children:U.label}),U.completed&&e.jsx("span",{className:"shrink-0 w-5 h-5 rounded-full bg-green-600 flex items-center justify-center",children:e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M20 6L9 17l-5-5"})})})]}),k?e.jsx("div",{children:k}):e.jsx("p",{className:"text-sm text-gray-500",children:U.completed?"This task has been completed.":"This task has not been started yet."}),p&&e.jsx("span",{className:"text-[10px] text-gray-600",children:"Saving..."})]})})}return e.jsx("div",{ref:P,className:"flex-1 overflow-auto font-['IBM_Plex_Sans']",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("button",{type:"button",onClick:t,className:"flex items-center gap-1.5 text-xs text-gray-500 hover:text-white bg-transparent border-none p-0 cursor-pointer transition-colors",children:[e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M15 18l-6-6 6-6"})}),"Back to App"]}),e.jsx("h2",{className:"text-lg font-medium text-white mt-0 mb-6",children:"Roadmap"}),e.jsxs("div",{className:"bg-[#2a2a2a] border border-[#3d3d3d] rounded-lg p-4",children:[e.jsx(Us,{title:"Plan",completedCount:v,totalCount:c.plan.length}),e.jsx("div",{className:"mt-2",children:c.plan.map(k=>e.jsxs(Hs,{todo:k,expanded:i.has(k.id),onToggle:()=>_(k.id),onRemove:k.userCreated?()=>$("plan",k.id):void 0,children:[k.id==="plan-project-name"&&k.completed&&e.jsx(Ks,{projectTitle:c.projectTitle,projectDescription:c.projectDescription,onSave:C,onEditNavigate:()=>O(k.id)}),k.id==="plan-tech-stack"&&e.jsx(wa,{techStack:c.techStack,onNavigate:l}),k.id==="plan-design-system"&&k.completed&&g&&e.jsx(Na,{designSystem:g,onEdit:n}),k.id==="plan-screen-sizes"&&k.completed&&e.jsx(Gs,{screenSizes:c.screenSizes,projectScreenSizes:c.projectScreenSizes,defaultScreenSize:c.defaultScreenSize,appFormats:c.appFormats,onSave:I,onEditNavigate:()=>O(k.id)})]},k.id))})]}),e.jsxs("div",{className:"bg-[#2a2a2a] border border-[#3d3d3d] rounded-lg p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("h3",{className:"text-sm font-medium text-white m-0",children:"Build"}),e.jsx("span",{className:"text-xs text-gray-500",children:W})]}),c.featureName&&e.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-gray-400",children:"Active:"}),e.jsxs("button",{type:"button",onClick:s,className:"text-xs text-[#D7FF63] hover:text-[#D7FF63]/70 bg-transparent border-none p-0 cursor-pointer transition-colors",children:[c.featureName,c.editorStepLabel&&e.jsxs("span",{className:"text-gray-500 ml-1",children:["— ",c.editorStepLabel]})]})]}),!c.featureName&&c.buildSessionCount===0&&e.jsx("p",{className:"text-xs text-gray-500 m-0 mt-2",children:"No working sessions yet. Start building to track progress here."}),!c.featureName&&c.buildSessionCount>0&&c.recentEntries.length===0&&e.jsx("p",{className:"text-xs text-gray-500 m-0 mt-2",children:"No active feature. Start a new working session in the Build tab."}),c.recentEntries.length>0&&e.jsxs("div",{className:"mt-3 space-y-1.5",children:[e.jsx("span",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider",children:"Recent"}),c.recentEntries.map(k=>e.jsxs("button",{type:"button",onClick:r,className:"w-full flex items-center gap-2 py-1 px-0 bg-transparent border-none cursor-pointer text-left group",children:[e.jsx("span",{className:`${ya[k.type]||"bg-gray-600"} text-white text-[8px] font-bold px-1.5 py-0.5 rounded uppercase tracking-wider shrink-0`,children:k.type}),e.jsx("span",{className:"text-xs text-gray-300 group-hover:text-white transition-colors truncate flex-1",children:k.title}),e.jsx("span",{className:"text-[10px] text-gray-600 shrink-0",children:va(k.time)})]},k.time)),c.buildSessionCount>3&&e.jsx("button",{type:"button",onClick:r,className:"text-xs text-[#D7FF63] hover:text-[#D7FF63]/70 bg-transparent border-none p-0 pt-1 cursor-pointer transition-colors",children:"View all working session results >"})]})]}),e.jsxs("div",{className:"bg-[#2a2a2a] border border-[#3d3d3d] rounded-lg p-4",children:[e.jsx(Us,{title:"Deploy",completedCount:L,totalCount:c.deploy.length}),e.jsx("div",{className:"mt-2",children:c.deploy.map(k=>e.jsx(Hs,{todo:k,expanded:i.has(k.id),onToggle:()=>_(k.id),onRemove:k.userCreated?()=>$("deploy",k.id):void 0,children:e.jsx("p",{className:"text-xs text-gray-500 m-0 mt-1 mb-2",children:k.completed?"Completed":"Not started yet"})},k.id))})]}),p&&e.jsx("span",{className:"text-[10px] text-gray-600",children:"Saving..."})]})})}function Ca({color:t,onColorChange:s}){const r=a.useRef(null),n=Fa(t.value),l=t.value.startsWith("#");return e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("button",{type:"button",className:"w-full h-10 rounded-md border border-[#444] cursor-pointer relative group",style:{backgroundColor:t.value},onClick:()=>{var i;return l&&((i=r.current)==null?void 0:i.click())},title:`--${t.name}: ${t.value}${t.comment?` (${t.comment})`:""}`,children:l&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity bg-black/30 rounded-md",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),e.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})})}),l&&e.jsx("input",{ref:r,type:"color",value:n,onChange:i=>s(t.name,i.target.value),className:"sr-only"}),e.jsxs("div",{className:"text-[9px] font-mono text-gray-500 truncate",title:`--${t.name}`,children:["--",t.name]}),e.jsx("div",{className:"text-[9px] font-mono text-gray-600 truncate",children:t.value})]})}function Fa(t){if(!t.startsWith("#"))return"#000000";const s=t.slice(1);return s.length===3?`#${s[0]}${s[0]}${s[1]}${s[1]}${s[2]}${s[2]}`:s.length===6||s.length===8?`#${s.slice(0,6)}`:"#000000"}function Ea({group:t,colors:s,onColorChange:r}){const[n,l]=a.useState(!1);return e.jsxs("div",{className:"mb-4",children:[e.jsxs("button",{type:"button",onClick:()=>l(!n),className:"flex items-center gap-1.5 text-[10px] font-semibold text-gray-400 uppercase tracking-wider mb-2 bg-transparent border-none p-0 cursor-pointer hover:text-gray-300 transition-colors",children:[e.jsx("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",className:`transition-transform ${n?"":"rotate-90"}`,children:e.jsx("path",{d:"M9 18l6-6-6-6"})}),t,e.jsxs("span",{className:"text-gray-600 font-normal",children:["(",s.length,")"]})]}),!n&&e.jsx("div",{className:"grid grid-cols-5 gap-2",children:s.map(i=>e.jsx(Ca,{color:i,onColorChange:r},`${i.group}-${i.name}`))})]})}function Da({designSystem:t,rawMarkdown:s,onSave:r}){const n=t.colors.reduce((c,b)=>(c[b.group]||(c[b.group]=[]),c[b.group].push(b),c),{}),l=a.useCallback((c,b)=>{const p=fa(s,c,b);r(p)},[s,r]),[i,o]=a.useState(t.fonts.length>0?t.fonts.join(", "):""),d=a.useCallback(()=>{if(!i.trim())return;const c=ga(s,`'${i.trim()}', sans-serif`);r(c)},[s,i,r]);return e.jsxs("div",{className:"space-y-6",children:[Object.keys(n).length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-medium text-white mb-3",children:"Colors"}),Object.entries(n).map(([c,b])=>e.jsx(Ea,{group:c,colors:b,onColorChange:l},c))]}),t.fonts.length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-medium text-white mb-3",children:"Typography"}),e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("label",{className:"text-[10px] text-gray-500 uppercase tracking-wider shrink-0",children:"Font"}),e.jsx("input",{type:"text",value:i,onChange:c=>o(c.target.value),onBlur:d,onKeyDown:c=>c.key==="Enter"&&d(),className:"flex-1 px-2 py-1 text-xs bg-[#222] border border-[#3d3d3d] rounded text-gray-300 outline-none focus:border-[#D7FF63]/50"})]}),t.typographyScale.length>0&&e.jsx("div",{className:"bg-[#222] rounded border border-[#333] overflow-hidden",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-[#333]",children:[e.jsx("th",{className:"text-left px-3 py-1.5 text-[9px] font-semibold text-gray-500 uppercase tracking-wider",children:"Style"}),e.jsx("th",{className:"text-left px-3 py-1.5 text-[9px] font-semibold text-gray-500 uppercase tracking-wider",children:"Size"}),e.jsx("th",{className:"text-left px-3 py-1.5 text-[9px] font-semibold text-gray-500 uppercase tracking-wider",children:"Weight"})]})}),e.jsx("tbody",{children:t.typographyScale.map(c=>e.jsxs("tr",{className:"border-b border-[#333] last:border-b-0",children:[e.jsx("td",{className:"px-3 py-1.5 text-xs text-gray-300",children:c.style}),e.jsx("td",{className:"px-3 py-1.5 text-xs font-mono text-gray-400",children:c.size}),e.jsx("td",{className:"px-3 py-1.5 text-xs font-mono text-gray-400",children:c.weight})]},c.style))})]})})]}),t.radiusTokens.length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-medium text-white mb-3",children:"Border Radius"}),e.jsx("div",{className:"flex gap-3 flex-wrap",children:t.radiusTokens.map(c=>e.jsxs("div",{className:"flex flex-col items-center gap-1",children:[e.jsx("div",{className:"w-10 h-10 bg-[#D7FF63]/20 border border-[#D7FF63]/40",style:{borderRadius:c.value}}),e.jsxs("div",{className:"text-[9px] font-mono text-gray-500",children:["--",c.name]}),e.jsx("div",{className:"text-[9px] font-mono text-gray-600",children:c.value})]},c.name))})]})]})}function Pa({content:t,onSave:s}){const[r,n]=a.useState(t),[l,i]=a.useState(!1);a.useEffect(()=>{n(t),i(!1)},[t]);const o=a.useCallback(()=>{s(r),i(!1)},[r,s]);return e.jsxs("div",{className:"flex flex-col gap-2 h-full",children:[e.jsx("textarea",{value:r,onChange:d=>{n(d.target.value),i(!0)},className:"flex-1 min-h-[400px] p-3 text-xs font-mono bg-[#1a1a1a] border border-[#3d3d3d] rounded-lg text-gray-300 outline-none focus:border-[#D7FF63]/50 resize-none leading-relaxed",spellCheck:!1}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:o,disabled:!l,className:`px-4 py-1.5 text-xs rounded-md font-medium transition-colors cursor-pointer ${l?"text-[#1e1e1e] bg-[#D7FF63] hover:bg-[#D7FF63]/80":"text-gray-500 bg-[#333] cursor-not-allowed"}`,children:"Save"}),l&&e.jsx("span",{className:"text-[10px] text-gray-500",children:"Unsaved changes"})]})]})}function Ta({onClose:t}){return e.jsx("div",{className:"border border-[#3d3d3d] rounded-lg overflow-hidden",children:e.jsx(De,{prompt:`# Edit Design System
90
+
91
+ You are helping the user edit their design system file at \`.codeyam/design-system.md\`.
92
+
93
+ Read the current design system file first, then ask the user what they'd like to change. Common changes include:
94
+ - Changing colors (background, text, accent colors)
95
+ - Switching fonts or typography scale
96
+ - Adjusting spacing, radius, or shadow values
97
+ - Adding or removing theme modes (light/dark)
98
+ - Changing the overall aesthetic (minimal, bold, editorial, etc.)
99
+
100
+ After making changes, briefly summarize what was updated.`,height:500,onClose:t})})}function $a({onBack:t,onPreviewShowcase:s}){const[r,n]=a.useState("visual"),[l,i]=a.useState(null),[o,d]=a.useState(null),[c,b]=a.useState(!1),[p,h]=a.useState(!1),g=a.useCallback(()=>{fetch("/api/editor-design-system").then(u=>u.json()).then(u=>{u.exists&&u.content&&(i(u.content),d(zt(u.content)))}).catch(()=>{})},[]);a.useEffect(()=>{g()},[g]),a.useEffect(()=>{if(r!=="claude"||!p)return;const u=setInterval(g,3e3);return()=>clearInterval(u)},[r,p,g]);const M=a.useCallback(u=>{b(!0),i(u),d(zt(u)),fetch("/api/editor-design-system",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:u})}).then(()=>{s()}).catch(()=>{}).finally(()=>b(!1))},[s]);if(!l||!o)return e.jsx("div",{className:"flex-1 flex items-center justify-center font-['IBM_Plex_Sans']",children:e.jsx("span",{className:"text-sm text-gray-500",children:"Loading design system..."})});const w=[{id:"visual",label:"Visual"},{id:"markdown",label:"Markdown"},{id:"claude",label:"Claude"}];return e.jsx("div",{className:"flex-1 overflow-auto font-['IBM_Plex_Sans']",children:e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("button",{type:"button",onClick:t,className:"flex items-center gap-1.5 text-xs text-gray-500 hover:text-white bg-transparent border-none p-0 cursor-pointer transition-colors",children:[e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M15 18l-6-6 6-6"})}),"Back to Roadmap"]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-medium text-white m-0",children:o.name}),o.description&&e.jsx("p",{className:"text-xs text-gray-500 m-0 mt-1 max-w-md",children:o.description})]}),e.jsxs("button",{type:"button",onClick:s,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs text-[#1e1e1e] bg-[#D7FF63] rounded-md hover:bg-[#D7FF63]/80 transition-colors cursor-pointer font-medium",children:[e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),e.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),"Preview Components"]})]}),e.jsx("div",{className:"flex gap-1 bg-[#222] rounded-lg p-0.5 w-fit border border-[#333]",children:w.map(u=>e.jsx("button",{type:"button",onClick:()=>{n(u.id),u.id==="claude"&&h(!0)},className:`px-3 py-1 text-xs rounded-md transition-colors cursor-pointer border-none ${r===u.id?"bg-[#3a3a3a] text-white font-medium":"bg-transparent text-gray-500 hover:text-gray-300"}`,children:u.label},u.id))}),e.jsxs("div",{className:"bg-[#2a2a2a] border border-[#3d3d3d] rounded-lg p-4",children:[r==="visual"&&e.jsx(Da,{designSystem:o,rawMarkdown:l,onSave:M}),r==="markdown"&&e.jsx(Pa,{content:l,onSave:M}),r==="claude"&&p&&e.jsx(Ta,{onClose:()=>{h(!1),g()}}),r==="claude"&&!p&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 gap-3",children:[e.jsx("p",{className:"text-xs text-gray-500",children:"Use Claude to make design system changes with natural language."}),e.jsx("button",{type:"button",onClick:()=>h(!0),className:"px-4 py-2 text-xs text-[#1e1e1e] bg-[#D7FF63] rounded-md hover:bg-[#D7FF63]/80 transition-colors cursor-pointer font-medium",children:"Start Claude Chat"})]})]}),c&&e.jsx("span",{className:"text-[10px] text-gray-600",children:"Saving..."})]})})}const ut=[{key:"languages",label:"Languages"},{key:"frameworks",label:"Frameworks"},{key:"databases",label:"Databases"},{key:"services",label:"External Services"},{key:"libraries",label:"Key Libraries"},{key:"infrastructure",label:"Infrastructure"}];function La({onBack:t}){const[s,r]=a.useState(null),[n,l]=a.useState(!1),[i,o]=a.useState(!1),[d,c]=a.useState({}),[b,p]=a.useState(!1),h=typeof window<"u"?window.location.origin:"",g=a.useCallback(()=>{fetch("/api/editor-project-info").then(P=>P.json()).then(P=>{r(P.techStack||null),l(!0)}).catch(()=>l(!0))},[]);a.useEffect(()=>{g()},[g]);const M=a.useCallback(P=>{fetch("/api/editor-project-info",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({techStack:P})}).then(()=>g()).catch(()=>{})},[g]),w=()=>{c(s?JSON.parse(JSON.stringify(s)):{}),o(!0)},u=()=>{const P={};for(const{key:J}of ut){const _=d[J];_&&_.length>0&&(P[J]=_.filter(O=>O.name.trim()!==""))}M(P),o(!1)},y=P=>{c(J=>({...J,[P]:[...J[P]||[],{name:"",url:"",description:""}]}))},C=(P,J)=>{c(_=>({..._,[P]:(_[P]||[]).filter((O,E)=>E!==J)}))},I=(P,J,_,O)=>{c(E=>({...E,[P]:(E[P]||[]).map((v,L)=>L===J?{...v,[_]:O}:v)}))},$=(P,J,_)=>{const O=_.split(",").map(E=>E.trim()).filter(Boolean);c(E=>({...E,[P]:(E[P]||[]).map((v,L)=>L===J?{...v,envKeys:O}:v)}))},B=a.useMemo(()=>`# Detect and Set Up Tech Stack
101
+
102
+ You are helping the user configure their project's tech stack in CodeYam.
103
+
104
+ ## Instructions
105
+
106
+ 1. Read \`package.json\` to find all dependencies and devDependencies
107
+ 2. Check for framework config files: \`next.config.js\`, \`next.config.ts\`, \`tailwind.config.js\`, \`prisma/schema.prisma\`, \`tsconfig.json\`, \`vite.config.ts\`, etc.
108
+ 3. Check \`.env\`, \`.env.example\`, \`.env.local\` for service references (e.g., STRIPE_SECRET_KEY, DATABASE_URL, OPENAI_API_KEY)
109
+ 4. Categorize everything into: languages, frameworks, databases, services, libraries, infrastructure
110
+
111
+ ## Tech Stack Categories
112
+
113
+ - **languages**: Programming languages (TypeScript, JavaScript, Python, etc.)
114
+ - **frameworks**: Application frameworks (Next.js, React, Express, etc.)
115
+ - **databases**: Database systems (PostgreSQL, SQLite, MongoDB, etc.)
116
+ - **services**: External services/APIs (Stripe, Auth0, SendGrid, AWS S3, etc.) — include \`url\` and \`envKeys\` for each
117
+ - **libraries**: Key libraries beyond the framework (Prisma, Tailwind CSS, Zod, etc.)
118
+ - **infrastructure**: Deployment/infrastructure tools (Vercel, Docker, etc.)
119
+
120
+ ## Output Format
121
+
122
+ After scanning, POST the tech stack:
123
+
124
+ \`\`\`bash
125
+ curl -s -X POST ${h}/api/editor-project-info \\
126
+ -H "Content-Type: application/json" \\
127
+ -d '{"techStack":{"languages":[{"name":"TypeScript","url":"https://typescriptlang.org","description":"Statically typed JavaScript superset","version":"5"}],"frameworks":[{"name":"Next.js","url":"https://nextjs.org","description":"Full-stack React framework with SSR and API routes","version":"15"}],"databases":[{"name":"SQLite","url":"https://sqlite.org","description":"Embedded relational database"}],"services":[{"name":"Stripe","url":"https://stripe.com","description":"Payment processing and billing","envKeys":["STRIPE_SECRET_KEY","STRIPE_PUBLISHABLE_KEY"]}],"libraries":[{"name":"Prisma","url":"https://prisma.io","description":"Type-safe database ORM and query builder","version":"7"}],"infrastructure":[]}}'
128
+ \`\`\`
129
+
130
+ Replace the example values with what you actually detect. For each item:
131
+ - \`name\` (required): Technology name
132
+ - \`url\` (required): Link to homepage or docs
133
+ - \`description\` (required): Brief description of what it does or how it's used in this project
134
+ - \`version\` (optional): Version number
135
+ - \`envKeys\` (optional): Array of environment variable names associated with this tech
136
+
137
+ Omit empty categories. After posting, briefly summarize what was detected.`,[h]),H=s&&ut.some(({key:P})=>s[P]&&s[P].length>0);return e.jsx("div",{className:"flex-1 overflow-auto font-['IBM_Plex_Sans']",children:e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("button",{type:"button",onClick:t,className:"flex items-center gap-1.5 text-xs text-gray-500 hover:text-white bg-transparent border-none p-0 cursor-pointer transition-colors",children:[e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M15 18l-6-6 6-6"})}),"Back to Roadmap"]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-lg font-medium text-white m-0",children:"Tech Stack"}),e.jsx("div",{className:"flex items-center gap-2",children:n&&!i&&!b&&(H?e.jsx("button",{type:"button",onClick:w,className:"px-3 py-1.5 text-[11px] font-medium text-[#1e1e1e] bg-[#D7FF63] rounded-md hover:bg-[#D7FF63]/80 transition-colors cursor-pointer",children:"Edit"}):e.jsx("button",{type:"button",onClick:()=>p(!0),className:"px-3 py-1.5 text-[11px] font-medium text-[#1e1e1e] bg-[#D7FF63] rounded-md hover:bg-[#D7FF63]/80 transition-colors cursor-pointer",children:"Set up with Claude"}))})]}),b&&e.jsx("div",{className:"border border-[#3d3d3d] rounded-lg overflow-hidden",children:e.jsx(De,{prompt:B,height:400,onClose:()=>{p(!1),g()}})}),i&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("button",{type:"button",onClick:()=>{o(!1),p(!0)},className:"px-3 py-1.5 text-[11px] font-medium text-[#1e1e1e] bg-[#D7FF63] rounded-md hover:bg-[#D7FF63]/80 transition-colors cursor-pointer",children:"Re-detect with Claude"}),ut.map(({key:P,label:J})=>{const _=d[P]||[];return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("label",{className:"text-[11px] font-semibold text-gray-500 uppercase tracking-wider",children:J}),e.jsx("button",{type:"button",onClick:()=>y(P),className:"text-[11px] text-[#D7FF63] hover:text-[#D7FF63]/70 bg-transparent border-none p-0 cursor-pointer transition-colors",children:"+ Add"})]}),_.map((O,E)=>e.jsxs("div",{className:"bg-[#2a2a2a] border border-[#3d3d3d] rounded-lg p-2.5 mb-2 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("input",{type:"text",value:O.name,onChange:v=>I(P,E,"name",v.target.value),placeholder:"Name *",className:"flex-1 min-w-0 px-2 py-1 text-xs bg-[#1e1e1e] border border-[#3d3d3d] rounded text-gray-200 placeholder-gray-600 outline-none focus:border-[#D7FF63]/50 transition-colors font-medium"}),e.jsx("input",{type:"text",value:O.version||"",onChange:v=>I(P,E,"version",v.target.value),placeholder:"Version",className:"w-20 px-2 py-1 text-xs bg-[#1e1e1e] border border-[#3d3d3d] rounded text-gray-200 placeholder-gray-600 outline-none focus:border-[#D7FF63]/50 transition-colors"}),e.jsx("button",{type:"button",onClick:()=>C(P,E),className:"text-gray-600 hover:text-red-400 bg-transparent border-none p-0.5 cursor-pointer transition-colors text-xs leading-none",children:"×"})]}),e.jsx("input",{type:"text",value:O.url||"",onChange:v=>I(P,E,"url",v.target.value),placeholder:"URL * (e.g. https://stripe.com)",className:"w-full px-2 py-1 text-[11px] bg-[#1e1e1e] border border-[#3d3d3d] rounded text-gray-300 placeholder-gray-600 outline-none focus:border-[#D7FF63]/50 transition-colors"}),e.jsx("input",{type:"text",value:O.description||"",onChange:v=>I(P,E,"description",v.target.value),placeholder:"Description * (e.g. Payment processing and billing)",className:"w-full px-2 py-1 text-[11px] bg-[#1e1e1e] border border-[#3d3d3d] rounded text-gray-300 placeholder-gray-600 outline-none focus:border-[#D7FF63]/50 transition-colors"}),e.jsx("input",{type:"text",value:(O.envKeys||[]).join(", "),onChange:v=>$(P,E,v.target.value),placeholder:"ENV_KEYS (comma-separated, e.g. STRIPE_SECRET_KEY, STRIPE_PUBLISHABLE_KEY)",className:"w-full px-2 py-1 text-[10px] bg-[#1e1e1e] border border-[#3d3d3d] rounded text-gray-400 placeholder-gray-600 outline-none focus:border-[#D7FF63]/50 transition-colors font-mono"})]},E)),_.length===0&&e.jsx("div",{className:"text-[11px] text-gray-600 italic py-1",children:"No items"})]},P)}),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsx("button",{type:"button",onClick:u,className:"px-4 py-1.5 text-[11px] text-[#1e1e1e] bg-[#D7FF63] rounded-md hover:bg-[#D7FF63]/80 transition-colors cursor-pointer font-medium",children:"Save"}),e.jsx("button",{type:"button",onClick:()=>o(!1),className:"px-4 py-1.5 text-[11px] text-gray-400 bg-transparent border border-[#3d3d3d] rounded-md hover:text-white hover:border-[#555] transition-colors cursor-pointer",children:"Cancel"})]})]}),!i&&!b&&e.jsx(e.Fragment,{children:H?e.jsx("div",{className:"space-y-4",children:ut.map(({key:P,label:J})=>{const _=s[P];return!_||_.length===0?null:e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] font-semibold text-gray-500 uppercase tracking-wider mb-2",children:J}),e.jsx("div",{className:"space-y-2",children:_.map((O,E)=>e.jsxs("div",{className:"bg-[#2a2a2a] rounded-lg px-3 py-2.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[O.url?e.jsx("a",{href:O.url,target:"_blank",rel:"noopener noreferrer",className:"text-sm font-medium text-gray-200 hover:text-[#D7FF63] transition-colors",children:O.name}):e.jsx("span",{className:"text-sm font-medium text-gray-200",children:O.name}),O.version&&e.jsxs("span",{className:"text-[11px] text-gray-500",children:["v",O.version]}),O.url&&e.jsx("a",{href:O.url,target:"_blank",rel:"noopener noreferrer",className:"text-[11px] text-gray-600 hover:text-gray-400 transition-colors truncate",children:O.url.replace(/^https?:\/\//,"")})]}),O.description&&e.jsx("div",{className:"text-xs text-gray-400 mt-1",children:O.description}),O.envKeys&&O.envKeys.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mt-1.5",children:O.envKeys.map((v,L)=>e.jsx("span",{className:"text-[10px] text-[#D7FF63]/60 bg-[#D7FF63]/10 px-1.5 py-0.5 rounded font-mono",children:v},L))})]},E))})]},P)})}):e.jsx("div",{className:"text-xs text-gray-500 italic py-4",children:"No tech stack configured yet. Use the buttons above to set up your project's tech stack."})})]})})}function Ma({hasProject:t,scenarios:s,analyzedEntities:r,allEntities:n=[],glossaryFunctions:l=[],cachedTestResults:i={},glossaryEntries:o=[],projectRoot:d,activeScenarioId:c,onScenarioSelect:b,onAnalyzedScenarioSelect:p,onSwitchToBuild:h,onSwitchToHistory:g,zoomComponent:M,focusedEntity:w,onZoomChange:u,entityImports:y,pageFilePaths:C={},projectTitle:I,projectDescription:$,migrationMode:B="none",migrationState:H,onStartMigration:P,breadcrumbItems:J=[],onReseedPreview:_,isAdmin:O=!1,roadmapView:E=!1,onRoadmapViewChange:v,designSystemView:L=!1,onDesignSystemViewChange:W,onPreviewDesignSystem:U,techStackView:k=!1,onTechStackViewChange:F}){const{pageGroups:D,componentGroups:f}=a.useMemo(()=>Ut(s),[s]),S=a.useMemo(()=>tr(D,f),[D,f]),j=a.useMemo(()=>new Set(r.map(V=>V.sha)),[r]),A=a.useMemo(()=>Bn(y||{}),[y]),R=a.useCallback(V=>_n(V,j,n,A),[j,n,A]),Y=a.useMemo(()=>{const V=new Map;for(const Q of n)V.set(Q.sha,Q.name);return V},[n]),Z=a.useMemo(()=>Wn(D,f,S,R),[D,f,S,R]),se=a.useMemo(()=>r.filter(V=>V.entityType==="visual").sort((V,Q)=>V.name.localeCompare(Q.name)),[r]),[K,ae]=a.useState(()=>{try{return localStorage.getItem("codeyam-app-banner-dismissed")==="true"}catch{return!1}}),pe=a.useCallback(()=>{ae(!0);try{localStorage.setItem("codeyam-app-banner-dismissed","true")}catch{}},[]),[ie,le]=a.useState(""),[me,Te]=a.useState(()=>new Set),ge=a.useRef(null),ce=a.useRef(0),be=a.useCallback(()=>{ge.current&&(ce.current=ge.current.scrollTop)},[]);a.useEffect(()=>{ge.current&&ce.current>0&&(ge.current.scrollTop=ce.current)});const ne=(w==null?void 0:w.sha)??"overview";if(!t)return e.jsx("div",{className:"flex-1 flex items-center justify-center font-['IBM_Plex_Sans']",children:e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx("h2",{className:"text-lg font-medium text-white m-0",children:"Ready to build something?"}),e.jsx("button",{onClick:h,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(B==="candidate")return e.jsx("div",{className:"flex-1 flex items-center justify-center font-['IBM_Plex_Sans']",children:e.jsxs("div",{className:"flex flex-col items-center gap-5 px-8 text-center max-w-[420px]",children:[e.jsx("h2",{className:"text-lg font-medium text-white m-0",children:"Migrate Your Project"}),e.jsx("p",{className:"text-sm text-gray-400 m-0 leading-relaxed",children:"It looks like you have an existing project. Claude can survey your codebase and systematically migrate it — deconstructing pages into clean components, extracting functions with tests, and creating scenarios. One page per session."}),e.jsx("button",{onClick:P,className:"px-6 py-3 bg-[#005c75] text-white text-sm font-medium rounded-lg hover:bg-[#004d63] transition-colors cursor-pointer",children:"Get Started"}),e.jsx("button",{onClick:h,className:"text-xs text-gray-500 hover:text-gray-300 bg-transparent border-none p-0 cursor-pointer underline",children:"Skip — build a new feature instead"})]})});if(B==="active"&&H){const V=H.pages||[],Q=V.filter(G=>G.status==="complete").length,m=V.length,z=m>0?Math.round(Q/m*100):0;return e.jsxs("div",{className:"flex-1 flex flex-col overflow-auto p-4 font-['IBM_Plex_Sans']",children:[e.jsx("h2",{className:"text-lg font-medium text-white m-0 mb-3",children:"Project Migration"}),e.jsxs("div",{className:"mb-4",children:[e.jsx("div",{className:"flex items-center gap-2 mb-1",children:e.jsxs("span",{className:"text-xs text-gray-400",children:[Q,"/",m," pages (",z,"%)"]})}),e.jsx("div",{className:"w-full h-1.5 bg-[#2d2d2d] rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-[#005c75] rounded-full transition-all",style:{width:`${z}%`}})})]}),e.jsx("div",{className:"space-y-1.5",children:V.map((G,X)=>{const de=G.status==="complete"?"✓":G.status==="in-progress"?"→":"○",ye=G.status==="complete"?"text-green-400":G.status==="in-progress"?"text-cyan-400":"text-gray-600";return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`text-xs ${ye} w-3 text-center`,children:de}),e.jsx("span",{className:`text-xs ${G.status==="in-progress"?"text-white font-medium":G.status==="complete"?"text-gray-400":"text-gray-600"}`,children:G.name}),e.jsx("span",{className:"text-[10px] text-gray-600",children:G.route}),G.status==="complete"&&e.jsxs("span",{className:"text-[10px] text-gray-600",children:[(G.extractedComponents||[]).length,"c"," ",(G.extractedFunctions||[]).length,"f"," ",G.scenarioCount||0,"s"]})]},X)})}),(H.sharedComponents||[]).length>0&&e.jsxs("div",{className:"mt-4",children:[e.jsx("h3",{className:"text-xs font-medium text-gray-400 mb-1.5",children:"Shared Components"}),(H.sharedComponents||[]).map((G,X)=>e.jsxs("div",{className:"text-[10px] text-gray-500 mb-0.5",children:[G.name," ",e.jsxs("span",{className:"text-gray-600",children:["— used in: ",(G.usedInPages||[]).join(", ")]})]},X))]}),e.jsx("div",{className:"mt-4",children:e.jsx("button",{onClick:h,className:"px-4 py-2 bg-[#005c75] text-white text-xs font-medium rounded-lg hover:bg-[#004d63] transition-colors cursor-pointer",children:"Continue in Chat"})})]})}return s.length>0||se.length>0?w?e.jsx(ar,{focusedEntity:w,breadcrumbItems:J,onZoomChange:u,projectRoot:d,scenarios:s,analyzedEntities:r,activeScenarioId:c,onScenarioSelect:b,onAnalyzedScenarioSelect:p,onSwitchToBuild:h,entityImports:y,glossaryFunctions:l,cachedTestResults:i,glossaryEntries:o,entityShaMap:S,componentGroups:f,visualEntities:se,isEntityComplete:R,onReseedPreview:_}):k?e.jsx(La,{onBack:()=>{F==null||F(!1),v==null||v(!0)}}):L?e.jsx($a,{onBack:()=>{W==null||W(!1),v==null||v(!0)},onPreviewShowcase:()=>U==null?void 0:U()}):O&&E?e.jsx(Sa,{onBack:()=>v==null?void 0:v(!1),onSwitchToBuild:h,onSwitchToHistory:g,onNavigateToDesignSystem:()=>{v==null||v(!1),W==null||W(!0)},onNavigateToTechStack:()=>{v==null||v(!1),F==null||F(!0)},expandedTasks:me,onExpandedTasksChange:Te}):e.jsx("div",{ref:ge,onScroll:be,className:"flex-1 overflow-auto font-['IBM_Plex_Sans']",children:e.jsxs("div",{className:"p-4 space-y-4 flex flex-col gap-12",children:[Z.length>1&&e.jsx(Un,{brokenEntities:Z}),!K&&e.jsxs("div",{className:"relative border border-[#2e7d32]/40 bg-cybg rounded-lg p-4 pr-10",children:[e.jsx("button",{onClick:pe,className:"absolute top-3 right-3 text-[#D7FF63] hover:text-white bg-transparent border-none cursor-pointer p-0.5",title:"Dismiss",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:e.jsx("path",{d:"M2 2l8 8M10 2l-8 8"})})}),e.jsx("p",{className:"text-sm text-white font-medium m-0 leading-snug",children:"These are all the pages in your project."}),e.jsxs("p",{className:"text-sm text-gray-400 m-0 leading-snug mt-0.5",children:["(1) Select a scenario below and switch to"," ",e.jsx("button",{type:"button",onClick:h,className:"underline text-[#D7FF63] bg-transparent border-none cursor-pointer p-0 text-sm inline hover:text-[#D7FF63]/70 transition-colors",children:"build"})," ","to change or enhance an existing page."]}),e.jsx("p",{className:"text-sm text-gray-400 m-0 leading-snug mt-0.5",children:"(2) Select a page to see all of its sub-components and edit scenarios."})]}),O&&e.jsx("div",{className:"mb-4",children:e.jsx(ca,{onNavigateToRoadmap:()=>v==null?void 0:v(!0),onSwitchToBuild:h})}),D.size>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-3 font-['IBM_Plex_Mono']",children:[e.jsx("span",{className:"text-xs font-bold text-gray-400 uppercase tracking-wider shrink-0",children:"Pages"}),e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:"relative",style:{width:170},children:[e.jsxs("svg",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-500",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("path",{d:"M21 21l-4.35-4.35"})]}),e.jsx("input",{type:"text",placeholder:"SEARCH...",value:ie,onChange:V=>le(V.target.value),className:"w-full pl-9 pr-3 py-2 text-xs bg-[#2a2a2a] border border-[#3d3d3d] rounded-md text-gray-300 placeholder-gray-600 outline-none focus:border-[#D7FF63]/50 transition-colors tracking-wider"})]}),e.jsxs("button",{onClick:h,className:"flex items-center gap-1.5 px-4 py-2 text-xs font-semibold text-[#1e1e1e] bg-[#D7FF63] rounded-md hover:bg-[#D7FF63]/80 transition-colors cursor-pointer shrink-0 uppercase tracking-wider",children:[e.jsx("span",{children:"+"})," New Page"]})]}),e.jsx("div",{className:"border-b border-[#2d2d2d] mt-3"}),[...D.entries()].sort(([V],[Q])=>V==="Home"?-1:Q==="Home"?1:V.localeCompare(Q)).filter(([V])=>{if(!ie.trim())return!0;const Q=S.get(V);return((Q?Y.get(Q):void 0)||V).toLowerCase().includes(ie.trim().toLowerCase())}).map(([V,Q])=>{const m=Q.some(z=>z.id===c);return e.jsx("div",{className:"mt-2",children:S.has(V)&&R(S.get(V))?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex items-center gap-1.5 py-1",children:e.jsxs("button",{onClick:()=>u(V,S.get(V)),className:`flex items-center gap-1.5 text-sm font-normal cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0 ${m?"text-[#D7FF63]":"text-gray-300"}`,children:[(()=>{const z=S.get(V);return(z?Y.get(z):void 0)||V})(),e.jsxs("span",{className:`font-normal text-sm ${m?"text-[#D7FF63]/60":"text-gray-500"}`,children:["(",Q.length,")"]}),e.jsx("svg",{className:m?"text-[#D7FF63]/60":"text-gray-500",width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M9 18l6-6-6-6"})})]})}),e.jsx("div",{className:"grid grid-cols-3 gap-2 pt-1",children:Se(Q).map(({scenario:z,dimensionLabel:G,screenshotPath:X,key:de})=>e.jsx(mt,{scenarioId:z.id,screenshotPath:X,updatedAt:z.updatedAt,hasScreenshot:!!X,name:z.name,dimensionLabel:G,isActive:z.id===c,onSelect:()=>b(z,G??void 0)},de))})]}):e.jsxs("div",{className:"py-2",children:[e.jsx("span",{className:"text-sm font-normal text-gray-500",children:(()=>{const z=S.get(V);return z&&Y.get(z)||V})()}),e.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#E0D400",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),e.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),e.jsx("p",{className:"text-xs text-[#E0D400]/80 m-0 leading-relaxed",children:"Data missing for this page."}),e.jsx(nr,{name:V,scenarios:Q,reason:S.has(V)?"incomplete":"missing"})]})]})},V)})]})]})},ne):e.jsx("div",{className:"flex-1 flex items-center justify-center font-['IBM_Plex_Sans']",children:e.jsxs("div",{className:"flex flex-col items-center gap-4 px-8 text-center",children:[I?e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"text-lg font-medium text-white m-0",children:I}),$&&e.jsx("p",{className:"text-sm text-gray-400 m-0 leading-relaxed",children:$})]}):e.jsx("h2",{className:"text-lg font-medium text-white m-0",children:"Your project is ready"}),e.jsx("p",{className:"text-sm text-gray-400 m-0 leading-relaxed",children:"Describe what you want to build in the Chat and your pages and components will appear here."}),e.jsx("button",{onClick:h,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"})]})})}const Ys=[{key:"app",label:"App"},{key:"build",label:"Build"},{key:"data",label:"Structure"},{key:"history",label:"History"}],Ia=()=>e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 12 12",fill:"none",className:"text-[#8E8E8E] shrink-0",children:e.jsx("path",{d:"M4.5 3L7.5 6L4.5 9",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})});function Aa({activeTab:t,onTabChange:s,buildIdle:r,projectTitle:n,breadcrumbItems:l,onBreadcrumbNavigate:i}){const[o,d]=a.useState(!1),c=a.useRef(null);a.useEffect(()=>{if(!o)return;const p=h=>{c.current&&!c.current.contains(h.target)&&d(!1)};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[o]);const b=l&&l.length>0;return e.jsxs("div",{className:"shrink-0 z-20 @container",children:[e.jsxs("div",{className:"bg-black h-10 flex items-center px-4 gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx("img",{src:gn,alt:"CodeYam",className:"h-5 shrink-0"}),e.jsx("span",{className:"text-sm font-medium text-white whitespace-nowrap hidden @min-[500px]:inline",children:"CodeYam Editor"})]}),e.jsx("span",{className:"text-[#8E8E8E] text-sm shrink-0",children:"/"}),e.jsx("div",{className:"hidden @min-[350px]:flex items-center gap-1",children:Ys.map(p=>e.jsxs("button",{onClick:()=>s(p.key),className:`px-2.5 py-2.5 text-sm transition-colors cursor-pointer border-b ${t===p.key?"text-[#D7FF63] border-[#D7FF63] font-medium":"text-[#8E8E8E] border-transparent hover:text-white font-light"}`,children:[p.label,p.key==="build"&&r&&t!=="build"&&e.jsx("span",{className:"ml-1 inline-block w-1.5 h-1.5 rounded-full bg-amber-400 animate-pulse"})]},p.key))})]}),e.jsx("div",{className:"flex-1"}),e.jsx("button",{onClick:()=>s("settings"),className:`hidden @min-[350px]:block p-1.5 rounded-md transition-colors cursor-pointer ${t==="settings"?"text-[#D7FF63]":"text-[#8E8E8E] hover:text-white"}`,title:"Settings",children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"3"}),e.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]})}),e.jsxs("div",{className:"@min-[350px]:hidden relative",ref:c,children:[e.jsx("button",{onClick:()=>d(!o),className:"p-1.5 rounded-md transition-colors cursor-pointer text-[#8E8E8E] hover:text-white",title:"Menu",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[e.jsx("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),e.jsx("line",{x1:"3",y1:"12",x2:"21",y2:"12"}),e.jsx("line",{x1:"3",y1:"18",x2:"21",y2:"18"})]})}),o&&e.jsxs("div",{className:"absolute right-0 top-full mt-1 bg-[#2d2d2d] border border-[#3d3d3d] rounded-lg shadow-lg py-1 min-w-[140px] z-50",children:[Ys.map(p=>e.jsxs("button",{onClick:()=>{s(p.key),d(!1)},className:`w-full text-left px-4 py-2 text-sm transition-colors cursor-pointer bg-transparent border-none ${t===p.key?"text-[#D7FF63]":"text-[#8E8E8E] hover:text-white hover:bg-[#3d3d3d]"}`,children:[p.label,p.key==="build"&&r&&t!=="build"&&e.jsx("span",{className:"ml-1 inline-block w-1.5 h-1.5 rounded-full bg-amber-400 animate-pulse"})]},p.key)),e.jsx("div",{className:"border-t border-[#3d3d3d] my-1"}),e.jsx("button",{onClick:()=>{s("settings"),d(!1)},className:`w-full text-left px-4 py-2 text-sm transition-colors cursor-pointer bg-transparent border-none ${t==="settings"?"text-[#D7FF63]":"text-[#8E8E8E] hover:text-white hover:bg-[#3d3d3d]"}`,children:"Settings"})]})]})]}),e.jsx("div",{className:`bg-[#161616] h-8 flex items-center px-4 border-b border-[#2d2d2d]${t==="build"?" hidden":""}`,children:e.jsx("nav",{className:"flex items-center gap-2 text-sm min-w-0",children:b?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>i==null?void 0:i(),className:"text-[#8E8E8E] hover:text-white transition-colors bg-transparent border-none p-0 cursor-pointer shrink-0",children:n||"Untitled Project"}),l.slice(1).map((p,h)=>{const g=h===l.length-2;return e.jsxs("span",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(Ia,{}),g?e.jsx("span",{className:"text-white truncate",children:p.name}):e.jsx("button",{type:"button",onClick:()=>i==null?void 0:i(p.componentName,p.entitySha),className:"text-[#8E8E8E] hover:text-white transition-colors bg-transparent border-none p-0 cursor-pointer truncate",children:p.name})]},p.componentName||p.name)})]}):e.jsx("span",{className:"text-[#8E8E8E]",children:n||"Untitled Project"})})})]})}function Ra({onMouseDown:t,onDoubleClick:s,isDragging:r}){return e.jsxs("div",{className:"shrink-0 relative flex items-center justify-center cursor-col-resize group",style:{width:12},onMouseDown:t,onDoubleClick:s,children:[e.jsx("div",{className:"absolute inset-y-0 left-1/2 -translate-x-1/2",style:{width:r?3:1,backgroundColor:r?"#3b82f6":"#3d3d3d",transition:"width 100ms, background-color 100ms"}}),!r&&e.jsx("div",{className:"absolute inset-0 bg-blue-500/0 group-hover:bg-blue-500/20 transition-colors pointer-events-none"}),e.jsxs("div",{className:"relative z-10 flex flex-col gap-[3px] opacity-0 group-hover:opacity-100 transition-opacity",style:r?{opacity:1}:void 0,children:[e.jsx("div",{className:"w-2 h-px bg-gray-400"}),e.jsx("div",{className:"w-2 h-px bg-gray-400"}),e.jsx("div",{className:"w-2 h-px bg-gray-400"})]})]})}const qs=300,ht=150;function Oa(t){const[s,r]=a.useState(null),[n,l]=a.useState(!1),i=a.useRef(0),o=a.useRef(null);a.useEffect(()=>{t.current&&r(Math.round(t.current.offsetWidth*.5))},[t]);const d=a.useCallback(()=>{var y;return((y=t.current)==null?void 0:y.offsetWidth)??(typeof window<"u"?window.innerWidth:1024)},[t]),c=a.useCallback(y=>{y.preventDefault(),l(!0)},[]),b=a.useCallback(()=>{r(Math.round(d()*.5))},[d]),p=a.useCallback(()=>{r(y=>(y&&y>0&&(o.current=y),0))},[]),h=a.useCallback(()=>{const y=o.current;o.current=null,r(y&&y>=qs?y:Math.round(d()*.5))},[d]),g=a.useCallback(()=>{r(Math.round(d()*.5))},[d]);a.useEffect(()=>{if(!n)return;document.body.style.cursor="col-resize",document.body.style.userSelect="none";const y=I=>{cancelAnimationFrame(i.current),i.current=requestAnimationFrame(()=>{var O;const $=(O=t.current)==null?void 0:O.getBoundingClientRect(),B=($==null?void 0:$.left)??0,P=(($==null?void 0:$.width)??window.innerWidth)-ht,J=I.clientX-B,_=Math.min(Math.max(J,qs),P);r(_)})},C=I=>{var J;cancelAnimationFrame(i.current),l(!1);const $=(J=t.current)==null?void 0:J.getBoundingClientRect(),B=($==null?void 0:$.left)??0,H=($==null?void 0:$.width)??window.innerWidth,P=I.clientX-B;P<ht?r(0):H-P<ht&&r(H)};return document.addEventListener("mousemove",y),document.addEventListener("mouseup",C),()=>{cancelAnimationFrame(i.current),document.removeEventListener("mousemove",y),document.removeEventListener("mouseup",C),document.body.style.cursor="",document.body.style.userSelect=""}},[n,t]),a.useEffect(()=>{const y=()=>{r(C=>{if(C===null||C===0)return C;const I=d();return C>=I?I:Math.min(C,I-ht)})};if(!(typeof window>"u"))return window.addEventListener("resize",y),()=>window.removeEventListener("resize",y)},[d]);const M=d(),w=s===0,u=s!==null&&s>=M;return{editorWidth:s,isDragging:n,isEditorCollapsed:w,isPreviewCollapsed:u,handleMouseDown:c,handleDoubleClick:b,collapseEditor:p,expandEditor:h,expandPreview:g}}function Ba({preview:t,viewportWidth:s,viewportHeight:r,scale:n,onDismiss:l,onLoadCommit:i}){const o=s*n,d=r*n;return e.jsxs("div",{className:"flex flex-col items-center gap-4 w-full",style:{maxWidth:`${o}px`},children:[e.jsxs("div",{className:"text-center shrink-0",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 border-2 border-[#ccc] shadow-md overflow-y-auto overflow-x-hidden shrink",style:{width:`${o}px`,maxHeight:`${d}px`},children:e.jsx("img",{src:t.screenshotUrl,alt:t.scenarioName,className:"block",style:{width:`${o}px`}})}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-[#666] shrink-0",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 shrink-0",children:t.commitSha&&i&&e.jsx(_a,{commitSha:t.commitSha,onLoadCommit:i})})]})}function _a({commitSha:t,onLoadCommit:s}){const[r,n]=a.useState(!1),[l,i]=a.useState(null);return e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>{n(!0),i(null),s(t).then(o=>{o.success||i(o.error||"Failed to load commit")}).catch(o=>{i(o instanceof Error?o.message:"Network error")}).finally(()=>n(!1))},disabled:r,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:r?"Reverting...":"Revert to this code and load this version"}),l&&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:l})]})}function Wa({preview:t,viewportWidth:s,viewportHeight:r,scale:n,onDismiss:l}){const i=s*n,o=r*n;return e.jsxs("div",{className:"flex flex-col items-center gap-4 w-full",style:{maxWidth:`${i}px`},children:[e.jsxs("div",{className:"text-center shrink-0",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-200 m-0 font-['IBM_Plex_Sans']",children:t.scenarioName}),e.jsxs("div",{className:"flex items-center justify-center gap-2 mt-2",children:[e.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-amber-400 animate-pulse"}),e.jsx("p",{className:"text-sm text-amber-400/90 m-0 font-['IBM_Plex_Sans']",children:"The app is being edited - you can control the live preview when building is paused or complete."})]})]}),t.hasScreenshot?e.jsx("div",{className:"rounded-lg border-2 border-[#4d4d4d] shadow-md overflow-y-auto overflow-x-hidden shrink",style:{width:`${i}px`,maxHeight:`${o}px`},children:e.jsx(ze,{scenarioId:t.scenarioId,screenshotPath:t.screenshotPath,updatedAt:t.updatedAt,alt:t.scenarioName,imgClassName:"block w-full",className:""})}):e.jsx("div",{className:"rounded-lg border-2 border-[#4d4d4d] bg-[#1a1a1a] flex items-center justify-center w-[400px] h-[300px]",children:e.jsx("span",{className:"text-sm text-gray-500",children:"No screenshot available"})}),e.jsx("button",{onClick:l,className:"text-xs text-gray-500 hover:text-gray-300 bg-transparent border-none cursor-pointer transition-colors shrink-0",children:"Dismiss"})]})}function za({analysisId:t,scenarioId:s,scenarioName:r,entityName:n,projectSlug:l,onStateChange:i}){const{interactiveServerUrl:o,isStarting:d,isLoading:c}=bn({analysisId:t,scenarioId:s,scenarioName:r,entityName:n,projectSlug:l,enabled:!0});return a.useEffect(()=>{i(o,d||c)},[o,d,c,i]),null}function Ha({onSaveToCurrent:t,onSaveAsNew:s,onDismiss:r,isSaving:n,scenarioName:l}){return e.jsxs("div",{className:"flex items-center justify-between px-4 py-1.5 bg-emerald-900/60 border-b border-emerald-700/50 text-emerald-200 text-xs",children:[e.jsx("span",{className:"font-medium",children:l?e.jsxs(e.Fragment,{children:["Data modified in “",l,"”."]}):"Data modified."}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:t,disabled:n,className:"px-2.5 py-0.5 bg-emerald-600 hover:bg-emerald-500 disabled:opacity-50 text-white text-xs font-medium rounded transition-colors cursor-pointer disabled:cursor-not-allowed",children:n?"Saving...":"Save to Scenario"}),e.jsx("button",{onClick:s,disabled:n,className:"px-2.5 py-0.5 bg-emerald-800 hover:bg-emerald-700 disabled:opacity-50 text-emerald-200 text-xs font-medium rounded transition-colors cursor-pointer disabled:cursor-not-allowed",children:"Save as New"}),e.jsx("button",{onClick:r,disabled:n,className:"text-emerald-400 hover:text-emerald-200 disabled:opacity-50 transition-colors cursor-pointer disabled:cursor-not-allowed",title:"Dismiss",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]})}function Ua({latestVersion:t}){const[s,r]=a.useState(!1);if(s)return null;const n=`npm install -g @codeyam/codeyam-cli@${t}`;return e.jsxs("div",{className:"shrink-0 w-full bg-[#D7FF63] px-4 py-1.5 flex items-center text-xs text-black font-['IBM_Plex_Sans']",children:[e.jsxs("div",{className:"flex-1 flex items-center justify-center gap-2",children:[e.jsx("span",{children:"An update to the codeyam editor is available."}),e.jsx("code",{className:"bg-[#2d2d2d] text-white font-mono text-xs px-3 py-0.5 rounded-full",children:n}),e.jsx(Pe,{content:n,icon:!0,iconSize:12,className:"text-black hover:text-gray-700 transition-colors"})]}),e.jsx("button",{type:"button",onClick:()=>r(!0),className:"shrink-0 p-0.5 rounded text-black/60 hover:text-black hover:bg-black/10 transition-colors cursor-pointer bg-transparent border-none","aria-label":"Dismiss upgrade banner",children:e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{d:"M6 18L18 6M6 6l12 12"})})})]})}function Ka(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 Ja(t){const[s,r]=a.useState({url:null,proxyUrl:null,isStarting:!1,error:null,canStartServer:!0,autoStartAttempted:!1}),n=a.useRef(s);n.current=s,a.useEffect(()=>{let o=!1,d=null;const c=async()=>{try{const b=await fetch("/api/editor-dev-server");if(o)return;const p=await b.json(),h=Ka(n.current,p),{shouldAutoStart:g,...M}=h;if(r(M),g&&!(t!=null&&t.skipAutoStart))try{const w=await fetch("/api/editor-dev-server",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"start"})});if(o)return;w.ok?r(u=>({...u,isStarting:!0})):r(u=>({...u,canStartServer:!1}))}catch{}}catch{}};return c(),d=setInterval(()=>void c(),2e3),()=>{o=!0,d&&clearInterval(d)}},[s.url]);const l=a.useCallback(()=>{r(o=>({...o,error:null,isStarting:!0})),fetch("/api/editor-dev-server",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"restart"})}).catch(()=>{})},[]),i=a.useCallback(()=>{r(o=>({...o,error:null,isStarting:!0})),fetch("/api/editor-dev-server",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"start"})}).catch(()=>{})},[]);return{devServerUrl:s.url,proxyUrl:s.proxyUrl,isStarting:s.isStarting,error:s.error,canStartServer:s.canStartServer,retryServer:l,startServer:i}}function Ga(t){const s=a.useRef(null),r=a.useRef(null);a.useEffect(()=>{if(typeof document>"u")return;r.current||(r.current=document.createElement("canvas"),r.current.width=64,r.current.height=64);const n=document.querySelector('link[rel="icon"]');if(!n)return;if(s.current||(s.current=n.href),!t){n.href=s.current;return}const l=new Image;l.crossOrigin="anonymous",l.onload=()=>{const i=r.current,o=i.getContext("2d");o.clearRect(0,0,64,64);const d=56,c=(64-d)/2;o.drawImage(l,c,c,d,d);const b=12,p=64-b-1,h=b+1;o.beginPath(),o.arc(p,h,b,0,2*Math.PI),o.fillStyle="#ef4444",o.fill(),n.href=i.toDataURL("image/png")},l.src=s.current},[t]),a.useEffect(()=>()=>{if(typeof document>"u")return;const n=document.querySelector('link[rel="icon"]');n&&s.current&&(n.href=s.current)},[])}function li({currentUrl:t,nextUrl:s,formMethod:r,defaultShouldRevalidate:n}){return r||t.pathname===s.pathname?n:t.pathname.startsWith("/editor")&&s.pathname.startsWith("/editor")?!1:n}const ci=()=>[{title:"Editor - CodeYam"},{name:"description",content:"CodeYam Code + Data Editor"}];class Ya extends a.Component{constructor(){super(...arguments);Es(this,"state",{error:null,errorInfo:null})}static getDerivedStateFromError(r){return{error:r,errorInfo:null}}componentDidCatch(r,n){console.error("[EditorErrorBoundary] Error:",r.message),console.error("[EditorErrorBoundary] Component stack:",n.componentStack),console.error("[EditorErrorBoundary] Loader snapshot:",JSON.stringify(this.props.loaderSnapshot,null,2)),this.setState({errorInfo:n})}render(){var r;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}),((r=this.state.errorInfo)==null?void 0:r.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 di=Qr(function(){var ks,Ss;const{projectSlug:s,projectRoot:r,hasProject:n,scenarios:l,allScenarios:i,analyzedEntities:o,allEntities:d,glossaryFunctions:c,glossaryEntries:b,entityImports:p,pageFilePaths:h,entityChangeStatus:g,modifiedFiles:M,featureName:w,userPrompt:u,projectTitle:y,projectDescription:C,defaultScreenSize:I,screenSizes:$,appFormats:B,editorStep:H,editorStepLabel:P,claudeSessionId:J,focusedEntitySha:_,newerEntitySha:O,focusedEntity:E,migrationMode:v,migrationState:L,cachedTestResults:W}=Zr(),U=en("root"),k=(U==null?void 0:U.npmUpdate)??null,F=(U==null?void 0:U.isAdmin)??!1,[D,f]=tn(),S=sn(),j=a.useRef(null),A=a.useRef(null),R=a.useRef(null),Y=a.useRef(null),[Z,se]=a.useState(_),[K,ae]=a.useState(!1),[pe,ie]=a.useState(!1),[le,me]=a.useState(!1),[Te,ge]=a.useState(0);a.useEffect(()=>{se(_)},[_]),a.useEffect(()=>{const x=N=>{const T=N.target;(T.tagName==="BUTTON"||T.closest("button"))&&(T.closest("button")??T).blur()};return document.addEventListener("mouseup",x),()=>document.removeEventListener("mouseup",x)},[]);const ce=a.useMemo(()=>Ps(Z,d),[Z,d,i]),be=(ce==null?void 0:ce.displayName)??void 0,ne=D.get("scenario")||((ks=ct(i))==null?void 0:ks.id)||void 0,[je,V]=a.useState(()=>be?[be]:[]),Q=a.useRef(null),m=a.useRef([]),z=a.useRef(null);a.useEffect(()=>{var te;const x=ne||((te=ct(i))==null?void 0:te.id);if(!ln(x,Q.current))return;const N=i.find(re=>re.id===x);if(!N)return;Q.current=x;const T=It(N,m.current,z.current);T&&Le(T);const q=Ke(N.name);fetch("/api/editor-switch-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioSlug:q,scenarioId:N.id,scenarioName:N.name,scenarioType:N.type})}).catch(()=>{})},[ne,i]),a.useEffect(()=>{const x=new BroadcastChannel("codeyam-editor");return x.onmessage=N=>{var T;if(((T=N.data)==null?void 0:T.type)==="switch-scenario"&&N.data.scenarioId){const q=N.data.scenarioId,te=i.find(We=>We.id===q);if(!te)return;Q.current=q;const re=new URLSearchParams(D);re.set("scenario",q),re.delete("zoom"),f(re),gt(null),Xe(null),Ce(null),we(!0);const ke=Ke(te.name);fetch("/api/editor-switch-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioSlug:ke,scenarioId:q,scenarioType:te.type})}).then(()=>{ue(!1),Ae(We=>We+1)}).catch(()=>{we(!1)})}},()=>x.close()},[D,f,i]),a.useEffect(()=>{if(D.get("ref")!=="link"||!ne)return;const x=new BroadcastChannel("codeyam-editor");x.postMessage({type:"switch-scenario",scenarioId:ne}),x.close(),window.close()},[]);const{devServerUrl:G,proxyUrl:X,isStarting:de,error:ye,canStartServer:or,retryServer:lr,startServer:cr}=Ja({skipAutoStart:v==="candidate"||v==="active"}),[Ve,ue]=a.useState(!1),[xe,gt]=a.useState(null),[Jt,Xe]=a.useState(null),[bt,Gt]=a.useState(!1),[Qe,Ce]=a.useState(null),[Ze,$e]=a.useState(null),dr=a.useCallback(async x=>{const T=await(await fetch("/api/editor-load-commit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({commitSha:x})})).json();return T.success&&(Ce(null),ue(!1)),T},[]),xr=a.useCallback((x,N)=>{Xe(T=>(x&&x!==T&&ue(!1),x)),!N&&x&&ue(!0),Gt(N)},[]),jt=a.useCallback(x=>{Ce(null),gt(T=>(T&&T.analysisId===x.analysisId||(Xe(null),Ae(te=>te+1)),x)),Gt(!0),ue(!1);const N=new URLSearchParams(D);N.delete("scenario"),N.delete("zoom"),f(N)},[D,f]),[ee,Le]=a.useState(I?{name:I.name,width:I.width,height:I.height}:{name:"Desktop",width:1440,height:900}),[Yt,qt]=a.useState(!1),[he,Vt]=a.useState(!1),ur=(B==null?void 0:B.includes("mobile-app"))??!1,Xt=I?{name:I.name,width:I.width,height:I.height}:null;z.current=Xt;const Qt=rn(),oe=a.useMemo(()=>{const x=Qt.pathname.split("/").filter(Boolean),N=x[x.length-1];return N==="build"||N==="history"||N==="settings"?N:N==="structure"?"data":"app"},[Qt.pathname]),fe=a.useCallback(x=>{se(null),V([]),ae(!1);const N=x==="app"?"":`/${x==="data"?"structure":x}`,T=D.get("scenario"),q=T?`?scenario=${T}`:"";S(`/editor${N}${q}`)},[S,D]),yt=a.useCallback(()=>{fe("build"),Me(!0)},[fe]),hr=a.useCallback(()=>{fe("history")},[fe]),pr=a.useCallback(()=>{fe("build"),Me(!0),setTimeout(()=>{var x;(x=j.current)==null||x.sendInput("codeyam editor migrate")},300)},[fe]),[mr,Me]=a.useState(oe==="build"),et=!!(w&&H),tt=H!=null&&H<=1,[st,Zt]=a.useState(et&&!tt?"pending":et&&tt?"fresh":"no-session"),es=a.useRef(!1);a.useEffect(()=>{st==="pending"&&!es.current&&(es.current=!0,fe("build"),Me(!0))},[st,fe]);const ts=a.useRef(!1);a.useEffect(()=>{et&&tt&&!ts.current&&(ts.current=!0,fetch("/api/editor-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"clear"})}).catch(()=>{}))},[et,tt]);const fr=a.useCallback(()=>{Zt("continue")},[]),gr=a.useCallback(()=>{fetch("/api/editor-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"clear"})}).catch(()=>{}),Zt("fresh")},[]),[br,vt]=a.useState("none"),jr=a.useCallback(()=>{vt("choosing")},[]),yr=a.useCallback(()=>{var x;fetch("/api/editor-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"clear"})}).catch(()=>{}),vt("none"),(x=j.current)==null||x.sendInput("/clear"),setTimeout(()=>{var N;(N=j.current)==null||N.sendInput("/codeyam-editor")},500)},[]),vr=a.useCallback(()=>{vt("none")},[]),[Nt,wt]=a.useState(!1),[Nr,ss]=a.useState(!1),rs=a.useRef(!1),rt=a.useRef(0),wr=a.useRef(!1),kr=a.useCallback(x=>{wt(x),x||(wr.current=!0),x&&!rs.current&&(ss(!1),rt.current=Date.now()),x||(rt.current=0),rs.current=x},[]),[ve,Sr]=a.useState(!1),kt=a.useRef(!1),Cr=a.useCallback(x=>{x!==kt.current&&(console.log("[Editor] claudeBuilding: %s → %s",kt.current,x),kt.current=x,Sr(x))},[]);Ga(Nt);const ns=a.useRef(ve);a.useEffect(()=>{var N;const x=ns.current&&!ve;if(ns.current=ve,!ve)if(x){const T=D.get("scenario")||((N=ct(i))==null?void 0:N.id),q=i.find(te=>te.id===T);if(q){console.log("[Editor] Building stopped, loading live preview for: %s",q.name),$e(null);const te=Ke(q.name);Q.current=q.id,we(!0),Re(!1),ue(!1),fetch("/api/editor-switch-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioSlug:te,scenarioId:q.id,scenarioType:q.type,skipBroadcast:!0})}).then(()=>{Ae(re=>re+1)}).catch(()=>{we(!1),ue(!0)})}else $e(null)}else $e(null)},[ve,D,i]);const{editorWidth:as,isDragging:is,isEditorCollapsed:Fe,isPreviewCollapsed:St,handleMouseDown:Fr,handleDoubleClick:Er,collapseEditor:Dr,expandEditor:os,expandPreview:Pr}=Oa(Y),[Ct,ls]=a.useState(!1),Tr=a.useCallback(()=>{ls(!0),fe("build"),Me(!0)},[fe]),cs=a.useCallback(()=>{ls(!1)},[]),$r=a.useCallback(x=>{Le(x),fetch("/api/editor-project-info",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({defaultScreenSize:x,skipBroadcast:!0})})},[]),[ds,xs]=a.useState(cn);a.useEffect(()=>{const x=dn();xs(x),x.systemNotification&&typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission()},[]);const Lr=a.useCallback(x=>{xs(x),xn(x)},[]);a.useEffect(()=>{if(oe==="build"){wt(!1);const x=setTimeout(()=>{var N,T;(N=j.current)==null||N.scrollToBottom(),(T=j.current)==null||T.focus()},50);return()=>clearTimeout(x)}},[oe]),a.useEffect(()=>{function x(){!document.hidden&&oe==="build"&&wt(!1)}return document.addEventListener("visibilitychange",x),()=>document.removeEventListener("visibilitychange",x)},[oe]);const[Ee,Mr]=a.useState(null);a.useEffect(()=>{const x=R.current;if(!x)return;const N=new ResizeObserver(T=>{const q=T[0];q&&Mr({width:q.contentRect.width,height:q.contentRect.height})});return N.observe(x),()=>N.disconnect()},[]);const He=ur&&!he&&(ee.height??900)>ee.width,Ne=a.useMemo(()=>Ee?He?Ds(Ee,{width:ee.width+dt.width,height:(ee.height??900)+dt.height}):Ds(Ee,ee):1,[Ee,ee,He]),[Ie,Ae]=a.useState(0),[us,Ft]=a.useState(null),[nt,we]=a.useState(!1),at=a.useRef(!1),[Ir,Re]=a.useState(!1),[Ar,hs]=a.useState(!1),Et=a.useRef(0);a.useEffect(()=>{Ie>0&&(Et.current=Date.now()+3e3)},[Ie]);const Rr=a.useCallback(()=>{if(Date.now()<Et.current)return;const x=rt.current;x===0||Date.now()-x<5e3||Re(!0)},[]);a.useEffect(()=>{const x=N=>{var T;if(((T=N.data)==null?void 0:T.type)==="codeyam-localstorage-changed"){if(Date.now()<Et.current)return;const q=rt.current;if(q===0||Date.now()-q<5e3)return;Re(!0)}};return window.addEventListener("message",x),()=>window.removeEventListener("message",x)},[]);const ps=a.useCallback(async x=>{hs(!0);try{let N;const T=A.current;T!=null&&T.contentWindow&&(N=await new Promise(re=>{const ke=setTimeout(()=>re(void 0),2e3),We=Cs=>{var Fs;((Fs=Cs.data)==null?void 0:Fs.type)==="codeyam-localstorage-state"&&(clearTimeout(ke),window.removeEventListener("message",We),re(Cs.data.data))};window.addEventListener("message",We),T.contentWindow.postMessage({type:"codeyam-get-localstorage"},"*")}));const te=await(await fetch("/api/editor-save-seed-state",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:x,localStorage:N})})).json();te.success?Re(!1):console.error("[editor] Save seed state failed:",te.error)}catch(N){console.error("[editor] Save seed state error:",N)}finally{hs(!1)}},[]),Or=a.useCallback((x,N)=>{if(Ft(x||null),N){const T=new URLSearchParams(D);T.set("scenario",N),Q.current=N,f(T);const q=i.find(te=>te.id===N);if(q){const te=It(q,m.current,z.current);te&&Le(te)}}Ce(null),ue(!1),Ae(T=>T+1)},[D,f,i]),{customSizes:Dt,addCustomSize:Br,removeCustomSize:_r}=an(s),Ue=a.useMemo(()=>Qs($,B),[$,B]),it=a.useMemo(()=>[...Ue,...Dt],[Ue,Dt]);m.current=it;const ot=a.useMemo(()=>{const x=new Map;for(const N of d){x.set(N.name,N.sha);const T=qe(Ye(N.filePath));T!==N.name&&x.set(T,N.sha)}return x},[d]),ms=a.useMemo(()=>{const x=new Map;for(const N of d)x.set(N.sha,N.name);return x},[d]),fs=a.useMemo(()=>{const x=[{name:"App"}];K&&x.push({name:"Roadmap"}),pe&&x.push({name:"Design System"}),le&&x.push({name:"Tech Stack"});for(const N of je){const T=ot.get(N),q=T?ms.get(T):void 0;x.push({name:q||N,componentName:N,entitySha:T})}return x},[je,ot,ms,K,pe,le]),{pageGroups:gs,componentGroups:Pt}=a.useMemo(()=>Ut(i),[i]),lt=a.useMemo(()=>tr(gs,Pt),[gs,Pt]),[Wr,zr]=a.useState("application"),[Oe,Tt]=a.useState([]),[$t,bs]=a.useState(null),js=a.useMemo(()=>$t?Ps($t,d):null,[$t,d,i]),ys=a.useMemo(()=>{const x=[{name:"App"}];for(const N of Oe)x.push({name:N,componentName:N,entitySha:ot.get(N)});return x},[Oe,ot]),Lt=a.useCallback((x,N)=>{if(!x){Tt([]),bs(null);return}const T=N||lt.get(x);if(!T)return;const q=Oe.indexOf(x);q>=0?Tt(Oe.slice(0,q+1)):Tt([...Oe,x]),bs(T)},[Oe,lt]),vs=a.useCallback((x,N)=>{if(!x){V([]),se(null);const re=D.get("scenario"),ke=re?`?scenario=${re}`:"";S(`/editor${ke}`);return}if(!N){console.error(`[editor] No entity SHA for "${x}" — entity missing from database`);return}const T=je.indexOf(x);T>=0?V(je.slice(0,T+1)):V([...je,x]);const q=i.find(re=>re.entitySha===N);se(N);const te=q?`?scenario=${q.id}`:"";S(`/editor/entity/${N}${te}`)},[S,i,je,D]),Ns=a.useCallback(x=>{we(!0),at.current=!0,Re(!1),ue(!1);const N=Ke(x.name);fetch("/api/editor-switch-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioSlug:N,scenarioId:x.id,scenarioType:x.type,skipBroadcast:!0})}).then(()=>{at.current=!1,Ae(T=>T+1)}).catch(()=>{at.current=!1,we(!1),ue(!0)})},[]),Be=a.useCallback((x,N)=>{console.log("[Editor] Scenario selected: %s dimension=%s (claudeBuilding=%s)",x.name,N??"default",ve),gt(null),Xe(null),Ce(null),Ft(null);let T=null;if(N&&($!=null&&$[N])){const te=$[N],re=it.find(ke=>ke.width===te.width&&ke.height===te.height);T={name:(re==null?void 0:re.name)||N,...te}}T||(T=It(x,it,Xt)),T&&Le(T),Q.current=x.id;const q=new URLSearchParams(D);q.set("scenario",x.id),f(q),ve?$e({scenarioId:x.id,scenarioName:x.name,updatedAt:x.updatedAt,hasScreenshot:!!x.screenshotPath,screenshotPath:x.screenshotPath}):($e(null),Ns(x))},[D,f,it,$,ve,Ns]),Hr=a.useCallback(()=>{const x=ne;if(!x)return;const N=i.find(q=>q.id===x);if(!N)return;const T=Ke(N.name);ue(!1),fetch("/api/editor-switch-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioSlug:T,scenarioId:N.id,scenarioType:N.type})}).then(()=>{Ae(q=>q+1)})},[ne,i]),Ur=a.useCallback(x=>{if(!x.commitSha){const N=i.find(T=>T.name===x.scenarioName);if(N){Be(N);return}}Ce(x)},[i,Be]),Kr=x=>{const N={name:x.name,width:x.width,height:x.height};Le(N),fetch("/api/editor-project-info",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({defaultScreenSize:N,skipBroadcast:!0})})},Jr=(x,N,T)=>{Br(x,N,T)},Gr=x=>{Le(x),fetch("/api/editor-project-info",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({defaultScreenSize:x,skipBroadcast:!0})})};a.useEffect(()=>{const x=N=>{var T;if(((T=N.data)==null?void 0:T.type)==="codeyam-preview-ready"&&!xe){if(at.current)return;ue(!0),we(!1)}};return window.addEventListener("message",x),()=>window.removeEventListener("message",x)},[xe]);const ws=()=>{xe||setTimeout(()=>{ue(x=>(x||we(!1),!0))},5e3)},_e=a.useMemo(()=>un({activeAnalyzedScenario:!!xe,analyzedPreviewUrl:Jt,activeScenarioId:ne||null,scenarios:i,proxyUrl:X,devServerUrl:G,zoomComponent:be||null}),[X,G,be,ne,i,xe,Jt]),Mt=a.useMemo(()=>{if(pe)return`/api/design-system-showcase?__cb=${Te}`;const x=hn(_e,us);if(!x)return null;const N=x.includes("?")?"&":"?";return`${x}${N}__cb=${Ie}`},[_e,us,Ie,pe,Te]),Yr=a.useMemo(()=>({projectSlug:s,hasProject:n,scenarioCount:l==null?void 0:l.length,allScenarioCount:i==null?void 0:i.length,analyzedEntityCount:o==null?void 0:o.length,glossaryFunctionCount:c==null?void 0:c.length,entityChangeStatusKeys:g?Object.keys(g):[],featureName:w}),[s,n,l,i,o,c,g,w]);return e.jsxs(e.Fragment,{children:[e.jsx(Ya,{loaderSnapshot:Yr,children:e.jsxs("div",{className:"fixed inset-0 bg-[#2d2d2d] flex flex-col",children:[xe&&e.jsx(za,{analysisId:xe.analysisId,scenarioId:xe.scenarioId,scenarioName:xe.scenarioName,entityName:xe.entityName,projectSlug:s,onStateChange:xr},xe.analysisId),k&&e.jsx(Ua,{latestVersion:k.latestVersion}),e.jsxs("div",{ref:Y,className:"flex-1 flex min-h-0",children:[Fe&&e.jsx("div",{className:"shrink-0 flex items-center justify-center cursor-pointer hover:bg-[#3d3d3d] transition-colors",style:{width:8,backgroundColor:"#2d2d2d"},onClick:os,title:"Expand editor",children:e.jsx("svg",{width:"6",height:"10",viewBox:"0 0 6 10",fill:"none",stroke:"#888",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M1 1l4 4-4 4"})})}),e.jsxs("aside",{className:"bg-[#1e1e1e] shrink-0 flex flex-col overflow-hidden",style:{...Fe?{display:"none"}:as!==null?{width:`${as}px`}:{width:"50%"}},children:[O&&ce&&e.jsxs("div",{className:"px-3 py-2 text-xs flex items-center justify-between",style:{background:"#2a1f00",borderBottom:"1px solid #3d2e00",color:"#f0c040"},children:[e.jsxs("span",{children:["Viewing an older version of"," ",e.jsx("strong",{children:ce.name}),". A newer version exists."]}),e.jsx("a",{href:`/editor/entity/${O}`,className:"px-2 py-0.5 rounded text-xs",style:{background:"#3d2e00",color:"#f0c040",textDecoration:"none"},children:"View latest"})]}),e.jsx(Aa,{activeTab:oe,onTabChange:x=>{fe(x),x==="build"&&Me(!0),fetch("/api/telemetry-page-view",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({route:`/editor/${x}`})}).catch(()=>{})},buildIdle:Nt,projectTitle:y,breadcrumbItems:oe==="data"?ys:fs,onBreadcrumbNavigate:oe==="data"?Lt:vs}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden relative",children:[Nt&&oe!=="build"&&!Nr&&e.jsxs("div",{className:"absolute top-3 left-1/2 -translate-x-1/2 z-50 animate-[slideDown_0.3s_ease-out]",children:[e.jsx("style",{children:`
138
+ @keyframes slideDown {
139
+ from { transform: translate(-50%, -100%); opacity: 0; }
140
+ to { transform: translate(-50%, 0); opacity: 1; }
141
+ }
142
+ `}),e.jsxs("div",{className:"flex items-center gap-1 bg-amber-50 border-2 border-amber-300 rounded-lg shadow-lg",children:[e.jsxs("button",{onClick:()=>{fe("build"),Me(!0)},className:"flex items-center gap-2 px-4 py-2 cursor-pointer hover:bg-amber-100 transition-colors rounded-l-md",children:[e.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-amber-400 animate-pulse"}),e.jsx("span",{className:"text-sm font-medium text-amber-900",children:"Claude is waiting for you"}),e.jsx("span",{className:"text-xs text-amber-600 ml-1",children:"Go to Build"})]}),e.jsx("button",{onClick:x=>{x.stopPropagation(),ss(!0)},className:"px-2 py-2 cursor-pointer hover:bg-amber-100 transition-colors rounded-r-md text-amber-400 hover:text-amber-600","aria-label":"Dismiss",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:e.jsx("path",{d:"M3 3l8 8M11 3l-8 8"})})})]})]}),mr&&e.jsxs("div",{className:"absolute inset-0 flex flex-col overflow-hidden",style:{visibility:oe==="build"?"visible":"hidden"},children:[e.jsx(Tn,{projectTitle:y,featureName:w,editorStep:H,editorStepLabel:P,migrationMode:v}),e.jsx("div",{className:"flex-1 min-h-0",style:Ct?{flex:"1 1 50%"}:void 0,children:st==="pending"?e.jsx(wn,{featureName:w,editorStep:H,editorStepLabel:P,onContinue:fr,onStartFresh:gr}):e.jsxs("div",{className:"relative h-full",children:[e.jsx(pn,{ref:j,entityName:"Editor",projectSlug:s,entityFilePath:null,scenarioName:null,onRefreshPreview:Or,onShowResults:Tr,onHideResults:cs,onSetViewport:$r,onDataMutationForwarded:Rr,onFeatureComplete:jr,editorMode:!0,onIdleChange:kr,onBuildingChange:Cr,notificationSettings:ds,buildTabActive:oe==="build",claudeStartMode:st==="continue"?"resume":"fresh",claudeSessionId:J,editorStepLabel:P,resultsOpen:Ct}),br==="choosing"&&e.jsx(kn,{onStartNextFeature:yr,onContinueInSession:vr})]})}),Ct&&e.jsx("div",{style:{flex:"1 1 50%"},className:"min-h-0 border-t-2 border-gray-300",children:e.jsx(Hn,{scenarios:l,allScenarios:i,glossaryFunctions:c,cachedTestResults:W,projectRoot:r,activeScenarioId:ne,onScenarioSelect:Be,onClose:cs,entityChangeStatus:g,modifiedFiles:M,featureName:w,userPrompt:u})})]}),e.jsx("div",{className:"absolute inset-0 flex flex-col overflow-hidden",style:{visibility:oe==="app"?"visible":"hidden"},children:e.jsx(Ma,{hasProject:n,scenarios:i,analyzedEntities:o,allEntities:d,glossaryFunctions:c,cachedTestResults:W,glossaryEntries:b,projectRoot:r,activeScenarioId:ne,onScenarioSelect:Be,onAnalyzedScenarioSelect:jt,onSwitchToBuild:yt,onSwitchToHistory:hr,zoomComponent:be,focusedEntity:ce,onZoomChange:vs,entityImports:p,pageFilePaths:h,projectTitle:y,projectDescription:C,breadcrumbItems:fs,migrationMode:v,migrationState:L,onStartMigration:pr,onReseedPreview:Hr,isAdmin:F,roadmapView:K,onRoadmapViewChange:ae,designSystemView:pe,onDesignSystemViewChange:ie,onPreviewDesignSystem:()=>{ge(x=>x+1)},techStackView:le,onTechStackViewChange:me})}),e.jsx("div",{className:"absolute inset-0 flex flex-col overflow-hidden",style:{visibility:oe==="data"?"visible":"hidden"},children:js?e.jsx(ar,{focusedEntity:js,breadcrumbItems:ys,onZoomChange:Lt,projectRoot:r,scenarios:i,analyzedEntities:[],activeScenarioId:ne,onScenarioSelect:Be,onAnalyzedScenarioSelect:jt,onSwitchToBuild:yt,entityImports:p,glossaryFunctions:c,cachedTestResults:W,glossaryEntries:b,entityShaMap:lt,componentGroups:Pt,visualEntities:[],isEntityComplete:()=>!0}):e.jsx($n,{scenarios:i,projectRoot:r,activeScenarioId:ne,onScenarioSelect:Be,zoomComponent:void 0,focusedEntity:null,onZoomChange:Lt,analyzedEntities:[],glossaryFunctions:c,cachedTestResults:W,activeAnalyzedScenarioId:xe==null?void 0:xe.scenarioId,onAnalyzedScenarioSelect:jt,entityImports:p,pageFilePaths:h,onSwitchToBuild:yt,entityShaMap:lt,structureTab:Wr,onStructureTabChange:zr})}),e.jsx("div",{className:"absolute inset-0 flex flex-col overflow-hidden",style:{visibility:oe==="history"?"visible":"hidden"},children:e.jsx(oa,{isActive:oe==="history",onScreenshotClick:Ur,glossaryFunctions:c,cachedTestResults:W})}),e.jsx("div",{className:"absolute inset-0 flex flex-col overflow-hidden",style:{visibility:oe==="settings"?"visible":"hidden"},children:e.jsxs("div",{className:"flex-1 overflow-auto p-4",children:[e.jsx("h2",{className:"text-sm font-semibold text-white mb-4",children:"Settings"}),e.jsx("p",{className:"text-xs text-gray-400",children:"Settings panel coming soon."})]})})]}),e.jsx(mn,{serverUrl:G,isStarting:de,projectSlug:s,devServerError:ye,onStartServer:or?cr:void 0,notificationSettings:ds,onChangeNotificationSettings:Lr})]}),!Fe&&!St&&e.jsx(Ra,{onMouseDown:Fr,onDoubleClick:Er,isDragging:is}),St&&e.jsx("div",{className:"shrink-0 flex items-center justify-center cursor-pointer hover:bg-[#3d3d3d] transition-colors",style:{width:8,backgroundColor:"#2d2d2d"},onClick:Pr,title:"Expand preview",children:e.jsx("svg",{width:"6",height:"10",viewBox:"0 0 6 10",fill:"none",stroke:"#888",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M5 1l-4 4 4 4"})})}),e.jsxs("div",{className:"flex-1 flex flex-col min-w-0",style:{...St?{display:"none"}:void 0,...is?{pointerEvents:"none"}:void 0},children:[e.jsxs("div",{className:"bg-[#2d2d2d] border-b border-[#3d3d3d] shrink-0 z-10 h-10 flex items-center pr-4 relative",children:[e.jsx("div",{className:"flex items-center gap-1 shrink-0 z-10",children:e.jsx("button",{onClick:()=>{Fe?(os(),setTimeout(()=>{var x;return(x=j.current)==null?void 0:x.focus()},50)):Dr()},className:`p-1.5 rounded transition-colors cursor-pointer ${Fe?"text-white bg-[#666] hover:bg-[#777]":"text-gray-500 hover:text-gray-300"}`,title:Fe?"Show chat":"Hide chat",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:Fe?e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M13 17l5-5-5-5"}),e.jsx("path",{d:"M6 17l5-5-5-5"})]}):e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M11 17l-5-5 5-5"}),e.jsx("path",{d:"M18 17l-5-5 5-5"})]})})})}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center gap-1 pointer-events-none",children:e.jsxs("div",{className:"flex items-center gap-1 pointer-events-auto",children:[Ue.map(x=>{const N=pt(x),T=N==="desktop"?"Desktop":N==="laptop"?"Laptop":N==="tablet"?"Tablet":"Mobile";return e.jsxs("button",{onClick:()=>{he&&Vt(!1),Kr(x)},className:`p-1.5 rounded transition-colors cursor-pointer ${!he&&ee.name===x.name?"text-white bg-[#555]":"text-gray-500 hover:text-gray-300"}`,title:`${x.name} (${x.width}×${x.height})`,children:[T==="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"})]}),T==="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"})]}),T==="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"})]}),T==="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"})]})]},x.name)}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>{he||qt(x=>!x)},className:`flex items-center gap-1.5 px-2 py-1 rounded transition-colors ${he?"":"cursor-pointer"} ${he||Yt||!Ue.some(x=>x.name===ee.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.jsx("span",{className:"text-xs font-mono",children:he&&Ee?`${Math.round(Ee.width)} × ${Math.round(Ee.height)}`:`${ee.width} × ${ee.height??900}`})]}),Yt&&e.jsx(on,{currentWidth:ee.width,currentHeight:ee.height??900,devicePresets:Ue,customSizes:Dt,onApply:Gr,onSave:Jr,onRemove:_r,onClose:()=>qt(!1)})]}),e.jsx("button",{onClick:()=>{Vt(x=>!x)},className:`p-1.5 rounded transition-colors cursor-pointer ${he?"text-white bg-[#555]":"text-gray-500 hover:text-gray-300"}`,title:he?"Exit fullscreen":"Fill page with 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:he?e.jsxs(e.Fragment,{children:[e.jsx("polyline",{points:"4 14 10 14 10 20"}),e.jsx("polyline",{points:"20 10 14 10 14 4"}),e.jsx("line",{x1:"14",y1:"10",x2:"21",y2:"3"}),e.jsx("line",{x1:"3",y1:"21",x2:"10",y2:"14"})]}):e.jsxs(e.Fragment,{children:[e.jsx("polyline",{points:"15 3 21 3 21 9"}),e.jsx("polyline",{points:"9 21 3 21 3 15"}),e.jsx("line",{x1:"21",y1:"3",x2:"14",y2:"10"}),e.jsx("line",{x1:"3",y1:"21",x2:"10",y2:"14"})]})})}),e.jsx("button",{onClick:()=>{const x=Mt||_e;x&&window.open(x,"_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"})]})})]})})]}),Ir&&e.jsx(Ha,{onSaveToCurrent:()=>void ps("overwrite"),onSaveAsNew:()=>void ps("new"),onDismiss:()=>Re(!1),isSaving:Ar,scenarioName:(Ss=i.find(x=>{var N;return x.id===(ne||((N=ct(i))==null?void 0:N.id))}))==null?void 0:Ss.name}),e.jsx("div",{ref:R,className:`flex-1 flex ${Qe||Ze?"overflow-y-auto overflow-x-hidden":"overflow-hidden"} ${he?"":"items-center justify-center p-8"}`,style:he?{backgroundColor:"#fff"}:Qe?{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)"}:Ze?{backgroundColor:"#1e1e1e"}:{backgroundImage:`
143
+ linear-gradient(45deg, #333 25%, transparent 25%),
144
+ linear-gradient(-45deg, #333 25%, transparent 25%),
145
+ linear-gradient(45deg, transparent 75%, #333 75%),
146
+ linear-gradient(-45deg, transparent 75%, #333 75%)
147
+ `,backgroundSize:"16px 16px",backgroundPosition:"0 0, 0 8px, 8px -8px, -8px 0px",backgroundColor:"#2d2d2d"},children:Qe?e.jsx(Ba,{preview:Qe,viewportWidth:ee.width,viewportHeight:ee.height??900,scale:Ne,onDismiss:()=>Ce(null),onLoadCommit:dr}):Ze?e.jsx(Wa,{preview:Ze,viewportWidth:ee.width,viewportHeight:ee.height??900,scale:Ne,onDismiss:()=>$e(null)}):_e?he?e.jsxs("div",{className:"relative w-full h-full bg-white",children:[!Ve&&!nt&&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(At,{})}),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"})]})]})}),nt&&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:A,src:Mt||_e,className:"w-full h-full border-none",title:"Editor preview",onLoad:ws,style:{opacity:Ve?1:0}},Ie)]}):e.jsx("div",{style:{width:`${(He?ee.width+dt.width:ee.width)*Ne}px`,height:`${(He?(ee.height??900)+dt.height:ee.height??900)*Ne}px`},children:e.jsx("div",{className:"origin-top-left",style:{transform:Ne<1?`scale(${Ne})`:void 0},children:e.jsx(Nn,{width:ee.width,height:ee.height??900,enabled:He,children:e.jsxs("div",{className:"relative bg-white",style:{width:`${ee.width}px`,height:`${ee.height??900}px`},children:[!Ve&&!nt&&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(At,{})}),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"})]})]})}),nt&&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:A,src:Mt||_e,className:"w-full h-full border-none",title:"Editor preview",onLoad:ws,style:{opacity:Ve?1:0}},Ie)]})})})}):e.jsx("div",{className:"bg-[#2a2a2a] rounded-lg flex flex-col items-center justify-center",style:{width:`${ee.width*Ne}px`,height:`${(ee.height??900)*Ne}px`},children:ye?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:ye}),e.jsx("button",{onClick:lr,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"})]}):de||bt?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mb-4",children:e.jsx(At,{})}),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:bt?"Starting Interactive Mode":"Starting Dev Server"}),e.jsx("p",{className:"text-sm text-gray-400 leading-5 m-0 font-['IBM_Plex_Sans']",children:bt?"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.jsx(nn,{})]})});export{di as default,ci as meta,li as shouldRevalidate};