@yuriai/web 0.2.20 → 0.2.24-beta.10

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 (119) hide show
  1. package/dist/assets/{AgentAvatar-MK9jNcwx.js → AgentAvatar-pXIw9gfD.js} +1 -1
  2. package/dist/assets/AssistantView-DouQsDKE.js +3 -0
  3. package/dist/assets/{DiagramView-ys2UVvx1.js → DiagramView-BSVbw3vz.js} +1 -1
  4. package/dist/assets/{FadeInOnReveal-B1g8C4P7.js → FadeInOnReveal-DAByozhu.js} +1 -1
  5. package/dist/assets/{GuiPluginSurface-C1KQZUmj.js → GuiPluginSurface--3BqaVDR.js} +1 -1
  6. package/dist/assets/{GuiPluginWindow-D4TIvZDn.js → GuiPluginWindow-Ccm-tyo2.js} +1 -1
  7. package/dist/assets/Icon-_iMMNG9-.js +1 -0
  8. package/dist/assets/{ImageLoadingPlaceholder-DM2ifWd8.js → ImageLoadingPlaceholder-BPEqdGkV.js} +1 -1
  9. package/dist/assets/{LoadingImage-BoaGSpZ_.js → LoadingImage-COJSLMyx.js} +1 -1
  10. package/dist/assets/MarkdownRenderer-B4jI8cPi.js +2 -0
  11. package/dist/assets/{MarkdownRendererImpl-DL069I2q.js → MarkdownRendererImpl-xzqXth65.js} +1 -1
  12. package/dist/assets/{MarkstreamRendererImpl-CwR_p-oQ.js → MarkstreamRendererImpl-BMIQwLHf.js} +1 -1
  13. package/dist/assets/{MobileDetailNavigation-C7Z7mVZV.js → MobileDetailNavigation-DKbf2A_6.js} +1 -1
  14. package/dist/assets/{MobileResizableSheet-ChrM2_er.js → MobileResizableSheet-Cp3AyvCP.js} +1 -1
  15. package/dist/assets/{MobileShareBridge-DtXwoQtk.js → MobileShareBridge-CCBq7lLo.js} +1 -1
  16. package/dist/assets/{MobileTabPageHeader-BT7U61qi.js → MobileTabPageHeader-D7QXtACw.js} +1 -1
  17. package/dist/assets/{MultiRunWindow-CFWkmiwx.js → MultiRunWindow-B8_rpG1G.js} +1 -1
  18. package/dist/assets/{OnboardingScreen-Bb3wmiKY.js → OnboardingScreen-BwQKn_88.js} +1 -1
  19. package/dist/assets/{OverlayScrollbar-DD6avzvO.js → OverlayScrollbar-U7GvtZ-e.js} +1 -1
  20. package/dist/assets/SettingsView-6Qavf-Sp.js +29 -0
  21. package/dist/assets/{SettingsWindow-jF7nPmJG.js → SettingsWindow-CXupqJmO.js} +1 -1
  22. package/dist/assets/{TerminalView-Cms4rfIE.js → TerminalView-CtiSAJDq.js} +1 -1
  23. package/dist/assets/{ToolOutputDialog-CBSb39qy.js → ToolOutputDialog-Bqe9nheH.js} +4 -4
  24. package/dist/assets/{YuriLogo-CeZsIqiE.js → YuriLogo-BFsNnpdF.js} +1 -1
  25. package/dist/assets/{appThemeRegistry-Bps27som.js → appThemeRegistry-DJceS-hu.js} +1 -1
  26. package/dist/assets/{button--mt1oJ-H.js → button-K_jXf_uP.js} +1 -1
  27. package/dist/assets/{capgoAdapter-ZBPKiKyL.js → capgoAdapter-Dg4nNQh2.js} +1 -1
  28. package/dist/assets/{collapsible-Dh2xZynB.js → collapsible-DqW91GHI.js} +1 -1
  29. package/dist/assets/desktop-5DP3-Bao.js +1 -0
  30. package/dist/assets/{desktopHosts-B4HMNmrx.js → desktopHosts-CrVcscUO.js} +1 -1
  31. package/dist/assets/{desktopRelayRestore-CRl62mqn.js → desktopRelayRestore-DJFLfsuw.js} +1 -1
  32. package/dist/assets/{device-Coc5tapU.js → device-BKQ_0FdZ.js} +1 -1
  33. package/dist/assets/{diagram-CrQbE7QP.js → diagram-Pn5Vu970.js} +1 -1
  34. package/dist/assets/{dialog-BG9W4FO9.js → dialog-DivrqsAq.js} +1 -1
  35. package/dist/assets/{dropdown-menu.styles-BOP49Dw2.js → dropdown-menu.styles-zVps2mhA.js} +1 -1
  36. package/dist/assets/{es-CuWYQYZ1.js → es-Clj7CS2r.js} +4 -4
  37. package/dist/assets/{fileMentionTouchSelection-m4Xsn0cx.js → fileMentionTouchSelection-BZJxEXqc.js} +1 -1
  38. package/dist/assets/{fileReferenceActions-BnPPqYXw.js → fileReferenceActions-DkLLKj6A.js} +1 -1
  39. package/dist/assets/{fr-yebDRPGw.js → fr-dmrFQLCO.js} +3 -3
  40. package/dist/assets/{gitApi-C1pkEDXu.js → gitApi-DwJ926Wm.js} +1 -1
  41. package/dist/assets/{gitApiHttp-CoNokuDM.js → gitApiHttp-Bnr4_wxy.js} +2 -2
  42. package/dist/assets/{host-BqNFap4A.js → host-DgJqhX6n.js} +1 -1
  43. package/dist/assets/{input-BMUm4I0i.js → input-BcXfvvm_.js} +1 -1
  44. package/dist/assets/insertionBoundaries-CW0uddv6.js +1 -0
  45. package/dist/assets/{ja-f1wDEfxS.js → ja-Co0dxiN_.js} +3 -3
  46. package/dist/assets/{ko-n8CMb8k9.js → ko-BltElAGq.js} +3 -3
  47. package/dist/assets/{main-djohnOii.js → main-By5dfId1.js} +2 -2
  48. package/dist/assets/main-DfGYCP4r.js +169 -0
  49. package/dist/assets/{markdownHeightCache-BWrnxGTO.js → markdownHeightCache-BaLmCxOF.js} +1 -1
  50. package/dist/assets/{mcpQueries-BfSiXImW.js → mcpQueries-Dj92UHx8.js} +1 -1
  51. package/dist/assets/{miniChat-DXN8mcdi.js → miniChat-sd1i9oFo.js} +2 -2
  52. package/dist/assets/mobile-D7tGc16i.js +2 -0
  53. package/dist/assets/{mobileBackNavigation-EIV61ZvG.js → mobileBackNavigation-DLoxo_5a.js} +1 -1
  54. package/dist/assets/{multirun-Dfuqt2Sd.js → multirun-aJrcR-3s.js} +1 -1
  55. package/dist/assets/{native-config-Cswl9jqU.js → native-config-rI_f4c03.js} +1 -1
  56. package/dist/assets/{persistence-CNEHspb4.js → persistence-BPb2hZ3c.js} +2 -2
  57. package/dist/assets/{pl-BpveZ1bR.js → pl-qd6Wnl7H.js} +4 -4
  58. package/dist/assets/{platform-Q45KPuGv.js → platform-wGCQUVxr.js} +1 -1
  59. package/dist/assets/{projectMeta-CuVxfoYb.js → projectMeta-DFRAlLUB.js} +1 -1
  60. package/dist/assets/{pt-BR-bq37AHb6.js → pt-BR-CsOFfQXS.js} +4 -4
  61. package/dist/assets/{readiness-DDF6yf-o.js → readiness-B5Cd9iIF.js} +1 -1
  62. package/dist/assets/{renderElectronMiniChatApp-Cfs2xjgL.js → renderElectronMiniChatApp-BVZT6wbt.js} +2 -2
  63. package/dist/assets/renderMobileApp-DW85f4t0.js +28 -0
  64. package/dist/assets/{runtimeConfig-DTkP4z43.js → runtimeConfig-kFdO-lRx.js} +1 -1
  65. package/dist/assets/runtimeEndpointReset-Cn9N7LPW.js +149 -0
  66. package/dist/assets/{scheduledTaskNavigation-7slq1geN.js → scheduledTaskNavigation-Bk2y-IY1.js} +1 -1
  67. package/dist/assets/{sessionChangeSummary-BYv_KUyn.js → sessionChangeSummary-BIbSjhps.js} +1 -1
  68. package/dist/assets/{sessionLookup-Cx0pE6yS.js → sessionLookup-5rU7IMVC.js} +1 -1
  69. package/dist/assets/{sortable-tabs-strip-D_efLXen.js → sortable-tabs-strip-DR_NRIKS.js} +1 -1
  70. package/dist/assets/{speechSettingsQueries-BxHtdoOT.js → speechSettingsQueries-BywoZDLQ.js} +3 -3
  71. package/dist/assets/src-BxW5eh2m.css +2 -0
  72. package/dist/assets/{store-CKBj6kYd.js → store-7wItZZ7_.js} +3 -3
  73. package/dist/assets/{terminalApi-DFhCeMya.js → terminalApi-Cjd7Jry6.js} +1 -1
  74. package/dist/assets/{textarea-CNvFHvhC.js → textarea-BnV-WjE-.js} +1 -1
  75. package/dist/assets/toolHelpers-iEHVHQ9p.js +2 -0
  76. package/dist/assets/{tooltip-C-gdI2Am.js → tooltip-8gf-KZqb.js} +1 -1
  77. package/dist/assets/types-C7xcxIWY.js +2 -0
  78. package/dist/assets/{uk-Ds3imyqV.js → uk-BNrdZFvK.js} +4 -4
  79. package/dist/assets/{useAppFontEffects-Ucq0gPN8.js → useAppFontEffects-fNQVBUds.js} +53 -53
  80. package/dist/assets/{useDesktopWindowControlsLayout-BEscodj1.js → useDesktopWindowControlsLayout-HSNk-2BM.js} +1 -1
  81. package/dist/assets/{useEffectiveDirectory-BWRQNoDF.js → useEffectiveDirectory-BAXWl1Le.js} +1 -1
  82. package/dist/assets/{useFontPreferences-DmeLn0t9.js → useFontPreferences-CGThMzt0.js} +1 -1
  83. package/dist/assets/{useMobileNavigationStore-DzkVc9H_.js → useMobileNavigationStore-NybUtx0x.js} +16 -16
  84. package/dist/assets/useWorkerHighlightedLines-BJ1sv_hM.js +7 -0
  85. package/dist/assets/{zh-CN-BNJ3ElZ9.js → zh-CN-DMvJXS23.js} +4 -4
  86. package/dist/assets/{zh-TW-C0jQloeH.js → zh-TW-D0wsKLs1.js} +4 -4
  87. package/dist/index.html +13 -13
  88. package/dist/mini-chat.html +13 -13
  89. package/dist/mobile.html +13 -13
  90. package/package.json +1 -1
  91. package/server/index.d.ts +9 -0
  92. package/server/index.js +10 -0
  93. package/server/lib/assistants/DOCUMENTATION.md +15 -0
  94. package/server/lib/assistants/harness.js +1 -4
  95. package/server/lib/assistants/harness.test.js +38 -0
  96. package/server/lib/assistants/summary.test.js +32 -0
  97. package/server/lib/realtime-proxy.js +2 -1
  98. package/server/lib/relay/tunnel-host.js +1 -0
  99. package/server/lib/remote-desktop/DOCUMENTATION.md +97 -0
  100. package/server/lib/remote-desktop/protocol.js +27 -0
  101. package/server/lib/remote-desktop/protocol.test.js +21 -0
  102. package/server/lib/remote-desktop/runtime.js +114 -0
  103. package/server/lib/remote-desktop/runtime.test.js +155 -0
  104. package/server/lib/ui-auth/DOCUMENTATION.md +2 -0
  105. package/server/lib/ui-auth/ui-auth.js +2 -1
  106. package/dist/assets/AssistantView-CVf9ta92.js +0 -3
  107. package/dist/assets/Icon-C93bLV0e.js +0 -1
  108. package/dist/assets/MarkdownRenderer-B8LWUc6A.js +0 -2
  109. package/dist/assets/SettingsView-B4xkRLZ3.js +0 -29
  110. package/dist/assets/desktop-CiqEZVr5.js +0 -1
  111. package/dist/assets/insertionBoundaries-WLpirs0A.js +0 -1
  112. package/dist/assets/main-CNmq04w8.js +0 -169
  113. package/dist/assets/mobile--08sYbKy.js +0 -2
  114. package/dist/assets/renderMobileApp-B66uW5zc.js +0 -28
  115. package/dist/assets/runtimeEndpointReset-BMAP5ZCY.js +0 -149
  116. package/dist/assets/src-DHHaXffU.css +0 -2
  117. package/dist/assets/toolHelpers-DL452NVK.js +0 -2
  118. package/dist/assets/types-BHKyslK4.js +0 -2
  119. package/dist/assets/useWorkerHighlightedLines-Dz6lLZ-1.js +0 -7
