@yuriai/web 0.3.2 → 0.3.3-beta.16

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 (312) hide show
  1. package/dist/assets/AgentAvatar-CHCjMxCF.js +1 -0
  2. package/dist/assets/AgentSelector-Y-O2ix4y.js +1 -0
  3. package/dist/assets/ArchivedSessionsDialog-BuA5qj8G.js +1 -0
  4. package/dist/assets/AssistantConversationSurface-B_cXq21H.js +3 -0
  5. package/dist/assets/AssistantSessionCard-DM513DvH.js +2 -0
  6. package/dist/assets/AssistantUnreadBadge-p9mkpbMC.js +1 -0
  7. package/dist/assets/AssistantView-C-KTy7x0.js +1 -0
  8. package/dist/assets/AssistantWorkingAvatar-CoxhuMvM.js +1 -0
  9. package/dist/assets/AssistantsSettingsPage-Dq6tz9a4.js +1 -0
  10. package/dist/assets/BinaryFileFallback-CKNAgvHj.css +1 -0
  11. package/dist/assets/BinaryFileFallback-Ce8Tb2eT.js +1 -0
  12. package/dist/assets/BtwPanel-m2z9ve0r.js +6 -0
  13. package/dist/assets/BusyDots-CtT00apU.js +4 -0
  14. package/dist/assets/ChatContainer-B_51a5IM.js +65 -0
  15. package/dist/assets/ChatView-XPKYQSRT.js +3 -0
  16. package/dist/assets/{DiagramView-CwgPnPU8.js → DiagramView-DdcQkKrt.js} +1 -1
  17. package/dist/assets/DiffView-DOkOTpyw.js +6 -0
  18. package/dist/assets/DiffViewToggle-BwJ6MYB7.js +1 -0
  19. package/dist/assets/DiffWorkerProvider-VFPkag9y.js +1 -0
  20. package/dist/assets/ErrorBoundary-CH2h3eG1.js +1 -0
  21. package/dist/assets/FadeInOnReveal-B3uT04YJ.js +1 -0
  22. package/dist/assets/GuiPluginMount-CwwJFGus.js +1 -0
  23. package/dist/assets/GuiPluginPage-3ckHzsip.js +1 -0
  24. package/dist/assets/GuiPluginSurface-DaaXNIx_.js +1 -0
  25. package/dist/assets/GuiPluginTitlebarItems-DxFINwbr.js +1 -0
  26. package/dist/assets/GuiPluginWindow-BkAFJyFd.js +1 -0
  27. package/dist/assets/Icon-DmykXZL1.js +1 -0
  28. package/dist/assets/ImageLoadingPlaceholder-DgM_EFHn.js +1 -0
  29. package/dist/assets/{LoadingImage-DNt-_HCJ.js → LoadingImage-Df22Rkor.js} +1 -1
  30. package/dist/assets/MarkdownRenderer-WoxwVIoR.js +2 -0
  31. package/dist/assets/MarkdownRendererImpl--jZL9vQc.js +10 -0
  32. package/dist/assets/MarkstreamRendererImpl-BJpcybrS.js +3 -0
  33. package/dist/assets/MobileAssistantSettingsPage-DXiu2yok.js +1 -0
  34. package/dist/assets/MobileAssistantTab-CMIQansR.js +1 -0
  35. package/dist/assets/MobileBtwPage-tdS0tYPj.js +1 -0
  36. package/dist/assets/MobileChangesSurface-BU4qFaHP.js +4 -0
  37. package/dist/assets/MobileChatScreen-DecNa9lW.js +1 -0
  38. package/dist/assets/MobileDetailNavigation-ldTzGo19.js +1 -0
  39. package/dist/assets/MobileFilesSurface-D2YLR9XN.js +2 -0
  40. package/dist/assets/MobileHtmlNetworkBoundary-D1U1-KQS.js +2 -0
  41. package/dist/assets/MobileOverlayPanel-C36VWWmN.js +1 -0
  42. package/dist/assets/MobileResizableSheet-CqphcaKq.js +1 -0
  43. package/dist/assets/MobileSettingsTab-CsbMGpja.js +1 -0
  44. package/dist/assets/MobileShareBridge-BAavK3r-.js +3 -0
  45. package/dist/assets/MobileSurface-cmaGf3hZ.js +1 -0
  46. package/dist/assets/MobileTabPageHeader-D6P4K98S.js +1 -0
  47. package/dist/assets/ModelLogo-BkbD514M.js +1 -0
  48. package/dist/assets/ModelSelector-DGFW9Dr_.js +1 -0
  49. package/dist/assets/MultiRunWindow-B6DftPF5.js +1 -0
  50. package/dist/assets/OnboardingScreen-De2wu_BS.js +1 -0
  51. package/dist/assets/OverlayScrollbar-D6vmoMkQ.js +1 -0
  52. package/dist/assets/PierreDiffViewer-CglLIEfr.js +139 -0
  53. package/dist/assets/ProviderLogo-DA98yu7M.js +1 -0
  54. package/dist/assets/RemoteAssistantSessionCard-VfMaU9MY.js +1 -0
  55. package/dist/assets/RemoteDesktopPanel-DBXYIcvY.js +1 -0
  56. package/dist/assets/ScheduledTasksDialog-DHbl98gj.js +3 -0
  57. package/dist/assets/ScrollableOverlay-stxT7gLf.js +1 -0
  58. package/dist/assets/SessionSurfaceContext-BP4NCKp6.js +10 -0
  59. package/dist/assets/SettingsGroup-CvaPYznp.js +1 -0
  60. package/dist/assets/SettingsView-CvH-qF2z.js +29 -0
  61. package/dist/assets/SettingsWindow-5Asj_0Ab.js +1 -0
  62. package/dist/assets/SetupTourDialog-D5j5AMCy.js +1 -0
  63. package/dist/assets/SyncActions-CrOoREWF.js +1 -0
  64. package/dist/assets/TerminalView-ClTlg6zO.js +8 -0
  65. package/dist/assets/TextSelectionMenu-CNB9OqIt.js +11 -0
  66. package/dist/assets/ToolOutputDialog-Bbvt55F0.js +16 -0
  67. package/dist/assets/{YuriLogo-BKdnDJwl.js → YuriLogo-Cp6vWDWp.js} +1 -1
  68. package/dist/assets/{YuriWordmark-D2e-o9nW.js → YuriWordmark-CLGHwobA.js} +1 -1
  69. package/dist/assets/appThemeRegistry-BdjrGBQ4.js +1 -0
  70. package/dist/assets/{assistant-attachment-cache-BYvIyn1x.js → assistant-attachment-cache-bRIIESGe.js} +1 -1
  71. package/dist/assets/assistantMessagePreview-DLBvPQtq.js +1 -0
  72. package/dist/assets/assistantPresentation-DRbsH1Ej.js +1 -0
  73. package/dist/assets/assistantQueries-NdPqu6rx.js +1 -0
  74. package/dist/assets/audio-session-BFWjrDbp.js +1 -0
  75. package/dist/assets/auto-read-context-CIdRIbjK.js +5 -0
  76. package/dist/assets/{speechSettingsQueries-BHZs2Dyf.js → browserVoiceService-x5Pci8L3.js} +3 -3
  77. package/dist/assets/{capgoAdapter-Q9jzJN69.js → capgoAdapter-C5kwQhZH.js} +1 -1
  78. package/dist/assets/card-DmysoUAV.js +1 -0
  79. package/dist/assets/chatUpwardIntent-BmpMGV0w.js +1 -0
  80. package/dist/assets/checkbox-BMN5hAVm.js +1 -0
  81. package/dist/assets/{client-CzjApAA4.js → client-B_907PBv.js} +1 -1
  82. package/dist/assets/collapsible-Z0IjDAMO.js +1 -0
  83. package/dist/assets/connection-hint-B-kOWome.js +2 -0
  84. package/dist/assets/context-menu-CKlB6wxo.js +1 -0
  85. package/dist/assets/contextPanelEmbeddedChat-Dm5R_b5X.js +1 -0
  86. package/dist/assets/{device-BlmHHWT1.js → device-EIfSfSWk.js} +1 -1
  87. package/dist/assets/diagram-CzY6n_4N.js +1 -0
  88. package/dist/assets/dialog-BeFBA6ja.js +1 -0
  89. package/dist/assets/dialog-D9CkSNCA.css +1 -0
  90. package/dist/assets/dropdown-menu-BblI9sN2.js +1 -0
  91. package/dist/assets/{es-DuTK1iYh.js → es-DqYZgeC6.js} +1 -1
  92. package/dist/assets/fileMentionAutocompleteState-B9411b4o.js +2 -0
  93. package/dist/assets/{fileMentionTouchSelection-C0O4_Efn.js → fileMentionTouchSelection-BQEUty_A.js} +2 -2
  94. package/dist/assets/{fileReferenceActions-DLTUzjwi.js → fileReferenceActions-TmbrIHBI.js} +1 -1
  95. package/dist/assets/{fr-C_XToFWm.js → fr-BHaun7Zq.js} +1 -1
  96. package/dist/assets/{gitApi-BA93t0ww.js → gitApi-BI8gTJru.js} +1 -1
  97. package/dist/assets/gitApiHttp-Dd-FwgCq.js +3 -0
  98. package/dist/assets/githubAuthQueries-DqregESf.js +1 -0
  99. package/dist/assets/historyImportQueries-D00KjUT2.js +1 -0
  100. package/dist/assets/{host-BBp7NPZz.js → host-ChBHl_Vl.js} +1 -1
  101. package/dist/assets/{i18n-BvjeIWrT.js → i18n-DXc6czdR.js} +1 -1
  102. package/dist/assets/icons-Bd-INsoy.js +1 -0
  103. package/dist/assets/{image-loading-Dlh4FIPJ.js → imageSource-BR4C9TuS.js} +1 -1
  104. package/dist/assets/inlineMessageLinks-DC78iKO5.js +1 -0
  105. package/dist/assets/input-Cf16qJ6g.js +1 -0
  106. package/dist/assets/{input-store-wWToFdzi.js → input-store-BSJBQTMi.js} +1 -1
  107. package/dist/assets/insertionBoundaries-BdPIw7sm.js +1 -0
  108. package/dist/assets/{ja-D0pDybpB.js → ja-BGNugvrx.js} +1 -1
  109. package/dist/assets/kbd-CamdaxHJ.js +1 -0
  110. package/dist/assets/{ko-CAzlaaDJ.js → ko-CGbNBfDe.js} +1 -1
  111. package/dist/assets/main-LnwLNNJu.js +169 -0
  112. package/dist/assets/main-gYmGdwmH.js +2 -0
  113. package/dist/assets/{markdownHeightCache-CaBnqn2C.js → markdownHeightCache-CHGGNhWI.js} +1 -1
  114. package/dist/assets/{markdownTheme-C2LJ3cJo.js → markdownTheme-D84XyNiT.js} +1 -1
  115. package/dist/assets/mcpQueries-BKAVhjr3.js +1 -0
  116. package/dist/assets/miniChat-C8uubxw9.js +2 -0
  117. package/dist/assets/mobile-OBzNXeEM.js +2 -0
  118. package/dist/assets/mobileAppContext-BQgdTp5T.js +1 -0
  119. package/dist/assets/mobileBackNavigation-8JySoaRF.js +1 -0
  120. package/dist/assets/mobileConnections-7wP-T5bc.js +2 -0
  121. package/dist/assets/multirun-B8wxvV3F.js +3 -0
  122. package/dist/assets/{native-config-C0CpO-0Q.js → native-config-rSn3LLz4.js} +1 -1
  123. package/dist/assets/nativeComposerCover-04c_IwGr.js +1 -0
  124. package/dist/assets/navigation--cBMQO70.js +2 -0
  125. package/dist/assets/openRemoteProjectSession-Driv6jop.js +1 -0
  126. package/dist/assets/permission-rules-DoQUXKll.js +1 -0
  127. package/dist/assets/{pl-BvjbUcJV.js → pl-k8-4URiE.js} +1 -1
  128. package/dist/assets/pluginPresentation-CuCmjxYR.js +2 -0
  129. package/dist/assets/{project-preview-BjTq299L.js → project-preview-BCtFY4Rg.js} +1 -1
  130. package/dist/assets/projectMeta-vIaGFaQr.js +1 -0
  131. package/dist/assets/{prompt-attachment-upload-Bem87nmm.js → prompt-attachment-upload-B5DHrw6U.js} +1 -1
  132. package/dist/assets/{pt-BR-D71qrP91.js → pt-BR-DdwCzXBH.js} +1 -1
  133. package/dist/assets/pwa-CmLnRiAE.js +2 -0
  134. package/dist/assets/queue-abort-optimistic-dagyHxI5.js +1 -0
  135. package/dist/assets/quota-CqWNkFzw.js +1 -0
  136. package/dist/assets/react-CPBNl-S9.js +1 -0
  137. package/dist/assets/reference-history-BqEmyaH0.js +1 -0
  138. package/dist/assets/{remote-input-store-BvlOGMu_.js → remote-input-store-C6UIEZxp.js} +1 -1
  139. package/dist/assets/remoteProjectQueries-C8382jM8.js +1 -0
  140. package/dist/assets/remoteSessionReference-wm-7vGPU.js +1 -0
  141. package/dist/assets/renderElectronMiniChatApp-CCqwX73F.js +2 -0
  142. package/dist/assets/renderMobileApp-DpdAzswD.js +17 -0
  143. package/dist/assets/router-DXUi1sBd.js +1 -0
  144. package/dist/assets/{runtime-file-download-DxL4XbME.js → runtime-file-download-BWeoSXRb.js} +1 -1
  145. package/dist/assets/runtime-file-resource-Bc_ss-sW.js +2 -0
  146. package/dist/assets/{runtimeConfig-C1A5pejN.js → runtimeConfig-pUJV4QRV.js} +1 -1
  147. package/dist/assets/runtimeEndpointReset-BeP-eS0q.js +4 -0
  148. package/dist/assets/{runtimeEndpointReset-BIrMtGn5.css → runtimeEndpointReset-DuvtZAyx.css} +1 -1
  149. package/dist/assets/scheduledTaskNavigation-VVTOq9n2.js +1 -0
  150. package/dist/assets/select-assistant-mmsKjj2O.js +1 -0
  151. package/dist/assets/select-vZCgcnYG.js +1 -0
  152. package/dist/assets/session-startup-barrier-DT-hIBRf.js +1 -0
  153. package/dist/assets/sessionLookup-9xT7pc4Q.js +1 -0
  154. package/dist/assets/sessionOwnership-xOCCIVwh.js +2 -0
  155. package/dist/assets/shortcuts-WkN3Gh8v.js +1 -0
  156. package/dist/assets/sortAssistantContacts-CcEdm3mS.js +1 -0
  157. package/dist/assets/sortable-tabs-strip-DmtfYPz0.js +1 -0
  158. package/dist/assets/spacedFileMention-Ds4GtgiF.js +1 -0
  159. package/dist/assets/speechSettingsQueries-BalG6g1E.js +1 -0
  160. package/dist/assets/src-QTj33Z0x.css +2 -0
  161. package/dist/assets/{store-Dj5cSf8B.js → store-C1ifDY0C.js} +4 -4
  162. package/dist/assets/switch-CNmsFYfY.js +1 -0
  163. package/dist/assets/{terminalApi-CwTOFYhX.js → terminalApi-DXvEquBF.js} +1 -1
  164. package/dist/assets/textarea-ZiXxEOHK.js +1 -0
  165. package/dist/assets/timeFormat-dCsf2MQv.js +1 -0
  166. package/dist/assets/tooltip-CpTbxEOE.js +1 -0
  167. package/dist/assets/touch-gestures-DOoBxhz5.js +1 -0
  168. package/dist/assets/truncated-path-CcmWjgCQ.js +1 -0
  169. package/dist/assets/types-s46TxX4o.js +2 -0
  170. package/dist/assets/ui-DyxdnQlj.js +13 -0
  171. package/dist/assets/{uk-C7c1Zece.js → uk-DU-7fAP4.js} +1 -1
  172. package/dist/assets/useAppFontEffects-xFDWXJMz.js +7 -0
  173. package/dist/assets/{useAssistantUIStore-CI42fWZh.js → useAssistantUIStore-CpJZ4Rqs.js} +1 -1
  174. package/dist/assets/useDebouncedValue-BHlMPqY8.js +1 -0
  175. package/dist/assets/useDesktopWindowControlsLayout-Cf_gfhz_.js +1 -0
  176. package/dist/assets/useDictation-CZzAlsW0.js +1 -0
  177. package/dist/assets/useEffectiveDirectory-CjnAEiMV.js +1 -0
  178. package/dist/assets/{useFontPreferences-DN1mCOsX.js → useFontPreferences-BiRBKhti.js} +1 -1
  179. package/dist/assets/useGitStore-B6LCPegX.js +1 -0
  180. package/dist/assets/useInlineCommentDraftStore-B2mkmAZd.js +6510 -0
  181. package/dist/assets/useMcpConfigStore-BdSg-516.js +1 -0
  182. package/dist/assets/{useMobileHtmlPreviewStore-DzzgY1eS.js → useMobileHtmlPreviewStore-BYunNOBo.js} +1 -1
  183. package/dist/assets/useMobileSwipeActions-XoxrtaUo.js +1 -0
  184. package/dist/assets/useMobileTranscriptSyncHint-BXi8O9sk.js +10 -0
  185. package/dist/assets/useModelLists-DmyYnnr4.js +1 -0
  186. package/dist/assets/useOpenCodeReadiness-Db_8COSR.js +1 -0
  187. package/dist/assets/usePluginsStore-COtfsDZ3.js +1 -0
  188. package/dist/assets/useProjectGitActions-BUoCPOxJ.js +1 -0
  189. package/dist/assets/useProjectGitStore-xVrTE-C9.js +1 -0
  190. package/dist/assets/useProjectRuntimeAPIs-BejNbqXr.js +1 -0
  191. package/dist/assets/useQuotaStore-CSn2pk3T.js +1 -0
  192. package/dist/assets/useSessionBtwStore-CD65yTSZ.js +11 -0
  193. package/dist/assets/{useStreamingTextThrottle-DAr0FPKI.js → useStreamingTextThrottle-C9SaKeil.js} +1 -1
  194. package/dist/assets/{useThemeSystem-D2YBbLma.js → useThemeSystem-BIXghnHj.js} +1 -1
  195. package/dist/assets/useUIStore-C3ewjGgP.js +1 -0
  196. package/dist/assets/{vendor-base-ui-fom6orB6.js → vendor-base-ui-wXsskyKm.js} +1 -1
  197. package/dist/assets/{vendor-cmdk-BKc6RGpL.js → vendor-cmdk-BDWoZLve.js} +1 -1
  198. package/dist/assets/{vendor-dnd-kit-accessibility-Cf9EEJvm.js → vendor-dnd-kit-accessibility-u0XSXxKq.js} +1 -1
  199. package/dist/assets/{vendor-dnd-kit-core-DRyd7I0I.js → vendor-dnd-kit-core-qy5stxu5.js} +1 -1
  200. package/dist/assets/{vendor-dnd-kit-sortable-C8S8cyRO.js → vendor-dnd-kit-sortable-CiTIuX4o.js} +1 -1
  201. package/dist/assets/{vendor-framer-motion-DiGWHm7K.js → vendor-framer-motion-D5NyyC73.js} +1 -1
  202. package/dist/assets/{vendor-markstream-react-Cwc-VXWM.js → vendor-markstream-react-BqCCtUAV.js} +3 -3
  203. package/dist/assets/vendor-motion-vLNN8EMu.js +1 -0
  204. package/dist/assets/{vendor-pierre-diffs-HJfPTtu2.js → vendor-pierre-diffs-B0OmIhMO.js} +22 -22
  205. package/dist/assets/{vendor-react-D5BntRmA.js → vendor-react-BkccXcWz.js} +1 -1
  206. package/dist/assets/{vendor-react-drawio-DXADKcSU.js → vendor-react-drawio-C9rszQEJ.js} +1 -1
  207. package/dist/assets/{vendor-reactuses-core-B8s-Rcd-.js → vendor-reactuses-core-DjKFMfz7.js} +1 -1
  208. package/dist/assets/{vendor-sonner-Y-KPX915.js → vendor-sonner-DX3nfJx4.js} +1 -1
  209. package/dist/assets/{vendor-stream-diffs-BMT21f-n.js → vendor-stream-diffs-CI1nlTpw.js} +2 -2
  210. package/dist/assets/{vendor-tanstack-react-query-ChSd65dm.js → vendor-tanstack-react-query-DIb_ItL-.js} +1 -1
  211. package/dist/assets/{vendor-tanstack-react-virtual-WY42p6U6.js → vendor-tanstack-react-virtual-qsd3nvZb.js} +1 -1
  212. package/dist/assets/{vendor-zustand-CNn3HHhT.js → vendor-zustand-CTekDqaS.js} +1 -1
  213. package/dist/assets/worktreeManager-Bv12AnI9.js +1 -0
  214. package/dist/assets/worktreeSourceBranchPreference-Bj0LPDqn.js +1 -0
  215. package/dist/assets/yuriEvents-BFrD5fMU.js +5 -0
  216. package/dist/assets/{zh-CN-D2ENuI1-.js → zh-CN-DOHH7nht.js} +1 -1
  217. package/dist/assets/{zh-TW-C40BXFhK.js → zh-TW-t1qlXGOg.js} +1 -1
  218. package/dist/assets/zhipuai-coding-plan-CcFj8zKy.js +1 -0
  219. package/dist/index.html +20 -19
  220. package/dist/mini-chat.html +20 -19
  221. package/dist/mobile.html +2 -2
  222. package/package.json +1 -1
  223. package/server/lib/opencode/settings-helpers.js +6 -0
  224. package/server/lib/opencode/settings-helpers.test.js +8 -0
  225. package/server/lib/session-index/DOCUMENTATION.md +27 -0
  226. package/server/lib/session-index/event-ingest.js +6 -2
  227. package/server/lib/session-index/event-ingest.test.js +12 -0
  228. package/server/lib/session-index/routes.js +26 -0
  229. package/server/lib/session-index/routes.test.js +53 -0
  230. package/server/lib/session-index/service.js +79 -1
  231. package/server/lib/session-index/service.test.js +125 -1
  232. package/dist/assets/AgentAvatar-DmvbnnMh.js +0 -1
  233. package/dist/assets/AssistantConversationSurface-DxmQrzax.js +0 -3
  234. package/dist/assets/AssistantSessionCard-CsZIdhOH.js +0 -2
  235. package/dist/assets/AssistantUnreadBadge-0K84uUof.js +0 -1
  236. package/dist/assets/AssistantView-eo7zU0tW.js +0 -1
  237. package/dist/assets/FadeInOnReveal-CIabuv8E.js +0 -1
  238. package/dist/assets/GuiPluginPage-CBWlpM7-.js +0 -1
  239. package/dist/assets/GuiPluginSurface-4piMFmC2.js +0 -1
  240. package/dist/assets/GuiPluginWindow-D02tLdop.js +0 -1
  241. package/dist/assets/Icon-Br-W35tz.js +0 -1
  242. package/dist/assets/ImageLoadingPlaceholder-EHe_20yz.js +0 -1
  243. package/dist/assets/MarkdownRenderer-BjRyxBUx.js +0 -2
  244. package/dist/assets/MarkdownRendererImpl-CxfAdy1l.js +0 -10
  245. package/dist/assets/MarkstreamRendererImpl-B1ALcl04.js +0 -3
  246. package/dist/assets/MarkstreamRendererImpl-C6aiJnjl.css +0 -1
  247. package/dist/assets/MobileDetailNavigation-DNLOs1n6.js +0 -1
  248. package/dist/assets/MobileResizableSheet-Bp_8Cf4j.js +0 -1
  249. package/dist/assets/MobileShareBridge-9zfdEyQ_.js +0 -3
  250. package/dist/assets/MobileSurface-B1O-lCca.js +0 -2
  251. package/dist/assets/MultiRunWindow-DMvB8O02.js +0 -1
  252. package/dist/assets/OnboardingScreen-DgxRaKDc.js +0 -1
  253. package/dist/assets/OverlayScrollbar-CcX4ZP8W.js +0 -1
  254. package/dist/assets/RemoteAssistantSessionCard-BJz_SKef.js +0 -1
  255. package/dist/assets/SettingsView-D7Kb5iGY.js +0 -29
  256. package/dist/assets/SettingsWindow-YzVAr8Bo.js +0 -1
  257. package/dist/assets/SetupTourDialog-Dw9q3oII.js +0 -1
  258. package/dist/assets/TerminalView-DZChxb-F.js +0 -8
  259. package/dist/assets/ToolOutputDialog-2F74CchZ.js +0 -16
  260. package/dist/assets/VoiceSettings-CJh5q7QP.js +0 -2
  261. package/dist/assets/checkbox-CqeGKP3Z.js +0 -1
  262. package/dist/assets/collapsible-BSOetNHq.js +0 -1
  263. package/dist/assets/context-menu-r_DjszgU.js +0 -1
  264. package/dist/assets/diagram-CxwT-HHn.js +0 -1
  265. package/dist/assets/dialog-DYOEW9DC.css +0 -1
  266. package/dist/assets/dialog-rXqw-6ab.js +0 -1
  267. package/dist/assets/fileMentionAutocompleteState-BZJqfgae.js +0 -2
  268. package/dist/assets/gitApiHttp-BgUDBfaJ.js +0 -3
  269. package/dist/assets/historyImportQueries-DiGQ8duS.js +0 -1
  270. package/dist/assets/input-9Y3tNEd9.js +0 -1
  271. package/dist/assets/insertionBoundaries-Dl5RMmA3.js +0 -1
  272. package/dist/assets/main-Cli25Koo.js +0 -169
  273. package/dist/assets/main-Dj1N_rUJ.js +0 -2
  274. package/dist/assets/mcpQueries-DCgOzZ7g.js +0 -1
  275. package/dist/assets/miniChat-Ct0NeLs3.js +0 -2
  276. package/dist/assets/mobile-Kg6aWex1.js +0 -2
  277. package/dist/assets/mobileBackNavigation-XjzoONfU.js +0 -1
  278. package/dist/assets/mobileConnections-plT2Z1fc.js +0 -2
  279. package/dist/assets/multirun-1YatqupB.js +0 -3
  280. package/dist/assets/navigation-Bz_aROXw.js +0 -2
  281. package/dist/assets/openRemoteProjectSession-9kfNj2Jy.js +0 -1
  282. package/dist/assets/projectMeta-CBxwAjHm.js +0 -1
  283. package/dist/assets/pwa-1EqcEjis.js +0 -2
  284. package/dist/assets/queue-abort-optimistic-C6AsLSmI.js +0 -1
  285. package/dist/assets/react-B_qpic0Y.js +0 -1
  286. package/dist/assets/readiness-DcOz5lOE.js +0 -2
  287. package/dist/assets/reference-history-DOMZlJml.js +0 -1
  288. package/dist/assets/remoteProjectQueries-yX3kOkR6.js +0 -1
  289. package/dist/assets/remoteSessionReference-Cn7Wzrg6.js +0 -1
  290. package/dist/assets/renderElectronMiniChatApp-B-hPtyBl.js +0 -2
  291. package/dist/assets/renderMobileApp-CuOXMDN3.js +0 -29
  292. package/dist/assets/runtime-file-resource-CKQQEwNv.js +0 -6
  293. package/dist/assets/runtimeEndpointReset-oiLvIGYI.js +0 -151
  294. package/dist/assets/scheduledTaskNavigation-CdBHn9ti.js +0 -1
  295. package/dist/assets/select-CK1DjdEi.js +0 -1
  296. package/dist/assets/sessionLookup-CmckqEe_.js +0 -1
  297. package/dist/assets/sortable-tabs-strip-Bd9uV_sY.js +0 -1
  298. package/dist/assets/src-aLILBedG.css +0 -2
  299. package/dist/assets/textarea-DvCd0eUo.js +0 -1
  300. package/dist/assets/tooltip-B93KmoPh.js +0 -1
  301. package/dist/assets/types-ClAbMq1_.js +0 -2
  302. package/dist/assets/useAppFontEffects-EXiDcoNt.js +0 -6620
  303. package/dist/assets/useDesktopWindowControlsLayout-4TLDMOLv.js +0 -1
  304. package/dist/assets/useDictation-OLmxagFb.js +0 -1
  305. package/dist/assets/useEffectiveDirectory-DFe0GivQ.js +0 -1
  306. package/dist/assets/useMobileNavigationStore-BtHQN423.js +0 -13
  307. package/dist/assets/usePluginsStore-Ch1DaoBM.js +0 -1
  308. package/dist/assets/useProjectRuntimeAPIs-CnTyVRex.js +0 -1
  309. package/dist/assets/useUIStore-DjizmHAt.js +0 -1
  310. package/dist/assets/vendor-motion-DtmZZeEm.js +0 -1
  311. /package/dist/assets/{useAppFontEffects-K31q-1OV.css → ChatContainer-K31q-1OV.css} +0 -0
  312. /package/dist/assets/{VoiceSettings-C0HSdVvS.css → pluginPresentation-C0HSdVvS.css} +0 -0
