@openchambery/web 1.18.2-beta.39 → 1.18.2-beta.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/dist/assets/{AgentAvatar-SFzXgOdv.js → AgentAvatar-OmE7AspO.js} +1 -1
  2. package/dist/assets/{AssistantView-CvYXAhVR.js → AssistantView-1qhaLhHt.js} +1 -1
  3. package/dist/assets/{ChatContainer-Be1DHzgc.js → ChatContainer-CEXwPvOE.js} +4 -4
  4. package/dist/assets/{DiagramView-D0COpV7w.js → DiagramView-zedL3sNZ.js} +1 -1
  5. package/dist/assets/{FadeInOnReveal-9uJN0g-H.js → FadeInOnReveal-EygBOzfu.js} +1 -1
  6. package/dist/assets/{Icon-CBdklpKH.js → Icon-C0dydAmx.js} +1 -1
  7. package/dist/assets/{MarkdownRendererImpl-DzZY5lYZ.js → MarkdownRendererImpl-CbBKHgg_.js} +1 -1
  8. package/dist/assets/{MobileDetailNavigation-DnkLVrVy.js → MobileDetailNavigation-BuGHMy3o.js} +1 -1
  9. package/dist/assets/{MobileShareBridge-C_m49-E6.js → MobileShareBridge-DwJRFCl2.js} +2 -2
  10. package/dist/assets/{MobileSurface-DPBYd_9L.js → MobileSurface-BBWgxzyI.js} +1 -1
  11. package/dist/assets/{MultiRunWindow-DPm1lQmo.js → MultiRunWindow-DJu-y4fb.js} +1 -1
  12. package/dist/assets/{OnboardingScreen-C1kAHsU9.js → OnboardingScreen-Ck8vLrCb.js} +1 -1
  13. package/dist/assets/{OverlayScrollbar-iaMCjwrs.js → OverlayScrollbar-DMQhwzR3.js} +1 -1
  14. package/dist/assets/{SettingsView-jKwiCthd.js → SettingsView-BzZTiaDd.js} +1 -1
  15. package/dist/assets/{SettingsWindow-YVW1K0vh.js → SettingsWindow-Biji-Bb4.js} +1 -1
  16. package/dist/assets/{TerminalView-CiyuM0im.js → TerminalView-BKCM76aM.js} +1 -1
  17. package/dist/assets/{ToolOutputDialog-DMHFrQtf.js → ToolOutputDialog-6lL_lCmU.js} +1 -1
  18. package/dist/assets/{appThemeRegistry-CBs9rFM0.js → appThemeRegistry-DUeCYxWD.js} +2 -2
  19. package/dist/assets/{button-DimCg1lF.js → button-Iv9uULki.js} +1 -1
  20. package/dist/assets/{clipboard-mzqrY_n2.js → clipboard-DH0BvKYH.js} +1 -1
  21. package/dist/assets/{collapsible-CF7TDu-T.js → collapsible-C46kU7ea.js} +1 -1
  22. package/dist/assets/{context-menu-ZC-7T9D6.js → context-menu-BWKM1gKq.js} +1 -1
  23. package/dist/assets/{desktopHosts-Tqz56Y0u.js → desktopHosts-DV_01iQq.js} +1 -1
  24. package/dist/assets/{desktopRelayRestore-DgHC01I5.js → desktopRelayRestore-DhQzRu4d.js} +1 -1
  25. package/dist/assets/{diagram-DObb9lfm.js → diagram-CqOdzPLy.js} +1 -1
  26. package/dist/assets/{dialog-DDrJKIhd.js → dialog-BPXCMWcj.js} +1 -1
  27. package/dist/assets/{fileQueries-BjL2dHDF.js → fileQueries-EAHC6GsF.js} +1 -1
  28. package/dist/assets/{gitApi-CdLpItUF.js → gitApi-4LIdr-v1.js} +1 -1
  29. package/dist/assets/{input-BNj7D6h_.js → input-7arjRNdx.js} +1 -1
  30. package/dist/assets/{insertionBoundaries-Dx-FimZn.js → insertionBoundaries-Dbq-aDBu.js} +1 -1
  31. package/dist/assets/{main-B2Qp731c.js → main-C-5guI2W.js} +2 -2
  32. package/dist/assets/{main-Dq04PAJw.js → main-CyVIqNNp.js} +4 -4
  33. package/dist/assets/{markdown-worker-CJ8ooXEK.js → markdown-worker-sIoCa792.js} +1 -1
  34. package/dist/assets/{markdownTheme-CziN3c9i.js → markdownTheme-QtXMKzKz.js} +1 -1
  35. package/dist/assets/{miniChat-XD8besP9.js → miniChat-DjAmMQNF.js} +2 -2
  36. package/dist/assets/mobile-B72TTAxF.js +2 -0
  37. package/dist/assets/{multirun-CgKdqjlp.js → multirun-hsF95duc.js} +1 -1
  38. package/dist/assets/{persistence-ZSrLIR97.js → persistence-Cm9DnxXq.js} +1 -1
  39. package/dist/assets/{platform-BiSk9jV3.js → platform-BrOZ1tqx.js} +1 -1
  40. package/dist/assets/{projectMeta-jWxWbDkQ.js → projectMeta-r5NAkHfX.js} +1 -1
  41. package/dist/assets/{radio-BArg8rN7.js → radio-G_YvD3ft.js} +1 -1
  42. package/dist/assets/{renderElectronMiniChatApp-CcHll5HJ.js → renderElectronMiniChatApp-YPzmrpPR.js} +2 -2
  43. package/dist/assets/{renderMobileApp-z9BLmg-1.js → renderMobileApp-CIKcbD89.js} +4 -4
  44. package/dist/assets/{runtimeConfig-o7VOqbIv.js → runtimeConfig-EBmDM9YF.js} +1 -1
  45. package/dist/assets/{runtimeEndpointReset-ZQl4KUPA.js → runtimeEndpointReset-m802uRQ1.js} +1 -1
  46. package/dist/assets/{sortable-tabs-strip-CBs61Gj9.js → sortable-tabs-strip-OO0ijdmq.js} +1 -1
  47. package/dist/assets/{terminalApi-CkknnXhV.js → terminalApi-BunCJZ0A.js} +1 -1
  48. package/dist/assets/{tooltip-BE6WDmtb.js → tooltip-CO8qCWXw.js} +1 -1
  49. package/dist/assets/{url-DQDmlZku.js → url-CM2fyKko.js} +1 -1
  50. package/dist/assets/{useAppFontEffects-BnAqVzvs.js → useAppFontEffects-BApC_Nk8.js} +2 -2
  51. package/dist/assets/{useAssistantUIStore-Bq3cPj2x.js → useAssistantUIStore-B9YvQgXU.js} +1 -1
  52. package/dist/assets/{useDesktopWindowControlsLayout-DW06JgtH.js → useDesktopWindowControlsLayout-CPOQ6w0N.js} +1 -1
  53. package/dist/assets/{useEffectiveDirectory-Cxk960zS.js → useEffectiveDirectory-Bc-cEAh0.js} +1 -1
  54. package/dist/assets/{useFontPreferences-ZvBF445N.js → useFontPreferences-DKIVD8RE.js} +1 -1
  55. package/dist/assets/{useMobileNavigationStore-7SQlIaRN.js → useMobileNavigationStore-f5hodHkc.js} +2 -2
  56. package/dist/assets/{useSessionAutoCleanup-fCB4vS1c.js → useSessionAutoCleanup-EKU0ZYhf.js} +1 -1
  57. package/dist/assets/{useUIStore-5agS8bsW.js → useUIStore-CL06MzOk.js} +1 -1
  58. package/dist/assets/{useWorkerHighlightedLines-Dur8-7lm.js → useWorkerHighlightedLines-DBz6RbGf.js} +1 -1
  59. package/dist/assets/{utils-Dh7UZFrA.js → utils-DlvuQ5yV.js} +1 -1
  60. package/dist/index.html +8 -8
  61. package/dist/mini-chat.html +8 -8
  62. package/dist/mobile.html +8 -8
  63. package/package.json +1 -1
  64. package/dist/assets/mobile-B-urUzQ2.js +0 -2
