@openchambery/web 1.19.17-beta.2 → 1.19.17-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/AgentAvatar-CUDJ3_nZ.js +1 -0
- package/dist/assets/AssistantView-CDXE0eTS.js +3 -0
- package/dist/assets/DiagramView-BrRV4o5T.js +1 -0
- package/dist/assets/FadeInOnReveal-BLSnyG2Z.js +1 -0
- package/dist/assets/Icon-C9ZHbwqp.js +1 -0
- package/dist/assets/MarkdownRenderer-CAdfUgV1.js +2 -0
- package/dist/assets/{MarkdownRendererImpl-BJd1Vjsc.js → MarkdownRendererImpl-D2dIlX0h.js} +2 -2
- package/dist/assets/MarkstreamRendererImpl-Drb2Tpv-.js +3 -0
- package/dist/assets/MobileDetailNavigation-BgCoDqtp.js +1 -0
- package/dist/assets/MobileShareBridge-ZlVURYWR.js +4 -0
- package/dist/assets/MobileSurface-DhLOTW0-.js +2 -0
- package/dist/assets/MultiRunWindow-BCvcwItK.js +1 -0
- package/dist/assets/OnboardingScreen-DSyZtiFS.js +1 -0
- package/dist/assets/OverlayScrollbar-C7fAOAKT.js +2 -0
- package/dist/assets/SettingsView-D57amZJb.js +25 -0
- package/dist/assets/SettingsWindow-B5DqLCkD.js +1 -0
- package/dist/assets/TerminalView-2_RFPaVs.js +8 -0
- package/dist/assets/{ToolOutputDialog-BQ_oXyS_.js → ToolOutputDialog-CQs_7KYT.js} +4 -4
- package/dist/assets/{appThemeRegistry-BDrIDWKH.js → appThemeRegistry-DpLe_jnW.js} +1 -1
- package/dist/assets/button-bhVnVYB_.js +1 -0
- package/dist/assets/collapsible-CoWJB_Zl.js +1 -0
- package/dist/assets/context-menu-gSO0b3sQ.js +1 -0
- package/dist/assets/diagram-Dx4UOZUn.js +1 -0
- package/dist/assets/dialog-C2Dw0yqA.js +1 -0
- package/dist/assets/{es-BQb6I8gl.js → es-Bxd4Lyu9.js} +2 -2
- package/dist/assets/{fileMentionTouchSelection-DzdgAvGS.js → fileMentionTouchSelection-CmQthb6Q.js} +2 -2
- package/dist/assets/{fr-BjGouC_l.js → fr-DiLDwVZs.js} +2 -2
- package/dist/assets/{gitApi-pLkl_IyQ.js → gitApi-8HxdR1zx.js} +3 -3
- package/dist/assets/input-8Te_vPwB.js +1 -0
- package/dist/assets/insertionBoundaries-Cdv9-1Bg.js +1 -0
- package/dist/assets/{ja-Cw9zliYY.js → ja-CWRlmEJM.js} +2 -2
- package/dist/assets/{ko-Dyz0Dk9b.js → ko-DmIugkgj.js} +2 -2
- package/dist/assets/main-CQY7JUX4.js +169 -0
- package/dist/assets/main-Cfru2-qr.js +2 -0
- package/dist/assets/{markdownHeightCache-BL8CUQ0M.js → markdownHeightCache-CT2d4yTV.js} +1 -1
- package/dist/assets/miniChat-BphFgAb_.js +2 -0
- package/dist/assets/mobile-BVRPTuLT.js +2 -0
- package/dist/assets/multirun-CYdieVzW.js +4 -0
- package/dist/assets/{pl-C7EY-dTH.js → pl-BU9AmdUM.js} +2 -2
- package/dist/assets/projectMeta-D8hiy3Dk.js +3 -0
- package/dist/assets/{pt-BR-B1uHpjFW.js → pt-BR-DQmEF9QB.js} +2 -2
- package/dist/assets/renderElectronMiniChatApp-CVqd3Nmc.js +2 -0
- package/dist/assets/renderMobileApp-DgtCGRKP.js +28 -0
- package/dist/assets/{runtimeConfig-BD1Fo5N5.js → runtimeConfig-DXXOBrK_.js} +1 -1
- package/dist/assets/runtimeEndpointReset-bSVOt7pi.js +147 -0
- package/dist/assets/sessionChangeSummary-CfnRZ0gS.js +2 -0
- package/dist/assets/sessionLookup-BZuujM6l.js +1 -0
- package/dist/assets/sortable-tabs-strip-BmvLnn6O.js +1 -0
- package/dist/assets/src-C_Yn9Ylz.css +2 -0
- package/dist/assets/{store-ClnJdJSj.js → store-BoixGrYS.js} +3 -3
- package/dist/assets/textarea-DRL916s6.js +1 -0
- package/dist/assets/tooltip-BLznq5KR.js +1 -0
- package/dist/assets/{uk-DgG8v2md.js → uk-Dax66sAC.js} +2 -2
- package/dist/assets/{useAppFontEffects-CN_3Jty7.js → useAppFontEffects-DhEfjuPp.js} +43 -43
- package/dist/assets/useDesktopWindowControlsLayout-BhNFU2Wd.js +1 -0
- package/dist/assets/{useEffectiveDirectory-C5Gg7EvP.js → useEffectiveDirectory-BhhzFJgX.js} +1 -1
- package/dist/assets/useMobileNavigationStore-1jdHeA49.js +413 -0
- package/dist/assets/useSessionAutoCleanup-C8u2-jrO.js +2 -0
- package/dist/assets/{useWorkerHighlightedLines-BSQQkZaO.js → useWorkerHighlightedLines-DFXK66lA.js} +2 -2
- package/dist/assets/vendor-zod-Dzk5kdUU.js +39 -0
- package/dist/assets/{zh-CN-C6OFKjeT.js → zh-CN-Du4VC8Z0.js} +2 -2
- package/dist/assets/{zh-TW-BVP99aMr.js → zh-TW-C0bY-Dso.js} +2 -2
- package/dist/index.html +3 -3
- package/dist/mini-chat.html +3 -3
- package/dist/mobile.html +3 -3
- package/package.json +1 -1
- package/server/index.js +51 -0
- package/server/lib/opencode/DOCUMENTATION.md +1 -0
- package/server/lib/opencode/core-routes.js +2 -0
- package/server/lib/opencode/feature-routes-runtime.js +20 -0
- package/server/lib/opencode/feature-routes-runtime.test.js +10 -0
- package/server/lib/opencode/routes.js +14 -1
- package/server/lib/opencode/settings-helpers.js +3 -0
- package/server/lib/opencode/settings-helpers.test.js +12 -0
- package/server/lib/opencode/shutdown-runtime.js +2 -0
- package/server/lib/question-auto-delegate/DOCUMENTATION.md +124 -0
- package/server/lib/question-auto-delegate/core.d.ts +255 -0
- package/server/lib/question-auto-delegate/core.js +1372 -0
- package/server/lib/question-auto-delegate/core.test.js +672 -0
- package/server/lib/question-auto-delegate/routes.js +223 -0
- package/server/lib/question-auto-delegate/routes.test.js +180 -0
- package/server/lib/question-auto-delegate/runtime.js +243 -0
- package/server/lib/session-goal/DOCUMENTATION.md +12 -2
- package/server/lib/session-goal/runtime.js +138 -35
- package/server/lib/session-goal/runtime.test.js +192 -0
- package/dist/assets/AgentAvatar-m1jNq4bX.js +0 -1
- package/dist/assets/AssistantView-DZMTfY1i.js +0 -3
- package/dist/assets/DiagramView-Byf2evGV.js +0 -1
- package/dist/assets/FadeInOnReveal-UGwClbL_.js +0 -1
- package/dist/assets/Icon-D1BcR8Tz.js +0 -1
- package/dist/assets/MarkdownRenderer-YMePGw0Z.js +0 -2
- package/dist/assets/MarkstreamRendererImpl-2oZKPfgd.js +0 -3
- package/dist/assets/MobileDetailNavigation-BeNUCxzK.js +0 -1
- package/dist/assets/MobileShareBridge-3tBtXXJJ.js +0 -4
- package/dist/assets/MobileSurface-ppn0zIpb.js +0 -2
- package/dist/assets/MultiRunWindow-CItY5bZ2.js +0 -1
- package/dist/assets/OnboardingScreen-bIWeMLVx.js +0 -1
- package/dist/assets/OverlayScrollbar-Bahg_P3r.js +0 -2
- package/dist/assets/SettingsView-0-Yqdzh-.js +0 -25
- package/dist/assets/SettingsWindow-1jOWzU2A.js +0 -1
- package/dist/assets/TerminalView-BLOCPFz9.js +0 -8
- package/dist/assets/button-9R-WgVMl.js +0 -1
- package/dist/assets/clipboard-GUUNlWIv.js +0 -1
- package/dist/assets/collapsible-Bbz9KiJf.js +0 -1
- package/dist/assets/context-menu-CSyOhRz8.js +0 -1
- package/dist/assets/diagram-NdsZih8P.js +0 -1
- package/dist/assets/dialog-DhMGbF_B.js +0 -1
- package/dist/assets/input-Cd_1HyQv.js +0 -1
- package/dist/assets/insertionBoundaries-DJvMDCJJ.js +0 -1
- package/dist/assets/main-B8fZfA3K.js +0 -169
- package/dist/assets/main-BGpPyUV2.js +0 -2
- package/dist/assets/miniChat-DHjphqgR.js +0 -2
- package/dist/assets/mobile-DNMX4u7x.js +0 -2
- package/dist/assets/multirun-BINJ2LCE.js +0 -4
- package/dist/assets/projectMeta-BMkGWqtz.js +0 -3
- package/dist/assets/renderElectronMiniChatApp-BonR3p7C.js +0 -2
- package/dist/assets/renderMobileApp-CZqNs2zK.js +0 -28
- package/dist/assets/runtimeEndpointReset-Dpx6GB_U.js +0 -147
- package/dist/assets/sessionChangeSummary-BG7l2heP.js +0 -2
- package/dist/assets/sessionLookup-BZuvc3Aa.js +0 -1
- package/dist/assets/sortable-tabs-strip-dYW6SH62.js +0 -1
- package/dist/assets/src-CO9q_82J.css +0 -2
- package/dist/assets/textarea-B9CmN13Z.js +0 -1
- package/dist/assets/tooltip-DSjr26A_.js +0 -1
- package/dist/assets/useDesktopWindowControlsLayout-C6kAkizT.js +0 -1
- package/dist/assets/useMobileNavigationStore-DDgESrzu.js +0 -413
- package/dist/assets/useSessionAutoCleanup-q2lauc7x.js +0 -2
- package/dist/assets/utils-2ZK8yboQ.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
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{n as l}from"./clipboard-GUUNlWIv.js";import{t as u}from"./utils-2ZK8yboQ.js";import{t as d}from"./SettingsView-0-Yqdzh-.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,8 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{n as t}from"./runtime-fetch-zIalUnbb.js";import{Qt as n}from"./persistence-DwRBC4zl.js";import{nt as r,rt as i,tt as a}from"./vendor-base-ui-CnHfUmDN.js";import{c as o,s,t as c}from"./useUIStore-CxOoCv7B.js";import{o as l}from"./terminalApi-CfgOfnZk.js";import{n as u,r as d,t as f}from"./vendor-ghostty-web-HohRXr3g.js";import{n as ee,t as p}from"./clipboard-GUUNlWIv.js";import{c as m}from"./useMobileNavigationStore-DDgESrzu.js";import{t as h}from"./utils-2ZK8yboQ.js";import{n as g}from"./Icon-D1BcR8Tz.js";import{t as _}from"./button-9R-WgVMl.js";import{n as v}from"./useThemeSystem-DMzWVJaW.js";import{i as y,t as b}from"./OverlayScrollbar-Bahg_P3r.js";import{n as te}from"./useRuntimeAPIs-DSLXJybW.js";import{n as x}from"./useEffectiveDirectory-C5Gg7EvP.js";import{t as S}from"./sortable-tabs-strip-dYW6SH62.js";import{n as C,t as w}from"./useFontPreferences-DCaY8NbU.js";import{r as T}from"./projectActions-CWvNGKfA.js";var E=e(i(),1);function ne(e){let{colors:t}=e,n=t.syntax.base;return{background:t.surface.background,foreground:n.foreground,cursor:t.interactive.cursor,cursorAccent:t.surface.background,selectionBackground:t.interactive.selection,selectionForeground:t.interactive.selectionForeground,selectionInactiveBackground:t.interactive.selection+`50`,black:t.surface.muted,red:t.status.error,green:t.status.success,yellow:t.status.warning,blue:n.function,magenta:n.keyword,cyan:n.type,white:n.foreground,brightBlack:n.comment,brightRed:t.status.error,brightGreen:t.status.success,brightYellow:t.status.warning,brightBlue:n.function,brightMagenta:n.keyword,brightCyan:n.type,brightWhite:t.surface.elevatedForeground}}function re(e,t,n,r,i=!1){return{cursorBlink:!1,cursorStyle:`bar`,fontSize:t,lineHeight:1.15,fontFamily:`${e}, "JetBrainsMonoNL Nerd Font", "FiraCode Nerd Font", "Cascadia Code PL", "Fira Code", "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", "Courier New", monospace`,allowTransparency:!1,theme:{background:n.background,foreground:n.foreground,cursor:n.cursor,cursorAccent:n.cursorAccent,selectionBackground:n.selectionBackground,selectionForeground:n.selectionForeground,black:n.black,red:n.red,green:n.green,yellow:n.yellow,blue:n.blue,magenta:n.magenta,cyan:n.cyan,white:n.white,brightBlack:n.brightBlack,brightRed:n.brightRed,brightGreen:n.brightGreen,brightYellow:n.brightYellow,brightBlue:n.brightBlue,brightMagenta:n.brightMagenta,brightCyan:n.brightCyan,brightWhite:n.brightWhite},scrollback:1e4,ghostty:r,disableStdin:i}}var ie=e(a(),1),D=r(),O=null;function k(){return O||=d.load(),O}function ae(e){if(typeof window>`u`)return null;let t=[e,...Array.from(e.querySelectorAll(`*`))],n=null;for(let e of t){let t=window.getComputedStyle(e).overflowY;if(t===`auto`||t===`scroll`){if(e.scrollHeight-e.clientHeight>2)return e;n||=e}}return n}var oe=E.forwardRef(({sessionKey:e,chunks:t,onInput:n,onResize:r,theme:i,fontFamily:a,fontSize:o,className:s,enableTouchScroll:c,autoFocus:l=!0,isVisible:d=!0},m)=>{let{t:g}=ee(),_=E.useRef(null),v=E.useRef(null),y=E.useRef(null),te=E.useRef(null),x=E.useRef(n),S=E.useRef(r),C=E.useRef(null),w=E.useRef(``),T=E.useRef(null),ne=E.useRef(!1),O=E.useRef(null),oe=E.useRef(!0),A=E.useRef(null),j=E.useRef(null),se=E.useRef(0),ce=E.useRef(null),M=E.useRef(null),N=E.useRef(!1),P=E.useRef(!1),le=E.useRef(null),ue=E.useRef(null),de=E.useRef(null),F=E.useRef(``),fe=E.useRef(null),pe=E.useRef(!c),me=E.useRef(d),[,he]=E.useReducer(e=>e+1,0),[ge,_e]=E.useReducer(e=>e+1,0);x.current=n,S.current=r;let ve=typeof navigator<`u`&&(/Android/i.test(navigator.userAgent)||navigator.userAgentData?.platform===`Android`),I=!!c;E.useEffect(()=>{if(!c){pe.current=!0,me.current=d;return}!me.current&&d&&(pe.current=!1),me.current=d},[c,d]);let ye=E.useCallback(()=>{if(!I)return;let e=_.current,t=ce.current;if(!e)return;let n=[];e.getAttribute(`contenteditable`)===`true`&&n.push(e),n.push(...Array.from(e.querySelectorAll(`[contenteditable="true"]`))),n.forEach(e=>{e.setAttribute(`data-terminal-disabled-contenteditable`,`true`),e.setAttribute(`contenteditable`,`false`),e.setAttribute(`aria-hidden`,`true`),e.tabIndex=-1,e.style.setProperty(`caret-color`,`transparent`),e.style.color=`transparent`,e.style.setProperty(`-webkit-text-fill-color`,`transparent`),e.style.background=`transparent`,e.style.outline=`none`,e.style.boxShadow=`none`,e.style.textShadow=`none`,e.style.setProperty(`user-select`,`none`),e.style.setProperty(`-webkit-user-select`,`none`)}),e.tabIndex=-1,e.removeAttribute(`role`),e.removeAttribute(`aria-multiline`),Array.from(e.querySelectorAll(`textarea`)).forEach(e=>{e.style.setProperty(`caret-color`,`transparent`),e.style.color=`transparent`,e.style.setProperty(`-webkit-text-fill-color`,`transparent`),e.style.background=`transparent`,e.style.border=`0`,e.style.outline=`none`,e.style.boxShadow=`none`,e.style.textShadow=`none`,e.style.fontSize=`0`,e.style.lineHeight=`0`,e!==t&&e.getAttribute(`data-terminal-disabled-input`)!==`true`&&(e.setAttribute(`data-terminal-disabled-input`,`true`),e.setAttribute(`aria-hidden`,`true`),e.tabIndex=-1,e.disabled=!0,e.style.position=`absolute`,e.style.opacity=`0`,e.style.width=`0px`,e.style.height=`0px`,e.style.pointerEvents=`none`,e.style.zIndex=`-1`)})},[I]),L=E.useCallback(e=>{if(fe.current===e)return;let t=y.current;if(t)try{if(typeof t.setOption==`function`){t.setOption(`cursorBlink`,e),fe.current=e;return}t.options&&(t.options.cursorBlink=e,fe.current=e)}catch{}},[]),R=I&&ve,z=E.useCallback((e,t)=>{let n=R?M.current:ce.current,r=_.current;if(!n||!r)return;let i=r.getBoundingClientRect(),a=typeof window<`u`?window.innerWidth:i.width,o=typeof window<`u`?window.innerHeight:i.height,s=i.left+i.width/2,c=i.top+i.height-12,l=typeof e==`number`?e:s,u=typeof t==`number`?t:c,d=Math.max(8,Math.min(a-8,l)),f=Math.max(8,Math.min(o-8,u));n.style.left=`${d}px`,n.style.top=`${f}px`,n.style.bottom=``,(n instanceof HTMLTextAreaElement||n instanceof HTMLInputElement)&&(n.disabled=!1,n.readOnly=!1,n.removeAttribute(`disabled`),n.removeAttribute(`readonly`));try{n.focus({preventScroll:!0})}catch{try{n.focus()}catch{}}},[R]),B=E.useCallback(()=>{if(I){z(),L(!0);return}y.current?.focus(),L(!0)},[z,L,I]),V=E.useCallback(e=>e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement?e.value:e.textContent??``,[]),H=E.useCallback(e=>{if(e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement){e.value=``;return}e.textContent=``},[]),be=E.useCallback(e=>{if(typeof window>`u`||R)return;de.current!==null&&(window.clearTimeout(de.current),de.current=null);let t=0,n=()=>{de.current=window.setTimeout(()=>{de.current=null;let r=V(e);if(!r){if(t+=1,t<3){n();return}return}let i=F.current;F.current=r;let a=r.startsWith(i)?r.slice(i.length):r;a&&x.current(a.replace(/\r\n|\r|\n/g,`\r`)),H(e),F.current=``},t===0?0:24)};n()},[H,V,R]);E.useEffect(()=>{let e=_.current;if(!I||!e||c)return;let t=t=>{let n=t.target;if(n&&n.getAttribute(`data-terminal-hidden-input`)!==`true`&&e.contains(n)){try{n.blur()}catch{}z()}};return e.addEventListener(`focusin`,t,!0),()=>{e.removeEventListener(`focusin`,t,!0)}},[c,I,z]);let U=E.useCallback(()=>{let e=y.current;if(!e||typeof e.getSelection!=`function`)return``;let t=e.getSelection();return typeof t==`string`?t:``},[]),xe=E.useCallback(()=>{if(typeof window>`u`)return``;let e=window.getSelection();if(!e)return``;let t=e.toString();if(!t.trim())return``;let n=_.current;if(!n)return``;let r=e.anchorNode,i=e.focusNode;return r&&!n.contains(r)||i&&!n.contains(i)?``:t},[]),Se=E.useCallback(async()=>{if(typeof document>`u`)return;let e=U()||xe();e.trim()&&await p(e)},[xe,U]),Ce=E.useCallback(()=>U().trim()?!0:!!xe().trim(),[xe,U]);E.useEffect(()=>{if(typeof window>`u`)return;let e=e=>{Ce()&&(e.preventDefault(),Se())};return window.addEventListener(`openchamber:copy`,e),()=>{window.removeEventListener(`openchamber:copy`,e)}},[Se,Ce]);let W=E.useCallback(()=>{w.current=``,T.current!==null&&typeof window<`u`&&window.cancelAnimationFrame(T.current),T.current=null,ne.current=!1,O.current=null},[]),G=E.useCallback(()=>{let e=te.current,t=y.current,n=_.current;if(!e||!t||!n)return;let r=n.getBoundingClientRect();if(!(r.width<24||r.height<24))try{e.fit();let n={cols:t.cols,rows:t.rows},r=C.current;(!r||r.cols!==n.cols||r.rows!==n.rows)&&(C.current=n,S.current(n.cols,n.rows))}catch{}},[]),K=E.useCallback(()=>{if(ne.current)return;let e=y.current;if(!e){W();return}if(!w.current)return;let t=w.current;w.current=``,ne.current=!0,e.write(t,()=>{ne.current=!1,w.current&&(typeof window<`u`?T.current=window.requestAnimationFrame(()=>{T.current=null,K()}):K())})},[W]),we=E.useCallback(()=>{T.current===null&&(typeof window<`u`?T.current=window.requestAnimationFrame(()=>{T.current=null,K()}):K())},[K]),q=E.useCallback(e=>{e&&(w.current+=e,we())},[we]),Te=E.useCallback(()=>{if(A.current?.(),A.current=null,j.current!==null&&typeof window<`u`&&(window.clearTimeout(j.current),j.current=null),!c){se.current=0;return}let e=_.current;if(!e)return;let t=y.current;if(!t)return;se.current=0;let n=2.2,r=2.8,i=.25,a=.05,s=.015,l={lastY:null,lastTime:null,velocity:0,rafId:null,startX:null,startY:null,didMove:!1},u=()=>typeof performance<`u`?performance.now():Date.now(),d=Math.max(12,Math.round(o*1.35)),f=0,ee=e=>{if(!e)return!1;let n=t.getViewportY(),r=f+e,i=Math.trunc(r/d);return f=r-i*d,i!==0&&t.scrollLines(i),t.getViewportY()!==n},p=()=>{l.rafId!==null&&typeof window<`u`&&window.cancelAnimationFrame(l.rafId),l.rafId=null},m={passive:!1,capture:!1};if(typeof window<`u`&&`PointerEvent`in window){let t=Object.assign(l,{pointerId:null,startX:null,startY:null,moved:!1}),o=n=>{if(n.pointerType===`touch`){p(),t.pointerId=n.pointerId,t.startX=n.clientX,t.startY=n.clientY,t.moved=!1,t.lastY=n.clientY,t.lastTime=u(),t.velocity=0;try{e.setPointerCapture(n.pointerId)}catch{}}},d=e=>{if(e.pointerType!==`touch`||t.pointerId!==e.pointerId)return;if(t.startX!==null&&t.startY!==null&&!t.moved){let n=e.clientX-t.startX,r=e.clientY-t.startY;Math.hypot(n,r)>=6&&(t.moved=!0)}if(t.lastY===null){t.lastY=e.clientY,t.lastTime=u();return}let a=t.lastY,o=t.lastTime??u(),s=u();t.lastY=e.clientY,t.lastTime=s;let c=a-e.clientY;if(Math.abs(c)<1)return;let l=Math.max(s-o,8),d=c*(n+Math.min(r,Math.abs(c)/25)),f=d/l;t.velocity=t.velocity*.75+f*i,t.velocity>8?t.velocity=8:t.velocity<-8&&(t.velocity=-8),t.moved&&(e.cancelable&&e.preventDefault(),e.stopPropagation()),ee(d)},f=n=>{if(n.pointerType!==`touch`||t.pointerId!==n.pointerId)return;let r=!t.moved;t.pointerId=null,t.startX=null,t.startY=null,t.moved=!1,t.lastY=null,t.lastTime=null;try{e.releasePointerCapture(n.pointerId)}catch{}if(r){I?z(n.clientX,n.clientY):c&&!pe.current&&(pe.current=!0,y.current?.focus());return}if(typeof window>`u`)return;if(Math.abs(t.velocity)<a){t.velocity=0;return}let i=u(),o=()=>{let e=u(),n=Math.max(e-i,8);i=e;let r=ee(t.velocity*n)??!1,c=Math.sign(t.velocity),l=Math.max(0,Math.abs(t.velocity)-s*n);if(t.velocity=l*c,!r||l<=a){p(),t.velocity=0;return}t.rafId=window.requestAnimationFrame(o)};t.rafId=window.requestAnimationFrame(o)};e.addEventListener(`pointerdown`,o,m),e.addEventListener(`pointermove`,d,m),e.addEventListener(`pointerup`,f,m),e.addEventListener(`pointercancel`,f,m);let h=e.style.touchAction,g=e.style.overscrollBehaviorY;e.style.touchAction=`none`,e.style.overscrollBehaviorY=`contain`,A.current=()=>{p(),j.current!==null&&typeof window<`u`&&(window.clearTimeout(j.current),j.current=null),se.current=0,e.removeEventListener(`pointerdown`,o,m),e.removeEventListener(`pointermove`,d,m),e.removeEventListener(`pointerup`,f,m),e.removeEventListener(`pointercancel`,f,m),e.style.touchAction=h,e.style.overscrollBehaviorY=g};return}let h=e=>{e.touches.length===1&&(p(),l.lastY=e.touches[0].clientY,l.lastTime=u(),l.velocity=0,l.startX=e.touches[0].clientX,l.startY=e.touches[0].clientY,l.didMove=!1)},g=e=>{if(e.touches.length!==1){l.lastY=null,l.lastTime=null,l.velocity=0,l.startX=null,l.startY=null,l.didMove=!1,p();return}let t=e.touches[0].clientX,a=e.touches[0].clientY;if(l.startX!==null&&l.startY!==null&&!l.didMove){let e=t-l.startX,n=a-l.startY;Math.hypot(e,n)>=6&&(l.didMove=!0)}if(l.lastY===null){l.lastY=a,l.lastTime=u();return}let o=l.lastY,s=l.lastTime??u(),c=u();l.lastY=a,l.lastTime=c;let d=o-a;if(Math.abs(d)<1)return;let f=Math.max(c-s,8),m=d*(n+Math.min(r,Math.abs(d)/25)),h=m/f;l.velocity=l.velocity*.75+h*i,l.velocity>8?l.velocity=8:l.velocity<-8&&(l.velocity=-8),l.didMove&&(e.preventDefault(),e.stopPropagation()),ee(m)},v=e=>{let t=!l.didMove;l.lastY=null,l.lastTime=null;let n=l.velocity;if(l.startX=null,l.startY=null,l.didMove=!1,t){let t=e.changedTouches?.[0];I?z(t?.clientX,t?.clientY):c&&!pe.current&&(pe.current=!0,y.current?.focus());return}if(typeof window>`u`)return;if(Math.abs(n)<a){l.velocity=0;return}let r=u(),i=()=>{let e=u(),t=Math.max(e-r,8);r=e;let n=ee(l.velocity*t)??!1,o=Math.sign(l.velocity),c=Math.max(0,Math.abs(l.velocity)-s*t);if(l.velocity=c*o,!n||c<=a){p(),l.velocity=0;return}l.rafId=window.requestAnimationFrame(i)};l.rafId=window.requestAnimationFrame(i)};e.addEventListener(`touchstart`,h,m),e.addEventListener(`touchmove`,g,m),e.addEventListener(`touchend`,v,m),e.addEventListener(`touchcancel`,v,m);let b=e.style.touchAction,te=e.style.overscrollBehaviorY;e.style.touchAction=`none`,e.style.overscrollBehaviorY=`contain`,A.current=()=>{p(),j.current!==null&&typeof window<`u`&&(window.clearTimeout(j.current),j.current=null),se.current=0,e.removeEventListener(`touchstart`,h,m),e.removeEventListener(`touchmove`,g,m),e.removeEventListener(`touchend`,v,m),e.removeEventListener(`touchcancel`,v,m),e.style.touchAction=b,e.style.overscrollBehaviorY=te}},[c,I,z,o]);E.useEffect(()=>{let e=!1,t=null,n=null,r=null,s=[],l=null,d=null,ee=null,p=_.current;if(!p)return;if(p.tabIndex=I?-1:0,I){let e=p.focus.bind(p),t=p;t.focus=((...e)=>{z()}),ee=()=>{t.focus=e}}let m=()=>{L(!0)},h=()=>{L(!1)},g=e=>{let t=e.target;if(t&&p.contains(t)){if(I&&t instanceof HTMLElement){window.setTimeout(()=>{t.blur(),z()},0),L(!1);return}if(c&&!pe.current&&t instanceof HTMLElement){window.setTimeout(()=>{t.blur()},0),L(!1);return}L(!0);return}L(!1)},b=()=>{L(!1)},S=null;return(async()=>{try{let ee=await k();if(e)return;let g=re(a,o,i,ee,!1),_=new u(g);oe.current=!0,I&&(_.focus=()=>{});let b=_;if(typeof b.scrollToBottom==`function`){let e=b.scrollToBottom.bind(b);b.scrollToBottom=()=>{oe.current&&e()},l=()=>{b.scrollToBottom=e}}let C=new f;if(t=_,y.current=_,te.current=C,_.loadAddon(C),_.open(p),c){let e=_.renderer;if(e&&typeof e.renderScrollbar==`function`){let t=e.renderScrollbar.bind(e);e.renderScrollbar=()=>{},d=()=>{e.renderScrollbar=t}}}_e(),fe.current=!1,S=_.textarea??p.querySelector(`textarea`),S&&(S.addEventListener(`focus`,m),S.addEventListener(`blur`,h)),ye(),typeof MutationObserver<`u`&&(r=new MutationObserver(()=>{ye()}),r.observe(p,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`contenteditable`,`role`,`tabindex`,`aria-label`]}));let w=ae(p);w?(w.classList.add(`overlay-scrollbar-target`,`overlay-scrollbar-container`),v.current=w,he()):v.current=null,G();let T=C;typeof T.observeResize==`function`&&T.observeResize(),Te(),s=[_.onData(e=>{x.current(e)}),_.onScroll(e=>{if(typeof e==`number`&&Number.isFinite(e)){let t=typeof _.hasSelection==`function`&&_.hasSelection();oe.current=!t&&e<=.5}}),_.onSelectionChange(()=>{if(typeof _.hasSelection==`function`&&_.hasSelection()){oe.current=!1;return}let e=typeof _.getViewportY==`function`?_.getViewportY():0;oe.current=e<=.5})],n=new ResizeObserver(()=>{G()}),n.observe(p),typeof window<`u`&&window.setTimeout(()=>{G()},0)}catch{}})(),document.addEventListener(`focusin`,g,!0),window.addEventListener(`blur`,b),()=>{e=!0,A.current?.(),A.current=null,document.removeEventListener(`focusin`,g,!0),window.removeEventListener(`blur`,b),s.forEach(e=>e.dispose()),l?.(),l=null,d?.(),d=null,S&&(S.removeEventListener(`focus`,m),S.removeEventListener(`blur`,h)),n?.disconnect(),r?.disconnect(),ee?.(),t?.dispose(),y.current=null,te.current=null,v.current=null,C.current=null,fe.current=null,W()}},[ye,c,G,z,a,o,Te,i,W,L,I]),E.useEffect(()=>{let e=y.current;e&&(e.reset(),W(),C.current=null,G())},[e,ge,G,W]),E.useEffect(()=>{l&&y.current&&B()},[l,B,e,ge]),E.useEffect(()=>(Te(),()=>{A.current?.(),A.current=null}),[Te,e]),E.useEffect(()=>{let e=y.current;if(!e)return;if(t.length===0){O.current!==null&&(e.reset(),W(),G());return}let n=O.current,r;if(n===null)r=t;else{let e=t.findIndex(e=>e.id===n);r=e>=0?t.slice(e+1):t}r.length>0&&q(r.map(e=>e.data).join(``)),O.current=t[t.length-1].id},[t,ge,q,G,W]),E.useImperativeHandle(m,()=>({focus:()=>{B()},clear:()=>{let e=y.current;e&&(e.reset(),W(),G())},fit:()=>{G()}}),[B,G,W]);let J=E.useCallback(e=>{if(!I)return;let t=_.current,n=e.relatedTarget,r=n?.tagName;r===`INPUT`||r===`TEXTAREA`||n?.isContentEditable,n?.getAttribute(`data-terminal-hidden-input`),n&&t?.contains(n)},[I]),Y=E.useCallback(e=>{let t=e.nativeEvent,n=t?.inputType??``,r=typeof t?.data==`string`?t.data:``;if(ue.current=typeof performance<`u`?performance.now():Date.now(),n===`insertCompositionText`){N.current=!0;return}if(!n&&r){if(N.current)return;e.preventDefault(),x.current(r),le.current={type:`insertText`,at:typeof performance<`u`?performance.now():Date.now()},P.current=!0;return}if(n===`insertText`&&r){if(N.current)return;e.preventDefault(),x.current(r),le.current={type:n,at:typeof performance<`u`?performance.now():Date.now()},P.current=!0;return}if(n===`insertLineBreak`){if(N.current)return;e.preventDefault(),x.current(`\r`),le.current={type:n,at:typeof performance<`u`?performance.now():Date.now()},P.current=!0;return}if(n===`deleteContentBackward`){if(N.current)return;e.preventDefault(),x.current(``),le.current={type:n,at:typeof performance<`u`?performance.now():Date.now()},P.current=!0}},[]),X=E.useCallback(e=>{let t=e.currentTarget;if(ue.current=typeof performance<`u`?performance.now():Date.now(),N.current)return;if(P.current){let e=le.current,n=typeof performance<`u`?performance.now():Date.now();if(e&&n-e.at<50){P.current=!1,H(t);return}P.current=!1}let n=V(t);if(!n)return;F.current=n;let r=n.replace(/\r\n|\r|\n/g,`\r`);x.current(r),H(t),F.current=``},[H,V]),Ee=E.useCallback(e=>{e.stopPropagation();let t=e.key.toLowerCase(),n=e.metaKey&&!e.ctrlKey&&!e.altKey&&t===`c`,r=e.ctrlKey&&e.shiftKey&&!e.metaKey&&!e.altKey&&t===`c`;if((n||r)&&Ce()){e.preventDefault(),Se();return}if(e.ctrlKey&&!e.metaKey&&!e.altKey&&e.key.length===1){let t=e.key.toUpperCase();if(t>=`A`&&t<=`Z`){e.preventDefault(),e.nativeEvent?.stopImmediatePropagation(),x.current(String.fromCharCode(t.charCodeAt(0)-64)),H(e.currentTarget);return}}if(e.altKey&&!e.ctrlKey&&!e.metaKey&&e.key.length===1){e.preventDefault(),e.nativeEvent?.stopImmediatePropagation(),x.current(`\x1B`+e.key),H(e.currentTarget);return}let i={ArrowUp:`\x1B[A`,ArrowDown:`\x1B[B`,ArrowRight:`\x1B[C`,ArrowLeft:`\x1B[D`,Escape:`\x1B`,Tab:` `,Delete:`\x1B[3~`,Home:`\x1B[H`,End:`\x1B[F`}[e.key];if(i){e.preventDefault(),x.current(i),H(e.currentTarget);return}let a=e.currentTarget;if(e.nativeEvent?.isComposing)return;let o=le.current,s=typeof performance<`u`?performance.now():Date.now(),c=!!(o&&s-o.at<50);if(e.key===`Enter`){if(c&&o?.type===`insertLineBreak`)return;e.preventDefault(),x.current(`\r`),H(a);return}if(e.key===`Backspace`){if(e.preventDefault(),c&&o?.type===`deleteContentBackward`)return;V(a)||x.current(``)}if(e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey){let t=ue.current;t&&s-t<50||(e.preventDefault(),x.current(e.key),P.current=!0,le.current={type:`keydown-text`,at:s})}be(a)},[H,Se,Ce,V,be]),De=E.useCallback(e=>{e.stopPropagation();let t=e.currentTarget;e.nativeEvent?.isComposing||be(t)},[be]),Oe=E.useCallback(e=>{let t=e.currentTarget;N.current=!1;let n=e.data||V(t);if(ue.current=typeof performance<`u`?performance.now():Date.now(),!n)return;let r=n.replace(/\r\n|\r|\n/g,`\r`);x.current(r),H(t),le.current={type:`compositionend`,at:typeof performance<`u`?performance.now():Date.now()},P.current=!0},[H,V]),ke=E.useCallback(e=>{e.stopPropagation();let t=e.clipboardData?.getData(`text`)??``;if(!t)return;e.preventDefault();let n=y.current?.hasBracketedPaste?.()?`\x1b[200~${t}\x1b[201~`:t;x.current(n)},[]),Ae={position:`fixed`,left:0,top:0,width:1,height:1,opacity:0,zIndex:-1,background:`transparent`,color:`transparent`,WebkitTextFillColor:`transparent`,caretColor:`transparent`,textShadow:`none`,WebkitAppearance:`none`,appearance:`none`,resize:`none`,overflow:`hidden`,whiteSpace:`nowrap`,border:`0`,padding:0,margin:0,outline:`none`,outlineOffset:0,fontSize:16,fontWeight:400,pointerEvents:`none`,WebkitUserSelect:`none`,userSelect:`none`};return(0,D.jsxs)(`div`,{ref:_,className:h(`relative h-full w-full terminal-viewport-container`,s),"data-hidden-input-overlay-active":I?`true`:void 0,style:{backgroundColor:i.background},onTouchStart:e=>{if(!(!I||c)&&!Ce()){let t=e.touches?.[0];z(t?.clientX,t?.clientY)}},onClick:e=>{if(!c)if(I){if(Ce())return;z(e.clientX,e.clientY)}else y.current?.focus()},onMouseUp:()=>{!c&&Ce()&&Se()},onTouchEnd:()=>{!c&&Ce()&&Se()},children:[I&&typeof document<`u`?(0,ie.createPortal)((0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`input`,{ref:M,type:`text`,inputMode:`text`,autoCapitalize:`off`,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,tabIndex:-1,enterKeyHint:`send`,"data-terminal-hidden-input":`true`,"aria-label":g(`terminalView.viewport.inputAria`),"aria-hidden":`true`,style:{...Ae,display:R?`block`:`none`},onBlur:J,onBeforeInput:Y,onCompositionStart:()=>{N.current=!0},onInput:X,onKeyDown:Ee,onKeyUp:De,onCompositionEnd:Oe,onPaste:ke}),(0,D.jsx)(`textarea`,{ref:ce,inputMode:`text`,autoCapitalize:`off`,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,tabIndex:-1,enterKeyHint:`send`,"data-terminal-hidden-input":`true`,"aria-label":g(`terminalView.viewport.inputAria`),"aria-hidden":`true`,style:{...Ae,display:R?`none`:`block`},onBlur:J,onBeforeInput:Y,onCompositionStart:()=>{N.current=!0},onInput:X,onKeyDown:Ee,onKeyUp:De,onCompositionEnd:Oe,onPaste:ke})]}),document.body):null,v.current&&!c?(0,D.jsx)(b,{containerRef:v,disableHorizontal:!0,className:`overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero`}):null]})});oe.displayName=`TerminalViewport`;var A=RegExp(`\x1B\\[[0-9;?]*[ -/]*[@-~]`,`g`),j=/(https?:\/\/(?:localhost|127\.0\.0\.1|0\.0\.0\.0|\[(?:::1|::)\])(?::\d{2,5})?(?:\/[^\s<>'"`]*)?)/gi,se=/(?:➜\s*(?:Local|Network):)|\b(?:local|network|loopback|serving|listening|available|ready|started|running|server|vite|webpack|next\.js|astro|sveltekit|nuxt)\b/i,ce=/Serving HTTP on .*? port (\d{2,5})/i,M=new Set([`.`,`,`,`;`,`:`,`!`,`?`]),N=e=>{let t=e;for(;t.length>0;){let e=t[t.length-1];if(e===`)`||e===`]`||e===`}`||e===`>`){let n=e===`)`?`(`:e===`]`?`[`:e===`}`?`{`:`<`,r=t.slice(0,-1);if((r.match(RegExp(`\\${n}`,`g`))||[]).length>(r.match(RegExp(`\\${e}`,`g`))||[]).length)break;t=r;continue}if(M.has(e)){t=t.slice(0,-1);continue}break}return t},P=e=>{let t=N(e);return t=t.replace(`0.0.0.0`,`127.0.0.1`),t=t.replace(`[::1]`,`127.0.0.1`),t=t.replace(`[::]`,`127.0.0.1`),t},le=e=>{if(!e)return null;let t=e.replace(A,``),n=t.match(ce);if(n?.[1]){let e=Number.parseInt(n[1],10);if(Number.isFinite(e)&&e>0&&e<=65535)return`http://127.0.0.1:${e}/`}let r=t.split(`
|
|
2
|
-
`);for(let e of r){if(!se.test(e))continue;let t=Array.from(e.matchAll(j));if(t.length!==0)return P((t.find(e=>{try{return!!new URL(P(e[1])).port}catch{return!1}})??t[0])[1])}return null},ue=async(e,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)}},de={esc:`\x1B`,tab:` `,enter:`\r`,"arrow-up":`\x1B[A`,"arrow-down":`\x1B[B`,"arrow-left":`\x1B[D`,"arrow-right":`\x1B[C`},F={ctrl:`5`,cmd:`3`},fe={retry:{maxRetries:3,initialDelayMs:500,maxDelayMs:8e3},connectionTimeoutMs:1e4},pe={retry:{maxRetries:8,initialDelayMs:400,maxDelayMs:8e3},connectionTimeoutMs:15e3},me=(e,t)=>{if(t)switch(e){case`arrow-up`:return`\u001b[1;${F[t]}A`;case`arrow-down`:return`\u001b[1;${F[t]}B`;case`arrow-right`:return`\u001b[1;${F[t]}C`;case`arrow-left`:return`\u001b[1;${F[t]}D`}return de[e]??null},he=()=>{let{t:e}=ee(),{terminal:t,runtime:r}=te(),{currentTheme:i}=v(),{monoFont:a}=w(),u=c(e=>e.terminalFontSize),d=c(e=>e.bottomTerminalHeight),f=c(e=>e.isBottomTerminalExpanded),{isMobile:p,isTablet:b,hasTouchOnlyPointer:re}=y(),ie=p||b,O=(ie||re)&&r.platform===`web`,k=r.platform!==`vscode`,ae=c(e=>e.showTerminalQuickKeysOnDesktop),A=!n()&&(ie||ae),j=m(e=>e.currentSessionId),se=m(e=>e.newSessionDraft),ce=j!==null||se?.open===!0,M=x()??null,N=C(e=>e.sessions),P=C(e=>e.hasHydrated),de=C(e=>e.ensureDirectory),F=C(e=>e.createTab),he=C(e=>e.setActiveTab),ge=C(e=>e.closeTab),_e=C(e=>e.setTabSessionId),ve=C(e=>e.setTabLifecycle),I=C(e=>e.setConnecting),ye=C(e=>e.appendToBuffer),L=C(e=>e.setTabPreviewUrl),R=C(e=>e.clearBuffer),z=c(e=>e.openContextPreview),B=E.useMemo(()=>{if(M)return N.get(M)},[N,M]),V=E.useMemo(()=>B?k?B.activeTabId??B.tabs[0]?.id??null:B.tabs[0]?.id??null:null,[B,k]),H=E.useMemo(()=>{if(B)return V?B.tabs.find(e=>e.id===V)??B.tabs[0]:B.tabs[0]},[B,V]),be=E.useMemo(()=>(B?.tabs??[]).map(t=>({icon:(()=>{let e=t.iconKey?T[t.iconKey]??`terminal`:`terminal`;return(0,D.jsx)(g,{name:e,className:`h-4 w-4`})})(),id:t.id,label:t.label,title:t.label,closeLabel:e(`terminalView.tabs.closeTabTitle`)})),[B?.tabs,e]),U=H?.terminalSessionId??null,xe=H?.lifecycle??`idle`,Se=H?.bufferChunks??[],Ce=H?.isConnecting??!1,W=H?.previewUrl??null,[G,K]=E.useState(null),[we,q]=E.useState(!1),[Te,J]=E.useState(!1),[Y,X]=E.useState(null),[Ee,De]=E.useState(!1),[Oe,ke]=E.useState(0),Ae=E.useRef(null),je=E.useRef(null),Me=E.useRef(V),Ne=E.useRef(U),Pe=E.useRef(M),Fe=E.useRef(null),Ie=E.useRef(null),Le=E.useRef(!1),Re=E.useRef(!1),ze=E.useRef(null),Be=E.useRef(null),Ve=E.useRef(new Set),He=E.useRef(!1),Ue=E.useRef(``),We=E.useRef(new Set),Ge=E.useRef(0),Ke=E.useCallback(()=>{Ue.current=``,We.current.clear(),Ge.current+=1},[]),qe=E.useCallback(()=>{O||typeof document<`u`&&!document.hasFocus()||Fe.current?.focus()},[O]),Je=E.useCallback(()=>{O||Fe.current?.focus()},[O]);E.useEffect(()=>{if(!P||He.current)return;He.current=!0;let e=new Set;for(let[,t]of C.getState().sessions.entries())for(let n of t.tabs)n.terminalSessionId&&e.add(n.terminalSessionId);Ve.current=e},[P]);let Ye=c(e=>e.activeMainTab),Xe=c(e=>e.isBottomTerminalOpen),Ze=c(e=>e.setBottomTerminalOpen),Qe=c(e=>e.setBottomTerminalExpanded),$e=Ye===`terminal`,Z=$e||Xe,[et,tt]=E.useState(Z);E.useEffect(()=>{!Z||r.platform===`vscode`||l()},[Z,r.platform]),E.useEffect(()=>{Z&&tt(!0)},[Z]),E.useEffect(()=>{Re.current=Z},[Z]),E.useEffect(()=>{Ne.current=U},[U]),E.useEffect(()=>{Me.current=V,Ke()},[V,Ke]),E.useEffect(()=>{Pe.current=M},[M]),E.useEffect(()=>{!A&&Y!==null&&X(null)},[A,Y,X]),E.useEffect(()=>{!U&&Y!==null&&X(null)},[U,Y,X]);let Q=E.useCallback(()=>{Ae.current?.(),Ae.current=null,je.current=null,ze.current=null,J(!1)},[]);E.useEffect(()=>()=>{Q(),Ne.current=null},[Q]);let nt=E.useCallback((e,t,n)=>{if(!n)return;let r=`${Ue.current}${n}`.replace(/\r\n|\r/g,`
|
|
3
|
-
`),i=r.split(`
|
|
4
|
-
`),a=r.endsWith(`
|
|
5
|
-
`)?i.join(`
|
|
6
|
-
`):i.slice(0,-1).join(`
|
|
7
|
-
`);if(Ue.current=r.endsWith(`
|
|
8
|
-
`)?``:(i[i.length-1]??``).slice(-1024),!a)return;let o=le(a);if(!o||We.current.has(o))return;let s=Ge.current;We.current.add(o),ue(o).then(n=>{if(We.current.delete(o),!n||Ge.current!==s)return;let r=C.getState().getDirectoryState(e)?.tabs.find(e=>e.id===t);!r||r.previewUrlLocked||r.previewUrl===o||L(e,t,o,{locked:!1,autoOpened:!1})})},[L]),rt=E.useCallback((n,r,i,a=fe,o=!1)=>{if(je.current===i)return;Q(),je.current=i;let s=t.connect(i,{onEvent:a=>{if(je.current===i)switch(a.type){case`connected`:ze.current=i,I(n,r,!1),K(null),q(!1),J(!1),qe(),Be.current===i&&(Be.current=null,t.sendInput(i,`\r`).catch(()=>{}));break;case`reconnecting`:K(null),q(!1),J(!0);break;case`data`:a.data&&(ye(n,r,a.data),nt(n,r,a.data));break;case`exit`:{let t=typeof a.exitCode==`number`?a.exitCode:null,i=typeof a.signal==`number`?a.signal:null,o=!!(C.getState().getDirectoryState(n)?.tabs.find(e=>e.id===r))?.label?.startsWith(`Action:`);ye(n,r,e(`terminalView.stream.processExitedMessage`,{exitCodeSegment:t===null?``:e(`terminalView.stream.processExitedWithCode`,{exitCode:t}),signalSegment:i===null?``:e(`terminalView.stream.processExitedWithSignal`,{signal:i})})),ve(n,r,`exited`),_e(n,r,null),I(n,r,!1),K(o?null:e(`terminalView.error.sessionEnded`)),q(!1),J(!1),Q();break}}},onError:(t,a)=>{if(je.current===i){if(!a){K(null),q(!1);return}if(/session not found/i.test(t.message)||o){J(!1),K(null),q(!1),I(n,r,!0),R(n,r),ve(n,r,`idle`),_e(n,r,null),Q();return}J(!1),K(e(`terminalView.error.connectionFailed`,{message:t.message})),q(!0),I(n,r,!1),R(n,r),ve(n,r,`exited`),_e(n,r,null),Q()}}},a);Ae.current=()=>{s.close(),je.current=null}},[ye,R,Q,qe,nt,I,ve,_e,e,t]);E.useEffect(()=>{let n=!1;if(!(!P||!et)){if(!M){K(e(ce?`terminalView.empty.noWorkingDirectory`:`terminalView.empty.selectSession`));return}return(async()=>{let r=M;if(!Pe.current||Pe.current!==r)return;de(r);let i=C.getState().getDirectoryState(r);if(!i||i.tabs.length===0)return;let a=k?i.activeTabId??i.tabs[0]?.id??null:i.tabs[0]?.id??null;if(!a)return;let o=i.tabs.find(e=>e.id===a)??i.tabs[0],s=o?.terminalSessionId??null,c=o?.lifecycle??`idle`,l=!!o?.label?.startsWith(`Action:`),u=(o?.bufferLength??0)>0||(o?.bufferChunks?.length??0)>0;if(s)return;if(c===`exited`){I(r,a,!1);return}if(l&&u){I(r,a,!1);return}let d=Ie.current;if(!(!d&&Re.current)){K(null),q(!1),J(!1),I(r,a,!0);try{let e=await t.createSession({cwd:r,cols:d?.cols,rows:d?.rows});if(!(!n&&Pe.current===r&&Me.current===a)){try{await t.close(e.sessionId)}catch{}return}if(C.getState().getDirectoryState(r)?.tabs.find(e=>e.id===a)?.terminalSessionId){try{await t.close(e.sessionId)}catch{}return}_e(r,a,e.sessionId)}catch(t){n||(K(t instanceof Error?t.message:e(`terminalView.error.startSessionFailed`)),q(!0),J(!1),I(r,a,!1))}}})(),()=>{n=!0}}},[ce,M,U,xe,V,et,Oe,k,P,de,I,_e,e,t]);let it=E.useRef(rt);it.current=rt;let at=E.useRef(Q);at.current=Q,E.useEffect(()=>{if(!P||!et)return;if(!M){at.current();return}let e=M,t=C.getState().getDirectoryState(e);if(!t||t.tabs.length===0){at.current();return}let n=k?t.activeTabId??t.tabs[0]?.id??null:t.tabs[0]?.id??null;if(!n){at.current();return}let r=t.tabs.find(e=>e.id===n)??t.tabs[0],i=r?.terminalSessionId??null;if(!i){at.current(),Ne.current=null;return}if(je.current===i&&Ae.current){Ne.current=i;return}Ne.current=i;let a=Ve.current.has(i),o=a&&(r?.bufferLength??0)===0&&(r?.bufferChunks?.length??0)===0;a&&Ve.current.delete(i),o&&(Be.current=i),it.current(e,n,i,a?pe:fe,a)},[M,U,V,k,et,P]),E.useEffect(()=>{if(!Z||O)return;if(typeof window>`u`){qe();return}let e=window.requestAnimationFrame(()=>{qe()});return()=>{window.cancelAnimationFrame(e)}},[V,qe,Z,O]);let ot=E.useCallback(async()=>{if(!M||Ee)return;let t=C.getState().getDirectoryState(M),n=k?V??t?.activeTabId??t?.tabs[0]?.id??null:t?.tabs[0]?.id??null;if(n){De(!0),K(null),q(!1),J(!1),Q(),R(M,n),Ke();try{await ge(M,n)}catch(t){K(t instanceof Error?t.message:e(`terminalView.error.restartFailed`)),q(!0),J(!1)}finally{De(!1)}}},[V,R,ge,Q,M,k,Ee,Ke,e]),st=E.useCallback(async()=>{await ot()},[ot]),ct=E.useCallback(()=>{if(!M)return;let e=F(M);he(M,e),K(null),q(!1),J(!1),Q()},[F,Q,M,he]),lt=E.useCallback(e=>{M&&(he(M,e),K(null),q(!1),J(!1),Q())},[Q,M,he]),ut=E.useCallback(e=>{M&&(e===V&&Q(),K(null),q(!1),J(!1),ge(M,e))},[V,ge,Q,M]),dt=E.useCallback(n=>{if(!n||Te)return;let r=n,i=!1;if(Y&&n.length>0){let e=n[0];if(e.length===1&&/[a-zA-Z]/.test(e)){let t=e.toUpperCase();(Y===`ctrl`||Y===`cmd`)&&(r=String.fromCharCode(t.charCodeAt(0)&31),i=!0)}i||=!0}let a=Ne.current;!a||ze.current!==a||(t.sendInput(a,r).catch(t=>{Te||K(t instanceof Error?t.message:e(`terminalView.error.sendInputFailed`))}),i&&(X(null),Je()))},[Y,Je,Te,X,e,t]),ft=E.useCallback((e,n)=>{let r=Ie.current;if((!r||r.cols!==e||r.rows!==n)&&(Ie.current={cols:e,rows:n}),Le.current||(Le.current=!0,ke(e=>e+1)),!Re.current)return;let i=Ne.current;!i||ze.current!==i||t.resize({sessionId:i,cols:e,rows:n}).catch(()=>{})},[t]),pt=E.useCallback(e=>{X(t=>t===e?null:e),Je()},[Je,X]),mt=E.useCallback(e=>{let t=me(e,Y);t&&(dt(t),X(null),Je())},[Y,Je,dt,X]);E.useEffect(()=>{if(!A||!Y||!U)return;let e=e=>{if(e.repeat)return;let t=e.key;if(!t||t===`Control`||t===`Meta`||t===`Alt`||t===`Shift`)return;let n=t.length===1?t.toLowerCase():t,r=e.code??``,i=r.startsWith(`Key`)&&r.length===4?r.slice(3).toUpperCase():null,a=t.length===1&&/[a-zA-Z]/.test(t)?t.toUpperCase():i,o={Tab:`tab`,Enter:`enter`,ArrowUp:`arrow-up`,ArrowDown:`arrow-down`,ArrowLeft:`arrow-left`,ArrowRight:`arrow-right`,Escape:`esc`,tab:`tab`,enter:`enter`,arrowup:`arrow-up`,arrowdown:`arrow-down`,arrowleft:`arrow-left`,arrowright:`arrow-right`,escape:`esc`};if(n in o){e.preventDefault(),e.stopPropagation(),mt(o[n]);return}if(Y===`ctrl`&&a&&a.length===1&&a>=`A`&&a<=`Z`){let t=String.fromCharCode(a.charCodeAt(0)&31);e.preventDefault(),e.stopPropagation(),dt(t),X(null),Je()}};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[Y,mt,dt,Je,A,X,U]);let ht=E.useMemo(()=>{let e=s[o].stack;if(typeof window>`u`)return(s[a]??s[`system-mono`]).stack;let t=window.getComputedStyle(document.documentElement).getPropertyValue(`--font-family-mono`);return t&&t.trim().length>0?t.trim():(s[a]??s[`system-mono`]).stack??e},[a]),gt=E.useMemo(()=>ne(i),[i]),_t=E.useMemo(()=>`${M??`no-dir`}::${V??`no-tab`}`,[M,V]);if(E.useEffect(()=>{if(!Z||O)return;let e=Fe.current;if(!e)return;let t=()=>{e.fit()};if(typeof window<`u`){let e=window.requestAnimationFrame(()=>{t(),qe()}),n=[220,400].map(e=>window.setTimeout(t,e));return()=>{window.cancelAnimationFrame(e),n.forEach(e=>window.clearTimeout(e))}}t()},[qe,Z,O,_t,U]),E.useEffect(()=>{if(O||!Z||!Xe)return;let e=Fe.current;if(!e)return;let t=()=>{e.fit()};if(typeof window<`u`){let e=window.requestAnimationFrame(()=>{t()}),n=[0,80,180,320].map(e=>window.setTimeout(t,e));return()=>{window.cancelAnimationFrame(e),n.forEach(e=>window.clearTimeout(e))}}t()},[d,f,Xe,Z,O]),!ce)return(0,D.jsx)(`div`,{className:`flex h-full items-center justify-center p-4 text-center text-sm text-muted-foreground`,children:e(`terminalView.empty.selectSession`)});if(!M)return(0,D.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 p-4 text-center text-sm text-muted-foreground`,children:[(0,D.jsx)(`p`,{children:e(`terminalView.empty.noWorkingDirectoryForSession`)}),(0,D.jsx)(`button`,{onClick:ot,className:`rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90`,children:e(`terminalView.actions.retry`)})]});let $=!U||Ce||Ee||Te,vt=et,yt=!ie&&Xe&&!$e,bt=(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(_,{type:`button`,size:`sm`,variant:`outline`,className:`h-6 px-2 text-xs`,onClick:()=>mt(`esc`),disabled:$,children:e(`terminalView.quickKeys.escape`)}),(0,D.jsxs)(_,{type:`button`,size:`sm`,variant:`outline`,className:`h-6 w-9 p-0`,onClick:()=>mt(`tab`),disabled:$,children:[(0,D.jsx)(g,{name:`arrow-right`,className:`h-4 w-4`}),(0,D.jsx)(`span`,{className:`sr-only`,children:e(`terminalView.quickKeys.tabAria`)})]}),(0,D.jsxs)(_,{type:`button`,size:`sm`,variant:`chip`,"aria-pressed":Y===`ctrl`,className:`h-6 w-9 p-0`,onClick:()=>pt(`ctrl`),disabled:$,children:[(0,D.jsx)(`span`,{className:`text-xs font-medium`,children:e(`terminalView.quickKeys.controlLabel`)}),(0,D.jsx)(`span`,{className:`sr-only`,children:e(`terminalView.quickKeys.controlModifierAria`)})]}),(0,D.jsxs)(_,{type:`button`,size:`sm`,variant:`chip`,"aria-pressed":Y===`cmd`,className:`h-6 w-9 p-0`,onClick:()=>pt(`cmd`),disabled:$,children:[(0,D.jsx)(g,{name:`command`}),(0,D.jsx)(`span`,{className:`sr-only`,children:e(`terminalView.quickKeys.commandModifierAria`)})]}),(0,D.jsxs)(_,{type:`button`,size:`sm`,variant:`outline`,className:`h-6 w-9 p-0`,onClick:()=>mt(`arrow-up`),disabled:$,children:[(0,D.jsx)(g,{name:`arrow-up`}),(0,D.jsx)(`span`,{className:`sr-only`,children:e(`terminalView.quickKeys.arrowUpAria`)})]}),(0,D.jsxs)(_,{type:`button`,size:`sm`,variant:`outline`,className:`h-6 w-9 p-0`,onClick:()=>mt(`arrow-left`),disabled:$,children:[(0,D.jsx)(g,{name:`arrow-left`}),(0,D.jsx)(`span`,{className:`sr-only`,children:e(`terminalView.quickKeys.arrowLeftAria`)})]}),(0,D.jsxs)(_,{type:`button`,size:`sm`,variant:`outline`,className:`h-6 w-9 p-0`,onClick:()=>mt(`arrow-down`),disabled:$,children:[(0,D.jsx)(g,{name:`arrow-down`}),(0,D.jsx)(`span`,{className:`sr-only`,children:e(`terminalView.quickKeys.arrowDownAria`)})]}),(0,D.jsxs)(_,{type:`button`,size:`sm`,variant:`outline`,className:`h-6 w-9 p-0`,onClick:()=>mt(`arrow-right`),disabled:$,children:[(0,D.jsx)(g,{name:`arrow-right`}),(0,D.jsx)(`span`,{className:`sr-only`,children:e(`terminalView.quickKeys.arrowRightAria`)})]}),(0,D.jsxs)(_,{type:`button`,size:`sm`,variant:`outline`,className:`h-6 w-9 p-0`,onClick:()=>mt(`enter`),disabled:$,children:[(0,D.jsx)(g,{name:`arrow-go-back`}),(0,D.jsx)(`span`,{className:`sr-only`,children:e(`terminalView.quickKeys.enterAria`)})]})]});return(0,D.jsxs)(`div`,{"data-terminal-view":`true`,className:`flex h-full flex-col overflow-hidden bg-[var(--surface-background)]`,children:[(0,D.jsxs)(`div`,{className:h(`app-region-no-drag sticky top-0 z-20 shrink-0 bg-[var(--surface-background)] text-xs`,ie?`px-3 py-1.5`:`pl-3 pr-1.5 py-1`),children:[k&&B?(0,D.jsxs)(`div`,{className:`flex items-center gap-2 pl-1 pr-1`,children:[(0,D.jsx)(`div`,{className:h(`min-w-0 flex-1`,ie?`h-8`:`h-7`),children:(0,D.jsx)(S,{items:be,activeId:V,onSelect:lt,onClose:ut,layoutMode:`scrollable`,variant:`default`,className:`h-full bg-transparent`})}),(0,D.jsx)(_,{type:`button`,size:`xs`,variant:`ghost`,className:h(`shrink-0`,ie?`h-8 w-8 p-0`:`h-7 w-7 p-0`),onClick:ct,title:e(`terminalView.tabs.newTabTitle`),children:(0,D.jsx)(g,{name:`add`,className:`${ie?`h-[18px] w-[18px]`:`h-4 w-4`}`})}),(0,D.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 overflow-visible`,children:[W?(0,D.jsxs)(_,{type:`button`,size:`xs`,variant:`outline`,className:`h-6 shrink-0 gap-1 px-2`,onClick:()=>{M&&z(M,W)},title:e(`terminalView.preview.openTitle`),children:[(0,D.jsx)(g,{name:`global`,className:`h-3.5 w-3.5 shrink-0`}),(0,D.jsx)(`span`,{className:`whitespace-nowrap`,children:e(`terminalView.preview.open`)})]}):null,yt?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(_,{type:`button`,size:`xs`,variant:`ghost`,onClick:()=>Qe(!f),className:h(`shrink-0 p-0`,p?`h-8 w-8`:`h-7 w-7`),title:e(f?`terminalView.bottomDock.restoreTitle`:`terminalView.bottomDock.expandTitle`),"aria-label":e(f?`terminalView.bottomDock.restoreAria`:`terminalView.bottomDock.expandAria`),children:f?(0,D.jsx)(g,{name:`fullscreen-exit`,className:`h-4 w-4`}):(0,D.jsx)(g,{name:`fullscreen`,className:`h-4 w-4`})}),(0,D.jsx)(_,{type:`button`,size:`xs`,variant:`ghost`,onClick:()=>Ze(!1),className:h(`shrink-0 p-0`,p?`h-8 w-8`:`h-7 w-7`),title:e(`terminalView.bottomDock.closeTitle`),"aria-label":e(`terminalView.bottomDock.closeAria`),children:(0,D.jsx)(g,{name:`close`,className:`h-4 w-4`})})]}):null]})]}):null,!p&&A&&k&&B?(0,D.jsx)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1 pl-1 pr-1`,children:bt}):null,A&&(p||!k||!B)?(0,D.jsx)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1`,children:bt}):null]}),(0,D.jsxs)(`div`,{className:`relative flex-1 overflow-hidden`,style:{backgroundColor:gt.background},children:[(0,D.jsx)(`div`,{className:`h-full w-full box-border pl-4 pr-1.5 pt-3 pb-4`,children:vt?(0,D.jsx)(oe,{ref:e=>{Fe.current=e},sessionKey:_t,chunks:Se,onInput:dt,onResize:ft,theme:gt,fontFamily:ht,fontSize:u,enableTouchScroll:O,autoFocus:!O&&Z,isVisible:Z},_t):null}),!Te&&G&&(0,D.jsxs)(`div`,{className:`absolute inset-x-0 bottom-0 bg-[var(--status-error-background)] px-3 py-2 text-xs text-[var(--status-error-foreground)] flex items-center justify-between gap-2`,children:[(0,D.jsx)(`span`,{children:G}),we&&p&&(0,D.jsx)(_,{size:`sm`,variant:`secondary`,className:`h-6 px-2 py-0 text-xs`,onClick:st,disabled:Ee,title:e(`terminalView.actions.hardRestartTitle`),type:`button`,children:e(`terminalView.actions.hardRestart`)})]})]})]})};export{he as TerminalView};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{nt as t,rt as n}from"./vendor-base-ui-CnHfUmDN.js";import{n as r}from"./vendor-react-DLPElpoQ.js";import{t as i}from"./vendor-class-variance-authority-BLUaYARZ.js";import{t as a}from"./utils-2ZK8yboQ.js";var o=r(),s=e(n(),1);function c(e,t){let n=(0,o.c)(3),r;return n[0]!==e||n[1]!==t?(r=n=>{for(let r of[e,t])r&&(typeof r==`function`?r(n):r.current=n)},n[0]=e,n[1]=t,n[2]=r):r=n[2],r}function l(e,t){let n={...t};for(let r in e){let i=t[r],a=e[r];n[r]=/^on[A-Z]/.test(r)&&typeof i==`function`&&typeof a==`function`?(...e)=>{a(...e),i(...e)}:r===`className`&&typeof i==`string`&&typeof a==`string`?`${a} ${i}`:r===`style`&&typeof i==`object`&&typeof a==`object`?{...a,...i}:a}return n}var u=s.forwardRef(function(e,t){let n=(0,o.c)(3),{children:r,...i}=e,a=s.isValidElement(r)?r:null,u=c(t,a?a.ref:void 0);if(!a)return null;let d=l(a.props,i),f;return n[0]!==u||n[1]!==d?(f={...d,ref:u},n[0]=u,n[1]=d,n[2]=f):f=n[2],s.cloneElement(a,f)}),d=t(),f=[`bg-[color-mix(in_srgb,var(--primary-base)_10%,var(--background))]`,`text-[var(--primary-base)]`,`border border-[color-mix(in_srgb,var(--primary-base)_12%,transparent)]`,`hover:bg-[color-mix(in_srgb,var(--primary-base)_16%,var(--background))]`,`active:bg-[color-mix(in_srgb,var(--primary-base)_22%,var(--background))]`,`dark:bg-[color-mix(in_srgb,var(--primary-base)_16%,transparent)]`,`dark:border-[color-mix(in_srgb,var(--primary-base)_20%,transparent)]`,`dark:hover:bg-[color-mix(in_srgb,var(--primary-base)_22%,transparent)]`,`dark:active:bg-[color-mix(in_srgb,var(--primary-base)_30%,transparent)]`].join(` `),p=[`bg-[color-mix(in_srgb,var(--status-error)_7%,var(--background))]`,`text-[var(--status-error)]`,`border border-[color-mix(in_srgb,var(--status-error)_9%,transparent)]`,`hover:bg-[color-mix(in_srgb,var(--status-error)_11%,var(--background))]`,`active:bg-[color-mix(in_srgb,var(--status-error)_16%,var(--background))]`,`dark:bg-[color-mix(in_srgb,var(--status-error)_9%,transparent)]`,`dark:border-[color-mix(in_srgb,var(--status-error)_14%,transparent)]`,`dark:hover:bg-[color-mix(in_srgb,var(--status-error)_14%,transparent)]`,`dark:active:bg-[color-mix(in_srgb,var(--status-error)_20%,transparent)]`].join(` `),m=i([`group relative inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-[10px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] typography-ui-label font-medium tracking-[0.01em] shrink-0 select-none`,`transition-[background-color,border-color,color,opacity,filter,transform] duration-150 ease-out outline-none`,`focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]`,`aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive`,`disabled:pointer-events-none disabled:opacity-50`,`[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`],{variants:{variant:{default:f,destructive:a(p,`focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40`),neutral:`bg-interactive-hover text-foreground border border-border/60 hover:bg-interactive-active`,outline:`bg-[var(--surface-elevated)] text-foreground border border-border/60 hover:bg-interactive-hover hover:text-foreground`,mobileGlass:`oc-mobile-floating-action text-foreground hover:brightness-105 active:bg-interactive-active focus-visible:border-transparent focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,chip:a(`border border-border/60 bg-transparent text-foreground hover:bg-interactive-hover hover:text-foreground`,`aria-pressed:bg-[color-mix(in_srgb,var(--primary-base)_10%,var(--background))]`,`aria-pressed:text-[var(--primary-base)]`,`aria-pressed:border-[color-mix(in_srgb,var(--primary-base)_12%,transparent)]`,`aria-pressed:hover:bg-[color-mix(in_srgb,var(--primary-base)_16%,var(--background))]`,`aria-pressed:hover:text-[var(--primary-base)]`,`dark:aria-pressed:bg-[color-mix(in_srgb,var(--primary-base)_16%,transparent)]`,`dark:aria-pressed:border-[color-mix(in_srgb,var(--primary-base)_20%,transparent)]`,`dark:aria-pressed:hover:bg-[color-mix(in_srgb,var(--primary-base)_22%,transparent)]`),secondary:`bg-interactive-hover text-foreground hover:bg-interactive-active`,ghost:`text-foreground hover:bg-interactive-hover hover:text-foreground active:bg-interactive-active`,link:`text-primary underline-offset-4 hover:underline`},size:{default:`h-9 px-3.5 has-[>svg]:px-3`,sm:`h-8 gap-1.5 px-2.5 has-[>svg]:px-2 rounded-[9px] supports-[corner-shape:squircle]:rounded-[50px]`,xs:`h-6 gap-1 px-2 typography-micro has-[>svg]:px-1.5 rounded-[7px] supports-[corner-shape:squircle]:rounded-[50px]`,lg:`h-10 px-4 has-[>svg]:px-3.5 rounded-[12px] supports-[corner-shape:squircle]:rounded-[50px]`,icon:`size-9`,mobileIcon:`size-10 min-h-10 min-w-10 rounded-full`}},defaultVariants:{variant:`default`,size:`default`}}),h=new Set([`icon`,`mobileIcon`,`xs`]);function g(e){let t=(0,o.c)(20),n,r,i,s,c,l;t[0]===e?(n=t[1],r=t[2],i=t[3],s=t[4],c=t[5],l=t[6]):({className:n,variant:l,size:i,asChild:s,type:c,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=s,t[5]=c,t[6]=l);let f=s!==void 0&&s,p=f?u:`button`,g;t[7]!==f||t[8]!==c?(g=f?c===void 0?{}:{type:c}:{type:c??`button`},t[7]=f,t[8]=c,t[9]=g):g=t[9];let _=g,v=i!=null&&h.has(i)?`compact`:void 0,y;t[10]!==n||t[11]!==i||t[12]!==l?(y=a(m({variant:l,size:i,className:n})),t[10]=n,t[11]=i,t[12]=l,t[13]=y):y=t[13];let b;return t[14]!==p||t[15]!==v||t[16]!==r||t[17]!==y||t[18]!==_?(b=(0,d.jsx)(p,{"data-slot":`button`,"data-mobile-press-feedback":v,className:y,..._,...r}),t[14]=p,t[15]=v,t[16]=r,t[17]=y,t[18]=_,t[19]=b):b=t[19],b}export{u as n,g as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{Jt as t,Qt as n,Yt as r}from"./persistence-DwRBC4zl.js";import{nt as i,rt as a}from"./vendor-base-ui-CnHfUmDN.js";import{n as o}from"./vendor-react-DLPElpoQ.js";import{a as s,i as c,o as l,t as u}from"./store-ClnJdJSj.js";var d=e(a(),1),f=o(),p=async(e,n)=>{if(!t())throw Error(`Desktop runtime is not available`);return r(e,n)},m=async()=>{if(n())try{await p(`desktop_start_window_drag`)}catch{}},h=async e=>{if(n())try{await p(`desktop_set_window_title`,{title:e})}catch{}},g=async(e,t)=>{if(n())try{await p(`desktop_set_window_theme`,{themeMode:e,themeVariant:t})}catch{}},_=async e=>{if(n())try{await p(`desktop_set_menu_locale`,{locale:e})}catch{}},v=async()=>{if(!n())return null;try{let e=await p(`desktop_get_app_version`);return typeof e==`string`&&e.trim().length>0?e:null}catch{return null}},y=d.createContext(null),b=i(),x=e=>{let t=(0,f.c)(19),{children:n}=e,r=c(S),i=c(C),a=c(w),o=c(T),p,m;t[0]===r?(p=t[1],m=t[2]):(p=()=>{typeof document>`u`||(document.documentElement.lang=r)},m=[r],t[0]=r,t[1]=p,t[2]=m),d.useEffect(p,m);let h,g;t[3]!==a||t[4]!==r?(h=()=>{a===null&&_(r)},g=[r,a],t[3]=a,t[4]=r,t[5]=h,t[6]=g):(h=t[5],g=t[6]),d.useEffect(h,g);let v;t[7]===i?v=t[8]:(v=(e,t)=>u(i,e,t),t[7]=i,t[8]=v);let x=v,E;t[9]===x?E=t[10]:(E=e=>x(l[e]),t[9]=x,t[10]=E);let D;t[11]!==r||t[12]!==o||t[13]!==x||t[14]!==E?(D={locale:r,locales:s,setLocale:o,label:E,t:x},t[11]=r,t[12]=o,t[13]=x,t[14]=E,t[15]=D):D=t[15];let O=D,k;return t[16]!==n||t[17]!==O?(k=(0,b.jsx)(y.Provider,{value:O,children:n}),t[16]=n,t[17]=O,t[18]=k):k=t[18],k};function S(e){return e.locale}function C(e){return e.dictionary}function w(e){return e.loadingLocale}function T(e){return e.setLocale}var E={en:`en-US`,fr:`fr-FR`,"zh-CN":`zh-CN`,"zh-TW":`zh-TW`,uk:`uk-UA`,es:`es-ES`,"pt-BR":`pt-BR`,ko:`ko-KR`,pl:`pl-PL`,ja:`ja-JP`},D=e=>E[e]??`en-US`,O=()=>D(c.getState().locale);function k(){let e=d.useContext(y);if(!e)throw Error(`useI18n must be used within I18nProvider`);return e}async function A(e){let t=null;if(typeof navigator<`u`&&navigator.clipboard?.writeText)try{return await navigator.clipboard.writeText(e),{ok:!0,method:`clipboard`}}catch(e){t=e instanceof Error?e.message:String(e)}if(typeof document<`u`&&document.body){let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.top=`-1000px`,t.style.left=`-1000px`,document.body.appendChild(t),t.select(),t.setSelectionRange(0,t.value.length);let n=document.execCommand(`copy`);if(document.body.removeChild(t),n)return{ok:!0,method:`execCommand`}}return{ok:!1,error:t??`Clipboard access denied in current context`}}export{v as a,h as c,x as i,m as l,k as n,p as o,O as r,g as s,A as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{n as t,nt as n,r,rt as i,t as a}from"./vendor-base-ui-CnHfUmDN.js";import{n as o}from"./vendor-react-DLPElpoQ.js";import{t as s}from"./utils-2ZK8yboQ.js";var c=o(),l=e(i(),1),u=n(),d=r,f=e=>{let n=(0,c.c)(14),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({className:a,asChild:r,children:i,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let d;n[5]!==r||n[6]!==i?(d=r&&l.isValidElement(i)?{render:i}:{children:i},n[5]=r,n[6]=i,n[7]=d):d=n[7];let f=d,p;n[8]===a?p=n[9]:(p=s(`flex w-full items-center justify-between rounded-lg px-2 py-1.5 text-left text-foreground hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,a),n[8]=a,n[9]=p);let m;return n[10]!==o||n[11]!==f||n[12]!==p?(m=(0,u.jsx)(t,{className:p,...o,...f}),n[10]=o,n[11]=f,n[12]=p,n[13]=m):m=n[13],m},p=e=>{let t=(0,c.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=s(`overflow-hidden data-[closed]:animate-collapsible-up data-[open]:animate-collapsible-down`,n),t[3]=n,t[4]=i);let o;return t[5]!==r||t[6]!==i?(o=(0,u.jsx)(a,{className:i,...r}),t[5]=r,t[6]=i,t[7]=o):o=t[7],o};export{p as n,f as r,d as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./rolldown-runtime-C0FnF6B9.js";import{E as e,F as t,I as n,N as r,P as i,a,i as o,nt as s,rt as c}from"./vendor-base-ui-CnHfUmDN.js";import{n as l}from"./vendor-react-DLPElpoQ.js";import{t as u}from"./utils-2ZK8yboQ.js";import{n as d,r as f,t as p}from"./dropdown-menu.styles-Bzo6L3FH.js";var m=l();c();var h=s();function g(e){let t=(0,m.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,h.jsx)(a,{...n}),t[2]=n,t[3]=r),r}function _(e){let t=(0,m.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,h.jsx)(o,{...n}),t[2]=n,t[3]=r),r}function v(e){let n=(0,m.c)(20),a,o,s,c,l;n[0]===e?(a=n[1],o=n[2],s=n[3],c=n[4],l=n[5]):({className:o,positionerClassName:s,children:a,style:l,...c}=e,n[0]=e,n[1]=a,n[2]=o,n[3]=s,n[4]=c,n[5]=l);let f;n[6]===s?f=n[7]:(f=u(`app-region-no-drag z-50`,s),n[6]=s,n[7]=f);let p;n[8]===l?p=n[9]:(p={backgroundColor:`var(--surface-elevated)`,color:`var(--surface-elevated-foreground)`,...l},n[8]=l,n[9]=p);let g;n[10]===o?g=n[11]:(g=u(d,o),n[10]=o,n[11]=g);let _;n[12]!==a||n[13]!==c||n[14]!==p||n[15]!==g?(_=(0,h.jsx)(t,{"data-slot":`dropdown-menu-content`,style:p,className:g,...c,children:a}),n[12]=a,n[13]=c,n[14]=p,n[15]=g,n[16]=_):_=n[16];let v;return n[17]!==f||n[18]!==_?(v=(0,h.jsx)(i,{children:(0,h.jsx)(r,{className:f,children:_})}),n[17]=f,n[18]=_,n[19]=v):v=n[19],v}function y(e){let t=(0,m.c)(8),r,i;t[0]===e?(r=t[1],i=t[2]):({className:r,...i}=e,t[0]=e,t[1]=r,t[2]=i);let a;t[3]===r?a=t[4]:(a=u(p,r),t[3]=r,t[4]=a);let o;return t[5]!==i||t[6]!==a?(o=(0,h.jsx)(n,{className:a,...i}),t[5]=i,t[6]=a,t[7]=o):o=t[7],o}function b(t){let n=(0,m.c)(8),r,i;n[0]===t?(r=n[1],i=n[2]):({className:r,...i}=t,n[0]=t,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=u(f,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==a?(o=(0,h.jsx)(e,{className:a,...i}),n[5]=i,n[6]=a,n[7]=o):o=n[7],o}export{_ as a,b as i,v as n,y as r,g as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{nt as t,rt as n}from"./vendor-base-ui-CnHfUmDN.js";import{t as r}from"./utils-2ZK8yboQ.js";import{t as i}from"./vendor-react-drawio-ECtEwvbc.js";var a=e(n(),1),o=t(),s=`<mxfile><diagram id="new" name="Page-1"><mxGraphModel dx="0" dy="0" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0"><root><mxCell id="0"/><mxCell id="1" parent="0"/></root></mxGraphModel></diagram></mxfile>`;function c(){if(typeof document>`u`)return!1;let e=document.documentElement.getAttribute(`data-theme`);return e===`dark`||!e&&window.matchMedia(`(prefers-color-scheme: dark)`).matches}var l=a.forwardRef(function({xml:e,readOnly:t,className:n,onChange:l},u){let d=a.useRef(e),f=a.useRef(null),p=a.useRef(!1),[m,h]=a.useState(c),g=a.useRef(e),_=a.useRef(e);_.current!==e&&(_.current=e,g.current=e,d.current=e);let v=a.useRef(m);v.current!==m&&(v.current=m,g.current=d.current);let y=a.useRef(null);a.useEffect(()=>{let e=()=>h(c());e();let t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-theme`]}),()=>t.disconnect()},[]),a.useEffect(()=>{let e=setTimeout(()=>{y.current?.querySelector(`.diagrams-iframe`)?.focus()},600);return()=>clearTimeout(e)},[]),a.useImperativeHandle(u,()=>({getXml:()=>d.current}));let b=a.useCallback(()=>{!e&&!p.current&&(p.current=!0,setTimeout(()=>{f.current?.template({})},500))},[e]),x=a.useCallback(e=>{d.current=e.xml,l?.(e.xml)},[l]);return(0,o.jsx)(`div`,{ref:y,className:r(`h-full w-full`,n),children:(0,o.jsx)(i,{ref:f,xml:g.current||s,autosave:!0,urlParameters:{ui:t?`simple`:m?`dark`:`kennedy`,spin:!0,libraries:!t,chrome:t,nav:t,layers:t,noSaveBtn:!0,noExitBtn:!0,saveAndExit:!1},onLoad:b,onAutoSave:x},m?`dark`:`light`)})});export{l as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{$ as t,J as n,K as r,Q as i,X as a,Y as o,Z as s,nt as c,q as l,rt as u}from"./vendor-base-ui-CnHfUmDN.js";import{n as d}from"./vendor-react-DLPElpoQ.js";import{n as f}from"./clipboard-GUUNlWIv.js";import{t as p}from"./utils-2ZK8yboQ.js";import{n as m}from"./Icon-D1BcR8Tz.js";var h=[{var:`--status-success`,class:`agent-success`},{var:`--syntax-keyword`,class:`agent-keyword`},{var:`--syntax-type`,class:`agent-type`},{var:`--syntax-function`,class:`agent-function`},{var:`--syntax-number`,class:`agent-number`},{var:`--status-info`,class:`agent-info`},{var:`--status-warning`,class:`agent-warning`},{var:`--syntax-variable`,class:`agent-variable`}];function g(e){if(!e||e===`build`)return h[0];let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t=(t<<5)-t+r,t&=t}return h[1+Math.abs(t)%(h.length-1)]}var _=5,v=Math.ceil(_/2);function y(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return t>>>0}function b(e){let t=Array.from({length:_},()=>Array.from({length:_},()=>!1));if(!e)return t;let n=y(e);for(let e=0;e<_;e++)for(let r=0;r<v;r++){let i=(n&1)==1;n>>>=1,t[e][r]=i,t[e][4-r]=i}return t}var x=d(),S=e(u(),1),C=c(),w=0;function T(e,t){return e&&S.isValidElement(t)?{render:t}:{children:t}}function E(e){let t=(0,x.c)(4),r;t[0]===e?r=t[1]:({...r}=e,t[0]=e,t[1]=r);let i;return t[2]===r?i=t[3]:(i=(0,C.jsx)(n,{...r}),t[2]=r,t[3]=i),i}function D(e){let t=(0,x.c)(10),n,i,a;t[0]===e?(n=t[1],i=t[2],a=t[3]):({asChild:n,children:i,...a}=e,t[0]=e,t[1]=n,t[2]=i,t[3]=a);let o;t[4]!==n||t[5]!==i?(o=T(n,i),t[4]=n,t[5]=i,t[6]=o):o=t[6];let s=o,c;return t[7]!==a||t[8]!==s?(c=(0,C.jsx)(r,{"data-slot":`dialog-trigger`,...a,...s}),t[7]=a,t[8]=s,t[9]=c):c=t[9],c}function O(e){let t=(0,x.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,C.jsx)(o,{...n}),t[2]=n,t[3]=r),r}var k=S.forwardRef((e,n)=>{let r=(0,x.c)(10),i,a;r[0]===e?(i=r[1],a=r[2]):({className:i,...a}=e,r[0]=e,r[1]=i,r[2]=a);let o;r[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=[],r[3]=o):o=r[3],S.useEffect(I,o);let s=n,c;r[4]===i?c=r[5]:(c=p(`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`,i),r[4]=i,r[5]=c);let l;return r[6]!==a||r[7]!==s||r[8]!==c?(l=(0,C.jsx)(t,{ref:s,"data-slot":`dialog-overlay`,className:c,...a}),r[6]=a,r[7]=s,r[8]=c,r[9]=l):l=r[9],l});k.displayName=`DialogOverlay`;function A(e){let t=(0,x.c)(29),n,r,o,s,c,l;t[0]===e?(n=t[1],r=t[2],o=t[3],s=t[4],c=t[5],l=t[6]):({className:r,overlayClassName:s,containerClassName:o,children:n,showCloseButton:l,...c}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=o,t[4]=s,t[5]=c,t[6]=l);let u=l===void 0||l,{t:d}=f(),h;t[7]===s?h=t[8]:(h=p(`rounded-none`,s),t[7]=s,t[8]=h);let g;t[9]===h?g=t[10]:(g=(0,C.jsx)(k,{className:h}),t[9]=h,t[10]=g);let _=o??`items-center p-4`,v;t[11]===_?v=t[12]:(v=p(`fixed inset-0 z-50 flex justify-center pointer-events-none`,_),t[11]=_,t[12]=v);let y;t[13]===r?y=t[14]:(y=p(`relative pointer-events-auto bg-background text-foreground flex flex-col w-full max-w-lg max-h-full gap-4 rounded-xl border p-6 shadow-none overflow-y-auto pwa-dialog-content origin-center`,`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]`,r),t[13]=r,t[14]=y);let b;t[15]!==u||t[16]!==d?(b=u&&(0,C.jsxs)(i,{"data-slot":`dialog-close`,className:`ring-offset-background focus:ring-ring data-[open]:bg-interactive-active data-[open]:text-foreground absolute top-2 right-2 rounded-lg opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none text-muted-foreground hover:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,children:[(0,C.jsx)(m,{name:`close`}),(0,C.jsx)(`span`,{className:`sr-only`,children:d(`dialog.common.actions.close`)})]}),t[15]=u,t[16]=d,t[17]=b):b=t[17];let S;t[18]!==n||t[19]!==c||t[20]!==y||t[21]!==b?(S=(0,C.jsxs)(a,{"data-slot":`dialog-content`,"data-state-slot":`dialog`,className:y,...c,children:[n,b]}),t[18]=n,t[19]=c,t[20]=y,t[21]=b,t[22]=S):S=t[22];let w;t[23]!==v||t[24]!==S?(w=(0,C.jsx)(`div`,{className:v,children:S}),t[23]=v,t[24]=S,t[25]=w):w=t[25];let T;return t[26]!==g||t[27]!==w?(T=(0,C.jsxs)(O,{children:[g,w]}),t[26]=g,t[27]=w,t[28]=T):T=t[28],T}function j(e){let t=(0,x.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=p(`flex flex-col gap-2 text-center sm:text-left`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,C.jsx)(`div`,{"data-slot":`dialog-header`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function M(e){let t=(0,x.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=p(`flex flex-col-reverse gap-2 bottom-safe-area sm:flex-row sm:justify-end`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,C.jsx)(`div`,{"data-slot":`dialog-footer`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function N(e){let t=(0,x.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=p(`typography-markdown leading-none font-semibold text-foreground`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,C.jsx)(l,{"data-slot":`dialog-title`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function P(e){let t=(0,x.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=p(`text-muted-foreground typography-ui-label`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,C.jsx)(s,{"data-slot":`dialog-description`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function F(){w=Math.max(0,w-1),w===0&&document.documentElement.classList.remove(`oc-dialog-open`)}function I(){return w+=1,document.documentElement.classList.add(`oc-dialog-open`),F}export{j as a,b as c,M as i,g as l,A as n,N as o,P as r,D as s,E as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./rolldown-runtime-C0FnF6B9.js";import{nt as e,rt as t}from"./vendor-base-ui-CnHfUmDN.js";import{n}from"./vendor-react-DLPElpoQ.js";import{t as r}from"./utils-2ZK8yboQ.js";var i=n();t();var a=e();function o(e){let t=(0,i.c)(10),n,o,s;t[0]===e?(n=t[1],o=t[2],s=t[3]):({className:n,type:s,...o}=e,t[0]=e,t[1]=n,t[2]=o,t[3]=s);let c;t[4]===n?c=t[5]:(c=r(`text-foreground file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground bg-[var(--surface-elevated)] appearance-none flex h-9 w-full min-w-0 rounded-lg px-3 py-1 typography-markdown outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:typography-ui-label file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:typography-ui-label`,`ring-1 ring-inset ring-border/60 transition duration-200 ease-out`,`hover:[&:not(:focus)]:bg-[var(--surface-subtle)] hover:[&:not(:focus)]:ring-transparent`,`focus:ring-2 focus:ring-[var(--interactive-focus-ring)] focus-visible:outline-none`,`aria-invalid:ring-[var(--status-error)] aria-invalid:focus:ring-[var(--status-error)]`,n),t[4]=n,t[5]=c);let l;return t[6]!==o||t[7]!==c||t[8]!==s?(l=(0,a.jsx)(`input`,{type:s,"data-slot":`input`,className:c,spellCheck:!1,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`off`,...o}),t[6]=o,t[7]=c,t[8]=s,t[9]=l):l=t[9],l}export{o as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{c as t,i as n}from"./runtime-switch-LvWDU-SL.js";import{Cn as r,D as i,d as a,k as o,tn as s,u as c}from"./persistence-DwRBC4zl.js";import{a as l,i as u,r as d}from"./vendor-zustand-B4dlGEM2.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-DQ5_LNKO.js";import{b as v,t as ee,y}from"./useUIStore-CxOoCv7B.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-BnW6GxJt.js";import{n as te}from"./clipboard-GUUNlWIv.js";import{Qi as ne,c as C,ct as re,dr as ie,dt as ae,eo as oe,ft as se,g as w,go as T,ho as ce,in as E,lt as D,mn as O,ot as k,st as le,y as A}from"./useMobileNavigationStore-DDgESrzu.js";import{c as j,t as M}from"./utils-2ZK8yboQ.js";import{n as N}from"./Icon-D1BcR8Tz.js";import{g as P,v as F}from"./gitApi-pLkl_IyQ.js";import{f as I,o as L,q as ue}from"./projectMeta-BMkGWqtz.js";import{n as de,r as fe,t as pe}from"./fileMentionTouchSelection-DzdgAvGS.js";import{n as me}from"./textarea-B9CmN13Z.js";var R=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`goal`:return`target`;case`review`:return`search-eye`;case`test`:case`build`:case`run`:return`terminal-box`;default:return e.isBuiltIn?`flashlight`:`command`}},he=()=>`book-open`,z=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`}},B=()=>`ai-agent`,ge=()=>`chat-thread`,_e=(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:R(e)}}),ve=e=>e.map(e=>({id:`${e.name}-${e.scope}`,title:e.name,subtitle:e.description,badge:e.scope,iconName:he()})),ye=({agents:e,sessions:t,recentFiles:n,pathHits:r,untitledSession:i,sessionBadge:a})=>{let o=[];for(let t of e)o.push({id:`agent:${t.name}`,title:`@${t.name}`,subtitle:t.description,iconName:B()});for(let e of t)o.push({id:`session:${e.id}`,title:e.title||i,badge:a,iconName:ge()});for(let e of n)o.push({id:`recent:${e.path}`,title:e.relativePath||e.name,iconName:z(e)});for(let e of r)o.push({id:`file:${e.path}`,title:e.relativePath||e.name,iconName:z(e)});return o},be=(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=se([...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)},xe=(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}),Se=(e,t)=>e.highlightedIndex===t.highlightedIndex&&xe(e.rows,t.rows),Ce=(e,t)=>xe(e,t)?e:t.slice(),we=(e,t,n)=>{e&&(t.current&&Se(t.current,n)||(t.current=n,e(n)))},Te=(e,t)=>{t.current=null,e?.({rows:[],highlightedIndex:0})},V=e(p(),1),H=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},U=e=>/^[A-Za-z]:\//.test(e)?e.toLowerCase():e,W=(e,t)=>{let n=H(t),r=H(e);if(!n||!r)return!1;let i=U(n),a=U(r);return a===i||a.startsWith(`${i}/`)},G=e=>{if(!e||typeof e!=`object`)return{};let t=e,n={};for(let[e,r]of Object.entries(t)){let t=H(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=>H(e)).filter(e=>W(e,t)))):[],o=Array.isArray(i.expandedPaths)?Array.from(new Set(i.expandedPaths.filter(e=>typeof e==`string`).map(e=>H(e)).filter(e=>W(e,t)))):[],s=typeof i.selectedPath==`string`?H(i.selectedPath):null,c=s&&W(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},K=(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},q=e=>e?{...e,touchedAt:Date.now()}:{openPaths:[],selectedPath:null,expandedPaths:[],touchedAt:Date.now()},Ee=l()(d(u((e,t)=>({byRoot:{},addOpenPath:(t,n,r)=>{let i=H((t||``).trim()),a=H((n||``).trim());!i||!a||!r?.allowOutsideRoot&&!W(a,i)||e(e=>{let t=e.byRoot[i],n=q(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:K({...e.byRoot,[i]:{...n,openPaths:o,selectedPath:s}},20)}})},removeOpenPath:(t,n)=>{let r=H((t||``).trim()),i=H((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=U(i),a=e=>U(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:K({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeOpenPathsByPrefix:(t,n)=>{let r=H((t||``).trim()),i=H((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=U(i),a=n.endsWith(`/`)?n:`${n}/`,o=e=>{let t=U(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:K({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeExpandedPathsByPrefix:(t,n)=>{let r=H((t||``).trim()),i=H((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=U(i),a=n.endsWith(`/`)?n:`${n}/`,o=t.expandedPaths.filter(e=>{let t=U(e);return t!==n&&!t.startsWith(a)});return o.length===t.expandedPaths.length?e:{byRoot:K({...e.byRoot,[r]:{...t,expandedPaths:o,touchedAt:Date.now()}},20)}})},setSelectedPath:(t,n,r)=>{let i=H((t||``).trim()),a=n?H(n.trim()):null;!i||a&&!r?.allowOutsideRoot&&!W(a,i)||e(e=>{let t=e.byRoot[i],n=q(t),r=a&&!n.openPaths.includes(a)?[...n.openPaths,a]:n.openPaths;return t&&t.selectedPath===a&&r===t.openPaths?e:{byRoot:K({...e.byRoot,[i]:{...n,openPaths:r,selectedPath:a}},20)}})},ensureSelectedPath:e=>{let n=H((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=H((t||``).trim()),i=H((n||``).trim());!r||!i||!W(i,r)||e(e=>{let t=e.byRoot[r],n=q(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:K({...e.byRoot,[r]:{...n,expandedPaths:a}},20)}})},expandPath:(t,n)=>{let r=H((t||``).trim()),i=H((n||``).trim());!r||!i||!W(i,r)||e(e=>{let t=e.byRoot[r],n=q(t);return n.expandedPaths.includes(i)&&t?e:{byRoot:K({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,i]}},20)}})},expandPaths:(t,n)=>{let r=H((t||``).trim());if(!r||!n||n.length===0)return;let i=n.map(e=>H((e||``).trim())).filter(e=>e&&W(e,r));i.length!==0&&e(e=>{let t=e.byRoot[r],n=q(t),a=new Set(n.expandedPaths),o=i.filter(e=>!a.has(e));return o.length===0?e:{byRoot:K({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,...o]}},20)}})}}),{name:`files-view-tabs-store`,version:2,storage:y(),migrate:e=>{if(!e||typeof e!=`object`)return{byRoot:{}};let t=e.byRoot;return{byRoot:G(t)}},partialize:e=>({byRoot:G(e.byRoot)})}),{name:`files-view-tabs-store`})),J=b(),De=(e,t)=>{let n=(0,J.c)(4),r=t===void 0?200:t,[i,a]=V.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]),V.useEffect(o,s),i},Oe=()=>{let e=(0,J.c)(17),t=C(Y),n=O(),r;e[0]===t?r=e[1]:(r=e=>t?e.getAttachment(t):void 0,e[0]=t,e[1]=r);let i=A(r),a=C(X),o=C(ke),s=T(Ae),c=T(je),l=h(Me);if(t){let r;e[2]===i?r=e[3]:(r=w(i),e[2]=i,e[3]=r);let o=r;if(o)return o;let s;e[4]!==t||e[5]!==a?(s=a.get(t),e[4]=t,e[5]=a,e[6]=s):s=e[6];let c=s;if(c?.path)return c.path;let l;if(e[7]!==t||e[8]!==n){let r;e[10]===t?r=e[11]:(r=e=>e.id===t,e[10]=t,e[11]=r),l=n.find(r),e[7]=t,e[8]=n,e[9]=l}else l=e[9];let u=l;if(u?.directory)return u.directory}if(o?.open&&(o.bootstrapPendingDirectory||o.directoryOverride))return(o.bootstrapPendingDirectory||o.directoryOverride)??void 0;if(s){let t;if(e[12]!==s||e[13]!==c){let n;e[15]===s?n=e[16]:(n=e=>e.id===s,e[15]=s,e[16]=n),t=c.find(n),e[12]=s,e[13]=c,e[14]=t}else t=e[14];let n=t;if(n?.path)return n.path}return l??void 0};function Y(e){return e.currentSessionId}function X(e){return e.worktreeMetadata}function ke(e){return e.newSessionDraft}function Ae(e){return e.activeProjectId}function je(e){return e.projects}function Me(e){return e.currentDirectory}var Z=f(),Ne=V.forwardRef(({searchQuery:e,onFileSelect:t,onAgentSelect:n,onSessionSelect:r,onClose:a,style:s,onRowsChange:c},l)=>{let{t:u}=te(),d=Oe()??``,f=C(e=>e.currentSessionId),p=ie(e=>e.activeSessions),m=T(e=>e.activeProjectId),h=T(e=>e.projects),g=V.useMemo(()=>h.find(e=>e.id===m)?.path??null,[m,h]),v=V.useMemo(()=>{let e=g||d;return e?e.replace(/\\/g,`/`).replace(/\/+$/,``):null},[g,d]),y=Ee(e=>v?e.byRoot[v]:void 0),b=ne(e=>e.getVisibleAgents),x=_(e=>e.searchFiles),oe=De(e,180),se=o(),w=i(),[ce,E]=V.useState([]),[O,A]=V.useState([]),[P,F]=V.useState(!1),[I,L]=V.useState(0),ue=V.useRef(0),[R,he]=V.useState(360),[B,ge]=V.useState({}),[_e,ve]=V.useState({}),be=V.useRef([]),xe=V.useRef([]),Se=V.useRef([]),Ce=V.useRef(null),H=V.useRef(null),U=V.useRef(null);U.current||=pe();let W=ee(e=>e.isMobile),G=(e??``).trim(),K=V.useMemo(()=>{if(!v||!y)return[];let e=[y.selectedPath,...y.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(`${v}/`)?e.slice(v.length+1):e;n.push({name:i,path:e,relativePath:a,extension:i.includes(`.`)?i.split(`.`).pop()?.toLowerCase():void 0})}return D(n,G,{limit:6})},[G,v,y]),q=V.useMemo(()=>G.length>0?O:O.slice(0,2),[O,G.length]),J=V.useMemo(()=>r?k({sessions:p,currentSessionId:f,searchQuery:G}):[],[p,f,G,r]),Y=K,X=ce;V.useEffect(()=>{let e=e=>{let t=e.target;!t||!Ce.current||Ce.current.contains(t)||a()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[a]),V.useEffect(()=>{if(!d){E([]);return}let e=(oe??``).trim(),t=ae(e);if(!t){E([]);return}let n=!1;F(!0);let r={includeHidden:se,respectGitignore:!w};return Promise.all([x(d,t,80,{...r,type:`file`}),x(d,t,40,{...r,type:`directory`})]).then(([t,r])=>{if(n)return;let i=new Set(K.map(e=>e.path));E(le({files:t,directories:r,query:e,excludePaths:i,limit:20}))}).catch(()=>{n||E([])}).finally(()=>{n||F(!1)}),()=>{n=!0}},[d,oe,K,x,se,w]),V.useEffect(()=>{let t=b().filter(e=>e.mode&&e.mode!==`primary`).map(e=>({name:e.name,description:e.description,mode:e.mode}));A(re(t,e??``))},[b,e]),V.useEffect(()=>{L(0),ge({}),ve({})},[X,Y.length,q.length,J.length]),V.useEffect(()=>{ue.current=I},[I]),V.useEffect(()=>{be.current[I]?.scrollIntoView({block:`nearest`})},[I]),V.useEffect(()=>{let e=null,t=()=>{e!==null&&cancelAnimationFrame(e),e=requestAnimationFrame(()=>{let e={},t={};xe.current.forEach((n,r)=>{if(!n)return;let i=Se.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}}),ge(e),ve(t)})};return t(),window.addEventListener(`resize`,t),()=>{e!==null&&cancelAnimationFrame(e),window.removeEventListener(`resize`,t)}},[X,Y]),V.useEffect(()=>{let e=xe.current[I];if(!e)return;let t=()=>{let t=e.clientWidth;t>0&&he(t)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>{n.disconnect()}},[I]);let ke=S(e=>{t(e)}),Ae=S(e=>{n?.(e)}),je=S(e=>{r?.(e)}),Me=(e,t)=>({onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&U.current?.pointerDown(e.clientX,e.clientY)},onPointerMove:e=>{e.pointerType===`touch`&&U.current?.pointerMove(e.clientX,e.clientY)},onPointerUp:e=>{e.pointerType===`touch`&&(U.current?.pointerUp(t)??!1)&&(e.preventDefault(),e.stopPropagation())},onPointerCancel:()=>U.current?.pointerCancel(),onClick:()=>{U.current?.click(t)},onMouseMove:()=>L(e)}),Ne=e=>{let t=q.length+J.length+Y.length+X.length;if(t===0)return;let n=(e%t+t)%t;if(n<q.length){let e=q[n];e&&Ae(e.name);return}let r=n-q.length;if(r<J.length){let e=J[r];e&&je(e);return}let i=r-J.length,a=i<Y.length?Y[i]:X[i-Y.length];a&&ke(a)};V.useEffect(()=>{we(c,H,{rows:ye({agents:q,sessions:J,recentFiles:Y,pathHits:X,untitledSession:u(`chat.fileMentionAutocomplete.untitledSession`),sessionBadge:u(`chat.fileMentionAutocomplete.sessionType`)}),highlightedIndex:I})},[c,I,u,q,X,Y,J]);let Pe=V.useRef(c);Pe.current=c,V.useEffect(()=>()=>{Te(Pe.current,H)},[]),V.useImperativeHandle(l,()=>({acceptIndex:e=>{Ne(e)},handleKeyDown:e=>{if(e===`Escape`){a();return}let t=q.length+J.length+Y.length+X.length;if(t!==0){if(e===`ArrowDown`){L(e=>(e+1)%t);return}if(e===`ArrowUp`){L(e=>(e-1+t)%t);return}(e===`Enter`||e===`Tab`)&&Ne(ue.current)}}}),[X,Y,q,J,a,ke,Ae,je]);let Fe=e=>(0,Z.jsx)(N,{name:z(e),className:`h-3.5 w-3.5 text-current`});return(0,Z.jsxs)(de,{ref:Ce,isMobile:W,className:`max-w-[640px] max-h-64`,style:s,children:[(0,Z.jsx)(me,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0`,children:(0,Z.jsxs)(`div`,{className:`pb-2`,children:[q.length>0&&(0,Z.jsx)(`div`,{className:`px-3 pb-1 pt-2 typography-meta font-medium text-muted-foreground`,children:u(`chat.fileMentionAutocomplete.groups.agents`)}),q.map((e,t)=>{let n=I===t;return(0,Z.jsx)(`div`,{ref:e=>{be.current[t]=e},className:M(`flex items-start gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,W&&`min-h-11`,fe(W,n),!W&&n&&`text-interactive-selection-foreground`),...Me(t,()=>Ae(e.name)),children:(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`font-semibold truncate`,children:[`@`,e.name]}),e.description&&!W?(0,Z.jsx)(`div`,{className:`typography-meta text-muted-foreground truncate`,children:e.description}):null]})},`agent-${e.name}`)}),q.length===2&&G.length===0&&O.length>2&&(0,Z.jsx)(`div`,{className:`px-3 py-1 typography-meta text-muted-foreground`,children:u(`chat.fileMentionAutocomplete.searchMoreAgents`)}),J.length>0&&(0,Z.jsx)(`div`,{className:`px-3 pb-1 pt-2 typography-meta font-medium text-muted-foreground`,children:u(`chat.fileMentionAutocomplete.groups.sessions`)}),J.map((e,t)=>{let n=q.length+t,r=I===n;return(0,Z.jsxs)(`div`,{ref:e=>{be.current[n]=e},className:M(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,W&&`min-h-11`,fe(W,r),!W&&r&&`text-interactive-selection-foreground`),...Me(n,()=>je(e)),children:[(0,Z.jsx)(N,{name:`chat-thread`,className:`h-4 w-4 flex-shrink-0 text-[var(--primary-base)]`}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.title||u(`chat.fileMentionAutocomplete.untitledSession`),children:e.title||u(`chat.fileMentionAutocomplete.untitledSession`)}),W?null:(0,Z.jsx)(`span`,{className:`flex-shrink-0 typography-meta text-muted-foreground`,children:u(`chat.fileMentionAutocomplete.sessionType`)})]},`session-${e.id}`)}),Y.length>0&&(0,Z.jsx)(`div`,{className:`px-3 pb-1 pt-2 typography-meta font-medium text-muted-foreground`,children:u(`chat.fileMentionAutocomplete.groups.recentFiles`)}),Y.map((e,t)=>{let n=q.length+J.length+t,r=e.relativePath||e.name,i=j(r,{maxLength:60}),a=I===n,o=B[n]??!1,s=_e[n]??2.6;return(0,Z.jsxs)(`div`,{ref:e=>{be.current[n]=e},className:M(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,W&&`min-h-11`,fe(W,a),!W&&a&&`text-interactive-selection-foreground`),...Me(n,()=>ke(e)),children:[Fe(e),(0,Z.jsxs)(`span`,{ref:e=>{xe.current[n]=e},className:`relative flex-1 min-w-0 overflow-hidden file-mention-marquee-container`,style:a?{"--file-mention-marquee-width":`${R}px`,"--file-mention-marquee-duration":`${s}s`}:void 0,"aria-label":r,children:[(0,Z.jsx)(`span`,{ref:e=>{Se.current[n]=e},className:`absolute invisible whitespace-nowrap pointer-events-none`,"aria-hidden":!0,children:r}),o&&a?(0,Z.jsx)(`span`,{className:`inline-block whitespace-nowrap file-mention-marquee`,children:r}):(0,Z.jsx)(`span`,{className:`block truncate`,children:i})]})]},`recent-${e.path}`)}),X.length>0&&(0,Z.jsx)(`div`,{className:`px-3 pb-1 pt-2 typography-meta font-medium text-muted-foreground`,children:u(`chat.fileMentionAutocomplete.groups.files`)}),X.map((e,t)=>{let n=q.length+J.length+Y.length+t,r=e.relativePath||e.name,i=j(r,{maxLength:60}),a=I===n,o=B[n]??!1,s=_e[n]??2.6;return(0,Z.jsxs)(`div`,{ref:e=>{be.current[n]=e},className:M(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,W&&`min-h-11`,fe(W,a),!W&&a&&`text-interactive-selection-foreground`),...Me(n,()=>ke(e)),children:[Fe(e),(0,Z.jsxs)(`span`,{ref:e=>{xe.current[n]=e},className:`relative flex-1 min-w-0 overflow-hidden file-mention-marquee-container`,style:a?{"--file-mention-marquee-width":`${R}px`,"--file-mention-marquee-duration":`${s}s`}:void 0,"aria-label":r,children:[(0,Z.jsx)(`span`,{ref:e=>{Se.current[n]=e},className:`absolute invisible whitespace-nowrap pointer-events-none`,"aria-hidden":!0,children:r}),o&&a?(0,Z.jsx)(`span`,{className:`inline-block whitespace-nowrap file-mention-marquee`,children:r}):(0,Z.jsx)(`span`,{className:`block truncate`,children:i})]})]},e.path)}),P&&X.length===0?(0,Z.jsx)(`div`,{className:`flex items-center justify-center py-3`,children:(0,Z.jsx)(N,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):null,!P&&X.length===0&&Y.length===0&&q.length===0&&J.length===0&&(0,Z.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:u(`chat.fileMentionAutocomplete.empty`)})]})}),!W&&(0,Z.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:u(`chat.autocomplete.keyboardHint`)})]})}),Pe=new Set([`new`,`fork`,`compact`,`undo`,`redo`,`model`,`goal`]),Fe=(e,t)=>{if(!t||e.isSkill)return!1;let n=e.name?.trim().toLowerCase();return!!(n&&Pe.has(n))},Ie=(e,t)=>!e||t({name:e}),Le=` `,Re=(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]===Le&&e[r-2]===`/`&&(r-=2),e[r]===`/`?{start:r,end:n}:null},ze=`text-[10px] leading-none uppercase font-bold tracking-tight px-1.5 py-1 rounded border flex-shrink-0`,Be=M(ze,`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)]`),Ve=M(ze,`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)]`),He=M(ze,`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)]`),Ue=M(ze,`bg-[var(--surface-muted)] text-muted-foreground border-[var(--interactive-border)]/60`),We=(e,t)=>e.length===t.length&&e.every((e,n)=>e.id===t[n]?.id),Ge=(e,t)=>{let n=!!e.sessionID;return{hasSession:n,canStartSessionCommand:n||e.hasNewDraft,canUseReviewHandoffFlow:n&&!t&&!s()}},Ke=V.forwardRef(({searchQuery:e,onCommandSelect:t,onClose:n,directory:r,style:i,commandPolicy:a,commandContext:o,onRowsChange:s},c)=>{let{t:l}=te(),u=ee(e=>e.isMobile),d=C(e=>e.currentSessionId),f=C(e=>!!e.newSessionDraft?.open),p=C(V.useCallback(e=>d?e.getDirectoryForSession(d):void 0,[d])),m=E(d??``,p??void 0),h=V.useMemo(()=>o??{sessionID:d??null,hasMessages:m.length>0,hasNewDraft:f},[o,d,m.length,f]),{hasSession:g,canStartSessionCommand:_,canUseReviewHandoffFlow:v}=V.useMemo(()=>Ge(h,u),[h,u]),y=h.hasMessages,[b,x]=V.useState([]),[S,ne]=V.useState(!1),re=ce({directory:r}),ie=V.useMemo(()=>re.data??[],[re.data]),ae=re.isFetching,se=oe({directory:r}),w=V.useMemo(()=>se.data??[],[se.data]),[T,D]=V.useState(0),O=V.useRef(0),k=V.useRef(!1),le=V.useRef([]),A=V.useRef(null),j=V.useRef(!1),P=V.useRef(null),F=V.useRef(!1),I=V.useRef(null);V.useEffect(()=>{let e=e=>{let t=e.target;!t||!A.current||A.current.contains(t)||n()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[n]),V.useEffect(()=>{(async()=>{ne(ae);try{let t=ie.map((e,t)=>({id:`opencode:${e.scope??`global`}:${e.name}:${e.agent??``}:${e.model??``}:${t}`,name:e.name,source:`opencode`,description:e.description,agent:e.agent??void 0,model:e.model??void 0,isBuiltIn:e.isBuiltIn,isSkill:e.source===`skill`,scope:e.scope,reference:e.reference})),n=w.map((e,t)=>({id:`skill:${e.scope}:${e.source??`opencode`}:${e.name}:${t}`,name:e.name,source:`skill`,description:e.description,isSkill:!0,scope:e.scope})),r=[{id:`openchamber:new`,name:`new`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.newDescription`),isBuiltIn:!0},...g&&!y?[{id:`openchamber:init`,name:`init`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.initDescription`),isBuiltIn:!0}]:[],...g?[{id:`openchamber:undo`,name:`undo`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.undoDescription`),isBuiltIn:!0},{id:`openchamber:redo`,name:`redo`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.redoDescription`),isBuiltIn:!0},{id:`openchamber:fork`,name:`fork`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.forkDescription`),isBuiltIn:!0},{id:`openchamber:timeline`,name:`timeline`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.timelineDescription`),isBuiltIn:!0}]:[],{id:`openchamber:model`,name:`model`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.modelDescription`),isBuiltIn:!0},{id:`openchamber:compact`,name:`compact`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.compactDescription`),isBuiltIn:!0},...g?[{id:`openchamber:summary`,name:`summary`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.summaryDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:workspace-review`,name:`workspace-review`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.workspaceReviewDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:handoff-review`,name:`handoff-review`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.handoffReviewDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:craft-goal`,name:`craft-goal`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.craftGoalDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:goal`,name:`goal`,source:`openchamber`,description:l(`chat.goal.button.armAria`),isBuiltIn:!0}]:[],..._?[{id:`openchamber:catch-up`,name:`catch-up`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.catchUpDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:debug`,name:`debug`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.debugDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:weigh`,name:`weigh`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.weighDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:explore`,name:`explore`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.exploreDescription`),isOpenChamber:!0}]:[],...t,...n],i=!y,o=be(r.filter(e=>(i||e.name!==`init`)&&(a?.(e)??!0)),e);x(e=>We(e,o)?e:o)}catch{let t=!y,n=be([{id:`openchamber:new`,name:`new`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.newDescription`),isBuiltIn:!0},...g&&!y?[{id:`openchamber:init`,name:`init`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.initDescription`),isBuiltIn:!0}]:[],...g?[{id:`openchamber:undo`,name:`undo`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.undoDescription`),isBuiltIn:!0},{id:`openchamber:redo`,name:`redo`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.redoDescription`),isBuiltIn:!0},{id:`openchamber:fork`,name:`fork`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.forkDescription`),isBuiltIn:!0},{id:`openchamber:timeline`,name:`timeline`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.timelineDescription`),isBuiltIn:!0}]:[],{id:`openchamber:model`,name:`model`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.modelDescription`),isBuiltIn:!0},{id:`openchamber:compact`,name:`compact`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.compactDescription`),isBuiltIn:!0},...g?[{id:`openchamber:summary`,name:`summary`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.summaryDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:workspace-review`,name:`workspace-review`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.workspaceReviewDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:handoff-review`,name:`handoff-review`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.handoffReviewDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:craft-goal`,name:`craft-goal`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.craftGoalDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:goal`,name:`goal`,source:`openchamber`,description:l(`chat.goal.button.armAria`),isBuiltIn:!0}]:[],..._?[{id:`openchamber:catch-up`,name:`catch-up`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.catchUpDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:debug`,name:`debug`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.debugDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:weigh`,name:`weigh`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.weighDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:explore`,name:`explore`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.exploreDescription`),isOpenChamber:!0}]:[]].filter(e=>(t||e.name!==`init`)&&(a?.(e)??!0)),e);x(e=>We(e,n)?e:n)}finally{ne(!1)}})()},[e,y,g,_,v,ie,ae,w,l,a]),V.useEffect(()=>{D(0)},[b]),V.useEffect(()=>{O.current=T},[T]),V.useEffect(()=>{le.current[T]?.scrollIntoView({block:`nearest`})},[T]),V.useEffect(()=>{we(s,I,{rows:_e(b,{skill:l(`chat.commandAutocomplete.badge.skill`),command:l(`chat.commandAutocomplete.badge.command`),system:l(`chat.commandAutocomplete.badge.system`)}),highlightedIndex:T})},[b,s,T,l]);let L=V.useRef(s);L.current=s,V.useEffect(()=>()=>{Te(L.current,I)},[]),V.useImperativeHandle(c,()=>({acceptIndex:(e,n=!0)=>{let r=b[e];r&&t(r,Fe(r,n))},handleKeyDown:e=>{let r=b.length;if(e===`Escape`){n();return}if(r!==0){if(e===`ArrowDown`){k.current=!0,D(e=>(e+1)%r);return}if(e===`ArrowUp`){k.current=!0,D(e=>(e-1+r)%r);return}if(e===`Enter`||e===`Tab`){let n=(O.current%r+r)%r,i=b[n];i&&t(i,Fe(i,e===`Enter`))}}}}),[b,n,t]);let ue=e=>{let t=R(e);switch(e.name){case`new`:return(0,Z.jsx)(N,{name:t,className:`h-3.5 w-3.5`});case`init`:return(0,Z.jsx)(N,{name:t,className:`h-3.5 w-3.5 text-green-500`});case`undo`:return(0,Z.jsx)(N,{name:t,className:`h-3.5 w-3.5 text-orange-500`});case`redo`:return(0,Z.jsx)(N,{name:t,className:`h-3.5 w-3.5 text-orange-500`});case`timeline`:return(0,Z.jsx)(N,{name:t,className:`h-3.5 w-3.5`});case`compact`:return(0,Z.jsx)(N,{name:t,className:`h-3.5 w-3.5 text-purple-500`});case`goal`:return(0,Z.jsx)(N,{name:t,className:`h-3.5 w-3.5`});case`review`:return(0,Z.jsx)(N,{name:t,className:`h-3.5 w-3.5 text-blue-500`});case`test`:case`build`:case`run`:return(0,Z.jsx)(N,{name:t,className:`h-3.5 w-3.5 text-cyan-500`});default:return e.isBuiltIn?(0,Z.jsx)(N,{name:t,className:`h-3.5 w-3.5 text-yellow-500`}):(0,Z.jsx)(N,{name:t,className:`h-3.5 w-3.5 text-muted-foreground`})}};return(0,Z.jsxs)(de,{ref:A,isMobile:u,className:`max-w-[450px] max-h-64`,style:i,children:[(0,Z.jsx)(me,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0 pb-2`,children:S?(0,Z.jsx)(`div`,{className:`flex items-center justify-center py-4`,children:(0,Z.jsx)(N,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):(0,Z.jsxs)(`div`,{children:[b.map((e,n)=>{let r=e.isBuiltIn,i=e.isOpenChamber;return(0,Z.jsxs)(`div`,{ref:e=>{le.current[n]=e},className:M(`flex gap-2 px-3 py-2 cursor-pointer rounded-lg`,u?`items-center`:`items-start`,fe(u,n===T)),onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&(P.current={x:e.clientX,y:e.clientY},F.current=!1)},onPointerMove:e=>{if(e.pointerType!==`touch`||!P.current)return;let t=e.clientX-P.current.x,n=e.clientY-P.current.y;Math.hypot(t,n)>6&&(F.current=!0)},onPointerUp:n=>{if(n.pointerType!==`touch`)return;let r=F.current;P.current=null,F.current=!1,!r&&(n.preventDefault(),n.stopPropagation(),j.current=!0,t(e,Fe(e,u)))},onPointerCancel:()=>{P.current=null,F.current=!1},onClick:()=>{if(j.current){j.current=!1;return}t(e,Fe(e,u))},onMouseMove:()=>{k.current=!1,D(n)},children:[(0,Z.jsx)(`div`,{className:M(!u&&`mt-0.5`),children:ue(e)}),(0,Z.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsxs)(`span`,{className:`typography-ui-label font-medium`,children:[`/`,e.name]}),e.isSkill?(0,Z.jsx)(`span`,{className:Be,children:l(`chat.commandAutocomplete.badge.skill`)}):(0,Z.jsx)(`span`,{className:Be,children:l(`chat.commandAutocomplete.badge.command`)}),i?(0,Z.jsx)(`span`,{className:Ue,children:`OpenChamber`}):r?(0,Z.jsx)(`span`,{className:Ue,children:l(`chat.commandAutocomplete.badge.system`)}):e.scope?(0,Z.jsx)(`span`,{className:e.scope===`project`?He:Ve,children:e.scope}):null,e.agent&&(0,Z.jsx)(`span`,{className:Ue,children:e.agent})]}),e.description&&!u&&(0,Z.jsx)(`div`,{className:`typography-meta text-muted-foreground mt-0.5 truncate`,children:e.description})]})]},e.id)}),b.length===0&&(0,Z.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:l(`chat.commandAutocomplete.empty`)})]})}),!u&&(0,Z.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:l(`chat.autocomplete.keyboardHint`)})]})});Ke.displayName=`CommandAutocomplete`;function qe(e){return(e.description||e.content).replace(/\s+/g,` `).trim().slice(0,120)}var Je=V.forwardRef((e,t)=>{let n=(0,J.c)(62),{searchQuery:r,onSnippetSelect:i,onClose:a,style:o}=e,{t:s}=te(),c=V.useRef(null),l=ee(Ye),[u,d]=V.useState(0),f=V.useRef(0),p;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=[],n[0]=p):p=n[0];let[m,h]=V.useState(p),g;n[1]===Symbol.for(`react.memo_cache_sentinel`)?(g=[],n[1]=g):g=n[1];let _=V.useRef(g),v=ue(Xe),y=ue(Ze),b=ue(Qe),x=ue($e),S=ee(et),ne=ee(tt),C,re;n[2]===y?(C=n[3],re=n[4]):(C=()=>{y()},re=[y],n[2]=y,n[3]=C,n[4]=re),V.useEffect(C,re);let ie,ae;n[5]!==r||n[6]!==v?(ie=()=>{let e=r.trim();if(!e.length){let e=[...v].sort(nt);h(e),d(+!!e.length);return}let t=se(v,e,rt);t.sort(it);let n=t.map(at);h(n),d(+!!n.length)},ae=[r,v],n[5]=r,n[6]=v,n[7]=ie,n[8]=ae):(ie=n[7],ae=n[8]),V.useEffect(ie,ae);let oe,w;n[9]===u?(oe=n[10],w=n[11]):(oe=()=>{f.current=u,_.current[u]?.scrollIntoView({block:`nearest`})},w=[u],n[9]=u,n[10]=oe,n[11]=w),V.useEffect(oe,w);let T,ce;n[12]===a?(T=n[13],ce=n[14]):(ce=()=>{let e=e=>{let t=e.target;t&&c.current&&!c.current.contains(t)&&a()};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},T=[a],n[12]=a,n[13]=T,n[14]=ce),V.useEffect(ce,T);let E;n[15]!==i||n[16]!==r?(E=e=>{let t=r.trim(),n=e.aliases.includes(t)?t:e.name;i(e,n)},n[15]=i,n[16]=r,n[17]=E):E=n[17];let D=E,O;n[18]!==a||n[19]!==x||n[20]!==S||n[21]!==ne||n[22]!==b||n[23]!==v?(O=()=>{let e=new Set(v.map(ot)),t=`new-snippet`,n=1;for(;e.has(t);)t=`new-snippet-${n++}`;b({name:t,scope:`global`}),x(t),ne(`snippets`),S(!0),a()},n[18]=a,n[19]=x,n[20]=S,n[21]=ne,n[22]=b,n[23]=v,n[24]=O):O=n[24];let k=O,le,A;n[25]!==D||n[26]!==m||n[27]!==a||n[28]!==k?(le=()=>({handleKeyDown:e=>{if(e===`Escape`){a();return}let t=m.length+1;if(e===`ArrowDown`){d(e=>(e+1)%t);return}if(e===`ArrowUp`){d(e=>(e-1+t)%t);return}if(e===`Enter`||e===`Tab`){if(f.current===0){k();return}let e=m[f.current-1];e&&D(e)}}}),A=[D,m,a,k],n[25]=D,n[26]=m,n[27]=a,n[28]=k,n[29]=le,n[30]=A):(le=n[29],A=n[30]),V.useImperativeHandle(t,le,A);let j;n[31]===Symbol.for(`react.memo_cache_sentinel`)?(j=e=>{_.current[0]=e},n[31]=j):j=n[31];let P;n[32]!==l||n[33]!==u?(P=M(`flex items-center gap-2 px-3 py-1.5 cursor-pointer rounded-lg typography-ui-label`,fe(l,u===0)),n[32]=l,n[33]=u,n[34]=P):P=n[34];let F,I;n[35]===Symbol.for(`react.memo_cache_sentinel`)?(F=()=>d(0),I=(0,Z.jsx)(N,{name:`add`,className:`h-3.5 w-3.5 text-muted-foreground`}),n[35]=F,n[36]=I):(F=n[35],I=n[36]);let L;n[37]===s?L=n[38]:(L=s(`chat.snippetAutocomplete.action.addNew`),n[37]=s,n[38]=L);let pe;n[39]===L?pe=n[40]:(pe=(0,Z.jsx)(`span`,{className:`font-medium text-foreground`,children:L}),n[39]=L,n[40]=pe);let R;n[41]!==k||n[42]!==P||n[43]!==pe?(R=(0,Z.jsxs)(`div`,{ref:j,className:P,onClick:k,onMouseMove:F,children:[I,pe]}),n[41]=k,n[42]=P,n[43]=pe,n[44]=R):R=n[44];let he;n[45]!==D||n[46]!==m||n[47]!==l||n[48]!==u||n[49]!==s?(he=m.length?m.map((e,t)=>(0,Z.jsx)(`div`,{ref:e=>{_.current[t+1]=e},className:M(`flex gap-2 px-3 py-1.5 cursor-pointer rounded-lg typography-ui-label`,l?`items-center`:`items-start`,fe(l,t+1===u)),onClick:()=>D(e),onMouseMove:()=>d(t+1),children:(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsxs)(`span`,{className:`font-semibold truncate`,children:[`#`,e.name]}),(0,Z.jsx)(`span`,{className:`text-[10px] leading-none uppercase font-bold tracking-tight px-1.5 py-1 rounded border flex-shrink-0 bg-[var(--surface-muted)] text-muted-foreground border-[var(--interactive-border)]/60`,children:s(`snippets.source.${e.source}`)})]}),!l&&(0,Z.jsx)(`div`,{className:`typography-meta text-muted-foreground mt-0.5 truncate`,children:qe(e)})]})},`${e.source}:${e.filePath}`)):(0,Z.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:s(`chat.snippetAutocomplete.empty`)}),n[45]=D,n[46]=m,n[47]=l,n[48]=u,n[49]=s,n[50]=he):he=n[50];let z;n[51]!==R||n[52]!==he?(z=(0,Z.jsxs)(me,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0 pb-2`,children:[R,he]}),n[51]=R,n[52]=he,n[53]=z):z=n[53];let B;n[54]!==l||n[55]!==s?(B=!l&&(0,Z.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:s(`chat.snippetAutocomplete.footer`)}),n[54]=l,n[55]=s,n[56]=B):B=n[56];let ge;return n[57]!==l||n[58]!==o||n[59]!==z||n[60]!==B?(ge=(0,Z.jsxs)(de,{ref:c,isMobile:l,className:`max-w-[450px] max-h-60`,style:o,children:[z,B]}),n[57]=l,n[58]=o,n[59]=z,n[60]=B,n[61]=ge):ge=n[61],ge});Je.displayName=`SnippetAutocomplete`;function Ye(e){return e.isMobile}function Xe(e){return e.snippets}function Ze(e){return e.loadSnippets}function Qe(e){return e.setSnippetDraft}function $e(e){return e.setSelectedSnippet}function et(e){return e.setSettingsDialogOpen}function tt(e){return e.setSettingsPage}function nt(e,t){return e.source===`project`&&t.source!==`project`?-1:e.source!==`project`&&t.source===`project`?1:e.name.localeCompare(t.name)}function rt(e){return[e.name,...e.aliases]}function it(e,t){return e.score===t.score?e.item.source===`project`&&t.item.source!==`project`?-1:e.item.source!==`project`&&t.item.source===`project`?1:e.item.name.localeCompare(t.item.name):e.score-t.score}function at(e){return e.item}function ot(e){return e.name}var st=2,ct=e=>!!e&&typeof e==`object`&&!Array.isArray(e),lt=e=>{let t=e?.trim().replace(/\\/g,`/`);return t?t.length>1?t.replace(/\/+$/,``):t:null},ut=e=>ct(e)&&Array.isArray(e.all)&&e.all.every(e=>typeof e==`string`)&&typeof e.current==`string`&&ct(e.branches),dt=(e,t)=>JSON.stringify([e,t]),ft=e=>`version`in e&&e.version===st&&ct(e.entries),pt=e=>{if(!e)return null;try{let t=JSON.parse(e);return ct(t)?t.version===st&&ct(t.entries)?{version:st,entries:t.entries}:t:null}catch{return null}},mt=(e,t)=>{try{e.setItem(`oc.gitBranchCache`,JSON.stringify(t))}catch{}},ht=(e,t,n)=>{let r=lt(e);if(!r||!t)return null;let i;try{i=n.getItem(`oc.gitBranchCache`)}catch{return null}let a=pt(i);if(!a)return null;if(ft(a))return ut(a.entries[dt(t,r)])?a.entries[dt(t,r)]:null;let o={};for(let[e,n]of Object.entries(a)){let r=lt(e);r&&ut(n)&&(o[dt(t,r)]=n)}return mt(n,{version:st,entries:o}),o[dt(t,r)]??null},gt=(e,t,n,r)=>{let i=lt(e);if(!i||!t||!ut(n))return;let a=null;try{a=r.getItem(`oc.gitBranchCache`)}catch{return}let o=pt(a);mt(r,{version:st,entries:{...o&&ft(o)?o.entries:{},[dt(t,i)]:n}})},_t=3e4,vt=lt,yt=(e,t=n())=>a.git.branches(vt(e),t),bt=(e,t=n())=>a.git.remotes(vt(e),t),xt=async(e,t,n)=>{n.throwIfAborted();let i=r()?.git,a=t?.getGitBranches?await t.getGitBranches(e,{signal:n}):i?await i.getGitBranches(e,{signal:n}):await g(e,{signal:n});return n.throwIfAborted(),a},St=async(e,t,n)=>{n.throwIfAborted();let i=r()?.git,a=t?.getRemotes?await t.getRemotes(e,{signal:n}):i?await i.getRemotes(e,{signal:n}):await m(e,{signal:n});return n.throwIfAborted(),a},Ct=(e,t,r=n(),i=v())=>{let a=vt(e),o=t;return{queryKey:yt(a,r),queryFn:async({signal:e})=>{if(!a)throw Error(`Git branches require a directory`);let t=await xt(a,o,e);return gt(a,r,t,i),t},staleTime:_t,gcTime:1/0,initialData:()=>ht(a,r,i)??void 0,initialDataUpdatedAt:0}},wt=(e,t,r=n())=>{let i=vt(e),a=t;return{queryKey:bt(i,r),queryFn:({signal:e})=>{if(!i)throw Error(`Git remotes require a directory`);return St(i,a,e)},staleTime:_t,gcTime:1/0}},Tt=(e,r,i)=>{let a=(0,J.c)(9),o=i===void 0||i,s=V.useSyncExternalStore(t,n,n),c,l,u;a[0]!==e||a[1]!==r||a[2]!==s?(c=vt(e),u=x,l=Ct(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)},Et=(e,r,i)=>{let a=(0,J.c)(9),o=i===void 0||i,s=V.useSyncExternalStore(t,n,n),c,l,u;a[0]!==e||a[1]!==r||a[2]!==s?(c=vt(e),u=x,l=wt(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)},Dt=(e,t,r=c,i=n())=>r.fetchQuery(Ct(e,t,i)),Ot=(e,t,r=c,i=n())=>r.fetchQuery({...Ct(e,t,i),staleTime:0}),kt=e=>e instanceof Error?e.name===`AbortError`||e.name===`CancelledError`||e.name===`Error`&&e.message===`CancelledError`:!1,At=1e4,jt=6e4,Mt=5e3,Nt=3e4,Pt=6e4,Ft=25,It=40,Lt=2,Rt=15e3,zt=500,Bt=30,Vt=20971520,Ht=new Map,Ut=new Map,Wt=new Map,Gt=new Map,Kt=new Map,qt=(e,t)=>`${t}:${e}`,Jt=e=>Ut.get(e)??0,Yt=e=>{let t=Jt(e)+1;return Ut.set(e,t),t},Xt=e=>{let t=(Wt.get(e)??0)+1;return Wt.set(e,t),t},Zt=e=>{let t=Ht.get(e);if(t)return t;let n=new Set;return Ht.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}),Qt=(e,t=Bt,n=Vt)=>{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},$t=(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},en=(e,t)=>!e&&!t?!1:!e||!t||e.remote!==t.remote||e.branch!==t.branch||e.ahead!==t.ahead||e.behind!==t.behind,tn=(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&&en(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&&$t(e.diffStats,t.diffStats))},nn=(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},rn=(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},an=e=>!e||e.trim().length===0,on=e=>(e||``).trim()===`U`,sn=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(on(t)||on(n))return e;let r=t===`?`||n===`?`?`A`:t||n||` `;return{...e,index:r,working_dir:` `}},cn=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(on(t)||on(n))return e;let r=n||(t===`A`||t===`?`?`?`:t)||` `;return{...e,index:` `,working_dir:r}},ln=e=>an(e.index)&&an(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&&Yt(r),n&&Yt(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=qt(n,a),s=Gt.get(o)??(a===`light`?Gt.get(qt(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)>jt,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(tn(s.status,u)){c=!0;let r=new Map(t().directories),i=r.get(n)??Q(),s=nn(i.status,u),l=rn(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&&Yt(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})();Gt.set(o,c);try{return await c}finally{Gt.get(o)===c&&Gt.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`?sn(e):cn(e);t!==e&&(l=!0),ln(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=Xt(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 Ot(r,i,void 0,o):await Dt(r,i,void 0,o);if(s!==Wt.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(kt(i)||console.error(`Failed to fetch git branches:`,i),s!==Wt.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>At||!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=Qt(s);a.set(n,{...o,diffCache:c}),e({directories:a})},clearDiffCache:n=>{Yt(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,Ft);await t().prefetchDiffs(e,n,i,{maxFiles:Ft})},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=It}=a,c=new Set(o.status.files.map(e=>e.path)),l=o.status.diffStats,u=Zt(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>zt||d.push(e)}let p=d.slice(0,Math.max(1,s));if(p.length===0)return;let m=Jt(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 ${Rt}ms`)),Rt)}),a=await Promise.race([t,i]);return{path:e,diff:{original:a.original??``,modified:a.modified??``,isBinary:a.isBinary}}},ee=async()=>{for(;;){if(m!==Jt(n))return;let e=_();if(!e)return;try{g.push(await v(e))}catch{}finally{u.delete(e)}}},y=Math.min(Lt,p.length);if(await Promise.allSettled(Array.from({length:y},()=>ee())),p.forEach(e=>u.delete(e)),m!==Jt(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 ne=Qt(S);b.set(n,{...x,diffCache:ne}),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<Mt||await t().fetchStatus(e,n,{silent:!!r?.status})},ensureAll:(e,n)=>{let r=Kt.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)>=Mt)&&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>=Nt)&&o.push(t().fetchBranches(e,n)),(!a.log||i-a.lastLogFetch>=At)&&o.push(t().fetchLog(e,n)),(!a.identity||i-a.lastIdentityFetch>=Pt)&&o.push(t().fetchIdentity(e,n)),o.length>0&&await Promise.all(o)})();return Kt.set(e,i),i.finally(()=>{Kt.get(e)===i&&Kt.delete(e)}),i},refresh:async(e,n={})=>{let{activeDirectory:r}=t();r&&await t().fetchAll(r,e,n)}}),{name:`git-store`})),un=e=>{let t=(0,J.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)},dn=e=>{let r=(0,J.c)(3),i=V.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)},fn=e=>{let t=(0,J.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)},pn=e=>{let t=(0,J.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)},mn=e=>{let t=(0,J.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)},hn={current:new Map},gn=()=>$(xn),_n=e=>{let t=(0,J.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=new Map,t[0]=n):n=t[0];let r=V.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)},vn=e=>{let t=(0,J.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)},yn=e=>{let t=(0,J.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)},bn=e=>{let t=(0,J.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isLoadingBranches??!1:!1,t[0]=e,t[1]=n),$(n)};function xn(e){let t=hn.current,n=t.size===e.directories.size;if(n){for(let[r,i]of e.directories)if(t.get(r)!==(i.status?.current??null)){n=!1;break}}if(n)return t;let r=new Map;for(let[t,n]of e.directories)r.set(t,n.status?.current??null);return hn.current=r,r}var Sn=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)}},Cn=e=>String(e||``).trim().replace(/^refs\/heads\//,``).replace(/^heads\//,``).replace(/^remotes\//,``),wn=e=>e.branchName?Cn(e.branchName):e.mode===`existing`?Cn(e.existingBranch||e.preferredName||``):Cn(e.preferredName||``),Tn=async e=>{let t=await I(e);try{let n=Sn((await P(e)).branches?.[t]?.tracking||null);if(n?.remote)return n.remote}catch{}try{let t=Sn((await F(e)).tracking);if(t?.remote)return t.remote}catch{}return null},En=async(e,t)=>{let n=await Tn(e),r=Cn(t);return!n||!r?null:{setUpstream:!0,upstreamRemote:n,upstreamBranch:r}},Dn=async(e,t,n)=>{let r=wn(t),i=n?.resolvedRootTrackingRemote,a=i===void 0?await En(e,r):i&&Cn(r)?{setUpstream:!0,upstreamRemote:i,upstreamBranch:Cn(r)}:null;return a?{...t,setUpstream:t.setUpstream??a.setUpstream,upstreamRemote:t.upstreamRemote||a.upstreamRemote,upstreamBranch:t.upstreamBranch||a.upstreamBranch}:t},On=async(e,t,n)=>{let r=await Dn(e.path,t,n);return L(e,r)},kn=`oc:lastWorktreeSourceBranch`,An=({mode:e,sourceBranch:t,linkedPr:n,selectedBranch:r})=>e===`existing-branch`?r||null:n?null:t||null,jn=({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},Mn=(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?` `:``}`},Nn=(e,t,n)=>{let r=Mn(e,t,n);return`${t.length===0&&!/^\s/.test(r)?` `:``}${r}${n.length===0&&!/\s$/.test(r)?` `:``}`},Pn=(e,t,n,r)=>{let i=e.slice(0,t),a=e.slice(n),o=Nn(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}},Fn=(e,t)=>{let n=e=>`${e.kind}:${e.value}:${e.range.start}:${e.range.end}`;return new Set(e.map(n)).has(n(t))?[...e]:[...e,t]},In=(e,t)=>t<e.length&&e[t]===` `?t+1:t;export{Oe as A,Tt as C,Re as D,Ke as E,Te as F,ve as I,Ee as M,Ce as N,Ie as O,we as P,Ot as S,Je as T,fn as _,kn as a,$ as b,On as c,gn as d,mn as f,vn as g,yn as h,Nn as i,De as j,Ne as k,Tn as l,bn as m,Fn as n,jn as o,dn as p,Pn as r,An as s,In as t,Dn as u,_n as v,Et as w,pn as x,un as y};
|