@yuriai/web 0.3.5 → 0.3.6-beta.5

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 (170) hide show
  1. package/dist/assets/{AgentAvatar-CNOu_vy0.js → AgentAvatar-BaKbuiEG.js} +1 -1
  2. package/dist/assets/{AgentSelector-K5JSbXv3.js → AgentSelector-BXLvdwk0.js} +1 -1
  3. package/dist/assets/{ArchivedSessionsDialog-CU9RXl8K.js → ArchivedSessionsDialog-wIl8A7HL.js} +1 -1
  4. package/dist/assets/{AssistantConversationSurface-u3ndSmZP.js → AssistantConversationSurface-DRwJ4zWe.js} +3 -3
  5. package/dist/assets/{AssistantSessionCard-MYBAni6A.js → AssistantSessionCard-D1AZs8JQ.js} +2 -2
  6. package/dist/assets/{AssistantUnreadBadge-opyLZlZd.js → AssistantUnreadBadge-4aoNcXVG.js} +1 -1
  7. package/dist/assets/{AssistantView-CDPTtrUZ.js → AssistantView-CG0DnE1H.js} +1 -1
  8. package/dist/assets/{AssistantWorkingAvatar-Vghb8xlt.js → AssistantWorkingAvatar-uOBMRhP_.js} +1 -1
  9. package/dist/assets/{AssistantsSettingsPage-Dt4OP3J-.js → AssistantsSettingsPage-DIWJVEf8.js} +1 -1
  10. package/dist/assets/{BinaryFileFallback-CJqnlBzh.js → BinaryFileFallback-BH_-EIjs.js} +1 -1
  11. package/dist/assets/{BtwPanel-DnMW6R43.js → BtwPanel-DRdap4Qu.js} +1 -1
  12. package/dist/assets/{BusyDots-FXSlMe2F.js → BusyDots-BGjLnIPh.js} +1 -1
  13. package/dist/assets/{ChatContainer-Dg9uDBjk.js → ChatContainer-BtfbvM1R.js} +4 -4
  14. package/dist/assets/{ChatView-AFUNEBdD.js → ChatView-CUwLwCFl.js} +1 -1
  15. package/dist/assets/{DiagramView-j7aFp44v.js → DiagramView-CRZFpG4-.js} +1 -1
  16. package/dist/assets/{DiffView-DZ_gKyTO.js → DiffView-4Z0aCFfu.js} +1 -1
  17. package/dist/assets/{DiffViewToggle-DkxhEUhV.js → DiffViewToggle-DYSI03aW.js} +1 -1
  18. package/dist/assets/{ErrorBoundary-CCH4LiRY.js → ErrorBoundary-CinEsvgD.js} +1 -1
  19. package/dist/assets/{FadeInOnReveal-DO9PZrJL.js → FadeInOnReveal-P-c7VO7Q.js} +1 -1
  20. package/dist/assets/{GuiPluginMount-BCqt2pmM.js → GuiPluginMount-DtJaOBdU.js} +1 -1
  21. package/dist/assets/{GuiPluginPage-BSjWEmIu.js → GuiPluginPage-DSeGfoT6.js} +1 -1
  22. package/dist/assets/{GuiPluginSurface-B8QjacMd.js → GuiPluginSurface-357Sz83f.js} +1 -1
  23. package/dist/assets/{GuiPluginTitlebarItems-DfHugxsx.js → GuiPluginTitlebarItems-XIPpX6DU.js} +1 -1
  24. package/dist/assets/{GuiPluginWindow-CDycMqzT.js → GuiPluginWindow-ICodvkoO.js} +1 -1
  25. package/dist/assets/{Icon-B-w2YKpn.js → Icon-CeG6IExS.js} +1 -1
  26. package/dist/assets/{ImageLoadingPlaceholder-DsgRtfYG.js → ImageLoadingPlaceholder-zzKCgcZz.js} +1 -1
  27. package/dist/assets/{LoadingImage-B3IL7hnv.js → LoadingImage-B4Icoej_.js} +1 -1
  28. package/dist/assets/MarkdownRenderer-Bjm6Wld2.js +2 -0
  29. package/dist/assets/{MarkdownRendererImpl-CPgpkd9b.js → MarkdownRendererImpl-BdOA-vAV.js} +1 -1
  30. package/dist/assets/{MarkstreamRendererImpl-BzK1BO80.js → MarkstreamRendererImpl-j30G11Dc.js} +1 -1
  31. package/dist/assets/{MobileAssistantSettingsPage-DVpE3b24.js → MobileAssistantSettingsPage-CGK1ceah.js} +1 -1
  32. package/dist/assets/{MobileAssistantTab-BbccE67x.js → MobileAssistantTab-ZugumKSY.js} +1 -1
  33. package/dist/assets/{MobileBtwPage-BRN1gAmR.js → MobileBtwPage-afopNi2T.js} +1 -1
  34. package/dist/assets/{MobileChangesSurface-BwmSTxeh.js → MobileChangesSurface-C3mhr7en.js} +1 -1
  35. package/dist/assets/{MobileChatScreen-Bf42GrQ8.js → MobileChatScreen-ByOiuFAV.js} +1 -1
  36. package/dist/assets/{MobileDetailNavigation-DKWnQoSh.js → MobileDetailNavigation-IQDDP6TO.js} +1 -1
  37. package/dist/assets/{MobileFilesSurface-qkfC06Oh.js → MobileFilesSurface-Bia8vPcg.js} +2 -2
  38. package/dist/assets/{MobileHtmlNetworkBoundary-BKSYPR9N.js → MobileHtmlNetworkBoundary-DCiTI-t-.js} +2 -2
  39. package/dist/assets/{MobileOverlayPanel-DcRWQlmf.js → MobileOverlayPanel-D0W5tjrd.js} +1 -1
  40. package/dist/assets/{MobileResizableSheet-CF3Pbot4.js → MobileResizableSheet-0fdiGkg0.js} +1 -1
  41. package/dist/assets/{MobileSettingsTab-of6zpTsr.js → MobileSettingsTab-iPLVIfcN.js} +1 -1
  42. package/dist/assets/{MobileShareBridge-CRq9F1rn.js → MobileShareBridge-DzcR4Knr.js} +1 -1
  43. package/dist/assets/{MobileSurface-DGNomvlu.js → MobileSurface-B1fG72a-.js} +1 -1
  44. package/dist/assets/{MobileTabPageHeader-0aJFe3_x.js → MobileTabPageHeader-BFKAUrAU.js} +1 -1
  45. package/dist/assets/{ModelLogo-D27dq-si.js → ModelLogo-CYR-ynHM.js} +1 -1
  46. package/dist/assets/{ModelSelector-Dg__8QLh.js → ModelSelector-B3h2Xy64.js} +1 -1
  47. package/dist/assets/{MultiRunWindow-COqSg1Nk.js → MultiRunWindow-C8S7H7Md.js} +1 -1
  48. package/dist/assets/{OnboardingScreen-DUNyDwc6.js → OnboardingScreen-D7fZQm8c.js} +1 -1
  49. package/dist/assets/{OverlayScrollbar-DS6XJ1HA.js → OverlayScrollbar-C5v7GRZi.js} +1 -1
  50. package/dist/assets/{PierreDiffViewer-BHwj_6j8.js → PierreDiffViewer-CxRfGY_b.js} +1 -1
  51. package/dist/assets/{ProviderLogo-Cm9RNV_U.js → ProviderLogo-zqjvjfIK.js} +1 -1
  52. package/dist/assets/{RemoteAssistantSessionCard-DAjHRUrC.js → RemoteAssistantSessionCard-B284CHHf.js} +1 -1
  53. package/dist/assets/{RemoteDesktopPanel-Bays6pHh.js → RemoteDesktopPanel-CREalB4m.js} +1 -1
  54. package/dist/assets/{ScheduledTasksDialog-DnwBC7cj.js → ScheduledTasksDialog-YAy5JZVs.js} +1 -1
  55. package/dist/assets/{ScrollableOverlay-CkX-buJm.js → ScrollableOverlay-BGOUZmbS.js} +1 -1
  56. package/dist/assets/{SettingsGroup-kZ_faXwL.js → SettingsGroup-BoEy2EFq.js} +1 -1
  57. package/dist/assets/{SettingsView-C62JngPE.js → SettingsView-cLTUC0DF.js} +1 -1
  58. package/dist/assets/{SettingsWindow-Cm8apHAR.js → SettingsWindow-Kp2ClVgJ.js} +1 -1
  59. package/dist/assets/{SetupTourDialog-W_UeWH-i.js → SetupTourDialog-DNb6i2Z1.js} +1 -1
  60. package/dist/assets/{SyncActions-Blnq08ks.js → SyncActions-D7uIFrJB.js} +1 -1
  61. package/dist/assets/{TerminalView-CMugifkh.js → TerminalView-viydTW0Q.js} +1 -1
  62. package/dist/assets/{TextSelectionMenu-B2fIBlD3.js → TextSelectionMenu-B3RIGNm7.js} +1 -1
  63. package/dist/assets/{ToolOutputDialog-DdSUE2kP.js → ToolOutputDialog-CoGamWCH.js} +1 -1
  64. package/dist/assets/{YuriLogo-Ceon25sC.js → YuriLogo-_1Inxw8P.js} +1 -1
  65. package/dist/assets/{assistantMessagePreview-C7YAFen1.js → assistantMessagePreview-CDdckvGJ.js} +1 -1
  66. package/dist/assets/{assistantQueries-DxvTFlpL.js → assistantQueries-DKqpPYqd.js} +1 -1
  67. package/dist/assets/{auto-read-context-Ce0o43YI.js → auto-read-context-G7T0GxFZ.js} +1 -1
  68. package/dist/assets/{capgoAdapter-DQwUA-Nt.js → capgoAdapter-Cu4rw1AP.js} +1 -1
  69. package/dist/assets/{card-D44sTpdY.js → card-BBxZ1WhJ.js} +1 -1
  70. package/dist/assets/{chatUpwardIntent-CnS7WWRL.js → chatUpwardIntent-DmVhPEhT.js} +1 -1
  71. package/dist/assets/{checkbox-DaKe0Tlq.js → checkbox-D9uVg1CM.js} +1 -1
  72. package/dist/assets/{collapsible-CL3SPnOf.js → collapsible-_BAnUguY.js} +1 -1
  73. package/dist/assets/{connection-hint-SMNZFDAe.js → connection-hint-BnhKxvRb.js} +1 -1
  74. package/dist/assets/{context-menu-DZunhC8o.js → context-menu-j9GOycjo.js} +1 -1
  75. package/dist/assets/{diagram-DFXqN638.js → diagram-B4DOrQoy.js} +1 -1
  76. package/dist/assets/{dialog-CmjXOKMz.js → dialog-CZlghHCF.js} +1 -1
  77. package/dist/assets/{dropdown-menu-BT_66BFT.js → dropdown-menu-C-MjrLjA.js} +1 -1
  78. package/dist/assets/{es-DqYZgeC6.js → es-BxH-QWNw.js} +1 -1
  79. package/dist/assets/{fileMentionTouchSelection-B_62hIQI.js → fileMentionTouchSelection-Dv6PCS5x.js} +1 -1
  80. package/dist/assets/{fileReferenceActions-TmbrIHBI.js → fileReferenceActions-B2jCazPJ.js} +1 -1
  81. package/dist/assets/{fr-BHaun7Zq.js → fr-BuXhxsLA.js} +1 -1
  82. package/dist/assets/{gitApi-CBfYFgtd.js → gitApi-BnZcCLpz.js} +1 -1
  83. package/dist/assets/gitApiHttp-DF1ID314.js +3 -0
  84. package/dist/assets/{i18n-Dojvs57M.js → i18n-BcqhT5IQ.js} +1 -1
  85. package/dist/assets/{icons-D_vRtitD.js → icons-BjKhmiUB.js} +1 -1
  86. package/dist/assets/{input-BllFKOjo.js → input-CK6ESZJN.js} +1 -1
  87. package/dist/assets/{insertionBoundaries-Br0Bdl9R.js → insertionBoundaries-CD1bfNQI.js} +1 -1
  88. package/dist/assets/{ja-BGNugvrx.js → ja-qWngDHZr.js} +1 -1
  89. package/dist/assets/{kbd-CwkasrzN.js → kbd-DqpD1Z1W.js} +1 -1
  90. package/dist/assets/{ko-CGbNBfDe.js → ko-CSKPW13b.js} +1 -1
  91. package/dist/assets/{main-B7wAfq9F.js → main-buUrzK21.js} +2 -2
  92. package/dist/assets/{main-DVmi0I-y.js → main-wnAp11Lg.js} +21 -21
  93. package/dist/assets/{markdownHeightCache-RX04MAqu.js → markdownHeightCache-B5NINUfB.js} +1 -1
  94. package/dist/assets/{mcpQueries-qRW-HQMx.js → mcpQueries-CEyM57ph.js} +1 -1
  95. package/dist/assets/miniChat-DDuanxyB.js +2 -0
  96. package/dist/assets/mobile-CL1PHr-g.js +2 -0
  97. package/dist/assets/{mobileBackNavigation-DsDUTnFY.js → mobileBackNavigation-Cqz28R4e.js} +1 -1
  98. package/dist/assets/{mobileConnections-PVy2SsQ_.js → mobileConnections-DBVkkjN_.js} +2 -2
  99. package/dist/assets/{multirun-C2RRF2Q3.js → multirun-CG2iQzs1.js} +1 -1
  100. package/dist/assets/{native-config-Czc142JT.js → native-config-q8-2XVGB.js} +1 -1
  101. package/dist/assets/{nativeComposerCover-DzEGSyOO.js → nativeComposerCover-X18Rxy9s.js} +1 -1
  102. package/dist/assets/{navigation-C1v9hIAT.js → navigation-B17JP7Nc.js} +1 -1
  103. package/dist/assets/{openRemoteProjectSession-C5z2Juv7.js → openRemoteProjectSession-B2oJdHC6.js} +1 -1
  104. package/dist/assets/{pl-k8-4URiE.js → pl-ON0IoadC.js} +1 -1
  105. package/dist/assets/{pluginPresentation-p_0sXPMT.js → pluginPresentation-OcngX2e8.js} +1 -1
  106. package/dist/assets/{pt-BR-DdwCzXBH.js → pt-BR-BAekLJyC.js} +1 -1
  107. package/dist/assets/{pwa-Br2HZksc.js → pwa-dfKnHt2U.js} +1 -1
  108. package/dist/assets/{queue-abort-optimistic-DciJN9X1.js → queue-abort-optimistic-CIugRVbT.js} +1 -1
  109. package/dist/assets/{quota-2PwXAoIg.js → quota-BpQX7Pfg.js} +1 -1
  110. package/dist/assets/{reference-history-BwtzPAmA.js → reference-history-Dk7Uz1e9.js} +1 -1
  111. package/dist/assets/{remoteSessionReference-XfJOxItc.js → remoteSessionReference-DL-cFaU4.js} +1 -1
  112. package/dist/assets/{renderElectronMiniChatApp-BekZAu-s.js → renderElectronMiniChatApp-D-qMtvJ5.js} +2 -2
  113. package/dist/assets/{renderMobileApp-C5U2cyeq.js → renderMobileApp-DE4dovZy.js} +5 -5
  114. package/dist/assets/{runtimeConfig-DzYIc49M.js → runtimeConfig-Bto7mqiH.js} +1 -1
  115. package/dist/assets/{runtimeEndpointReset-BKLVdNhJ.js → runtimeEndpointReset-C41HR0MC.js} +3 -3
  116. package/dist/assets/{scheduledTaskNavigation-VVTOq9n2.js → scheduledTaskNavigation-qCB0nuyR.js} +1 -1
  117. package/dist/assets/{select-BOtGs1FV.js → select-DsqFxij6.js} +1 -1
  118. package/dist/assets/{sessionLookup-BTQ_AtWh.js → sessionLookup-BL43L4KX.js} +1 -1
  119. package/dist/assets/sessionOwnership-CoFyzErn.js +2 -0
  120. package/dist/assets/{shortcuts-Cu4ioDvH.js → shortcuts-CS2j7q63.js} +1 -1
  121. package/dist/assets/{sortable-tabs-strip-DACGW9sB.js → sortable-tabs-strip-DiIB2-kp.js} +1 -1
  122. package/dist/assets/{speechSettingsQueries-BU-4Axb5.js → speechSettingsQueries-DXlNIuv5.js} +1 -1
  123. package/dist/assets/src-DYCPWwUH.css +2 -0
  124. package/dist/assets/{store-DRUKTpV5.js → store-BHq6XijA.js} +2 -2
  125. package/dist/assets/{switch-DaUn0G3u.js → switch-C-h9UNYt.js} +1 -1
  126. package/dist/assets/{terminalApi-ClNhXBA8.js → terminalApi-2TIqWX2z.js} +1 -1
  127. package/dist/assets/{textarea-IhQHekYx.js → textarea-DjSTlLEk.js} +1 -1
  128. package/dist/assets/{timeFormat-BsuUDWLs.js → timeFormat-CPklO4G4.js} +1 -1
  129. package/dist/assets/{tooltip-Dw3DApa-.js → tooltip-mPnbOruE.js} +1 -1
  130. package/dist/assets/{truncated-path-KHrfQ66P.js → truncated-path-DJ1GdoM1.js} +1 -1
  131. package/dist/assets/types-DjjmI1B9.js +2 -0
  132. package/dist/assets/{ui-CHdferA1.js → ui-Cd2-HQSa.js} +6 -6
  133. package/dist/assets/{uk-DU-7fAP4.js → uk-CV7mskVO.js} +1 -1
  134. package/dist/assets/{useAppFontEffects-Dw6o6XbA.js → useAppFontEffects-mOLMhLug.js} +3 -3
  135. package/dist/assets/{useAssistantUIStore-CpJZ4Rqs.js → useAssistantUIStore-AI2LkqlQ.js} +1 -1
  136. package/dist/assets/{useDesktopWindowControlsLayout-DAkTdcAP.js → useDesktopWindowControlsLayout-BC62ly7f.js} +1 -1
  137. package/dist/assets/{useDictation-sdgDfATy.js → useDictation-D8v7PflM.js} +1 -1
  138. package/dist/assets/{useEffectiveDirectory-DZqC-2HE.js → useEffectiveDirectory-CCVmwzs7.js} +1 -1
  139. package/dist/assets/{useFontPreferences-Bb-bxdL8.js → useFontPreferences-DB18Mtz6.js} +1 -1
  140. package/dist/assets/{useGitStore-Bbmai549.js → useGitStore-Bab2zave.js} +1 -1
  141. package/dist/assets/{useInlineCommentDraftStore-DrC99u6A.js → useInlineCommentDraftStore-DAYe4P_i.js} +1 -1
  142. package/dist/assets/{useMcpConfigStore-ZsZxSrCt.js → useMcpConfigStore-BJm6513j.js} +1 -1
  143. package/dist/assets/{useMobileSwipeActions-fUp7Bkbn.js → useMobileSwipeActions-D0WXnZEj.js} +1 -1
  144. package/dist/assets/{useMobileTranscriptSyncHint-B4izCfqe.js → useMobileTranscriptSyncHint-CG4nKZAr.js} +1 -1
  145. package/dist/assets/{useModelLists-B0qSYDby.js → useModelLists-BimLCgIE.js} +1 -1
  146. package/dist/assets/{useOpenCodeReadiness-B9d-wLZB.js → useOpenCodeReadiness-DXkY7-Jm.js} +1 -1
  147. package/dist/assets/{usePluginsStore-BLncdNj-.js → usePluginsStore-C69K4oDx.js} +1 -1
  148. package/dist/assets/{useProjectGitActions-CHMe1ku4.js → useProjectGitActions-DVpxGjd_.js} +1 -1
  149. package/dist/assets/{useProjectGitStore-Lz9AV32V.js → useProjectGitStore-tqdyts8E.js} +1 -1
  150. package/dist/assets/{useProjectRuntimeAPIs-D51dVo-V.js → useProjectRuntimeAPIs-3ykZWBEc.js} +1 -1
  151. package/dist/assets/{useQuotaStore-mZs9LTwx.js → useQuotaStore-B3QxYEfM.js} +1 -1
  152. package/dist/assets/{useSessionBtwStore-CYaTDkvT.js → useSessionBtwStore-LV6b9oRF.js} +1 -1
  153. package/dist/assets/{useStreamingTextThrottle-ul6e3dUd.js → useStreamingTextThrottle-ClWAbNdQ.js} +1 -1
  154. package/dist/assets/{useUIStore-C3ewjGgP.js → useUIStore-Dzf_W6hZ.js} +1 -1
  155. package/dist/assets/{worktreeManager-V6hoSVxH.js → worktreeManager-CZpGApxy.js} +1 -1
  156. package/dist/assets/{worktreeSourceBranchPreference-MQFPkOZy.js → worktreeSourceBranchPreference-CyrpQH5R.js} +1 -1
  157. package/dist/assets/{zh-CN-DOHH7nht.js → zh-CN-D9xdLrNm.js} +1 -1
  158. package/dist/assets/{zh-TW-t1qlXGOg.js → zh-TW-Dyiv4-Dr.js} +1 -1
  159. package/dist/index.html +9 -9
  160. package/dist/mini-chat.html +9 -9
  161. package/dist/mobile.html +2 -2
  162. package/package.json +1 -1
  163. package/server/lib/opencode/settings-helpers.js +4 -0
  164. package/dist/assets/MarkdownRenderer-CsEylQVj.js +0 -2
  165. package/dist/assets/gitApiHttp-Bswf6gnl.js +0 -3
  166. package/dist/assets/miniChat-D7-JQ1hw.js +0 -2
  167. package/dist/assets/mobile-BFQBDlo9.js +0 -2
  168. package/dist/assets/sessionOwnership-BPfk1qCS.js +0 -2
  169. package/dist/assets/src-Dj147H4m.css +0 -2
  170. package/dist/assets/types-BBBwzIOU.js +0 -2
