@codeyam/codeyam-cli 0.1.21 → 0.1.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/analyzer-template/.build-info.json +7 -7
  2. package/analyzer-template/log.txt +3 -3
  3. package/analyzer-template/packages/ai/src/lib/dataStructure/ScopeDataStructure.ts +31 -8
  4. package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/ParentScopeManager.ts +10 -3
  5. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.ts +16 -6
  6. package/analyzer-template/packages/analyze/index.ts +4 -1
  7. package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.ts +28 -2
  8. package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities.ts +5 -36
  9. package/analyzer-template/packages/analyze/src/lib/files/analyze/trackEntityCircularDependencies.ts +21 -0
  10. package/analyzer-template/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.ts +82 -10
  11. package/analyzer-template/packages/analyze/src/lib/files/analyzeNextRoute.ts +8 -3
  12. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateDataStructure.ts +235 -58
  13. package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.ts +170 -26
  14. package/codeyam-cli/src/commands/__tests__/editor.auditNoAutoAnalysis.test.js +63 -0
  15. package/codeyam-cli/src/commands/__tests__/editor.auditNoAutoAnalysis.test.js.map +1 -0
  16. package/codeyam-cli/src/commands/editor.js +412 -78
  17. package/codeyam-cli/src/commands/editor.js.map +1 -1
  18. package/codeyam-cli/src/utils/__tests__/editorAudit.test.js +354 -1
  19. package/codeyam-cli/src/utils/__tests__/editorAudit.test.js.map +1 -1
  20. package/codeyam-cli/src/utils/__tests__/editorPreview.test.js +11 -3
  21. package/codeyam-cli/src/utils/__tests__/editorPreview.test.js.map +1 -1
  22. package/codeyam-cli/src/utils/__tests__/entityChangeStatus.test.js +33 -1
  23. package/codeyam-cli/src/utils/__tests__/entityChangeStatus.test.js.map +1 -1
  24. package/codeyam-cli/src/utils/__tests__/manualEntityAnalysis.test.js +302 -0
  25. package/codeyam-cli/src/utils/__tests__/manualEntityAnalysis.test.js.map +1 -0
  26. package/codeyam-cli/src/utils/__tests__/testRunner.test.js +217 -0
  27. package/codeyam-cli/src/utils/__tests__/testRunner.test.js.map +1 -0
  28. package/codeyam-cli/src/utils/analysisRunner.js +28 -1
  29. package/codeyam-cli/src/utils/analysisRunner.js.map +1 -1
  30. package/codeyam-cli/src/utils/analyzer.js +4 -2
  31. package/codeyam-cli/src/utils/analyzer.js.map +1 -1
  32. package/codeyam-cli/src/utils/editorAudit.js +98 -3
  33. package/codeyam-cli/src/utils/editorAudit.js.map +1 -1
  34. package/codeyam-cli/src/utils/editorPreview.js +5 -3
  35. package/codeyam-cli/src/utils/editorPreview.js.map +1 -1
  36. package/codeyam-cli/src/utils/entityChangeStatus.server.js +16 -0
  37. package/codeyam-cli/src/utils/entityChangeStatus.server.js.map +1 -1
  38. package/codeyam-cli/src/utils/manualEntityAnalysis.js +196 -0
  39. package/codeyam-cli/src/utils/manualEntityAnalysis.js.map +1 -0
  40. package/codeyam-cli/src/utils/queue/job.js +20 -2
  41. package/codeyam-cli/src/utils/queue/job.js.map +1 -1
  42. package/codeyam-cli/src/utils/testRunner.js +199 -1
  43. package/codeyam-cli/src/utils/testRunner.js.map +1 -1
  44. package/codeyam-cli/src/webserver/__tests__/idleDetector.test.js +35 -0
  45. package/codeyam-cli/src/webserver/__tests__/idleDetector.test.js.map +1 -1
  46. package/codeyam-cli/src/webserver/build/client/assets/MiniClaudeChat-CQENLSrF.js +36 -0
  47. package/codeyam-cli/src/webserver/build/client/assets/cy-logo-cli-Coe5NhbS.js +1 -0
  48. package/codeyam-cli/src/webserver/build/client/assets/{cy-logo-cli-CJzc4vOH.svg → cy-logo-cli-DoA97ML3.svg} +2 -2
  49. package/codeyam-cli/src/webserver/build/client/assets/editor.entity.(_sha)-aIHKLB-m.js +96 -0
  50. package/codeyam-cli/src/webserver/build/client/assets/{editorPreview-NTuLi4Xg.js → editorPreview-CluPkvXJ.js} +6 -6
  51. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha._-Blfy9UlN.js → entity._sha._-ByHz6rAQ.js} +13 -12
  52. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha.scenarios._scenarioId.dev-BA5L8bU-.js → entity._sha.scenarios._scenarioId.dev-CmLO432x.js} +1 -1
  53. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha.scenarios._scenarioId.fullscreen-D4dmRgvO.js → entity._sha.scenarios._scenarioId.fullscreen-Bz9sCUF_.js} +1 -1
  54. package/codeyam-cli/src/webserver/build/client/assets/globals-oyPmV37k.css +1 -0
  55. package/codeyam-cli/src/webserver/build/client/assets/{manifest-5025e428.js → manifest-bcbb3d49.js} +1 -1
  56. package/codeyam-cli/src/webserver/build/client/assets/{root-BCx1S8Z3.js → root-D2_tktnk.js} +6 -6
  57. package/codeyam-cli/src/webserver/build/server/assets/analysisRunner-DjF-soOH.js +16 -0
  58. package/codeyam-cli/src/webserver/build/server/assets/{index-C91yWWCI.js → index-nAvHGWbz.js} +1 -1
  59. package/codeyam-cli/src/webserver/build/server/assets/{init-Dkas-RUS.js → init-XhpIt-OT.js} +1 -1
  60. package/codeyam-cli/src/webserver/build/server/assets/server-build-DVwiibFu.js +644 -0
  61. package/codeyam-cli/src/webserver/build/server/index.js +1 -1
  62. package/codeyam-cli/src/webserver/build-info.json +5 -5
  63. package/codeyam-cli/src/webserver/idleDetector.js +15 -0
  64. package/codeyam-cli/src/webserver/idleDetector.js.map +1 -1
  65. package/codeyam-cli/src/webserver/terminalServer.js +8 -2
  66. package/codeyam-cli/src/webserver/terminalServer.js.map +1 -1
  67. package/codeyam-cli/templates/skills/codeyam-editor/SKILL.md +2 -2
  68. package/package.json +1 -1
  69. package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js +23 -9
  70. package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js.map +1 -1
  71. package/packages/ai/src/lib/dataStructure/equivalencyManagers/ParentScopeManager.js +9 -2
  72. package/packages/ai/src/lib/dataStructure/equivalencyManagers/ParentScopeManager.js.map +1 -1
  73. package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js +14 -4
  74. package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js.map +1 -1
  75. package/packages/analyze/index.js +1 -1
  76. package/packages/analyze/index.js.map +1 -1
  77. package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js +16 -2
  78. package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js.map +1 -1
  79. package/packages/analyze/src/lib/files/analyze/analyzeEntities.js +6 -26
  80. package/packages/analyze/src/lib/files/analyze/analyzeEntities.js.map +1 -1
  81. package/packages/analyze/src/lib/files/analyze/trackEntityCircularDependencies.js +14 -0
  82. package/packages/analyze/src/lib/files/analyze/trackEntityCircularDependencies.js.map +1 -1
  83. package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js +44 -11
  84. package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js.map +1 -1
  85. package/packages/analyze/src/lib/files/analyzeNextRoute.js +5 -1
  86. package/packages/analyze/src/lib/files/analyzeNextRoute.js.map +1 -1
  87. package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js +116 -28
  88. package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js.map +1 -1
  89. package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js +139 -24
  90. package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js.map +1 -1
  91. package/codeyam-cli/src/webserver/build/client/assets/cy-logo-cli-DODLxLcw.js +0 -1
  92. package/codeyam-cli/src/webserver/build/client/assets/editor.entity.(_sha)-Dx-h1rJK.js +0 -130
  93. package/codeyam-cli/src/webserver/build/client/assets/globals-BrPXT1iR.css +0 -1
  94. package/codeyam-cli/src/webserver/build/server/assets/analysisRunner-C1kjC9UJ.js +0 -13
  95. package/codeyam-cli/src/webserver/build/server/assets/server-build-pulXLTrG.js +0 -640