@@ -1 +0,0 @@
1
- import{w as e}from"./runtime-auth-BaBM02zI.js";import{r as t,t as n}from"./runtime-switch-DhMY9eiB.js";import{t as r}from"./runtimeAPIRegistry-C2VogTny.js";var i=[`local`,`remote`,null],a=[`ok`,`not-configured`,`unreachable`,`incompatible`,`wrong-service`,`missing`];function o(e){if(!e||typeof e!=`object`)return{valid:!1};let t=e,n=t.target,r=t.status;if(n!==null&&(typeof n!=`string`||!i.includes(n))||typeof r!=`string`||!a.includes(r))return{valid:!1};if(n===`remote`||n===`local`){if(r===`ok`&&n===`local`)return{valid:!0,outcome:{target:`local`,status:`ok`}};if(r===`ok`&&n===`remote`)return typeof t.hostId!=`string`||typeof t.url!=`string`?{valid:!1}:{valid:!0,outcome:{target:`remote`,status:`ok`,hostId:t.hostId,url:t.url}};if(r===`unreachable`)return n===`local`?{valid:!0,outcome:{target:`local`,status:`unreachable`}}:typeof t.hostId!=`string`||typeof t.url!=`string`?{valid:!1}:{valid:!0,outcome:{target:`remote`,status:`unreachable`,hostId:t.hostId,url:t.url}};if(r===`incompatible`||r===`wrong-service`)return n!==`remote`||typeof t.hostId!=`string`||typeof t.url!=`string`?{valid:!1}:{valid:!0,outcome:{target:`remote`,status:r,hostId:t.hostId,url:t.url}};if(r===`missing`)return n!==`remote`||typeof t.hostId!=`string`?{valid:!1}:{valid:!0,outcome:{target:`remote`,status:`missing`,hostId:t.hostId}}}if(n===null){if(r===`not-configured`)return{valid:!0,outcome:{target:null,status:`not-configured`}};if(r===`missing`)return{valid:!1}}return{valid:!1}}function s(e){if(!e.isDesktopShell)return null;let t=e.bootOutcome;if(!t)return null;if(t.status===`ok`){if(t.target===`local`)return{screen:`main`};if(t.target===`remote`)return{screen:`main`,hostId:t.hostId,url:t.url}}if(t.target===null&&t.status===`not-configured`)return{screen:`chooser`};if(t.target===`local`&&t.status===`unreachable`)return{screen:`recovery`,variant:`local-unavailable`};if(t.target===`remote`){if(t.status===`unreachable`)return{screen:`recovery`,variant:`remote-unreachable`,hostId:t.hostId,url:t.url};if(t.status===`incompatible`)return{screen:`recovery`,variant:`remote-incompatible`,hostId:t.hostId,url:t.url};if(t.status===`wrong-service`)return{screen:`recovery`,variant:`remote-wrong-service`,hostId:t.hostId,url:t.url};if(t.status===`missing`)return{screen:`recovery`,variant:`remote-missing`,hostId:t.hostId}}return null}function c(e){return e.isDesktopShell?e.bootOutcomeKnown?e.bootViewIsMain===!1||e.isInitialized:!1:e.isInitialized}function l(e){return e.isDesktopShell&&!e.isDesktopLocalOriginActive}function u(){if(f()!==`valid`)return null;let e=o(d());return e.valid?e.outcome:null}var d=()=>{if(typeof window>`u`)return;let e=window.__YURI_DESKTOP_BOOT_OUTCOME__;if(e!=null)return e;let t=window.__YURI_DESKTOP_BOOT__;if(t&&typeof t.getOutcome==`function`)try{return t.getOutcome()}catch{return}return e};function f(){if(typeof window>`u`)return`not-injected`;let e=d();return e==null?`not-injected`:o(e).valid?`valid`:`malformed`}var p=()=>typeof window>`u`?null:window.__YURI_ELECTRON__??null,m=()=>typeof window>`u`?null:window.__YURI_DESKTOP__??null,h=()=>p()?.runtime===`electron`,g=()=>h()&&p()?.packaged===!0,_=e=>{if(!h())return null;let t=m()?.getPathForFile?.(e);return typeof t==`string`&&t.trim()?t:null},v=()=>{if(typeof window>`u`)return null;let e=window.__YURI_PLATFORM__;return typeof e==`string`?e:null},ee=()=>{if(!h())return!1;let e=v();return e===`win32`||e===`linux`},y=(e=v())=>e===`linux`?`left`:`right`,b=(e,t=v())=>e===`left`||e===`right`?e:y(t),x=()=>typeof m()?.invoke==`function`,S=()=>h()&&x(),C=()=>h()&&F()?m()?.guiPlugins:void 0,w=()=>h()?m()?.guiPlugins:void 0,T=()=>h()?m()?.viewExport:void 0,E=async(e,t)=>{let n=m();return typeof n?.invoke==`function`?n.invoke(e,t??{}):null},te=async()=>{if(!S()||!F())return null;try{let e=await E(`desktop_get_launch_at_login`);return!e||typeof e.supported!=`boolean`||typeof e.enabled!=`boolean`?null:e}catch(e){return console.warn(`Failed to get launch at login status`,e),null}},ne=async e=>{if(!S()||!F())return null;try{let t=await E(`desktop_set_launch_at_login`,{enabled:e});return!t||typeof t.supported!=`boolean`||typeof t.enabled!=`boolean`?null:t}catch(e){return console.warn(`Failed to set launch at login status`,e),null}},D=async()=>{if(!S()||!F())return null;try{let e=await E(`desktop_get_minimize_to_tray`);return!e||typeof e.supported!=`boolean`||typeof e.enabled!=`boolean`?null:e}catch(e){return console.warn(`Failed to get minimize to tray status`,e),null}},O=async e=>{if(!S()||!F())return null;try{let t=await E(`desktop_set_minimize_to_tray`,{enabled:e});return!t||typeof t.supported!=`boolean`||typeof t.enabled!=`boolean`?null:t}catch(e){return console.warn(`Failed to set minimize to tray status`,e),null}},k=async()=>{if(!S()||!F())return null;try{let e=await E(`desktop_get_keep_awake`);return!e||typeof e.supported!=`boolean`||typeof e.enabled!=`boolean`||typeof e.active!=`boolean`?null:e}catch(e){return console.warn(`Failed to get keep awake status`,e),null}},A=async e=>{if(!S()||!F())return null;try{let t=await E(`desktop_set_keep_awake`,{enabled:e});return!t||typeof t.supported!=`boolean`||typeof t.enabled!=`boolean`||typeof t.active!=`boolean`?null:t}catch(e){return console.warn(`Failed to set keep awake status`,e),null}},j=e=>{let t=e.trim();if(!t)return null;try{return new URL(t).origin}catch{try{return new URL(t.endsWith(`/`)?t:`${t}/`).origin}catch{return null}}},M=e=>{let t=e.trim();if(!t)return null;try{return new URL(t)}catch{try{return new URL(t.endsWith(`/`)?t:`${t}/`)}catch{return null}}},N=e=>e.replace(/^\[|\]$/g,``).toLowerCase(),P=e=>{let t=N(e);return t===`localhost`||t===`127.0.0.1`||t===`::1`},F=()=>{if(typeof window>`u`||!I()||e())return!1;let r=t();if(r.startsWith(`host:`))return!1;if(r===`local`)return!0;let i=typeof window.__YURI_LOCAL_ORIGIN__==`string`?window.__YURI_LOCAL_ORIGIN__:``,a=M(i),o=M(n());if(!o&&a&&u()?.target===`local`)return!0;if(a&&o){if(a.origin===o.origin)return!0;let e=a.port||(a.protocol===`https:`?`443`:`80`),t=o.port||(o.protocol===`https:`?`443`:`80`);return a.protocol===o.protocol&&e===t&&P(a.hostname)&&P(o.hostname)}let s=M(window.location.origin);if(a&&s){if(a.origin===s.origin)return!0;let e=a.port||(a.protocol===`https:`?`443`:`80`),t=s.port||(s.protocol===`https:`?`443`:`80`);return a.protocol===s.protocol&&e===t&&P(a.hostname)&&P(s.hostname)}let c=j(i),l=j(window.location.origin)||window.location.origin;return c&&l&&c===l?!0:!!(s&&P(s.hostname))},I=()=>typeof window>`u`?!1:h(),L=async()=>{if(!I())return!1;try{return await E(`desktop_start_window_drag`),!0}catch{return!1}},R=()=>r()?.runtime?.isVSCode===!0,z=()=>{let e=r()?.runtime?.platform;return e===`web`?!0:e===`desktop`||e===`vscode`?!1:!R()},B=async()=>{if(typeof window<`u`){let e=window.__YURI_HOME__;if(e&&e.length>0)return e}return null},V=async e=>{if(x()&&F())try{let e=await m()?.openDialog?.({directory:!0,multiple:!1,title:`Select Working Directory`});return!e||typeof e!=`string`?{success:!1,error:`Directory selection cancelled`}:{success:!0,path:e}}catch(e){return console.warn(`Failed to request directory access`,e),{success:!1,error:e instanceof Error?e.message:String(e)}}return{success:!0,path:e}},H=e=>typeof e==`object`&&!!e&&!Array.isArray(e),re=async e=>{if(x()&&F())try{let t=await m()?.openDialog?.({directory:!1,multiple:!1,title:`Select File`,returnGrant:!0,...e?.filters?{filters:e.filters}:{},...e?.defaultPath?{defaultPath:e.defaultPath}:{}});if(!t)return{success:!1,error:`File selection cancelled`};if(typeof t==`string`)return{success:!0,path:t};if(!H(t))return{success:!1,error:`File selection cancelled`};let n=typeof t.path==`string`?t.path:``;return n?{success:!0,path:n,outsideFileGrant:typeof t.outsideFileGrant==`string`?t.outsideFileGrant:void 0}:{success:!1,error:`File selection cancelled`}}catch(e){return console.warn(`Failed to request file access`,e),{success:!1,error:e instanceof Error?e.message:String(e)}}return{success:!1,error:`Native file picker not available`}},U=async e=>{let t=typeof e==`string`?e.trim():``;if(!t)return{success:!1,error:`Path is required`};if(!x()||!F())return{success:!1,error:`Native file access not available`};try{let e=await m()?.grantFileAccess?.(t);if(!H(e))return{success:!1,error:`File access was not granted`};let n=typeof e.path==`string`?e.path:``,r=typeof e.outsideFileGrant==`string`?e.outsideFileGrant:``;return!n||!r?{success:!1,error:`File access was not granted`}:{success:!0,path:n,outsideFileGrant:r}}catch(e){return console.warn(`Failed to request existing file access`,e),{success:!1,error:e instanceof Error?e.message:String(e)}}},W=async e=>({success:!0}),G=async e=>({success:!0}),K=async e=>{if(!x())throw Error(`Desktop update checker is unavailable`);let t=await E(`desktop_check_for_updates`,{channelOverride:e});if(!t)throw Error(`Desktop update checker returned no result`);return t},q=async e=>{x()&&await E(`desktop_ota_ready`,{version:e})},J=()=>E(`desktop_get_app_version`),Y=async e=>{let t=m();return typeof t?.listen==`function`?t.listen(`yuri:update-progress`,t=>{let n=t?.payload;if(!n||typeof n!=`object`)return;let r=n;e({event:typeof r.event==`string`?r.event:void 0,data:r.data&&typeof r.data==`object`?r.data:void 0})}):null},X=async e=>{let t=m();return typeof t?.listen==`function`?t.listen(`yuri:update-ready`,t=>{let n=t?.payload;if(!n||typeof n!=`object`)return;let r=n;e({version:typeof r.version==`string`?r.version:null,downloaded:r.downloaded===!0})}):null},ie=async e=>{if(!x())return!1;let t=m(),n=null,r=0,i;try{return typeof e==`function`&&t?.listen&&(n=await t.listen(`yuri:update-progress`,t=>{let n=t?.payload;if(!n||typeof n!=`object`)return;let a=n,o=typeof a.event==`string`?a.event:null,s=a.data&&typeof a.data==`object`?a.data:null;if(o===`Started`){r=0,i=typeof s?.contentLength==`number`?s.contentLength:void 0,e({downloaded:r,total:i});return}if(o===`Progress`){let t=s?.downloaded,n=s?.total;typeof t==`number`&&(r=t),typeof n==`number`&&(i=n),e({downloaded:r,total:i});return}o===`Finished`&&e({downloaded:r,total:i})})),await E(`desktop_download_and_install_update`),!0}catch(e){throw e instanceof Error?e:Error(String(e))}finally{if(n)try{let e=n();e instanceof Promise&&await e}catch{}}},ae=async()=>x()?Z({applyUpdate:!0}):!1,Z=async({applyUpdate:e=!1}={})=>{if(!x())return!1;try{return await E(`desktop_restart`,e?{applyUpdate:!0}:void 0),!0}catch(e){return console.warn(`Failed to restart desktop app`,e),!1}},oe=async()=>{if(!x()||!F())return null;try{let e=await E(`desktop_get_lan_address`);return typeof e==`string`&&e.trim().length>0?e.trim():null}catch(e){return console.warn(`Failed to get desktop LAN address`,e),null}},Q=async(e,t)=>{if(!x()||!F())return!1;let n=e?.trim();if(!n)return!1;try{return await E(`desktop_open_path`,{path:n,app:typeof t==`string`&&t.trim().length>0?t.trim():void 0}),!0}catch(e){return console.warn(`Failed to open path`,e),!1}},$=async e=>{if(!x()||!F())return null;let t=e?.trim();if(!t)return null;try{let e=await E(`desktop_is_binary_path`,{path:t});return typeof e==`boolean`?e:null}catch{return null}},se=async e=>{if(!x()||!F())return!1;let t=e?.trim();if(!t)return!1;try{return await E(`desktop_reveal_path`,{path:t}),!0}catch{return Q(t)}},ce=async(e,t)=>{if(!x()||!F())return null;let n=e?.trim();if(!n)return null;try{let e=await E(`desktop_save_markdown_file`,{defaultFileName:n,content:t});return typeof e==`string`&&e.trim().length>0?e:null}catch(e){return console.warn(`Failed to save markdown file`,e),null}},le=async(e,n,r,i)=>{if(!x()||!i&&!F())return!1;if(i)return t()===`host:${i}`&&(await E(`desktop_open_ssh_in_app`,{projectPath:e,appId:n,hostId:i}),!0);let a=e?.trim(),o=n?.trim(),s=r?.trim();if(!a||!o||!s)return!1;try{return await E(`desktop_open_in_app`,{projectPath:a,appId:o,appName:s}),!0}catch(e){return console.warn(`Failed to open project in app`,e),!1}},ue=async(e,t,n)=>{if(!x()||!F())return!1;let r=e?.trim(),i=t?.trim(),a=n?.trim();if(!r||!i||!a)return!1;try{return await E(`desktop_open_file_in_app`,{filePath:r,appId:i,appName:a}),!0}catch(e){return console.warn(`Failed to open file in app`,e),!1}},de=async(e,t)=>{if(!x())return{apps:[],success:!1,hasCache:!1,isCacheStale:!1};if(v()===`linux`)return{apps:[],success:!0,hasCache:!1,isCacheStale:!1};let n=Array.isArray(e)?e.filter(e=>typeof e==`string`):[];if(n.length===0)return{apps:[],success:!0,hasCache:!1,isCacheStale:!1};try{let e=await E(`desktop_get_installed_apps`,{apps:n,force:t===!0||void 0});if(!e||typeof e!=`object`)return{apps:[],success:!1,hasCache:!1,isCacheStale:!1};let r=e;return r.supported===!1?{apps:[],success:!0,hasCache:!1,isCacheStale:!1}:Array.isArray(r.apps)?{apps:r.apps.filter(e=>e&&typeof e==`object`).map(e=>{let t=e;return{name:typeof t.name==`string`?t.name:``,iconDataUrl:typeof t.iconDataUrl==`string`?t.iconDataUrl:null}}).filter(e=>e.name.length>0),success:!0,hasCache:r.hasCache===!0,isCacheStale:r.isCacheStale===!0}:{apps:[],success:!1,hasCache:!1,isCacheStale:!1}}catch(e){return console.warn(`Failed to fetch installed apps`,e),{apps:[],success:!1,hasCache:!1,isCacheStale:!1}}};export{le as A,ne as B,R as C,q as D,X as E,Z as F,ee as G,W as H,ae as I,u as J,c as K,se as L,U as M,re as N,ue as O,b as P,ce as R,g as S,Y as T,L as U,O as V,G as W,l as X,s as Y,E as _,J as a,I as b,B as c,te as d,D as f,x as g,v as h,de as i,V as j,Q as k,k as l,_ as m,K as n,C as o,T as p,f as q,ie as r,w as s,S as t,oe as u,$ as v,z as w,h as x,F as y,A as z};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,i as n}from"./runtime-switch-DhMY9eiB.js";import{C as r}from"./desktop-CiqEZVr5.js";import{t as i}from"./runtimeAPIRegistry-C2VogTny.js";import{a,i as o,r as s}from"./vendor-zustand-o69pgTEK.js";import{it as c,rt as l}from"./vendor-base-ui-CdzJ6My_.js";import{L as u,bt as d,k as f,kt as p}from"./gitApiHttp-CoNokuDM.js";import{b as m,n as ee,x as h}from"./useUIStore-CEingF2z.js";import{D as g,O as _}from"./persistence-CNEHspb4.js";import{n as v}from"./vendor-react-BP2cRVqX.js";import{s as y}from"./vendor-tanstack-react-query-CdqCAt40.js";import{a as b,o as x}from"./queryRuntime-DWgXfxGx.js";import{r as S}from"./vendor-reactuses-core-BJ-jJ4YM.js";import{f as te,r as C,u as ne}from"./button--mt1oJ-H.js";import{Ea as re,Gn as w,Ht as ie,Ir as ae,S as T,Va as E,Za as oe,_t as se,bn as D,ct as ce,d as O,kr as le,lt as k,mo as A,po as ue,un as de,ut as fe,y as pe}from"./useMobileNavigationStore-DzkVc9H_.js";import{t as me}from"./AgentAvatar-MK9jNcwx.js";import{n as j}from"./Icon-C93bLV0e.js";import{g as he,v as ge}from"./gitApi-C1pkEDXu.js";import{f as _e,o as M}from"./projectMeta-CuVxfoYb.js";import{c as ve,d as ye,l as N,n as be,r as xe,t as Se}from"./fileMentionTouchSelection-m4Xsn0cx.js";import{n as Ce}from"./textarea-CNvFHvhC.js";var we=(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=w([...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)},Te=(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&&e.agentName===r.agentName}),Ee=(e,t)=>e.highlightedIndex===t.highlightedIndex&&Te(e.rows,t.rows),De=(e,t)=>Te(e,t)?e:t.slice(),Oe=(e,t,n)=>{e&&(t.current&&Ee(t.current,n)||(t.current=n,e(n)))},ke=(e,t)=>{t.current=null,e?.({rows:[],highlightedIndex:0})},P=e(c(),1),F=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},I=e=>/^[A-Za-z]:\//.test(e)?e.toLowerCase():e,L=(e,t)=>{let n=F(t),r=F(e);if(!n||!r)return!1;let i=I(n),a=I(r);return a===i||a.startsWith(`${i}/`)},Ae=e=>{if(!e||typeof e!=`object`)return{};let t=e,n={};for(let[e,r]of Object.entries(t)){let t=F(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=>F(e)).filter(e=>L(e,t)))):[],o=Array.isArray(i.expandedPaths)?Array.from(new Set(i.expandedPaths.filter(e=>typeof e==`string`).map(e=>F(e)).filter(e=>L(e,t)))):[],s=typeof i.selectedPath==`string`?F(i.selectedPath):null,c=s&&L(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},R=(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},z=e=>e?{...e,touchedAt:Date.now()}:{openPaths:[],selectedPath:null,expandedPaths:[],touchedAt:Date.now()},je=a()(s(o((e,t)=>({byRoot:{},addOpenPath:(t,n,r)=>{let i=F((t||``).trim()),a=F((n||``).trim());!i||!a||!r?.allowOutsideRoot&&!L(a,i)||e(e=>{let t=e.byRoot[i],n=z(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:R({...e.byRoot,[i]:{...n,openPaths:o,selectedPath:s}},20)}})},removeOpenPath:(t,n)=>{let r=F((t||``).trim()),i=F((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=I(i),a=e=>I(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:R({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeOpenPathsByPrefix:(t,n)=>{let r=F((t||``).trim()),i=F((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=I(i),a=n.endsWith(`/`)?n:`${n}/`,o=e=>{let t=I(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:R({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeExpandedPathsByPrefix:(t,n)=>{let r=F((t||``).trim()),i=F((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=I(i),a=n.endsWith(`/`)?n:`${n}/`,o=t.expandedPaths.filter(e=>{let t=I(e);return t!==n&&!t.startsWith(a)});return o.length===t.expandedPaths.length?e:{byRoot:R({...e.byRoot,[r]:{...t,expandedPaths:o,touchedAt:Date.now()}},20)}})},setSelectedPath:(t,n,r)=>{let i=F((t||``).trim()),a=n?F(n.trim()):null;!i||a&&!r?.allowOutsideRoot&&!L(a,i)||e(e=>{let t=e.byRoot[i],n=z(t),r=a&&!n.openPaths.includes(a)?[...n.openPaths,a]:n.openPaths;return t&&t.selectedPath===a&&r===t.openPaths?e:{byRoot:R({...e.byRoot,[i]:{...n,openPaths:r,selectedPath:a}},20)}})},ensureSelectedPath:e=>{let n=F((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=F((t||``).trim()),i=F((n||``).trim());!r||!i||!L(i,r)||e(e=>{let t=e.byRoot[r],n=z(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:R({...e.byRoot,[r]:{...n,expandedPaths:a}},20)}})},expandPath:(t,n)=>{let r=F((t||``).trim()),i=F((n||``).trim());!r||!i||!L(i,r)||e(e=>{let t=e.byRoot[r],n=z(t);return n.expandedPaths.includes(i)&&t?e:{byRoot:R({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,i]}},20)}})},expandPaths:(t,n)=>{let r=F((t||``).trim());if(!r||!n||n.length===0)return;let i=n.map(e=>F((e||``).trim())).filter(e=>e&&L(e,r));i.length!==0&&e(e=>{let t=e.byRoot[r],n=z(t),a=new Set(n.expandedPaths),o=i.filter(e=>!a.has(e));return o.length===0?e:{byRoot:R({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,...o]}},20)}})}}),{name:`files-view-tabs-store`,version:2,storage:m(),migrate:e=>{if(!e||typeof e!=`object`)return{byRoot:{}};let t=e.byRoot;return{byRoot:Ae(t)}},partialize:e=>({byRoot:Ae(e.byRoot)})}),{name:`files-view-tabs-store`})),B=v(),Me=(e,t)=>{let n=(0,B.c)(4),r=t===void 0?200:t,[i,a]=P.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]),P.useEffect(o,s),i},Ne=()=>{let e=(0,B.c)(17),t=O(Pe),n=D(),r;e[0]===t?r=e[1]:(r=e=>t?e.getAttachment(t):void 0,e[0]=t,e[1]=r);let i=T(r),a=O(V),o=O(H),s=A(U),c=A(Fe),l=d(Ie);if(t){let r;e[2]===i?r=e[3]:(r=pe(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 Pe(e){return e.currentSessionId}function V(e){return e.worktreeMetadata}function H(e){return e.newSessionDraft}function U(e){return e.activeProjectId}function Fe(e){return e.projects}function Ie(e){return e.currentDirectory}var W=l(),Le=`bg-transparent font-[inherit] text-[var(--primary-base)]`,Re=(e,t)=>{let n=t.trim().toLowerCase();if(!n)return e;let r=e.toLowerCase();if(!r.includes(n))return e;let i=[],a=0,o=r.indexOf(n);for(;o!==-1;)o>a&&i.push(e.slice(a,o)),i.push((0,W.jsx)(`mark`,{className:Le,children:e.slice(o,o+n.length)},`${o}-${n}`)),a=o+n.length,o=r.indexOf(n,a);return a<e.length&&i.push(e.slice(a)),i},ze=P.forwardRef(({searchQuery:e,onFileSelect:t,onAgentSelect:n,onSkillSelect:r,onSessionSelect:i,onClose:a,style:o,onRowsChange:s},c)=>{let{t:l}=te(),u=Ne()??``,d=O(e=>e.currentSessionId),f=ae(e=>e.activeSessions),m=ie({enabled:!!i}),h=A(e=>e.activeProjectId),v=A(e=>e.projects),y=P.useMemo(()=>v.find(e=>e.id===h)?.path??null,[h,v]),b=P.useMemo(()=>{let e=y||u;return e?e.replace(/\\/g,`/`).replace(/\/+$/,``):null},[y,u]),x=je(e=>b?e.byRoot[b]:void 0),w=re(e=>e.agents),T=p(e=>e.searchFiles),D=Me(e,180),ue=_(),de=g(),[pe,he]=P.useState([]),[ge,_e]=P.useState(!1),[M,ye]=P.useState(0),N=P.useRef(0),we=P.useRef({query:e,directory:u,ids:[]}),[Te,Ee]=P.useState(360),[De,F]=P.useState({}),[I,L]=P.useState({}),Ae=P.useRef([]),R=P.useRef([]),z=P.useRef([]),B=P.useRef(null),Pe=P.useRef(null),V=P.useRef(null);V.current||=Se();let H=ee(e=>e.isMobile),U=(e??``).trim(),Fe=oe({directory:u||null}),Ie=P.useMemo(()=>r?Fe.data??[]:[],[r,Fe.data]),Le=P.useMemo(()=>{if(!b||!x)return[];let e=[x.selectedPath,...x.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(`${b}/`)?e.slice(b.length+1):e;n.push({name:i,path:e,relativePath:a,extension:i.includes(`.`)?i.split(`.`).pop()?.toLowerCase():void 0})}return fe(n,U,{limit:6})},[U,b,x]),ze=P.useMemo(()=>n?E(w).filter(e=>e.mode!==`primary`):[],[w,n]),Be=P.useMemo(()=>i?ce({sessions:le(f,m),currentSessionId:d,searchQuery:U}):[],[f,d,m,U,i]),G=Le,Ve=pe,K=P.useMemo(()=>ve({skills:Ie,agents:ze,sessions:Be,recentFiles:G,pathHits:Ve,searchQuery:U,untitledSession:l(`chat.fileMentionAutocomplete.untitledSession`),sessionBadge:l(`chat.fileMentionAutocomplete.sessionType`),skillBadge:l(`chat.commandAutocomplete.badge.skill`)}),[Ie,ze,Be,G,Ve,U,l]);P.useEffect(()=>{let e=e=>{let t=e.target;!t||!B.current||B.current.contains(t)||a()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[a]),P.useEffect(()=>{if(!u){he([]);return}let e=(D??``).trim(),t=se(e);if(!t){he([]);return}let n=!1;_e(!0);let r={includeHidden:ue,respectGitignore:!de};return Promise.all([T(u,t,80,{...r,type:`file`}),T(u,t,40,{...r,type:`directory`})]).then(([t,r])=>{if(n)return;let i=new Set(Le.map(e=>e.path));he(k({files:t,directories:r,query:e,excludePaths:i,limit:20}))}).catch(()=>{n||he([])}).finally(()=>{n||_e(!1)}),()=>{n=!0}},[u,D,Le,T,ue,de]),P.useLayoutEffect(()=>{let t=we.current,n=t.ids[N.current],r=t.query===e&&t.directory===u?Math.max(0,K.findIndex(e=>e.id===n)):0;we.current={query:e,directory:u,ids:K.map(e=>e.id)},N.current=r,ye(r)},[K,e,u]),P.useEffect(()=>{F({}),L({})},[K]),P.useEffect(()=>{Ae.current[M]?.scrollIntoView({block:`nearest`})},[M]),P.useEffect(()=>{let e=null,t=()=>{e!==null&&cancelAnimationFrame(e),e=requestAnimationFrame(()=>{let e={},t={};R.current.forEach((n,r)=>{if(!n)return;let i=z.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}}),F(e),L(t)})};return t(),window.addEventListener(`resize`,t),()=>{e!==null&&cancelAnimationFrame(e),window.removeEventListener(`resize`,t)}},[K]),P.useEffect(()=>{let e=R.current[M];if(!e)return;let t=()=>{let t=e.clientWidth;t>0&&Ee(t)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>{n.disconnect()}},[M]);let He=S(e=>{t(e)}),Ue=S(e=>{n?.(e)}),We=S(e=>{i?.(e)}),Ge=S(e=>{r?.(e)}),Ke=(e,t)=>({onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&V.current?.pointerDown(e.clientX,e.clientY)},onPointerMove:e=>{e.pointerType===`touch`&&V.current?.pointerMove(e.clientX,e.clientY)},onPointerUp:e=>{e.pointerType===`touch`&&(V.current?.pointerUp(t)??!1)&&(e.preventDefault(),e.stopPropagation())},onPointerCancel:()=>V.current?.pointerCancel(),onClick:()=>{V.current?.click(t)},onMouseMove:()=>{N.current=e,ye(e)}}),q=e=>{let t=K.length;if(t===0)return;let n=(e%t+t)%t,r=K[n];if(r.agentName!==void 0){Ue(r.agentName);return}if(r.id.startsWith(`skill:`)){let e=Ie.find(e=>r.id===`skill:${e.name}-${e.scope}`);e&&Ge(e);return}if(r.id.startsWith(`session:`)){let e=Be.find(e=>r.id===`session:${e.id}`);e&&We(e);return}let i=r.id.startsWith(`recent:`)?G.find(e=>r.id===`recent:${e.path}`):Ve.find(e=>r.id===`file:${e.path}`);i&&He(i)};P.useEffect(()=>{Oe(s,Pe,{rows:K,highlightedIndex:M})},[s,M,K]);let qe=P.useRef(s);return qe.current=s,P.useEffect(()=>()=>{ke(qe.current,Pe)},[]),P.useImperativeHandle(c,()=>({acceptIndex:e=>{q(e)},handleKeyDown:e=>{if(e===`Escape`){a();return}let t=K.length;if(t!==0){if(e===`ArrowDown`){N.current=(N.current+1)%t,ye(N.current);return}if(e===`ArrowUp`){N.current=(N.current-1+t)%t,ye(N.current);return}(e===`Enter`||e===`Tab`)&&q(N.current)}}})),(0,W.jsxs)(be,{ref:B,isMobile:H,className:`max-w-[640px] max-h-64`,style:o,children:[(0,W.jsx)(Ce,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0`,children:(0,W.jsxs)(`div`,{className:`py-1`,children:[K.map((e,t)=>{let n=e.id.startsWith(`file:`)||e.id.startsWith(`recent:`),r=n?ne(e.title,{maxLength:60}):e.title,i=M===t,a=De[t]??!1,o=I[t]??2.6;return(0,W.jsxs)(`div`,{"data-mention-id":e.id,ref:e=>{Ae.current[t]=e},className:C(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,H&&`min-h-11`,xe(H,i),!H&&i&&`text-interactive-selection-foreground`),...Ke(t,()=>q(t)),children:[(0,W.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center`,children:e.agentName===void 0?(0,W.jsx)(j,{name:e.iconName,className:`size-3.5 text-current`}):(0,W.jsx)(me,{name:e.agentName,size:20})}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`span`,{ref:e=>{R.current[t]=e},className:`relative block min-w-0 overflow-hidden file-mention-marquee-container`,style:i?{"--file-mention-marquee-width":`${Te}px`,"--file-mention-marquee-duration":`${o}s`}:void 0,title:e.title,children:[(0,W.jsx)(`span`,{ref:e=>{z.current[t]=e},className:`absolute invisible whitespace-nowrap pointer-events-none`,"aria-hidden":!0,children:e.title}),n&&a&&i?(0,W.jsx)(`span`,{className:`inline-block whitespace-nowrap file-mention-marquee`,children:Re(e.title,U)}):(0,W.jsx)(`span`,{className:`block truncate`,children:Re(r,U)})]}),e.subtitle?(0,W.jsx)(`div`,{className:C(`truncate text-muted-foreground`,H?`typography-micro`:`typography-meta`),children:Re(e.subtitle,U)}):null]})]},e.id)}),ge&&Ve.length===0?(0,W.jsx)(`div`,{className:`flex items-center justify-center py-3`,children:(0,W.jsx)(j,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):null,!ge&&K.length===0&&(0,W.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:l(`chat.fileMentionAutocomplete.empty`)})]})}),!H&&(0,W.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:l(`chat.autocomplete.keyboardHint`)})]})}),Be=new Set([`new`,`fork`,`compact`,`reload`,`undo`,`redo`,`model`,`goal`,`btw`]),G=(e,t)=>{if(!t||e.isSkill)return!1;let n=e.name?.trim().toLowerCase();return!!(n&&Be.has(n))},Ve=(e,t)=>!e||t({name:e}),K=` `,He=(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]===K&&e[r-2]===`/`&&(r-=2),e[r]===`/`?{start:r,end:n}:null},Ue=`text-[10px] leading-none uppercase font-bold tracking-tight px-1.5 py-1 rounded border flex-shrink-0`,We=C(Ue,`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)]`),Ge=C(Ue,`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)]`),Ke=C(Ue,`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)]`),q=C(Ue,`bg-[var(--surface-muted)] text-muted-foreground border-[var(--interactive-border)]/60`),qe=(e,t)=>e.length===t.length&&e.every((e,n)=>e.id===t[n]?.id&&e.description===t[n]?.description),Je=(e,t)=>{let n=!!e.sessionID;return{hasSession:n,canStartSessionCommand:n||e.hasNewDraft,canUseReviewHandoffFlow:n&&!t&&!r()}},Ye=P.forwardRef(({searchQuery:e,onCommandSelect:t,onClose:n,directory:i,style:a,commandPolicy:o,commandContext:s,onRowsChange:c},l)=>{let{t:u}=te(),d=ee(e=>e.isMobile),f=O(e=>e.currentSessionId),p=O(e=>!!e.newSessionDraft?.open),m=O(P.useCallback(e=>f?e.getDirectoryForSession(f):void 0,[f])),h=de(f??``,m??void 0),g=P.useMemo(()=>s??{sessionID:f??null,hasMessages:h.length>0,hasNewDraft:p},[s,f,h.length,p]),{hasSession:_,canStartSessionCommand:v,canUseReviewHandoffFlow:y}=P.useMemo(()=>Je(g,d),[g,d]),b=g.hasMessages,[x,S]=P.useState([]),[ne,re]=P.useState(!1),w=ue({directory:i}),ie=P.useMemo(()=>w.data??[],[w.data]),ae=w.isFetching,[T,E]=P.useState(0),oe=P.useRef(0),se=P.useRef(!1),D=P.useRef([]),ce=P.useRef(null),le=P.useRef(!1),k=P.useRef(null),A=P.useRef(!1),fe=P.useRef(null);P.useEffect(()=>{let e=e=>{let t=e.target;!t||!ce.current||ce.current.contains(t)||n()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[n]),P.useEffect(()=>{(async()=>{re(ae);try{let t=ie.flatMap((e,t)=>e.source===`skill`?[]:[{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,scope:e.scope,reference:e.reference}]),n=[{id:`yuri:new`,name:`new`,source:`yuri`,description:u(`chat.commandAutocomplete.command.newDescription`),isBuiltIn:!0},..._&&!b?[{id:`yuri:init`,name:`init`,source:`yuri`,description:u(`chat.commandAutocomplete.command.initDescription`),isBuiltIn:!0}]:[],..._?[{id:`yuri:btw`,name:`btw`,source:`yuri`,description:u(`chat.btw.description`),isBuiltIn:!0},{id:`yuri:undo`,name:`undo`,source:`yuri`,description:u(`chat.commandAutocomplete.command.undoDescription`),isBuiltIn:!0},{id:`yuri:redo`,name:`redo`,source:`yuri`,description:u(`chat.commandAutocomplete.command.redoDescription`),isBuiltIn:!0},{id:`yuri:fork`,name:`fork`,source:`yuri`,description:u(`chat.commandAutocomplete.command.forkDescription`),isBuiltIn:!0},{id:`yuri:timeline`,name:`timeline`,source:`yuri`,description:u(`chat.commandAutocomplete.command.timelineDescription`),isBuiltIn:!0}]:[],{id:`yuri:model`,name:`model`,source:`yuri`,description:u(`chat.commandAutocomplete.command.modelDescription`),isBuiltIn:!0},{id:`yuri:compact`,name:`compact`,source:`yuri`,description:u(`chat.commandAutocomplete.command.compactDescription`),isBuiltIn:!0},...r()?[{id:`yuri:reload`,name:`reload`,source:`yuri`,description:u(`chat.commandAutocomplete.command.reloadDescription`),isBuiltIn:!0}]:[],..._?[{id:`yuri:summary`,name:`summary`,source:`yuri`,description:u(`chat.commandAutocomplete.command.summaryDescription`),isYuri:!0}]:[],...v?[{id:`yuri:workspace-review`,name:`workspace-review`,source:`yuri`,description:u(`chat.commandAutocomplete.command.workspaceReviewDescription`),isYuri:!0}]:[],...y?[{id:`yuri:handoff-review`,name:`handoff-review`,source:`yuri`,description:u(`chat.commandAutocomplete.command.handoffReviewDescription`),isYuri:!0}]:[],...v?[{id:`yuri:craft-goal`,name:`craft-goal`,source:`yuri`,description:u(`chat.commandAutocomplete.command.craftGoalDescription`),isYuri:!0}]:[],...v?[{id:`yuri:goal`,name:`goal`,source:`yuri`,description:u(`chat.goal.button.armAria`),isBuiltIn:!0}]:[],...v?[{id:`yuri:catch-up`,name:`catch-up`,source:`yuri`,description:u(`chat.commandAutocomplete.command.catchUpDescription`),isYuri:!0}]:[],...v?[{id:`yuri:debug`,name:`debug`,source:`yuri`,description:u(`chat.commandAutocomplete.command.debugDescription`),isYuri:!0}]:[],...v?[{id:`yuri:weigh`,name:`weigh`,source:`yuri`,description:u(`chat.commandAutocomplete.command.weighDescription`),isYuri:!0}]:[],...v?[{id:`yuri:explore`,name:`explore`,source:`yuri`,description:u(`chat.commandAutocomplete.command.exploreDescription`),isYuri:!0}]:[],...t],i=!b,a=we(n.filter(e=>(i||e.name!==`init`)&&(o?.(e)??!0)),e);S(e=>qe(e,a)?e:a)}catch{let t=!b,n=we([{id:`yuri:new`,name:`new`,source:`yuri`,description:u(`chat.commandAutocomplete.command.newDescription`),isBuiltIn:!0},..._&&!b?[{id:`yuri:init`,name:`init`,source:`yuri`,description:u(`chat.commandAutocomplete.command.initDescription`),isBuiltIn:!0}]:[],..._?[{id:`yuri:btw`,name:`btw`,source:`yuri`,description:u(`chat.btw.description`),isBuiltIn:!0},{id:`yuri:undo`,name:`undo`,source:`yuri`,description:u(`chat.commandAutocomplete.command.undoDescription`),isBuiltIn:!0},{id:`yuri:redo`,name:`redo`,source:`yuri`,description:u(`chat.commandAutocomplete.command.redoDescription`),isBuiltIn:!0},{id:`yuri:fork`,name:`fork`,source:`yuri`,description:u(`chat.commandAutocomplete.command.forkDescription`),isBuiltIn:!0},{id:`yuri:timeline`,name:`timeline`,source:`yuri`,description:u(`chat.commandAutocomplete.command.timelineDescription`),isBuiltIn:!0}]:[],{id:`yuri:model`,name:`model`,source:`yuri`,description:u(`chat.commandAutocomplete.command.modelDescription`),isBuiltIn:!0},{id:`yuri:compact`,name:`compact`,source:`yuri`,description:u(`chat.commandAutocomplete.command.compactDescription`),isBuiltIn:!0},...r()?[{id:`yuri:reload`,name:`reload`,source:`yuri`,description:u(`chat.commandAutocomplete.command.reloadDescription`),isBuiltIn:!0}]:[],..._?[{id:`yuri:summary`,name:`summary`,source:`yuri`,description:u(`chat.commandAutocomplete.command.summaryDescription`),isYuri:!0}]:[],...v?[{id:`yuri:workspace-review`,name:`workspace-review`,source:`yuri`,description:u(`chat.commandAutocomplete.command.workspaceReviewDescription`),isYuri:!0}]:[],...y?[{id:`yuri:handoff-review`,name:`handoff-review`,source:`yuri`,description:u(`chat.commandAutocomplete.command.handoffReviewDescription`),isYuri:!0}]:[],...v?[{id:`yuri:craft-goal`,name:`craft-goal`,source:`yuri`,description:u(`chat.commandAutocomplete.command.craftGoalDescription`),isYuri:!0}]:[],...v?[{id:`yuri:goal`,name:`goal`,source:`yuri`,description:u(`chat.goal.button.armAria`),isBuiltIn:!0}]:[],...v?[{id:`yuri:catch-up`,name:`catch-up`,source:`yuri`,description:u(`chat.commandAutocomplete.command.catchUpDescription`),isYuri:!0}]:[],...v?[{id:`yuri:debug`,name:`debug`,source:`yuri`,description:u(`chat.commandAutocomplete.command.debugDescription`),isYuri:!0}]:[],...v?[{id:`yuri:weigh`,name:`weigh`,source:`yuri`,description:u(`chat.commandAutocomplete.command.weighDescription`),isYuri:!0}]:[],...v?[{id:`yuri:explore`,name:`explore`,source:`yuri`,description:u(`chat.commandAutocomplete.command.exploreDescription`),isYuri:!0}]:[]].filter(e=>(t||e.name!==`init`)&&(o?.(e)??!0)),e);S(e=>qe(e,n)?e:n)}finally{re(!1)}})()},[e,b,_,v,y,ie,ae,u,o]),P.useEffect(()=>{E(0)},[x]),P.useEffect(()=>{oe.current=T},[T]),P.useEffect(()=>{D.current[T]?.scrollIntoView({block:`nearest`})},[T]),P.useEffect(()=>{Oe(c,fe,{rows:N(x,{skill:u(`chat.commandAutocomplete.badge.skill`),command:u(`chat.commandAutocomplete.badge.command`),system:u(`chat.commandAutocomplete.badge.system`)}),highlightedIndex:T})},[x,c,T,u]);let pe=P.useRef(c);pe.current=c,P.useEffect(()=>()=>{ke(pe.current,fe)},[]),P.useImperativeHandle(l,()=>({acceptIndex:(e,n=!0)=>{let r=x[e];r&&t(r,G(r,n))},handleKeyDown:e=>{let r=x.length;if(e===`Escape`){n();return}if(r!==0){if(e===`ArrowDown`){se.current=!0,E(e=>(e+1)%r);return}if(e===`ArrowUp`){se.current=!0,E(e=>(e-1+r)%r);return}if(e===`Enter`||e===`Tab`){let n=(oe.current%r+r)%r,i=x[n];i&&t(i,G(i,e===`Enter`))}}}}),[x,n,t]);let me=e=>{let t=ye(e);switch(e.name){case`new`:return(0,W.jsx)(j,{name:t,className:`h-3.5 w-3.5`});case`init`:return(0,W.jsx)(j,{name:t,className:`h-3.5 w-3.5 text-green-500`});case`undo`:return(0,W.jsx)(j,{name:t,className:`h-3.5 w-3.5 text-orange-500`});case`redo`:return(0,W.jsx)(j,{name:t,className:`h-3.5 w-3.5 text-orange-500`});case`timeline`:case`reload`:return(0,W.jsx)(j,{name:t,className:`h-3.5 w-3.5`});case`compact`:return(0,W.jsx)(j,{name:t,className:`h-3.5 w-3.5 text-purple-500`});case`goal`:return(0,W.jsx)(j,{name:t,className:`h-3.5 w-3.5`});case`review`:return(0,W.jsx)(j,{name:t,className:`h-3.5 w-3.5 text-blue-500`});case`test`:case`build`:case`run`:return(0,W.jsx)(j,{name:t,className:`h-3.5 w-3.5 text-cyan-500`});default:return e.isBuiltIn?(0,W.jsx)(j,{name:t,className:`h-3.5 w-3.5 text-yellow-500`}):(0,W.jsx)(j,{name:t,className:`h-3.5 w-3.5 text-muted-foreground`})}};return(0,W.jsxs)(be,{ref:ce,isMobile:d,className:`max-w-[450px] max-h-64`,style:a,children:[(0,W.jsx)(Ce,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0 py-1.5`,children:ne?(0,W.jsx)(`div`,{className:`flex items-center justify-center py-4`,children:(0,W.jsx)(j,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):(0,W.jsxs)(`div`,{children:[x.map((n,r)=>{let i=n.isBuiltIn,a=n.isYuri;return(0,W.jsxs)(`div`,{ref:e=>{D.current[r]=e},className:C(`flex gap-2 px-2 py-2 cursor-pointer rounded-lg`,d?`items-center`:`items-start`,xe(d,r===T),!d&&r===T&&`bg-interactive-selection/35`),onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&(k.current={x:e.clientX,y:e.clientY},A.current=!1)},onPointerMove:e=>{if(e.pointerType!==`touch`||!k.current)return;let t=e.clientX-k.current.x,n=e.clientY-k.current.y;Math.hypot(t,n)>6&&(A.current=!0)},onPointerUp:e=>{if(e.pointerType!==`touch`)return;let r=A.current;k.current=null,A.current=!1,!r&&(e.preventDefault(),e.stopPropagation(),le.current=!0,t(n,G(n,d)))},onPointerCancel:()=>{k.current=null,A.current=!1},onClick:()=>{if(le.current){le.current=!1;return}t(n,G(n,d))},onMouseMove:()=>{se.current=!1,E(r)},children:[(0,W.jsx)(`div`,{className:C(!d&&`mt-0.5`),children:me(n)}),(0,W.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsxs)(`span`,{className:`typography-ui-label font-medium`,children:[`/`,Re(n.name,e)]}),n.isSkill?(0,W.jsx)(`span`,{className:We,children:u(`chat.commandAutocomplete.badge.skill`)}):(0,W.jsx)(`span`,{className:We,children:u(`chat.commandAutocomplete.badge.command`)}),a?(0,W.jsx)(`span`,{className:q,children:`Yuri`}):i?(0,W.jsx)(`span`,{className:q,children:u(`chat.commandAutocomplete.badge.system`)}):n.scope?(0,W.jsx)(`span`,{className:n.scope===`project`?Ke:Ge,children:n.scope}):null,n.agent&&(0,W.jsx)(`span`,{className:q,children:n.agent})]}),n.description&&!d&&(0,W.jsx)(`div`,{className:`typography-meta text-muted-foreground mt-0.5 truncate`,children:Re(n.description,e)})]})]},n.id)}),x.length===0&&(0,W.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:u(`chat.commandAutocomplete.empty`)})]})}),!d&&(0,W.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:u(`chat.autocomplete.keyboardHint`)})]})});Ye.displayName=`CommandAutocomplete`;var Xe=2,Ze=e=>!!e&&typeof e==`object`&&!Array.isArray(e),Qe=e=>{let t=e?.trim().replace(/\\/g,`/`);return t?t.length>1?t.replace(/\/+$/,``):t:null},$e=e=>Ze(e)&&Array.isArray(e.all)&&e.all.every(e=>typeof e==`string`)&&typeof e.current==`string`&&Ze(e.branches),J=(e,t)=>JSON.stringify([e,t]),et=e=>`version`in e&&e.version===Xe&&Ze(e.entries),tt=e=>{if(!e)return null;try{let t=JSON.parse(e);return Ze(t)?t.version===Xe&&Ze(t.entries)?{version:Xe,entries:t.entries}:t:null}catch{return null}},nt=(e,t)=>{try{e.setItem(`yuri.gitBranchCache`,JSON.stringify(t))}catch{}},rt=(e,t,n)=>{let r=Qe(e);if(!r||!t)return null;let i;try{i=n.getItem(`yuri.gitBranchCache`)}catch{return null}let a=tt(i);if(!a)return null;if(et(a))return $e(a.entries[J(t,r)])?a.entries[J(t,r)]:null;let o={};for(let[e,n]of Object.entries(a)){let r=Qe(e);r&&$e(n)&&(o[J(t,r)]=n)}return nt(n,{version:Xe,entries:o}),o[J(t,r)]??null},it=(e,t,n,r)=>{let i=Qe(e);if(!i||!t||!$e(n))return;let a=null;try{a=r.getItem(`yuri.gitBranchCache`)}catch{return}let o=tt(a);nt(r,{version:Xe,entries:{...o&&et(o)?o.entries:{},[J(t,i)]:n}})},at=3e4,Y=Qe,ot=(e,t=n())=>x.git.branches(Y(e),t),st=(e,t=n())=>x.git.remotes(Y(e),t),ct=async(e,t,n)=>{n.throwIfAborted();let r=i()?.git,a=t?.getGitBranches?await t.getGitBranches(e,{signal:n}):r?await r.getGitBranches(e,{signal:n}):await f(e,{signal:n});return n.throwIfAborted(),a},lt=async(e,t,n)=>{n.throwIfAborted();let r=i()?.git,a=t?.getRemotes?await t.getRemotes(e,{signal:n}):r?await r.getRemotes(e,{signal:n}):await u(e,{signal:n});return n.throwIfAborted(),a},ut=(e,t,r=n(),i=h())=>{let a=Y(e),o=t;return{queryKey:ot(a,r),queryFn:async({signal:e})=>{if(!a)throw Error(`Git branches require a directory`);let t=await ct(a,o,e);return it(a,r,t,i),t},staleTime:at,gcTime:1/0,initialData:()=>rt(a,r,i)??void 0,initialDataUpdatedAt:0}},dt=(e,t,r=n())=>{let i=Y(e),a=t;return{queryKey:st(i,r),queryFn:({signal:e})=>{if(!i)throw Error(`Git remotes require a directory`);return lt(i,a,e)},staleTime:at,gcTime:1/0}},ft=(e,r,i)=>{let a=(0,B.c)(9),o=i===void 0||i,s=P.useSyncExternalStore(t,n,n),c,l,u;a[0]!==e||a[1]!==r||a[2]!==s?(c=Y(e),u=y,l=ut(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)},pt=(e,r,i)=>{let a=(0,B.c)(9),o=i===void 0||i,s=P.useSyncExternalStore(t,n,n),c,l,u;a[0]!==e||a[1]!==r||a[2]!==s?(c=Y(e),u=y,l=dt(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)},mt=(e,t,r=b,i=n())=>r.fetchQuery(ut(e,t,i)),ht=(e,t,r=b,i=n())=>r.fetchQuery({...ut(e,t,i),staleTime:0}),gt=e=>e instanceof Error?e.name===`AbortError`||e.name===`CancelledError`||e.name===`Error`&&e.message===`CancelledError`:!1,_t=1e4,vt=6e4,yt=5e3,bt=3e4,xt=6e4,St=25,Ct=40,wt=2,Tt=15e3,Et=500,Dt=30,Ot=20971520,kt=new Map,At=new Map,jt=new Map,X=new Map,Mt=new Map,Nt=new Map,Pt=new WeakMap,Ft=e=>{let t=Pt.get(e);return t||(t=new Set(e.files.map(e=>e.path)),Pt.set(e,t)),t},It=(e,t)=>`${t}:${e}`,Lt=e=>At.get(e)??0,Rt=e=>{let t=Lt(e)+1;return At.set(e,t),t},zt=e=>{let t=(jt.get(e)??0)+1;return jt.set(e,t),t},Bt=e=>{let t=kt.get(e);if(t)return t;let n=new Set;return kt.set(e,n),n},Z=()=>({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}),Vt=(e,t=Dt,n=Ot)=>{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},Ht=(e,t)=>!e&&!t?!1:!e||!t||e.remote!==t.remote||e.branch!==t.branch||e.ahead!==t.ahead||e.behind!==t.behind,Ut=e=>{let t=e?.trim()??``;return t===`?`?``:t},Wt=(e,t)=>{let n=new Set,r=!1,i=!e;e&&(i=e.ahead!==t.ahead||e.behind!==t.behind||e.current!==t.current||e.tracking!==t.tracking||e.isClean!==t.isClean||t.upstreamComparison!==void 0&&Ht(e.upstreamComparison,t.upstreamComparison)||t.diffStats!==void 0&&e.diffStats===void 0);let a=new Map;for(let t of e?.files??[])a.set(t.path,t);for(let e of t.files??[]){let t=a.get(e.path);if(!t){n.add(e.path),Ut(e.index)&&(r=!0);continue}a.delete(e.path),(t.index!==e.index||t.working_dir!==e.working_dir)&&n.add(e.path),!r&&Ut(t.index)!==Ut(e.index)&&(r=!0)}for(let[e,t]of a)n.add(e),Ut(t.index)&&(r=!0);let o=t.diffStats,s=e?.diffStats;if(o!==void 0&&o!==s){let e=s??{};for(let t in o){let r=o[t],i=e[t];(!i||i.insertions!==r.insertions||i.deletions!==r.deletions)&&n.add(t)}for(let t in e)t in o||n.add(t)}return{changed:i||n.size>0,changedPaths:n,indexChanged:r}},Gt=e=>!e||e.trim().length===0,Kt=e=>(e||``).trim()===`U`,qt=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(Kt(t)||Kt(n))return e;let r=t===`?`||n===`?`?`A`:t||n||` `;return{...e,index:r,working_dir:` `}},Jt=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(Kt(t)||Kt(n))return e;let r=n||(t===`A`||t===`?`?`?`:t)||` `;return{...e,index:` `,working_dir:r}},Yt=e=>Gt(e.index)&&Gt(e.working_dir),Q=a()(s((e,t)=>({directories:new Map,activeDirectory:null,setActiveDirectory:n=>{let{activeDirectory:r,directories:i}=t();if(r!==n)if(r&&Rt(r),n&&Rt(n),n&&!i.has(n)){let t=new Map(i);t.set(n,Z()),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=It(n,a),s=X.get(o)??(a===`light`?X.get(It(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||=Z(),!a){let r=new Map(t().directories),i=r.get(n)??Z();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)>vt,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),d=t().directories.get(n)??Z(),f=Nt.get(n),p=f?.received===u&&f.stored===d.status?null:Wt(d.status,u);if(p?.changed){c=!0;let r=new Map(t().directories),i=r.get(n)??Z(),{changedPaths:s,indexChanged:l}=p,d=new Map(i.diffCache);for(let e of s)d.delete(e);let f=s.size>0;f&&Rt(n);let m={...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:m,diffCache:d,indexRevision:l?i.indexRevision+1:i.indexRevision,lastRepoCheckAt:o?a:i.lastRepoCheckAt,lastStatusFetch:Date.now(),lastStatusChange:f?Date.now():i.lastStatusChange}),e({directories:r}),Nt.set(n,{received:u,stored:m})}else{Nt.set(n,{received:u,stored:d.status});let r=new Map(t().directories),i=r.get(n)??Z();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)??Z();r.set(n,{...i,isLoadingStatus:!1}),e({directories:r})}}return c})();X.set(o,c);try{return await c}finally{X.get(o)===c&&X.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`?qt(e):Jt(e);t!==e&&(l=!0),Yt(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=zt(r);{let n=new Map(t().directories),i=n.get(r)??Z();n.set(r,{...i,isLoadingBranches:!0}),e({directories:n})}try{let c=a.force?await ht(r,i,void 0,o):await mt(r,i,void 0,o);if(s!==jt.get(r)||o!==n())return;let l=new Map(t().directories),u=l.get(r)??Z();l.set(r,{...u,branches:c,branchesTransportIdentity:o,isLoadingBranches:!1,lastBranchesFetch:Date.now()}),e({directories:l})}catch(i){if(gt(i)||console.error(`Failed to fetch git branches:`,i),s!==jt.get(r)||o!==n())return;let a=new Map(t().directories),c=a.get(r)??Z();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)??Z();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)??Z();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)??Z();i.set(n,{...a,isLoadingLog:!1}),e({directories:i})}},fetchIdentity:async(n,r)=>{{let r=new Map(t().directories),i=r.get(n)??Z();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)??Z();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)??Z();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=Z();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)??Z(),s=new Map(o.diffCache);s.set(r,{...i,fetchedAt:Date.now()});let c=Vt(s);a.set(n,{...o,diffCache:c}),e({directories:a})},clearDiffCache:n=>{Rt(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,St);await t().prefetchDiffs(e,n,i,{maxFiles:St})},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=Ct}=a,c=Math.min(Math.max(1,s),Dt),l=Ft(o.status),u=o.status.diffStats,d=Bt(n),f=[],p=new Set;for(let e of i){if(p.size>=c)break;if(!e||p.has(e)||!l.has(e))continue;let t=u?.[e];t&&t.insertions+t.deletions>Et||(p.add(e),!o.diffCache.has(e)&&(d.has(e)||f.push(e)))}let m=f;if(m.length===0)return;let ee=Lt(n);if(typeof document<`u`&&document.hidden)return;m.forEach(e=>d.add(e));let h=0,g=[],_=()=>{let e=h;return h+=1,e<m.length?m[e]:null},v=async e=>{let t=r.getGitFileDiff(n,{path:e}),i=new Promise((e,t)=>{setTimeout(()=>t(Error(`Timed out after ${Tt}ms`)),Tt)}),a=await Promise.race([t,i]);return{path:e,diff:{original:a.original??``,modified:a.modified??``,isBinary:a.isBinary}}},y=async()=>{for(;;){if(ee!==Lt(n))return;let e=_();if(!e)return;try{g.push(await v(e))}catch{}finally{d.delete(e)}}},b=Math.min(wt,m.length);if(await Promise.allSettled(Array.from({length:b},()=>y())),m.forEach(e=>d.delete(e)),ee!==Lt(n))return;let x=new Map(t().directories),S=x.get(n);if(!S)return;let te=new Map(S.diffCache),C=Date.now();g.forEach(e=>{!e.diff.isBinary&&e.diff.original===``&&e.diff.modified===``||te.set(e.path,{...e.diff,fetchedAt:C})});let ne=Vt(te);x.set(n,{...S,diffCache:ne}),e({directories:x})},setLogMaxCount:(n,r)=>{let i=new Map(t().directories),a=i.get(n)??Z();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<yt||await t().fetchStatus(e,n,{silent:!!r?.status})},ensureAll:(e,n)=>{let r=Mt.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)>=yt)&&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>=bt)&&o.push(t().fetchBranches(e,n)),(!a.log||i-a.lastLogFetch>=_t)&&o.push(t().fetchLog(e,n)),(!a.identity||i-a.lastIdentityFetch>=xt)&&o.push(t().fetchIdentity(e,n)),o.length>0&&await Promise.all(o)})();return Mt.set(e,i),i.finally(()=>{Mt.get(e)===i&&Mt.delete(e)}),i},refresh:async(e,n={})=>{let{activeDirectory:r}=t();r&&await t().fetchAll(r,e,n)}}),{name:`git-store`})),Xt=e=>{let t=(0,B.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),Q(n)},Zt=e=>{let r=(0,B.c)(3),i=P.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],Q(a)},Qt=e=>{let t=(0,B.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),Q(n)},$t=e=>{let t=(0,B.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),Q(n)},en=e=>{let t=(0,B.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),Q(n)},tn=e=>{let t=(0,B.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=new Map,t[0]=n):n=t[0];let r=P.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),Q(i)},nn=e=>{let t=(0,B.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),Q(n)},rn=e=>{let t=(0,B.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),Q(n)},an=e=>{let t=(0,B.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),Q(n)},on=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)}},$=e=>String(e||``).trim().replace(/^refs\/heads\//,``).replace(/^heads\//,``).replace(/^remotes\//,``),sn=e=>e.branchName?$(e.branchName):e.mode===`existing`?$(e.existingBranch||e.preferredName||``):$(e.preferredName||``),cn=async e=>{let t=await _e(e);try{let n=on((await he(e)).branches?.[t]?.tracking||null);if(n?.remote)return n.remote}catch{}try{let t=on((await ge(e)).tracking);if(t?.remote)return t.remote}catch{}return null},ln=async(e,t)=>{let n=await cn(e),r=$(t);return!n||!r?null:{setUpstream:!0,upstreamRemote:n,upstreamBranch:r}},un=async(e,t,n)=>{let r=sn(t),i=n?.resolvedRootTrackingRemote,a=i===void 0?await ln(e,r):i&&$(r)?{setUpstream:!0,upstreamRemote:i,upstreamBranch:$(r)}:null;return a?{...t,setUpstream:t.setUpstream??a.setUpstream,upstreamRemote:t.upstreamRemote||a.upstreamRemote,upstreamBranch:t.upstreamBranch||a.upstreamBranch}:t},dn=async(e,t,n)=>{let r=await un(e.path,t,n);return M(e,r)},fn=`yuri:lastWorktreeSourceBranch`,pn=({mode:e,sourceBranch:t,linkedPr:n,selectedBranch:r})=>e===`existing-branch`?r||null:n?null:t||null,mn=({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},hn=(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?` `:``}`},gn=(e,t,n)=>{let r=hn(e,t,n);return`${t.length===0&&!/^\s/.test(r)?` `:``}${r}${n.length===0&&!/\s$/.test(r)?` `:``}`},_n=(e,t,n,r)=>{let i=e.slice(0,t),a=e.slice(n),o=gn(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}},vn=(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.some(e=>e.range.start<t.range.end&&t.range.start<e.range.end)?[...e]:[...e,t]},yn=(e,t)=>t<e.length&&e[t]===` `?t+1:t;export{je as A,pt as C,ze as D,Ve as E,Ne as O,ft as S,He as T,tn as _,fn as a,$t as b,dn as c,en as d,Zt as f,Qt as g,nn as h,gn as i,De as j,Me as k,cn as l,rn as m,vn as n,mn as o,an as p,_n as r,pn as s,yn as t,un as u,Xt as v,Ye as w,ht as x,Q as y};