@@ -1,4 +1,4 @@
1
- import{n as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,n}from"./runtime-switch-DEPKHgdL.js";import{n as r}from"./runtime-fetch-V-iMWR8t.js";import{t as i}from"./runtimeAPIRegistry-C2VogTny.js";import{$ as a,A as o,B as s,D as c,E as l,F as u,G as d,H as f,I as p,J as m,K as ee,L as te,M as ne,N as re,O as ie,P as ae,Q as oe,R as se,S as ce,T as le,U as ue,V as de,W as h,X as fe,Y as pe,Z as me,_ as he,_t as ge,a as _e,at as ve,b as ye,bt as be,c as xe,ct as Se,d as Ce,dt as we,et as Te,f as Ee,ft as De,g as Oe,gt as ke,h as Ae,ht as je,i as Me,it as Ne,j as g,k as Pe,l as Fe,lt as Ie,m as Le,mt as Re,n as ze,nt as Be,o as Ve,ot as He,p as Ue,pt as We,q as Ge,r as Ke,rt as qe,s as Je,st as Ye,t as Xe,tt as Ze,u as Qe,ut as $e,v as et,vt as tt,x as nt,y as rt,yt as it,z as at}from"./gitApiHttp-Bswf6gnl.js";import{n as ot}from"./client-ITylDDCS.js";import{Yi as _,f as v,l as st}from"./ui-CHdferA1.js";var y=`/api/magic-prompts`,ct=new Map([{id:`git.commit.generate.visible`,title:`Commit Generation Visible Prompt`,group:`Git`,description:`Visible user message for commit message generation.`,template:`You are generating a Conventional Commits subject line from the diffs of the selected files.`},{id:`git.commit.generate.instructions`,title:`Commit Generation Instructions`,group:`Git`,description:`Hidden instructions for commit message generation.`,placeholders:[{key:`selected_files`,description:`Bullet list of currently selected file paths.`}],template:`Return exactly one JSON object and nothing else. Do not include prose, markdown, explanations, or code fences.
1
+ import{n as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,n}from"./runtime-switch-DEPKHgdL.js";import{n as r}from"./runtime-fetch-V-iMWR8t.js";import{t as i}from"./runtimeAPIRegistry-C2VogTny.js";import{$ as a,A as o,B as s,D as c,E as l,F as u,G as d,H as f,I as p,J as m,K as ee,L as te,M as ne,N as re,O as ie,P as ae,Q as oe,R as se,S as ce,T as le,U as ue,V as de,W as h,X as fe,Y as pe,Z as me,_ as he,_t as ge,a as _e,at as ve,b as ye,bt as be,c as xe,ct as Se,d as Ce,dt as we,et as Te,f as Ee,ft as De,g as Oe,gt as ke,h as Ae,ht as je,i as Me,it as Ne,j as g,k as Pe,l as Fe,lt as Ie,m as Le,mt as Re,n as ze,nt as Be,o as Ve,ot as He,p as Ue,pt as We,q as Ge,r as Ke,rt as qe,s as Je,st as Ye,t as Xe,tt as Ze,u as Qe,ut as $e,v as et,vt as tt,x as nt,y as rt,yt as it,z as at}from"./gitApiHttp-DF1ID314.js";import{n as ot}from"./client-ITylDDCS.js";import{Yi as _,f as v,l as st}from"./ui-Cd2-HQSa.js";var y=`/api/magic-prompts`,ct=new Map([{id:`git.commit.generate.visible`,title:`Commit Generation Visible Prompt`,group:`Git`,description:`Visible user message for commit message generation.`,template:`You are generating a Conventional Commits subject line from the diffs of the selected files.`},{id:`git.commit.generate.instructions`,title:`Commit Generation Instructions`,group:`Git`,description:`Hidden instructions for commit message generation.`,placeholders:[{key:`selected_files`,description:`Bullet list of currently selected file paths.`}],template:`Return exactly one JSON object and nothing else. Do not include prose, markdown, explanations, or code fences.
2
2
 
3
3
  The JSON object must have exactly this shape:
4
4
  {"subject": string, "highlights": string[]}
@@ -0,0 +1,3 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{C as t,D as n,k as r}from"./runtime-auth-DA-qfGHk.js";import{c as i,f as a,i as o,n as s,s as c}from"./runtime-switch-DEPKHgdL.js";import{n as l}from"./runtime-fetch-V-iMWR8t.js";import{F as u,P as d,R as f,S as p,d as m}from"./platform-CiUKDeXd.js";import{t as h}from"./runtimeAPIRegistry-C2VogTny.js";import{a as g,i as ee,r as _}from"./vendor-zustand-CTekDqaS.js";import{st as te}from"./vendor-base-ui-wXsskyKm.js";import"./brand-storage-bootstrap-D4BW3w-M.js";import{i as ne,n as v,t as re}from"./safeStorage-DTOhKN0V.js";import{Cr as y,R as ie,Sr as ae,n as b,xr as oe}from"./client-ITylDDCS.js";import{A as se,F as ce,I as le,L as ue,M as de,N as fe,T as pe,V as me,f as he,g as ge,h as _e,j as ve,m as ye,p as be,x}from"./prompt-attachment-upload-BGppTOgV.js";import{n as xe}from"./vendor-react-BkccXcWz.js";import{q as Se}from"./runtime-file-resource-C5kmYlLv.js";import{_ as Ce,c as we,l as Te,r as S,v as Ee}from"./useUIStore-Dzf_W6hZ.js";import{t as De}from"./uuid-D-SDZijH.js";var Oe=(e,t)=>e!==t;function ke(e){if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`Invalid Hub project layout`);let t=e;if(typeof t.hubId!=`string`||!t.hubId.trim()||!Array.isArray(t.order)||t.order.some(e=>typeof e!=`string`||!e.trim())||!t.collapsed||typeof t.collapsed!=`object`||Array.isArray(t.collapsed)||Object.entries(t.collapsed).some(([e,t])=>!e.trim()||typeof t!=`boolean`))throw Error(`Invalid Hub project layout`);return{hubId:t.hubId,order:[...new Set(t.order)],collapsed:Object.fromEntries(Object.entries(t.collapsed))}}var Ae=e=>{let t=e.replace(/\\/g,`/`).replace(/\/+$/g,``).trim();if(!t)return``;let n=new TextEncoder().encode(t),r=``;for(let e of n)r+=String.fromCharCode(e);return`path_${typeof btoa==`function`?btoa(r).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/g,``):t.replace(/[^A-Za-z0-9._-]+/g,`_`)}`},C={...x,sessionIdLength:x.sessionIDLength,visibleTextLength:1e5,canonicalOutputLength:2e5},je=e=>typeof e==`string`&&de(e),Me=e=>e.replaceAll(`\\`,`/`).split(`/`).at(-1)?.replace(/\.md$/,``)??``,Ne=e=>({trigger:`@`,icon:`chat-thread`,label:e}),Pe=e=>({type:`session`,sessionId:e.sessionId,...e.directory===void 0?{}:{directory:e.directory},...e.target?{target:e.target}:{}}),Fe=e=>e.directory!==void 0||e.target?`@session:${JSON.stringify({sessionID:e.sessionId,...le(e)})}`:`@session:${e.sessionId}`,w=`"(?:[^"\\\\\\r\\n]|\\\\.)*"`,Ie=RegExp(`@session:(\\{"sessionID":${w},"directory":${w}(?:,"target":\\{"hubId":${w},"hostId":${w},"instanceId":${w}\\})?\\}|[A-Za-z0-9_-]+)`,`g`),Le=e=>{if(je(e))return{sessionId:e};try{let t=JSON.parse(e);if(!je(t.sessionID))return;let n=le(t);return n?{sessionId:t.sessionID,...n}:void 0}catch{return}},Re=(e,t)=>({trigger:`/`,icon:t,label:e}),ze=(e,t)=>({trigger:t,icon:`book-open`,label:e}),Be=(e,t)=>[`/`,`@`].some(n=>ge(e,ze(t,n))),Ve=(e,t)=>ge(e,ze(t,`@`))?ze(t,`@`):ze(t,`/`),He={session:{kind:`session`,validatePayload:e=>je(e.sessionId)&&le(e)!==void 0,contributeCanonical:e=>({text:Fe(e),semantic:Pe(e)}),contributeDirectSend:e=>{let t=Ne(be(e.display,`@`));return{text:ye(t),semantic:Pe(e)}},decorate:e=>{let t=Ne(be(e.display,`@`));return{style:`mentionSession`,visual:_e(t,e.display)}},payloadBudget:()=>void 0,canonical:{matcher:Ie,resolveDisplay:(e,t)=>{let n=e.index===0?``:t.text[e.index-1],r=t.text[e.index+e[0].length]??``,i=Le(e[1]);return i&&(n===``||/[\s([{]/.test(n))&&(r===``||/[\s)\]},.!?;:]/.test(r))?he(Ne((i.target?void 0:t.sessionTitles.get(i.sessionId))||i.sessionId)):null},materialize:(e,t,n)=>{let r=Le(e[1]);return{id:`session:${r.sessionId}:${e.index}`,kind:`session`,...r,display:t,start:n,end:n+t.length}}}},paste:{kind:`paste`,validatePayload:e=>typeof e.text==`string`&&e.text.length<=C.pastePayloadLength&&typeof e.characterCount==`number`&&Number.isSafeInteger(e.characterCount)&&e.characterCount===me(e.text)&&typeof e.index==`number`&&Number.isSafeInteger(e.index)&&e.index>=1,contributeCanonical:e=>({text:e.text}),contributeDirectSend:e=>({text:e.text}),decorate:()=>({style:`mentionPaste`}),payloadBudget:e=>({category:`opaque-text`,length:e.text.length})},skill:{kind:`skill`,validatePayload:e=>fe(e.skillName)&&typeof e.display==`string`&&Be(e.display,e.skillName),contributeCanonical:e=>({text:`[skill:${e.skillName}]`}),contributeDirectSend:e=>({text:`[skill:${e.skillName}]`}),decorate:e=>({style:`mentionCommand`,skillName:e.skillName,visual:_e(Ve(e.display,e.skillName),e.display)}),payloadBudget:()=>void 0,canonical:{matcher:pe(),resolveDisplay:e=>he(ze(e[1],`@`)),materialize:(e,t,n)=>({id:`skill:${n}`,kind:`skill`,skillName:e[1],display:t,start:n,end:n+t.length})}},command:{kind:`command`,validatePayload:e=>se(e.commandName)&&ve(e.reference)&&typeof e.display==`string`&&ge(e.display,Re(e.commandName,`command`)),contributeCanonical:e=>({text:`[command:${e.reference}]`}),contributeDirectSend:e=>({text:`[command:${e.reference}]`}),decorate:e=>({style:`mentionCommand`,visual:_e(Re(e.commandName,`command`),e.display)}),payloadBudget:()=>void 0,canonical:{matcher:/\[command:([^\]\r\n]+)\]/g,resolveDisplay:e=>{let t=Me(e[1]);return ve(e[1])&&se(t)?he(Re(t,`command`)):null},materialize:(e,t,n)=>({id:`command:${n}`,kind:`command`,commandName:Me(e[1]),reference:e[1],display:t,start:n,end:n+t.length})}}},T=e=>He[e],Ue=(e,t)=>T(e).validatePayload(t),We=e=>T(e.kind).contributeCanonical(e),Ge=e=>T(e.kind).contributeDirectSend(e),Ke=e=>T(e.kind).decorate(e),qe=e=>T(e.kind).payloadBudget(e),Je=e=>T(e.kind).describeResourceIdentity?.(e),Ye=Object.keys(He),Xe=e=>typeof e==`string`&&Ye.includes(e),Ze=()=>Ye.flatMap(e=>{let t=T(e).canonical;return t?[t]:[]}),Qe=e=>{if(e.type===`attachment`)return`attachment:${e.attachmentRefID}`},$e=e=>{let t=new Map;for(let n of e.references){let e=Je(n);e&&t.set(Qe(e),e)}return[...t.values()]},et=(e,t)=>{let n=new Map(e.map(e=>[Qe(e),e])),r=new Map(t.map(e=>[Qe(e),e]));return{previous:[...n.values()],next:[...r.values()],added:[...r].flatMap(([e,t])=>n.has(e)?[]:[t]),removed:[...n].flatMap(([e,t])=>r.has(e)?[]:[t])}},tt=(e,t)=>et($e(e),$e(t)),nt=(e,t=`queue-canonical`)=>{if(e.references.length>C.referenceCount)return{ok:!1,reason:`reference-budget-exceeded`};let n=[...e.references].sort((e,t)=>e.start-t.start),r=0,i=0;for(let t of n){if(t.start<r||t.start<0||t.end<=t.start||t.end>e.text.length||e.text.slice(t.start,t.end)!==t.display)return{ok:!1,reason:`invalid-references`};r=t.end;let n=qe(t);i+=n?.category===`opaque-text`?n.length:0}if(i>C.totalPastePayloadLength)return{ok:!1,reason:`reference-payload-budget-exceeded`};let a=[],o=[],s=0;for(let r of n){s<r.start&&a.push({provenance:`authored`,text:e.text.slice(s,r.start),start:s,end:r.start});let n=t===`direct-send-display`?Ge(r):We(r);n.semantic?(a.push({provenance:`generated-reference`,text:n.text,start:r.start,end:r.end,referenceId:r.id,semantic:n.semantic}),o.push(n.semantic)):a.push({provenance:`reference-payload`,text:n.text,start:r.start,end:r.end,referenceId:r.id}),s=r.end}s<e.text.length&&a.push({provenance:`authored`,text:e.text.slice(s),start:s,end:e.text.length});let c=a.map(e=>e.text).join(``);return c.length>C.canonicalOutputLength?{ok:!1,reason:`canonical-output-too-large`}:{ok:!0,plan:{chunks:a,semantics:o},text:c}},E=(e,t)=>Math.max(0,Math.min(e,t)),rt=(e,t)=>typeof e==`string`&&e.length>0&&e.length<=t,it=e=>{if(typeof e!=`object`||!e)return!1;let t=e;return!rt(t.id,C.displayLength)||!rt(t.display,C.displayLength)||!Number.isSafeInteger(t.start)||!Number.isSafeInteger(t.end)||typeof t.kind!=`string`?!1:Xe(t.kind)&&Ue(t.kind,t)},D=(e,t)=>{let n=[],r=0,i=[],a=Math.min(t.length,C.referenceCount);for(let e=0;e<a;e+=1){let a=t[e];if(!it(a)){typeof a==`object`&&a&&typeof a.id==`string`&&n.push(a.id),r+=1;continue}i.push({reference:a,index:e})}i.sort((e,t)=>e.reference.start-t.reference.start||e.index-t.index);let o=[],s=new Set,c=0,l=0,u=!1;for(let{reference:t}of i){if(s.has(t.id)||t.start<c||t.start<0||t.end<=t.start||t.end>e.length||e.slice(t.start,t.end)!==t.display){n.push(t.id),r+=1;continue}s.add(t.id),c=t.end;let i=qe(t);if(l+=i?.category===`opaque-text`?i.length:0,l>x.totalPastePayloadLength){n.push(t.id),r+=1,s.delete(t.id),c=o.at(-1)?.end??0,u=!0,l-=i?.category===`opaque-text`?i.length:0;continue}o.push(t)}return r+=t.length-a,{document:{text:e,references:o},rejectedIds:n,rejectedCount:r,budgetExceeded:t.length>C.referenceCount,payloadBudgetExceeded:u}},O=e=>{let t=[...e.references].sort((e,t)=>e.start-t.start||e.end-t.end),n=[],r=new Set,i=0,a=0;for(let o of t){if(!rt(o.id,C.idLength)||!rt(o.display,C.displayLength)||!Xe(o.kind)||!Number.isSafeInteger(o.start)||!Number.isSafeInteger(o.end)||r.has(o.id)||o.start<i||o.start<0||o.end<=o.start||o.end>e.text.length||e.text.slice(o.start,o.end)!==o.display)continue;let t=qe(o),s=t?.category===`opaque-text`?t.length:0;a+s>x.totalPastePayloadLength||(r.add(o.id),i=o.end,a+=s,n.push(o))}return{text:e.text,references:n}},at=(e,t)=>{if(t.length>x.pastePayloadLength)return!1;let n=D(e.text,e.references);return n.budgetExceeded||n.payloadBudgetExceeded?!1:n.document.references.reduce((e,t)=>{let n=qe(t);return e+(n?.category===`opaque-text`?n.length:0)},0)+t.length<=x.totalPastePayloadLength},ot=(e,t,n)=>{let r=e.filter(e=>t===n?t>e.start&&t<e.end:e.start<n&&e.end>t);return r.length===0?{start:t,end:n}:{start:Math.min(t,...r.map(e=>e.start)),end:Math.max(n,...r.map(e=>e.end))}};function st(e,t,n,r,i={}){let a=O(e);if(!Ue(r.kind,r))return{document:a,caret:E(n,a.text.length),edit:{oldStart:t,oldEnd:n,newEnd:n}};let o=E(t,a.text.length),s=Math.max(o,E(n,a.text.length)),c=ot(a.references,o,s),l=a.text.slice(0,c.start),u=a.text.slice(c.end),d=!!i.padDocumentEdges&&i.padLeadingDocumentEdge!==!1,f=!!i.padDocumentEdges,p=i.inlineBoundaries&&(l.length>0||d)&&!/\s$/.test(l)?` `:``,m=i.inlineBoundaries&&(u.length>0||f)&&!/^\s/.test(u)?` `:``,h=`${l}${p}${r.display}${m}${u}`,g={...r,start:c.start+p.length,end:c.start+p.length+r.display.length},ee=p.length+r.display.length+m.length-(c.end-c.start);return{document:O({text:h,references:[...a.references.filter(e=>e.end<=c.start||e.start>=c.end).map(e=>e.start>=c.end?{...e,start:e.start+ee,end:e.end+ee}:e),g]}),caret:g.end,edit:{oldStart:c.start,oldEnd:c.end,newEnd:c.start+p.length+r.display.length+m.length}}}var ct=(e,t)=>e<=t.oldStart?e:e>=t.oldEnd?e+t.newEnd-t.oldEnd:t.newEnd,lt=(e,t,n=t.length,r=n)=>{let i=O(e),a=0,o=Math.min(i.text.length,t.length);for(;a<o&&i.text[a]===t[a];)a+=1;let s=0;for(;s<i.text.length-a&&s<t.length-a&&i.text[i.text.length-s-1]===t[t.length-s-1];)s+=1;let c={oldStart:a,oldEnd:i.text.length-s,newEnd:t.length-s},l=ot(i.references,c.oldStart,c.oldEnd),u=l.start!==c.oldStart||l.end!==c.oldEnd,d=i.references.filter(e=>e.start<l.end&&e.end>l.start),f=t.slice(c.oldStart,c.newEnd),p=`${i.text.slice(0,l.start)}${f}${i.text.slice(l.end)}`,m={oldStart:l.start,oldEnd:l.end,newEnd:l.start+f.length},h=m.newEnd-m.oldEnd,g=i.references.filter(e=>e.end<=l.start||e.start>=l.end).map(e=>e.start>=l.end?{...e,start:e.start+h,end:e.end+h}:e),ee=(e,n)=>{let r=E(e,t.length),i=c.newEnd+l.end-c.oldEnd;return E(r<=l.start?r:r<c.oldStart||r===c.oldStart&&n===`start`?l.start:r<c.newEnd||r===c.newEnd&&n===`start`?l.start+r-c.oldStart:r<=i?m.newEnd:m.newEnd+r-i,p.length)},_=ee(n,`start`),te=Math.max(_,ee(r,`end`)),ne=O({text:p,references:g});return{document:ne,edit:m,requiresTextCorrection:u,selectionStart:_,selectionEnd:te,caret:te,mapCaret:e=>E(ct(e,m),ne.text.length),removedReferences:d}},ut=(e,t,n)=>{let r=ot(n,e,t);return r.start===e&&r.end===t?null:r},dt=(e,t,n)=>{let r=n,i=n;if(t===`Backspace`){for(;r>0&&/\s/.test(e[r-1]);)--r;for(;r>0&&!/\s/.test(e[r-1]);)--r}else{for(;i<e.length&&/\s/.test(e[i]);)i+=1;for(;i<e.length&&!/\s/.test(e[i]);)i+=1}return{start:r,end:i}},ft=(e,t)=>{let n=O(e),r=E(t.selectionStart,n.text.length),i=Math.max(r,E(t.selectionEnd,n.text.length)),a=r===i?t.altKey?dt(n.text,t.key,r):t.key===`Backspace`?{start:Math.max(0,r-1),end:r}:{start:r,end:Math.min(n.text.length,r+1)}:{start:r,end:i},o=ut(a.start,a.end,n.references);if(!o)return null;let s=n.references.filter(e=>e.start<o.end&&e.end>o.start);return{document:O({text:`${n.text.slice(0,o.start)}${n.text.slice(o.end)}`,references:n.references.filter(e=>!s.includes(e)).map(e=>e.start>=o.end?{...e,start:e.start-(o.end-o.start),end:e.end-(o.end-o.start)}:e)}),caret:o.start,edit:{oldStart:o.start,oldEnd:o.end,newEnd:o.start},removedIds:s.map(e=>e.id),removedReferences:s}},pt=(e,t)=>{let n=t,r=t;for(;n>0&&/\s/.test(e[n-1]);)--n;for(;r<e.length&&/\s/.test(e[r]);)r+=1;let i=n>0&&r<e.length?` `:``;return{text:`${e.slice(0,n)}${i}${e.slice(r)}`,caret:n+i.length}},mt=(e,t=`queue-canonical`)=>{let n=D(e.text,e.references);if(n.budgetExceeded)return{ok:!1,reason:`reference-budget-exceeded`};if(n.payloadBudgetExceeded)return{ok:!1,reason:`reference-payload-budget-exceeded`};if(n.rejectedCount>0)return{ok:!1,reason:`invalid-references`};let r=nt(n.document,t);return r.ok?{ok:!0,text:r.text,chunks:r.plan.chunks,semantics:r.plan.semantics}:r},ht=(e,t)=>e.match.index-t.match.index||e.adapterOrder-t.adapterOrder||e.matchOrder-t.matchOrder,gt=e=>{if(e.length>C.canonicalOutputLength||e.length>C.visibleTextLength)return null;let t=[],n=0;for(let[r,i]of Ze().entries()){i.matcher.lastIndex=0;let a,o=0;for(;(a=i.matcher.exec(e))!==null;){if(n+=1,n>C.referenceCount)return null;let e={codec:i,match:a,adapterOrder:r,matchOrder:o};o+=1;let s=t.findIndex(t=>ht(e,t)<0);s===-1?t.push(e):t.splice(s,0,e)}}return t},_t=(e,t)=>{let n=D(e.text,e.references).document,r=gt(n.text);if(r===null)return n;let i={text:n.text,sessionTitles:t},a=[],o=``,s=0,c=0,l=new Set(n.references.map(e=>e.id)),u=[];for(let e of r){let{match:t,codec:r}=e,a=t.index,o=a+t[0].length;if(a<c||n.references.some(e=>e.start<o&&e.end>a))continue;let s=r.resolveDisplay(t,i);if(s===null||s.length>C.displayLength)continue;let d=r.materialize(t,s,a),f=d.id;for(;l.has(f);)f=`materialized:${f}`;l.add(f),u.push({start:a,end:o,display:s,reference:{...d,id:f}}),c=o}s=0;let d=0;for(let e of u){o+=`${n.text.slice(s,e.start)}${e.display}`;let t=e.start+d;a.push({...e.reference,start:t,end:t+e.display.length}),d+=e.display.length-(e.end-e.start),s=e.end}if(o+=n.text.slice(s),o.length>C.visibleTextLength)return n;let f=n.references.map(e=>{let t=u.filter(t=>t.end<=e.start).reduce((e,t)=>e+t.display.length-(t.end-t.start),0);return{...e,start:e.start+t,end:e.end+t}});return D(o,[...f,...a]).document},vt=(e,t)=>_t({text:e,references:[]},t),yt=(e,t)=>vt(e,t),bt=(e,t,n=`
2
+
3
+ `)=>{let r=D(e.text,e.references).document,i=D(t.text,t.references).document;if(r.text===i.text&&JSON.stringify(r.references)===JSON.stringify(i.references))return i;let a=new Set(r.references.map(e=>e.id)),o=e=>{let t=e;for(;a.has(t);)t=`recovered:${t}`;return a.add(t),t},s=r.text.length+n.length;return D(`${r.text}${n}${i.text}`,[...r.references,...i.references.map(e=>({...e,id:o(e.id),start:e.start+s,end:e.end+s}))]).document},xt=e=>({state:`unbound-legacy`,sessionID:e}),k=e=>e.state===`bound`?`bound:${JSON.stringify([e.transportIdentity,m(e.directory),e.sessionID,e.deliveryTarget??{kind:`primary`}])}`:`unbound-legacy:${JSON.stringify([e.sessionID])}`,St=(e,t)=>e.queuedMessages[k(t)]??Ct,Ct=[],wt=3e4,Tt=`queue`,Et=e=>e===`steer`||e===`queue`,Dt=(e,t)=>e===`immediate`?`steer`:Et(e)?e:t===!1?`steer`:`queue`,Ot=[],kt=(e,t)=>e.pendingAdmissions[k(t)]??Ot,At=e=>`${e}-${De()}`,jt=e=>typeof e==`object`&&!!e&&Object.getPrototypeOf(e)===Object.prototype,Mt=(e,t,n=[])=>{if(!jt(e)||!Object.keys(e).every(e=>e===`text`||e===`references`))return;let r=e;if(typeof r.text!=`string`)return;let i=ce(r.text,r.references),a=i&&mt(i,`queue-canonical`);if(!a||!a.ok||a.text!==t)return;let o=new Set(n.map(e=>e.id));return $e(i).every(e=>o.has(e.attachmentRefID))?i:void 0},Nt=(e,t)=>{if(e===void 0)return[];if(!t)return;let n=ue(t.text,e);if(n)return n.some(e=>t.references.some(t=>e.range.start<t.end&&t.start<e.range.end))?void 0:n},Pt=(e,t)=>{let n=jt(e)&&typeof e.content==`string`?e:t,r=Mt(n.composerDocument,n.content,Array.isArray(n.attachments)?n.attachments:[]),i=Nt(n.composerMentions,r);return{content:n.content,...r?{composerDocument:r}:{},...r&&i?.length?{composerMentions:i}:{},...Array.isArray(n.attachments)?{attachments:n.attachments}:{},...jt(n.sendConfig)?{sendConfig:n.sendConfig}:{}}},Ft=e=>Pt(void 0,e),It=(e,t)=>e.queueItemID===t.queueItemID&&e.operationID===t.operationID&&(!t.messageID||e.messageID===t.messageID),A=e=>e.status===`sending`||e.status===`reconciling`,Lt=re(),Rt=()=>Lt?.flush()??!0,zt=`quiescing`,Bt=new Set,Vt=new Set,Ht=e=>{if(zt!==e){zt=e;for(let e of Vt)e()}},Ut=e=>{if(!(!e||Bt.has(e))){Bt.add(e);for(let e of Vt)e()}},Wt=e=>e.state===`bound`&&Bt.has(e.transportIdentity),j=e=>zt===`open`&&(!e||!Wt(e)),Gt=(e,t=Date.now())=>({reconciliationStartedAt:e.reconciliationStartedAt??t,reconciliationDeadlineAt:e.reconciliationDeadlineAt??(e.reconciliationStartedAt??t)+wt,reconciliationChecks:Math.max(0,Math.floor(e.reconciliationChecks??0))}),Kt=(e,t,n)=>{let r=t.queueItemID??(t.id||At(`queued`)),i=!t.owner&&(t.status===`sending`||t.status===`reconciling`),a=i?`unresolved`:t.status===`sending`?`reconciling`:t.status===`retrying`||t.status===`reconciling`||t.status===`unresolved`||t.status===`failed`?t.status:`queued`,o=typeof t.messageID==`string`&&t.messageID.startsWith(`msg_`)?t.messageID:ie(`msg`),s=Mt(t.composerDocument,t.content,t.attachments),c=Nt(t.composerMentions,s);return{...t,...s?{composerDocument:s}:{composerDocument:void 0},...s&&c?.length?{composerMentions:c}:{composerMentions:void 0},id:r,queueItemID:r,operationID:t.operationID??At(`operation`),messageID:o,owner:n,status:a,attemptCount:Math.max(0,Math.floor(t.attemptCount??0)),...t.status===`sending`||t.status===`reconciling`?Gt(t):{},...i||a===`reconciling`&&t.status===`sending`?{failure:{kind:`ambiguous-dispatch`,recovery:Pt(t.failure?.recovery,t)}}:{}}},qt=e=>{let t=e??{},n={};for(let[e,r]of Object.entries(t.queuedMessages??{})){if(!Array.isArray(r))continue;let t;if(e.startsWith(`bound:`)||e.startsWith(`unbound-legacy:`)){let n=r[0],i=e.startsWith(`unbound-legacy:`)?(()=>{try{let t=JSON.parse(e.slice(15));return Array.isArray(t)&&typeof t[0]==`string`?t[0]:e}catch{return e}})():e;t=n?.owner?.state===`bound`?n.owner:xt(n?.owner?.sessionID??i)}else t=xt(e);for(let e of r){let r=e.owner?.state===`bound`?e.owner:t,i=k(r);(n[i]??=[]).push(Kt(r.sessionID,e,r))}}return{queuedMessages:n,followUpBehavior:Dt(t.followUpBehavior,t.queueModeEnabled??null)}},M=(e,t,n,r)=>{if(Wt(t))return;let i=k(t);e(e=>{let t=e.queuedMessages[i],a=t?.findIndex(e=>k(e.owner)===i&&It(e,n))??-1;if(a<0||!t)return e;let o=r(t[a]);if(o===t[a])return e;let s=t.slice();return s[a]=o,{queuedMessages:{...e.queuedMessages,[i]:s}}})},Jt=g()(_(ee((e,t)=>({queuedMessages:{},followUpBehavior:Tt,pendingAdmissions:{},addToQueue:(t,n)=>{if(!j(t))return{ok:!1,reason:`invalid-composer-document`};let r=Mt(n.composerDocument,n.content,n.attachments);if(n.composerDocument!==void 0&&!r)return{ok:!1,reason:`invalid-composer-document`};let i=Nt(n.composerMentions,r);if(n.composerMentions!==void 0&&!i)return{ok:!1,reason:`invalid-composer-mentions`};n={...n,...r?{composerDocument:r}:{},...i?.length?{composerMentions:i}:{}};let a={...n,id:At(`queued`),queueItemID:``,operationID:At(`operation`),messageID:ie(`msg`),createdAt:Date.now(),owner:t,status:`queued`,attemptCount:0};a.queueItemID=a.id;let o=k(t);return e(e=>({queuedMessages:{...e.queuedMessages,[o]:[...e.queuedMessages[o]??[],a]}})),{ok:!0,item:a}},removeFromQueue:(n,r,i)=>{if(!j(n)||!i)return!1;let a=k(n),o=t().queuedMessages[a];if(!o||o.length===0)return!0;let s=o.find(e=>(e.queueItemID===r||e.id===r)&&k(e.owner)===a);if(s&&s.operationID!==i)return!1;let c=o.find(e=>(e.queueItemID===r||e.id===r)&&e.operationID===i&&k(e.owner)===a);return!c||!A(c)&&(e(e=>{let t=e.queuedMessages[a];if(!t)return e;let n=t.filter(e=>e!==c);if(n.length===t.length)return e;if(n.length)return{queuedMessages:{...e.queuedMessages,[a]:n}};let{[a]:r,...i}=e.queuedMessages;return{queuedMessages:i}}),!St(t(),n).some(e=>e===c||(e.queueItemID===r||e.id===r)&&e.operationID===i))},reorderQueue:(t,n,r,i)=>{if(!j(t)||!i)return;let a=k(t);e(e=>{let t=e.queuedMessages[a],o=t?.findIndex(e=>(e.id===n||e.queueItemID===n)&&e.operationID===i&&k(e.owner)===a)??-1,s=t?.findIndex(e=>(e.id===r||e.queueItemID===r)&&k(e.owner)===a)??-1;if(!t||o<0||s<0||o===s||A(t[o])||A(t[s]))return e;let c=t.slice(),[l]=c.splice(o,1);return c.splice(s,0,l),{queuedMessages:{...e.queuedMessages,[a]:c}}})},popToInput:(e,n,r)=>{if(!j(e)||!r)return null;let i=St(t(),e).find(t=>(t.id===n||t.queueItemID===n)&&t.operationID===r&&k(t.owner)===k(e));return!i||A(i)||!t().removeFromQueue(e,i.queueItemID,i.operationID)?null:i},clearQueue:n=>{if(!j(n))return!1;let r=k(n),i=t().queuedMessages[r],a=(t().pendingAdmissions[r]??[]).length>0;return(!i||i.length===0)&&!a||!i?.some(A)&&(e(e=>{if(e.queuedMessages[r]?.some(A))return e;let t={...e.queuedMessages},n={...e.pendingAdmissions};return delete t[r],delete n[r],{queuedMessages:t,pendingAdmissions:n}}),(t().queuedMessages[r]??[]).length===0)},clearAllQueues:()=>{j()&&e(e=>{let t={},n=!1;for(let[r,i]of Object.entries(e.queuedMessages)){if(i[0]&&Wt(i[0].owner)){t[r]=i;continue}let e=i.filter(A);e.length&&(t[r]=e),e.length!==i.length&&(n=!0)}let r=Object.keys(e.pendingAdmissions).length>0;return n||r?{queuedMessages:t,pendingAdmissions:{}}:e})},setFollowUpBehavior:t=>{j()&&(e({followUpBehavior:t}),V({followUpBehavior:t}))},getQueueForScope:e=>St(t(),e),getPendingAdmissionsForScope:e=>kt(t(),e),stageAdmission:(t,n)=>{if(!j(t)||!n.requestID||!n.queueItemID||!n.operationID||!n.messageID||typeof n.content!=`string`)return;let r=Mt(n.composerDocument,n.content);if(n.composerDocument!==void 0&&!r)return;let i=Nt(n.composerMentions,r);if(n.composerMentions!==void 0&&!i)return;let a=k(t),o={kind:`pending-admission`,requestID:n.requestID,queueItemID:n.queueItemID,operationID:n.operationID,messageID:n.messageID,content:n.content,createdAt:n.createdAt,phase:`admitting`,attachmentCount:Math.max(0,Math.floor(n.attachmentCount??0)),...r?{composerDocument:r}:{},...r&&i?.length?{composerMentions:i}:{}};e(e=>{let t=[...(e.pendingAdmissions[a]??[]).filter(e=>e.requestID!==o.requestID&&e.queueItemID!==o.queueItemID),o];return{pendingAdmissions:{...e.pendingAdmissions,[a]:t}}})},unstageAdmission:(t,n)=>{if(!n)return;let r=k(t);e(e=>{let t=e.pendingAdmissions[r];if(!t?.length)return e;let i=t.filter(e=>e.requestID!==n);if(i.length===t.length)return e;if(i.length)return{pendingAdmissions:{...e.pendingAdmissions,[r]:i}};let{[r]:a,...o}=e.pendingAdmissions;return{pendingAdmissions:o}})},confirmAdmission:(n,r)=>{if(!j(n)||!r.requestID||!r.sendConfig?.providerID||!r.sendConfig?.modelID)return{ok:!1,reason:`invalid-composer-document`};let i=k(n),a=(t().pendingAdmissions[i]??[]).find(e=>e.requestID===r.requestID);if(!a)return{ok:!1,reason:`invalid-composer-document`};let o=Mt(a.composerDocument,a.content,r.attachments);if(a.composerDocument!==void 0&&!o)return{ok:!1,reason:`invalid-composer-document`};let s=Nt(a.composerMentions,o);if(a.composerMentions!==void 0&&!s)return{ok:!1,reason:`invalid-composer-mentions`};let c={id:a.queueItemID,queueItemID:a.queueItemID,operationID:a.operationID,messageID:a.messageID,content:a.content,createdAt:a.createdAt,owner:n,status:`queued`,attemptCount:0,sendConfig:r.sendConfig,...o?{composerDocument:o}:{},...o&&s?.length?{composerMentions:s}:{},...r.attachments?.length?{attachments:r.attachments}:{}};return e(e=>{let t=(e.pendingAdmissions[i]??[]).filter(e=>e.requestID!==r.requestID);return{pendingAdmissions:t.length?{...e.pendingAdmissions,[i]:t}:(()=>{let{[i]:t,...n}=e.pendingAdmissions;return n})(),queuedMessages:{...e.queuedMessages,[i]:[...e.queuedMessages[i]??[],c]}}}),{ok:!0,item:c}},bindLegacyQueue:(t,n)=>{if(!j(t)||!j(n)||t.state!==`unbound-legacy`||n.state!==`bound`||t.sessionID!==n.sessionID)return[];let r=k(t),i=k(n),a=[];return e(e=>{let t=e.queuedMessages[r];if(!t||(a=t.filter(e=>!A(e)),a.length===0))return e;let o=t.filter(A),s={...e.queuedMessages,[i]:[...a.map(e=>({...e,owner:n})),...e.queuedMessages[i]??[]]};return o.length?s[r]=o:delete s[r],{queuedMessages:s}}),a.map(e=>({...e,owner:n}))},markQueueItemSendAttempt:(t,n)=>{j(t)&&M(e,t,n,e=>e.status===`queued`||e.status===`retrying`&&(e.nextAttemptAt??0)<=Date.now()?{...e,status:`sending`,attemptCount:e.attemptCount+1,nextAttemptAt:void 0,failure:void 0}:e)},markQueueItemPreDispatchRetry:(t,n,r,i)=>M(e,t,n,e=>e.status===`sending`?{...e,status:`retrying`,nextAttemptAt:r,failure:{kind:`pre-dispatch`,recovery:i?.recovery??Ft(e)}}:e),markQueueItemReconciling:(t,n,r)=>M(e,t,n,e=>e.status===`sending`?{...e,status:`reconciling`,nextAttemptAt:void 0,...Gt(e),reconciliationNextCheckAt:void 0,failure:{kind:`ambiguous-dispatch`,recovery:r?.recovery??Ft(e)}}:e),recordQueueItemReconciliationCheck:(t,n)=>M(e,t,n,e=>e.status===`reconciling`&&It(e,n)?{...e,reconciliationChecks:(e.reconciliationChecks??0)+1,reconciliationNextCheckAt:Date.now()+2e3}:e),resolveQueueItemReconciliation:(t,n)=>M(e,t,n,e=>e.status===`reconciling`&&It(e,n)?{...e,status:`unresolved`,nextAttemptAt:void 0}:e),markQueueItemDefinitiveFailure:(t,n,r)=>M(e,t,n,e=>e.status===`sending`?{...e,status:`failed`,nextAttemptAt:void 0,failure:{kind:`definitive`,recovery:r?.recovery??Ft(e)}}:e),resetQueueItemForDispatch:(t,n)=>{j(t)&&M(e,t,n,e=>e.status!==`failed`&&e.status!==`unresolved`&&e.status!==`retrying`?e:{...e,status:`queued`,nextAttemptAt:void 0,failure:void 0,reconciliationStartedAt:void 0,reconciliationDeadlineAt:void 0,reconciliationChecks:void 0,reconciliationNextCheckAt:void 0})},beginQueueItemDispatch:(t,n,r,i,a=Date.now())=>{if(!j(t)||!r.startsWith(`msg_`))return null;let o=k(t),s=null;return e(e=>{let t=e.queuedMessages[o],c=i?t?.findIndex(e=>k(e.owner)===o&&It(e,n))??-1:0,l=c>=0?t?.[c]:void 0,u=l?.status===`queued`||l?.status===`retrying`&&(i||(l.nextAttemptAt??0)<=a)||i&&(l?.status===`failed`||l?.status===`unresolved`);if(!l||k(l.owner)!==o||!It(l,n)||!u||t?.some(A))return e;s={...l,messageID:r,status:`sending`,attemptCount:l.attemptCount+1,nextAttemptAt:void 0,failure:void 0,reconciliationStartedAt:void 0,reconciliationDeadlineAt:void 0,reconciliationChecks:void 0,reconciliationNextCheckAt:void 0};let d=t.slice();return d.splice(c,1),d.unshift(s),{queuedMessages:{...e.queuedMessages,[o]:d}}}),s},confirmQueueItem:(t,n)=>{if(Wt(t))return;let r=k(t);e(e=>{let t=e.queuedMessages[r],i=t?.find(e=>{let t=!n.operationID||e.operationID===n.operationID,r=!n.messageID||e.messageID===n.messageID,i=!n.queueItemID||e.queueItemID===n.queueItemID;return t&&r&&i});if(!i||!n.operationID&&!n.messageID)return e;let a=t.filter(e=>e!==i);if(a.length)return{queuedMessages:{...e.queuedMessages,[r]:a}};let{[r]:o,...s}=e.queuedMessages;return{queuedMessages:s}})}}),{name:`message-queue-store`,version:4,storage:Lt,partialize:e=>({queuedMessages:e.queuedMessages,followUpBehavior:e.followUpBehavior}),migrate:qt,merge:(e,t)=>({...t,...qt(e),pendingAdmissions:t.pendingAdmissions})}),{name:`message-queue-store`})),Yt=(e,t)=>{let n=Jt.getState().queuedMessages,r=[],i=[];for(let[a,o]of Object.entries(n)){let n=o[0]?.owner;if(!n||n.state!==`unbound-legacy`)continue;let s=t(n.sessionID);if(!s){i.push(n.sessionID);continue}r.push({sourceKey:a,target:{state:`bound`,transportIdentity:e,directory:s,sessionID:n.sessionID},items:o})}return!e||i.length?{ok:!1,unresolvedSessionIDs:i}:r.length?(Jt.setState(e=>{let t={...e.queuedMessages};for(let e of r){let n=k(e.target);t[n]=[...e.items.map(t=>({...t,owner:e.target})),...t[n]??[]],delete t[e.sourceKey]}return{queuedMessages:t}}),{ok:!0,moved:r.reduce((e,t)=>e+t.items.length,0)}):{ok:!0,moved:0}},Xt=xe(),Zt=e(te(),1),Qt=`directoryTreeShowHidden`,$t=`directory-show-hidden-change`,en=()=>{if(typeof window>`u`)return!0;try{let e=v().getItem(Qt);return e===null||e===`true`}catch{return!0}},tn=()=>{typeof window>`u`||window.dispatchEvent(new Event($t))},nn=(e,t={})=>{if(!(typeof window>`u`)){try{v().setItem(Qt,e?`true`:`false`),tn()}catch{}t.persist!==!1&&V({directoryShowHidden:e})}},rn=()=>{let e=(0,Xt.c)(2),[t,n]=Zt.useState(en),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{if(typeof window>`u`)return;let e=()=>{n(en())};return window.addEventListener(`storage`,e),window.addEventListener($t,e),()=>{window.removeEventListener(`storage`,e),window.removeEventListener($t,e)}},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),Zt.useEffect(r,i),t},an=`filesViewShowGitignored`,on=`files-view-show-gitignored-change`,sn=()=>{if(typeof window>`u`)return!1;try{return v().getItem(an)===`true`}catch{return!1}},cn=()=>{typeof window>`u`||window.dispatchEvent(new Event(on))},ln=(e,t={})=>{if(!(typeof window>`u`)){try{v().setItem(an,e?`true`:`false`),cn()}catch{}t.persist!==!1&&V({filesViewShowGitignored:e})}},un=()=>{let e=(0,Xt.c)(2),[t,n]=Zt.useState(sn),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{if(typeof window>`u`)return;let e=()=>{n(sn())};return window.addEventListener(`storage`,e),window.addEventListener(on,e),()=>{window.removeEventListener(`storage`,e),window.removeEventListener(on,e)}},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),Zt.useEffect(r,i),t},dn=e=>{if(!e||typeof e!=`object`)return null;let t={};return typeof e.showReasoningTraces==`boolean`&&(t.showReasoningTraces=e.showReasoningTraces),typeof e.collapsibleThinkingBlocks==`boolean`&&(t.collapsibleThinkingBlocks=e.collapsibleThinkingBlocks),Object.keys(t).length>0?t:null},fn=e=>{if(!e||typeof e!=`object`)return null;let t=e;return{showReasoningTraces:t.showReasoningTraces,collapsibleThinkingBlocks:t.collapsibleThinkingBlocks}},pn=e=>{let t=S.getState();typeof e.showReasoningTraces==`boolean`&&t.setShowReasoningTraces(e.showReasoningTraces),typeof e.collapsibleThinkingBlocks==`boolean`&&t.setCollapsibleThinkingBlocks(e.collapsibleThinkingBlocks)},mn=async()=>{if(typeof window>`u`)return null;let e=localStorage.getItem(`appearance-preferences`);if(!e)return null;try{return dn(fn(JSON.parse(e)))}catch(e){return console.warn(`Failed to parse stored appearance preferences:`,e),null}},hn=[{name:`explore`,icon:`compass-3`,labelKey:`chat.draftPresets.explore.label`,command:`/explore`},{name:`catch-up`,icon:`history`,labelKey:`chat.draftPresets.catchup.label`,command:`/catch-up`},{name:`weigh`,icon:`scales-3`,labelKey:`chat.draftPresets.weigh.label`,command:`/weigh`},{name:`craft-goal`,icon:`target`,labelKey:`chat.draftPresets.craftGoal.label`,command:`/craft-goal`},{name:`debug`,icon:`bug`,labelKey:`chat.draftPresets.debug.label`,command:`/debug`},{name:`review`,icon:`search-eye`,labelKey:`chat.draftPresets.review.label`,command:`/workspace-review`}],gn=new Map(hn.map(e=>[e.name,e])),_n=e=>gn.get(e),vn=[{type:`command`,name:`explore`},{type:`command`,name:`catch-up`},{type:`command`,name:`weigh`},{type:`command`,name:`debug`},{type:`command`,name:`review`}],yn=`terminal-box`,bn=`book-open`,xn=e=>`${e.type}:${e.name}`,Sn=(e,t)=>e.type===t.type&&e.name===t.name,Cn=e=>{let t=e.replace(/^\//,``).replace(/[-_]+/g,` `).replace(/\s+/g,` `).trim();return t?t.charAt(0).toUpperCase()+t.slice(1):e},wn=e=>{if(!Array.isArray(e))return[];let t=[],n=new Set;for(let r of e){if(!r||typeof r!=`object`)continue;let e=r,i=e.type===`command`||e.type===`skill`?e.type:null,a=typeof e.name==`string`?e.name.trim():``;if(!i||!a)continue;let o=`${i}:${a}`;n.has(o)||(n.add(o),t.push({type:i,name:a}))}return t},Tn=`yuri.rt.`,En=e=>{try{return btoa(unescape(encodeURIComponent(e))).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/g,``)}catch{return encodeURIComponent(e)}},N=(e,t=o())=>`${Tn}${En(t.trim().length>0?t.trim():`default`)}.${e}`,Dn=(e,t,n=o())=>e?e===N(t,n):!1,On=()=>{if(typeof window>`u`)return!0;if(u())return d();let e=window.__YURI_API_BASE_URL__,t=window.__YURI_LOCAL_ORIGIN__;if(typeof e==`string`&&e.trim()&&typeof t==`string`&&t.trim())try{return new URL(e).origin===new URL(t).origin}catch{return!1}try{if(d())return!0}catch{}if(typeof e==`string`&&e.trim())try{let t=new URL(e).hostname;if(t!==`localhost`&&t!==`127.0.0.1`&&t!==`::1`)return!1}catch{return!1}return!0},kn=(e,t)=>{let n=t?.storage??(typeof localStorage<`u`?localStorage:{getItem:()=>null}),r=t?.transport??o(),i=n.getItem(N(e,r));return i===null?On()?n.getItem(e):null:i},P=(e,t,n)=>{let r=n?.storage??(typeof localStorage<`u`?localStorage:{setItem:()=>void 0}),i=n?.transport??o();r.setItem(N(e,i),t)},An=e=>{let t;try{t=ne()}catch{return}let n=t=>t===null?null:JSON.parse(t,e?.reviver),r=e=>t.getItem(e);return{getItem:e=>{let t=N(e,o()),i=r(t);if(i instanceof Promise)return i.then(t=>{if(t!==null)return n(t);if(!On())return null;let i=r(e);return i instanceof Promise?i.then(n):n(i)});if(i!==null)return n(i);if(!On())return null;let a=r(e);return a instanceof Promise?a.then(n):n(a)},setItem:(n,r)=>{let i=N(n,o());t.setItem(i,JSON.stringify(r,e?.replacer))},removeItem:e=>{let n=N(e,o());t.removeItem(n)}}},jn=512,Mn=4096,Nn=64,Pn=2e5,Fn=[`concise`,`detailed`,`mentor`,`pushback`,`noFiller`,`matchEnergy`,`warmPeer`,`custom`],In=[`defaultModel`,`defaultVariant`,`defaultAgent`,`autoCreateWorktree`,`gitmojiEnabled`,`defaultFileViewerPreview`,`zenModel`,`messageStreamTransport`,`sttProvider`,`sttServerUrl`,`sttModel`,`sttLocalModel`,`sttLanguage`,`responseStyleEnabled`,`responseStylePreset`,`responseStyleCustomInstructions`],Ln=e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getPrototypeOf(e)===Object.prototype,F=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Rn=(e,t)=>{if(typeof e!=`string`)return;let n=e.trim();return n.length<=t?n:void 0},zn=e=>{let t=Rn(e,Mn);if(t!==void 0)try{let e=new URL(t);return(e.protocol===`http:`||e.protocol===`https:`)&&!e.username&&!e.password?t:void 0}catch{return}},Bn=(e,t)=>typeof e==`string`&&t.includes(e)?e:void 0,Vn=e=>typeof e==`boolean`?e:void 0,Hn=(e,t)=>{let n=e[t];switch(t){case`autoCreateWorktree`:case`gitmojiEnabled`:case`defaultFileViewerPreview`:case`responseStyleEnabled`:return Vn(n);case`messageStreamTransport`:return Bn(n,[`auto`,`ws`,`sse`]);case`sttProvider`:return Bn(n,[`local`,`openai-compatible`,`volcengine`]);case`sttServerUrl`:return zn(n);case`sttLanguage`:return Rn(n,Nn);case`responseStyleCustomInstructions`:return Rn(n,Pn);case`responseStylePreset`:return Bn(n,Fn);default:return Rn(n,jn)}},Un=e=>{if(!Ln(e))throw Error(`Invalid settings bootstrap response`);if(!F(e,`schemaVersion`)||e.schemaVersion!==1)throw Error(`Unsupported settings bootstrap schema version`);let t={schemaVersion:1};typeof e.hasRemoteProjects==`boolean`&&(t.hasRemoteProjects=e.hasRemoteProjects);for(let n of In){if(!F(e,n))continue;let r=Hn(e,n);r!==void 0&&Object.assign(t,{[n]:r})}return t},Wn=e=>{if(!Ln(e))throw Error(`Invalid settings bootstrap patch`);for(let t of Object.keys(e))if(!In.includes(t))throw Error(`Invalid settings bootstrap patch`);let t=Un({schemaVersion:1,...e}),n={};for(let r of In)if(F(e,r)){if(!F(t,r))throw Error(`Invalid settings bootstrap patch`);Object.assign(n,{[r]:t[r]})}return n},Gn=e=>{if(!Ln(e))return{};let t={};for(let n of In){if(!F(e,n))continue;let r=Hn(e,n);r!==void 0&&Object.assign(t,{[n]:r})}return t},Kn=async(e,t)=>{let n=new AbortController,r,i=new Promise((e,t)=>{r=t}),a=e=>{r(e),n.abort(e)},o=()=>a(e.reason??new DOMException(`Request aborted`,`AbortError`)),s=setTimeout(()=>a(new DOMException(`Configuration request timed out`,`TimeoutError`)),3e4);e.addEventListener(`abort`,o,{once:!0});try{return e.aborted?(o(),await i):await Promise.race([t(n.signal),i])}finally{clearTimeout(s),e.removeEventListener(`abort`,o)}},qn=class extends Error{status;constructor(e){super(`Settings bootstrap request failed (${e})`),this.status=e,this.name=`SettingsBootstrapRequestError`}},Jn=(e=o())=>[e,`settings`,`bootstrap`],Yn=(e=o())=>({queryKey:Jn(e),queryFn:({signal:e})=>Kn(e,async e=>{let t=await l(`/api/config/settings/bootstrap`,{method:`GET`,headers:{Accept:`application/json`},signal:e});if(!t.ok)throw new qn(t.status);return Un(await t.json())}),retry:(e,t)=>!(t instanceof qn&&(t.status===404||t.status===501))&&e<1,staleTime:1/0,gcTime:1/0}),Xn=(e=o())=>Se.fetchQuery(Yn(e)),Zn=(e=o())=>Se.getQueryData(Jn(e)),Qn=(e,t=o())=>{let n=Wn(e),r=Jn(t),i=Un({schemaVersion:1,...Se.getQueryData(r),...n});return Se.setQueryData(r,i),i},$n=e=>{if(!(typeof window>`u`)&&!(typeof window.__YURI_HOME__==`string`&&window.__YURI_HOME__.length>0))try{window.__YURI_HOME__=e}catch{}},er=e=>{if(!(typeof window>`u`)){if(e.themeId&&P(`selectedThemeId`,e.themeId),e.themeVariant&&P(`selectedThemeVariant`,e.themeVariant),e.lightThemeId&&P(`lightThemeId`,e.lightThemeId),e.darkThemeId&&P(`darkThemeId`,e.darkThemeId),typeof e.useSystemTheme==`boolean`&&(P(`useSystemTheme`,String(e.useSystemTheme)),P(`themeMode`,e.useSystemTheme?`system`:e.themeVariant===`dark`||e.themeVariant===`light`?e.themeVariant:`system`)),e.lastDirectory&&y(`lastDirectory`,e.lastDirectory),e.homeDirectory&&(y(`homeDirectory`,e.homeDirectory),$n(e.homeDirectory)),Array.isArray(e.projects)&&e.projects.length>0?y(`projects`,JSON.stringify(e.projects)):ae(`projects`),e.activeProjectId?y(`activeProjectId`,e.activeProjectId):ae(`activeProjectId`),Array.isArray(e.pinnedDirectories)&&e.pinnedDirectories.length>0?y(`pinnedDirectories`,JSON.stringify(e.pinnedDirectories)):ae(`pinnedDirectories`),Array.isArray(e.projects)&&e.projects.length>0){let t=e.projects.filter(e=>e.sidebarCollapsed===!0).map(e=>e.id).filter(e=>typeof e==`string`&&e.length>0);t.length>0?y(`yuri.sessions.projectCollapse`,JSON.stringify(t)):ae(`yuri.sessions.projectCollapse`)}if(typeof e.gitmojiEnabled==`boolean`?localStorage.setItem(`gitmojiEnabled`,String(e.gitmojiEnabled)):localStorage.removeItem(`gitmojiEnabled`),typeof e.directoryShowHidden==`boolean`&&localStorage.setItem(`directoryTreeShowHidden`,e.directoryShowHidden?`true`:`false`),typeof e.filesViewShowGitignored==`boolean`&&localStorage.setItem(`filesViewShowGitignored`,e.filesViewShowGitignored?`true`:`false`),typeof e.openInAppId==`string`&&e.openInAppId.length>0&&localStorage.setItem(`openInAppId`,e.openInAppId),typeof e.pwaAppName==`string`){let t=e.pwaAppName.trim().replace(/\s+/g,` `).slice(0,64);t.length>0?localStorage.setItem(`yuri.pwaName`,t):localStorage.removeItem(`yuri.pwaName`)}if(typeof e.mobileKeyboardMode==`string`&&Te(e.mobileKeyboardMode),typeof e.openCodeUpdateToastDismissedVersion==`string`){let t=e.openCodeUpdateToastDismissedVersion.trim();t?localStorage.setItem(`opencode-update-toast-dismissed-version`,t):localStorage.removeItem(`opencode-update-toast-dismissed-version`)}}},tr=e=>{typeof window>`u`||window.dispatchEvent(new CustomEvent(`yuri:settings-synced`,{detail:e}))},nr=e=>{if(!Array.isArray(e))return;let t=[],n=new Set;for(let r of e){if(!r||typeof r!=`object`)continue;let e=r,i=typeof e.id==`string`?e.id.trim():``,a=typeof e.label==`string`?e.label.trim():``,o=typeof e.source==`string`?e.source.trim():``,s=typeof e.subpath==`string`?e.subpath.trim():``,c=typeof e.gitIdentityId==`string`?e.gitIdentityId.trim():``;!i||!a||!o||n.has(i)||(n.add(i),t.push({id:i,label:a,source:o,...s?{subpath:s}:{},...c?{gitIdentityId:c}:{}}))}return t},rr=e=>{if(!e||typeof e!=`object`||Array.isArray(e))return;let t={};for(let[n,r]of Object.entries(e)){let e=typeof n==`string`?n.trim():``,i=typeof r==`string`?r.trim():``;!e||!i||(t[e]=i)}return t},ir=(e,t)=>{let n=Object.entries(e),r=Object.entries(t);return n.length===r.length&&n.every(([e,n])=>t[e]===n)},ar=(e,t)=>e.length===t.length&&e.every((e,n)=>e.providerID===t[n]?.providerID&&e.modelID===t[n]?.modelID&&e.variant===t[n]?.variant),or=(e,t)=>{if(t.length===0)return t;let n=new Map;for(let t of e)typeof t.variant==`string`&&t.variant.length>0&&n.set(`${t.providerID}/${t.modelID}`,t.variant);return t.map(e=>{if(typeof e.variant==`string`&&e.variant.length>0)return e;let t=n.get(`${e.providerID}/${e.modelID}`);return t?{providerID:e.providerID,modelID:e.modelID,variant:t}:e})},sr=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),cr=e=>{if(Array.isArray(e))return Array.from(new Set(e.filter(e=>typeof e==`string`&&e.length>0)))},lr=e=>{if(!e||typeof e!=`object`||Array.isArray(e))return;let t={};for(let[n,r]of Object.entries(e)){if(!n||!Array.isArray(r))continue;let e=cr(r);e&&e.length>0&&(t[n]=e.slice(0,5))}return Object.keys(t).length>0?t:void 0},ur=(e,t)=>{let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>Array.isArray(t[n])&&sr(e[n],t[n]))},dr=/^#(?:[\da-fA-F]{3}|[\da-fA-F]{6})$/,fr=e=>{if(typeof e!=`string`)return null;let t=e.trim();return t&&dr.test(t)?t.toLowerCase():null},pr=e=>{if(!Array.isArray(e))return;let t=[],n=new Set,r=new Set;for(let i of e){if(!i||typeof i!=`object`)continue;let e=i,a=typeof e.path==`string`?e.path.trim():``;if(!a)continue;let o=a===`/`?a:a.replace(/\\/g,`/`).replace(/\/+$/,``);if(!o)continue;let s=Ae(o);if(!s||n.has(s)||r.has(o))continue;n.add(s),r.add(o);let c={id:s,path:o};if(typeof e.label==`string`&&e.label.trim().length>0&&(c.label=e.label.trim()),typeof e.icon==`string`&&e.icon.trim().length>0&&(c.icon=e.icon.trim()),e.iconImage===null)c.iconImage=null;else if(e.iconImage&&typeof e.iconImage==`object`){let t=e.iconImage,n=typeof t.mime==`string`?t.mime.trim():``,r=typeof t.updatedAt==`number`&&Number.isFinite(t.updatedAt)?Math.max(0,Math.round(t.updatedAt)):0,i=t.source===`custom`||t.source===`auto`?t.source:null;n&&r>0&&i&&(c.iconImage={mime:n,updatedAt:r,source:i})}if(typeof e.color==`string`&&e.color.trim().length>0&&(c.color=e.color.trim()),e.iconBackground===null)c.iconBackground=null;else{let t=fr(e.iconBackground);t&&(c.iconBackground=t)}typeof e.addedAt==`number`&&Number.isFinite(e.addedAt)&&e.addedAt>=0&&(c.addedAt=e.addedAt),typeof e.lastOpenedAt==`number`&&Number.isFinite(e.lastOpenedAt)&&e.lastOpenedAt>=0&&(c.lastOpenedAt=e.lastOpenedAt),typeof e.sidebarCollapsed==`boolean`&&(c.sidebarCollapsed=e.sidebarCollapsed),t.push(c)}return t.length>0?t:void 0},mr=(e,t,n)=>{if(!Array.isArray(e))return;let r=[],i=new Set,a=n?.preserveVariant===!0;for(let n of e){if(!n||typeof n!=`object`)continue;let e=n,o=typeof e.providerID==`string`?e.providerID.trim():``,s=typeof e.modelID==`string`?e.modelID.trim():``;if(!o||!s)continue;let c=`${o}/${s}`;if(!i.has(c)&&(i.add(c),a&&typeof e.variant==`string`&&e.variant.trim().length>0?r.push({providerID:o,modelID:s,variant:e.variant.trim()}):r.push({providerID:o,modelID:s}),r.length>=t))break}return r},hr=()=>{let e=S.persist;if(e&&typeof e==`object`)return e},gr=()=>h()?.settings??null,_r=(e,t,n)=>{let r={...Gn(t),...Gn(e)};if(Object.keys(r).length!==0)try{Qn(r,n)}catch(e){console.warn(`Failed to patch settings bootstrap cache:`,e)}},vr=e=>{let t=S.getState(),n=typeof window<`u`?window.__zustand_config_store__?.getState?.()??null:null,r=Jt.getState();if(typeof e.showReasoningTraces==`boolean`&&e.showReasoningTraces!==t.showReasoningTraces&&t.setShowReasoningTraces(e.showReasoningTraces),typeof e.sessionTitleRefreshEnabled==`boolean`&&e.sessionTitleRefreshEnabled!==t.sessionTitleRefreshEnabled&&t.setSessionTitleRefreshEnabled(e.sessionTitleRefreshEnabled),typeof e.sessionGoalEnabled==`boolean`&&e.sessionGoalEnabled!==t.sessionGoalEnabled&&t.setSessionGoalEnabled(e.sessionGoalEnabled),typeof e.collapsibleThinkingBlocks==`boolean`&&e.collapsibleThinkingBlocks!==t.collapsibleThinkingBlocks&&t.setCollapsibleThinkingBlocks(e.collapsibleThinkingBlocks),typeof e.autoDeleteEnabled==`boolean`&&e.autoDeleteEnabled!==t.autoDeleteEnabled&&t.setAutoDeleteEnabled(e.autoDeleteEnabled),typeof e.autoDeleteAfterDays==`number`&&Number.isFinite(e.autoDeleteAfterDays)){let n=Math.max(1,Math.min(365,e.autoDeleteAfterDays));n!==t.autoDeleteAfterDays&&t.setAutoDeleteAfterDays(n)}(e.sessionRetentionAction===`archive`||e.sessionRetentionAction===`delete`)&&e.sessionRetentionAction!==t.sessionRetentionAction&&t.setSessionRetentionAction(e.sessionRetentionAction);let i=null;if(Et(e.followUpBehavior)?i=e.followUpBehavior:typeof e.queueModeEnabled==`boolean`&&(i=Dt(void 0,e.queueModeEnabled)),i&&i!==r.followUpBehavior&&r.setFollowUpBehavior(i),typeof e.showDeletionDialog==`boolean`&&e.showDeletionDialog!==t.showDeletionDialog&&t.setShowDeletionDialog(e.showDeletionDialog),typeof e.nativeNotificationsEnabled==`boolean`&&e.nativeNotificationsEnabled!==t.nativeNotificationsEnabled&&t.setNativeNotificationsEnabled(e.nativeNotificationsEnabled),typeof e.notificationMode==`string`&&(e.notificationMode===`always`||e.notificationMode===`hidden-only`)&&e.notificationMode!==t.notificationMode&&t.setNotificationMode(e.notificationMode),typeof e.notifyOnSubtasks==`boolean`&&e.notifyOnSubtasks!==t.notifyOnSubtasks&&t.setNotifyOnSubtasks(e.notifyOnSubtasks),typeof e.notifyOnCompletion==`boolean`&&e.notifyOnCompletion!==t.notifyOnCompletion&&t.setNotifyOnCompletion(e.notifyOnCompletion),typeof e.notifyOnError==`boolean`&&e.notifyOnError!==t.notifyOnError&&t.setNotifyOnError(e.notifyOnError),typeof e.notifyOnQuestion==`boolean`&&e.notifyOnQuestion!==t.notifyOnQuestion&&t.setNotifyOnQuestion(e.notifyOnQuestion),typeof e.notifyOnPermission==`boolean`&&e.notifyOnPermission!==t.notifyOnPermission&&t.setNotifyOnPermission(e.notifyOnPermission),typeof e.notifyOnScheduledTasks==`boolean`&&e.notifyOnScheduledTasks!==t.notifyOnScheduledTasks&&t.setNotifyOnScheduledTasks(e.notifyOnScheduledTasks),typeof e.notifyOnAssistants==`boolean`&&e.notifyOnAssistants!==t.notifyOnAssistants&&t.setNotifyOnAssistants(e.notifyOnAssistants),typeof e.notifyOnGoals==`boolean`&&e.notifyOnGoals!==t.notifyOnGoals&&t.setNotifyOnGoals(e.notifyOnGoals),e.notificationTemplates&&typeof e.notificationTemplates==`object`&&t.setNotificationTemplates(e.notificationTemplates),typeof e.summarizeLastMessage==`boolean`&&e.summarizeLastMessage!==t.summarizeLastMessage&&t.setSummarizeLastMessage(e.summarizeLastMessage),typeof e.summaryThreshold==`number`&&Number.isFinite(e.summaryThreshold)&&t.setSummaryThreshold(e.summaryThreshold),typeof e.summaryLength==`number`&&Number.isFinite(e.summaryLength)&&t.setSummaryLength(e.summaryLength),typeof e.maxLastMessageLength==`number`&&Number.isFinite(e.maxLastMessageLength)&&t.setMaxLastMessageLength(e.maxLastMessageLength),typeof e.inputSpellcheckEnabled==`boolean`&&e.inputSpellcheckEnabled!==t.inputSpellcheckEnabled&&t.setInputSpellcheckEnabled(e.inputSpellcheckEnabled),typeof e.showOpenCodeUpdateNotifications==`boolean`&&e.showOpenCodeUpdateNotifications!==t.showOpenCodeUpdateNotifications&&t.setShowOpenCodeUpdateNotifications(e.showOpenCodeUpdateNotifications),typeof e.showToolFileIcons==`boolean`&&e.showToolFileIcons!==t.showToolFileIcons&&t.setShowToolFileIcons(e.showToolFileIcons),typeof e.showTurnChangedFiles==`boolean`&&e.showTurnChangedFiles!==t.showTurnChangedFiles&&t.setShowTurnChangedFiles(e.showTurnChangedFiles),typeof e.showExpandedBashTools==`boolean`&&e.showExpandedBashTools!==t.showExpandedBashTools&&t.setShowExpandedBashTools(e.showExpandedBashTools),typeof e.showSubagentTaskDetails==`boolean`&&e.showSubagentTaskDetails!==t.showSubagentTaskDetails&&t.setShowSubagentTaskDetails(e.showSubagentTaskDetails),typeof e.timeFormatPreference==`string`&&(e.timeFormatPreference===`auto`||e.timeFormatPreference===`12h`||e.timeFormatPreference===`24h`)&&e.timeFormatPreference!==t.timeFormatPreference&&t.setTimeFormatPreference(e.timeFormatPreference),typeof e.weekStartPreference==`string`&&(e.weekStartPreference===`auto`||e.weekStartPreference===`sunday`||e.weekStartPreference===`monday`)&&e.weekStartPreference!==t.weekStartPreference&&t.setWeekStartPreference(e.weekStartPreference),typeof e.desktopWindowControlsPosition==`string`&&(e.desktopWindowControlsPosition===`auto`||e.desktopWindowControlsPosition===`left`||e.desktopWindowControlsPosition===`right`)&&e.desktopWindowControlsPosition!==t.desktopWindowControlsPosition&&t.setDesktopWindowControlsPosition(e.desktopWindowControlsPosition),(e.sidebarView===`tasks`||e.sidebarView===`projects`)&&e.sidebarView!==t.sidebarView&&t.setSidebarView(e.sidebarView),typeof e.chatRenderMode==`string`&&(e.chatRenderMode===`sorted`||e.chatRenderMode===`live`)&&e.chatRenderMode!==t.chatRenderMode&&t.setChatRenderMode(e.chatRenderMode),typeof e.activityRenderMode==`string`&&(e.activityRenderMode===`collapsed`||e.activityRenderMode===`summary`)&&e.activityRenderMode!==t.activityRenderMode&&t.setActivityRenderMode(e.activityRenderMode),typeof e.collapsibleUserMessages==`boolean`&&e.collapsibleUserMessages!==t.collapsibleUserMessages&&t.setCollapsibleUserMessages(e.collapsibleUserMessages),typeof e.messageStreamTransport==`string`&&(e.messageStreamTransport===`auto`||e.messageStreamTransport===`ws`||e.messageStreamTransport===`sse`)&&n&&e.messageStreamTransport!==n.settingsMessageStreamTransport&&n.setSettingsMessageStreamTransport(e.messageStreamTransport),typeof e.promptNavigatorEnabled==`boolean`&&e.promptNavigatorEnabled!==t.promptNavigatorEnabled&&t.setPromptNavigatorEnabled(e.promptNavigatorEnabled),typeof e.showSplitAssistantMessageActions==`boolean`&&e.showSplitAssistantMessageActions!==t.showSplitAssistantMessageActions&&t.setShowSplitAssistantMessageActions(e.showSplitAssistantMessageActions),typeof e.showAssistantTps==`boolean`&&e.showAssistantTps!==t.showAssistantTps&&t.setShowAssistantTps(e.showAssistantTps),typeof e.reportUsage==`boolean`&&e.reportUsage!==t.reportUsage&&t.setReportUsage(e.reportUsage),typeof e.fontSize==`number`&&Number.isFinite(e.fontSize)&&e.fontSize!==t.fontSize&&t.setFontSize(e.fontSize),Array.isArray(e.draftStarters)){let n=wn(e.draftStarters);JSON.stringify(t.globalDraftStarters)!==JSON.stringify(n)&&t.setGlobalDraftStarters(n)}if(typeof e.terminalFontSize==`number`&&Number.isFinite(e.terminalFontSize)&&e.terminalFontSize!==t.terminalFontSize&&t.setTerminalFontSize(e.terminalFontSize),typeof e.editorFontSize==`number`&&Number.isFinite(e.editorFontSize)&&e.editorFontSize!==t.editorFontSize&&t.setEditorFontSize(e.editorFontSize),Ee(e.uiFont)&&e.uiFont!==t.uiFont&&t.setUiFont(e.uiFont),Ce(e.monoFont)&&e.monoFont!==t.monoFont&&t.setMonoFont(e.monoFont),typeof e.padding==`number`&&Number.isFinite(e.padding)&&e.padding!==t.padding&&t.setPadding(e.padding),typeof e.cornerRadius==`number`&&Number.isFinite(e.cornerRadius)&&e.cornerRadius!==t.cornerRadius&&t.setCornerRadius(e.cornerRadius),typeof e.inputBarOffset==`number`&&Number.isFinite(e.inputBarOffset)&&e.inputBarOffset!==t.inputBarOffset&&t.setInputBarOffset(e.inputBarOffset),e.shortcutOverrides&&!ir(e.shortcutOverrides,t.shortcutOverrides)&&S.setState({shortcutOverrides:e.shortcutOverrides}),typeof e.mobileKeyboardMode==`string`){let n=we(e.mobileKeyboardMode,t.mobileKeyboardMode);n!==t.mobileKeyboardMode&&t.setMobileKeyboardMode(n)}if(Array.isArray(e.favoriteModels)){let n=t.favoriteModels,r=or(n,e.favoriteModels);ar(n,r)||S.setState({favoriteModels:r})}if(Array.isArray(e.hiddenModels)){let n=t.hiddenModels,r=e.hiddenModels;ar(n,r)||S.setState({hiddenModels:r})}if(Array.isArray(e.collapsedModelProviders)){let n=t.collapsedModelProviders,r=e.collapsedModelProviders;sr(n,r)||S.setState({collapsedModelProviders:r})}if(Array.isArray(e.providerOrder)){let n=t.providerOrder,r=e.providerOrder;sr(n,r)||S.setState({providerOrder:r})}if(Array.isArray(e.recentModels)){let n=t.recentModels,r=or(n,e.recentModels);ar(n,r)||S.setState({recentModels:r})}if(Array.isArray(e.recentAgents)){let n=t.recentAgents,r=e.recentAgents;sr(n,r)||S.setState({recentAgents:r})}if(e.recentEfforts&&typeof e.recentEfforts==`object`){let n=t.recentEfforts,r=e.recentEfforts;ur(n,r)||S.setState({recentEfforts:r})}typeof e.diffLayoutPreference==`string`&&(e.diffLayoutPreference===`dynamic`||e.diffLayoutPreference===`inline`||e.diffLayoutPreference===`side-by-side`)&&e.diffLayoutPreference!==t.diffLayoutPreference&&t.setDiffLayoutPreference(e.diffLayoutPreference),typeof e.gitChangesViewMode==`string`&&(e.gitChangesViewMode===`flat`||e.gitChangesViewMode===`tree`)&&e.gitChangesViewMode!==t.gitChangesViewMode&&t.setGitChangesViewMode(e.gitChangesViewMode),typeof e.directoryShowHidden==`boolean`&&nn(e.directoryShowHidden,{persist:!1}),typeof e.filesViewShowGitignored==`boolean`&&ln(e.filesViewShowGitignored,{persist:!1})},yr=e=>{if(!e||typeof e!=`object`)return null;let t=e,n={};if(typeof t.hasRemoteProjects==`boolean`&&(n.hasRemoteProjects=t.hasRemoteProjects),t.hubProjectLayout!==void 0&&(n.hubProjectLayout=ke(t.hubProjectLayout)),typeof t.themeId==`string`&&t.themeId.length>0&&(n.themeId=t.themeId),(t.useSystemTheme===!0||t.useSystemTheme===!1)&&(n.useSystemTheme=t.useSystemTheme),typeof t.themeVariant==`string`&&(t.themeVariant===`light`||t.themeVariant===`dark`)&&(n.themeVariant=t.themeVariant),typeof t.lightThemeId==`string`&&t.lightThemeId.length>0&&(n.lightThemeId=t.lightThemeId),typeof t.darkThemeId==`string`&&t.darkThemeId.length>0&&(n.darkThemeId=t.darkThemeId),typeof t.lastDirectory==`string`&&t.lastDirectory.length>0&&(n.lastDirectory=t.lastDirectory),typeof t.homeDirectory==`string`&&t.homeDirectory.length>0&&(n.homeDirectory=t.homeDirectory),typeof t.opencodeBinary==`string`){let e=t.opencodeBinary.trim();n.opencodeBinary=e.length>0?e:void 0}typeof t.desktopLanAccessEnabled==`boolean`&&(n.desktopLanAccessEnabled=t.desktopLanAccessEnabled),typeof t.desktopKeepAwakeEnabled==`boolean`&&(n.desktopKeepAwakeEnabled=t.desktopKeepAwakeEnabled),typeof t.desktopMinimizeToTrayEnabled==`boolean`&&(n.desktopMinimizeToTrayEnabled=t.desktopMinimizeToTrayEnabled);let r=pr(t.projects);if([`manual`,`a-z`,`z-a`,`date-added`,`recent`].includes(t.projectSortOrder)&&(n.projectSortOrder=t.projectSortOrder),r&&(n.projects=r),typeof t.activeProjectId==`string`&&t.activeProjectId.length>0&&(n.activeProjectId=t.activeProjectId),Array.isArray(t.securityScopedBookmarks)&&(n.securityScopedBookmarks=t.securityScopedBookmarks.filter(e=>typeof e==`string`&&e.length>0)),Array.isArray(t.pinnedDirectories)&&(n.pinnedDirectories=Array.from(new Set(t.pinnedDirectories.filter(e=>typeof e==`string`&&e.length>0)))),Array.isArray(t.draftStarters)&&(n.draftStarters=wn(t.draftStarters)),typeof t.draftStartersCraftGoalAdded==`boolean`&&(n.draftStartersCraftGoalAdded=t.draftStartersCraftGoalAdded),typeof t.showReasoningTraces==`boolean`&&(n.showReasoningTraces=t.showReasoningTraces),typeof t.sessionTitleRefreshEnabled==`boolean`&&(n.sessionTitleRefreshEnabled=t.sessionTitleRefreshEnabled),typeof t.sessionGoalEnabled==`boolean`&&(n.sessionGoalEnabled=t.sessionGoalEnabled),typeof t.collapsibleThinkingBlocks==`boolean`&&(n.collapsibleThinkingBlocks=t.collapsibleThinkingBlocks),typeof t.autoDeleteEnabled==`boolean`&&(n.autoDeleteEnabled=t.autoDeleteEnabled),typeof t.autoDeleteAfterDays==`number`&&Number.isFinite(t.autoDeleteAfterDays)&&(n.autoDeleteAfterDays=t.autoDeleteAfterDays),(t.sessionRetentionAction===`archive`||t.sessionRetentionAction===`delete`)&&(n.sessionRetentionAction=t.sessionRetentionAction),typeof t.defaultModel==`string`&&t.defaultModel.length>0&&(n.defaultModel=t.defaultModel),typeof t.defaultVariant==`string`&&t.defaultVariant.length>0&&(n.defaultVariant=t.defaultVariant),typeof t.defaultAgent==`string`&&t.defaultAgent.length>0&&(n.defaultAgent=t.defaultAgent),typeof t.smallModelUseDefault==`boolean`&&(n.smallModelUseDefault=t.smallModelUseDefault),typeof t.smallModelOverride==`string`&&t.smallModelOverride.length>0&&(n.smallModelOverride=t.smallModelOverride),(t.summaryModelMode===`provider`||t.summaryModelMode===`custom`)&&(n.summaryModelMode=t.summaryModelMode),typeof t.summaryProviderID==`string`&&t.summaryProviderID.length>0&&(n.summaryProviderID=t.summaryProviderID),typeof t.summaryModelID==`string`&&t.summaryModelID.length>0&&(n.summaryModelID=t.summaryModelID),typeof t.summaryCustomModelID==`string`&&t.summaryCustomModelID.length>0&&(n.summaryCustomModelID=t.summaryCustomModelID),typeof t.summaryCustomBaseURL==`string`&&(n.summaryCustomBaseURL=t.summaryCustomBaseURL),typeof t.hasSummaryCustomAPIToken==`boolean`&&(n.hasSummaryCustomAPIToken=t.hasSummaryCustomAPIToken),typeof t.summaryCommitPrompt==`string`&&(n.summaryCommitPrompt=t.summaryCommitPrompt),typeof t.summarySessionTitlePrompt==`string`&&(n.summarySessionTitlePrompt=t.summarySessionTitlePrompt),typeof t.autoCreateWorktree==`boolean`&&(n.autoCreateWorktree=t.autoCreateWorktree),typeof t.gitmojiEnabled==`boolean`&&(n.gitmojiEnabled=t.gitmojiEnabled),Et(t.followUpBehavior)?n.followUpBehavior=t.followUpBehavior:typeof t.queueModeEnabled==`boolean`&&(n.followUpBehavior=Dt(void 0,t.queueModeEnabled)),typeof t.showDeletionDialog==`boolean`&&(n.showDeletionDialog=t.showDeletionDialog),typeof t.nativeNotificationsEnabled==`boolean`&&(n.nativeNotificationsEnabled=t.nativeNotificationsEnabled),typeof t.notificationMode==`string`&&(t.notificationMode===`always`||t.notificationMode===`hidden-only`)&&(n.notificationMode=t.notificationMode),typeof t.notifyOnSubtasks==`boolean`&&(n.notifyOnSubtasks=t.notifyOnSubtasks),typeof t.notifyOnCompletion==`boolean`&&(n.notifyOnCompletion=t.notifyOnCompletion),typeof t.notifyOnError==`boolean`&&(n.notifyOnError=t.notifyOnError),typeof t.notifyOnQuestion==`boolean`&&(n.notifyOnQuestion=t.notifyOnQuestion),typeof t.notifyOnPermission==`boolean`&&(n.notifyOnPermission=t.notifyOnPermission),typeof t.notifyOnScheduledTasks==`boolean`&&(n.notifyOnScheduledTasks=t.notifyOnScheduledTasks),typeof t.notifyOnAssistants==`boolean`&&(n.notifyOnAssistants=t.notifyOnAssistants),typeof t.notifyOnGoals==`boolean`&&(n.notifyOnGoals=t.notifyOnGoals),t.notificationTemplates&&typeof t.notificationTemplates==`object`){let e=t.notificationTemplates,r=t=>{let n=e[t];if(!n||typeof n!=`object`)return;let r=n;return{title:typeof r.title==`string`?r.title:``,message:typeof r.message==`string`?r.message:``}},i=r(`completion`),a=r(`error`),o=r(`question`),s=r(`subtask`);(i||a||o||s)&&(n.notificationTemplates={completion:i??{title:`Task Complete`,message:`Your task has finished.`},error:a??{title:`Error Occurred`,message:`An error occurred while processing your task.`},question:o??{title:`Input Needed`,message:`Please provide input to continue.`},subtask:s??{title:`Subtask Complete`,message:`A subtask has finished.`}})}if(typeof t.summarizeLastMessage==`boolean`&&(n.summarizeLastMessage=t.summarizeLastMessage),typeof t.summaryThreshold==`number`&&Number.isFinite(t.summaryThreshold)&&(n.summaryThreshold=Math.max(0,Math.round(t.summaryThreshold))),typeof t.summaryLength==`number`&&Number.isFinite(t.summaryLength)&&(n.summaryLength=Math.max(10,Math.round(t.summaryLength))),typeof t.maxLastMessageLength==`number`&&Number.isFinite(t.maxLastMessageLength)&&(n.maxLastMessageLength=Math.max(10,Math.round(t.maxLastMessageLength))),typeof t.usageAutoRefresh==`boolean`&&(n.usageAutoRefresh=t.usageAutoRefresh),typeof t.usageRefreshIntervalMs==`number`&&Number.isFinite(t.usageRefreshIntervalMs)&&(n.usageRefreshIntervalMs=t.usageRefreshIntervalMs),(t.usageDisplayMode===`usage`||t.usageDisplayMode===`remaining`)&&(n.usageDisplayMode=t.usageDisplayMode),typeof t.usageShowPredValues==`boolean`&&(n.usageShowPredValues=t.usageShowPredValues),Array.isArray(t.usageDropdownProviders)&&(n.usageDropdownProviders=t.usageDropdownProviders.filter(e=>typeof e==`string`&&e.length>0)),typeof t.magpieUsageUrl==`string`&&(n.magpieUsageUrl=t.magpieUsageUrl),Array.isArray(t.magpieHiddenProviders)&&(n.magpieHiddenProviders=t.magpieHiddenProviders.filter(e=>typeof e==`string`&&e.startsWith(`magpie:`))),t.usageSelectedModels&&typeof t.usageSelectedModels==`object`){let e={};for(let[n,r]of Object.entries(t.usageSelectedModels))Array.isArray(r)&&(e[n]=r.filter(e=>typeof e==`string`));Object.keys(e).length>0&&(n.usageSelectedModels=e)}if(t.usageCollapsedFamilies&&typeof t.usageCollapsedFamilies==`object`){let e={};for(let[n,r]of Object.entries(t.usageCollapsedFamilies))Array.isArray(r)&&(e[n]=r.filter(e=>typeof e==`string`));Object.keys(e).length>0&&(n.usageCollapsedFamilies=e)}if(t.usageExpandedFamilies&&typeof t.usageExpandedFamilies==`object`){let e={};for(let[n,r]of Object.entries(t.usageExpandedFamilies))Array.isArray(r)&&(e[n]=r.filter(e=>typeof e==`string`));Object.keys(e).length>0&&(n.usageExpandedFamilies=e)}if(t.usageModelGroups&&typeof t.usageModelGroups==`object`){let e={};for(let[n,r]of Object.entries(t.usageModelGroups))if(r&&typeof r==`object`){let t=r,i={};Array.isArray(t.customGroups)&&(i.customGroups=t.customGroups.filter(e=>e&&typeof e==`object`).map(e=>({id:String(e.id??``),label:String(e.label??``),models:Array.isArray(e.models)?e.models.filter(e=>typeof e==`string`):[],order:typeof e.order==`number`?e.order:0}))),t.modelAssignments&&typeof t.modelAssignments==`object`&&(i.modelAssignments=Object.fromEntries(Object.entries(t.modelAssignments).filter(([,e])=>typeof e==`string`).map(([e,t])=>[e,String(t)]))),t.renamedGroups&&typeof t.renamedGroups==`object`&&(i.renamedGroups=Object.fromEntries(Object.entries(t.renamedGroups).filter(([,e])=>typeof e==`string`).map(([e,t])=>[e,String(t)]))),Object.keys(i).length>0&&(e[n]=i)}Object.keys(e).length>0&&(n.usageModelGroups=e)}typeof t.inputSpellcheckEnabled==`boolean`&&(n.inputSpellcheckEnabled=t.inputSpellcheckEnabled),typeof t.showOpenCodeUpdateNotifications==`boolean`&&(n.showOpenCodeUpdateNotifications=t.showOpenCodeUpdateNotifications),typeof t.openCodeUpdateToastDismissedVersion==`string`&&(n.openCodeUpdateToastDismissedVersion=t.openCodeUpdateToastDismissedVersion.trim().slice(0,128)),typeof t.showToolFileIcons==`boolean`&&(n.showToolFileIcons=t.showToolFileIcons),typeof t.showTurnChangedFiles==`boolean`&&(n.showTurnChangedFiles=t.showTurnChangedFiles),typeof t.showExpandedBashTools==`boolean`&&(n.showExpandedBashTools=t.showExpandedBashTools),typeof t.showSubagentTaskDetails==`boolean`&&(n.showSubagentTaskDetails=t.showSubagentTaskDetails),typeof t.timeFormatPreference==`string`&&(t.timeFormatPreference===`auto`||t.timeFormatPreference===`12h`||t.timeFormatPreference===`24h`)&&(n.timeFormatPreference=t.timeFormatPreference),typeof t.weekStartPreference==`string`&&(t.weekStartPreference===`auto`||t.weekStartPreference===`sunday`||t.weekStartPreference===`monday`)&&(n.weekStartPreference=t.weekStartPreference),typeof t.desktopWindowControlsPosition==`string`&&(t.desktopWindowControlsPosition===`auto`||t.desktopWindowControlsPosition===`left`||t.desktopWindowControlsPosition===`right`)&&(n.desktopWindowControlsPosition=t.desktopWindowControlsPosition),(t.sidebarView===`tasks`||t.sidebarView===`projects`)&&(n.sidebarView=t.sidebarView),typeof t.chatRenderMode==`string`&&(t.chatRenderMode===`sorted`||t.chatRenderMode===`live`)&&(n.chatRenderMode=t.chatRenderMode),typeof t.messageStreamTransport==`string`&&(t.messageStreamTransport===`auto`||t.messageStreamTransport===`ws`||t.messageStreamTransport===`sse`)&&(n.messageStreamTransport=t.messageStreamTransport),typeof t.activityRenderMode==`string`&&(t.activityRenderMode===`collapsed`||t.activityRenderMode===`summary`)&&(n.activityRenderMode=t.activityRenderMode),typeof t.collapsibleUserMessages==`boolean`&&(n.collapsibleUserMessages=t.collapsibleUserMessages),typeof t.showSplitAssistantMessageActions==`boolean`&&(n.showSplitAssistantMessageActions=t.showSplitAssistantMessageActions),typeof t.showAssistantTps==`boolean`&&(n.showAssistantTps=t.showAssistantTps),typeof t.fontSize==`number`&&Number.isFinite(t.fontSize)&&(n.fontSize=t.fontSize),typeof t.terminalFontSize==`number`&&Number.isFinite(t.terminalFontSize)&&(n.terminalFontSize=t.terminalFontSize),typeof t.editorFontSize==`number`&&Number.isFinite(t.editorFontSize)&&(n.editorFontSize=t.editorFontSize),Ee(t.uiFont)&&(n.uiFont=t.uiFont),Ce(t.monoFont)&&(n.monoFont=t.monoFont),typeof t.padding==`number`&&Number.isFinite(t.padding)&&(n.padding=t.padding),typeof t.cornerRadius==`number`&&Number.isFinite(t.cornerRadius)&&(n.cornerRadius=t.cornerRadius),typeof t.inputBarOffset==`number`&&Number.isFinite(t.inputBarOffset)&&(n.inputBarOffset=t.inputBarOffset);let i=rr(t.shortcutOverrides);i&&(n.shortcutOverrides=i),typeof t.mobileKeyboardMode==`string`&&(t.mobileKeyboardMode===`native`||t.mobileKeyboardMode===`resize-content`)&&(n.mobileKeyboardMode=t.mobileKeyboardMode);let a=mr(t.favoriteModels,64,{preserveVariant:!0});a&&(n.favoriteModels=a);let o=mr(t.hiddenModels,1024);o&&(n.hiddenModels=o);let s=cr(t.collapsedModelProviders);s&&(n.collapsedModelProviders=s);let c=cr(t.providerOrder);c&&(n.providerOrder=c);let l=mr(t.recentModels,16,{preserveVariant:!0});l&&(n.recentModels=l);let u=cr(t.recentAgents);u&&(n.recentAgents=u);let d=lr(t.recentEfforts);if(d&&(n.recentEfforts=d),typeof t.diffLayoutPreference==`string`&&(t.diffLayoutPreference===`dynamic`||t.diffLayoutPreference===`inline`||t.diffLayoutPreference===`side-by-side`)&&(n.diffLayoutPreference=t.diffLayoutPreference),typeof t.gitChangesViewMode==`string`&&(t.gitChangesViewMode===`flat`||t.gitChangesViewMode===`tree`)&&(n.gitChangesViewMode=t.gitChangesViewMode),typeof t.directoryShowHidden==`boolean`&&(n.directoryShowHidden=t.directoryShowHidden),typeof t.filesViewShowGitignored==`boolean`&&(n.filesViewShowGitignored=t.filesViewShowGitignored),typeof t.openInAppId==`string`&&t.openInAppId.length>0&&(n.openInAppId=t.openInAppId),typeof t.pwaAppName==`string`){let e=t.pwaAppName.trim().replace(/\s+/g,` `).slice(0,64);n.pwaAppName=e.length>0?e:``}let f=nr(t.skillCatalogs);return f&&(n.skillCatalogs=f),typeof t.reportUsage==`boolean`&&(n.reportUsage=t.reportUsage),typeof t.globalBehaviorPrompt==`string`&&(n.globalBehaviorPrompt=t.globalBehaviorPrompt),typeof t.responseStyleEnabled==`boolean`&&(n.responseStyleEnabled=t.responseStyleEnabled),typeof t.responseStylePreset==`string`&&(t.responseStylePreset===`concise`||t.responseStylePreset===`detailed`||t.responseStylePreset===`mentor`||t.responseStylePreset===`pushback`||t.responseStylePreset===`noFiller`||t.responseStylePreset===`matchEnergy`||t.responseStylePreset===`warmPeer`||t.responseStylePreset===`custom`)&&(n.responseStylePreset=t.responseStylePreset),typeof t.responseStyleCustomInstructions==`string`&&(n.responseStyleCustomInstructions=t.responseStyleCustomInstructions),typeof t.dictationEnabled==`boolean`&&(n.dictationEnabled=t.dictationEnabled),t.sttProvider===`local`||t.sttProvider===`openai-compatible`||t.sttProvider===`volcengine`?n.sttProvider=t.sttProvider:t.sttProvider===`server`?n.sttProvider=`openai-compatible`:(t.sttProvider===`browser`||t.sttProvider===`wasm`)&&(n.sttProvider=`local`),typeof t.sttServerUrl==`string`&&(n.sttServerUrl=t.sttServerUrl.trim()),typeof t.sttModel==`string`&&(n.sttModel=t.sttModel.trim()),typeof t.sttLocalModel==`string`&&(n.sttLocalModel=t.sttLocalModel.trim()),typeof t.sttLanguage==`string`&&(n.sttLanguage=t.sttLanguage.trim()),n},I=new Map,br=new Map,xr=2e3,Sr=async e=>{let t=I.get(e);if(t&&Date.now()-t.at<xr)return t.value;let n=br.get(e);if(n)return n;let r=(async()=>{if(o()!==e)return null;let t=gr();if(t)try{let n=yr((await t.load()).settings);return I.set(e,{value:n,at:Date.now()}),n}catch(e){console.warn(`Failed to load shared settings from runtime settings API:`,e)}if(o()!==e)return null;try{let t=await l(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});if(!t.ok)return null;let n=yr(await t.json().catch(()=>null));return I.set(e,{value:n,at:Date.now()}),n}catch(e){return console.warn(`Failed to load shared settings from server:`,e),null}})();br.set(e,r);try{return await r}finally{br.get(e)===r&&br.delete(e)}},Cr=(e=o())=>{I.delete(e)},wr=async()=>{if(typeof window>`u`)return;let e=o(),t=hr(),n=()=>!t?.hasHydrated||t.hasHydrated()||!t.onFinishHydration?Promise.resolve():new Promise(e=>{let n=!1,r=()=>{n||(n=!0,e())},i=t.onFinishHydration(()=>{i?.(),r()});t.hasHydrated?.()&&r()}),r=async t=>{if(await n(),o()===e){try{er(t)}catch(e){console.warn(`persistToLocalStorage failed:`,e)}try{vr(t)}catch(e){console.warn(`applyDesktopUiPreferences failed:`,e)}tr(t)}};try{let t=await Sr(e);t&&o()===e&&await r(t)}catch(e){console.warn(`Failed to synchronise settings:`,e)}},L=null,R=null,z=null,Tr=[],Er=200,B=new Map,Dr=async e=>{for(;B.get(e)?.size;)await Promise.all([...B.get(e)])},Or=async()=>{let e=L,t=R,n=Tr;if(L=null,R=null,z=null,Tr=[],!e||!t||Object.keys(e).length===0){n.forEach(e=>e());return}if(o()!==t){n.forEach(e=>e());return}let r=()=>o()===t,i=gr();if(i){try{let a=await i.save(e);_r(a,e,t),a&&r()&&(er(a),vr(a),tr(a),I.set(t,{value:yr(a),at:Date.now()})),n.forEach(e=>e());return}catch(e){console.warn(`Failed to update settings via runtime settings API:`,e)}if(!r()){n.forEach(e=>e());return}}try{let n=await l(`/api/config/settings`,{method:`PUT`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(e)});if(!n.ok){console.warn(`Failed to update shared settings via API:`,n.status,n.statusText);return}let i=await n.json().catch(()=>null);_r(i,e,t),i&&r()&&(er(i),vr(i),tr(i),I.set(t,{value:yr(i),at:Date.now()}))}catch(e){console.warn(`Failed to update shared settings via API:`,e)}finally{n.forEach(e=>e())}},V=async e=>{if(typeof window>`u`)return;let t=o();if(R&&R!==t){z&&=(clearTimeout(z),null),L=null,R=null;let e=Tr;Tr=[],e.forEach(e=>e())}let n={...L??{}},r=I.get(t)?.value;for(let[t,i]of Object.entries(e)){let e=r?.[t];Object.is(i,e)||i!==void 0&&e!==void 0&&JSON.stringify(i)===JSON.stringify(e)?delete n[t]:n[t]=i}if(L=n,R=t,Object.keys(n).length===0&&!z){L=null,R=null;return}z&&clearTimeout(z);let i=new Promise(e=>{Tr.push(e)}),a=B.get(t)??new Set;B.set(t,a),a.add(i),z=setTimeout(()=>void Or(),Er);try{await i}finally{a.delete(i),a.size===0&&B.get(t)===a&&B.delete(t)}},kr=async()=>{if(typeof window>`u`)return;let e=hr();try{let t=await mn();if(!t)return;let n=()=>pn(t);if(e?.hasHydrated?.()){n();return}if(n(),e?.onFinishHydration){let t=e.onFinishHydration(()=>{t?.(),n()})}}catch(e){console.warn(`Failed to load appearance preferences:`,e)}},Ar=3e4,jr=40,Mr=60,Nr=(e,t,n,r,i,a)=>{let o=e.trim(),s=t.trim().toLowerCase();return JSON.stringify([o,s,n,r,i,a])},Pr=(e,t)=>{try{let n=JSON.parse(e);return Array.isArray(n)&&n[0]===t}catch{return!1}},Fr=g()(_((e,t)=>({cache:{},cacheKeys:[],inFlight:{},async searchFiles(n,r,i=Mr,a){if(!n||n.trim().length===0)return[];let o=n.trim(),s=typeof r==`string`?r.trim():``,c=!!a?.includeHidden,l=a?.respectGitignore??!0,u=a?.type===`directory`?`directory`:`file`,d=Nr(o,s,i,c,l,u),f=Date.now(),p=t().cache[d];if(p&&f-p.timestamp<Ar)return p.files;let m=t().inFlight[d];if(m)return m;let h=b.searchFiles(s,{directory:o,limit:i,includeHidden:c,respectGitignore:l,dirs:u!==`file`,type:u}).then(t=>(e(e=>{if(e.inFlight[d]!==h)return e;let n={...e.cache,[d]:{files:t,timestamp:Date.now()}},r=e.cacheKeys.filter(e=>e!==d);for(r.push(d);r.length>jr;){let e=r.shift();e&&delete n[e]}return{cache:n,cacheKeys:r}}),t)).finally(()=>{e(e=>{if(e.inFlight[d]!==h)return e;let t={...e.inFlight};return delete t[d],{inFlight:t}})});return e(e=>({inFlight:{...e.inFlight,[d]:h}})),h},invalidateDirectory(t){if(!t||t.trim().length===0){e({cache:{},cacheKeys:[],inFlight:{}});return}let n=t.trim();e(e=>{let t={...e.cache},r=e.cacheKeys.filter(e=>!Pr(e,n)||(delete t[e],!1)),i=Object.entries(e.inFlight).filter(([e])=>!Pr(e,n));return{cache:t,cacheKeys:r,inFlight:Object.fromEntries(i)}})}}),{name:`file-search-store`})),Ir=()=>{if(typeof window>`u`)return!1;try{return window.localStorage.getItem(`yuri_stream_debug`)===`1`}catch{return!1}},Lr=`yuri_stream_perf`,Rr=()=>{if(typeof window>`u`)return!1;try{return window.localStorage.getItem(Lr)===`1`}catch{return!1}},zr=()=>typeof performance<`u`&&typeof performance.now==`function`?performance.now():Date.now(),Br=()=>{if(!Rr()||typeof window>`u`)return null;if(!window.__yuriStreamPerfState){let e=Date.now();window.__yuriStreamPerfState={counters:new Map,startedAt:e,lastUpdatedAt:e}}return window.__yuriStreamPerfState},Vr=e=>Array.from(e.entries()).map(([e,t])=>({metric:e,count:t.count,avg:t.count>0?Number((t.total/t.count).toFixed(3)):0,max:Number(t.max.toFixed(3)),total:Number(t.total.toFixed(3)),last:Number(t.last.toFixed(3))})).sort((e,t)=>t.total-e.total||t.count-e.count),Hr=(e,t)=>{let n=Br();if(!n)return;let r=n.counters.get(e)??{count:0,total:0,max:0,last:0};r.count+=1,r.total+=t,r.max=Math.max(r.max,t),r.last=t,n.counters.set(e,r),n.lastUpdatedAt=Date.now()},Ur=e=>{if(!(typeof window>`u`))try{if(e){window.localStorage.setItem(Lr,`1`),window.__yuriStreamPerfState={counters:new Map,startedAt:Date.now(),lastUpdatedAt:Date.now()};return}window.localStorage.removeItem(Lr),delete window.__yuriStreamPerfState,delete window.__yuriVsCodeStreamPerfState}catch{}},Wr=()=>{typeof window>`u`||(Rr()&&(window.__yuriStreamPerfState={counters:new Map,startedAt:Date.now(),lastUpdatedAt:Date.now()}),window.__yuriVsCodeStreamPerfState&&(window.__yuriVsCodeStreamPerfState={...window.__yuriVsCodeStreamPerfState,counters:new Map,startedAt:Date.now(),lastUpdatedAt:Date.now()}))},Gr=()=>{if(typeof window>`u`)return{enabled:!1,startedAt:null,lastUpdatedAt:null,durationMs:0,entries:[]};let e=window.__yuriStreamPerfState;return!Rr()||!e?{enabled:!1,startedAt:null,lastUpdatedAt:null,durationMs:0,entries:[]}:{enabled:!0,startedAt:e.startedAt,lastUpdatedAt:e.lastUpdatedAt,durationMs:Math.max(0,Date.now()-e.startedAt),entries:Vr(e.counters)}},Kr=()=>{if(typeof window>`u`)return{enabled:!1,startedAt:null,lastUpdatedAt:null,durationMs:0,entries:[]};let e=window.__yuriVsCodeStreamPerfState;if(!Rr()||!e)return{enabled:!1,startedAt:null,lastUpdatedAt:null,durationMs:0,entries:[]};let t=typeof e.startedAt==`number`?e.startedAt:null;return{enabled:!0,startedAt:t,lastUpdatedAt:typeof e.lastUpdatedAt==`number`?e.lastUpdatedAt:null,durationMs:t?Math.max(0,Date.now()-t):0,entries:Vr(e.counters)}},qr=(e,t=1)=>{Hr(e,t)},Jr=(e,t)=>{Hr(e,t)},Yr=(e,t)=>{if(!Rr())return t();let n=zr();try{return t()}finally{Hr(e,zr()-n)}},H=null,Xr=0,U=v(),Zr=oe(`lastDirectory`,{storage:U}),Qr=typeof Zr==`string`&&Zr.length>0,$r=e=>{try{Fr.getState().invalidateDirectory(e)}catch(e){console.warn(`Failed to invalidate file search cache:`,e)}},W=e=>{let t=e.trim();if(!t)return t;let n=t.replace(/\\/g,`/`).replace(/^([a-z]):/,(e,t)=>t.toUpperCase()+`:`);return n.length>1?n.replace(/\/+$/,``):n},ei=(e,t)=>{let n=e.trim();return n.startsWith(`~`)?n===`~`?t||n:(n.startsWith(`~/`)||n.startsWith(`~\\`))&&t?`${t}${n.slice(1)}`:n:n},ti=(e,t)=>W(ei(e,t)),ni=()=>{let e=oe(`homeDirectory`,{storage:U});if(typeof e!=`string`||e.trim().length===0)return null;let t=W(e);return t.length>0?t:null},ri=()=>{let e=oe(`lastDirectory`,{storage:U});if(typeof e!=`string`||e.trim().length===0)return null;let t=W(e);return t.length>0?t:null},ii=()=>{if(typeof process>`u`)return null;let e={},t=e?.HOME||e?.USERPROFILE||(e?.HOMEDRIVE&&e?.HOMEPATH?`${e.HOMEDRIVE}${e.HOMEPATH}`:void 0);if(typeof t==`string`&&t.trim().length>0){let e=W(t);return e.length>0?e:null}let n=process?.cwd?.();if(typeof n==`string`&&n.trim().length>0){let e=W(n);return e.length>0?e:null}return null},ai=()=>{if(typeof window<`u`){if(H)return H;let e=typeof window.__YURI_HOME__==`string`&&window.__YURI_HOME__.length>0?window.__YURI_HOME__:null;if(e&&e.length>0)return H=e,y(`homeDirectory`,e,{storage:U}),e;let t=ni();if(t&&!f())return H=t,t}return ii()||`/`},oi=e=>{if(typeof e!=`string`)return null;let t=e.trim();if(!t)return null;let n=t.replace(/\\/g,`/`);if(n.length>1){let e=n.replace(/\/+$/,``);if(e&&e.length>0)return e===`/`?null:e}return n===`/`||n.length===0?null:n},si=e=>(H=e,typeof window<`u`&&y(`homeDirectory`,e,{storage:U}),V({homeDirectory:e}),e),ci=async()=>{let e=e=>{let t=oi(e);return t?si(t):null};try{let t=e(await b.getFilesystemHome());if(t)return t}catch(e){console.warn(`Failed to obtain filesystem home directory:`,e)}try{let t=e((await b.getSystemInfo())?.homeDirectory);if(t)return t}catch(e){console.warn(`Failed to get home directory from system info:`,e)}try{let t=e(await p());if(t)return t}catch(e){console.warn(`Failed to obtain desktop-integrated home directory:`,e)}let t=ai();return e(t)||t},li=(()=>{if(!f())return null;let e=window.__VSCODE_CONFIG__?.workspaceFolder;if(typeof e!=`string`||e.trim().length===0)return null;let t=W(e);return t.length>0?t:null})()||ai(),ui=(()=>{let e=ri();return e&&!f()?ti(e,li):li})();ui&&b.setDirectory(ui);var di=!!(li&&li!==`/`),fi=g()(_((e,t)=>({currentDirectory:ui,directoryHistory:[ui],historyIndex:0,homeDirectory:li,hasPersistedDirectory:Qr,isHomeReady:di,isSwitchingDirectory:!1,setDirectory:(n,r)=>{let i=ti(n,H||t().homeDirectory||oe(`homeDirectory`,{storage:U}));Ir(),Oe(t().currentDirectory,i)&&(b.setDirectory(i),$r(),e(e=>{let t=[...e.directoryHistory.slice(0,e.historyIndex+1),i];return y(`lastDirectory`,i,{storage:U}),V({lastDirectory:i}),{currentDirectory:i,directoryHistory:t,historyIndex:t.length-1,hasPersistedDirectory:!0,isHomeReady:!0,isSwitchingDirectory:!1}}))},goBack:()=>{let n=t();if(n.historyIndex>0){let t=n.historyIndex-1,r=n.directoryHistory[t];b.setDirectory(r),$r(),y(`lastDirectory`,r,{storage:U}),V({lastDirectory:r}),e({currentDirectory:r,historyIndex:t,hasPersistedDirectory:!0,isHomeReady:!0,isSwitchingDirectory:!1})}},goForward:()=>{let n=t();if(n.historyIndex<n.directoryHistory.length-1){let t=n.historyIndex+1,r=n.directoryHistory[t];b.setDirectory(r),$r(),y(`lastDirectory`,r,{storage:U}),V({lastDirectory:r}),e({currentDirectory:r,historyIndex:t,hasPersistedDirectory:!0,isHomeReady:!0,isSwitchingDirectory:!1})}},goToParent:()=>{let{currentDirectory:e,setDirectory:n}=t();if(e===(H||t().homeDirectory||ai())||e===`/`)return;let r=e.endsWith(`/`)?e.slice(0,-1):e,i=r.lastIndexOf(`/`);n(i===-1?H||ai():i===0?`/`:r.substring(0,i))},goHome:async()=>{let e=H||t().homeDirectory||await ci();t().setDirectory(e)},synchronizeHomeDirectory:n=>{let r=t(),i=n;H=i;let a=r.homeDirectory!==i,o=oe(`lastDirectory`,{storage:U}),s=typeof o==`string`&&o.length>0,c=!s&&(r.currentDirectory===`/`||r.currentDirectory===r.homeDirectory||!r.currentDirectory);if(!a&&!c){r.isHomeReady||e({isHomeReady:!0});return}let l=typeof i==`string`&&i!==``&&i!==`/`,u=r.currentDirectory?ti(r.currentDirectory,i):r.currentDirectory,d=r.directoryHistory.map(e=>ti(e,i)),f=d.some((e,t)=>e!==r.directoryHistory[t]),p=!!(u&&u!==r.currentDirectory),m={homeDirectory:i,hasPersistedDirectory:s,isHomeReady:l};if(c?(m.currentDirectory=i,m.directoryHistory=[i],m.historyIndex=0,m.isSwitchingDirectory=!1):(p||f)&&(m.currentDirectory=u,m.directoryHistory=d,m.historyIndex=Math.min(r.historyIndex,d.length-1),m.isSwitchingDirectory=!1),e(()=>m),(c||p)&&l){let e=c?i:u;b.setDirectory(e),$r(),y(`lastDirectory`,e,{storage:U}),V({lastDirectory:e})}V({homeDirectory:i})}}),{name:`directory-store`}));typeof window<`u`&&(ci().then(e=>{fi.getState().synchronizeHomeDirectory(e)}),i(e=>{H=null;let t=++Xr;if(c(e)){let e=ni(),t=ri(),n=e||`/`,r=t||n;H=e,fi.setState({currentDirectory:r,directoryHistory:[r],historyIndex:0,homeDirectory:n,hasPersistedDirectory:!!t,isHomeReady:!!(e&&e!==`/`),isSwitchingDirectory:!1}),r&&(b.setDirectory(r),$r())}ci().then(e=>{t===Xr&&fi.getState().synchronizeHomeDirectory(e)})}));var pi=(e,i)=>{let a=t();return a?a.openWebSocket(r(e),i):n(i?new WebSocket(e,i):new WebSocket(e))},G=`/api/git`,mi=1200,hi=5e3,gi=2,_i=5e3,vi=`${G}/worktrees/queue-activation`,yi=`message_queue_activation_pending`,bi=`worktree_lifecycle_busy`,xi=`worktree_activation_stale`,Si=5e3,Ci=3e4,wi=[0,500,1e3,2e3,4e3,8e3,14e3],Ti=new Map,K=new Map,Ei=new Map,Di=new Map,Oi=new Map,ki=new Map,q=new Map,J=new Map,Ai=new Map,ji=new Map,Y=new Map,Mi=new Map,Ni=new Set,Pi=0,Fi=[],Ii=()=>Pi<gi?(Pi+=1,Promise.resolve()):new Promise(e=>{Fi.push(e)}),Li=()=>{let e=Fi.shift();if(e){e();return}Pi=Math.max(0,Pi-1)},Ri=async e=>{await Ii();try{return await e()}finally{Li()}},zi=Symbol.for(`yuri.git.discoveryGated`),Bi=e=>(Object.defineProperty(e,zi,{value:!0,configurable:!0}),e),Vi=e=>typeof e==`function`&&e[zi]===!0,X=e=>e.trim(),Hi=``,Z=e=>{let t=`${s()}\u0000${o()}`;return t!==Hi&&(Hi=t,Oi.clear(),ki.clear(),q.clear(),J.clear(),Ai.clear(),ji.clear(),Y.clear(),Mi.clear()),`${t}\u0000${X(e)}`},Ui=(e,t)=>t===`light`?`${X(e)}::light`:X(e),Wi=e=>Ei.get(X(e))??0,Q=e=>{let t=X(e);Ei.set(t,Wi(e)+1);for(let e of Array.from(Di.keys()))(e===t||e.startsWith(`${t}::`))&&Di.delete(e);for(let e of Array.from(Ti.keys()))(e===t||e.startsWith(`${t}::`))&&Ti.delete(e);for(let e of Array.from(K.keys()))(e===t||e.startsWith(`${t}::`))&&K.delete(e)},Gi=e=>Mi.get(Z(e))??0,Ki=e=>{let t=Z(e);t&&(Mi.set(t,Gi(e)+1),ji.delete(t),Y.delete(t))};function $(e,t,n){let r={...n};return t&&(r.directory=t),a().api(e,r)}var qi=(e,t,n)=>{if(!X(e))return;let r=Z(e),i=Date.now()+_i;Oi.set(r,{value:t,expiresAt:i}),typeof n==`string`&&n?J.set(Z(e),{value:{root:n},expiresAt:i}):J.delete(Z(e))};async function Ji(e){let t=Array.from(new Set(e.map(e=>X(e)).filter(Boolean))),n=new Map,r=s();if(t.length===0)return n;let i=Date.now(),o=[];for(let e of t){let t=Z(e),r=Oi.get(t),a=J.get(t);if(r&&r.expiresAt>i&&(!r.value||a&&a.expiresAt>i)){n.set(e,{isGitRepository:r.value,primaryRoot:a?.value.root??null});continue}o.push(e)}if(o.length===0)return n;let c=e=>{for(let t of e){let e=typeof t.directory==`string`?X(t.directory):``;if(!e)continue;let i=!!t.isGitRepository,a=typeof t.primaryRoot==`string`&&t.primaryRoot?t.primaryRoot:null;r===s()&&qi(e,i,a),n.set(e,{isGitRepository:i,primaryRoot:a})}},u=async e=>{await Promise.all(e.map(async e=>{try{let t=await Yi(e);if(r!==s())return;let i=t?(await Zi(e)).root:null;r===s()&&qi(e,t,t?i:null),n.set(e,{isGitRepository:t,primaryRoot:t?i:null})}catch{}}))},d=o.map(Z),f=[...new Set(d.map(e=>q.get(e)).filter(e=>e!==void 0))];if(f.length>0)return await Promise.allSettled(f),r===s()?Ji(t):n;let p=Ri(async()=>{if(r!==s())return;let e=new URLSearchParams;for(let t of o)e.append(`directories`,t);let t=a().api(`${G}/discover`),n=e.toString(),i=n?t.includes(`?`)?`${t}&${n}`:`${t}?${n}`:t,u=await l(i);if(u.status===501||!u.ok)throw Error(`Batch git discover unavailable: ${u.status} ${u.statusText}`);let d=await u.json().catch(()=>null),f=Array.isArray(d)?d:[];if(f.length===0&&o.length>0)throw Error(`Batch git discover returned empty payload`);c(f)});for(let e of d)q.set(e,p);try{await p}catch{}finally{for(let e of d)q.get(e)===p&&q.delete(e)}if(r!==s())return n;let m=o.filter(e=>!n.has(e));return m.length>0&&await u(m),n}async function Yi(e){let t=Z(e),n=s(),r=q.get(t);if(r&&await r.catch(()=>void 0),n!==s())throw new DOMException(`Git discovery runtime changed`,`AbortError`);let i=Date.now(),a=Oi.get(t);if(a&&a.expiresAt>i)return a.value;let o=ki.get(t);if(o)return o;let c=Ri(async()=>{if(n!==s())throw new DOMException(`Git discovery runtime changed`,`AbortError`);let r=await l($(`${G}/check`,e));if(!r.ok)throw Error(`Failed to check git repository: ${r.statusText}`);let i=!!(await r.json()).isGitRepository;return n===s()&&Oi.set(t,{value:i,expiresAt:Date.now()+hi}),i});ki.set(t,c);try{return await c}finally{ki.get(t)===c&&ki.delete(t)}}async function Xi(e,t){let n=t?.mode,r=Ui(e,n),i=Date.now(),a=Ti.get(r);if(a&&a.expiresAt>i)return a.value;let s=K.get(r);if(s)return s;let c=(async()=>{let t=Wi(e),i=o(),a=Di.get(r),s=a&&a.transport===i&&a.cacheVersion===t?a:null,c=await l($(`${G}/status`,e,{...n?{mode:n}:{},...s?{since:s.revision}:{}}));if(!c.ok)throw Error(`Failed to get git status: ${c.statusText}`);let u=await c.json(),d;if(`unchanged`in u&&u.unchanged===!0){if(!s||u.revision!==s.revision)throw Error(`Failed to get git status: unexpected unchanged response`);d=s.value}else{let{revision:n,...a}=u;d=a,typeof n==`string`&&Wi(e)===t&&Di.set(r,{revision:n,value:d,transport:i,cacheVersion:t})}return Wi(e)===t&&Ti.set(r,{value:d,expiresAt:Date.now()+mi}),d})();K.set(r,c);try{return await c}finally{K.get(r)===c&&K.delete(r)}}async function Zi(e){let t=Z(e),n=s(),r=q.get(t);if(r&&await r.catch(()=>void 0),n!==s())throw new DOMException(`Git discovery runtime changed`,`AbortError`);let i=Date.now(),a=J.get(t);if(a&&a.expiresAt>i)return a.value;let o=Ai.get(t);if(o)return o;let c=Ri(async()=>{if(n!==s())throw new DOMException(`Git discovery runtime changed`,`AbortError`);let r=await l($(`${G}/primary-root`,e));if(!r.ok)throw Error(`Failed to resolve git primary root: ${r.statusText}`);let i=await r.json().catch(()=>({}));if(typeof i.root!=`string`||!i.root.trim())throw Error(`Invalid git primary root response`);let a={root:i.root};return n===s()&&J.set(t,{value:a,expiresAt:Date.now()+_i}),a});Ai.set(t,c);try{return await c}finally{Ai.get(t)===c&&Ai.delete(t)}}async function Qi(e){let t=await l($(`${G}/toplevel`,e));if(!t.ok)throw Error(`Failed to resolve git toplevel: ${t.statusText}`);let n=await t.json().catch(()=>({}));return{root:typeof n.root==`string`&&n.root?n.root:e}}async function $i(e,t){let n=await l($(`${G}/commit-summaries`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({shas:t})});if(!n.ok)throw Error(`Failed to get git commit summaries: ${n.statusText}`);let r=await n.json().catch(()=>({}));return{commits:Array.isArray(r.commits)?r.commits.map(e=>({sha:typeof e.sha==`string`?e.sha:``,short:typeof e.short==`string`?e.short:``,subject:typeof e.subject==`string`?e.subject:``})).filter(e=>e.sha&&e.short):[]}}async function ea(e,t){let{path:n,staged:r,contextLines:i}=t;if(!n)throw Error(`path is required to fetch git diff`);let a=await l($(`${G}/diff`,e,{path:n,staged:r?`true`:void 0,context:i}));if(!a.ok)throw Error(`Failed to get git diff: ${a.statusText}`);return a.json()}async function ta(e,t){let{path:n,staged:r}=t;if(!n)throw Error(`path is required to fetch git file diff`);let i=await l($(`${G}/file-diff`,e,{path:n,staged:r?`true`:void 0}));if(!i.ok)throw Error(`Failed to get git file diff: ${i.statusText}`);return i.json()}async function na(e,t,n){if(!t)throw Error(`path is required to revert git changes`);let r=await l($(`${G}/revert`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:t,scope:n?.scope})});if(!r.ok){let e=await r.json().catch(()=>({error:r.statusText}));throw Error(e.error||`Failed to revert git changes`)}Q(e)}async function ra(e,t){await ia(e,[t])}async function ia(e,t){let n=t.map(e=>e.trim()).filter(Boolean);if(n.length===0)throw Error(`path is required to stage git changes`);let r=await l($(`${G}/stage`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({paths:n})});if(!r.ok){let e=await r.json().catch(()=>({error:r.statusText}));throw Error(e.error||`Failed to stage git changes`)}Q(e)}async function aa(e,t){await oa(e,[t])}async function oa(e,t){let n=t.map(e=>e.trim()).filter(Boolean);if(n.length===0)throw Error(`path is required to unstage git changes`);let r=await l($(`${G}/unstage`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({paths:n})});if(!r.ok){let e=await r.json().catch(()=>({error:r.statusText}));throw Error(e.error||`Failed to unstage git changes`)}Q(e)}async function sa(e,t,n){await ua(e,t,n,`stage`)}async function ca(e,t,n){await ua(e,t,n,`unstage`)}async function la(e,t,n){await ua(e,t,n,`discard`)}async function ua(e,t,n,r){if(!t)throw Error(`path is required to apply a git hunk`);if(typeof n!=`string`||!n.trim())throw Error(`patch is required to apply a git hunk`);let i=await l($(`${G}/apply-hunk`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:t,patch:n,action:r})});if(!i.ok){let e=await i.json().catch(()=>({error:i.statusText}));throw Error(e.error||`Failed to apply git hunk`)}Q(e)}async function da(e){if(!e)return!1;let t=await l($(`${G}/worktree-type`,e));if(!t.ok)throw Error(`Failed to detect worktree type: ${t.statusText}`);return!!(await t.json()).linked}async function fa(e,t){let n=await l($(`${G}/branches`,e),{signal:t?.signal});if(!n.ok)throw Error(`Failed to get branches: ${n.statusText}`);return n.json()}async function pa(e,t){if(!t?.branch)throw Error(`branch is required to delete a branch`);let n=await l($(`${G}/branches`,e),{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to delete branch`)}return n.json()}async function ma(e,t){if(!t?.branch)throw Error(`branch is required to delete remote branch`);let n=await l($(`${G}/remote-branches`,e),{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to delete remote branch`)}return n.json()}async function ha(e,t){let n=t?.remote?.trim();if(!n)throw Error(`remote is required to remove a remote`);let r=await l($(`${G}/remotes`,e),{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify({remote:n})});if(!r.ok){let e=await r.json().catch(()=>({error:r.statusText}));throw Error(e.error||`Failed to remove remote`)}return r.json()}async function ga(e,t,n){if(!Array.isArray(t)||t.length===0)throw Error(`No files provided to generate commit message`);let r={files:t};n?.zenModel&&(r.zenModel=n.zenModel),n?.providerId&&(r.providerId=n.providerId),n?.modelId&&(r.modelId=n.modelId);let i=await l($(`${G}/commit-message`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r)});if(!i.ok){let e=await i.json().catch(()=>({error:i.statusText}));console.error(`[git-generation][browser] http error`,{status:i.status,statusText:i.statusText,error:e});let t=typeof e?.traceId==`string`&&e.traceId?` (traceId: ${e.traceId})`:``;throw Error(`${e.error||`Failed to generate commit message`}${t}`)}let a=await i.json();if(!a?.message||typeof a.message!=`object`)throw Error(`Malformed commit generation response`);return{message:{subject:typeof a.message.subject==`string`&&a.message.subject.trim().length>0?a.message.subject.trim():``,highlights:Array.isArray(a.message.highlights)?a.message.highlights.filter(e=>typeof e==`string`&&e.trim().length>0).map(e=>e.trim()):[]}}}async function _a(e,t){let{base:n,head:r,context:i,zenModel:a,providerId:o,modelId:s}=t;if(!n||!r)throw Error(`base and head are required`);let c={base:n,head:r};i?.trim()&&(c.context=i.trim()),a&&(c.zenModel=a),o&&(c.providerId=o),s&&(c.modelId=s);let u=await l($(`${G}/pr-description`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(c)});if(!u.ok){let e=await u.json().catch(()=>({error:u.statusText}));throw Error(e.error||`Failed to generate PR description`)}let d=await u.json().catch(()=>null),f=typeof d?.title==`string`?d.title:``,p=typeof d?.body==`string`?d.body:``;if(!f&&!p)throw Error(`Malformed PR description response`);return{title:f,body:p}}async function va(e){let t=Z(e),n=s(),r=Date.now(),i=ji.get(t);if(i&&i.expiresAt>r)return i.value;let a=Y.get(t);if(a)return a;let o=Gi(e),c=Ri(async()=>{let r=await l($(`${G}/worktrees`,e));if(!r.ok){let e=await r.json().catch(()=>({error:r.statusText}));throw Error(e.error||`Failed to list worktrees`)}let i=await r.json();return n===s()&&o===Gi(e)&&ji.set(t,{value:i,expiresAt:Date.now()+_i}),i});Y.set(t,c);try{return await c}finally{Y.get(t)===c&&Y.delete(t)}}Bi(va);async function ya(e,t){let n=await l($(`${G}/worktrees/validate`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t??{})});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to validate worktree`)}return n.json()}async function ba(e){let t=await l($(`${G}/worktrees/bootstrap-status`,e));if(!t.ok){let e=await t.json().catch(()=>({error:t.statusText}));throw Error(e.error||`Failed to get worktree bootstrap status`)}return t.json()}async function xa(e,t){let n=await l($(`${G}/worktrees/preview`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t??{})});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to preview worktree`)}return n.json()}var Sa=e=>typeof e==`string`&&e.length>0,Ca=e=>{if(!e||typeof e!=`object`)return null;let t=e;if(!Sa(t.name)||!Sa(t.path))return null;let n={head:typeof t.head==`string`?t.head:``,name:t.name,branch:typeof t.branch==`string`?t.branch:``,path:t.path};return t.directoryCreated===!0&&(n.directoryCreated=!0),t.bootstrapStatus&&typeof t.bootstrapStatus==`object`&&(n.bootstrapStatus=t.bootstrapStatus),n},wa=(e,t,n)=>{if(e!==503||!t||typeof t!=`object`)return null;let r=t;if(r.code!==yi)return null;let i=Ca(r.worktree);if(!i)return null;let a=r.repair;if(!a||typeof a!=`object`)return null;let o=a;if(o.method!==`POST`||o.path!==vi)return null;let s=o.body;if(!s||typeof s!=`object`)return null;let c=s;return c.projectDirectory!==n||c.directory!==i.path?null:i},Ta=(e,t,n,r)=>`${e}\u0000${t}\u0000${n}\u0000${r}`,Ea=e=>new Promise(t=>{setTimeout(t,e)}),Da=async e=>{if(e.status===409){let t=await e.json().catch(()=>null);return t?.code===bi||t?.code===xi}return e.status===503&&(await e.json().catch(()=>null))?.code===yi},Oa=e=>e===400||e===401||e===403||e===501,ka=(e,t)=>{let n=o(),r=s(),i=Ta(n,r,e,t);if(Ni.has(i))return;Ni.add(i);let a=()=>o()===n&&s()===r;(async()=>{let n=Date.now(),r=0;for(;Date.now()-n<Ci;){if(!a())return;let i=wi[Math.min(r,wi.length-1)]??0;if(i>0){let e=Ci-(Date.now()-n);if(e<=0||(await Ea(Math.min(i,e)),!a()))return}let o=new AbortController,s=setTimeout(()=>o.abort(),Si);try{let n=await l($(vi,void 0),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({projectDirectory:e,directory:t}),signal:o.signal});if(n.ok||Oa(n.status))return;if(await Da(n)){r+=1;continue}return}catch{r+=1}finally{clearTimeout(s)}}})().catch(()=>{}).finally(()=>{Ni.delete(i)})};async function Aa(e,t){let n=await l($(`${G}/worktrees`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t??{})}),r=await n.json().catch(()=>null);if(n.ok){let t=Ca(r);if(t)return Ki(e),t;if(r&&typeof r==`object`)return Ki(e),r;throw Error(`Failed to create worktree`)}let i=wa(n.status,r,e);if(i)return Ki(e),ka(e,i.path),i;let a=r&&typeof r==`object`?r:{error:n.statusText};throw Error(a.error||`Failed to create worktree`)}async function ja(e,t){let n=await l($(`${G}/worktrees`,e),{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t??{})});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to delete worktree`)}let r=await n.json();return Ki(e),r}async function Ma(e,t,n={}){let r=await l($(`${G}/commit`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({message:t,addAll:n.addAll??!1,files:n.files,stageFiles:n.stageFiles})});if(!r.ok){let e=await r.json().catch(()=>({error:r.statusText}));throw Error(e.error||`Failed to create commit`)}let i=await r.json();return Q(e),i}async function Na(e,t={}){let n=await l($(`${G}/push`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to push`)}let r=await n.json();return Q(e),r}async function Pa(e,t={}){let n=await l($(`${G}/pull`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to pull`)}let r=await n.json();return Q(e),r}async function Fa(e,t={}){let n=await l($(`${G}/fetch`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to fetch`)}let r=await n.json();return Q(e),r}async function Ia(e){let t=await l($(`${G}/stashes`,e));if(!t.ok){let e=await t.json().catch(()=>({error:t.statusText}));throw Error(e.error||`Failed to list stashes`)}return t.json()}async function La(e,t){let n=await l($(`${G}/stashes/file-counts`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({refs:t})});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to count stash files`)}return n.json()}async function Ra(e,t={}){let n=await l($(`${G}/stash`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to stash changes`)}return n.json()}var za=async(e,t,n)=>{let r=await l($(`${G}/${t}`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)});if(!r.ok){let e=await r.json().catch(()=>({error:r.statusText}));throw Error(e.error||`Failed to ${t}`)}return r.json()},Ba=(e,t)=>za(e,`stash/apply`,t),Va=(e,t)=>za(e,`stash/pop`,t),Ha=(e,t)=>za(e,`stash/drop`,t);async function Ua(e,t){let n=await l($(`${G}/checkout`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({branch:t})});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to checkout branch`)}return n.json()}async function Wa(e,t,n){let r=await l($(`${G}/branches`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:t,startPoint:n})});if(!r.ok){let e=await r.json().catch(()=>({error:r.statusText}));throw Error(e.error||`Failed to create branch`)}return r.json()}async function Ga(e,t,n){let r=await l($(`${G}/branches/rename`,e),{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({oldName:t,newName:n})});if(!r.ok){let e=await r.json().catch(()=>({error:r.statusText}));throw Error(e.error||`Failed to rename branch`)}return r.json()}async function Ka(e,t={}){let n=await l($(`${G}/log`,e,{maxCount:t.maxCount,from:t.from,to:t.to,file:t.file,all:t.all?`true`:void 0}));if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(`Failed to get git log: ${e.error||n.statusText}`)}return n.json()}async function qa(e,t){let n=await l($(`${G}/commit-files`,e,{hash:t}));if(!n.ok)throw Error(`Failed to get commit files: ${n.statusText}`);return n.json()}async function Ja(e,t,n,r){let i=await l($(`${G}/commit-file-diff`,e,{hash:t,path:n,binary:r?`true`:void 0}));if(!i.ok)throw Error(`Failed to get commit file diff: ${i.statusText}`);return i.json()}async function Ya(){let e=await l($(`${G}/identities`,void 0));if(!e.ok)throw Error(`Failed to get git identities: ${e.statusText}`);return e.json()}async function Xa(e){let t=await l($(`${G}/identities`,void 0),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok){let e=await t.json().catch(()=>({error:t.statusText}));throw Error(e.error||`Failed to create git identity`)}return t.json()}async function Za(e,t){let n=await l($(`${G}/identities/${e}`,void 0),{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to update git identity`)}return n.json()}async function Qa(e){let t=await l($(`${G}/identities/${e}`,void 0),{method:`DELETE`});if(!t.ok){let e=await t.json().catch(()=>({error:t.statusText}));throw Error(e.error||`Failed to delete git identity`)}}async function $a(e){if(!e)return null;let t=await l($(`${G}/current-identity`,e));if(!t.ok)throw Error(`Failed to get current git identity: ${t.statusText}`);let n=await t.json();return n?{userName:n.userName??null,userEmail:n.userEmail??null,sshCommand:n.sshCommand??null}:null}async function eo(e){if(!e)return!1;let t=await l($(`${G}/has-local-identity`,e));if(!t.ok)throw Error(`Failed to check local identity: ${t.statusText}`);return(await t.json().catch(()=>null))?.hasLocalIdentity===!0}async function to(){let e=await l($(`${G}/global-identity`,void 0));if(!e.ok)throw Error(`Failed to get global git identity: ${e.statusText}`);let t=await e.json();return!t||!t.userName&&!t.userEmail?null:{userName:t.userName??null,userEmail:t.userEmail??null,sshCommand:t.sshCommand??null}}async function no(e,t){let n=await l($(`${G}/set-identity`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({profileId:t})});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to set git identity`)}return n.json()}async function ro(){let e=await l($(`${G}/discover-credentials`,void 0));if(!e.ok)throw Error(`Failed to discover git credentials: ${e.statusText}`);return e.json()}async function io(e,t){if(!e)return null;let n=await l($(`${G}/remote-url`,e,{remote:t}));return n.ok?(await n.json()).url??null:null}async function ao(e,t){let n=await l($(`${G}/remotes`,e),{signal:t?.signal});if(!n.ok)throw Error(`Failed to get remotes: ${n.statusText}`);return n.json()}async function oo(e,t){let n=await l($(`${G}/rebase`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to rebase`)}return n.json()}async function so(e){let t=await l($(`${G}/rebase/abort`,e),{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>({error:t.statusText}));throw Error(e.error||`Failed to abort rebase`)}return t.json()}async function co(e,t){let n=await l($(`${G}/merge`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to merge`)}return n.json()}async function lo(e,t){let n=await l($(`${G}/checkout-commit`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({hash:t})});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to checkout commit`)}return n.json()}async function uo(e,t){let n=await l($(`${G}/cherry-pick`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({hash:t})});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to cherry-pick`)}return n.json()}async function fo(e,t){let n=await l($(`${G}/revert-commit`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({hash:t})});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to revert commit`)}return n.json()}async function po(e,t,n,r){let i=await l($(`${G}/reset-to-commit`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({hash:t,mode:n,force:r})});if(!i.ok){let e=await i.json().catch(()=>({error:i.statusText}));throw Error(e.error||`Failed to reset`)}return i.json()}async function mo(e){let t=await l($(`${G}/merge/abort`,e),{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>({error:t.statusText}));throw Error(e.error||`Failed to abort merge`)}return t.json()}async function ho(e){let t=await l($(`${G}/rebase/continue`,e),{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>({error:t.statusText}));throw Error(e.error||`Failed to continue rebase`)}return t.json()}async function go(e){let t=await l($(`${G}/merge/continue`,e),{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>({error:t.statusText}));throw Error(e.error||`Failed to continue merge`)}return t.json()}async function _o(e,t){return await Ra(e,{message:t?.message}),{success:!0}}async function vo(e){return await Va(e,{ref:`stash@{0}`}),{success:!0}}async function yo(e){let t=await l($(`${G}/conflict-details`,e));if(!t.ok)throw Error(`Failed to get conflict details: ${t.statusText}`);return t.json()}async function bo(e,t){let n=await l(`${G}/validate-directory`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({directory:e,worktreeRoot:t})});if(!n.ok)throw Error(`Failed to validate worktree directory: ${n.statusText}`);return n.json()}async function xo(e){let t=await l(`${G}/canonicalize-worktree-state`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({directory:e})});if(!t.ok)throw Error(`Failed to canonicalize worktree state: ${t.statusText}`);return t.json()}export{ha as $,_n as $t,$i as A,tt as An,Jr as At,Fa as B,Yn as Bt,ga as C,pt as Cn,Gr as Ct,yo as D,D as Dn,Ir as Dt,qa as E,mt as En,Ur as Et,Xi as F,V as Ft,Vi as G,On as Gt,Na as H,Gn as Ht,ba as I,Dr as It,va as J,P as Jt,da as K,kn as Kt,to as L,Xn as Lt,ta as M,ke as Mn,kr as Mt,Ya as N,Cr as Nt,$a as O,Ke as On,qr as Ot,Ka as P,wr as Pt,oo as Q,bn as Qt,io as R,Qn as Rt,Ha as S,bt as Sn,fi as St,Ja as T,ft as Tn,Wr as Tt,eo as U,An as Ut,Pa as V,Kn as Vt,Ki as W,Dn as Wt,Va as X,yn as Xt,co as Y,hn as Yt,xa as Z,vn as Zt,Qa as _,ut as _n,Za as _t,Yi as a,un as an,na as at,ro as b,vt as bn,Ri as bt,uo as c,kt as cn,ra as ct,La as d,Ut as dn,_o as dt,Cn as en,Ga as et,Wa as f,Yt as fn,Ra as ft,pa as g,at as gn,ca as gt,Aa as h,Jt as hn,oa as ht,xo as i,ln as in,fo as it,ea as j,Ae as jn,Fr as jt,fa as k,$e as kn,Yr as kt,go as l,St as ln,ia as lt,Xa as m,Ht as mn,aa as mt,so as n,wn as nn,Zi as nt,Ua as o,rn as on,la as ot,Ma as p,k as pn,vo as pt,Ia as q,N as qt,Ba as r,xn as rn,Qi as rt,lo as s,Rt as sn,no as st,mo as t,Sn as tn,po as tt,ho as u,xt as un,sa as ut,ja as v,st as vn,ya as vt,_a as w,lt as wn,Kr as wt,Ji as x,yt as xn,pi as xt,ma as y,_t as yn,bo as yt,ao as z,Zn as zt};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{A as t,F as n,j as r}from"./platform-CiUKDeXd.js";import{ot as i,st as a}from"./vendor-base-ui-wXsskyKm.js";import{n as o}from"./vendor-react-BkccXcWz.js";import{n as s,t as c}from"./runtime-ead7P81A.js";import"./bootstrap-eLlfzqAI.js";import{i as l,t as u}from"./store-DRUKTpV5.js";var d=e(a(),1),f=o(),p=async(e,n)=>{if(!t())throw Error(`Desktop runtime is not available`);return r(e,n)},m=async()=>{if(n())try{await p(`desktop_start_window_drag`)}catch{}},h=async e=>{if(n())try{await p(`desktop_set_window_title`,{title:e})}catch{}},g=async(e,t)=>{if(n())try{await p(`desktop_set_window_theme`,{themeMode:e,themeVariant:t})}catch{}},_=async e=>{if(n())try{await p(`desktop_set_menu_locale`,{locale:e})}catch{}},v=async()=>{if(!n())return null;try{let e=await p(`desktop_get_app_version`);return typeof e==`string`&&e.trim().length>0?e:null}catch{return null}},y=d.createContext(null),b=i(),x=e=>{let t=(0,f.c)(19),{children:n}=e,r=l(S),i=l(C),a=l(w),o=l(T),p,m;t[0]===r?(p=t[1],m=t[2]):(p=()=>{typeof document>`u`||(document.documentElement.lang=r)},m=[r],t[0]=r,t[1]=p,t[2]=m),d.useEffect(p,m);let h,g;t[3]!==a||t[4]!==r?(h=()=>{a===null&&_(r)},g=[r,a],t[3]=a,t[4]=r,t[5]=h,t[6]=g):(h=t[5],g=t[6]),d.useEffect(h,g);let v;t[7]===i?v=t[8]:(v=(e,t)=>u(i,e,t),t[7]=i,t[8]=v);let x=v,E;t[9]===x?E=t[10]:(E=e=>x(s[e]),t[9]=x,t[10]=E);let D;t[11]!==r||t[12]!==o||t[13]!==x||t[14]!==E?(D={locale:r,locales:c,setLocale:o,label:E,t:x},t[11]=r,t[12]=o,t[13]=x,t[14]=E,t[15]=D):D=t[15];let O=D,k;return t[16]!==n||t[17]!==O?(k=(0,b.jsx)(y.Provider,{value:O,children:n}),t[16]=n,t[17]=O,t[18]=k):k=t[18],k};function S(e){return e.locale}function C(e){return e.dictionary}function w(e){return e.loadingLocale}function T(e){return e.setLocale}var E={en:`en-US`,fr:`fr-FR`,"zh-CN":`zh-CN`,"zh-TW":`zh-TW`,uk:`uk-UA`,es:`es-ES`,"pt-BR":`pt-BR`,ko:`ko-KR`,pl:`pl-PL`,ja:`ja-JP`},D=e=>E[e]??`en-US`,O=()=>D(l.getState().locale);function k(){let e=d.useContext(y);if(!e)throw Error(`useI18n must be used within I18nProvider`);return e}export{p as a,m as c,v as i,O as n,g as o,x as r,h as s,k as t};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{A as t,F as n,j as r}from"./platform-CiUKDeXd.js";import{ot as i,st as a}from"./vendor-base-ui-wXsskyKm.js";import{n as o}from"./vendor-react-BkccXcWz.js";import{n as s,t as c}from"./runtime-ead7P81A.js";import"./bootstrap-eLlfzqAI.js";import{i as l,t as u}from"./store-BHq6XijA.js";var d=e(a(),1),f=o(),p=async(e,n)=>{if(!t())throw Error(`Desktop runtime is not available`);return r(e,n)},m=async()=>{if(n())try{await p(`desktop_start_window_drag`)}catch{}},h=async e=>{if(n())try{await p(`desktop_set_window_title`,{title:e})}catch{}},g=async(e,t)=>{if(n())try{await p(`desktop_set_window_theme`,{themeMode:e,themeVariant:t})}catch{}},_=async e=>{if(n())try{await p(`desktop_set_menu_locale`,{locale:e})}catch{}},v=async()=>{if(!n())return null;try{let e=await p(`desktop_get_app_version`);return typeof e==`string`&&e.trim().length>0?e:null}catch{return null}},y=d.createContext(null),b=i(),x=e=>{let t=(0,f.c)(19),{children:n}=e,r=l(S),i=l(C),a=l(w),o=l(T),p,m;t[0]===r?(p=t[1],m=t[2]):(p=()=>{typeof document>`u`||(document.documentElement.lang=r)},m=[r],t[0]=r,t[1]=p,t[2]=m),d.useEffect(p,m);let h,g;t[3]!==a||t[4]!==r?(h=()=>{a===null&&_(r)},g=[r,a],t[3]=a,t[4]=r,t[5]=h,t[6]=g):(h=t[5],g=t[6]),d.useEffect(h,g);let v;t[7]===i?v=t[8]:(v=(e,t)=>u(i,e,t),t[7]=i,t[8]=v);let x=v,E;t[9]===x?E=t[10]:(E=e=>x(s[e]),t[9]=x,t[10]=E);let D;t[11]!==r||t[12]!==o||t[13]!==x||t[14]!==E?(D={locale:r,locales:c,setLocale:o,label:E,t:x},t[11]=r,t[12]=o,t[13]=x,t[14]=E,t[15]=D):D=t[15];let O=D,k;return t[16]!==n||t[17]!==O?(k=(0,b.jsx)(y.Provider,{value:O,children:n}),t[16]=n,t[17]=O,t[18]=k):k=t[18],k};function S(e){return e.locale}function C(e){return e.dictionary}function w(e){return e.loadingLocale}function T(e){return e.setLocale}var E={en:`en-US`,fr:`fr-FR`,"zh-CN":`zh-CN`,"zh-TW":`zh-TW`,uk:`uk-UA`,es:`es-ES`,"pt-BR":`pt-BR`,ko:`ko-KR`,pl:`pl-PL`,ja:`ja-JP`},D=e=>E[e]??`en-US`,O=()=>D(l.getState().locale);function k(){let e=d.useContext(y);if(!e)throw Error(`useI18n must be used within I18nProvider`);return e}export{p as a,m as c,v as i,O as n,g as o,x as r,h as s,k as t};
@@ -1 +1 @@
1
- import{r as e}from"./Icon-B-w2YKpn.js";var t=(e,t)=>{if(!t||t.length<2)return e;let n=t.map(e=>e.name).filter(Boolean).sort((e,t)=>t.length-e.length);return e.map(([e,t])=>{let r=n.find(t=>e.startsWith(`${t} · `));return r?[e,{...t,accountName:r}]:[e,t]})},n=(e,t)=>{let n=e[t]?.accountName;return!n||t>0&&e[t-1].accountName===n?null:new Set(e.map(e=>e.accountName).filter(Boolean)).size>1?n:null},r=(e,t)=>n(e.map(([,e])=>e),t),i={globe:`global`,server:`server`,"circle-check":`checkbox-circle`,"circle-x":`close-circle`,"window-analytics":`bar-chart-box`};function a(t){return t?Object.hasOwn(i,t)?i[t]:Object.hasOwn(e,t)?t:void 0:void 0}export{t as i,r as n,n as r,a as t};
1
+ import{r as e}from"./Icon-CeG6IExS.js";var t=(e,t)=>{if(!t||t.length<2)return e;let n=t.map(e=>e.name).filter(Boolean).sort((e,t)=>t.length-e.length);return e.map(([e,t])=>{let r=n.find(t=>e.startsWith(`${t} · `));return r?[e,{...t,accountName:r}]:[e,t]})},n=(e,t)=>{let n=e[t]?.accountName;return!n||t>0&&e[t-1].accountName===n?null:new Set(e.map(e=>e.accountName).filter(Boolean)).size>1?n:null},r=(e,t)=>n(e.map(([,e])=>e),t),i={globe:`global`,server:`server`,"circle-check":`checkbox-circle`,"circle-x":`close-circle`,"window-analytics":`bar-chart-box`};function a(t){return t?Object.hasOwn(i,t)?i[t]:Object.hasOwn(e,t)?t:void 0:void 0}export{t as i,r as n,n as r,a as t};
@@ -1 +1 @@
1
- import"./rolldown-runtime-hePW80VL.js";import{ot as e,st as t}from"./vendor-base-ui-wXsskyKm.js";import{n}from"./vendor-react-BkccXcWz.js";import{no as r}from"./ui-CHdferA1.js";var i=n();t();var a=e();function o(e){let t=(0,i.c)(23),n,o,s,c,l,u;t[0]===e?(n=t[1],o=t[2],s=t[3],c=t[4],l=t[5],u=t[6]):({className:o,type:u,bordered:n,placeholder:c,endAdornment:s,...l}=e,t[0]=e,t[1]=n,t[2]=o,t[3]=s,t[4]=c,t[5]=l,t[6]=u);let d=c||` `,f=n!==void 0&&`border border-transparent ring-0 focus:ring-0 aria-invalid:ring-1 aria-invalid:focus:ring-1`,p=n&&`border-[var(--form-surface-border)]`,m=s&&`pe-11`,h;t[7]!==o||t[8]!==f||t[9]!==p||t[10]!==m?(h=r(`text-foreground file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground bg-[var(--surface-elevated)] appearance-none flex h-9 w-full min-w-0 rounded-lg px-3 py-1 typography-markdown outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:typography-ui-label file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:typography-ui-label`,`ring-1 ring-inset ring-border/60 transition duration-200 ease-out`,`hover:[&:not(:focus)]:bg-[var(--surface-subtle)] hover:[&:not(:focus)]:ring-transparent`,`focus:ring-2 focus:ring-[var(--interactive-focus-ring)] focus-visible:outline-none`,`aria-invalid:ring-[var(--status-error)] aria-invalid:focus:ring-[var(--status-error)]`,f,p,o,m),t[7]=o,t[8]=f,t[9]=p,t[10]=m,t[11]=h):h=t[11];let g;t[12]!==n||t[13]!==l||t[14]!==d||t[15]!==h||t[16]!==u?(g=(0,a.jsx)(`input`,{type:u,"data-slot":`input`,"data-bordered":n,placeholder:d,className:h,spellCheck:!1,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`off`,...l}),t[12]=n,t[13]=l,t[14]=d,t[15]=h,t[16]=u,t[17]=g):g=t[17];let _=g;if(!s)return _;let v;t[18]===s?v=t[19]:(v=(0,a.jsx)(`div`,{"data-slot":`input-end-adornment`,className:`absolute inset-y-0 end-0 flex items-center`,children:s}),t[18]=s,t[19]=v);let y;return t[20]!==_||t[21]!==v?(y=(0,a.jsxs)(`div`,{"data-slot":`input-wrapper`,className:`relative min-w-0 w-full flex-1`,children:[_,v]}),t[20]=_,t[21]=v,t[22]=y):y=t[22],y}export{o as t};
1
+ import"./rolldown-runtime-hePW80VL.js";import{ot as e,st as t}from"./vendor-base-ui-wXsskyKm.js";import{n}from"./vendor-react-BkccXcWz.js";import{no as r}from"./ui-Cd2-HQSa.js";var i=n();t();var a=e();function o(e){let t=(0,i.c)(23),n,o,s,c,l,u;t[0]===e?(n=t[1],o=t[2],s=t[3],c=t[4],l=t[5],u=t[6]):({className:o,type:u,bordered:n,placeholder:c,endAdornment:s,...l}=e,t[0]=e,t[1]=n,t[2]=o,t[3]=s,t[4]=c,t[5]=l,t[6]=u);let d=c||` `,f=n!==void 0&&`border border-transparent ring-0 focus:ring-0 aria-invalid:ring-1 aria-invalid:focus:ring-1`,p=n&&`border-[var(--form-surface-border)]`,m=s&&`pe-11`,h;t[7]!==o||t[8]!==f||t[9]!==p||t[10]!==m?(h=r(`text-foreground file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground bg-[var(--surface-elevated)] appearance-none flex h-9 w-full min-w-0 rounded-lg px-3 py-1 typography-markdown outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:typography-ui-label file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:typography-ui-label`,`ring-1 ring-inset ring-border/60 transition duration-200 ease-out`,`hover:[&:not(:focus)]:bg-[var(--surface-subtle)] hover:[&:not(:focus)]:ring-transparent`,`focus:ring-2 focus:ring-[var(--interactive-focus-ring)] focus-visible:outline-none`,`aria-invalid:ring-[var(--status-error)] aria-invalid:focus:ring-[var(--status-error)]`,f,p,o,m),t[7]=o,t[8]=f,t[9]=p,t[10]=m,t[11]=h):h=t[11];let g;t[12]!==n||t[13]!==l||t[14]!==d||t[15]!==h||t[16]!==u?(g=(0,a.jsx)(`input`,{type:u,"data-slot":`input`,"data-bordered":n,placeholder:d,className:h,spellCheck:!1,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`off`,...l}),t[12]=n,t[13]=l,t[14]=d,t[15]=h,t[16]=u,t[17]=g):g=t[17];let _=g;if(!s)return _;let v;t[18]===s?v=t[19]:(v=(0,a.jsx)(`div`,{"data-slot":`input-end-adornment`,className:`absolute inset-y-0 end-0 flex items-center`,children:s}),t[18]=s,t[19]=v);let y;return t[20]!==_||t[21]!==v?(y=(0,a.jsxs)(`div`,{"data-slot":`input-wrapper`,className:`relative min-w-0 w-full flex-1`,children:[_,v]}),t[20]=_,t[21]=v,t[22]=y):y=t[22],y}export{o as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{R as t,l as n,u as r}from"./platform-CiUKDeXd.js";import{a as i,i as a,r as o}from"./vendor-zustand-CTekDqaS.js";import{ot as s,st as c}from"./vendor-base-ui-wXsskyKm.js";import{St as l,an as u,jt as d,on as f}from"./gitApiHttp-Bswf6gnl.js";import{t as p}from"./safeStorage-DTOhKN0V.js";import{i as m,t as h}from"./vendor-pathe-vBmvQE8f.js";import{n as g}from"./vendor-react-BkccXcWz.js";import{s as _,u as v}from"./vendor-tanstack-react-query-DIb_ItL-.js";import{E as y}from"./runtime-file-resource-C5kmYlLv.js";import{o as b}from"./path-utils-jGozTg9d.js";import{r as x}from"./vendor-reactuses-core-DjKFMfz7.js";import{r as S}from"./useUIStore-C3ewjGgP.js";import{o as C,s as w}from"./spacedFileMention-Ds4GtgiF.js";import{Ba as T,Fi as E,Oi as D,Pa as O,R as k,Yi as A,_ as j,b as M,bt as N,f as P,lo as ee,no as F,ua as I,ut as L,xa as R,za as te}from"./ui-CHdferA1.js";import{n as z}from"./Icon-B-w2YKpn.js";import{s as ne}from"./remoteProjectQueries-BXrXdLjN.js";import{t as re}from"./i18n-Dojvs57M.js";import{t as ie}from"./ScrollableOverlay-CkX-buJm.js";import{t as ae}from"./useDebouncedValue-BHlMPqY8.js";import{t as oe}from"./AgentAvatar-CNOu_vy0.js";import{c as se,d as ce,l as le,n as ue,r as de,t as fe}from"./fileMentionTouchSelection-B_62hIQI.js";import{a as pe,o as me,s as he}from"./fileMentionAutocompleteState-B9411b4o.js";var ge=(e,t)=>{let n=t.trim();if(!n)return[...e].sort((e,t)=>e.isBuiltIn===t.isBuiltIn?e.name.localeCompare(t.name):e.isBuiltIn?-1:1);let r=w([...e],n,e=>[e.name,e.description??``]);return r.sort((e,t)=>e.score===t.score?e.item.isBuiltIn===t.item.isBuiltIn?e.item.name.localeCompare(t.item.name):e.item.isBuiltIn?-1:1:e.score-t.score),r.map(e=>e.item)},_e=(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}),ve=(e,t)=>e.highlightedIndex===t.highlightedIndex&&_e(e.rows,t.rows),ye=(e,t)=>_e(e,t)?e:t.slice(),be=(e,t,n)=>{e&&(t.current&&ve(t.current,n)||(t.current=n,e(n)))},xe=(e,t)=>{t.current=null,e?.({rows:[],highlightedIndex:0})},B=e(c(),1),V=g(),Se=e=>e.directories.flatMap(e=>e.sessions),H=(e,t)=>({...ne(e,t.location.hostId),select:Se}),Ce=async(e,t,n)=>{n.sdk();let r=await e.fetchQuery(H(t,n));return n.sdk(),Se(r)},U=(e,t,n,r)=>{n.sdk();let i=e.getQueryData(H(t,n).queryKey);for(let e of i?.directories??[]){let t=e.sessions.find(e=>e.id===r);if(t)return t.title||r}return r},W=(e,t,n,r={})=>({queryKey:[...e.queryScope,`composer-files`,t,n,r],staleTime:3e4,gcTime:3e4,queryFn:async({signal:i})=>{let a=await e.sdk().file.find({query:t,location:{directory:e.location.directory},limit:n,type:r.type},{signal:i});if(e.sdk(),i.throwIfAborted(),!Array.isArray(a.data))throw Error(`File search returned no data`);return a.data.map(t=>{let n=m(t.path),r=h(n);return{name:r,path:b(e.location.directory,n),relativePath:n,extension:r.includes(`.`)?r.split(`.`).pop()?.toLowerCase():void 0,isDirectory:t.type===`directory`}})}}),G=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},K=e=>/^[A-Za-z]:\//.test(e)?e.toLowerCase():e,q=e=>e.startsWith(`yuri-remote-location:`)?n(e):G(e),J=(e,t)=>{let n=G(r(t,`local`).directory),i=G(e);if(!n||!i)return!1;let a=K(n),o=K(i);return o===a||o.startsWith(a.endsWith(`/`)?a:`${a}/`)},we=e=>{if(!e||typeof e!=`object`)return{};let t=e,n={};for(let[e,r]of Object.entries(t)){let t;try{t=q(e)}catch{continue}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=>G(e)).filter(e=>J(e,t)))):[],o=Array.isArray(i.expandedPaths)?Array.from(new Set(i.expandedPaths.filter(e=>typeof e==`string`).map(e=>G(e)).filter(e=>J(e,t)))):[],s=typeof i.selectedPath==`string`?G(i.selectedPath):null,c=s&&J(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])),i=u.selectedPath??c??e[0]??null;n[t]={openPaths:e,selectedPath:i,expandedPaths:r,touchedAt:Math.max(u.touchedAt,l)};continue}n[t]={openPaths:a,selectedPath:c,expandedPaths:o,touchedAt:l}}return n},Y=(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},X=e=>e?{...e,touchedAt:Date.now()}:{openPaths:[],selectedPath:null,expandedPaths:[],touchedAt:Date.now()},Z=i()(o(a((e,t)=>({byRoot:{},addOpenPath:(t,n,r)=>{let i=q((t||``).trim()),a=G((n||``).trim());!i||!a||!r?.allowOutsideRoot&&!J(a,i)||e(e=>{let t=e.byRoot[i],n=X(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:Y({...e.byRoot,[i]:{...n,openPaths:o,selectedPath:s}},20)}})},removeOpenPath:(t,n)=>{let r=q((t||``).trim()),i=G((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=K(i),a=e=>K(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:Y({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeOpenPathsByPrefix:(t,n)=>{let r=q((t||``).trim()),i=G((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=K(i),a=n.endsWith(`/`)?n:`${n}/`,o=e=>{let t=K(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:Y({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeExpandedPathsByPrefix:(t,n)=>{let r=q((t||``).trim()),i=G((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=K(i),a=n.endsWith(`/`)?n:`${n}/`,o=t.expandedPaths.filter(e=>{let t=K(e);return t!==n&&!t.startsWith(a)});return o.length===t.expandedPaths.length?e:{byRoot:Y({...e.byRoot,[r]:{...t,expandedPaths:o,touchedAt:Date.now()}},20)}})},setSelectedPath:(t,n,r)=>{let i=q((t||``).trim()),a=n?G(n.trim()):null;!i||a&&!r?.allowOutsideRoot&&!J(a,i)||e(e=>{let t=e.byRoot[i],n=X(t),r=a&&!n.openPaths.includes(a)?[...n.openPaths,a]:n.openPaths;return t&&t.selectedPath===a&&r===t.openPaths?e:{byRoot:Y({...e.byRoot,[i]:{...n,openPaths:r,selectedPath:a}},20)}})},ensureSelectedPath:e=>{let n=q((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=q((t||``).trim()),i=G((n||``).trim());!r||!i||!J(i,r)||e(e=>{let t=e.byRoot[r],n=X(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:Y({...e.byRoot,[r]:{...n,expandedPaths:a}},20)}})},expandPath:(t,n)=>{let r=q((t||``).trim()),i=G((n||``).trim());!r||!i||!J(i,r)||e(e=>{let t=e.byRoot[r],n=X(t);return n.expandedPaths.includes(i)&&t?e:{byRoot:Y({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,i]}},20)}})},expandPaths:(t,n)=>{let r=q((t||``).trim());if(!r||!n||n.length===0)return;let i=n.map(e=>G((e||``).trim())).filter(e=>e&&J(e,r));i.length!==0&&e(e=>{let t=e.byRoot[r],n=X(t),a=new Set(n.expandedPaths),o=i.filter(e=>!a.has(e));return o.length===0?e:{byRoot:Y({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,...o]}},20)}})}}),{name:`files-view-tabs-store`,version:2,storage:p(),migrate:e=>{if(!e||typeof e!=`object`)return{byRoot:{}};let t=e.byRoot;return{byRoot:we(t)}},merge:(e,t)=>({...t,byRoot:we(e&&typeof e==`object`?e.byRoot:void 0)}),partialize:e=>({byRoot:we(e.byRoot)})}),{name:`files-view-tabs-store`})),Q=()=>{let e=(0,V.c)(17),t=P(Te),n=N(),r;e[0]===t?r=e[1]:(r=e=>t?e.getAttachment(t):void 0,e[0]=t,e[1]=r);let i=M(r),a=P(Ee),o=P(De),s=T(Oe),c=T(ke),u=l(Ae);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 u??void 0};function Te(e){return e.currentSessionId}function Ee(e){return e.worktreeMetadata}function De(e){return e.newSessionDraft}function Oe(e){return e.activeProjectId}function ke(e){return e.projects}function Ae(e){return e.currentDirectory}var $=s(),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,$.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=B.forwardRef((e,t)=>{let n=(0,V.c)(4),r=y(),i;return n[0]!==r||n[1]!==e||n[2]!==t?(i=r?.entry.location.hostId?(0,$.jsx)(Le,{...e,ref:t,entry:r.entry,registry:r.registry},JSON.stringify(r.entry.queryScope)):(0,$.jsx)(Pe,{...e,ref:t}),n[0]=r,n[1]=e,n[2]=t,n[3]=i):i=n[3],i}),Pe=B.forwardRef((e,t)=>{let n=(0,V.c)(22),r=Q()??``,i=P(ze),a=E(Be),o=!!e.onSessionSelect,s;n[0]===o?s=n[1]:(s={enabled:o},n[0]=o,n[1]=s);let c=k(s),l=T(Ve),u=T(He),f;if(n[2]!==l||n[3]!==r||n[4]!==u){let e=u.find(e=>e.id===l)?.path||r;f=e?e.replace(/\\/g,`/`).replace(/\/+$/,``):null,n[2]=l,n[3]=r,n[4]=u,n[5]=f}else f=n[5];let p=f,m;n[6]===p?m=n[7]:(m=e=>p?e.byRoot[p]:void 0,n[6]=p,n[7]=m);let h=Z(m),g=A(Ue),_=d(We),v;n[8]!==a||n[9]!==c||n[10]!==e.onSessionSelect?(v=e.onSessionSelect?D(a,c):[],n[8]=a,n[9]=c,n[10]=e.onSessionSelect,n[11]=v):v=n[11];let y=v,b=e.currentSessionId??i,x;return n[12]!==g||n[13]!==r||n[14]!==p||n[15]!==h||n[16]!==e||n[17]!==t||n[18]!==_||n[19]!==y||n[20]!==b?(x=(0,$.jsx)(Re,{...e,ref:t,currentDirectory:r,currentSessionId:b,projectRoot:p,projectTabs:h,agentCatalog:g,sessions:y,searchFiles:_}),n[12]=g,n[13]=r,n[14]=p,n[15]=h,n[16]=e,n[17]=t,n[18]=_,n[19]=y,n[20]=b,n[21]=x):x=n[21],x}),Fe=[],Ie=[],Le=B.forwardRef((e,t)=>{let n=(0,V.c)(32),{entry:r,registry:i}=e,a=v(),o;n[0]===r?o=n[1]:(o=O(r.location.directory,void 0,r),n[0]=r,n[1]=o);let s=!!e.onAgentSelect,c;n[2]!==o||n[3]!==s?(c={...o,enabled:s},n[2]=o,n[3]=s,n[4]=c):c=n[4];let l=_(c),u;n[5]!==r||n[6]!==i?(u=H(i,r),n[5]=r,n[6]=i,n[7]=u):u=n[7];let d=!!e.onSessionSelect,f;n[8]!==u||n[9]!==d?(f={...u,enabled:d},n[8]=u,n[9]=d,n[10]=f):f=n[10];let p=_(f),m;n[11]===r.key?m=n[12]:(m=e=>e.byRoot[r.key],n[11]=r.key,n[12]=m);let h=Z(m),g;n[13]!==a||n[14]!==r?(g=(e,t,n,i)=>{let o=n===void 0?60:n;return a.fetchQuery(W(r,t,o,i))},n[13]=a,n[14]=r,n[15]=g):g=n[15];let y=x(g),b=r.location.directory,S;if(n[16]!==r.location.directory){let e;n[18]===Symbol.for(`react.memo_cache_sentinel`)?(e=/\/+$/,n[18]=e):e=n[18],S=r.location.directory.replace(/\\/g,`/`).replace(e,``),n[16]=r.location.directory,n[17]=S}else S=n[17];let C=l.data??Ie,w=p.data??Fe,T=l.error??p.error,E;n[19]===r?E=n[20]:(E=()=>{r.sdk()},n[19]=r,n[20]=E);let D;return n[21]!==r.location.directory||n[22]!==h||n[23]!==e||n[24]!==t||n[25]!==y||n[26]!==C||n[27]!==w||n[28]!==T||n[29]!==E||n[30]!==S?(D=(0,$.jsx)(Re,{...e,ref:t,currentDirectory:b,projectRoot:S,projectTabs:h,agentCatalog:C,sessions:w,searchFiles:y,catalogError:T,assertCurrent:E}),n[21]=r.location.directory,n[22]=h,n[23]=e,n[24]=t,n[25]=y,n[26]=C,n[27]=w,n[28]=T,n[29]=E,n[30]=S,n[31]=D):D=n[31],D}),Re=B.forwardRef(({searchQuery:e,onFileSelect:t,onAgentSelect:n,onSkillSelect:r,onSessionSelect:i,onClose:a,style:o,onRowsChange:s,currentDirectory:c,currentSessionId:l,projectRoot:d,projectTabs:p,agentCatalog:m,sessions:h,searchFiles:g,catalogError:_,assertCurrent:v},y)=>{let{t:b}=re(),w=ae(e,180),T=f(),E=u(),[D,O]=B.useState([]),[k,A]=B.useState(!1),[j,M]=B.useState(null),[N,P]=B.useState(0),L=B.useRef(0),te=B.useRef({query:e,directory:c,ids:[]}),[ne,ce]=B.useState(360),[le,ge]=B.useState({}),[_e,ve]=B.useState({}),ye=B.useRef([]),V=B.useRef([]),Se=B.useRef([]),H=B.useRef(null),Ce=B.useRef(null),U=B.useRef(null);U.current||=fe();let W=S(e=>e.isMobile),G=(e??``).trim(),K=R({directory:c||null}),q=B.useMemo(()=>r?K.data??[]:[],[r,K.data]),J=B.useMemo(()=>{if(!d||!p)return[];let e=[p.selectedPath,...p.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 he(n,G,{limit:6})},[G,d,p]),we=B.useMemo(()=>n?I(m).filter(e=>e.mode!==`primary`):[],[m,n]),Y=B.useMemo(()=>i?pe({sessions:h,currentSessionId:l??null,searchQuery:G}):[],[h,l,G,i]),X=J,Z=D,Q=B.useMemo(()=>se({skills:q,agents:we,sessions:Y,recentFiles:X,pathHits:Z,searchQuery:G,untitledSession:b(`chat.fileMentionAutocomplete.untitledSession`),sessionBadge:b(`chat.fileMentionAutocomplete.sessionType`),skillBadge:b(`chat.commandAutocomplete.badge.skill`)}),[q,we,Y,X,Z,G,b]);B.useEffect(()=>{let e=e=>{let t=e.target;!t||!H.current||H.current.contains(t)||a()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[a]),B.useEffect(()=>{if(!c){O([]),A(!1),M(null);return}let e=(w??``).trim(),t=C(e);if(!t){O([]),A(!1),M(null);return}let n=!1;A(!0),M(null);let r={includeHidden:T,respectGitignore:!E};return Promise.all([g(c,t,80,{...r,type:`file`}),g(c,t,40,{...r,type:`directory`})]).then(([t,r])=>{if(n)return;let i=new Set(J.map(e=>e.path));O(me({files:t,directories:r,query:e,excludePaths:i,limit:20}))}).catch(e=>{n||M(e instanceof Error?e:Error(String(e)))}).finally(()=>{n||A(!1)}),()=>{n=!0}},[c,w,J,g,T,E]),B.useLayoutEffect(()=>{let t=te.current,n=t.ids[L.current],r=t.query===e&&t.directory===c?Math.max(0,Q.findIndex(e=>e.id===n)):0;te.current={query:e,directory:c,ids:Q.map(e=>e.id)},L.current=r,P(r)},[Q,e,c]),B.useEffect(()=>{ge({}),ve({})},[Q]),B.useEffect(()=>{ye.current[N]?.scrollIntoView({block:`nearest`})},[N]),B.useEffect(()=>{let e=null,t=()=>{e!==null&&cancelAnimationFrame(e),e=requestAnimationFrame(()=>{let e={},t={};V.current.forEach((n,r)=>{if(!n)return;let i=Se.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}}),ge(e),ve(t)})};return t(),window.addEventListener(`resize`,t),()=>{e!==null&&cancelAnimationFrame(e),window.removeEventListener(`resize`,t)}},[Q]),B.useEffect(()=>{let e=V.current[N];if(!e)return;let t=()=>{let t=e.clientWidth;t>0&&ce(t)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>{n.disconnect()}},[N]);let Te=x(e=>{t(e)}),Ee=x(e=>{n?.(e)}),De=x(e=>{i?.(e)}),Oe=x(e=>{r?.(e)}),ke=(e,t)=>({onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&U.current?.pointerDown(e.clientX,e.clientY)},onPointerMove:e=>{e.pointerType===`touch`&&U.current?.pointerMove(e.clientX,e.clientY)},onPointerUp:e=>{e.pointerType===`touch`&&(U.current?.pointerUp(t)??!1)&&(e.preventDefault(),e.stopPropagation())},onPointerCancel:()=>U.current?.pointerCancel(),onClick:()=>{U.current?.click(t)},onMouseMove:()=>{L.current=e,P(e)}}),Ae=e=>{try{v?.()}catch(e){M(e instanceof Error?e:Error(String(e)));return}let t=Q.length;if(t===0)return;let n=(e%t+t)%t,r=Q[n];if(r.agentName!==void 0){Ee(r.agentName);return}if(r.id.startsWith(`skill:`)){let e=q.find(e=>r.id===`skill:${e.name}-${e.scope}`);e&&Oe(e);return}if(r.id.startsWith(`session:`)){let e=Y.find(e=>r.id===`session:${e.id}`);e&&De(e);return}let i=r.id.startsWith(`recent:`)?X.find(e=>r.id===`recent:${e.path}`):Z.find(e=>r.id===`file:${e.path}`);i&&Te(i)};B.useEffect(()=>{be(s,Ce,{rows:Q,highlightedIndex:N})},[s,N,Q]);let je=B.useRef(s);return je.current=s,B.useEffect(()=>()=>{xe(je.current,Ce)},[]),B.useImperativeHandle(y,()=>({acceptIndex:e=>{Ae(e)},handleKeyDown:e=>{if(e===`Escape`){a();return}let t=Q.length;if(t!==0){if(e===`ArrowDown`){L.current=(L.current+1)%t,P(L.current);return}if(e===`ArrowUp`){L.current=(L.current-1+t)%t,P(L.current);return}(e===`Enter`||e===`Tab`)&&Ae(L.current)}}})),(0,$.jsxs)(ue,{ref:H,isMobile:W,className:`max-w-[640px] max-h-64`,style:o,children:[(0,$.jsx)(ie,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0`,children:(0,$.jsxs)(`div`,{className:`py-1`,children:[_||K.error||j?(0,$.jsx)(`div`,{role:`alert`,className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:(_??K.error??j)?.message}):null,Q.map((e,t)=>{let n=e.id.startsWith(`file:`)||e.id.startsWith(`recent:`),r=n?ee(e.title,{maxLength:60}):e.title,i=N===t,a=le[t]??!1,o=_e[t]??2.6;return(0,$.jsxs)(`div`,{"data-mention-id":e.id,ref:e=>{ye.current[t]=e},className:F(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,W&&`min-h-11`,de(W,i),!W&&i&&`text-interactive-selection-foreground`),...ke(t,()=>Ae(t)),children:[(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center`,children:e.agentName===void 0?(0,$.jsx)(z,{name:e.iconName,className:`size-3.5 text-current`}):(0,$.jsx)(oe,{name:e.agentName,size:20})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,$.jsxs)(`span`,{ref:e=>{V.current[t]=e},className:F(`relative block min-w-0 overflow-hidden`,n&&a&&i&&`file-mention-marquee-container`),style:i?{"--file-mention-marquee-width":`${ne}px`,"--file-mention-marquee-duration":`${o}s`}:void 0,title:e.title,children:[(0,$.jsx)(`span`,{ref:e=>{Se.current[t]=e},className:`absolute invisible whitespace-nowrap pointer-events-none`,"aria-hidden":!0,children:e.title}),n&&a&&i?(0,$.jsx)(`span`,{className:`inline-block whitespace-nowrap file-mention-marquee`,children:Me(e.title,G)}):(0,$.jsx)(`span`,{className:`block truncate`,children:Me(r,G)})]}),e.trailingLabel?(0,$.jsx)(`span`,{className:F(`max-w-[40%] shrink-0 truncate text-muted-foreground`,W?`typography-micro`:`typography-meta`),children:e.trailingLabel}):null]}),e.subtitle?(0,$.jsx)(`div`,{className:F(`truncate text-muted-foreground`,W?`typography-micro`:`typography-meta`),children:Me(e.subtitle,G)}):null]})]},e.id)}),k&&Z.length===0?(0,$.jsx)(`div`,{className:`flex items-center justify-center py-3`,children:(0,$.jsx)(z,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):null,!k&&Q.length===0&&(0,$.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:b(`chat.fileMentionAutocomplete.empty`)})]})}),!W&&(0,$.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:b(`chat.autocomplete.keyboardHint`)})]})});function ze(e){return e.currentSessionId}function Be(e){return e.activeSessions}function Ve(e){return e.activeProjectId}function He(e){return e.projects}function Ue(e){return e.agents}function We(e){return e.searchFiles}var Ge=new Set([`new`,`fork`,`compact`,`reload`,`undo`,`redo`,`model`,`btw`]),Ke=(e,t)=>{if(!t||e.isSkill)return!1;let n=e.name?.trim().toLowerCase();return!!(n&&Ge.has(n))},qe=(e,t)=>!e||t({name:e}),Je=` `,Ye=(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]===Je&&e[r-2]===`/`&&(r-=2),e[r]===`/`?{start:r,end:n}:null},Xe=`text-[10px] leading-none uppercase font-bold tracking-tight px-1.5 py-1 rounded border flex-shrink-0`,Ze=F(Xe,`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)]`),Qe=F(Xe,`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)]`),$e=F(Xe,`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)]`),et=F(Xe,`bg-[var(--surface-muted)] text-muted-foreground border-[var(--interactive-border)]/60`),tt=(e,t)=>e.length===t.length&&e.every((e,n)=>e.id===t[n]?.id&&e.description===t[n]?.description),nt=e=>{let t=!!e.sessionID;return{hasSession:t,canStartSessionCommand:t||e.hasNewDraft}},rt=B.forwardRef(({searchQuery:e,onCommandSelect:n,onClose:r,directory:i,style:a,commandPolicy:o,commandContext:s,onRowsChange:c},l)=>{let{t:u}=re(),d=S(e=>e.isMobile),f=P(e=>e.currentSessionId),p=P(e=>!!e.newSessionDraft?.open),m=P(B.useCallback(e=>f?e.getDirectoryForSession(f):void 0,[f])),h=L(f??``,m??void 0),g=B.useMemo(()=>s??{sessionID:f??null,hasMessages:h.length>0,hasNewDraft:p},[s,f,h.length,p]),{hasSession:_,canStartSessionCommand:v}=B.useMemo(()=>nt(g),[g]),y=g.hasMessages,[b,x]=B.useState([]),[C,w]=B.useState(!1),T=te({directory:i}),E=B.useMemo(()=>T.data??[],[T.data]),D=T.isFetching,[O,k]=B.useState(0),A=B.useRef(0),j=B.useRef(!1),M=B.useRef([]),N=B.useRef(null),ee=B.useRef(!1),I=B.useRef(null),R=B.useRef(!1),ne=B.useRef(null);B.useEffect(()=>{let e=e=>{let t=e.target;!t||!N.current||N.current.contains(t)||r()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[r]),B.useEffect(()=>{(async()=>{w(D);try{let n=E.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}]),r=[{id:`yuri:new`,name:`new`,source:`yuri`,description:u(`chat.commandAutocomplete.command.newDescription`),isBuiltIn:!0},..._&&!y?[{id:`yuri:init`,name:`init`,source:`yuri`,description:u(`chat.commandAutocomplete.command.initDescription`),isBuiltIn:!0}]:[],..._?[{id:`yuri:btw`,name:`btw`,source:`yuri`,description:u(`chat.btw.description`),isBuiltIn:!0},{id:`yuri:undo`,name:`undo`,source:`yuri`,description:u(`chat.commandAutocomplete.command.undoDescription`),isBuiltIn:!0},{id:`yuri:redo`,name:`redo`,source:`yuri`,description:u(`chat.commandAutocomplete.command.redoDescription`),isBuiltIn:!0},{id:`yuri:fork`,name:`fork`,source:`yuri`,description:u(`chat.commandAutocomplete.command.forkDescription`),isBuiltIn:!0},{id:`yuri:timeline`,name:`timeline`,source:`yuri`,description:u(`chat.commandAutocomplete.command.timelineDescription`),isBuiltIn:!0}]:[],{id:`yuri:model`,name:`model`,source:`yuri`,description:u(`chat.commandAutocomplete.command.modelDescription`),isBuiltIn:!0},{id:`yuri:compact`,name:`compact`,source:`yuri`,description:u(`chat.commandAutocomplete.command.compactDescription`),isBuiltIn:!0},...t()?[{id:`yuri:reload`,name:`reload`,source:`yuri`,description:u(`chat.commandAutocomplete.command.reloadDescription`),isBuiltIn:!0}]:[],..._?[{id:`yuri:summary`,name:`summary`,source:`yuri`,description:u(`chat.commandAutocomplete.command.summaryDescription`),isYuri:!0}]:[],...v?[{id:`yuri:workspace-review`,name:`workspace-review`,source:`yuri`,description:u(`chat.commandAutocomplete.command.workspaceReviewDescription`),isYuri:!0}]:[],...v?[{id:`yuri:craft-goal`,name:`craft-goal`,source:`yuri`,description:u(`chat.commandAutocomplete.command.craftGoalDescription`),isYuri:!0}]:[],...v?[{id:`yuri:catch-up`,name:`catch-up`,source:`yuri`,description:u(`chat.commandAutocomplete.command.catchUpDescription`),isYuri:!0}]:[],...v?[{id:`yuri:debug`,name:`debug`,source:`yuri`,description:u(`chat.commandAutocomplete.command.debugDescription`),isYuri:!0}]:[],...v?[{id:`yuri:weigh`,name:`weigh`,source:`yuri`,description:u(`chat.commandAutocomplete.command.weighDescription`),isYuri:!0}]:[],...v?[{id:`yuri:explore`,name:`explore`,source:`yuri`,description:u(`chat.commandAutocomplete.command.exploreDescription`),isYuri:!0}]:[],...n],i=!y,a=ge(r.filter(e=>(i||e.name!==`init`)&&(o?.(e)??!0)),e);x(e=>tt(e,a)?e:a)}catch{let n=!y,r=ge([{id:`yuri:new`,name:`new`,source:`yuri`,description:u(`chat.commandAutocomplete.command.newDescription`),isBuiltIn:!0},..._&&!y?[{id:`yuri:init`,name:`init`,source:`yuri`,description:u(`chat.commandAutocomplete.command.initDescription`),isBuiltIn:!0}]:[],..._?[{id:`yuri:btw`,name:`btw`,source:`yuri`,description:u(`chat.btw.description`),isBuiltIn:!0},{id:`yuri:undo`,name:`undo`,source:`yuri`,description:u(`chat.commandAutocomplete.command.undoDescription`),isBuiltIn:!0},{id:`yuri:redo`,name:`redo`,source:`yuri`,description:u(`chat.commandAutocomplete.command.redoDescription`),isBuiltIn:!0},{id:`yuri:fork`,name:`fork`,source:`yuri`,description:u(`chat.commandAutocomplete.command.forkDescription`),isBuiltIn:!0},{id:`yuri:timeline`,name:`timeline`,source:`yuri`,description:u(`chat.commandAutocomplete.command.timelineDescription`),isBuiltIn:!0}]:[],{id:`yuri:model`,name:`model`,source:`yuri`,description:u(`chat.commandAutocomplete.command.modelDescription`),isBuiltIn:!0},{id:`yuri:compact`,name:`compact`,source:`yuri`,description:u(`chat.commandAutocomplete.command.compactDescription`),isBuiltIn:!0},...t()?[{id:`yuri:reload`,name:`reload`,source:`yuri`,description:u(`chat.commandAutocomplete.command.reloadDescription`),isBuiltIn:!0}]:[],..._?[{id:`yuri:summary`,name:`summary`,source:`yuri`,description:u(`chat.commandAutocomplete.command.summaryDescription`),isYuri:!0}]:[],...v?[{id:`yuri:workspace-review`,name:`workspace-review`,source:`yuri`,description:u(`chat.commandAutocomplete.command.workspaceReviewDescription`),isYuri:!0}]:[],...v?[{id:`yuri:craft-goal`,name:`craft-goal`,source:`yuri`,description:u(`chat.commandAutocomplete.command.craftGoalDescription`),isYuri:!0}]:[],...v?[{id:`yuri:catch-up`,name:`catch-up`,source:`yuri`,description:u(`chat.commandAutocomplete.command.catchUpDescription`),isYuri:!0}]:[],...v?[{id:`yuri:debug`,name:`debug`,source:`yuri`,description:u(`chat.commandAutocomplete.command.debugDescription`),isYuri:!0}]:[],...v?[{id:`yuri:weigh`,name:`weigh`,source:`yuri`,description:u(`chat.commandAutocomplete.command.weighDescription`),isYuri:!0}]:[],...v?[{id:`yuri:explore`,name:`explore`,source:`yuri`,description:u(`chat.commandAutocomplete.command.exploreDescription`),isYuri:!0}]:[]].filter(e=>(n||e.name!==`init`)&&(o?.(e)??!0)),e);x(e=>tt(e,r)?e:r)}finally{w(!1)}})()},[e,y,_,v,E,D,u,o]),B.useEffect(()=>{k(0)},[b]),B.useEffect(()=>{A.current=O},[O]),B.useEffect(()=>{M.current[O]?.scrollIntoView({block:`nearest`})},[O]),B.useEffect(()=>{be(c,ne,{rows:le(b,{skill:u(`chat.commandAutocomplete.badge.skill`),command:u(`chat.commandAutocomplete.badge.command`),system:u(`chat.commandAutocomplete.badge.system`)}),highlightedIndex:O})},[b,c,O,u]);let ae=B.useRef(c);ae.current=c,B.useEffect(()=>()=>{xe(ae.current,ne)},[]),B.useImperativeHandle(l,()=>({acceptIndex:(e,t=!0)=>{let r=b[e];r&&n(r,Ke(r,t))},handleKeyDown:e=>{let t=b.length;if(e===`Escape`){r();return}if(t!==0){if(e===`ArrowDown`){j.current=!0,k(e=>(e+1)%t);return}if(e===`ArrowUp`){j.current=!0,k(e=>(e-1+t)%t);return}if(e===`Enter`||e===`Tab`){let r=(A.current%t+t)%t,i=b[r];i&&n(i,Ke(i,e===`Enter`))}}}}),[b,r,n]);let oe=e=>{let t=ce(e);switch(e.name){case`new`:return(0,$.jsx)(z,{name:t,className:`h-3.5 w-3.5`});case`init`:return(0,$.jsx)(z,{name:t,className:`h-3.5 w-3.5 text-green-500`});case`undo`:return(0,$.jsx)(z,{name:t,className:`h-3.5 w-3.5 text-orange-500`});case`redo`:return(0,$.jsx)(z,{name:t,className:`h-3.5 w-3.5 text-orange-500`});case`timeline`:case`reload`:return(0,$.jsx)(z,{name:t,className:`h-3.5 w-3.5`});case`compact`:return(0,$.jsx)(z,{name:t,className:`h-3.5 w-3.5 text-purple-500`});case`goal`:return(0,$.jsx)(z,{name:t,className:`h-3.5 w-3.5`});case`review`:return(0,$.jsx)(z,{name:t,className:`h-3.5 w-3.5 text-blue-500`});case`test`:case`build`:case`run`:return(0,$.jsx)(z,{name:t,className:`h-3.5 w-3.5 text-cyan-500`});default:return e.isBuiltIn?(0,$.jsx)(z,{name:t,className:`h-3.5 w-3.5 text-yellow-500`}):(0,$.jsx)(z,{name:t,className:`h-3.5 w-3.5 text-muted-foreground`})}};return(0,$.jsxs)(ue,{ref:N,isMobile:d,className:`max-w-[450px] max-h-64`,style:a,children:[(0,$.jsx)(ie,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0 py-1.5`,children:C?(0,$.jsx)(`div`,{className:`flex items-center justify-center py-4`,children:(0,$.jsx)(z,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):(0,$.jsxs)(`div`,{children:[b.map((t,r)=>{let i=t.isBuiltIn,a=t.isYuri;return(0,$.jsxs)(`div`,{ref:e=>{M.current[r]=e},className:F(`flex gap-2 px-2 py-2 cursor-pointer rounded-lg`,d?`items-center`:`items-start`,de(d,r===O),!d&&r===O&&`bg-interactive-selection/35`),onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&(I.current={x:e.clientX,y:e.clientY},R.current=!1)},onPointerMove:e=>{if(e.pointerType!==`touch`||!I.current)return;let t=e.clientX-I.current.x,n=e.clientY-I.current.y;Math.hypot(t,n)>6&&(R.current=!0)},onPointerUp:e=>{if(e.pointerType!==`touch`)return;let r=R.current;I.current=null,R.current=!1,!r&&(e.preventDefault(),e.stopPropagation(),ee.current=!0,n(t,Ke(t,d)))},onPointerCancel:()=>{I.current=null,R.current=!1},onClick:()=>{if(ee.current){ee.current=!1;return}n(t,Ke(t,d))},onMouseMove:()=>{j.current=!1,k(r)},children:[(0,$.jsx)(`div`,{className:F(!d&&`mt-0.5`),children:oe(t)}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(`span`,{className:`typography-ui-label font-medium`,children:[`/`,Me(t.name,e)]}),t.isSkill?(0,$.jsx)(`span`,{className:Ze,children:u(`chat.commandAutocomplete.badge.skill`)}):(0,$.jsx)(`span`,{className:Ze,children:u(`chat.commandAutocomplete.badge.command`)}),a?(0,$.jsx)(`span`,{className:et,children:`Yuri`}):i?(0,$.jsx)(`span`,{className:et,children:u(`chat.commandAutocomplete.badge.system`)}):t.scope?(0,$.jsx)(`span`,{className:t.scope===`project`?$e:Qe,children:t.scope}):null,t.agent&&(0,$.jsx)(`span`,{className:et,children:t.agent})]}),t.description&&!d&&(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground mt-0.5 truncate`,children:Me(t.description,e)})]})]},t.id)}),b.length===0&&(0,$.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:u(`chat.commandAutocomplete.empty`)})]})}),!d&&(0,$.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:u(`chat.autocomplete.keyboardHint`)})]})});rt.displayName=`CommandAutocomplete`;var it=(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?` `:``}`},at=(e,t,n)=>{let r=it(e,t,n);return`${t.length===0&&!/^\s/.test(r)?` `:``}${r}${n.length===0&&!/\s$/.test(r)?` `:``}`},ot=(e,t,n,r)=>{let i=e.slice(0,t),a=e.slice(n),o=at(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}},st=(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]},ct=(e,t)=>t<e.length&&e[t]===` `?t+1:t;export{rt as a,Ne as c,Ce as d,U as f,at as i,Q as l,st as n,Ye as o,ye as p,ot as r,qe as s,ct as t,Z as u};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{R as t,l as n,u as r}from"./platform-CiUKDeXd.js";import{a as i,i as a,r as o}from"./vendor-zustand-CTekDqaS.js";import{ot as s,st as c}from"./vendor-base-ui-wXsskyKm.js";import{St as l,an as u,jt as d,on as f}from"./gitApiHttp-DF1ID314.js";import{t as p}from"./safeStorage-DTOhKN0V.js";import{i as m,t as h}from"./vendor-pathe-vBmvQE8f.js";import{n as g}from"./vendor-react-BkccXcWz.js";import{s as _,u as v}from"./vendor-tanstack-react-query-DIb_ItL-.js";import{E as y}from"./runtime-file-resource-C5kmYlLv.js";import{o as b}from"./path-utils-jGozTg9d.js";import{r as x}from"./vendor-reactuses-core-DjKFMfz7.js";import{r as S}from"./useUIStore-Dzf_W6hZ.js";import{o as C,s as w}from"./spacedFileMention-Ds4GtgiF.js";import{Ba as T,Fi as E,Oi as D,Pa as O,R as k,Yi as A,_ as j,b as M,bt as N,f as P,lo as ee,no as F,ua as I,ut as L,xa as R,za as te}from"./ui-Cd2-HQSa.js";import{n as z}from"./Icon-CeG6IExS.js";import{s as ne}from"./remoteProjectQueries-BXrXdLjN.js";import{t as re}from"./i18n-BcqhT5IQ.js";import{t as ie}from"./ScrollableOverlay-BGOUZmbS.js";import{t as ae}from"./useDebouncedValue-BHlMPqY8.js";import{t as oe}from"./AgentAvatar-BaKbuiEG.js";import{c as se,d as ce,l as le,n as ue,r as de,t as fe}from"./fileMentionTouchSelection-Dv6PCS5x.js";import{a as pe,o as me,s as he}from"./fileMentionAutocompleteState-B9411b4o.js";var ge=(e,t)=>{let n=t.trim();if(!n)return[...e].sort((e,t)=>e.isBuiltIn===t.isBuiltIn?e.name.localeCompare(t.name):e.isBuiltIn?-1:1);let r=w([...e],n,e=>[e.name,e.description??``]);return r.sort((e,t)=>e.score===t.score?e.item.isBuiltIn===t.item.isBuiltIn?e.item.name.localeCompare(t.item.name):e.item.isBuiltIn?-1:1:e.score-t.score),r.map(e=>e.item)},_e=(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}),ve=(e,t)=>e.highlightedIndex===t.highlightedIndex&&_e(e.rows,t.rows),ye=(e,t)=>_e(e,t)?e:t.slice(),be=(e,t,n)=>{e&&(t.current&&ve(t.current,n)||(t.current=n,e(n)))},xe=(e,t)=>{t.current=null,e?.({rows:[],highlightedIndex:0})},B=e(c(),1),V=g(),Se=e=>e.directories.flatMap(e=>e.sessions),H=(e,t)=>({...ne(e,t.location.hostId),select:Se}),Ce=async(e,t,n)=>{n.sdk();let r=await e.fetchQuery(H(t,n));return n.sdk(),Se(r)},U=(e,t,n,r)=>{n.sdk();let i=e.getQueryData(H(t,n).queryKey);for(let e of i?.directories??[]){let t=e.sessions.find(e=>e.id===r);if(t)return t.title||r}return r},W=(e,t,n,r={})=>({queryKey:[...e.queryScope,`composer-files`,t,n,r],staleTime:3e4,gcTime:3e4,queryFn:async({signal:i})=>{let a=await e.sdk().file.find({query:t,location:{directory:e.location.directory},limit:n,type:r.type},{signal:i});if(e.sdk(),i.throwIfAborted(),!Array.isArray(a.data))throw Error(`File search returned no data`);return a.data.map(t=>{let n=m(t.path),r=h(n);return{name:r,path:b(e.location.directory,n),relativePath:n,extension:r.includes(`.`)?r.split(`.`).pop()?.toLowerCase():void 0,isDirectory:t.type===`directory`}})}}),G=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},K=e=>/^[A-Za-z]:\//.test(e)?e.toLowerCase():e,q=e=>e.startsWith(`yuri-remote-location:`)?n(e):G(e),J=(e,t)=>{let n=G(r(t,`local`).directory),i=G(e);if(!n||!i)return!1;let a=K(n),o=K(i);return o===a||o.startsWith(a.endsWith(`/`)?a:`${a}/`)},we=e=>{if(!e||typeof e!=`object`)return{};let t=e,n={};for(let[e,r]of Object.entries(t)){let t;try{t=q(e)}catch{continue}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=>G(e)).filter(e=>J(e,t)))):[],o=Array.isArray(i.expandedPaths)?Array.from(new Set(i.expandedPaths.filter(e=>typeof e==`string`).map(e=>G(e)).filter(e=>J(e,t)))):[],s=typeof i.selectedPath==`string`?G(i.selectedPath):null,c=s&&J(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])),i=u.selectedPath??c??e[0]??null;n[t]={openPaths:e,selectedPath:i,expandedPaths:r,touchedAt:Math.max(u.touchedAt,l)};continue}n[t]={openPaths:a,selectedPath:c,expandedPaths:o,touchedAt:l}}return n},Y=(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},X=e=>e?{...e,touchedAt:Date.now()}:{openPaths:[],selectedPath:null,expandedPaths:[],touchedAt:Date.now()},Z=i()(o(a((e,t)=>({byRoot:{},addOpenPath:(t,n,r)=>{let i=q((t||``).trim()),a=G((n||``).trim());!i||!a||!r?.allowOutsideRoot&&!J(a,i)||e(e=>{let t=e.byRoot[i],n=X(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:Y({...e.byRoot,[i]:{...n,openPaths:o,selectedPath:s}},20)}})},removeOpenPath:(t,n)=>{let r=q((t||``).trim()),i=G((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=K(i),a=e=>K(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:Y({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeOpenPathsByPrefix:(t,n)=>{let r=q((t||``).trim()),i=G((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=K(i),a=n.endsWith(`/`)?n:`${n}/`,o=e=>{let t=K(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:Y({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeExpandedPathsByPrefix:(t,n)=>{let r=q((t||``).trim()),i=G((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=K(i),a=n.endsWith(`/`)?n:`${n}/`,o=t.expandedPaths.filter(e=>{let t=K(e);return t!==n&&!t.startsWith(a)});return o.length===t.expandedPaths.length?e:{byRoot:Y({...e.byRoot,[r]:{...t,expandedPaths:o,touchedAt:Date.now()}},20)}})},setSelectedPath:(t,n,r)=>{let i=q((t||``).trim()),a=n?G(n.trim()):null;!i||a&&!r?.allowOutsideRoot&&!J(a,i)||e(e=>{let t=e.byRoot[i],n=X(t),r=a&&!n.openPaths.includes(a)?[...n.openPaths,a]:n.openPaths;return t&&t.selectedPath===a&&r===t.openPaths?e:{byRoot:Y({...e.byRoot,[i]:{...n,openPaths:r,selectedPath:a}},20)}})},ensureSelectedPath:e=>{let n=q((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=q((t||``).trim()),i=G((n||``).trim());!r||!i||!J(i,r)||e(e=>{let t=e.byRoot[r],n=X(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:Y({...e.byRoot,[r]:{...n,expandedPaths:a}},20)}})},expandPath:(t,n)=>{let r=q((t||``).trim()),i=G((n||``).trim());!r||!i||!J(i,r)||e(e=>{let t=e.byRoot[r],n=X(t);return n.expandedPaths.includes(i)&&t?e:{byRoot:Y({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,i]}},20)}})},expandPaths:(t,n)=>{let r=q((t||``).trim());if(!r||!n||n.length===0)return;let i=n.map(e=>G((e||``).trim())).filter(e=>e&&J(e,r));i.length!==0&&e(e=>{let t=e.byRoot[r],n=X(t),a=new Set(n.expandedPaths),o=i.filter(e=>!a.has(e));return o.length===0?e:{byRoot:Y({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,...o]}},20)}})}}),{name:`files-view-tabs-store`,version:2,storage:p(),migrate:e=>{if(!e||typeof e!=`object`)return{byRoot:{}};let t=e.byRoot;return{byRoot:we(t)}},merge:(e,t)=>({...t,byRoot:we(e&&typeof e==`object`?e.byRoot:void 0)}),partialize:e=>({byRoot:we(e.byRoot)})}),{name:`files-view-tabs-store`})),Q=()=>{let e=(0,V.c)(17),t=P(Te),n=N(),r;e[0]===t?r=e[1]:(r=e=>t?e.getAttachment(t):void 0,e[0]=t,e[1]=r);let i=M(r),a=P(Ee),o=P(De),s=T(Oe),c=T(ke),u=l(Ae);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 u??void 0};function Te(e){return e.currentSessionId}function Ee(e){return e.worktreeMetadata}function De(e){return e.newSessionDraft}function Oe(e){return e.activeProjectId}function ke(e){return e.projects}function Ae(e){return e.currentDirectory}var $=s(),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,$.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=B.forwardRef((e,t)=>{let n=(0,V.c)(4),r=y(),i;return n[0]!==r||n[1]!==e||n[2]!==t?(i=r?.entry.location.hostId?(0,$.jsx)(Le,{...e,ref:t,entry:r.entry,registry:r.registry},JSON.stringify(r.entry.queryScope)):(0,$.jsx)(Pe,{...e,ref:t}),n[0]=r,n[1]=e,n[2]=t,n[3]=i):i=n[3],i}),Pe=B.forwardRef((e,t)=>{let n=(0,V.c)(22),r=Q()??``,i=P(ze),a=E(Be),o=!!e.onSessionSelect,s;n[0]===o?s=n[1]:(s={enabled:o},n[0]=o,n[1]=s);let c=k(s),l=T(Ve),u=T(He),f;if(n[2]!==l||n[3]!==r||n[4]!==u){let e=u.find(e=>e.id===l)?.path||r;f=e?e.replace(/\\/g,`/`).replace(/\/+$/,``):null,n[2]=l,n[3]=r,n[4]=u,n[5]=f}else f=n[5];let p=f,m;n[6]===p?m=n[7]:(m=e=>p?e.byRoot[p]:void 0,n[6]=p,n[7]=m);let h=Z(m),g=A(Ue),_=d(We),v;n[8]!==a||n[9]!==c||n[10]!==e.onSessionSelect?(v=e.onSessionSelect?D(a,c):[],n[8]=a,n[9]=c,n[10]=e.onSessionSelect,n[11]=v):v=n[11];let y=v,b=e.currentSessionId??i,x;return n[12]!==g||n[13]!==r||n[14]!==p||n[15]!==h||n[16]!==e||n[17]!==t||n[18]!==_||n[19]!==y||n[20]!==b?(x=(0,$.jsx)(Re,{...e,ref:t,currentDirectory:r,currentSessionId:b,projectRoot:p,projectTabs:h,agentCatalog:g,sessions:y,searchFiles:_}),n[12]=g,n[13]=r,n[14]=p,n[15]=h,n[16]=e,n[17]=t,n[18]=_,n[19]=y,n[20]=b,n[21]=x):x=n[21],x}),Fe=[],Ie=[],Le=B.forwardRef((e,t)=>{let n=(0,V.c)(32),{entry:r,registry:i}=e,a=v(),o;n[0]===r?o=n[1]:(o=O(r.location.directory,void 0,r),n[0]=r,n[1]=o);let s=!!e.onAgentSelect,c;n[2]!==o||n[3]!==s?(c={...o,enabled:s},n[2]=o,n[3]=s,n[4]=c):c=n[4];let l=_(c),u;n[5]!==r||n[6]!==i?(u=H(i,r),n[5]=r,n[6]=i,n[7]=u):u=n[7];let d=!!e.onSessionSelect,f;n[8]!==u||n[9]!==d?(f={...u,enabled:d},n[8]=u,n[9]=d,n[10]=f):f=n[10];let p=_(f),m;n[11]===r.key?m=n[12]:(m=e=>e.byRoot[r.key],n[11]=r.key,n[12]=m);let h=Z(m),g;n[13]!==a||n[14]!==r?(g=(e,t,n,i)=>{let o=n===void 0?60:n;return a.fetchQuery(W(r,t,o,i))},n[13]=a,n[14]=r,n[15]=g):g=n[15];let y=x(g),b=r.location.directory,S;if(n[16]!==r.location.directory){let e;n[18]===Symbol.for(`react.memo_cache_sentinel`)?(e=/\/+$/,n[18]=e):e=n[18],S=r.location.directory.replace(/\\/g,`/`).replace(e,``),n[16]=r.location.directory,n[17]=S}else S=n[17];let C=l.data??Ie,w=p.data??Fe,T=l.error??p.error,E;n[19]===r?E=n[20]:(E=()=>{r.sdk()},n[19]=r,n[20]=E);let D;return n[21]!==r.location.directory||n[22]!==h||n[23]!==e||n[24]!==t||n[25]!==y||n[26]!==C||n[27]!==w||n[28]!==T||n[29]!==E||n[30]!==S?(D=(0,$.jsx)(Re,{...e,ref:t,currentDirectory:b,projectRoot:S,projectTabs:h,agentCatalog:C,sessions:w,searchFiles:y,catalogError:T,assertCurrent:E}),n[21]=r.location.directory,n[22]=h,n[23]=e,n[24]=t,n[25]=y,n[26]=C,n[27]=w,n[28]=T,n[29]=E,n[30]=S,n[31]=D):D=n[31],D}),Re=B.forwardRef(({searchQuery:e,onFileSelect:t,onAgentSelect:n,onSkillSelect:r,onSessionSelect:i,onClose:a,style:o,onRowsChange:s,currentDirectory:c,currentSessionId:l,projectRoot:d,projectTabs:p,agentCatalog:m,sessions:h,searchFiles:g,catalogError:_,assertCurrent:v},y)=>{let{t:b}=re(),w=ae(e,180),T=f(),E=u(),[D,O]=B.useState([]),[k,A]=B.useState(!1),[j,M]=B.useState(null),[N,P]=B.useState(0),L=B.useRef(0),te=B.useRef({query:e,directory:c,ids:[]}),[ne,ce]=B.useState(360),[le,ge]=B.useState({}),[_e,ve]=B.useState({}),ye=B.useRef([]),V=B.useRef([]),Se=B.useRef([]),H=B.useRef(null),Ce=B.useRef(null),U=B.useRef(null);U.current||=fe();let W=S(e=>e.isMobile),G=(e??``).trim(),K=R({directory:c||null}),q=B.useMemo(()=>r?K.data??[]:[],[r,K.data]),J=B.useMemo(()=>{if(!d||!p)return[];let e=[p.selectedPath,...p.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 he(n,G,{limit:6})},[G,d,p]),we=B.useMemo(()=>n?I(m).filter(e=>e.mode!==`primary`):[],[m,n]),Y=B.useMemo(()=>i?pe({sessions:h,currentSessionId:l??null,searchQuery:G}):[],[h,l,G,i]),X=J,Z=D,Q=B.useMemo(()=>se({skills:q,agents:we,sessions:Y,recentFiles:X,pathHits:Z,searchQuery:G,untitledSession:b(`chat.fileMentionAutocomplete.untitledSession`),sessionBadge:b(`chat.fileMentionAutocomplete.sessionType`),skillBadge:b(`chat.commandAutocomplete.badge.skill`)}),[q,we,Y,X,Z,G,b]);B.useEffect(()=>{let e=e=>{let t=e.target;!t||!H.current||H.current.contains(t)||a()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[a]),B.useEffect(()=>{if(!c){O([]),A(!1),M(null);return}let e=(w??``).trim(),t=C(e);if(!t){O([]),A(!1),M(null);return}let n=!1;A(!0),M(null);let r={includeHidden:T,respectGitignore:!E};return Promise.all([g(c,t,80,{...r,type:`file`}),g(c,t,40,{...r,type:`directory`})]).then(([t,r])=>{if(n)return;let i=new Set(J.map(e=>e.path));O(me({files:t,directories:r,query:e,excludePaths:i,limit:20}))}).catch(e=>{n||M(e instanceof Error?e:Error(String(e)))}).finally(()=>{n||A(!1)}),()=>{n=!0}},[c,w,J,g,T,E]),B.useLayoutEffect(()=>{let t=te.current,n=t.ids[L.current],r=t.query===e&&t.directory===c?Math.max(0,Q.findIndex(e=>e.id===n)):0;te.current={query:e,directory:c,ids:Q.map(e=>e.id)},L.current=r,P(r)},[Q,e,c]),B.useEffect(()=>{ge({}),ve({})},[Q]),B.useEffect(()=>{ye.current[N]?.scrollIntoView({block:`nearest`})},[N]),B.useEffect(()=>{let e=null,t=()=>{e!==null&&cancelAnimationFrame(e),e=requestAnimationFrame(()=>{let e={},t={};V.current.forEach((n,r)=>{if(!n)return;let i=Se.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}}),ge(e),ve(t)})};return t(),window.addEventListener(`resize`,t),()=>{e!==null&&cancelAnimationFrame(e),window.removeEventListener(`resize`,t)}},[Q]),B.useEffect(()=>{let e=V.current[N];if(!e)return;let t=()=>{let t=e.clientWidth;t>0&&ce(t)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>{n.disconnect()}},[N]);let Te=x(e=>{t(e)}),Ee=x(e=>{n?.(e)}),De=x(e=>{i?.(e)}),Oe=x(e=>{r?.(e)}),ke=(e,t)=>({onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&U.current?.pointerDown(e.clientX,e.clientY)},onPointerMove:e=>{e.pointerType===`touch`&&U.current?.pointerMove(e.clientX,e.clientY)},onPointerUp:e=>{e.pointerType===`touch`&&(U.current?.pointerUp(t)??!1)&&(e.preventDefault(),e.stopPropagation())},onPointerCancel:()=>U.current?.pointerCancel(),onClick:()=>{U.current?.click(t)},onMouseMove:()=>{L.current=e,P(e)}}),Ae=e=>{try{v?.()}catch(e){M(e instanceof Error?e:Error(String(e)));return}let t=Q.length;if(t===0)return;let n=(e%t+t)%t,r=Q[n];if(r.agentName!==void 0){Ee(r.agentName);return}if(r.id.startsWith(`skill:`)){let e=q.find(e=>r.id===`skill:${e.name}-${e.scope}`);e&&Oe(e);return}if(r.id.startsWith(`session:`)){let e=Y.find(e=>r.id===`session:${e.id}`);e&&De(e);return}let i=r.id.startsWith(`recent:`)?X.find(e=>r.id===`recent:${e.path}`):Z.find(e=>r.id===`file:${e.path}`);i&&Te(i)};B.useEffect(()=>{be(s,Ce,{rows:Q,highlightedIndex:N})},[s,N,Q]);let je=B.useRef(s);return je.current=s,B.useEffect(()=>()=>{xe(je.current,Ce)},[]),B.useImperativeHandle(y,()=>({acceptIndex:e=>{Ae(e)},handleKeyDown:e=>{if(e===`Escape`){a();return}let t=Q.length;if(t!==0){if(e===`ArrowDown`){L.current=(L.current+1)%t,P(L.current);return}if(e===`ArrowUp`){L.current=(L.current-1+t)%t,P(L.current);return}(e===`Enter`||e===`Tab`)&&Ae(L.current)}}})),(0,$.jsxs)(ue,{ref:H,isMobile:W,className:`max-w-[640px] max-h-64`,style:o,children:[(0,$.jsx)(ie,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0`,children:(0,$.jsxs)(`div`,{className:`py-1`,children:[_||K.error||j?(0,$.jsx)(`div`,{role:`alert`,className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:(_??K.error??j)?.message}):null,Q.map((e,t)=>{let n=e.id.startsWith(`file:`)||e.id.startsWith(`recent:`),r=n?ee(e.title,{maxLength:60}):e.title,i=N===t,a=le[t]??!1,o=_e[t]??2.6;return(0,$.jsxs)(`div`,{"data-mention-id":e.id,ref:e=>{ye.current[t]=e},className:F(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,W&&`min-h-11`,de(W,i),!W&&i&&`text-interactive-selection-foreground`),...ke(t,()=>Ae(t)),children:[(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center`,children:e.agentName===void 0?(0,$.jsx)(z,{name:e.iconName,className:`size-3.5 text-current`}):(0,$.jsx)(oe,{name:e.agentName,size:20})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,$.jsxs)(`span`,{ref:e=>{V.current[t]=e},className:F(`relative block min-w-0 overflow-hidden`,n&&a&&i&&`file-mention-marquee-container`),style:i?{"--file-mention-marquee-width":`${ne}px`,"--file-mention-marquee-duration":`${o}s`}:void 0,title:e.title,children:[(0,$.jsx)(`span`,{ref:e=>{Se.current[t]=e},className:`absolute invisible whitespace-nowrap pointer-events-none`,"aria-hidden":!0,children:e.title}),n&&a&&i?(0,$.jsx)(`span`,{className:`inline-block whitespace-nowrap file-mention-marquee`,children:Me(e.title,G)}):(0,$.jsx)(`span`,{className:`block truncate`,children:Me(r,G)})]}),e.trailingLabel?(0,$.jsx)(`span`,{className:F(`max-w-[40%] shrink-0 truncate text-muted-foreground`,W?`typography-micro`:`typography-meta`),children:e.trailingLabel}):null]}),e.subtitle?(0,$.jsx)(`div`,{className:F(`truncate text-muted-foreground`,W?`typography-micro`:`typography-meta`),children:Me(e.subtitle,G)}):null]})]},e.id)}),k&&Z.length===0?(0,$.jsx)(`div`,{className:`flex items-center justify-center py-3`,children:(0,$.jsx)(z,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):null,!k&&Q.length===0&&(0,$.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:b(`chat.fileMentionAutocomplete.empty`)})]})}),!W&&(0,$.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:b(`chat.autocomplete.keyboardHint`)})]})});function ze(e){return e.currentSessionId}function Be(e){return e.activeSessions}function Ve(e){return e.activeProjectId}function He(e){return e.projects}function Ue(e){return e.agents}function We(e){return e.searchFiles}var Ge=new Set([`new`,`fork`,`compact`,`reload`,`undo`,`redo`,`model`,`btw`]),Ke=(e,t)=>{if(!t||e.isSkill)return!1;let n=e.name?.trim().toLowerCase();return!!(n&&Ge.has(n))},qe=(e,t)=>!e||t({name:e}),Je=` `,Ye=(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]===Je&&e[r-2]===`/`&&(r-=2),e[r]===`/`?{start:r,end:n}:null},Xe=`text-[10px] leading-none uppercase font-bold tracking-tight px-1.5 py-1 rounded border flex-shrink-0`,Ze=F(Xe,`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)]`),Qe=F(Xe,`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)]`),$e=F(Xe,`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)]`),et=F(Xe,`bg-[var(--surface-muted)] text-muted-foreground border-[var(--interactive-border)]/60`),tt=(e,t)=>e.length===t.length&&e.every((e,n)=>e.id===t[n]?.id&&e.description===t[n]?.description),nt=e=>{let t=!!e.sessionID;return{hasSession:t,canStartSessionCommand:t||e.hasNewDraft}},rt=B.forwardRef(({searchQuery:e,onCommandSelect:n,onClose:r,directory:i,style:a,commandPolicy:o,commandContext:s,onRowsChange:c},l)=>{let{t:u}=re(),d=S(e=>e.isMobile),f=P(e=>e.currentSessionId),p=P(e=>!!e.newSessionDraft?.open),m=P(B.useCallback(e=>f?e.getDirectoryForSession(f):void 0,[f])),h=L(f??``,m??void 0),g=B.useMemo(()=>s??{sessionID:f??null,hasMessages:h.length>0,hasNewDraft:p},[s,f,h.length,p]),{hasSession:_,canStartSessionCommand:v}=B.useMemo(()=>nt(g),[g]),y=g.hasMessages,[b,x]=B.useState([]),[C,w]=B.useState(!1),T=te({directory:i}),E=B.useMemo(()=>T.data??[],[T.data]),D=T.isFetching,[O,k]=B.useState(0),A=B.useRef(0),j=B.useRef(!1),M=B.useRef([]),N=B.useRef(null),ee=B.useRef(!1),I=B.useRef(null),R=B.useRef(!1),ne=B.useRef(null);B.useEffect(()=>{let e=e=>{let t=e.target;!t||!N.current||N.current.contains(t)||r()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[r]),B.useEffect(()=>{(async()=>{w(D);try{let n=E.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}]),r=[{id:`yuri:new`,name:`new`,source:`yuri`,description:u(`chat.commandAutocomplete.command.newDescription`),isBuiltIn:!0},..._&&!y?[{id:`yuri:init`,name:`init`,source:`yuri`,description:u(`chat.commandAutocomplete.command.initDescription`),isBuiltIn:!0}]:[],..._?[{id:`yuri:btw`,name:`btw`,source:`yuri`,description:u(`chat.btw.description`),isBuiltIn:!0},{id:`yuri:undo`,name:`undo`,source:`yuri`,description:u(`chat.commandAutocomplete.command.undoDescription`),isBuiltIn:!0},{id:`yuri:redo`,name:`redo`,source:`yuri`,description:u(`chat.commandAutocomplete.command.redoDescription`),isBuiltIn:!0},{id:`yuri:fork`,name:`fork`,source:`yuri`,description:u(`chat.commandAutocomplete.command.forkDescription`),isBuiltIn:!0},{id:`yuri:timeline`,name:`timeline`,source:`yuri`,description:u(`chat.commandAutocomplete.command.timelineDescription`),isBuiltIn:!0}]:[],{id:`yuri:model`,name:`model`,source:`yuri`,description:u(`chat.commandAutocomplete.command.modelDescription`),isBuiltIn:!0},{id:`yuri:compact`,name:`compact`,source:`yuri`,description:u(`chat.commandAutocomplete.command.compactDescription`),isBuiltIn:!0},...t()?[{id:`yuri:reload`,name:`reload`,source:`yuri`,description:u(`chat.commandAutocomplete.command.reloadDescription`),isBuiltIn:!0}]:[],..._?[{id:`yuri:summary`,name:`summary`,source:`yuri`,description:u(`chat.commandAutocomplete.command.summaryDescription`),isYuri:!0}]:[],...v?[{id:`yuri:workspace-review`,name:`workspace-review`,source:`yuri`,description:u(`chat.commandAutocomplete.command.workspaceReviewDescription`),isYuri:!0}]:[],...v?[{id:`yuri:craft-goal`,name:`craft-goal`,source:`yuri`,description:u(`chat.commandAutocomplete.command.craftGoalDescription`),isYuri:!0}]:[],...v?[{id:`yuri:catch-up`,name:`catch-up`,source:`yuri`,description:u(`chat.commandAutocomplete.command.catchUpDescription`),isYuri:!0}]:[],...v?[{id:`yuri:debug`,name:`debug`,source:`yuri`,description:u(`chat.commandAutocomplete.command.debugDescription`),isYuri:!0}]:[],...v?[{id:`yuri:weigh`,name:`weigh`,source:`yuri`,description:u(`chat.commandAutocomplete.command.weighDescription`),isYuri:!0}]:[],...v?[{id:`yuri:explore`,name:`explore`,source:`yuri`,description:u(`chat.commandAutocomplete.command.exploreDescription`),isYuri:!0}]:[],...n],i=!y,a=ge(r.filter(e=>(i||e.name!==`init`)&&(o?.(e)??!0)),e);x(e=>tt(e,a)?e:a)}catch{let n=!y,r=ge([{id:`yuri:new`,name:`new`,source:`yuri`,description:u(`chat.commandAutocomplete.command.newDescription`),isBuiltIn:!0},..._&&!y?[{id:`yuri:init`,name:`init`,source:`yuri`,description:u(`chat.commandAutocomplete.command.initDescription`),isBuiltIn:!0}]:[],..._?[{id:`yuri:btw`,name:`btw`,source:`yuri`,description:u(`chat.btw.description`),isBuiltIn:!0},{id:`yuri:undo`,name:`undo`,source:`yuri`,description:u(`chat.commandAutocomplete.command.undoDescription`),isBuiltIn:!0},{id:`yuri:redo`,name:`redo`,source:`yuri`,description:u(`chat.commandAutocomplete.command.redoDescription`),isBuiltIn:!0},{id:`yuri:fork`,name:`fork`,source:`yuri`,description:u(`chat.commandAutocomplete.command.forkDescription`),isBuiltIn:!0},{id:`yuri:timeline`,name:`timeline`,source:`yuri`,description:u(`chat.commandAutocomplete.command.timelineDescription`),isBuiltIn:!0}]:[],{id:`yuri:model`,name:`model`,source:`yuri`,description:u(`chat.commandAutocomplete.command.modelDescription`),isBuiltIn:!0},{id:`yuri:compact`,name:`compact`,source:`yuri`,description:u(`chat.commandAutocomplete.command.compactDescription`),isBuiltIn:!0},...t()?[{id:`yuri:reload`,name:`reload`,source:`yuri`,description:u(`chat.commandAutocomplete.command.reloadDescription`),isBuiltIn:!0}]:[],..._?[{id:`yuri:summary`,name:`summary`,source:`yuri`,description:u(`chat.commandAutocomplete.command.summaryDescription`),isYuri:!0}]:[],...v?[{id:`yuri:workspace-review`,name:`workspace-review`,source:`yuri`,description:u(`chat.commandAutocomplete.command.workspaceReviewDescription`),isYuri:!0}]:[],...v?[{id:`yuri:craft-goal`,name:`craft-goal`,source:`yuri`,description:u(`chat.commandAutocomplete.command.craftGoalDescription`),isYuri:!0}]:[],...v?[{id:`yuri:catch-up`,name:`catch-up`,source:`yuri`,description:u(`chat.commandAutocomplete.command.catchUpDescription`),isYuri:!0}]:[],...v?[{id:`yuri:debug`,name:`debug`,source:`yuri`,description:u(`chat.commandAutocomplete.command.debugDescription`),isYuri:!0}]:[],...v?[{id:`yuri:weigh`,name:`weigh`,source:`yuri`,description:u(`chat.commandAutocomplete.command.weighDescription`),isYuri:!0}]:[],...v?[{id:`yuri:explore`,name:`explore`,source:`yuri`,description:u(`chat.commandAutocomplete.command.exploreDescription`),isYuri:!0}]:[]].filter(e=>(n||e.name!==`init`)&&(o?.(e)??!0)),e);x(e=>tt(e,r)?e:r)}finally{w(!1)}})()},[e,y,_,v,E,D,u,o]),B.useEffect(()=>{k(0)},[b]),B.useEffect(()=>{A.current=O},[O]),B.useEffect(()=>{M.current[O]?.scrollIntoView({block:`nearest`})},[O]),B.useEffect(()=>{be(c,ne,{rows:le(b,{skill:u(`chat.commandAutocomplete.badge.skill`),command:u(`chat.commandAutocomplete.badge.command`),system:u(`chat.commandAutocomplete.badge.system`)}),highlightedIndex:O})},[b,c,O,u]);let ae=B.useRef(c);ae.current=c,B.useEffect(()=>()=>{xe(ae.current,ne)},[]),B.useImperativeHandle(l,()=>({acceptIndex:(e,t=!0)=>{let r=b[e];r&&n(r,Ke(r,t))},handleKeyDown:e=>{let t=b.length;if(e===`Escape`){r();return}if(t!==0){if(e===`ArrowDown`){j.current=!0,k(e=>(e+1)%t);return}if(e===`ArrowUp`){j.current=!0,k(e=>(e-1+t)%t);return}if(e===`Enter`||e===`Tab`){let r=(A.current%t+t)%t,i=b[r];i&&n(i,Ke(i,e===`Enter`))}}}}),[b,r,n]);let oe=e=>{let t=ce(e);switch(e.name){case`new`:return(0,$.jsx)(z,{name:t,className:`h-3.5 w-3.5`});case`init`:return(0,$.jsx)(z,{name:t,className:`h-3.5 w-3.5 text-green-500`});case`undo`:return(0,$.jsx)(z,{name:t,className:`h-3.5 w-3.5 text-orange-500`});case`redo`:return(0,$.jsx)(z,{name:t,className:`h-3.5 w-3.5 text-orange-500`});case`timeline`:case`reload`:return(0,$.jsx)(z,{name:t,className:`h-3.5 w-3.5`});case`compact`:return(0,$.jsx)(z,{name:t,className:`h-3.5 w-3.5 text-purple-500`});case`goal`:return(0,$.jsx)(z,{name:t,className:`h-3.5 w-3.5`});case`review`:return(0,$.jsx)(z,{name:t,className:`h-3.5 w-3.5 text-blue-500`});case`test`:case`build`:case`run`:return(0,$.jsx)(z,{name:t,className:`h-3.5 w-3.5 text-cyan-500`});default:return e.isBuiltIn?(0,$.jsx)(z,{name:t,className:`h-3.5 w-3.5 text-yellow-500`}):(0,$.jsx)(z,{name:t,className:`h-3.5 w-3.5 text-muted-foreground`})}};return(0,$.jsxs)(ue,{ref:N,isMobile:d,className:`max-w-[450px] max-h-64`,style:a,children:[(0,$.jsx)(ie,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0 py-1.5`,children:C?(0,$.jsx)(`div`,{className:`flex items-center justify-center py-4`,children:(0,$.jsx)(z,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):(0,$.jsxs)(`div`,{children:[b.map((t,r)=>{let i=t.isBuiltIn,a=t.isYuri;return(0,$.jsxs)(`div`,{ref:e=>{M.current[r]=e},className:F(`flex gap-2 px-2 py-2 cursor-pointer rounded-lg`,d?`items-center`:`items-start`,de(d,r===O),!d&&r===O&&`bg-interactive-selection/35`),onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&(I.current={x:e.clientX,y:e.clientY},R.current=!1)},onPointerMove:e=>{if(e.pointerType!==`touch`||!I.current)return;let t=e.clientX-I.current.x,n=e.clientY-I.current.y;Math.hypot(t,n)>6&&(R.current=!0)},onPointerUp:e=>{if(e.pointerType!==`touch`)return;let r=R.current;I.current=null,R.current=!1,!r&&(e.preventDefault(),e.stopPropagation(),ee.current=!0,n(t,Ke(t,d)))},onPointerCancel:()=>{I.current=null,R.current=!1},onClick:()=>{if(ee.current){ee.current=!1;return}n(t,Ke(t,d))},onMouseMove:()=>{j.current=!1,k(r)},children:[(0,$.jsx)(`div`,{className:F(!d&&`mt-0.5`),children:oe(t)}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(`span`,{className:`typography-ui-label font-medium`,children:[`/`,Me(t.name,e)]}),t.isSkill?(0,$.jsx)(`span`,{className:Ze,children:u(`chat.commandAutocomplete.badge.skill`)}):(0,$.jsx)(`span`,{className:Ze,children:u(`chat.commandAutocomplete.badge.command`)}),a?(0,$.jsx)(`span`,{className:et,children:`Yuri`}):i?(0,$.jsx)(`span`,{className:et,children:u(`chat.commandAutocomplete.badge.system`)}):t.scope?(0,$.jsx)(`span`,{className:t.scope===`project`?$e:Qe,children:t.scope}):null,t.agent&&(0,$.jsx)(`span`,{className:et,children:t.agent})]}),t.description&&!d&&(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground mt-0.5 truncate`,children:Me(t.description,e)})]})]},t.id)}),b.length===0&&(0,$.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:u(`chat.commandAutocomplete.empty`)})]})}),!d&&(0,$.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:u(`chat.autocomplete.keyboardHint`)})]})});rt.displayName=`CommandAutocomplete`;var it=(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?` `:``}`},at=(e,t,n)=>{let r=it(e,t,n);return`${t.length===0&&!/^\s/.test(r)?` `:``}${r}${n.length===0&&!/\s$/.test(r)?` `:``}`},ot=(e,t,n,r)=>{let i=e.slice(0,t),a=e.slice(n),o=at(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}},st=(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]},ct=(e,t)=>t<e.length&&e[t]===` `?t+1:t;export{rt as a,Ne as c,Ce as d,U as f,at as i,Q as l,st as n,Ye as o,ye as p,ot as r,qe as s,ct as t,Z as u};