@@ -1,5 +1,5 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/addon-web-links-CHx25PAe.js","assets/chunk-JZWAC4HX-BAdwhyCx.js"])))=>i.map(i=>d[i]);
2
- var ge=Object.defineProperty;var be=(r,e,s)=>e in r?ge(r,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):r[e]=s;var B=(r,e,s)=>be(r,typeof e!="symbol"?e+"":e,s);import{j as d}from"./jsx-runtime-D_zvdyIk.js";import{r as u}from"./chunk-JZWAC4HX-BAdwhyCx.js";import{_ as q}from"./preload-helper-ckwbz45p.js";const $={sound:"soft-double-tap",systemNotification:!0},Te=[{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"}],fe="codeyam-editor-notifications";function Ie(){try{const r=localStorage.getItem(fe);if(!r)return $;const e=JSON.parse(r);return typeof e=="string"?e==="true"?$:{...$,sound:"off",systemNotification:!1}:{...$,...e}}catch{return $}}function ke(r){localStorage.setItem(fe,JSON.stringify(r))}function me(r){var e;if(r!=="off")try{const s=new AudioContext,a={"soft-double-tap":t=>{[0,.12].forEach(n=>{const o=t.createOscillator(),v=t.createGain();o.connect(v),v.connect(t.destination),o.type="sine",o.frequency.value=392,v.gain.setValueAtTime(.25,t.currentTime+n),v.gain.exponentialRampToValueAtTime(.01,t.currentTime+n+.1),o.start(t.currentTime+n),o.stop(t.currentTime+n+.1)})},"gentle-chime":t=>{const n=t.createOscillator(),o=t.createGain();n.connect(o),o.connect(t.destination),n.type="sine",n.frequency.setValueAtTime(523,t.currentTime),n.frequency.setValueAtTime(659,t.currentTime+.15),o.gain.setValueAtTime(.3,t.currentTime),o.gain.exponentialRampToValueAtTime(.01,t.currentTime+.4),n.start(),n.stop(t.currentTime+.4)},"warm-ding":t=>{const n=t.createOscillator(),o=t.createGain();n.connect(o),o.connect(t.destination),n.type="sine",n.frequency.value=330,o.gain.setValueAtTime(.35,t.currentTime),o.gain.exponentialRampToValueAtTime(.01,t.currentTime+.6),n.start(),n.stop(t.currentTime+.6)},"mellow-two-tone":t=>{const n=t.createOscillator(),o=t.createGain();n.connect(o),o.connect(t.destination),n.type="sine",n.frequency.setValueAtTime(294,t.currentTime),n.frequency.setValueAtTime(440,t.currentTime+.18),o.gain.setValueAtTime(.3,t.currentTime),o.gain.exponentialRampToValueAtTime(.01,t.currentTime+.5),n.start(),n.stop(t.currentTime+.5)},"triangle-bell":t=>{const n=t.createOscillator(),o=t.createGain();n.connect(o),o.connect(t.destination),n.type="triangle",n.frequency.value=523,o.gain.setValueAtTime(.4,t.currentTime),o.gain.exponentialRampToValueAtTime(.01,t.currentTime+.8),n.start(),n.stop(t.currentTime+.8)}};(e=a[r])==null||e.call(a,s)}catch{}}function je({serverUrl:r,isStarting:e,projectSlug:s,devServerError:a,onStartServer:t,notificationSettings:n,onChangeNotificationSettings:o}){const[v,A]=u.useState(null),[x,w]=u.useState(!1),E=u.useRef(null),_=u.useRef(null);u.useEffect(()=>{if(!s)return;const p=new EventSource("/api/dev-mode-events");return p.onmessage=O=>{try{const z=JSON.parse(O.data);z.type==="file-synced"&&(A(z.fileName),_.current&&clearTimeout(_.current),_.current=setTimeout(()=>{A(null)},5e3))}catch{}},()=>{p.close(),_.current&&clearTimeout(_.current)}},[s]),u.useEffect(()=>{if(!x)return;function p(O){E.current&&!E.current.contains(O.target)&&w(!1)}return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[x]);let T;a?T="error":e?T="starting":r?T="running":T="stopped";const D={starting:"bg-yellow-400",running:"bg-green-400",stopped:"bg-gray-400",error:"bg-red-400"},H={starting:"Starting...",running:r||"Running",stopped:"Stopped",error:"Error"},W=n&&(n.sound!=="off"||n.systemNotification);return d.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:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("div",{className:`w-2 h-2 rounded-full ${D[T]}`}),d.jsxs("span",{className:"text-gray-400",children:["Server:"," ",d.jsx("span",{className:"text-gray-300",children:H[T]})]}),(T==="stopped"||T==="error")&&t&&d.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"})]}),d.jsx("div",{className:"w-px h-3 bg-[#3d3d3d]"}),v&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"flex items-center gap-1.5",children:[d.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"#4ade80",strokeWidth:"2",children:d.jsx("path",{d:"M20 6L9 17l-5-5"})}),d.jsxs("span",{className:"text-green-400",children:["Synced: ",v]})]}),d.jsx("div",{className:"w-px h-3 bg-[#3d3d3d]"})]}),d.jsx("div",{className:"flex-1"}),o&&n&&d.jsxs("div",{className:"relative",ref:E,children:[d.jsx("button",{onClick:()=>w(!x),className:`text-[11px] rounded transition-colors cursor-pointer ${W?"text-cygreen hover:text-cygreen/80":"text-gray-500 hover:text-gray-300"}`,children:W?"Notifications On":"Notifications Off"}),x&&d.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:[d.jsxs("div",{children:[d.jsx("div",{className:"text-[11px] text-gray-400 mb-1.5",children:"Notification sound"}),d.jsx("div",{className:"flex flex-col gap-0.5",children:Te.map(p=>d.jsx("button",{onClick:()=>{o({...n,sound:p.id}),p.id!=="off"&&me(p.id)},className:`text-left text-[11px] px-2 py-1 rounded cursor-pointer transition-colors ${n.sound===p.id?"bg-[#444] text-white":"text-gray-300 hover:bg-[#3a3a3a]"}`,children:p.label},p.id))})]}),d.jsxs("div",{className:"border-t border-[#4d4d4d] pt-2",children:[d.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[d.jsx("input",{type:"checkbox",checked:n.systemNotification,onChange:p=>{const O=p.target.checked;o({...n,systemNotification:O}),O&&typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission()},className:"accent-green-500"}),d.jsx("span",{className:"text-[11px] text-gray-300",children:"System notification"})]}),d.jsx("div",{className:"text-[10px] text-gray-500 mt-1 ml-5",children:"Shows when tab is not visible"})]})]})]})]})}async function Ne(r,e){try{const{WebglAddon:a}=await q(async()=>{const{WebglAddon:n}=await import("./addon-webgl-DI8QOUvO.js").then(o=>o.a);return{WebglAddon:n}},[]),t=new a;return t.onContextLoss(()=>{e==null||e("webgl","canvas",new Error("WebGL context lost")),t.dispose(),de(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 s=await de(r);return s||(e==null||e("canvas","dom",new Error("Canvas addon failed")),{type:"dom",dispose:()=>{}})}async function de(r){try{const{CanvasAddon:e}=await q(async()=>{const{CanvasAddon:a}=await import("./addon-canvas-DpzMmAy5.js").then(t=>t.a);return{CanvasAddon:a}},[]),s=new e;return r.loadAddon(s),{type:"canvas",dispose:()=>s.dispose()}}catch{return null}}class Se{constructor(e,s){B(this,"deferred",!1);B(this,"userActiveSinceLastOutput",!1);B(this,"actions");B(this,"env");this.actions=e,this.env=s}reportUserActivity(){this.userActiveSinceLastOutput=!0}resetActivityFlag(){this.userActiveSinceLastOutput=!1}onIdle(e,s){return this.deferred=!1,s&&this.env.hasBrowserFocus()&&this.userActiveSinceLastOutput?(this.userActiveSinceLastOutput=!1,"suppressed"):this.notify(e)}onBuildTabChange(e,s){return!e&&this.deferred?(this.deferred=!1,this.notify(s),!0):!1}onActive(){this.deferred=!1}onUserEngagement(){const e=this.deferred;return this.deferred=!1,e}get isDeferred(){return this.deferred}notify(e){const s=!!(e!=null&&e.sound)&&e.sound!=="off";return s&&this.actions.playSound(e.sound),!this.env.hasBrowserFocus()&&(e!=null&&e.systemNotification)&&this.env.hasNotificationPermission()&&this.actions.showSystemNotification(),s?"played":"played-no-sound"}}class Ae{constructor(e){B(this,"_isIdle",!1);B(this,"_isBuilding",!1);B(this,"callbacks");this.callbacks=e}get isIdle(){return this._isIdle}get isBuilding(){return this._isBuilding}handleClaudeIdle(e,s,a){e==null||e.onIdle(s,a),this._isIdle=!0,this._isBuilding=!1,this.callbacks.onIdleChange(!0),this.callbacks.onBuildingChange(!1)}handleClaudeActive(e){this._isIdle=!1,this._isBuilding=!0,this.callbacks.onIdleChange(!1),this.callbacks.onBuildingChange(!0),e==null||e.onActive(),e==null||e.resetActivityFlag(),this.callbacks.onCloseNotification()}handleOutput(e){this.callbacks.onIdleChange(!1),e==null||e.resetActivityFlag()}}const Ee=`
2
+ var we=Object.defineProperty;var be=(r,e,s)=>e in r?we(r,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):r[e]=s;var I=(r,e,s)=>be(r,typeof e!="symbol"?e+"":e,s);import{j as d}from"./jsx-runtime-D_zvdyIk.js";import{r as u}from"./chunk-JZWAC4HX-BAdwhyCx.js";import{_ as q}from"./preload-helper-ckwbz45p.js";const $={sound:"soft-double-tap",systemNotification:!0},Te=[{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"}],fe="codeyam-editor-notifications";function Le(){try{const r=localStorage.getItem(fe);if(!r)return $;const e=JSON.parse(r);return typeof e=="string"?e==="true"?$:{...$,sound:"off",systemNotification:!1}:{...$,...e}}catch{return $}}function ke(r){localStorage.setItem(fe,JSON.stringify(r))}function me(r){var e;if(r!=="off")try{const s=new AudioContext,l={"soft-double-tap":t=>{[0,.12].forEach(n=>{const o=t.createOscillator(),v=t.createGain();o.connect(v),v.connect(t.destination),o.type="sine",o.frequency.value=392,v.gain.setValueAtTime(.25,t.currentTime+n),v.gain.exponentialRampToValueAtTime(.01,t.currentTime+n+.1),o.start(t.currentTime+n),o.stop(t.currentTime+n+.1)})},"gentle-chime":t=>{const n=t.createOscillator(),o=t.createGain();n.connect(o),o.connect(t.destination),n.type="sine",n.frequency.setValueAtTime(523,t.currentTime),n.frequency.setValueAtTime(659,t.currentTime+.15),o.gain.setValueAtTime(.3,t.currentTime),o.gain.exponentialRampToValueAtTime(.01,t.currentTime+.4),n.start(),n.stop(t.currentTime+.4)},"warm-ding":t=>{const n=t.createOscillator(),o=t.createGain();n.connect(o),o.connect(t.destination),n.type="sine",n.frequency.value=330,o.gain.setValueAtTime(.35,t.currentTime),o.gain.exponentialRampToValueAtTime(.01,t.currentTime+.6),n.start(),n.stop(t.currentTime+.6)},"mellow-two-tone":t=>{const n=t.createOscillator(),o=t.createGain();n.connect(o),o.connect(t.destination),n.type="sine",n.frequency.setValueAtTime(294,t.currentTime),n.frequency.setValueAtTime(440,t.currentTime+.18),o.gain.setValueAtTime(.3,t.currentTime),o.gain.exponentialRampToValueAtTime(.01,t.currentTime+.5),n.start(),n.stop(t.currentTime+.5)},"triangle-bell":t=>{const n=t.createOscillator(),o=t.createGain();n.connect(o),o.connect(t.destination),n.type="triangle",n.frequency.value=523,o.gain.setValueAtTime(.4,t.currentTime),o.gain.exponentialRampToValueAtTime(.01,t.currentTime+.8),n.start(),n.stop(t.currentTime+.8)}};(e=l[r])==null||e.call(l,s)}catch{}}function je({serverUrl:r,isStarting:e,projectSlug:s,devServerError:l,onStartServer:t,notificationSettings:n,onChangeNotificationSettings:o}){const[v,A]=u.useState(null),[x,g]=u.useState(!1),_=u.useRef(null),E=u.useRef(null);u.useEffect(()=>{if(!s)return;const p=new EventSource("/api/dev-mode-events");return p.onmessage=O=>{try{const P=JSON.parse(O.data);P.type==="file-synced"&&(A(P.fileName),E.current&&clearTimeout(E.current),E.current=setTimeout(()=>{A(null)},5e3))}catch{}},()=>{p.close(),E.current&&clearTimeout(E.current)}},[s]),u.useEffect(()=>{if(!x)return;function p(O){_.current&&!_.current.contains(O.target)&&g(!1)}return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[x]);let T;l?T="error":e?T="starting":r?T="running":T="stopped";const D={starting:"bg-yellow-400",running:"bg-green-400",stopped:"bg-gray-400",error:"bg-red-400"},J={starting:"Starting...",running:r||"Running",stopped:"Stopped",error:"Error"},z=n&&(n.sound!=="off"||n.systemNotification);return d.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:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("div",{className:`w-2 h-2 rounded-full ${D[T]}`}),d.jsxs("span",{className:"text-gray-400",children:["Server:"," ",d.jsx("span",{className:"text-gray-300",children:J[T]})]}),(T==="stopped"||T==="error")&&t&&d.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"})]}),d.jsx("div",{className:"w-px h-3 bg-[#3d3d3d]"}),v&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"flex items-center gap-1.5",children:[d.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"#4ade80",strokeWidth:"2",children:d.jsx("path",{d:"M20 6L9 17l-5-5"})}),d.jsxs("span",{className:"text-green-400",children:["Synced: ",v]})]}),d.jsx("div",{className:"w-px h-3 bg-[#3d3d3d]"})]}),d.jsx("div",{className:"flex-1"}),o&&n&&d.jsxs("div",{className:"relative",ref:_,children:[d.jsx("button",{onClick:()=>g(!x),className:`text-[11px] rounded transition-colors cursor-pointer ${z?"text-cygreen hover:text-cygreen/80":"text-gray-500 hover:text-gray-300"}`,children:z?"Notifications On":"Notifications Off"}),x&&d.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:[d.jsxs("div",{children:[d.jsx("div",{className:"text-[11px] text-gray-400 mb-1.5",children:"Notification sound"}),d.jsx("div",{className:"flex flex-col gap-0.5",children:Te.map(p=>d.jsx("button",{onClick:()=>{o({...n,sound:p.id}),p.id!=="off"&&me(p.id)},className:`text-left text-[11px] px-2 py-1 rounded cursor-pointer transition-colors ${n.sound===p.id?"bg-[#444] text-white":"text-gray-300 hover:bg-[#3a3a3a]"}`,children:p.label},p.id))})]}),d.jsxs("div",{className:"border-t border-[#4d4d4d] pt-2",children:[d.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[d.jsx("input",{type:"checkbox",checked:n.systemNotification,onChange:p=>{const O=p.target.checked;o({...n,systemNotification:O}),O&&typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission()},className:"accent-green-500"}),d.jsx("span",{className:"text-[11px] text-gray-300",children:"System notification"})]}),d.jsx("div",{className:"text-[10px] text-gray-500 mt-1 ml-5",children:"Shows when tab is not visible"})]})]})]})]})}async function Ne(r,e){try{const{WebglAddon:l}=await q(async()=>{const{WebglAddon:n}=await import("./addon-webgl-DI8QOUvO.js").then(o=>o.a);return{WebglAddon:n}},[]),t=new l;return t.onContextLoss(()=>{e==null||e("webgl","canvas",new Error("WebGL context lost")),t.dispose(),de(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(l){e==null||e("webgl","canvas",l)}const s=await de(r);return s||(e==null||e("canvas","dom",new Error("Canvas addon failed")),{type:"dom",dispose:()=>{}})}async function de(r){try{const{CanvasAddon:e}=await q(async()=>{const{CanvasAddon:l}=await import("./addon-canvas-DpzMmAy5.js").then(t=>t.a);return{CanvasAddon:l}},[]),s=new e;return r.loadAddon(s),{type:"canvas",dispose:()=>s.dispose()}}catch{return null}}class Se{constructor(e,s){I(this,"deferred",!1);I(this,"userActiveSinceLastOutput",!1);I(this,"actions");I(this,"env");this.actions=e,this.env=s}reportUserActivity(){this.userActiveSinceLastOutput=!0}resetActivityFlag(){this.userActiveSinceLastOutput=!1}onIdle(e,s){return this.deferred=!1,s&&this.env.hasBrowserFocus()&&this.userActiveSinceLastOutput?(this.userActiveSinceLastOutput=!1,"suppressed"):this.notify(e)}onBuildTabChange(e,s){return!e&&this.deferred?(this.deferred=!1,this.notify(s),!0):!1}onActive(){this.deferred=!1}onUserEngagement(){const e=this.deferred;return this.deferred=!1,e}get isDeferred(){return this.deferred}notify(e){const s=!!(e!=null&&e.sound)&&e.sound!=="off";return s&&this.actions.playSound(e.sound),!this.env.hasBrowserFocus()&&(e!=null&&e.systemNotification)&&this.env.hasNotificationPermission()&&this.actions.showSystemNotification(),s?"played":"played-no-sound"}}class Ae{constructor(e){I(this,"_isIdle",!1);I(this,"_isBuilding",!1);I(this,"callbacks");this.callbacks=e}get isIdle(){return this._isIdle}get isBuilding(){return this._isBuilding}handleClaudeIdle(e,s,l){console.log("[TerminalIdleHandler] claude-idle, building: %s → false",this._isBuilding),e==null||e.onIdle(s,l),this._isIdle=!0,this._isBuilding=!1,this.callbacks.onIdleChange(!0),this.callbacks.onBuildingChange(!1)}handleClaudeActive(e){console.log("[TerminalIdleHandler] claude-active, building: %s → true",this._isBuilding),this._isIdle=!1,this._isBuilding=!0,this.callbacks.onIdleChange(!1),this.callbacks.onBuildingChange(!0),e==null||e.onActive(),e==null||e.resetActivityFlag(),this.callbacks.onCloseNotification()}handleOutput(e){this.callbacks.onIdleChange(!1),e==null||e.resetActivityFlag()}reset(){this._isBuilding&&(console.log("[TerminalIdleHandler] reset, was building: true"),this._isBuilding=!1,this.callbacks.onBuildingChange(!1))}}const _e=`
3
3
  .xterm { cursor: text; position: relative; user-select: none; -ms-user-select: none; -webkit-user-select: none; }
4
4
  .xterm.focus, .xterm:focus { outline: none; }
5
5
  .xterm .xterm-helpers { position: absolute; top: 0; z-index: 5; }
@@ -30,12 +30,12 @@ var ge=Object.defineProperty;var be=(r,e,s)=>e in r?ge(r,e,{enumerable:!0,config
30
30
  .xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer { z-index: 7; }
31
31
  .xterm-decoration-overview-ruler { z-index: 8; position: absolute; top: 0; right: 0; pointer-events: none; }
32
32
  .xterm-decoration-top { z-index: 2; position: relative; }
33
- `;function _e(){let r=document.getElementById("xterm-css");r||(r=document.createElement("style"),r.id="xterm-css",document.head.appendChild(r)),r.textContent=Ee}const We=u.forwardRef(function({entityName:e,entityType:s,entitySha:a,entityFilePath:t,scenarioName:n,scenarioDescription:o,analysisId:v,projectSlug:A,onRefreshPreview:x,onShowResults:w,onHideResults:E,onSetViewport:_,editorMode:T,onIdleChange:D,onBuildingChange:H,notificationSettings:W,buildTabActive:p,claudeStartMode:O,claudeSessionId:z,onDataMutationForwarded:M,resultsOpen:ie,editorStepLabel:oe},pe){const ee=u.useRef(null),P=u.useRef(null),J=u.useRef(null),I=u.useRef(null),G=u.useRef(null),te=u.useRef(!1),K=u.useRef(0),re=u.useRef(!1),k=u.useRef(D);k.current=D;const X=u.useRef(H);X.current=H;const ne=u.useRef(W);ne.current=W;const R=u.useRef(p);R.current=p;const ce=u.useRef(ie);ce.current=ie;const C=u.useRef(null),Y=u.useRef(!1),N=u.useRef(null);N.current||(N.current=new Se({playSound:i=>me(i),showSystemNotification:()=>{C.current&&C.current.close();const i=new Notification("Claude is ready for you",{body:"Claude has finished and is waiting for your input.",tag:"claude-idle"});i.onclick=()=>{window.focus(),i.close()},C.current=i}},{hasBrowserFocus:()=>document.hasFocus(),hasNotificationPermission:()=>typeof Notification<"u"&&Notification.permission==="granted"}));const V=u.useRef(null);V.current||(V.current=new Ae({onIdleChange:i=>{var f;Y.current=i,(f=k.current)==null||f.call(k,i)},onCloseNotification:()=>{C.current&&(C.current.close(),C.current=null)},onBuildingChange:i=>{var f;(f=X.current)==null||f.call(X,i)}}));function he(){C.current&&(C.current.close(),C.current=null)}function j(){var i,f;Y.current&&(Y.current=!1,he(),(i=k.current)==null||i.call(k,!1),(f=N.current)==null||f.onUserEngagement())}u.useEffect(()=>{function i(){var S;document.hasFocus()&&R.current&&j(),R.current&&document.hasFocus()&&((S=N.current)==null||S.reportUserActivity())}function f(){!document.hidden&&R.current&&j()}function L(){var S;document.hasFocus()&&R.current&&j(),R.current&&document.hasFocus()&&((S=N.current)==null||S.reportUserActivity())}function Z(){var S;R.current&&j(),R.current&&((S=N.current)==null||S.reportUserActivity())}return window.addEventListener("focus",Z),document.addEventListener("visibilitychange",f),document.addEventListener("mousemove",i),document.addEventListener("mousedown",L),document.addEventListener("keydown",i),()=>{window.removeEventListener("focus",Z),document.removeEventListener("visibilitychange",f),document.removeEventListener("mousemove",i),document.removeEventListener("mousedown",L),document.removeEventListener("keydown",i)}},[]),u.useEffect(()=>{var i;p&&Y.current&&document.hasFocus()&&j(),(i=N.current)==null||i.onBuildTabChange(!!p,ne.current)},[p]);const xe=u.useCallback(()=>{var i;(i=J.current)==null||i.focus()},[]);return u.useImperativeHandle(pe,()=>({sendInput(i){const f=I.current;f&&f.readyState===WebSocket.OPEN&&(f.send(JSON.stringify({type:"input",data:i})),setTimeout(()=>{f.readyState===WebSocket.OPEN&&f.send(JSON.stringify({type:"input",data:"\r"}))},100))},focus(){var i;(i=J.current)==null||i.focus()},scrollToBottom(){var f;const i=(f=ee.current)==null?void 0:f.querySelector(".xterm-viewport");i&&(i.scrollTop=i.scrollHeight)}})),u.useEffect(()=>{const i=ee.current;if(!i)return;let f=!1;return _e(),Promise.all([q(()=>import("./xterm-BqvuqXEL.js"),[]),q(()=>import("./addon-fit-YJmn1quW.js"),[]),q(()=>import("./addon-web-links-CHx25PAe.js").then(L=>L.a),__vite__mapDeps([0,1]))]).then(([L,Z,S])=>{if(f)return;const m=new L.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,c){try{const h=new URL(c),g=h.searchParams.get("scenario");if(g&&h.pathname.startsWith("/editor")){const b=new BroadcastChannel("codeyam-editor");b.postMessage({type:"switch-scenario",scenarioId:g}),b.close();return}}catch{}window.open(c,"_blank")}}}),F=new Z.FitAddon;m.loadAddon(F),m.loadAddon(new S.WebLinksAddon),m.open(i),m.attachCustomKeyEventHandler(l=>{if(ce.current&&(l.key==="ArrowLeft"||l.key==="ArrowRight")&&!l.ctrlKey&&!l.altKey&&!l.metaKey&&l.type==="keydown"){const c=l.key==="ArrowLeft"?"\x1B[D":"\x1B[C",h=I.current;return h&&h.readyState===WebSocket.OPEN&&h.send(JSON.stringify({type:"input",data:c})),!1}return!0}),m.write("\x1B[?25l");let Q=null;Ne(m,(l,c,h)=>{console.warn(`[Terminal] Renderer fallback: ${l} → ${c}`,h)}).then(l=>{if(f){l.dispose();return}console.log(`[Terminal] Using ${l.type} renderer`),Q=l.dispose}),requestAnimationFrame(()=>{try{F.fit()}catch{}}),J.current=m,m.focus(),setTimeout(()=>m.focus(),100),setTimeout(()=>m.focus(),500);const ye=window.location.protocol==="https:"?"wss:":"ws:",ve=window.location.host;function we(l){const c=new URLSearchParams;return c.set("entityName",e),s&&c.set("entityType",s),a&&c.set("entitySha",a),t&&c.set("entityFilePath",t),n&&c.set("scenarioName",n),o&&c.set("scenarioDescription",o),v&&c.set("analysisId",v),A&&c.set("projectSlug",A),T&&c.set("editorMode","true"),l&&c.set("reconnectId",l),O&&c.set("claudeStartMode",O),z&&c.set("claudeSessionId",z),oe&&c.set("editorStepLabel",oe),`${ye}//${ve}/ws/terminal?${c.toString()}`}function se(l){const c=we(l),h=new WebSocket(c);I.current=h,h.onopen=()=>{K.current=0,re.current=!1,h.send(JSON.stringify({type:"resize",cols:m.cols,rows:m.rows}))},h.onmessage=g=>{var b,le,ue;try{const y=JSON.parse(g.data);if(y.type==="session-id"){G.current=y.sessionId;return}if(y.type==="refresh-preview"){x==null||x(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"){M==null||M();return}if(y.type==="set-viewport"){_==null||_({name:y.name,width:y.width,height:y.height});return}if(y.type==="claude-idle"){(b=V.current)==null||b.handleClaudeIdle(N.current,ne.current,R.current??!1);return}if(y.type==="claude-active"){(le=V.current)==null||le.handleClaudeActive(N.current);return}y.type==="output"&&(m.write(y.data),(ue=V.current)==null||ue.handleOutput(N.current))}catch{m.write(g.data)}},h.onclose=()=>{if(te.current){m.write(`\r
33
+ `;function Ee(){let r=document.getElementById("xterm-css");r||(r=document.createElement("style"),r.id="xterm-css",document.head.appendChild(r)),r.textContent=_e}const We=u.forwardRef(function({entityName:e,entityType:s,entitySha:l,entityFilePath:t,scenarioName:n,scenarioDescription:o,analysisId:v,projectSlug:A,onRefreshPreview:x,onShowResults:g,onHideResults:_,onSetViewport:E,editorMode:T,onIdleChange:D,onBuildingChange:J,notificationSettings:z,buildTabActive:p,claudeStartMode:O,claudeSessionId:P,onDataMutationForwarded:re,resultsOpen:ce,editorStepLabel:le},pe){const ne=u.useRef(null),V=u.useRef(null),G=u.useRef(null),L=u.useRef(null),K=u.useRef(null),X=u.useRef(!1),Y=u.useRef(0),se=u.useRef(!1),k=u.useRef(D);k.current=D;const Z=u.useRef(J);Z.current=J;const ie=u.useRef(z);ie.current=z;const R=u.useRef(p);R.current=p;const ae=u.useRef(ce);ae.current=ce;const B=u.useRef(null),F=u.useRef(!1),N=u.useRef(null);N.current||(N.current=new Se({playSound:i=>me(i),showSystemNotification:()=>{B.current&&B.current.close();const i=new Notification("Claude is ready for you",{body:"Claude has finished and is waiting for your input.",tag:"claude-idle"});i.onclick=()=>{window.focus(),i.close()},B.current=i}},{hasBrowserFocus:()=>document.hasFocus(),hasNotificationPermission:()=>typeof Notification<"u"&&Notification.permission==="granted"}));const j=u.useRef(null);j.current||(j.current=new Ae({onIdleChange:i=>{var f;F.current=i,(f=k.current)==null||f.call(k,i)},onCloseNotification:()=>{B.current&&(B.current.close(),B.current=null)},onBuildingChange:i=>{var f;(f=Z.current)==null||f.call(Z,i)}}));function he(){B.current&&(B.current.close(),B.current=null)}function W(){var i,f;F.current&&(F.current=!1,he(),(i=k.current)==null||i.call(k,!1),(f=N.current)==null||f.onUserEngagement())}u.useEffect(()=>{function i(){var S;document.hasFocus()&&R.current&&W(),R.current&&document.hasFocus()&&((S=N.current)==null||S.reportUserActivity())}function f(){!document.hidden&&R.current&&W()}function C(){var S;document.hasFocus()&&R.current&&W(),R.current&&document.hasFocus()&&((S=N.current)==null||S.reportUserActivity())}function Q(){var S;R.current&&W(),R.current&&((S=N.current)==null||S.reportUserActivity())}return window.addEventListener("focus",Q),document.addEventListener("visibilitychange",f),document.addEventListener("mousemove",i),document.addEventListener("mousedown",C),document.addEventListener("keydown",i),()=>{window.removeEventListener("focus",Q),document.removeEventListener("visibilitychange",f),document.removeEventListener("mousemove",i),document.removeEventListener("mousedown",C),document.removeEventListener("keydown",i)}},[]),u.useEffect(()=>{var i;p&&F.current&&document.hasFocus()&&W(),(i=N.current)==null||i.onBuildTabChange(!!p,ie.current)},[p]);const xe=u.useCallback(()=>{var i;(i=G.current)==null||i.focus()},[]);return u.useImperativeHandle(pe,()=>({sendInput(i){const f=L.current;f&&f.readyState===WebSocket.OPEN&&(f.send(JSON.stringify({type:"input",data:i})),setTimeout(()=>{f.readyState===WebSocket.OPEN&&f.send(JSON.stringify({type:"input",data:"\r"}))},100))},focus(){var i;(i=G.current)==null||i.focus()},scrollToBottom(){var f;const i=(f=ne.current)==null?void 0:f.querySelector(".xterm-viewport");i&&(i.scrollTop=i.scrollHeight)}})),u.useEffect(()=>{const i=ne.current;if(!i)return;let f=!1;return Ee(),Promise.all([q(()=>import("./xterm-BqvuqXEL.js"),[]),q(()=>import("./addon-fit-YJmn1quW.js"),[]),q(()=>import("./addon-web-links-CHx25PAe.js").then(C=>C.a),__vite__mapDeps([0,1]))]).then(([C,Q,S])=>{if(f)return;const m=new C.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(a,c){try{const h=new URL(c),w=h.searchParams.get("scenario");if(w&&h.pathname.startsWith("/editor")){const b=new BroadcastChannel("codeyam-editor");b.postMessage({type:"switch-scenario",scenarioId:w}),b.close();return}}catch{}window.open(c,"_blank")}}}),M=new Q.FitAddon;m.loadAddon(M),m.loadAddon(new S.WebLinksAddon),m.open(i),m.attachCustomKeyEventHandler(a=>{if(ae.current&&(a.key==="ArrowLeft"||a.key==="ArrowRight")&&!a.ctrlKey&&!a.altKey&&!a.metaKey&&a.type==="keydown"){const c=a.key==="ArrowLeft"?"\x1B[D":"\x1B[C",h=L.current;return h&&h.readyState===WebSocket.OPEN&&h.send(JSON.stringify({type:"input",data:c})),!1}return!0}),m.write("\x1B[?25l");let ee=null;Ne(m,(a,c,h)=>{console.warn(`[Terminal] Renderer fallback: ${a} → ${c}`,h)}).then(a=>{if(f){a.dispose();return}console.log(`[Terminal] Using ${a.type} renderer`),ee=a.dispose}),requestAnimationFrame(()=>{try{M.fit()}catch{}}),G.current=m,m.focus(),setTimeout(()=>m.focus(),100),setTimeout(()=>m.focus(),500);const ye=window.location.protocol==="https:"?"wss:":"ws:",ve=window.location.host;function ge(a){const c=new URLSearchParams;return c.set("entityName",e),s&&c.set("entityType",s),l&&c.set("entitySha",l),t&&c.set("entityFilePath",t),n&&c.set("scenarioName",n),o&&c.set("scenarioDescription",o),v&&c.set("analysisId",v),A&&c.set("projectSlug",A),T&&c.set("editorMode","true"),a&&c.set("reconnectId",a),O&&c.set("claudeStartMode",O),P&&c.set("claudeSessionId",P),le&&c.set("editorStepLabel",le),`${ye}//${ve}/ws/terminal?${c.toString()}`}function oe(a){const c=ge(a),h=new WebSocket(c);L.current=h,h.onopen=()=>{Y.current=0,se.current=!1,h.send(JSON.stringify({type:"resize",cols:m.cols,rows:m.rows}))},h.onmessage=w=>{var b,U,te;try{const y=JSON.parse(w.data);if(y.type==="session-id"){K.current=y.sessionId;return}if(y.type==="refresh-preview"){x==null||x(y.path,y.scenarioId);return}if(y.type==="show-results"){g==null||g();return}if(y.type==="hide-results"){_==null||_();return}if(y.type==="data-mutation-forwarded"){re==null||re();return}if(y.type==="set-viewport"){E==null||E({name:y.name,width:y.width,height:y.height});return}if(y.type==="claude-idle"){(b=j.current)==null||b.handleClaudeIdle(N.current,ie.current,R.current??!1);return}if(y.type==="claude-active"){(U=j.current)==null||U.handleClaudeActive(N.current);return}y.type==="output"&&(m.write(y.data),(te=j.current)==null||te.handleOutput(N.current))}catch{m.write(w.data)}},h.onclose=()=>{var b,U;if(console.log("[Terminal] WS closed, intentional=%s",X.current),X.current){m.write(`\r
34
34
  \x1B[90m[Terminal session ended]\x1B[0m\r
35
- `);return}const g=K.current;if(g<5&&G.current){const b=1e3*Math.pow(2,Math.min(g,3));K.current=g+1,m.write(`\r
35
+ `),(b=j.current)==null||b.reset();return}const w=Y.current;if(w<5&&K.current){const te=1e3*Math.pow(2,Math.min(w,3));Y.current=w+1,m.write(`\r
36
36
  \x1B[33m[Reconnecting...]\x1B[0m\r
37
- `),setTimeout(()=>{te.current||se(G.current)},b)}else re.current?m.write(`\r
37
+ `),setTimeout(()=>{X.current||oe(K.current)},te)}else se.current?(m.write(`\r
38
38
  \x1B[90m[Terminal session ended]\x1B[0m\r
39
- `):(re.current=!0,m.write(`\r
39
+ `),(U=j.current)==null||U.reset()):(se.current=!0,m.write(`\r
40
40
  \x1B[33m[Starting new session...]\x1B[0m\r
41
- `),G.current=null,K.current=0,se())},h.onerror=()=>{}}se(),m.onData(l=>{const c=I.current;c&&c.readyState===WebSocket.OPEN&&c.send(JSON.stringify({type:"input",data:l})),j()});let U=null;const ae=new ResizeObserver(()=>{U&&clearTimeout(U),U=setTimeout(()=>{let l;try{l=F.proposeDimensions()}catch{return}if(!l||l.cols===m.cols&&l.rows===m.rows)return;const c=i.querySelector(".xterm-viewport");let h,g=!0;c&&(h=c.scrollTop,g=c.scrollTop+c.clientHeight>=c.scrollHeight-10),F.fit(),c&&h!==void 0&&(g?c.scrollTop=c.scrollHeight:c.scrollTop=h);const b=I.current;b&&b.readyState===WebSocket.OPEN&&b.send(JSON.stringify({type:"resize",cols:m.cols,rows:m.rows}))},150)});ae.observe(i),P.current=()=>{var l;U&&clearTimeout(U),ae.disconnect(),te.current=!0,(l=I.current)==null||l.close(),I.current=null,Q==null||Q(),m.dispose(),J.current=null}}),()=>{var L;f=!0,(L=P.current)==null||L.call(P),P.current=null}},[]),d.jsx("div",{ref:ee,onClick:xe,className:"w-full h-full relative overflow-hidden",style:{padding:"4px 0 0 8px"}})});function Oe(r){return r.replace(/[^a-zA-Z0-9_]+/g,"_")}function ze(r){const{activeAnalyzedScenario:e,analyzedPreviewUrl:s,activeScenarioId:a,scenarios:t,proxyUrl:n,devServerUrl:o,zoomComponent:v}=r;if(e&&s)return s;if(e&&!s)return null;if(a){const x=t.find(w=>w.id===a);if(x!=null&&x.url){const w=n||o;return w?x.url.startsWith("/")?`${w}${x.url}`:x.url:null}}const A=n||o;if(!A)return null;if(v&&a){const x=t.find(E=>E.id===a),w=x?Oe(x.name):"Default";return`${A}/__codeyam__/${v}/${w}`}return A}function Pe(r,e){if(!r||!e)return r;try{const s=new URL(r),a=e.indexOf("?");return a>=0?(s.pathname=e.slice(0,a),s.search=e.slice(a)):(s.pathname=e,s.search=""),s.href}catch{return r}}function Ve(r,e){return r?r!==e:!1}function Ue(r){if(r.length!==0)return r.find(e=>e.type==="application")||r[0]}function $e(r,e,s){if(!r.viewportWidth||!r.viewportHeight)return s??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 qe(r,e){const s=e.width,a=e.height??900,t=r.width,n=r.height;return s<=t&&a<=n?1:Math.min(t/s,n/a)}export{je as D,We as T,Pe as a,Oe as b,$ as c,ke as d,qe as e,ze as f,Ue as g,Ie as l,$e as r,Ve as s};
41
+ `),K.current=null,Y.current=0,oe())},h.onerror=()=>{}}oe(),m.onData(a=>{const c=L.current;c&&c.readyState===WebSocket.OPEN&&c.send(JSON.stringify({type:"input",data:a})),W()});let H=null;const ue=new ResizeObserver(()=>{H&&clearTimeout(H),H=setTimeout(()=>{let a;try{a=M.proposeDimensions()}catch{return}if(!a||a.cols===m.cols&&a.rows===m.rows)return;const c=i.querySelector(".xterm-viewport");let h,w=!0;c&&(h=c.scrollTop,w=c.scrollTop+c.clientHeight>=c.scrollHeight-10),M.fit(),c&&h!==void 0&&(w?c.scrollTop=c.scrollHeight:c.scrollTop=h);const b=L.current;b&&b.readyState===WebSocket.OPEN&&b.send(JSON.stringify({type:"resize",cols:m.cols,rows:m.rows}))},150)});ue.observe(i),V.current=()=>{var a;H&&clearTimeout(H),ue.disconnect(),X.current=!0,(a=L.current)==null||a.close(),L.current=null,ee==null||ee(),m.dispose(),G.current=null}}),()=>{var C;f=!0,(C=V.current)==null||C.call(V),V.current=null}},[]),d.jsx("div",{ref:ne,onClick:xe,className:"w-full h-full relative overflow-hidden",style:{padding:"4px 0 0 8px"}})});function Oe(r){return r.replace(/[^a-zA-Z0-9_]+/g,"_")}function ze(r){const{activeAnalyzedScenario:e,analyzedPreviewUrl:s,activeScenarioId:l,scenarios:t,proxyUrl:n,devServerUrl:o,zoomComponent:v}=r;if(e&&s)return s;if(e&&!s)return null;if(l){const x=t.find(g=>g.id===l);if(x!=null&&x.url){const g=n||o;return g?x.url.startsWith("/")?`${g}${x.url}`:x.url:null}}const A=n||o;if(!A)return null;if(v&&l){const x=t.find(_=>_.id===l),g=x?Oe(x.name):"Default";return`${A}/__codeyam__/${v}/${g}`}return A}function Pe(r,e){if(!r||!e)return r;try{const s=new URL(r),l=e.indexOf("?");return l>=0?(s.pathname=e.slice(0,l),s.search=e.slice(l)):(s.pathname=e,s.search=""),s.href}catch{return r}}function Ve(r,e){return r?r!==e:!1}function He(r){if(r.length!==0)return r.find(e=>e.url==="/")||r.find(e=>e.type==="application")||r[0]}function Ue(r,e,s){if(!r.viewportWidth||!r.viewportHeight)return s??null;const l=e.find(t=>t.width===r.viewportWidth&&t.height===r.viewportHeight);return{name:(l==null?void 0:l.name)||"Custom",width:r.viewportWidth,height:r.viewportHeight}}function $e(r,e){const s=e.width,l=e.height??900,t=r.width,n=r.height;return s<=t&&l<=n?1:Math.min(t/s,n/l)}export{je as D,We as T,Pe as a,Oe as b,$ as c,ke as d,$e as e,ze as f,He as g,Le as l,Ue as r,Ve as s};