@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,4 +1,4 @@
1
- import{n as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,n}from"./runtime-switch-DEPKHgdL.js";import{n as r}from"./runtime-fetch-V-iMWR8t.js";import{t as i}from"./runtimeAPIRegistry-C2VogTny.js";import{$ as a,A as o,B as s,D as c,E as l,F as u,G as d,H as f,I as p,J as m,K as ee,L as te,M as ne,N as re,O as ie,P as ae,Q as oe,R as se,S as ce,T as le,U as ue,V as de,W as h,X as fe,Y as pe,Z as me,_ as he,_t as ge,a as _e,at as ve,b as ye,bt as be,c as xe,ct as Se,d as Ce,dt as we,et as Te,f as Ee,ft as De,g as Oe,gt as ke,h as Ae,ht as je,i as Me,it as Ne,j as g,k as Pe,l as Fe,lt as Ie,m as Le,mt as Re,n as ze,nt as Be,o as Ve,ot as He,p as Ue,pt as We,q as Ge,r as Ke,rt as qe,s as Je,st as Ye,t as Xe,tt as Ze,u as Qe,ut as $e,v as et,vt as tt,x as nt,y as rt,yt as it,z as at}from"./gitApiHttp-BgUDBfaJ.js";import{n as ot}from"./client-CzjApAA4.js";import{Zi as _,p as v,u as st}from"./useMobileNavigationStore-BtHQN423.js";var y=`/api/magic-prompts`,ct=new Map([{id:`git.commit.generate.visible`,title:`Commit Generation Visible Prompt`,group:`Git`,description:`Visible user message for commit message generation.`,template:`You are generating a Conventional Commits subject line from the diffs of the selected files.`},{id:`git.commit.generate.instructions`,title:`Commit Generation Instructions`,group:`Git`,description:`Hidden instructions for commit message generation.`,placeholders:[{key:`selected_files`,description:`Bullet list of currently selected file paths.`}],template:`Return exactly one JSON object and nothing else. Do not include prose, markdown, explanations, or code fences.
1
+ import{n as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,n}from"./runtime-switch-DEPKHgdL.js";import{n as r}from"./runtime-fetch-V-iMWR8t.js";import{t as i}from"./runtimeAPIRegistry-C2VogTny.js";import{$ as a,A as o,B as s,D as c,E as l,F as u,G as d,H as f,I as p,J as m,K as ee,L as te,M as ne,N as re,O as ie,P as ae,Q as oe,R as se,S as ce,T as le,U as ue,V as de,W as h,X as fe,Y as pe,Z as me,_ as he,_t as ge,a as _e,at as ve,b as ye,bt as be,c as xe,ct as Se,d as Ce,dt as we,et as Te,f as Ee,ft as De,g as Oe,gt as ke,h as Ae,ht as je,i as Me,it as Ne,j as g,k as Pe,l as Fe,lt as Ie,m as Le,mt as Re,n as ze,nt as Be,o as Ve,ot as He,p as Ue,pt as We,q as Ge,r as Ke,rt as qe,s as Je,st as Ye,t as Xe,tt as Ze,u as Qe,ut as $e,v as et,vt as tt,x as nt,y as rt,yt as it,z as at}from"./gitApiHttp-Dd-FwgCq.js";import{n as ot}from"./client-B_907PBv.js";import{Hi as _,f as v,l as st}from"./ui-DyxdnQlj.js";var y=`/api/magic-prompts`,ct=new Map([{id:`git.commit.generate.visible`,title:`Commit Generation Visible Prompt`,group:`Git`,description:`Visible user message for commit message generation.`,template:`You are generating a Conventional Commits subject line from the diffs of the selected files.`},{id:`git.commit.generate.instructions`,title:`Commit Generation Instructions`,group:`Git`,description:`Hidden instructions for commit message generation.`,placeholders:[{key:`selected_files`,description:`Bullet list of currently selected file paths.`}],template:`Return exactly one JSON object and nothing else. Do not include prose, markdown, explanations, or code fences.
2
2
 
3
3
  The JSON object must have exactly this shape:
4
4
  {"subject": string, "highlights": string[]}
@@ -0,0 +1,3 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{C as t,D as n,k as r}from"./runtime-auth-DA-qfGHk.js";import{c as i,f as a,i as o,n as s,s as c}from"./runtime-switch-DEPKHgdL.js";import{n as l}from"./runtime-fetch-V-iMWR8t.js";import{F as u,P as d,R as f,S as p,d as m}from"./platform-CiUKDeXd.js";import{t as h}from"./runtimeAPIRegistry-C2VogTny.js";import{a as g,i as ee,r as te}from"./vendor-zustand-CTekDqaS.js";import{st as ne}from"./vendor-base-ui-wXsskyKm.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-B_907PBv.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-B5DHrw6U.js";import{n as xe}from"./vendor-react-BkccXcWz.js";import{c as Se}from"./yuriEvents-BFrD5fMU.js";import{_ as Ce,c as we,l as Te,r as S,v as Ee}from"./useUIStore-C3ewjGgP.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}),z({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&&z({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&&z({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,zn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Bn=(e,t)=>{if(typeof e!=`string`)return;let n=e.trim();return n.length<=t?n:void 0},Vn=e=>{let t=Bn(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}},Hn=(e,t)=>typeof e==`string`&&t.includes(e)?e:void 0,Un=e=>typeof e==`boolean`?e:void 0,Wn=(e,t)=>{let n=e[t];switch(t){case`autoCreateWorktree`:case`gitmojiEnabled`:case`defaultFileViewerPreview`:case`responseStyleEnabled`:return Un(n);case`messageStreamTransport`:return Hn(n,[`auto`,`ws`,`sse`]);case`sttProvider`:return Hn(n,[`local`,`openai-compatible`,`volcengine`]);case`sttServerUrl`:return Vn(n);case`sttLanguage`:return Bn(n,Pn);case`responseStyleCustomInstructions`:return Bn(n,Fn);case`responseStylePreset`:return Hn(n,In);default:return Bn(n,Mn)}},Gn=e=>{if(!Rn(e))throw Error(`Invalid settings bootstrap response`);if(!zn(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(!zn(e,n))continue;let r=Wn(e,n);r!==void 0&&Object.assign(t,{[n]:r})}return t},Kn=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=Gn({schemaVersion:1,...e}),n={};for(let r of Ln)if(zn(e,r)){if(!zn(t,r))throw Error(`Invalid settings bootstrap patch`);Object.assign(n,{[r]:t[r]})}return n},qn=e=>{if(!Rn(e))return{};let t={};for(let n of Ln){if(!zn(e,n))continue;let r=Wn(e,n);r!==void 0&&Object.assign(t,{[n]:r})}return t},Jn=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)}},Yn=class extends Error{status;constructor(e){super(`Settings bootstrap request failed (${e})`),this.status=e,this.name=`SettingsBootstrapRequestError`}},Xn=(e=o())=>[e,`settings`,`bootstrap`],Zn=(e=o())=>({queryKey:Xn(e),queryFn:({signal:e})=>Jn(e,async e=>{let t=await l(`/api/config/settings/bootstrap`,{method:`GET`,headers:{Accept:`application/json`},signal:e});if(!t.ok)throw new Yn(t.status);return Gn(await t.json())}),retry:(e,t)=>!(t instanceof Yn&&(t.status===404||t.status===501))&&e<1,staleTime:1/0,gcTime:1/0}),Qn=(e=o())=>Se.fetchQuery(Zn(e)),$n=(e=o())=>Se.getQueryData(Xn(e)),er=(e,t=o())=>{let n=Kn(e),r=Xn(t),i=Gn({schemaVersion:1,...Se.getQueryData(r),...n});return Se.setQueryData(r,i),i},tr=e=>{if(!(typeof window>`u`)&&!(typeof window.__YURI_HOME__==`string`&&window.__YURI_HOME__.length>0))try{window.__YURI_HOME__=e}catch{}},nr=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),tr(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`)}}},rr=e=>{typeof window>`u`||window.dispatchEvent(new CustomEvent(`yuri:settings-synced`,{detail:e}))},ir=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},ar=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},or=(e,t)=>{let n=Object.entries(e),r=Object.entries(t);return n.length===r.length&&n.every(([e,n])=>t[e]===n)},sr=(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),cr=(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})},lr=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),ur=e=>{if(Array.isArray(e))return Array.from(new Set(e.filter(e=>typeof e==`string`&&e.length>0)))},dr=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=ur(r);e&&e.length>0&&(t[n]=e.slice(0,5))}return Object.keys(t).length>0?t:void 0},fr=(e,t)=>{let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>Array.isArray(t[n])&&lr(e[n],t[n]))},pr=/^#(?:[\da-fA-F]{3}|[\da-fA-F]{6})$/,mr=e=>{if(typeof e!=`string`)return null;let t=e.trim();return t&&pr.test(t)?t.toLowerCase():null},hr=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=mr(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},gr=(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},_r=()=>{let e=S.persist;if(e&&typeof e==`object`)return e},vr=()=>h()?.settings??null,yr=(e,t,n)=>{let r={...qn(t),...qn(e)};if(Object.keys(r).length!==0)try{er(r,n)}catch(e){console.warn(`Failed to patch settings bootstrap cache:`,e)}},br=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),(e.sidebarView===`tasks`||e.sidebarView===`projects`)&&e.sidebarView!==t.sidebarView&&t.setSidebarView(e.sidebarView),typeof e.chatRenderMode==`string`&&(e.chatRenderMode===`sorted`||e.chatRenderMode===`live`)&&e.chatRenderMode!==t.chatRenderMode&&t.setChatRenderMode(e.chatRenderMode),typeof e.activityRenderMode==`string`&&(e.activityRenderMode===`collapsed`||e.activityRenderMode===`summary`)&&e.activityRenderMode!==t.activityRenderMode&&t.setActivityRenderMode(e.activityRenderMode),typeof e.collapsibleUserMessages==`boolean`&&e.collapsibleUserMessages!==t.collapsibleUserMessages&&t.setCollapsibleUserMessages(e.collapsibleUserMessages),typeof e.messageStreamTransport==`string`&&(e.messageStreamTransport===`auto`||e.messageStreamTransport===`ws`||e.messageStreamTransport===`sse`)&&n&&e.messageStreamTransport!==n.settingsMessageStreamTransport&&n.setSettingsMessageStreamTransport(e.messageStreamTransport),typeof e.promptNavigatorEnabled==`boolean`&&e.promptNavigatorEnabled!==t.promptNavigatorEnabled&&t.setPromptNavigatorEnabled(e.promptNavigatorEnabled),typeof e.showSplitAssistantMessageActions==`boolean`&&e.showSplitAssistantMessageActions!==t.showSplitAssistantMessageActions&&t.setShowSplitAssistantMessageActions(e.showSplitAssistantMessageActions),typeof e.showAssistantTps==`boolean`&&e.showAssistantTps!==t.showAssistantTps&&t.setShowAssistantTps(e.showAssistantTps),typeof e.reportUsage==`boolean`&&e.reportUsage!==t.reportUsage&&t.setReportUsage(e.reportUsage),typeof e.fontSize==`number`&&Number.isFinite(e.fontSize)&&e.fontSize!==t.fontSize&&t.setFontSize(e.fontSize),Array.isArray(e.draftStarters)){let n=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&&!or(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=cr(n,e.favoriteModels);sr(n,r)||S.setState({favoriteModels:r})}if(Array.isArray(e.hiddenModels)){let n=t.hiddenModels,r=e.hiddenModels;sr(n,r)||S.setState({hiddenModels:r})}if(Array.isArray(e.collapsedModelProviders)){let n=t.collapsedModelProviders,r=e.collapsedModelProviders;lr(n,r)||S.setState({collapsedModelProviders:r})}if(Array.isArray(e.recentModels)){let n=t.recentModels,r=cr(n,e.recentModels);sr(n,r)||S.setState({recentModels:r})}if(Array.isArray(e.recentAgents)){let n=t.recentAgents,r=e.recentAgents;lr(n,r)||S.setState({recentAgents:r})}if(e.recentEfforts&&typeof e.recentEfforts==`object`){let n=t.recentEfforts,r=e.recentEfforts;fr(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})},xr=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=hr(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),(t.sidebarView===`tasks`||t.sidebarView===`projects`)&&(n.sidebarView=t.sidebarView),typeof t.chatRenderMode==`string`&&(t.chatRenderMode===`sorted`||t.chatRenderMode===`live`)&&(n.chatRenderMode=t.chatRenderMode),typeof t.messageStreamTransport==`string`&&(t.messageStreamTransport===`auto`||t.messageStreamTransport===`ws`||t.messageStreamTransport===`sse`)&&(n.messageStreamTransport=t.messageStreamTransport),typeof t.activityRenderMode==`string`&&(t.activityRenderMode===`collapsed`||t.activityRenderMode===`summary`)&&(n.activityRenderMode=t.activityRenderMode),typeof t.collapsibleUserMessages==`boolean`&&(n.collapsibleUserMessages=t.collapsibleUserMessages),typeof t.showSplitAssistantMessageActions==`boolean`&&(n.showSplitAssistantMessageActions=t.showSplitAssistantMessageActions),typeof t.showAssistantTps==`boolean`&&(n.showAssistantTps=t.showAssistantTps),typeof t.fontSize==`number`&&Number.isFinite(t.fontSize)&&(n.fontSize=t.fontSize),typeof t.terminalFontSize==`number`&&Number.isFinite(t.terminalFontSize)&&(n.terminalFontSize=t.terminalFontSize),typeof t.editorFontSize==`number`&&Number.isFinite(t.editorFontSize)&&(n.editorFontSize=t.editorFontSize),Ee(t.uiFont)&&(n.uiFont=t.uiFont),Ce(t.monoFont)&&(n.monoFont=t.monoFont),typeof t.padding==`number`&&Number.isFinite(t.padding)&&(n.padding=t.padding),typeof t.cornerRadius==`number`&&Number.isFinite(t.cornerRadius)&&(n.cornerRadius=t.cornerRadius),typeof t.inputBarOffset==`number`&&Number.isFinite(t.inputBarOffset)&&(n.inputBarOffset=t.inputBarOffset);let i=ar(t.shortcutOverrides);i&&(n.shortcutOverrides=i),typeof t.mobileKeyboardMode==`string`&&(t.mobileKeyboardMode===`native`||t.mobileKeyboardMode===`resize-content`)&&(n.mobileKeyboardMode=t.mobileKeyboardMode);let a=gr(t.favoriteModels,64,{preserveVariant:!0});a&&(n.favoriteModels=a);let o=gr(t.hiddenModels,1024);o&&(n.hiddenModels=o);let s=ur(t.collapsedModelProviders);s&&(n.collapsedModelProviders=s);let c=gr(t.recentModels,16,{preserveVariant:!0});c&&(n.recentModels=c);let l=ur(t.recentAgents);l&&(n.recentAgents=l);let u=dr(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=ir(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},P=new Map,Sr=new Map,Cr=2e3,wr=async e=>{let t=P.get(e);if(t&&Date.now()-t.at<Cr)return t.value;let n=Sr.get(e);if(n)return n;let r=(async()=>{if(o()!==e)return null;let t=vr();if(t)try{let n=xr((await t.load()).settings);return P.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=xr(await t.json().catch(()=>null));return P.set(e,{value:n,at:Date.now()}),n}catch(e){return console.warn(`Failed to load shared settings from server:`,e),null}})();Sr.set(e,r);try{return await r}finally{Sr.get(e)===r&&Sr.delete(e)}},Tr=(e=o())=>{P.delete(e)},Er=async()=>{if(typeof window>`u`)return;let e=o(),t=_r(),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{nr(t)}catch(e){console.warn(`persistToLocalStorage failed:`,e)}try{br(t)}catch(e){console.warn(`applyDesktopUiPreferences failed:`,e)}rr(t)}};try{let t=await wr(e);t&&o()===e&&await r(t)}catch(e){console.warn(`Failed to synchronise settings:`,e)}},F=null,I=null,L=null,Dr=[],Or=200,R=new Map,kr=async e=>{for(;R.get(e)?.size;)await Promise.all([...R.get(e)])},Ar=async()=>{let e=F,t=I,n=Dr;if(F=null,I=null,L=null,Dr=[],!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=vr();if(i){try{let a=await i.save(e);yr(a,e,t),a&&r()&&(nr(a),br(a),rr(a),P.set(t,{value:xr(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);yr(i,e,t),i&&r()&&(nr(i),br(i),rr(i),P.set(t,{value:xr(i),at:Date.now()}))}catch(e){console.warn(`Failed to update shared settings via API:`,e)}finally{n.forEach(e=>e())}},z=async e=>{if(typeof window>`u`)return;let t=o();if(I&&I!==t){L&&=(clearTimeout(L),null),F=null,I=null;let e=Dr;Dr=[],e.forEach(e=>e())}let n={...F??{}},r=P.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(F=n,I=t,Object.keys(n).length===0&&!L){F=null,I=null;return}L&&clearTimeout(L);let i=new Promise(e=>{Dr.push(e)}),a=R.get(t)??new Set;R.set(t,a),a.add(i),L=setTimeout(()=>void Ar(),Or);try{await i}finally{a.delete(i),a.size===0&&R.get(t)===a&&R.delete(t)}},jr=async()=>{if(typeof window>`u`)return;let e=_r();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)}},Mr=3e4,Nr=40,Pr=60,Fr=(e,t,n,r,i,a)=>{let o=e.trim(),s=t.trim().toLowerCase();return JSON.stringify([o,s,n,r,i,a])},Ir=(e,t)=>{try{let n=JSON.parse(e);return Array.isArray(n)&&n[0]===t}catch{return!1}},Lr=g()(te((e,t)=>({cache:{},cacheKeys:[],inFlight:{},async searchFiles(n,r,i=Pr,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=Fr(o,s,i,c,l,u),f=Date.now(),p=t().cache[d];if(p&&f-p.timestamp<Mr)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>Nr;){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=>!Ir(e,n)||(delete t[e],!1)),i=Object.entries(e.inFlight).filter(([e])=>!Ir(e,n));return{cache:t,cacheKeys:r,inFlight:Object.fromEntries(i)}})}}),{name:`file-search-store`})),Rr=()=>{if(typeof window>`u`)return!1;try{return window.localStorage.getItem(`yuri_stream_debug`)===`1`}catch{return!1}},zr=`yuri_stream_perf`,Br=()=>{if(typeof window>`u`)return!1;try{return window.localStorage.getItem(zr)===`1`}catch{return!1}},Vr=()=>typeof performance<`u`&&typeof performance.now==`function`?performance.now():Date.now(),Hr=()=>{if(!Br()||typeof window>`u`)return null;if(!window.__yuriStreamPerfState){let e=Date.now();window.__yuriStreamPerfState={counters:new Map,startedAt:e,lastUpdatedAt:e}}return window.__yuriStreamPerfState},Ur=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),Wr=(e,t)=>{let n=Hr();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()},Gr=e=>{if(!(typeof window>`u`))try{if(e){window.localStorage.setItem(zr,`1`),window.__yuriStreamPerfState={counters:new Map,startedAt:Date.now(),lastUpdatedAt:Date.now()};return}window.localStorage.removeItem(zr),delete window.__yuriStreamPerfState,delete window.__yuriVsCodeStreamPerfState}catch{}},Kr=()=>{typeof window>`u`||(Br()&&(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()}))},qr=()=>{if(typeof window>`u`)return{enabled:!1,startedAt:null,lastUpdatedAt:null,durationMs:0,entries:[]};let e=window.__yuriStreamPerfState;return!Br()||!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:Ur(e.counters)}},Jr=()=>{if(typeof window>`u`)return{enabled:!1,startedAt:null,lastUpdatedAt:null,durationMs:0,entries:[]};let e=window.__yuriVsCodeStreamPerfState;if(!Br()||!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:Ur(e.counters)}},Yr=(e,t=1)=>{Wr(e,t)},Xr=(e,t)=>{Wr(e,t)},Zr=(e,t)=>{if(!Br())return t();let n=Vr();try{return t()}finally{Wr(e,Vr()-n)}},B=null,Qr=0,V=_(),$r=b(`lastDirectory`,{storage:V}),ei=typeof $r==`string`&&$r.length>0,ti=e=>{try{Lr.getState().invalidateDirectory(e)}catch(e){console.warn(`Failed to invalidate file search cache:`,e)}},H=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},ni=(e,t)=>{let n=e.trim();return n.startsWith(`~`)?n===`~`?t||n:(n.startsWith(`~/`)||n.startsWith(`~\\`))&&t?`${t}${n.slice(1)}`:n:n},ri=(e,t)=>H(ni(e,t)),ii=()=>{let e=b(`homeDirectory`,{storage:V});if(typeof e!=`string`||e.trim().length===0)return null;let t=H(e);return t.length>0?t:null},ai=()=>{let e=b(`lastDirectory`,{storage:V});if(typeof e!=`string`||e.trim().length===0)return null;let t=H(e);return t.length>0?t:null},oi=()=>{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=H(t);return e.length>0?e:null}let n=process?.cwd?.();if(typeof n==`string`&&n.trim().length>0){let e=H(n);return e.length>0?e:null}return null},si=()=>{if(typeof window<`u`){if(B)return B;let e=typeof window.__YURI_HOME__==`string`&&window.__YURI_HOME__.length>0?window.__YURI_HOME__:null;if(e&&e.length>0)return B=e,v(`homeDirectory`,e,{storage:V}),e;let t=ii();if(t&&!f())return B=t,t}return oi()||`/`},ci=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},li=e=>(B=e,typeof window<`u`&&v(`homeDirectory`,e,{storage:V}),z({homeDirectory:e}),e),ui=async()=>{let e=e=>{let t=ci(e);return t?li(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=si();return e(t)||t},di=(()=>{if(!f())return null;let e=window.__VSCODE_CONFIG__?.workspaceFolder;if(typeof e!=`string`||e.trim().length===0)return null;let t=H(e);return t.length>0?t:null})()||si(),fi=(()=>{let e=ai();return e&&!f()?ri(e,di):di})();fi&&y.setDirectory(fi);var pi=!!(di&&di!==`/`),mi=g()(te((e,t)=>({currentDirectory:fi,directoryHistory:[fi],historyIndex:0,homeDirectory:di,hasPersistedDirectory:ei,isHomeReady:pi,isSwitchingDirectory:!1,setDirectory:(n,r)=>{let i=ri(n,B||t().homeDirectory||b(`homeDirectory`,{storage:V}));Rr(),Oe(t().currentDirectory,i)&&(y.setDirectory(i),ti(),e(e=>{let t=[...e.directoryHistory.slice(0,e.historyIndex+1),i];return v(`lastDirectory`,i,{storage:V}),z({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),ti(),v(`lastDirectory`,r,{storage:V}),z({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),ti(),v(`lastDirectory`,r,{storage:V}),z({lastDirectory:r}),e({currentDirectory:r,historyIndex:t,hasPersistedDirectory:!0,isHomeReady:!0,isSwitchingDirectory:!1})}},goToParent:()=>{let{currentDirectory:e,setDirectory:n}=t();if(e===(B||t().homeDirectory||si())||e===`/`)return;let r=e.endsWith(`/`)?e.slice(0,-1):e,i=r.lastIndexOf(`/`);n(i===-1?B||si():i===0?`/`:r.substring(0,i))},goHome:async()=>{let e=B||t().homeDirectory||await ui();t().setDirectory(e)},synchronizeHomeDirectory:n=>{let r=t(),i=n;B=i;let a=r.homeDirectory!==i,o=b(`lastDirectory`,{storage:V}),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?ri(r.currentDirectory,i):r.currentDirectory,d=r.directoryHistory.map(e=>ri(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),ti(),v(`lastDirectory`,e,{storage:V}),z({lastDirectory:e})}z({homeDirectory:i})}}),{name:`directory-store`}));typeof window<`u`&&(ui().then(e=>{mi.getState().synchronizeHomeDirectory(e)}),i(e=>{B=null;let t=++Qr;if(c(e)){let e=ii(),t=ai(),n=e||`/`,r=t||n;B=e,mi.setState({currentDirectory:r,directoryHistory:[r],historyIndex:0,homeDirectory:n,hasPersistedDirectory:!!t,isHomeReady:!!(e&&e!==`/`),isSwitchingDirectory:!1}),r&&(y.setDirectory(r),ti())}ui().then(e=>{t===Qr&&mi.getState().synchronizeHomeDirectory(e)})}));var hi=(e,i)=>{let a=t();return a?a.openWebSocket(r(e),i):n(i?new WebSocket(e,i):new WebSocket(e))},U=`/api/git`,gi=1200,_i=5e3,vi=2,yi=5e3,bi=`${U}/worktrees/queue-activation`,xi=`message_queue_activation_pending`,Si=`worktree_lifecycle_busy`,Ci=`worktree_activation_stale`,wi=5e3,Ti=3e4,Ei=[0,500,1e3,2e3,4e3,8e3,14e3],Di=new Map,W=new Map,Oi=new Map,ki=new Map,Ai=new Map,G=new Map,K=new Map,q=new Map,ji=new Map,Mi=new Map,J=new Map,Ni=new Map,Pi=new Set,Fi=0,Ii=[],Li=()=>Fi<vi?(Fi+=1,Promise.resolve()):new Promise(e=>{Ii.push(e)}),Ri=()=>{let e=Ii.shift();if(e){e();return}Fi=Math.max(0,Fi-1)},zi=async e=>{await Li();try{return await e()}finally{Ri()}},Bi=Symbol.for(`yuri.git.discoveryGated`),Vi=e=>(Object.defineProperty(e,Bi,{value:!0,configurable:!0}),e),Hi=e=>typeof e==`function`&&e[Bi]===!0,Y=e=>e.trim(),Ui=``,X=e=>{let t=`${s()}\u0000${o()}`;return t!==Ui&&(Ui=t,Ai.clear(),G.clear(),K.clear(),q.clear(),ji.clear(),Mi.clear(),J.clear(),Ni.clear()),`${t}\u0000${Y(e)}`},Wi=(e,t)=>t===`light`?`${Y(e)}::light`:Y(e),Gi=e=>Oi.get(Y(e))??0,Z=e=>{let t=Y(e);Oi.set(t,Gi(e)+1);for(let e of Array.from(ki.keys()))(e===t||e.startsWith(`${t}::`))&&ki.delete(e);for(let e of Array.from(Di.keys()))(e===t||e.startsWith(`${t}::`))&&Di.delete(e);for(let e of Array.from(W.keys()))(e===t||e.startsWith(`${t}::`))&&W.delete(e)},Ki=e=>Ni.get(X(e))??0,Q=e=>{let t=X(e);t&&(Ni.set(t,Ki(e)+1),Mi.delete(t),J.delete(t))};function $(e,t,n){let r={...n};return t&&(r.directory=t),a().api(e,r)}var qi=(e,t,n)=>{if(!Y(e))return;let r=X(e),i=Date.now()+yi;Ai.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 Ji(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=X(e),r=Ai.get(t),a=q.get(t);if(r&&r.expiresAt>i&&(!r.value||a&&a.expiresAt>i)){n.set(e,{isGitRepository:r.value,primaryRoot:a?.value.root??null});continue}o.push(e)}if(o.length===0)return n;let c=e=>{for(let t of e){let e=typeof t.directory==`string`?Y(t.directory):``;if(!e)continue;let i=!!t.isGitRepository,a=typeof t.primaryRoot==`string`&&t.primaryRoot?t.primaryRoot:null;r===s()&&qi(e,i,a),n.set(e,{isGitRepository:i,primaryRoot:a})}},u=async e=>{await Promise.all(e.map(async e=>{try{let t=await Yi(e);if(r!==s())return;let i=t?(await Zi(e)).root:null;r===s()&&qi(e,t,t?i:null),n.set(e,{isGitRepository:t,primaryRoot:t?i:null})}catch{}}))},d=o.map(X),f=[...new Set(d.map(e=>K.get(e)).filter(e=>e!==void 0))];if(f.length>0)return await Promise.allSettled(f),r===s()?Ji(t):n;let p=zi(async()=>{if(r!==s())return;let e=new URLSearchParams;for(let t of o)e.append(`directories`,t);let t=a().api(`${U}/discover`),n=e.toString(),i=n?t.includes(`?`)?`${t}&${n}`:`${t}?${n}`:t,u=await l(i);if(u.status===501||!u.ok)throw Error(`Batch git discover unavailable: ${u.status} ${u.statusText}`);let d=await u.json().catch(()=>null),f=Array.isArray(d)?d:[];if(f.length===0&&o.length>0)throw Error(`Batch git discover returned empty payload`);c(f)});for(let e of d)K.set(e,p);try{await p}catch{}finally{for(let e of d)K.get(e)===p&&K.delete(e)}if(r!==s())return n;let m=o.filter(e=>!n.has(e));return m.length>0&&await u(m),n}async function Yi(e){let t=X(e),n=s(),r=K.get(t);if(r&&await r.catch(()=>void 0),n!==s())throw new DOMException(`Git discovery runtime changed`,`AbortError`);let i=Date.now(),a=Ai.get(t);if(a&&a.expiresAt>i)return a.value;let o=G.get(t);if(o)return o;let c=zi(async()=>{if(n!==s())throw new DOMException(`Git discovery runtime changed`,`AbortError`);let r=await l($(`${U}/check`,e));if(!r.ok)throw Error(`Failed to check git repository: ${r.statusText}`);let i=!!(await r.json()).isGitRepository;return n===s()&&Ai.set(t,{value:i,expiresAt:Date.now()+_i}),i});G.set(t,c);try{return await c}finally{G.get(t)===c&&G.delete(t)}}async function Xi(e,t){let n=t?.mode,r=Wi(e,n),i=Date.now(),a=Di.get(r);if(a&&a.expiresAt>i)return a.value;let s=W.get(r);if(s)return s;let c=(async()=>{let t=Gi(e),i=o(),a=ki.get(r),s=a&&a.transport===i&&a.cacheVersion===t?a:null,c=await l($(`${U}/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`&&Gi(e)===t&&ki.set(r,{revision:n,value:d,transport:i,cacheVersion:t})}return Gi(e)===t&&Di.set(r,{value:d,expiresAt:Date.now()+gi}),d})();W.set(r,c);try{return await c}finally{W.get(r)===c&&W.delete(r)}}async function Zi(e){let t=X(e),n=s(),r=K.get(t);if(r&&await r.catch(()=>void 0),n!==s())throw new DOMException(`Git discovery runtime changed`,`AbortError`);let i=Date.now(),a=q.get(t);if(a&&a.expiresAt>i)return a.value;let o=ji.get(t);if(o)return o;let c=zi(async()=>{if(n!==s())throw new DOMException(`Git discovery runtime changed`,`AbortError`);let r=await l($(`${U}/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()+yi}),a});ji.set(t,c);try{return await c}finally{ji.get(t)===c&&ji.delete(t)}}async function Qi(e){let t=await l($(`${U}/toplevel`,e));if(!t.ok)throw Error(`Failed to resolve git toplevel: ${t.statusText}`);let n=await t.json().catch(()=>({}));return{root:typeof n.root==`string`&&n.root?n.root:e}}async function $i(e,t){let n=await l($(`${U}/commit-summaries`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({shas:t})});if(!n.ok)throw Error(`Failed to get git commit summaries: ${n.statusText}`);let r=await n.json().catch(()=>({}));return{commits:Array.isArray(r.commits)?r.commits.map(e=>({sha:typeof e.sha==`string`?e.sha:``,short:typeof e.short==`string`?e.short:``,subject:typeof e.subject==`string`?e.subject:``})).filter(e=>e.sha&&e.short):[]}}async function ea(e,t){let{path:n,staged:r,contextLines:i}=t;if(!n)throw Error(`path is required to fetch git diff`);let a=await l($(`${U}/diff`,e,{path:n,staged:r?`true`:void 0,context:i}));if(!a.ok)throw Error(`Failed to get git diff: ${a.statusText}`);return a.json()}async function ta(e,t){let{path:n,staged:r}=t;if(!n)throw Error(`path is required to fetch git file diff`);let i=await l($(`${U}/file-diff`,e,{path:n,staged:r?`true`:void 0}));if(!i.ok)throw Error(`Failed to get git file diff: ${i.statusText}`);return i.json()}async function na(e,t,n){if(!t)throw Error(`path is required to revert git changes`);let r=await l($(`${U}/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 ra(e,t){await ia(e,[t])}async function ia(e,t){let n=t.map(e=>e.trim()).filter(Boolean);if(n.length===0)throw Error(`path is required to stage git changes`);let r=await l($(`${U}/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 aa(e,t){await oa(e,[t])}async function oa(e,t){let n=t.map(e=>e.trim()).filter(Boolean);if(n.length===0)throw Error(`path is required to unstage git changes`);let r=await l($(`${U}/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 sa(e,t,n){await ua(e,t,n,`stage`)}async function ca(e,t,n){await ua(e,t,n,`unstage`)}async function la(e,t,n){await ua(e,t,n,`discard`)}async function ua(e,t,n,r){if(!t)throw Error(`path is required to apply a git hunk`);if(typeof n!=`string`||!n.trim())throw Error(`patch is required to apply a git hunk`);let i=await l($(`${U}/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 da(e){if(!e)return!1;let t=await l($(`${U}/worktree-type`,e));if(!t.ok)throw Error(`Failed to detect worktree type: ${t.statusText}`);return!!(await t.json()).linked}async function fa(e,t){let n=await l($(`${U}/branches`,e),{signal:t?.signal});if(!n.ok)throw Error(`Failed to get branches: ${n.statusText}`);return n.json()}async function pa(e,t){if(!t?.branch)throw Error(`branch is required to delete a branch`);let n=await l($(`${U}/branches`,e),{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to delete branch`)}return n.json()}async function ma(e,t){if(!t?.branch)throw Error(`branch is required to delete remote branch`);let n=await l($(`${U}/remote-branches`,e),{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to delete remote branch`)}return n.json()}async function ha(e,t){let n=t?.remote?.trim();if(!n)throw Error(`remote is required to remove a remote`);let r=await l($(`${U}/remotes`,e),{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify({remote:n})});if(!r.ok){let e=await r.json().catch(()=>({error:r.statusText}));throw Error(e.error||`Failed to remove remote`)}return r.json()}async function ga(e,t,n){if(!Array.isArray(t)||t.length===0)throw Error(`No files provided to generate commit message`);let r={files:t};n?.zenModel&&(r.zenModel=n.zenModel),n?.providerId&&(r.providerId=n.providerId),n?.modelId&&(r.modelId=n.modelId);let i=await l($(`${U}/commit-message`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r)});if(!i.ok){let e=await i.json().catch(()=>({error:i.statusText}));console.error(`[git-generation][browser] http error`,{status:i.status,statusText:i.statusText,error:e});let t=typeof e?.traceId==`string`&&e.traceId?` (traceId: ${e.traceId})`:``;throw Error(`${e.error||`Failed to generate commit message`}${t}`)}let a=await i.json();if(!a?.message||typeof a.message!=`object`)throw Error(`Malformed commit generation response`);return{message:{subject:typeof a.message.subject==`string`&&a.message.subject.trim().length>0?a.message.subject.trim():``,highlights:Array.isArray(a.message.highlights)?a.message.highlights.filter(e=>typeof e==`string`&&e.trim().length>0).map(e=>e.trim()):[]}}}async function _a(e,t){let{base:n,head:r,context:i,zenModel:a,providerId:o,modelId:s}=t;if(!n||!r)throw Error(`base and head are required`);let c={base:n,head:r};i?.trim()&&(c.context=i.trim()),a&&(c.zenModel=a),o&&(c.providerId=o),s&&(c.modelId=s);let u=await l($(`${U}/pr-description`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(c)});if(!u.ok){let e=await u.json().catch(()=>({error:u.statusText}));throw Error(e.error||`Failed to generate PR description`)}let d=await u.json().catch(()=>null),f=typeof d?.title==`string`?d.title:``,p=typeof d?.body==`string`?d.body:``;if(!f&&!p)throw Error(`Malformed PR description response`);return{title:f,body:p}}async function va(e){let t=X(e),n=s(),r=Date.now(),i=Mi.get(t);if(i&&i.expiresAt>r)return i.value;let a=J.get(t);if(a)return a;let o=Ki(e),c=zi(async()=>{let r=await l($(`${U}/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===Ki(e)&&Mi.set(t,{value:i,expiresAt:Date.now()+yi}),i});J.set(t,c);try{return await c}finally{J.get(t)===c&&J.delete(t)}}Vi(va);async function ya(e,t){let n=await l($(`${U}/worktrees/validate`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t??{})});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to validate worktree`)}return n.json()}async function ba(e){let t=await l($(`${U}/worktrees/bootstrap-status`,e));if(!t.ok){let e=await t.json().catch(()=>({error:t.statusText}));throw Error(e.error||`Failed to get worktree bootstrap status`)}return t.json()}async function xa(e,t){let n=await l($(`${U}/worktrees/preview`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t??{})});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to preview worktree`)}return n.json()}var Sa=e=>typeof e==`string`&&e.length>0,Ca=e=>{if(!e||typeof e!=`object`)return null;let t=e;if(!Sa(t.name)||!Sa(t.path))return null;let n={head:typeof t.head==`string`?t.head:``,name:t.name,branch:typeof t.branch==`string`?t.branch:``,path:t.path};return t.directoryCreated===!0&&(n.directoryCreated=!0),t.bootstrapStatus&&typeof t.bootstrapStatus==`object`&&(n.bootstrapStatus=t.bootstrapStatus),n},wa=(e,t,n)=>{if(e!==503||!t||typeof t!=`object`)return null;let r=t;if(r.code!==xi)return null;let i=Ca(r.worktree);if(!i)return null;let a=r.repair;if(!a||typeof a!=`object`)return null;let o=a;if(o.method!==`POST`||o.path!==bi)return null;let s=o.body;if(!s||typeof s!=`object`)return null;let c=s;return c.projectDirectory!==n||c.directory!==i.path?null:i},Ta=(e,t,n,r)=>`${e}\u0000${t}\u0000${n}\u0000${r}`,Ea=e=>new Promise(t=>{setTimeout(t,e)}),Da=async e=>{if(e.status===409){let t=await e.json().catch(()=>null);return t?.code===Si||t?.code===Ci}return e.status===503&&(await e.json().catch(()=>null))?.code===xi},Oa=e=>e===400||e===401||e===403||e===501,ka=(e,t)=>{let n=o(),r=s(),i=Ta(n,r,e,t);if(Pi.has(i))return;Pi.add(i);let a=()=>o()===n&&s()===r;(async()=>{let n=Date.now(),r=0;for(;Date.now()-n<Ti;){if(!a())return;let i=Ei[Math.min(r,Ei.length-1)]??0;if(i>0){let e=Ti-(Date.now()-n);if(e<=0||(await Ea(Math.min(i,e)),!a()))return}let o=new AbortController,s=setTimeout(()=>o.abort(),wi);try{let n=await l($(bi,void 0),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({projectDirectory:e,directory:t}),signal:o.signal});if(n.ok||Oa(n.status))return;if(await Da(n)){r+=1;continue}return}catch{r+=1}finally{clearTimeout(s)}}})().catch(()=>{}).finally(()=>{Pi.delete(i)})};async function Aa(e,t){let n=await l($(`${U}/worktrees`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t??{})}),r=await n.json().catch(()=>null);if(n.ok){let t=Ca(r);if(t)return Q(e),t;if(r&&typeof r==`object`)return Q(e),r;throw Error(`Failed to create worktree`)}let i=wa(n.status,r,e);if(i)return Q(e),ka(e,i.path),i;let a=r&&typeof r==`object`?r:{error:n.statusText};throw Error(a.error||`Failed to create worktree`)}async function ja(e,t){let n=await l($(`${U}/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 Ma(e,t,n={}){let r=await l($(`${U}/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 Na(e,t={}){let n=await l($(`${U}/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 Pa(e,t={}){let n=await l($(`${U}/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 Fa(e,t={}){let n=await l($(`${U}/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 Ia(e){let t=await l($(`${U}/stashes`,e));if(!t.ok){let e=await t.json().catch(()=>({error:t.statusText}));throw Error(e.error||`Failed to list stashes`)}return t.json()}async function La(e,t){let n=await l($(`${U}/stashes/file-counts`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({refs:t})});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to count stash files`)}return n.json()}async function Ra(e,t={}){let n=await l($(`${U}/stash`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to stash changes`)}return n.json()}var za=async(e,t,n)=>{let r=await l($(`${U}/${t}`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)});if(!r.ok){let e=await r.json().catch(()=>({error:r.statusText}));throw Error(e.error||`Failed to ${t}`)}return r.json()},Ba=(e,t)=>za(e,`stash/apply`,t),Va=(e,t)=>za(e,`stash/pop`,t),Ha=(e,t)=>za(e,`stash/drop`,t);async function Ua(e,t){let n=await l($(`${U}/checkout`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({branch:t})});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to checkout branch`)}return n.json()}async function Wa(e,t,n){let r=await l($(`${U}/branches`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:t,startPoint:n})});if(!r.ok){let e=await r.json().catch(()=>({error:r.statusText}));throw Error(e.error||`Failed to create branch`)}return r.json()}async function Ga(e,t,n){let r=await l($(`${U}/branches/rename`,e),{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({oldName:t,newName:n})});if(!r.ok){let e=await r.json().catch(()=>({error:r.statusText}));throw Error(e.error||`Failed to rename branch`)}return r.json()}async function Ka(e,t={}){let n=await l($(`${U}/log`,e,{maxCount:t.maxCount,from:t.from,to:t.to,file:t.file,all:t.all?`true`:void 0}));if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(`Failed to get git log: ${e.error||n.statusText}`)}return n.json()}async function qa(e,t){let n=await l($(`${U}/commit-files`,e,{hash:t}));if(!n.ok)throw Error(`Failed to get commit files: ${n.statusText}`);return n.json()}async function Ja(e,t,n,r){let i=await l($(`${U}/commit-file-diff`,e,{hash:t,path:n,binary:r?`true`:void 0}));if(!i.ok)throw Error(`Failed to get commit file diff: ${i.statusText}`);return i.json()}async function Ya(){let e=await l($(`${U}/identities`,void 0));if(!e.ok)throw Error(`Failed to get git identities: ${e.statusText}`);return e.json()}async function Xa(e){let t=await l($(`${U}/identities`,void 0),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok){let e=await t.json().catch(()=>({error:t.statusText}));throw Error(e.error||`Failed to create git identity`)}return t.json()}async function Za(e,t){let n=await l($(`${U}/identities/${e}`,void 0),{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to update git identity`)}return n.json()}async function Qa(e){let t=await l($(`${U}/identities/${e}`,void 0),{method:`DELETE`});if(!t.ok){let e=await t.json().catch(()=>({error:t.statusText}));throw Error(e.error||`Failed to delete git identity`)}}async function $a(e){if(!e)return null;let t=await l($(`${U}/current-identity`,e));if(!t.ok)throw Error(`Failed to get current git identity: ${t.statusText}`);let n=await t.json();return n?{userName:n.userName??null,userEmail:n.userEmail??null,sshCommand:n.sshCommand??null}:null}async function eo(e){if(!e)return!1;let t=await l($(`${U}/has-local-identity`,e));if(!t.ok)throw Error(`Failed to check local identity: ${t.statusText}`);return(await t.json().catch(()=>null))?.hasLocalIdentity===!0}async function to(){let e=await l($(`${U}/global-identity`,void 0));if(!e.ok)throw Error(`Failed to get global git identity: ${e.statusText}`);let t=await e.json();return!t||!t.userName&&!t.userEmail?null:{userName:t.userName??null,userEmail:t.userEmail??null,sshCommand:t.sshCommand??null}}async function no(e,t){let n=await l($(`${U}/set-identity`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({profileId:t})});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to set git identity`)}return n.json()}async function ro(){let e=await l($(`${U}/discover-credentials`,void 0));if(!e.ok)throw Error(`Failed to discover git credentials: ${e.statusText}`);return e.json()}async function io(e,t){if(!e)return null;let n=await l($(`${U}/remote-url`,e,{remote:t}));return n.ok?(await n.json()).url??null:null}async function ao(e,t){let n=await l($(`${U}/remotes`,e),{signal:t?.signal});if(!n.ok)throw Error(`Failed to get remotes: ${n.statusText}`);return n.json()}async function oo(e,t){let n=await l($(`${U}/rebase`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to rebase`)}return n.json()}async function so(e){let t=await l($(`${U}/rebase/abort`,e),{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>({error:t.statusText}));throw Error(e.error||`Failed to abort rebase`)}return t.json()}async function co(e,t){let n=await l($(`${U}/merge`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to merge`)}return n.json()}async function lo(e,t){let n=await l($(`${U}/checkout-commit`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({hash:t})});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to checkout commit`)}return n.json()}async function uo(e,t){let n=await l($(`${U}/cherry-pick`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({hash:t})});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to cherry-pick`)}return n.json()}async function fo(e,t){let n=await l($(`${U}/revert-commit`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({hash:t})});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to revert commit`)}return n.json()}async function po(e,t,n,r){let i=await l($(`${U}/reset-to-commit`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({hash:t,mode:n,force:r})});if(!i.ok){let e=await i.json().catch(()=>({error:i.statusText}));throw Error(e.error||`Failed to reset`)}return i.json()}async function mo(e){let t=await l($(`${U}/merge/abort`,e),{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>({error:t.statusText}));throw Error(e.error||`Failed to abort merge`)}return t.json()}async function ho(e){let t=await l($(`${U}/rebase/continue`,e),{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>({error:t.statusText}));throw Error(e.error||`Failed to continue rebase`)}return t.json()}async function go(e){let t=await l($(`${U}/merge/continue`,e),{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>({error:t.statusText}));throw Error(e.error||`Failed to continue merge`)}return t.json()}async function _o(e,t){return await Ra(e,{message:t?.message}),{success:!0}}async function vo(e){return await Va(e,{ref:`stash@{0}`}),{success:!0}}async function yo(e){let t=await l($(`${U}/conflict-details`,e));if(!t.ok)throw Error(`Failed to get conflict details: ${t.statusText}`);return t.json()}async function bo(e,t){let n=await l(`${U}/validate-directory`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({directory:e,worktreeRoot:t})});if(!n.ok)throw Error(`Failed to validate worktree directory: ${n.statusText}`);return n.json()}async function xo(e){let t=await l(`${U}/canonicalize-worktree-state`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({directory:e})});if(!t.ok)throw Error(`Failed to canonicalize worktree state: ${t.statusText}`);return t.json()}export{ha as $,vn as $t,$i as A,nt as An,Xr as At,Fa as B,Zn as Bt,ga as C,mt as Cn,qr as Ct,yo as D,E as Dn,Rr as Dt,qa as E,ht as En,Gr as Et,Xi as F,z as Ft,Hi as G,kn as Gt,Na as H,qn as Ht,ba as I,kr as It,va as J,N as Jt,da as K,An as Kt,to as L,Qn as Lt,ta as M,ke as Mn,jr as Mt,Ya as N,Tr as Nt,$a as O,qe as On,Yr as Ot,Ka as P,Er as Pt,oo as Q,xn as Qt,io as R,er as Rt,Ha as S,xt as Sn,mi as St,Ja as T,pt as Tn,Kr as Tt,eo as U,jn as Ut,Pa as V,Jn as Vt,Q as W,On as Wt,Va as X,bn as Xt,co as Y,gn as Yt,xa as Z,yn as Zt,Qa as _,dt as _n,Za as _t,Yi as a,dn as an,na as at,ro as b,yt as bn,zi as bt,uo as c,At as cn,ra as ct,La as d,Wt as dn,_o as dt,wn as en,Ga as et,Wa as f,Xt as fn,Ra as ft,pa as g,ot as gn,ca as gt,Aa as h,Yt as hn,oa as ht,xo as i,un as in,fo as it,ea as j,Ae as jn,Lr as jt,fa as k,et as kn,Zr as kt,go as l,Ct as ln,ia as lt,Xa as m,Ut as mn,aa as mt,so as n,Tn as nn,Zi as nt,Ua as o,an as on,la as ot,Ma as p,O as pn,vo as pt,Ia as q,M as qt,Ba as r,Sn as rn,Qi as rt,lo as s,zt as sn,no as st,mo as t,Cn as tn,po as tt,ho as u,St as un,sa as ut,ja as v,ct as vn,ya as vt,_a as w,ut as wn,Jr as wt,Ji as x,bt as xn,hi as xt,ma as y,vt as yn,bo as yt,ao as z,$n as zt};
@@ -0,0 +1 @@
1
+ import{i as e}from"./runtime-switch-DEPKHgdL.js";import{n as t}from"./runtime-fetch-V-iMWR8t.js";import{t as n}from"./runtimeAPIRegistry-C2VogTny.js";import{n as r}from"./vendor-react-BkccXcWz.js";import{s as i}from"./vendor-tanstack-react-query-DIb_ItL-.js";import{c as a,l as o}from"./yuriEvents-BFrD5fMU.js";var s=r(),c=e=>e??n()?.github,l=(t=e())=>o.github.auth(t),u=async(e,n)=>{if(e)return e.authStatus();let r=await t(`/api/github/auth/status`,{method:`GET`,headers:{Accept:`application/json`},signal:n}),i=await r.json().catch(()=>null);if(!r.ok||!i)throw Error(i?.error||r.statusText||`Failed to load GitHub status`);return i},d=(t,n=e())=>{let r=c(t);return{queryKey:l(n),queryFn:async({signal:e})=>u(r,e),retry:2}},f=e=>!!e&&typeof e==`object`&&`authStatus`in e,p=e=>{let t=(0,s.c)(5),n=f(e)?e:void 0,r=f(e)?void 0:e?.enabled,a;t[0]===n?a=t[1]:(a=d(n),t[0]=n,t[1]=a);let o;return t[2]!==r||t[3]!==a?(o={...a,enabled:r},t[2]=r,t[3]=a,t[4]=o):o=t[4],i(o)},m=(t=a,n=e())=>t.getQueryData(l(n))??null,h=async(t,n,r)=>e()===r?t.fetchQuery({...d(n,r),staleTime:0}):t.getQueryData(l(r))??null,g=(t=a,n,r=e())=>{t.setQueryData(l(r),n)};export{p as a,g as i,m as n,h as r,d as t};
@@ -0,0 +1 @@
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-BkccXcWz.js";import{s as i}from"./vendor-tanstack-react-query-DIb_ItL-.js";import{c as a}from"./yuriEvents-BFrD5fMU.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 +1 @@
1
- import{f as e,n as t}from"./platform-CiUKDeXd.js";import{C as n,D as r,I as i,L as a,M as o,O as s,P as c,S as l,T as u,_ as d,a as f,b as p,c as m,j as h,n as g,o as _,r as v,s as y,t as ee,v as b,w as x,y as S}from"./vendor-opencode-client-BM2r1f0o.js";import{a as te}from"./vendor-tanstack-query-core-BSjXNgF_.js";import{b as ne,v as C}from"./runtime-file-resource-CKQQEwNv.js";import{o as w}from"./path-utils-jGozTg9d.js";import{a as T,n as re}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{Dt as ie,ht as ae,mt as oe,y as se}from"./vendor-effect-X1Hqc7ba.js";import{t as E}from"./native-errors-06if6eu-.js";import{a as ce,i as le,n as ue,o as de,r as fe,s as D}from"./appearance-DFsI3pnP.js";import{i as pe,o as me}from"./fileReferenceParser-1HHDBUum.js";import{a as he,r as O}from"./pages-CYkE04ml.js";import{n as ge,t as _e}from"./vendor-solid-js-BBVUd3Hw.js";import{a as ve,c as ye,d as be,f as k,g as A,h as j,i as M,l as N,m as xe,n as Se,o as P,p as F,r as Ce,s as we,t as Te,u as Ee}from"./vendor-opencode-plugin-ZhpPgHCL.js";var I={"@opencode/plugin/gui":P,"@opencode/plugin/gui/main":P,"@opencode/plugin/gui/file":ve,"@opencode/plugin/gui/review":M,"@opencode/plugin/gui/browser":Ce,"@opencode/plugin/rpc":Te,"@opencode/schema/rpc":Se,"@opencode/client":v,"@opencode/client/effect":g,"@opencode/client/solid":ee,effect:se,"solid-js":c,"solid-js/web":ge,"solid-js/store":y},De=new Set(`assert assert/strict async_hooks buffer child_process cluster console constants crypto dgram diagnostics_channel dns dns/promises domain events fs fs/promises http http2 https inspector inspector/promises module net os path path/posix path/win32 perf_hooks process punycode querystring readline readline/promises repl stream stream/consumers stream/promises stream/web string_decoder sys timers timers/promises tls trace_events tty url util util/types v8 vm wasi worker_threads zlib`.split(` `));function Oe(){let e=new Proxy(function(){},{get:(t,n)=>n===`then`?void 0:n===Symbol.hasInstance?()=>!1:n===Symbol.toPrimitive||n===`toString`?()=>`[main-only module]`:e,apply:()=>e,construct:()=>e,set:()=>!0});return e}function ke(e,t){if(e.length>16777216)throw Error(`GUI bundle exceeds 16 MiB`);let n={exports:{}};Function(`require`,`module`,`exports`,e)(e=>{if(Object.hasOwn(I,e))return I[e];if(e===`electron`||e.startsWith(`node:`)||De.has(e))return Oe();throw Error(`Unsupported GUI shared module: ${e}`)},n,n.exports);let r=n.exports,i=r&&typeof r==`object`&&`default`in r?r.default:r;if(!i||typeof i!=`object`)throw Error(`GUI bundle must default-export Plugin.define`);if((!(`setup`in i)||typeof i.setup!=`function`)&&!(t&&`main`in i&&typeof i.main==`function`))throw new E(`GUI_PLUGIN_UNSUPPORTED`,`This host requires a window setup; main-only plugins are unsupported`);if(`os`in i&&i.os!==void 0){if(!t)throw new E(`GUI_PLUGIN_UNSUPPORTED`,`OS-restricted plugins require the native GUI host`);if(!Array.isArray(i.os)||!i.os.includes(t))throw new E(`GUI_PLUGIN_UNSUPPORTED`,`GUI plugin is unavailable on this OS`)}if(`main`in i&&i.main!==void 0&&typeof i.main!=`function`)throw Error(`Invalid GUI main entry`);if(`stores`in i&&i.stores!==void 0){if(!i.stores||typeof i.stores!=`object`||Array.isArray(i.stores))throw Error(`Invalid GUI stores`);for(let e of Object.values(i.stores))if(!e||typeof e!=`object`||!(`schema`in e)||!ie(e.schema)||!(`scope`in e)||![`global`,`session`].includes(String(e.scope))||!(`initial`in e))throw Error(`Invalid GUI store declaration`)}if(`i18n`in i&&i.i18n!==void 0){if(!i.i18n||typeof i.i18n!=`object`||Array.isArray(i.i18n))throw Error(`Invalid GUI locale catalog`);for(let e of Object.values(i.i18n))if(!e||typeof e!=`object`||Array.isArray(e)||Object.values(e).some(e=>typeof e!=`string`))throw Error(`GUI locales must be inline string dictionaries`)}return i}function L(t){let n=t;if(/^file:/i.test(n)){let e=new URL(n);n=`${e.hostname&&e.hostname!==`localhost`?`//${e.hostname}`:``}${decodeURIComponent(e.pathname)}`,/^\/[a-z]:\//i.test(n)&&(n=n.slice(1))}let r=e(n)??``;return r===`.`?``:r}var R=e=>/^(?:\/|[a-z]:\/)/i.test(e),z=()=>{throw Error(`Unsupported GUI file API: tree`)},B=class extends Error{},V=e=>new TextEncoder().encode(e).byteLength,Ae=class{files;query;transport;root;api;ended=!1;states=new Map;inflight=new Map;watches=new Map;apiLeases=new Map;registeredOwners=new WeakSet;endedOwners=new WeakSet;leaseCount=0;rerun=new Set;selections=new Map;scrolls=new Map;subscriptions=new Map;constructor(e,t,n,r){this.files=e,this.query=t,this.transport=n,this.root=r,this.root=L(r),this.api={root:this.root,ready:()=>!this.ended,resolve:e=>this.resolve(e),absolute:R,get:e=>{let t=this.track(e,`file`);return this.states.get(t)},missing:e=>{let t=this.track(e,`missing`);return this.states.get(t)?.notFound===!0},sync:(e,t)=>{let n=s();return this.ended||n&&this.endedOwners.has(n)?Promise.resolve():(this.acquireApiLease(e),this.sync(e,t?.force))},unwatch:e=>this.releaseApiLease(s(),this.resolve(e)),exists:async e=>{try{if(this.files.statFile)return(await this.query.fetchQuery(this.statOptions(e))).isFile;let t=this.full(e);return(await this.files.listDirectory(t.slice(0,t.lastIndexOf(`/`)))).entries.some(e=>!e.isDirectory&&L(e.path)===t)}catch{return!1}},search:async(e,t)=>{if(t?.kind===`any`)throw Error(`Unsupported GUI file search: directories`);t?.signal?.throwIfAborted();let r=await this.query.fetchQuery({queryKey:[`gui-plugin-files`,n,this.root,`search`,e,t?.limit],gcTime:3e4,queryFn:async({signal:n})=>(n.throwIfAborted(),this.files.search({directory:this.root,query:e,maxResults:t?.limit??100}))});if(t?.signal?.throwIfAborted(),this.ended)throw new DOMException(`GUI file model was disposed`,`AbortError`);return r.map(e=>this.resolve(e.path))},selection:{get:e=>this.selections.get(this.track(e,`selection`)),set:(e,t)=>{let n=this.resolve(e),r=this.selections.get(n);r===t||r&&t&&r.start===t.start&&r.end===t.end&&r.side===t.side&&r.endSide===t.endSide||(this.selections.set(n,t),this.trim(this.selections,`selection`),this.changed(n,`selection`))}},scroll:{get:e=>this.scrolls.get(this.track(e,`scroll`))??{},set:(e,t)=>{let n=this.resolve(e),r=this.scrolls.get(n),i={...r,...t};(r?.top!==i.top||r?.left!==i.left)&&(this.scrolls.set(n,i),this.trim(this.scrolls,`scroll`),this.changed(n,`scroll`))}},tree:{list:z,state:z,sync:z,expand:z,collapse:z}}}resolve(e){let t=L(e);if(!R(t))return t;if(t===this.root)return``;let n=this.root.endsWith(`/`)?this.root:`${this.root}/`;return t.startsWith(n)?t.slice(n.length):t}full(e){let t=this.resolve(e);return R(t)?t:L(`${this.root}/${t}`)}input(e){return{scopeDirectory:this.root,path:this.full(e),options:{directory:this.root}}}statOptions(e){return{...ne(this.files,this.input(e),this.transport),gcTime:3e4}}track(e,t){let n=this.resolve(e),i=r();if(!i||this.ended)return n;let a=`${t}:${n}`,s=this.subscriptions.get(a);s||(s={revision:u(0),listeners:new Set},this.subscriptions.set(a,s));let c=s;return c.listeners.has(i)||(c.listeners.add(i),o(i,()=>h(()=>{c.listeners.delete(i),!c.listeners.size&&this.subscriptions.get(a)===c&&this.subscriptions.delete(a)}))),c.revision[0](),n}changed(e,t){this.ended||this.subscriptions.get(`${t}:${e}`)?.revision[1](e=>e+1)}trim(e,t){for(;e.size>64;){let n=e.keys().next().value;e.delete(n),this.changed(n,t)}}setState(e,t){let n=this.states.get(e);n?.content?.content===t.content?.content&&n?.content?.type===t.content?.type&&(t.content=n?.content),!(n&&n.loaded===t.loaded&&n.loading===t.loading&&n.error===t.error&&n.notFound===t.notFound&&n.content===t.content)&&(this.states.set(e,t),d(()=>{this.changed(e,`file`),n?.notFound===!0!=(t.notFound===!0)&&this.changed(e,`missing`)}))}acquireApiLease(e){let t=s();if(this.ended||t&&this.endedOwners.has(t)||!this.files.statFile)return;let n=this.resolve(e),r=this.apiLeases.get(t);if(r?.has(n))return;if(this.leaseCount>=256)throw Error(`GUI file consumer limit exceeded`);let i=this.watch(n);r||(r=new Map,this.apiLeases.set(t,r)),r.set(n,i),this.leaseCount++,t&&!this.registeredOwners.has(t)&&(this.registeredOwners.add(t),h(()=>{`fn`in t||this.endedOwners.add(t),this.registeredOwners.delete(t);for(let e of[...this.apiLeases.get(t)?.keys()??[]])this.releaseApiLease(t,e)}))}releaseApiLease(e,t){let n=this.apiLeases.get(e),r=n?.get(t);r&&(n.delete(t),this.leaseCount--,n.size||this.apiLeases.delete(e),r())}reserve(e){if(!this.states.has(e)){if(this.states.size>=64){let e=[...this.states.keys()].find(e=>!this.watches.has(e)&&!this.inflight.has(e));if(!e)throw Error(`GUI file cache limit exceeded`);let t=this.states.get(e)?.notFound===!0;this.states.delete(e),d(()=>{this.changed(e,`file`),t&&this.changed(e,`missing`)})}this.states.set(e,{path:e,name:e.split(`/`).at(-1)??e})}}async sync(e,t=!1){if(this.ended)return;let n=this.resolve(e);if(this.inflight.has(n))return t&&this.rerun.add(n),this.inflight.get(n);if(!t&&this.states.get(n)?.loaded&&!this.states.get(n)?.error)return;this.reserve(n);let r=this.states.get(n);this.setState(n,{...r,path:n,name:n.split(`/`).at(-1)??n,loading:!r?.loaded&&!this.watches.get(n)?.failed});let i=(async()=>{try{do{this.rerun.delete(n);let e=this.watches.get(n),r=e?.epoch;try{let i=C(this.files,this.input(n),this.transport),a=await this.query.fetchQuery({...i,gcTime:3e4,staleTime:t?0:3e4,queryFn:async()=>{if(!this.files.readFile)throw Error(`File content reads are unavailable in this runtime`);let e=await this.files.readFile(this.full(n),{directory:this.root});if(e.exists===!1)throw new B(`File does not exist`);let t=e.content;if(V(t)>131072)throw Error(`GUI file preview exceeds 128 KiB`);return t}});if(this.ended)return;if(V(a)>131072)throw Error(`GUI file preview exceeds 128 KiB`);(!e||e.epoch===r&&!e.failed)&&this.setState(n,{path:n,name:n.split(`/`).at(-1)??n,loaded:!0,loading:!1,content:{type:`text`,content:a}})}catch(t){if(this.ended)return;if((!e||e.epoch===r&&!e.failed)&&this.setState(n,{...this.states.get(n),loading:!1,...t instanceof B?{notFound:!0}:{},error:String(t)}),!this.rerun.has(n))throw t}t=!0}while(!this.ended&&this.rerun.has(n))}finally{this.inflight.delete(n),this.rerun.delete(n)}})();return this.inflight.set(n,i),i}watch(e){if(this.ended||!this.files.statFile)return()=>{};let t=this.resolve(e),n=this.watches.get(t);if(!n){if(this.watches.size>=64)throw Error(`GUI file watch limit exceeded`);this.reserve(t),n={count:0,epoch:0,failed:!1,stop:()=>{}};let e=n;this.watches.set(t,e);let r,i=new te(this.query,{...this.statOptions(t),refetchInterval:2e3,refetchIntervalInBackground:!1}),a=i.subscribe(n=>{if(this.ended||this.watches.get(t)!==e||n.isFetching)return;if(n.isError||n.isSuccess&&!n.data.isFile){e.failed=!0,e.epoch++,this.setState(t,{...this.states.get(t),loading:!1,notFound:n.isSuccess?!0:this.states.get(t)?.notFound,error:n.isError?String(n.error):`File does not exist`});return}if(!n.data||!n.isSuccess)return;let i=`${n.data.size}:${n.data.mtimeMs??``}`,a=e.failed||r!==void 0&&i!==r;e.failed=!1,r=i,a&&(e.epoch++,this.sync(t,!0).catch(()=>{}))});e.stop=()=>{a(),i.destroy()},this.states.get(t)?.loaded&&this.sync(t,!0).catch(()=>{})}n.count++;let r=!0;return()=>{r&&(r=!1,--n.count===0&&this.watches.get(t)===n&&this.stopWatch(t))}}stopWatch(e){this.watches.get(e)?.stop(),this.watches.delete(e)}dispose(){this.ended=!0;for(let e of this.watches.values())e.stop();this.watches.clear(),this.apiLeases.clear(),this.leaseCount=0,this.rerun.clear(),this.states.clear(),this.inflight.clear(),this.selections.clear(),this.scrolls.clear(),this.subscriptions.clear()}},H=256,U=2097152,W=e=>structuredClone(m(e)),je=class{backend;transport;memory=new Map;resets=new Map;constructor(e,t){this.backend=e,this.transport=t}forPlugin(e,t){let n=(t,n=`global`)=>{if(typeof n==`object`&&`session`in n&&!n.session.location)throw Error(`Unsupported GUI storage: session location is unknown`);let r=n===`global`?n:`session`in n?[n.session.server.id,n.session.id,n.session.location]:[n.server,n.directory];return`yuri.gui-plugin.${JSON.stringify([this.transport,e,r,t])}`},r=e=>{if(t.aborted)throw Error(`GUI plugin has been disposed`);if(e!==void 0)throw Error(`Unsupported GUI storage migration: from`)},i=new Map;return{store:(e,a)=>{r(a.from);let o=n(e,a.scope),s=i.get(o);if(s)return s;if(i.size>=H)throw Error(`GUI plugin store limit exceeded`);let c=oe(a.schema),l=ae(a.schema),d=c(l(W(a.initial)));if(JSON.stringify(l(d)).length>U)throw Error(`GUI plugin store exceeds 2 MiB`);let f=d,p=this.backend.getItem(o);if(p!==null&&p.length<=U)try{f=c(JSON.parse(p))}catch{f=d}let[m,h]=u(f),g=e=>{r();let t=JSON.stringify(l(W(e)));if(t.length>U)throw Error(`GUI plugin store exceeds 2 MiB`);let n=c(JSON.parse(t));this.backend.setItem(o,t),h(()=>n)},_={get value(){return m()},ready:()=>!0,set:g,update:e=>{let t=W(m());if(e(t)!==void 0)throw Error(`Store update must not return a replacement`);g(t)}},v=()=>h(()=>W(d)),y=this.resets.get(o)??new Set;return y.add(v),this.resets.set(o,y),t.addEventListener(`abort`,()=>{y.delete(v),y.size||this.resets.delete(o),i.clear()},{once:!0}),i.set(o,_),_},memory:(e,t)=>{r();let i=n(e),a=this.memory.get(i);if(a)return[a[0],e=>{r(),a[1](e)}];if(this.memory.size>=H)throw Error(`GUI plugin memory store limit exceeded`);if(JSON.stringify(t.initial).length>U)throw Error(`GUI plugin memory exceeds 2 MiB`);let[o,s]=f(W(t.initial)),c=[o,e=>{r();let t=W(m(o));if(e(t)!==void 0)throw Error(`Memory update must not return a replacement`);if(JSON.stringify(t).length>U)throw Error(`GUI plugin memory exceeds 2 MiB`);s(_(t))}];return this.memory.set(i,[o,e=>{let t=W(m(o));if(e(t)!==void 0)throw Error(`Memory update must not return a replacement`);if(JSON.stringify(t).length>U)throw Error(`GUI plugin memory exceeds 2 MiB`);s(_(t))}]),c},remove:(e,t)=>{r(t?.from);let i=n(e,t?.scope);this.backend.removeItem(i);for(let e of this.resets.get(i)??[])e()}}}dispose(){this.memory.clear(),this.resets.clear()}};function Me(e){if(typeof e!=`string`||e.length>2097152)return;let t=e.trim();if(t)try{if(t.startsWith(`<`))return D(t);if(!/^data:/i.test(t))return t;let e=/^data:image\/(svg\+xml|png|jpeg|gif|webp|avif|x-icon|vnd\.microsoft\.icon)(?:;charset=utf-8)?(;base64)?,([\s\S]+)$/i.exec(t);if(!e)return;let[,n,r,i]=e;if(r&&!/^[A-Za-z0-9+/]+={0,2}$/.test(i))return;if(n.toLowerCase()===`svg+xml`){let e=r?new TextDecoder(`utf-8`,{fatal:!0}).decode(Uint8Array.from(atob(i),e=>e.charCodeAt(0))):decodeURIComponent(i);return D(e)}return!r||!atob(i).length?void 0:`data:image/${n.toLowerCase()};base64,${i}`}catch{return}}var G=e=>e===`yuri.exportPDF`||e===`yuri.exportLongImage`,Ne=class{api;probe;clients=new Map;ended=!1;constructor(e){this.api=e}use(e,t){let n=this.clients.get(t),r=n?.get(e);if(r)return r.live;let[i,a]=u(this.api&&!t.aborted&&!this.ended?{status:`pending`}:{status:`inactive`,reason:`disabled`}),o=()=>{a({status:`inactive`,reason:`disabled`}),t.removeEventListener(`abort`,o),this.clients.delete(t)},s={live:A(i),stop:o};if(this.ended||t.aborted||(n||(n=new Map,this.clients.set(t,n)),n.set(e,s),t.addEventListener(`abort`,o,{once:!0}),!this.api))return s.live;let c=this.api;return this.probe??=Promise.resolve().then(()=>c.capabilities()),this.probe.then(n=>{if(this.ended||t.aborted)return;let r=e===`yuri.exportPDF`?`exportPDF`:`exportLongImage`;if(n.version!==1||!n[r]){a({status:`inactive`,reason:`disabled`});return}let o=async(e,n={})=>{if(this.ended||t.aborted||i().status!==`active`)return{status:`cancelled`};let o=AbortSignal.any([t,...n.signal?[n.signal]:[]]);try{return await c[r](e,{...n,signal:o})}catch(e){throw e&&typeof e==`object`&&`code`in e&&e.code===`EXPORT_UNSUPPORTED`&&a({status:`inactive`,reason:`failed`}),e}},s=Object.freeze(e===`yuri.exportPDF`?{version:1,limits:n.limits,exportPDF:o}:{version:1,limits:n.limits,exportLongImage:o});a({status:`active`,generation:1,value:s})}).catch(()=>{!this.ended&&!t.aborted&&a({status:`inactive`,reason:`failed`})}),s.live}dispose(){this.ended=!0;for(let e of this.clients.values())for(let t of e.values())t.stop();this.clients.clear()}};function Pe(e,t){let n=new Map,r=Object.freeze({dismiss(){}});return e.addEventListener(`abort`,()=>{for(let e of[...n.values()])e.handle.dismiss()},{once:!0}),Object.freeze({show(i){if(e.aborted)return r;if(!t)throw new E(`GUI_PLUGIN_UNSUPPORTED`,`GUI toast is unavailable`);if(!i||typeof i!=`object`)throw new E(`GUI_PLUGIN_INVALID_INPUT`,`Expected toast options`);let{title:a,description:o,variant:s=`default`,duration:c=5e3,persistent:l=!1,icon:u,actions:d}=i;if(typeof a!=`string`||o!==void 0&&typeof o!=`string`||![`default`,`success`,`error`,`loading`].includes(s)||typeof l!=`boolean`||typeof c!=`number`||!Number.isFinite(c)||c<0)throw new E(`GUI_PLUGIN_INVALID_INPUT`,`Invalid toast options`);if(u!==void 0||d!==void 0)throw new E(`GUI_PLUGIN_UNSUPPORTED`,`GUI toast icon/actions are unsupported`);if(e.aborted)return r;let f=JSON.stringify([a,o??null,s,c,l]),p=n.get(f),m=()=>{let e=n.get(f);!e||e.id!==h||(clearTimeout(e.timer),n.delete(f))},h=(s==="default"?t:t[s])(a,{id:p?.id,description:o,duration:l?1/0:c,onDismiss:m,onAutoClose:m}),g=p?.handle??Object.freeze({dismiss(){m(),t.dismiss(h)}});clearTimeout(p?.timer);let _=s===`loading`&&!l?setTimeout(()=>g.dismiss(),c):void 0;return n.set(f,{id:h,handle:g,timer:_}),g}})}var Fe=T(`YuriMedia`);async function Ie(e){let n=/\.html?$/i.test(e.name)?`text/html`:`text/plain`,r=new Blob([e.content],{type:n});if(t()){if(!re.isPluginAvailable(`YuriMedia`))throw new E(`GUI_PLUGIN_UNSUPPORTED`,`Native file saving is unavailable`);if(r.size>33554432)throw new E(`GUI_PLUGIN_INVALID_INPUT`,`File exceeds maximum size`);let t=await new Promise((e,t)=>{let n=new FileReader;n.onload=()=>{if(typeof n.result!=`string`){t(Error(`Failed to encode file`));return}e(n.result.slice(n.result.indexOf(`,`)+1))},n.onerror=()=>t(n.error??Error(`Failed to encode file`)),n.readAsDataURL(r)});return!(await Fe.saveFile({dataBase64:t,mimeType:n,filename:e.name})).cancelled}let i=URL.createObjectURL(r),a=document.createElement(`a`);try{return a.href=i,a.download=e.name,document.body.append(a),a.click(),!0}finally{a.remove(),setTimeout(()=>URL.revokeObjectURL(i),1e3)}}var K=p();function Le(e){return{version:1,register(t){let n=a(K);if(!n||n.plugin!==e||n.signal.aborted||e.aborted)throw Error(`Preview actions require the owning mounted panel`);let r=new AbortController,i=AbortSignal.any([e,n.signal,r.signal]),o,s=()=>{i.removeEventListener(`abort`,s),r.abort(),o?.remove()};h(s),i.addEventListener(`abort`,s,{once:!0});try{o=t.render({element:t.element,signal:i,async snapshot(e={}){let r=AbortSignal.any([i,...e.signal?[e.signal]:[]]);if(r.throwIfAborted(),!n.content.contains(t.element)||n.target.contains(t.element))throw Error(`Preview capture region is no longer in its owning panel`);let a=await t.capture({...e,signal:r});if(r.throwIfAborted(),!n.content.contains(t.element))throw Error(`Preview capture region was replaced`);return a}}),i.throwIfAborted(),n.target.append(o)}catch(e){throw s(),e}return s}}}var Re=`yuri.work-status`;function q(e,t){return e===t||!!(e&&t&&Object.keys(e).length===Object.keys(t).length&&Object.keys(e).every(n=>e[n]===t[n]))}var J=e=>e&&Object.freeze({...e});function Y(e,t,n){let r=new AbortController,[i,a]=u(!0),[o,s]=u(J(e.project),{equals:q}),[c,l]=u(J(e.worktree),{equals:q}),[f,p]=u(Object.freeze({...e.git}),{equals:q}),[m,h]=u(e.placement);return{props:Object.freeze({session:t,directory:e.directory,runtimeId:n,signal:r.signal,get active(){return i()},get project(){return o()},get worktree(){return c()},get git(){return f()},get placement(){return m()}}),matches:t=>t.sessionId===e.sessionId&&t.directory===e.directory&&t.scope===e.scope,update(e){r.signal.aborted||d(()=>{s(J(e.project)),l(J(e.worktree)),p(Object.freeze({...e.git})),h(e.placement)})},dispose(){r.signal.aborted||(a(!1),r.abort())}}}var ze=class{plugins=new Map;order=new Map;snapshot=Object.freeze([]);generation=0;listeners=new Set;subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getSnapshot=()=>this.snapshot;setOrder(e){e.length===this.order.size&&e.every((e,t)=>this.order.get(e)===t)||(this.order=new Map(e.map((e,t)=>[e,t])),this.publish())}replace(e,t,n){let r=this.plugins.get(e)??[],i=new Set,a=n.map(n=>{if(!n||typeof n!=`object`||!(`id`in n)||typeof n.id!=`string`||!n.id.trim()||n.id.length>128||i.has(n.id)||!(`render`in n)||typeof n.render!=`function`||`order`in n&&n.order!==void 0&&(typeof n.order!=`number`||!Number.isFinite(n.order)))throw Error(`Invalid or duplicate yuri.work-status contribution`);i.add(n.id);let a=JSON.stringify([e,n.id]),o=`order`in n&&typeof n.order==`number`?n.order:0,s=n.render,c=r.find(e=>e.key===a),l=c&&c.revision===t&&c.render===s?c.generation:++this.generation;return c&&c.revision===t&&c.render===s&&c.order===o?c:Object.freeze({key:a,pluginId:e,revision:t,generation:l,order:o,render:s})});a.length?this.plugins.set(e,a):this.plugins.delete(e),this.publish()}contains(e){return this.plugins.get(e.pluginId)?.some(t=>t.key===e.key&&t.generation===e.generation)??!1}remove(e){this.plugins.delete(e)&&this.publish()}dispose(){this.plugins.clear(),this.publish(),this.listeners.clear()}publish(){let e=[...this.plugins.values()].flat().sort((e,t)=>e.order-t.order||(this.order.get(e.pluginId)??2**53-1)-(this.order.get(t.pluginId)??2**53-1));if(!(e.length===this.snapshot.length&&e.every((e,t)=>e===this.snapshot[t]))){this.snapshot=Object.freeze(e);for(let e of this.listeners)i(e)}}},X=e=>{throw new E(`GUI_PLUGIN_UNSUPPORTED`,`Unsupported GUI host API: ${e}`)};function Z(e,t){return new Proxy(t,{get:(t,n)=>n in t?Reflect.get(t,n):X(`${e}.${String(n)}`)})}var Q=e=>Object.freeze(e.map(e=>Object.freeze(e)));function Be(e,t){if(!e.fields||!t.fields)return!1;let n=Reflect.ownKeys(e.fields);return n.length===Reflect.ownKeys(t.fields).length&&n.every(n=>{let r=e.fields[n],i=t.fields[n];return i!==void 0&&`value`in r&&`value`in i&&Object.is(r.value,i.value)&&r.enumerable===i.enumerable&&r.configurable===i.configurable&&r.writable===i.writable})}function $(e,t){if(e){for(let n of e.owned??[])$(n,t);e.cleanups&&=e.cleanups.map(e=>()=>{try{Promise.resolve(e()).catch(t)}catch(e){t(e)}})}}var Ve=class{options;fileIcons=new de;appearanceCatalog=new le;workStatus=new ze;instances=new Map;listeners=new Set;panelMounts=new Set;fileViews=new Map;changes=u(0);views=u(0);session=u();currentPage=u();mobilePageNetworkReady=u(!1);appearance;layouts=new Map;files;storage;ended=!1;contracts=new Map;snapshot=Object.freeze({plugins:Object.freeze([]),commands:Object.freeze([]),titlebarItems:Object.freeze([]),panels:Object.freeze([]),pages:Object.freeze([]),settings:Object.freeze([]),menuItems:Object.freeze([]),activePanel:null});#e;viewExports;constructor(e){this.options=e,this.viewExports=new Ne(e.viewExport),this.appearance=u({locale:e.locale,mode:e.mode,narrow:e.narrow}),this.storage=new je(e.storage,e.transport);let t=()=>(this.session[0](),this.files?.api??X(`screen.file without a session`));this.#e=Z(`screen`,{get file(){return t()}})}subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getSnapshot=()=>this.snapshot;changed(e=!1){let t=this.snapshot;this.changes[1](e=>e+1),e&&t===this.snapshot&&this.publish()}setSession(e){if(this.ended)return;let t=this.session[0]();if(t?.id===e?.id&&t?.directory===e?.directory)return;if(!e)for(let e of[...this.panelMounts])e();this.files?.dispose(),this.files=e?new Ae(this.options.files,this.options.queryClient,this.options.transport,e.directory):void 0;let n=e?this.sessionReference(e):void 0,r=this.snapshot;this.session[1](n),r===this.snapshot&&this.publish()}sessionReference(e,t){let n=t?JSON.stringify(t.queryScope):this.options.transport,r=Z(`session.server`,{id:n,name:t?.location.hostId??this.options.transport,...t?{}:{client:this.options.client}});return Object.freeze(Z(`session`,{id:e.id,directory:e.directory,key:t?JSON.stringify([n,e.id]):`${this.options.transport}\n${e.id}`,tab:e.id,server:r,pending:!1,visit:{},location:t?Object.freeze({...t.location}):{directory:e.directory}}))}setAppearance(e){if(this.ended)return;let t=this.appearance[0]();(t.locale!==e.locale||t.mode!==e.mode||t.narrow!==e.narrow)&&this.appearance[1]({...e})}setPage(e){this.ended||this.currentPage[1](e)}setMobilePageNetworkReady(e){this.mobilePageNetworkReady[1](!this.ended&&e)}install(e,t,r){if(this.options.mobileNetworkRequired&&!this.mobilePageNetworkReady[0]()&&!this.ended)throw new E(`GUI_PLUGIN_UNAVAILABLE`,`Mobile plugin Relay is not ready`);let a=this.instances.get(e);if(this.ended||a?.status===`active`&&a.revision===t.revision&&a.native?.active!==!1){r?.dispose();return}a&&(this.instances.delete(e),this.release(a));let c={id:e,native:r,revision:t.revision,controller:new AbortController,status:`active`,cleanups:new Set,contributions:new Set,iconChanges:u(0),appearanceChanges:u(0),workStatusChanges:u(0),commands:[],titlebarItems:[],panels:[],pages:[],settings:[],menus:[]};this.instances.set(e,c);try{if(e===`yuri`||e.startsWith(`yuri.`))throw Error(`The yuri namespace is reserved to the host`);let a=ke(t.code,r?.activation.os);x(e=>{c.dispose=e,c.root=s(),b(()=>S(j.Provider,{value:c.context=this.context(c,a,t.options),get children(){c.owner=s();let e=i(()=>a.setup?.(c.context));if(typeof e==`function`)c.cleanups.add(()=>{Promise.resolve(e()).catch(e=>{c.error=String(e)})});else if(e!==void 0)throw e&&typeof e==`object`&&`then`in e&&Promise.resolve(e).catch(()=>{}),Error(`GUI setup must be synchronous and return only cleanup`);return null}}),e=>this.fail(c,e)),c.controller.signal.aborted||o(c.owner,()=>n(()=>{if(c.iconChanges[0](),!c.controller.signal.aborted)try{let e=[...c.contributions].filter(e=>e.registry===ce).map(e=>e.read()).filter(e=>e!==void 0);this.fileIcons.replace(c.id,e),c.iconError!==void 0&&i(()=>{c.iconError=void 0,this.publish()})}catch(e){i(()=>{this.fileIcons.remove(c.id),c.iconError=e instanceof Error?e.message:String(e),this.publish()})}})),c.controller.signal.aborted||o(c.owner,()=>n(()=>{if(c.appearanceChanges[0](),!c.controller.signal.aborted)try{let e=e=>[...c.contributions].filter(t=>t.registry===e).map(e=>e.read()).filter(e=>e!==void 0);this.appearanceCatalog.replace(c.id,e(fe),e(ue),c.native?.activation.capabilities?.dockIcon===!0)}catch(e){i(()=>this.fail(c,e))}})),c.controller.signal.aborted||o(c.owner,()=>n(()=>{if(c.workStatusChanges[0](),!c.controller.signal.aborted)try{let e=[...c.contributions].filter(e=>e.registry===Re).map(e=>e.read()).filter(e=>e!==void 0);this.workStatus.replace(c.id,c.revision,e)}catch(e){i(()=>this.fail(c,e))}})),c.controller.signal.aborted||o(c.owner,()=>n(()=>{this.changes[0](),this.session[0](),this.appearance[0]();try{this.derive(c)}catch(e){i(()=>this.fail(c,e))}i(()=>this.publish())}))})}catch(e){this.fail(c,e)}this.changed(!0)}release(e){e.controller.abort(),e.native?.dispose();for(let t of[...e.cleanups])try{t()}catch(t){e.error??=String(t)}e.cleanups.clear(),$(e.root,t=>{e.error??=String(t)});try{e.dispose?.()}catch(t){e.error??=String(t)}e.contributions.clear(),e.commands=[],e.titlebarItems=[],e.panels=[],e.pages=[],e.settings=[],e.menus=[],this.fileIcons.remove(e.id),this.appearanceCatalog.remove(e.id),this.workStatus.remove(e.id);for(let t of this.contracts.values())t.provider===e&&(t.provider=void 0,t.live[1]({status:`inactive`,reason:e.status===`failed`?`failed`:`disabled`}))}fail(e,t){e.status!==`failed`&&this.instances.get(e.id)===e&&(e.status=`failed`,e.error=t instanceof Error?t.message:String(t),t instanceof E&&(e.errorCode=t.code),this.release(e),this.publish())}uninstall(e){let t=this.instances.get(e);if(t){this.instances.delete(e),this.release(t);for(let t of this.layouts.values())t.open=t.open.filter(t=>!t.startsWith(`${e}:`)),t.active?.startsWith(`${e}:`)&&(t.active=null);this.changed(!0)}}dispose(){this.ended||(this.ended=!0,d(()=>{for(let e of[...this.instances.keys()])this.uninstall(e)}),this.viewExports.dispose(),this.files?.dispose(),this.fileIcons.dispose(),this.appearanceCatalog.dispose(),this.workStatus.dispose(),this.storage.dispose(),this.layouts.clear(),this.fileViews.clear(),this.contracts.clear(),this.listeners.clear())}async setDockIcon(e,t){let n=this.instances.get(e),r=n?.native;if(!r?.active||!r.activation.capabilities?.dockIcon)return X(`Dock icon`);try{await r.setDockIcon(t)}catch(e){throw t!==null&&n&&this.fail(n,e),e}}own(e,t){let n=!0,r=()=>{n&&(n=!1,e.cleanups.delete(r),t())};return e.controller.signal.aborted||a(F)?.ended?(r(),r):(e.cleanups.add(r),s()&&h(r),r)}list(e){this.changes[0]();let t=[];for(let n of this.instances.values())if(n.status===`active`){for(let r of n.contributions)if(r.registry===e.id){let e=r.read();e!==void 0&&t.push(e)}}return t}context(e,t,r){let o=this.storage.forPlugin(e.id,e.controller.signal),c=Object.fromEntries(Object.entries(t.stores??{}).map(([e,t])=>[e,t.scope===`global`?o.store(e,{...t,scope:`global`}):n=>o.store(e,{...t,scope:{session:n}})])),u=(e,n)=>{let r=this.appearance[0]().locale;return(t.i18n?.[r]?.[e]??t.i18n?.[r.split(`-`)[0]]?.[e]??t.i18n?.en?.[e]??e).replace(/\{\{(\w+)\}\}/g,(e,t)=>String(n?.[t]??e))},d=Z(`layout`,{narrow:()=>this.appearance[0]().narrow,ready:()=>!!this.session[0](),open:(t,n,r)=>{e.controller.signal.aborted||this.openPanel(t,n,r)},close:(t,n)=>{e.controller.signal.aborted||this.closeFor(t,n)},toggle:(e,t)=>d.state(e,t)===`visible`?d.close(e,t):d.open(e,t),hide:(t,n)=>{if(e.controller.signal.aborted)return;let r=this.layout(n);r.active===t&&r.shown&&(r.shown=!1,this.changed())},state:(e,t)=>{this.changes[0]();let n=this.layout(t);return n.active===e?n.shown?`visible`:`active`:n.open.includes(e)?`open`:`closed`},stored:t=>(this.changes[0](),this.layout(t).open.filter(t=>t.startsWith(`${e.id}:`)).map(t=>t.slice(e.id.length+1))),side:{opened:e=>(this.changes[0](),this.layout(e).shown),toggle:t=>{if(e.controller.signal.aborted)return;let n=this.layout(t);n.shown=!n.shown,this.changed()},menu:()=>this.list(N).filter(e=>e.menu===`session.panel`).sort((e,t)=>(e.order??0)-(t.order??0))},scroll:{get:(e,t)=>(this.changes[0](),this.layout(e).scroll.get(t)),set:(t,n,r)=>{if(e.controller.signal.aborted)return;let i=this.layout(t).scroll;if(!i.has(n)&&i.size>=128)throw Error(`GUI layout scroll limit exceeded`);i.set(n,{...r}),this.changed()}}}),f=Le(e.controller.signal),p=A(()=>e.controller.signal.aborted?{status:`inactive`,reason:`disabled`}:{status:`active`,generation:1,value:f}),m={open:t=>e.controller.signal.aborted||this.appearance[0]().narrow&&!this.mobilePageNetworkReady[0]()||!e.pages.some(e=>e.id===t)?!1:this.options.openPage?.(O(e.id,t))??!1,current:()=>{let t=this.currentPage[0]();return e.pages.find(n=>O(e.id,n.id)===t)?.id}},g=A(()=>e.controller.signal.aborted||!this.options.openPage||this.appearance[0]().narrow&&!this.mobilePageNetworkReady[0]()?{status:`inactive`,reason:`disabled`}:{status:`active`,generation:1,value:m});return Z(`ctx`,{id:e.id,options:r,signal:e.controller.signal,client:this.options.client,storage:o,stores:c,toast:Pe(e.controller.signal,this.options.toast),app:{name:`yuri`,version:e.native?.activation.app.version??``,channel:e.native?.activation.app.packaged?`prod`:`local`,platform:e.native?`desktop`:`web`,packaged:e.native?.activation.app.packaged??!1},desktop:e.native?Z(`desktop`,{os:e.native.activation.os}):void 0,t:u,plural:(e,t,n)=>{let r=`${e}.${new Intl.PluralRules(this.appearance[0]().locale).select(t)}`;return u(r,{...n,count:t})===r?u(`${e}.other`,{...n,count:t}):u(r,{...n,count:t})},add:(t,r)=>{if(e.controller.signal.aborted||a(F)?.ended)return()=>{};if([`server`,`composer-pill`,`slot`,`file.viewer`,`menubar-item`].includes(t.id)&&X(`registry.${t.id}`),e.contributions.size>=256)throw Error(`GUI contribution limit exceeded`);let o=()=>{},c,u=x(i=>{o=i,c=s();let a=()=>typeof r==`function`?r():r,u;if(t.id===`yuri.file-icon`){let e=l(()=>{try{return{ok:!0,value:a()}}catch(e){return{ok:!1,error:e}}});u=()=>{let t=e();if(!t.ok)throw t.error;return t.value}}else u=l(a);if(t.id===`style`){let t=document.createElement(`style`);t.dataset.yuriPluginStyle=e.id,document.head.append(t),h(()=>t.remove()),n(()=>{let e=u();t.textContent=e===void 0?``:String(e)})}return{registry:t.id,read:u}},s()??e.owner);e.contributions.add(u);let d=()=>{t.id===`yuri.file-icon`&&e.iconChanges[1](e=>e+1)},f=()=>{(t.id===`yuri.theme`||t.id===`yuri.branding`)&&e.appearanceChanges[1](e=>e+1)},p=()=>{t.id===`yuri.work-status`&&e.workStatusChanges[1](e=>e+1)};return i(d),i(f),i(p),i(()=>this.changed()),this.own(e,()=>{$(c,t=>{e.error??=String(t)}),o(),e.contributions.delete(u),i(d),i(f),i(p),i(()=>this.changed())})},list:e=>this.list(e),provide:(t,n)=>{if(e.controller.signal.aborted||a(F)?.ended)return()=>{};if(G(t.id)||t.id===`yuri.previewActions`||t.id===`yuri.pages`)throw Error(`Preview/export/page contracts are provided only by the Yuri host`);if(t.kind!==`contract`||!(t.id===e.id||t.id.startsWith(`${e.id}.`)))throw Error(`Contract must belong to the providing plugin`);let r=this.contract(t.id);if(r.provider)throw Error(`Contract already provided: ${t.id}`);return r.provider=e,r.live[1]({status:`active`,value:n,generation:++r.generation}),this.own(e,()=>{r.provider===e&&(r.provider=void 0,r.live[1]({status:`inactive`,reason:e.status===`failed`?`failed`:`disabled`}))})},use:t=>t.id===`yuri.pages`?t.kind===`contract`?g:X(`pages token must be a Contract`):t.id===`yuri.previewActions`?t.kind===`contract`?p:X(`preview actions token must be a Contract`):G(t.id)?t.kind===`contract`?this.viewExports.use(t.id,e.controller.signal):X(`export token must be a Contract`):t.kind===`ipc`&&e.native?e.native.token(t).live:this.contract(t.id,t.kind===`ipc`).live[0],main:t=>{if(!(t.id===e.id||t.id.startsWith(`${e.id}.`)))throw new E(`GUI_PLUGIN_FORBIDDEN`,`IPC must belong to the plugin`);return e.native?e.native.token(t).value:new Proxy({state:()=>void 0},{get:(e,t)=>t===`state`?e.state:t===`on`?()=>{throw new E(`GUI_PLUGIN_UNSUPPORTED`)}:()=>Promise.reject(new E(`GUI_PLUGIN_UNSUPPORTED`))})},sessions:{current:this.session[0],list:()=>{let e=this.session[0]();return e?[e]:[]}},screen:{current:()=>this.session[0]()?this.#e:void 0},layout:d,appearance:{mode:()=>this.appearance[0]().mode,font:()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||`monospace`},locale:{locale:()=>this.appearance[0]().locale,direction:()=>/^(ar|fa|he|ur)(-|$)/i.test(this.appearance[0]().locale)?`rtl`:`ltr`},system:{copy:e=>navigator.clipboard.writeText(e),openExternal:e=>{let t=new URL(e);[`https:`,`http:`,`mailto:`].includes(t.protocol)||X(`system.openExternal protocol`),window.open(e,`_blank`,`noopener,noreferrer`)},save:Ie},commands:{run:t=>e.controller.signal.aborted||!this.command(t)?!1:(this.runCommand(t),!0)},links:{open:t=>!e.controller.signal.aborted&&this.navigateLink(e,t),exists:t=>i(()=>{if(e.controller.signal.aborted)return!1;let n=this.linkHandler(t);try{return Promise.resolve(n?.value.exists?.(t)??!1).catch(()=>!1)}catch{return!1}})}})}contract(e,t=!1){let n=this.contracts.get(e);if(!n){if(this.contracts.size>=256)throw Error(`GUI contract limit exceeded`);let t=u({status:`inactive`,reason:`disabled`});n={live:[A(t[0]),t[1]],generation:0},this.contracts.set(e,n)}return t&&n.provider&&X(`IPC contract collision`),n}derive(e){if(e.status!==`active`)return;let t=[],n=[],r=[],a=[],o=[],s=[],c=this.session[0]();for(let i of e.contributions){if([`yuri.file-icon`,`yuri.theme`,`yuri.branding`,`yuri.work-status`].includes(i.registry))continue;let l=i.read();if(l!==void 0){if(i.registry===`yuri.page`){let e=he(l);if(s.some(t=>t.id===e.id))throw Error(`Duplicate yuri.page id`);s.push(e)}else if(i.registry===we.id){let n=l;n.enabled!==!1&&t.push({key:`${e.id}.${n.id}`,pluginId:e.id,title:n.title,description:n.description,bind:n.bind,hidden:n.hidden,run:()=>this.invoke(e,()=>n.run())})}else if(i.registry===k.id){let t=l;o.push({key:JSON.stringify([e.id,t.id]),pluginId:e.id,label:t.label,title:t.title,icon:Me(t.icon),busy:t.busy,pressed:t.pressed,actionable:!!t.run,run:t.run})}else if(i.registry===Ee.id&&c){let t=l,r=`${e.id}:`,i=this.layout(c).open.filter(e=>e.startsWith(r)).map(e=>e.slice(r.length));for(let r of t.list({session:c,screen:this.#e,open:i}))n.push({plugin:e,panel:t,tab:r})}else if(i.registry===be.id){let e=l;(e.page||e.section)&&X(`SettingsPage host sections`),e.title,r.push(e)}else if(i.registry===N.id){let e=l;e.menu===`session.panel`?(e.title,a.push(e)):X(`MenuItem.${e.menu}`)}}}for(let e of n)e.tab.title;e.commands=t,e.titlebarItems=o,e.panels=n,e.pages=s,e.settings=r,e.menus=a,i(()=>this.views[1](e=>e+1))}publish(){let e=i(this.session[0]),t=e?this.layouts.get(e.key):void 0,n=[...this.instances.values()],r=n.filter(e=>e.status===`active`),a=r.flatMap(e=>e.panels.map(({tab:n})=>{let r=n.file?this.filePath(n.file):void 0;return{key:`${e.id}:${n.id}`,pluginId:e.id,title:n.title,file:r,inline:!!(r&&this.fileViews.has(r)),active:t?.shown===!0&&t.active===`${e.id}:${n.id}`}}));this.snapshot=Object.freeze({plugins:Q(n.map(({id:e,revision:t,status:n,error:r,errorCode:i,iconError:a})=>({id:e,revision:t,status:n,error:r??a,...i?{errorCode:i}:{}}))),commands:Q(r.flatMap(e=>e.commands.filter(e=>!e.hidden))),panels:Q(a),titlebarItems:Q(r.flatMap(e=>e.titlebarItems.map(({run:e,...t})=>t))),pages:Q(r.flatMap(e=>e.pages.map(t=>({key:O(e.id,t.id),pluginId:e.id,title:t.title,icon:t.icon})))),settings:Q(r.flatMap(e=>e.settings.map(t=>({key:`${e.id}:${t.id}`,pluginId:e.id,title:t.title})))),menuItems:Q(r.flatMap(e=>e.menus.map(t=>({key:`${e.id}:${t.id}`,pluginId:e.id,title:t.title,description:t.description,run:()=>{this.invoke(e,()=>t.run())}})))),activePanel:t?.shown&&a.some(e=>e.key===t.active)?t.active:null,sessionKey:e?.key});for(let e of this.listeners)e()}invoke(e,t){if(!e.controller.signal.aborted)try{let n=o(e.owner??null,t);if(n instanceof Promise)return n.catch(t=>this.fail(e,t))}catch(t){this.fail(e,t)}}command(e){return[...this.instances.values()].flatMap(e=>e.commands).find(t=>t.key===e)}runCommand(e){return this.command(e)?.run()}runTitlebarItem(e){for(let t of this.instances.values()){let n=t.titlebarItems.find(t=>t.key===e);if(n?.run&&!n.busy)return this.invoke(t,n.run)}}linkHandler(e){let t=[];for(let e of this.instances.values())for(let n of e.contributions)if(n.registry===ye.id){let r=n.read();r&&t.push({instance:e,value:r})}for(let n of t.sort((e,t)=>(t.value.priority??0)-(e.value.priority??0)))try{if(n.value.match(e))return n}catch(e){this.fail(n.instance,e)}}navigateLink(e,t){if(this.ended)return!1;let n=me(t.href);if(!n||!pe(n.path))return this.openLink(t);let r=this.session[0]();if(!r||t.session&&(t.session.key!==r.key||t.session.server.id!==r.server.id))return!1;if(!this.options.focusFile)return this.openLink(t);let i=w(t.base??r.directory,n.path),a=n.line===void 0?``:`:${n.line}${n.column===void 0?``:`:${n.column}`}`;return this.invoke(e,()=>this.options.focusFile(i+a,r.directory)),!0}openLink(e){if(this.ended)return!1;let t={...e,session:e.session??this.session[0]()},n=this.linkHandler(t);return n?(this.invoke(n.instance,()=>n.value.open(t)),!0):!1}filePath(e,t=this.session[0]()?.directory){let n=L(e);return/^(?:\/|[a-z]:\/)/i.test(n)||!t?n:L(`${t}/${n}`)}registerFileView(e,t){if(this.ended)return()=>{};let n=this.filePath(e,t),r=this.fileViews.get(n)??0;this.fileViews.set(n,r+1),r===0&&this.changed(!0);let i=!1;return()=>{if(i||this.ended)return;i=!0;let e=(this.fileViews.get(n)??1)-1;if(e){this.fileViews.set(n,e);return}{let e=this.session[0](),t=e&&this.layouts.get(e.key);t?.active&&this.snapshot.panels.some(e=>e.key===t.active&&e.file===n)&&(t.shown=!1),this.fileViews.delete(n)}this.changed(!0)}}filePanel(e,t){let n=this.filePath(e,t);return this.snapshot.panels.find(e=>e.file===n&&e.inline)}panelVisible(e){let t=this.session[0]();if(!t)return!1;let n=this.panel(e)?.tab.file;if(n&&this.fileViews.has(this.filePath(n)))return!0;let r=this.layouts.get(t.key);return!!(r?.shown&&r.active===e)}layout(e){let t=this.layouts.get(e.key);if(!t){if(this.layouts.size>=128)throw Error(`GUI session layout limit exceeded`);t={open:[],active:null,shown:!1,scroll:new Map},this.layouts.set(e.key,t)}return t}openPanel(e,t,n){if(this.ended)return;let r=this.layout(t),i=r.active,a=r.shown,o=r.open.length;if(!r.open.includes(e)){if(r.open.length>=64)throw Error(`GUI panel tab limit exceeded`);r.open=[...r.open,e]}n?.tab!==`append`&&(r.active=e,r.shown=!(this.appearance[0]().narrow&&n?.background)),(i!==r.active||a!==r.shown||o!==r.open.length)&&this.changed(!0);let s=this.panel(e);t.key===this.session[0]()?.key&&s&&n?.tab!==`append`&&this.invoke(s.plugin,()=>s.panel.focus?.({...this.props(e),restored:!1}))}selectPanel(e){let t=this.session[0]();t&&this.openPanel(e,t)}closeFor(e,t){let n=this.layout(t),r=t.key===this.session[0]()?.key?this.panel(e):void 0;if(!n.open.includes(e)||r?.tab.pinned||r?.tab.closable===!1)return;let i=this.session[0](),a=r&&i?{tab:r.tab,session:i,screen:this.#e}:void 0;n.open=n.open.filter(t=>t!==e),n.active===e&&(n.active=n.open.at(-1)??null),this.changed(!0),r&&a&&this.invoke(r.plugin,()=>r.panel.close?.(a))}closePanel(e){let t=this.session[0]();t&&this.closeFor(e,t)}hidePanel(){let e=this.session[0]();if(!e)return;let t=this.layout(e);t.shown&&(t.shown=!1,this.changed(!0))}panel(e){return[...this.instances.values()].flatMap(e=>e.panels).find(t=>`${t.plugin.id}:${t.tab.id}`===e)}props(e,t=!1){let n=this.panel(e)?.tab,r=()=>(this.views[0](),this.panel(e)?.tab??n??X(`panel no longer listed`)),i=t?l(()=>{let e=r();return{tab:e,fields:Object.getPrototypeOf(e)===Object.prototype?Object.getOwnPropertyDescriptors(e):void 0}},void 0,{equals:Be}):void 0,a=i?()=>i().tab:r,o=()=>this.session[0]()??X(`panel without session`);return{get tab(){return a()},get session(){return o()},screen:this.#e}}mountPanel(e,t,r){let a=this.panel(e);if(!a)return()=>{};let o=new AbortController,s=()=>{let s=l(()=>{this.session[0](),this.changes[0](),this.views[0]();let t=this.panel(e)?.tab.file;return t&&this.files&&this.panelVisible(e)?{model:this.files,file:t}:void 0},void 0,{equals:(e,t)=>e?.model===t?.model&&e?.file===t?.file});n(()=>{let e=s();e&&(h(e.model.watch(e.file)),e.model.sync(e.file).catch(()=>{}))});let c=()=>i(()=>a.panel.render(this.props(e,!0)));return S(K.Provider,{value:r?{plugin:a.plugin.controller.signal,signal:o.signal,content:t,target:r}:void 0,get children(){return c()}})},c=this.mount(a.plugin,t,()=>S(xe.Provider,{value:{visible:()=>(this.changes[0](),this.panelVisible(e)),present:()=>(this.changes[0](),this.panelVisible(e)),placement:()=>this.appearance[0]().narrow?`mobile`:`side`,reserve:()=>!1,animate:()=>!1,sidebar:Z(`panel.sidebar`,{}),open:()=>{let e=this.session[0]();return e?a.plugin.context.layout.stored(e):[]}},get children(){return s()}})),u=()=>{this.panelMounts.delete(u),o.abort(),c()};return this.panelMounts.add(u),this.own(a.plugin,u)}mountSettings(e,t){for(let n of this.instances.values()){let r=n.settings.find(t=>`${n.id}:${t.id}`===e);if(r)return this.mount(n,t,()=>r.render({}))}return()=>{}}mountPage(e,t){if(this.appearance[0]().narrow&&!this.mobilePageNetworkReady[0]())throw new E(`GUI_PLUGIN_UNAVAILABLE`,`Mobile page Relay is not ready`);for(let n of this.instances.values()){let r=n.pages.find(t=>O(n.id,t.id)===e);if(r)return this.mount(n,t,()=>r.render())}return()=>{}}mountWorkStatus(e,t,n){let r=this.instances.get(e.pluginId);if(!r||!this.workStatus.contains(e)||this.ended)return{update(){},dispose(){}};let i=Y(n,n.sessionId&&n.directory?this.sessionReference({id:n.sessionId,directory:n.directory},n.scope):void 0,n.scope?JSON.stringify(n.scope.queryScope):this.options.transport),a=()=>{},o=()=>{},s=this.own(r,()=>{i.dispose(),o(),a()});return o=this.workStatus.subscribe(()=>{this.workStatus.contains(e)||s()}),a=this.mount(r,t,()=>e.render(i.props)),i.props.signal.aborted&&(o(),a()),{update:e=>{if(!i.matches(e)){s();return}i.update(e)},dispose:s}}mount(e,t,n){if(e.controller.signal.aborted)return()=>{};let r=()=>{},a,o=t=>{queueMicrotask(()=>this.fail(e,t))};try{r=_e(()=>S(j.Provider,{value:e.context,get children(){return a=s(),b(()=>i(n),o)}}),t)}catch(t){this.fail(e,t)}return this.own(e,()=>{$(a,t=>{e.error??=String(t)}),r(),t.replaceChildren()})}};export{Ve as GuiPluginHost};
1
+ import{f as e,n as t}from"./platform-CiUKDeXd.js";import{C as n,D as r,I as i,L as a,M as o,O as s,P as c,S as l,T as u,_ as d,a as f,b as p,c as m,j as h,n as g,o as _,r as v,s as y,t as ee,v as b,w as x,y as S}from"./vendor-opencode-client-BM2r1f0o.js";import{a as te}from"./vendor-tanstack-query-core-BSjXNgF_.js";import{b as ne,v as C}from"./runtime-file-resource-Bc_ss-sW.js";import{o as w}from"./path-utils-jGozTg9d.js";import{a as T,n as re}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{Dt as ie,ht as ae,mt as oe,y as se}from"./vendor-effect-X1Hqc7ba.js";import{t as E}from"./native-errors-06if6eu-.js";import{a as ce,i as le,n as ue,o as de,r as fe,s as D}from"./appearance-DFsI3pnP.js";import{i as pe,o as me}from"./fileReferenceParser-1HHDBUum.js";import{a as he,r as O}from"./pages-CYkE04ml.js";import{n as ge,t as _e}from"./vendor-solid-js-BBVUd3Hw.js";import{a as ve,c as ye,d as be,f as k,g as A,h as j,i as M,l as N,m as xe,n as Se,o as P,p as F,r as Ce,s as we,t as Te,u as Ee}from"./vendor-opencode-plugin-ZhpPgHCL.js";var I={"@opencode/plugin/gui":P,"@opencode/plugin/gui/main":P,"@opencode/plugin/gui/file":ve,"@opencode/plugin/gui/review":M,"@opencode/plugin/gui/browser":Ce,"@opencode/plugin/rpc":Te,"@opencode/schema/rpc":Se,"@opencode/client":v,"@opencode/client/effect":g,"@opencode/client/solid":ee,effect:se,"solid-js":c,"solid-js/web":ge,"solid-js/store":y},De=new Set(`assert assert/strict async_hooks buffer child_process cluster console constants crypto dgram diagnostics_channel dns dns/promises domain events fs fs/promises http http2 https inspector inspector/promises module net os path path/posix path/win32 perf_hooks process punycode querystring readline readline/promises repl stream stream/consumers stream/promises stream/web string_decoder sys timers timers/promises tls trace_events tty url util util/types v8 vm wasi worker_threads zlib`.split(` `));function Oe(){let e=new Proxy(function(){},{get:(t,n)=>n===`then`?void 0:n===Symbol.hasInstance?()=>!1:n===Symbol.toPrimitive||n===`toString`?()=>`[main-only module]`:e,apply:()=>e,construct:()=>e,set:()=>!0});return e}function ke(e,t){if(e.length>16777216)throw Error(`GUI bundle exceeds 16 MiB`);let n={exports:{}};Function(`require`,`module`,`exports`,e)(e=>{if(Object.hasOwn(I,e))return I[e];if(e===`electron`||e.startsWith(`node:`)||De.has(e))return Oe();throw Error(`Unsupported GUI shared module: ${e}`)},n,n.exports);let r=n.exports,i=r&&typeof r==`object`&&`default`in r?r.default:r;if(!i||typeof i!=`object`)throw Error(`GUI bundle must default-export Plugin.define`);if((!(`setup`in i)||typeof i.setup!=`function`)&&!(t&&`main`in i&&typeof i.main==`function`))throw new E(`GUI_PLUGIN_UNSUPPORTED`,`This host requires a window setup; main-only plugins are unsupported`);if(`os`in i&&i.os!==void 0){if(!t)throw new E(`GUI_PLUGIN_UNSUPPORTED`,`OS-restricted plugins require the native GUI host`);if(!Array.isArray(i.os)||!i.os.includes(t))throw new E(`GUI_PLUGIN_UNSUPPORTED`,`GUI plugin is unavailable on this OS`)}if(`main`in i&&i.main!==void 0&&typeof i.main!=`function`)throw Error(`Invalid GUI main entry`);if(`stores`in i&&i.stores!==void 0){if(!i.stores||typeof i.stores!=`object`||Array.isArray(i.stores))throw Error(`Invalid GUI stores`);for(let e of Object.values(i.stores))if(!e||typeof e!=`object`||!(`schema`in e)||!ie(e.schema)||!(`scope`in e)||![`global`,`session`].includes(String(e.scope))||!(`initial`in e))throw Error(`Invalid GUI store declaration`)}if(`i18n`in i&&i.i18n!==void 0){if(!i.i18n||typeof i.i18n!=`object`||Array.isArray(i.i18n))throw Error(`Invalid GUI locale catalog`);for(let e of Object.values(i.i18n))if(!e||typeof e!=`object`||Array.isArray(e)||Object.values(e).some(e=>typeof e!=`string`))throw Error(`GUI locales must be inline string dictionaries`)}return i}function L(t){let n=t;if(/^file:/i.test(n)){let e=new URL(n);n=`${e.hostname&&e.hostname!==`localhost`?`//${e.hostname}`:``}${decodeURIComponent(e.pathname)}`,/^\/[a-z]:\//i.test(n)&&(n=n.slice(1))}let r=e(n)??``;return r===`.`?``:r}var R=e=>/^(?:\/|[a-z]:\/)/i.test(e),z=()=>{throw Error(`Unsupported GUI file API: tree`)},B=class extends Error{},V=e=>new TextEncoder().encode(e).byteLength,Ae=class{files;query;transport;root;api;ended=!1;states=new Map;inflight=new Map;watches=new Map;apiLeases=new Map;registeredOwners=new WeakSet;endedOwners=new WeakSet;leaseCount=0;rerun=new Set;selections=new Map;scrolls=new Map;subscriptions=new Map;constructor(e,t,n,r){this.files=e,this.query=t,this.transport=n,this.root=r,this.root=L(r),this.api={root:this.root,ready:()=>!this.ended,resolve:e=>this.resolve(e),absolute:R,get:e=>{let t=this.track(e,`file`);return this.states.get(t)},missing:e=>{let t=this.track(e,`missing`);return this.states.get(t)?.notFound===!0},sync:(e,t)=>{let n=s();return this.ended||n&&this.endedOwners.has(n)?Promise.resolve():(this.acquireApiLease(e),this.sync(e,t?.force))},unwatch:e=>this.releaseApiLease(s(),this.resolve(e)),exists:async e=>{try{if(this.files.statFile)return(await this.query.fetchQuery(this.statOptions(e))).isFile;let t=this.full(e);return(await this.files.listDirectory(t.slice(0,t.lastIndexOf(`/`)))).entries.some(e=>!e.isDirectory&&L(e.path)===t)}catch{return!1}},search:async(e,t)=>{if(t?.kind===`any`)throw Error(`Unsupported GUI file search: directories`);t?.signal?.throwIfAborted();let r=await this.query.fetchQuery({queryKey:[`gui-plugin-files`,n,this.root,`search`,e,t?.limit],gcTime:3e4,queryFn:async({signal:n})=>(n.throwIfAborted(),this.files.search({directory:this.root,query:e,maxResults:t?.limit??100}))});if(t?.signal?.throwIfAborted(),this.ended)throw new DOMException(`GUI file model was disposed`,`AbortError`);return r.map(e=>this.resolve(e.path))},selection:{get:e=>this.selections.get(this.track(e,`selection`)),set:(e,t)=>{let n=this.resolve(e),r=this.selections.get(n);r===t||r&&t&&r.start===t.start&&r.end===t.end&&r.side===t.side&&r.endSide===t.endSide||(this.selections.set(n,t),this.trim(this.selections,`selection`),this.changed(n,`selection`))}},scroll:{get:e=>this.scrolls.get(this.track(e,`scroll`))??{},set:(e,t)=>{let n=this.resolve(e),r=this.scrolls.get(n),i={...r,...t};(r?.top!==i.top||r?.left!==i.left)&&(this.scrolls.set(n,i),this.trim(this.scrolls,`scroll`),this.changed(n,`scroll`))}},tree:{list:z,state:z,sync:z,expand:z,collapse:z}}}resolve(e){let t=L(e);if(!R(t))return t;if(t===this.root)return``;let n=this.root.endsWith(`/`)?this.root:`${this.root}/`;return t.startsWith(n)?t.slice(n.length):t}full(e){let t=this.resolve(e);return R(t)?t:L(`${this.root}/${t}`)}input(e){return{scopeDirectory:this.root,path:this.full(e),options:{directory:this.root}}}statOptions(e){return{...ne(this.files,this.input(e),this.transport),gcTime:3e4}}track(e,t){let n=this.resolve(e),i=r();if(!i||this.ended)return n;let a=`${t}:${n}`,s=this.subscriptions.get(a);s||(s={revision:u(0),listeners:new Set},this.subscriptions.set(a,s));let c=s;return c.listeners.has(i)||(c.listeners.add(i),o(i,()=>h(()=>{c.listeners.delete(i),!c.listeners.size&&this.subscriptions.get(a)===c&&this.subscriptions.delete(a)}))),c.revision[0](),n}changed(e,t){this.ended||this.subscriptions.get(`${t}:${e}`)?.revision[1](e=>e+1)}trim(e,t){for(;e.size>64;){let n=e.keys().next().value;e.delete(n),this.changed(n,t)}}setState(e,t){let n=this.states.get(e);n?.content?.content===t.content?.content&&n?.content?.type===t.content?.type&&(t.content=n?.content),!(n&&n.loaded===t.loaded&&n.loading===t.loading&&n.error===t.error&&n.notFound===t.notFound&&n.content===t.content)&&(this.states.set(e,t),d(()=>{this.changed(e,`file`),n?.notFound===!0!=(t.notFound===!0)&&this.changed(e,`missing`)}))}acquireApiLease(e){let t=s();if(this.ended||t&&this.endedOwners.has(t)||!this.files.statFile)return;let n=this.resolve(e),r=this.apiLeases.get(t);if(r?.has(n))return;if(this.leaseCount>=256)throw Error(`GUI file consumer limit exceeded`);let i=this.watch(n);r||(r=new Map,this.apiLeases.set(t,r)),r.set(n,i),this.leaseCount++,t&&!this.registeredOwners.has(t)&&(this.registeredOwners.add(t),h(()=>{`fn`in t||this.endedOwners.add(t),this.registeredOwners.delete(t);for(let e of[...this.apiLeases.get(t)?.keys()??[]])this.releaseApiLease(t,e)}))}releaseApiLease(e,t){let n=this.apiLeases.get(e),r=n?.get(t);r&&(n.delete(t),this.leaseCount--,n.size||this.apiLeases.delete(e),r())}reserve(e){if(!this.states.has(e)){if(this.states.size>=64){let e=[...this.states.keys()].find(e=>!this.watches.has(e)&&!this.inflight.has(e));if(!e)throw Error(`GUI file cache limit exceeded`);let t=this.states.get(e)?.notFound===!0;this.states.delete(e),d(()=>{this.changed(e,`file`),t&&this.changed(e,`missing`)})}this.states.set(e,{path:e,name:e.split(`/`).at(-1)??e})}}async sync(e,t=!1){if(this.ended)return;let n=this.resolve(e);if(this.inflight.has(n))return t&&this.rerun.add(n),this.inflight.get(n);if(!t&&this.states.get(n)?.loaded&&!this.states.get(n)?.error)return;this.reserve(n);let r=this.states.get(n);this.setState(n,{...r,path:n,name:n.split(`/`).at(-1)??n,loading:!r?.loaded&&!this.watches.get(n)?.failed});let i=(async()=>{try{do{this.rerun.delete(n);let e=this.watches.get(n),r=e?.epoch;try{let i=C(this.files,this.input(n),this.transport),a=await this.query.fetchQuery({...i,gcTime:3e4,staleTime:t?0:3e4,queryFn:async()=>{if(!this.files.readFile)throw Error(`File content reads are unavailable in this runtime`);let e=await this.files.readFile(this.full(n),{directory:this.root});if(e.exists===!1)throw new B(`File does not exist`);let t=e.content;if(V(t)>131072)throw Error(`GUI file preview exceeds 128 KiB`);return t}});if(this.ended)return;if(V(a)>131072)throw Error(`GUI file preview exceeds 128 KiB`);(!e||e.epoch===r&&!e.failed)&&this.setState(n,{path:n,name:n.split(`/`).at(-1)??n,loaded:!0,loading:!1,content:{type:`text`,content:a}})}catch(t){if(this.ended)return;if((!e||e.epoch===r&&!e.failed)&&this.setState(n,{...this.states.get(n),loading:!1,...t instanceof B?{notFound:!0}:{},error:String(t)}),!this.rerun.has(n))throw t}t=!0}while(!this.ended&&this.rerun.has(n))}finally{this.inflight.delete(n),this.rerun.delete(n)}})();return this.inflight.set(n,i),i}watch(e){if(this.ended||!this.files.statFile)return()=>{};let t=this.resolve(e),n=this.watches.get(t);if(!n){if(this.watches.size>=64)throw Error(`GUI file watch limit exceeded`);this.reserve(t),n={count:0,epoch:0,failed:!1,stop:()=>{}};let e=n;this.watches.set(t,e);let r,i=new te(this.query,{...this.statOptions(t),refetchInterval:2e3,refetchIntervalInBackground:!1}),a=i.subscribe(n=>{if(this.ended||this.watches.get(t)!==e||n.isFetching)return;if(n.isError||n.isSuccess&&!n.data.isFile){e.failed=!0,e.epoch++,this.setState(t,{...this.states.get(t),loading:!1,notFound:n.isSuccess?!0:this.states.get(t)?.notFound,error:n.isError?String(n.error):`File does not exist`});return}if(!n.data||!n.isSuccess)return;let i=`${n.data.size}:${n.data.mtimeMs??``}`,a=e.failed||r!==void 0&&i!==r;e.failed=!1,r=i,a&&(e.epoch++,this.sync(t,!0).catch(()=>{}))});e.stop=()=>{a(),i.destroy()},this.states.get(t)?.loaded&&this.sync(t,!0).catch(()=>{})}n.count++;let r=!0;return()=>{r&&(r=!1,--n.count===0&&this.watches.get(t)===n&&this.stopWatch(t))}}stopWatch(e){this.watches.get(e)?.stop(),this.watches.delete(e)}dispose(){this.ended=!0;for(let e of this.watches.values())e.stop();this.watches.clear(),this.apiLeases.clear(),this.leaseCount=0,this.rerun.clear(),this.states.clear(),this.inflight.clear(),this.selections.clear(),this.scrolls.clear(),this.subscriptions.clear()}},H=256,U=2097152,W=e=>structuredClone(m(e)),je=class{backend;transport;memory=new Map;resets=new Map;constructor(e,t){this.backend=e,this.transport=t}forPlugin(e,t){let n=(t,n=`global`)=>{if(typeof n==`object`&&`session`in n&&!n.session.location)throw Error(`Unsupported GUI storage: session location is unknown`);let r=n===`global`?n:`session`in n?[n.session.server.id,n.session.id,n.session.location]:[n.server,n.directory];return`yuri.gui-plugin.${JSON.stringify([this.transport,e,r,t])}`},r=e=>{if(t.aborted)throw Error(`GUI plugin has been disposed`);if(e!==void 0)throw Error(`Unsupported GUI storage migration: from`)},i=new Map;return{store:(e,a)=>{r(a.from);let o=n(e,a.scope),s=i.get(o);if(s)return s;if(i.size>=H)throw Error(`GUI plugin store limit exceeded`);let c=oe(a.schema),l=ae(a.schema),d=c(l(W(a.initial)));if(JSON.stringify(l(d)).length>U)throw Error(`GUI plugin store exceeds 2 MiB`);let f=d,p=this.backend.getItem(o);if(p!==null&&p.length<=U)try{f=c(JSON.parse(p))}catch{f=d}let[m,h]=u(f),g=e=>{r();let t=JSON.stringify(l(W(e)));if(t.length>U)throw Error(`GUI plugin store exceeds 2 MiB`);let n=c(JSON.parse(t));this.backend.setItem(o,t),h(()=>n)},_={get value(){return m()},ready:()=>!0,set:g,update:e=>{let t=W(m());if(e(t)!==void 0)throw Error(`Store update must not return a replacement`);g(t)}},v=()=>h(()=>W(d)),y=this.resets.get(o)??new Set;return y.add(v),this.resets.set(o,y),t.addEventListener(`abort`,()=>{y.delete(v),y.size||this.resets.delete(o),i.clear()},{once:!0}),i.set(o,_),_},memory:(e,t)=>{r();let i=n(e),a=this.memory.get(i);if(a)return[a[0],e=>{r(),a[1](e)}];if(this.memory.size>=H)throw Error(`GUI plugin memory store limit exceeded`);if(JSON.stringify(t.initial).length>U)throw Error(`GUI plugin memory exceeds 2 MiB`);let[o,s]=f(W(t.initial)),c=[o,e=>{r();let t=W(m(o));if(e(t)!==void 0)throw Error(`Memory update must not return a replacement`);if(JSON.stringify(t).length>U)throw Error(`GUI plugin memory exceeds 2 MiB`);s(_(t))}];return this.memory.set(i,[o,e=>{let t=W(m(o));if(e(t)!==void 0)throw Error(`Memory update must not return a replacement`);if(JSON.stringify(t).length>U)throw Error(`GUI plugin memory exceeds 2 MiB`);s(_(t))}]),c},remove:(e,t)=>{r(t?.from);let i=n(e,t?.scope);this.backend.removeItem(i);for(let e of this.resets.get(i)??[])e()}}}dispose(){this.memory.clear(),this.resets.clear()}};function Me(e){if(typeof e!=`string`||e.length>2097152)return;let t=e.trim();if(t)try{if(t.startsWith(`<`))return D(t);if(!/^data:/i.test(t))return t;let e=/^data:image\/(svg\+xml|png|jpeg|gif|webp|avif|x-icon|vnd\.microsoft\.icon)(?:;charset=utf-8)?(;base64)?,([\s\S]+)$/i.exec(t);if(!e)return;let[,n,r,i]=e;if(r&&!/^[A-Za-z0-9+/]+={0,2}$/.test(i))return;if(n.toLowerCase()===`svg+xml`){let e=r?new TextDecoder(`utf-8`,{fatal:!0}).decode(Uint8Array.from(atob(i),e=>e.charCodeAt(0))):decodeURIComponent(i);return D(e)}return!r||!atob(i).length?void 0:`data:image/${n.toLowerCase()};base64,${i}`}catch{return}}var G=e=>e===`yuri.exportPDF`||e===`yuri.exportLongImage`,Ne=class{api;probe;clients=new Map;ended=!1;constructor(e){this.api=e}use(e,t){let n=this.clients.get(t),r=n?.get(e);if(r)return r.live;let[i,a]=u(this.api&&!t.aborted&&!this.ended?{status:`pending`}:{status:`inactive`,reason:`disabled`}),o=()=>{a({status:`inactive`,reason:`disabled`}),t.removeEventListener(`abort`,o),this.clients.delete(t)},s={live:A(i),stop:o};if(this.ended||t.aborted||(n||(n=new Map,this.clients.set(t,n)),n.set(e,s),t.addEventListener(`abort`,o,{once:!0}),!this.api))return s.live;let c=this.api;return this.probe??=Promise.resolve().then(()=>c.capabilities()),this.probe.then(n=>{if(this.ended||t.aborted)return;let r=e===`yuri.exportPDF`?`exportPDF`:`exportLongImage`;if(n.version!==1||!n[r]){a({status:`inactive`,reason:`disabled`});return}let o=async(e,n={})=>{if(this.ended||t.aborted||i().status!==`active`)return{status:`cancelled`};let o=AbortSignal.any([t,...n.signal?[n.signal]:[]]);try{return await c[r](e,{...n,signal:o})}catch(e){throw e&&typeof e==`object`&&`code`in e&&e.code===`EXPORT_UNSUPPORTED`&&a({status:`inactive`,reason:`failed`}),e}},s=Object.freeze(e===`yuri.exportPDF`?{version:1,limits:n.limits,exportPDF:o}:{version:1,limits:n.limits,exportLongImage:o});a({status:`active`,generation:1,value:s})}).catch(()=>{!this.ended&&!t.aborted&&a({status:`inactive`,reason:`failed`})}),s.live}dispose(){this.ended=!0;for(let e of this.clients.values())for(let t of e.values())t.stop();this.clients.clear()}};function Pe(e,t){let n=new Map,r=Object.freeze({dismiss(){}});return e.addEventListener(`abort`,()=>{for(let e of[...n.values()])e.handle.dismiss()},{once:!0}),Object.freeze({show(i){if(e.aborted)return r;if(!t)throw new E(`GUI_PLUGIN_UNSUPPORTED`,`GUI toast is unavailable`);if(!i||typeof i!=`object`)throw new E(`GUI_PLUGIN_INVALID_INPUT`,`Expected toast options`);let{title:a,description:o,variant:s=`default`,duration:c=5e3,persistent:l=!1,icon:u,actions:d}=i;if(typeof a!=`string`||o!==void 0&&typeof o!=`string`||![`default`,`success`,`error`,`loading`].includes(s)||typeof l!=`boolean`||typeof c!=`number`||!Number.isFinite(c)||c<0)throw new E(`GUI_PLUGIN_INVALID_INPUT`,`Invalid toast options`);if(u!==void 0||d!==void 0)throw new E(`GUI_PLUGIN_UNSUPPORTED`,`GUI toast icon/actions are unsupported`);if(e.aborted)return r;let f=JSON.stringify([a,o??null,s,c,l]),p=n.get(f),m=()=>{let e=n.get(f);!e||e.id!==h||(clearTimeout(e.timer),n.delete(f))},h=(s==="default"?t:t[s])(a,{id:p?.id,description:o,duration:l?1/0:c,onDismiss:m,onAutoClose:m}),g=p?.handle??Object.freeze({dismiss(){m(),t.dismiss(h)}});clearTimeout(p?.timer);let _=s===`loading`&&!l?setTimeout(()=>g.dismiss(),c):void 0;return n.set(f,{id:h,handle:g,timer:_}),g}})}var Fe=T(`YuriMedia`);async function Ie(e){let n=/\.html?$/i.test(e.name)?`text/html`:`text/plain`,r=new Blob([e.content],{type:n});if(t()){if(!re.isPluginAvailable(`YuriMedia`))throw new E(`GUI_PLUGIN_UNSUPPORTED`,`Native file saving is unavailable`);if(r.size>33554432)throw new E(`GUI_PLUGIN_INVALID_INPUT`,`File exceeds maximum size`);let t=await new Promise((e,t)=>{let n=new FileReader;n.onload=()=>{if(typeof n.result!=`string`){t(Error(`Failed to encode file`));return}e(n.result.slice(n.result.indexOf(`,`)+1))},n.onerror=()=>t(n.error??Error(`Failed to encode file`)),n.readAsDataURL(r)});return!(await Fe.saveFile({dataBase64:t,mimeType:n,filename:e.name})).cancelled}let i=URL.createObjectURL(r),a=document.createElement(`a`);try{return a.href=i,a.download=e.name,document.body.append(a),a.click(),!0}finally{a.remove(),setTimeout(()=>URL.revokeObjectURL(i),1e3)}}var K=p();function Le(e){return{version:1,register(t){let n=a(K);if(!n||n.plugin!==e||n.signal.aborted||e.aborted)throw Error(`Preview actions require the owning mounted panel`);let r=new AbortController,i=AbortSignal.any([e,n.signal,r.signal]),o,s=()=>{i.removeEventListener(`abort`,s),r.abort(),o?.remove()};h(s),i.addEventListener(`abort`,s,{once:!0});try{o=t.render({element:t.element,signal:i,async snapshot(e={}){let r=AbortSignal.any([i,...e.signal?[e.signal]:[]]);if(r.throwIfAborted(),!n.content.contains(t.element)||n.target.contains(t.element))throw Error(`Preview capture region is no longer in its owning panel`);let a=await t.capture({...e,signal:r});if(r.throwIfAborted(),!n.content.contains(t.element))throw Error(`Preview capture region was replaced`);return a}}),i.throwIfAborted(),n.target.append(o)}catch(e){throw s(),e}return s}}}var Re=`yuri.work-status`;function q(e,t){return e===t||!!(e&&t&&Object.keys(e).length===Object.keys(t).length&&Object.keys(e).every(n=>e[n]===t[n]))}var J=e=>e&&Object.freeze({...e});function Y(e,t,n){let r=new AbortController,[i,a]=u(!0),[o,s]=u(J(e.project),{equals:q}),[c,l]=u(J(e.worktree),{equals:q}),[f,p]=u(Object.freeze({...e.git}),{equals:q}),[m,h]=u(e.placement);return{props:Object.freeze({session:t,directory:e.directory,runtimeId:n,signal:r.signal,get active(){return i()},get project(){return o()},get worktree(){return c()},get git(){return f()},get placement(){return m()}}),matches:t=>t.sessionId===e.sessionId&&t.directory===e.directory&&t.scope===e.scope,update(e){r.signal.aborted||d(()=>{s(J(e.project)),l(J(e.worktree)),p(Object.freeze({...e.git})),h(e.placement)})},dispose(){r.signal.aborted||(a(!1),r.abort())}}}var ze=class{plugins=new Map;order=new Map;snapshot=Object.freeze([]);generation=0;listeners=new Set;subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getSnapshot=()=>this.snapshot;setOrder(e){e.length===this.order.size&&e.every((e,t)=>this.order.get(e)===t)||(this.order=new Map(e.map((e,t)=>[e,t])),this.publish())}replace(e,t,n){let r=this.plugins.get(e)??[],i=new Set,a=n.map(n=>{if(!n||typeof n!=`object`||!(`id`in n)||typeof n.id!=`string`||!n.id.trim()||n.id.length>128||i.has(n.id)||!(`render`in n)||typeof n.render!=`function`||`order`in n&&n.order!==void 0&&(typeof n.order!=`number`||!Number.isFinite(n.order)))throw Error(`Invalid or duplicate yuri.work-status contribution`);i.add(n.id);let a=JSON.stringify([e,n.id]),o=`order`in n&&typeof n.order==`number`?n.order:0,s=n.render,c=r.find(e=>e.key===a),l=c&&c.revision===t&&c.render===s?c.generation:++this.generation;return c&&c.revision===t&&c.render===s&&c.order===o?c:Object.freeze({key:a,pluginId:e,revision:t,generation:l,order:o,render:s})});a.length?this.plugins.set(e,a):this.plugins.delete(e),this.publish()}contains(e){return this.plugins.get(e.pluginId)?.some(t=>t.key===e.key&&t.generation===e.generation)??!1}remove(e){this.plugins.delete(e)&&this.publish()}dispose(){this.plugins.clear(),this.publish(),this.listeners.clear()}publish(){let e=[...this.plugins.values()].flat().sort((e,t)=>e.order-t.order||(this.order.get(e.pluginId)??2**53-1)-(this.order.get(t.pluginId)??2**53-1));if(!(e.length===this.snapshot.length&&e.every((e,t)=>e===this.snapshot[t]))){this.snapshot=Object.freeze(e);for(let e of this.listeners)i(e)}}},X=e=>{throw new E(`GUI_PLUGIN_UNSUPPORTED`,`Unsupported GUI host API: ${e}`)};function Z(e,t){return new Proxy(t,{get:(t,n)=>n in t?Reflect.get(t,n):X(`${e}.${String(n)}`)})}var Q=e=>Object.freeze(e.map(e=>Object.freeze(e)));function Be(e,t){if(!e.fields||!t.fields)return!1;let n=Reflect.ownKeys(e.fields);return n.length===Reflect.ownKeys(t.fields).length&&n.every(n=>{let r=e.fields[n],i=t.fields[n];return i!==void 0&&`value`in r&&`value`in i&&Object.is(r.value,i.value)&&r.enumerable===i.enumerable&&r.configurable===i.configurable&&r.writable===i.writable})}function $(e,t){if(e){for(let n of e.owned??[])$(n,t);e.cleanups&&=e.cleanups.map(e=>()=>{try{Promise.resolve(e()).catch(t)}catch(e){t(e)}})}}var Ve=class{options;fileIcons=new de;appearanceCatalog=new le;workStatus=new ze;instances=new Map;listeners=new Set;panelMounts=new Set;fileViews=new Map;changes=u(0);views=u(0);session=u();currentPage=u();mobilePageNetworkReady=u(!1);appearance;layouts=new Map;files;storage;ended=!1;contracts=new Map;snapshot=Object.freeze({plugins:Object.freeze([]),commands:Object.freeze([]),titlebarItems:Object.freeze([]),panels:Object.freeze([]),pages:Object.freeze([]),settings:Object.freeze([]),menuItems:Object.freeze([]),activePanel:null});#e;viewExports;constructor(e){this.options=e,this.viewExports=new Ne(e.viewExport),this.appearance=u({locale:e.locale,mode:e.mode,narrow:e.narrow}),this.storage=new je(e.storage,e.transport);let t=()=>(this.session[0](),this.files?.api??X(`screen.file without a session`));this.#e=Z(`screen`,{get file(){return t()}})}subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getSnapshot=()=>this.snapshot;changed(e=!1){let t=this.snapshot;this.changes[1](e=>e+1),e&&t===this.snapshot&&this.publish()}setSession(e){if(this.ended)return;let t=this.session[0]();if(t?.id===e?.id&&t?.directory===e?.directory)return;if(!e)for(let e of[...this.panelMounts])e();this.files?.dispose(),this.files=e?new Ae(this.options.files,this.options.queryClient,this.options.transport,e.directory):void 0;let n=e?this.sessionReference(e):void 0,r=this.snapshot;this.session[1](n),r===this.snapshot&&this.publish()}sessionReference(e,t){let n=t?JSON.stringify(t.queryScope):this.options.transport,r=Z(`session.server`,{id:n,name:t?.location.hostId??this.options.transport,...t?{}:{client:this.options.client}});return Object.freeze(Z(`session`,{id:e.id,directory:e.directory,key:t?JSON.stringify([n,e.id]):`${this.options.transport}\n${e.id}`,tab:e.id,server:r,pending:!1,visit:{},location:t?Object.freeze({...t.location}):{directory:e.directory}}))}setAppearance(e){if(this.ended)return;let t=this.appearance[0]();(t.locale!==e.locale||t.mode!==e.mode||t.narrow!==e.narrow)&&this.appearance[1]({...e})}setPage(e){this.ended||this.currentPage[1](e)}setMobilePageNetworkReady(e){this.mobilePageNetworkReady[1](!this.ended&&e)}install(e,t,r){if(this.options.mobileNetworkRequired&&!this.mobilePageNetworkReady[0]()&&!this.ended)throw new E(`GUI_PLUGIN_UNAVAILABLE`,`Mobile plugin Relay is not ready`);let a=this.instances.get(e);if(this.ended||a?.status===`active`&&a.revision===t.revision&&a.native?.active!==!1){r?.dispose();return}a&&(this.instances.delete(e),this.release(a));let c={id:e,native:r,revision:t.revision,controller:new AbortController,status:`active`,cleanups:new Set,contributions:new Set,iconChanges:u(0),appearanceChanges:u(0),workStatusChanges:u(0),commands:[],titlebarItems:[],panels:[],pages:[],settings:[],menus:[]};this.instances.set(e,c);try{if(e===`yuri`||e.startsWith(`yuri.`))throw Error(`The yuri namespace is reserved to the host`);let a=ke(t.code,r?.activation.os);x(e=>{c.dispose=e,c.root=s(),b(()=>S(j.Provider,{value:c.context=this.context(c,a,t.options),get children(){c.owner=s();let e=i(()=>a.setup?.(c.context));if(typeof e==`function`)c.cleanups.add(()=>{Promise.resolve(e()).catch(e=>{c.error=String(e)})});else if(e!==void 0)throw e&&typeof e==`object`&&`then`in e&&Promise.resolve(e).catch(()=>{}),Error(`GUI setup must be synchronous and return only cleanup`);return null}}),e=>this.fail(c,e)),c.controller.signal.aborted||o(c.owner,()=>n(()=>{if(c.iconChanges[0](),!c.controller.signal.aborted)try{let e=[...c.contributions].filter(e=>e.registry===ce).map(e=>e.read()).filter(e=>e!==void 0);this.fileIcons.replace(c.id,e),c.iconError!==void 0&&i(()=>{c.iconError=void 0,this.publish()})}catch(e){i(()=>{this.fileIcons.remove(c.id),c.iconError=e instanceof Error?e.message:String(e),this.publish()})}})),c.controller.signal.aborted||o(c.owner,()=>n(()=>{if(c.appearanceChanges[0](),!c.controller.signal.aborted)try{let e=e=>[...c.contributions].filter(t=>t.registry===e).map(e=>e.read()).filter(e=>e!==void 0);this.appearanceCatalog.replace(c.id,e(fe),e(ue),c.native?.activation.capabilities?.dockIcon===!0)}catch(e){i(()=>this.fail(c,e))}})),c.controller.signal.aborted||o(c.owner,()=>n(()=>{if(c.workStatusChanges[0](),!c.controller.signal.aborted)try{let e=[...c.contributions].filter(e=>e.registry===Re).map(e=>e.read()).filter(e=>e!==void 0);this.workStatus.replace(c.id,c.revision,e)}catch(e){i(()=>this.fail(c,e))}})),c.controller.signal.aborted||o(c.owner,()=>n(()=>{this.changes[0](),this.session[0](),this.appearance[0]();try{this.derive(c)}catch(e){i(()=>this.fail(c,e))}i(()=>this.publish())}))})}catch(e){this.fail(c,e)}this.changed(!0)}release(e){e.controller.abort(),e.native?.dispose();for(let t of[...e.cleanups])try{t()}catch(t){e.error??=String(t)}e.cleanups.clear(),$(e.root,t=>{e.error??=String(t)});try{e.dispose?.()}catch(t){e.error??=String(t)}e.contributions.clear(),e.commands=[],e.titlebarItems=[],e.panels=[],e.pages=[],e.settings=[],e.menus=[],this.fileIcons.remove(e.id),this.appearanceCatalog.remove(e.id),this.workStatus.remove(e.id);for(let t of this.contracts.values())t.provider===e&&(t.provider=void 0,t.live[1]({status:`inactive`,reason:e.status===`failed`?`failed`:`disabled`}))}fail(e,t){e.status!==`failed`&&this.instances.get(e.id)===e&&(e.status=`failed`,e.error=t instanceof Error?t.message:String(t),t instanceof E&&(e.errorCode=t.code),this.release(e),this.publish())}uninstall(e){let t=this.instances.get(e);if(t){this.instances.delete(e),this.release(t);for(let t of this.layouts.values())t.open=t.open.filter(t=>!t.startsWith(`${e}:`)),t.active?.startsWith(`${e}:`)&&(t.active=null);this.changed(!0)}}dispose(){this.ended||(this.ended=!0,d(()=>{for(let e of[...this.instances.keys()])this.uninstall(e)}),this.viewExports.dispose(),this.files?.dispose(),this.fileIcons.dispose(),this.appearanceCatalog.dispose(),this.workStatus.dispose(),this.storage.dispose(),this.layouts.clear(),this.fileViews.clear(),this.contracts.clear(),this.listeners.clear())}async setDockIcon(e,t){let n=this.instances.get(e),r=n?.native;if(!r?.active||!r.activation.capabilities?.dockIcon)return X(`Dock icon`);try{await r.setDockIcon(t)}catch(e){throw t!==null&&n&&this.fail(n,e),e}}own(e,t){let n=!0,r=()=>{n&&(n=!1,e.cleanups.delete(r),t())};return e.controller.signal.aborted||a(F)?.ended?(r(),r):(e.cleanups.add(r),s()&&h(r),r)}list(e){this.changes[0]();let t=[];for(let n of this.instances.values())if(n.status===`active`){for(let r of n.contributions)if(r.registry===e.id){let e=r.read();e!==void 0&&t.push(e)}}return t}context(e,t,r){let o=this.storage.forPlugin(e.id,e.controller.signal),c=Object.fromEntries(Object.entries(t.stores??{}).map(([e,t])=>[e,t.scope===`global`?o.store(e,{...t,scope:`global`}):n=>o.store(e,{...t,scope:{session:n}})])),u=(e,n)=>{let r=this.appearance[0]().locale;return(t.i18n?.[r]?.[e]??t.i18n?.[r.split(`-`)[0]]?.[e]??t.i18n?.en?.[e]??e).replace(/\{\{(\w+)\}\}/g,(e,t)=>String(n?.[t]??e))},d=Z(`layout`,{narrow:()=>this.appearance[0]().narrow,ready:()=>!!this.session[0](),open:(t,n,r)=>{e.controller.signal.aborted||this.openPanel(t,n,r)},close:(t,n)=>{e.controller.signal.aborted||this.closeFor(t,n)},toggle:(e,t)=>d.state(e,t)===`visible`?d.close(e,t):d.open(e,t),hide:(t,n)=>{if(e.controller.signal.aborted)return;let r=this.layout(n);r.active===t&&r.shown&&(r.shown=!1,this.changed())},state:(e,t)=>{this.changes[0]();let n=this.layout(t);return n.active===e?n.shown?`visible`:`active`:n.open.includes(e)?`open`:`closed`},stored:t=>(this.changes[0](),this.layout(t).open.filter(t=>t.startsWith(`${e.id}:`)).map(t=>t.slice(e.id.length+1))),side:{opened:e=>(this.changes[0](),this.layout(e).shown),toggle:t=>{if(e.controller.signal.aborted)return;let n=this.layout(t);n.shown=!n.shown,this.changed()},menu:()=>this.list(N).filter(e=>e.menu===`session.panel`).sort((e,t)=>(e.order??0)-(t.order??0))},scroll:{get:(e,t)=>(this.changes[0](),this.layout(e).scroll.get(t)),set:(t,n,r)=>{if(e.controller.signal.aborted)return;let i=this.layout(t).scroll;if(!i.has(n)&&i.size>=128)throw Error(`GUI layout scroll limit exceeded`);i.set(n,{...r}),this.changed()}}}),f=Le(e.controller.signal),p=A(()=>e.controller.signal.aborted?{status:`inactive`,reason:`disabled`}:{status:`active`,generation:1,value:f}),m={open:t=>e.controller.signal.aborted||this.appearance[0]().narrow&&!this.mobilePageNetworkReady[0]()||!e.pages.some(e=>e.id===t)?!1:this.options.openPage?.(O(e.id,t))??!1,current:()=>{let t=this.currentPage[0]();return e.pages.find(n=>O(e.id,n.id)===t)?.id}},g=A(()=>e.controller.signal.aborted||!this.options.openPage||this.appearance[0]().narrow&&!this.mobilePageNetworkReady[0]()?{status:`inactive`,reason:`disabled`}:{status:`active`,generation:1,value:m});return Z(`ctx`,{id:e.id,options:r,signal:e.controller.signal,client:this.options.client,storage:o,stores:c,toast:Pe(e.controller.signal,this.options.toast),app:{name:`yuri`,version:e.native?.activation.app.version??``,channel:e.native?.activation.app.packaged?`prod`:`local`,platform:e.native?`desktop`:`web`,packaged:e.native?.activation.app.packaged??!1},desktop:e.native?Z(`desktop`,{os:e.native.activation.os}):void 0,t:u,plural:(e,t,n)=>{let r=`${e}.${new Intl.PluralRules(this.appearance[0]().locale).select(t)}`;return u(r,{...n,count:t})===r?u(`${e}.other`,{...n,count:t}):u(r,{...n,count:t})},add:(t,r)=>{if(e.controller.signal.aborted||a(F)?.ended)return()=>{};if([`server`,`composer-pill`,`slot`,`file.viewer`,`menubar-item`].includes(t.id)&&X(`registry.${t.id}`),e.contributions.size>=256)throw Error(`GUI contribution limit exceeded`);let o=()=>{},c,u=x(i=>{o=i,c=s();let a=()=>typeof r==`function`?r():r,u;if(t.id===`yuri.file-icon`){let e=l(()=>{try{return{ok:!0,value:a()}}catch(e){return{ok:!1,error:e}}});u=()=>{let t=e();if(!t.ok)throw t.error;return t.value}}else u=l(a);if(t.id===`style`){let t=document.createElement(`style`);t.dataset.yuriPluginStyle=e.id,document.head.append(t),h(()=>t.remove()),n(()=>{let e=u();t.textContent=e===void 0?``:String(e)})}return{registry:t.id,read:u}},s()??e.owner);e.contributions.add(u);let d=()=>{t.id===`yuri.file-icon`&&e.iconChanges[1](e=>e+1)},f=()=>{(t.id===`yuri.theme`||t.id===`yuri.branding`)&&e.appearanceChanges[1](e=>e+1)},p=()=>{t.id===`yuri.work-status`&&e.workStatusChanges[1](e=>e+1)};return i(d),i(f),i(p),i(()=>this.changed()),this.own(e,()=>{$(c,t=>{e.error??=String(t)}),o(),e.contributions.delete(u),i(d),i(f),i(p),i(()=>this.changed())})},list:e=>this.list(e),provide:(t,n)=>{if(e.controller.signal.aborted||a(F)?.ended)return()=>{};if(G(t.id)||t.id===`yuri.previewActions`||t.id===`yuri.pages`)throw Error(`Preview/export/page contracts are provided only by the Yuri host`);if(t.kind!==`contract`||!(t.id===e.id||t.id.startsWith(`${e.id}.`)))throw Error(`Contract must belong to the providing plugin`);let r=this.contract(t.id);if(r.provider)throw Error(`Contract already provided: ${t.id}`);return r.provider=e,r.live[1]({status:`active`,value:n,generation:++r.generation}),this.own(e,()=>{r.provider===e&&(r.provider=void 0,r.live[1]({status:`inactive`,reason:e.status===`failed`?`failed`:`disabled`}))})},use:t=>t.id===`yuri.pages`?t.kind===`contract`?g:X(`pages token must be a Contract`):t.id===`yuri.previewActions`?t.kind===`contract`?p:X(`preview actions token must be a Contract`):G(t.id)?t.kind===`contract`?this.viewExports.use(t.id,e.controller.signal):X(`export token must be a Contract`):t.kind===`ipc`&&e.native?e.native.token(t).live:this.contract(t.id,t.kind===`ipc`).live[0],main:t=>{if(!(t.id===e.id||t.id.startsWith(`${e.id}.`)))throw new E(`GUI_PLUGIN_FORBIDDEN`,`IPC must belong to the plugin`);return e.native?e.native.token(t).value:new Proxy({state:()=>void 0},{get:(e,t)=>t===`state`?e.state:t===`on`?()=>{throw new E(`GUI_PLUGIN_UNSUPPORTED`)}:()=>Promise.reject(new E(`GUI_PLUGIN_UNSUPPORTED`))})},sessions:{current:this.session[0],list:()=>{let e=this.session[0]();return e?[e]:[]}},screen:{current:()=>this.session[0]()?this.#e:void 0},layout:d,appearance:{mode:()=>this.appearance[0]().mode,font:()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||`monospace`},locale:{locale:()=>this.appearance[0]().locale,direction:()=>/^(ar|fa|he|ur)(-|$)/i.test(this.appearance[0]().locale)?`rtl`:`ltr`},system:{copy:e=>navigator.clipboard.writeText(e),openExternal:e=>{let t=new URL(e);[`https:`,`http:`,`mailto:`].includes(t.protocol)||X(`system.openExternal protocol`),window.open(e,`_blank`,`noopener,noreferrer`)},save:Ie},commands:{run:t=>e.controller.signal.aborted||!this.command(t)?!1:(this.runCommand(t),!0)},links:{open:t=>!e.controller.signal.aborted&&this.navigateLink(e,t),exists:t=>i(()=>{if(e.controller.signal.aborted)return!1;let n=this.linkHandler(t);try{return Promise.resolve(n?.value.exists?.(t)??!1).catch(()=>!1)}catch{return!1}})}})}contract(e,t=!1){let n=this.contracts.get(e);if(!n){if(this.contracts.size>=256)throw Error(`GUI contract limit exceeded`);let t=u({status:`inactive`,reason:`disabled`});n={live:[A(t[0]),t[1]],generation:0},this.contracts.set(e,n)}return t&&n.provider&&X(`IPC contract collision`),n}derive(e){if(e.status!==`active`)return;let t=[],n=[],r=[],a=[],o=[],s=[],c=this.session[0]();for(let i of e.contributions){if([`yuri.file-icon`,`yuri.theme`,`yuri.branding`,`yuri.work-status`].includes(i.registry))continue;let l=i.read();if(l!==void 0){if(i.registry===`yuri.page`){let e=he(l);if(s.some(t=>t.id===e.id))throw Error(`Duplicate yuri.page id`);s.push(e)}else if(i.registry===we.id){let n=l;n.enabled!==!1&&t.push({key:`${e.id}.${n.id}`,pluginId:e.id,title:n.title,description:n.description,bind:n.bind,hidden:n.hidden,run:()=>this.invoke(e,()=>n.run())})}else if(i.registry===k.id){let t=l;o.push({key:JSON.stringify([e.id,t.id]),pluginId:e.id,label:t.label,title:t.title,icon:Me(t.icon),busy:t.busy,pressed:t.pressed,actionable:!!t.run,run:t.run})}else if(i.registry===Ee.id&&c){let t=l,r=`${e.id}:`,i=this.layout(c).open.filter(e=>e.startsWith(r)).map(e=>e.slice(r.length));for(let r of t.list({session:c,screen:this.#e,open:i}))n.push({plugin:e,panel:t,tab:r})}else if(i.registry===be.id){let e=l;(e.page||e.section)&&X(`SettingsPage host sections`),e.title,r.push(e)}else if(i.registry===N.id){let e=l;e.menu===`session.panel`?(e.title,a.push(e)):X(`MenuItem.${e.menu}`)}}}for(let e of n)e.tab.title;e.commands=t,e.titlebarItems=o,e.panels=n,e.pages=s,e.settings=r,e.menus=a,i(()=>this.views[1](e=>e+1))}publish(){let e=i(this.session[0]),t=e?this.layouts.get(e.key):void 0,n=[...this.instances.values()],r=n.filter(e=>e.status===`active`),a=r.flatMap(e=>e.panels.map(({tab:n})=>{let r=n.file?this.filePath(n.file):void 0;return{key:`${e.id}:${n.id}`,pluginId:e.id,title:n.title,file:r,inline:!!(r&&this.fileViews.has(r)),active:t?.shown===!0&&t.active===`${e.id}:${n.id}`}}));this.snapshot=Object.freeze({plugins:Q(n.map(({id:e,revision:t,status:n,error:r,errorCode:i,iconError:a})=>({id:e,revision:t,status:n,error:r??a,...i?{errorCode:i}:{}}))),commands:Q(r.flatMap(e=>e.commands.filter(e=>!e.hidden))),panels:Q(a),titlebarItems:Q(r.flatMap(e=>e.titlebarItems.map(({run:e,...t})=>t))),pages:Q(r.flatMap(e=>e.pages.map(t=>({key:O(e.id,t.id),pluginId:e.id,title:t.title,icon:t.icon})))),settings:Q(r.flatMap(e=>e.settings.map(t=>({key:`${e.id}:${t.id}`,pluginId:e.id,title:t.title})))),menuItems:Q(r.flatMap(e=>e.menus.map(t=>({key:`${e.id}:${t.id}`,pluginId:e.id,title:t.title,description:t.description,run:()=>{this.invoke(e,()=>t.run())}})))),activePanel:t?.shown&&a.some(e=>e.key===t.active)?t.active:null,sessionKey:e?.key});for(let e of this.listeners)e()}invoke(e,t){if(!e.controller.signal.aborted)try{let n=o(e.owner??null,t);if(n instanceof Promise)return n.catch(t=>this.fail(e,t))}catch(t){this.fail(e,t)}}command(e){return[...this.instances.values()].flatMap(e=>e.commands).find(t=>t.key===e)}runCommand(e){return this.command(e)?.run()}runTitlebarItem(e){for(let t of this.instances.values()){let n=t.titlebarItems.find(t=>t.key===e);if(n?.run&&!n.busy)return this.invoke(t,n.run)}}linkHandler(e){let t=[];for(let e of this.instances.values())for(let n of e.contributions)if(n.registry===ye.id){let r=n.read();r&&t.push({instance:e,value:r})}for(let n of t.sort((e,t)=>(t.value.priority??0)-(e.value.priority??0)))try{if(n.value.match(e))return n}catch(e){this.fail(n.instance,e)}}navigateLink(e,t){if(this.ended)return!1;let n=me(t.href);if(!n||!pe(n.path))return this.openLink(t);let r=this.session[0]();if(!r||t.session&&(t.session.key!==r.key||t.session.server.id!==r.server.id))return!1;if(!this.options.focusFile)return this.openLink(t);let i=w(t.base??r.directory,n.path),a=n.line===void 0?``:`:${n.line}${n.column===void 0?``:`:${n.column}`}`;return this.invoke(e,()=>this.options.focusFile(i+a,r.directory)),!0}openLink(e){if(this.ended)return!1;let t={...e,session:e.session??this.session[0]()},n=this.linkHandler(t);return n?(this.invoke(n.instance,()=>n.value.open(t)),!0):!1}filePath(e,t=this.session[0]()?.directory){let n=L(e);return/^(?:\/|[a-z]:\/)/i.test(n)||!t?n:L(`${t}/${n}`)}registerFileView(e,t){if(this.ended)return()=>{};let n=this.filePath(e,t),r=this.fileViews.get(n)??0;this.fileViews.set(n,r+1),r===0&&this.changed(!0);let i=!1;return()=>{if(i||this.ended)return;i=!0;let e=(this.fileViews.get(n)??1)-1;if(e){this.fileViews.set(n,e);return}{let e=this.session[0](),t=e&&this.layouts.get(e.key);t?.active&&this.snapshot.panels.some(e=>e.key===t.active&&e.file===n)&&(t.shown=!1),this.fileViews.delete(n)}this.changed(!0)}}filePanel(e,t){let n=this.filePath(e,t);return this.snapshot.panels.find(e=>e.file===n&&e.inline)}panelVisible(e){let t=this.session[0]();if(!t)return!1;let n=this.panel(e)?.tab.file;if(n&&this.fileViews.has(this.filePath(n)))return!0;let r=this.layouts.get(t.key);return!!(r?.shown&&r.active===e)}layout(e){let t=this.layouts.get(e.key);if(!t){if(this.layouts.size>=128)throw Error(`GUI session layout limit exceeded`);t={open:[],active:null,shown:!1,scroll:new Map},this.layouts.set(e.key,t)}return t}openPanel(e,t,n){if(this.ended)return;let r=this.layout(t),i=r.active,a=r.shown,o=r.open.length;if(!r.open.includes(e)){if(r.open.length>=64)throw Error(`GUI panel tab limit exceeded`);r.open=[...r.open,e]}n?.tab!==`append`&&(r.active=e,r.shown=!(this.appearance[0]().narrow&&n?.background)),(i!==r.active||a!==r.shown||o!==r.open.length)&&this.changed(!0);let s=this.panel(e);t.key===this.session[0]()?.key&&s&&n?.tab!==`append`&&this.invoke(s.plugin,()=>s.panel.focus?.({...this.props(e),restored:!1}))}selectPanel(e){let t=this.session[0]();t&&this.openPanel(e,t)}closeFor(e,t){let n=this.layout(t),r=t.key===this.session[0]()?.key?this.panel(e):void 0;if(!n.open.includes(e)||r?.tab.pinned||r?.tab.closable===!1)return;let i=this.session[0](),a=r&&i?{tab:r.tab,session:i,screen:this.#e}:void 0;n.open=n.open.filter(t=>t!==e),n.active===e&&(n.active=n.open.at(-1)??null),this.changed(!0),r&&a&&this.invoke(r.plugin,()=>r.panel.close?.(a))}closePanel(e){let t=this.session[0]();t&&this.closeFor(e,t)}hidePanel(){let e=this.session[0]();if(!e)return;let t=this.layout(e);t.shown&&(t.shown=!1,this.changed(!0))}panel(e){return[...this.instances.values()].flatMap(e=>e.panels).find(t=>`${t.plugin.id}:${t.tab.id}`===e)}props(e,t=!1){let n=this.panel(e)?.tab,r=()=>(this.views[0](),this.panel(e)?.tab??n??X(`panel no longer listed`)),i=t?l(()=>{let e=r();return{tab:e,fields:Object.getPrototypeOf(e)===Object.prototype?Object.getOwnPropertyDescriptors(e):void 0}},void 0,{equals:Be}):void 0,a=i?()=>i().tab:r,o=()=>this.session[0]()??X(`panel without session`);return{get tab(){return a()},get session(){return o()},screen:this.#e}}mountPanel(e,t,r){let a=this.panel(e);if(!a)return()=>{};let o=new AbortController,s=()=>{let s=l(()=>{this.session[0](),this.changes[0](),this.views[0]();let t=this.panel(e)?.tab.file;return t&&this.files&&this.panelVisible(e)?{model:this.files,file:t}:void 0},void 0,{equals:(e,t)=>e?.model===t?.model&&e?.file===t?.file});n(()=>{let e=s();e&&(h(e.model.watch(e.file)),e.model.sync(e.file).catch(()=>{}))});let c=()=>i(()=>a.panel.render(this.props(e,!0)));return S(K.Provider,{value:r?{plugin:a.plugin.controller.signal,signal:o.signal,content:t,target:r}:void 0,get children(){return c()}})},c=this.mount(a.plugin,t,()=>S(xe.Provider,{value:{visible:()=>(this.changes[0](),this.panelVisible(e)),present:()=>(this.changes[0](),this.panelVisible(e)),placement:()=>this.appearance[0]().narrow?`mobile`:`side`,reserve:()=>!1,animate:()=>!1,sidebar:Z(`panel.sidebar`,{}),open:()=>{let e=this.session[0]();return e?a.plugin.context.layout.stored(e):[]}},get children(){return s()}})),u=()=>{this.panelMounts.delete(u),o.abort(),c()};return this.panelMounts.add(u),this.own(a.plugin,u)}mountSettings(e,t){for(let n of this.instances.values()){let r=n.settings.find(t=>`${n.id}:${t.id}`===e);if(r)return this.mount(n,t,()=>r.render({}))}return()=>{}}mountPage(e,t){if(this.appearance[0]().narrow&&!this.mobilePageNetworkReady[0]())throw new E(`GUI_PLUGIN_UNAVAILABLE`,`Mobile page Relay is not ready`);for(let n of this.instances.values()){let r=n.pages.find(t=>O(n.id,t.id)===e);if(r)return this.mount(n,t,()=>r.render())}return()=>{}}mountWorkStatus(e,t,n){let r=this.instances.get(e.pluginId);if(!r||!this.workStatus.contains(e)||this.ended)return{update(){},dispose(){}};let i=Y(n,n.sessionId&&n.directory?this.sessionReference({id:n.sessionId,directory:n.directory},n.scope):void 0,n.scope?JSON.stringify(n.scope.queryScope):this.options.transport),a=()=>{},o=()=>{},s=this.own(r,()=>{i.dispose(),o(),a()});return o=this.workStatus.subscribe(()=>{this.workStatus.contains(e)||s()}),a=this.mount(r,t,()=>e.render(i.props)),i.props.signal.aborted&&(o(),a()),{update:e=>{if(!i.matches(e)){s();return}i.update(e)},dispose:s}}mount(e,t,n){if(e.controller.signal.aborted)return()=>{};let r=()=>{},a,o=t=>{queueMicrotask(()=>this.fail(e,t))};try{r=_e(()=>S(j.Provider,{value:e.context,get children(){return a=s(),b(()=>i(n),o)}}),t)}catch(t){this.fail(e,t)}return this.own(e,()=>{$(a,t=>{e.error??=String(t)}),r(),t.replaceChildren()})}};export{Ve as GuiPluginHost};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{A as t,F as n,j as r}from"./platform-CiUKDeXd.js";import{ot as i,st as a}from"./vendor-base-ui-fom6orB6.js";import{n as o}from"./vendor-react-D5BntRmA.js";import{n as s,t as c}from"./runtime-ead7P81A.js";import"./bootstrap-eLlfzqAI.js";import{i as l,t as u}from"./store-Dj5cSf8B.js";var d=e(a(),1),f=o(),p=async(e,n)=>{if(!t())throw Error(`Desktop runtime is not available`);return r(e,n)},m=async()=>{if(n())try{await p(`desktop_start_window_drag`)}catch{}},h=async e=>{if(n())try{await p(`desktop_set_window_title`,{title:e})}catch{}},g=async(e,t)=>{if(n())try{await p(`desktop_set_window_theme`,{themeMode:e,themeVariant:t})}catch{}},_=async e=>{if(n())try{await p(`desktop_set_menu_locale`,{locale:e})}catch{}},v=async()=>{if(!n())return null;try{let e=await p(`desktop_get_app_version`);return typeof e==`string`&&e.trim().length>0?e:null}catch{return null}},y=d.createContext(null),b=i(),x=e=>{let t=(0,f.c)(19),{children:n}=e,r=l(S),i=l(C),a=l(w),o=l(T),p,m;t[0]===r?(p=t[1],m=t[2]):(p=()=>{typeof document>`u`||(document.documentElement.lang=r)},m=[r],t[0]=r,t[1]=p,t[2]=m),d.useEffect(p,m);let h,g;t[3]!==a||t[4]!==r?(h=()=>{a===null&&_(r)},g=[r,a],t[3]=a,t[4]=r,t[5]=h,t[6]=g):(h=t[5],g=t[6]),d.useEffect(h,g);let v;t[7]===i?v=t[8]:(v=(e,t)=>u(i,e,t),t[7]=i,t[8]=v);let x=v,E;t[9]===x?E=t[10]:(E=e=>x(s[e]),t[9]=x,t[10]=E);let D;t[11]!==r||t[12]!==o||t[13]!==x||t[14]!==E?(D={locale:r,locales:c,setLocale:o,label:E,t:x},t[11]=r,t[12]=o,t[13]=x,t[14]=E,t[15]=D):D=t[15];let O=D,k;return t[16]!==n||t[17]!==O?(k=(0,b.jsx)(y.Provider,{value:O,children:n}),t[16]=n,t[17]=O,t[18]=k):k=t[18],k};function S(e){return e.locale}function C(e){return e.dictionary}function w(e){return e.loadingLocale}function T(e){return e.setLocale}var E={en:`en-US`,fr:`fr-FR`,"zh-CN":`zh-CN`,"zh-TW":`zh-TW`,uk:`uk-UA`,es:`es-ES`,"pt-BR":`pt-BR`,ko:`ko-KR`,pl:`pl-PL`,ja:`ja-JP`},D=e=>E[e]??`en-US`,O=()=>D(l.getState().locale);function k(){let e=d.useContext(y);if(!e)throw Error(`useI18n must be used within I18nProvider`);return e}export{p as a,m as c,v as i,O as n,g as o,x as r,h as s,k as t};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{A as t,F as n,j as r}from"./platform-CiUKDeXd.js";import{ot as i,st as a}from"./vendor-base-ui-wXsskyKm.js";import{n as o}from"./vendor-react-BkccXcWz.js";import{n as s,t as c}from"./runtime-ead7P81A.js";import"./bootstrap-eLlfzqAI.js";import{i as l,t as u}from"./store-C1ifDY0C.js";var d=e(a(),1),f=o(),p=async(e,n)=>{if(!t())throw Error(`Desktop runtime is not available`);return r(e,n)},m=async()=>{if(n())try{await p(`desktop_start_window_drag`)}catch{}},h=async e=>{if(n())try{await p(`desktop_set_window_title`,{title:e})}catch{}},g=async(e,t)=>{if(n())try{await p(`desktop_set_window_theme`,{themeMode:e,themeVariant:t})}catch{}},_=async e=>{if(n())try{await p(`desktop_set_menu_locale`,{locale:e})}catch{}},v=async()=>{if(!n())return null;try{let e=await p(`desktop_get_app_version`);return typeof e==`string`&&e.trim().length>0?e:null}catch{return null}},y=d.createContext(null),b=i(),x=e=>{let t=(0,f.c)(19),{children:n}=e,r=l(S),i=l(C),a=l(w),o=l(T),p,m;t[0]===r?(p=t[1],m=t[2]):(p=()=>{typeof document>`u`||(document.documentElement.lang=r)},m=[r],t[0]=r,t[1]=p,t[2]=m),d.useEffect(p,m);let h,g;t[3]!==a||t[4]!==r?(h=()=>{a===null&&_(r)},g=[r,a],t[3]=a,t[4]=r,t[5]=h,t[6]=g):(h=t[5],g=t[6]),d.useEffect(h,g);let v;t[7]===i?v=t[8]:(v=(e,t)=>u(i,e,t),t[7]=i,t[8]=v);let x=v,E;t[9]===x?E=t[10]:(E=e=>x(s[e]),t[9]=x,t[10]=E);let D;t[11]!==r||t[12]!==o||t[13]!==x||t[14]!==E?(D={locale:r,locales:c,setLocale:o,label:E,t:x},t[11]=r,t[12]=o,t[13]=x,t[14]=E,t[15]=D):D=t[15];let O=D,k;return t[16]!==n||t[17]!==O?(k=(0,b.jsx)(y.Provider,{value:O,children:n}),t[16]=n,t[17]=O,t[18]=k):k=t[18],k};function S(e){return e.locale}function C(e){return e.dictionary}function w(e){return e.loadingLocale}function T(e){return e.setLocale}var E={en:`en-US`,fr:`fr-FR`,"zh-CN":`zh-CN`,"zh-TW":`zh-TW`,uk:`uk-UA`,es:`es-ES`,"pt-BR":`pt-BR`,ko:`ko-KR`,pl:`pl-PL`,ja:`ja-JP`},D=e=>E[e]??`en-US`,O=()=>D(l.getState().locale);function k(){let e=d.useContext(y);if(!e)throw Error(`useI18n must be used within I18nProvider`);return e}export{p as a,m as c,v as i,O as n,g as o,x as r,h as s,k as t};
@@ -0,0 +1 @@
1
+ import{r as e}from"./Icon-DmykXZL1.js";var t=(e,t)=>{if(!t||t.length<2)return e;let n=t.map(e=>e.name).filter(Boolean).sort((e,t)=>t.length-e.length);return e.map(([e,t])=>{let r=n.find(t=>e.startsWith(`${t} · `));return r?[e,{...t,accountName:r}]:[e,t]})},n=(e,t)=>{let n=e[t]?.accountName;return!n||t>0&&e[t-1].accountName===n?null:new Set(e.map(e=>e.accountName).filter(Boolean)).size>1?n:null},r=(e,t)=>n(e.map(([,e])=>e),t),i={globe:`global`,server:`server`,"circle-check":`checkbox-circle`,"circle-x":`close-circle`,"window-analytics":`bar-chart-box`};function a(t){return t?Object.hasOwn(i,t)?i[t]:Object.hasOwn(e,t)?t:void 0:void 0}export{t as i,r as n,n as r,a as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{_ as t,s as n}from"./runtime-auth-DA-qfGHk.js";import{c as r,i}from"./runtime-switch-DEPKHgdL.js";import{st as a}from"./vendor-base-ui-fom6orB6.js";import"./brand-storage-bootstrap-D4BW3w-M.js";import{n as o}from"./vendor-react-D5BntRmA.js";import{E as s,t as c}from"./runtime-file-resource-CKQQEwNv.js";import{a as l,o as u,r as d}from"./path-utils-jGozTg9d.js";var f=e(a(),1),p=o(),m=[0,250,750],h=e=>{try{return decodeURIComponent(e)}catch{return e}},g=e=>{try{let t=new URL(e),n=h(t.hostname),r=h(t.pathname);return/^[A-Za-z]$/.test(n)?r=`${n.toUpperCase()}:${r}`:n&&n.toLowerCase()!==`localhost`&&(r=`//${n}${r}`),/^\/[A-Za-z]:[\\/]/.test(r)&&(r=r.slice(1)),l(r)}catch{let t=h(e.replace(/^file:\/\//i,``));return/^\/[A-Za-z]:[\\/]/.test(t)&&(t=t.slice(1)),l(t)}},_=(e,t)=>{let n=e.trim();if(!n||/^https?:/i.test(n)||/^(?:data|blob):/i.test(n)||/^\/api(?=\/|[?#]|$)/.test(n))return{kind:`direct`,source:n};if(/^file:\/\//i.test(n))return{kind:`runtime-file`,source:n,path:g(n)};if(/^[a-z][a-z\d+.-]*:/i.test(n)&&!/^[A-Za-z]:[\\/]/.test(n))return{kind:`direct`,source:n};let r=h(n);return{kind:`runtime-file`,source:n,path:d(r)?l(r):u(t,r)}},v=(e,t,n)=>y(()=>c(e,t,void 0,n),t),y=async(e,t)=>{let r=i(),a=n(),o;for(let s of m){t.throwIfAborted(),s>0&&await new Promise((e,n)=>{let r=window.setTimeout(()=>{t.removeEventListener(`abort`,i),e()},s),i=()=>{window.clearTimeout(r),n(t.reason)};t.addEventListener(`abort`,i,{once:!0})});try{if(t.throwIfAborted(),r!==i()||a!==n())throw new DOMException(`Image request superseded`,`AbortError`);return await e()}catch(e){if(t.aborted||r!==i()||a!==n())throw e;o=e}}throw o instanceof Error?o:Error(`Image source request failed`)},b=()=>!1,x=e=>e.startsWith(`relay:`)||b(),S=(e,t)=>typeof t==`number`&&Number.isFinite(t)&&t>1048576&&x(e),C=()=>f.useSyncExternalStore(T,i,i),w=e=>e.kind===`runtime-file`&&!!e.path,T=e=>r(()=>e()),E=e=>t(()=>e()),D=(e,t,r)=>{let a=(0,p.c)(22),o=r===void 0?`inline`:r,l=s(),u=l?.entry.location.hostId?l.entry:void 0,d=f.useSyncExternalStore(E,n,n),m=f.useSyncExternalStore(T,i,i),h;a[0]!==t||a[1]!==e?(h=_(e,t),a[0]=t,a[1]=e,a[2]=h):h=a[2];let g=h,v;a[3]===g?v=a[4]:(v=w(g),a[3]=g,a[4]=v);let y=v,b=`${m}\n${u?.key??``}\n${u?.connectionGeneration??``}\n${d}\n${t}\n${e}\n${o}`,x=y?``:g.source,S=y,C;a[5]!==S||a[6]!==x||a[7]!==b?(C={key:b,source:x,loading:S,error:null},a[5]=S,a[6]=x,a[7]=b,a[8]=C):C=a[8];let[D,O]=f.useState(C),k,A;a[9]!==o||a[10]!==b||a[11]!==g||a[12]!==u||a[13]!==m||a[14]!==y?(k=()=>{if(!y||!w(g)){O({key:b,source:g.source,loading:!1,error:null});return}O({key:b,source:``,loading:!0,error:null});let e=new AbortController,t;return c(g.path,e.signal,o,u).then(n=>{if(e.signal.aborted||i()!==m){n.release();return}t=n.release,O({key:b,source:n.url,loading:!1,error:null})}).catch(t=>{e.signal.aborted||O({key:b,source:``,loading:!1,error:t instanceof Error?t.message:`Image source request failed`})}),()=>{e.abort(),t?.()}},A=[b,g,m,y,o,u],a[9]=o,a[10]=b,a[11]=g,a[12]=u,a[13]=m,a[14]=y,a[15]=k,a[16]=A):(k=a[15],A=a[16]),f.useEffect(k,A);let j;return a[17]!==D||a[18]!==S||a[19]!==x||a[20]!==b?(j=D.key===b?D:{key:b,source:x,loading:S,error:null},a[17]=D,a[18]=S,a[19]=x,a[20]=b,a[21]=j):j=a[21],j},O=(e,t,n)=>D(e,t,n===void 0?`inline`:n).source;export{_ as a,C as c,w as i,S as n,D as o,x as r,O as s,v as t};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{_ as t,s as n}from"./runtime-auth-DA-qfGHk.js";import{c as r,i}from"./runtime-switch-DEPKHgdL.js";import{st as a}from"./vendor-base-ui-wXsskyKm.js";import"./brand-storage-bootstrap-D4BW3w-M.js";import{n as o}from"./vendor-react-BkccXcWz.js";import{E as s,t as c}from"./runtime-file-resource-Bc_ss-sW.js";import{a as l,o as u,r as d}from"./path-utils-jGozTg9d.js";var f=e(a(),1),p=o(),m=[0,250,750],h=e=>{try{return decodeURIComponent(e)}catch{return e}},g=e=>{try{let t=new URL(e),n=h(t.hostname),r=h(t.pathname);return/^[A-Za-z]$/.test(n)?r=`${n.toUpperCase()}:${r}`:n&&n.toLowerCase()!==`localhost`&&(r=`//${n}${r}`),/^\/[A-Za-z]:[\\/]/.test(r)&&(r=r.slice(1)),l(r)}catch{let t=h(e.replace(/^file:\/\//i,``));return/^\/[A-Za-z]:[\\/]/.test(t)&&(t=t.slice(1)),l(t)}},_=(e,t)=>{let n=e.trim();if(!n||/^https?:/i.test(n)||/^(?:data|blob):/i.test(n)||/^\/api(?=\/|[?#]|$)/.test(n))return{kind:`direct`,source:n};if(/^file:\/\//i.test(n))return{kind:`runtime-file`,source:n,path:g(n)};if(/^[a-z][a-z\d+.-]*:/i.test(n)&&!/^[A-Za-z]:[\\/]/.test(n))return{kind:`direct`,source:n};let r=h(n);return{kind:`runtime-file`,source:n,path:d(r)?l(r):u(t,r)}},v=(e,t,n)=>y(()=>c(e,t,void 0,n),t),y=async(e,t)=>{let r=i(),a=n(),o;for(let s of m){t.throwIfAborted(),s>0&&await new Promise((e,n)=>{let r=window.setTimeout(()=>{t.removeEventListener(`abort`,i),e()},s),i=()=>{window.clearTimeout(r),n(t.reason)};t.addEventListener(`abort`,i,{once:!0})});try{if(t.throwIfAborted(),r!==i()||a!==n())throw new DOMException(`Image request superseded`,`AbortError`);return await e()}catch(e){if(t.aborted||r!==i()||a!==n())throw e;o=e}}throw o instanceof Error?o:Error(`Image source request failed`)},b=()=>!1,x=e=>e.startsWith(`relay:`)||b(),S=(e,t)=>typeof t==`number`&&Number.isFinite(t)&&t>1048576&&x(e),C=()=>f.useSyncExternalStore(T,i,i),w=e=>e.kind===`runtime-file`&&!!e.path,T=e=>r(()=>e()),E=e=>t(()=>e()),D=(e,t,r)=>{let a=(0,p.c)(22),o=r===void 0?`inline`:r,l=s(),u=l?.entry.location.hostId?l.entry:void 0,d=f.useSyncExternalStore(E,n,n),m=f.useSyncExternalStore(T,i,i),h;a[0]!==t||a[1]!==e?(h=_(e,t),a[0]=t,a[1]=e,a[2]=h):h=a[2];let g=h,v;a[3]===g?v=a[4]:(v=w(g),a[3]=g,a[4]=v);let y=v,b=`${m}\n${u?.key??``}\n${u?.connectionGeneration??``}\n${d}\n${t}\n${e}\n${o}`,x=y?``:g.source,S=y,C;a[5]!==S||a[6]!==x||a[7]!==b?(C={key:b,source:x,loading:S,error:null},a[5]=S,a[6]=x,a[7]=b,a[8]=C):C=a[8];let[D,O]=f.useState(C),k,A;a[9]!==o||a[10]!==b||a[11]!==g||a[12]!==u||a[13]!==m||a[14]!==y?(k=()=>{if(!y||!w(g)){O({key:b,source:g.source,loading:!1,error:null});return}O({key:b,source:``,loading:!0,error:null});let e=new AbortController,t;return c(g.path,e.signal,o,u).then(n=>{if(e.signal.aborted||i()!==m){n.release();return}t=n.release,O({key:b,source:n.url,loading:!1,error:null})}).catch(t=>{e.signal.aborted||O({key:b,source:``,loading:!1,error:t instanceof Error?t.message:`Image source request failed`})}),()=>{e.abort(),t?.()}},A=[b,g,m,y,o,u],a[9]=o,a[10]=b,a[11]=g,a[12]=u,a[13]=m,a[14]=y,a[15]=k,a[16]=A):(k=a[15],A=a[16]),f.useEffect(k,A);let j;return a[17]!==D||a[18]!==S||a[19]!==x||a[20]!==b?(j=D.key===b?D:{key:b,source:x,loading:S,error:null},a[17]=D,a[18]=S,a[19]=x,a[20]=b,a[21]=j):j=a[21],j},O=(e,t,n)=>D(e,t,n===void 0?`inline`:n).source;export{_ as a,C as c,w as i,S as n,D as o,x as r,O as s,v as t};
@@ -0,0 +1 @@
1
+ var e=`#yuri-skill:`,t=`#yuri-agent:`,n=e=>`https://opencode.ai/docs/agents/#${encodeURIComponent(e)}`,r=t=>`${e}${encodeURIComponent(t)}`,i=e=>`${t}${encodeURIComponent(e)}`,a=t=>{let n=[e,`#openchamber-skill:`].find(e=>t?.startsWith(e));if(!n||!t)return null;try{return decodeURIComponent(t.slice(n.length))}catch{return null}},o=e=>{let n=[t,`#openchamber-agent:`].find(t=>e?.startsWith(t));if(!n||!e)return null;try{return decodeURIComponent(e.slice(n.length))}catch{return null}};export{a,o as i,n,r,i as t};
@@ -0,0 +1 @@
1
+ import"./rolldown-runtime-hePW80VL.js";import{ot as e,st as t}from"./vendor-base-ui-wXsskyKm.js";import{n}from"./vendor-react-BkccXcWz.js";import{o as r}from"./session-startup-barrier-DT-hIBRf.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};