@openchambery/web 1.19.7-beta.2 → 1.19.7-beta.21
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-DI2zs2WH.js +1 -0
- package/dist/assets/AssistantView-sV1PVQiM.js +2 -0
- package/dist/assets/DiagramView-D2hqP5VV.js +1 -0
- package/dist/assets/FadeInOnReveal-BWJcUp5P.js +1 -0
- package/dist/assets/Icon-4My8YZwt.js +1 -0
- package/dist/assets/MarkdownLoadingSkeleton-Vezjvk9B.js +3 -0
- package/dist/assets/MarkdownRenderer-x091Z--3.js +2 -0
- package/dist/assets/MarkdownRendererImpl-DML8BSro.js +7 -0
- package/dist/assets/MarkstreamRendererImpl-BK-HM2k3.js +1 -0
- package/dist/assets/{MarkstreamRendererImpl-CR0fBG5w.css → MarkstreamRendererImpl-Ca7RATbs.css} +1 -1
- package/dist/assets/MobileDetailNavigation-DcxkWiks.js +1 -0
- package/dist/assets/MobileShareBridge-TAGcOiyb.js +4 -0
- package/dist/assets/MobileSurface-zqlZzEFQ.js +2 -0
- package/dist/assets/{MultiRunWindow-khpnWyZO.js → MultiRunWindow-iH1d9S14.js} +1 -1
- package/dist/assets/OnboardingScreen-BNEtPmvw.js +1 -0
- package/dist/assets/OverlayScrollbar-BZB21Yp_.js +2 -0
- package/dist/assets/SettingsView-CzW23DZA.js +25 -0
- package/dist/assets/{SettingsWindow-Dx5rU9v5.js → SettingsWindow-DZXCWZid.js} +1 -1
- package/dist/assets/TerminalView-pU0wpD8s.js +8 -0
- package/dist/assets/ToolOutputDialog-Bt7JChFG.js +10 -0
- package/dist/assets/appThemeRegistry-BI7WR2Wo.js +1 -0
- package/dist/assets/{button-z0GOBtWi.js → button-Or0daT9o.js} +1 -1
- package/dist/assets/clipboard-BXxLshVq.js +1 -0
- package/dist/assets/{collapsible-D9zJRpeB.js → collapsible-C-kzSGkq.js} +1 -1
- package/dist/assets/context-menu-Dpjla5p4.js +1 -0
- package/dist/assets/desktopHosts-BzSE0sK7.js +1 -0
- package/dist/assets/desktopRelayRestore-BaKjk1kQ.js +1 -0
- package/dist/assets/{diagram-CoEqmReY.js → diagram-D0mT3mo1.js} +1 -1
- package/dist/assets/{dialog-HCE4eLUW.js → dialog-BkhHBTd4.js} +1 -1
- package/dist/assets/dropdown-menu.styles-Bzo6L3FH.js +1 -0
- package/dist/assets/{es-D9KcV5TX.js → es-BHqnSjoZ.js} +1 -1
- package/dist/assets/fileQueries-DFY6Kiy1.js +1 -0
- package/dist/assets/fileReferenceActions-Di_DoDex.js +1 -0
- package/dist/assets/{fr-DPA9qUl3.js → fr-BfrlJY9i.js} +1 -1
- package/dist/assets/{gitApi-DNTMAa3F.js → gitApi-CeFszLvk.js} +3 -3
- package/dist/assets/{input-BG3VWTIF.js → input-BUsGnzwe.js} +1 -1
- package/dist/assets/insertionBoundaries-DDJNusn2.js +4 -0
- package/dist/assets/{ja-Dsif3NoD.js → ja-DP-7qt-x.js} +1 -1
- package/dist/assets/{ko-Dixx4Ctg.js → ko-E2B5vGQP.js} +1 -1
- package/dist/assets/main-CjnOsKDL.js +169 -0
- package/dist/assets/main-j-Ij13jc.js +2 -0
- package/dist/assets/markdown-worker-BuveaH3O.js +1 -0
- package/dist/assets/markdownTheme-CVS01wHf.js +2 -0
- package/dist/assets/miniChat-DgxavREE.js +2 -0
- package/dist/assets/mobile-C0rwPMPM.js +2 -0
- package/dist/assets/multirun-ot7-bKg7.js +4 -0
- package/dist/assets/outsideFileGrants-BB4GPvCq.js +1 -0
- package/dist/assets/path-utils-jGozTg9d.js +1 -0
- package/dist/assets/persistence-CSZp1CNB.js +3 -0
- package/dist/assets/{pl-Bj78ZGgf.js → pl-r8X5gRM5.js} +1 -1
- package/dist/assets/platform-CenlWqxu.js +2 -0
- package/dist/assets/projectMeta-3yOEc0oI.js +3 -0
- package/dist/assets/{pt-BR-CFL3xSAf.js → pt-BR-DcpdXCf5.js} +1 -1
- package/dist/assets/renderElectronMiniChatApp-BPNvFA_N.js +2 -0
- package/dist/assets/renderMobileApp-CNog29Xy.js +28 -0
- package/dist/assets/runtimeConfig-D28kNEYO.js +2 -0
- package/dist/assets/runtimeEndpointReset-CorvFIRk.js +147 -0
- package/dist/assets/sessionChangeSummary-CX2MJIkc.js +1 -0
- package/dist/assets/sessionLookup-CbatbQf7.js +1 -0
- package/dist/assets/sortable-tabs-strip-C5gGnikj.js +1 -0
- package/dist/assets/src-Af9cMFKF.css +2 -0
- package/dist/assets/{store-DzpbXWX1.js → store-BDFdnk6l.js} +2 -2
- package/dist/assets/terminalApi-CIIs9vFx.js +1 -0
- package/dist/assets/textarea-CIO34TZz.js +1 -0
- package/dist/assets/toolHelpers-DEvVP9U0.js +2 -0
- package/dist/assets/{tooltip-CtH61mQh.js → tooltip-BSrJYYYc.js} +1 -1
- package/dist/assets/{uk-BY60Ub3Z.js → uk-Di0vl9V-.js} +1 -1
- package/dist/assets/url-CE_gAfNa.js +1 -0
- package/dist/assets/{ChatContainer-CnOrdAgs.js → useAppFontEffects-CDpeZWK4.js} +44 -39
- package/dist/assets/useAssistantUIStore-BHacrxe_.js +1 -0
- package/dist/assets/useDesktopWindowControlsLayout-D-xPByG0.js +1 -0
- package/dist/assets/useEffectiveDirectory-Dp-tez_r.js +1 -0
- package/dist/assets/useFontPreferences-BxOHKuVw.js +1 -0
- package/dist/assets/useMobileNavigationStore-DE1Pe9A9.js +412 -0
- package/dist/assets/useSessionAutoCleanup-jNJ_WC38.js +1 -0
- package/dist/assets/useUIStore-CqqO11ZI.js +1 -0
- package/dist/assets/useWorkerHighlightedLines-MDnGj3yv.js +7 -0
- package/dist/assets/utils-B0mQXN9L.js +1 -0
- package/dist/assets/{vendor-markstream-react-CwvbEg9R.js → vendor-markstream-react-C3K8YH0d.js} +4 -4
- package/dist/assets/{zh-CN-Cox1LaOW.js → zh-CN-coFCfeQE.js} +1 -1
- package/dist/assets/{zh-TW-B6RU0mxa.js → zh-TW-oDRZ1-yb.js} +1 -1
- package/dist/index.html +9 -11
- package/dist/mini-chat.html +9 -11
- package/dist/mobile.html +15 -17
- package/package.json +2 -1
- package/server/index.js +2 -0
- package/server/lib/assistant-delivery-parts.js +3 -1
- package/server/lib/assistant-delivery-parts.test.js +11 -0
- package/server/lib/assistants/DOCUMENTATION.md +76 -3
- package/server/lib/assistants/assign.js +225 -0
- package/server/lib/assistants/assign.test.js +118 -0
- package/server/lib/assistants/bubbles.js +45 -0
- package/server/lib/assistants/bubbles.test.js +36 -0
- package/server/lib/assistants/cards.js +148 -0
- package/server/lib/assistants/cards.test.js +116 -0
- package/server/lib/assistants/contact-store.js +284 -0
- package/server/lib/assistants/contact-store.test.js +131 -0
- package/server/lib/assistants/contact-tools.js +761 -0
- package/server/lib/assistants/contact-tools.test.js +328 -0
- package/server/lib/assistants/contracts.js +20 -1
- package/server/lib/assistants/harness.js +551 -0
- package/server/lib/assistants/harness.test.js +607 -0
- package/server/lib/assistants/routes.js +44 -4
- package/server/lib/assistants/service.js +930 -17
- package/server/lib/assistants/service.test.js +1163 -45
- package/server/lib/llm/DOCUMENTATION.md +84 -0
- package/server/lib/llm/catalog.js +100 -0
- package/server/lib/llm/catalog.test.js +78 -0
- package/server/lib/llm/completions.js +151 -0
- package/server/lib/llm/completions.test.js +127 -0
- package/server/lib/llm/generate.js +570 -0
- package/server/lib/llm/generate.test.js +459 -0
- package/server/lib/llm/routes.js +47 -0
- package/server/lib/llm/temp-directory.js +37 -0
- package/server/lib/notifications/APNS.md +23 -17
- package/server/lib/notifications/DOCUMENTATION.md +5 -4
- package/server/lib/notifications/apns-runtime.js +139 -20
- package/server/lib/notifications/apns-runtime.test.js +66 -7
- package/server/lib/notifications/apns-titles.js +62 -62
- package/server/lib/notifications/apns-titles.test.js +3 -1
- package/server/lib/notifications/routes.js +1 -1
- package/server/lib/notifications/runtime.js +177 -86
- package/server/lib/notifications/runtime.test.js +122 -0
- package/server/lib/opencode/feature-routes-runtime.js +30 -0
- package/server/lib/opencode/feature-routes-runtime.test.js +20 -0
- package/server/lib/opencode/settings-runtime.js +18 -2
- package/server/lib/session-goal/DOCUMENTATION.md +8 -1
- package/server/lib/session-goal/runtime.js +20 -0
- package/server/lib/session-index/DOCUMENTATION.md +3 -1
- package/server/lib/session-index/service.js +10 -4
- package/server/lib/session-index/service.test.js +37 -0
- package/server/lib/session-title/runtime.js +1 -0
- package/server/lib/session-title/runtime.test.js +11 -0
- package/dist/assets/AgentAvatar-ziUs4sw3.js +0 -1
- package/dist/assets/AssistantView-DF4yXFgS.js +0 -1
- package/dist/assets/ContextPanel-Cg_uCHzJ.js +0 -285
- package/dist/assets/DiagramView-DYh3Zn2y.js +0 -1
- package/dist/assets/FadeInOnReveal-BAlsRFJH.js +0 -1
- package/dist/assets/Icon-CLpn1mIz.js +0 -1
- package/dist/assets/MarkdownRendererImpl-QzUEpBEm.js +0 -7
- package/dist/assets/MarkstreamRendererImpl-CXrfeUia.js +0 -1
- package/dist/assets/MobileDetailNavigation-DJXEYfq4.js +0 -1
- package/dist/assets/MobileShareBridge-CliVo1YH.js +0 -4
- package/dist/assets/MobileSurface-9Xh6WQkY.js +0 -2
- package/dist/assets/OnboardingScreen-CJYyR54B.js +0 -1
- package/dist/assets/OverlayScrollbar-C-jZ8ITG.js +0 -2
- package/dist/assets/SettingsView-DyCZehFG.js +0 -25
- package/dist/assets/TerminalView-XSALfUaH.js +0 -8
- package/dist/assets/ToolOutputDialog-BfuXazW9.js +0 -10
- package/dist/assets/appThemeRegistry-DDWrniMM.js +0 -2
- package/dist/assets/clipboard-Bz0Zm9VJ.js +0 -1
- package/dist/assets/desktop-CfLlmafK.js +0 -1
- package/dist/assets/desktopHosts-C1Ns3DUu.js +0 -1
- package/dist/assets/desktopRelayRestore-LBt0CBOj.js +0 -1
- package/dist/assets/fileQueries-Dnn15WsA.js +0 -1
- package/dist/assets/insertionBoundaries-DMxuUnL_.js +0 -4
- package/dist/assets/main-B9HVtgXE.js +0 -2
- package/dist/assets/main-ZNyIs3Sn.js +0 -29
- package/dist/assets/markdown-worker-y3ewaqAK.js +0 -4
- package/dist/assets/markdownTheme-TdhQOZSN.js +0 -2
- package/dist/assets/miniChat-q0T0WGkZ.js +0 -2
- package/dist/assets/mobile-DEduvLJj.js +0 -2
- package/dist/assets/multirun-DU-wrxlG.js +0 -4
- package/dist/assets/persistence-CmjKImz2.js +0 -3
- package/dist/assets/platform-skqcMARt.js +0 -2
- package/dist/assets/projectMeta-DNWx6Uva.js +0 -3
- package/dist/assets/radio-BEonIX1k.js +0 -1
- package/dist/assets/renderElectronMiniChatApp--JYWY41L.js +0 -2
- package/dist/assets/renderMobileApp-B0Ix_uNo.js +0 -25
- package/dist/assets/runtime-switch-BkpTTbEi.js +0 -1
- package/dist/assets/runtimeConfig-BTDIG7mX.js +0 -2
- package/dist/assets/runtimeEndpointReset-CZQCYtVI.js +0 -4
- package/dist/assets/shikiHighlight-C9Cx56Qg.js +0 -1
- package/dist/assets/sortable-tabs-strip-Bj8N0VWf.js +0 -1
- package/dist/assets/src-2eFAiBLq.css +0 -2
- package/dist/assets/terminalApi-CNqqwjfG.js +0 -1
- package/dist/assets/url-KeihbE0d.js +0 -1
- package/dist/assets/useAppFontEffects-CKLSamae.js +0 -7
- package/dist/assets/useAssistantUIStore-DaplPyb0.js +0 -1
- package/dist/assets/useDesktopWindowControlsLayout-DJSkFfhT.js +0 -1
- package/dist/assets/useEffectiveDirectory-B3rbY1Kv.js +0 -1
- package/dist/assets/useFontPreferences-D8emhcNv.js +0 -1
- package/dist/assets/useMobileNavigationStore-CAvVUItx.js +0 -412
- package/dist/assets/useSessionAutoCleanup-DxNgqJ8s.js +0 -1
- package/dist/assets/useUIStore-B7KJS5G7.js +0 -1
- package/dist/assets/useWorkerHighlightedLines-DiDF68LR.js +0 -7
- package/dist/assets/utils-CTL16t2f.js +0 -1
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{It as t}from"./persistence-CmjKImz2.js";import{g as n}from"./desktop-CfLlmafK.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-B7KJS5G7.js";import{o as l}from"./terminalApi-CNqqwjfG.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-Bz0Zm9VJ.js";import{l as m}from"./useMobileNavigationStore-CAvVUItx.js";import{t as h}from"./utils-CTL16t2f.js";import{n as g}from"./Icon-CLpn1mIz.js";import{t as _}from"./button-z0GOBtWi.js";import{n as v}from"./useThemeSystem-DMzWVJaW.js";import{i as y,t as b}from"./OverlayScrollbar-C-jZ8ITG.js";import{n as te}from"./useRuntimeAPIs-DSLXJybW.js";import{n as x}from"./useEffectiveDirectory-B3rbY1Kv.js";import{t as S}from"./sortable-tabs-strip-Bj8N0VWf.js";import{n as C,t as w}from"./useFontPreferences-D8emhcNv.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,10 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{It as t}from"./persistence-CmjKImz2.js";import{nt as n,rt as r,tt as i}from"./vendor-base-ui-CnHfUmDN.js";import{g as a}from"./useUIStore-B7KJS5G7.js";import{n as o}from"./vendor-react-DLPElpoQ.js";import{a as s,i as c}from"./vendor-pierre-diffs-DX7XTPG3.js";import{n as l}from"./vendor-reactuses-core-DDoDDyM9.js";import{n as u}from"./clipboard-Bz0Zm9VJ.js";import{n as d,t as f}from"./dialog-HCE4eLUW.js";import{t as p}from"./utils-CTL16t2f.js";import{n as m}from"./Icon-CLpn1mIz.js";import{t as h}from"./button-z0GOBtWi.js";import{n as g,t as _}from"./useThemeSystem-DMzWVJaW.js";import{l as v,n as y,v as b,x}from"./markdownTheme-TdhQOZSN.js";import{i as ee,l as S,t as C}from"./appThemeRegistry-DDWrniMM.js";import{u as w}from"./markdown-worker-y3ewaqAK.js";import{n as T}from"./useEffectiveDirectory-B3rbY1Kv.js";import{_ as E,d as D,f as te,g as O,h as ne,l as k,m as A,n as j,p as M,r as N,s as P,t as F,u as I}from"./useWorkerHighlightedLines-DiDF68LR.js";import{t as L}from"./vendor-tanstack-react-virtual-tlDgH6PG.js";var re=e(i(),1),R=o(),z=e(r(),1),B=n(),V=80,ie=20,H=z.memo(e=>{let t=(0,R.c)(26),{lines:n,language:r,maxHeight:i,showLineNumbers:a,lineStyles:o}=e,s=i===void 0?`60vh`:i,c=a===void 0||a,{currentTheme:l}=g(),u;t[0]===l?u=t[1]:(u=y(l),t[0]=l,t[1]=u);let d=u,f;t[2]===n?f=t[3]:(f=n.map(G).join(`
|
|
2
|
-
`),t[2]=n,t[3]=f);let p=F(f,r);if(!(n.length>V)){let e=d,r;t[4]!==s||t[5]!==e?(r={...e,maxHeight:s,overflow:`auto`},t[4]=s,t[5]=e,t[6]=r):r=t[6];let i;if(t[7]!==p||t[8]!==o||t[9]!==n||t[10]!==c){let e;t[12]!==p||t[13]!==o||t[14]!==c?(e=(e,t)=>(0,B.jsx)(W,{line:e,html:p?.[t],showLineNumbers:c,style:o?.(e)},t),t[12]=p,t[13]=o,t[14]=c,t[15]=e):e=t[15],i=n.map(e),t[7]=p,t[8]=o,t[9]=n,t[10]=c,t[11]=i}else i=t[11];let a;return t[16]!==r||t[17]!==i?(a=(0,B.jsx)(`div`,{className:`typography-code font-mono w-full min-w-0`,style:r,children:i}),t[16]=r,t[17]=i,t[18]=a):a=t[18],a}let m;return t[19]!==p||t[20]!==o||t[21]!==n||t[22]!==s||t[23]!==c||t[24]!==d?(m=(0,B.jsx)(U,{lines:n,highlighted:p,syntaxVars:d,maxHeight:s,showLineNumbers:c,lineStyles:o}),t[19]=p,t[20]=o,t[21]=n,t[22]=s,t[23]=c,t[24]=d,t[25]=m):m=t[25],m});H.displayName=`VirtualizedCodeBlock`;var U=z.memo(({lines:e,highlighted:t,syntaxVars:n,maxHeight:r,showLineNumbers:i,lineStyles:a})=>{let o=z.useRef(null),s=`min(${e.length*ie}px, ${r})`,c=L({count:e.length,getScrollElement:()=>o.current,estimateSize:()=>ie,overscan:20}),l=c.getVirtualItems();return(0,B.jsx)(`div`,{ref:o,className:`typography-code font-mono w-full min-w-0`,style:{...n,height:s,maxHeight:r,overflow:`auto`},children:(0,B.jsx)(`div`,{style:{height:c.getTotalSize(),position:`relative`},children:l.map(n=>{let r=e[n.index];return r?(0,B.jsx)(`div`,{"data-index":n.index,ref:c.measureElement,style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${n.start}px)`},children:(0,B.jsx)(W,{line:r,html:t?.[n.index],showLineNumbers:i,style:a?.(r)})},n.index):null})})})});U.displayName=`VirtualizedRows`;var W=z.memo(e=>{let t=(0,R.c)(12),{line:n,html:r,showLineNumbers:i,style:a}=e,o;t[0]!==n.isInfo||t[1]!==n.lineNumber||t[2]!==i?(o=i&&(0,B.jsx)(`span`,{className:`w-10 flex-shrink-0 text-right pr-3 select-none border-r mr-3 -my-0.5 py-0.5`,style:{color:`var(--tools-edit-line-number)`,borderColor:`var(--tools-border)`},children:!n.isInfo&&n.lineNumber!=null?n.lineNumber:``}),t[0]=n.isInfo,t[1]=n.lineNumber,t[2]=i,t[3]=o):o=t[3];let s;t[4]!==r||t[5]!==n.isInfo||t[6]!==n.text?(s=(0,B.jsx)(`div`,{className:`flex-1 min-w-0`,children:n.isInfo?(0,B.jsx)(`div`,{className:`whitespace-pre-wrap break-words text-muted-foreground/70 italic`,children:n.text}):r===void 0?(0,B.jsx)(`div`,{className:`whitespace-pre`,children:n.text}):(0,B.jsx)(`div`,{className:`whitespace-pre`,dangerouslySetInnerHTML:{__html:r}})}),t[4]=r,t[5]=n.isInfo,t[6]=n.text,t[7]=s):s=t[7];let c;return t[8]!==a||t[9]!==o||t[10]!==s?(c=(0,B.jsxs)(`div`,{className:`typography-code font-mono flex w-full min-w-0`,style:a,children:[o,s]}),t[8]=a,t[9]=o,t[10]=s,t[11]=c):c=t[11],c});W.displayName=`VirtualizedCodeBlock.Row`;function G(e){return e.text}var K=z.memo(function({jsonString:e,className:t,maxHeight:n=`100%`,initiallyExpandedDepth:r=2}){let{t:i}=u(),a=z.useRef(null),[o,s]=z.useState(null),c=z.useMemo(()=>{try{let t=e.trim();if(!t)return s(i(`jsonTreeView.error.emptyJson`)),null;let n=JSON.parse(t);return s(null),n}catch(e){return s(e instanceof Error?e.message:i(`jsonTreeView.error.invalidJson`)),null}},[e,i]),l=z.useCallback(()=>{a.current?.expandAll()},[]),d=z.useCallback(()=>{a.current?.collapseAll()},[]);return o?(0,B.jsx)(`div`,{className:t,children:(0,B.jsxs)(`div`,{className:`rounded-md border border-[var(--interactive-border)] bg-[var(--syntax-base-background)] p-4`,children:[(0,B.jsx)(`div`,{className:`mb-1 font-medium text-[var(--surface-foreground)]`,children:i(`jsonTreeView.error.invalidJsonTitle`)}),(0,B.jsx)(`div`,{className:`font-mono text-xs text-[var(--surface-mutedForeground)]`,children:o})]})}):c===null?null:(0,B.jsxs)(`div`,{className:t,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-[var(--interactive-border)] px-2 py-1`,children:[(0,B.jsxs)(h,{variant:`ghost`,size:`xs`,onClick:l,className:`gap-1 text-xs text-muted-foreground`,children:[(0,B.jsx)(m,{name:`arrow-down-s`,className:`h-3 w-3`}),i(`jsonTreeView.actions.expandAll`)]}),(0,B.jsxs)(h,{variant:`ghost`,size:`xs`,onClick:d,className:`gap-1 text-xs text-muted-foreground`,children:[(0,B.jsx)(m,{name:`arrow-up-s`,className:`h-3 w-3`}),i(`jsonTreeView.actions.collapseAll`)]})]}),(0,B.jsx)(`div`,{className:`bg-[var(--syntax-base-background)] py-1`,style:{maxHeight:n,overflow:`auto`},children:(0,B.jsx)(N,{ref:a,data:c,maxHeight:n,initiallyExpandedDepth:r})})]})}),q=class extends Error{key;params;constructor(e,t){super(e),this.name=`MermaidLoadFailure`,this.key=e,this.params=t}},J=(e,t)=>new q(e,t),ae=e=>e instanceof q,oe=e=>e+1,se=(e,t)=>e===t,ce=e=>{let t=e.indexOf(`,`);if(t<0)throw J(`chat.toolOutputDialog.mermaid.dataUrlMalformed`);let n=e.slice(0,t).toLowerCase(),r=e.slice(t+1);return n.includes(`;base64`)?atob(r):decodeURIComponent(r)},le=e=>Promise.resolve().then(()=>ce(e)),Y=1,X=56,Z=(e,t,n)=>Math.min(n,Math.max(t,e)),ue=({isMobile:e,pointerType:t,cancelled:n,moved:r,suppressTap:i,targetWasCanvas:a,start:o,end:s,startScale:c,hasMultipleImages:l})=>{if(n||i)return`none`;let u={x:s.x-o.x,y:s.y-o.y},d=Math.hypot(u.x,u.y),f=t!==`mouse`;if(e&&f&&c<=1.01&&Math.abs(u.x)>=X&&Math.abs(u.x)>Math.abs(u.y)*1.2)return l?u.x<0?`next`:`previous`:`none`;let p=!r&&d<=10;return e&&f&&p||!e&&t===`mouse`&&p&&a?`close`:`none`},de=(e,t)=>{if(e.width<=0||e.height<=0||t.width<=0||t.height<=0)return{width:1,height:1};let n=Math.min(t.width/e.width,t.height/e.height);return{width:Math.max(1,e.width*n),height:Math.max(1,e.height*n)}},fe=(e,t)=>{let n=t.minScale??Y,r=t.maxScale??5,i=Z(e.scale,n,r),a=Math.max(0,(t.image.width*i-t.viewport.width)/2),o=Math.max(0,(t.image.height*i-t.viewport.height)/2);return{scale:i,x:Z(e.x,-a,a),y:Z(e.y,-o,o)}},pe=(e,t,n,r,i)=>{let a=Z(t,i.minScale??Y,i.maxScale??5),o=a/e.scale;return fe({scale:a,x:n.x-r.x-(n.x-r.x-e.x)*o,y:n.y-r.y-(n.y-r.y-e.y)*o},i)},me=(e,t,n)=>fe({...e,x:e.x+t.x,y:e.y+t.y},n),he=(e,t,n,r,i,a)=>{let o=Z(r,a.minScale??Y,a.maxScale??5),s=o/e.scale;return fe({scale:o,x:n.x-i.x-(t.x-i.x-e.x)*s,y:n.y-i.y-(t.y-i.y-e.y)*s},a)},Q=500,$=24,ge=(e,t={})=>{let n=t.target??(typeof document>`u`?null:document);if(!n)return()=>{};let r=t.durationMs??Q,i=t.maxDistance??$,a=!0,o,s=()=>{a&&(a=!1,n.removeEventListener(`click`,c,!0),o!==void 0&&globalThis.clearTimeout(o))},c=t=>{let n=t;typeof n.clientX==`number`&&typeof n.clientY==`number`&&(Math.hypot(n.clientX-e.x,n.clientY-e.y)>i||(s(),t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation()))};return n.addEventListener(`click`,c,!0),o=globalThis.setTimeout(s,r),s},_e=(e,t,n={})=>{ge(e,n),t()},ve=500,ye=400,be=(e,t)=>new q(e,t),xe=e=>{let t=`h-3.5 w-3.5 flex-shrink-0`,n=e.toLowerCase();return n===`reasoning`?(0,B.jsx)(m,{name:`brain-ai-3`,className:t}):n===`image-preview`?(0,B.jsx)(m,{name:`file-image`,className:t}):n===`mermaid-preview`?(0,B.jsx)(m,{name:`file-list-2`,className:t}):n===`edit`||n===`multiedit`||n===`apply_patch`||n===`str_replace`||n===`str_replace_based_edit_tool`?(0,B.jsx)(m,{name:`pencil-ai`,className:t}):n===`write`||n===`create`||n===`file_write`||n===`read`||n===`view`||n===`file_read`||n===`cat`?(0,B.jsx)(m,{name:`file-pdf`,className:t}):n===`bash`||n===`shell`||n===`cmd`||n===`terminal`?(0,B.jsx)(m,{name:`terminal-box`,className:t}):n===`list`||n===`ls`||n===`dir`||n===`list_files`?(0,B.jsx)(m,{name:`folder-6`,className:t}):n===`search`||n===`grep`||n===`find`||n===`ripgrep`?(0,B.jsx)(m,{name:`search`,className:t}):n===`glob`?(0,B.jsx)(m,{name:`file-search`,className:t}):n===`fetch`||n===`curl`||n===`wget`||n===`webfetch`?(0,B.jsx)(m,{name:`global`,className:t}):n===`web-search`||n===`websearch`||n===`search_web`||n===`google`||n===`bing`||n===`duckduckgo`?(0,B.jsx)(m,{name:`search`,className:t}):n===`todowrite`||n===`todoread`?(0,B.jsx)(m,{name:`list-check-3`,className:t}):n.startsWith(`git`)?(0,B.jsx)(m,{name:`git-branch`,className:t}):(0,B.jsx)(m,{name:`tools`,className:t})},Se=150,Ce=40,we=120,Te=3,Ee={style:{background:`transparent`,backgroundColor:`transparent`,fontSize:`inherit`}},De={download:!1,copy:!1,showPanZoomControls:!0},Oe=`
|
|
3
|
-
[data-diff-header],
|
|
4
|
-
[data-diff] {
|
|
5
|
-
[data-separator] {
|
|
6
|
-
height: 24px !important;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
`,ke={hunkLineCount:50,lineHeight:24,diffHeaderHeight:44,hunkSeparatorHeight:24,spacing:0},Ae=()=>{let e=(0,R.c)(22),t=_(),n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=x(!1),e[0]=n):n=e[0];let r=n,i;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(i=x(!0),e[1]=i):i=e[1];let a=i,o;e[2]===t?.availableThemes?o=e[3]:(o=()=>t?.availableThemes??[r,a],e[2]=t?.availableThemes,e[3]=o),t?.availableThemes;let s;e[4]===o?s=e[5]:(s=o(),e[4]=o,e[5]=s);let c=s,l=t?.lightThemeId??r.metadata.id,u=t?.darkThemeId??a.metadata.id,d;e[6]!==c||e[7]!==l?(d=c.find(e=>e.metadata.id===l)??r,e[6]=c,e[7]=l,e[8]=d):d=e[8];let f=d,p;e[9]!==c||e[10]!==u?(p=c.find(e=>e.metadata.id===u)??a,e[9]=c,e[10]=u,e[11]=p):p=e[11];let m=p,h,g;e[12]!==m||e[13]!==f?(h=()=>{C(f),C(m)},g=[m,f],e[12]=m,e[13]=f,e[14]=h,e[15]=g):(h=e[14],g=e[15]),z.useEffect(h,g);let v=t?.currentTheme.metadata.variant??`light`,y;e[16]!==m.metadata.id||e[17]!==f.metadata.id?(y={light:f.metadata.id,dark:m.metadata.id},e[16]=m.metadata.id,e[17]=f.metadata.id,e[18]=y):y=e[18];let b=v===`dark`?`dark`:`light`,ee;return e[19]!==y||e[20]!==b?(ee={theme:y,themeType:b},e[19]=y,e[20]=b,e[21]=ee):ee=e[21],ee},je=()=>({width:typeof window<`u`?window.innerWidth:0,height:typeof window<`u`?window.innerHeight:0}),Me={mobile:{widthRatio:.94,heightRatio:.86,padding:10},desktop:{widthRatio:.8,heightRatio:.8,padding:16}},Ne=(e,t)=>{let n=t?Me.mobile:Me.desktop,r=Math.max(160,e.width-n.padding*2),i=Math.max(160,e.height-n.padding*2);return{maxWidth:Math.max(160,Math.min(r,e.width*n.widthRatio)),maxHeight:Math.max(160,Math.min(i,e.height*n.heightRatio))}},Pe=e=>{try{let t=Array.from(e.querySelectorAll(`g`)),n=0,r=null;for(let e of t){if(!(e instanceof SVGGraphicsElement))continue;let t=e.getBBox();if(!(t.width>0&&t.height>0))continue;let i=t.width*t.height;i>n&&(n=i,r=t.width/t.height)}if(r&&Number.isFinite(r)&&r>0)return r}catch{}let t=e.getAttribute(`viewBox`);if(t){let e=t.trim().split(/\s+/).map(Number);if(e.length===4){let t=e[2],n=e[3];if(Number.isFinite(t)&&Number.isFinite(n)&&t>0&&n>0)return t/n}}let n=Number(e.getAttribute(`width`)),r=Number(e.getAttribute(`height`));if(Number.isFinite(n)&&Number.isFinite(r)&&n>0&&r>0)return n/r;let i=e.getBoundingClientRect();return i.width>0&&i.height>0?i.width/i.height:null},Fe=e=>{let t=(0,R.c)(7),[n,r]=z.useState(e),[i,a]=z.useState(e),[o,s]=z.useState(!1),c,l;t[0]===e?(c=t[1],l=t[2]):(c=()=>{if(e){if(r(!0),s(!0),typeof window>`u`){a(!0);return}let e=window.requestAnimationFrame(()=>{a(!0)}),t=window.setTimeout(()=>{s(!1)},Se);return()=>{window.cancelAnimationFrame(e),window.clearTimeout(t)}}if(a(!1),s(!0),typeof window>`u`){r(!1);return}let t=window.setTimeout(()=>{r(!1),s(!1)},Se);return()=>{window.clearTimeout(t)}},l=[e],t[0]=e,t[1]=c,t[2]=l),z.useEffect(c,l);let u;return t[3]!==n||t[4]!==o||t[5]!==i?(u={isRendered:n,isVisible:i,isTransitioning:o},t[3]=n,t[4]=o,t[5]=i,t[6]=u):u=t[6],u},Ie=e=>{let t=(0,R.c)(3),[n,r]=z.useState(je),i,a;return t[0]===e?(i=t[1],a=t[2]):(i=()=>{if(!e||typeof window>`u`)return;let t=()=>{r(je())};return t(),window.addEventListener(`resize`,t),()=>{window.removeEventListener(`resize`,t)}},a=[e],t[0]=e,t[1]=i,t[2]=a),z.useEffect(i,a),n},Le=({popup:e,onOpenChange:t,isMobile:n})=>{let{t:r}=u(),i=_(),a=T()??``,o=z.useMemo(()=>{let t=e.image;if(!t)return[];let n=Array.isArray(t.gallery)?t.gallery.filter(e=>!!e?.url):[];return n.length>0?n:[{url:t.url,mimeType:t.mimeType,filename:t.filename,size:t.size}]},[e.image]),[s,c]=z.useState(0),[d,f]=z.useState(null),[g,y]=z.useState(!1),{isRendered:x,isVisible:ee,isTransitioning:C}=Fe(e.open),w=Ie(e.open),D=z.useRef(null),te=z.useRef(null),O=z.useRef(null),ne=z.useRef(null),k=z.useRef(null),A=z.useRef(null),j=z.useRef({scale:1,x:0,y:0}),M=z.useRef({image:{width:1,height:1},viewport:{width:1,height:1},maxScale:5}),N=z.useRef(new Map),P=z.useRef(null),F=z.useRef(null),I=z.useRef(null),L=z.useRef(null),R=z.useRef(0);z.useEffect(()=>{e.open&&(R.current=typeof performance<`u`?performance.now():Date.now())},[e.open]);let V=l(()=>(typeof performance<`u`?performance.now():Date.now())-R.current<ye),ie=l(()=>!V()&&(t(!1),!0));S({id:`image-preview`,active:e.open&&n,layer:`overlay`,onBack:ie,surfaceRef:te});let H=l(()=>{let e=P.current;e?.longPressTimer&&(clearTimeout(e.longPressTimer),e.longPressTimer=null)});z.useEffect(()=>{if(!e.open||o.length===0)return;let t=typeof e.image?.index==`number`?e.image.index:-1;if(t>=0&&t<o.length){c(t);return}let n=e.image?.url?o.findIndex(t=>t.url===e.image?.url):-1;c(n>=0?n:0)},[o,e.image?.index,e.image?.url,e.open]);let U=o[s]??o[0]??e.image,W=v(U?.url??``,a),G=U?.filename||e.title,K=o.length>1,q=l(()=>{let t=U?.url??e.image?.url??``;if(!t&&!W)return;let n=U?.mimeType||e.image?.mimeType,r=U?.filename||e.image?.filename||e.title,i=k.current;if(i&&i.naturalWidth>0){E(i,n||`image/png`).then(e=>{b({sourceUrl:t||W,displayUrl:W||i.currentSrc||i.src||void 0,filename:r,mimeType:n,effectiveDirectory:a,prefetchedBlob:e??void 0})});return}b({sourceUrl:t||W,displayUrl:W||void 0,filename:r,mimeType:n,effectiveDirectory:a})}),J=l(()=>{o.length<=1||c(e=>(e-1+o.length)%o.length)}),ae=l(()=>{o.length<=1||c(e=>(e+1)%o.length)}),oe=z.useMemo(()=>{let e={width:Math.max(1,w.width),height:Math.max(1,w.height)};return d?de(d,e):e},[d,w.height,w.width]),se=z.useMemo(()=>({image:oe,viewport:{width:Math.max(1,w.width),height:Math.max(1,w.height)},maxScale:5}),[oe,w.height,w.width]),ce=l((e,t=!1)=>{let n=fe(e,M.current);j.current=n,L.current={transform:n,animate:t},!(I.current!==null||typeof window>`u`)&&(I.current=window.requestAnimationFrame(()=>{I.current=null;let e=L.current;L.current=null,e&&(k.current&&(k.current.style.transition=e.animate?`transform 180ms cubic-bezier(0.22, 1, 0.36, 1)`:`none`,k.current.style.transform=`translate3d(${e.transform.x}px, ${e.transform.y}px, 0) scale(${e.transform.scale})`),A.current&&(A.current.textContent=`${Math.round(e.transform.scale*100)}%`),D.current&&(D.current.style.cursor=e.transform.scale>1?`grab`:`zoom-in`))}))}),le=l((e=!0)=>{ce({scale:1,x:0,y:0},e)}),Y=l(()=>({x:M.current.viewport.width/2,y:M.current.viewport.height/2})),X=l((e,t,n=!1)=>{ce(pe(j.current,e,t,Y(),M.current),n)}),Z=l(e=>{if(j.current.scale>1.01){le(!0);return}X(2,e,!0)}),Q=l(e=>{if(e.key===`Escape`){e.preventDefault(),t(!1);return}if(e.key===`Tab`){let t=te.current;if(!t)return;let n=Array.from(t.querySelectorAll(`button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`));if(n.length===0){e.preventDefault(),t.focus({preventScroll:!0});return}let r=n[0],i=n[n.length-1];if(e.shiftKey&&(document.activeElement===r||!t.contains(document.activeElement))){e.preventDefault(),i.focus({preventScroll:!0});return}!e.shiftKey&&(document.activeElement===i||!t.contains(document.activeElement))&&(e.preventDefault(),r.focus({preventScroll:!0}));return}if(!n){if(e.key===`+`||e.key===`=`){e.preventDefault(),X(j.current.scale*1.4,Y(),!0);return}if(e.key===`-`||e.key===`_`){e.preventDefault(),X(j.current.scale/1.4,Y(),!0);return}if(e.key===`0`){e.preventDefault(),le(!0);return}if(e.key===`ArrowLeft`&&K){e.preventDefault(),J();return}e.key===`ArrowRight`&&K&&(e.preventDefault(),ae())}});z.useEffect(()=>{if(e.open)return window.addEventListener(`keydown`,Q),()=>{window.removeEventListener(`keydown`,Q)}},[e.open]),z.useLayoutEffect(()=>{if(!(!e.open||!x))return ne.current=document.activeElement instanceof HTMLElement?document.activeElement:null,O.current?.focus({preventScroll:!0}),()=>{let e=ne.current;ne.current=null,e?.isConnected&&e.focus({preventScroll:!0})}},[x,e.open]),z.useEffect(()=>{I.current!==null&&window.cancelAnimationFrame(I.current),I.current=null,L.current=null,f(null),y(!1),j.current={scale:1,x:0,y:0},N.current.clear(),P.current=null,F.current=null,k.current&&(k.current.style.transform=`translate3d(0, 0, 0) scale(1)`),A.current&&(A.current.textContent=`100%`)},[U?.url,W]),z.useLayoutEffect(()=>{M.current=se;let e=fe(j.current,M.current);j.current=e,k.current&&(k.current.style.transition=`none`,k.current.style.transform=`translate3d(${e.x}px, ${e.y}px, 0) scale(${e.scale})`)},[se]),z.useEffect(()=>()=>{I.current!==null&&window.cancelAnimationFrame(I.current),I.current=null,L.current=null;let e=P.current;e?.longPressTimer&&(clearTimeout(e.longPressTimer),e.longPressTimer=null)},[]);let $=l(e=>{if(n)return;e.preventDefault();let t={x:e.clientX,y:e.clientY},r=Math.exp(-e.deltaY*.002);X(j.current.scale*r,t)});z.useEffect(()=>{let e=D.current;if(!(!x||n||!e))return e.addEventListener(`wheel`,$,{passive:!1}),()=>e.removeEventListener(`wheel`,$)},[n,x]);let ge=l(e=>{n||(e.preventDefault(),Z({x:e.clientX,y:e.clientY}))}),be=l(e=>{e.preventDefault(),e.stopPropagation()}),xe=l(e=>{e.pointerType!==`mouse`&&e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId);let t={x:e.clientX,y:e.clientY};if(N.current.set(e.pointerId,{point:t,pointerType:e.pointerType}),N.current.size===1){if(P.current={pointerId:e.pointerId,pointerType:e.pointerType,start:t,transform:j.current,moved:!1,targetWasCanvas:e.target===e.currentTarget,suppressTap:!1,longPressTimer:null,longPressTriggered:!1},e.pointerType!==`mouse`||j.current.scale<=1.01){let t=P.current;t.longPressTimer=setTimeout(()=>{!P.current||P.current.pointerId!==e.pointerId||P.current.moved||(P.current.longPressTriggered=!0,P.current.suppressTap=!0,q())},ve)}D.current&&j.current.scale>1&&(D.current.style.cursor=`grabbing`);return}H(),P.current&&(P.current.suppressTap=!0,P.current.longPressTriggered=!1);let n=Array.from(N.current.values()).slice(0,2).map(e=>e.point),r=n[1].x-n[0].x,i=n[1].y-n[0].y;F.current={distance:Math.max(1,Math.hypot(r,i)),midpoint:{x:(n[0].x+n[1].x)/2,y:(n[0].y+n[1].y)/2},transform:j.current},P.current&&(P.current.suppressTap=!0)}),Se=l(e=>{if(!N.current.has(e.pointerId))return;e.preventDefault();let t={x:e.clientX,y:e.clientY};if(N.current.set(e.pointerId,{point:t,pointerType:e.pointerType}),N.current.size>=2&&F.current){H();let e=Array.from(N.current.values()).slice(0,2).map(e=>e.point),t=e[1].x-e[0].x,n=e[1].y-e[0].y,r={x:(e[0].x+e[1].x)/2,y:(e[0].y+e[1].y)/2},i=F.current.transform.scale*Math.hypot(t,n)/F.current.distance;ce(he(F.current.transform,F.current.midpoint,r,i,Y(),M.current));return}let n=P.current;if(!n||n.pointerId!==e.pointerId)return;let r={x:t.x-n.start.x,y:t.y-n.start.y};Math.hypot(r.x,r.y)>10&&(n.moved=!0,H()),n.transform.scale>1.01&&ce(me(n.transform,r,M.current))}),Ce=l((e,r)=>{let i=P.current,a=N.current.get(e.pointerId)?{x:e.clientX,y:e.clientY}:void 0;if(N.current.delete(e.pointerId),i?.pointerId===e.pointerId&&(H(),a&&!i.longPressTriggered)){let e=ue({isMobile:n,pointerType:i.pointerType,cancelled:r,moved:i.moved||Math.hypot(a.x-i.start.x,a.y-i.start.y)>10,suppressTap:i.suppressTap,targetWasCanvas:i.targetWasCanvas,start:i.start,end:a,startScale:i.transform.scale,hasMultipleImages:K});if(e===`next`&&ae(),e===`previous`&&J(),e===`close`){if(V())return;if(n&&i.pointerType!==`mouse`){_e(a,()=>t(!1));return}t(!1)}}if(N.current.size===1){let[e,t]=Array.from(N.current.entries())[0];P.current={pointerId:e,pointerType:t.pointerType,start:t.point,transform:j.current,moved:!1,targetWasCanvas:!1,suppressTap:!0,longPressTimer:null,longPressTriggered:!1},F.current=null}else N.current.size===0&&(P.current=null,F.current=null,D.current&&(D.current.style.cursor=j.current.scale>1?`grab`:`zoom-in`));e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId)}),we=l(e=>{e.preventDefault(),e.stopPropagation(),q()}),Te=l(e=>{let t=e.currentTarget;t.naturalWidth>0&&t.naturalHeight>0&&f(e=>e?.width===t.naturalWidth&&e.height===t.naturalHeight?e:{width:t.naturalWidth,height:t.naturalHeight}),y(!0)});if(!x||!U||typeof document>`u`)return null;let Ee=i?.currentTheme.metadata.variant===`dark`,De=Ee?`bg-background text-foreground`:`bg-foreground text-background`,Oe=Ee?`border-foreground/15 bg-foreground/10 text-foreground`:`border-background/15 bg-background/10 text-background`,ke=Ee?`text-foreground hover:bg-foreground/15 hover:text-foreground`:`text-background hover:bg-background/15 hover:text-background`,Ae=(0,B.jsxs)(`div`,{ref:te,className:p(`fixed inset-0 z-50 overflow-hidden select-none`,De,C&&`transition-opacity duration-150 ease-out`,ee?`opacity-100`:`opacity-0`,`pointer-events-auto`),role:`dialog`,"aria-modal":`true`,"aria-label":G,tabIndex:-1,onClick:be,children:[(0,B.jsx)(h,{ref:O,className:`sr-only`,onClick:()=>t(!1),children:r(`dialog.common.actions.close`)}),(0,B.jsxs)(`div`,{ref:D,className:`absolute inset-0 flex items-center justify-center overflow-hidden touch-none [overscroll-behavior:none]`,onDoubleClick:n?void 0:ge,onContextMenu:we,onPointerDown:xe,onPointerMove:Se,onPointerUp:e=>Ce(e,!1),onPointerCancel:e=>Ce(e,!0),onLostPointerCapture:e=>Ce(e,!0),children:[!g&&(0,B.jsx)(`div`,{className:`pointer-events-none absolute inset-0 flex items-center justify-center`,role:`status`,children:(0,B.jsxs)(`span`,{className:`flex items-center gap-2 typography-ui-label opacity-70`,children:[(0,B.jsx)(m,{name:`loader-4`,className:`size-4 animate-spin`}),r(`common.loading`)]})}),(0,B.jsx)(`img`,{ref:k,src:W||void 0,alt:G??``,className:p(`block max-w-none object-contain will-change-transform`,g?`opacity-100`:`opacity-0`),style:{width:`${oe.width}px`,height:`${oe.height}px`},loading:`lazy`,draggable:!1,onLoad:Te})]}),(0,B.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-0 z-10 flex justify-center px-2 pb-[max(0.5rem,env(safe-area-inset-bottom))]`,children:(0,B.jsxs)(`div`,{className:p(`pointer-events-auto flex h-10 items-center gap-0.5 rounded-full border px-1 shadow-lg backdrop-blur-xl`,Oe),onPointerDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),children:[K&&(0,B.jsx)(h,{variant:`ghost`,size:`icon`,className:p(`size-8 rounded-full`,ke),onClick:J,"aria-label":r(`chat.toolOutputDialog.image.previousAria`),title:r(`chat.toolOutputDialog.image.previousAria`),children:(0,B.jsx)(m,{name:`arrow-left-s`,className:`size-5`})}),K&&(0,B.jsxs)(`span`,{className:`min-w-10 px-1 text-center typography-micro tabular-nums opacity-80`,children:[s+1,` / `,o.length]}),K&&(0,B.jsx)(h,{variant:`ghost`,size:`icon`,className:p(`size-8 rounded-full`,ke),onClick:ae,"aria-label":r(`chat.toolOutputDialog.image.nextAria`),title:r(`chat.toolOutputDialog.image.nextAria`),children:(0,B.jsx)(m,{name:`arrow-right-s`,className:`size-5`})}),K&&(0,B.jsx)(`span`,{className:`mx-0.5 h-4 w-px bg-current opacity-15`,"aria-hidden":`true`}),(0,B.jsx)(h,{variant:`ghost`,size:`icon`,className:p(`size-8 rounded-full`,ke),onClick:()=>X(j.current.scale/1.4,Y(),!0),"aria-label":r(`chat.toolOutputDialog.image.zoomOutAria`),title:r(`chat.toolOutputDialog.image.zoomOutAria`),children:(0,B.jsx)(m,{name:`subtract`,className:`size-4`})}),(0,B.jsxs)(h,{variant:`ghost`,size:`sm`,className:p(`h-8 min-w-14 rounded-full px-2 tabular-nums`,ke),onClick:()=>le(!0),"aria-label":r(`chat.toolOutputDialog.image.resetZoomAria`),title:r(`chat.toolOutputDialog.image.resetZoomAria`),children:[(0,B.jsx)(m,{name:`restart`,className:`size-3.5`}),(0,B.jsx)(`span`,{ref:A,children:`100%`})]}),(0,B.jsx)(h,{variant:`ghost`,size:`icon`,className:p(`size-8 rounded-full`,ke),onClick:()=>X(j.current.scale*1.4,Y(),!0),"aria-label":r(`chat.toolOutputDialog.image.zoomInAria`),title:r(`chat.toolOutputDialog.image.zoomInAria`),children:(0,B.jsx)(m,{name:`add`,className:`size-4`})})]})})]});return(0,re.createPortal)(Ae,document.body)},Re=z.memo(e=>{let t=(0,R.c)(7),{popup:n,diffViewMode:r,pierreThemeConfig:i}=e,a=n.content||``,o=r===`unified`?`unified`:`split`,s;t[0]!==i.theme||t[1]!==i.themeType||t[2]!==o?(s={diffStyle:o,diffIndicators:`none`,hunkSeparators:`line-info-basic`,lineDiffType:`none`,disableFileHeader:!0,maxLineDiffLength:1e3,expansionLineCount:20,overflow:`wrap`,theme:i.theme,themeType:i.themeType,unsafeCSS:Oe},t[0]=i.theme,t[1]=i.themeType,t[2]=o,t[3]=s):s=t[3];let l;return t[4]!==a||t[5]!==s?(l=(0,B.jsx)(`div`,{className:`typography-code`,children:(0,B.jsx)(c,{patch:a,metrics:ke,options:s,className:`block w-full`})}),t[4]=a,t[5]=s,t[6]=l):l=t[6],l});Re.displayName=`DialogUnifiedDiff`;var ze=z.memo(e=>{let t=(0,R.c)(29),{popup:n,pierreThemeConfig:r}=e,i;t[0]===n.content?i=t[1]:(i=k(n.content),t[0]=n.content,t[1]=i);let a=i,o=n.metadata?.input,c;t[2]===o?c=t[3]:(c=typeof o==`object`&&o?o:{},t[2]=o,t[3]=c);let l=c,u=typeof l.offset==`number`?l.offset:0,d=typeof l.file_path==`string`?l.file_path:typeof l.filePath==`string`?l.filePath:typeof l.path==`string`?l.path:`read-output`,f;t[4]===a.lines?f=t[5]:(f=a.lines.map(He).join(`
|
|
10
|
-
`),t[4]=a.lines,t[5]=f);let p=f,m;t[6]!==d||t[7]!==n.language?(m=n.language||w(d)||`text`,t[6]=d,t[7]=n.language,t[8]=m):m=t[8];let h=m,g;t[9]===a.lines?g=t[10]:(g=a.lines.some(Ue),t[9]=a.lines,t[10]=g);let _=g,v;if(t[11]!==_||t[12]!==u||t[13]!==a.lines||t[14]!==a.type){v=[];let e=u;for(let t of a.lines){t.lineNumber!==null&&(e=t.lineNumber);let n=a.type===`file`&&!_&&t.lineNumber===null&&!t.isInfo,r=t.lineNumber??(n?e+1:null);typeof r==`number`&&(e=r),v.push({text:t.text,lineNumber:r,isInfo:t.isInfo})}t[11]=_,t[12]=u,t[13]=a.lines,t[14]=a.type,t[15]=v}else v=t[15];let y=v;if(a.type===`file`){let e=h||void 0,n;t[16]!==p||t[17]!==d||t[18]!==e?(n={name:d,contents:p,lang:e},t[16]=p,t[17]=d,t[18]=e,t[19]=n):n=t[19];let i;t[20]!==r.theme||t[21]!==r.themeType?(i={disableFileHeader:!0,overflow:`wrap`,theme:r.theme,themeType:r.themeType},t[20]=r.theme,t[21]=r.themeType,t[22]=i):i=t[22];let a;return t[23]!==n||t[24]!==i?(a=(0,B.jsx)(s,{file:n,options:i,className:`block w-full`}),t[23]=n,t[24]=i,t[25]=a):a=t[25],a}let b;return t[26]!==y||t[27]!==h?(b=(0,B.jsx)(H,{lines:y,language:h,maxHeight:`70vh`}),t[26]=y,t[27]=h,t[28]=b):b=t[28],b});ze.displayName=`DialogReadContent`;var Be=e=>{let n=(0,R.c)(90),{popup:r,onOpenChange:i,isMobile:a}=e,{t:o}=u(),[s,c]=z.useState(r.mermaid?.source||``),[l,d]=z.useState(r.mermaid?.source?`ready`:`idle`),[f,h]=z.useState(``),{isRendered:g,isVisible:_,isTransitioning:v}=Fe(r.open),[y,b]=z.useState(null),x=Ie(r.open),S=z.useRef(0),C=z.useRef(null),w=qe,T;n[0]!==r.mermaid||n[1]!==o?(T=async()=>{let e=r.mermaid,n=oe(S.current);if(S.current=n,!e?.url){d(`error`),h(o(`chat.toolOutputDialog.mermaid.missingSource`));return}if(e.source){c(e.source),d(`ready`),h(``);return}d(`loading`),h(``);let i;if(e.url.startsWith(`data:`))i=le(e.url);else if(e.url.toLowerCase().startsWith(`file://`)){let n=w(e.url);i=n?t(`/api/fs/raw`,{query:{path:n}}).then(Je):Promise.reject(be(`chat.toolOutputDialog.mermaid.invalidLocalPath`))}else{let t=typeof URL.canParse==`function`&&URL.canParse(e.url,window.location.origin)?new URL(e.url,window.location.origin):null;i=!t||t.protocol!==`http:`&&t.protocol!==`https:`?Promise.reject(be(`chat.toolOutputDialog.mermaid.unsupportedUrlProtocol`)):fetch(t.toString()).then(Ye)}await i.then(e=>{se(S.current,n)&&(c(e),d(`ready`))}).catch(e=>{se(S.current,n)&&(d(`error`),h(ae(e)?o(e.key,e.params):o(`chat.toolOutputDialog.mermaid.loadFailed`)))})},n[0]=r.mermaid,n[1]=o,n[2]=T):T=n[2];let E=T,D,te;n[3]!==E||n[4]!==r.mermaid||n[5]!==r.open?(D=()=>{!r.open||!r.mermaid||E()},te=[E,r.mermaid,r.open],n[3]=E,n[4]=r.mermaid,n[5]=r.open,n[6]=D,n[7]=te):(D=n[6],te=n[7]),z.useEffect(D,te);let O,ne;n[8]!==i||n[9]!==r.open?(O=()=>{if(!r.open)return;let e=e=>{e.key===`Escape`&&i(!1)};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},ne=[i,r.open],n[8]=i,n[9]=r.open,n[10]=O,n[11]=ne):(O=n[10],ne=n[11]),z.useEffect(O,ne);let k;n[12]!==r.open||n[13]!==l?(k=()=>{if(!r.open||l!==`ready`){b(null);return}let e=()=>{let e=C.current?.querySelector(`svg`);if(!e)return!1;let t=Pe(e);return!t||!Number.isFinite(t)||t<=0?!1:(b(e=>e&&Math.abs(e-t)<.001?e:t),!0)},t=window.requestAnimationFrame(()=>{e()||(t=window.requestAnimationFrame(()=>{e()}))}),n=0,i,a=()=>{n>=Te||(i=window.setTimeout(()=>{n+=1,e()||a()},we))};a();let o=new MutationObserver(()=>{e()});return C.current&&o.observe(C.current,{childList:!0,subtree:!0,attributes:!0}),()=>{window.cancelAnimationFrame(t),typeof i==`number`&&window.clearTimeout(i),o.disconnect()}},n[12]=r.open,n[13]=l,n[14]=k):k=n[14];let A;n[15]!==r.open||n[16]!==s||n[17]!==l?(A=[r.open,s,l],n[15]=r.open,n[16]=s,n[17]=l,n[18]=A):A=n[18],z.useEffect(k,A);let j=`\`\`\`mermaid\n${s}\n\`\`\``,M;if(n[19]!==y||n[20]!==a||n[21]!==x){bb0:{let{maxWidth:e,maxHeight:t}=Ne(x,a),r=Math.max(160,t-Ce);if(y&&y<1){let t=Math.min(e,r),i;n[23]===t?i=n[24]:(i=Math.round(t),n[23]=t,n[24]=i);let a;n[25]===t?a=n[26]:(a=Math.round(t),n[25]=t,n[26]=a);let o;n[27]!==a||n[28]!==i?(o={width:i,height:a},n[27]=a,n[28]=i,n[29]=o):o=n[29],M=o;break bb0}let i=Math.round(e),o;n[30]===r?o=n[31]:(o=Math.round(r),n[30]=r,n[31]=o),M={width:i,height:o}}n[19]=y,n[20]=a,n[21]=x,n[22]=M}else M=n[22];let N=M;if(!g||typeof document>`u`)return null;let P=r.open?`pointer-events-auto`:`pointer-events-none`,F;n[32]===P?F=n[33]:(F=p(`fixed inset-0 z-50`,P),n[32]=P,n[33]=F);let I=v&&`transition-opacity duration-150 ease-out`,L=_?`opacity-100`:`opacity-0`,V;n[34]!==I||n[35]!==L?(V=p(`absolute inset-0`,I,L),n[34]=I,n[35]=L,n[36]=V):V=n[36];let ie;n[37]===Symbol.for(`react.memo_cache_sentinel`)?(ie={backgroundColor:`color-mix(in srgb, var(--surface-background) 70%, transparent)`},n[37]=ie):ie=n[37];let H;n[38]===i?H=n[39]:(H=()=>i(!1),n[38]=i,n[39]=H);let U;n[40]!==V||n[41]!==H?(U=(0,B.jsx)(`div`,{"aria-hidden":`true`,className:V,style:ie,onMouseDown:H}),n[40]=V,n[41]=H,n[42]=U):U=n[42];let W=a?`p-2.5`:`p-4`,G;n[43]===W?G=n[44]:(G=p(`absolute inset-0 flex items-center justify-center pointer-events-none`,W),n[43]=W,n[44]=G);let K=v&&`transition-opacity duration-150 ease-out`,q=_?`opacity-100`:`opacity-0`,J;n[45]!==K||n[46]!==q?(J=p(`pointer-events-auto flex flex-col gap-2`,K,q),n[45]=K,n[46]=q,n[47]=J):J=n[47];let ce=`${N.width}px`,Y;n[48]===ce?Y=n[49]:(Y={width:ce},n[48]=ce,n[49]=Y);let X;n[50]===i?X=n[51]:(X=()=>i(!1),n[50]=i,n[51]=X);let Z;n[52]===o?Z=n[53]:(Z=o(`chat.toolOutputDialog.mermaid.closeAria`),n[52]=o,n[53]=Z);let ue;n[54]===Symbol.for(`react.memo_cache_sentinel`)?(ue=(0,B.jsx)(m,{name:`close`,className:`h-4 w-4`}),n[54]=ue):ue=n[54];let de;n[55]!==X||n[56]!==Z?(de=(0,B.jsx)(`div`,{className:`flex items-center justify-end`,children:(0,B.jsx)(`button`,{type:`button`,className:`h-8 w-8 flex items-center justify-center rounded-lg text-muted-foreground/80 hover:text-foreground focus:outline-none focus:ring-2 focus:ring-primary/60`,onClick:X,"aria-label":Z,children:ue})}),n[55]=X,n[56]=Z,n[57]=de):de=n[57];let fe=`${N.height}px`,pe;n[58]===fe?pe=n[59]:(pe={height:fe},n[58]=fe,n[59]=pe);let me;n[60]!==l||n[61]!==o?(me=l===`loading`&&(0,B.jsxs)(`div`,{className:`h-full min-h-28 flex items-center justify-center gap-2 text-muted-foreground typography-meta`,children:[(0,B.jsx)(m,{name:`loader-4`,className:`h-4 w-4 animate-spin`}),(0,B.jsx)(`span`,{children:o(`chat.toolOutputDialog.mermaid.loading`)})]}),n[60]=l,n[61]=o,n[62]=me):me=n[62];let he;n[63]!==f||n[64]!==E||n[65]!==l||n[66]!==o?(he=l===`error`&&(0,B.jsxs)(`div`,{className:`rounded-xl border p-3 space-y-3`,style:{backgroundColor:`var(--status-error-background)`,borderColor:`var(--status-error-border)`},children:[(0,B.jsx)(`p`,{className:`typography-markdown`,style:{color:`var(--status-error)`},children:f||o(`chat.toolOutputDialog.mermaid.renderFailed`)}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>{E()},className:`px-3 py-1.5 rounded-lg typography-meta border transition-colors hover:bg-[var(--interactive-hover)]`,style:{borderColor:`var(--interactive-border)`,color:`var(--surface-foreground)`},children:o(`chat.toolOutputDialog.mermaid.retry`)})]}),n[63]=f,n[64]=E,n[65]=l,n[66]=o,n[67]=he):he=n[67];let Q;n[68]!==j||n[69]!==l?(Q=l===`ready`&&(0,B.jsx)(`div`,{ref:C,className:`h-full`,children:(0,B.jsx)(ee,{content:j,variant:`tool`,allowMermaidWheelEvents:!0,className:`markdown-mermaid-fullscreen h-full`,mermaidControls:De,enableFileReferences:!1})}),n[68]=j,n[69]=l,n[70]=Q):Q=n[70];let $;n[71]!==me||n[72]!==he||n[73]!==Q?($=(0,B.jsxs)(`div`,{className:`h-full overflow-hidden`,children:[me,he,Q]}),n[71]=me,n[72]=he,n[73]=Q,n[74]=$):$=n[74];let ge;n[75]!==pe||n[76]!==$?(ge=(0,B.jsx)(`div`,{className:`relative overflow-hidden`,style:pe,children:$}),n[75]=pe,n[76]=$,n[77]=ge):ge=n[77];let _e;n[78]!==J||n[79]!==Y||n[80]!==de||n[81]!==ge?(_e=(0,B.jsxs)(`div`,{className:J,style:Y,onMouseDown:Xe,children:[de,ge]}),n[78]=J,n[79]=Y,n[80]=de,n[81]=ge,n[82]=_e):_e=n[82];let ve;n[83]!==G||n[84]!==_e?(ve=(0,B.jsx)(`div`,{className:G,children:_e}),n[83]=G,n[84]=_e,n[85]=ve):ve=n[85];let ye;return n[86]!==F||n[87]!==U||n[88]!==ve?(ye=(0,re.createPortal)((0,B.jsxs)(`div`,{className:F,children:[U,ve]}),document.body),n[86]=F,n[87]=U,n[88]=ve,n[89]=ye):ye=n[89],ye},Ve=e=>{let t=(0,R.c)(48),{popup:n,onOpenChange:r,isMobile:i}=e,{t:o}=u(),[c,l]=z.useState(`unified`),h=Ae(),g;t[0]===n.open?g=t[1]:(g=()=>{n.open&&l(`unified`)},t[0]=n.open,t[1]=g);let _;if(t[2]!==n.open||t[3]!==n.title?(_=[n.open,n.title],t[2]=n.open,t[3]=n.title,t[4]=_):_=t[4],z.useEffect(g,_),n.image){let e;return t[5]!==i||t[6]!==r||t[7]!==n?(e=(0,B.jsx)(Le,{popup:n,onOpenChange:r,isMobile:i}),t[5]=i,t[6]=r,t[7]=n,t[8]=e):e=t[8],e}if(n.mermaid){let e;return t[9]!==i||t[10]!==r||t[11]!==n?(e=(0,B.jsx)(Be,{popup:n,onOpenChange:r,isMobile:i}),t[9]=i,t[10]=r,t[11]=n,t[12]=e):e=t[12],e}let v=n.open,y=i?`w-[95vw] max-w-[95vw]`:`max-w-5xl`,b=i?`[&>button]:right-1`:`[&>button]:top-2.5 [&>button]:right-4`,x;t[13]!==y||t[14]!==b?(x=p(`overflow-hidden flex flex-col min-h-0 pt-3 pb-4 px-4 gap-1`,`[&>button]:top-1.5`,y,b),t[13]=y,t[14]=b,t[15]=x):x=t[15];let S;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(S={maxHeight:`90vh`},t[16]=S):S=t[16];let C;t[17]===n.metadata?C=t[18]:(C=n.metadata?.tool?xe(n.metadata.tool):(0,B.jsx)(m,{name:`tools`,className:`h-3.5 w-3.5 text-foreground flex-shrink-0`}),t[17]=n.metadata,t[18]=C);let T;t[19]===n.title?T=t[20]:(T=(0,B.jsx)(`span`,{className:`break-words flex-1 leading-tight`,children:n.title}),t[19]=n.title,t[20]=T);let E;t[21]!==c||t[22]!==n.isDiff?(E=n.isDiff&&(0,B.jsx)(j,{mode:c,onModeChange:l,className:`mr-8 flex-shrink-0`}),t[21]=c,t[22]=n.isDiff,t[23]=E):E=t[23];let k;t[24]!==E||t[25]!==C||t[26]!==T?(k=(0,B.jsx)(`div`,{className:`flex-shrink-0 pb-1`,children:(0,B.jsxs)(`div`,{className:`flex items-start gap-2 text-foreground typography-ui-header font-semibold`,children:[C,T,E]})}),t[24]=E,t[25]=C,t[26]=T,t[27]=k):k=t[27];let N;t[28]!==h||t[29]!==n.metadata?(N=n.metadata?.input&&typeof n.metadata.input==`object`&&Object.keys(n.metadata.input).length>0&&n.metadata?.tool!==`todowrite`&&n.metadata?.tool!==`todoread`&&n.metadata?.tool!==`apply_patch`?(()=>{let e=n.metadata,t=e.input,r=e=>{let n=t[e];return typeof n==`string`?n:typeof n==`number`?String(n):null};return(0,B.jsxs)(`div`,{className:`border-b border-border/20 p-4 -mx-3`,children:[(0,B.jsx)(`div`,{className:`typography-markdown font-medium text-muted-foreground mb-2 px-3`,children:e.tool===`bash`?`Command:`:e.tool===`task`?`Task Details:`:`Input:`}),e.tool===`bash`&&r(`command`)?(0,B.jsx)(`div`,{className:`tool-input-surface bg-transparent rounded-xl border border-border/20 mx-3`,children:(0,B.jsx)(O,{language:`bash`,code:r(`command`),style:a.getPopupStyles(),codeStyle:Ee.style,wrap:!0})}):e.tool===`task`&&r(`prompt`)?(0,B.jsxs)(`div`,{className:`tool-input-surface bg-transparent rounded-xl border border-border/20 font-mono whitespace-pre-wrap text-foreground/90 mx-3`,style:a.getPopupStyles(),children:[r(`description`)?`Task: ${r(`description`)}\n`:``,r(`subagent_type`)?`Agent Type: ${r(`subagent_type`)}\n`:``,`Instructions:\n${r(`prompt`)}`]}):e.tool===`write`&&r(`content`)?(0,B.jsx)(`div`,{className:`tool-input-surface bg-transparent rounded-xl border border-border/20 mx-3`,children:(0,B.jsx)(s,{file:{name:r(`filePath`)||r(`file_path`)||`new-file`,contents:r(`content`),lang:w(r(`filePath`)||r(`file_path`)||``)||void 0},options:{disableFileHeader:!0,overflow:`wrap`,theme:h.theme,themeType:h.themeType},className:`block w-full`})}):(0,B.jsx)(`div`,{className:`tool-input-surface bg-transparent rounded-xl border border-border/20 font-mono whitespace-pre-wrap text-foreground/90 mx-3`,style:a.getPopupStyles(),children:P(t,e.tool)})]})})():null,t[28]=h,t[29]=n.metadata,t[30]=N):N=t[30];let F;t[31]!==c||t[32]!==i||t[33]!==h||t[34]!==n||t[35]!==o?(F=n.isDiff?(0,B.jsx)(Re,{popup:n,diffViewMode:c,pierreThemeConfig:h}):n.content?(0,B.jsx)(`div`,{className:`p-4`,children:(()=>{let e=n.metadata?.tool;return e===`todowrite`||e===`todoread`?M(n.content)||(0,B.jsx)(O,{language:`json`,code:n.content,style:a.getPopupContainerStyles(),codeStyle:Ee.style,wrap:!0}):e===`list`?te(n.content)||(0,B.jsx)(`pre`,{className:`typography-markdown bg-muted/30 p-2 rounded-xl border border-border/20 font-mono whitespace-pre-wrap`,children:n.content}):e===`grep`?D(n.content,i)||(0,B.jsx)(`pre`,{className:`typography-code bg-muted/30 p-2 rounded-xl border border-border/20 font-mono whitespace-pre-wrap`,children:n.content}):e===`glob`?I(n.content,i)||(0,B.jsx)(`pre`,{className:`typography-code bg-muted/30 p-2 rounded-xl border border-border/20 font-mono whitespace-pre-wrap`,children:n.content}):e===`task`||e===`reasoning`?(0,B.jsx)(`div`,{className:e===`reasoning`?`text-muted-foreground/70`:``,children:(0,B.jsx)(ee,{content:n.content,variant:`tool`})}):e===`web-search`||e===`websearch`||e===`search_web`?A(n.content)||(0,B.jsx)(O,{language:`text`,code:n.content,style:a.getPopupContainerStyles(),codeStyle:Ee.style,wrap:!0}):e===`read`?(0,B.jsx)(ze,{popup:n,pierreThemeConfig:h}):(n.content?ne(n.content):{data:null,isJson:!1}).isJson?(0,B.jsx)(K,{jsonString:n.content,initiallyExpandedDepth:3,maxHeight:`70vh`}):(0,B.jsx)(O,{language:n.language||`text`,code:n.content,style:a.getPopupContainerStyles(),codeStyle:Ee.style,wrap:!0})})()}):(0,B.jsxs)(`div`,{className:`p-8 text-muted-foreground typography-ui-header`,children:[(0,B.jsx)(`div`,{className:`mb-2`,children:o(`chat.toolOutputDialog.commandCompleted`)}),(0,B.jsx)(`div`,{className:`typography-meta`,children:o(`chat.toolOutputDialog.noOutputProduced`)})]}),t[31]=c,t[32]=i,t[33]=h,t[34]=n,t[35]=o,t[36]=F):F=t[36];let L;t[37]!==N||t[38]!==F?(L=(0,B.jsx)(`div`,{className:`flex-1 min-h-0 rounded-xl border border-border/30 bg-muted/10 overflow-hidden`,children:(0,B.jsxs)(`div`,{className:`tool-output-surface h-full max-h-[75vh] overflow-y-auto px-3 pr-4`,children:[N,F]})}),t[37]=N,t[38]=F,t[39]=L):L=t[39];let re;t[40]!==k||t[41]!==L||t[42]!==x?(re=(0,B.jsxs)(d,{className:x,style:S,children:[k,L]}),t[40]=k,t[41]=L,t[42]=x,t[43]=re):re=t[43];let V;return t[44]!==r||t[45]!==n.open||t[46]!==re?(V=(0,B.jsx)(f,{open:v,onOpenChange:r,children:re}),t[44]=r,t[45]=n.open,t[46]=re,t[47]=V):V=t[47],V};function He(e){return e.text}function Ue(e){return e.lineNumber!==null}function We(e){if(!e||/[\0\r\n]/.test(e))return!1;let t=e.replace(/\\/g,`/`);return t.split(`/`).filter(Boolean).includes(`..`)?!1:t.startsWith(`/`)?!0:/^[A-Za-z]:\//.test(t)}function Ge(e,t){let n=Number.parseInt(t,16);return Number.isFinite(n)?String.fromCharCode(n):`%${t}`}function Ke(e){return e.replace(/%([0-9A-Fa-f]{2})/g,Ge)}function qe(e){let t=e.trim();if(!t.toLowerCase().startsWith(`file://`))return null;let n=We,r=Ke;if(typeof URL.canParse==`function`&&URL.canParse(t)){let e=r(new URL(t).pathname||``);return/^\/[A-Za-z]:\//.test(e)&&(e=e.slice(1)),n(e)?e:null}let i=t.replace(/^file:\/\//i,``),a=r(i);return n(a)?a:n(i)?i:null}function Je(e){return e.ok?e.text():Promise.reject(be(`chat.toolOutputDialog.mermaid.readFileFailedWithStatus`,{status:e.status}))}function Ye(e){return e.ok?e.text():Promise.reject(be(`chat.toolOutputDialog.mermaid.loadFailedWithStatus`,{status:e.status}))}function Xe(e){return e.stopPropagation()}export{Ve as default};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkstreamRendererImpl-CXrfeUia.js","assets/rolldown-runtime-C0FnF6B9.js","assets/vendor-base-ui-CnHfUmDN.js","assets/vendor-markstream-react-CwvbEg9R.js","assets/vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js","assets/vendor-markstream-core-Cm34iPLL.js","assets/vendor-floating-ui-dom-BHhLtF5l.js","assets/vendor-floating-ui-core-Co1I1lFV.js","assets/vendor-markstream-react-CGQrpq8a.css","assets/vendor-reactuses-core-DDoDDyM9.js","assets/vendor-lodash-es-DfLbG5Af.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/utils-CTL16t2f.js","assets/desktop-CfLlmafK.js","assets/runtime-switch-BkpTTbEi.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/useThemeSystem-DMzWVJaW.js","assets/url-KeihbE0d.js","assets/markdownHeightCache-CvUyZT4q.js","assets/MarkstreamRendererImpl-CR0fBG5w.css","assets/MarkdownRendererImpl-QzUEpBEm.js","assets/persistence-CmjKImz2.js","assets/vendor-zustand-B4dlGEM2.js","assets/useUIStore-B7KJS5G7.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-react-DLPElpoQ.js","assets/vendor-tanstack-query-core-BWz0ose6.js","assets/platform-skqcMARt.js","assets/vendor-opencode-sdk-C07HQypa.js","assets/vendor-katex--B5dHUyk.js","assets/clipboard-Bz0Zm9VJ.js","assets/store-DzpbXWX1.js","assets/useMobileNavigationStore-CAvVUItx.js","assets/vendor-tanstack-react-query-D7pys_c9.js","assets/vendor-sonner-DVzioF3d.js","assets/useAssistantUIStore-DaplPyb0.js","assets/vendor-fuse.js-DB5wDJbI.js","assets/markdownTheme-TdhQOZSN.js","assets/vendor-pierre-diffs-DX7XTPG3.js","assets/vendor-hast-util-to-html-B0p1k5Xa.js","assets/vendor-character-entities-legacy-Wut6vMuj.js","assets/vendor-character-entities-html4-DlN_yAFd.js","assets/vendor-ccount-CyGsA0u7.js","assets/vendor-comma-separated-tokens-B9ouxNNS.js","assets/vendor-oniguruma-to-es-CrHzjjSU.js","assets/vendor-oniguruma-parser-D2DIvhSP.js","assets/vendor-diff-Dq7CZNim.js","assets/vendor-lru_map-DpDied8H.js","assets/useRuntimeAPIs-DSLXJybW.js","assets/markdown-worker-y3ewaqAK.js","assets/useEffectiveDirectory-B3rbY1Kv.js","assets/FadeInOnReveal-BAlsRFJH.js","assets/vendor-morphdom-BbKiNDAu.js","assets/vendor-beautiful-mermaid-DykqIK5D.js","assets/vendor-dompurify-CeJNOzik.js","assets/vendor-marked-WVekxjAN.js","assets/vendor-remend-C3cXc-tf.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{a as t}from"./vendor-zustand-B4dlGEM2.js";import{nt as n,rt as r}from"./vendor-base-ui-CnHfUmDN.js";import{n as i,t as a}from"./platform-skqcMARt.js";import{a as o,n as s,o as c}from"./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js";import{n as l}from"./vendor-react-DLPElpoQ.js";import{r as u}from"./vendor-pierre-diffs-DX7XTPG3.js";import{n as d}from"./vendor-reactuses-core-DDoDDyM9.js";import{r as f}from"./useMobileNavigationStore-CAvVUItx.js";import{c as p,l as m}from"./dialog-HCE4eLUW.js";import{t as h}from"./utils-CTL16t2f.js";import{a as ee}from"./markdown-worker-y3ewaqAK.js";import{n as g,t as te}from"./markdownHeightCache-CvUyZT4q.js";var _=e(r(),1),v=l(),y=`openchamber.iosNativeUi`,ne=()=>{if(typeof window>`u`)return!1;try{return window.localStorage.getItem(y)===`1`}catch{return!1}},re=e=>{if(!(typeof window>`u`))try{e?window.localStorage.setItem(y,`1`):window.localStorage.removeItem(y)}catch{}},b=t(e=>({enabled:ne(),setEnabled:t=>{re(t),e({enabled:t})}})),ie=()=>b.getState().enabled,ae=()=>b(se),oe=()=>i()&&a()===`ios`;function se(e){return e.enabled}var ce=`oc-native-ios-composer`,x=`--oc-native-composer-height`,S=`--oc-native-composer-accessory`,le=33554432,C=`OpenChamberComposer`,w=`#22c55e`,T=32,ue=()=>({open:!1,highlightedIndex:0,rows:[]}),de=()=>({text:``,placeholder:``,modelLabel:``,modelVariantLabel:``,modelIcon:``,canSend:!1,canAbort:!1,attachmentCount:0,attachmentPreviews:[],citationRanges:[],chipRanges:[],appearance:`dark`,attachAria:``,attachTitle:``,attachPhotosLabel:``,attachFilesLabel:``,attachCancelLabel:``,sendAria:``,queueAria:``,stopAria:``,modelAria:``,agentAria:``,agentLabel:``,agentColor:w,agentIdenticon:Array.from({length:25},()=>0),suppressed:!0,showScrollToBottom:!1,scrollAria:``,autocomplete:ue()}),fe=o(C),pe=e=>e.isCapacitor&&e.platform===`ios`&&e.pluginAvailable&&e.isMobile&&e.nativeUiEnabled!==!1;function me(e){return typeof window>`u`?!1:pe({isCapacitor:i(),platform:a(),pluginAvailable:s.isPluginAvailable(C),isMobile:e,nativeUiEnabled:ie()})}var he=e=>e.classList.contains(`dark`)?`dark`:`light`,ge=e=>{let t=e?.height;return typeof t!=`number`||!Number.isFinite(t)||t<0?0:t},_e=(e,t)=>{if(!(t>0)){e.style.removeProperty(x);return}e.style.setProperty(x,`${Math.round(t)}px`)},ve=(e,t)=>{if(!(t>0)){e.style.removeProperty(S);return}e.style.setProperty(S,`${Math.round(t)}px`)},E=(e,t)=>{e.classList.toggle(ce,t),t||(e.style.removeProperty(x),e.style.removeProperty(S))},ye=e=>p(e).flat().map(e=>+!!e),D=new Map,O=null,be=e=>{let t=D.get(e);if(t!==void 0)return t;if(typeof document>`u`||typeof getComputedStyle>`u`)return w;!O&&typeof MutationObserver<`u`&&(O=new MutationObserver(()=>{D.clear()}),O.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`,`style`]}));let n=getComputedStyle(document.documentElement).getPropertyValue(e).trim(),r=document.createElement(`span`);r.style.color=n||`var(${e})`,document.documentElement.appendChild(r);let i=getComputedStyle(r).color;r.remove();let a=/rgba?\(\s*([\d.]+)(?:\s*,\s*|\s+)([\d.]+)(?:\s*,\s*|\s+)([\d.]+)/.exec(i);if(!a)return D.set(e,w),w;let o=e=>Math.max(0,Math.min(255,Math.round(Number(e)))).toString(16).padStart(2,`0`),s=`#${o(a[1])}${o(a[2])}${o(a[3])}`;return D.set(e,s),s},xe=e=>be(m(e).var),k=(e,t)=>e.text===t.text&&e.placeholder===t.placeholder&&e.modelLabel===t.modelLabel&&e.modelVariantLabel===t.modelVariantLabel&&e.modelIcon===t.modelIcon&&e.canSend===t.canSend&&e.canAbort===t.canAbort&&e.attachmentCount===t.attachmentCount&&Se(e.attachmentPreviews,t.attachmentPreviews)&&Ce(e.citationRanges,t.citationRanges)&&we(e.chipRanges,t.chipRanges)&&e.appearance===t.appearance&&e.attachAria===t.attachAria&&e.attachTitle===t.attachTitle&&e.attachPhotosLabel===t.attachPhotosLabel&&e.attachFilesLabel===t.attachFilesLabel&&e.attachCancelLabel===t.attachCancelLabel&&e.sendAria===t.sendAria&&e.queueAria===t.queueAria&&e.stopAria===t.stopAria&&e.modelAria===t.modelAria&&e.agentAria===t.agentAria&&e.agentLabel===t.agentLabel&&e.agentColor===t.agentColor&&e.agentIdenticon.join(``)===t.agentIdenticon.join(``)&&e.suppressed===t.suppressed&&e.showScrollToBottom===t.showScrollToBottom&&e.scrollAria===t.scrollAria&&A(e.autocomplete,t.autocomplete),A=(e,t)=>e.open===t.open&&e.highlightedIndex===t.highlightedIndex&&e.rows.length===t.rows.length&&e.rows.every((e,n)=>{let r=t.rows[n];return!!(r&&e.id===r.id&&e.title===r.title&&e.subtitle===r.subtitle&&e.badge===r.badge&&e.iconBase64===r.iconBase64)}),Se=(e,t)=>e.length===t.length&&e.every((e,n)=>{let r=t[n];return!!(r&&e.id===r.id&&e.filename===r.filename&&e.mime===r.mime&&e.thumbnailBase64===r.thumbnailBase64&&e.removeAria===r.removeAria)}),Ce=(e,t)=>e.length===t.length&&e.every((e,n)=>e.start===t[n]?.start&&e.end===t[n]?.end),we=(e,t)=>e.length===t.length&&e.every((e,n)=>{let r=t[n];return!!(r&&e.start===r.start&&e.end===r.end&&e.triggerLength===r.triggerLength&&e.color===r.color)}),Te=(e,t)=>{if(!e||!t||t.length===0)return[];let n=[],r=0;for(let e of t){let t=r;r+=e.text.length;let i=e.visual;if(!i)continue;let a=i.trigger.length;a<1||t+a>r||i.icon&&n.push({start:t,end:r,triggerLength:a,iconName:i.icon})}return n},Ee=(e,t)=>e.map(e=>({start:e.start,end:e.end,triggerLength:e.triggerLength,color:t})),De=e=>e.map(e=>`${e.id}:${e.filename}:${e.mimeType}:${e.dataUrl?.length??0}`).join(`|`),Oe=e=>{let t=e?.id;return typeof t==`string`&&t.trim()?t:``},j=e=>{if(typeof e==`number`&&Number.isFinite(e)&&e>=0)return Math.floor(e);if(typeof e==`string`&&e.trim()){let t=Number(e);if(Number.isFinite(t)&&t>=0)return Math.floor(t)}return null},ke=e=>{let t=j(e?.selectionStart);if(t===null)return null;let n=j(e?.selectionEnd);return{start:t,end:n!==null&&n>=t?n:t}},Ae=e=>j(e?.index)??0,je=(e,t)=>{let n=Math.max(0,e);return typeof t!=`number`||!Number.isFinite(t)?n:Math.max(0,Math.min(Math.floor(t),n))},Me=e=>e.nextText===e.nativeOwnedText?{omitText:!0,forceText:!1}:e.nextText.length===0&&e.nativeOwnedText.length>0||e.preset?{omitText:!1,forceText:!0}:e.echoingNative?{omitText:!0,forceText:!1}:{omitText:!1,forceText:!0},Ne=e=>e.replacedText!==null&&e.incoming===e.replacedText,Pe=e=>setTimeout(e,0),Fe=e=>{e.applyDocument(e.text),Pe(e.submit)},M=(e,t)=>e===t,Ie=(e,t,n,r)=>{if(n.omitText&&e&&k(e,t))return null;let i={};if(n.omitText||(i.text=t.text,n.forceText&&(i.forceText=!0),n.forceText&&typeof r?.caret==`number`&&Number.isFinite(r.caret)&&(i.caret=Math.max(0,Math.floor(r.caret)))),!e){let{text:e,...n}=t;return Object.assign(i,n),i}let a=(n,r)=>{r(e[n],t[n])||(i[n]=t[n])};return a(`placeholder`,M),a(`modelLabel`,M),a(`modelVariantLabel`,M),a(`modelIcon`,M),a(`canSend`,M),a(`canAbort`,M),a(`attachmentCount`,M),a(`attachmentPreviews`,Se),a(`citationRanges`,Ce),a(`chipRanges`,we),a(`appearance`,M),a(`attachAria`,M),a(`attachTitle`,M),a(`attachPhotosLabel`,M),a(`attachFilesLabel`,M),a(`attachCancelLabel`,M),a(`sendAria`,M),a(`queueAria`,M),a(`stopAria`,M),a(`modelAria`,M),a(`agentAria`,M),a(`agentLabel`,M),a(`agentColor`,M),a(`agentIdenticon`,(e,t)=>e.join(``)===t.join(``)),a(`suppressed`,M),a(`showScrollToBottom`,M),a(`scrollAria`,M),a(`autocomplete`,A),Object.keys(i).length===0?null:i},Le=e=>{let t=Array.isArray(e?.skipped)?e.skipped:[],n=[];for(let e of t){if(!e||typeof e!=`object`)continue;let t=e.name;typeof t==`string`&&t.trim()&&n.push(t)}return n},Re=e=>{try{let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}catch{return null}},ze=(e,t=le)=>{let n=Array.isArray(e?.files)?e.files:[],r=[];for(let e of n){if(!e||typeof e!=`object`)continue;let n=e;if(typeof n.dataBase64!=`string`||n.dataBase64.length===0)continue;let i=Re(n.dataBase64);if(!i||i.byteLength===0||i.byteLength>t)continue;let a=typeof n.name==`string`&&n.name.trim()?n.name:`file`,o=typeof n.mime==`string`&&n.mime.trim()?n.mime:`application/octet-stream`;r.push(new File([new Uint8Array(i)],a,{type:o}))}return r},N=80,Be=e=>typeof document>`u`||!e||!e.startsWith(`data:image/`)?Promise.resolve(null):new Promise(t=>{let n=new Image;n.decoding=`async`,n.onload=()=>{try{let e=document.createElement(`canvas`);e.width=N,e.height=N;let r=e.getContext(`2d`);if(!r){t(null);return}r.clearRect(0,0,N,N),r.drawImage(n,0,0,N,N);let i=e.toDataURL(`image/jpeg`,.72),a=i.indexOf(`,`);t(a>=0?i.slice(a+1):null)}catch{t(null)}},n.onerror=()=>t(null),n.src=e}),Ve=e=>typeof document>`u`||!e?Promise.resolve(null):new Promise(t=>{let n=new Image;n.decoding=`async`,n.onload=()=>{try{let e=document.createElement(`canvas`);e.width=T,e.height=T;let r=e.getContext(`2d`);if(!r){t(null);return}r.clearRect(0,0,T,T),r.drawImage(n,0,0,T,T);let i=e.toDataURL(`image/png`),a=i.indexOf(`,`);t(a>=0?i.slice(a+1):null)}catch{t(null)}},n.onerror=()=>t(null),n.src=e}),He=()=>fe,P=((e=He)=>{let t=0,n=null,r=[],i=null,a=``,o=!1,s=!1,c=()=>{n!==null&&(clearTimeout(n),n=null)},l=(e,...t)=>{let n=i;n&&n[e](...t)},u=async()=>{if(r.length>0)return;let t=e(),n=await Promise.all([t.addListener(`textChanged`,e=>{let t=typeof e.text==`string`?e.text:``;a=t,l(`onText`,t,e.composing===!0,ke(e))}),t.addListener(`send`,e=>{let t=typeof e.text==`string`?e.text:a;a=t,l(`onSend`,t)}),t.addListener(`abort`,()=>{l(`onAbort`)}),t.addListener(`attach`,()=>{l(`onAttach`)}),t.addListener(`filesPicked`,t=>{l(`onFiles`,ze(t),Le(t)),e().focus()}),t.addListener(`removeAttachment`,e=>{let t=Oe(e);t&&l(`onRemoveAttachment`,t)}),t.addListener(`openModel`,()=>{l(`onOpenModel`)}),t.addListener(`cycleAgent`,()=>{l(`onCycleAgent`)}),t.addListener(`openAgent`,()=>{l(`onOpenAgent`)}),t.addListener(`heightChanged`,e=>{l(`onHeight`,ge(e))}),t.addListener(`scrollToBottom`,()=>{l(`onScrollToBottom`)}),t.addListener(`autocompleteAccept`,e=>{l(`onAutocompleteAccept`,Ae(e))}),t.addListener(`autocompleteDismiss`,()=>{l(`onAutocompleteDismiss`)})]);if(r.length>0){for(let e of n)e.remove();return}r=n},d=n=>{t>0||(i=null,o=!1,E(n,!1),e().dismiss())};return{bind(e){i=e},rememberText(e){a=e},rememberState(e){a=e.text},conceal(){o||t===0||(o=!0,e().hide())},reveal(){!o||t===0||(o=!1,e().show())},async warm(){s||t>0||(s=!0,await e().present(de()))},async retain(n,i){c(),t+=1,o=!1,s=!0,a=i.text,E(n,!0),r.length===0&&await u(),await e().present(i)},release(e){t=Math.max(0,t-1),!(t>0)&&(c(),n=setTimeout(()=>{n=null,d(e)},0))},shutdown(n=document.documentElement){c(),t=0,s=!1,o=!1,i=null,E(n,!1),e().dismiss()},snapshot(){return{retainCount:t,listenerCount:r.length,hidePending:n!==null,concealed:o,warmed:s}}}})(),Ue=()=>o(`OpenChamberNavigation`),We=e=>e?.kind===`chat`||e?.kind===`draft`,F=e=>e?e.kind===`draft`||e.kind===`chat`&&e.routes.length<=1:!1,Ge=(e,t)=>We(e)&&!We(t),Ke=(e=P)=>{F(f.getState().secondary)&&e.conceal()},qe=(e=P)=>{let t=f.subscribe((t,n)=>{Ge(n.secondary,t.secondary)&&e.conceal()}),n=[],r=!1;return s.getPlatform()===`ios`&&(async()=>{let t=Ue(),i=await t.addListener(`backStarted`,()=>{F(f.getState().secondary)&&e.conceal()}),a=await t.addListener(`backCancelled`,()=>{e.reveal()});if(r){i.remove(),a.remove();return}n=[i,a]})(),()=>{r=!0,t();for(let e of n)e.remove();n=[]}},I=`openchamber:chunk-import-reload`,Je=250,Ye=3e4,Xe=[/Importing a module script failed/i,/Failed to fetch dynamically imported module/i,/error loading dynamically imported module/i,/Loading chunk \S+ failed/i,/ChunkLoadError/i];function L(e){if(e instanceof Error)return`${e.name}\n${e.message}\n${e.stack??``}`;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function R(e){let t=L(e);return Xe.some(e=>e.test(t))}function Ze(e){return`1.19.7-beta.2:${L(e).slice(0,500)}`}function Qe(e){if(typeof window>`u`)return;let t=Date.now(),n=Ze(e),r=null;try{let e=window.sessionStorage.getItem(I);if(e)try{r=JSON.parse(e)}catch{r=null}}catch{return}let i=typeof r?.timestamp==`number`?r.timestamp:0;if(!(r?.signature===n&&t-i<Ye)){try{window.sessionStorage.setItem(I,JSON.stringify({signature:n,timestamp:t}))}catch{return}console.error(`[refresh-debug] chunk-import-reload`,{error:L(e).slice(0,1e3)}),window.setTimeout(()=>{window.location.reload()},0)}}async function $e(e,t={}){let n=t.retries??1,r;for(let t=0;t<=n;t+=1)try{return await e()}catch(e){if(r=e,!R(e)||t>=n)break;await new Promise(e=>setTimeout(e,Je*(t+1)))}throw R(r)&&Qe(r),r}var z=e=>(0,_.lazy)(()=>$e(e)),B=`__openchamberMobileBackRoute`,et=()=>typeof window>`u`||i()?null:{currentState:()=>window.history.state&&typeof window.history.state==`object`?window.history.state:null,pushState:e=>window.history.pushState(e,``,window.location.href),back:()=>window.history.back(),subscribe:e=>{let t=t=>e(t.state&&typeof t.state==`object`?t.state:null);return window.addEventListener(`popstate`,t),()=>window.removeEventListener(`popstate`,t)}},V=e=>{let t=e?.[B];return typeof t==`number`&&Number.isFinite(t)?t:null},H=new class{routes=[];listeners=new Set;nextToken=1;history;removeHistoryListener=null;programmaticHistoryBackToken=null;pendingHistoryRemovals=new Map;animatedBackDriver=null;presentationCancelDriver=null;constructor(e=et()){this.history=e}subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));getTopRoute=()=>this.routes.at(-1)??null;register=e=>{let t=this.pendingHistoryRemovals.get(e.id);this.pendingHistoryRemovals.delete(e.id);let n=!!(this.history&&t!==void 0&&V(this.history.currentState())===t),r={...e,token:n&&t!==void 0?t:this.nextToken++};this.routes.push(r),this.ensureHistoryListener(),this.history&&!n&&this.history.pushState({...this.history.currentState()??{},[B]:r.token}),this.notify();let i=!0;return()=>{if(!i)return;i=!1;let e=this.routes.indexOf(r);e<0||(this.routes.splice(e,1),this.history&&V(this.history.currentState())===r.token?(this.pendingHistoryRemovals.set(r.id,r.token),queueMicrotask(()=>{if(this.pendingHistoryRemovals.get(r.id)===r.token){if(this.pendingHistoryRemovals.delete(r.id),!this.history||V(this.history.currentState())!==r.token){this.routes.length===0&&this.pendingHistoryRemovals.size===0&&this.disposeHistoryListener();return}this.programmaticHistoryBackToken=r.token,this.history.back(),this.routes.length===0&&this.pendingHistoryRemovals.size===0&&this.disposeHistoryListener()}})):this.routes.length===0&&this.pendingHistoryRemovals.size===0&&this.disposeHistoryListener(),this.notify())}};backImmediately=e=>{let t=this.getTopRoute();return!t||e&&t.layer!==e?!1:t.onBack()!==!1};requestAnimatedBack=e=>{let t=this.getTopRoute();return!t||e&&t.layer!==e?!1:this.animatedBackDriver?.(t)?!0:this.backImmediately(e)};setAnimatedBackDriver=e=>(this.animatedBackDriver=e,()=>{this.animatedBackDriver===e&&(this.animatedBackDriver=null)});setPresentationCancelDriver=e=>(this.presentationCancelDriver=e,()=>{this.presentationCancelDriver===e&&(this.presentationCancelDriver=null)});cancelPresentation=()=>{this.presentationCancelDriver?.()};requestBrowserBack=()=>{let e=this.getTopRoute();return e?this.history&&V(this.history.currentState())===e.token?(this.history.back(),!0):e.onBack()!==!1:!1};ensureHistoryListener(){!this.history||this.removeHistoryListener||(this.removeHistoryListener=this.history.subscribe(e=>{if(this.programmaticHistoryBackToken!==null){this.programmaticHistoryBackToken=null;return}let t=this.getTopRoute();t&&V(e)!==t.token&&t.onBack()===!1&&this.history&&this.history.pushState({...this.history.currentState()??{},[B]:t.token})}))}disposeHistoryListener(){this.removeHistoryListener?.(),this.removeHistoryListener=null,this.programmaticHistoryBackToken=null,this.pendingHistoryRemovals.clear()}notify(){this.listeners.forEach(e=>e())}},tt=e=>{let t=(0,v.c)(8),{id:n,active:r,layer:i,onBack:a,surfaceRef:o,underlayRef:s}=e,c=i===void 0?`root`:i,l=d(a),u,f;t[0]!==r||t[1]!==l||t[2]!==n||t[3]!==c||t[4]!==o||t[5]!==s?(u=()=>{if(r)return H.register({id:n,layer:c,onBack:l,getSurface:()=>o.current,getUnderlay:()=>s?.current??null})},f=[r,l,n,c,o,s],t[0]=r,t[1]=l,t[2]=n,t[3]=c,t[4]=o,t[5]=s,t[6]=u,t[7]=f):(u=t[6],f=t[7]),_.useEffect(u,f)},U=o(`OpenChamberNavigation`),W=e=>Math.min(1,Math.max(0,Number.isFinite(e)?e:0)),nt=(e,t)=>!e||!t?!1:e.onBack()!==!1,rt=e=>{let t=W(e.progress),n=e.commit?1-t:t;if(n<=.001)return 0;let r=Math.max(1,e.viewportWidth??390),i=Math.abs(e.velocityX??0)/r,a=n/Math.max(e.commit?2.4:2.8,i)*1e3,o=e.commit?90:100,s=e.commit?320:260;return Math.round(Math.min(s,Math.max(o,a)))},G=e=>{let{surface:t,underlay:n,surfaceTransition:r,surfaceAnimation:i,underlayTransition:a,underlayAnimation:o}=e;t.style.removeProperty(`transform`),t.style.removeProperty(`opacity`),t.style.removeProperty(`will-change`),t.style.removeProperty(`box-shadow`),t.style.transition=r,t.style.animation=i,n&&(n.style.removeProperty(`transform`),n.style.removeProperty(`opacity`),n.style.removeProperty(`will-change`),n.style.transition=a??``,n.style.animation=o??``)},K=(e,t)=>{let n=W(t),{surface:r}=e;r.style.transform=`translate3d(${n*100}%, 0, 0)`},it=e=>!e.surfaceConnected||e.topRouteToken!==e.routeToken||e.routeSurface!==e.outgoingSurface,at=async(e,t,n,r)=>{if(!r&&typeof e.animate==`function`){let r=e.style.transform||`translate3d(0%, 0, 0)`,i=`translate3d(${t}%, 0, 0)`,a=e.animate([{transform:r},{transform:i}],{duration:n,easing:`cubic-bezier(0.22, 1, 0.36, 1)`,fill:`forwards`}),o=!1;try{await a.finished,o=!0}catch{}finally{o&&(e.style.transform=i),a.cancel()}return}e.style.transform=`translate3d(${t}%, 0, 0)`},ot=async(e,t,n=typeof window<`u`&&window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches,r=rt({progress:Number.parseFloat(e.style.transform.match(/translate3d\(([-\d.]+)%/)?.[1]??`0`)/100,commit:t}))=>at(e,t?100:0,r,n),st=class{pending=0;enqueue(){this.pending+=1}take(){return this.pending!==0&&(--this.pending,!0)}clear(){this.pending=0}},ct=e=>{let t=(0,v.c)(4),{enabled:n,rootRoutesBlocked:r}=e,a,o;t[0]!==n||t[1]!==r?(a=()=>{if(!n||!i()||s.getPlatform()===`web`)return;let e=!1,t=null,a=null,o=0,c=0,l=0,u=new st,d=[],f=e=>!!e&&(!r||e?.layer===`overlay`),p=()=>{let e=f(H.getTopRoute());U.setEnabled({enabled:e}).catch(lt)},m=()=>{if(H.cancelPresentation(),a)return;let e=H.getTopRoute();if(!f(e))return;let n=e.getSurface();if(!n)return;n.getAnimations().forEach(ut),a=null;let r=e.layer===`root`?e.getUnderlay():null,i=n.style.transition,o=n.style.animation,s=r?.style.transition??null,c=r?.style.animation??null;r?.getAnimations().forEach(dt),n.style.transition=`none`,n.style.animation=`none`,n.style.willChange=`transform`,r&&(r.style.removeProperty(`transform`),r.style.removeProperty(`will-change`)),l+=1,t={route:e,surface:n,underlay:r,surfaceTransition:i,surfaceAnimation:o,underlayTransition:s,underlayAnimation:c},K(t,0)},h=e=>{c=W(e),!o&&(o=window.requestAnimationFrame(()=>{o=0,t&&K(t,c)}))},ee=ft,g=(n,r,i)=>{if(n&&Ke(),a)return n&&f(H.getTopRoute())?(u.enqueue(),!0):!1;o&&=(window.cancelAnimationFrame(o),0),t||m(),t&&r!==void 0&&K(t,r);let s=t,d=l;if(t=null,!s){if(!n)return!1;let e=H.getTopRoute();return nt(e,f(e))}a=s;let p=window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches??!1,h=rt({progress:W(r??c),commit:n,velocityX:i,viewportWidth:window.innerWidth});return ot(s.surface,n,p,h).then(async()=>{d===l&&(!e&&n&&(s.route.onBack(),await ee(s)),d===l&&(G(s),a===s&&(a=null),!e&&u.take()&&g(!0,0,0)))}),!0},te=H.setAnimatedBackDriver(e=>e!==H.getTopRoute()||!f(e)?!1:g(!0,0,0)),_=H.subscribe(p);return(async()=>{let t=await U.addListener(`backStarted`,m),n=await U.addListener(`backProgressed`,e=>h(e.progress??0)),r=await U.addListener(`backCancelled`,e=>g(!1,e.progress,e.velocityX)),i=await U.addListener(`backInvoked`,e=>g(!0,e.progress,e.velocityX));if(e){await Promise.all([t.remove(),n.remove(),r.remove(),i.remove()]);return}d.push(t,n,r,i),p()})().catch(pt),p(),()=>{e=!0,l+=1,u.clear(),_(),te(),o&&window.cancelAnimationFrame(o),t&&G(t),a&&(a.surface.getAnimations().forEach(mt),a.underlay?.getAnimations().forEach(ht),G(a)),t=null,a=null,U.setEnabled({enabled:!1}).catch(gt),d.forEach(_t)}},o=[n,r],t[0]=n,t[1]=r,t[2]=a,t[3]=o):(a=t[2],o=t[3]),_.useEffect(a,o)};function lt(){}function ut(e){return e.cancel()}function dt(e){return e.cancel()}function ft(e){return new Promise(t=>{let n=0,r=12,i=!1,a=()=>{i||(i=!0,c(),n&&window.cancelAnimationFrame(n),t())},o=()=>{let t=H.getTopRoute();return it({surfaceConnected:e.surface.isConnected,routeToken:e.route.token,topRouteToken:t?.token??null,routeSurface:e.route.getSurface(),outgoingSurface:e.surface})},s=()=>{if(o()||r<=0){a();return}--r,n=window.requestAnimationFrame(s)},c=H.subscribe(()=>{o()&&a()});s()})}function pt(){}function mt(e){return e.cancel()}function ht(e){return e.cancel()}function gt(){}function _t(e){e.remove()}var vt=(e,t)=>{try{let n=t??(typeof localStorage>`u`?null:localStorage);return n?n.getItem(e)===`1`:!1}catch{return!1}},yt=(e,t)=>{try{let n=t??(typeof localStorage>`u`?null:localStorage);return!n||n.getItem(e)!==`0`}catch{return!0}},bt=(e,t)=>{try{typeof localStorage<`u`&&localStorage.setItem(e,t?`1`:`0`)}catch{}},xt=`oc:legend-timeline`,St=e=>vt(xt,e),Ct=`oc:markstream-react`,wt=e=>yt(Ct,e),q=t(e=>({legendTimelineEnabled:St(),setLegendTimelineEnabled:t=>{bt(xt,t),e({legendTimelineEnabled:t})},markstreamReactEnabled:wt(),setMarkstreamReactEnabled:t=>{bt(Ct,t),e({markstreamReactEnabled:t})}})),J=null,Tt=()=>(J??=c(()=>import(`./MarkstreamRendererImpl-CXrfeUia.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20])).catch(e=>{throw J=null,e}),J),Et=()=>{Tt().catch(()=>void 0)},Y=null,X=()=>(Y??=c(()=>import(`./MarkdownRendererImpl-QzUEpBEm.js`),__vite__mapDeps([21,1,14,22,13,23,2,24,25,26,27,28,29,4,30,9,10,11,31,32,33,34,35,36,37,12,15,16,17,38,39,40,41,42,43,44,45,46,47,48,49,18,50,19,51,52,53,54,55,56,57])).catch(e=>{throw Y=null,e}),Y),Dt=()=>{X().catch(()=>void 0),wt()&&Et()},Ot=class extends _.Component{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){console.warn(`[markstream-react] falling back to the current Markdown renderer`,e)}render(){return this.state.hasError?this.props.fallback:this.props.children}},kt=_.createContext(!0),At=()=>_.useContext(kt),Z=n(),jt=z(()=>X().then(e=>({default:e.MarkdownRenderer}))),Mt=z(()=>Tt().then(e=>({default:e.MarkstreamRenderer}))),Nt=z(()=>X().then(e=>({default:e.SimpleMarkdownRenderer}))),Pt=e=>e===`tool`?`markdown-content markdown-tool`:e===`reasoning`?`markdown-content markdown-reasoning`:`markdown-content leading-relaxed`,Q=e=>{let t=(0,v.c)(15),n=q(Lt),r=typeof e.content==`string`?e.content:``,i=typeof e.variant==`string`?e.variant:`assistant`,a;t[0]!==r||t[1]!==n||t[2]!==e.reserveMeasuredHeight||t[3]!==i?(a=e.reserveMeasuredHeight?g(te(r,n?`markstream:${i}`:i)):void 0,t[0]=r,t[1]=n,t[2]=e.reserveMeasuredHeight,t[3]=i,t[4]=a):a=t[4];let o=a,s;t[5]!==e.className||t[6]!==e.variant?(s=h(`relative break-words w-full min-w-0`,Pt(e.variant),typeof e.className==`string`?e.className:void 0),t[5]=e.className,t[6]=e.variant,t[7]=s):s=t[7];let c;t[8]!==r||t[9]!==e.animated||t[10]!==o?(c=(0,Z.jsx)(ee,{animated:e.animated,content:r,reservedHeight:o}),t[8]=r,t[9]=e.animated,t[10]=o,t[11]=c):c=t[11];let l;return t[12]!==s||t[13]!==c?(l=(0,Z.jsx)(`div`,{className:s,"aria-busy":`true`,"data-markdown-hydration":`deferred`,"data-markdown-ready":`false`,children:c}),t[12]=s,t[13]=c,t[14]=l):l=t[14],l},Ft=e=>{let t=(0,v.c)(9),n=At(),r=q(Rt);if(!n&&e.isStreaming!==!0){let n;return t[0]===e?n=t[1]:(n=(0,Z.jsx)(Q,{...e,animated:!1,reserveMeasuredHeight:!0}),t[0]=e,t[1]=n),n}let i;t[2]===e?i=t[3]:(i=(0,Z.jsx)(_.Suspense,{fallback:(0,Z.jsx)(Q,{...e,reserveMeasuredHeight:!0}),children:(0,Z.jsx)(jt,{...e})}),t[2]=e,t[3]=i);let a=i;if(!r)return a;let o;t[4]===e?o=t[5]:(o=(0,Z.jsx)(_.Suspense,{fallback:(0,Z.jsx)(Q,{...e,reserveMeasuredHeight:!0}),children:(0,Z.jsx)(Mt,{...e})}),t[4]=e,t[5]=o);let s;return t[6]!==a||t[7]!==o?(s=(0,Z.jsx)(Ot,{fallback:a,children:o}),t[6]=a,t[7]=o,t[8]=s):s=t[8],s},It=e=>{let t=(0,v.c)(4);if(!At()){let n;return t[0]===e?n=t[1]:(n=(0,Z.jsx)(Q,{...e,animated:!1}),t[0]=e,t[1]=n),n}let n;return t[2]===e?n=t[3]:(n=(0,Z.jsx)(_.Suspense,{fallback:(0,Z.jsx)(Q,{...e}),children:(0,Z.jsx)(Nt,{...e})}),t[2]=e,t[3]=n),n};function Lt(e){return e.markstreamReactEnabled}function Rt(e){return e.markstreamReactEnabled}var zt=e=>/^#[0-9a-fA-F]{6}$/.test(e),Bt=e=>/^#[0-9a-fA-F]{8}$/.test(e),Vt=(e,t)=>/^[0-9a-fA-F]{2}$/.test(t)?zt(e)?`${e}${t}`:Bt(e)?`${e.slice(0,7)}${t}`:e:e,$=(e,t)=>typeof e==`string`&&e.trim().length>0?e:t,Ht=e=>{let t=e.colors.syntax.base,n=e.colors.syntax.tokens??{},r=(e,t)=>$(n[e],t);return[{name:`plain`,scope:[`source`,`support.type.property-name.css`],settings:{foreground:t.foreground}},{name:`classes`,scope:[`entity.name.type.class`],settings:{foreground:r(`className`,r(`class`,t.function))}},{name:`interfaces`,scope:[`entity.name.type.interface`,`entity.name.type`],settings:{foreground:r(`interface`,t.type)}},{name:`structs`,scope:[`entity.name.type.struct`],settings:{foreground:r(`struct`,t.function)}},{name:`enums`,scope:[`entity.name.type.enum`],settings:{foreground:r(`enum`,t.function)}},{name:`keys`,scope:[`meta.object-literal.key`,`support.type.property-name`],settings:{foreground:r(`key`,t.function)}},{name:`methods`,scope:[`entity.name.function.method`,`meta.function.method`],settings:{foreground:r(`method`,e.colors.status.success)}},{name:`functions`,scope:[`entity.name.function`,`support.function`,`meta.function-call.generic`],settings:{foreground:t.function,fontStyle:`bold`}},{name:`variables`,scope:[`variable`,`meta.variable`,`variable.other.object.property`],settings:{foreground:t.variable}},{name:`variablesOther`,scope:[`variable.other.object`,`variable.other.readwrite.alias`],settings:{foreground:r(`variableOther`,r(`method`,e.colors.status.success))}},{name:`globalVariables`,scope:[`variable.other.global`,`variable.language.this`],settings:{foreground:r(`variableGlobal`,t.number)}},{name:`localVariables`,scope:[`variable.other.local`],settings:{foreground:r(`variableLocal`,e.colors.surface.elevated)}},{name:`parameters`,scope:[`variable.parameter`,`meta.parameter`],settings:{foreground:r(`parameter`,t.foreground)}},{name:`properties`,scope:[`variable.other.property`,`meta.property`],settings:{foreground:r(`variableProperty`,e.colors.status.info)}},{name:`strings`,scope:[`string`,`string.other.link`,`markup.inline.raw.string.markdown`],settings:{foreground:t.string}},{name:`stringEscapeSequences`,scope:[`constant.character.escape`,`constant.other.placeholder`],settings:{foreground:r(`stringEscape`,t.foreground)}},{name:`keywords`,scope:[`keyword`],settings:{foreground:t.keyword}},{name:`keywordsControl`,scope:[`keyword.control.import`,`keyword.control.from`,`keyword.import`],settings:{foreground:r(`keywordImport`,t.operator)}},{name:`storageModifiers`,scope:[`storage.modifier`,`keyword.modifier`,`storage.type`],settings:{foreground:r(`storageModifier`,t.keyword)}},{name:`comments`,scope:[`comment`,`punctuation.definition.comment`],settings:{foreground:t.comment}},{name:`docComments`,scope:[`comment.documentation`,`comment.line.documentation`],settings:{foreground:r(`commentDoc`,e.colors.surface.mutedForeground)}},{name:`numbers`,scope:[`constant.numeric`],settings:{foreground:t.number}},{name:`booleans`,scope:[`constant.language`],settings:{foreground:r(`boolean`,t.type)}},{name:`operators`,scope:[`keyword.operator`],settings:{foreground:t.operator}},{name:`macros`,scope:[`entity.name.function.preprocessor`,`meta.preprocessor`],settings:{foreground:r(`macro`,t.keyword)}},{name:`preprocessor`,scope:[`meta.preprocessor`],settings:{foreground:r(`preprocessor`,r(`label`,t.number))}},{name:`urls`,scope:[`markup.underline.link`],settings:{foreground:r(`url`,e.colors.status.info)}},{name:`tags`,scope:[`entity.name.tag`],settings:{foreground:r(`tag`,t.keyword)}},{name:`jsxTags`,scope:[`support.class.component`],settings:{foreground:r(`jsxTag`,r(`label`,t.number))}},{name:`attributes`,scope:[`entity.other.attribute-name`,`meta.attribute`],settings:{foreground:r(`tagAttribute`,t.type)}},{name:`types`,scope:[`support.type`],settings:{foreground:t.type}},{name:`constants`,scope:[`variable.other.constant`,`variable.readonly`],settings:{foreground:r(`constant`,t.foreground)}},{name:`labels`,scope:[`entity.name.label`,`punctuation.definition.label`],settings:{foreground:r(`label`,r(`variableGlobal`,t.number))}},{name:`namespaces`,scope:[`entity.name.namespace`,`storage.modifier.namespace`,`markup.bold.markdown`],settings:{foreground:r(`namespace`,t.type)}},{name:`modules`,scope:[`entity.name.module`,`storage.modifier.module`],settings:{foreground:r(`module`,t.operator)}},{name:`typeParameters`,scope:[`variable.type.parameter`,`variable.parameter.type`],settings:{foreground:r(`typeParameter`,t.function)}},{name:`exceptions`,scope:[`keyword.control.exception`,`keyword.control.trycatch`],settings:{foreground:r(`exception`,r(`label`,t.number))}},{name:`decorators`,scope:[`meta.decorator`,`punctuation.decorator`,`entity.name.function.decorator`],settings:{foreground:r(`decorator`,t.type)}},{name:`calls`,scope:[`variable.function`],settings:{foreground:t.foreground}},{name:`punctuation`,scope:[`punctuation`,`punctuation.terminator`,`punctuation.definition.tag`,`punctuation.separator`,`punctuation.definition.string`,`punctuation.section.block`],settings:{foreground:r(`punctuation`,t.comment)}},{name:`yellow`,scope:[`storage.type.numeric.go`,`storage.type.byte.go`,`storage.type.boolean.go`,`storage.type.string.go`,`storage.type.uintptr.go`,`storage.type.error.go`,`storage.type.rune.go`,`constant.language.go`,`support.class.dart`,`keyword.other.documentation`,`storage.modifier.import.java`,`punctuation.definition.list.begin.markdown`,`punctuation.definition.quote.begin.markdown`,`meta.separator.markdown`,`entity.name.section.markdown`],settings:{foreground:t.type}},{name:`green`,scope:[],settings:{foreground:r(`method`,e.colors.status.success)}},{name:`cyan`,scope:[`markup.italic.markdown`,`support.type.python`,`variable.legacy.builtin.python`,`support.constant.property-value.css`,`storage.modifier.attribute.swift`],settings:{foreground:t.string}},{name:`blue`,scope:[],settings:{foreground:t.keyword}},{name:`purple`,scope:[`keyword.channel.go`,`keyword.other.platform.os.swift`],settings:{foreground:t.number}},{name:`magenta`,scope:[`punctuation.definition.heading.markdown`],settings:{foreground:r(`label`,r(`variableGlobal`,t.number))}},{name:`red`,scope:[],settings:{foreground:t.operator}},{name:`orange`,scope:[],settings:{foreground:t.function}}]},Ut=e=>{let t=e.colors.surface,n=e.colors.interactive,r=e.colors.status,i=e.colors.syntax.base,a=e.colors.syntax.highlights??{},o=$(a.diffAddedBackground,r.successBackground),s=$(a.diffRemovedBackground,r.errorBackground);return{"editor.background":t.background,"editor.foreground":t.foreground,"editor.hoverHighlightBackground":$(n.hover,t.subtle),"editor.lineHighlightBackground":t.muted,"editor.selectionBackground":n.selection,"editor.selectionHighlightBackground":n.selection,"editor.findMatchBackground":i.type,"editor.findMatchHighlightBackground":Vt(i.type,`cc`),"editor.findRangeHighlightBackground":t.muted,"editor.inactiveSelectionBackground":t.elevated,"editor.lineHighlightBorder":t.elevated,"editor.rangeHighlightBackground":$(n.active,n.borderHover),"notifications.background":t.elevated,"editorInlayHint.typeBackground":t.subtle,"editorInlayHint.typeForeground":t.foreground,"editorWhitespace.foreground":n.borderHover,"editorIndentGuide.background1":t.subtle,"editorHoverWidget.background":t.elevated,"editorLineNumber.activeForeground":$(a.lineNumberActive,t.foreground),"editorLineNumber.foreground":$(a.lineNumber,t.mutedForeground),"editorGutter.background":t.background,"editorGutter.modifiedBackground":r.info,"editorGutter.addedBackground":r.success,"editorGutter.deletedBackground":r.error,"editorBracketMatch.background":t.elevated,"editorBracketMatch.border":t.subtle,"editorError.foreground":r.error,"editorWarning.foreground":r.warning,"editorInfo.foreground":r.info,"diffEditor.insertedTextBackground":o,"diffEditor.removedTextBackground":s,"editorGroupHeader.tabsBackground":t.background,"editorGroup.border":n.border,"tab.activeBackground":t.background,"tab.inactiveBackground":t.muted,"tab.inactiveForeground":t.mutedForeground,"tab.activeForeground":t.foreground,"tab.hoverBackground":t.subtle,"tab.unfocusedHoverBackground":t.subtle,"tab.border":n.border,"tab.activeModifiedBorder":i.type,"tab.inactiveModifiedBorder":r.info,"tab.unfocusedActiveModifiedBorder":i.type,"tab.unfocusedInactiveModifiedBorder":r.info,"editorWidget.background":t.muted,"editorWidget.border":n.border,"editorSuggestWidget.background":t.background,"editorSuggestWidget.border":n.border,"editorSuggestWidget.foreground":t.foreground,"editorSuggestWidget.highlightForeground":t.mutedForeground,"editorSuggestWidget.selectedBackground":t.subtle,"peekView.border":n.border,"peekViewEditor.background":t.background,"peekViewEditor.matchHighlightBackground":t.subtle,"peekViewResult.background":t.muted,"peekViewResult.fileForeground":t.foreground,"peekViewResult.lineForeground":t.mutedForeground,"peekViewResult.matchHighlightBackground":t.subtle,"peekViewResult.selectionBackground":t.elevated,"peekViewResult.selectionForeground":t.mutedForeground,"peekViewTitle.background":t.subtle,"peekViewTitleDescription.foreground":t.mutedForeground,"peekViewTitleLabel.foreground":t.foreground,"merge.currentHeaderBackground":r.success,"merge.currentContentBackground":$(a.diffAdded,r.success),"merge.incomingHeaderBackground":r.info,"merge.incomingContentBackground":$(a.diffModified,r.info),"merge.border":n.border,"merge.commonContentBackground":t.subtle,"merge.commonHeaderBackground":t.muted,"panel.background":t.background,"panel.border":n.border,"panelTitle.activeBorder":n.borderHover,"panelTitle.activeForeground":t.foreground,"panelTitle.inactiveForeground":t.mutedForeground,"statusBar.background":t.background,"statusBar.foreground":t.foreground,"statusBar.border":n.border,"statusBar.debuggingBackground":r.error,"statusBar.debuggingForeground":r.errorForeground,"statusBar.noFolderBackground":t.subtle,"statusBar.noFolderForeground":t.mutedForeground,"titleBar.activeBackground":t.background,"titleBar.activeForeground":t.foreground,"titleBar.inactiveBackground":t.muted,"titleBar.inactiveForeground":t.mutedForeground,"titleBar.border":n.border,"menu.foreground":t.foreground,"menu.background":t.background,"menu.selectionForeground":t.foreground,"menu.selectionBackground":t.subtle,"menu.border":n.border,"editorInlayHint.foreground":t.mutedForeground,"editorInlayHint.background":t.subtle,"terminal.foreground":t.foreground,"terminal.background":t.background,"terminalCursor.foreground":t.foreground,"terminalCursor.background":t.background,"terminal.ansiRed":$(a.diffRemoved,r.error),"terminal.ansiGreen":$(a.diffAdded,r.success),"terminal.ansiYellow":r.warning,"terminal.ansiBlue":$(a.diffModified,r.info),"terminal.ansiMagenta":i.keyword,"terminal.ansiCyan":i.type,"activityBar.background":t.background,"activityBar.foreground":t.foreground,"activityBar.inactiveForeground":t.mutedForeground,"activityBar.activeBorder":t.foreground,"activityBar.border":n.border,"sideBar.background":t.background,"sideBar.foreground":t.foreground,"sideBar.border":n.border,"sideBarTitle.foreground":t.foreground,"sideBarSectionHeader.background":t.muted,"sideBarSectionHeader.foreground":t.foreground,"sideBarSectionHeader.border":n.border,"sideBar.activeBackground":t.subtle,"sideBar.activeForeground":t.foreground,"sideBar.hoverBackground":t.muted,"sideBar.hoverForeground":t.foreground,"list.warningForeground":r.warning,"list.errorForeground":r.error,"list.inactiveSelectionBackground":t.subtle,"list.activeSelectionBackground":t.elevated,"list.inactiveSelectionForeground":t.foreground,"list.activeSelectionForeground":t.foreground,"list.hoverForeground":t.foreground,"list.hoverBackground":t.muted,"input.background":t.muted,"input.foreground":t.foreground,"input.border":n.border,"input.placeholderForeground":t.mutedForeground,"inputOption.activeBorder":n.border,"inputOption.activeBackground":t.elevated,"inputOption.activeForeground":t.foreground,"inputValidation.infoBackground":r.infoBackground,"inputValidation.infoBorder":r.infoBorder,"inputValidation.warningBackground":r.warningBackground,"inputValidation.warningBorder":r.warningBorder,"inputValidation.errorBackground":r.errorBackground,"inputValidation.errorBorder":r.errorBorder,"dropdown.background":t.muted,"dropdown.foreground":t.foreground,"dropdown.border":n.border,"dropdown.listBackground":t.background,"badge.background":e.colors.primary.base,"activityBarBadge.background":e.colors.primary.base,"button.background":e.colors.primary.base,"button.foreground":$(e.colors.primary.foreground,t.background),"badge.foreground":$(e.colors.primary.foreground,t.background),"activityBarBadge.foreground":$(e.colors.primary.foreground,t.background)}};function Wt(e){return{name:e.metadata.name,type:e.metadata.variant,colors:Ut(e),tokenColors:Ht(e)}}var Gt=e=>/^#[0-9a-fA-F]{8}$/.test(e),Kt=e=>Gt(e)?e.slice(0,7):e;function qt(e,t){return Object.defineProperty(e,"toString",{value:()=>t,enumerable:!1,configurable:!0}),Object.defineProperty(e,Symbol.toPrimitive,{value:()=>t,enumerable:!1,configurable:!0}),e}var Jt=new Map,Yt=new Set,Xt=(e,t)=>{let n=e.colors?.[`editor.background`],r=e.colors?.[`editor.foreground`],i=n?Kt(n):void 0,a=r?Kt(r):void 0;if(!i||!a)throw Error(`Theme "${t}" is missing editor.background/editor.foreground`);let o=e.tokenColors??[];return qt({...e,name:t,fg:a,bg:i,settings:o},t)},Zt=e=>Wt(e),Qt=e=>{let t=Jt.get(e.metadata.id);if(t)return t;let n=Xt(Zt(e),e.metadata.id);return Jt.set(e.metadata.id,n),n},$t=e=>{let t=e.metadata.id;if(Yt.has(t))return;let n=Qt(e);u(t,async()=>n),Yt.add(t)};export{Ve as A,A as C,he as D,xe as E,Ne as F,oe as I,ie as L,be as M,Me as N,ye as O,E as P,ae as R,Fe as S,k as T,Ee as _,kt as a,ue as b,H as c,z as d,qe as f,De as g,_e as h,It as i,je as j,Be as k,tt as l,ve as m,Qt as n,Dt as o,P as p,Ft as r,q as s,$t as t,ct as u,Ie as v,Te as w,He as x,me as y,b as z};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{f as t,g as n,p as r}from"./desktop-CfLlmafK.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-DzpbXWX1.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{r as e,t}from"./runtime-switch-BkpTTbEi.js";var n=[`local`,`remote`,null],r=[`ok`,`not-configured`,`unreachable`,`incompatible`,`wrong-service`,`missing`];function i(e){if(!e||typeof e!=`object`)return{valid:!1};let t=e,i=t.target,a=t.status;if(i!==null&&(typeof i!=`string`||!n.includes(i))||typeof a!=`string`||!r.includes(a))return{valid:!1};if(i===`remote`||i===`local`){if(a===`ok`&&i===`local`)return{valid:!0,outcome:{target:`local`,status:`ok`}};if(a===`ok`&&i===`remote`)return typeof t.hostId!=`string`||typeof t.url!=`string`?{valid:!1}:{valid:!0,outcome:{target:`remote`,status:`ok`,hostId:t.hostId,url:t.url}};if(a===`unreachable`)return i===`local`?{valid:!0,outcome:{target:`local`,status:`unreachable`}}:typeof t.hostId!=`string`||typeof t.url!=`string`?{valid:!1}:{valid:!0,outcome:{target:`remote`,status:`unreachable`,hostId:t.hostId,url:t.url}};if(a===`incompatible`||a===`wrong-service`)return i!==`remote`||typeof t.hostId!=`string`||typeof t.url!=`string`?{valid:!1}:{valid:!0,outcome:{target:`remote`,status:a,hostId:t.hostId,url:t.url}};if(a===`missing`)return i!==`remote`||typeof t.hostId!=`string`?{valid:!1}:{valid:!0,outcome:{target:`remote`,status:`missing`,hostId:t.hostId}}}if(i===null){if(a===`not-configured`)return{valid:!0,outcome:{target:null,status:`not-configured`}};if(a===`missing`)return{valid:!1}}return{valid:!1}}function a(e){if(!e.isDesktopShell)return null;let t=e.bootOutcome;if(!t)return null;if(t.status===`ok`){if(t.target===`local`)return{screen:`main`};if(t.target===`remote`)return{screen:`main`,hostId:t.hostId,url:t.url}}if(t.target===null&&t.status===`not-configured`)return{screen:`chooser`};if(t.target===`local`&&t.status===`unreachable`)return{screen:`recovery`,variant:`local-unavailable`};if(t.target===`remote`){if(t.status===`unreachable`)return{screen:`recovery`,variant:`remote-unreachable`,hostId:t.hostId,url:t.url};if(t.status===`incompatible`)return{screen:`recovery`,variant:`remote-incompatible`,hostId:t.hostId,url:t.url};if(t.status===`wrong-service`)return{screen:`recovery`,variant:`remote-wrong-service`,hostId:t.hostId,url:t.url};if(t.status===`missing`)return{screen:`recovery`,variant:`remote-missing`,hostId:t.hostId}}return null}function o(e){return e.isDesktopShell?e.bootOutcomeKnown?e.bootViewIsMain===!1||e.isInitialized:!1:e.isInitialized}function s(e){return e.isDesktopShell&&!e.isDesktopLocalOriginActive}function c(){if(u()!==`valid`)return null;let e=i(l());return e.valid?e.outcome:null}var l=()=>{if(typeof window>`u`)return;let e=window.__OPENCHAMBER_DESKTOP_BOOT_OUTCOME__;if(e!=null)return e;let t=window.__OPENCHAMBER_DESKTOP_BOOT__;if(t&&typeof t.getOutcome==`function`)try{return t.getOutcome()}catch{return}return e};function u(){if(typeof window>`u`)return`not-injected`;let e=l();return e==null?`not-injected`:i(e).valid?`valid`:`malformed`}var d=null,f=e=>{d=e},p=()=>d||(typeof window>`u`?null:window.__OPENCHAMBER_RUNTIME_APIS__??null),m=()=>typeof window>`u`?null:window.__OPENCHAMBER_ELECTRON__??null,h=()=>typeof window>`u`?null:window.__OPENCHAMBER_DESKTOP__??null,g=()=>m()?.runtime===`electron`,_=()=>g()&&m()?.packaged===!0,v=e=>{if(!g())return null;let t=h()?.getPathForFile?.(e);return typeof t==`string`&&t.trim()?t:null},y=()=>{if(typeof window>`u`)return null;let e=window.__OPENCHAMBER_PLATFORM__;return typeof e==`string`?e:null},b=()=>{if(!g())return!1;let e=y();return e===`win32`||e===`linux`},x=(e=y())=>e===`linux`?`left`:`right`,S=(e,t=y())=>e===`left`||e===`right`?e:x(t),C=()=>typeof h()?.invoke==`function`,w=()=>g()&&C(),T=async(e,t)=>{let n=h();return typeof n?.invoke==`function`?n.invoke(e,t??{}):null},E=async()=>{if(!w()||!F())return null;try{let e=await T(`desktop_get_launch_at_login`);return!e||typeof e.supported!=`boolean`||typeof e.enabled!=`boolean`?null:e}catch(e){return console.warn(`Failed to get launch at login status`,e),null}},D=async e=>{if(!w()||!F())return null;try{let t=await T(`desktop_set_launch_at_login`,{enabled:e});return!t||typeof t.supported!=`boolean`||typeof t.enabled!=`boolean`?null:t}catch(e){return console.warn(`Failed to set launch at login status`,e),null}},O=async()=>{if(!w()||!F())return null;try{let e=await T(`desktop_get_minimize_to_tray`);return!e||typeof e.supported!=`boolean`||typeof e.enabled!=`boolean`?null:e}catch(e){return console.warn(`Failed to get minimize to tray status`,e),null}},ee=async e=>{if(!w()||!F())return null;try{let t=await T(`desktop_set_minimize_to_tray`,{enabled:e});return!t||typeof t.supported!=`boolean`||typeof t.enabled!=`boolean`?null:t}catch(e){return console.warn(`Failed to set minimize to tray status`,e),null}},k=async()=>{if(!w()||!F())return null;try{let e=await T(`desktop_get_keep_awake`);return!e||typeof e.supported!=`boolean`||typeof e.enabled!=`boolean`||typeof e.active!=`boolean`?null:e}catch(e){return console.warn(`Failed to get keep awake status`,e),null}},A=async e=>{if(!w()||!F())return null;try{let t=await T(`desktop_set_keep_awake`,{enabled:e});return!t||typeof t.supported!=`boolean`||typeof t.enabled!=`boolean`||typeof t.active!=`boolean`?null:t}catch(e){return console.warn(`Failed to set keep awake status`,e),null}},j=e=>{let t=e.trim();if(!t)return null;try{return new URL(t).origin}catch{try{return new URL(t.endsWith(`/`)?t:`${t}/`).origin}catch{return null}}},M=e=>{let t=e.trim();if(!t)return null;try{return new URL(t)}catch{try{return new URL(t.endsWith(`/`)?t:`${t}/`)}catch{return null}}},N=e=>e.replace(/^\[|\]$/g,``).toLowerCase(),P=e=>{let t=N(e);return t===`localhost`||t===`127.0.0.1`||t===`::1`},F=()=>{if(typeof window>`u`||!I())return!1;if(e()===`local`)return!0;let n=typeof window.__OPENCHAMBER_LOCAL_ORIGIN__==`string`?window.__OPENCHAMBER_LOCAL_ORIGIN__:``,r=M(n),i=M(t());if(!i&&r&&c()?.target===`local`)return!0;if(r&&i){if(r.origin===i.origin)return!0;let e=r.port||(r.protocol===`https:`?`443`:`80`),t=i.port||(i.protocol===`https:`?`443`:`80`);return r.protocol===i.protocol&&e===t&&P(r.hostname)&&P(i.hostname)}let a=M(window.location.origin);if(r&&a){if(r.origin===a.origin)return!0;let e=r.port||(r.protocol===`https:`?`443`:`80`),t=a.port||(a.protocol===`https:`?`443`:`80`);return r.protocol===a.protocol&&e===t&&P(r.hostname)&&P(a.hostname)}let o=j(n),s=j(window.location.origin)||window.location.origin;return o&&s&&o===s?!0:!!(a&&P(a.hostname))},I=()=>typeof window>`u`?!1:g(),L=async()=>{if(!I())return!1;try{return await T(`desktop_start_window_drag`),!0}catch{return!1}},R=()=>p()?.runtime?.isVSCode===!0,z=()=>{let e=p()?.runtime?.platform;return e===`web`?!0:e===`desktop`||e===`vscode`?!1:!R()},B=async()=>{if(typeof window<`u`){let e=window.__OPENCHAMBER_HOME__;if(e&&e.length>0)return e}return null},V=async e=>{if(C()&&F())try{let e=await h()?.openDialog?.({directory:!0,multiple:!1,title:`Select Working Directory`});return!e||typeof e!=`string`?{success:!1,error:`Directory selection cancelled`}:{success:!0,path:e}}catch(e){return console.warn(`Failed to request directory access`,e),{success:!1,error:e instanceof Error?e.message:String(e)}}return{success:!0,path:e}},H=e=>typeof e==`object`&&!!e&&!Array.isArray(e),U=async e=>{if(C()&&F())try{let t=await h()?.openDialog?.({directory:!1,multiple:!1,title:`Select File`,returnGrant:!0,...e?.filters?{filters:e.filters}:{},...e?.defaultPath?{defaultPath:e.defaultPath}:{}});if(!t)return{success:!1,error:`File selection cancelled`};if(typeof t==`string`)return{success:!0,path:t};if(!H(t))return{success:!1,error:`File selection cancelled`};let n=typeof t.path==`string`?t.path:``;return n?{success:!0,path:n,outsideFileGrant:typeof t.outsideFileGrant==`string`?t.outsideFileGrant:void 0}:{success:!1,error:`File selection cancelled`}}catch(e){return console.warn(`Failed to request file access`,e),{success:!1,error:e instanceof Error?e.message:String(e)}}return{success:!1,error:`Native file picker not available`}},W=async e=>{let t=typeof e==`string`?e.trim():``;if(!t)return{success:!1,error:`Path is required`};if(!C()||!F())return{success:!1,error:`Native file access not available`};try{let e=await h()?.grantFileAccess?.(t);if(!H(e))return{success:!1,error:`File access was not granted`};let n=typeof e.path==`string`?e.path:``,r=typeof e.outsideFileGrant==`string`?e.outsideFileGrant:``;return!n||!r?{success:!1,error:`File access was not granted`}:{success:!0,path:n,outsideFileGrant:r}}catch(e){return console.warn(`Failed to request existing file access`,e),{success:!1,error:e instanceof Error?e.message:String(e)}}},G=async e=>({success:!0}),K=async e=>({success:!0}),q=async()=>{if(!C())throw Error(`Desktop update checker is unavailable`);let e=await T(`desktop_check_for_updates`);if(!e)throw Error(`Desktop update checker returned no result`);return e},J=async e=>{let t=h();return typeof t?.listen==`function`?t.listen(`openchamber:update-progress`,t=>{let n=t?.payload;if(!n||typeof n!=`object`)return;let r=n;e({event:typeof r.event==`string`?r.event:void 0,data:r.data&&typeof r.data==`object`?r.data:void 0})}):null},Y=async e=>{let t=h();return typeof t?.listen==`function`?t.listen(`openchamber:update-ready`,t=>{let n=t?.payload;if(!n||typeof n!=`object`)return;let r=n;e({version:typeof r.version==`string`?r.version:null,downloaded:r.downloaded===!0})}):null},X=async e=>{if(!C())return!1;let t=h(),n=null,r=0,i;try{return typeof e==`function`&&t?.listen&&(n=await t.listen(`openchamber:update-progress`,t=>{let n=t?.payload;if(!n||typeof n!=`object`)return;let a=n,o=typeof a.event==`string`?a.event:null,s=a.data&&typeof a.data==`object`?a.data:null;if(o===`Started`){r=0,i=typeof s?.contentLength==`number`?s.contentLength:void 0,e({downloaded:r,total:i});return}if(o===`Progress`){let t=s?.downloaded,n=s?.total;typeof t==`number`&&(r=t),typeof n==`number`&&(i=n),e({downloaded:r,total:i});return}o===`Finished`&&e({downloaded:r,total:i})})),await T(`desktop_download_and_install_update`),!0}catch(e){throw e instanceof Error?e:Error(String(e))}finally{if(n)try{let e=n();e instanceof Promise&&await e}catch{}}},Z=async()=>C()?Q({applyUpdate:!0}):!1,Q=async({applyUpdate:e=!1}={})=>{if(!C())return!1;try{return await T(`desktop_restart`,e?{applyUpdate:!0}:void 0),!0}catch(e){return console.warn(`Failed to restart desktop app`,e),!1}},te=async()=>{if(!C()||!F())return null;try{let e=await T(`desktop_get_lan_address`);return typeof e==`string`&&e.trim().length>0?e.trim():null}catch(e){return console.warn(`Failed to get desktop LAN address`,e),null}},$=async(e,t)=>{if(!C()||!F())return!1;let n=e?.trim();if(!n)return!1;try{return await T(`desktop_open_path`,{path:n,app:typeof t==`string`&&t.trim().length>0?t.trim():void 0}),!0}catch(e){return console.warn(`Failed to open path`,e),!1}},ne=async e=>{if(!C()||!F())return null;let t=e?.trim();if(!t)return null;try{let e=await T(`desktop_is_binary_path`,{path:t});return typeof e==`boolean`?e:null}catch{return null}},re=async e=>{if(!C()||!F())return!1;let t=e?.trim();if(!t)return!1;try{return await T(`desktop_reveal_path`,{path:t}),!0}catch{return $(t)}},ie=async(e,t)=>{if(!C()||!F())return null;let n=e?.trim();if(!n)return null;try{let e=await T(`desktop_save_markdown_file`,{defaultFileName:n,content:t});return typeof e==`string`&&e.trim().length>0?e:null}catch(e){return console.warn(`Failed to save markdown file`,e),null}},ae=async(e,t,n)=>{if(!C()||!F())return!1;let r=e?.trim(),i=t?.trim(),a=n?.trim();if(!r||!i||!a)return!1;try{return await T(`desktop_open_in_app`,{projectPath:r,appId:i,appName:a}),!0}catch(e){return console.warn(`Failed to open project in app`,e),!1}},oe=async(e,t,n)=>{if(!C()||!F())return!1;let r=e?.trim(),i=t?.trim(),a=n?.trim();if(!r||!i||!a)return!1;try{return await T(`desktop_open_file_in_app`,{filePath:r,appId:i,appName:a}),!0}catch(e){return console.warn(`Failed to open file in app`,e),!1}},se=async(e,t)=>{if(!C()||!F())return{apps:[],success:!1,hasCache:!1,isCacheStale:!1};if(y()===`linux`)return{apps:[],success:!0,hasCache:!1,isCacheStale:!1};let n=Array.isArray(e)?e.filter(e=>typeof e==`string`):[];if(n.length===0)return{apps:[],success:!0,hasCache:!1,isCacheStale:!1};try{let e=await T(`desktop_get_installed_apps`,{apps:n,force:t===!0||void 0});if(!e||typeof e!=`object`)return{apps:[],success:!1,hasCache:!1,isCacheStale:!1};let r=e;return r.supported===!1?{apps:[],success:!0,hasCache:!1,isCacheStale:!1}:Array.isArray(r.apps)?{apps:r.apps.filter(e=>e&&typeof e==`object`).map(e=>{let t=e;return{name:typeof t.name==`string`?t.name:``,iconDataUrl:typeof t.iconDataUrl==`string`?t.iconDataUrl:null}}).filter(e=>e.name.length>0),success:!0,hasCache:r.hasCache===!0,isCacheStale:r.isCacheStale===!0}:{apps:[],success:!1,hasCache:!1,isCacheStale:!1}}catch(e){return console.warn(`Failed to fetch installed apps`,e),{apps:[],success:!1,hasCache:!1,isCacheStale:!1}}};export{Q as A,b as B,oe as C,W as D,V as E,D as F,c as G,f as H,ee as I,a as K,G as L,re as M,ie as N,U as O,A as P,L as R,Y as S,ae as T,o as U,p as V,u as W,g as _,B as a,z as b,E as c,y as d,C as f,I as g,F as h,se as i,Z as j,S as k,O as l,ne as m,q as n,k as o,T as p,s as q,X as r,te as s,w as t,v as u,_ as v,$ as w,J as x,R as y,K as z};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{A as e}from"./runtime-switch-BkpTTbEi.js";import{f as t,p as n}from"./desktop-CfLlmafK.js";var r=e=>typeof e==`object`&&!!e,i=e=>e.trim().toLowerCase()===`authorization`,a=e=>{if(!r(e))return;let t={};for(let[n,r]of Object.entries(e)){let e=n.trim(),a=typeof r==`string`?r.trim():``;!e||!a||/[\r\n:]/.test(e)||/[\r\n]/.test(a)||i(e)||(t[e]=a)}return Object.keys(t).length>0?t:void 0},o=`connect-link`,s=(e,t)=>e.source===`connect-link`||e.relay?!0:t.has(e.id),c=(e,t)=>!t.has(e.id)&&s(e,t),l=e=>`relay://${e}`,u=e=>{if(!r(e))return null;let t=g(e,`relayUrl`)||g(e,`relay_url`),n=g(e,`serverId`)||g(e,`server_id`),i=e.hostEncPubJwk??e.host_enc_pub_jwk;return!t||!n||!r(i)?null:{relayUrl:t,serverId:n,hostEncPubJwk:i}},d=/^(t|.*(?:token|auth|secret|api).*)$/i,f=e=>{let t=e.trim();if(!t)return null;try{let e=new URL(t);return e.protocol!==`http:`&&e.protocol!==`https:`?null:t.split(`#`)[0]||null}catch{return null}},p=e=>{let t=f(e);if(!t)return null;try{let e=new URL(t);if((e.pathname.replace(/\/+$/,``)||`/`)===`/connect`&&e.searchParams.has(`t`))return{persistedUrl:e.origin,redeemUrl:e.toString(),kind:`tunnel-connect-link`}}catch{return null}return{persistedUrl:t,redeemUrl:null,kind:`normal-host`}},m=e=>{let t=f(e);if(!t)return e;try{let e=new URL(t);(e.username||e.password)&&(e.username=``,e.password=``);let n=Array.from(new Set(Array.from(e.searchParams.keys())));for(let t of n)d.test(t)&&e.searchParams.set(t,`[REDACTED]`);return e.toString()}catch{return t}},h=(e,t)=>{let n=f(e),r=f(t);if(!n||!r)return!1;try{let e=new URL(n),t=new URL(r);if(e.origin!==t.origin||t.search&&e.search!==t.search)return!1;let i=t.pathname.length>1?t.pathname.replace(/\/+$/,``):t.pathname,a=e.pathname.length>1?e.pathname.replace(/\/+$/,``):e.pathname;return i===`/`||a===i||a.startsWith(`${i}/`)}catch{return!1}},g=(e,t)=>{let n=e[t];return typeof n==`string`?n:null},_=(e,t)=>{let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:null},v=e=>{if(!r(e))return null;let t=g(e,`id`),n=g(e,`label`),i=g(e,`url`),s=g(e,`apiUrl`)||g(e,`api_url`),c=g(e,`clientToken`)||g(e,`client_token`),l=a(e.requestHeaders),d=u(e.relay),f=g(e,`source`)===`connect-link`?o:void 0;return!t||!n||!i&&!d?null:{id:t,label:n,url:i||``,...s?{apiUrl:s}:{},...c?{clientToken:c}:{},...l?{requestHeaders:l}:{},...d?{relay:d}:{},...f?{source:f}:{}}},y=e=>f(e.apiUrl||e.url)||e.apiUrl||e.url,b=()=>t()?(e,t)=>n(e,t):null,x=async()=>{let e=b();if(!e)return{hosts:[],defaultHostId:null,initialHostChoiceCompleted:!1};let t=await e(`desktop_hosts_get`);if(!r(t))return{hosts:[],defaultHostId:null,initialHostChoiceCompleted:!1};let n=t.hosts;return{hosts:Array.isArray(n)?n.map(v).filter(e=>!!e):[],defaultHostId:g(t,`defaultHostId`)||g(t,`default_host_id`)||g(t,`defaultHostID`),initialHostChoiceCompleted:t.initialHostChoiceCompleted===!0||t.initial_host_choice_completed===!0,localOrigin:g(t,`localOrigin`)||g(t,`local_origin`)}},S=async e=>{let t=b();if(!t)return;let n={hosts:e.hosts,defaultHostId:e.defaultHostId,initialHostChoiceCompleted:e.initialHostChoiceCompleted};e.localClientToken!==void 0&&(n.localClientToken=e.localClientToken),await t(`desktop_hosts_set`,{input:n})},C=async()=>{let e=b();if(!e)return``;let t=await e(`desktop_local_client_token_get`).catch(()=>null);return typeof t==`string`?t.trim():``},w=async()=>{let e=b();if(!e)return``;let t=await e(`desktop_install_id_get`).catch(()=>null);return typeof t==`string`?t.trim():``},T=8e3,E=async(t,n)=>{let r=e({relayUrl:t.relayUrl,serverId:t.serverId,hostEncPubJwk:t.hostEncPubJwk}),i=Date.now(),a=!1;try{return(await Promise.race([r.fetch(`/health`),new Promise(e=>{let t=window.setTimeout(()=>e(null),T);typeof t!=`number`&&typeof t.unref==`function`&&t.unref()})]))?.ok?(a=n?.keepTunnel===!0,{status:`ok`,latencyMs:Math.max(0,Date.now()-i),...a?{tunnel:r}:{}}):{status:`unreachable`,latencyMs:0}}catch{return{status:`unreachable`,latencyMs:0}}finally{a||r.close()}},D=async(e,t)=>{let n=b();if(!n)return{status:`unreachable`,latencyMs:0};let i=await n(`desktop_host_probe`,{url:e,clientToken:t?.clientToken||void 0,requestHeaders:t?.requestHeaders||void 0,expectedServerId:t?.expectedServerId||void 0});if(!r(i))return{status:`unreachable`,latencyMs:0};let a=i.status;return{status:a===`ok`||a===`auth`||a===`update-recommended`||a===`incompatible`||a===`wrong-service`||a===`unreachable`?a:`unreachable`,latencyMs:_(i,`latencyMs`)??_(i,`latency_ms`)??0}},O=async(e,t)=>{let n=b();n&&await n(`desktop_new_window_at_url`,{url:e,clientToken:t?.clientToken||void 0,requestHeaders:t?.requestHeaders||void 0})},k=async e=>{let t=b();t&&await t(`desktop_new_window_for_host`,{hostId:e})};export{p as _,w as a,k as c,s as d,h as f,l as g,m as h,S as i,y as l,E as m,D as n,C as o,f as p,x as r,O as s,o as t,c as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{T as e,l as t,r as n}from"./runtime-switch-BkpTTbEi.js";import{It as r}from"./persistence-CmjKImz2.js";import{_ as i}from"./desktop-CfLlmafK.js";import{i as a,l as o,m as s,n as c,p as l,r as u}from"./desktopHosts-C1Ns3DUu.js";var d=e=>e===`unreachable`||e===`wrong-service`||e===`incompatible`,f=e=>e.id===`local`?`local`:`host:${e.id}`,p=e=>n()===f(e),m=async(n,r)=>{if(!i())return{ok:!1,status:{status:`unreachable`,latencyMs:0},reason:`unsupported`};let a=l(o(n))||``;if(!a&&!n.relay)return{ok:!1,status:{status:`unreachable`,latencyMs:0},reason:`unreachable`};let u=(r,i)=>{i&&e({relayUrl:r.relayUrl,serverId:r.serverId,hostEncPubJwk:r.hostEncPubJwk},i),t({apiBaseUrl:typeof window<`u`?window.location.origin:``,clientToken:n.clientToken||null,runtimeKey:f(n),relay:r}),b(n.id)},p=e=>{t({apiBaseUrl:e,clientToken:n.clientToken||null,requestHeaders:n.requestHeaders||null,runtimeKey:f(n)})},m=r?.cachedProbe;if(m?.status===`ok`){if(m.via===`relay`&&n.relay)return u(n.relay),{ok:!0,via:`relay`,status:m};if(a&&m.via!==`relay`)return p(a),{ok:!0,via:`direct`,status:m};if(n.relay)return u(n.relay),{ok:!0,via:`relay`,status:{...m,via:`relay`}}}let h={status:`unreachable`,latencyMs:0},g=null,_;if(a){let e=await c(a,{clientToken:n.clientToken||null,requestHeaders:n.requestHeaders||null}).catch(()=>({status:`unreachable`,latencyMs:0}));h={status:e.status,latencyMs:e.latencyMs},d(e.status)||(g=`direct`)}if(!g&&n.relay){let e=await s(n.relay,{keepTunnel:!0}).catch(()=>({status:`unreachable`,latencyMs:0}));e.status===`ok`?(h={status:e.status,latencyMs:e.latencyMs,via:`relay`},g=`relay`,_=`tunnel`in e?e.tunnel:void 0):a||(h={status:e.status,latencyMs:e.latencyMs})}return g?g===`relay`&&n.relay?(u(n.relay,_),{ok:!0,via:`relay`,status:h}):(p(a),{ok:!0,via:`direct`,status:h}):{ok:!1,status:h,reason:`unreachable`}},h=5e3,g=1500,_=e=>e===`ok`||e===`update-recommended`,v=!1,y=async e=>{if(!i()||v)return;let o=`host:${e}`;if(n()===o){v=!0;try{let i=await u().catch(()=>null),s=i?.hosts.find(t=>t.id===e);if(!i||!s?.relay)return;let d=s.apiUrl?l(s.apiUrl):null;if(d&&d.startsWith(`https://`))return;let f=await r(`/api/client-auth/connection/candidates`).catch(()=>null);if(!f?.ok)return;let p=await f.json().catch(()=>null);if(!p||p.serverId!==s.relay.serverId)return;let m=Array.isArray(p.candidates)?p.candidates:[],h=[];for(let e of m){if(!e||typeof e!=`object`)continue;let t=e;if(t.type!==`lan`||typeof t.url!=`string`)continue;let n=l(t.url);n&&!h.includes(n)&&h.push(n)}if(h.length===0)return;let g=d&&h.includes(d)?d:h[0];if(g!==d&&await a({hosts:i.hosts.map(t=>t.id===e?{...t,apiUrl:g}:t),defaultHostId:i.defaultHostId,initialHostChoiceCompleted:i.initialHostChoiceCompleted}).catch(()=>void 0),!_((await c(g,{clientToken:s.clientToken||null,requestHeaders:s.requestHeaders||null,expectedServerId:s.relay.serverId}).catch(()=>({status:`unreachable`,latencyMs:0}))).status)||n()!==o)return;t({apiBaseUrl:g,clientToken:s.clientToken||null,requestHeaders:s.requestHeaders||null,runtimeKey:o})}finally{v=!1}}},b=e=>{typeof window>`u`||window.setTimeout(()=>{y(e).catch(()=>void 0)},h)},x=async e=>{if(!i())return;let r=await u().catch(()=>null);if(!r)return;let a=e||(r.defaultHostId===`local`?null:r.defaultHostId);if(!a)return;let s=r.hosts.find(e=>e.id===a);if(!s?.relay)return;let d=f(s);if(n()===d)return;let p=e=>{t({apiBaseUrl:e,clientToken:s.clientToken||null,requestHeaders:s.requestHeaders||null,runtimeKey:d})},m=()=>{t({apiBaseUrl:typeof window<`u`?window.location.origin:``,clientToken:s.clientToken||null,runtimeKey:d,relay:s.relay??void 0}),b(s.id)},h=s.apiUrl?l(o(s)):null;if(!h){m();return}let v=e=>_(e.status),y=c(h,{clientToken:s.clientToken||null,requestHeaders:s.requestHeaders||null,expectedServerId:s.relay.serverId}).catch(()=>({status:`unreachable`,latencyMs:0})),x=await Promise.race([y,new Promise(e=>setTimeout(()=>e(null),g))]);if(x){if(v(x)){p(h);return}m();return}m(),y.then(e=>{v(e)&&n()===d&&p(h)})};export{m as i,p as n,f as r,x as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{i as t}from"./runtime-switch-BkpTTbEi.js";import{d as n,u as r}from"./persistence-CmjKImz2.js";import{rt as i}from"./vendor-base-ui-CnHfUmDN.js";import{n as a}from"./vendor-react-DLPElpoQ.js";import{s as o}from"./vendor-tanstack-react-query-D7pys_c9.js";import{n as s}from"./useRuntimeAPIs-DSLXJybW.js";var c=a(),l=e(i(),1),u=e=>e,d=(e,r=t())=>n.files.content(e.scopeDirectory,e.path,u(e.options),r),f=(e,r,i=t())=>({queryKey:n.files.directory(r.scopeDirectory,r.directory,r.respectGitignore,i),queryFn:async()=>{if(!r.directory)throw Error(`A directory is required to list files`);return r.respectGitignore===void 0?e.listDirectory(r.directory):e.listDirectory(r.directory,{respectGitignore:r.respectGitignore})}}),p=(e,r,i=t())=>({queryKey:n.files.search(r.directory,r.query,r.maxResults,r.includeHidden,r.respectGitignore,i),queryFn:async()=>{if(!r.directory)throw Error(`A directory is required to search files`);let t={directory:r.directory,query:r.query.trim(),maxResults:r.maxResults,...r.includeHidden===void 0?{}:{includeHidden:r.includeHidden},...r.respectGitignore===void 0?{}:{respectGitignore:r.respectGitignore}};return e.search(t)}}),m=(e,n,r=t())=>({queryKey:d(n,r),queryFn:async()=>{if(!n.path)throw Error(`A file path is required to read file content`);if(!e.readFile)throw Error(`File content reads are unavailable in this runtime`);return(await(n.options===void 0?e.readFile(n.path):e.readFile(n.path,n.options))).content}}),h=(e,t,n,r)=>{e.setQueryData(d(t,n),r)},g=(e,r,i=t())=>({queryKey:n.files.stat(r.scopeDirectory,r.path,u(r.options),i),queryFn:async()=>{if(!r.path)throw Error(`A file path is required to read file status`);if(!e.statFile)throw Error(`File status reads are unavailable in this runtime`);return r.options===void 0?e.statFile(r.path):e.statFile(r.path,r.options)}}),_=(e,n)=>{let r=(0,c.c)(9),i;r[0]===n?i=r[1]:(i=n===void 0?{}:n,r[0]=n,r[1]=i);let a=i,{files:l}=s(),u,d;if(r[2]!==l||r[3]!==e){let n=t();d=o,u=f(l,e,n),r[2]=l,r[3]=e,r[4]=u,r[5]=d}else u=r[4],d=r[5];let p;return r[6]!==a||r[7]!==u?(p={...u,...a},r[6]=a,r[7]=u,r[8]=p):p=r[8],d(p)},v=(e,n)=>{let r=(0,c.c)(9),i;r[0]===n?i=r[1]:(i=n===void 0?{}:n,r[0]=n,r[1]=i);let a=i,{files:l}=s(),u,d;if(r[2]!==l||r[3]!==e){let n=t();d=o,u=p(l,e,n),r[2]=l,r[3]=e,r[4]=u,r[5]=d}else u=r[4],d=r[5];let f;return r[6]!==a||r[7]!==u?(f={...u,...a},r[6]=a,r[7]=u,r[8]=f):f=r[8],d(f)},y=(e,n)=>{let r=(0,c.c)(9),i;r[0]===n?i=r[1]:(i=n===void 0?{}:n,r[0]=n,r[1]=i);let a=i,{files:l}=s(),u,d;if(r[2]!==l||r[3]!==e){let n=t();d=o,u=m(l,e,n),r[2]=l,r[3]=e,r[4]=u,r[5]=d}else u=r[4],d=r[5];let f;return r[6]!==a||r[7]!==u?(f={...u,...a},r[6]=a,r[7]=u,r[8]=f):f=r[8],d(f)},b=2e3,x=(e,n)=>{let i=(0,c.c)(19),a;i[0]===n?a=i[1]:(a=n===void 0?{}:n,i[0]=n,i[1]=a);let u=a,{files:f}=s(),p,m,h,_;i[2]!==f||i[3]!==e||i[4]!==u.enabled?(_=t(),p=!!(u.enabled&&e.path&&f.statFile),h=o,m=g(f,e,_),i[2]=f,i[3]=e,i[4]=u.enabled,i[5]=p,i[6]=m,i[7]=h,i[8]=_):(p=i[5],m=i[6],h=i[7],_=i[8]);let v=u.intervalMs??b,y;i[9]!==p||i[10]!==m||i[11]!==v?(y={...m,enabled:p,refetchInterval:v,refetchIntervalInBackground:!1,staleTime:0},i[9]=p,i[10]=m,i[11]=v,i[12]=y):y=i[12];let x=h(y),S=l.useRef(null),C=l.useRef(null),w;i[13]!==p||i[14]!==e||i[15]!==u.client||i[16]!==x||i[17]!==_?(w=()=>{let t=x.data;if(!p||!t)return;S.current!==e.path&&(S.current=e.path??null,C.current=null);let n=`${t.size}:${t.mtimeMs??``}`,i=C.current;C.current=n,i!==null&&i!==n&&(u.client??r).invalidateQueries({queryKey:d(e,_)})},i[13]=p,i[14]=e,i[15]=u.client,i[16]=x,i[17]=_,i[18]=w):w=i[18],l.useEffect(w)};export{v as a,_ as i,h as n,x as o,y as r,d as t};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{c as t,i as n}from"./runtime-switch-BkpTTbEi.js";import{D as r,d as i,k as a,ot as o,u as s}from"./persistence-CmjKImz2.js";import{V as c,y as l}from"./desktop-CfLlmafK.js";import{a as u,i as d,r as f}from"./vendor-zustand-B4dlGEM2.js";import{nt as p,rt as m,tt as h}from"./vendor-base-ui-CnHfUmDN.js";import{B as g,Ct as _,M as v,Mt as y}from"./platform-skqcMARt.js";import{b,t as ee,y as x}from"./useUIStore-B7KJS5G7.js";import{n as S}from"./vendor-react-DLPElpoQ.js";import{s as C}from"./vendor-tanstack-react-query-D7pys_c9.js";import{n as w}from"./vendor-reactuses-core-DDoDDyM9.js";import{n as te}from"./clipboard-Bz0Zm9VJ.js";import{_ as ne,an as re,b as T,bo as E,ct as ie,fr as D,ft as O,hn as k,l as A,lt as ae,ot as j,pt as oe,ro as se,st as ce,ta as M,ut as N,yo as P}from"./useMobileNavigationStore-CAvVUItx.js";import{c as le,t as F}from"./utils-CTL16t2f.js";import{n as I,r as L,t as R}from"./Icon-CLpn1mIz.js";import{g as ue,v as de}from"./gitApi-DNTMAa3F.js";import{A as fe,X as pe,p as z,s as B}from"./projectMeta-DNWx6Uva.js";var V=e(m(),1),H=S(),U=p(),W=e(h(),1),me=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`,ge=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`}},_e=()=>`ai-agent`,ve=()=>`chat-thread`,G=32,K=(e,t)=>{let n=L[e];return typeof n!=`string`||n.length===0?null:`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="${t}" stroke-width="${R}" stroke-linecap="round" stroke-linejoin="round">${n}</svg>`},ye=(e,t)=>{let n=K(e,t);return!n||typeof document>`u`?Promise.resolve(null):new Promise(e=>{let t=new Image;t.decoding=`async`,t.onload=()=>{try{let n=document.createElement(`canvas`);n.width=G,n.height=G;let r=n.getContext(`2d`);if(!r){e(null);return}r.clearRect(0,0,G,G),r.drawImage(t,0,0,G,G);let i=n.toDataURL(`image/png`),a=i.indexOf(`,`);e(a>=0?i.slice(a+1):null)}catch{e(null)}},t.onerror=()=>e(null),t.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n)}`})},be=(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:me(e)}}),q=e=>e.map(e=>({id:`${e.name}-${e.scope}`,title:e.name,subtitle:e.description,badge:e.scope,iconName:he()})),xe=({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:_e()});for(let e of t)o.push({id:`session:${e.id}`,title:e.title||i,badge:a,iconName:ve()});for(let e of n)o.push({id:`recent:${e.path}`,title:e.relativePath||e.name,iconName:ge(e)});for(let e of r)o.push({id:`file:${e.path}`,title:e.relativePath||e.name,iconName:ge(e)});return o},J=(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=oe([...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)},Y=(e,t)=>{if(!e.includes(`/`)||t.size===0)return[];let n=RegExp(`(^|\\s)/(${o})?([A-Za-z0-9][A-Za-z0-9_-]*)(?=$|\\s)`,`g`),r=[],i;for(;(i=n.exec(e))!==null;){let e=i[3]??``;if(!t.has(e.toLowerCase()))continue;let n=i[2]??``,a=i.index+(i[1]?.length??0);r.push({start:a,end:a+1+n.length+e.length,name:e,hasSlot:n.length>0})}return r},X=(e,t,n=e.length)=>{let r=Y(e,t).filter(e=>!e.hasSlot);if(r.length===0)return null;let i=e,a=n;for(let e=r.length-1;e>=0;--e){let t=r[e].start+1;i=`${i.slice(0,t)}${o}${i.slice(t)}`,a>t&&(a+=o.length)}return i===e?null:{text:i,caret:a}},Se=e=>e.startsWith(o)?e.slice(o.length):e,Ce=e=>{if(e.inputMode===`shell`)return null;let t=e.text,n=Math.max(0,Math.min(e.cursor,t.length));if(t.startsWith(`/`)){let e=t.indexOf(` `),r=t.indexOf(`
|
|
2
|
-
`),i=Math.min(e===-1?t.length:e,r===-1?t.length:r);if(n<=i&&e===-1)return{kind:`slash-command`,query:Se(t.substring(1,i)),tokenStart:0,tokenEnd:i}}let r=t.substring(0,n),i=r.lastIndexOf(`/`);if(i!==-1){let e=i>0?r[i-1]:null,t=Se(r.substring(i+1)),a=t.includes(` `)||t.includes(`
|
|
3
|
-
`);if((!e||/\s/.test(e))&&!a)return{kind:`slash-skill`,query:t,tokenStart:i,tokenEnd:n}}let a=r.lastIndexOf(`#`);if(a!==-1){let e=a>0?r[a-1]:null,t=r.substring(a+1);if((!e||/\s/.test(e))&&!t.includes(` `)&&!t.includes(`
|
|
4
|
-
`))return{kind:`snippet`,query:t,tokenStart:a,tokenEnd:n}}let o=j({value:t,cursorPosition:n,inputSource:e.mentionInputSource??`manual`,insertedText:e.insertedText});return o===null?null:{kind:`mention`,query:o,tokenStart:r.lastIndexOf(`@`),tokenEnd:n}},we=e=>e===`mention`?`@`:e===`snippet`?`#`:`/`,Te=(e,t,n)=>{if(n&&n.tokenStart>=0&&n.tokenEnd>=n.tokenStart&&n.tokenEnd<=e.length&&e.startsWith(we(n.kind),n.tokenStart))return{start:n.tokenStart,end:n.tokenEnd};let r=Ce({text:e,cursor:t});return r?{start:r.tokenStart,end:r.tokenEnd}:null},Ee=(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}),De=(e,t)=>e.highlightedIndex===t.highlightedIndex&&Ee(e.rows,t.rows),Oe=(e,t)=>Ee(e,t)?e:t.slice(),ke=(e,t,n)=>{e&&(t.current&&De(t.current,n)||(t.current=n,e(n)))},Ae=(e,t)=>{t.current=null,e?.({rows:[],highlightedIndex:0})},Z=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},je=e=>/^[A-Za-z]:\//.test(e)?e.toLowerCase():e,Me=(e,t)=>{let n=Z(t),r=Z(e);if(!n||!r)return!1;let i=je(n),a=je(r);return a===i||a.startsWith(`${i}/`)},Ne=e=>{if(!e||typeof e!=`object`)return{};let t=e,n={};for(let[e,r]of Object.entries(t)){let t=Z(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=>Z(e)).filter(e=>Me(e,t)))):[],o=Array.isArray(i.expandedPaths)?Array.from(new Set(i.expandedPaths.filter(e=>typeof e==`string`).map(e=>Z(e)).filter(e=>Me(e,t)))):[],s=typeof i.selectedPath==`string`?Z(i.selectedPath):null,c=s&&Me(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},Pe=(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},Fe=e=>e?{...e,touchedAt:Date.now()}:{openPaths:[],selectedPath:null,expandedPaths:[],touchedAt:Date.now()},Ie=u()(f(d((e,t)=>({byRoot:{},addOpenPath:(t,n,r)=>{let i=Z((t||``).trim()),a=Z((n||``).trim());!i||!a||!r?.allowOutsideRoot&&!Me(a,i)||e(e=>{let t=e.byRoot[i],n=Fe(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:Pe({...e.byRoot,[i]:{...n,openPaths:o,selectedPath:s}},20)}})},removeOpenPath:(t,n)=>{let r=Z((t||``).trim()),i=Z((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=je(i),a=e=>je(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:Pe({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeOpenPathsByPrefix:(t,n)=>{let r=Z((t||``).trim()),i=Z((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=je(i),a=n.endsWith(`/`)?n:`${n}/`,o=e=>{let t=je(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:Pe({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeExpandedPathsByPrefix:(t,n)=>{let r=Z((t||``).trim()),i=Z((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=je(i),a=n.endsWith(`/`)?n:`${n}/`,o=t.expandedPaths.filter(e=>{let t=je(e);return t!==n&&!t.startsWith(a)});return o.length===t.expandedPaths.length?e:{byRoot:Pe({...e.byRoot,[r]:{...t,expandedPaths:o,touchedAt:Date.now()}},20)}})},setSelectedPath:(t,n,r)=>{let i=Z((t||``).trim()),a=n?Z(n.trim()):null;!i||a&&!r?.allowOutsideRoot&&!Me(a,i)||e(e=>{let t=e.byRoot[i],n=Fe(t),r=a&&!n.openPaths.includes(a)?[...n.openPaths,a]:n.openPaths;return t&&t.selectedPath===a&&r===t.openPaths?e:{byRoot:Pe({...e.byRoot,[i]:{...n,openPaths:r,selectedPath:a}},20)}})},ensureSelectedPath:e=>{let n=Z((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=Z((t||``).trim()),i=Z((n||``).trim());!r||!i||!Me(i,r)||e(e=>{let t=e.byRoot[r],n=Fe(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:Pe({...e.byRoot,[r]:{...n,expandedPaths:a}},20)}})},expandPath:(t,n)=>{let r=Z((t||``).trim()),i=Z((n||``).trim());!r||!i||!Me(i,r)||e(e=>{let t=e.byRoot[r],n=Fe(t);return n.expandedPaths.includes(i)&&t?e:{byRoot:Pe({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,i]}},20)}})},expandPaths:(t,n)=>{let r=Z((t||``).trim());if(!r||!n||n.length===0)return;let i=n.map(e=>Z((e||``).trim())).filter(e=>e&&Me(e,r));i.length!==0&&e(e=>{let t=e.byRoot[r],n=Fe(t),a=new Set(n.expandedPaths),o=i.filter(e=>!a.has(e));return o.length===0?e:{byRoot:Pe({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,...o]}},20)}})}}),{name:`files-view-tabs-store`,version:2,storage:x(),migrate:e=>{if(!e||typeof e!=`object`)return{byRoot:{}};let t=e.byRoot;return{byRoot:Ne(t)}},partialize:e=>({byRoot:Ne(e.byRoot)})}),{name:`files-view-tabs-store`})),Le=(e,t)=>{let n=(0,H.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},Re=()=>{let e=(0,H.c)(17),t=A(ze),n=k(),r;e[0]===t?r=e[1]:(r=e=>t?e.getAttachment(t):void 0,e[0]=t,e[1]=r);let i=T(r),a=A(Be),o=A(Ve),s=E(He),c=E(Ue),l=_(We);if(t){let r;e[2]===i?r=e[3]:(r=ne(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 ze(e){return e.currentSessionId}function Be(e){return e.worktreeMetadata}function Ve(e){return e.newSessionDraft}function He(e){return e.activeProjectId}function Ue(e){return e.projects}function We(e){return e.currentDirectory}var Ge=`absolute z-[100] min-w-0 w-full bottom-full mb-2 left-0 flex flex-col rounded-xl`,Ke=`pointer-events-auto absolute z-[100] min-w-0 flex flex-col rounded-xl`;function qe(e,t){return F(e?Ke:Ge,e?`oc-mobile-overlay-surface oc-mobile-overlay-surface--translucent oc-composer-autocomplete-surface`:`bg-background border-2 border-border/60 shadow-none`,t)}function Je(e,t){return e?`oc-composer-autocomplete-row`:t?`bg-interactive-selection`:void 0}var Ye=.4,Xe=e=>{let t=e.gap??8,n=e.composerTop-t;return{left:e.composerLeft,width:e.composerWidth,bottom:Math.max(0,e.visibleBottom-n),maxHeight:Ze({popupBottom:n,boundaryTop:e.boundaryTop,viewportHeight:e.viewportHeight,gap:t})}},Ze=e=>{let t=e.gap??8,n=Math.max(0,e.popupBottom-e.boundaryTop-t),r=e.viewportHeight*Ye,i=Math.floor(Math.min(n,r));return n>=120?Math.min(n,Math.max(120,i)):i},Qe=(e,t=0)=>{let n=e.closest(`main`);if(!n)return null;let r=(e.closest(`.mobile-chat-screen__content`)?.parentElement??n.parentElement?.closest(`main`)??n).querySelector(`:scope > .oc-mobile-detail-navigation`)?.getBoundingClientRect().bottom,i=n.getBoundingClientRect().top;return Math.max(r===void 0?i:Math.max(r,i),t)},$e=(e,t)=>{let n=(0,H.c)(5),[r,i]=V.useState(void 0),a;n[0]!==t||n[1]!==e?(a=()=>{if(!t){i(void 0);return}let n=()=>{let t=e.current?.parentElement;if(!t)return;let n=t.getBoundingClientRect(),r=window.visualViewport,a=r?.offsetTop??0,o=r?.height??window.innerHeight,s=Qe(t,a)??a,c=Xe({composerTop:n.top,composerLeft:n.left,composerWidth:n.width,visibleBottom:a+o,boundaryTop:s,viewportHeight:o});i(e=>e&&e.left===c.left&&e.width===c.width&&e.bottom===c.bottom&&e.maxHeight===c.maxHeight?e:c)};return n(),window.addEventListener(`resize`,n),window.addEventListener(`oc:keyboard-settled`,n),window.visualViewport?.addEventListener(`resize`,n),window.visualViewport?.addEventListener(`scroll`,n),()=>{window.removeEventListener(`resize`,n),window.removeEventListener(`oc:keyboard-settled`,n),window.visualViewport?.removeEventListener(`resize`,n),window.visualViewport?.removeEventListener(`scroll`,n)}},n[0]=t,n[1]=e,n[2]=a):a=n[2];let o;return n[3]===t?o=n[4]:(o=[t],n[3]=t,n[4]=o),V.useLayoutEffect(a,o),t?r:void 0},et=e=>e?e.closest(`.oc-chat-composer-swap-scope`)??e.closest(`main`):null,tt=V.forwardRef((e,t)=>{let n=(0,H.c)(28),{isMobile:r,className:i,style:a,children:o}=e,s=V.useRef(null),[c,l]=V.useState(null),u=$e(s,r),d,f;if(n[0]===r?(d=n[1],f=n[2]):(d=()=>{if(!r){l(null);return}l(et(s.current?.parentElement??null))},f=[r],n[0]=r,n[1]=d,n[2]=f),V.useLayoutEffect(d,f),!r){let e;n[3]===i?e=n[4]:(e=qe(!1,i),n[3]=i,n[4]=e);let r;return n[5]!==o||n[6]!==t||n[7]!==a||n[8]!==e?(r=(0,U.jsx)(`div`,{ref:t,className:e,style:a,children:o}),n[5]=o,n[6]=t,n[7]=a,n[8]=e,n[9]=r):r=n[9],r}let p;n[10]===i?p=n[11]:(p=qe(!0,i),n[10]=i,n[11]=p);let m;n[12]===u?m=n[13]:(m=u?{left:u.left,width:u.width,bottom:u.bottom,maxHeight:u.maxHeight}:{visibility:`hidden`},n[12]=u,n[13]=m);let h;n[14]!==a||n[15]!==m?(h={...a,...m},n[14]=a,n[15]=m,n[16]=h):h=n[16];let g;n[17]!==o||n[18]!==t||n[19]!==p||n[20]!==h?(g=(0,U.jsx)(`div`,{className:`pointer-events-none fixed inset-0 z-[100]`,children:(0,U.jsx)(`div`,{ref:t,className:p,style:h,children:o})}),n[17]=o,n[18]=t,n[19]=p,n[20]=h,n[21]=g):g=n[21];let _=g,v;n[22]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,U.jsx)(`span`,{ref:s,className:`hidden`,"aria-hidden":!0}),n[22]=v):v=n[22];let y;n[23]!==_||n[24]!==c?(y=c?(0,W.createPortal)(_,c):_,n[23]=_,n[24]=c,n[25]=y):y=n[25];let b;return n[26]===y?b=n[27]:(b=(0,U.jsxs)(U.Fragment,{children:[v,y]}),n[26]=y,n[27]=b),b});tt.displayName=`ComposerAutocompleteLayer`;var nt=()=>{let e=null,t=!1,n=!1;return{pointerDown:(n,r)=>{e={x:n,y:r},t=!1},pointerMove:(n,r)=>{e&&Math.hypot(n-e.x,r-e.y)>6&&(t=!0)},pointerCancel:()=>{e=null,t=!1},pointerUp:r=>{if(!e)return!1;let i=!t;return e=null,t=!1,i?(n=!0,r(),!0):(n=!0,!1)},click:e=>n?(n=!1,!1):(e(),!0)}},rt=V.forwardRef(({searchQuery:e,onFileSelect:t,onAgentSelect:n,onSessionSelect:i,onClose:o,style:s,onRowsChange:c},l)=>{let{t:u}=te(),d=Re()??``,f=A(e=>e.currentSessionId),p=D(e=>e.activeSessions),m=E(e=>e.activeProjectId),h=E(e=>e.projects),g=V.useMemo(()=>h.find(e=>e.id===m)?.path??null,[m,h]),_=V.useMemo(()=>{let e=g||d;return e?e.replace(/\\/g,`/`).replace(/\/+$/,``):null},[g,d]),v=Ie(e=>_?e.byRoot[_]:void 0),b=M(e=>e.getVisibleAgents),x=y(e=>e.searchFiles),S=Le(e,180),C=a(),ne=r(),[re,T]=V.useState([]),[k,j]=V.useState([]),[oe,se]=V.useState(!1),[P,L]=V.useState(0),R=V.useRef(0),[ue,de]=V.useState(360),[pe,z]=V.useState({}),[B,H]=V.useState({}),W=V.useRef([]),me=V.useRef([]),he=V.useRef([]),_e=V.useRef(null),ve=V.useRef(null),G=V.useRef(null);G.current||=nt();let K=ee(e=>e.isMobile),ye=(e??``).trim(),be=V.useMemo(()=>{if(!_||!v)return[];let e=[v.selectedPath,...v.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(`${_}/`)?e.slice(_.length+1):e;n.push({name:i,path:e,relativePath:a,extension:i.includes(`.`)?i.split(`.`).pop()?.toLowerCase():void 0})}return N(n,ye,{limit:6})},[ye,_,v]),q=V.useMemo(()=>ye.length>0?k:k.slice(0,2),[k,ye.length]),J=V.useMemo(()=>i?ce({sessions:p,currentSessionId:f,searchQuery:ye}):[],[p,f,ye,i]),Y=be,X=re;V.useEffect(()=>{let e=e=>{let t=e.target;!t||!_e.current||_e.current.contains(t)||o()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[o]),V.useEffect(()=>{if(!d){T([]);return}let e=(S??``).trim(),t=O(e);if(!t){T([]);return}let n=!1;se(!0);let r={includeHidden:C,respectGitignore:!ne};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(be.map(e=>e.path));T(ie({files:t,directories:r,query:e,excludePaths:i,limit:20}))}).catch(()=>{n||T([])}).finally(()=>{n||se(!1)}),()=>{n=!0}},[d,S,be,x,C,ne]),V.useEffect(()=>{let t=b().filter(e=>e.mode&&e.mode!==`primary`).map(e=>({name:e.name,description:e.description,mode:e.mode}));j(ae(t,e??``))},[b,e]),V.useEffect(()=>{L(0),z({}),H({})},[X,Y.length,q.length,J.length]),V.useEffect(()=>{R.current=P},[P]),V.useEffect(()=>{W.current[P]?.scrollIntoView({block:`nearest`})},[P]),V.useEffect(()=>{let e=null,t=()=>{e!==null&&cancelAnimationFrame(e),e=requestAnimationFrame(()=>{let e={},t={};me.current.forEach((n,r)=>{if(!n)return;let i=he.current[r]?.offsetWidth??n.scrollWidth,a=Math.max(0,i-n.clientWidth),o=a>8;if(e[r]=o,o){let e=Math.max(.6,a/110);t[r]=e}}),z(e),H(t)})};return t(),window.addEventListener(`resize`,t),()=>{e!==null&&cancelAnimationFrame(e),window.removeEventListener(`resize`,t)}},[X,Y]),V.useEffect(()=>{let e=me.current[P];if(!e)return;let t=()=>{let t=e.clientWidth;t>0&&de(t)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>{n.disconnect()}},[P]);let Se=w(e=>{t(e)}),Ce=w(e=>{n?.(e)}),we=w(e=>{i?.(e)}),Te=(e,t)=>({onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&G.current?.pointerDown(e.clientX,e.clientY)},onPointerMove:e=>{e.pointerType===`touch`&&G.current?.pointerMove(e.clientX,e.clientY)},onPointerUp:e=>{e.pointerType===`touch`&&(G.current?.pointerUp(t)??!1)&&(e.preventDefault(),e.stopPropagation())},onPointerCancel:()=>G.current?.pointerCancel(),onClick:()=>{G.current?.click(t)},onMouseMove:()=>L(e)}),Ee=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&&Ce(e.name);return}let r=n-q.length;if(r<J.length){let e=J[r];e&&we(e);return}let i=r-J.length,a=i<Y.length?Y[i]:X[i-Y.length];a&&Se(a)};V.useEffect(()=>{ke(c,ve,{rows:xe({agents:q,sessions:J,recentFiles:Y,pathHits:X,untitledSession:u(`chat.fileMentionAutocomplete.untitledSession`),sessionBadge:u(`chat.fileMentionAutocomplete.sessionType`)}),highlightedIndex:P})},[c,P,u,q,X,Y,J]);let De=V.useRef(c);De.current=c,V.useEffect(()=>()=>{Ae(De.current,ve)},[]),V.useImperativeHandle(l,()=>({acceptIndex:e=>{Ee(e)},handleKeyDown:e=>{if(e===`Escape`){o();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`)&&Ee(R.current)}}}),[X,Y,q,J,o,Se,Ce,we]);let Oe=e=>(0,U.jsx)(I,{name:ge(e),className:`h-3.5 w-3.5 text-current`});return(0,U.jsxs)(tt,{ref:_e,isMobile:K,className:`max-w-[640px] max-h-64`,style:s,children:[(0,U.jsx)(fe,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0`,children:(0,U.jsxs)(`div`,{className:`pb-2`,children:[q.length>0&&(0,U.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=P===t;return(0,U.jsx)(`div`,{ref:e=>{W.current[t]=e},className:F(`flex items-start gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,K&&`min-h-11`,Je(K,n),!K&&n&&`text-interactive-selection-foreground`),...Te(t,()=>Ce(e.name)),children:(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsxs)(`div`,{className:`font-semibold truncate`,children:[`@`,e.name]}),e.description&&!K?(0,U.jsx)(`div`,{className:`typography-meta text-muted-foreground truncate`,children:e.description}):null]})},`agent-${e.name}`)}),q.length===2&&ye.length===0&&k.length>2&&(0,U.jsx)(`div`,{className:`px-3 py-1 typography-meta text-muted-foreground`,children:u(`chat.fileMentionAutocomplete.searchMoreAgents`)}),J.length>0&&(0,U.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=P===n;return(0,U.jsxs)(`div`,{ref:e=>{W.current[n]=e},className:F(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,K&&`min-h-11`,Je(K,r),!K&&r&&`text-interactive-selection-foreground`),...Te(n,()=>we(e)),children:[(0,U.jsx)(I,{name:`chat-thread`,className:`h-4 w-4 flex-shrink-0 text-[var(--primary-base)]`}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.title||u(`chat.fileMentionAutocomplete.untitledSession`),children:e.title||u(`chat.fileMentionAutocomplete.untitledSession`)}),K?null:(0,U.jsx)(`span`,{className:`flex-shrink-0 typography-meta text-muted-foreground`,children:u(`chat.fileMentionAutocomplete.sessionType`)})]},`session-${e.id}`)}),Y.length>0&&(0,U.jsx)(`div`,{className:`px-3 pb-1 pt-2 typography-meta font-medium text-muted-foreground`,children:u(`chat.fileMentionAutocomplete.groups.recentFiles`)}),Y.map((e,t)=>{let n=q.length+J.length+t,r=e.relativePath||e.name,i=le(r,{maxLength:60}),a=P===n,o=pe[n]??!1,s=B[n]??2.6;return(0,U.jsxs)(`div`,{ref:e=>{W.current[n]=e},className:F(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,K&&`min-h-11`,Je(K,a),!K&&a&&`text-interactive-selection-foreground`),...Te(n,()=>Se(e)),children:[Oe(e),(0,U.jsxs)(`span`,{ref:e=>{me.current[n]=e},className:`relative flex-1 min-w-0 overflow-hidden file-mention-marquee-container`,style:a?{"--file-mention-marquee-width":`${ue}px`,"--file-mention-marquee-duration":`${s}s`}:void 0,"aria-label":r,children:[(0,U.jsx)(`span`,{ref:e=>{he.current[n]=e},className:`absolute invisible whitespace-nowrap pointer-events-none`,"aria-hidden":!0,children:r}),o&&a?(0,U.jsx)(`span`,{className:`inline-block whitespace-nowrap file-mention-marquee`,children:r}):(0,U.jsx)(`span`,{className:`block truncate`,children:i})]})]},`recent-${e.path}`)}),X.length>0&&(0,U.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=le(r,{maxLength:60}),a=P===n,o=pe[n]??!1,s=B[n]??2.6;return(0,U.jsxs)(`div`,{ref:e=>{W.current[n]=e},className:F(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,K&&`min-h-11`,Je(K,a),!K&&a&&`text-interactive-selection-foreground`),...Te(n,()=>Se(e)),children:[Oe(e),(0,U.jsxs)(`span`,{ref:e=>{me.current[n]=e},className:`relative flex-1 min-w-0 overflow-hidden file-mention-marquee-container`,style:a?{"--file-mention-marquee-width":`${ue}px`,"--file-mention-marquee-duration":`${s}s`}:void 0,"aria-label":r,children:[(0,U.jsx)(`span`,{ref:e=>{he.current[n]=e},className:`absolute invisible whitespace-nowrap pointer-events-none`,"aria-hidden":!0,children:r}),o&&a?(0,U.jsx)(`span`,{className:`inline-block whitespace-nowrap file-mention-marquee`,children:r}):(0,U.jsx)(`span`,{className:`block truncate`,children:i})]})]},e.path)}),oe&&X.length===0?(0,U.jsx)(`div`,{className:`flex items-center justify-center py-3`,children:(0,U.jsx)(I,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):null,!oe&&X.length===0&&Y.length===0&&q.length===0&&J.length===0&&(0,U.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:u(`chat.fileMentionAutocomplete.empty`)})]})}),!K&&(0,U.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:u(`chat.autocomplete.keyboardHint`)})]})}),it=new Set([`new`,`fork`,`compact`,`undo`,`redo`,`model`,`goal`]),at=(e,t)=>{if(!t||e.isSkill)return!1;let n=e.name?.trim().toLowerCase();return!!(n&&it.has(n))},ot=(e,t)=>!e||t({name:e}),st=` `,ct=(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]===st&&e[r-2]===`/`&&(r-=2),e[r]===`/`?{start:r,end:n}:null},lt=`text-[10px] leading-none uppercase font-bold tracking-tight px-1.5 py-1 rounded border flex-shrink-0`,ut=F(lt,`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)]`),dt=F(lt,`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)]`),ft=F(lt,`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)]`),pt=F(lt,`bg-[var(--surface-muted)] text-muted-foreground border-[var(--interactive-border)]/60`),mt=(e,t)=>e.length===t.length&&e.every((e,n)=>e.id===t[n]?.id),ht=(e,t)=>{let n=!!e.sessionID;return{hasSession:n,canStartSessionCommand:n||e.hasNewDraft,canUseReviewHandoffFlow:n&&!t&&!l()}},gt=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=A(e=>e.currentSessionId),f=A(e=>!!e.newSessionDraft?.open),p=A(V.useCallback(e=>d?e.getDirectoryForSession(d):void 0,[d])),m=re(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(()=>ht(h,u),[h,u]),y=h.hasMessages,[b,x]=V.useState([]),[S,C]=V.useState(!1),w=P({directory:r}),ne=V.useMemo(()=>w.data??[],[w.data]),T=w.isFetching,E=se({directory:r}),ie=V.useMemo(()=>E.data??[],[E.data]),[D,O]=V.useState(0),k=V.useRef(0),ae=V.useRef(!1),j=V.useRef([]),oe=V.useRef(null),ce=V.useRef(!1),M=V.useRef(null),N=V.useRef(!1),le=V.useRef(null);V.useEffect(()=>{let e=e=>{let t=e.target;!t||!oe.current||oe.current.contains(t)||n()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[n]),V.useEffect(()=>{(async()=>{C(T);try{let t=ne.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=ie.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=J(r.filter(e=>(i||e.name!==`init`)&&(a?.(e)??!0)),e);x(e=>mt(e,o)?e:o)}catch{let t=!y,n=J([{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=>mt(e,n)?e:n)}finally{C(!1)}})()},[e,y,g,_,v,ne,T,ie,l,a]),V.useEffect(()=>{O(0)},[b]),V.useEffect(()=>{k.current=D},[D]),V.useEffect(()=>{j.current[D]?.scrollIntoView({block:`nearest`})},[D]),V.useEffect(()=>{ke(s,le,{rows:be(b,{skill:l(`chat.commandAutocomplete.badge.skill`),command:l(`chat.commandAutocomplete.badge.command`),system:l(`chat.commandAutocomplete.badge.system`)}),highlightedIndex:D})},[b,s,D,l]);let L=V.useRef(s);L.current=s,V.useEffect(()=>()=>{Ae(L.current,le)},[]),V.useImperativeHandle(c,()=>({acceptIndex:(e,n=!0)=>{let r=b[e];r&&t(r,at(r,n))},handleKeyDown:e=>{let r=b.length;if(e===`Escape`){n();return}if(r!==0){if(e===`ArrowDown`){ae.current=!0,O(e=>(e+1)%r);return}if(e===`ArrowUp`){ae.current=!0,O(e=>(e-1+r)%r);return}if(e===`Enter`||e===`Tab`){let n=(k.current%r+r)%r,i=b[n];i&&t(i,at(i,e===`Enter`))}}}}),[b,n,t]);let R=e=>{let t=me(e);switch(e.name){case`new`:return(0,U.jsx)(I,{name:t,className:`h-3.5 w-3.5`});case`init`:return(0,U.jsx)(I,{name:t,className:`h-3.5 w-3.5 text-green-500`});case`undo`:return(0,U.jsx)(I,{name:t,className:`h-3.5 w-3.5 text-orange-500`});case`redo`:return(0,U.jsx)(I,{name:t,className:`h-3.5 w-3.5 text-orange-500`});case`timeline`:return(0,U.jsx)(I,{name:t,className:`h-3.5 w-3.5`});case`compact`:return(0,U.jsx)(I,{name:t,className:`h-3.5 w-3.5 text-purple-500`});case`goal`:return(0,U.jsx)(I,{name:t,className:`h-3.5 w-3.5`});case`review`:return(0,U.jsx)(I,{name:t,className:`h-3.5 w-3.5 text-blue-500`});case`test`:case`build`:case`run`:return(0,U.jsx)(I,{name:t,className:`h-3.5 w-3.5 text-cyan-500`});default:return e.isBuiltIn?(0,U.jsx)(I,{name:t,className:`h-3.5 w-3.5 text-yellow-500`}):(0,U.jsx)(I,{name:t,className:`h-3.5 w-3.5 text-muted-foreground`})}};return(0,U.jsxs)(tt,{ref:oe,isMobile:u,className:`max-w-[450px] max-h-64`,style:i,children:[(0,U.jsx)(fe,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0 pb-2`,children:S?(0,U.jsx)(`div`,{className:`flex items-center justify-center py-4`,children:(0,U.jsx)(I,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):(0,U.jsxs)(`div`,{children:[b.map((e,n)=>{let r=e.isBuiltIn,i=e.isOpenChamber;return(0,U.jsxs)(`div`,{ref:e=>{j.current[n]=e},className:F(`flex gap-2 px-3 py-2 cursor-pointer rounded-lg`,u?`items-center`:`items-start`,Je(u,n===D)),onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&(M.current={x:e.clientX,y:e.clientY},N.current=!1)},onPointerMove:e=>{if(e.pointerType!==`touch`||!M.current)return;let t=e.clientX-M.current.x,n=e.clientY-M.current.y;Math.hypot(t,n)>6&&(N.current=!0)},onPointerUp:n=>{if(n.pointerType!==`touch`)return;let r=N.current;M.current=null,N.current=!1,!r&&(n.preventDefault(),n.stopPropagation(),ce.current=!0,t(e,at(e,u)))},onPointerCancel:()=>{M.current=null,N.current=!1},onClick:()=>{if(ce.current){ce.current=!1;return}t(e,at(e,u))},onMouseMove:()=>{ae.current=!1,O(n)},children:[(0,U.jsx)(`div`,{className:F(!u&&`mt-0.5`),children:R(e)}),(0,U.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsxs)(`span`,{className:`typography-ui-label font-medium`,children:[`/`,e.name]}),e.isSkill?(0,U.jsx)(`span`,{className:ut,children:l(`chat.commandAutocomplete.badge.skill`)}):(0,U.jsx)(`span`,{className:ut,children:l(`chat.commandAutocomplete.badge.command`)}),i?(0,U.jsx)(`span`,{className:pt,children:`OpenChamber`}):r?(0,U.jsx)(`span`,{className:pt,children:l(`chat.commandAutocomplete.badge.system`)}):e.scope?(0,U.jsx)(`span`,{className:e.scope===`project`?ft:dt,children:e.scope}):null,e.agent&&(0,U.jsx)(`span`,{className:pt,children:e.agent})]}),e.description&&!u&&(0,U.jsx)(`div`,{className:`typography-meta text-muted-foreground mt-0.5 truncate`,children:e.description})]})]},e.id)}),b.length===0&&(0,U.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:l(`chat.commandAutocomplete.empty`)})]})}),!u&&(0,U.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:l(`chat.autocomplete.keyboardHint`)})]})});gt.displayName=`CommandAutocomplete`;function _t(e){return(e.description||e.content).replace(/\s+/g,` `).trim().slice(0,120)}var vt=V.forwardRef((e,t)=>{let n=(0,H.c)(62),{searchQuery:r,onSnippetSelect:i,onClose:a,style:o}=e,{t:s}=te(),c=V.useRef(null),l=ee(yt),[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=pe(bt),y=pe(xt),b=pe(St),x=pe(Ct),S=ee(wt),C=ee(Tt),w,ne;n[2]===y?(w=n[3],ne=n[4]):(w=()=>{y()},ne=[y],n[2]=y,n[3]=w,n[4]=ne),V.useEffect(w,ne);let re,T;n[5]!==r||n[6]!==v?(re=()=>{let e=r.trim();if(!e.length){let e=[...v].sort(Et);h(e),d(+!!e.length);return}let t=oe(v,e,Dt);t.sort(Ot);let n=t.map(kt);h(n),d(+!!n.length)},T=[r,v],n[5]=r,n[6]=v,n[7]=re,n[8]=T):(re=n[7],T=n[8]),V.useEffect(re,T);let E,ie;n[9]===u?(E=n[10],ie=n[11]):(E=()=>{f.current=u,_.current[u]?.scrollIntoView({block:`nearest`})},ie=[u],n[9]=u,n[10]=E,n[11]=ie),V.useEffect(E,ie);let D,O;n[12]===a?(D=n[13],O=n[14]):(O=()=>{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)},D=[a],n[12]=a,n[13]=D,n[14]=O),V.useEffect(O,D);let k;n[15]!==i||n[16]!==r?(k=e=>{let t=r.trim(),n=e.aliases.includes(t)?t:e.name;i(e,n)},n[15]=i,n[16]=r,n[17]=k):k=n[17];let A=k,ae;n[18]!==a||n[19]!==x||n[20]!==S||n[21]!==C||n[22]!==b||n[23]!==v?(ae=()=>{let e=new Set(v.map(At)),t=`new-snippet`,n=1;for(;e.has(t);)t=`new-snippet-${n++}`;b({name:t,scope:`global`}),x(t),C(`snippets`),S(!0),a()},n[18]=a,n[19]=x,n[20]=S,n[21]=C,n[22]=b,n[23]=v,n[24]=ae):ae=n[24];let j=ae,se,ce;n[25]!==A||n[26]!==m||n[27]!==a||n[28]!==j?(se=()=>({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){j();return}let e=m[f.current-1];e&&A(e)}}}),ce=[A,m,a,j],n[25]=A,n[26]=m,n[27]=a,n[28]=j,n[29]=se,n[30]=ce):(se=n[29],ce=n[30]),V.useImperativeHandle(t,se,ce);let M;n[31]===Symbol.for(`react.memo_cache_sentinel`)?(M=e=>{_.current[0]=e},n[31]=M):M=n[31];let N;n[32]!==l||n[33]!==u?(N=F(`flex items-center gap-2 px-3 py-1.5 cursor-pointer rounded-lg typography-ui-label`,Je(l,u===0)),n[32]=l,n[33]=u,n[34]=N):N=n[34];let P,le;n[35]===Symbol.for(`react.memo_cache_sentinel`)?(P=()=>d(0),le=(0,U.jsx)(I,{name:`add`,className:`h-3.5 w-3.5 text-muted-foreground`}),n[35]=P,n[36]=le):(P=n[35],le=n[36]);let L;n[37]===s?L=n[38]:(L=s(`chat.snippetAutocomplete.action.addNew`),n[37]=s,n[38]=L);let R;n[39]===L?R=n[40]:(R=(0,U.jsx)(`span`,{className:`font-medium text-foreground`,children:L}),n[39]=L,n[40]=R);let ue;n[41]!==j||n[42]!==N||n[43]!==R?(ue=(0,U.jsxs)(`div`,{ref:M,className:N,onClick:j,onMouseMove:P,children:[le,R]}),n[41]=j,n[42]=N,n[43]=R,n[44]=ue):ue=n[44];let de;n[45]!==A||n[46]!==m||n[47]!==l||n[48]!==u||n[49]!==s?(de=m.length?m.map((e,t)=>(0,U.jsx)(`div`,{ref:e=>{_.current[t+1]=e},className:F(`flex gap-2 px-3 py-1.5 cursor-pointer rounded-lg typography-ui-label`,l?`items-center`:`items-start`,Je(l,t+1===u)),onClick:()=>A(e),onMouseMove:()=>d(t+1),children:(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsxs)(`span`,{className:`font-semibold truncate`,children:[`#`,e.name]}),(0,U.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,U.jsx)(`div`,{className:`typography-meta text-muted-foreground mt-0.5 truncate`,children:_t(e)})]})},`${e.source}:${e.filePath}`)):(0,U.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:s(`chat.snippetAutocomplete.empty`)}),n[45]=A,n[46]=m,n[47]=l,n[48]=u,n[49]=s,n[50]=de):de=n[50];let z;n[51]!==ue||n[52]!==de?(z=(0,U.jsxs)(fe,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0 pb-2`,children:[ue,de]}),n[51]=ue,n[52]=de,n[53]=z):z=n[53];let B;n[54]!==l||n[55]!==s?(B=!l&&(0,U.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 W;return n[57]!==l||n[58]!==o||n[59]!==z||n[60]!==B?(W=(0,U.jsxs)(tt,{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]=W):W=n[61],W});vt.displayName=`SnippetAutocomplete`;function yt(e){return e.isMobile}function bt(e){return e.snippets}function xt(e){return e.loadSnippets}function St(e){return e.setSnippetDraft}function Ct(e){return e.setSelectedSnippet}function wt(e){return e.setSettingsDialogOpen}function Tt(e){return e.setSettingsPage}function Et(e,t){return e.source===`project`&&t.source!==`project`?-1:e.source!==`project`&&t.source===`project`?1:e.name.localeCompare(t.name)}function Dt(e){return[e.name,...e.aliases]}function Ot(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 kt(e){return e.item}function At(e){return e.name}var jt=2,Mt=e=>!!e&&typeof e==`object`&&!Array.isArray(e),Nt=e=>{let t=e?.trim().replace(/\\/g,`/`);return t?t.length>1?t.replace(/\/+$/,``):t:null},Pt=e=>Mt(e)&&Array.isArray(e.all)&&e.all.every(e=>typeof e==`string`)&&typeof e.current==`string`&&Mt(e.branches),Ft=(e,t)=>JSON.stringify([e,t]),It=e=>`version`in e&&e.version===jt&&Mt(e.entries),Lt=e=>{if(!e)return null;try{let t=JSON.parse(e);return Mt(t)?t.version===jt&&Mt(t.entries)?{version:jt,entries:t.entries}:t:null}catch{return null}},Rt=(e,t)=>{try{e.setItem(`oc.gitBranchCache`,JSON.stringify(t))}catch{}},zt=(e,t,n)=>{let r=Nt(e);if(!r||!t)return null;let i;try{i=n.getItem(`oc.gitBranchCache`)}catch{return null}let a=Lt(i);if(!a)return null;if(It(a))return Pt(a.entries[Ft(t,r)])?a.entries[Ft(t,r)]:null;let o={};for(let[e,n]of Object.entries(a)){let r=Nt(e);r&&Pt(n)&&(o[Ft(t,r)]=n)}return Rt(n,{version:jt,entries:o}),o[Ft(t,r)]??null},Bt=(e,t,n,r)=>{let i=Nt(e);if(!i||!t||!Pt(n))return;let a=null;try{a=r.getItem(`oc.gitBranchCache`)}catch{return}let o=Lt(a);Rt(r,{version:jt,entries:{...o&&It(o)?o.entries:{},[Ft(t,i)]:n}})},Vt=3e4,Ht=Nt,Ut=(e,t=n())=>i.git.branches(Ht(e),t),Wt=(e,t=n())=>i.git.remotes(Ht(e),t),Gt=async(e,t,n)=>{n.throwIfAborted();let r=c()?.git,i=t?.getGitBranches?await t.getGitBranches(e,{signal:n}):r?await r.getGitBranches(e,{signal:n}):await v(e,{signal:n});return n.throwIfAborted(),i},Kt=async(e,t,n)=>{n.throwIfAborted();let r=c()?.git,i=t?.getRemotes?await t.getRemotes(e,{signal:n}):r?await r.getRemotes(e,{signal:n}):await g(e,{signal:n});return n.throwIfAborted(),i},qt=(e,t,r=n(),i=b())=>{let a=Ht(e),o=t;return{queryKey:Ut(a,r),queryFn:async({signal:e})=>{if(!a)throw Error(`Git branches require a directory`);let t=await Gt(a,o,e);return Bt(a,r,t,i),t},staleTime:Vt,gcTime:1/0,initialData:()=>zt(a,r,i)??void 0,initialDataUpdatedAt:0}},Jt=(e,t,r=n())=>{let i=Ht(e),a=t;return{queryKey:Wt(i,r),queryFn:({signal:e})=>{if(!i)throw Error(`Git remotes require a directory`);return Kt(i,a,e)},staleTime:Vt,gcTime:1/0}},Yt=(e,r,i)=>{let a=(0,H.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=Ht(e),u=C,l=qt(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)},Xt=(e,r,i)=>{let a=(0,H.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=Ht(e),u=C,l=Jt(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)},Zt=(e,t,r=s,i=n())=>r.fetchQuery(qt(e,t,i)),Qt=(e,t,r=s,i=n())=>r.fetchQuery({...qt(e,t,i),staleTime:0}),$t=e=>e instanceof Error?e.name===`AbortError`||e.name===`CancelledError`||e.name===`Error`&&e.message===`CancelledError`:!1,en=1e4,tn=6e4,nn=5e3,rn=3e4,an=6e4,on=25,sn=40,cn=2,ln=15e3,un=500,dn=30,fn=20971520,pn=new Map,mn=new Map,hn=new Map,gn=new Map,_n=new Map,vn=(e,t)=>`${t}:${e}`,yn=e=>mn.get(e)??0,bn=e=>{let t=yn(e)+1;return mn.set(e,t),t},xn=e=>{let t=(hn.get(e)??0)+1;return hn.set(e,t),t},Sn=e=>{let t=pn.get(e);if(t)return t;let n=new Set;return pn.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}),Cn=(e,t=dn,n=fn)=>{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},wn=(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},Tn=(e,t)=>!e&&!t?!1:!e||!t||e.remote!==t.remote||e.branch!==t.branch||e.ahead!==t.ahead||e.behind!==t.behind,En=(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&&Tn(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&&wn(e.diffStats,t.diffStats))},Dn=(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},On=(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},kn=e=>!e||e.trim().length===0,An=e=>(e||``).trim()===`U`,jn=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(An(t)||An(n))return e;let r=t===`?`||n===`?`?`A`:t||n||` `;return{...e,index:r,working_dir:` `}},Mn=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(An(t)||An(n))return e;let r=n||(t===`A`||t===`?`?`?`:t)||` `;return{...e,index:` `,working_dir:r}},Nn=e=>kn(e.index)&&kn(e.working_dir),$=u()(f((e,t)=>({directories:new Map,activeDirectory:null,setActiveDirectory:n=>{let{activeDirectory:r,directories:i}=t();if(r!==n)if(r&&bn(r),n&&bn(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=vn(n,a),s=gn.get(o)??(a===`light`?gn.get(vn(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)>tn,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(En(s.status,u)){c=!0;let r=new Map(t().directories),i=r.get(n)??Q(),s=Dn(i.status,u),l=On(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&&bn(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})();gn.set(o,c);try{return await c}finally{gn.get(o)===c&&gn.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`?jn(e):Mn(e);t!==e&&(l=!0),Nn(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=xn(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 Qt(r,i,void 0,o):await Zt(r,i,void 0,o);if(s!==hn.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($t(i)||console.error(`Failed to fetch git branches:`,i),s!==hn.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>en||!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=Cn(s);a.set(n,{...o,diffCache:c}),e({directories:a})},clearDiffCache:n=>{bn(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,on);await t().prefetchDiffs(e,n,i,{maxFiles:on})},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=sn}=a,c=new Set(o.status.files.map(e=>e.path)),l=o.status.diffStats,u=Sn(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>un||d.push(e)}let p=d.slice(0,Math.max(1,s));if(p.length===0)return;let m=yn(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 ${ln}ms`)),ln)}),a=await Promise.race([t,i]);return{path:e,diff:{original:a.original??``,modified:a.modified??``,isBinary:a.isBinary}}},y=async()=>{for(;;){if(m!==yn(n))return;let e=_();if(!e)return;try{g.push(await v(e))}catch{}finally{u.delete(e)}}},b=Math.min(cn,p.length);if(await Promise.allSettled(Array.from({length:b},()=>y())),p.forEach(e=>u.delete(e)),m!==yn(n))return;let ee=new Map(t().directories),x=ee.get(n);if(!x)return;let S=new Map(x.diffCache),C=Date.now();g.forEach(e=>{!e.diff.isBinary&&e.diff.original===``&&e.diff.modified===``||S.set(e.path,{...e.diff,fetchedAt:C})});let w=Cn(S);ee.set(n,{...x,diffCache:w}),e({directories:ee})},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<nn||await t().fetchStatus(e,n,{silent:!!r?.status})},ensureAll:(e,n)=>{let r=_n.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)>=nn)&&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>=rn)&&o.push(t().fetchBranches(e,n)),(!a.log||i-a.lastLogFetch>=en)&&o.push(t().fetchLog(e,n)),(!a.identity||i-a.lastIdentityFetch>=an)&&o.push(t().fetchIdentity(e,n)),o.length>0&&await Promise.all(o)})();return _n.set(e,i),i.finally(()=>{_n.get(e)===i&&_n.delete(e)}),i},refresh:async(e,n={})=>{let{activeDirectory:r}=t();r&&await t().fetchAll(r,e,n)}}),{name:`git-store`})),Pn=e=>{let t=(0,H.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.status??null:null,t[0]=e,t[1]=n),$(n)},Fn=e=>{let r=(0,H.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)},In=e=>{let t=(0,H.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.log??null:null,t[0]=e,t[1]=n),$(n)},Ln=e=>{let t=(0,H.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isGitRepo??null:null,t[0]=e,t[1]=n),$(n)},Rn=e=>{let t=(0,H.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.status?.current?.trim()??null:null,t[0]=e,t[1]=n),$(n)},zn={current:new Map},Bn=()=>$(Gn),Vn=e=>{let t=(0,H.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=new Map,t[0]=n):n=t[0];let r=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)},Hn=e=>{let t=(0,H.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isLoadingStatus??!1:!1,t[0]=e,t[1]=n),$(n)},Un=e=>{let t=(0,H.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isLoadingLog??!1:!1,t[0]=e,t[1]=n),$(n)},Wn=e=>{let t=(0,H.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isLoadingBranches??!1:!1,t[0]=e,t[1]=n),$(n)};function Gn(e){let t=zn.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 zn.current=r,r}var Kn=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)}},qn=e=>String(e||``).trim().replace(/^refs\/heads\//,``).replace(/^heads\//,``).replace(/^remotes\//,``),Jn=e=>e.branchName?qn(e.branchName):e.mode===`existing`?qn(e.existingBranch||e.preferredName||``):qn(e.preferredName||``),Yn=async e=>{let t=await z(e);try{let n=Kn((await ue(e)).branches?.[t]?.tracking||null);if(n?.remote)return n.remote}catch{}try{let t=Kn((await de(e)).tracking);if(t?.remote)return t.remote}catch{}return null},Xn=async(e,t)=>{let n=await Yn(e),r=qn(t);return!n||!r?null:{setUpstream:!0,upstreamRemote:n,upstreamBranch:r}},Zn=async(e,t,n)=>{let r=Jn(t),i=n?.resolvedRootTrackingRemote,a=i===void 0?await Xn(e,r):i&&qn(r)?{setUpstream:!0,upstreamRemote:i,upstreamBranch:qn(r)}:null;return a?{...t,setUpstream:t.setUpstream??a.setUpstream,upstreamRemote:t.upstreamRemote||a.upstreamRemote,upstreamBranch:t.upstreamBranch||a.upstreamBranch}:t},Qn=async(e,t,n)=>{let r=await Zn(e.path,t,n);return B(e,r)},$n=`oc:lastWorktreeSourceBranch`,er=({mode:e,sourceBranch:t,linkedPr:n,selectedBranch:r})=>e===`existing-branch`?r||null:n?null:t||null,tr=({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},nr=(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?` `:``}`},rr=(e,t,n)=>{let r=nr(e,t,n);return`${t.length===0&&!/^\s/.test(r)?` `:``}${r}${n.length===0&&!/\s$/.test(r)?` `:``}`},ir=(e,t,n,r)=>{let i=e.slice(0,t),a=e.slice(n),o=rr(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}},ar=(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]},or=(e,t)=>t<e.length&&e[t]===` `?t+1:t;export{tt as A,X as B,Yt as C,ct as D,gt as E,Oe as F,q as H,ke as I,Ae as L,Re as M,Le as N,ot as O,Ie as P,Te as R,Qt as S,vt as T,ye as U,Se as V,In as _,$n as a,$ as b,Qn as c,Bn as d,Rn as f,Hn as g,Un as h,rr as i,Je as j,rt as k,Yn as l,Wn as m,ar as n,tr as o,Fn as p,ir as r,er as s,or as t,Zn as u,Vn as v,Xt as w,Ln as x,Pn as y,Ce as z};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-workbox-window-qnW0Nbv7.js","assets/rolldown-runtime-C0FnF6B9.js","assets/renderMobileApp-B0Ix_uNo.js","assets/runtime-switch-BkpTTbEi.js","assets/persistence-CmjKImz2.js","assets/desktop-CfLlmafK.js","assets/vendor-zustand-B4dlGEM2.js","assets/vendor-base-ui-CnHfUmDN.js","assets/useUIStore-B7KJS5G7.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-react-DLPElpoQ.js","assets/vendor-tanstack-query-core-BWz0ose6.js","assets/platform-skqcMARt.js","assets/vendor-opencode-sdk-C07HQypa.js","assets/vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js","assets/capgoAdapter-DCowZ2ab.js","assets/types-BuiqMmh_.js","assets/vendor-pierre-diffs-DX7XTPG3.js","assets/vendor-hast-util-to-html-B0p1k5Xa.js","assets/vendor-character-entities-legacy-Wut6vMuj.js","assets/vendor-character-entities-html4-DlN_yAFd.js","assets/vendor-ccount-CyGsA0u7.js","assets/vendor-comma-separated-tokens-B9ouxNNS.js","assets/vendor-oniguruma-to-es-CrHzjjSU.js","assets/vendor-oniguruma-parser-D2DIvhSP.js","assets/vendor-diff-Dq7CZNim.js","assets/vendor-lru_map-DpDied8H.js","assets/vendor-sonner-DVzioF3d.js","assets/vendor-reactuses-core-DDoDDyM9.js","assets/vendor-lodash-es-DfLbG5Af.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/clipboard-Bz0Zm9VJ.js","assets/store-DzpbXWX1.js","assets/MobileShareBridge-CliVo1YH.js","assets/useMobileNavigationStore-CAvVUItx.js","assets/vendor-tanstack-react-query-D7pys_c9.js","assets/useAssistantUIStore-DaplPyb0.js","assets/vendor-fuse.js-DB5wDJbI.js","assets/MobileDetailNavigation-DJXEYfq4.js","assets/utils-CTL16t2f.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/Icon-CLpn1mIz.js","assets/button-z0GOBtWi.js","assets/dialog-HCE4eLUW.js","assets/AgentAvatar-ziUs4sw3.js","assets/gitApi-DNTMAa3F.js","assets/useAppFontEffects-CKLSamae.js","assets/desktopHosts-C1Ns3DUu.js","assets/desktopRelayRestore-LBt0CBOj.js","assets/vendor-simplewebauthn-browser-Dwhcdg_5.js","assets/projectMeta-DNWx6Uva.js","assets/input-BG3VWTIF.js","assets/tooltip-CtH61mQh.js","assets/OverlayScrollbar-C-jZ8ITG.js","assets/vendor-dnd-kit-core-CvWxUPdb.js","assets/vendor-dnd-kit-accessibility-BY5LhhUB.js","assets/vendor-dnd-kit-sortable-hHdP9lLb.js","assets/useSessionAutoCleanup-DxNgqJ8s.js","assets/radio-BEonIX1k.js","assets/vendor-codemirror-autocomplete-DHomsvW7.js","assets/vendor-codemirror-lang-angular-DShkBD6m.js","assets/vendor-codemirror-lang-json-CYJRHck9.js","assets/vendor-codemirror-lang-markdown-WORgx6ZD.js","assets/vendor-codemirror-lang-python-Du6XQ8Zw.js","assets/vendor-codemirror-legacy-modes-DuRAjNvB.js","assets/useThemeSystem-DMzWVJaW.js","assets/vendor-codemirror-language-data-BfYFhIH1.js","assets/markdownTheme-TdhQOZSN.js","assets/ChatContainer-CnOrdAgs.js","assets/useRuntimeAPIs-DSLXJybW.js","assets/insertionBoundaries-DMxuUnL_.js","assets/appThemeRegistry-DDWrniMM.js","assets/markdown-worker-y3ewaqAK.js","assets/markdownHeightCache-CvUyZT4q.js","assets/url-KeihbE0d.js","assets/useEffectiveDirectory-B3rbY1Kv.js","assets/FadeInOnReveal-BAlsRFJH.js","assets/useWorkerHighlightedLines-DiDF68LR.js","assets/vendor-tanstack-react-virtual-tlDgH6PG.js","assets/vendor-cmdk-CeAGfrLo.js","assets/vendor-aria-hidden-BbL3cEyI.js","assets/sortable-tabs-strip-Bj8N0VWf.js","assets/vendor-framer-motion-DFy_BSVd.js","assets/vendor-legendapp-list-WE32lwNk.js","assets/useFontPreferences-D8emhcNv.js","assets/terminalApi-CNqqwjfG.js","assets/MobileSurface-9Xh6WQkY.js","assets/collapsible-D9zJRpeB.js","assets/projectActions-CWvNGKfA.js","assets/ContextPanel-Cg_uCHzJ.js","assets/shikiHighlight-C9Cx56Qg.js","assets/vendor-codemirror-commands-C9DCaJ0C.js","assets/vendor-codemirror-search-D2SOgzph.js","assets/vendor-replit-codemirror-vim-CEibx3EP.js","assets/diagram-CoEqmReY.js","assets/vendor-react-drawio-ECtEwvbc.js","assets/vendor-zumer-snapdom-yq9vlCKr.js","assets/vendor-html-to-image-BDMm2v6d.js","assets/runtimeEndpointReset-CZQCYtVI.js","assets/vendor-cron-parser-CCD11YFT.js","assets/SettingsView-DyCZehFG.js","assets/vendor-yaml-DIcAK3EC.js","assets/vendor-qrcode-DAuVxiQR.js","assets/vendor-dijkstrajs-DztKuCwY.js","assets/AssistantView-DF4yXFgS.js","assets/fileQueries-Dnn15WsA.js","assets/src-2eFAiBLq.css","assets/main-ZNyIs3Sn.js","assets/useDesktopWindowControlsLayout-DJSkFfhT.js","assets/multirun-DU-wrxlG.js","assets/main-qSeeJRW1.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{n as e,t}from"./runtimeConfig-BTDIG7mX.js";import{o as n}from"./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js";/* empty css */var r=`true`,i=`false`,a=r===`true`,o=i===`true`;function s(e={}){let{immediate:t=!1,onNeedReload:r,onNeedRefresh:i,onOfflineReady:s,onRegistered:c,onRegisteredSW:l,onRegisterError:u}=e,d,f,p,m=async(e=!0)=>{await f,a||p?.()};async function h(){if(`serviceWorker`in navigator){if(d=await n(async()=>{let{Workbox:e}=await import(`./vendor-workbox-window-qnW0Nbv7.js`).then(e=>e.t);return{Workbox:e}},__vite__mapDeps([0,1])).then(({Workbox:e})=>new e(`/sw.js`,{scope:`/`,type:`classic`})).catch(e=>{u?.(e)}),!d)return;if(p=()=>{d?.messageSkipWaiting()},!o)if(a)d.addEventListener(`activated`,e=>{(e.isUpdate||e.isExternal)&&(r?r():window.location.reload())}),d.addEventListener(`installed`,e=>{e.isUpdate||s?.()});else{let e=!1,t=()=>{e=!0,d?.addEventListener(`controlling`,e=>{e.isUpdate&&(r?r():window.location.reload())}),i?.()};d.addEventListener(`installed`,n=>{n.isUpdate===void 0?n.isExternal===void 0?!e&&s?.():n.isExternal?t():!e&&s?.():n.isUpdate||s?.()}),d.addEventListener(`waiting`,t)}d.register({immediate:t}).then(e=>{l?l(`/sw.js`,e):c?.(e)}).catch(e=>{u?.(e)})}}return f=h(),m}window.__OPENCHAMBER_RUNTIME_APIS__=t();var c=()=>typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(`(pointer: coarse)`).matches,l=(()=>{let e=new URLSearchParams(window.location.search).get(`surface`);if(e===`mobile`)return`mobile`;if(e===`desktop`)return`desktop`;let t=Math.min(window.innerWidth||0,window.screen?.width||window.innerWidth||0),n=navigator.maxTouchPoints||0;return t>0&&t<=760&&(n>0||c())?`mobile`:`desktop`})();window.__OPENCHAMBER_SURFACE__=l;var u=()=>!(!(`serviceWorker`in navigator)||!window.isSecureContext||window.location.protocol!==`http:`&&window.location.protocol!==`https:`||document.prerendering||String(document.visibilityState)===`prerender`),d=e=>{let t=!1,n=()=>{t||u()&&(t=!0,e())},r=()=>{setTimeout(n,0)};document.readyState===`complete`?r():window.addEventListener(`load`,r,{once:!0}),(document.prerendering||String(document.visibilityState)===`prerender`)&&document.addEventListener(`visibilitychange`,n,{once:!0})},f=()=>{d(()=>{try{s({onRegisterError(e){console.warn(`[PWA] service worker registration skipped:`,e)}})}catch(e){console.warn(`[PWA] service worker registration skipped:`,e)}})},p=`openchamber.dev.module-reload`,m=(e,t)=>{console.error(`[openchamber] failed to load ${t}:`,e)};l===`mobile`?n(async()=>{let{renderMobileApp:e}=await import(`./renderMobileApp-B0Ix_uNo.js`);return{renderMobileApp:e}},__vite__mapDeps([2,1,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107])).then(({renderMobileApp:e})=>{try{sessionStorage.removeItem(p)}catch{}e(window.__OPENCHAMBER_RUNTIME_APIS__??t())}).catch(e=>m(e,`renderMobileApp`)):e().then(()=>n(()=>import(`./main-ZNyIs3Sn.js`),__vite__mapDeps([108,1,3,4,5,6,7,8,9,10,11,48,12,13,14,86,28,29,30,31,32,34,35,27,36,37,38,39,40,41,42,43,44,46,47,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,45,66,67,68,17,18,19,20,21,22,23,24,25,26,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,87,16,88,89,109,90,91,92,93,94,95,96,97,98,99,100,110,111,107]))).then(()=>{try{sessionStorage.removeItem(p)}catch{}}).catch(e=>m(e,`desktop main`)),f();
|