@openchambery/web 2.0.5-beta.3 → 2.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AssistantView-BeQjlQi5.js → AssistantView-kXN4mz6j.js} +3 -3
- package/dist/assets/{DiagramView-BPFVXhly.js → DiagramView-CGLAl3iS.js} +1 -1
- package/dist/assets/MarkdownRenderer-DA08bZsM.js +2 -0
- package/dist/assets/{MarkdownRendererImpl-DCim2MBS.js → MarkdownRendererImpl-qaVTVCHe.js} +1 -1
- package/dist/assets/{MarkstreamRendererImpl-DLI17gOM.js → MarkstreamRendererImpl-CQdVI8Vx.js} +1 -1
- package/dist/assets/{MobileDetailNavigation-C9097prS.js → MobileDetailNavigation-xaAVkxD-.js} +1 -1
- package/dist/assets/{MobileShareBridge-BVRtivg8.js → MobileShareBridge-z2TFroKY.js} +1 -1
- package/dist/assets/MobileTabPageHeader-DPlvhJFe.js +2 -0
- package/dist/assets/{MultiRunWindow-VdUAIkKj.js → MultiRunWindow-vJc2NLzu.js} +1 -1
- package/dist/assets/{SettingsView-BcQCG9q0.js → SettingsView-BG7DgHmP.js} +6 -6
- package/dist/assets/{SettingsWindow-BSap8D3j.js → SettingsWindow-3QrhPfuk.js} +1 -1
- package/dist/assets/{TerminalView-CQEmfuGt.js → TerminalView-Ciw0BIiz.js} +1 -1
- package/dist/assets/{ToolOutputDialog-3cIIsSBA.js → ToolOutputDialog-D_23USz-.js} +1 -1
- package/dist/assets/{appThemeRegistry-Dl2OjM9t.js → appThemeRegistry-lhAKuFFB.js} +1 -1
- package/dist/assets/{fileMentionTouchSelection-BJOHH2CX.js → fileMentionTouchSelection-DPSC4Fx2.js} +1 -1
- package/dist/assets/{gitApi-C-zOJTEi.js → gitApi-DeWWyR94.js} +3 -3
- package/dist/assets/insertionBoundaries-aV1Cm6zA.js +1 -0
- package/dist/assets/{main-ctL2Nr48.js → main-0XIuL0dd.js} +11 -11
- package/dist/assets/{main-Fbjmo73O.js → main-DZGXa6wk.js} +2 -2
- package/dist/assets/{mcpQueries-B1I3urB4.js → mcpQueries-pTPWjOQO.js} +1 -1
- package/dist/assets/{miniChat-BFctomLE.js → miniChat-C8K4fwOO.js} +2 -2
- package/dist/assets/{mobile-CgrEAs5U.js → mobile-Brtl2UnC.js} +2 -2
- package/dist/assets/multirun-B7FPVrQ-.js +3 -0
- package/dist/assets/{projectMeta-iGmHOQNp.js → projectMeta-D_jCNzjw.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-B82q9wxX.js → renderElectronMiniChatApp-e6XqcsYi.js} +2 -2
- package/dist/assets/renderMobileApp-BQenfg50.js +28 -0
- package/dist/assets/{runtimeConfig-CCw0l6aJ.js → runtimeConfig-CJE7T1Sr.js} +1 -1
- package/dist/assets/{runtimeEndpointReset-CvWlsn11.js → runtimeEndpointReset-DULSaOrI.js} +6 -6
- package/dist/assets/{sessionChangeSummary-BCz7YMwL.js → sessionChangeSummary-CVZBClsA.js} +1 -1
- package/dist/assets/{sessionLookup-BpO4cCmV.js → sessionLookup--qnazVNO.js} +1 -1
- package/dist/assets/{useAppFontEffects-KlbtUhYE.js → useAppFontEffects-BHenW5Q2.js} +53 -53
- package/dist/assets/{useDesktopWindowControlsLayout-BflHVu5S.js → useDesktopWindowControlsLayout-BGgoqF_n.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-BbQKZPcu.js → useEffectiveDirectory-CF16bcpx.js} +1 -1
- package/dist/assets/useMobileNavigationStore-DBML5LIl.js +415 -0
- package/dist/assets/{useSessionAutoCleanup-Dho6q-O2.js → useSessionAutoCleanup-moxr9XbA.js} +1 -1
- package/dist/assets/{useWorkerHighlightedLines-CbvulSje.js → useWorkerHighlightedLines-DYVg-cuB.js} +1 -1
- package/dist/index.html +2 -2
- package/dist/mini-chat.html +2 -2
- package/dist/mobile.html +2 -2
- package/package.json +1 -1
- package/server/lib/question-auto-delegate/DOCUMENTATION.md +4 -0
- package/server/lib/question-auto-delegate/core.d.ts +5 -0
- package/server/lib/question-auto-delegate/core.js +62 -13
- package/server/lib/question-auto-delegate/form-io.js +4 -1
- package/server/lib/question-auto-delegate/pause-store.d.ts +7 -0
- package/server/lib/question-auto-delegate/pause-store.js +39 -0
- package/server/lib/question-auto-delegate/runtime.js +3 -0
- package/server/lib/question-auto-delegate/runtime.test.js +128 -1
- package/dist/assets/MarkdownRenderer-D1fVOsHS.js +0 -2
- package/dist/assets/MobileTabPageHeader-tKa6r_KP.js +0 -2
- package/dist/assets/insertionBoundaries-DduQc2QR.js +0 -1
- package/dist/assets/multirun-BuVN-s4M.js +0 -3
- package/dist/assets/renderMobileApp-CM_El_gZ.js +0 -28
- package/dist/assets/useMobileNavigationStore-BjIptzTV.js +0 -415
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{$ as t,J as n,X as r,Y as i,Z as a,nt as o,rt as s}from"./vendor-base-ui-CnHfUmDN.js";import{n as c}from"./vendor-react-DLPElpoQ.js";import{f as l,r as u}from"./button-CUwjpv-i.js";import{t as d}from"./SettingsView-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{$ as t,J as n,X as r,Y as i,Z as a,nt as o,rt as s}from"./vendor-base-ui-CnHfUmDN.js";import{n as c}from"./vendor-react-DLPElpoQ.js";import{f as l,r as u}from"./button-CUwjpv-i.js";import{t as d}from"./SettingsView-BG7DgHmP.js";var f=c(),p=e(s(),1),m=o(),h=e=>{let o=(0,f.c)(19),{open:s,onOpenChange:c}=e,{t:h}=l(),_=p.useId(),v=g,y;o[0]===c?y=o[1]:(y=e=>{!e&&v()||c(e)},o[0]=c,o[1]=y);let b;o[2]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,m.jsx)(t,{className:u(`fixed inset-0 z-50 bg-black/50 dark:bg-black/75`,`transition-opacity duration-150 ease-out`,`data-[starting-style]:opacity-0 data-[ending-style]:opacity-0`)}),o[2]=b):b=o[2];let x;o[3]===Symbol.for(`react.memo_cache_sentinel`)?(x=u(`relative pointer-events-auto`,`w-[90vw] max-w-[1200px] h-[85vh] max-h-[900px]`,`rounded-xl border shadow-none overflow-hidden origin-center`,`bg-background`,`transition-all duration-150 ease-out`,`data-[starting-style]:opacity-0 data-[starting-style]:scale-[0.98]`,`data-[ending-style]:opacity-0 data-[ending-style]:scale-[0.98]`,`data-[nested-dialog-open]:brightness-[0.55] dark:data-[nested-dialog-open]:brightness-[0.4]`),o[3]=x):x=o[3];let S;o[4]===h?S=o[5]:(S=h(`settings.window.description`),o[4]=h,o[5]=S);let C;o[6]!==_||o[7]!==S?(C=(0,m.jsx)(a,{id:_,className:`sr-only`,children:S}),o[6]=_,o[7]=S,o[8]=C):C=o[8];let w;o[9]===c?w=o[10]:(w=(0,m.jsx)(d,{onClose:()=>c(!1),isWindowed:!0}),o[9]=c,o[10]=w);let T;o[11]!==_||o[12]!==C||o[13]!==w?(T=(0,m.jsxs)(i,{children:[b,(0,m.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center pointer-events-none`,children:(0,m.jsxs)(r,{"aria-describedby":_,className:x,children:[C,w]})})]}),o[11]=_,o[12]=C,o[13]=w,o[14]=T):T=o[14];let E;return o[15]!==s||o[16]!==y||o[17]!==T?(E=(0,m.jsx)(n,{open:s,onOpenChange:y,children:T}),o[15]=s,o[16]=y,o[17]=T,o[18]=E):E=o[18],E};function g(){return typeof document>`u`?!1:!!document.querySelector(`[data-slot="dropdown-menu-content"][data-open], [data-slot="select-content"][data-open]`)}export{h as SettingsWindow};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{n as t}from"./runtime-fetch-CiqQd__Y.js";import{rn as n}from"./persistence-Dnj1QOdX.js";import{nt as r,rt as i,tt as a}from"./vendor-base-ui-CnHfUmDN.js";import{c as o,l as s,n as c}from"./useUIStore-Dfx6TKvi.js";import{o as l}from"./terminalApi-DXyzaX3K.js";import{n as u,r as d,t as f}from"./vendor-ghostty-web-HohRXr3g.js";import{d as p,f as m,r as h,t as g}from"./button-CUwjpv-i.js";import{d as _}from"./useMobileNavigationStore-BjIptzTV.js";import{n as v}from"./Icon-BdzPRCSy.js";import{n as y}from"./useThemeSystem-DMzWVJaW.js";import{i as b,t as x}from"./OverlayScrollbar-C1C2aKOe.js";import{n as ee}from"./useRuntimeAPIs-DSLXJybW.js";import{n as S}from"./useEffectiveDirectory-BbQKZPcu.js";import{t as C}from"./sortable-tabs-strip-NN4v9dLg.js";import{n as w,t as T}from"./useFontPreferences-Cw2aKlz7.js";import{r as E}from"./projectActions-CWvNGKfA.js";var D=e(i(),1);function te(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 ne(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 re=e(a(),1),O=r(),k=null;function A(){return k||=d.load(),k}function ie(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 ae=D.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},g)=>{let{t:_}=m(),v=D.useRef(null),y=D.useRef(null),b=D.useRef(null),ee=D.useRef(null),S=D.useRef(n),C=D.useRef(r),w=D.useRef(null),T=D.useRef(``),E=D.useRef(null),te=D.useRef(!1),k=D.useRef(null),ae=D.useRef(!0),j=D.useRef(null),M=D.useRef(null),oe=D.useRef(0),se=D.useRef(null),N=D.useRef(null),P=D.useRef(!1),F=D.useRef(!1),ce=D.useRef(null),le=D.useRef(null),ue=D.useRef(null),I=D.useRef(``),de=D.useRef(null),fe=D.useRef(!c),pe=D.useRef(d),[,me]=D.useReducer(e=>e+1,0),[he,ge]=D.useReducer(e=>e+1,0);S.current=n,C.current=r;let _e=typeof navigator<`u`&&(/Android/i.test(navigator.userAgent)||navigator.userAgentData?.platform===`Android`),L=!!c;D.useEffect(()=>{if(!c){fe.current=!0,pe.current=d;return}!pe.current&&d&&(fe.current=!1),pe.current=d},[c,d]);let ve=D.useCallback(()=>{if(!L)return;let e=v.current,t=se.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`)})},[L]),R=D.useCallback(e=>{if(de.current===e)return;let t=b.current;if(t)try{if(typeof t.setOption==`function`){t.setOption(`cursorBlink`,e),de.current=e;return}t.options&&(t.options.cursorBlink=e,de.current=e)}catch{}},[]),z=L&&_e,B=D.useCallback((e,t)=>{let n=z?N.current:se.current,r=v.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{}}},[z]),V=D.useCallback(()=>{if(L){B(),R(!0);return}b.current?.focus(),R(!0)},[B,R,L]),H=D.useCallback(e=>e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement?e.value:e.textContent??``,[]),U=D.useCallback(e=>{if(e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement){e.value=``;return}e.textContent=``},[]),ye=D.useCallback(e=>{if(typeof window>`u`||z)return;ue.current!==null&&(window.clearTimeout(ue.current),ue.current=null);let t=0,n=()=>{ue.current=window.setTimeout(()=>{ue.current=null;let r=H(e);if(!r){if(t+=1,t<3){n();return}return}let i=I.current;I.current=r;let a=r.startsWith(i)?r.slice(i.length):r;a&&S.current(a.replace(/\r\n|\r|\n/g,`\r`)),U(e),I.current=``},t===0?0:24)};n()},[U,H,z]);D.useEffect(()=>{let e=v.current;if(!L||!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{}B()}};return e.addEventListener(`focusin`,t,!0),()=>{e.removeEventListener(`focusin`,t,!0)}},[c,L,B]);let W=D.useCallback(()=>{let e=b.current;if(!e||typeof e.getSelection!=`function`)return``;let t=e.getSelection();return typeof t==`string`?t:``},[]),be=D.useCallback(()=>{if(typeof window>`u`)return``;let e=window.getSelection();if(!e)return``;let t=e.toString();if(!t.trim())return``;let n=v.current;if(!n)return``;let r=e.anchorNode,i=e.focusNode;return r&&!n.contains(r)||i&&!n.contains(i)?``:t},[]),xe=D.useCallback(async()=>{if(typeof document>`u`)return;let e=W()||be();e.trim()&&await p(e)},[be,W]),Se=D.useCallback(()=>W().trim()?!0:!!be().trim(),[be,W]);D.useEffect(()=>{if(typeof window>`u`)return;let e=e=>{Se()&&(e.preventDefault(),xe())};return window.addEventListener(`openchamber:copy`,e),()=>{window.removeEventListener(`openchamber:copy`,e)}},[xe,Se]);let G=D.useCallback(()=>{T.current=``,E.current!==null&&typeof window<`u`&&window.cancelAnimationFrame(E.current),E.current=null,te.current=!1,k.current=null},[]),K=D.useCallback(()=>{let e=ee.current,t=b.current,n=v.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=w.current;(!r||r.cols!==n.cols||r.rows!==n.rows)&&(w.current=n,C.current(n.cols,n.rows))}catch{}},[]),q=D.useCallback(()=>{if(te.current)return;let e=b.current;if(!e){G();return}if(!T.current)return;let t=T.current;T.current=``,te.current=!0,e.write(t,()=>{te.current=!1,T.current&&(typeof window<`u`?E.current=window.requestAnimationFrame(()=>{E.current=null,q()}):q())})},[G]),Ce=D.useCallback(()=>{E.current===null&&(typeof window<`u`?E.current=window.requestAnimationFrame(()=>{E.current=null,q()}):q())},[q]),J=D.useCallback(e=>{e&&(T.current+=e,Ce())},[Ce]),we=D.useCallback(()=>{if(j.current?.(),j.current=null,M.current!==null&&typeof window<`u`&&(window.clearTimeout(M.current),M.current=null),!c){oe.current=0;return}let e=v.current;if(!e)return;let t=b.current;if(!t)return;oe.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,p=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},m=()=>{l.rafId!==null&&typeof window<`u`&&window.cancelAnimationFrame(l.rafId),l.rafId=null},h={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`){m(),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()),p(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){L?B(n.clientX,n.clientY):c&&!fe.current&&(fe.current=!0,b.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=p(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){m(),t.velocity=0;return}t.rafId=window.requestAnimationFrame(o)};t.rafId=window.requestAnimationFrame(o)};e.addEventListener(`pointerdown`,o,h),e.addEventListener(`pointermove`,d,h),e.addEventListener(`pointerup`,f,h),e.addEventListener(`pointercancel`,f,h);let g=e.style.touchAction,_=e.style.overscrollBehaviorY;e.style.touchAction=`none`,e.style.overscrollBehaviorY=`contain`,j.current=()=>{m(),M.current!==null&&typeof window<`u`&&(window.clearTimeout(M.current),M.current=null),oe.current=0,e.removeEventListener(`pointerdown`,o,h),e.removeEventListener(`pointermove`,d,h),e.removeEventListener(`pointerup`,f,h),e.removeEventListener(`pointercancel`,f,h),e.style.touchAction=g,e.style.overscrollBehaviorY=_};return}let g=e=>{e.touches.length===1&&(m(),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)},_=e=>{if(e.touches.length!==1){l.lastY=null,l.lastTime=null,l.velocity=0,l.startX=null,l.startY=null,l.didMove=!1,m();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),h=d*(n+Math.min(r,Math.abs(d)/25)),g=h/f;l.velocity=l.velocity*.75+g*i,l.velocity>8?l.velocity=8:l.velocity<-8&&(l.velocity=-8),l.didMove&&(e.preventDefault(),e.stopPropagation()),p(h)},y=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];L?B(t?.clientX,t?.clientY):c&&!fe.current&&(fe.current=!0,b.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=p(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){m(),l.velocity=0;return}l.rafId=window.requestAnimationFrame(i)};l.rafId=window.requestAnimationFrame(i)};e.addEventListener(`touchstart`,g,h),e.addEventListener(`touchmove`,_,h),e.addEventListener(`touchend`,y,h),e.addEventListener(`touchcancel`,y,h);let x=e.style.touchAction,ee=e.style.overscrollBehaviorY;e.style.touchAction=`none`,e.style.overscrollBehaviorY=`contain`,j.current=()=>{m(),M.current!==null&&typeof window<`u`&&(window.clearTimeout(M.current),M.current=null),oe.current=0,e.removeEventListener(`touchstart`,g,h),e.removeEventListener(`touchmove`,_,h),e.removeEventListener(`touchend`,y,h),e.removeEventListener(`touchcancel`,y,h),e.style.touchAction=x,e.style.overscrollBehaviorY=ee}},[c,L,B,o]);D.useEffect(()=>{let e=!1,t=null,n=null,r=null,s=[],l=null,d=null,p=null,m=v.current;if(!m)return;if(m.tabIndex=L?-1:0,L){let e=m.focus.bind(m),t=m;t.focus=((...e)=>{B()}),p=()=>{t.focus=e}}let h=()=>{R(!0)},g=()=>{R(!1)},_=e=>{let t=e.target;if(t&&m.contains(t)){if(L&&t instanceof HTMLElement){window.setTimeout(()=>{t.blur(),B()},0),R(!1);return}if(c&&!fe.current&&t instanceof HTMLElement){window.setTimeout(()=>{t.blur()},0),R(!1);return}R(!0);return}R(!1)},x=()=>{R(!1)},C=null;return(async()=>{try{let p=await A();if(e)return;let _=ne(a,o,i,p,!1),v=new u(_);ae.current=!0,L&&(v.focus=()=>{});let x=v;if(typeof x.scrollToBottom==`function`){let e=x.scrollToBottom.bind(x);x.scrollToBottom=()=>{ae.current&&e()},l=()=>{x.scrollToBottom=e}}let w=new f;if(t=v,b.current=v,ee.current=w,v.loadAddon(w),v.open(m),c){let e=v.renderer;if(e&&typeof e.renderScrollbar==`function`){let t=e.renderScrollbar.bind(e);e.renderScrollbar=()=>{},d=()=>{e.renderScrollbar=t}}}ge(),de.current=!1,C=v.textarea??m.querySelector(`textarea`),C&&(C.addEventListener(`focus`,h),C.addEventListener(`blur`,g)),ve(),typeof MutationObserver<`u`&&(r=new MutationObserver(()=>{ve()}),r.observe(m,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`contenteditable`,`role`,`tabindex`,`aria-label`]}));let T=ie(m);T?(T.classList.add(`overlay-scrollbar-target`,`overlay-scrollbar-container`),y.current=T,me()):y.current=null,K();let E=w;typeof E.observeResize==`function`&&E.observeResize(),we(),s=[v.onData(e=>{S.current(e)}),v.onScroll(e=>{if(typeof e==`number`&&Number.isFinite(e)){let t=typeof v.hasSelection==`function`&&v.hasSelection();ae.current=!t&&e<=.5}}),v.onSelectionChange(()=>{if(typeof v.hasSelection==`function`&&v.hasSelection()){ae.current=!1;return}let e=typeof v.getViewportY==`function`?v.getViewportY():0;ae.current=e<=.5})],n=new ResizeObserver(()=>{K()}),n.observe(m),typeof window<`u`&&window.setTimeout(()=>{K()},0)}catch{}})(),document.addEventListener(`focusin`,_,!0),window.addEventListener(`blur`,x),()=>{e=!0,j.current?.(),j.current=null,document.removeEventListener(`focusin`,_,!0),window.removeEventListener(`blur`,x),s.forEach(e=>e.dispose()),l?.(),l=null,d?.(),d=null,C&&(C.removeEventListener(`focus`,h),C.removeEventListener(`blur`,g)),n?.disconnect(),r?.disconnect(),p?.(),t?.dispose(),b.current=null,ee.current=null,y.current=null,w.current=null,de.current=null,G()}},[ve,c,K,B,a,o,we,i,G,R,L]),D.useEffect(()=>{let e=b.current;e&&(e.reset(),G(),w.current=null,K())},[e,he,K,G]),D.useEffect(()=>{l&&b.current&&V()},[l,V,e,he]),D.useEffect(()=>(we(),()=>{j.current?.(),j.current=null}),[we,e]),D.useEffect(()=>{let e=b.current;if(!e)return;if(t.length===0){k.current!==null&&(e.reset(),G(),K());return}let n=k.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&&J(r.map(e=>e.data).join(``)),k.current=t[t.length-1].id},[t,he,J,K,G]),D.useImperativeHandle(g,()=>({focus:()=>{V()},clear:()=>{let e=b.current;e&&(e.reset(),G(),K())},fit:()=>{K()}}),[V,K,G]);let Y=D.useCallback(e=>{if(!L)return;let t=v.current,n=e.relatedTarget,r=n?.tagName;r===`INPUT`||r===`TEXTAREA`||n?.isContentEditable,n?.getAttribute(`data-terminal-hidden-input`),n&&t?.contains(n)},[L]),X=D.useCallback(e=>{let t=e.nativeEvent,n=t?.inputType??``,r=typeof t?.data==`string`?t.data:``;if(le.current=typeof performance<`u`?performance.now():Date.now(),n===`insertCompositionText`){P.current=!0;return}if(!n&&r){if(P.current)return;e.preventDefault(),S.current(r),ce.current={type:`insertText`,at:typeof performance<`u`?performance.now():Date.now()},F.current=!0;return}if(n===`insertText`&&r){if(P.current)return;e.preventDefault(),S.current(r),ce.current={type:n,at:typeof performance<`u`?performance.now():Date.now()},F.current=!0;return}if(n===`insertLineBreak`){if(P.current)return;e.preventDefault(),S.current(`\r`),ce.current={type:n,at:typeof performance<`u`?performance.now():Date.now()},F.current=!0;return}if(n===`deleteContentBackward`){if(P.current)return;e.preventDefault(),S.current(``),ce.current={type:n,at:typeof performance<`u`?performance.now():Date.now()},F.current=!0}},[]),Z=D.useCallback(e=>{let t=e.currentTarget;if(le.current=typeof performance<`u`?performance.now():Date.now(),P.current)return;if(F.current){let e=ce.current,n=typeof performance<`u`?performance.now():Date.now();if(e&&n-e.at<50){F.current=!1,U(t);return}F.current=!1}let n=H(t);if(!n)return;I.current=n;let r=n.replace(/\r\n|\r|\n/g,`\r`);S.current(r),U(t),I.current=``},[U,H]),Te=D.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)&&Se()){e.preventDefault(),xe();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(),S.current(String.fromCharCode(t.charCodeAt(0)-64)),U(e.currentTarget);return}}if(e.altKey&&!e.ctrlKey&&!e.metaKey&&e.key.length===1){e.preventDefault(),e.nativeEvent?.stopImmediatePropagation(),S.current(`\x1B`+e.key),U(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(),S.current(i),U(e.currentTarget);return}let a=e.currentTarget;if(e.nativeEvent?.isComposing)return;let o=ce.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(),S.current(`\r`),U(a);return}if(e.key===`Backspace`){if(e.preventDefault(),c&&o?.type===`deleteContentBackward`)return;H(a)||S.current(``)}if(e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey){let t=le.current;t&&s-t<50||(e.preventDefault(),S.current(e.key),F.current=!0,ce.current={type:`keydown-text`,at:s})}ye(a)},[U,xe,Se,H,ye]),Ee=D.useCallback(e=>{e.stopPropagation();let t=e.currentTarget;e.nativeEvent?.isComposing||ye(t)},[ye]),De=D.useCallback(e=>{let t=e.currentTarget;P.current=!1;let n=e.data||H(t);if(le.current=typeof performance<`u`?performance.now():Date.now(),!n)return;let r=n.replace(/\r\n|\r|\n/g,`\r`);S.current(r),U(t),ce.current={type:`compositionend`,at:typeof performance<`u`?performance.now():Date.now()},F.current=!0},[U,H]),Oe=D.useCallback(e=>{e.stopPropagation();let t=e.clipboardData?.getData(`text`)??``;if(!t)return;e.preventDefault();let n=b.current?.hasBracketedPaste?.()?`\x1b[200~${t}\x1b[201~`:t;S.current(n)},[]),ke={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,O.jsxs)(`div`,{ref:v,className:h(`relative h-full w-full terminal-viewport-container`,s),"data-hidden-input-overlay-active":L?`true`:void 0,style:{backgroundColor:i.background},onTouchStart:e=>{if(!(!L||c)&&!Se()){let t=e.touches?.[0];B(t?.clientX,t?.clientY)}},onClick:e=>{if(!c)if(L){if(Se())return;B(e.clientX,e.clientY)}else b.current?.focus()},onMouseUp:()=>{!c&&Se()&&xe()},onTouchEnd:()=>{!c&&Se()&&xe()},children:[L&&typeof document<`u`?(0,re.createPortal)((0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`input`,{ref:N,type:`text`,inputMode:`text`,autoCapitalize:`off`,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,tabIndex:-1,enterKeyHint:`send`,"data-terminal-hidden-input":`true`,"aria-label":_(`terminalView.viewport.inputAria`),"aria-hidden":`true`,style:{...ke,display:z?`block`:`none`},onBlur:Y,onBeforeInput:X,onCompositionStart:()=>{P.current=!0},onInput:Z,onKeyDown:Te,onKeyUp:Ee,onCompositionEnd:De,onPaste:Oe}),(0,O.jsx)(`textarea`,{ref:se,inputMode:`text`,autoCapitalize:`off`,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,tabIndex:-1,enterKeyHint:`send`,"data-terminal-hidden-input":`true`,"aria-label":_(`terminalView.viewport.inputAria`),"aria-hidden":`true`,style:{...ke,display:z?`none`:`block`},onBlur:Y,onBeforeInput:X,onCompositionStart:()=>{P.current=!0},onInput:Z,onKeyDown:Te,onKeyUp:Ee,onCompositionEnd:De,onPaste:Oe})]}),document.body):null,y.current&&!c?(0,O.jsx)(x,{containerRef:y,disableHorizontal:!0,className:`overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero`}):null]})});ae.displayName=`TerminalViewport`;var j=RegExp(`\x1B\\[[0-9;?]*[ -/]*[@-~]`,`g`),M=/(https?:\/\/(?:localhost|127\.0\.0\.1|0\.0\.0\.0|\[(?:::1|::)\])(?::\d{2,5})?(?:\/[^\s<>'"`]*)?)/gi,oe=/(?:➜\s*(?:Local|Network):)|\b(?:local|network|loopback|serving|listening|available|ready|started|running|server|vite|webpack|next\.js|astro|sveltekit|nuxt)\b/i,se=/Serving HTTP on .*? port (\d{2,5})/i,N=new Set([`.`,`,`,`;`,`:`,`!`,`?`]),P=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(N.has(e)){t=t.slice(0,-1);continue}break}return t},F=e=>{let t=P(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},ce=e=>{if(!e)return null;let t=e.replace(j,``),n=t.match(se);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{n as t}from"./runtime-fetch-CiqQd__Y.js";import{rn as n}from"./persistence-Dnj1QOdX.js";import{nt as r,rt as i,tt as a}from"./vendor-base-ui-CnHfUmDN.js";import{c as o,l as s,n as c}from"./useUIStore-Dfx6TKvi.js";import{o as l}from"./terminalApi-DXyzaX3K.js";import{n as u,r as d,t as f}from"./vendor-ghostty-web-HohRXr3g.js";import{d as p,f as m,r as h,t as g}from"./button-CUwjpv-i.js";import{d as _}from"./useMobileNavigationStore-DBML5LIl.js";import{n as v}from"./Icon-BdzPRCSy.js";import{n as y}from"./useThemeSystem-DMzWVJaW.js";import{i as b,t as x}from"./OverlayScrollbar-C1C2aKOe.js";import{n as ee}from"./useRuntimeAPIs-DSLXJybW.js";import{n as S}from"./useEffectiveDirectory-CF16bcpx.js";import{t as C}from"./sortable-tabs-strip-NN4v9dLg.js";import{n as w,t as T}from"./useFontPreferences-Cw2aKlz7.js";import{r as E}from"./projectActions-CWvNGKfA.js";var D=e(i(),1);function te(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 ne(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 re=e(a(),1),O=r(),k=null;function A(){return k||=d.load(),k}function ie(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 ae=D.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},g)=>{let{t:_}=m(),v=D.useRef(null),y=D.useRef(null),b=D.useRef(null),ee=D.useRef(null),S=D.useRef(n),C=D.useRef(r),w=D.useRef(null),T=D.useRef(``),E=D.useRef(null),te=D.useRef(!1),k=D.useRef(null),ae=D.useRef(!0),j=D.useRef(null),M=D.useRef(null),oe=D.useRef(0),se=D.useRef(null),N=D.useRef(null),P=D.useRef(!1),F=D.useRef(!1),ce=D.useRef(null),le=D.useRef(null),ue=D.useRef(null),I=D.useRef(``),de=D.useRef(null),fe=D.useRef(!c),pe=D.useRef(d),[,me]=D.useReducer(e=>e+1,0),[he,ge]=D.useReducer(e=>e+1,0);S.current=n,C.current=r;let _e=typeof navigator<`u`&&(/Android/i.test(navigator.userAgent)||navigator.userAgentData?.platform===`Android`),L=!!c;D.useEffect(()=>{if(!c){fe.current=!0,pe.current=d;return}!pe.current&&d&&(fe.current=!1),pe.current=d},[c,d]);let ve=D.useCallback(()=>{if(!L)return;let e=v.current,t=se.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`)})},[L]),R=D.useCallback(e=>{if(de.current===e)return;let t=b.current;if(t)try{if(typeof t.setOption==`function`){t.setOption(`cursorBlink`,e),de.current=e;return}t.options&&(t.options.cursorBlink=e,de.current=e)}catch{}},[]),z=L&&_e,B=D.useCallback((e,t)=>{let n=z?N.current:se.current,r=v.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{}}},[z]),V=D.useCallback(()=>{if(L){B(),R(!0);return}b.current?.focus(),R(!0)},[B,R,L]),H=D.useCallback(e=>e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement?e.value:e.textContent??``,[]),U=D.useCallback(e=>{if(e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement){e.value=``;return}e.textContent=``},[]),ye=D.useCallback(e=>{if(typeof window>`u`||z)return;ue.current!==null&&(window.clearTimeout(ue.current),ue.current=null);let t=0,n=()=>{ue.current=window.setTimeout(()=>{ue.current=null;let r=H(e);if(!r){if(t+=1,t<3){n();return}return}let i=I.current;I.current=r;let a=r.startsWith(i)?r.slice(i.length):r;a&&S.current(a.replace(/\r\n|\r|\n/g,`\r`)),U(e),I.current=``},t===0?0:24)};n()},[U,H,z]);D.useEffect(()=>{let e=v.current;if(!L||!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{}B()}};return e.addEventListener(`focusin`,t,!0),()=>{e.removeEventListener(`focusin`,t,!0)}},[c,L,B]);let W=D.useCallback(()=>{let e=b.current;if(!e||typeof e.getSelection!=`function`)return``;let t=e.getSelection();return typeof t==`string`?t:``},[]),be=D.useCallback(()=>{if(typeof window>`u`)return``;let e=window.getSelection();if(!e)return``;let t=e.toString();if(!t.trim())return``;let n=v.current;if(!n)return``;let r=e.anchorNode,i=e.focusNode;return r&&!n.contains(r)||i&&!n.contains(i)?``:t},[]),xe=D.useCallback(async()=>{if(typeof document>`u`)return;let e=W()||be();e.trim()&&await p(e)},[be,W]),Se=D.useCallback(()=>W().trim()?!0:!!be().trim(),[be,W]);D.useEffect(()=>{if(typeof window>`u`)return;let e=e=>{Se()&&(e.preventDefault(),xe())};return window.addEventListener(`openchamber:copy`,e),()=>{window.removeEventListener(`openchamber:copy`,e)}},[xe,Se]);let G=D.useCallback(()=>{T.current=``,E.current!==null&&typeof window<`u`&&window.cancelAnimationFrame(E.current),E.current=null,te.current=!1,k.current=null},[]),K=D.useCallback(()=>{let e=ee.current,t=b.current,n=v.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=w.current;(!r||r.cols!==n.cols||r.rows!==n.rows)&&(w.current=n,C.current(n.cols,n.rows))}catch{}},[]),q=D.useCallback(()=>{if(te.current)return;let e=b.current;if(!e){G();return}if(!T.current)return;let t=T.current;T.current=``,te.current=!0,e.write(t,()=>{te.current=!1,T.current&&(typeof window<`u`?E.current=window.requestAnimationFrame(()=>{E.current=null,q()}):q())})},[G]),Ce=D.useCallback(()=>{E.current===null&&(typeof window<`u`?E.current=window.requestAnimationFrame(()=>{E.current=null,q()}):q())},[q]),J=D.useCallback(e=>{e&&(T.current+=e,Ce())},[Ce]),we=D.useCallback(()=>{if(j.current?.(),j.current=null,M.current!==null&&typeof window<`u`&&(window.clearTimeout(M.current),M.current=null),!c){oe.current=0;return}let e=v.current;if(!e)return;let t=b.current;if(!t)return;oe.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,p=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},m=()=>{l.rafId!==null&&typeof window<`u`&&window.cancelAnimationFrame(l.rafId),l.rafId=null},h={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`){m(),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()),p(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){L?B(n.clientX,n.clientY):c&&!fe.current&&(fe.current=!0,b.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=p(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){m(),t.velocity=0;return}t.rafId=window.requestAnimationFrame(o)};t.rafId=window.requestAnimationFrame(o)};e.addEventListener(`pointerdown`,o,h),e.addEventListener(`pointermove`,d,h),e.addEventListener(`pointerup`,f,h),e.addEventListener(`pointercancel`,f,h);let g=e.style.touchAction,_=e.style.overscrollBehaviorY;e.style.touchAction=`none`,e.style.overscrollBehaviorY=`contain`,j.current=()=>{m(),M.current!==null&&typeof window<`u`&&(window.clearTimeout(M.current),M.current=null),oe.current=0,e.removeEventListener(`pointerdown`,o,h),e.removeEventListener(`pointermove`,d,h),e.removeEventListener(`pointerup`,f,h),e.removeEventListener(`pointercancel`,f,h),e.style.touchAction=g,e.style.overscrollBehaviorY=_};return}let g=e=>{e.touches.length===1&&(m(),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)},_=e=>{if(e.touches.length!==1){l.lastY=null,l.lastTime=null,l.velocity=0,l.startX=null,l.startY=null,l.didMove=!1,m();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),h=d*(n+Math.min(r,Math.abs(d)/25)),g=h/f;l.velocity=l.velocity*.75+g*i,l.velocity>8?l.velocity=8:l.velocity<-8&&(l.velocity=-8),l.didMove&&(e.preventDefault(),e.stopPropagation()),p(h)},y=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];L?B(t?.clientX,t?.clientY):c&&!fe.current&&(fe.current=!0,b.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=p(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){m(),l.velocity=0;return}l.rafId=window.requestAnimationFrame(i)};l.rafId=window.requestAnimationFrame(i)};e.addEventListener(`touchstart`,g,h),e.addEventListener(`touchmove`,_,h),e.addEventListener(`touchend`,y,h),e.addEventListener(`touchcancel`,y,h);let x=e.style.touchAction,ee=e.style.overscrollBehaviorY;e.style.touchAction=`none`,e.style.overscrollBehaviorY=`contain`,j.current=()=>{m(),M.current!==null&&typeof window<`u`&&(window.clearTimeout(M.current),M.current=null),oe.current=0,e.removeEventListener(`touchstart`,g,h),e.removeEventListener(`touchmove`,_,h),e.removeEventListener(`touchend`,y,h),e.removeEventListener(`touchcancel`,y,h),e.style.touchAction=x,e.style.overscrollBehaviorY=ee}},[c,L,B,o]);D.useEffect(()=>{let e=!1,t=null,n=null,r=null,s=[],l=null,d=null,p=null,m=v.current;if(!m)return;if(m.tabIndex=L?-1:0,L){let e=m.focus.bind(m),t=m;t.focus=((...e)=>{B()}),p=()=>{t.focus=e}}let h=()=>{R(!0)},g=()=>{R(!1)},_=e=>{let t=e.target;if(t&&m.contains(t)){if(L&&t instanceof HTMLElement){window.setTimeout(()=>{t.blur(),B()},0),R(!1);return}if(c&&!fe.current&&t instanceof HTMLElement){window.setTimeout(()=>{t.blur()},0),R(!1);return}R(!0);return}R(!1)},x=()=>{R(!1)},C=null;return(async()=>{try{let p=await A();if(e)return;let _=ne(a,o,i,p,!1),v=new u(_);ae.current=!0,L&&(v.focus=()=>{});let x=v;if(typeof x.scrollToBottom==`function`){let e=x.scrollToBottom.bind(x);x.scrollToBottom=()=>{ae.current&&e()},l=()=>{x.scrollToBottom=e}}let w=new f;if(t=v,b.current=v,ee.current=w,v.loadAddon(w),v.open(m),c){let e=v.renderer;if(e&&typeof e.renderScrollbar==`function`){let t=e.renderScrollbar.bind(e);e.renderScrollbar=()=>{},d=()=>{e.renderScrollbar=t}}}ge(),de.current=!1,C=v.textarea??m.querySelector(`textarea`),C&&(C.addEventListener(`focus`,h),C.addEventListener(`blur`,g)),ve(),typeof MutationObserver<`u`&&(r=new MutationObserver(()=>{ve()}),r.observe(m,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`contenteditable`,`role`,`tabindex`,`aria-label`]}));let T=ie(m);T?(T.classList.add(`overlay-scrollbar-target`,`overlay-scrollbar-container`),y.current=T,me()):y.current=null,K();let E=w;typeof E.observeResize==`function`&&E.observeResize(),we(),s=[v.onData(e=>{S.current(e)}),v.onScroll(e=>{if(typeof e==`number`&&Number.isFinite(e)){let t=typeof v.hasSelection==`function`&&v.hasSelection();ae.current=!t&&e<=.5}}),v.onSelectionChange(()=>{if(typeof v.hasSelection==`function`&&v.hasSelection()){ae.current=!1;return}let e=typeof v.getViewportY==`function`?v.getViewportY():0;ae.current=e<=.5})],n=new ResizeObserver(()=>{K()}),n.observe(m),typeof window<`u`&&window.setTimeout(()=>{K()},0)}catch{}})(),document.addEventListener(`focusin`,_,!0),window.addEventListener(`blur`,x),()=>{e=!0,j.current?.(),j.current=null,document.removeEventListener(`focusin`,_,!0),window.removeEventListener(`blur`,x),s.forEach(e=>e.dispose()),l?.(),l=null,d?.(),d=null,C&&(C.removeEventListener(`focus`,h),C.removeEventListener(`blur`,g)),n?.disconnect(),r?.disconnect(),p?.(),t?.dispose(),b.current=null,ee.current=null,y.current=null,w.current=null,de.current=null,G()}},[ve,c,K,B,a,o,we,i,G,R,L]),D.useEffect(()=>{let e=b.current;e&&(e.reset(),G(),w.current=null,K())},[e,he,K,G]),D.useEffect(()=>{l&&b.current&&V()},[l,V,e,he]),D.useEffect(()=>(we(),()=>{j.current?.(),j.current=null}),[we,e]),D.useEffect(()=>{let e=b.current;if(!e)return;if(t.length===0){k.current!==null&&(e.reset(),G(),K());return}let n=k.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&&J(r.map(e=>e.data).join(``)),k.current=t[t.length-1].id},[t,he,J,K,G]),D.useImperativeHandle(g,()=>({focus:()=>{V()},clear:()=>{let e=b.current;e&&(e.reset(),G(),K())},fit:()=>{K()}}),[V,K,G]);let Y=D.useCallback(e=>{if(!L)return;let t=v.current,n=e.relatedTarget,r=n?.tagName;r===`INPUT`||r===`TEXTAREA`||n?.isContentEditable,n?.getAttribute(`data-terminal-hidden-input`),n&&t?.contains(n)},[L]),X=D.useCallback(e=>{let t=e.nativeEvent,n=t?.inputType??``,r=typeof t?.data==`string`?t.data:``;if(le.current=typeof performance<`u`?performance.now():Date.now(),n===`insertCompositionText`){P.current=!0;return}if(!n&&r){if(P.current)return;e.preventDefault(),S.current(r),ce.current={type:`insertText`,at:typeof performance<`u`?performance.now():Date.now()},F.current=!0;return}if(n===`insertText`&&r){if(P.current)return;e.preventDefault(),S.current(r),ce.current={type:n,at:typeof performance<`u`?performance.now():Date.now()},F.current=!0;return}if(n===`insertLineBreak`){if(P.current)return;e.preventDefault(),S.current(`\r`),ce.current={type:n,at:typeof performance<`u`?performance.now():Date.now()},F.current=!0;return}if(n===`deleteContentBackward`){if(P.current)return;e.preventDefault(),S.current(``),ce.current={type:n,at:typeof performance<`u`?performance.now():Date.now()},F.current=!0}},[]),Z=D.useCallback(e=>{let t=e.currentTarget;if(le.current=typeof performance<`u`?performance.now():Date.now(),P.current)return;if(F.current){let e=ce.current,n=typeof performance<`u`?performance.now():Date.now();if(e&&n-e.at<50){F.current=!1,U(t);return}F.current=!1}let n=H(t);if(!n)return;I.current=n;let r=n.replace(/\r\n|\r|\n/g,`\r`);S.current(r),U(t),I.current=``},[U,H]),Te=D.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)&&Se()){e.preventDefault(),xe();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(),S.current(String.fromCharCode(t.charCodeAt(0)-64)),U(e.currentTarget);return}}if(e.altKey&&!e.ctrlKey&&!e.metaKey&&e.key.length===1){e.preventDefault(),e.nativeEvent?.stopImmediatePropagation(),S.current(`\x1B`+e.key),U(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(),S.current(i),U(e.currentTarget);return}let a=e.currentTarget;if(e.nativeEvent?.isComposing)return;let o=ce.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(),S.current(`\r`),U(a);return}if(e.key===`Backspace`){if(e.preventDefault(),c&&o?.type===`deleteContentBackward`)return;H(a)||S.current(``)}if(e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey){let t=le.current;t&&s-t<50||(e.preventDefault(),S.current(e.key),F.current=!0,ce.current={type:`keydown-text`,at:s})}ye(a)},[U,xe,Se,H,ye]),Ee=D.useCallback(e=>{e.stopPropagation();let t=e.currentTarget;e.nativeEvent?.isComposing||ye(t)},[ye]),De=D.useCallback(e=>{let t=e.currentTarget;P.current=!1;let n=e.data||H(t);if(le.current=typeof performance<`u`?performance.now():Date.now(),!n)return;let r=n.replace(/\r\n|\r|\n/g,`\r`);S.current(r),U(t),ce.current={type:`compositionend`,at:typeof performance<`u`?performance.now():Date.now()},F.current=!0},[U,H]),Oe=D.useCallback(e=>{e.stopPropagation();let t=e.clipboardData?.getData(`text`)??``;if(!t)return;e.preventDefault();let n=b.current?.hasBracketedPaste?.()?`\x1b[200~${t}\x1b[201~`:t;S.current(n)},[]),ke={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,O.jsxs)(`div`,{ref:v,className:h(`relative h-full w-full terminal-viewport-container`,s),"data-hidden-input-overlay-active":L?`true`:void 0,style:{backgroundColor:i.background},onTouchStart:e=>{if(!(!L||c)&&!Se()){let t=e.touches?.[0];B(t?.clientX,t?.clientY)}},onClick:e=>{if(!c)if(L){if(Se())return;B(e.clientX,e.clientY)}else b.current?.focus()},onMouseUp:()=>{!c&&Se()&&xe()},onTouchEnd:()=>{!c&&Se()&&xe()},children:[L&&typeof document<`u`?(0,re.createPortal)((0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`input`,{ref:N,type:`text`,inputMode:`text`,autoCapitalize:`off`,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,tabIndex:-1,enterKeyHint:`send`,"data-terminal-hidden-input":`true`,"aria-label":_(`terminalView.viewport.inputAria`),"aria-hidden":`true`,style:{...ke,display:z?`block`:`none`},onBlur:Y,onBeforeInput:X,onCompositionStart:()=>{P.current=!0},onInput:Z,onKeyDown:Te,onKeyUp:Ee,onCompositionEnd:De,onPaste:Oe}),(0,O.jsx)(`textarea`,{ref:se,inputMode:`text`,autoCapitalize:`off`,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,tabIndex:-1,enterKeyHint:`send`,"data-terminal-hidden-input":`true`,"aria-label":_(`terminalView.viewport.inputAria`),"aria-hidden":`true`,style:{...ke,display:z?`none`:`block`},onBlur:Y,onBeforeInput:X,onCompositionStart:()=>{P.current=!0},onInput:Z,onKeyDown:Te,onKeyUp:Ee,onCompositionEnd:De,onPaste:Oe})]}),document.body):null,y.current&&!c?(0,O.jsx)(x,{containerRef:y,disableHorizontal:!0,className:`overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero`}):null]})});ae.displayName=`TerminalViewport`;var j=RegExp(`\x1B\\[[0-9;?]*[ -/]*[@-~]`,`g`),M=/(https?:\/\/(?:localhost|127\.0\.0\.1|0\.0\.0\.0|\[(?:::1|::)\])(?::\d{2,5})?(?:\/[^\s<>'"`]*)?)/gi,oe=/(?:➜\s*(?:Local|Network):)|\b(?:local|network|loopback|serving|listening|available|ready|started|running|server|vite|webpack|next\.js|astro|sveltekit|nuxt)\b/i,se=/Serving HTTP on .*? port (\d{2,5})/i,N=new Set([`.`,`,`,`;`,`:`,`!`,`?`]),P=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(N.has(e)){t=t.slice(0,-1);continue}break}return t},F=e=>{let t=P(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},ce=e=>{if(!e)return null;let t=e.replace(j,``),n=t.match(se);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(!oe.test(e))continue;let t=Array.from(e.matchAll(M));if(t.length!==0)return F((t.find(e=>{try{return!!new URL(F(e[1])).port}catch{return!1}})??t[0])[1])}return null},le=async(e,n=1500)=>{if(!e||typeof window>`u`)return!1;let r;try{r=new URL(e)}catch{return!1}if(r.protocol!==`http:`&&r.protocol!==`https:`)return!1;let i=r.hostname.toLowerCase();if(i!==`localhost`&&i!==`127.0.0.1`&&i!==`0.0.0.0`&&i!==`::1`&&i!==`::`)return!1;let a=new AbortController,o=window.setTimeout(()=>a.abort(),n);try{let e=await t(`/api/system/probe-url`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:r.toString()}),cache:`no-store`,signal:a.signal});return e.ok?(await e.json().catch(()=>null))?.ok===!0:!1}catch{return!1}finally{window.clearTimeout(o)}},ue={esc:`\x1B`,tab:` `,enter:`\r`,"arrow-up":`\x1B[A`,"arrow-down":`\x1B[B`,"arrow-left":`\x1B[D`,"arrow-right":`\x1B[C`},I={ctrl:`5`,cmd:`3`},de={retry:{maxRetries:3,initialDelayMs:500,maxDelayMs:8e3},connectionTimeoutMs:1e4},fe={retry:{maxRetries:8,initialDelayMs:400,maxDelayMs:8e3},connectionTimeoutMs:15e3},pe=(e,t)=>{if(t)switch(e){case`arrow-up`:return`\u001b[1;${I[t]}A`;case`arrow-down`:return`\u001b[1;${I[t]}B`;case`arrow-right`:return`\u001b[1;${I[t]}C`;case`arrow-left`:return`\u001b[1;${I[t]}D`}return ue[e]??null},me=()=>{let{t:e}=m(),{terminal:t,runtime:r}=ee(),{currentTheme:i}=y(),{monoFont:a}=T(),u=c(e=>e.terminalFontSize),d=c(e=>e.bottomTerminalHeight),f=c(e=>e.isBottomTerminalExpanded),{isMobile:p,isTablet:x,hasTouchOnlyPointer:ne}=b(),re=p||x,k=(re||ne)&&r.platform===`web`,A=r.platform!==`vscode`,ie=c(e=>e.showTerminalQuickKeysOnDesktop),j=!n()&&(re||ie),M=_(e=>e.currentSessionId),oe=_(e=>e.newSessionDraft),se=M!==null||oe?.open===!0,N=S()??null,P=w(e=>e.sessions),F=w(e=>e.hasHydrated),ue=w(e=>e.ensureDirectory),I=w(e=>e.createTab),me=w(e=>e.setActiveTab),he=w(e=>e.closeTab),ge=w(e=>e.setTabSessionId),_e=w(e=>e.setTabLifecycle),L=w(e=>e.setConnecting),ve=w(e=>e.appendToBuffer),R=w(e=>e.setTabPreviewUrl),z=w(e=>e.clearBuffer),B=c(e=>e.openContextPreview),V=D.useMemo(()=>{if(N)return P.get(N)},[P,N]),H=D.useMemo(()=>V?A?V.activeTabId??V.tabs[0]?.id??null:V.tabs[0]?.id??null:null,[V,A]),U=D.useMemo(()=>{if(V)return H?V.tabs.find(e=>e.id===H)??V.tabs[0]:V.tabs[0]},[V,H]),ye=D.useMemo(()=>(V?.tabs??[]).map(t=>({icon:(()=>{let e=t.iconKey?E[t.iconKey]??`terminal`:`terminal`;return(0,O.jsx)(v,{name:e,className:`h-4 w-4`})})(),id:t.id,label:t.label,title:t.label,closeLabel:e(`terminalView.tabs.closeTabTitle`)})),[V?.tabs,e]),W=U?.terminalSessionId??null,be=U?.lifecycle??`idle`,xe=U?.bufferChunks??[],Se=U?.isConnecting??!1,G=U?.previewUrl??null,[K,q]=D.useState(null),[Ce,J]=D.useState(!1),[we,Y]=D.useState(!1),[X,Z]=D.useState(null),[Te,Ee]=D.useState(!1),[De,Oe]=D.useState(0),ke=D.useRef(null),Ae=D.useRef(null),je=D.useRef(H),Me=D.useRef(W),Ne=D.useRef(N),Pe=D.useRef(null),Fe=D.useRef(null),Ie=D.useRef(!1),Le=D.useRef(!1),Re=D.useRef(null),ze=D.useRef(null),Be=D.useRef(new Set),Ve=D.useRef(!1),He=D.useRef(``),Ue=D.useRef(new Set),We=D.useRef(0),Ge=D.useCallback(()=>{He.current=``,Ue.current.clear(),We.current+=1},[]),Ke=D.useCallback(()=>{k||typeof document<`u`&&!document.hasFocus()||Pe.current?.focus()},[k]),qe=D.useCallback(()=>{k||Pe.current?.focus()},[k]);D.useEffect(()=>{if(!F||Ve.current)return;Ve.current=!0;let e=new Set;for(let[,t]of w.getState().sessions.entries())for(let n of t.tabs)n.terminalSessionId&&e.add(n.terminalSessionId);Be.current=e},[F]);let Je=c(e=>e.activeMainTab),Ye=c(e=>e.isBottomTerminalOpen),Xe=c(e=>e.setBottomTerminalOpen),Ze=c(e=>e.setBottomTerminalExpanded),Qe=Je===`terminal`,Q=Qe||Ye,[$e,et]=D.useState(Q);D.useEffect(()=>{!Q||r.platform===`vscode`||l()},[Q,r.platform]),D.useEffect(()=>{Q&&et(!0)},[Q]),D.useEffect(()=>{Le.current=Q},[Q]),D.useEffect(()=>{Me.current=W},[W]),D.useEffect(()=>{je.current=H,Ge()},[H,Ge]),D.useEffect(()=>{Ne.current=N},[N]),D.useEffect(()=>{!j&&X!==null&&Z(null)},[j,X,Z]),D.useEffect(()=>{!W&&X!==null&&Z(null)},[W,X,Z]);let $=D.useCallback(()=>{ke.current?.(),ke.current=null,Ae.current=null,Re.current=null,Y(!1)},[]);D.useEffect(()=>()=>{$(),Me.current=null},[$]);let tt=D.useCallback((e,t,n)=>{if(!n)return;let r=`${He.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{n as t}from"./runtime-fetch-CiqQd__Y.js";import{nt as n,rt as r,tt as i}from"./vendor-base-ui-CnHfUmDN.js";import{_ as a}from"./useUIStore-Dfx6TKvi.js";import{n as o}from"./vendor-react-DLPElpoQ.js";import{a as s,i as c}from"./vendor-pierre-diffs-DX7XTPG3.js";import{n as l}from"./vendor-reactuses-core-Dq5ocTF8.js";import{f as u,r as d,t as f}from"./button-CUwjpv-i.js";import{n as p,t as m}from"./dialog-PjKWayIU.js";import{n as h}from"./Icon-BdzPRCSy.js";import{n as g,t as _}from"./useThemeSystem-DMzWVJaW.js";import{i as v,n as y,s as b}from"./markdownTheme-DM5h1i18.js";import{i as x,t as S}from"./appThemeRegistry-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{n as t}from"./runtime-fetch-CiqQd__Y.js";import{nt as n,rt as r,tt as i}from"./vendor-base-ui-CnHfUmDN.js";import{_ as a}from"./useUIStore-Dfx6TKvi.js";import{n as o}from"./vendor-react-DLPElpoQ.js";import{a as s,i as c}from"./vendor-pierre-diffs-DX7XTPG3.js";import{n as l}from"./vendor-reactuses-core-Dq5ocTF8.js";import{f as u,r as d,t as f}from"./button-CUwjpv-i.js";import{n as p,t as m}from"./dialog-PjKWayIU.js";import{n as h}from"./Icon-BdzPRCSy.js";import{n as g,t as _}from"./useThemeSystem-DMzWVJaW.js";import{i as v,n as y,s as b}from"./markdownTheme-DM5h1i18.js";import{i as x,t as S}from"./appThemeRegistry-lhAKuFFB.js";import{n as ee}from"./MarkdownRenderer-DA08bZsM.js";import{l as C}from"./markdown-worker-bS5OgGO3.js";import{n as te}from"./useEffectiveDirectory-CF16bcpx.js";import{s as w}from"./imageSource-BpUsiwFd.js";import{_ as T,d as E,f as ne,g as D,h as re,l as O,m as k,n as A,p as j,r as M,s as N,t as P,u as F}from"./useWorkerHighlightedLines-DYVg-cuB.js";import{t as I}from"./vendor-tanstack-react-virtual-tlDgH6PG.js";var ie=e(i(),1),L=o(),R=e(r(),1),z=n(),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}=g(),u;t[0]===l?u=t[1]:(u=y(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=P(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 m;return t[19]!==p||t[20]!==o||t[21]!==n||t[22]!==s||t[23]!==c||t[24]!==d?(m=(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]=m):m=t[25],m});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=I({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}=u(),a=R.useRef(null),[o,s]=R.useState(null),c=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]),l=R.useCallback(()=>{a.current?.expandAll()},[]),d=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})]})}):c===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)(f,{variant:`ghost`,size:`xs`,onClick:l,className:`gap-1 text-xs text-muted-foreground`,children:[(0,z.jsx)(h,{name:`arrow-down-s`,className:`h-3 w-3`}),i(`jsonTreeView.actions.expandAll`)]}),(0,z.jsxs)(f,{variant:`ghost`,size:`xs`,onClick:d,className:`gap-1 text-xs text-muted-foreground`,children:[(0,z.jsx)(h,{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)(M,{ref:a,data:c,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)(h,{name:`brain-ai-3`,className:t}):n===`image-preview`?(0,z.jsx)(h,{name:`file-image`,className:t}):n===`mermaid-preview`?(0,z.jsx)(h,{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)(h,{name:`pencil-ai`,className:t}):n===`write`||n===`create`||n===`file_write`||n===`read`||n===`view`||n===`file_read`||n===`cat`?(0,z.jsx)(h,{name:`file-pdf`,className:t}):n===`bash`||n===`shell`||n===`cmd`||n===`terminal`?(0,z.jsx)(h,{name:`terminal-box`,className:t}):n===`list`||n===`ls`||n===`dir`||n===`list_files`?(0,z.jsx)(h,{name:`folder-6`,className:t}):n===`search`||n===`grep`||n===`find`||n===`ripgrep`?(0,z.jsx)(h,{name:`search`,className:t}):n===`glob`?(0,z.jsx)(h,{name:`file-search`,className:t}):n===`fetch`||n===`curl`||n===`wget`||n===`webfetch`?(0,z.jsx)(h,{name:`global`,className:t}):n===`web-search`||n===`websearch`||n===`search_web`||n===`google`||n===`bing`||n===`duckduckgo`?(0,z.jsx)(h,{name:`search`,className:t}):n===`todowrite`||n===`todoread`?(0,z.jsx)(h,{name:`list-check-3`,className:t}):n.startsWith(`git`)?(0,z.jsx)(h,{name:`git-branch`,className:t}):(0,z.jsx)(h,{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] {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{a as t}from"./vendor-zustand-DzRqcymP.js";import{rt as n}from"./vendor-base-ui-CnHfUmDN.js";import{n as r,t as i}from"./platform-wu6wSDfg.js";import{n as a}from"./vendor-react-DLPElpoQ.js";import{a as o,n as s}from"./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js";import{r as c}from"./vendor-pierre-diffs-DX7XTPG3.js";import{n as l}from"./vendor-reactuses-core-Dq5ocTF8.js";import{o as u}from"./useMobileNavigationStore-BjIptzTV.js";import{c as d,l as f}from"./dialog-PjKWayIU.js";var p=e(n(),1),m=a(),h=`openchamber.iosNativeUi`,g=()=>{if(typeof window>`u`)return!1;try{return window.localStorage.getItem(h)===`1`}catch{return!1}},_=e=>{if(!(typeof window>`u`))try{e?window.localStorage.setItem(h,`1`):window.localStorage.removeItem(h)}catch{}},v=t(e=>({enabled:g(),setEnabled:t=>{_(t),e({enabled:t})}})),y=()=>v.getState().enabled,ee=()=>v(ne),te=()=>r()&&i()===`ios`;function ne(e){return e.enabled}var re=`oc-native-ios-composer`,b=`--oc-native-composer-height`,x=`--oc-native-composer-accessory`,ie=33554432,S=`OpenChamberComposer`,C=`#22c55e`,w=32,T=()=>({open:!1,highlightedIndex:0,query:``,highlightColor:``,rows:[]}),ae=()=>({text:``,placeholder:``,modelLabel:``,modelVariantLabel:``,modelIcon:``,canSend:!1,canAbort:!1,attachmentCount:0,attachmentPreviews:[],citationRanges:[],chipRanges:[],appearance:`dark`,attachAria:``,attachTitle:``,attachPhotosLabel:``,attachFilesLabel:``,attachCancelLabel:``,sendAria:``,queueAria:``,stopAria:``,modelAria:``,agentAria:``,agentLabel:``,agentColor:C,agentIdenticon:Array.from({length:25},()=>0),suppressed:!0,showScrollToBottom:!1,scrollAria:``,autocomplete:T()}),oe=o(S),se=e=>e.isCapacitor&&e.platform===`ios`&&e.pluginAvailable&&e.isMobile&&e.nativeUiEnabled!==!1;function ce(e){return typeof window>`u`?!1:se({isCapacitor:r(),platform:i(),pluginAvailable:s.isPluginAvailable(S),isMobile:e,nativeUiEnabled:y()})}var le=e=>e.classList.contains(`dark`)?`dark`:`light`,ue=e=>{let t=e?.height;return typeof t!=`number`||!Number.isFinite(t)||t<0?0:t},de=(e,t)=>{if(!(t>0)){e.style.removeProperty(b);return}e.style.setProperty(b,`${Math.round(t)}px`)},fe=(e,t)=>{if(!(t>0)){e.style.removeProperty(x);return}e.style.setProperty(x,`${Math.round(t)}px`)},E=(e,t)=>{e.classList.toggle(re,t),t||(e.style.removeProperty(b),e.style.removeProperty(x))},pe=e=>d(e).flat().map(e=>+!!e),D=new Map,O=null,k=e=>{let t=D.get(e);if(t!==void 0)return t;if(typeof document>`u`||typeof getComputedStyle>`u`)return C;!O&&typeof MutationObserver<`u`&&(O=new MutationObserver(()=>{D.clear()}),O.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`,`style`]}));let n=getComputedStyle(document.documentElement).getPropertyValue(e).trim(),r=document.createElement(`span`);r.style.color=n||`var(${e})`,document.documentElement.appendChild(r);let i=getComputedStyle(r).color;r.remove();let a=/rgba?\(\s*([\d.]+)(?:\s*,\s*|\s+)([\d.]+)(?:\s*,\s*|\s+)([\d.]+)/.exec(i);if(!a)return D.set(e,C),C;let o=e=>Math.max(0,Math.min(255,Math.round(Number(e)))).toString(16).padStart(2,`0`),s=`#${o(a[1])}${o(a[2])}${o(a[3])}`;return D.set(e,s),s},me=e=>k(f(e).var),A=(e,t)=>e.text===t.text&&e.placeholder===t.placeholder&&e.modelLabel===t.modelLabel&&e.modelVariantLabel===t.modelVariantLabel&&e.modelIcon===t.modelIcon&&e.canSend===t.canSend&&e.canAbort===t.canAbort&&e.attachmentCount===t.attachmentCount&&M(e.attachmentPreviews,t.attachmentPreviews)&&N(e.citationRanges,t.citationRanges)&&P(e.chipRanges,t.chipRanges)&&e.appearance===t.appearance&&e.attachAria===t.attachAria&&e.attachTitle===t.attachTitle&&e.attachPhotosLabel===t.attachPhotosLabel&&e.attachFilesLabel===t.attachFilesLabel&&e.attachCancelLabel===t.attachCancelLabel&&e.sendAria===t.sendAria&&e.queueAria===t.queueAria&&e.stopAria===t.stopAria&&e.modelAria===t.modelAria&&e.agentAria===t.agentAria&&e.agentLabel===t.agentLabel&&e.agentColor===t.agentColor&&e.agentIdenticon.join(``)===t.agentIdenticon.join(``)&&e.suppressed===t.suppressed&&e.showScrollToBottom===t.showScrollToBottom&&e.scrollAria===t.scrollAria&&j(e.autocomplete,t.autocomplete),j=(e,t)=>e.open===t.open&&e.highlightedIndex===t.highlightedIndex&&e.query===t.query&&e.highlightColor===t.highlightColor&&e.rows.length===t.rows.length&&e.rows.every((e,n)=>{let r=t.rows[n];return!!(r&&e.id===r.id&&e.title===r.title&&e.subtitle===r.subtitle&&e.badge===r.badge&&e.iconBase64===r.iconBase64)}),M=(e,t)=>e.length===t.length&&e.every((e,n)=>{let r=t[n];return!!(r&&e.id===r.id&&e.filename===r.filename&&e.mime===r.mime&&e.thumbnailBase64===r.thumbnailBase64&&e.removeAria===r.removeAria)}),N=(e,t)=>e.length===t.length&&e.every((e,n)=>e.start===t[n]?.start&&e.end===t[n]?.end),P=(e,t)=>e.length===t.length&&e.every((e,n)=>{let r=t[n];return!!(r&&e.start===r.start&&e.end===r.end&&e.triggerLength===r.triggerLength&&e.color===r.color)}),he=(e,t)=>{if(!e||!t||t.length===0)return[];let n=[],r=0;for(let e of t){let t=r;r+=e.text.length;let i=e.visual;if(!i)continue;let a=i.trigger.length;a<1||t+a>r||i.icon&&n.push({start:t,end:r,triggerLength:a,iconName:i.icon})}return n},ge=(e,t)=>e.map(e=>({start:e.start,end:e.end,triggerLength:e.triggerLength,color:t})),_e=e=>e.map(e=>`${e.id}:${e.filename}:${e.mimeType}:${e.dataUrl?.length??0}`).join(`|`),ve=e=>{let t=e?.id;return typeof t==`string`&&t.trim()?t:``},F=e=>{if(typeof e==`number`&&Number.isFinite(e)&&e>=0)return Math.floor(e);if(typeof e==`string`&&e.trim()){let t=Number(e);if(Number.isFinite(t)&&t>=0)return Math.floor(t)}return null},ye=e=>{let t=F(e?.selectionStart);if(t===null)return null;let n=F(e?.selectionEnd);return{start:t,end:n!==null&&n>=t?n:t}},be=e=>F(e?.index)??0,xe=(e,t)=>{let n=Math.max(0,e);return typeof t!=`number`||!Number.isFinite(t)?n:Math.max(0,Math.min(Math.floor(t),n))},Se=e=>e.nextText===e.nativeOwnedText?{omitText:!0,forceText:!1}:e.nextText.length===0&&e.nativeOwnedText.length>0||e.preset?{omitText:!1,forceText:!0}:e.echoingNative?{omitText:!0,forceText:!1}:{omitText:!1,forceText:!0},Ce=e=>e.replacedText!==null&&e.incoming===e.replacedText,we=e=>setTimeout(e,0),Te=e=>{e.applyDocument(e.text),we(e.submit)},I=(e,t)=>e===t,Ee=(e,t,n,r)=>{if(n.omitText&&e&&A(e,t))return null;let i={};if(n.omitText||(i.text=t.text,n.forceText&&(i.forceText=!0),n.forceText&&typeof r?.caret==`number`&&Number.isFinite(r.caret)&&(i.caret=Math.max(0,Math.floor(r.caret)))),!e){let{text:e,...n}=t;return Object.assign(i,n),i}let a=(n,r)=>{r(e[n],t[n])||(i[n]=t[n])};return a(`placeholder`,I),a(`modelLabel`,I),a(`modelVariantLabel`,I),a(`modelIcon`,I),a(`canSend`,I),a(`canAbort`,I),a(`attachmentCount`,I),a(`attachmentPreviews`,M),a(`citationRanges`,N),a(`chipRanges`,P),a(`appearance`,I),a(`attachAria`,I),a(`attachTitle`,I),a(`attachPhotosLabel`,I),a(`attachFilesLabel`,I),a(`attachCancelLabel`,I),a(`sendAria`,I),a(`queueAria`,I),a(`stopAria`,I),a(`modelAria`,I),a(`agentAria`,I),a(`agentLabel`,I),a(`agentColor`,I),a(`agentIdenticon`,(e,t)=>e.join(``)===t.join(``)),a(`suppressed`,I),a(`showScrollToBottom`,I),a(`scrollAria`,I),a(`autocomplete`,j),Object.keys(i).length===0?null:i},De=e=>{let t=Array.isArray(e?.skipped)?e.skipped:[],n=[];for(let e of t){if(!e||typeof e!=`object`)continue;let t=e.name;typeof t==`string`&&t.trim()&&n.push(t)}return n},Oe=e=>{try{let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}catch{return null}},ke=(e,t=ie)=>{let n=Array.isArray(e?.files)?e.files:[],r=[];for(let e of n){if(!e||typeof e!=`object`)continue;let n=e;if(typeof n.dataBase64!=`string`||n.dataBase64.length===0)continue;let i=Oe(n.dataBase64);if(!i||i.byteLength===0||i.byteLength>t)continue;let a=typeof n.name==`string`&&n.name.trim()?n.name:`file`,o=typeof n.mime==`string`&&n.mime.trim()?n.mime:`application/octet-stream`;r.push(new File([new Uint8Array(i)],a,{type:o}))}return r},L=80,Ae=e=>typeof document>`u`||!e||!e.startsWith(`data:image/`)?Promise.resolve(null):new Promise(t=>{let n=new Image;n.decoding=`async`,n.onload=()=>{try{let e=document.createElement(`canvas`);e.width=L,e.height=L;let r=e.getContext(`2d`);if(!r){t(null);return}r.clearRect(0,0,L,L),r.drawImage(n,0,0,L,L);let i=e.toDataURL(`image/jpeg`,.72),a=i.indexOf(`,`);t(a>=0?i.slice(a+1):null)}catch{t(null)}},n.onerror=()=>t(null),n.src=e}),je=e=>typeof document>`u`||!e?Promise.resolve(null):new Promise(t=>{let n=new Image;n.decoding=`async`,n.onload=()=>{try{let e=document.createElement(`canvas`);e.width=w,e.height=w;let r=e.getContext(`2d`);if(!r){t(null);return}r.clearRect(0,0,w,w),r.drawImage(n,0,0,w,w);let i=e.toDataURL(`image/png`),a=i.indexOf(`,`);t(a>=0?i.slice(a+1):null)}catch{t(null)}},n.onerror=()=>t(null),n.src=e}),R=()=>oe,z=((e=R)=>{let t=0,n=null,r=[],i=null,a=``,o=!1,s=!1,c=()=>{n!==null&&(clearTimeout(n),n=null)},l=(e,...t)=>{let n=i;n&&n[e](...t)},u=async()=>{if(r.length>0)return;let t=e(),n=await Promise.all([t.addListener(`textChanged`,e=>{let t=typeof e.text==`string`?e.text:``;a=t,l(`onText`,t,e.composing===!0,ye(e))}),t.addListener(`send`,e=>{let t=typeof e.text==`string`?e.text:a;a=t,l(`onSend`,t)}),t.addListener(`abort`,()=>{l(`onAbort`)}),t.addListener(`attach`,()=>{l(`onAttach`)}),t.addListener(`filesPicked`,t=>{l(`onFiles`,ke(t),De(t)),e().focus()}),t.addListener(`removeAttachment`,e=>{let t=ve(e);t&&l(`onRemoveAttachment`,t)}),t.addListener(`openModel`,()=>{l(`onOpenModel`)}),t.addListener(`cycleAgent`,()=>{l(`onCycleAgent`)}),t.addListener(`openAgent`,()=>{l(`onOpenAgent`)}),t.addListener(`heightChanged`,e=>{l(`onHeight`,ue(e))}),t.addListener(`scrollToBottom`,()=>{l(`onScrollToBottom`)}),t.addListener(`autocompleteAccept`,e=>{l(`onAutocompleteAccept`,be(e))}),t.addListener(`autocompleteDismiss`,()=>{l(`onAutocompleteDismiss`)})]);if(r.length>0){for(let e of n)e.remove();return}r=n},d=n=>{t>0||(i=null,o=!1,E(n,!1),e().dismiss())};return{bind(e){i=e},rememberText(e){a=e},rememberState(e){a=e.text},conceal(){o||t===0||(o=!0,e().hide())},reveal(){!o||t===0||(o=!1,e().show())},async warm(){s||t>0||(s=!0,await e().present(ae()))},async retain(n,i){c(),t+=1,o=!1,s=!0,a=i.text,E(n,!0),r.length===0&&await u(),await e().present(i)},release(e){t=Math.max(0,t-1),!(t>0)&&(c(),n=setTimeout(()=>{n=null,d(e)},0))},shutdown(n=document.documentElement){c(),t=0,s=!1,o=!1,i=null,E(n,!1),e().dismiss()},snapshot(){return{retainCount:t,listenerCount:r.length,hidePending:n!==null,concealed:o,warmed:s}}}})(),Me=()=>o(`OpenChamberNavigation`),B=e=>e?.kind===`chat`||e?.kind===`draft`,V=e=>e?e.kind===`draft`||e.kind===`chat`&&e.routes.length<=1:!1,Ne=(e,t)=>B(e)&&!B(t),Pe=(e=z)=>{V(u.getState().secondary)&&e.conceal()},Fe=(e=z)=>{let t=u.subscribe((t,n)=>{Ne(n.secondary,t.secondary)&&e.conceal()}),n=[],r=!1;return s.getPlatform()===`ios`&&(async()=>{let t=Me(),i=await t.addListener(`backStarted`,()=>{V(u.getState().secondary)&&e.conceal()}),a=await t.addListener(`backCancelled`,()=>{e.reveal()});if(r){i.remove(),a.remove();return}n=[i,a]})(),()=>{r=!0,t();for(let e of n)e.remove();n=[]}},H=`__openchamberMobileBackRoute`,Ie=()=>typeof window>`u`||r()?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)}},U=e=>{let t=e?.[H];return typeof t==`number`&&Number.isFinite(t)?t:null},W=new class{routes=[];listeners=new Set;nextToken=1;history;removeHistoryListener=null;programmaticHistoryBackToken=null;pendingHistoryRemovals=new Map;animatedBackDriver=null;presentationCancelDriver=null;constructor(e=Ie()){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&&U(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()??{},[H]: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&&U(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||U(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&&U(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&&U(e)!==t.token&&t.onBack()===!1&&this.history&&this.history.pushState({...this.history.currentState()??{},[H]:t.token})}))}disposeHistoryListener(){this.removeHistoryListener?.(),this.removeHistoryListener=null,this.programmaticHistoryBackToken=null,this.pendingHistoryRemovals.clear()}notify(){this.listeners.forEach(e=>e())}},Le=e=>{let t=(0,m.c)(8),{id:n,active:r,layer:i,onBack:a,surfaceRef:o,underlayRef:s}=e,c=i===void 0?`root`:i,u=l(a),d,f;t[0]!==r||t[1]!==u||t[2]!==n||t[3]!==c||t[4]!==o||t[5]!==s?(d=()=>{if(r)return W.register({id:n,layer:c,onBack:u,getSurface:()=>o.current,getUnderlay:()=>s?.current??null})},f=[r,u,n,c,o,s],t[0]=r,t[1]=u,t[2]=n,t[3]=c,t[4]=o,t[5]=s,t[6]=d,t[7]=f):(d=t[6],f=t[7]),p.useEffect(d,f)},G=o(`OpenChamberNavigation`),K=e=>Math.min(1,Math.max(0,Number.isFinite(e)?e:0)),Re=(e,t)=>!e||!t?!1:e.onBack()!==!1,q=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)))},J=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??``)},Y=(e,t)=>{let n=K(t),{surface:r}=e;r.style.transform=`translate3d(${n*100}%, 0, 0)`},ze=e=>!e.surfaceConnected||e.topRouteToken!==e.routeToken||e.routeSurface!==e.outgoingSurface,Be=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)`},Ve=async(e,t,n=typeof window<`u`&&window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches,r=q({progress:Number.parseFloat(e.style.transform.match(/translate3d\(([-\d.]+)%/)?.[1]??`0`)/100,commit:t}))=>Be(e,t?100:0,r,n),He=class{pending=0;enqueue(){this.pending+=1}take(){return this.pending!==0&&(--this.pending,!0)}clear(){this.pending=0}},Ue=e=>{let t=(0,m.c)(4),{enabled:n,rootRoutesBlocked:i}=e,a,o;t[0]!==n||t[1]!==i?(a=()=>{if(!n||!r()||s.getPlatform()===`web`)return;let e=!1,t=null,a=null,o=0,c=0,l=0,u=new He,d=[],f=e=>!!e&&(!i||e?.layer===`overlay`),p=()=>{let e=f(W.getTopRoute());G.setEnabled({enabled:e}).catch(We)},m=()=>{if(W.cancelPresentation(),a)return;let e=W.getTopRoute();if(!f(e))return;let n=e.getSurface();if(!n)return;n.getAnimations().forEach(Ge),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(Ke),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},Y(t,0)},h=e=>{c=K(e),!o&&(o=window.requestAnimationFrame(()=>{o=0,t&&Y(t,c)}))},g=qe,_=(n,r,i)=>{if(n&&Pe(),a)return n&&f(W.getTopRoute())?(u.enqueue(),!0):!1;o&&=(window.cancelAnimationFrame(o),0),t||m(),t&&r!==void 0&&Y(t,r);let s=t,d=l;if(t=null,!s){if(!n)return!1;let e=W.getTopRoute();return Re(e,f(e))}a=s;let p=window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches??!1,h=q({progress:K(r??c),commit:n,velocityX:i,viewportWidth:window.innerWidth});return Ve(s.surface,n,p,h).then(async()=>{d===l&&(!e&&n&&(s.route.onBack(),await g(s)),d===l&&(J(s),a===s&&(a=null),!e&&u.take()&&_(!0,0,0)))}),!0},v=W.setAnimatedBackDriver(e=>e!==W.getTopRoute()||!f(e)?!1:_(!0,0,0)),y=W.subscribe(p);return(async()=>{let t=await G.addListener(`backStarted`,m),n=await G.addListener(`backProgressed`,e=>h(e.progress??0)),r=await G.addListener(`backCancelled`,e=>_(!1,e.progress,e.velocityX)),i=await G.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(Je),p(),()=>{e=!0,l+=1,u.clear(),y(),v(),o&&window.cancelAnimationFrame(o),t&&J(t),a&&(a.surface.getAnimations().forEach(Ye),a.underlay?.getAnimations().forEach(Xe),J(a)),t=null,a=null,G.setEnabled({enabled:!1}).catch(Ze),d.forEach(Qe)}},o=[n,i],t[0]=n,t[1]=i,t[2]=a,t[3]=o):(a=t[2],o=t[3]),p.useEffect(a,o)};function We(){}function Ge(e){return e.cancel()}function Ke(e){return e.cancel()}function qe(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=W.getTopRoute();return ze({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=W.subscribe(()=>{o()&&a()});s()})}function Je(){}function Ye(e){return e.cancel()}function Xe(e){return e.cancel()}function Ze(){}function Qe(e){e.remove()}var $e=e=>/^#[0-9a-fA-F]{6}$/.test(e),et=e=>/^#[0-9a-fA-F]{8}$/.test(e),tt=(e,t)=>/^[0-9a-fA-F]{2}$/.test(t)?$e(e)?`${e}${t}`:et(e)?`${e.slice(0,7)}${t}`:e:e,X=(e,t)=>typeof e==`string`&&e.trim().length>0?e:t,nt=e=>{let t=e.colors.syntax.base,n=e.colors.syntax.tokens??{},r=(e,t)=>X(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`],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}}]},rt=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=X(a.diffAddedBackground,r.successBackground),s=X(a.diffRemovedBackground,r.errorBackground);return{"editor.background":t.background,"editor.foreground":t.foreground,"editor.hoverHighlightBackground":X(n.hover,t.subtle),"editor.lineHighlightBackground":t.muted,"editor.selectionBackground":n.selection,"editor.selectionHighlightBackground":n.selection,"editor.findMatchBackground":i.type,"editor.findMatchHighlightBackground":tt(i.type,`cc`),"editor.findRangeHighlightBackground":t.muted,"editor.inactiveSelectionBackground":t.elevated,"editor.lineHighlightBorder":t.elevated,"editor.rangeHighlightBackground":X(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":X(a.lineNumberActive,t.foreground),"editorLineNumber.foreground":X(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":X(a.diffAdded,r.success),"merge.incomingHeaderBackground":r.info,"merge.incomingContentBackground":X(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":X(a.diffRemoved,r.error),"terminal.ansiGreen":X(a.diffAdded,r.success),"terminal.ansiYellow":r.warning,"terminal.ansiBlue":X(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":X(e.colors.primary.foreground,t.background),"badge.foreground":X(e.colors.primary.foreground,t.background),"activityBarBadge.foreground":X(e.colors.primary.foreground,t.background)}};function it(e){return{name:e.metadata.name,type:e.metadata.variant,colors:rt(e),tokenColors:nt(e)}}var at=e=>/^#[0-9a-fA-F]{8}$/.test(e),Z=e=>at(e)?e.slice(0,7):e;function ot(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 Q=new Map,$=new Set,st=(e,t)=>{let n=e.colors?.[`editor.background`],r=e.colors?.[`editor.foreground`],i=n?Z(n):void 0,a=r?Z(r):void 0;if(!i||!a)throw Error(`Theme "${t}" is missing editor.background/editor.foreground`);let o=e.tokenColors??[];return ot({...e,name:t,fg:a,bg:i,settings:o},t)},ct=e=>it(e),lt=e=>{let t=Q.get(e.metadata.id);if(t)return t;let n=st(ct(e),e.metadata.id);return Q.set(e.metadata.id,n),n},ut=e=>{let t=e.metadata.id;if($.has(t))return;let n=lt(e);c(t,async()=>n),$.add(t)};export{Ce as A,pe as C,k as D,xe as E,y as M,ee as N,Se as O,v as P,le as S,je as T,Te as _,Ue as a,A as b,b as c,_e as d,ge as f,R as g,T as h,Le as i,te as j,E as k,fe as l,ce as m,lt as n,Fe as o,Ee as p,W as r,z as s,ut as t,de as u,j as v,Ae as w,me as x,he as y};
|
|
1
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{a as t}from"./vendor-zustand-DzRqcymP.js";import{rt as n}from"./vendor-base-ui-CnHfUmDN.js";import{n as r,t as i}from"./platform-wu6wSDfg.js";import{n as a}from"./vendor-react-DLPElpoQ.js";import{a as o,n as s}from"./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js";import{r as c}from"./vendor-pierre-diffs-DX7XTPG3.js";import{n as l}from"./vendor-reactuses-core-Dq5ocTF8.js";import{o as u}from"./useMobileNavigationStore-DBML5LIl.js";import{c as d,l as f}from"./dialog-PjKWayIU.js";var p=e(n(),1),m=a(),h=`openchamber.iosNativeUi`,g=()=>{if(typeof window>`u`)return!1;try{return window.localStorage.getItem(h)===`1`}catch{return!1}},_=e=>{if(!(typeof window>`u`))try{e?window.localStorage.setItem(h,`1`):window.localStorage.removeItem(h)}catch{}},v=t(e=>({enabled:g(),setEnabled:t=>{_(t),e({enabled:t})}})),y=()=>v.getState().enabled,ee=()=>v(ne),te=()=>r()&&i()===`ios`;function ne(e){return e.enabled}var re=`oc-native-ios-composer`,b=`--oc-native-composer-height`,x=`--oc-native-composer-accessory`,ie=33554432,S=`OpenChamberComposer`,C=`#22c55e`,w=32,T=()=>({open:!1,highlightedIndex:0,query:``,highlightColor:``,rows:[]}),ae=()=>({text:``,placeholder:``,modelLabel:``,modelVariantLabel:``,modelIcon:``,canSend:!1,canAbort:!1,attachmentCount:0,attachmentPreviews:[],citationRanges:[],chipRanges:[],appearance:`dark`,attachAria:``,attachTitle:``,attachPhotosLabel:``,attachFilesLabel:``,attachCancelLabel:``,sendAria:``,queueAria:``,stopAria:``,modelAria:``,agentAria:``,agentLabel:``,agentColor:C,agentIdenticon:Array.from({length:25},()=>0),suppressed:!0,showScrollToBottom:!1,scrollAria:``,autocomplete:T()}),oe=o(S),se=e=>e.isCapacitor&&e.platform===`ios`&&e.pluginAvailable&&e.isMobile&&e.nativeUiEnabled!==!1;function ce(e){return typeof window>`u`?!1:se({isCapacitor:r(),platform:i(),pluginAvailable:s.isPluginAvailable(S),isMobile:e,nativeUiEnabled:y()})}var le=e=>e.classList.contains(`dark`)?`dark`:`light`,ue=e=>{let t=e?.height;return typeof t!=`number`||!Number.isFinite(t)||t<0?0:t},de=(e,t)=>{if(!(t>0)){e.style.removeProperty(b);return}e.style.setProperty(b,`${Math.round(t)}px`)},fe=(e,t)=>{if(!(t>0)){e.style.removeProperty(x);return}e.style.setProperty(x,`${Math.round(t)}px`)},E=(e,t)=>{e.classList.toggle(re,t),t||(e.style.removeProperty(b),e.style.removeProperty(x))},pe=e=>d(e).flat().map(e=>+!!e),D=new Map,O=null,k=e=>{let t=D.get(e);if(t!==void 0)return t;if(typeof document>`u`||typeof getComputedStyle>`u`)return C;!O&&typeof MutationObserver<`u`&&(O=new MutationObserver(()=>{D.clear()}),O.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`,`style`]}));let n=getComputedStyle(document.documentElement).getPropertyValue(e).trim(),r=document.createElement(`span`);r.style.color=n||`var(${e})`,document.documentElement.appendChild(r);let i=getComputedStyle(r).color;r.remove();let a=/rgba?\(\s*([\d.]+)(?:\s*,\s*|\s+)([\d.]+)(?:\s*,\s*|\s+)([\d.]+)/.exec(i);if(!a)return D.set(e,C),C;let o=e=>Math.max(0,Math.min(255,Math.round(Number(e)))).toString(16).padStart(2,`0`),s=`#${o(a[1])}${o(a[2])}${o(a[3])}`;return D.set(e,s),s},me=e=>k(f(e).var),A=(e,t)=>e.text===t.text&&e.placeholder===t.placeholder&&e.modelLabel===t.modelLabel&&e.modelVariantLabel===t.modelVariantLabel&&e.modelIcon===t.modelIcon&&e.canSend===t.canSend&&e.canAbort===t.canAbort&&e.attachmentCount===t.attachmentCount&&M(e.attachmentPreviews,t.attachmentPreviews)&&N(e.citationRanges,t.citationRanges)&&P(e.chipRanges,t.chipRanges)&&e.appearance===t.appearance&&e.attachAria===t.attachAria&&e.attachTitle===t.attachTitle&&e.attachPhotosLabel===t.attachPhotosLabel&&e.attachFilesLabel===t.attachFilesLabel&&e.attachCancelLabel===t.attachCancelLabel&&e.sendAria===t.sendAria&&e.queueAria===t.queueAria&&e.stopAria===t.stopAria&&e.modelAria===t.modelAria&&e.agentAria===t.agentAria&&e.agentLabel===t.agentLabel&&e.agentColor===t.agentColor&&e.agentIdenticon.join(``)===t.agentIdenticon.join(``)&&e.suppressed===t.suppressed&&e.showScrollToBottom===t.showScrollToBottom&&e.scrollAria===t.scrollAria&&j(e.autocomplete,t.autocomplete),j=(e,t)=>e.open===t.open&&e.highlightedIndex===t.highlightedIndex&&e.query===t.query&&e.highlightColor===t.highlightColor&&e.rows.length===t.rows.length&&e.rows.every((e,n)=>{let r=t.rows[n];return!!(r&&e.id===r.id&&e.title===r.title&&e.subtitle===r.subtitle&&e.badge===r.badge&&e.iconBase64===r.iconBase64)}),M=(e,t)=>e.length===t.length&&e.every((e,n)=>{let r=t[n];return!!(r&&e.id===r.id&&e.filename===r.filename&&e.mime===r.mime&&e.thumbnailBase64===r.thumbnailBase64&&e.removeAria===r.removeAria)}),N=(e,t)=>e.length===t.length&&e.every((e,n)=>e.start===t[n]?.start&&e.end===t[n]?.end),P=(e,t)=>e.length===t.length&&e.every((e,n)=>{let r=t[n];return!!(r&&e.start===r.start&&e.end===r.end&&e.triggerLength===r.triggerLength&&e.color===r.color)}),he=(e,t)=>{if(!e||!t||t.length===0)return[];let n=[],r=0;for(let e of t){let t=r;r+=e.text.length;let i=e.visual;if(!i)continue;let a=i.trigger.length;a<1||t+a>r||i.icon&&n.push({start:t,end:r,triggerLength:a,iconName:i.icon})}return n},ge=(e,t)=>e.map(e=>({start:e.start,end:e.end,triggerLength:e.triggerLength,color:t})),_e=e=>e.map(e=>`${e.id}:${e.filename}:${e.mimeType}:${e.dataUrl?.length??0}`).join(`|`),ve=e=>{let t=e?.id;return typeof t==`string`&&t.trim()?t:``},F=e=>{if(typeof e==`number`&&Number.isFinite(e)&&e>=0)return Math.floor(e);if(typeof e==`string`&&e.trim()){let t=Number(e);if(Number.isFinite(t)&&t>=0)return Math.floor(t)}return null},ye=e=>{let t=F(e?.selectionStart);if(t===null)return null;let n=F(e?.selectionEnd);return{start:t,end:n!==null&&n>=t?n:t}},be=e=>F(e?.index)??0,xe=(e,t)=>{let n=Math.max(0,e);return typeof t!=`number`||!Number.isFinite(t)?n:Math.max(0,Math.min(Math.floor(t),n))},Se=e=>e.nextText===e.nativeOwnedText?{omitText:!0,forceText:!1}:e.nextText.length===0&&e.nativeOwnedText.length>0||e.preset?{omitText:!1,forceText:!0}:e.echoingNative?{omitText:!0,forceText:!1}:{omitText:!1,forceText:!0},Ce=e=>e.replacedText!==null&&e.incoming===e.replacedText,we=e=>setTimeout(e,0),Te=e=>{e.applyDocument(e.text),we(e.submit)},I=(e,t)=>e===t,Ee=(e,t,n,r)=>{if(n.omitText&&e&&A(e,t))return null;let i={};if(n.omitText||(i.text=t.text,n.forceText&&(i.forceText=!0),n.forceText&&typeof r?.caret==`number`&&Number.isFinite(r.caret)&&(i.caret=Math.max(0,Math.floor(r.caret)))),!e){let{text:e,...n}=t;return Object.assign(i,n),i}let a=(n,r)=>{r(e[n],t[n])||(i[n]=t[n])};return a(`placeholder`,I),a(`modelLabel`,I),a(`modelVariantLabel`,I),a(`modelIcon`,I),a(`canSend`,I),a(`canAbort`,I),a(`attachmentCount`,I),a(`attachmentPreviews`,M),a(`citationRanges`,N),a(`chipRanges`,P),a(`appearance`,I),a(`attachAria`,I),a(`attachTitle`,I),a(`attachPhotosLabel`,I),a(`attachFilesLabel`,I),a(`attachCancelLabel`,I),a(`sendAria`,I),a(`queueAria`,I),a(`stopAria`,I),a(`modelAria`,I),a(`agentAria`,I),a(`agentLabel`,I),a(`agentColor`,I),a(`agentIdenticon`,(e,t)=>e.join(``)===t.join(``)),a(`suppressed`,I),a(`showScrollToBottom`,I),a(`scrollAria`,I),a(`autocomplete`,j),Object.keys(i).length===0?null:i},De=e=>{let t=Array.isArray(e?.skipped)?e.skipped:[],n=[];for(let e of t){if(!e||typeof e!=`object`)continue;let t=e.name;typeof t==`string`&&t.trim()&&n.push(t)}return n},Oe=e=>{try{let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}catch{return null}},ke=(e,t=ie)=>{let n=Array.isArray(e?.files)?e.files:[],r=[];for(let e of n){if(!e||typeof e!=`object`)continue;let n=e;if(typeof n.dataBase64!=`string`||n.dataBase64.length===0)continue;let i=Oe(n.dataBase64);if(!i||i.byteLength===0||i.byteLength>t)continue;let a=typeof n.name==`string`&&n.name.trim()?n.name:`file`,o=typeof n.mime==`string`&&n.mime.trim()?n.mime:`application/octet-stream`;r.push(new File([new Uint8Array(i)],a,{type:o}))}return r},L=80,Ae=e=>typeof document>`u`||!e||!e.startsWith(`data:image/`)?Promise.resolve(null):new Promise(t=>{let n=new Image;n.decoding=`async`,n.onload=()=>{try{let e=document.createElement(`canvas`);e.width=L,e.height=L;let r=e.getContext(`2d`);if(!r){t(null);return}r.clearRect(0,0,L,L),r.drawImage(n,0,0,L,L);let i=e.toDataURL(`image/jpeg`,.72),a=i.indexOf(`,`);t(a>=0?i.slice(a+1):null)}catch{t(null)}},n.onerror=()=>t(null),n.src=e}),je=e=>typeof document>`u`||!e?Promise.resolve(null):new Promise(t=>{let n=new Image;n.decoding=`async`,n.onload=()=>{try{let e=document.createElement(`canvas`);e.width=w,e.height=w;let r=e.getContext(`2d`);if(!r){t(null);return}r.clearRect(0,0,w,w),r.drawImage(n,0,0,w,w);let i=e.toDataURL(`image/png`),a=i.indexOf(`,`);t(a>=0?i.slice(a+1):null)}catch{t(null)}},n.onerror=()=>t(null),n.src=e}),R=()=>oe,z=((e=R)=>{let t=0,n=null,r=[],i=null,a=``,o=!1,s=!1,c=()=>{n!==null&&(clearTimeout(n),n=null)},l=(e,...t)=>{let n=i;n&&n[e](...t)},u=async()=>{if(r.length>0)return;let t=e(),n=await Promise.all([t.addListener(`textChanged`,e=>{let t=typeof e.text==`string`?e.text:``;a=t,l(`onText`,t,e.composing===!0,ye(e))}),t.addListener(`send`,e=>{let t=typeof e.text==`string`?e.text:a;a=t,l(`onSend`,t)}),t.addListener(`abort`,()=>{l(`onAbort`)}),t.addListener(`attach`,()=>{l(`onAttach`)}),t.addListener(`filesPicked`,t=>{l(`onFiles`,ke(t),De(t)),e().focus()}),t.addListener(`removeAttachment`,e=>{let t=ve(e);t&&l(`onRemoveAttachment`,t)}),t.addListener(`openModel`,()=>{l(`onOpenModel`)}),t.addListener(`cycleAgent`,()=>{l(`onCycleAgent`)}),t.addListener(`openAgent`,()=>{l(`onOpenAgent`)}),t.addListener(`heightChanged`,e=>{l(`onHeight`,ue(e))}),t.addListener(`scrollToBottom`,()=>{l(`onScrollToBottom`)}),t.addListener(`autocompleteAccept`,e=>{l(`onAutocompleteAccept`,be(e))}),t.addListener(`autocompleteDismiss`,()=>{l(`onAutocompleteDismiss`)})]);if(r.length>0){for(let e of n)e.remove();return}r=n},d=n=>{t>0||(i=null,o=!1,E(n,!1),e().dismiss())};return{bind(e){i=e},rememberText(e){a=e},rememberState(e){a=e.text},conceal(){o||t===0||(o=!0,e().hide())},reveal(){!o||t===0||(o=!1,e().show())},async warm(){s||t>0||(s=!0,await e().present(ae()))},async retain(n,i){c(),t+=1,o=!1,s=!0,a=i.text,E(n,!0),r.length===0&&await u(),await e().present(i)},release(e){t=Math.max(0,t-1),!(t>0)&&(c(),n=setTimeout(()=>{n=null,d(e)},0))},shutdown(n=document.documentElement){c(),t=0,s=!1,o=!1,i=null,E(n,!1),e().dismiss()},snapshot(){return{retainCount:t,listenerCount:r.length,hidePending:n!==null,concealed:o,warmed:s}}}})(),Me=()=>o(`OpenChamberNavigation`),B=e=>e?.kind===`chat`||e?.kind===`draft`,V=e=>e?e.kind===`draft`||e.kind===`chat`&&e.routes.length<=1:!1,Ne=(e,t)=>B(e)&&!B(t),Pe=(e=z)=>{V(u.getState().secondary)&&e.conceal()},Fe=(e=z)=>{let t=u.subscribe((t,n)=>{Ne(n.secondary,t.secondary)&&e.conceal()}),n=[],r=!1;return s.getPlatform()===`ios`&&(async()=>{let t=Me(),i=await t.addListener(`backStarted`,()=>{V(u.getState().secondary)&&e.conceal()}),a=await t.addListener(`backCancelled`,()=>{e.reveal()});if(r){i.remove(),a.remove();return}n=[i,a]})(),()=>{r=!0,t();for(let e of n)e.remove();n=[]}},H=`__openchamberMobileBackRoute`,Ie=()=>typeof window>`u`||r()?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)}},U=e=>{let t=e?.[H];return typeof t==`number`&&Number.isFinite(t)?t:null},W=new class{routes=[];listeners=new Set;nextToken=1;history;removeHistoryListener=null;programmaticHistoryBackToken=null;pendingHistoryRemovals=new Map;animatedBackDriver=null;presentationCancelDriver=null;constructor(e=Ie()){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&&U(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()??{},[H]: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&&U(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||U(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&&U(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&&U(e)!==t.token&&t.onBack()===!1&&this.history&&this.history.pushState({...this.history.currentState()??{},[H]:t.token})}))}disposeHistoryListener(){this.removeHistoryListener?.(),this.removeHistoryListener=null,this.programmaticHistoryBackToken=null,this.pendingHistoryRemovals.clear()}notify(){this.listeners.forEach(e=>e())}},Le=e=>{let t=(0,m.c)(8),{id:n,active:r,layer:i,onBack:a,surfaceRef:o,underlayRef:s}=e,c=i===void 0?`root`:i,u=l(a),d,f;t[0]!==r||t[1]!==u||t[2]!==n||t[3]!==c||t[4]!==o||t[5]!==s?(d=()=>{if(r)return W.register({id:n,layer:c,onBack:u,getSurface:()=>o.current,getUnderlay:()=>s?.current??null})},f=[r,u,n,c,o,s],t[0]=r,t[1]=u,t[2]=n,t[3]=c,t[4]=o,t[5]=s,t[6]=d,t[7]=f):(d=t[6],f=t[7]),p.useEffect(d,f)},G=o(`OpenChamberNavigation`),K=e=>Math.min(1,Math.max(0,Number.isFinite(e)?e:0)),Re=(e,t)=>!e||!t?!1:e.onBack()!==!1,q=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)))},J=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??``)},Y=(e,t)=>{let n=K(t),{surface:r}=e;r.style.transform=`translate3d(${n*100}%, 0, 0)`},ze=e=>!e.surfaceConnected||e.topRouteToken!==e.routeToken||e.routeSurface!==e.outgoingSurface,Be=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)`},Ve=async(e,t,n=typeof window<`u`&&window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches,r=q({progress:Number.parseFloat(e.style.transform.match(/translate3d\(([-\d.]+)%/)?.[1]??`0`)/100,commit:t}))=>Be(e,t?100:0,r,n),He=class{pending=0;enqueue(){this.pending+=1}take(){return this.pending!==0&&(--this.pending,!0)}clear(){this.pending=0}},Ue=e=>{let t=(0,m.c)(4),{enabled:n,rootRoutesBlocked:i}=e,a,o;t[0]!==n||t[1]!==i?(a=()=>{if(!n||!r()||s.getPlatform()===`web`)return;let e=!1,t=null,a=null,o=0,c=0,l=0,u=new He,d=[],f=e=>!!e&&(!i||e?.layer===`overlay`),p=()=>{let e=f(W.getTopRoute());G.setEnabled({enabled:e}).catch(We)},m=()=>{if(W.cancelPresentation(),a)return;let e=W.getTopRoute();if(!f(e))return;let n=e.getSurface();if(!n)return;n.getAnimations().forEach(Ge),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(Ke),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},Y(t,0)},h=e=>{c=K(e),!o&&(o=window.requestAnimationFrame(()=>{o=0,t&&Y(t,c)}))},g=qe,_=(n,r,i)=>{if(n&&Pe(),a)return n&&f(W.getTopRoute())?(u.enqueue(),!0):!1;o&&=(window.cancelAnimationFrame(o),0),t||m(),t&&r!==void 0&&Y(t,r);let s=t,d=l;if(t=null,!s){if(!n)return!1;let e=W.getTopRoute();return Re(e,f(e))}a=s;let p=window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches??!1,h=q({progress:K(r??c),commit:n,velocityX:i,viewportWidth:window.innerWidth});return Ve(s.surface,n,p,h).then(async()=>{d===l&&(!e&&n&&(s.route.onBack(),await g(s)),d===l&&(J(s),a===s&&(a=null),!e&&u.take()&&_(!0,0,0)))}),!0},v=W.setAnimatedBackDriver(e=>e!==W.getTopRoute()||!f(e)?!1:_(!0,0,0)),y=W.subscribe(p);return(async()=>{let t=await G.addListener(`backStarted`,m),n=await G.addListener(`backProgressed`,e=>h(e.progress??0)),r=await G.addListener(`backCancelled`,e=>_(!1,e.progress,e.velocityX)),i=await G.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(Je),p(),()=>{e=!0,l+=1,u.clear(),y(),v(),o&&window.cancelAnimationFrame(o),t&&J(t),a&&(a.surface.getAnimations().forEach(Ye),a.underlay?.getAnimations().forEach(Xe),J(a)),t=null,a=null,G.setEnabled({enabled:!1}).catch(Ze),d.forEach(Qe)}},o=[n,i],t[0]=n,t[1]=i,t[2]=a,t[3]=o):(a=t[2],o=t[3]),p.useEffect(a,o)};function We(){}function Ge(e){return e.cancel()}function Ke(e){return e.cancel()}function qe(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=W.getTopRoute();return ze({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=W.subscribe(()=>{o()&&a()});s()})}function Je(){}function Ye(e){return e.cancel()}function Xe(e){return e.cancel()}function Ze(){}function Qe(e){e.remove()}var $e=e=>/^#[0-9a-fA-F]{6}$/.test(e),et=e=>/^#[0-9a-fA-F]{8}$/.test(e),tt=(e,t)=>/^[0-9a-fA-F]{2}$/.test(t)?$e(e)?`${e}${t}`:et(e)?`${e.slice(0,7)}${t}`:e:e,X=(e,t)=>typeof e==`string`&&e.trim().length>0?e:t,nt=e=>{let t=e.colors.syntax.base,n=e.colors.syntax.tokens??{},r=(e,t)=>X(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`],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}}]},rt=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=X(a.diffAddedBackground,r.successBackground),s=X(a.diffRemovedBackground,r.errorBackground);return{"editor.background":t.background,"editor.foreground":t.foreground,"editor.hoverHighlightBackground":X(n.hover,t.subtle),"editor.lineHighlightBackground":t.muted,"editor.selectionBackground":n.selection,"editor.selectionHighlightBackground":n.selection,"editor.findMatchBackground":i.type,"editor.findMatchHighlightBackground":tt(i.type,`cc`),"editor.findRangeHighlightBackground":t.muted,"editor.inactiveSelectionBackground":t.elevated,"editor.lineHighlightBorder":t.elevated,"editor.rangeHighlightBackground":X(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":X(a.lineNumberActive,t.foreground),"editorLineNumber.foreground":X(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":X(a.diffAdded,r.success),"merge.incomingHeaderBackground":r.info,"merge.incomingContentBackground":X(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":X(a.diffRemoved,r.error),"terminal.ansiGreen":X(a.diffAdded,r.success),"terminal.ansiYellow":r.warning,"terminal.ansiBlue":X(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":X(e.colors.primary.foreground,t.background),"badge.foreground":X(e.colors.primary.foreground,t.background),"activityBarBadge.foreground":X(e.colors.primary.foreground,t.background)}};function it(e){return{name:e.metadata.name,type:e.metadata.variant,colors:rt(e),tokenColors:nt(e)}}var at=e=>/^#[0-9a-fA-F]{8}$/.test(e),Z=e=>at(e)?e.slice(0,7):e;function ot(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 Q=new Map,$=new Set,st=(e,t)=>{let n=e.colors?.[`editor.background`],r=e.colors?.[`editor.foreground`],i=n?Z(n):void 0,a=r?Z(r):void 0;if(!i||!a)throw Error(`Theme "${t}" is missing editor.background/editor.foreground`);let o=e.tokenColors??[];return ot({...e,name:t,fg:a,bg:i,settings:o},t)},ct=e=>it(e),lt=e=>{let t=Q.get(e.metadata.id);if(t)return t;let n=st(ct(e),e.metadata.id);return Q.set(e.metadata.id,n),n},ut=e=>{let t=e.metadata.id;if($.has(t))return;let n=lt(e);c(t,async()=>n),$.add(t)};export{Ce as A,pe as C,k as D,xe as E,y as M,ee as N,Se as O,v as P,le as S,je as T,Te as _,Ue as a,A as b,b as c,_e as d,ge as f,R as g,T as h,Le as i,te as j,E as k,fe as l,ce as m,lt as n,Fe as o,Ee as p,W as r,z as s,ut as t,de as u,j as v,Ae as w,me as x,he as y};
|
package/dist/assets/{fileMentionTouchSelection-BJOHH2CX.js → fileMentionTouchSelection-DPSC4Fx2.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{dt as t}from"./persistence-Dnj1QOdX.js";import{nt as n,rt as r,tt as i}from"./vendor-base-ui-CnHfUmDN.js";import{n as a}from"./vendor-react-DLPElpoQ.js";import{r as o}from"./button-CUwjpv-i.js";import{ut as s}from"./useMobileNavigationStore-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{dt as t}from"./persistence-Dnj1QOdX.js";import{nt as n,rt as r,tt as i}from"./vendor-base-ui-CnHfUmDN.js";import{n as a}from"./vendor-react-DLPElpoQ.js";import{r as o}from"./button-CUwjpv-i.js";import{ut as s}from"./useMobileNavigationStore-DBML5LIl.js";import{r as c,t as l}from"./Icon-BdzPRCSy.js";var u=32,d=(e,t)=>{let n=c[e];return typeof n!=`string`||n.length===0?null:`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="${t}" stroke-width="${l}" stroke-linecap="round" stroke-linejoin="round">${n}</svg>`},f=(e,t)=>{let n=d(e,t);return!n||typeof document>`u`?Promise.resolve(null):new Promise(e=>{let t=new Image;t.decoding=`async`,t.onload=()=>{try{let n=document.createElement(`canvas`);n.width=u,n.height=u;let r=n.getContext(`2d`);if(!r){e(null);return}r.clearRect(0,0,u,u),r.drawImage(t,0,0,u,u);let i=n.toDataURL(`image/png`),a=i.indexOf(`,`);e(a>=0?i.slice(a+1):null)}catch{e(null)}},t.onerror=()=>e(null),t.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n)}`})},p=(e,n)=>{if(!e.includes(`/`)||n.size===0)return[];let r=RegExp(`(^|\\s)/(${t})?([A-Za-z0-9][A-Za-z0-9_-]*)(?=$|\\s)`,`g`),i=[],a;for(;(a=r.exec(e))!==null;){let e=a[3]??``;if(!n.has(e.toLowerCase()))continue;let t=a[2]??``,r=a.index+(a[1]?.length??0);i.push({start:r,end:r+1+t.length+e.length,name:e,hasSlot:t.length>0})}return i},m=(e,n,r=e.length)=>{let i=p(e,n).filter(e=>!e.hasSlot);if(i.length===0)return null;let a=e,o=r;for(let e=i.length-1;e>=0;--e){let n=i[e].start+1;a=`${a.slice(0,n)}${t}${a.slice(n)}`,o>n&&(o+=t.length)}return a===e?null:{text:a,caret:o}},h=e=>e.startsWith(t)?e.slice(t.length):e,g=e=>{if(e.inputMode===`shell`)return null;let t=e.text,n=Math.max(0,Math.min(e.cursor,t.length));if(t.startsWith(`/`)){let e=t.indexOf(` `),r=t.indexOf(`
|
|
2
2
|
`),i=Math.min(e===-1?t.length:e,r===-1?t.length:r);if(n<=i&&e===-1)return{kind:`slash-command`,query:h(t.substring(1,i)),tokenStart:0,tokenEnd:i}}let r=t.substring(0,n),i=s({value:t,cursorPosition:n,inputSource:e.mentionInputSource??`manual`,insertedText:e.insertedText});return i===null?null:{kind:`mention`,query:i,tokenStart:r.lastIndexOf(`@`),tokenEnd:n}},_=e=>e===`mention`?`@`:`/`,v=(e,t,n)=>{if(n&&n.tokenStart>=0&&n.tokenEnd>=n.tokenStart&&n.tokenEnd<=e.length&&e.startsWith(_(n.kind),n.tokenStart))return{start:n.tokenStart,end:n.tokenEnd};let r=g({text:e,cursor:t});return r?{start:r.tokenStart,end:r.tokenEnd}:null},y=e(r(),1),b=a(),x=e(i(),1),S=`absolute z-[100] min-w-0 w-full bottom-full mb-2 left-0 flex flex-col rounded-xl`,C=`pointer-events-auto absolute z-[100] min-w-0 flex flex-col rounded-xl`;function w(e,t){return o(e?C:S,`oc-mobile-overlay-surface oc-mobile-overlay-surface--translucent oc-composer-autocomplete-surface`,t)}function T(e,t){return e?`oc-composer-autocomplete-row`:o(`mx-1.5 hover:bg-[color-mix(in_srgb,var(--interactive-selection)_40%,transparent)]`,t&&`bg-[color-mix(in_srgb,var(--interactive-selection)_40%,transparent)]`)}var E=.4,D=e=>{let t=e.gap??8,n=Math.min(e.composerTop-t,e.visibleBottom-t);return{left:e.composerLeft,width:e.composerWidth,bottom:Math.max(0,e.fixedContainingBottom-n),maxHeight:O({popupBottom:n,boundaryTop:e.boundaryTop,viewportHeight:e.viewportHeight,gap:t})}},O=e=>{let t=e.gap??8,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},k=(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)},A=(e,t)=>{let n=(0,b.c)(5),[r,i]=y.useState(void 0),a;n[0]!==t||n[1]!==e?(a=()=>{if(!t){i(void 0);return}let n=0,r=0,a=()=>{let t=e.current?.parentElement;if(!t)return;let n=t.getBoundingClientRect(),r=window.visualViewport,a=r?.offsetTop??0,o=r?.height??window.innerHeight,s=window.innerHeight,c=a+o,l=k(t,a)??a,u=D({composerTop:n.top,composerLeft:n.left,composerWidth:n.width,fixedContainingBottom:s,visibleBottom:c,boundaryTop:l,viewportHeight:o});i(e=>e&&e.left===u.left&&e.width===u.width&&e.bottom===u.bottom&&e.maxHeight===u.maxHeight?e:u)},o=()=>{a(),n&&window.cancelAnimationFrame(n),r&&window.clearTimeout(r),n=window.requestAnimationFrame(()=>{a(),r=window.setTimeout(a,220)})};return a(),window.addEventListener(`resize`,a),window.addEventListener(`oc:keyboard-settled`,o),window.addEventListener(`oc:keyboard-anim`,o),window.visualViewport?.addEventListener(`resize`,a),window.visualViewport?.addEventListener(`scroll`,a),()=>{n&&window.cancelAnimationFrame(n),r&&window.clearTimeout(r),window.removeEventListener(`resize`,a),window.removeEventListener(`oc:keyboard-settled`,o),window.removeEventListener(`oc:keyboard-anim`,o),window.visualViewport?.removeEventListener(`resize`,a),window.visualViewport?.removeEventListener(`scroll`,a)}},n[0]=t,n[1]=e,n[2]=a):a=n[2];let o;return n[3]===t?o=n[4]:(o=[t],n[3]=t,n[4]=o),y.useLayoutEffect(a,o),t?r:void 0},j=n(),M=y.forwardRef((e,t)=>{let n=(0,b.c)(24),{isMobile:r,className:i,style:a,children:o}=e,s=y.useRef(null),c=A(s,r),l=typeof document<`u`?document.body:null;if(!r){let e;n[0]===i?e=n[1]:(e=w(!1,i),n[0]=i,n[1]=e);let r;return n[2]!==o||n[3]!==t||n[4]!==a||n[5]!==e?(r=(0,j.jsx)(`div`,{ref:t,className:e,style:a,children:o}),n[2]=o,n[3]=t,n[4]=a,n[5]=e,n[6]=r):r=n[6],r}let u;n[7]===i?u=n[8]:(u=w(!0,i),n[7]=i,n[8]=u);let d;n[9]===c?d=n[10]:(d=c?{left:c.left,width:c.width,bottom:c.bottom,maxHeight:c.maxHeight,overflow:`hidden`}:{visibility:`hidden`},n[9]=c,n[10]=d);let f;n[11]!==a||n[12]!==d?(f={...a,...d},n[11]=a,n[12]=d,n[13]=f):f=n[13];let p;n[14]!==o||n[15]!==t||n[16]!==u||n[17]!==f?(p=(0,j.jsx)(`div`,{className:`pointer-events-none fixed inset-0 z-[100]`,children:(0,j.jsx)(`div`,{ref:t,className:u,style:f,children:o})}),n[14]=o,n[15]=t,n[16]=u,n[17]=f,n[18]=p):p=n[18];let m=p,h;n[19]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,j.jsx)(`span`,{ref:s,className:`hidden`,"aria-hidden":!0}),n[19]=h):h=n[19];let g;n[20]===m?g=n[21]:(g=l?(0,x.createPortal)(m,l):m,n[20]=m,n[21]=g);let _;return n[22]===g?_=n[23]:(_=(0,j.jsxs)(j.Fragment,{children:[h,g]}),n[22]=g,n[23]=_),_});M.displayName=`ComposerAutocompleteLayer`;var N=()=>{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)}};export{g as a,f as c,v as i,M as n,m as o,T as r,h as s,N as t};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-C0FnF6B9.js";import{i as t,n}from"./runtime-switch-BJM2k_uH.js";import{n as r}from"./runtime-fetch-CiqQd__Y.js";import{On as i}from"./persistence-Dnj1QOdX.js";import{$ as a,A as o,C as s,F as c,G as l,J as u,K as d,L as f,M as p,N as m,Nt as ee,O as te,Q as ne,R as re,S as ie,T as ae,X as oe,Y as h,Z as se,_ as ce,at as le,b as ue,c as de,d as fe,gt as pe,h as me,ht as he,it as ge,lt as _e,m as ve,nt as ye,o as be,pt as xe,rt as Se,u as Ce,ut as we,v as Te,vt as Ee,w as De,x as Oe,xt as ke,yt as Ae,z as je}from"./platform-wu6wSDfg.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime-C0FnF6B9.js";import{i as t,n}from"./runtime-switch-BJM2k_uH.js";import{n as r}from"./runtime-fetch-CiqQd__Y.js";import{On as i}from"./persistence-Dnj1QOdX.js";import{$ as a,A as o,C as s,F as c,G as l,J as u,K as d,L as f,M as p,N as m,Nt as ee,O as te,Q as ne,R as re,S as ie,T as ae,X as oe,Y as h,Z as se,_ as ce,at as le,b as ue,c as de,d as fe,gt as pe,h as me,ht as he,it as ge,lt as _e,m as ve,nt as ye,o as be,pt as xe,rt as Se,u as Ce,ut as we,v as Te,vt as Ee,w as De,x as Oe,xt as ke,yt as Ae,z as je}from"./platform-wu6wSDfg.js";import{d as g,l as Me,ua as _,va as v}from"./useMobileNavigationStore-DBML5LIl.js";var Ne=e({COMMIT_DIFF_FILE_LIMIT:()=>30,COMMIT_DIFF_TOTAL_CHAR_LIMIT:()=>j,SESSION_GENERATE_TIMEOUT_MS:()=>M,applyGitStash:()=>K,checkIsGitRepository:()=>x,checkoutCommit:()=>$e,cherryPick:()=>et,collectSelectedFileDiffs:()=>N,countGitStashFiles:()=>W,createBranch:()=>Y,createGitIdentity:()=>Q,createGitWorktree:()=>B,deleteGitIdentity:()=>Je,deleteGitWorktree:()=>V,deleteRemoteBranch:()=>A,discoverGitCredentials:()=>Ye,discoverGitRepositories:()=>S,dropGitStash:()=>J,generateCommitMessage:()=>F,getCommitFileDiff:()=>X,getConflictDetails:()=>$,getGitBranches:()=>k,getGitIdentities:()=>Z,getGitStatus:()=>C,getGitWorktreeBootstrapStatus:()=>R,getGlobalGitIdentity:()=>Xe,git:()=>H,listGitStashes:()=>U,listGitWorktrees:()=>I,merge:()=>Qe,popGitStash:()=>q,previewGitWorktree:()=>z,rebase:()=>Ze,resetToCommit:()=>nt,resolveGitPrimaryRoot:()=>w,resolveGitTopLevel:()=>T,revertCommit:()=>tt,stageGitFile:()=>E,stageGitFiles:()=>D,stashGitChanges:()=>G,unstageGitFile:()=>Pe,unstageGitFiles:()=>O,updateGitIdentity:()=>qe,validateGitWorktree:()=>L}),y=()=>i()?.git??null,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};async function x(e){let t=y();return t?t.checkIsGitRepository(e):de(e)}async function S(e){return De(e)}async function C(e,t){let n=y();return n?n.getGitStatus(e,t):f(e,t)}async function w(e){return(await Se(e)).root}async function T(e){return(await ge(e)).root}async function E(e,t){let n=y();return n?.stageGitFile?n.stageGitFile(e,t):_e(e,t)}async function D(e,t){let n=y();return n?.stageGitFiles?n.stageGitFiles(e,t):we(e,t)}async function Pe(e,t){let n=y();return n?.unstageGitFile?n.unstageGitFile(e,t):he(e,t)}async function O(e,t){let n=y();return n?.unstageGitFiles?n.unstageGitFiles(e,t):pe(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 p(e,t)}async function A(e,t){let n=y();return n?n.deleteRemoteBranch(e,t):ie(e,t)}var j=12e4,M=9e4,Fe=[`This is an auxiliary structured generation request (git copy).`,`Use the active session context plus the materials below.`,`Answer with the required JSON only.`,`Do not call any tools and do not take any actions.`,`Model and instructions follow the session.generate session contract.`].join(` `),Ie=`Select an active session for generation. session.generate uses that session model contract and does not mutate chat history.`,Le=`No default provider or model configured. Please select a provider and model in settings first.`,Re=`Runtime changed during session.generate`,ze=`session.generate returned empty text`,Be=`session.generate returned invalid structured output`,Ve=e=>{let t=[`Diff budget: included ${e.includedFileCount} of ${e.selectedFileCount} selected files`,`fileLimit=${e.fileLimit}`,`charLimit=${e.charLimit}`,`truncatedByCharLimit=${e.truncatedByCharLimit?`yes`:`no`}`,`omittedFiles=${e.omittedFileCount}`],n=e.omittedFileCount>0||e.truncatedByCharLimit?` Materials are partial under this budget — do not invent diffs for omitted or truncated files; base the message only on provided material.`:` Materials cover the full selected set within the budget.`;return`${t.join(`; `)}.${n}`};async function N(e,t){let n=t.length,r=t.slice(0,30),i=await Promise.all(r.map(async t=>{try{let[n,r]=await Promise.all([m(e,{path:t,staged:!0}).catch(()=>null),m(e,{path:t,staged:!1}).catch(()=>null)]);return[n?.diff,r?.diff].filter(e=>typeof e==`string`&&e.trim().length>0).join(`
|
|
2
2
|
`)||`--- ${t} (no textual diff available)`}catch{return`--- ${t} (diff unavailable)`}})),a=``,o=0,s=!1;for(let e of i){let t=a?`
|
|
3
3
|
|
|
4
4
|
`:``;if(a.length+t.length+e.length>12e4){a+=`
|
|
5
|
-
[remaining diffs truncated by char budget — not a full selected-set dump]`,s=!0;break}a+=t+e,o+=1}let c=Math.max(0,n-r.length),l=c+(s?Math.max(0,r.length-o):0);c>0&&(a+=`\n[${c} more selected files omitted by file budget — not included]`);let u={selectedFileCount:n,includedFileCount:o,omittedFileCount:l,truncatedByCharLimit:s,fileLimit:30,charLimit:j};return{...u,text:a,budgetNote:Ve(u)}}var P=e=>{let t=typeof e?.subject==`string`?e.subject.trim():``,n=Array.isArray(e?.highlights)?e.highlights.filter(e=>typeof e==`string`).map(e=>e.trim()).filter(Boolean).slice(0,3):[];if(!t)throw Error(`Structured output missing subject`);return{subject:t,highlights:n}},He=(e,t)=>{if(t?.aborted)return!0;if(!e||typeof e!=`object`)return!1;let n=`name`in e?String(e.name??``):``;return n===`AbortError`||n===`TimeoutError`},Ue=e=>{let t=new AbortController,n=()=>{try{t.abort(e?.reason)}catch{t.abort()}};e&&(e.aborted?n():e.addEventListener(`abort`,n,{once:!0}));let r=setTimeout(()=>{let e=new DOMException(`session.generate timed out after ${M}ms`,`TimeoutError`);try{t.abort(e)}catch{t.abort()}},M);return{signal:t.signal,cleanup:()=>{clearTimeout(r),e&&e.removeEventListener(`abort`,n)}}};async function We(){let e=
|
|
5
|
+
[remaining diffs truncated by char budget — not a full selected-set dump]`,s=!0;break}a+=t+e,o+=1}let c=Math.max(0,n-r.length),l=c+(s?Math.max(0,r.length-o):0);c>0&&(a+=`\n[${c} more selected files omitted by file budget — not included]`);let u={selectedFileCount:n,includedFileCount:o,omittedFileCount:l,truncatedByCharLimit:s,fileLimit:30,charLimit:j};return{...u,text:a,budgetNote:Ve(u)}}var P=e=>{let t=typeof e?.subject==`string`?e.subject.trim():``,n=Array.isArray(e?.highlights)?e.highlights.filter(e=>typeof e==`string`).map(e=>e.trim()).filter(Boolean).slice(0,3):[];if(!t)throw Error(`Structured output missing subject`);return{subject:t,highlights:n}},He=(e,t)=>{if(t?.aborted)return!0;if(!e||typeof e!=`object`)return!1;let n=`name`in e?String(e.name??``):``;return n===`AbortError`||n===`TimeoutError`},Ue=e=>{let t=new AbortController,n=()=>{try{t.abort(e?.reason)}catch{t.abort()}};e&&(e.aborted?n():e.addEventListener(`abort`,n,{once:!0}));let r=setTimeout(()=>{let e=new DOMException(`session.generate timed out after ${M}ms`,`TimeoutError`);try{t.abort(e)}catch{t.abort()}},M);return{signal:t.signal,cleanup:()=>{clearTimeout(r),e&&e.removeEventListener(`abort`,n)}}};async function We(){let e=g.getState().currentSessionId;if(typeof e==`string`&&e.trim())return e.trim();if(!g.getState().newSessionDraft?.open)throw Error(Ie);let t=v.getState();if(!t.currentProviderId||!t.currentModelId)throw Error(Le);let n=await Me({providerID:t.currentProviderId,modelID:t.currentModelId,agent:t.currentAgentName||void 0,variant:t.currentVariant||void 0});if(n?.sessionId)return n.sessionId;let r=g.getState().currentSessionId;if(typeof r==`string`&&r.trim())return r.trim();throw Error(`Failed to create session for generation`)}async function Ge(e){let r={sessionId:await We(),directory:e.directory,kind:e.kind,runtimeGeneration:n(),runtimeTransport:t()},i=typeof e.prompt==`string`?e.prompt.trim():``;if(!i)throw Error(`Generation prompts are empty`);let{signal:a,cleanup:o}=Ue(e.signal),s=Date.now();r.kind,r.directory,r.sessionId,i.length;try{a.throwIfAborted();let e=await ee.generateSessionAside({sessionId:r.sessionId,directory:r.directory,prompt:i,signal:a});if(n()!==r.runtimeGeneration||t()!==r.runtimeTransport)throw Error(Re);let o=typeof e?.text==`string`?e.text.trim():``;if(!o)throw Error(ze);let c=b(o);if(!c)throw console.error(`[git-generation][browser] invalid JSON from session.generate`,{kind:r.kind,sessionId:r.sessionId,elapsedMs:Date.now()-s,textPreview:o.slice(0,400)}),Error(Be);return r.kind,r.sessionId,Date.now()-s,o.length,c}catch(e){if(He(e,a)){let e=a.reason instanceof Error?a.reason.message:typeof a.reason==`string`&&a.reason.trim()?a.reason:`session.generate cancelled`;throw new DOMException(e,a.reason instanceof DOMException?a.reason.name:`AbortError`)}throw e}finally{o()}}var Ke=(e,t)=>[Fe,typeof e==`string`?e.trim():``,typeof t==`string`?t.trim():``].filter(Boolean).join(`
|
|
6
6
|
|
|
7
|
-
`);async function F(e,t,n){let i=Date.now(),a=n?.signal;n?.zenModel,n?.providerId,n?.modelId,t.length;let o=await
|
|
7
|
+
`);async function F(e,t,n){let i=Date.now(),a=n?.signal;n?.zenModel,n?.providerId,n?.modelId,t.length;let o=await _(`git.commit.generate.visible`),s=await _(`git.commit.generate.instructions`,{selected_files:t.map(e=>`- ${e}`).join(`
|
|
8
8
|
`)});try{a?.throwIfAborted();let n=await N(e,t),c=[s,n.budgetNote,`Diffs of the selected files (budget-aligned; see note above):`,n.text].join(`
|
|
9
9
|
|
|
10
10
|
`),{currentProviderId:l,currentModelId:u}=v.getState(),d=await r(`/api/small-model/generate`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({purpose:`commit`,system:o,prompt:c,directory:e,...l?{preferredProviderID:l}:{},...u?{preferredModelID:u}:{}}),...a?{signal:a}:{}});if(d.status===404){t.length,n.includedFileCount,n.omittedFileCount,n.truncatedByCharLimit,c.length;let r={message:P(await Ge({directory:e,prompt:Ke(o,c),kind:`commit`,signal:a}))};return Date.now()-i,r.message.subject.length,r.message.highlights.length,n.includedFileCount,n.omittedFileCount,n.truncatedByCharLimit,r}let f=await d.json().catch(()=>null);if(!d.ok||typeof f?.text!=`string`){let e=typeof f?.error==`string`?f.error:`HTTP ${d.status}`;throw Error(e)}let p={message:P(b(f.text))};return Date.now()-i,p.message.subject.length,p.message.highlights.length,n.includedFileCount,n.omittedFileCount,n.truncatedByCharLimit,p}catch(e){throw console.error(`[git-generation][browser] failed`,{transport:`small-model|session.generate`,kind:`commit`,elapsedMs:Date.now()-i,message:e instanceof Error?e.message:String(e),error:e}),e}}async function I(e){let t=y();if(!t)return h(e);let n=t.worktree?.list??t.listGitWorktrees;if(d(n))return h(e);let r=t.worktree?.list?t.worktree.list.bind(t.worktree):t.listGitWorktrees.bind(t);return ke(()=>r(e))}async function L(e,t){let n=y();return n?.worktree?.validate?n.worktree.validate(e,t):n?.validateGitWorktree?n.validateGitWorktree(e,t):Ae(e,t)}async function R(e){let t=y();return t?.worktree?.bootstrapStatus?t.worktree.bootstrapStatus(e):t?.getGitWorktreeBootstrapStatus?t.getGitWorktreeBootstrapStatus(e):re(e)}async function z(e,t){let n=y();return n?.worktree?.preview?n.worktree.preview(e,t):n?.previewGitWorktree?n.previewGitWorktree(e,t):ne(e,t)}async function B(e,t){let n=y(),r;return r=n?.worktree?.create?await n.worktree.create(e,t):n?.createGitWorktree?await n.createGitWorktree(e,t):await Te(e,t),l(e),r}async function V(e,t){let n=y(),r;return r=n?.worktree?.remove?await n.worktree.remove(e,t):n?.deleteGitWorktree?await n.deleteGitWorktree(e,t):await Oe(e,t),l(e),r}var H={worktree:{list:I,validate:L,create:B,remove:V}};async function U(e){let t=y();return t?t.listGitStashes(e):u(e)}async function W(e,t){let n=y();return n?n.countGitStashFiles(e,t):ve(e,t)}async function G(e,t={}){let n=y();return n?n.stashGitChanges(e,t):xe(e,t)}async function K(e,t){let n=y();return n?n.applyGitStash(e,t):be(e,t)}async function q(e,t){let n=y();return n?n.popGitStash(e,t):se(e,t)}async function J(e,t){let n=y();return n?n.dropGitStash(e,t):ae(e,t)}async function Y(e,t,n){let r=y();return r?r.createBranch(e,t,n):me(e,t,n)}async function X(e,t,n,r){let i=y();return i?.getCommitFileDiff?i.getCommitFileDiff(e,t,n,r):te(e,t,n,r)}async function Z(){let e=y();return e?e.getGitIdentities():c()}async function Q(e){let t=y();return t?t.createGitIdentity(e):ce(e)}async function qe(e,t){let n=y();return n?n.updateGitIdentity(e,t):Ee(e,t)}async function Je(e){let t=y();return t?t.deleteGitIdentity(e):ue(e)}async function Ye(){let e=y();return e?.discoverGitCredentials?e.discoverGitCredentials():s()}async function Xe(){let e=y();return e?.getGlobalGitIdentity?e.getGlobalGitIdentity():je()}async function Ze(e,t){let n=y();return n?n.rebase(e,t):a(e,t)}async function Qe(e,t){let n=y();return n?n.merge(e,t):oe(e,t)}async function $e(e,t){let n=y();return n?n.checkoutCommit(e,t):Ce(e,t)}async function et(e,t){let n=y();return n?n.cherryPick(e,t):fe(e,t)}async function tt(e,t){let n=y();return n?n.revertCommit(e,t):le(e,t)}async function nt(e,t,n,r){let i=y();return i?i.resetToCommit(e,t,n,r):ye(e,t,n,r)}async function $(e){let t=y();return t?.getConflictDetails?t.getConflictDetails(e):o(e)}export{T as A,U as C,Ze as D,z as E,Pe as F,O as I,qe as L,E as M,D as N,nt as O,G as P,Ne as S,q as T,Z as _,W as a,Xe as b,Je as c,S as d,J as f,k as g,$ as h,et as i,tt as j,w as k,A as l,X as m,x as n,Y as o,F as p,$e as r,Q as s,K as t,Ye as u,C as v,Qe as w,H as x,R as y};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{c as t,i as n}from"./runtime-switch-BJM2k_uH.js";import{A as r,M as i,On as a,d as o,f as s,on as c}from"./persistence-Dnj1QOdX.js";import{a as l,i as u,r as d}from"./vendor-zustand-DzRqcymP.js";import{nt as f,rt as p}from"./vendor-base-ui-CnHfUmDN.js";import{B as m,Ct as h,M as g,Mt as _}from"./platform-wu6wSDfg.js";import{b as v,n as ee,x as y}from"./useUIStore-Dfx6TKvi.js";import{n as b}from"./vendor-react-DLPElpoQ.js";import{s as x}from"./vendor-tanstack-react-query-D7pys_c9.js";import{n as S}from"./vendor-reactuses-core-Dq5ocTF8.js";import{f as te,r as C,u as ne}from"./button-CUwjpv-i.js";import{Mr as re,S as ie,Tr as ae,Ua as oe,Vt as w,Wn as T,_t as se,ao as ce,cn as le,d as E,dt as ue,ft as de,mt as fe,oo as D,pt as O,va as pe,vn as me,y as he}from"./useMobileNavigationStore-DBML5LIl.js";import{n as k}from"./Icon-BdzPRCSy.js";import{g as ge,v as _e}from"./gitApi-DeWWyR94.js";import{f as ve,o as ye}from"./projectMeta-D_jCNzjw.js";import{n as be}from"./textarea-Kl-rTWJe.js";import{n as xe,r as Se,t as Ce}from"./fileMentionTouchSelection-DPSC4Fx2.js";var we=e=>{switch(e.name){case`new`:return`add`;case`init`:return`file`;case`undo`:return`arrow-go-back`;case`redo`:return`arrow-go-forward`;case`timeline`:return`time`;case`compact`:return`scissors`;case`reload`:return`refresh`;case`goal`:return`target`;case`review`:return`search-eye`;case`test`:case`build`:case`run`:return`terminal-box`;default:return e.isBuiltIn?`flashlight`:`command`}},Te=()=>`book-open`,Ee=e=>{if(e.isDirectory)return`folder-3-fill`;switch(e.extension?.toLowerCase()){case`ts`:case`tsx`:case`js`:case`jsx`:case`json`:return`code`;case`md`:case`mdx`:return`file`;case`png`:case`jpg`:case`jpeg`:case`gif`:case`svg`:return`file-image`;default:return`file-pdf`}},A=()=>`ai-agent`,De=()=>`chat-thread`,Oe=(e,t)=>e.map(e=>{let n=e.isSkill?t.skill:e.isOpenChamber?`OpenChamber`:e.isBuiltIn?t.system:e.scope||e.agent||t.command;return{id:e.id,title:`/${e.name}`,subtitle:e.description,badge:n,iconName:we(e)}}),ke=({skills:e=[],agents:t,sessions:n,recentFiles:r,pathHits:i,untitledSession:a,sessionBadge:o,skillBadge:s})=>{let c=[];for(let t of e)c.push({id:`skill:${t.name}-${t.scope}`,title:`@${t.name}`,subtitle:t.description,badge:s??t.scope,iconName:Te()});for(let e of t)c.push({id:`agent:${e.name}`,title:`@${e.name}`,subtitle:e.description,iconName:A()});for(let e of n)c.push({id:`session:${e.id}`,title:e.title||a,badge:o,iconName:De()});for(let e of r)c.push({id:`recent:${e.path}`,title:e.relativePath||e.name,iconName:Ee(e)});for(let e of i)c.push({id:`file:${e.path}`,title:e.relativePath||e.name,iconName:Ee(e)});return c},Ae=(e,t)=>{let n=t.trim();if(!n.length)return[...e].sort((e,t)=>e.scope===`project`&&t.scope!==`project`?-1:e.scope!==`project`&&t.scope===`project`?1:e.name.localeCompare(t.name));let r=T([...e],n,e=>[e.name,e.description??``]);return r.sort((e,t)=>e.score===t.score?e.item.scope===`project`&&t.item.scope!==`project`?-1:e.item.scope!==`project`&&t.item.scope===`project`?1:e.item.name.localeCompare(t.item.name):e.score-t.score),r.map(e=>e.item)},je=(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=T([...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)},Me=(e,t)=>e===t||e.length===t.length&&e.every((e,n)=>{let r=t[n];return r!=null&&e.id===r.id&&e.title===r.title&&(e.subtitle??``)===(r.subtitle??``)&&(e.badge??``)===(r.badge??``)&&e.iconName===r.iconName}),Ne=(e,t)=>e.highlightedIndex===t.highlightedIndex&&Me(e.rows,t.rows),Pe=(e,t)=>Me(e,t)?e:t.slice(),Fe=(e,t,n)=>{e&&(t.current&&Ne(t.current,n)||(t.current=n,e(n)))},Ie=(e,t)=>{t.current=null,e?.({rows:[],highlightedIndex:0})},j=e(p(),1),M=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},N=e=>/^[A-Za-z]:\//.test(e)?e.toLowerCase():e,P=(e,t)=>{let n=M(t),r=M(e);if(!n||!r)return!1;let i=N(n),a=N(r);return a===i||a.startsWith(`${i}/`)},Le=e=>{if(!e||typeof e!=`object`)return{};let t=e,n={};for(let[e,r]of Object.entries(t)){let t=M(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=>M(e)).filter(e=>P(e,t)))):[],o=Array.isArray(i.expandedPaths)?Array.from(new Set(i.expandedPaths.filter(e=>typeof e==`string`).map(e=>M(e)).filter(e=>P(e,t)))):[],s=typeof i.selectedPath==`string`?M(i.selectedPath):null,c=s&&P(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},F=(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},I=e=>e?{...e,touchedAt:Date.now()}:{openPaths:[],selectedPath:null,expandedPaths:[],touchedAt:Date.now()},Re=l()(d(u((e,t)=>({byRoot:{},addOpenPath:(t,n,r)=>{let i=M((t||``).trim()),a=M((n||``).trim());!i||!a||!r?.allowOutsideRoot&&!P(a,i)||e(e=>{let t=e.byRoot[i],n=I(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:F({...e.byRoot,[i]:{...n,openPaths:o,selectedPath:s}},20)}})},removeOpenPath:(t,n)=>{let r=M((t||``).trim()),i=M((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=N(i),a=e=>N(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:F({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeOpenPathsByPrefix:(t,n)=>{let r=M((t||``).trim()),i=M((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=N(i),a=n.endsWith(`/`)?n:`${n}/`,o=e=>{let t=N(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:F({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeExpandedPathsByPrefix:(t,n)=>{let r=M((t||``).trim()),i=M((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=N(i),a=n.endsWith(`/`)?n:`${n}/`,o=t.expandedPaths.filter(e=>{let t=N(e);return t!==n&&!t.startsWith(a)});return o.length===t.expandedPaths.length?e:{byRoot:F({...e.byRoot,[r]:{...t,expandedPaths:o,touchedAt:Date.now()}},20)}})},setSelectedPath:(t,n,r)=>{let i=M((t||``).trim()),a=n?M(n.trim()):null;!i||a&&!r?.allowOutsideRoot&&!P(a,i)||e(e=>{let t=e.byRoot[i],n=I(t),r=a&&!n.openPaths.includes(a)?[...n.openPaths,a]:n.openPaths;return t&&t.selectedPath===a&&r===t.openPaths?e:{byRoot:F({...e.byRoot,[i]:{...n,openPaths:r,selectedPath:a}},20)}})},ensureSelectedPath:e=>{let n=M((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=M((t||``).trim()),i=M((n||``).trim());!r||!i||!P(i,r)||e(e=>{let t=e.byRoot[r],n=I(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:F({...e.byRoot,[r]:{...n,expandedPaths:a}},20)}})},expandPath:(t,n)=>{let r=M((t||``).trim()),i=M((n||``).trim());!r||!i||!P(i,r)||e(e=>{let t=e.byRoot[r],n=I(t);return n.expandedPaths.includes(i)&&t?e:{byRoot:F({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,i]}},20)}})},expandPaths:(t,n)=>{let r=M((t||``).trim());if(!r||!n||n.length===0)return;let i=n.map(e=>M((e||``).trim())).filter(e=>e&&P(e,r));i.length!==0&&e(e=>{let t=e.byRoot[r],n=I(t),a=new Set(n.expandedPaths),o=i.filter(e=>!a.has(e));return o.length===0?e:{byRoot:F({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,...o]}},20)}})}}),{name:`files-view-tabs-store`,version:2,storage:v(),migrate:e=>{if(!e||typeof e!=`object`)return{byRoot:{}};let t=e.byRoot;return{byRoot:Le(t)}},partialize:e=>({byRoot:Le(e.byRoot)})}),{name:`files-view-tabs-store`})),L=b(),ze=(e,t)=>{let n=(0,L.c)(4),r=t===void 0?200:t,[i,a]=j.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]),j.useEffect(o,s),i},Be=()=>{let e=(0,L.c)(17),t=E(R),n=me(),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=E(z),o=E(B),s=D(Ve),c=D(V),l=h(He);if(t){let r;e[2]===i?r=e[3]:(r=he(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 R(e){return e.currentSessionId}function z(e){return e.worktreeMetadata}function B(e){return e.newSessionDraft}function Ve(e){return e.activeProjectId}function V(e){return e.projects}function He(e){return e.currentDirectory}var H=f(),U=`bg-transparent font-[inherit] text-[var(--primary-base)]`,W=(e,t)=>{let n=t.trim().toLowerCase();if(!n)return e;let r=e.toLowerCase();if(!r.includes(n))return e;let i=[],a=0,o=r.indexOf(n);for(;o!==-1;)o>a&&i.push(e.slice(a,o)),i.push((0,H.jsx)(`mark`,{className:U,children:e.slice(o,o+n.length)},`${o}-${n}`)),a=o+n.length,o=r.indexOf(n,a);return a<e.length&&i.push(e.slice(a)),i},G=j.forwardRef(({searchQuery:e,onFileSelect:t,onAgentSelect:n,onSkillSelect:a,onSessionSelect:o,onClose:s,style:c,onRowsChange:l},u)=>{let{t:d}=te(),f=Be()??``,p=E(e=>e.currentSessionId),m=re(e=>e.activeSessions),h=w({enabled:!!o}),g=D(e=>e.activeProjectId),v=D(e=>e.projects),y=j.useMemo(()=>v.find(e=>e.id===g)?.path??null,[g,v]),b=j.useMemo(()=>{let e=y||f;return e?e.replace(/\\/g,`/`).replace(/\/+$/,``):null},[y,f]),x=Re(e=>b?e.byRoot[b]:void 0),ie=pe(e=>e.getVisibleAgents),T=_(e=>e.searchFiles),ce=ze(e,180),le=i(),me=r(),[he,ge]=j.useState([]),[_e,ve]=j.useState([]),[ye,we]=j.useState(!1),[A,De]=j.useState(0),Oe=j.useRef(0),[je,Me]=j.useState(360),[Ne,Pe]=j.useState({}),[M,N]=j.useState({}),P=j.useRef([]),Le=j.useRef([]),F=j.useRef([]),I=j.useRef(null),L=j.useRef(null),R=j.useRef(null);R.current||=Ce();let z=ee(e=>e.isMobile),B=(e??``).trim(),Ve=oe({directory:f||null}),V=j.useMemo(()=>a?Ae(Ve.data??[],B):[],[B,a,Ve.data]),He=j.useMemo(()=>{if(!b||!x)return[];let e=[x.selectedPath,...x.openPaths.slice().reverse()].filter(e=>typeof e==`string`&&e.length>0),t=new Set,n=[];for(let r of e){if(t.has(r))continue;t.add(r);let e=r.replace(/\\/g,`/`),i=e.split(`/`).filter(Boolean).pop()||e,a=e.startsWith(`${b}/`)?e.slice(b.length+1):e;n.push({name:i,path:e,relativePath:a,extension:i.includes(`.`)?i.split(`.`).pop()?.toLowerCase():void 0})}return fe(n,B,{limit:6})},[B,b,x]),U=j.useMemo(()=>B.length>0?_e:_e.slice(0,2),[_e,B.length]),G=j.useMemo(()=>o?ue({sessions:ae(m,h),currentSessionId:p,searchQuery:B}):[],[m,p,h,B,o]),K=He,q=he;j.useEffect(()=>{let e=e=>{let t=e.target;!t||!I.current||I.current.contains(t)||s()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[s]),j.useEffect(()=>{if(!f){ge([]);return}let e=(ce??``).trim(),t=se(e);if(!t){ge([]);return}let n=!1;we(!0);let r={includeHidden:le,respectGitignore:!me};return Promise.all([T(f,t,80,{...r,type:`file`}),T(f,t,40,{...r,type:`directory`})]).then(([t,r])=>{if(n)return;let i=new Set(He.map(e=>e.path));ge(de({files:t,directories:r,query:e,excludePaths:i,limit:20}))}).catch(()=>{n||ge([])}).finally(()=>{n||we(!1)}),()=>{n=!0}},[f,ce,He,T,le,me]),j.useEffect(()=>{let t=ie().filter(e=>e.mode&&e.mode!==`primary`).map(e=>({name:e.name,description:e.description,mode:e.mode}));ve(O(t,e??``))},[ie,e]),j.useEffect(()=>{De(0),Pe({}),N({})},[q,K.length,U.length,G.length,V.length]),j.useEffect(()=>{Oe.current=A},[A]),j.useEffect(()=>{P.current[A]?.scrollIntoView({block:`nearest`})},[A]),j.useEffect(()=>{let e=null,t=()=>{e!==null&&cancelAnimationFrame(e),e=requestAnimationFrame(()=>{let e={},t={};Le.current.forEach((n,r)=>{if(!n)return;let i=F.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}}),Pe(e),N(t)})};return t(),window.addEventListener(`resize`,t),()=>{e!==null&&cancelAnimationFrame(e),window.removeEventListener(`resize`,t)}},[q,K]),j.useEffect(()=>{let e=Le.current[A];if(!e)return;let t=()=>{let t=e.clientWidth;t>0&&Me(t)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>{n.disconnect()}},[A]);let Ue=S(e=>{t(e)}),We=S(e=>{n?.(e)}),Ge=S(e=>{o?.(e)}),J=S(e=>{a?.(e)}),Y=V.length,Ke=Y,qe=Ke+U.length,X=qe+G.length,Je=X+K.length,Ye=(e,t)=>({onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&R.current?.pointerDown(e.clientX,e.clientY)},onPointerMove:e=>{e.pointerType===`touch`&&R.current?.pointerMove(e.clientX,e.clientY)},onPointerUp:e=>{e.pointerType===`touch`&&(R.current?.pointerUp(t)??!1)&&(e.preventDefault(),e.stopPropagation())},onPointerCancel:()=>R.current?.pointerCancel(),onClick:()=>{R.current?.click(t)},onMouseMove:()=>De(e)}),Xe=e=>{let t=Y+U.length+G.length+K.length+q.length;if(t===0)return;let n=(e%t+t)%t;if(n<Y){let e=V[n];e&&J(e);return}if(n<qe){let e=U[n-Ke];e&&We(e.name);return}if(n<X){let e=G[n-qe];e&&Ge(e);return}let r=n-X,i=r<K.length?K[r]:q[r-K.length];i&&Ue(i)};j.useEffect(()=>{Fe(l,L,{rows:ke({skills:V,agents:U,sessions:G,recentFiles:K,pathHits:q,untitledSession:d(`chat.fileMentionAutocomplete.untitledSession`),sessionBadge:d(`chat.fileMentionAutocomplete.sessionType`),skillBadge:d(`chat.commandAutocomplete.badge.skill`)}),highlightedIndex:A})},[l,A,d,U,q,K,G,V]);let Z=j.useRef(l);Z.current=l,j.useEffect(()=>()=>{Ie(Z.current,L)},[]),j.useImperativeHandle(u,()=>({acceptIndex:e=>{Xe(e)},handleKeyDown:e=>{if(e===`Escape`){s();return}let t=Y+U.length+G.length+K.length+q.length;if(t!==0){if(e===`ArrowDown`){De(e=>(e+1)%t);return}if(e===`ArrowUp`){De(e=>(e-1+t)%t);return}(e===`Enter`||e===`Tab`)&&Xe(Oe.current)}}}),[Y,q,K,U,G,V,s,Ue,We,Ge,J]);let Ze=e=>(0,H.jsx)(k,{name:Ee(e),className:`h-3.5 w-3.5 text-current`});return(0,H.jsxs)(xe,{ref:I,isMobile:z,className:`max-w-[640px] max-h-64`,style:c,children:[(0,H.jsx)(be,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0`,children:(0,H.jsxs)(`div`,{className:`pb-2`,children:[V.length>0&&(0,H.jsx)(`div`,{className:`px-3 pb-1 pt-2 typography-meta font-medium text-muted-foreground`,children:d(`chat.fileMentionAutocomplete.groups.skills`)}),V.map((e,t)=>{let n=A===t;return(0,H.jsx)(`div`,{ref:e=>{P.current[t]=e},className:C(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,z&&`min-h-11`,Se(z,n),!z&&n&&`text-interactive-selection-foreground`),...Ye(t,()=>J(e)),children:(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(k,{name:Te(),className:`h-3.5 w-3.5 translate-y-px flex-shrink-0 text-current`}),(0,H.jsxs)(`span`,{className:`min-w-0 truncate`,children:[`@`,W(e.name,B)]}),z?null:(0,H.jsx)(`span`,{className:`flex-shrink-0 typography-meta text-muted-foreground`,children:e.scope})]}),e.description?(0,H.jsx)(`div`,{className:C(`pl-5.5 truncate text-muted-foreground`,z?`typography-micro`:`typography-meta`),children:W(e.description,B)}):null]})},`skill-${e.name}-${e.scope}`)}),U.length>0&&(0,H.jsx)(`div`,{className:`px-3 pb-1 pt-2 typography-meta font-medium text-muted-foreground`,children:d(`chat.fileMentionAutocomplete.groups.agents`)}),U.map((e,t)=>{let n=Ke+t,r=A===n;return(0,H.jsx)(`div`,{ref:e=>{P.current[n]=e},className:C(`flex items-start gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,z&&`min-h-11`,Se(z,r),!z&&r&&`text-interactive-selection-foreground`),...Ye(n,()=>We(e.name)),children:(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsxs)(`div`,{className:`truncate`,children:[`@`,W(e.name,B)]}),e.description&&!z?(0,H.jsx)(`div`,{className:`typography-meta text-muted-foreground truncate`,children:W(e.description,B)}):null]})},`agent-${e.name}`)}),U.length===2&&B.length===0&&_e.length>2&&(0,H.jsx)(`div`,{className:`px-3 py-1 typography-meta text-muted-foreground`,children:d(`chat.fileMentionAutocomplete.searchMoreAgents`)}),G.length>0&&(0,H.jsx)(`div`,{className:`px-3 pb-1 pt-2 typography-meta font-medium text-muted-foreground`,children:d(`chat.fileMentionAutocomplete.groups.sessions`)}),G.map((e,t)=>{let n=qe+t,r=A===n;return(0,H.jsxs)(`div`,{ref:e=>{P.current[n]=e},className:C(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,z&&`min-h-11`,Se(z,r),!z&&r&&`text-interactive-selection-foreground`),...Ye(n,()=>Ge(e)),children:[(0,H.jsx)(k,{name:`chat-thread`,className:`h-4 w-4 flex-shrink-0 text-[var(--primary-base)]`}),(0,H.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.title||d(`chat.fileMentionAutocomplete.untitledSession`),children:W(e.title||d(`chat.fileMentionAutocomplete.untitledSession`),B)}),z?null:(0,H.jsx)(`span`,{className:`flex-shrink-0 typography-meta text-muted-foreground`,children:d(`chat.fileMentionAutocomplete.sessionType`)})]},`session-${e.id}`)}),K.length>0&&(0,H.jsx)(`div`,{className:`px-3 pb-1 pt-2 typography-meta font-medium text-muted-foreground`,children:d(`chat.fileMentionAutocomplete.groups.recentFiles`)}),K.map((e,t)=>{let n=X+t,r=e.relativePath||e.name,i=ne(r,{maxLength:60}),a=A===n,o=Ne[n]??!1,s=M[n]??2.6;return(0,H.jsxs)(`div`,{ref:e=>{P.current[n]=e},className:C(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,z&&`min-h-11`,Se(z,a),!z&&a&&`text-interactive-selection-foreground`),...Ye(n,()=>Ue(e)),children:[Ze(e),(0,H.jsxs)(`span`,{ref:e=>{Le.current[n]=e},className:`relative flex-1 min-w-0 overflow-hidden file-mention-marquee-container`,style:a?{"--file-mention-marquee-width":`${je}px`,"--file-mention-marquee-duration":`${s}s`}:void 0,"aria-label":r,children:[(0,H.jsx)(`span`,{ref:e=>{F.current[n]=e},className:`absolute invisible whitespace-nowrap pointer-events-none`,"aria-hidden":!0,children:r}),o&&a?(0,H.jsx)(`span`,{className:`inline-block whitespace-nowrap file-mention-marquee`,children:W(r,B)}):(0,H.jsx)(`span`,{className:`block truncate`,children:W(i,B)})]})]},`recent-${e.path}`)}),q.length>0&&(0,H.jsx)(`div`,{className:`px-3 pb-1 pt-2 typography-meta font-medium text-muted-foreground`,children:d(`chat.fileMentionAutocomplete.groups.files`)}),q.map((e,t)=>{let n=Je+t,r=e.relativePath||e.name,i=ne(r,{maxLength:60}),a=A===n,o=Ne[n]??!1,s=M[n]??2.6;return(0,H.jsxs)(`div`,{ref:e=>{P.current[n]=e},className:C(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,z&&`min-h-11`,Se(z,a),!z&&a&&`text-interactive-selection-foreground`),...Ye(n,()=>Ue(e)),children:[Ze(e),(0,H.jsxs)(`span`,{ref:e=>{Le.current[n]=e},className:`relative flex-1 min-w-0 overflow-hidden file-mention-marquee-container`,style:a?{"--file-mention-marquee-width":`${je}px`,"--file-mention-marquee-duration":`${s}s`}:void 0,"aria-label":r,children:[(0,H.jsx)(`span`,{ref:e=>{F.current[n]=e},className:`absolute invisible whitespace-nowrap pointer-events-none`,"aria-hidden":!0,children:r}),o&&a?(0,H.jsx)(`span`,{className:`inline-block whitespace-nowrap file-mention-marquee`,children:W(r,B)}):(0,H.jsx)(`span`,{className:`block truncate`,children:W(i,B)})]})]},e.path)}),ye&&q.length===0?(0,H.jsx)(`div`,{className:`flex items-center justify-center py-3`,children:(0,H.jsx)(k,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):null,!ye&&q.length===0&&K.length===0&&U.length===0&&G.length===0&&V.length===0&&(0,H.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:d(`chat.fileMentionAutocomplete.empty`)})]})}),!z&&(0,H.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:d(`chat.autocomplete.keyboardHint`)})]})}),K=new Set([`new`,`fork`,`compact`,`reload`,`undo`,`redo`,`model`,`goal`,`btw`]),q=(e,t)=>{if(!t||e.isSkill)return!1;let n=e.name?.trim().toLowerCase();return!!(n&&K.has(n))},Ue=(e,t)=>!e||t({name:e}),We=` `,Ge=(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]===We&&e[r-2]===`/`&&(r-=2),e[r]===`/`?{start:r,end:n}:null},J=`text-[10px] leading-none uppercase font-bold tracking-tight px-1.5 py-1 rounded border flex-shrink-0`,Y=C(J,`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)]`),Ke=C(J,`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)]`),qe=C(J,`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)]`),X=C(J,`bg-[var(--surface-muted)] text-muted-foreground border-[var(--interactive-border)]/60`),Je=(e,t)=>e.length===t.length&&e.every((e,n)=>e.id===t[n]?.id&&e.description===t[n]?.description),Ye=(e,t)=>{let n=!!e.sessionID;return{hasSession:n,canStartSessionCommand:n||e.hasNewDraft,canUseReviewHandoffFlow:n&&!t&&!c()}},Xe=j.forwardRef(({searchQuery:e,onCommandSelect:t,onClose:n,directory:r,style:i,commandPolicy:a,commandContext:o,onRowsChange:s},l)=>{let{t:u}=te(),d=ee(e=>e.isMobile),f=E(e=>e.currentSessionId),p=E(e=>!!e.newSessionDraft?.open),m=E(j.useCallback(e=>f?e.getDirectoryForSession(f):void 0,[f])),h=le(f??``,m??void 0),g=j.useMemo(()=>o??{sessionID:f??null,hasMessages:h.length>0,hasNewDraft:p},[o,f,h.length,p]),{hasSession:_,canStartSessionCommand:v,canUseReviewHandoffFlow:y}=j.useMemo(()=>Ye(g,d),[g,d]),b=g.hasMessages,[x,S]=j.useState([]),[ne,re]=j.useState(!1),ie=ce({directory:r}),ae=j.useMemo(()=>ie.data??[],[ie.data]),oe=ie.isFetching,[w,T]=j.useState(0),se=j.useRef(0),ue=j.useRef(!1),de=j.useRef([]),fe=j.useRef(null),D=j.useRef(!1),O=j.useRef(null),pe=j.useRef(!1),me=j.useRef(null);j.useEffect(()=>{let e=e=>{let t=e.target;!t||!fe.current||fe.current.contains(t)||n()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[n]),j.useEffect(()=>{(async()=>{re(oe);try{let t=ae.flatMap((e,t)=>e.source===`skill`?[]:[{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,scope:e.scope,reference:e.reference}]),n=[{id:`openchamber:new`,name:`new`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.newDescription`),isBuiltIn:!0},..._&&!b?[{id:`openchamber:init`,name:`init`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.initDescription`),isBuiltIn:!0}]:[],..._?[{id:`openchamber:btw`,name:`btw`,source:`openchamber`,description:u(`chat.btw.description`),isBuiltIn:!0},{id:`openchamber:undo`,name:`undo`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.undoDescription`),isBuiltIn:!0},{id:`openchamber:redo`,name:`redo`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.redoDescription`),isBuiltIn:!0},{id:`openchamber:fork`,name:`fork`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.forkDescription`),isBuiltIn:!0},{id:`openchamber:timeline`,name:`timeline`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.timelineDescription`),isBuiltIn:!0}]:[],{id:`openchamber:model`,name:`model`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.modelDescription`),isBuiltIn:!0},{id:`openchamber:compact`,name:`compact`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.compactDescription`),isBuiltIn:!0},...c()?[{id:`openchamber:reload`,name:`reload`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.reloadDescription`),isBuiltIn:!0}]:[],..._?[{id:`openchamber:summary`,name:`summary`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.summaryDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:workspace-review`,name:`workspace-review`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.workspaceReviewDescription`),isOpenChamber:!0}]:[],...y?[{id:`openchamber:handoff-review`,name:`handoff-review`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.handoffReviewDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:craft-goal`,name:`craft-goal`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.craftGoalDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:goal`,name:`goal`,source:`openchamber`,description:u(`chat.goal.button.armAria`),isBuiltIn:!0}]:[],...v?[{id:`openchamber:catch-up`,name:`catch-up`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.catchUpDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:debug`,name:`debug`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.debugDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:weigh`,name:`weigh`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.weighDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:explore`,name:`explore`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.exploreDescription`),isOpenChamber:!0}]:[],...t],r=!b,i=je(n.filter(e=>(r||e.name!==`init`)&&(a?.(e)??!0)),e);S(e=>Je(e,i)?e:i)}catch{let t=!b,n=je([{id:`openchamber:new`,name:`new`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.newDescription`),isBuiltIn:!0},..._&&!b?[{id:`openchamber:init`,name:`init`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.initDescription`),isBuiltIn:!0}]:[],..._?[{id:`openchamber:btw`,name:`btw`,source:`openchamber`,description:u(`chat.btw.description`),isBuiltIn:!0},{id:`openchamber:undo`,name:`undo`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.undoDescription`),isBuiltIn:!0},{id:`openchamber:redo`,name:`redo`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.redoDescription`),isBuiltIn:!0},{id:`openchamber:fork`,name:`fork`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.forkDescription`),isBuiltIn:!0},{id:`openchamber:timeline`,name:`timeline`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.timelineDescription`),isBuiltIn:!0}]:[],{id:`openchamber:model`,name:`model`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.modelDescription`),isBuiltIn:!0},{id:`openchamber:compact`,name:`compact`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.compactDescription`),isBuiltIn:!0},...c()?[{id:`openchamber:reload`,name:`reload`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.reloadDescription`),isBuiltIn:!0}]:[],..._?[{id:`openchamber:summary`,name:`summary`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.summaryDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:workspace-review`,name:`workspace-review`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.workspaceReviewDescription`),isOpenChamber:!0}]:[],...y?[{id:`openchamber:handoff-review`,name:`handoff-review`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.handoffReviewDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:craft-goal`,name:`craft-goal`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.craftGoalDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:goal`,name:`goal`,source:`openchamber`,description:u(`chat.goal.button.armAria`),isBuiltIn:!0}]:[],...v?[{id:`openchamber:catch-up`,name:`catch-up`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.catchUpDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:debug`,name:`debug`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.debugDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:weigh`,name:`weigh`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.weighDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:explore`,name:`explore`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.exploreDescription`),isOpenChamber:!0}]:[]].filter(e=>(t||e.name!==`init`)&&(a?.(e)??!0)),e);S(e=>Je(e,n)?e:n)}finally{re(!1)}})()},[e,b,_,v,y,ae,oe,u,a]),j.useEffect(()=>{T(0)},[x]),j.useEffect(()=>{se.current=w},[w]),j.useEffect(()=>{de.current[w]?.scrollIntoView({block:`nearest`})},[w]),j.useEffect(()=>{Fe(s,me,{rows:Oe(x,{skill:u(`chat.commandAutocomplete.badge.skill`),command:u(`chat.commandAutocomplete.badge.command`),system:u(`chat.commandAutocomplete.badge.system`)}),highlightedIndex:w})},[x,s,w,u]);let he=j.useRef(s);he.current=s,j.useEffect(()=>()=>{Ie(he.current,me)},[]),j.useImperativeHandle(l,()=>({acceptIndex:(e,n=!0)=>{let r=x[e];r&&t(r,q(r,n))},handleKeyDown:e=>{let r=x.length;if(e===`Escape`){n();return}if(r!==0){if(e===`ArrowDown`){ue.current=!0,T(e=>(e+1)%r);return}if(e===`ArrowUp`){ue.current=!0,T(e=>(e-1+r)%r);return}if(e===`Enter`||e===`Tab`){let n=(se.current%r+r)%r,i=x[n];i&&t(i,q(i,e===`Enter`))}}}}),[x,n,t]);let ge=e=>{let t=we(e);switch(e.name){case`new`:return(0,H.jsx)(k,{name:t,className:`h-3.5 w-3.5`});case`init`:return(0,H.jsx)(k,{name:t,className:`h-3.5 w-3.5 text-green-500`});case`undo`:return(0,H.jsx)(k,{name:t,className:`h-3.5 w-3.5 text-orange-500`});case`redo`:return(0,H.jsx)(k,{name:t,className:`h-3.5 w-3.5 text-orange-500`});case`timeline`:case`reload`:return(0,H.jsx)(k,{name:t,className:`h-3.5 w-3.5`});case`compact`:return(0,H.jsx)(k,{name:t,className:`h-3.5 w-3.5 text-purple-500`});case`goal`:return(0,H.jsx)(k,{name:t,className:`h-3.5 w-3.5`});case`review`:return(0,H.jsx)(k,{name:t,className:`h-3.5 w-3.5 text-blue-500`});case`test`:case`build`:case`run`:return(0,H.jsx)(k,{name:t,className:`h-3.5 w-3.5 text-cyan-500`});default:return e.isBuiltIn?(0,H.jsx)(k,{name:t,className:`h-3.5 w-3.5 text-yellow-500`}):(0,H.jsx)(k,{name:t,className:`h-3.5 w-3.5 text-muted-foreground`})}};return(0,H.jsxs)(xe,{ref:fe,isMobile:d,className:`max-w-[450px] max-h-64`,style:i,children:[(0,H.jsx)(be,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0 py-1.5`,children:ne?(0,H.jsx)(`div`,{className:`flex items-center justify-center py-4`,children:(0,H.jsx)(k,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):(0,H.jsxs)(`div`,{children:[x.map((n,r)=>{let i=n.isBuiltIn,a=n.isOpenChamber;return(0,H.jsxs)(`div`,{ref:e=>{de.current[r]=e},className:C(`flex gap-2 px-2 py-2 cursor-pointer rounded-lg`,d?`items-center`:`items-start`,Se(d,r===w),!d&&r===w&&`bg-interactive-selection/35`),onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&(O.current={x:e.clientX,y:e.clientY},pe.current=!1)},onPointerMove:e=>{if(e.pointerType!==`touch`||!O.current)return;let t=e.clientX-O.current.x,n=e.clientY-O.current.y;Math.hypot(t,n)>6&&(pe.current=!0)},onPointerUp:e=>{if(e.pointerType!==`touch`)return;let r=pe.current;O.current=null,pe.current=!1,!r&&(e.preventDefault(),e.stopPropagation(),D.current=!0,t(n,q(n,d)))},onPointerCancel:()=>{O.current=null,pe.current=!1},onClick:()=>{if(D.current){D.current=!1;return}t(n,q(n,d))},onMouseMove:()=>{ue.current=!1,T(r)},children:[(0,H.jsx)(`div`,{className:C(!d&&`mt-0.5`),children:ge(n)}),(0,H.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsxs)(`span`,{className:`typography-ui-label font-medium`,children:[`/`,W(n.name,e)]}),n.isSkill?(0,H.jsx)(`span`,{className:Y,children:u(`chat.commandAutocomplete.badge.skill`)}):(0,H.jsx)(`span`,{className:Y,children:u(`chat.commandAutocomplete.badge.command`)}),a?(0,H.jsx)(`span`,{className:X,children:`OpenChamber`}):i?(0,H.jsx)(`span`,{className:X,children:u(`chat.commandAutocomplete.badge.system`)}):n.scope?(0,H.jsx)(`span`,{className:n.scope===`project`?qe:Ke,children:n.scope}):null,n.agent&&(0,H.jsx)(`span`,{className:X,children:n.agent})]}),n.description&&!d&&(0,H.jsx)(`div`,{className:`typography-meta text-muted-foreground mt-0.5 truncate`,children:W(n.description,e)})]})]},n.id)}),x.length===0&&(0,H.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:u(`chat.commandAutocomplete.empty`)})]})}),!d&&(0,H.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:u(`chat.autocomplete.keyboardHint`)})]})});Xe.displayName=`CommandAutocomplete`;var Z=2,Ze=e=>!!e&&typeof e==`object`&&!Array.isArray(e),Qe=e=>{let t=e?.trim().replace(/\\/g,`/`);return t?t.length>1?t.replace(/\/+$/,``):t:null},$e=e=>Ze(e)&&Array.isArray(e.all)&&e.all.every(e=>typeof e==`string`)&&typeof e.current==`string`&&Ze(e.branches),et=(e,t)=>JSON.stringify([e,t]),tt=e=>`version`in e&&e.version===Z&&Ze(e.entries),nt=e=>{if(!e)return null;try{let t=JSON.parse(e);return Ze(t)?t.version===Z&&Ze(t.entries)?{version:Z,entries:t.entries}:t:null}catch{return null}},rt=(e,t)=>{try{e.setItem(`oc.gitBranchCache`,JSON.stringify(t))}catch{}},it=(e,t,n)=>{let r=Qe(e);if(!r||!t)return null;let i;try{i=n.getItem(`oc.gitBranchCache`)}catch{return null}let a=nt(i);if(!a)return null;if(tt(a))return $e(a.entries[et(t,r)])?a.entries[et(t,r)]:null;let o={};for(let[e,n]of Object.entries(a)){let r=Qe(e);r&&$e(n)&&(o[et(t,r)]=n)}return rt(n,{version:Z,entries:o}),o[et(t,r)]??null},at=(e,t,n,r)=>{let i=Qe(e);if(!i||!t||!$e(n))return;let a=null;try{a=r.getItem(`oc.gitBranchCache`)}catch{return}let o=nt(a);rt(r,{version:Z,entries:{...o&&tt(o)?o.entries:{},[et(t,i)]:n}})},ot=3e4,st=Qe,ct=(e,t=n())=>s.git.branches(st(e),t),lt=(e,t=n())=>s.git.remotes(st(e),t),ut=async(e,t,n)=>{n.throwIfAborted();let r=a()?.git,i=t?.getGitBranches?await t.getGitBranches(e,{signal:n}):r?await r.getGitBranches(e,{signal:n}):await g(e,{signal:n});return n.throwIfAborted(),i},dt=async(e,t,n)=>{n.throwIfAborted();let r=a()?.git,i=t?.getRemotes?await t.getRemotes(e,{signal:n}):r?await r.getRemotes(e,{signal:n}):await m(e,{signal:n});return n.throwIfAborted(),i},ft=(e,t,r=n(),i=y())=>{let a=st(e),o=t;return{queryKey:ct(a,r),queryFn:async({signal:e})=>{if(!a)throw Error(`Git branches require a directory`);let t=await ut(a,o,e);return at(a,r,t,i),t},staleTime:ot,gcTime:1/0,initialData:()=>it(a,r,i)??void 0,initialDataUpdatedAt:0}},pt=(e,t,r=n())=>{let i=st(e),a=t;return{queryKey:lt(i,r),queryFn:({signal:e})=>{if(!i)throw Error(`Git remotes require a directory`);return dt(i,a,e)},staleTime:ot,gcTime:1/0}},mt=(e,r,i)=>{let a=(0,L.c)(9),o=i===void 0||i,s=j.useSyncExternalStore(t,n,n),c,l,u;a[0]!==e||a[1]!==r||a[2]!==s?(c=st(e),u=x,l=ft(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)},ht=(e,r,i)=>{let a=(0,L.c)(9),o=i===void 0||i,s=j.useSyncExternalStore(t,n,n),c,l,u;a[0]!==e||a[1]!==r||a[2]!==s?(c=st(e),u=x,l=pt(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)},gt=(e,t,r=o,i=n())=>r.fetchQuery(ft(e,t,i)),_t=(e,t,r=o,i=n())=>r.fetchQuery({...ft(e,t,i),staleTime:0}),vt=e=>e instanceof Error?e.name===`AbortError`||e.name===`CancelledError`||e.name===`Error`&&e.message===`CancelledError`:!1,yt=1e4,bt=6e4,xt=5e3,St=3e4,Ct=6e4,wt=25,Tt=40,Et=2,Dt=15e3,Ot=500,kt=30,At=20971520,jt=new Map,Mt=new Map,Nt=new Map,Pt=new Map,Ft=new Map,It=(e,t)=>`${t}:${e}`,Lt=e=>Mt.get(e)??0,Rt=e=>{let t=Lt(e)+1;return Mt.set(e,t),t},zt=e=>{let t=(Nt.get(e)??0)+1;return Nt.set(e,t),t},Bt=e=>{let t=jt.get(e);if(t)return t;let n=new Set;return jt.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}),Vt=(e,t=kt,n=At)=>{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},Ht=(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},Ut=(e,t)=>!e&&!t?!1:!e||!t||e.remote!==t.remote||e.branch!==t.branch||e.ahead!==t.ahead||e.behind!==t.behind,Wt=(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&&Ut(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&&Ht(e.diffStats,t.diffStats))},Gt=(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},Kt=(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},qt=e=>!e||e.trim().length===0,Jt=e=>(e||``).trim()===`U`,Yt=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(Jt(t)||Jt(n))return e;let r=t===`?`||n===`?`?`A`:t||n||` `;return{...e,index:r,working_dir:` `}},Xt=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(Jt(t)||Jt(n))return e;let r=n||(t===`A`||t===`?`?`?`:t)||` `;return{...e,index:` `,working_dir:r}},Zt=e=>qt(e.index)&&qt(e.working_dir),$=l()(d((e,t)=>({directories:new Map,activeDirectory:null,setActiveDirectory:n=>{let{activeDirectory:r,directories:i}=t();if(r!==n)if(r&&Rt(r),n&&Rt(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=It(n,a),s=Pt.get(o)??(a===`light`?Pt.get(It(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)>bt,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(Wt(s.status,u)){c=!0;let r=new Map(t().directories),i=r.get(n)??Q(),s=Gt(i.status,u),l=Kt(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&&Rt(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})();Pt.set(o,c);try{return await c}finally{Pt.get(o)===c&&Pt.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`?Yt(e):Xt(e);t!==e&&(l=!0),Zt(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=zt(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 _t(r,i,void 0,o):await gt(r,i,void 0,o);if(s!==Nt.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(vt(i)||console.error(`Failed to fetch git branches:`,i),s!==Nt.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>yt||!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=Vt(s);a.set(n,{...o,diffCache:c}),e({directories:a})},clearDiffCache:n=>{Rt(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,wt);await t().prefetchDiffs(e,n,i,{maxFiles:wt})},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=Tt}=a,c=new Set(o.status.files.map(e=>e.path)),l=o.status.diffStats,u=Bt(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>Ot||d.push(e)}let p=d.slice(0,Math.max(1,s));if(p.length===0)return;let m=Lt(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 ${Dt}ms`)),Dt)}),a=await Promise.race([t,i]);return{path:e,diff:{original:a.original??``,modified:a.modified??``,isBinary:a.isBinary}}},ee=async()=>{for(;;){if(m!==Lt(n))return;let e=_();if(!e)return;try{g.push(await v(e))}catch{}finally{u.delete(e)}}},y=Math.min(Et,p.length);if(await Promise.allSettled(Array.from({length:y},()=>ee())),p.forEach(e=>u.delete(e)),m!==Lt(n))return;let b=new Map(t().directories),x=b.get(n);if(!x)return;let S=new Map(x.diffCache),te=Date.now();g.forEach(e=>{!e.diff.isBinary&&e.diff.original===``&&e.diff.modified===``||S.set(e.path,{...e.diff,fetchedAt:te})});let C=Vt(S);b.set(n,{...x,diffCache:C}),e({directories:b})},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<xt||await t().fetchStatus(e,n,{silent:!!r?.status})},ensureAll:(e,n)=>{let r=Ft.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)>=xt)&&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>=St)&&o.push(t().fetchBranches(e,n)),(!a.log||i-a.lastLogFetch>=yt)&&o.push(t().fetchLog(e,n)),(!a.identity||i-a.lastIdentityFetch>=Ct)&&o.push(t().fetchIdentity(e,n)),o.length>0&&await Promise.all(o)})();return Ft.set(e,i),i.finally(()=>{Ft.get(e)===i&&Ft.delete(e)}),i},refresh:async(e,n={})=>{let{activeDirectory:r}=t();r&&await t().fetchAll(r,e,n)}}),{name:`git-store`})),Qt=e=>{let t=(0,L.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)},$t=e=>{let r=(0,L.c)(3),i=j.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)},en=e=>{let t=(0,L.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)},tn=e=>{let t=(0,L.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)},nn=e=>{let t=(0,L.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)},rn=e=>{let t=(0,L.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=new Map,t[0]=n):n=t[0];let r=j.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)},an=e=>{let t=(0,L.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)},on=e=>{let t=(0,L.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)},sn=e=>{let t=(0,L.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)},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 ve(e);try{let n=cn((await ge(e)).branches?.[t]?.tracking||null);if(n?.remote)return n.remote}catch{}try{let t=cn((await _e(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 ye(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.some(e=>e.range.start<t.range.end&&t.range.start<e.range.end)?[...e]:[...e,t]},Sn=(e,t)=>t<e.length&&e[t]===` `?t+1:t;export{Re as A,ht as C,G as D,Ue as E,Be as O,mt as S,Ge as T,rn as _,hn as a,tn as b,mn as c,nn as d,$t as f,en as g,an as h,yn as i,Pe as j,ze as k,dn as l,on as m,xn as n,_n as o,sn as p,bn as r,gn as s,Sn as t,pn as u,Qt as v,Xe as w,_t as x,$ as y};
|