aicodeman 1.8.1 → 1.8.3

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 (120) hide show
  1. package/dist/config/webview-limits.d.ts +36 -0
  2. package/dist/config/webview-limits.d.ts.map +1 -0
  3. package/dist/config/webview-limits.js +40 -0
  4. package/dist/config/webview-limits.js.map +1 -0
  5. package/dist/types/index.d.ts +1 -0
  6. package/dist/types/index.d.ts.map +1 -1
  7. package/dist/types/index.js +1 -0
  8. package/dist/types/index.js.map +1 -1
  9. package/dist/types/webview.d.ts +84 -0
  10. package/dist/types/webview.d.ts.map +1 -0
  11. package/dist/types/webview.js +21 -0
  12. package/dist/types/webview.js.map +1 -0
  13. package/dist/web/middleware/auth.d.ts.map +1 -1
  14. package/dist/web/middleware/auth.js +75 -3
  15. package/dist/web/middleware/auth.js.map +1 -1
  16. package/dist/web/public/admin-ui.js.gz +0 -0
  17. package/dist/web/public/api-client.c9b1cddc.js.gz +0 -0
  18. package/dist/web/public/app.adc992cd.js +38 -0
  19. package/dist/web/public/app.adc992cd.js.br +0 -0
  20. package/dist/web/public/app.adc992cd.js.gz +0 -0
  21. package/dist/web/public/{constants.21a0a83e.js → constants.e7175b95.js} +3 -0
  22. package/dist/web/public/constants.e7175b95.js.br +0 -0
  23. package/dist/web/public/{constants.21a0a83e.js.gz → constants.e7175b95.js.gz} +0 -0
  24. package/dist/web/public/cron-ui.js.gz +0 -0
  25. package/dist/web/public/i18n.4dcf1b87.js.gz +0 -0
  26. package/dist/web/public/image-input.ee16ad88.js.gz +0 -0
  27. package/dist/web/public/index.html +91 -19
  28. package/dist/web/public/index.html.br +0 -0
  29. package/dist/web/public/index.html.gz +0 -0
  30. package/dist/web/public/input-cjk.63794d0b.js.gz +0 -0
  31. package/dist/web/public/keyboard-accessory.3f91acef.js.gz +0 -0
  32. package/dist/web/public/mobile-handlers.bc2b8c1d.js.gz +0 -0
  33. package/dist/web/public/{mobile.2ebdbb03.css → mobile.6153d275.css} +1 -1
  34. package/dist/web/public/mobile.6153d275.css.br +0 -0
  35. package/dist/web/public/mobile.6153d275.css.gz +0 -0
  36. package/dist/web/public/notification-manager.fca811fd.js.gz +0 -0
  37. package/dist/web/public/orchestrator-panel.js.gz +0 -0
  38. package/dist/web/public/{panels-ui.58582d4c.js → panels-ui.3910e1e2.js} +16 -16
  39. package/dist/web/public/panels-ui.3910e1e2.js.br +0 -0
  40. package/dist/web/public/panels-ui.3910e1e2.js.gz +0 -0
  41. package/dist/web/public/ralph-panel.6de2d0f8.js.gz +0 -0
  42. package/dist/web/public/ralph-wizard.13a1831e.js.gz +0 -0
  43. package/dist/web/public/respawn-ui.2d249da9.js.gz +0 -0
  44. package/dist/web/public/sanitize-html.bc7078d6.js.gz +0 -0
  45. package/dist/web/public/session-ui.fd39c53c.js.gz +0 -0
  46. package/dist/web/public/{settings-ui.478c8242.js → settings-ui.b8def032.js} +1 -1
  47. package/dist/web/public/settings-ui.b8def032.js.br +0 -0
  48. package/dist/web/public/settings-ui.b8def032.js.gz +0 -0
  49. package/dist/web/public/styles.bd210c71.css +1 -0
  50. package/dist/web/public/styles.bd210c71.css.br +0 -0
  51. package/dist/web/public/styles.bd210c71.css.gz +0 -0
  52. package/dist/web/public/subagent-windows.69b60c35.js.gz +0 -0
  53. package/dist/web/public/sw.js.gz +0 -0
  54. package/dist/web/public/terminal-ui.feaf75c2.js +3 -0
  55. package/dist/web/public/terminal-ui.feaf75c2.js.br +0 -0
  56. package/dist/web/public/terminal-ui.feaf75c2.js.gz +0 -0
  57. package/dist/web/public/ultracode-panel.js.gz +0 -0
  58. package/dist/web/public/ultracode-windows.js.gz +0 -0
  59. package/dist/web/public/upload.html.gz +0 -0
  60. package/dist/web/public/vendor/dompurify.min.js.gz +0 -0
  61. package/dist/web/public/vendor/marked.min.js.gz +0 -0
  62. package/dist/web/public/vendor/xterm-addon-fit.min.js.gz +0 -0
  63. package/dist/web/public/vendor/xterm-addon-serialize.min.js.gz +0 -0
  64. package/dist/web/public/vendor/xterm-addon-unicode11.min.js.gz +0 -0
  65. package/dist/web/public/vendor/xterm-addon-webgl.min.js.gz +0 -0
  66. package/dist/web/public/vendor/xterm-zerolag-input.137ad9f0.js.gz +0 -0
  67. package/dist/web/public/vendor/xterm.css.gz +0 -0
  68. package/dist/web/public/vendor/xterm.min.js.gz +0 -0
  69. package/dist/web/public/voice-input.085e9e73.js.gz +0 -0
  70. package/dist/web/public/webview-tabs.js +445 -0
  71. package/dist/web/public/webview-tabs.js.br +0 -0
  72. package/dist/web/public/webview-tabs.js.gz +0 -0
  73. package/dist/web/routes/index.d.ts +1 -0
  74. package/dist/web/routes/index.d.ts.map +1 -1
  75. package/dist/web/routes/index.js +1 -0
  76. package/dist/web/routes/index.js.map +1 -1
  77. package/dist/web/routes/webview-routes.d.ts +50 -0
  78. package/dist/web/routes/webview-routes.d.ts.map +1 -0
  79. package/dist/web/routes/webview-routes.js +541 -0
  80. package/dist/web/routes/webview-routes.js.map +1 -0
  81. package/dist/web/schemas.d.ts +26 -0
  82. package/dist/web/schemas.d.ts.map +1 -1
  83. package/dist/web/schemas.js +34 -0
  84. package/dist/web/schemas.js.map +1 -1
  85. package/dist/web/server.d.ts.map +1 -1
  86. package/dist/web/server.js +11 -5
  87. package/dist/web/server.js.map +1 -1
  88. package/dist/web/sse-events.d.ts +7 -1
  89. package/dist/web/sse-events.d.ts.map +1 -1
  90. package/dist/web/sse-events.js +8 -1
  91. package/dist/web/sse-events.js.map +1 -1
  92. package/dist/web/webview-proxy.d.ts +181 -0
  93. package/dist/web/webview-proxy.d.ts.map +1 -0
  94. package/dist/web/webview-proxy.js +491 -0
  95. package/dist/web/webview-proxy.js.map +1 -0
  96. package/dist/webview-capabilities.d.ts +55 -0
  97. package/dist/webview-capabilities.d.ts.map +1 -0
  98. package/dist/webview-capabilities.js +102 -0
  99. package/dist/webview-capabilities.js.map +1 -0
  100. package/dist/webview-store.d.ts +16 -0
  101. package/dist/webview-store.d.ts.map +1 -0
  102. package/dist/webview-store.js +34 -0
  103. package/dist/webview-store.js.map +1 -0
  104. package/package.json +2 -1
  105. package/dist/web/public/app.2e95c82d.js +0 -38
  106. package/dist/web/public/app.2e95c82d.js.br +0 -0
  107. package/dist/web/public/app.2e95c82d.js.gz +0 -0
  108. package/dist/web/public/constants.21a0a83e.js.br +0 -0
  109. package/dist/web/public/mobile.2ebdbb03.css.br +0 -0
  110. package/dist/web/public/mobile.2ebdbb03.css.gz +0 -0
  111. package/dist/web/public/panels-ui.58582d4c.js.br +0 -0
  112. package/dist/web/public/panels-ui.58582d4c.js.gz +0 -0
  113. package/dist/web/public/settings-ui.478c8242.js.br +0 -0
  114. package/dist/web/public/settings-ui.478c8242.js.gz +0 -0
  115. package/dist/web/public/styles.5339e2f0.css +0 -1
  116. package/dist/web/public/styles.5339e2f0.css.br +0 -0
  117. package/dist/web/public/styles.5339e2f0.css.gz +0 -0
  118. package/dist/web/public/terminal-ui.9ea677e9.js +0 -3
  119. package/dist/web/public/terminal-ui.9ea677e9.js.br +0 -0
  120. package/dist/web/public/terminal-ui.9ea677e9.js.gz +0 -0