@@ -1,3 +0,0 @@
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 te}from"./vendor-zustand-CNn3HHhT.js";import{st as ne}from"./vendor-base-ui-fom6orB6.js";import"./brand-storage-bootstrap-D4BW3w-M.js";import{i as re,n as _,t as ie}from"./safeStorage-DTOhKN0V.js";import{Cr as v,R as ae,Sr as oe,n as y,xr as b}from"./client-CzjApAA4.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-Bem87nmm.js";import{n as xe}from"./vendor-react-D5BntRmA.js";import{q as Se}from"./runtime-file-resource-CKQQEwNv.js";import{_ as Ce,c as we,l as Te,r as S,v as Ee}from"./useUIStore-DjizmHAt.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}`,Ie=`"(?:[^"\\\\\\r\\n]|\\\\.)*"`,Le=RegExp(`@session:(\\{"sessionID":${Ie},"directory":${Ie}(?:,"target":\\{"hubId":${Ie},"hostId":${Ie},"instanceId":${Ie}\\})?\\}|[A-Za-z0-9_-]+)`,`g`),Re=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}},ze=(e,t)=>({trigger:`/`,icon:t,label:e}),Be=(e,t)=>({trigger:t,icon:`book-open`,label:e}),Ve=(e,t)=>[`/`,`@`].some(n=>ge(e,Be(t,n))),He=(e,t)=>ge(e,Be(t,`@`))?Be(t,`@`):Be(t,`/`),Ue={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:Le,resolveDisplay:(e,t)=>{let n=e.index===0?``:t.text[e.index-1],r=t.text[e.index+e[0].length]??``,i=Re(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=Re(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`&&Ve(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(He(e.display,e.skillName),e.display)}),payloadBudget:()=>void 0,canonical:{matcher:pe(),resolveDisplay:e=>he(Be(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,ze(e.commandName,`command`)),contributeCanonical:e=>({text:`[command:${e.reference}]`}),contributeDirectSend:e=>({text:`[command:${e.reference}]`}),decorate:e=>({style:`mentionCommand`,visual:_e(ze(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(ze(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})}}},w=e=>Ue[e],We=(e,t)=>w(e).validatePayload(t),Ge=e=>w(e.kind).contributeCanonical(e),Ke=e=>w(e.kind).contributeDirectSend(e),qe=e=>w(e.kind).decorate(e),Je=e=>w(e.kind).payloadBudget(e),Ye=e=>w(e.kind).describeResourceIdentity?.(e),Xe=Object.keys(Ue),Ze=e=>typeof e==`string`&&Xe.includes(e),Qe=()=>Xe.flatMap(e=>{let t=w(e).canonical;return t?[t]:[]}),$e=e=>{if(e.type===`attachment`)return`attachment:${e.attachmentRefID}`},et=e=>{let t=new Map;for(let n of e.references){let e=Ye(n);e&&t.set($e(e),e)}return[...t.values()]},tt=(e,t)=>{let n=new Map(e.map(e=>[$e(e),e])),r=new Map(t.map(e=>[$e(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])}},nt=(e,t)=>tt(et(e),et(t)),rt=(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=Je(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`?Ke(r):Ge(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}},T=(e,t)=>Math.max(0,Math.min(e,t)),it=(e,t)=>typeof e==`string`&&e.length>0&&e.length<=t,at=e=>{if(typeof e!=`object`||!e)return!1;let t=e;return!it(t.id,C.displayLength)||!it(t.display,C.displayLength)||!Number.isSafeInteger(t.start)||!Number.isSafeInteger(t.end)||typeof t.kind!=`string`?!1:Ze(t.kind)&&We(t.kind,t)},E=(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(!at(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=Je(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}},D=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(!it(o.id,C.idLength)||!it(o.display,C.displayLength)||!Ze(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=Je(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}},ot=(e,t)=>{if(t.length>x.pastePayloadLength)return!1;let n=E(e.text,e.references);return n.budgetExceeded||n.payloadBudgetExceeded?!1:n.document.references.reduce((e,t)=>{let n=Je(t);return e+(n?.category===`opaque-text`?n.length:0)},0)+t.length<=x.totalPastePayloadLength},st=(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 ct(e,t,n,r,i={}){let a=D(e);if(!We(r.kind,r))return{document:a,caret:T(n,a.text.length),edit:{oldStart:t,oldEnd:n,newEnd:n}};let o=T(t,a.text.length),s=Math.max(o,T(n,a.text.length)),c=st(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:D({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 lt=(e,t)=>e<=t.oldStart?e:e>=t.oldEnd?e+t.newEnd-t.oldEnd:t.newEnd,ut=(e,t,n=t.length,r=n)=>{let i=D(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=st(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=T(e,t.length),i=c.newEnd+l.end-c.oldEnd;return T(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)},te=ee(n,`start`),ne=Math.max(te,ee(r,`end`)),re=D({text:p,references:g});return{document:re,edit:m,requiresTextCorrection:u,selectionStart:te,selectionEnd:ne,caret:ne,mapCaret:e=>T(lt(e,m),re.text.length),removedReferences:d}},dt=(e,t,n)=>{let r=st(n,e,t);return r.start===e&&r.end===t?null:r},ft=(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}},pt=(e,t)=>{let n=D(e),r=T(t.selectionStart,n.text.length),i=Math.max(r,T(t.selectionEnd,n.text.length)),a=r===i?t.altKey?ft(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=dt(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:D({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}},mt=(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}},ht=(e,t=`queue-canonical`)=>{let n=E(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=rt(n.document,t);return r.ok?{ok:!0,text:r.text,chunks:r.plan.chunks,semantics:r.plan.semantics}:r},gt=(e,t)=>e.match.index-t.match.index||e.adapterOrder-t.adapterOrder||e.matchOrder-t.matchOrder,_t=e=>{if(e.length>C.canonicalOutputLength||e.length>C.visibleTextLength)return null;let t=[],n=0;for(let[r,i]of Qe().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=>gt(e,t)<0);s===-1?t.push(e):t.splice(s,0,e)}}return t},vt=(e,t)=>{let n=E(e.text,e.references).document,r=_t(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 E(o,[...f,...a]).document},yt=(e,t)=>vt({text:e,references:[]},t),bt=(e,t)=>yt(e,t),xt=(e,t,n=`
2
-
3
- `)=>{let r=E(e.text,e.references).document,i=E(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 E(`${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},St=e=>({state:`unbound-legacy`,sessionID:e}),O=e=>e.state===`bound`?`bound:${JSON.stringify([e.transportIdentity,m(e.directory),e.sessionID,e.deliveryTarget??{kind:`primary`}])}`:`unbound-legacy:${JSON.stringify([e.sessionID])}`,Ct=(e,t)=>e.queuedMessages[O(t)]??wt,wt=[],Tt=3e4,Et=`queue`,Dt=e=>e===`steer`||e===`queue`,Ot=(e,t)=>e===`immediate`?`steer`:Dt(e)?e:t===!1?`steer`:`queue`,kt=[],At=(e,t)=>e.pendingAdmissions[O(t)]??kt,jt=e=>`${e}-${De()}`,Mt=e=>typeof e==`object`&&!!e&&Object.getPrototypeOf(e)===Object.prototype,Nt=(e,t,n=[])=>{if(!Mt(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&&ht(i,`queue-canonical`);if(!a||!a.ok||a.text!==t)return;let o=new Set(n.map(e=>e.id));return et(i).every(e=>o.has(e.attachmentRefID))?i:void 0},Pt=(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},Ft=(e,t)=>{let n=Mt(e)&&typeof e.content==`string`?e:t,r=Nt(n.composerDocument,n.content,Array.isArray(n.attachments)?n.attachments:[]),i=Pt(n.composerMentions,r);return{content:n.content,...r?{composerDocument:r}:{},...r&&i?.length?{composerMentions:i}:{},...Array.isArray(n.attachments)?{attachments:n.attachments}:{},...Mt(n.sendConfig)?{sendConfig:n.sendConfig}:{}}},It=e=>Ft(void 0,e),Lt=(e,t)=>e.queueItemID===t.queueItemID&&e.operationID===t.operationID&&(!t.messageID||e.messageID===t.messageID),k=e=>e.status===`sending`||e.status===`reconciling`,Rt=ie(),zt=()=>Rt?.flush()??!0,Bt=`quiescing`,Vt=new Set,Ht=new Set,Ut=e=>{if(Bt!==e){Bt=e;for(let e of Ht)e()}},Wt=e=>{if(!(!e||Vt.has(e))){Vt.add(e);for(let e of Ht)e()}},Gt=e=>e.state===`bound`&&Vt.has(e.transportIdentity),A=e=>Bt===`open`&&(!e||!Gt(e)),Kt=(e,t=Date.now())=>({reconciliationStartedAt:e.reconciliationStartedAt??t,reconciliationDeadlineAt:e.reconciliationDeadlineAt??(e.reconciliationStartedAt??t)+Tt,reconciliationChecks:Math.max(0,Math.floor(e.reconciliationChecks??0))}),qt=(e,t,n)=>{let r=t.queueItemID??(t.id||jt(`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:ae(`msg`),s=Nt(t.composerDocument,t.content,t.attachments),c=Pt(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??jt(`operation`),messageID:o,owner:n,status:a,attemptCount:Math.max(0,Math.floor(t.attemptCount??0)),...t.status===`sending`||t.status===`reconciling`?Kt(t):{},...i||a===`reconciling`&&t.status===`sending`?{failure:{kind:`ambiguous-dispatch`,recovery:Ft(t.failure?.recovery,t)}}:{}}},Jt=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:St(n?.owner?.sessionID??i)}else t=St(e);for(let e of r){let r=e.owner?.state===`bound`?e.owner:t,i=O(r);(n[i]??=[]).push(qt(r.sessionID,e,r))}}return{queuedMessages:n,followUpBehavior:Ot(t.followUpBehavior,t.queueModeEnabled??null)}},j=(e,t,n,r)=>{if(Gt(t))return;let i=O(t);e(e=>{let t=e.queuedMessages[i],a=t?.findIndex(e=>O(e.owner)===i&&Lt(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}}})},Yt=g()(te(ee((e,t)=>({queuedMessages:{},followUpBehavior:Et,pendingAdmissions:{},addToQueue:(t,n)=>{if(!A(t))return{ok:!1,reason:`invalid-composer-document`};let r=Nt(n.composerDocument,n.content,n.attachments);if(n.composerDocument!==void 0&&!r)return{ok:!1,reason:`invalid-composer-document`};let i=Pt(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:jt(`queued`),queueItemID:``,operationID:jt(`operation`),messageID:ae(`msg`),createdAt:Date.now(),owner:t,status:`queued`,attemptCount:0};a.queueItemID=a.id;let o=O(t);return e(e=>({queuedMessages:{...e.queuedMessages,[o]:[...e.queuedMessages[o]??[],a]}})),{ok:!0,item:a}},removeFromQueue:(n,r,i)=>{if(!A(n)||!i)return!1;let a=O(n),o=t().queuedMessages[a];if(!o||o.length===0)return!0;let s=o.find(e=>(e.queueItemID===r||e.id===r)&&O(e.owner)===a);if(s&&s.operationID!==i)return!1;let c=o.find(e=>(e.queueItemID===r||e.id===r)&&e.operationID===i&&O(e.owner)===a);return!c||!k(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}}),!Ct(t(),n).some(e=>e===c||(e.queueItemID===r||e.id===r)&&e.operationID===i))},reorderQueue:(t,n,r,i)=>{if(!A(t)||!i)return;let a=O(t);e(e=>{let t=e.queuedMessages[a],o=t?.findIndex(e=>(e.id===n||e.queueItemID===n)&&e.operationID===i&&O(e.owner)===a)??-1,s=t?.findIndex(e=>(e.id===r||e.queueItemID===r)&&O(e.owner)===a)??-1;if(!t||o<0||s<0||o===s||k(t[o])||k(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(!A(e)||!r)return null;let i=Ct(t(),e).find(t=>(t.id===n||t.queueItemID===n)&&t.operationID===r&&O(t.owner)===O(e));return!i||k(i)||!t().removeFromQueue(e,i.queueItemID,i.operationID)?null:i},clearQueue:n=>{if(!A(n))return!1;let r=O(n),i=t().queuedMessages[r],a=(t().pendingAdmissions[r]??[]).length>0;return(!i||i.length===0)&&!a||!i?.some(k)&&(e(e=>{if(e.queuedMessages[r]?.some(k))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:()=>{A()&&e(e=>{let t={},n=!1;for(let[r,i]of Object.entries(e.queuedMessages)){if(i[0]&&Gt(i[0].owner)){t[r]=i;continue}let e=i.filter(k);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=>{A()&&(e({followUpBehavior:t}),V({followUpBehavior:t}))},getQueueForScope:e=>Ct(t(),e),getPendingAdmissionsForScope:e=>At(t(),e),stageAdmission:(t,n)=>{if(!A(t)||!n.requestID||!n.queueItemID||!n.operationID||!n.messageID||typeof n.content!=`string`)return;let r=Nt(n.composerDocument,n.content);if(n.composerDocument!==void 0&&!r)return;let i=Pt(n.composerMentions,r);if(n.composerMentions!==void 0&&!i)return;let a=O(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=O(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(!A(n)||!r.requestID||!r.sendConfig?.providerID||!r.sendConfig?.modelID)return{ok:!1,reason:`invalid-composer-document`};let i=O(n),a=(t().pendingAdmissions[i]??[]).find(e=>e.requestID===r.requestID);if(!a)return{ok:!1,reason:`invalid-composer-document`};let o=Nt(a.composerDocument,a.content,r.attachments);if(a.composerDocument!==void 0&&!o)return{ok:!1,reason:`invalid-composer-document`};let s=Pt(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(!A(t)||!A(n)||t.state!==`unbound-legacy`||n.state!==`bound`||t.sessionID!==n.sessionID)return[];let r=O(t),i=O(n),a=[];return e(e=>{let t=e.queuedMessages[r];if(!t||(a=t.filter(e=>!k(e)),a.length===0))return e;let o=t.filter(k),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)=>{A(t)&&j(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)=>j(e,t,n,e=>e.status===`sending`?{...e,status:`retrying`,nextAttemptAt:r,failure:{kind:`pre-dispatch`,recovery:i?.recovery??It(e)}}:e),markQueueItemReconciling:(t,n,r)=>j(e,t,n,e=>e.status===`sending`?{...e,status:`reconciling`,nextAttemptAt:void 0,...Kt(e),reconciliationNextCheckAt:void 0,failure:{kind:`ambiguous-dispatch`,recovery:r?.recovery??It(e)}}:e),recordQueueItemReconciliationCheck:(t,n)=>j(e,t,n,e=>e.status===`reconciling`&&Lt(e,n)?{...e,reconciliationChecks:(e.reconciliationChecks??0)+1,reconciliationNextCheckAt:Date.now()+2e3}:e),resolveQueueItemReconciliation:(t,n)=>j(e,t,n,e=>e.status===`reconciling`&&Lt(e,n)?{...e,status:`unresolved`,nextAttemptAt:void 0}:e),markQueueItemDefinitiveFailure:(t,n,r)=>j(e,t,n,e=>e.status===`sending`?{...e,status:`failed`,nextAttemptAt:void 0,failure:{kind:`definitive`,recovery:r?.recovery??It(e)}}:e),resetQueueItemForDispatch:(t,n)=>{A(t)&&j(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(!A(t)||!r.startsWith(`msg_`))return null;let o=O(t),s=null;return e(e=>{let t=e.queuedMessages[o],c=i?t?.findIndex(e=>O(e.owner)===o&&Lt(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||O(l.owner)!==o||!Lt(l,n)||!u||t?.some(k))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(Gt(t))return;let r=O(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:Rt,partialize:e=>({queuedMessages:e.queuedMessages,followUpBehavior:e.followUpBehavior}),migrate:Jt,merge:(e,t)=>({...t,...Jt(e),pendingAdmissions:t.pendingAdmissions})}),{name:`message-queue-store`})),Xt=(e,t)=>{let n=Yt.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?(Yt.setState(e=>{let t={...e.queuedMessages};for(let e of r){let n=O(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}},Zt=xe(),Qt=e(ne(),1),$t=`directoryTreeShowHidden`,en=`directory-show-hidden-change`,tn=()=>{if(typeof window>`u`)return!0;try{let e=_().getItem($t);return e===null||e===`true`}catch{return!0}},nn=()=>{typeof window>`u`||window.dispatchEvent(new Event(en))},rn=(e,t={})=>{if(!(typeof window>`u`)){try{_().setItem($t,e?`true`:`false`),nn()}catch{}t.persist!==!1&&V({directoryShowHidden:e})}},an=()=>{let e=(0,Zt.c)(2),[t,n]=Qt.useState(tn),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{if(typeof window>`u`)return;let e=()=>{n(tn())};return window.addEventListener(`storage`,e),window.addEventListener(en,e),()=>{window.removeEventListener(`storage`,e),window.removeEventListener(en,e)}},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),Qt.useEffect(r,i),t},on=`filesViewShowGitignored`,sn=`files-view-show-gitignored-change`,cn=()=>{if(typeof window>`u`)return!1;try{return _().getItem(on)===`true`}catch{return!1}},ln=()=>{typeof window>`u`||window.dispatchEvent(new Event(sn))},un=(e,t={})=>{if(!(typeof window>`u`)){try{_().setItem(on,e?`true`:`false`),ln()}catch{}t.persist!==!1&&V({filesViewShowGitignored:e})}},dn=()=>{let e=(0,Zt.c)(2),[t,n]=Qt.useState(cn),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{if(typeof window>`u`)return;let e=()=>{n(cn())};return window.addEventListener(`storage`,e),window.addEventListener(sn,e),()=>{window.removeEventListener(`storage`,e),window.removeEventListener(sn,e)}},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),Qt.useEffect(r,i),t},fn=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},pn=e=>{if(!e||typeof e!=`object`)return null;let t=e;return{showReasoningTraces:t.showReasoningTraces,collapsibleThinkingBlocks:t.collapsibleThinkingBlocks}},mn=e=>{let t=S.getState();typeof e.showReasoningTraces==`boolean`&&t.setShowReasoningTraces(e.showReasoningTraces),typeof e.collapsibleThinkingBlocks==`boolean`&&t.setCollapsibleThinkingBlocks(e.collapsibleThinkingBlocks)},hn=async()=>{if(typeof window>`u`)return null;let e=localStorage.getItem(`appearance-preferences`);if(!e)return null;try{return fn(pn(JSON.parse(e)))}catch(e){return console.warn(`Failed to parse stored appearance preferences:`,e),null}},gn=[{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`}],_n=new Map(gn.map(e=>[e.name,e])),vn=e=>_n.get(e),yn=[{type:`command`,name:`explore`},{type:`command`,name:`catch-up`},{type:`command`,name:`weigh`},{type:`command`,name:`debug`},{type:`command`,name:`review`}],bn=`terminal-box`,xn=`book-open`,Sn=e=>`${e.type}:${e.name}`,Cn=(e,t)=>e.type===t.type&&e.name===t.name,wn=e=>{let t=e.replace(/^\//,``).replace(/[-_]+/g,` `).replace(/\s+/g,` `).trim();return t?t.charAt(0).toUpperCase()+t.slice(1):e},Tn=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},En=`yuri.rt.`,Dn=e=>{try{return btoa(unescape(encodeURIComponent(e))).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/g,``)}catch{return encodeURIComponent(e)}},M=(e,t=o())=>`${En}${Dn(t.trim().length>0?t.trim():`default`)}.${e}`,On=(e,t,n=o())=>e?e===M(t,n):!1,kn=()=>{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},An=(e,t)=>{let n=t?.storage??(typeof localStorage<`u`?localStorage:{getItem:()=>null}),r=t?.transport??o(),i=n.getItem(M(e,r));return i===null?kn()?n.getItem(e):null:i},N=(e,t,n)=>{let r=n?.storage??(typeof localStorage<`u`?localStorage:{setItem:()=>void 0}),i=n?.transport??o();r.setItem(M(e,i),t)},jn=e=>{let t;try{t=re()}catch{return}let n=t=>t===null?null:JSON.parse(t,e?.reviver),r=e=>t.getItem(e);return{getItem:e=>{let t=M(e,o()),i=r(t);if(i instanceof Promise)return i.then(t=>{if(t!==null)return n(t);if(!kn())return null;let i=r(e);return i instanceof Promise?i.then(n):n(i)});if(i!==null)return n(i);if(!kn())return null;let a=r(e);return a instanceof Promise?a.then(n):n(a)},setItem:(n,r)=>{let i=M(n,o());t.setItem(i,JSON.stringify(r,e?.replacer))},removeItem:e=>{let n=M(e,o());t.removeItem(n)}}},Mn=512,Nn=4096,Pn=64,Fn=2e5,In=[`concise`,`detailed`,`mentor`,`pushback`,`noFiller`,`matchEnergy`,`warmPeer`,`custom`],Ln=[`defaultModel`,`defaultVariant`,`defaultAgent`,`autoCreateWorktree`,`gitmojiEnabled`,`defaultFileViewerPreview`,`zenModel`,`messageStreamTransport`,`sttProvider`,`sttServerUrl`,`sttModel`,`sttLocalModel`,`sttLanguage`,`responseStyleEnabled`,`responseStylePreset`,`responseStyleCustomInstructions`],Rn=e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getPrototypeOf(e)===Object.prototype,P=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),zn=(e,t)=>{if(typeof e!=`string`)return;let n=e.trim();return n.length<=t?n:void 0},Bn=e=>{let t=zn(e,Nn);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}},Vn=(e,t)=>typeof e==`string`&&t.includes(e)?e:void 0,Hn=e=>typeof e==`boolean`?e:void 0,Un=(e,t)=>{let n=e[t];switch(t){case`autoCreateWorktree`:case`gitmojiEnabled`:case`defaultFileViewerPreview`:case`responseStyleEnabled`:return Hn(n);case`messageStreamTransport`:return Vn(n,[`auto`,`ws`,`sse`]);case`sttProvider`:return Vn(n,[`local`,`openai-compatible`,`volcengine`]);case`sttServerUrl`:return Bn(n);case`sttLanguage`:return zn(n,Pn);case`responseStyleCustomInstructions`:return zn(n,Fn);case`responseStylePreset`:return Vn(n,In);default:return zn(n,Mn)}},Wn=e=>{if(!Rn(e))throw Error(`Invalid settings bootstrap response`);if(!P(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 Ln){if(!P(e,n))continue;let r=Un(e,n);r!==void 0&&Object.assign(t,{[n]:r})}return t},Gn=e=>{if(!Rn(e))throw Error(`Invalid settings bootstrap patch`);for(let t of Object.keys(e))if(!Ln.includes(t))throw Error(`Invalid settings bootstrap patch`);let t=Wn({schemaVersion:1,...e}),n={};for(let r of Ln)if(P(e,r)){if(!P(t,r))throw Error(`Invalid settings bootstrap patch`);Object.assign(n,{[r]:t[r]})}return n},Kn=e=>{if(!Rn(e))return{};let t={};for(let n of Ln){if(!P(e,n))continue;let r=Un(e,n);r!==void 0&&Object.assign(t,{[n]:r})}return t},qn=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)}},Jn=class extends Error{status;constructor(e){super(`Settings bootstrap request failed (${e})`),this.status=e,this.name=`SettingsBootstrapRequestError`}},Yn=(e=o())=>[e,`settings`,`bootstrap`],Xn=(e=o())=>({queryKey:Yn(e),queryFn:({signal:e})=>qn(e,async e=>{let t=await l(`/api/config/settings/bootstrap`,{method:`GET`,headers:{Accept:`application/json`},signal:e});if(!t.ok)throw new Jn(t.status);return Wn(await t.json())}),retry:(e,t)=>!(t instanceof Jn&&(t.status===404||t.status===501))&&e<1,staleTime:1/0,gcTime:1/0}),Zn=(e=o())=>Se.fetchQuery(Xn(e)),Qn=(e=o())=>Se.getQueryData(Yn(e)),$n=(e,t=o())=>{let n=Gn(e),r=Yn(t),i=Wn({schemaVersion:1,...Se.getQueryData(r),...n});return Se.setQueryData(r,i),i},er=e=>{if(!(typeof window>`u`)&&!(typeof window.__YURI_HOME__==`string`&&window.__YURI_HOME__.length>0))try{window.__YURI_HOME__=e}catch{}},tr=e=>{if(!(typeof window>`u`)){if(e.themeId&&N(`selectedThemeId`,e.themeId),e.themeVariant&&N(`selectedThemeVariant`,e.themeVariant),e.lightThemeId&&N(`lightThemeId`,e.lightThemeId),e.darkThemeId&&N(`darkThemeId`,e.darkThemeId),typeof e.useSystemTheme==`boolean`&&(N(`useSystemTheme`,String(e.useSystemTheme)),N(`themeMode`,e.useSystemTheme?`system`:e.themeVariant===`dark`||e.themeVariant===`light`?e.themeVariant:`system`)),e.lastDirectory&&v(`lastDirectory`,e.lastDirectory),e.homeDirectory&&(v(`homeDirectory`,e.homeDirectory),er(e.homeDirectory)),Array.isArray(e.projects)&&e.projects.length>0?v(`projects`,JSON.stringify(e.projects)):oe(`projects`),e.activeProjectId?v(`activeProjectId`,e.activeProjectId):oe(`activeProjectId`),Array.isArray(e.pinnedDirectories)&&e.pinnedDirectories.length>0?v(`pinnedDirectories`,JSON.stringify(e.pinnedDirectories)):oe(`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?v(`yuri.sessions.projectCollapse`,JSON.stringify(t)):oe(`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`)}}},nr=e=>{typeof window>`u`||window.dispatchEvent(new CustomEvent(`yuri:settings-synced`,{detail:e}))},rr=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},ir=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},ar=(e,t)=>{let n=Object.entries(e),r=Object.entries(t);return n.length===r.length&&n.every(([e,n])=>t[e]===n)},or=(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),sr=(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})},cr=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),lr=e=>{if(Array.isArray(e))return Array.from(new Set(e.filter(e=>typeof e==`string`&&e.length>0)))},ur=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=lr(r);e&&e.length>0&&(t[n]=e.slice(0,5))}return Object.keys(t).length>0?t:void 0},dr=(e,t)=>{let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>Array.isArray(t[n])&&cr(e[n],t[n]))},fr=/^#(?:[\da-fA-F]{3}|[\da-fA-F]{6})$/,pr=e=>{if(typeof e!=`string`)return null;let t=e.trim();return t&&fr.test(t)?t.toLowerCase():null},mr=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=pr(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},hr=(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},gr=()=>{let e=S.persist;if(e&&typeof e==`object`)return e},_r=()=>h()?.settings??null,vr=(e,t,n)=>{let r={...Kn(t),...Kn(e)};if(Object.keys(r).length!==0)try{$n(r,n)}catch(e){console.warn(`Failed to patch settings bootstrap cache:`,e)}},yr=e=>{let t=S.getState(),n=typeof window<`u`?window.__zustand_config_store__?.getState?.()??null:null,r=Yt.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(Dt(e.followUpBehavior)?i=e.followUpBehavior:typeof e.queueModeEnabled==`boolean`&&(i=Ot(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),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=Tn(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&&!ar(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=sr(n,e.favoriteModels);or(n,r)||S.setState({favoriteModels:r})}if(Array.isArray(e.hiddenModels)){let n=t.hiddenModels,r=e.hiddenModels;or(n,r)||S.setState({hiddenModels:r})}if(Array.isArray(e.collapsedModelProviders)){let n=t.collapsedModelProviders,r=e.collapsedModelProviders;cr(n,r)||S.setState({collapsedModelProviders:r})}if(Array.isArray(e.recentModels)){let n=t.recentModels,r=sr(n,e.recentModels);or(n,r)||S.setState({recentModels:r})}if(Array.isArray(e.recentAgents)){let n=t.recentAgents,r=e.recentAgents;cr(n,r)||S.setState({recentAgents:r})}if(e.recentEfforts&&typeof e.recentEfforts==`object`){let n=t.recentEfforts,r=e.recentEfforts;dr(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`&&rn(e.directoryShowHidden,{persist:!1}),typeof e.filesViewShowGitignored==`boolean`&&un(e.filesViewShowGitignored,{persist:!1})},br=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=mr(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=Tn(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),Dt(t.followUpBehavior)?n.followUpBehavior=t.followUpBehavior:typeof t.queueModeEnabled==`boolean`&&(n.followUpBehavior=Ot(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),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=ir(t.shortcutOverrides);i&&(n.shortcutOverrides=i),typeof t.mobileKeyboardMode==`string`&&(t.mobileKeyboardMode===`native`||t.mobileKeyboardMode===`resize-content`)&&(n.mobileKeyboardMode=t.mobileKeyboardMode);let a=hr(t.favoriteModels,64,{preserveVariant:!0});a&&(n.favoriteModels=a);let o=hr(t.hiddenModels,1024);o&&(n.hiddenModels=o);let s=lr(t.collapsedModelProviders);s&&(n.collapsedModelProviders=s);let c=hr(t.recentModels,16,{preserveVariant:!0});c&&(n.recentModels=c);let l=lr(t.recentAgents);l&&(n.recentAgents=l);let u=ur(t.recentEfforts);if(u&&(n.recentEfforts=u),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 d=rr(t.skillCatalogs);return d&&(n.skillCatalogs=d),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},F=new Map,xr=new Map,Sr=2e3,Cr=async e=>{let t=F.get(e);if(t&&Date.now()-t.at<Sr)return t.value;let n=xr.get(e);if(n)return n;let r=(async()=>{if(o()!==e)return null;let t=_r();if(t)try{let n=br((await t.load()).settings);return F.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=br(await t.json().catch(()=>null));return F.set(e,{value:n,at:Date.now()}),n}catch(e){return console.warn(`Failed to load shared settings from server:`,e),null}})();xr.set(e,r);try{return await r}finally{xr.get(e)===r&&xr.delete(e)}},wr=(e=o())=>{F.delete(e)},Tr=async()=>{if(typeof window>`u`)return;let e=o(),t=gr(),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{tr(t)}catch(e){console.warn(`persistToLocalStorage failed:`,e)}try{yr(t)}catch(e){console.warn(`applyDesktopUiPreferences failed:`,e)}nr(t)}};try{let t=await Cr(e);t&&o()===e&&await r(t)}catch(e){console.warn(`Failed to synchronise settings:`,e)}},I=null,L=null,R=null,z=[],Er=200,B=new Map,Dr=async e=>{for(;B.get(e)?.size;)await Promise.all([...B.get(e)])},Or=async()=>{let e=I,t=L,n=z;if(I=null,L=null,R=null,z=[],!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=_r();if(i){try{let a=await i.save(e);vr(a,e,t),a&&r()&&(tr(a),yr(a),nr(a),F.set(t,{value:br(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);vr(i,e,t),i&&r()&&(tr(i),yr(i),nr(i),F.set(t,{value:br(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(L&&L!==t){R&&=(clearTimeout(R),null),I=null,L=null;let e=z;z=[],e.forEach(e=>e())}let n={...I??{}},r=F.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(I=n,L=t,Object.keys(n).length===0&&!R){I=null,L=null;return}R&&clearTimeout(R);let i=new Promise(e=>{z.push(e)}),a=B.get(t)??new Set;B.set(t,a),a.add(i),R=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=gr();try{let t=await hn();if(!t)return;let n=()=>mn(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()(te((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=y.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=_(),Zr=b(`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=b(`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=b(`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,v(`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`&&v(`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 y.getFilesystemHome());if(t)return t}catch(e){console.warn(`Failed to obtain filesystem home directory:`,e)}try{let t=e((await y.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&&y.setDirectory(ui);var di=!!(li&&li!==`/`),fi=g()(te((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||b(`homeDirectory`,{storage:U}));Ir(),Oe(t().currentDirectory,i)&&(y.setDirectory(i),$r(),e(e=>{let t=[...e.directoryHistory.slice(0,e.historyIndex+1),i];return v(`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];y.setDirectory(r),$r(),v(`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];y.setDirectory(r),$r(),v(`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=b(`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;y.setDirectory(e),$r(),v(`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&&(y.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,Ai=new Map,ji=new Map,J=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,Y=e=>e.trim(),Hi=``,X=e=>{let t=`${s()}\u0000${o()}`;return t!==Hi&&(Hi=t,q.clear(),Ai.clear(),ji.clear(),J.clear(),Mi.clear()),`${t}\u0000${Y(e)}`},Ui=(e,t)=>t===`light`?`${Y(e)}::light`:Y(e),Wi=e=>Ei.get(Y(e))??0,Z=e=>{let t=Y(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(X(e))??0,Q=e=>{let t=X(e);t&&(Mi.set(t,Gi(e)+1),ji.delete(t),J.delete(t))};function $(e,t,n){let r={...n};return t&&(r.directory=t),a().api(e,r)}var Ki=(e,t,n)=>{let r=Y(e);if(!r)return;let i=Date.now()+_i;Oi.set(r,{value:t,expiresAt:i}),typeof n==`string`&&n?q.set(X(e),{value:{root:n},expiresAt:i}):q.delete(X(e))};async function qi(e){let t=Array.from(new Set(e.map(e=>Y(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=Oi.get(e),r=q.get(X(e));if(t&&t.expiresAt>i&&r&&r.expiresAt>i){n.set(e,{isGitRepository:t.value,primaryRoot:r.value.root});continue}o.push(e)}if(o.length===0)return n;let c=e=>{for(let t of e){let e=typeof t.directory==`string`?Y(t.directory):``;if(!e)continue;let i=!!t.isGitRepository,a=typeof t.primaryRoot==`string`&&t.primaryRoot?t.primaryRoot:null;r===s()&&Ki(e,i,a),n.set(e,{isGitRepository:i,primaryRoot:a})}},u=async e=>{await Promise.all(e.map(async e=>{try{let[t,i]=await Promise.all([Ji(e),Xi(e).then(e=>e.root).catch(()=>e)]);r===s()&&Ki(e,t,t?i:null),n.set(e,{isGitRepository:t,primaryRoot:t?i:null})}catch{r===s()&&Ki(e,!1,null),n.set(e,{isGitRepository:!1,primaryRoot:null})}}))};try{await Ri(async()=>{let e=new URLSearchParams;for(let t of o)e.append(`directories`,t);let t=a().api(`${G}/discover`),n=e.toString(),r=n?t.includes(`?`)?`${t}&${n}`:`${t}?${n}`:t,i=await l(r);if(i.status===501||!i.ok)throw Error(`Batch git discover unavailable: ${i.status} ${i.statusText}`);let s=await i.json().catch(()=>null),u=Array.isArray(s)?s:[];if(u.length===0&&o.length>0)throw Error(`Batch git discover returned empty payload`);c(u)})}catch{}let d=o.filter(e=>!n.has(e));return d.length>0&&await u(d),n}async function Ji(e){let t=Y(e),n=Date.now(),r=Oi.get(t);if(r&&r.expiresAt>n)return r.value;let i=ki.get(t);if(i)return i;let a=(async()=>{let n=await l($(`${G}/check`,e));if(!n.ok)throw Error(`Failed to check git repository: ${n.statusText}`);let r=!!(await n.json()).isGitRepository;return Oi.set(t,{value:r,expiresAt:Date.now()+hi}),r})();ki.set(t,a);try{return await a}finally{ki.get(t)===a&&ki.delete(t)}}async function Yi(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 Xi(e){let t=X(e),n=s(),r=Date.now(),i=q.get(t);if(i&&i.expiresAt>r)return i.value;let a=Ai.get(t);if(a)return a;let o=Ri(async()=>{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()&&q.set(t,{value:a,expiresAt:Date.now()+_i}),a});Ai.set(t,o);try{return await o}finally{Ai.get(t)===o&&Ai.delete(t)}}async function Zi(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 Qi(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 $i(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 ea(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 ta(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`)}Z(e)}async function na(e,t){await ra(e,[t])}async function ra(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`)}Z(e)}async function ia(e,t){await aa(e,[t])}async function aa(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`)}Z(e)}async function oa(e,t,n){await la(e,t,n,`stage`)}async function sa(e,t,n){await la(e,t,n,`unstage`)}async function ca(e,t,n){await la(e,t,n,`discard`)}async function la(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`)}Z(e)}async function ua(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 da(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 fa(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 pa(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 ma(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 ha(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 ga(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 _a(e){let t=X(e),n=s(),r=Date.now(),i=ji.get(t);if(i&&i.expiresAt>r)return i.value;let a=J.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});J.set(t,c);try{return await c}finally{J.get(t)===c&&J.delete(t)}}Bi(_a);async function va(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 ya(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 ba(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 xa=e=>typeof e==`string`&&e.length>0,Sa=e=>{if(!e||typeof e!=`object`)return null;let t=e;if(!xa(t.name)||!xa(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},Ca=(e,t,n)=>{if(e!==503||!t||typeof t!=`object`)return null;let r=t;if(r.code!==yi)return null;let i=Sa(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},wa=(e,t,n,r)=>`${e}\u0000${t}\u0000${n}\u0000${r}`,Ta=e=>new Promise(t=>{setTimeout(t,e)}),Ea=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},Da=e=>e===400||e===401||e===403||e===501,Oa=(e,t)=>{let n=o(),r=s(),i=wa(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 Ta(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||Da(n.status))return;if(await Ea(n)){r+=1;continue}return}catch{r+=1}finally{clearTimeout(s)}}})().catch(()=>{}).finally(()=>{Ni.delete(i)})};async function ka(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=Sa(r);if(t)return Q(e),t;if(r&&typeof r==`object`)return Q(e),r;throw Error(`Failed to create worktree`)}let i=Ca(n.status,r,e);if(i)return Q(e),Oa(e,i.path),i;let a=r&&typeof r==`object`?r:{error:n.statusText};throw Error(a.error||`Failed to create worktree`)}async function Aa(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 Q(e),r}async function ja(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 Z(e),i}async function Ma(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 Z(e),r}async function Na(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 Z(e),r}async function Pa(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 Z(e),r}async function Fa(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 Ia(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 La(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 Ra=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()},za=(e,t)=>Ra(e,`stash/apply`,t),Ba=(e,t)=>Ra(e,`stash/pop`,t),Va=(e,t)=>Ra(e,`stash/drop`,t);async function Ha(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 Ua(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 Wa(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 Ga(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 Ka(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 qa(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 Ja(){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 Ya(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 Xa(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 Za(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 Qa(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 $a(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 eo(){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 to(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 no(){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 ro(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 io(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 ao(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 oo(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 so(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 co(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 lo(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 uo(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 fo(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 po(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 mo(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 ho(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 go(e,t){return await La(e,{message:t?.message}),{success:!0}}async function _o(e){return await Ba(e,{ref:`stash@{0}`}),{success:!0}}async function vo(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 yo(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 bo(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{ma as $,vn as $t,Qi as A,nt as An,Jr as At,Pa as B,Xn as Bt,ha as C,mt as Cn,Gr as Ct,vo as D,E as Dn,Ir as Dt,Ka as E,ht as En,Ur as Et,Yi as F,V as Ft,Vi as G,kn as Gt,Ma as H,Kn as Ht,ya as I,Dr as It,_a as J,N as Jt,ua as K,An as Kt,eo as L,Zn as Lt,ea as M,ke as Mn,kr as Mt,Ja as N,wr as Nt,Qa as O,qe as On,qr as Ot,Ga as P,Tr as Pt,ao as Q,xn as Qt,ro as R,$n as Rt,Va as S,xt as Sn,fi as St,qa as T,pt as Tn,Wr as Tt,$a as U,jn as Ut,Na as V,qn as Vt,Q as W,On as Wt,Ba as X,bn as Xt,so as Y,gn as Yt,ba as Z,yn as Zt,Za as _,dt as _n,Xa as _t,Ji as a,dn as an,ta as at,no as b,yt as bn,Ri as bt,lo as c,At as cn,na as ct,Ia as d,Wt as dn,go as dt,wn as en,Wa as et,Ua as f,Xt as fn,La as ft,fa as g,ot as gn,sa as gt,ka as h,Yt as hn,aa as ht,bo as i,un as in,uo as it,$i as j,Ae as jn,Fr as jt,da as k,et as kn,Yr as kt,ho as l,Ct as ln,ra as lt,Ya as m,Ut as mn,ia as mt,oo as n,Tn as nn,Xi as nt,Ha as o,an as on,ca as ot,ja as p,O as pn,_o as pt,Fa as q,M as qt,za as r,Sn as rn,Zi as rt,co as s,zt as sn,to as st,po as t,Cn as tn,fo as tt,mo as u,St as un,oa as ut,Aa as v,ct as vn,va as vt,ga as w,ut as wn,Kr as wt,qi as x,bt as xn,pi as xt,pa as y,vt as yn,yo as yt,io as z,Qn as zt};
@@ -1 +0,0 @@
1
- import{i as e,n as t}from"./runtime-switch-DEPKHgdL.js";import{n}from"./runtime-fetch-V-iMWR8t.js";import{n as r}from"./vendor-react-D5BntRmA.js";import{s as i}from"./vendor-tanstack-react-query-ChSd65dm.js";import{q as a}from"./runtime-file-resource-CKQQEwNv.js";var o=r(),s=[{id:`claude`,name:`Claude Code`},{id:`codex`,name:`Codex`},{id:`cursor`,name:`Cursor`},{id:`dsh`,name:`DeepSeek Harness`},{id:`opencode`,name:`OpenCode`}],c=e=>e.progress??{phase:`importing`,completed:e.completed,total:e.total},l=e=>e?.state===`completed`||e?.state===`partial`,u=async(r,i,a,o)=>{let s=t();if(o!==e())throw Error(`runtime_changed`);let c=await n(`/api/yuri/history-import/${r}`,{...i===void 0?{}:{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(i)},signal:a});if(!c.ok){let e=await c.json().catch(()=>({}));throw Error(c.status===404||c.status===501?`history_import_unsupported`:e.code??`import_failed`)}let l=await c.json();if(o!==e()||s!==t())throw Error(`runtime_changed`);return l},d=(t=e())=>({queryKey:[t,`history-import`,`job`],queryFn:({signal:e})=>u(`job`,void 0,e,t),staleTime:0,retry:1,refetchInterval:e=>e.state.data?.state===`running`&&1e3}),f=e=>{let t=(0,o.c)(3),n=e===void 0||e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=d(),t[0]=r):r=t[0];let a;return t[1]===n?a=t[2]:(a={...r,enabled:n},t[1]=n,t[2]=a),i(a)},p=(t=e())=>({queryKey:[t,`history-import`,`jobs`],queryFn:({signal:e})=>u(`jobs`,void 0,e,t),staleTime:0,retry:!1});function m(e,t){a.setQueryData(d(t).queryKey,e),a.setQueryData(p(t).queryKey,t=>l(e)?t?.filter(t=>t.id!==e.id):t?.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t??[],e])}var h=(e,t,n)=>u(`scan`,e,t,n),g=(t=e())=>({queryKey:[t,`history-import`,`sources`,`sample`,5,`counts`],queryFn:({signal:e})=>h({sources:s.map(e=>e.id),limitPerSource:5,includeCounts:!0},e,t),staleTime:6e4,gcTime:3e5,retry:!1,refetchOnWindowFocus:!1}),_=e=>{let t=(0,o.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=g(),t[0]=n):n=t[0];let r;return t[1]===e?r=t[2]:(r={...n,enabled:e},t[1]=e,t[2]=r),i(r)},v=(t,n,r,i=e())=>({queryKey:[i,`history-import`,`imported`,t,n,r],queryFn:({signal:e})=>u(`imported`,{scanID:t,directory:n},e,i),staleTime:6e4,gcTime:3e5,retry:!1,refetchOnWindowFocus:!1}),y=(e,t,n,r)=>{let a=(0,o.c)(7),s;a[0]!==t||a[1]!==n||a[2]!==e?(s=v(e,t,n),a[0]=t,a[1]=n,a[2]=e,a[3]=s):s=a[3];let c=!!e&&r,l;return a[4]!==s||a[5]!==c?(l={...s,enabled:c},a[4]=s,a[5]=c,a[6]=l):l=a[6],i(l)};async function b(e,n,r,i,a){if(a!==t())throw Error(`runtime_changed`);let o=await u(`start`,{sources:e,directory:n,confirm:!0},r,i);if(a!==t())throw Error(`runtime_changed`);return m(o,i),o}var x=(e,t,n)=>u(`cancel`,{id:e},t,n);async function S(e,n,r){if(r!==t())throw Error(`runtime_changed`);let i=await u(`resume`,{id:e,confirm:!0},new AbortController().signal,n);if(r!==t())throw Error(`runtime_changed`);return m(i,n),i}async function C(e,n,r){if(r!==t())throw Error(`runtime_changed`);let i=await u(`dismiss`,{id:e},new AbortController().signal,n);if(await Promise.all([a.cancelQueries({queryKey:p(n).queryKey,exact:!0}),a.cancelQueries({queryKey:d(n).queryKey,exact:!0})]),r!==t())throw Error(`runtime_changed`);return a.setQueryData(p(n).queryKey,e=>e?.filter(e=>e.id!==i.id)),a.setQueryData(d(n).queryKey,e=>e?.id===i.id?null:e),i}export{b as a,y as c,l as d,S as i,s as l,C as n,f as o,p as r,_ as s,x as t,c as u};
@@ -1 +0,0 @@
1
- import"./rolldown-runtime-hePW80VL.js";import{ot as e,st as t}from"./vendor-base-ui-fom6orB6.js";import{n}from"./vendor-react-D5BntRmA.js";import{Rn as r}from"./useMobileNavigationStore-BtHQN423.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 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,i as n}from"./runtime-switch-DEPKHgdL.js";import{R as r,l as i,u as a}from"./platform-CiUKDeXd.js";import{a as o,i as s,r as c}from"./vendor-zustand-CNn3HHhT.js";import{ot as l,st as u}from"./vendor-base-ui-fom6orB6.js";import{St as d,an as f,jt as p,on as m}from"./gitApiHttp-BgUDBfaJ.js";import{t as h}from"./safeStorage-DTOhKN0V.js";import{i as g,t as _}from"./vendor-pathe-vBmvQE8f.js";import{n as v}from"./vendor-react-D5BntRmA.js";import{s as y,u as b}from"./vendor-tanstack-react-query-ChSd65dm.js";import{E as x}from"./runtime-file-resource-CKQQEwNv.js";import{o as S}from"./path-utils-jGozTg9d.js";import{r as C}from"./vendor-reactuses-core-B8s-Rcd-.js";import{r as w}from"./useUIStore-DjizmHAt.js";import{t as T}from"./i18n-BvjeIWrT.js";import{Ca as E,Gn as D,Ha as O,Ia as k,Jn as A,R as ee,Rn as j,Va as te,Xn as M,Zi as N,fa as ne,fi as P,lt as re,p as F,v as I,x as L,yi as ie,yt as ae}from"./useMobileNavigationStore-BtHQN423.js";import{s as oe}from"./remoteProjectQueries-yX3kOkR6.js";import{a as se,g as ce,o as le,p as ue,s as de}from"./fileMentionAutocompleteState-BZJqfgae.js";import{t as fe}from"./AgentAvatar-DmvbnnMh.js";import{n as R}from"./Icon-Br-W35tz.js";import{l as pe,s as me}from"./gitApi-BA93t0ww.js";import{c as he,d as ge,l as _e,n as ve,r as ye,t as be}from"./fileMentionTouchSelection-C0O4_Efn.js";import{n as xe}from"./textarea-DvCd0eUo.js";import{f as Se,o as Ce}from"./projectMeta-CBxwAjHm.js";var z=(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=ce([...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)},B=(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}),V=(e,t)=>e.highlightedIndex===t.highlightedIndex&&B(e.rows,t.rows),we=(e,t)=>B(e,t)?e:t.slice(),Te=(e,t,n)=>{e&&(t.current&&V(t.current,n)||(t.current=n,e(n)))},Ee=(e,t)=>{t.current=null,e?.({rows:[],highlightedIndex:0})},H=e(u(),1),U=v(),De=e=>e.directories.flatMap(e=>e.sessions),Oe=(e,t)=>({...oe(e,t.location.hostId),select:De}),ke=async(e,t,n)=>{n.sdk();let r=await e.fetchQuery(Oe(t,n));return n.sdk(),De(r)},Ae=(e,t,n,r)=>{n.sdk();let i=e.getQueryData(Oe(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},je=(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=g(t.path),r=_(n);return{name:r,path:S(e.location.directory,n),relativePath:n,extension:r.includes(`.`)?r.split(`.`).pop()?.toLowerCase():void 0,isDirectory:t.type===`directory`}})}}),W=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},G=e=>/^[A-Za-z]:\//.test(e)?e.toLowerCase():e,K=e=>e.startsWith(`yuri-remote-location:`)?i(e):W(e),q=(e,t)=>{let n=W(a(t,`local`).directory),r=W(e);if(!n||!r)return!1;let i=G(n),o=G(r);return o===i||o.startsWith(i.endsWith(`/`)?i:`${i}/`)},Me=e=>{if(!e||typeof e!=`object`)return{};let t=e,n={};for(let[e,r]of Object.entries(t)){let t;try{t=K(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=>W(e)).filter(e=>q(e,t)))):[],o=Array.isArray(i.expandedPaths)?Array.from(new Set(i.expandedPaths.filter(e=>typeof e==`string`).map(e=>W(e)).filter(e=>q(e,t)))):[],s=typeof i.selectedPath==`string`?W(i.selectedPath):null,c=s&&q(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},J=(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},Y=e=>e?{...e,touchedAt:Date.now()}:{openPaths:[],selectedPath:null,expandedPaths:[],touchedAt:Date.now()},Ne=o()(c(s((e,t)=>({byRoot:{},addOpenPath:(t,n,r)=>{let i=K((t||``).trim()),a=W((n||``).trim());!i||!a||!r?.allowOutsideRoot&&!q(a,i)||e(e=>{let t=e.byRoot[i],n=Y(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:J({...e.byRoot,[i]:{...n,openPaths:o,selectedPath:s}},20)}})},removeOpenPath:(t,n)=>{let r=K((t||``).trim()),i=W((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=G(i),a=e=>G(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:J({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeOpenPathsByPrefix:(t,n)=>{let r=K((t||``).trim()),i=W((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=G(i),a=n.endsWith(`/`)?n:`${n}/`,o=e=>{let t=G(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:J({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeExpandedPathsByPrefix:(t,n)=>{let r=K((t||``).trim()),i=W((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=G(i),a=n.endsWith(`/`)?n:`${n}/`,o=t.expandedPaths.filter(e=>{let t=G(e);return t!==n&&!t.startsWith(a)});return o.length===t.expandedPaths.length?e:{byRoot:J({...e.byRoot,[r]:{...t,expandedPaths:o,touchedAt:Date.now()}},20)}})},setSelectedPath:(t,n,r)=>{let i=K((t||``).trim()),a=n?W(n.trim()):null;!i||a&&!r?.allowOutsideRoot&&!q(a,i)||e(e=>{let t=e.byRoot[i],n=Y(t),r=a&&!n.openPaths.includes(a)?[...n.openPaths,a]:n.openPaths;return t&&t.selectedPath===a&&r===t.openPaths?e:{byRoot:J({...e.byRoot,[i]:{...n,openPaths:r,selectedPath:a}},20)}})},ensureSelectedPath:e=>{let n=K((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=K((t||``).trim()),i=W((n||``).trim());!r||!i||!q(i,r)||e(e=>{let t=e.byRoot[r],n=Y(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:J({...e.byRoot,[r]:{...n,expandedPaths:a}},20)}})},expandPath:(t,n)=>{let r=K((t||``).trim()),i=W((n||``).trim());!r||!i||!q(i,r)||e(e=>{let t=e.byRoot[r],n=Y(t);return n.expandedPaths.includes(i)&&t?e:{byRoot:J({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,i]}},20)}})},expandPaths:(t,n)=>{let r=K((t||``).trim());if(!r||!n||n.length===0)return;let i=n.map(e=>W((e||``).trim())).filter(e=>e&&q(e,r));i.length!==0&&e(e=>{let t=e.byRoot[r],n=Y(t),a=new Set(n.expandedPaths),o=i.filter(e=>!a.has(e));return o.length===0?e:{byRoot:J({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,...o]}},20)}})}}),{name:`files-view-tabs-store`,version:2,storage:h(),migrate:e=>{if(!e||typeof e!=`object`)return{byRoot:{}};let t=e.byRoot;return{byRoot:Me(t)}},merge:(e,t)=>({...t,byRoot:Me(e&&typeof e==`object`?e.byRoot:void 0)}),partialize:e=>({byRoot:Me(e.byRoot)})}),{name:`files-view-tabs-store`})),Pe=(e,t)=>{let n=(0,U.c)(4),r=t===void 0?200:t,[i,a]=H.useState(e),o,s;return n[0]!==r||n[1]!==e?(o=()=>{let t=window.setTimeout(()=>{a(e)},r);return()=>{window.clearTimeout(t)}},s=[e,r],n[0]=r,n[1]=e,n[2]=o,n[3]=s):(o=n[2],s=n[3]),H.useEffect(o,s),i},Fe=()=>{let e=(0,U.c)(17),t=F(Ie),n=ae(),r;e[0]===t?r=e[1]:(r=e=>t?e.getAttachment(t):void 0,e[0]=t,e[1]=r);let i=L(r),a=F(Le),o=F(Re),s=O(ze),c=O(Be),l=d(Ve);if(t){let r;e[2]===i?r=e[3]:(r=I(i),e[2]=i,e[3]=r);let o=r;if(o)return o;let s;e[4]!==t||e[5]!==a?(s=a.get(t),e[4]=t,e[5]=a,e[6]=s):s=e[6];let c=s;if(c?.path)return c.path;let l;if(e[7]!==t||e[8]!==n){let r;e[10]===t?r=e[11]:(r=e=>e.id===t,e[10]=t,e[11]=r),l=n.find(r),e[7]=t,e[8]=n,e[9]=l}else l=e[9];let u=l;if(u?.directory)return u.directory}if(o?.open&&(o.bootstrapPendingDirectory||o.directoryOverride))return(o.bootstrapPendingDirectory||o.directoryOverride)??void 0;if(s){let t;if(e[12]!==s||e[13]!==c){let n;e[15]===s?n=e[16]:(n=e=>e.id===s,e[15]=s,e[16]=n),t=c.find(n),e[12]=s,e[13]=c,e[14]=t}else t=e[14];let n=t;if(n?.path)return n.path}return l??void 0};function Ie(e){return e.currentSessionId}function Le(e){return e.worktreeMetadata}function Re(e){return e.newSessionDraft}function ze(e){return e.activeProjectId}function Be(e){return e.projects}function Ve(e){return e.currentDirectory}var X=l(),He=`bg-transparent font-[inherit] text-[var(--primary-base)]`,Ue=(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,X.jsx)(`mark`,{className:He,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},We=H.forwardRef((e,t)=>{let n=(0,U.c)(4),r=x(),i;return n[0]!==r||n[1]!==e||n[2]!==t?(i=r?.entry.location.hostId?(0,X.jsx)(Je,{...e,ref:t,entry:r.entry,registry:r.registry},JSON.stringify(r.entry.queryScope)):(0,X.jsx)(Ge,{...e,ref:t}),n[0]=r,n[1]=e,n[2]=t,n[3]=i):i=n[3],i}),Ge=H.forwardRef((e,t)=>{let n=(0,U.c)(22),r=Fe()??``,i=F(Xe),a=ie(Ze),o=!!e.onSessionSelect,s;n[0]===o?s=n[1]:(s={enabled:o},n[0]=o,n[1]=s);let c=ee(s),l=O(Qe),u=O($e),d;if(n[2]!==l||n[3]!==r||n[4]!==u){let e=u.find(e=>e.id===l)?.path||r;d=e?e.replace(/\\/g,`/`).replace(/\/+$/,``):null,n[2]=l,n[3]=r,n[4]=u,n[5]=d}else d=n[5];let f=d,m;n[6]===f?m=n[7]:(m=e=>f?e.byRoot[f]:void 0,n[6]=f,n[7]=m);let h=Ne(m),g=N(et),_=p(tt),v;n[8]!==a||n[9]!==c||n[10]!==e.onSessionSelect?(v=e.onSessionSelect?P(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]!==f||n[15]!==h||n[16]!==e||n[17]!==t||n[18]!==_||n[19]!==y||n[20]!==b?(x=(0,X.jsx)(Ye,{...e,ref:t,currentDirectory:r,currentSessionId:b,projectRoot:f,projectTabs:h,agentCatalog:g,sessions:y,searchFiles:_}),n[12]=g,n[13]=r,n[14]=f,n[15]=h,n[16]=e,n[17]=t,n[18]=_,n[19]=y,n[20]=b,n[21]=x):x=n[21],x}),Ke=[],qe=[],Je=H.forwardRef((e,t)=>{let n=(0,U.c)(32),{entry:r,registry:i}=e,a=b(),o;n[0]===r?o=n[1]:(o=k(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=y(c),u;n[5]!==r||n[6]!==i?(u=Oe(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=y(f),m;n[11]===r.key?m=n[12]:(m=e=>e.byRoot[r.key],n[11]=r.key,n[12]=m);let h=Ne(m),g;n[13]!==a||n[14]!==r?(g=(e,t,n,i)=>{let o=n===void 0?60:n;return a.fetchQuery(je(r,t,o,i))},n[13]=a,n[14]=r,n[15]=g):g=n[15];let _=C(g),v=r.location.directory,x;if(n[16]!==r.location.directory){let e;n[18]===Symbol.for(`react.memo_cache_sentinel`)?(e=/\/+$/,n[18]=e):e=n[18],x=r.location.directory.replace(/\\/g,`/`).replace(e,``),n[16]=r.location.directory,n[17]=x}else x=n[17];let S=l.data??qe,w=p.data??Ke,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]!==_||n[26]!==S||n[27]!==w||n[28]!==T||n[29]!==E||n[30]!==x?(D=(0,X.jsx)(Ye,{...e,ref:t,currentDirectory:v,projectRoot:x,projectTabs:h,agentCatalog:S,sessions:w,searchFiles:_,catalogError:T,assertCurrent:E}),n[21]=r.location.directory,n[22]=h,n[23]=e,n[24]=t,n[25]=_,n[26]=S,n[27]=w,n[28]=T,n[29]=E,n[30]=x,n[31]=D):D=n[31],D}),Ye=H.forwardRef(({searchQuery:e,onFileSelect:t,onAgentSelect:n,onSkillSelect:r,onSessionSelect:i,onClose:a,style:o,onRowsChange:s,currentDirectory:c,currentSessionId:l,projectRoot:u,projectTabs:d,agentCatalog:p,sessions:h,searchFiles:g,catalogError:_,assertCurrent:v},y)=>{let{t:b}=T(),x=Pe(e,180),S=m(),O=f(),[k,A]=H.useState([]),[ee,te]=H.useState(!1),[M,N]=H.useState(null),[P,re]=H.useState(0),F=H.useRef(0),I=H.useRef({query:e,directory:c,ids:[]}),[L,ie]=H.useState(360),[ae,oe]=H.useState({}),[ce,pe]=H.useState({}),me=H.useRef([]),ge=H.useRef([]),_e=H.useRef([]),Se=H.useRef(null),Ce=H.useRef(null),z=H.useRef(null);z.current||=be();let B=w(e=>e.isMobile),V=(e??``).trim(),we=E({directory:c||null}),U=H.useMemo(()=>r?we.data??[]:[],[r,we.data]),De=H.useMemo(()=>{if(!u||!d)return[];let e=[d.selectedPath,...d.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(`${u}/`)?e.slice(u.length+1):e;n.push({name:i,path:e,relativePath:a,extension:i.includes(`.`)?i.split(`.`).pop()?.toLowerCase():void 0})}return de(n,V,{limit:6})},[V,u,d]),Oe=H.useMemo(()=>n?ne(p).filter(e=>e.mode!==`primary`):[],[p,n]),ke=H.useMemo(()=>i?se({sessions:h,currentSessionId:l??null,searchQuery:V}):[],[h,l,V,i]),Ae=De,je=k,W=H.useMemo(()=>he({skills:U,agents:Oe,sessions:ke,recentFiles:Ae,pathHits:je,searchQuery:V,untitledSession:b(`chat.fileMentionAutocomplete.untitledSession`),sessionBadge:b(`chat.fileMentionAutocomplete.sessionType`),skillBadge:b(`chat.commandAutocomplete.badge.skill`)}),[U,Oe,ke,Ae,je,V,b]);H.useEffect(()=>{let e=e=>{let t=e.target;!t||!Se.current||Se.current.contains(t)||a()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[a]),H.useEffect(()=>{if(!c){A([]),te(!1),N(null);return}let e=(x??``).trim(),t=ue(e);if(!t){A([]),te(!1),N(null);return}let n=!1;te(!0),N(null);let r={includeHidden:S,respectGitignore:!O};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(De.map(e=>e.path));A(le({files:t,directories:r,query:e,excludePaths:i,limit:20}))}).catch(e=>{n||N(e instanceof Error?e:Error(String(e)))}).finally(()=>{n||te(!1)}),()=>{n=!0}},[c,x,De,g,S,O]),H.useLayoutEffect(()=>{let t=I.current,n=t.ids[F.current],r=t.query===e&&t.directory===c?Math.max(0,W.findIndex(e=>e.id===n)):0;I.current={query:e,directory:c,ids:W.map(e=>e.id)},F.current=r,re(r)},[W,e,c]),H.useEffect(()=>{oe({}),pe({})},[W]),H.useEffect(()=>{me.current[P]?.scrollIntoView({block:`nearest`})},[P]),H.useEffect(()=>{let e=null,t=()=>{e!==null&&cancelAnimationFrame(e),e=requestAnimationFrame(()=>{let e={},t={};ge.current.forEach((n,r)=>{if(!n)return;let i=_e.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}}),oe(e),pe(t)})};return t(),window.addEventListener(`resize`,t),()=>{e!==null&&cancelAnimationFrame(e),window.removeEventListener(`resize`,t)}},[W]),H.useEffect(()=>{let e=ge.current[P];if(!e)return;let t=()=>{let t=e.clientWidth;t>0&&ie(t)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>{n.disconnect()}},[P]);let G=C(e=>{t(e)}),K=C(e=>{n?.(e)}),q=C(e=>{i?.(e)}),Me=C(e=>{r?.(e)}),J=(e,t)=>({onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&z.current?.pointerDown(e.clientX,e.clientY)},onPointerMove:e=>{e.pointerType===`touch`&&z.current?.pointerMove(e.clientX,e.clientY)},onPointerUp:e=>{e.pointerType===`touch`&&(z.current?.pointerUp(t)??!1)&&(e.preventDefault(),e.stopPropagation())},onPointerCancel:()=>z.current?.pointerCancel(),onClick:()=>{z.current?.click(t)},onMouseMove:()=>{F.current=e,re(e)}}),Y=e=>{try{v?.()}catch(e){N(e instanceof Error?e:Error(String(e)));return}let t=W.length;if(t===0)return;let n=(e%t+t)%t,r=W[n];if(r.agentName!==void 0){K(r.agentName);return}if(r.id.startsWith(`skill:`)){let e=U.find(e=>r.id===`skill:${e.name}-${e.scope}`);e&&Me(e);return}if(r.id.startsWith(`session:`)){let e=ke.find(e=>r.id===`session:${e.id}`);e&&q(e);return}let i=r.id.startsWith(`recent:`)?Ae.find(e=>r.id===`recent:${e.path}`):je.find(e=>r.id===`file:${e.path}`);i&&G(i)};H.useEffect(()=>{Te(s,Ce,{rows:W,highlightedIndex:P})},[s,P,W]);let Ne=H.useRef(s);return Ne.current=s,H.useEffect(()=>()=>{Ee(Ne.current,Ce)},[]),H.useImperativeHandle(y,()=>({acceptIndex:e=>{Y(e)},handleKeyDown:e=>{if(e===`Escape`){a();return}let t=W.length;if(t!==0){if(e===`ArrowDown`){F.current=(F.current+1)%t,re(F.current);return}if(e===`ArrowUp`){F.current=(F.current-1+t)%t,re(F.current);return}(e===`Enter`||e===`Tab`)&&Y(F.current)}}})),(0,X.jsxs)(ve,{ref:Se,isMobile:B,className:`max-w-[640px] max-h-64`,style:o,children:[(0,X.jsx)(xe,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0`,children:(0,X.jsxs)(`div`,{className:`py-1`,children:[_||we.error||M?(0,X.jsx)(`div`,{role:`alert`,className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:(_??we.error??M)?.message}):null,W.map((e,t)=>{let n=e.id.startsWith(`file:`)||e.id.startsWith(`recent:`),r=n?D(e.title,{maxLength:60}):e.title,i=P===t,a=ae[t]??!1,o=ce[t]??2.6;return(0,X.jsxs)(`div`,{"data-mention-id":e.id,ref:e=>{me.current[t]=e},className:j(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,B&&`min-h-11`,ye(B,i),!B&&i&&`text-interactive-selection-foreground`),...J(t,()=>Y(t)),children:[(0,X.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center`,children:e.agentName===void 0?(0,X.jsx)(R,{name:e.iconName,className:`size-3.5 text-current`}):(0,X.jsx)(fe,{name:e.agentName,size:20})}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,X.jsxs)(`span`,{ref:e=>{ge.current[t]=e},className:j(`relative block min-w-0 overflow-hidden`,n&&a&&i&&`file-mention-marquee-container`),style:i?{"--file-mention-marquee-width":`${L}px`,"--file-mention-marquee-duration":`${o}s`}:void 0,title:e.title,children:[(0,X.jsx)(`span`,{ref:e=>{_e.current[t]=e},className:`absolute invisible whitespace-nowrap pointer-events-none`,"aria-hidden":!0,children:e.title}),n&&a&&i?(0,X.jsx)(`span`,{className:`inline-block whitespace-nowrap file-mention-marquee`,children:Ue(e.title,V)}):(0,X.jsx)(`span`,{className:`block truncate`,children:Ue(r,V)})]}),e.trailingLabel?(0,X.jsx)(`span`,{className:j(`max-w-[40%] shrink-0 truncate text-muted-foreground`,B?`typography-micro`:`typography-meta`),children:e.trailingLabel}):null]}),e.subtitle?(0,X.jsx)(`div`,{className:j(`truncate text-muted-foreground`,B?`typography-micro`:`typography-meta`),children:Ue(e.subtitle,V)}):null]})]},e.id)}),ee&&je.length===0?(0,X.jsx)(`div`,{className:`flex items-center justify-center py-3`,children:(0,X.jsx)(R,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):null,!ee&&W.length===0&&(0,X.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:b(`chat.fileMentionAutocomplete.empty`)})]})}),!B&&(0,X.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:b(`chat.autocomplete.keyboardHint`)})]})});function Xe(e){return e.currentSessionId}function Ze(e){return e.activeSessions}function Qe(e){return e.activeProjectId}function $e(e){return e.projects}function et(e){return e.agents}function tt(e){return e.searchFiles}var nt=new Set([`new`,`fork`,`compact`,`reload`,`undo`,`redo`,`model`,`btw`]),rt=(e,t)=>{if(!t||e.isSkill)return!1;let n=e.name?.trim().toLowerCase();return!!(n&&nt.has(n))},it=(e,t)=>!e||t({name:e}),at=` `,ot=(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]===at&&e[r-2]===`/`&&(r-=2),e[r]===`/`?{start:r,end:n}:null},st=`text-[10px] leading-none uppercase font-bold tracking-tight px-1.5 py-1 rounded border flex-shrink-0`,ct=j(st,`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)]`),lt=j(st,`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)]`),ut=j(st,`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)]`),dt=j(st,`bg-[var(--surface-muted)] text-muted-foreground border-[var(--interactive-border)]/60`),ft=(e,t)=>e.length===t.length&&e.every((e,n)=>e.id===t[n]?.id&&e.description===t[n]?.description),pt=e=>{let t=!!e.sessionID;return{hasSession:t,canStartSessionCommand:t||e.hasNewDraft}},mt=H.forwardRef(({searchQuery:e,onCommandSelect:t,onClose:n,directory:i,style:a,commandPolicy:o,commandContext:s,onRowsChange:c},l)=>{let{t:u}=T(),d=w(e=>e.isMobile),f=F(e=>e.currentSessionId),p=F(e=>!!e.newSessionDraft?.open),m=F(H.useCallback(e=>f?e.getDirectoryForSession(f):void 0,[f])),h=re(f??``,m??void 0),g=H.useMemo(()=>s??{sessionID:f??null,hasMessages:h.length>0,hasNewDraft:p},[s,f,h.length,p]),{hasSession:_,canStartSessionCommand:v}=H.useMemo(()=>pt(g),[g]),y=g.hasMessages,[b,x]=H.useState([]),[S,C]=H.useState(!1),E=te({directory:i}),D=H.useMemo(()=>E.data??[],[E.data]),O=E.isFetching,[k,A]=H.useState(0),ee=H.useRef(0),M=H.useRef(!1),N=H.useRef([]),ne=H.useRef(null),P=H.useRef(!1),I=H.useRef(null),L=H.useRef(!1),ie=H.useRef(null);H.useEffect(()=>{let e=e=>{let t=e.target;!t||!ne.current||ne.current.contains(t)||n()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[n]),H.useEffect(()=>{(async()=>{C(O);try{let t=D.flatMap((e,t)=>e.source===`skill`?[]:[{id:`opencode:${e.scope??`global`}:${e.name}:${e.agent??``}:${e.model??``}:${t}`,name:e.name,source:`opencode`,description:e.description,agent:e.agent??void 0,model:e.model??void 0,isBuiltIn:e.isBuiltIn,scope:e.scope,reference:e.reference}]),n=[{id:`yuri:new`,name:`new`,source:`yuri`,description:u(`chat.commandAutocomplete.command.newDescription`),isBuiltIn:!0},..._&&!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},...r()?[{id:`yuri:reload`,name:`reload`,source:`yuri`,description:u(`chat.commandAutocomplete.command.reloadDescription`),isBuiltIn:!0}]:[],..._?[{id:`yuri:summary`,name:`summary`,source:`yuri`,description:u(`chat.commandAutocomplete.command.summaryDescription`),isYuri:!0}]:[],...v?[{id:`yuri:workspace-review`,name:`workspace-review`,source:`yuri`,description:u(`chat.commandAutocomplete.command.workspaceReviewDescription`),isYuri:!0}]:[],...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}]:[],...t],i=!y,a=z(n.filter(e=>(i||e.name!==`init`)&&(o?.(e)??!0)),e);x(e=>ft(e,a)?e:a)}catch{let t=!y,n=z([{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},...r()?[{id:`yuri:reload`,name:`reload`,source:`yuri`,description:u(`chat.commandAutocomplete.command.reloadDescription`),isBuiltIn:!0}]:[],..._?[{id:`yuri:summary`,name:`summary`,source:`yuri`,description:u(`chat.commandAutocomplete.command.summaryDescription`),isYuri:!0}]:[],...v?[{id:`yuri:workspace-review`,name:`workspace-review`,source:`yuri`,description:u(`chat.commandAutocomplete.command.workspaceReviewDescription`),isYuri:!0}]:[],...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=>(t||e.name!==`init`)&&(o?.(e)??!0)),e);x(e=>ft(e,n)?e:n)}finally{C(!1)}})()},[e,y,_,v,D,O,u,o]),H.useEffect(()=>{A(0)},[b]),H.useEffect(()=>{ee.current=k},[k]),H.useEffect(()=>{N.current[k]?.scrollIntoView({block:`nearest`})},[k]),H.useEffect(()=>{Te(c,ie,{rows:_e(b,{skill:u(`chat.commandAutocomplete.badge.skill`),command:u(`chat.commandAutocomplete.badge.command`),system:u(`chat.commandAutocomplete.badge.system`)}),highlightedIndex:k})},[b,c,k,u]);let ae=H.useRef(c);ae.current=c,H.useEffect(()=>()=>{Ee(ae.current,ie)},[]),H.useImperativeHandle(l,()=>({acceptIndex:(e,n=!0)=>{let r=b[e];r&&t(r,rt(r,n))},handleKeyDown:e=>{let r=b.length;if(e===`Escape`){n();return}if(r!==0){if(e===`ArrowDown`){M.current=!0,A(e=>(e+1)%r);return}if(e===`ArrowUp`){M.current=!0,A(e=>(e-1+r)%r);return}if(e===`Enter`||e===`Tab`){let n=(ee.current%r+r)%r,i=b[n];i&&t(i,rt(i,e===`Enter`))}}}}),[b,n,t]);let oe=e=>{let t=ge(e);switch(e.name){case`new`:return(0,X.jsx)(R,{name:t,className:`h-3.5 w-3.5`});case`init`:return(0,X.jsx)(R,{name:t,className:`h-3.5 w-3.5 text-green-500`});case`undo`:return(0,X.jsx)(R,{name:t,className:`h-3.5 w-3.5 text-orange-500`});case`redo`:return(0,X.jsx)(R,{name:t,className:`h-3.5 w-3.5 text-orange-500`});case`timeline`:case`reload`:return(0,X.jsx)(R,{name:t,className:`h-3.5 w-3.5`});case`compact`:return(0,X.jsx)(R,{name:t,className:`h-3.5 w-3.5 text-purple-500`});case`goal`:return(0,X.jsx)(R,{name:t,className:`h-3.5 w-3.5`});case`review`:return(0,X.jsx)(R,{name:t,className:`h-3.5 w-3.5 text-blue-500`});case`test`:case`build`:case`run`:return(0,X.jsx)(R,{name:t,className:`h-3.5 w-3.5 text-cyan-500`});default:return e.isBuiltIn?(0,X.jsx)(R,{name:t,className:`h-3.5 w-3.5 text-yellow-500`}):(0,X.jsx)(R,{name:t,className:`h-3.5 w-3.5 text-muted-foreground`})}};return(0,X.jsxs)(ve,{ref:ne,isMobile:d,className:`max-w-[450px] max-h-64`,style:a,children:[(0,X.jsx)(xe,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0 py-1.5`,children:S?(0,X.jsx)(`div`,{className:`flex items-center justify-center py-4`,children:(0,X.jsx)(R,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):(0,X.jsxs)(`div`,{children:[b.map((n,r)=>{let i=n.isBuiltIn,a=n.isYuri;return(0,X.jsxs)(`div`,{ref:e=>{N.current[r]=e},className:j(`flex gap-2 px-2 py-2 cursor-pointer rounded-lg`,d?`items-center`:`items-start`,ye(d,r===k),!d&&r===k&&`bg-interactive-selection/35`),onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&(I.current={x:e.clientX,y:e.clientY},L.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&&(L.current=!0)},onPointerUp:e=>{if(e.pointerType!==`touch`)return;let r=L.current;I.current=null,L.current=!1,!r&&(e.preventDefault(),e.stopPropagation(),P.current=!0,t(n,rt(n,d)))},onPointerCancel:()=>{I.current=null,L.current=!1},onClick:()=>{if(P.current){P.current=!1;return}t(n,rt(n,d))},onMouseMove:()=>{M.current=!1,A(r)},children:[(0,X.jsx)(`div`,{className:j(!d&&`mt-0.5`),children:oe(n)}),(0,X.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsxs)(`span`,{className:`typography-ui-label font-medium`,children:[`/`,Ue(n.name,e)]}),n.isSkill?(0,X.jsx)(`span`,{className:ct,children:u(`chat.commandAutocomplete.badge.skill`)}):(0,X.jsx)(`span`,{className:ct,children:u(`chat.commandAutocomplete.badge.command`)}),a?(0,X.jsx)(`span`,{className:dt,children:`Yuri`}):i?(0,X.jsx)(`span`,{className:dt,children:u(`chat.commandAutocomplete.badge.system`)}):n.scope?(0,X.jsx)(`span`,{className:n.scope===`project`?ut:lt,children:n.scope}):null,n.agent&&(0,X.jsx)(`span`,{className:dt,children:n.agent})]}),n.description&&!d&&(0,X.jsx)(`div`,{className:`typography-meta text-muted-foreground mt-0.5 truncate`,children:Ue(n.description,e)})]})]},n.id)}),b.length===0&&(0,X.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:u(`chat.commandAutocomplete.empty`)})]})}),!d&&(0,X.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:u(`chat.autocomplete.keyboardHint`)})]})});mt.displayName=`CommandAutocomplete`;var ht=e=>e instanceof Error?e.name===`AbortError`||e.name===`CancelledError`||e.name===`Error`&&e.message===`CancelledError`:!1,gt=1e4,_t=6e4,vt=5e3,yt=3e4,bt=6e4,xt=25,St=40,Ct=2,wt=15e3,Tt=500,Et=30,Dt=20971520,Ot=new Map,kt=new Map,At=new Map,jt=new Map,Mt=new Map,Nt=new Map,Pt=new WeakMap,Ft=e=>{let t=Pt.get(e);return t||(t=new Set(e.files.map(e=>e.path)),Pt.set(e,t)),t},It=(e,t)=>`${t}:${e}`,Lt=e=>kt.get(e)??0,Rt=e=>{let t=Lt(e)+1;return kt.set(e,t),t},zt=e=>{let t=(At.get(e)??0)+1;return At.set(e,t),t},Bt=e=>{let t=Ot.get(e);if(t)return t;let n=new Set;return Ot.set(e,n),n},Z=()=>({isGitRepo:null,status:null,branches:null,branchesTransportIdentity:null,log:null,identity:null,diffCache:new Map,indexRevision:0,lastRepoCheckAt:0,lastStatusFetch:0,lastStatusChange:0,lastLogFetch:0,lastBranchesFetch:0,lastIdentityFetch:0,logMaxCount:25,isLoadingStatus:!1,isLoadingLog:!1,isLoadingBranches:!1,isLoadingIdentity:!1}),Vt=(e,t=Et,n=Dt)=>{let r=0;for(let t of e.values())r+=(t.original?.length??0)+(t.modified?.length??0);if(e.size<=t&&r<=n)return e;let i=Array.from(e.entries()).sort((e,t)=>e[1].fetchedAt-t[1].fetchedAt),a=new Map,o=0;for(let e=i.length-1;e>=0;e--){let[r,s]=i[e],c=(s.original?.length??0)+(s.modified?.length??0);if(a.size>=t)break;o+c>n&&a.size>0||(a.set(r,s),o+=c)}return a},Ht=(e,t)=>!e&&!t?!1:!e||!t||e.remote!==t.remote||e.branch!==t.branch||e.ahead!==t.ahead||e.behind!==t.behind,Ut=e=>{let t=e?.trim()??``;return t===`?`?``:t},Wt=(e,t)=>{let n=new Set,r=!1,i=!e;e&&(i=e.ahead!==t.ahead||e.behind!==t.behind||e.current!==t.current||e.tracking!==t.tracking||e.isClean!==t.isClean||t.upstreamComparison!==void 0&&Ht(e.upstreamComparison,t.upstreamComparison)||t.diffStats!==void 0&&e.diffStats===void 0);let a=new Map;for(let t of e?.files??[])a.set(t.path,t);for(let e of t.files??[]){let t=a.get(e.path);if(!t){n.add(e.path),Ut(e.index)&&(r=!0);continue}a.delete(e.path),(t.index!==e.index||t.working_dir!==e.working_dir)&&n.add(e.path),!r&&Ut(t.index)!==Ut(e.index)&&(r=!0)}for(let[e,t]of a)n.add(e),Ut(t.index)&&(r=!0);let o=t.diffStats,s=e?.diffStats;if(o!==void 0&&o!==s){let e=s??{};for(let t in o){let r=o[t],i=e[t];(!i||i.insertions!==r.insertions||i.deletions!==r.deletions)&&n.add(t)}for(let t in e)t in o||n.add(t)}return{changed:i||n.size>0,changedPaths:n,indexChanged:r}},Gt=e=>!e||e.trim().length===0,Kt=e=>(e||``).trim()===`U`,qt=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(Kt(t)||Kt(n))return e;let r=t===`?`||n===`?`?`A`:t||n||` `;return{...e,index:r,working_dir:` `}},Jt=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(Kt(t)||Kt(n))return e;let r=n||(t===`A`||t===`?`?`?`:t)||` `;return{...e,index:` `,working_dir:r}},Yt=e=>Gt(e.index)&&Gt(e.working_dir),Q=o()(c((e,t)=>({directories:new Map,activeDirectory:null,setActiveDirectory:n=>{let{activeDirectory:r,directories:i}=t();if(r!==n)if(r&&Rt(r),n&&Rt(n),n&&!i.has(n)){let t=new Map(i);t.set(n,Z()),e({activeDirectory:n,directories:t})}else e({activeDirectory:n})},getDirectoryState:e=>t().directories.get(e)??null,fetchStatus:async(n,r,i={})=>{let a=i.mode??`full`,o=It(n,a),s=jt.get(o)??(a===`light`?jt.get(It(n,`full`)):void 0);if(s)return s;let c=(async()=>{let{silent:a=!1}=i,{directories:o}=t(),s=o.get(n);if(s||=Z(),!a){let r=new Map(t().directories),i=r.get(n)??Z();r.set(n,{...i,isLoadingStatus:!0}),e({directories:r})}let c=!1;try{let a=Date.now(),o=s.isGitRepo!==!0||a-(s.lastRepoCheckAt||0)>_t,l=s.isGitRepo===!0;if(o&&(l=await r.checkIsGitRepository(n)),!l){let r=new Map(t().directories),i=r.get(n)??s;return r.set(n,{...i,isGitRepo:!1,status:null,isLoadingStatus:!1,lastRepoCheckAt:a,lastStatusFetch:a}),e({directories:r}),!1}let u=await r.getGitStatus(n,i.mode?{mode:i.mode}:void 0),d=t().directories.get(n)??Z(),f=Nt.get(n),p=f?.received===u&&f.stored===d.status?null:Wt(d.status,u);if(p?.changed){c=!0;let r=new Map(t().directories),i=r.get(n)??Z(),{changedPaths:s,indexChanged:l}=p,d=new Map(i.diffCache);for(let e of s)d.delete(e);let f=s.size>0;f&&Rt(n);let m={...u,diffStats:u.diffStats===void 0&&i.status?.diffStats!==void 0?i.status.diffStats:u.diffStats,upstreamComparison:u.upstreamComparison===void 0?i.status?.upstreamComparison:u.upstreamComparison};r.set(n,{...i,isGitRepo:!0,status:m,diffCache:d,indexRevision:l?i.indexRevision+1:i.indexRevision,lastRepoCheckAt:o?a:i.lastRepoCheckAt,lastStatusFetch:Date.now(),lastStatusChange:f?Date.now():i.lastStatusChange}),e({directories:r}),Nt.set(n,{received:u,stored:m})}else{Nt.set(n,{received:u,stored:d.status});let r=new Map(t().directories),i=r.get(n)??Z();r.set(n,{...i,isGitRepo:!0,lastRepoCheckAt:o?a:i.lastRepoCheckAt,lastStatusFetch:Date.now(),lastStatusChange:i.lastStatusChange}),e({directories:r})}}catch(e){console.error(`Failed to fetch git status:`,e)}finally{if(!a){let r=new Map(t().directories),i=r.get(n)??Z();r.set(n,{...i,isLoadingStatus:!1}),e({directories:r})}}return c})();jt.set(o,c);try{return await c}finally{jt.get(o)===c&&jt.delete(o)}},moveStatusPathsOptimistically:(n,r,i)=>{let a=new Set(r.map(e=>e.trim()).filter(Boolean));if(a.size===0)return null;let{directories:o}=t(),s=o.get(n),c=s?.status??null;if(!s||!c)return c;let l=!1,u=[];for(let e of c.files){if(!a.has(e.path)){u.push(e);continue}let t=i===`stage`?qt(e):Jt(e);t!==e&&(l=!0),Yt(t)?l=!0:u.push(t)}if(!l)return c;let d=new Map(o);return d.set(n,{...s,status:{...c,files:u,isClean:u.length===0},indexRevision:s.indexRevision+1,lastStatusChange:Date.now()}),e({directories:d}),c},restoreStatus:(n,r)=>{let{directories:i}=t(),a=i.get(n);if(!a)return;let o=new Map(i);o.set(n,{...a,status:r,indexRevision:a.indexRevision+1,lastStatusChange:Date.now()}),e({directories:o})},bumpIndexRevision:n=>{let{directories:r}=t(),i=r.get(n);if(!i)return;let a=new Map(r);a.set(n,{...i,indexRevision:i.indexRevision+1}),e({directories:a})},fetchBranches:async(r,i,a={})=>{let o=n(),s=zt(r);{let n=new Map(t().directories),i=n.get(r)??Z();n.set(r,{...i,isLoadingBranches:!0}),e({directories:n})}try{let c=a.force?await M(r,i,void 0,o):await A(r,i,void 0,o);if(s!==At.get(r)||o!==n())return;let l=new Map(t().directories),u=l.get(r)??Z();l.set(r,{...u,branches:c,branchesTransportIdentity:o,isLoadingBranches:!1,lastBranchesFetch:Date.now()}),e({directories:l})}catch(i){if(ht(i)||console.error(`Failed to fetch git branches:`,i),s!==At.get(r)||o!==n())return;let a=new Map(t().directories),c=a.get(r)??Z();a.set(r,{...c,isLoadingBranches:!1}),e({directories:a})}},fetchLog:async(n,r,i)=>{let{directories:a}=t(),o=a.get(n),s=i??o?.logMaxCount??25;{let r=new Map(t().directories),i=r.get(n)??Z();r.set(n,{...i,isLoadingLog:!0}),e({directories:r})}try{let i=await r.getGitLog(n,{maxCount:s}),a=new Map(t().directories),o=a.get(n)??Z();a.set(n,{...o,log:i,isLoadingLog:!1,lastLogFetch:Date.now(),logMaxCount:s}),e({directories:a})}catch(r){console.error(`Failed to fetch git log:`,r);let i=new Map(t().directories),a=i.get(n)??Z();i.set(n,{...a,isLoadingLog:!1}),e({directories:i})}},fetchIdentity:async(n,r)=>{{let r=new Map(t().directories),i=r.get(n)??Z();r.set(n,{...i,isLoadingIdentity:!0}),e({directories:r})}try{let i=await r.getCurrentGitIdentity(n),a=new Map(t().directories),o=a.get(n)??Z();a.set(n,{...o,identity:i,isLoadingIdentity:!1,lastIdentityFetch:Date.now()}),e({directories:a})}catch(r){console.error(`Failed to fetch git identity:`,r);let i=new Map(t().directories),a=i.get(n)??Z();i.set(n,{...a,isLoadingIdentity:!1}),e({directories:i})}},fetchAll:async(n,r,i={})=>{let{directories:a}=t(),o=a.get(n);if(!o){o=Z();let t=new Map(a);t.set(n,o),e({directories:t})}let{force:s=!1,silentIfCached:c=!1}=i,l=Date.now();await t().fetchStatus(n,r,{silent:c&&!!o?.status});let u=t().directories.get(n);if(!u?.isGitRepo)return;await t().fetchBranches(n,r,{force:s});let d=l-(u.lastLogFetch||0);(s||d>gt||!u.log)&&await t().fetchLog(n,r),await t().fetchIdentity(n,r)},getDiff:(e,n)=>t().directories.get(e)?.diffCache.get(n)??null,setDiff:(n,r,i)=>{let a=new Map(t().directories),o=a.get(n)??Z(),s=new Map(o.diffCache);s.set(r,{...i,fetchedAt:Date.now()});let c=Vt(s);a.set(n,{...o,diffCache:c}),e({directories:a})},clearDiffCache:n=>{Rt(n);let r=new Map(t().directories),i=r.get(n);i&&(r.set(n,{...i,diffCache:new Map}),e({directories:r}))},fetchAllDiffs:async(e,n)=>{let r=t().directories.get(e);if(!r?.status?.files||r.status.files.length===0)return;let i=r.status.files.map(e=>e.path).slice(0,xt);await t().prefetchDiffs(e,n,i,{maxFiles:xt})},prefetchDiffs:async(n,r,i,a={})=>{let o=t().directories.get(n);if(!o?.status?.files||o.status.files.length===0||i.length===0)return;let{maxFiles:s=St}=a,c=Math.min(Math.max(1,s),Et),l=Ft(o.status),u=o.status.diffStats,d=Bt(n),f=[],p=new Set;for(let e of i){if(p.size>=c)break;if(!e||p.has(e)||!l.has(e))continue;let t=u?.[e];t&&t.insertions+t.deletions>Tt||(p.add(e),!o.diffCache.has(e)&&(d.has(e)||f.push(e)))}let m=f;if(m.length===0)return;let h=Lt(n);if(typeof document<`u`&&document.hidden)return;m.forEach(e=>d.add(e));let g=0,_=[],v=()=>{let e=g;return g+=1,e<m.length?m[e]:null},y=async e=>{let t=r.getGitFileDiff(n,{path:e}),i=new Promise((e,t)=>{setTimeout(()=>t(Error(`Timed out after ${wt}ms`)),wt)}),a=await Promise.race([t,i]);return{path:e,diff:{original:a.original??``,modified:a.modified??``,isBinary:a.isBinary}}},b=async()=>{for(;;){if(h!==Lt(n))return;let e=v();if(!e)return;try{_.push(await y(e))}catch{}finally{d.delete(e)}}},x=Math.min(Ct,m.length);if(await Promise.allSettled(Array.from({length:x},()=>b())),m.forEach(e=>d.delete(e)),h!==Lt(n))return;let S=new Map(t().directories),C=S.get(n);if(!C)return;let w=new Map(C.diffCache),T=Date.now();_.forEach(e=>{!e.diff.isBinary&&e.diff.original===``&&e.diff.modified===``||w.set(e.path,{...e.diff,fetchedAt:T})});let E=Vt(w);S.set(n,{...C,diffCache:E}),e({directories:S})},setLogMaxCount:(n,r)=>{let i=new Map(t().directories),a=i.get(n)??Z();i.set(n,{...a,logMaxCount:r}),e({directories:i})},ensureStatus:async(e,n)=>{let r=t().directories.get(e),i=Date.now();r?.status&&i-r.lastStatusFetch<vt||await t().fetchStatus(e,n,{silent:!!r?.status})},ensureAll:(e,n)=>{let r=Mt.get(e);if(r)return r;let i=(async()=>{let r=t().directories.get(e),i=Date.now();(!r?.status||r.status.diffStats===void 0||i-(r?.lastStatusFetch??0)>=vt)&&await t().fetchStatus(e,n,{silent:!!r?.status});let a=t().directories.get(e);if(!a?.isGitRepo)return;let o=[];(!a.branches||i-a.lastBranchesFetch>=yt)&&o.push(t().fetchBranches(e,n)),(!a.log||i-a.lastLogFetch>=gt)&&o.push(t().fetchLog(e,n)),(!a.identity||i-a.lastIdentityFetch>=bt)&&o.push(t().fetchIdentity(e,n)),o.length>0&&await Promise.all(o)})();return Mt.set(e,i),i.finally(()=>{Mt.get(e)===i&&Mt.delete(e)}),i},refresh:async(e,n={})=>{let{activeDirectory:r}=t();r&&await t().fetchAll(r,e,n)}}),{name:`git-store`})),Xt=e=>{let t=(0,U.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.status??null:null,t[0]=e,t[1]=n),Q(n)},Zt=e=>{let r=(0,U.c)(3),i=H.useSyncExternalStore(t,n,n),a;return r[0]!==e||r[1]!==i?(a=t=>{if(!e)return null;let n=t.directories.get(e);return n?.branchesTransportIdentity===i?n.branches:null},r[0]=e,r[1]=i,r[2]=a):a=r[2],Q(a)},Qt=e=>{let t=(0,U.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isGitRepo??null:null,t[0]=e,t[1]=n),Q(n)},$t=e=>{let t=(0,U.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.status?.current?.trim()??null:null,t[0]=e,t[1]=n),Q(n)},en=e=>{let t=(0,U.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=new Map,t[0]=n):n=t[0];let r=H.useRef(n),i;return t[1]===e?i=t[2]:(i=t=>{let n=r.current,i=n.size===e.length;if(i)for(let r of e){let e=t.directories.get(r),a=n.get(r);if(!a||(e?.isGitRepo??null)!==a.isGitRepo||(e?.status?.current??null)!==a.branch){i=!1;break}}if(i)return n;let a=new Map;for(let n of e){let e=t.directories.get(n);a.set(n,{isGitRepo:e?.isGitRepo??null,branch:e?.status?.current??null})}return r.current=a,a},t[1]=e,t[2]=i),Q(i)},tn=e=>{let t=(0,U.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isLoadingStatus??!1:!1,t[0]=e,t[1]=n),Q(n)},nn=e=>{let t=(0,U.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isLoadingBranches??!1:!1,t[0]=e,t[1]=n),Q(n)},rn=e=>{let t=String(e||``).trim().replace(/^remotes\//,``);if(!t)return null;let n=t.indexOf(`/`);return n<=0||n>=t.length-1?null:{remote:t.slice(0,n),branch:t.slice(n+1)}},$=e=>String(e||``).trim().replace(/^refs\/heads\//,``).replace(/^heads\//,``).replace(/^remotes\//,``),an=e=>e.branchName?$(e.branchName):e.mode===`existing`?$(e.existingBranch||e.preferredName||``):$(e.preferredName||``),on=async e=>{let t=await Se(e);try{let n=rn((await me(e)).branches?.[t]?.tracking||null);if(n?.remote)return n.remote}catch{}try{let t=rn((await pe(e)).tracking);if(t?.remote)return t.remote}catch{}return null},sn=async(e,t)=>{let n=await on(e),r=$(t);return!n||!r?null:{setUpstream:!0,upstreamRemote:n,upstreamBranch:r}},cn=async(e,t,n)=>{let r=an(t),i=n?.resolvedRootTrackingRemote,a=i===void 0?await sn(e,r):i&&$(r)?{setUpstream:!0,upstreamRemote:i,upstreamBranch:$(r)}:null;return a?{...t,setUpstream:t.setUpstream??a.setUpstream,upstreamRemote:t.upstreamRemote||a.upstreamRemote,upstreamBranch:t.upstreamBranch||a.upstreamBranch}:t},ln=async(e,t,n)=>{let r=await cn(e.path,t,n);return Ce(e,r)},un=`yuri:lastWorktreeSourceBranch`,dn=({mode:e,sourceBranch:t,linkedPr:n,selectedBranch:r})=>e===`existing-branch`?r||null:n?null:t||null,fn=({branches:e,savedSourceBranch:t,rootBranch:n})=>t&&e.includes(t)&&t?{sourceBranch:t,shouldClearSavedSourceBranch:!1}:{sourceBranch:n&&e.includes(n)?n:e.includes(`main`)?`main`:e.includes(`master`)?`master`:e[0]??``,shouldClearSavedSourceBranch:!!t},pn=(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?` `:``}`},mn=(e,t,n)=>{let r=pn(e,t,n);return`${t.length===0&&!/^\s/.test(r)?` `:``}${r}${n.length===0&&!/\s$/.test(r)?` `:``}`},hn=(e,t,n,r)=>{let i=e.slice(0,t),a=e.slice(n),o=mn(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}},gn=(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]},_n=(e,t)=>t<e.length&&e[t]===` `?t+1:t;export{Fe as C,Ae as D,ke as E,we as O,We as S,Ne as T,Q as _,un as a,ot as b,ln as c,$t as d,Zt as f,Xt as g,en as h,mn as i,on as l,tn as m,gn as n,fn as o,nn as p,hn as r,dn as s,_n as t,cn as u,Qt as v,Pe as w,it as x,mt as y};