@openchambery/web 1.17.1-beta.8 → 1.17.1

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 (43) hide show
  1. package/dist/assets/{AssistantView-ZlXc0xFT.js → AssistantView-CbnxMZU0.js} +1 -1
  2. package/dist/assets/{ChatContainer-BXFy3Uu2.js → ChatContainer-DEDGosbz.js} +36 -36
  3. package/dist/assets/{DiagramView-CgotrQyK.js → DiagramView-Byxhaduz.js} +1 -1
  4. package/dist/assets/{MarkdownRendererImpl-Cj4y0P0S.js → MarkdownRendererImpl-Cv8V-Q5l.js} +1 -1
  5. package/dist/assets/{MobileDetailNavigation-5tAL5d_M.js → MobileDetailNavigation-lVtCe-5P.js} +1 -1
  6. package/dist/assets/{MobileShareBridge-BL7Ehxhd.js → MobileShareBridge-DAlvgjo1.js} +1 -1
  7. package/dist/assets/MobileSurface-Bde8yLWo.js +2 -0
  8. package/dist/assets/{MultiRunWindow-Che7L3TX.js → MultiRunWindow-1kkKTh4h.js} +1 -1
  9. package/dist/assets/{OverlayScrollbar-C2pEDFq-.js → OverlayScrollbar-Dqk1zGJB.js} +1 -1
  10. package/dist/assets/{SettingsView-D0p-e8Px.js → SettingsView-D0dhTIur.js} +1 -1
  11. package/dist/assets/{SettingsWindow-KYhsFUrb.js → SettingsWindow-DMQMRgc3.js} +1 -1
  12. package/dist/assets/{TerminalView-Da5aLqHR.js → TerminalView-jYq0JQPc.js} +1 -1
  13. package/dist/assets/{ToolOutputDialog-DZI4uxx3.js → ToolOutputDialog-DJefd2N6.js} +1 -1
  14. package/dist/assets/appThemeRegistry-BXeIggYO.js +2 -0
  15. package/dist/assets/{context-menu-BXH0AcOc.js → context-menu-BbRpMBQh.js} +1 -1
  16. package/dist/assets/{gitApi-BW5AFgD1.js → gitApi-Bs_2iBAm.js} +1 -1
  17. package/dist/assets/{insertionBoundaries-D4KbXFFj.js → insertionBoundaries-BAFtAotq.js} +1 -1
  18. package/dist/assets/{main-CcyyPAib.js → main-CT0DuuLm.js} +2 -2
  19. package/dist/assets/{main-DzxdsF_k.js → main-G8tKFcTV.js} +3 -3
  20. package/dist/assets/{miniChat-BsNf9y48.js → miniChat-BP3OHqNF.js} +2 -2
  21. package/dist/assets/{mobile-CsJg2IAq.js → mobile-BtwuDs-C.js} +2 -2
  22. package/dist/assets/{multirun-qs5hZkwM.js → multirun-B-L3JH60.js} +1 -1
  23. package/dist/assets/{projectMeta-1SSTNg8w.js → projectMeta-Cp74cItv.js} +1 -1
  24. package/dist/assets/{radio-DBJG9Dd1.js → radio-Bs4mdPv5.js} +1 -1
  25. package/dist/assets/{renderElectronMiniChatApp-DOWE0jSA.js → renderElectronMiniChatApp-dgirEOtR.js} +2 -2
  26. package/dist/assets/{renderMobileApp-bklJJSZi.js → renderMobileApp-DK9qzy0P.js} +3 -3
  27. package/dist/assets/{runtimeEndpointReset-ix1NxqYw.js → runtimeEndpointReset-C0eCWIE6.js} +1 -1
  28. package/dist/assets/{sortable-tabs-strip-DncWjNx4.js → sortable-tabs-strip-oKJ700WG.js} +1 -1
  29. package/dist/assets/src-8zziWB78.css +2 -0
  30. package/dist/assets/{useAppFontEffects-B1EhZNex.js → useAppFontEffects-BhLcUfRB.js} +2 -2
  31. package/dist/assets/{useDesktopWindowControlsLayout-Dc69l-pm.js → useDesktopWindowControlsLayout-Cq5a2gcJ.js} +1 -1
  32. package/dist/assets/{useEffectiveDirectory-dCGvvYRh.js → useEffectiveDirectory-DG6uPzBG.js} +1 -1
  33. package/dist/assets/useMobileNavigationStore-1xHjnAsg.js +475 -0
  34. package/dist/assets/{useSessionAutoCleanup-D-r9oDye.js → useSessionAutoCleanup-BFletAeV.js} +1 -1
  35. package/dist/assets/{useWorkerHighlightedLines-05dLFgTI.js → useWorkerHighlightedLines-ADgu9578.js} +1 -1
  36. package/dist/index.html +2 -2
  37. package/dist/mini-chat.html +2 -2
  38. package/dist/mobile.html +2 -2
  39. package/package.json +1 -1
  40. package/dist/assets/MobileSurface-ByMnQ5rD.js +0 -2
  41. package/dist/assets/appThemeRegistry-DAgBeFsZ.js +0 -2
  42. package/dist/assets/src-B8mzksNL.css +0 -2
  43. package/dist/assets/useMobileNavigationStore-DhkIZBJw.js +0 -475
