@openchambery/web 1.19.12 → 1.19.13-beta.1

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 (115) hide show
  1. package/dist/assets/{AgentAvatar-CX0a1rKE.js → AgentAvatar-CiQIIM0d.js} +1 -1
  2. package/dist/assets/AssistantView-YmeyxehG.js +2 -0
  3. package/dist/assets/{DiagramView-BeUgp_Y0.js → DiagramView-BpZb-G9P.js} +1 -1
  4. package/dist/assets/{FadeInOnReveal-CTlNE4Hg.js → FadeInOnReveal-nf6-ZCrs.js} +1 -1
  5. package/dist/assets/{Icon-BYM02QyU.js → Icon-CeKHYyKZ.js} +1 -1
  6. package/dist/assets/MarkdownRenderer-wpeGdciL.js +2 -0
  7. package/dist/assets/{MarkdownRendererImpl-DB4Q3kGa.js → MarkdownRendererImpl-Peu0GVSQ.js} +1 -1
  8. package/dist/assets/{MarkstreamRendererImpl-BFdJzxia.js → MarkstreamRendererImpl-B-odd2Gz.js} +1 -1
  9. package/dist/assets/MobileDetailNavigation-CtYke_1C.js +1 -0
  10. package/dist/assets/{MobileShareBridge-UiOLx0-2.js → MobileShareBridge-DIfOl8EZ.js} +3 -3
  11. package/dist/assets/MobileSurface-_KoX75Ff.js +2 -0
  12. package/dist/assets/{MultiRunWindow-C3p3lj3U.js → MultiRunWindow-BT5Dwgzu.js} +1 -1
  13. package/dist/assets/{OnboardingScreen-DS2nugLX.js → OnboardingScreen-BPusUgFG.js} +1 -1
  14. package/dist/assets/{OverlayScrollbar-KUpvYHdv.js → OverlayScrollbar-DUghqFGg.js} +1 -1
  15. package/dist/assets/{SettingsView-BXfKsz0J.js → SettingsView-BwQpbIZl.js} +11 -11
  16. package/dist/assets/{SettingsWindow-8IDuPZA5.js → SettingsWindow-DfEGfyr8.js} +1 -1
  17. package/dist/assets/{TerminalView-BiKCueth.js → TerminalView-8402vpcO.js} +1 -1
  18. package/dist/assets/{ToolOutputDialog-BC2F_Fdl.js → ToolOutputDialog-B5RdkhsG.js} +1 -1
  19. package/dist/assets/{appThemeRegistry-B87OLIgc.js → appThemeRegistry-CIZ-shMD.js} +1 -1
  20. package/dist/assets/{button-C0cth9tl.js → button-DFPOdZ0g.js} +1 -1
  21. package/dist/assets/{clipboard-DJ4nQEuY.js → clipboard-C05anBwU.js} +1 -1
  22. package/dist/assets/{collapsible-DFT9cE80.js → collapsible-oGbEvbe1.js} +1 -1
  23. package/dist/assets/{context-menu-CAp74NfV.js → context-menu-DGz4_2hs.js} +1 -1
  24. package/dist/assets/{desktopHosts-Dc2PS66M.js → desktopHosts-BVJXQq1S.js} +1 -1
  25. package/dist/assets/{desktopRelayRestore-T9y0orqa.js → desktopRelayRestore-RDfuj1M7.js} +1 -1
  26. package/dist/assets/{diagram-BryzMuta.js → diagram-Csk5GpDC.js} +1 -1
  27. package/dist/assets/{dialog-CgbV5ljg.js → dialog-rrqB-H6q.js} +1 -1
  28. package/dist/assets/{es-BHqnSjoZ.js → es-FE0sJ9EC.js} +1 -1
  29. package/dist/assets/{fileQueries-BY-9OWzp.js → fileQueries-BcdWOPlD.js} +1 -1
  30. package/dist/assets/{fr-BfrlJY9i.js → fr-DNDCSfGt.js} +1 -1
  31. package/dist/assets/{gitApi-tTtHQVA3.js → gitApi-_P0FsoXe.js} +1 -1
  32. package/dist/assets/{input-DFLpqjGR.js → input-BO3r20op.js} +1 -1
  33. package/dist/assets/{insertionBoundaries-CCQpZ5zn.js → insertionBoundaries-CWoioTdE.js} +1 -1
  34. package/dist/assets/{ja-DP-7qt-x.js → ja-BDwrk0cM.js} +1 -1
  35. package/dist/assets/{ko-E2B5vGQP.js → ko-BeeU2o4I.js} +1 -1
  36. package/dist/assets/{main-Dkg31fRY.js → main-CLj_WS1o.js} +2 -2
  37. package/dist/assets/{main-C_PUoT3E.js → main-CnSZ89pD.js} +4 -4
  38. package/dist/assets/{markdown-worker-CTsrtpPh.js → markdown-worker-CZWE1F1M.js} +1 -1
  39. package/dist/assets/{markdownHeightCache-CYDlisxr.js → markdownHeightCache-Cdd3hkMl.js} +1 -1
  40. package/dist/assets/{markdownTheme-DyJ4Gfcj.js → markdownTheme-DIB8WVmz.js} +1 -1
  41. package/dist/assets/miniChat-B9c3y2pD.js +2 -0
  42. package/dist/assets/{mobile-Z_X7CbzB.js → mobile-DvbXUfNS.js} +2 -2
  43. package/dist/assets/{multirun-B0V3hdnD.js → multirun-CxhTsmRq.js} +1 -1
  44. package/dist/assets/{persistence-DdUac14I.js → persistence-CVTWFaqe.js} +2 -2
  45. package/dist/assets/{pl-r8X5gRM5.js → pl-BYuzpcI5.js} +1 -1
  46. package/dist/assets/{platform-B4KKLnZ5.js → platform-BY_Gtsqr.js} +1 -1
  47. package/dist/assets/{projectMeta-DRW9MQ4z.js → projectMeta-Dl5iPCB6.js} +1 -1
  48. package/dist/assets/{pt-BR-DcpdXCf5.js → pt-BR-Bn7cwEzv.js} +1 -1
  49. package/dist/assets/{renderElectronMiniChatApp-Dn1Su1dd.js → renderElectronMiniChatApp-CkJ51qCh.js} +2 -2
  50. package/dist/assets/renderMobileApp-DcjQPhWw.js +28 -0
  51. package/dist/assets/{runtimeConfig-C6matIEB.js → runtimeConfig-Bsk2kWsW.js} +1 -1
  52. package/dist/assets/runtimeEndpointReset-BBLFgl85.js +147 -0
  53. package/dist/assets/{sessionChangeSummary-hVby3sJk.js → sessionChangeSummary-DDVT7O5J.js} +1 -1
  54. package/dist/assets/{sessionLookup-B6P_aCun.js → sessionLookup-C8VZn0gJ.js} +1 -1
  55. package/dist/assets/{sortable-tabs-strip-C8_9kHqu.js → sortable-tabs-strip-s7UUxsa6.js} +1 -1
  56. package/dist/assets/src-BpHDMgud.css +2 -0
  57. package/dist/assets/{store-BDFdnk6l.js → store-n94dSb3M.js} +2 -2
  58. package/dist/assets/{terminalApi-947l7Ra3.js → terminalApi-C54_rKEK.js} +1 -1
  59. package/dist/assets/{textarea-Cgo_nWUU.js → textarea-BjX-KhMN.js} +1 -1
  60. package/dist/assets/{tooltip-BifLJ8o0.js → tooltip-CQGqGAG_.js} +1 -1
  61. package/dist/assets/{uk-Di0vl9V-.js → uk-CwpbHEa3.js} +1 -1
  62. package/dist/assets/{url-Pk6tQ1EZ.js → url-BMjqccCo.js} +1 -1
  63. package/dist/assets/{useAppFontEffects-Dmes1chr.js → useAppFontEffects-BIFw36SA.js} +5 -5
  64. package/dist/assets/{useAssistantUIStore-me6s63b2.js → useAssistantUIStore-Cg9bsT4b.js} +1 -1
  65. package/dist/assets/{useDesktopWindowControlsLayout-DuZ6URPR.js → useDesktopWindowControlsLayout-DoygEcN4.js} +1 -1
  66. package/dist/assets/{useEffectiveDirectory-CU2ChP0J.js → useEffectiveDirectory-DJSYYkVp.js} +1 -1
  67. package/dist/assets/{useFontPreferences-BCOBlaAd.js → useFontPreferences-B5_apbBC.js} +1 -1
  68. package/dist/assets/{useMobileNavigationStore-C8_J-qTp.js → useMobileNavigationStore-DuTu0Mzh.js} +5 -5
  69. package/dist/assets/{useSessionAutoCleanup-FOQeu1_T.js → useSessionAutoCleanup-C-L9teva.js} +1 -1
  70. package/dist/assets/{useUIStore-CuaA8-Hp.js → useUIStore-DwpQTjLO.js} +1 -1
  71. package/dist/assets/{useWorkerHighlightedLines-GBqKnki1.js → useWorkerHighlightedLines-DxTfgdEi.js} +1 -1
  72. package/dist/assets/{utils-BiK3tBGM.js → utils-81nUI_xp.js} +1 -1
  73. package/dist/assets/{zh-CN-coFCfeQE.js → zh-CN-BpzFZ-LU.js} +1 -1
  74. package/dist/assets/{zh-TW-oDRZ1-yb.js → zh-TW-Bopgc5Eo.js} +1 -1
  75. package/dist/index.html +9 -9
  76. package/dist/mini-chat.html +9 -9
  77. package/dist/mobile.html +9 -9
  78. package/package.json +1 -1
  79. package/server/index.js +19 -0
  80. package/server/lib/assistants/DOCUMENTATION.md +17 -4
  81. package/server/lib/assistants/assign.js +455 -30
  82. package/server/lib/assistants/assign.test.js +351 -0
  83. package/server/lib/assistants/contact-active-turn.http.test.js +134 -0
  84. package/server/lib/assistants/contact-store.js +64 -0
  85. package/server/lib/assistants/contact-store.test.js +12 -0
  86. package/server/lib/assistants/contact-tools.js +108 -9
  87. package/server/lib/assistants/contact-tools.test.js +111 -0
  88. package/server/lib/assistants/contracts.js +2 -2
  89. package/server/lib/assistants/harness.js +4 -1
  90. package/server/lib/assistants/service.js +320 -27
  91. package/server/lib/assistants/service.test.js +538 -9
  92. package/server/lib/llm/catalog.js +91 -16
  93. package/server/lib/llm/catalog.test.js +152 -11
  94. package/server/lib/notifications/APNS.md +20 -4
  95. package/server/lib/notifications/DOCUMENTATION.md +5 -0
  96. package/server/lib/notifications/apns-runtime.js +136 -18
  97. package/server/lib/notifications/apns-runtime.test.js +128 -0
  98. package/server/lib/notifications/apns-titles.js +21 -1
  99. package/server/lib/notifications/live-activity-refresh-runtime.js +185 -0
  100. package/server/lib/notifications/live-activity-refresh-runtime.test.js +242 -0
  101. package/server/lib/notifications/runtime.js +93 -2
  102. package/server/lib/notifications/runtime.test.js +167 -4
  103. package/server/lib/opencode/settings-helpers.js +12 -0
  104. package/server/lib/opencode/settings-runtime.js +16 -0
  105. package/server/lib/opencode/settings-runtime.test.js +21 -0
  106. package/server/lib/scheduled-tasks/runtime.js +21 -0
  107. package/server/lib/scheduled-tasks/runtime.test.js +24 -0
  108. package/dist/assets/AssistantView-DxIghtun.js +0 -2
  109. package/dist/assets/MarkdownRenderer-C4MGa_kQ.js +0 -2
  110. package/dist/assets/MobileDetailNavigation-B_RwWOwv.js +0 -1
  111. package/dist/assets/MobileSurface-CNChj_dX.js +0 -2
  112. package/dist/assets/miniChat-C9QMj8T8.js +0 -2
  113. package/dist/assets/renderMobileApp-BG1JJt1Q.js +0 -28
  114. package/dist/assets/runtimeEndpointReset-kgwmUJDb.js +0 -147
  115. package/dist/assets/src-B-P5qIBc.css +0 -2
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-C0FnF6B9.js";import{kn as t,xn as n}from"./persistence-DdUac14I.js";import{$ as r,A as i,C as a,F as o,G as s,J as c,K as l,L as u,M as d,N as f,Nt as p,O as m,Q as h,R as ee,S as te,T as ne,X as re,Y as g,Z as ie,_ as ae,at as oe,b as se,c as ce,d as le,gt as ue,h as de,ht as fe,it as pe,lt as me,m as he,nt as ge,o as _e,pt as ve,rt as ye,u as be,ut as xe,v as Se,vt as Ce,w as we,x as Te,xt as Ee,yt as De,z as Oe}from"./platform-B4KKLnZ5.js";import{Fa as ke,Ui as _,Zi as v,c as y,o as Ae}from"./useMobileNavigationStore-C8_J-qTp.js";var je=e({applyGitStash:()=>G,checkIsGitRepository:()=>S,checkoutCommit:()=>Ke,cherryPick:()=>qe,countGitStashFiles:()=>U,createBranch:()=>J,createGitIdentity:()=>Z,createGitWorktree:()=>z,deleteGitIdentity:()=>$,deleteGitWorktree:()=>B,deleteRemoteBranch:()=>j,discoverGitCredentials:()=>He,discoverGitRepositories:()=>C,dropGitStash:()=>q,generateCommitMessage:()=>N,getCommitFileDiff:()=>Y,getConflictDetails:()=>Xe,getGitBranches:()=>A,getGitIdentities:()=>X,getGitStatus:()=>w,getGitWorktreeBootstrapStatus:()=>L,getGlobalGitIdentity:()=>Ue,git:()=>V,listGitStashes:()=>H,listGitWorktrees:()=>F,merge:()=>Ge,popGitStash:()=>K,previewGitWorktree:()=>R,rebase:()=>We,resetToCommit:()=>Ye,resolveGitPrimaryRoot:()=>T,resolveGitTopLevel:()=>E,revertCommit:()=>Je,stageGitFile:()=>D,stageGitFiles:()=>O,stashGitChanges:()=>W,unstageGitFile:()=>Pe,unstageGitFiles:()=>k,updateGitIdentity:()=>Q,validateGitWorktree:()=>I}),b=()=>n()?.git??null,Me=e=>{typeof window>`u`||window.dispatchEvent(new CustomEvent(`openchamber:chat-force-scroll-bottom`,{detail:{sessionId:e}}))},x=e=>{let t=e.trim(),n=(t.match(/```(?:json)?\s*([\s\S]*?)```/i)?.[1]??t).trim(),r=[n.indexOf(`{`)].filter(e=>e>=0);for(let e of r)for(let t=n.length;t>e;--t)if(n[t-1]===`}`)try{let r=JSON.parse(n.slice(e,t));if(r&&typeof r==`object`&&!Array.isArray(r))return r}catch{}return null},Ne=e=>{let t=e?.data;return(Array.isArray(t?.parts)?t.parts:[]).map(e=>{let t=e;return t.type===`text`?typeof t.text==`string`?t.text:typeof t.content==`string`?t.content:typeof t.value==`string`?t.value:``:``}).filter(e=>e.trim().length>0).join(`
1
+ import{r as e}from"./rolldown-runtime-C0FnF6B9.js";import{kn as t,xn as n}from"./persistence-CVTWFaqe.js";import{$ as r,A as i,C as a,F as o,G as s,J as c,K as l,L as u,M as d,N as f,Nt as p,O as m,Q as h,R as ee,S as te,T as ne,X as re,Y as g,Z as ie,_ as ae,at as oe,b as se,c as ce,d as le,gt as ue,h as de,ht as fe,it as pe,lt as me,m as he,nt as ge,o as _e,pt as ve,rt as ye,u as be,ut as xe,v as Se,vt as Ce,w as we,x as Te,xt as Ee,yt as De,z as Oe}from"./platform-BY_Gtsqr.js";import{Fa as ke,Ui as _,Zi as v,c as y,o as Ae}from"./useMobileNavigationStore-DuTu0Mzh.js";var je=e({applyGitStash:()=>G,checkIsGitRepository:()=>S,checkoutCommit:()=>Ke,cherryPick:()=>qe,countGitStashFiles:()=>U,createBranch:()=>J,createGitIdentity:()=>Z,createGitWorktree:()=>z,deleteGitIdentity:()=>$,deleteGitWorktree:()=>B,deleteRemoteBranch:()=>j,discoverGitCredentials:()=>He,discoverGitRepositories:()=>C,dropGitStash:()=>q,generateCommitMessage:()=>N,getCommitFileDiff:()=>Y,getConflictDetails:()=>Xe,getGitBranches:()=>A,getGitIdentities:()=>X,getGitStatus:()=>w,getGitWorktreeBootstrapStatus:()=>L,getGlobalGitIdentity:()=>Ue,git:()=>V,listGitStashes:()=>H,listGitWorktrees:()=>F,merge:()=>Ge,popGitStash:()=>K,previewGitWorktree:()=>R,rebase:()=>We,resetToCommit:()=>Ye,resolveGitPrimaryRoot:()=>T,resolveGitTopLevel:()=>E,revertCommit:()=>Je,stageGitFile:()=>D,stageGitFiles:()=>O,stashGitChanges:()=>W,unstageGitFile:()=>Pe,unstageGitFiles:()=>k,updateGitIdentity:()=>Q,validateGitWorktree:()=>I}),b=()=>n()?.git??null,Me=e=>{typeof window>`u`||window.dispatchEvent(new CustomEvent(`openchamber:chat-force-scroll-bottom`,{detail:{sessionId:e}}))},x=e=>{let t=e.trim(),n=(t.match(/```(?:json)?\s*([\s\S]*?)```/i)?.[1]??t).trim(),r=[n.indexOf(`{`)].filter(e=>e>=0);for(let e of r)for(let t=n.length;t>e;--t)if(n[t-1]===`}`)try{let r=JSON.parse(n.slice(e,t));if(r&&typeof r==`object`&&!Array.isArray(r))return r}catch{}return null},Ne=e=>{let t=e?.data;return(Array.isArray(t?.parts)?t.parts:[]).map(e=>{let t=e;return t.type===`text`?typeof t.text==`string`?t.text:typeof t.content==`string`?t.content:typeof t.value==`string`?t.value:``:``}).filter(e=>e.trim().length>0).join(`
2
2
  `).trim()};async function S(e){let t=b();return t?t.checkIsGitRepository(e):ce(e)}async function C(e){return we(e)}async function w(e,t){let n=b();return n?n.getGitStatus(e,t):u(e,t)}async function T(e){return(await ye(e)).root}async function E(e){return(await pe(e)).root}async function D(e,t){let n=b();return n?.stageGitFile?n.stageGitFile(e,t):me(e,t)}async function O(e,t){let n=b();return n?.stageGitFiles?n.stageGitFiles(e,t):xe(e,t)}async function Pe(e,t){let n=b();return n?.unstageGitFile?n.unstageGitFile(e,t):fe(e,t)}async function k(e,t){let n=b();return n?.unstageGitFiles?n.unstageGitFiles(e,t):ue(e,t)}async function A(e,t){let n=b();if(t?.signal?.throwIfAborted(),n){let r=await n.getGitBranches(e,t);return t?.signal?.throwIfAborted(),r}return d(e,t)}async function j(e,t){let n=b();return n?n.deleteRemoteBranch(e,t):te(e,t)}var Fe=30,Ie=12e4,Le=async(e,t)=>{let n=t.slice(0,Fe),r=await Promise.all(n.map(async t=>{try{let[n,r]=await Promise.all([f(e,{path:t,staged:!0}).catch(()=>null),f(e,{path:t,staged:!1}).catch(()=>null)]);return[n?.diff,r?.diff].filter(e=>typeof e==`string`&&e.trim().length>0).join(`
3
3
  `)||`--- ${t} (no textual diff available)`}catch{return`--- ${t} (diff unavailable)`}})),i=``;for(let e of r){if(i.length+e.length>Ie){i+=`
4
4
  [remaining diffs truncated]`;break}i+=(i?`
@@ -1 +1 @@
1
- import"./rolldown-runtime-C0FnF6B9.js";import{nt as e,rt as t}from"./vendor-base-ui-CnHfUmDN.js";import{n}from"./vendor-react-DLPElpoQ.js";import{t as r}from"./utils-BiK3tBGM.js";var i=n();t();var a=e();function o(e){let t=(0,i.c)(10),n,o,s;t[0]===e?(n=t[1],o=t[2],s=t[3]):({className:n,type:s,...o}=e,t[0]=e,t[1]=n,t[2]=o,t[3]=s);let c;t[4]===n?c=t[5]:(c=r(`text-foreground file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground bg-[var(--surface-elevated)] appearance-none flex h-9 w-full min-w-0 rounded-lg px-3 py-1 typography-markdown outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:typography-ui-label file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:typography-ui-label`,`ring-1 ring-inset ring-border/60 transition duration-200 ease-out`,`hover:[&:not(:focus)]:bg-[var(--surface-subtle)] hover:[&:not(:focus)]:ring-transparent`,`focus:ring-2 focus:ring-[var(--interactive-focus-ring)] focus-visible:outline-none`,`aria-invalid:ring-[var(--status-error)] aria-invalid:focus:ring-[var(--status-error)]`,n),t[4]=n,t[5]=c);let l;return t[6]!==o||t[7]!==c||t[8]!==s?(l=(0,a.jsx)(`input`,{type:s,"data-slot":`input`,className:c,spellCheck:!1,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`off`,...o}),t[6]=o,t[7]=c,t[8]=s,t[9]=l):l=t[9],l}export{o as t};
1
+ import"./rolldown-runtime-C0FnF6B9.js";import{nt as e,rt as t}from"./vendor-base-ui-CnHfUmDN.js";import{n}from"./vendor-react-DLPElpoQ.js";import{t as r}from"./utils-81nUI_xp.js";var i=n();t();var a=e();function o(e){let t=(0,i.c)(10),n,o,s;t[0]===e?(n=t[1],o=t[2],s=t[3]):({className:n,type:s,...o}=e,t[0]=e,t[1]=n,t[2]=o,t[3]=s);let c;t[4]===n?c=t[5]:(c=r(`text-foreground file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground bg-[var(--surface-elevated)] appearance-none flex h-9 w-full min-w-0 rounded-lg px-3 py-1 typography-markdown outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:typography-ui-label file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:typography-ui-label`,`ring-1 ring-inset ring-border/60 transition duration-200 ease-out`,`hover:[&:not(:focus)]:bg-[var(--surface-subtle)] hover:[&:not(:focus)]:ring-transparent`,`focus:ring-2 focus:ring-[var(--interactive-focus-ring)] focus-visible:outline-none`,`aria-invalid:ring-[var(--status-error)] aria-invalid:focus:ring-[var(--status-error)]`,n),t[4]=n,t[5]=c);let l;return t[6]!==o||t[7]!==c||t[8]!==s?(l=(0,a.jsx)(`input`,{type:s,"data-slot":`input`,className:c,spellCheck:!1,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`off`,...o}),t[6]=o,t[7]=c,t[8]=s,t[9]=l):l=t[9],l}export{o as t};
@@ -1,4 +1,4 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{A as t,E as n,b as r,t as i,y as a}from"./useUIStore-CuaA8-Hp.js";import{$t as o,D as s,d as c,k as l,ot as u,u as d,xn as f}from"./persistence-DdUac14I.js";import{a as p,i as m,r as h}from"./vendor-zustand-B4dlGEM2.js";import{nt as g,rt as _,tt as v}from"./vendor-base-ui-CnHfUmDN.js";import{B as y,Ct as b,M as x,Mt as S}from"./platform-B4KKLnZ5.js";import{n as ee}from"./vendor-react-DLPElpoQ.js";import{s as C}from"./vendor-tanstack-react-query-D7pys_c9.js";import{n as w}from"./vendor-reactuses-core-DDoDDyM9.js";import{n as te}from"./clipboard-DJ4nQEuY.js";import{$a as ne,Zi as re,at as ie,c as T,ct as ae,dr as oe,dt as E,ft as D,g as O,ho as k,in as se,lt as A,mn as j,mo as ce,ot as le,st as M,y as N}from"./useMobileNavigationStore-C8_J-qTp.js";import{c as ue,t as P}from"./utils-BiK3tBGM.js";import{n as F,r as I,t as L}from"./Icon-BYM02QyU.js";import{g as R,v as de}from"./gitApi-tTtHQVA3.js";import{f as z,o as B,q as fe}from"./projectMeta-DRW9MQ4z.js";import{n as pe}from"./textarea-Cgo_nWUU.js";var V=e(_(),1),H=ee(),U=g(),W=e(v(),1),me=e=>{switch(e.name){case`new`:return`add`;case`init`:return`file`;case`undo`:return`arrow-go-back`;case`redo`:return`arrow-go-forward`;case`timeline`:return`time`;case`compact`:return`scissors`;case`goal`:return`target`;case`review`:return`search-eye`;case`test`:case`build`:case`run`:return`terminal-box`;default:return e.isBuiltIn?`flashlight`:`command`}},he=()=>`book-open`,ge=e=>{if(e.isDirectory)return`folder-3-fill`;switch(e.extension?.toLowerCase()){case`ts`:case`tsx`:case`js`:case`jsx`:case`json`:return`code`;case`md`:case`mdx`:return`file`;case`png`:case`jpg`:case`jpeg`:case`gif`:case`svg`:return`file-image`;default:return`file-pdf`}},_e=()=>`ai-agent`,ve=()=>`chat-thread`,G=32,K=(e,t)=>{let n=I[e];return typeof n!=`string`||n.length===0?null:`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="${t}" stroke-width="${L}" stroke-linecap="round" stroke-linejoin="round">${n}</svg>`},ye=(e,t)=>{let n=K(e,t);return!n||typeof document>`u`?Promise.resolve(null):new Promise(e=>{let t=new Image;t.decoding=`async`,t.onload=()=>{try{let n=document.createElement(`canvas`);n.width=G,n.height=G;let r=n.getContext(`2d`);if(!r){e(null);return}r.clearRect(0,0,G,G),r.drawImage(t,0,0,G,G);let i=n.toDataURL(`image/png`),a=i.indexOf(`,`);e(a>=0?i.slice(a+1):null)}catch{e(null)}},t.onerror=()=>e(null),t.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n)}`})},be=(e,t)=>e.map(e=>{let n=e.isSkill?t.skill:e.isOpenChamber?`OpenChamber`:e.isBuiltIn?t.system:e.scope||e.agent||t.command;return{id:e.id,title:`/${e.name}`,subtitle:e.description,badge:n,iconName:me(e)}}),q=e=>e.map(e=>({id:`${e.name}-${e.scope}`,title:e.name,subtitle:e.description,badge:e.scope,iconName:he()})),xe=({agents:e,sessions:t,recentFiles:n,pathHits:r,untitledSession:i,sessionBadge:a})=>{let o=[];for(let t of e)o.push({id:`agent:${t.name}`,title:`@${t.name}`,subtitle:t.description,iconName:_e()});for(let e of t)o.push({id:`session:${e.id}`,title:e.title||i,badge:a,iconName:ve()});for(let e of n)o.push({id:`recent:${e.path}`,title:e.relativePath||e.name,iconName:ge(e)});for(let e of r)o.push({id:`file:${e.path}`,title:e.relativePath||e.name,iconName:ge(e)});return o},J=(e,t)=>{let n=t.trim();if(!n)return[...e].sort((e,t)=>e.isBuiltIn===t.isBuiltIn?e.name.localeCompare(t.name):e.isBuiltIn?-1:1);let r=D([...e],n,e=>[e.name,e.description??``]);return r.sort((e,t)=>e.score===t.score?e.item.isBuiltIn===t.item.isBuiltIn?e.item.name.localeCompare(t.item.name):e.item.isBuiltIn?-1:1:e.score-t.score),r.map(e=>e.item)},Y=(e,t)=>{if(!e.includes(`/`)||t.size===0)return[];let n=RegExp(`(^|\\s)/(${u})?([A-Za-z0-9][A-Za-z0-9_-]*)(?=$|\\s)`,`g`),r=[],i;for(;(i=n.exec(e))!==null;){let e=i[3]??``;if(!t.has(e.toLowerCase()))continue;let n=i[2]??``,a=i.index+(i[1]?.length??0);r.push({start:a,end:a+1+n.length+e.length,name:e,hasSlot:n.length>0})}return r},X=(e,t,n=e.length)=>{let r=Y(e,t).filter(e=>!e.hasSlot);if(r.length===0)return null;let i=e,a=n;for(let e=r.length-1;e>=0;--e){let t=r[e].start+1;i=`${i.slice(0,t)}${u}${i.slice(t)}`,a>t&&(a+=u.length)}return i===e?null:{text:i,caret:a}},Se=e=>e.startsWith(u)?e.slice(u.length):e,Ce=e=>{if(e.inputMode===`shell`)return null;let t=e.text,n=Math.max(0,Math.min(e.cursor,t.length));if(t.startsWith(`/`)){let e=t.indexOf(` `),r=t.indexOf(`
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{A as t,E as n,b as r,t as i,y as a}from"./useUIStore-DwpQTjLO.js";import{$t as o,D as s,d as c,k as l,ot as u,u as d,xn as f}from"./persistence-CVTWFaqe.js";import{a as p,i as m,r as h}from"./vendor-zustand-B4dlGEM2.js";import{nt as g,rt as _,tt as v}from"./vendor-base-ui-CnHfUmDN.js";import{B as y,Ct as b,M as x,Mt as S}from"./platform-BY_Gtsqr.js";import{n as ee}from"./vendor-react-DLPElpoQ.js";import{s as C}from"./vendor-tanstack-react-query-D7pys_c9.js";import{n as w}from"./vendor-reactuses-core-DDoDDyM9.js";import{n as te}from"./clipboard-C05anBwU.js";import{$a as ne,Zi as re,at as ie,c as T,ct as ae,dr as oe,dt as E,ft as D,g as O,ho as k,in as se,lt as A,mn as j,mo as ce,ot as le,st as M,y as N}from"./useMobileNavigationStore-DuTu0Mzh.js";import{c as ue,t as P}from"./utils-81nUI_xp.js";import{n as F,r as I,t as L}from"./Icon-CeKHYyKZ.js";import{g as R,v as de}from"./gitApi-_P0FsoXe.js";import{f as z,o as B,q as fe}from"./projectMeta-Dl5iPCB6.js";import{n as pe}from"./textarea-BjX-KhMN.js";var V=e(_(),1),H=ee(),U=g(),W=e(v(),1),me=e=>{switch(e.name){case`new`:return`add`;case`init`:return`file`;case`undo`:return`arrow-go-back`;case`redo`:return`arrow-go-forward`;case`timeline`:return`time`;case`compact`:return`scissors`;case`goal`:return`target`;case`review`:return`search-eye`;case`test`:case`build`:case`run`:return`terminal-box`;default:return e.isBuiltIn?`flashlight`:`command`}},he=()=>`book-open`,ge=e=>{if(e.isDirectory)return`folder-3-fill`;switch(e.extension?.toLowerCase()){case`ts`:case`tsx`:case`js`:case`jsx`:case`json`:return`code`;case`md`:case`mdx`:return`file`;case`png`:case`jpg`:case`jpeg`:case`gif`:case`svg`:return`file-image`;default:return`file-pdf`}},_e=()=>`ai-agent`,ve=()=>`chat-thread`,G=32,K=(e,t)=>{let n=I[e];return typeof n!=`string`||n.length===0?null:`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="${t}" stroke-width="${L}" stroke-linecap="round" stroke-linejoin="round">${n}</svg>`},ye=(e,t)=>{let n=K(e,t);return!n||typeof document>`u`?Promise.resolve(null):new Promise(e=>{let t=new Image;t.decoding=`async`,t.onload=()=>{try{let n=document.createElement(`canvas`);n.width=G,n.height=G;let r=n.getContext(`2d`);if(!r){e(null);return}r.clearRect(0,0,G,G),r.drawImage(t,0,0,G,G);let i=n.toDataURL(`image/png`),a=i.indexOf(`,`);e(a>=0?i.slice(a+1):null)}catch{e(null)}},t.onerror=()=>e(null),t.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n)}`})},be=(e,t)=>e.map(e=>{let n=e.isSkill?t.skill:e.isOpenChamber?`OpenChamber`:e.isBuiltIn?t.system:e.scope||e.agent||t.command;return{id:e.id,title:`/${e.name}`,subtitle:e.description,badge:n,iconName:me(e)}}),q=e=>e.map(e=>({id:`${e.name}-${e.scope}`,title:e.name,subtitle:e.description,badge:e.scope,iconName:he()})),xe=({agents:e,sessions:t,recentFiles:n,pathHits:r,untitledSession:i,sessionBadge:a})=>{let o=[];for(let t of e)o.push({id:`agent:${t.name}`,title:`@${t.name}`,subtitle:t.description,iconName:_e()});for(let e of t)o.push({id:`session:${e.id}`,title:e.title||i,badge:a,iconName:ve()});for(let e of n)o.push({id:`recent:${e.path}`,title:e.relativePath||e.name,iconName:ge(e)});for(let e of r)o.push({id:`file:${e.path}`,title:e.relativePath||e.name,iconName:ge(e)});return o},J=(e,t)=>{let n=t.trim();if(!n)return[...e].sort((e,t)=>e.isBuiltIn===t.isBuiltIn?e.name.localeCompare(t.name):e.isBuiltIn?-1:1);let r=D([...e],n,e=>[e.name,e.description??``]);return r.sort((e,t)=>e.score===t.score?e.item.isBuiltIn===t.item.isBuiltIn?e.item.name.localeCompare(t.item.name):e.item.isBuiltIn?-1:1:e.score-t.score),r.map(e=>e.item)},Y=(e,t)=>{if(!e.includes(`/`)||t.size===0)return[];let n=RegExp(`(^|\\s)/(${u})?([A-Za-z0-9][A-Za-z0-9_-]*)(?=$|\\s)`,`g`),r=[],i;for(;(i=n.exec(e))!==null;){let e=i[3]??``;if(!t.has(e.toLowerCase()))continue;let n=i[2]??``,a=i.index+(i[1]?.length??0);r.push({start:a,end:a+1+n.length+e.length,name:e,hasSlot:n.length>0})}return r},X=(e,t,n=e.length)=>{let r=Y(e,t).filter(e=>!e.hasSlot);if(r.length===0)return null;let i=e,a=n;for(let e=r.length-1;e>=0;--e){let t=r[e].start+1;i=`${i.slice(0,t)}${u}${i.slice(t)}`,a>t&&(a+=u.length)}return i===e?null:{text:i,caret:a}},Se=e=>e.startsWith(u)?e.slice(u.length):e,Ce=e=>{if(e.inputMode===`shell`)return null;let t=e.text,n=Math.max(0,Math.min(e.cursor,t.length));if(t.startsWith(`/`)){let e=t.indexOf(` `),r=t.indexOf(`
2
2
  `),i=Math.min(e===-1?t.length:e,r===-1?t.length:r);if(n<=i&&e===-1)return{kind:`slash-command`,query:Se(t.substring(1,i)),tokenStart:0,tokenEnd:i}}let r=t.substring(0,n),i=r.lastIndexOf(`/`);if(i!==-1){let e=i>0?r[i-1]:null,t=Se(r.substring(i+1)),a=t.includes(` `)||t.includes(`
3
3
  `);if((!e||/\s/.test(e))&&!a)return{kind:`slash-skill`,query:t,tokenStart:i,tokenEnd:n}}let a=r.lastIndexOf(`#`);if(a!==-1){let e=a>0?r[a-1]:null,t=r.substring(a+1);if((!e||/\s/.test(e))&&!t.includes(` `)&&!t.includes(`
4
4
  `))return{kind:`snippet`,query:t,tokenStart:a,tokenEnd:n}}let o=ie({value:t,cursorPosition:n,inputSource:e.mentionInputSource??`manual`,insertedText:e.insertedText});return o===null?null:{kind:`mention`,query:o,tokenStart:r.lastIndexOf(`@`),tokenEnd:n}},we=e=>e===`mention`?`@`:e===`snippet`?`#`:`/`,Te=(e,t,n)=>{if(n&&n.tokenStart>=0&&n.tokenEnd>=n.tokenStart&&n.tokenEnd<=e.length&&e.startsWith(we(n.kind),n.tokenStart))return{start:n.tokenStart,end:n.tokenEnd};let r=Ce({text:e,cursor:t});return r?{start:r.tokenStart,end:r.tokenEnd}:null},Ee=(e,t)=>e===t||e.length===t.length&&e.every((e,n)=>{let r=t[n];return r!=null&&e.id===r.id&&e.title===r.title&&(e.subtitle??``)===(r.subtitle??``)&&(e.badge??``)===(r.badge??``)&&e.iconName===r.iconName}),De=(e,t)=>e.highlightedIndex===t.highlightedIndex&&Ee(e.rows,t.rows),Oe=(e,t)=>Ee(e,t)?e:t.slice(),ke=(e,t,n)=>{e&&(t.current&&De(t.current,n)||(t.current=n,e(n)))},Ae=(e,t)=>{t.current=null,e?.({rows:[],highlightedIndex:0})},Z=e=>{if(!e)return``;let t=e.replace(/\\/g,`/`),n=t.startsWith(`//`),r=t.replace(/\/+/g,`/`);n&&!r.startsWith(`//`)&&(r=`/${r}`);let i=r===`/`,a=/^[A-Za-z]:\/$/.test(r);return!i&&!a&&(r=r.replace(/\/+$/,``)),r},je=e=>/^[A-Za-z]:\//.test(e)?e.toLowerCase():e,Me=(e,t)=>{let n=Z(t),r=Z(e);if(!n||!r)return!1;let i=je(n),a=je(r);return a===i||a.startsWith(`${i}/`)},Ne=e=>{if(!e||typeof e!=`object`)return{};let t=e,n={};for(let[e,r]of Object.entries(t)){let t=Z(e);if(!t||!r||typeof r!=`object`)continue;let i=r,a=Array.isArray(i.openPaths)?Array.from(new Set(i.openPaths.filter(e=>typeof e==`string`).map(e=>Z(e)).filter(e=>Me(e,t)))):[],o=Array.isArray(i.expandedPaths)?Array.from(new Set(i.expandedPaths.filter(e=>typeof e==`string`).map(e=>Z(e)).filter(e=>Me(e,t)))):[],s=typeof i.selectedPath==`string`?Z(i.selectedPath):null,c=s&&Me(s,t)?s:a[0]??null,l=typeof i.touchedAt==`number`&&Number.isFinite(i.touchedAt)?i.touchedAt:Date.now(),u=n[t];if(u){let e=Array.from(new Set([...u.openPaths,...a])),r=Array.from(new Set([...u.expandedPaths,...o]));n[t]={openPaths:e,selectedPath:u.selectedPath??c??e[0]??null,expandedPaths:r,touchedAt:Math.max(u.touchedAt,l)};continue}n[t]={openPaths:a,selectedPath:c,expandedPaths:o,touchedAt:l}}return n},Pe=(e,t)=>{let n=Object.entries(e);if(n.length<=t)return e;n.sort((e,t)=>(t[1]?.touchedAt??0)-(e[1]?.touchedAt??0));let r={};for(let[e,i]of n.slice(0,t))r[e]=i;return r},Fe=e=>e?{...e,touchedAt:Date.now()}:{openPaths:[],selectedPath:null,expandedPaths:[],touchedAt:Date.now()},Ie=p()(h(m((e,t)=>({byRoot:{},addOpenPath:(t,n,r)=>{let i=Z((t||``).trim()),a=Z((n||``).trim());!i||!a||!r?.allowOutsideRoot&&!Me(a,i)||e(e=>{let t=e.byRoot[i],n=Fe(t),r=n.openPaths.includes(a),o=r?n.openPaths:[...n.openPaths,a],s=n.selectedPath??a;return t&&r&&t.selectedPath===s?e:{byRoot:Pe({...e.byRoot,[i]:{...n,openPaths:o,selectedPath:s}},20)}})},removeOpenPath:(t,n)=>{let r=Z((t||``).trim()),i=Z((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=je(i),a=e=>je(e)===n,o=t.selectedPath?a(t.selectedPath):!1;if(!t.openPaths.some(a)&&!o)return e;let s=t.openPaths.filter(e=>!a(e)),c=o?s[0]??null:t.selectedPath;return{byRoot:Pe({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeOpenPathsByPrefix:(t,n)=>{let r=Z((t||``).trim()),i=Z((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=je(i),a=n.endsWith(`/`)?n:`${n}/`,o=e=>{let t=je(e);return t===n||t.startsWith(a)},s=t.openPaths.filter(e=>!o(e));if(s.length===t.openPaths.length)return e;let c=t.selectedPath&&o(t.selectedPath)?s[0]??null:t.selectedPath;return{byRoot:Pe({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeExpandedPathsByPrefix:(t,n)=>{let r=Z((t||``).trim()),i=Z((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=je(i),a=n.endsWith(`/`)?n:`${n}/`,o=t.expandedPaths.filter(e=>{let t=je(e);return t!==n&&!t.startsWith(a)});return o.length===t.expandedPaths.length?e:{byRoot:Pe({...e.byRoot,[r]:{...t,expandedPaths:o,touchedAt:Date.now()}},20)}})},setSelectedPath:(t,n,r)=>{let i=Z((t||``).trim()),a=n?Z(n.trim()):null;!i||a&&!r?.allowOutsideRoot&&!Me(a,i)||e(e=>{let t=e.byRoot[i],n=Fe(t),r=a&&!n.openPaths.includes(a)?[...n.openPaths,a]:n.openPaths;return t&&t.selectedPath===a&&r===t.openPaths?e:{byRoot:Pe({...e.byRoot,[i]:{...n,openPaths:r,selectedPath:a}},20)}})},ensureSelectedPath:e=>{let n=Z((e||``).trim());if(!n)return;let r=t().byRoot[n];if(!r||r.selectedPath)return;let i=r.openPaths[0]??null;i&&t().setSelectedPath(n,i)},toggleExpandedPath:(t,n)=>{let r=Z((t||``).trim()),i=Z((n||``).trim());!r||!i||!Me(i,r)||e(e=>{let t=e.byRoot[r],n=Fe(t),a=n.expandedPaths.includes(i)?n.expandedPaths.filter(e=>e!==i):[...n.expandedPaths,i];return t&&t.expandedPaths===a&&t.selectedPath===n.selectedPath&&t.openPaths===n.openPaths?e:{byRoot:Pe({...e.byRoot,[r]:{...n,expandedPaths:a}},20)}})},expandPath:(t,n)=>{let r=Z((t||``).trim()),i=Z((n||``).trim());!r||!i||!Me(i,r)||e(e=>{let t=e.byRoot[r],n=Fe(t);return n.expandedPaths.includes(i)&&t?e:{byRoot:Pe({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,i]}},20)}})},expandPaths:(t,n)=>{let r=Z((t||``).trim());if(!r||!n||n.length===0)return;let i=n.map(e=>Z((e||``).trim())).filter(e=>e&&Me(e,r));i.length!==0&&e(e=>{let t=e.byRoot[r],n=Fe(t),a=new Set(n.expandedPaths),o=i.filter(e=>!a.has(e));return o.length===0?e:{byRoot:Pe({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,...o]}},20)}})}}),{name:`files-view-tabs-store`,version:2,storage:a(),migrate:e=>{if(!e||typeof e!=`object`)return{byRoot:{}};let t=e.byRoot;return{byRoot:Ne(t)}},partialize:e=>({byRoot:Ne(e.byRoot)})}),{name:`files-view-tabs-store`})),Le=(e,t)=>{let n=(0,H.c)(4),r=t===void 0?200:t,[i,a]=V.useState(e),o,s;return n[0]!==r||n[1]!==e?(o=()=>{let t=window.setTimeout(()=>{a(e)},r);return()=>{window.clearTimeout(t)}},s=[e,r],n[0]=r,n[1]=e,n[2]=o,n[3]=s):(o=n[2],s=n[3]),V.useEffect(o,s),i},Re=()=>{let e=(0,H.c)(17),t=T(ze),n=j(),r;e[0]===t?r=e[1]:(r=e=>t?e.getAttachment(t):void 0,e[0]=t,e[1]=r);let i=N(r),a=T(Be),o=T(Ve),s=k(He),c=k(Ue),l=b(We);if(t){let r;e[2]===i?r=e[3]:(r=O(i),e[2]=i,e[3]=r);let o=r;if(o)return o;let s;e[4]!==t||e[5]!==a?(s=a.get(t),e[4]=t,e[5]=a,e[6]=s):s=e[6];let c=s;if(c?.path)return c.path;let l;if(e[7]!==t||e[8]!==n){let r;e[10]===t?r=e[11]:(r=e=>e.id===t,e[10]=t,e[11]=r),l=n.find(r),e[7]=t,e[8]=n,e[9]=l}else l=e[9];let u=l;if(u?.directory)return u.directory}if(o?.open&&(o.bootstrapPendingDirectory||o.directoryOverride))return(o.bootstrapPendingDirectory||o.directoryOverride)??void 0;if(s){let t;if(e[12]!==s||e[13]!==c){let n;e[15]===s?n=e[16]:(n=e=>e.id===s,e[15]=s,e[16]=n),t=c.find(n),e[12]=s,e[13]=c,e[14]=t}else t=e[14];let n=t;if(n?.path)return n.path}return l??void 0};function ze(e){return e.currentSessionId}function Be(e){return e.worktreeMetadata}function Ve(e){return e.newSessionDraft}function He(e){return e.activeProjectId}function Ue(e){return e.projects}function We(e){return e.currentDirectory}var Ge=`absolute z-[100] min-w-0 w-full bottom-full mb-2 left-0 flex flex-col rounded-xl`,Ke=`pointer-events-auto absolute z-[100] min-w-0 flex flex-col rounded-xl`;function qe(e,t){return P(e?Ke:Ge,e?`oc-mobile-overlay-surface oc-mobile-overlay-surface--translucent oc-composer-autocomplete-surface`:`bg-background border-2 border-border/60 shadow-none`,t)}function Je(e,t){return e?`oc-composer-autocomplete-row`:t?`bg-interactive-selection`:void 0}var Ye=.4,Xe=e=>{let t=e.gap??8,n=Math.min(e.composerTop-t,e.visibleBottom-t);return{left:e.composerLeft,width:e.composerWidth,bottom:Math.max(0,e.fixedContainingBottom-n),maxHeight:Ze({popupBottom:n,boundaryTop:e.boundaryTop,viewportHeight:e.viewportHeight,gap:t})}},Ze=e=>{let t=e.gap??8,n=Math.max(0,e.popupBottom-e.boundaryTop-t),r=e.viewportHeight*Ye,i=Math.floor(Math.min(n,r));return n>=120?Math.min(n,Math.max(120,i)):i},Qe=(e,t=0)=>{let n=e.closest(`main`);if(!n)return null;let r=(e.closest(`.mobile-chat-screen__content`)?.parentElement??n.parentElement?.closest(`main`)??n).querySelector(`:scope > .oc-mobile-detail-navigation`)?.getBoundingClientRect().bottom,i=n.getBoundingClientRect().top;return Math.max(r===void 0?i:Math.max(r,i),t)},$e=(e,t)=>{let n=(0,H.c)(5),[r,i]=V.useState(void 0),a;n[0]!==t||n[1]!==e?(a=()=>{if(!t){i(void 0);return}let n=0,r=0,a=()=>{let t=e.current?.parentElement;if(!t)return;let n=t.getBoundingClientRect(),r=window.visualViewport,a=r?.offsetTop??0,o=r?.height??window.innerHeight,s=window.innerHeight,c=a+o,l=Qe(t,a)??a,u=Xe({composerTop:n.top,composerLeft:n.left,composerWidth:n.width,fixedContainingBottom:s,visibleBottom:c,boundaryTop:l,viewportHeight:o});i(e=>e&&e.left===u.left&&e.width===u.width&&e.bottom===u.bottom&&e.maxHeight===u.maxHeight?e:u)},o=()=>{a(),n&&window.cancelAnimationFrame(n),r&&window.clearTimeout(r),n=window.requestAnimationFrame(()=>{a(),r=window.setTimeout(a,220)})};return a(),window.addEventListener(`resize`,a),window.addEventListener(`oc:keyboard-settled`,o),window.addEventListener(`oc:keyboard-anim`,o),window.visualViewport?.addEventListener(`resize`,a),window.visualViewport?.addEventListener(`scroll`,a),()=>{n&&window.cancelAnimationFrame(n),r&&window.clearTimeout(r),window.removeEventListener(`resize`,a),window.removeEventListener(`oc:keyboard-settled`,o),window.removeEventListener(`oc:keyboard-anim`,o),window.visualViewport?.removeEventListener(`resize`,a),window.visualViewport?.removeEventListener(`scroll`,a)}},n[0]=t,n[1]=e,n[2]=a):a=n[2];let o;return n[3]===t?o=n[4]:(o=[t],n[3]=t,n[4]=o),V.useLayoutEffect(a,o),t?r:void 0},et=V.forwardRef((e,t)=>{let n=(0,H.c)(24),{isMobile:r,className:i,style:a,children:o}=e,s=V.useRef(null),c=$e(s,r),l=typeof document<`u`?document.body:null;if(!r){let e;n[0]===i?e=n[1]:(e=qe(!1,i),n[0]=i,n[1]=e);let r;return n[2]!==o||n[3]!==t||n[4]!==a||n[5]!==e?(r=(0,U.jsx)(`div`,{ref:t,className:e,style:a,children:o}),n[2]=o,n[3]=t,n[4]=a,n[5]=e,n[6]=r):r=n[6],r}let u;n[7]===i?u=n[8]:(u=qe(!0,i),n[7]=i,n[8]=u);let d;n[9]===c?d=n[10]:(d=c?{left:c.left,width:c.width,bottom:c.bottom,maxHeight:c.maxHeight,overflow:`hidden`}:{visibility:`hidden`},n[9]=c,n[10]=d);let f;n[11]!==a||n[12]!==d?(f={...a,...d},n[11]=a,n[12]=d,n[13]=f):f=n[13];let p;n[14]!==o||n[15]!==t||n[16]!==u||n[17]!==f?(p=(0,U.jsx)(`div`,{className:`pointer-events-none fixed inset-0 z-[100]`,children:(0,U.jsx)(`div`,{ref:t,className:u,style:f,children:o})}),n[14]=o,n[15]=t,n[16]=u,n[17]=f,n[18]=p):p=n[18];let m=p,h;n[19]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,U.jsx)(`span`,{ref:s,className:`hidden`,"aria-hidden":!0}),n[19]=h):h=n[19];let g;n[20]===m?g=n[21]:(g=l?(0,W.createPortal)(m,l):m,n[20]=m,n[21]=g);let _;return n[22]===g?_=n[23]:(_=(0,U.jsxs)(U.Fragment,{children:[h,g]}),n[22]=g,n[23]=_),_});et.displayName=`ComposerAutocompleteLayer`;var tt=()=>{let e=null,t=!1,n=!1;return{pointerDown:(n,r)=>{e={x:n,y:r},t=!1},pointerMove:(n,r)=>{e&&Math.hypot(n-e.x,r-e.y)>6&&(t=!0)},pointerCancel:()=>{e=null,t=!1},pointerUp:r=>{if(!e)return!1;let i=!t;return e=null,t=!1,i?(n=!0,r(),!0):(n=!0,!1)},click:e=>n?(n=!1,!1):(e(),!0)}},nt=V.forwardRef(({searchQuery:e,onFileSelect:t,onAgentSelect:n,onSessionSelect:r,onClose:a,style:o,onRowsChange:c},u)=>{let{t:d}=te(),f=Re()??``,p=T(e=>e.currentSessionId),m=oe(e=>e.activeSessions),h=k(e=>e.activeProjectId),g=k(e=>e.projects),_=V.useMemo(()=>g.find(e=>e.id===h)?.path??null,[h,g]),v=V.useMemo(()=>{let e=_||f;return e?e.replace(/\\/g,`/`).replace(/\/+$/,``):null},[_,f]),y=Ie(e=>v?e.byRoot[v]:void 0),b=re(e=>e.getVisibleAgents),x=S(e=>e.searchFiles),ee=Le(e,180),C=l(),ne=s(),[ie,D]=V.useState([]),[O,se]=V.useState([]),[j,ce]=V.useState(!1),[N,I]=V.useState(0),L=V.useRef(0),[R,de]=V.useState(360),[z,B]=V.useState({}),[fe,H]=V.useState({}),W=V.useRef([]),me=V.useRef([]),he=V.useRef([]),_e=V.useRef(null),ve=V.useRef(null),G=V.useRef(null);G.current||=tt();let K=i(e=>e.isMobile),ye=(e??``).trim(),be=V.useMemo(()=>{if(!v||!y)return[];let e=[y.selectedPath,...y.openPaths.slice().reverse()].filter(e=>typeof e==`string`&&e.length>0),t=new Set,n=[];for(let r of e){if(t.has(r))continue;t.add(r);let e=r.replace(/\\/g,`/`),i=e.split(`/`).filter(Boolean).pop()||e,a=e.startsWith(`${v}/`)?e.slice(v.length+1):e;n.push({name:i,path:e,relativePath:a,extension:i.includes(`.`)?i.split(`.`).pop()?.toLowerCase():void 0})}return A(n,ye,{limit:6})},[ye,v,y]),q=V.useMemo(()=>ye.length>0?O:O.slice(0,2),[O,ye.length]),J=V.useMemo(()=>r?le({sessions:m,currentSessionId:p,searchQuery:ye}):[],[m,p,ye,r]),Y=be,X=ie;V.useEffect(()=>{let e=e=>{let t=e.target;!t||!_e.current||_e.current.contains(t)||a()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[a]),V.useEffect(()=>{if(!f){D([]);return}let e=(ee??``).trim(),t=E(e);if(!t){D([]);return}let n=!1;ce(!0);let r={includeHidden:C,respectGitignore:!ne};return Promise.all([x(f,t,80,{...r,type:`file`}),x(f,t,40,{...r,type:`directory`})]).then(([t,r])=>{if(n)return;let i=new Set(be.map(e=>e.path));D(M({files:t,directories:r,query:e,excludePaths:i,limit:20}))}).catch(()=>{n||D([])}).finally(()=>{n||ce(!1)}),()=>{n=!0}},[f,ee,be,x,C,ne]),V.useEffect(()=>{let t=b().filter(e=>e.mode&&e.mode!==`primary`).map(e=>({name:e.name,description:e.description,mode:e.mode}));se(ae(t,e??``))},[b,e]),V.useEffect(()=>{I(0),B({}),H({})},[X,Y.length,q.length,J.length]),V.useEffect(()=>{L.current=N},[N]),V.useEffect(()=>{W.current[N]?.scrollIntoView({block:`nearest`})},[N]),V.useEffect(()=>{let e=null,t=()=>{e!==null&&cancelAnimationFrame(e),e=requestAnimationFrame(()=>{let e={},t={};me.current.forEach((n,r)=>{if(!n)return;let i=he.current[r]?.offsetWidth??n.scrollWidth,a=Math.max(0,i-n.clientWidth),o=a>8;if(e[r]=o,o){let e=Math.max(.6,a/110);t[r]=e}}),B(e),H(t)})};return t(),window.addEventListener(`resize`,t),()=>{e!==null&&cancelAnimationFrame(e),window.removeEventListener(`resize`,t)}},[X,Y]),V.useEffect(()=>{let e=me.current[N];if(!e)return;let t=()=>{let t=e.clientWidth;t>0&&de(t)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>{n.disconnect()}},[N]);let Se=w(e=>{t(e)}),Ce=w(e=>{n?.(e)}),we=w(e=>{r?.(e)}),Te=(e,t)=>({onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&G.current?.pointerDown(e.clientX,e.clientY)},onPointerMove:e=>{e.pointerType===`touch`&&G.current?.pointerMove(e.clientX,e.clientY)},onPointerUp:e=>{e.pointerType===`touch`&&(G.current?.pointerUp(t)??!1)&&(e.preventDefault(),e.stopPropagation())},onPointerCancel:()=>G.current?.pointerCancel(),onClick:()=>{G.current?.click(t)},onMouseMove:()=>I(e)}),Ee=e=>{let t=q.length+J.length+Y.length+X.length;if(t===0)return;let n=(e%t+t)%t;if(n<q.length){let e=q[n];e&&Ce(e.name);return}let r=n-q.length;if(r<J.length){let e=J[r];e&&we(e);return}let i=r-J.length,a=i<Y.length?Y[i]:X[i-Y.length];a&&Se(a)};V.useEffect(()=>{ke(c,ve,{rows:xe({agents:q,sessions:J,recentFiles:Y,pathHits:X,untitledSession:d(`chat.fileMentionAutocomplete.untitledSession`),sessionBadge:d(`chat.fileMentionAutocomplete.sessionType`)}),highlightedIndex:N})},[c,N,d,q,X,Y,J]);let De=V.useRef(c);De.current=c,V.useEffect(()=>()=>{Ae(De.current,ve)},[]),V.useImperativeHandle(u,()=>({acceptIndex:e=>{Ee(e)},handleKeyDown:e=>{if(e===`Escape`){a();return}let t=q.length+J.length+Y.length+X.length;if(t!==0){if(e===`ArrowDown`){I(e=>(e+1)%t);return}if(e===`ArrowUp`){I(e=>(e-1+t)%t);return}(e===`Enter`||e===`Tab`)&&Ee(L.current)}}}),[X,Y,q,J,a,Se,Ce,we]);let Oe=e=>(0,U.jsx)(F,{name:ge(e),className:`h-3.5 w-3.5 text-current`});return(0,U.jsxs)(et,{ref:_e,isMobile:K,className:`max-w-[640px] max-h-64`,style:o,children:[(0,U.jsx)(pe,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0`,children:(0,U.jsxs)(`div`,{className:`pb-2`,children:[q.length>0&&(0,U.jsx)(`div`,{className:`px-3 pb-1 pt-2 typography-meta font-medium text-muted-foreground`,children:d(`chat.fileMentionAutocomplete.groups.agents`)}),q.map((e,t)=>{let n=N===t;return(0,U.jsx)(`div`,{ref:e=>{W.current[t]=e},className:P(`flex items-start gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,K&&`min-h-11`,Je(K,n),!K&&n&&`text-interactive-selection-foreground`),...Te(t,()=>Ce(e.name)),children:(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsxs)(`div`,{className:`font-semibold truncate`,children:[`@`,e.name]}),e.description&&!K?(0,U.jsx)(`div`,{className:`typography-meta text-muted-foreground truncate`,children:e.description}):null]})},`agent-${e.name}`)}),q.length===2&&ye.length===0&&O.length>2&&(0,U.jsx)(`div`,{className:`px-3 py-1 typography-meta text-muted-foreground`,children:d(`chat.fileMentionAutocomplete.searchMoreAgents`)}),J.length>0&&(0,U.jsx)(`div`,{className:`px-3 pb-1 pt-2 typography-meta font-medium text-muted-foreground`,children:d(`chat.fileMentionAutocomplete.groups.sessions`)}),J.map((e,t)=>{let n=q.length+t,r=N===n;return(0,U.jsxs)(`div`,{ref:e=>{W.current[n]=e},className:P(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,K&&`min-h-11`,Je(K,r),!K&&r&&`text-interactive-selection-foreground`),...Te(n,()=>we(e)),children:[(0,U.jsx)(F,{name:`chat-thread`,className:`h-4 w-4 flex-shrink-0 text-[var(--primary-base)]`}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.title||d(`chat.fileMentionAutocomplete.untitledSession`),children:e.title||d(`chat.fileMentionAutocomplete.untitledSession`)}),K?null:(0,U.jsx)(`span`,{className:`flex-shrink-0 typography-meta text-muted-foreground`,children:d(`chat.fileMentionAutocomplete.sessionType`)})]},`session-${e.id}`)}),Y.length>0&&(0,U.jsx)(`div`,{className:`px-3 pb-1 pt-2 typography-meta font-medium text-muted-foreground`,children:d(`chat.fileMentionAutocomplete.groups.recentFiles`)}),Y.map((e,t)=>{let n=q.length+J.length+t,r=e.relativePath||e.name,i=ue(r,{maxLength:60}),a=N===n,o=z[n]??!1,s=fe[n]??2.6;return(0,U.jsxs)(`div`,{ref:e=>{W.current[n]=e},className:P(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,K&&`min-h-11`,Je(K,a),!K&&a&&`text-interactive-selection-foreground`),...Te(n,()=>Se(e)),children:[Oe(e),(0,U.jsxs)(`span`,{ref:e=>{me.current[n]=e},className:`relative flex-1 min-w-0 overflow-hidden file-mention-marquee-container`,style:a?{"--file-mention-marquee-width":`${R}px`,"--file-mention-marquee-duration":`${s}s`}:void 0,"aria-label":r,children:[(0,U.jsx)(`span`,{ref:e=>{he.current[n]=e},className:`absolute invisible whitespace-nowrap pointer-events-none`,"aria-hidden":!0,children:r}),o&&a?(0,U.jsx)(`span`,{className:`inline-block whitespace-nowrap file-mention-marquee`,children:r}):(0,U.jsx)(`span`,{className:`block truncate`,children:i})]})]},`recent-${e.path}`)}),X.length>0&&(0,U.jsx)(`div`,{className:`px-3 pb-1 pt-2 typography-meta font-medium text-muted-foreground`,children:d(`chat.fileMentionAutocomplete.groups.files`)}),X.map((e,t)=>{let n=q.length+J.length+Y.length+t,r=e.relativePath||e.name,i=ue(r,{maxLength:60}),a=N===n,o=z[n]??!1,s=fe[n]??2.6;return(0,U.jsxs)(`div`,{ref:e=>{W.current[n]=e},className:P(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,K&&`min-h-11`,Je(K,a),!K&&a&&`text-interactive-selection-foreground`),...Te(n,()=>Se(e)),children:[Oe(e),(0,U.jsxs)(`span`,{ref:e=>{me.current[n]=e},className:`relative flex-1 min-w-0 overflow-hidden file-mention-marquee-container`,style:a?{"--file-mention-marquee-width":`${R}px`,"--file-mention-marquee-duration":`${s}s`}:void 0,"aria-label":r,children:[(0,U.jsx)(`span`,{ref:e=>{he.current[n]=e},className:`absolute invisible whitespace-nowrap pointer-events-none`,"aria-hidden":!0,children:r}),o&&a?(0,U.jsx)(`span`,{className:`inline-block whitespace-nowrap file-mention-marquee`,children:r}):(0,U.jsx)(`span`,{className:`block truncate`,children:i})]})]},e.path)}),j&&X.length===0?(0,U.jsx)(`div`,{className:`flex items-center justify-center py-3`,children:(0,U.jsx)(F,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):null,!j&&X.length===0&&Y.length===0&&q.length===0&&J.length===0&&(0,U.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:d(`chat.fileMentionAutocomplete.empty`)})]})}),!K&&(0,U.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:d(`chat.autocomplete.keyboardHint`)})]})}),rt=new Set([`new`,`fork`,`compact`,`undo`,`redo`,`model`,`goal`]),it=(e,t)=>{if(!t||e.isSkill)return!1;let n=e.name?.trim().toLowerCase();return!!(n&&rt.has(n))},at=(e,t)=>!e||t({name:e}),ot=` `,st=(e,t)=>{let n=Math.max(0,Math.min(t,e.length)),r=n;for(;r>0&&!/\s/.test(e[r-1]);)--r;return r>=2&&e[r-1]===ot&&e[r-2]===`/`&&(r-=2),e[r]===`/`?{start:r,end:n}:null},ct=`text-[10px] leading-none uppercase font-bold tracking-tight px-1.5 py-1 rounded border flex-shrink-0`,lt=P(ct,`bg-[color-mix(in_srgb,var(--primary-base)_12%,transparent)] text-[color-mix(in_srgb,var(--primary-base)_70%,transparent)] border-[color-mix(in_srgb,var(--primary-base)_24%,transparent)]`),ut=P(ct,`bg-[color-mix(in_srgb,var(--status-success)_12%,transparent)] text-[color-mix(in_srgb,var(--status-success)_70%,transparent)] border-[color-mix(in_srgb,var(--status-success)_24%,transparent)]`),dt=P(ct,`bg-[color-mix(in_srgb,var(--status-info)_12%,transparent)] text-[color-mix(in_srgb,var(--status-info)_70%,transparent)] border-[color-mix(in_srgb,var(--status-info)_24%,transparent)]`),ft=P(ct,`bg-[var(--surface-muted)] text-muted-foreground border-[var(--interactive-border)]/60`),pt=(e,t)=>e.length===t.length&&e.every((e,n)=>e.id===t[n]?.id),mt=(e,t)=>{let n=!!e.sessionID;return{hasSession:n,canStartSessionCommand:n||e.hasNewDraft,canUseReviewHandoffFlow:n&&!t&&!o()}},ht=V.forwardRef(({searchQuery:e,onCommandSelect:t,onClose:n,directory:r,style:a,commandPolicy:o,commandContext:s,onRowsChange:c},l)=>{let{t:u}=te(),d=i(e=>e.isMobile),f=T(e=>e.currentSessionId),p=T(e=>!!e.newSessionDraft?.open),m=T(V.useCallback(e=>f?e.getDirectoryForSession(f):void 0,[f])),h=se(f??``,m??void 0),g=V.useMemo(()=>s??{sessionID:f??null,hasMessages:h.length>0,hasNewDraft:p},[s,f,h.length,p]),{hasSession:_,canStartSessionCommand:v,canUseReviewHandoffFlow:y}=V.useMemo(()=>mt(g,d),[g,d]),b=g.hasMessages,[x,S]=V.useState([]),[ee,C]=V.useState(!1),w=ce({directory:r}),re=V.useMemo(()=>w.data??[],[w.data]),ie=w.isFetching,ae=ne({directory:r}),oe=V.useMemo(()=>ae.data??[],[ae.data]),[E,D]=V.useState(0),O=V.useRef(0),k=V.useRef(!1),A=V.useRef([]),j=V.useRef(null),le=V.useRef(!1),M=V.useRef(null),N=V.useRef(!1),ue=V.useRef(null);V.useEffect(()=>{let e=e=>{let t=e.target;!t||!j.current||j.current.contains(t)||n()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[n]),V.useEffect(()=>{(async()=>{C(ie);try{let t=re.map((e,t)=>({id:`opencode:${e.scope??`global`}:${e.name}:${e.agent??``}:${e.model??``}:${t}`,name:e.name,source:`opencode`,description:e.description,agent:e.agent??void 0,model:e.model??void 0,isBuiltIn:e.isBuiltIn,isSkill:e.source===`skill`,scope:e.scope,reference:e.reference})),n=oe.map((e,t)=>({id:`skill:${e.scope}:${e.source??`opencode`}:${e.name}:${t}`,name:e.name,source:`skill`,description:e.description,isSkill:!0,scope:e.scope})),r=[{id:`openchamber:new`,name:`new`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.newDescription`),isBuiltIn:!0},..._&&!b?[{id:`openchamber:init`,name:`init`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.initDescription`),isBuiltIn:!0}]:[],..._?[{id:`openchamber:undo`,name:`undo`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.undoDescription`),isBuiltIn:!0},{id:`openchamber:redo`,name:`redo`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.redoDescription`),isBuiltIn:!0},{id:`openchamber:fork`,name:`fork`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.forkDescription`),isBuiltIn:!0},{id:`openchamber:timeline`,name:`timeline`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.timelineDescription`),isBuiltIn:!0}]:[],{id:`openchamber:model`,name:`model`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.modelDescription`),isBuiltIn:!0},{id:`openchamber:compact`,name:`compact`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.compactDescription`),isBuiltIn:!0},..._?[{id:`openchamber:summary`,name:`summary`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.summaryDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:workspace-review`,name:`workspace-review`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.workspaceReviewDescription`),isOpenChamber:!0}]:[],...y?[{id:`openchamber:handoff-review`,name:`handoff-review`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.handoffReviewDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:craft-goal`,name:`craft-goal`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.craftGoalDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:goal`,name:`goal`,source:`openchamber`,description:u(`chat.goal.button.armAria`),isBuiltIn:!0}]:[],...v?[{id:`openchamber:catch-up`,name:`catch-up`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.catchUpDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:debug`,name:`debug`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.debugDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:weigh`,name:`weigh`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.weighDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:explore`,name:`explore`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.exploreDescription`),isOpenChamber:!0}]:[],...t,...n],i=!b,a=J(r.filter(e=>(i||e.name!==`init`)&&(o?.(e)??!0)),e);S(e=>pt(e,a)?e:a)}catch{let t=!b,n=J([{id:`openchamber:new`,name:`new`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.newDescription`),isBuiltIn:!0},..._&&!b?[{id:`openchamber:init`,name:`init`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.initDescription`),isBuiltIn:!0}]:[],..._?[{id:`openchamber:undo`,name:`undo`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.undoDescription`),isBuiltIn:!0},{id:`openchamber:redo`,name:`redo`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.redoDescription`),isBuiltIn:!0},{id:`openchamber:fork`,name:`fork`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.forkDescription`),isBuiltIn:!0},{id:`openchamber:timeline`,name:`timeline`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.timelineDescription`),isBuiltIn:!0}]:[],{id:`openchamber:model`,name:`model`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.modelDescription`),isBuiltIn:!0},{id:`openchamber:compact`,name:`compact`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.compactDescription`),isBuiltIn:!0},..._?[{id:`openchamber:summary`,name:`summary`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.summaryDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:workspace-review`,name:`workspace-review`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.workspaceReviewDescription`),isOpenChamber:!0}]:[],...y?[{id:`openchamber:handoff-review`,name:`handoff-review`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.handoffReviewDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:craft-goal`,name:`craft-goal`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.craftGoalDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:goal`,name:`goal`,source:`openchamber`,description:u(`chat.goal.button.armAria`),isBuiltIn:!0}]:[],...v?[{id:`openchamber:catch-up`,name:`catch-up`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.catchUpDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:debug`,name:`debug`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.debugDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:weigh`,name:`weigh`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.weighDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:explore`,name:`explore`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.exploreDescription`),isOpenChamber:!0}]:[]].filter(e=>(t||e.name!==`init`)&&(o?.(e)??!0)),e);S(e=>pt(e,n)?e:n)}finally{C(!1)}})()},[e,b,_,v,y,re,ie,oe,u,o]),V.useEffect(()=>{D(0)},[x]),V.useEffect(()=>{O.current=E},[E]),V.useEffect(()=>{A.current[E]?.scrollIntoView({block:`nearest`})},[E]),V.useEffect(()=>{ke(c,ue,{rows:be(x,{skill:u(`chat.commandAutocomplete.badge.skill`),command:u(`chat.commandAutocomplete.badge.command`),system:u(`chat.commandAutocomplete.badge.system`)}),highlightedIndex:E})},[x,c,E,u]);let I=V.useRef(c);I.current=c,V.useEffect(()=>()=>{Ae(I.current,ue)},[]),V.useImperativeHandle(l,()=>({acceptIndex:(e,n=!0)=>{let r=x[e];r&&t(r,it(r,n))},handleKeyDown:e=>{let r=x.length;if(e===`Escape`){n();return}if(r!==0){if(e===`ArrowDown`){k.current=!0,D(e=>(e+1)%r);return}if(e===`ArrowUp`){k.current=!0,D(e=>(e-1+r)%r);return}if(e===`Enter`||e===`Tab`){let n=(O.current%r+r)%r,i=x[n];i&&t(i,it(i,e===`Enter`))}}}}),[x,n,t]);let L=e=>{let t=me(e);switch(e.name){case`new`:return(0,U.jsx)(F,{name:t,className:`h-3.5 w-3.5`});case`init`:return(0,U.jsx)(F,{name:t,className:`h-3.5 w-3.5 text-green-500`});case`undo`:return(0,U.jsx)(F,{name:t,className:`h-3.5 w-3.5 text-orange-500`});case`redo`:return(0,U.jsx)(F,{name:t,className:`h-3.5 w-3.5 text-orange-500`});case`timeline`:return(0,U.jsx)(F,{name:t,className:`h-3.5 w-3.5`});case`compact`:return(0,U.jsx)(F,{name:t,className:`h-3.5 w-3.5 text-purple-500`});case`goal`:return(0,U.jsx)(F,{name:t,className:`h-3.5 w-3.5`});case`review`:return(0,U.jsx)(F,{name:t,className:`h-3.5 w-3.5 text-blue-500`});case`test`:case`build`:case`run`:return(0,U.jsx)(F,{name:t,className:`h-3.5 w-3.5 text-cyan-500`});default:return e.isBuiltIn?(0,U.jsx)(F,{name:t,className:`h-3.5 w-3.5 text-yellow-500`}):(0,U.jsx)(F,{name:t,className:`h-3.5 w-3.5 text-muted-foreground`})}};return(0,U.jsxs)(et,{ref:j,isMobile:d,className:`max-w-[450px] max-h-64`,style:a,children:[(0,U.jsx)(pe,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0 pb-2`,children:ee?(0,U.jsx)(`div`,{className:`flex items-center justify-center py-4`,children:(0,U.jsx)(F,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):(0,U.jsxs)(`div`,{children:[x.map((e,n)=>{let r=e.isBuiltIn,i=e.isOpenChamber;return(0,U.jsxs)(`div`,{ref:e=>{A.current[n]=e},className:P(`flex gap-2 px-3 py-2 cursor-pointer rounded-lg`,d?`items-center`:`items-start`,Je(d,n===E)),onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&(M.current={x:e.clientX,y:e.clientY},N.current=!1)},onPointerMove:e=>{if(e.pointerType!==`touch`||!M.current)return;let t=e.clientX-M.current.x,n=e.clientY-M.current.y;Math.hypot(t,n)>6&&(N.current=!0)},onPointerUp:n=>{if(n.pointerType!==`touch`)return;let r=N.current;M.current=null,N.current=!1,!r&&(n.preventDefault(),n.stopPropagation(),le.current=!0,t(e,it(e,d)))},onPointerCancel:()=>{M.current=null,N.current=!1},onClick:()=>{if(le.current){le.current=!1;return}t(e,it(e,d))},onMouseMove:()=>{k.current=!1,D(n)},children:[(0,U.jsx)(`div`,{className:P(!d&&`mt-0.5`),children:L(e)}),(0,U.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsxs)(`span`,{className:`typography-ui-label font-medium`,children:[`/`,e.name]}),e.isSkill?(0,U.jsx)(`span`,{className:lt,children:u(`chat.commandAutocomplete.badge.skill`)}):(0,U.jsx)(`span`,{className:lt,children:u(`chat.commandAutocomplete.badge.command`)}),i?(0,U.jsx)(`span`,{className:ft,children:`OpenChamber`}):r?(0,U.jsx)(`span`,{className:ft,children:u(`chat.commandAutocomplete.badge.system`)}):e.scope?(0,U.jsx)(`span`,{className:e.scope===`project`?dt:ut,children:e.scope}):null,e.agent&&(0,U.jsx)(`span`,{className:ft,children:e.agent})]}),e.description&&!d&&(0,U.jsx)(`div`,{className:`typography-meta text-muted-foreground mt-0.5 truncate`,children:e.description})]})]},e.id)}),x.length===0&&(0,U.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:u(`chat.commandAutocomplete.empty`)})]})}),!d&&(0,U.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:u(`chat.autocomplete.keyboardHint`)})]})});ht.displayName=`CommandAutocomplete`;function gt(e){return(e.description||e.content).replace(/\s+/g,` `).trim().slice(0,120)}var _t=V.forwardRef((e,t)=>{let n=(0,H.c)(62),{searchQuery:r,onSnippetSelect:a,onClose:o,style:s}=e,{t:c}=te(),l=V.useRef(null),u=i(vt),[d,f]=V.useState(0),p=V.useRef(0),m;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=[],n[0]=m):m=n[0];let[h,g]=V.useState(m),_;n[1]===Symbol.for(`react.memo_cache_sentinel`)?(_=[],n[1]=_):_=n[1];let v=V.useRef(_),y=fe(yt),b=fe(bt),x=fe(xt),S=fe(St),ee=i(Ct),C=i(wt),w,ne;n[2]===b?(w=n[3],ne=n[4]):(w=()=>{b()},ne=[b],n[2]=b,n[3]=w,n[4]=ne),V.useEffect(w,ne);let re,ie;n[5]!==r||n[6]!==y?(re=()=>{let e=r.trim();if(!e.length){let e=[...y].sort(Tt);g(e),f(+!!e.length);return}let t=D(y,e,Et);t.sort(Dt);let n=t.map(Ot);g(n),f(+!!n.length)},ie=[r,y],n[5]=r,n[6]=y,n[7]=re,n[8]=ie):(re=n[7],ie=n[8]),V.useEffect(re,ie);let T,ae;n[9]===d?(T=n[10],ae=n[11]):(T=()=>{p.current=d,v.current[d]?.scrollIntoView({block:`nearest`})},ae=[d],n[9]=d,n[10]=T,n[11]=ae),V.useEffect(T,ae);let oe,E;n[12]===o?(oe=n[13],E=n[14]):(E=()=>{let e=e=>{let t=e.target;t&&l.current&&!l.current.contains(t)&&o()};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},oe=[o],n[12]=o,n[13]=oe,n[14]=E),V.useEffect(E,oe);let O;n[15]!==a||n[16]!==r?(O=e=>{let t=r.trim(),n=e.aliases.includes(t)?t:e.name;a(e,n)},n[15]=a,n[16]=r,n[17]=O):O=n[17];let k=O,se;n[18]!==o||n[19]!==S||n[20]!==ee||n[21]!==C||n[22]!==x||n[23]!==y?(se=()=>{let e=new Set(y.map(kt)),t=`new-snippet`,n=1;for(;e.has(t);)t=`new-snippet-${n++}`;x({name:t,scope:`global`}),S(t),C(`snippets`),ee(!0),o()},n[18]=o,n[19]=S,n[20]=ee,n[21]=C,n[22]=x,n[23]=y,n[24]=se):se=n[24];let A=se,j,ce;n[25]!==k||n[26]!==h||n[27]!==o||n[28]!==A?(j=()=>({handleKeyDown:e=>{if(e===`Escape`){o();return}let t=h.length+1;if(e===`ArrowDown`){f(e=>(e+1)%t);return}if(e===`ArrowUp`){f(e=>(e-1+t)%t);return}if(e===`Enter`||e===`Tab`){if(p.current===0){A();return}let e=h[p.current-1];e&&k(e)}}}),ce=[k,h,o,A],n[25]=k,n[26]=h,n[27]=o,n[28]=A,n[29]=j,n[30]=ce):(j=n[29],ce=n[30]),V.useImperativeHandle(t,j,ce);let le;n[31]===Symbol.for(`react.memo_cache_sentinel`)?(le=e=>{v.current[0]=e},n[31]=le):le=n[31];let M;n[32]!==u||n[33]!==d?(M=P(`flex items-center gap-2 px-3 py-1.5 cursor-pointer rounded-lg typography-ui-label`,Je(u,d===0)),n[32]=u,n[33]=d,n[34]=M):M=n[34];let N,ue;n[35]===Symbol.for(`react.memo_cache_sentinel`)?(N=()=>f(0),ue=(0,U.jsx)(F,{name:`add`,className:`h-3.5 w-3.5 text-muted-foreground`}),n[35]=N,n[36]=ue):(N=n[35],ue=n[36]);let I;n[37]===c?I=n[38]:(I=c(`chat.snippetAutocomplete.action.addNew`),n[37]=c,n[38]=I);let L;n[39]===I?L=n[40]:(L=(0,U.jsx)(`span`,{className:`font-medium text-foreground`,children:I}),n[39]=I,n[40]=L);let R;n[41]!==A||n[42]!==M||n[43]!==L?(R=(0,U.jsxs)(`div`,{ref:le,className:M,onClick:A,onMouseMove:N,children:[ue,L]}),n[41]=A,n[42]=M,n[43]=L,n[44]=R):R=n[44];let de;n[45]!==k||n[46]!==h||n[47]!==u||n[48]!==d||n[49]!==c?(de=h.length?h.map((e,t)=>(0,U.jsx)(`div`,{ref:e=>{v.current[t+1]=e},className:P(`flex gap-2 px-3 py-1.5 cursor-pointer rounded-lg typography-ui-label`,u?`items-center`:`items-start`,Je(u,t+1===d)),onClick:()=>k(e),onMouseMove:()=>f(t+1),children:(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsxs)(`span`,{className:`font-semibold truncate`,children:[`#`,e.name]}),(0,U.jsx)(`span`,{className:`text-[10px] leading-none uppercase font-bold tracking-tight px-1.5 py-1 rounded border flex-shrink-0 bg-[var(--surface-muted)] text-muted-foreground border-[var(--interactive-border)]/60`,children:c(`snippets.source.${e.source}`)})]}),!u&&(0,U.jsx)(`div`,{className:`typography-meta text-muted-foreground mt-0.5 truncate`,children:gt(e)})]})},`${e.source}:${e.filePath}`)):(0,U.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:c(`chat.snippetAutocomplete.empty`)}),n[45]=k,n[46]=h,n[47]=u,n[48]=d,n[49]=c,n[50]=de):de=n[50];let z;n[51]!==R||n[52]!==de?(z=(0,U.jsxs)(pe,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0 pb-2`,children:[R,de]}),n[51]=R,n[52]=de,n[53]=z):z=n[53];let B;n[54]!==u||n[55]!==c?(B=!u&&(0,U.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:c(`chat.snippetAutocomplete.footer`)}),n[54]=u,n[55]=c,n[56]=B):B=n[56];let W;return n[57]!==u||n[58]!==s||n[59]!==z||n[60]!==B?(W=(0,U.jsxs)(et,{ref:l,isMobile:u,className:`max-w-[450px] max-h-60`,style:s,children:[z,B]}),n[57]=u,n[58]=s,n[59]=z,n[60]=B,n[61]=W):W=n[61],W});_t.displayName=`SnippetAutocomplete`;function vt(e){return e.isMobile}function yt(e){return e.snippets}function bt(e){return e.loadSnippets}function xt(e){return e.setSnippetDraft}function St(e){return e.setSelectedSnippet}function Ct(e){return e.setSettingsDialogOpen}function wt(e){return e.setSettingsPage}function Tt(e,t){return e.source===`project`&&t.source!==`project`?-1:e.source!==`project`&&t.source===`project`?1:e.name.localeCompare(t.name)}function Et(e){return[e.name,...e.aliases]}function Dt(e,t){return e.score===t.score?e.item.source===`project`&&t.item.source!==`project`?-1:e.item.source!==`project`&&t.item.source===`project`?1:e.item.name.localeCompare(t.item.name):e.score-t.score}function Ot(e){return e.item}function kt(e){return e.name}var At=2,jt=e=>!!e&&typeof e==`object`&&!Array.isArray(e),Mt=e=>{let t=e?.trim().replace(/\\/g,`/`);return t?t.length>1?t.replace(/\/+$/,``):t:null},Nt=e=>jt(e)&&Array.isArray(e.all)&&e.all.every(e=>typeof e==`string`)&&typeof e.current==`string`&&jt(e.branches),Pt=(e,t)=>JSON.stringify([e,t]),Ft=e=>`version`in e&&e.version===At&&jt(e.entries),It=e=>{if(!e)return null;try{let t=JSON.parse(e);return jt(t)?t.version===At&&jt(t.entries)?{version:At,entries:t.entries}:t:null}catch{return null}},Lt=(e,t)=>{try{e.setItem(`oc.gitBranchCache`,JSON.stringify(t))}catch{}},Rt=(e,t,n)=>{let r=Mt(e);if(!r||!t)return null;let i;try{i=n.getItem(`oc.gitBranchCache`)}catch{return null}let a=It(i);if(!a)return null;if(Ft(a))return Nt(a.entries[Pt(t,r)])?a.entries[Pt(t,r)]:null;let o={};for(let[e,n]of Object.entries(a)){let r=Mt(e);r&&Nt(n)&&(o[Pt(t,r)]=n)}return Lt(n,{version:At,entries:o}),o[Pt(t,r)]??null},zt=(e,t,n,r)=>{let i=Mt(e);if(!i||!t||!Nt(n))return;let a=null;try{a=r.getItem(`oc.gitBranchCache`)}catch{return}let o=It(a);Lt(r,{version:At,entries:{...o&&Ft(o)?o.entries:{},[Pt(t,i)]:n}})},Bt=3e4,Vt=Mt,Ht=(e,t=n())=>c.git.branches(Vt(e),t),Ut=(e,t=n())=>c.git.remotes(Vt(e),t),Wt=async(e,t,n)=>{n.throwIfAborted();let r=f()?.git,i=t?.getGitBranches?await t.getGitBranches(e,{signal:n}):r?await r.getGitBranches(e,{signal:n}):await x(e,{signal:n});return n.throwIfAborted(),i},Gt=async(e,t,n)=>{n.throwIfAborted();let r=f()?.git,i=t?.getRemotes?await t.getRemotes(e,{signal:n}):r?await r.getRemotes(e,{signal:n}):await y(e,{signal:n});return n.throwIfAborted(),i},Kt=(e,t,i=n(),a=r())=>{let o=Vt(e),s=t;return{queryKey:Ht(o,i),queryFn:async({signal:e})=>{if(!o)throw Error(`Git branches require a directory`);let t=await Wt(o,s,e);return zt(o,i,t,a),t},staleTime:Bt,gcTime:1/0,initialData:()=>Rt(o,i,a)??void 0,initialDataUpdatedAt:0}},qt=(e,t,r=n())=>{let i=Vt(e),a=t;return{queryKey:Ut(i,r),queryFn:({signal:e})=>{if(!i)throw Error(`Git remotes require a directory`);return Gt(i,a,e)},staleTime:Bt,gcTime:1/0}},Jt=(e,r,i)=>{let a=(0,H.c)(9),o=i===void 0||i,s=V.useSyncExternalStore(t,n,n),c,l,u;a[0]!==e||a[1]!==r||a[2]!==s?(c=Vt(e),u=C,l=Kt(c,r,s),a[0]=e,a[1]=r,a[2]=s,a[3]=c,a[4]=l,a[5]=u):(c=a[3],l=a[4],u=a[5]);let d=o&&!!c,f;return a[6]!==l||a[7]!==d?(f={...l,enabled:d},a[6]=l,a[7]=d,a[8]=f):f=a[8],u(f)},Yt=(e,r,i)=>{let a=(0,H.c)(9),o=i===void 0||i,s=V.useSyncExternalStore(t,n,n),c,l,u;a[0]!==e||a[1]!==r||a[2]!==s?(c=Vt(e),u=C,l=qt(c,r,s),a[0]=e,a[1]=r,a[2]=s,a[3]=c,a[4]=l,a[5]=u):(c=a[3],l=a[4],u=a[5]);let d=o&&!!c,f;return a[6]!==l||a[7]!==d?(f={...l,enabled:d},a[6]=l,a[7]=d,a[8]=f):f=a[8],u(f)},Xt=(e,t,r=d,i=n())=>r.fetchQuery(Kt(e,t,i)),Zt=(e,t,r=d,i=n())=>r.fetchQuery({...Kt(e,t,i),staleTime:0}),Qt=e=>e instanceof Error?e.name===`AbortError`||e.name===`CancelledError`||e.name===`Error`&&e.message===`CancelledError`:!1,$t=1e4,en=6e4,tn=5e3,nn=3e4,rn=6e4,an=25,on=40,sn=2,cn=15e3,ln=500,un=30,dn=20971520,fn=new Map,pn=new Map,mn=new Map,hn=new Map,gn=new Map,_n=(e,t)=>`${t}:${e}`,vn=e=>pn.get(e)??0,yn=e=>{let t=vn(e)+1;return pn.set(e,t),t},bn=e=>{let t=(mn.get(e)??0)+1;return mn.set(e,t),t},xn=e=>{let t=fn.get(e);if(t)return t;let n=new Set;return fn.set(e,n),n},Q=()=>({isGitRepo:null,status:null,branches:null,branchesTransportIdentity:null,log:null,identity:null,diffCache:new Map,indexRevision:0,lastRepoCheckAt:0,lastStatusFetch:0,lastStatusChange:0,lastLogFetch:0,lastBranchesFetch:0,lastIdentityFetch:0,logMaxCount:25,isLoadingStatus:!1,isLoadingLog:!1,isLoadingBranches:!1,isLoadingIdentity:!1}),Sn=(e,t=un,n=dn)=>{let r=0;for(let t of e.values())r+=(t.original?.length??0)+(t.modified?.length??0);if(e.size<=t&&r<=n)return e;let i=Array.from(e.entries()).sort((e,t)=>e[1].fetchedAt-t[1].fetchedAt),a=new Map,o=0;for(let e=i.length-1;e>=0;e--){let[r,s]=i[e],c=(s.original?.length??0)+(s.modified?.length??0);if(a.size>=t)break;o+c>n&&a.size>0||(a.set(r,s),o+=c)}return a},Cn=(e,t)=>{if(!e&&!t)return!1;if(!e||!t)return!0;let n=new Set([...Object.keys(e),...Object.keys(t)]);for(let r of n){let n=e[r],i=t[r];if(!(!n&&!i)&&(!n||!i||n.insertions!==i.insertions||n.deletions!==i.deletions))return!0}return!1},wn=(e,t)=>!e&&!t?!1:!e||!t||e.remote!==t.remote||e.branch!==t.branch||e.ahead!==t.ahead||e.behind!==t.behind,Tn=(e,t)=>{if(!e&&!t)return!1;if(!e||!t)return!0;let n=e.files??[],r=t.files??[];if(n.length!==r.length||e.ahead!==t.ahead||e.behind!==t.behind||e.current!==t.current||e.tracking!==t.tracking||e.isClean!==t.isClean||t.upstreamComparison!==void 0&&wn(e.upstreamComparison,t.upstreamComparison))return!0;let i=new Set(n.map(e=>`${e.path}:${e.index}:${e.working_dir}`));for(let e of r)if(!i.has(`${e.path}:${e.index}:${e.working_dir}`))return!0;return!!(t.diffStats!==void 0&&Cn(e.diffStats,t.diffStats))},En=(e,t)=>{let n=new Set;if(!t)return n;let r=e?.files??[],i=t.files??[],a=new Map(r.map(e=>[e.path,e])),o=new Map(i.map(e=>[e.path,e])),s=new Set([...a.keys(),...o.keys()]);for(let e of s){let t=a.get(e),r=o.get(e);if(!t||!r){n.add(e);continue}if(t.index!==r.index||t.working_dir!==r.working_dir){n.add(e);continue}}if(t.diffStats!==void 0){let r=e?.diffStats??{},i=t.diffStats??{},a=new Set([...Object.keys(r),...Object.keys(i)]);for(let e of a){let t=r[e],a=i[e];if(!t||!a){n.add(e);continue}(t.insertions!==a.insertions||t.deletions!==a.deletions)&&n.add(e)}}return n},Dn=(e,t)=>{if(!e&&!t)return!1;if(!e||!t)return!0;let n=e.files??[],r=t.files??[],i=e=>{let t=e?.trim()??``;return t===`?`?``:t},a=new Map(n.map(e=>[e.path,i(e.index)])),o=new Map(r.map(e=>[e.path,i(e.index)])),s=new Set([...a.keys(),...o.keys()]);for(let e of s)if((a.get(e)??``)!==(o.get(e)??``))return!0;return!1},On=e=>!e||e.trim().length===0,kn=e=>(e||``).trim()===`U`,An=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(kn(t)||kn(n))return e;let r=t===`?`||n===`?`?`A`:t||n||` `;return{...e,index:r,working_dir:` `}},jn=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(kn(t)||kn(n))return e;let r=n||(t===`A`||t===`?`?`?`:t)||` `;return{...e,index:` `,working_dir:r}},Mn=e=>On(e.index)&&On(e.working_dir),$=p()(h((e,t)=>({directories:new Map,activeDirectory:null,setActiveDirectory:n=>{let{activeDirectory:r,directories:i}=t();if(r!==n)if(r&&yn(r),n&&yn(n),n&&!i.has(n)){let t=new Map(i);t.set(n,Q()),e({activeDirectory:n,directories:t})}else e({activeDirectory:n})},getDirectoryState:e=>t().directories.get(e)??null,fetchStatus:async(n,r,i={})=>{let a=i.mode??`full`,o=_n(n,a),s=hn.get(o)??(a===`light`?hn.get(_n(n,`full`)):void 0);if(s)return s;let c=(async()=>{let{silent:a=!1}=i,{directories:o}=t(),s=o.get(n);if(s||=Q(),!a){let r=new Map(t().directories),i=r.get(n)??Q();r.set(n,{...i,isLoadingStatus:!0}),e({directories:r})}let c=!1;try{let a=Date.now(),o=s.isGitRepo!==!0||a-(s.lastRepoCheckAt||0)>en,l=s.isGitRepo===!0;if(o&&(l=await r.checkIsGitRepository(n)),!l){let r=new Map(t().directories),i=r.get(n)??s;return r.set(n,{...i,isGitRepo:!1,status:null,isLoadingStatus:!1,lastRepoCheckAt:a,lastStatusFetch:a}),e({directories:r}),!1}let u=await r.getGitStatus(n,i.mode?{mode:i.mode}:void 0);if(Tn(s.status,u)){c=!0;let r=new Map(t().directories),i=r.get(n)??Q(),s=En(i.status,u),l=Dn(i.status,u),d=new Set((i.status?.files??[]).map(e=>e.path)),f=new Set((u.files??[]).map(e=>e.path)),p=new Map(i.diffCache);for(let e of d)f.has(e)||p.delete(e);for(let e of s)p.delete(e);let m=s.size>0;m&&yn(n);let h={...u,diffStats:u.diffStats===void 0&&i.status?.diffStats!==void 0?i.status.diffStats:u.diffStats,upstreamComparison:u.upstreamComparison===void 0?i.status?.upstreamComparison:u.upstreamComparison};r.set(n,{...i,isGitRepo:!0,status:h,diffCache:p,indexRevision:l?i.indexRevision+1:i.indexRevision,lastRepoCheckAt:o?a:i.lastRepoCheckAt,lastStatusFetch:Date.now(),lastStatusChange:m?Date.now():i.lastStatusChange}),e({directories:r})}else{let r=new Map(t().directories),i=r.get(n)??Q();r.set(n,{...i,isGitRepo:!0,lastRepoCheckAt:o?a:i.lastRepoCheckAt,lastStatusFetch:Date.now(),lastStatusChange:i.lastStatusChange}),e({directories:r})}}catch(e){console.error(`Failed to fetch git status:`,e)}finally{if(!a){let r=new Map(t().directories),i=r.get(n)??Q();r.set(n,{...i,isLoadingStatus:!1}),e({directories:r})}}return c})();hn.set(o,c);try{return await c}finally{hn.get(o)===c&&hn.delete(o)}},moveStatusPathsOptimistically:(n,r,i)=>{let a=new Set(r.map(e=>e.trim()).filter(Boolean));if(a.size===0)return null;let{directories:o}=t(),s=o.get(n),c=s?.status??null;if(!s||!c)return c;let l=!1,u=[];for(let e of c.files){if(!a.has(e.path)){u.push(e);continue}let t=i===`stage`?An(e):jn(e);t!==e&&(l=!0),Mn(t)?l=!0:u.push(t)}if(!l)return c;let d=new Map(o);return d.set(n,{...s,status:{...c,files:u,isClean:u.length===0},indexRevision:s.indexRevision+1,lastStatusChange:Date.now()}),e({directories:d}),c},restoreStatus:(n,r)=>{let{directories:i}=t(),a=i.get(n);if(!a)return;let o=new Map(i);o.set(n,{...a,status:r,indexRevision:a.indexRevision+1,lastStatusChange:Date.now()}),e({directories:o})},bumpIndexRevision:n=>{let{directories:r}=t(),i=r.get(n);if(!i)return;let a=new Map(r);a.set(n,{...i,indexRevision:i.indexRevision+1}),e({directories:a})},fetchBranches:async(r,i,a={})=>{let o=n(),s=bn(r);{let n=new Map(t().directories),i=n.get(r)??Q();n.set(r,{...i,isLoadingBranches:!0}),e({directories:n})}try{let c=a.force?await Zt(r,i,void 0,o):await Xt(r,i,void 0,o);if(s!==mn.get(r)||o!==n())return;let l=new Map(t().directories),u=l.get(r)??Q();l.set(r,{...u,branches:c,branchesTransportIdentity:o,isLoadingBranches:!1,lastBranchesFetch:Date.now()}),e({directories:l})}catch(i){if(Qt(i)||console.error(`Failed to fetch git branches:`,i),s!==mn.get(r)||o!==n())return;let a=new Map(t().directories),c=a.get(r)??Q();a.set(r,{...c,isLoadingBranches:!1}),e({directories:a})}},fetchLog:async(n,r,i)=>{let{directories:a}=t(),o=a.get(n),s=i??o?.logMaxCount??25;{let r=new Map(t().directories),i=r.get(n)??Q();r.set(n,{...i,isLoadingLog:!0}),e({directories:r})}try{let i=await r.getGitLog(n,{maxCount:s}),a=new Map(t().directories),o=a.get(n)??Q();a.set(n,{...o,log:i,isLoadingLog:!1,lastLogFetch:Date.now(),logMaxCount:s}),e({directories:a})}catch(r){console.error(`Failed to fetch git log:`,r);let i=new Map(t().directories),a=i.get(n)??Q();i.set(n,{...a,isLoadingLog:!1}),e({directories:i})}},fetchIdentity:async(n,r)=>{{let r=new Map(t().directories),i=r.get(n)??Q();r.set(n,{...i,isLoadingIdentity:!0}),e({directories:r})}try{let i=await r.getCurrentGitIdentity(n),a=new Map(t().directories),o=a.get(n)??Q();a.set(n,{...o,identity:i,isLoadingIdentity:!1,lastIdentityFetch:Date.now()}),e({directories:a})}catch(r){console.error(`Failed to fetch git identity:`,r);let i=new Map(t().directories),a=i.get(n)??Q();i.set(n,{...a,isLoadingIdentity:!1}),e({directories:i})}},fetchAll:async(n,r,i={})=>{let{directories:a}=t(),o=a.get(n);if(!o){o=Q();let t=new Map(a);t.set(n,o),e({directories:t})}let{force:s=!1,silentIfCached:c=!1}=i,l=Date.now();await t().fetchStatus(n,r,{silent:c&&!!o?.status});let u=t().directories.get(n);if(!u?.isGitRepo)return;await t().fetchBranches(n,r,{force:s});let d=l-(u.lastLogFetch||0);(s||d>$t||!u.log)&&await t().fetchLog(n,r),await t().fetchIdentity(n,r)},getDiff:(e,n)=>t().directories.get(e)?.diffCache.get(n)??null,setDiff:(n,r,i)=>{let a=new Map(t().directories),o=a.get(n)??Q(),s=new Map(o.diffCache);s.set(r,{...i,fetchedAt:Date.now()});let c=Sn(s);a.set(n,{...o,diffCache:c}),e({directories:a})},clearDiffCache:n=>{yn(n);let r=new Map(t().directories),i=r.get(n);i&&(r.set(n,{...i,diffCache:new Map}),e({directories:r}))},fetchAllDiffs:async(e,n)=>{let r=t().directories.get(e);if(!r?.status?.files||r.status.files.length===0)return;let i=r.status.files.map(e=>e.path).slice(0,an);await t().prefetchDiffs(e,n,i,{maxFiles:an})},prefetchDiffs:async(n,r,i,a={})=>{let o=t().directories.get(n);if(!o?.status?.files||o.status.files.length===0||i.length===0)return;let{maxFiles:s=on}=a,c=new Set(o.status.files.map(e=>e.path)),l=o.status.diffStats,u=xn(n),d=[],f=new Set;for(let e of i){if(!e||f.has(e)||(f.add(e),!c.has(e))||o.diffCache.has(e)||u.has(e))continue;let t=l?.[e];t&&t.insertions+t.deletions>ln||d.push(e)}let p=d.slice(0,Math.max(1,s));if(p.length===0)return;let m=vn(n);if(typeof document<`u`&&document.hidden)return;p.forEach(e=>u.add(e));let h=0,g=[],_=()=>{let e=h;return h+=1,e<p.length?p[e]:null},v=async e=>{let t=r.getGitFileDiff(n,{path:e}),i=new Promise((e,t)=>{setTimeout(()=>t(Error(`Timed out after ${cn}ms`)),cn)}),a=await Promise.race([t,i]);return{path:e,diff:{original:a.original??``,modified:a.modified??``,isBinary:a.isBinary}}},y=async()=>{for(;;){if(m!==vn(n))return;let e=_();if(!e)return;try{g.push(await v(e))}catch{}finally{u.delete(e)}}},b=Math.min(sn,p.length);if(await Promise.allSettled(Array.from({length:b},()=>y())),p.forEach(e=>u.delete(e)),m!==vn(n))return;let x=new Map(t().directories),S=x.get(n);if(!S)return;let ee=new Map(S.diffCache),C=Date.now();g.forEach(e=>{!e.diff.isBinary&&e.diff.original===``&&e.diff.modified===``||ee.set(e.path,{...e.diff,fetchedAt:C})});let w=Sn(ee);x.set(n,{...S,diffCache:w}),e({directories:x})},setLogMaxCount:(n,r)=>{let i=new Map(t().directories),a=i.get(n)??Q();i.set(n,{...a,logMaxCount:r}),e({directories:i})},ensureStatus:async(e,n)=>{let r=t().directories.get(e),i=Date.now();r?.status&&i-r.lastStatusFetch<tn||await t().fetchStatus(e,n,{silent:!!r?.status})},ensureAll:(e,n)=>{let r=gn.get(e);if(r)return r;let i=(async()=>{let r=t().directories.get(e),i=Date.now();(!r?.status||r.status.diffStats===void 0||i-(r?.lastStatusFetch??0)>=tn)&&await t().fetchStatus(e,n,{silent:!!r?.status});let a=t().directories.get(e);if(!a?.isGitRepo)return;let o=[];(!a.branches||i-a.lastBranchesFetch>=nn)&&o.push(t().fetchBranches(e,n)),(!a.log||i-a.lastLogFetch>=$t)&&o.push(t().fetchLog(e,n)),(!a.identity||i-a.lastIdentityFetch>=rn)&&o.push(t().fetchIdentity(e,n)),o.length>0&&await Promise.all(o)})();return gn.set(e,i),i.finally(()=>{gn.get(e)===i&&gn.delete(e)}),i},refresh:async(e,n={})=>{let{activeDirectory:r}=t();r&&await t().fetchAll(r,e,n)}}),{name:`git-store`})),Nn=e=>{let t=(0,H.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.status??null:null,t[0]=e,t[1]=n),$(n)},Pn=e=>{let r=(0,H.c)(3),i=V.useSyncExternalStore(t,n,n),a;return r[0]!==e||r[1]!==i?(a=t=>{if(!e)return null;let n=t.directories.get(e);return n?.branchesTransportIdentity===i?n.branches:null},r[0]=e,r[1]=i,r[2]=a):a=r[2],$(a)},Fn=e=>{let t=(0,H.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.log??null:null,t[0]=e,t[1]=n),$(n)},In=e=>{let t=(0,H.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isGitRepo??null:null,t[0]=e,t[1]=n),$(n)},Ln=e=>{let t=(0,H.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.status?.current?.trim()??null:null,t[0]=e,t[1]=n),$(n)},Rn={current:new Map},zn=()=>$(Wn),Bn=e=>{let t=(0,H.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=new Map,t[0]=n):n=t[0];let r=V.useRef(n),i;return t[1]===e?i=t[2]:(i=t=>{let n=r.current,i=n.size===e.length;if(i)for(let r of e){let e=t.directories.get(r),a=n.get(r);if(!a||(e?.isGitRepo??null)!==a.isGitRepo||(e?.status?.current??null)!==a.branch){i=!1;break}}if(i)return n;let a=new Map;for(let n of e){let e=t.directories.get(n);a.set(n,{isGitRepo:e?.isGitRepo??null,branch:e?.status?.current??null})}return r.current=a,a},t[1]=e,t[2]=i),$(i)},Vn=e=>{let t=(0,H.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isLoadingStatus??!1:!1,t[0]=e,t[1]=n),$(n)},Hn=e=>{let t=(0,H.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isLoadingLog??!1:!1,t[0]=e,t[1]=n),$(n)},Un=e=>{let t=(0,H.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isLoadingBranches??!1:!1,t[0]=e,t[1]=n),$(n)};function Wn(e){let t=Rn.current,n=t.size===e.directories.size;if(n){for(let[r,i]of e.directories)if(t.get(r)!==(i.status?.current??null)){n=!1;break}}if(n)return t;let r=new Map;for(let[t,n]of e.directories)r.set(t,n.status?.current??null);return Rn.current=r,r}var Gn=e=>{let t=String(e||``).trim().replace(/^remotes\//,``);if(!t)return null;let n=t.indexOf(`/`);return n<=0||n>=t.length-1?null:{remote:t.slice(0,n),branch:t.slice(n+1)}},Kn=e=>String(e||``).trim().replace(/^refs\/heads\//,``).replace(/^heads\//,``).replace(/^remotes\//,``),qn=e=>e.branchName?Kn(e.branchName):e.mode===`existing`?Kn(e.existingBranch||e.preferredName||``):Kn(e.preferredName||``),Jn=async e=>{let t=await z(e);try{let n=Gn((await R(e)).branches?.[t]?.tracking||null);if(n?.remote)return n.remote}catch{}try{let t=Gn((await de(e)).tracking);if(t?.remote)return t.remote}catch{}return null},Yn=async(e,t)=>{let n=await Jn(e),r=Kn(t);return!n||!r?null:{setUpstream:!0,upstreamRemote:n,upstreamBranch:r}},Xn=async(e,t,n)=>{let r=qn(t),i=n?.resolvedRootTrackingRemote,a=i===void 0?await Yn(e,r):i&&Kn(r)?{setUpstream:!0,upstreamRemote:i,upstreamBranch:Kn(r)}:null;return a?{...t,setUpstream:t.setUpstream??a.setUpstream,upstreamRemote:t.upstreamRemote||a.upstreamRemote,upstreamBranch:t.upstreamBranch||a.upstreamBranch}:t},Zn=async(e,t,n)=>{let r=await Xn(e.path,t,n);return B(e,r)},Qn=`oc:lastWorktreeSourceBranch`,$n=({mode:e,sourceBranch:t,linkedPr:n,selectedBranch:r})=>e===`existing-branch`?r||null:n?null:t||null,er=({branches:e,savedSourceBranch:t,rootBranch:n})=>t&&e.includes(t)&&t?{sourceBranch:t,shouldClearSavedSourceBranch:!1}:{sourceBranch:n&&e.includes(n)?n:e.includes(`main`)?`main`:e.includes(`master`)?`master`:e[0]??``,shouldClearSavedSourceBranch:!!t},tr=(e,t,n)=>{if(!e)return e;let r=t.length>0&&!/\s$/.test(t)&&!/^\s/.test(e)&&!/[([{]$/.test(t),i=n.length>0&&!/\s$/.test(e)&&!/^\s/.test(n)&&!/^[\])}.,;:!?]/.test(n);return`${r?` `:``}${e}${i?` `:``}`},nr=(e,t,n)=>{let r=tr(e,t,n);return`${t.length===0&&!/^\s/.test(r)?` `:``}${r}${n.length===0&&!/\s$/.test(r)?` `:``}`},rr=(e,t,n,r)=>{let i=e.slice(0,t),a=e.slice(n),o=nr(r,i,a),s=Math.max(0,o.indexOf(r)),c=i.length+s;return{text:`${i}${o}${a}`,caret:i.length+o.length,start:c,end:c+r.length}},ir=(e,t)=>{let n=e=>`${e.kind}:${e.value}:${e.range.start}:${e.range.end}`;return new Set(e.map(n)).has(n(t))?[...e]:[...e,t]},ar=(e,t)=>t<e.length&&e[t]===` `?t+1:t;export{et as A,X as B,Jt as C,st as D,ht as E,Oe as F,q as H,ke as I,Ae as L,Re as M,Le as N,at as O,Ie as P,Te as R,Zt as S,_t as T,ye as U,Se as V,Fn as _,Qn as a,$ as b,Zn as c,zn as d,Ln as f,Vn as g,Hn as h,nr as i,Je as j,nt as k,Jn as l,Un as m,ir as n,er as o,Pn as p,rr as r,$n as s,ar as t,Xn as u,Bn as v,Yt as w,In as x,Nn as y,Ce as z};