@codeyam/codeyam-cli 0.1.13 → 0.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/analyzer-template/.build-info.json +6 -6
- package/analyzer-template/log.txt +3 -3
- package/codeyam-cli/src/commands/editor.js +22 -22
- package/codeyam-cli/src/commands/editor.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/editorAudit.test.js +101 -0
- package/codeyam-cli/src/utils/__tests__/editorAudit.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/editorEntityHelpers.test.js +58 -4
- package/codeyam-cli/src/utils/__tests__/editorEntityHelpers.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/editorScenarios.test.js +37 -0
- package/codeyam-cli/src/utils/__tests__/editorScenarios.test.js.map +1 -1
- package/codeyam-cli/src/utils/editorAudit.js +38 -5
- package/codeyam-cli/src/utils/editorAudit.js.map +1 -1
- package/codeyam-cli/src/utils/editorEntityHelpers.js +18 -3
- package/codeyam-cli/src/utils/editorEntityHelpers.js.map +1 -1
- package/codeyam-cli/src/utils/editorScenarios.js +6 -1
- package/codeyam-cli/src/utils/editorScenarios.js.map +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/editor.entity.(_sha)-DYqG1D_d.js +58 -0
- package/codeyam-cli/src/webserver/build/client/assets/editorPreview-DggyRwOr.js +41 -0
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha.scenarios._scenarioId.dev-BOi8kpwd.js → entity._sha.scenarios._scenarioId.dev-D1eikpe1.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{manifest-75b1b319.js → manifest-f4212c17.js} +1 -1
- package/codeyam-cli/src/webserver/build/server/assets/{analysisRunner-lv2ooewK.js → analysisRunner-if8kM_1Q.js} +1 -1
- package/codeyam-cli/src/webserver/build/server/assets/{index-Im3Smyei.js → index-CHymws6l.js} +1 -1
- package/codeyam-cli/src/webserver/build/server/assets/{init-BjuAFKGM.js → init-D3HkMDbI.js} +1 -1
- package/codeyam-cli/src/webserver/build/server/assets/server-build-DTCzJQiH.js +551 -0
- package/codeyam-cli/src/webserver/build/server/index.js +1 -1
- package/codeyam-cli/src/webserver/build-info.json +5 -5
- package/codeyam-cli/templates/nextjs-prisma-sqlite/package.json +1 -1
- package/codeyam-cli/templates/nextjs-prisma-supabase/package.json +1 -1
- package/package.json +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/editor.entity.(_sha)-CjC3_6JI.js +0 -58
- package/codeyam-cli/src/webserver/build/client/assets/editorPreview-DBa7T2FK.js +0 -41
- package/codeyam-cli/src/webserver/build/server/assets/server-build-CNjF0B9B.js +0 -551
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-Blo6EK8G.js","assets/jsx-runtime-D_zvdyIk.js","assets/chunk-JZWAC4HX-BBXArFPl.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var vs=Object.defineProperty;var Ns=(t,s,n)=>s in t?vs(t,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[s]=n;var kt=(t,s,n)=>Ns(t,typeof s!="symbol"?s+"":s,n);import{r,w as ws,u as Ss,b as ks,a as Cs,c as Ps,O as Es}from"./chunk-JZWAC4HX-BBXArFPl.js";import{j as e}from"./jsx-runtime-D_zvdyIk.js";import{u as Ms,C as Is}from"./useCustomSizes-BR3Rs7JY.js";import{g as Ts,s as $s,r as Ke,b as Qe,c as As,l as Rs,d as Ls,e as _s,f as Ds,a as Fs,T as Bs,D as Os}from"./editorPreview-DggyRwOr.js";import{C as ge}from"./CopyButton-CzTDWkF2.js";import{_ as et}from"./preload-helper-ckwbz45p.js";import{c as zs}from"./cy-logo-cli-DcX-ZS3p.js";import{u as Ws,S as Ct}from"./Spinner-Df3UCi8k.js";import"./copy-zK0B6Nu-.js";import"./createLucideIcon-DJB0YQJL.js";import"./useLastLogLine-BxxP_XF9.js";function Me(t){var l;if(!t.startsWith("app/")&&!t.startsWith("("))return"/";const n=t.replace(/^app\//,"").split("/"),a=n.pop(),c=((l=a.match(/\.(tsx?|jsx?|js)$/))==null?void 0:l[0])||"",o=a.slice(0,-c.length);let i;return o==="page"||o==="index"?i=n:i=[...n,o],i=i.filter(m=>!m.startsWith("(")),i.length===0?"/":"/"+i.join("/")}function Ie(t){return t==="/"?"Home":t.replace(/^\//,"").split("/").map(n=>n.startsWith("[")?n:n.charAt(0).toUpperCase()+n.slice(1)).join(" / ")}function De(t){if(!t||t==="/")return"Home";const s=t.split("?")[0].replace(/^\//,"");if(!s)return"Home";const n=s.split("/")[0].replace(/\.[^.]+$/,"");return n.charAt(0).toUpperCase()+n.slice(1)}function Ot(t){return t?t.includes("/isolated-components"):!1}function Us(t,s){return!s||Object.keys(s).length===0?t:t.filter(n=>s[n.name])}const _e=[{name:"Desktop",width:1440,height:900},{name:"Laptop",width:1024,height:768},{name:"Tablet",width:768,height:1024},{name:"Mobile",width:375,height:667}];function Hs(t){if(!t)return _e;const s=Object.entries(t).map(([a,c])=>({name:a,width:c.width,height:c.height})),n=new Set(s.map(a=>a.name));return[...s,..._e.filter(a=>!n.has(a.name))]}function Js({featureName:t,editorStep:s,editorStepLabel:n,onContinue:a}){const c=r.useCallback(o=>{o.key==="Enter"&&(o.preventDefault(),a())},[a]);return r.useEffect(()=>(window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)),[c]),e.jsx("div",{className:"flex items-center justify-center h-full bg-[#1e1e1e] text-[#d4d4d4]",children:e.jsxs("div",{className:"max-w-md w-full mx-4 p-6 bg-[#252526] border border-[#3d3d3d] rounded-lg",children:[e.jsx("h2",{className:"text-lg font-semibold mb-3 text-white",children:"Resume Previous Session?"}),e.jsx("p",{className:"text-sm text-[#999] mb-4",children:"An editor session is still in progress:"}),e.jsxs("div",{className:"bg-[#1e1e1e] rounded p-3 mb-5 text-sm",children:[t&&e.jsxs("div",{className:"mb-1",children:[e.jsx("span",{className:"text-[#999]",children:"Feature:"})," ",e.jsx("span",{className:"text-white",children:t})]}),s!=null&&n&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[#999]",children:"Step:"})," ",e.jsxs("span",{className:"text-white",children:[s," (",n,")"]})]})]}),e.jsx("button",{onClick:a,className:"w-full px-4 py-2 text-sm rounded transition-colors cursor-pointer bg-[#005c75] text-white font-medium hover:bg-[#004d63] ring-2 ring-white/50",children:"Continue Session"})]})})}function st(t){const[s,n]=r.useState(null),[a,c]=r.useState(!1),o=r.useCallback(()=>{t&&(c(!0),fetch(`/api/editor-test-results?testFile=${encodeURIComponent(t)}`).then(i=>i.json()).then(i=>{n(i),c(!1)}).catch(()=>{n({testFilePath:t,status:"error",testCases:[],errorMessage:"Failed to fetch test results"}),c(!1)}))},[t]);return r.useEffect(()=>{t&&o()},[t,o]),{results:s,isRunning:a,runTests:o}}function Fe({scenarioId:t,updatedAt:s,alt:n,className:a="",imgClassName:c=""}){const[o,i]=r.useState(!1),l=`/api/editor-scenario-image/${t}.png${s?`?v=${encodeURIComponent(s)}`:""}`;return r.useEffect(()=>{i(!1)},[t]),o?e.jsx("div",{className:`flex items-center justify-center ${a}`,children:e.jsx("span",{className:"text-[8px] text-gray-500",children:"No img"})}):e.jsx("div",{className:a,children:e.jsx("img",{src:l,alt:n,className:c,loading:"lazy",onError:()=>i(!0)})})}function Pe({scenarioId:t,updatedAt:s,hasScreenshot:n,imgSrc:a,name:c,isActive:o,onSelect:i}){const l=t&&n,m=!t&&a;return e.jsxs("button",{onClick:i,className:"flex flex-col items-center gap-1 cursor-pointer group",title:c,children:[e.jsx("div",{className:`w-32 h-32 rounded overflow-hidden border-2 transition-all bg-[#1a1a1a] ${o?"border-[#005c75] ring-1 ring-[#005c75]":"border-transparent hover:border-[#4d4d4d]"}`,children:l?e.jsx(Fe,{scenarioId:t,updatedAt:s,alt:c,className:"w-full h-full",imgClassName:"w-full h-full object-contain"}):m?e.jsx("img",{src:a,alt:c,className:"w-full h-full object-contain",loading:"lazy"}):e.jsx("div",{className:"w-full h-full bg-[#1a1a1a] flex items-center justify-center",children:e.jsx("span",{className:"text-[8px] text-gray-600",children:"No img"})})}),e.jsx("span",{className:`text-[10px] leading-tight text-center truncate w-32 ${o?"text-white":"text-gray-500 group-hover:text-gray-300"}`,children:c})]})}function Ze({testFile:t,entityName:s}){const{results:n,isRunning:a,runTests:c}=st(t);if(a&&!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 o=s?n.testCases.filter(m=>m.fullName.startsWith(s)):n.testCases,i=o.length>0?o:n.testCases;if(i.length===0)return null;const l=s?`${s} > `:"";return e.jsxs("div",{className:"px-2 pt-1 space-y-0.5",children:[i.map(m=>{var j;const N=l&&m.fullName.startsWith(l)?m.fullName.slice(l.length):m.fullName;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[m.status==="passed"?e.jsx("span",{className:"text-green-400 text-[10px]",children:"✓"}):m.status==="failed"?e.jsx("span",{className:"text-red-400 text-[10px]",children:"✗"}):e.jsx("span",{className:"text-gray-500 text-[10px]",children:"—"}),e.jsx("span",{className:`text-[10px] ${m.status==="passed"?"text-green-400":m.status==="failed"?"text-red-400":"text-gray-500"}`,children:N})]}),m.status==="failed"&&((j=m.failureMessages)==null?void 0:j.map((k,b)=>e.jsx("div",{className:"pl-4 text-[9px] text-red-300/70 truncate max-w-full",title:k,children:k.split(`
|
|
3
|
+
`)[0]},b)))]},m.fullName)}),e.jsx("button",{onClick:c,disabled:a,className:"mt-1 text-[10px] text-[#00a0c4] hover:text-[#00c4ee] transition-colors cursor-pointer disabled:opacity-50 bg-transparent border-none p-0",children:a?"Running...":"Re-run"})]})}function le({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(ge,{content:t,icon:!0,iconSize:10,className:"shrink-0 text-gray-500 hover:text-gray-300 transition-colors"})]}):null}function Gs({scenarios:t,projectRoot:s,activeScenarioId:n,onScenarioSelect:a,zoomComponent:c,focusedEntity:o,onZoomChange:i,analyzedEntities:l=[],glossaryFunctions:m=[],activeAnalyzedScenarioId:N,onAnalyzedScenarioSelect:j,entityImports:k,pageFilePaths:b={}}){const{pageGroups:I,componentGroups:u}=r.useMemo(()=>{var h;const p=new Map,x=new Map;for(const w of t)if(w.componentName){const P=x.get(w.componentName)||[];P.push(w),x.set(w.componentName,P)}else if(Ot(w.url)){const P=(h=w.url)==null?void 0:h.match(/[?&]c=([^&]+)/),R=P?decodeURIComponent(P[1]):"Isolated",D=x.get(R)||[];D.push(w),x.set(R,D)}else{const P=w.pageFilePath?Ie(Me(w.pageFilePath)):De(w.url),R=p.get(P)||[];R.push(w),p.set(P,R)}const y=new Map([...x.entries()].sort(([w],[P])=>w.localeCompare(P)));return{pageGroups:p,componentGroups:y}},[t]),L=r.useMemo(()=>{const p=new Set((l||[]).filter(y=>y.entityType==="visual").map(y=>y.name)),x=new Map;for(const[y,h]of u)p.has(y)||x.set(y,h);return x},[u,l]),{visualEntities:_,libraryEntities:$}=r.useMemo(()=>{const p=l.filter(y=>y.entityType==="visual").sort((y,h)=>y.name.localeCompare(h.name)),x=l.filter(y=>y.entityType==="library"||y.entityType==="functionCall").sort((y,h)=>y.name.localeCompare(h.name));return{visualEntities:p,libraryEntities:x}},[l]),B=r.useMemo(()=>{const p=new Set($.map(x=>x.name));return m.filter(x=>!p.has(x.name)).sort((x,y)=>x.name.localeCompare(y.name))},[m,$]),F=l.some(p=>p.isAnalyzing),v=r.useRef(null),E=r.useRef(0),z=r.useCallback(()=>{v.current&&(E.current=v.current.scrollTop)},[]);if(r.useEffect(()=>{v.current&&E.current>0&&(v.current.scrollTop=E.current)}),t.length===0&&l.length===0&&B.length===0)return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center text-gray-500 px-8",children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"No scenarios yet"}),e.jsx("p",{className:"text-xs",children:"Scenarios will appear here as Claude creates them alongside your code. Each scenario represents a different state of your app's data."})]})});if(c&&o){const p=o.name,x=o.filePath,y=o.sha,h=t.filter(M=>M.componentName===p||M.componentPath===x||!M.componentName&&(M.pageFilePath===x||y&&M.entitySha===y)),w=new Set((k==null?void 0:k[p])||[]),P=w.size>0,R=P?_.filter(M=>w.has(M.name)):[],D=P?$.filter(M=>w.has(M.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:()=>i(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:o.displayName})}),e.jsx("div",{className:"flex flex-wrap gap-2 px-2",children:h.length===0?e.jsx("div",{className:"px-3 py-2 text-xs text-gray-500",children:"No scenarios for this component"}):h.map(M=>e.jsx(Pe,{scenarioId:M.id,updatedAt:M.updatedAt,hasScreenshot:!!M.screenshotPath,name:M.name,isActive:M.id===n,onSelect:()=>a(M)},M.id))}),R.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"})}),R.map(M=>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:()=>i(M.name),className:"text-[11px] font-medium text-gray-400 truncate cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:M.name})}),e.jsx(le,{filePath:M.filePath,projectRoot:s}),(M.scenarios.length>0||M.pendingScenarios.length>0)&&e.jsx("div",{className:"flex flex-wrap gap-2 px-2 pt-1",children:M.scenarios.map(J=>e.jsx(Pe,{imgSrc:J.screenshotPath?`/api/screenshot/${J.screenshotPath}`:null,name:J.name,isActive:J.id===N,onSelect:()=>j==null?void 0:j({analysisId:M.analysisId,scenarioId:J.id,scenarioName:J.name,entitySha:M.sha,entityName:M.name})},J.id))})]},M.sha))]}),D.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"})}),D.map(M=>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:M.name})}),e.jsx(le,{filePath:M.filePath,projectRoot:s}),M.testFile&&e.jsx(Ze,{testFile:M.testFile,entityName:M.name})]},M.sha))]})]})})}return e.jsx("div",{ref:v,onScroll:z,className:"flex-1 overflow-auto",children:e.jsxs("div",{className:"p-3 space-y-3",children:[I.size>0&&e.jsxs("div",{children:[e.jsx("div",{className:"px-2 py-1",children:e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Application"})}),[...I.entries()].sort(([p],[x])=>p==="Home"?-1:x==="Home"?1:p.localeCompare(x)).map(([p,x])=>{var y,h;return e.jsxs("div",{className:"px-2 pt-1",children:[e.jsx("div",{className:"py-0.5",children:e.jsx("span",{className:"text-[11px] font-medium text-gray-400",children:p})}),(((y=x[0])==null?void 0:y.pageFilePath)||b[p])&&e.jsx(le,{filePath:((h=x[0])==null?void 0:h.pageFilePath)||b[p],projectRoot:s}),e.jsx("div",{className:"flex flex-wrap gap-2 pt-1",children:x.map(w=>e.jsx(Pe,{scenarioId:w.id,updatedAt:w.updatedAt,hasScreenshot:!!w.screenshotPath,name:w.name,isActive:w.id===n&&!N,onSelect:()=>a(w)},w.id))})]},p)})]}),L.size>0&&e.jsxs("div",{className:"pt-2 mt-1 border-t border-[#3d3d3d]",children:[e.jsx("div",{className:"px-2 py-1",children:e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Components"})}),[...L.entries()].map(([p,x])=>{var y;return e.jsxs("div",{className:"mt-2",children:[e.jsx("div",{className:"flex items-center justify-between px-2 py-1",children:e.jsx("button",{onClick:()=>i(p),className:"text-[11px] font-medium text-gray-400 truncate cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:p})}),((y=x[0])==null?void 0:y.componentPath)&&e.jsx(le,{filePath:x[0].componentPath,projectRoot:s}),e.jsx("div",{className:"flex flex-wrap gap-2 px-2 pt-1",children:x.map(h=>e.jsx(Pe,{scenarioId:h.id,updatedAt:h.updatedAt,hasScreenshot:!!h.screenshotPath,name:h.name,isActive:h.id===n&&!N,onSelect:()=>a(h)},h.id))})]},p)})]}),_.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"}),F&&t.length===0&&l.every(p=>p.scenarioCount===0)&&e.jsx("span",{className:"ml-2 text-[10px] text-gray-500",children:"— Entities are being analyzed..."})]}),_.map(p=>e.jsxs("div",{className:"mt-2",children:[e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1",children:[e.jsx("button",{onClick:()=>i(p.name),className:"text-[11px] font-medium text-gray-400 truncate cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:p.name}),p.isAnalyzing&&p.scenarioCount===0&&e.jsxs("span",{className:"flex items-center gap-1.5 text-[10px] text-gray-400",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[#005c75] animate-pulse"}),"Analyzing..."]})]}),e.jsx(le,{filePath:p.filePath,projectRoot:s}),(p.scenarios.length>0||p.pendingScenarios.length>0)&&e.jsxs("div",{className:"flex flex-wrap gap-2 px-2 pt-1",children:[p.scenarios.map(x=>e.jsx(Pe,{imgSrc:x.screenshotPath?`/api/screenshot/${x.screenshotPath}`:null,name:x.name,isActive:x.id===N,onSelect:()=>j==null?void 0:j({analysisId:p.analysisId,scenarioId:x.id,scenarioName:x.name,entitySha:p.sha,entityName:p.name})},x.id)),p.pendingScenarios.map(x=>e.jsx("div",{className:"px-2.5 py-1 bg-[#2a2a2a] text-gray-400 text-[10px] rounded-full",title:x,children:x},x))]})]},p.sha))]}),($.length>0||B.length>0)&&e.jsxs("div",{className:`pt-2 mt-1 ${_.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"})}),$.map(p=>e.jsxs("div",{className:"mt-2",children:[e.jsxs("div",{className:"px-2 py-1",children:[e.jsx("span",{className:"text-[11px] font-medium text-gray-300",children:p.name}),p.isAnalyzing&&p.scenarioCount===0&&e.jsxs("span",{className:"ml-2 inline-flex items-center gap-1.5 text-[10px] text-gray-400",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[#005c75] animate-pulse"}),"Analyzing..."]})]}),e.jsx(le,{filePath:p.filePath,projectRoot:s}),p.testFile?e.jsx(Ze,{testFile:p.testFile,entityName:p.name}):e.jsx("div",{className:"px-2 pt-1",children:e.jsx("span",{className:"text-[10px] text-gray-500",children:"No test file"})})]},p.sha)),B.map(p=>e.jsxs("div",{className:"mt-2",children:[e.jsx("div",{className:"px-2 py-1",children:e.jsx("span",{className:"text-[11px] font-medium text-gray-300",children:p.name})}),e.jsx(le,{filePath:p.filePath,projectRoot:s}),e.jsx(Ze,{testFile:p.testFile,entityName:p.name})]},p.name))]})]})})}function Vs(t,s,n=new Date){const a={"1d":1,"3d":3,"7d":7,"30d":30}[s],c=new Date(n);c.setDate(c.getDate()-a);const o=c.toISOString().split("T")[0],i=t.filter(k=>k.date>=o),l=new Set(i.map(k=>k.commitSha).filter(Boolean)),m=new Map;for(const k of i)if(k.scenarioScreenshots)for(const b of k.scenarioScreenshots){m.has(b.name)||m.set(b.name,[]);const I=m.get(b.name);I.some(u=>u.path===b.path)||I.push({path:b.path,time:k.time})}for(const k of m.values())k.sort((b,I)=>b.time.localeCompare(I.time));const N=[],j=new Map;for(const[k,b]of m){const I=k.indexOf(" - ");if(I!==-1){const u=k.slice(0,I);j.has(u)||j.set(u,[]),j.get(u).push({name:k,screenshots:b})}else N.push({name:k,screenshots:b})}return{commitCount:l.size,entryCount:i.length,appScenarios:N,componentGroups:j,totalScenarios:m.size}}function qs(t){const s=new Map;for(const n of[...t].reverse()){const a=s.get(n.date)||[];a.push(n),s.set(n.date,a)}return s}function Ys(t){const s=new Map;for(const n of t){let a;if("componentName"in n&&n.componentName)a=n.componentName;else if("componentName"in n&&n.componentName===null)a="App";else{const o=n.name.indexOf(" - ");a=o!==-1?n.name.slice(0,o):"App"}const c=s.get(a)||[];c.push(n),s.set(a,c)}return[...s.entries()].sort(([n],[a])=>n==="App"?-1:a==="App"?1:n.localeCompare(a))}const Pt=120;function zt({text:t,theme:s}){const[n,a]=r.useState(!1),c=t.length>Pt,o=c&&!n?t.slice(0,Pt)+"…":t,i=s==="light";return e.jsxs("div",{className:`px-4 py-2 ${i?"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 ${i?"text-gray-600":"text-gray-400"}`,children:[o,c&&e.jsx("button",{onClick:()=>a(!n),className:`ml-1 text-[11px] font-medium bg-transparent border-none p-0 cursor-pointer ${i?"text-blue-500 hover:text-blue-700":"text-[#00a0c4] hover:text-[#00c0e8]"}`,children:n?"Show less":"Read more…"})]})]})}function Et({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 Xs({testFile:t,entityName:s}){const{results:n,isRunning:a,runTests:c}=st(t);if(a&&!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 o=s?n.testCases.filter(m=>m.fullName.startsWith(s)):n.testCases,i=o.length>0?o:n.testCases;if(i.length===0)return null;const l=s?`${s} > `:"";return e.jsxs("div",{className:"pt-1 space-y-0.5",children:[i.map(m=>{var j;const N=l&&m.fullName.startsWith(l)?m.fullName.slice(l.length):m.fullName;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[m.status==="passed"?e.jsx("span",{className:"text-green-400 text-[10px]",children:"✓"}):m.status==="failed"?e.jsx("span",{className:"text-red-400 text-[10px]",children:"✗"}):e.jsx("span",{className:"text-gray-500 text-[10px]",children:"—"}),e.jsx("span",{className:`text-[10px] ${m.status==="passed"?"text-green-400":m.status==="failed"?"text-red-400":"text-gray-500"}`,children:N})]}),m.status==="failed"&&((j=m.failureMessages)==null?void 0:j.map((k,b)=>e.jsx("div",{className:"pl-4 text-[9px] text-red-400/70 truncate max-w-full",title:k,children:k.split(`
|
|
4
|
+
`)[0]},b)))]},m.fullName)}),e.jsx("button",{onClick:c,disabled:a,className:"mt-1 text-[10px] text-[#00a0c4] hover:text-[#38bdf8] transition-colors cursor-pointer disabled:opacity-50 bg-transparent border-none p-0",children:a?"Running...":"Re-run"})]})}const Ks={added:"text-green-400",untracked:"text-green-400",modified:"text-blue-400",renamed:"text-purple-400"};function Qs({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 ${Ks[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 Zs={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 en(t){try{return new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}}function tn(t){try{return new Date(t+"T00:00:00").toLocaleDateString([],{weekday:"long",month:"long",day:"numeric"})}catch{return t}}const sn=[{value:"1d",label:"1 Day"},{value:"3d",label:"3 Days"},{value:"7d",label:"1 Week"},{value:"30d",label:"1 Month"}];function nn({entries:t,onScreenshotClick:s}){const[n,a]=r.useState(!1),[c,o]=r.useState("7d"),i=r.useMemo(()=>Vs(t,c),[t,c]);return e.jsxs("div",{className:"bg-[#2d2d2d] rounded-lg overflow-hidden",children:[e.jsxs("button",{onClick:()=>a(!n),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 ${n?"rotate-180":""}`,children:"▼"})]}),n&&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:sn.map(l=>e.jsx("button",{onClick:()=>o(l.value),className:`px-2.5 py-1 text-[10px] font-medium rounded transition-colors cursor-pointer border ${c===l.value?"bg-[#005c75] text-white border-[#005c75]":"bg-transparent text-gray-400 border-[#4d4d4d] hover:text-white hover:border-[#005c75]"}`,children:l.label},l.value))}),e.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-gray-400",children:[e.jsxs("span",{children:[e.jsx("span",{className:"text-white font-medium",children:i.commitCount})," ",i.commitCount===1?"commit":"commits"]}),e.jsx("span",{className:"text-[#3d3d3d]",children:"|"}),e.jsxs("span",{children:[e.jsx("span",{className:"text-white font-medium",children:i.totalScenarios})," ",i.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:i.entryCount})," ",i.entryCount===1?"entry":"entries"]})]}),i.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:[i.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"}),i.appScenarios.map(l=>e.jsx(Mt,{scenario:l,onScreenshotClick:s},l.name))]}),i.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"}),[...i.componentGroups.entries()].sort(([l],[m])=>l.localeCompare(m)).map(([l,m])=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("span",{className:"text-[10px] font-medium text-gray-400",children:l}),m.map(N=>e.jsx(Mt,{scenario:N,onScreenshotClick:s},N.name))]},l))]})]})]})]})}function Mt({scenario:t,onScreenshotClick:s}){const n=t.name.indexOf(" - "),a=n!==-1?t.name.slice(n+3):t.name;return e.jsxs("div",{className:"pl-2",children:[e.jsx("span",{className:"text-[10px] text-gray-500 block mb-1",children:a}),e.jsx("div",{className:"flex items-center gap-1 overflow-x-auto",children:t.screenshots.map((c,o)=>e.jsxs("div",{className:"flex items-center shrink-0",children:[o>0&&e.jsx("span",{className:"text-[8px] text-gray-600 mx-0.5",children:"→"}),e.jsx("button",{type:"button",className:"w-16 h-16 rounded overflow-hidden border border-[#3d3d3d] hover:border-[#00a0c4] bg-[#1e1e1e] shrink-0 flex items-center justify-center cursor-pointer transition-colors",title:`${t.name} (${new Date(c.time).toLocaleDateString()})`,onClick:()=>s==null?void 0:s({screenshotUrl:`/api/editor-journal-image/${c.path.replace("screenshots/","")}`,commitSha:null,commitMessage:null,scenarioName:t.name}),children:e.jsx("img",{src:`/api/editor-journal-image/${c.path.replace("screenshots/","")}`,alt:t.name,className:"max-w-full max-h-full object-contain",loading:"lazy"})})]},c.path))})]})}function an({isActive:t,onScreenshotClick:s,glossaryFunctions:n=[]}){const[a,c]=r.useState([]),[o,i]=r.useState(!0),[l,m]=r.useState(new Set),N=r.useCallback(b=>{m(I=>{const u=new Set(I);return u.has(b)?u.delete(b):u.add(b),u})},[]),j=r.useCallback(async()=>{try{const b=await fetch("/api/editor-journal");if(b.ok){const I=await b.json();c(I.entries||[])}}catch{}finally{i(!1)}},[]);if(r.useEffect(()=>{j()},[j]),r.useEffect(()=>{t&&j()},[t,j]),r.useEffect(()=>{if(!t)return;const b=setInterval(()=>void j(),5e3);return()=>clearInterval(b)},[t,j]),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(a.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 k=qs(a);return e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsx(nn,{entries:a,onScreenshotClick:s}),[...k.entries()].map(([b,I])=>e.jsxs("div",{children:[e.jsx("div",{className:"px-3 py-1.5 sticky top-0 bg-[#1e1e1e] z-10",children:e.jsx("span",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider",children:tn(b)})}),e.jsx("div",{className:"space-y-2",children:I.map((u,L)=>{const _=Zs[u.type]||{label:u.type,color:"bg-gray-600"},$=`${u.time}-${L}`,B=l.has($);return e.jsxs("div",{className:"bg-[#2d2d2d] rounded-lg overflow-hidden",children:[e.jsxs("div",{className:`p-3 space-y-2 ${B?"":"max-h-[300px] overflow-y-auto"}`,children:[e.jsx("div",{className:"flex items-start gap-2 cursor-pointer",onClick:()=>N($),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:`${_.color} text-white text-[9px] font-bold px-1.5 py-0.5 rounded uppercase tracking-wider shrink-0`,children:_.label})]}),e.jsx("span",{className:"text-[10px] text-gray-500",children:en(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(zt,{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 F=Ys(u.scenarioScreenshots),v=u.entityChangeStatus,E=F.filter(([h])=>h==="App").flatMap(([,h])=>h),z=F.filter(([h])=>h!=="App"),p=new Map;for(const h of E){const w=h,P=w.pageFilePath?Ie(Me(w.pageFilePath)):De(w.url??null),R=p.get(P)||[];R.push(h),p.set(P,R)}const x=[...p.entries()],y=h=>e.jsx("button",{type:"button",className:"w-[4.5rem] h-[4.5rem] rounded overflow-hidden border border-[#3d3d3d] hover:border-[#00a0c4] bg-[#1e1e1e] shrink-0 flex items-center justify-center cursor-pointer transition-colors",onClick:()=>s==null?void 0:s({screenshotUrl:`/api/editor-journal-image/${h.path.replace("screenshots/","")}`,commitSha:u.commitSha,commitMessage:u.commitMessage,scenarioName:h.name}),children:e.jsx("img",{src:`/api/editor-journal-image/${h.path.replace("screenshots/","")}`,alt:h.name,title:h.name,className:"max-w-full max-h-full object-contain",loading:"lazy"})},h.path);return e.jsxs("div",{className:"space-y-2",children:[x.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("span",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider",children:"Application"}),x.map(([h,w])=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[10px] font-medium text-gray-400",children:h}),(v==null?void 0:v[h])&&e.jsx(Et,{status:v[h]})]}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-0.5",children:w.map(y)})]},h))]}),z.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"}),z.map(([h,w])=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[10px] font-medium text-gray-400",children:h}),(v==null?void 0:v[h])&&e.jsx(Et,{status:v[h]})]}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-0.5",children:w.map(y)})]},h))]})]})})(),n.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:n.map(F=>e.jsxs("div",{children:[e.jsx("span",{className:"text-[11px] font-medium text-gray-200",children:F.name}),e.jsx("span",{className:"text-[9px] text-gray-500 truncate block",children:F.filePath}),F.testFile?e.jsx(Xs,{testFile:F.testFile,entityName:F.name}):e.jsx("div",{className:"pt-1",children:e.jsx("span",{className:"text-[10px] text-gray-500",children:"No test file"})})]},F.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})]}),B&&u.modifiedFiles&&u.modifiedFiles.length>0&&e.jsx(Qs,{files:u.modifiedFiles})]}),e.jsxs("button",{onClick:()=>N($),className:"w-full py-1.5 text-[10px] text-gray-500 hover:text-gray-300 border-t border-[#3d3d3d] transition-colors cursor-pointer",children:["——— ",B?"Collapse":"Expand"," ———"]})]},$)})})]},b))]})})}function rn({prompt:t,height:s=300,onClose:n}){const a=r.useRef(null),c=r.useRef(null),o=r.useRef(null),i=r.useRef(!1),l=r.useRef(t);return r.useEffect(()=>{const m=a.current;if(!m)return;let N=!1,j=null;async function k(){const[b,I]=await Promise.all([et(()=>import("./xterm-BqvuqXEL.js"),[]),et(()=>import("./addon-fit-YJmn1quW.js"),[])]);if(N)return;{let p=document.getElementById("xterm-css");p||(p=document.createElement("style"),p.id="xterm-css",document.head.appendChild(p)),p.textContent=`
|
|
5
|
+
.xterm { cursor: text; position: relative; user-select: none; -ms-user-select: none; -webkit-user-select: none; }
|
|
6
|
+
.xterm.focus, .xterm:focus { outline: none; }
|
|
7
|
+
.xterm .xterm-helpers { position: absolute; top: 0; z-index: 5; }
|
|
8
|
+
.xterm .xterm-helper-textarea { padding: 0; border: 0; margin: 0; position: absolute; opacity: 0; left: -9999em; top: 0; width: 0; height: 0; z-index: -5; white-space: nowrap; overflow: hidden; resize: none; caret-color: transparent !important; clip-path: inset(100%) !important; }
|
|
9
|
+
.xterm .composition-view { background: #000; color: #FFF; display: none; position: absolute; white-space: nowrap; z-index: 1; }
|
|
10
|
+
.xterm .composition-view.active { display: block; }
|
|
11
|
+
.xterm .xterm-viewport { background-color: #000; overflow-y: scroll; cursor: default; position: absolute; right: 0; left: 0; top: 0; bottom: 0; }
|
|
12
|
+
.xterm .xterm-screen { position: relative; }
|
|
13
|
+
.xterm .xterm-screen canvas { position: absolute; left: 0; top: 0; }
|
|
14
|
+
.xterm .xterm-scroll-area { visibility: hidden; }
|
|
15
|
+
.xterm-char-measure-element { display: inline-block; visibility: hidden; position: absolute; top: 0; left: -9999em; line-height: normal; }
|
|
16
|
+
.xterm.enable-mouse-events { cursor: default; }
|
|
17
|
+
.xterm.xterm-cursor-pointer, .xterm .xterm-cursor-pointer { cursor: pointer; }
|
|
18
|
+
.xterm.column-select.focus { cursor: crosshair; }
|
|
19
|
+
.xterm .xterm-accessibility:not(.debug), .xterm .xterm-message { position: absolute; left: 0; top: 0; bottom: 0; right: 0; z-index: 10; color: transparent; pointer-events: none; }
|
|
20
|
+
.xterm .xterm-accessibility-tree:not(.debug) *::selection { color: transparent; }
|
|
21
|
+
.xterm .xterm-accessibility-tree { user-select: text; white-space: pre; }
|
|
22
|
+
.xterm .live-region { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
|
|
23
|
+
.xterm-dim { opacity: 1 !important; }
|
|
24
|
+
.xterm-underline-1 { text-decoration: underline; }
|
|
25
|
+
.xterm-underline-2 { text-decoration: double underline; }
|
|
26
|
+
.xterm-underline-3 { text-decoration: wavy underline; }
|
|
27
|
+
.xterm-underline-4 { text-decoration: dotted underline; }
|
|
28
|
+
.xterm-underline-5 { text-decoration: dashed underline; }
|
|
29
|
+
.xterm-overline { text-decoration: overline; }
|
|
30
|
+
.xterm-strikethrough { text-decoration: line-through; }
|
|
31
|
+
.xterm-screen .xterm-decoration-container .xterm-decoration { z-index: 6; position: absolute; }
|
|
32
|
+
.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer { z-index: 7; }
|
|
33
|
+
.xterm-decoration-overview-ruler { z-index: 8; position: absolute; top: 0; right: 0; pointer-events: none; }
|
|
34
|
+
.xterm-decoration-top { z-index: 2; position: relative; }
|
|
35
|
+
`}const u=new b.Terminal({theme:{background:"#1a1a1a",foreground:"#d4d4d4",cursor:"#d4d4d4",selectionBackground:"#264f78"},fontSize:12,fontFamily:"'IBM Plex Mono', 'Menlo', 'Monaco', monospace",cursorBlink:!0,scrollback:5e3,allowProposedApi:!0}),L=new I.FitAddon;u.loadAddon(L),u.open(m),requestAnimationFrame(()=>{try{L.fit()}catch{}}),o.current=u;let _=null;try{const p=await fetch("/api/editor-scenario-prompt",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:l.current})});p.ok&&(_=(await p.json()).promptFile)}catch{}if(N)return;const $=window.location.protocol==="https:"?"wss:":"ws:",B=window.location.host,F=new URLSearchParams;F.set("entityName","inline-claude");const v=`${$}//${B}/ws/terminal?${F.toString()}`,E=new WebSocket(v);c.current=E,E.onopen=()=>{E.send(JSON.stringify({type:"resize",cols:u.cols,rows:u.rows}))};let z=!1;E.onmessage=p=>{try{const x=JSON.parse(p.data);if(x.type==="session-id"&&!z){z=!0,setTimeout(()=>{const y=_?`claude "Read the file at '${_.replace(/'/g,"'\\''")}' for your instructions."`:"claude";E.send(JSON.stringify({type:"input",data:y+"\r"}))},300);return}if(x.type==="output"&&x.data){u.write(x.data);return}}catch{u.write(p.data)}},E.onclose=()=>{i.current||u.write(`\r
|
|
36
|
+
\x1B[90m--- Session ended ---\x1B[0m\r
|
|
37
|
+
`)},E.onerror=()=>{u.write(`\r
|
|
38
|
+
\x1B[31mConnection error\x1B[0m\r
|
|
39
|
+
`)},u.onData(p=>{E.readyState===WebSocket.OPEN&&E.send(JSON.stringify({type:"input",data:p}))}),j=new ResizeObserver(()=>{try{L.fit(),E.readyState===WebSocket.OPEN&&E.send(JSON.stringify({type:"resize",cols:u.cols,rows:u.rows}))}catch{}}),j.observe(m)}return k(),()=>{var b,I;N=!0,i.current=!0,j==null||j.disconnect(),((b=c.current)==null?void 0:b.readyState)===WebSocket.OPEN&&c.current.close(),(I=o.current)==null||I.dispose()}},[]),e.jsxs("div",{className:"border-t border-[#2d2d2d]",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 bg-[#1e1e1e]",children:[e.jsx("span",{className:"text-[10px] font-medium text-[#00a0c4]",children:"Claude"}),n&&e.jsx("button",{onClick:n,className:"text-gray-500 hover:text-gray-300 text-[10px] bg-transparent border-none cursor-pointer",children:"Close"})]}),e.jsx("div",{ref:a,style:{height:s,background:"#1a1a1a",padding:"4px 0",position:"relative",overflow:"hidden"}})]})}const It=()=>e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",className:"text-gray-500 shrink-0",children:e.jsx("path",{d:"M4.5 3L7.5 6L4.5 9",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})});function on(t,s){if(t.length<=s)return t;const n=s-2;return[t[0],"ellipsis",...t.slice(t.length-n)]}function Tt({items:t,onNavigate:s}){if(t.length===0)return null;const n=on(t,4);return e.jsx("nav",{className:"flex items-center gap-1 text-xs min-w-0",children:n.map((a,c)=>{if(a==="ellipsis")return e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(It,{}),e.jsx("span",{className:"text-gray-500",children:"..."})]},"ellipsis");const o=c===n.length-1;return e.jsxs("span",{className:"flex items-center gap-1 min-w-0",children:[c>0&&e.jsx(It,{}),o?e.jsx("span",{className:"text-white font-medium truncate",children:a.name}):e.jsx("button",{onClick:()=>s(a.componentName,a.entitySha),className:"text-gray-400 hover:text-white transition-colors cursor-pointer bg-transparent border-none p-0 truncate",children:a.name})]},a.componentName||"app")})})}function Wt(t){var c,o;const s=new Map,n=new Map;for(const i of t)if(i.componentName){const l=n.get(i.componentName)||[];l.push(i),n.set(i.componentName,l)}else if(Ot(i.url)){const l=(c=i.url)==null?void 0:c.match(/[?&]c=([^&]+)/),m=l?decodeURIComponent(l[1]):"Isolated",N=n.get(m)||[];N.push(i),n.set(m,N)}else{const l=i.displayName||((o=i.pageFilePath)!=null&&o.startsWith("app/")?Ie(Me(i.pageFilePath)):De(i.url)),m=s.get(l)||[];m.push(i),s.set(l,m)}const a=new Map([...n.entries()].sort(([i],[l])=>i.localeCompare(l)));return{pageGroups:s,componentGroups:a}}function ln(t,s){var a,c;const n=new Map;for(const[o,i]of t){const l=(a=i.find(m=>m.entitySha))==null?void 0:a.entitySha;l&&n.set(o,l)}for(const[o,i]of s){const l=(c=i.find(m=>m.entitySha))==null?void 0:c.entitySha;l&&n.set(o,l)}return n}function cn(t){const s=new Set;for(const[n,a]of Object.entries(t)){s.add(n);for(const c of a)s.add(c)}return s}function dn(t,s,n,a){if(s.has(t))return!0;const c=n.find(o=>o.sha===t);return c?a.has(c.name):!1}function mn(t,s,n,a){const c=[];for(const[o,i]of t){const l=n.get(o);l?a(l)||c.push({name:o,scenarios:i,reason:"incomplete"}):c.push({name:o,scenarios:i,reason:"missing"})}for(const[o,i]of s){const l=n.get(o);l?a(l)||c.push({name:o,scenarios:i,reason:"incomplete"}):c.push({name:o,scenarios:i,reason:"missing"})}return c}function xn(t,s,n){if(!t)return null;const a=s.find(c=>c.sha===t);return a?{sha:t,name:a.name,filePath:a.filePath,entityType:a.entityType,displayName:a.name}:null}const $t={new:0,edited:1,impacted:2};function At({status:t,onClick:s}){const n={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],a=s&&(t.status==="edited"||t.status==="impacted");return e.jsx("button",{onClick:a?s:void 0,className:`${n.bg} ${n.text} ${n.border} border text-[9px] font-bold px-1.5 py-0.5 rounded-full uppercase tracking-wider shrink-0 ${a?"cursor-pointer hover:opacity-80 transition-opacity":"cursor-default"}`,children:n.label})}function Rt({filePath:t}){const[s,n]=r.useState(null),[a,c]=r.useState(!0),[o,i]=r.useState(null);return r.useEffect(()=>{et(()=>import("./index-Blo6EK8G.js"),__vite__mapDeps([0,1,2])).then(l=>{i(()=>l.default)})},[]),r.useEffect(()=>{c(!0),fetch(`/api/editor-file-diff?path=${encodeURIComponent(t)}`).then(l=>l.json()).then(l=>{n({oldContent:l.oldContent,newContent:l.newContent})}).catch(()=>{n(null)}).finally(()=>c(!1))},[t]),a?e.jsx("div",{className:"p-2 text-[10px] text-gray-400",children:"Loading diff..."}):!s||!o?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(o,{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 Lt({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(n=>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 ${n.changeType==="new"?"bg-green-100 text-green-700 border-green-200":"bg-blue-100 text-blue-700 border-blue-200"}`,children:n.changeType==="new"?"New":"Edited"}),e.jsx("span",{className:"text-[11px] font-medium text-amber-800",children:n.name}),e.jsx("span",{className:"text-[9px] text-amber-500 truncate",children:n.filePath})]},n.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(n=>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 ${n.status==="new"?"bg-green-100 text-green-700 border-green-200":"bg-blue-100 text-blue-700 border-blue-200"}`,children:n.status==="new"?"New":"Edited"}),e.jsx("span",{className:"text-[11px] font-medium text-amber-800",children:n.name})]},n.name))})]}):e.jsx("span",{className:"text-[10px] text-amber-600",children:"This component was re-captured because a dependency changed"})})}function _t({scenarioId:t,name:s,isActive:n,onSelect:a,updatedAt:c}){const o=r.useRef(null);return r.useEffect(()=>{n&&o.current&&o.current.scrollIntoView({block:"nearest",behavior:"smooth"})},[n]),e.jsxs("button",{ref:o,onClick:a,className:"flex flex-col items-center gap-1.5 cursor-pointer group",title:s,children:[e.jsx("div",{className:`w-32 h-32 rounded-lg overflow-hidden border-2 transition-all ${n?"border-[#0ea5e9] ring-2 ring-[#0ea5e9]/40 shadow-lg shadow-[#0ea5e9]/20":"border-gray-200 hover:border-gray-400 shadow-sm"}`,children:e.jsx(Fe,{scenarioId:t,updatedAt:c,alt:s,className:"w-full h-full bg-white",imgClassName:"w-full h-full object-contain bg-white"})}),e.jsx("span",{className:`text-[11px] leading-tight text-center truncate w-32 font-medium ${n?"text-gray-900":"text-gray-600 group-hover:text-gray-900"}`,children:s})]})}function pn({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(ge,{content:t,icon:!0,iconSize:10,className:"shrink-0 text-gray-400 hover:text-gray-600 transition-colors"})]}):null}function tt({testFile:t,entityName:s}){const{results:n,isRunning:a,runTests:c}=st(t);if(a&&!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 o=s?n.testCases.filter(m=>m.fullName.startsWith(s)):n.testCases,i=o.length>0?o:n.testCases;if(i.length===0)return null;const l=s?`${s} > `:"";return e.jsxs("div",{className:"pt-1 space-y-0.5",children:[i.map(m=>{var j;const N=l&&m.fullName.startsWith(l)?m.fullName.slice(l.length):m.fullName;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[m.status==="passed"?e.jsx("span",{className:"text-green-600 text-[10px]",children:"✓"}):m.status==="failed"?e.jsx("span",{className:"text-red-500 text-[10px]",children:"✗"}):e.jsx("span",{className:"text-gray-400 text-[10px]",children:"—"}),e.jsx("span",{className:`text-[10px] ${m.status==="passed"?"text-green-600":m.status==="failed"?"text-red-500":"text-gray-400"}`,children:N})]}),m.status==="failed"&&((j=m.failureMessages)==null?void 0:j.map((k,b)=>e.jsx("div",{className:"pl-4 text-[9px] text-red-400 truncate max-w-full",title:k,children:k.split(`
|
|
40
|
+
`)[0]},b)))]},m.fullName)}),e.jsx("button",{onClick:c,disabled:a,className:"mt-1 text-[10px] text-[#0ea5e9] hover:text-[#38bdf8] transition-colors cursor-pointer disabled:opacity-50 bg-transparent border-none p-0",children:a?"Running...":"Re-run"})]})}function Dt(t){const s=t.indexOf(" - ");return s!==-1?t.slice(s+3):t}function Ft(t,s){return!s||Object.keys(s).length===0?t:[...t].sort(([n],[a])=>{var l,m;const c=((l=s[n])==null?void 0:l.status)||"impacted",o=((m=s[a])==null?void 0:m.status)||"impacted",i=($t[c]??2)-($t[o]??2);return i!==0?i:n.localeCompare(a)})}function un({scenarios:t,allScenarios:s=[],glossaryFunctions:n=[],projectRoot:a,activeScenarioId:c,onScenarioSelect:o,onClose:i,entityChangeStatus:l={},modifiedFiles:m=[],featureName:N,userPrompt:j}){const k=r.useMemo(()=>{if(s.length===0||Object.keys(l).length===0)return t;const x=new Set(t.map(h=>h.id)),y=s.filter(h=>{var P,R;if(x.has(h.id))return!1;const w=h.componentName||h.displayName||((P=h.pageFilePath)!=null&&P.startsWith("app/")?Ie(Me(h.pageFilePath)):De(h.url));return((R=l[w])==null?void 0:R.status)==="impacted"});return y.length===0?t:[...t,...y]},[t,s,l]),b=r.useMemo(()=>Object.entries(l).filter(([,x])=>x.status==="new"||x.status==="edited").map(([x,y])=>({name:x,status:y.status})),[l]),[I,u]=r.useState(null),L=r.useCallback(x=>{u(y=>y===x?null:x)},[]),{pageGroups:_,componentGroups:$}=r.useMemo(()=>Wt(k),[k]),B=r.useMemo(()=>Ft([..._.entries()],l),[_,l]),F=r.useMemo(()=>Ft([...$.entries()],l),[$,l]),v=B,E=F,z=r.useMemo(()=>Us(n,l),[n,l]),p=r.useMemo(()=>{const x=[];for(const[,y]of v)x.push(...y);for(const[,y]of E)x.push(...y);return x},[v,E]);return r.useEffect(()=>{if(p.length===0)return;const x=y=>{if(y.key!=="ArrowLeft"&&y.key!=="ArrowRight")return;const h=y.target,w=h==null?void 0:h.tagName;if(w==="INPUT"||w==="SELECT"||w==="TEXTAREA"&&!h.classList.contains("xterm-helper-textarea"))return;y.preventDefault();const P=p.findIndex(D=>D.id===c);let R;y.key==="ArrowLeft"?R=P<=0?p.length-1:P-1:R=P>=p.length-1?0:P+1,o(p[R])};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[p,c,o]),k.length===0&&n.length===0?e.jsxs("div",{className:"h-full bg-white flex items-center justify-center relative",children:[e.jsx("button",{onClick:i,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"}),N&&e.jsx("div",{className:"text-[11px] text-gray-400 truncate",title:N,children:N})]}),e.jsx("button",{onClick:i,className:"text-gray-400 hover:text-gray-700 text-lg leading-none cursor-pointer bg-transparent border-none shrink-0",title:"Close results",children:"×"})]}),j&&e.jsx(zt,{text:j,theme:"light"}),e.jsx("div",{className:"flex-1 overflow-auto p-4",children:e.jsxs("div",{className:"space-y-5",children:[v.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:v.map(([x,y])=>{var R;const h=l[x],w=I===x,P=(R=y[0])==null?void 0:R.componentPath;return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1.5 flex items-center gap-2",children:[e.jsx("span",{className:"text-[11px] font-medium text-gray-600",children:x}),h&&e.jsx(At,{status:h,onClick:()=>L(x)})]}),w&&(h==null?void 0:h.status)==="edited"&&P&&e.jsx(Rt,{filePath:P}),w&&(h==null?void 0:h.status)==="impacted"&&e.jsx(Lt,{impactedBy:h.impactedBy,changedEntities:b}),e.jsx("div",{className:"flex flex-wrap gap-3",children:y.map(D=>e.jsx(_t,{scenarioId:D.id,name:Dt(D.name),isActive:D.id===c,onSelect:()=>o(D),updatedAt:D.updatedAt},D.id))})]},x)})})]}),E.length>0&&e.jsxs("div",{className:v.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:E.map(([x,y])=>{var R;const h=l[x],w=I===x,P=(R=y[0])==null?void 0:R.componentPath;return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1.5 flex items-center gap-2",children:[e.jsx("span",{className:"text-[11px] font-medium text-gray-600",children:x}),h&&e.jsx(At,{status:h,onClick:()=>L(x)})]}),w&&(h==null?void 0:h.status)==="edited"&&P&&e.jsx(Rt,{filePath:P}),w&&(h==null?void 0:h.status)==="impacted"&&e.jsx(Lt,{impactedBy:h.impactedBy,changedEntities:b}),e.jsx("div",{className:"flex flex-wrap gap-3",children:y.map(D=>e.jsx(_t,{scenarioId:D.id,name:Dt(D.name),isActive:D.id===c,onSelect:()=>o(D),updatedAt:D.updatedAt},D.id))})]},x)})})]}),z.length>0&&e.jsxs("div",{className:v.length>0||E.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:z.map(x=>e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{className:"text-[11px] font-medium text-gray-700",children:x.name})}),e.jsx(pn,{filePath:x.filePath,projectRoot:a}),x.testFile?e.jsx(tt,{testFile:x.testFile,entityName:x.name}):e.jsx("div",{className:"pt-1",children:e.jsx("span",{className:"text-[10px] text-gray-400",children:"No test file"})})]},x.name))})]}),m.length>0&&e.jsxs("div",{className:v.length>0||E.length>0||z.length>0?"pt-3 border-t border-gray-200":"",children:[e.jsx("div",{className:"mb-2",children:e.jsxs("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:["Modified Files (",m.length,")"]})}),e.jsx("div",{className:"space-y-0.5 pl-1 max-h-[200px] overflow-auto",children:m.map(x=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:`text-[9px] font-bold uppercase w-[14px] text-center ${x.status==="added"||x.status==="untracked"?"text-green-600":x.status==="modified"?"text-blue-600":x.status==="renamed"?"text-purple-600":"text-gray-400"}`,children:x.status==="added"||x.status==="untracked"?"A":x.status==="modified"?"M":x.status==="renamed"?"R":"?"}),e.jsx("span",{className:"text-[10px] text-gray-500 truncate font-mono",children:x.path})]},x.path))})]})]})})]})}function hn(t,s,n,a){var m;const c=a.length>0?a.map(N=>`- "${N.name}" (ID: ${N.id})${N.url?` — URL: ${N.url}`:""}`).join(`
|
|
41
|
+
`):"(no scenarios yet)",o=s.endsWith("/page.tsx")||s.endsWith("/page.js"),i=((m=a.find(N=>N.url))==null?void 0:m.url)||"/",l=[`You are helping edit scenarios for the "${t}" entity in a CodeYam project.`,"","## Entity",`- **Name:** ${t}`,`- **File:** ${s}`,`- **Type:** ${o?"Page (application scenario with seed data)":"Component (component scenario with mock props)"}`,"","## Existing Scenarios",c,""];return o?l.push("## How Seed Data Works","","Application scenarios use `seed` data to populate the database before the page is captured.","The seed is a JSON object where each key is a Prisma model name in camelCase singular (matching the Prisma client accessor name) and the value is an array of records.","","### Seed Key Naming Convention","The key must be the camelCase singular form of the Prisma model name:",'- `model User` → key `"user"`','- `model BlogPost` → key `"blogPost"`','- `model Feedback` → key `"feedback"`',"",'**WARNING:** Do NOT use plural forms like "users", "blogPosts", or "feedbacks" — the seed adapter will silently fail to match them.',"","To understand the data models, read the Prisma schema at `prisma/schema.prisma`.","To see examples of existing seed data, look at `.codeyam/editor-scenarios/*.seed.json` files.","",`Also read the source file at \`${s}\` to understand what data the page queries and renders.`,"","## Registering a Scenario","","For small seed data, pass it inline:","```",`codeyam editor register '{"name":"Scenario Name","type":"application","url":"${i}","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":"${i}","dimensions":["Laptop"],"seed":{"user":[...],"feedback":[...]}}`,"SCENARIO_EOF","codeyam editor register @.codeyam/tmp/scenario.json","```"):l.push("## Registering a Scenario","",`Read the source file at \`${s}\` to understand what props the component expects.`,"","```",`codeyam editor register '{"name":"Scenario Name","type":"component","componentName":"${t}","componentPath":"${s}","dimensions":["Laptop"],"mockData":{"propName":"value"}}'`,"```"),l.push("","## Deleting a Scenario","","To delete a scenario, use its ID from the list above:","```","codeyam editor delete <scenarioId>","```","","## Validating Seed Data","","Before registering, you can validate seed data structure and check that keys match Prisma models:","```",`codeyam editor validate-seed '{"user":[...]}'`,"```"),l.push("","## Important","- DO NOT take any action until the user tells you what they want","- Start by briefly listing the existing scenarios",'- Then ask: "Would you like to modify an existing scenario or add a new one?"',"- Wait for the user's answer before proceeding",'- Keep scenario names descriptive: "Empty State", "With Comments", "Admin View", etc.',`- Each scenario should capture a distinct, meaningful state of the ${o?"page":"component"}`),l.join(`
|
|
42
|
+
`)}function Ut(t,s){var c;const n=s.some(o=>!o.componentName),a=s.map(o=>`'${o.id}'`).join(", ");if(n){const o=((c=s.find(l=>l.url))==null?void 0:c.url)||null,i=s.map(l=>`.codeyam/editor-scenarios/${l.id}.json`).join(", ");return[`### Page: "${t}" (${s.length} scenario(s))`,...o?["",`Scenario URL: \`${o}\``]:[],"",...o?["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 \`${o}\`, 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 (${a});"`,"","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 (${a});"`,"","Step E: Add pageFilePath to the scenario JSON files so this fix persists across clones.",`For each file (${i}), read it and add \`"pageFilePath": "PAGE_FILE_PATH"\` to the \`_metadata\` object (after the \`"type"\` field). Then commit the updated JSON files.`].join(`
|
|
43
|
+
`)}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 (${a});"`].join(`
|
|
44
|
+
`)}function Bt({name:t,scenarios:s,reason:n="missing"}){var o,i;const a=((o=s[0])==null?void 0:o.componentPath)||((i=s[0])==null?void 0:i.pageFilePath)||null,c=n==="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": "${a||"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(`
|
|
45
|
+
`):[`The "${t}" ${s.some(l=>!l.componentName)?"page":"component"} is missing entity data in the CodeYam database. Its scenarios are hidden until this is fixed.`,"","IMPORTANT: Do NOT re-register scenarios — that would overwrite their screenshots. 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:","",Ut(t,s),"","Step 3: Reload the editor page in the browser and verify the scenarios appear."].join(`
|
|
46
|
+
`);return e.jsx(ge,{content:c,label:"Copy Fix Prompt",copiedLabel:"Copied!",className:"text-[9px] text-amber-400 hover:text-amber-300 bg-transparent border border-amber-400/30 rounded px-1.5 py-0.5 cursor-pointer transition-colors ml-2"})}function fn({brokenEntities:t}){if(t.length===0)return null;const s=t.reduce((o,i)=>o+i.scenarios.length,0),n=t.filter(o=>o.reason==="incomplete"),a=t.filter(o=>o.reason==="missing"),c=[`${t.length} entities are missing data in the CodeYam database. ${s} total scenario(s) are hidden until this is fixed.`,"","IMPORTANT: Do NOT re-register scenarios — that would overwrite their screenshots. Instead, update the database and scenario JSON files directly.","","Follow these steps EXACTLY:","",...n.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:","",...n.map(o=>{var l,m;const i=((l=o.scenarios[0])==null?void 0:l.componentPath)||((m=o.scenarios[0])==null?void 0:m.pageFilePath)||"FILL_IN_PATH";return`- "${o.name}" (filePath: "${i}")`}),"",'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","",...a.length>0?["## Step 3: Fix missing entity associations","",...a.map(o=>Ut(o.name,o.scenarios)),""]:[],`## Step ${a.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(`
|
|
47
|
+
`);return e.jsxs("div",{className:"mb-3 p-2 rounded border border-amber-400/30 bg-amber-400/5",children:[e.jsxs("p",{className:"text-[10px] text-amber-400/80 m-0 leading-relaxed",children:[t.length," ",t.length===1?"entity is":"entities are"," missing data (",s," hidden scenario",s!==1?"s":"","). Copy this prompt into Claude to fix them all at once."]}),e.jsx("div",{className:"mt-1.5",children:e.jsx(ge,{content:c,label:"Copy Fix All Prompt",copiedLabel:"Copied!",className:"text-[9px] text-amber-400 hover:text-amber-300 bg-transparent border border-amber-400/30 rounded px-1.5 py-0.5 cursor-pointer transition-colors"})})]})}function gn({scenarios:t,entityName:s,entityFilePath:n,entityType:a,onSwitchToBuild:c,onScenarioSelect:o}){const[i,l]=r.useState(!1),[m,N]=r.useState(null),[j,k]=r.useState(""),[b,I]=r.useState(!1),[u,L]=r.useState(null),[_,$]=r.useState(!1),B=r.useCallback(async v=>{if(!(!j.trim()||b)){I(!0);try{(await fetch("/api/editor-rename-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioId:v,name:j.trim()})})).ok&&N(null)}catch{}finally{I(!1)}}},[j,b]),F=r.useCallback(async v=>{if(confirm(`Delete scenario "${v.name}"?`)){L(v.id);try{const E=v.screenshotPaths?Object.values(v.screenshotPaths):v.screenshotPath?[v.screenshotPath]:[];await fetch("/api/delete-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioId:v.id,screenshotPaths:E})})}catch{}finally{L(null)}}},[]);return i?e.jsxs("div",{className:"border border-[#3d3d3d] rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 bg-[#1e1e1e]",children:[e.jsx("span",{className:"text-xs font-medium text-gray-400",children:"Edit Scenarios"}),e.jsx("button",{onClick:()=>{l(!1),N(null)},className:"text-gray-500 hover:text-gray-300 text-xs bg-transparent border-none cursor-pointer",children:"Close"})]}),e.jsx("div",{className:"divide-y divide-[#2d2d2d]",children:t.map(v=>e.jsxs("div",{className:"px-3 py-2 flex items-center gap-2 hover:bg-[#252525] cursor-pointer transition-colors",style:{opacity:u===v.id?.4:1},onClick:()=>{m!==v.id&&o(v)},children:[v.screenshotPath?e.jsx(Fe,{scenarioId:v.id,updatedAt:v.updatedAt,alt:"",className:"rounded w-[40px] h-[40px] shrink-0 overflow-hidden",imgClassName:"w-full h-full object-cover"}):e.jsx("div",{className:"rounded bg-[#1e1e1e]",style:{width:40,height:40,flexShrink:0}}),m===v.id?e.jsxs("form",{className:"flex-1 flex items-center gap-1.5 min-w-0",onSubmit:E=>{E.preventDefault(),B(v.id)},children:[e.jsx("input",{type:"text",value:j,onChange:E=>k(E.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:b}),e.jsx("button",{type:"submit",disabled:b||!j.trim(),className:"px-2 py-1 text-[10px] bg-[#005c75] text-white rounded hover:bg-[#004d63] disabled:opacity-40 cursor-pointer border-none",children:b?"...":"Save"}),e.jsx("button",{type:"button",onClick:()=>N(null),className:"px-2 py-1 text-[10px] text-gray-400 hover:text-white cursor-pointer bg-transparent border-none",children:"Cancel"})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"flex-1 text-xs text-gray-300 truncate min-w-0",children:v.name}),e.jsx("button",{onClick:E=>{E.stopPropagation(),N(v.id),k(v.name)},className:"text-[10px] text-gray-500 hover:text-gray-300 cursor-pointer bg-transparent border-none px-1",title:"Rename",children:"Rename"}),e.jsx("button",{onClick:E=>{E.stopPropagation(),F(v)},disabled:u===v.id,className:"text-[10px] text-red-400/60 hover:text-red-400 cursor-pointer bg-transparent border-none px-1",title:"Delete",children:"Delete"})]})]},v.id))}),_?e.jsx(rn,{prompt:hn(s,n,a,t),height:500,onClose:()=>$(!1)}):e.jsx("div",{className:"px-3 py-2.5 bg-[#1e1e1e] border-t border-[#2d2d2d] flex justify-center",children:e.jsx("button",{onClick:()=>$(!0),className:"px-5 py-2 text-xs font-medium text-white cursor-pointer bg-[#005c75] hover:bg-[#004d63] border-none rounded-md transition-colors",children:"Modify with Claude"})})]}):e.jsx("div",{className:"flex justify-center",children:e.jsx("button",{onClick:()=>l(!0),className:"px-5 py-2 text-xs font-medium text-gray-300 hover:text-white transition-colors cursor-pointer bg-[#2a2a2a] hover:bg-[#333] border border-[#4a4a4a] hover:border-[#666] rounded-md",children:"Edit Scenarios"})})}function fe({scenarioId:t,updatedAt:s,hasScreenshot:n,imgSrc:a,name:c,isActive:o,onSelect:i}){const l=t&&n,m=!t&&a;return e.jsxs("button",{onClick:i,className:"flex flex-col items-center gap-1 cursor-pointer group w-full",title:c,children:[e.jsx("div",{className:`w-full aspect-square rounded overflow-hidden border-2 transition-all bg-[#1a1a1a] ${o?"border-[#005c75] ring-1 ring-[#005c75]":"border-transparent hover:border-[#4d4d4d]"}`,children:l?e.jsx(Fe,{scenarioId:t,updatedAt:s,alt:c,className:"w-full h-full",imgClassName:"w-full h-full object-contain"}):m?e.jsx("img",{src:a,alt:c,className:"w-full h-full object-contain",loading:"lazy"}):e.jsx("div",{className:"w-full h-full bg-[#1a1a1a] flex items-center justify-center",children:e.jsx("span",{className:"text-[8px] text-gray-600",children:"No img"})})}),e.jsx("span",{className:`text-[10px] leading-tight text-center truncate w-full ${o?"text-white":"text-gray-500 group-hover:text-gray-300"}`,children:c})]})}function Ee({filePath:t}){return t?e.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[e.jsxs("a",{href:`/api/editor-file?path=${encodeURIComponent(t)}`,target:"_blank",rel:"noopener noreferrer",title:"Open file",className:"flex items-center gap-1 text-gray-500 hover:text-gray-300 transition-colors min-w-0",children:[e.jsx("span",{className:"text-[9px] truncate",children:t}),e.jsx("svg",{className:"shrink-0",width:"10",height:"10",viewBox:"0 0 12 12",fill:"none",children:e.jsx("path",{d:"M4.5 1.5H2.5C1.95 1.5 1.5 1.95 1.5 2.5V9.5C1.5 10.05 1.95 10.5 2.5 10.5H9.5C10.05 10.5 10.5 10.05 10.5 9.5V7.5M7.5 1.5H10.5M10.5 1.5V4.5M10.5 1.5L5 7",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})})]}),e.jsx(ge,{content:t,icon:!0,iconSize:10,className:"shrink-0 text-gray-500 hover:text-gray-300 transition-colors"})]}):null}function bn({hasProject:t,scenarios:s,analyzedEntities:n,allEntities:a=[],glossaryFunctions:c=[],glossaryEntries:o=[],projectRoot:i,activeScenarioId:l,onScenarioSelect:m,onAnalyzedScenarioSelect:N,onSwitchToBuild:j,zoomComponent:k,focusedEntity:b,onZoomChange:I,entityImports:u,pageFilePaths:L={},projectTitle:_,projectDescription:$,migrationMode:B="none",migrationState:F,onStartMigration:v,breadcrumbItems:E=[]}){var te;const{pageGroups:z,componentGroups:p}=r.useMemo(()=>Wt(s),[s]),x=r.useMemo(()=>ln(z,p),[z,p]),y=r.useMemo(()=>new Set(n.map(S=>S.sha)),[n]),h=r.useMemo(()=>cn(u||{}),[u]),w=r.useCallback(S=>dn(S,y,a,h),[y,a,h]),P=r.useMemo(()=>{const S=new Map;for(const T of a)S.set(T.sha,T.name);return S},[a]),R=r.useMemo(()=>mn(z,p,x,w),[z,p,x,w]),D=r.useMemo(()=>n.filter(S=>S.entityType==="visual").sort((S,T)=>S.name.localeCompare(T.name)),[n]),M=r.useMemo(()=>{const S=new Map;for(const T of c)S.set(T.name,T);return S},[c]),J=r.useRef(null),ce=r.useRef(0),be=r.useCallback(()=>{J.current&&(ce.current=J.current.scrollTop)},[]);r.useEffect(()=>{J.current&&ce.current>0&&(J.current.scrollTop=ce.current)});const je=(b==null?void 0:b.sha)??"overview";if(!t)return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx("h2",{className:"text-lg font-medium text-white font-['IBM_Plex_Sans'] m-0",children:"Ready to build something?"}),e.jsx("button",{onClick:j,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",children:e.jsxs("div",{className:"flex flex-col items-center gap-5 px-8 text-center max-w-[420px]",children:[e.jsx("h2",{className:"text-lg font-medium text-white font-['IBM_Plex_Sans'] m-0",children:"Migrate Your Project"}),e.jsx("p",{className:"text-sm text-gray-400 m-0 font-['IBM_Plex_Sans'] leading-relaxed",children:"It looks like you have an existing project. Claude can survey your codebase and systematically migrate it — deconstructing pages into clean components, extracting functions with tests, and creating scenarios. One page per session."}),e.jsx("button",{onClick:v,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:j,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"&&F){const S=F.pages||[],T=S.filter(A=>A.status==="complete").length,G=S.length,V=G>0?Math.round(T/G*100):0;return e.jsxs("div",{className:"flex-1 flex flex-col overflow-auto p-4",children:[e.jsx("h2",{className:"text-lg font-medium text-white font-['IBM_Plex_Sans'] m-0 mb-3",children:"Project Migration"}),e.jsxs("div",{className:"mb-4",children:[e.jsx("div",{className:"flex items-center gap-2 mb-1",children:e.jsxs("span",{className:"text-xs text-gray-400 font-['IBM_Plex_Sans']",children:[T,"/",G," pages (",V,"%)"]})}),e.jsx("div",{className:"w-full h-1.5 bg-[#2d2d2d] rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-[#005c75] rounded-full transition-all",style:{width:`${V}%`}})})]}),e.jsx("div",{className:"space-y-1.5",children:S.map((A,K)=>{const re=A.status==="complete"?"✓":A.status==="in-progress"?"→":"○",q=A.status==="complete"?"text-green-400":A.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 ${q} w-3 text-center`,children:re}),e.jsx("span",{className:`text-xs font-['IBM_Plex_Sans'] ${A.status==="in-progress"?"text-white font-medium":A.status==="complete"?"text-gray-400":"text-gray-600"}`,children:A.name}),e.jsx("span",{className:"text-[10px] text-gray-600",children:A.route}),A.status==="complete"&&e.jsxs("span",{className:"text-[10px] text-gray-600",children:[(A.extractedComponents||[]).length,"c"," ",(A.extractedFunctions||[]).length,"f"," ",A.scenarioCount||0,"s"]})]},K)})}),(F.sharedComponents||[]).length>0&&e.jsxs("div",{className:"mt-4",children:[e.jsx("h3",{className:"text-xs font-medium text-gray-400 font-['IBM_Plex_Sans'] mb-1.5",children:"Shared Components"}),(F.sharedComponents||[]).map((A,K)=>e.jsxs("div",{className:"text-[10px] text-gray-500 mb-0.5",children:[A.name," ",e.jsxs("span",{className:"text-gray-600",children:["— used in: ",(A.usedInPages||[]).join(", ")]})]},K))]}),e.jsx("div",{className:"mt-4",children:e.jsx("button",{onClick:j,className:"px-4 py-2 bg-[#005c75] text-white text-xs font-medium rounded-lg hover:bg-[#004d63] transition-colors cursor-pointer",children:"Continue in Chat"})})]})}if(!(s.length>0||D.length>0))return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-4 px-8 text-center",children:[_?e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"text-lg font-medium text-white font-['IBM_Plex_Sans'] m-0",children:_}),$&&e.jsx("p",{className:"text-sm text-gray-400 m-0 font-['IBM_Plex_Sans'] leading-relaxed",children:$})]}):e.jsx("h2",{className:"text-lg font-medium text-white font-['IBM_Plex_Sans'] m-0",children:"Your project is ready"}),e.jsx("p",{className:"text-sm text-gray-400 m-0 font-['IBM_Plex_Sans'] leading-relaxed",children:"Describe what you want to build in the Chat and your pages and components will appear here."}),e.jsx("button",{onClick:j,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){const S=b.filePath,T=b.name,G=n.some(f=>f.sha===b.sha||f.filePath===S),V=!!((te=u==null?void 0:u[T])!=null&&te.length);if(!G&&!V){s.some(O=>O.componentName===T&&O.entitySha===b.sha);const f=s.filter(O=>O.entitySha===b.sha),U=[`The "${b.displayName}" entity (${S}) 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 "${T}" to the glossary if it's not already there:`,` Check: cat .codeyam/glossary.json | grep "${T}"`,"",` If not found, add an entry with name "${T}" and filePath "${S}" 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(`
|
|
48
|
+
`);return e.jsx("div",{ref:J,onScroll:be,className:"flex-1 overflow-auto",children:e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsx(Tt,{items:E,onNavigate:I}),e.jsx("h2",{className:"text-sm font-semibold text-white m-0 font-['IBM_Plex_Sans'] uppercase tracking-wider",children:b.displayName}),S&&e.jsx(Ee,{filePath:S,projectRoot:i}),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(ge,{content:U,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"})})]}),f.length>0&&e.jsx("div",{className:"grid grid-cols-3 gap-2",children:f.map(O=>e.jsx(fe,{scenarioId:O.id,updatedAt:O.updatedAt,hasScreenshot:!!O.screenshotPath,name:O.name,isActive:O.id===l,onSelect:()=>m(O)},O.id))})]})},je)}const A=b.sha,K=s.filter(f=>!f.componentName&&(f.pageFilePath===S||A&&f.entitySha===A)),re=s.filter(f=>f.componentName===T||f.componentPath===S),q=D.find(f=>f.filePath===S||f.name===T),ne=M.get(T)||c.find(f=>f.filePath===S),ae=[...K,...re],ie=new Set((u==null?void 0:u[T])||[]),ve=V?[...p.entries()].filter(([f])=>ie.has(f)):[],Te=V?D.filter(f=>ie.has(f.name)&&!ve.some(([U])=>U===f.name)):[],$e=V?o.filter(f=>ie.has(f.name)&&f.returnType!=="JSX.Element"&&f.returnType!=="React.ReactNode").map(f=>({name:f.name,filePath:f.filePath,description:f.description||"",testFile:f.testFile,feature:f.feature})):[],Ne=ve.length>0||Te.length>0,ee=$e.length>0,Y=Ne||ee;return e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsx(Tt,{items:E,onNavigate:I}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold text-white m-0 font-['IBM_Plex_Sans'] uppercase tracking-wider",children:b.displayName}),b.filePath&&e.jsx(Ee,{filePath:b.filePath,projectRoot:i})]}),ae.length>0&&e.jsx("div",{className:"grid grid-cols-3 gap-2",children:ae.map(f=>e.jsx(fe,{scenarioId:f.id,updatedAt:f.updatedAt,hasScreenshot:!!f.screenshotPath,name:f.name,isActive:f.id===l,onSelect:()=>m(f)},f.id))}),q&&(q.scenarios.length>0||q.pendingScenarios.length>0)&&e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[q.scenarios.map(f=>e.jsx(fe,{imgSrc:f.screenshotPath?`/api/screenshot/${f.screenshotPath}`:null,name:f.name,isActive:!1,onSelect:()=>N({analysisId:q.analysisId,scenarioId:f.id,scenarioName:f.name,entitySha:q.sha,entityName:q.name})},f.id)),q.pendingScenarios.map(f=>e.jsx("div",{className:"px-2.5 py-1 bg-[#2a2a2a] text-gray-400 text-[10px] rounded-full",title:f,children:f},f))]}),ne&&ne.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(Ee,{filePath:ne.testFile,projectRoot:i})]}),e.jsx(tt,{testFile:ne.testFile,entityName:T})]}),ae.length===0&&!q&&!ne&&e.jsx("div",{className:"text-xs text-gray-500",children:"No scenarios for this entity"}),ae.length>0&&e.jsx(gn,{scenarios:ae,entityName:b.displayName,entityFilePath:b.filePath,entityType:b.entityType,onSwitchToBuild:j,onScenarioSelect:m}),Y&&e.jsxs("div",{className:"pt-3 mt-2 border-t border-[#3d3d3d] space-y-3",children:[Ne&&e.jsxs("div",{children:[e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Components"}),ve.map(([f,U])=>e.jsx("div",{className:"mt-3",children:x.has(f)?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"py-1",children:e.jsx("button",{onClick:()=>I(f,x.get(f)),className:"text-[11px] font-medium text-gray-400 cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:f})}),U.length>0&&e.jsx("div",{className:"grid grid-cols-3 gap-2 pt-1",children:U.map(O=>e.jsx(fe,{scenarioId:O.id,updatedAt:O.updatedAt,hasScreenshot:!!O.screenshotPath,name:O.name,isActive:O.id===l,onSelect:()=>m(O)},O.id))})]}):e.jsxs("div",{className:"py-2",children:[e.jsx("span",{className:"text-[11px] font-medium text-gray-500",children:f}),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(Bt,{name:f,scenarios:U})})]})},f)),Te.map(f=>e.jsxs("div",{className:"mt-3",children:[e.jsx("div",{className:"py-1",children:e.jsx("button",{onClick:()=>I(f.name,f.sha),className:"text-[11px] font-medium text-gray-400 cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:f.name})}),(f.scenarios.length>0||f.pendingScenarios.length>0)&&e.jsxs("div",{className:"grid grid-cols-3 gap-2 pt-1",children:[f.scenarios.map(U=>e.jsx(fe,{imgSrc:U.screenshotPath?`/api/screenshot/${U.screenshotPath}`:null,name:U.name,isActive:!1,onSelect:()=>N({analysisId:f.analysisId,scenarioId:U.id,scenarioName:U.name,entitySha:f.sha,entityName:f.name})},U.id)),f.pendingScenarios.map(U=>e.jsx("div",{className:"px-2.5 py-1 bg-[#2a2a2a] text-gray-400 text-[10px] rounded-full",title:U,children:U},U))]})]},f.sha))]}),ee&&e.jsxs("div",{children:[e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Functions"}),$e.map(f=>e.jsxs("div",{className:"mt-2",children:[e.jsx("div",{className:"py-1",children:e.jsx("button",{onClick:()=>I(f.name,x.get(f.name)),className:"text-[11px] font-medium text-gray-400 cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:f.name})}),e.jsx(Ee,{filePath:f.filePath,projectRoot:i}),f.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:f.testFile})]}),e.jsx(tt,{testFile:f.testFile,entityName:f.name})]})]},f.name))]})]})]})})}return e.jsx("div",{ref:J,onScroll:be,className:"flex-1 overflow-auto",children:e.jsxs("div",{className:"p-4 space-y-4",children:[_&&e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-white m-0 font-['IBM_Plex_Sans']",children:_}),$&&e.jsx("p",{className:"text-xs text-gray-400 m-0 mt-1 font-['IBM_Plex_Sans'] leading-relaxed",children:$})]}),R.length>1&&e.jsx(fn,{brokenEntities:R}),z.size>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Application"}),e.jsx("button",{onClick:j,className:"px-2.5 py-1 text-[10px] font-medium text-gray-400 bg-[#2a2a2a] border border-[#4d4d4d] rounded hover:bg-[#333] hover:text-white hover:border-[#005c75] transition-colors cursor-pointer",children:"+ New Page"})]}),e.jsxs("p",{className:"text-[11px] text-gray-500 m-0 mt-1.5 font-['IBM_Plex_Sans'] leading-relaxed",children:["Select a page scenario below and switch to"," ",e.jsx("button",{onClick:j,className:"text-[#00a0c4] hover:text-[#00c4eb] bg-transparent border-none p-0 cursor-pointer underline font-inherit text-inherit",children:"Build"})," ","to change or enhance an existing page or"," ",e.jsx("button",{onClick:j,className:"text-[#00a0c4] hover:text-[#00c4eb] bg-transparent border-none p-0 cursor-pointer underline font-inherit text-inherit",children:"create a new page"})]}),[...z.entries()].sort(([S],[T])=>S==="Home"?-1:T==="Home"?1:S.localeCompare(T)).map(([S,T])=>{var G,V;return e.jsx("div",{className:"mt-2",children:x.has(S)&&w(x.get(S))?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"py-1",children:[e.jsx("button",{onClick:()=>I(S,x.get(S)),className:"text-[11px] font-medium text-gray-400 cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:S}),(()=>{const A=x.get(S),K=A?P.get(A):void 0;return K&&K!==S?e.jsx("span",{className:"text-[10px] text-gray-600 ml-1.5",children:K}):null})()]}),(((G=T[0])==null?void 0:G.pageFilePath)||L[S])&&e.jsx(Ee,{filePath:((V=T[0])==null?void 0:V.pageFilePath)||L[S],projectRoot:i}),e.jsx("div",{className:"grid grid-cols-3 gap-2 pt-1",children:T.map(A=>e.jsx(fe,{scenarioId:A.id,updatedAt:A.updatedAt,hasScreenshot:!!A.screenshotPath,name:A.name,isActive:A.id===l,onSelect:()=>m(A)},A.id))})]}):e.jsxs("div",{className:"py-2",children:[e.jsx("span",{className:"text-[11px] font-medium text-gray-500",children:S}),e.jsx("p",{className:"text-[10px] text-amber-400/80 m-0 mt-1.5 leading-relaxed",children:"There is data missing that is required to show the scenarios for this page. Please copy and paste this prompt into Claude to ask Claude to fix the data."}),e.jsx("div",{className:"mt-1.5",children:e.jsx(Bt,{name:S,scenarios:T,reason:x.has(S)?"incomplete":"missing"})})]})},S)})]})]})},je)}const jn=[{key:"app",label:"App"},{key:"build",label:"Build"},{key:"data",label:"Structure"},{key:"journal",label:"Journal"}];function yn({activeTab:t,onTabChange:s,buildIdle:n}){return e.jsxs("div",{className:"bg-[#3d3d3d] h-10 flex items-center px-3 gap-3 shrink-0 z-20 border-b border-[#2d2d2d]",children:[e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx("img",{src:zs,alt:"CodeYam",className:"h-5 brightness-0 invert"}),e.jsx("span",{className:"text-white font-medium text-xs whitespace-nowrap",children:"Codeyam Editor"})]}),e.jsx("div",{className:"flex-1"}),e.jsx("div",{className:"flex items-center gap-2 shrink-0",children:e.jsx("div",{className:"flex items-center gap-0.5 bg-[#4a3232] rounded-lg p-0.5",children:jn.map(a=>e.jsxs("button",{onClick:()=>s(a.key),className:`px-2.5 py-1 text-xs font-medium rounded-md transition-colors cursor-pointer ${t===a.key?"bg-[#7a4444] text-white":"text-gray-300 hover:text-white"}`,children:[a.label,a.key==="build"&&n&&t!=="build"&&e.jsx("span",{className:"ml-1 inline-block w-1.5 h-1.5 rounded-full bg-amber-400 animate-pulse"})]},a.key))})})]})}function vn({onMouseDown:t,onDoubleClick:s,isDragging:n}){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:n?3:1,backgroundColor:n?"#3b82f6":"#3d3d3d",transition:"width 100ms, background-color 100ms"}}),!n&&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:n?{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 Nn=300,Le=150;function wn(t){const[s,n]=r.useState(null),[a,c]=r.useState(!1),o=r.useRef(0);r.useEffect(()=>{t.current&&n(Math.round(t.current.offsetWidth*.5))},[t]);const i=r.useCallback(()=>{var u;return((u=t.current)==null?void 0:u.offsetWidth)??(typeof window<"u"?window.innerWidth:1024)},[t]),l=r.useCallback(u=>{u.preventDefault(),c(!0)},[]),m=r.useCallback(()=>{n(Math.round(i()*.5))},[i]),N=r.useCallback(()=>{n(Math.round(i()*.5))},[i]),j=r.useCallback(()=>{n(Math.round(i()*.5))},[i]);r.useEffect(()=>{if(!a)return;document.body.style.cursor="col-resize",document.body.style.userSelect="none";const u=_=>{cancelAnimationFrame(o.current),o.current=requestAnimationFrame(()=>{var p;const $=(p=t.current)==null?void 0:p.getBoundingClientRect(),B=($==null?void 0:$.left)??0,v=(($==null?void 0:$.width)??window.innerWidth)-Le,E=_.clientX-B,z=Math.min(Math.max(E,Nn),v);n(z)})},L=_=>{var E;cancelAnimationFrame(o.current),c(!1);const $=(E=t.current)==null?void 0:E.getBoundingClientRect(),B=($==null?void 0:$.left)??0,F=($==null?void 0:$.width)??window.innerWidth,v=_.clientX-B;v<Le?n(0):F-v<Le&&n(F)};return document.addEventListener("mousemove",u),document.addEventListener("mouseup",L),()=>{cancelAnimationFrame(o.current),document.removeEventListener("mousemove",u),document.removeEventListener("mouseup",L),document.body.style.cursor="",document.body.style.userSelect=""}},[a,t]),r.useEffect(()=>{const u=()=>{n(L=>{if(L===null||L===0)return L;const _=i();return L>=_?_:Math.min(L,_-Le)})};if(!(typeof window>"u"))return window.addEventListener("resize",u),()=>window.removeEventListener("resize",u)},[i]);const k=i(),b=s===0,I=s!==null&&s>=k;return{editorWidth:s,isDragging:a,isEditorCollapsed:b,isPreviewCollapsed:I,handleMouseDown:l,handleDoubleClick:m,expandEditor:N,expandPreview:j}}function Sn({preview:t,onDismiss:s,onLoadCommit:n}){return e.jsxs("div",{className:"flex flex-col items-center gap-6 max-w-[700px] w-full",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("h2",{className:"text-lg font-semibold text-[#333] m-0 font-['IBM_Plex_Sans']",children:"Journal Screenshot"}),e.jsx("p",{className:"text-sm text-[#888] mt-1 m-0 font-['IBM_Plex_Sans']",children:"This is a snapshot from a previous version — not a live preview"})]}),e.jsx("div",{className:"rounded-lg overflow-hidden border-2 border-[#ccc] shadow-md max-w-full w-fit",children:e.jsx("img",{src:t.screenshotUrl,alt:t.scenarioName,className:"max-w-full h-auto block"})}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-[#666]",children:[t.commitSha&&e.jsx("span",{className:"font-mono text-xs text-[#00a0c4] bg-[#00a0c4]/15 px-2 py-0.5 rounded",children:t.commitSha.slice(0,7)}),e.jsxs("span",{className:"truncate",children:[t.scenarioName,t.commitMessage&&` — ${t.commitMessage}`]})]}),e.jsx("div",{className:"flex items-center gap-3",children:t.commitSha&&n&&e.jsx(kn,{commitSha:t.commitSha,onLoadCommit:n})})]})}function kn({commitSha:t,onLoadCommit:s}){const[n,a]=r.useState(!1),[c,o]=r.useState(null);return e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>{a(!0),o(null),s(t).then(i=>{i.success||o(i.error||"Failed to load commit")}).catch(i=>{o(i instanceof Error?i.message:"Network error")}).finally(()=>a(!1))},disabled:n,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:n?"Reverting...":"Revert to this code and load this version"}),c&&e.jsx("div",{className:"bg-red-50 border border-red-200 rounded px-4 py-2 text-sm text-red-600 w-full text-center",children:c})]})}function Cn({analysisId:t,scenarioId:s,scenarioName:n,entityName:a,projectSlug:c,onStateChange:o}){const{interactiveServerUrl:i,isStarting:l,isLoading:m}=Ws({analysisId:t,scenarioId:s,scenarioName:n,entityName:a,projectSlug:c,enabled:!0});return r.useEffect(()=>{o(i,l||m)},[i,l,m,o]),null}function Pn({onSaveToCurrent:t,onSaveAsNew:s,onDismiss:n,isSaving:a}){return e.jsxs("div",{className:"flex items-center justify-between px-4 py-1.5 bg-emerald-900/60 border-b border-emerald-700/50 text-emerald-200 text-xs",children:[e.jsx("span",{className:"font-medium",children:"Data modified."}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:t,disabled:a,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:a?"Saving...":"Save to Scenario"}),e.jsx("button",{onClick:s,disabled:a,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:n,disabled:a,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 En(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 Mn(t){const[s,n]=r.useState({url:null,proxyUrl:null,isStarting:!1,error:null,canStartServer:!0,autoStartAttempted:!1}),a=r.useRef(s);a.current=s,r.useEffect(()=>{let i=!1,l=null;const m=async()=>{try{const N=await fetch("/api/editor-dev-server");if(i)return;const j=await N.json(),k=En(a.current,j),{shouldAutoStart:b,...I}=k;if(n(I),b&&!(t!=null&&t.skipAutoStart))try{const u=await fetch("/api/editor-dev-server",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"start"})});if(i)return;u.ok?n(L=>({...L,isStarting:!0})):n(L=>({...L,canStartServer:!1}))}catch{}}catch{}};return m(),l=setInterval(()=>void m(),2e3),()=>{i=!0,l&&clearInterval(l)}},[s.url]);const c=r.useCallback(()=>{n(i=>({...i,error:null,isStarting:!0})),fetch("/api/editor-dev-server",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"restart"})}).catch(()=>{})},[]),o=r.useCallback(()=>{n(i=>({...i,error:null,isStarting:!0})),fetch("/api/editor-dev-server",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"start"})}).catch(()=>{})},[]);return{devServerUrl:s.url,proxyUrl:s.proxyUrl,isStarting:s.isStarting,error:s.error,canStartServer:s.canStartServer,retryServer:c,startServer:o}}function In(t){const s=r.useRef(null),n=r.useRef(null);r.useEffect(()=>{if(typeof document>"u")return;n.current||(n.current=document.createElement("canvas"),n.current.width=64,n.current.height=64);const a=document.querySelector('link[rel="icon"]');if(!a)return;if(s.current||(s.current=a.href),!t){a.href=s.current;return}const c=new Image;c.crossOrigin="anonymous",c.onload=()=>{const o=n.current,i=o.getContext("2d");i.clearRect(0,0,64,64);const l=56,m=(64-l)/2;i.drawImage(c,m,m,l,l);const N=12,j=64-N-1,k=N+1;i.beginPath(),i.arc(j,k,N+3,0,2*Math.PI),i.fillStyle="#ffffff",i.fill(),i.beginPath(),i.arc(j,k,N,0,2*Math.PI),i.fillStyle="#ef4444",i.fill(),a.href=o.toDataURL("image/png")},c.src=s.current},[t]),r.useEffect(()=>()=>{if(typeof document>"u")return;const a=document.querySelector('link[rel="icon"]');a&&s.current&&(a.href=s.current)},[])}function Hn({currentUrl:t,nextUrl:s,formMethod:n,defaultShouldRevalidate:a}){return n||t.pathname===s.pathname?a:t.pathname.startsWith("/editor")&&s.pathname.startsWith("/editor")?!1:a}const Jn=()=>[{title:"Editor - CodeYam"},{name:"description",content:"CodeYam Code + Data Editor"}];class Tn extends r.Component{constructor(){super(...arguments);kt(this,"state",{error:null,errorInfo:null})}static getDerivedStateFromError(n){return{error:n,errorInfo:null}}componentDidCatch(n,a){console.error("[EditorErrorBoundary] Error:",n.message),console.error("[EditorErrorBoundary] Component stack:",a.componentStack),console.error("[EditorErrorBoundary] Loader snapshot:",JSON.stringify(this.props.loaderSnapshot,null,2)),this.setState({errorInfo:a})}render(){var n;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}),((n=this.state.errorInfo)==null?void 0:n.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 Gn=ws(function(){const{projectSlug:s,projectRoot:n,hasProject:a,scenarios:c,allScenarios:o,analyzedEntities:i,allEntities:l,glossaryFunctions:m,glossaryEntries:N,entityImports:j,pageFilePaths:k,entityChangeStatus:b,modifiedFiles:I,featureName:u,userPrompt:L,projectTitle:_,projectDescription:$,defaultScreenSize:B,screenSizes:F,editorStep:v,editorStepLabel:E,claudeSessionId:z,focusedEntitySha:p,newerEntitySha:x,focusedEntity:y,migrationMode:h,migrationState:w}=Ss(),[P,R]=ks(),D=Cs(),M=r.useRef(null),J=r.useRef(null),ce=r.useRef(null),be=r.useRef(null),[je,ye]=r.useState(p);r.useEffect(()=>{ye(p)},[p]);const te=r.useMemo(()=>xn(je,l),[je,l,o]),S=(te==null?void 0:te.displayName)??void 0,T=P.get("scenario")||void 0,[G,V]=r.useState(()=>S?[S]:[]),A=r.useRef(null),K=r.useRef([]),re=r.useRef(null);r.useEffect(()=>{var H;const d=T||((H=Ts(o))==null?void 0:H.id);if(!$s(d,A.current))return;const g=o.find(Z=>Z.id===d);if(!g)return;A.current=d;const C=Ke(g,K.current,re.current);C&&de(C);const W=Qe(g.name);fetch("/api/editor-switch-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioSlug:W,scenarioId:g.id,scenarioName:g.name,scenarioType:g.type})}).catch(()=>{})},[T,o]),r.useEffect(()=>{const d=new BroadcastChannel("codeyam-editor");return d.onmessage=g=>{var C;if(((C=g.data)==null?void 0:C.type)==="switch-scenario"&&g.data.scenarioId){const W=g.data.scenarioId,H=o.find(he=>he.id===W);if(!H)return;A.current=W;const Z=new URLSearchParams(P);Z.set("scenario",W),Z.delete("zoom"),R(Z),f(null),O(null),oe(null),we(!0);const Ce=Qe(H.name);fetch("/api/editor-switch-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioSlug:Ce,scenarioId:W,scenarioType:H.type})}).then(()=>{ee(!1),Re(he=>he+1)}).catch(()=>{we(!1)})}},()=>d.close()},[P,R,o]),r.useEffect(()=>{if(P.get("ref")!=="link"||!T)return;const d=new BroadcastChannel("codeyam-editor");d.postMessage({type:"switch-scenario",scenarioId:T}),d.close(),window.close()},[]);const{devServerUrl:q,proxyUrl:ne,isStarting:ae,error:ie,canStartServer:ve,retryServer:Te,startServer:$e}=Mn({skipAutoStart:h==="candidate"||h==="active"}),[Ne,ee]=r.useState(!1),[Y,f]=r.useState(null),[U,O]=r.useState(null),[Be,nt]=r.useState(!1),[Oe,oe]=r.useState(null),Ht=r.useCallback(async d=>{const C=await(await fetch("/api/editor-load-commit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({commitSha:d})})).json();return C.success&&(oe(null),ee(!1)),C},[]),Jt=r.useCallback((d,g)=>{O(C=>(d&&d!==C&&ee(!1),d)),!g&&d&&ee(!0),nt(g)},[]),at=r.useCallback(d=>{oe(null),f(C=>(C&&C.analysisId===d.analysisId||(O(null),Re(H=>H+1)),d)),nt(!0),ee(!1);const g=new URLSearchParams(P);g.delete("scenario"),g.delete("zoom"),R(g)},[P,R]),[X,de]=r.useState(B?{name:B.name,width:B.width,height:B.height}:{name:"Desktop",width:1440,height:900}),[rt,it]=r.useState(!1),ot=B?{name:B.name,width:B.width,height:B.height}:null;re.current=ot;const lt=Ps(),Q=r.useMemo(()=>{const d=lt.pathname.split("/").filter(Boolean),g=d[d.length-1];return g==="build"||g==="journal"?g:g==="structure"?"data":"app"},[lt.pathname]),se=r.useCallback(d=>{ye(null),V([]);const g=d==="app"?"":`/${d==="data"?"structure":d}`,C=P.get("scenario"),W=C?`?scenario=${C}`:"";D(`/editor${g}${W}`)},[D,P]),Gt=r.useCallback(()=>{se("build"),me(!0)},[se]),Vt=r.useCallback(()=>{se("build"),me(!0),setTimeout(()=>{var d;(d=M.current)==null||d.sendInput("codeyam editor migrate")},300)},[se]),[qt,me]=r.useState(Q==="build"),Yt=!!(u&&v),[Ae,Xt]=r.useState(Yt?"pending":"no-session");r.useEffect(()=>{Ae==="pending"&&(se("build"),me(!0))},[Ae,se]);const Kt=r.useCallback(()=>{Xt("continue")},[]),[ze,We]=r.useState(!1),[Qt,ct]=r.useState(!1),Zt=r.useCallback(d=>{We(d),d&&ct(!1)},[]);In(ze);const{editorWidth:dt,isDragging:mt,isEditorCollapsed:Ue,isPreviewCollapsed:He,handleMouseDown:es,handleDoubleClick:ts,expandEditor:ss,expandPreview:ns}=wn(be),[xe,xt]=r.useState(!1),as=r.useCallback(()=>{xt(!0),se("build"),me(!0)},[se]);r.useEffect(()=>{if(!xe||c.length===0)return;const g=c.filter(C=>!C.componentName)[0]||c[0];g&&g.id!==T&&ue(g)},[xe]);const pt=r.useCallback(()=>{xt(!1)},[]),rs=r.useCallback(d=>{de(d),fetch("/api/editor-project-info",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({defaultScreenSize:d,skipBroadcast:!0})})},[]),[ut,ht]=r.useState(As);r.useEffect(()=>{const d=Rs();ht(d),d.systemNotification&&typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission()},[]);const is=r.useCallback(d=>{ht(d),Ls(d)},[]);r.useEffect(()=>{if(Q==="build"){We(!1);const d=setTimeout(()=>{var g,C;(g=M.current)==null||g.scrollToBottom(),(C=M.current)==null||C.focus()},50);return()=>clearTimeout(d)}},[Q]),r.useEffect(()=>{function d(){!document.hidden&&Q==="build"&&We(!1)}return document.addEventListener("visibilitychange",d),()=>document.removeEventListener("visibilitychange",d)},[Q]);const[Je,os]=r.useState(null);r.useEffect(()=>{const d=ce.current;if(!d)return;const g=new ResizeObserver(C=>{const W=C[0];W&&os({width:W.contentRect.width,height:W.contentRect.height})});return g.observe(d),()=>g.disconnect()},[]);const pe=r.useMemo(()=>Je?_s(Je,X):1,[Je,X]),[Ge,Re]=r.useState(0),[ft,Ve]=r.useState(null),[gt,we]=r.useState(!1),[ls,Se]=r.useState(!1),[cs,bt]=r.useState(!1),ds=r.useCallback(()=>{Se(!0)},[]);r.useEffect(()=>{const d=g=>{var C;((C=g.data)==null?void 0:C.type)==="codeyam-localstorage-changed"&&Se(!0)};return window.addEventListener("message",d),()=>window.removeEventListener("message",d)},[]);const jt=r.useCallback(async d=>{bt(!0);try{let g;const C=J.current;C!=null&&C.contentWindow&&(g=await new Promise(Z=>{const Ce=setTimeout(()=>Z(void 0),2e3),he=wt=>{var St;((St=wt.data)==null?void 0:St.type)==="codeyam-localstorage-state"&&(clearTimeout(Ce),window.removeEventListener("message",he),Z(wt.data.data))};window.addEventListener("message",he),C.contentWindow.postMessage({type:"codeyam-get-localstorage"},"*")}));const H=await(await fetch("/api/editor-save-seed-state",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:d,localStorage:g})})).json();H.success?Se(!1):console.error("[editor] Save seed state failed:",H.error)}catch(g){console.error("[editor] Save seed state error:",g)}finally{bt(!1)}},[]),ms=r.useCallback((d,g)=>{if(Ve(d||null),g){const C=new URLSearchParams(P);C.set("scenario",g),A.current=g,R(C);const W=o.find(H=>H.id===g);if(W){const H=Ke(W,K.current,re.current);H&&de(H)}}oe(null),ee(!1),Re(C=>C+1)},[P,R,o]),{customSizes:qe,addCustomSize:xs,removeCustomSize:ps}=Ms(s),Ye=r.useMemo(()=>Hs(F),[F]),Xe=r.useMemo(()=>[...Ye,...qe],[Ye,qe]);K.current=Xe;const yt=r.useMemo(()=>{const d=new Map;for(const g of l){d.set(g.name,g.sha);const C=Ie(Me(g.filePath));C!==g.name&&d.set(C,g.sha)}return d},[l]),us=r.useMemo(()=>{const d=[{name:"App"}];for(const g of G)d.push({name:g,componentName:g,entitySha:yt.get(g)});return d},[G,yt]),vt=r.useCallback((d,g)=>{if(!d){V([]),ye(null);const Z=P.get("scenario"),Ce=Z?`?scenario=${Z}`:"";D(`/editor${Ce}`);return}if(!g){console.error(`[editor] No entity SHA for "${d}" — entity missing from database`);return}const C=G.indexOf(d);C>=0?V(G.slice(0,C+1)):V([...G,d]);const W=o.find(Z=>Z.entitySha===g);ye(g);const H=W?`?scenario=${W.id}`:"";D(`/editor/entity/${g}${H}`)},[D,o,G,P]),ue=r.useCallback(d=>{f(null),O(null),oe(null),Ve(null);const g=Ke(d,Xe,ot);g&&de(g),A.current=d.id;const C=new URLSearchParams(P);C.set("scenario",d.id),R(C),we(!0),Se(!1);const W=Qe(d.name);fetch("/api/editor-switch-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioSlug:W,scenarioId:d.id,scenarioType:d.type,skipBroadcast:!0})}).then(()=>{ee(!1),Re(H=>H+1)}).catch(()=>{we(!1)})},[P,R,Xe]),hs=r.useCallback(d=>{if(!d.commitSha){const g=o.find(C=>C.name===d.scenarioName);if(g){ue(g);return}}oe(d)},[o,ue]),fs=d=>{const g={name:d.name,width:d.width,height:d.height};de(g),fetch("/api/editor-project-info",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({defaultScreenSize:g,skipBroadcast:!0})})},gs=(d,g,C)=>{xs(d,g,C)},bs=d=>{de(d),fetch("/api/editor-project-info",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({defaultScreenSize:d,skipBroadcast:!0})})},js=()=>{Y||ee(!0),we(!1)},ke=r.useMemo(()=>Ds({activeAnalyzedScenario:!!Y,analyzedPreviewUrl:U,activeScenarioId:T||null,scenarios:o,proxyUrl:ne,devServerUrl:q,zoomComponent:S||null}),[ne,q,S,T,o,Y,U]),Nt=r.useMemo(()=>{const d=Fs(ke,ft);if(!d)return null;const g=d.includes("?")?"&":"?";return`${d}${g}__cb=${Ge}`},[ke,ft,Ge]),ys=r.useMemo(()=>({projectSlug:s,hasProject:a,scenarioCount:c==null?void 0:c.length,allScenarioCount:o==null?void 0:o.length,analyzedEntityCount:i==null?void 0:i.length,glossaryFunctionCount:m==null?void 0:m.length,entityChangeStatusKeys:b?Object.keys(b):[],featureName:u}),[s,a,c,o,i,m,b,u]);return e.jsxs(e.Fragment,{children:[e.jsx(Tn,{loaderSnapshot:ys,children:e.jsxs("div",{className:"fixed inset-0 bg-[#2d2d2d] flex flex-col",children:[Y&&e.jsx(Cn,{analysisId:Y.analysisId,scenarioId:Y.scenarioId,scenarioName:Y.scenarioName,entityName:Y.entityName,projectSlug:s,onStateChange:Jt},Y.analysisId),e.jsxs("div",{ref:be,className:"flex-1 flex min-h-0",children:[Ue&&e.jsx("div",{className:"shrink-0 flex items-center justify-center cursor-pointer hover:bg-[#3d3d3d] transition-colors",style:{width:8,backgroundColor:"#2d2d2d"},onClick:ss,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:{...Ue?{display:"none"}:dt!==null?{width:`${dt}px`}:{width:"50%"}},children:[x&&te&&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:te.name}),". A newer version exists."]}),e.jsx("a",{href:`/editor/entity/${x}`,className:"px-2 py-0.5 rounded text-xs",style:{background:"#3d2e00",color:"#f0c040",textDecoration:"none"},children:"View latest"})]}),e.jsx(yn,{activeTab:Q,onTabChange:d=>{se(d),d==="build"&&me(!0),fetch("/api/telemetry-page-view",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({route:`/editor/${d}`})}).catch(()=>{})},buildIdle:ze}),e.jsxs("div",{className:"flex-1 overflow-hidden relative",children:[ze&&Q!=="build"&&!Qt&&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:`
|
|
49
|
+
@keyframes slideDown {
|
|
50
|
+
from { transform: translate(-50%, -100%); opacity: 0; }
|
|
51
|
+
to { transform: translate(-50%, 0); opacity: 1; }
|
|
52
|
+
}
|
|
53
|
+
`}),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:()=>{se("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:d=>{d.stopPropagation(),ct(!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"})})})]})]}),qt&&e.jsxs("div",{className:"absolute inset-0 flex flex-col overflow-hidden",style:{visibility:Q==="build"?"visible":"hidden"},children:[e.jsx("div",{className:xe?"flex-1 min-h-0":"flex-1",style:xe?{flex:"1 1 50%"}:void 0,children:Ae==="pending"?e.jsx(Js,{featureName:u,editorStep:v,editorStepLabel:E,onContinue:Kt}):e.jsx(Bs,{ref:M,entityName:"Editor",projectSlug:s,entityFilePath:null,scenarioName:null,onRefreshPreview:ms,onShowResults:as,onHideResults:pt,onSetViewport:rs,onDataMutationForwarded:ds,editorMode:!0,onIdleChange:Zt,notificationSettings:ut,buildTabActive:Q==="build",claudeStartMode:Ae==="continue"?"resume":"fresh",claudeSessionId:z,resultsOpen:xe})}),xe&&e.jsx("div",{style:{flex:"1 1 50%"},className:"min-h-0 border-t-2 border-gray-300",children:e.jsx(un,{scenarios:c,allScenarios:o,glossaryFunctions:m,projectRoot:n,activeScenarioId:T,onScenarioSelect:ue,onClose:pt,entityChangeStatus:b,modifiedFiles:I,featureName:u,userPrompt:L})})]}),e.jsx("div",{className:"absolute inset-0 flex flex-col overflow-hidden",style:{visibility:Q==="app"?"visible":"hidden"},children:e.jsx(bn,{hasProject:a,scenarios:o,analyzedEntities:i,allEntities:l,glossaryFunctions:m,glossaryEntries:N,projectRoot:n,activeScenarioId:T,onScenarioSelect:ue,onAnalyzedScenarioSelect:at,onSwitchToBuild:Gt,zoomComponent:S,focusedEntity:te,onZoomChange:vt,entityImports:j,pageFilePaths:k,projectTitle:_,projectDescription:$,breadcrumbItems:us,migrationMode:h,migrationState:w,onStartMigration:Vt})}),e.jsx("div",{className:"absolute inset-0 flex flex-col overflow-hidden",style:{visibility:Q==="data"?"visible":"hidden"},children:e.jsx(Gs,{scenarios:o,projectRoot:n,activeScenarioId:T,onScenarioSelect:ue,zoomComponent:S,focusedEntity:te,onZoomChange:vt,analyzedEntities:[],glossaryFunctions:m,activeAnalyzedScenarioId:Y==null?void 0:Y.scenarioId,onAnalyzedScenarioSelect:at,entityImports:j,pageFilePaths:k})}),e.jsx("div",{className:"absolute inset-0 flex flex-col overflow-hidden",style:{visibility:Q==="journal"?"visible":"hidden"},children:e.jsx(an,{isActive:Q==="journal",onScreenshotClick:hs,glossaryFunctions:m})})]}),e.jsx(Os,{serverUrl:q,isStarting:ae,projectSlug:s,devServerError:ie,onStartServer:ve?$e:void 0,notificationSettings:ut,onChangeNotificationSettings:is})]}),!Ue&&!He&&e.jsx(vn,{onMouseDown:es,onDoubleClick:ts,isDragging:mt}),He&&e.jsx("div",{className:"shrink-0 flex items-center justify-center cursor-pointer hover:bg-[#3d3d3d] transition-colors",style:{width:8,backgroundColor:"#2d2d2d"},onClick:ns,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:{...He?{display:"none"}:void 0,...mt?{pointerEvents:"none"}:void 0},children:[e.jsxs("div",{className:"bg-[#2d2d2d] border-b border-[#3d3d3d] shrink-0 z-10 h-10 flex items-center px-4 relative",children:[e.jsx("div",{className:"flex items-center gap-1 shrink-0 z-10"}),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:[_e.map(d=>e.jsxs("button",{onClick:()=>fs(d),className:`p-1.5 rounded transition-colors cursor-pointer ${X.name===d.name?"text-white bg-[#555]":"text-gray-500 hover:text-gray-300"}`,title:`${d.name} (${d.width}×${d.height})`,children:[d.name==="Desktop"&&e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2"}),e.jsx("path",{d:"M8 21h8M12 17v4"})]}),d.name==="Laptop"&&e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M4 6a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v8H4V6z"}),e.jsx("path",{d:"M2 18h20"})]}),d.name==="Tablet"&&e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"5",y:"2",width:"14",height:"20",rx:"2"}),e.jsx("path",{d:"M12 18h.01"})]}),d.name==="Mobile"&&e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"7",y:"2",width:"10",height:"20",rx:"2"}),e.jsx("path",{d:"M12 18h.01"})]})]},d.name)),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>it(d=>!d),className:`flex items-center gap-1.5 px-2 py-1 rounded transition-colors cursor-pointer ${rt||!_e.some(d=>d.name===X.name)?"text-white bg-[#555]":"text-gray-400 hover:text-gray-200 hover:bg-[#444]"}`,title:"Custom dimensions",children:[e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M17 3a2.83 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"})}),e.jsxs("span",{className:"text-xs font-mono",children:[X.width," ×"," ",X.height??900]})]}),rt&&e.jsx(Is,{currentWidth:X.width,currentHeight:X.height??900,devicePresets:Ye,customSizes:qe,onApply:bs,onSave:gs,onRemove:ps,onClose:()=>it(!1)})]}),e.jsx("button",{onClick:()=>{const d=Nt||ke;d&&window.open(d,"_blank")},className:"p-1.5 rounded text-gray-500 hover:text-gray-300 transition-colors cursor-pointer",title:"Open preview in new window",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),e.jsx("polyline",{points:"15 3 21 3 21 9"}),e.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]})})]})})]}),ls&&e.jsx(Pn,{onSaveToCurrent:()=>void jt("overwrite"),onSaveAsNew:()=>void jt("new"),onDismiss:()=>Se(!1),isSaving:cs}),e.jsx("div",{ref:ce,className:"flex-1 flex items-center justify-center overflow-hidden p-8",style:Oe?{backgroundColor:"#f5f0e8",backgroundImage:"repeating-linear-gradient(0deg, transparent, transparent 19px, #e8e0d0 19px, #e8e0d0 20px), repeating-linear-gradient(90deg, transparent, transparent 19px, #e8e0d0 19px, #e8e0d0 20px)"}:{backgroundImage:`
|
|
54
|
+
linear-gradient(45deg, #333 25%, transparent 25%),
|
|
55
|
+
linear-gradient(-45deg, #333 25%, transparent 25%),
|
|
56
|
+
linear-gradient(45deg, transparent 75%, #333 75%),
|
|
57
|
+
linear-gradient(-45deg, transparent 75%, #333 75%)
|
|
58
|
+
`,backgroundSize:"16px 16px",backgroundPosition:"0 0, 0 8px, 8px -8px, -8px 0px",backgroundColor:"#2d2d2d"},children:Oe?e.jsx(Sn,{preview:Oe,onDismiss:()=>oe(null),onLoadCommit:Ht}):ke?e.jsx("div",{style:{width:`${X.width*pe}px`,height:`${(X.height??900)*pe}px`},children:e.jsxs("div",{className:"relative bg-white origin-top-left",style:{width:`${X.width}px`,height:`${X.height??900}px`,transform:pe<1?`scale(${pe})`:void 0},children:[!Ne&&!gt&&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(Ct,{})}),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"})]})]})}),gt&&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:J,src:Nt||ke,className:"w-full h-full border-none",title:"Editor preview",onLoad:js,style:{opacity:Ne?1:0}},Ge)]})}):e.jsx("div",{className:"bg-[#2a2a2a] rounded-lg flex flex-col items-center justify-center",style:{width:`${X.width*pe}px`,height:`${(X.height??900)*pe}px`},children:ie?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:ie}),e.jsx("button",{onClick:Te,className:"mx-auto px-4 py-2 bg-[#005c75] text-white text-sm font-medium rounded hover:bg-[#004d63] transition-colors cursor-pointer",children:"Retry"})]}):ae||Be?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mb-4",children:e.jsx(Ct,{})}),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:Be?"Starting Interactive Mode":"Starting Dev Server"}),e.jsx("p",{className:"text-sm text-gray-400 leading-5 m-0 font-['IBM_Plex_Sans']",children:Be?"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(Es,{})]})});export{Gn as default,Jn as meta,Hn as shouldRevalidate};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/addon-web-links-74hnHF59.js","assets/chunk-JZWAC4HX-BBXArFPl.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var ye=Object.defineProperty;var ge=(r,e,o)=>e in r?ye(r,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):r[e]=o;var U=(r,e,o)=>ge(r,typeof e!="symbol"?e+"":e,o);import{j as u}from"./jsx-runtime-D_zvdyIk.js";import{r as d}from"./chunk-JZWAC4HX-BBXArFPl.js";import{_ as P}from"./preload-helper-ckwbz45p.js";const z={sound:"soft-double-tap",systemNotification:!0},we=[{id:"soft-double-tap",label:"Soft double tap"},{id:"gentle-chime",label:"Gentle chime"},{id:"warm-ding",label:"Warm ding"},{id:"mellow-two-tone",label:"Mellow two-tone"},{id:"triangle-bell",label:"Triangle bell"},{id:"off",label:"No sound"}],ce="codeyam-editor-notifications";function Re(){try{const r=localStorage.getItem(ce);if(!r)return z;const e=JSON.parse(r);return typeof e=="string"?e==="true"?z:{...z,sound:"off",systemNotification:!1}:{...z,...e}}catch{return z}}function je(r){localStorage.setItem(ce,JSON.stringify(r))}function ae(r){var e;if(r!=="off")try{const o=new AudioContext,a={"soft-double-tap":t=>{[0,.12].forEach(n=>{const i=t.createOscillator(),g=t.createGain();i.connect(g),g.connect(t.destination),i.type="sine",i.frequency.value=392,g.gain.setValueAtTime(.25,t.currentTime+n),g.gain.exponentialRampToValueAtTime(.01,t.currentTime+n+.1),i.start(t.currentTime+n),i.stop(t.currentTime+n+.1)})},"gentle-chime":t=>{const n=t.createOscillator(),i=t.createGain();n.connect(i),i.connect(t.destination),n.type="sine",n.frequency.setValueAtTime(523,t.currentTime),n.frequency.setValueAtTime(659,t.currentTime+.15),i.gain.setValueAtTime(.3,t.currentTime),i.gain.exponentialRampToValueAtTime(.01,t.currentTime+.4),n.start(),n.stop(t.currentTime+.4)},"warm-ding":t=>{const n=t.createOscillator(),i=t.createGain();n.connect(i),i.connect(t.destination),n.type="sine",n.frequency.value=330,i.gain.setValueAtTime(.35,t.currentTime),i.gain.exponentialRampToValueAtTime(.01,t.currentTime+.6),n.start(),n.stop(t.currentTime+.6)},"mellow-two-tone":t=>{const n=t.createOscillator(),i=t.createGain();n.connect(i),i.connect(t.destination),n.type="sine",n.frequency.setValueAtTime(294,t.currentTime),n.frequency.setValueAtTime(440,t.currentTime+.18),i.gain.setValueAtTime(.3,t.currentTime),i.gain.exponentialRampToValueAtTime(.01,t.currentTime+.5),n.start(),n.stop(t.currentTime+.5)},"triangle-bell":t=>{const n=t.createOscillator(),i=t.createGain();n.connect(i),i.connect(t.destination),n.type="triangle",n.frequency.value=523,i.gain.setValueAtTime(.4,t.currentTime),i.gain.exponentialRampToValueAtTime(.01,t.currentTime+.8),n.start(),n.stop(t.currentTime+.8)}};(e=a[r])==null||e.call(a,o)}catch{}}function Be({serverUrl:r,isStarting:e,projectSlug:o,devServerError:a,onStartServer:t,notificationSettings:n,onChangeNotificationSettings:i}){const[g,S]=d.useState(null),[p,w]=d.useState(!1),E=d.useRef(null),A=d.useRef(null);d.useEffect(()=>{if(!o)return;const h=new EventSource("/api/dev-mode-events");return h.onmessage=_=>{try{const B=JSON.parse(_.data);B.type==="file-synced"&&(S(B.fileName),A.current&&clearTimeout(A.current),A.current=setTimeout(()=>{S(null)},5e3))}catch{}},()=>{h.close(),A.current&&clearTimeout(A.current)}},[o]),d.useEffect(()=>{if(!p)return;function h(_){E.current&&!E.current.contains(_.target)&&w(!1)}return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[p]);let N;a?N="error":e?N="starting":r?N="running":N="stopped";const V={starting:"bg-yellow-400",running:"bg-green-400",stopped:"bg-gray-400",error:"bg-red-400"},I={starting:"Starting...",running:r||"Running",stopped:"Stopped",error:"Error"},R=n&&(n.sound!=="off"||n.systemNotification);return u.jsxs("div",{className:"bg-[#1e1e1e] border-t border-[#3d3d3d] h-7 flex items-center px-4 gap-4 shrink-0 text-xs font-mono",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("div",{className:`w-2 h-2 rounded-full ${V[N]}`}),u.jsxs("span",{className:"text-gray-400",children:["Server:"," ",u.jsx("span",{className:"text-gray-300",children:I[N]})]}),(N==="stopped"||N==="error")&&t&&u.jsx("button",{onClick:t,className:"ml-1 px-2.5 py-0.5 bg-[#005c75] hover:bg-[#007a9a] text-white text-[11px] font-medium rounded transition-colors cursor-pointer border-none leading-tight",children:"Start Server"})]}),u.jsx("div",{className:"w-px h-3 bg-[#3d3d3d]"}),g&&u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"#4ade80",strokeWidth:"2",children:u.jsx("path",{d:"M20 6L9 17l-5-5"})}),u.jsxs("span",{className:"text-green-400",children:["Synced: ",g]})]}),u.jsx("div",{className:"w-px h-3 bg-[#3d3d3d]"})]}),u.jsx("div",{className:"flex-1"}),i&&n&&u.jsxs("div",{className:"relative",ref:E,children:[u.jsx("button",{onClick:()=>w(!p),className:`text-[11px] rounded transition-colors cursor-pointer ${R?"text-green-400 hover:text-green-300":"text-gray-500 hover:text-gray-300"}`,children:R?"Notifications On":"Notifications Off"}),p&&u.jsxs("div",{className:"absolute bottom-full right-0 mb-2 w-56 bg-[#2d2d2d] border border-[#4d4d4d] rounded-lg shadow-xl p-3 flex flex-col gap-3 z-50",children:[u.jsxs("div",{children:[u.jsx("div",{className:"text-[11px] text-gray-400 mb-1.5",children:"Notification sound"}),u.jsx("div",{className:"flex flex-col gap-0.5",children:we.map(h=>u.jsx("button",{onClick:()=>{i({...n,sound:h.id}),h.id!=="off"&&ae(h.id)},className:`text-left text-[11px] px-2 py-1 rounded cursor-pointer transition-colors ${n.sound===h.id?"bg-[#444] text-white":"text-gray-300 hover:bg-[#3a3a3a]"}`,children:h.label},h.id))})]}),u.jsxs("div",{className:"border-t border-[#4d4d4d] pt-2",children:[u.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[u.jsx("input",{type:"checkbox",checked:n.systemNotification,onChange:h=>{const _=h.target.checked;i({...n,systemNotification:_}),_&&typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission()},className:"accent-green-500"}),u.jsx("span",{className:"text-[11px] text-gray-300",children:"System notification"})]}),u.jsx("div",{className:"text-[10px] text-gray-500 mt-1 ml-5",children:"Shows when tab is not visible"})]})]})]})]})}async function ve(r,e){try{const{WebglAddon:a}=await P(async()=>{const{WebglAddon:n}=await import("./addon-webgl-DI8QOUvO.js").then(i=>i.a);return{WebglAddon:n}},[]),t=new a;return t.onContextLoss(()=>{e==null||e("webgl","canvas",new Error("WebGL context lost")),t.dispose(),se(r).then(n=>{n||e==null||e("canvas","dom",new Error("Canvas fallback failed after context loss"))})}),r.loadAddon(t),{type:"webgl",dispose:()=>t.dispose()}}catch(a){e==null||e("webgl","canvas",a)}const o=await se(r);return o||(e==null||e("canvas","dom",new Error("Canvas addon failed")),{type:"dom",dispose:()=>{}})}async function se(r){try{const{CanvasAddon:e}=await P(async()=>{const{CanvasAddon:a}=await import("./addon-canvas-DpzMmAy5.js").then(t=>t.a);return{CanvasAddon:a}},[]),o=new e;return r.loadAddon(o),{type:"canvas",dispose:()=>o.dispose()}}catch{return null}}class be{constructor(e,o){U(this,"deferred",!1);U(this,"actions");U(this,"env");this.actions=e,this.env=o}onIdle(e,o){return o&&this.env.hasBrowserFocus()?(this.deferred=!0,"deferred"):(this.deferred=!1,this.notify(e))}onBuildTabChange(e,o){return!e&&this.deferred?(this.deferred=!1,this.notify(o),!0):!1}onActive(){this.deferred=!1}onUserEngagement(){const e=this.deferred;return this.deferred=!1,e}get isDeferred(){return this.deferred}notify(e){const o=!!(e!=null&&e.sound)&&e.sound!=="off";return o&&this.actions.playSound(e.sound),!this.env.hasBrowserFocus()&&(e!=null&&e.systemNotification)&&this.env.hasNotificationPermission()&&this.actions.showSystemNotification(),o?"played":"played-no-sound"}}const Te=`
|
|
3
|
+
.xterm { cursor: text; position: relative; user-select: none; -ms-user-select: none; -webkit-user-select: none; }
|
|
4
|
+
.xterm.focus, .xterm:focus { outline: none; }
|
|
5
|
+
.xterm .xterm-helpers { position: absolute; top: 0; z-index: 5; }
|
|
6
|
+
.xterm .xterm-helper-textarea { padding: 0; border: 0; margin: 0; position: absolute; opacity: 0; left: -9999em; top: 0; width: 0; height: 0; z-index: -5; white-space: nowrap; overflow: hidden; resize: none; caret-color: transparent !important; clip-path: inset(100%) !important; }
|
|
7
|
+
.xterm .composition-view { background: #000; color: #FFF; display: none; position: absolute; white-space: nowrap; z-index: 1; }
|
|
8
|
+
.xterm .composition-view.active { display: block; }
|
|
9
|
+
.xterm .xterm-viewport { background-color: #000; overflow-y: scroll; cursor: default; position: absolute; right: 0; left: 0; top: 0; bottom: 0; }
|
|
10
|
+
.xterm .xterm-screen { position: relative; }
|
|
11
|
+
.xterm .xterm-screen canvas { position: absolute; left: 0; top: 0; }
|
|
12
|
+
.xterm .xterm-scroll-area { visibility: hidden; }
|
|
13
|
+
.xterm-char-measure-element { display: inline-block; visibility: hidden; position: absolute; top: 0; left: -9999em; line-height: normal; }
|
|
14
|
+
.xterm.enable-mouse-events { cursor: default; }
|
|
15
|
+
.xterm.xterm-cursor-pointer, .xterm .xterm-cursor-pointer { cursor: pointer; }
|
|
16
|
+
.xterm.column-select.focus { cursor: crosshair; }
|
|
17
|
+
.xterm .xterm-accessibility:not(.debug), .xterm .xterm-message { position: absolute; left: 0; top: 0; bottom: 0; right: 0; z-index: 10; color: transparent; pointer-events: none; }
|
|
18
|
+
.xterm .xterm-accessibility-tree:not(.debug) *::selection { color: transparent; }
|
|
19
|
+
.xterm .xterm-accessibility-tree { user-select: text; white-space: pre; }
|
|
20
|
+
.xterm .live-region { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
|
|
21
|
+
.xterm-dim { opacity: 1 !important; }
|
|
22
|
+
.xterm-underline-1 { text-decoration: underline; }
|
|
23
|
+
.xterm-underline-2 { text-decoration: double underline; }
|
|
24
|
+
.xterm-underline-3 { text-decoration: wavy underline; }
|
|
25
|
+
.xterm-underline-4 { text-decoration: dotted underline; }
|
|
26
|
+
.xterm-underline-5 { text-decoration: dashed underline; }
|
|
27
|
+
.xterm-overline { text-decoration: overline; }
|
|
28
|
+
.xterm-strikethrough { text-decoration: line-through; }
|
|
29
|
+
.xterm-screen .xterm-decoration-container .xterm-decoration { z-index: 6; position: absolute; }
|
|
30
|
+
.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer { z-index: 7; }
|
|
31
|
+
.xterm-decoration-overview-ruler { z-index: 8; position: absolute; top: 0; right: 0; pointer-events: none; }
|
|
32
|
+
.xterm-decoration-top { z-index: 2; position: relative; }
|
|
33
|
+
`;function Ne(){let r=document.getElementById("xterm-css");r||(r=document.createElement("style"),r.id="xterm-css",document.head.appendChild(r)),r.textContent=Te}const Le=d.forwardRef(function({entityName:e,entityType:o,entitySha:a,entityFilePath:t,scenarioName:n,scenarioDescription:i,analysisId:g,projectSlug:S,onRefreshPreview:p,onShowResults:w,onHideResults:E,onSetViewport:A,editorMode:N,onIdleChange:V,notificationSettings:I,buildTabActive:R,claudeStartMode:h,claudeSessionId:_,onDataMutationForwarded:B,resultsOpen:Q},le){const G=d.useRef(null),k=d.useRef(null),$=d.useRef(null),j=d.useRef(null),q=d.useRef(null),H=d.useRef(!1),M=d.useRef(0),K=d.useRef(!1),v=d.useRef(V);v.current=V;const X=d.useRef(I);X.current=I;const F=d.useRef(R);F.current=R;const ee=d.useRef(Q);ee.current=Q;const O=d.useRef(null),L=d.useRef(null);L.current||(L.current=new be({playSound:c=>ae(c),showSystemNotification:()=>{O.current&&O.current.close();const c=new Notification("Claude is ready for you",{body:"Claude has finished and is waiting for your input.",tag:"claude-idle"});c.onclick=()=>{window.focus(),c.close()},O.current=c}},{hasBrowserFocus:()=>document.hasFocus(),hasNotificationPermission:()=>typeof Notification<"u"&&Notification.permission==="granted"}));function ue(){O.current&&(O.current.close(),O.current=null)}function Y(){var c,x;ue(),(c=v.current)==null||c.call(v,!1),(x=L.current)==null||x.onUserEngagement()}d.useEffect(()=>{function c(){Y()}function x(){document.hidden||Y()}return window.addEventListener("focus",c),document.addEventListener("visibilitychange",x),()=>{window.removeEventListener("focus",c),document.removeEventListener("visibilitychange",x)}},[]),d.useEffect(()=>{var c;(c=L.current)==null||c.onBuildTabChange(!!R,X.current)},[R]);const de=d.useCallback(()=>{var c;(c=$.current)==null||c.focus()},[]);return d.useImperativeHandle(le,()=>({sendInput(c){const x=j.current;x&&x.readyState===WebSocket.OPEN&&(x.send(JSON.stringify({type:"input",data:c})),setTimeout(()=>{x.readyState===WebSocket.OPEN&&x.send(JSON.stringify({type:"input",data:"\r"}))},100))},focus(){var c;(c=$.current)==null||c.focus()},scrollToBottom(){var x;const c=(x=G.current)==null?void 0:x.querySelector(".xterm-viewport");c&&(c.scrollTop=c.scrollHeight)}})),d.useEffect(()=>{const c=G.current;if(!c)return;let x=!1;return Ne(),Promise.all([P(()=>import("./xterm-BqvuqXEL.js"),[]),P(()=>import("./addon-fit-YJmn1quW.js"),[]),P(()=>import("./addon-web-links-74hnHF59.js").then(W=>W.a),__vite__mapDeps([0,1]))]).then(([W,fe,me])=>{if(x)return;const f=new W.Terminal({cursorBlink:!1,cursorInactiveStyle:"none",scrollback:5e3,fontSize:13,fontFamily:"'IBM Plex Mono', 'Menlo', 'Monaco', monospace",theme:{background:"#1e1e1e",foreground:"#d4d4d4",cursor:"#1e1e1e",selectionBackground:"#264f78"},linkHandler:{activate(l,s){try{const m=new URL(s),b=m.searchParams.get("scenario");if(b&&m.pathname.startsWith("/editor")){const T=new BroadcastChannel("codeyam-editor");T.postMessage({type:"switch-scenario",scenarioId:b}),T.close();return}}catch{}window.open(s,"_blank")}}}),D=new fe.FitAddon;f.loadAddon(D),f.loadAddon(new me.WebLinksAddon),f.open(c),f.attachCustomKeyEventHandler(l=>{if(ee.current&&(l.key==="ArrowLeft"||l.key==="ArrowRight")&&!l.ctrlKey&&!l.altKey&&!l.metaKey&&l.type==="keydown"){const s=l.key==="ArrowLeft"?"\x1B[D":"\x1B[C",m=j.current;return m&&m.readyState===WebSocket.OPEN&&m.send(JSON.stringify({type:"input",data:s})),!1}return!0}),f.write("\x1B[?25l");let J=null;ve(f,(l,s,m)=>{console.warn(`[Terminal] Renderer fallback: ${l} → ${s}`,m)}).then(l=>{if(x){l.dispose();return}console.log(`[Terminal] Using ${l.type} renderer`),J=l.dispose}),requestAnimationFrame(()=>{try{D.fit()}catch{}}),$.current=f,f.focus(),setTimeout(()=>f.focus(),100),setTimeout(()=>f.focus(),500);const pe=window.location.protocol==="https:"?"wss:":"ws:",xe=window.location.host;function he(l){const s=new URLSearchParams;return s.set("entityName",e),o&&s.set("entityType",o),a&&s.set("entitySha",a),t&&s.set("entityFilePath",t),n&&s.set("scenarioName",n),i&&s.set("scenarioDescription",i),g&&s.set("analysisId",g),S&&s.set("projectSlug",S),N&&s.set("editorMode","true"),l&&s.set("reconnectId",l),h&&s.set("claudeStartMode",h),_&&s.set("claudeSessionId",_),`${pe}//${xe}/ws/terminal?${s.toString()}`}function Z(l){const s=he(l),m=new WebSocket(s);j.current=m,m.onopen=()=>{M.current=0,K.current=!1,m.send(JSON.stringify({type:"resize",cols:f.cols,rows:f.rows}))},m.onmessage=b=>{var T,re,ne,oe,ie;try{const y=JSON.parse(b.data);if(y.type==="session-id"){q.current=y.sessionId;return}if(y.type==="refresh-preview"){p==null||p(y.path,y.scenarioId);return}if(y.type==="show-results"){w==null||w();return}if(y.type==="hide-results"){E==null||E();return}if(y.type==="data-mutation-forwarded"){B==null||B();return}if(y.type==="set-viewport"){A==null||A({name:y.name,width:y.width,height:y.height});return}if(y.type==="claude-idle"){(T=v.current)==null||T.call(v,!0),(re=L.current)==null||re.onIdle(X.current,F.current??!1);return}if(y.type==="claude-active"){(ne=v.current)==null||ne.call(v,!1),(oe=L.current)==null||oe.onActive(),O.current&&(O.current.close(),O.current=null);return}y.type==="output"&&(f.write(y.data),(ie=v.current)==null||ie.call(v,!1))}catch{f.write(b.data)}},m.onclose=()=>{if(H.current){f.write(`\r
|
|
34
|
+
\x1B[90m[Terminal session ended]\x1B[0m\r
|
|
35
|
+
`);return}const b=M.current;if(b<5&&q.current){const T=1e3*Math.pow(2,Math.min(b,3));M.current=b+1,f.write(`\r
|
|
36
|
+
\x1B[33m[Reconnecting...]\x1B[0m\r
|
|
37
|
+
`),setTimeout(()=>{H.current||Z(q.current)},T)}else K.current?f.write(`\r
|
|
38
|
+
\x1B[90m[Terminal session ended]\x1B[0m\r
|
|
39
|
+
`):(K.current=!0,f.write(`\r
|
|
40
|
+
\x1B[33m[Starting new session...]\x1B[0m\r
|
|
41
|
+
`),q.current=null,M.current=0,Z())},m.onerror=()=>{}}Z(),f.onData(l=>{const s=j.current;s&&s.readyState===WebSocket.OPEN&&s.send(JSON.stringify({type:"input",data:l})),Y()});let C=null;const te=new ResizeObserver(()=>{C&&clearTimeout(C),C=setTimeout(()=>{let l;try{l=D.proposeDimensions()}catch{return}if(!l||l.cols===f.cols&&l.rows===f.rows)return;const s=c.querySelector(".xterm-viewport");let m,b=!0;s&&(m=s.scrollTop,b=s.scrollTop+s.clientHeight>=s.scrollHeight-10),D.fit(),s&&m!==void 0&&(b?s.scrollTop=s.scrollHeight:s.scrollTop=m);const T=j.current;T&&T.readyState===WebSocket.OPEN&&T.send(JSON.stringify({type:"resize",cols:f.cols,rows:f.rows}))},150)});te.observe(c),k.current=()=>{var l;C&&clearTimeout(C),te.disconnect(),H.current=!0,(l=j.current)==null||l.close(),j.current=null,J==null||J(),f.dispose(),$.current=null}}),()=>{var W;x=!0,(W=k.current)==null||W.call(k),k.current=null}},[]),u.jsx("div",{ref:G,onClick:de,className:"w-full h-full relative overflow-hidden",style:{padding:"4px 0 0 8px"}})});function Se(r){return r.replace(/[^a-zA-Z0-9_]+/g,"_")}function We(r){const{activeAnalyzedScenario:e,analyzedPreviewUrl:o,activeScenarioId:a,scenarios:t,proxyUrl:n,devServerUrl:i,zoomComponent:g}=r;if(e&&o)return o;if(e&&!o)return null;if(a){const p=t.find(w=>w.id===a);if(p!=null&&p.url){const w=n||i;return w?p.url.startsWith("/")?`${w}${p.url}`:p.url:null}}const S=n||i;if(!S)return null;if(g&&a){const p=t.find(E=>E.id===a),w=p?Se(p.name):"Default";return`${S}/__codeyam__/${g}/${w}`}return S}function ke(r,e){if(!r||!e)return r;try{const o=new URL(r),a=e.indexOf("?");return a>=0?(o.pathname=e.slice(0,a),o.search=e.slice(a)):(o.pathname=e,o.search=""),o.href}catch{return r}}function Ce(r,e){return r?r!==e:!1}function ze(r){if(r.length!==0)return r.find(e=>e.type==="application")||r[0]}function Pe(r,e,o){if(!r.viewportWidth||!r.viewportHeight)return o??null;const a=e.find(t=>t.width===r.viewportWidth&&t.height===r.viewportHeight);return{name:(a==null?void 0:a.name)||"Custom",width:r.viewportWidth,height:r.viewportHeight}}function Ve(r,e){const o=e.width,a=e.height??900,t=r.width,n=r.height;return o<=t&&a<=n?1:Math.min(t/o,n/a)}export{Be as D,Le as T,ke as a,Se as b,z as c,je as d,Ve as e,We as f,ze as g,Re as l,Pe as r,Ce as s};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as V,w as re,u as oe,r as i}from"./chunk-JZWAC4HX-BBXArFPl.js";import{j as e}from"./jsx-runtime-D_zvdyIk.js";import{u as le,S as W}from"./Spinner-Df3UCi8k.js";import{u as ce}from"./useLastLogLine-BxxP_XF9.js";import{V as de}from"./ViewportInspectBar-DRKR9T0U.js";import{u as he,S as xe}from"./useCustomSizes-BR3Rs7JY.js";import{c as me}from"./cy-logo-cli-DcX-ZS3p.js";import{I as E}from"./InlineSpinner-DuYodzo1.js";import{a as ue,T as pe,D as ge}from"./editorPreview-
|
|
1
|
+
import{a as V,w as re,u as oe,r as i}from"./chunk-JZWAC4HX-BBXArFPl.js";import{j as e}from"./jsx-runtime-D_zvdyIk.js";import{u as le,S as W}from"./Spinner-Df3UCi8k.js";import{u as ce}from"./useLastLogLine-BxxP_XF9.js";import{V as de}from"./ViewportInspectBar-DRKR9T0U.js";import{u as he,S as xe}from"./useCustomSizes-BR3Rs7JY.js";import{c as me}from"./cy-logo-cli-DcX-ZS3p.js";import{I as E}from"./InlineSpinner-DuYodzo1.js";import{a as ue,T as pe,D as ge}from"./editorPreview-DggyRwOr.js";import{S as fe}from"./SafeScreenshot-CDoF7ZpU.js";import"./preload-helper-ckwbz45p.js";function ve({scenarios:w,currentScenarioId:r,entitySha:s,cacheBuster:l}){const c=V();return w.length===0?e.jsx("div",{className:"flex-1 flex items-center justify-center p-8",children:e.jsx("p",{className:"text-gray-500 text-sm",children:"No scenarios found"})}):e.jsx("div",{className:"flex-1 overflow-y-auto p-3 space-y-3",children:w.map(o=>{var j,u;const g=o.id===r,f=(u=(j=o.metadata)==null?void 0:j.screenshotPaths)==null?void 0:u[0];return e.jsxs("button",{onClick:()=>{c(`/entity/${s}/scenarios/${o.id}/dev`)},className:`w-full text-left rounded-lg overflow-hidden border transition-colors cursor-pointer flex ${g?"border-[#005c75] bg-[#1a3a44]":"border-[#3d3d3d] bg-[#252525] hover:border-[#555]"}`,children:[e.jsx("div",{className:"w-24 h-20 shrink-0 bg-[#1a1a1a]",children:e.jsx(fe,{screenshotPath:f,cacheBuster:l,alt:o.name,className:"w-full h-full object-cover object-top"})}),e.jsxs("div",{className:"p-2.5 min-w-0 flex-1",children:[e.jsxs("div",{className:"text-white text-sm font-medium truncate",children:[g&&e.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-[#005c75] mr-1.5 relative top-[-1px]"}),o.name]}),o.description&&e.jsx("div",{className:"text-gray-400 text-xs mt-1 line-clamp-2",children:o.description})]})]},o.id)})})}const I=[{name:"Mobile",width:375,height:667},{name:"Tablet",width:768,height:1024},{name:"Laptop",width:1024,height:768},{name:"Desktop",width:1440,height:900}],De=re(function(){const{entity:r,scenario:s,analysis:l,projectSlug:c}=oe(),o=V(),g=i.useRef(null),f=i.useRef(null),[j,u]=i.useState(null),[A,M]=i.useState(1440),[n,N]=i.useState({name:"Desktop",width:1440,height:900}),[H,y]=i.useState(!1),[S,U]=i.useState(null),[d,k]=i.useState("chat"),[F,q]=i.useState(0),[D,$]=i.useState(null),K=i.useCallback(t=>{$(t||null),q(a=>a+1)},[]),{customSizes:_,addCustomSize:Y}=he(c),v=i.useMemo(()=>[...I,..._],[_]),{interactiveServerUrl:h,isStarting:C,isLoading:z,showIframe:B,iframeKey:G,onIframeLoad:J}=le({analysisId:l==null?void 0:l.id,scenarioId:s==null?void 0:s.id,scenarioName:s==null?void 0:s.name,projectSlug:c,enabled:!0,refreshTrigger:F}),O=i.useMemo(()=>ue(h,D),[h,D]),{lastLine:b}=ce(c,C||z),Q=()=>{o(`/entity/${r.sha}`)},X=(t,a)=>{M(t);const m=v.find(T=>T.width===t&&T.height===a);u(m||null),N({name:(m==null?void 0:m.name)||"Custom",width:t,height:a})},R=t=>{u(t),M(t.width),N({name:t.name,width:t.width,height:t.height})},Z=t=>{Y(t,n.width,n.height??900),y(!1),N(a=>({...a,name:t}))},ee=()=>{var a;k("chat"),(a=f.current)==null||a.sendInput("Create a new scenario for this entity based on the work we've just done. Create a name and description that reflects what the live preview is showing. Use the scenario data you've changed to create a new scenario in the database. If the data structure was fixed in any way you need to update that in the database as well and backfill all existing scenarios, then save to the database and capture a screenshot. Remember the database is at `.codeyam/db.sqlite3`, the scenarios table has all scenarios and the analyses table contains the scenariosDataStructure is its metadata.")},x=((l==null?void 0:l.scenarios)||[]).filter(t=>{var a;return!((a=t.metadata)!=null&&a.sameAsDefault)}),p=x.findIndex(t=>t.id===(s==null?void 0:s.id)),te=p+1,se=x.length,L=p>0,P=p<x.length-1,ae=()=>{if(L){const t=x[p-1];o(`/entity/${r.sha}/scenarios/${t.id}/dev`)}},ne=()=>{if(P){const t=x[p+1];o(`/entity/${r.sha}/scenarios/${t.id}/dev`)}},ie=C||z||!B;return e.jsxs("div",{className:"fixed inset-0 bg-[#2d2d2d] flex flex-col",children:[e.jsxs("div",{className:"bg-[#3d3d3d] h-12 flex items-center px-4 gap-4 shrink-0 z-20",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[e.jsx("img",{src:me,alt:"CodeYam",className:"h-6 brightness-0 invert"}),e.jsx("span",{className:"text-white font-medium text-sm whitespace-nowrap",children:r.name}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx("button",{onClick:ae,disabled:!L,className:`${L?"text-white hover:text-gray-300":"text-gray-600 cursor-not-allowed"} transition-colors`,"aria-label":"Previous scenario",children:e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:e.jsx("path",{d:"M12.5 15L7.5 10L12.5 5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}),e.jsxs("span",{className:"text-gray-400 text-sm",children:[te,"/",se]}),e.jsx("button",{onClick:ne,disabled:!P,className:`${P?"text-white hover:text-gray-300":"text-gray-600 cursor-not-allowed"} transition-colors`,"aria-label":"Next scenario",children:e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:e.jsx("path",{d:"M7.5 15L12.5 10L7.5 5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-2 min-w-0",children:[e.jsx("span",{className:"text-white font-semibold text-xs whitespace-nowrap shrink-0",children:s==null?void 0:s.name}),(s==null?void 0:s.description)&&e.jsxs("div",{className:"relative group min-w-0",children:[e.jsx("span",{className:"text-gray-400 text-xs truncate block",children:s.description}),e.jsx("div",{className:"absolute left-0 top-full mt-1 hidden group-hover:block z-50 bg-black text-white text-xs px-3 py-2 rounded shadow-lg max-w-md",children:s.description})]})]}),e.jsx("span",{className:"bg-[#005c75] text-white text-[10px] font-bold px-2 py-0.5 rounded uppercase tracking-wider ml-2",children:"Dev Mode"})]}),e.jsx("button",{onClick:Q,className:"text-white hover:text-gray-300 transition-colors ml-4","aria-label":"Close dev mode",children:e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:e.jsx("path",{d:"M15 5L5 15M5 5L15 15",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})})]}),e.jsxs("div",{className:"flex-1 flex min-h-0",children:[e.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[e.jsxs("div",{className:"bg-[#e5e7eb] border-b border-[rgba(0,0,0,0.1)] shrink-0 z-10 h-6 flex items-center justify-center relative",children:[e.jsx("div",{className:"absolute inset-0 flex justify-center",children:e.jsx("div",{style:{maxWidth:`${I[I.length-1].width}px`,width:"100%"},children:e.jsx(de,{currentViewportWidth:A,currentPresetName:n.name,onDevicePresetClick:R,devicePresets:v,hideLabel:!0,onHoverChange:U,lightMode:!0})})}),e.jsxs("div",{className:"relative z-10 flex items-center gap-2",children:[e.jsxs("div",{className:"relative w-28 h-5",children:[e.jsxs("div",{className:"absolute inset-0 bg-white text-gray-900 text-xs px-2 rounded flex items-center justify-between pointer-events-none border border-gray-300",children:[e.jsx("span",{className:"leading-none",children:(S==null?void 0:S.name)||n.name}),e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 12 12",fill:"none",className:"shrink-0",children:e.jsx("path",{d:"M3 4.5L6 7.5L9 4.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),e.jsxs("select",{value:n.name,onChange:t=>{const a=v.find(m=>m.name===t.target.value);a&&R(a)},className:"relative w-full h-full opacity-0 cursor-pointer",children:[v.map(t=>e.jsx("option",{value:t.name,children:t.name},t.name)),n.name==="Custom"&&e.jsx("option",{value:"Custom",children:"Custom"})]})]}),e.jsx("input",{type:"number",value:n.width,onChange:t=>{const a=parseInt(t.target.value,10);!isNaN(a)&&a>0&&X(a,n.height??900)},className:"bg-white text-gray-900 text-xs px-1 rounded border border-gray-300 outline-none w-16 text-center h-5 leading-none",min:"200",max:"3840"}),e.jsx("span",{className:"text-gray-400 text-xs h-5 flex items-center leading-none",children:"x"}),e.jsx("span",{className:"bg-gray-100 text-gray-600 text-xs px-1 rounded w-14 text-center h-5 flex items-center justify-center leading-none",children:n.height??900}),n.name==="Custom"&&e.jsx("button",{onClick:()=>y(!0),className:"bg-white text-gray-900 text-xs px-2 rounded h-5 flex items-center leading-none border border-gray-300 hover:bg-gray-50 transition-colors",children:"Save"})]})]}),e.jsx("div",{className:"flex-1 flex items-center justify-center overflow-auto p-8",style:{backgroundImage:`
|
|
2
2
|
linear-gradient(45deg, #ebebeb 25%, transparent 25%),
|
|
3
3
|
linear-gradient(-45deg, #ebebeb 25%, transparent 25%),
|
|
4
4
|
linear-gradient(45deg, transparent 75%, #ebebeb 75%),
|