@@ -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,I as r,K as i,N as a,O as o,P as s,U as c,W as l}from"./useUIStore-5agS8bsW.js";import{On as u,et as d,kn as f}from"./persistence-ZSrLIR97.js";import{t as ee}from"./desktopRelayRestore-DgHC01I5.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 m,et as h,f as g,ft as _,g as v,gt as y,h as b,ht as x,i as Ne,j as Pe,k as Fe,l as Ie,lt as Le,m as Re,mt as ze,n as S,nt as Be,o as Ve,ot as He,p as Ue,pt as We,q as Ge,s as Ke,st as qe,t as Je,tt as Ye,u as Xe,ut as Ze,v as C,vt as Qe,x as w,y as $e,yt as T}from"./platform-BiSk9jV3.js";import{n as E,o as D}from"./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js";import{a as et,c as tt,l as nt,n as rt,r as it,s as at,t as ot}from"./terminalApi-CkknnXhV.js";import{t as O}from"./types-BuiqMmh_.js";import{n as k,t as A}from"./capgoAdapter-BSPH5_gX.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 st=e=>{let t=e?.retry;return{maxRetries:t?.maxRetries??3,initialRetryDelay:t?.initialDelayMs??1e3,maxRetryDelay:t?.maxDelayMs??8e3,connectionTimeout:e?.connectionTimeoutMs??1e4}},ct=()=>({async createSession(e){return it(e)},connect(e,t,n){let r=rt(e,t.onEvent,t.onError,st(n));return{close:()=>r()}},async sendInput(e,t){await nt(e,t)},async resize(e){await at(e.sessionId,e.cols,e.rows)},async close(e){await ot(e)},async restartSession(e,t){return tt(e,{cwd:t.cwd??``,cols:t.cols,rows:t.rows})},async forceKill(e){await et(e)}}),lt=()=>({checkIsGitRepository:Ae,getGitStatus:de,getGitDiff:pe,getGitFileDiff:me,revertGitFile:He,stageGitFile:Le,stageGitFiles:Ze,unstageGitFile:x,unstageGitFiles:y,stageGitHunk:m,unstageGitHunk:Te,revertGitHunk:qe,isLinkedWorktree:Ge,getGitBranches:fe,deleteGitBranch:$e,deleteRemoteBranch:_e,removeRemote:h,generateCommitMessage:oe,generatePullRequestDescription:ae,listGitWorktrees:p,validateGitWorktree:T,createGitWorktree:C,deleteGitWorktree:w,validateWorktreeDirectory:ke,canonicalizeWorktreeState:Ke,createGitCommit(e,t,n){return v(e,t,n)},gitPush:ye,gitPull:ce,gitFetch:be,listGitStashes:ue,countGitStashFiles:Re,stashGitChanges:We,applyGitStash:Ve,popGitStash:Ce,dropGitStash:ve,checkoutBranch:Ie,createBranch:b,renameBranch:Ye,getGitLog(e,t){return le(e,t)},getCommitFiles:Fe,getCurrentGitIdentity:Pe,hasLocalIdentity:xe,setGitIdentity:je,getGitIdentities:se,createGitIdentity:we,updateGitIdentity:Qe,deleteGitIdentity:Oe,getRemotes:re,rebase:te,abortRebase:Ee,continueRebase:Ue,merge:Se,abortMerge:Ne,continueMerge:g,checkoutCommit:Xe,cherryPick:Me,revertCommit:De,resetToCommit:Be,stash:_,stashPop:ze,getConflictDetails:ne,worktree:{list:p,validate:T,bootstrapStatus:ge,preview:he,create:C,remove:w}}),j=e=>e.replace(/\\/g,`/`),ut=(e,t)=>({directory:j(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:j(e.path),isDirectory:!!e.isDirectory}))}),M=(e,t)=>{let n=t||e?.();return n?{"x-opencode-directory":n}:void 0},dt=({getDirectory:e})=>({async listDirectory(t,n){let r=j(t),i=new URLSearchParams;r&&i.set(`path`,r),n?.respectGitignore&&i.set(`respectGitignore`,`true`);let a=await f(`/api/fs/list`,{query:i,headers:M(e)});if(!a.ok){let e=await a.json().catch(()=>({error:a.statusText}));throw Error(e.error||`Failed to list directory`)}return ut(r,await a.json())},async search(t){let n=new URLSearchParams,r=j(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 f(`/api/find/file`,{query:n,headers:M(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:j(`${r}/${e}`),preview:[j(e)]}))},async createDirectory(t){let n=j(t),r=await f(`/api/fs/mkdir`,{method:`POST`,headers:{"Content-Type":`application/json`,...M(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`?j(i.path):n}},async statFile(t,n){let r=j(t),i=new URLSearchParams({path:r});n?.allowOutsideWorkspace&&i.set(`allowOutsideWorkspace`,`true`),n?.outsideFileGrant&&i.set(`outsideFileGrant`,n.outsideFileGrant);let a=await f(`/api/fs/stat`,{query:i,headers:M(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`?j(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=j(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 f(`/api/fs/read`,{query:i,cache:n?.optional?`no-store`:`default`,headers:M(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=j(t),i=await f(`/api/fs/write`,{method:`POST`,headers:{"Content-Type":`application/json`,...M(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`?j(a.path):r}},async delete(t){let n=j(t),r=await f(`/api/fs/delete`,{method:`POST`,headers:{"Content-Type":`application/json`,...M(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 f(`/api/fs/rename`,{method:`POST`,headers:{"Content-Type":`application/json`,...M(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`?j(i.path):n}},async revealPath(t){let n=await f(`/api/fs/reveal`,{method:`POST`,headers:{"Content-Type":`application/json`,...M(e)},body:JSON.stringify({path:j(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=j(t),r=await f(`/api/fs/raw`,{query:{path:n,download:!0},headers:M(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)}}),N=`/api/config/settings`,ft=`/api/config/reload`,P=e=>!e||typeof e!=`object`?{}:e,pt=()=>({async load(){let e=await f(N,{method:`GET`,headers:{Accept:`application/json`}});if(!e.ok)throw Error(`Failed to load settings: ${e.statusText}`);return{settings:P(await e.json().catch(()=>({}))),source:`web`}},async save(e){let t=await f(N,{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 P(await t.json().catch(()=>({})))},async restartOpenCode(){let e=await f(ft,{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}}}),mt=()=>({async requestDirectoryAccess(e){return{success:!0,path:e.path}},async startAccessingDirectory(e){return{success:!0}},async stopAccessingDirectory(e){return{success:!0}}}),ht=1500,F=5e3,gt=`openchamber-notification-claim:`,I=new Map,_t=()=>typeof document>`u`||document.visibilityState===`visible`&&document.hasFocus(),vt=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(`|`),yt=e=>{for(let[t,n]of I)e-n>F&&I.delete(t)},bt=e=>{let t=vt(e);if(!t)return!0;let n=Date.now();if(yt(n),n-(I.get(t)??0)<F)return!1;try{if(typeof window<`u`&&window.localStorage){let e=`${gt}${t}`,r=Number(window.localStorage.getItem(e)??`0`);if(Number.isFinite(r)&&n-r<F)return I.set(t,r),!1;Number.isFinite(r)&&r>0&&window.localStorage.removeItem(e),window.localStorage.setItem(e,String(n))}}catch{}return I.set(t,n),!0},L=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),ht)})])??e}catch{return e}},xt=async e=>{let t=await L();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}},St=async()=>{let e=await L();if(!e||!(`pushManager`in e)||!e.pushManager)return!1;try{return!!await e.pushManager.getSubscription()}catch{return!1}},Ct=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(!_t()&&await St()||!bt(e))return!0;try{return await xt(e)||new Notification(e?.title??`OpenChamber`,{body:e?.body,tag:e?.tag}),!0}catch(e){return console.warn(`Failed to send notification`,e),!1}},wt=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}},Tt=()=>({async notifyAgentCompletion(e){return await wt(e)||await Ct(e)},canNotify:()=>typeof window<`u`&&window.__OPENCHAMBER_DESKTOP__?.invoke?!0:typeof Notification<`u`&&Notification.permission===`granted`}),Et=()=>({async getAvailableTools(){let e=await f(`/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()}}),R=async(e,t)=>{try{let n=await f(e,{...t,credentials:`include`,headers:{Accept:`application/json`,...t?.headers??{}}});return n.ok?await n.json():null}catch{return null}},Dt=()=>({async getVapidPublicKey(){return R(`/api/push/vapid-public-key`)},async subscribe(e){return R(`/api/push/subscribe`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})},async unsubscribe(e){return R(`/api/push/subscribe`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})},async setVisibility(e){return R(`/api/push/visibility`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e),keepalive:!0})},async registerApnsToken(e){return R(`/api/push/apns-token`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})},async unregisterApnsToken(e){return R(`/api/push/apns-token`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})}}),z=async e=>await e.json().catch(()=>null),Ot=({urls:e})=>({async authStatus(){let e=await f(`/api/github/auth/status`,{method:`GET`,headers:{Accept:`application/json`}}),t=await z(e);if(!e.ok||!t)throw Error(t?.error||e.statusText||`Failed to load GitHub status`);return t},async authStart(){let e=await f(`/api/github/auth/start`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({})}),t=await z(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 f(`/api/github/auth/complete`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({deviceCode:e})}),n=await z(t);if(!t.ok||!n)throw Error(n?.error||t.statusText||`Failed to complete GitHub auth`);return n},async authDisconnect(){let e=await f(`/api/github/auth`,{method:`DELETE`,headers:{Accept:`application/json`}}),t=await z(e);if(!e.ok)throw Error(t?.error||e.statusText||`Failed to disconnect GitHub`);return{removed:!!t?.removed}},async authActivate(e){let t=await f(`/api/github/auth/activate`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({accountId:e})}),n=await z(t);if(!t.ok||!n)throw Error(n?.error||t.statusText||`Failed to activate GitHub account`);return n},async authSetGhCliDisabled(e){let t=await f(`/api/github/auth/gh-cli`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({disabled:e})}),n=await z(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 f(`/api/github/me`,{method:`GET`,headers:{Accept:`application/json`}}),t=await z(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 f(`/api/github/pr/status?${i.toString()}`,{method:`GET`,headers:{Accept:`application/json`}}),o=await z(a);if(!a.ok||!o)throw Error(o?.error||a.statusText||`Failed to load PR status`);return o},async prCreate(e){let t=await f(`/api/github/pr/create`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(e)}),n=await z(t);if(!t.ok||!n)throw Error(n?.error||t.statusText||`Failed to create PR`);return n},async prUpdate(e){let t=await f(`/api/github/pr/update`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(e)}),n=await z(t);if(!t.ok||!n)throw Error(n?.error||t.statusText||`Failed to update PR`);return n},async prMerge(e){let t=await f(`/api/github/pr/merge`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(e)}),n=await z(t);if(!t.ok||!n)throw Error(n?.error||t.statusText||`Failed to merge PR`);return n},async prReady(e){let t=await f(`/api/github/pr/ready`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(e)}),n=await z(t);if(!t.ok||!n)throw Error(n?.error||t.statusText||`Failed to mark PR ready`);return n},async repoUpstream(e){let t=await f(`/api/github/repo/upstream?directory=${encodeURIComponent(e)}`,{method:`GET`,headers:{Accept:`application/json`}}),n=await z(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 f(`/api/github/repo/branches?owner=${encodeURIComponent(e)}&repo=${encodeURIComponent(t)}`,{method:`GET`,headers:{Accept:`application/json`}}),r=await z(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 f(`/api/github/pulls/list?${r.toString()}`,{method:`GET`,headers:{Accept:`application/json`}}),a=await z(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 f(e.api(`/api/github/pulls/context`,i),{method:`GET`,headers:{Accept:`application/json`}}),o=await z(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 f(`/api/github/issues/list?${r.toString()}`,{method:`GET`,headers:{Accept:`application/json`}}),a=await z(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 f(e.api(`/api/github/issues/get`,i),{method:`GET`,headers:{Accept:`application/json`}}),o=await z(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 f(e.api(`/api/github/issues/comments`,i),{method:`GET`,headers:{Accept:`application/json`}}),o=await z(a);if(!a.ok||!o)throw Error(o?.error||a.statusText||`Failed to load issue comments`);return o}}),B=async e=>await e.json().catch(()=>null),kt=()=>({async listClients(){let e=await f(`/api/client-auth/clients`,{method:`GET`,headers:{Accept:`application/json`}}),t=await B(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 f(`/api/client-auth/clients`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({label:e.label??``})}),n=await B(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 f(`/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}:{},...e.sshHostId?{sshHostId:e.sshHostId}:{}})}),n=await B(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 f(`/api/client-auth/pairing/sessions`,{method:`GET`,headers:{Accept:`application/json`}}),t=await B(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 f(`/api/client-auth/pairing/transports`,{method:`GET`,headers:{Accept:`application/json`}}),t=await B(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 f(`/api/client-auth/pairing/sessions/${encodeURIComponent(e)}`,{method:`DELETE`,headers:{Accept:`application/json`}}),n=await B(t);if(!t.ok||!n)throw Error(n?.error||t.statusText||`Failed to cancel pairing`);return{cancelled:n.cancelled===!0}},async revokeClient(e){let t=await f(`/api/client-auth/clients/${encodeURIComponent(e)}`,{method:`DELETE`,headers:{Accept:`application/json`}}),n=await B(t);if(!t.ok||!n)throw Error(n?.error||t.statusText||`Failed to revoke remote client`);return n},async purgeRevokedClients(){let e=await f(`/api/client-auth/clients`,{method:`DELETE`,headers:{Accept:`application/json`}}),t=await B(e);if(!e.ok||!t)throw Error(t?.error||e.statusText||`Failed to clear revoked clients`);return t}}),V=e=>typeof e==`object`&&!!e&&!Array.isArray(e),H=e=>typeof e==`number`&&Number.isFinite(e),At=e=>{if(!V(e)||typeof e.ok!=`boolean`)return!1;if(e.ok===!0)return V(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&&!H(e.status));case`prompt`:return V(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||H(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}},jt=()=>({async createWithPrompt(e,t){let n;try{n=await f(`/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(!At(r))throw Error(`Unexpected server response: result shape mismatch`);return r}}),Mt=`https://openchamber.xiaobe.top/v1/mobile/update/check`,Nt=`https://openchamber-update.vercel.app/v1/mobile/update/check`,Pt=1e4,U=`openchamber.mobile-ota.device-id.v1`,W=e=>typeof e==`string`&&e.trim().length>0?e.trim():null,G=()=>{try{let e=E;return((typeof e.getConfig==`function`?e.getConfig():void 0)??e.config)?.OpenChamberOTA??{}}catch{return{}}},Ft=()=>G().channel===`stable`?`stable`:`beta`,It=()=>{let e=G().shellApiVersion;return typeof e==`number`&&Number.isFinite(e)&&e>0?Math.floor(e):1},Lt=()=>{let e=Je();if(e===`ios`||e===`android`)return e;try{let e=E.getPlatform();if(e===`ios`||e===`android`)return e}catch{}return`android`},Rt=()=>{if(typeof window>`u`)return null;try{return W(window.localStorage.getItem(U))}catch{return null}},K=e=>{if(!(typeof window>`u`))try{window.localStorage.setItem(U,e)}catch{}},zt=async e=>{if(e)try{let t=W((await e.getDeviceId()).deviceId);if(t)return K(t),t}catch{}let t=Rt();if(t)return t;let n=d();return K(n),n},Bt=async()=>{let e=W(`1.18.2-beta.39`);if(S())try{let{App:t}=await D(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=W(n.version)??e??`0.0.0`,i=W(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}},q=(e,t)=>{let n=W(e);return n&&n!==`builtin`?n:W(t)??`builtin`},Vt=()=>W(`1.18.2-beta.39`),Ht=async e=>{let t=Vt();if(!e)return q(null,t);try{return q((await e.current()).bundle?.id,t)}catch{return q(null,t)}},Ut=()=>[Mt,Nt],Wt=(e,t,n)=>{let r=e-n();return r<=0||t<=0?null:Math.max(1,Math.ceil(r/t))};async function Gt(e,t,n,r){try{if(S())try{let{CapacitorHttp:r}=await D(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 J=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))};async function Kt(e,t,n,r){let i=await Gt(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}return J(a)?a:null}async function qt(e={}){let t=e.updater===void 0?await A():e.updater;if(!t&&!S())throw new O;let n=e.fetchImpl??fetch,r=e.now??Date.now,[i,a,o]=await Promise.all([zt(t),Bt(),Ht(t)]),s={channel:Ft(),platform:Lt(),deviceId:i,nativeVersion:a.version,nativeBuild:a.build,shellApiVersion:It(),currentBundleId:o},c=Ut(),l=r()+Pt,u=null;for(let[e,t]of c.entries()){let i=Wt(l,c.length-e,r);if(i===null)break;try{let e=await Kt(t,s,i,n);if(e)return e;u=Error(`Mobile OTA check failed at ${t}`)}catch(e){u=e instanceof Error?e:Error(`Mobile OTA check failed`)}}throw u??Error(`Unable to check for mobile OTA updates`)}async function Jt(e){let t=await A();if(!t)throw new O;return(await t.download({url:e.url,version:e.releaseVersion,checksum:e.checksum,...e.sessionKey?{sessionKey:e.sessionKey}:{}})).id}async function Yt(){let e=await A();if(!e)throw new O;await e.reload()}async function Xt(e){let t=await A();if(!t)throw new O;await t.next({id:e})}var Y=null,X=e=>typeof e==`string`&&e.trim().length>0?e.trim():null,Z=async()=>{let e=X(`1.18.2-beta.39`);try{if(E.isNativePlatform()){let{App:t}=await D(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`},Zt=()=>({async checkForOtaUpdate(){if(!k()&&!E.isNativePlatform())throw new O;return qt()},async downloadOtaUpdate(e){if(!k())throw new O;Y=await Jt(e)},async applyOtaUpdateNow(){if(!k())throw new O;await Yt()},async queueOtaUpdateForNextLaunch(){if(!k())throw new O;let e=Y;if(!e)throw Error(`No downloaded OTA bundle to queue`);await Xt(e)},async getOtaStatus(){if(!k())return{supported:!1,currentBundleId:`builtin`,nativeVersion:await Z()};let e=await A();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()}}}}),Qt=()=>({api:(...t)=>e().api(...t),authenticatedAsset:(...t)=>e().authenticatedAsset(...t),auth:(...t)=>e().auth(...t),health:(...t)=>e().health(...t),rawFile:(...t)=>e().rawFile(...t),sse:(...t)=>e().sse(...t),websocket:(...t)=>e().websocket(...t)}),$t=(e={})=>{let t=e.urls??s();r(t);let n=Qt();return{runtime:{platform:`web`,isDesktop:!1,isVSCode:!1,label:`web`},terminal:ct(),git:lt(),files:dt({urls:n,getDirectory:()=>ie.getState().currentDirectory}),settings:pt(),permissions:mt(),notifications:Tt(),github:Ot({urls:n}),push:Dt(),mobileUpdates:Zt(),clientAuth:kt(),tools:Et(),conversations:jt()}},Q=(e,t)=>{if(!e||!t)return!1;try{return new URL(e).origin===new URL(t).origin}catch{return!1}},$=Promise.resolve(),en=()=>$,tn=()=>{let e=typeof window.__OPENCHAMBER_API_BASE_URL__==`string`?window.__OPENCHAMBER_API_BASE_URL__.trim():``,r=typeof window.__OPENCHAMBER_CLIENT_TOKEN__==`string`?window.__OPENCHAMBER_CLIENT_TOKEN__.trim():``,s=typeof window.__OPENCHAMBER_LOCAL_ORIGIN__==`string`?window.__OPENCHAMBER_LOCAL_ORIGIN__.trim():``,d=a({apiBaseUrl:e||void 0,realtimeBaseUrl:e||void 0});o({apiBaseUrl:e,runtimeKey:Q(e,s)?`local`:null}),t(r||null),i(window.__OPENCHAMBER_RUNTIME_HEADERS__||null),l(e||void 0).catch(()=>{}),s&&!Q(e,s)&&Object.keys(n()).length>0&&c(s).catch(()=>{}),u();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)})]),$t({urls:d})};export{en as n,tn as t};
2
+ import{F as e,G as t,H as n,I as r,K as i,N as a,O as o,P as s,U as c,W as l}from"./useUIStore-CL06MzOk.js";import{On as u,et as d,kn as f}from"./persistence-Cm9DnxXq.js";import{t as ee}from"./desktopRelayRestore-DhQzRu4d.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 m,et as h,f as g,ft as _,g as v,gt as y,h as b,ht as x,i as Ne,j as Pe,k as Fe,l as Ie,lt as Le,m as Re,mt as ze,n as S,nt as Be,o as Ve,ot as He,p as Ue,pt as We,q as Ge,s as Ke,st as qe,t as Je,tt as Ye,u as Xe,ut as Ze,v as C,vt as Qe,x as w,y as $e,yt as T}from"./platform-BrOZ1tqx.js";import{n as E,o as D}from"./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js";import{a as et,c as tt,l as nt,n as rt,r as it,s as at,t as ot}from"./terminalApi-BunCJZ0A.js";import{t as O}from"./types-BuiqMmh_.js";import{n as k,t as A}from"./capgoAdapter-BSPH5_gX.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 st=e=>{let t=e?.retry;return{maxRetries:t?.maxRetries??3,initialRetryDelay:t?.initialDelayMs??1e3,maxRetryDelay:t?.maxDelayMs??8e3,connectionTimeout:e?.connectionTimeoutMs??1e4}},ct=()=>({async createSession(e){return it(e)},connect(e,t,n){let r=rt(e,t.onEvent,t.onError,st(n));return{close:()=>r()}},async sendInput(e,t){await nt(e,t)},async resize(e){await at(e.sessionId,e.cols,e.rows)},async close(e){await ot(e)},async restartSession(e,t){return tt(e,{cwd:t.cwd??``,cols:t.cols,rows:t.rows})},async forceKill(e){await et(e)}}),lt=()=>({checkIsGitRepository:Ae,getGitStatus:de,getGitDiff:pe,getGitFileDiff:me,revertGitFile:He,stageGitFile:Le,stageGitFiles:Ze,unstageGitFile:x,unstageGitFiles:y,stageGitHunk:m,unstageGitHunk:Te,revertGitHunk:qe,isLinkedWorktree:Ge,getGitBranches:fe,deleteGitBranch:$e,deleteRemoteBranch:_e,removeRemote:h,generateCommitMessage:oe,generatePullRequestDescription:ae,listGitWorktrees:p,validateGitWorktree:T,createGitWorktree:C,deleteGitWorktree:w,validateWorktreeDirectory:ke,canonicalizeWorktreeState:Ke,createGitCommit(e,t,n){return v(e,t,n)},gitPush:ye,gitPull:ce,gitFetch:be,listGitStashes:ue,countGitStashFiles:Re,stashGitChanges:We,applyGitStash:Ve,popGitStash:Ce,dropGitStash:ve,checkoutBranch:Ie,createBranch:b,renameBranch:Ye,getGitLog(e,t){return le(e,t)},getCommitFiles:Fe,getCurrentGitIdentity:Pe,hasLocalIdentity:xe,setGitIdentity:je,getGitIdentities:se,createGitIdentity:we,updateGitIdentity:Qe,deleteGitIdentity:Oe,getRemotes:re,rebase:te,abortRebase:Ee,continueRebase:Ue,merge:Se,abortMerge:Ne,continueMerge:g,checkoutCommit:Xe,cherryPick:Me,revertCommit:De,resetToCommit:Be,stash:_,stashPop:ze,getConflictDetails:ne,worktree:{list:p,validate:T,bootstrapStatus:ge,preview:he,create:C,remove:w}}),j=e=>e.replace(/\\/g,`/`),ut=(e,t)=>({directory:j(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:j(e.path),isDirectory:!!e.isDirectory}))}),M=(e,t)=>{let n=t||e?.();return n?{"x-opencode-directory":n}:void 0},dt=({getDirectory:e})=>({async listDirectory(t,n){let r=j(t),i=new URLSearchParams;r&&i.set(`path`,r),n?.respectGitignore&&i.set(`respectGitignore`,`true`);let a=await f(`/api/fs/list`,{query:i,headers:M(e)});if(!a.ok){let e=await a.json().catch(()=>({error:a.statusText}));throw Error(e.error||`Failed to list directory`)}return ut(r,await a.json())},async search(t){let n=new URLSearchParams,r=j(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 f(`/api/find/file`,{query:n,headers:M(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:j(`${r}/${e}`),preview:[j(e)]}))},async createDirectory(t){let n=j(t),r=await f(`/api/fs/mkdir`,{method:`POST`,headers:{"Content-Type":`application/json`,...M(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`?j(i.path):n}},async statFile(t,n){let r=j(t),i=new URLSearchParams({path:r});n?.allowOutsideWorkspace&&i.set(`allowOutsideWorkspace`,`true`),n?.outsideFileGrant&&i.set(`outsideFileGrant`,n.outsideFileGrant);let a=await f(`/api/fs/stat`,{query:i,headers:M(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`?j(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=j(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 f(`/api/fs/read`,{query:i,cache:n?.optional?`no-store`:`default`,headers:M(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=j(t),i=await f(`/api/fs/write`,{method:`POST`,headers:{"Content-Type":`application/json`,...M(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`?j(a.path):r}},async delete(t){let n=j(t),r=await f(`/api/fs/delete`,{method:`POST`,headers:{"Content-Type":`application/json`,...M(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 f(`/api/fs/rename`,{method:`POST`,headers:{"Content-Type":`application/json`,...M(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`?j(i.path):n}},async revealPath(t){let n=await f(`/api/fs/reveal`,{method:`POST`,headers:{"Content-Type":`application/json`,...M(e)},body:JSON.stringify({path:j(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=j(t),r=await f(`/api/fs/raw`,{query:{path:n,download:!0},headers:M(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)}}),N=`/api/config/settings`,ft=`/api/config/reload`,P=e=>!e||typeof e!=`object`?{}:e,pt=()=>({async load(){let e=await f(N,{method:`GET`,headers:{Accept:`application/json`}});if(!e.ok)throw Error(`Failed to load settings: ${e.statusText}`);return{settings:P(await e.json().catch(()=>({}))),source:`web`}},async save(e){let t=await f(N,{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 P(await t.json().catch(()=>({})))},async restartOpenCode(){let e=await f(ft,{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}}}),mt=()=>({async requestDirectoryAccess(e){return{success:!0,path:e.path}},async startAccessingDirectory(e){return{success:!0}},async stopAccessingDirectory(e){return{success:!0}}}),ht=1500,F=5e3,gt=`openchamber-notification-claim:`,I=new Map,_t=()=>typeof document>`u`||document.visibilityState===`visible`&&document.hasFocus(),vt=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(`|`),yt=e=>{for(let[t,n]of I)e-n>F&&I.delete(t)},bt=e=>{let t=vt(e);if(!t)return!0;let n=Date.now();if(yt(n),n-(I.get(t)??0)<F)return!1;try{if(typeof window<`u`&&window.localStorage){let e=`${gt}${t}`,r=Number(window.localStorage.getItem(e)??`0`);if(Number.isFinite(r)&&n-r<F)return I.set(t,r),!1;Number.isFinite(r)&&r>0&&window.localStorage.removeItem(e),window.localStorage.setItem(e,String(n))}}catch{}return I.set(t,n),!0},L=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),ht)})])??e}catch{return e}},xt=async e=>{let t=await L();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}},St=async()=>{let e=await L();if(!e||!(`pushManager`in e)||!e.pushManager)return!1;try{return!!await e.pushManager.getSubscription()}catch{return!1}},Ct=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(!_t()&&await St()||!bt(e))return!0;try{return await xt(e)||new Notification(e?.title??`OpenChamber`,{body:e?.body,tag:e?.tag}),!0}catch(e){return console.warn(`Failed to send notification`,e),!1}},wt=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}},Tt=()=>({async notifyAgentCompletion(e){return await wt(e)||await Ct(e)},canNotify:()=>typeof window<`u`&&window.__OPENCHAMBER_DESKTOP__?.invoke?!0:typeof Notification<`u`&&Notification.permission===`granted`}),Et=()=>({async getAvailableTools(){let e=await f(`/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()}}),R=async(e,t)=>{try{let n=await f(e,{...t,credentials:`include`,headers:{Accept:`application/json`,...t?.headers??{}}});return n.ok?await n.json():null}catch{return null}},Dt=()=>({async getVapidPublicKey(){return R(`/api/push/vapid-public-key`)},async subscribe(e){return R(`/api/push/subscribe`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})},async unsubscribe(e){return R(`/api/push/subscribe`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})},async setVisibility(e){return R(`/api/push/visibility`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e),keepalive:!0})},async registerApnsToken(e){return R(`/api/push/apns-token`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})},async unregisterApnsToken(e){return R(`/api/push/apns-token`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})}}),z=async e=>await e.json().catch(()=>null),Ot=({urls:e})=>({async authStatus(){let e=await f(`/api/github/auth/status`,{method:`GET`,headers:{Accept:`application/json`}}),t=await z(e);if(!e.ok||!t)throw Error(t?.error||e.statusText||`Failed to load GitHub status`);return t},async authStart(){let e=await f(`/api/github/auth/start`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({})}),t=await z(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 f(`/api/github/auth/complete`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({deviceCode:e})}),n=await z(t);if(!t.ok||!n)throw Error(n?.error||t.statusText||`Failed to complete GitHub auth`);return n},async authDisconnect(){let e=await f(`/api/github/auth`,{method:`DELETE`,headers:{Accept:`application/json`}}),t=await z(e);if(!e.ok)throw Error(t?.error||e.statusText||`Failed to disconnect GitHub`);return{removed:!!t?.removed}},async authActivate(e){let t=await f(`/api/github/auth/activate`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({accountId:e})}),n=await z(t);if(!t.ok||!n)throw Error(n?.error||t.statusText||`Failed to activate GitHub account`);return n},async authSetGhCliDisabled(e){let t=await f(`/api/github/auth/gh-cli`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({disabled:e})}),n=await z(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 f(`/api/github/me`,{method:`GET`,headers:{Accept:`application/json`}}),t=await z(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 f(`/api/github/pr/status?${i.toString()}`,{method:`GET`,headers:{Accept:`application/json`}}),o=await z(a);if(!a.ok||!o)throw Error(o?.error||a.statusText||`Failed to load PR status`);return o},async prCreate(e){let t=await f(`/api/github/pr/create`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(e)}),n=await z(t);if(!t.ok||!n)throw Error(n?.error||t.statusText||`Failed to create PR`);return n},async prUpdate(e){let t=await f(`/api/github/pr/update`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(e)}),n=await z(t);if(!t.ok||!n)throw Error(n?.error||t.statusText||`Failed to update PR`);return n},async prMerge(e){let t=await f(`/api/github/pr/merge`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(e)}),n=await z(t);if(!t.ok||!n)throw Error(n?.error||t.statusText||`Failed to merge PR`);return n},async prReady(e){let t=await f(`/api/github/pr/ready`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(e)}),n=await z(t);if(!t.ok||!n)throw Error(n?.error||t.statusText||`Failed to mark PR ready`);return n},async repoUpstream(e){let t=await f(`/api/github/repo/upstream?directory=${encodeURIComponent(e)}`,{method:`GET`,headers:{Accept:`application/json`}}),n=await z(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 f(`/api/github/repo/branches?owner=${encodeURIComponent(e)}&repo=${encodeURIComponent(t)}`,{method:`GET`,headers:{Accept:`application/json`}}),r=await z(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 f(`/api/github/pulls/list?${r.toString()}`,{method:`GET`,headers:{Accept:`application/json`}}),a=await z(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 f(e.api(`/api/github/pulls/context`,i),{method:`GET`,headers:{Accept:`application/json`}}),o=await z(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 f(`/api/github/issues/list?${r.toString()}`,{method:`GET`,headers:{Accept:`application/json`}}),a=await z(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 f(e.api(`/api/github/issues/get`,i),{method:`GET`,headers:{Accept:`application/json`}}),o=await z(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 f(e.api(`/api/github/issues/comments`,i),{method:`GET`,headers:{Accept:`application/json`}}),o=await z(a);if(!a.ok||!o)throw Error(o?.error||a.statusText||`Failed to load issue comments`);return o}}),B=async e=>await e.json().catch(()=>null),kt=()=>({async listClients(){let e=await f(`/api/client-auth/clients`,{method:`GET`,headers:{Accept:`application/json`}}),t=await B(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 f(`/api/client-auth/clients`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({label:e.label??``})}),n=await B(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 f(`/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}:{},...e.sshHostId?{sshHostId:e.sshHostId}:{}})}),n=await B(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 f(`/api/client-auth/pairing/sessions`,{method:`GET`,headers:{Accept:`application/json`}}),t=await B(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 f(`/api/client-auth/pairing/transports`,{method:`GET`,headers:{Accept:`application/json`}}),t=await B(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 f(`/api/client-auth/pairing/sessions/${encodeURIComponent(e)}`,{method:`DELETE`,headers:{Accept:`application/json`}}),n=await B(t);if(!t.ok||!n)throw Error(n?.error||t.statusText||`Failed to cancel pairing`);return{cancelled:n.cancelled===!0}},async revokeClient(e){let t=await f(`/api/client-auth/clients/${encodeURIComponent(e)}`,{method:`DELETE`,headers:{Accept:`application/json`}}),n=await B(t);if(!t.ok||!n)throw Error(n?.error||t.statusText||`Failed to revoke remote client`);return n},async purgeRevokedClients(){let e=await f(`/api/client-auth/clients`,{method:`DELETE`,headers:{Accept:`application/json`}}),t=await B(e);if(!e.ok||!t)throw Error(t?.error||e.statusText||`Failed to clear revoked clients`);return t}}),V=e=>typeof e==`object`&&!!e&&!Array.isArray(e),H=e=>typeof e==`number`&&Number.isFinite(e),At=e=>{if(!V(e)||typeof e.ok!=`boolean`)return!1;if(e.ok===!0)return V(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&&!H(e.status));case`prompt`:return V(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||H(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}},jt=()=>({async createWithPrompt(e,t){let n;try{n=await f(`/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(!At(r))throw Error(`Unexpected server response: result shape mismatch`);return r}}),Mt=`https://openchamber.xiaobe.top/v1/mobile/update/check`,Nt=`https://openchamber-update.vercel.app/v1/mobile/update/check`,Pt=1e4,U=`openchamber.mobile-ota.device-id.v1`,W=e=>typeof e==`string`&&e.trim().length>0?e.trim():null,G=()=>{try{let e=E;return((typeof e.getConfig==`function`?e.getConfig():void 0)??e.config)?.OpenChamberOTA??{}}catch{return{}}},Ft=()=>G().channel===`stable`?`stable`:`beta`,It=()=>{let e=G().shellApiVersion;return typeof e==`number`&&Number.isFinite(e)&&e>0?Math.floor(e):1},Lt=()=>{let e=Je();if(e===`ios`||e===`android`)return e;try{let e=E.getPlatform();if(e===`ios`||e===`android`)return e}catch{}return`android`},Rt=()=>{if(typeof window>`u`)return null;try{return W(window.localStorage.getItem(U))}catch{return null}},K=e=>{if(!(typeof window>`u`))try{window.localStorage.setItem(U,e)}catch{}},zt=async e=>{if(e)try{let t=W((await e.getDeviceId()).deviceId);if(t)return K(t),t}catch{}let t=Rt();if(t)return t;let n=d();return K(n),n},Bt=async()=>{let e=W(`1.18.2-beta.40`);if(S())try{let{App:t}=await D(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=W(n.version)??e??`0.0.0`,i=W(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}},q=(e,t)=>{let n=W(e);return n&&n!==`builtin`?n:W(t)??`builtin`},Vt=()=>W(`1.18.2-beta.40`),Ht=async e=>{let t=Vt();if(!e)return q(null,t);try{return q((await e.current()).bundle?.id,t)}catch{return q(null,t)}},Ut=()=>[Mt,Nt],Wt=(e,t,n)=>{let r=e-n();return r<=0||t<=0?null:Math.max(1,Math.ceil(r/t))};async function Gt(e,t,n,r){try{if(S())try{let{CapacitorHttp:r}=await D(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 J=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))};async function Kt(e,t,n,r){let i=await Gt(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}return J(a)?a:null}async function qt(e={}){let t=e.updater===void 0?await A():e.updater;if(!t&&!S())throw new O;let n=e.fetchImpl??fetch,r=e.now??Date.now,[i,a,o]=await Promise.all([zt(t),Bt(),Ht(t)]),s={channel:Ft(),platform:Lt(),deviceId:i,nativeVersion:a.version,nativeBuild:a.build,shellApiVersion:It(),currentBundleId:o},c=Ut(),l=r()+Pt,u=null;for(let[e,t]of c.entries()){let i=Wt(l,c.length-e,r);if(i===null)break;try{let e=await Kt(t,s,i,n);if(e)return e;u=Error(`Mobile OTA check failed at ${t}`)}catch(e){u=e instanceof Error?e:Error(`Mobile OTA check failed`)}}throw u??Error(`Unable to check for mobile OTA updates`)}async function Jt(e){let t=await A();if(!t)throw new O;return(await t.download({url:e.url,version:e.releaseVersion,checksum:e.checksum,...e.sessionKey?{sessionKey:e.sessionKey}:{}})).id}async function Yt(){let e=await A();if(!e)throw new O;await e.reload()}async function Xt(e){let t=await A();if(!t)throw new O;await t.next({id:e})}var Y=null,X=e=>typeof e==`string`&&e.trim().length>0?e.trim():null,Z=async()=>{let e=X(`1.18.2-beta.40`);try{if(E.isNativePlatform()){let{App:t}=await D(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`},Zt=()=>({async checkForOtaUpdate(){if(!k()&&!E.isNativePlatform())throw new O;return qt()},async downloadOtaUpdate(e){if(!k())throw new O;Y=await Jt(e)},async applyOtaUpdateNow(){if(!k())throw new O;await Yt()},async queueOtaUpdateForNextLaunch(){if(!k())throw new O;let e=Y;if(!e)throw Error(`No downloaded OTA bundle to queue`);await Xt(e)},async getOtaStatus(){if(!k())return{supported:!1,currentBundleId:`builtin`,nativeVersion:await Z()};let e=await A();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()}}}}),Qt=()=>({api:(...t)=>e().api(...t),authenticatedAsset:(...t)=>e().authenticatedAsset(...t),auth:(...t)=>e().auth(...t),health:(...t)=>e().health(...t),rawFile:(...t)=>e().rawFile(...t),sse:(...t)=>e().sse(...t),websocket:(...t)=>e().websocket(...t)}),$t=(e={})=>{let t=e.urls??s();r(t);let n=Qt();return{runtime:{platform:`web`,isDesktop:!1,isVSCode:!1,label:`web`},terminal:ct(),git:lt(),files:dt({urls:n,getDirectory:()=>ie.getState().currentDirectory}),settings:pt(),permissions:mt(),notifications:Tt(),github:Ot({urls:n}),push:Dt(),mobileUpdates:Zt(),clientAuth:kt(),tools:Et(),conversations:jt()}},Q=(e,t)=>{if(!e||!t)return!1;try{return new URL(e).origin===new URL(t).origin}catch{return!1}},$=Promise.resolve(),en=()=>$,tn=()=>{let e=typeof window.__OPENCHAMBER_API_BASE_URL__==`string`?window.__OPENCHAMBER_API_BASE_URL__.trim():``,r=typeof window.__OPENCHAMBER_CLIENT_TOKEN__==`string`?window.__OPENCHAMBER_CLIENT_TOKEN__.trim():``,s=typeof window.__OPENCHAMBER_LOCAL_ORIGIN__==`string`?window.__OPENCHAMBER_LOCAL_ORIGIN__.trim():``,d=a({apiBaseUrl:e||void 0,realtimeBaseUrl:e||void 0});o({apiBaseUrl:e,runtimeKey:Q(e,s)?`local`:null}),t(r||null),i(window.__OPENCHAMBER_RUNTIME_HEADERS__||null),l(e||void 0).catch(()=>{}),s&&!Q(e,s)&&Object.keys(n()).length>0&&c(s).catch(()=>{}),u();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)})]),$t({urls:d})};export{en as n,tn as t};
@@ -1,4 +1,4 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{A as t,D as n,E as r,b as i,j as a,k as o,t as s}from"./useUIStore-5agS8bsW.js";import{$ as c,$t as l,Xt as u,_n as d,d as f,kn as p,kt as m,on as h,r as g,st as _,u as v,yn as y}from"./persistence-ZSrLIR97.js";import{a as b,i as x}from"./vendor-zustand-B4dlGEM2.js";import{nt as S,o as C,rt as w,s as T,tt as E}from"./vendor-base-ui-CnHfUmDN.js";import{Ct as D,Nt as O,r as k}from"./platform-BiSk9jV3.js";import{n as A}from"./vendor-react-DLPElpoQ.js";import{n as j,s as M,t as N}from"./vendor-tanstack-react-query-D7pys_c9.js";import{i as P}from"./terminalApi-CkknnXhV.js";import{n as F}from"./vendor-reactuses-core-DDoDDyM9.js";import{n as ee,r as I,t as te}from"./clipboard-mzqrY_n2.js";import{i as ne,t as L}from"./store-BLmIK6EO.js";import{$a as R,$i as z,Ao as B,Co as V,Dr as H,En as U,Ga as W,Hi as G,It as re,Lt as ie,Mo as ae,Po as K,Pr as oe,Qr as q,Rr as se,To as ce,Yr as le,_n as ue,_r as de,cr as fe,dr as pe,en as me,fr as he,gn as ge,gr as _e,hr as ve,ii as ye,ir as be,jr as xe,l as Se,lr as Ce,mn as we,mr as Te,pn as Ee,pr as De,r as Oe,sr as ke,ta as Ae,vr as J,xo as je,yn as Me}from"./useMobileNavigationStore-7SQlIaRN.js";import{t as Ne}from"./MobileDetailNavigation-DnkLVrVy.js";import{i as Pe,t as Fe}from"./useAssistantUIStore-Bq3cPj2x.js";import{n as Ie,t as Y}from"./utils-Dh7UZFrA.js";import{n as X}from"./Icon-CBdklpKH.js";import{a as Le,i as Re,n as ze,o as Be,r as Ve,t as He}from"./dialog-DDrJKIhd.js";import{t as Z}from"./button-DimCg1lF.js";import{d as Ue}from"./gitApi-CdLpItUF.js";import{D as We,X as Ge,o as Ke,s as qe}from"./useAppFontEffects-BnAqVzvs.js";import{A as Je,N as Ye,S as Xe,a as Ze,c as Qe,f as $e,g as et,h as tt,i as nt,j as rt,m as it,n as at,o as ot,p as st,r as ct,t as lt,u as ut,v as dt,x as ft}from"./projectMeta-jWxWbDkQ.js";import{t as pt}from"./input-BNj7D6h_.js";import{i as mt,n as ht,t as gt}from"./tooltip-BE6WDmtb.js";import{_ as _t,g as vt,h as yt,m as bt}from"./useSessionAutoCleanup-fCB4vS1c.js";import{n as xt,t as St}from"./useThemeSystem-DMzWVJaW.js";import{A as Ct,C as wt,D as Tt,E as Et,N as Dt,O as Ot,Q as kt,T as At,Z as jt,_ as Mt,h as Nt,j as Pt,p as Ft,v as It,y as Lt}from"./radio-BArg8rN7.js";import{i as Rt,t as zt}from"./OverlayScrollbar-iaMCjwrs.js";import{g as Bt,x as Vt}from"./markdownTheme-CziN3c9i.js";import{K as Ht,M as Ut,U as Wt,V as Gt,W as Kt,et as qt,t as Jt,y as Yt,z as Xt}from"./ChatContainer-Be1DHzgc.js";import{n as Zt}from"./useRuntimeAPIs-DSLXJybW.js";import{c as Qt,n as $t,t as en}from"./appThemeRegistry-CBs9rFM0.js";import{_ as tn,i as nn,l as rn,s as an,t as on,v as sn,y as cn}from"./vendor-dnd-kit-core-CvWxUPdb.js";import{a as ln,o as un,s as dn,t as fn}from"./vendor-dnd-kit-sortable-hHdP9lLb.js";import{h as pn,p as mn}from"./markdown-worker-CJ8ooXEK.js";import{n as hn}from"./useEffectiveDirectory-Cxk960zS.js";import{f as gn}from"./FadeInOnReveal-9uJN0g-H.js";import{E as _n,T as vn,b as yn,g as bn,k as xn,r as Sn,x as Cn,y as wn}from"./insertionBoundaries-Dx-FimZn.js";import{n as Tn}from"./useWorkerHighlightedLines-Dur8-7lm.js";import{t as En}from"./vendor-tanstack-react-virtual-tlDgH6PG.js";import{c as Dn,d as On,f as kn,l as An,m as jn,n as Mn,o as Nn,p as Pn,s as Fn,t as In,u as Ln}from"./vendor-pierre-diffs-BenIz2TM.js";import{a as Rn,i as zn,n as Bn}from"./vendor-framer-motion-DFy_BSVd.js";import{E as Vn,P as Hn,W as Un,X as Wn,Z as Gn,a as Kn,g as qn,t as Jn,u as Yn}from"./MobileSurface-DPBYd_9L.js";import{a as Xn,i as Zn,n as Qn,r as $n,t as er}from"./context-menu-ZC-7T9D6.js";import{n as tr,r as nr,t as rr}from"./collapsible-CF7TDu-T.js";import{t as ir}from"./vendor-cron-parser-CCD11YFT.js";var Q=e(w(),1),ar=A(),$=S(),or=e(E(),1);function sr(){return new Worker(In,{type:`module`})}var cr=[`typescript`,`javascript`,`tsx`,`jsx`,`json`,`markdown`],lr={unified:{poolSize:1,totalASTLRUCacheSize:24,lineDiffType:`none`},split:{poolSize:2,totalASTLRUCacheSize:56,lineDiffType:`word-alt`}},ur,dr,fr=e=>{let t=lr[e],n=new Pn({workerFactory:sr,poolSize:t.poolSize,totalASTLRUCacheSize:t.totalASTLRUCacheSize},{theme:{light:`pierre-light`,dark:`pierre-dark`},langs:cr,lineDiffType:t.lineDiffType,preferredHighlighter:`shiki-wasm`});return n.initialize(),n},pr=e=>{if(!(typeof window>`u`))return e===`split`?(dr??=fr(`split`),dr):(ur??=fr(`unified`),ur)},mr=e=>{let t=(0,ar.c)(7),{children:n,renderTheme:r}=e,i=gr(`unified`),a=gr(`split`),o,s;t[0]!==r||t[1]!==a||t[2]!==i?(o=()=>{i&&i.setRenderOptions({theme:r,lineDiffType:lr.unified.lineDiffType}),a&&a.setRenderOptions({theme:r,lineDiffType:lr.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},hr=e=>{let t=(0,ar.c)(11),{children:n}=e,r=St(),i,a;if(t[0]!==r?.availableThemes||t[1]!==r?.darkThemeId||t[2]!==r?.lightThemeId){let e=Vt(!1),n=Vt(!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,en(a),en(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)(mr,{renderTheme:s,children:n}),t[8]=n,t[9]=s,t[10]=c):c=t[10],c},gr=e=>{let t=(0,ar.c)(2),n=e===void 0?`unified`:e,r;return t[0]===n?r=t[1]:(r=pr(n),t[0]=n,t[1]=r),r},_r=Q.forwardRef((e,t)=>{let n=(0,ar.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)(C,{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)(T,{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});_r.displayName=`Switch`;var vr={},yr=[],br=(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}},xr=e=>{switch(e?.status){case`connected`:return`success`;case`failed`:return`error`;case`needs_auth`:case`needs_client_registration`:return`warning`;default:return`default`}},Sr=({active:e,className:t,headerAction:n,listClassName:r,hideHeader:i=!1,mobileListDensity:a=!1})=>{let{t:o}=ee(),s=D(e=>e.currentDirectory)??null,c=Un(e=>e.connect),l=Un(e=>e.disconnect),{data:u,refetch:d,isError:f,error:p}=Gn(s,{enabled:e}),{data:m}=Wn(s,{enabled:e}),h=u??vr,g=m??yr,[_,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)(X,{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=xr(t),r=t?.status===`connected`,i=y===e,d=br(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)(gt,{children:[(0,$.jsx)(mt,{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)(ht,{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)(_r,{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`)})]})})]})},Cr=e=>!(e.dismissed===`true`||e.sessionShown===`true`||e.hasActiveToast),wr=e=>!(!e.version||e.seenVersions.has(e.version)||e.dismissedVersion!==null&&e.dismissedVersion===e.version),Tr=e=>{if(typeof e!=`object`||!e)return``;let t=e.version;return typeof t==`string`?t.trim():``},Er=e=>!e||e.available!==!0||typeof e.latestVersion!=`string`?``:e.latestVersion.trim(),Dr=5e3,Or={setTimeout:(e,t)=>globalThis.setTimeout(e,t),clearTimeout:e=>globalThis.clearTimeout(e)};function kr(e,t,n=Or){if(!e)return()=>void 0;let r=n.setTimeout(()=>{t().catch(()=>void 0)},Dr);return()=>n.clearTimeout(r)}var Ar=`opencode-update-available`,jr=`opencode-upgrade-progress`,Mr=`opencode-update-toast-dismissed-version`,Nr=()=>{let{t:e}=ee(),t=s(e=>e.showOpenCodeUpdateNotifications),n=Q.useRef(new Set),r=Q.useRef(!1);Q.useEffect(()=>{t||J.dismiss(Ar)},[t]);let a=Q.useCallback(()=>{J.dismiss(jr),R({message:e(`opencodeUpdate.toast.reload.message`),mode:`projects`,scopes:[`all`]}).catch(()=>void 0)},[e]),o=Q.useCallback(async()=>{if(!r.current){r.current=!0,J.dismiss(Ar),J.message(e(`opencodeUpdate.toast.upgrading.title`),{id:jr,description:e(`opencodeUpdate.toast.upgrading.description`),duration:1/0,icon:(0,$.jsx)(X,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})});try{let t=await p(`/api/opencode/upgrade`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({})}),n=await t.json().catch(()=>null);if(!t.ok||n?.success===!1)throw Error(n?.error||t.statusText||e(`opencodeUpdate.toast.failed.description`));J.success(e(`opencodeUpdate.toast.updated.title`),{id:jr,description:n?.version?e(`opencodeUpdate.toast.updated.descriptionWithVersion`,{version:n.version}):e(`opencodeUpdate.toast.updated.description`),duration:1/0,icon:(0,$.jsx)(X,{name:`check`,className:`h-4 w-4 text-[var(--status-success)]`}),action:{label:e(`opencodeUpdate.toast.actions.reload`),onClick:a}})}catch(t){J.error(e(`opencodeUpdate.toast.failed.title`),{id:jr,description:t instanceof Error?t.message:e(`opencodeUpdate.toast.failed.description`),duration:1/0})}finally{r.current=!1}}},[a,e]);return Q.useEffect(()=>{let r=t=>{if(!s.getState().showOpenCodeUpdateNotifications){J.dismiss(Ar);return}wr({version:t,dismissedVersion:i().getItem(Mr),seenVersions:n.current})&&(n.current.add(t),J.info(e(`opencodeUpdate.toast.available.title`),{id:Ar,description:e(`opencodeUpdate.toast.available.description`,{version:t}),duration:1/0,action:{label:e(`opencodeUpdate.toast.actions.update`),onClick:o},cancel:{label:e(`opencodeUpdate.toast.actions.dismiss`),onClick:()=>{i().setItem(Mr,t),g({openCodeUpdateToastDismissedVersion:t}),J.dismiss(Ar)}}}))},a=e=>{let t=Tr(e.detail);r(t)},c=!1,l=kr(t,async()=>{try{let e=await p(`/api/opencode/upgrade-status`,{headers:{Accept:`application/json`}});if(!e.ok)throw Error(e.statusText||`OpenCode upgrade status check failed`);let t=Er(await e.json().catch(()=>null));!c&&t&&r(t)}catch{}});return window.addEventListener(`openchamber:opencode-update-available`,a),()=>{c=!0,l(),window.removeEventListener(`openchamber:opencode-update-available`,a)}},[o,t,e]),null},Pr=()=>{let e=(0,ar.c)(3),[t,n]=Q.useState(Fr),{isUpdating:r}=t,i,a;if(e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=()=>ce(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)(kt,{width:80,height:80,isAnimated:!0})}),e[2]=o):o=e[2],o};function Fr(){return V()}var Ir=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)(bt,{className:`w-full max-w-md`,children:[(0,$.jsx)(vt,{className:`text-center`,children:(0,$.jsxs)(_t,{className:`flex items-center justify-center gap-2 text-destructive`,children:[(0,$.jsx)(X,{name:`chat-3`,className:`h-5 w-5`}),this.props.texts.title]})}),(0,$.jsxs)(yt,{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)(Z,{onClick:this.handleReset,variant:`outline`,className:`flex-1`,children:[(0,$.jsx)(X,{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 Lr(e){let t=(0,ar.c)(22),{t:n}=ee(),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)(Ir,{...e,texts:l}),t[19]=e,t[20]=l,t[21]=u):u=t[21],u}var Rr=e=>{let t=(0,ar.c)(10),{readOnly:n,active:r,selectionOverride:i}=e,a=n!==void 0&&n,o=r===void 0||r,s=Se(zr),c=(i?.sessionId??s)||void 0,l;t[0]!==o||t[1]!==i?(l=i?{...i,active:o}:void 0,t[0]=o,t[1]=i,t[2]=l):l=t[2];let u;t[3]!==o||t[4]!==a||t[5]!==l?(u=(0,$.jsx)(Jt,{readOnly:a,active:o,explicitSession:l}),t[3]=o,t[4]=a,t[5]=l,t[6]=u):u=t[6];let d;return t[7]!==c||t[8]!==u?(d=(0,$.jsx)(Lr,{sessionId:c,children:u}),t[7]=c,t[8]=u,t[9]=d):d=t[9],d};function zr(e){return e.currentSessionId}function Br(e){let t=(0,ar.c)(85),{draft:n,onEdit:r,onDelete:i,className:a,maxWidth:o}=e,{t:s}=ee(),c=St()?.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(`
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{A as t,D as n,E as r,b as i,j as a,k as o,t as s}from"./useUIStore-CL06MzOk.js";import{$ as c,$t as l,Xt as u,_n as d,d as f,kn as p,kt as m,on as h,r as g,st as _,u as v,yn as y}from"./persistence-Cm9DnxXq.js";import{a as b,i as x}from"./vendor-zustand-B4dlGEM2.js";import{nt as S,o as C,rt as w,s as T,tt as E}from"./vendor-base-ui-CnHfUmDN.js";import{Ct as D,Nt as O,r as k}from"./platform-BrOZ1tqx.js";import{n as A}from"./vendor-react-DLPElpoQ.js";import{n as j,s as M,t as N}from"./vendor-tanstack-react-query-D7pys_c9.js";import{i as P}from"./terminalApi-BunCJZ0A.js";import{n as F}from"./vendor-reactuses-core-DDoDDyM9.js";import{n as ee,r as I,t as te}from"./clipboard-DH0BvKYH.js";import{i as ne,t as L}from"./store-BLmIK6EO.js";import{$a as R,$i as z,Ao as B,Co as V,Dr as H,En as U,Ga as W,Hi as G,It as re,Lt as ie,Mo as ae,Po as K,Pr as oe,Qr as q,Rr as se,To as ce,Yr as le,_n as ue,_r as de,cr as fe,dr as pe,en as me,fr as he,gn as ge,gr as _e,hr as ve,ii as ye,ir as be,jr as xe,l as Se,lr as Ce,mn as we,mr as Te,pn as Ee,pr as De,r as Oe,sr as ke,ta as Ae,vr as J,xo as je,yn as Me}from"./useMobileNavigationStore-f5hodHkc.js";import{t as Ne}from"./MobileDetailNavigation-BuGHMy3o.js";import{i as Pe,t as Fe}from"./useAssistantUIStore-B9YvQgXU.js";import{n as Ie,t as Y}from"./utils-DlvuQ5yV.js";import{n as X}from"./Icon-C0dydAmx.js";import{a as Le,i as Re,n as ze,o as Be,r as Ve,t as He}from"./dialog-BPXCMWcj.js";import{t as Z}from"./button-Iv9uULki.js";import{d as Ue}from"./gitApi-4LIdr-v1.js";import{D as We,X as Ge,o as Ke,s as qe}from"./useAppFontEffects-BApC_Nk8.js";import{A as Je,N as Ye,S as Xe,a as Ze,c as Qe,f as $e,g as et,h as tt,i as nt,j as rt,m as it,n as at,o as ot,p as st,r as ct,t as lt,u as ut,v as dt,x as ft}from"./projectMeta-r5NAkHfX.js";import{t as pt}from"./input-7arjRNdx.js";import{i as mt,n as ht,t as gt}from"./tooltip-CO8qCWXw.js";import{_ as _t,g as vt,h as yt,m as bt}from"./useSessionAutoCleanup-EKU0ZYhf.js";import{n as xt,t as St}from"./useThemeSystem-DMzWVJaW.js";import{A as Ct,C as wt,D as Tt,E as Et,N as Dt,O as Ot,Q as kt,T as At,Z as jt,_ as Mt,h as Nt,j as Pt,p as Ft,v as It,y as Lt}from"./radio-G_YvD3ft.js";import{i as Rt,t as zt}from"./OverlayScrollbar-DMQhwzR3.js";import{g as Bt,x as Vt}from"./markdownTheme-QtXMKzKz.js";import{K as Ht,M as Ut,U as Wt,V as Gt,W as Kt,et as qt,t as Jt,y as Yt,z as Xt}from"./ChatContainer-CEXwPvOE.js";import{n as Zt}from"./useRuntimeAPIs-DSLXJybW.js";import{c as Qt,n as $t,t as en}from"./appThemeRegistry-DUeCYxWD.js";import{_ as tn,i as nn,l as rn,s as an,t as on,v as sn,y as cn}from"./vendor-dnd-kit-core-CvWxUPdb.js";import{a as ln,o as un,s as dn,t as fn}from"./vendor-dnd-kit-sortable-hHdP9lLb.js";import{h as pn,p as mn}from"./markdown-worker-sIoCa792.js";import{n as hn}from"./useEffectiveDirectory-Bc-cEAh0.js";import{f as gn}from"./FadeInOnReveal-EygBOzfu.js";import{E as _n,T as vn,b as yn,g as bn,k as xn,r as Sn,x as Cn,y as wn}from"./insertionBoundaries-Dbq-aDBu.js";import{n as Tn}from"./useWorkerHighlightedLines-DBz6RbGf.js";import{t as En}from"./vendor-tanstack-react-virtual-tlDgH6PG.js";import{c as Dn,d as On,f as kn,l as An,m as jn,n as Mn,o as Nn,p as Pn,s as Fn,t as In,u as Ln}from"./vendor-pierre-diffs-BenIz2TM.js";import{a as Rn,i as zn,n as Bn}from"./vendor-framer-motion-DFy_BSVd.js";import{E as Vn,P as Hn,W as Un,X as Wn,Z as Gn,a as Kn,g as qn,t as Jn,u as Yn}from"./MobileSurface-BBWgxzyI.js";import{a as Xn,i as Zn,n as Qn,r as $n,t as er}from"./context-menu-BWKM1gKq.js";import{n as tr,r as nr,t as rr}from"./collapsible-C46kU7ea.js";import{t as ir}from"./vendor-cron-parser-CCD11YFT.js";var Q=e(w(),1),ar=A(),$=S(),or=e(E(),1);function sr(){return new Worker(In,{type:`module`})}var cr=[`typescript`,`javascript`,`tsx`,`jsx`,`json`,`markdown`],lr={unified:{poolSize:1,totalASTLRUCacheSize:24,lineDiffType:`none`},split:{poolSize:2,totalASTLRUCacheSize:56,lineDiffType:`word-alt`}},ur,dr,fr=e=>{let t=lr[e],n=new Pn({workerFactory:sr,poolSize:t.poolSize,totalASTLRUCacheSize:t.totalASTLRUCacheSize},{theme:{light:`pierre-light`,dark:`pierre-dark`},langs:cr,lineDiffType:t.lineDiffType,preferredHighlighter:`shiki-wasm`});return n.initialize(),n},pr=e=>{if(!(typeof window>`u`))return e===`split`?(dr??=fr(`split`),dr):(ur??=fr(`unified`),ur)},mr=e=>{let t=(0,ar.c)(7),{children:n,renderTheme:r}=e,i=gr(`unified`),a=gr(`split`),o,s;t[0]!==r||t[1]!==a||t[2]!==i?(o=()=>{i&&i.setRenderOptions({theme:r,lineDiffType:lr.unified.lineDiffType}),a&&a.setRenderOptions({theme:r,lineDiffType:lr.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},hr=e=>{let t=(0,ar.c)(11),{children:n}=e,r=St(),i,a;if(t[0]!==r?.availableThemes||t[1]!==r?.darkThemeId||t[2]!==r?.lightThemeId){let e=Vt(!1),n=Vt(!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,en(a),en(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)(mr,{renderTheme:s,children:n}),t[8]=n,t[9]=s,t[10]=c):c=t[10],c},gr=e=>{let t=(0,ar.c)(2),n=e===void 0?`unified`:e,r;return t[0]===n?r=t[1]:(r=pr(n),t[0]=n,t[1]=r),r},_r=Q.forwardRef((e,t)=>{let n=(0,ar.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)(C,{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)(T,{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});_r.displayName=`Switch`;var vr={},yr=[],br=(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}},xr=e=>{switch(e?.status){case`connected`:return`success`;case`failed`:return`error`;case`needs_auth`:case`needs_client_registration`:return`warning`;default:return`default`}},Sr=({active:e,className:t,headerAction:n,listClassName:r,hideHeader:i=!1,mobileListDensity:a=!1})=>{let{t:o}=ee(),s=D(e=>e.currentDirectory)??null,c=Un(e=>e.connect),l=Un(e=>e.disconnect),{data:u,refetch:d,isError:f,error:p}=Gn(s,{enabled:e}),{data:m}=Wn(s,{enabled:e}),h=u??vr,g=m??yr,[_,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)(X,{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=xr(t),r=t?.status===`connected`,i=y===e,d=br(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)(gt,{children:[(0,$.jsx)(mt,{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)(ht,{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)(_r,{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`)})]})})]})},Cr=e=>!(e.dismissed===`true`||e.sessionShown===`true`||e.hasActiveToast),wr=e=>!(!e.version||e.seenVersions.has(e.version)||e.dismissedVersion!==null&&e.dismissedVersion===e.version),Tr=e=>{if(typeof e!=`object`||!e)return``;let t=e.version;return typeof t==`string`?t.trim():``},Er=e=>!e||e.available!==!0||typeof e.latestVersion!=`string`?``:e.latestVersion.trim(),Dr=5e3,Or={setTimeout:(e,t)=>globalThis.setTimeout(e,t),clearTimeout:e=>globalThis.clearTimeout(e)};function kr(e,t,n=Or){if(!e)return()=>void 0;let r=n.setTimeout(()=>{t().catch(()=>void 0)},Dr);return()=>n.clearTimeout(r)}var Ar=`opencode-update-available`,jr=`opencode-upgrade-progress`,Mr=`opencode-update-toast-dismissed-version`,Nr=()=>{let{t:e}=ee(),t=s(e=>e.showOpenCodeUpdateNotifications),n=Q.useRef(new Set),r=Q.useRef(!1);Q.useEffect(()=>{t||J.dismiss(Ar)},[t]);let a=Q.useCallback(()=>{J.dismiss(jr),R({message:e(`opencodeUpdate.toast.reload.message`),mode:`projects`,scopes:[`all`]}).catch(()=>void 0)},[e]),o=Q.useCallback(async()=>{if(!r.current){r.current=!0,J.dismiss(Ar),J.message(e(`opencodeUpdate.toast.upgrading.title`),{id:jr,description:e(`opencodeUpdate.toast.upgrading.description`),duration:1/0,icon:(0,$.jsx)(X,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})});try{let t=await p(`/api/opencode/upgrade`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({})}),n=await t.json().catch(()=>null);if(!t.ok||n?.success===!1)throw Error(n?.error||t.statusText||e(`opencodeUpdate.toast.failed.description`));J.success(e(`opencodeUpdate.toast.updated.title`),{id:jr,description:n?.version?e(`opencodeUpdate.toast.updated.descriptionWithVersion`,{version:n.version}):e(`opencodeUpdate.toast.updated.description`),duration:1/0,icon:(0,$.jsx)(X,{name:`check`,className:`h-4 w-4 text-[var(--status-success)]`}),action:{label:e(`opencodeUpdate.toast.actions.reload`),onClick:a}})}catch(t){J.error(e(`opencodeUpdate.toast.failed.title`),{id:jr,description:t instanceof Error?t.message:e(`opencodeUpdate.toast.failed.description`),duration:1/0})}finally{r.current=!1}}},[a,e]);return Q.useEffect(()=>{let r=t=>{if(!s.getState().showOpenCodeUpdateNotifications){J.dismiss(Ar);return}wr({version:t,dismissedVersion:i().getItem(Mr),seenVersions:n.current})&&(n.current.add(t),J.info(e(`opencodeUpdate.toast.available.title`),{id:Ar,description:e(`opencodeUpdate.toast.available.description`,{version:t}),duration:1/0,action:{label:e(`opencodeUpdate.toast.actions.update`),onClick:o},cancel:{label:e(`opencodeUpdate.toast.actions.dismiss`),onClick:()=>{i().setItem(Mr,t),g({openCodeUpdateToastDismissedVersion:t}),J.dismiss(Ar)}}}))},a=e=>{let t=Tr(e.detail);r(t)},c=!1,l=kr(t,async()=>{try{let e=await p(`/api/opencode/upgrade-status`,{headers:{Accept:`application/json`}});if(!e.ok)throw Error(e.statusText||`OpenCode upgrade status check failed`);let t=Er(await e.json().catch(()=>null));!c&&t&&r(t)}catch{}});return window.addEventListener(`openchamber:opencode-update-available`,a),()=>{c=!0,l(),window.removeEventListener(`openchamber:opencode-update-available`,a)}},[o,t,e]),null},Pr=()=>{let e=(0,ar.c)(3),[t,n]=Q.useState(Fr),{isUpdating:r}=t,i,a;if(e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=()=>ce(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)(kt,{width:80,height:80,isAnimated:!0})}),e[2]=o):o=e[2],o};function Fr(){return V()}var Ir=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)(bt,{className:`w-full max-w-md`,children:[(0,$.jsx)(vt,{className:`text-center`,children:(0,$.jsxs)(_t,{className:`flex items-center justify-center gap-2 text-destructive`,children:[(0,$.jsx)(X,{name:`chat-3`,className:`h-5 w-5`}),this.props.texts.title]})}),(0,$.jsxs)(yt,{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)(Z,{onClick:this.handleReset,variant:`outline`,className:`flex-1`,children:[(0,$.jsx)(X,{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 Lr(e){let t=(0,ar.c)(22),{t:n}=ee(),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)(Ir,{...e,texts:l}),t[19]=e,t[20]=l,t[21]=u):u=t[21],u}var Rr=e=>{let t=(0,ar.c)(10),{readOnly:n,active:r,selectionOverride:i}=e,a=n!==void 0&&n,o=r===void 0||r,s=Se(zr),c=(i?.sessionId??s)||void 0,l;t[0]!==o||t[1]!==i?(l=i?{...i,active:o}:void 0,t[0]=o,t[1]=i,t[2]=l):l=t[2];let u;t[3]!==o||t[4]!==a||t[5]!==l?(u=(0,$.jsx)(Jt,{readOnly:a,active:o,explicitSession:l}),t[3]=o,t[4]=a,t[5]=l,t[6]=u):u=t[6];let d;return t[7]!==c||t[8]!==u?(d=(0,$.jsx)(Lr,{sessionId:c,children:u}),t[7]=c,t[8]=u,t[9]=d):d=t[9],d};function zr(e){return e.currentSessionId}function Br(e){let t=(0,ar.c)(85),{draft:n,onEdit:r,onDelete:i,className:a,maxWidth:o}=e,{t:s}=ee(),c=St()?.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(`
2
2
  `).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)(nr,{asChild:!0,children:(0,$.jsx)(Z,{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)(X,{name:`arrow-up-s`,className:`size-3 mr-1`}),s(`inlineComment.actions.showLess`)]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(X,{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)(tr,{}),t[36]=P):P=t[36];let F;t[37]!==k||t[38]!==M||t[39]!==N?(F=(0,$.jsxs)(rr,{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 te;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,$.jsx)(Dt,{asChild:!0,children:(0,$.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-6 w-6 -mr-1 text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(X,{name:`more`,className:`size-4`})})}),t[44]=te):te=t[44];let ne;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,$.jsx)(X,{name:`edit`,className:`size-4 mr-2`}),t[45]=ne):ne=t[45];let L;t[46]===s?L=t[47]:(L=s(`inlineComment.actions.editComment`),t[46]=s,t[47]=L);let R;t[48]!==r||t[49]!==L?(R=(0,$.jsxs)(Ot,{onClick:r,children:[ne,L]}),t[48]=r,t[49]=L,t[50]=R):R=t[50];let z;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(X,{name:`delete-bin`,className:`size-4 mr-2`}),t[51]=z):z=t[51];let B;t[52]===s?B=t[53]:(B=s(`inlineComment.actions.deleteComment`),t[52]=s,t[53]=B);let V;t[54]!==i||t[55]!==B?(V=(0,$.jsxs)(Ot,{onClick:i,className:`text-destructive`,children:[z,B]}),t[54]=i,t[55]=B,t[56]=V):V=t[56];let H;t[57]!==R||t[58]!==V?(H=(0,$.jsxs)(Et,{children:[te,(0,$.jsxs)(Tt,{align:`end`,children:[R,V]})]}),t[57]=R,t[58]=V,t[59]=H):H=t[59];let U;t[60]!==I||t[61]!==H?(U=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2 p-3`,children:[I,H]}),t[60]=I,t[61]=H,t[62]=U):U=t[62];let W;t[63]!==U||t[64]!==S?(W=(0,$.jsx)(Xn,{render:S,children:U}),t[63]=U,t[64]=S,t[65]=W):W=t[65];let G;t[66]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,$.jsx)(X,{name:`edit`,className:`size-4 mr-2`}),t[66]=G):G=t[66];let re;t[67]===s?re=t[68]:(re=s(`inlineComment.actions.editComment`),t[67]=s,t[68]=re);let ie;t[69]!==r||t[70]!==re?(ie=(0,$.jsxs)($n,{onClick:r,children:[G,re]}),t[69]=r,t[70]=re,t[71]=ie):ie=t[71];let ae;t[72]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,$.jsx)(X,{name:`delete-bin`,className:`size-4 mr-2`}),t[72]=ae):ae=t[72];let K;t[73]===s?K=t[74]:(K=s(`inlineComment.actions.deleteComment`),t[73]=s,t[74]=K);let oe;t[75]!==i||t[76]!==K?(oe=(0,$.jsxs)($n,{onClick:i,className:`text-destructive focus:text-destructive`,children:[ae,K]}),t[75]=i,t[76]=K,t[77]=oe):oe=t[77];let q;t[78]!==ie||t[79]!==oe?(q=(0,$.jsxs)(Qn,{children:[ie,oe]}),t[78]=ie,t[79]=oe,t[80]=q):q=t[80];let se;return t[81]!==d||t[82]!==W||t[83]!==q?(se=(0,$.jsxs)(er,{open:d,onOpenChange:f,children:[W,q]}),t[81]=d,t[82]=W,t[83]=q,t[84]=se):se=t[84],se}function Vr(e){let t=(0,ar.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}=ee(),h=St()?.currentTheme,{isMobile:g}=Rt(),[_,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=Yr,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,te;t[17]!==P||t[18]!==F||t[19]!==I?(te={backgroundColor:P,borderColor:F,maxWidth:I},t[17]=P,t[18]=F,t[19]=I,t[20]=te):te=t[20];let ne=Jr,L=qr,R=(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})})]}),z;t[21]===x?z=t[22]:(z=e=>x(e.target.value),t[21]=x,t[22]=z);let B;t[23]!==g||t[24]!==m?(B=m(g?`inlineComment.input.placeholderShort`:`inlineComment.input.placeholder`),t[23]=g,t[24]=m,t[25]=B):B=t[25];let V;t[26]!==A||t[27]!==z||t[28]!==B||t[29]!==_?(V=(0,$.jsx)(ot,{simple:!0,ref:y,value:_,onChange:z,onKeyDown:A,placeholder:B,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]=z,t[28]=B,t[29]=_,t[30]=V):V=t[30];let H;t[31]!==E||t[32]!==d||t[33]!==m?(H=E&&d?(0,$.jsxs)(Z,{variant:`outline`,size:`sm`,onClick:()=>d(E),onPointerDown:Kr,className:`mr-auto h-8 gap-1.5`,children:[(0,$.jsx)(X,{name:`add`,className:`size-4`}),m(`chat.textSelection.actions.addToChat`),(0,$.jsx)(Gt,{shortcut:`⌘+I`})]}):null,t[31]=E,t[32]=d,t[33]=m,t[34]=H):H=t[34];let U;t[35]===m?U=t[36]:(U=m(`inlineComment.actions.cancel`),t[35]=m,t[36]=U);let W;t[37]!==a||t[38]!==U?(W=(0,$.jsx)(Z,{variant:`ghost`,size:`sm`,onClick:a,onPointerDown:Gr,onTouchStart:Wr,className:`h-8 text-muted-foreground hover:text-foreground`,children:U}),t[37]=a,t[38]=U,t[39]=W):W=t[39];let G;t[40]===_?G=t[41]:(G=_.trim(),t[40]=_,t[41]=G);let re=!G,ie=h?.colors?.status?.success,ae=h?.colors?.status?.successForeground,K;t[42]!==ie||t[43]!==ae?(K={backgroundColor:ie,color:ae},t[42]=ie,t[43]=ae,t[44]=K):K=t[44];let oe;t[45]!==p||t[46]!==m?(oe=m(p?`inlineComment.actions.save`:`inlineComment.actions.comment`),t[45]=p,t[46]=m,t[47]=oe):oe=t[47];let q;t[48]!==M||t[49]!==re||t[50]!==K||t[51]!==oe?(q=(0,$.jsx)(Z,{size:`sm`,onClick:M,onPointerDown:Ur,onTouchStart:Hr,disabled:re,className:`h-8 min-w-[80px]`,style:K,children:oe}),t[48]=M,t[49]=re,t[50]=K,t[51]=oe,t[52]=q):q=t[52];let se;t[53]!==H||t[54]!==W||t[55]!==q?(se=(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2 mt-3`,children:[H,W,q]}),t[53]=H,t[54]=W,t[55]=q,t[56]=se):se=t[56];let ce;t[57]!==R||t[58]!==V||t[59]!==se?(ce=(0,$.jsxs)(`div`,{className:`p-3`,children:[R,V,se]}),t[57]=R,t[58]=V,t[59]=se,t[60]=ce):ce=t[60];let le;return t[61]!==N||t[62]!==te||t[63]!==ne||t[64]!==L||t[65]!==ce?(le=(0,$.jsx)(`div`,{className:N,style:te,"data-comment-input":`true`,onPointerDown:ne,onTouchStart:L,children:ce}),t[61]=N,t[62]=te,t[63]=ne,t[64]=L,t[65]=ce,t[66]=le):le=t[66],le}function Hr(e){return e.stopPropagation()}function Ur(e){return e.stopPropagation()}function Wr(e){return e.stopPropagation()}function Gr(e){return e.stopPropagation()}function Kr(e){return e.stopPropagation()}function qr(e){return e.stopPropagation()}function Jr(e){return e.stopPropagation()}function Yr(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 Xr=e=>{let t=Math.min(e.startLine,e.endLine),n=Math.max(e.startLine,e.endLine);return{...e,startLine:t,endLine:n}},Zr=e=>{let t=Math.min(e.start,e.end),n=Math.max(e.start,e.end);return{...e,start:t,end:n}};function Qr(e){let t=(0,ar.c)(40),{t:n}=ee(),{source:r,fileLabel:i,language:a,getCodeForRange:o,toStoreRange:s,fromDraftRange:c}=e,l=Se(ii),u=Se(ri),d=Ht(ni),f=Ht(ti),p=Ht(ei),m=Ht($r),[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=Zr(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){J.error(n(`inlineComment.toast.selectSessionToSave`));return}let u=Zr(c),p=Xr(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 $r(e){return e.drafts}function ei(e){return e.removeDraft}function ti(e){return e.updateDraft}function ni(e){return e.addDraft}function ri(e){return e.newSessionDraft?.open}function ii(e){return e.currentSessionId}function ai(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)(Vr,{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)(Br,{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)(Vr,{initialText:r,onTextChange:i,fileLabel:s,lineRange:e,isEditing:!1,onSave:u,onCancel:d,onAddToChat:m},c)})}return h}var oi=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}`},si=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 ci(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 li(e){if(!(!e||e<=0))return Math.max(200,Math.floor(e))}function ui(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:oi({type:`new`,selection:r}),[i,r]),v=Q.useMemo(()=>{let e=n.map(e=>oi({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=ci(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?li(Math.min(...o)):li(h)},[t,h]);return(0,$.jsxs)($.Fragment,{children:[n.map(e=>{let t=oi({type:e.id===i?`edit`:`saved`,draft:e}),n=y(t);if(!n)return null;let r=b(n);return e.id===i?(0,or.createPortal)((0,$.jsx)(Vr,{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,or.createPortal)((0,$.jsx)(Br,{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,or.createPortal)((0,$.jsx)(Vr,{initialText:a,onTextChange:o,fileLabel:s,lineRange:r,isEditing:!1,onSave:c,onCancel:l,onAddToChat:f,maxWidth:t}),e,_)})()]})}function di(e){let t=(0,ar.c)(13),{position:n,onAddToChat:r}=e,{t:i}=ee(),a;t[0]!==n.x||t[1]!==n.y?(a={left:n.x,top:n.y},t[0]=n.x,t[1]=n.y,t[2]=a):a=t[2];let o;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(X,{name:`add`,className:`size-4`}),t[3]=o):o=t[3];let s;t[4]===i?s=t[5]:(s=i(`chat.textSelection.actions.addToChat`),t[4]=i,t[5]=s);let c;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(Gt,{shortcut:`⌘+I`}),t[6]=c):c=t[6];let l;t[7]!==r||t[8]!==s?(l=(0,$.jsxs)(Z,{variant:`ghost`,size:`sm`,className:`h-7 gap-1.5 px-2`,onClick:r,children:[o,s,c]}),t[7]=r,t[8]=s,t[9]=l):l=t[9];let u;return t[10]!==a||t[11]!==l?(u=(0,or.createPortal)((0,$.jsx)(`div`,{"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:a,onPointerDown:fi,children:l}),document.body),t[10]=a,t[11]=l,t[12]=u):u=t[12],u}function fi(e){return e.preventDefault()}var pi=5e5,mi=`
3
3
  :host {
4
4
  font-family: var(--font-mono);
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{t}from"./useUIStore-5agS8bsW.js";import{nt as n,rt as r}from"./vendor-base-ui-CnHfUmDN.js";import{n as i}from"./vendor-react-DLPElpoQ.js";import{n as a}from"./clipboard-mzqrY_n2.js";import{t as o}from"./utils-Dh7UZFrA.js";import{n as s}from"./Icon-CBdklpKH.js";import{i as c}from"./OverlayScrollbar-iaMCjwrs.js";import{_ as l,l as u,n as d,s as ee,t as f,v as p,y as m}from"./vendor-dnd-kit-core-CvWxUPdb.js";import{o as h,r as te,t as g}from"./vendor-dnd-kit-sortable-hHdP9lLb.js";var ne=i(),_=e(r(),1),v=n(),re=({transform:e})=>({...e,y:0}),ie=e=>{let t=(0,ne.c)(18),{id:n,children:r,className:i}=e,a;t[0]===n?a=t[1]:(a={id:n},t[0]=n,t[1]=a);let{attributes:s,listeners:c,setNodeRef:l,transform:u,transition:d,isDragging:ee}=h(a),f;t[2]===u?f=t[3]:(f=m.Transform.toString(u),t[2]=u,t[3]=f);let p;t[4]!==f||t[5]!==d?(p={transform:f,transition:d},t[4]=f,t[5]=d,t[6]=p):p=t[6];let te=ee&&`opacity-50`,g;t[7]!==i||t[8]!==te?(g=o(`h-full rounded-md`,i,te),t[7]=i,t[8]=te,t[9]=g):g=t[9];let _;return t[10]!==s||t[11]!==r||t[12]!==n||t[13]!==c||t[14]!==l||t[15]!==p||t[16]!==g?(_=(0,v.jsx)(`div`,{ref:l,"data-sortable-tab-id":n,style:p,className:g,...s,...c,children:r}),t[10]=s,t[11]=r,t[12]=n,t[13]=c,t[14]=l,t[15]=p,t[16]=g,t[17]=_):_=t[17],_},ae=e=>{let t=(0,ne.c)(6),{id:n,children:r,className:i}=e,a;t[0]===i?a=t[1]:(a=o(`h-full`,i),t[0]=i,t[1]=a);let s;return t[2]!==r||t[3]!==n||t[4]!==a?(s=(0,v.jsx)(`div`,{className:a,"data-sortable-tab-id":n,children:r}),t[2]=r,t[3]=n,t[4]=a,t[5]=s):s=t[5],s},y=e=>{let n=(0,ne.c)(121),{items:r,activeId:i,onSelect:m,onClose:h,onReorder:y,layoutMode:he,variant:ge,activePillInsetClassName:_e,activePillButtonClassName:b,inactiveTabsIconOnly:ve,iconOnlyActiveTab:ye,animateActivePill:be,activePillLowercase:xe,className:Se}=e,Ce=he===void 0?`scrollable`:he,we=ge===void 0?`default`:ge,x=ve!==void 0&&ve,S=ye!==void 0&&ye,C=xe===void 0||xe,{t:Te}=a(),w=t(oe),{isTablet:Ee}=c(),T=w||Ee,E=_.useRef(null),De;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(De={left:!1,right:!1},n[0]=De):De=n[0];let[D,O]=_.useState(De),k;n[1]===r?k=n[2]:(k=r.map(se),n[1]=r,n[2]=k);let Oe=k,A=Ce===`scrollable`,ke=we==="default",j=we===`active-pill`,Ae=we===`animated`,M=j||Ae,N=ke,P=M||N,F=j&&A,je=M,Me=be??Ae,Ne=typeof y==`function`,I=Ne?ie:ae,L;n[3]===Symbol.for(`react.memo_cache_sentinel`)?(L=new Map,n[3]=L):L=n[3];let R=_.useRef(L),[z,Pe]=_.useState(null),Fe;n[4]===Symbol.for(`react.memo_cache_sentinel`)?(Fe={activationConstraint:{distance:8}},n[4]=Fe):Fe=n[4];let Ie=p(l(ee,Fe)),Le=ce,Re;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(Re=(e,t)=>{if(t){R.current.set(e,t);return}R.current.delete(e)},n[5]=Re):Re=n[5];let ze=Re,Be;n[6]!==i||n[7]!==P?(Be=()=>{if(!P||!i){Pe(le);return}let e=E.current,t=R.current.get(i);if(!e||!t){Pe(ue);return}let n=0,r=0,a=t;for(;a&&a!==e;)n+=a.offsetLeft,r+=a.offsetTop,a=a.offsetParent;let o={left:n,top:r,width:t.offsetWidth,height:t.offsetHeight};Pe(e=>Le(e,o)?e:o)},n[6]=i,n[7]=P,n[8]=Be):Be=n[8];let B=Be,Ve;n[9]===A?Ve=n[10]:(Ve=()=>{if(!A){O({left:!1,right:!1});return}let e=E.current;if(!e){O({left:!1,right:!1});return}O({left:e.scrollLeft>2,right:e.scrollLeft+e.clientWidth<e.scrollWidth-2})},n[9]=A,n[10]=Ve);let V=Ve,He;n[11]!==A||n[12]!==V?(He=()=>{if(!A){O({left:!1,right:!1});return}let e=E.current;if(!e)return;V(),e.addEventListener(`scroll`,V,{passive:!0});let t=new ResizeObserver(V);return t.observe(e),()=>{e.removeEventListener(`scroll`,V),t.disconnect()}},n[11]=A,n[12]=V,n[13]=He):He=n[13];let Ue;n[14]!==A||n[15]!==r.length||n[16]!==V?(Ue=[A,r.length,V],n[14]=A,n[15]=r.length,n[16]=V,n[17]=Ue):Ue=n[17],_.useEffect(He,Ue);let We;n[18]!==i||n[19]!==B||n[20]!==P?(We=()=>{if(!P){Pe(null);return}B();let e=E.current;if(!e)return;let t=new ResizeObserver(B);if(t.observe(e),i){let e=R.current.get(i);e&&t.observe(e)}return()=>{t.disconnect()}},n[18]=i,n[19]=B,n[20]=P,n[21]=We):We=n[21];let Ge;n[22]!==i||n[23]!==r.length||n[24]!==B||n[25]!==P?(Ge=[i,r.length,B,P],n[22]=i,n[23]=r.length,n[24]=B,n[25]=P,n[26]=Ge):Ge=n[26],_.useEffect(We,Ge);let Ke;n[27]===B?Ke=n[28]:(Ke=()=>{B()},n[27]=B,n[28]=Ke),_.useLayoutEffect(Ke);let qe;n[29]!==i||n[30]!==A||n[31]!==V?(qe=()=>{if(!A||!i)return;let e=E.current;if(!e)return;let t=window.requestAnimationFrame(()=>{let t=typeof window.CSS?.escape==`function`?window.CSS.escape(i):i.replace(/"/g,`\\"`),n=e.querySelector(`[data-sortable-tab-id="${t}"]`);n&&(n.scrollIntoView({block:`nearest`,inline:`nearest`}),V())});return()=>{window.cancelAnimationFrame(t)}},n[29]=i,n[30]=A,n[31]=V,n[32]=qe):qe=n[32];let Je;n[33]!==i||n[34]!==A||n[35]!==r.length||n[36]!==V?(Je=[i,A,r.length,V],n[33]=i,n[34]=A,n[35]=r.length,n[36]=V,n[37]=Je):Je=n[37],_.useEffect(qe,Je);let Ye;n[38]===y?Ye=n[39]:(Ye=e=>{if(!y)return;let{active:t,over:n}=e;!n||t.id===n.id||y(String(t.id),String(n.id))},n[38]=y,n[39]=Ye);let Xe=Ye,H;n[40]===Se?H=n[41]:(H=o(`relative flex h-full min-w-0 flex-1`,Se),n[40]=Se,n[41]=H);let U;n[42]!==A||n[43]!==D||n[44]!==M?(U=A&&D.left?(0,v.jsx)(`div`,{className:o(`pointer-events-none absolute inset-y-0 left-0 z-20 bg-gradient-to-r to-transparent`,M?`w-8 from-[var(--surface-background)]`:`w-6 from-background`)}):null,n[42]=A,n[43]=D,n[44]=M,n[45]=U):U=n[45];let W;n[46]!==A||n[47]!==D||n[48]!==M?(W=A&&D.right?(0,v.jsx)(`div`,{className:o(`pointer-events-none absolute inset-y-0 right-0 z-20 bg-gradient-to-l to-transparent`,M?`w-8 from-[var(--surface-background)]`:`w-6 from-background`)}):null,n[46]=A,n[47]=D,n[48]=M,n[49]=W):W=n[49];let Ze=M?`items-center overflow-x-hidden overflow-y-hidden`:`items-stretch`,Qe=M&&`@container/pill-tabs`,$e=M&&`pill-tabs__track`,et=M&&(_e??`gap-0.5 py-0.5`),tt=N&&`items-center overflow-y-hidden`,nt=je&&`rounded-[10px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] bg-[color-mix(in_srgb,var(--foreground)_2%,transparent)] p-0.5 gap-0.5`,rt=A?`overflow-x-auto scrollbar-none`:`overflow-x-hidden`,G;n[50]!==Ze||n[51]!==Qe||n[52]!==$e||n[53]!==et||n[54]!==tt||n[55]!==nt||n[56]!==rt?(G=o(`relative flex h-full min-w-0 flex-1`,Ze,Qe,$e,et,tt,nt,rt),n[50]=Ze,n[51]=Qe,n[52]=$e,n[53]=et,n[54]=tt,n[55]=nt,n[56]=rt,n[57]=G):G=n[57];let K;n[58]===A?K=n[59]:(K=A?{scrollbarWidth:`none`,msOverflowStyle:`none`}:void 0,n[58]=A,n[59]=K);let q;n[60]===Te?q=n[61]:(q=Te(`sortableTabsStrip.aria.tabs`),n[60]=Te,n[61]=q);let J;n[62]!==z||n[63]!==Me||n[64]!==M?(J=M&&z?(0,v.jsx)(`div`,{className:o(`oc-segmented-selected-pill pointer-events-none absolute left-0 top-0 z-0 rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px]`),style:{transform:`translate3d(${z.left}px, ${z.top}px, 0)`,width:`${z.width}px`,height:`${z.height}px`,transition:Me?`transform 300ms cubic-bezier(0.65, 0, 0.35, 1), width 300ms cubic-bezier(0.65, 0, 0.35, 1), height 300ms cubic-bezier(0.65, 0, 0.35, 1)`:void 0}}):null,n[62]=z,n[63]=Me,n[64]=M,n[65]=J):J=n[65];let Y;n[66]!==z||n[67]!==N?(Y=N&&z?(0,v.jsx)(`div`,{className:`pointer-events-none absolute left-0 -bottom-px z-10 h-[3px] rounded-t-[2px] bg-[var(--primary-base)]`,style:{transform:`translate3d(${z.left}px, 0, 0)`,width:`${z.width}px`},"aria-hidden":!0}):null,n[66]=z,n[67]=N,n[68]=Y):Y=n[68];let X;if(n[69]!==I||n[70]!==i||n[71]!==b||n[72]!==C||n[73]!==T||n[74]!==S||n[75]!==x||n[76]!==j||n[77]!==w||n[78]!==A||n[79]!==r||n[80]!==h||n[81]!==m||n[82]!==F||n[83]!==M){let e;n[85]!==I||n[86]!==i||n[87]!==b||n[88]!==C||n[89]!==T||n[90]!==S||n[91]!==x||n[92]!==j||n[93]!==w||n[94]!==A||n[95]!==h||n[96]!==m||n[97]!==F||n[98]!==M?(e=e=>{let t=e.id===i,n=x&&M&&!t&&!!e.icon,r=!n,a=!!e.icon&&(!S||t),c=x&&M&&t&&!A&&!F,l=e.closable!==!1&&!!h,u=l&&!!e.icon,d=A||F?void 0:M?c?`flex-none basis-auto`:w?`flex-1 basis-0 min-w-0`:`flex-1 basis-0 min-w-fit`:`min-w-0 flex-1 basis-0`,ee=l?t=>{t.button===1&&(t.preventDefault(),t.stopPropagation(),h?.(e.id))}:void 0,f=l?de:void 0;return(0,v.jsx)(I,{id:e.id,className:d,children:(0,v.jsxs)(`div`,{ref:t=>ze(e.id,t),onAuxClick:ee,onMouseDown:f,className:o(`group flex h-full min-w-0 flex-nowrap items-center`,A||F?`shrink-0`:M?`w-full`:`w-full min-w-0`,M?`relative z-10 bg-transparent`:t?`relative z-10 bg-transparent text-foreground`:`relative z-10 bg-transparent text-muted-foreground hover:text-foreground`),children:[(0,v.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":t,"aria-label":n?e.title??e.label:void 0,onClick:()=>m(e.id),className:o(M?`animated-tabs__button pill-tabs__button relative z-10 flex flex-1 min-w-0 flex-nowrap items-center justify-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] text-sm font-medium transition-colors duration-150 !min-h-0`:`flex h-full min-w-0 flex-nowrap items-center typography-micro`,M&&C?`lowercase`:null,M&&(n?`gap-0`:`gap-1.5`),M?F?`shrink-0 whitespace-nowrap px-3 text-center`:A?`max-w-56 shrink-0 px-3 text-center`:n?`px-2 !min-w-0 text-center`:c?`shrink-0 whitespace-nowrap px-3 text-center`:`px-3 text-center`:A?`max-w-56 justify-start truncate px-3 text-left`:`w-full justify-center truncate px-3 text-center`,M?b??(j?w?`h-[38px]`:`h-[31px]`:`h-7`):null,M?t?`text-foreground`:`text-muted-foreground hover:text-foreground`:null,M?`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] focus-visible:ring-offset-1 focus-visible:ring-offset-background`:null),title:e.title??e.label,children:M?(0,v.jsxs)(v.Fragment,{children:[a?(0,v.jsxs)(`span`,{className:`relative flex h-4 w-4 shrink-0 items-center justify-center`,children:[(0,v.jsx)(`span`,{className:o(`flex items-center justify-center transition-opacity`,u&&(T?`opacity-0`:`group-hover:opacity-0`)),children:e.icon}),u?(0,v.jsx)(`span`,{role:`button`,tabIndex:-1,className:o(`absolute inset-0 z-20 flex !min-h-0 !min-w-0 items-center justify-center rounded-sm text-muted-foreground transition-opacity hover:text-foreground`,T?`opacity-100`:`opacity-0 group-hover:opacity-100`),onPointerDown:fe,onClick:t=>{t.stopPropagation(),h?.(e.id)},"aria-label":e.closeLabel??`Close ${e.label} tab`,title:e.closeLabel??`Close ${e.label} tab`,children:(0,v.jsx)(s,{name:`close`,className:`h-3.5 w-3.5`})}):null]}):null,r?(0,v.jsx)(`span`,{className:`animated-tabs__label truncate`,children:e.label}):null]}):(0,v.jsxs)(`span`,{className:o(`flex min-w-0 flex-nowrap items-center gap-1.5`,!A&&`justify-center`),children:[a?(0,v.jsxs)(`span`,{className:o(`relative flex h-4 w-4 shrink-0 items-center justify-center transition-colors duration-200 ease-out`,t?`text-[var(--primary-base)]`:`text-muted-foreground`),children:[(0,v.jsx)(`span`,{className:o(`flex items-center justify-center transition-opacity`,u&&(T?`opacity-0`:`group-hover:opacity-0`)),children:e.icon}),u?(0,v.jsx)(`span`,{role:`button`,tabIndex:-1,className:o(`absolute inset-0 z-20 flex !min-h-0 !min-w-0 items-center justify-center rounded-sm text-muted-foreground transition-opacity hover:text-foreground`,T?`opacity-100`:`opacity-0 group-hover:opacity-100`),onPointerDown:pe,onClick:t=>{t.stopPropagation(),h?.(e.id)},"aria-label":e.closeLabel??`Close ${e.label} tab`,title:e.closeLabel??`Close ${e.label} tab`,children:(0,v.jsx)(s,{name:`close`,className:`h-3.5 w-3.5`})}):null]}):null,(0,v.jsx)(`span`,{className:`truncate leading-[1.2]`,children:e.label})]})}),l&&!u?(0,v.jsx)(`button`,{type:`button`,onPointerDown:me,onClick:t=>{t.stopPropagation(),h?.(e.id)},className:o(`relative z-20 inline-flex !min-h-0 !min-w-0 items-center justify-center transition-opacity`,M?`-ml-2.5 mr-1 h-[88%] w-5 self-center !aspect-auto rounded-md`:`aspect-square h-[65%] min-h-4 max-h-5 rounded-sm mr-1`,M?t?`text-muted-foreground hover:bg-transparent hover:text-foreground`:`text-muted-foreground opacity-0 hover:bg-transparent hover:text-foreground group-hover:opacity-100`:t?`text-muted-foreground hover:bg-interactive-hover/60 hover:text-foreground`:`text-muted-foreground opacity-0 hover:bg-interactive-hover/80 hover:text-foreground group-hover:opacity-100`),"aria-label":e.closeLabel??`Close ${e.label} tab`,title:e.closeLabel??`Close ${e.label} tab`,children:(0,v.jsx)(s,{name:`close`,className:`h-3 w-3`})}):null]})},e.id)},n[85]=I,n[86]=i,n[87]=b,n[88]=C,n[89]=T,n[90]=S,n[91]=x,n[92]=j,n[93]=w,n[94]=A,n[95]=h,n[96]=m,n[97]=F,n[98]=M,n[99]=e):e=n[99],X=r.map(e),n[69]=I,n[70]=i,n[71]=b,n[72]=C,n[73]=T,n[74]=S,n[75]=x,n[76]=j,n[77]=w,n[78]=A,n[79]=r,n[80]=h,n[81]=m,n[82]=F,n[83]=M,n[84]=X}else X=n[84];let Z;n[100]!==G||n[101]!==K||n[102]!==q||n[103]!==J||n[104]!==Y||n[105]!==X?(Z=(0,v.jsxs)(`div`,{ref:E,className:G,style:K,role:`tablist`,"aria-label":q,children:[J,Y,X]}),n[100]=G,n[101]=K,n[102]=q,n[103]=J,n[104]=Y,n[105]=X,n[106]=Z):Z=n[106];let it;n[107]!==H||n[108]!==U||n[109]!==W||n[110]!==Z?(it=(0,v.jsxs)(`div`,{className:H,children:[U,W,Z]}),n[107]=H,n[108]=U,n[109]=W,n[110]=Z,n[111]=it):it=n[111];let at=it;if(!Ne)return at;let ot;n[112]===Symbol.for(`react.memo_cache_sentinel`)?(ot=[re],n[112]=ot):ot=n[112];let Q;n[113]!==Oe||n[114]!==at?(Q=(0,v.jsx)(g,{items:Oe,strategy:te,children:at}),n[113]=Oe,n[114]=at,n[115]=Q):Q=n[115];let st;n[116]===Symbol.for(`react.memo_cache_sentinel`)?(st=(0,v.jsx)(d,{dropAnimation:null}),n[116]=st):st=n[116];let $;return n[117]!==Xe||n[118]!==Ie||n[119]!==Q?($=(0,v.jsxs)(f,{sensors:Ie,collisionDetection:u,onDragEnd:Xe,modifiers:ot,children:[Q,st]}),n[117]=Xe,n[118]=Ie,n[119]=Q,n[120]=$):$=n[120],$};function oe(e){return e.isMobile}function se(e){return e.id}function ce(e,t){return!e||!t?e===t:Math.abs(e.left-t.left)<.5&&Math.abs(e.top-t.top)<.5&&Math.abs(e.width-t.width)<.5&&Math.abs(e.height-t.height)<.5}function le(e){return e===null?e:null}function ue(e){return e===null?e:null}function de(e){e.button===1&&e.preventDefault()}function fe(e){e.stopPropagation()}function pe(e){e.stopPropagation()}function me(e){e.stopPropagation()}export{y as t};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{t}from"./useUIStore-CL06MzOk.js";import{nt as n,rt as r}from"./vendor-base-ui-CnHfUmDN.js";import{n as i}from"./vendor-react-DLPElpoQ.js";import{n as a}from"./clipboard-DH0BvKYH.js";import{t as o}from"./utils-DlvuQ5yV.js";import{n as s}from"./Icon-C0dydAmx.js";import{i as c}from"./OverlayScrollbar-DMQhwzR3.js";import{_ as l,l as u,n as d,s as ee,t as f,v as p,y as m}from"./vendor-dnd-kit-core-CvWxUPdb.js";import{o as h,r as te,t as g}from"./vendor-dnd-kit-sortable-hHdP9lLb.js";var ne=i(),_=e(r(),1),v=n(),re=({transform:e})=>({...e,y:0}),ie=e=>{let t=(0,ne.c)(18),{id:n,children:r,className:i}=e,a;t[0]===n?a=t[1]:(a={id:n},t[0]=n,t[1]=a);let{attributes:s,listeners:c,setNodeRef:l,transform:u,transition:d,isDragging:ee}=h(a),f;t[2]===u?f=t[3]:(f=m.Transform.toString(u),t[2]=u,t[3]=f);let p;t[4]!==f||t[5]!==d?(p={transform:f,transition:d},t[4]=f,t[5]=d,t[6]=p):p=t[6];let te=ee&&`opacity-50`,g;t[7]!==i||t[8]!==te?(g=o(`h-full rounded-md`,i,te),t[7]=i,t[8]=te,t[9]=g):g=t[9];let _;return t[10]!==s||t[11]!==r||t[12]!==n||t[13]!==c||t[14]!==l||t[15]!==p||t[16]!==g?(_=(0,v.jsx)(`div`,{ref:l,"data-sortable-tab-id":n,style:p,className:g,...s,...c,children:r}),t[10]=s,t[11]=r,t[12]=n,t[13]=c,t[14]=l,t[15]=p,t[16]=g,t[17]=_):_=t[17],_},ae=e=>{let t=(0,ne.c)(6),{id:n,children:r,className:i}=e,a;t[0]===i?a=t[1]:(a=o(`h-full`,i),t[0]=i,t[1]=a);let s;return t[2]!==r||t[3]!==n||t[4]!==a?(s=(0,v.jsx)(`div`,{className:a,"data-sortable-tab-id":n,children:r}),t[2]=r,t[3]=n,t[4]=a,t[5]=s):s=t[5],s},y=e=>{let n=(0,ne.c)(121),{items:r,activeId:i,onSelect:m,onClose:h,onReorder:y,layoutMode:he,variant:ge,activePillInsetClassName:_e,activePillButtonClassName:b,inactiveTabsIconOnly:ve,iconOnlyActiveTab:ye,animateActivePill:be,activePillLowercase:xe,className:Se}=e,Ce=he===void 0?`scrollable`:he,we=ge===void 0?`default`:ge,x=ve!==void 0&&ve,S=ye!==void 0&&ye,C=xe===void 0||xe,{t:Te}=a(),w=t(oe),{isTablet:Ee}=c(),T=w||Ee,E=_.useRef(null),De;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(De={left:!1,right:!1},n[0]=De):De=n[0];let[D,O]=_.useState(De),k;n[1]===r?k=n[2]:(k=r.map(se),n[1]=r,n[2]=k);let Oe=k,A=Ce===`scrollable`,ke=we==="default",j=we===`active-pill`,Ae=we===`animated`,M=j||Ae,N=ke,P=M||N,F=j&&A,je=M,Me=be??Ae,Ne=typeof y==`function`,I=Ne?ie:ae,L;n[3]===Symbol.for(`react.memo_cache_sentinel`)?(L=new Map,n[3]=L):L=n[3];let R=_.useRef(L),[z,Pe]=_.useState(null),Fe;n[4]===Symbol.for(`react.memo_cache_sentinel`)?(Fe={activationConstraint:{distance:8}},n[4]=Fe):Fe=n[4];let Ie=p(l(ee,Fe)),Le=ce,Re;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(Re=(e,t)=>{if(t){R.current.set(e,t);return}R.current.delete(e)},n[5]=Re):Re=n[5];let ze=Re,Be;n[6]!==i||n[7]!==P?(Be=()=>{if(!P||!i){Pe(le);return}let e=E.current,t=R.current.get(i);if(!e||!t){Pe(ue);return}let n=0,r=0,a=t;for(;a&&a!==e;)n+=a.offsetLeft,r+=a.offsetTop,a=a.offsetParent;let o={left:n,top:r,width:t.offsetWidth,height:t.offsetHeight};Pe(e=>Le(e,o)?e:o)},n[6]=i,n[7]=P,n[8]=Be):Be=n[8];let B=Be,Ve;n[9]===A?Ve=n[10]:(Ve=()=>{if(!A){O({left:!1,right:!1});return}let e=E.current;if(!e){O({left:!1,right:!1});return}O({left:e.scrollLeft>2,right:e.scrollLeft+e.clientWidth<e.scrollWidth-2})},n[9]=A,n[10]=Ve);let V=Ve,He;n[11]!==A||n[12]!==V?(He=()=>{if(!A){O({left:!1,right:!1});return}let e=E.current;if(!e)return;V(),e.addEventListener(`scroll`,V,{passive:!0});let t=new ResizeObserver(V);return t.observe(e),()=>{e.removeEventListener(`scroll`,V),t.disconnect()}},n[11]=A,n[12]=V,n[13]=He):He=n[13];let Ue;n[14]!==A||n[15]!==r.length||n[16]!==V?(Ue=[A,r.length,V],n[14]=A,n[15]=r.length,n[16]=V,n[17]=Ue):Ue=n[17],_.useEffect(He,Ue);let We;n[18]!==i||n[19]!==B||n[20]!==P?(We=()=>{if(!P){Pe(null);return}B();let e=E.current;if(!e)return;let t=new ResizeObserver(B);if(t.observe(e),i){let e=R.current.get(i);e&&t.observe(e)}return()=>{t.disconnect()}},n[18]=i,n[19]=B,n[20]=P,n[21]=We):We=n[21];let Ge;n[22]!==i||n[23]!==r.length||n[24]!==B||n[25]!==P?(Ge=[i,r.length,B,P],n[22]=i,n[23]=r.length,n[24]=B,n[25]=P,n[26]=Ge):Ge=n[26],_.useEffect(We,Ge);let Ke;n[27]===B?Ke=n[28]:(Ke=()=>{B()},n[27]=B,n[28]=Ke),_.useLayoutEffect(Ke);let qe;n[29]!==i||n[30]!==A||n[31]!==V?(qe=()=>{if(!A||!i)return;let e=E.current;if(!e)return;let t=window.requestAnimationFrame(()=>{let t=typeof window.CSS?.escape==`function`?window.CSS.escape(i):i.replace(/"/g,`\\"`),n=e.querySelector(`[data-sortable-tab-id="${t}"]`);n&&(n.scrollIntoView({block:`nearest`,inline:`nearest`}),V())});return()=>{window.cancelAnimationFrame(t)}},n[29]=i,n[30]=A,n[31]=V,n[32]=qe):qe=n[32];let Je;n[33]!==i||n[34]!==A||n[35]!==r.length||n[36]!==V?(Je=[i,A,r.length,V],n[33]=i,n[34]=A,n[35]=r.length,n[36]=V,n[37]=Je):Je=n[37],_.useEffect(qe,Je);let Ye;n[38]===y?Ye=n[39]:(Ye=e=>{if(!y)return;let{active:t,over:n}=e;!n||t.id===n.id||y(String(t.id),String(n.id))},n[38]=y,n[39]=Ye);let Xe=Ye,H;n[40]===Se?H=n[41]:(H=o(`relative flex h-full min-w-0 flex-1`,Se),n[40]=Se,n[41]=H);let U;n[42]!==A||n[43]!==D||n[44]!==M?(U=A&&D.left?(0,v.jsx)(`div`,{className:o(`pointer-events-none absolute inset-y-0 left-0 z-20 bg-gradient-to-r to-transparent`,M?`w-8 from-[var(--surface-background)]`:`w-6 from-background`)}):null,n[42]=A,n[43]=D,n[44]=M,n[45]=U):U=n[45];let W;n[46]!==A||n[47]!==D||n[48]!==M?(W=A&&D.right?(0,v.jsx)(`div`,{className:o(`pointer-events-none absolute inset-y-0 right-0 z-20 bg-gradient-to-l to-transparent`,M?`w-8 from-[var(--surface-background)]`:`w-6 from-background`)}):null,n[46]=A,n[47]=D,n[48]=M,n[49]=W):W=n[49];let Ze=M?`items-center overflow-x-hidden overflow-y-hidden`:`items-stretch`,Qe=M&&`@container/pill-tabs`,$e=M&&`pill-tabs__track`,et=M&&(_e??`gap-0.5 py-0.5`),tt=N&&`items-center overflow-y-hidden`,nt=je&&`rounded-[10px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] bg-[color-mix(in_srgb,var(--foreground)_2%,transparent)] p-0.5 gap-0.5`,rt=A?`overflow-x-auto scrollbar-none`:`overflow-x-hidden`,G;n[50]!==Ze||n[51]!==Qe||n[52]!==$e||n[53]!==et||n[54]!==tt||n[55]!==nt||n[56]!==rt?(G=o(`relative flex h-full min-w-0 flex-1`,Ze,Qe,$e,et,tt,nt,rt),n[50]=Ze,n[51]=Qe,n[52]=$e,n[53]=et,n[54]=tt,n[55]=nt,n[56]=rt,n[57]=G):G=n[57];let K;n[58]===A?K=n[59]:(K=A?{scrollbarWidth:`none`,msOverflowStyle:`none`}:void 0,n[58]=A,n[59]=K);let q;n[60]===Te?q=n[61]:(q=Te(`sortableTabsStrip.aria.tabs`),n[60]=Te,n[61]=q);let J;n[62]!==z||n[63]!==Me||n[64]!==M?(J=M&&z?(0,v.jsx)(`div`,{className:o(`oc-segmented-selected-pill pointer-events-none absolute left-0 top-0 z-0 rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px]`),style:{transform:`translate3d(${z.left}px, ${z.top}px, 0)`,width:`${z.width}px`,height:`${z.height}px`,transition:Me?`transform 300ms cubic-bezier(0.65, 0, 0.35, 1), width 300ms cubic-bezier(0.65, 0, 0.35, 1), height 300ms cubic-bezier(0.65, 0, 0.35, 1)`:void 0}}):null,n[62]=z,n[63]=Me,n[64]=M,n[65]=J):J=n[65];let Y;n[66]!==z||n[67]!==N?(Y=N&&z?(0,v.jsx)(`div`,{className:`pointer-events-none absolute left-0 -bottom-px z-10 h-[3px] rounded-t-[2px] bg-[var(--primary-base)]`,style:{transform:`translate3d(${z.left}px, 0, 0)`,width:`${z.width}px`},"aria-hidden":!0}):null,n[66]=z,n[67]=N,n[68]=Y):Y=n[68];let X;if(n[69]!==I||n[70]!==i||n[71]!==b||n[72]!==C||n[73]!==T||n[74]!==S||n[75]!==x||n[76]!==j||n[77]!==w||n[78]!==A||n[79]!==r||n[80]!==h||n[81]!==m||n[82]!==F||n[83]!==M){let e;n[85]!==I||n[86]!==i||n[87]!==b||n[88]!==C||n[89]!==T||n[90]!==S||n[91]!==x||n[92]!==j||n[93]!==w||n[94]!==A||n[95]!==h||n[96]!==m||n[97]!==F||n[98]!==M?(e=e=>{let t=e.id===i,n=x&&M&&!t&&!!e.icon,r=!n,a=!!e.icon&&(!S||t),c=x&&M&&t&&!A&&!F,l=e.closable!==!1&&!!h,u=l&&!!e.icon,d=A||F?void 0:M?c?`flex-none basis-auto`:w?`flex-1 basis-0 min-w-0`:`flex-1 basis-0 min-w-fit`:`min-w-0 flex-1 basis-0`,ee=l?t=>{t.button===1&&(t.preventDefault(),t.stopPropagation(),h?.(e.id))}:void 0,f=l?de:void 0;return(0,v.jsx)(I,{id:e.id,className:d,children:(0,v.jsxs)(`div`,{ref:t=>ze(e.id,t),onAuxClick:ee,onMouseDown:f,className:o(`group flex h-full min-w-0 flex-nowrap items-center`,A||F?`shrink-0`:M?`w-full`:`w-full min-w-0`,M?`relative z-10 bg-transparent`:t?`relative z-10 bg-transparent text-foreground`:`relative z-10 bg-transparent text-muted-foreground hover:text-foreground`),children:[(0,v.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":t,"aria-label":n?e.title??e.label:void 0,onClick:()=>m(e.id),className:o(M?`animated-tabs__button pill-tabs__button relative z-10 flex flex-1 min-w-0 flex-nowrap items-center justify-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] text-sm font-medium transition-colors duration-150 !min-h-0`:`flex h-full min-w-0 flex-nowrap items-center typography-micro`,M&&C?`lowercase`:null,M&&(n?`gap-0`:`gap-1.5`),M?F?`shrink-0 whitespace-nowrap px-3 text-center`:A?`max-w-56 shrink-0 px-3 text-center`:n?`px-2 !min-w-0 text-center`:c?`shrink-0 whitespace-nowrap px-3 text-center`:`px-3 text-center`:A?`max-w-56 justify-start truncate px-3 text-left`:`w-full justify-center truncate px-3 text-center`,M?b??(j?w?`h-[38px]`:`h-[31px]`:`h-7`):null,M?t?`text-foreground`:`text-muted-foreground hover:text-foreground`:null,M?`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] focus-visible:ring-offset-1 focus-visible:ring-offset-background`:null),title:e.title??e.label,children:M?(0,v.jsxs)(v.Fragment,{children:[a?(0,v.jsxs)(`span`,{className:`relative flex h-4 w-4 shrink-0 items-center justify-center`,children:[(0,v.jsx)(`span`,{className:o(`flex items-center justify-center transition-opacity`,u&&(T?`opacity-0`:`group-hover:opacity-0`)),children:e.icon}),u?(0,v.jsx)(`span`,{role:`button`,tabIndex:-1,className:o(`absolute inset-0 z-20 flex !min-h-0 !min-w-0 items-center justify-center rounded-sm text-muted-foreground transition-opacity hover:text-foreground`,T?`opacity-100`:`opacity-0 group-hover:opacity-100`),onPointerDown:fe,onClick:t=>{t.stopPropagation(),h?.(e.id)},"aria-label":e.closeLabel??`Close ${e.label} tab`,title:e.closeLabel??`Close ${e.label} tab`,children:(0,v.jsx)(s,{name:`close`,className:`h-3.5 w-3.5`})}):null]}):null,r?(0,v.jsx)(`span`,{className:`animated-tabs__label truncate`,children:e.label}):null]}):(0,v.jsxs)(`span`,{className:o(`flex min-w-0 flex-nowrap items-center gap-1.5`,!A&&`justify-center`),children:[a?(0,v.jsxs)(`span`,{className:o(`relative flex h-4 w-4 shrink-0 items-center justify-center transition-colors duration-200 ease-out`,t?`text-[var(--primary-base)]`:`text-muted-foreground`),children:[(0,v.jsx)(`span`,{className:o(`flex items-center justify-center transition-opacity`,u&&(T?`opacity-0`:`group-hover:opacity-0`)),children:e.icon}),u?(0,v.jsx)(`span`,{role:`button`,tabIndex:-1,className:o(`absolute inset-0 z-20 flex !min-h-0 !min-w-0 items-center justify-center rounded-sm text-muted-foreground transition-opacity hover:text-foreground`,T?`opacity-100`:`opacity-0 group-hover:opacity-100`),onPointerDown:pe,onClick:t=>{t.stopPropagation(),h?.(e.id)},"aria-label":e.closeLabel??`Close ${e.label} tab`,title:e.closeLabel??`Close ${e.label} tab`,children:(0,v.jsx)(s,{name:`close`,className:`h-3.5 w-3.5`})}):null]}):null,(0,v.jsx)(`span`,{className:`truncate leading-[1.2]`,children:e.label})]})}),l&&!u?(0,v.jsx)(`button`,{type:`button`,onPointerDown:me,onClick:t=>{t.stopPropagation(),h?.(e.id)},className:o(`relative z-20 inline-flex !min-h-0 !min-w-0 items-center justify-center transition-opacity`,M?`-ml-2.5 mr-1 h-[88%] w-5 self-center !aspect-auto rounded-md`:`aspect-square h-[65%] min-h-4 max-h-5 rounded-sm mr-1`,M?t?`text-muted-foreground hover:bg-transparent hover:text-foreground`:`text-muted-foreground opacity-0 hover:bg-transparent hover:text-foreground group-hover:opacity-100`:t?`text-muted-foreground hover:bg-interactive-hover/60 hover:text-foreground`:`text-muted-foreground opacity-0 hover:bg-interactive-hover/80 hover:text-foreground group-hover:opacity-100`),"aria-label":e.closeLabel??`Close ${e.label} tab`,title:e.closeLabel??`Close ${e.label} tab`,children:(0,v.jsx)(s,{name:`close`,className:`h-3 w-3`})}):null]})},e.id)},n[85]=I,n[86]=i,n[87]=b,n[88]=C,n[89]=T,n[90]=S,n[91]=x,n[92]=j,n[93]=w,n[94]=A,n[95]=h,n[96]=m,n[97]=F,n[98]=M,n[99]=e):e=n[99],X=r.map(e),n[69]=I,n[70]=i,n[71]=b,n[72]=C,n[73]=T,n[74]=S,n[75]=x,n[76]=j,n[77]=w,n[78]=A,n[79]=r,n[80]=h,n[81]=m,n[82]=F,n[83]=M,n[84]=X}else X=n[84];let Z;n[100]!==G||n[101]!==K||n[102]!==q||n[103]!==J||n[104]!==Y||n[105]!==X?(Z=(0,v.jsxs)(`div`,{ref:E,className:G,style:K,role:`tablist`,"aria-label":q,children:[J,Y,X]}),n[100]=G,n[101]=K,n[102]=q,n[103]=J,n[104]=Y,n[105]=X,n[106]=Z):Z=n[106];let it;n[107]!==H||n[108]!==U||n[109]!==W||n[110]!==Z?(it=(0,v.jsxs)(`div`,{className:H,children:[U,W,Z]}),n[107]=H,n[108]=U,n[109]=W,n[110]=Z,n[111]=it):it=n[111];let at=it;if(!Ne)return at;let ot;n[112]===Symbol.for(`react.memo_cache_sentinel`)?(ot=[re],n[112]=ot):ot=n[112];let Q;n[113]!==Oe||n[114]!==at?(Q=(0,v.jsx)(g,{items:Oe,strategy:te,children:at}),n[113]=Oe,n[114]=at,n[115]=Q):Q=n[115];let st;n[116]===Symbol.for(`react.memo_cache_sentinel`)?(st=(0,v.jsx)(d,{dropAnimation:null}),n[116]=st):st=n[116];let $;return n[117]!==Xe||n[118]!==Ie||n[119]!==Q?($=(0,v.jsxs)(f,{sensors:Ie,collisionDetection:u,onDragEnd:Xe,modifiers:ot,children:[Q,st]}),n[117]=Xe,n[118]=Ie,n[119]=Q,n[120]=$):$=n[120],$};function oe(e){return e.isMobile}function se(e){return e.id}function ce(e,t){return!e||!t?e===t:Math.abs(e.left-t.left)<.5&&Math.abs(e.top-t.top)<.5&&Math.abs(e.width-t.width)<.5&&Math.abs(e.height-t.height)<.5}function le(e){return e===null?e:null}function ue(e){return e===null?e:null}function de(e){e.button===1&&e.preventDefault()}function fe(e){e.stopPropagation()}function pe(e){e.stopPropagation()}function me(e){e.stopPropagation()}export{y as t};
@@ -1 +1 @@
1
- import{F as e,W as t}from"./useUIStore-5agS8bsW.js";import{kn as n}from"./persistence-ZSrLIR97.js";import{St as r}from"./platform-BiSk9jV3.js";var i=1,a=1,o=0,s=`/api/terminal/ws`,c=1200,l=250,u=2e4,d=5e3,f=`__openchamberTerminalTransportState`,p=new TextEncoder,m=new TextDecoder,h=t=>e().websocket(t),g=e=>{let t=p.encode(JSON.stringify(e)),n=new Uint8Array(t.length+1);return n[0]=i,n.set(t,1),n},_=e=>e?((e.transports??[]).includes(`ws`)||e.preferred===`ws`)&&typeof e.ws?.path==`string`&&e.ws.path.length>0:!1,v=e=>e.streamCapability?.ws?.path??e.inputCapability?.ws?.path??s,y=e=>{switch(e){case`SESSION_NOT_FOUND`:return Error(`Terminal session not found`);case`NOT_BOUND`:return Error(`Terminal session is not bound`);case`WRITE_FAIL`:return Error(`Failed to write to terminal`);case`RATE_LIMIT`:return Error(`Terminal websocket is rate limited`);case`BAD_FRAME`:return Error(`Terminal websocket protocol violation`);default:return Error(`Terminal websocket error`)}},b=class{socket=null;socketUrl=``;boundSessionId=null;requestedSessionId=null;openPromise=null;reconnectTimeout=null;keepaliveInterval=null;closed=!1;subscriptions=new Map;activeSubscriptionToken=null;replayCursorBySession=new Map;configure(e){if(e){if(this.socketUrl===e){this.closed=!1,this.isConnectedOrConnecting()||this.ensureConnected();return}this.socketUrl=e,this.closed=!1,this.resetConnection(),this.ensureConnected()}}subscribe(e,t,n,r){let i=Symbol(e),o={token:i,sessionId:e,onEvent:t,onError:n,maxRetries:r?.maxRetries??3,initialRetryDelay:r?.initialRetryDelay??1e3,maxRetryDelay:r?.maxRetryDelay??8e3,connectionTimeout:r?.connectionTimeout??1e4,retryCount:0,connected:!1,connectionTimeoutId:null};return this.subscriptions.set(i,o),this.activeSubscriptionToken=i,this.requestedSessionId=e,this.ensureConnected(),this.boundSessionId===e&&this.socket&&this.socket.readyState===a?(o.retryCount=0,o.connected=!0,o.onEvent({type:`connected`})):(this.boundSessionId=null,this.startConnectionTimeout(o),this.bindActiveSession()),()=>{if(this.clearConnectionTimeout(o),this.subscriptions.delete(i),this.activeSubscriptionToken===i&&(this.activeSubscriptionToken=null),this.hasSubscriptionForSession(e)||(this.boundSessionId===e&&(this.boundSessionId=null),this.requestedSessionId===e&&(this.requestedSessionId=null)),this.subscriptions.size===0){this.clearReconnectTimeout(),this.resetConnection();return}this.promoteActiveSubscription()}}async sendInput(e,t){if(!e||!t||this.closed||!this.socketUrl)return!1;let n=await this.getOpenSocket(c);if(!n||n.readyState!==a)return!1;try{return this.boundSessionId!==e&&(this.requestedSessionId=e,n.send(g({t:`b`,s:e,r:this.replayCursorBySession.get(e)??0,v:2}))),n.send(t),!0}catch{return this.handleSocketFailure(Error(`Terminal websocket send failed`)),!1}}unbindSession(e){e&&(this.boundSessionId===e&&(this.boundSessionId=null),this.requestedSessionId===e&&(this.requestedSessionId=null))}close(){this.closed=!0,this.clearReconnectTimeout();for(let e of this.subscriptions.values())this.clearConnectionTimeout(e);this.resetConnection(),this.socketUrl=``,this.subscriptions.clear(),this.activeSubscriptionToken=null,this.replayCursorBySession.clear()}prime(){this.closed||!this.socketUrl||this.isConnectedOrConnecting()||this.ensureConnected()}isConnectedOrConnecting(e){return this.closed||e&&this.socketUrl!==e?!1:this.socket&&(this.socket.readyState===a||this.socket.readyState===o)?!0:this.openPromise!==null}getActiveSubscription(){return this.activeSubscriptionToken?this.subscriptions.get(this.activeSubscriptionToken)??null:null}hasSubscriptionForSession(e){for(let t of this.subscriptions.values())if(t.sessionId===e)return!0;return!1}promoteActiveSubscription(){if(this.getActiveSubscription())return;let e=this.subscriptions.values().next().value;if(!e){this.activeSubscriptionToken=null;return}this.activeSubscriptionToken=e.token,this.requestedSessionId=e.sessionId,this.boundSessionId===e.sessionId?e.connected||(e.retryCount=0,e.connected=!0,this.clearConnectionTimeout(e),e.onEvent({type:`connected`})):(this.boundSessionId=null,this.startConnectionTimeout(e),this.bindActiveSession())}emitToSession(e,t){for(let n of this.subscriptions.values())n.sessionId===e&&n.onEvent(t)}markSessionConnected(e,t){for(let n of this.subscriptions.values())n.sessionId===e&&(n.retryCount=0,n.connected=!0,this.clearConnectionTimeout(n),n.onEvent(t))}emitErrorToSession(e,t,n){for(let r of this.subscriptions.values())r.sessionId===e&&(r.connected=!1,n&&this.clearConnectionTimeout(r),r.onError?.(t,n))}startConnectionTimeout(e){this.clearConnectionTimeout(e),e.connectionTimeoutId=setTimeout(()=>{e.connected||!this.subscriptions.has(e.token)||this.getActiveSubscription()?.token===e.token&&this.handleSocketFailure(Error(`Connection timeout`))},e.connectionTimeout)}clearConnectionTimeout(e){e.connectionTimeoutId&&=(clearTimeout(e.connectionTimeoutId),null)}async getOpenSocket(e){if(this.socket&&this.socket.readyState===a||(this.ensureConnected(),this.socket&&this.socket.readyState===a))return this.socket;let t=await Promise.race([this.openPromise??Promise.resolve(null),new Promise(t=>{setTimeout(()=>t(null),e)})]);return t&&t.readyState===a?t:this.socket&&this.socket.readyState===a?this.socket:null}ensureConnected(){this.closed||!this.socketUrl||this.socket&&(this.socket.readyState===a||this.socket.readyState===o)||(this.openPromise||=(this.clearReconnectTimeout(),(async()=>{try{await t()}catch{}return new Promise(e=>{let t=!1,n=null,i=r=>{t||(t=!0,n&&=(clearTimeout(n),null),this.openPromise=null,e(r))};try{let e=r(h(this.socketUrl));e.binaryType=`arraybuffer`,e.onopen=()=>{this.socket=e,this.startKeepalive(),i(e)},e.onmessage=e=>{this.handleSocketMessage(e.data)},e.onerror=()=>{!this.closed&&!this.getActiveSubscription()&&this.scheduleReconnect(Error(`Terminal websocket error`))},e.onclose=()=>{this.socket===e&&(this.socket=null,this.boundSessionId=null,this.stopKeepalive(),this.closed||this.scheduleReconnect(Error(`Terminal stream connection error`))),i(null)},this.socket=e,n=setTimeout(()=>{e.readyState===o&&(e.close(),i(null))},d)}catch{i(null),this.closed||this.scheduleReconnect(Error(`Terminal websocket open failed`))}})})()))}bindActiveSession(){let e=this.getActiveSubscription();if(!(!e||!this.socket||this.socket.readyState!==a)){this.requestedSessionId=e.sessionId;try{this.socket.send(g({t:`b`,s:e.sessionId,r:this.replayCursorBySession.get(e.sessionId)??0,v:2}))}catch{this.handleSocketFailure(Error(`Terminal websocket bind failed`))}}}scheduleReconnect(e){if(this.closed||!this.socketUrl||this.reconnectTimeout)return;this.promoteActiveSubscription();let t=this.getActiveSubscription();if(!t)return;let n=t.retryCount+1,r=t.initialRetryDelay,i=t.maxRetryDelay,a=t.maxRetries;if(n>a){this.clearConnectionTimeout(t),this.emitErrorToSession(t.sessionId,e,!0);return}t.retryCount=n;for(let e of this.subscriptions.values())e.sessionId===t.sessionId&&(e.connected=!1,e.retryCount=n,e.onEvent({type:`reconnecting`,attempt:n,maxAttempts:a}));this.startConnectionTimeout(t);let o=Math.min(r*2**Math.max(n-1,0),i)+Math.floor(Math.random()*l);this.reconnectTimeout=setTimeout(()=>{this.reconnectTimeout=null,this.ensureConnected(),this.bindActiveSession()},o)}clearReconnectTimeout(){this.reconnectTimeout&&=(clearTimeout(this.reconnectTimeout),null)}sendControl(e){if(!this.socket||this.socket.readyState!==a)return!1;try{return this.socket.send(g(e)),!0}catch{return this.handleSocketFailure(Error(`Terminal websocket control send failed`)),!1}}startKeepalive(){this.stopKeepalive(),this.keepaliveInterval=setInterval(()=>{this.closed||this.sendControl({t:`p`,v:2})},u)}stopKeepalive(){this.keepaliveInterval&&=(clearInterval(this.keepaliveInterval),null)}async handleSocketMessage(e){let t=await this.asUint8Array(e);if(t&&t.length>0&&t[0]===i){this.handleControlMessage(t);return}let n=await this.asText(e);if(!n)return;let r=this.boundSessionId??this.requestedSessionId??this.getActiveSubscription()?.sessionId;r&&this.emitToSession(r,{type:`data`,data:n})}handleControlMessage(e){if(e.length<2)return;let t;try{t=JSON.parse(m.decode(e.subarray(1)))}catch{this.handleSocketFailure(Error(`Terminal websocket control parse failed`));return}let n=this.getActiveSubscription();switch(t.t){case`ok`:this.bindActiveSession();return;case`po`:return;case`d`:{let e=t.s??this.boundSessionId??this.requestedSessionId;if(!e)return;typeof t.i==`number`&&Number.isFinite(t.i)&&this.replayCursorBySession.set(e,Math.max(this.replayCursorBySession.get(e)??0,Math.trunc(t.i))),typeof t.d==`string`&&t.d.length>0&&this.emitToSession(e,{type:`data`,data:t.d});return}case`bok`:{let e=t.s??this.requestedSessionId;if(this.boundSessionId=e,!e)return;this.markSessionConnected(e,{type:`connected`,runtime:t.runtime,ptyBackend:t.ptyBackend});return}case`x`:{let e=t.s??this.boundSessionId??n?.sessionId??null;if(!e){this.boundSessionId=null;return}this.boundSessionId===e&&(this.boundSessionId=null),this.requestedSessionId===e&&(this.requestedSessionId=null),this.replayCursorBySession.delete(e);for(let n of this.subscriptions.values())n.sessionId===e&&(n.connected=!1,this.clearConnectionTimeout(n),n.onEvent({type:`exit`,exitCode:t.exitCode,signal:t.signal??null}));return}case`e`:{let e=y(t.c),r=t.f===!0;(t.c===`NOT_BOUND`||t.c===`SESSION_NOT_FOUND`)&&(this.boundSessionId=null);let i=t.s??this.requestedSessionId??n?.sessionId??null;if(i){if(t.c===`SESSION_NOT_FOUND`){this.emitErrorToSession(i,e,!0);return}this.emitErrorToSession(i,e,r)}else n&&(n.connected=!1,r&&this.clearConnectionTimeout(n),n.onError?.(e,r));t.f===!0&&this.handleSocketFailure(e);return}default:return}}async asUint8Array(e){if(e instanceof ArrayBuffer)return new Uint8Array(e);if(e instanceof Uint8Array)return e;if(typeof Blob<`u`&&e instanceof Blob){let t=await e.arrayBuffer();return new Uint8Array(t)}return null}async asText(e){if(typeof e==`string`)return e;let t=await this.asUint8Array(e);return t?m.decode(t):``}handleSocketFailure(e){this.boundSessionId=null,this.requestedSessionId=null,this.resetConnection(),this.scheduleReconnect(e)}resetConnection(){if(this.openPromise=null,this.stopKeepalive(),this.socket){let e=this.socket;this.socket=null,e.onopen=null,e.onmessage=null,e.onerror=null,e.onclose=null,(e.readyState===a||e.readyState===o)&&e.close()}this.boundSessionId=null}},x=()=>{let e=globalThis;return e[f]||(e[f]={inputCapability:null,streamCapability:null,manager:null}),e[f]},S=()=>{let e=x();return e.manager||=new b,e.manager},C=e=>{let t=x();if(t.inputCapability=e?.input??null,t.streamCapability=e?.stream??null,!_(t.inputCapability)&&!_(t.streamCapability)){t.manager?.close(),t.manager=null;return}let n=h(v(t));n&&S().configure(n)},w=async(e,t)=>{let r=await n(`/api/terminal/${e}/input`,{method:`POST`,headers:{"Content-Type":`text/plain`},body:t});if(!r.ok){let e=await r.json().catch(()=>({error:`Failed to send terminal input`}));throw Error(e.error||`Failed to send terminal input`)}};async function T(e){let t=await n(`/api/terminal/create`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({cwd:e.cwd,cols:e.cols??80,rows:e.rows??24})});if(!t.ok){let e=await t.json().catch(()=>({error:`Failed to create terminal`}));throw Error(e.error||`Failed to create terminal session`)}let r=await t.json();return C(r.capabilities),r}var E=(t,n,r,i={})=>{let a=i.maxRetries??3,o=i.initialRetryDelay??1e3,s=i.maxRetryDelay??8e3,c=i.connectionTimeout??1e4,l=null,u=0,d=null,f=null,p=!1,m=!1,h=()=>{d&&=(clearTimeout(d),null),f&&=(clearTimeout(f),null)},g=()=>{p||(p=!0,h(),l&&=(l.close(),null))},_=(e,t)=>{if(!(p||m)){if(u<a&&!t){u+=1;let e=Math.min(o*2**(u-1),s);n({type:`reconnecting`,attempt:u,maxAttempts:a}),d=setTimeout(()=>{!p&&!m&&v()},e);return}r?.(e,!0),g()}},v=()=>{if(p||m||l&&l.readyState!==EventSource.CLOSED)return;l=new EventSource(e().sse(`/api/terminal/${t}/stream`));let i=!1;f=setTimeout(()=>{!i&&l?.readyState!==EventSource.OPEN&&(l?.close(),_(Error(`Connection timeout`),!1))},c),l.onopen=()=>{i||(i=!0,u=0,h(),n({type:`connected`}))},l.onmessage=e=>{try{let r=JSON.parse(e.data);r.type===`exit`&&(x().manager?.unbindSession(t),m=!0,g()),n(r)}catch(e){r?.(e,!1)}},l.onerror=()=>{h();let e=m||l?.readyState===EventSource.CLOSED;l?.close(),l=null,m||_(Error(`Terminal stream connection error`),e)}};return v(),g};function D(e,t,n,r={}){let i=x();if(i.streamCapability&&!_(i.streamCapability))return E(e,t,n,r);let a=S(),o=h(v(i));return o?(a.configure(o),a.subscribe(e,t,n,r)):E(e,t,n,r)}async function O(e,t){let n=x();n.manager&&await n.manager.sendInput(e,t)||await w(e,t)}async function k(e,t,r){let i=await n(`/api/terminal/${e}/resize`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({cols:t,rows:r})});if(!i.ok){let e=await i.json().catch(()=>({error:`Failed to resize terminal`}));throw Error(e.error||`Failed to resize terminal`)}}async function A(e){x().manager?.unbindSession(e);let t=await n(`/api/terminal/${e}`,{method:`DELETE`});if(!t.ok){let e=await t.json().catch(()=>({error:`Failed to close terminal`}));throw Error(e.error||`Failed to close terminal`)}}async function j(e,t){x().manager?.unbindSession(e);let r=await n(`/api/terminal/${e}/restart`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({cwd:t.cwd,cols:t.cols??80,rows:t.rows??24})});if(!r.ok){let e=await r.json().catch(()=>({error:`Failed to restart terminal`}));throw Error(e.error||`Failed to restart terminal`)}let i=await r.json();return C(i.capabilities),i}async function M(e){let t=await n(`/api/terminal/force-kill`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok){let e=await t.json().catch(()=>({error:`Failed to force kill terminal`}));throw Error(e.error||`Failed to force kill terminal`)}e.sessionId&&x().manager?.unbindSession(e.sessionId)}function N(){let e=x();e.manager?.close(),e.manager=null,e.inputCapability=null,e.streamCapability=null}function P(){let e=x();if(e.inputCapability&&e.streamCapability&&!_(e.inputCapability)&&!_(e.streamCapability))return;let t=h(v(e)||s);if(!t)return;let n=S();n.isConnectedOrConnecting(t)||(n.configure(t),n.prime())}export{M as a,j as c,N as i,O as l,D as n,P as o,T as r,k as s,A as t};
1
+ import{F as e,W as t}from"./useUIStore-CL06MzOk.js";import{kn as n}from"./persistence-Cm9DnxXq.js";import{St as r}from"./platform-BrOZ1tqx.js";var i=1,a=1,o=0,s=`/api/terminal/ws`,c=1200,l=250,u=2e4,d=5e3,f=`__openchamberTerminalTransportState`,p=new TextEncoder,m=new TextDecoder,h=t=>e().websocket(t),g=e=>{let t=p.encode(JSON.stringify(e)),n=new Uint8Array(t.length+1);return n[0]=i,n.set(t,1),n},_=e=>e?((e.transports??[]).includes(`ws`)||e.preferred===`ws`)&&typeof e.ws?.path==`string`&&e.ws.path.length>0:!1,v=e=>e.streamCapability?.ws?.path??e.inputCapability?.ws?.path??s,y=e=>{switch(e){case`SESSION_NOT_FOUND`:return Error(`Terminal session not found`);case`NOT_BOUND`:return Error(`Terminal session is not bound`);case`WRITE_FAIL`:return Error(`Failed to write to terminal`);case`RATE_LIMIT`:return Error(`Terminal websocket is rate limited`);case`BAD_FRAME`:return Error(`Terminal websocket protocol violation`);default:return Error(`Terminal websocket error`)}},b=class{socket=null;socketUrl=``;boundSessionId=null;requestedSessionId=null;openPromise=null;reconnectTimeout=null;keepaliveInterval=null;closed=!1;subscriptions=new Map;activeSubscriptionToken=null;replayCursorBySession=new Map;configure(e){if(e){if(this.socketUrl===e){this.closed=!1,this.isConnectedOrConnecting()||this.ensureConnected();return}this.socketUrl=e,this.closed=!1,this.resetConnection(),this.ensureConnected()}}subscribe(e,t,n,r){let i=Symbol(e),o={token:i,sessionId:e,onEvent:t,onError:n,maxRetries:r?.maxRetries??3,initialRetryDelay:r?.initialRetryDelay??1e3,maxRetryDelay:r?.maxRetryDelay??8e3,connectionTimeout:r?.connectionTimeout??1e4,retryCount:0,connected:!1,connectionTimeoutId:null};return this.subscriptions.set(i,o),this.activeSubscriptionToken=i,this.requestedSessionId=e,this.ensureConnected(),this.boundSessionId===e&&this.socket&&this.socket.readyState===a?(o.retryCount=0,o.connected=!0,o.onEvent({type:`connected`})):(this.boundSessionId=null,this.startConnectionTimeout(o),this.bindActiveSession()),()=>{if(this.clearConnectionTimeout(o),this.subscriptions.delete(i),this.activeSubscriptionToken===i&&(this.activeSubscriptionToken=null),this.hasSubscriptionForSession(e)||(this.boundSessionId===e&&(this.boundSessionId=null),this.requestedSessionId===e&&(this.requestedSessionId=null)),this.subscriptions.size===0){this.clearReconnectTimeout(),this.resetConnection();return}this.promoteActiveSubscription()}}async sendInput(e,t){if(!e||!t||this.closed||!this.socketUrl)return!1;let n=await this.getOpenSocket(c);if(!n||n.readyState!==a)return!1;try{return this.boundSessionId!==e&&(this.requestedSessionId=e,n.send(g({t:`b`,s:e,r:this.replayCursorBySession.get(e)??0,v:2}))),n.send(t),!0}catch{return this.handleSocketFailure(Error(`Terminal websocket send failed`)),!1}}unbindSession(e){e&&(this.boundSessionId===e&&(this.boundSessionId=null),this.requestedSessionId===e&&(this.requestedSessionId=null))}close(){this.closed=!0,this.clearReconnectTimeout();for(let e of this.subscriptions.values())this.clearConnectionTimeout(e);this.resetConnection(),this.socketUrl=``,this.subscriptions.clear(),this.activeSubscriptionToken=null,this.replayCursorBySession.clear()}prime(){this.closed||!this.socketUrl||this.isConnectedOrConnecting()||this.ensureConnected()}isConnectedOrConnecting(e){return this.closed||e&&this.socketUrl!==e?!1:this.socket&&(this.socket.readyState===a||this.socket.readyState===o)?!0:this.openPromise!==null}getActiveSubscription(){return this.activeSubscriptionToken?this.subscriptions.get(this.activeSubscriptionToken)??null:null}hasSubscriptionForSession(e){for(let t of this.subscriptions.values())if(t.sessionId===e)return!0;return!1}promoteActiveSubscription(){if(this.getActiveSubscription())return;let e=this.subscriptions.values().next().value;if(!e){this.activeSubscriptionToken=null;return}this.activeSubscriptionToken=e.token,this.requestedSessionId=e.sessionId,this.boundSessionId===e.sessionId?e.connected||(e.retryCount=0,e.connected=!0,this.clearConnectionTimeout(e),e.onEvent({type:`connected`})):(this.boundSessionId=null,this.startConnectionTimeout(e),this.bindActiveSession())}emitToSession(e,t){for(let n of this.subscriptions.values())n.sessionId===e&&n.onEvent(t)}markSessionConnected(e,t){for(let n of this.subscriptions.values())n.sessionId===e&&(n.retryCount=0,n.connected=!0,this.clearConnectionTimeout(n),n.onEvent(t))}emitErrorToSession(e,t,n){for(let r of this.subscriptions.values())r.sessionId===e&&(r.connected=!1,n&&this.clearConnectionTimeout(r),r.onError?.(t,n))}startConnectionTimeout(e){this.clearConnectionTimeout(e),e.connectionTimeoutId=setTimeout(()=>{e.connected||!this.subscriptions.has(e.token)||this.getActiveSubscription()?.token===e.token&&this.handleSocketFailure(Error(`Connection timeout`))},e.connectionTimeout)}clearConnectionTimeout(e){e.connectionTimeoutId&&=(clearTimeout(e.connectionTimeoutId),null)}async getOpenSocket(e){if(this.socket&&this.socket.readyState===a||(this.ensureConnected(),this.socket&&this.socket.readyState===a))return this.socket;let t=await Promise.race([this.openPromise??Promise.resolve(null),new Promise(t=>{setTimeout(()=>t(null),e)})]);return t&&t.readyState===a?t:this.socket&&this.socket.readyState===a?this.socket:null}ensureConnected(){this.closed||!this.socketUrl||this.socket&&(this.socket.readyState===a||this.socket.readyState===o)||(this.openPromise||=(this.clearReconnectTimeout(),(async()=>{try{await t()}catch{}return new Promise(e=>{let t=!1,n=null,i=r=>{t||(t=!0,n&&=(clearTimeout(n),null),this.openPromise=null,e(r))};try{let e=r(h(this.socketUrl));e.binaryType=`arraybuffer`,e.onopen=()=>{this.socket=e,this.startKeepalive(),i(e)},e.onmessage=e=>{this.handleSocketMessage(e.data)},e.onerror=()=>{!this.closed&&!this.getActiveSubscription()&&this.scheduleReconnect(Error(`Terminal websocket error`))},e.onclose=()=>{this.socket===e&&(this.socket=null,this.boundSessionId=null,this.stopKeepalive(),this.closed||this.scheduleReconnect(Error(`Terminal stream connection error`))),i(null)},this.socket=e,n=setTimeout(()=>{e.readyState===o&&(e.close(),i(null))},d)}catch{i(null),this.closed||this.scheduleReconnect(Error(`Terminal websocket open failed`))}})})()))}bindActiveSession(){let e=this.getActiveSubscription();if(!(!e||!this.socket||this.socket.readyState!==a)){this.requestedSessionId=e.sessionId;try{this.socket.send(g({t:`b`,s:e.sessionId,r:this.replayCursorBySession.get(e.sessionId)??0,v:2}))}catch{this.handleSocketFailure(Error(`Terminal websocket bind failed`))}}}scheduleReconnect(e){if(this.closed||!this.socketUrl||this.reconnectTimeout)return;this.promoteActiveSubscription();let t=this.getActiveSubscription();if(!t)return;let n=t.retryCount+1,r=t.initialRetryDelay,i=t.maxRetryDelay,a=t.maxRetries;if(n>a){this.clearConnectionTimeout(t),this.emitErrorToSession(t.sessionId,e,!0);return}t.retryCount=n;for(let e of this.subscriptions.values())e.sessionId===t.sessionId&&(e.connected=!1,e.retryCount=n,e.onEvent({type:`reconnecting`,attempt:n,maxAttempts:a}));this.startConnectionTimeout(t);let o=Math.min(r*2**Math.max(n-1,0),i)+Math.floor(Math.random()*l);this.reconnectTimeout=setTimeout(()=>{this.reconnectTimeout=null,this.ensureConnected(),this.bindActiveSession()},o)}clearReconnectTimeout(){this.reconnectTimeout&&=(clearTimeout(this.reconnectTimeout),null)}sendControl(e){if(!this.socket||this.socket.readyState!==a)return!1;try{return this.socket.send(g(e)),!0}catch{return this.handleSocketFailure(Error(`Terminal websocket control send failed`)),!1}}startKeepalive(){this.stopKeepalive(),this.keepaliveInterval=setInterval(()=>{this.closed||this.sendControl({t:`p`,v:2})},u)}stopKeepalive(){this.keepaliveInterval&&=(clearInterval(this.keepaliveInterval),null)}async handleSocketMessage(e){let t=await this.asUint8Array(e);if(t&&t.length>0&&t[0]===i){this.handleControlMessage(t);return}let n=await this.asText(e);if(!n)return;let r=this.boundSessionId??this.requestedSessionId??this.getActiveSubscription()?.sessionId;r&&this.emitToSession(r,{type:`data`,data:n})}handleControlMessage(e){if(e.length<2)return;let t;try{t=JSON.parse(m.decode(e.subarray(1)))}catch{this.handleSocketFailure(Error(`Terminal websocket control parse failed`));return}let n=this.getActiveSubscription();switch(t.t){case`ok`:this.bindActiveSession();return;case`po`:return;case`d`:{let e=t.s??this.boundSessionId??this.requestedSessionId;if(!e)return;typeof t.i==`number`&&Number.isFinite(t.i)&&this.replayCursorBySession.set(e,Math.max(this.replayCursorBySession.get(e)??0,Math.trunc(t.i))),typeof t.d==`string`&&t.d.length>0&&this.emitToSession(e,{type:`data`,data:t.d});return}case`bok`:{let e=t.s??this.requestedSessionId;if(this.boundSessionId=e,!e)return;this.markSessionConnected(e,{type:`connected`,runtime:t.runtime,ptyBackend:t.ptyBackend});return}case`x`:{let e=t.s??this.boundSessionId??n?.sessionId??null;if(!e){this.boundSessionId=null;return}this.boundSessionId===e&&(this.boundSessionId=null),this.requestedSessionId===e&&(this.requestedSessionId=null),this.replayCursorBySession.delete(e);for(let n of this.subscriptions.values())n.sessionId===e&&(n.connected=!1,this.clearConnectionTimeout(n),n.onEvent({type:`exit`,exitCode:t.exitCode,signal:t.signal??null}));return}case`e`:{let e=y(t.c),r=t.f===!0;(t.c===`NOT_BOUND`||t.c===`SESSION_NOT_FOUND`)&&(this.boundSessionId=null);let i=t.s??this.requestedSessionId??n?.sessionId??null;if(i){if(t.c===`SESSION_NOT_FOUND`){this.emitErrorToSession(i,e,!0);return}this.emitErrorToSession(i,e,r)}else n&&(n.connected=!1,r&&this.clearConnectionTimeout(n),n.onError?.(e,r));t.f===!0&&this.handleSocketFailure(e);return}default:return}}async asUint8Array(e){if(e instanceof ArrayBuffer)return new Uint8Array(e);if(e instanceof Uint8Array)return e;if(typeof Blob<`u`&&e instanceof Blob){let t=await e.arrayBuffer();return new Uint8Array(t)}return null}async asText(e){if(typeof e==`string`)return e;let t=await this.asUint8Array(e);return t?m.decode(t):``}handleSocketFailure(e){this.boundSessionId=null,this.requestedSessionId=null,this.resetConnection(),this.scheduleReconnect(e)}resetConnection(){if(this.openPromise=null,this.stopKeepalive(),this.socket){let e=this.socket;this.socket=null,e.onopen=null,e.onmessage=null,e.onerror=null,e.onclose=null,(e.readyState===a||e.readyState===o)&&e.close()}this.boundSessionId=null}},x=()=>{let e=globalThis;return e[f]||(e[f]={inputCapability:null,streamCapability:null,manager:null}),e[f]},S=()=>{let e=x();return e.manager||=new b,e.manager},C=e=>{let t=x();if(t.inputCapability=e?.input??null,t.streamCapability=e?.stream??null,!_(t.inputCapability)&&!_(t.streamCapability)){t.manager?.close(),t.manager=null;return}let n=h(v(t));n&&S().configure(n)},w=async(e,t)=>{let r=await n(`/api/terminal/${e}/input`,{method:`POST`,headers:{"Content-Type":`text/plain`},body:t});if(!r.ok){let e=await r.json().catch(()=>({error:`Failed to send terminal input`}));throw Error(e.error||`Failed to send terminal input`)}};async function T(e){let t=await n(`/api/terminal/create`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({cwd:e.cwd,cols:e.cols??80,rows:e.rows??24})});if(!t.ok){let e=await t.json().catch(()=>({error:`Failed to create terminal`}));throw Error(e.error||`Failed to create terminal session`)}let r=await t.json();return C(r.capabilities),r}var E=(t,n,r,i={})=>{let a=i.maxRetries??3,o=i.initialRetryDelay??1e3,s=i.maxRetryDelay??8e3,c=i.connectionTimeout??1e4,l=null,u=0,d=null,f=null,p=!1,m=!1,h=()=>{d&&=(clearTimeout(d),null),f&&=(clearTimeout(f),null)},g=()=>{p||(p=!0,h(),l&&=(l.close(),null))},_=(e,t)=>{if(!(p||m)){if(u<a&&!t){u+=1;let e=Math.min(o*2**(u-1),s);n({type:`reconnecting`,attempt:u,maxAttempts:a}),d=setTimeout(()=>{!p&&!m&&v()},e);return}r?.(e,!0),g()}},v=()=>{if(p||m||l&&l.readyState!==EventSource.CLOSED)return;l=new EventSource(e().sse(`/api/terminal/${t}/stream`));let i=!1;f=setTimeout(()=>{!i&&l?.readyState!==EventSource.OPEN&&(l?.close(),_(Error(`Connection timeout`),!1))},c),l.onopen=()=>{i||(i=!0,u=0,h(),n({type:`connected`}))},l.onmessage=e=>{try{let r=JSON.parse(e.data);r.type===`exit`&&(x().manager?.unbindSession(t),m=!0,g()),n(r)}catch(e){r?.(e,!1)}},l.onerror=()=>{h();let e=m||l?.readyState===EventSource.CLOSED;l?.close(),l=null,m||_(Error(`Terminal stream connection error`),e)}};return v(),g};function D(e,t,n,r={}){let i=x();if(i.streamCapability&&!_(i.streamCapability))return E(e,t,n,r);let a=S(),o=h(v(i));return o?(a.configure(o),a.subscribe(e,t,n,r)):E(e,t,n,r)}async function O(e,t){let n=x();n.manager&&await n.manager.sendInput(e,t)||await w(e,t)}async function k(e,t,r){let i=await n(`/api/terminal/${e}/resize`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({cols:t,rows:r})});if(!i.ok){let e=await i.json().catch(()=>({error:`Failed to resize terminal`}));throw Error(e.error||`Failed to resize terminal`)}}async function A(e){x().manager?.unbindSession(e);let t=await n(`/api/terminal/${e}`,{method:`DELETE`});if(!t.ok){let e=await t.json().catch(()=>({error:`Failed to close terminal`}));throw Error(e.error||`Failed to close terminal`)}}async function j(e,t){x().manager?.unbindSession(e);let r=await n(`/api/terminal/${e}/restart`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({cwd:t.cwd,cols:t.cols??80,rows:t.rows??24})});if(!r.ok){let e=await r.json().catch(()=>({error:`Failed to restart terminal`}));throw Error(e.error||`Failed to restart terminal`)}let i=await r.json();return C(i.capabilities),i}async function M(e){let t=await n(`/api/terminal/force-kill`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok){let e=await t.json().catch(()=>({error:`Failed to force kill terminal`}));throw Error(e.error||`Failed to force kill terminal`)}e.sessionId&&x().manager?.unbindSession(e.sessionId)}function N(){let e=x();e.manager?.close(),e.manager=null,e.inputCapability=null,e.streamCapability=null}function P(){let e=x();if(e.inputCapability&&e.streamCapability&&!_(e.inputCapability)&&!_(e.streamCapability))return;let t=h(v(e)||s);if(!t)return;let n=S();n.isConnectedOrConnecting(t)||(n.configure(t),n.prime())}export{M as a,j as c,N as i,O as l,D as n,P as o,T as r,k as s,A as t};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{B as t,H as n,L as r,R as i,U as a,V as o,nt as s,rt as c,z as l}from"./vendor-base-ui-CnHfUmDN.js";import{n as u}from"./vendor-react-DLPElpoQ.js";import{t as d}from"./utils-Dh7UZFrA.js";var f=u(),p=e(c(),1),m=s(),h=600,g=1600,_=10,v=p.createContext(null),y=class extends p.Component{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?this.props.fallback??null:this.props.children}};function b(e){let t=(0,f.c)(12),n,i,a,o,s,c;t[0]===e?(n=t[1],i=t[2],a=t[3],o=t[4],s=t[5],c=t[6]):({delayDuration:s,skipDelayDuration:o,delay:i,closeDelay:n,timeout:c,...a}=e,t[0]=e,t[1]=n,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c);let l=i??(s===void 0?0:s),u=n??o,d;return t[7]!==a||t[8]!==l||t[9]!==u||t[10]!==c?(d=(0,m.jsx)(r,{delay:l,closeDelay:u,timeout:c,...a}),t[7]=a,t[8]=l,t[9]=u,t[10]=c,t[11]=d):d=t[11],d}function x(e){let t=(0,f.c)(35),n,r,i,o;t[0]===e?(n=t[1],r=t[2],i=t[3],o=t[4]):({delayDuration:n,open:i,onOpenChange:r,...o}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=o);let[s,c]=p.useState(!1),l=p.useRef(null),u=p.useRef(null),d=p.useRef(null),y=p.useRef(!1),x=i!==void 0,S=x?i:s,C;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(C=()=>{l.current!==null&&(window.clearTimeout(l.current),l.current=null)},t[5]=C):C=t[5];let w=C,T;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(T=()=>{u.current!==null&&(window.clearTimeout(u.current),u.current=null)},t[6]=T):T=t[6];let E=T,D;t[7]===x?D=t[8]:(D=e=>{x||c(e)},t[7]=x,t[8]=D);let O=D,k;t[9]!==x||t[10]!==O?(k=e=>{(e.pointerType===`touch`||e.pointerType===`pen`)&&(w(),E(),d.current={x:e.clientX,y:e.clientY},l.current=window.setTimeout(()=>{x||(y.current=!0,O(!0))},h))},t[9]=x,t[10]=O,t[11]=k):k=t[11];let A;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(A=e=>{let t=d.current;if(!t)return;let n=Math.abs(e.clientX-t.x),r=Math.abs(e.clientY-t.y);(n>_||r>_)&&(w(),d.current=null)},t[12]=A):A=t[12];let j;t[13]===O?j=t[14]:(j=()=>{w(),d.current=null,y.current&&(E(),u.current=window.setTimeout(()=>{y.current=!1,O(!1)},g))},t[13]=O,t[14]=j);let M,N;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(M=e=>{y.current&&(y.current=!1,e.preventDefault(),e.stopPropagation())},N=e=>{y.current&&e.preventDefault()},t[15]=M,t[16]=N):(M=t[15],N=t[16]);let P;t[17]!==k||t[18]!==j?(P={handlePointerDown:k,handlePointerMove:A,handlePointerEnd:j,handleClickCapture:M,handleContextMenu:N},t[17]=k,t[18]=j,t[19]=P):P=t[19];let F=P,I,L;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(I=()=>()=>{w(),E()},L=[E,w],t[20]=I,t[21]=L):(I=t[20],L=t[21]),p.useEffect(I,L);let R;t[22]!==x||t[23]!==r?(R=(e,t)=>{x||c(e),r?.(e,t)},t[22]=x,t[23]=r,t[24]=R):R=t[24];let z=R,B;t[25]!==z||t[26]!==o||t[27]!==S?(B=(0,m.jsx)(a,{open:S,onOpenChange:z,...o}),t[25]=z,t[26]=o,t[27]=S,t[28]=B):B=t[28];let V;t[29]!==F||t[30]!==B?(V=(0,m.jsx)(v.Provider,{value:F,children:B}),t[29]=F,t[30]=B,t[31]=V):V=t[31];let H=V;if(n===void 0)return H;let U;return t[32]!==n||t[33]!==H?(U=(0,m.jsx)(b,{delayDuration:n,children:H}),t[32]=n,t[33]=H,t[34]=U):U=t[34],U}function S(e){let t=(0,f.c)(43),r,i,a,o,s,c,l,u,d;t[0]===e?(r=t[1],i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9]):({asChild:r,children:i,onPointerDown:c,onPointerMove:l,onPointerUp:u,onPointerCancel:s,onClickCapture:a,onContextMenu:o,...d}=e,t[0]=e,t[1]=r,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d);let h=p.useContext(v),g;t[10]!==r||t[11]!==i?(g=r&&p.isValidElement(i)?{render:i}:{children:i},t[10]=r,t[11]=i,t[12]=g):g=t[12];let _=g,b;t[13]!==h||t[14]!==c?(b=e=>{c?.(e),h?.handlePointerDown(e)},t[13]=h,t[14]=c,t[15]=b):b=t[15];let x;t[16]!==h||t[17]!==l?(x=e=>{l?.(e),h?.handlePointerMove(e)},t[16]=h,t[17]=l,t[18]=x):x=t[18];let S;t[19]!==h||t[20]!==u?(S=e=>{u?.(e),h?.handlePointerEnd()},t[19]=h,t[20]=u,t[21]=S):S=t[21];let C;t[22]!==h||t[23]!==s?(C=e=>{s?.(e),h?.handlePointerEnd()},t[22]=h,t[23]=s,t[24]=C):C=t[24];let w;t[25]!==h||t[26]!==a?(w=e=>{h?.handleClickCapture(e),!e.defaultPrevented&&a?.(e)},t[25]=h,t[26]=a,t[27]=w):w=t[27];let T;t[28]!==h||t[29]!==o?(T=e=>{h?.handleContextMenu(e),!e.defaultPrevented&&o?.(e)},t[28]=h,t[29]=o,t[30]=T):T=t[30];let E;t[31]!==d||t[32]!==_||t[33]!==b||t[34]!==x||t[35]!==S||t[36]!==C||t[37]!==w||t[38]!==T?(E=(0,m.jsx)(n,{"data-slot":`tooltip-trigger`,onPointerDown:b,onPointerMove:x,onPointerUp:S,onPointerCancel:C,onClickCapture:w,onContextMenu:T,...d,..._}),t[31]=d,t[32]=_,t[33]=b,t[34]=x,t[35]=S,t[36]=C,t[37]=w,t[38]=T,t[39]=E):E=t[39];let D;return t[40]!==i||t[41]!==E?(D=(0,m.jsx)(y,{fallback:i,children:E}),t[40]=i,t[41]=E,t[42]=D):D=t[42],D}function C(e){let n=(0,f.c)(23),r,a,s,c,u,p,h;n[0]===e?(r=n[1],a=n[2],s=n[3],c=n[4],u=n[5],p=n[6],h=n[7]):({className:s,sideOffset:h,side:u,align:r,children:a,style:p,...c}=e,n[0]=e,n[1]=r,n[2]=a,n[3]=s,n[4]=c,n[5]=u,n[6]=p,n[7]=h);let g=h===void 0?0:h,_;n[8]===s?_=n[9]:(_=d(`bg-[var(--surface-elevated)] text-[var(--surface-elevated-foreground)] border border-border/60 transition-all duration-150 ease-out data-[starting-style]:opacity-0 data-[starting-style]:scale-95 data-[ending-style]:opacity-0 data-[ending-style]:scale-95 z-50 w-fit origin-[var(--transform-origin)] rounded-xl px-3 py-1.5 typography-meta text-balance overflow-hidden`,s),n[8]=s,n[9]=_);let v;n[10]===p?v=n[11]:(v={...p},n[10]=p,n[11]=v);let b;n[12]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,m.jsx)(i,{className:`fill-[var(--surface-elevated)] z-50 size-2`}),n[12]=b):b=n[12];let x;n[13]!==a||n[14]!==c||n[15]!==_||n[16]!==v?(x=(0,m.jsxs)(l,{"data-slot":`tooltip-content`,className:_,style:v,...c,children:[a,b]}),n[13]=a,n[14]=c,n[15]=_,n[16]=v,n[17]=x):x=n[17];let S;return n[18]!==r||n[19]!==u||n[20]!==g||n[21]!==x?(S=(0,m.jsx)(y,{children:(0,m.jsx)(o,{children:(0,m.jsx)(t,{sideOffset:g,side:u,align:r,className:`z-50`,children:x})})}),n[18]=r,n[19]=u,n[20]=g,n[21]=x,n[22]=S):S=n[22],S}export{S as i,C as n,b as r,x as t};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{B as t,H as n,L as r,R as i,U as a,V as o,nt as s,rt as c,z as l}from"./vendor-base-ui-CnHfUmDN.js";import{n as u}from"./vendor-react-DLPElpoQ.js";import{t as d}from"./utils-DlvuQ5yV.js";var f=u(),p=e(c(),1),m=s(),h=600,g=1600,_=10,v=p.createContext(null),y=class extends p.Component{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?this.props.fallback??null:this.props.children}};function b(e){let t=(0,f.c)(12),n,i,a,o,s,c;t[0]===e?(n=t[1],i=t[2],a=t[3],o=t[4],s=t[5],c=t[6]):({delayDuration:s,skipDelayDuration:o,delay:i,closeDelay:n,timeout:c,...a}=e,t[0]=e,t[1]=n,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c);let l=i??(s===void 0?0:s),u=n??o,d;return t[7]!==a||t[8]!==l||t[9]!==u||t[10]!==c?(d=(0,m.jsx)(r,{delay:l,closeDelay:u,timeout:c,...a}),t[7]=a,t[8]=l,t[9]=u,t[10]=c,t[11]=d):d=t[11],d}function x(e){let t=(0,f.c)(35),n,r,i,o;t[0]===e?(n=t[1],r=t[2],i=t[3],o=t[4]):({delayDuration:n,open:i,onOpenChange:r,...o}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=o);let[s,c]=p.useState(!1),l=p.useRef(null),u=p.useRef(null),d=p.useRef(null),y=p.useRef(!1),x=i!==void 0,S=x?i:s,C;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(C=()=>{l.current!==null&&(window.clearTimeout(l.current),l.current=null)},t[5]=C):C=t[5];let w=C,T;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(T=()=>{u.current!==null&&(window.clearTimeout(u.current),u.current=null)},t[6]=T):T=t[6];let E=T,D;t[7]===x?D=t[8]:(D=e=>{x||c(e)},t[7]=x,t[8]=D);let O=D,k;t[9]!==x||t[10]!==O?(k=e=>{(e.pointerType===`touch`||e.pointerType===`pen`)&&(w(),E(),d.current={x:e.clientX,y:e.clientY},l.current=window.setTimeout(()=>{x||(y.current=!0,O(!0))},h))},t[9]=x,t[10]=O,t[11]=k):k=t[11];let A;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(A=e=>{let t=d.current;if(!t)return;let n=Math.abs(e.clientX-t.x),r=Math.abs(e.clientY-t.y);(n>_||r>_)&&(w(),d.current=null)},t[12]=A):A=t[12];let j;t[13]===O?j=t[14]:(j=()=>{w(),d.current=null,y.current&&(E(),u.current=window.setTimeout(()=>{y.current=!1,O(!1)},g))},t[13]=O,t[14]=j);let M,N;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(M=e=>{y.current&&(y.current=!1,e.preventDefault(),e.stopPropagation())},N=e=>{y.current&&e.preventDefault()},t[15]=M,t[16]=N):(M=t[15],N=t[16]);let P;t[17]!==k||t[18]!==j?(P={handlePointerDown:k,handlePointerMove:A,handlePointerEnd:j,handleClickCapture:M,handleContextMenu:N},t[17]=k,t[18]=j,t[19]=P):P=t[19];let F=P,I,L;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(I=()=>()=>{w(),E()},L=[E,w],t[20]=I,t[21]=L):(I=t[20],L=t[21]),p.useEffect(I,L);let R;t[22]!==x||t[23]!==r?(R=(e,t)=>{x||c(e),r?.(e,t)},t[22]=x,t[23]=r,t[24]=R):R=t[24];let z=R,B;t[25]!==z||t[26]!==o||t[27]!==S?(B=(0,m.jsx)(a,{open:S,onOpenChange:z,...o}),t[25]=z,t[26]=o,t[27]=S,t[28]=B):B=t[28];let V;t[29]!==F||t[30]!==B?(V=(0,m.jsx)(v.Provider,{value:F,children:B}),t[29]=F,t[30]=B,t[31]=V):V=t[31];let H=V;if(n===void 0)return H;let U;return t[32]!==n||t[33]!==H?(U=(0,m.jsx)(b,{delayDuration:n,children:H}),t[32]=n,t[33]=H,t[34]=U):U=t[34],U}function S(e){let t=(0,f.c)(43),r,i,a,o,s,c,l,u,d;t[0]===e?(r=t[1],i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9]):({asChild:r,children:i,onPointerDown:c,onPointerMove:l,onPointerUp:u,onPointerCancel:s,onClickCapture:a,onContextMenu:o,...d}=e,t[0]=e,t[1]=r,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d);let h=p.useContext(v),g;t[10]!==r||t[11]!==i?(g=r&&p.isValidElement(i)?{render:i}:{children:i},t[10]=r,t[11]=i,t[12]=g):g=t[12];let _=g,b;t[13]!==h||t[14]!==c?(b=e=>{c?.(e),h?.handlePointerDown(e)},t[13]=h,t[14]=c,t[15]=b):b=t[15];let x;t[16]!==h||t[17]!==l?(x=e=>{l?.(e),h?.handlePointerMove(e)},t[16]=h,t[17]=l,t[18]=x):x=t[18];let S;t[19]!==h||t[20]!==u?(S=e=>{u?.(e),h?.handlePointerEnd()},t[19]=h,t[20]=u,t[21]=S):S=t[21];let C;t[22]!==h||t[23]!==s?(C=e=>{s?.(e),h?.handlePointerEnd()},t[22]=h,t[23]=s,t[24]=C):C=t[24];let w;t[25]!==h||t[26]!==a?(w=e=>{h?.handleClickCapture(e),!e.defaultPrevented&&a?.(e)},t[25]=h,t[26]=a,t[27]=w):w=t[27];let T;t[28]!==h||t[29]!==o?(T=e=>{h?.handleContextMenu(e),!e.defaultPrevented&&o?.(e)},t[28]=h,t[29]=o,t[30]=T):T=t[30];let E;t[31]!==d||t[32]!==_||t[33]!==b||t[34]!==x||t[35]!==S||t[36]!==C||t[37]!==w||t[38]!==T?(E=(0,m.jsx)(n,{"data-slot":`tooltip-trigger`,onPointerDown:b,onPointerMove:x,onPointerUp:S,onPointerCancel:C,onClickCapture:w,onContextMenu:T,...d,..._}),t[31]=d,t[32]=_,t[33]=b,t[34]=x,t[35]=S,t[36]=C,t[37]=w,t[38]=T,t[39]=E):E=t[39];let D;return t[40]!==i||t[41]!==E?(D=(0,m.jsx)(y,{fallback:i,children:E}),t[40]=i,t[41]=E,t[42]=D):D=t[42],D}function C(e){let n=(0,f.c)(23),r,a,s,c,u,p,h;n[0]===e?(r=n[1],a=n[2],s=n[3],c=n[4],u=n[5],p=n[6],h=n[7]):({className:s,sideOffset:h,side:u,align:r,children:a,style:p,...c}=e,n[0]=e,n[1]=r,n[2]=a,n[3]=s,n[4]=c,n[5]=u,n[6]=p,n[7]=h);let g=h===void 0?0:h,_;n[8]===s?_=n[9]:(_=d(`bg-[var(--surface-elevated)] text-[var(--surface-elevated-foreground)] border border-border/60 transition-all duration-150 ease-out data-[starting-style]:opacity-0 data-[starting-style]:scale-95 data-[ending-style]:opacity-0 data-[ending-style]:scale-95 z-50 w-fit origin-[var(--transform-origin)] rounded-xl px-3 py-1.5 typography-meta text-balance overflow-hidden`,s),n[8]=s,n[9]=_);let v;n[10]===p?v=n[11]:(v={...p},n[10]=p,n[11]=v);let b;n[12]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,m.jsx)(i,{className:`fill-[var(--surface-elevated)] z-50 size-2`}),n[12]=b):b=n[12];let x;n[13]!==a||n[14]!==c||n[15]!==_||n[16]!==v?(x=(0,m.jsxs)(l,{"data-slot":`tooltip-content`,className:_,style:v,...c,children:[a,b]}),n[13]=a,n[14]=c,n[15]=_,n[16]=v,n[17]=x):x=n[17];let S;return n[18]!==r||n[19]!==u||n[20]!==g||n[21]!==x?(S=(0,m.jsx)(y,{children:(0,m.jsx)(o,{children:(0,m.jsx)(t,{sideOffset:g,side:u,align:r,className:`z-50`,children:x})})}),n[18]=r,n[19]=u,n[20]=g,n[21]=x,n[22]=S):S=n[22],S}export{S as i,C as n,b as r,x as t};
@@ -1 +1 @@
1
- import{xn as e}from"./persistence-ZSrLIR97.js";var t=e=>{try{return new URL(e)}catch{return null}},n=e=>{let n=t(e.trim());return n?n.protocol===`http:`||n.protocol===`https:`:!1},r=e=>{let n=t(e.trim());return!n||n.protocol!==`http:`&&n.protocol!==`https:`?null:`https://icons.duckduckgo.com/ip3/${n.hostname.toLowerCase()}.ico`},i=new Set([`localhost`,`127.0.0.1`,`0.0.0.0`,`::1`]),a=e=>{let n=t(e.trim());return!n||n.protocol!==`http:`&&n.protocol!==`https:`?!1:i.has(n.hostname.toLowerCase())},o=/\bhttps?:\/\/(?:localhost|127\.0\.0\.1|0\.0\.0\.0|\[::1\])(?::\d{2,5})?(?:\/[^\s<>"'`\u0000-\u001f]*)?/gi,s=e=>{if(!e)return[];let t=e.match(o);if(!t||t.length===0)return[];let n=new Set,r=[];for(let e of t){let t=e.replace(/[),.;:!?'"`]+$/g,``);!t||!a(t)||n.has(t)||(n.add(t),r.push(t))}return r},c=async n=>{if(typeof window>`u`)return!1;let r=n.trim();if(!r)return!1;let i=t(r);if(!i||i.protocol!==`http:`&&i.protocol!==`https:`)return!1;let a=i.toString(),o=e();if(o?.runtime?.isVSCode&&o.vscode?.openExternalUrl)try{return await o.vscode.openExternalUrl(a),!0}catch{return!1}let s=window.__OPENCHAMBER_DESKTOP__;if(s?.openExternal)try{return await s.openExternal(a),!0}catch{}try{return window.open(a,`_blank`,`noopener,noreferrer`),!0}catch{return!1}};export{c as a,a as i,r as n,n as r,s as t};
1
+ import{xn as e}from"./persistence-Cm9DnxXq.js";var t=e=>{try{return new URL(e)}catch{return null}},n=e=>{let n=t(e.trim());return n?n.protocol===`http:`||n.protocol===`https:`:!1},r=e=>{let n=t(e.trim());return!n||n.protocol!==`http:`&&n.protocol!==`https:`?null:`https://icons.duckduckgo.com/ip3/${n.hostname.toLowerCase()}.ico`},i=new Set([`localhost`,`127.0.0.1`,`0.0.0.0`,`::1`]),a=e=>{let n=t(e.trim());return!n||n.protocol!==`http:`&&n.protocol!==`https:`?!1:i.has(n.hostname.toLowerCase())},o=/\bhttps?:\/\/(?:localhost|127\.0\.0\.1|0\.0\.0\.0|\[::1\])(?::\d{2,5})?(?:\/[^\s<>"'`\u0000-\u001f]*)?/gi,s=e=>{if(!e)return[];let t=e.match(o);if(!t||t.length===0)return[];let n=new Set,r=[];for(let e of t){let t=e.replace(/[),.;:!?'"`]+$/g,``);!t||!a(t)||n.has(t)||(n.add(t),r.push(t))}return r},c=async n=>{if(typeof window>`u`)return!1;let r=n.trim();if(!r)return!1;let i=t(r);if(!i||i.protocol!==`http:`&&i.protocol!==`https:`)return!1;let a=i.toString(),o=e();if(o?.runtime?.isVSCode&&o.vscode?.openExternalUrl)try{return await o.vscode.openExternalUrl(a),!0}catch{return!1}let s=window.__OPENCHAMBER_DESKTOP__;if(s?.openExternal)try{return await s.openExternal(a),!0}catch{}try{return window.open(a,`_blank`,`noopener,noreferrer`),!0}catch{return!1}};export{c as a,a as i,r as n,n as r,s as t};