@@ -0,0 +1,3 @@
1
+ "use strict";(function(e){const t=/^\x1b\[[\?>=]?[\d;]*[cnR]$/,s=/^\x1b\][\d;]*[^\x07\x1b]*(?:\x07|\x1b\\)$/;function a(y){return t.test(y)||s.test(y)}function n(y){return a(y)}const l={og:{background:"#0d0d0d",foreground:"#e0e0e0",cursor:"#e0e0e0",cursorAccent:"#0d0d0d",selection:"rgba(255,255,255,0.3)",black:"#0d0d0d",red:"#ff6b6b",green:"#51cf66",yellow:"#ffd43b",blue:"#339af0",magenta:"#cc5de8",cyan:"#22b8cf",white:"#e0e0e0",brightBlack:"#495057",brightRed:"#ff8787",brightGreen:"#69db7c",brightYellow:"#ffe066",brightBlue:"#5c7cfa",brightMagenta:"#da77f2",brightCyan:"#66d9e8",brightWhite:"#ffffff"},"daylight-green":{background:"#161b23",foreground:"#dfe6ef",cursor:"#2fd3aa",cursorAccent:"#161b23",selection:"rgba(47,211,170,0.22)",black:"#161b23",red:"#ff8585",green:"#34d8a0",yellow:"#f0c25a",blue:"#5cc6e8",magenta:"#c79af2",cyan:"#2bcbbb",white:"#dfe6ef",brightBlack:"#5b6675",brightRed:"#ffa0a0",brightGreen:"#5fe6b8",brightYellow:"#ffd884",brightBlue:"#82d4ee",brightMagenta:"#d6b3f7",brightCyan:"#5ee0d4",brightWhite:"#f3f6fa"},"daylight-blue":{background:"#161b23",foreground:"#dfe6ef",cursor:"#38b6f0",cursorAccent:"#161b23",selection:"rgba(56,182,240,0.22)",black:"#161b23",red:"#ff8585",green:"#34d8a0",yellow:"#f0c25a",blue:"#5cc6e8",magenta:"#c79af2",cyan:"#2bcbbb",white:"#dfe6ef",brightBlack:"#5b6675",brightRed:"#ffa0a0",brightGreen:"#5fe6b8",brightYellow:"#ffd884",brightBlue:"#82d4ee",brightMagenta:"#d6b3f7",brightCyan:"#5ee0d4",brightWhite:"#f3f6fa"},"paper-gray":{background:"#f6f8fa",foreground:"#1f2328",cursor:"#0969da",cursorAccent:"#ffffff",selection:"rgba(9,105,218,0.2)",black:"#24292f",red:"#cf222e",green:"#1a7f37",yellow:"#9a6700",blue:"#0969da",magenta:"#8250df",cyan:"#1b7c83",white:"#59636e",brightBlack:"#6e7781",brightRed:"#a40e26",brightGreen:"#116329",brightYellow:"#7d4e00",brightBlue:"#0550ae",brightMagenta:"#6639ba",brightCyan:"#116b75",brightWhite:"#1f2328"},"solarized-light":{background:"#fdf6e3",foreground:"#586e75",cursor:"#147ba3",cursorAccent:"#fdf6e3",selection:"rgba(38,139,210,0.2)",black:"#eee8d5",red:"#dc322f",green:"#758600",yellow:"#9b7800",blue:"#147ba3",magenta:"#d33682",cyan:"#2a9189",white:"#073642",brightBlack:"#93a1a1",brightRed:"#cb4b16",brightGreen:"#657b83",brightYellow:"#586e75",brightBlue:"#268bd2",brightMagenta:"#6c71c4",brightCyan:"#2aa198",brightWhite:"#002b36"},"catppuccin-latte":{background:"#eff1f5",foreground:"#4c4f69",cursor:"#1e66f5",cursorAccent:"#ffffff",selection:"rgba(30,102,245,0.18)",black:"#5c5f77",red:"#d20f39",green:"#3b8f2b",yellow:"#a86605",blue:"#1e66f5",magenta:"#8839ef",cyan:"#177f86",white:"#6c6f85",brightBlack:"#7c7f93",brightRed:"#b50930",brightGreen:"#2f7622",brightYellow:"#8b5604",brightBlue:"#174fbf",brightMagenta:"#6f2bc5",brightCyan:"#116b71",brightWhite:"#4c4f69"},"rose-pine-dawn":{background:"#faf4ed",foreground:"#575279",cursor:"#286983",cursorAccent:"#fffaf3",selection:"rgba(40,105,131,0.2)",black:"#575279",red:"#b4637a",green:"#286983",yellow:"#96681f",blue:"#477f91",magenta:"#907aa9",cyan:"#3f7f8b",white:"#6e6a86",brightBlack:"#797593",brightRed:"#984d66",brightGreen:"#1f5266",brightYellow:"#7d5417",brightBlue:"#386b7c",brightMagenta:"#765f90",brightCyan:"#326b76",brightWhite:"#575279"}},d=new Set(["paper-gray","solarized-light","catppuccin-latte","rose-pine-dawn"]);function u(){return typeof document<"u"&&document.documentElement.dataset.skin||"daylight-blue"}function c(){const y=u();return l[y]||l["daylight-blue"]}function m(y=u()){return d.has(y)}e.CodemanTerminalInput={isTerminalQueryResponse:a,shouldSuppressTerminalQueryResponse:n,USER_SCROLL_STICKY_SUPPRESS_MS:1500,TOUCH_COMPAT_MOUSE_SUPPRESS_MS:450},e.CODEMAN_XTERM_THEMES=l,e.codemanCurrentXtermTheme=c,e.codemanCurrentSkinIsLight=m})(window),Object.assign(CodemanApp.prototype,{initTerminal(){const e=parseInt(localStorage.getItem("codeman-scrollback")),t=Number.isFinite(e)&&e>0?Math.max(e,DEFAULT_SCROLLBACK):DEFAULT_SCROLLBACK;if(this.terminal=new Terminal({theme:{...window.codemanCurrentXtermTheme()},fontFamily:'"Fira Code", "Cascadia Code", "JetBrains Mono", "SF Mono", Monaco, monospace',fontSize:MobileDetection.getDeviceType()==="mobile"?10:14,lineHeight:1.2,cursorBlink:!1,cursorStyle:"block",minimumContrastRatio:window.codemanCurrentSkinIsLight()?4.5:1,scrollback:t,allowTransparency:!0,allowProposedApi:!0}),this.fitAddon=new FitAddon.FitAddon,this.terminal.loadAddon(this.fitAddon),this._xtermSnapshots=new Map,typeof SerializeAddon<"u")try{this._serializeAddon=new SerializeAddon.SerializeAddon,this.terminal.loadAddon(this._serializeAddon)}catch{this._serializeAddon=null}if(typeof Unicode11Addon<"u")try{const r=new Unicode11Addon.Unicode11Addon;this.terminal.loadAddon(r),this.terminal.unicode.activeVersion="11"}catch{}const s=document.getElementById("terminalContainer");this.terminal.open(s),this._installMobileTapMouseGuard(),this.terminal.attachCustomKeyEventHandler(r=>{if(r.isComposing||r.keyCode===229||r.altKey&&!r.ctrlKey&&!r.shiftKey&&/^(Digit[1-9]|BracketLeft|BracketRight|KeyK)$/.test(r.code||"")||r.type==="keydown"&&this.shouldOpenCommandPaletteFromShortcut?.(r))return!1;if((r.ctrlKey||r.metaKey)&&r.key==="v"&&r.type==="keydown")return this.activeSessionId&&this._handleImagePaste&&this._handleImagePaste(),!1;if(r.key==="Enter"&&(r.shiftKey||r.ctrlKey)&&r.type==="keydown"){if(this.activeSessionId)if(this._localEchoEnabled){const g=this._localEchoOverlay?.pendingText||"";this._localEchoOverlay?.clear(),this._localEchoOverlay?.suppressBufferDetection(),this._flushedOffsets?.delete(this.activeSessionId),this._flushedTexts?.delete(this.activeSessionId),g&&(this._pendingInput+=g,w()),setTimeout(()=>{fetch(`/api/sessions/${this.activeSessionId}/send-key`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:r.ctrlKey?"C-Enter":"S-Enter"})})},g?80:0)}else fetch(`/api/sessions/${this.activeSessionId}/send-key`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:r.ctrlKey?"C-Enter":"S-Enter"})});return!1}return!0});{const r=s.querySelector(".xterm-helper-textarea");if(r&&MobileDetection.isTouchDevice()){let g=!1,h=0;r.addEventListener("compositionstart",()=>{g=!0}),r.addEventListener("compositionend",()=>{g=!1}),r.addEventListener("keydown",_=>{!_.isComposing&&_.keyCode!==229&&(h=Date.now())}),r.addEventListener("input",_=>{if(g||_.isComposing||_.inputType!=="insertText"||!_.data||Date.now()-h<50)return;const b=_.data,v=this._localEchoOverlay?.pendingText||"";Promise.resolve().then(()=>{if(this._lastTerminalData?.data===b&&performance.now()-this._lastTerminalData.time<100){r.value="";return}const T=this._localEchoOverlay?.pendingText||"";if(this._localEchoEnabled&&T.length>v.length&&T.endsWith(b)){r.value="";return}const f=r.value;!f||f.trim()===""&&b!==" "||(this.terminal._core.coreService.triggerDataEvent(b,!0),r.value="")})})}}this._webglAddon=null;const i=new URLSearchParams(location.search),o=(()=>{try{const r=localStorage.getItem("codeman-webgl-disabled");if(!r)return!1;const{at:g}=JSON.parse(r);return Date.now()-g>WEBGL_FALLBACK.STICKY_EXPIRY_MS?(localStorage.removeItem("codeman-webgl-disabled"),!1):!0}catch{return!1}})(),a=this.loadAppSettingsFromStorage(),n=this.getDefaultSettings(),l=a.webglRendererEnabled??n.webglRendererEnabled,{skip:d,clearSticky:u}=shouldSkipWebGL({deviceType:MobileDetection.getDeviceType(),noWebglParam:i.has("nowebgl"),forceParam:i.get("webgl")==="force",stickyDisabled:o,userPrefEnabled:l});if(u)try{localStorage.removeItem("codeman-webgl-disabled")}catch{}if(d&&o&&console.log("[CRASH-DIAG] WebGL sticky-disabled from prior stalls \u2014 DOM renderer in use. Re-enable: ?webgl=force"),!d)if(typeof WebglAddon<"u")this._initWebGL();else{const r=document.createElement("script");r.src="vendor/xterm-addon-webgl.min.js",r.onload=()=>this._initWebGL(),r.onerror=()=>console.warn("[CRASH-DIAG] Failed to load WebGL addon \u2014 using canvas renderer"),document.head.appendChild(r)}this._localEchoOverlay=new LocalEchoOverlay(this.terminal),MobileDetection.isTouchDevice()&&(this.terminal.onCursorMove(()=>this._syncMobileHelperTextareaToCursor()),this.terminal.onRender(()=>this._syncMobileHelperTextareaToCursor())),this._cjkInput=null,typeof CjkInput<"u"&&(this._cjkInput=CjkInput.init({send:r=>{this._handleCjkInput(r)}}));const c=this.terminal.focus.bind(this.terminal);this.terminal.focus=()=>{const r=document.getElementById("cjkInput");r?.classList.contains("cjk-input-visible")?r.focus():c()},MobileDetection.getDeviceType()==="mobile"&&document.body.classList.contains("safari-browser")?requestAnimationFrame(()=>{this.fitAddon.fit(),requestAnimationFrame(()=>this.fitAddon.fit())}):this.fitAddon.fit(),this.registerFilePathLinkProvider(),s.addEventListener("wheel",r=>{r.preventDefault();const g=this._wheelScrollLines(r);if(this._shouldForwardWheelToApp(r)){this._sendSyntheticSgrWheel(r.clientX,r.clientY,g);return}this._noteTerminalUserScroll(g),this.terminal.scrollLines(g)},{passive:!1});{const r=()=>this.terminal._core?._renderService?.dimensions?.css?.cell?.height||13;let g=0,h=0,_=0,b=null,v=!1;const T=I=>{const k=_?(I-_)/16.67:1;if(_=I,!v&&Math.abs(h)>.3){const A=Math.round(h/r());A!==0&&this.terminal.scrollLines(A),h*=.92,b=requestAnimationFrame(T)}else v?b=requestAnimationFrame(T):(b=null,h=0)};let f=0,S=!1,C=0;const M=8;s.addEventListener("touchstart",I=>{I.touches.length===1&&(g=I.touches[0].clientY,C=g,h=0,f=0,v=!0,S=!1,_=0,b&&(cancelAnimationFrame(b),b=null))},{passive:!0}),s.addEventListener("touchmove",I=>{if(I.touches.length===1&&v){const k=I.touches[0].clientY;if(!S&&Math.abs(k-C)>=M&&(S=!0),!S)return;I.preventDefault();const A=g-k;f+=A,h=A*1.2,g=k;const p=r(),L=Math.trunc(f/p);L!==0&&(this._noteTerminalUserScroll(L),this.terminal.scrollLines(L),f-=L*p)}},{passive:!1}),s.addEventListener("touchend",I=>{if(v=!1,!b&&Math.abs(h)>.3&&(b=requestAnimationFrame(T)),!S&&this.terminal){const k=I.changedTouches&&I.changedTouches[0],A=this.terminal.modes?.mouseTrackingMode,p=!!A&&A!=="none";k&&this._suppressTrustedTapMouseEvents(),k&&p?this._dispatchSyntheticTerminalClick(k.clientX,k.clientY):k&&this._sessionUsesServerMouseStrip()&&this._sendSyntheticSgrTap(k.clientX,k.clientY),this._syncMobileHelperTextareaToCursor();const L=document.getElementById("cjkInput");L?.classList.contains("cjk-input-visible")?L.focus():this.terminal.focus()}},{passive:!0}),s.addEventListener("touchcancel",()=>{v=!1,h=0,f=0},{passive:!0})}s.addEventListener("click",r=>this._handleDesktopTerminalClick(r)),this.showWelcome(),this.initImageInput(),this._chunkedWriteGen=0,this._bufferLoadSeq=0,this._bufferLoadOwner=null,this._lastUserScrollUpAt=null,this._resizeTimeout=null,this._lastResizeDims=null;const y=40,E=10,x=()=>{this._resizeTimeout&&clearTimeout(this._resizeTimeout),this._resizeTimeout=setTimeout(()=>{this._resizeTimeout=null,this.fitAddon&&this.fitAddon.fit(),this.flickerFilterBuffer&&(this.flickerFilterTimeout&&(clearTimeout(this.flickerFilterTimeout),this.flickerFilterTimeout=null),this.flushFlickerBuffer());const r=typeof KeyboardHandler<"u"&&KeyboardHandler.keyboardVisible;if(this.activeSessionId&&!r){const g=this.fitAddon.proposeDimensions(),h=g?Math.max(g.cols,y):y,_=g?Math.max(g.rows,E):E;if(!this._lastResizeDims||h!==this._lastResizeDims.cols||_!==this._lastResizeDims.rows){const b=this.activeSessionId?this.sessions.get(this.activeSessionId):null;b&&b.mode!=="shell"&&this.terminal&&this.isTerminalAtBottom()&&this.terminal.write("\x1B[3J\x1B[H\x1B[2J"),this._lastResizeDims={cols:h,rows:_};const v=typeof MobileDetection<"u"&&MobileDetection.getDeviceType?MobileDetection.getDeviceType():"desktop";let T=!1;if(this._wsReady&&this._wsSessionId===this.activeSessionId)try{this._ws.send(JSON.stringify({t:"z",c:h,r:_,v})),T=!0}catch{}T||fetch(`/api/sessions/${this.activeSessionId}/resize`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cols:h,rows:_,viewportType:v})}).catch(()=>{})}}this.updateConnectionLines(),this._localEchoOverlay?.hasPending&&this._localEchoOverlay.rerender()},300)};window.addEventListener("resize",x),this.terminalResizeObserver&&this.terminalResizeObserver.disconnect(),this.terminalResizeObserver=new ResizeObserver(x),this.terminalResizeObserver.observe(s),this._pendingInput="",this._inputFlushTimeout=null,this._lastKeystrokeTime=0;const w=()=>{if(this._inputFlushTimeout=null,this._pendingInput&&this.activeSessionId){const r=this._pendingInput,g=this.activeSessionId;this._pendingInput="",this._sendInputAsync(g,r)}};this.terminal.onData(r=>{if(!/^\x1b\[<\d+;\d+;\d+[Mm]$/.test(r)&&(window.cjkActive||document.activeElement?.id==="cjkInput")){const h=document.getElementById("cjkInput");h?.classList.contains("cjk-input-visible")&&document.activeElement===this.terminal.textarea&&!window.CodemanTerminalInput?.shouldSuppressTerminalQueryResponse(r)&&(_crashDiag.log("CJK regain-focus (onData swallowed input)"),h.focus());return}if(this.activeSessionId){if(window.CodemanTerminalInput?.shouldSuppressTerminalQueryResponse(r))return;if(this._lastTerminalData={data:r,time:performance.now()},this._localEchoEnabled){if(r==="\x7F"){if(this._localEchoOverlay?.removeChar()==="flushed"){const{count:b,text:v}=this._localEchoOverlay.getFlushed();this._flushedOffsets?.has(this.activeSessionId)&&(b===0?(this._flushedOffsets.delete(this.activeSessionId),this._flushedTexts?.delete(this.activeSessionId)):(this._flushedOffsets.set(this.activeSessionId,b),this._flushedTexts?.set(this.activeSessionId,v))),this._pendingInput+=r,w()}return}if(/^[\r\n]+$/.test(r)){const _=this._localEchoOverlay?.pendingText||"";this._localEchoOverlay?.clear(),this._localEchoOverlay?.suppressBufferDetection(),this._flushedOffsets?.delete(this.activeSessionId),this._flushedTexts?.delete(this.activeSessionId),this._inputFlushTimeout&&(clearTimeout(this._inputFlushTimeout),this._inputFlushTimeout=null),_&&(this._pendingInput+=_,w()),setTimeout(()=>{this._pendingInput+="\r",w()},80);return}if(r.length>1&&r.charCodeAt(0)>=32){this._localEchoOverlay?.appendText(r);return}if(r.charCodeAt(0)<32){if(r.length>1&&r.charCodeAt(0)===27){this._pendingInput+=r,w();return}if(this._restoringFlushedState){this._pendingInput+=r,w();return}if(r===" "){const b=this._localEchoOverlay?.pendingText||"";this._localEchoOverlay?.clear(),this._flushedOffsets?.delete(this.activeSessionId),this._flushedTexts?.delete(this.activeSessionId),b&&(this._pendingInput+=b),this._pendingInput+=r,this._inputFlushTimeout&&(clearTimeout(this._inputFlushTimeout),this._inputFlushTimeout=null);let v="";try{const f=this._localEchoOverlay?.findPrompt?.();if(f){const S=this.terminal.buffer.active,C=S.getLine(S.viewportY+f.row);C&&(v=C.translateToString(!0).slice(f.col+2).trimEnd())}}catch{}this._tabCompletionBaseText=v,w(),this._tabCompletionSessionId=this.activeSessionId,this._tabCompletionRetries=0,this._tabCompletionFallback&&clearTimeout(this._tabCompletionFallback);const T=this;this._tabCompletionFallback=setTimeout(()=>{if(T._tabCompletionFallback=null,!T._tabCompletionSessionId||T._tabCompletionSessionId!==T.activeSessionId)return;const f=T._localEchoOverlay;!f||f.pendingText||T.terminal.write("",()=>{if(!T._tabCompletionSessionId)return;f.resetBufferDetection();const S=f.detectBufferText();S&&S!==T._tabCompletionBaseText&&(T._tabCompletionSessionId=null,T._tabCompletionRetries=0,T._tabCompletionBaseText=null,f.rerender())})},300);return}const _=this._localEchoOverlay?.pendingText||"";this._localEchoOverlay?.clear(),this._localEchoOverlay?.suppressBufferDetection(),this._flushedOffsets?.delete(this.activeSessionId),this._flushedTexts?.delete(this.activeSessionId),_&&(this._pendingInput+=_),this._pendingInput+=r,this._inputFlushTimeout&&(clearTimeout(this._inputFlushTimeout),this._inputFlushTimeout=null),w();return}if(r.length===1&&r.charCodeAt(0)>=32){this._localEchoOverlay?.addChar(r);return}}if(this._pendingInput+=r,r.charCodeAt(0)<32||r.length>1){this._inputFlushTimeout&&(clearTimeout(this._inputFlushTimeout),this._inputFlushTimeout=null),w();return}const h=performance.now();h-this._lastKeystrokeTime>50?(this._inputFlushTimeout&&(clearTimeout(this._inputFlushTimeout),this._inputFlushTimeout=null),this._lastKeystrokeTime=h,w()):(this._lastKeystrokeTime=h,this._inputFlushTimeout||(this._inputFlushTimeout=setTimeout(w,0)))}})},registerFilePathLinkProvider(){const e=this;let t=-1;this.terminal.registerLinkProvider({provideLinks(s,i){s!==t&&(t=s,console.debug("[LinkProvider] Checking line:",s));const o=e.terminal.buffer.active;if(!o.getLine(s-1)){i(void 0);return}const n=e.terminal.cols,l=S=>o.getLine(S-1),d=S=>{if(S<=1)return!1;if(l(S)?.isWrapped)return!0;const C=l(S-1);return!!C&&C.translateToString(!0).length>=n},u=12;let c=s;for(;c>1&&s-c<u&&d(c);)c--;let m=s;for(;m<o.length&&m-c<u&&d(m+1);)m++;const y=[];for(let S=c;S<=m;S++){const C=l(S);if(!C)break;y.push(C.translateToString(S===m))}const E=y.join(""),x=S=>{let C=S;for(let M=0;M<y.length-1;M++){if(C<y[M].length)return{x:C+1,y:c+M};C-=y[M].length}return{x:C+1,y:c+y.length-1}};if(!E||!E.includes("/")){i(void 0);return}const w=[],r=/https?:\/\/(?:[^\s"'<>|;&)\]\x00-\x1f]|&(?!&))+/g,g=(S,C)=>{const M=S.replace(/[.,;:!?)&]+$/,""),I=E.indexOf(M,C);if(I===-1)return;const k=x(I),A=x(I+M.length);w.some(p=>p.range.start.x===k.x&&p.range.start.y===k.y)||w.push({text:M,range:{start:k,end:A},decorations:{pointerCursor:!0,underline:!0},activate(p,L){window.open(L,"_blank","noopener,noreferrer")},hover(){e._linkHovered=!0},leave(){e._linkHovered=!1}})},h=/\b(tail|cat|head|less|grep|watch|vim|nano)\s+(?:[^\s\/]+\s+){0,4}(\/[^\s"'<>|;&\n\x00-\x1f]+)/g,_=/(\/(?:home|tmp|var|etc|opt)[^\s"'<>|;&\n\x00-\x1f]*\.(?:log|txt|json|md|yaml|yml|csv|xml|sh|py|ts|js|png|jpe?g|gif|webp|bmp|svg|pdf))\b/g,b=/Bash\([^)]*?(\/(?:home|tmp|var|etc|opt)[^\s"'<>|;&\)\n\x00-\x1f]+)/g,v=new Set(["png","jpg","jpeg","gif","webp","bmp","svg","pdf"]),T=(S,C)=>{const M=E.indexOf(S,C);if(M===-1)return;const I=x(M),k=x(M+S.length);w.some(A=>A.range.start.x===I.x&&A.range.start.y===I.y)||w.push({text:S,range:{start:I,end:k},decorations:{pointerCursor:!0,underline:!0},activate(A,p){const L=(p.split(".").pop()||"").toLowerCase();if(v.has(L)){e.openFilePreview(p,e.activeSessionId);return}e.openLogViewerWindow(p,e.activeSessionId)},hover(){e._linkHovered=!0},leave(){e._linkHovered=!1}})};let f;for(r.lastIndex=0;(f=r.exec(E))!==null;)g(f[0],f.index);for(h.lastIndex=0;(f=h.exec(E))!==null;)T(f[2],f.index);for(_.lastIndex=0;(f=_.exec(E))!==null;)T(f[1],f.index);for(b.lastIndex=0;(f=b.exec(E))!==null;)T(f[1],f.index);w.length>0&&console.debug("[LinkProvider] Found links:",w.map(S=>S.text)),i(w.length>0?w:void 0)}}),console.log("[LinkProvider] File path link provider registered")},showWelcome(){const e=document.getElementById("welcomeOverlay");e&&(e.classList.add("visible"),this.loadTunnelStatus(),this.loadHistorySessions(),this.initSearchPanel()),this._updateCjkInputState?.()},hideWelcome(){const e=document.getElementById("welcomeOverlay");e&&e.classList.remove("visible");const t=document.getElementById("welcomeQr");t&&(clearTimeout(this._welcomeQrShrinkTimer),t.classList.remove("expanded")),this._updateCjkInputState?.()},async _fetchHistorySessions(){const s=(await(await fetch("/api/history/sessions")).json()).data?.sessions||[];if(s.length===0)return[];const i=new Map;for(const a of s){const n=a.projectKey||a.workingDir;i.has(n)||i.set(n,[]),i.get(n).push(a)}const o=[];for(const[,a]of i)o.push(...a.slice(0,3));return o.sort((a,n)=>new Date(n.lastModified)-new Date(a.lastModified)),o},async _fetchUnifiedSessions(e=60){const t=await fetch("/api/sessions/unified?limit="+e),s=await t.json().catch(()=>null);if(!t.ok||!s||s.success===!1||!s.data)throw new Error(s?.error||`unified sessions request failed (HTTP ${t.status})`);return s.data.sessions||[]},_resolveCaseLabel(e,t){if(!e)return"";let s=null;for(const i of t||[])if(!(!i||!i.path)){if(e===i.path)return`#${i.name}`;if(e.startsWith(i.path+"/")){const o=i.path.length;(!s||o>s.len)&&(s={name:i.name,suffix:e.slice(o),len:o})}}return s?`#${s.name}${s.suffix}`:e.split("/").pop()||e},_shortenHomePath(e){return(e||"").replace(/^\/home\/[^/]+\//,"~/").replace(/^\/Users\/[^/]+\//,"~/")},_buildHistoryItem(e,t,s){const i=s?.showViewAll!==!1,o=typeof e.sizeBytes=="number",a=o?e.sizeBytes<1024?`${e.sizeBytes}B`:e.sizeBytes<1048576?`${(e.sizeBytes/1024).toFixed(0)}K`:`${(e.sizeBytes/1048576).toFixed(1)}M`:"",n=typeof e.lastActivityAt=="number"?e.lastActivityAt:e.lastModified?Date.parse(e.lastModified):NaN;let l="";if(!Number.isNaN(n)){const p=new Date(n);l=p.toLocaleDateString("en",{month:"short",day:"numeric"})+" "+p.toLocaleTimeString("en",{hour:"2-digit",minute:"2-digit",hour12:!1})}const d=this._shortenHomePath(e.workingDir),u=this._resolveCaseLabel(e.workingDir,t),c=Array.isArray(e.sources)&&e.sources.includes("live"),m=e.pinned===!0,y=document.createElement("div");y.className="history-item"+(m?" is-pinned":""),y.title=e.workingDir||"";const E=document.createElement("div");E.className="history-item-main",E.addEventListener("click",s?.onActivate||(()=>{c&&this.sessions.has(e.sessionId)?this.selectSession(e.sessionId):this.resumeHistorySession(e.claudeSessionId||e.sessionId,e.workingDir||"",e.name)}));const x=document.createElement("div");x.className="history-item-text";const w=document.createElement("span");if(w.className="history-item-title",m){const p=document.createElement("span");p.className="history-item-pin",p.textContent="\u{1F4CC}",p.setAttribute("aria-label","Pinned"),p.title="Pinned",w.appendChild(p)}w.appendChild(document.createTextNode(e.name||e.firstPrompt||d));const r=document.createElement("div");if(r.className="history-item-badges",e.mode){const p=document.createElement("span");p.className="history-item-badge history-item-badge-mode",p.textContent=e.mode,r.appendChild(p)}if(c){const p=document.createElement("span");p.className="history-item-badge history-item-badge-live",p.textContent="LIVE",r.appendChild(p)}const g=document.createElement("span");g.className="history-item-subtitle",u.startsWith("#")&&g.classList.add("is-case"),g.textContent=u,x.append(w),r.childElementCount>0&&x.append(r),x.append(g);const h=document.createElement("span");h.className="history-item-meta",h.textContent=l;const _=document.createElement("button");_.className="history-item-expand",_.type="button",_.setAttribute("aria-haspopup","menu"),_.setAttribute("aria-label","Session actions"),_.setAttribute("aria-expanded","false"),_.textContent="\u22EF",E.append(x,h,_);const b=document.createElement("div");b.className="history-item-detail",b.hidden=!0;const v=document.createElement("div");v.className="history-detail-row";const T=document.createElement("span");T.className="history-detail-label",T.textContent="Prompt";const f=document.createElement("span");f.className="history-detail-value history-detail-prompt",f.textContent=e.firstPrompt||"(no prompt captured)",v.append(T,f);let S=null;if(e.lastPrompt&&e.lastPrompt!==e.firstPrompt){S=document.createElement("div"),S.className="history-detail-row";const p=document.createElement("span");p.className="history-detail-label",p.textContent="Last prompt";const L=document.createElement("span");L.className="history-detail-value history-detail-prompt",L.textContent=e.lastPrompt,S.append(p,L)}const C=document.createElement("div");C.className="history-detail-row";const M=document.createElement("span");M.className="history-detail-label",M.textContent="Path";const I=document.createElement("span");I.className="history-detail-value history-detail-path",I.textContent=d,C.append(M,I);const k=document.createElement("div");k.className="history-detail-row history-detail-meta";const A=[];if(l&&A.push(l),o&&A.push(a),A.push(e.sessionId.slice(0,8)),k.textContent=A.join(" \xB7 "),b.append(v),S&&b.append(S),b.append(C,k),i&&e.projectKey){const p=document.createElement("div");p.className="history-detail-row history-detail-actions";const L=document.createElement("button");L.type="button",L.className="history-view-all-btn",L.textContent="View all in this folder",L.addEventListener("click",R=>{R.stopPropagation(),this.openFolderHistoryModal(e.projectKey,e.workingDir,t)}),p.appendChild(L),b.appendChild(p)}return _.addEventListener("click",p=>{p.stopPropagation(),p.preventDefault(),this._openSessionRowMenu(p.currentTarget,e,t,y,b)}),y.append(E,b),y},_openSessionRowMenu(e,t,s,i,o){if(this._openRowMenuClose)try{this._openRowMenuClose()}catch{}const a=Array.isArray(t.sources)&&t.sources.includes("live")&&this.sessions.has(t.sessionId),n=document.createElement("div");n.className="session-row-menu",n.setAttribute("role","menu");let l=null,d=null,u=null;const c=()=>{document.removeEventListener("mousedown",l,!0),document.removeEventListener("keydown",d,!0),window.removeEventListener("scroll",u,!0),window.removeEventListener("resize",u,!0);try{n.remove()}catch{}this._openRowMenuEl===n&&(this._openRowMenuEl=null,this._openRowMenuClose=null)},m=(h,_,b)=>{const v=document.createElement("button");v.type="button",v.className="session-row-menu-item",v.setAttribute("role","menuitem");const T=document.createElement("span");if(T.className="session-row-menu-label",T.textContent=h,v.appendChild(T),b&&b.sublabel){const f=document.createElement("span");f.className="session-row-menu-sublabel",f.textContent=b.sublabel,v.appendChild(f)}v.addEventListener("click",async f=>{f.stopPropagation(),f.preventDefault(),await _()}),n.appendChild(v)};m(a?"Switch to session":"Resume session",()=>{a?this.selectSession(t.sessionId):this.resumeHistorySession(t.claudeSessionId||t.sessionId,t.workingDir||"",t.name),this.closeSessionManager?.(),c()});const y=t.pinned===!0;m(y?"Unpin session":"Pin to top",async()=>{await this._setSessionPinned(t.sessionId,!y)?(t.pinned=!y,this.showToast(y?"Unpinned":"Pinned to top","success")):this.showToast("Pin failed","error"),c()}),a&&m("Open folder",()=>{this.selectSession(t.sessionId),this.loadFileBrowser?.(t.sessionId),this.closeSessionManager?.(),c()}),t.workingDir&&m("Copy path",async()=>{const h=await this._copyText(t.workingDir);this.showToast(h?"Path copied":"Copy failed",h?"success":"error"),c()}),m("Show details",()=>{const h=i.classList.toggle("expanded");o.hidden=!h,e.setAttribute("aria-expanded",h?"true":"false"),c()}),document.body.appendChild(n);const E=e.getBoundingClientRect(),x=n.getBoundingClientRect(),w=4;let r=E.bottom+w;r+x.height>window.innerHeight&&E.top-w-x.height>=0&&(r=E.top-w-x.height);let g=E.right-x.width;g<w&&(g=w),g+x.width>window.innerWidth-w&&(g=Math.max(w,window.innerWidth-w-x.width)),n.style.top=`${Math.max(w,r)}px`,n.style.left=`${g}px`,l=h=>{n.contains(h.target)||e.contains(h.target)||c()},d=h=>{h.key==="Escape"&&(h.stopPropagation(),c())},u=()=>c(),document.addEventListener("mousedown",l,!0),document.addEventListener("keydown",d,!0),window.addEventListener("scroll",u,!0),window.addEventListener("resize",u,!0),this._openRowMenuEl=n,this._openRowMenuClose=c},async _setSessionPinned(e,t){try{const s=await fetch(`/api/sessions/${encodeURIComponent(e)}/pin`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"same-origin",body:JSON.stringify({pinned:t})});return s.ok?(await s.json())?.success===!0:!1}catch(s){return console.error("[_setSessionPinned]",s),!1}},_HISTORY_INITIAL_COUNT:4,async loadHistorySessions(){const e=document.getElementById("historySessions"),t=document.getElementById("historyList");if(!(!e||!t))try{const s=Array.isArray(this.cases)&&this.cases.length>0?Promise.resolve(this.cases):fetch("/api/cases").then(n=>n.ok?n.json():null).then(n=>n?.data||[]).catch(()=>[]),[i,o]=await Promise.all([this._fetchUnifiedSessions(60),s]);if(i.length===0){e.style.display="none";return}t.replaceChildren();const a=this._HISTORY_INITIAL_COUNT;for(let n=0;n<Math.min(a,i.length);n++)t.appendChild(this._buildHistoryItem(i[n],o));if(i.length>a){const n=document.createElement("button");n.className="history-show-more",n.textContent=`Show ${i.length-a} more`,n.addEventListener("click",()=>{for(let l=a;l<i.length;l++)t.insertBefore(this._buildHistoryItem(i[l],o),n);n.remove()}),t.appendChild(n)}e.style.display=""}catch(s){console.error("[loadHistorySessions]",s),e.style.display="none"}},_FOLDER_HISTORY_PAGE_SIZE:20,openFolderHistoryModal(e,t,s){this._closeFolderHistoryModal();const i=document.createElement("div");i.className="modal active folder-history-modal",i.id="folderHistoryModal";const o=document.createElement("div");o.className="modal-backdrop",o.addEventListener("click",()=>this._closeFolderHistoryModal());const a=document.createElement("div");a.className="modal-content modal-lg";const n=document.createElement("div");n.className="modal-header";const l=document.createElement("h3");l.textContent="Folder History";const d=document.createElement("div");d.className="folder-history-subtitle",d.textContent=this._shortenHomePath(t);const u=document.createElement("button");u.className="modal-close",u.setAttribute("aria-label","Close"),u.innerHTML="&times;",u.addEventListener("click",()=>this._closeFolderHistoryModal()),n.append(l,u);const c=document.createElement("div");c.className="modal-body";const m=document.createElement("div");m.className="folder-history-list",m.setAttribute("data-loading","true"),m.textContent="Loading...",c.append(d,m),a.append(n,c),i.append(o,a),document.body.appendChild(i),this._folderHistoryState={projectKey:e,workingDir:t,cases:s||[],offset:0,total:null,list:m},this._folderHistoryEscHandler=y=>{y.key==="Escape"&&this._closeFolderHistoryModal()},document.addEventListener("keydown",this._folderHistoryEscHandler),this._loadFolderHistoryPage()},async _loadFolderHistoryPage(){const e=this._folderHistoryState;if(!e)return;const{projectKey:t,cases:s,list:i}=e,o=this._FOLDER_HISTORY_PAGE_SIZE,a=e.offset,n=i.querySelector(".folder-history-more");n&&n.remove(),a===0&&(i.replaceChildren(),i.removeAttribute("data-loading"));try{const l=`/api/history/sessions?projectKey=${encodeURIComponent(t)}&offset=${a}&limit=${o}`,u=await(await fetch(l)).json(),c=u.data?.sessions||[];if(e.total=typeof u.data?.total=="number"?u.data.total:c.length+a,a===0&&c.length===0){const m=document.createElement("div");m.className="folder-history-empty",m.textContent="No conversations found in this folder.",i.appendChild(m);return}for(const m of c)i.appendChild(this._buildHistoryItem(m,s,{showViewAll:!1}));if(e.offset=a+c.length,e.offset<e.total){const m=e.total-e.offset,y=document.createElement("button");y.className="history-show-more folder-history-more",y.textContent=`Show ${Math.min(o,m)} more (${m} remaining)`,y.addEventListener("click",()=>this._loadFolderHistoryPage()),i.appendChild(y)}}catch(l){console.error("[loadFolderHistoryPage]",l);const d=document.createElement("div");d.className="folder-history-empty",d.textContent="Failed to load folder history.",i.appendChild(d)}},_closeFolderHistoryModal(){const e=document.getElementById("folderHistoryModal");e&&e.remove(),this._folderHistoryEscHandler&&(document.removeEventListener("keydown",this._folderHistoryEscHandler),this._folderHistoryEscHandler=null),this._folderHistoryState=null},_resolveResumeName(e,t){if(typeof e=="string"&&e.trim())return e;const s=(t||"").split("/").pop()||"session";let i=1;for(const[,o]of this.sessions){const a=o.name&&o.name.match(/^w(\d+)-/);if(a){const n=parseInt(a[1]);n>=i&&(i=n+1)}}return`w${i}-${s}`},async resumeHistorySession(e,t,s){document.getElementById("runModeMenu")?.classList.remove("active"),this._closeFolderHistoryModal();try{this.terminal.clear(),this.terminal.writeln(`\x1B[1;32m Resuming conversation ${e.slice(0,8)}...\x1B[0m`);const i=this._resolveResumeName(s,t),a=(this.cases||[]).find(y=>y.path===t)?.name||t.split("/").pop()||"",n=this.loadAppSettingsFromStorage(),l=this.buildEnvOverrides(this.getCaseSettings(a),n),d=this.getEffortSetting(n),c=await(await fetch("/api/sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workingDir:t,name:i,resumeSessionId:e,...Object.keys(l).length>0?{envOverrides:l}:{},...d?{effort:d}:{}})})).json();if(!c.success)throw new Error(c.error);const m=c.data.session.id;await fetch(`/api/sessions/${m}/interactive`,{method:"POST"}),this.terminal.writeln(`\x1B[90m Session ${i} ready\x1B[0m`),await this.selectSession(m),this.terminal.focus()}catch(i){this.terminal.writeln(`\x1B[1;31m Error: ${i.message}\x1B[0m`)}},isTerminalAtBottom(){if(!this.terminal)return!0;const e=this.terminal.buffer.active;return e.viewportY>=e.baseY-2},_noteTerminalUserScroll(e){e<0?this._lastUserScrollUpAt=performance.now():this.isTerminalAtBottom()&&(this._lastUserScrollUpAt=null)},_hasRecentUserScrollUp(){return typeof this._lastUserScrollUpAt!="number"?!1:performance.now()-this._lastUserScrollUpAt<window.CodemanTerminalInput.USER_SCROLL_STICKY_SUPPRESS_MS},batchTerminalWrite(e){if(this._isLoadingBuffer){this._loadBufferQueue&&this._loadBufferQueue.push(e);return}if(this.writeFrameScheduled||(this._wasAtBottomBeforeWrite=this.isTerminalAtBottom()),(this.activeSessionId?this.sessions.get(this.activeSessionId):null)?.flickerFilterEnabled??!1){if(e.includes("\x1B[2J")||e.includes("\x1B[H\x1B[J")||e.includes("\x1B[H")&&e.includes("\x1B[?25l")){this.flickerFilterActive=!0,this.flickerFilterBuffer+=e,this.flickerFilterTimeout&&clearTimeout(this.flickerFilterTimeout),this.flickerFilterTimeout=setTimeout(()=>{this.flickerFilterTimeout=null,this.flushFlickerBuffer()},SYNC_WAIT_TIMEOUT_MS);return}if(this.flickerFilterActive){this.flickerFilterBuffer+=e;return}}this.pendingWrites.push(e),this.writeFrameScheduled||(this.writeFrameScheduled=!0,this._safeYield(()=>{this.flushPendingWrites(),this.writeFrameScheduled=!1}))},flushFlickerBuffer(){this.flickerFilterBuffer&&(this.pendingWrites.push(this.flickerFilterBuffer),this.flickerFilterBuffer="",this.flickerFilterActive=!1,this.writeFrameScheduled||(this.writeFrameScheduled=!0,this._safeYield(()=>{this.flushPendingWrites(),this.writeFrameScheduled=!1})))},_updateLocalEchoState(){const e=this.loadAppSettingsFromStorage(),t=this.activeSessionId?this.sessions.get(this.activeSessionId):null,i=!!((e.localEchoEnabled??MobileDetection.isTouchDevice())&&t);this._localEchoEnabled&&!i&&this._localEchoOverlay?.clear(),this._localEchoEnabled=i,this._localEchoOverlay&&t&&(t.mode==="opencode"?this._localEchoOverlay.setPrompt({type:"custom",offset:3,find:o=>{try{const a=o.buffer.active,n=a.cursorY,l=a.getLine(a.viewportY+n);if(!l)return null;const u=l.translateToString(!0).indexOf("\u2503");return u>=0?{row:n,col:u}:null}catch{return null}}}):t.mode==="shell"?(this._localEchoOverlay.clear(),this._localEchoEnabled=!1):this._localEchoOverlay.setPrompt({type:"custom",offset:0,find:o=>{try{const a=o.buffer.active;for(let n=o.rows-1;n>=0;n--){const l=a.getLine(a.viewportY+n);if(!l)continue;const u=l.translateToString(!0).lastIndexOf("\u276F");if(u>=0)return{row:n,col:u+2}}return{row:Math.max(0,Math.min(o.rows-1,a.cursorY)),col:Math.max(0,Math.min(o.cols-1,a.cursorX))}}catch{return null}}}))},_handleCjkInput(e){if(!this.activeSessionId){_crashDiag.log(`CJK send DROP no-session len=${e.length}`);return}_crashDiag.log(`CJK send\u2192${this.activeSessionId.slice(0,8)} len=${e.length}`),this._sendInputAsync(this.activeSessionId,e)},flushPendingWrites(){if(this.pendingWrites.length===0||!this.terminal)return;const e=performance.now(),t=this.pendingWrites.join("");this.pendingWrites=[];const s=t.length;s>16384&&_crashDiag.log(`FLUSH: ${(s/1024).toFixed(0)}KB`);const o=(this.activeSessionId&&this.sessions?this.sessions.get(this.activeSessionId):null)?.mode==="codex"?32768:65536;let a=!1;const n=this._hasRecentUserScrollUp()&&this.terminal.buffer?.active?this.terminal.buffer.active.viewportY:null;s<=o?this.terminal.write(t):(this.terminal.write(t.slice(0,o)),this.pendingWrites.push(t.slice(o)),a=!0,this.writeFrameScheduled||(this.writeFrameScheduled=!0,this._safeYield(()=>{this.flushPendingWrites(),this.writeFrameScheduled=!1}))),n!==null&&this.terminal.buffer?.active?.viewportY!==n&&typeof this.terminal.scrollToLine=="function"&&this.terminal.scrollToLine(n);const l=a?o:s,d=performance.now()-e;if((d>100||a)&&console.warn(`[CRASH-DIAG] flushPendingWrites: ${d.toFixed(0)}ms, ${(l/1024).toFixed(0)}KB written${a?", rest deferred":""} (total ${(s/1024).toFixed(0)}KB)`),this._wasAtBottomBeforeWrite&&!this._hasRecentUserScrollUp()&&this.terminal.scrollToBottom(),this._localEchoOverlay?.hasPending&&this._localEchoOverlay.rerender(),this._tabCompletionSessionId&&this._tabCompletionSessionId===this.activeSessionId&&this._localEchoOverlay&&!this._localEchoOverlay.pendingText){const u=this._localEchoOverlay,c=this;this.terminal.write("",()=>{if(!c._tabCompletionSessionId)return;u.resetBufferDetection();const m=u.detectBufferText();m?m===c._tabCompletionBaseText?(u.undoDetection(),c._tabCompletionRetries=(c._tabCompletionRetries||0)+1,c._tabCompletionRetries>60&&(c._tabCompletionSessionId=null,c._tabCompletionRetries=0)):(c._tabCompletionSessionId=null,c._tabCompletionRetries=0,c._tabCompletionBaseText=null,c._tabCompletionFallback&&(clearTimeout(c._tabCompletionFallback),c._tabCompletionFallback=null),u.rerender()):(c._tabCompletionRetries=(c._tabCompletionRetries||0)+1,c._tabCompletionRetries>60&&(c._tabCompletionSessionId=null,c._tabCompletionRetries=0))})}},_safeYield(e){let t=!1;const s=()=>{t||(t=!0,e())};requestAnimationFrame(s),setTimeout(s,50),this._workerYield(s)},_workerYield(e){try{if(this._yieldWorker===void 0){const t="onmessage=()=>setTimeout(()=>postMessage(0),0);",s=new Blob([t],{type:"application/javascript"}),i=URL.createObjectURL(s);this._yieldWorker=new Worker(i),URL.revokeObjectURL(i),this._yieldQueue=[],this._yieldWorker.onmessage=()=>{const o=this._yieldQueue.shift();o&&o()}}if(!this._yieldWorker)return;this._yieldQueue.push(e),this._yieldWorker.postMessage(0)}catch{this._yieldWorker=null}},scrollToLastNonEmptyLine(){if(!this.terminal?.buffer?.active){this.terminal?.scrollToBottom?.();return}const e=this.terminal.buffer.active,t=e.baseY+e.length;let s=-1;for(let i=t-1;i>=0;i--)if(e.getLine(i)?.translateToString(!0).trim()){s=i;break}if(s>=0&&typeof this.terminal.scrollToLine=="function"){let i=Math.max(0,s-this.terminal.rows+2);const o=Math.max(0,s);for(;i<o&&!e.getLine(i)?.translateToString(!0).trim();)i++;this.terminal.scrollToLine(i)}else this.terminal.scrollToBottom()},chunkedTerminalWrite(e,t=TERMINAL_CHUNK_SIZE,s){const i=++this._chunkedWriteGen,o=this._beginBufferLoad(s);return new Promise(a=>{if(!e||e.length===0){this._finishBufferLoad(o),a();return}const n=e.replace(DEC_SYNC_STRIP_RE,""),l=()=>{this._chunkedWriteGen===i&&this._finishBufferLoad(o),a()};if(n.length<=t){this.terminal.write(n,l);return}let d=0;const u=performance.now();let c=0;const m=()=>{if(this._chunkedWriteGen!==i){a();return}if(d>=n.length){const w=performance.now()-u;console.log(`[CRASH-DIAG] chunkedTerminalWrite complete: ${n.length} bytes in ${c} chunks, ${w.toFixed(0)}ms total`),this._safeYield(l);return}const y=performance.now(),E=n.slice(d,d+t);this.terminal.write(E);const x=performance.now()-y;c++,x>50&&console.warn(`[CRASH-DIAG] chunk #${c} write took ${x.toFixed(0)}ms (${E.length} bytes at offset ${d})`),d+=t,this._safeYield(m)};this._safeYield(m)})},_beginBufferLoad(e){this._bufferLoadSeq===void 0&&(this._bufferLoadSeq=0);const t=e===void 0?`buffer-${++this._bufferLoadSeq}`:e;return this._bufferLoadOwner=t,this._isLoadingBuffer=!0,this._loadBufferQueue=[],t},_finishBufferLoad(e,t){if(e!==void 0&&this._bufferLoadOwner!==e)return!1;const s=this._loadBufferQueue;if(this._isLoadingBuffer=!1,this._loadBufferQueue=null,this._bufferLoadOwner=null,t?.flushQueued&&s&&s.length)for(const i of s)this.batchTerminalWrite(i);return!0},clearTerminal(){this.terminal.clear()},async restoreTerminalSize(){if(!this.activeSessionId){this.showToast("No active session","warning");return}const e=this.getTerminalDimensions();if(!e){this.showToast("Could not determine terminal size","error");return}try{await this.sendResize(this.activeSessionId,{force:!0}),this.showToast(`Terminal restored to ${e.cols}x${e.rows}`,"success")}catch(t){console.error("Failed to restore terminal size:",t),this.showToast("Failed to restore terminal size","error")}},sendPendingCtrlL(e){},async copyTerminal(){try{const e=this.terminal.buffer.active;let t="";for(let s=0;s<e.length;s++){const i=e.getLine(s);i&&(t+=i.translateToString(!0)+`
2
+ `)}await navigator.clipboard.writeText(t.replace(/\n+$/,`
3
+ `)),this.showToast("Copied to clipboard","success")}catch{this.showToast("Failed to copy","error")}},_syncMobileHelperTextareaToCursor(){if(!(!MobileDetection.isTouchDevice()||!this.terminal?.element))try{const e=this.terminal.element,t=this.terminal.element.querySelector(".xterm-cursor"),s=this.terminal.element.querySelector(".xterm-screen");if(!(e instanceof HTMLElement)||!(t instanceof HTMLElement)||!(s instanceof HTMLElement))return;const i=t.getBoundingClientRect(),o=s.getBoundingClientRect();if(!i.width&&!i.height)return;const a=Math.max(0,Math.round(i.left-o.left)),n=Math.max(0,Math.round(i.top-o.top));e.style.setProperty("--xterm-helper-left",`${a}px`),e.style.setProperty("--xterm-helper-top",`${n}px`)}catch{}},_dispatchSyntheticTerminalClick(e,t){const s=this.terminal?.element;if(!s||!Number.isFinite(e)||!Number.isFinite(t))return;const i={bubbles:!0,cancelable:!0,view:window,clientX:e,clientY:t,screenX:e,screenY:t,button:0,detail:1};try{s.dispatchEvent(new MouseEvent("mousedown",{...i,buttons:1})),s.dispatchEvent(new MouseEvent("mouseup",{...i,buttons:0}))}catch{}},_sessionUsesServerMouseStrip(){const e=this.sessions?.get(this.activeSessionId)?.mode||"claude";return e==="claude"||e==="codex"||e==="gemini"},_terminalViewportAtBottom(){const e=this.terminal?.buffer?.active;return!e||e.viewportY>=e.baseY},_clientPointToCell(e,t){if(!this.terminal||!Number.isFinite(e)||!Number.isFinite(t))return null;const s=this.terminal.element?.querySelector(".xterm-screen"),i=this.terminal._core?._renderService?.dimensions?.css?.cell;if(!s||!i?.width||!i?.height)return null;const o=s.getBoundingClientRect(),a=Math.max(1,Math.min(this.terminal.cols,Math.floor((e-o.left)/i.width)+1)),n=Math.max(1,Math.min(this.terminal.rows,Math.floor((t-o.top)/i.height)+1));return{col:a,row:n}},_sendSyntheticSgrTap(e,t){if(!this.activeSessionId||!this._terminalViewportAtBottom())return;const s=this._clientPointToCell(e,t);s&&this._sendInputAsync(this.activeSessionId,`\x1B[<0;${s.col};${s.row}M\x1B[<0;${s.col};${s.row}m`)},_cliVersionAtLeast(e,t){if(typeof e!="string")return!1;const s=e.trim().replace(/^v/,"").split(".").map(Number);if(s.length!==3||s.some(o=>!Number.isFinite(o)))return!1;const i=t.split(".").map(Number);for(let o=0;o<3;o++)if(s[o]!==i[o])return s[o]>i[o];return!0},_wheelScrollLines(e){const t=e.shiftKey&&Math.abs(e.deltaX)>Math.abs(e.deltaY)?e.deltaX:e.deltaY;return Math.round(t/25)||(t>0?1:-1)},_shouldForwardWheelToApp(e){if(e.shiftKey||this.loadAppSettingsFromStorage?.()?.terminalWheelLocalScrollback)return!1;const t=this.terminal?.modes?.mouseTrackingMode;if(t&&t!=="none")return!1;const s=this.sessions?.get(this.activeSessionId),i=s?.mode||"claude";if(i==="claude"){if(!this._cliVersionAtLeast(s?.cliVersion,"2.1.187"))return!1}else if(i!=="codex")return!1;return this._terminalViewportAtBottom()},_sendSyntheticSgrWheel(e,t,s){if(!this.activeSessionId||!s)return;const i=this._clientPointToCell(e,t);if(!i)return;const o=s<0?64:65,a=Math.min(Math.abs(s),5),n=this._wheelSgrQueue||"";n.length>512||(this._wheelSgrQueue=n+`\x1B[<${o};${i.col};${i.row}M`.repeat(a),!this._wheelSgrFlushTimer&&(this._wheelSgrFlushTimer=setTimeout(()=>this._flushWheelSgrQueue(),40)))},_flushWheelSgrQueue(){this._wheelSgrFlushTimer=null;const e=this._wheelSgrQueue;this._wheelSgrQueue="",e&&this.activeSessionId&&this._sendInputEphemeral(this.activeSessionId,e)},_handleDesktopTerminalClick(e){if(!this.terminal||!e?.isTrusted||e.button!==0||e.detail!==1||e.shiftKey||e.altKey||e.ctrlKey||e.metaKey)return;const t=this.terminal.modes?.mouseTrackingMode;t&&t!=="none"||this._sessionUsesServerMouseStrip()&&(this.terminal.hasSelection?.()||this._linkHovered||performance.now()<=(this._trustedTapMouseSuppressUntil||0)||e.target?.closest?.(".xterm-screen")&&this._sendSyntheticSgrTap(e.clientX,e.clientY))},_installMobileTapMouseGuard(){const e=this.terminal?.element;if(!e||e._codemanTapMouseGuardInstalled||typeof MobileDetection<"u"&&MobileDetection.isTouchDevice&&!MobileDetection.isTouchDevice())return;e._codemanTapMouseGuardInstalled=!0;const t=s=>{const i=this._trustedTapMouseSuppressUntil||0;!s.isTrusted||performance.now()>i||(s.preventDefault(),s.stopImmediatePropagation())};e.addEventListener("mousedown",t,!0),e.addEventListener("mouseup",t,!0)},_suppressTrustedTapMouseEvents(){const e=window.CodemanTerminalInput?.TOUCH_COMPAT_MOUSE_SUPPRESS_MS||450;this._trustedTapMouseSuppressUntil=performance.now()+e},increaseFontSize(){const e=this.terminal.options.fontSize||14;this.setFontSize(Math.min(e+2,24))},decreaseFontSize(){const e=this.terminal.options.fontSize||14;this.setFontSize(Math.max(e-2,10))},setFontSize(e){this.terminal.options.fontSize=e,document.getElementById("fontSizeDisplay").textContent=e,this.fitAddon.fit(),localStorage.setItem("codeman-font-size",e),this._localEchoOverlay?.refreshFont()},loadFontSize(){const e=localStorage.getItem("codeman-font-size");if(e){const t=parseInt(e,10);t>=10&&t<=24&&(this.terminal.options.fontSize=t,document.getElementById("fontSizeDisplay").textContent=t)}},getTerminalDimensions(){const s=this.fitAddon?.proposeDimensions();return s?{cols:Math.max(s.cols,40),rows:Math.max(s.rows,10)}:null},async sendResize(e,t={}){this.fitAddon&&this.fitAddon.fit();const s=this.getTerminalDimensions();if(!s)return!1;const i=this._lastResizeDims,o=!i||i.cols!==s.cols||i.rows!==s.rows;this._lastResizeDims={cols:s.cols,rows:s.rows};const a=typeof MobileDetection<"u"&&MobileDetection.getDeviceType?MobileDetection.getDeviceType():window.innerWidth<430?"mobile":window.innerWidth<768?"tablet":"desktop";if(!t.forceHttp&&this._wsReady&&this._wsSessionId===e)try{const l={t:"z",c:s.cols,r:s.rows,v:a};return t.force&&(l.f=!0),this._ws.send(JSON.stringify(l)),o}catch{}const n={...s,viewportType:a};return t.force&&(n.force=!0),await fetch(`/api/sessions/${e}/resize`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)}),o},async sendInput(e){!this.activeSessionId||!e||this._sendInputAsync(this.activeSessionId,e,{useMux:!0})},toggleDirInput(){const e=document.querySelector("#dirDisplay").parentElement,t=document.getElementById("dirInput");t.classList.contains("hidden")&&(t.classList.remove("hidden"),e.style.display="none",t.focus())},hideDirInput(){const e=document.querySelector("#dirDisplay").parentElement,t=document.getElementById("dirInput");setTimeout(()=>{t.classList.add("hidden"),e.style.display="";const s=t.value.trim();document.getElementById("dirDisplay").textContent=s||"No directory"},100)},applyTerminalSkin(e){const t={...window.CODEMAN_XTERM_THEMES[e]||window.CODEMAN_XTERM_THEMES["daylight-blue"]},s=window.codemanCurrentSkinIsLight(e)?4.5:1;if(this.terminal){this.terminal.options.minimumContrastRatio=s,this.terminal.options.theme=t,this._localEchoOverlay?.refreshFont();try{this.terminal.refresh(0,this.terminal.rows-1)}catch{}}if(this.teammateTerminals){for(const[,i]of this.teammateTerminals)if(i&&i.terminal){i.terminal.options.minimumContrastRatio=s,i.terminal.options.theme={...t};try{i.terminal.refresh(0,i.terminal.rows-1)}catch{}}}}}),(function(e){const i={session:"Sessions",event:"Events",file:"Files"};function o(a){if(!Number.isFinite(a))return"";const n=new Date(a);return n.toLocaleDateString("en",{month:"short",day:"numeric"})+" "+n.toLocaleTimeString("en",{hour:"2-digit",minute:"2-digit",hour12:!1})}e.CodemanSearch={SEARCH_DEBOUNCE_MS:250,SEARCH_LIMIT:60,SOURCE_LABELS:i,formatSearchTime:o}})(window),Object.assign(CodemanApp.prototype,{initSearchPanel(){const e=document.getElementById("searchInput");if(!e||this._searchPanelWired){this._searchPanelWired&&this._populateSearchCaseFilter();return}this._searchPanelWired=!0,this._searchTypes=new Set(["session","event","file"]),this._searchSecondary={caseLabel:"",status:"",days:""},this._searchDebounceTimer=null,this._searchSeq=0,this._searchLastData=null;const t=document.getElementById("searchClearBtn"),s=document.getElementById("searchResults");e.addEventListener("input",()=>{t&&(t.hidden=e.value.length===0),this._scheduleSearch()}),e.addEventListener("keydown",n=>{n.key==="Escape"&&e.value&&(n.stopPropagation(),this._clearSearch())}),t&&t.addEventListener("click",()=>this._clearSearch()),document.querySelectorAll("#searchFilters .search-filter-chip").forEach(n=>{n.addEventListener("click",()=>{const l=n.dataset.typeFilter;this._searchTypes.has(l)&&this._searchTypes.size===1||(this._searchTypes.has(l)?(this._searchTypes.delete(l),n.classList.remove("active")):(this._searchTypes.add(l),n.classList.add("active")),this._runSearch())})});const i=document.getElementById("searchCaseFilter"),o=document.getElementById("searchStatusFilter"),a=document.getElementById("searchDateFilter");i&&i.addEventListener("change",()=>{this._searchSecondary.caseLabel=i.value,this._renderSearch(this._searchLastData)}),o&&o.addEventListener("change",()=>{this._searchSecondary.status=o.value,this._renderSearch(this._searchLastData)}),a&&a.addEventListener("change",()=>{this._searchSecondary.days=a.value,this._renderSearch(this._searchLastData)}),this._populateSearchCaseFilter(),s&&(s.hidden=!0)},_populateSearchCaseFilter(){const e=document.getElementById("searchCaseFilter");if(!e)return;const t=Array.isArray(this.cases)?this.cases:[],s=Array.from(new Set(t.map(a=>a&&a.name).filter(Boolean))).sort(),i=e.value;e.innerHTML="";const o=document.createElement("option");o.value="",o.textContent="All cases",e.appendChild(o);for(const a of s){const n=document.createElement("option");n.value=a,n.textContent="#"+a,e.appendChild(n)}i&&s.includes(i)&&(e.value=i)},_scheduleSearch(){clearTimeout(this._searchDebounceTimer),this._searchDebounceTimer=setTimeout(()=>this._runSearch(),window.CodemanSearch.SEARCH_DEBOUNCE_MS)},_clearSearch(){const e=document.getElementById("searchInput"),t=document.getElementById("searchClearBtn");e&&(e.value=""),t&&(t.hidden=!0),this._searchLastData=null,this._renderSearch(null)},async _runSearch(){const e=document.getElementById("searchInput");if(!e)return;const t=e.value.trim();if(t.length===0){this._searchLastData=null,this._renderSearch(null);return}const s=Array.from(this._searchTypes),i=new URLSearchParams;i.set("q",t.slice(0,200)),s.length>0&&s.length<3&&i.set("types",s.join(",")),i.set("limit",String(window.CodemanSearch.SEARCH_LIMIT));const o=++this._searchSeq,a=await this._apiJson("/api/search?"+i.toString());o===this._searchSeq&&(a?this._searchLastData=a:this._searchLastData={query:t,groups:[],totalResults:0,truncated:!1,_error:!0},this._renderSearch(this._searchLastData))},_applySecondaryFilters(e){const{caseLabel:t,status:s,days:i}=this._searchSecondary;let o=e;if(t){const a="#"+t;o=o.filter(n=>(n.sessionName||"").includes(a)||n.sessionName===t)}if(s){const a=new Set((this.sessionOrder||[]).concat(Object.keys(this.sessions||{})));o=o.filter(n=>{const l=a.has(n.sessionId);return s==="active"?l:!l})}if(i){const a=Date.now()-Number(i)*24*60*60*1e3;o=o.filter(n=>Number.isFinite(n.timestamp)&&n.timestamp>=a)}return o},_renderSearch(e){const t=document.getElementById("searchResults"),s=document.getElementById("historyTitle"),i=document.getElementById("historyList");if(!t)return;const o=!!e;if(s&&(s.style.display=o?"none":""),i&&(i.style.display=o?"none":""),t.innerHTML="",!e){t.hidden=!0;return}if(t.hidden=!1,e._error){const l=document.createElement("div");l.className="search-empty",l.textContent="Search unavailable \u2014 check the query and try again.",t.appendChild(l);return}const a=(e.groups||[]).map(l=>({type:l.type,results:this._applySecondaryFilters(l.results||[])})).filter(l=>l.results.length>0);if(a.reduce((l,d)=>l+d.results.length,0)===0){const l=document.createElement("div");l.className="search-empty",l.textContent='No results for "'+(e.query||"")+'"',t.appendChild(l);return}for(const l of a){const d=document.createElement("div");d.className="search-group-header";const u=document.createElement("span");u.className="search-group-label",u.textContent=window.CodemanSearch.SOURCE_LABELS[l.type]||l.type;const c=document.createElement("span");c.className="search-group-count",c.textContent=String(l.results.length),d.append(u,c),t.appendChild(d);for(const m of l.results)t.appendChild(this._buildSearchResultCard(m))}if(e.truncated){const l=document.createElement("div");l.className="search-truncated",l.textContent="Showing the top matches \u2014 refine your search to narrow results.",t.appendChild(l)}},_buildSearchResultCard(e){const t=document.createElement("div");t.className="search-result-card",t.dataset.type=e.type,t.tabIndex=0,t.setAttribute("role","button");const s=document.createElement("div");s.className="search-result-top";const i=document.createElement("span");i.className="search-result-badge search-badge-"+e.type,i.textContent=(window.CodemanSearch.SOURCE_LABELS[e.type]||e.type).replace(/s$/,"");const o=document.createElement("span");o.className="search-result-name",o.textContent=e.sessionName||e.sessionId||"(session)";const a=document.createElement("span");a.className="search-result-time",a.textContent=window.CodemanSearch.formatSearchTime(e.timestamp),s.append(i,o,a);const n=document.createElement("div");n.className="search-result-snippet",n.textContent=e.snippet||"",t.append(s,n);const l=()=>this._jumpToSearchResult(e);return t.addEventListener("click",l),t.addEventListener("keydown",d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),l())}),t},_jumpToSearchResult(e){const t=e&&e.jumpTo;if(t){typeof this.hideWelcome=="function"&&this.hideWelcome();try{t.kind==="run-summary"?this.openRunSummary(t.sessionId):t.kind==="file-preview"?this.openFilePreview(t.relativePath||"",t.sessionId,t.targetId||null):this.selectSession(t.sessionId)}catch(s){console.error("[search] jump failed",s)}}}});
Binary file
Binary file
@@ -0,0 +1,445 @@
1
+ /**
2
+ * @fileoverview Web tabs: saved dashboard URLs rendered as tabs beside agent
3
+ * sessions, so Codeman is one mission control instead of Codeman plus a pile of
4
+ * browser tabs.
5
+ *
6
+ * Each open dashboard is an <iframe> inside #webviewLayer, which covers the
7
+ * terminal while a web tab is active. Frames stay MOUNTED while hidden, because a
8
+ * dashboard that reloads and re-authenticates on every tab switch is worse than
9
+ * the browser tab it replaced. `maxLiveFrames` (from the server) bounds that with
10
+ * least-recently-viewed eviction.
11
+ *
12
+ * Sandboxing: a proxied dashboard is served from Codeman's own origin, so the
13
+ * iframe deliberately omits `allow-same-origin` unless the dashboard is marked
14
+ * trusted. Without that omission the page could read this document and call the
15
+ * API that spawns agents.
16
+ *
17
+ * @mixin Extends CodemanApp.prototype via Object.assign
18
+ * @dependency app.js, api-client.js, constants.js (escapeHtml)
19
+ * @loadorder 12.5 of 16, after session-ui.js (needs the tab strip), before api-client.js
20
+ */
21
+
22
+ Object.assign(CodemanApp.prototype, {
23
+ // ── State ─────────────────────────────────────────────────────────────────
24
+
25
+ /** Load the saved list and restore which tabs were open. */
26
+ async initWebviews() {
27
+ this.webviews = this.webviews || new Map();
28
+ this.webviewOrder = this.webviewOrder || [];
29
+ this.activeWebviewId = this.activeWebviewId || null;
30
+ this._webviewMaxFrames = this._webviewMaxFrames || 6;
31
+ this._webviewFrameLru = this._webviewFrameLru || [];
32
+
33
+ await this.refreshWebviews();
34
+
35
+ // Restore the previously open web tabs (per device: which dashboards you keep
36
+ // open is a workspace-layout choice, not something to sync across machines).
37
+ let saved = [];
38
+ try {
39
+ saved = JSON.parse(localStorage.getItem('codeman-webview-order') || '[]');
40
+ } catch {
41
+ saved = [];
42
+ }
43
+ this.webviewOrder = saved.filter((id) => this.webviews.has(id));
44
+ this.renderSessionTabs();
45
+ },
46
+
47
+ async refreshWebviews() {
48
+ const data = await this._apiJson('/api/webviews');
49
+ if (!data) return;
50
+ this.webviews = new Map((data.webviews || []).map((w) => [w.id, w]));
51
+ if (typeof data.maxLiveFrames === 'number') this._webviewMaxFrames = data.maxLiveFrames;
52
+ this.renderWebviewMenuItems();
53
+ },
54
+
55
+ /** SSE: the saved list changed (possibly on another device). */
56
+ async _onWebviewChanged(data) {
57
+ await this.refreshWebviews();
58
+ // A dashboard deleted elsewhere must not linger as a dead tab here.
59
+ if (data && data.action === 'deleted' && data.id) this._removeWebviewTab(data.id);
60
+ this.renderSessionTabs();
61
+ },
62
+
63
+ _persistWebviewOrder() {
64
+ try {
65
+ localStorage.setItem('codeman-webview-order', JSON.stringify(this.webviewOrder || []));
66
+ } catch {
67
+ /* private mode / quota, order is a convenience, never fatal */
68
+ }
69
+ },
70
+
71
+ // ── Tab strip ─────────────────────────────────────────────────────────────
72
+
73
+ /**
74
+ * Tab HTML for every OPEN web tab, appended by _fullRenderSessionTabs().
75
+ * `startIndex` continues the Alt+N numbering after the session tabs.
76
+ */
77
+ renderWebviewTabs(startIndex) {
78
+ if (!this.webviewOrder || this.webviewOrder.length === 0) return '';
79
+ const parts = [];
80
+ let idx = startIndex;
81
+
82
+ for (const id of this.webviewOrder) {
83
+ const webview = this.webviews.get(id);
84
+ if (!webview) continue;
85
+ const isActive = id === this.activeWebviewId;
86
+ const jsonId = escapeHtml(JSON.stringify(id));
87
+ const icon = webview.icon ? escapeHtml(webview.icon) : '';
88
+
89
+ parts.push(`<div class="session-tab session-tab--web ${isActive ? 'active' : ''}" data-webview-id="${escapeHtml(id)}"
90
+ onclick="app.handleWebviewTabClick(event, ${jsonId})"
91
+ tabindex="0" role="tab" aria-selected="${isActive ? 'true' : 'false'}"
92
+ aria-label="${escapeHtml(webview.name)} web tab" title="${escapeHtml(webview.url)}">
93
+ ${idx < 9 ? '<span class="tab-number">' + (idx + 1) + '</span>' : ''}
94
+ <span class="tab-web-icon" aria-hidden="true">${icon || this._webviewGlobeIcon()}</span>
95
+ <span class="tab-info">
96
+ <span class="tab-name-row">
97
+ <span class="tab-name">${escapeHtml(webview.name)}</span>
98
+ </span>
99
+ </span>
100
+ <span class="tab-gear" onclick="event.stopPropagation(); app.showWebviewModal(${jsonId})" title="URL settings" aria-label="URL settings" tabindex="0">&#x2699;</span>
101
+ <span class="tab-close" onclick="event.stopPropagation(); app.closeWebviewTab(${jsonId})" title="Close tab" aria-label="Close web tab" tabindex="0">&times;</span>
102
+ </div>`);
103
+ idx++;
104
+ }
105
+ return parts.join('');
106
+ },
107
+
108
+ _webviewGlobeIcon() {
109
+ return '<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><path d="M2 12h20M12 2a15 15 0 0 1 0 20 15 15 0 0 1 0-20"/></svg>';
110
+ },
111
+
112
+ handleWebviewTabClick(event, id) {
113
+ event?.preventDefault?.();
114
+ return this.openWebview(id);
115
+ },
116
+
117
+ /** Mark exactly one tab active across BOTH tab kinds. */
118
+ _updateActiveWebviewTab() {
119
+ const container = this.$('sessionTabs');
120
+ if (!container) return;
121
+ for (const tab of container.querySelectorAll('.session-tab[data-webview-id]')) {
122
+ tab.classList.toggle('active', tab.dataset.webviewId === this.activeWebviewId);
123
+ }
124
+ if (this.activeWebviewId) {
125
+ // A web tab is active, so no session tab may also look active.
126
+ for (const tab of container.querySelectorAll('.session-tab[data-id]')) tab.classList.remove('active');
127
+ }
128
+ },
129
+
130
+ // ── Opening / closing ─────────────────────────────────────────────────────
131
+
132
+ /**
133
+ * Open (or focus) a dashboard tab. Mints a fresh capability every time: they are
134
+ * memory-only and expire, so a tab reopened after a server restart must not reuse
135
+ * the dead URL from the previous run.
136
+ */
137
+ async openWebview(id) {
138
+ const webview = this.webviews.get(id);
139
+ if (!webview) return;
140
+
141
+ if (!this.webviewOrder.includes(id)) {
142
+ this.webviewOrder.push(id);
143
+ this._persistWebviewOrder();
144
+ }
145
+
146
+ const data = await this._apiJson(`/api/webviews/${encodeURIComponent(id)}/open`, { method: 'POST' });
147
+ if (!data) {
148
+ this.showToast?.('Could not open URL', 'error');
149
+ return;
150
+ }
151
+ if (data.webview) this.webviews.set(id, data.webview);
152
+
153
+ const src = data.embedUrl || data.webview?.url || webview.url;
154
+ this._mountWebviewFrame(id, src, data.webview || webview);
155
+ this.activeWebviewId = id;
156
+ this.hideWelcome?.();
157
+ document.querySelector('.main')?.classList.add('webview-active');
158
+ this.renderSessionTabs();
159
+ this._updateActiveWebviewTab();
160
+ },
161
+
162
+ /** Create the frame if absent, then reveal it and hide its siblings. */
163
+ _mountWebviewFrame(id, src, webview) {
164
+ const layer = document.getElementById('webviewLayer');
165
+ if (!layer) return;
166
+
167
+ let wrap = layer.querySelector(`.webview-frame[data-webview-id="${CSS.escape(id)}"]`);
168
+ if (!wrap) {
169
+ wrap = document.createElement('div');
170
+ wrap.className = 'webview-frame';
171
+ wrap.dataset.webviewId = id;
172
+
173
+ const frame = document.createElement('iframe');
174
+ frame.className = 'webview-iframe';
175
+ frame.setAttribute('title', webview.name);
176
+ // No allow-same-origin unless explicitly trusted: a proxied page is served
177
+ // from THIS origin, so granting it would let the dashboard read this document
178
+ // and drive the Codeman API.
179
+ const sandbox = ['allow-scripts', 'allow-forms', 'allow-popups', 'allow-downloads', 'allow-modals'];
180
+ if (webview.trusted) sandbox.push('allow-same-origin');
181
+ frame.setAttribute('sandbox', sandbox.join(' '));
182
+ frame.setAttribute('referrerpolicy', 'no-referrer-when-downgrade');
183
+ frame.src = src;
184
+
185
+ const failure = document.createElement('div');
186
+ failure.className = 'webview-failure';
187
+ failure.innerHTML = this._webviewFailureHtml(id);
188
+
189
+ wrap.appendChild(frame);
190
+ wrap.appendChild(failure);
191
+ layer.appendChild(wrap);
192
+
193
+ // A frame that never fires `load` is the normal symptom of a refused embed or
194
+ // an unreachable host. Show an actionable panel instead of a blank rectangle.
195
+ const timer = setTimeout(() => wrap.classList.add('webview-frame--failed'), 8000);
196
+ frame.addEventListener('load', () => {
197
+ clearTimeout(timer);
198
+ wrap.classList.remove('webview-frame--failed');
199
+ });
200
+ }
201
+
202
+ this._touchWebviewFrame(id);
203
+ for (const other of layer.querySelectorAll('.webview-frame')) {
204
+ other.classList.toggle('active', other.dataset.webviewId === id);
205
+ }
206
+ // Chart libraries measure on resize; a frame revealed from display:none needs the nudge.
207
+ requestAnimationFrame(() => window.dispatchEvent(new Event('resize')));
208
+ },
209
+
210
+ _webviewFailureHtml(id) {
211
+ const jsonId = escapeHtml(JSON.stringify(id));
212
+ return `<div class="webview-failure-inner">
213
+ <h3>This URL did not load</h3>
214
+ <p>It may be unreachable from the Codeman server, or it may refuse to be embedded.</p>
215
+ <div class="webview-failure-actions">
216
+ <button class="btn-secondary" onclick="app.reloadWebview(${jsonId})">Reload</button>
217
+ <button class="btn-secondary" onclick="app.openWebviewExternal(${jsonId})">Open in new tab</button>
218
+ <button class="btn-secondary" onclick="app.showWebviewModal(${jsonId})">Edit</button>
219
+ </div>
220
+ </div>`;
221
+ },
222
+
223
+ /** Least-recently-viewed eviction so N open dashboards cannot pin N live pages. */
224
+ _touchWebviewFrame(id) {
225
+ this._webviewFrameLru = (this._webviewFrameLru || []).filter((x) => x !== id);
226
+ this._webviewFrameLru.push(id);
227
+ const layer = document.getElementById('webviewLayer');
228
+ if (!layer) return;
229
+ while (this._webviewFrameLru.length > this._webviewMaxFrames) {
230
+ const evict = this._webviewFrameLru.shift();
231
+ if (evict === this.activeWebviewId) continue;
232
+ layer.querySelector(`.webview-frame[data-webview-id="${CSS.escape(evict)}"]`)?.remove();
233
+ }
234
+ },
235
+
236
+ reloadWebview(id) {
237
+ const target = id || this.activeWebviewId;
238
+ if (!target) return;
239
+ document
240
+ .getElementById('webviewLayer')
241
+ ?.querySelector(`.webview-frame[data-webview-id="${CSS.escape(target)}"]`)
242
+ ?.remove();
243
+ this._webviewFrameLru = (this._webviewFrameLru || []).filter((x) => x !== target);
244
+ return this.openWebview(target);
245
+ },
246
+
247
+ openWebviewExternal(id) {
248
+ const webview = this.webviews.get(id || this.activeWebviewId);
249
+ if (webview) window.open(webview.url, '_blank', 'noopener');
250
+ },
251
+
252
+ closeWebviewTab(id) {
253
+ this._removeWebviewTab(id);
254
+ this.renderSessionTabs();
255
+ },
256
+
257
+ _removeWebviewTab(id) {
258
+ this.webviewOrder = (this.webviewOrder || []).filter((x) => x !== id);
259
+ this._webviewFrameLru = (this._webviewFrameLru || []).filter((x) => x !== id);
260
+ this._persistWebviewOrder();
261
+ document
262
+ .getElementById('webviewLayer')
263
+ ?.querySelector(`.webview-frame[data-webview-id="${CSS.escape(id)}"]`)
264
+ ?.remove();
265
+
266
+ if (this.activeWebviewId === id) {
267
+ this.activeWebviewId = null;
268
+ const next = this.webviewOrder[0];
269
+ if (next) {
270
+ this.openWebview(next);
271
+ } else {
272
+ this._hideWebviewLayer();
273
+ // Fall back to whatever session was last shown, or the welcome screen.
274
+ if (this.activeSessionId) this._updateActiveTabImmediate(this.activeSessionId);
275
+ else this.showWelcome?.();
276
+ }
277
+ }
278
+ },
279
+
280
+ /** Called by selectSession(): a session tab takes the stage back from a web tab. */
281
+ _hideWebviewLayer() {
282
+ if (!this.activeWebviewId && !document.querySelector('.main.webview-active')) return;
283
+ this.activeWebviewId = null;
284
+ document.querySelector('.main')?.classList.remove('webview-active');
285
+ for (const frame of document.querySelectorAll('#webviewLayer .webview-frame')) {
286
+ frame.classList.remove('active');
287
+ }
288
+ this._updateActiveWebviewTab();
289
+ },
290
+
291
+ // ── Run-menu entries ──────────────────────────────────────────────────────
292
+
293
+ /** Saved dashboards listed inside the Run dropdown, under "Web / URL". */
294
+ renderWebviewMenuItems() {
295
+ const container = document.getElementById('runModeWebviews');
296
+ if (!container) return;
297
+ const list = [...(this.webviews?.values() || [])];
298
+ if (list.length === 0) {
299
+ container.innerHTML = '<div class="run-mode-empty">No URLs yet</div>';
300
+ return;
301
+ }
302
+ container.innerHTML = list
303
+ .map(
304
+ (w) => `<button class="run-mode-option run-mode-option--web" onclick="app.openWebviewFromMenu(${escapeHtml(
305
+ JSON.stringify(w.id)
306
+ )})" title="${escapeHtml(w.url)}">
307
+ <span class="run-mode-menu-icon">${w.icon ? escapeHtml(w.icon) : '<span class="run-mode-dot web"></span>'}</span>${escapeHtml(
308
+ w.name
309
+ )}
310
+ </button>`
311
+ )
312
+ .join('');
313
+ },
314
+
315
+ openWebviewFromMenu(id) {
316
+ document.getElementById('runModeMenu')?.classList.remove('active');
317
+ return this.openWebview(id);
318
+ },
319
+
320
+ // ── Icon picker ───────────────────────────────────────────────────────────
321
+
322
+ /** Common dashboard/service glyphs. The text field stays open for anything else. */
323
+ _webviewIconChoices() {
324
+ return ['📊', '📈', '🖥️', '🎛️', '📡', '🐳', '🗄️', '🔒', '🌐', '📁', '🧪', '🧬', '⚡', '🔔', '📝', '🎧'];
325
+ },
326
+
327
+ _renderWebviewIconPicker(selected) {
328
+ const picker = document.getElementById('webviewIconPicker');
329
+ if (!picker) return;
330
+ picker.innerHTML = this._webviewIconChoices()
331
+ .map(
332
+ (icon) =>
333
+ `<button type="button" class="webview-icon-choice${icon === selected ? ' selected' : ''}"
334
+ onclick="app.pickWebviewIcon(${escapeHtml(JSON.stringify(icon))})"
335
+ aria-label="Use ${escapeHtml(icon)} as the icon">${escapeHtml(icon)}</button>`
336
+ )
337
+ .join('');
338
+ },
339
+
340
+ /** Clicking the selected icon again clears it, so there is a way back to no icon. */
341
+ pickWebviewIcon(icon) {
342
+ const field = document.getElementById('webviewIcon');
343
+ if (!field) return;
344
+ field.value = field.value === icon ? '' : icon;
345
+ this._renderWebviewIconPicker(field.value);
346
+ },
347
+
348
+ // ── Editor modal ──────────────────────────────────────────────────────────
349
+
350
+ showWebviewModal(id) {
351
+ const modal = document.getElementById('webviewModal');
352
+ if (!modal) return;
353
+ const webview = id ? this.webviews.get(id) : null;
354
+ this._editingWebviewId = webview ? webview.id : null;
355
+
356
+ document.getElementById('webviewModalTitle').textContent = webview ? 'Edit URL' : 'Add URL';
357
+ this._renderWebviewIconPicker(webview?.icon || '');
358
+ document.getElementById('webviewName').value = webview?.name || '';
359
+ document.getElementById('webviewUrl').value = webview?.url || '';
360
+ document.getElementById('webviewIcon').value = webview?.icon || '';
361
+ document.getElementById('webviewSandboxed').checked = !webview?.trusted;
362
+ document.getElementById('webviewProbeResult').textContent = '';
363
+ document.getElementById('webviewDeleteBtn').style.display = webview ? '' : 'none';
364
+
365
+ document.getElementById('runModeMenu')?.classList.remove('active');
366
+ modal.classList.add('active');
367
+ document.getElementById('webviewName').focus();
368
+ },
369
+
370
+ closeWebviewModal() {
371
+ document.getElementById('webviewModal')?.classList.remove('active');
372
+ this._editingWebviewId = null;
373
+ },
374
+
375
+ /** Server-side probe: it runs from the network position the proxy will use. */
376
+ async testWebviewUrl() {
377
+ const url = document.getElementById('webviewUrl').value.trim();
378
+ const out = document.getElementById('webviewProbeResult');
379
+ if (!url) {
380
+ out.textContent = 'Enter a URL first.';
381
+ return;
382
+ }
383
+ out.textContent = 'Testing...';
384
+ const probe = await this._apiJson('/api/webviews/probe', { method: 'POST', body: { url } });
385
+ if (!probe) {
386
+ out.textContent = 'Test failed (invalid URL?).';
387
+ return;
388
+ }
389
+ out.textContent = probe.reachable
390
+ ? `Reachable (HTTP ${probe.status}). ${probe.reason}`
391
+ : `Not reachable. ${probe.reason}`;
392
+ out.className = 'form-hint webview-probe-result ' + (probe.reachable ? 'ok' : 'bad');
393
+ },
394
+
395
+ async saveWebview() {
396
+ const name = document.getElementById('webviewName').value.trim();
397
+ const url = document.getElementById('webviewUrl').value.trim();
398
+ const icon = document.getElementById('webviewIcon').value.trim();
399
+ const trusted = !document.getElementById('webviewSandboxed').checked;
400
+ if (!name || !url) {
401
+ this.showToast?.('Name and URL are required', 'error');
402
+ return;
403
+ }
404
+
405
+ // `icon: undefined` rather than null, the schema uses .optional(), which
406
+ // rejects an explicit null on the wire.
407
+ const body = { name, url, icon: icon || undefined, trusted };
408
+ const editing = this._editingWebviewId;
409
+ const data = editing
410
+ ? await this._apiJson(`/api/webviews/${encodeURIComponent(editing)}`, { method: 'PATCH', body })
411
+ : await this._apiJson('/api/webviews', { method: 'POST', body });
412
+
413
+ if (!data) {
414
+ this.showToast?.('Could not save (check the URL)', 'error');
415
+ return;
416
+ }
417
+
418
+ await this.refreshWebviews();
419
+ this.closeWebviewModal();
420
+ if (editing) {
421
+ // The capability was revoked server-side by the edit, so a mounted frame is
422
+ // now pointing at a dead URL. Remount it.
423
+ if (this.webviewOrder.includes(editing)) this.reloadWebview(editing);
424
+ } else {
425
+ this.openWebview(data.id);
426
+ }
427
+ },
428
+
429
+ async deleteWebview() {
430
+ const id = this._editingWebviewId;
431
+ if (!id) return;
432
+ const webview = this.webviews.get(id);
433
+ if (!confirm(`Delete "${webview?.name || id}"?`)) return;
434
+ const res = await this._apiDelete(`/api/webviews/${encodeURIComponent(id)}`);
435
+ if (!res || !res.ok) {
436
+ this.showToast?.('Could not delete URL', 'error');
437
+ return;
438
+ }
439
+ this._removeWebviewTab(id);
440
+ this.webviews.delete(id);
441
+ this.closeWebviewModal();
442
+ this.renderWebviewMenuItems();
443
+ this.renderSessionTabs();
444
+ },
445
+ });
@@ -21,4 +21,5 @@ export { registerSearchRoutes } from './search-routes.js';
21
21
  export { registerMeRoutes } from './me-routes.js';
22
22
  export { registerAdminRoutes } from './admin-routes.js';
23
23
  export { registerWsRoutes } from './ws-routes.js';
24
+ export { registerWebviewRoutes, tryWebviewRefererFallback } from './webview-routes.js';
24
25
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/web/routes/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,6BAA6B,EAAE,MAAM,8BAA8B,CAAC;AAC7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/web/routes/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,6BAA6B,EAAE,MAAM,8BAA8B,CAAC;AAC7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC"}