@yuriai/web 0.2.31 → 0.2.32-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 (201) hide show
  1. package/README.md +19 -0
  2. package/dist/assets/{AgentAvatar-DLAQkFQe.js → AgentAvatar-DLzcNrQ0.js} +1 -1
  3. package/dist/assets/AssistantContactStatus-Bf1yg0yx.js +3 -0
  4. package/dist/assets/{AssistantUnreadBadge-BynxNQMk.js → AssistantUnreadBadge-BUFyxUrT.js} +1 -1
  5. package/dist/assets/{AssistantView-CDZyA9ft.js → AssistantView-CELFybSr.js} +1 -1
  6. package/dist/assets/{DiagramView-DdVFGHQQ.js → DiagramView-DV4P3-Wg.js} +1 -1
  7. package/dist/assets/{FadeInOnReveal-C9a7XnAh.js → FadeInOnReveal-BRrU2ivL.js} +1 -1
  8. package/dist/assets/{GuiPluginSurface-v8r-Hex5.js → GuiPluginSurface-NOHaJGy2.js} +1 -1
  9. package/dist/assets/{GuiPluginWindow-Ba1HfrjQ.js → GuiPluginWindow-BykPaQeY.js} +1 -1
  10. package/dist/assets/Icon-OJf0qBKf.js +1 -0
  11. package/dist/assets/{ImageLoadingPlaceholder-Dcy5lc7F.js → ImageLoadingPlaceholder-DlQbo9CM.js} +1 -1
  12. package/dist/assets/{LoadingImage-BxjJ_Xyj.js → LoadingImage-sZ5omN5L.js} +1 -1
  13. package/dist/assets/MarkdownRenderer-BFR9FWQL.js +2 -0
  14. package/dist/assets/MarkdownRendererImpl-iZFUMI3M.js +10 -0
  15. package/dist/assets/{MarkstreamRendererImpl-EpBnVy9J.css → MarkstreamRendererImpl-C6aiJnjl.css} +1 -1
  16. package/dist/assets/MarkstreamRendererImpl-DjC_Y4LS.js +3 -0
  17. package/dist/assets/{MobileDetailNavigation-o54juFXD.js → MobileDetailNavigation-BOZpHdI2.js} +1 -1
  18. package/dist/assets/{MobileResizableSheet-sV9XR-0k.js → MobileResizableSheet-DuAi_epR.js} +1 -1
  19. package/dist/assets/{MobileShareBridge-oqBZ_f6M.js → MobileShareBridge-D1DrqLWf.js} +1 -1
  20. package/dist/assets/MobileTabPageHeader-BT9gWugr.js +2 -0
  21. package/dist/assets/{MultiRunWindow-7W_86vL6.js → MultiRunWindow-C0GYNaUU.js} +1 -1
  22. package/dist/assets/{OnboardingScreen-CnkijSLE.js → OnboardingScreen-CqsI0632.js} +1 -1
  23. package/dist/assets/{OverlayScrollbar-CCtBTJQj.js → OverlayScrollbar-CZD1yU06.js} +1 -1
  24. package/dist/assets/SettingsView-BYO8LY5A.js +29 -0
  25. package/dist/assets/{SettingsWindow-C0HiNvXh.js → SettingsWindow-CM0Ph9WD.js} +1 -1
  26. package/dist/assets/SetupTourDialog-BYlSBPKZ.js +1 -0
  27. package/dist/assets/SetupTourDialog-DrL_4ODI.css +1 -0
  28. package/dist/assets/{TerminalView-y36H_fIe.js → TerminalView-DnyEAShU.js} +1 -1
  29. package/dist/assets/{ToolOutputDialog-BfjBeqGS.js → ToolOutputDialog-BWONfWze.js} +1 -1
  30. package/dist/assets/{VoiceSettings-BONwzGgR.js → VoiceSettings-Ru_0ySgM.js} +2 -2
  31. package/dist/assets/{YuriLogo-BA5FWp-g.js → YuriLogo-CMUoGUHc.js} +1 -1
  32. package/dist/assets/YuriWordmark-DHYo0FlR.js +1 -0
  33. package/dist/assets/{appThemeRegistry-BsLMp3bc.js → appThemeRegistry-BMlAlm0m.js} +1 -1
  34. package/dist/assets/{button-CBjOhOI0.js → button-C-gRcs_2.js} +1 -1
  35. package/dist/assets/{capgoAdapter-DjlyVxy_.js → capgoAdapter-GdNfjwXs.js} +1 -1
  36. package/dist/assets/checkbox-BrJBzET8.js +1 -0
  37. package/dist/assets/{collapsible-B0j5IQ0T.js → collapsible-B7esGYLd.js} +1 -1
  38. package/dist/assets/{context-menu-C4e_bpls.js → context-menu-DWn1nSZC.js} +1 -1
  39. package/dist/assets/desktopHosts-BLU1tGSX.js +1 -0
  40. package/dist/assets/{desktopRelayRestore-AE3_TnQz.js → desktopRelayRestore-2BIIs8mZ.js} +1 -1
  41. package/dist/assets/{diagram-WPmk0Qh6.js → diagram-Bnra5_6g.js} +1 -1
  42. package/dist/assets/{dialog-Dx3IT7dQ.js → dialog-3UseH0hM.js} +1 -1
  43. package/dist/assets/{es-JU--16Gd.js → es-J7a_sZ1u.js} +2 -2
  44. package/dist/assets/{fileMentionTouchSelection-Bizsisaj.js → fileMentionTouchSelection-ByaQJcTS.js} +1 -1
  45. package/dist/assets/{fr-BUZcRuMk.js → fr-BYxUMKWp.js} +2 -2
  46. package/dist/assets/{gitApi-CNgEj6X5.js → gitApi-BdwvoQFb.js} +1 -1
  47. package/dist/assets/historyImportQueries-C8VK9R5_.js +1 -0
  48. package/dist/assets/host-z9PU8q1e.js +1 -0
  49. package/dist/assets/{input-CEJGM-TS.js → input-CmLlZdeD.js} +1 -1
  50. package/dist/assets/insertionBoundaries-BpQ6nLjP.js +1 -0
  51. package/dist/assets/{ja-BwtVLTXD.js → ja-DCdBiJmD.js} +2 -2
  52. package/dist/assets/{ko--sLsRFpA.js → ko-D-Nb_RJY.js} +2 -2
  53. package/dist/assets/main-Dosy2jXg.js +2 -0
  54. package/dist/assets/main-oBh-dk5-.js +169 -0
  55. package/dist/assets/{markdownHeightCache-D6iSNJG2.js → markdownHeightCache-xNkQdlqi.js} +1 -1
  56. package/dist/assets/{mcpQueries-DVSsZeuk.js → mcpQueries-C8zsTQqJ.js} +1 -1
  57. package/dist/assets/miniChat-CI8ryDGT.js +2 -0
  58. package/dist/assets/mobile-e_mTK3dh.js +2 -0
  59. package/dist/assets/{mobileBackNavigation-Dmbf0kw1.js → mobileBackNavigation-sB7c0Pi4.js} +1 -1
  60. package/dist/assets/multirun-DbmgWrsY.js +3 -0
  61. package/dist/assets/{native-config-BaRHaY4y.js → native-config-C_mwkFzh.js} +1 -1
  62. package/dist/assets/{pl-C4_4J5yA.js → pl-AmU4w3aM.js} +2 -2
  63. package/dist/assets/{projectMeta-rrpZdm8D.js → projectMeta-1iUbVl_M.js} +1 -1
  64. package/dist/assets/{pt-BR-DvNC5K1q.js → pt-BR-BI4ft-Fj.js} +2 -2
  65. package/dist/assets/pwa-BdUAGhLt.js +2 -0
  66. package/dist/assets/{queue-abort-optimistic-CSkERbr4.js → queue-abort-optimistic-BwDsaym5.js} +1 -1
  67. package/dist/assets/react-a6PrrNTm.js +1 -0
  68. package/dist/assets/{readiness-BnO7IaZV.js → readiness-D2N0DtZF.js} +1 -1
  69. package/dist/assets/{renderElectronMiniChatApp-Bq3iNKtr.js → renderElectronMiniChatApp-DV0cNt_O.js} +2 -2
  70. package/dist/assets/{renderMobileApp-DiNeMgwp.js → renderMobileApp-b7--jT5z.js} +7 -7
  71. package/dist/assets/{runtimeConfig-BHOiBANF.js → runtimeConfig-DxmJLWUO.js} +1 -1
  72. package/dist/assets/runtimeEndpointReset-jYAYa3Rh.js +149 -0
  73. package/dist/assets/{select-bKMw5JE8.js → select-J8r9SxHt.js} +1 -1
  74. package/dist/assets/sessionLookup-CUQqj2N4.js +1 -0
  75. package/dist/assets/{sortable-tabs-strip-3sKiA7T1.js → sortable-tabs-strip-CiP6RIQa.js} +1 -1
  76. package/dist/assets/{speechSettingsQueries-BDDxw8LP.js → speechSettingsQueries-B3ziGQvb.js} +1 -1
  77. package/dist/assets/src-GtPQ8f4o.css +2 -0
  78. package/dist/assets/{store-X3lU0obe.js → store-OjrIiXCx.js} +5 -5
  79. package/dist/assets/{textarea-EsaDD051.js → textarea-BHgcxJdC.js} +1 -1
  80. package/dist/assets/{tooltip-LLDL5nIZ.js → tooltip-Degmpxnd.js} +1 -1
  81. package/dist/assets/tour-DDI0Zg7l.js +1 -0
  82. package/dist/assets/types-QETHY-S7.js +2 -0
  83. package/dist/assets/{uk-Dvj0JjiC.js → uk-CbdByxxj.js} +2 -2
  84. package/dist/assets/{useAppFontEffects-wIWWE59b.js → useAppFontEffects-LADr3Zl1.js} +53 -53
  85. package/dist/assets/useDesktopWindowControlsLayout-BVNnRHtc.js +1 -0
  86. package/dist/assets/{useDictation-DlEHSN6P.js → useDictation-DFVJpRbm.js} +1 -1
  87. package/dist/assets/{useEffectiveDirectory-DzqpWUC3.js → useEffectiveDirectory-8tqfGdV5.js} +1 -1
  88. package/dist/assets/{useMobileNavigationStore-BWLhXqci.js → useMobileNavigationStore-CLUFv-TZ.js} +13 -13
  89. package/dist/assets/usePluginsStore-B_SIDwsK.js +1 -0
  90. package/dist/assets/useStreamingTextThrottle-VhgGU_te.js +1 -0
  91. package/dist/assets/{useWorkerHighlightedLines-DMS69wKa.js → useWorkerHighlightedLines-jlxakDGs.js} +1 -1
  92. package/dist/assets/{vendor-markstream-react-DfLaSG3W.js → vendor-markstream-react-6zxyQLCD.js} +1 -1
  93. package/dist/assets/{zh-CN-2Y6u8t24.js → zh-CN-ufEVDbXp.js} +2 -2
  94. package/dist/assets/{zh-TW-Z5wVv4Fb.js → zh-TW-DTBlZ4YC.js} +2 -2
  95. package/dist/index.html +8 -8
  96. package/dist/mini-chat.html +8 -8
  97. package/dist/mobile.html +8 -8
  98. package/package.json +1 -1
  99. package/server/index.js +3 -0
  100. package/server/lib/client-auth/pairing.js +2 -0
  101. package/server/lib/client-auth/pairing.test.js +29 -0
  102. package/server/lib/config-sync/DOCUMENTATION.md +8 -4
  103. package/server/lib/config-sync/index.js +1 -1
  104. package/server/lib/config-sync/magpie-auth.js +10 -4
  105. package/server/lib/config-sync/magpie-auth.test.js +4 -0
  106. package/server/lib/config-sync/magpie.js +28 -22
  107. package/server/lib/config-sync/magpie.test.js +127 -2
  108. package/server/lib/config-sync/plugins.js +44 -0
  109. package/server/lib/config-sync/plugins.test.js +64 -0
  110. package/server/lib/config-sync/tar.js +61 -1
  111. package/server/lib/content-search/DOCUMENTATION.md +9 -0
  112. package/server/lib/content-search/routes.js +18 -1
  113. package/server/lib/content-search/routes.test.js +21 -0
  114. package/server/lib/content-search/runtime.js +7 -3
  115. package/server/lib/content-search/runtime.test.js +26 -0
  116. package/server/lib/gui-customization/DOCUMENTATION.md +21 -1
  117. package/server/lib/gui-customization/session-skill.js +2 -2
  118. package/server/lib/gui-customization/session-skill.test.js +3 -1
  119. package/server/lib/gui-customization/skill/SKILL.md +5 -1
  120. package/server/lib/gui-customization/skill/references/global-pages.md +1 -1
  121. package/server/lib/gui-customization/skill/references/gui-api.md +4 -1
  122. package/server/lib/gui-customization/skill/references/icons.md +134 -0
  123. package/server/lib/gui-customization/skill/references/plugin-styles.md +112 -0
  124. package/server/lib/gui-customization/skill/references/ui-surfaces.md +2 -0
  125. package/server/lib/gui-customization/skill/references/work-status.md +110 -0
  126. package/server/lib/history-import/AGENT_CONNECT_LICENSE +21 -0
  127. package/server/lib/history-import/DOCUMENTATION.md +223 -0
  128. package/server/lib/history-import/dev-proxy.integration.test.js +56 -0
  129. package/server/lib/history-import/events.js +322 -0
  130. package/server/lib/history-import/events.test.js +110 -0
  131. package/server/lib/history-import/installations.js +39 -0
  132. package/server/lib/history-import/installations.test.js +24 -0
  133. package/server/lib/history-import/native.js +49 -0
  134. package/server/lib/history-import/native.test.js +42 -0
  135. package/server/lib/history-import/routes.js +48 -0
  136. package/server/lib/history-import/routes.test.js +55 -0
  137. package/server/lib/history-import/service.js +374 -0
  138. package/server/lib/history-import/service.test.js +538 -0
  139. package/server/lib/history-import/settings.js +146 -0
  140. package/server/lib/history-import/settings.test.js +88 -0
  141. package/server/lib/history-import/sources.js +184 -0
  142. package/server/lib/history-import/sources.test.js +190 -0
  143. package/server/lib/history-import/sqlite.js +187 -0
  144. package/server/lib/history-import/store.js +58 -0
  145. package/server/lib/history-import/store.test.js +84 -0
  146. package/server/lib/history-import/targets.js +24 -0
  147. package/server/lib/host-update/DOCUMENTATION.md +6 -0
  148. package/server/lib/host-update/routes.test.js +1 -1
  149. package/server/lib/notifications/native-stream.relay.test.js +1 -0
  150. package/server/lib/opencode/DOCUMENTATION.md +14 -0
  151. package/server/lib/opencode/core-routes.js +1 -0
  152. package/server/lib/opencode/feature-routes-runtime.js +11 -1
  153. package/server/lib/opencode/plugin-routes.test.js +1 -0
  154. package/server/lib/opencode/plugins.js +1 -1
  155. package/server/lib/opencode/plugins.test.js +3 -2
  156. package/server/lib/opencode/proxy.js +29 -4
  157. package/server/lib/opencode/proxy.test.js +85 -1
  158. package/server/lib/opencode/server-utils-runtime.js +2 -0
  159. package/server/lib/opencode/settings-runtime.js +8 -6
  160. package/server/lib/opencode/settings-runtime.test.js +44 -0
  161. package/server/lib/opencode/yuri-routes.js +1 -1
  162. package/server/lib/relay/DOCUMENTATION.md +1 -1
  163. package/server/lib/relay/host-client.js +3 -1
  164. package/server/lib/relay/host-client.test.js +1 -0
  165. package/server/lib/relay/reasoning-projection.e2e.test.ts +1 -0
  166. package/server/lib/relay/relay-server.e2e.test.ts +32 -17
  167. package/server/lib/relay/service.js +2 -0
  168. package/server/lib/relay/tunnel-host.js +26 -1
  169. package/server/lib/relay/tunnel-host.test.js +27 -3
  170. package/server/lib/remote-desktop/runtime.test.js +2 -2
  171. package/server/lib/ui-auth/DOCUMENTATION.md +3 -0
  172. package/server/lib/ui-auth/ui-auth.js +27 -0
  173. package/server/lib/ui-auth/ui-auth.test.js +42 -1
  174. package/server/plugin-gui-proxy.test.js +1 -1
  175. package/dist/assets/AssistantContactStatus-DZGGspw4.js +0 -3
  176. package/dist/assets/Icon-Bh3TaKoN.js +0 -1
  177. package/dist/assets/MarkdownRenderer-CS6Pia5D.js +0 -2
  178. package/dist/assets/MarkdownRendererImpl-Bdwe3qUr.js +0 -10
  179. package/dist/assets/MarkstreamRendererImpl-CCQj9IkL.js +0 -3
  180. package/dist/assets/MobileTabPageHeader-CptcDWNS.js +0 -2
  181. package/dist/assets/SettingsView-CkJpYIMe.js +0 -29
  182. package/dist/assets/SetupTourDialog-BcEbaEO3.js +0 -1
  183. package/dist/assets/SetupTourDialog-CUzqT2sw.css +0 -1
  184. package/dist/assets/YuriWordmark-Cr1vkcue.js +0 -1
  185. package/dist/assets/desktopHosts-CMglnUdS.js +0 -1
  186. package/dist/assets/host-CBfSyi4l.js +0 -1
  187. package/dist/assets/insertionBoundaries-CgYf6gys.js +0 -1
  188. package/dist/assets/main-B8FcBwPM.js +0 -169
  189. package/dist/assets/main-DrqtyqDc.js +0 -2
  190. package/dist/assets/miniChat-CgeCl4RY.js +0 -2
  191. package/dist/assets/mobile-DAhJKHUq.js +0 -2
  192. package/dist/assets/multirun-BbWnHeaY.js +0 -3
  193. package/dist/assets/pwa-Dm_DJEr9.js +0 -2
  194. package/dist/assets/react-Bwr5-XPi.js +0 -1
  195. package/dist/assets/runtimeEndpointReset-DGxT24oE.js +0 -149
  196. package/dist/assets/sessionLookup-DGNxfDsP.js +0 -1
  197. package/dist/assets/src-PTWgTO6W.css +0 -2
  198. package/dist/assets/tour-Db44qwfs.js +0 -1
  199. package/dist/assets/types-Cl7nTpsb.js +0 -2
  200. package/dist/assets/useDesktopWindowControlsLayout-CdUr9mCZ.js +0 -1
  201. package/dist/assets/usePluginsStore-aZl0WTK8.js +0 -1
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,n}from"./runtime-switch-DEZ1K7qW.js";import{ot as r,st as i}from"./vendor-base-ui-CzHs0bHY.js";import{n as a}from"./vendor-react-DlzBev0S.js";import{s as o}from"./vendor-tanstack-react-query-B-Wpqq5J.js";import{a as s}from"./queryRuntime-2dx7jbt9.js";import{i as c}from"./vendor-reactuses-core-DWo5Wn6R.js";import{f as l,r as u,t as d}from"./button-CBjOhOI0.js";import{Oi as f,da as p}from"./useMobileNavigationStore-BWLhXqci.js";import{n as m}from"./Icon-Bh3TaKoN.js";import{a as h,n as g,o as _,t as v}from"./dialog-Dx3IT7dQ.js";import{t as y}from"./YuriLogo-BA5FWp-g.js";import{l as b}from"./select-bKMw5JE8.js";import{n as x}from"./MarkdownRenderer-CS6Pia5D.js";import{n as S}from"./speechSettingsQueries-BDDxw8LP.js";import{n as C,t as w}from"./YuriWordmark-Cr1vkcue.js";import{a as T,c as E,d as D,f as O,g as k,i as A,r as j,t as M}from"./usePluginsStore-aZl0WTK8.js";import{c as ee,i as N,n as P,r as F,s as I,t as te}from"./VoiceSettings-BONwzGgR.js";var L=e(i(),1),R=a(),z=[{name:`Magpie`,spec:`opencode-magpie-plugin`},{name:`Eficy`,spec:`@eficy/opencode2-plugin`},{name:`yee-profile`,spec:`@yee94/opencode-profile`}];function ne(e,t){return e.some(e=>e.parsedKind===`npm`&&I(e.spec).name===t)}async function B(e,t){let n=[];for(let r of new Set(e)){if(!t.current())throw Error(`Runtime changed`);try{let e=await t.list();if(!t.current())throw Error(`Runtime changed`);ne(e,r)||(await t.create(r)).ok||n.push(r)}catch{n.push(r)}}if(!t.current())throw Error(`Runtime changed`);let r=e.filter(e=>!n.includes(e)),i=r.length?await t.active(r):[];if(!t.current())throw Error(`Runtime changed`);return{failed:n,pending:e.filter(e=>!n.includes(e)&&!i.includes(e))}}function re(e,r,i){let a=t(),o=n(),c=()=>!i.aborted&&o===n()&&a===t();return B(e,{current:c,list:async()=>(await s.fetchQuery({...T(r,a),staleTime:0})).entries,create:e=>M.getState().createEntry({spec:e,scope:`user`}),active:async e=>{let t=[];for(let n=0;n<20;n++){if(!c()||(t=await O(r,i),!c()))throw Error(`Runtime changed`);if(s.setQueryData(A(r,a).queryKey,t),e.every(e=>t.some(t=>t.source.kind===`package`&&I(t.source.target).name===e))||n===19)break;await new Promise((e,t)=>{let n=()=>{clearTimeout(r),i.removeEventListener(`abort`,n),t(Error(`Runtime changed`))},r=setTimeout(()=>{i.removeEventListener(`abort`,n),e()},750);i.addEventListener(`abort`,n,{once:!0}),i.aborted&&n()})}return t.flatMap(e=>e.source.kind===`package`&&e.state.kind===`active`?[I(e.source.target).name]:[])}})}var V=r(),H=z.map(e=>e.spec),ie=[`tour.models`,`tour.plugins`,`tour.voice`],ae=[{id:`openai`,name:`OpenAI`},{id:`anthropic`,name:`Anthropic`},{id:`google`,name:`Google Gemini`},{id:`github-copilot`,name:`GitHub Copilot`},{id:`deepseek`,name:`DeepSeek`},{id:`openrouter`,name:`OpenRouter`}];function oe(e){let t=(0,R.c)(48),{index:n,info:r,installed:i,selected:a,onSelect:o,onReadme:s}=e,{t:c}=l(),f=z[n],p=r?.kind===`npm-ok`?r:void 0,h=a&&`yuri-tour-card-selected`,g;t[0]===h?g=t[1]:(g=u(`yuri-tour-plugin yuri-tour-select-card`,h),t[0]=h,t[1]=g);let _;t[2]===a?_=t[3]:(_=a&&(0,V.jsx)(m,{name:`check`,className:`size-5`}),t[2]=a,t[3]=_);let v;t[4]===_?v=t[5]:(v=(0,V.jsx)(`span`,{className:`yuri-tour-card-check`,"aria-hidden":`true`,children:_}),t[4]=_,t[5]=v);let y;t[6]!==o||t[7]!==f.name||t[8]!==a||t[9]!==v?(y=(0,V.jsx)(d,{variant:`ghost`,className:`yuri-tour-card-toggle`,"aria-label":f.name,"aria-pressed":a,onClick:o,children:v}),t[6]=o,t[7]=f.name,t[8]=a,t[9]=v,t[10]=y):y=t[10];let b=p?.icon,x;t[11]!==f.name||t[12]!==b?(x=(0,V.jsx)(ee,{name:f.name,src:b,size:30}),t[11]=f.name,t[12]=b,t[13]=x):x=t[13];let S;t[14]===f.name?S=t[15]:(S=(0,V.jsx)(`h3`,{className:`typography-ui-label font-medium`,children:f.name}),t[14]=f.name,t[15]=S);let C;t[16]===f.spec?C=t[17]:(C=(0,V.jsx)(`p`,{className:`break-all typography-micro text-muted-foreground`,children:f.spec}),t[16]=f.spec,t[17]=C);let w;t[18]!==S||t[19]!==C?(w=(0,V.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[S,C]}),t[18]=S,t[19]=C,t[20]=w):w=t[20];let T;t[21]===p?T=t[22]:(T=p?.latestVersion&&(0,V.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:p.latestVersion}),t[21]=p,t[22]=T);let E;t[23]!==w||t[24]!==T||t[25]!==x?(E=(0,V.jsxs)(`div`,{className:`flex items-start gap-3 pr-10`,children:[x,w,T]}),t[23]=w,t[24]=T,t[25]=x,t[26]=E):E=t[26];let D;t[27]!==r||t[28]!==p?.description||t[29]!==c?(D=p?.description||c(r?`tour.metadataUnavailable`:`common.loading`),t[27]=r,t[28]=p?.description,t[29]=c,t[30]=D):D=t[30];let O;t[31]===D?O=t[32]:(O=(0,V.jsx)(`p`,{className:`flex-1 typography-meta text-muted-foreground`,children:D}),t[31]=D,t[32]=O);let k=!p,A;t[33]!==s||t[34]!==k?(A=(0,V.jsx)(d,{size:`xs`,variant:`ghost`,className:`yuri-tour-card-link`,disabled:k,onClick:s,children:`README`}),t[33]=s,t[34]=k,t[35]=A):A=t[35];let j;t[36]!==i||t[37]!==c?(j=i&&(0,V.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:c(`tour.saved`)}),t[36]=i,t[37]=c,t[38]=j):j=t[38];let M;t[39]!==A||t[40]!==j?(M=(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[A,j]}),t[39]=A,t[40]=j,t[41]=M):M=t[41];let N;return t[42]!==E||t[43]!==O||t[44]!==M||t[45]!==g||t[46]!==y?(N=(0,V.jsxs)(`section`,{className:g,children:[y,E,O,M]}),t[42]=E,t[43]=O,t[44]=M,t[45]=g,t[46]=y,t[47]=N):N=t[47],N}function se(e){let t=(0,R.c)(28),{settings:n,onComplete:r,onBusy:i}=e,{t:a}=l(),o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o={voiceProvider:`volcengine`,sttProvider:`volcengine`,dictationEnabled:!0,showMessageTTSButtons:!0},t[0]=o):o=t[0];let s=P(n,o),u=c(i),d,f;t[1]!==s.saving||t[2]!==u?(d=()=>(u(s.saving),()=>u(!1)),f=[s.saving,u],t[1]=s.saving,t[2]=u,t[3]=d,t[4]=f):(d=t[3],f=t[4]),L.useEffect(d,f);let p;t[5]!==s||t[6]!==r||t[7]!==n.configured?(p=async e=>{e.preventDefault(),!(!n.configured&&!s.draft.apiKey?.trim())&&(await s.save())?.configured&&r()},t[5]=s,t[6]=r,t[7]=n.configured,t[8]=p):p=t[8];let m=p,h;t[9]===m?h=t[10]:(h=e=>void m(e),t[9]=m,t[10]=h);let g;t[11]===a?g=t[12]:(g=a(`settings.voice.volcengine.name`),t[11]=a,t[12]=g);let _,v;t[13]===s?(_=t[14],v=t[15]):(_=(0,V.jsx)(F,{mode:`tts`,form:s}),v=(0,V.jsx)(F,{mode:`asr`,form:s,showCredentials:!1}),t[13]=s,t[14]=_,t[15]=v);let y;t[16]!==g||t[17]!==_||t[18]!==v?(y=(0,V.jsxs)(k,{label:g,children:[_,v]}),t[16]=g,t[17]=_,t[18]=v,t[19]=y):y=t[19];let b;t[20]!==s.draft||t[21]!==n.configured||t[22]!==a?(b=!n.configured&&!s.draft.apiKey?.trim()&&(0,V.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:a(`settings.providers.page.toast.apiKeyRequired`)}),t[20]=s.draft,t[21]=n.configured,t[22]=a,t[23]=b):b=t[23];let x;return t[24]!==b||t[25]!==h||t[26]!==y?(x=(0,V.jsxs)(`form`,{id:`yuri-tour-voice`,onSubmit:h,className:`yuri-settings-section-stack`,children:[y,b]}),t[24]=b,t[25]=h,t[26]=y,t[27]=x):x=t[27],x}function U({runtime:e,onClose:r}){let{t:i}=l(),a=E(),c=C(t=>t.progress[e]?.step??0),[T,O]=L.useState(`magpie`),[k,A]=L.useState(),[M,ee]=L.useState(H.slice(1)),[P,F]=L.useState(`tour`),[I,R]=L.useState(null),[B,U]=L.useState(!1),[ce,W]=L.useState(null),le=n(),G=t(),K=L.useRef(null),q=L.useRef(!1);L.useEffect(()=>{let e=new AbortController;return K.current=e,()=>e.abort()},[]);let J=D(),Y=o({...j(a,H.slice(1),!1,G,!0),enabled:c===1}),X=o({...S(G),enabled:c===2}),ue=J.data?.entries??[],de=e=>{let t=f.getState(),n=e&&t.providers.some(t=>t.id===e);O(`other`),A(n?void 0:e),t.setSelectedProvider(n?e:`__add_provider__`),F(`providers`)},Z=()=>!K.current?.signal.aborted&&le===n()&&G===t(),Q=t=>{F(`tour`),W(null),C.getState().move(e,t)},$=()=>{Z()&&r()},fe=()=>{c===2?$():Q(c+1)},pe=async()=>{if(!(q.current||B||!K.current)){q.current=!0,U(!0),W(null);try{let e=c===0?T===`magpie`?[H[0]]:[]:M;if(e.length){let t=await re(e,a,K.current.signal);if(!Z())return;if(t.failed.length){W(i(`tour.installFailed`,{names:t.failed.join(`, `)}));return}if(t.pending.length){W(i(`tour.activationPending`,{names:t.pending.join(`, `)}));return}}if(c===0){let e=await s.fetchQuery({...p(a,G),staleTime:0});if(!Z())return;if(e.partial||!e.providers.some(e=>Object.keys(e.models).length>0)){W(i(T===`magpie`?`tour.magpieSetup`:`tour.noModels`));return}await f.getState().loadProviders({directory:a,forceRefresh:!0,source:`setup-tour`})}Z()&&fe()}catch{Z()&&W(i(`tour.operationFailed`))}finally{q.current=!1,Z()&&U(!1)}}},me=()=>{I===null?P===`tour`?c>0&&Q(c-1):F(`tour`):R(null)},he=I===null?void 0:Y.data?.[H[I]],ge=he?.kind===`npm-ok`?he.readme:void 0;return(0,V.jsx)(v,{open:!0,onOpenChange:e=>{!e&&!B&&(I!==null||P!==`tour`?me():$())},children:(0,V.jsxs)(g,{className:`yuri-setup-tour yuri-settings-workspace`,showCloseButton:!1,"aria-describedby":void 0,children:[(0,V.jsx)(`div`,{className:`yuri-tour-watermark`,"aria-hidden":`true`,children:(0,V.jsx)(y,{width:440,height:440})}),(0,V.jsx)(h,{children:(0,V.jsxs)(_,{className:`yuri-tour-title`,children:[(0,V.jsx)(`span`,{"aria-hidden":`true`,children:`👋`}),i(`tour.title`).split(`Yuri`).map((e,t)=>(0,V.jsxs)(L.Fragment,{children:[t>0&&(0,V.jsx)(w,{width:`2.05em`}),(0,V.jsx)(`span`,{children:e.trim()})]},t))]})}),(0,V.jsxs)(`div`,{className:`yuri-tour-body`,children:[(0,V.jsx)(`nav`,{className:`yuri-tour-progress`,"aria-label":i(`tour.title`),children:ie.map((e,t)=>(0,V.jsxs)(d,{variant:`ghost`,size:`lg`,disabled:B,"aria-current":c===t?`step`:void 0,onClick:()=>{R(null),Q(t)},children:[(0,V.jsx)(`span`,{className:`yuri-tour-number`,"aria-hidden":`true`,children:String(t+1).padStart(2,`0`)}),(0,V.jsx)(`span`,{children:i(e)})]},e))}),(0,V.jsx)(`div`,{className:u(`yuri-tour-content`,P===`providers`&&I===null&&`yuri-tour-provider-content`),children:(0,V.jsxs)(`fieldset`,{disabled:B,className:`contents`,children:[I===null?P===`providers`?(0,V.jsx)(N,{initialConnectionId:k}):P===`voice`&&X.data?(0,V.jsx)(se,{settings:X.data,onComplete:$,onBusy:U}):P===`asr`||P===`tts`?(0,V.jsx)(te,{section:P}):(0,V.jsxs)(V.Fragment,{children:[c<2&&(c===1&&Y.isError||J.isError)&&(0,V.jsxs)(`div`,{role:`alert`,className:`yuri-tour-feedback`,children:[(0,V.jsx)(`p`,{children:i(`tour.metadataUnavailable`)}),(0,V.jsx)(d,{size:`xs`,onClick:()=>{c===1&&Y.refetch(),J.refetch()},children:i(`settings.plugins.status.retry`)})]}),c===0&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`section`,{className:u(`yuri-tour-magpie yuri-tour-select-card`,T===`magpie`&&`yuri-tour-card-selected`),children:[(0,V.jsx)(d,{variant:`ghost`,className:`yuri-tour-card-toggle`,"aria-label":`Magpie`,"aria-pressed":T===`magpie`,onClick:()=>O(T===`magpie`?`other`:`magpie`),children:(0,V.jsx)(`span`,{className:`yuri-tour-card-check`,"aria-hidden":`true`,children:T===`magpie`&&(0,V.jsx)(m,{name:`check`,className:`size-5`})})}),(0,V.jsxs)(`div`,{className:`flex w-full items-center gap-3 pr-10`,children:[(0,V.jsx)(b,{providerId:`magpie`,alt:`Magpie`,className:`size-8 shrink-0`}),(0,V.jsx)(`span`,{className:`typography-ui-label`,children:`Magpie`}),(0,V.jsx)(`span`,{className:`yuri-tour-recommended`,children:i(`tour.recommended`)})]}),(0,V.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:i(`tour.magpieDescription`)}),(0,V.jsxs)(`a`,{className:`yuri-tour-card-link typography-meta text-muted-foreground underline`,href:`https://usemagpie.ai/docs/start`,target:`_blank`,rel:`noreferrer`,children:[i(`tour.docs`),` ↗`]})]}),(0,V.jsxs)(`div`,{className:`yuri-tour-provider-heading`,children:[(0,V.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:`OpenCode`}),(0,V.jsxs)(`a`,{className:`typography-meta text-muted-foreground underline`,href:`https://opencode.ai/docs/providers/`,target:`_blank`,rel:`noreferrer`,children:[i(`tour.docs`),` ↗`]})]}),(0,V.jsx)(`div`,{className:`yuri-tour-provider-grid`,children:ae.map(e=>(0,V.jsxs)(d,{variant:`ghost`,className:`yuri-tour-provider-choice`,onClick:()=>de(e.id),children:[(0,V.jsx)(b,{providerId:e.id,alt:e.name,className:`size-6 shrink-0`}),(0,V.jsx)(`span`,{children:e.name})]},e.id))}),(0,V.jsxs)(d,{className:`mt-3`,size:`sm`,variant:`ghost`,onClick:()=>de(),children:[i(`tour.otherProvider`),(0,V.jsx)(m,{name:`arrow-right-s`,className:`size-4`})]})]}),c===1&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{className:`yuri-tour-plugins`,children:[1,2].map(e=>(0,V.jsx)(oe,{index:e,info:Y.data?.[H[e]],installed:ne(ue,H[e]),selected:M.includes(H[e]),onSelect:()=>ee(t=>t.includes(H[e])?t.filter(t=>t!==H[e]):[...t,H[e]]),onReadme:()=>R(e)},e))}),(0,V.jsxs)(`a`,{className:`mt-4 inline-block typography-meta text-muted-foreground underline underline-offset-4 hover:text-foreground`,href:`https://opencode.ai/docs/ecosystem/#plugins`,target:`_blank`,rel:`noopener noreferrer`,children:[i(`tour.morePlugins`),` ↗`]})]}),c===2&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{className:`yuri-tour-voice-intro`,children:[(0,V.jsx)(`h2`,{children:i(`tour.voiceHeading`)}),(0,V.jsx)(`p`,{children:i(`tour.voiceIntro`)})]}),(0,V.jsxs)(`div`,{className:`yuri-tour-voice-capabilities`,children:[(0,V.jsxs)(`section`,{children:[(0,V.jsx)(m,{name:`mic`,className:`yuri-tour-voice-icon`}),(0,V.jsx)(`h3`,{children:i(`settings.voice.page.section.speechRecognition`)}),(0,V.jsx)(`p`,{children:i(`tour.dictationDescription`)}),(0,V.jsxs)(`div`,{className:`yuri-tour-voice-services`,children:[(0,V.jsxs)(`span`,{children:[(0,V.jsx)(`img`,{src:`data:image/svg+xml,%3csvg%20height='24'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='24'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eDoubao%3c/title%3e%3cpath%20d='M5.31%2015.756c.172-3.75%201.883-5.999%202.549-6.739-3.26%202.058-5.425%205.658-6.358%208.308v1.12C1.501%2021.513%204.226%2024%207.59%2024a6.59%206.59%200%20002.2-.375c.353-.12.7-.248%201.039-.378.913-.899%201.65-1.91%202.243-2.992-4.877%202.431-7.974.072-7.763-4.5l.002.001z'%20fill='%231E37FC'%3e%3c/path%3e%3cpath%20d='M22.57%2010.283c-1.212-.901-4.109-2.404-7.397-2.8.295%203.792.093%208.766-2.1%2012.773a12.782%2012.782%200%2001-2.244%202.992c3.764-1.448%206.746-3.457%208.596-5.219%202.82-2.683%203.353-5.178%203.361-6.66a2.737%202.737%200%2000-.216-1.084v-.002z'%20fill='%2337E1BE'%3e%3c/path%3e%3cpath%20d='M14.303%201.867C12.955.7%2011.248%200%209.39%200%207.532%200%205.883.677%204.545%201.807%202.791%203.29%201.627%205.557%201.5%208.125v9.201c.932-2.65%203.097-6.25%206.357-8.307.5-.318%201.025-.595%201.569-.829%201.883-.801%203.878-.932%205.746-.706-.222-2.83-.718-5.002-.87-5.617h.001z'%20fill='%23A569FF'%3e%3c/path%3e%3cpath%20d='M17.305%204.961a199.47%20199.47%200%2001-1.08-1.094c-.202-.213-.398-.419-.586-.622l-1.333-1.378c.151.615.648%202.786.869%205.617%203.288.395%206.185%201.898%207.396%202.8-1.306-1.275-3.475-3.487-5.266-5.323z'%20fill='%231E37FC'%3e%3c/path%3e%3c/svg%3e`,alt:``,className:`size-4`}),i(`settings.voice.volcengine.name`)]}),(0,V.jsxs)(`span`,{children:[(0,V.jsx)(m,{name:`computer`}),i(`settings.voice.page.provider.local`)]}),(0,V.jsxs)(`span`,{children:[(0,V.jsx)(m,{name:`server`}),i(`settings.voice.page.provider.server`)]})]}),(0,V.jsxs)(d,{size:`sm`,onClick:()=>F(`asr`),children:[i(`tour.configureInput`),(0,V.jsx)(m,{name:`arrow-right-s`,className:`size-4`})]})]}),(0,V.jsxs)(`section`,{children:[(0,V.jsx)(m,{name:`volume-up`,className:`yuri-tour-voice-icon`}),(0,V.jsx)(`h3`,{children:i(`tour.readAloudTitle`)}),(0,V.jsx)(`p`,{children:i(`tour.readAloudDescription`)}),(0,V.jsxs)(`div`,{className:`yuri-tour-voice-services`,children:[(0,V.jsxs)(`span`,{children:[(0,V.jsx)(`img`,{src:`data:image/svg+xml,%3csvg%20height='24'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='24'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eDoubao%3c/title%3e%3cpath%20d='M5.31%2015.756c.172-3.75%201.883-5.999%202.549-6.739-3.26%202.058-5.425%205.658-6.358%208.308v1.12C1.501%2021.513%204.226%2024%207.59%2024a6.59%206.59%200%20002.2-.375c.353-.12.7-.248%201.039-.378.913-.899%201.65-1.91%202.243-2.992-4.877%202.431-7.974.072-7.763-4.5l.002.001z'%20fill='%231E37FC'%3e%3c/path%3e%3cpath%20d='M22.57%2010.283c-1.212-.901-4.109-2.404-7.397-2.8.295%203.792.093%208.766-2.1%2012.773a12.782%2012.782%200%2001-2.244%202.992c3.764-1.448%206.746-3.457%208.596-5.219%202.82-2.683%203.353-5.178%203.361-6.66a2.737%202.737%200%2000-.216-1.084v-.002z'%20fill='%2337E1BE'%3e%3c/path%3e%3cpath%20d='M14.303%201.867C12.955.7%2011.248%200%209.39%200%207.532%200%205.883.677%204.545%201.807%202.791%203.29%201.627%205.557%201.5%208.125v9.201c.932-2.65%203.097-6.25%206.357-8.307.5-.318%201.025-.595%201.569-.829%201.883-.801%203.878-.932%205.746-.706-.222-2.83-.718-5.002-.87-5.617h.001z'%20fill='%23A569FF'%3e%3c/path%3e%3cpath%20d='M17.305%204.961a199.47%20199.47%200%2001-1.08-1.094c-.202-.213-.398-.419-.586-.622l-1.333-1.378c.151.615.648%202.786.869%205.617%203.288.395%206.185%201.898%207.396%202.8-1.306-1.275-3.475-3.487-5.266-5.323z'%20fill='%231E37FC'%3e%3c/path%3e%3c/svg%3e`,alt:``,className:`size-4`}),i(`settings.voice.volcengine.name`)]}),(0,V.jsxs)(`span`,{children:[(0,V.jsx)(b,{providerId:`openai`,alt:`OpenAI`,className:`size-4`}),`OpenAI`]}),(0,V.jsxs)(`span`,{children:[(0,V.jsx)(m,{name:`computer`}),i(`settings.voice.page.provider.browser`)]}),(0,V.jsxs)(`span`,{children:[(0,V.jsx)(m,{name:`cloud`}),i(`settings.voice.page.provider.custom`)]})]}),(0,V.jsxs)(d,{size:`sm`,onClick:()=>F(`tts`),children:[i(`tour.configureReadAloud`),(0,V.jsx)(m,{name:`arrow-right-s`,className:`size-4`})]})]})]}),(0,V.jsxs)(`section`,{className:`yuri-tour-voice-recommendation`,children:[(0,V.jsx)(`img`,{src:`data:image/svg+xml,%3csvg%20height='24'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='24'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eDoubao%3c/title%3e%3cpath%20d='M5.31%2015.756c.172-3.75%201.883-5.999%202.549-6.739-3.26%202.058-5.425%205.658-6.358%208.308v1.12C1.501%2021.513%204.226%2024%207.59%2024a6.59%206.59%200%20002.2-.375c.353-.12.7-.248%201.039-.378.913-.899%201.65-1.91%202.243-2.992-4.877%202.431-7.974.072-7.763-4.5l.002.001z'%20fill='%231E37FC'%3e%3c/path%3e%3cpath%20d='M22.57%2010.283c-1.212-.901-4.109-2.404-7.397-2.8.295%203.792.093%208.766-2.1%2012.773a12.782%2012.782%200%2001-2.244%202.992c3.764-1.448%206.746-3.457%208.596-5.219%202.82-2.683%203.353-5.178%203.361-6.66a2.737%202.737%200%2000-.216-1.084v-.002z'%20fill='%2337E1BE'%3e%3c/path%3e%3cpath%20d='M14.303%201.867C12.955.7%2011.248%200%209.39%200%207.532%200%205.883.677%204.545%201.807%202.791%203.29%201.627%205.557%201.5%208.125v9.201c.932-2.65%203.097-6.25%206.357-8.307.5-.318%201.025-.595%201.569-.829%201.883-.801%203.878-.932%205.746-.706-.222-2.83-.718-5.002-.87-5.617h.001z'%20fill='%23A569FF'%3e%3c/path%3e%3cpath%20d='M17.305%204.961a199.47%20199.47%200%2001-1.08-1.094c-.202-.213-.398-.419-.586-.622l-1.333-1.378c.151.615.648%202.786.869%205.617%203.288.395%206.185%201.898%207.396%202.8-1.306-1.275-3.475-3.487-5.266-5.323z'%20fill='%231E37FC'%3e%3c/path%3e%3c/svg%3e`,alt:``,className:`size-6 shrink-0`}),(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,V.jsx)(`h3`,{children:i(`settings.voice.volcengine.name`)}),(0,V.jsx)(`span`,{className:`yuri-tour-recommended`,children:i(`tour.recommended`)})]}),(0,V.jsx)(`p`,{children:i(`tour.voiceAllowance`)})]}),(0,V.jsx)(d,{disabled:!X.data,size:`sm`,onClick:()=>F(`voice`),children:i(`tour.configureVoice`)})]}),X.isError&&(0,V.jsxs)(`div`,{role:`alert`,className:`yuri-tour-feedback`,children:[(0,V.jsx)(`p`,{children:i(`settings.voice.volcengine.loadFailed`)}),(0,V.jsx)(d,{size:`xs`,onClick:()=>void X.refetch(),children:i(`settings.voice.volcengine.retry`)})]})]})]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`h3`,{className:`typography-ui-label mb-4`,children:[z[I].name,` · README`]}),ge?(0,V.jsx)(x,{content:ge,enableFileReferences:!1}):(0,V.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:i(`tour.metadataUnavailable`)})]}),ce&&I===null&&(0,V.jsx)(`p`,{role:`alert`,className:`yuri-tour-feedback`,children:ce})]})})]}),(0,V.jsxs)(`footer`,{className:`yuri-tour-footer`,children:[(P!==`tour`||I!==null)&&(0,V.jsx)(d,{variant:`ghost`,size:`sm`,disabled:B,onClick:me,children:i(`onboarding.common.actions.back`)}),I===null&&(0,V.jsxs)(`div`,{className:`ml-auto flex flex-wrap justify-end gap-2`,children:[(0,V.jsx)(d,{variant:`ghost`,size:`sm`,disabled:B,onClick:fe,children:i(`tour.later`)}),c===2?(0,V.jsx)(d,{size:`sm`,disabled:B,type:P===`voice`?`submit`:`button`,form:P===`voice`?`yuri-tour-voice`:void 0,onClick:P===`voice`?void 0:$,children:i(P===`voice`?`settings.common.actions.saveChanges`:`tour.finish`)}):(0,V.jsxs)(d,{size:`sm`,disabled:B||!J.data||J.isError,"aria-busy":B,onClick:()=>void pe(),children:[B&&(0,V.jsx)(m,{name:`loader-4`,className:`size-3 animate-spin`}),i(`tour.continue`)]})]})]})]})})}export{U as SetupTourDialog};
@@ -1 +0,0 @@
1
- .yuri-setup-tour[data-slot=dialog-content]{isolation:isolate;gap:18px;width:min(980px,100vw - 32px);max-width:980px;height:auto;min-height:min(640px,100dvh - 32px);max-height:calc(100dvh - 32px);padding:26px 28px 20px;overflow:hidden}.yuri-tour-watermark{aspect-ratio:1;z-index:-1;pointer-events:none;-webkit-user-select:none;user-select:none;opacity:.12;width:min(440px,55%);color:var(--surface-foreground);position:absolute;top:-60px;right:-90px;-webkit-mask-image:linear-gradient(225deg,#000 10%,#0000 76%);mask-image:linear-gradient(225deg,#000 10%,#0000 76%)}.yuri-tour-watermark>[data-yuri-logo]{width:100%;height:100%}.yuri-tour-watermark svg path{fill:currentColor}.yuri-tour-title[data-slot=dialog-title]{font-size:calc(24 * var(--dpt));text-align:left;flex-wrap:wrap;justify-content:flex-start;align-items:center;gap:.15em .2em;line-height:1.4;display:flex}.yuri-setup-tour>[data-slot=dialog-header]{margin-bottom:16px}.yuri-tour-body{flex:1;grid-template-columns:150px minmax(0,1fr);gap:24px;min-height:0;display:grid}.yuri-tour-progress{flex-direction:column;align-items:stretch;gap:24px;display:flex}.yuri-tour-progress>button{min-width:0;color:var(--surface-muted-foreground);justify-content:flex-start;gap:14px;padding-inline:8px;position:relative}.yuri-tour-progress>button[aria-current=step]{color:var(--surface-foreground)}.yuri-tour-progress>button:after{content:"";background:var(--interactive-border);height:1px;position:absolute;bottom:-6px;left:8px;right:8px}.yuri-tour-progress>button[aria-current=step]:after{background:var(--surface-foreground)}.yuri-tour-number{font-size:calc(32 * var(--dpt));letter-spacing:-.05em;font-variant-numeric:tabular-nums;opacity:.6;flex-shrink:0;font-weight:300;line-height:1}.yuri-tour-progress>button[aria-current=step] .yuri-tour-number{opacity:1}.yuri-tour-content{scrollbar-gutter:stable;flex:1;min-height:0;overflow:auto}.yuri-tour-provider-content{scrollbar-gutter:auto;overflow:hidden}.yuri-tour-provider-content .yuri-settings-section-stack.mx-auto{max-width:none;padding:0}.yuri-tour-plugins{grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;display:grid}.yuri-tour-magpie{border:1px solid var(--interactive-border);border-radius:10px;flex-direction:column;align-items:flex-start;gap:14px;padding:18px;display:flex}.yuri-tour-recommended{background:var(--interactive-selection);color:var(--interactive-selection-foreground);font-size:calc(11 * var(--dpt));border-radius:6px;padding:2px 6px}.yuri-tour-provider-heading{justify-content:space-between;align-items:center;margin:24px 0 12px;display:flex}.yuri-tour-provider-grid{grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;display:grid}.yuri-tour-provider-choice{border:1px solid var(--interactive-border);white-space:normal;text-align:left;justify-content:flex-start}.yuri-tour-plugin{border:1px solid var(--interactive-border);border-radius:10px;flex-direction:column;gap:14px;padding:16px;display:flex}.yuri-tour-select-card{isolation:isolate;position:relative}.yuri-tour-select-card>:not(.yuri-tour-card-toggle){pointer-events:none}.yuri-tour-select-card .yuri-tour-card-link{z-index:1;pointer-events:auto;position:relative}.yuri-tour-card-toggle{z-index:-1;border-radius:inherit;width:100%;height:100%;padding:0;position:absolute;inset:0}.yuri-tour-card-toggle:hover,.yuri-tour-card-toggle:active{box-shadow:none;background:0 0}.yuri-tour-select-card:has(.yuri-tour-card-toggle:hover){border-color:var(--interactive-selection-foreground)}.yuri-tour-card-selected{border-color:var(--interactive-selection-foreground);box-shadow:inset 0 0 0 1px var(--interactive-selection-foreground);background:color-mix(in srgb, var(--interactive-selection) 35%, var(--surface-background))}.yuri-tour-card-check{border:1px solid var(--interactive-border);width:28px;height:28px;color:var(--interactive-selection-foreground);border-radius:50%;place-items:center;display:grid;position:absolute;top:16px;right:16px}.yuri-tour-card-selected .yuri-tour-card-check{border-color:var(--interactive-selection-foreground);background:var(--interactive-selection)}.yuri-tour-note{font-size:calc(12 * var(--dpt));color:var(--surface-muted-foreground);margin:14px 0;line-height:1.8}.yuri-tour-feedback{font-size:calc(12 * var(--dpt));color:var(--surface-muted-foreground);overflow-wrap:anywhere;margin-top:12px;line-height:1.7}.yuri-tour-footer{flex-shrink:0;justify-content:space-between;align-items:center;gap:8px;display:flex}.yuri-tour-voice-intro{padding:8px 0 28px}.yuri-tour-voice-intro h2{letter-spacing:-.03em;font-size:clamp(24px,3vw,32px);font-weight:500;line-height:1.35}.yuri-tour-voice-intro p{max-width:54ch;color:var(--surface-muted-foreground);font-size:calc(13 * var(--dpt));margin-top:12px;line-height:1.8}.yuri-tour-voice-capabilities{grid-template-columns:repeat(2,minmax(0,1fr));gap:28px;display:grid}.yuri-tour-voice-capabilities>section{border-top:1px solid var(--interactive-border);flex-direction:column;align-items:flex-start;gap:12px;padding-block:20px;display:flex}.yuri-tour-voice-icon{width:32px;height:32px;color:var(--surface-foreground);margin-bottom:8px}.yuri-tour-voice-capabilities h3{font-size:calc(18 * var(--dpt));font-weight:500}.yuri-tour-voice-capabilities p{font-size:calc(13 * var(--dpt));color:var(--surface-muted-foreground);line-height:1.7}.yuri-tour-voice-services{color:var(--surface-muted-foreground);font-size:calc(11 * var(--dpt));flex-wrap:wrap;flex:1;gap:8px 14px;margin:4px 0 12px;display:flex}.yuri-tour-voice-services>span{align-items:center;gap:6px;display:inline-flex}.yuri-tour-voice-services svg{width:14px;height:14px}.yuri-tour-voice-recommendation{background:var(--surface-muted);border-radius:10px;align-items:center;gap:16px;margin-top:16px;padding:18px;display:flex}.yuri-tour-voice-recommendation>div{flex:1;min-width:0}.yuri-tour-voice-recommendation h3{font-size:calc(13 * var(--dpt));font-weight:500}.yuri-tour-voice-recommendation p{color:var(--surface-muted-foreground);font-size:calc(12 * var(--dpt));margin-top:6px;line-height:1.7}@media (width<=600px){.yuri-tour-voice-capabilities{grid-template-columns:1fr;gap:8px}.yuri-tour-voice-recommendation{flex-wrap:wrap}.yuri-setup-tour[data-slot=dialog-content]{gap:16px;padding:22px 18px 18px}.yuri-tour-plugins{grid-template-columns:1fr}.yuri-tour-provider-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.yuri-tour-body{grid-template-rows:auto minmax(0,1fr);grid-template-columns:minmax(0,1fr);gap:16px}.yuri-tour-progress{flex-direction:row;gap:8px}.yuri-tour-progress>button{font-size:calc(11 * var(--dpt));flex:1;gap:6px;padding-inline:4px}.yuri-tour-number{font-size:calc(24 * var(--dpt))}}
@@ -1 +0,0 @@
1
- import"./rolldown-runtime-hePW80VL.js";import{c as e,s as t}from"./runtime-switch-DEZ1K7qW.js";import{a as n,i as r}from"./vendor-zustand-vDaAPGfl.js";import{ot as i,st as a}from"./vendor-base-ui-CzHs0bHY.js";import{Mt as o}from"./bootstrap-C8paoQ0j.js";import{n as s}from"./vendor-react-DlzBev0S.js";var c=n()(r(e=>({progress:{},openedRuntime:null,open:t=>e(e=>({openedRuntime:t,progress:{...e.progress,[t]:e.progress[t]??{step:0,dismissed:!1}}})),move:(t,n)=>e(e=>({progress:{...e.progress,[t]:{step:n,dismissed:e.progress[t]?.dismissed??!1}}})),dismiss:t=>e(e=>({openedRuntime:e.openedRuntime===t?null:e.openedRuntime,progress:{...e.progress,[t]:{step:e.progress[t]?.step??0,dismissed:!0}}}))}),{name:`yuri-setup-tour`,storage:o(),partialize:e=>({progress:e.progress}),merge:(e,t)=>{let n=e,r={};if(n?.progress&&typeof n.progress==`object`)for(let[e,t]of Object.entries(n.progress))t&&[0,1,2].includes(t.step)&&typeof t.dismissed==`boolean`&&(r[e]={step:t.step,dismissed:t.dismissed});return{...t,progress:r,openedRuntime:null}}}));e(e=>{t(e)&&c.persist.rehydrate()}),a();var l=s(),u=`/assets/yuri-wordmark-DSJqXYVo.svg`,d=i();function f(e){let t=(0,l.c)(5),{className:n,width:r}=e,i=n===void 0?``:n,a=r===void 0?112:r,o=`inline-block shrink-0 ${i}`,s;t[0]===a?s=t[1]:(s={width:a,aspectRatio:`626.723 / 280`,backgroundColor:`currentColor`,mask:`url("${u}") center / contain no-repeat`,WebkitMask:`url("${u}") center / contain no-repeat`},t[0]=a,t[1]=s);let c;return t[2]!==o||t[3]!==s?(c=(0,d.jsx)(`span`,{role:`img`,"aria-label":`Yuri`,className:o,style:s}),t[2]=o,t[3]=s,t[4]=c):c=t[4],c}export{c as n,f as t};
@@ -1 +0,0 @@
1
- import{E as e}from"./runtime-auth-DBn9yahL.js";import{v as t,y as n}from"./desktop-BAmoc_34.js";var r=e=>typeof e==`object`&&!!e,i=e=>e.trim().toLowerCase()===`authorization`,a=e=>{if(!r(e))return;let t={};for(let[n,r]of Object.entries(e)){let e=n.trim(),a=typeof r==`string`?r.trim():``;!e||!a||/[\r\n:]/.test(e)||/[\r\n]/.test(a)||i(e)||(t[e]=a)}return Object.keys(t).length>0?t:void 0},o=`connect-link`,s=(e,t)=>e.source===`connect-link`||e.relay?!0:t.has(e.id),c=(e,t)=>!t.has(e.id)&&s(e,t),l=e=>`relay://${e}`,u=e=>{if(!r(e))return null;let t=g(e,`relayUrl`)||g(e,`relay_url`),n=g(e,`serverId`)||g(e,`server_id`),i=e.hostEncPubJwk??e.host_enc_pub_jwk;return!t||!n||!r(i)?null:{relayUrl:t,serverId:n,hostEncPubJwk:i}},d=/^(t|.*(?:token|auth|secret|api).*)$/i,f=e=>{let t=e.trim();if(!t)return null;try{let e=new URL(t);return e.protocol!==`http:`&&e.protocol!==`https:`?null:t.split(`#`)[0]||null}catch{return null}},p=e=>{let t=f(e);if(!t)return null;try{let e=new URL(t);if((e.pathname.replace(/\/+$/,``)||`/`)===`/connect`&&e.searchParams.has(`t`))return{persistedUrl:e.origin,redeemUrl:e.toString(),kind:`tunnel-connect-link`}}catch{return null}return{persistedUrl:t,redeemUrl:null,kind:`normal-host`}},m=e=>{let t=f(e);if(!t)return e;try{let e=new URL(t);(e.username||e.password)&&(e.username=``,e.password=``);let n=Array.from(new Set(Array.from(e.searchParams.keys())));for(let t of n)d.test(t)&&e.searchParams.set(t,`[REDACTED]`);return e.toString()}catch{return t}},h=(e,t)=>{let n=f(e),r=f(t);if(!n||!r)return!1;try{let e=new URL(n),t=new URL(r);if(e.origin!==t.origin||t.search&&e.search!==t.search)return!1;let i=t.pathname.length>1?t.pathname.replace(/\/+$/,``):t.pathname,a=e.pathname.length>1?e.pathname.replace(/\/+$/,``):e.pathname;return i===`/`||a===i||a.startsWith(`${i}/`)}catch{return!1}},g=(e,t)=>{let n=e[t];return typeof n==`string`?n:null},_=(e,t)=>{let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:null},v=e=>{if(!r(e))return null;let t=g(e,`id`),n=g(e,`label`),i=g(e,`url`),s=g(e,`apiUrl`)||g(e,`api_url`),c=g(e,`clientToken`)||g(e,`client_token`),l=a(e.requestHeaders),d=u(e.relay),f=g(e,`source`)===`connect-link`?o:void 0;return!t||!n||!i&&!d?null:{id:t,label:n,url:i||``,...s?{apiUrl:s}:{},...c?{clientToken:c}:{},...l?{requestHeaders:l}:{},...d?{relay:d}:{},...f?{source:f}:{}}},y=e=>f(e.apiUrl||e.url)||e.apiUrl||e.url,b=()=>t()?(e,t)=>n(e,t):null,x=async()=>{let e=b();if(!e)return{hosts:[],defaultHostId:null,initialHostChoiceCompleted:!1};let t=await e(`desktop_hosts_get`);if(!r(t))return{hosts:[],defaultHostId:null,initialHostChoiceCompleted:!1};let n=t.hosts;return{hosts:Array.isArray(n)?n.map(v).filter(e=>!!e):[],defaultHostId:g(t,`defaultHostId`)||g(t,`default_host_id`)||g(t,`defaultHostID`),initialHostChoiceCompleted:t.initialHostChoiceCompleted===!0||t.initial_host_choice_completed===!0,localOrigin:g(t,`localOrigin`)||g(t,`local_origin`)}},S=async e=>{let t=b();if(!t)return;let n={hosts:e.hosts,defaultHostId:e.defaultHostId,initialHostChoiceCompleted:e.initialHostChoiceCompleted};e.localClientToken!==void 0&&(n.localClientToken=e.localClientToken),await t(`desktop_hosts_set`,{input:n})},C=async e=>{let t=b();if(!t)throw Error(`Desktop host preparation is unavailable`);let n=v(await t(`desktop_host_prepare`,{hostId:e.id}));if(!n||n.id!==e.id)throw Error(`Invalid prepared desktop host`);return n},w=async()=>{let e=b();if(!e)throw Error(`Local host settings are unavailable`);await e(`desktop_open_local_host_settings`)},T=async()=>{let e=b();if(!e)return``;let t=await e(`desktop_local_client_token_get`).catch(()=>null);return typeof t==`string`?t.trim():``},E=async()=>{let e=b();if(!e)return``;let t=await e(`desktop_install_id_get`).catch(()=>null);return typeof t==`string`?t.trim():``},D=8e3,O=async(t,n)=>{let r=e({relayUrl:t.relayUrl,serverId:t.serverId,hostEncPubJwk:t.hostEncPubJwk}),i=Date.now(),a=!1,o;try{let e=await Promise.race([(async()=>{let e=await r.fetch(`/auth/session`,{headers:n?.clientToken?{Authorization:`Bearer ${n.clientToken}`}:{}});return{response:e,payload:e.ok?await e.json().catch(()=>null):null}})(),new Promise(e=>{o=setTimeout(()=>e(null),D)})]),t=e?.response;return t?.status===401||t?.status===403?{status:`auth`,latencyMs:Math.max(0,Date.now()-i)}:t?.ok?e?.payload?.authenticated===!0?(a=n?.keepTunnel===!0,{status:`ok`,latencyMs:Math.max(0,Date.now()-i),...a?{tunnel:r}:{}}):{status:`auth`,latencyMs:Math.max(0,Date.now()-i)}:{status:`unreachable`,latencyMs:0}}catch{return{status:`unreachable`,latencyMs:0}}finally{o!==void 0&&clearTimeout(o),a||r.close()}},k=async(e,t)=>{let n=b();if(!n)return{status:`unreachable`,latencyMs:0};let i=await n(`desktop_host_probe`,{url:e,clientToken:t?.clientToken||void 0,requestHeaders:t?.requestHeaders||void 0,expectedServerId:t?.expectedServerId||void 0});if(!r(i))return{status:`unreachable`,latencyMs:0};let a=i.status;return{status:a===`ok`||a===`auth`||a===`update-recommended`||a===`incompatible`||a===`wrong-service`||a===`unreachable`?a:`unreachable`,latencyMs:_(i,`latencyMs`)??_(i,`latency_ms`)??0}},A=async(e,t)=>{let n=b();n&&await n(`desktop_new_window_at_url`,{url:e,clientToken:t?.clientToken||void 0,requestHeaders:t?.requestHeaders||void 0})},j=async e=>{let t=b();t&&await t(`desktop_new_window_for_host`,{hostId:e})};export{m as _,E as a,A as c,y as d,c as f,O as g,f as h,S as i,j as l,h as m,k as n,T as o,s as p,x as r,w as s,o as t,C as u,l as v,p as y};
@@ -1 +0,0 @@
1
- import{C as e,D as t,I as n,L as r,M as i,O as a,P as o,S as s,T as c,_ as l,a as u,b as d,c as f,j as p,n as m,o as h,r as g,s as _,t as v,v as y,w as b,y as x}from"./vendor-opencode-client-cQ47ywrT.js";import{i as ee}from"./vendor-tanstack-query-core-Y_YoRHtC.js";import{n as te,r as ne}from"./fileQueries-C2Rs6TPz.js";import{o as re}from"./path-utils-jGozTg9d.js";import{a as ie,n as ae}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{n as oe}from"./pathNormalization-ewtPqJWn.js";import{n as se}from"./platform-sEg2IOLZ.js";import{Dt as S,ht as C,mt as w,y as T}from"./vendor-effect-X1Hqc7ba.js";import{t as E}from"./native-errors-06if6eu-.js";import{a as ce,i as le,n as ue,o as de,r as fe}from"./appearance--vFosLNi.js";import{i as pe,o as me}from"./fileReferenceParser-1HHDBUum.js";import{n as he,t as ge}from"./vendor-solid-js-D98iXT7C.js";import{a as _e,c as ve,d as D,f as O,g as k,h as A,i as j,l as M,m as N,n as P,o as F,p as I,r as ye,s as be,t as xe,u as Se}from"./vendor-opencode-plugin-BmdTE4Te.js";var L={"@opencode/plugin/gui":F,"@opencode/plugin/gui/main":F,"@opencode/plugin/gui/file":_e,"@opencode/plugin/gui/review":j,"@opencode/plugin/gui/browser":ye,"@opencode/plugin/rpc":xe,"@opencode/schema/rpc":P,"@opencode/client":g,"@opencode/client/effect":m,"@opencode/client/solid":v,effect:T,"solid-js":o,"solid-js/web":he,"solid-js/store":_},Ce=new Set(`assert assert/strict async_hooks buffer child_process cluster console constants crypto dgram diagnostics_channel dns dns/promises domain events fs fs/promises http http2 https inspector inspector/promises module net os path path/posix path/win32 perf_hooks process punycode querystring readline readline/promises repl stream stream/consumers stream/promises stream/web string_decoder sys timers timers/promises tls trace_events tty url util util/types v8 vm wasi worker_threads zlib`.split(` `));function we(){let e=new Proxy(function(){},{get:(t,n)=>n===`then`?void 0:n===Symbol.hasInstance?()=>!1:n===Symbol.toPrimitive||n===`toString`?()=>`[main-only module]`:e,apply:()=>e,construct:()=>e,set:()=>!0});return e}function Te(e,t){if(e.length>16777216)throw Error(`GUI bundle exceeds 16 MiB`);let n={exports:{}};Function(`require`,`module`,`exports`,e)(e=>{if(Object.hasOwn(L,e))return L[e];if(e===`electron`||e.startsWith(`node:`)||Ce.has(e))return we();throw Error(`Unsupported GUI shared module: ${e}`)},n,n.exports);let r=n.exports,i=r&&typeof r==`object`&&`default`in r?r.default:r;if(!i||typeof i!=`object`)throw Error(`GUI bundle must default-export Plugin.define`);if((!(`setup`in i)||typeof i.setup!=`function`)&&!(t&&`main`in i&&typeof i.main==`function`))throw new E(`GUI_PLUGIN_UNSUPPORTED`,`This host requires a window setup; main-only plugins are unsupported`);if(`os`in i&&i.os!==void 0){if(!t)throw new E(`GUI_PLUGIN_UNSUPPORTED`,`OS-restricted plugins require the native GUI host`);if(!Array.isArray(i.os)||!i.os.includes(t))throw new E(`GUI_PLUGIN_UNSUPPORTED`,`GUI plugin is unavailable on this OS`)}if(`main`in i&&i.main!==void 0&&typeof i.main!=`function`)throw Error(`Invalid GUI main entry`);if(`stores`in i&&i.stores!==void 0){if(!i.stores||typeof i.stores!=`object`||Array.isArray(i.stores))throw Error(`Invalid GUI stores`);for(let e of Object.values(i.stores))if(!e||typeof e!=`object`||!(`schema`in e)||!S(e.schema)||!(`scope`in e)||![`global`,`session`].includes(String(e.scope))||!(`initial`in e))throw Error(`Invalid GUI store declaration`)}if(`i18n`in i&&i.i18n!==void 0){if(!i.i18n||typeof i.i18n!=`object`||Array.isArray(i.i18n))throw Error(`Invalid GUI locale catalog`);for(let e of Object.values(i.i18n))if(!e||typeof e!=`object`||Array.isArray(e)||Object.values(e).some(e=>typeof e!=`string`))throw Error(`GUI locales must be inline string dictionaries`)}return i}function R(e){let t=e;if(/^file:/i.test(t)){let e=new URL(t);t=`${e.hostname&&e.hostname!==`localhost`?`//${e.hostname}`:``}${decodeURIComponent(e.pathname)}`,/^\/[a-z]:\//i.test(t)&&(t=t.slice(1))}let n=oe(t)??``;return n===`.`?``:n}var z=e=>/^(?:\/|[a-z]:\/)/i.test(e),B=()=>{throw Error(`Unsupported GUI file API: tree`)},V=class extends Error{},H=e=>new TextEncoder().encode(e).byteLength,Ee=class{files;query;transport;root;api;ended=!1;states=new Map;inflight=new Map;watches=new Map;apiLeases=new Map;registeredOwners=new WeakSet;endedOwners=new WeakSet;leaseCount=0;rerun=new Set;selections=new Map;scrolls=new Map;subscriptions=new Map;constructor(e,t,n,r){this.files=e,this.query=t,this.transport=n,this.root=r,this.root=R(r),this.api={root:this.root,ready:()=>!this.ended,resolve:e=>this.resolve(e),absolute:z,get:e=>{let t=this.track(e,`file`);return this.states.get(t)},missing:e=>{let t=this.track(e,`missing`);return this.states.get(t)?.notFound===!0},sync:(e,t)=>{let n=a();return this.ended||n&&this.endedOwners.has(n)?Promise.resolve():(this.acquireApiLease(e),this.sync(e,t?.force))},unwatch:e=>this.releaseApiLease(a(),this.resolve(e)),exists:async e=>{try{if(this.files.statFile)return(await this.query.fetchQuery(this.statOptions(e))).isFile;let t=this.full(e);return(await this.files.listDirectory(t.slice(0,t.lastIndexOf(`/`)))).entries.some(e=>!e.isDirectory&&R(e.path)===t)}catch{return!1}},search:async(e,t)=>{if(t?.kind===`any`)throw Error(`Unsupported GUI file search: directories`);t?.signal?.throwIfAborted();let r=await this.query.fetchQuery({queryKey:[`gui-plugin-files`,n,this.root,`search`,e,t?.limit],gcTime:3e4,queryFn:async({signal:n})=>(n.throwIfAborted(),this.files.search({directory:this.root,query:e,maxResults:t?.limit??100}))});if(t?.signal?.throwIfAborted(),this.ended)throw new DOMException(`GUI file model was disposed`,`AbortError`);return r.map(e=>this.resolve(e.path))},selection:{get:e=>this.selections.get(this.track(e,`selection`)),set:(e,t)=>{let n=this.resolve(e),r=this.selections.get(n);r===t||r&&t&&r.start===t.start&&r.end===t.end&&r.side===t.side&&r.endSide===t.endSide||(this.selections.set(n,t),this.trim(this.selections,`selection`),this.changed(n,`selection`))}},scroll:{get:e=>this.scrolls.get(this.track(e,`scroll`))??{},set:(e,t)=>{let n=this.resolve(e),r=this.scrolls.get(n),i={...r,...t};(r?.top!==i.top||r?.left!==i.left)&&(this.scrolls.set(n,i),this.trim(this.scrolls,`scroll`),this.changed(n,`scroll`))}},tree:{list:B,state:B,sync:B,expand:B,collapse:B}}}resolve(e){let t=R(e);if(!z(t))return t;if(t===this.root)return``;let n=this.root.endsWith(`/`)?this.root:`${this.root}/`;return t.startsWith(n)?t.slice(n.length):t}full(e){let t=this.resolve(e);return z(t)?t:R(`${this.root}/${t}`)}input(e){return{scopeDirectory:this.root,path:this.full(e),options:{directory:this.root}}}statOptions(e){return{...ne(this.files,this.input(e),this.transport),gcTime:3e4}}track(e,n){let r=this.resolve(e),a=t();if(!a||this.ended)return r;let o=`${n}:${r}`,s=this.subscriptions.get(o);s||(s={revision:c(0),listeners:new Set},this.subscriptions.set(o,s));let l=s;return l.listeners.has(a)||(l.listeners.add(a),i(a,()=>p(()=>{l.listeners.delete(a),!l.listeners.size&&this.subscriptions.get(o)===l&&this.subscriptions.delete(o)}))),l.revision[0](),r}changed(e,t){this.ended||this.subscriptions.get(`${t}:${e}`)?.revision[1](e=>e+1)}trim(e,t){for(;e.size>64;){let n=e.keys().next().value;e.delete(n),this.changed(n,t)}}setState(e,t){let n=this.states.get(e);n?.content?.content===t.content?.content&&n?.content?.type===t.content?.type&&(t.content=n?.content),!(n&&n.loaded===t.loaded&&n.loading===t.loading&&n.error===t.error&&n.notFound===t.notFound&&n.content===t.content)&&(this.states.set(e,t),l(()=>{this.changed(e,`file`),n?.notFound===!0!=(t.notFound===!0)&&this.changed(e,`missing`)}))}acquireApiLease(e){let t=a();if(this.ended||t&&this.endedOwners.has(t)||!this.files.statFile)return;let n=this.resolve(e),r=this.apiLeases.get(t);if(r?.has(n))return;if(this.leaseCount>=256)throw Error(`GUI file consumer limit exceeded`);let i=this.watch(n);r||(r=new Map,this.apiLeases.set(t,r)),r.set(n,i),this.leaseCount++,t&&!this.registeredOwners.has(t)&&(this.registeredOwners.add(t),p(()=>{`fn`in t||this.endedOwners.add(t),this.registeredOwners.delete(t);for(let e of[...this.apiLeases.get(t)?.keys()??[]])this.releaseApiLease(t,e)}))}releaseApiLease(e,t){let n=this.apiLeases.get(e),r=n?.get(t);r&&(n.delete(t),this.leaseCount--,n.size||this.apiLeases.delete(e),r())}reserve(e){if(!this.states.has(e)){if(this.states.size>=64){let e=[...this.states.keys()].find(e=>!this.watches.has(e)&&!this.inflight.has(e));if(!e)throw Error(`GUI file cache limit exceeded`);let t=this.states.get(e)?.notFound===!0;this.states.delete(e),l(()=>{this.changed(e,`file`),t&&this.changed(e,`missing`)})}this.states.set(e,{path:e,name:e.split(`/`).at(-1)??e})}}async sync(e,t=!1){if(this.ended)return;let n=this.resolve(e);if(this.inflight.has(n))return t&&this.rerun.add(n),this.inflight.get(n);if(!t&&this.states.get(n)?.loaded&&!this.states.get(n)?.error)return;this.reserve(n);let r=this.states.get(n);this.setState(n,{...r,path:n,name:n.split(`/`).at(-1)??n,loading:!r?.loaded&&!this.watches.get(n)?.failed});let i=(async()=>{try{do{this.rerun.delete(n);let e=this.watches.get(n),r=e?.epoch;try{let i=te(this.files,this.input(n),this.transport),a=await this.query.fetchQuery({...i,gcTime:3e4,staleTime:t?0:3e4,queryFn:async()=>{if(!this.files.readFile)throw Error(`File content reads are unavailable in this runtime`);let e=await this.files.readFile(this.full(n),{directory:this.root});if(e.exists===!1)throw new V(`File does not exist`);let t=e.content;if(H(t)>131072)throw Error(`GUI file preview exceeds 128 KiB`);return t}});if(this.ended)return;if(H(a)>131072)throw Error(`GUI file preview exceeds 128 KiB`);(!e||e.epoch===r&&!e.failed)&&this.setState(n,{path:n,name:n.split(`/`).at(-1)??n,loaded:!0,loading:!1,content:{type:`text`,content:a}})}catch(t){if(this.ended)return;if((!e||e.epoch===r&&!e.failed)&&this.setState(n,{...this.states.get(n),loading:!1,...t instanceof V?{notFound:!0}:{},error:String(t)}),!this.rerun.has(n))throw t}t=!0}while(!this.ended&&this.rerun.has(n))}finally{this.inflight.delete(n),this.rerun.delete(n)}})();return this.inflight.set(n,i),i}watch(e){if(this.ended||!this.files.statFile)return()=>{};let t=this.resolve(e),n=this.watches.get(t);if(!n){if(this.watches.size>=64)throw Error(`GUI file watch limit exceeded`);this.reserve(t),n={count:0,epoch:0,failed:!1,stop:()=>{}};let e=n;this.watches.set(t,e);let r,i=new ee(this.query,{...this.statOptions(t),refetchInterval:2e3,refetchIntervalInBackground:!1}),a=i.subscribe(n=>{if(this.ended||this.watches.get(t)!==e||n.isFetching)return;if(n.isError||n.isSuccess&&!n.data.isFile){e.failed=!0,e.epoch++,this.setState(t,{...this.states.get(t),loading:!1,notFound:n.isSuccess?!0:this.states.get(t)?.notFound,error:n.isError?String(n.error):`File does not exist`});return}if(!n.data||!n.isSuccess)return;let i=`${n.data.size}:${n.data.mtimeMs??``}`,a=e.failed||r!==void 0&&i!==r;e.failed=!1,r=i,a&&(e.epoch++,this.sync(t,!0).catch(()=>{}))});e.stop=()=>{a(),i.destroy()},this.states.get(t)?.loaded&&this.sync(t,!0).catch(()=>{})}n.count++;let r=!0;return()=>{r&&(r=!1,--n.count===0&&this.watches.get(t)===n&&this.stopWatch(t))}}stopWatch(e){this.watches.get(e)?.stop(),this.watches.delete(e)}dispose(){this.ended=!0;for(let e of this.watches.values())e.stop();this.watches.clear(),this.apiLeases.clear(),this.leaseCount=0,this.rerun.clear(),this.states.clear(),this.inflight.clear(),this.selections.clear(),this.scrolls.clear(),this.subscriptions.clear()}},U=256,W=2097152,G=e=>structuredClone(f(e)),De=class{backend;transport;memory=new Map;resets=new Map;constructor(e,t){this.backend=e,this.transport=t}forPlugin(e,t){let n=(t,n=`global`)=>{if(typeof n==`object`&&`session`in n&&!n.session.location)throw Error(`Unsupported GUI storage: session location is unknown`);let r=n===`global`?n:`session`in n?[n.session.server.id,n.session.id,n.session.location]:[n.server,n.directory];return`yuri.gui-plugin.${JSON.stringify([this.transport,e,r,t])}`},r=e=>{if(t.aborted)throw Error(`GUI plugin has been disposed`);if(e!==void 0)throw Error(`Unsupported GUI storage migration: from`)},i=new Map;return{store:(e,a)=>{r(a.from);let o=n(e,a.scope),s=i.get(o);if(s)return s;if(i.size>=U)throw Error(`GUI plugin store limit exceeded`);let l=w(a.schema),u=C(a.schema),d=l(u(G(a.initial)));if(JSON.stringify(u(d)).length>W)throw Error(`GUI plugin store exceeds 2 MiB`);let f=d,p=this.backend.getItem(o);if(p!==null&&p.length<=W)try{f=l(JSON.parse(p))}catch{f=d}let[m,h]=c(f),g=e=>{r();let t=JSON.stringify(u(G(e)));if(t.length>W)throw Error(`GUI plugin store exceeds 2 MiB`);let n=l(JSON.parse(t));this.backend.setItem(o,t),h(()=>n)},_={get value(){return m()},ready:()=>!0,set:g,update:e=>{let t=G(m());if(e(t)!==void 0)throw Error(`Store update must not return a replacement`);g(t)}},v=()=>h(()=>G(d)),y=this.resets.get(o)??new Set;return y.add(v),this.resets.set(o,y),t.addEventListener(`abort`,()=>{y.delete(v),y.size||this.resets.delete(o),i.clear()},{once:!0}),i.set(o,_),_},memory:(e,t)=>{r();let i=n(e),a=this.memory.get(i);if(a)return[a[0],e=>{r(),a[1](e)}];if(this.memory.size>=U)throw Error(`GUI plugin memory store limit exceeded`);if(JSON.stringify(t.initial).length>W)throw Error(`GUI plugin memory exceeds 2 MiB`);let[o,s]=u(G(t.initial)),c=[o,e=>{r();let t=G(f(o));if(e(t)!==void 0)throw Error(`Memory update must not return a replacement`);if(JSON.stringify(t).length>W)throw Error(`GUI plugin memory exceeds 2 MiB`);s(h(t))}];return this.memory.set(i,[o,e=>{let t=G(f(o));if(e(t)!==void 0)throw Error(`Memory update must not return a replacement`);if(JSON.stringify(t).length>W)throw Error(`GUI plugin memory exceeds 2 MiB`);s(h(t))}]),c},remove:(e,t)=>{r(t?.from);let i=n(e,t?.scope);this.backend.removeItem(i);for(let e of this.resets.get(i)??[])e()}}}dispose(){this.memory.clear(),this.resets.clear()}},K=e=>e===`yuri.exportPDF`||e===`yuri.exportLongImage`,Oe=class{api;probe;clients=new Map;ended=!1;constructor(e){this.api=e}use(e,t){let n=this.clients.get(t),r=n?.get(e);if(r)return r.live;let[i,a]=c(this.api&&!t.aborted&&!this.ended?{status:`pending`}:{status:`inactive`,reason:`disabled`}),o=()=>{a({status:`inactive`,reason:`disabled`}),t.removeEventListener(`abort`,o),this.clients.delete(t)},s={live:k(i),stop:o};if(this.ended||t.aborted||(n||(n=new Map,this.clients.set(t,n)),n.set(e,s),t.addEventListener(`abort`,o,{once:!0}),!this.api))return s.live;let l=this.api;return this.probe??=Promise.resolve().then(()=>l.capabilities()),this.probe.then(n=>{if(this.ended||t.aborted)return;let r=e===`yuri.exportPDF`?`exportPDF`:`exportLongImage`;if(n.version!==1||!n[r]){a({status:`inactive`,reason:`disabled`});return}let o=async(e,n={})=>{if(this.ended||t.aborted||i().status!==`active`)return{status:`cancelled`};let o=AbortSignal.any([t,...n.signal?[n.signal]:[]]);try{return await l[r](e,{...n,signal:o})}catch(e){throw e&&typeof e==`object`&&`code`in e&&e.code===`EXPORT_UNSUPPORTED`&&a({status:`inactive`,reason:`failed`}),e}},s=Object.freeze(e===`yuri.exportPDF`?{version:1,limits:n.limits,exportPDF:o}:{version:1,limits:n.limits,exportLongImage:o});a({status:`active`,generation:1,value:s})}).catch(()=>{!this.ended&&!t.aborted&&a({status:`inactive`,reason:`failed`})}),s.live}dispose(){this.ended=!0;for(let e of this.clients.values())for(let t of e.values())t.stop();this.clients.clear()}};function q(e,t){let n=new Map,r=Object.freeze({dismiss(){}});return e.addEventListener(`abort`,()=>{for(let e of[...n.values()])e.handle.dismiss()},{once:!0}),Object.freeze({show(i){if(e.aborted)return r;if(!t)throw new E(`GUI_PLUGIN_UNSUPPORTED`,`GUI toast is unavailable`);if(!i||typeof i!=`object`)throw new E(`GUI_PLUGIN_INVALID_INPUT`,`Expected toast options`);let{title:a,description:o,variant:s=`default`,duration:c=5e3,persistent:l=!1,icon:u,actions:d}=i;if(typeof a!=`string`||o!==void 0&&typeof o!=`string`||![`default`,`success`,`error`,`loading`].includes(s)||typeof l!=`boolean`||typeof c!=`number`||!Number.isFinite(c)||c<0)throw new E(`GUI_PLUGIN_INVALID_INPUT`,`Invalid toast options`);if(u!==void 0||d!==void 0)throw new E(`GUI_PLUGIN_UNSUPPORTED`,`GUI toast icon/actions are unsupported`);if(e.aborted)return r;let f=JSON.stringify([a,o??null,s,c,l]),p=n.get(f),m=()=>{let e=n.get(f);!e||e.id!==h||(clearTimeout(e.timer),n.delete(f))},h=(s==="default"?t:t[s])(a,{id:p?.id,description:o,duration:l?1/0:c,onDismiss:m,onAutoClose:m}),g=p?.handle??Object.freeze({dismiss(){m(),t.dismiss(h)}});clearTimeout(p?.timer);let _=s===`loading`&&!l?setTimeout(()=>g.dismiss(),c):void 0;return n.set(f,{id:h,handle:g,timer:_}),g}})}var ke=ie(`YuriMedia`);async function Ae(e){let t=/\.html?$/i.test(e.name)?`text/html`:`text/plain`,n=new Blob([e.content],{type:t});if(se()){if(!ae.isPluginAvailable(`YuriMedia`))throw new E(`GUI_PLUGIN_UNSUPPORTED`,`Native file saving is unavailable`);if(n.size>33554432)throw new E(`GUI_PLUGIN_INVALID_INPUT`,`File exceeds maximum size`);let r=await new Promise((e,t)=>{let r=new FileReader;r.onload=()=>{if(typeof r.result!=`string`){t(Error(`Failed to encode file`));return}e(r.result.slice(r.result.indexOf(`,`)+1))},r.onerror=()=>t(r.error??Error(`Failed to encode file`)),r.readAsDataURL(n)});return!(await ke.saveFile({dataBase64:r,mimeType:t,filename:e.name})).cancelled}let r=URL.createObjectURL(n),i=document.createElement(`a`);try{return i.href=r,i.download=e.name,document.body.append(i),i.click(),!0}finally{i.remove(),setTimeout(()=>URL.revokeObjectURL(r),1e3)}}var J=d();function je(e){return{version:1,register(t){let n=r(J);if(!n||n.plugin!==e||n.signal.aborted||e.aborted)throw Error(`Preview actions require the owning mounted panel`);let i=new AbortController,a=AbortSignal.any([e,n.signal,i.signal]),o,s=()=>{a.removeEventListener(`abort`,s),i.abort(),o?.remove()};p(s),a.addEventListener(`abort`,s,{once:!0});try{o=t.render({element:t.element,signal:a,async snapshot(e={}){let r=AbortSignal.any([a,...e.signal?[e.signal]:[]]);if(r.throwIfAborted(),!n.content.contains(t.element)||n.target.contains(t.element))throw Error(`Preview capture region is no longer in its owning panel`);let i=await t.capture({...e,signal:r});if(r.throwIfAborted(),!n.content.contains(t.element))throw Error(`Preview capture region was replaced`);return i}}),a.throwIfAborted(),n.target.append(o)}catch(e){throw s(),e}return s}}}function Y(e,t){return JSON.stringify([e,t])}function Me(e){if(!e||typeof e!=`object`||!(`id`in e)||typeof e.id!=`string`||!e.id.trim()||e.id.length>128||!(`title`in e)||typeof e.title!=`string`||!(`render`in e)||typeof e.render!=`function`)throw Error(`Invalid yuri.page contribution`);return e}var X=e=>{throw new E(`GUI_PLUGIN_UNSUPPORTED`,`Unsupported GUI host API: ${e}`)};function Z(e,t){return new Proxy(t,{get:(t,n)=>n in t?Reflect.get(t,n):X(`${e}.${String(n)}`)})}var Q=e=>Object.freeze(e.map(e=>Object.freeze(e)));function Ne(e,t){if(!e.fields||!t.fields)return!1;let n=Reflect.ownKeys(e.fields);return n.length===Reflect.ownKeys(t.fields).length&&n.every(n=>{let r=e.fields[n],i=t.fields[n];return i!==void 0&&`value`in r&&`value`in i&&Object.is(r.value,i.value)&&r.enumerable===i.enumerable&&r.configurable===i.configurable&&r.writable===i.writable})}function $(e,t){if(e){for(let n of e.owned??[])$(n,t);e.cleanups&&=e.cleanups.map(e=>()=>{try{Promise.resolve(e()).catch(t)}catch(e){t(e)}})}}var Pe=class{options;fileIcons=new de;appearanceCatalog=new le;instances=new Map;listeners=new Set;panelMounts=new Set;fileViews=new Map;changes=c(0);views=c(0);session=c();currentPage=c();appearance;layouts=new Map;files;storage;ended=!1;contracts=new Map;snapshot=Object.freeze({plugins:Object.freeze([]),commands:Object.freeze([]),titlebarItems:Object.freeze([]),panels:Object.freeze([]),pages:Object.freeze([]),settings:Object.freeze([]),menuItems:Object.freeze([]),activePanel:null});#e;viewExports;constructor(e){this.options=e,this.viewExports=new Oe(e.viewExport),this.appearance=c({locale:e.locale,mode:e.mode,narrow:e.narrow}),this.storage=new De(e.storage,e.transport);let t=()=>(this.session[0](),this.files?.api??X(`screen.file without a session`));this.#e=Z(`screen`,{get file(){return t()}})}subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getSnapshot=()=>this.snapshot;changed(e=!1){let t=this.snapshot;this.changes[1](e=>e+1),e&&t===this.snapshot&&this.publish()}setSession(e){if(this.ended)return;let t=this.session[0]();if(t?.id===e?.id&&t?.directory===e?.directory)return;if(!e)for(let e of[...this.panelMounts])e();this.files?.dispose(),this.files=e?new Ee(this.options.files,this.options.queryClient,this.options.transport,e.directory):void 0;let n=Z(`session.server`,{id:this.options.transport,name:this.options.transport,client:this.options.client}),r=e?Object.freeze(Z(`session`,{id:e.id,directory:e.directory,key:`${this.options.transport}\n${e.id}`,tab:e.id,server:n,pending:!1,visit:{},location:{directory:e.directory}})):void 0,i=this.snapshot;this.session[1](r),i===this.snapshot&&this.publish()}setAppearance(e){if(this.ended)return;let t=this.appearance[0]();(t.locale!==e.locale||t.mode!==e.mode||t.narrow!==e.narrow)&&this.appearance[1]({...e})}setPage(e){this.ended||this.currentPage[1](e)}install(t,r,o){let s=this.instances.get(t);if(this.ended||s?.status===`active`&&s.revision===r.revision&&s.native?.active!==!1){o?.dispose();return}s&&(this.instances.delete(t),this.release(s));let l={id:t,native:o,revision:r.revision,controller:new AbortController,status:`active`,cleanups:new Set,contributions:new Set,iconChanges:c(0),appearanceChanges:c(0),commands:[],titlebarItems:[],panels:[],pages:[],settings:[],menus:[]};this.instances.set(t,l);try{if(t===`yuri`||t.startsWith(`yuri.`))throw Error(`The yuri namespace is reserved to the host`);let s=Te(r.code,o?.activation.os);b(t=>{l.dispose=t,l.root=a(),y(()=>x(A.Provider,{value:l.context=this.context(l,s,r.options),get children(){l.owner=a();let e=n(()=>s.setup?.(l.context));if(typeof e==`function`)l.cleanups.add(()=>{Promise.resolve(e()).catch(e=>{l.error=String(e)})});else if(e!==void 0)throw e&&typeof e==`object`&&`then`in e&&Promise.resolve(e).catch(()=>{}),Error(`GUI setup must be synchronous and return only cleanup`);return null}}),e=>this.fail(l,e)),l.controller.signal.aborted||i(l.owner,()=>e(()=>{if(l.iconChanges[0](),!l.controller.signal.aborted)try{let e=[...l.contributions].filter(e=>e.registry===ce).map(e=>e.read()).filter(e=>e!==void 0);this.fileIcons.replace(l.id,e),l.iconError!==void 0&&n(()=>{l.iconError=void 0,this.publish()})}catch(e){n(()=>{this.fileIcons.remove(l.id),l.iconError=e instanceof Error?e.message:String(e),this.publish()})}})),l.controller.signal.aborted||i(l.owner,()=>e(()=>{if(l.appearanceChanges[0](),!l.controller.signal.aborted)try{let e=e=>[...l.contributions].filter(t=>t.registry===e).map(e=>e.read()).filter(e=>e!==void 0);this.appearanceCatalog.replace(l.id,e(fe),e(ue),l.native?.activation.capabilities?.dockIcon===!0)}catch(e){n(()=>this.fail(l,e))}})),l.controller.signal.aborted||i(l.owner,()=>e(()=>{this.changes[0](),this.session[0](),this.appearance[0]();try{this.derive(l)}catch(e){n(()=>this.fail(l,e))}n(()=>this.publish())}))})}catch(e){this.fail(l,e)}this.changed(!0)}release(e){e.controller.abort(),e.native?.dispose();for(let t of[...e.cleanups])try{t()}catch(t){e.error??=String(t)}e.cleanups.clear(),$(e.root,t=>{e.error??=String(t)});try{e.dispose?.()}catch(t){e.error??=String(t)}e.contributions.clear(),e.commands=[],e.titlebarItems=[],e.panels=[],e.pages=[],e.settings=[],e.menus=[],this.fileIcons.remove(e.id),this.appearanceCatalog.remove(e.id);for(let t of this.contracts.values())t.provider===e&&(t.provider=void 0,t.live[1]({status:`inactive`,reason:e.status===`failed`?`failed`:`disabled`}))}fail(e,t){e.status!==`failed`&&this.instances.get(e.id)===e&&(e.status=`failed`,e.error=t instanceof Error?t.message:String(t),t instanceof E&&(e.errorCode=t.code),this.release(e),this.publish())}uninstall(e){let t=this.instances.get(e);if(t){this.instances.delete(e),this.release(t);for(let t of this.layouts.values())t.open=t.open.filter(t=>!t.startsWith(`${e}:`)),t.active?.startsWith(`${e}:`)&&(t.active=null);this.changed(!0)}}dispose(){this.ended||(this.ended=!0,l(()=>{for(let e of[...this.instances.keys()])this.uninstall(e)}),this.viewExports.dispose(),this.files?.dispose(),this.fileIcons.dispose(),this.appearanceCatalog.dispose(),this.storage.dispose(),this.layouts.clear(),this.fileViews.clear(),this.contracts.clear(),this.listeners.clear())}async setDockIcon(e,t){let n=this.instances.get(e),r=n?.native;if(!r?.active||!r.activation.capabilities?.dockIcon)return X(`Dock icon`);try{await r.setDockIcon(t)}catch(e){throw t!==null&&n&&this.fail(n,e),e}}own(e,t){let n=!0,i=()=>{n&&(n=!1,e.cleanups.delete(i),t())};return e.controller.signal.aborted||r(I)?.ended?(i(),i):(e.cleanups.add(i),a()&&p(i),i)}list(e){this.changes[0]();let t=[];for(let n of this.instances.values())if(n.status===`active`){for(let r of n.contributions)if(r.registry===e.id){let e=r.read();e!==void 0&&t.push(e)}}return t}context(t,i,o){let c=this.storage.forPlugin(t.id,t.controller.signal),l=Object.fromEntries(Object.entries(i.stores??{}).map(([e,t])=>[e,t.scope===`global`?c.store(e,{...t,scope:`global`}):n=>c.store(e,{...t,scope:{session:n}})])),u=(e,t)=>{let n=this.appearance[0]().locale;return(i.i18n?.[n]?.[e]??i.i18n?.[n.split(`-`)[0]]?.[e]??i.i18n?.en?.[e]??e).replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t?.[n]??e))},d=Z(`layout`,{narrow:()=>this.appearance[0]().narrow,ready:()=>!!this.session[0](),open:(e,n,r)=>{t.controller.signal.aborted||this.openPanel(e,n,r)},close:(e,n)=>{t.controller.signal.aborted||this.closeFor(e,n)},toggle:(e,t)=>d.state(e,t)===`visible`?d.close(e,t):d.open(e,t),hide:(e,n)=>{if(t.controller.signal.aborted)return;let r=this.layout(n);r.active===e&&r.shown&&(r.shown=!1,this.changed())},state:(e,t)=>{this.changes[0]();let n=this.layout(t);return n.active===e?n.shown?`visible`:`active`:n.open.includes(e)?`open`:`closed`},stored:e=>(this.changes[0](),this.layout(e).open.filter(e=>e.startsWith(`${t.id}:`)).map(e=>e.slice(t.id.length+1))),side:{opened:e=>(this.changes[0](),this.layout(e).shown),toggle:e=>{if(t.controller.signal.aborted)return;let n=this.layout(e);n.shown=!n.shown,this.changed()},menu:()=>this.list(M).filter(e=>e.menu===`session.panel`).sort((e,t)=>(e.order??0)-(t.order??0))},scroll:{get:(e,t)=>(this.changes[0](),this.layout(e).scroll.get(t)),set:(e,n,r)=>{if(t.controller.signal.aborted)return;let i=this.layout(e).scroll;if(!i.has(n)&&i.size>=128)throw Error(`GUI layout scroll limit exceeded`);i.set(n,{...r}),this.changed()}}}),f=je(t.controller.signal),m=k(()=>t.controller.signal.aborted?{status:`inactive`,reason:`disabled`}:{status:`active`,generation:1,value:f}),h={open:e=>t.controller.signal.aborted||this.appearance[0]().narrow||!t.pages.some(t=>t.id===e)?!1:this.options.openPage?.(Y(t.id,e))??!1,current:()=>{let e=this.currentPage[0]();return t.pages.find(n=>Y(t.id,n.id)===e)?.id}},g=k(()=>t.controller.signal.aborted||!this.options.openPage||this.appearance[0]().narrow?{status:`inactive`,reason:`disabled`}:{status:`active`,generation:1,value:h});return Z(`ctx`,{id:t.id,options:o,signal:t.controller.signal,client:this.options.client,storage:c,stores:l,toast:q(t.controller.signal,this.options.toast),app:{name:`yuri`,version:t.native?.activation.app.version??``,channel:t.native?.activation.app.packaged?`prod`:`local`,platform:t.native?`desktop`:`web`,packaged:t.native?.activation.app.packaged??!1},desktop:t.native?Z(`desktop`,{os:t.native.activation.os}):void 0,t:u,plural:(e,t,n)=>{let r=`${e}.${new Intl.PluralRules(this.appearance[0]().locale).select(t)}`;return u(r,{...n,count:t})===r?u(`${e}.other`,{...n,count:t}):u(r,{...n,count:t})},add:(i,o)=>{if(t.controller.signal.aborted||r(I)?.ended)return()=>{};if([`server`,`composer-pill`,`slot`,`file.viewer`,`menubar-item`].includes(i.id)&&X(`registry.${i.id}`),t.contributions.size>=256)throw Error(`GUI contribution limit exceeded`);let c=()=>{},l,u=b(n=>{c=n,l=a();let r=()=>typeof o==`function`?o():o,u;if(i.id===`yuri.file-icon`){let e=s(()=>{try{return{ok:!0,value:r()}}catch(e){return{ok:!1,error:e}}});u=()=>{let t=e();if(!t.ok)throw t.error;return t.value}}else u=s(r);if(i.id===`style`){let n=document.createElement(`style`);n.dataset.yuriPluginStyle=t.id,document.head.append(n),p(()=>n.remove()),e(()=>{let e=u();n.textContent=e===void 0?``:String(e)})}return{registry:i.id,read:u}},a()??t.owner);t.contributions.add(u);let d=()=>{i.id===`yuri.file-icon`&&t.iconChanges[1](e=>e+1)},f=()=>{(i.id===`yuri.theme`||i.id===`yuri.branding`)&&t.appearanceChanges[1](e=>e+1)};return n(d),n(f),n(()=>this.changed()),this.own(t,()=>{$(l,e=>{t.error??=String(e)}),c(),t.contributions.delete(u),n(d),n(f),n(()=>this.changed())})},list:e=>this.list(e),provide:(e,n)=>{if(t.controller.signal.aborted||r(I)?.ended)return()=>{};if(K(e.id)||e.id===`yuri.previewActions`||e.id===`yuri.pages`)throw Error(`Preview/export/page contracts are provided only by the Yuri host`);if(e.kind!==`contract`||!(e.id===t.id||e.id.startsWith(`${t.id}.`)))throw Error(`Contract must belong to the providing plugin`);let i=this.contract(e.id);if(i.provider)throw Error(`Contract already provided: ${e.id}`);return i.provider=t,i.live[1]({status:`active`,value:n,generation:++i.generation}),this.own(t,()=>{i.provider===t&&(i.provider=void 0,i.live[1]({status:`inactive`,reason:t.status===`failed`?`failed`:`disabled`}))})},use:e=>e.id===`yuri.pages`?e.kind===`contract`?g:X(`pages token must be a Contract`):e.id===`yuri.previewActions`?e.kind===`contract`?m:X(`preview actions token must be a Contract`):K(e.id)?e.kind===`contract`?this.viewExports.use(e.id,t.controller.signal):X(`export token must be a Contract`):e.kind===`ipc`&&t.native?t.native.token(e).live:this.contract(e.id,e.kind===`ipc`).live[0],main:e=>{if(!(e.id===t.id||e.id.startsWith(`${t.id}.`)))throw new E(`GUI_PLUGIN_FORBIDDEN`,`IPC must belong to the plugin`);return t.native?t.native.token(e).value:new Proxy({state:()=>void 0},{get:(e,t)=>t===`state`?e.state:t===`on`?()=>{throw new E(`GUI_PLUGIN_UNSUPPORTED`)}:()=>Promise.reject(new E(`GUI_PLUGIN_UNSUPPORTED`))})},sessions:{current:this.session[0],list:()=>{let e=this.session[0]();return e?[e]:[]}},screen:{current:()=>this.session[0]()?this.#e:void 0},layout:d,appearance:{mode:()=>this.appearance[0]().mode,font:()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||`monospace`},locale:{locale:()=>this.appearance[0]().locale,direction:()=>/^(ar|fa|he|ur)(-|$)/i.test(this.appearance[0]().locale)?`rtl`:`ltr`},system:{copy:e=>navigator.clipboard.writeText(e),openExternal:e=>{let t=new URL(e);[`https:`,`http:`,`mailto:`].includes(t.protocol)||X(`system.openExternal protocol`),window.open(e,`_blank`,`noopener,noreferrer`)},save:Ae},commands:{run:e=>t.controller.signal.aborted||!this.command(e)?!1:(this.runCommand(e),!0)},links:{open:e=>!t.controller.signal.aborted&&this.navigateLink(t,e),exists:e=>n(()=>{if(t.controller.signal.aborted)return!1;let n=this.linkHandler(e);try{return Promise.resolve(n?.value.exists?.(e)??!1).catch(()=>!1)}catch{return!1}})}})}contract(e,t=!1){let n=this.contracts.get(e);if(!n){if(this.contracts.size>=256)throw Error(`GUI contract limit exceeded`);let t=c({status:`inactive`,reason:`disabled`});n={live:[k(t[0]),t[1]],generation:0},this.contracts.set(e,n)}return t&&n.provider&&X(`IPC contract collision`),n}derive(e){if(e.status!==`active`)return;let t=[],r=[],i=[],a=[],o=[],s=[],c=this.session[0]();for(let n of e.contributions){if([`yuri.file-icon`,`yuri.theme`,`yuri.branding`].includes(n.registry))continue;let l=n.read();if(l!==void 0){if(n.registry===`yuri.page`){let e=Me(l);if(s.some(t=>t.id===e.id))throw Error(`Duplicate yuri.page id`);s.push(e)}else if(n.registry===be.id){let n=l;n.enabled!==!1&&t.push({key:`${e.id}.${n.id}`,pluginId:e.id,title:n.title,description:n.description,bind:n.bind,hidden:n.hidden,run:()=>this.invoke(e,()=>n.run())})}else if(n.registry===O.id){let t=l;o.push({key:JSON.stringify([e.id,t.id]),pluginId:e.id,label:t.label,title:t.title,icon:t.icon,busy:t.busy,pressed:t.pressed,actionable:!!t.run,run:t.run})}else if(n.registry===Se.id&&c){let t=l,n=`${e.id}:`,i=this.layout(c).open.filter(e=>e.startsWith(n)).map(e=>e.slice(n.length));for(let n of t.list({session:c,screen:this.#e,open:i}))r.push({plugin:e,panel:t,tab:n})}else if(n.registry===D.id){let e=l;(e.page||e.section)&&X(`SettingsPage host sections`),e.title,i.push(e)}else if(n.registry===M.id){let e=l;e.menu===`session.panel`?(e.title,a.push(e)):X(`MenuItem.${e.menu}`)}}}for(let e of r)e.tab.title;e.commands=t,e.titlebarItems=o,e.panels=r,e.pages=s,e.settings=i,e.menus=a,n(()=>this.views[1](e=>e+1))}publish(){let e=n(this.session[0]),t=e?this.layouts.get(e.key):void 0,r=[...this.instances.values()],i=r.filter(e=>e.status===`active`),a=i.flatMap(e=>e.panels.map(({tab:n})=>{let r=n.file?this.filePath(n.file):void 0;return{key:`${e.id}:${n.id}`,pluginId:e.id,title:n.title,file:r,inline:!!(r&&this.fileViews.has(r)),active:t?.shown===!0&&t.active===`${e.id}:${n.id}`}}));this.snapshot=Object.freeze({plugins:Q(r.map(({id:e,revision:t,status:n,error:r,errorCode:i,iconError:a})=>({id:e,revision:t,status:n,error:r??a,...i?{errorCode:i}:{}}))),commands:Q(i.flatMap(e=>e.commands.filter(e=>!e.hidden))),panels:Q(a),titlebarItems:Q(i.flatMap(e=>e.titlebarItems.map(({run:e,...t})=>t))),pages:Q(i.flatMap(e=>e.pages.map(t=>({key:Y(e.id,t.id),pluginId:e.id,title:t.title,icon:t.icon})))),settings:Q(i.flatMap(e=>e.settings.map(t=>({key:`${e.id}:${t.id}`,pluginId:e.id,title:t.title})))),menuItems:Q(i.flatMap(e=>e.menus.map(t=>({key:`${e.id}:${t.id}`,pluginId:e.id,title:t.title,description:t.description,run:()=>{this.invoke(e,()=>t.run())}})))),activePanel:t?.shown&&a.some(e=>e.key===t.active)?t.active:null,sessionKey:e?.key});for(let e of this.listeners)e()}invoke(e,t){if(!e.controller.signal.aborted)try{let n=i(e.owner??null,t);if(n instanceof Promise)return n.catch(t=>this.fail(e,t))}catch(t){this.fail(e,t)}}command(e){return[...this.instances.values()].flatMap(e=>e.commands).find(t=>t.key===e)}runCommand(e){return this.command(e)?.run()}runTitlebarItem(e){for(let t of this.instances.values()){let n=t.titlebarItems.find(t=>t.key===e);if(n?.run&&!n.busy)return this.invoke(t,n.run)}}linkHandler(e){let t=[];for(let e of this.instances.values())for(let n of e.contributions)if(n.registry===ve.id){let r=n.read();r&&t.push({instance:e,value:r})}for(let n of t.sort((e,t)=>(t.value.priority??0)-(e.value.priority??0)))try{if(n.value.match(e))return n}catch(e){this.fail(n.instance,e)}}navigateLink(e,t){if(this.ended)return!1;let n=me(t.href);if(!n||!pe(n.path))return this.openLink(t);let r=this.session[0]();if(!r||t.session&&(t.session.key!==r.key||t.session.server.id!==r.server.id))return!1;if(!this.options.focusFile)return this.openLink(t);let i=re(t.base??r.directory,n.path),a=n.line===void 0?``:`:${n.line}${n.column===void 0?``:`:${n.column}`}`;return this.invoke(e,()=>this.options.focusFile(i+a,r.directory)),!0}openLink(e){if(this.ended)return!1;let t={...e,session:e.session??this.session[0]()},n=this.linkHandler(t);return n?(this.invoke(n.instance,()=>n.value.open(t)),!0):!1}filePath(e,t=this.session[0]()?.directory){let n=R(e);return/^(?:\/|[a-z]:\/)/i.test(n)||!t?n:R(`${t}/${n}`)}registerFileView(e,t){if(this.ended)return()=>{};let n=this.filePath(e,t),r=this.fileViews.get(n)??0;this.fileViews.set(n,r+1),r===0&&this.changed(!0);let i=!1;return()=>{if(i||this.ended)return;i=!0;let e=(this.fileViews.get(n)??1)-1;if(e){this.fileViews.set(n,e);return}{let e=this.session[0](),t=e&&this.layouts.get(e.key);t?.active&&this.snapshot.panels.some(e=>e.key===t.active&&e.file===n)&&(t.shown=!1),this.fileViews.delete(n)}this.changed(!0)}}filePanel(e,t){let n=this.filePath(e,t);return this.snapshot.panels.find(e=>e.file===n&&e.inline)}panelVisible(e){let t=this.session[0]();if(!t)return!1;let n=this.panel(e)?.tab.file;if(n&&this.fileViews.has(this.filePath(n)))return!0;let r=this.layouts.get(t.key);return!!(r?.shown&&r.active===e)}layout(e){let t=this.layouts.get(e.key);if(!t){if(this.layouts.size>=128)throw Error(`GUI session layout limit exceeded`);t={open:[],active:null,shown:!1,scroll:new Map},this.layouts.set(e.key,t)}return t}openPanel(e,t,n){if(this.ended)return;let r=this.layout(t),i=r.active,a=r.shown,o=r.open.length;if(!r.open.includes(e)){if(r.open.length>=64)throw Error(`GUI panel tab limit exceeded`);r.open=[...r.open,e]}n?.tab!==`append`&&(r.active=e,r.shown=!(this.appearance[0]().narrow&&n?.background)),(i!==r.active||a!==r.shown||o!==r.open.length)&&this.changed(!0);let s=this.panel(e);t.key===this.session[0]()?.key&&s&&n?.tab!==`append`&&this.invoke(s.plugin,()=>s.panel.focus?.({...this.props(e),restored:!1}))}selectPanel(e){let t=this.session[0]();t&&this.openPanel(e,t)}closeFor(e,t){let n=this.layout(t),r=t.key===this.session[0]()?.key?this.panel(e):void 0;if(!n.open.includes(e)||r?.tab.pinned||r?.tab.closable===!1)return;let i=this.session[0](),a=r&&i?{tab:r.tab,session:i,screen:this.#e}:void 0;n.open=n.open.filter(t=>t!==e),n.active===e&&(n.active=n.open.at(-1)??null),this.changed(!0),r&&a&&this.invoke(r.plugin,()=>r.panel.close?.(a))}closePanel(e){let t=this.session[0]();t&&this.closeFor(e,t)}hidePanel(){let e=this.session[0]();if(!e)return;let t=this.layout(e);t.shown&&(t.shown=!1,this.changed(!0))}panel(e){return[...this.instances.values()].flatMap(e=>e.panels).find(t=>`${t.plugin.id}:${t.tab.id}`===e)}props(e,t=!1){let n=this.panel(e)?.tab,r=()=>(this.views[0](),this.panel(e)?.tab??n??X(`panel no longer listed`)),i=t?s(()=>{let e=r();return{tab:e,fields:Object.getPrototypeOf(e)===Object.prototype?Object.getOwnPropertyDescriptors(e):void 0}},void 0,{equals:Ne}):void 0,a=i?()=>i().tab:r,o=()=>this.session[0]()??X(`panel without session`);return{get tab(){return a()},get session(){return o()},screen:this.#e}}mountPanel(t,r,i){let a=this.panel(t);if(!a)return()=>{};let o=new AbortController,c=()=>{let c=s(()=>{this.session[0](),this.changes[0](),this.views[0]();let e=this.panel(t)?.tab.file;return e&&this.files&&this.panelVisible(t)?{model:this.files,file:e}:void 0},void 0,{equals:(e,t)=>e?.model===t?.model&&e?.file===t?.file});e(()=>{let e=c();e&&(p(e.model.watch(e.file)),e.model.sync(e.file).catch(()=>{}))});let l=()=>n(()=>a.panel.render(this.props(t,!0)));return x(J.Provider,{value:i?{plugin:a.plugin.controller.signal,signal:o.signal,content:r,target:i}:void 0,get children(){return l()}})},l=this.mount(a.plugin,r,()=>x(N.Provider,{value:{visible:()=>(this.changes[0](),this.panelVisible(t)),present:()=>(this.changes[0](),this.panelVisible(t)),placement:()=>this.appearance[0]().narrow?`mobile`:`side`,reserve:()=>!1,animate:()=>!1,sidebar:Z(`panel.sidebar`,{}),open:()=>{let e=this.session[0]();return e?a.plugin.context.layout.stored(e):[]}},get children(){return c()}})),u=()=>{this.panelMounts.delete(u),o.abort(),l()};return this.panelMounts.add(u),this.own(a.plugin,u)}mountSettings(e,t){for(let n of this.instances.values()){let r=n.settings.find(t=>`${n.id}:${t.id}`===e);if(r)return this.mount(n,t,()=>r.render({}))}return()=>{}}mountPage(e,t){if(this.appearance[0]().narrow)return()=>{};for(let n of this.instances.values()){let r=n.pages.find(t=>Y(n.id,t.id)===e);if(r)return this.mount(n,t,()=>r.render())}return()=>{}}mount(e,t,r){if(e.controller.signal.aborted)return()=>{};let i=()=>{},o,s=t=>{queueMicrotask(()=>this.fail(e,t))};try{i=ge(()=>x(A.Provider,{value:e.context,get children(){return o=a(),y(()=>n(r),s)}}),t)}catch(t){this.fail(e,t)}return this.own(e,()=>{$(o,t=>{e.error??=String(t)}),i(),t.replaceChildren()})}};export{Pe as GuiPluginHost};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,i as n}from"./runtime-switch-DEZ1K7qW.js";import{T as r}from"./desktop-BAmoc_34.js";import{a as i,i as a,r as o}from"./vendor-zustand-vDaAPGfl.js";import{J as s,Y as c,ot as l,st as u}from"./vendor-base-ui-CzHs0bHY.js";import{bt as d,kt as f}from"./gitApiHttp-MWsHNHuo.js";import{r as p,x as m}from"./useUIStore-BerIUSLP.js";import{A as h,k as g}from"./bootstrap-C8paoQ0j.js";import{n as _}from"./vendor-react-DlzBev0S.js";import{i as v}from"./vendor-reactuses-core-DWo5Wn6R.js";import{f as y,r as b,u as x}from"./button-CBjOhOI0.js";import{$i as S,Gr as C,Oi as ee,Qn as te,Qr as ne,St as w,Ui as re,V as ie,Zn as T,_a as E,ft as D,ga as O,p as k,w as A,x as j}from"./useMobileNavigationStore-BWLhXqci.js";import{a as ae,g as M,o as oe,p as N,s as P}from"./fileMentionAutocompleteState-BZJqfgae.js";import{t as se}from"./AgentAvatar-DLAQkFQe.js";import{n as F}from"./Icon-Bh3TaKoN.js";import{g as ce,v as le}from"./gitApi-CNgEj6X5.js";import{c as ue,d as de,l as fe,n as pe,r as me,t as he}from"./fileMentionTouchSelection-Bizsisaj.js";import{n as ge}from"./textarea-EsaDD051.js";import{f as _e,o as ve}from"./projectMeta-rrpZdm8D.js";var I=_(),L=e(u(),1),R=l(),z=L.memo(function(e){let t=(0,I.c)(20),{checked:n,onChange:r,disabled:i,indeterminate:a,ariaLabel:o,className:l,iconClassName:u}=e,d=i!==void 0&&i,f=n||a,p;t[0]===r?p=t[1]:(p=e=>r(!!e),t[0]=r,t[1]=p);let m=f?`border-[color:color-mix(in_srgb,var(--primary-base)_65%,var(--interactive-border))] bg-transparent shadow-none hover:bg-[var(--interactive-hover)] hover:border-[color:color-mix(in_srgb,var(--primary-base)_75%,var(--interactive-border))]`:`border-[var(--interactive-border)] bg-transparent shadow-none hover:bg-[var(--interactive-hover)] hover:border-[var(--interactive-border)]`,h;t[2]!==l||t[3]!==m?(h=b(`group/checkbox relative flex shrink-0 self-center items-center justify-center rounded-[4px] border outline-none`,`h-[14px] w-[14px] min-h-[14px] min-w-[14px]`,`transition-[background-color,border-color,box-shadow] duration-200 ease-out`,m,`focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] focus-visible:ring-offset-1 focus-visible:ring-offset-transparent`,`disabled:cursor-not-allowed disabled:opacity-50`,l),t[2]=l,t[3]=m,t[4]=h):h=t[4];let g;t[5]===u?g=t[6]:(g=b(`flex items-center justify-center text-[var(--primary-base)]`,`data-[unchecked]:hidden`,u),t[5]=u,t[6]=g);let _;t[7]===a?_=t[8]:(_=a?(0,R.jsx)(F,{name:`subtract`,className:b(`h-[10px] w-[10px] min-h-[10px] min-w-[10px]`,`text-[var(--primary-base)]`)}):(0,R.jsx)(F,{name:`check`,className:b(`h-[10px] w-[10px] min-h-[10px] min-w-[10px]`,`text-[var(--primary-base)]`)}),t[7]=a,t[8]=_);let v;t[9]!==g||t[10]!==_?(v=(0,R.jsx)(s,{keepMounted:!0,className:g,children:_}),t[9]=g,t[10]=_,t[11]=v):v=t[11];let y;return t[12]!==o||t[13]!==n||t[14]!==d||t[15]!==a||t[16]!==p||t[17]!==h||t[18]!==v?(y=(0,R.jsx)(c,{checked:n,onCheckedChange:p,disabled:d,indeterminate:a,"aria-label":o,className:h,children:v}),t[12]=o,t[13]=n,t[14]=d,t[15]=a,t[16]=p,t[17]=h,t[18]=v,t[19]=y):y=t[19],y}),B=(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=M([...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)},ye=(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}),be=(e,t)=>e.highlightedIndex===t.highlightedIndex&&ye(e.rows,t.rows),xe=(e,t)=>ye(e,t)?e:t.slice(),Se=(e,t,n)=>{e&&(t.current&&be(t.current,n)||(t.current=n,e(n)))},Ce=(e,t)=>{t.current=null,e?.({rows:[],highlightedIndex:0})},V=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},H=e=>/^[A-Za-z]:\//.test(e)?e.toLowerCase():e,U=(e,t)=>{let n=V(t),r=V(e);if(!n||!r)return!1;let i=H(n),a=H(r);return a===i||a.startsWith(`${i}/`)},we=e=>{if(!e||typeof e!=`object`)return{};let t=e,n={};for(let[e,r]of Object.entries(t)){let t=V(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=>V(e)).filter(e=>U(e,t)))):[],o=Array.isArray(i.expandedPaths)?Array.from(new Set(i.expandedPaths.filter(e=>typeof e==`string`).map(e=>V(e)).filter(e=>U(e,t)))):[],s=typeof i.selectedPath==`string`?V(i.selectedPath):null,c=s&&U(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},W=(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},G=e=>e?{...e,touchedAt:Date.now()}:{openPaths:[],selectedPath:null,expandedPaths:[],touchedAt:Date.now()},Te=i()(o(a((e,t)=>({byRoot:{},addOpenPath:(t,n,r)=>{let i=V((t||``).trim()),a=V((n||``).trim());!i||!a||!r?.allowOutsideRoot&&!U(a,i)||e(e=>{let t=e.byRoot[i],n=G(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:W({...e.byRoot,[i]:{...n,openPaths:o,selectedPath:s}},20)}})},removeOpenPath:(t,n)=>{let r=V((t||``).trim()),i=V((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=H(i),a=e=>H(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:W({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeOpenPathsByPrefix:(t,n)=>{let r=V((t||``).trim()),i=V((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=H(i),a=n.endsWith(`/`)?n:`${n}/`,o=e=>{let t=H(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:W({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeExpandedPathsByPrefix:(t,n)=>{let r=V((t||``).trim()),i=V((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=H(i),a=n.endsWith(`/`)?n:`${n}/`,o=t.expandedPaths.filter(e=>{let t=H(e);return t!==n&&!t.startsWith(a)});return o.length===t.expandedPaths.length?e:{byRoot:W({...e.byRoot,[r]:{...t,expandedPaths:o,touchedAt:Date.now()}},20)}})},setSelectedPath:(t,n,r)=>{let i=V((t||``).trim()),a=n?V(n.trim()):null;!i||a&&!r?.allowOutsideRoot&&!U(a,i)||e(e=>{let t=e.byRoot[i],n=G(t),r=a&&!n.openPaths.includes(a)?[...n.openPaths,a]:n.openPaths;return t&&t.selectedPath===a&&r===t.openPaths?e:{byRoot:W({...e.byRoot,[i]:{...n,openPaths:r,selectedPath:a}},20)}})},ensureSelectedPath:e=>{let n=V((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=V((t||``).trim()),i=V((n||``).trim());!r||!i||!U(i,r)||e(e=>{let t=e.byRoot[r],n=G(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:W({...e.byRoot,[r]:{...n,expandedPaths:a}},20)}})},expandPath:(t,n)=>{let r=V((t||``).trim()),i=V((n||``).trim());!r||!i||!U(i,r)||e(e=>{let t=e.byRoot[r],n=G(t);return n.expandedPaths.includes(i)&&t?e:{byRoot:W({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,i]}},20)}})},expandPaths:(t,n)=>{let r=V((t||``).trim());if(!r||!n||n.length===0)return;let i=n.map(e=>V((e||``).trim())).filter(e=>e&&U(e,r));i.length!==0&&e(e=>{let t=e.byRoot[r],n=G(t),a=new Set(n.expandedPaths),o=i.filter(e=>!a.has(e));return o.length===0?e:{byRoot:W({...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:we(t)}},partialize:e=>({byRoot:we(e.byRoot)})}),{name:`files-view-tabs-store`})),Ee=(e,t)=>{let n=(0,I.c)(4),r=t===void 0?200:t,[i,a]=L.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]),L.useEffect(o,s),i},De=()=>{let e=(0,I.c)(17),t=k(Oe),n=w(),r;e[0]===t?r=e[1]:(r=e=>t?e.getAttachment(t):void 0,e[0]=t,e[1]=r);let i=A(r),a=k(ke),o=k(Ae),s=E(K),c=E(q),l=d(J);if(t){let r;e[2]===i?r=e[3]:(r=j(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 Oe(e){return e.currentSessionId}function ke(e){return e.worktreeMetadata}function Ae(e){return e.newSessionDraft}function K(e){return e.activeProjectId}function q(e){return e.projects}function J(e){return e.currentDirectory}var je=`bg-transparent font-[inherit] text-[var(--primary-base)]`,Me=(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,R.jsx)(`mark`,{className:je,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},Ne=L.forwardRef(({searchQuery:e,onFileSelect:t,onAgentSelect:n,onSkillSelect:r,onSessionSelect:i,onClose:a,style:o,onRowsChange:s},c)=>{let{t:l}=y(),u=De()??``,d=k(e=>e.currentSessionId),m=ne(e=>e.activeSessions),_=ie({enabled:!!i}),te=E(e=>e.activeProjectId),w=E(e=>e.projects),T=L.useMemo(()=>w.find(e=>e.id===te)?.path??null,[te,w]),D=L.useMemo(()=>{let e=T||u;return e?e.replace(/\\/g,`/`).replace(/\/+$/,``):null},[T,u]),O=Te(e=>D?e.byRoot[D]:void 0),A=ee(e=>e.agents),j=f(e=>e.searchFiles),M=Ee(e,180),ce=h(),le=g(),[de,fe]=L.useState([]),[_e,ve]=L.useState(!1),[I,z]=L.useState(0),B=L.useRef(0),ye=L.useRef({query:e,directory:u,ids:[]}),[be,xe]=L.useState(360),[V,H]=L.useState({}),[U,we]=L.useState({}),W=L.useRef([]),G=L.useRef([]),Oe=L.useRef([]),ke=L.useRef(null),Ae=L.useRef(null),K=L.useRef(null);K.current||=he();let q=p(e=>e.isMobile),J=(e??``).trim(),je=S({directory:u||null}),Ne=L.useMemo(()=>r?je.data??[]:[],[r,je.data]),Pe=L.useMemo(()=>{if(!D||!O)return[];let e=[O.selectedPath,...O.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(`${D}/`)?e.slice(D.length+1):e;n.push({name:i,path:e,relativePath:a,extension:i.includes(`.`)?i.split(`.`).pop()?.toLowerCase():void 0})}return P(n,J,{limit:6})},[J,D,O]),Y=L.useMemo(()=>n?re(A).filter(e=>e.mode!==`primary`):[],[A,n]),Fe=L.useMemo(()=>i?ae({sessions:C(m,_),currentSessionId:d,searchQuery:J}):[],[m,d,_,J,i]),Ie=Pe,Le=de,X=L.useMemo(()=>ue({skills:Ne,agents:Y,sessions:Fe,recentFiles:Ie,pathHits:Le,searchQuery:J,untitledSession:l(`chat.fileMentionAutocomplete.untitledSession`),sessionBadge:l(`chat.fileMentionAutocomplete.sessionType`),skillBadge:l(`chat.commandAutocomplete.badge.skill`)}),[Ne,Y,Fe,Ie,Le,J,l]);L.useEffect(()=>{let e=e=>{let t=e.target;!t||!ke.current||ke.current.contains(t)||a()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[a]),L.useEffect(()=>{if(!u){fe([]);return}let e=(M??``).trim(),t=N(e);if(!t){fe([]);return}let n=!1;ve(!0);let r={includeHidden:ce,respectGitignore:!le};return Promise.all([j(u,t,80,{...r,type:`file`}),j(u,t,40,{...r,type:`directory`})]).then(([t,r])=>{if(n)return;let i=new Set(Pe.map(e=>e.path));fe(oe({files:t,directories:r,query:e,excludePaths:i,limit:20}))}).catch(()=>{n||fe([])}).finally(()=>{n||ve(!1)}),()=>{n=!0}},[u,M,Pe,j,ce,le]),L.useLayoutEffect(()=>{let t=ye.current,n=t.ids[B.current],r=t.query===e&&t.directory===u?Math.max(0,X.findIndex(e=>e.id===n)):0;ye.current={query:e,directory:u,ids:X.map(e=>e.id)},B.current=r,z(r)},[X,e,u]),L.useEffect(()=>{H({}),we({})},[X]),L.useEffect(()=>{W.current[I]?.scrollIntoView({block:`nearest`})},[I]),L.useEffect(()=>{let e=null,t=()=>{e!==null&&cancelAnimationFrame(e),e=requestAnimationFrame(()=>{let e={},t={};G.current.forEach((n,r)=>{if(!n)return;let i=Oe.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}}),H(e),we(t)})};return t(),window.addEventListener(`resize`,t),()=>{e!==null&&cancelAnimationFrame(e),window.removeEventListener(`resize`,t)}},[X]),L.useEffect(()=>{let e=G.current[I];if(!e)return;let t=()=>{let t=e.clientWidth;t>0&&xe(t)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>{n.disconnect()}},[I]);let Re=v(e=>{t(e)}),ze=v(e=>{n?.(e)}),Be=v(e=>{i?.(e)}),Ve=v(e=>{r?.(e)}),He=(e,t)=>({onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&K.current?.pointerDown(e.clientX,e.clientY)},onPointerMove:e=>{e.pointerType===`touch`&&K.current?.pointerMove(e.clientX,e.clientY)},onPointerUp:e=>{e.pointerType===`touch`&&(K.current?.pointerUp(t)??!1)&&(e.preventDefault(),e.stopPropagation())},onPointerCancel:()=>K.current?.pointerCancel(),onClick:()=>{K.current?.click(t)},onMouseMove:()=>{B.current=e,z(e)}}),Ue=e=>{let t=X.length;if(t===0)return;let n=(e%t+t)%t,r=X[n];if(r.agentName!==void 0){ze(r.agentName);return}if(r.id.startsWith(`skill:`)){let e=Ne.find(e=>r.id===`skill:${e.name}-${e.scope}`);e&&Ve(e);return}if(r.id.startsWith(`session:`)){let e=Fe.find(e=>r.id===`session:${e.id}`);e&&Be(e);return}let i=r.id.startsWith(`recent:`)?Ie.find(e=>r.id===`recent:${e.path}`):Le.find(e=>r.id===`file:${e.path}`);i&&Re(i)};L.useEffect(()=>{Se(s,Ae,{rows:X,highlightedIndex:I})},[s,I,X]);let We=L.useRef(s);return We.current=s,L.useEffect(()=>()=>{Ce(We.current,Ae)},[]),L.useImperativeHandle(c,()=>({acceptIndex:e=>{Ue(e)},handleKeyDown:e=>{if(e===`Escape`){a();return}let t=X.length;if(t!==0){if(e===`ArrowDown`){B.current=(B.current+1)%t,z(B.current);return}if(e===`ArrowUp`){B.current=(B.current-1+t)%t,z(B.current);return}(e===`Enter`||e===`Tab`)&&Ue(B.current)}}})),(0,R.jsxs)(pe,{ref:ke,isMobile:q,className:`max-w-[640px] max-h-64`,style:o,children:[(0,R.jsx)(ge,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0`,children:(0,R.jsxs)(`div`,{className:`py-1`,children:[X.map((e,t)=>{let n=e.id.startsWith(`file:`)||e.id.startsWith(`recent:`),r=n?x(e.title,{maxLength:60}):e.title,i=I===t,a=V[t]??!1,o=U[t]??2.6;return(0,R.jsxs)(`div`,{"data-mention-id":e.id,ref:e=>{W.current[t]=e},className:b(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,q&&`min-h-11`,me(q,i),!q&&i&&`text-interactive-selection-foreground`),...He(t,()=>Ue(t)),children:[(0,R.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center`,children:e.agentName===void 0?(0,R.jsx)(F,{name:e.iconName,className:`size-3.5 text-current`}):(0,R.jsx)(se,{name:e.agentName,size:20})}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,R.jsxs)(`span`,{ref:e=>{G.current[t]=e},className:b(`relative block min-w-0 overflow-hidden`,n&&a&&i&&`file-mention-marquee-container`),style:i?{"--file-mention-marquee-width":`${be}px`,"--file-mention-marquee-duration":`${o}s`}:void 0,title:e.title,children:[(0,R.jsx)(`span`,{ref:e=>{Oe.current[t]=e},className:`absolute invisible whitespace-nowrap pointer-events-none`,"aria-hidden":!0,children:e.title}),n&&a&&i?(0,R.jsx)(`span`,{className:`inline-block whitespace-nowrap file-mention-marquee`,children:Me(e.title,J)}):(0,R.jsx)(`span`,{className:`block truncate`,children:Me(r,J)})]}),e.trailingLabel?(0,R.jsx)(`span`,{className:b(`max-w-[40%] shrink-0 truncate text-muted-foreground`,q?`typography-micro`:`typography-meta`),children:e.trailingLabel}):null]}),e.subtitle?(0,R.jsx)(`div`,{className:b(`truncate text-muted-foreground`,q?`typography-micro`:`typography-meta`),children:Me(e.subtitle,J)}):null]})]},e.id)}),_e&&Le.length===0?(0,R.jsx)(`div`,{className:`flex items-center justify-center py-3`,children:(0,R.jsx)(F,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):null,!_e&&X.length===0&&(0,R.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:l(`chat.fileMentionAutocomplete.empty`)})]})}),!q&&(0,R.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:l(`chat.autocomplete.keyboardHint`)})]})}),Pe=new Set([`new`,`fork`,`compact`,`reload`,`undo`,`redo`,`model`,`btw`]),Y=(e,t)=>{if(!t||e.isSkill)return!1;let n=e.name?.trim().toLowerCase();return!!(n&&Pe.has(n))},Fe=(e,t)=>!e||t({name:e}),Ie=` `,Le=(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]===Ie&&e[r-2]===`/`&&(r-=2),e[r]===`/`?{start:r,end:n}:null},X=`text-[10px] leading-none uppercase font-bold tracking-tight px-1.5 py-1 rounded border flex-shrink-0`,Re=b(X,`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)]`),ze=b(X,`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)]`),Be=b(X,`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)]`),Ve=b(X,`bg-[var(--surface-muted)] text-muted-foreground border-[var(--interactive-border)]/60`),He=(e,t)=>e.length===t.length&&e.every((e,n)=>e.id===t[n]?.id&&e.description===t[n]?.description),Ue=e=>{let t=!!e.sessionID;return{hasSession:t,canStartSessionCommand:t||e.hasNewDraft}},We=L.forwardRef(({searchQuery:e,onCommandSelect:t,onClose:n,directory:i,style:a,commandPolicy:o,commandContext:s,onRowsChange:c},l)=>{let{t:u}=y(),d=p(e=>e.isMobile),f=k(e=>e.currentSessionId),m=k(e=>!!e.newSessionDraft?.open),h=k(L.useCallback(e=>f?e.getDirectoryForSession(f):void 0,[f])),g=D(f??``,h??void 0),_=L.useMemo(()=>s??{sessionID:f??null,hasMessages:g.length>0,hasNewDraft:m},[s,f,g.length,m]),{hasSession:v,canStartSessionCommand:x}=L.useMemo(()=>Ue(_),[_]),S=_.hasMessages,[C,ee]=L.useState([]),[te,ne]=L.useState(!1),w=O({directory:i}),re=L.useMemo(()=>w.data??[],[w.data]),ie=w.isFetching,[T,E]=L.useState(0),A=L.useRef(0),j=L.useRef(!1),ae=L.useRef([]),M=L.useRef(null),oe=L.useRef(!1),N=L.useRef(null),P=L.useRef(!1),se=L.useRef(null);L.useEffect(()=>{let e=e=>{let t=e.target;!t||!M.current||M.current.contains(t)||n()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[n]),L.useEffect(()=>{(async()=>{ne(ie);try{let t=re.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},...v&&!S?[{id:`yuri:init`,name:`init`,source:`yuri`,description:u(`chat.commandAutocomplete.command.initDescription`),isBuiltIn:!0}]:[],...v?[{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}]:[],...v?[{id:`yuri:summary`,name:`summary`,source:`yuri`,description:u(`chat.commandAutocomplete.command.summaryDescription`),isYuri:!0}]:[],...x?[{id:`yuri:workspace-review`,name:`workspace-review`,source:`yuri`,description:u(`chat.commandAutocomplete.command.workspaceReviewDescription`),isYuri:!0}]:[],...x?[{id:`yuri:craft-goal`,name:`craft-goal`,source:`yuri`,description:u(`chat.commandAutocomplete.command.craftGoalDescription`),isYuri:!0}]:[],...x?[{id:`yuri:catch-up`,name:`catch-up`,source:`yuri`,description:u(`chat.commandAutocomplete.command.catchUpDescription`),isYuri:!0}]:[],...x?[{id:`yuri:debug`,name:`debug`,source:`yuri`,description:u(`chat.commandAutocomplete.command.debugDescription`),isYuri:!0}]:[],...x?[{id:`yuri:weigh`,name:`weigh`,source:`yuri`,description:u(`chat.commandAutocomplete.command.weighDescription`),isYuri:!0}]:[],...x?[{id:`yuri:explore`,name:`explore`,source:`yuri`,description:u(`chat.commandAutocomplete.command.exploreDescription`),isYuri:!0}]:[],...t],i=!S,a=B(n.filter(e=>(i||e.name!==`init`)&&(o?.(e)??!0)),e);ee(e=>He(e,a)?e:a)}catch{let t=!S,n=B([{id:`yuri:new`,name:`new`,source:`yuri`,description:u(`chat.commandAutocomplete.command.newDescription`),isBuiltIn:!0},...v&&!S?[{id:`yuri:init`,name:`init`,source:`yuri`,description:u(`chat.commandAutocomplete.command.initDescription`),isBuiltIn:!0}]:[],...v?[{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}]:[],...v?[{id:`yuri:summary`,name:`summary`,source:`yuri`,description:u(`chat.commandAutocomplete.command.summaryDescription`),isYuri:!0}]:[],...x?[{id:`yuri:workspace-review`,name:`workspace-review`,source:`yuri`,description:u(`chat.commandAutocomplete.command.workspaceReviewDescription`),isYuri:!0}]:[],...x?[{id:`yuri:craft-goal`,name:`craft-goal`,source:`yuri`,description:u(`chat.commandAutocomplete.command.craftGoalDescription`),isYuri:!0}]:[],...x?[{id:`yuri:catch-up`,name:`catch-up`,source:`yuri`,description:u(`chat.commandAutocomplete.command.catchUpDescription`),isYuri:!0}]:[],...x?[{id:`yuri:debug`,name:`debug`,source:`yuri`,description:u(`chat.commandAutocomplete.command.debugDescription`),isYuri:!0}]:[],...x?[{id:`yuri:weigh`,name:`weigh`,source:`yuri`,description:u(`chat.commandAutocomplete.command.weighDescription`),isYuri:!0}]:[],...x?[{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);ee(e=>He(e,n)?e:n)}finally{ne(!1)}})()},[e,S,v,x,re,ie,u,o]),L.useEffect(()=>{E(0)},[C]),L.useEffect(()=>{A.current=T},[T]),L.useEffect(()=>{ae.current[T]?.scrollIntoView({block:`nearest`})},[T]),L.useEffect(()=>{Se(c,se,{rows:fe(C,{skill:u(`chat.commandAutocomplete.badge.skill`),command:u(`chat.commandAutocomplete.badge.command`),system:u(`chat.commandAutocomplete.badge.system`)}),highlightedIndex:T})},[C,c,T,u]);let ce=L.useRef(c);ce.current=c,L.useEffect(()=>()=>{Ce(ce.current,se)},[]),L.useImperativeHandle(l,()=>({acceptIndex:(e,n=!0)=>{let r=C[e];r&&t(r,Y(r,n))},handleKeyDown:e=>{let r=C.length;if(e===`Escape`){n();return}if(r!==0){if(e===`ArrowDown`){j.current=!0,E(e=>(e+1)%r);return}if(e===`ArrowUp`){j.current=!0,E(e=>(e-1+r)%r);return}if(e===`Enter`||e===`Tab`){let n=(A.current%r+r)%r,i=C[n];i&&t(i,Y(i,e===`Enter`))}}}}),[C,n,t]);let le=e=>{let t=de(e);switch(e.name){case`new`:return(0,R.jsx)(F,{name:t,className:`h-3.5 w-3.5`});case`init`:return(0,R.jsx)(F,{name:t,className:`h-3.5 w-3.5 text-green-500`});case`undo`:return(0,R.jsx)(F,{name:t,className:`h-3.5 w-3.5 text-orange-500`});case`redo`:return(0,R.jsx)(F,{name:t,className:`h-3.5 w-3.5 text-orange-500`});case`timeline`:case`reload`:return(0,R.jsx)(F,{name:t,className:`h-3.5 w-3.5`});case`compact`:return(0,R.jsx)(F,{name:t,className:`h-3.5 w-3.5 text-purple-500`});case`goal`:return(0,R.jsx)(F,{name:t,className:`h-3.5 w-3.5`});case`review`:return(0,R.jsx)(F,{name:t,className:`h-3.5 w-3.5 text-blue-500`});case`test`:case`build`:case`run`:return(0,R.jsx)(F,{name:t,className:`h-3.5 w-3.5 text-cyan-500`});default:return e.isBuiltIn?(0,R.jsx)(F,{name:t,className:`h-3.5 w-3.5 text-yellow-500`}):(0,R.jsx)(F,{name:t,className:`h-3.5 w-3.5 text-muted-foreground`})}};return(0,R.jsxs)(pe,{ref:M,isMobile:d,className:`max-w-[450px] max-h-64`,style:a,children:[(0,R.jsx)(ge,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0 py-1.5`,children:te?(0,R.jsx)(`div`,{className:`flex items-center justify-center py-4`,children:(0,R.jsx)(F,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):(0,R.jsxs)(`div`,{children:[C.map((n,r)=>{let i=n.isBuiltIn,a=n.isYuri;return(0,R.jsxs)(`div`,{ref:e=>{ae.current[r]=e},className:b(`flex gap-2 px-2 py-2 cursor-pointer rounded-lg`,d?`items-center`:`items-start`,me(d,r===T),!d&&r===T&&`bg-interactive-selection/35`),onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&(N.current={x:e.clientX,y:e.clientY},P.current=!1)},onPointerMove:e=>{if(e.pointerType!==`touch`||!N.current)return;let t=e.clientX-N.current.x,n=e.clientY-N.current.y;Math.hypot(t,n)>6&&(P.current=!0)},onPointerUp:e=>{if(e.pointerType!==`touch`)return;let r=P.current;N.current=null,P.current=!1,!r&&(e.preventDefault(),e.stopPropagation(),oe.current=!0,t(n,Y(n,d)))},onPointerCancel:()=>{N.current=null,P.current=!1},onClick:()=>{if(oe.current){oe.current=!1;return}t(n,Y(n,d))},onMouseMove:()=>{j.current=!1,E(r)},children:[(0,R.jsx)(`div`,{className:b(!d&&`mt-0.5`),children:le(n)}),(0,R.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsxs)(`span`,{className:`typography-ui-label font-medium`,children:[`/`,Me(n.name,e)]}),n.isSkill?(0,R.jsx)(`span`,{className:Re,children:u(`chat.commandAutocomplete.badge.skill`)}):(0,R.jsx)(`span`,{className:Re,children:u(`chat.commandAutocomplete.badge.command`)}),a?(0,R.jsx)(`span`,{className:Ve,children:`Yuri`}):i?(0,R.jsx)(`span`,{className:Ve,children:u(`chat.commandAutocomplete.badge.system`)}):n.scope?(0,R.jsx)(`span`,{className:n.scope===`project`?Be:ze,children:n.scope}):null,n.agent&&(0,R.jsx)(`span`,{className:Ve,children:n.agent})]}),n.description&&!d&&(0,R.jsx)(`div`,{className:`typography-meta text-muted-foreground mt-0.5 truncate`,children:Me(n.description,e)})]})]},n.id)}),C.length===0&&(0,R.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:u(`chat.commandAutocomplete.empty`)})]})}),!d&&(0,R.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:u(`chat.autocomplete.keyboardHint`)})]})});We.displayName=`CommandAutocomplete`;var Ge=e=>e instanceof Error?e.name===`AbortError`||e.name===`CancelledError`||e.name===`Error`&&e.message===`CancelledError`:!1,Ke=1e4,qe=6e4,Je=5e3,Ye=3e4,Xe=6e4,Ze=25,Qe=40,$e=2,et=15e3,tt=500,nt=30,rt=20971520,it=new Map,at=new Map,ot=new Map,st=new Map,ct=new Map,lt=new Map,ut=new WeakMap,dt=e=>{let t=ut.get(e);return t||(t=new Set(e.files.map(e=>e.path)),ut.set(e,t)),t},ft=(e,t)=>`${t}:${e}`,pt=e=>at.get(e)??0,mt=e=>{let t=pt(e)+1;return at.set(e,t),t},ht=e=>{let t=(ot.get(e)??0)+1;return ot.set(e,t),t},gt=e=>{let t=it.get(e);if(t)return t;let n=new Set;return it.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}),_t=(e,t=nt,n=rt)=>{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},vt=(e,t)=>!e&&!t?!1:!e||!t||e.remote!==t.remote||e.branch!==t.branch||e.ahead!==t.ahead||e.behind!==t.behind,yt=e=>{let t=e?.trim()??``;return t===`?`?``:t},bt=(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&&vt(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),yt(e.index)&&(r=!0);continue}a.delete(e.path),(t.index!==e.index||t.working_dir!==e.working_dir)&&n.add(e.path),!r&&yt(t.index)!==yt(e.index)&&(r=!0)}for(let[e,t]of a)n.add(e),yt(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}},xt=e=>!e||e.trim().length===0,St=e=>(e||``).trim()===`U`,Ct=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(St(t)||St(n))return e;let r=t===`?`||n===`?`?`A`:t||n||` `;return{...e,index:r,working_dir:` `}},wt=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(St(t)||St(n))return e;let r=n||(t===`A`||t===`?`?`?`:t)||` `;return{...e,index:` `,working_dir:r}},Tt=e=>xt(e.index)&&xt(e.working_dir),Q=i()(o((e,t)=>({directories:new Map,activeDirectory:null,setActiveDirectory:n=>{let{activeDirectory:r,directories:i}=t();if(r!==n)if(r&&mt(r),n&&mt(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=ft(n,a),s=st.get(o)??(a===`light`?st.get(ft(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)>qe,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=lt.get(n),p=f?.received===u&&f.stored===d.status?null:bt(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&&mt(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}),lt.set(n,{received:u,stored:m})}else{lt.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})();st.set(o,c);try{return await c}finally{st.get(o)===c&&st.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`?Ct(e):wt(e);t!==e&&(l=!0),Tt(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=ht(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 te(r,i,void 0,o):await T(r,i,void 0,o);if(s!==ot.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(Ge(i)||console.error(`Failed to fetch git branches:`,i),s!==ot.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>Ke||!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=_t(s);a.set(n,{...o,diffCache:c}),e({directories:a})},clearDiffCache:n=>{mt(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,Ze);await t().prefetchDiffs(e,n,i,{maxFiles:Ze})},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=Qe}=a,c=Math.min(Math.max(1,s),nt),l=dt(o.status),u=o.status.diffStats,d=gt(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>tt||(p.add(e),!o.diffCache.has(e)&&(d.has(e)||f.push(e)))}let m=f;if(m.length===0)return;let h=pt(n);if(typeof document<`u`&&document.hidden)return;m.forEach(e=>d.add(e));let g=0,_=[],v=()=>{let e=g;return g+=1,e<m.length?m[e]:null},y=async e=>{let t=r.getGitFileDiff(n,{path:e}),i=new Promise((e,t)=>{setTimeout(()=>t(Error(`Timed out after ${et}ms`)),et)}),a=await Promise.race([t,i]);return{path:e,diff:{original:a.original??``,modified:a.modified??``,isBinary:a.isBinary}}},b=async()=>{for(;;){if(h!==pt(n))return;let e=v();if(!e)return;try{_.push(await y(e))}catch{}finally{d.delete(e)}}},x=Math.min($e,m.length);if(await Promise.allSettled(Array.from({length:x},()=>b())),m.forEach(e=>d.delete(e)),h!==pt(n))return;let S=new Map(t().directories),C=S.get(n);if(!C)return;let ee=new Map(C.diffCache),te=Date.now();_.forEach(e=>{!e.diff.isBinary&&e.diff.original===``&&e.diff.modified===``||ee.set(e.path,{...e.diff,fetchedAt:te})});let ne=_t(ee);S.set(n,{...C,diffCache:ne}),e({directories:S})},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<Je||await t().fetchStatus(e,n,{silent:!!r?.status})},ensureAll:(e,n)=>{let r=ct.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)>=Je)&&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>=Ye)&&o.push(t().fetchBranches(e,n)),(!a.log||i-a.lastLogFetch>=Ke)&&o.push(t().fetchLog(e,n)),(!a.identity||i-a.lastIdentityFetch>=Xe)&&o.push(t().fetchIdentity(e,n)),o.length>0&&await Promise.all(o)})();return ct.set(e,i),i.finally(()=>{ct.get(e)===i&&ct.delete(e)}),i},refresh:async(e,n={})=>{let{activeDirectory:r}=t();r&&await t().fetchAll(r,e,n)}}),{name:`git-store`})),Et=e=>{let t=(0,I.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)},Dt=e=>{let r=(0,I.c)(3),i=L.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)},Ot=e=>{let t=(0,I.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)},kt=e=>{let t=(0,I.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)},At=e=>{let t=(0,I.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)},jt=e=>{let t=(0,I.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=new Map,t[0]=n):n=t[0];let r=L.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)},Mt=e=>{let t=(0,I.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)},Nt=e=>{let t=(0,I.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)},Pt=e=>{let t=(0,I.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)},Ft=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\//,``),It=e=>e.branchName?$(e.branchName):e.mode===`existing`?$(e.existingBranch||e.preferredName||``):$(e.preferredName||``),Lt=async e=>{let t=await _e(e);try{let n=Ft((await ce(e)).branches?.[t]?.tracking||null);if(n?.remote)return n.remote}catch{}try{let t=Ft((await le(e)).tracking);if(t?.remote)return t.remote}catch{}return null},Rt=async(e,t)=>{let n=await Lt(e),r=$(t);return!n||!r?null:{setUpstream:!0,upstreamRemote:n,upstreamBranch:r}},zt=async(e,t,n)=>{let r=It(t),i=n?.resolvedRootTrackingRemote,a=i===void 0?await Rt(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},Bt=async(e,t,n)=>{let r=await zt(e.path,t,n);return ve(e,r)},Vt=`yuri:lastWorktreeSourceBranch`,Ht=({mode:e,sourceBranch:t,linkedPr:n,selectedBranch:r})=>e===`existing-branch`?r||null:n?null:t||null,Ut=({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},Wt=(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?` `:``}`},Gt=(e,t,n)=>{let r=Wt(e,t,n);return`${t.length===0&&!/^\s/.test(r)?` `:``}${r}${n.length===0&&!/\s$/.test(r)?` `:``}`},Kt=(e,t,n,r)=>{let i=e.slice(0,t),a=e.slice(n),o=Gt(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}},qt=(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]},Jt=(e,t)=>t<e.length&&e[t]===` `?t+1:t;export{Fe as C,Te as D,Ee as E,xe as O,Le as S,De as T,jt as _,Vt as a,kt as b,Bt as c,At as d,Dt as f,Ot as g,Mt as h,Gt as i,z as k,Lt as l,Nt as m,qt as n,Ut as o,Pt as p,Kt as r,Ht as s,Jt as t,zt as u,Et as v,Ne as w,We as x,Q as y};