@@ -1,4 +1,4 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{c as t,s as n,t as r}from"./useUIStore-D6BTB4va.js";import{Xt as i,kn as a}from"./persistence-C_KCiMcY.js";import{nt as o,rt as s,tt as c}from"./vendor-base-ui-CnHfUmDN.js";import{o as l}from"./terminalApi-BYTA045F.js";import{n as u,r as d,t as f}from"./vendor-ghostty-web-HohRXr3g.js";import{n as ee,t as p}from"./clipboard-CXWbHCAk.js";import{l as m}from"./useMobileNavigationStore-DhkIZBJw.js";import{t as h}from"./utils-DyUyiLje.js";import{n as g}from"./Icon-BPJ_quEe.js";import{t as _}from"./button-BmNJBT13.js";import{n as v}from"./useThemeSystem-DMzWVJaW.js";import{i as y,t as b}from"./OverlayScrollbar-C2pEDFq-.js";import{n as te}from"./useRuntimeAPIs-DSLXJybW.js";import{n as x}from"./useEffectiveDirectory-dCGvvYRh.js";import{t as S}from"./sortable-tabs-strip-DncWjNx4.js";import{n as C,t as w}from"./useFontPreferences-Bu4ME5hk.js";import{r as T}from"./projectActions-CWvNGKfA.js";var E=e(s(),1);function ne(e){let{colors:t}=e,n=t.syntax.base;return{background:t.surface.background,foreground:n.foreground,cursor:t.interactive.cursor,cursorAccent:t.surface.background,selectionBackground:t.interactive.selection,selectionForeground:t.interactive.selectionForeground,selectionInactiveBackground:t.interactive.selection+`50`,black:t.surface.muted,red:t.status.error,green:t.status.success,yellow:t.status.warning,blue:n.function,magenta:n.keyword,cyan:n.type,white:n.foreground,brightBlack:n.comment,brightRed:t.status.error,brightGreen:t.status.success,brightYellow:t.status.warning,brightBlue:n.function,brightMagenta:n.keyword,brightCyan:n.type,brightWhite:t.surface.elevatedForeground}}function re(e,t,n,r,i=!1){return{cursorBlink:!1,cursorStyle:`bar`,fontSize:t,lineHeight:1.15,fontFamily:`${e}, "JetBrainsMonoNL Nerd Font", "FiraCode Nerd Font", "Cascadia Code PL", "Fira Code", "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", "Courier New", monospace`,allowTransparency:!1,theme:{background:n.background,foreground:n.foreground,cursor:n.cursor,cursorAccent:n.cursorAccent,selectionBackground:n.selectionBackground,selectionForeground:n.selectionForeground,black:n.black,red:n.red,green:n.green,yellow:n.yellow,blue:n.blue,magenta:n.magenta,cyan:n.cyan,white:n.white,brightBlack:n.brightBlack,brightRed:n.brightRed,brightGreen:n.brightGreen,brightYellow:n.brightYellow,brightBlue:n.brightBlue,brightMagenta:n.brightMagenta,brightCyan:n.brightCyan,brightWhite:n.brightWhite},scrollback:1e4,ghostty:r,disableStdin:i}}var ie=e(c(),1),D=o(),O=null;function k(){return O||=d.load(),O}function ae(e){if(typeof window>`u`)return null;let t=[e,...Array.from(e.querySelectorAll(`*`))],n=null;for(let e of t){let t=window.getComputedStyle(e).overflowY;if(t===`auto`||t===`scroll`){if(e.scrollHeight-e.clientHeight>2)return e;n||=e}}return n}var oe=E.forwardRef(({sessionKey:e,chunks:t,onInput:n,onResize:r,theme:i,fontFamily:a,fontSize:o,className:s,enableTouchScroll:c,autoFocus:l=!0,isVisible:d=!0},m)=>{let{t:g}=ee(),_=E.useRef(null),v=E.useRef(null),y=E.useRef(null),te=E.useRef(null),x=E.useRef(n),S=E.useRef(r),C=E.useRef(null),w=E.useRef(``),T=E.useRef(null),ne=E.useRef(!1),O=E.useRef(null),oe=E.useRef(!0),A=E.useRef(null),j=E.useRef(null),se=E.useRef(0),ce=E.useRef(null),M=E.useRef(null),N=E.useRef(!1),P=E.useRef(!1),le=E.useRef(null),ue=E.useRef(null),de=E.useRef(null),F=E.useRef(``),fe=E.useRef(null),pe=E.useRef(!c),me=E.useRef(d),[,he]=E.useReducer(e=>e+1,0),[ge,_e]=E.useReducer(e=>e+1,0);x.current=n,S.current=r;let ve=typeof navigator<`u`&&(/Android/i.test(navigator.userAgent)||navigator.userAgentData?.platform===`Android`),I=!!c;E.useEffect(()=>{if(!c){pe.current=!0,me.current=d;return}!me.current&&d&&(pe.current=!1),me.current=d},[c,d]);let ye=E.useCallback(()=>{if(!I)return;let e=_.current,t=ce.current;if(!e)return;let n=[];e.getAttribute(`contenteditable`)===`true`&&n.push(e),n.push(...Array.from(e.querySelectorAll(`[contenteditable="true"]`))),n.forEach(e=>{e.setAttribute(`data-terminal-disabled-contenteditable`,`true`),e.setAttribute(`contenteditable`,`false`),e.setAttribute(`aria-hidden`,`true`),e.tabIndex=-1,e.style.setProperty(`caret-color`,`transparent`),e.style.color=`transparent`,e.style.setProperty(`-webkit-text-fill-color`,`transparent`),e.style.background=`transparent`,e.style.outline=`none`,e.style.boxShadow=`none`,e.style.textShadow=`none`,e.style.setProperty(`user-select`,`none`),e.style.setProperty(`-webkit-user-select`,`none`)}),e.tabIndex=-1,e.removeAttribute(`role`),e.removeAttribute(`aria-multiline`),Array.from(e.querySelectorAll(`textarea`)).forEach(e=>{e.style.setProperty(`caret-color`,`transparent`),e.style.color=`transparent`,e.style.setProperty(`-webkit-text-fill-color`,`transparent`),e.style.background=`transparent`,e.style.border=`0`,e.style.outline=`none`,e.style.boxShadow=`none`,e.style.textShadow=`none`,e.style.fontSize=`0`,e.style.lineHeight=`0`,e!==t&&e.getAttribute(`data-terminal-disabled-input`)!==`true`&&(e.setAttribute(`data-terminal-disabled-input`,`true`),e.setAttribute(`aria-hidden`,`true`),e.tabIndex=-1,e.disabled=!0,e.style.position=`absolute`,e.style.opacity=`0`,e.style.width=`0px`,e.style.height=`0px`,e.style.pointerEvents=`none`,e.style.zIndex=`-1`)})},[I]),L=E.useCallback(e=>{if(fe.current===e)return;let t=y.current;if(t)try{if(typeof t.setOption==`function`){t.setOption(`cursorBlink`,e),fe.current=e;return}t.options&&(t.options.cursorBlink=e,fe.current=e)}catch{}},[]),R=I&&ve,z=E.useCallback((e,t)=>{let n=R?M.current:ce.current,r=_.current;if(!n||!r)return;let i=r.getBoundingClientRect(),a=typeof window<`u`?window.innerWidth:i.width,o=typeof window<`u`?window.innerHeight:i.height,s=i.left+i.width/2,c=i.top+i.height-12,l=typeof e==`number`?e:s,u=typeof t==`number`?t:c,d=Math.max(8,Math.min(a-8,l)),f=Math.max(8,Math.min(o-8,u));n.style.left=`${d}px`,n.style.top=`${f}px`,n.style.bottom=``,(n instanceof HTMLTextAreaElement||n instanceof HTMLInputElement)&&(n.disabled=!1,n.readOnly=!1,n.removeAttribute(`disabled`),n.removeAttribute(`readonly`));try{n.focus({preventScroll:!0})}catch{try{n.focus()}catch{}}},[R]),B=E.useCallback(()=>{if(I){z(),L(!0);return}y.current?.focus(),L(!0)},[z,L,I]),V=E.useCallback(e=>e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement?e.value:e.textContent??``,[]),H=E.useCallback(e=>{if(e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement){e.value=``;return}e.textContent=``},[]),be=E.useCallback(e=>{if(typeof window>`u`||R)return;de.current!==null&&(window.clearTimeout(de.current),de.current=null);let t=0,n=()=>{de.current=window.setTimeout(()=>{de.current=null;let r=V(e);if(!r){if(t+=1,t<3){n();return}return}let i=F.current;F.current=r;let a=r.startsWith(i)?r.slice(i.length):r;a&&x.current(a.replace(/\r\n|\r|\n/g,`\r`)),H(e),F.current=``},t===0?0:24)};n()},[H,V,R]);E.useEffect(()=>{let e=_.current;if(!I||!e||c)return;let t=t=>{let n=t.target;if(n&&n.getAttribute(`data-terminal-hidden-input`)!==`true`&&e.contains(n)){try{n.blur()}catch{}z()}};return e.addEventListener(`focusin`,t,!0),()=>{e.removeEventListener(`focusin`,t,!0)}},[c,I,z]);let U=E.useCallback(()=>{let e=y.current;if(!e||typeof e.getSelection!=`function`)return``;let t=e.getSelection();return typeof t==`string`?t:``},[]),xe=E.useCallback(()=>{if(typeof window>`u`)return``;let e=window.getSelection();if(!e)return``;let t=e.toString();if(!t.trim())return``;let n=_.current;if(!n)return``;let r=e.anchorNode,i=e.focusNode;return r&&!n.contains(r)||i&&!n.contains(i)?``:t},[]),Se=E.useCallback(async()=>{if(typeof document>`u`)return;let e=U()||xe();e.trim()&&await p(e)},[xe,U]),Ce=E.useCallback(()=>U().trim()?!0:!!xe().trim(),[xe,U]);E.useEffect(()=>{if(typeof window>`u`)return;let e=e=>{Ce()&&(e.preventDefault(),Se())};return window.addEventListener(`openchamber:copy`,e),()=>{window.removeEventListener(`openchamber:copy`,e)}},[Se,Ce]);let W=E.useCallback(()=>{w.current=``,T.current!==null&&typeof window<`u`&&window.cancelAnimationFrame(T.current),T.current=null,ne.current=!1,O.current=null},[]),G=E.useCallback(()=>{let e=te.current,t=y.current,n=_.current;if(!e||!t||!n)return;let r=n.getBoundingClientRect();if(!(r.width<24||r.height<24))try{e.fit();let n={cols:t.cols,rows:t.rows},r=C.current;(!r||r.cols!==n.cols||r.rows!==n.rows)&&(C.current=n,S.current(n.cols,n.rows))}catch{}},[]),K=E.useCallback(()=>{if(ne.current)return;let e=y.current;if(!e){W();return}if(!w.current)return;let t=w.current;w.current=``,ne.current=!0,e.write(t,()=>{ne.current=!1,w.current&&(typeof window<`u`?T.current=window.requestAnimationFrame(()=>{T.current=null,K()}):K())})},[W]),we=E.useCallback(()=>{T.current===null&&(typeof window<`u`?T.current=window.requestAnimationFrame(()=>{T.current=null,K()}):K())},[K]),q=E.useCallback(e=>{e&&(w.current+=e,we())},[we]),Te=E.useCallback(()=>{if(A.current?.(),A.current=null,j.current!==null&&typeof window<`u`&&(window.clearTimeout(j.current),j.current=null),!c){se.current=0;return}let e=_.current;if(!e)return;let t=y.current;if(!t)return;se.current=0;let n=2.2,r=2.8,i=.25,a=.05,s=.015,l={lastY:null,lastTime:null,velocity:0,rafId:null,startX:null,startY:null,didMove:!1},u=()=>typeof performance<`u`?performance.now():Date.now(),d=Math.max(12,Math.round(o*1.35)),f=0,ee=e=>{if(!e)return!1;let n=t.getViewportY(),r=f+e,i=Math.trunc(r/d);return f=r-i*d,i!==0&&t.scrollLines(i),t.getViewportY()!==n},p=()=>{l.rafId!==null&&typeof window<`u`&&window.cancelAnimationFrame(l.rafId),l.rafId=null},m={passive:!1,capture:!1};if(typeof window<`u`&&`PointerEvent`in window){let t=Object.assign(l,{pointerId:null,startX:null,startY:null,moved:!1}),o=n=>{if(n.pointerType===`touch`){p(),t.pointerId=n.pointerId,t.startX=n.clientX,t.startY=n.clientY,t.moved=!1,t.lastY=n.clientY,t.lastTime=u(),t.velocity=0;try{e.setPointerCapture(n.pointerId)}catch{}}},d=e=>{if(e.pointerType!==`touch`||t.pointerId!==e.pointerId)return;if(t.startX!==null&&t.startY!==null&&!t.moved){let n=e.clientX-t.startX,r=e.clientY-t.startY;Math.hypot(n,r)>=6&&(t.moved=!0)}if(t.lastY===null){t.lastY=e.clientY,t.lastTime=u();return}let a=t.lastY,o=t.lastTime??u(),s=u();t.lastY=e.clientY,t.lastTime=s;let c=a-e.clientY;if(Math.abs(c)<1)return;let l=Math.max(s-o,8),d=c*(n+Math.min(r,Math.abs(c)/25)),f=d/l;t.velocity=t.velocity*.75+f*i,t.velocity>8?t.velocity=8:t.velocity<-8&&(t.velocity=-8),t.moved&&(e.cancelable&&e.preventDefault(),e.stopPropagation()),ee(d)},f=n=>{if(n.pointerType!==`touch`||t.pointerId!==n.pointerId)return;let r=!t.moved;t.pointerId=null,t.startX=null,t.startY=null,t.moved=!1,t.lastY=null,t.lastTime=null;try{e.releasePointerCapture(n.pointerId)}catch{}if(r){I?z(n.clientX,n.clientY):c&&!pe.current&&(pe.current=!0,y.current?.focus());return}if(typeof window>`u`)return;if(Math.abs(t.velocity)<a){t.velocity=0;return}let i=u(),o=()=>{let e=u(),n=Math.max(e-i,8);i=e;let r=ee(t.velocity*n)??!1,c=Math.sign(t.velocity),l=Math.max(0,Math.abs(t.velocity)-s*n);if(t.velocity=l*c,!r||l<=a){p(),t.velocity=0;return}t.rafId=window.requestAnimationFrame(o)};t.rafId=window.requestAnimationFrame(o)};e.addEventListener(`pointerdown`,o,m),e.addEventListener(`pointermove`,d,m),e.addEventListener(`pointerup`,f,m),e.addEventListener(`pointercancel`,f,m);let h=e.style.touchAction,g=e.style.overscrollBehaviorY;e.style.touchAction=`none`,e.style.overscrollBehaviorY=`contain`,A.current=()=>{p(),j.current!==null&&typeof window<`u`&&(window.clearTimeout(j.current),j.current=null),se.current=0,e.removeEventListener(`pointerdown`,o,m),e.removeEventListener(`pointermove`,d,m),e.removeEventListener(`pointerup`,f,m),e.removeEventListener(`pointercancel`,f,m),e.style.touchAction=h,e.style.overscrollBehaviorY=g};return}let h=e=>{e.touches.length===1&&(p(),l.lastY=e.touches[0].clientY,l.lastTime=u(),l.velocity=0,l.startX=e.touches[0].clientX,l.startY=e.touches[0].clientY,l.didMove=!1)},g=e=>{if(e.touches.length!==1){l.lastY=null,l.lastTime=null,l.velocity=0,l.startX=null,l.startY=null,l.didMove=!1,p();return}let t=e.touches[0].clientX,a=e.touches[0].clientY;if(l.startX!==null&&l.startY!==null&&!l.didMove){let e=t-l.startX,n=a-l.startY;Math.hypot(e,n)>=6&&(l.didMove=!0)}if(l.lastY===null){l.lastY=a,l.lastTime=u();return}let o=l.lastY,s=l.lastTime??u(),c=u();l.lastY=a,l.lastTime=c;let d=o-a;if(Math.abs(d)<1)return;let f=Math.max(c-s,8),m=d*(n+Math.min(r,Math.abs(d)/25)),h=m/f;l.velocity=l.velocity*.75+h*i,l.velocity>8?l.velocity=8:l.velocity<-8&&(l.velocity=-8),l.didMove&&(e.preventDefault(),e.stopPropagation()),ee(m)},v=e=>{let t=!l.didMove;l.lastY=null,l.lastTime=null;let n=l.velocity;if(l.startX=null,l.startY=null,l.didMove=!1,t){let t=e.changedTouches?.[0];I?z(t?.clientX,t?.clientY):c&&!pe.current&&(pe.current=!0,y.current?.focus());return}if(typeof window>`u`)return;if(Math.abs(n)<a){l.velocity=0;return}let r=u(),i=()=>{let e=u(),t=Math.max(e-r,8);r=e;let n=ee(l.velocity*t)??!1,o=Math.sign(l.velocity),c=Math.max(0,Math.abs(l.velocity)-s*t);if(l.velocity=c*o,!n||c<=a){p(),l.velocity=0;return}l.rafId=window.requestAnimationFrame(i)};l.rafId=window.requestAnimationFrame(i)};e.addEventListener(`touchstart`,h,m),e.addEventListener(`touchmove`,g,m),e.addEventListener(`touchend`,v,m),e.addEventListener(`touchcancel`,v,m);let b=e.style.touchAction,te=e.style.overscrollBehaviorY;e.style.touchAction=`none`,e.style.overscrollBehaviorY=`contain`,A.current=()=>{p(),j.current!==null&&typeof window<`u`&&(window.clearTimeout(j.current),j.current=null),se.current=0,e.removeEventListener(`touchstart`,h,m),e.removeEventListener(`touchmove`,g,m),e.removeEventListener(`touchend`,v,m),e.removeEventListener(`touchcancel`,v,m),e.style.touchAction=b,e.style.overscrollBehaviorY=te}},[c,I,z,o]);E.useEffect(()=>{let e=!1,t=null,n=null,r=null,s=[],l=null,d=null,ee=null,p=_.current;if(!p)return;if(p.tabIndex=I?-1:0,I){let e=p.focus.bind(p),t=p;t.focus=((...e)=>{z()}),ee=()=>{t.focus=e}}let m=()=>{L(!0)},h=()=>{L(!1)},g=e=>{let t=e.target;if(t&&p.contains(t)){if(I&&t instanceof HTMLElement){window.setTimeout(()=>{t.blur(),z()},0),L(!1);return}if(c&&!pe.current&&t instanceof HTMLElement){window.setTimeout(()=>{t.blur()},0),L(!1);return}L(!0);return}L(!1)},b=()=>{L(!1)},S=null;return(async()=>{try{let ee=await k();if(e)return;let g=re(a,o,i,ee,!1),_=new u(g);oe.current=!0,I&&(_.focus=()=>{});let b=_;if(typeof b.scrollToBottom==`function`){let e=b.scrollToBottom.bind(b);b.scrollToBottom=()=>{oe.current&&e()},l=()=>{b.scrollToBottom=e}}let C=new f;if(t=_,y.current=_,te.current=C,_.loadAddon(C),_.open(p),c){let e=_.renderer;if(e&&typeof e.renderScrollbar==`function`){let t=e.renderScrollbar.bind(e);e.renderScrollbar=()=>{},d=()=>{e.renderScrollbar=t}}}_e(),fe.current=!1,S=_.textarea??p.querySelector(`textarea`),S&&(S.addEventListener(`focus`,m),S.addEventListener(`blur`,h)),ye(),typeof MutationObserver<`u`&&(r=new MutationObserver(()=>{ye()}),r.observe(p,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`contenteditable`,`role`,`tabindex`,`aria-label`]}));let w=ae(p);w?(w.classList.add(`overlay-scrollbar-target`,`overlay-scrollbar-container`),v.current=w,he()):v.current=null,G();let T=C;typeof T.observeResize==`function`&&T.observeResize(),Te(),s=[_.onData(e=>{x.current(e)}),_.onScroll(e=>{if(typeof e==`number`&&Number.isFinite(e)){let t=typeof _.hasSelection==`function`&&_.hasSelection();oe.current=!t&&e<=.5}}),_.onSelectionChange(()=>{if(typeof _.hasSelection==`function`&&_.hasSelection()){oe.current=!1;return}let e=typeof _.getViewportY==`function`?_.getViewportY():0;oe.current=e<=.5})],n=new ResizeObserver(()=>{G()}),n.observe(p),typeof window<`u`&&window.setTimeout(()=>{G()},0)}catch{}})(),document.addEventListener(`focusin`,g,!0),window.addEventListener(`blur`,b),()=>{e=!0,A.current?.(),A.current=null,document.removeEventListener(`focusin`,g,!0),window.removeEventListener(`blur`,b),s.forEach(e=>e.dispose()),l?.(),l=null,d?.(),d=null,S&&(S.removeEventListener(`focus`,m),S.removeEventListener(`blur`,h)),n?.disconnect(),r?.disconnect(),ee?.(),t?.dispose(),y.current=null,te.current=null,v.current=null,C.current=null,fe.current=null,W()}},[ye,c,G,z,a,o,Te,i,W,L,I]),E.useEffect(()=>{let e=y.current;e&&(e.reset(),W(),C.current=null,G())},[e,ge,G,W]),E.useEffect(()=>{l&&y.current&&B()},[l,B,e,ge]),E.useEffect(()=>(Te(),()=>{A.current?.(),A.current=null}),[Te,e]),E.useEffect(()=>{let e=y.current;if(!e)return;if(t.length===0){O.current!==null&&(e.reset(),W(),G());return}let n=O.current,r;if(n===null)r=t;else{let e=t.findIndex(e=>e.id===n);r=e>=0?t.slice(e+1):t}r.length>0&&q(r.map(e=>e.data).join(``)),O.current=t[t.length-1].id},[t,ge,q,G,W]),E.useImperativeHandle(m,()=>({focus:()=>{B()},clear:()=>{let e=y.current;e&&(e.reset(),W(),G())},fit:()=>{G()}}),[B,G,W]);let J=E.useCallback(e=>{if(!I)return;let t=_.current,n=e.relatedTarget,r=n?.tagName;r===`INPUT`||r===`TEXTAREA`||n?.isContentEditable,n?.getAttribute(`data-terminal-hidden-input`),n&&t?.contains(n)},[I]),Y=E.useCallback(e=>{let t=e.nativeEvent,n=t?.inputType??``,r=typeof t?.data==`string`?t.data:``;if(ue.current=typeof performance<`u`?performance.now():Date.now(),n===`insertCompositionText`){N.current=!0;return}if(!n&&r){if(N.current)return;e.preventDefault(),x.current(r),le.current={type:`insertText`,at:typeof performance<`u`?performance.now():Date.now()},P.current=!0;return}if(n===`insertText`&&r){if(N.current)return;e.preventDefault(),x.current(r),le.current={type:n,at:typeof performance<`u`?performance.now():Date.now()},P.current=!0;return}if(n===`insertLineBreak`){if(N.current)return;e.preventDefault(),x.current(`\r`),le.current={type:n,at:typeof performance<`u`?performance.now():Date.now()},P.current=!0;return}if(n===`deleteContentBackward`){if(N.current)return;e.preventDefault(),x.current(``),le.current={type:n,at:typeof performance<`u`?performance.now():Date.now()},P.current=!0}},[]),X=E.useCallback(e=>{let t=e.currentTarget;if(ue.current=typeof performance<`u`?performance.now():Date.now(),N.current)return;if(P.current){let e=le.current,n=typeof performance<`u`?performance.now():Date.now();if(e&&n-e.at<50){P.current=!1,H(t);return}P.current=!1}let n=V(t);if(!n)return;F.current=n;let r=n.replace(/\r\n|\r|\n/g,`\r`);x.current(r),H(t),F.current=``},[H,V]),Ee=E.useCallback(e=>{e.stopPropagation();let t=e.key.toLowerCase(),n=e.metaKey&&!e.ctrlKey&&!e.altKey&&t===`c`,r=e.ctrlKey&&e.shiftKey&&!e.metaKey&&!e.altKey&&t===`c`;if((n||r)&&Ce()){e.preventDefault(),Se();return}if(e.ctrlKey&&!e.metaKey&&!e.altKey&&e.key.length===1){let t=e.key.toUpperCase();if(t>=`A`&&t<=`Z`){e.preventDefault(),e.nativeEvent?.stopImmediatePropagation(),x.current(String.fromCharCode(t.charCodeAt(0)-64)),H(e.currentTarget);return}}if(e.altKey&&!e.ctrlKey&&!e.metaKey&&e.key.length===1){e.preventDefault(),e.nativeEvent?.stopImmediatePropagation(),x.current(`\x1B`+e.key),H(e.currentTarget);return}let i={ArrowUp:`\x1B[A`,ArrowDown:`\x1B[B`,ArrowRight:`\x1B[C`,ArrowLeft:`\x1B[D`,Escape:`\x1B`,Tab:` `,Delete:`\x1B[3~`,Home:`\x1B[H`,End:`\x1B[F`}[e.key];if(i){e.preventDefault(),x.current(i),H(e.currentTarget);return}let a=e.currentTarget;if(e.nativeEvent?.isComposing)return;let o=le.current,s=typeof performance<`u`?performance.now():Date.now(),c=!!(o&&s-o.at<50);if(e.key===`Enter`){if(c&&o?.type===`insertLineBreak`)return;e.preventDefault(),x.current(`\r`),H(a);return}if(e.key===`Backspace`){if(e.preventDefault(),c&&o?.type===`deleteContentBackward`)return;V(a)||x.current(``)}if(e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey){let t=ue.current;t&&s-t<50||(e.preventDefault(),x.current(e.key),P.current=!0,le.current={type:`keydown-text`,at:s})}be(a)},[H,Se,Ce,V,be]),De=E.useCallback(e=>{e.stopPropagation();let t=e.currentTarget;e.nativeEvent?.isComposing||be(t)},[be]),Oe=E.useCallback(e=>{let t=e.currentTarget;N.current=!1;let n=e.data||V(t);if(ue.current=typeof performance<`u`?performance.now():Date.now(),!n)return;let r=n.replace(/\r\n|\r|\n/g,`\r`);x.current(r),H(t),le.current={type:`compositionend`,at:typeof performance<`u`?performance.now():Date.now()},P.current=!0},[H,V]),ke=E.useCallback(e=>{e.stopPropagation();let t=e.clipboardData?.getData(`text`)??``;if(!t)return;e.preventDefault();let n=y.current?.hasBracketedPaste?.()?`\x1b[200~${t}\x1b[201~`:t;x.current(n)},[]),Ae={position:`fixed`,left:0,top:0,width:1,height:1,opacity:0,zIndex:-1,background:`transparent`,color:`transparent`,WebkitTextFillColor:`transparent`,caretColor:`transparent`,textShadow:`none`,WebkitAppearance:`none`,appearance:`none`,resize:`none`,overflow:`hidden`,whiteSpace:`nowrap`,border:`0`,padding:0,margin:0,outline:`none`,outlineOffset:0,fontSize:16,fontWeight:400,pointerEvents:`none`,WebkitUserSelect:`none`,userSelect:`none`};return(0,D.jsxs)(`div`,{ref:_,className:h(`relative h-full w-full terminal-viewport-container`,s),"data-hidden-input-overlay-active":I?`true`:void 0,style:{backgroundColor:i.background},onTouchStart:e=>{if(!(!I||c)&&!Ce()){let t=e.touches?.[0];z(t?.clientX,t?.clientY)}},onClick:e=>{if(!c)if(I){if(Ce())return;z(e.clientX,e.clientY)}else y.current?.focus()},onMouseUp:()=>{!c&&Ce()&&Se()},onTouchEnd:()=>{!c&&Ce()&&Se()},children:[I&&typeof document<`u`?(0,ie.createPortal)((0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`input`,{ref:M,type:`text`,inputMode:`text`,autoCapitalize:`off`,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,tabIndex:-1,enterKeyHint:`send`,"data-terminal-hidden-input":`true`,"aria-label":g(`terminalView.viewport.inputAria`),"aria-hidden":`true`,style:{...Ae,display:R?`block`:`none`},onBlur:J,onBeforeInput:Y,onCompositionStart:()=>{N.current=!0},onInput:X,onKeyDown:Ee,onKeyUp:De,onCompositionEnd:Oe,onPaste:ke}),(0,D.jsx)(`textarea`,{ref:ce,inputMode:`text`,autoCapitalize:`off`,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,tabIndex:-1,enterKeyHint:`send`,"data-terminal-hidden-input":`true`,"aria-label":g(`terminalView.viewport.inputAria`),"aria-hidden":`true`,style:{...Ae,display:R?`none`:`block`},onBlur:J,onBeforeInput:Y,onCompositionStart:()=>{N.current=!0},onInput:X,onKeyDown:Ee,onKeyUp:De,onCompositionEnd:Oe,onPaste:ke})]}),document.body):null,v.current&&!c?(0,D.jsx)(b,{containerRef:v,disableHorizontal:!0,className:`overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero`}):null]})});oe.displayName=`TerminalViewport`;var A=RegExp(`\x1B\\[[0-9;?]*[ -/]*[@-~]`,`g`),j=/(https?:\/\/(?:localhost|127\.0\.0\.1|0\.0\.0\.0|\[(?:::1|::)\])(?::\d{2,5})?(?:\/[^\s<>'"`]*)?)/gi,se=/(?:➜\s*(?:Local|Network):)|\b(?:local|network|loopback|serving|listening|available|ready|started|running|server|vite|webpack|next\.js|astro|sveltekit|nuxt)\b/i,ce=/Serving HTTP on .*? port (\d{2,5})/i,M=new Set([`.`,`,`,`;`,`:`,`!`,`?`]),N=e=>{let t=e;for(;t.length>0;){let e=t[t.length-1];if(e===`)`||e===`]`||e===`}`||e===`>`){let n=e===`)`?`(`:e===`]`?`[`:e===`}`?`{`:`<`,r=t.slice(0,-1);if((r.match(RegExp(`\\${n}`,`g`))||[]).length>(r.match(RegExp(`\\${e}`,`g`))||[]).length)break;t=r;continue}if(M.has(e)){t=t.slice(0,-1);continue}break}return t},P=e=>{let t=N(e);return t=t.replace(`0.0.0.0`,`127.0.0.1`),t=t.replace(`[::1]`,`127.0.0.1`),t=t.replace(`[::]`,`127.0.0.1`),t},le=e=>{if(!e)return null;let t=e.replace(A,``),n=t.match(ce);if(n?.[1]){let e=Number.parseInt(n[1],10);if(Number.isFinite(e)&&e>0&&e<=65535)return`http://127.0.0.1:${e}/`}let r=t.split(`
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{c as t,s as n,t as r}from"./useUIStore-D6BTB4va.js";import{Xt as i,kn as a}from"./persistence-C_KCiMcY.js";import{nt as o,rt as s,tt as c}from"./vendor-base-ui-CnHfUmDN.js";import{o as l}from"./terminalApi-BYTA045F.js";import{n as u,r as d,t as f}from"./vendor-ghostty-web-HohRXr3g.js";import{n as ee,t as p}from"./clipboard-CXWbHCAk.js";import{l as m}from"./useMobileNavigationStore-1xHjnAsg.js";import{t as h}from"./utils-DyUyiLje.js";import{n as g}from"./Icon-BPJ_quEe.js";import{t as _}from"./button-BmNJBT13.js";import{n as v}from"./useThemeSystem-DMzWVJaW.js";import{i as y,t as b}from"./OverlayScrollbar-Dqk1zGJB.js";import{n as te}from"./useRuntimeAPIs-DSLXJybW.js";import{n as x}from"./useEffectiveDirectory-DG6uPzBG.js";import{t as S}from"./sortable-tabs-strip-oKJ700WG.js";import{n as C,t as w}from"./useFontPreferences-Bu4ME5hk.js";import{r as T}from"./projectActions-CWvNGKfA.js";var E=e(s(),1);function ne(e){let{colors:t}=e,n=t.syntax.base;return{background:t.surface.background,foreground:n.foreground,cursor:t.interactive.cursor,cursorAccent:t.surface.background,selectionBackground:t.interactive.selection,selectionForeground:t.interactive.selectionForeground,selectionInactiveBackground:t.interactive.selection+`50`,black:t.surface.muted,red:t.status.error,green:t.status.success,yellow:t.status.warning,blue:n.function,magenta:n.keyword,cyan:n.type,white:n.foreground,brightBlack:n.comment,brightRed:t.status.error,brightGreen:t.status.success,brightYellow:t.status.warning,brightBlue:n.function,brightMagenta:n.keyword,brightCyan:n.type,brightWhite:t.surface.elevatedForeground}}function re(e,t,n,r,i=!1){return{cursorBlink:!1,cursorStyle:`bar`,fontSize:t,lineHeight:1.15,fontFamily:`${e}, "JetBrainsMonoNL Nerd Font", "FiraCode Nerd Font", "Cascadia Code PL", "Fira Code", "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", "Courier New", monospace`,allowTransparency:!1,theme:{background:n.background,foreground:n.foreground,cursor:n.cursor,cursorAccent:n.cursorAccent,selectionBackground:n.selectionBackground,selectionForeground:n.selectionForeground,black:n.black,red:n.red,green:n.green,yellow:n.yellow,blue:n.blue,magenta:n.magenta,cyan:n.cyan,white:n.white,brightBlack:n.brightBlack,brightRed:n.brightRed,brightGreen:n.brightGreen,brightYellow:n.brightYellow,brightBlue:n.brightBlue,brightMagenta:n.brightMagenta,brightCyan:n.brightCyan,brightWhite:n.brightWhite},scrollback:1e4,ghostty:r,disableStdin:i}}var ie=e(c(),1),D=o(),O=null;function k(){return O||=d.load(),O}function ae(e){if(typeof window>`u`)return null;let t=[e,...Array.from(e.querySelectorAll(`*`))],n=null;for(let e of t){let t=window.getComputedStyle(e).overflowY;if(t===`auto`||t===`scroll`){if(e.scrollHeight-e.clientHeight>2)return e;n||=e}}return n}var oe=E.forwardRef(({sessionKey:e,chunks:t,onInput:n,onResize:r,theme:i,fontFamily:a,fontSize:o,className:s,enableTouchScroll:c,autoFocus:l=!0,isVisible:d=!0},m)=>{let{t:g}=ee(),_=E.useRef(null),v=E.useRef(null),y=E.useRef(null),te=E.useRef(null),x=E.useRef(n),S=E.useRef(r),C=E.useRef(null),w=E.useRef(``),T=E.useRef(null),ne=E.useRef(!1),O=E.useRef(null),oe=E.useRef(!0),A=E.useRef(null),j=E.useRef(null),se=E.useRef(0),ce=E.useRef(null),M=E.useRef(null),N=E.useRef(!1),P=E.useRef(!1),le=E.useRef(null),ue=E.useRef(null),de=E.useRef(null),F=E.useRef(``),fe=E.useRef(null),pe=E.useRef(!c),me=E.useRef(d),[,he]=E.useReducer(e=>e+1,0),[ge,_e]=E.useReducer(e=>e+1,0);x.current=n,S.current=r;let ve=typeof navigator<`u`&&(/Android/i.test(navigator.userAgent)||navigator.userAgentData?.platform===`Android`),I=!!c;E.useEffect(()=>{if(!c){pe.current=!0,me.current=d;return}!me.current&&d&&(pe.current=!1),me.current=d},[c,d]);let ye=E.useCallback(()=>{if(!I)return;let e=_.current,t=ce.current;if(!e)return;let n=[];e.getAttribute(`contenteditable`)===`true`&&n.push(e),n.push(...Array.from(e.querySelectorAll(`[contenteditable="true"]`))),n.forEach(e=>{e.setAttribute(`data-terminal-disabled-contenteditable`,`true`),e.setAttribute(`contenteditable`,`false`),e.setAttribute(`aria-hidden`,`true`),e.tabIndex=-1,e.style.setProperty(`caret-color`,`transparent`),e.style.color=`transparent`,e.style.setProperty(`-webkit-text-fill-color`,`transparent`),e.style.background=`transparent`,e.style.outline=`none`,e.style.boxShadow=`none`,e.style.textShadow=`none`,e.style.setProperty(`user-select`,`none`),e.style.setProperty(`-webkit-user-select`,`none`)}),e.tabIndex=-1,e.removeAttribute(`role`),e.removeAttribute(`aria-multiline`),Array.from(e.querySelectorAll(`textarea`)).forEach(e=>{e.style.setProperty(`caret-color`,`transparent`),e.style.color=`transparent`,e.style.setProperty(`-webkit-text-fill-color`,`transparent`),e.style.background=`transparent`,e.style.border=`0`,e.style.outline=`none`,e.style.boxShadow=`none`,e.style.textShadow=`none`,e.style.fontSize=`0`,e.style.lineHeight=`0`,e!==t&&e.getAttribute(`data-terminal-disabled-input`)!==`true`&&(e.setAttribute(`data-terminal-disabled-input`,`true`),e.setAttribute(`aria-hidden`,`true`),e.tabIndex=-1,e.disabled=!0,e.style.position=`absolute`,e.style.opacity=`0`,e.style.width=`0px`,e.style.height=`0px`,e.style.pointerEvents=`none`,e.style.zIndex=`-1`)})},[I]),L=E.useCallback(e=>{if(fe.current===e)return;let t=y.current;if(t)try{if(typeof t.setOption==`function`){t.setOption(`cursorBlink`,e),fe.current=e;return}t.options&&(t.options.cursorBlink=e,fe.current=e)}catch{}},[]),R=I&&ve,z=E.useCallback((e,t)=>{let n=R?M.current:ce.current,r=_.current;if(!n||!r)return;let i=r.getBoundingClientRect(),a=typeof window<`u`?window.innerWidth:i.width,o=typeof window<`u`?window.innerHeight:i.height,s=i.left+i.width/2,c=i.top+i.height-12,l=typeof e==`number`?e:s,u=typeof t==`number`?t:c,d=Math.max(8,Math.min(a-8,l)),f=Math.max(8,Math.min(o-8,u));n.style.left=`${d}px`,n.style.top=`${f}px`,n.style.bottom=``,(n instanceof HTMLTextAreaElement||n instanceof HTMLInputElement)&&(n.disabled=!1,n.readOnly=!1,n.removeAttribute(`disabled`),n.removeAttribute(`readonly`));try{n.focus({preventScroll:!0})}catch{try{n.focus()}catch{}}},[R]),B=E.useCallback(()=>{if(I){z(),L(!0);return}y.current?.focus(),L(!0)},[z,L,I]),V=E.useCallback(e=>e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement?e.value:e.textContent??``,[]),H=E.useCallback(e=>{if(e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement){e.value=``;return}e.textContent=``},[]),be=E.useCallback(e=>{if(typeof window>`u`||R)return;de.current!==null&&(window.clearTimeout(de.current),de.current=null);let t=0,n=()=>{de.current=window.setTimeout(()=>{de.current=null;let r=V(e);if(!r){if(t+=1,t<3){n();return}return}let i=F.current;F.current=r;let a=r.startsWith(i)?r.slice(i.length):r;a&&x.current(a.replace(/\r\n|\r|\n/g,`\r`)),H(e),F.current=``},t===0?0:24)};n()},[H,V,R]);E.useEffect(()=>{let e=_.current;if(!I||!e||c)return;let t=t=>{let n=t.target;if(n&&n.getAttribute(`data-terminal-hidden-input`)!==`true`&&e.contains(n)){try{n.blur()}catch{}z()}};return e.addEventListener(`focusin`,t,!0),()=>{e.removeEventListener(`focusin`,t,!0)}},[c,I,z]);let U=E.useCallback(()=>{let e=y.current;if(!e||typeof e.getSelection!=`function`)return``;let t=e.getSelection();return typeof t==`string`?t:``},[]),xe=E.useCallback(()=>{if(typeof window>`u`)return``;let e=window.getSelection();if(!e)return``;let t=e.toString();if(!t.trim())return``;let n=_.current;if(!n)return``;let r=e.anchorNode,i=e.focusNode;return r&&!n.contains(r)||i&&!n.contains(i)?``:t},[]),Se=E.useCallback(async()=>{if(typeof document>`u`)return;let e=U()||xe();e.trim()&&await p(e)},[xe,U]),Ce=E.useCallback(()=>U().trim()?!0:!!xe().trim(),[xe,U]);E.useEffect(()=>{if(typeof window>`u`)return;let e=e=>{Ce()&&(e.preventDefault(),Se())};return window.addEventListener(`openchamber:copy`,e),()=>{window.removeEventListener(`openchamber:copy`,e)}},[Se,Ce]);let W=E.useCallback(()=>{w.current=``,T.current!==null&&typeof window<`u`&&window.cancelAnimationFrame(T.current),T.current=null,ne.current=!1,O.current=null},[]),G=E.useCallback(()=>{let e=te.current,t=y.current,n=_.current;if(!e||!t||!n)return;let r=n.getBoundingClientRect();if(!(r.width<24||r.height<24))try{e.fit();let n={cols:t.cols,rows:t.rows},r=C.current;(!r||r.cols!==n.cols||r.rows!==n.rows)&&(C.current=n,S.current(n.cols,n.rows))}catch{}},[]),K=E.useCallback(()=>{if(ne.current)return;let e=y.current;if(!e){W();return}if(!w.current)return;let t=w.current;w.current=``,ne.current=!0,e.write(t,()=>{ne.current=!1,w.current&&(typeof window<`u`?T.current=window.requestAnimationFrame(()=>{T.current=null,K()}):K())})},[W]),we=E.useCallback(()=>{T.current===null&&(typeof window<`u`?T.current=window.requestAnimationFrame(()=>{T.current=null,K()}):K())},[K]),q=E.useCallback(e=>{e&&(w.current+=e,we())},[we]),Te=E.useCallback(()=>{if(A.current?.(),A.current=null,j.current!==null&&typeof window<`u`&&(window.clearTimeout(j.current),j.current=null),!c){se.current=0;return}let e=_.current;if(!e)return;let t=y.current;if(!t)return;se.current=0;let n=2.2,r=2.8,i=.25,a=.05,s=.015,l={lastY:null,lastTime:null,velocity:0,rafId:null,startX:null,startY:null,didMove:!1},u=()=>typeof performance<`u`?performance.now():Date.now(),d=Math.max(12,Math.round(o*1.35)),f=0,ee=e=>{if(!e)return!1;let n=t.getViewportY(),r=f+e,i=Math.trunc(r/d);return f=r-i*d,i!==0&&t.scrollLines(i),t.getViewportY()!==n},p=()=>{l.rafId!==null&&typeof window<`u`&&window.cancelAnimationFrame(l.rafId),l.rafId=null},m={passive:!1,capture:!1};if(typeof window<`u`&&`PointerEvent`in window){let t=Object.assign(l,{pointerId:null,startX:null,startY:null,moved:!1}),o=n=>{if(n.pointerType===`touch`){p(),t.pointerId=n.pointerId,t.startX=n.clientX,t.startY=n.clientY,t.moved=!1,t.lastY=n.clientY,t.lastTime=u(),t.velocity=0;try{e.setPointerCapture(n.pointerId)}catch{}}},d=e=>{if(e.pointerType!==`touch`||t.pointerId!==e.pointerId)return;if(t.startX!==null&&t.startY!==null&&!t.moved){let n=e.clientX-t.startX,r=e.clientY-t.startY;Math.hypot(n,r)>=6&&(t.moved=!0)}if(t.lastY===null){t.lastY=e.clientY,t.lastTime=u();return}let a=t.lastY,o=t.lastTime??u(),s=u();t.lastY=e.clientY,t.lastTime=s;let c=a-e.clientY;if(Math.abs(c)<1)return;let l=Math.max(s-o,8),d=c*(n+Math.min(r,Math.abs(c)/25)),f=d/l;t.velocity=t.velocity*.75+f*i,t.velocity>8?t.velocity=8:t.velocity<-8&&(t.velocity=-8),t.moved&&(e.cancelable&&e.preventDefault(),e.stopPropagation()),ee(d)},f=n=>{if(n.pointerType!==`touch`||t.pointerId!==n.pointerId)return;let r=!t.moved;t.pointerId=null,t.startX=null,t.startY=null,t.moved=!1,t.lastY=null,t.lastTime=null;try{e.releasePointerCapture(n.pointerId)}catch{}if(r){I?z(n.clientX,n.clientY):c&&!pe.current&&(pe.current=!0,y.current?.focus());return}if(typeof window>`u`)return;if(Math.abs(t.velocity)<a){t.velocity=0;return}let i=u(),o=()=>{let e=u(),n=Math.max(e-i,8);i=e;let r=ee(t.velocity*n)??!1,c=Math.sign(t.velocity),l=Math.max(0,Math.abs(t.velocity)-s*n);if(t.velocity=l*c,!r||l<=a){p(),t.velocity=0;return}t.rafId=window.requestAnimationFrame(o)};t.rafId=window.requestAnimationFrame(o)};e.addEventListener(`pointerdown`,o,m),e.addEventListener(`pointermove`,d,m),e.addEventListener(`pointerup`,f,m),e.addEventListener(`pointercancel`,f,m);let h=e.style.touchAction,g=e.style.overscrollBehaviorY;e.style.touchAction=`none`,e.style.overscrollBehaviorY=`contain`,A.current=()=>{p(),j.current!==null&&typeof window<`u`&&(window.clearTimeout(j.current),j.current=null),se.current=0,e.removeEventListener(`pointerdown`,o,m),e.removeEventListener(`pointermove`,d,m),e.removeEventListener(`pointerup`,f,m),e.removeEventListener(`pointercancel`,f,m),e.style.touchAction=h,e.style.overscrollBehaviorY=g};return}let h=e=>{e.touches.length===1&&(p(),l.lastY=e.touches[0].clientY,l.lastTime=u(),l.velocity=0,l.startX=e.touches[0].clientX,l.startY=e.touches[0].clientY,l.didMove=!1)},g=e=>{if(e.touches.length!==1){l.lastY=null,l.lastTime=null,l.velocity=0,l.startX=null,l.startY=null,l.didMove=!1,p();return}let t=e.touches[0].clientX,a=e.touches[0].clientY;if(l.startX!==null&&l.startY!==null&&!l.didMove){let e=t-l.startX,n=a-l.startY;Math.hypot(e,n)>=6&&(l.didMove=!0)}if(l.lastY===null){l.lastY=a,l.lastTime=u();return}let o=l.lastY,s=l.lastTime??u(),c=u();l.lastY=a,l.lastTime=c;let d=o-a;if(Math.abs(d)<1)return;let f=Math.max(c-s,8),m=d*(n+Math.min(r,Math.abs(d)/25)),h=m/f;l.velocity=l.velocity*.75+h*i,l.velocity>8?l.velocity=8:l.velocity<-8&&(l.velocity=-8),l.didMove&&(e.preventDefault(),e.stopPropagation()),ee(m)},v=e=>{let t=!l.didMove;l.lastY=null,l.lastTime=null;let n=l.velocity;if(l.startX=null,l.startY=null,l.didMove=!1,t){let t=e.changedTouches?.[0];I?z(t?.clientX,t?.clientY):c&&!pe.current&&(pe.current=!0,y.current?.focus());return}if(typeof window>`u`)return;if(Math.abs(n)<a){l.velocity=0;return}let r=u(),i=()=>{let e=u(),t=Math.max(e-r,8);r=e;let n=ee(l.velocity*t)??!1,o=Math.sign(l.velocity),c=Math.max(0,Math.abs(l.velocity)-s*t);if(l.velocity=c*o,!n||c<=a){p(),l.velocity=0;return}l.rafId=window.requestAnimationFrame(i)};l.rafId=window.requestAnimationFrame(i)};e.addEventListener(`touchstart`,h,m),e.addEventListener(`touchmove`,g,m),e.addEventListener(`touchend`,v,m),e.addEventListener(`touchcancel`,v,m);let b=e.style.touchAction,te=e.style.overscrollBehaviorY;e.style.touchAction=`none`,e.style.overscrollBehaviorY=`contain`,A.current=()=>{p(),j.current!==null&&typeof window<`u`&&(window.clearTimeout(j.current),j.current=null),se.current=0,e.removeEventListener(`touchstart`,h,m),e.removeEventListener(`touchmove`,g,m),e.removeEventListener(`touchend`,v,m),e.removeEventListener(`touchcancel`,v,m),e.style.touchAction=b,e.style.overscrollBehaviorY=te}},[c,I,z,o]);E.useEffect(()=>{let e=!1,t=null,n=null,r=null,s=[],l=null,d=null,ee=null,p=_.current;if(!p)return;if(p.tabIndex=I?-1:0,I){let e=p.focus.bind(p),t=p;t.focus=((...e)=>{z()}),ee=()=>{t.focus=e}}let m=()=>{L(!0)},h=()=>{L(!1)},g=e=>{let t=e.target;if(t&&p.contains(t)){if(I&&t instanceof HTMLElement){window.setTimeout(()=>{t.blur(),z()},0),L(!1);return}if(c&&!pe.current&&t instanceof HTMLElement){window.setTimeout(()=>{t.blur()},0),L(!1);return}L(!0);return}L(!1)},b=()=>{L(!1)},S=null;return(async()=>{try{let ee=await k();if(e)return;let g=re(a,o,i,ee,!1),_=new u(g);oe.current=!0,I&&(_.focus=()=>{});let b=_;if(typeof b.scrollToBottom==`function`){let e=b.scrollToBottom.bind(b);b.scrollToBottom=()=>{oe.current&&e()},l=()=>{b.scrollToBottom=e}}let C=new f;if(t=_,y.current=_,te.current=C,_.loadAddon(C),_.open(p),c){let e=_.renderer;if(e&&typeof e.renderScrollbar==`function`){let t=e.renderScrollbar.bind(e);e.renderScrollbar=()=>{},d=()=>{e.renderScrollbar=t}}}_e(),fe.current=!1,S=_.textarea??p.querySelector(`textarea`),S&&(S.addEventListener(`focus`,m),S.addEventListener(`blur`,h)),ye(),typeof MutationObserver<`u`&&(r=new MutationObserver(()=>{ye()}),r.observe(p,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`contenteditable`,`role`,`tabindex`,`aria-label`]}));let w=ae(p);w?(w.classList.add(`overlay-scrollbar-target`,`overlay-scrollbar-container`),v.current=w,he()):v.current=null,G();let T=C;typeof T.observeResize==`function`&&T.observeResize(),Te(),s=[_.onData(e=>{x.current(e)}),_.onScroll(e=>{if(typeof e==`number`&&Number.isFinite(e)){let t=typeof _.hasSelection==`function`&&_.hasSelection();oe.current=!t&&e<=.5}}),_.onSelectionChange(()=>{if(typeof _.hasSelection==`function`&&_.hasSelection()){oe.current=!1;return}let e=typeof _.getViewportY==`function`?_.getViewportY():0;oe.current=e<=.5})],n=new ResizeObserver(()=>{G()}),n.observe(p),typeof window<`u`&&window.setTimeout(()=>{G()},0)}catch{}})(),document.addEventListener(`focusin`,g,!0),window.addEventListener(`blur`,b),()=>{e=!0,A.current?.(),A.current=null,document.removeEventListener(`focusin`,g,!0),window.removeEventListener(`blur`,b),s.forEach(e=>e.dispose()),l?.(),l=null,d?.(),d=null,S&&(S.removeEventListener(`focus`,m),S.removeEventListener(`blur`,h)),n?.disconnect(),r?.disconnect(),ee?.(),t?.dispose(),y.current=null,te.current=null,v.current=null,C.current=null,fe.current=null,W()}},[ye,c,G,z,a,o,Te,i,W,L,I]),E.useEffect(()=>{let e=y.current;e&&(e.reset(),W(),C.current=null,G())},[e,ge,G,W]),E.useEffect(()=>{l&&y.current&&B()},[l,B,e,ge]),E.useEffect(()=>(Te(),()=>{A.current?.(),A.current=null}),[Te,e]),E.useEffect(()=>{let e=y.current;if(!e)return;if(t.length===0){O.current!==null&&(e.reset(),W(),G());return}let n=O.current,r;if(n===null)r=t;else{let e=t.findIndex(e=>e.id===n);r=e>=0?t.slice(e+1):t}r.length>0&&q(r.map(e=>e.data).join(``)),O.current=t[t.length-1].id},[t,ge,q,G,W]),E.useImperativeHandle(m,()=>({focus:()=>{B()},clear:()=>{let e=y.current;e&&(e.reset(),W(),G())},fit:()=>{G()}}),[B,G,W]);let J=E.useCallback(e=>{if(!I)return;let t=_.current,n=e.relatedTarget,r=n?.tagName;r===`INPUT`||r===`TEXTAREA`||n?.isContentEditable,n?.getAttribute(`data-terminal-hidden-input`),n&&t?.contains(n)},[I]),Y=E.useCallback(e=>{let t=e.nativeEvent,n=t?.inputType??``,r=typeof t?.data==`string`?t.data:``;if(ue.current=typeof performance<`u`?performance.now():Date.now(),n===`insertCompositionText`){N.current=!0;return}if(!n&&r){if(N.current)return;e.preventDefault(),x.current(r),le.current={type:`insertText`,at:typeof performance<`u`?performance.now():Date.now()},P.current=!0;return}if(n===`insertText`&&r){if(N.current)return;e.preventDefault(),x.current(r),le.current={type:n,at:typeof performance<`u`?performance.now():Date.now()},P.current=!0;return}if(n===`insertLineBreak`){if(N.current)return;e.preventDefault(),x.current(`\r`),le.current={type:n,at:typeof performance<`u`?performance.now():Date.now()},P.current=!0;return}if(n===`deleteContentBackward`){if(N.current)return;e.preventDefault(),x.current(``),le.current={type:n,at:typeof performance<`u`?performance.now():Date.now()},P.current=!0}},[]),X=E.useCallback(e=>{let t=e.currentTarget;if(ue.current=typeof performance<`u`?performance.now():Date.now(),N.current)return;if(P.current){let e=le.current,n=typeof performance<`u`?performance.now():Date.now();if(e&&n-e.at<50){P.current=!1,H(t);return}P.current=!1}let n=V(t);if(!n)return;F.current=n;let r=n.replace(/\r\n|\r|\n/g,`\r`);x.current(r),H(t),F.current=``},[H,V]),Ee=E.useCallback(e=>{e.stopPropagation();let t=e.key.toLowerCase(),n=e.metaKey&&!e.ctrlKey&&!e.altKey&&t===`c`,r=e.ctrlKey&&e.shiftKey&&!e.metaKey&&!e.altKey&&t===`c`;if((n||r)&&Ce()){e.preventDefault(),Se();return}if(e.ctrlKey&&!e.metaKey&&!e.altKey&&e.key.length===1){let t=e.key.toUpperCase();if(t>=`A`&&t<=`Z`){e.preventDefault(),e.nativeEvent?.stopImmediatePropagation(),x.current(String.fromCharCode(t.charCodeAt(0)-64)),H(e.currentTarget);return}}if(e.altKey&&!e.ctrlKey&&!e.metaKey&&e.key.length===1){e.preventDefault(),e.nativeEvent?.stopImmediatePropagation(),x.current(`\x1B`+e.key),H(e.currentTarget);return}let i={ArrowUp:`\x1B[A`,ArrowDown:`\x1B[B`,ArrowRight:`\x1B[C`,ArrowLeft:`\x1B[D`,Escape:`\x1B`,Tab:` `,Delete:`\x1B[3~`,Home:`\x1B[H`,End:`\x1B[F`}[e.key];if(i){e.preventDefault(),x.current(i),H(e.currentTarget);return}let a=e.currentTarget;if(e.nativeEvent?.isComposing)return;let o=le.current,s=typeof performance<`u`?performance.now():Date.now(),c=!!(o&&s-o.at<50);if(e.key===`Enter`){if(c&&o?.type===`insertLineBreak`)return;e.preventDefault(),x.current(`\r`),H(a);return}if(e.key===`Backspace`){if(e.preventDefault(),c&&o?.type===`deleteContentBackward`)return;V(a)||x.current(``)}if(e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey){let t=ue.current;t&&s-t<50||(e.preventDefault(),x.current(e.key),P.current=!0,le.current={type:`keydown-text`,at:s})}be(a)},[H,Se,Ce,V,be]),De=E.useCallback(e=>{e.stopPropagation();let t=e.currentTarget;e.nativeEvent?.isComposing||be(t)},[be]),Oe=E.useCallback(e=>{let t=e.currentTarget;N.current=!1;let n=e.data||V(t);if(ue.current=typeof performance<`u`?performance.now():Date.now(),!n)return;let r=n.replace(/\r\n|\r|\n/g,`\r`);x.current(r),H(t),le.current={type:`compositionend`,at:typeof performance<`u`?performance.now():Date.now()},P.current=!0},[H,V]),ke=E.useCallback(e=>{e.stopPropagation();let t=e.clipboardData?.getData(`text`)??``;if(!t)return;e.preventDefault();let n=y.current?.hasBracketedPaste?.()?`\x1b[200~${t}\x1b[201~`:t;x.current(n)},[]),Ae={position:`fixed`,left:0,top:0,width:1,height:1,opacity:0,zIndex:-1,background:`transparent`,color:`transparent`,WebkitTextFillColor:`transparent`,caretColor:`transparent`,textShadow:`none`,WebkitAppearance:`none`,appearance:`none`,resize:`none`,overflow:`hidden`,whiteSpace:`nowrap`,border:`0`,padding:0,margin:0,outline:`none`,outlineOffset:0,fontSize:16,fontWeight:400,pointerEvents:`none`,WebkitUserSelect:`none`,userSelect:`none`};return(0,D.jsxs)(`div`,{ref:_,className:h(`relative h-full w-full terminal-viewport-container`,s),"data-hidden-input-overlay-active":I?`true`:void 0,style:{backgroundColor:i.background},onTouchStart:e=>{if(!(!I||c)&&!Ce()){let t=e.touches?.[0];z(t?.clientX,t?.clientY)}},onClick:e=>{if(!c)if(I){if(Ce())return;z(e.clientX,e.clientY)}else y.current?.focus()},onMouseUp:()=>{!c&&Ce()&&Se()},onTouchEnd:()=>{!c&&Ce()&&Se()},children:[I&&typeof document<`u`?(0,ie.createPortal)((0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`input`,{ref:M,type:`text`,inputMode:`text`,autoCapitalize:`off`,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,tabIndex:-1,enterKeyHint:`send`,"data-terminal-hidden-input":`true`,"aria-label":g(`terminalView.viewport.inputAria`),"aria-hidden":`true`,style:{...Ae,display:R?`block`:`none`},onBlur:J,onBeforeInput:Y,onCompositionStart:()=>{N.current=!0},onInput:X,onKeyDown:Ee,onKeyUp:De,onCompositionEnd:Oe,onPaste:ke}),(0,D.jsx)(`textarea`,{ref:ce,inputMode:`text`,autoCapitalize:`off`,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,tabIndex:-1,enterKeyHint:`send`,"data-terminal-hidden-input":`true`,"aria-label":g(`terminalView.viewport.inputAria`),"aria-hidden":`true`,style:{...Ae,display:R?`none`:`block`},onBlur:J,onBeforeInput:Y,onCompositionStart:()=>{N.current=!0},onInput:X,onKeyDown:Ee,onKeyUp:De,onCompositionEnd:Oe,onPaste:ke})]}),document.body):null,v.current&&!c?(0,D.jsx)(b,{containerRef:v,disableHorizontal:!0,className:`overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero`}):null]})});oe.displayName=`TerminalViewport`;var A=RegExp(`\x1B\\[[0-9;?]*[ -/]*[@-~]`,`g`),j=/(https?:\/\/(?:localhost|127\.0\.0\.1|0\.0\.0\.0|\[(?:::1|::)\])(?::\d{2,5})?(?:\/[^\s<>'"`]*)?)/gi,se=/(?:➜\s*(?:Local|Network):)|\b(?:local|network|loopback|serving|listening|available|ready|started|running|server|vite|webpack|next\.js|astro|sveltekit|nuxt)\b/i,ce=/Serving HTTP on .*? port (\d{2,5})/i,M=new Set([`.`,`,`,`;`,`:`,`!`,`?`]),N=e=>{let t=e;for(;t.length>0;){let e=t[t.length-1];if(e===`)`||e===`]`||e===`}`||e===`>`){let n=e===`)`?`(`:e===`]`?`[`:e===`}`?`{`:`<`,r=t.slice(0,-1);if((r.match(RegExp(`\\${n}`,`g`))||[]).length>(r.match(RegExp(`\\${e}`,`g`))||[]).length)break;t=r;continue}if(M.has(e)){t=t.slice(0,-1);continue}break}return t},P=e=>{let t=N(e);return t=t.replace(`0.0.0.0`,`127.0.0.1`),t=t.replace(`[::1]`,`127.0.0.1`),t=t.replace(`[::]`,`127.0.0.1`),t},le=e=>{if(!e)return null;let t=e.replace(A,``),n=t.match(ce);if(n?.[1]){let e=Number.parseInt(n[1],10);if(Number.isFinite(e)&&e>0&&e<=65535)return`http://127.0.0.1:${e}/`}let r=t.split(`
2
2
  `);for(let e of r){if(!se.test(e))continue;let t=Array.from(e.matchAll(j));if(t.length!==0)return P((t.find(e=>{try{return!!new URL(P(e[1])).port}catch{return!1}})??t[0])[1])}return null},ue=async(e,t=1500)=>{if(!e||typeof window>`u`)return!1;let n;try{n=new URL(e)}catch{return!1}if(n.protocol!==`http:`&&n.protocol!==`https:`)return!1;let r=n.hostname.toLowerCase();if(r!==`localhost`&&r!==`127.0.0.1`&&r!==`0.0.0.0`&&r!==`::1`&&r!==`::`)return!1;let i=new AbortController,o=window.setTimeout(()=>i.abort(),t);try{let e=await a(`/api/system/probe-url`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:n.toString()}),cache:`no-store`,signal:i.signal});return e.ok?(await e.json().catch(()=>null))?.ok===!0:!1}catch{return!1}finally{window.clearTimeout(o)}},de={esc:`\x1B`,tab:` `,enter:`\r`,"arrow-up":`\x1B[A`,"arrow-down":`\x1B[B`,"arrow-left":`\x1B[D`,"arrow-right":`\x1B[C`},F={ctrl:`5`,cmd:`3`},fe={retry:{maxRetries:3,initialDelayMs:500,maxDelayMs:8e3},connectionTimeoutMs:1e4},pe={retry:{maxRetries:8,initialDelayMs:400,maxDelayMs:8e3},connectionTimeoutMs:15e3},me=(e,t)=>{if(t)switch(e){case`arrow-up`:return`\u001b[1;${F[t]}A`;case`arrow-down`:return`\u001b[1;${F[t]}B`;case`arrow-right`:return`\u001b[1;${F[t]}C`;case`arrow-left`:return`\u001b[1;${F[t]}D`}return de[e]??null},he=()=>{let{t:e}=ee(),{terminal:a,runtime:o}=te(),{currentTheme:s}=v(),{monoFont:c}=w(),u=r(e=>e.terminalFontSize),d=r(e=>e.bottomTerminalHeight),f=r(e=>e.isBottomTerminalExpanded),{isMobile:p,isTablet:b,hasTouchOnlyPointer:re}=y(),ie=p||b,O=(ie||re)&&o.platform===`web`,k=o.platform!==`vscode`,ae=r(e=>e.showTerminalQuickKeysOnDesktop),A=!i()&&(ie||ae),j=m(e=>e.currentSessionId),se=m(e=>e.newSessionDraft),ce=j!==null||se?.open===!0,M=x()??null,N=C(e=>e.sessions),P=C(e=>e.hasHydrated),de=C(e=>e.ensureDirectory),F=C(e=>e.createTab),he=C(e=>e.setActiveTab),ge=C(e=>e.closeTab),_e=C(e=>e.setTabSessionId),ve=C(e=>e.setTabLifecycle),I=C(e=>e.setConnecting),ye=C(e=>e.appendToBuffer),L=C(e=>e.setTabPreviewUrl),R=C(e=>e.clearBuffer),z=r(e=>e.openContextPreview),B=E.useMemo(()=>{if(M)return N.get(M)},[N,M]),V=E.useMemo(()=>B?k?B.activeTabId??B.tabs[0]?.id??null:B.tabs[0]?.id??null:null,[B,k]),H=E.useMemo(()=>{if(B)return V?B.tabs.find(e=>e.id===V)??B.tabs[0]:B.tabs[0]},[B,V]),be=E.useMemo(()=>(B?.tabs??[]).map(t=>({icon:(()=>{let e=t.iconKey?T[t.iconKey]??`terminal`:`terminal`;return(0,D.jsx)(g,{name:e,className:`h-4 w-4`})})(),id:t.id,label:t.label,title:t.label,closeLabel:e(`terminalView.tabs.closeTabTitle`)})),[B?.tabs,e]),U=H?.terminalSessionId??null,xe=H?.lifecycle??`idle`,Se=H?.bufferChunks??[],Ce=H?.isConnecting??!1,W=H?.previewUrl??null,[G,K]=E.useState(null),[we,q]=E.useState(!1),[Te,J]=E.useState(!1),[Y,X]=E.useState(null),[Ee,De]=E.useState(!1),[Oe,ke]=E.useState(0),Ae=E.useRef(null),je=E.useRef(null),Me=E.useRef(V),Ne=E.useRef(U),Pe=E.useRef(M),Fe=E.useRef(null),Ie=E.useRef(null),Le=E.useRef(!1),Re=E.useRef(!1),ze=E.useRef(null),Be=E.useRef(null),Ve=E.useRef(new Set),He=E.useRef(!1),Ue=E.useRef(``),We=E.useRef(new Set),Ge=E.useRef(0),Ke=E.useCallback(()=>{Ue.current=``,We.current.clear(),Ge.current+=1},[]),qe=E.useCallback(()=>{O||typeof document<`u`&&!document.hasFocus()||Fe.current?.focus()},[O]),Je=E.useCallback(()=>{O||Fe.current?.focus()},[O]);E.useEffect(()=>{if(!P||He.current)return;He.current=!0;let e=new Set;for(let[,t]of C.getState().sessions.entries())for(let n of t.tabs)n.terminalSessionId&&e.add(n.terminalSessionId);Ve.current=e},[P]);let Ye=r(e=>e.activeMainTab),Xe=r(e=>e.isBottomTerminalOpen),Ze=r(e=>e.setBottomTerminalOpen),Qe=r(e=>e.setBottomTerminalExpanded),$e=Ye===`terminal`,Z=$e||Xe,[et,tt]=E.useState(Z);E.useEffect(()=>{!Z||o.platform===`vscode`||l()},[Z,o.platform]),E.useEffect(()=>{Z&&tt(!0)},[Z]),E.useEffect(()=>{Re.current=Z},[Z]),E.useEffect(()=>{Ne.current=U},[U]),E.useEffect(()=>{Me.current=V,Ke()},[V,Ke]),E.useEffect(()=>{Pe.current=M},[M]),E.useEffect(()=>{!A&&Y!==null&&X(null)},[A,Y,X]),E.useEffect(()=>{!U&&Y!==null&&X(null)},[U,Y,X]);let Q=E.useCallback(()=>{Ae.current?.(),Ae.current=null,je.current=null,ze.current=null,J(!1)},[]);E.useEffect(()=>()=>{Q(),Ne.current=null},[Q]);let nt=E.useCallback((e,t,n)=>{if(!n)return;let r=`${Ue.current}${n}`.replace(/\r\n|\r/g,`
3
3
  `),i=r.split(`
4
4
  `),a=r.endsWith(`
@@ -1,4 +1,4 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{g as t}from"./useUIStore-D6BTB4va.js";import{kn as n}from"./persistence-C_KCiMcY.js";import{nt as r,rt as i,tt as a}from"./vendor-base-ui-CnHfUmDN.js";import{n as o}from"./vendor-react-DLPElpoQ.js";import{n as s}from"./vendor-reactuses-core-DDoDDyM9.js";import{n as c}from"./clipboard-CXWbHCAk.js";import{t as l}from"./utils-DyUyiLje.js";import{n as u}from"./Icon-BPJ_quEe.js";import{n as d,t as f}from"./dialog-BV1ENlLf.js";import{t as p}from"./button-BmNJBT13.js";import{n as m,t as h}from"./useThemeSystem-DMzWVJaW.js";import{l as g,n as _,v,x as y}from"./markdownTheme-CCnvI6L0.js";import{c as b,i as ee,t as x}from"./appThemeRegistry-DAgBeFsZ.js";import{p as S}from"./markdown-worker-Cq3Twp1A.js";import{n as C}from"./useEffectiveDirectory-dCGvvYRh.js";import{_ as te,d as ne,f as w,g as T,h as re,l as E,m as ie,n as D,p as O,r as k,s as A,t as j,u as M}from"./useWorkerHighlightedLines-05dLFgTI.js";import{t as N}from"./vendor-tanstack-react-virtual-tlDgH6PG.js";import{a as P,i as F}from"./vendor-pierre-diffs-BenIz2TM.js";var I=e(a(),1),L=o(),R=e(i(),1),z=r(),B=80,ae=20,V=R.memo(e=>{let t=(0,L.c)(26),{lines:n,language:r,maxHeight:i,showLineNumbers:a,lineStyles:o}=e,s=i===void 0?`60vh`:i,c=a===void 0||a,{currentTheme:l}=m(),u;t[0]===l?u=t[1]:(u=_(l),t[0]=l,t[1]=u);let d=u,f;t[2]===n?f=t[3]:(f=n.map(W).join(`
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{g as t}from"./useUIStore-D6BTB4va.js";import{kn as n}from"./persistence-C_KCiMcY.js";import{nt as r,rt as i,tt as a}from"./vendor-base-ui-CnHfUmDN.js";import{n as o}from"./vendor-react-DLPElpoQ.js";import{n as s}from"./vendor-reactuses-core-DDoDDyM9.js";import{n as c}from"./clipboard-CXWbHCAk.js";import{t as l}from"./utils-DyUyiLje.js";import{n as u}from"./Icon-BPJ_quEe.js";import{n as d,t as f}from"./dialog-BV1ENlLf.js";import{t as p}from"./button-BmNJBT13.js";import{n as m,t as h}from"./useThemeSystem-DMzWVJaW.js";import{l as g,n as _,v,x as y}from"./markdownTheme-CCnvI6L0.js";import{c as b,i as ee,t as x}from"./appThemeRegistry-BXeIggYO.js";import{p as S}from"./markdown-worker-Cq3Twp1A.js";import{n as C}from"./useEffectiveDirectory-DG6uPzBG.js";import{_ as te,d as ne,f as w,g as T,h as re,l as E,m as ie,n as D,p as O,r as k,s as A,t as j,u as M}from"./useWorkerHighlightedLines-ADgu9578.js";import{t as N}from"./vendor-tanstack-react-virtual-tlDgH6PG.js";import{a as P,i as F}from"./vendor-pierre-diffs-BenIz2TM.js";var I=e(a(),1),L=o(),R=e(i(),1),z=r(),B=80,ae=20,V=R.memo(e=>{let t=(0,L.c)(26),{lines:n,language:r,maxHeight:i,showLineNumbers:a,lineStyles:o}=e,s=i===void 0?`60vh`:i,c=a===void 0||a,{currentTheme:l}=m(),u;t[0]===l?u=t[1]:(u=_(l),t[0]=l,t[1]=u);let d=u,f;t[2]===n?f=t[3]:(f=n.map(W).join(`
2
2
  `),t[2]=n,t[3]=f);let p=j(f,r);if(!(n.length>B)){let e=d,r;t[4]!==s||t[5]!==e?(r={...e,maxHeight:s,overflow:`auto`},t[4]=s,t[5]=e,t[6]=r):r=t[6];let i;if(t[7]!==p||t[8]!==o||t[9]!==n||t[10]!==c){let e;t[12]!==p||t[13]!==o||t[14]!==c?(e=(e,t)=>(0,z.jsx)(U,{line:e,html:p?.[t],showLineNumbers:c,style:o?.(e)},t),t[12]=p,t[13]=o,t[14]=c,t[15]=e):e=t[15],i=n.map(e),t[7]=p,t[8]=o,t[9]=n,t[10]=c,t[11]=i}else i=t[11];let a;return t[16]!==r||t[17]!==i?(a=(0,z.jsx)(`div`,{className:`typography-code font-mono w-full min-w-0`,style:r,children:i}),t[16]=r,t[17]=i,t[18]=a):a=t[18],a}let h;return t[19]!==p||t[20]!==o||t[21]!==n||t[22]!==s||t[23]!==c||t[24]!==d?(h=(0,z.jsx)(H,{lines:n,highlighted:p,syntaxVars:d,maxHeight:s,showLineNumbers:c,lineStyles:o}),t[19]=p,t[20]=o,t[21]=n,t[22]=s,t[23]=c,t[24]=d,t[25]=h):h=t[25],h});V.displayName=`VirtualizedCodeBlock`;var H=R.memo(({lines:e,highlighted:t,syntaxVars:n,maxHeight:r,showLineNumbers:i,lineStyles:a})=>{let o=R.useRef(null),s=`min(${e.length*ae}px, ${r})`,c=N({count:e.length,getScrollElement:()=>o.current,estimateSize:()=>ae,overscan:20}),l=c.getVirtualItems();return(0,z.jsx)(`div`,{ref:o,className:`typography-code font-mono w-full min-w-0`,style:{...n,height:s,maxHeight:r,overflow:`auto`},children:(0,z.jsx)(`div`,{style:{height:c.getTotalSize(),position:`relative`},children:l.map(n=>{let r=e[n.index];return r?(0,z.jsx)(`div`,{"data-index":n.index,ref:c.measureElement,style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${n.start}px)`},children:(0,z.jsx)(U,{line:r,html:t?.[n.index],showLineNumbers:i,style:a?.(r)})},n.index):null})})})});H.displayName=`VirtualizedRows`;var U=R.memo(e=>{let t=(0,L.c)(12),{line:n,html:r,showLineNumbers:i,style:a}=e,o;t[0]!==n.isInfo||t[1]!==n.lineNumber||t[2]!==i?(o=i&&(0,z.jsx)(`span`,{className:`w-10 flex-shrink-0 text-right pr-3 select-none border-r mr-3 -my-0.5 py-0.5`,style:{color:`var(--tools-edit-line-number)`,borderColor:`var(--tools-border)`},children:!n.isInfo&&n.lineNumber!=null?n.lineNumber:``}),t[0]=n.isInfo,t[1]=n.lineNumber,t[2]=i,t[3]=o):o=t[3];let s;t[4]!==r||t[5]!==n.isInfo||t[6]!==n.text?(s=(0,z.jsx)(`div`,{className:`flex-1 min-w-0`,children:n.isInfo?(0,z.jsx)(`div`,{className:`whitespace-pre-wrap break-words text-muted-foreground/70 italic`,children:n.text}):r===void 0?(0,z.jsx)(`div`,{className:`whitespace-pre`,children:n.text}):(0,z.jsx)(`div`,{className:`whitespace-pre`,dangerouslySetInnerHTML:{__html:r}})}),t[4]=r,t[5]=n.isInfo,t[6]=n.text,t[7]=s):s=t[7];let c;return t[8]!==a||t[9]!==o||t[10]!==s?(c=(0,z.jsxs)(`div`,{className:`typography-code font-mono flex w-full min-w-0`,style:a,children:[o,s]}),t[8]=a,t[9]=o,t[10]=s,t[11]=c):c=t[11],c});U.displayName=`VirtualizedCodeBlock.Row`;function W(e){return e.text}var G=R.memo(function({jsonString:e,className:t,maxHeight:n=`100%`,initiallyExpandedDepth:r=2}){let{t:i}=c(),a=R.useRef(null),[o,s]=R.useState(null),l=R.useMemo(()=>{try{let t=e.trim();if(!t)return s(i(`jsonTreeView.error.emptyJson`)),null;let n=JSON.parse(t);return s(null),n}catch(e){return s(e instanceof Error?e.message:i(`jsonTreeView.error.invalidJson`)),null}},[e,i]),d=R.useCallback(()=>{a.current?.expandAll()},[]),f=R.useCallback(()=>{a.current?.collapseAll()},[]);return o?(0,z.jsx)(`div`,{className:t,children:(0,z.jsxs)(`div`,{className:`rounded-md border border-[var(--interactive-border)] bg-[var(--syntax-base-background)] p-4`,children:[(0,z.jsx)(`div`,{className:`mb-1 font-medium text-[var(--surface-foreground)]`,children:i(`jsonTreeView.error.invalidJsonTitle`)}),(0,z.jsx)(`div`,{className:`font-mono text-xs text-[var(--surface-mutedForeground)]`,children:o})]})}):l===null?null:(0,z.jsxs)(`div`,{className:t,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-[var(--interactive-border)] px-2 py-1`,children:[(0,z.jsxs)(p,{variant:`ghost`,size:`xs`,onClick:d,className:`gap-1 text-xs text-muted-foreground`,children:[(0,z.jsx)(u,{name:`arrow-down-s`,className:`h-3 w-3`}),i(`jsonTreeView.actions.expandAll`)]}),(0,z.jsxs)(p,{variant:`ghost`,size:`xs`,onClick:f,className:`gap-1 text-xs text-muted-foreground`,children:[(0,z.jsx)(u,{name:`arrow-up-s`,className:`h-3 w-3`}),i(`jsonTreeView.actions.collapseAll`)]})]}),(0,z.jsx)(`div`,{className:`bg-[var(--syntax-base-background)] py-1`,style:{maxHeight:n,overflow:`auto`},children:(0,z.jsx)(k,{ref:a,data:l,maxHeight:n,initiallyExpandedDepth:r})})]})}),K=class extends Error{key;params;constructor(e,t){super(e),this.name=`MermaidLoadFailure`,this.key=e,this.params=t}},q=(e,t)=>new K(e,t),oe=e=>e instanceof K,se=e=>e+1,ce=(e,t)=>e===t,J=e=>{let t=e.indexOf(`,`);if(t<0)throw q(`chat.toolOutputDialog.mermaid.dataUrlMalformed`);let n=e.slice(0,t).toLowerCase(),r=e.slice(t+1);return n.includes(`;base64`)?atob(r):decodeURIComponent(r)},le=e=>Promise.resolve().then(()=>J(e)),Y=1,X=56,Z=(e,t,n)=>Math.min(n,Math.max(t,e)),ue=({isMobile:e,pointerType:t,cancelled:n,moved:r,suppressTap:i,targetWasCanvas:a,start:o,end:s,startScale:c,hasMultipleImages:l})=>{if(n||i)return`none`;let u={x:s.x-o.x,y:s.y-o.y},d=Math.hypot(u.x,u.y),f=t!==`mouse`;if(e&&f&&c<=1.01&&Math.abs(u.x)>=X&&Math.abs(u.x)>Math.abs(u.y)*1.2)return l?u.x<0?`next`:`previous`:`none`;let p=!r&&d<=10;return e&&f&&p||!e&&t===`mouse`&&p&&a?`close`:`none`},de=(e,t)=>{if(e.width<=0||e.height<=0||t.width<=0||t.height<=0)return{width:1,height:1};let n=Math.min(t.width/e.width,t.height/e.height);return{width:Math.max(1,e.width*n),height:Math.max(1,e.height*n)}},fe=(e,t)=>{let n=t.minScale??Y,r=t.maxScale??5,i=Z(e.scale,n,r),a=Math.max(0,(t.image.width*i-t.viewport.width)/2),o=Math.max(0,(t.image.height*i-t.viewport.height)/2);return{scale:i,x:Z(e.x,-a,a),y:Z(e.y,-o,o)}},pe=(e,t,n,r,i)=>{let a=Z(t,i.minScale??Y,i.maxScale??5),o=a/e.scale;return fe({scale:a,x:n.x-r.x-(n.x-r.x-e.x)*o,y:n.y-r.y-(n.y-r.y-e.y)*o},i)},me=(e,t,n)=>fe({...e,x:e.x+t.x,y:e.y+t.y},n),he=(e,t,n,r,i,a)=>{let o=Z(r,a.minScale??Y,a.maxScale??5),s=o/e.scale;return fe({scale:o,x:n.x-i.x-(t.x-i.x-e.x)*s,y:n.y-i.y-(t.y-i.y-e.y)*s},a)},Q=500,$=24,ge=(e,t={})=>{let n=t.target??(typeof document>`u`?null:document);if(!n)return()=>{};let r=t.durationMs??Q,i=t.maxDistance??$,a=!0,o,s=()=>{a&&(a=!1,n.removeEventListener(`click`,c,!0),o!==void 0&&globalThis.clearTimeout(o))},c=t=>{let n=t;typeof n.clientX==`number`&&typeof n.clientY==`number`&&(Math.hypot(n.clientX-e.x,n.clientY-e.y)>i||(s(),t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation()))};return n.addEventListener(`click`,c,!0),o=globalThis.setTimeout(s,r),s},_e=(e,t,n={})=>{ge(e,n),t()},ve=500,ye=400,be=(e,t)=>new K(e,t),xe=e=>{let t=`h-3.5 w-3.5 flex-shrink-0`,n=e.toLowerCase();return n===`reasoning`?(0,z.jsx)(u,{name:`brain-ai-3`,className:t}):n===`image-preview`?(0,z.jsx)(u,{name:`file-image`,className:t}):n===`mermaid-preview`?(0,z.jsx)(u,{name:`file-list-2`,className:t}):n===`edit`||n===`multiedit`||n===`apply_patch`||n===`str_replace`||n===`str_replace_based_edit_tool`?(0,z.jsx)(u,{name:`pencil-ai`,className:t}):n===`write`||n===`create`||n===`file_write`||n===`read`||n===`view`||n===`file_read`||n===`cat`?(0,z.jsx)(u,{name:`file-pdf`,className:t}):n===`bash`||n===`shell`||n===`cmd`||n===`terminal`?(0,z.jsx)(u,{name:`terminal-box`,className:t}):n===`list`||n===`ls`||n===`dir`||n===`list_files`?(0,z.jsx)(u,{name:`folder-6`,className:t}):n===`search`||n===`grep`||n===`find`||n===`ripgrep`?(0,z.jsx)(u,{name:`search`,className:t}):n===`glob`?(0,z.jsx)(u,{name:`file-search`,className:t}):n===`fetch`||n===`curl`||n===`wget`||n===`webfetch`?(0,z.jsx)(u,{name:`global`,className:t}):n===`web-search`||n===`websearch`||n===`search_web`||n===`google`||n===`bing`||n===`duckduckgo`?(0,z.jsx)(u,{name:`search`,className:t}):n===`todowrite`||n===`todoread`?(0,z.jsx)(u,{name:`list-check-3`,className:t}):n===`plan_enter`?(0,z.jsx)(u,{name:`file-list-2`,className:t}):n===`plan_exit`?(0,z.jsx)(u,{name:`task`,className:t}):n.startsWith(`git`)?(0,z.jsx)(u,{name:`git-branch`,className:t}):(0,z.jsx)(u,{name:`tools`,className:t})},Se=150,Ce=40,we=120,Te=3,Ee={style:{background:`transparent`,backgroundColor:`transparent`,fontSize:`inherit`}},De={download:!1,copy:!1,showPanZoomControls:!0},Oe=`
3
3
  [data-diff-header],
4
4
  [data-diff] {
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownRendererImpl-Cv8V-Q5l.js","assets/rolldown-runtime-C0FnF6B9.js","assets/useUIStore-D6BTB4va.js","assets/vendor-zustand-B4dlGEM2.js","assets/vendor-base-ui-CnHfUmDN.js","assets/persistence-C_KCiMcY.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-react-DLPElpoQ.js","assets/vendor-tanstack-query-core-BWz0ose6.js","assets/vendor-reactuses-core-DDoDDyM9.js","assets/vendor-lodash-es-DfLbG5Af.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/clipboard-CXWbHCAk.js","assets/store-oojlrF4d.js","assets/vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js","assets/useMobileNavigationStore-1xHjnAsg.js","assets/gitApiHttp-C1DaEMKR.js","assets/vendor-opencode-sdk-C07HQypa.js","assets/vendor-tanstack-react-query-D7pys_c9.js","assets/vendor-sonner-DVzioF3d.js","assets/useAssistantUIStore-ESTV1mEY.js","assets/vendor-fuse.js-DB5wDJbI.js","assets/utils-DyUyiLje.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/useThemeSystem-DMzWVJaW.js","assets/markdownTheme-CCnvI6L0.js","assets/vendor-pierre-diffs-BenIz2TM.js","assets/vendor-hast-util-to-html-B0p1k5Xa.js","assets/vendor-character-entities-legacy-Wut6vMuj.js","assets/vendor-character-entities-html4-DlN_yAFd.js","assets/vendor-ccount-CyGsA0u7.js","assets/vendor-comma-separated-tokens-B9ouxNNS.js","assets/vendor-oniguruma-to-es-CrHzjjSU.js","assets/vendor-oniguruma-parser-D2DIvhSP.js","assets/vendor-diff-Dq7CZNim.js","assets/vendor-lru_map-DpDied8H.js","assets/useRuntimeAPIs-DSLXJybW.js","assets/url-CGHw6D-E.js","assets/markdown-worker-Cq3Twp1A.js","assets/useEffectiveDirectory-DG6uPzBG.js","assets/FadeInOnReveal-CvNA_aGD.js","assets/vendor-morphdom-BbKiNDAu.js","assets/vendor-beautiful-mermaid-DykqIK5D.js","assets/vendor-marked-WVekxjAN.js","assets/vendor-remend-C3cXc-tf.js","assets/vendor-katex-CNGgSigB.js","assets/vendor-dompurify-CeJNOzik.js"])))=>i.map(i=>d[i]);
2
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{nt as t,rt as n}from"./vendor-base-ui-CnHfUmDN.js";import{a as r,n as i,o as a}from"./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js";import{n as o}from"./vendor-react-DLPElpoQ.js";import{n as s}from"./vendor-reactuses-core-DDoDDyM9.js";import{Co as c}from"./useMobileNavigationStore-1xHjnAsg.js";import{t as l}from"./utils-DyUyiLje.js";import{a as u,c as d,i as f}from"./markdown-worker-Cq3Twp1A.js";import{r as p}from"./vendor-pierre-diffs-BenIz2TM.js";var m=o(),h=e(n(),1),g=`openchamber:chunk-import-reload`,_=250,v=3e4,y=[/Importing a module script failed/i,/Failed to fetch dynamically imported module/i,/error loading dynamically imported module/i,/Loading chunk \S+ failed/i,/ChunkLoadError/i];function b(e){if(e instanceof Error)return`${e.name}\n${e.message}\n${e.stack??``}`;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function x(e){let t=b(e);return y.some(e=>e.test(t))}function ee(e){return`1.17.1:${b(e).slice(0,500)}`}function S(e){if(typeof window>`u`)return;let t=Date.now(),n=ee(e),r=null;try{let e=window.sessionStorage.getItem(g);if(e)try{r=JSON.parse(e)}catch{r=null}}catch{return}let i=typeof r?.timestamp==`number`?r.timestamp:0;if(!(r?.signature===n&&t-i<v)){try{window.sessionStorage.setItem(g,JSON.stringify({signature:n,timestamp:t}))}catch{return}console.error(`[refresh-debug] chunk-import-reload`,{error:b(e).slice(0,1e3)}),window.setTimeout(()=>{window.location.reload()},0)}}async function te(e,t={}){let n=t.retries??1,r;for(let t=0;t<=n;t+=1)try{return await e()}catch(e){if(r=e,!x(e)||t>=n)break;await new Promise(e=>setTimeout(e,_*(t+1)))}throw x(r)&&S(r),r}var C=e=>(0,h.lazy)(()=>te(e)),w=`__openchamberMobileBackRoute`,T=()=>typeof window>`u`||c()?null:{currentState:()=>window.history.state&&typeof window.history.state==`object`?window.history.state:null,pushState:e=>window.history.pushState(e,``,window.location.href),back:()=>window.history.back(),subscribe:e=>{let t=t=>e(t.state&&typeof t.state==`object`?t.state:null);return window.addEventListener(`popstate`,t),()=>window.removeEventListener(`popstate`,t)}},E=e=>{let t=e?.[w];return typeof t==`number`&&Number.isFinite(t)?t:null},D=new class{routes=[];listeners=new Set;nextToken=1;history;removeHistoryListener=null;programmaticHistoryBackToken=null;pendingHistoryRemovals=new Map;animatedBackDriver=null;presentationCancelDriver=null;constructor(e=T()){this.history=e}subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));getTopRoute=()=>this.routes.at(-1)??null;register=e=>{let t=this.pendingHistoryRemovals.get(e.id);this.pendingHistoryRemovals.delete(e.id);let n=!!(this.history&&t!==void 0&&E(this.history.currentState())===t),r={...e,token:n&&t!==void 0?t:this.nextToken++};this.routes.push(r),this.ensureHistoryListener(),this.history&&!n&&this.history.pushState({...this.history.currentState()??{},[w]:r.token}),this.notify();let i=!0;return()=>{if(!i)return;i=!1;let e=this.routes.indexOf(r);e<0||(this.routes.splice(e,1),this.history&&E(this.history.currentState())===r.token?(this.pendingHistoryRemovals.set(r.id,r.token),queueMicrotask(()=>{if(this.pendingHistoryRemovals.get(r.id)===r.token){if(this.pendingHistoryRemovals.delete(r.id),!this.history||E(this.history.currentState())!==r.token){this.routes.length===0&&this.pendingHistoryRemovals.size===0&&this.disposeHistoryListener();return}this.programmaticHistoryBackToken=r.token,this.history.back(),this.routes.length===0&&this.pendingHistoryRemovals.size===0&&this.disposeHistoryListener()}})):this.routes.length===0&&this.pendingHistoryRemovals.size===0&&this.disposeHistoryListener(),this.notify())}};backImmediately=e=>{let t=this.getTopRoute();return!t||e&&t.layer!==e?!1:t.onBack()!==!1};requestAnimatedBack=e=>{let t=this.getTopRoute();return!t||e&&t.layer!==e?!1:this.animatedBackDriver?.(t)?!0:this.backImmediately(e)};setAnimatedBackDriver=e=>(this.animatedBackDriver=e,()=>{this.animatedBackDriver===e&&(this.animatedBackDriver=null)});setPresentationCancelDriver=e=>(this.presentationCancelDriver=e,()=>{this.presentationCancelDriver===e&&(this.presentationCancelDriver=null)});cancelPresentation=()=>{this.presentationCancelDriver?.()};requestBrowserBack=()=>{let e=this.getTopRoute();return e?this.history&&E(this.history.currentState())===e.token?(this.history.back(),!0):e.onBack()!==!1:!1};ensureHistoryListener(){!this.history||this.removeHistoryListener||(this.removeHistoryListener=this.history.subscribe(e=>{if(this.programmaticHistoryBackToken!==null){this.programmaticHistoryBackToken=null;return}let t=this.getTopRoute();t&&E(e)!==t.token&&t.onBack()===!1&&this.history&&this.history.pushState({...this.history.currentState()??{},[w]:t.token})}))}disposeHistoryListener(){this.removeHistoryListener?.(),this.removeHistoryListener=null,this.programmaticHistoryBackToken=null,this.pendingHistoryRemovals.clear()}notify(){this.listeners.forEach(e=>e())}},ne=e=>{let t=(0,m.c)(8),{id:n,active:r,layer:i,onBack:a,surfaceRef:o,underlayRef:c}=e,l=i===void 0?`root`:i,u=s(a),d,f;t[0]!==r||t[1]!==u||t[2]!==n||t[3]!==l||t[4]!==o||t[5]!==c?(d=()=>{if(r)return D.register({id:n,layer:l,onBack:u,getSurface:()=>o.current,getUnderlay:()=>c?.current??null})},f=[r,u,n,l,o,c],t[0]=r,t[1]=u,t[2]=n,t[3]=l,t[4]=o,t[5]=c,t[6]=d,t[7]=f):(d=t[6],f=t[7]),h.useEffect(d,f)},O=r(`OpenChamberNavigation`),k=e=>Math.min(1,Math.max(0,Number.isFinite(e)?e:0)),A=(e,t)=>!e||!t?!1:e.onBack()!==!1,j=e=>{let t=k(e.progress),n=e.commit?1-t:t;if(n<=.001)return 0;let r=Math.max(1,e.viewportWidth??390),i=Math.abs(e.velocityX??0)/r,a=n/Math.max(e.commit?2.4:2.8,i)*1e3,o=e.commit?90:100,s=e.commit?320:260;return Math.round(Math.min(s,Math.max(o,a)))},M=e=>{let{surface:t,underlay:n,surfaceTransition:r,surfaceAnimation:i,underlayTransition:a,underlayAnimation:o}=e;t.style.removeProperty(`transform`),t.style.removeProperty(`opacity`),t.style.removeProperty(`will-change`),t.style.removeProperty(`box-shadow`),t.style.transition=r,t.style.animation=i,n&&(n.style.removeProperty(`transform`),n.style.removeProperty(`opacity`),n.style.removeProperty(`will-change`),n.style.transition=a??``,n.style.animation=o??``)},N=(e,t)=>{let n=k(t),{surface:r}=e;r.style.transform=`translate3d(${n*100}%, 0, 0)`},re=e=>!e.surfaceConnected||e.topRouteToken!==e.routeToken||e.routeSurface!==e.outgoingSurface,ie=async(e,t,n,r)=>{if(!r&&typeof e.animate==`function`){let r=e.style.transform||`translate3d(0%, 0, 0)`,i=`translate3d(${t}%, 0, 0)`,a=e.animate([{transform:r},{transform:i}],{duration:n,easing:`cubic-bezier(0.22, 1, 0.36, 1)`,fill:`forwards`}),o=!1;try{await a.finished,o=!0}catch{}finally{o&&(e.style.transform=i),a.cancel()}return}e.style.transform=`translate3d(${t}%, 0, 0)`},ae=async(e,t,n=typeof window<`u`&&window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches,r=j({progress:Number.parseFloat(e.style.transform.match(/translate3d\(([-\d.]+)%/)?.[1]??`0`)/100,commit:t}))=>ie(e,t?100:0,r,n),oe=class{pending=0;enqueue(){this.pending+=1}take(){return this.pending!==0&&(--this.pending,!0)}clear(){this.pending=0}},se=e=>{let t=(0,m.c)(4),{enabled:n,rootRoutesBlocked:r}=e,a,o;t[0]!==n||t[1]!==r?(a=()=>{if(!n||!c()||i.getPlatform()===`web`)return;let e=!1,t=null,a=null,o=0,s=0,l=0,u=new oe,d=[],f=e=>!!e&&(!r||e?.layer===`overlay`),p=()=>{let e=f(D.getTopRoute());O.setEnabled({enabled:e}).catch(ce)},m=()=>{if(D.cancelPresentation(),a)return;let e=D.getTopRoute();if(!f(e))return;let n=e.getSurface();if(!n)return;n.getAnimations().forEach(le),a=null;let r=e.layer===`root`?e.getUnderlay():null,i=n.style.transition,o=n.style.animation,s=r?.style.transition??null,c=r?.style.animation??null;r?.getAnimations().forEach(P),n.style.transition=`none`,n.style.animation=`none`,n.style.willChange=`transform`,r&&(r.style.removeProperty(`transform`),r.style.removeProperty(`will-change`)),l+=1,t={route:e,surface:n,underlay:r,surfaceTransition:i,surfaceAnimation:o,underlayTransition:s,underlayAnimation:c},N(t,0)},h=e=>{s=k(e),!o&&(o=window.requestAnimationFrame(()=>{o=0,t&&N(t,s)}))},g=F,_=(n,r,i)=>{if(a)return n&&f(D.getTopRoute())?(u.enqueue(),!0):!1;o&&=(window.cancelAnimationFrame(o),0),t||m(),t&&r!==void 0&&N(t,r);let c=t,d=l;if(t=null,!c){if(!n)return!1;let e=D.getTopRoute();return A(e,f(e))}a=c;let p=window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches??!1,h=j({progress:k(r??s),commit:n,velocityX:i,viewportWidth:window.innerWidth});return ae(c.surface,n,p,h).then(async()=>{d===l&&(!e&&n&&(c.route.onBack(),await g(c)),d===l&&(M(c),a===c&&(a=null),!e&&u.take()&&_(!0,0,0)))}),!0},v=D.setAnimatedBackDriver(e=>e!==D.getTopRoute()||!f(e)?!1:_(!0,0,0)),y=D.subscribe(p);return(async()=>{let t=await O.addListener(`backStarted`,m),n=await O.addListener(`backProgressed`,e=>h(e.progress??0)),r=await O.addListener(`backCancelled`,e=>_(!1,e.progress,e.velocityX)),i=await O.addListener(`backInvoked`,e=>_(!0,e.progress,e.velocityX));if(e){await Promise.all([t.remove(),n.remove(),r.remove(),i.remove()]);return}d.push(t,n,r,i),p()})().catch(I),p(),()=>{e=!0,l+=1,u.clear(),y(),v(),o&&window.cancelAnimationFrame(o),t&&M(t),a&&(a.surface.getAnimations().forEach(L),a.underlay?.getAnimations().forEach(R),M(a)),t=null,a=null,O.setEnabled({enabled:!1}).catch(z),d.forEach(B)}},o=[n,r],t[0]=n,t[1]=r,t[2]=a,t[3]=o):(a=t[2],o=t[3]),h.useEffect(a,o)};function ce(){}function le(e){return e.cancel()}function P(e){return e.cancel()}function F(e){return new Promise(t=>{let n=0,r=12,i=!1,a=()=>{i||(i=!0,c(),n&&window.cancelAnimationFrame(n),t())},o=()=>{let t=D.getTopRoute();return re({surfaceConnected:e.surface.isConnected,routeToken:e.route.token,topRouteToken:t?.token??null,routeSurface:e.route.getSurface(),outgoingSurface:e.surface})},s=()=>{if(o()||r<=0){a();return}--r,n=window.requestAnimationFrame(s)},c=D.subscribe(()=>{o()&&a()});s()})}function I(){}function L(e){return e.cancel()}function R(e){return e.cancel()}function z(){}function B(e){e.remove()}var V=null,H=()=>(V??=a(()=>import(`./MarkdownRendererImpl-Cv8V-Q5l.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47])).catch(e=>{throw V=null,e}),V),U=()=>{H().catch(()=>void 0)},W=h.createContext(!0),G=()=>h.useContext(W),K=t(),ue=C(()=>H().then(e=>({default:e.MarkdownRenderer}))),de=C(()=>H().then(e=>({default:e.SimpleMarkdownRenderer}))),fe=e=>e===`tool`?`markdown-content markdown-tool`:e===`reasoning`?`markdown-content markdown-reasoning`:`markdown-content leading-relaxed`,q=e=>{let t=(0,m.c)(14),n=typeof e.content==`string`?e.content:``,r=typeof e.variant==`string`?e.variant:`assistant`,i;t[0]!==n||t[1]!==e.reserveMeasuredHeight||t[2]!==r?(i=e.reserveMeasuredHeight?u(f(n,r)):void 0,t[0]=n,t[1]=e.reserveMeasuredHeight,t[2]=r,t[3]=i):i=t[3];let a=i,o;t[4]!==e.className||t[5]!==e.variant?(o=l(`relative break-words w-full min-w-0`,fe(e.variant),typeof e.className==`string`?e.className:void 0),t[4]=e.className,t[5]=e.variant,t[6]=o):o=t[6];let s;t[7]!==n||t[8]!==e.animated||t[9]!==a?(s=(0,K.jsx)(d,{animated:e.animated,content:n,reservedHeight:a}),t[7]=n,t[8]=e.animated,t[9]=a,t[10]=s):s=t[10];let c;return t[11]!==o||t[12]!==s?(c=(0,K.jsx)(`div`,{className:o,"aria-busy":`true`,"data-markdown-hydration":`deferred`,children:s}),t[11]=o,t[12]=s,t[13]=c):c=t[13],c},pe=e=>{let t=(0,m.c)(4);if(!G()&&e.isStreaming!==!0){let n;return t[0]===e?n=t[1]:(n=(0,K.jsx)(q,{...e,animated:!1,reserveMeasuredHeight:!0}),t[0]=e,t[1]=n),n}let n;return t[2]===e?n=t[3]:(n=(0,K.jsx)(h.Suspense,{fallback:(0,K.jsx)(q,{...e,reserveMeasuredHeight:!0}),children:(0,K.jsx)(ue,{...e})}),t[2]=e,t[3]=n),n},me=e=>{let t=(0,m.c)(4);if(!G()){let n;return t[0]===e?n=t[1]:(n=(0,K.jsx)(q,{...e,animated:!1}),t[0]=e,t[1]=n),n}let n;return t[2]===e?n=t[3]:(n=(0,K.jsx)(h.Suspense,{fallback:(0,K.jsx)(q,{...e}),children:(0,K.jsx)(de,{...e})}),t[2]=e,t[3]=n),n},he=e=>/^#[0-9a-fA-F]{6}$/.test(e),ge=e=>/^#[0-9a-fA-F]{8}$/.test(e),_e=(e,t)=>/^[0-9a-fA-F]{2}$/.test(t)?he(e)?`${e}${t}`:ge(e)?`${e.slice(0,7)}${t}`:e:e,J=(e,t)=>typeof e==`string`&&e.trim().length>0?e:t,Y=e=>{let t=e.colors.syntax.base,n=e.colors.syntax.tokens??{},r=(e,t)=>J(n[e],t);return[{name:`plain`,scope:[`source`,`support.type.property-name.css`],settings:{foreground:t.foreground}},{name:`classes`,scope:[`entity.name.type.class`],settings:{foreground:r(`className`,r(`class`,t.function))}},{name:`interfaces`,scope:[`entity.name.type.interface`,`entity.name.type`],settings:{foreground:r(`interface`,t.type)}},{name:`structs`,scope:[`entity.name.type.struct`],settings:{foreground:r(`struct`,t.function)}},{name:`enums`,scope:[`entity.name.type.enum`],settings:{foreground:r(`enum`,t.function)}},{name:`keys`,scope:[`meta.object-literal.key`,`support.type.property-name`],settings:{foreground:r(`key`,t.function)}},{name:`methods`,scope:[`entity.name.function.method`,`meta.function.method`],settings:{foreground:r(`method`,e.colors.status.success)}},{name:`functions`,scope:[`entity.name.function`,`support.function`,`meta.function-call.generic`],settings:{foreground:t.function,fontStyle:`bold`}},{name:`variables`,scope:[`variable`,`meta.variable`,`variable.other.object.property`],settings:{foreground:t.variable}},{name:`variablesOther`,scope:[`variable.other.object`,`variable.other.readwrite.alias`],settings:{foreground:r(`variableOther`,r(`method`,e.colors.status.success))}},{name:`globalVariables`,scope:[`variable.other.global`,`variable.language.this`],settings:{foreground:r(`variableGlobal`,t.number)}},{name:`localVariables`,scope:[`variable.other.local`],settings:{foreground:r(`variableLocal`,e.colors.surface.elevated)}},{name:`parameters`,scope:[`variable.parameter`,`meta.parameter`],settings:{foreground:r(`parameter`,t.foreground)}},{name:`properties`,scope:[`variable.other.property`,`meta.property`],settings:{foreground:r(`variableProperty`,e.colors.status.info)}},{name:`strings`,scope:[`string`,`string.other.link`,`markup.inline.raw.string.markdown`],settings:{foreground:t.string}},{name:`stringEscapeSequences`,scope:[`constant.character.escape`,`constant.other.placeholder`],settings:{foreground:r(`stringEscape`,t.foreground)}},{name:`keywords`,scope:[`keyword`],settings:{foreground:t.keyword}},{name:`keywordsControl`,scope:[`keyword.control.import`,`keyword.control.from`,`keyword.import`],settings:{foreground:r(`keywordImport`,t.operator)}},{name:`storageModifiers`,scope:[`storage.modifier`,`keyword.modifier`,`storage.type`],settings:{foreground:r(`storageModifier`,t.keyword)}},{name:`comments`,scope:[`comment`,`punctuation.definition.comment`],settings:{foreground:t.comment}},{name:`docComments`,scope:[`comment.documentation`,`comment.line.documentation`],settings:{foreground:r(`commentDoc`,e.colors.surface.mutedForeground)}},{name:`numbers`,scope:[`constant.numeric`],settings:{foreground:t.number}},{name:`booleans`,scope:[`constant.language.boolean`,`constant.language.json`],settings:{foreground:r(`boolean`,t.type)}},{name:`operators`,scope:[`keyword.operator`],settings:{foreground:t.operator}},{name:`macros`,scope:[`entity.name.function.preprocessor`,`meta.preprocessor`],settings:{foreground:r(`macro`,t.keyword)}},{name:`preprocessor`,scope:[`meta.preprocessor`],settings:{foreground:r(`preprocessor`,r(`label`,t.number))}},{name:`urls`,scope:[`markup.underline.link`],settings:{foreground:r(`url`,e.colors.status.info)}},{name:`tags`,scope:[`entity.name.tag`],settings:{foreground:r(`tag`,t.keyword)}},{name:`jsxTags`,scope:[`support.class.component`],settings:{foreground:r(`jsxTag`,r(`label`,t.number))}},{name:`attributes`,scope:[`entity.other.attribute-name`,`meta.attribute`],settings:{foreground:r(`tagAttribute`,t.type)}},{name:`types`,scope:[`support.type`],settings:{foreground:t.type}},{name:`constants`,scope:[`variable.other.constant`,`variable.readonly`],settings:{foreground:r(`constant`,t.foreground)}},{name:`labels`,scope:[`entity.name.label`,`punctuation.definition.label`],settings:{foreground:r(`label`,r(`variableGlobal`,t.number))}},{name:`namespaces`,scope:[`entity.name.namespace`,`storage.modifier.namespace`,`markup.bold.markdown`],settings:{foreground:r(`namespace`,t.type)}},{name:`modules`,scope:[`entity.name.module`,`storage.modifier.module`],settings:{foreground:r(`module`,t.operator)}},{name:`typeParameters`,scope:[`variable.type.parameter`,`variable.parameter.type`],settings:{foreground:r(`typeParameter`,t.function)}},{name:`exceptions`,scope:[`keyword.control.exception`,`keyword.control.trycatch`],settings:{foreground:r(`exception`,r(`label`,t.number))}},{name:`decorators`,scope:[`meta.decorator`,`punctuation.decorator`,`entity.name.function.decorator`],settings:{foreground:r(`decorator`,t.type)}},{name:`calls`,scope:[`variable.function`],settings:{foreground:t.foreground}},{name:`punctuation`,scope:[`punctuation`,`punctuation.terminator`,`punctuation.definition.tag`,`punctuation.separator`,`punctuation.definition.string`,`punctuation.section.block`],settings:{foreground:r(`punctuation`,t.comment)}},{name:`yellow`,scope:[`storage.type.numeric.go`,`storage.type.byte.go`,`storage.type.boolean.go`,`storage.type.string.go`,`storage.type.uintptr.go`,`storage.type.error.go`,`storage.type.rune.go`,`constant.language.go`,`support.class.dart`,`keyword.other.documentation`,`storage.modifier.import.java`,`punctuation.definition.list.begin.markdown`,`punctuation.definition.quote.begin.markdown`,`meta.separator.markdown`,`entity.name.section.markdown`],settings:{foreground:t.type}},{name:`green`,scope:[],settings:{foreground:r(`method`,e.colors.status.success)}},{name:`cyan`,scope:[`markup.italic.markdown`,`support.type.python`,`variable.legacy.builtin.python`,`support.constant.property-value.css`,`storage.modifier.attribute.swift`],settings:{foreground:t.string}},{name:`blue`,scope:[],settings:{foreground:t.keyword}},{name:`purple`,scope:[`keyword.channel.go`,`keyword.other.platform.os.swift`],settings:{foreground:t.number}},{name:`magenta`,scope:[`punctuation.definition.heading.markdown`],settings:{foreground:r(`label`,r(`variableGlobal`,t.number))}},{name:`red`,scope:[],settings:{foreground:t.operator}},{name:`orange`,scope:[],settings:{foreground:t.function}}]},ve=e=>{let t=e.colors.surface,n=e.colors.interactive,r=e.colors.status,i=e.colors.syntax.base,a=e.colors.syntax.highlights??{},o=J(a.diffAddedBackground,r.successBackground),s=J(a.diffRemovedBackground,r.errorBackground);return{"editor.background":t.background,"editor.foreground":t.foreground,"editor.hoverHighlightBackground":J(n.hover,t.subtle),"editor.lineHighlightBackground":t.muted,"editor.selectionBackground":n.selection,"editor.selectionHighlightBackground":n.selection,"editor.findMatchBackground":i.type,"editor.findMatchHighlightBackground":_e(i.type,`cc`),"editor.findRangeHighlightBackground":t.muted,"editor.inactiveSelectionBackground":t.elevated,"editor.lineHighlightBorder":t.elevated,"editor.rangeHighlightBackground":J(n.active,n.borderHover),"notifications.background":t.elevated,"editorInlayHint.typeBackground":t.subtle,"editorInlayHint.typeForeground":t.foreground,"editorWhitespace.foreground":n.borderHover,"editorIndentGuide.background1":t.subtle,"editorHoverWidget.background":t.elevated,"editorLineNumber.activeForeground":J(a.lineNumberActive,t.foreground),"editorLineNumber.foreground":J(a.lineNumber,t.mutedForeground),"editorGutter.background":t.background,"editorGutter.modifiedBackground":r.info,"editorGutter.addedBackground":r.success,"editorGutter.deletedBackground":r.error,"editorBracketMatch.background":t.elevated,"editorBracketMatch.border":t.subtle,"editorError.foreground":r.error,"editorWarning.foreground":r.warning,"editorInfo.foreground":r.info,"diffEditor.insertedTextBackground":o,"diffEditor.removedTextBackground":s,"editorGroupHeader.tabsBackground":t.background,"editorGroup.border":n.border,"tab.activeBackground":t.background,"tab.inactiveBackground":t.muted,"tab.inactiveForeground":t.mutedForeground,"tab.activeForeground":t.foreground,"tab.hoverBackground":t.subtle,"tab.unfocusedHoverBackground":t.subtle,"tab.border":n.border,"tab.activeModifiedBorder":i.type,"tab.inactiveModifiedBorder":r.info,"tab.unfocusedActiveModifiedBorder":i.type,"tab.unfocusedInactiveModifiedBorder":r.info,"editorWidget.background":t.muted,"editorWidget.border":n.border,"editorSuggestWidget.background":t.background,"editorSuggestWidget.border":n.border,"editorSuggestWidget.foreground":t.foreground,"editorSuggestWidget.highlightForeground":t.mutedForeground,"editorSuggestWidget.selectedBackground":t.subtle,"peekView.border":n.border,"peekViewEditor.background":t.background,"peekViewEditor.matchHighlightBackground":t.subtle,"peekViewResult.background":t.muted,"peekViewResult.fileForeground":t.foreground,"peekViewResult.lineForeground":t.mutedForeground,"peekViewResult.matchHighlightBackground":t.subtle,"peekViewResult.selectionBackground":t.elevated,"peekViewResult.selectionForeground":t.mutedForeground,"peekViewTitle.background":t.subtle,"peekViewTitleDescription.foreground":t.mutedForeground,"peekViewTitleLabel.foreground":t.foreground,"merge.currentHeaderBackground":r.success,"merge.currentContentBackground":J(a.diffAdded,r.success),"merge.incomingHeaderBackground":r.info,"merge.incomingContentBackground":J(a.diffModified,r.info),"merge.border":n.border,"merge.commonContentBackground":t.subtle,"merge.commonHeaderBackground":t.muted,"panel.background":t.background,"panel.border":n.border,"panelTitle.activeBorder":n.borderHover,"panelTitle.activeForeground":t.foreground,"panelTitle.inactiveForeground":t.mutedForeground,"statusBar.background":t.background,"statusBar.foreground":t.foreground,"statusBar.border":n.border,"statusBar.debuggingBackground":r.error,"statusBar.debuggingForeground":r.errorForeground,"statusBar.noFolderBackground":t.subtle,"statusBar.noFolderForeground":t.mutedForeground,"titleBar.activeBackground":t.background,"titleBar.activeForeground":t.foreground,"titleBar.inactiveBackground":t.muted,"titleBar.inactiveForeground":t.mutedForeground,"titleBar.border":n.border,"menu.foreground":t.foreground,"menu.background":t.background,"menu.selectionForeground":t.foreground,"menu.selectionBackground":t.subtle,"menu.border":n.border,"editorInlayHint.foreground":t.mutedForeground,"editorInlayHint.background":t.subtle,"terminal.foreground":t.foreground,"terminal.background":t.background,"terminalCursor.foreground":t.foreground,"terminalCursor.background":t.background,"terminal.ansiRed":J(a.diffRemoved,r.error),"terminal.ansiGreen":J(a.diffAdded,r.success),"terminal.ansiYellow":r.warning,"terminal.ansiBlue":J(a.diffModified,r.info),"terminal.ansiMagenta":i.keyword,"terminal.ansiCyan":i.type,"activityBar.background":t.background,"activityBar.foreground":t.foreground,"activityBar.inactiveForeground":t.mutedForeground,"activityBar.activeBorder":t.foreground,"activityBar.border":n.border,"sideBar.background":t.background,"sideBar.foreground":t.foreground,"sideBar.border":n.border,"sideBarTitle.foreground":t.foreground,"sideBarSectionHeader.background":t.muted,"sideBarSectionHeader.foreground":t.foreground,"sideBarSectionHeader.border":n.border,"sideBar.activeBackground":t.subtle,"sideBar.activeForeground":t.foreground,"sideBar.hoverBackground":t.muted,"sideBar.hoverForeground":t.foreground,"list.warningForeground":r.warning,"list.errorForeground":r.error,"list.inactiveSelectionBackground":t.subtle,"list.activeSelectionBackground":t.elevated,"list.inactiveSelectionForeground":t.foreground,"list.activeSelectionForeground":t.foreground,"list.hoverForeground":t.foreground,"list.hoverBackground":t.muted,"input.background":t.muted,"input.foreground":t.foreground,"input.border":n.border,"input.placeholderForeground":t.mutedForeground,"inputOption.activeBorder":n.border,"inputOption.activeBackground":t.elevated,"inputOption.activeForeground":t.foreground,"inputValidation.infoBackground":r.infoBackground,"inputValidation.infoBorder":r.infoBorder,"inputValidation.warningBackground":r.warningBackground,"inputValidation.warningBorder":r.warningBorder,"inputValidation.errorBackground":r.errorBackground,"inputValidation.errorBorder":r.errorBorder,"dropdown.background":t.muted,"dropdown.foreground":t.foreground,"dropdown.border":n.border,"dropdown.listBackground":t.background,"badge.background":e.colors.primary.base,"activityBarBadge.background":e.colors.primary.base,"button.background":e.colors.primary.base,"button.foreground":J(e.colors.primary.foreground,t.background),"badge.foreground":J(e.colors.primary.foreground,t.background),"activityBarBadge.foreground":J(e.colors.primary.foreground,t.background)}};function ye(e){return{name:e.metadata.name,type:e.metadata.variant,colors:ve(e),tokenColors:Y(e)}}var be=e=>/^#[0-9a-fA-F]{8}$/.test(e),X=e=>be(e)?e.slice(0,7):e;function xe(e,t){return Object.defineProperty(e,"toString",{value:()=>t,enumerable:!1,configurable:!0}),Object.defineProperty(e,Symbol.toPrimitive,{value:()=>t,enumerable:!1,configurable:!0}),e}var Z=new Map,Q=new Set,Se=(e,t)=>{let n=e.colors?.[`editor.background`],r=e.colors?.[`editor.foreground`],i=n?X(n):void 0,a=r?X(r):void 0;if(!i||!a)throw Error(`Theme "${t}" is missing editor.background/editor.foreground`);let o=e.tokenColors??[];return xe({...e,name:t,fg:a,bg:i,settings:o},t)},Ce=e=>ye(e),$=e=>{let t=Z.get(e.metadata.id);if(t)return t;let n=Se(Ce(e),e.metadata.id);return Z.set(e.metadata.id,n),n},we=e=>{let t=e.metadata.id;if(Q.has(t))return;let n=$(e);p(t,async()=>n),Q.add(t)};export{W as a,ne as c,me as i,se as l,$ as n,U as o,pe as r,D as s,we as t,C as u};
@@ -1 +1 @@
1
- import"./rolldown-runtime-C0FnF6B9.js";import{E as e,F as t,I as n,N as r,P as i,a,i as o,nt as s,rt as c}from"./vendor-base-ui-CnHfUmDN.js";import{n as l}from"./vendor-react-DLPElpoQ.js";import{t as u}from"./utils-DyUyiLje.js";import{M as d,N as f,P as p}from"./radio-DBJG9Dd1.js";var m=l();c();var h=s();function g(e){let t=(0,m.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,h.jsx)(a,{...n}),t[2]=n,t[3]=r),r}function _(e){let t=(0,m.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,h.jsx)(o,{...n}),t[2]=n,t[3]=r),r}function v(e){let n=(0,m.c)(20),a,o,s,c,l;n[0]===e?(a=n[1],o=n[2],s=n[3],c=n[4],l=n[5]):({className:o,positionerClassName:s,children:a,style:l,...c}=e,n[0]=e,n[1]=a,n[2]=o,n[3]=s,n[4]=c,n[5]=l);let d;n[6]===s?d=n[7]:(d=u(`app-region-no-drag z-50`,s),n[6]=s,n[7]=d);let p;n[8]===l?p=n[9]:(p={backgroundColor:`var(--surface-elevated)`,color:`var(--surface-elevated-foreground)`,...l},n[8]=l,n[9]=p);let g;n[10]===o?g=n[11]:(g=u(f,o),n[10]=o,n[11]=g);let _;n[12]!==a||n[13]!==c||n[14]!==p||n[15]!==g?(_=(0,h.jsx)(t,{"data-slot":`dropdown-menu-content`,style:p,className:g,...c,children:a}),n[12]=a,n[13]=c,n[14]=p,n[15]=g,n[16]=_):_=n[16];let v;return n[17]!==d||n[18]!==_?(v=(0,h.jsx)(i,{children:(0,h.jsx)(r,{className:d,children:_})}),n[17]=d,n[18]=_,n[19]=v):v=n[19],v}function y(e){let t=(0,m.c)(8),r,i;t[0]===e?(r=t[1],i=t[2]):({className:r,...i}=e,t[0]=e,t[1]=r,t[2]=i);let a;t[3]===r?a=t[4]:(a=u(d,r),t[3]=r,t[4]=a);let o;return t[5]!==i||t[6]!==a?(o=(0,h.jsx)(n,{className:a,...i}),t[5]=i,t[6]=a,t[7]=o):o=t[7],o}function b(t){let n=(0,m.c)(8),r,i;n[0]===t?(r=n[1],i=n[2]):({className:r,...i}=t,n[0]=t,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=u(p,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==a?(o=(0,h.jsx)(e,{className:a,...i}),n[5]=i,n[6]=a,n[7]=o):o=n[7],o}export{_ as a,b as i,v as n,y as r,g as t};
1
+ import"./rolldown-runtime-C0FnF6B9.js";import{E as e,F as t,I as n,N as r,P as i,a,i as o,nt as s,rt as c}from"./vendor-base-ui-CnHfUmDN.js";import{n as l}from"./vendor-react-DLPElpoQ.js";import{t as u}from"./utils-DyUyiLje.js";import{M as d,N as f,P as p}from"./radio-Bs4mdPv5.js";var m=l();c();var h=s();function g(e){let t=(0,m.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,h.jsx)(a,{...n}),t[2]=n,t[3]=r),r}function _(e){let t=(0,m.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,h.jsx)(o,{...n}),t[2]=n,t[3]=r),r}function v(e){let n=(0,m.c)(20),a,o,s,c,l;n[0]===e?(a=n[1],o=n[2],s=n[3],c=n[4],l=n[5]):({className:o,positionerClassName:s,children:a,style:l,...c}=e,n[0]=e,n[1]=a,n[2]=o,n[3]=s,n[4]=c,n[5]=l);let d;n[6]===s?d=n[7]:(d=u(`app-region-no-drag z-50`,s),n[6]=s,n[7]=d);let p;n[8]===l?p=n[9]:(p={backgroundColor:`var(--surface-elevated)`,color:`var(--surface-elevated-foreground)`,...l},n[8]=l,n[9]=p);let g;n[10]===o?g=n[11]:(g=u(f,o),n[10]=o,n[11]=g);let _;n[12]!==a||n[13]!==c||n[14]!==p||n[15]!==g?(_=(0,h.jsx)(t,{"data-slot":`dropdown-menu-content`,style:p,className:g,...c,children:a}),n[12]=a,n[13]=c,n[14]=p,n[15]=g,n[16]=_):_=n[16];let v;return n[17]!==d||n[18]!==_?(v=(0,h.jsx)(i,{children:(0,h.jsx)(r,{className:d,children:_})}),n[17]=d,n[18]=_,n[19]=v):v=n[19],v}function y(e){let t=(0,m.c)(8),r,i;t[0]===e?(r=t[1],i=t[2]):({className:r,...i}=e,t[0]=e,t[1]=r,t[2]=i);let a;t[3]===r?a=t[4]:(a=u(d,r),t[3]=r,t[4]=a);let o;return t[5]!==i||t[6]!==a?(o=(0,h.jsx)(n,{className:a,...i}),t[5]=i,t[6]=a,t[7]=o):o=t[7],o}function b(t){let n=(0,m.c)(8),r,i;n[0]===t?(r=n[1],i=n[2]):({className:r,...i}=t,n[0]=t,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=u(p,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==a?(o=(0,h.jsx)(e,{className:a,...i}),n[5]=i,n[6]=a,n[7]=o):o=n[7],o}export{_ as a,b as i,v as n,y as r,g as t};
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-C0FnF6B9.js";import{kn as t,xn as n}from"./persistence-C_KCiMcY.js";import{$ as r,A as i,D as a,F as o,G as s,H as c,I as l,J as u,K as d,M as f,P as p,Q as m,S as ee,T as te,W as ne,Y as re,_ as ie,_t as ae,a as oe,at as se,b as ce,c as le,d as ue,dt as de,et as fe,f as pe,ft as me,h as he,ht as ge,k as _e,kt as h,lt as ve,m as ye,mt as be,ot as xe,q as Se,r as Ce,s as we,tt as Te,v as Ee,x as De,y as Oe}from"./gitApiHttp-C1DaEMKR.js";import{Da as ke,Hi as g,Pi as _,l as v,s as Ae}from"./useMobileNavigationStore-DhkIZBJw.js";var je=e({applyGitStash:()=>W,checkIsGitRepository:()=>x,checkoutCommit:()=>Ke,cherryPick:()=>qe,countGitStashFiles:()=>H,createBranch:()=>q,createGitIdentity:()=>X,createGitWorktree:()=>R,deleteGitIdentity:()=>He,deleteGitWorktree:()=>z,deleteRemoteBranch:()=>A,discoverGitCredentials:()=>Q,discoverGitRepositories:()=>S,dropGitStash:()=>K,generateCommitMessage:()=>M,getCommitFileDiff:()=>J,getConflictDetails:()=>$,getGitBranches:()=>k,getGitIdentities:()=>Y,getGitStatus:()=>C,getGitWorktreeBootstrapStatus:()=>I,getGlobalGitIdentity:()=>Ue,git:()=>B,listGitStashes:()=>V,listGitWorktrees:()=>P,merge:()=>Ge,popGitStash:()=>G,previewGitWorktree:()=>L,rebase:()=>We,resetToCommit:()=>Ye,resolveGitPrimaryRoot:()=>w,resolveGitTopLevel:()=>Pe,revertCommit:()=>Je,stageGitFile:()=>T,stageGitFiles:()=>E,stashGitChanges:()=>U,unstageGitFile:()=>D,unstageGitFiles:()=>O,updateGitIdentity:()=>Z,validateGitWorktree:()=>F}),y=()=>n()?.git??null,Me=e=>{typeof window>`u`||window.dispatchEvent(new CustomEvent(`openchamber:chat-force-scroll-bottom`,{detail:{sessionId:e}}))},b=e=>{let t=e.trim(),n=(t.match(/```(?:json)?\s*([\s\S]*?)```/i)?.[1]??t).trim(),r=[n.indexOf(`{`)].filter(e=>e>=0);for(let e of r)for(let t=n.length;t>e;--t)if(n[t-1]===`}`)try{let r=JSON.parse(n.slice(e,t));if(r&&typeof r==`object`&&!Array.isArray(r))return r}catch{}return null},Ne=e=>{let t=e?.data;return(Array.isArray(t?.parts)?t.parts:[]).map(e=>{let t=e;return t.type===`text`?typeof t.text==`string`?t.text:typeof t.content==`string`?t.content:typeof t.value==`string`?t.value:``:``}).filter(e=>e.trim().length>0).join(`
1
+ import{r as e}from"./rolldown-runtime-C0FnF6B9.js";import{kn as t,xn as n}from"./persistence-C_KCiMcY.js";import{$ as r,A as i,D as a,F as o,G as s,H as c,I as l,J as u,K as d,M as f,P as p,Q as m,S as ee,T as te,W as ne,Y as re,_ as ie,_t as ae,a as oe,at as se,b as ce,c as le,d as ue,dt as de,et as fe,f as pe,ft as me,h as he,ht as ge,k as _e,kt as h,lt as ve,m as ye,mt as be,ot as xe,q as Se,r as Ce,s as we,tt as Te,v as Ee,x as De,y as Oe}from"./gitApiHttp-C1DaEMKR.js";import{Da as ke,Hi as g,Pi as _,l as v,s as Ae}from"./useMobileNavigationStore-1xHjnAsg.js";var je=e({applyGitStash:()=>W,checkIsGitRepository:()=>x,checkoutCommit:()=>Ke,cherryPick:()=>qe,countGitStashFiles:()=>H,createBranch:()=>q,createGitIdentity:()=>X,createGitWorktree:()=>R,deleteGitIdentity:()=>He,deleteGitWorktree:()=>z,deleteRemoteBranch:()=>A,discoverGitCredentials:()=>Q,discoverGitRepositories:()=>S,dropGitStash:()=>K,generateCommitMessage:()=>M,getCommitFileDiff:()=>J,getConflictDetails:()=>$,getGitBranches:()=>k,getGitIdentities:()=>Y,getGitStatus:()=>C,getGitWorktreeBootstrapStatus:()=>I,getGlobalGitIdentity:()=>Ue,git:()=>B,listGitStashes:()=>V,listGitWorktrees:()=>P,merge:()=>Ge,popGitStash:()=>G,previewGitWorktree:()=>L,rebase:()=>We,resetToCommit:()=>Ye,resolveGitPrimaryRoot:()=>w,resolveGitTopLevel:()=>Pe,revertCommit:()=>Je,stageGitFile:()=>T,stageGitFiles:()=>E,stashGitChanges:()=>U,unstageGitFile:()=>D,unstageGitFiles:()=>O,updateGitIdentity:()=>Z,validateGitWorktree:()=>F}),y=()=>n()?.git??null,Me=e=>{typeof window>`u`||window.dispatchEvent(new CustomEvent(`openchamber:chat-force-scroll-bottom`,{detail:{sessionId:e}}))},b=e=>{let t=e.trim(),n=(t.match(/```(?:json)?\s*([\s\S]*?)```/i)?.[1]??t).trim(),r=[n.indexOf(`{`)].filter(e=>e>=0);for(let e of r)for(let t=n.length;t>e;--t)if(n[t-1]===`}`)try{let r=JSON.parse(n.slice(e,t));if(r&&typeof r==`object`&&!Array.isArray(r))return r}catch{}return null},Ne=e=>{let t=e?.data;return(Array.isArray(t?.parts)?t.parts:[]).map(e=>{let t=e;return t.type===`text`?typeof t.text==`string`?t.text:typeof t.content==`string`?t.content:typeof t.value==`string`?t.value:``:``}).filter(e=>e.trim().length>0).join(`
2
2
  `).trim()};async function x(e){let t=y();return t?t.checkIsGitRepository(e):oe(e)}async function S(e){return De(e)}async function C(e,t){let n=y();return n?n.getGitStatus(e,t):p(e,t)}async function w(e){return(await r(e)).root}async function Pe(e){return(await fe(e)).root}async function T(e,t){let n=y();return n?.stageGitFile?n.stageGitFile(e,t):se(e,t)}async function E(e,t){let n=y();return n?.stageGitFiles?n.stageGitFiles(e,t):xe(e,t)}async function D(e,t){let n=y();return n?.unstageGitFile?n.unstageGitFile(e,t):de(e,t)}async function O(e,t){let n=y();return n?.unstageGitFiles?n.unstageGitFiles(e,t):me(e,t)}async function k(e,t){let n=y();if(t?.signal?.throwIfAborted(),n){let r=await n.getGitBranches(e,t);return t?.signal?.throwIfAborted(),r}return _e(e,t)}async function A(e,t){let n=y();return n?n.deleteRemoteBranch(e,t):Oe(e,t)}var Fe=30,Ie=12e4,Le=async(e,t)=>{let n=t.slice(0,Fe),r=await Promise.all(n.map(async t=>{try{let[n,r]=await Promise.all([i(e,{path:t,staged:!0}).catch(()=>null),i(e,{path:t,staged:!1}).catch(()=>null)]);return[n?.diff,r?.diff].filter(e=>typeof e==`string`&&e.trim().length>0).join(`
3
3
  `)||`--- ${t} (no textual diff available)`}catch{return`--- ${t} (diff unavailable)`}})),a=``;for(let e of r){if(a.length+e.length>Ie){a+=`
4
4
  [remaining diffs truncated]`;break}a+=(a?`
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{A as t,E as n,b as r,t as i,y as a}from"./useUIStore-D6BTB4va.js";import{$t as o,D as s,d as c,k as l,u,xn as d}from"./persistence-C_KCiMcY.js";import{a as f,i as p,r as m}from"./vendor-zustand-B4dlGEM2.js";import{nt as h,rt as g}from"./vendor-base-ui-CnHfUmDN.js";import{L as _,Ot as v,k as y,yt as b}from"./gitApiHttp-C1DaEMKR.js";import{n as x}from"./vendor-react-DLPElpoQ.js";import{s as S}from"./vendor-tanstack-react-query-D7pys_c9.js";import{n as C}from"./vendor-reactuses-core-DDoDDyM9.js";import{n as ee}from"./clipboard-CXWbHCAk.js";import{Ga as te,Hi as ne,Sr as re,_ as w,b as ie,co as T,ct as E,en as ae,l as D,ot as oe,so as se,st as ce,un as O}from"./useMobileNavigationStore-DhkIZBJw.js";import{c as le,t as k}from"./utils-DyUyiLje.js";import{n as A}from"./Icon-BPJ_quEe.js";import{g as j,v as M}from"./gitApi-BW5AFgD1.js";import{A as ue,M as N,p as P,s as F}from"./projectMeta-1SSTNg8w.js";var I=e(g(),1),L=e=>{if(!e)return``;let t=e.replace(/\\/g,`/`),n=t.startsWith(`//`),r=t.replace(/\/+/g,`/`);n&&!r.startsWith(`//`)&&(r=`/${r}`);let i=r===`/`,a=/^[A-Za-z]:\/$/.test(r);return!i&&!a&&(r=r.replace(/\/+$/,``)),r},R=e=>/^[A-Za-z]:\//.test(e)?e.toLowerCase():e,z=(e,t)=>{let n=L(t),r=L(e);if(!n||!r)return!1;let i=R(n),a=R(r);return a===i||a.startsWith(`${i}/`)},de=e=>{if(!e||typeof e!=`object`)return{};let t=e,n={};for(let[e,r]of Object.entries(t)){let t=L(e);if(!t||!r||typeof r!=`object`)continue;let i=r,a=Array.isArray(i.openPaths)?Array.from(new Set(i.openPaths.filter(e=>typeof e==`string`).map(e=>L(e)).filter(e=>z(e,t)))):[],o=Array.isArray(i.expandedPaths)?Array.from(new Set(i.expandedPaths.filter(e=>typeof e==`string`).map(e=>L(e)).filter(e=>z(e,t)))):[],s=typeof i.selectedPath==`string`?L(i.selectedPath):null,c=s&&z(s,t)?s:a[0]??null,l=typeof i.touchedAt==`number`&&Number.isFinite(i.touchedAt)?i.touchedAt:Date.now(),u=n[t];if(u){let e=Array.from(new Set([...u.openPaths,...a])),r=Array.from(new Set([...u.expandedPaths,...o]));n[t]={openPaths:e,selectedPath:u.selectedPath??c??e[0]??null,expandedPaths:r,touchedAt:Math.max(u.touchedAt,l)};continue}n[t]={openPaths:a,selectedPath:c,expandedPaths:o,touchedAt:l}}return n},B=(e,t)=>{let n=Object.entries(e);if(n.length<=t)return e;n.sort((e,t)=>(t[1]?.touchedAt??0)-(e[1]?.touchedAt??0));let r={};for(let[e,i]of n.slice(0,t))r[e]=i;return r},V=e=>e?{...e,touchedAt:Date.now()}:{openPaths:[],selectedPath:null,expandedPaths:[],touchedAt:Date.now()},fe=f()(m(p((e,t)=>({byRoot:{},addOpenPath:(t,n,r)=>{let i=L((t||``).trim()),a=L((n||``).trim());!i||!a||!r?.allowOutsideRoot&&!z(a,i)||e(e=>{let t=e.byRoot[i],n=V(t),r=n.openPaths.includes(a),o=r?n.openPaths:[...n.openPaths,a],s=n.selectedPath??a;return t&&r&&t.selectedPath===s?e:{byRoot:B({...e.byRoot,[i]:{...n,openPaths:o,selectedPath:s}},20)}})},removeOpenPath:(t,n)=>{let r=L((t||``).trim()),i=L((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=R(i),a=e=>R(e)===n,o=t.selectedPath?a(t.selectedPath):!1;if(!t.openPaths.some(a)&&!o)return e;let s=t.openPaths.filter(e=>!a(e)),c=o?s[0]??null:t.selectedPath;return{byRoot:B({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeOpenPathsByPrefix:(t,n)=>{let r=L((t||``).trim()),i=L((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=R(i),a=n.endsWith(`/`)?n:`${n}/`,o=e=>{let t=R(e);return t===n||t.startsWith(a)},s=t.openPaths.filter(e=>!o(e));if(s.length===t.openPaths.length)return e;let c=t.selectedPath&&o(t.selectedPath)?s[0]??null:t.selectedPath;return{byRoot:B({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeExpandedPathsByPrefix:(t,n)=>{let r=L((t||``).trim()),i=L((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=R(i),a=n.endsWith(`/`)?n:`${n}/`,o=t.expandedPaths.filter(e=>{let t=R(e);return t!==n&&!t.startsWith(a)});return o.length===t.expandedPaths.length?e:{byRoot:B({...e.byRoot,[r]:{...t,expandedPaths:o,touchedAt:Date.now()}},20)}})},setSelectedPath:(t,n,r)=>{let i=L((t||``).trim()),a=n?L(n.trim()):null;!i||a&&!r?.allowOutsideRoot&&!z(a,i)||e(e=>{let t=e.byRoot[i],n=V(t),r=a&&!n.openPaths.includes(a)?[...n.openPaths,a]:n.openPaths;return t&&t.selectedPath===a&&r===t.openPaths?e:{byRoot:B({...e.byRoot,[i]:{...n,openPaths:r,selectedPath:a}},20)}})},ensureSelectedPath:e=>{let n=L((e||``).trim());if(!n)return;let r=t().byRoot[n];if(!r||r.selectedPath)return;let i=r.openPaths[0]??null;i&&t().setSelectedPath(n,i)},toggleExpandedPath:(t,n)=>{let r=L((t||``).trim()),i=L((n||``).trim());!r||!i||!z(i,r)||e(e=>{let t=e.byRoot[r],n=V(t),a=n.expandedPaths.includes(i)?n.expandedPaths.filter(e=>e!==i):[...n.expandedPaths,i];return t&&t.expandedPaths===a&&t.selectedPath===n.selectedPath&&t.openPaths===n.openPaths?e:{byRoot:B({...e.byRoot,[r]:{...n,expandedPaths:a}},20)}})},expandPath:(t,n)=>{let r=L((t||``).trim()),i=L((n||``).trim());!r||!i||!z(i,r)||e(e=>{let t=e.byRoot[r],n=V(t);return n.expandedPaths.includes(i)&&t?e:{byRoot:B({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,i]}},20)}})},expandPaths:(t,n)=>{let r=L((t||``).trim());if(!r||!n||n.length===0)return;let i=n.map(e=>L((e||``).trim())).filter(e=>e&&z(e,r));i.length!==0&&e(e=>{let t=e.byRoot[r],n=V(t),a=new Set(n.expandedPaths),o=i.filter(e=>!a.has(e));return o.length===0?e:{byRoot:B({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,...o]}},20)}})}}),{name:`files-view-tabs-store`,version:2,storage:a(),migrate:e=>{if(!e||typeof e!=`object`)return{byRoot:{}};let t=e.byRoot;return{byRoot:de(t)}},partialize:e=>({byRoot:de(e.byRoot)})}),{name:`files-view-tabs-store`})),H=x(),pe=(e,t)=>{let n=(0,H.c)(4),r=t===void 0?200:t,[i,a]=I.useState(e),o,s;return n[0]!==r||n[1]!==e?(o=()=>{let t=window.setTimeout(()=>{a(e)},r);return()=>{window.clearTimeout(t)}},s=[e,r],n[0]=r,n[1]=e,n[2]=o,n[3]=s):(o=n[2],s=n[3]),I.useEffect(o,s),i},me=()=>{let e=(0,H.c)(17),t=D(U),n=O(),r;e[0]===t?r=e[1]:(r=e=>t?e.getAttachment(t):void 0,e[0]=t,e[1]=r);let i=ie(r),a=D(W),o=D(G),s=T(K),c=T(he),l=b(ge);if(t){let r;e[2]===i?r=e[3]:(r=w(i),e[2]=i,e[3]=r);let o=r;if(o)return o;let s;e[4]!==t||e[5]!==a?(s=a.get(t),e[4]=t,e[5]=a,e[6]=s):s=e[6];let c=s;if(c?.path)return c.path;let l;if(e[7]!==t||e[8]!==n){let r;e[10]===t?r=e[11]:(r=e=>e.id===t,e[10]=t,e[11]=r),l=n.find(r),e[7]=t,e[8]=n,e[9]=l}else l=e[9];let u=l;if(u?.directory)return u.directory}if(o?.open&&(o.bootstrapPendingDirectory||o.directoryOverride))return(o.bootstrapPendingDirectory||o.directoryOverride)??void 0;if(s){let t;if(e[12]!==s||e[13]!==c){let n;e[15]===s?n=e[16]:(n=e=>e.id===s,e[15]=s,e[16]=n),t=c.find(n),e[12]=s,e[13]=c,e[14]=t}else t=e[14];let n=t;if(n?.path)return n.path}return l??void 0};function U(e){return e.currentSessionId}function W(e){return e.worktreeMetadata}function G(e){return e.newSessionDraft}function K(e){return e.activeProjectId}function he(e){return e.projects}function ge(e){return e.currentDirectory}var _e=.4,q=8,J=e=>{let t=e.gap??q,n=Math.max(0,e.popupBottom-e.boundaryTop-t),r=e.viewportHeight*_e,i=Math.floor(Math.min(n,r));return n>=120?Math.min(n,Math.max(120,i)):i},Y=(e,t=0)=>{let n=e.closest(`main`);if(!n)return null;let r=(e.closest(`.mobile-chat-screen__content`)?.parentElement??n.parentElement?.closest(`main`)??n).querySelector(`:scope > .oc-mobile-detail-navigation`)?.getBoundingClientRect().bottom,i=n.getBoundingClientRect().top;return Math.max(r===void 0?i:Math.max(r,i),t)},ve=(e,t)=>{let n=(0,H.c)(3),[r,i]=I.useState(void 0),a;return n[0]!==e||n[1]!==t?(a=()=>{if(!t)return;let n=()=>{let t=e.current;if(!t)return;let n=window.visualViewport,r=Y(t,n?.offsetTop??0);if(r===null)return;let a=n?.height??window.innerHeight,o=J({popupBottom:t.getBoundingClientRect().bottom,boundaryTop:r,viewportHeight:a});i(e=>e===o?e:o)};return n(),window.addEventListener(`resize`,n),window.addEventListener(`oc:keyboard-settled`,n),window.visualViewport?.addEventListener(`resize`,n),window.visualViewport?.addEventListener(`scroll`,n),()=>{window.removeEventListener(`resize`,n),window.removeEventListener(`oc:keyboard-settled`,n),window.visualViewport?.removeEventListener(`resize`,n),window.visualViewport?.removeEventListener(`scroll`,n)}},n[0]=e,n[1]=t,n[2]=a):a=n[2],I.useLayoutEffect(a),t?r:void 0},ye=()=>{let e=null,t=!1,n=!1;return{pointerDown:(n,r)=>{e={x:n,y:r},t=!1},pointerMove:(n,r)=>{e&&Math.hypot(n-e.x,r-e.y)>6&&(t=!0)},pointerCancel:()=>{e=null,t=!1},pointerUp:r=>{if(!e)return!1;let i=!t;return e=null,t=!1,i?(n=!0,r(),!0):(n=!0,!1)},click:e=>n?(n=!1,!1):(e(),!0)}},X=h(),Z=I.forwardRef(({searchQuery:e,onFileSelect:t,onAgentSelect:n,onSessionSelect:r,onClose:a,style:o},c)=>{let{t:u}=ee(),d=me()??``,f=D(e=>e.currentSessionId),p=re(e=>e.activeSessions),m=T(e=>e.activeProjectId),h=T(e=>e.projects),g=I.useMemo(()=>h.find(e=>e.id===m)?.path??null,[m,h]),_=I.useMemo(()=>{let e=g||d;return e?e.replace(/\\/g,`/`).replace(/\/+$/,``):null},[g,d]),y=fe(e=>_?e.byRoot[_]:void 0),b=ne(e=>e.getVisibleAgents),x=v(e=>e.searchFiles),S=pe(e,180),te=l(),w=s(),[ie,E]=I.useState([]),[ae,se]=I.useState([]),[O,j]=I.useState(!1),[M,N]=I.useState(0),P=I.useRef(0),[F,L]=I.useState(360),[R,z]=I.useState({}),[de,B]=I.useState({}),V=I.useRef([]),H=I.useRef([]),U=I.useRef([]),W=I.useRef(null),G=I.useRef(null);G.current||=ye();let K=i(e=>e.isMobile),he=ve(W,K),ge=(e??``).trim(),_e=I.useMemo(()=>{if(!_||!y)return[];let e=[y.selectedPath,...y.openPaths.slice().reverse()].filter(e=>typeof e==`string`&&e.length>0),t=new Set,n=ge.toLowerCase();return e.filter(e=>{if(t.has(e))return!1;t.add(e);let r=e.startsWith(`${_}/`)?e.slice(_.length+1):e;return!n||r.toLowerCase().includes(n)}).slice(0,6).map(e=>{let t=e.replace(/\\/g,`/`),n=t.split(`/`).filter(Boolean).pop()||t;return{name:n,path:t,relativePath:t.startsWith(`${_}/`)?t.slice(_.length+1):t,extension:n.includes(`.`)?n.split(`.`).pop()?.toLowerCase():void 0}})},[ge,_,y]),q=I.useMemo(()=>ge.length>0?ae:ae.slice(0,2),[ae,ge.length]),J=I.useMemo(()=>r?oe({sessions:p,currentSessionId:f,searchQuery:ge}):[],[p,f,ge,r]),Y=_e,Z=ie;I.useEffect(()=>{let e=e=>{let t=e.target;!t||!W.current||W.current.contains(t)||a()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[a]),I.useEffect(()=>{if(!d){E([]);return}let e=(S??``).trim().replace(/^\.\//,``).replace(/^\/+/,``).toLowerCase();if(!e){E([]);return}let t=!1;j(!0);let n={includeHidden:te,respectGitignore:!w};return Promise.all([x(d,e,80,{...n,type:`file`}),x(d,e,40,{...n,type:`directory`})]).then(([n,r])=>{if(t)return;let i=new Set(_e.map(e=>e.path));E(ce({files:n,directories:r,query:e,excludePaths:i,limit:20}))}).catch(()=>{t||E([])}).finally(()=>{t||j(!1)}),()=>{t=!0}},[d,S,_e,x,te,w]),I.useEffect(()=>{let t=b(),n=(e??``).trim().toLowerCase(),r=t.filter(e=>e.mode&&e.mode!==`primary`).filter(e=>!n||`${e.name} ${e.description??``}`.toLowerCase().includes(n)).map(e=>({name:e.name,description:e.description,mode:e.mode})).sort((e,t)=>e.name.localeCompare(t.name));se(r)},[b,e]),I.useEffect(()=>{N(0),z({}),B({})},[Z,Y.length,q.length,J.length]),I.useEffect(()=>{P.current=M},[M]),I.useEffect(()=>{V.current[M]?.scrollIntoView({block:`nearest`})},[M]),I.useEffect(()=>{let e=null,t=()=>{e!==null&&cancelAnimationFrame(e),e=requestAnimationFrame(()=>{let e={},t={};H.current.forEach((n,r)=>{if(!n)return;let i=U.current[r]?.offsetWidth??n.scrollWidth,a=Math.max(0,i-n.clientWidth),o=a>8;if(e[r]=o,o){let e=Math.max(.6,a/110);t[r]=e}}),z(e),B(t)})};return t(),window.addEventListener(`resize`,t),()=>{e!==null&&cancelAnimationFrame(e),window.removeEventListener(`resize`,t)}},[Z,Y]),I.useEffect(()=>{let e=H.current[M];if(!e)return;let t=()=>{let t=e.clientWidth;t>0&&L(t)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>{n.disconnect()}},[M]);let be=C(e=>{t(e)}),xe=C(e=>{n?.(e)}),Se=C(e=>{r?.(e)}),Ce=(e,t)=>({onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&G.current?.pointerDown(e.clientX,e.clientY)},onPointerMove:e=>{e.pointerType===`touch`&&G.current?.pointerMove(e.clientX,e.clientY)},onPointerUp:e=>{e.pointerType===`touch`&&(G.current?.pointerUp(t)??!1)&&(e.preventDefault(),e.stopPropagation())},onPointerCancel:()=>G.current?.pointerCancel(),onClick:()=>{G.current?.click(t)},onMouseMove:()=>N(e)});I.useImperativeHandle(c,()=>({handleKeyDown:e=>{if(e===`Escape`){a();return}let t=q.length+J.length+Y.length+Z.length;if(t!==0){if(e===`ArrowDown`){N(e=>(e+1)%t);return}if(e===`ArrowUp`){N(e=>(e-1+t)%t);return}if(e===`Enter`||e===`Tab`){let e=(P.current%t+t)%t;if(e<q.length){let t=q[e];t&&xe(t.name);return}let n=e-q.length;if(n<J.length){let e=J[n];e&&Se(e);return}let r=n-J.length,i=r<Y.length?Y[r]:Z[r-Y.length];i&&be(i)}}}}),[Z,Y,q,J,a,be,xe,Se]);let we=e=>{if(e.isDirectory)return(0,X.jsx)(A,{name:`folder-3-fill`,className:`h-3.5 w-3.5 text-current`});switch(e.extension?.toLowerCase()){case`ts`:case`tsx`:case`js`:case`jsx`:return(0,X.jsx)(A,{name:`code`,className:`h-3.5 w-3.5 text-current`});case`json`:return(0,X.jsx)(A,{name:`code`,className:`h-3.5 w-3.5 text-current`});case`md`:case`mdx`:return(0,X.jsx)(A,{name:`file`,className:`h-3.5 w-3.5 text-current`});case`png`:case`jpg`:case`jpeg`:case`gif`:case`svg`:return(0,X.jsx)(A,{name:`file-image`,className:`h-3.5 w-3.5 text-current`});default:return(0,X.jsx)(A,{name:`file-pdf`,className:`h-3.5 w-3.5 text-current`})}};return(0,X.jsxs)(`div`,{ref:W,className:`absolute z-[100] min-w-0 w-full max-w-[640px] max-h-64 bg-background border-2 border-border/60 rounded-xl shadow-none bottom-full mb-2 left-0 flex flex-col`,style:he===void 0?o:{...o,maxHeight:he},children:[(0,X.jsx)(ue,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0`,children:(0,X.jsxs)(`div`,{className:`pb-2`,children:[q.length>0&&(0,X.jsx)(`div`,{className:`px-3 pb-1 pt-2 typography-meta font-medium text-muted-foreground`,children:u(`chat.fileMentionAutocomplete.groups.agents`)}),q.map((e,t)=>(0,X.jsx)(`div`,{ref:e=>{V.current[t]=e},className:k(`flex items-start gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,K&&`min-h-11`,M===t&&`bg-interactive-selection text-interactive-selection-foreground`),...Ce(t,()=>xe(e.name)),children:(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`div`,{className:`font-semibold truncate`,children:[`@`,e.name]}),e.description&&!K?(0,X.jsx)(`div`,{className:`typography-meta text-muted-foreground truncate`,children:e.description}):null]})},`agent-${e.name}`)),q.length===2&&ge.length===0&&ae.length>2&&(0,X.jsx)(`div`,{className:`px-3 py-1 typography-meta text-muted-foreground`,children:u(`chat.fileMentionAutocomplete.searchMoreAgents`)}),J.length>0&&(0,X.jsx)(`div`,{className:`px-3 pb-1 pt-2 typography-meta font-medium text-muted-foreground`,children:u(`chat.fileMentionAutocomplete.groups.sessions`)}),J.map((e,t)=>{let n=q.length+t;return(0,X.jsxs)(`div`,{ref:e=>{V.current[n]=e},className:k(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,K&&`min-h-11`,M===n&&`bg-interactive-selection text-interactive-selection-foreground`),...Ce(n,()=>Se(e)),children:[(0,X.jsx)(A,{name:`chat-thread`,className:`h-4 w-4 flex-shrink-0 text-[var(--primary-base)]`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.title||u(`chat.fileMentionAutocomplete.untitledSession`),children:e.title||u(`chat.fileMentionAutocomplete.untitledSession`)}),K?null:(0,X.jsx)(`span`,{className:`flex-shrink-0 typography-meta text-muted-foreground`,children:u(`chat.fileMentionAutocomplete.sessionType`)})]},`session-${e.id}`)}),Y.length>0&&(0,X.jsx)(`div`,{className:`px-3 pb-1 pt-2 typography-meta font-medium text-muted-foreground`,children:u(`chat.fileMentionAutocomplete.groups.recentFiles`)}),Y.map((e,t)=>{let n=q.length+J.length+t,r=e.relativePath||e.name,i=le(r,{maxLength:60}),a=M===n,o=R[n]??!1,s=de[n]??2.6;return(0,X.jsxs)(`div`,{ref:e=>{V.current[n]=e},className:k(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,K&&`min-h-11`,a&&`bg-interactive-selection text-interactive-selection-foreground`),...Ce(n,()=>be(e)),children:[we(e),(0,X.jsxs)(`span`,{ref:e=>{H.current[n]=e},className:`relative flex-1 min-w-0 overflow-hidden file-mention-marquee-container`,style:a?{"--file-mention-marquee-width":`${F}px`,"--file-mention-marquee-duration":`${s}s`}:void 0,"aria-label":r,children:[(0,X.jsx)(`span`,{ref:e=>{U.current[n]=e},className:`absolute invisible whitespace-nowrap pointer-events-none`,"aria-hidden":!0,children:r}),o&&a?(0,X.jsx)(`span`,{className:`inline-block whitespace-nowrap file-mention-marquee`,children:r}):(0,X.jsx)(`span`,{className:`block truncate`,children:i})]})]},`recent-${e.path}`)}),Z.length>0&&(0,X.jsx)(`div`,{className:`px-3 pb-1 pt-2 typography-meta font-medium text-muted-foreground`,children:u(`chat.fileMentionAutocomplete.groups.files`)}),Z.map((e,t)=>{let n=q.length+J.length+Y.length+t,r=e.relativePath||e.name,i=le(r,{maxLength:60}),a=M===n,o=R[n]??!1,s=de[n]??2.6;return(0,X.jsxs)(`div`,{ref:e=>{V.current[n]=e},className:k(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,K&&`min-h-11`,a&&`bg-interactive-selection text-interactive-selection-foreground`),...Ce(n,()=>be(e)),children:[we(e),(0,X.jsxs)(`span`,{ref:e=>{H.current[n]=e},className:`relative flex-1 min-w-0 overflow-hidden file-mention-marquee-container`,style:a?{"--file-mention-marquee-width":`${F}px`,"--file-mention-marquee-duration":`${s}s`}:void 0,"aria-label":r,children:[(0,X.jsx)(`span`,{ref:e=>{U.current[n]=e},className:`absolute invisible whitespace-nowrap pointer-events-none`,"aria-hidden":!0,children:r}),o&&a?(0,X.jsx)(`span`,{className:`inline-block whitespace-nowrap file-mention-marquee`,children:r}):(0,X.jsx)(`span`,{className:`block truncate`,children:i})]})]},e.path)}),O&&Z.length===0?(0,X.jsx)(`div`,{className:`flex items-center justify-center py-3`,children:(0,X.jsx)(A,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):null,!O&&Z.length===0&&Y.length===0&&q.length===0&&J.length===0&&(0,X.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:u(`chat.fileMentionAutocomplete.empty`)})]})}),!K&&(0,X.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:u(`chat.autocomplete.keyboardHint`)})]})}),be=new Set([`new`,`fork`,`compact`,`undo`,`redo`,`model`,`goal`]),xe=(e,t)=>{if(!t||e.isSkill)return!1;let n=e.name?.trim().toLowerCase();return!!(n&&be.has(n))},Se=(e,t)=>!e||t({name:e}),Ce=` `,we=(e,t)=>{let n=Math.max(0,Math.min(t,e.length)),r=n;for(;r>0&&!/\s/.test(e[r-1]);)--r;return r>=2&&e[r-1]===Ce&&e[r-2]===`/`&&(r-=2),e[r]===`/`?{start:r,end:n}:null},Te=`text-[10px] leading-none uppercase font-bold tracking-tight px-1.5 py-1 rounded border flex-shrink-0`,Ee=k(Te,`bg-[color-mix(in_srgb,var(--primary-base)_12%,transparent)] text-[color-mix(in_srgb,var(--primary-base)_70%,transparent)] border-[color-mix(in_srgb,var(--primary-base)_24%,transparent)]`),De=k(Te,`bg-[color-mix(in_srgb,var(--status-success)_12%,transparent)] text-[color-mix(in_srgb,var(--status-success)_70%,transparent)] border-[color-mix(in_srgb,var(--status-success)_24%,transparent)]`),Oe=k(Te,`bg-[color-mix(in_srgb,var(--status-info)_12%,transparent)] text-[color-mix(in_srgb,var(--status-info)_70%,transparent)] border-[color-mix(in_srgb,var(--status-info)_24%,transparent)]`),ke=k(Te,`bg-[var(--surface-muted)] text-muted-foreground border-[var(--interactive-border)]/60`),Ae=(e,t)=>{let n=t.trim();if(!n)return[...e].sort((e,t)=>e.isBuiltIn===t.isBuiltIn?e.name.localeCompare(t.name):e.isBuiltIn?-1:1);let r=E(e,n,e=>[e.name,e.description??``]);return r.sort((e,t)=>e.score===t.score?e.item.isBuiltIn===t.item.isBuiltIn?e.item.name.localeCompare(t.item.name):e.item.isBuiltIn?-1:1:e.score-t.score),r.map(e=>e.item)},je=(e,t)=>{let n=!!e.sessionID;return{hasSession:n,canStartSessionCommand:n||e.hasNewDraft,canUseReviewHandoffFlow:n&&!t&&!o()}},Me=I.forwardRef(({searchQuery:e,onCommandSelect:t,onClose:n,directory:r,style:a,commandPolicy:o,commandContext:s},c)=>{let{t:l}=ee(),u=i(e=>e.isMobile),d=D(e=>e.currentSessionId),f=D(e=>!!e.newSessionDraft?.open),p=D(I.useCallback(e=>d?e.getDirectoryForSession(d):void 0,[d])),m=ae(d??``,p??void 0),h=I.useMemo(()=>s??{sessionID:d??null,hasMessages:m.length>0,hasNewDraft:f},[s,d,m.length,f]),{hasSession:g,canStartSessionCommand:_,canUseReviewHandoffFlow:v}=I.useMemo(()=>je(h,u),[h,u]),y=h.hasMessages,[b,x]=I.useState([]),[S,C]=I.useState(!1),ne=se({directory:r}),re=I.useMemo(()=>ne.data??[],[ne.data]),w=ne.isFetching,ie=te({directory:r}),T=I.useMemo(()=>ie.data??[],[ie.data]),[E,oe]=I.useState(0),ce=I.useRef(0),O=I.useRef(!1),le=I.useRef([]),j=I.useRef(null),M=ve(j,u),N=I.useRef(!1),P=I.useRef(null),F=I.useRef(!1);I.useEffect(()=>{let e=e=>{let t=e.target;!t||!j.current||j.current.contains(t)||n()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[n]),I.useEffect(()=>{(async()=>{C(w);try{let t=re.map((e,t)=>({id:`opencode:${e.scope??`global`}:${e.name}:${e.agent??``}:${e.model??``}:${t}`,name:e.name,source:`opencode`,description:e.description,agent:e.agent??void 0,model:e.model??void 0,isBuiltIn:e.isBuiltIn,isSkill:e.source===`skill`,scope:e.scope,reference:e.reference})),n=T.map((e,t)=>({id:`skill:${e.scope}:${e.source??`opencode`}:${e.name}:${t}`,name:e.name,source:`skill`,description:e.description,isSkill:!0,scope:e.scope})),r=[{id:`openchamber:new`,name:`new`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.newDescription`),isBuiltIn:!0},...g&&!y?[{id:`openchamber:init`,name:`init`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.initDescription`),isBuiltIn:!0}]:[],...g?[{id:`openchamber:undo`,name:`undo`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.undoDescription`),isBuiltIn:!0},{id:`openchamber:redo`,name:`redo`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.redoDescription`),isBuiltIn:!0},{id:`openchamber:fork`,name:`fork`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.forkDescription`),isBuiltIn:!0},{id:`openchamber:timeline`,name:`timeline`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.timelineDescription`),isBuiltIn:!0}]:[],{id:`openchamber:model`,name:`model`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.modelDescription`),isBuiltIn:!0},{id:`openchamber:compact`,name:`compact`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.compactDescription`),isBuiltIn:!0},...g?[{id:`openchamber:summary`,name:`summary`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.summaryDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:workspace-review`,name:`workspace-review`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.workspaceReviewDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:handoff-review`,name:`handoff-review`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.handoffReviewDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:plan-feature`,name:`plan-feature`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.featurePlanDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:craft-goal`,name:`craft-goal`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.craftGoalDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:goal`,name:`goal`,source:`openchamber`,description:l(`chat.goal.button.armAria`),isBuiltIn:!0}]:[],..._?[{id:`openchamber:catch-up`,name:`catch-up`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.catchUpDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:debug`,name:`debug`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.debugDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:weigh`,name:`weigh`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.weighDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:explore`,name:`explore`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.exploreDescription`),isOpenChamber:!0}]:[],...t,...n],i=!y,a=r.filter(e=>(i||e.name!==`init`)&&(o?.(e)??!0));x(Ae(a,e))}catch{let t=!y,n=[{id:`openchamber:new`,name:`new`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.newDescription`),isBuiltIn:!0},...g&&!y?[{id:`openchamber:init`,name:`init`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.initDescription`),isBuiltIn:!0}]:[],...g?[{id:`openchamber:undo`,name:`undo`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.undoDescription`),isBuiltIn:!0},{id:`openchamber:redo`,name:`redo`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.redoDescription`),isBuiltIn:!0},{id:`openchamber:fork`,name:`fork`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.forkDescription`),isBuiltIn:!0},{id:`openchamber:timeline`,name:`timeline`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.timelineDescription`),isBuiltIn:!0}]:[],{id:`openchamber:model`,name:`model`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.modelDescription`),isBuiltIn:!0},{id:`openchamber:compact`,name:`compact`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.compactDescription`),isBuiltIn:!0},...g?[{id:`openchamber:summary`,name:`summary`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.summaryDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:workspace-review`,name:`workspace-review`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.workspaceReviewDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:handoff-review`,name:`handoff-review`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.handoffReviewDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:plan-feature`,name:`plan-feature`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.featurePlanDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:craft-goal`,name:`craft-goal`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.craftGoalDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:goal`,name:`goal`,source:`openchamber`,description:l(`chat.goal.button.armAria`),isBuiltIn:!0}]:[],..._?[{id:`openchamber:catch-up`,name:`catch-up`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.catchUpDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:debug`,name:`debug`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.debugDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:weigh`,name:`weigh`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.weighDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:explore`,name:`explore`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.exploreDescription`),isOpenChamber:!0}]:[]].filter(e=>(t||e.name!==`init`)&&(o?.(e)??!0));x(Ae(n,e))}finally{C(!1)}})()},[e,y,g,_,v,re,w,T,l,o]),I.useEffect(()=>{oe(0)},[b]),I.useEffect(()=>{ce.current=E},[E]),I.useEffect(()=>{le.current[E]?.scrollIntoView({block:`nearest`})},[E]),I.useImperativeHandle(c,()=>({handleKeyDown:e=>{let r=b.length;if(e===`Escape`){n();return}if(r!==0){if(e===`ArrowDown`){O.current=!0,oe(e=>(e+1)%r);return}if(e===`ArrowUp`){O.current=!0,oe(e=>(e-1+r)%r);return}if(e===`Enter`||e===`Tab`){let n=(ce.current%r+r)%r,i=b[n];i&&t(i,xe(i,e===`Enter`))}}}}),[b,n,t]);let L=e=>{switch(e.name){case`new`:return(0,X.jsx)(A,{name:`add`,className:`h-3.5 w-3.5`});case`init`:return(0,X.jsx)(A,{name:`file`,className:`h-3.5 w-3.5 text-green-500`});case`undo`:return(0,X.jsx)(A,{name:`arrow-go-back`,className:`h-3.5 w-3.5 text-orange-500`});case`redo`:return(0,X.jsx)(A,{name:`arrow-go-forward`,className:`h-3.5 w-3.5 text-orange-500`});case`timeline`:return(0,X.jsx)(A,{name:`time`,className:`h-3.5 w-3.5`});case`compact`:return(0,X.jsx)(A,{name:`scissors`,className:`h-3.5 w-3.5 text-purple-500`});case`goal`:return(0,X.jsx)(A,{name:`target`,className:`h-3.5 w-3.5`});case`review`:return(0,X.jsx)(A,{name:`search-eye`,className:`h-3.5 w-3.5 text-blue-500`});case`test`:case`build`:case`run`:return(0,X.jsx)(A,{name:`terminal-box`,className:`h-3.5 w-3.5 text-cyan-500`});default:return e.isBuiltIn?(0,X.jsx)(A,{name:`flashlight`,className:`h-3.5 w-3.5 text-yellow-500`}):(0,X.jsx)(A,{name:`command`,className:`h-3.5 w-3.5 text-muted-foreground`})}};return(0,X.jsxs)(`div`,{ref:j,className:`absolute z-[100] min-w-0 w-full max-w-[450px] max-h-64 bg-background border-2 border-border/60 rounded-xl shadow-none bottom-full mb-2 left-0 flex flex-col`,style:M===void 0?a:{...a,maxHeight:M},children:[(0,X.jsx)(ue,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0 pb-2`,children:S?(0,X.jsx)(`div`,{className:`flex items-center justify-center py-4`,children:(0,X.jsx)(A,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):(0,X.jsxs)(`div`,{children:[b.map((e,n)=>{let r=e.isBuiltIn,i=e.isOpenChamber;return(0,X.jsxs)(`div`,{ref:e=>{le.current[n]=e},className:k(`flex gap-2 px-3 py-2 cursor-pointer rounded-lg`,u?`items-center`:`items-start`,n===E&&`bg-interactive-selection`),onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&(P.current={x:e.clientX,y:e.clientY},F.current=!1)},onPointerMove:e=>{if(e.pointerType!==`touch`||!P.current)return;let t=e.clientX-P.current.x,n=e.clientY-P.current.y;Math.hypot(t,n)>6&&(F.current=!0)},onPointerUp:n=>{if(n.pointerType!==`touch`)return;let r=F.current;P.current=null,F.current=!1,!r&&(n.preventDefault(),n.stopPropagation(),N.current=!0,t(e,xe(e,u)))},onPointerCancel:()=>{P.current=null,F.current=!1},onClick:()=>{if(N.current){N.current=!1;return}t(e,xe(e,u))},onMouseMove:()=>{O.current=!1,oe(n)},children:[(0,X.jsx)(`div`,{className:k(!u&&`mt-0.5`),children:L(e)}),(0,X.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsxs)(`span`,{className:`typography-ui-label font-medium`,children:[`/`,e.name]}),e.isSkill?(0,X.jsx)(`span`,{className:Ee,children:l(`chat.commandAutocomplete.badge.skill`)}):(0,X.jsx)(`span`,{className:Ee,children:l(`chat.commandAutocomplete.badge.command`)}),i?(0,X.jsx)(`span`,{className:ke,children:`OpenChamber`}):r?(0,X.jsx)(`span`,{className:ke,children:l(`chat.commandAutocomplete.badge.system`)}):e.scope?(0,X.jsx)(`span`,{className:e.scope===`project`?Oe:De,children:e.scope}):null,e.agent&&(0,X.jsx)(`span`,{className:ke,children:e.agent})]}),e.description&&!u&&(0,X.jsx)(`div`,{className:`typography-meta text-muted-foreground mt-0.5 truncate`,children:e.description})]})]},e.id)}),b.length===0&&(0,X.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:l(`chat.commandAutocomplete.empty`)})]})}),!u&&(0,X.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:l(`chat.autocomplete.keyboardHint`)})]})});Me.displayName=`CommandAutocomplete`;function Ne(e){return(e.description||e.content).replace(/\s+/g,` `).trim().slice(0,120)}var Pe=I.forwardRef((e,t)=>{let n=(0,H.c)(63),{searchQuery:r,onSnippetSelect:a,onClose:o,style:s}=e,{t:c}=ee(),l=I.useRef(null),u=i(Fe),d=ve(l,u),[f,p]=I.useState(0),m=I.useRef(0),h;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(h=[],n[0]=h):h=n[0];let[g,_]=I.useState(h),v;n[1]===Symbol.for(`react.memo_cache_sentinel`)?(v=[],n[1]=v):v=n[1];let y=I.useRef(v),b=N(Ie),x=N(Le),S=N(Re),C=N(ze),te=i(Be),ne=i(Ve),re,w;n[2]===x?(re=n[3],w=n[4]):(re=()=>{x()},w=[x],n[2]=x,n[3]=re,n[4]=w),I.useEffect(re,w);let ie,T;n[5]!==r||n[6]!==b?(ie=()=>{let e=r.trim();if(!e.length){let e=[...b].sort(He);_(e),p(+!!e.length);return}let t=E(b,e,Ue);t.sort(We);let n=t.map(Ge);_(n),p(+!!n.length)},T=[r,b],n[5]=r,n[6]=b,n[7]=ie,n[8]=T):(ie=n[7],T=n[8]),I.useEffect(ie,T);let ae,D;n[9]===f?(ae=n[10],D=n[11]):(ae=()=>{m.current=f,y.current[f]?.scrollIntoView({block:`nearest`})},D=[f],n[9]=f,n[10]=ae,n[11]=D),I.useEffect(ae,D);let oe,se;n[12]===o?(oe=n[13],se=n[14]):(se=()=>{let e=e=>{let t=e.target;t&&l.current&&!l.current.contains(t)&&o()};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},oe=[o],n[12]=o,n[13]=oe,n[14]=se),I.useEffect(se,oe);let ce;n[15]!==a||n[16]!==r?(ce=e=>{let t=r.trim(),n=e.aliases.includes(t)?t:e.name;a(e,n)},n[15]=a,n[16]=r,n[17]=ce):ce=n[17];let O=ce,le;n[18]!==o||n[19]!==C||n[20]!==te||n[21]!==ne||n[22]!==S||n[23]!==b?(le=()=>{let e=new Set(b.map(Ke)),t=`new-snippet`,n=1;for(;e.has(t);)t=`new-snippet-${n++}`;S({name:t,scope:`global`}),C(t),ne(`snippets`),te(!0),o()},n[18]=o,n[19]=C,n[20]=te,n[21]=ne,n[22]=S,n[23]=b,n[24]=le):le=n[24];let j=le,M,P;n[25]!==O||n[26]!==g||n[27]!==o||n[28]!==j?(M=()=>({handleKeyDown:e=>{if(e===`Escape`){o();return}let t=g.length+1;if(e===`ArrowDown`){p(e=>(e+1)%t);return}if(e===`ArrowUp`){p(e=>(e-1+t)%t);return}if(e===`Enter`||e===`Tab`){if(m.current===0){j();return}let e=g[m.current-1];e&&O(e)}}}),P=[O,g,o,j],n[25]=O,n[26]=g,n[27]=o,n[28]=j,n[29]=M,n[30]=P):(M=n[29],P=n[30]),I.useImperativeHandle(t,M,P);let F;n[31]!==d||n[32]!==s?(F=d===void 0?s:{...s,maxHeight:d},n[31]=d,n[32]=s,n[33]=F):F=n[33];let L;n[34]===Symbol.for(`react.memo_cache_sentinel`)?(L=e=>{y.current[0]=e},n[34]=L):L=n[34];let R=f===0&&`bg-interactive-selection`,z;n[35]===R?z=n[36]:(z=k(`flex items-center gap-2 px-3 py-1.5 cursor-pointer rounded-lg typography-ui-label`,R),n[35]=R,n[36]=z);let de,B;n[37]===Symbol.for(`react.memo_cache_sentinel`)?(de=()=>p(0),B=(0,X.jsx)(A,{name:`add`,className:`h-3.5 w-3.5 text-muted-foreground`}),n[37]=de,n[38]=B):(de=n[37],B=n[38]);let V;n[39]===c?V=n[40]:(V=c(`chat.snippetAutocomplete.action.addNew`),n[39]=c,n[40]=V);let fe;n[41]===V?fe=n[42]:(fe=(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:V}),n[41]=V,n[42]=fe);let pe;n[43]!==j||n[44]!==z||n[45]!==fe?(pe=(0,X.jsxs)(`div`,{ref:L,className:z,onClick:j,onMouseMove:de,children:[B,fe]}),n[43]=j,n[44]=z,n[45]=fe,n[46]=pe):pe=n[46];let me;n[47]!==O||n[48]!==g||n[49]!==u||n[50]!==f||n[51]!==c?(me=g.length?g.map((e,t)=>(0,X.jsx)(`div`,{ref:e=>{y.current[t+1]=e},className:k(`flex gap-2 px-3 py-1.5 cursor-pointer rounded-lg typography-ui-label`,u?`items-center`:`items-start`,t+1===f&&`bg-interactive-selection`),onClick:()=>O(e),onMouseMove:()=>p(t+1),children:(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsxs)(`span`,{className:`font-semibold truncate`,children:[`#`,e.name]}),(0,X.jsx)(`span`,{className:`text-[10px] leading-none uppercase font-bold tracking-tight px-1.5 py-1 rounded border flex-shrink-0 bg-[var(--surface-muted)] text-muted-foreground border-[var(--interactive-border)]/60`,children:c(`snippets.source.${e.source}`)})]}),!u&&(0,X.jsx)(`div`,{className:`typography-meta text-muted-foreground mt-0.5 truncate`,children:Ne(e)})]})},`${e.source}:${e.filePath}`)):(0,X.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:c(`chat.snippetAutocomplete.empty`)}),n[47]=O,n[48]=g,n[49]=u,n[50]=f,n[51]=c,n[52]=me):me=n[52];let U;n[53]!==pe||n[54]!==me?(U=(0,X.jsxs)(ue,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0 pb-2`,children:[pe,me]}),n[53]=pe,n[54]=me,n[55]=U):U=n[55];let W;n[56]!==u||n[57]!==c?(W=!u&&(0,X.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:c(`chat.snippetAutocomplete.footer`)}),n[56]=u,n[57]=c,n[58]=W):W=n[58];let G;return n[59]!==F||n[60]!==U||n[61]!==W?(G=(0,X.jsxs)(`div`,{ref:l,className:`absolute z-[100] min-w-0 w-full max-w-[450px] max-h-60 bg-background border-2 border-border/60 rounded-xl shadow-none bottom-full mb-2 left-0 flex flex-col`,style:F,children:[U,W]}),n[59]=F,n[60]=U,n[61]=W,n[62]=G):G=n[62],G});Pe.displayName=`SnippetAutocomplete`;function Fe(e){return e.isMobile}function Ie(e){return e.snippets}function Le(e){return e.loadSnippets}function Re(e){return e.setSnippetDraft}function ze(e){return e.setSelectedSnippet}function Be(e){return e.setSettingsDialogOpen}function Ve(e){return e.setSettingsPage}function He(e,t){return e.source===`project`&&t.source!==`project`?-1:e.source!==`project`&&t.source===`project`?1:e.name.localeCompare(t.name)}function Ue(e){return[e.name,...e.aliases]}function We(e,t){return e.score===t.score?e.item.source===`project`&&t.item.source!==`project`?-1:e.item.source!==`project`&&t.item.source===`project`?1:e.item.name.localeCompare(t.item.name):e.score-t.score}function Ge(e){return e.item}function Ke(e){return e.name}var qe=2,Je=e=>!!e&&typeof e==`object`&&!Array.isArray(e),Ye=e=>{let t=e?.trim().replace(/\\/g,`/`);return t?t.length>1?t.replace(/\/+$/,``):t:null},Xe=e=>Je(e)&&Array.isArray(e.all)&&e.all.every(e=>typeof e==`string`)&&typeof e.current==`string`&&Je(e.branches),Ze=(e,t)=>JSON.stringify([e,t]),Qe=e=>`version`in e&&e.version===qe&&Je(e.entries),$e=e=>{if(!e)return null;try{let t=JSON.parse(e);return Je(t)?t.version===qe&&Je(t.entries)?{version:qe,entries:t.entries}:t:null}catch{return null}},et=(e,t)=>{try{e.setItem(`oc.gitBranchCache`,JSON.stringify(t))}catch{}},tt=(e,t,n)=>{let r=Ye(e);if(!r||!t)return null;let i;try{i=n.getItem(`oc.gitBranchCache`)}catch{return null}let a=$e(i);if(!a)return null;if(Qe(a))return Xe(a.entries[Ze(t,r)])?a.entries[Ze(t,r)]:null;let o={};for(let[e,n]of Object.entries(a)){let r=Ye(e);r&&Xe(n)&&(o[Ze(t,r)]=n)}return et(n,{version:qe,entries:o}),o[Ze(t,r)]??null},nt=(e,t,n,r)=>{let i=Ye(e);if(!i||!t||!Xe(n))return;let a=null;try{a=r.getItem(`oc.gitBranchCache`)}catch{return}let o=$e(a);et(r,{version:qe,entries:{...o&&Qe(o)?o.entries:{},[Ze(t,i)]:n}})},rt=3e4,it=Ye,at=(e,t=n())=>c.git.branches(it(e),t),ot=(e,t=n())=>c.git.remotes(it(e),t),st=async(e,t,n)=>{n.throwIfAborted();let r=d()?.git,i=t?.getGitBranches?await t.getGitBranches(e,{signal:n}):r?await r.getGitBranches(e,{signal:n}):await y(e,{signal:n});return n.throwIfAborted(),i},ct=async(e,t,n)=>{n.throwIfAborted();let r=d()?.git,i=t?.getRemotes?await t.getRemotes(e,{signal:n}):r?await r.getRemotes(e,{signal:n}):await _(e,{signal:n});return n.throwIfAborted(),i},lt=(e,t,i=n(),a=r())=>{let o=it(e),s=t;return{queryKey:at(o,i),queryFn:async({signal:e})=>{if(!o)throw Error(`Git branches require a directory`);let t=await st(o,s,e);return nt(o,i,t,a),t},staleTime:rt,gcTime:1/0,initialData:()=>tt(o,i,a)??void 0,initialDataUpdatedAt:0}},ut=(e,t,r=n())=>{let i=it(e),a=t;return{queryKey:ot(i,r),queryFn:({signal:e})=>{if(!i)throw Error(`Git remotes require a directory`);return ct(i,a,e)},staleTime:rt,gcTime:1/0}},dt=(e,r,i)=>{let a=(0,H.c)(9),o=i===void 0||i,s=I.useSyncExternalStore(t,n,n),c,l,u;a[0]!==e||a[1]!==r||a[2]!==s?(c=it(e),u=S,l=lt(c,r,s),a[0]=e,a[1]=r,a[2]=s,a[3]=c,a[4]=l,a[5]=u):(c=a[3],l=a[4],u=a[5]);let d=o&&!!c,f;return a[6]!==l||a[7]!==d?(f={...l,enabled:d},a[6]=l,a[7]=d,a[8]=f):f=a[8],u(f)},ft=(e,r,i)=>{let a=(0,H.c)(9),o=i===void 0||i,s=I.useSyncExternalStore(t,n,n),c,l,u;a[0]!==e||a[1]!==r||a[2]!==s?(c=it(e),u=S,l=ut(c,r,s),a[0]=e,a[1]=r,a[2]=s,a[3]=c,a[4]=l,a[5]=u):(c=a[3],l=a[4],u=a[5]);let d=o&&!!c,f;return a[6]!==l||a[7]!==d?(f={...l,enabled:d},a[6]=l,a[7]=d,a[8]=f):f=a[8],u(f)},pt=(e,t,r=u,i=n())=>r.fetchQuery(lt(e,t,i)),mt=(e,t,r=u,i=n())=>r.fetchQuery({...lt(e,t,i),staleTime:0}),ht=e=>e instanceof Error?e.name===`AbortError`||e.name===`CancelledError`||e.name===`Error`&&e.message===`CancelledError`:!1,gt=1e4,_t=6e4,vt=5e3,yt=3e4,bt=6e4,xt=25,St=40,Ct=2,wt=15e3,Tt=500,Et=30,Dt=20971520,Ot=new Map,kt=new Map,At=new Map,jt=new Map,Mt=new Map,Nt=(e,t)=>`${t}:${e}`,Pt=e=>kt.get(e)??0,Ft=e=>{let t=Pt(e)+1;return kt.set(e,t),t},It=e=>{let t=(At.get(e)??0)+1;return At.set(e,t),t},Lt=e=>{let t=Ot.get(e);if(t)return t;let n=new Set;return Ot.set(e,n),n},Q=()=>({isGitRepo:null,status:null,branches:null,branchesTransportIdentity:null,log:null,identity:null,diffCache:new Map,indexRevision:0,lastRepoCheckAt:0,lastStatusFetch:0,lastStatusChange:0,lastLogFetch:0,lastBranchesFetch:0,lastIdentityFetch:0,logMaxCount:25,isLoadingStatus:!1,isLoadingLog:!1,isLoadingBranches:!1,isLoadingIdentity:!1}),Rt=(e,t=Et,n=Dt)=>{let r=0;for(let t of e.values())r+=(t.original?.length??0)+(t.modified?.length??0);if(e.size<=t&&r<=n)return e;let i=Array.from(e.entries()).sort((e,t)=>e[1].fetchedAt-t[1].fetchedAt),a=new Map,o=0;for(let e=i.length-1;e>=0;e--){let[r,s]=i[e],c=(s.original?.length??0)+(s.modified?.length??0);if(a.size>=t)break;o+c>n&&a.size>0||(a.set(r,s),o+=c)}return a},zt=(e,t)=>{if(!e&&!t)return!1;if(!e||!t)return!0;let n=new Set([...Object.keys(e),...Object.keys(t)]);for(let r of n){let n=e[r],i=t[r];if(!(!n&&!i)&&(!n||!i||n.insertions!==i.insertions||n.deletions!==i.deletions))return!0}return!1},Bt=(e,t)=>!e&&!t?!1:!e||!t||e.remote!==t.remote||e.branch!==t.branch||e.ahead!==t.ahead||e.behind!==t.behind,Vt=(e,t)=>{if(!e&&!t)return!1;if(!e||!t)return!0;let n=e.files??[],r=t.files??[];if(n.length!==r.length||e.ahead!==t.ahead||e.behind!==t.behind||e.current!==t.current||e.tracking!==t.tracking||e.isClean!==t.isClean||t.upstreamComparison!==void 0&&Bt(e.upstreamComparison,t.upstreamComparison))return!0;let i=new Set(n.map(e=>`${e.path}:${e.index}:${e.working_dir}`));for(let e of r)if(!i.has(`${e.path}:${e.index}:${e.working_dir}`))return!0;return!!(t.diffStats!==void 0&&zt(e.diffStats,t.diffStats))},Ht=(e,t)=>{let n=new Set;if(!t)return n;let r=e?.files??[],i=t.files??[],a=new Map(r.map(e=>[e.path,e])),o=new Map(i.map(e=>[e.path,e])),s=new Set([...a.keys(),...o.keys()]);for(let e of s){let t=a.get(e),r=o.get(e);if(!t||!r){n.add(e);continue}if(t.index!==r.index||t.working_dir!==r.working_dir){n.add(e);continue}}if(t.diffStats!==void 0){let r=e?.diffStats??{},i=t.diffStats??{},a=new Set([...Object.keys(r),...Object.keys(i)]);for(let e of a){let t=r[e],a=i[e];if(!t||!a){n.add(e);continue}(t.insertions!==a.insertions||t.deletions!==a.deletions)&&n.add(e)}}return n},Ut=(e,t)=>{if(!e&&!t)return!1;if(!e||!t)return!0;let n=e.files??[],r=t.files??[],i=e=>{let t=e?.trim()??``;return t===`?`?``:t},a=new Map(n.map(e=>[e.path,i(e.index)])),o=new Map(r.map(e=>[e.path,i(e.index)])),s=new Set([...a.keys(),...o.keys()]);for(let e of s)if((a.get(e)??``)!==(o.get(e)??``))return!0;return!1},Wt=e=>!e||e.trim().length===0,Gt=e=>(e||``).trim()===`U`,Kt=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(Gt(t)||Gt(n))return e;let r=t===`?`||n===`?`?`A`:t||n||` `;return{...e,index:r,working_dir:` `}},qt=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(Gt(t)||Gt(n))return e;let r=n||(t===`A`||t===`?`?`?`:t)||` `;return{...e,index:` `,working_dir:r}},Jt=e=>Wt(e.index)&&Wt(e.working_dir),$=f()(m((e,t)=>({directories:new Map,activeDirectory:null,setActiveDirectory:n=>{let{activeDirectory:r,directories:i}=t();if(r!==n)if(r&&Ft(r),n&&Ft(n),n&&!i.has(n)){let t=new Map(i);t.set(n,Q()),e({activeDirectory:n,directories:t})}else e({activeDirectory:n})},getDirectoryState:e=>t().directories.get(e)??null,fetchStatus:async(n,r,i={})=>{let a=i.mode??`full`,o=Nt(n,a),s=jt.get(o)??(a===`light`?jt.get(Nt(n,`full`)):void 0);if(s)return s;let c=(async()=>{let{silent:a=!1}=i,{directories:o}=t(),s=o.get(n);if(s||=Q(),!a){let r=new Map(t().directories),i=r.get(n)??Q();r.set(n,{...i,isLoadingStatus:!0}),e({directories:r})}let c=!1;try{let a=Date.now(),o=s.isGitRepo!==!0||a-(s.lastRepoCheckAt||0)>_t,l=s.isGitRepo===!0;if(o&&(l=await r.checkIsGitRepository(n)),!l){let r=new Map(t().directories),i=r.get(n)??s;return r.set(n,{...i,isGitRepo:!1,status:null,isLoadingStatus:!1,lastRepoCheckAt:a,lastStatusFetch:a}),e({directories:r}),!1}let u=await r.getGitStatus(n,i.mode?{mode:i.mode}:void 0);if(Vt(s.status,u)){c=!0;let r=new Map(t().directories),i=r.get(n)??Q(),s=Ht(i.status,u),l=Ut(i.status,u),d=new Set((i.status?.files??[]).map(e=>e.path)),f=new Set((u.files??[]).map(e=>e.path)),p=new Map(i.diffCache);for(let e of d)f.has(e)||p.delete(e);for(let e of s)p.delete(e);let m=s.size>0;m&&Ft(n);let h={...u,diffStats:u.diffStats===void 0&&i.status?.diffStats!==void 0?i.status.diffStats:u.diffStats,upstreamComparison:u.upstreamComparison===void 0?i.status?.upstreamComparison:u.upstreamComparison};r.set(n,{...i,isGitRepo:!0,status:h,diffCache:p,indexRevision:l?i.indexRevision+1:i.indexRevision,lastRepoCheckAt:o?a:i.lastRepoCheckAt,lastStatusFetch:Date.now(),lastStatusChange:m?Date.now():i.lastStatusChange}),e({directories:r})}else{let r=new Map(t().directories),i=r.get(n)??Q();r.set(n,{...i,isGitRepo:!0,lastRepoCheckAt:o?a:i.lastRepoCheckAt,lastStatusFetch:Date.now(),lastStatusChange:i.lastStatusChange}),e({directories:r})}}catch(e){console.error(`Failed to fetch git status:`,e)}finally{if(!a){let r=new Map(t().directories),i=r.get(n)??Q();r.set(n,{...i,isLoadingStatus:!1}),e({directories:r})}}return c})();jt.set(o,c);try{return await c}finally{jt.get(o)===c&&jt.delete(o)}},moveStatusPathsOptimistically:(n,r,i)=>{let a=new Set(r.map(e=>e.trim()).filter(Boolean));if(a.size===0)return null;let{directories:o}=t(),s=o.get(n),c=s?.status??null;if(!s||!c)return c;let l=!1,u=[];for(let e of c.files){if(!a.has(e.path)){u.push(e);continue}let t=i===`stage`?Kt(e):qt(e);t!==e&&(l=!0),Jt(t)?l=!0:u.push(t)}if(!l)return c;let d=new Map(o);return d.set(n,{...s,status:{...c,files:u,isClean:u.length===0},indexRevision:s.indexRevision+1,lastStatusChange:Date.now()}),e({directories:d}),c},restoreStatus:(n,r)=>{let{directories:i}=t(),a=i.get(n);if(!a)return;let o=new Map(i);o.set(n,{...a,status:r,indexRevision:a.indexRevision+1,lastStatusChange:Date.now()}),e({directories:o})},bumpIndexRevision:n=>{let{directories:r}=t(),i=r.get(n);if(!i)return;let a=new Map(r);a.set(n,{...i,indexRevision:i.indexRevision+1}),e({directories:a})},fetchBranches:async(r,i,a={})=>{let o=n(),s=It(r);{let n=new Map(t().directories),i=n.get(r)??Q();n.set(r,{...i,isLoadingBranches:!0}),e({directories:n})}try{let c=a.force?await mt(r,i,void 0,o):await pt(r,i,void 0,o);if(s!==At.get(r)||o!==n())return;let l=new Map(t().directories),u=l.get(r)??Q();l.set(r,{...u,branches:c,branchesTransportIdentity:o,isLoadingBranches:!1,lastBranchesFetch:Date.now()}),e({directories:l})}catch(i){if(ht(i)||console.error(`Failed to fetch git branches:`,i),s!==At.get(r)||o!==n())return;let a=new Map(t().directories),c=a.get(r)??Q();a.set(r,{...c,isLoadingBranches:!1}),e({directories:a})}},fetchLog:async(n,r,i)=>{let{directories:a}=t(),o=a.get(n),s=i??o?.logMaxCount??25;{let r=new Map(t().directories),i=r.get(n)??Q();r.set(n,{...i,isLoadingLog:!0}),e({directories:r})}try{let i=await r.getGitLog(n,{maxCount:s}),a=new Map(t().directories),o=a.get(n)??Q();a.set(n,{...o,log:i,isLoadingLog:!1,lastLogFetch:Date.now(),logMaxCount:s}),e({directories:a})}catch(r){console.error(`Failed to fetch git log:`,r);let i=new Map(t().directories),a=i.get(n)??Q();i.set(n,{...a,isLoadingLog:!1}),e({directories:i})}},fetchIdentity:async(n,r)=>{{let r=new Map(t().directories),i=r.get(n)??Q();r.set(n,{...i,isLoadingIdentity:!0}),e({directories:r})}try{let i=await r.getCurrentGitIdentity(n),a=new Map(t().directories),o=a.get(n)??Q();a.set(n,{...o,identity:i,isLoadingIdentity:!1,lastIdentityFetch:Date.now()}),e({directories:a})}catch(r){console.error(`Failed to fetch git identity:`,r);let i=new Map(t().directories),a=i.get(n)??Q();i.set(n,{...a,isLoadingIdentity:!1}),e({directories:i})}},fetchAll:async(n,r,i={})=>{let{directories:a}=t(),o=a.get(n);if(!o){o=Q();let t=new Map(a);t.set(n,o),e({directories:t})}let{force:s=!1,silentIfCached:c=!1}=i,l=Date.now();await t().fetchStatus(n,r,{silent:c&&!!o?.status});let u=t().directories.get(n);if(!u?.isGitRepo)return;await t().fetchBranches(n,r,{force:s});let d=l-(u.lastLogFetch||0);(s||d>gt||!u.log)&&await t().fetchLog(n,r),await t().fetchIdentity(n,r)},getDiff:(e,n)=>t().directories.get(e)?.diffCache.get(n)??null,setDiff:(n,r,i)=>{let a=new Map(t().directories),o=a.get(n)??Q(),s=new Map(o.diffCache);s.set(r,{...i,fetchedAt:Date.now()});let c=Rt(s);a.set(n,{...o,diffCache:c}),e({directories:a})},clearDiffCache:n=>{Ft(n);let r=new Map(t().directories),i=r.get(n);i&&(r.set(n,{...i,diffCache:new Map}),e({directories:r}))},fetchAllDiffs:async(e,n)=>{let r=t().directories.get(e);if(!r?.status?.files||r.status.files.length===0)return;let i=r.status.files.map(e=>e.path).slice(0,xt);await t().prefetchDiffs(e,n,i,{maxFiles:xt})},prefetchDiffs:async(n,r,i,a={})=>{let o=t().directories.get(n);if(!o?.status?.files||o.status.files.length===0||i.length===0)return;let{maxFiles:s=St}=a,c=new Set(o.status.files.map(e=>e.path)),l=o.status.diffStats,u=Lt(n),d=[],f=new Set;for(let e of i){if(!e||f.has(e)||(f.add(e),!c.has(e))||o.diffCache.has(e)||u.has(e))continue;let t=l?.[e];t&&t.insertions+t.deletions>Tt||d.push(e)}let p=d.slice(0,Math.max(1,s));if(p.length===0)return;let m=Pt(n);if(typeof document<`u`&&document.hidden)return;p.forEach(e=>u.add(e));let h=0,g=[],_=()=>{let e=h;return h+=1,e<p.length?p[e]:null},v=async e=>{let t=r.getGitFileDiff(n,{path:e}),i=new Promise((e,t)=>{setTimeout(()=>t(Error(`Timed out after ${wt}ms`)),wt)}),a=await Promise.race([t,i]);return{path:e,diff:{original:a.original??``,modified:a.modified??``,isBinary:a.isBinary}}},y=async()=>{for(;;){if(m!==Pt(n))return;let e=_();if(!e)return;try{g.push(await v(e))}catch{}finally{u.delete(e)}}},b=Math.min(Ct,p.length);if(await Promise.allSettled(Array.from({length:b},()=>y())),p.forEach(e=>u.delete(e)),m!==Pt(n))return;let x=new Map(t().directories),S=x.get(n);if(!S)return;let C=new Map(S.diffCache),ee=Date.now();g.forEach(e=>{C.set(e.path,{...e.diff,fetchedAt:ee})});let te=Rt(C);x.set(n,{...S,diffCache:te}),e({directories:x})},setLogMaxCount:(n,r)=>{let i=new Map(t().directories),a=i.get(n)??Q();i.set(n,{...a,logMaxCount:r}),e({directories:i})},ensureStatus:async(e,n)=>{let r=t().directories.get(e),i=Date.now();r?.status&&i-r.lastStatusFetch<vt||await t().fetchStatus(e,n,{silent:!!r?.status})},ensureAll:(e,n)=>{let r=Mt.get(e);if(r)return r;let i=(async()=>{let r=t().directories.get(e),i=Date.now();(!r?.status||r.status.diffStats===void 0||i-(r?.lastStatusFetch??0)>=vt)&&await t().fetchStatus(e,n,{silent:!!r?.status});let a=t().directories.get(e);if(!a?.isGitRepo)return;let o=[];(!a.branches||i-a.lastBranchesFetch>=yt)&&o.push(t().fetchBranches(e,n)),(!a.log||i-a.lastLogFetch>=gt)&&o.push(t().fetchLog(e,n)),(!a.identity||i-a.lastIdentityFetch>=bt)&&o.push(t().fetchIdentity(e,n)),o.length>0&&await Promise.all(o)})();return Mt.set(e,i),i.finally(()=>{Mt.get(e)===i&&Mt.delete(e)}),i},refresh:async(e,n={})=>{let{activeDirectory:r}=t();r&&await t().fetchAll(r,e,n)}}),{name:`git-store`})),Yt=e=>{let t=(0,H.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.status??null:null,t[0]=e,t[1]=n),$(n)},Xt=e=>{let r=(0,H.c)(3),i=I.useSyncExternalStore(t,n,n),a;return r[0]!==e||r[1]!==i?(a=t=>{if(!e)return null;let n=t.directories.get(e);return n?.branchesTransportIdentity===i?n.branches:null},r[0]=e,r[1]=i,r[2]=a):a=r[2],$(a)},Zt=e=>{let t=(0,H.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.log??null:null,t[0]=e,t[1]=n),$(n)},Qt=e=>{let t=(0,H.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isGitRepo??null:null,t[0]=e,t[1]=n),$(n)},$t=e=>{let t=(0,H.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.status?.current?.trim()??null:null,t[0]=e,t[1]=n),$(n)},en={current:new Map},tn=()=>$(sn),nn=e=>{let t=(0,H.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=new Map,t[0]=n):n=t[0];let r=I.useRef(n),i;return t[1]===e?i=t[2]:(i=t=>{let n=r.current,i=n.size===e.length;if(i)for(let r of e){let e=t.directories.get(r),a=n.get(r);if(!a||(e?.isGitRepo??null)!==a.isGitRepo||(e?.status?.current??null)!==a.branch){i=!1;break}}if(i)return n;let a=new Map;for(let n of e){let e=t.directories.get(n);a.set(n,{isGitRepo:e?.isGitRepo??null,branch:e?.status?.current??null})}return r.current=a,a},t[1]=e,t[2]=i),$(i)},rn=e=>{let t=(0,H.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isLoadingStatus??!1:!1,t[0]=e,t[1]=n),$(n)},an=e=>{let t=(0,H.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isLoadingLog??!1:!1,t[0]=e,t[1]=n),$(n)},on=e=>{let t=(0,H.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isLoadingBranches??!1:!1,t[0]=e,t[1]=n),$(n)};function sn(e){let t=en.current,n=t.size===e.directories.size;if(n){for(let[r,i]of e.directories)if(t.get(r)!==(i.status?.current??null)){n=!1;break}}if(n)return t;let r=new Map;for(let[t,n]of e.directories)r.set(t,n.status?.current??null);return en.current=r,r}var cn=e=>{let t=String(e||``).trim().replace(/^remotes\//,``);if(!t)return null;let n=t.indexOf(`/`);return n<=0||n>=t.length-1?null:{remote:t.slice(0,n),branch:t.slice(n+1)}},ln=e=>String(e||``).trim().replace(/^refs\/heads\//,``).replace(/^heads\//,``).replace(/^remotes\//,``),un=e=>e.branchName?ln(e.branchName):e.mode===`existing`?ln(e.existingBranch||e.preferredName||``):ln(e.preferredName||``),dn=async e=>{let t=await P(e);try{let n=cn((await j(e)).branches?.[t]?.tracking||null);if(n?.remote)return n.remote}catch{}try{let t=cn((await M(e)).tracking);if(t?.remote)return t.remote}catch{}return null},fn=async(e,t)=>{let n=await dn(e),r=ln(t);return!n||!r?null:{setUpstream:!0,upstreamRemote:n,upstreamBranch:r}},pn=async(e,t,n)=>{let r=un(t),i=n?.resolvedRootTrackingRemote,a=i===void 0?await fn(e,r):i&&ln(r)?{setUpstream:!0,upstreamRemote:i,upstreamBranch:ln(r)}:null;return a?{...t,setUpstream:t.setUpstream??a.setUpstream,upstreamRemote:t.upstreamRemote||a.upstreamRemote,upstreamBranch:t.upstreamBranch||a.upstreamBranch}:t},mn=async(e,t,n)=>{let r=await pn(e.path,t,n);return F(e,r)},hn=`oc:lastWorktreeSourceBranch`,gn=({mode:e,sourceBranch:t,linkedPr:n,selectedBranch:r})=>e===`existing-branch`?r||null:n?null:t||null,_n=({branches:e,savedSourceBranch:t,rootBranch:n})=>t&&e.includes(t)&&t?{sourceBranch:t,shouldClearSavedSourceBranch:!1}:{sourceBranch:n&&e.includes(n)?n:e.includes(`main`)?`main`:e.includes(`master`)?`master`:e[0]??``,shouldClearSavedSourceBranch:!!t},vn=(e,t,n)=>{if(!e)return e;let r=t.length>0&&!/\s$/.test(t)&&!/^\s/.test(e)&&!/[([{]$/.test(t),i=n.length>0&&!/\s$/.test(e)&&!/^\s/.test(n)&&!/^[\])}.,;:!?]/.test(n);return`${r?` `:``}${e}${i?` `:``}`},yn=(e,t,n)=>{let r=vn(e,t,n);return`${t.length===0&&!/^\s/.test(r)?` `:``}${r}${n.length===0&&!/\s$/.test(r)?` `:``}`},bn=(e,t,n,r)=>{let i=e.slice(0,t),a=e.slice(n),o=yn(r,i,a),s=Math.max(0,o.indexOf(r)),c=i.length+s;return{text:`${i}${o}${a}`,caret:i.length+o.length,start:c,end:c+r.length}},xn=(e,t)=>{let n=e=>`${e.kind}:${e.value}:${e.range.start}:${e.range.end}`;return new Set(e.map(n)).has(n(t))?[...e]:[...e,t]},Sn=(e,t)=>t<e.length&&e[t]===` `?t+1:t;export{ve as A,dt as C,we as D,Me as E,pe as M,fe as N,Se as O,mt as S,Pe as T,Zt as _,hn as a,$ as b,mn as c,tn as d,$t as f,rn as g,an as h,yn as i,me as j,Z as k,dn as l,on as m,xn as n,_n as o,Xt as p,bn as r,gn as s,Sn as t,pn as u,nn as v,ft as w,Qt as x,Yt as y};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{A as t,E as n,b as r,t as i,y as a}from"./useUIStore-D6BTB4va.js";import{$t as o,D as s,d as c,k as l,u,xn as d}from"./persistence-C_KCiMcY.js";import{a as f,i as p,r as m}from"./vendor-zustand-B4dlGEM2.js";import{nt as h,rt as g}from"./vendor-base-ui-CnHfUmDN.js";import{L as _,Ot as v,k as y,yt as b}from"./gitApiHttp-C1DaEMKR.js";import{n as x}from"./vendor-react-DLPElpoQ.js";import{s as S}from"./vendor-tanstack-react-query-D7pys_c9.js";import{n as C}from"./vendor-reactuses-core-DDoDDyM9.js";import{n as ee}from"./clipboard-CXWbHCAk.js";import{Ga as te,Hi as ne,Sr as re,_ as w,b as ie,co as T,ct as E,en as ae,l as D,ot as oe,so as se,st as ce,un as O}from"./useMobileNavigationStore-1xHjnAsg.js";import{c as le,t as k}from"./utils-DyUyiLje.js";import{n as A}from"./Icon-BPJ_quEe.js";import{g as j,v as M}from"./gitApi-Bs_2iBAm.js";import{A as ue,M as N,p as P,s as F}from"./projectMeta-Cp74cItv.js";var I=e(g(),1),L=e=>{if(!e)return``;let t=e.replace(/\\/g,`/`),n=t.startsWith(`//`),r=t.replace(/\/+/g,`/`);n&&!r.startsWith(`//`)&&(r=`/${r}`);let i=r===`/`,a=/^[A-Za-z]:\/$/.test(r);return!i&&!a&&(r=r.replace(/\/+$/,``)),r},R=e=>/^[A-Za-z]:\//.test(e)?e.toLowerCase():e,z=(e,t)=>{let n=L(t),r=L(e);if(!n||!r)return!1;let i=R(n),a=R(r);return a===i||a.startsWith(`${i}/`)},de=e=>{if(!e||typeof e!=`object`)return{};let t=e,n={};for(let[e,r]of Object.entries(t)){let t=L(e);if(!t||!r||typeof r!=`object`)continue;let i=r,a=Array.isArray(i.openPaths)?Array.from(new Set(i.openPaths.filter(e=>typeof e==`string`).map(e=>L(e)).filter(e=>z(e,t)))):[],o=Array.isArray(i.expandedPaths)?Array.from(new Set(i.expandedPaths.filter(e=>typeof e==`string`).map(e=>L(e)).filter(e=>z(e,t)))):[],s=typeof i.selectedPath==`string`?L(i.selectedPath):null,c=s&&z(s,t)?s:a[0]??null,l=typeof i.touchedAt==`number`&&Number.isFinite(i.touchedAt)?i.touchedAt:Date.now(),u=n[t];if(u){let e=Array.from(new Set([...u.openPaths,...a])),r=Array.from(new Set([...u.expandedPaths,...o]));n[t]={openPaths:e,selectedPath:u.selectedPath??c??e[0]??null,expandedPaths:r,touchedAt:Math.max(u.touchedAt,l)};continue}n[t]={openPaths:a,selectedPath:c,expandedPaths:o,touchedAt:l}}return n},B=(e,t)=>{let n=Object.entries(e);if(n.length<=t)return e;n.sort((e,t)=>(t[1]?.touchedAt??0)-(e[1]?.touchedAt??0));let r={};for(let[e,i]of n.slice(0,t))r[e]=i;return r},V=e=>e?{...e,touchedAt:Date.now()}:{openPaths:[],selectedPath:null,expandedPaths:[],touchedAt:Date.now()},fe=f()(m(p((e,t)=>({byRoot:{},addOpenPath:(t,n,r)=>{let i=L((t||``).trim()),a=L((n||``).trim());!i||!a||!r?.allowOutsideRoot&&!z(a,i)||e(e=>{let t=e.byRoot[i],n=V(t),r=n.openPaths.includes(a),o=r?n.openPaths:[...n.openPaths,a],s=n.selectedPath??a;return t&&r&&t.selectedPath===s?e:{byRoot:B({...e.byRoot,[i]:{...n,openPaths:o,selectedPath:s}},20)}})},removeOpenPath:(t,n)=>{let r=L((t||``).trim()),i=L((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=R(i),a=e=>R(e)===n,o=t.selectedPath?a(t.selectedPath):!1;if(!t.openPaths.some(a)&&!o)return e;let s=t.openPaths.filter(e=>!a(e)),c=o?s[0]??null:t.selectedPath;return{byRoot:B({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeOpenPathsByPrefix:(t,n)=>{let r=L((t||``).trim()),i=L((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=R(i),a=n.endsWith(`/`)?n:`${n}/`,o=e=>{let t=R(e);return t===n||t.startsWith(a)},s=t.openPaths.filter(e=>!o(e));if(s.length===t.openPaths.length)return e;let c=t.selectedPath&&o(t.selectedPath)?s[0]??null:t.selectedPath;return{byRoot:B({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeExpandedPathsByPrefix:(t,n)=>{let r=L((t||``).trim()),i=L((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=R(i),a=n.endsWith(`/`)?n:`${n}/`,o=t.expandedPaths.filter(e=>{let t=R(e);return t!==n&&!t.startsWith(a)});return o.length===t.expandedPaths.length?e:{byRoot:B({...e.byRoot,[r]:{...t,expandedPaths:o,touchedAt:Date.now()}},20)}})},setSelectedPath:(t,n,r)=>{let i=L((t||``).trim()),a=n?L(n.trim()):null;!i||a&&!r?.allowOutsideRoot&&!z(a,i)||e(e=>{let t=e.byRoot[i],n=V(t),r=a&&!n.openPaths.includes(a)?[...n.openPaths,a]:n.openPaths;return t&&t.selectedPath===a&&r===t.openPaths?e:{byRoot:B({...e.byRoot,[i]:{...n,openPaths:r,selectedPath:a}},20)}})},ensureSelectedPath:e=>{let n=L((e||``).trim());if(!n)return;let r=t().byRoot[n];if(!r||r.selectedPath)return;let i=r.openPaths[0]??null;i&&t().setSelectedPath(n,i)},toggleExpandedPath:(t,n)=>{let r=L((t||``).trim()),i=L((n||``).trim());!r||!i||!z(i,r)||e(e=>{let t=e.byRoot[r],n=V(t),a=n.expandedPaths.includes(i)?n.expandedPaths.filter(e=>e!==i):[...n.expandedPaths,i];return t&&t.expandedPaths===a&&t.selectedPath===n.selectedPath&&t.openPaths===n.openPaths?e:{byRoot:B({...e.byRoot,[r]:{...n,expandedPaths:a}},20)}})},expandPath:(t,n)=>{let r=L((t||``).trim()),i=L((n||``).trim());!r||!i||!z(i,r)||e(e=>{let t=e.byRoot[r],n=V(t);return n.expandedPaths.includes(i)&&t?e:{byRoot:B({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,i]}},20)}})},expandPaths:(t,n)=>{let r=L((t||``).trim());if(!r||!n||n.length===0)return;let i=n.map(e=>L((e||``).trim())).filter(e=>e&&z(e,r));i.length!==0&&e(e=>{let t=e.byRoot[r],n=V(t),a=new Set(n.expandedPaths),o=i.filter(e=>!a.has(e));return o.length===0?e:{byRoot:B({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,...o]}},20)}})}}),{name:`files-view-tabs-store`,version:2,storage:a(),migrate:e=>{if(!e||typeof e!=`object`)return{byRoot:{}};let t=e.byRoot;return{byRoot:de(t)}},partialize:e=>({byRoot:de(e.byRoot)})}),{name:`files-view-tabs-store`})),H=x(),pe=(e,t)=>{let n=(0,H.c)(4),r=t===void 0?200:t,[i,a]=I.useState(e),o,s;return n[0]!==r||n[1]!==e?(o=()=>{let t=window.setTimeout(()=>{a(e)},r);return()=>{window.clearTimeout(t)}},s=[e,r],n[0]=r,n[1]=e,n[2]=o,n[3]=s):(o=n[2],s=n[3]),I.useEffect(o,s),i},me=()=>{let e=(0,H.c)(17),t=D(U),n=O(),r;e[0]===t?r=e[1]:(r=e=>t?e.getAttachment(t):void 0,e[0]=t,e[1]=r);let i=ie(r),a=D(W),o=D(G),s=T(K),c=T(he),l=b(ge);if(t){let r;e[2]===i?r=e[3]:(r=w(i),e[2]=i,e[3]=r);let o=r;if(o)return o;let s;e[4]!==t||e[5]!==a?(s=a.get(t),e[4]=t,e[5]=a,e[6]=s):s=e[6];let c=s;if(c?.path)return c.path;let l;if(e[7]!==t||e[8]!==n){let r;e[10]===t?r=e[11]:(r=e=>e.id===t,e[10]=t,e[11]=r),l=n.find(r),e[7]=t,e[8]=n,e[9]=l}else l=e[9];let u=l;if(u?.directory)return u.directory}if(o?.open&&(o.bootstrapPendingDirectory||o.directoryOverride))return(o.bootstrapPendingDirectory||o.directoryOverride)??void 0;if(s){let t;if(e[12]!==s||e[13]!==c){let n;e[15]===s?n=e[16]:(n=e=>e.id===s,e[15]=s,e[16]=n),t=c.find(n),e[12]=s,e[13]=c,e[14]=t}else t=e[14];let n=t;if(n?.path)return n.path}return l??void 0};function U(e){return e.currentSessionId}function W(e){return e.worktreeMetadata}function G(e){return e.newSessionDraft}function K(e){return e.activeProjectId}function he(e){return e.projects}function ge(e){return e.currentDirectory}var _e=.4,q=8,J=e=>{let t=e.gap??q,n=Math.max(0,e.popupBottom-e.boundaryTop-t),r=e.viewportHeight*_e,i=Math.floor(Math.min(n,r));return n>=120?Math.min(n,Math.max(120,i)):i},Y=(e,t=0)=>{let n=e.closest(`main`);if(!n)return null;let r=(e.closest(`.mobile-chat-screen__content`)?.parentElement??n.parentElement?.closest(`main`)??n).querySelector(`:scope > .oc-mobile-detail-navigation`)?.getBoundingClientRect().bottom,i=n.getBoundingClientRect().top;return Math.max(r===void 0?i:Math.max(r,i),t)},ve=(e,t)=>{let n=(0,H.c)(3),[r,i]=I.useState(void 0),a;return n[0]!==e||n[1]!==t?(a=()=>{if(!t)return;let n=()=>{let t=e.current;if(!t)return;let n=window.visualViewport,r=Y(t,n?.offsetTop??0);if(r===null)return;let a=n?.height??window.innerHeight,o=J({popupBottom:t.getBoundingClientRect().bottom,boundaryTop:r,viewportHeight:a});i(e=>e===o?e:o)};return n(),window.addEventListener(`resize`,n),window.addEventListener(`oc:keyboard-settled`,n),window.visualViewport?.addEventListener(`resize`,n),window.visualViewport?.addEventListener(`scroll`,n),()=>{window.removeEventListener(`resize`,n),window.removeEventListener(`oc:keyboard-settled`,n),window.visualViewport?.removeEventListener(`resize`,n),window.visualViewport?.removeEventListener(`scroll`,n)}},n[0]=e,n[1]=t,n[2]=a):a=n[2],I.useLayoutEffect(a),t?r:void 0},ye=()=>{let e=null,t=!1,n=!1;return{pointerDown:(n,r)=>{e={x:n,y:r},t=!1},pointerMove:(n,r)=>{e&&Math.hypot(n-e.x,r-e.y)>6&&(t=!0)},pointerCancel:()=>{e=null,t=!1},pointerUp:r=>{if(!e)return!1;let i=!t;return e=null,t=!1,i?(n=!0,r(),!0):(n=!0,!1)},click:e=>n?(n=!1,!1):(e(),!0)}},X=h(),Z=I.forwardRef(({searchQuery:e,onFileSelect:t,onAgentSelect:n,onSessionSelect:r,onClose:a,style:o},c)=>{let{t:u}=ee(),d=me()??``,f=D(e=>e.currentSessionId),p=re(e=>e.activeSessions),m=T(e=>e.activeProjectId),h=T(e=>e.projects),g=I.useMemo(()=>h.find(e=>e.id===m)?.path??null,[m,h]),_=I.useMemo(()=>{let e=g||d;return e?e.replace(/\\/g,`/`).replace(/\/+$/,``):null},[g,d]),y=fe(e=>_?e.byRoot[_]:void 0),b=ne(e=>e.getVisibleAgents),x=v(e=>e.searchFiles),S=pe(e,180),te=l(),w=s(),[ie,E]=I.useState([]),[ae,se]=I.useState([]),[O,j]=I.useState(!1),[M,N]=I.useState(0),P=I.useRef(0),[F,L]=I.useState(360),[R,z]=I.useState({}),[de,B]=I.useState({}),V=I.useRef([]),H=I.useRef([]),U=I.useRef([]),W=I.useRef(null),G=I.useRef(null);G.current||=ye();let K=i(e=>e.isMobile),he=ve(W,K),ge=(e??``).trim(),_e=I.useMemo(()=>{if(!_||!y)return[];let e=[y.selectedPath,...y.openPaths.slice().reverse()].filter(e=>typeof e==`string`&&e.length>0),t=new Set,n=ge.toLowerCase();return e.filter(e=>{if(t.has(e))return!1;t.add(e);let r=e.startsWith(`${_}/`)?e.slice(_.length+1):e;return!n||r.toLowerCase().includes(n)}).slice(0,6).map(e=>{let t=e.replace(/\\/g,`/`),n=t.split(`/`).filter(Boolean).pop()||t;return{name:n,path:t,relativePath:t.startsWith(`${_}/`)?t.slice(_.length+1):t,extension:n.includes(`.`)?n.split(`.`).pop()?.toLowerCase():void 0}})},[ge,_,y]),q=I.useMemo(()=>ge.length>0?ae:ae.slice(0,2),[ae,ge.length]),J=I.useMemo(()=>r?oe({sessions:p,currentSessionId:f,searchQuery:ge}):[],[p,f,ge,r]),Y=_e,Z=ie;I.useEffect(()=>{let e=e=>{let t=e.target;!t||!W.current||W.current.contains(t)||a()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[a]),I.useEffect(()=>{if(!d){E([]);return}let e=(S??``).trim().replace(/^\.\//,``).replace(/^\/+/,``).toLowerCase();if(!e){E([]);return}let t=!1;j(!0);let n={includeHidden:te,respectGitignore:!w};return Promise.all([x(d,e,80,{...n,type:`file`}),x(d,e,40,{...n,type:`directory`})]).then(([n,r])=>{if(t)return;let i=new Set(_e.map(e=>e.path));E(ce({files:n,directories:r,query:e,excludePaths:i,limit:20}))}).catch(()=>{t||E([])}).finally(()=>{t||j(!1)}),()=>{t=!0}},[d,S,_e,x,te,w]),I.useEffect(()=>{let t=b(),n=(e??``).trim().toLowerCase(),r=t.filter(e=>e.mode&&e.mode!==`primary`).filter(e=>!n||`${e.name} ${e.description??``}`.toLowerCase().includes(n)).map(e=>({name:e.name,description:e.description,mode:e.mode})).sort((e,t)=>e.name.localeCompare(t.name));se(r)},[b,e]),I.useEffect(()=>{N(0),z({}),B({})},[Z,Y.length,q.length,J.length]),I.useEffect(()=>{P.current=M},[M]),I.useEffect(()=>{V.current[M]?.scrollIntoView({block:`nearest`})},[M]),I.useEffect(()=>{let e=null,t=()=>{e!==null&&cancelAnimationFrame(e),e=requestAnimationFrame(()=>{let e={},t={};H.current.forEach((n,r)=>{if(!n)return;let i=U.current[r]?.offsetWidth??n.scrollWidth,a=Math.max(0,i-n.clientWidth),o=a>8;if(e[r]=o,o){let e=Math.max(.6,a/110);t[r]=e}}),z(e),B(t)})};return t(),window.addEventListener(`resize`,t),()=>{e!==null&&cancelAnimationFrame(e),window.removeEventListener(`resize`,t)}},[Z,Y]),I.useEffect(()=>{let e=H.current[M];if(!e)return;let t=()=>{let t=e.clientWidth;t>0&&L(t)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>{n.disconnect()}},[M]);let be=C(e=>{t(e)}),xe=C(e=>{n?.(e)}),Se=C(e=>{r?.(e)}),Ce=(e,t)=>({onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&G.current?.pointerDown(e.clientX,e.clientY)},onPointerMove:e=>{e.pointerType===`touch`&&G.current?.pointerMove(e.clientX,e.clientY)},onPointerUp:e=>{e.pointerType===`touch`&&(G.current?.pointerUp(t)??!1)&&(e.preventDefault(),e.stopPropagation())},onPointerCancel:()=>G.current?.pointerCancel(),onClick:()=>{G.current?.click(t)},onMouseMove:()=>N(e)});I.useImperativeHandle(c,()=>({handleKeyDown:e=>{if(e===`Escape`){a();return}let t=q.length+J.length+Y.length+Z.length;if(t!==0){if(e===`ArrowDown`){N(e=>(e+1)%t);return}if(e===`ArrowUp`){N(e=>(e-1+t)%t);return}if(e===`Enter`||e===`Tab`){let e=(P.current%t+t)%t;if(e<q.length){let t=q[e];t&&xe(t.name);return}let n=e-q.length;if(n<J.length){let e=J[n];e&&Se(e);return}let r=n-J.length,i=r<Y.length?Y[r]:Z[r-Y.length];i&&be(i)}}}}),[Z,Y,q,J,a,be,xe,Se]);let we=e=>{if(e.isDirectory)return(0,X.jsx)(A,{name:`folder-3-fill`,className:`h-3.5 w-3.5 text-current`});switch(e.extension?.toLowerCase()){case`ts`:case`tsx`:case`js`:case`jsx`:return(0,X.jsx)(A,{name:`code`,className:`h-3.5 w-3.5 text-current`});case`json`:return(0,X.jsx)(A,{name:`code`,className:`h-3.5 w-3.5 text-current`});case`md`:case`mdx`:return(0,X.jsx)(A,{name:`file`,className:`h-3.5 w-3.5 text-current`});case`png`:case`jpg`:case`jpeg`:case`gif`:case`svg`:return(0,X.jsx)(A,{name:`file-image`,className:`h-3.5 w-3.5 text-current`});default:return(0,X.jsx)(A,{name:`file-pdf`,className:`h-3.5 w-3.5 text-current`})}};return(0,X.jsxs)(`div`,{ref:W,className:`absolute z-[100] min-w-0 w-full max-w-[640px] max-h-64 bg-background border-2 border-border/60 rounded-xl shadow-none bottom-full mb-2 left-0 flex flex-col`,style:he===void 0?o:{...o,maxHeight:he},children:[(0,X.jsx)(ue,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0`,children:(0,X.jsxs)(`div`,{className:`pb-2`,children:[q.length>0&&(0,X.jsx)(`div`,{className:`px-3 pb-1 pt-2 typography-meta font-medium text-muted-foreground`,children:u(`chat.fileMentionAutocomplete.groups.agents`)}),q.map((e,t)=>(0,X.jsx)(`div`,{ref:e=>{V.current[t]=e},className:k(`flex items-start gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,K&&`min-h-11`,M===t&&`bg-interactive-selection text-interactive-selection-foreground`),...Ce(t,()=>xe(e.name)),children:(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`div`,{className:`font-semibold truncate`,children:[`@`,e.name]}),e.description&&!K?(0,X.jsx)(`div`,{className:`typography-meta text-muted-foreground truncate`,children:e.description}):null]})},`agent-${e.name}`)),q.length===2&&ge.length===0&&ae.length>2&&(0,X.jsx)(`div`,{className:`px-3 py-1 typography-meta text-muted-foreground`,children:u(`chat.fileMentionAutocomplete.searchMoreAgents`)}),J.length>0&&(0,X.jsx)(`div`,{className:`px-3 pb-1 pt-2 typography-meta font-medium text-muted-foreground`,children:u(`chat.fileMentionAutocomplete.groups.sessions`)}),J.map((e,t)=>{let n=q.length+t;return(0,X.jsxs)(`div`,{ref:e=>{V.current[n]=e},className:k(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,K&&`min-h-11`,M===n&&`bg-interactive-selection text-interactive-selection-foreground`),...Ce(n,()=>Se(e)),children:[(0,X.jsx)(A,{name:`chat-thread`,className:`h-4 w-4 flex-shrink-0 text-[var(--primary-base)]`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.title||u(`chat.fileMentionAutocomplete.untitledSession`),children:e.title||u(`chat.fileMentionAutocomplete.untitledSession`)}),K?null:(0,X.jsx)(`span`,{className:`flex-shrink-0 typography-meta text-muted-foreground`,children:u(`chat.fileMentionAutocomplete.sessionType`)})]},`session-${e.id}`)}),Y.length>0&&(0,X.jsx)(`div`,{className:`px-3 pb-1 pt-2 typography-meta font-medium text-muted-foreground`,children:u(`chat.fileMentionAutocomplete.groups.recentFiles`)}),Y.map((e,t)=>{let n=q.length+J.length+t,r=e.relativePath||e.name,i=le(r,{maxLength:60}),a=M===n,o=R[n]??!1,s=de[n]??2.6;return(0,X.jsxs)(`div`,{ref:e=>{V.current[n]=e},className:k(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,K&&`min-h-11`,a&&`bg-interactive-selection text-interactive-selection-foreground`),...Ce(n,()=>be(e)),children:[we(e),(0,X.jsxs)(`span`,{ref:e=>{H.current[n]=e},className:`relative flex-1 min-w-0 overflow-hidden file-mention-marquee-container`,style:a?{"--file-mention-marquee-width":`${F}px`,"--file-mention-marquee-duration":`${s}s`}:void 0,"aria-label":r,children:[(0,X.jsx)(`span`,{ref:e=>{U.current[n]=e},className:`absolute invisible whitespace-nowrap pointer-events-none`,"aria-hidden":!0,children:r}),o&&a?(0,X.jsx)(`span`,{className:`inline-block whitespace-nowrap file-mention-marquee`,children:r}):(0,X.jsx)(`span`,{className:`block truncate`,children:i})]})]},`recent-${e.path}`)}),Z.length>0&&(0,X.jsx)(`div`,{className:`px-3 pb-1 pt-2 typography-meta font-medium text-muted-foreground`,children:u(`chat.fileMentionAutocomplete.groups.files`)}),Z.map((e,t)=>{let n=q.length+J.length+Y.length+t,r=e.relativePath||e.name,i=le(r,{maxLength:60}),a=M===n,o=R[n]??!1,s=de[n]??2.6;return(0,X.jsxs)(`div`,{ref:e=>{V.current[n]=e},className:k(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,K&&`min-h-11`,a&&`bg-interactive-selection text-interactive-selection-foreground`),...Ce(n,()=>be(e)),children:[we(e),(0,X.jsxs)(`span`,{ref:e=>{H.current[n]=e},className:`relative flex-1 min-w-0 overflow-hidden file-mention-marquee-container`,style:a?{"--file-mention-marquee-width":`${F}px`,"--file-mention-marquee-duration":`${s}s`}:void 0,"aria-label":r,children:[(0,X.jsx)(`span`,{ref:e=>{U.current[n]=e},className:`absolute invisible whitespace-nowrap pointer-events-none`,"aria-hidden":!0,children:r}),o&&a?(0,X.jsx)(`span`,{className:`inline-block whitespace-nowrap file-mention-marquee`,children:r}):(0,X.jsx)(`span`,{className:`block truncate`,children:i})]})]},e.path)}),O&&Z.length===0?(0,X.jsx)(`div`,{className:`flex items-center justify-center py-3`,children:(0,X.jsx)(A,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):null,!O&&Z.length===0&&Y.length===0&&q.length===0&&J.length===0&&(0,X.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:u(`chat.fileMentionAutocomplete.empty`)})]})}),!K&&(0,X.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:u(`chat.autocomplete.keyboardHint`)})]})}),be=new Set([`new`,`fork`,`compact`,`undo`,`redo`,`model`,`goal`]),xe=(e,t)=>{if(!t||e.isSkill)return!1;let n=e.name?.trim().toLowerCase();return!!(n&&be.has(n))},Se=(e,t)=>!e||t({name:e}),Ce=` `,we=(e,t)=>{let n=Math.max(0,Math.min(t,e.length)),r=n;for(;r>0&&!/\s/.test(e[r-1]);)--r;return r>=2&&e[r-1]===Ce&&e[r-2]===`/`&&(r-=2),e[r]===`/`?{start:r,end:n}:null},Te=`text-[10px] leading-none uppercase font-bold tracking-tight px-1.5 py-1 rounded border flex-shrink-0`,Ee=k(Te,`bg-[color-mix(in_srgb,var(--primary-base)_12%,transparent)] text-[color-mix(in_srgb,var(--primary-base)_70%,transparent)] border-[color-mix(in_srgb,var(--primary-base)_24%,transparent)]`),De=k(Te,`bg-[color-mix(in_srgb,var(--status-success)_12%,transparent)] text-[color-mix(in_srgb,var(--status-success)_70%,transparent)] border-[color-mix(in_srgb,var(--status-success)_24%,transparent)]`),Oe=k(Te,`bg-[color-mix(in_srgb,var(--status-info)_12%,transparent)] text-[color-mix(in_srgb,var(--status-info)_70%,transparent)] border-[color-mix(in_srgb,var(--status-info)_24%,transparent)]`),ke=k(Te,`bg-[var(--surface-muted)] text-muted-foreground border-[var(--interactive-border)]/60`),Ae=(e,t)=>{let n=t.trim();if(!n)return[...e].sort((e,t)=>e.isBuiltIn===t.isBuiltIn?e.name.localeCompare(t.name):e.isBuiltIn?-1:1);let r=E(e,n,e=>[e.name,e.description??``]);return r.sort((e,t)=>e.score===t.score?e.item.isBuiltIn===t.item.isBuiltIn?e.item.name.localeCompare(t.item.name):e.item.isBuiltIn?-1:1:e.score-t.score),r.map(e=>e.item)},je=(e,t)=>{let n=!!e.sessionID;return{hasSession:n,canStartSessionCommand:n||e.hasNewDraft,canUseReviewHandoffFlow:n&&!t&&!o()}},Me=I.forwardRef(({searchQuery:e,onCommandSelect:t,onClose:n,directory:r,style:a,commandPolicy:o,commandContext:s},c)=>{let{t:l}=ee(),u=i(e=>e.isMobile),d=D(e=>e.currentSessionId),f=D(e=>!!e.newSessionDraft?.open),p=D(I.useCallback(e=>d?e.getDirectoryForSession(d):void 0,[d])),m=ae(d??``,p??void 0),h=I.useMemo(()=>s??{sessionID:d??null,hasMessages:m.length>0,hasNewDraft:f},[s,d,m.length,f]),{hasSession:g,canStartSessionCommand:_,canUseReviewHandoffFlow:v}=I.useMemo(()=>je(h,u),[h,u]),y=h.hasMessages,[b,x]=I.useState([]),[S,C]=I.useState(!1),ne=se({directory:r}),re=I.useMemo(()=>ne.data??[],[ne.data]),w=ne.isFetching,ie=te({directory:r}),T=I.useMemo(()=>ie.data??[],[ie.data]),[E,oe]=I.useState(0),ce=I.useRef(0),O=I.useRef(!1),le=I.useRef([]),j=I.useRef(null),M=ve(j,u),N=I.useRef(!1),P=I.useRef(null),F=I.useRef(!1);I.useEffect(()=>{let e=e=>{let t=e.target;!t||!j.current||j.current.contains(t)||n()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[n]),I.useEffect(()=>{(async()=>{C(w);try{let t=re.map((e,t)=>({id:`opencode:${e.scope??`global`}:${e.name}:${e.agent??``}:${e.model??``}:${t}`,name:e.name,source:`opencode`,description:e.description,agent:e.agent??void 0,model:e.model??void 0,isBuiltIn:e.isBuiltIn,isSkill:e.source===`skill`,scope:e.scope,reference:e.reference})),n=T.map((e,t)=>({id:`skill:${e.scope}:${e.source??`opencode`}:${e.name}:${t}`,name:e.name,source:`skill`,description:e.description,isSkill:!0,scope:e.scope})),r=[{id:`openchamber:new`,name:`new`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.newDescription`),isBuiltIn:!0},...g&&!y?[{id:`openchamber:init`,name:`init`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.initDescription`),isBuiltIn:!0}]:[],...g?[{id:`openchamber:undo`,name:`undo`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.undoDescription`),isBuiltIn:!0},{id:`openchamber:redo`,name:`redo`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.redoDescription`),isBuiltIn:!0},{id:`openchamber:fork`,name:`fork`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.forkDescription`),isBuiltIn:!0},{id:`openchamber:timeline`,name:`timeline`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.timelineDescription`),isBuiltIn:!0}]:[],{id:`openchamber:model`,name:`model`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.modelDescription`),isBuiltIn:!0},{id:`openchamber:compact`,name:`compact`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.compactDescription`),isBuiltIn:!0},...g?[{id:`openchamber:summary`,name:`summary`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.summaryDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:workspace-review`,name:`workspace-review`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.workspaceReviewDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:handoff-review`,name:`handoff-review`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.handoffReviewDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:plan-feature`,name:`plan-feature`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.featurePlanDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:craft-goal`,name:`craft-goal`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.craftGoalDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:goal`,name:`goal`,source:`openchamber`,description:l(`chat.goal.button.armAria`),isBuiltIn:!0}]:[],..._?[{id:`openchamber:catch-up`,name:`catch-up`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.catchUpDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:debug`,name:`debug`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.debugDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:weigh`,name:`weigh`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.weighDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:explore`,name:`explore`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.exploreDescription`),isOpenChamber:!0}]:[],...t,...n],i=!y,a=r.filter(e=>(i||e.name!==`init`)&&(o?.(e)??!0));x(Ae(a,e))}catch{let t=!y,n=[{id:`openchamber:new`,name:`new`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.newDescription`),isBuiltIn:!0},...g&&!y?[{id:`openchamber:init`,name:`init`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.initDescription`),isBuiltIn:!0}]:[],...g?[{id:`openchamber:undo`,name:`undo`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.undoDescription`),isBuiltIn:!0},{id:`openchamber:redo`,name:`redo`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.redoDescription`),isBuiltIn:!0},{id:`openchamber:fork`,name:`fork`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.forkDescription`),isBuiltIn:!0},{id:`openchamber:timeline`,name:`timeline`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.timelineDescription`),isBuiltIn:!0}]:[],{id:`openchamber:model`,name:`model`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.modelDescription`),isBuiltIn:!0},{id:`openchamber:compact`,name:`compact`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.compactDescription`),isBuiltIn:!0},...g?[{id:`openchamber:summary`,name:`summary`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.summaryDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:workspace-review`,name:`workspace-review`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.workspaceReviewDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:handoff-review`,name:`handoff-review`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.handoffReviewDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:plan-feature`,name:`plan-feature`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.featurePlanDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:craft-goal`,name:`craft-goal`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.craftGoalDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:goal`,name:`goal`,source:`openchamber`,description:l(`chat.goal.button.armAria`),isBuiltIn:!0}]:[],..._?[{id:`openchamber:catch-up`,name:`catch-up`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.catchUpDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:debug`,name:`debug`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.debugDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:weigh`,name:`weigh`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.weighDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:explore`,name:`explore`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.exploreDescription`),isOpenChamber:!0}]:[]].filter(e=>(t||e.name!==`init`)&&(o?.(e)??!0));x(Ae(n,e))}finally{C(!1)}})()},[e,y,g,_,v,re,w,T,l,o]),I.useEffect(()=>{oe(0)},[b]),I.useEffect(()=>{ce.current=E},[E]),I.useEffect(()=>{le.current[E]?.scrollIntoView({block:`nearest`})},[E]),I.useImperativeHandle(c,()=>({handleKeyDown:e=>{let r=b.length;if(e===`Escape`){n();return}if(r!==0){if(e===`ArrowDown`){O.current=!0,oe(e=>(e+1)%r);return}if(e===`ArrowUp`){O.current=!0,oe(e=>(e-1+r)%r);return}if(e===`Enter`||e===`Tab`){let n=(ce.current%r+r)%r,i=b[n];i&&t(i,xe(i,e===`Enter`))}}}}),[b,n,t]);let L=e=>{switch(e.name){case`new`:return(0,X.jsx)(A,{name:`add`,className:`h-3.5 w-3.5`});case`init`:return(0,X.jsx)(A,{name:`file`,className:`h-3.5 w-3.5 text-green-500`});case`undo`:return(0,X.jsx)(A,{name:`arrow-go-back`,className:`h-3.5 w-3.5 text-orange-500`});case`redo`:return(0,X.jsx)(A,{name:`arrow-go-forward`,className:`h-3.5 w-3.5 text-orange-500`});case`timeline`:return(0,X.jsx)(A,{name:`time`,className:`h-3.5 w-3.5`});case`compact`:return(0,X.jsx)(A,{name:`scissors`,className:`h-3.5 w-3.5 text-purple-500`});case`goal`:return(0,X.jsx)(A,{name:`target`,className:`h-3.5 w-3.5`});case`review`:return(0,X.jsx)(A,{name:`search-eye`,className:`h-3.5 w-3.5 text-blue-500`});case`test`:case`build`:case`run`:return(0,X.jsx)(A,{name:`terminal-box`,className:`h-3.5 w-3.5 text-cyan-500`});default:return e.isBuiltIn?(0,X.jsx)(A,{name:`flashlight`,className:`h-3.5 w-3.5 text-yellow-500`}):(0,X.jsx)(A,{name:`command`,className:`h-3.5 w-3.5 text-muted-foreground`})}};return(0,X.jsxs)(`div`,{ref:j,className:`absolute z-[100] min-w-0 w-full max-w-[450px] max-h-64 bg-background border-2 border-border/60 rounded-xl shadow-none bottom-full mb-2 left-0 flex flex-col`,style:M===void 0?a:{...a,maxHeight:M},children:[(0,X.jsx)(ue,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0 pb-2`,children:S?(0,X.jsx)(`div`,{className:`flex items-center justify-center py-4`,children:(0,X.jsx)(A,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):(0,X.jsxs)(`div`,{children:[b.map((e,n)=>{let r=e.isBuiltIn,i=e.isOpenChamber;return(0,X.jsxs)(`div`,{ref:e=>{le.current[n]=e},className:k(`flex gap-2 px-3 py-2 cursor-pointer rounded-lg`,u?`items-center`:`items-start`,n===E&&`bg-interactive-selection`),onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&(P.current={x:e.clientX,y:e.clientY},F.current=!1)},onPointerMove:e=>{if(e.pointerType!==`touch`||!P.current)return;let t=e.clientX-P.current.x,n=e.clientY-P.current.y;Math.hypot(t,n)>6&&(F.current=!0)},onPointerUp:n=>{if(n.pointerType!==`touch`)return;let r=F.current;P.current=null,F.current=!1,!r&&(n.preventDefault(),n.stopPropagation(),N.current=!0,t(e,xe(e,u)))},onPointerCancel:()=>{P.current=null,F.current=!1},onClick:()=>{if(N.current){N.current=!1;return}t(e,xe(e,u))},onMouseMove:()=>{O.current=!1,oe(n)},children:[(0,X.jsx)(`div`,{className:k(!u&&`mt-0.5`),children:L(e)}),(0,X.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsxs)(`span`,{className:`typography-ui-label font-medium`,children:[`/`,e.name]}),e.isSkill?(0,X.jsx)(`span`,{className:Ee,children:l(`chat.commandAutocomplete.badge.skill`)}):(0,X.jsx)(`span`,{className:Ee,children:l(`chat.commandAutocomplete.badge.command`)}),i?(0,X.jsx)(`span`,{className:ke,children:`OpenChamber`}):r?(0,X.jsx)(`span`,{className:ke,children:l(`chat.commandAutocomplete.badge.system`)}):e.scope?(0,X.jsx)(`span`,{className:e.scope===`project`?Oe:De,children:e.scope}):null,e.agent&&(0,X.jsx)(`span`,{className:ke,children:e.agent})]}),e.description&&!u&&(0,X.jsx)(`div`,{className:`typography-meta text-muted-foreground mt-0.5 truncate`,children:e.description})]})]},e.id)}),b.length===0&&(0,X.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:l(`chat.commandAutocomplete.empty`)})]})}),!u&&(0,X.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:l(`chat.autocomplete.keyboardHint`)})]})});Me.displayName=`CommandAutocomplete`;function Ne(e){return(e.description||e.content).replace(/\s+/g,` `).trim().slice(0,120)}var Pe=I.forwardRef((e,t)=>{let n=(0,H.c)(63),{searchQuery:r,onSnippetSelect:a,onClose:o,style:s}=e,{t:c}=ee(),l=I.useRef(null),u=i(Fe),d=ve(l,u),[f,p]=I.useState(0),m=I.useRef(0),h;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(h=[],n[0]=h):h=n[0];let[g,_]=I.useState(h),v;n[1]===Symbol.for(`react.memo_cache_sentinel`)?(v=[],n[1]=v):v=n[1];let y=I.useRef(v),b=N(Ie),x=N(Le),S=N(Re),C=N(ze),te=i(Be),ne=i(Ve),re,w;n[2]===x?(re=n[3],w=n[4]):(re=()=>{x()},w=[x],n[2]=x,n[3]=re,n[4]=w),I.useEffect(re,w);let ie,T;n[5]!==r||n[6]!==b?(ie=()=>{let e=r.trim();if(!e.length){let e=[...b].sort(He);_(e),p(+!!e.length);return}let t=E(b,e,Ue);t.sort(We);let n=t.map(Ge);_(n),p(+!!n.length)},T=[r,b],n[5]=r,n[6]=b,n[7]=ie,n[8]=T):(ie=n[7],T=n[8]),I.useEffect(ie,T);let ae,D;n[9]===f?(ae=n[10],D=n[11]):(ae=()=>{m.current=f,y.current[f]?.scrollIntoView({block:`nearest`})},D=[f],n[9]=f,n[10]=ae,n[11]=D),I.useEffect(ae,D);let oe,se;n[12]===o?(oe=n[13],se=n[14]):(se=()=>{let e=e=>{let t=e.target;t&&l.current&&!l.current.contains(t)&&o()};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},oe=[o],n[12]=o,n[13]=oe,n[14]=se),I.useEffect(se,oe);let ce;n[15]!==a||n[16]!==r?(ce=e=>{let t=r.trim(),n=e.aliases.includes(t)?t:e.name;a(e,n)},n[15]=a,n[16]=r,n[17]=ce):ce=n[17];let O=ce,le;n[18]!==o||n[19]!==C||n[20]!==te||n[21]!==ne||n[22]!==S||n[23]!==b?(le=()=>{let e=new Set(b.map(Ke)),t=`new-snippet`,n=1;for(;e.has(t);)t=`new-snippet-${n++}`;S({name:t,scope:`global`}),C(t),ne(`snippets`),te(!0),o()},n[18]=o,n[19]=C,n[20]=te,n[21]=ne,n[22]=S,n[23]=b,n[24]=le):le=n[24];let j=le,M,P;n[25]!==O||n[26]!==g||n[27]!==o||n[28]!==j?(M=()=>({handleKeyDown:e=>{if(e===`Escape`){o();return}let t=g.length+1;if(e===`ArrowDown`){p(e=>(e+1)%t);return}if(e===`ArrowUp`){p(e=>(e-1+t)%t);return}if(e===`Enter`||e===`Tab`){if(m.current===0){j();return}let e=g[m.current-1];e&&O(e)}}}),P=[O,g,o,j],n[25]=O,n[26]=g,n[27]=o,n[28]=j,n[29]=M,n[30]=P):(M=n[29],P=n[30]),I.useImperativeHandle(t,M,P);let F;n[31]!==d||n[32]!==s?(F=d===void 0?s:{...s,maxHeight:d},n[31]=d,n[32]=s,n[33]=F):F=n[33];let L;n[34]===Symbol.for(`react.memo_cache_sentinel`)?(L=e=>{y.current[0]=e},n[34]=L):L=n[34];let R=f===0&&`bg-interactive-selection`,z;n[35]===R?z=n[36]:(z=k(`flex items-center gap-2 px-3 py-1.5 cursor-pointer rounded-lg typography-ui-label`,R),n[35]=R,n[36]=z);let de,B;n[37]===Symbol.for(`react.memo_cache_sentinel`)?(de=()=>p(0),B=(0,X.jsx)(A,{name:`add`,className:`h-3.5 w-3.5 text-muted-foreground`}),n[37]=de,n[38]=B):(de=n[37],B=n[38]);let V;n[39]===c?V=n[40]:(V=c(`chat.snippetAutocomplete.action.addNew`),n[39]=c,n[40]=V);let fe;n[41]===V?fe=n[42]:(fe=(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:V}),n[41]=V,n[42]=fe);let pe;n[43]!==j||n[44]!==z||n[45]!==fe?(pe=(0,X.jsxs)(`div`,{ref:L,className:z,onClick:j,onMouseMove:de,children:[B,fe]}),n[43]=j,n[44]=z,n[45]=fe,n[46]=pe):pe=n[46];let me;n[47]!==O||n[48]!==g||n[49]!==u||n[50]!==f||n[51]!==c?(me=g.length?g.map((e,t)=>(0,X.jsx)(`div`,{ref:e=>{y.current[t+1]=e},className:k(`flex gap-2 px-3 py-1.5 cursor-pointer rounded-lg typography-ui-label`,u?`items-center`:`items-start`,t+1===f&&`bg-interactive-selection`),onClick:()=>O(e),onMouseMove:()=>p(t+1),children:(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsxs)(`span`,{className:`font-semibold truncate`,children:[`#`,e.name]}),(0,X.jsx)(`span`,{className:`text-[10px] leading-none uppercase font-bold tracking-tight px-1.5 py-1 rounded border flex-shrink-0 bg-[var(--surface-muted)] text-muted-foreground border-[var(--interactive-border)]/60`,children:c(`snippets.source.${e.source}`)})]}),!u&&(0,X.jsx)(`div`,{className:`typography-meta text-muted-foreground mt-0.5 truncate`,children:Ne(e)})]})},`${e.source}:${e.filePath}`)):(0,X.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:c(`chat.snippetAutocomplete.empty`)}),n[47]=O,n[48]=g,n[49]=u,n[50]=f,n[51]=c,n[52]=me):me=n[52];let U;n[53]!==pe||n[54]!==me?(U=(0,X.jsxs)(ue,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0 pb-2`,children:[pe,me]}),n[53]=pe,n[54]=me,n[55]=U):U=n[55];let W;n[56]!==u||n[57]!==c?(W=!u&&(0,X.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:c(`chat.snippetAutocomplete.footer`)}),n[56]=u,n[57]=c,n[58]=W):W=n[58];let G;return n[59]!==F||n[60]!==U||n[61]!==W?(G=(0,X.jsxs)(`div`,{ref:l,className:`absolute z-[100] min-w-0 w-full max-w-[450px] max-h-60 bg-background border-2 border-border/60 rounded-xl shadow-none bottom-full mb-2 left-0 flex flex-col`,style:F,children:[U,W]}),n[59]=F,n[60]=U,n[61]=W,n[62]=G):G=n[62],G});Pe.displayName=`SnippetAutocomplete`;function Fe(e){return e.isMobile}function Ie(e){return e.snippets}function Le(e){return e.loadSnippets}function Re(e){return e.setSnippetDraft}function ze(e){return e.setSelectedSnippet}function Be(e){return e.setSettingsDialogOpen}function Ve(e){return e.setSettingsPage}function He(e,t){return e.source===`project`&&t.source!==`project`?-1:e.source!==`project`&&t.source===`project`?1:e.name.localeCompare(t.name)}function Ue(e){return[e.name,...e.aliases]}function We(e,t){return e.score===t.score?e.item.source===`project`&&t.item.source!==`project`?-1:e.item.source!==`project`&&t.item.source===`project`?1:e.item.name.localeCompare(t.item.name):e.score-t.score}function Ge(e){return e.item}function Ke(e){return e.name}var qe=2,Je=e=>!!e&&typeof e==`object`&&!Array.isArray(e),Ye=e=>{let t=e?.trim().replace(/\\/g,`/`);return t?t.length>1?t.replace(/\/+$/,``):t:null},Xe=e=>Je(e)&&Array.isArray(e.all)&&e.all.every(e=>typeof e==`string`)&&typeof e.current==`string`&&Je(e.branches),Ze=(e,t)=>JSON.stringify([e,t]),Qe=e=>`version`in e&&e.version===qe&&Je(e.entries),$e=e=>{if(!e)return null;try{let t=JSON.parse(e);return Je(t)?t.version===qe&&Je(t.entries)?{version:qe,entries:t.entries}:t:null}catch{return null}},et=(e,t)=>{try{e.setItem(`oc.gitBranchCache`,JSON.stringify(t))}catch{}},tt=(e,t,n)=>{let r=Ye(e);if(!r||!t)return null;let i;try{i=n.getItem(`oc.gitBranchCache`)}catch{return null}let a=$e(i);if(!a)return null;if(Qe(a))return Xe(a.entries[Ze(t,r)])?a.entries[Ze(t,r)]:null;let o={};for(let[e,n]of Object.entries(a)){let r=Ye(e);r&&Xe(n)&&(o[Ze(t,r)]=n)}return et(n,{version:qe,entries:o}),o[Ze(t,r)]??null},nt=(e,t,n,r)=>{let i=Ye(e);if(!i||!t||!Xe(n))return;let a=null;try{a=r.getItem(`oc.gitBranchCache`)}catch{return}let o=$e(a);et(r,{version:qe,entries:{...o&&Qe(o)?o.entries:{},[Ze(t,i)]:n}})},rt=3e4,it=Ye,at=(e,t=n())=>c.git.branches(it(e),t),ot=(e,t=n())=>c.git.remotes(it(e),t),st=async(e,t,n)=>{n.throwIfAborted();let r=d()?.git,i=t?.getGitBranches?await t.getGitBranches(e,{signal:n}):r?await r.getGitBranches(e,{signal:n}):await y(e,{signal:n});return n.throwIfAborted(),i},ct=async(e,t,n)=>{n.throwIfAborted();let r=d()?.git,i=t?.getRemotes?await t.getRemotes(e,{signal:n}):r?await r.getRemotes(e,{signal:n}):await _(e,{signal:n});return n.throwIfAborted(),i},lt=(e,t,i=n(),a=r())=>{let o=it(e),s=t;return{queryKey:at(o,i),queryFn:async({signal:e})=>{if(!o)throw Error(`Git branches require a directory`);let t=await st(o,s,e);return nt(o,i,t,a),t},staleTime:rt,gcTime:1/0,initialData:()=>tt(o,i,a)??void 0,initialDataUpdatedAt:0}},ut=(e,t,r=n())=>{let i=it(e),a=t;return{queryKey:ot(i,r),queryFn:({signal:e})=>{if(!i)throw Error(`Git remotes require a directory`);return ct(i,a,e)},staleTime:rt,gcTime:1/0}},dt=(e,r,i)=>{let a=(0,H.c)(9),o=i===void 0||i,s=I.useSyncExternalStore(t,n,n),c,l,u;a[0]!==e||a[1]!==r||a[2]!==s?(c=it(e),u=S,l=lt(c,r,s),a[0]=e,a[1]=r,a[2]=s,a[3]=c,a[4]=l,a[5]=u):(c=a[3],l=a[4],u=a[5]);let d=o&&!!c,f;return a[6]!==l||a[7]!==d?(f={...l,enabled:d},a[6]=l,a[7]=d,a[8]=f):f=a[8],u(f)},ft=(e,r,i)=>{let a=(0,H.c)(9),o=i===void 0||i,s=I.useSyncExternalStore(t,n,n),c,l,u;a[0]!==e||a[1]!==r||a[2]!==s?(c=it(e),u=S,l=ut(c,r,s),a[0]=e,a[1]=r,a[2]=s,a[3]=c,a[4]=l,a[5]=u):(c=a[3],l=a[4],u=a[5]);let d=o&&!!c,f;return a[6]!==l||a[7]!==d?(f={...l,enabled:d},a[6]=l,a[7]=d,a[8]=f):f=a[8],u(f)},pt=(e,t,r=u,i=n())=>r.fetchQuery(lt(e,t,i)),mt=(e,t,r=u,i=n())=>r.fetchQuery({...lt(e,t,i),staleTime:0}),ht=e=>e instanceof Error?e.name===`AbortError`||e.name===`CancelledError`||e.name===`Error`&&e.message===`CancelledError`:!1,gt=1e4,_t=6e4,vt=5e3,yt=3e4,bt=6e4,xt=25,St=40,Ct=2,wt=15e3,Tt=500,Et=30,Dt=20971520,Ot=new Map,kt=new Map,At=new Map,jt=new Map,Mt=new Map,Nt=(e,t)=>`${t}:${e}`,Pt=e=>kt.get(e)??0,Ft=e=>{let t=Pt(e)+1;return kt.set(e,t),t},It=e=>{let t=(At.get(e)??0)+1;return At.set(e,t),t},Lt=e=>{let t=Ot.get(e);if(t)return t;let n=new Set;return Ot.set(e,n),n},Q=()=>({isGitRepo:null,status:null,branches:null,branchesTransportIdentity:null,log:null,identity:null,diffCache:new Map,indexRevision:0,lastRepoCheckAt:0,lastStatusFetch:0,lastStatusChange:0,lastLogFetch:0,lastBranchesFetch:0,lastIdentityFetch:0,logMaxCount:25,isLoadingStatus:!1,isLoadingLog:!1,isLoadingBranches:!1,isLoadingIdentity:!1}),Rt=(e,t=Et,n=Dt)=>{let r=0;for(let t of e.values())r+=(t.original?.length??0)+(t.modified?.length??0);if(e.size<=t&&r<=n)return e;let i=Array.from(e.entries()).sort((e,t)=>e[1].fetchedAt-t[1].fetchedAt),a=new Map,o=0;for(let e=i.length-1;e>=0;e--){let[r,s]=i[e],c=(s.original?.length??0)+(s.modified?.length??0);if(a.size>=t)break;o+c>n&&a.size>0||(a.set(r,s),o+=c)}return a},zt=(e,t)=>{if(!e&&!t)return!1;if(!e||!t)return!0;let n=new Set([...Object.keys(e),...Object.keys(t)]);for(let r of n){let n=e[r],i=t[r];if(!(!n&&!i)&&(!n||!i||n.insertions!==i.insertions||n.deletions!==i.deletions))return!0}return!1},Bt=(e,t)=>!e&&!t?!1:!e||!t||e.remote!==t.remote||e.branch!==t.branch||e.ahead!==t.ahead||e.behind!==t.behind,Vt=(e,t)=>{if(!e&&!t)return!1;if(!e||!t)return!0;let n=e.files??[],r=t.files??[];if(n.length!==r.length||e.ahead!==t.ahead||e.behind!==t.behind||e.current!==t.current||e.tracking!==t.tracking||e.isClean!==t.isClean||t.upstreamComparison!==void 0&&Bt(e.upstreamComparison,t.upstreamComparison))return!0;let i=new Set(n.map(e=>`${e.path}:${e.index}:${e.working_dir}`));for(let e of r)if(!i.has(`${e.path}:${e.index}:${e.working_dir}`))return!0;return!!(t.diffStats!==void 0&&zt(e.diffStats,t.diffStats))},Ht=(e,t)=>{let n=new Set;if(!t)return n;let r=e?.files??[],i=t.files??[],a=new Map(r.map(e=>[e.path,e])),o=new Map(i.map(e=>[e.path,e])),s=new Set([...a.keys(),...o.keys()]);for(let e of s){let t=a.get(e),r=o.get(e);if(!t||!r){n.add(e);continue}if(t.index!==r.index||t.working_dir!==r.working_dir){n.add(e);continue}}if(t.diffStats!==void 0){let r=e?.diffStats??{},i=t.diffStats??{},a=new Set([...Object.keys(r),...Object.keys(i)]);for(let e of a){let t=r[e],a=i[e];if(!t||!a){n.add(e);continue}(t.insertions!==a.insertions||t.deletions!==a.deletions)&&n.add(e)}}return n},Ut=(e,t)=>{if(!e&&!t)return!1;if(!e||!t)return!0;let n=e.files??[],r=t.files??[],i=e=>{let t=e?.trim()??``;return t===`?`?``:t},a=new Map(n.map(e=>[e.path,i(e.index)])),o=new Map(r.map(e=>[e.path,i(e.index)])),s=new Set([...a.keys(),...o.keys()]);for(let e of s)if((a.get(e)??``)!==(o.get(e)??``))return!0;return!1},Wt=e=>!e||e.trim().length===0,Gt=e=>(e||``).trim()===`U`,Kt=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(Gt(t)||Gt(n))return e;let r=t===`?`||n===`?`?`A`:t||n||` `;return{...e,index:r,working_dir:` `}},qt=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(Gt(t)||Gt(n))return e;let r=n||(t===`A`||t===`?`?`?`:t)||` `;return{...e,index:` `,working_dir:r}},Jt=e=>Wt(e.index)&&Wt(e.working_dir),$=f()(m((e,t)=>({directories:new Map,activeDirectory:null,setActiveDirectory:n=>{let{activeDirectory:r,directories:i}=t();if(r!==n)if(r&&Ft(r),n&&Ft(n),n&&!i.has(n)){let t=new Map(i);t.set(n,Q()),e({activeDirectory:n,directories:t})}else e({activeDirectory:n})},getDirectoryState:e=>t().directories.get(e)??null,fetchStatus:async(n,r,i={})=>{let a=i.mode??`full`,o=Nt(n,a),s=jt.get(o)??(a===`light`?jt.get(Nt(n,`full`)):void 0);if(s)return s;let c=(async()=>{let{silent:a=!1}=i,{directories:o}=t(),s=o.get(n);if(s||=Q(),!a){let r=new Map(t().directories),i=r.get(n)??Q();r.set(n,{...i,isLoadingStatus:!0}),e({directories:r})}let c=!1;try{let a=Date.now(),o=s.isGitRepo!==!0||a-(s.lastRepoCheckAt||0)>_t,l=s.isGitRepo===!0;if(o&&(l=await r.checkIsGitRepository(n)),!l){let r=new Map(t().directories),i=r.get(n)??s;return r.set(n,{...i,isGitRepo:!1,status:null,isLoadingStatus:!1,lastRepoCheckAt:a,lastStatusFetch:a}),e({directories:r}),!1}let u=await r.getGitStatus(n,i.mode?{mode:i.mode}:void 0);if(Vt(s.status,u)){c=!0;let r=new Map(t().directories),i=r.get(n)??Q(),s=Ht(i.status,u),l=Ut(i.status,u),d=new Set((i.status?.files??[]).map(e=>e.path)),f=new Set((u.files??[]).map(e=>e.path)),p=new Map(i.diffCache);for(let e of d)f.has(e)||p.delete(e);for(let e of s)p.delete(e);let m=s.size>0;m&&Ft(n);let h={...u,diffStats:u.diffStats===void 0&&i.status?.diffStats!==void 0?i.status.diffStats:u.diffStats,upstreamComparison:u.upstreamComparison===void 0?i.status?.upstreamComparison:u.upstreamComparison};r.set(n,{...i,isGitRepo:!0,status:h,diffCache:p,indexRevision:l?i.indexRevision+1:i.indexRevision,lastRepoCheckAt:o?a:i.lastRepoCheckAt,lastStatusFetch:Date.now(),lastStatusChange:m?Date.now():i.lastStatusChange}),e({directories:r})}else{let r=new Map(t().directories),i=r.get(n)??Q();r.set(n,{...i,isGitRepo:!0,lastRepoCheckAt:o?a:i.lastRepoCheckAt,lastStatusFetch:Date.now(),lastStatusChange:i.lastStatusChange}),e({directories:r})}}catch(e){console.error(`Failed to fetch git status:`,e)}finally{if(!a){let r=new Map(t().directories),i=r.get(n)??Q();r.set(n,{...i,isLoadingStatus:!1}),e({directories:r})}}return c})();jt.set(o,c);try{return await c}finally{jt.get(o)===c&&jt.delete(o)}},moveStatusPathsOptimistically:(n,r,i)=>{let a=new Set(r.map(e=>e.trim()).filter(Boolean));if(a.size===0)return null;let{directories:o}=t(),s=o.get(n),c=s?.status??null;if(!s||!c)return c;let l=!1,u=[];for(let e of c.files){if(!a.has(e.path)){u.push(e);continue}let t=i===`stage`?Kt(e):qt(e);t!==e&&(l=!0),Jt(t)?l=!0:u.push(t)}if(!l)return c;let d=new Map(o);return d.set(n,{...s,status:{...c,files:u,isClean:u.length===0},indexRevision:s.indexRevision+1,lastStatusChange:Date.now()}),e({directories:d}),c},restoreStatus:(n,r)=>{let{directories:i}=t(),a=i.get(n);if(!a)return;let o=new Map(i);o.set(n,{...a,status:r,indexRevision:a.indexRevision+1,lastStatusChange:Date.now()}),e({directories:o})},bumpIndexRevision:n=>{let{directories:r}=t(),i=r.get(n);if(!i)return;let a=new Map(r);a.set(n,{...i,indexRevision:i.indexRevision+1}),e({directories:a})},fetchBranches:async(r,i,a={})=>{let o=n(),s=It(r);{let n=new Map(t().directories),i=n.get(r)??Q();n.set(r,{...i,isLoadingBranches:!0}),e({directories:n})}try{let c=a.force?await mt(r,i,void 0,o):await pt(r,i,void 0,o);if(s!==At.get(r)||o!==n())return;let l=new Map(t().directories),u=l.get(r)??Q();l.set(r,{...u,branches:c,branchesTransportIdentity:o,isLoadingBranches:!1,lastBranchesFetch:Date.now()}),e({directories:l})}catch(i){if(ht(i)||console.error(`Failed to fetch git branches:`,i),s!==At.get(r)||o!==n())return;let a=new Map(t().directories),c=a.get(r)??Q();a.set(r,{...c,isLoadingBranches:!1}),e({directories:a})}},fetchLog:async(n,r,i)=>{let{directories:a}=t(),o=a.get(n),s=i??o?.logMaxCount??25;{let r=new Map(t().directories),i=r.get(n)??Q();r.set(n,{...i,isLoadingLog:!0}),e({directories:r})}try{let i=await r.getGitLog(n,{maxCount:s}),a=new Map(t().directories),o=a.get(n)??Q();a.set(n,{...o,log:i,isLoadingLog:!1,lastLogFetch:Date.now(),logMaxCount:s}),e({directories:a})}catch(r){console.error(`Failed to fetch git log:`,r);let i=new Map(t().directories),a=i.get(n)??Q();i.set(n,{...a,isLoadingLog:!1}),e({directories:i})}},fetchIdentity:async(n,r)=>{{let r=new Map(t().directories),i=r.get(n)??Q();r.set(n,{...i,isLoadingIdentity:!0}),e({directories:r})}try{let i=await r.getCurrentGitIdentity(n),a=new Map(t().directories),o=a.get(n)??Q();a.set(n,{...o,identity:i,isLoadingIdentity:!1,lastIdentityFetch:Date.now()}),e({directories:a})}catch(r){console.error(`Failed to fetch git identity:`,r);let i=new Map(t().directories),a=i.get(n)??Q();i.set(n,{...a,isLoadingIdentity:!1}),e({directories:i})}},fetchAll:async(n,r,i={})=>{let{directories:a}=t(),o=a.get(n);if(!o){o=Q();let t=new Map(a);t.set(n,o),e({directories:t})}let{force:s=!1,silentIfCached:c=!1}=i,l=Date.now();await t().fetchStatus(n,r,{silent:c&&!!o?.status});let u=t().directories.get(n);if(!u?.isGitRepo)return;await t().fetchBranches(n,r,{force:s});let d=l-(u.lastLogFetch||0);(s||d>gt||!u.log)&&await t().fetchLog(n,r),await t().fetchIdentity(n,r)},getDiff:(e,n)=>t().directories.get(e)?.diffCache.get(n)??null,setDiff:(n,r,i)=>{let a=new Map(t().directories),o=a.get(n)??Q(),s=new Map(o.diffCache);s.set(r,{...i,fetchedAt:Date.now()});let c=Rt(s);a.set(n,{...o,diffCache:c}),e({directories:a})},clearDiffCache:n=>{Ft(n);let r=new Map(t().directories),i=r.get(n);i&&(r.set(n,{...i,diffCache:new Map}),e({directories:r}))},fetchAllDiffs:async(e,n)=>{let r=t().directories.get(e);if(!r?.status?.files||r.status.files.length===0)return;let i=r.status.files.map(e=>e.path).slice(0,xt);await t().prefetchDiffs(e,n,i,{maxFiles:xt})},prefetchDiffs:async(n,r,i,a={})=>{let o=t().directories.get(n);if(!o?.status?.files||o.status.files.length===0||i.length===0)return;let{maxFiles:s=St}=a,c=new Set(o.status.files.map(e=>e.path)),l=o.status.diffStats,u=Lt(n),d=[],f=new Set;for(let e of i){if(!e||f.has(e)||(f.add(e),!c.has(e))||o.diffCache.has(e)||u.has(e))continue;let t=l?.[e];t&&t.insertions+t.deletions>Tt||d.push(e)}let p=d.slice(0,Math.max(1,s));if(p.length===0)return;let m=Pt(n);if(typeof document<`u`&&document.hidden)return;p.forEach(e=>u.add(e));let h=0,g=[],_=()=>{let e=h;return h+=1,e<p.length?p[e]:null},v=async e=>{let t=r.getGitFileDiff(n,{path:e}),i=new Promise((e,t)=>{setTimeout(()=>t(Error(`Timed out after ${wt}ms`)),wt)}),a=await Promise.race([t,i]);return{path:e,diff:{original:a.original??``,modified:a.modified??``,isBinary:a.isBinary}}},y=async()=>{for(;;){if(m!==Pt(n))return;let e=_();if(!e)return;try{g.push(await v(e))}catch{}finally{u.delete(e)}}},b=Math.min(Ct,p.length);if(await Promise.allSettled(Array.from({length:b},()=>y())),p.forEach(e=>u.delete(e)),m!==Pt(n))return;let x=new Map(t().directories),S=x.get(n);if(!S)return;let C=new Map(S.diffCache),ee=Date.now();g.forEach(e=>{C.set(e.path,{...e.diff,fetchedAt:ee})});let te=Rt(C);x.set(n,{...S,diffCache:te}),e({directories:x})},setLogMaxCount:(n,r)=>{let i=new Map(t().directories),a=i.get(n)??Q();i.set(n,{...a,logMaxCount:r}),e({directories:i})},ensureStatus:async(e,n)=>{let r=t().directories.get(e),i=Date.now();r?.status&&i-r.lastStatusFetch<vt||await t().fetchStatus(e,n,{silent:!!r?.status})},ensureAll:(e,n)=>{let r=Mt.get(e);if(r)return r;let i=(async()=>{let r=t().directories.get(e),i=Date.now();(!r?.status||r.status.diffStats===void 0||i-(r?.lastStatusFetch??0)>=vt)&&await t().fetchStatus(e,n,{silent:!!r?.status});let a=t().directories.get(e);if(!a?.isGitRepo)return;let o=[];(!a.branches||i-a.lastBranchesFetch>=yt)&&o.push(t().fetchBranches(e,n)),(!a.log||i-a.lastLogFetch>=gt)&&o.push(t().fetchLog(e,n)),(!a.identity||i-a.lastIdentityFetch>=bt)&&o.push(t().fetchIdentity(e,n)),o.length>0&&await Promise.all(o)})();return Mt.set(e,i),i.finally(()=>{Mt.get(e)===i&&Mt.delete(e)}),i},refresh:async(e,n={})=>{let{activeDirectory:r}=t();r&&await t().fetchAll(r,e,n)}}),{name:`git-store`})),Yt=e=>{let t=(0,H.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.status??null:null,t[0]=e,t[1]=n),$(n)},Xt=e=>{let r=(0,H.c)(3),i=I.useSyncExternalStore(t,n,n),a;return r[0]!==e||r[1]!==i?(a=t=>{if(!e)return null;let n=t.directories.get(e);return n?.branchesTransportIdentity===i?n.branches:null},r[0]=e,r[1]=i,r[2]=a):a=r[2],$(a)},Zt=e=>{let t=(0,H.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.log??null:null,t[0]=e,t[1]=n),$(n)},Qt=e=>{let t=(0,H.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isGitRepo??null:null,t[0]=e,t[1]=n),$(n)},$t=e=>{let t=(0,H.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.status?.current?.trim()??null:null,t[0]=e,t[1]=n),$(n)},en={current:new Map},tn=()=>$(sn),nn=e=>{let t=(0,H.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=new Map,t[0]=n):n=t[0];let r=I.useRef(n),i;return t[1]===e?i=t[2]:(i=t=>{let n=r.current,i=n.size===e.length;if(i)for(let r of e){let e=t.directories.get(r),a=n.get(r);if(!a||(e?.isGitRepo??null)!==a.isGitRepo||(e?.status?.current??null)!==a.branch){i=!1;break}}if(i)return n;let a=new Map;for(let n of e){let e=t.directories.get(n);a.set(n,{isGitRepo:e?.isGitRepo??null,branch:e?.status?.current??null})}return r.current=a,a},t[1]=e,t[2]=i),$(i)},rn=e=>{let t=(0,H.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isLoadingStatus??!1:!1,t[0]=e,t[1]=n),$(n)},an=e=>{let t=(0,H.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isLoadingLog??!1:!1,t[0]=e,t[1]=n),$(n)},on=e=>{let t=(0,H.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isLoadingBranches??!1:!1,t[0]=e,t[1]=n),$(n)};function sn(e){let t=en.current,n=t.size===e.directories.size;if(n){for(let[r,i]of e.directories)if(t.get(r)!==(i.status?.current??null)){n=!1;break}}if(n)return t;let r=new Map;for(let[t,n]of e.directories)r.set(t,n.status?.current??null);return en.current=r,r}var cn=e=>{let t=String(e||``).trim().replace(/^remotes\//,``);if(!t)return null;let n=t.indexOf(`/`);return n<=0||n>=t.length-1?null:{remote:t.slice(0,n),branch:t.slice(n+1)}},ln=e=>String(e||``).trim().replace(/^refs\/heads\//,``).replace(/^heads\//,``).replace(/^remotes\//,``),un=e=>e.branchName?ln(e.branchName):e.mode===`existing`?ln(e.existingBranch||e.preferredName||``):ln(e.preferredName||``),dn=async e=>{let t=await P(e);try{let n=cn((await j(e)).branches?.[t]?.tracking||null);if(n?.remote)return n.remote}catch{}try{let t=cn((await M(e)).tracking);if(t?.remote)return t.remote}catch{}return null},fn=async(e,t)=>{let n=await dn(e),r=ln(t);return!n||!r?null:{setUpstream:!0,upstreamRemote:n,upstreamBranch:r}},pn=async(e,t,n)=>{let r=un(t),i=n?.resolvedRootTrackingRemote,a=i===void 0?await fn(e,r):i&&ln(r)?{setUpstream:!0,upstreamRemote:i,upstreamBranch:ln(r)}:null;return a?{...t,setUpstream:t.setUpstream??a.setUpstream,upstreamRemote:t.upstreamRemote||a.upstreamRemote,upstreamBranch:t.upstreamBranch||a.upstreamBranch}:t},mn=async(e,t,n)=>{let r=await pn(e.path,t,n);return F(e,r)},hn=`oc:lastWorktreeSourceBranch`,gn=({mode:e,sourceBranch:t,linkedPr:n,selectedBranch:r})=>e===`existing-branch`?r||null:n?null:t||null,_n=({branches:e,savedSourceBranch:t,rootBranch:n})=>t&&e.includes(t)&&t?{sourceBranch:t,shouldClearSavedSourceBranch:!1}:{sourceBranch:n&&e.includes(n)?n:e.includes(`main`)?`main`:e.includes(`master`)?`master`:e[0]??``,shouldClearSavedSourceBranch:!!t},vn=(e,t,n)=>{if(!e)return e;let r=t.length>0&&!/\s$/.test(t)&&!/^\s/.test(e)&&!/[([{]$/.test(t),i=n.length>0&&!/\s$/.test(e)&&!/^\s/.test(n)&&!/^[\])}.,;:!?]/.test(n);return`${r?` `:``}${e}${i?` `:``}`},yn=(e,t,n)=>{let r=vn(e,t,n);return`${t.length===0&&!/^\s/.test(r)?` `:``}${r}${n.length===0&&!/\s$/.test(r)?` `:``}`},bn=(e,t,n,r)=>{let i=e.slice(0,t),a=e.slice(n),o=yn(r,i,a),s=Math.max(0,o.indexOf(r)),c=i.length+s;return{text:`${i}${o}${a}`,caret:i.length+o.length,start:c,end:c+r.length}},xn=(e,t)=>{let n=e=>`${e.kind}:${e.value}:${e.range.start}:${e.range.end}`;return new Set(e.map(n)).has(n(t))?[...e]:[...e,t]},Sn=(e,t)=>t<e.length&&e[t]===` `?t+1:t;export{ve as A,dt as C,we as D,Me as E,pe as M,fe as N,Se as O,mt as S,Pe as T,Zt as _,hn as a,$ as b,mn as c,tn as d,$t as f,rn as g,an as h,yn as i,me as j,Z as k,dn as l,on as m,xn as n,_n as o,Xt as p,bn as r,gn as s,Sn as t,pn as u,nn as v,ft as w,Qt as x,Yt as y};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-workbox-window-qnW0Nbv7.js","assets/rolldown-runtime-C0FnF6B9.js","assets/renderMobileApp-bklJJSZi.js","assets/useUIStore-D6BTB4va.js","assets/vendor-zustand-B4dlGEM2.js","assets/vendor-base-ui-CnHfUmDN.js","assets/persistence-C_KCiMcY.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-react-DLPElpoQ.js","assets/vendor-tanstack-query-core-BWz0ose6.js","assets/gitApiHttp-C1DaEMKR.js","assets/vendor-opencode-sdk-C07HQypa.js","assets/vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js","assets/vendor-sonner-DVzioF3d.js","assets/vendor-reactuses-core-DDoDDyM9.js","assets/vendor-lodash-es-DfLbG5Af.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/clipboard-CXWbHCAk.js","assets/store-oojlrF4d.js","assets/useMobileNavigationStore-DhkIZBJw.js","assets/vendor-tanstack-react-query-D7pys_c9.js","assets/useAssistantUIStore-ESTV1mEY.js","assets/vendor-fuse.js-DB5wDJbI.js","assets/MobileShareBridge-BL7Ehxhd.js","assets/MobileDetailNavigation-5tAL5d_M.js","assets/utils-DyUyiLje.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/Icon-BPJ_quEe.js","assets/button-BmNJBT13.js","assets/AgentAvatar-C6Hxu5_o.js","assets/dialog-BV1ENlLf.js","assets/gitApi-BW5AFgD1.js","assets/useAppFontEffects-B1EhZNex.js","assets/desktopHosts-BpjUSDz4.js","assets/vendor-simplewebauthn-browser-Dwhcdg_5.js","assets/projectMeta-1SSTNg8w.js","assets/input-BLVhPvhN.js","assets/tooltip-BYGBBTc2.js","assets/OverlayScrollbar-C2pEDFq-.js","assets/vendor-dnd-kit-core-CvWxUPdb.js","assets/vendor-dnd-kit-accessibility-BY5LhhUB.js","assets/vendor-dnd-kit-sortable-hHdP9lLb.js","assets/useSessionAutoCleanup-D-r9oDye.js","assets/desktopRelayRestore-BzUEk1i7.js","assets/radio-DBJG9Dd1.js","assets/vendor-codemirror-autocomplete-DHomsvW7.js","assets/vendor-codemirror-lang-angular-DShkBD6m.js","assets/vendor-codemirror-lang-json-CYJRHck9.js","assets/vendor-codemirror-lang-markdown-WORgx6ZD.js","assets/vendor-codemirror-lang-python-Du6XQ8Zw.js","assets/vendor-codemirror-legacy-modes-DuRAjNvB.js","assets/useThemeSystem-DMzWVJaW.js","assets/vendor-codemirror-language-data-BfYFhIH1.js","assets/markdownTheme-CCnvI6L0.js","assets/vendor-pierre-diffs-BenIz2TM.js","assets/vendor-hast-util-to-html-B0p1k5Xa.js","assets/vendor-character-entities-legacy-Wut6vMuj.js","assets/vendor-character-entities-html4-DlN_yAFd.js","assets/vendor-ccount-CyGsA0u7.js","assets/vendor-comma-separated-tokens-B9ouxNNS.js","assets/vendor-oniguruma-to-es-CrHzjjSU.js","assets/vendor-oniguruma-parser-D2DIvhSP.js","assets/vendor-diff-Dq7CZNim.js","assets/vendor-lru_map-DpDied8H.js","assets/ChatContainer-BXFy3Uu2.js","assets/useRuntimeAPIs-DSLXJybW.js","assets/appThemeRegistry-DAgBeFsZ.js","assets/markdown-worker-Cq3Twp1A.js","assets/url-CGHw6D-E.js","assets/useEffectiveDirectory-dCGvvYRh.js","assets/FadeInOnReveal-CvNA_aGD.js","assets/insertionBoundaries-D4KbXFFj.js","assets/useWorkerHighlightedLines-05dLFgTI.js","assets/vendor-tanstack-react-virtual-tlDgH6PG.js","assets/vendor-cmdk-CeAGfrLo.js","assets/vendor-aria-hidden-BbL3cEyI.js","assets/sortable-tabs-strip-DncWjNx4.js","assets/vendor-framer-motion-DFy_BSVd.js","assets/useFontPreferences-Bu4ME5hk.js","assets/terminalApi-BYTA045F.js","assets/MobileSurface-ByMnQ5rD.js","assets/collapsible-68IqWBM1.js","assets/vendor-codemirror-commands-C9DCaJ0C.js","assets/vendor-codemirror-search-D2SOgzph.js","assets/vendor-replit-codemirror-vim-CEibx3EP.js","assets/projectActions-CWvNGKfA.js","assets/runtimeEndpointReset-ix1NxqYw.js","assets/context-menu-BXH0AcOc.js","assets/vendor-cron-parser-CCD11YFT.js","assets/SettingsView-D0p-e8Px.js","assets/vendor-yaml-DIcAK3EC.js","assets/vendor-qrcode-DAuVxiQR.js","assets/vendor-dijkstrajs-DztKuCwY.js","assets/AssistantView-ZlXc0xFT.js","assets/fileQueries-i4oziMnC.js","assets/src-B8mzksNL.css","assets/main-DzxdsF_k.js","assets/useDesktopWindowControlsLayout-Dc69l-pm.js","assets/diagram-YN0GZ1Q0.js","assets/vendor-react-drawio-ECtEwvbc.js","assets/multirun-qs5hZkwM.js","assets/vendor-zumer-snapdom-yq9vlCKr.js","assets/vendor-html-to-image-BDMm2v6d.js","assets/main-qSeeJRW1.css"])))=>i.map(i=>d[i]);
2
- import{n as e,t}from"./runtimeConfig-JSaYFA5x.js";import{o as n}from"./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js";/* empty css */var r=`true`,i=`false`,a=r===`true`,o=i===`true`;function s(e={}){let{immediate:t=!1,onNeedReload:r,onNeedRefresh:i,onOfflineReady:s,onRegistered:c,onRegisteredSW:l,onRegisterError:u}=e,d,f,p,m=async(e=!0)=>{await f,a||p?.()};async function h(){if(`serviceWorker`in navigator){if(d=await n(async()=>{let{Workbox:e}=await import(`./vendor-workbox-window-qnW0Nbv7.js`).then(e=>e.t);return{Workbox:e}},__vite__mapDeps([0,1])).then(({Workbox:e})=>new e(`/sw.js`,{scope:`/`,type:`classic`})).catch(e=>{u?.(e)}),!d)return;if(p=()=>{d?.messageSkipWaiting()},!o)if(a)d.addEventListener(`activated`,e=>{(e.isUpdate||e.isExternal)&&(r?r():window.location.reload())}),d.addEventListener(`installed`,e=>{e.isUpdate||s?.()});else{let e=!1,t=()=>{e=!0,d?.addEventListener(`controlling`,e=>{e.isUpdate&&(r?r():window.location.reload())}),i?.()};d.addEventListener(`installed`,n=>{n.isUpdate===void 0?n.isExternal===void 0?!e&&s?.():n.isExternal?t():!e&&s?.():n.isUpdate||s?.()}),d.addEventListener(`waiting`,t)}d.register({immediate:t}).then(e=>{l?l(`/sw.js`,e):c?.(e)}).catch(e=>{u?.(e)})}}return f=h(),m}window.__OPENCHAMBER_RUNTIME_APIS__=t();var c=()=>typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(`(pointer: coarse)`).matches,l=(()=>{let e=new URLSearchParams(window.location.search).get(`surface`);if(e===`mobile`)return`mobile`;if(e===`desktop`)return`desktop`;let t=Math.min(window.innerWidth||0,window.screen?.width||window.innerWidth||0),n=navigator.maxTouchPoints||0;return t>0&&t<=760&&(n>0||c())?`mobile`:`desktop`})();window.__OPENCHAMBER_SURFACE__=l;var u=()=>!(!(`serviceWorker`in navigator)||!window.isSecureContext||window.location.protocol!==`http:`&&window.location.protocol!==`https:`||document.prerendering||String(document.visibilityState)===`prerender`),d=e=>{let t=!1,n=()=>{t||u()&&(t=!0,e())},r=()=>{setTimeout(n,0)};document.readyState===`complete`?r():window.addEventListener(`load`,r,{once:!0}),(document.prerendering||String(document.visibilityState)===`prerender`)&&document.addEventListener(`visibilitychange`,n,{once:!0})},f=()=>{d(()=>{try{s({onRegisterError(e){console.warn(`[PWA] service worker registration skipped:`,e)}})}catch(e){console.warn(`[PWA] service worker registration skipped:`,e)}})},p=`openchamber.dev.module-reload`,m=(e,t)=>{console.error(`[openchamber] failed to load ${t}:`,e)};l===`mobile`?n(async()=>{let{renderMobileApp:e}=await import(`./renderMobileApp-bklJJSZi.js`);return{renderMobileApp:e}},__vite__mapDeps([2,1,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96])).then(({renderMobileApp:e})=>{try{sessionStorage.removeItem(p)}catch{}e(window.__OPENCHAMBER_RUNTIME_APIS__??t())}).catch(e=>m(e,`renderMobileApp`)):e().then(()=>n(()=>import(`./main-DzxdsF_k.js`),__vite__mapDeps([97,1,3,4,5,6,7,8,9,34,10,11,12,20,80,46,14,15,16,17,18,19,13,21,22,24,25,26,27,28,29,31,32,33,35,36,37,38,39,40,41,42,43,44,45,47,48,49,50,51,30,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,81,82,83,84,85,86,98,87,88,89,95,99,100,101,102,103,104,96]))).then(()=>{try{sessionStorage.removeItem(p)}catch{}}).catch(e=>m(e,`desktop main`)),f();
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-workbox-window-qnW0Nbv7.js","assets/rolldown-runtime-C0FnF6B9.js","assets/renderMobileApp-DK9qzy0P.js","assets/useUIStore-D6BTB4va.js","assets/vendor-zustand-B4dlGEM2.js","assets/vendor-base-ui-CnHfUmDN.js","assets/persistence-C_KCiMcY.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-react-DLPElpoQ.js","assets/vendor-tanstack-query-core-BWz0ose6.js","assets/gitApiHttp-C1DaEMKR.js","assets/vendor-opencode-sdk-C07HQypa.js","assets/vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js","assets/vendor-sonner-DVzioF3d.js","assets/vendor-reactuses-core-DDoDDyM9.js","assets/vendor-lodash-es-DfLbG5Af.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/clipboard-CXWbHCAk.js","assets/store-oojlrF4d.js","assets/useMobileNavigationStore-1xHjnAsg.js","assets/vendor-tanstack-react-query-D7pys_c9.js","assets/useAssistantUIStore-ESTV1mEY.js","assets/vendor-fuse.js-DB5wDJbI.js","assets/MobileShareBridge-DAlvgjo1.js","assets/MobileDetailNavigation-lVtCe-5P.js","assets/utils-DyUyiLje.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/Icon-BPJ_quEe.js","assets/button-BmNJBT13.js","assets/AgentAvatar-C6Hxu5_o.js","assets/dialog-BV1ENlLf.js","assets/gitApi-Bs_2iBAm.js","assets/useAppFontEffects-BhLcUfRB.js","assets/desktopHosts-BpjUSDz4.js","assets/vendor-simplewebauthn-browser-Dwhcdg_5.js","assets/projectMeta-Cp74cItv.js","assets/input-BLVhPvhN.js","assets/tooltip-BYGBBTc2.js","assets/OverlayScrollbar-Dqk1zGJB.js","assets/vendor-dnd-kit-core-CvWxUPdb.js","assets/vendor-dnd-kit-accessibility-BY5LhhUB.js","assets/vendor-dnd-kit-sortable-hHdP9lLb.js","assets/useSessionAutoCleanup-BFletAeV.js","assets/desktopRelayRestore-BzUEk1i7.js","assets/radio-Bs4mdPv5.js","assets/vendor-codemirror-autocomplete-DHomsvW7.js","assets/vendor-codemirror-lang-angular-DShkBD6m.js","assets/vendor-codemirror-lang-json-CYJRHck9.js","assets/vendor-codemirror-lang-markdown-WORgx6ZD.js","assets/vendor-codemirror-lang-python-Du6XQ8Zw.js","assets/vendor-codemirror-legacy-modes-DuRAjNvB.js","assets/useThemeSystem-DMzWVJaW.js","assets/vendor-codemirror-language-data-BfYFhIH1.js","assets/markdownTheme-CCnvI6L0.js","assets/vendor-pierre-diffs-BenIz2TM.js","assets/vendor-hast-util-to-html-B0p1k5Xa.js","assets/vendor-character-entities-legacy-Wut6vMuj.js","assets/vendor-character-entities-html4-DlN_yAFd.js","assets/vendor-ccount-CyGsA0u7.js","assets/vendor-comma-separated-tokens-B9ouxNNS.js","assets/vendor-oniguruma-to-es-CrHzjjSU.js","assets/vendor-oniguruma-parser-D2DIvhSP.js","assets/vendor-diff-Dq7CZNim.js","assets/vendor-lru_map-DpDied8H.js","assets/ChatContainer-DEDGosbz.js","assets/useRuntimeAPIs-DSLXJybW.js","assets/appThemeRegistry-BXeIggYO.js","assets/markdown-worker-Cq3Twp1A.js","assets/url-CGHw6D-E.js","assets/useEffectiveDirectory-DG6uPzBG.js","assets/FadeInOnReveal-CvNA_aGD.js","assets/insertionBoundaries-BAFtAotq.js","assets/useWorkerHighlightedLines-ADgu9578.js","assets/vendor-tanstack-react-virtual-tlDgH6PG.js","assets/vendor-cmdk-CeAGfrLo.js","assets/vendor-aria-hidden-BbL3cEyI.js","assets/sortable-tabs-strip-oKJ700WG.js","assets/vendor-framer-motion-DFy_BSVd.js","assets/useFontPreferences-Bu4ME5hk.js","assets/terminalApi-BYTA045F.js","assets/MobileSurface-Bde8yLWo.js","assets/collapsible-68IqWBM1.js","assets/vendor-codemirror-commands-C9DCaJ0C.js","assets/vendor-codemirror-search-D2SOgzph.js","assets/vendor-replit-codemirror-vim-CEibx3EP.js","assets/projectActions-CWvNGKfA.js","assets/runtimeEndpointReset-C0eCWIE6.js","assets/context-menu-BbRpMBQh.js","assets/vendor-cron-parser-CCD11YFT.js","assets/SettingsView-D0dhTIur.js","assets/vendor-yaml-DIcAK3EC.js","assets/vendor-qrcode-DAuVxiQR.js","assets/vendor-dijkstrajs-DztKuCwY.js","assets/AssistantView-CbnxMZU0.js","assets/fileQueries-i4oziMnC.js","assets/src-8zziWB78.css","assets/main-G8tKFcTV.js","assets/useDesktopWindowControlsLayout-Cq5a2gcJ.js","assets/diagram-YN0GZ1Q0.js","assets/vendor-react-drawio-ECtEwvbc.js","assets/multirun-B-L3JH60.js","assets/vendor-zumer-snapdom-yq9vlCKr.js","assets/vendor-html-to-image-BDMm2v6d.js","assets/main-qSeeJRW1.css"])))=>i.map(i=>d[i]);
2
+ import{n as e,t}from"./runtimeConfig-JSaYFA5x.js";import{o as n}from"./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js";/* empty css */var r=`true`,i=`false`,a=r===`true`,o=i===`true`;function s(e={}){let{immediate:t=!1,onNeedReload:r,onNeedRefresh:i,onOfflineReady:s,onRegistered:c,onRegisteredSW:l,onRegisterError:u}=e,d,f,p,m=async(e=!0)=>{await f,a||p?.()};async function h(){if(`serviceWorker`in navigator){if(d=await n(async()=>{let{Workbox:e}=await import(`./vendor-workbox-window-qnW0Nbv7.js`).then(e=>e.t);return{Workbox:e}},__vite__mapDeps([0,1])).then(({Workbox:e})=>new e(`/sw.js`,{scope:`/`,type:`classic`})).catch(e=>{u?.(e)}),!d)return;if(p=()=>{d?.messageSkipWaiting()},!o)if(a)d.addEventListener(`activated`,e=>{(e.isUpdate||e.isExternal)&&(r?r():window.location.reload())}),d.addEventListener(`installed`,e=>{e.isUpdate||s?.()});else{let e=!1,t=()=>{e=!0,d?.addEventListener(`controlling`,e=>{e.isUpdate&&(r?r():window.location.reload())}),i?.()};d.addEventListener(`installed`,n=>{n.isUpdate===void 0?n.isExternal===void 0?!e&&s?.():n.isExternal?t():!e&&s?.():n.isUpdate||s?.()}),d.addEventListener(`waiting`,t)}d.register({immediate:t}).then(e=>{l?l(`/sw.js`,e):c?.(e)}).catch(e=>{u?.(e)})}}return f=h(),m}window.__OPENCHAMBER_RUNTIME_APIS__=t();var c=()=>typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(`(pointer: coarse)`).matches,l=(()=>{let e=new URLSearchParams(window.location.search).get(`surface`);if(e===`mobile`)return`mobile`;if(e===`desktop`)return`desktop`;let t=Math.min(window.innerWidth||0,window.screen?.width||window.innerWidth||0),n=navigator.maxTouchPoints||0;return t>0&&t<=760&&(n>0||c())?`mobile`:`desktop`})();window.__OPENCHAMBER_SURFACE__=l;var u=()=>!(!(`serviceWorker`in navigator)||!window.isSecureContext||window.location.protocol!==`http:`&&window.location.protocol!==`https:`||document.prerendering||String(document.visibilityState)===`prerender`),d=e=>{let t=!1,n=()=>{t||u()&&(t=!0,e())},r=()=>{setTimeout(n,0)};document.readyState===`complete`?r():window.addEventListener(`load`,r,{once:!0}),(document.prerendering||String(document.visibilityState)===`prerender`)&&document.addEventListener(`visibilitychange`,n,{once:!0})},f=()=>{d(()=>{try{s({onRegisterError(e){console.warn(`[PWA] service worker registration skipped:`,e)}})}catch(e){console.warn(`[PWA] service worker registration skipped:`,e)}})},p=`openchamber.dev.module-reload`,m=(e,t)=>{console.error(`[openchamber] failed to load ${t}:`,e)};l===`mobile`?n(async()=>{let{renderMobileApp:e}=await import(`./renderMobileApp-DK9qzy0P.js`);return{renderMobileApp:e}},__vite__mapDeps([2,1,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96])).then(({renderMobileApp:e})=>{try{sessionStorage.removeItem(p)}catch{}e(window.__OPENCHAMBER_RUNTIME_APIS__??t())}).catch(e=>m(e,`renderMobileApp`)):e().then(()=>n(()=>import(`./main-G8tKFcTV.js`),__vite__mapDeps([97,1,3,4,5,6,7,8,9,34,10,11,12,20,80,46,14,15,16,17,18,19,13,21,22,24,25,26,27,28,29,31,32,33,35,36,37,38,39,40,41,42,43,44,45,47,48,49,50,51,30,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,81,82,83,84,85,86,98,87,88,89,95,99,100,101,102,103,104,96]))).then(()=>{try{sessionStorage.removeItem(p)}catch{}}).catch(e=>m(e,`desktop main`)),f();