@openchambery/web 2.0.6-beta.1 → 2.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AssistantView-DsgpHe_G.js → AssistantView-DLUolSub.js} +3 -3
- package/dist/assets/{DiagramView-DuvXv4Od.js → DiagramView-B6h8-vCk.js} +1 -1
- package/dist/assets/MarkdownRenderer-DiqXtlPY.js +2 -0
- package/dist/assets/{MarkdownRendererImpl-D8C0rd-n.js → MarkdownRendererImpl-GIbIaefQ.js} +1 -1
- package/dist/assets/{MarkstreamRendererImpl-O8GZIsgu.js → MarkstreamRendererImpl-CGjsxaSN.js} +1 -1
- package/dist/assets/{MobileDetailNavigation-CIcwr5l8.js → MobileDetailNavigation-K0t7WpHc.js} +1 -1
- package/dist/assets/{MobileShareBridge-2SPCvQjG.js → MobileShareBridge-DO-CARuF.js} +1 -1
- package/dist/assets/MobileTabPageHeader-DqJxINvb.js +2 -0
- package/dist/assets/{MultiRunWindow-D5moWjkz.js → MultiRunWindow--JoVZi36.js} +1 -1
- package/dist/assets/OnboardingScreen-LRDK1g4i.js +1 -0
- package/dist/assets/{SettingsView-B3If_auS.js → SettingsView-CO0mECFt.js} +1 -1
- package/dist/assets/{SettingsWindow-k85IZlt2.js → SettingsWindow-BYAjBBLz.js} +1 -1
- package/dist/assets/{TerminalView-pP9uBt3N.js → TerminalView-CBqy3Pzs.js} +1 -1
- package/dist/assets/{ToolOutputDialog--awOsUnN.js → ToolOutputDialog-uV3vzudG.js} +1 -1
- package/dist/assets/{appThemeRegistry-CiKayBT8.js → appThemeRegistry-Dlr9-bh4.js} +1 -1
- package/dist/assets/{fileMentionTouchSelection-CX6vJThH.js → fileMentionTouchSelection-C23bTawL.js} +1 -1
- package/dist/assets/{gitApi-Di72KR8u.js → gitApi-DE2yWjO8.js} +1 -1
- package/dist/assets/{insertionBoundaries-DoGr0K7K.js → insertionBoundaries-DDPb68YA.js} +1 -1
- package/dist/assets/{main-DUlb_vFY.js → main-DXBjSgr-.js} +4 -4
- package/dist/assets/{main-fGTyaWcX.js → main-DpO16IIO.js} +2 -2
- package/dist/assets/{mcpQueries-CoEKBTbS.js → mcpQueries-ocXyPQro.js} +1 -1
- package/dist/assets/{miniChat-B6-ZOkuR.js → miniChat-Dx7eoX99.js} +2 -2
- package/dist/assets/{mobile-B-Aw9U4g.js → mobile-DmMf2oXY.js} +2 -2
- package/dist/assets/{multirun-B9PHKTdt.js → multirun-CH1Z9bM9.js} +1 -1
- package/dist/assets/{projectMeta-fCje5XPW.js → projectMeta-C73SSuR-.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-CutFNuSq.js → renderElectronMiniChatApp-b0n4c2JK.js} +2 -2
- package/dist/assets/{renderMobileApp-DIAA4Z7m.js → renderMobileApp-Dwh_0T_B.js} +4 -4
- package/dist/assets/{runtimeConfig-DSMeq4bP.js → runtimeConfig-CMJbqejT.js} +1 -1
- package/dist/assets/{runtimeEndpointReset-e5NSrhJU.js → runtimeEndpointReset-uDC_3SmP.js} +1 -1
- package/dist/assets/{sessionChangeSummary-CcJchTlD.js → sessionChangeSummary-Dkh6zTfg.js} +1 -1
- package/dist/assets/{sessionLookup-CQ2dDFlT.js → sessionLookup-CFAECzHw.js} +1 -1
- package/dist/assets/{useAppFontEffects-B65A3hwa.js → useAppFontEffects-DSU_Sv-3.js} +5 -5
- package/dist/assets/{useDesktopWindowControlsLayout-Do6pdnP_.js → useDesktopWindowControlsLayout-BTr8tajh.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-KtTREBSZ.js → useEffectiveDirectory-CFQzWp5y.js} +1 -1
- package/dist/assets/{useMobileNavigationStore-DQI782g6.js → useMobileNavigationStore-EUU6F5qa.js} +3 -3
- package/dist/assets/{useSessionAutoCleanup-pOtef-w4.js → useSessionAutoCleanup-HIVvSBYB.js} +1 -1
- package/dist/assets/{useWorkerHighlightedLines-ClpjfaPG.js → useWorkerHighlightedLines-CpujrTzr.js} +1 -1
- package/dist/index.html +2 -2
- package/dist/mini-chat.html +2 -2
- package/dist/mobile.html +2 -2
- package/package.json +1 -1
- package/dist/assets/MarkdownRenderer-MIrT5b9I.js +0 -2
- package/dist/assets/MobileTabPageHeader-Dxr3BYP1.js +0 -2
- package/dist/assets/OnboardingScreen-yRdQTR1M.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-capacitor-app-PzT84wSx.js","assets/rolldown-runtime-C0FnF6B9.js","assets/vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{f as e,g as t,h as n,l as r,p as i}from"./runtime-auth-D66yq6ie.js";import{a,d as o,f as s,p as c,u as l}from"./runtime-switch-BJM2k_uH.js";import{n as u,t as d}from"./runtime-fetch-CiqQd__Y.js";import{at as f}from"./persistence-Dnj1QOdX.js";import{t as ee}from"./desktopRelayRestore-g378BdZf.js";import{$ as te,A as ne,B as re,Ct as ie,D as ae,E as oe,F as se,H as ce,I as le,J as ue,L as de,M as fe,N as pe,P as me,Q as he,R as ge,S as _e,T as ve,U as ye,V as be,W as xe,X as Se,Y as p,Z as Ce,_ as we,_t as Te,a as Ee,at as De,b as Oe,bt as ke,c as Ae,ct as je,d as Me,dt as Ne,et as Pe,f as Fe,ft as Ie,g as Le,gt as Re,h as ze,ht as Be,i as Ve,j as He,k as Ue,l as We,lt as Ge,m as Ke,mt as qe,n as m,nt as Je,o as Ye,ot as Xe,p as Ze,pt as Qe,q as $e,s as et,st as tt,t as nt,tt as rt,u as it,ut as at,v as h,vt as ot,x as g,y as st,yt as _}from"./platform-wu6wSDfg.js";import{n as v,o as y}from"./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js";import{a as ct,c as lt,l as ut,n as dt,r as ft,s as pt,t as mt}from"./terminalApi-DXyzaX3K.js";import{t as b}from"./types-BuiqMmh_.js";import{n as x,t as S}from"./capgoAdapter-DCowZ2ab.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var ht=e=>{let t=e?.retry;return{maxRetries:t?.maxRetries??3,initialRetryDelay:t?.initialDelayMs??1e3,maxRetryDelay:t?.maxDelayMs??8e3,connectionTimeout:e?.connectionTimeoutMs??1e4}},gt=()=>({async createSession(e){return ft(e)},connect(e,t,n){let r=dt(e,t.onEvent,t.onError,ht(n));return{close:()=>r()}},async sendInput(e,t){await ut(e,t)},async resize(e){await pt(e.sessionId,e.cols,e.rows)},async close(e){await mt(e)},async restartSession(e,t){return lt(e,{cwd:t.cwd??``,cols:t.cols,rows:t.rows})},async forceKill(e){await ct(e)}}),_t=()=>({checkIsGitRepository:Ae,getGitStatus:de,getGitDiff:pe,getGitFileDiff:me,revertGitFile:Xe,stageGitFile:Ge,stageGitFiles:at,unstageGitFile:Be,unstageGitFiles:Re,stageGitHunk:Ne,unstageGitHunk:Te,revertGitHunk:tt,isLinkedWorktree:$e,getGitBranches:fe,deleteGitBranch:st,deleteRemoteBranch:_e,removeRemote:Pe,generateCommitMessage:oe,generatePullRequestDescription:ae,listGitWorktrees:p,validateGitWorktree:_,createGitWorktree:h,deleteGitWorktree:g,validateWorktreeDirectory:ke,canonicalizeWorktreeState:et,createGitCommit(e,t,n){return Le(e,t,n)},gitPush:ye,gitPull:ce,gitFetch:be,listGitStashes:ue,countGitStashFiles:Ke,stashGitChanges:Qe,applyGitStash:Ye,popGitStash:Ce,dropGitStash:ve,checkoutBranch:We,createBranch:ze,renameBranch:rt,getGitLog(e,t){return le(e,t)},getCommitFiles:Ue,getCurrentGitIdentity:He,hasLocalIdentity:xe,setGitIdentity:je,getGitIdentities:se,createGitIdentity:we,updateGitIdentity:ot,deleteGitIdentity:Oe,getRemotes:re,rebase:te,abortRebase:Ee,continueRebase:Ze,merge:Se,abortMerge:Ve,continueMerge:Fe,checkoutCommit:it,cherryPick:Me,revertCommit:De,resetToCommit:Je,stash:Ie,stashPop:qe,getConflictDetails:ne,worktree:{list:p,validate:_,bootstrapStatus:ge,preview:he,create:h,remove:g}}),C=e=>e.replace(/\\/g,`/`),vt=(e,t)=>({directory:C(t?.directory||t?.path||e),entries:(Array.isArray(t?.entries)?t.entries:[]).filter(e=>!!(e&&typeof e.name==`string`&&typeof e.path==`string`)).map(e=>({name:e.name,path:C(e.path),isDirectory:!!e.isDirectory}))}),w=(e,t)=>{let n=t||e?.();return n?{"x-opencode-directory":n}:void 0},yt=({getDirectory:e})=>({async listDirectory(t,n){let r=C(t),i=new URLSearchParams;r&&i.set(`path`,r),n?.respectGitignore&&i.set(`respectGitignore`,`true`);let a=await u(`/api/fs/list`,{query:i,headers:w(e)});if(!a.ok){let e=await a.json().catch(()=>({error:a.statusText}));throw Error(e.error||`Failed to list directory`)}return vt(r,await a.json())},async search(t){let n=new URLSearchParams,r=C(t.directory);r&&n.set(`directory`,r),n.set(`query`,t.query),n.set(`dirs`,`false`),n.set(`type`,`file`),typeof t.maxResults==`number`&&Number.isFinite(t.maxResults)&&n.set(`limit`,String(t.maxResults));let i=await u(`/api/find/file`,{query:n,headers:w(e)});if(!i.ok){let e=await i.json().catch(()=>({error:i.statusText}));throw Error(e.error||`Failed to search files`)}let a=await i.json();return(Array.isArray(a)?a:[]).map(e=>({path:C(`${r}/${e}`),preview:[C(e)]}))},async createDirectory(t){let n=C(t),r=await u(`/api/fs/mkdir`,{method:`POST`,headers:{"Content-Type":`application/json`,...w(e)},body:JSON.stringify({path:n})});if(!r.ok){let e=await r.json().catch(()=>({error:r.statusText}));throw Error(e.error||`Failed to create directory`)}let i=await r.json();return{success:!!i?.success,path:typeof i?.path==`string`?C(i.path):n}},async statFile(t,n){let r=C(t),i=new URLSearchParams({path:r});n?.allowOutsideWorkspace&&i.set(`allowOutsideWorkspace`,`true`),n?.outsideFileGrant&&i.set(`outsideFileGrant`,n.outsideFileGrant);let a=await u(`/api/fs/stat`,{query:i,headers:w(e,n?.directory)});if(!a.ok){let e=await a.json().catch(()=>({error:a.statusText}));throw Error(e.error||`Failed to stat file`)}let o=await a.json().catch(()=>({}));return{path:typeof o.path==`string`?C(o.path):r,isFile:!!o.isFile,size:typeof o.size==`number`?o.size:0,mtimeMs:typeof o.mtimeMs==`number`?o.mtimeMs:void 0,isBinary:typeof o.isBinary==`boolean`?o.isBinary:void 0}},async readFile(t,n){let r=C(t),i=new URLSearchParams({path:r});n?.allowOutsideWorkspace&&i.set(`allowOutsideWorkspace`,`true`),n?.outsideFileGrant&&i.set(`outsideFileGrant`,n.outsideFileGrant),n?.optional&&i.set(`optional`,`true`);let a=await u(`/api/fs/read`,{query:i,cache:n?.optional?`no-store`:`default`,headers:w(e,n?.directory)});if(!a.ok){let e=await a.json().catch(()=>({error:a.statusText}));throw Error(e.error||`Failed to read file`)}let o=await a.text();if(n?.optional){let e=a.headers.get(`x-openchamber-file-exists`);if(e!==`true`&&e!==`false`)throw Error(`Optional file read requires an existence response header`);return{content:o,path:r,exists:e===`true`}}return{content:o,path:r,exists:!0}},async writeFile(t,n){let r=C(t),i=await u(`/api/fs/write`,{method:`POST`,headers:{"Content-Type":`application/json`,...w(e)},body:JSON.stringify({path:r,content:n})});if(!i.ok){let e=await i.json().catch(()=>({error:i.statusText}));throw Error(e.error||`Failed to write file`)}let a=await i.json().catch(()=>({}));return{success:!!a.success,path:typeof a.path==`string`?C(a.path):r}},async delete(t){let n=C(t),r=await u(`/api/fs/delete`,{method:`POST`,headers:{"Content-Type":`application/json`,...w(e)},body:JSON.stringify({path:n})});if(!r.ok){let e=await r.json().catch(()=>({error:r.statusText}));throw Error(e.error||`Failed to delete file`)}return{success:!!(await r.json().catch(()=>({}))).success}},async rename(t,n){let r=await u(`/api/fs/rename`,{method:`POST`,headers:{"Content-Type":`application/json`,...w(e)},body:JSON.stringify({oldPath:t,newPath:n})});if(!r.ok){let e=await r.json().catch(()=>({error:r.statusText}));throw Error(e.error||`Failed to rename file`)}let i=await r.json().catch(()=>({}));return{success:!!i.success,path:typeof i.path==`string`?C(i.path):n}},async revealPath(t){let n=await u(`/api/fs/reveal`,{method:`POST`,headers:{"Content-Type":`application/json`,...w(e)},body:JSON.stringify({path:C(t)})});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to reveal path`)}return{success:!!(await n.json().catch(()=>({}))).success}},async downloadFile(t){let n=C(t),r=await u(`/api/fs/raw`,{query:{path:n,download:!0},headers:w(e)});if(!r.ok)throw Error(`Download failed (${r.status})`);let i=await r.blob(),a=URL.createObjectURL(i),o=document.createElement(`a`);o.href=a,o.download=n.split(`/`).pop()||`file`,document.body.appendChild(o),o.click(),document.body.removeChild(o),setTimeout(()=>URL.revokeObjectURL(a),100)}}),T=`/api/config/settings`,bt=`/api/config/reload`,E=e=>!e||typeof e!=`object`?{}:e,xt=()=>({async load(){let e=await u(T,{method:`GET`,headers:{Accept:`application/json`}});if(!e.ok)throw Error(`Failed to load settings: ${e.statusText}`);return{settings:E(await e.json().catch(()=>({}))),source:`web`}},async save(e){let t=await u(T,{method:`PUT`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(e)});if(!t.ok){let e=await t.json().catch(()=>({error:t.statusText}));throw Error(e.error||`Failed to save settings`)}return E(await t.json().catch(()=>({})))},async restartOpenCode(){let e=await u(bt,{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({error:e.statusText}));throw Error(t.error||`Failed to restart OpenCode`)}return{restarted:!0}}}),St=()=>({async requestDirectoryAccess(e){return{success:!0,path:e.path}},async startAccessingDirectory(e){return{success:!0}},async stopAccessingDirectory(e){return{success:!0}}}),Ct=1500,D=5e3,wt=`openchamber-notification-claim:`,O=new Map,Tt=()=>typeof document>`u`||document.visibilityState===`visible`&&document.hasFocus(),Et=e=>(typeof e?.tag==`string`?e.tag.trim():``)||[e?.sessionId,e?.kind,e?.title,e?.body].filter(e=>typeof e==`string`&&e.trim().length>0).map(e=>e.trim()).join(`|`),Dt=e=>{for(let[t,n]of O)e-n>D&&O.delete(t)},Ot=e=>{let t=Et(e);if(!t)return!0;let n=Date.now();if(Dt(n),n-(O.get(t)??0)<D)return!1;try{if(typeof window<`u`&&window.localStorage){let e=`${wt}${t}`,r=Number(window.localStorage.getItem(e)??`0`);if(Number.isFinite(r)&&n-r<D)return O.set(t,r),!1;Number.isFinite(r)&&r>0&&window.localStorage.removeItem(e),window.localStorage.setItem(e,String(n))}}catch{}return O.set(t,n),!0},k=async()=>{if(typeof navigator>`u`||!(`serviceWorker`in navigator))return null;let e=null;try{e=await navigator.serviceWorker.getRegistration()??null}catch{e=null}if(e?.active)return e;if(!e)return null;try{return await Promise.race([navigator.serviceWorker.ready,new Promise(e=>{setTimeout(()=>e(null),Ct)})])??e}catch{return e}},kt=async e=>{let t=await k();if(!t||typeof t.showNotification!=`function`)return!1;try{return await t.showNotification(e?.title??`OpenChamber`,{body:e?.body,tag:e?.tag}),!0}catch(e){return console.warn(`Failed to send notification via service worker`,e),!1}},At=async()=>{let e=await k();if(!e||!(`pushManager`in e)||!e.pushManager)return!1;try{return!!await e.pushManager.getSubscription()}catch{return!1}},jt=async e=>{if(e?.requireHidden&&typeof document<`u`&&document.hasFocus())return!0;if(typeof Notification>`u`)return!1;if(Notification.permission==="default"&&await Notification.requestPermission()!==`granted`||Notification.permission!==`granted`)return console.warn(`Notification permission not granted`),!1;if(!Tt()&&await At()||!Ot(e))return!0;try{return await kt(e)||new Notification(e?.title??`OpenChamber`,{body:e?.body,tag:e?.tag}),!0}catch(e){return console.warn(`Failed to send notification`,e),!1}},Mt=async e=>{if(typeof window>`u`)return!1;let t=window.__OPENCHAMBER_DESKTOP__;if(!t?.invoke)return!1;try{return await t.invoke(`desktop_notify`,{payload:{title:e?.title,body:e?.body,tag:e?.tag,kind:e?.kind,sessionId:e?.sessionId,directory:e?.directory,requireHidden:e?.requireHidden}}),!0}catch(e){return console.warn(`Failed to send native notification (desktop)`,e),!1}},Nt=()=>({async notifyAgentCompletion(e){return await Mt(e)||await jt(e)},canNotify:()=>typeof window<`u`&&window.__OPENCHAMBER_DESKTOP__?.invoke?!0:typeof Notification<`u`&&Notification.permission===`granted`}),Pt=()=>({async getAvailableTools(){let e=await u(`/api/experimental/tool/ids`);if(!e.ok)throw Error(`Tools API returned ${e.status} ${e.statusText}`);let t=await e.json();if(!Array.isArray(t))throw Error(`Tools API returned invalid data format`);return t.filter(e=>typeof e==`string`&&e!==`invalid`).sort()}}),A=async(e,t)=>{try{let n=await u(e,{...t,credentials:`include`,headers:{Accept:`application/json`,...t?.headers??{}}});return n.ok?await n.json():null}catch{return null}},Ft=()=>({async getVapidPublicKey(){return A(`/api/push/vapid-public-key`)},async subscribe(e){return A(`/api/push/subscribe`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})},async unsubscribe(e){return A(`/api/push/subscribe`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})},async setVisibility(e){return A(`/api/push/visibility`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e),keepalive:!0})},async registerApnsToken(e){return A(`/api/push/apns-token`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})},async unregisterApnsToken(e){return A(`/api/push/apns-token`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})},async registerLiveActivityToken(e){return A(`/api/push/live-activity-token`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})},async unregisterLiveActivityToken(e){return A(`/api/push/live-activity-token`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})}}),j=async e=>await e.json().catch(()=>null),It=({urls:e})=>({async authStatus(){let e=await u(`/api/github/auth/status`,{method:`GET`,headers:{Accept:`application/json`}}),t=await j(e);if(!e.ok||!t)throw Error(t?.error||e.statusText||`Failed to load GitHub status`);return t},async authStart(){let e=await u(`/api/github/auth/start`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({})}),t=await j(e);if(!e.ok||!t||!(`deviceCode`in t))throw Error(t?.error||e.statusText||`Failed to start GitHub auth`);return t},async authComplete(e){let t=await u(`/api/github/auth/complete`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({deviceCode:e})}),n=await j(t);if(!t.ok||!n)throw Error(n?.error||t.statusText||`Failed to complete GitHub auth`);return n},async authDisconnect(){let e=await u(`/api/github/auth`,{method:`DELETE`,headers:{Accept:`application/json`}}),t=await j(e);if(!e.ok)throw Error(t?.error||e.statusText||`Failed to disconnect GitHub`);return{removed:!!t?.removed}},async authActivate(e){let t=await u(`/api/github/auth/activate`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({accountId:e})}),n=await j(t);if(!t.ok||!n)throw Error(n?.error||t.statusText||`Failed to activate GitHub account`);return n},async authSetGhCliDisabled(e){let t=await u(`/api/github/auth/gh-cli`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({disabled:e})}),n=await j(t);if(!t.ok||!n)throw Error(n?.error||t.statusText||`Failed to update gh CLI setting`);return{disabled:!!n.disabled}},async me(){let e=await u(`/api/github/me`,{method:`GET`,headers:{Accept:`application/json`}}),t=await j(e);if(!e.ok||!t)throw Error(t?.error||e.statusText||`Failed to fetch GitHub user`);return t},async prStatus(e,t,n,r){let i=new URLSearchParams({directory:e,branch:t,...n?{remote:n}:{},...r?.force?{force:`true`}:{}}),a=await u(`/api/github/pr/status?${i.toString()}`,{method:`GET`,headers:{Accept:`application/json`}}),o=await j(a);if(!a.ok||!o)throw Error(o?.error||a.statusText||`Failed to load PR status`);return o},async prCreate(e){let t=await u(`/api/github/pr/create`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(e)}),n=await j(t);if(!t.ok||!n)throw Error(n?.error||t.statusText||`Failed to create PR`);return n},async prUpdate(e){let t=await u(`/api/github/pr/update`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(e)}),n=await j(t);if(!t.ok||!n)throw Error(n?.error||t.statusText||`Failed to update PR`);return n},async prMerge(e){let t=await u(`/api/github/pr/merge`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(e)}),n=await j(t);if(!t.ok||!n)throw Error(n?.error||t.statusText||`Failed to merge PR`);return n},async prReady(e){let t=await u(`/api/github/pr/ready`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(e)}),n=await j(t);if(!t.ok||!n)throw Error(n?.error||t.statusText||`Failed to mark PR ready`);return n},async repoUpstream(e){let t=await u(`/api/github/repo/upstream?directory=${encodeURIComponent(e)}`,{method:`GET`,headers:{Accept:`application/json`}}),n=await j(t);if(!t.ok||!n)throw Error(n?.error||t.statusText||`Failed to detect upstream repo`);return n},async repoBranches(e,t){let n=await u(`/api/github/repo/branches?owner=${encodeURIComponent(e)}&repo=${encodeURIComponent(t)}`,{method:`GET`,headers:{Accept:`application/json`}}),r=await j(n);if(!n.ok||!r)throw Error(r?.error||n.statusText||`Failed to fetch repo branches`);return r.branches??[]},async prsList(e,t){let n=t?.page??1,r=new URLSearchParams({directory:e,page:String(n)});t?.query&&r.set(`query`,t.query);let i=await u(`/api/github/pulls/list?${r.toString()}`,{method:`GET`,headers:{Accept:`application/json`}}),a=await j(i);if(!i.ok||!a)throw Error(a?.error||i.statusText||`Failed to load pull requests`);return a},async prContext(t,n,r){let i=new URLSearchParams({directory:t,number:String(n)});r?.includeDiff&&i.set(`diff`,`1`),r?.includeCheckDetails&&i.set(`checkDetails`,`1`),r?.sourceRepo?.owner&&r.sourceRepo.repo&&(i.set(`owner`,r.sourceRepo.owner),i.set(`repo`,r.sourceRepo.repo));let a=await u(e.api(`/api/github/pulls/context`,i),{method:`GET`,headers:{Accept:`application/json`}}),o=await j(a);if(!a.ok||!o)throw Error(o?.error||a.statusText||`Failed to load pull request context`);return o},async issuesList(e,t){let n=t?.page??1,r=new URLSearchParams({directory:e,page:String(n)});t?.query&&r.set(`query`,t.query);let i=await u(`/api/github/issues/list?${r.toString()}`,{method:`GET`,headers:{Accept:`application/json`}}),a=await j(i);if(!i.ok||!a)throw Error(a?.error||i.statusText||`Failed to load issues`);return a},async issueGet(t,n,r){let i=new URLSearchParams({directory:t,number:String(n)});r?.sourceRepo?.owner&&r.sourceRepo.repo&&(i.set(`owner`,r.sourceRepo.owner),i.set(`repo`,r.sourceRepo.repo));let a=await u(e.api(`/api/github/issues/get`,i),{method:`GET`,headers:{Accept:`application/json`}}),o=await j(a);if(!a.ok||!o)throw Error(o?.error||a.statusText||`Failed to load issue`);return o},async issueComments(t,n,r){let i=new URLSearchParams({directory:t,number:String(n)});r?.sourceRepo?.owner&&r.sourceRepo.repo&&(i.set(`owner`,r.sourceRepo.owner),i.set(`repo`,r.sourceRepo.repo));let a=await u(e.api(`/api/github/issues/comments`,i),{method:`GET`,headers:{Accept:`application/json`}}),o=await j(a);if(!a.ok||!o)throw Error(o?.error||a.statusText||`Failed to load issue comments`);return o}}),M=async e=>await e.json().catch(()=>null),Lt=()=>({async listClients(){let e=await u(`/api/client-auth/clients`,{method:`GET`,headers:{Accept:`application/json`}}),t=await M(e);if(!e.ok||!t)throw Error(t?.error||e.statusText||`Failed to load remote clients`);return Array.isArray(t.clients)?t.clients:[]},async createClient(e={}){let t=await u(`/api/client-auth/clients`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({label:e.label??``})}),n=await M(t);if(!t.ok||!n?.client||typeof n.token!=`string`)throw Error(n?.error||t.statusText||`Failed to create remote client token`);return n},async createPairingSession(e={}){let t=await u(`/api/client-auth/pairing/sessions`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({label:e.label??``,...e.allowedClientKinds?{allowedClientKinds:e.allowedClientKinds}:{},...e.serverUrl?{serverUrl:e.serverUrl}:{},...typeof e.includeRelay==`boolean`?{includeRelay:e.includeRelay}:{},...typeof e.includeDirect==`boolean`?{includeDirect:e.includeDirect}:{},...e.relayUrl?{relayUrl:e.relayUrl}:{}})}),n=await M(t);if(!t.ok||typeof n?.pairing?.secret!=`string`||!n?.server)throw Error(n?.error||t.statusText||`Failed to create pairing session`);return n},async listPendingPairings(){let e=await u(`/api/client-auth/pairing/sessions`,{method:`GET`,headers:{Accept:`application/json`}}),t=await M(e);if(!e.ok||!t)throw Error(t?.error||e.statusText||`Failed to load pending pairings`);return Array.isArray(t.pending)?t.pending:[]},async getPairingTransports(){let e=await u(`/api/client-auth/pairing/transports`,{method:`GET`,headers:{Accept:`application/json`}}),t=await M(e);if(!e.ok||!t)throw Error(t?.error||e.statusText||`Failed to load pairing transports`);return{local:t.local??null,lan:t.lan??null,relayAvailable:t.relayAvailable===!0,...typeof t.relayUrl==`string`?{relayUrl:t.relayUrl}:{},...typeof t.relayUrlLocked==`boolean`?{relayUrlLocked:t.relayUrlLocked}:{}}},async cancelPairing(e){let t=await u(`/api/client-auth/pairing/sessions/${encodeURIComponent(e)}`,{method:`DELETE`,headers:{Accept:`application/json`}}),n=await M(t);if(!t.ok||!n)throw Error(n?.error||t.statusText||`Failed to cancel pairing`);return{cancelled:n.cancelled===!0}},async renameClient(e,t){let n=await u(`/api/client-auth/clients/${encodeURIComponent(e)}`,{method:`PATCH`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({label:t})}),r=await M(n);if(!n.ok||!r?.client)throw Error(r?.error||n.statusText||`Failed to rename remote client`);return r.client},async revokeClient(e){let t=await u(`/api/client-auth/clients/${encodeURIComponent(e)}`,{method:`DELETE`,headers:{Accept:`application/json`}}),n=await M(t);if(!t.ok||!n)throw Error(n?.error||t.statusText||`Failed to revoke remote client`);return n},async purgeRevokedClients(){let e=await u(`/api/client-auth/clients`,{method:`DELETE`,headers:{Accept:`application/json`}}),t=await M(e);if(!e.ok||!t)throw Error(t?.error||e.statusText||`Failed to clear revoked clients`);return t}}),N=e=>typeof e==`object`&&!!e&&!Array.isArray(e),P=e=>typeof e==`number`&&Number.isFinite(e),Rt=e=>{if(!N(e)||typeof e.ok!=`boolean`)return!1;if(e.ok===!0)return N(e.session)&&typeof e.session.id==`string`&&typeof e.messageID==`string`;let t=e.phase;if(typeof t!=`string`)return!1;switch(t){case`validate`:return typeof e.error==`string`&&Array.isArray(e.errors)&&e.errors.every(e=>typeof e==`string`);case`create`:return!(typeof e.error!=`string`||`status`in e&&e.status!==void 0&&!P(e.status));case`prompt`:return N(e.session)&&typeof e.session.id==`string`&&typeof e.messageID==`string`&&typeof e.ambiguous==`boolean`&&typeof e.error==`string`&&(!(`status`in e)||e.status===void 0||P(e.status));case`conflict`:return typeof e.error==`string`;case`unavailable`:return typeof e.error==`string`;case`internal`:return typeof e.error==`string`;default:return!1}},zt=()=>({async createWithPrompt(e,t){let n;try{n=await u(`/api/openchamber/conversations`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e),signal:t})}catch{throw Error(`Conversation request failed`)}let r;try{r=await n.json()}catch{throw Error(`Unexpected server response: invalid JSON`)}if(!Rt(r))throw Error(`Unexpected server response: result shape mismatch`);return r}}),Bt=`https://openchamber.xiaobe.top/v1/mobile/update/check`,Vt=`https://openchamber-update.vercel.app/v1/mobile/update/check`,Ht=1e4,F=`openchamber.mobile-ota.device-id.v1`,I=e=>typeof e==`string`&&e.trim().length>0?e.trim():null,L=()=>{try{let e=v;return((typeof e.getConfig==`function`?e.getConfig():void 0)??e.config)?.OpenChamberOTA??{}}catch{return{}}},R=e=>e===`beta`||e===`stable`?e:L().channel===`stable`?`stable`:`beta`,z=()=>{let e=L().shellApiVersion;return typeof e==`number`&&Number.isFinite(e)&&e>0?Math.floor(e):1},B=()=>{let e=nt();if(e===`ios`||e===`android`)return e;try{let e=v.getPlatform();if(e===`ios`||e===`android`)return e}catch{}return`android`},Ut=()=>{if(typeof window>`u`)return null;try{return I(window.localStorage.getItem(F))}catch{return null}},V=e=>{if(!(typeof window>`u`))try{window.localStorage.setItem(F,e)}catch{}},H=async e=>{if(e)try{let t=I((await e.getDeviceId()).deviceId);if(t)return V(t),t}catch{}let t=Ut();if(t)return t;let n=f();return V(n),n},U=async()=>{let e=I(`2.0.6-beta.1`);if(m())try{let{App:t}=await y(async()=>{let{App:e}=await import(`./vendor-capacitor-app-PzT84wSx.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([0,1,2])),n=await t.getInfo(),r=I(n.version)??e??`0.0.0`,i=I(n.build),a=i?Number.parseInt(i,10):0;return{version:r,build:Number.isFinite(a)?a:0}}catch{}return{version:e??`0.0.0`,build:0}},W=(e,t,n)=>{let r=I(e?.version),i=I(t);if(n===`beta`&&i)return i;if(r&&r!==`builtin`)return i&&i!==r&&i.startsWith(`${r}-`)?i:r;let a=I(e?.id);return a&&a!==`builtin`?a:i??`builtin`},Wt=()=>I(`2.0.6-beta.1`),G=e=>{let t=e?.trim().match(/^v?(\d+)\.\d+\.\d+(?:-beta\.\d+)?$/i),n=t?Number(t[1]):void 0;return n!==void 0&&Number.isSafeInteger(n)?n:void 0},K=async(e,t)=>{let n=Wt();if(!e)return W(null,n,t);try{return W((await e.current()).bundle,n,t)}catch{return W(null,n,t)}},Gt=()=>[Bt,Vt],Kt=(e,t,n)=>{let r=e-n();return r<=0||t<=0?null:Math.max(1,Math.ceil(r/t))};async function qt(e,t,n,r){try{if(m())try{let{CapacitorHttp:r}=await y(async()=>{let{CapacitorHttp:e}=await import(`./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js`).then(e=>e.i);return{CapacitorHttp:e}},__vite__mapDeps([2,1])),i=Object.fromEntries(new Headers(t.headers).entries()),a;if(typeof t.body==`string`)try{a=JSON.parse(t.body)}catch{a=t.body}let o=await Promise.race([r.request({url:e,method:t.method||`GET`,headers:i,data:a,connectTimeout:n,readTimeout:n}),new Promise(e=>{window.setTimeout(()=>e(null),n)})]);return o?{ok:o.status>=200&&o.status<300,status:o.status,json:async()=>{if(typeof o.data==`string`)try{return JSON.parse(o.data)}catch{return o.data}return o.data}}:null}catch{}let i=await r(e,{...t,signal:AbortSignal.timeout(n)});return{ok:i.ok,status:i.status,json:()=>i.json()}}catch{return null}}var Jt=e=>{if(!e||typeof e!=`object`)return!1;let t=e;return!(t.status!==`ok`||t.primaryAction!==`none`&&t.primaryAction!==`apply_ota`&&t.primaryAction!==`install_native_required`||!t.ota||typeof t.ota!=`object`||!t.native||typeof t.native!=`object`||typeof t.nextCheckInSec!=`number`||!Number.isFinite(t.nextCheckInSec))},Yt=e=>{let t=e;return t.isChannelRollback===!0||t.is_channel_rollback===!0?{...e,isChannelRollback:!0}:e};async function Xt(e,t,n,r){let i=await qt(e,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify(t)},n,r);if(!i?.ok)return null;let a;try{a=await i.json()}catch{return null}if(!Jt(a))return null;if(a.primaryAction===`apply_ota`&&(t.releaseMajor===void 0||G(a.ota.bundle?.releaseVersion)!==t.releaseMajor))throw Error(`OTA release major mismatch`);return Yt(a)}async function Zt(e={}){let t=e.updater===void 0?await S():e.updater;if(!t&&!m())throw new b;let n=e.fetchImpl??fetch,r=e.now??Date.now,i=R(e.channelOverride),[a,o,s]=await Promise.all([H(t),U(),K(t,i)]),c={channel:i,platform:B(),deviceId:a,nativeVersion:o.version,nativeBuild:o.build,shellApiVersion:z(),currentBundleId:s,releaseMajor:G(s)??G(o.version)},l=Gt(),u=r()+Ht,d=null;for(let[e,t]of l.entries()){let i=Kt(u,l.length-e,r);if(i===null)break;try{let e=await Xt(t,c,i,n);if(e)return e;d=Error(`Mobile OTA check failed at ${t}`)}catch(e){d=e instanceof Error?e:Error(`Mobile OTA check failed`)}}throw d??Error(`Unable to check for mobile OTA updates`)}async function Qt(e){let t=await S();if(!t)return null;let n=await J({updater:t});if(n.releaseMajor===void 0||G(e.releaseVersion)!==n.releaseMajor)throw Error(`OTA release major mismatch`);try{let{bundles:n}=await t.list();return n.find(t=>t.checksum===e.checksum&&t.version===e.releaseVersion&&(t.status===`success`||t.status===`pending`))?.id??null}catch{return null}}async function $t(e){let t=await S();if(!t)throw new b;let n=await J({updater:t});if(n.releaseMajor===void 0||G(e.releaseVersion)!==n.releaseMajor)throw Error(`OTA release major mismatch`);return(await t.download({url:e.url,version:e.releaseVersion,checksum:e.checksum,...e.sessionKey?{sessionKey:e.sessionKey}:{}})).id}async function q(){let e=await S();if(!e)throw new b;await e.reload()}async function en(e){let t=await S();if(!t)throw new b;await t.next({id:e})}async function J(e={}){let t=e.updater===void 0?await S():e.updater,n=R(e.channelOverride),[r,i,a]=await Promise.all([H(t),U(),K(t,n)]);return{channel:n,platform:B(),deviceId:r,nativeVersion:i.version,nativeBuild:i.build,shellApiVersion:z(),currentBundleId:a,releaseMajor:G(a)??G(i.version)}}var Y=null,X=e=>typeof e==`string`&&e.trim().length>0?e.trim():null,Z=async()=>{let e=X(`2.0.6-beta.1`);try{if(v.isNativePlatform()){let{App:t}=await y(async()=>{let{App:e}=await import(`./vendor-capacitor-app-PzT84wSx.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([0,1,2]));return X((await t.getInfo()).version)??e??`unknown`}}catch{}return e??`unknown`},tn=()=>({async checkForOtaUpdate(e){if(!x()&&!v.isNativePlatform())throw new b;return Zt(e?.channelOverride?{channelOverride:e.channelOverride}:{})},async downloadOtaUpdate(e){if(!x())throw new b;let t=await Qt(e);return t?(Y=t,{skipped:!0}):(Y=await $t(e),{skipped:!1})},async applyOtaUpdateNow(){if(!x())throw new b;await q()},async queueOtaUpdateForNextLaunch(){if(!x())throw new b;let e=Y;if(!e)throw Error(`No downloaded OTA bundle to queue`);await en(e)},async getOtaStatus(){if(!x())return{supported:!1,currentBundleId:`builtin`,nativeVersion:await Z()};let e=await S();if(!e)return{supported:!1,currentBundleId:`builtin`,nativeVersion:await Z()};try{let[t,n]=await Promise.all([e.current(),Z()]);return{supported:!0,currentBundleId:X(t.bundle?.id)||`builtin`,nativeVersion:n}}catch{return{supported:!0,currentBundleId:`builtin`,nativeVersion:await Z()}}}}),nn=()=>({api:(...e)=>s().api(...e),authenticatedAsset:(...e)=>s().authenticatedAsset(...e),auth:(...e)=>s().auth(...e),health:(...e)=>s().health(...e),rawFile:(...e)=>s().rawFile(...e),sse:(...e)=>s().sse(...e),websocket:(...e)=>s().websocket(...e)}),rn=(e={})=>{let t=e.urls??o();c(t);let n=nn();return{runtime:{platform:`web`,isDesktop:!1,isVSCode:!1,label:`web`},terminal:gt(),git:_t(),files:yt({urls:n,getDirectory:()=>ie.getState().currentDirectory}),settings:xt(),permissions:St(),notifications:Nt(),github:It({urls:n}),push:Ft(),mobileUpdates:tn(),clientAuth:Lt(),tools:Pt(),conversations:zt()}},Q=(e,t)=>{if(!e||!t)return!1;try{return new URL(e).origin===new URL(t).origin}catch{return!1}},$=Promise.resolve(),an=()=>$,on=()=>{let o=typeof window.__OPENCHAMBER_API_BASE_URL__==`string`?window.__OPENCHAMBER_API_BASE_URL__.trim():``,s=typeof window.__OPENCHAMBER_CLIENT_TOKEN__==`string`?window.__OPENCHAMBER_CLIENT_TOKEN__.trim():``,c=typeof window.__OPENCHAMBER_LOCAL_ORIGIN__==`string`?window.__OPENCHAMBER_LOCAL_ORIGIN__.trim():``,u=l({apiBaseUrl:o||void 0,realtimeBaseUrl:o||void 0});a({apiBaseUrl:o,runtimeKey:Q(o,c)?`local`:null}),n(s||null),t(window.__OPENCHAMBER_RUNTIME_HEADERS__||null),i(o||void 0).catch(()=>{}),c&&!Q(o,c)&&Object.keys(r()).length>0&&e(c).catch(()=>{}),d();let f=window.__OPENCHAMBER_RELAY_HOST_ID__;return $=Promise.race([ee(typeof f==`string`&&f?f:void 0).catch(()=>{}),new Promise(e=>{window.setTimeout(e,1e4)})]),rn({urls:u})};export{an as n,on as t};
|
|
2
|
+
import{f as e,g as t,h as n,l as r,p as i}from"./runtime-auth-D66yq6ie.js";import{a,d as o,f as s,p as c,u as l}from"./runtime-switch-BJM2k_uH.js";import{n as u,t as d}from"./runtime-fetch-CiqQd__Y.js";import{at as f}from"./persistence-Dnj1QOdX.js";import{t as ee}from"./desktopRelayRestore-g378BdZf.js";import{$ as te,A as ne,B as re,Ct as ie,D as ae,E as oe,F as se,H as ce,I as le,J as ue,L as de,M as fe,N as pe,P as me,Q as he,R as ge,S as _e,T as ve,U as ye,V as be,W as xe,X as Se,Y as p,Z as Ce,_ as we,_t as Te,a as Ee,at as De,b as Oe,bt as ke,c as Ae,ct as je,d as Me,dt as Ne,et as Pe,f as Fe,ft as Ie,g as Le,gt as Re,h as ze,ht as Be,i as Ve,j as He,k as Ue,l as We,lt as Ge,m as Ke,mt as qe,n as m,nt as Je,o as Ye,ot as Xe,p as Ze,pt as Qe,q as $e,s as et,st as tt,t as nt,tt as rt,u as it,ut as at,v as h,vt as ot,x as g,y as st,yt as _}from"./platform-wu6wSDfg.js";import{n as v,o as y}from"./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js";import{a as ct,c as lt,l as ut,n as dt,r as ft,s as pt,t as mt}from"./terminalApi-DXyzaX3K.js";import{t as b}from"./types-BuiqMmh_.js";import{n as x,t as S}from"./capgoAdapter-DCowZ2ab.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var ht=e=>{let t=e?.retry;return{maxRetries:t?.maxRetries??3,initialRetryDelay:t?.initialDelayMs??1e3,maxRetryDelay:t?.maxDelayMs??8e3,connectionTimeout:e?.connectionTimeoutMs??1e4}},gt=()=>({async createSession(e){return ft(e)},connect(e,t,n){let r=dt(e,t.onEvent,t.onError,ht(n));return{close:()=>r()}},async sendInput(e,t){await ut(e,t)},async resize(e){await pt(e.sessionId,e.cols,e.rows)},async close(e){await mt(e)},async restartSession(e,t){return lt(e,{cwd:t.cwd??``,cols:t.cols,rows:t.rows})},async forceKill(e){await ct(e)}}),_t=()=>({checkIsGitRepository:Ae,getGitStatus:de,getGitDiff:pe,getGitFileDiff:me,revertGitFile:Xe,stageGitFile:Ge,stageGitFiles:at,unstageGitFile:Be,unstageGitFiles:Re,stageGitHunk:Ne,unstageGitHunk:Te,revertGitHunk:tt,isLinkedWorktree:$e,getGitBranches:fe,deleteGitBranch:st,deleteRemoteBranch:_e,removeRemote:Pe,generateCommitMessage:oe,generatePullRequestDescription:ae,listGitWorktrees:p,validateGitWorktree:_,createGitWorktree:h,deleteGitWorktree:g,validateWorktreeDirectory:ke,canonicalizeWorktreeState:et,createGitCommit(e,t,n){return Le(e,t,n)},gitPush:ye,gitPull:ce,gitFetch:be,listGitStashes:ue,countGitStashFiles:Ke,stashGitChanges:Qe,applyGitStash:Ye,popGitStash:Ce,dropGitStash:ve,checkoutBranch:We,createBranch:ze,renameBranch:rt,getGitLog(e,t){return le(e,t)},getCommitFiles:Ue,getCurrentGitIdentity:He,hasLocalIdentity:xe,setGitIdentity:je,getGitIdentities:se,createGitIdentity:we,updateGitIdentity:ot,deleteGitIdentity:Oe,getRemotes:re,rebase:te,abortRebase:Ee,continueRebase:Ze,merge:Se,abortMerge:Ve,continueMerge:Fe,checkoutCommit:it,cherryPick:Me,revertCommit:De,resetToCommit:Je,stash:Ie,stashPop:qe,getConflictDetails:ne,worktree:{list:p,validate:_,bootstrapStatus:ge,preview:he,create:h,remove:g}}),C=e=>e.replace(/\\/g,`/`),vt=(e,t)=>({directory:C(t?.directory||t?.path||e),entries:(Array.isArray(t?.entries)?t.entries:[]).filter(e=>!!(e&&typeof e.name==`string`&&typeof e.path==`string`)).map(e=>({name:e.name,path:C(e.path),isDirectory:!!e.isDirectory}))}),w=(e,t)=>{let n=t||e?.();return n?{"x-opencode-directory":n}:void 0},yt=({getDirectory:e})=>({async listDirectory(t,n){let r=C(t),i=new URLSearchParams;r&&i.set(`path`,r),n?.respectGitignore&&i.set(`respectGitignore`,`true`);let a=await u(`/api/fs/list`,{query:i,headers:w(e)});if(!a.ok){let e=await a.json().catch(()=>({error:a.statusText}));throw Error(e.error||`Failed to list directory`)}return vt(r,await a.json())},async search(t){let n=new URLSearchParams,r=C(t.directory);r&&n.set(`directory`,r),n.set(`query`,t.query),n.set(`dirs`,`false`),n.set(`type`,`file`),typeof t.maxResults==`number`&&Number.isFinite(t.maxResults)&&n.set(`limit`,String(t.maxResults));let i=await u(`/api/find/file`,{query:n,headers:w(e)});if(!i.ok){let e=await i.json().catch(()=>({error:i.statusText}));throw Error(e.error||`Failed to search files`)}let a=await i.json();return(Array.isArray(a)?a:[]).map(e=>({path:C(`${r}/${e}`),preview:[C(e)]}))},async createDirectory(t){let n=C(t),r=await u(`/api/fs/mkdir`,{method:`POST`,headers:{"Content-Type":`application/json`,...w(e)},body:JSON.stringify({path:n})});if(!r.ok){let e=await r.json().catch(()=>({error:r.statusText}));throw Error(e.error||`Failed to create directory`)}let i=await r.json();return{success:!!i?.success,path:typeof i?.path==`string`?C(i.path):n}},async statFile(t,n){let r=C(t),i=new URLSearchParams({path:r});n?.allowOutsideWorkspace&&i.set(`allowOutsideWorkspace`,`true`),n?.outsideFileGrant&&i.set(`outsideFileGrant`,n.outsideFileGrant);let a=await u(`/api/fs/stat`,{query:i,headers:w(e,n?.directory)});if(!a.ok){let e=await a.json().catch(()=>({error:a.statusText}));throw Error(e.error||`Failed to stat file`)}let o=await a.json().catch(()=>({}));return{path:typeof o.path==`string`?C(o.path):r,isFile:!!o.isFile,size:typeof o.size==`number`?o.size:0,mtimeMs:typeof o.mtimeMs==`number`?o.mtimeMs:void 0,isBinary:typeof o.isBinary==`boolean`?o.isBinary:void 0}},async readFile(t,n){let r=C(t),i=new URLSearchParams({path:r});n?.allowOutsideWorkspace&&i.set(`allowOutsideWorkspace`,`true`),n?.outsideFileGrant&&i.set(`outsideFileGrant`,n.outsideFileGrant),n?.optional&&i.set(`optional`,`true`);let a=await u(`/api/fs/read`,{query:i,cache:n?.optional?`no-store`:`default`,headers:w(e,n?.directory)});if(!a.ok){let e=await a.json().catch(()=>({error:a.statusText}));throw Error(e.error||`Failed to read file`)}let o=await a.text();if(n?.optional){let e=a.headers.get(`x-openchamber-file-exists`);if(e!==`true`&&e!==`false`)throw Error(`Optional file read requires an existence response header`);return{content:o,path:r,exists:e===`true`}}return{content:o,path:r,exists:!0}},async writeFile(t,n){let r=C(t),i=await u(`/api/fs/write`,{method:`POST`,headers:{"Content-Type":`application/json`,...w(e)},body:JSON.stringify({path:r,content:n})});if(!i.ok){let e=await i.json().catch(()=>({error:i.statusText}));throw Error(e.error||`Failed to write file`)}let a=await i.json().catch(()=>({}));return{success:!!a.success,path:typeof a.path==`string`?C(a.path):r}},async delete(t){let n=C(t),r=await u(`/api/fs/delete`,{method:`POST`,headers:{"Content-Type":`application/json`,...w(e)},body:JSON.stringify({path:n})});if(!r.ok){let e=await r.json().catch(()=>({error:r.statusText}));throw Error(e.error||`Failed to delete file`)}return{success:!!(await r.json().catch(()=>({}))).success}},async rename(t,n){let r=await u(`/api/fs/rename`,{method:`POST`,headers:{"Content-Type":`application/json`,...w(e)},body:JSON.stringify({oldPath:t,newPath:n})});if(!r.ok){let e=await r.json().catch(()=>({error:r.statusText}));throw Error(e.error||`Failed to rename file`)}let i=await r.json().catch(()=>({}));return{success:!!i.success,path:typeof i.path==`string`?C(i.path):n}},async revealPath(t){let n=await u(`/api/fs/reveal`,{method:`POST`,headers:{"Content-Type":`application/json`,...w(e)},body:JSON.stringify({path:C(t)})});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to reveal path`)}return{success:!!(await n.json().catch(()=>({}))).success}},async downloadFile(t){let n=C(t),r=await u(`/api/fs/raw`,{query:{path:n,download:!0},headers:w(e)});if(!r.ok)throw Error(`Download failed (${r.status})`);let i=await r.blob(),a=URL.createObjectURL(i),o=document.createElement(`a`);o.href=a,o.download=n.split(`/`).pop()||`file`,document.body.appendChild(o),o.click(),document.body.removeChild(o),setTimeout(()=>URL.revokeObjectURL(a),100)}}),T=`/api/config/settings`,bt=`/api/config/reload`,E=e=>!e||typeof e!=`object`?{}:e,xt=()=>({async load(){let e=await u(T,{method:`GET`,headers:{Accept:`application/json`}});if(!e.ok)throw Error(`Failed to load settings: ${e.statusText}`);return{settings:E(await e.json().catch(()=>({}))),source:`web`}},async save(e){let t=await u(T,{method:`PUT`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(e)});if(!t.ok){let e=await t.json().catch(()=>({error:t.statusText}));throw Error(e.error||`Failed to save settings`)}return E(await t.json().catch(()=>({})))},async restartOpenCode(){let e=await u(bt,{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({error:e.statusText}));throw Error(t.error||`Failed to restart OpenCode`)}return{restarted:!0}}}),St=()=>({async requestDirectoryAccess(e){return{success:!0,path:e.path}},async startAccessingDirectory(e){return{success:!0}},async stopAccessingDirectory(e){return{success:!0}}}),Ct=1500,D=5e3,wt=`openchamber-notification-claim:`,O=new Map,Tt=()=>typeof document>`u`||document.visibilityState===`visible`&&document.hasFocus(),Et=e=>(typeof e?.tag==`string`?e.tag.trim():``)||[e?.sessionId,e?.kind,e?.title,e?.body].filter(e=>typeof e==`string`&&e.trim().length>0).map(e=>e.trim()).join(`|`),Dt=e=>{for(let[t,n]of O)e-n>D&&O.delete(t)},Ot=e=>{let t=Et(e);if(!t)return!0;let n=Date.now();if(Dt(n),n-(O.get(t)??0)<D)return!1;try{if(typeof window<`u`&&window.localStorage){let e=`${wt}${t}`,r=Number(window.localStorage.getItem(e)??`0`);if(Number.isFinite(r)&&n-r<D)return O.set(t,r),!1;Number.isFinite(r)&&r>0&&window.localStorage.removeItem(e),window.localStorage.setItem(e,String(n))}}catch{}return O.set(t,n),!0},k=async()=>{if(typeof navigator>`u`||!(`serviceWorker`in navigator))return null;let e=null;try{e=await navigator.serviceWorker.getRegistration()??null}catch{e=null}if(e?.active)return e;if(!e)return null;try{return await Promise.race([navigator.serviceWorker.ready,new Promise(e=>{setTimeout(()=>e(null),Ct)})])??e}catch{return e}},kt=async e=>{let t=await k();if(!t||typeof t.showNotification!=`function`)return!1;try{return await t.showNotification(e?.title??`OpenChamber`,{body:e?.body,tag:e?.tag}),!0}catch(e){return console.warn(`Failed to send notification via service worker`,e),!1}},At=async()=>{let e=await k();if(!e||!(`pushManager`in e)||!e.pushManager)return!1;try{return!!await e.pushManager.getSubscription()}catch{return!1}},jt=async e=>{if(e?.requireHidden&&typeof document<`u`&&document.hasFocus())return!0;if(typeof Notification>`u`)return!1;if(Notification.permission==="default"&&await Notification.requestPermission()!==`granted`||Notification.permission!==`granted`)return console.warn(`Notification permission not granted`),!1;if(!Tt()&&await At()||!Ot(e))return!0;try{return await kt(e)||new Notification(e?.title??`OpenChamber`,{body:e?.body,tag:e?.tag}),!0}catch(e){return console.warn(`Failed to send notification`,e),!1}},Mt=async e=>{if(typeof window>`u`)return!1;let t=window.__OPENCHAMBER_DESKTOP__;if(!t?.invoke)return!1;try{return await t.invoke(`desktop_notify`,{payload:{title:e?.title,body:e?.body,tag:e?.tag,kind:e?.kind,sessionId:e?.sessionId,directory:e?.directory,requireHidden:e?.requireHidden}}),!0}catch(e){return console.warn(`Failed to send native notification (desktop)`,e),!1}},Nt=()=>({async notifyAgentCompletion(e){return await Mt(e)||await jt(e)},canNotify:()=>typeof window<`u`&&window.__OPENCHAMBER_DESKTOP__?.invoke?!0:typeof Notification<`u`&&Notification.permission===`granted`}),Pt=()=>({async getAvailableTools(){let e=await u(`/api/experimental/tool/ids`);if(!e.ok)throw Error(`Tools API returned ${e.status} ${e.statusText}`);let t=await e.json();if(!Array.isArray(t))throw Error(`Tools API returned invalid data format`);return t.filter(e=>typeof e==`string`&&e!==`invalid`).sort()}}),A=async(e,t)=>{try{let n=await u(e,{...t,credentials:`include`,headers:{Accept:`application/json`,...t?.headers??{}}});return n.ok?await n.json():null}catch{return null}},Ft=()=>({async getVapidPublicKey(){return A(`/api/push/vapid-public-key`)},async subscribe(e){return A(`/api/push/subscribe`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})},async unsubscribe(e){return A(`/api/push/subscribe`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})},async setVisibility(e){return A(`/api/push/visibility`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e),keepalive:!0})},async registerApnsToken(e){return A(`/api/push/apns-token`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})},async unregisterApnsToken(e){return A(`/api/push/apns-token`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})},async registerLiveActivityToken(e){return A(`/api/push/live-activity-token`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})},async unregisterLiveActivityToken(e){return A(`/api/push/live-activity-token`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})}}),j=async e=>await e.json().catch(()=>null),It=({urls:e})=>({async authStatus(){let e=await u(`/api/github/auth/status`,{method:`GET`,headers:{Accept:`application/json`}}),t=await j(e);if(!e.ok||!t)throw Error(t?.error||e.statusText||`Failed to load GitHub status`);return t},async authStart(){let e=await u(`/api/github/auth/start`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({})}),t=await j(e);if(!e.ok||!t||!(`deviceCode`in t))throw Error(t?.error||e.statusText||`Failed to start GitHub auth`);return t},async authComplete(e){let t=await u(`/api/github/auth/complete`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({deviceCode:e})}),n=await j(t);if(!t.ok||!n)throw Error(n?.error||t.statusText||`Failed to complete GitHub auth`);return n},async authDisconnect(){let e=await u(`/api/github/auth`,{method:`DELETE`,headers:{Accept:`application/json`}}),t=await j(e);if(!e.ok)throw Error(t?.error||e.statusText||`Failed to disconnect GitHub`);return{removed:!!t?.removed}},async authActivate(e){let t=await u(`/api/github/auth/activate`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({accountId:e})}),n=await j(t);if(!t.ok||!n)throw Error(n?.error||t.statusText||`Failed to activate GitHub account`);return n},async authSetGhCliDisabled(e){let t=await u(`/api/github/auth/gh-cli`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({disabled:e})}),n=await j(t);if(!t.ok||!n)throw Error(n?.error||t.statusText||`Failed to update gh CLI setting`);return{disabled:!!n.disabled}},async me(){let e=await u(`/api/github/me`,{method:`GET`,headers:{Accept:`application/json`}}),t=await j(e);if(!e.ok||!t)throw Error(t?.error||e.statusText||`Failed to fetch GitHub user`);return t},async prStatus(e,t,n,r){let i=new URLSearchParams({directory:e,branch:t,...n?{remote:n}:{},...r?.force?{force:`true`}:{}}),a=await u(`/api/github/pr/status?${i.toString()}`,{method:`GET`,headers:{Accept:`application/json`}}),o=await j(a);if(!a.ok||!o)throw Error(o?.error||a.statusText||`Failed to load PR status`);return o},async prCreate(e){let t=await u(`/api/github/pr/create`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(e)}),n=await j(t);if(!t.ok||!n)throw Error(n?.error||t.statusText||`Failed to create PR`);return n},async prUpdate(e){let t=await u(`/api/github/pr/update`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(e)}),n=await j(t);if(!t.ok||!n)throw Error(n?.error||t.statusText||`Failed to update PR`);return n},async prMerge(e){let t=await u(`/api/github/pr/merge`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(e)}),n=await j(t);if(!t.ok||!n)throw Error(n?.error||t.statusText||`Failed to merge PR`);return n},async prReady(e){let t=await u(`/api/github/pr/ready`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(e)}),n=await j(t);if(!t.ok||!n)throw Error(n?.error||t.statusText||`Failed to mark PR ready`);return n},async repoUpstream(e){let t=await u(`/api/github/repo/upstream?directory=${encodeURIComponent(e)}`,{method:`GET`,headers:{Accept:`application/json`}}),n=await j(t);if(!t.ok||!n)throw Error(n?.error||t.statusText||`Failed to detect upstream repo`);return n},async repoBranches(e,t){let n=await u(`/api/github/repo/branches?owner=${encodeURIComponent(e)}&repo=${encodeURIComponent(t)}`,{method:`GET`,headers:{Accept:`application/json`}}),r=await j(n);if(!n.ok||!r)throw Error(r?.error||n.statusText||`Failed to fetch repo branches`);return r.branches??[]},async prsList(e,t){let n=t?.page??1,r=new URLSearchParams({directory:e,page:String(n)});t?.query&&r.set(`query`,t.query);let i=await u(`/api/github/pulls/list?${r.toString()}`,{method:`GET`,headers:{Accept:`application/json`}}),a=await j(i);if(!i.ok||!a)throw Error(a?.error||i.statusText||`Failed to load pull requests`);return a},async prContext(t,n,r){let i=new URLSearchParams({directory:t,number:String(n)});r?.includeDiff&&i.set(`diff`,`1`),r?.includeCheckDetails&&i.set(`checkDetails`,`1`),r?.sourceRepo?.owner&&r.sourceRepo.repo&&(i.set(`owner`,r.sourceRepo.owner),i.set(`repo`,r.sourceRepo.repo));let a=await u(e.api(`/api/github/pulls/context`,i),{method:`GET`,headers:{Accept:`application/json`}}),o=await j(a);if(!a.ok||!o)throw Error(o?.error||a.statusText||`Failed to load pull request context`);return o},async issuesList(e,t){let n=t?.page??1,r=new URLSearchParams({directory:e,page:String(n)});t?.query&&r.set(`query`,t.query);let i=await u(`/api/github/issues/list?${r.toString()}`,{method:`GET`,headers:{Accept:`application/json`}}),a=await j(i);if(!i.ok||!a)throw Error(a?.error||i.statusText||`Failed to load issues`);return a},async issueGet(t,n,r){let i=new URLSearchParams({directory:t,number:String(n)});r?.sourceRepo?.owner&&r.sourceRepo.repo&&(i.set(`owner`,r.sourceRepo.owner),i.set(`repo`,r.sourceRepo.repo));let a=await u(e.api(`/api/github/issues/get`,i),{method:`GET`,headers:{Accept:`application/json`}}),o=await j(a);if(!a.ok||!o)throw Error(o?.error||a.statusText||`Failed to load issue`);return o},async issueComments(t,n,r){let i=new URLSearchParams({directory:t,number:String(n)});r?.sourceRepo?.owner&&r.sourceRepo.repo&&(i.set(`owner`,r.sourceRepo.owner),i.set(`repo`,r.sourceRepo.repo));let a=await u(e.api(`/api/github/issues/comments`,i),{method:`GET`,headers:{Accept:`application/json`}}),o=await j(a);if(!a.ok||!o)throw Error(o?.error||a.statusText||`Failed to load issue comments`);return o}}),M=async e=>await e.json().catch(()=>null),Lt=()=>({async listClients(){let e=await u(`/api/client-auth/clients`,{method:`GET`,headers:{Accept:`application/json`}}),t=await M(e);if(!e.ok||!t)throw Error(t?.error||e.statusText||`Failed to load remote clients`);return Array.isArray(t.clients)?t.clients:[]},async createClient(e={}){let t=await u(`/api/client-auth/clients`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({label:e.label??``})}),n=await M(t);if(!t.ok||!n?.client||typeof n.token!=`string`)throw Error(n?.error||t.statusText||`Failed to create remote client token`);return n},async createPairingSession(e={}){let t=await u(`/api/client-auth/pairing/sessions`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({label:e.label??``,...e.allowedClientKinds?{allowedClientKinds:e.allowedClientKinds}:{},...e.serverUrl?{serverUrl:e.serverUrl}:{},...typeof e.includeRelay==`boolean`?{includeRelay:e.includeRelay}:{},...typeof e.includeDirect==`boolean`?{includeDirect:e.includeDirect}:{},...e.relayUrl?{relayUrl:e.relayUrl}:{}})}),n=await M(t);if(!t.ok||typeof n?.pairing?.secret!=`string`||!n?.server)throw Error(n?.error||t.statusText||`Failed to create pairing session`);return n},async listPendingPairings(){let e=await u(`/api/client-auth/pairing/sessions`,{method:`GET`,headers:{Accept:`application/json`}}),t=await M(e);if(!e.ok||!t)throw Error(t?.error||e.statusText||`Failed to load pending pairings`);return Array.isArray(t.pending)?t.pending:[]},async getPairingTransports(){let e=await u(`/api/client-auth/pairing/transports`,{method:`GET`,headers:{Accept:`application/json`}}),t=await M(e);if(!e.ok||!t)throw Error(t?.error||e.statusText||`Failed to load pairing transports`);return{local:t.local??null,lan:t.lan??null,relayAvailable:t.relayAvailable===!0,...typeof t.relayUrl==`string`?{relayUrl:t.relayUrl}:{},...typeof t.relayUrlLocked==`boolean`?{relayUrlLocked:t.relayUrlLocked}:{}}},async cancelPairing(e){let t=await u(`/api/client-auth/pairing/sessions/${encodeURIComponent(e)}`,{method:`DELETE`,headers:{Accept:`application/json`}}),n=await M(t);if(!t.ok||!n)throw Error(n?.error||t.statusText||`Failed to cancel pairing`);return{cancelled:n.cancelled===!0}},async renameClient(e,t){let n=await u(`/api/client-auth/clients/${encodeURIComponent(e)}`,{method:`PATCH`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({label:t})}),r=await M(n);if(!n.ok||!r?.client)throw Error(r?.error||n.statusText||`Failed to rename remote client`);return r.client},async revokeClient(e){let t=await u(`/api/client-auth/clients/${encodeURIComponent(e)}`,{method:`DELETE`,headers:{Accept:`application/json`}}),n=await M(t);if(!t.ok||!n)throw Error(n?.error||t.statusText||`Failed to revoke remote client`);return n},async purgeRevokedClients(){let e=await u(`/api/client-auth/clients`,{method:`DELETE`,headers:{Accept:`application/json`}}),t=await M(e);if(!e.ok||!t)throw Error(t?.error||e.statusText||`Failed to clear revoked clients`);return t}}),N=e=>typeof e==`object`&&!!e&&!Array.isArray(e),P=e=>typeof e==`number`&&Number.isFinite(e),Rt=e=>{if(!N(e)||typeof e.ok!=`boolean`)return!1;if(e.ok===!0)return N(e.session)&&typeof e.session.id==`string`&&typeof e.messageID==`string`;let t=e.phase;if(typeof t!=`string`)return!1;switch(t){case`validate`:return typeof e.error==`string`&&Array.isArray(e.errors)&&e.errors.every(e=>typeof e==`string`);case`create`:return!(typeof e.error!=`string`||`status`in e&&e.status!==void 0&&!P(e.status));case`prompt`:return N(e.session)&&typeof e.session.id==`string`&&typeof e.messageID==`string`&&typeof e.ambiguous==`boolean`&&typeof e.error==`string`&&(!(`status`in e)||e.status===void 0||P(e.status));case`conflict`:return typeof e.error==`string`;case`unavailable`:return typeof e.error==`string`;case`internal`:return typeof e.error==`string`;default:return!1}},zt=()=>({async createWithPrompt(e,t){let n;try{n=await u(`/api/openchamber/conversations`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e),signal:t})}catch{throw Error(`Conversation request failed`)}let r;try{r=await n.json()}catch{throw Error(`Unexpected server response: invalid JSON`)}if(!Rt(r))throw Error(`Unexpected server response: result shape mismatch`);return r}}),Bt=`https://openchamber.xiaobe.top/v1/mobile/update/check`,Vt=`https://openchamber-update.vercel.app/v1/mobile/update/check`,Ht=1e4,F=`openchamber.mobile-ota.device-id.v1`,I=e=>typeof e==`string`&&e.trim().length>0?e.trim():null,L=()=>{try{let e=v;return((typeof e.getConfig==`function`?e.getConfig():void 0)??e.config)?.OpenChamberOTA??{}}catch{return{}}},R=e=>e===`beta`||e===`stable`?e:L().channel===`stable`?`stable`:`beta`,z=()=>{let e=L().shellApiVersion;return typeof e==`number`&&Number.isFinite(e)&&e>0?Math.floor(e):1},B=()=>{let e=nt();if(e===`ios`||e===`android`)return e;try{let e=v.getPlatform();if(e===`ios`||e===`android`)return e}catch{}return`android`},Ut=()=>{if(typeof window>`u`)return null;try{return I(window.localStorage.getItem(F))}catch{return null}},V=e=>{if(!(typeof window>`u`))try{window.localStorage.setItem(F,e)}catch{}},H=async e=>{if(e)try{let t=I((await e.getDeviceId()).deviceId);if(t)return V(t),t}catch{}let t=Ut();if(t)return t;let n=f();return V(n),n},U=async()=>{let e=I(`2.0.6`);if(m())try{let{App:t}=await y(async()=>{let{App:e}=await import(`./vendor-capacitor-app-PzT84wSx.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([0,1,2])),n=await t.getInfo(),r=I(n.version)??e??`0.0.0`,i=I(n.build),a=i?Number.parseInt(i,10):0;return{version:r,build:Number.isFinite(a)?a:0}}catch{}return{version:e??`0.0.0`,build:0}},W=(e,t,n)=>{let r=I(e?.version),i=I(t);if(n===`beta`&&i)return i;if(r&&r!==`builtin`)return i&&i!==r&&i.startsWith(`${r}-`)?i:r;let a=I(e?.id);return a&&a!==`builtin`?a:i??`builtin`},Wt=()=>I(`2.0.6`),G=e=>{let t=e?.trim().match(/^v?(\d+)\.\d+\.\d+(?:-beta\.\d+)?$/i),n=t?Number(t[1]):void 0;return n!==void 0&&Number.isSafeInteger(n)?n:void 0},K=async(e,t)=>{let n=Wt();if(!e)return W(null,n,t);try{return W((await e.current()).bundle,n,t)}catch{return W(null,n,t)}},Gt=()=>[Bt,Vt],Kt=(e,t,n)=>{let r=e-n();return r<=0||t<=0?null:Math.max(1,Math.ceil(r/t))};async function qt(e,t,n,r){try{if(m())try{let{CapacitorHttp:r}=await y(async()=>{let{CapacitorHttp:e}=await import(`./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js`).then(e=>e.i);return{CapacitorHttp:e}},__vite__mapDeps([2,1])),i=Object.fromEntries(new Headers(t.headers).entries()),a;if(typeof t.body==`string`)try{a=JSON.parse(t.body)}catch{a=t.body}let o=await Promise.race([r.request({url:e,method:t.method||`GET`,headers:i,data:a,connectTimeout:n,readTimeout:n}),new Promise(e=>{window.setTimeout(()=>e(null),n)})]);return o?{ok:o.status>=200&&o.status<300,status:o.status,json:async()=>{if(typeof o.data==`string`)try{return JSON.parse(o.data)}catch{return o.data}return o.data}}:null}catch{}let i=await r(e,{...t,signal:AbortSignal.timeout(n)});return{ok:i.ok,status:i.status,json:()=>i.json()}}catch{return null}}var Jt=e=>{if(!e||typeof e!=`object`)return!1;let t=e;return!(t.status!==`ok`||t.primaryAction!==`none`&&t.primaryAction!==`apply_ota`&&t.primaryAction!==`install_native_required`||!t.ota||typeof t.ota!=`object`||!t.native||typeof t.native!=`object`||typeof t.nextCheckInSec!=`number`||!Number.isFinite(t.nextCheckInSec))},Yt=e=>{let t=e;return t.isChannelRollback===!0||t.is_channel_rollback===!0?{...e,isChannelRollback:!0}:e};async function Xt(e,t,n,r){let i=await qt(e,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify(t)},n,r);if(!i?.ok)return null;let a;try{a=await i.json()}catch{return null}if(!Jt(a))return null;if(a.primaryAction===`apply_ota`&&(t.releaseMajor===void 0||G(a.ota.bundle?.releaseVersion)!==t.releaseMajor))throw Error(`OTA release major mismatch`);return Yt(a)}async function Zt(e={}){let t=e.updater===void 0?await S():e.updater;if(!t&&!m())throw new b;let n=e.fetchImpl??fetch,r=e.now??Date.now,i=R(e.channelOverride),[a,o,s]=await Promise.all([H(t),U(),K(t,i)]),c={channel:i,platform:B(),deviceId:a,nativeVersion:o.version,nativeBuild:o.build,shellApiVersion:z(),currentBundleId:s,releaseMajor:G(s)??G(o.version)},l=Gt(),u=r()+Ht,d=null;for(let[e,t]of l.entries()){let i=Kt(u,l.length-e,r);if(i===null)break;try{let e=await Xt(t,c,i,n);if(e)return e;d=Error(`Mobile OTA check failed at ${t}`)}catch(e){d=e instanceof Error?e:Error(`Mobile OTA check failed`)}}throw d??Error(`Unable to check for mobile OTA updates`)}async function Qt(e){let t=await S();if(!t)return null;let n=await J({updater:t});if(n.releaseMajor===void 0||G(e.releaseVersion)!==n.releaseMajor)throw Error(`OTA release major mismatch`);try{let{bundles:n}=await t.list();return n.find(t=>t.checksum===e.checksum&&t.version===e.releaseVersion&&(t.status===`success`||t.status===`pending`))?.id??null}catch{return null}}async function $t(e){let t=await S();if(!t)throw new b;let n=await J({updater:t});if(n.releaseMajor===void 0||G(e.releaseVersion)!==n.releaseMajor)throw Error(`OTA release major mismatch`);return(await t.download({url:e.url,version:e.releaseVersion,checksum:e.checksum,...e.sessionKey?{sessionKey:e.sessionKey}:{}})).id}async function q(){let e=await S();if(!e)throw new b;await e.reload()}async function en(e){let t=await S();if(!t)throw new b;await t.next({id:e})}async function J(e={}){let t=e.updater===void 0?await S():e.updater,n=R(e.channelOverride),[r,i,a]=await Promise.all([H(t),U(),K(t,n)]);return{channel:n,platform:B(),deviceId:r,nativeVersion:i.version,nativeBuild:i.build,shellApiVersion:z(),currentBundleId:a,releaseMajor:G(a)??G(i.version)}}var Y=null,X=e=>typeof e==`string`&&e.trim().length>0?e.trim():null,Z=async()=>{let e=X(`2.0.6`);try{if(v.isNativePlatform()){let{App:t}=await y(async()=>{let{App:e}=await import(`./vendor-capacitor-app-PzT84wSx.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([0,1,2]));return X((await t.getInfo()).version)??e??`unknown`}}catch{}return e??`unknown`},tn=()=>({async checkForOtaUpdate(e){if(!x()&&!v.isNativePlatform())throw new b;return Zt(e?.channelOverride?{channelOverride:e.channelOverride}:{})},async downloadOtaUpdate(e){if(!x())throw new b;let t=await Qt(e);return t?(Y=t,{skipped:!0}):(Y=await $t(e),{skipped:!1})},async applyOtaUpdateNow(){if(!x())throw new b;await q()},async queueOtaUpdateForNextLaunch(){if(!x())throw new b;let e=Y;if(!e)throw Error(`No downloaded OTA bundle to queue`);await en(e)},async getOtaStatus(){if(!x())return{supported:!1,currentBundleId:`builtin`,nativeVersion:await Z()};let e=await S();if(!e)return{supported:!1,currentBundleId:`builtin`,nativeVersion:await Z()};try{let[t,n]=await Promise.all([e.current(),Z()]);return{supported:!0,currentBundleId:X(t.bundle?.id)||`builtin`,nativeVersion:n}}catch{return{supported:!0,currentBundleId:`builtin`,nativeVersion:await Z()}}}}),nn=()=>({api:(...e)=>s().api(...e),authenticatedAsset:(...e)=>s().authenticatedAsset(...e),auth:(...e)=>s().auth(...e),health:(...e)=>s().health(...e),rawFile:(...e)=>s().rawFile(...e),sse:(...e)=>s().sse(...e),websocket:(...e)=>s().websocket(...e)}),rn=(e={})=>{let t=e.urls??o();c(t);let n=nn();return{runtime:{platform:`web`,isDesktop:!1,isVSCode:!1,label:`web`},terminal:gt(),git:_t(),files:yt({urls:n,getDirectory:()=>ie.getState().currentDirectory}),settings:xt(),permissions:St(),notifications:Nt(),github:It({urls:n}),push:Ft(),mobileUpdates:tn(),clientAuth:Lt(),tools:Pt(),conversations:zt()}},Q=(e,t)=>{if(!e||!t)return!1;try{return new URL(e).origin===new URL(t).origin}catch{return!1}},$=Promise.resolve(),an=()=>$,on=()=>{let o=typeof window.__OPENCHAMBER_API_BASE_URL__==`string`?window.__OPENCHAMBER_API_BASE_URL__.trim():``,s=typeof window.__OPENCHAMBER_CLIENT_TOKEN__==`string`?window.__OPENCHAMBER_CLIENT_TOKEN__.trim():``,c=typeof window.__OPENCHAMBER_LOCAL_ORIGIN__==`string`?window.__OPENCHAMBER_LOCAL_ORIGIN__.trim():``,u=l({apiBaseUrl:o||void 0,realtimeBaseUrl:o||void 0});a({apiBaseUrl:o,runtimeKey:Q(o,c)?`local`:null}),n(s||null),t(window.__OPENCHAMBER_RUNTIME_HEADERS__||null),i(o||void 0).catch(()=>{}),c&&!Q(o,c)&&Object.keys(r()).length>0&&e(c).catch(()=>{}),d();let f=window.__OPENCHAMBER_RELAY_HOST_ID__;return $=Promise.race([ee(typeof f==`string`&&f?f:void 0).catch(()=>{}),new Promise(e=>{window.setTimeout(e,1e4)})]),rn({urls:u})};export{an as n,on as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{c as t,i as n,n as r,o as i,r as a,s as o}from"./runtime-switch-BJM2k_uH.js";import{n as s}from"./runtime-fetch-CiqQd__Y.js";import{En as c,Ht as l,It as u,d,en as f,f as p,ft as m,it as h,on as g,pn as _,rn as v,sn as y,wn as b}from"./persistence-Dnj1QOdX.js";import{a as x,i as S,o as C}from"./vendor-zustand-DzRqcymP.js";import{nt as w,o as T,rt as E,s as D,tt as O}from"./vendor-base-ui-CnHfUmDN.js";import{Ct as k,Mt as A,Nt as j,lr as M,r as N}from"./platform-wu6wSDfg.js";import{n as P,t as F,x as I}from"./useUIStore-Dfx6TKvi.js";import{n as L}from"./vendor-react-DLPElpoQ.js";import{l as R,n as z,o as B,s as V,t as ee}from"./vendor-tanstack-react-query-D7pys_c9.js";import{i as H}from"./terminalApi-DXyzaX3K.js";import{c as U,d as W,f as te,l as G,m as K,n as ne,o as re,p as ie,s as q,t as ae,u as J}from"./vendor-pierre-diffs-DX7XTPG3.js";import{r as oe}from"./vendor-sonner-DVzioF3d.js";import{l as se,n as ce,p as le,r as ue}from"./vendor-reactuses-core-Dq5ocTF8.js";import{d as de,f as fe,i as pe,l as me,p as he,r as Y,t as X,u as ge}from"./button-CUwjpv-i.js";import{i as _e,t as ve}from"./store-l_X_jQNz.js";import{A as ye,D as be,E as xe,O as Se,k as Ce,t as we}from"./MobileDetailNavigation-CIcwr5l8.js";import{$n as Te,An as Ee,Ar as De,Cn as Oe,Cr as ke,Er as Ae,Fr as je,Gt as Me,Ht as Ne,Ir as Pe,Mr as Fe,Or as Ie,Pr as Le,Sn as Re,Vt as ze,Wn as Be,Xr as Ve,Yn as He,Zr as Ue,aa as We,br as Ge,cn as Ke,co as qe,d as Je,fi as Ye,fo as Xe,ga as Ze,go as Qe,jn as $e,jr as et,ka as tt,kr as nt,mi as rt,mo as it,o as at,oo as ot,so as st,ti as ct,va as lt,wr as ut,xn as dt,yi as ft}from"./useMobileNavigationStore-DQI782g6.js";import{i as pt,t as mt}from"./useAssistantUIStore-DBwfg9nX.js";import{a as ht,i as gt,n as _t,o as vt,r as yt,t as bt}from"./dialog-PjKWayIU.js";import{t as xt}from"./AgentAvatar-C1MGZ7qC.js";import{n as Z}from"./Icon-BdzPRCSy.js";import{d as St}from"./gitApi-Di72KR8u.js";import{$ as Ct,B as wt,E as Tt,J as Et,Mt as Dt,Q as Ot,Rt as kt,V as At,X as jt,_t as Mt,c as Nt,et as Pt,gt as Ft,it as It,lt as Lt,mt as Rt,nt as zt,o as Bt,pt as Vt,rt as Ht,s as Ut,tt as Wt,vt as Gt}from"./useAppFontEffects-B65A3hwa.js";import{A as Kt,_ as qt,a as Jt,b as Yt,d as Xt,f as Zt,h as Qt,i as $t,l as en,m as tn,n as nn,p as rn,r as an,s as on,t as sn,x as cn}from"./projectMeta-fCje5XPW.js";import{t as ln}from"./input-BeVw4D0W.js";import{i as un,n as dn,t as fn}from"./tooltip-DDNnmcXI.js";import{Dt as pn,Et as mn,J as hn,Rt as gn,Tt as _n,at as vn,ct as yn,gt as bn,h as xn,it as Sn,m as Cn,mt as wn,q as Tn,rt as En,st as Dn,tt as On,ut as kn,wt as An}from"./useSessionAutoCleanup-pOtef-w4.js";import{n as jn,t as Mn}from"./useThemeSystem-DMzWVJaW.js";import{i as Nn,t as Pn}from"./OverlayScrollbar-C1C2aKOe.js";import{s as Fn}from"./markdownTheme-DM5h1i18.js";import{n as In}from"./useRuntimeAPIs-DSLXJybW.js";import{C as Ln,g as Rn,h as zn,i as Bn,n as Vn,o as Hn,p as Un,r as Wn,t as Gn,x as Kn,y as qn}from"./textarea-Kl-rTWJe.js";import{D as Jn}from"./sessionChangeSummary-CcJchTlD.js";import{D as Yn,b as Xn,h as Zn,k as Qn,r as $n,v as er,w as tr,y as nr}from"./insertionBoundaries-DoGr0K7K.js";import{i as rr,n as ir,t as ar}from"./appThemeRegistry-CiKayBT8.js";import{_ as or,i as sr,l as cr,s as lr,t as ur,v as dr,y as fr}from"./vendor-dnd-kit-core-CvWxUPdb.js";import{a as pr,o as mr,s as hr,t as gr}from"./vendor-dnd-kit-sortable-hHdP9lLb.js";import{f as _r,l as vr}from"./markdown-worker-bS5OgGO3.js";import{n as yr}from"./useEffectiveDirectory-KtTREBSZ.js";import{f as br}from"./FadeInOnReveal-BMSk_tY-.js";import{m as xr}from"./imageSource-BpUsiwFd.js";import{n as Sr}from"./useWorkerHighlightedLines-ClpjfaPG.js";import{t as Cr}from"./vendor-tanstack-react-virtual-tlDgH6PG.js";import{a as wr,i as Tr,n as Er}from"./vendor-framer-motion-DFy_BSVd.js";import{A as Dr,N as Or,U as kr,t as Ar,u as jr,v as Mr,x as Nr}from"./MobileTabPageHeader-Dxr3BYP1.js";import{c as Pr,l as Fr}from"./mcpQueries-CoEKBTbS.js";import{n as Ir,r as Lr}from"./sessionLookup-CQ2dDFlT.js";import{a as Rr,i as zr,n as Br,r as Vr,t as Hr}from"./context-menu-K6zNumqN.js";import{n as Ur,r as Wr,t as Gr}from"./collapsible-paItOH3A.js";import{t as Kr}from"./vendor-cron-parser-CCD11YFT.js";var Q=e(E(),1),qr=L(),$=w(),Jr=e(O(),1);function Yr(){return new Worker(ae,{type:`module`})}var Xr=[`typescript`,`javascript`,`tsx`,`jsx`,`json`,`markdown`],Zr={unified:{poolSize:1,totalASTLRUCacheSize:24,lineDiffType:`none`},split:{poolSize:2,totalASTLRUCacheSize:56,lineDiffType:`word-alt`}},Qr,$r,ei=e=>{let t=Zr[e],n=new ie({workerFactory:Yr,poolSize:t.poolSize,totalASTLRUCacheSize:t.totalASTLRUCacheSize},{theme:{light:`pierre-light`,dark:`pierre-dark`},langs:Xr,lineDiffType:t.lineDiffType,preferredHighlighter:`shiki-wasm`});return n.initialize(),n},ti=e=>{if(!(typeof window>`u`))return e===`split`?($r??=ei(`split`),$r):(Qr??=ei(`unified`),Qr)},ni=e=>{let t=(0,qr.c)(7),{children:n,renderTheme:r}=e,i=ii(`unified`),a=ii(`split`),o,s;t[0]!==r||t[1]!==a||t[2]!==i?(o=()=>{i&&i.setRenderOptions({theme:r,lineDiffType:Zr.unified.lineDiffType}),a&&a.setRenderOptions({theme:r,lineDiffType:Zr.split.lineDiffType})},s=[r,a,i],t[0]=r,t[1]=a,t[2]=i,t[3]=o,t[4]=s):(o=t[3],s=t[4]),(0,Q.useEffect)(o,s);let c;return t[5]===n?c=t[6]:(c=(0,$.jsx)($.Fragment,{children:n}),t[5]=n,t[6]=c),c},ri=e=>{let t=(0,qr.c)(11),{children:n}=e,r=Mn(),i,a;if(t[0]!==r?.availableThemes||t[1]!==r?.darkThemeId||t[2]!==r?.lightThemeId){let e=Fn(!1),n=Fn(!0),o=r?.lightThemeId??e.metadata.id,s=r?.darkThemeId??n.metadata.id;a=r?.availableThemes.find(e=>e.metadata.id===o)??e,i=r?.availableThemes.find(e=>e.metadata.id===s)??n,ar(a),ar(i),t[0]=r?.availableThemes,t[1]=r?.darkThemeId,t[2]=r?.lightThemeId,t[3]=i,t[4]=a}else i=t[3],a=t[4];let o;t[5]!==i.metadata.id||t[6]!==a.metadata.id?(o={light:a.metadata.id,dark:i.metadata.id},t[5]=i.metadata.id,t[6]=a.metadata.id,t[7]=o):o=t[7];let s=o,c;return t[8]!==n||t[9]!==s?(c=(0,$.jsx)(ni,{renderTheme:s,children:n}),t[8]=n,t[9]=s,t[10]=c):c=t[10],c},ii=e=>{let t=(0,qr.c)(2),n=e===void 0?`unified`:e,r;return t[0]===n?r=t[1]:(r=ti(n),t[0]=n,t[1]=r),r},ai=Q.forwardRef((e,t)=>{let n=(0,qr.c)(11),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=Y(`peer inline-flex shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-none transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[checked]:bg-primary data-[unchecked]:bg-[var(--interactive-border)]`,r),n[3]=r,n[4]=a);let o;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(o={width:`36px`,height:`20px`,minWidth:`36px`,minHeight:`20px`},n[5]=o):o=n[5];let s;n[6]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(T,{className:Y(`pointer-events-none block rounded-full bg-background shadow-none ring-0 transition-transform data-[checked]:translate-x-4 data-[unchecked]:translate-x-0`),style:{width:`16px`,height:`16px`,minWidth:`16px`,minHeight:`16px`}}),n[6]=s):s=n[6];let c;return n[7]!==i||n[8]!==t||n[9]!==a?(c=(0,$.jsx)(D,{className:a,style:o,...i,ref:t,children:s}),n[7]=i,n[8]=t,n[9]=a,n[10]=c):c=n[10],c});ai.displayName=`Switch`;var oi={},si=[],ci=(e,t)=>{if(!e)return t(`mcpDropdown.status.unknown`);switch(e.status){case`connected`:return t(`mcpDropdown.status.connected`);case`failed`:return t(`mcpDropdown.status.failed`,{error:e.error||t(`mcpDropdown.status.unknownError`)});case`needs_auth`:return t(`mcpDropdown.status.needsAuth`);case`needs_client_registration`:return t(`mcpDropdown.status.needsRegistration`,{error:e.error||``});default:return e.status}},li=e=>{switch(e?.status){case`connected`:return`success`;case`failed`:return`error`;case`needs_auth`:case`needs_client_registration`:return`warning`;default:return`default`}},ui=({active:e,className:t,headerAction:n,listClassName:r,hideHeader:i=!1,mobileListDensity:a=!1})=>{let{t:o}=fe(),s=k(e=>e.currentDirectory)??null,c=kr(e=>e.connect),l=kr(e=>e.disconnect),{data:u,refetch:d,isError:f,error:p}=Fr(s,{enabled:e}),{data:m}=Pr(s,{enabled:e}),h=u??oi,g=m??si,[_,v]=Q.useState(!1),[y,b]=Q.useState(null),x=Q.useMemo(()=>{let e=new Set(Object.keys(h));for(let t of g)t?.name&&e.add(t.name);return Array.from(e).sort((e,t)=>e.localeCompare(t))},[g,h]),S=Q.useCallback(e=>{if(e?.preventDefault(),_)return;v(!0);let t=new Promise(e=>setTimeout(e,500));Promise.all([d(),t]).finally(()=>{v(!1)})},[_,d]);return(0,$.jsxs)(`div`,{className:Y(`w-full`,t),children:[i?null:(0,$.jsx)(`div`,{className:`border-b border-[var(--interactive-border)]`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-4 py-2.5`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex items-baseline gap-2`,children:[(0,$.jsx)(`div`,{className:`typography-ui-header font-semibold text-foreground`,children:o(`mcpDropdown.title`)}),s&&(0,$.jsx)(`div`,{className:`truncate typography-micro text-muted-foreground`,children:s.split(`/`).pop()||s})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[n,(0,$.jsx)(`button`,{type:`button`,className:`inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:text-foreground hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,disabled:_,onClick:S,"aria-label":o(`mcpDropdown.actions.refreshAria`),children:(0,$.jsx)(Z,{name:`refresh`,className:Y(`h-4 w-4`,_&&`animate-spin`)})})]})]})}),(0,$.jsx)(`div`,{className:Y(`max-h-64 overflow-y-auto`,a?`space-y-1 py-3`:`px-3 py-2.5`,r),children:(0,$.jsxs)(`div`,{className:Y(!a&&x.length>0&&`rounded-xl bg-[var(--surface-muted)] p-1.5`),children:[x.map(e=>{let t=h[e]??(f&&!u&&g.some(t=>t.name===e)?{status:`failed`,error:p.message}:void 0),n=li(t),r=t?.status===`connected`,i=y===e,d=ci(t,o);return(0,$.jsxs)(`div`,{className:Y(`flex items-center justify-between rounded-lg hover:bg-interactive-hover/50`,a?`gap-3 px-4 py-3`:`gap-2 px-2.5 py-2`),children:[(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,$.jsxs)(fn,{children:[(0,$.jsx)(un,{asChild:!0,children:(0,$.jsx)(`span`,{className:Y(`rounded-full flex-shrink-0`,a?`h-2.5 w-2.5`:`h-2 w-2`,n===`success`&&`bg-status-success`,n===`error`&&`bg-status-error`,n===`warning`&&`bg-status-warning`,n==="default"&&`bg-muted-foreground/40`),"aria-label":d})}),(0,$.jsx)(dn,{side:`left`,children:(0,$.jsx)(`p`,{children:d})})]}),(0,$.jsx)(`span`,{className:Y(`truncate`,a?`text-[17px] leading-6 font-medium`:`typography-ui-label`),children:e})]})}),(0,$.jsx)(ai,{checked:r,disabled:i,className:`data-[checked]:bg-status-info`,onCheckedChange:async t=>{b(e);try{t?await c(e,s):await l(e,s)}finally{b(null)}}})]},e)}),x.length===0&&(0,$.jsx)(`div`,{className:`px-4 py-5 typography-ui-label text-muted-foreground text-center`,children:o(`mcpDropdown.empty.configureInConfig`)})]})})]})},di=e=>!(e.dismissed===`true`||e.sessionShown===`true`||e.hasActiveToast),fi=e=>!(!e.version||e.seenVersions.has(e.version)||e.dismissedVersion!==null&&e.dismissedVersion===e.version),pi=e=>{if(typeof e!=`object`||!e)return``;let t=e.version;return typeof t==`string`?t.trim():``},mi=e=>{if(!e||e.available!==!0||e.canManage===!1)return``;let t=typeof e.latestVersion==`string`?e.latestVersion:typeof e.targetVersion==`string`?e.targetVersion:``;return t?t.trim():``},hi=e=>{let t=e.trim().replace(/^v/i,``);return t?{target:t}:null},gi=5e3,_i={setTimeout:(e,t)=>globalThis.setTimeout(e,t),clearTimeout:e=>globalThis.clearTimeout(e)};function vi(e,t,n=_i){if(!e)return()=>void 0;let r=n.setTimeout(()=>{t().catch(()=>void 0)},gi);return()=>n.clearTimeout(r)}var yi=(e,t)=>({queryKey:[e,`opencode-update`,t],queryFn:async({signal:i})=>{let a=()=>e===n()&&t===r();if(!a())throw Error(`Stale OpenCode update check`);let o=await s(`/api/opencode/upgrade-status`,{headers:{Accept:`application/json`},signal:i});if(!o.ok)throw Error(`OpenCode update check failed`);let c=await o.json();if(i.aborted||!a())throw Error(`Stale OpenCode update check`);if(!c||typeof c!=`object`||Array.isArray(c))throw Error(`Invalid OpenCode update status`);return c},staleTime:3e4,refetchInterval:3e5,refetchOnWindowFocus:!0,refetchOnReconnect:!0,retry:1}),bi=`opencode-update-available`,xi=`opencode-upgrade-progress`,Si=`opencode-update-toast-dismissed-version`,Ci=()=>{let{t:e}=fe(),i=P(e=>e.showOpenCodeUpdateNotifications),a=Q.useRef(new Set),o=Q.useRef(!1),c=Q.useSyncExternalStore(t,n,n),l=Q.useSyncExternalStore(t,r,r),u=R(),[d,f]=Q.useState(!1);Q.useEffect(()=>vi(i,async()=>{f(!0)}),[i]);let p=V({...yi(c,l),enabled:i&&d});ue(`openchamber:opencode-update-available`,e=>{i&&pi(e.detail)&&p.refetch()});let m=`${Si}:${c}`;Q.useEffect(()=>{a.current.clear(),Pe.dismiss(bi),Pe.dismiss(xi)},[c,l]),Q.useEffect(()=>{i||Pe.dismiss(bi)},[i]);let h=ce(async(t,i=!1)=>{if(o.current)return;o.current=!0;let a=()=>c===n()&&l===r();Pe.dismiss(bi),Pe.message(e(`opencodeUpdate.toast.upgrading.title`),{id:xi,description:e(`opencodeUpdate.toast.upgrading.description`),duration:1/0,icon:(0,$.jsx)(Z,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})});try{let n=hi(t);if(!n)throw Error(e(`opencodeUpdate.toast.failed.description`));let r=await s(`/api/opencode/upgrade`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({...n,confirmActiveTasks:i})}),o=await r.json().catch(()=>null);if(!a())return;if(o?.errorCode===`UPGRADE_ACTIVE_TASKS`){Pe.error(e(`opencodeUpdate.toast.failed.title`),{id:xi,description:o.error,duration:1/0,action:{label:e(`opencodeUpdate.toast.actions.update`),onClick:()=>{a()&&h(t,!0)}}});return}if(!r.ok||o?.success!==!0)throw Error(o?.error||r.statusText||e(`opencodeUpdate.toast.failed.description`));Pe.success(e(`opencodeUpdate.toast.updated.title`),{id:xi,description:o?.version?e(`opencodeUpdate.toast.updated.descriptionWithVersion`,{version:o.version}):e(`opencodeUpdate.toast.updated.description`),duration:1/0,icon:(0,$.jsx)(Z,{name:`check`,className:`h-4 w-4 text-[var(--status-success)]`})}),u.invalidateQueries({queryKey:[c,`opencode-update`,l]}),u.invalidateQueries({queryKey:[c,`about`,l]})}catch(n){if(!a())return;Pe.error(e(`opencodeUpdate.toast.failed.title`),{id:xi,description:n instanceof Error?n.message:e(`opencodeUpdate.toast.failed.description`),duration:1/0,action:{label:e(`opencodeUpdate.toast.actions.update`),onClick:()=>{a()&&h(t)}}})}finally{o.current=!1}});return Q.useEffect(()=>{let t=t=>{if(!P.getState().showOpenCodeUpdateNotifications){Pe.dismiss(bi);return}fi({version:t,dismissedVersion:I().getItem(m),seenVersions:a.current})&&(a.current.add(t),Pe.info(e(`opencodeUpdate.toast.available.title`),{id:bi,description:e(`opencodeUpdate.toast.available.description`,{version:t}),duration:1/0,action:{label:e(`opencodeUpdate.toast.actions.update`),onClick:()=>{c===n()&&l===r()&&h(t)}},cancel:{label:e(`opencodeUpdate.toast.actions.dismiss`),onClick:()=>{I().setItem(m,t),Pe.dismiss(bi)}}}))},i=mi(p.data);i?t(i):(p.data?.available===!1||p.data?.canManage===!1)&&Pe.dismiss(bi)},[i,e,p.data,m,c,l,h]),null},wi=()=>{let e=(0,qr.c)(3),[t,n]=Q.useState(Ti),{isUpdating:r}=t,i,a;if(e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=()=>qe(n),a=[],e[0]=i,e[1]=a):(i=e[0],a=e[1]),Q.useEffect(i,a),!r)return null;let o;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(`div`,{className:`fixed inset-0 z-[9999] flex items-center justify-center bg-background/90`,children:(0,$.jsx)(gn,{width:80,height:80,isAnimated:!0})}),e[2]=o):o=e[2],o};function Ti(){return st()}var Ei=5e3,Di=(e,t)=>{if(!e)return 1;let n=1;for(let r=0;r<e.length;r+=1)if(e.charCodeAt(r)===10&&(n+=1,n>t))return n;return n},Oi=(e,t)=>ve(_e.getState().dictionary,e,t),ki=e=>{let t=(e instanceof Error?e.message:String(e??``)).toLowerCase();return t.includes(`file not found`)||t.includes(`not found`)||t.includes(`enoent`)||t.includes(`no such file`)||t.includes(`does not exist`)?`missing`:`unreadable`},Ai=async(e,t)=>{if(e.readFile){let n=await e.readFile(t,{optional:!0});if(typeof n.exists!=`boolean`)throw Error(`Optional file read requires an existence response header`);return{content:n.content??``,exists:n.exists}}let n=new URLSearchParams({path:t,optional:`true`}),r=await s(`/api/fs/read?${n.toString()}`,{cache:`no-store`});if(!r.ok){let e=await r.json().catch(()=>({error:r.statusText}));throw Error(e.error||`Failed to read file`)}let i=r.headers.get(`x-openchamber-file-exists`);if(i!==`true`&&i!==`false`)throw Error(`Optional file read requires an existence response header`);return{content:await r.text(),exists:i===`true`}},ji=async(e,t)=>{try{let{content:n,exists:r}=await Ai(e,t);return r?Di(n,5e3)>5e3?{ok:!1,reason:`too-large`}:{ok:!0}:{ok:!1,reason:`missing`}}catch(e){return{ok:!1,reason:ki(e)}}},Mi=e=>e===`too-large`?Oi(`contextFileOpen.failure.tooLarge`,{count:Ei.toLocaleString(he())}):Oi(e===`missing`?`contextFileOpen.failure.missing`:`contextFileOpen.failure.unreadable`),Ni=(e,t)=>!e||t.length===0?``:JSON.stringify([e,t]),Pi=(e,t,n,r)=>!n||r!==n||e.length===0?[]:Be(e,t,e=>e.name,{limit:10,threshold:.4}),Fi=(e,t={})=>{let r=e.trim(),i=t.transport??n(),a=t.searchSessions??(e=>j.searchSessionsByTitle(e));return B({queryKey:p.sessionTitleSearch.query(r,i),enabled:r.length>0,queryFn:({signal:e})=>a({search:r,limit:30,signal:e}),staleTime:5e3,retry:1})},Ii=e=>{let t=(0,qr.c)(13),{title:n,description:r,trailing:i}=e,a=r?`min-w-0 max-w-[58%] shrink-0 truncate typography-meta font-medium leading-4 text-foreground`:`min-w-0 flex-1 truncate typography-meta font-medium leading-4 text-foreground`,o;t[0]!==a||t[1]!==n?(o=(0,$.jsx)(`span`,{className:a,children:n}),t[0]=a,t[1]=n,t[2]=o):o=t[2];let s;t[3]===r?s=t[4]:(s=r?(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-micro leading-4 text-muted-foreground/65`,children:r}):null,t[3]=r,t[4]=s);let c;t[5]!==o||t[6]!==s?(c=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2.5`,children:[o,s]}),t[5]=o,t[6]=s,t[7]=c):c=t[7];let l;t[8]===i?l=t[9]:(l=i?(0,$.jsx)(`div`,{className:`ml-auto flex shrink-0 items-center pl-2 text-muted-foreground/50`,children:i}):null,t[8]=i,t[9]=l);let u;return t[10]!==c||t[11]!==l?(u=(0,$.jsxs)($.Fragment,{children:[c,l]}),t[10]=c,t[11]=l,t[12]=u):u=t[12],u},Li=`min-h-9 gap-2 rounded-lg px-3 py-2 typography-meta`,Ri=`py-0 [&_[cmdk-group-heading]]:px-2.5 [&_[cmdk-group-heading]]:pb-2 [&_[cmdk-group-heading]]:pt-3 [&_[cmdk-group-heading]]:font-normal [&_[cmdk-group-heading]]:text-muted-foreground`;function zi(e,t){let n=t.toLowerCase().split(/\s+/).filter(Boolean);if(!n.length)return e;let r=n.map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`));return e.split(RegExp(`(${r.join(`|`)})`,`gi`)).map((e,t)=>n.includes(e.toLowerCase())?(0,$.jsx)(`mark`,{className:`bg-transparent font-[inherit] text-[var(--primary-base)]`,children:e},t):e)}var Bi=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},Vi=e=>{let t=(0,qr.c)(180),{presentation:n,onBack:r}=e,i=n===void 0?`dialog`:n,{t:a}=fe(),o=Jn(),s=P(Hi),[c,u]=Q.useState(s),d=P(Ui),p=P(Wi),m=P(Gi),h=P(Ki),_=P(qi),b=P(Ji),x=P(Yi),S=P(Xi),C=P(Zi),w=P(Qi),T=P($i),E=Je(ea),D=Je(ta),O=Fe(na),j=Fe(ra),M=k(ia),N=ot(aa),F=ot(oa),I=yr(),L=A(sa),{files:R}=In(),{isMobile:z}=Nn(),B=i===`page`||z,ee;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(ee=me(),t[0]=ee):ee=t[0];let H=ee,U=Q.useRef(null),W=Q.useRef(null),te;t[1]!==s||t[2]!==B?(te=()=>{if(!B||!s||!U.current)return;let e=window.visualViewport;U.current.style.setProperty(`--search-viewport-height`,`${e?.height??window.innerHeight}px`),U.current.style.setProperty(`--search-viewport-top`,`${e?.offsetTop??0}px`)},t[1]=s,t[2]=B,t[3]=te):te=t[3];let G=ce(te),K;t[4]!==s||t[5]!==B?(K=()=>B&&s?window.visualViewport??window:null,t[4]=s,t[5]=B,t[6]=K):K=t[6],ue(`resize`,G,K);let ne;t[7]!==s||t[8]!==B?(ne=()=>B&&s?window.visualViewport:null,t[7]=s,t[8]=B,t[9]=ne):ne=t[9],ue(`scroll`,G,ne);let re;t[10]===G?re=t[11]:(re=()=>{G()},t[10]=G,t[11]=re);let ie;t[12]!==s||t[13]!==B?(ie=[B,s],t[12]=s,t[13]=B,t[14]=ie):ie=t[14],Q.useEffect(re,ie);let q,ae;t[15]!==s||t[16]!==i?(q=()=>{i===`page`&&s&&W.current?.focus({preventScroll:!0})},ae=[i,s],t[15]=s,t[16]=i,t[17]=q,t[18]=ae):(q=t[17],ae=t[18]),Q.useEffect(q,ae);let J;t[19]===I?J=t[20]:(J=I?Bi(I):null,t[19]=I,t[20]=J);let oe=J,[se,le]=Q.useState(``),de=Qn(se,200).trim(),pe;t[21]===se?pe=t[22]:(pe=se.trim(),t[21]=se,t[22]=pe);let he=pe,Y,X;t[23]===s?(Y=t[24],X=t[25]):(Y=()=>{s&&(le(``),u(!0))},X=[s],t[23]=s,t[24]=Y,t[25]=X),Q.useEffect(Y,X);let _e;t[26]===d?_e=t[27]:(_e=()=>d(!1),t[26]=d,t[27]=_e);let ve=ce(_e),ye;t[28]===ve?ye=t[29]:(ye=e=>()=>{ve(),e()},t[28]=ve,t[29]=ye);let be=ce(ye);N?.id,N?.path;let xe=(()=>{let e=[{id:`new-session`,title:a(`commandPalette.item.newSession`),shortcutId:`new_chat`,searchText:a(`commandPalette.item.newSession`),onSelect:be(()=>{p(`chat`),_(!1),E()})},{id:`new-worktree`,title:a(`commandPalette.item.newWorktreeDraft`),shortcutId:`new_chat_worktree`,searchText:a(`commandPalette.item.newWorktreeDraft`),onSelect:be(ca)},{id:`add-project`,title:a(`commandPalette.item.addProject`),searchText:a(`commandPalette.item.addProject`),onSelect:be(la)},{id:`toggle-sidebar`,title:a(B?`commandPalette.item.showSessionSwitcher`:`commandPalette.item.toggleSidebar`),shortcutId:`toggle_sidebar`,searchText:a(B?`commandPalette.item.showSessionSwitcher`:`commandPalette.item.toggleSidebar`),onSelect:be(()=>{if(B){let{isSessionSwitcherOpen:e}=P.getState();_(!e)}else b()})},{id:`toggle-right-sidebar`,title:a(`commandPalette.item.toggleRightSidebar`),shortcutId:`toggle_right_sidebar`,searchText:a(`commandPalette.item.toggleRightSidebar`),onSelect:be(()=>x())},{id:`toggle-terminal`,title:a(`commandPalette.item.toggleTerminal`),shortcutId:`toggle_terminal`,searchText:a(`commandPalette.item.toggleTerminal`),onSelect:be(()=>S())},{id:`new-terminal-tab`,title:a(`commandPalette.item.newTerminalTab`),shortcutId:`open_new_terminal`,searchText:a(`commandPalette.item.newTerminalTab`),onSelect:be(()=>{I&&Nt(I)})},{id:`context-usage`,title:a(`commandPalette.item.showContextUsage`),searchText:a(`commandPalette.item.showContextUsage`),onSelect:be(()=>{M&&C(M)})},{id:`open-settings`,title:a(`commandPalette.item.openSettings`),shortcutId:`open_settings`,searchText:a(`commandPalette.item.openSettings`),onSelect:be(()=>m(!0))}];return l()&&e.splice(1,0,{id:`new-mini-chat`,title:a(`commandPalette.item.newMiniChat`),shortcutId:`new_mini_chat`,searchText:a(`commandPalette.item.newMiniChat`),onSelect:be(()=>{f(`desktop_open_draft_mini_chat_window`,{directory:Bi(M||N?.path||``),projectId:N?.id??null}).catch(ua)})}),e})(),Se=v(),Ce={isVSCode:g(),isWeb:!Se&&y(),isDesktop:Se,isMobile:B},Ee=Dr.filter(da).filter(e=>!e.isAvailable||e.isAvailable(Ce)).map(e=>{let t=(e.keywords??[]).join(` `);return{id:`settings:${e.slug}`,title:e.title,searchText:`${e.title} ${e.group} ${t}`,onSelect:be(()=>{h(e.slug),m(!0)})}}),De=fa,Oe;if(t[30]!==O){let e;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(e=(e,t)=>De(t)-De(e),t[32]=e):e=t[32],Oe=[...O].sort(e),t[30]=O,t[31]=Oe}else Oe=t[31];let ke=Oe,Ae=Je(pa),je=Je(ma),Me;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(Me=[],t[33]=Me):Me=t[33];let[Ne,Ie]=Q.useState(Me),[Le,Re]=Q.useState(``),[ze,Ve]=Q.useState(``),He=Ni(oe,de),Ue;t[34]!==oe||t[35]!==He||t[36]!==s||t[37]!==L||t[38]!==Ve||t[39]!==Ie||t[40]!==Re||t[41]!==de?(Ue=()=>{if(!s){Ie([]),Re(``),Ve(``);return}if(!He){Ie([]),Re(``),Ve(``);return}if(!oe){Ie([]),Re(``),Ve(``);return}let e=!1;return Ve(``),L(oe,de,10,{type:`file`}).then(t=>{e||(Ie(t.map(ha)),Re(He),Ve(``))}).catch(()=>{e||(Ie([]),Re(``),Ve(He))}),()=>{e=!0}},t[34]=oe,t[35]=He,t[36]=s,t[37]=L,t[38]=Ve,t[39]=Ie,t[40]=Re,t[41]=de,t[42]=Ue):Ue=t[42];let We;t[43]!==oe||t[44]!==He||t[45]!==s||t[46]!==L||t[47]!==de?(We=[s,oe,de,He,L],t[43]=oe,t[44]=He,t[45]=s,t[46]=L,t[47]=de,t[48]=We):We=t[48],Q.useEffect(Ue,We);let Ge=he.length>0,Ke;bb0:{if(!Ge){Ke=xe.map(ga);break bb0}Ke=Be(xe,he,_a,{limit:7,noFuzzy:!0})}let qe=Ke,Ye;bb1:{if(!Ge){Ye=[];break bb1}Ye=Be(Ee,he,va,{limit:7,noFuzzy:!0})}let Xe=Ye,Ze;t[49]===de?Ze=t[50]:(Ze=Fi(de),t[49]=de,t[50]=Ze);let Qe=(s||c)&&(de.length>0||i===`page`),$e;t[51]!==Ze||t[52]!==Qe?($e={...Ze,enabled:Qe},t[51]=Ze,t[52]=Qe,t[53]=$e):$e=t[53];let et=V($e),tt=Ge&&he===de&&et.isSuccess,rt=(Ge||i===`page`)&&he===de&&et.isError,it;bb2:{if(!rt){let e;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[54]=e):e=t[54],it=e;break bb2}let e;t[55]!==he||t[56]!==ke?(e=Be(ke,he,ya,{limit:30,threshold:.2}).map(ba),t[55]=he,t[56]=ke,t[57]=e):e=t[57],it=e}let st=it,ct;bb3:{if(!Ge){if(i===`page`&&!de&&et.isSuccess){ct=et.data;break bb3}let e;t[58]!==i||t[59]!==ke?(e=ke.slice(0,i===`page`?30:9),t[58]=i,t[59]=ke,t[60]=e):e=t[60],ct=e;break bb3}if(!tt){let e;t[61]!==st||t[62]!==rt?(e=rt?st:[],t[61]=st,t[62]=rt,t[63]=e):e=t[63],ct=e;break bb3}let e;t[64]===et.data?e=t[65]:(e=et.data??[],t[64]=et.data,t[65]=e),ct=e}let lt=ct,ut;bb4:{if(!s&&!c){ut=[];break bb4}if(he!==de||ze===He){ut=[];break bb4}ut=Pi(Ne,de,He,Le)}let dt=ut,ft=(s||c)&&He.length>0&&Le!==He&&ze!==He,pt;bb5:{if(!Ge){pt=[];break bb5}let e=F.map(xa);pt=Be(e,he,Sa,{limit:7,threshold:.4})}let mt=pt,gt=qe.map(Ca),xt=Xe.map(wa),Z=lt,St=Ge?dt.map(Ta):[],wt=Ge?mt.map(Ea):[],Tt;bb6:{if(!Ge){Tt=[`sessions`,`commands`];break bb6}let e=Da,t=[{key:`commands`,score:e(qe)},{key:`settings`,score:e(Xe)},{key:`files`,score:e(dt)},{key:`projects`,score:e(mt)}];t.sort(Oa),Tt=[`sessions`,...t.map(ka)]}let Et=Tt,Dt;t[66]!==ve||t[67]!==o||t[68]!==p||t[69]!==D||t[70]!==_?(Dt=e=>{ve(),p(`chat`),_(!1);let t=nt(e)||``;o?at.getState().openSession({sessionId:e.id,directory:t}):D(e.id,t)},t[66]=ve,t[67]=o,t[68]=p,t[69]=D,t[70]=_,t[71]=Dt):Dt=t[71];let kt=ce(Dt),At;t[72]!==ve||t[73]!==oe||t[74]!==R||t[75]!==o||t[76]!==w?(At=async e=>{if(!oe)return;let t=await ji(R,e);if(!t.ok){Pe.error(Mi(t.reason));return}o?o.openFile({path:e}):w(oe,e),ve()},t[72]=ve,t[73]=oe,t[74]=R,t[75]=o,t[76]=w,t[77]=At):At=t[77];let jt=ce(At),Mt;t[78]!==ve||t[79]!==o||t[80]!==E?(Mt=(e,t)=>{ve();let n={selectedProjectId:e,directoryOverride:t};o?at.getState().openDraft(n):E(n)},t[78]=ve,t[79]=o,t[80]=E,t[81]=Mt):Mt=t[81];let Ft=ce(Mt),It=e=>wn(bn(e,T)),Lt;t[82]!==kt||t[83]!==B||t[84]!==Z?(Lt=e=>{if(B||e.nativeEvent.isComposing||e.altKey||e.shiftKey||(H?!e.metaKey||e.ctrlKey:!e.ctrlKey||e.metaKey)||!/^[1-9]$/.test(e.key)||(e.preventDefault(),e.stopPropagation(),e.repeat))return;let t=Z[Number(e.key)-1];t&&kt(t)},t[82]=kt,t[83]=B,t[84]=Z,t[85]=Lt):Lt=t[85];let Rt=ce(Lt),Bt=e=>{let t=Bi(Ae.get(e.id)?.projectDirectory||nt(e)||``),n=Te(F,je,t);return n?.label||(n?.path||t).split(`/`).pop()||``},Ut=Ge&&!!oe&&(he!==de||ft),Gt=Ge&&he===de&&!!He&&ze===He,Kt=(Ge||i===`page`)&&(he!==de||et.isFetching&&!et.isSuccess),qt=i===`page`?`mobileGlass`:`default`,Jt;t[86]===a?Jt=t[87]:(Jt=a(`commandPalette.title`),t[86]=a,t[87]=Jt);let Yt;t[88]===a?Yt=t[89]:(Yt=a(`commandPalette.input.placeholder`),t[88]=a,t[89]=Yt);let Xt;t[90]!==se||t[91]!==qt||t[92]!==Jt||t[93]!==Yt?(Xt=(0,$.jsx)(Wt,{ref:W,variant:qt,className:`font-normal`,"aria-label":Jt,inputMode:`search`,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,value:se,onValueChange:le,placeholder:Yt}),t[90]=se,t[91]=qt,t[92]=Jt,t[93]=Yt,t[94]=Xt):Xt=t[94];let Zt=Xt,Qt=Ot,$t,en,tn;t[95]===B?($t=t[96],en=t[97],tn=t[98]):($t=e=>{let t=e.target.closest(`[cmdk-item]`);B&&t&&Rn({currentTarget:t})},en=e=>{let t=e.target.closest(`[cmdk-item]`);B&&t&&zn({currentTarget:t,detail:1})},tn=e=>{let t=e.target.closest(`[cmdk-item]`);B&&t&&e.detail>0&&!zn({currentTarget:t,detail:e.detail})&&(e.preventDefault(),e.stopPropagation())},t[95]=B,t[96]=$t,t[97]=en,t[98]=tn);let nn;t[99]!==ve||t[100]!==r||t[101]!==i||t[102]!==Zt||t[103]!==a?(nn=i===`page`?(0,$.jsx)(we,{title:Zt,backAriaLabel:a(`header.actions.backAria`),onBack:r??ve}):Zt,t[99]=ve,t[100]=r,t[101]=i,t[102]=Zt,t[103]=a,t[104]=nn):nn=t[104];let rn=Ht,an;t[105]===a?an=t[106]:(an=a(`commandPalette.title`),t[105]=a,t[106]=an);let on;t[107]!==a||t[108]!==Z.length?(on=Z.length===0?(0,$.jsx)(`div`,{className:`px-2.5 pb-2 pt-3 typography-meta text-muted-foreground`,children:a(`layout.mainTab.chat`)}):null,t[107]=a,t[108]=Z.length,t[109]=on):on=t[109];let sn;t[110]!==Gt||t[111]!==j||t[112]!==a||t[113]!==rt||t[114]!==Ut||t[115]!==Kt?(sn=!Ut&&!Kt&&!Gt&&!rt&&j!==`loading`&&j!==`error`?(0,$.jsx)(Ct,{className:`py-10 text-center typography-meta text-muted-foreground`,children:a(`commandPalette.empty.noResults`)}):null,t[110]=Gt,t[111]=j,t[112]=a,t[113]=rt,t[114]=Ut,t[115]=Kt,t[116]=sn):sn=t[116];let cn=Et.map(e=>e===`commands`&>.length>0?(0,$.jsx)(Pt,{heading:a(`settings.page.commands.title`),className:Ri,children:gt.map(e=>(0,$.jsx)(zt,{value:e.id,onSelect:e.onSelect,className:Li,children:(0,$.jsx)(Ii,{title:e.title,trailing:!B&&e.shortcutId?(0,$.jsx)(Vt,{className:`h-3.5 min-w-0 shrink-0 rounded-full border-0 bg-[color-mix(in_srgb,var(--surface-foreground)_6%,transparent)] px-1.5 font-sans text-[10px] font-medium tracking-tight text-muted-foreground/65 shadow-none`,children:It(e.shortcutId)}):void 0})},e.id))},`commands`):e===`settings`&&xt.length>0?(0,$.jsx)(Pt,{heading:a(`settings.view.home.title`),className:Ri,children:xt.map(Aa)},`settings`):e===`sessions`&&Z.length>0?(0,$.jsx)(Pt,{heading:a(`layout.mainTab.chat`),className:Ri,children:Z.map((e,t)=>{let n=e.title||a(`commandPalette.session.untitled`),r=Bt(e);return(0,$.jsx)(zt,{value:`session:${e.id}`,onSelect:()=>kt(e),className:`flex-col items-stretch gap-1 rounded-lg px-3 py-2`,"aria-keyshortcuts":!B&&t<9?`${H?`Meta`:`Control`}+${t+1}`:void 0,children:(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-ui-label text-foreground`,title:n,children:zi(n,he)}),(0,$.jsx)(`span`,{className:`max-w-[28%] shrink-0 truncate typography-meta text-muted-foreground`,title:r,children:r}),!B&&t<9?(0,$.jsxs)(Vt,{className:`h-5 min-w-8 shrink-0 rounded-full border-0 bg-interactive-selection px-2 text-muted-foreground shadow-none`,children:[H?`⌘`:`Ctrl+`,t+1]}):null]})},e.id)})},`sessions`):e===`files`&&St.length>0?(0,$.jsx)(Pt,{heading:a(`layout.mainTab.files`),className:Ri,children:St.map(e=>{let t=ge(e.relativePath||e.name,{maxLength:80});return(0,$.jsx)(zt,{value:`file:${e.path}`,onSelect:()=>{jt(e.path)},className:Li,children:(0,$.jsx)(Ii,{title:zi(e.name,he),description:t===e.name?void 0:zi(t,he)})},`file:${e.path}`)})},`files`):e===`projects`&&wt.length>0?(0,$.jsx)(Pt,{heading:a(`sessions.sidebar.projectsTitle`),className:Ri,children:wt.map(e=>{let t=e.displayName;return(0,$.jsx)(zt,{value:`project:${e.id}`,onSelect:()=>Ft(e.id,e.path),className:Li,children:(0,$.jsx)(Ii,{title:zi(t,he)})},`project:${e.id}`)})},`projects`):null),ln;t[117]!==j||t[118]!==a?(ln=j===`loading`?(0,$.jsx)(`div`,{role:`status`,className:`px-3 py-4 text-center typography-meta text-muted-foreground`,children:a(`common.loading`)}):null,t[117]=j,t[118]=a,t[119]=ln):ln=t[119];let un;t[120]!==j||t[121]!==a?(un=j===`error`?(0,$.jsx)(`div`,{role:`alert`,className:`px-3 py-4 typography-meta text-[var(--status-error)]`,children:a(`commandPalette.error.sessions`)}):null,t[120]=j,t[121]=a,t[122]=un):un=t[122];let dn;t[123]!==a||t[124]!==rt?(dn=rt?(0,$.jsx)(`div`,{role:`alert`,className:`px-3 py-4 typography-meta text-[var(--status-error)]`,children:a(`commandPalette.error.sessions`)}):null,t[123]=a,t[124]=rt,t[125]=dn):dn=t[125];let fn;t[126]!==a||t[127]!==Kt?(fn=Kt?(0,$.jsx)(`div`,{role:`status`,className:`px-3 py-4 text-center typography-meta text-muted-foreground`,children:a(`common.loading`)}):null,t[126]=a,t[127]=Kt,t[128]=fn):fn=t[128];let pn;t[129]!==a||t[130]!==Ut?(pn=Ut?(0,$.jsx)(`div`,{role:`status`,className:`px-3 py-4 typography-meta text-muted-foreground`,children:a(`commandPalette.empty.searchingFiles`)}):null,t[129]=a,t[130]=Ut,t[131]=pn):pn=t[131];let mn;t[132]!==Gt||t[133]!==a?(mn=Gt?(0,$.jsx)(`div`,{role:`alert`,className:`px-3 py-4 typography-meta text-[var(--status-error)]`,children:a(`mobile.files.error.listFailed`)}):null,t[132]=Gt,t[133]=a,t[134]=mn):mn=t[134];let hn;t[135]!==rn||t[136]!==an||t[137]!==on||t[138]!==sn||t[139]!==cn||t[140]!==ln||t[141]!==un||t[142]!==dn||t[143]!==fn||t[144]!==pn||t[145]!==mn?(hn=(0,$.jsxs)(rn,{"aria-label":an,className:`overscroll-contain p-1.5`,children:[on,sn,cn,ln,un,dn,fn,pn,mn]}),t[135]=rn,t[136]=an,t[137]=on,t[138]=sn,t[139]=cn,t[140]=ln,t[141]=un,t[142]=dn,t[143]=fn,t[144]=pn,t[145]=mn,t[146]=hn):hn=t[146];let gn;t[147]!==Qt||t[148]!==Rt||t[149]!==$t||t[150]!==en||t[151]!==tn||t[152]!==nn||t[153]!==hn?(gn=(0,$.jsxs)(Qt,{shouldFilter:!1,onKeyDownCapture:Rt,onPointerDownCapture:$t,onPointerCancelCapture:en,onClickCapture:tn,className:`max-h-full min-h-0 rounded-[inherit] bg-transparent [&_[cmdk-group]]:px-0 [&_[cmdk-item][data-selected=true]]:!bg-[color-mix(in_srgb,var(--interactive-selection)_40%,transparent)] [&_[cmdk-item]:hover]:!bg-[color-mix(in_srgb,var(--interactive-selection)_40%,transparent)]`,children:[nn,hn]}),t[147]=Qt,t[148]=Rt,t[149]=$t,t[150]=en,t[151]=tn,t[152]=nn,t[153]=hn,t[154]=gn):gn=t[154];let _n=gn;if(i===`page`){let e;t[155]===a?e=t[156]:(e=a(`commandPalette.title`),t[155]=a,t[156]=e);let n;return t[157]!==_n||t[158]!==e?(n=(0,$.jsx)(`section`,{ref:U,"data-global-search":`true`,"data-page-scroll-lock":`true`,"aria-label":e,className:`oc-global-search-page flex min-h-0 w-full flex-col bg-background text-foreground`,children:_n}),t[157]=_n,t[158]=e,t[159]=n):n=t[159],n}let vn;t[160]===Symbol.for(`react.memo_cache_sentinel`)?(vn=e=>{e||u(!1)},t[160]=vn):vn=t[160];let yn;t[161]===a?yn=t[162]:(yn=a(`commandPalette.title`),t[161]=a,t[162]=yn);let xn;t[163]===yn?xn=t[164]:(xn=(0,$.jsx)(vt,{children:yn}),t[163]=yn,t[164]=xn);let Sn;t[165]===a?Sn=t[166]:(Sn=a(`commandPalette.description`),t[165]=a,t[166]=Sn);let Cn;t[167]===Sn?Cn=t[168]:(Cn=(0,$.jsx)(yt,{children:Sn}),t[167]=Sn,t[168]=Cn);let Tn;t[169]!==xn||t[170]!==Cn?(Tn=(0,$.jsxs)(ht,{className:`sr-only`,children:[xn,Cn]}),t[169]=xn,t[170]=Cn,t[171]=Tn):Tn=t[171];let En;t[172]!==_n||t[173]!==B||t[174]!==Tn?(En=(0,$.jsxs)(_t,{ref:U,initialFocus:W,"data-global-search":`true`,"data-mobile":B,"data-page-scroll-lock":`true`,className:`oc-global-search oc-mobile-overlay-surface oc-mobile-overlay-surface--translucent oc-composer-autocomplete-surface fixed left-1/2 top-[12vh] z-50 w-[min(40rem,calc(100vw-1.5rem))] max-w-none -translate-x-1/2 translate-y-0 gap-0 overflow-hidden rounded-3xl border-0 p-0`,containerClassName:`block p-0`,overlayClassName:`bg-transparent dark:bg-transparent`,showCloseButton:B,children:[Tn,_n]}),t[172]=_n,t[173]=B,t[174]=Tn,t[175]=En):En=t[175];let Dn;return t[176]!==s||t[177]!==d||t[178]!==En?(Dn=(0,$.jsx)(bt,{open:s,onOpenChange:d,onOpenChangeComplete:vn,children:En}),t[176]=s,t[177]=d,t[178]=En,t[179]=Dn):Dn=t[179],Dn};function Hi(e){return e.isCommandPaletteOpen}function Ui(e){return e.setCommandPaletteOpen}function Wi(e){return e.setActiveMainTab}function Gi(e){return e.setSettingsDialogOpen}function Ki(e){return e.setSettingsPage}function qi(e){return e.setSessionSwitcherOpen}function Ji(e){return e.toggleSidebar}function Yi(e){return e.toggleRightSidebar}function Xi(e){return e.toggleBottomTerminal}function Zi(e){return e.openContextOverview}function Qi(e){return e.openContextFile}function $i(e){return e.shortcutOverrides}function ea(e){return e.openNewSessionDraft}function ta(e){return e.setCurrentSession}function na(e){return e.activeSessions}function ra(e){return e.status}function ia(e){return e.currentDirectory}function aa(e){return e.getActiveProject()}function oa(e){return e.projects}function sa(e){return e.searchFiles}function ca(){It()}function la(){ft.requestDirectoryDialog()}function ua(e){console.warn(`[command-palette] failed to open draft mini chat window`,e)}function da(e){return e.slug!==`home`}function fa(e){return(typeof e.time?.updated==`number`?e.time.updated:0)||(typeof e.time?.created==`number`?e.time.created:0)}function pa(e){return e.worktreeMetadata}function ma(e){return e.availableWorktreesByProject}function ha(e){return{path:Bi(e.path),name:e.name,relativePath:e.relativePath}}function ga(e){return{item:e,score:0}}function _a(e){return e.searchText}function va(e){return e.searchText}function ya(e){return e.title||``}function ba(e){let{item:t}=e;return t}function xa(e){return{...e,displayName:e.label||e.path.split(`/`).pop()||e.path,searchText:`${e.label||``} ${e.path}`}}function Sa(e){return e.searchText}function Ca(e){return e.item}function wa(e){return e.item}function Ta(e){return e.item}function Ea(e){return e.item}function Da(e){return e.length?e[0].score:1/0}function Oa(e,t){return e.score-t.score}function ka(e){return e.key}function Aa(e){return(0,$.jsx)(zt,{value:e.id,onSelect:e.onSelect,className:Li,children:(0,$.jsx)(Ii,{title:e.title})},e.id)}var ja=class extends Q.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){this.setState({error:e,errorInfo:t})}handleReset=()=>{this.setState({hasError:!1,error:void 0,errorInfo:void 0})};render(){return this.state.hasError?(0,$.jsx)(`div`,{className:`flex items-center justify-center min-h-screen p-4`,children:(0,$.jsxs)(An,{className:`w-full max-w-md`,children:[(0,$.jsx)(mn,{className:`text-center`,children:(0,$.jsxs)(pn,{className:`flex items-center justify-center gap-2 text-destructive`,children:[(0,$.jsx)(Z,{name:`chat-3`,className:`h-5 w-5`}),this.props.texts.title]})}),(0,$.jsxs)(_n,{className:`space-y-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground text-center`,children:this.props.texts.description}),this.props.sessionId&&(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground text-center`,children:[this.props.texts.sessionLabel,`: `,this.props.sessionId]}),this.state.error&&(0,$.jsxs)(`details`,{className:`text-xs font-mono bg-muted p-3 rounded`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer hover:bg-interactive-hover/80`,children:this.props.texts.detailsSummary}),(0,$.jsx)(`pre`,{className:`mt-2 max-h-48 overflow-auto`,children:this.state.error.toString()})]}),(0,$.jsx)(`div`,{className:`flex gap-2`,children:(0,$.jsxs)(X,{onClick:this.handleReset,variant:`outline`,className:`flex-1`,children:[(0,$.jsx)(Z,{name:`restart`,className:`h-4 w-4 mr-2`}),this.props.texts.resetAction]})}),(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground text-center`,children:this.props.texts.persistentHint})]})]})}):this.props.children}};function Ma(e){let t=(0,qr.c)(22),{t:n}=fe(),r;t[0]===n?r=t[1]:(r=n(`chat.errorBoundary.title`),t[0]=n,t[1]=r);let i;t[2]===n?i=t[3]:(i=n(`chat.errorBoundary.description`),t[2]=n,t[3]=i);let a;t[4]===n?a=t[5]:(a=n(`chat.errorBoundary.sessionLabel`),t[4]=n,t[5]=a);let o;t[6]===n?o=t[7]:(o=n(`chat.errorBoundary.detailsSummary`),t[6]=n,t[7]=o);let s;t[8]===n?s=t[9]:(s=n(`chat.errorBoundary.resetAction`),t[8]=n,t[9]=s);let c;t[10]===n?c=t[11]:(c=n(`chat.errorBoundary.persistentHint`),t[10]=n,t[11]=c);let l;t[12]!==r||t[13]!==i||t[14]!==a||t[15]!==o||t[16]!==s||t[17]!==c?(l={title:r,description:i,sessionLabel:a,detailsSummary:o,resetAction:s,persistentHint:c},t[12]=r,t[13]=i,t[14]=a,t[15]=o,t[16]=s,t[17]=c,t[18]=l):l=t[18];let u;return t[19]!==e||t[20]!==l?(u=(0,$.jsx)(ja,{...e,texts:l}),t[19]=e,t[20]=l,t[21]=u):u=t[21],u}var Na=1440,Pa=e=>{let t=(0,qr.c)(8),{isMobile:n,isVSCode:r,directory:i}=e,a=se(`(min-width: ${Na}px)`),o;t[0]===i?o=t[1]:(o=i?F(i):``,t[0]=i,t[1]=o);let s=o,c;t[2]===s?c=t[3]:(c=e=>{let t=s?e.contextPanelByDirectory[s]:void 0;return t?.isOpen?!!(t.tabs.find(e=>e.id===t.activeTabId)??t.tabs[t.tabs.length-1]??null):!1},t[2]=s,t[3]=c);let l=P(c),u=P(Fa),d=P(Ia),f=!n&&!r&&!l&&!d,p=f&&a,m=u&&p,h;return t[4]!==p||t[5]!==f||t[6]!==m?(h={visible:m,fits:p,layoutAllows:f},t[4]=p,t[5]=f,t[6]=m,t[7]=h):h=t[7],h};function Fa(e){return e.workStatusPanelEnabled}function Ia(e){return e.isRightSidebarOpen}var La=[],Ra=[`subagent_type`,`subagentType`,`agent`,`subagent`],za=(...e)=>{for(let t of e){if(!t||typeof t!=`object`)continue;let e=t;for(let t of Ra){let n=e[t];if(typeof n!=`string`)continue;let r=n.trim();if(r)return r.charAt(0).toUpperCase()+r.slice(1)}}return``},Ba=e=>At(e)||void 0,Va=e=>e===`pending`||e===`running`,Ha=e=>{let t=[],n=new Set;for(let r of e.messageOrder){let i=e.partsByMessageID[r];if(i)for(let e of i){if(!e?.id||n.has(e.id))continue;if(e.type===`tool`&&wt(e.tool)){n.add(e.id);let r=e.state;t.push({id:e.id,sessionID:Ba(e.metadata)??Ba(r)??Ba(r?.metadata)??Ba(r?.input),label:za(r?.input,e.metadata,r?.metadata),running:Va(r?.status)});continue}if(e.type!==`subtask`)continue;let r=e,i=typeof r.taskSessionID==`string`?r.taskSessionID.trim():``,a=typeof r.agent==`string`?r.agent.trim():``,o=typeof r.description==`string`?r.description.trim():``;n.add(e.id),t.push({id:e.id,sessionID:i||void 0,label:a?a.charAt(0).toUpperCase()+a.slice(1):o,running:Va(r.status)})}}return t.length===0?La:t},Ua=(e,t)=>{if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){let r=e[n],i=t[n];if(!r||!i||r.id!==i.id||r.sessionID!==i.sessionID||r.label!==i.label||r.running!==i.running)return!1}return!0},Wa=(e,t,n)=>{let r=new Map(t.map(e=>[e.id,e])),i=new Set,a=[];for(let t of e){t.sessionID&&i.add(t.sessionID);let e=t.sessionID?r.get(t.sessionID):void 0,o=t.running||!!e?.busy||!!(t.sessionID&&n?.has(t.sessionID));a.push({key:t.id,sessionID:t.sessionID,seed:t.id,label:t.label||e?.title?.trim()||``,phase:o?`working`:`done`})}for(let e of t)i.has(e.id)||a.push({key:e.id,sessionID:e.id,seed:e.id,label:e.title?.trim()||``,phase:e.busy?`working`:`done`});let o=a.filter(e=>e.phase===`working`),s=a.filter(e=>e.phase===`done`);return o.length===0?s:s.length===0?o:[...o,...s]},Ga=new Set,Ka=e=>{if(!e)return``;let t=[];for(let n of Object.keys(e)){let r=e[n]?.type;(r===`busy`||r===`retry`)&&t.push(n)}return t.sort(),t.join(`
|
|
1
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{c as t,i as n,n as r,o as i,r as a,s as o}from"./runtime-switch-BJM2k_uH.js";import{n as s}from"./runtime-fetch-CiqQd__Y.js";import{En as c,Ht as l,It as u,d,en as f,f as p,ft as m,it as h,on as g,pn as _,rn as v,sn as y,wn as b}from"./persistence-Dnj1QOdX.js";import{a as x,i as S,o as C}from"./vendor-zustand-DzRqcymP.js";import{nt as w,o as T,rt as E,s as D,tt as O}from"./vendor-base-ui-CnHfUmDN.js";import{Ct as k,Mt as A,Nt as j,lr as M,r as N}from"./platform-wu6wSDfg.js";import{n as P,t as F,x as I}from"./useUIStore-Dfx6TKvi.js";import{n as L}from"./vendor-react-DLPElpoQ.js";import{l as R,n as z,o as B,s as V,t as ee}from"./vendor-tanstack-react-query-D7pys_c9.js";import{i as H}from"./terminalApi-DXyzaX3K.js";import{c as U,d as W,f as te,l as G,m as K,n as ne,o as re,p as ie,s as q,t as ae,u as J}from"./vendor-pierre-diffs-DX7XTPG3.js";import{r as oe}from"./vendor-sonner-DVzioF3d.js";import{l as se,n as ce,p as le,r as ue}from"./vendor-reactuses-core-Dq5ocTF8.js";import{d as de,f as fe,i as pe,l as me,p as he,r as Y,t as X,u as ge}from"./button-CUwjpv-i.js";import{i as _e,t as ve}from"./store-l_X_jQNz.js";import{A as ye,D as be,E as xe,O as Se,k as Ce,t as we}from"./MobileDetailNavigation-K0t7WpHc.js";import{$n as Te,An as Ee,Ar as De,Cn as Oe,Cr as ke,Er as Ae,Fr as je,Gt as Me,Ht as Ne,Ir as Pe,Mr as Fe,Or as Ie,Pr as Le,Sn as Re,Vt as ze,Wn as Be,Xr as Ve,Yn as He,Zr as Ue,aa as We,br as Ge,cn as Ke,co as qe,d as Je,fi as Ye,fo as Xe,ga as Ze,go as Qe,jn as $e,jr as et,ka as tt,kr as nt,mi as rt,mo as it,o as at,oo as ot,so as st,ti as ct,va as lt,wr as ut,xn as dt,yi as ft}from"./useMobileNavigationStore-EUU6F5qa.js";import{i as pt,t as mt}from"./useAssistantUIStore-DBwfg9nX.js";import{a as ht,i as gt,n as _t,o as vt,r as yt,t as bt}from"./dialog-PjKWayIU.js";import{t as xt}from"./AgentAvatar-C1MGZ7qC.js";import{n as Z}from"./Icon-BdzPRCSy.js";import{d as St}from"./gitApi-DE2yWjO8.js";import{$ as Ct,B as wt,E as Tt,J as Et,Mt as Dt,Q as Ot,Rt as kt,V as At,X as jt,_t as Mt,c as Nt,et as Pt,gt as Ft,it as It,lt as Lt,mt as Rt,nt as zt,o as Bt,pt as Vt,rt as Ht,s as Ut,tt as Wt,vt as Gt}from"./useAppFontEffects-DSU_Sv-3.js";import{A as Kt,_ as qt,a as Jt,b as Yt,d as Xt,f as Zt,h as Qt,i as $t,l as en,m as tn,n as nn,p as rn,r as an,s as on,t as sn,x as cn}from"./projectMeta-C73SSuR-.js";import{t as ln}from"./input-BeVw4D0W.js";import{i as un,n as dn,t as fn}from"./tooltip-DDNnmcXI.js";import{Dt as pn,Et as mn,J as hn,Rt as gn,Tt as _n,at as vn,ct as yn,gt as bn,h as xn,it as Sn,m as Cn,mt as wn,q as Tn,rt as En,st as Dn,tt as On,ut as kn,wt as An}from"./useSessionAutoCleanup-HIVvSBYB.js";import{n as jn,t as Mn}from"./useThemeSystem-DMzWVJaW.js";import{i as Nn,t as Pn}from"./OverlayScrollbar-C1C2aKOe.js";import{s as Fn}from"./markdownTheme-DM5h1i18.js";import{n as In}from"./useRuntimeAPIs-DSLXJybW.js";import{C as Ln,g as Rn,h as zn,i as Bn,n as Vn,o as Hn,p as Un,r as Wn,t as Gn,x as Kn,y as qn}from"./textarea-Kl-rTWJe.js";import{D as Jn}from"./sessionChangeSummary-Dkh6zTfg.js";import{D as Yn,b as Xn,h as Zn,k as Qn,r as $n,v as er,w as tr,y as nr}from"./insertionBoundaries-DDPb68YA.js";import{i as rr,n as ir,t as ar}from"./appThemeRegistry-Dlr9-bh4.js";import{_ as or,i as sr,l as cr,s as lr,t as ur,v as dr,y as fr}from"./vendor-dnd-kit-core-CvWxUPdb.js";import{a as pr,o as mr,s as hr,t as gr}from"./vendor-dnd-kit-sortable-hHdP9lLb.js";import{f as _r,l as vr}from"./markdown-worker-bS5OgGO3.js";import{n as yr}from"./useEffectiveDirectory-CFQzWp5y.js";import{f as br}from"./FadeInOnReveal-BMSk_tY-.js";import{m as xr}from"./imageSource-BpUsiwFd.js";import{n as Sr}from"./useWorkerHighlightedLines-CpujrTzr.js";import{t as Cr}from"./vendor-tanstack-react-virtual-tlDgH6PG.js";import{a as wr,i as Tr,n as Er}from"./vendor-framer-motion-DFy_BSVd.js";import{A as Dr,N as Or,U as kr,t as Ar,u as jr,v as Mr,x as Nr}from"./MobileTabPageHeader-DqJxINvb.js";import{c as Pr,l as Fr}from"./mcpQueries-ocXyPQro.js";import{n as Ir,r as Lr}from"./sessionLookup-CFAECzHw.js";import{a as Rr,i as zr,n as Br,r as Vr,t as Hr}from"./context-menu-K6zNumqN.js";import{n as Ur,r as Wr,t as Gr}from"./collapsible-paItOH3A.js";import{t as Kr}from"./vendor-cron-parser-CCD11YFT.js";var Q=e(E(),1),qr=L(),$=w(),Jr=e(O(),1);function Yr(){return new Worker(ae,{type:`module`})}var Xr=[`typescript`,`javascript`,`tsx`,`jsx`,`json`,`markdown`],Zr={unified:{poolSize:1,totalASTLRUCacheSize:24,lineDiffType:`none`},split:{poolSize:2,totalASTLRUCacheSize:56,lineDiffType:`word-alt`}},Qr,$r,ei=e=>{let t=Zr[e],n=new ie({workerFactory:Yr,poolSize:t.poolSize,totalASTLRUCacheSize:t.totalASTLRUCacheSize},{theme:{light:`pierre-light`,dark:`pierre-dark`},langs:Xr,lineDiffType:t.lineDiffType,preferredHighlighter:`shiki-wasm`});return n.initialize(),n},ti=e=>{if(!(typeof window>`u`))return e===`split`?($r??=ei(`split`),$r):(Qr??=ei(`unified`),Qr)},ni=e=>{let t=(0,qr.c)(7),{children:n,renderTheme:r}=e,i=ii(`unified`),a=ii(`split`),o,s;t[0]!==r||t[1]!==a||t[2]!==i?(o=()=>{i&&i.setRenderOptions({theme:r,lineDiffType:Zr.unified.lineDiffType}),a&&a.setRenderOptions({theme:r,lineDiffType:Zr.split.lineDiffType})},s=[r,a,i],t[0]=r,t[1]=a,t[2]=i,t[3]=o,t[4]=s):(o=t[3],s=t[4]),(0,Q.useEffect)(o,s);let c;return t[5]===n?c=t[6]:(c=(0,$.jsx)($.Fragment,{children:n}),t[5]=n,t[6]=c),c},ri=e=>{let t=(0,qr.c)(11),{children:n}=e,r=Mn(),i,a;if(t[0]!==r?.availableThemes||t[1]!==r?.darkThemeId||t[2]!==r?.lightThemeId){let e=Fn(!1),n=Fn(!0),o=r?.lightThemeId??e.metadata.id,s=r?.darkThemeId??n.metadata.id;a=r?.availableThemes.find(e=>e.metadata.id===o)??e,i=r?.availableThemes.find(e=>e.metadata.id===s)??n,ar(a),ar(i),t[0]=r?.availableThemes,t[1]=r?.darkThemeId,t[2]=r?.lightThemeId,t[3]=i,t[4]=a}else i=t[3],a=t[4];let o;t[5]!==i.metadata.id||t[6]!==a.metadata.id?(o={light:a.metadata.id,dark:i.metadata.id},t[5]=i.metadata.id,t[6]=a.metadata.id,t[7]=o):o=t[7];let s=o,c;return t[8]!==n||t[9]!==s?(c=(0,$.jsx)(ni,{renderTheme:s,children:n}),t[8]=n,t[9]=s,t[10]=c):c=t[10],c},ii=e=>{let t=(0,qr.c)(2),n=e===void 0?`unified`:e,r;return t[0]===n?r=t[1]:(r=ti(n),t[0]=n,t[1]=r),r},ai=Q.forwardRef((e,t)=>{let n=(0,qr.c)(11),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=Y(`peer inline-flex shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-none transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[checked]:bg-primary data-[unchecked]:bg-[var(--interactive-border)]`,r),n[3]=r,n[4]=a);let o;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(o={width:`36px`,height:`20px`,minWidth:`36px`,minHeight:`20px`},n[5]=o):o=n[5];let s;n[6]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(T,{className:Y(`pointer-events-none block rounded-full bg-background shadow-none ring-0 transition-transform data-[checked]:translate-x-4 data-[unchecked]:translate-x-0`),style:{width:`16px`,height:`16px`,minWidth:`16px`,minHeight:`16px`}}),n[6]=s):s=n[6];let c;return n[7]!==i||n[8]!==t||n[9]!==a?(c=(0,$.jsx)(D,{className:a,style:o,...i,ref:t,children:s}),n[7]=i,n[8]=t,n[9]=a,n[10]=c):c=n[10],c});ai.displayName=`Switch`;var oi={},si=[],ci=(e,t)=>{if(!e)return t(`mcpDropdown.status.unknown`);switch(e.status){case`connected`:return t(`mcpDropdown.status.connected`);case`failed`:return t(`mcpDropdown.status.failed`,{error:e.error||t(`mcpDropdown.status.unknownError`)});case`needs_auth`:return t(`mcpDropdown.status.needsAuth`);case`needs_client_registration`:return t(`mcpDropdown.status.needsRegistration`,{error:e.error||``});default:return e.status}},li=e=>{switch(e?.status){case`connected`:return`success`;case`failed`:return`error`;case`needs_auth`:case`needs_client_registration`:return`warning`;default:return`default`}},ui=({active:e,className:t,headerAction:n,listClassName:r,hideHeader:i=!1,mobileListDensity:a=!1})=>{let{t:o}=fe(),s=k(e=>e.currentDirectory)??null,c=kr(e=>e.connect),l=kr(e=>e.disconnect),{data:u,refetch:d,isError:f,error:p}=Fr(s,{enabled:e}),{data:m}=Pr(s,{enabled:e}),h=u??oi,g=m??si,[_,v]=Q.useState(!1),[y,b]=Q.useState(null),x=Q.useMemo(()=>{let e=new Set(Object.keys(h));for(let t of g)t?.name&&e.add(t.name);return Array.from(e).sort((e,t)=>e.localeCompare(t))},[g,h]),S=Q.useCallback(e=>{if(e?.preventDefault(),_)return;v(!0);let t=new Promise(e=>setTimeout(e,500));Promise.all([d(),t]).finally(()=>{v(!1)})},[_,d]);return(0,$.jsxs)(`div`,{className:Y(`w-full`,t),children:[i?null:(0,$.jsx)(`div`,{className:`border-b border-[var(--interactive-border)]`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-4 py-2.5`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex items-baseline gap-2`,children:[(0,$.jsx)(`div`,{className:`typography-ui-header font-semibold text-foreground`,children:o(`mcpDropdown.title`)}),s&&(0,$.jsx)(`div`,{className:`truncate typography-micro text-muted-foreground`,children:s.split(`/`).pop()||s})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[n,(0,$.jsx)(`button`,{type:`button`,className:`inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:text-foreground hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,disabled:_,onClick:S,"aria-label":o(`mcpDropdown.actions.refreshAria`),children:(0,$.jsx)(Z,{name:`refresh`,className:Y(`h-4 w-4`,_&&`animate-spin`)})})]})]})}),(0,$.jsx)(`div`,{className:Y(`max-h-64 overflow-y-auto`,a?`space-y-1 py-3`:`px-3 py-2.5`,r),children:(0,$.jsxs)(`div`,{className:Y(!a&&x.length>0&&`rounded-xl bg-[var(--surface-muted)] p-1.5`),children:[x.map(e=>{let t=h[e]??(f&&!u&&g.some(t=>t.name===e)?{status:`failed`,error:p.message}:void 0),n=li(t),r=t?.status===`connected`,i=y===e,d=ci(t,o);return(0,$.jsxs)(`div`,{className:Y(`flex items-center justify-between rounded-lg hover:bg-interactive-hover/50`,a?`gap-3 px-4 py-3`:`gap-2 px-2.5 py-2`),children:[(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,$.jsxs)(fn,{children:[(0,$.jsx)(un,{asChild:!0,children:(0,$.jsx)(`span`,{className:Y(`rounded-full flex-shrink-0`,a?`h-2.5 w-2.5`:`h-2 w-2`,n===`success`&&`bg-status-success`,n===`error`&&`bg-status-error`,n===`warning`&&`bg-status-warning`,n==="default"&&`bg-muted-foreground/40`),"aria-label":d})}),(0,$.jsx)(dn,{side:`left`,children:(0,$.jsx)(`p`,{children:d})})]}),(0,$.jsx)(`span`,{className:Y(`truncate`,a?`text-[17px] leading-6 font-medium`:`typography-ui-label`),children:e})]})}),(0,$.jsx)(ai,{checked:r,disabled:i,className:`data-[checked]:bg-status-info`,onCheckedChange:async t=>{b(e);try{t?await c(e,s):await l(e,s)}finally{b(null)}}})]},e)}),x.length===0&&(0,$.jsx)(`div`,{className:`px-4 py-5 typography-ui-label text-muted-foreground text-center`,children:o(`mcpDropdown.empty.configureInConfig`)})]})})]})},di=e=>!(e.dismissed===`true`||e.sessionShown===`true`||e.hasActiveToast),fi=e=>!(!e.version||e.seenVersions.has(e.version)||e.dismissedVersion!==null&&e.dismissedVersion===e.version),pi=e=>{if(typeof e!=`object`||!e)return``;let t=e.version;return typeof t==`string`?t.trim():``},mi=e=>{if(!e||e.available!==!0||e.canManage===!1)return``;let t=typeof e.latestVersion==`string`?e.latestVersion:typeof e.targetVersion==`string`?e.targetVersion:``;return t?t.trim():``},hi=e=>{let t=e.trim().replace(/^v/i,``);return t?{target:t}:null},gi=5e3,_i={setTimeout:(e,t)=>globalThis.setTimeout(e,t),clearTimeout:e=>globalThis.clearTimeout(e)};function vi(e,t,n=_i){if(!e)return()=>void 0;let r=n.setTimeout(()=>{t().catch(()=>void 0)},gi);return()=>n.clearTimeout(r)}var yi=(e,t)=>({queryKey:[e,`opencode-update`,t],queryFn:async({signal:i})=>{let a=()=>e===n()&&t===r();if(!a())throw Error(`Stale OpenCode update check`);let o=await s(`/api/opencode/upgrade-status`,{headers:{Accept:`application/json`},signal:i});if(!o.ok)throw Error(`OpenCode update check failed`);let c=await o.json();if(i.aborted||!a())throw Error(`Stale OpenCode update check`);if(!c||typeof c!=`object`||Array.isArray(c))throw Error(`Invalid OpenCode update status`);return c},staleTime:3e4,refetchInterval:3e5,refetchOnWindowFocus:!0,refetchOnReconnect:!0,retry:1}),bi=`opencode-update-available`,xi=`opencode-upgrade-progress`,Si=`opencode-update-toast-dismissed-version`,Ci=()=>{let{t:e}=fe(),i=P(e=>e.showOpenCodeUpdateNotifications),a=Q.useRef(new Set),o=Q.useRef(!1),c=Q.useSyncExternalStore(t,n,n),l=Q.useSyncExternalStore(t,r,r),u=R(),[d,f]=Q.useState(!1);Q.useEffect(()=>vi(i,async()=>{f(!0)}),[i]);let p=V({...yi(c,l),enabled:i&&d});ue(`openchamber:opencode-update-available`,e=>{i&&pi(e.detail)&&p.refetch()});let m=`${Si}:${c}`;Q.useEffect(()=>{a.current.clear(),Pe.dismiss(bi),Pe.dismiss(xi)},[c,l]),Q.useEffect(()=>{i||Pe.dismiss(bi)},[i]);let h=ce(async(t,i=!1)=>{if(o.current)return;o.current=!0;let a=()=>c===n()&&l===r();Pe.dismiss(bi),Pe.message(e(`opencodeUpdate.toast.upgrading.title`),{id:xi,description:e(`opencodeUpdate.toast.upgrading.description`),duration:1/0,icon:(0,$.jsx)(Z,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})});try{let n=hi(t);if(!n)throw Error(e(`opencodeUpdate.toast.failed.description`));let r=await s(`/api/opencode/upgrade`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({...n,confirmActiveTasks:i})}),o=await r.json().catch(()=>null);if(!a())return;if(o?.errorCode===`UPGRADE_ACTIVE_TASKS`){Pe.error(e(`opencodeUpdate.toast.failed.title`),{id:xi,description:o.error,duration:1/0,action:{label:e(`opencodeUpdate.toast.actions.update`),onClick:()=>{a()&&h(t,!0)}}});return}if(!r.ok||o?.success!==!0)throw Error(o?.error||r.statusText||e(`opencodeUpdate.toast.failed.description`));Pe.success(e(`opencodeUpdate.toast.updated.title`),{id:xi,description:o?.version?e(`opencodeUpdate.toast.updated.descriptionWithVersion`,{version:o.version}):e(`opencodeUpdate.toast.updated.description`),duration:1/0,icon:(0,$.jsx)(Z,{name:`check`,className:`h-4 w-4 text-[var(--status-success)]`})}),u.invalidateQueries({queryKey:[c,`opencode-update`,l]}),u.invalidateQueries({queryKey:[c,`about`,l]})}catch(n){if(!a())return;Pe.error(e(`opencodeUpdate.toast.failed.title`),{id:xi,description:n instanceof Error?n.message:e(`opencodeUpdate.toast.failed.description`),duration:1/0,action:{label:e(`opencodeUpdate.toast.actions.update`),onClick:()=>{a()&&h(t)}}})}finally{o.current=!1}});return Q.useEffect(()=>{let t=t=>{if(!P.getState().showOpenCodeUpdateNotifications){Pe.dismiss(bi);return}fi({version:t,dismissedVersion:I().getItem(m),seenVersions:a.current})&&(a.current.add(t),Pe.info(e(`opencodeUpdate.toast.available.title`),{id:bi,description:e(`opencodeUpdate.toast.available.description`,{version:t}),duration:1/0,action:{label:e(`opencodeUpdate.toast.actions.update`),onClick:()=>{c===n()&&l===r()&&h(t)}},cancel:{label:e(`opencodeUpdate.toast.actions.dismiss`),onClick:()=>{I().setItem(m,t),Pe.dismiss(bi)}}}))},i=mi(p.data);i?t(i):(p.data?.available===!1||p.data?.canManage===!1)&&Pe.dismiss(bi)},[i,e,p.data,m,c,l,h]),null},wi=()=>{let e=(0,qr.c)(3),[t,n]=Q.useState(Ti),{isUpdating:r}=t,i,a;if(e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=()=>qe(n),a=[],e[0]=i,e[1]=a):(i=e[0],a=e[1]),Q.useEffect(i,a),!r)return null;let o;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(`div`,{className:`fixed inset-0 z-[9999] flex items-center justify-center bg-background/90`,children:(0,$.jsx)(gn,{width:80,height:80,isAnimated:!0})}),e[2]=o):o=e[2],o};function Ti(){return st()}var Ei=5e3,Di=(e,t)=>{if(!e)return 1;let n=1;for(let r=0;r<e.length;r+=1)if(e.charCodeAt(r)===10&&(n+=1,n>t))return n;return n},Oi=(e,t)=>ve(_e.getState().dictionary,e,t),ki=e=>{let t=(e instanceof Error?e.message:String(e??``)).toLowerCase();return t.includes(`file not found`)||t.includes(`not found`)||t.includes(`enoent`)||t.includes(`no such file`)||t.includes(`does not exist`)?`missing`:`unreadable`},Ai=async(e,t)=>{if(e.readFile){let n=await e.readFile(t,{optional:!0});if(typeof n.exists!=`boolean`)throw Error(`Optional file read requires an existence response header`);return{content:n.content??``,exists:n.exists}}let n=new URLSearchParams({path:t,optional:`true`}),r=await s(`/api/fs/read?${n.toString()}`,{cache:`no-store`});if(!r.ok){let e=await r.json().catch(()=>({error:r.statusText}));throw Error(e.error||`Failed to read file`)}let i=r.headers.get(`x-openchamber-file-exists`);if(i!==`true`&&i!==`false`)throw Error(`Optional file read requires an existence response header`);return{content:await r.text(),exists:i===`true`}},ji=async(e,t)=>{try{let{content:n,exists:r}=await Ai(e,t);return r?Di(n,5e3)>5e3?{ok:!1,reason:`too-large`}:{ok:!0}:{ok:!1,reason:`missing`}}catch(e){return{ok:!1,reason:ki(e)}}},Mi=e=>e===`too-large`?Oi(`contextFileOpen.failure.tooLarge`,{count:Ei.toLocaleString(he())}):Oi(e===`missing`?`contextFileOpen.failure.missing`:`contextFileOpen.failure.unreadable`),Ni=(e,t)=>!e||t.length===0?``:JSON.stringify([e,t]),Pi=(e,t,n,r)=>!n||r!==n||e.length===0?[]:Be(e,t,e=>e.name,{limit:10,threshold:.4}),Fi=(e,t={})=>{let r=e.trim(),i=t.transport??n(),a=t.searchSessions??(e=>j.searchSessionsByTitle(e));return B({queryKey:p.sessionTitleSearch.query(r,i),enabled:r.length>0,queryFn:({signal:e})=>a({search:r,limit:30,signal:e}),staleTime:5e3,retry:1})},Ii=e=>{let t=(0,qr.c)(13),{title:n,description:r,trailing:i}=e,a=r?`min-w-0 max-w-[58%] shrink-0 truncate typography-meta font-medium leading-4 text-foreground`:`min-w-0 flex-1 truncate typography-meta font-medium leading-4 text-foreground`,o;t[0]!==a||t[1]!==n?(o=(0,$.jsx)(`span`,{className:a,children:n}),t[0]=a,t[1]=n,t[2]=o):o=t[2];let s;t[3]===r?s=t[4]:(s=r?(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-micro leading-4 text-muted-foreground/65`,children:r}):null,t[3]=r,t[4]=s);let c;t[5]!==o||t[6]!==s?(c=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2.5`,children:[o,s]}),t[5]=o,t[6]=s,t[7]=c):c=t[7];let l;t[8]===i?l=t[9]:(l=i?(0,$.jsx)(`div`,{className:`ml-auto flex shrink-0 items-center pl-2 text-muted-foreground/50`,children:i}):null,t[8]=i,t[9]=l);let u;return t[10]!==c||t[11]!==l?(u=(0,$.jsxs)($.Fragment,{children:[c,l]}),t[10]=c,t[11]=l,t[12]=u):u=t[12],u},Li=`min-h-9 gap-2 rounded-lg px-3 py-2 typography-meta`,Ri=`py-0 [&_[cmdk-group-heading]]:px-2.5 [&_[cmdk-group-heading]]:pb-2 [&_[cmdk-group-heading]]:pt-3 [&_[cmdk-group-heading]]:font-normal [&_[cmdk-group-heading]]:text-muted-foreground`;function zi(e,t){let n=t.toLowerCase().split(/\s+/).filter(Boolean);if(!n.length)return e;let r=n.map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`));return e.split(RegExp(`(${r.join(`|`)})`,`gi`)).map((e,t)=>n.includes(e.toLowerCase())?(0,$.jsx)(`mark`,{className:`bg-transparent font-[inherit] text-[var(--primary-base)]`,children:e},t):e)}var Bi=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},Vi=e=>{let t=(0,qr.c)(180),{presentation:n,onBack:r}=e,i=n===void 0?`dialog`:n,{t:a}=fe(),o=Jn(),s=P(Hi),[c,u]=Q.useState(s),d=P(Ui),p=P(Wi),m=P(Gi),h=P(Ki),_=P(qi),b=P(Ji),x=P(Yi),S=P(Xi),C=P(Zi),w=P(Qi),T=P($i),E=Je(ea),D=Je(ta),O=Fe(na),j=Fe(ra),M=k(ia),N=ot(aa),F=ot(oa),I=yr(),L=A(sa),{files:R}=In(),{isMobile:z}=Nn(),B=i===`page`||z,ee;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(ee=me(),t[0]=ee):ee=t[0];let H=ee,U=Q.useRef(null),W=Q.useRef(null),te;t[1]!==s||t[2]!==B?(te=()=>{if(!B||!s||!U.current)return;let e=window.visualViewport;U.current.style.setProperty(`--search-viewport-height`,`${e?.height??window.innerHeight}px`),U.current.style.setProperty(`--search-viewport-top`,`${e?.offsetTop??0}px`)},t[1]=s,t[2]=B,t[3]=te):te=t[3];let G=ce(te),K;t[4]!==s||t[5]!==B?(K=()=>B&&s?window.visualViewport??window:null,t[4]=s,t[5]=B,t[6]=K):K=t[6],ue(`resize`,G,K);let ne;t[7]!==s||t[8]!==B?(ne=()=>B&&s?window.visualViewport:null,t[7]=s,t[8]=B,t[9]=ne):ne=t[9],ue(`scroll`,G,ne);let re;t[10]===G?re=t[11]:(re=()=>{G()},t[10]=G,t[11]=re);let ie;t[12]!==s||t[13]!==B?(ie=[B,s],t[12]=s,t[13]=B,t[14]=ie):ie=t[14],Q.useEffect(re,ie);let q,ae;t[15]!==s||t[16]!==i?(q=()=>{i===`page`&&s&&W.current?.focus({preventScroll:!0})},ae=[i,s],t[15]=s,t[16]=i,t[17]=q,t[18]=ae):(q=t[17],ae=t[18]),Q.useEffect(q,ae);let J;t[19]===I?J=t[20]:(J=I?Bi(I):null,t[19]=I,t[20]=J);let oe=J,[se,le]=Q.useState(``),de=Qn(se,200).trim(),pe;t[21]===se?pe=t[22]:(pe=se.trim(),t[21]=se,t[22]=pe);let he=pe,Y,X;t[23]===s?(Y=t[24],X=t[25]):(Y=()=>{s&&(le(``),u(!0))},X=[s],t[23]=s,t[24]=Y,t[25]=X),Q.useEffect(Y,X);let _e;t[26]===d?_e=t[27]:(_e=()=>d(!1),t[26]=d,t[27]=_e);let ve=ce(_e),ye;t[28]===ve?ye=t[29]:(ye=e=>()=>{ve(),e()},t[28]=ve,t[29]=ye);let be=ce(ye);N?.id,N?.path;let xe=(()=>{let e=[{id:`new-session`,title:a(`commandPalette.item.newSession`),shortcutId:`new_chat`,searchText:a(`commandPalette.item.newSession`),onSelect:be(()=>{p(`chat`),_(!1),E()})},{id:`new-worktree`,title:a(`commandPalette.item.newWorktreeDraft`),shortcutId:`new_chat_worktree`,searchText:a(`commandPalette.item.newWorktreeDraft`),onSelect:be(ca)},{id:`add-project`,title:a(`commandPalette.item.addProject`),searchText:a(`commandPalette.item.addProject`),onSelect:be(la)},{id:`toggle-sidebar`,title:a(B?`commandPalette.item.showSessionSwitcher`:`commandPalette.item.toggleSidebar`),shortcutId:`toggle_sidebar`,searchText:a(B?`commandPalette.item.showSessionSwitcher`:`commandPalette.item.toggleSidebar`),onSelect:be(()=>{if(B){let{isSessionSwitcherOpen:e}=P.getState();_(!e)}else b()})},{id:`toggle-right-sidebar`,title:a(`commandPalette.item.toggleRightSidebar`),shortcutId:`toggle_right_sidebar`,searchText:a(`commandPalette.item.toggleRightSidebar`),onSelect:be(()=>x())},{id:`toggle-terminal`,title:a(`commandPalette.item.toggleTerminal`),shortcutId:`toggle_terminal`,searchText:a(`commandPalette.item.toggleTerminal`),onSelect:be(()=>S())},{id:`new-terminal-tab`,title:a(`commandPalette.item.newTerminalTab`),shortcutId:`open_new_terminal`,searchText:a(`commandPalette.item.newTerminalTab`),onSelect:be(()=>{I&&Nt(I)})},{id:`context-usage`,title:a(`commandPalette.item.showContextUsage`),searchText:a(`commandPalette.item.showContextUsage`),onSelect:be(()=>{M&&C(M)})},{id:`open-settings`,title:a(`commandPalette.item.openSettings`),shortcutId:`open_settings`,searchText:a(`commandPalette.item.openSettings`),onSelect:be(()=>m(!0))}];return l()&&e.splice(1,0,{id:`new-mini-chat`,title:a(`commandPalette.item.newMiniChat`),shortcutId:`new_mini_chat`,searchText:a(`commandPalette.item.newMiniChat`),onSelect:be(()=>{f(`desktop_open_draft_mini_chat_window`,{directory:Bi(M||N?.path||``),projectId:N?.id??null}).catch(ua)})}),e})(),Se=v(),Ce={isVSCode:g(),isWeb:!Se&&y(),isDesktop:Se,isMobile:B},Ee=Dr.filter(da).filter(e=>!e.isAvailable||e.isAvailable(Ce)).map(e=>{let t=(e.keywords??[]).join(` `);return{id:`settings:${e.slug}`,title:e.title,searchText:`${e.title} ${e.group} ${t}`,onSelect:be(()=>{h(e.slug),m(!0)})}}),De=fa,Oe;if(t[30]!==O){let e;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(e=(e,t)=>De(t)-De(e),t[32]=e):e=t[32],Oe=[...O].sort(e),t[30]=O,t[31]=Oe}else Oe=t[31];let ke=Oe,Ae=Je(pa),je=Je(ma),Me;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(Me=[],t[33]=Me):Me=t[33];let[Ne,Ie]=Q.useState(Me),[Le,Re]=Q.useState(``),[ze,Ve]=Q.useState(``),He=Ni(oe,de),Ue;t[34]!==oe||t[35]!==He||t[36]!==s||t[37]!==L||t[38]!==Ve||t[39]!==Ie||t[40]!==Re||t[41]!==de?(Ue=()=>{if(!s){Ie([]),Re(``),Ve(``);return}if(!He){Ie([]),Re(``),Ve(``);return}if(!oe){Ie([]),Re(``),Ve(``);return}let e=!1;return Ve(``),L(oe,de,10,{type:`file`}).then(t=>{e||(Ie(t.map(ha)),Re(He),Ve(``))}).catch(()=>{e||(Ie([]),Re(``),Ve(He))}),()=>{e=!0}},t[34]=oe,t[35]=He,t[36]=s,t[37]=L,t[38]=Ve,t[39]=Ie,t[40]=Re,t[41]=de,t[42]=Ue):Ue=t[42];let We;t[43]!==oe||t[44]!==He||t[45]!==s||t[46]!==L||t[47]!==de?(We=[s,oe,de,He,L],t[43]=oe,t[44]=He,t[45]=s,t[46]=L,t[47]=de,t[48]=We):We=t[48],Q.useEffect(Ue,We);let Ge=he.length>0,Ke;bb0:{if(!Ge){Ke=xe.map(ga);break bb0}Ke=Be(xe,he,_a,{limit:7,noFuzzy:!0})}let qe=Ke,Ye;bb1:{if(!Ge){Ye=[];break bb1}Ye=Be(Ee,he,va,{limit:7,noFuzzy:!0})}let Xe=Ye,Ze;t[49]===de?Ze=t[50]:(Ze=Fi(de),t[49]=de,t[50]=Ze);let Qe=(s||c)&&(de.length>0||i===`page`),$e;t[51]!==Ze||t[52]!==Qe?($e={...Ze,enabled:Qe},t[51]=Ze,t[52]=Qe,t[53]=$e):$e=t[53];let et=V($e),tt=Ge&&he===de&&et.isSuccess,rt=(Ge||i===`page`)&&he===de&&et.isError,it;bb2:{if(!rt){let e;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[54]=e):e=t[54],it=e;break bb2}let e;t[55]!==he||t[56]!==ke?(e=Be(ke,he,ya,{limit:30,threshold:.2}).map(ba),t[55]=he,t[56]=ke,t[57]=e):e=t[57],it=e}let st=it,ct;bb3:{if(!Ge){if(i===`page`&&!de&&et.isSuccess){ct=et.data;break bb3}let e;t[58]!==i||t[59]!==ke?(e=ke.slice(0,i===`page`?30:9),t[58]=i,t[59]=ke,t[60]=e):e=t[60],ct=e;break bb3}if(!tt){let e;t[61]!==st||t[62]!==rt?(e=rt?st:[],t[61]=st,t[62]=rt,t[63]=e):e=t[63],ct=e;break bb3}let e;t[64]===et.data?e=t[65]:(e=et.data??[],t[64]=et.data,t[65]=e),ct=e}let lt=ct,ut;bb4:{if(!s&&!c){ut=[];break bb4}if(he!==de||ze===He){ut=[];break bb4}ut=Pi(Ne,de,He,Le)}let dt=ut,ft=(s||c)&&He.length>0&&Le!==He&&ze!==He,pt;bb5:{if(!Ge){pt=[];break bb5}let e=F.map(xa);pt=Be(e,he,Sa,{limit:7,threshold:.4})}let mt=pt,gt=qe.map(Ca),xt=Xe.map(wa),Z=lt,St=Ge?dt.map(Ta):[],wt=Ge?mt.map(Ea):[],Tt;bb6:{if(!Ge){Tt=[`sessions`,`commands`];break bb6}let e=Da,t=[{key:`commands`,score:e(qe)},{key:`settings`,score:e(Xe)},{key:`files`,score:e(dt)},{key:`projects`,score:e(mt)}];t.sort(Oa),Tt=[`sessions`,...t.map(ka)]}let Et=Tt,Dt;t[66]!==ve||t[67]!==o||t[68]!==p||t[69]!==D||t[70]!==_?(Dt=e=>{ve(),p(`chat`),_(!1);let t=nt(e)||``;o?at.getState().openSession({sessionId:e.id,directory:t}):D(e.id,t)},t[66]=ve,t[67]=o,t[68]=p,t[69]=D,t[70]=_,t[71]=Dt):Dt=t[71];let kt=ce(Dt),At;t[72]!==ve||t[73]!==oe||t[74]!==R||t[75]!==o||t[76]!==w?(At=async e=>{if(!oe)return;let t=await ji(R,e);if(!t.ok){Pe.error(Mi(t.reason));return}o?o.openFile({path:e}):w(oe,e),ve()},t[72]=ve,t[73]=oe,t[74]=R,t[75]=o,t[76]=w,t[77]=At):At=t[77];let jt=ce(At),Mt;t[78]!==ve||t[79]!==o||t[80]!==E?(Mt=(e,t)=>{ve();let n={selectedProjectId:e,directoryOverride:t};o?at.getState().openDraft(n):E(n)},t[78]=ve,t[79]=o,t[80]=E,t[81]=Mt):Mt=t[81];let Ft=ce(Mt),It=e=>wn(bn(e,T)),Lt;t[82]!==kt||t[83]!==B||t[84]!==Z?(Lt=e=>{if(B||e.nativeEvent.isComposing||e.altKey||e.shiftKey||(H?!e.metaKey||e.ctrlKey:!e.ctrlKey||e.metaKey)||!/^[1-9]$/.test(e.key)||(e.preventDefault(),e.stopPropagation(),e.repeat))return;let t=Z[Number(e.key)-1];t&&kt(t)},t[82]=kt,t[83]=B,t[84]=Z,t[85]=Lt):Lt=t[85];let Rt=ce(Lt),Bt=e=>{let t=Bi(Ae.get(e.id)?.projectDirectory||nt(e)||``),n=Te(F,je,t);return n?.label||(n?.path||t).split(`/`).pop()||``},Ut=Ge&&!!oe&&(he!==de||ft),Gt=Ge&&he===de&&!!He&&ze===He,Kt=(Ge||i===`page`)&&(he!==de||et.isFetching&&!et.isSuccess),qt=i===`page`?`mobileGlass`:`default`,Jt;t[86]===a?Jt=t[87]:(Jt=a(`commandPalette.title`),t[86]=a,t[87]=Jt);let Yt;t[88]===a?Yt=t[89]:(Yt=a(`commandPalette.input.placeholder`),t[88]=a,t[89]=Yt);let Xt;t[90]!==se||t[91]!==qt||t[92]!==Jt||t[93]!==Yt?(Xt=(0,$.jsx)(Wt,{ref:W,variant:qt,className:`font-normal`,"aria-label":Jt,inputMode:`search`,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,value:se,onValueChange:le,placeholder:Yt}),t[90]=se,t[91]=qt,t[92]=Jt,t[93]=Yt,t[94]=Xt):Xt=t[94];let Zt=Xt,Qt=Ot,$t,en,tn;t[95]===B?($t=t[96],en=t[97],tn=t[98]):($t=e=>{let t=e.target.closest(`[cmdk-item]`);B&&t&&Rn({currentTarget:t})},en=e=>{let t=e.target.closest(`[cmdk-item]`);B&&t&&zn({currentTarget:t,detail:1})},tn=e=>{let t=e.target.closest(`[cmdk-item]`);B&&t&&e.detail>0&&!zn({currentTarget:t,detail:e.detail})&&(e.preventDefault(),e.stopPropagation())},t[95]=B,t[96]=$t,t[97]=en,t[98]=tn);let nn;t[99]!==ve||t[100]!==r||t[101]!==i||t[102]!==Zt||t[103]!==a?(nn=i===`page`?(0,$.jsx)(we,{title:Zt,backAriaLabel:a(`header.actions.backAria`),onBack:r??ve}):Zt,t[99]=ve,t[100]=r,t[101]=i,t[102]=Zt,t[103]=a,t[104]=nn):nn=t[104];let rn=Ht,an;t[105]===a?an=t[106]:(an=a(`commandPalette.title`),t[105]=a,t[106]=an);let on;t[107]!==a||t[108]!==Z.length?(on=Z.length===0?(0,$.jsx)(`div`,{className:`px-2.5 pb-2 pt-3 typography-meta text-muted-foreground`,children:a(`layout.mainTab.chat`)}):null,t[107]=a,t[108]=Z.length,t[109]=on):on=t[109];let sn;t[110]!==Gt||t[111]!==j||t[112]!==a||t[113]!==rt||t[114]!==Ut||t[115]!==Kt?(sn=!Ut&&!Kt&&!Gt&&!rt&&j!==`loading`&&j!==`error`?(0,$.jsx)(Ct,{className:`py-10 text-center typography-meta text-muted-foreground`,children:a(`commandPalette.empty.noResults`)}):null,t[110]=Gt,t[111]=j,t[112]=a,t[113]=rt,t[114]=Ut,t[115]=Kt,t[116]=sn):sn=t[116];let cn=Et.map(e=>e===`commands`&>.length>0?(0,$.jsx)(Pt,{heading:a(`settings.page.commands.title`),className:Ri,children:gt.map(e=>(0,$.jsx)(zt,{value:e.id,onSelect:e.onSelect,className:Li,children:(0,$.jsx)(Ii,{title:e.title,trailing:!B&&e.shortcutId?(0,$.jsx)(Vt,{className:`h-3.5 min-w-0 shrink-0 rounded-full border-0 bg-[color-mix(in_srgb,var(--surface-foreground)_6%,transparent)] px-1.5 font-sans text-[10px] font-medium tracking-tight text-muted-foreground/65 shadow-none`,children:It(e.shortcutId)}):void 0})},e.id))},`commands`):e===`settings`&&xt.length>0?(0,$.jsx)(Pt,{heading:a(`settings.view.home.title`),className:Ri,children:xt.map(Aa)},`settings`):e===`sessions`&&Z.length>0?(0,$.jsx)(Pt,{heading:a(`layout.mainTab.chat`),className:Ri,children:Z.map((e,t)=>{let n=e.title||a(`commandPalette.session.untitled`),r=Bt(e);return(0,$.jsx)(zt,{value:`session:${e.id}`,onSelect:()=>kt(e),className:`flex-col items-stretch gap-1 rounded-lg px-3 py-2`,"aria-keyshortcuts":!B&&t<9?`${H?`Meta`:`Control`}+${t+1}`:void 0,children:(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-ui-label text-foreground`,title:n,children:zi(n,he)}),(0,$.jsx)(`span`,{className:`max-w-[28%] shrink-0 truncate typography-meta text-muted-foreground`,title:r,children:r}),!B&&t<9?(0,$.jsxs)(Vt,{className:`h-5 min-w-8 shrink-0 rounded-full border-0 bg-interactive-selection px-2 text-muted-foreground shadow-none`,children:[H?`⌘`:`Ctrl+`,t+1]}):null]})},e.id)})},`sessions`):e===`files`&&St.length>0?(0,$.jsx)(Pt,{heading:a(`layout.mainTab.files`),className:Ri,children:St.map(e=>{let t=ge(e.relativePath||e.name,{maxLength:80});return(0,$.jsx)(zt,{value:`file:${e.path}`,onSelect:()=>{jt(e.path)},className:Li,children:(0,$.jsx)(Ii,{title:zi(e.name,he),description:t===e.name?void 0:zi(t,he)})},`file:${e.path}`)})},`files`):e===`projects`&&wt.length>0?(0,$.jsx)(Pt,{heading:a(`sessions.sidebar.projectsTitle`),className:Ri,children:wt.map(e=>{let t=e.displayName;return(0,$.jsx)(zt,{value:`project:${e.id}`,onSelect:()=>Ft(e.id,e.path),className:Li,children:(0,$.jsx)(Ii,{title:zi(t,he)})},`project:${e.id}`)})},`projects`):null),ln;t[117]!==j||t[118]!==a?(ln=j===`loading`?(0,$.jsx)(`div`,{role:`status`,className:`px-3 py-4 text-center typography-meta text-muted-foreground`,children:a(`common.loading`)}):null,t[117]=j,t[118]=a,t[119]=ln):ln=t[119];let un;t[120]!==j||t[121]!==a?(un=j===`error`?(0,$.jsx)(`div`,{role:`alert`,className:`px-3 py-4 typography-meta text-[var(--status-error)]`,children:a(`commandPalette.error.sessions`)}):null,t[120]=j,t[121]=a,t[122]=un):un=t[122];let dn;t[123]!==a||t[124]!==rt?(dn=rt?(0,$.jsx)(`div`,{role:`alert`,className:`px-3 py-4 typography-meta text-[var(--status-error)]`,children:a(`commandPalette.error.sessions`)}):null,t[123]=a,t[124]=rt,t[125]=dn):dn=t[125];let fn;t[126]!==a||t[127]!==Kt?(fn=Kt?(0,$.jsx)(`div`,{role:`status`,className:`px-3 py-4 text-center typography-meta text-muted-foreground`,children:a(`common.loading`)}):null,t[126]=a,t[127]=Kt,t[128]=fn):fn=t[128];let pn;t[129]!==a||t[130]!==Ut?(pn=Ut?(0,$.jsx)(`div`,{role:`status`,className:`px-3 py-4 typography-meta text-muted-foreground`,children:a(`commandPalette.empty.searchingFiles`)}):null,t[129]=a,t[130]=Ut,t[131]=pn):pn=t[131];let mn;t[132]!==Gt||t[133]!==a?(mn=Gt?(0,$.jsx)(`div`,{role:`alert`,className:`px-3 py-4 typography-meta text-[var(--status-error)]`,children:a(`mobile.files.error.listFailed`)}):null,t[132]=Gt,t[133]=a,t[134]=mn):mn=t[134];let hn;t[135]!==rn||t[136]!==an||t[137]!==on||t[138]!==sn||t[139]!==cn||t[140]!==ln||t[141]!==un||t[142]!==dn||t[143]!==fn||t[144]!==pn||t[145]!==mn?(hn=(0,$.jsxs)(rn,{"aria-label":an,className:`overscroll-contain p-1.5`,children:[on,sn,cn,ln,un,dn,fn,pn,mn]}),t[135]=rn,t[136]=an,t[137]=on,t[138]=sn,t[139]=cn,t[140]=ln,t[141]=un,t[142]=dn,t[143]=fn,t[144]=pn,t[145]=mn,t[146]=hn):hn=t[146];let gn;t[147]!==Qt||t[148]!==Rt||t[149]!==$t||t[150]!==en||t[151]!==tn||t[152]!==nn||t[153]!==hn?(gn=(0,$.jsxs)(Qt,{shouldFilter:!1,onKeyDownCapture:Rt,onPointerDownCapture:$t,onPointerCancelCapture:en,onClickCapture:tn,className:`max-h-full min-h-0 rounded-[inherit] bg-transparent [&_[cmdk-group]]:px-0 [&_[cmdk-item][data-selected=true]]:!bg-[color-mix(in_srgb,var(--interactive-selection)_40%,transparent)] [&_[cmdk-item]:hover]:!bg-[color-mix(in_srgb,var(--interactive-selection)_40%,transparent)]`,children:[nn,hn]}),t[147]=Qt,t[148]=Rt,t[149]=$t,t[150]=en,t[151]=tn,t[152]=nn,t[153]=hn,t[154]=gn):gn=t[154];let _n=gn;if(i===`page`){let e;t[155]===a?e=t[156]:(e=a(`commandPalette.title`),t[155]=a,t[156]=e);let n;return t[157]!==_n||t[158]!==e?(n=(0,$.jsx)(`section`,{ref:U,"data-global-search":`true`,"data-page-scroll-lock":`true`,"aria-label":e,className:`oc-global-search-page flex min-h-0 w-full flex-col bg-background text-foreground`,children:_n}),t[157]=_n,t[158]=e,t[159]=n):n=t[159],n}let vn;t[160]===Symbol.for(`react.memo_cache_sentinel`)?(vn=e=>{e||u(!1)},t[160]=vn):vn=t[160];let yn;t[161]===a?yn=t[162]:(yn=a(`commandPalette.title`),t[161]=a,t[162]=yn);let xn;t[163]===yn?xn=t[164]:(xn=(0,$.jsx)(vt,{children:yn}),t[163]=yn,t[164]=xn);let Sn;t[165]===a?Sn=t[166]:(Sn=a(`commandPalette.description`),t[165]=a,t[166]=Sn);let Cn;t[167]===Sn?Cn=t[168]:(Cn=(0,$.jsx)(yt,{children:Sn}),t[167]=Sn,t[168]=Cn);let Tn;t[169]!==xn||t[170]!==Cn?(Tn=(0,$.jsxs)(ht,{className:`sr-only`,children:[xn,Cn]}),t[169]=xn,t[170]=Cn,t[171]=Tn):Tn=t[171];let En;t[172]!==_n||t[173]!==B||t[174]!==Tn?(En=(0,$.jsxs)(_t,{ref:U,initialFocus:W,"data-global-search":`true`,"data-mobile":B,"data-page-scroll-lock":`true`,className:`oc-global-search oc-mobile-overlay-surface oc-mobile-overlay-surface--translucent oc-composer-autocomplete-surface fixed left-1/2 top-[12vh] z-50 w-[min(40rem,calc(100vw-1.5rem))] max-w-none -translate-x-1/2 translate-y-0 gap-0 overflow-hidden rounded-3xl border-0 p-0`,containerClassName:`block p-0`,overlayClassName:`bg-transparent dark:bg-transparent`,showCloseButton:B,children:[Tn,_n]}),t[172]=_n,t[173]=B,t[174]=Tn,t[175]=En):En=t[175];let Dn;return t[176]!==s||t[177]!==d||t[178]!==En?(Dn=(0,$.jsx)(bt,{open:s,onOpenChange:d,onOpenChangeComplete:vn,children:En}),t[176]=s,t[177]=d,t[178]=En,t[179]=Dn):Dn=t[179],Dn};function Hi(e){return e.isCommandPaletteOpen}function Ui(e){return e.setCommandPaletteOpen}function Wi(e){return e.setActiveMainTab}function Gi(e){return e.setSettingsDialogOpen}function Ki(e){return e.setSettingsPage}function qi(e){return e.setSessionSwitcherOpen}function Ji(e){return e.toggleSidebar}function Yi(e){return e.toggleRightSidebar}function Xi(e){return e.toggleBottomTerminal}function Zi(e){return e.openContextOverview}function Qi(e){return e.openContextFile}function $i(e){return e.shortcutOverrides}function ea(e){return e.openNewSessionDraft}function ta(e){return e.setCurrentSession}function na(e){return e.activeSessions}function ra(e){return e.status}function ia(e){return e.currentDirectory}function aa(e){return e.getActiveProject()}function oa(e){return e.projects}function sa(e){return e.searchFiles}function ca(){It()}function la(){ft.requestDirectoryDialog()}function ua(e){console.warn(`[command-palette] failed to open draft mini chat window`,e)}function da(e){return e.slug!==`home`}function fa(e){return(typeof e.time?.updated==`number`?e.time.updated:0)||(typeof e.time?.created==`number`?e.time.created:0)}function pa(e){return e.worktreeMetadata}function ma(e){return e.availableWorktreesByProject}function ha(e){return{path:Bi(e.path),name:e.name,relativePath:e.relativePath}}function ga(e){return{item:e,score:0}}function _a(e){return e.searchText}function va(e){return e.searchText}function ya(e){return e.title||``}function ba(e){let{item:t}=e;return t}function xa(e){return{...e,displayName:e.label||e.path.split(`/`).pop()||e.path,searchText:`${e.label||``} ${e.path}`}}function Sa(e){return e.searchText}function Ca(e){return e.item}function wa(e){return e.item}function Ta(e){return e.item}function Ea(e){return e.item}function Da(e){return e.length?e[0].score:1/0}function Oa(e,t){return e.score-t.score}function ka(e){return e.key}function Aa(e){return(0,$.jsx)(zt,{value:e.id,onSelect:e.onSelect,className:Li,children:(0,$.jsx)(Ii,{title:e.title})},e.id)}var ja=class extends Q.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){this.setState({error:e,errorInfo:t})}handleReset=()=>{this.setState({hasError:!1,error:void 0,errorInfo:void 0})};render(){return this.state.hasError?(0,$.jsx)(`div`,{className:`flex items-center justify-center min-h-screen p-4`,children:(0,$.jsxs)(An,{className:`w-full max-w-md`,children:[(0,$.jsx)(mn,{className:`text-center`,children:(0,$.jsxs)(pn,{className:`flex items-center justify-center gap-2 text-destructive`,children:[(0,$.jsx)(Z,{name:`chat-3`,className:`h-5 w-5`}),this.props.texts.title]})}),(0,$.jsxs)(_n,{className:`space-y-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground text-center`,children:this.props.texts.description}),this.props.sessionId&&(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground text-center`,children:[this.props.texts.sessionLabel,`: `,this.props.sessionId]}),this.state.error&&(0,$.jsxs)(`details`,{className:`text-xs font-mono bg-muted p-3 rounded`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer hover:bg-interactive-hover/80`,children:this.props.texts.detailsSummary}),(0,$.jsx)(`pre`,{className:`mt-2 max-h-48 overflow-auto`,children:this.state.error.toString()})]}),(0,$.jsx)(`div`,{className:`flex gap-2`,children:(0,$.jsxs)(X,{onClick:this.handleReset,variant:`outline`,className:`flex-1`,children:[(0,$.jsx)(Z,{name:`restart`,className:`h-4 w-4 mr-2`}),this.props.texts.resetAction]})}),(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground text-center`,children:this.props.texts.persistentHint})]})]})}):this.props.children}};function Ma(e){let t=(0,qr.c)(22),{t:n}=fe(),r;t[0]===n?r=t[1]:(r=n(`chat.errorBoundary.title`),t[0]=n,t[1]=r);let i;t[2]===n?i=t[3]:(i=n(`chat.errorBoundary.description`),t[2]=n,t[3]=i);let a;t[4]===n?a=t[5]:(a=n(`chat.errorBoundary.sessionLabel`),t[4]=n,t[5]=a);let o;t[6]===n?o=t[7]:(o=n(`chat.errorBoundary.detailsSummary`),t[6]=n,t[7]=o);let s;t[8]===n?s=t[9]:(s=n(`chat.errorBoundary.resetAction`),t[8]=n,t[9]=s);let c;t[10]===n?c=t[11]:(c=n(`chat.errorBoundary.persistentHint`),t[10]=n,t[11]=c);let l;t[12]!==r||t[13]!==i||t[14]!==a||t[15]!==o||t[16]!==s||t[17]!==c?(l={title:r,description:i,sessionLabel:a,detailsSummary:o,resetAction:s,persistentHint:c},t[12]=r,t[13]=i,t[14]=a,t[15]=o,t[16]=s,t[17]=c,t[18]=l):l=t[18];let u;return t[19]!==e||t[20]!==l?(u=(0,$.jsx)(ja,{...e,texts:l}),t[19]=e,t[20]=l,t[21]=u):u=t[21],u}var Na=1440,Pa=e=>{let t=(0,qr.c)(8),{isMobile:n,isVSCode:r,directory:i}=e,a=se(`(min-width: ${Na}px)`),o;t[0]===i?o=t[1]:(o=i?F(i):``,t[0]=i,t[1]=o);let s=o,c;t[2]===s?c=t[3]:(c=e=>{let t=s?e.contextPanelByDirectory[s]:void 0;return t?.isOpen?!!(t.tabs.find(e=>e.id===t.activeTabId)??t.tabs[t.tabs.length-1]??null):!1},t[2]=s,t[3]=c);let l=P(c),u=P(Fa),d=P(Ia),f=!n&&!r&&!l&&!d,p=f&&a,m=u&&p,h;return t[4]!==p||t[5]!==f||t[6]!==m?(h={visible:m,fits:p,layoutAllows:f},t[4]=p,t[5]=f,t[6]=m,t[7]=h):h=t[7],h};function Fa(e){return e.workStatusPanelEnabled}function Ia(e){return e.isRightSidebarOpen}var La=[],Ra=[`subagent_type`,`subagentType`,`agent`,`subagent`],za=(...e)=>{for(let t of e){if(!t||typeof t!=`object`)continue;let e=t;for(let t of Ra){let n=e[t];if(typeof n!=`string`)continue;let r=n.trim();if(r)return r.charAt(0).toUpperCase()+r.slice(1)}}return``},Ba=e=>At(e)||void 0,Va=e=>e===`pending`||e===`running`,Ha=e=>{let t=[],n=new Set;for(let r of e.messageOrder){let i=e.partsByMessageID[r];if(i)for(let e of i){if(!e?.id||n.has(e.id))continue;if(e.type===`tool`&&wt(e.tool)){n.add(e.id);let r=e.state;t.push({id:e.id,sessionID:Ba(e.metadata)??Ba(r)??Ba(r?.metadata)??Ba(r?.input),label:za(r?.input,e.metadata,r?.metadata),running:Va(r?.status)});continue}if(e.type!==`subtask`)continue;let r=e,i=typeof r.taskSessionID==`string`?r.taskSessionID.trim():``,a=typeof r.agent==`string`?r.agent.trim():``,o=typeof r.description==`string`?r.description.trim():``;n.add(e.id),t.push({id:e.id,sessionID:i||void 0,label:a?a.charAt(0).toUpperCase()+a.slice(1):o,running:Va(r.status)})}}return t.length===0?La:t},Ua=(e,t)=>{if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){let r=e[n],i=t[n];if(!r||!i||r.id!==i.id||r.sessionID!==i.sessionID||r.label!==i.label||r.running!==i.running)return!1}return!0},Wa=(e,t,n)=>{let r=new Map(t.map(e=>[e.id,e])),i=new Set,a=[];for(let t of e){t.sessionID&&i.add(t.sessionID);let e=t.sessionID?r.get(t.sessionID):void 0,o=t.running||!!e?.busy||!!(t.sessionID&&n?.has(t.sessionID));a.push({key:t.id,sessionID:t.sessionID,seed:t.id,label:t.label||e?.title?.trim()||``,phase:o?`working`:`done`})}for(let e of t)i.has(e.id)||a.push({key:e.id,sessionID:e.id,seed:e.id,label:e.title?.trim()||``,phase:e.busy?`working`:`done`});let o=a.filter(e=>e.phase===`working`),s=a.filter(e=>e.phase===`done`);return o.length===0?s:s.length===0?o:[...o,...s]},Ga=new Set,Ka=e=>{if(!e)return``;let t=[];for(let n of Object.keys(e)){let r=e[n]?.type;(r===`busy`||r===`retry`)&&t.push(n)}return t.sort(),t.join(`
|
|
2
2
|
`)},qa=(e,t)=>{let n=(0,qr.c)(4),r;n[0]===t?r=n[1]:(r=e=>t?Ka(e.session_status):``,n[0]=t,n[1]=r);let i=C(e,r),a;return n[2]===i?a=n[3]:(a=i?new Set(i.split(`
|
|
3
3
|
`)):Ga,n[2]=i,n[3]=a),a},Ja=(e,t)=>{let n=(0,qr.c)(15),r=!!(e&&t),i=!!e,a;n[0]===i?a=n[1]:(a={enabled:i},n[0]=i,n[1]=a);let o=ze(a),s;n[2]===Symbol.for(`react.memo_cache_sentinel`)?(s={bootstrap:!1},n[2]=s):s=n[2];let c=Me(t||void 0,s),l;n[3]===r?l=n[4]:(l={enabled:r},n[3]=r,n[4]=l);let u=M(e??``,t??``,c,Ha,Ua,l),d=qa(c,r),f;bb0:{if(!e){let e;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],n[5]=e):e=n[5],f=e;break bb0}let t;if(n[6]!==d||n[7]!==o||n[8]!==e||n[9]!==u){let r;n[11]===e?r=n[12]:(r=t=>t.parentID===e,n[11]=e,n[12]=r);let i;n[13]===d?i=n[14]:(i=e=>({id:e.id,title:e.title,busy:d.has(e.id)}),n[13]=d,n[14]=i),t=Wa(u,o.filter(r).map(i),d),n[6]=d,n[7]=o,n[8]=e,n[9]=u,n[10]=t}else t=n[10];f=t}return f},Ya=`flex w-full min-w-0 items-center justify-start gap-2 text-left text-[13px] font-normal leading-5 tracking-normal text-muted-foreground`,Xa=`size-3.5 shrink-0`,Za=`oc-work-status-action pointer-events-none shrink-0 text-muted-foreground opacity-0 transition-opacity group-hover/copy:pointer-events-auto group-hover/copy:opacity-100 focus-visible:pointer-events-auto focus-visible:opacity-100`,Qa=e=>e.split(/[\\/]/).filter(Boolean).pop()||e,$a=({sessionId:e,directory:t})=>{let{t:n}=fe(),{git:r}=In(),i=nr(e=>e.ensureStatus),a=er(t),o=ot(e=>e.projects),s=Je(e=>e.availableWorktreesByProject),c=Je(t=>e?t.worktreeMetadata.get(e):void 0),{project:l,worktree:u}=Q.useMemo(()=>{let e=h(t),n=t=>{let n=h(t);return!!(e&&n&&(e===n||e.startsWith(`${n}/`)))},r=c&&n(c.path)?c:void 0,i=Te(o,s,r?.projectDirectory||t),a=i?s.get(i.path):void 0;return{project:i,worktree:r??a?.filter(e=>n(e.path)).sort((e,t)=>t.path.length-e.path.length)[0]}},[s,t,o,c]),d=l?.path||u?.projectDirectory||t,f=l?.label?.trim()||(d?Qa(d):null),p=u&&h(u.path)!==h(d)?u.name?.trim()||Qa(u.path):null,m=Ja(e,t),g=[{phase:`working`,labelKey:`chat.workStatus.subagent.workingCount`,items:m.filter(e=>e.phase===`working`)},{phase:`done`,labelKey:`chat.workStatus.subagent.doneCount`,items:m.filter(e=>e.phase===`done`)}],_=m.slice(0,3),[v,y]=Q.useState(!1),b=Q.useId(),x=P(e=>e.setRightSidebarOpen),S=P(e=>e.openContextPanelTab),C=P(e=>e.setRightSidebarTab),[w,T]=Q.useState(null),[,E]=le(()=>T(null),1500,{immediate:!1}),D=ce(async(e,t)=>{try{let n=await de(t);if(!n.ok)throw Error(n.error);T(e),E()}catch{oe.error(n(`gitView.toast.copyFailed`))}});Q.useEffect(()=>{!t||!r||i(t,r)},[t,i,r]);let O=a?.current||null,k=u?.worktreeStatus===`pending`?0:a?.files.length??0,A=0,j=0;if(a?.diffStats)for(let e of Object.values(a.diffStats))A+=e?.insertions??0,j+=e?.deletions??0;let M=O?`branch:${O}`:``,N=u?.path?`worktree:${u.path}`:``,F=!!(M&&w===M),I=!!(N&&w===N),L=ce(()=>{O&&D(M,O)}),R=ce(()=>{let e=u?.path;e&&D(N,e)}),z=ce(()=>{C(`git`),x(!0)});return(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[f?(0,$.jsxs)(`div`,{className:`${Ya} h-8 px-2`,title:`${n(`chat.workStatus.section.project`)}: ${d}`,children:[(0,$.jsx)(Z,{name:`folder`,weight:`medium`,className:Xa}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:f})]}):null,O?(0,$.jsxs)(`div`,{className:`${Ya} group/copy h-8 px-2`,title:`${n(`gitView.branch.currentBranchTooltip`)}: ${O}`,children:[(0,$.jsx)(Z,{name:`git-branch`,weight:`medium`,className:Xa}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:O}),(0,$.jsx)(X,{variant:`ghost`,size:`xs`,className:Za,"aria-label":n(`chat.workStatus.action.copyBranch`),title:n(F?`contextSidebar.actions.copied`:`chat.workStatus.action.copyBranch`),onClick:L,children:(0,$.jsx)(Z,{name:F?`check`:`file-copy`,className:Xa})})]}):null,p?(0,$.jsxs)(`div`,{className:`${Ya} group/copy h-8 px-2`,title:`${n(`sessions.sidebar.sessionDialogs.worktree.label`)}: ${u?.path}`,children:[(0,$.jsx)(Z,{name:`node-tree`,weight:`medium`,className:Xa}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:p}),(0,$.jsx)(X,{variant:`ghost`,size:`xs`,className:Za,"aria-label":n(`agentManager.detail.actions.copyWorktreePath`),title:n(I?`contextSidebar.actions.copied`:`agentManager.detail.actions.copyWorktreePath`),onClick:R,children:(0,$.jsx)(Z,{name:I?`check`:`file-copy`,className:Xa})})]}):null,k>0?(0,$.jsxs)(X,{variant:`ghost`,size:`sm`,className:`oc-work-status-action ${Ya}`,title:n(k===1?`chat.workStatus.git.changedFileSingle`:`chat.workStatus.git.changedFilePlural`,{count:k}),"aria-label":n(`chat.workStatus.action.openGit`),onClick:z,children:[(0,$.jsx)(Z,{name:`changes`,weight:`medium`,className:Xa}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:n(`chat.workStatus.compact.changes`)}),A>0||j>0?(0,$.jsxs)(`span`,{className:`ml-auto flex shrink-0 gap-1.5 text-[12px] tabular-nums`,children:[(0,$.jsx)(`span`,{className:`text-[var(--status-success)]`,children:`+${A}`}),(0,$.jsx)(`span`,{className:`text-[var(--status-error)]`,children:`−${j}`})]}):(0,$.jsx)(`span`,{className:`ml-auto tabular-nums`,children:k})]}):null,m.length>0?(0,$.jsxs)(`div`,{role:`group`,"aria-label":n(`chat.workStatus.section.subagents`),className:`flex min-w-0 flex-col`,children:[(0,$.jsxs)(X,{type:`button`,variant:`ghost`,size:`sm`,className:`oc-work-status-action ${Ya} gap-1.5`,"aria-expanded":v,"aria-controls":b,onClick:()=>y(e=>!e),children:[(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`inline-flex shrink-0 items-center`,children:_.map((e,t)=>{let r=e.label.trim()||n(`chat.workStatus.subagent.untitled`);return(0,$.jsx)(xt,{name:e.seed,label:r,size:14,className:`relative bg-background ring-2 ring-background ${t>0?`-ml-1`:``}`},e.key)})}),(0,$.jsx)(`span`,{className:`flex min-w-0 flex-1 items-center gap-x-1 whitespace-nowrap text-left text-[11px] leading-5 tabular-nums`,children:g.filter(e=>e.items.length>0).map((e,t)=>(0,$.jsxs)(Q.Fragment,{children:[t>0?(0,$.jsx)(`span`,{"aria-hidden":`true`,children:`·`}):null,(0,$.jsx)(`span`,{children:n(e.labelKey,{count:e.items.length})})]},e.phase))}),(0,$.jsx)(Z,{name:v?`arrow-down-s`:`arrow-right-s`,className:`size-3.5 shrink-0 text-muted-foreground opacity-70`})]}),(0,$.jsx)(`div`,{id:b,hidden:!v,className:v?`mt-1 mb-1 flex min-w-0 flex-col gap-1`:`hidden`,children:v?g.filter(e=>e.items.length>0).map(e=>(0,$.jsxs)(`section`,{"aria-label":n(e.labelKey,{count:e.items.length}),className:`flex min-w-0 flex-col gap-1 [&+section]:mt-2`,children:[(0,$.jsx)(`div`,{className:`px-2 py-1 text-[11px] leading-4 text-muted-foreground/70`,children:n(e.labelKey,{count:e.items.length})}),e.items.map(e=>{let r=e.label.trim()||n(`chat.workStatus.subagent.untitled`);return(0,$.jsxs)(X,{variant:`ghost`,size:`sm`,disabled:!e.sessionID||!t,className:`oc-work-status-action flex w-full min-w-0 items-center justify-start gap-2 text-left text-[12px] font-normal leading-5 text-muted-foreground`,onClick:()=>{!e.sessionID||!t||S(t,{mode:`chat`,dedupeKey:`session:${e.sessionID}`,label:r,readOnly:!0})},children:[(0,$.jsx)(xt,{name:e.seed,label:r,size:14}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:r,children:r})]},e.key)})]},e.phase)):null})]}):null]})},eo=200,to=e=>{let t=(0,qr.c)(32),{sessionId:n,directory:r,visible:i,overlay:a}=e,o=a!==void 0&&a,{t:s}=fe(),c=P(no),l=Q.useRef(null),[u,d]=Q.useState(i),f,p;t[0]===i?(f=t[1],p=t[2]):(f=()=>{if(i){d(!0);return}let e=window.setTimeout(()=>d(!1),eo);return()=>window.clearTimeout(e)},p=[i],t[0]=i,t[1]=f,t[2]=p),Q.useEffect(f,p);let m,h;t[3]!==o||t[4]!==c||t[5]!==i?(m=()=>{if(!o||!i)return;let e=e=>{let t=e.target instanceof Element?e.target:null;l.current?.contains(t)||t?.closest(`[data-work-status-toggle]`)||c(!1)},t=e=>{e.key===`Escape`&&c(!1)};return document.addEventListener(`pointerdown`,e,!0),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e,!0),document.removeEventListener(`keydown`,t)}},h=[o,c,i],t[3]=o,t[4]=c,t[5]=i,t[6]=m,t[7]=h):(m=t[6],h=t[7]),Q.useEffect(m,h);let g;t[8]===s?g=t[9]:(g=s(`chat.workStatus.ariaLabel`),t[8]=s,t[9]=g);let _=!i,v=!i,y=o&&`absolute right-3 top-3 z-30 my-0 max-h-[calc(100%-1.5rem)] rounded-lg bg-[var(--surface-elevated)]/95 px-1 backdrop-blur-md`,b=!o&&(i?`mr-3`:`mr-0`),x;t[10]!==b||t[11]!==y?(x=Y(`relative my-2 flex max-h-[calc(100%-1rem)] shrink-0 flex-col self-start overflow-x-hidden overflow-y-auto bg-transparent`,y,b),t[10]=b,t[11]=y,t[12]=x):x=t[12];let S=o||i?196:0,C=+!!i,w=i?`none`:o?`translateY(-6px)`:`translateX(24px)`,T=o?`opacity, transform`:`none`,E=i?void 0:`none`,D;t[13]!==S||t[14]!==C||t[15]!==w||t[16]!==T||t[17]!==E?(D={width:S,opacity:C,transform:w,transitionProperty:T,transitionDuration:`${eo}ms`,transitionTimingFunction:`cubic-bezier(0.22, 1, 0.36, 1)`,pointerEvents:E},t[13]=S,t[14]=C,t[15]=w,t[16]=T,t[17]=E,t[18]=D):D=t[18];let O;t[19]!==u||t[20]!==r||t[21]!==o||t[22]!==n||t[23]!==i?(O=i||o&&u?(0,$.jsx)($a,{sessionId:n,directory:r}):null,t[19]=u,t[20]=r,t[21]=o,t[22]=n,t[23]=i,t[24]=O):O=t[24];let k;return t[25]!==x||t[26]!==D||t[27]!==O||t[28]!==g||t[29]!==_||t[30]!==v?(k=(0,$.jsx)(`aside`,{ref:l,"aria-label":g,"aria-hidden":_,inert:v,className:x,style:D,children:O}),t[25]=x,t[26]=D,t[27]=O,t[28]=g,t[29]=_,t[30]=v,t[31]=k):k=t[31],k};function no(e){return e.setWorkStatusOverlayOpen}var ro=e=>{let t=(0,qr.c)(10),{sessionId:n,directory:r,visible:i,overlay:a,publishVisible:o}=e,s=a!==void 0&&a,c=o!==void 0&&o,l=P(ao),u,d;t[0]!==c||t[1]!==l||t[2]!==i?(u=()=>{if(c)return l(i),()=>l(!1)},d=[c,l,i],t[0]=c,t[1]=l,t[2]=i,t[3]=u,t[4]=d):(u=t[3],d=t[4]),Q.useEffect(u,d);let f;return t[5]!==r||t[6]!==s||t[7]!==n||t[8]!==i?(f=(0,$.jsx)(to,{overlay:s,visible:i,sessionId:n,directory:r}),t[5]=r,t[6]=s,t[7]=n,t[8]=i,t[9]=f):f=t[9],f},io=e=>{let t=(0,qr.c)(35),{readOnly:n,active:r,selectionOverride:i}=e,a=n!==void 0&&n,o=r===void 0||r,s=Je(oo),c=Je(so),l=Je(co),u=Je(lo),d=yr(),f=P(uo),p=P(fo),m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=g(),t[0]=m):m=t[0];let h=m,_=P(po),v=P(mo),y=P(ho),b=i?.sessionId??s,x=i?.sessionId??s,S=i?.directory??c??d??null,C;t[1]!==S||t[2]!==f?(C={isMobile:f,isVSCode:h,directory:S},t[1]=S,t[2]=f,t[3]=C):C=t[3];let{visible:w,fits:T,layoutAllows:E}=Pa(C),D=i?!!i.sessionId:l?u:!!x,O=o&&E&&!p&&D,k=O&&w,A=O&&_&&!T&&v,j,M;t[4]!==T||t[5]!==O||t[6]!==y?(j=()=>(y(O&&T),()=>y(!1)),M=[T,O,y],t[4]=T,t[5]=O,t[6]=y,t[7]=j,t[8]=M):(j=t[7],M=t[8]),Q.useEffect(j,M);let N=b||void 0,F;t[9]!==o||t[10]!==i?(F=i?{...i,active:o}:void 0,t[9]=o,t[10]=i,t[11]=F):F=t[11];let I;t[12]!==o||t[13]!==a||t[14]!==F?(I=(0,$.jsx)(Tt,{readOnly:a,active:o,explicitSession:F}),t[12]=o,t[13]=a,t[14]=F,t[15]=I):I=t[15];let L;t[16]!==N||t[17]!==I?(L=(0,$.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1`,children:(0,$.jsx)(Ma,{sessionId:N,children:I})}),t[16]=N,t[17]=I,t[18]=L):L=t[18];let R;t[19]!==S||t[20]!==O||t[21]!==x||t[22]!==k?(R=O?(0,$.jsx)(ro,{publishVisible:!0,visible:k,sessionId:x,directory:S}):null,t[19]=S,t[20]=O,t[21]=x,t[22]=k,t[23]=R):R=t[23];let z;t[24]!==S||t[25]!==T||t[26]!==O||t[27]!==x||t[28]!==A||t[29]!==_?(z=O&&_&&!T?(0,$.jsx)(ro,{overlay:!0,visible:A,sessionId:x,directory:S}):null,t[24]=S,t[25]=T,t[26]=O,t[27]=x,t[28]=A,t[29]=_,t[30]=z):z=t[30];let B;return t[31]!==L||t[32]!==R||t[33]!==z?(B=(0,$.jsxs)(`div`,{className:`relative flex h-full min-h-0 min-w-0`,children:[L,R,z]}),t[31]=L,t[32]=R,t[33]=z,t[34]=B):B=t[34],B};function ao(e){return e.setWorkStatusPanelVisible}function oo(e){return e.currentSessionId}function so(e){return e.currentSessionDirectory}function co(e){return!!e.newSessionDraft?.open}function lo(e){return!!(e.newSessionDraft?.open&&e.newSessionDraft.pendingUserMessage&&(e.newSessionDraft.draftEstablishing||e.newSessionDraft.draftSubmitting))}function uo(e){return e.isMobile}function fo(e){return e.isExpandedInput}function po(e){return e.workStatusPanelEnabled}function mo(e){return e.workStatusOverlayOpen}function ho(e){return e.setWorkStatusPanelFits}function go(e){let t=(0,qr.c)(85),{draft:n,onEdit:r,onDelete:i,className:a,maxWidth:o}=e,{t:s}=fe(),c=Mn()?.currentTheme,[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(!1),p=typeof n.text==`string`?n.text:``,m;t[0]===p?m=t[1]:(m=p.length>150||p.split(`
|
|
4
4
|
`).length>3,t[0]=p,t[1]=m);let h=m,g;t[2]===a?g=t[3]:(g=Y(`rounded-lg border shadow-none w-full max-w-[min(100%,calc(var(--oc-context-panel-width,100vw)-var(--oc-editor-gutter-width,0px)))] overflow-hidden transition-all duration-200`,a),t[2]=a,t[3]=g);let _=c?.colors?.surface?.elevated,v=c?.colors?.interactive?.border,y=o?`${Math.max(200,Math.floor(o))}px`:void 0,b;t[4]!==_||t[5]!==v||t[6]!==y?(b={backgroundColor:_,borderColor:v,maxWidth:y},t[4]=_,t[5]=v,t[6]=y,t[7]=b):b=t[7];let x;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(x=e=>{e.preventDefault(),f(!0)},t[8]=x):x=t[8];let S;t[9]!==g||t[10]!==b?(S=(0,$.jsx)(`div`,{className:g,style:b,"data-comment-card":`true`,onContextMenu:x}),t[9]=g,t[10]=b,t[11]=S):S=t[11];let C;t[12]===n.fileLabel?C=t[13]:(C=(0,$.jsx)(`span`,{className:`truncate max-w-[200px]`,title:n.fileLabel,children:n.fileLabel}),t[12]=n.fileLabel,t[13]=C);let w;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(`span`,{children:`•`}),t[14]=w):w=t[14];let T;t[15]!==n.endLine||t[16]!==n.startLine||t[17]!==s?(T=s(`inlineComment.range.lines`,{start:n.startLine,end:n.endLine}),t[15]=n.endLine,t[16]=n.startLine,t[17]=s,t[18]=T):T=t[18];let E;t[19]===T?E=t[20]:(E=(0,$.jsx)(`span`,{children:T}),t[19]=T,t[20]=E);let D;t[21]===n.side?D=t[22]:(D=n.side&&(0,$.jsxs)(`span`,{children:[`(`,n.side,`)`]}),t[21]=n.side,t[22]=D);let O;t[23]!==E||t[24]!==D||t[25]!==C?(O=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-muted-foreground mb-1.5`,children:[C,w,E,D]}),t[23]=E,t[24]=D,t[25]=C,t[26]=O):O=t[26];let k=l||!h,A=!l&&h&&`line-clamp-3`,j;t[27]===A?j=t[28]:(j=Y(`text-sm whitespace-pre-wrap break-words leading-relaxed`,A),t[27]=A,t[28]=j);let M;t[29]!==p||t[30]!==j?(M=(0,$.jsx)(`div`,{className:j,children:p}),t[29]=p,t[30]=j,t[31]=M):M=t[31];let N;t[32]!==h||t[33]!==l||t[34]!==s?(N=h&&(0,$.jsx)(Wr,{asChild:!0,children:(0,$.jsx)(X,{variant:`ghost`,size:`sm`,className:`h-6 px-0 mt-1 text-xs text-muted-foreground hover:text-foreground w-full justify-start`,children:l?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{name:`arrow-up-s`,className:`size-3 mr-1`}),s(`inlineComment.actions.showLess`)]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{name:`arrow-down-s`,className:`size-3 mr-1`}),s(`inlineComment.actions.showMore`)]})})}),t[32]=h,t[33]=l,t[34]=s,t[35]=N):N=t[35];let P;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,$.jsx)(Ur,{}),t[36]=P):P=t[36];let F;t[37]!==k||t[38]!==M||t[39]!==N?(F=(0,$.jsxs)(Gr,{open:k,onOpenChange:u,children:[M,N,P]}),t[37]=k,t[38]=M,t[39]=N,t[40]=F):F=t[40];let I;t[41]!==O||t[42]!==F?(I=(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[O,F]}),t[41]=O,t[42]=F,t[43]=I):I=t[43];let L;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(kn,{asChild:!0,children:(0,$.jsx)(X,{variant:`ghost`,size:`icon`,className:`h-6 w-6 -mr-1 text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(Z,{name:`more`,className:`size-4`})})}),t[44]=L):L=t[44];let R;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,$.jsx)(Z,{name:`edit`,className:`size-4 mr-2`}),t[45]=R):R=t[45];let z;t[46]===s?z=t[47]:(z=s(`inlineComment.actions.editComment`),t[46]=s,t[47]=z);let B;t[48]!==r||t[49]!==z?(B=(0,$.jsxs)(vn,{onClick:r,children:[R,z]}),t[48]=r,t[49]=z,t[50]=B):B=t[50];let V;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,$.jsx)(Z,{name:`delete-bin`,className:`size-4 mr-2`}),t[51]=V):V=t[51];let ee;t[52]===s?ee=t[53]:(ee=s(`inlineComment.actions.deleteComment`),t[52]=s,t[53]=ee);let H;t[54]!==i||t[55]!==ee?(H=(0,$.jsxs)(vn,{onClick:i,className:`text-destructive`,children:[V,ee]}),t[54]=i,t[55]=ee,t[56]=H):H=t[56];let U;t[57]!==B||t[58]!==H?(U=(0,$.jsxs)(En,{children:[L,(0,$.jsxs)(Sn,{align:`end`,children:[B,H]})]}),t[57]=B,t[58]=H,t[59]=U):U=t[59];let W;t[60]!==I||t[61]!==U?(W=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2 p-3`,children:[I,U]}),t[60]=I,t[61]=U,t[62]=W):W=t[62];let te;t[63]!==W||t[64]!==S?(te=(0,$.jsx)(Rr,{render:S,children:W}),t[63]=W,t[64]=S,t[65]=te):te=t[65];let G;t[66]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,$.jsx)(Z,{name:`edit`,className:`size-4 mr-2`}),t[66]=G):G=t[66];let K;t[67]===s?K=t[68]:(K=s(`inlineComment.actions.editComment`),t[67]=s,t[68]=K);let ne;t[69]!==r||t[70]!==K?(ne=(0,$.jsxs)(Vr,{onClick:r,children:[G,K]}),t[69]=r,t[70]=K,t[71]=ne):ne=t[71];let re;t[72]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,$.jsx)(Z,{name:`delete-bin`,className:`size-4 mr-2`}),t[72]=re):re=t[72];let ie;t[73]===s?ie=t[74]:(ie=s(`inlineComment.actions.deleteComment`),t[73]=s,t[74]=ie);let q;t[75]!==i||t[76]!==ie?(q=(0,$.jsxs)(Vr,{onClick:i,className:`text-destructive focus:text-destructive`,children:[re,ie]}),t[75]=i,t[76]=ie,t[77]=q):q=t[77];let ae;t[78]!==ne||t[79]!==q?(ae=(0,$.jsxs)(Br,{children:[ne,q]}),t[78]=ne,t[79]=q,t[80]=ae):ae=t[80];let J;return t[81]!==d||t[82]!==te||t[83]!==ae?(J=(0,$.jsxs)(Hr,{open:d,onOpenChange:f,children:[te,ae]}),t[81]=d,t[82]=te,t[83]=ae,t[84]=J):J=t[84],J}function _o(e){let t=(0,qr.c)(67),{initialText:n,onTextChange:r,onSave:i,onCancel:a,fileLabel:o,lineRange:s,isEditing:c,className:l,maxWidth:u,onAddToChat:d}=e,f=n===void 0?``:n,p=c!==void 0&&c,{t:m}=fe(),h=Mn()?.currentTheme,{isMobile:g}=Nn(),[_,v]=Q.useState(f),y=(0,Q.useRef)(null),b;t[0]===r?b=t[1]:(b=e=>{v(e),r?.(e)},t[0]=r,t[1]=b);let x=b,S=(0,Q.useRef)(s),C,w;t[2]===s?(C=t[3],w=t[4]):(C=()=>{s&&(S.current=s)},w=[s],t[2]=s,t[3]=C,t[4]=w),(0,Q.useEffect)(C,w);let T=To,E=T(s),D,O;t[5]===g?(D=t[6],O=t[7]):(D=()=>{let e=y.current;if(!e)return;let t=e.closest(`.overlay-scrollbar-container`),n=t?.scrollTop??window.scrollY,r=t?.scrollLeft??window.scrollX;if(g){e.scrollIntoView({behavior:`auto`,block:`nearest`});try{e.focus({preventScroll:!0})}catch{e.focus()}return}try{e.focus({preventScroll:!0})}catch{e.focus()}let i=e.value.length;try{e.setSelectionRange(i,i)}catch{}requestAnimationFrame(()=>{t?(t.scrollTop=n,t.scrollLeft=r):window.scrollTo({top:n,left:r})})},O=[g],t[5]=g,t[6]=D,t[7]=O),(0,Q.useEffect)(D,O);let k;t[8]!==a||t[9]!==i||t[10]!==_?(k=e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`?(e.preventDefault(),_.trim()&&i(_,T(S.current))):e.key===`Escape`&&(e.preventDefault(),a())},t[8]=a,t[9]=i,t[10]=_,t[11]=k):k=t[11];let A=k,j;t[12]!==i||t[13]!==_?(j=e=>{e.stopPropagation(),_.trim()&&i(_,T(S.current))},t[12]=i,t[13]=_,t[14]=j):j=t[14];let M=j,N;t[15]===l?N=t[16]:(N=Y(`rounded-lg border shadow-none w-full max-w-[min(100%,calc(var(--oc-context-panel-width,100vw)-var(--oc-editor-gutter-width,0px)))] overflow-hidden animate-in fade-in zoom-in-95 duration-200`,l),t[15]=l,t[16]=N);let P=h?.colors?.surface?.elevated,F=h?.colors?.interactive?.border,I=u?`${Math.max(200,Math.floor(u))}px`:void 0,L;t[17]!==P||t[18]!==F||t[19]!==I?(L={backgroundColor:P,borderColor:F,maxWidth:I},t[17]=P,t[18]=F,t[19]=I,t[20]=L):L=t[20];let R=wo,z=Co,B=(o||s)&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-muted-foreground mb-2`,children:[o&&(0,$.jsx)(`span`,{className:`truncate max-w-[200px]`,children:o}),o&&s&&(0,$.jsx)(`span`,{children:`•`}),E&&(0,$.jsx)(`span`,{children:m(`inlineComment.range.lines`,{start:E.start,end:E.end})})]}),V;t[21]===x?V=t[22]:(V=e=>x(e.target.value),t[21]=x,t[22]=V);let ee;t[23]!==g||t[24]!==m?(ee=m(g?`inlineComment.input.placeholderShort`:`inlineComment.input.placeholder`),t[23]=g,t[24]=m,t[25]=ee):ee=t[25];let H;t[26]!==A||t[27]!==V||t[28]!==ee||t[29]!==_?(H=(0,$.jsx)(Gn,{simple:!0,ref:y,value:_,onChange:V,onKeyDown:A,placeholder:ee,outerClassName:`rounded-[var(--radius-xl)] bg-[var(--surface-subtle)] ring-1 ring-inset ring-border/60 focus-within:ring-2 focus-within:ring-[var(--interactive-focus-ring)]`,className:`min-h-[80px] px-3 py-2.5 text-sm resize-y`}),t[26]=A,t[27]=V,t[28]=ee,t[29]=_,t[30]=H):H=t[30];let U;t[31]!==E||t[32]!==d||t[33]!==m?(U=E&&d?(0,$.jsxs)(X,{variant:`outline`,size:`sm`,onClick:()=>d(E),onPointerDown:So,className:`mr-auto h-8 gap-1.5`,children:[(0,$.jsx)(Z,{name:`add`,className:`size-4`}),m(`chat.textSelection.actions.addToChat`),(0,$.jsx)(Rt,{shortcut:`⌘+I`})]}):null,t[31]=E,t[32]=d,t[33]=m,t[34]=U):U=t[34];let W;t[35]===m?W=t[36]:(W=m(`inlineComment.actions.cancel`),t[35]=m,t[36]=W);let te;t[37]!==a||t[38]!==W?(te=(0,$.jsx)(X,{variant:`ghost`,size:`sm`,onClick:a,onPointerDown:xo,onTouchStart:bo,className:`h-8 text-muted-foreground hover:text-foreground`,children:W}),t[37]=a,t[38]=W,t[39]=te):te=t[39];let G;t[40]===_?G=t[41]:(G=_.trim(),t[40]=_,t[41]=G);let K=!G,ne=h?.colors?.status?.success,re=h?.colors?.status?.successForeground,ie;t[42]!==ne||t[43]!==re?(ie={backgroundColor:ne,color:re},t[42]=ne,t[43]=re,t[44]=ie):ie=t[44];let q;t[45]!==p||t[46]!==m?(q=m(p?`inlineComment.actions.save`:`inlineComment.actions.comment`),t[45]=p,t[46]=m,t[47]=q):q=t[47];let ae;t[48]!==M||t[49]!==K||t[50]!==ie||t[51]!==q?(ae=(0,$.jsx)(X,{size:`sm`,onClick:M,onPointerDown:yo,onTouchStart:vo,disabled:K,className:`h-8 min-w-[80px]`,style:ie,children:q}),t[48]=M,t[49]=K,t[50]=ie,t[51]=q,t[52]=ae):ae=t[52];let J;t[53]!==U||t[54]!==te||t[55]!==ae?(J=(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2 mt-3`,children:[U,te,ae]}),t[53]=U,t[54]=te,t[55]=ae,t[56]=J):J=t[56];let oe;t[57]!==B||t[58]!==H||t[59]!==J?(oe=(0,$.jsxs)(`div`,{className:`p-3`,children:[B,H,J]}),t[57]=B,t[58]=H,t[59]=J,t[60]=oe):oe=t[60];let se;return t[61]!==N||t[62]!==L||t[63]!==R||t[64]!==z||t[65]!==oe?(se=(0,$.jsx)(`div`,{className:N,style:L,"data-comment-input":`true`,onPointerDown:R,onTouchStart:z,children:oe}),t[61]=N,t[62]=L,t[63]=R,t[64]=z,t[65]=oe,t[66]=se):se=t[66],se}function vo(e){return e.stopPropagation()}function yo(e){return e.stopPropagation()}function bo(e){return e.stopPropagation()}function xo(e){return e.stopPropagation()}function So(e){return e.stopPropagation()}function Co(e){return e.stopPropagation()}function wo(e){return e.stopPropagation()}function To(e){if(!e)return;let t=Math.min(e.start,e.end),n=Math.max(e.start,e.end);return{...e,start:t,end:n}}var Eo=e=>{let t=Math.min(e.startLine,e.endLine),n=Math.max(e.startLine,e.endLine);return{...e,startLine:t,endLine:n}},Do=e=>{let t=Math.min(e.start,e.end),n=Math.max(e.start,e.end);return{...e,start:t,end:n}};function Oo(e){let t=(0,qr.c)(40),{t:n}=fe(),{source:r,fileLabel:i,language:a,getCodeForRange:o,toStoreRange:s,fromDraftRange:c}=e,l=Je(Po),u=Je(No),d=Gt(Mo),f=Gt(jo),p=Gt(Ao),m=Gt(ko),[h,g]=Q.useState(null),[_,v]=Q.useState(``),[y,b]=Q.useState(null),x=l??(u?`draft`:null),S;bb0:{if(!x||!i){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[0]=e):e=t[0],S=e;break bb0}let e;t[1]!==m||t[2]!==x?(e=m[x]??[],t[1]=m,t[2]=x,t[3]=e):e=t[3];let n=e,a;if(t[4]!==i||t[5]!==n||t[6]!==r){let e;t[8]!==i||t[9]!==r?(e=e=>e.source===r&&e.fileLabel===i,t[8]=i,t[9]=r,t[10]=e):e=t[10],a=n.filter(e),t[4]=i,t[5]=n,t[6]=r,t[7]=a}else a=t[7];S=a}let C=S,w;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(w=()=>{g(null),v(``),b(null)},t[11]=w):w=t[11];let T=w,E;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(E=()=>{T()},t[12]=E):E=t[12];let D=E,O;t[13]===c?O=t[14]:(O=e=>{let t=Do(c(e));g(t),v(e.text),b(e.id)},t[13]=c,t[14]=O);let k=O,A;t[15]!==y||t[16]!==p?(A=e=>{p(e.sessionKey,e.id),y===e.id&&T()},t[15]=y,t[16]=p,t[17]=A):A=t[17];let j=A,M;t[18]!==d||t[19]!==y||t[20]!==i||t[21]!==o||t[22]!==a||t[23]!==h||t[24]!==x||t[25]!==r||t[26]!==n||t[27]!==s||t[28]!==f?(M=(e,t)=>{let c=t??h,l=e.trim();if(!c||!l||!i)return;if(!x){Pe.error(n(`inlineComment.toast.selectSessionToSave`));return}let u=Do(c),p=Eo(s(u)),m=o(u);y?f(x,y,{fileLabel:i,startLine:p.startLine,endLine:p.endLine,side:p.side,code:m,language:a,text:l}):d({sessionKey:x,source:r,fileLabel:i,startLine:p.startLine,endLine:p.endLine,side:p.side,code:m,language:a,text:l}),T()},t[18]=d,t[19]=y,t[20]=i,t[21]=o,t[22]=a,t[23]=h,t[24]=x,t[25]=r,t[26]=n,t[27]=s,t[28]=f,t[29]=M):M=t[29];let N=M,P;return t[30]!==_||t[31]!==j||t[32]!==C||t[33]!==y||t[34]!==c||t[35]!==N||t[36]!==h||t[37]!==x||t[38]!==k?(P={sessionKey:x,drafts:C,selection:h,setSelection:g,commentText:_,setCommentText:v,editingDraftId:y,setEditingDraftId:b,reset:T,cancel:D,startEdit:k,deleteDraft:j,saveComment:N,fromDraftRange:c},t[30]=_,t[31]=j,t[32]=C,t[33]=y,t[34]=c,t[35]=N,t[36]=h,t[37]=x,t[38]=k,t[39]=P):P=t[39],P}function ko(e){return e.drafts}function Ao(e){return e.removeDraft}function jo(e){return e.updateDraft}function Mo(e){return e.addDraft}function No(e){return e.newSessionDraft?.open}function Po(e){return e.currentSessionId}function Fo(e){let{drafts:t,editingDraftId:n,commentText:r,onTextChange:i,selection:a,isDragging:o,fileLabel:s,newWidgetId:c,mapDraftToRange:l,onSave:u,onCancel:d,onEdit:f,onDelete:p,onAddToChat:m}=e,h=[];for(let e of t){let t=l(e);if(e.id===n){h.push({afterLine:t.end,id:`edit-${e.id}`,content:(0,$.jsx)(_o,{initialText:r,onTextChange:i,fileLabel:s,lineRange:t,isEditing:!0,onSave:u,onCancel:d,onAddToChat:m},`edit-${e.id}`)});continue}h.push({afterLine:t.end,id:`card-${e.id}`,content:(0,$.jsx)(go,{draft:e,onEdit:()=>f(e),onDelete:()=>p(e)},`card-${e.id}`)})}if(a&&!n&&!o){let e={...a,start:Math.min(a.start,a.end),end:Math.max(a.start,a.end)};h.push({afterLine:e.end,id:c,content:(0,$.jsx)(_o,{initialText:r,onTextChange:i,fileLabel:s,lineRange:e,isEditing:!1,onSave:u,onCancel:d,onAddToChat:m},c)})}return h}var Io=e=>{if(e.type===`new`){let t=Math.min(e.selection.start,e.selection.end),n=Math.max(e.selection.start,e.selection.end);return`new-comment-${e.selection.side??`additions`}-${t}-${n}`}return`draft-${e.draft.id}`},Lo=e=>{let{drafts:t,editingDraftId:n,selection:r}=e,i=[];for(let e of t){if(!Number.isFinite(e.endLine))continue;let t=Math.max(1,Math.floor(e.endLine)),r=e.side===`original`?`deletions`:`additions`;i.push({lineNumber:t,side:r,metadata:{type:e.id===n?`edit`:`saved`,draft:e}})}return r&&!n&&i.push({lineNumber:Math.max(r.start,r.end),side:r.side??`additions`,metadata:{type:`new`,selection:r}}),i};function Ro(e){let t=e.trim();if(!t)return null;if(/^-?\d+(\.\d+)?$/.test(t)){let e=Number.parseFloat(t);return Number.isFinite(e)?e:null}if(t.endsWith(`px`)){let e=Number.parseFloat(t.slice(0,-2));return Number.isFinite(e)?e:null}return null}function zo(e){if(!(!e||e<=0))return Math.max(200,Math.floor(e))}function Bo(e){let{diffRootRef:t,drafts:n,selection:r,editingDraftId:i,commentText:a,onTextChange:o,fileLabel:s,onSave:c,onCancel:l,onEdit:u,onDelete:d,onAddToChat:f}=e,[p,m]=Q.useState(0),[h,g]=Q.useState(null),_=Q.useMemo(()=>!r||i?null:Io({type:`new`,selection:r}),[i,r]),v=Q.useMemo(()=>{let e=n.map(e=>Io({type:e.id===i?`edit`:`saved`,draft:e}));return _&&e.push(_),e},[n,i,_]),y=Q.useCallback(e=>{let n=t.current;if(!n)return null;let r=n.querySelector(`diffs-container`);if(!(r instanceof HTMLElement))return null;let i=r.querySelector(`[data-annotation-id="${e}"]`);if(i instanceof HTMLElement)return i;let a=r.shadowRoot;return a?a.querySelector(`[data-annotation-id="${e}"]`):null},[t]);Q.useEffect(()=>{if(v.length===0)return;let e=!1,t=0,n=()=>{e||v.every(e=>!!y(e))||t>=12||(t+=1,requestAnimationFrame(()=>{e||(m(e=>e+1),n())}))};return n(),()=>{e=!0}},[v,y]),Q.useEffect(()=>{let e=t.current;if(!e)return;let n=()=>{let t=Ro(getComputedStyle(e).getPropertyValue(`--oc-context-panel-width`)),n=e.getBoundingClientRect(),r=t??n.width;g(r>0?r:null)};n();let r=new ResizeObserver(()=>{n()});return r.observe(e),window.addEventListener(`resize`,n),()=>{r.disconnect(),window.removeEventListener(`resize`,n)}},[t]);let b=Q.useCallback(e=>{let n=t.current?.getBoundingClientRect(),r=e.closest(`[data-annotation-content]`),i=r instanceof HTMLElement?r.getBoundingClientRect():e.getBoundingClientRect(),a=[i.width];n&&a.push(n.right-i.left);let o=a.filter(e=>Number.isFinite(e)&&e>0);return o.length>0?zo(Math.min(...o)):zo(h)},[t,h]);return(0,$.jsxs)($.Fragment,{children:[n.map(e=>{let t=Io({type:e.id===i?`edit`:`saved`,draft:e}),n=y(t);if(!n)return null;let r=b(n);return e.id===i?(0,Jr.createPortal)((0,$.jsx)(_o,{initialText:a,onTextChange:o,fileLabel:s,lineRange:{start:e.startLine,end:e.endLine,side:e.side===`original`?`deletions`:`additions`},isEditing:!0,onSave:c,onCancel:l,onAddToChat:f,maxWidth:r}),n,`draft-edit-${e.id}`):(0,Jr.createPortal)((0,$.jsx)(go,{draft:e,onEdit:()=>u(e),onDelete:()=>d(e),maxWidth:r}),n,`draft-card-${e.id}`)}),r&&!i&&_&&(()=>{let e=y(_);if(!e)return null;let t=b(e);return(0,Jr.createPortal)((0,$.jsx)(_o,{initialText:a,onTextChange:o,fileLabel:s,lineRange:r,isEditing:!1,onSave:c,onCancel:l,onAddToChat:f,maxWidth:t}),e,_)})()]})}function Vo(e){let t=(0,qr.c)(16),{position:n,onAddToChat:r,onDismiss:i}=e,{t:a}=fe(),o=Q.useRef(null),s,c;t[0]===i?(s=t[1],c=t[2]):(s=()=>{if(!i)return;let e=e=>{o.current&&e.target instanceof Node&&o.current.contains(e.target)||i()};return window.addEventListener(`scroll`,e,{capture:!0,passive:!0}),()=>{window.removeEventListener(`scroll`,e,!0)}},c=[i],t[0]=i,t[1]=s,t[2]=c),Q.useEffect(s,c);let l;t[3]!==n.x||t[4]!==n.y?(l={left:n.x,top:n.y},t[3]=n.x,t[4]=n.y,t[5]=l):l=t[5];let u;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(Z,{name:`add`,className:`size-4`}),t[6]=u):u=t[6];let d;t[7]===a?d=t[8]:(d=a(`chat.textSelection.actions.addToChat`),t[7]=a,t[8]=d);let f;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(Rt,{shortcut:`⌘+I`}),t[9]=f):f=t[9];let p;t[10]!==r||t[11]!==d?(p=(0,$.jsxs)(X,{variant:`ghost`,size:`sm`,className:`h-7 gap-1.5 px-2`,onClick:r,children:[u,d,f]}),t[10]=r,t[11]=d,t[12]=p):p=t[12];let m;return t[13]!==l||t[14]!==p?(m=(0,Jr.createPortal)((0,$.jsx)(`div`,{ref:o,"data-code-selection-action":`true`,className:`fixed z-[100] -translate-y-full rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-1 shadow-lg`,style:l,onPointerDown:Ho,children:p}),document.body),t[13]=l,t[14]=p,t[15]=m):m=t[15],m}function Ho(e){return e.preventDefault()}var Uo=`[data-code-selection-action]`;function Wo(e){return e instanceof Element&&!!e.closest(Uo)}function Go(e,t=[]){return Wo(e)?!0:t.some(e=>e instanceof Element&&e.matches(`[data-column-number]`))}function Ko(e,t){return e&&!!t?.trim()}function qo(e,t,n,r){let i=r.side===`deletions`,a=Math.min(r.start,r.end),o=Math.max(r.start,r.end);if(!n){let n=(i?e:t).split(`
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{_t as t,ht as n,lt as r,mt as i,ut as a}from"./persistence-Dnj1QOdX.js";import{nt as o,rt as s}from"./vendor-base-ui-CnHfUmDN.js";import{n as c,t as l}from"./platform-wu6wSDfg.js";import{n as u}from"./vendor-react-DLPElpoQ.js";import{a as d,n as f}from"./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js";import{f as p,n as m,r as h}from"./vendor-reactuses-core-Dq5ocTF8.js";import{f as g,r as _,t as v}from"./button-CUwjpv-i.js";import{Ir as y}from"./useMobileNavigationStore-DQI782g6.js";import{n as b}from"./Icon-BdzPRCSy.js";import{i as x,t as S}from"./textarea-Kl-rTWJe.js";var C=e(s(),1),w=u(),T=o(),E=d(`OpenChamberMedia`);function D(e){return e.platform===`android`||/Android/i.test(e.userAgent)||e.userAgentDataPlatform===`Android`}function O(){if(typeof window>`u`)return!1;let e=navigator.userAgentData;return D({platform:l(),userAgent:navigator.userAgent||``,userAgentDataPlatform:e?.platform})}function ee(){return c()&&f.getPlatform()===`android`&&f.isPluginAvailable(`OpenChamberMedia`)}async function te(e){if(!ee())return null;let t=await E.pickMedia({limit:e});if(t.cancelled)return[];let n=[];for(let e of t.files){let t=await fetch(f.convertFileSrc(e.path));if(!t.ok)throw Error(`Native media fetch failed (${t.status})`);let r=await t.blob();n.push(new File([r],e.name,{type:e.mimeType}))}return n}var k=`h-auto min-h-12 w-full justify-start gap-3 rounded-none supports-[corner-shape:squircle]:rounded-none px-4 border-b border-[var(--surface-subtle)] last:border-b-0`,ne=e=>{let t=(0,w.c)(38),{id:n,open:r,onOpenChange:i,onPickPhotos:a,onPickFiles:o}=e,{t:s}=g(),c;t[0]===s?c=t[1]:(c=s(`chat.chatInput.actions.addAttachment`),t[0]=s,t[1]=c);let l;t[2]===c?l=t[3]:(l=(0,T.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold`,children:c}),t[2]=c,t[3]=l);let u;t[4]===s?u=t[5]:(u=s(`chat.chatInput.actions.addAttachment`),t[4]=s,t[5]=u);let d;t[6]===s?d=t[7]:(d=s(`mobile.surface.closeAria`),t[6]=s,t[7]=d);let f;t[8]===s?f=t[9]:(f=s(`mobile.sessions.sheet.resizeAria`),t[8]=s,t[9]=f);let p;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,T.jsx)(b,{name:`file-image`,className:`size-5 flex-shrink-0 text-muted-foreground`}),t[10]=p):p=t[10];let m;t[11]===s?m=t[12]:(m=s(`chat.chatInput.actions.attachPhotos`),t[11]=s,t[12]=m);let h;t[13]===m?h=t[14]:(h=(0,T.jsx)(`span`,{className:`truncate`,children:m}),t[13]=m,t[14]=h);let _;t[15]!==a||t[16]!==h?(_=(0,T.jsxs)(v,{type:`button`,variant:`ghost`,size:`lg`,className:k,"data-mobile-press-feedback":`none`,onClick:a,children:[p,h]}),t[15]=a,t[16]=h,t[17]=_):_=t[17];let y;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,T.jsx)(b,{name:`attachment-2`,className:`size-5 flex-shrink-0 text-muted-foreground`}),t[18]=y):y=t[18];let S;t[19]===s?S=t[20]:(S=s(`chat.chatInput.actions.attachFiles`),t[19]=s,t[20]=S);let C;t[21]===S?C=t[22]:(C=(0,T.jsx)(`span`,{className:`truncate`,children:S}),t[21]=S,t[22]=C);let E;t[23]!==o||t[24]!==C?(E=(0,T.jsxs)(v,{type:`button`,variant:`ghost`,size:`lg`,className:k,"data-mobile-press-feedback":`none`,onClick:o,children:[y,C]}),t[23]=o,t[24]=C,t[25]=E):E=t[25];let D;t[26]!==E||t[27]!==_?(D=(0,T.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-y-auto overscroll-contain px-3 pb-3`,children:(0,T.jsxs)(`div`,{className:`overflow-hidden rounded-2xl bg-[var(--surface-muted)]`,"data-page-scroll-lock":`true`,children:[_,E]})}),t[26]=E,t[27]=_,t[28]=D):D=t[28];let O;return t[29]!==n||t[30]!==i||t[31]!==r||t[32]!==D||t[33]!==l||t[34]!==u||t[35]!==d||t[36]!==f?(O=(0,T.jsx)(x,{id:n,open:r,onOpenChange:i,title:l,ariaLabel:u,closeAriaLabel:d,resizeAriaLabel:f,fitContent:!0,children:D}),t[29]=n,t[30]=i,t[31]=r,t[32]=D,t[33]=l,t[34]=u,t[35]=d,t[36]=f,t[37]=O):O=t[37],O},re=C.createContext(null),A=e=>{let t=(0,w.c)(3),{actions:n,children:r}=e,i;return t[0]!==n||t[1]!==r?(i=(0,T.jsx)(re.Provider,{value:n,children:r}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i},ie=()=>C.useContext(re),ae=e=>e.nativeEvent.isComposing||e.nativeEvent.keyCode===229;function j(e){let t=(0,w.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:r,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===r?a=t[5]:(a=_(`inline-flex shrink-0 items-center justify-center rounded-full bg-foreground text-background`,r),t[4]=r,t[5]=a);let o;return t[6]!==n||t[7]!==i||t[8]!==a?(o=(0,T.jsx)(`span`,{className:a,...i,"aria-hidden":!0,children:n}),t[6]=n,t[7]=i,t[8]=a,t[9]=o):o=t[9],o}function M(e){let t=(0,w.c)(7),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,T.jsx)(`span`,{"data-stop-glyph":`true`,className:`block size-[38%] rounded-[20%] bg-current`}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,T.jsx)(j,{className:n,...r,children:i}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function N(e){let t=(0,w.c)(13),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,spinning:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i!==void 0&&i,o=a?`loader-4`:`arrow-up`,s=a?`size-[50%] animate-spin`:`size-[56%]`,c;t[4]===s?c=t[5]:(c=_(s),t[4]=s,t[5]=c);let l;t[6]!==o||t[7]!==c?(l=(0,T.jsx)(b,{name:o,weight:`medium`,className:c}),t[6]=o,t[7]=c,t[8]=l):l=t[8];let u;return t[9]!==n||t[10]!==r||t[11]!==l?(u=(0,T.jsx)(j,{className:n,...r,children:l}),t[9]=n,t[10]=r,t[11]=l,t[12]=u):u=t[12],u}var oe=C.forwardRef((e,t)=>{let n=(0,w.c)(19),r,i,a,o,s,c;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4],s=n[5],c=n[6]):({children:r,className:i,expanded:s,focusedTone:c,style:o,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o,n[5]=s,n[6]=c);let l=s!==void 0&&s,u=c===void 0?`primary`:c,d=l&&`min-h-0 flex-1`,f=u===`info`?`focus-within:ring-[var(--status-info)]`:`focus-within:ring-primary/50`,p;n[7]!==i||n[8]!==d||n[9]!==f?(p=_(`relative flex flex-col overflow-visible border border-border/80 focus-within:ring-1`,d,f,i),n[7]=i,n[8]=d,n[9]=f,n[10]=p):p=n[10];let m;n[11]===o?m=n[12]:(m={borderRadius:`var(--radius-xl)`,backgroundColor:`var(--surface-subtle)`,...o},n[11]=o,n[12]=m);let h;return n[13]!==r||n[14]!==a||n[15]!==t||n[16]!==p||n[17]!==m?(h=(0,T.jsx)(`div`,{ref:t,className:p,style:m,...a,children:r}),n[13]=r,n[14]=a,n[15]=t,n[16]=p,n[17]=m,n[18]=h):h=n[18],h});oe.displayName=`ChatComposerSurface`;var se=C.forwardRef((e,t)=>{let n=(0,w.c)(3),r;return n[0]!==e||n[1]!==t?(r=(0,T.jsx)(S,{ref:t,...e}),n[0]=e,n[1]=t,n[2]=r):r=n[2],r});se.displayName=`ChatPromptTextarea`;var ce=e=>{let t=(0,w.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:r,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===r?a=t[5]:(a=_(`flex shrink-0 items-center gap-2 bg-transparent px-2.5 py-1.5`,r),t[4]=r,t[5]=a);let o;return t[6]!==n||t[7]!==i||t[8]!==a?(o=(0,T.jsx)(`div`,{className:a,"data-chat-input-footer":`true`,...i,children:n}),t[6]=n,t[7]=i,t[8]=a,t[9]=o):o=t[9],o},le=(e,t)=>{typeof e==`function`?e(t):e&&(e.current=t)},P=({value:e,attachments:t=[],disabled:n=!1,pending:r=!1,placeholder:i,isMobile:a=!1,onChange:o,onSubmit:s,onStop:c,onAddFiles:l,onRemoveAttachment:u,addFilesLabel:d,removeAttachmentLabel:f,fileAccept:h=`image/*`,sendLabel:v,stopLabel:x,hint:S,leftControls:w,rightControls:E,footerContent:D,inputHeader:k,attachmentContent:re,highlightedContent:A,highlightRef:ie,inputRef:j,textareaProps:P,textLayoutClassName:ue,inputClassName:F,inputOuterClassName:de,inputStyle:I,footerClassName:L,footerStyle:R,contentClassName:z,inputSectionClassName:fe,autoResize:B=!0,disableInputWhilePending:V=!0,layout:H=`stacked`,children:pe,className:me,expanded:U=!1,...he})=>{let{t:ge}=g(),W=H===`inline`,[G,_e]=C.useState(!1),[ve,K]=C.useState(!1),q=O(),ye=t.length>0||G,J=C.useRef(null),Y=C.useRef(null),X=C.useRef(null),be=C.useId().replace(/:/g,``),xe=m(()=>{if(!B||U||P?.fillContainer){W&&_e(!1);return}let e=J.current;if(!e)return;e.style.height=W?`0px`:`auto`;let t=Number.parseFloat(window.getComputedStyle(e).maxHeight),n=W?Math.max(e.scrollHeight,48):e.scrollHeight,r=Number.isFinite(t)?Math.min(n,t):n;e.style.height=`${r}px`,e.style.overflowY=Number.isFinite(t)&&n>t?`auto`:`hidden`;let i=r>48;W&&_e(e=>e===i?e:i)});C.useLayoutEffect(()=>{xe()},[B,U,W,P?.fillContainer,e]),p(W&&B&&!U&&!P?.fillContainer?J:null,xe);let Z=e=>{P?.onKeyDown?.(e),!(e.defaultPrevented||ae(e))&&e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),!n&&(!r||!V)&&s())},Se=e=>{l?.(e.target.files),e.target.value=``},Ce=m(()=>{J.current?.blur(),K(!0)}),we=m(e=>{K(!1),requestAnimationFrame(()=>e?.click())}),Te=m(()=>{K(!1),requestAnimationFrame(()=>{(async()=>{if(!ee()){X.current?.click();return}try{let e=await te(20);if(e===null){X.current?.click();return}e.length>0&&l?.(e)}catch(e){console.error(`Native photo pick failed`,e),y.error(ge(`chat.chatInput.toast.attachFileFailed`))}})()})}),Ee=e.trim().length>0||t.length>0,De=t.filter(e=>e.mime.startsWith(`image/`)),Oe=t.filter(e=>!e.mime.startsWith(`image/`)),ke=l?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`input`,{ref:Y,type:`file`,accept:h,multiple:!0,className:`hidden`,onChange:Se}),q?(0,T.jsx)(`input`,{ref:X,type:`file`,accept:`image/*`,multiple:!0,className:`hidden`,onChange:Se}):null,(0,T.jsx)(`button`,{type:`button`,className:`flex size-8 shrink-0 items-center justify-center rounded-md text-foreground outline-none hover:bg-[var(--interactive-hover)] disabled:cursor-not-allowed disabled:opacity-40`,onClick:()=>q?Ce():Y.current?.click(),onMouseDown:a?e=>e.preventDefault():void 0,onPointerDownCapture:a?e=>e.preventDefault():void 0,disabled:n||r,"aria-label":d,children:(0,T.jsx)(b,{name:`attachment-2`,className:`size-[18px]`})})]}):null,Q=!n&&!r&&Ee,$=a?`size-6`:`size-full`,Ae=r&&c?(0,T.jsx)(`button`,{type:`button`,"data-composer-stop":`true`,className:`flex size-8 shrink-0 items-center justify-center rounded-full outline-none hover:opacity-80`,onClick:c,"aria-label":x,children:(0,T.jsx)(M,{className:$})}):(0,T.jsx)(`button`,{type:`submit`,"data-composer-send":`true`,"data-composer-circle":Q?`true`:void 0,className:_(`flex size-8 shrink-0 items-center justify-center outline-none`,Q?`rounded-full hover:opacity-80`:`rounded-md text-primary hover:bg-[var(--interactive-hover)] disabled:cursor-not-allowed disabled:opacity-30`),disabled:n||r||!Ee,"aria-label":v,children:Q?(0,T.jsx)(N,{className:$}):(0,T.jsx)(b,{name:r?`loader-4`:`send-plane-2`,className:_(`size-4`,r&&`animate-spin`)})}),je=r&&c?(0,T.jsx)(`button`,{type:`button`,"data-composer-stop":`true`,className:`flex size-8 shrink-0 items-center justify-center rounded-full outline-none hover:opacity-80`,onClick:c,"aria-label":x,children:(0,T.jsx)(M,{className:$})}):(0,T.jsx)(`button`,{type:`submit`,"data-composer-send":`true`,"data-composer-circle":`true`,className:_(`flex size-8 shrink-0 items-center justify-center rounded-full outline-none`,Q?`hover:opacity-80`:`cursor-not-allowed opacity-30`),disabled:n||r||!Ee,"aria-busy":r||void 0,"aria-label":v,children:(0,T.jsx)(N,{className:$,spinning:r})}),Me=W?je:Ae,Ne=w===void 0?ke:w;return(0,T.jsxs)(oe,{className:me,expanded:U,...he,children:[pe,(0,T.jsxs)(`div`,{"data-composer-content":`true`,"data-composer-layout":H,className:_(`relative flex min-h-0`,W?_(`min-h-12 flex-row`,ye?`items-end`:`items-center`):`flex-col`,U&&`flex-1`,z),children:[W&&Ne?(0,T.jsx)(`div`,{className:`flex h-12 shrink-0 items-center pl-1.5`,"data-composer-inline-attach":`true`,children:Ne}):null,(0,T.jsxs)(`div`,{className:_(`overflow-hidden`,W&&`min-w-0 flex-1`,U&&`flex min-h-0 flex-1 flex-col`,fe),children:[k,re,De.length>0?(0,T.jsx)(`div`,{className:`flex gap-2 overflow-x-auto px-3 pt-3`,"data-chat-prompt-attachments":`true`,children:De.map(e=>(0,T.jsxs)(`div`,{className:`group relative shrink-0`,children:[(0,T.jsx)(`img`,{src:e.url,alt:e.name,className:`size-16 rounded-lg border border-border object-cover`}),u?(0,T.jsx)(`button`,{type:`button`,className:`absolute -right-1 -top-1 flex size-6 items-center justify-center rounded-full border border-border bg-[var(--surface-elevated)] shadow-sm hover:bg-[var(--interactive-hover)]`,onClick:()=>u(e.id),"aria-label":f,children:(0,T.jsx)(b,{name:`close`,className:`size-3`})}):null]},e.id))}):null,Oe.length>0?(0,T.jsx)(`div`,{className:`flex flex-wrap gap-2 px-3 pt-3`,"data-chat-prompt-file-attachments":`true`,children:Oe.map(e=>(0,T.jsxs)(`div`,{className:`relative flex max-w-[12rem] items-center gap-1.5 rounded-lg border border-border bg-[var(--surface-elevated)] px-2 py-1`,children:[(0,T.jsx)(b,{name:`file-text`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,T.jsx)(`span`,{className:`min-w-0 truncate typography-micro`,children:e.name}),u?(0,T.jsx)(`button`,{type:`button`,className:`flex size-5 shrink-0 items-center justify-center rounded-full text-muted-foreground hover:bg-[var(--interactive-hover)]`,onClick:()=>u(e.id),"aria-label":f,children:(0,T.jsx)(b,{name:`close`,className:`size-3`})}):null]},e.id))}):null,(0,T.jsxs)(`div`,{className:_(`relative overflow-hidden`,W&&_(`flex min-h-12`,G?`items-end`:`items-center`),U&&`flex min-h-0 flex-1 flex-col`),"data-composer-input-shell":`true`,children:[A?(0,T.jsx)(`div`,{ref:ie,"aria-hidden":!0,"data-composer-highlight":`true`,className:_(`pointer-events-none absolute inset-0 z-0 rounded-b-none`,ue,F),children:A}):null,(0,T.jsx)(se,{...P,simple:!0,fillContainer:!W&&P?.fillContainer,ref:e=>{J.current=e,le(j,e)},"data-chat-input":`true`,value:e,onChange:e=>o(e.target.value,e),onKeyDown:Z,disabled:n||r&&V,placeholder:i,enterKeyHint:a?`send`:P?.enterKeyHint,outerClassName:_(`ring-0 bg-transparent shadow-none hover:bg-transparent focus-within:ring-0`,W&&`flex-none`,U&&`min-h-0 flex-1`,de),className:_(`relative z-10 resize-none overflow-y-hidden appearance-none border-0 bg-transparent typography-markdown hover:border-transparent md:typography-ui-label`,W?`field-sizing-fixed min-h-12 max-h-32 px-3 py-3 leading-6`:`min-h-[52px] max-h-40 rounded-b-none px-3 pb-2 pt-4`,ue,F,A&&`text-transparent caret-[var(--surface-foreground)]`),style:I,rows:P?.rows??1})]})]}),W?(0,T.jsx)(`div`,{className:_(`flex h-12 shrink-0 items-center pr-1.5`,L),style:R,"data-composer-inline-send":`true`,children:E??Me}):(0,T.jsx)(ce,{className:L,style:R,children:D??(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`div`,{className:`flex items-center gap-1.5`,children:w??ke}),S?(0,T.jsx)(`div`,{className:`min-w-0 flex-1 truncate typography-micro text-muted-foreground`,children:S}):(0,T.jsx)(`div`,{className:`flex-1`}),(0,T.jsx)(`div`,{className:`flex items-center gap-1.5`,children:E??Me})]})})]}),q&&l?(0,T.jsx)(ne,{id:`mobile-attach-pick-${be}`,open:ve,onOpenChange:e=>{e||K(!1)},onPickPhotos:Te,onPickFiles:()=>we(Y.current)}):null]})},ue={mentionFile:100,mentionAgent:100,mentionSession:100,mentionCommand:100,mentionPaste:100,code:90,codeFence:90,link:80,linkUrl:78,heading:70,blockquote:40,listMarker:35,marker:10},F={mentionFile:`text-[var(--primary)]`,mentionAgent:`text-[var(--primary)]`,mentionSession:`text-[var(--primary)]`,mentionCommand:`text-[var(--primary)]`,mentionPaste:`text-[var(--primary)]`,code:`rounded-[3px] bg-[var(--surface-subtle)] text-[var(--markdown-inline-code)]`,codeFence:`bg-[var(--surface-subtle)] text-[var(--markdown-inline-code)]`,link:`text-[var(--status-info)] underline`,linkUrl:`text-muted-foreground`,heading:`text-[var(--syntax-keyword)]`,blockquote:`text-muted-foreground`,listMarker:`text-[var(--syntax-keyword)]`,marker:`text-muted-foreground`},de=`text-foreground`;function I(e,t,n){let r=0,i=e.length;for(;r<i;){let i=e[r];if(i==="`"){let i=/^`+/.exec(e.slice(r))?.[0]??``,a=e.indexOf(i,r+i.length);if(a!==-1){let e=a+i.length;n.push({start:t+r,end:t+e,style:`code`}),r=e;continue}}if(i===`[`){let i=/^\[([^\]\n]*)\]\(([^)\n]*)\)/.exec(e.slice(r));if(i){let e=t+r,a=i[1].length,o=i[2].length,s=e+1,c=s+a,l=c+2,u=l+o,d=u+1;n.push({start:e,end:s,style:`marker`}),a>0&&n.push({start:s,end:c,style:`link`}),n.push({start:c,end:l,style:`marker`}),o>0&&n.push({start:l,end:u,style:`linkUrl`}),n.push({start:u,end:d,style:`marker`}),r+=i[0].length;continue}}r+=1}}var L=/^(\s*)(`{3,}|~{3,})\s*(\S*)/;function R(e){let t=L.exec(e);return t?{marker:t[2],lang:t[3]||``}:null}function z(e,t){return RegExp(`^\\s*\\${t[0]}{${t.length},}\\s*$`).test(e)}function fe(e){let t=[];if(!e)return t;let n=0,r=!1,i=``,a=e.split(`
|
|
1
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{_t as t,ht as n,lt as r,mt as i,ut as a}from"./persistence-Dnj1QOdX.js";import{nt as o,rt as s}from"./vendor-base-ui-CnHfUmDN.js";import{n as c,t as l}from"./platform-wu6wSDfg.js";import{n as u}from"./vendor-react-DLPElpoQ.js";import{a as d,n as f}from"./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js";import{f as p,n as m,r as h}from"./vendor-reactuses-core-Dq5ocTF8.js";import{f as g,r as _,t as v}from"./button-CUwjpv-i.js";import{Ir as y}from"./useMobileNavigationStore-EUU6F5qa.js";import{n as b}from"./Icon-BdzPRCSy.js";import{i as x,t as S}from"./textarea-Kl-rTWJe.js";var C=e(s(),1),w=u(),T=o(),E=d(`OpenChamberMedia`);function D(e){return e.platform===`android`||/Android/i.test(e.userAgent)||e.userAgentDataPlatform===`Android`}function O(){if(typeof window>`u`)return!1;let e=navigator.userAgentData;return D({platform:l(),userAgent:navigator.userAgent||``,userAgentDataPlatform:e?.platform})}function ee(){return c()&&f.getPlatform()===`android`&&f.isPluginAvailable(`OpenChamberMedia`)}async function te(e){if(!ee())return null;let t=await E.pickMedia({limit:e});if(t.cancelled)return[];let n=[];for(let e of t.files){let t=await fetch(f.convertFileSrc(e.path));if(!t.ok)throw Error(`Native media fetch failed (${t.status})`);let r=await t.blob();n.push(new File([r],e.name,{type:e.mimeType}))}return n}var k=`h-auto min-h-12 w-full justify-start gap-3 rounded-none supports-[corner-shape:squircle]:rounded-none px-4 border-b border-[var(--surface-subtle)] last:border-b-0`,ne=e=>{let t=(0,w.c)(38),{id:n,open:r,onOpenChange:i,onPickPhotos:a,onPickFiles:o}=e,{t:s}=g(),c;t[0]===s?c=t[1]:(c=s(`chat.chatInput.actions.addAttachment`),t[0]=s,t[1]=c);let l;t[2]===c?l=t[3]:(l=(0,T.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold`,children:c}),t[2]=c,t[3]=l);let u;t[4]===s?u=t[5]:(u=s(`chat.chatInput.actions.addAttachment`),t[4]=s,t[5]=u);let d;t[6]===s?d=t[7]:(d=s(`mobile.surface.closeAria`),t[6]=s,t[7]=d);let f;t[8]===s?f=t[9]:(f=s(`mobile.sessions.sheet.resizeAria`),t[8]=s,t[9]=f);let p;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,T.jsx)(b,{name:`file-image`,className:`size-5 flex-shrink-0 text-muted-foreground`}),t[10]=p):p=t[10];let m;t[11]===s?m=t[12]:(m=s(`chat.chatInput.actions.attachPhotos`),t[11]=s,t[12]=m);let h;t[13]===m?h=t[14]:(h=(0,T.jsx)(`span`,{className:`truncate`,children:m}),t[13]=m,t[14]=h);let _;t[15]!==a||t[16]!==h?(_=(0,T.jsxs)(v,{type:`button`,variant:`ghost`,size:`lg`,className:k,"data-mobile-press-feedback":`none`,onClick:a,children:[p,h]}),t[15]=a,t[16]=h,t[17]=_):_=t[17];let y;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,T.jsx)(b,{name:`attachment-2`,className:`size-5 flex-shrink-0 text-muted-foreground`}),t[18]=y):y=t[18];let S;t[19]===s?S=t[20]:(S=s(`chat.chatInput.actions.attachFiles`),t[19]=s,t[20]=S);let C;t[21]===S?C=t[22]:(C=(0,T.jsx)(`span`,{className:`truncate`,children:S}),t[21]=S,t[22]=C);let E;t[23]!==o||t[24]!==C?(E=(0,T.jsxs)(v,{type:`button`,variant:`ghost`,size:`lg`,className:k,"data-mobile-press-feedback":`none`,onClick:o,children:[y,C]}),t[23]=o,t[24]=C,t[25]=E):E=t[25];let D;t[26]!==E||t[27]!==_?(D=(0,T.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-y-auto overscroll-contain px-3 pb-3`,children:(0,T.jsxs)(`div`,{className:`overflow-hidden rounded-2xl bg-[var(--surface-muted)]`,"data-page-scroll-lock":`true`,children:[_,E]})}),t[26]=E,t[27]=_,t[28]=D):D=t[28];let O;return t[29]!==n||t[30]!==i||t[31]!==r||t[32]!==D||t[33]!==l||t[34]!==u||t[35]!==d||t[36]!==f?(O=(0,T.jsx)(x,{id:n,open:r,onOpenChange:i,title:l,ariaLabel:u,closeAriaLabel:d,resizeAriaLabel:f,fitContent:!0,children:D}),t[29]=n,t[30]=i,t[31]=r,t[32]=D,t[33]=l,t[34]=u,t[35]=d,t[36]=f,t[37]=O):O=t[37],O},re=C.createContext(null),A=e=>{let t=(0,w.c)(3),{actions:n,children:r}=e,i;return t[0]!==n||t[1]!==r?(i=(0,T.jsx)(re.Provider,{value:n,children:r}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i},ie=()=>C.useContext(re),ae=e=>e.nativeEvent.isComposing||e.nativeEvent.keyCode===229;function j(e){let t=(0,w.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:r,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===r?a=t[5]:(a=_(`inline-flex shrink-0 items-center justify-center rounded-full bg-foreground text-background`,r),t[4]=r,t[5]=a);let o;return t[6]!==n||t[7]!==i||t[8]!==a?(o=(0,T.jsx)(`span`,{className:a,...i,"aria-hidden":!0,children:n}),t[6]=n,t[7]=i,t[8]=a,t[9]=o):o=t[9],o}function M(e){let t=(0,w.c)(7),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,T.jsx)(`span`,{"data-stop-glyph":`true`,className:`block size-[38%] rounded-[20%] bg-current`}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,T.jsx)(j,{className:n,...r,children:i}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function N(e){let t=(0,w.c)(13),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,spinning:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i!==void 0&&i,o=a?`loader-4`:`arrow-up`,s=a?`size-[50%] animate-spin`:`size-[56%]`,c;t[4]===s?c=t[5]:(c=_(s),t[4]=s,t[5]=c);let l;t[6]!==o||t[7]!==c?(l=(0,T.jsx)(b,{name:o,weight:`medium`,className:c}),t[6]=o,t[7]=c,t[8]=l):l=t[8];let u;return t[9]!==n||t[10]!==r||t[11]!==l?(u=(0,T.jsx)(j,{className:n,...r,children:l}),t[9]=n,t[10]=r,t[11]=l,t[12]=u):u=t[12],u}var oe=C.forwardRef((e,t)=>{let n=(0,w.c)(19),r,i,a,o,s,c;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4],s=n[5],c=n[6]):({children:r,className:i,expanded:s,focusedTone:c,style:o,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o,n[5]=s,n[6]=c);let l=s!==void 0&&s,u=c===void 0?`primary`:c,d=l&&`min-h-0 flex-1`,f=u===`info`?`focus-within:ring-[var(--status-info)]`:`focus-within:ring-primary/50`,p;n[7]!==i||n[8]!==d||n[9]!==f?(p=_(`relative flex flex-col overflow-visible border border-border/80 focus-within:ring-1`,d,f,i),n[7]=i,n[8]=d,n[9]=f,n[10]=p):p=n[10];let m;n[11]===o?m=n[12]:(m={borderRadius:`var(--radius-xl)`,backgroundColor:`var(--surface-subtle)`,...o},n[11]=o,n[12]=m);let h;return n[13]!==r||n[14]!==a||n[15]!==t||n[16]!==p||n[17]!==m?(h=(0,T.jsx)(`div`,{ref:t,className:p,style:m,...a,children:r}),n[13]=r,n[14]=a,n[15]=t,n[16]=p,n[17]=m,n[18]=h):h=n[18],h});oe.displayName=`ChatComposerSurface`;var se=C.forwardRef((e,t)=>{let n=(0,w.c)(3),r;return n[0]!==e||n[1]!==t?(r=(0,T.jsx)(S,{ref:t,...e}),n[0]=e,n[1]=t,n[2]=r):r=n[2],r});se.displayName=`ChatPromptTextarea`;var ce=e=>{let t=(0,w.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:r,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===r?a=t[5]:(a=_(`flex shrink-0 items-center gap-2 bg-transparent px-2.5 py-1.5`,r),t[4]=r,t[5]=a);let o;return t[6]!==n||t[7]!==i||t[8]!==a?(o=(0,T.jsx)(`div`,{className:a,"data-chat-input-footer":`true`,...i,children:n}),t[6]=n,t[7]=i,t[8]=a,t[9]=o):o=t[9],o},le=(e,t)=>{typeof e==`function`?e(t):e&&(e.current=t)},P=({value:e,attachments:t=[],disabled:n=!1,pending:r=!1,placeholder:i,isMobile:a=!1,onChange:o,onSubmit:s,onStop:c,onAddFiles:l,onRemoveAttachment:u,addFilesLabel:d,removeAttachmentLabel:f,fileAccept:h=`image/*`,sendLabel:v,stopLabel:x,hint:S,leftControls:w,rightControls:E,footerContent:D,inputHeader:k,attachmentContent:re,highlightedContent:A,highlightRef:ie,inputRef:j,textareaProps:P,textLayoutClassName:ue,inputClassName:F,inputOuterClassName:de,inputStyle:I,footerClassName:L,footerStyle:R,contentClassName:z,inputSectionClassName:fe,autoResize:B=!0,disableInputWhilePending:V=!0,layout:H=`stacked`,children:pe,className:me,expanded:U=!1,...he})=>{let{t:ge}=g(),W=H===`inline`,[G,_e]=C.useState(!1),[ve,K]=C.useState(!1),q=O(),ye=t.length>0||G,J=C.useRef(null),Y=C.useRef(null),X=C.useRef(null),be=C.useId().replace(/:/g,``),xe=m(()=>{if(!B||U||P?.fillContainer){W&&_e(!1);return}let e=J.current;if(!e)return;e.style.height=W?`0px`:`auto`;let t=Number.parseFloat(window.getComputedStyle(e).maxHeight),n=W?Math.max(e.scrollHeight,48):e.scrollHeight,r=Number.isFinite(t)?Math.min(n,t):n;e.style.height=`${r}px`,e.style.overflowY=Number.isFinite(t)&&n>t?`auto`:`hidden`;let i=r>48;W&&_e(e=>e===i?e:i)});C.useLayoutEffect(()=>{xe()},[B,U,W,P?.fillContainer,e]),p(W&&B&&!U&&!P?.fillContainer?J:null,xe);let Z=e=>{P?.onKeyDown?.(e),!(e.defaultPrevented||ae(e))&&e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),!n&&(!r||!V)&&s())},Se=e=>{l?.(e.target.files),e.target.value=``},Ce=m(()=>{J.current?.blur(),K(!0)}),we=m(e=>{K(!1),requestAnimationFrame(()=>e?.click())}),Te=m(()=>{K(!1),requestAnimationFrame(()=>{(async()=>{if(!ee()){X.current?.click();return}try{let e=await te(20);if(e===null){X.current?.click();return}e.length>0&&l?.(e)}catch(e){console.error(`Native photo pick failed`,e),y.error(ge(`chat.chatInput.toast.attachFileFailed`))}})()})}),Ee=e.trim().length>0||t.length>0,De=t.filter(e=>e.mime.startsWith(`image/`)),Oe=t.filter(e=>!e.mime.startsWith(`image/`)),ke=l?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`input`,{ref:Y,type:`file`,accept:h,multiple:!0,className:`hidden`,onChange:Se}),q?(0,T.jsx)(`input`,{ref:X,type:`file`,accept:`image/*`,multiple:!0,className:`hidden`,onChange:Se}):null,(0,T.jsx)(`button`,{type:`button`,className:`flex size-8 shrink-0 items-center justify-center rounded-md text-foreground outline-none hover:bg-[var(--interactive-hover)] disabled:cursor-not-allowed disabled:opacity-40`,onClick:()=>q?Ce():Y.current?.click(),onMouseDown:a?e=>e.preventDefault():void 0,onPointerDownCapture:a?e=>e.preventDefault():void 0,disabled:n||r,"aria-label":d,children:(0,T.jsx)(b,{name:`attachment-2`,className:`size-[18px]`})})]}):null,Q=!n&&!r&&Ee,$=a?`size-6`:`size-full`,Ae=r&&c?(0,T.jsx)(`button`,{type:`button`,"data-composer-stop":`true`,className:`flex size-8 shrink-0 items-center justify-center rounded-full outline-none hover:opacity-80`,onClick:c,"aria-label":x,children:(0,T.jsx)(M,{className:$})}):(0,T.jsx)(`button`,{type:`submit`,"data-composer-send":`true`,"data-composer-circle":Q?`true`:void 0,className:_(`flex size-8 shrink-0 items-center justify-center outline-none`,Q?`rounded-full hover:opacity-80`:`rounded-md text-primary hover:bg-[var(--interactive-hover)] disabled:cursor-not-allowed disabled:opacity-30`),disabled:n||r||!Ee,"aria-label":v,children:Q?(0,T.jsx)(N,{className:$}):(0,T.jsx)(b,{name:r?`loader-4`:`send-plane-2`,className:_(`size-4`,r&&`animate-spin`)})}),je=r&&c?(0,T.jsx)(`button`,{type:`button`,"data-composer-stop":`true`,className:`flex size-8 shrink-0 items-center justify-center rounded-full outline-none hover:opacity-80`,onClick:c,"aria-label":x,children:(0,T.jsx)(M,{className:$})}):(0,T.jsx)(`button`,{type:`submit`,"data-composer-send":`true`,"data-composer-circle":`true`,className:_(`flex size-8 shrink-0 items-center justify-center rounded-full outline-none`,Q?`hover:opacity-80`:`cursor-not-allowed opacity-30`),disabled:n||r||!Ee,"aria-busy":r||void 0,"aria-label":v,children:(0,T.jsx)(N,{className:$,spinning:r})}),Me=W?je:Ae,Ne=w===void 0?ke:w;return(0,T.jsxs)(oe,{className:me,expanded:U,...he,children:[pe,(0,T.jsxs)(`div`,{"data-composer-content":`true`,"data-composer-layout":H,className:_(`relative flex min-h-0`,W?_(`min-h-12 flex-row`,ye?`items-end`:`items-center`):`flex-col`,U&&`flex-1`,z),children:[W&&Ne?(0,T.jsx)(`div`,{className:`flex h-12 shrink-0 items-center pl-1.5`,"data-composer-inline-attach":`true`,children:Ne}):null,(0,T.jsxs)(`div`,{className:_(`overflow-hidden`,W&&`min-w-0 flex-1`,U&&`flex min-h-0 flex-1 flex-col`,fe),children:[k,re,De.length>0?(0,T.jsx)(`div`,{className:`flex gap-2 overflow-x-auto px-3 pt-3`,"data-chat-prompt-attachments":`true`,children:De.map(e=>(0,T.jsxs)(`div`,{className:`group relative shrink-0`,children:[(0,T.jsx)(`img`,{src:e.url,alt:e.name,className:`size-16 rounded-lg border border-border object-cover`}),u?(0,T.jsx)(`button`,{type:`button`,className:`absolute -right-1 -top-1 flex size-6 items-center justify-center rounded-full border border-border bg-[var(--surface-elevated)] shadow-sm hover:bg-[var(--interactive-hover)]`,onClick:()=>u(e.id),"aria-label":f,children:(0,T.jsx)(b,{name:`close`,className:`size-3`})}):null]},e.id))}):null,Oe.length>0?(0,T.jsx)(`div`,{className:`flex flex-wrap gap-2 px-3 pt-3`,"data-chat-prompt-file-attachments":`true`,children:Oe.map(e=>(0,T.jsxs)(`div`,{className:`relative flex max-w-[12rem] items-center gap-1.5 rounded-lg border border-border bg-[var(--surface-elevated)] px-2 py-1`,children:[(0,T.jsx)(b,{name:`file-text`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,T.jsx)(`span`,{className:`min-w-0 truncate typography-micro`,children:e.name}),u?(0,T.jsx)(`button`,{type:`button`,className:`flex size-5 shrink-0 items-center justify-center rounded-full text-muted-foreground hover:bg-[var(--interactive-hover)]`,onClick:()=>u(e.id),"aria-label":f,children:(0,T.jsx)(b,{name:`close`,className:`size-3`})}):null]},e.id))}):null,(0,T.jsxs)(`div`,{className:_(`relative overflow-hidden`,W&&_(`flex min-h-12`,G?`items-end`:`items-center`),U&&`flex min-h-0 flex-1 flex-col`),"data-composer-input-shell":`true`,children:[A?(0,T.jsx)(`div`,{ref:ie,"aria-hidden":!0,"data-composer-highlight":`true`,className:_(`pointer-events-none absolute inset-0 z-0 rounded-b-none`,ue,F),children:A}):null,(0,T.jsx)(se,{...P,simple:!0,fillContainer:!W&&P?.fillContainer,ref:e=>{J.current=e,le(j,e)},"data-chat-input":`true`,value:e,onChange:e=>o(e.target.value,e),onKeyDown:Z,disabled:n||r&&V,placeholder:i,enterKeyHint:a?`send`:P?.enterKeyHint,outerClassName:_(`ring-0 bg-transparent shadow-none hover:bg-transparent focus-within:ring-0`,W&&`flex-none`,U&&`min-h-0 flex-1`,de),className:_(`relative z-10 resize-none overflow-y-hidden appearance-none border-0 bg-transparent typography-markdown hover:border-transparent md:typography-ui-label`,W?`field-sizing-fixed min-h-12 max-h-32 px-3 py-3 leading-6`:`min-h-[52px] max-h-40 rounded-b-none px-3 pb-2 pt-4`,ue,F,A&&`text-transparent caret-[var(--surface-foreground)]`),style:I,rows:P?.rows??1})]})]}),W?(0,T.jsx)(`div`,{className:_(`flex h-12 shrink-0 items-center pr-1.5`,L),style:R,"data-composer-inline-send":`true`,children:E??Me}):(0,T.jsx)(ce,{className:L,style:R,children:D??(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`div`,{className:`flex items-center gap-1.5`,children:w??ke}),S?(0,T.jsx)(`div`,{className:`min-w-0 flex-1 truncate typography-micro text-muted-foreground`,children:S}):(0,T.jsx)(`div`,{className:`flex-1`}),(0,T.jsx)(`div`,{className:`flex items-center gap-1.5`,children:E??Me})]})})]}),q&&l?(0,T.jsx)(ne,{id:`mobile-attach-pick-${be}`,open:ve,onOpenChange:e=>{e||K(!1)},onPickPhotos:Te,onPickFiles:()=>we(Y.current)}):null]})},ue={mentionFile:100,mentionAgent:100,mentionSession:100,mentionCommand:100,mentionPaste:100,code:90,codeFence:90,link:80,linkUrl:78,heading:70,blockquote:40,listMarker:35,marker:10},F={mentionFile:`text-[var(--primary)]`,mentionAgent:`text-[var(--primary)]`,mentionSession:`text-[var(--primary)]`,mentionCommand:`text-[var(--primary)]`,mentionPaste:`text-[var(--primary)]`,code:`rounded-[3px] bg-[var(--surface-subtle)] text-[var(--markdown-inline-code)]`,codeFence:`bg-[var(--surface-subtle)] text-[var(--markdown-inline-code)]`,link:`text-[var(--status-info)] underline`,linkUrl:`text-muted-foreground`,heading:`text-[var(--syntax-keyword)]`,blockquote:`text-muted-foreground`,listMarker:`text-[var(--syntax-keyword)]`,marker:`text-muted-foreground`},de=`text-foreground`;function I(e,t,n){let r=0,i=e.length;for(;r<i;){let i=e[r];if(i==="`"){let i=/^`+/.exec(e.slice(r))?.[0]??``,a=e.indexOf(i,r+i.length);if(a!==-1){let e=a+i.length;n.push({start:t+r,end:t+e,style:`code`}),r=e;continue}}if(i===`[`){let i=/^\[([^\]\n]*)\]\(([^)\n]*)\)/.exec(e.slice(r));if(i){let e=t+r,a=i[1].length,o=i[2].length,s=e+1,c=s+a,l=c+2,u=l+o,d=u+1;n.push({start:e,end:s,style:`marker`}),a>0&&n.push({start:s,end:c,style:`link`}),n.push({start:c,end:l,style:`marker`}),o>0&&n.push({start:l,end:u,style:`linkUrl`}),n.push({start:u,end:d,style:`marker`}),r+=i[0].length;continue}}r+=1}}var L=/^(\s*)(`{3,}|~{3,})\s*(\S*)/;function R(e){let t=L.exec(e);return t?{marker:t[2],lang:t[3]||``}:null}function z(e,t){return RegExp(`^\\s*\\${t[0]}{${t.length},}\\s*$`).test(e)}function fe(e){let t=[];if(!e)return t;let n=0,r=!1,i=``,a=e.split(`
|
|
2
2
|
`);for(let e=0;e<a.length;e+=1){let o=a[e],s=n,c=s+o.length;if(n=c+1,r){t.push({start:s,end:c,style:`codeFence`}),z(o,i)&&(r=!1);continue}let l=R(o);if(l){r=!0,i=l.marker,t.push({start:s,end:c,style:`codeFence`});continue}let u=/^(\s*)(#{1,6})(\s+)/.exec(o);if(u){let e=s+u[1].length,n=e+u[2].length;t.push({start:e,end:n,style:`marker`});let r=n+u[3].length;c>r&&(t.push({start:r,end:c,style:`heading`}),I(o.slice(r-s),r,t));continue}let d=/^(\s*)(>+)(\s?)/.exec(o);if(d){let e=s+d[1].length,n=e+d[2].length;t.push({start:e,end:n,style:`marker`});let r=n+d[3].length;c>r&&(t.push({start:r,end:c,style:`blockquote`}),I(o.slice(r-s),r,t));continue}let f=/^(\s*)([-*+]|\d{1,9}[.)])(\s+)/.exec(o);if(f){let e=s+f[1].length,n=e+f[2].length;t.push({start:e,end:n,style:`listMarker`});let r=n+f[3].length;I(o.slice(r-s),r,t);continue}I(o,s,t)}return t}function B(e,n){if(!e||n.length===0)return null;let r=e.length,i=new Set([0,r]);for(let e of n)e.start>0&&e.start<r&&i.add(e.start),e.end>0&&e.end<r&&i.add(e.end);let a=[...i].sort((e,t)=>e-t),o=n.map((e,t)=>({range:e,index:t})).filter(e=>e.range.end>e.range.start).sort((e,t)=>e.range.start-t.range.start),s=[],c=[],l=0;for(let n=0;n<a.length-1;n+=1){let r=a[n],i=a[n+1];if(i<=r)continue;for(;l<o.length&&o[l].range.start<=r;)c.push(o[l]),l+=1;for(let e=c.length-1;e>=0;--e)c[e].range.end<=r&&c.splice(e,1);let u=null,d=-1,f=1/0;for(let{range:e,index:t}of c){let n=e.priority??ue[e.style];(n>d||n===d&&t<f)&&(d=n,f=t,u=e)}let p=u?u.className??F[u.style]:de,m=e.slice(r,i),h=u?.visual,g=u?.skillName,_=s[s.length-1];_&&_.className===p&&t(_.visual,h)&&_.skillName===g?_.text+=m:s.push({text:m,className:p,visual:h,skillName:g})}return s.length>0?s:null}function V(e,t){let n=new Set(Array.from(t,e=>e.toLowerCase())),r=[];for(let t of[/(^|\s)\/(\u2003)?([a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?)/gi,/(^|\s)@(\u2003)?([a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?)(?=$|\s|[),.;:!?])/gi]){let i;for(;(i=t.exec(e))!==null;){let e=i[2]??``,t=i[3]||``;if(!n.has(t.toLowerCase()))continue;let a=i.index+(i[1]?.length??0);r.push({start:a,end:a+1+e.length+t.length,name:t})}}return r}function H(e,t,n){if(e===t){let t=n.find(t=>e>t.start&&e<t.end);return t?{start:t.start,end:t.end}:null}let r=n.filter(n=>n.start<t&&n.end>e);return r.length===0?null:{start:Math.min(e,...r.map(e=>e.start)),end:Math.max(t,...r.map(e=>e.end))}}function pe(e,t,n){let r=V(e,t),i=Math.max(0,Math.min(n.selectionStart,e.length)),a=Math.max(i,Math.min(n.selectionEnd,e.length)),o=i,s=a;if(i===a)if(n.altKey)if(n.key===`Backspace`){for(;o>0&&/\s/.test(e[o-1]);)--o;for(;o>0&&!/\s/.test(e[o-1]);)--o}else{for(;s<e.length&&/\s/.test(e[s]);)s+=1;for(;s<e.length&&!/\s/.test(e[s]);)s+=1}else n.key===`Backspace`?o=Math.max(0,i-1):s=Math.min(e.length,i+1);if(o===s)return null;let c=r.filter(e=>e.start<s&&e.end>o);if(c.length===0)return null;let l=Math.min(o,...c.map(e=>e.start)),u=Math.max(s,...c.map(e=>e.end));return u<e.length&&/\s/.test(e[u])&&(l===0||/\s/.test(e[l-1]))?u+=1:u===e.length&&l>0&&/\s/.test(e[l-1])&&--l,{text:`${e.slice(0,l)}${e.slice(u)}`,caret:l,removedSkillNames:c.map(e=>e.name)}}function me(e){return e.map(e=>({start:e.start,end:e.end,style:e.kind===`file`?`mentionFile`:e.kind===`session`?`mentionSession`:`mentionAgent`,visual:e.kind===`session`&&e.label?n({trigger:`@`,icon:`chat-thread`,label:e.label},i({trigger:`@`,icon:`chat-thread`,label:e.label})):void 0}))}function U(e){let t=(0,w.c)(28),{visual:n,text:i}=e,o=n.trigger.length,s=o+n.label.length,c=s+(n.suffix?.length??0),l;t[0]!==s||t[1]!==o||t[2]!==i?(l=i.slice(o,Math.min(s,i.length)),t[0]=s,t[1]=o,t[2]=i,t[3]=l):l=t[3];let u=l,d;t[4]!==s||t[5]!==c||t[6]!==i?(d=i.slice(s,Math.min(c,i.length)),t[4]=s,t[5]=c,t[6]=i,t[7]=d):d=t[7];let f=d,p;t[8]!==c||t[9]!==i?(p=i.slice(Math.min(c,i.length)),t[8]=c,t[9]=i,t[10]=p):p=t[10];let m=p,h;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(h={left:r,right:r},t[11]=h):h=t[11];let g=n.icon,_;t[12]===g?_=t[13]:(_=(0,T.jsx)(`span`,{className:`pointer-events-none absolute inset-y-0 inline-flex items-center justify-center`,style:h,children:(0,T.jsx)(b,{name:g,className:`${a} shrink-0 text-[var(--primary)]`,"aria-hidden":`true`})}),t[12]=g,t[13]=_);let v;t[14]!==_||t[15]!==n.trigger?(v=(0,T.jsxs)(`span`,{className:`relative inline-block align-baseline text-transparent leading-none`,children:[n.trigger,_]}),t[14]=_,t[15]=n.trigger,t[16]=v):v=t[16];let y;t[17]===u?y=t[18]:(y=(0,T.jsx)(`span`,{children:u}),t[17]=u,t[18]=y);let x;t[19]===f?x=t[20]:(x=f?(0,T.jsx)(`span`,{className:`text-transparent`,children:f}):null,t[19]=f,t[20]=x);let S;t[21]===m?S=t[22]:(S=m?(0,T.jsx)(`span`,{className:`text-transparent`,children:m}):null,t[21]=m,t[22]=S);let C;return t[23]!==S||t[24]!==v||t[25]!==y||t[26]!==x?(C=(0,T.jsxs)(T.Fragment,{children:[v,y,x,S]}),t[23]=S,t[24]=v,t[25]=y,t[26]=x,t[27]=C):C=t[27],C}var he=e=>({text:e.text,references:e.references.map(e=>({...e}))}),ge=e=>e.map(e=>({...e,range:{...e.range}})),W=(e,t)=>e.text===t.text&&JSON.stringify(e.references)===JSON.stringify(t.references),G=(e,t,n)=>({document:he(e),mentions:ge(t),selection:{...n}}),_e=()=>({undo:[],redo:[]}),ve=(e,t)=>({undo:[...e.undo,t].slice(-100),redo:[]}),K=(e,t)=>{let n=e.undo.at(-1);return!n||!W(n.after.document,t)?null:{history:{undo:e.undo.slice(0,-1),redo:[...e.redo,n]},snapshot:G(n.before.document,n.before.mentions,n.before.selection)}},q=(e,t)=>{let n=e.redo.at(-1);return!n||!W(n.before.document,t)?null:{history:{undo:[...e.undo,n],redo:e.redo.slice(0,-1)},snapshot:G(n.after.document,n.after.mentions,n.after.selection)}},ye=e=>{if(e.altKey||e.ctrlKey||e.metaKey)return!1;switch(e.key){case`ArrowUp`:case`PageUp`:case`Home`:return!0;default:return!1}},J=(e,t)=>{let n=t instanceof Element?t:t instanceof Node?t.parentElement:null;for(;n&&n!==e;){if(n instanceof HTMLElement&&n.scrollTop>0&&n.scrollHeight>n.clientHeight+1)return!0;n=n.parentElement}return!1},Y=e=>{let t=(0,w.c)(15),{scrollRef:n,enabled:r,onUpwardIntent:i}=e,a=r===void 0||r,o=C.useRef(null),s;t[0]===i?s=t[1]:(s=()=>{i()},t[0]=i,t[1]=s);let c=m(s),l;t[2]!==c||t[3]!==n?(l=e=>{let t=n.current;t&&(e.deltaY>=0||t instanceof HTMLElement&&(J(t,e.target)||c()))},t[2]=c,t[3]=n,t[4]=l):l=t[4];let u=m(l),d;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(d=e=>{let t=e.touches.item(0);o.current=t?t.clientY:null},t[5]=d):d=t[5];let f=m(d),p;t[6]!==c||t[7]!==n?(p=e=>{let t=n.current,r=e.touches.item(0);if(!r){o.current=null;return}let i=o.current;o.current=r.clientY,i!==null&&(r.clientY-i<=2||!t||!(t instanceof HTMLElement)||J(t,e.target)||c())},t[6]=c,t[7]=n,t[8]=p):p=t[8];let g=m(p),_;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(_=()=>{o.current=null},t[9]=_):_=t[9];let v=m(_),y;t[10]===c?y=t[11]:(y=e=>{ye(e)&&c()},t[10]=c,t[11]=y);let b=m(y),[x,S]=C.useState(null),T;t[12]===n?T=t[13]:(T=()=>{let e=n.current??null;S(t=>t===e?t:e)},t[12]=n,t[13]=T),C.useEffect(T);let E=a&&x?x:X,D;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(D={passive:!0},t[14]=D):D=t[14];let O=D;h(`wheel`,u,E,O),h(`touchstart`,f,E,O),h(`touchmove`,g,E,O),h(`touchend`,v,E,O),h(`touchcancel`,v,E,O),h(`keydown`,b,E)};function X(){}var be=e=>{if(typeof e!=`number`||!Number.isFinite(e))return;let t=Math.trunc(e);return t>=0?t:void 0},xe=e=>{if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e.summary;return!t||typeof t!=`object`||Array.isArray(t)?null:t},Z=e=>{let t=be(e);return t!==void 0&&t>0?t:void 0};function Se(e){let t=xe(e);if(!t)return null;let n=Z(t.additions),r=Z(t.deletions),i=Z(t.files)??Z(t.diffCount);return n===void 0&&r===void 0&&i===void 0?null:{...n===void 0?{}:{additions:n},...r===void 0?{}:{deletions:r},...i===void 0?{}:{files:i}}}function Ce(e){if(!e)return null;let t=[];return e.additions!==void 0&&e.additions>0&&t.push(`+${e.additions}`),e.deletions!==void 0&&e.deletions>0&&t.push(`−${e.deletions}`),t.length>0?t.join(` `):null}function we(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e,n=typeof t.providerID==`string`?t.providerID.trim():``,r=typeof t.modelID==`string`?t.modelID.trim():``;if(n&&r)return`${n}/${r}`;let i=t.model;if(typeof i==`string`&&i.trim())return i.trim();if(i&&typeof i==`object`&&!Array.isArray(i)){let e=i,t=typeof e.providerID==`string`?e.providerID.trim():typeof e.provider==`string`?e.provider.trim():``,n=typeof e.modelID==`string`?e.modelID.trim():typeof e.id==`string`?e.id.trim():``;if(t&&n)return`${t}/${n}`}return null}function Te(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e;if(typeof t.branch==`string`&&t.branch.trim())return t.branch.trim();let n=t.project;if(n&&typeof n==`object`&&!Array.isArray(n)){let e=n.branch;if(typeof e==`string`&&e.trim())return e.trim()}return null}export{te as A,N as C,ie as D,A as E,ne as O,P as S,ae as T,R as _,ye as a,pe as b,G as c,q as d,K as f,z as g,V as h,we as i,O as j,ee as k,_e as l,B as m,Te as n,J as o,U as p,Se as r,Y as s,Ce as t,ve as u,me as v,M as w,fe as x,H as y};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{nt as e}from"./vendor-base-ui-CnHfUmDN.js";import{Nt as t}from"./platform-wu6wSDfg.js";import{n}from"./vendor-react-DLPElpoQ.js";import{f as r,r as i}from"./button-CUwjpv-i.js";import{x as a}from"./MobileDetailNavigation-
|
|
1
|
+
import{nt as e}from"./vendor-base-ui-CnHfUmDN.js";import{Nt as t}from"./platform-wu6wSDfg.js";import{n}from"./vendor-react-DLPElpoQ.js";import{f as r,r as i}from"./button-CUwjpv-i.js";import{x as a}from"./MobileDetailNavigation-K0t7WpHc.js";import{Kr as o,Mr as s,kr as c}from"./useMobileNavigationStore-EUU6F5qa.js";var l=n(),u=e();function d(e){let t=(0,l.c)(10),{count:n,className:a}=e,{t:o}=r();if(!(n>0))return null;let s;t[0]===a?s=t[1]:(s=i(`inline-flex h-[18px] min-w-[18px] shrink-0 items-center justify-center rounded-full bg-[var(--status-info)] px-1.5 typography-micro font-semibold leading-none text-[var(--status-info-foreground)] tabular-nums shadow-[inset_0_0_0_1px_color-mix(in_srgb,var(--status-info-foreground)_15%,transparent)]`,a),t[0]=a,t[1]=s);let c;t[2]!==n||t[3]!==o?(c=o(`assistants.unread.label`,{count:n}),t[2]=n,t[3]=o,t[4]=c):c=t[4];let d=n>99?`99+`:n,f;return t[5]!==n||t[6]!==s||t[7]!==c||t[8]!==d?(f=(0,u.jsx)(`span`,{className:s,"aria-label":c,"data-assistant-unread-count":n,children:d}),t[5]=n,t[6]=s,t[7]=c,t[8]=d,t[9]=f):f=t[9],f}function f(e){let t=(0,l.c)(3),{className:n}=e,r=a(),i;return t[0]!==n||t[1]!==r?(i=(0,u.jsx)(d,{count:r,className:n}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}function p(e){if(!e||e.trim().length===0)return null;let t=s.getState(),n=t.activeSessions.find(t=>t.id===e)??t.archivedSessions.find(t=>t.id===e)??null;if(!n)return null;let r=c(n);return r?{sessionId:e,directory:r,session:n,fromCache:!t.hasLoaded,source:`memory`}:null}function m(e){return p(e)?.directory??null}var h=new Map;async function g(e,n){let r=e.trim();if(!r)return null;let i=p(r);if(i)return i;let a=h.get(r);if(a)return a;let s=(async()=>{let e=p(r);if(e)return e;let i=await o(r,{signal:n?.signal});if(i?.directory)return{sessionId:i.id,directory:i.directory,session:null,fromCache:!1,source:`session-index`};if(n?.trySessionGet===!1)return null;try{let e=await t.getSession(r),n=typeof e.directory==`string`&&e.directory.trim()||(typeof e.project?.worktree==`string`?e.project.worktree.trim():``)||null;return n?{sessionId:r,directory:n,session:e,fromCache:!1,source:`session-get`}:null}catch{return null}})().finally(()=>{h.get(r)===s&&h.delete(r)});return h.set(r,s),s}export{d as a,f as i,m as n,g as r,p as t};
|