@yuriai/web 0.2.28 → 0.2.29-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (255) hide show
  1. package/dist/assets/AgentAvatar-GVufO03R.js +1 -0
  2. package/dist/assets/AssistantContactStatus-B67HXRUY.js +3 -0
  3. package/dist/assets/{AssistantUnreadBadge-DqThZdCe.js → AssistantUnreadBadge-Xz7kMLSv.js} +1 -1
  4. package/dist/assets/{AssistantView-DPUDCXoY.js → AssistantView-YVdgtBeh.js} +1 -1
  5. package/dist/assets/{DiagramView-CHVLoYrV.js → DiagramView-DCrAY37j.js} +1 -1
  6. package/dist/assets/{FadeInOnReveal-Cj3JXYvE.js → FadeInOnReveal-8NiBU75a.js} +1 -1
  7. package/dist/assets/{GuiPluginSurface-CBZYeKHb.js → GuiPluginSurface-u815jFNI.js} +1 -1
  8. package/dist/assets/{GuiPluginWindow-_Z5wycnH.js → GuiPluginWindow-CW0-Tapi.js} +1 -1
  9. package/dist/assets/{Icon-CeRMtJa8.js → Icon-CLLDJn-P.js} +1 -1
  10. package/dist/assets/{ImageLoadingPlaceholder-DjLaKB4o.js → ImageLoadingPlaceholder-DTWzB26a.js} +1 -1
  11. package/dist/assets/LoadingImage-B89ghYMH.js +1 -0
  12. package/dist/assets/MarkdownRenderer-DZXM92vp.js +2 -0
  13. package/dist/assets/{MarkdownRendererImpl-_plqOlsV.js → MarkdownRendererImpl-BLzRLmeZ.js} +3 -3
  14. package/dist/assets/MarkstreamRendererImpl-MqrsrtVx.js +3 -0
  15. package/dist/assets/{MobileDetailNavigation-SeT764Ps.js → MobileDetailNavigation-CozkWJ5y.js} +1 -1
  16. package/dist/assets/{MobileResizableSheet-BY1-oo_E.js → MobileResizableSheet-CAj4YGtu.js} +1 -1
  17. package/dist/assets/{MobileShareBridge-Dw8gLtJD.js → MobileShareBridge-yWj21Mpo.js} +2 -2
  18. package/dist/assets/MobileTabPageHeader-BSbOGw3M.js +2 -0
  19. package/dist/assets/MultiRunWindow-BDh7FxgY.js +1 -0
  20. package/dist/assets/{OnboardingScreen-CGqabMbp.js → OnboardingScreen-BdU6Tyax.js} +1 -1
  21. package/dist/assets/{OverlayScrollbar-AGSWQKg-.js → OverlayScrollbar-CzQC0JQI.js} +1 -1
  22. package/dist/assets/SettingsView-C0HSdVvS.css +1 -0
  23. package/dist/assets/SettingsView-C1dLufb0.js +30 -0
  24. package/dist/assets/SettingsWindow-DZFZJ8PI.js +1 -0
  25. package/dist/assets/{TerminalView-OHqpkHzz.js → TerminalView-2DhtuWTv.js} +3 -3
  26. package/dist/assets/ToolOutputDialog-COWWhGPD.js +10 -0
  27. package/dist/assets/YuriLogo-BZC0ckt0.js +1 -0
  28. package/dist/assets/{appThemeRegistry-9j-rCSlE.js → appThemeRegistry-CPa7wDcf.js} +1 -1
  29. package/dist/assets/appearance--vFosLNi.js +1 -0
  30. package/dist/assets/{assistant-attachment-cache-B_qRvy-k.js → assistant-attachment-cache-DMw2Smc8.js} +1 -1
  31. package/dist/assets/{button-Bjh2BSXh.js → button-BF2cNEuq.js} +1 -1
  32. package/dist/assets/{capgoAdapter-DERfot6h.js → capgoAdapter-CQz-vZo-.js} +1 -1
  33. package/dist/assets/collapsible-CS5qCQRU.js +1 -0
  34. package/dist/assets/context-menu-C6l4ycZG.js +1 -0
  35. package/dist/assets/desktopRelayRestore-C7pjf6fE.js +1 -0
  36. package/dist/assets/{device-BcRP6Tjd.js → device-DN1GigI_.js} +1 -1
  37. package/dist/assets/{diagram-CXVm2vzI.js → diagram-D9-jif9d.js} +1 -1
  38. package/dist/assets/dialog-r7RRePv5.js +1 -0
  39. package/dist/assets/{dropdown-menu.styles-M78xpvb2.js → dropdown-menu.styles-CX8oXdks.js} +1 -1
  40. package/dist/assets/es-C8kGYKZo.js +15 -0
  41. package/dist/assets/{fileMentionTouchSelection-B9NbPN9D.js → fileMentionTouchSelection-dpFpcetU.js} +2 -2
  42. package/dist/assets/{fileQueries-BeXkd3o6.js → fileQueries-DWj9yB2g.js} +1 -1
  43. package/dist/assets/{fileReferenceActions-CrIAce3K.js → fileReferenceActions-BBLYnGEx.js} +1 -1
  44. package/dist/assets/{fr-CIGqV46N.js → fr-BV_9HcN9.js} +3 -3
  45. package/dist/assets/{gitApi-CY3D5CF0.js → gitApi-CXkfrI_H.js} +1 -1
  46. package/dist/assets/{gitApiHttp-B7vYwgBh.js → gitApiHttp-DGAlAuET.js} +4 -4
  47. package/dist/assets/host-DB6QzbOw.js +1 -0
  48. package/dist/assets/image-loading-BUouaouB.js +1 -0
  49. package/dist/assets/input-DvF_mp0Y.js +1 -0
  50. package/dist/assets/insertionBoundaries-CmxtGojv.js +1 -0
  51. package/dist/assets/{ja-DAhnTq6V.js → ja-CIMpz4Z2.js} +3 -3
  52. package/dist/assets/{ko-FbMgNKcI.js → ko-DPUsuWV1.js} +3 -3
  53. package/dist/assets/magpie-BuRvkGVQ.svg +1 -0
  54. package/dist/assets/main-CJAnB1m1.js +169 -0
  55. package/dist/assets/main-DuN735GT.js +2 -0
  56. package/dist/assets/{markdownHeightCache-DVWGXtAX.js → markdownHeightCache-D02GlOiy.js} +1 -1
  57. package/dist/assets/{markdownTheme-hpURsgju.js → markdownTheme-CHNl6tUv.js} +1 -1
  58. package/dist/assets/{mcpQueries-CdOYmUdO.js → mcpQueries-Ls770ehB.js} +1 -1
  59. package/dist/assets/miniChat-BibI1YhA.js +2 -0
  60. package/dist/assets/mobile-DNvOl_GU.js +2 -0
  61. package/dist/assets/{mobileBackNavigation-CgZndzFA.js → mobileBackNavigation-CXfKEN3p.js} +1 -1
  62. package/dist/assets/multirun-CicU-KQt.js +3 -0
  63. package/dist/assets/native-CILcYDJz.js +1 -0
  64. package/dist/assets/{native-config-BpsFKLGl.js → native-config-BHa0LfdJ.js} +1 -1
  65. package/dist/assets/persistence-Dta0OwIa.js +3 -0
  66. package/dist/assets/{pl-DzX0cbiQ.js → pl-ChxP5OZm.js} +3 -3
  67. package/dist/assets/projectMeta-D3GYq5jV.js +1 -0
  68. package/dist/assets/pt-BR-9N8nJVqC.js +15 -0
  69. package/dist/assets/{queue-abort-optimistic-DCLBpirg.js → queue-abort-optimistic-DRJa-BrH.js} +1 -1
  70. package/dist/assets/{react-DRe85o5s.js → react-Bwr5-XPi.js} +1 -1
  71. package/dist/assets/readiness-lO-fOlzd.js +1 -0
  72. package/dist/assets/renderElectronMiniChatApp-DnzgZv3d.js +2 -0
  73. package/dist/assets/renderMobileApp-DLFGqfxp.js +28 -0
  74. package/dist/assets/{runtime-file-download-Cf1WxfeW.js → runtime-file-download-o29morT6.js} +1 -1
  75. package/dist/assets/{runtime-file-resource-UJjHUF2C.js → runtime-file-resource-qB_oVdE6.js} +1 -1
  76. package/dist/assets/{runtimeConfig-BBgkLVr_.js → runtimeConfig-Be6cMHuS.js} +1 -1
  77. package/dist/assets/runtimeEndpointReset-DeWcqIyJ.js +149 -0
  78. package/dist/assets/scheduledTaskNavigation-BqkeRfVc.js +1 -0
  79. package/dist/assets/sessionLookup-qvz-n65R.js +1 -0
  80. package/dist/assets/sortable-tabs-strip-Dc4Jr4ml.js +1 -0
  81. package/dist/assets/{speechSettingsQueries-CBSEAKyj.js → speechSettingsQueries-CsCKPsRU.js} +2 -2
  82. package/dist/assets/src-DME3XM8W.css +2 -0
  83. package/dist/assets/{store-DVfZQktm.js → store-BPYoxYhv.js} +4 -4
  84. package/dist/assets/{terminalApi-rl9mZAlB.js → terminalApi-CPVNQ5DH.js} +1 -1
  85. package/dist/assets/{textarea-C6VQ7dHH.js → textarea-CIhiRPB2.js} +1 -1
  86. package/dist/assets/theme-validation-BGYdrOu7.js +1 -0
  87. package/dist/assets/themes-BgDJcxRc.js +1 -0
  88. package/dist/assets/tooltip-BoAbDVNP.js +1 -0
  89. package/dist/assets/{touch-gestures-K2_ZOkKW.js → touch-gestures-CErgaXZ7.js} +1 -1
  90. package/dist/assets/types-CTkS0uZU.js +2 -0
  91. package/dist/assets/uk-C-aeGNQI.js +15 -0
  92. package/dist/assets/{useAppFontEffects-CEgDiZHu.js → useAppFontEffects-Cs_0mUpl.js} +43 -43
  93. package/dist/assets/{useAssistantUIStore-CfaQV3ID.js → useAssistantUIStore-CYyXdd5c.js} +1 -1
  94. package/dist/assets/useDesktopWindowControlsLayout-avf-_JWZ.js +1 -0
  95. package/dist/assets/{useEffectiveDirectory-BOYMJ6k7.js → useEffectiveDirectory-esZ8PL08.js} +1 -1
  96. package/dist/assets/{useFontPreferences-DeqW9nRx.js → useFontPreferences-UzjDmx4b.js} +1 -1
  97. package/dist/assets/useMobileNavigationStore-9lAGHZos.js +17 -0
  98. package/dist/assets/{useThemeSystem-CGF5jnIh.js → useThemeSystem-CNzUUkFn.js} +1 -1
  99. package/dist/assets/useUIStore-BDZCXouA.js +1 -0
  100. package/dist/assets/{useWorkerHighlightedLines-EcJThS4x.js → useWorkerHighlightedLines-BxqdOw1S.js} +1 -1
  101. package/dist/assets/vendor-base-ui-CzHs0bHY.js +1 -0
  102. package/dist/assets/{vendor-cmdk-C3oBVL9X.js → vendor-cmdk-C_tivUtr.js} +1 -1
  103. package/dist/assets/vendor-codemirror-autocomplete-C0FrlFqZ.js +12 -0
  104. package/dist/assets/vendor-codemirror-commands-5saeUOVY.js +1 -0
  105. package/dist/assets/vendor-codemirror-lang-angular-Cm7vBE3E.js +23 -0
  106. package/dist/assets/vendor-codemirror-lang-cpp-BjixvwC2.js +1 -0
  107. package/dist/assets/vendor-codemirror-lang-go-DFb2d_8t.js +11 -0
  108. package/dist/assets/vendor-codemirror-lang-java-CHitPigf.js +1 -0
  109. package/dist/assets/vendor-codemirror-lang-jinja-B8yrwpok.js +1 -0
  110. package/dist/assets/{vendor-codemirror-lang-json-mLulNbwB.js → vendor-codemirror-lang-json-DowyFczU.js} +1 -1
  111. package/dist/assets/{vendor-codemirror-lang-less-CNvptX3P.js → vendor-codemirror-lang-less-B1_0-sTl.js} +1 -1
  112. package/dist/assets/vendor-codemirror-lang-liquid-FIsA7YFN.js +1 -0
  113. package/dist/assets/vendor-codemirror-lang-markdown-npWBZIoE.js +6 -0
  114. package/dist/assets/vendor-codemirror-lang-php-wyEc0fdz.js +1 -0
  115. package/dist/assets/vendor-codemirror-lang-python-OPRdU26g.js +9 -0
  116. package/dist/assets/{vendor-codemirror-lang-rust-CtafR0gt.js → vendor-codemirror-lang-rust-DgovszuH.js} +1 -1
  117. package/dist/assets/vendor-codemirror-lang-sass-BdU-i07o.js +1 -0
  118. package/dist/assets/{vendor-codemirror-lang-sql-C6q09UUZ.js → vendor-codemirror-lang-sql-DUutq98l.js} +2 -2
  119. package/dist/assets/{vendor-codemirror-lang-vue-DIB78UsR.js → vendor-codemirror-lang-vue-CuRNbe8H.js} +1 -1
  120. package/dist/assets/{vendor-codemirror-lang-wast-C_JVdOCF.js → vendor-codemirror-lang-wast-CGFAOCoB.js} +1 -1
  121. package/dist/assets/vendor-codemirror-lang-xml-CMKBqGXF.js +1 -0
  122. package/dist/assets/{vendor-codemirror-lang-yaml-BO0hIfQM.js → vendor-codemirror-lang-yaml-CH9a1QiY.js} +1 -1
  123. package/dist/assets/{vendor-codemirror-language-data-Ctd4WxgW.js → vendor-codemirror-language-data-B3pLWvv-.js} +2 -2
  124. package/dist/assets/vendor-codemirror-search-hZY-L2l8.js +2 -0
  125. package/dist/assets/{vendor-dnd-kit-accessibility-DxpFzZhi.js → vendor-dnd-kit-accessibility-BOtnpZt5.js} +1 -1
  126. package/dist/assets/{vendor-dnd-kit-core-B3g3zWQd.js → vendor-dnd-kit-core-DK4OoOTr.js} +1 -1
  127. package/dist/assets/{vendor-dnd-kit-sortable-BKewx0Py.js → vendor-dnd-kit-sortable-Cv69eQm1.js} +1 -1
  128. package/dist/assets/{vendor-framer-motion-C1twy-GF.js → vendor-framer-motion-DDMKlXiP.js} +1 -1
  129. package/dist/assets/vendor-lodash-es-BS45jPoZ.js +1 -0
  130. package/dist/assets/{vendor-markstream-react-BlbOg72y.js → vendor-markstream-react-DfLaSG3W.js} +3 -3
  131. package/dist/assets/vendor-motion-C9oiAdx-.js +1 -0
  132. package/dist/assets/{vendor-pierre-diffs-Bj9Nqn6w.js → vendor-pierre-diffs-BFiZ3IhI.js} +2 -2
  133. package/dist/assets/{vendor-react-D5d-V1vN.js → vendor-react-DlzBev0S.js} +1 -1
  134. package/dist/assets/{vendor-react-drawio-C-iPmmED.js → vendor-react-drawio-Dyg1-39Q.js} +1 -1
  135. package/dist/assets/vendor-reactuses-core-DWo5Wn6R.js +1 -0
  136. package/dist/assets/{vendor-replit-codemirror-vim-DCdAdxvE.js → vendor-replit-codemirror-vim-BmQmU1lR.js} +6 -6
  137. package/dist/assets/{vendor-sonner-r2EJnfoo.js → vendor-sonner-BEHGipm5.js} +1 -1
  138. package/dist/assets/{vendor-stream-diffs-BnLmeqg2.js → vendor-stream-diffs-wcQxoPZk.js} +2 -2
  139. package/dist/assets/{vendor-tanstack-react-query-C4SG3JZB.js → vendor-tanstack-react-query-B2psfNaU.js} +1 -1
  140. package/dist/assets/{vendor-tanstack-react-virtual-BeZn51tF.js → vendor-tanstack-react-virtual-DSFNK3qc.js} +1 -1
  141. package/dist/assets/{vendor-zustand-B43HCgwC.js → vendor-zustand-vDaAPGfl.js} +1 -1
  142. package/dist/assets/zh-CN-DOchDQti.js +15 -0
  143. package/dist/assets/zh-TW-Dtigv2CE.js +15 -0
  144. package/dist/index.html +18 -18
  145. package/dist/mini-chat.html +18 -18
  146. package/dist/mobile.html +18 -18
  147. package/package.json +2 -1
  148. package/server/lib/config-sync/DOCUMENTATION.md +1 -0
  149. package/server/lib/config-sync/config-sync.test.js +22 -0
  150. package/server/lib/config-sync/constants.js +0 -3
  151. package/server/lib/gui-customization/DOCUMENTATION.md +45 -0
  152. package/server/lib/gui-customization/session-skill.js +58 -0
  153. package/server/lib/gui-customization/session-skill.test.js +53 -0
  154. package/server/lib/gui-customization/skill/SKILL.md +33 -0
  155. package/server/lib/gui-customization/skill/references/appearance.md +79 -0
  156. package/server/lib/gui-customization/skill/references/file-previews.md +113 -0
  157. package/server/lib/gui-customization/skill/references/global-pages.md +81 -0
  158. package/server/lib/gui-customization/skill/references/gui-api.md +37 -0
  159. package/server/lib/gui-customization/skill/references/preview-exports.md +74 -0
  160. package/server/lib/gui-customization/skill/references/workflow.md +81 -0
  161. package/server/lib/opencode/DOCUMENTATION.md +74 -1
  162. package/server/lib/opencode/config-entity-routes.js +2 -4
  163. package/server/lib/opencode/config-entity-routes.test.js +16 -13
  164. package/server/lib/opencode/core-routes.js +2 -0
  165. package/server/lib/opencode/core-routes.test.js +2 -2
  166. package/server/lib/opencode/custom-provider-models.d.ts +2 -0
  167. package/server/lib/opencode/custom-provider-models.js +71 -0
  168. package/server/lib/opencode/custom-provider-models.test.js +90 -0
  169. package/server/lib/opencode/custom-provider.d.ts +2 -0
  170. package/server/lib/opencode/custom-provider.js +107 -0
  171. package/server/lib/opencode/custom-provider.test.js +211 -0
  172. package/server/lib/opencode/feature-routes-runtime.js +5 -0
  173. package/server/lib/opencode/provider-catalog.js +14 -0
  174. package/server/lib/opencode/provider-catalog.test.js +15 -0
  175. package/server/lib/opencode/provider-configuration.test.js +64 -0
  176. package/server/lib/opencode/provider-model-config.d.ts +1 -0
  177. package/server/lib/opencode/provider-model-config.js +39 -0
  178. package/server/lib/opencode/provider-model-config.test.js +69 -0
  179. package/server/lib/opencode/provider-sources.d.ts +10 -0
  180. package/server/lib/opencode/provider-sources.js +52 -0
  181. package/server/lib/opencode/provider-sources.test.js +73 -0
  182. package/server/lib/opencode/providers.d.ts +5 -0
  183. package/server/lib/opencode/providers.js +28 -0
  184. package/server/lib/opencode/routes.js +50 -1
  185. package/server/lib/remote-desktop/DOCUMENTATION.md +6 -2
  186. package/server/lib/remote-desktop/runtime.js +3 -2
  187. package/server/lib/remote-desktop/runtime.test.js +20 -0
  188. package/server/lib/scheduled-tasks/session-skill.js +3 -0
  189. package/server/lib/scheduled-tasks/session-skill.test.js +4 -2
  190. package/shared/custom-provider-protocol.d.ts +4 -0
  191. package/shared/custom-provider-protocol.js +32 -0
  192. package/dist/assets/AgentAvatar-BybF1ayP.js +0 -1
  193. package/dist/assets/AssistantContactStatus-BwpxTn0d.js +0 -3
  194. package/dist/assets/LoadingImage-DG3otL5V.js +0 -1
  195. package/dist/assets/MarkdownRenderer-C8rv6z7p.js +0 -2
  196. package/dist/assets/MarkstreamRendererImpl-bs8HZ4Ra.js +0 -3
  197. package/dist/assets/MobileTabPageHeader-EsrOCLyg.js +0 -2
  198. package/dist/assets/MultiRunWindow-C-Qw_g7N.js +0 -1
  199. package/dist/assets/SettingsView-BLfFnnnX.js +0 -29
  200. package/dist/assets/SettingsView-BRIvklfP.css +0 -1
  201. package/dist/assets/SettingsWindow-lyYO8Byy.js +0 -1
  202. package/dist/assets/ToolOutputDialog-DU4Pb1s0.js +0 -10
  203. package/dist/assets/YuriLogo-Bb6yHagP.js +0 -1
  204. package/dist/assets/collapsible-BEAHoxNi.js +0 -1
  205. package/dist/assets/context-menu-BxLcot-3.js +0 -1
  206. package/dist/assets/desktopRelayRestore-D1UX7HW2.js +0 -1
  207. package/dist/assets/dialog-nshKUSE5.js +0 -1
  208. package/dist/assets/es-N9ZkQwG9.js +0 -15
  209. package/dist/assets/host-CnVx34Dh.js +0 -1
  210. package/dist/assets/image-loading-D6kOgU4w.js +0 -1
  211. package/dist/assets/input-3Re4pmHm.js +0 -1
  212. package/dist/assets/insertionBoundaries-DK7XYF8d.js +0 -1
  213. package/dist/assets/main-B_THXYMs.js +0 -2
  214. package/dist/assets/main-CpcudEZb.js +0 -169
  215. package/dist/assets/miniChat-DxZiTnAZ.js +0 -2
  216. package/dist/assets/mobile-BJuATiaC.js +0 -2
  217. package/dist/assets/multirun-BlaYsQi2.js +0 -3
  218. package/dist/assets/native-BYMhr-xH.js +0 -1
  219. package/dist/assets/persistence-CWuLIq1J.js +0 -3
  220. package/dist/assets/projectMeta-CnXHTolN.js +0 -1
  221. package/dist/assets/pt-BR-C5yvwyDK.js +0 -15
  222. package/dist/assets/readiness-U16Qor79.js +0 -1
  223. package/dist/assets/renderElectronMiniChatApp-n-nhgy1V.js +0 -2
  224. package/dist/assets/renderMobileApp-DBj_7RlD.js +0 -28
  225. package/dist/assets/runtimeEndpointReset-BvSQVFfx.js +0 -149
  226. package/dist/assets/scheduledTaskNavigation-EomDNVu2.js +0 -1
  227. package/dist/assets/sessionLookup-C_CCp7MJ.js +0 -1
  228. package/dist/assets/sortable-tabs-strip-p16Pn6Zz.js +0 -1
  229. package/dist/assets/src-u-YDfCVw.css +0 -2
  230. package/dist/assets/tooltip-Dnc6GA-X.js +0 -1
  231. package/dist/assets/types-DnZw0gLD.js +0 -2
  232. package/dist/assets/uk-zbDcUpBy.js +0 -15
  233. package/dist/assets/useDesktopWindowControlsLayout-B2o4IFmd.js +0 -1
  234. package/dist/assets/useMobileNavigationStore-DlvrZQ49.js +0 -17
  235. package/dist/assets/useUIStore-C6CE42oh.js +0 -1
  236. package/dist/assets/vendor-base-ui-BQjbsJ43.js +0 -1
  237. package/dist/assets/vendor-codemirror-autocomplete-7c2L_4dM.js +0 -12
  238. package/dist/assets/vendor-codemirror-commands-B8KrBQ9B.js +0 -1
  239. package/dist/assets/vendor-codemirror-lang-angular-DXOgWEVj.js +0 -23
  240. package/dist/assets/vendor-codemirror-lang-cpp-Dh8C3xqP.js +0 -1
  241. package/dist/assets/vendor-codemirror-lang-go-BXAJ1_dh.js +0 -11
  242. package/dist/assets/vendor-codemirror-lang-java-DAyCHRhk.js +0 -1
  243. package/dist/assets/vendor-codemirror-lang-jinja-0TICrMfO.js +0 -1
  244. package/dist/assets/vendor-codemirror-lang-liquid-8g5seytq.js +0 -1
  245. package/dist/assets/vendor-codemirror-lang-markdown-CV1IO6Qs.js +0 -6
  246. package/dist/assets/vendor-codemirror-lang-php-xP7rf28_.js +0 -1
  247. package/dist/assets/vendor-codemirror-lang-python-YM2WVLHF.js +0 -9
  248. package/dist/assets/vendor-codemirror-lang-sass-B4iav_Ps.js +0 -1
  249. package/dist/assets/vendor-codemirror-lang-xml-DIuzY_d4.js +0 -1
  250. package/dist/assets/vendor-codemirror-search-DiPwvA-6.js +0 -2
  251. package/dist/assets/vendor-lodash-es-DfLbG5Af.js +0 -1
  252. package/dist/assets/vendor-motion-BmLx2V78.js +0 -1
  253. package/dist/assets/vendor-reactuses-core-BcebBLwF.js +0 -1
  254. package/dist/assets/zh-CN-BHRJ7CF3.js +0 -15
  255. package/dist/assets/zh-TW-BFI_YFd-.js +0 -15
@@ -1,10 +1,10 @@
1
- import{n as e,r as t}from"./rolldown-runtime-hePW80VL.js";import{i as n}from"./runtime-switch-DEZ1K7qW.js";import{w as r}from"./desktop-JwYqThiw.js";import{at as i,it as a}from"./vendor-base-ui-BQjbsJ43.js";import{n as o}from"./useUIStore-C6CE42oh.js";import{n as s}from"./vendor-react-D5d-V1vN.js";import{u as c}from"./fileQueries-BeXkd3o6.js";import{t as l}from"./platform-DFJEtBlo.js";import{n as u}from"./vendor-katex-DNVSTX6g.js";import{i as d,p as f,r as p}from"./vendor-reactuses-core-BcebBLwF.js";import{d as m,f as h,r as g}from"./button-Bjh2BSXh.js";import{Rn as _}from"./useMobileNavigationStore-DlvrZQ49.js";import{t as v}from"./dualLimitLru-D8Sphgua.js";import{t as y}from"./useThemeSystem-CGF5jnIh.js";import{a as b,d as x,i as S,t as C}from"./image-loading-D6kOgU4w.js";import{a as w,i as T,n as E,r as D}from"./url-MRa-FtQa.js";import{n as ee}from"./useEffectiveDirectory-BOYMJ6k7.js";import{c as O,i as k,l as te,n as ne,o as A,r as re}from"./FadeInOnReveal-Cj3JXYvE.js";import{i as ie,r as j,t as ae}from"./markdownHeightCache-DVWGXtAX.js";import{n as oe,t as M}from"./markdownTheme-hpURsgju.js";import{i as N,n as P,t as F}from"./markdown-worker-oBGEB9Eg.js";import{t as se}from"./vendor-morphdom-BbKiNDAu.js";import{t as I}from"./vendor-dompurify-CeJNOzik.js";import{t as L}from"./vendor-pele-C1WTNWUm.js";import{t as R}from"./vendor-marked-WVekxjAN.js";import{t as z}from"./vendor-remend-C3cXc-tf.js";import{a as B,c as ce,f as V,g as le,h as H,i as U,l as W,n as ue,o as de,p as fe,t as pe,u as me}from"./fileReferenceActions-CrIAce3K.js";var G=t(i(),1),he=s(),K=new v({maxEntries:100,maxBytes:8388608}),ge=(e,t)=>{let{surface:n,interactive:r,primary:i,status:a}=t.colors,o={bg:n.elevated,fg:n.foreground,muted:n.mutedForeground,line:r.border,surface:n.muted,"surface-alt":n.background,border:r.border,accent:i.base,critical:a.error,error:a.error,"series-1":i.base,"series-2":a.info,"series-3":a.success,"series-4":a.warning,"series-5":a.error,"series-6":i.hover??i.base,"series-7":a.infoForeground,"series-8":a.successForeground},s=JSON.stringify([o,new Date().toDateString(),e]),c=K.get(s);if(c)return c;let l;try{let{svg:t}=L(e,{fontFamily:`system-ui, sans-serif`,autoDirection:!1,links:!1,images:!1}),n=I.sanitize(t,{USE_PROFILES:{svg:!0,svgFilters:!0},RETURN_DOM_FRAGMENT:!0}).querySelector(`svg`);if(!n)throw Error(`Missing diagram SVG`);for(let[e,t]of Object.entries(o))n.style.setProperty(`--pele-${e}`,t);l={svg:n.outerHTML}}catch{l={}}return K.set(s,l,(s.length+(l.svg?.length??0))*2),l},q=`data-md-stream-fence`,J=`data-md-stream-line`,_e=`data-md-stream-src`,ve=`data-md-stream-applied`,ye=(e,t)=>{let n=Math.min(e.length,t.length);for(let r=0;r<n;r+=1)if(e[r]!==t[r])return r;return n},be=e=>Array.from(e.children).filter(e=>e instanceof HTMLElement&&e.hasAttribute(`data-md-stream-line`)),xe=(e,t)=>{let n=document.createElement(`span`);return n.setAttribute(J,String(t)),n.className=`line`,n.innerHTML=e,n},Se=(e,t)=>{let n=be(e),r=ye(n.map(e=>e.innerHTML),t);if(n.length===0&&e.childNodes.length>0&&t.length>0){e.replaceChildren();for(let n=0;n<t.length;n+=1)n>0&&e.appendChild(document.createTextNode(`
1
+ import{n as e,r as t}from"./rolldown-runtime-hePW80VL.js";import{i as n}from"./runtime-switch-DEZ1K7qW.js";import{w as r}from"./desktop-JwYqThiw.js";import{ot as i,st as a}from"./vendor-base-ui-CzHs0bHY.js";import{r as o}from"./useUIStore-BDZCXouA.js";import{n as s}from"./vendor-react-DlzBev0S.js";import{u as c}from"./fileQueries-DWj9yB2g.js";import{t as l}from"./platform-DFJEtBlo.js";import{n as u}from"./vendor-katex-DNVSTX6g.js";import{a as d,i as f,m as p}from"./vendor-reactuses-core-DWo5Wn6R.js";import{d as m,f as h,r as g}from"./button-BF2cNEuq.js";import{Rn as _}from"./useMobileNavigationStore-9lAGHZos.js";import{t as v}from"./dualLimitLru-D8Sphgua.js";import{t as y}from"./useThemeSystem-CNzUUkFn.js";import{r as b}from"./themes-BgDJcxRc.js";import{a as x,i as S,n as C,r as w}from"./url-MRa-FtQa.js";import{n as ee}from"./useEffectiveDirectory-esZ8PL08.js";import{a as T,i as E,t as D}from"./image-loading-BUouaouB.js";import{c as O,i as k,l as te,n as ne,o as A,r as re}from"./FadeInOnReveal-8NiBU75a.js";import{i as ie,r as j,t as ae}from"./markdownHeightCache-D02GlOiy.js";import{n as oe,t as M}from"./markdownTheme-CHNl6tUv.js";import{i as N,n as P,t as F}from"./markdown-worker-oBGEB9Eg.js";import{t as se}from"./vendor-morphdom-BbKiNDAu.js";import{t as I}from"./vendor-dompurify-CeJNOzik.js";import{t as L}from"./vendor-pele-C1WTNWUm.js";import{t as R}from"./vendor-marked-WVekxjAN.js";import{t as z}from"./vendor-remend-C3cXc-tf.js";import{a as B,c as ce,f as V,g as le,h as H,i as U,l as W,n as ue,o as de,p as fe,t as pe,u as me}from"./fileReferenceActions-BBLYnGEx.js";var G=t(a(),1),he=s(),K=new v({maxEntries:100,maxBytes:8388608}),ge=(e,t)=>{let{surface:n,interactive:r,primary:i,status:a}=t.colors,o={bg:n.elevated,fg:n.foreground,muted:n.mutedForeground,line:r.border,surface:n.muted,"surface-alt":n.background,border:r.border,accent:i.base,critical:a.error,error:a.error,"series-1":i.base,"series-2":a.info,"series-3":a.success,"series-4":a.warning,"series-5":a.error,"series-6":i.hover??i.base,"series-7":a.infoForeground,"series-8":a.successForeground},s=JSON.stringify([o,new Date().toDateString(),e]),c=K.get(s);if(c)return c;let l;try{let{svg:t}=L(e,{fontFamily:`system-ui, sans-serif`,autoDirection:!1,links:!1,images:!1}),n=I.sanitize(t,{USE_PROFILES:{svg:!0,svgFilters:!0},RETURN_DOM_FRAGMENT:!0}).querySelector(`svg`);if(!n)throw Error(`Missing diagram SVG`);for(let[e,t]of Object.entries(o))n.style.setProperty(`--pele-${e}`,t);l={svg:n.outerHTML}}catch{l={}}return K.set(s,l,(s.length+(l.svg?.length??0))*2),l},q=`data-md-stream-fence`,J=`data-md-stream-line`,_e=`data-md-stream-src`,ve=`data-md-stream-applied`,ye=(e,t)=>{let n=Math.min(e.length,t.length);for(let r=0;r<n;r+=1)if(e[r]!==t[r])return r;return n},be=e=>Array.from(e.children).filter(e=>e instanceof HTMLElement&&e.hasAttribute(`data-md-stream-line`)),xe=(e,t)=>{let n=document.createElement(`span`);return n.setAttribute(J,String(t)),n.className=`line`,n.innerHTML=e,n},Se=(e,t)=>{let n=be(e),r=ye(n.map(e=>e.innerHTML),t);if(n.length===0&&e.childNodes.length>0&&t.length>0){e.replaceChildren();for(let n=0;n<t.length;n+=1)n>0&&e.appendChild(document.createTextNode(`
2
2
  `)),e.appendChild(xe(t[n]??``,n));return{reused:0,replaced:0,added:t.length,removed:0}}let i=0;if(r<n.length&&r<t.length){let e=n[r];e&&(e.innerHTML=t[r]??``,e.setAttribute(J,String(r)),i=1)}let a=0;for(let e=n.length-1;e>=r+i;--e){let t=n[e]?.previousSibling;t?.nodeType===Node.TEXT_NODE&&t.remove(),n[e]?.remove(),a+=1}let o=0;for(let n=r+i;n<t.length;n+=1)n>0&&e.appendChild(document.createTextNode(`
3
3
  `)),e.appendChild(xe(t[n]??``,n)),o+=1;return{reused:r,replaced:i,added:o,removed:a}},Ce=e=>{if(e.includes(`data-md-stream-fence=`))return e;let t=e.toLowerCase().lastIndexOf(`<pre`);return t<0?e:`${e.slice(0,t)}${e.slice(t).replace(/<pre\b/i,`<pre ${q}="true"`)}`},we=(e,t)=>{if(!(e instanceof HTMLElement)||!(t instanceof HTMLElement)||e.getAttribute(`data-md-stream-fence`)!==`true`||t.getAttribute(`data-md-stream-fence`)!==`true`)return!1;let n=e.tagName===`CODE`?e:e.querySelector(`code`),r=t.tagName===`CODE`?t:t.querySelector(`code`);return n instanceof HTMLElement&&r instanceof HTMLElement&&n.setAttribute(_e,r.textContent??``),!0},Te=e=>e.getAttribute(`data-md-stream-src`)??e.textContent??``,Ee=e=>{let t=e.querySelectorAll(`pre[${q}="true"]`),n=[];return t.forEach(e=>{let t=e.querySelector(`code`);t instanceof HTMLElement&&n.push(t)}),n},De=e=>e.closest(`pre`)?.getAttribute(`data-md-lang`)||e.className.match(/language-([^\s"]+)/)?.[1]||`text`,Oe=async(e,t,n)=>{if(n?.signal?.aborted)return;let r=Ee(e);await Promise.all(r.map(async r=>{let i=Te(r);if(!i||n?.signal?.aborted||r.getAttribute(`data-md-stream-applied`)===i)return;let a=De(r);if(a===`mermaid`)return;let o=await t(i,a,n);if(!(n?.signal?.aborted||!e.contains(r)||Te(r)!==i)){if(!o){let e=be(r),t=document.createElement(`span`);Se(r,i.split(`
4
4
  `).map((n,r)=>{let i=e[r];return i?.textContent===n?i.innerHTML:(t.textContent=n,t.innerHTML)}));return}Se(r,o),r.setAttribute(ve,i),r.removeAttribute(_e)}}))},ke=`text`,Ae=/^(\d+):(\d+):(.+)$/,je={ts:`typescript`,mts:`typescript`,cts:`typescript`,tsx:`tsx`,js:`javascript`,mjs:`javascript`,cjs:`javascript`,jsx:`jsx`,vue:`vue`,svelte:`svelte`,astro:`astro`,json:`json`,jsonc:`jsonc`,json5:`json5`,jsonl:`json`,ndjson:`json`,geojson:`json`,yaml:`yaml`,yml:`yaml`,toml:`toml`,ini:`ini`,cfg:`ini`,conf:`ini`,properties:`properties`,env:`dotenv`,css:`css`,scss:`scss`,sass:`sass`,less:`less`,styl:`stylus`,html:`html`,htm:`html`,xml:`xml`,svg:`xml`,md:`markdown`,markdown:`markdown`,mdown:`markdown`,mkd:`markdown`,mdx:`mdx`,py:`python`,pyw:`python`,pyi:`python`,rb:`ruby`,go:`go`,rs:`rust`,java:`java`,kt:`kotlin`,kts:`kotlin`,swift:`swift`,scala:`scala`,c:`c`,h:`c`,cc:`cpp`,cpp:`cpp`,cxx:`cpp`,hpp:`cpp`,hh:`cpp`,m:`objective-c`,mm:`objective-cpp`,cs:`csharp`,fs:`fsharp`,fsx:`fsharp`,vb:`vb`,php:`php`,pl:`perl`,pm:`perl`,lua:`lua`,r:`r`,dart:`dart`,ex:`elixir`,exs:`elixir`,erl:`erlang`,hrl:`erlang`,hs:`haskell`,clj:`clojure`,cljs:`clojure`,cljc:`clojure`,groovy:`groovy`,jl:`julia`,ml:`ocaml`,mli:`ocaml`,zig:`zig`,nix:`nix`,sol:`solidity`,prisma:`prisma`,proto:`proto`,graphql:`graphql`,gql:`graphql`,sql:`sql`,sh:`shellscript`,bash:`shellscript`,zsh:`shellscript`,fish:`shellscript`,ps1:`powershell`,psm1:`powershell`,bat:`bat`,cmd:`bat`,tf:`terraform`,tfvars:`terraform`,hcl:`hcl`,diff:`diff`,patch:`diff`,csv:`csv`,tex:`latex`,vim:`viml`,wgsl:`wgsl`,glsl:`glsl`,wat:`wasm`,mermaid:`mermaid`,mmd:`mermaid`},Me={dockerfile:`docker`,containerfile:`docker`,makefile:`make`,gnumakefile:`make`,"cmakelists.txt":`cmake`,gemfile:`ruby`,rakefile:`ruby`,podfile:`ruby`,".env":`dotenv`,".bashrc":`shellscript`,".zshrc":`shellscript`,".profile":`shellscript`},Ne=e=>{let t=e.split(/[\\/]/).pop()?.toLowerCase()??``;if(!t)return ke;let n=Me[t];if(n)return n;let r=t.lastIndexOf(`.`);return r<=0?ke:je[t.slice(r+1)]??ke},Pe=e=>{let t=e?.trim()??``;if(!t)return{lang:ke,label:ke,reference:!1};let n=Ae.exec(t);if(!n){let e=t.toLowerCase();return{lang:e,label:e,reference:!1}}let[,r=``,i=``,a=``]=n,o=r===i?r:`${r}-${i}`;return{lang:Ne(a),label:`${a}:${o}`,reference:!0}},Fe=e=>e===` `||e===` `||e===`
5
5
  `||e===`\r`,Ie=e=>e!==void 0&&e>=`0`&&e<=`9`,Le=e=>{for(let t=0;t<e.length;t+=1){let n=e.charCodeAt(t);if(n>=11904&&n<=40959||n>=12288&&n<=12351||n>=63744&&n<=64255||n>=65280&&n<=65519)return!0}return!1},Re=e=>{for(let t=0;t<e.length;t+=1){let n=e[t];if(n===`"`||n===`'`||Fe(n))return!0}return!1},ze=e=>{let t=0;for(;t<e.length;){let n=e.indexOf(`$`,t);if(n<0)return;let r=e[n+1];if(r===`$`||r!==void 0&&!Fe(r))return n;t=n+1}},Be=e=>{if(e[0]===`$`){if(e[1]===`$`){let t=e.indexOf(`$$`,2);return t<0?void 0:{raw:e.slice(0,t+2),text:e.slice(2,t),display:!0}}if(!(e.length<3||Fe(e[1])))for(let t=1;t<e.length;t+=1){let n=e[t];if(n===`\\`){t+=1;continue}if(n==="`")return;if(n!==`$`)continue;if(e[t+1]===`$`||Fe(e[t-1]))return;if(Ie(e[t+1]))continue;if(t===1)return;let r=e.slice(1,t);return Le(r)||Ie(e[1])&&Re(r)?void 0:{raw:e.slice(0,t+1),text:r,display:!1}}}},Y=e=>e.replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`),Ve=e=>{let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36)},He=e=>`${Ve(e.raw)}:${e.mode}:${+!!e.highlight}`,Ue=e=>/^\[[^\]]+\]:\s+\S+/m.test(e)||/^\[\^[^\]]+\]:\s+/m.test(e),We=e=>{let t=e.match(/^[ \t]{0,3}(`{3,}|~{3,})/);if(!t)return!1;let n=t[1];if(!n)return!1;let r=n[0],i=n.length,a=e.trimEnd().split(`
6
- `).at(-1)?.trim()??``;return!RegExp(`^[\\t ]{0,3}${r}{${i},}[\\t ]*$`).test(a)},Ge=e=>{try{return z(e,{linkMode:`text-only`})}catch{return e}},Ke=(e,t)=>{let n=t?`live`:`full`;if(Ue(e))return[{raw:e,src:Ge(e),mode:n,highlight:!0}];let r;try{r=R.lexer(e)}catch{return[{raw:e,src:Ge(e),mode:n,highlight:!0}]}let i=-1;for(let e=r.length-1;e>=0;--e)if(r[e]?.type!==`space`){i=e;break}if(i<0)return[{raw:e,src:Ge(e),mode:n,highlight:!0}];let a=[];for(let e=0;e<r.length;e+=1){let t=r[e];if(!t||t.type===`space`)continue;let o=t.raw??``,s=e===i,c=t.type===`code`&&We(o);a.push({raw:o,src:c?o:Ge(o),mode:s?n:`full`,highlight:!c})}return a.length===0?[{raw:e,src:Ge(e),mode:n,highlight:!0}]:a},qe=16,Je=new Map,Ye=(e,t)=>{let n=`${+!!t}:${e}`,r=Je.get(n);if(r)return Je.delete(n),Je.set(n,r),r;let i=Ke(e,t);for(;Je.size>=qe;){let e=Je.keys().next().value;if(typeof e!=`string`)break;Je.delete(e)}return Je.set(n,i),i},Xe=(e,t,n)=>{try{return u.renderToString(e,{displayMode:n,throwOnError:!1})}catch{return t}},Ze=R.use({gfm:!0,breaks:!1,extensions:[{name:`inlineMath`,level:`inline`,start(e){let t=e.indexOf(`\\(`);return t<0?void 0:t},tokenizer(e){let t=/^\\\(([\s\S]+?)\\\)/.exec(e);if(t)return{type:`inlineMath`,raw:t[0],text:t[1]??``}},renderer(e){let t=e;return Xe(t.text,t.raw,!1)}},{name:`blockMath`,level:`block`,start(e){let t=e.indexOf(`\\[`);return t<0?void 0:t},tokenizer(e){let t=/^\\\[([\s\S]+?)\\\]/.exec(e);if(t)return{type:`blockMath`,raw:t[0],text:t[1]??``}},renderer(e){let t=e;return Xe(t.text,t.raw,!0)}},{name:`dollarMath`,level:`inline`,start(e){return ze(e)},tokenizer(e){let t=Be(e);if(t)return{type:`dollarMath`,raw:t.raw,text:t.text,display:t.display}},renderer(e){let t=e;return Xe(t.text,t.raw,t.display)}}],renderer:{link({href:e,title:t,text:n}){let r=e??``,i=O(r);if(i)return`<a href="${Y(A(i))}" data-yuri-agent-mention="true" class="text-primary hover:underline" target="_blank" rel="noopener noreferrer">${n}</a>`;let a=te(r);if(a)return`<a href="${Y(r)}" data-skill-name="${Y(a)}" class="text-primary hover:underline">${n}</a>`;let o=t?` title="${Y(t)}"`:``;return`<a href="${Y(r)}"${o} class="external-link" target="_blank" rel="noopener noreferrer">${n}</a>`}}}),Qe=e=>e.replace(/\$\$([\s\S]*?)\$\$/g,(e,t)=>{try{return u.renderToString(t,{displayMode:!0,throwOnError:!1})}catch{return`$$${t}$$`}}),$e=e=>e.indexOf(`$`)===-1?e:e.split(/(<(?:pre|code|kbd)[^>]*>[\s\S]*?<\/(?:pre|code|kbd)>)/gi).map((e,t)=>t%2==1?e:Qe(e)).join(``),et=e=>$e(Ze.parse(e)),tt=e=>{let t=et(e.src);return e.highlight?t:Ce(t)},nt=/<pre><code(?:\s+class="language-([^"]*)")?>([\s\S]*?)<\/code><\/pre>/g,rt=1200,it=(e,t)=>{let n=1;for(let r=0;r<e.length;r+=1)if(e.charCodeAt(r)===10&&++n>t)return!0;return!1},at=e=>e.replace(/&lt;/g,`<`).replace(/&gt;/g,`>`).replace(/&quot;/g,`"`).replace(/&#39;/g,`'`).replace(/&amp;/g,`&`),ot=e=>e.reference?`data-md-lang="${Y(e.lang)}" data-md-label="${Y(e.label)}"`:`data-md-lang="${Y(e.lang)}"`,st=async(e,t,n)=>{if(n.isCancelled?.())return null;let r=[...e.matchAll(nt)];if(r.length===0)return e;let i=e;for(let e of r){if(n.isCancelled?.())return null;let[r,a,o]=e,s=Pe(a);if(s.lang===`mermaid`&&!s.reference)continue;let c=at(o??``);if(it(c,n.lineLimit)){i=i.replace(r,()=>r.replace(`<pre`,`<pre ${ot(s)}`));continue}let l=await t(c,s.lang);if(n.isCancelled?.())return null;if(l){let e=l.replace(/^<pre/,`<pre ${ot(s)}`);i=i.replace(r,()=>e)}}return i},ct=(e,t)=>!t&&e.length<=480&&!e.includes("```"),lt={USE_PROFILES:{html:!0,mathMl:!0,svg:!0},ADD_TAGS:[`svg`,`path`,`g`,`rect`,`line`,`polygon`,`polyline`,`circle`,`ellipse`,`text`,`tspan`,`defs`,`marker`],ADD_ATTR:[`d`,`viewBox`,`preserveAspectRatio`,`xmlns`,`target`,`fill`,`stroke`,`stroke-width`,`transform`,`points`,`x`,`y`,`x1`,`y1`,`x2`,`y2`,`cx`,`cy`,`r`,`rx`,`ry`,`style`],FORBID_TAGS:[`script`],FORBID_CONTENTS:[`script`]},ut=!1,dt=()=>{ut||typeof window>`u`||!I.isSupported||(ut=!0,I.addHook(`uponSanitizeAttribute`,(e,t)=>{if(!(e instanceof HTMLImageElement)||t.attrName!==`src`)return;let n=typeof t.attrValue==`string`?t.attrValue:``;/^file:/i.test(n)&&(e.setAttribute(`data-md-image-source`,n),t.keepAttr=!1)}),I.addHook(`afterSanitizeAttributes`,e=>{e instanceof HTMLAnchorElement&&e.target===`_blank`&&e.setAttribute(`rel`,`noopener noreferrer`)}))},ft=e=>I.isSupported?(dt(),I.sanitize(e,lt)):``,pt=`data-md-sanitize-block`,mt=e=>{if(e.length===0)return[];if(e.length===1)return[ft(e[0])];if(!I.isSupported||typeof document>`u`)return e.map(e=>ft(e));let t=e.map((e,t)=>`<div ${pt}="${t}">${e}</div>`).join(``),n=document.createElement(`div`);n.innerHTML=ft(t);let r=e.map(()=>``);return n.querySelectorAll(`[${pt}]`).forEach(e=>{let t=Number(e.getAttribute(pt));Number.isInteger(t)&&t>=0&&t<r.length&&(r[t]=e.innerHTML)}),r},ht=()=>r()?200:rt,gt=240,_t=16777216,vt=160,yt=8388608,bt=new v({maxEntries:gt,maxBytes:_t}),xt=new v({maxEntries:vt,maxBytes:yt}),St=e=>e.length*2,Ct=(e,t)=>{bt.set(e,t,St(e)+St(t.hash)+St(t.html))},wt=async(e,t,n)=>st(e,(e,r)=>F(e,r,{signal:t,priority:n}),{lineLimit:ht(),isCancelled:()=>!!t?.aborted}),Tt=async(e,t,n)=>{if(t?.aborted)return null;let r=tt(e);if(t?.aborted)return null;let i=e.highlight?await wt(r,t,n):r;if(i===null||t?.aborted)return null;let a=ft(i);return t?.aborted?null:a},Et=e=>`${Ve(e)}:${e.length}`,Dt=e=>{let t=xt.get(Et(e));return t?.source===e?t.html:void 0},Ot=(e,t)=>{let n=Et(e);xt.set(n,{source:e,html:t},St(n)+St(e)+St(t))},kt=e=>{if(!e)return[];let t=Ye(e,!1),n=Array(t.length).fill(``),r=[],i=[];t.forEach((e,t)=>{let a=Dt(e.src);if(a!==void 0){n[t]=a;return}r.push(t),i.push(tt(e))});let a=mt(i);return r.forEach((e,r)=>{let i=a[r]??``;n[e]=i;let o=t[e]?.src;o!==void 0&&Ot(o,i)}),n},At=8,jt=()=>typeof performance<`u`?performance.now():Date.now(),Mt=e=>e?.aborted?Promise.resolve(!1):new Promise(t=>{let n=!1,r=r=>{n||(n=!0,e?.removeEventListener(`abort`,a),t(r))},i=k(()=>{r(!e?.aborted)},{priority:`visible`}),a=()=>{i(),r(!1)};e?.addEventListener(`abort`,a,{once:!0})}),Nt=(e,t)=>{let n=[];for(let r=0;r<e.length;r+=1){let i=e[r];if(!i)return null;let a=Ve(i.raw),o=`${t}:${r}:${i.mode}`,s=bt.get(o);if(!s||s.hash!==a)return null;n.push({id:He(i),html:s.html})}return n},Pt=(e,t,n)=>{let r=mt(t.map(e=>e.html));return t.map((t,i)=>{let a=e[i],o=r[i]??``;return a&&Ct(`${n}:${i}:${a.mode}`,{hash:Ve(a.raw),html:o}),{id:t.id,html:o}})},Ft=async(e,t,n,r)=>{let i=n?`visible`:`background`,a=async(e,n)=>{if(r?.aborted)return null;let a=Ve(e.raw),o=He(e),s=`${t}:${n}:${e.mode}`,c=bt.get(s);if(c&&c.hash===a)return{id:o,html:c.html};let l=await Tt(e,r,i);return l===null||r?.aborted?null:(Ct(s,{hash:a,html:l}),{id:o,html:l})};if(n)return(await Promise.all(e.map(a))).filter(e=>e!==null);let o=[],s=0;for(let t=0;t<e.length&&!r?.aborted;t+=1){let n=e[t];if(!n)continue;if(jt()>=s){if(!await Mt(r))break;s=jt()+At}let i=await a(n,t);i&&o.push(i)}return o},It=async(e,t,n,r)=>{if(!e)return[];let i=Ye(e,t),a=Nt(i,n);if(a)return a;let o=t?`visible`:`background`,s=[],c=[];for(let e=0;e<i.length;e+=1){let t=i[e];if(!t)continue;let r=bt.get(`${n}:${e}:${t.mode}`);r&&r.hash===Ve(t.raw)||(s.push(t),c.push(e))}if(!ct(e,t)&&s.length>0)try{let e=await N({streaming:t,highlight:!0,highlightLineLimit:ht(),signal:r,priority:o,blocks:s});if(r?.aborted)return[];if(e&&e.length===s.length)return Pt(i,i.map((t,r)=>{let i=c.indexOf(r);if(i>=0)return e[i]??{id:He(t),html:``,highlight:t.highlight};let a=bt.get(`${n}:${r}:${t.mode}`);return{id:He(t),html:a?.html??``,highlight:t.highlight}}),n)}catch{}return Ft(i,n,t,r)},X=e=>Number.isFinite(e)&&e>0,Lt=e=>{if(typeof e==`number`)return X(e)?e:null;if(typeof e!=`string`)return null;let t=e.trim().match(/^([+-]?(?:(?:\d+\.?\d*)|(?:\.\d+))(?:[eE][+-]?\d+)?)(?:px)?$/);if(!t)return null;let n=Number(t[1]);return X(n)?n:null},Rt=(e,t,n)=>Math.min(n,Math.max(t,e)),zt=6,Bt=1.25,Vt=1.0015,Ht=16,Ut=1e3,Wt=.5,Gt=12,Kt=400,qt=`[data-markdown="mermaid-block"]`,Jt=e=>e.querySelector(qt)!==null,Yt=e=>[e.x,e.y,e.width,e.height].map(e=>{let t=Number(e.toFixed(zt));return Object.is(t,-0)?`0`:String(t)}).join(` `),Xt=e=>{let t=e.viewBox?.trim().split(/[\s,]+/).map(e=>Number.parseFloat(e));if(t?.length===4){let[e,n,r,i]=t;if(Number.isFinite(e)&&Number.isFinite(n)&&X(r)&&X(i))return{x:e,y:n,width:r,height:i}}let n=Lt(e.width),r=Lt(e.height);return n===null||r===null?null:{x:0,y:0,width:n,height:r}},Zt=e=>{let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36)},Qt=e=>{let t=e.renderMode||`unknown`,n=e.svgMarkup??``;if(!n){let n=[e.viewBox??``,e.width??``,e.height??``];return n.some(e=>e!==``)?`${t}:bounds:${n.join(`:`)}`:`${t}:no-svg`}return[t,Zt(n)].join(`:`)},$t=(e,t)=>{if(!X(t.width)||!X(t.height))return e;let n=e.width/e.height,r=t.width/t.height;if(n>r){let t=e.width/r;return{x:e.x,y:e.y-(t-e.height)/2,width:e.width,height:t}}let i=e.height*r;return{x:e.x-(i-e.width)/2,y:e.y,width:i,height:e.height}},en=({currentBox:e,viewport:t,delta:n})=>!X(t.width)||!X(t.height)||!X(e.width)||!X(e.height)?e:{x:e.x-n.x/t.width*e.width,y:e.y-n.y/t.height*e.height,width:e.width,height:e.height},tn=(e,t,n)=>{let r=e*(t===1?Ht:t===2?X(n)?n:0:1);return Number.isFinite(r)?Rt(r,-1e3,Ut):0},nn=e=>{let t=null;for(let n of e){if(!t){t=n;continue}return{center:{x:(t.x+n.x)/2,y:(t.y+n.y)/2},distance:Math.hypot(n.x-t.x,n.y-t.y)}}return null},rn=(e,t)=>{let n=t.x-e.x,r=t.y-e.y;return n*n+r*r>9},an=({currentBox:e,contentBox:t,viewport:n,pointer:r,zoomFactor:i,minScale:a,maxScale:o})=>{if(!X(n.width)||!X(n.height)||!X(i)||!X(e.width)||!X(e.height)||!X(t.width)||!X(t.height)||!X(a)||!X(o))return e;let s=Math.min(a,o),c=Math.max(a,o),l=$t(t,n),u=Rt(l.width/e.width*i,s,c),d=l.width/u,f=d/(e.width/e.height),p=Rt(r.x/n.width,0,1),m=Rt(r.y/n.height,0,1),h=e.x+p*e.width,g=e.y+m*e.height;return{x:h-p*d,y:g-m*f,width:d,height:f}},on=({currentBox:e,contentBox:t,viewport:n,previousGesture:r,gesture:i,minScale:a,maxScale:o})=>!X(r.distance)||!X(i.distance)?e:an({currentBox:en({currentBox:e,viewport:n,delta:{x:i.center.x-r.center.x,y:i.center.y-r.center.y}}),contentBox:t,viewport:n,pointer:i.center,zoomFactor:i.distance/r.distance,minScale:a,maxScale:o}),sn=new WeakMap,cn=e=>e instanceof HTMLElement?sn.get(e)??null:null,ln=e=>e.querySelector(`[data-markdown="mermaid-viewport"]`)??e.querySelector(`[data-markdown="mermaid"]`),un=e=>{let t=e.querySelector(`[data-markdown="mermaid"] svg`),n=e.querySelector(`[data-markdown="mermaid"]`);return Qt({renderMode:e.getAttribute(`data-mermaid-render`),svgMarkup:n?.getAttribute(`data-md-original-svg`)??t?.outerHTML??null,viewBox:t?.getAttribute(`viewBox`),width:t?.getAttribute(`width`),height:t?.getAttribute(`height`)})},dn=e=>{let t=e.getBoundingClientRect();return{width:t.width,height:t.height}},fn=(e,t)=>({x:e.clientX-t.left,y:e.clientY-t.top}),pn=(e,t)=>fn(e,t.getBoundingClientRect()),mn=e=>e instanceof Element&&!!e.closest(`button, a, [role="button"]`),hn=e=>{let t=ln(e),n=e.querySelector(`[data-markdown="mermaid"] svg`);if(!t||!n)return null;let r=Xt({viewBox:n.getAttribute(`viewBox`),width:n.getAttribute(`width`),height:n.getAttribute(`height`)});if(!r)return null;let i=r,a=null,o=null,s=null,c=new Map,l=new Set,u=null,d=null,f=e=>{i=e,n.setAttribute(`viewBox`,Yt(e)),n.removeAttribute(`width`),n.removeAttribute(`height`)},p=()=>{f($t(r,dn(t)))},m=(e,n)=>{f(an({currentBox:i,contentBox:r,viewport:dn(t),pointer:e,zoomFactor:n,minScale:Wt,maxScale:Gt}))},h=()=>{let e=dn(t);m({x:e.width/2,y:e.height/2},Bt)},g=()=>{let e=dn(t);m({x:e.width/2,y:e.height/2},1/Bt)},_=e=>{e.preventDefault(),e.stopPropagation();let n=tn(e.deltaY,e.deltaMode,dn(t).height);m(pn(e,t),Vt**+-n)},v=e=>{try{t.setPointerCapture(e),l.add(e)}catch{}},y=e=>{if(l.delete(e))try{t.hasPointerCapture(e)&&t.releasePointerCapture(e)}catch{}},b=()=>{a=null,o=null,s=null,c.clear(),u=null},x=()=>{b(),e.removeAttribute(`data-mermaid-panning`),e.hasAttribute(`data-mermaid-suppress-click`)&&(d=window.setTimeout(()=>{e.removeAttribute(`data-mermaid-suppress-click`),d=null},Kt))},S=n=>{if(n.pointerType!==`touch`&&n.button!==0||mn(n.target))return;d!==null&&(window.clearTimeout(d),d=null),e.removeAttribute(`data-mermaid-suppress-click`);let r=pn(n,t);v(n.pointerId),e.setAttribute(`data-mermaid-panning`,`true`),n.pointerType===`touch`?(c.set(n.pointerId,r),c.size>=2?(a=null,o=null,s=null,u=nn(c.values()),e.setAttribute(`data-mermaid-suppress-click`,`true`)):(a=n.pointerId,o=r,s=r)):(a=n.pointerId,o=r,s=r),n.preventDefault()},C=n=>{if(n.pointerType===`touch`){if(!c.has(n.pointerId))return;let a=pn(n,t);if(c.set(n.pointerId,a),c.size>=2){let a=nn(c.values());u&&a&&f(on({currentBox:i,contentBox:r,viewport:dn(t),previousGesture:u,gesture:a,minScale:Wt,maxScale:Gt})),u=a,e.setAttribute(`data-mermaid-suppress-click`,`true`),n.preventDefault();return}}if(a!==n.pointerId||!s)return;let l=pn(n,t);f(en({currentBox:i,viewport:dn(t),delta:{x:l.x-s.x,y:l.y-s.y}})),s=l,o&&rn(o,l)&&e.setAttribute(`data-mermaid-suppress-click`,`true`),n.preventDefault()},w=e=>{if(e.pointerType===`touch`||c.has(e.pointerId)){if(!c.has(e.pointerId))return;if(c.delete(e.pointerId),u=nn(c.values()),c.size>0){for(let[e,t]of c){a=e,o=t,s=t;break}c.size>=2&&(a=null,o=null,s=null),y(e.pointerId);return}x(),y(e.pointerId);return}a===e.pointerId&&(x(),y(e.pointerId))},T=()=>{p()};t.addEventListener(`wheel`,_,{passive:!1}),t.addEventListener(`pointerdown`,S),t.addEventListener(`pointermove`,C),t.addEventListener(`pointerup`,w),t.addEventListener(`pointercancel`,w),t.addEventListener(`lostpointercapture`,w),window.addEventListener(`resize`,T);let E=typeof ResizeObserver>`u`?null:new ResizeObserver(T);return E?.observe(t),p(),{zoomIn:h,zoomOut:g,fit:p,cleanup:()=>{t.removeEventListener(`wheel`,_),t.removeEventListener(`pointerdown`,S),t.removeEventListener(`pointermove`,C),t.removeEventListener(`pointerup`,w),t.removeEventListener(`pointercancel`,w),t.removeEventListener(`lostpointercapture`,w),window.removeEventListener(`resize`,T),E?.disconnect(),d!==null&&window.clearTimeout(d);for(let e of Array.from(l))y(e);b(),e.removeAttribute(`data-mermaid-panning`),e.removeAttribute(`data-mermaid-suppress-click`),sn.delete(e)}}},gn=e=>{let t=new Map,n=new Map,r=()=>{for(let[r,i]of Array.from(t.entries())){let a=un(r);(!e.contains(r)||a!==n.get(r))&&(i.cleanup(),t.delete(r),n.delete(r))}for(let r of Array.from(e.querySelectorAll(qt))){if(t.has(r)||r.querySelector(`[data-markdown="mermaid"] svg`)===null)continue;let e=hn(r);e&&(t.set(r,e),n.set(r,un(r)),sn.set(r,e))}};return r(),{refresh:r,cleanup:()=>{for(let e of t.values())e.cleanup();t.clear(),n.clear()}}},Z=(e,t=`size-3.5`)=>`<svg class="yuri-icon ${t}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><use href="#yuri-${e}"></use></svg>`,_n={copy:Z(`file-copy`),check:Z(`check`),download:Z(`download`),zoomIn:Z(`add`),zoomOut:Z(`subtract`),fit:Z(`refresh`),textWrap:Z(`text-wrap`),image:Z(`file-image`,`size-10`),imageDownload:Z(`download`,`size-3`),imageLoading:Z(`loader-4`,`size-3.5 animate-spin motion-reduce:animate-none`)},vn=`p-1 rounded hover:bg-interactive-hover/60 text-muted-foreground hover:text-foreground transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--interactive-focus-ring)]`,yn=(e,t)=>{e.innerHTML=t},bn=(e,t,n)=>{let r=document.createElement(`button`);return r.type=`button`,r.className=vn,r.setAttribute(`data-md-action`,n),r.setAttribute(`title`,t),r.setAttribute(`aria-label`,t),yn(r,_n[e]),r},xn=(e,t,n)=>{let r=e.querySelector(`[data-md-code-body]`),i=e.querySelector(`pre`),a=e.querySelector(`pre code`),o=e.querySelector(`[data-md-action="toggle-code-wrap"]`);if(e.setAttribute(`data-code-wrap`,t?`true`:`false`),r?.classList.toggle(`overflow-x-auto`,!t),r?.classList.toggle(`overflow-x-hidden`,t),i?.classList.toggle(`whitespace-pre-wrap`,t),i?.classList.toggle(`break-words`,t),a?.classList.toggle(`whitespace-pre-wrap`,t),a?.classList.toggle(`break-words`,t),i&&(i.style.whiteSpace=t?`pre-wrap`:`pre`,i.style.overflowWrap=t?`anywhere`:`normal`),a&&(a.style.whiteSpace=t?`pre-wrap`:`pre`,a.style.overflowWrap=t?`anywhere`:`normal`),o){let e=t?n.disableCodeWrap:n.enableCodeWrap;o.setAttribute(`title`,e),o.setAttribute(`aria-label`,e),o.classList.toggle(`text-foreground`,t),o.classList.toggle(`opacity-100`,t),o.classList.toggle(`text-muted-foreground`,!t),o.classList.toggle(`opacity-65`,!t),o.setAttribute(`aria-pressed`,t?`true`:`false`)}},Sn=e=>{let t=document.createElement(`div`);t.setAttribute(`data-md-code-line-numbers`,``),t.setAttribute(`aria-hidden`,`true`),t.className=`min-w-8 shrink-0 select-none border-r border-border/50 pr-3 text-right font-mono text-[13px] text-muted-foreground/45`;let n=e.textContent??``,r=Math.max(1,n.endsWith(`
6
+ `).at(-1)?.trim()??``;return!RegExp(`^[\\t ]{0,3}${r}{${i},}[\\t ]*$`).test(a)},Ge=e=>{try{return z(e,{linkMode:`text-only`})}catch{return e}},Ke=(e,t)=>{let n=t?`live`:`full`;if(Ue(e))return[{raw:e,src:Ge(e),mode:n,highlight:!0}];let r;try{r=R.lexer(e)}catch{return[{raw:e,src:Ge(e),mode:n,highlight:!0}]}let i=-1;for(let e=r.length-1;e>=0;--e)if(r[e]?.type!==`space`){i=e;break}if(i<0)return[{raw:e,src:Ge(e),mode:n,highlight:!0}];let a=[];for(let e=0;e<r.length;e+=1){let t=r[e];if(!t||t.type===`space`)continue;let o=t.raw??``,s=e===i,c=t.type===`code`&&We(o);a.push({raw:o,src:c?o:Ge(o),mode:s?n:`full`,highlight:!c})}return a.length===0?[{raw:e,src:Ge(e),mode:n,highlight:!0}]:a},qe=16,Je=new Map,Ye=(e,t)=>{let n=`${+!!t}:${e}`,r=Je.get(n);if(r)return Je.delete(n),Je.set(n,r),r;let i=Ke(e,t);for(;Je.size>=qe;){let e=Je.keys().next().value;if(typeof e!=`string`)break;Je.delete(e)}return Je.set(n,i),i},Xe=(e,t,n)=>{try{return u.renderToString(e,{displayMode:n,throwOnError:!1})}catch{return t}},Ze=R.use({gfm:!0,breaks:!1,extensions:[{name:`inlineMath`,level:`inline`,start(e){let t=e.indexOf(`\\(`);return t<0?void 0:t},tokenizer(e){let t=/^\\\(([\s\S]+?)\\\)/.exec(e);if(t)return{type:`inlineMath`,raw:t[0],text:t[1]??``}},renderer(e){let t=e;return Xe(t.text,t.raw,!1)}},{name:`blockMath`,level:`block`,start(e){let t=e.indexOf(`\\[`);return t<0?void 0:t},tokenizer(e){let t=/^\\\[([\s\S]+?)\\\]/.exec(e);if(t)return{type:`blockMath`,raw:t[0],text:t[1]??``}},renderer(e){let t=e;return Xe(t.text,t.raw,!0)}},{name:`dollarMath`,level:`inline`,start(e){return ze(e)},tokenizer(e){let t=Be(e);if(t)return{type:`dollarMath`,raw:t.raw,text:t.text,display:t.display}},renderer(e){let t=e;return Xe(t.text,t.raw,t.display)}}],renderer:{link({href:e,title:t,text:n}){let r=e??``,i=O(r);if(i)return`<a href="${Y(A(i))}" data-yuri-agent-mention="true" class="text-primary hover:underline" target="_blank" rel="noopener noreferrer">${n}</a>`;let a=te(r);if(a)return`<a href="${Y(r)}" data-skill-name="${Y(a)}" class="text-primary hover:underline">${n}</a>`;let o=t?` title="${Y(t)}"`:``;return`<a href="${Y(r)}"${o} class="external-link" target="_blank" rel="noopener noreferrer">${n}</a>`}}}),Qe=e=>e.replace(/\$\$([\s\S]*?)\$\$/g,(e,t)=>{try{return u.renderToString(t,{displayMode:!0,throwOnError:!1})}catch{return`$$${t}$$`}}),$e=e=>e.indexOf(`$`)===-1?e:e.split(/(<(?:pre|code|kbd)[^>]*>[\s\S]*?<\/(?:pre|code|kbd)>)/gi).map((e,t)=>t%2==1?e:Qe(e)).join(``),et=e=>$e(Ze.parse(e)),tt=e=>{let t=et(e.src);return e.highlight?t:Ce(t)},nt=/<pre><code(?:\s+class="language-([^"]*)")?>([\s\S]*?)<\/code><\/pre>/g,rt=1200,it=(e,t)=>{let n=1;for(let r=0;r<e.length;r+=1)if(e.charCodeAt(r)===10&&++n>t)return!0;return!1},at=e=>e.replace(/&lt;/g,`<`).replace(/&gt;/g,`>`).replace(/&quot;/g,`"`).replace(/&#39;/g,`'`).replace(/&amp;/g,`&`),ot=e=>e.reference?`data-md-lang="${Y(e.lang)}" data-md-label="${Y(e.label)}"`:`data-md-lang="${Y(e.lang)}"`,st=async(e,t,n)=>{if(n.isCancelled?.())return null;let r=[...e.matchAll(nt)];if(r.length===0)return e;let i=e;for(let e of r){if(n.isCancelled?.())return null;let[r,a,o]=e,s=Pe(a);if(s.lang===`mermaid`&&!s.reference)continue;let c=at(o??``);if(it(c,n.lineLimit)){i=i.replace(r,()=>r.replace(`<pre`,`<pre ${ot(s)}`));continue}let l=await t(c,s.lang);if(n.isCancelled?.())return null;if(l){let e=l.replace(/^<pre/,`<pre ${ot(s)}`);i=i.replace(r,()=>e)}}return i},ct=(e,t)=>!t&&e.length<=480&&!e.includes("```"),lt={USE_PROFILES:{html:!0,mathMl:!0,svg:!0},ADD_TAGS:[`svg`,`path`,`g`,`rect`,`line`,`polygon`,`polyline`,`circle`,`ellipse`,`text`,`tspan`,`defs`,`marker`],ADD_ATTR:[`d`,`viewBox`,`preserveAspectRatio`,`xmlns`,`target`,`fill`,`stroke`,`stroke-width`,`transform`,`points`,`x`,`y`,`x1`,`y1`,`x2`,`y2`,`cx`,`cy`,`r`,`rx`,`ry`,`style`],FORBID_TAGS:[`script`],FORBID_CONTENTS:[`script`]},ut=!1,dt=()=>{ut||typeof window>`u`||!I.isSupported||(ut=!0,I.addHook(`uponSanitizeAttribute`,(e,t)=>{if(!(e instanceof HTMLImageElement)||t.attrName!==`src`)return;let n=typeof t.attrValue==`string`?t.attrValue:``;/^file:/i.test(n)&&(e.setAttribute(`data-md-image-source`,n),t.keepAttr=!1)}),I.addHook(`afterSanitizeAttributes`,e=>{e instanceof HTMLAnchorElement&&e.target===`_blank`&&e.setAttribute(`rel`,`noopener noreferrer`)}))},ft=e=>I.isSupported?(dt(),I.sanitize(e,lt)):``,pt=`data-md-sanitize-block`,mt=e=>{if(e.length===0)return[];if(e.length===1)return[ft(e[0])];if(!I.isSupported||typeof document>`u`)return e.map(e=>ft(e));let t=e.map((e,t)=>`<div ${pt}="${t}">${e}</div>`).join(``),n=document.createElement(`div`);n.innerHTML=ft(t);let r=e.map(()=>``);return n.querySelectorAll(`[${pt}]`).forEach(e=>{let t=Number(e.getAttribute(pt));Number.isInteger(t)&&t>=0&&t<r.length&&(r[t]=e.innerHTML)}),r},ht=()=>r()?200:rt,gt=240,_t=16777216,vt=160,yt=8388608,bt=new v({maxEntries:gt,maxBytes:_t}),xt=new v({maxEntries:vt,maxBytes:yt}),St=e=>e.length*2,Ct=(e,t)=>{bt.set(e,t,St(e)+St(t.hash)+St(t.html))},wt=async(e,t,n)=>st(e,(e,r)=>F(e,r,{signal:t,priority:n}),{lineLimit:ht(),isCancelled:()=>!!t?.aborted}),Tt=async(e,t,n)=>{if(t?.aborted)return null;let r=tt(e);if(t?.aborted)return null;let i=e.highlight?await wt(r,t,n):r;if(i===null||t?.aborted)return null;let a=ft(i);return t?.aborted?null:a},Et=e=>`${Ve(e)}:${e.length}`,Dt=e=>{let t=xt.get(Et(e));return t?.source===e?t.html:void 0},Ot=(e,t)=>{let n=Et(e);xt.set(n,{source:e,html:t},St(n)+St(e)+St(t))},kt=e=>{if(!e)return[];let t=Ye(e,!1),n=Array(t.length).fill(``),r=[],i=[];t.forEach((e,t)=>{let a=Dt(e.src);if(a!==void 0){n[t]=a;return}r.push(t),i.push(tt(e))});let a=mt(i);return r.forEach((e,r)=>{let i=a[r]??``;n[e]=i;let o=t[e]?.src;o!==void 0&&Ot(o,i)}),n},At=8,jt=()=>typeof performance<`u`?performance.now():Date.now(),Mt=e=>e?.aborted?Promise.resolve(!1):new Promise(t=>{let n=!1,r=r=>{n||(n=!0,e?.removeEventListener(`abort`,a),t(r))},i=k(()=>{r(!e?.aborted)},{priority:`visible`}),a=()=>{i(),r(!1)};e?.addEventListener(`abort`,a,{once:!0})}),Nt=(e,t)=>{let n=[];for(let r=0;r<e.length;r+=1){let i=e[r];if(!i)return null;let a=Ve(i.raw),o=`${t}:${r}:${i.mode}`,s=bt.get(o);if(!s||s.hash!==a)return null;n.push({id:He(i),html:s.html})}return n},Pt=(e,t,n)=>{let r=mt(t.map(e=>e.html));return t.map((t,i)=>{let a=e[i],o=r[i]??``;return a&&Ct(`${n}:${i}:${a.mode}`,{hash:Ve(a.raw),html:o}),{id:t.id,html:o}})},Ft=async(e,t,n,r)=>{let i=n?`visible`:`background`,a=async(e,n)=>{if(r?.aborted)return null;let a=Ve(e.raw),o=He(e),s=`${t}:${n}:${e.mode}`,c=bt.get(s);if(c&&c.hash===a)return{id:o,html:c.html};let l=await Tt(e,r,i);return l===null||r?.aborted?null:(Ct(s,{hash:a,html:l}),{id:o,html:l})};if(n)return(await Promise.all(e.map(a))).filter(e=>e!==null);let o=[],s=0;for(let t=0;t<e.length&&!r?.aborted;t+=1){let n=e[t];if(!n)continue;if(jt()>=s){if(!await Mt(r))break;s=jt()+At}let i=await a(n,t);i&&o.push(i)}return o},It=async(e,t,n,r)=>{if(!e)return[];let i=Ye(e,t),a=Nt(i,n);if(a)return a;let o=t?`visible`:`background`,s=[],c=[];for(let e=0;e<i.length;e+=1){let t=i[e];if(!t)continue;let r=bt.get(`${n}:${e}:${t.mode}`);r&&r.hash===Ve(t.raw)||(s.push(t),c.push(e))}if(!ct(e,t)&&s.length>0)try{let e=await N({streaming:t,highlight:!0,highlightLineLimit:ht(),signal:r,priority:o,blocks:s});if(r?.aborted)return[];if(e&&e.length===s.length)return Pt(i,i.map((t,r)=>{let i=c.indexOf(r);if(i>=0)return e[i]??{id:He(t),html:``,highlight:t.highlight};let a=bt.get(`${n}:${r}:${t.mode}`);return{id:He(t),html:a?.html??``,highlight:t.highlight}}),n)}catch{}return Ft(i,n,t,r)},X=e=>Number.isFinite(e)&&e>0,Lt=e=>{if(typeof e==`number`)return X(e)?e:null;if(typeof e!=`string`)return null;let t=e.trim().match(/^([+-]?(?:(?:\d+\.?\d*)|(?:\.\d+))(?:[eE][+-]?\d+)?)(?:px)?$/);if(!t)return null;let n=Number(t[1]);return X(n)?n:null},Rt=(e,t,n)=>Math.min(n,Math.max(t,e)),zt=6,Bt=1.25,Vt=1.0015,Ht=16,Ut=1e3,Wt=.5,Gt=12,Kt=400,qt=`[data-markdown="mermaid-block"]`,Jt=e=>e.querySelector(qt)!==null,Yt=e=>[e.x,e.y,e.width,e.height].map(e=>{let t=Number(e.toFixed(zt));return Object.is(t,-0)?`0`:String(t)}).join(` `),Xt=e=>{let t=e.viewBox?.trim().split(/[\s,]+/).map(e=>Number.parseFloat(e));if(t?.length===4){let[e,n,r,i]=t;if(Number.isFinite(e)&&Number.isFinite(n)&&X(r)&&X(i))return{x:e,y:n,width:r,height:i}}let n=Lt(e.width),r=Lt(e.height);return n===null||r===null?null:{x:0,y:0,width:n,height:r}},Zt=e=>{let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36)},Qt=e=>{let t=e.renderMode||`unknown`,n=e.svgMarkup??``;if(!n){let n=[e.viewBox??``,e.width??``,e.height??``];return n.some(e=>e!==``)?`${t}:bounds:${n.join(`:`)}`:`${t}:no-svg`}return[t,Zt(n)].join(`:`)},$t=(e,t)=>{if(!X(t.width)||!X(t.height))return e;let n=e.width/e.height,r=t.width/t.height;if(n>r){let t=e.width/r;return{x:e.x,y:e.y-(t-e.height)/2,width:e.width,height:t}}let i=e.height*r;return{x:e.x-(i-e.width)/2,y:e.y,width:i,height:e.height}},en=({currentBox:e,viewport:t,delta:n})=>!X(t.width)||!X(t.height)||!X(e.width)||!X(e.height)?e:{x:e.x-n.x/t.width*e.width,y:e.y-n.y/t.height*e.height,width:e.width,height:e.height},tn=(e,t,n)=>{let r=e*(t===1?Ht:t===2?X(n)?n:0:1);return Number.isFinite(r)?Rt(r,-1e3,Ut):0},nn=e=>{let t=null;for(let n of e){if(!t){t=n;continue}return{center:{x:(t.x+n.x)/2,y:(t.y+n.y)/2},distance:Math.hypot(n.x-t.x,n.y-t.y)}}return null},rn=(e,t)=>{let n=t.x-e.x,r=t.y-e.y;return n*n+r*r>9},an=({currentBox:e,contentBox:t,viewport:n,pointer:r,zoomFactor:i,minScale:a,maxScale:o})=>{if(!X(n.width)||!X(n.height)||!X(i)||!X(e.width)||!X(e.height)||!X(t.width)||!X(t.height)||!X(a)||!X(o))return e;let s=Math.min(a,o),c=Math.max(a,o),l=$t(t,n),u=Rt(l.width/e.width*i,s,c),d=l.width/u,f=d/(e.width/e.height),p=Rt(r.x/n.width,0,1),m=Rt(r.y/n.height,0,1),h=e.x+p*e.width,g=e.y+m*e.height;return{x:h-p*d,y:g-m*f,width:d,height:f}},on=({currentBox:e,contentBox:t,viewport:n,previousGesture:r,gesture:i,minScale:a,maxScale:o})=>!X(r.distance)||!X(i.distance)?e:an({currentBox:en({currentBox:e,viewport:n,delta:{x:i.center.x-r.center.x,y:i.center.y-r.center.y}}),contentBox:t,viewport:n,pointer:i.center,zoomFactor:i.distance/r.distance,minScale:a,maxScale:o}),sn=new WeakMap,cn=e=>e instanceof HTMLElement?sn.get(e)??null:null,ln=e=>e.querySelector(`[data-markdown="mermaid-viewport"]`)??e.querySelector(`[data-markdown="mermaid"]`),un=e=>{let t=e.querySelector(`[data-markdown="mermaid"] svg`),n=e.querySelector(`[data-markdown="mermaid"]`);return Qt({renderMode:e.getAttribute(`data-mermaid-render`),svgMarkup:n?.getAttribute(`data-md-original-svg`)??t?.outerHTML??null,viewBox:t?.getAttribute(`viewBox`),width:t?.getAttribute(`width`),height:t?.getAttribute(`height`)})},dn=e=>{let t=e.getBoundingClientRect();return{width:t.width,height:t.height}},fn=(e,t)=>({x:e.clientX-t.left,y:e.clientY-t.top}),pn=(e,t)=>fn(e,t.getBoundingClientRect()),mn=e=>e instanceof Element&&!!e.closest(`button, a, [role="button"]`),hn=e=>{let t=ln(e),n=e.querySelector(`[data-markdown="mermaid"] svg`);if(!t||!n)return null;let r=Xt({viewBox:n.getAttribute(`viewBox`),width:n.getAttribute(`width`),height:n.getAttribute(`height`)});if(!r)return null;let i=r,a=null,o=null,s=null,c=new Map,l=new Set,u=null,d=null,f=e=>{i=e,n.setAttribute(`viewBox`,Yt(e)),n.removeAttribute(`width`),n.removeAttribute(`height`)},p=()=>{f($t(r,dn(t)))},m=(e,n)=>{f(an({currentBox:i,contentBox:r,viewport:dn(t),pointer:e,zoomFactor:n,minScale:Wt,maxScale:Gt}))},h=()=>{let e=dn(t);m({x:e.width/2,y:e.height/2},Bt)},g=()=>{let e=dn(t);m({x:e.width/2,y:e.height/2},1/Bt)},_=e=>{e.preventDefault(),e.stopPropagation();let n=tn(e.deltaY,e.deltaMode,dn(t).height);m(pn(e,t),Vt**+-n)},v=e=>{try{t.setPointerCapture(e),l.add(e)}catch{}},y=e=>{if(l.delete(e))try{t.hasPointerCapture(e)&&t.releasePointerCapture(e)}catch{}},b=()=>{a=null,o=null,s=null,c.clear(),u=null},x=()=>{b(),e.removeAttribute(`data-mermaid-panning`),e.hasAttribute(`data-mermaid-suppress-click`)&&(d=window.setTimeout(()=>{e.removeAttribute(`data-mermaid-suppress-click`),d=null},Kt))},S=n=>{if(n.pointerType!==`touch`&&n.button!==0||mn(n.target))return;d!==null&&(window.clearTimeout(d),d=null),e.removeAttribute(`data-mermaid-suppress-click`);let r=pn(n,t);v(n.pointerId),e.setAttribute(`data-mermaid-panning`,`true`),n.pointerType===`touch`?(c.set(n.pointerId,r),c.size>=2?(a=null,o=null,s=null,u=nn(c.values()),e.setAttribute(`data-mermaid-suppress-click`,`true`)):(a=n.pointerId,o=r,s=r)):(a=n.pointerId,o=r,s=r),n.preventDefault()},C=n=>{if(n.pointerType===`touch`){if(!c.has(n.pointerId))return;let a=pn(n,t);if(c.set(n.pointerId,a),c.size>=2){let a=nn(c.values());u&&a&&f(on({currentBox:i,contentBox:r,viewport:dn(t),previousGesture:u,gesture:a,minScale:Wt,maxScale:Gt})),u=a,e.setAttribute(`data-mermaid-suppress-click`,`true`),n.preventDefault();return}}if(a!==n.pointerId||!s)return;let l=pn(n,t);f(en({currentBox:i,viewport:dn(t),delta:{x:l.x-s.x,y:l.y-s.y}})),s=l,o&&rn(o,l)&&e.setAttribute(`data-mermaid-suppress-click`,`true`),n.preventDefault()},w=e=>{if(e.pointerType===`touch`||c.has(e.pointerId)){if(!c.has(e.pointerId))return;if(c.delete(e.pointerId),u=nn(c.values()),c.size>0){for(let[e,t]of c){a=e,o=t,s=t;break}c.size>=2&&(a=null,o=null,s=null),y(e.pointerId);return}x(),y(e.pointerId);return}a===e.pointerId&&(x(),y(e.pointerId))},ee=()=>{p()};t.addEventListener(`wheel`,_,{passive:!1}),t.addEventListener(`pointerdown`,S),t.addEventListener(`pointermove`,C),t.addEventListener(`pointerup`,w),t.addEventListener(`pointercancel`,w),t.addEventListener(`lostpointercapture`,w),window.addEventListener(`resize`,ee);let T=typeof ResizeObserver>`u`?null:new ResizeObserver(ee);return T?.observe(t),p(),{zoomIn:h,zoomOut:g,fit:p,cleanup:()=>{t.removeEventListener(`wheel`,_),t.removeEventListener(`pointerdown`,S),t.removeEventListener(`pointermove`,C),t.removeEventListener(`pointerup`,w),t.removeEventListener(`pointercancel`,w),t.removeEventListener(`lostpointercapture`,w),window.removeEventListener(`resize`,ee),T?.disconnect(),d!==null&&window.clearTimeout(d);for(let e of Array.from(l))y(e);b(),e.removeAttribute(`data-mermaid-panning`),e.removeAttribute(`data-mermaid-suppress-click`),sn.delete(e)}}},gn=e=>{let t=new Map,n=new Map,r=()=>{for(let[r,i]of Array.from(t.entries())){let a=un(r);(!e.contains(r)||a!==n.get(r))&&(i.cleanup(),t.delete(r),n.delete(r))}for(let r of Array.from(e.querySelectorAll(qt))){if(t.has(r)||r.querySelector(`[data-markdown="mermaid"] svg`)===null)continue;let e=hn(r);e&&(t.set(r,e),n.set(r,un(r)),sn.set(r,e))}};return r(),{refresh:r,cleanup:()=>{for(let e of t.values())e.cleanup();t.clear(),n.clear()}}},Z=(e,t=`size-3.5`)=>`<svg class="yuri-icon ${t}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><use href="#yuri-${e}"></use></svg>`,_n={copy:Z(`file-copy`),check:Z(`check`),download:Z(`download`),zoomIn:Z(`add`),zoomOut:Z(`subtract`),fit:Z(`refresh`),textWrap:Z(`text-wrap`),image:Z(`file-image`,`size-10`),imageDownload:Z(`download`,`size-3`),imageLoading:Z(`loader-4`,`size-3.5 animate-spin motion-reduce:animate-none`)},vn=`p-1 rounded hover:bg-interactive-hover/60 text-muted-foreground hover:text-foreground transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--interactive-focus-ring)]`,yn=(e,t)=>{e.innerHTML=t},bn=(e,t,n)=>{let r=document.createElement(`button`);return r.type=`button`,r.className=vn,r.setAttribute(`data-md-action`,n),r.setAttribute(`title`,t),r.setAttribute(`aria-label`,t),yn(r,_n[e]),r},xn=(e,t,n)=>{let r=e.querySelector(`[data-md-code-body]`),i=e.querySelector(`pre`),a=e.querySelector(`pre code`),o=e.querySelector(`[data-md-action="toggle-code-wrap"]`);if(e.setAttribute(`data-code-wrap`,t?`true`:`false`),r?.classList.toggle(`overflow-x-auto`,!t),r?.classList.toggle(`overflow-x-hidden`,t),i?.classList.toggle(`whitespace-pre-wrap`,t),i?.classList.toggle(`break-words`,t),a?.classList.toggle(`whitespace-pre-wrap`,t),a?.classList.toggle(`break-words`,t),i&&(i.style.whiteSpace=t?`pre-wrap`:`pre`,i.style.overflowWrap=t?`anywhere`:`normal`),a&&(a.style.whiteSpace=t?`pre-wrap`:`pre`,a.style.overflowWrap=t?`anywhere`:`normal`),o){let e=t?n.disableCodeWrap:n.enableCodeWrap;o.setAttribute(`title`,e),o.setAttribute(`aria-label`,e),o.classList.toggle(`text-foreground`,t),o.classList.toggle(`opacity-100`,t),o.classList.toggle(`text-muted-foreground`,!t),o.classList.toggle(`opacity-65`,!t),o.setAttribute(`aria-pressed`,t?`true`:`false`)}},Sn=e=>{let t=document.createElement(`div`);t.setAttribute(`data-md-code-line-numbers`,``),t.setAttribute(`aria-hidden`,`true`),t.className=`min-w-8 shrink-0 select-none border-r border-border/50 pr-3 text-right font-mono text-[13px] text-muted-foreground/45`;let n=e.textContent??``,r=Math.max(1,n.endsWith(`
7
7
  `)?n.split(`
8
8
  `).length-1:n.split(`
9
9
  `).length);for(let e=1;e<=r;e+=1){let n=document.createElement(`div`);n.className=`tabular-nums`,n.textContent=String(e),t.appendChild(n)}return t},Cn=e=>{let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),r=n.nextNode();for(;r;)t.push(r),r=n.nextNode();return t},wn=(e,t)=>{let n=0;for(let r of e){let e=n+r.data.length;if(t<=e)return{node:r,offset:Math.max(0,t-n)};n=e}let r=e.at(-1);return r?{node:r,offset:r.data.length}:null},Tn=(e,t)=>{let n=1/0,r=-1/0;for(let t=0;t<e.length;t+=1){let i=e[t];!i||i.width===0&&i.height===0||(i.top<n&&(n=i.top),i.bottom>r&&(r=i.bottom))}return!Number.isFinite(n)||r<=n?t:Math.max(t,r-n)},En=e=>Array.from(e.children).filter(e=>e instanceof HTMLElement&&e.classList.contains(`line`)),Dn=(e,t,n)=>{e.style.height=`${t}px`,e.style.lineHeight=`${n}px`},On=(e,t,n)=>{let r=document.createRange();r.setStart(e.node,e.offset),r.setEnd(t.node,t.offset);let i=Math.max(Tn(r.getClientRects(),n),Tn([r.getBoundingClientRect()],n));return r.detach(),i},kn=e=>{let t=e.querySelectorAll(`[data-component="markdown-code"]`);for(let e of Array.from(t)){let t=e.querySelector(`pre code`),n=e.querySelector(`[data-md-code-line-numbers]`);if(!t||!n)continue;let r=Array.from(n.children),i=window.getComputedStyle(t),a=Number.parseFloat(i.lineHeight)||20;n.style.fontFamily=i.fontFamily,n.style.fontSize=i.fontSize,n.style.lineHeight=`${a}px`;let o=En(t);if(o.length===r.length){let e=o.map(e=>e.getBoundingClientRect()),t=e=>(e?.textContent??``).length===0;for(let n=0;n<r.length;n+=1){let i=r[n],s=o[n],c=e[n];if(!i||!s||!c)continue;if(t(s)){Dn(i,a,a);continue}let l=o[n+1],u=e[n+1],d=u&&!t(l)?u.top:c.bottom;Dn(i,Tn([{top:c.top,bottom:d,width:1,height:d-c.top}],a),a)}continue}let s=t.textContent??``,c=Cn(t),l=0;for(let e=0;e<r.length;e+=1){let t=s.indexOf(`
10
- `,l),n=t===-1?s.length:t,i=r[e];if(!i)continue;let o=wn(c,l),u=wn(c,n);!o||!u||l===n?Dn(i,a,a):Dn(i,On(o,u,a),a),l=n+1}}},An=e=>{window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>kn(e))})},jn=(e,t,n)=>{let r=e.querySelectorAll(`[data-component="markdown-code"]`);for(let e of Array.from(r)){let r=e.querySelector(`[data-md-code-body]`),i=e.querySelector(`pre`);r&&i&&!r.querySelector(`[data-md-code-line-numbers]`)&&(r.classList.add(`flex`,`gap-3`),r.insertBefore(Sn(i),i)),xn(e,t,n)}An(e)},Mn=(e,t,n,r)=>{yn(e,_n.check),e.setAttribute(`title`,t),e.setAttribute(`aria-label`,t),window.setTimeout(()=>{yn(e,_n[n]),e.setAttribute(`title`,r),e.setAttribute(`aria-label`,r)},2e3)},Nn=e=>{let t=e.querySelectorAll(`:not(pre) > code`);for(let e of Array.from(t))e.getAttribute(`data-markdown`)!==`inline-code`&&e.setAttribute(`data-markdown`,`inline-code`)},Pn=(e,t)=>{let n=e.querySelectorAll(`pre`);for(let e of Array.from(n)){if(e.querySelector(`code.language-mermaid`))continue;let n=e.parentElement;if(!n||n.closest(`[data-component="markdown-code"]`))continue;let r=e.querySelector(`code`)?.className.match(/language-([^\s"]+)/)?.[1],i=e.getAttribute(`data-md-label`)??e.getAttribute(`data-md-lang`)??Pe(r).label,a=document.createElement(`div`);a.setAttribute(`data-component`,`markdown-code`),a.className=`my-4 group overflow-clip rounded-2xl border border-border/80 bg-[var(--surface-elevated)]`;let o=document.createElement(`div`);o.className=`flex items-center justify-between border-b border-border/70 px-3 py-1.5`;let s=document.createElement(`span`);s.className=`font-mono text-[13px] text-muted-foreground`,s.textContent=i;let c=bn(`copy`,t.labels.copy,`copy-code`),l=bn(`textWrap`,t.codeBlockLineWrap?t.labels.disableCodeWrap:t.labels.enableCodeWrap,`toggle-code-wrap`);o.appendChild(s);let u=document.createElement(`div`);u.className=`flex items-center gap-1`,u.appendChild(l),u.appendChild(c),o.appendChild(u);let d=document.createElement(`div`);d.setAttribute(`data-md-code-body`,``),d.className=`px-3 py-2.5 overflow-x-auto`,n.replaceChild(a,e),e.style.margin=`0`,e.style.background=`transparent`,e.classList.add(`min-w-0`,`w-full`,`flex-1`),d.appendChild(e),a.appendChild(o),a.appendChild(d),xn(a,t.codeBlockLineWrap,t.labels)}},Fn=e=>{let t=e.querySelectorAll(`table`);for(let e of Array.from(t)){if(e.closest(`[data-markdown="table-wrapper"]`))continue;let t=document.createElement(`div`);t.className=`my-4`,t.setAttribute(`data-markdown`,`table-wrapper`);let n=document.createElement(`div`);n.setAttribute(`data-markdown`,`table-scroll`);let r=e.parentElement;if(r){r.replaceChild(t,e),e.setAttribute(`data-markdown`,`table`);for(let t of Array.from(e.querySelectorAll(`tr`)))t.setAttribute(`data-markdown`,`table-row`);for(let t of Array.from(e.querySelectorAll(`th`)))t.setAttribute(`data-markdown`,`table-header-cell`);for(let t of Array.from(e.querySelectorAll(`td`)))t.setAttribute(`data-markdown`,`table-cell`);n.appendChild(e),t.appendChild(n)}}},In=0,Ln=(e,t)=>{let n=e.querySelectorAll(`pre > code.language-mermaid`);for(let e of Array.from(n)){let n=e.parentElement;if(!n)continue;let r=(e.textContent??``).replace(/\s+$/,``),i=t.renderMermaid(r),a=document.createElement(`div`);a.setAttribute(`data-markdown`,`mermaid-block`),a.setAttribute(`data-md-source`,r),a.className=`group relative`;let o=document.createElement(`div`);o.setAttribute(`data-markdown`,`mermaid-scroll`);let s=document.createElement(`div`);if(s.setAttribute(`data-markdown`,`mermaid-toolbar`),s.className=`absolute top-1 right-2 flex items-center gap-1 opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 transition-opacity`,i.svg){a.setAttribute(`data-mermaid-render`,`svg`);let e=document.createElement(`div`);e.setAttribute(`data-markdown`,`mermaid-viewport`);let n=document.createElement(`div`);n.setAttribute(`data-markdown`,`mermaid`),n.setAttribute(`data-md-original-svg`,i.svg),n.innerHTML=i.svg;let c=n.querySelector(`svg`),l=++In;for(let[e,t]of[[`title[id]`,`aria-labelledby`],[`desc[id]`,`aria-describedby`]]){let n=c?.querySelector(e);n&&(n.id=`yuri-mermaid-${l}-${n.localName}`,c?.setAttribute(t,n.id))}if(e.appendChild(n),o.appendChild(e),t.mermaidControls.showPanZoomControls&&(s.appendChild(bn(`zoomIn`,t.labels.zoomInDiagram,`mermaid-zoom-in`)),s.appendChild(bn(`zoomOut`,t.labels.zoomOutDiagram,`mermaid-zoom-out`)),s.appendChild(bn(`fit`,t.labels.resetDiagramView,`mermaid-fit`))),t.mermaidControls.copy){let e=bn(`copy`,t.labels.copyDiagram,`mermaid-copy`);e.setAttribute(`data-md-source`,r),s.appendChild(e)}if(t.mermaidControls.download){let e=bn(`download`,t.labels.downloadDiagram,`mermaid-download`);e.setAttribute(`data-md-svg`,`1`),s.appendChild(e)}}else{a.setAttribute(`data-mermaid-render`,`source`);let e=document.createElement(`pre`);if(e.setAttribute(`data-markdown`,`mermaid-source`),e.textContent=r,o.appendChild(e),t.mermaidControls.copy){let e=bn(`copy`,t.labels.copyDiagram,`mermaid-copy`);e.setAttribute(`data-md-source`,r),s.appendChild(e)}}a.appendChild(o),a.appendChild(s);let c=n.parentElement;c&&c.replaceChild(a,n)}},Rn=(e,t)=>{let n=e.querySelectorAll(`a[href]`);for(let e of Array.from(n)){if(e.getAttribute(`data-md-link-decorated`)===`true`||e.getAttribute(`data-yuri-file-link`)===`true`)continue;let n=e.getAttribute(`href`)??``;if(!D(n))continue;e.setAttribute(`data-md-link-decorated`,`true`);let r=E(n);if(r){let t=document.createElement(`span`);t.className=`mr-1 inline-flex size-[18px] items-center justify-center rounded border border-[var(--border)] bg-[var(--interactive-hover)] align-middle`;let n=document.createElement(`img`);n.setAttribute(`data-md-link-favicon`,`true`),n.src=r,n.alt=``,n.setAttribute(`aria-hidden`,`true`),n.loading=`lazy`,n.decoding=`async`,n.className=`size-3.5 rounded-sm`,n.addEventListener(`error`,()=>t.remove(),{once:!0}),t.appendChild(n),e.parentNode?.insertBefore(t,e)}if(t.onPreviewLoopback&&T(n)){let r=document.createElement(`button`);r.type=`button`,r.className=`ml-1 align-middle ${vn}`,r.setAttribute(`data-md-action`,`preview-loopback`),r.setAttribute(`data-md-url`,n),r.setAttribute(`title`,t.labels.previewTitle),r.setAttribute(`aria-label`,t.labels.previewLabel),yn(r,_n.download),e.parentNode?.insertBefore(r,e.nextSibling)}}},zn=`img:not([data-md-link-favicon="true"])`,Bn=`[data-md-image-presentation="true"]`,Vn=`data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" width="576" height="324" viewBox="0 0 576 324"%3E%3C/svg%3E`,Hn=[`block`,`max-w-full`,`rounded-xl`,`border`,`border-border/80`,`bg-[var(--surface-muted)]`,`transition-colors`,`focus-visible:outline`,`focus-visible:outline-2`,`focus-visible:outline-offset-2`,`focus-visible:outline-[var(--interactive-focus-ring)]`],Un=[`cursor-pointer`,`hover:bg-interactive-hover/60`],Wn=[`object-contain`],Gn=e=>{let t=e.parentElement;if(t?.matches(Bn))return t;let n=document.createElement(`span`);n.setAttribute(`data-md-image-presentation`,`true`),n.className=`relative my-4 block w-fit max-w-full`;let r=document.createElement(`span`);r.setAttribute(`data-md-image-placeholder-visual`,`true`),r.setAttribute(`aria-hidden`,`true`),r.className=`pointer-events-none absolute inset-0 flex items-center justify-center text-muted-foreground`,r.classList.add(`yuri-image-loading`),_()&&n.setAttribute(`data-mobile-image`,`true`);let i=document.createElement(`span`);i.className=`relative flex size-14 items-center justify-center rounded-2xl border border-border/80 bg-[var(--surface-elevated)] shadow-sm`,yn(i,_n.image);let a=document.createElement(`span`);a.setAttribute(`data-md-image-download-badge`,`true`),a.className=`absolute -right-1.5 -bottom-1.5 flex size-6 items-center justify-center rounded-full border border-border bg-[var(--surface-elevated)] text-foreground shadow-sm`,yn(a,_n.imageDownload);let o=document.createElement(`span`);return o.setAttribute(`data-md-image-loading-badge`,`true`),o.className=`absolute -right-1.5 -bottom-1.5 hidden size-6 items-center justify-center rounded-full border border-border bg-[var(--surface-elevated)] text-foreground shadow-sm`,yn(o,_n.imageLoading),i.appendChild(a),i.appendChild(o),r.appendChild(i),t?.replaceChild(n,e),n.appendChild(e),n.appendChild(r),n},Kn=e=>{e.src=Vn,e.setAttribute(`data-md-placeholder-source`,Vn),e.setAttribute(`data-md-image-state`,`placeholder`),e.classList.add(...Wn)},qn=e=>{e.removeAttribute(`data-md-image-state`),e.removeAttribute(`data-md-placeholder-source`),e.removeAttribute(`aria-busy`),e.classList.remove(...Wn)},Jn=(e,t)=>{if(!t.imagePreviewEnabled)return;let n=e.querySelectorAll(zn);for(let e of Array.from(n)){let n=e.getAttribute(`data-md-image-source`)??e.getAttribute(`src`)??``,r=b(n,t.imageEffectiveDirectory);if(!S(r)){e.setAttribute(`data-md-image-source`,n),Gn(e),e.setAttribute(`data-md-image-state`,e.complete&&e.naturalWidth>0?`loaded`:`loading`);continue}e.classList.add(...Hn,...Un),e.setAttribute(`role`,`button`),e.setAttribute(`tabindex`,`0`),e.setAttribute(`data-md-image-source`,n),Gn(e),Kn(e)}},Yn=(e,t)=>{Nn(e),Ln(e,t),Pn(e,t),Fn(e),Rn(e,t),Jn(e,t),le(e)},Xn=(e,t,n)=>{let r=new Blob([t],{type:n}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=e,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i)},Zn=(e,t)=>{let n=e=>{let n=e.target;if(!(n instanceof Element))return;let r=n.closest(`[data-md-action]`);if(!r)return;let i=r.getAttribute(`data-md-action`)??``;if(i===`copy-code`){let e=r.closest(`[data-component="markdown-code"]`)?.querySelector(`code`)?.textContent??``;e&&m(e).then(()=>Mn(r,t.labels.copied,`copy`,t.labels.copy));return}if(i===`toggle-code-wrap`){e.preventDefault(),t.onToggleCodeBlockLineWrap?.();return}if(i===`mermaid-copy`){let e=r.getAttribute(`data-md-source`)??``;e&&m(e).then(()=>Mn(r,t.labels.copied,`copy`,t.labels.copyDiagram));return}if(i===`mermaid-zoom-in`||i===`mermaid-zoom-out`||i===`mermaid-fit`){e.preventDefault();let t=cn(r.closest(`[data-markdown="mermaid-block"]`));i===`mermaid-zoom-in`?t?.zoomIn():i===`mermaid-zoom-out`?t?.zoomOut():t?.fit();return}if(i===`mermaid-download`){let e=r.closest(`[data-markdown="mermaid-block"]`)?.querySelector(`[data-markdown="mermaid"]`),t=e?.getAttribute(`data-md-original-svg`)??e?.innerHTML??``;t&&Xn(`diagram.svg`,t,`image/svg+xml;charset=utf-8`);return}if(i===`preview-loopback`){e.preventDefault();let n=r.getAttribute(`data-md-url`)??``;n&&t.onPreviewLoopback?.(n);return}};return e.addEventListener(`click`,n),()=>e.removeEventListener(`click`,n)},Qn=e({MarkdownRenderer:()=>Sr,SimpleMarkdownRenderer:()=>Cr}),Q=a(),$n=()=>{let e=(0,he.c)(4),t=y(),n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=x(!1),e[0]=n):n=e[0];let r=n,i;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(i=x(!0),e[1]=i):i=e[1];let a=i,o;return e[2]===t?.currentTheme?o=e[3]:(o=t?.currentTheme??(typeof window<`u`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?a:r),e[2]=t?.currentTheme,e[3]=o),o},er=e=>{let t=(0,he.c)(5),{containerRef:n,enabled:r,effectiveDirectory:i,openInAppBrowser:a,fileReference:o}=e,s;t[0]!==i||t[1]!==r||t[2]!==o||t[3]!==a?(s=e=>{if(r===!1||e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;let t=e.target;if(!(t instanceof Element)||t.closest($))return;let n=t.closest(`a[href]`);if(!(n instanceof HTMLAnchorElement)||n.getAttribute(`data-yuri-file-link`)===`true`)return;let s=n.getAttribute(`href`)??``;if(H(s)){e.preventDefault(),e.stopPropagation(),o&&B(s,o.effectiveDirectory,`href`)&&de(n,o);return}if(!D(s))return;e.preventDefault(),e.stopPropagation();let c=(i||``).trim();if(!_()&&c&&a){a(c,s);return}w(s)},t[0]=i,t[1]=r,t[2]=o,t[3]=a,t[4]=s):s=t[4];let c=p(s);d(`click`,c,n)},$=`img:not([data-md-link-favicon="true"])`,tr=e=>e.getAttribute(`data-md-image-source`)??e.getAttribute(`src`)??``,nr=({containerRef:e,effectiveDirectory:t,onShowPopup:r})=>{let i=G.useRef(null);i.current??=n();let a=i.current,o=!!r,s=p(e=>r?.(e)),c=G.useRef(()=>{}),l=G.useRef(new Map),u=G.useRef(null),d=G.useMemo(()=>e=>c.current(e),[]);return G.useLayoutEffect(()=>{let n=l.current;if(u.current!==null&&(clearTimeout(u.current),u.current=null),c.current=()=>{},!o){for(let[e,t]of n)t.controller?.abort(),t.release?.(),n.delete(e);return}let r=e.current;if(!r)return;let i=e=>{let n=Array.from(r.querySelectorAll($));if(n.indexOf(e)<0)return;let i=n.map(e=>({url:tr(e),filename:e.alt||tr(e)||void 0})).filter(e=>e.url),a=tr(e),o=i.findIndex(e=>e.url===a),c=e.alt||a;s({open:!0,title:c,content:``,metadata:{tool:`image-preview`,filename:c},previewSource:e,image:{url:a,filename:c,gallery:i,index:Math.max(0,o),directory:t}})},d=e=>{let t=n.get(e);t&&(t.controller?.abort(),t.release?.(),n.delete(e))},f=e=>{let n=tr(e),r=b(n,t);if(S(r))return`${a}\n${t}\n${n}`},p=e=>{let t=f(e);if(!t){d(e);return}let r=n.get(e);if(r?.key===t)return r;d(e);let i={key:t};return n.set(e,i),i},m=(e,i)=>{if(i.controller||i.objectUrl||!r.contains(e))return;let a=tr(e),o=b(a,t);if(!S(o)){d(e);return}let s=new AbortController;i.controller=s,e.setAttribute(`data-md-image-state`,`loading`),e.setAttribute(`aria-busy`,`true`),C(o.path,s.signal).then(t=>{let r=n.get(e);if(!r||r!==i||r.controller!==s||s.signal.aborted){t.release();return}r.controller=void 0,r.objectUrl=t.url,r.release=t.release,e.src=t.url}).catch(()=>{let t=n.get(e);t===i&&(t.controller=void 0,e.removeAttribute(`aria-busy`),e.setAttribute(`data-md-image-state`,`error`))})};c.current=e=>{for(let[t,r]of n)(!e.contains(t)||f(t)!==r.key)&&d(t);for(let t of Array.from(e.querySelectorAll($))){let e=p(t);e&&!e.objectUrl&&m(t,e)}},c.current(r);let h=e=>{let t=p(e);if(t&&!t.objectUrl){m(e,t);return}i(e)},g=e=>{let t=e.target;if(!(t instanceof Element))return;let n=t.closest($);n&&(e.preventDefault(),e.stopPropagation(),h(n))},_=e=>{if(e.key!==`Enter`&&e.key!==` `)return;let t=e.target;!(t instanceof HTMLImageElement)||!t.matches($)||(e.preventDefault(),e.stopPropagation(),h(t))},v=e=>{let t=e.target;t instanceof Element&&t.closest($)&&(e.preventDefault(),e.stopPropagation())},y=e=>{let t=e.target;!(t instanceof HTMLImageElement)||!t.matches($)||t.getAttribute(`src`)!==t.getAttribute(`data-md-placeholder-source`)&&(qn(t),t.setAttribute(`data-md-image-state`,`loaded`))},x=e=>{let t=e.target;!(t instanceof HTMLImageElement)||!t.matches($)||(t.removeAttribute(`aria-busy`),t.setAttribute(`data-md-image-state`,`error`))};return r.addEventListener(`load`,y,!0),r.addEventListener(`error`,x,!0),r.addEventListener(`click`,g),r.addEventListener(`keydown`,_),r.addEventListener(`contextmenu`,v),()=>{c.current=()=>{},r.removeEventListener(`load`,y,!0),r.removeEventListener(`error`,x,!0),r.removeEventListener(`click`,g),r.removeEventListener(`keydown`,_),r.removeEventListener(`contextmenu`,v),u.current=setTimeout(()=>{u.current=null;for(let e of Array.from(n.keys()))r.contains(e)&&Kn(e),d(e)},0)}},[e,t,o,a]),{reconcileMarkdownImageResources:d,transportIdentity:a}},rr={download:!0,copy:!0,showPanZoomControls:!0},ir=!0,ar=e=>{let t=e.match(/^(?:\uFEFF)?(---|\+\+\+)[^\S\r\n]*\r?\n[\s\S]*?\r?\n\1[^\S\r\n]*(?:\r?\n|$)/);return t?e.slice(t[0].length):e},or=160,sr=e=>{let t=(0,he.c)(8),{containerRef:n,effectiveDirectory:r,editor:i,preferRuntimeEditor:a,onShowPopup:o,enabled:s}=e,c=G.useRef(null),l,u;t[0]!==n||t[1]!==i||t[2]!==r||t[3]!==s||t[4]!==o||t[5]!==a?(l=()=>{let e=n.current;if(!e)return;let t=!1,l=_(),u=U(),d=s,f=wr,p=()=>{let t=e.querySelectorAll(V);for(let e of Array.from(t))f(e)};if(!d){p();return}let m=e=>{let n=e===void 0?0:e;if(c.current!==null&&typeof window<`u`&&window.clearTimeout(c.current),typeof window>`u`){h();return}c.current=window.setTimeout(()=>{c.current=null,window.requestAnimationFrame(()=>{t||h()})},n)},h=()=>{let n=e.querySelectorAll(`[data-markdown="inline-code"], a, ${me}`),i=0;for(let a of Array.from(n)){let n=ue(a),o=B(n,r,a.tagName.toLowerCase()===`a`?`href`:`path`);if(!o){f(a);continue}if(i>=u){f(a);continue}i+=1,(a.getAttribute(`data-yuri-file-link`)!==`true`||a.getAttribute(`data-yuri-file-path`)!==o.resolvedPath)&&ce(o.resolvedPath,r).then(n=>{if(t||!e.contains(a))return;let i=ue(a),s=B(i,r,a.tagName.toLowerCase()===`a`?`href`:`path`);if(!(!s||s.resolvedPath!==o.resolvedPath)){if(!W(s.resolvedPath,n,l)){f(a);return}a.setAttribute(`data-yuri-file-link`,`true`),a.setAttribute(`data-yuri-file-ref`,i),a.setAttribute(`data-yuri-file-path`,s.resolvedPath),a.setAttribute(`data-yuri-file-binary`,String(n.isBinary)),a.setAttribute(`title`,pe),a.tagName.toLowerCase()!==`a`&&(a.setAttribute(`role`,`button`),a.setAttribute(`tabindex`,`0`))}}).catch(Tr)}},g=e=>de(e,{effectiveDirectory:r,editor:i,preferRuntimeEditor:a,onShowPopup:o}),v=e=>{let t=e.target;if(!(t instanceof Element)||t.closest($))return;let n=t.closest(V);n instanceof HTMLElement&&(e.preventDefault(),e.stopPropagation(),g(n))},y=e=>{if(e.key!==`Enter`&&e.key!==` `)return;let t=e.target;!(t instanceof HTMLElement)||t.getAttribute(`data-yuri-file-link`)!==`true`||(e.preventDefault(),e.stopPropagation(),g(t))};m(or);let b=new MutationObserver(()=>{m(or)});return b.observe(e,{childList:!0,subtree:!0}),e.addEventListener(`click`,v),e.addEventListener(`keydown`,y),()=>{t=!0,c.current!==null&&typeof window<`u`&&window.clearTimeout(c.current),c.current=null,b.disconnect(),e.removeEventListener(`click`,v),e.removeEventListener(`keydown`,y)}},u=[n,i,r,o,a,s],t[0]=n,t[1]=i,t[2]=r,t[3]=s,t[4]=o,t[5]=a,t[6]=l,t[7]=u):(l=t[6],u=t[7]),G.useEffect(l,u)},cr=({containerRef:e,onShowPopup:t,enableFullscreen:n,enablePanZoom:r,allowMermaidWheelEvents:i})=>{let a=p(e=>t?.(e)),o=!!t,s=p(t=>{if(!n||!o)return;let r=e.current;if(!r)return;let i=t.target;if(!(i instanceof Element)||i.closest(`button, a, [role="button"]`))return;let s=i.closest(qt);if(!s)return;if(s instanceof HTMLElement&&s.hasAttribute(`data-mermaid-suppress-click`)){s.removeAttribute(`data-mermaid-suppress-click`);return}let c=Array.from(r.querySelectorAll(qt)).indexOf(s);if(c<0)return;let l=s instanceof HTMLElement?s.getAttribute(`data-md-source`):null;if(!l||l.trim().length===0)return;let u=`Diagram ${c+1}`;a({open:!0,title:u,content:``,metadata:{tool:`mermaid-preview`,filename:u},mermaid:{url:`data:text/plain;charset=utf-8,${encodeURIComponent(l)}`,source:l,filename:u},previewSource:s instanceof HTMLElement?s:void 0})}),c=p(e=>{if(i||r)return;let t=e.target;t instanceof Element&&t.closest(`[data-markdown="mermaid-block"]`)&&e.stopPropagation()});d(`click`,s,e),G.useEffect(()=>{let t=e.current;if(t)return t.addEventListener(`wheel`,c,{capture:!0,passive:!0}),()=>{t.removeEventListener(`wheel`,c,!0)}},[e])},lr=24,ur=1,dr=12,fr=/[\s.,!?;:)\]]/,pr=(e,t)=>{let n=e<=12?2:e<=48?4:e<=96?8:Math.min(24,Math.ceil(e/8));return Math.max(1,Math.round(t/lr*n))},mr=(e,t)=>pr(e,t)*(1e3/t),hr=(e,t,n)=>{let r=Math.min(e.length,t+n);for(let t=r;t<Math.min(e.length,r+8);t+=1)if(fr.test(e[t]??``))return t+1;return r},gr=(e,t,n)=>{let[r,i]=G.useState(()=>t?0:e.length),a=G.useRef(r),o=G.useRef(0),s=G.useRef(null);return a.current=r,G.useEffect(()=>{if(!t||typeof window>`u`){o.current=0,s.current=null,i(e.length);return}a.current>e.length&&(a.current=e.length,o.current=0,i(e.length));let r=null,c=t=>{let l=Math.min(a.current,e.length);if(l>=e.length){r=null,s.current=null;return}let u=s.current;if(u===null){s.current=t,r=window.requestAnimationFrame(c);return}let d=Math.min(t-u,100);s.current=t,o.current+=mr(e.length-l,n)*(d/1e3);let f=Math.min(dr,Math.floor(o.current));if(f>=ur){o.current-=f;let t=hr(e,l,f);a.current=t,i(t)}r=window.requestAnimationFrame(c)};return a.current<e.length&&(r=window.requestAnimationFrame(c)),()=>{r!==null&&window.cancelAnimationFrame(r)}},[e,t,n]),t?e.slice(0,Math.min(r,e.length)):e},_r=(e,t,r,i=rr,a=n(),s=``,c=!1)=>{let{t:l}=h(),u=G.useMemo(()=>({copy:l(`markdownRenderer.code.actions.copyTitle`),copied:l(`markdownRenderer.code.actions.copiedTitle`),enableCodeWrap:l(`markdownRenderer.code.actions.enableWrapTitle`),disableCodeWrap:l(`markdownRenderer.code.actions.disableWrapTitle`),copyDiagram:l(`markdownRenderer.mermaid.actions.copySourceTitle`),downloadDiagram:l(`markdownRenderer.mermaid.actions.downloadSvgTitle`),zoomInDiagram:l(`markdownRenderer.mermaid.actions.zoomInTitle`),zoomOutDiagram:l(`markdownRenderer.mermaid.actions.zoomOutTitle`),resetDiagramView:l(`markdownRenderer.mermaid.actions.resetViewTitle`),previewLabel:l(`terminalView.preview.open`),previewTitle:l(`terminalView.preview.openTitle`)}),[l]),d=o(e=>e.codeBlockLineWrap),f=o(e=>e.setCodeBlockLineWrap),m=p(()=>{f(!o.getState().codeBlockLineWrap)});return G.useMemo(()=>({labels:u,mermaidControls:i,codeBlockLineWrap:d,deferCodeLineNumberSync:t,onToggleCodeBlockLineWrap:m,renderMermaid:t=>ge(t,e),onPreviewLoopback:r,imageTransportIdentity:a,imageEffectiveDirectory:s,imagePreviewEnabled:c}),[e,u,i,d,t,r,a,s,c])},vr=({containerRef:e,text:t,streaming:n,cacheKey:r,syntaxVars:i,ctx:a,reconcileMarkdownImageResources:o,onRichContentReady:s})=>{G.useEffect(()=>{M()},[]);let c=G.useRef(null),l=p(()=>{s?.()}),u=p(()=>{let t=e.current;if(t){if(!c.current){if(!Jt(t))return;c.current=gn(t);return}c.current.refresh()}});G.useLayoutEffect(()=>{let r=e.current,i=r?.querySelector(`[data-markdown-content]`)??r;if(i&&t&&i.childNodes.length===0){for(let e of kt(t)){let t=document.createElement(`div`);t.setAttribute(`data-md-block`,``),t.style.display=`contents`,t.innerHTML=e,Yn(t,a),i.appendChild(t)}o(i),n||l()}},[e,a,o,n,t]),G.useEffect(()=>()=>{c.current?.cleanup(),c.current=null},[]),G.useEffect(()=>{let i=e.current;if(!i)return;let s=i.querySelector(`[data-markdown-content]`)??i,c=!0,d=new AbortController,f=()=>{},p=()=>{},m=()=>{if(!c||n||d.signal.aborted)return;s.replaceChildren();let e=document.createElement(`div`);e.setAttribute(`data-md-block`,``),e.setAttribute(`data-md-render-fallback`,`text`),e.style.display=`contents`;let r=document.createElement(`span`);r.style.whiteSpace=`pre-wrap`,r.textContent=t,e.appendChild(r),s.appendChild(e),o(s),l()},h=e=>{if(!c)return;let t=Array.from(s.children);e.forEach((e,n)=>{let r=t[n];if(r||(r=document.createElement(`div`),r.setAttribute(`data-md-block`,``),r.style.display=`contents`,s.appendChild(r)),r.getAttribute(`data-md-id`)===e.id)return;let i=document.createElement(`div`);i.innerHTML=e.html,Yn(i,a);let o=Jt(r),c=Jt(i);se(r,i,{childrenOnly:!0,onBeforeElUpdated:(e,t)=>{if(we(e,t))return!1;if(fe(e,t),e instanceof HTMLImageElement&&t instanceof HTMLImageElement){let n=e.getAttribute(`data-md-image-source`);if(n&&n===t.getAttribute(`data-md-image-source`)){let n=e.getAttribute(`src`);n===null?t.removeAttribute(`src`):t.setAttribute(`src`,n),t.className=e.className;for(let n of[`data-md-image-state`,`data-md-placeholder-source`,`aria-busy`]){let r=e.getAttribute(n);r===null?t.removeAttribute(n):t.setAttribute(n,r)}}}return!e.isEqualNode(t)}}),r.setAttribute(`data-md-id`,e.id),(o||c||Jt(r))&&u()});let n=Jt(s),r=!1;for(let n=t.length-1;n>=e.length;--n){let e=t[n];e&&Jt(e)&&(r=!0),e?.remove()}(r||t.length>e.length&&n)&&u(),o(s),a.deferCodeLineNumberSync||jn(s,a.codeBlockLineWrap,a.labels),Oe(s,P,{signal:d.signal,priority:`visible`}),l()},g=e=>{try{h(e)}catch{m()}},_=()=>{It(t,n,r,d.signal).then(e=>{if(c){if(n){g(e);return}p=k(()=>g(e),{priority:`visible`})}}).catch(m)};return n?_():f=k(_,{priority:`visible`}),()=>{c=!1,d.abort(),f(),p()}},[e,t,n,r,a,o]),G.useEffect(()=>{let t=e.current;if(t)return Zn(t,a)},[e,a]),G.useEffect(()=>{let t=e.current,n=t?.querySelector(`[data-markdown-content]`)??t;if(n)for(let[e,t]of Object.entries(i))n.style.setProperty(e,t)},[e,i]),G.useEffect(()=>{let t=e.current,n=t?.querySelector(`[data-markdown-content]`)??t;n&&(a.deferCodeLineNumberSync||jn(n,a.codeBlockLineWrap,a.labels))},[e,a.codeBlockLineWrap,a.deferCodeLineNumberSync,a.labels]);let d=G.useRef(null),m=p(()=>{let t=e.current,n=t?.querySelector(`[data-markdown-content]`)??t;n&&(d.current!==null&&window.cancelAnimationFrame(d.current),d.current=window.requestAnimationFrame(()=>{d.current=null,kn(n)}))});f(e,m),G.useEffect(()=>()=>{d.current!==null&&window.cancelAnimationFrame(d.current)},[])},yr=e=>e===`tool`?`markdown-content markdown-tool`:e===`reasoning`?`markdown-content markdown-reasoning`:`markdown-content leading-relaxed`,br=e=>{let t=(0,he.c)(4),[n,r]=G.useState(e),i=G.useRef(e),a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>{i.current||(i.current=!0,r(!0))},t[0]=a):a=t[0];let o=p(a),s;return t[1]!==o||t[2]!==n?(s=[n,o],t[1]=o,t[2]=n,t[3]=s):s=t[3],s},xr=(e,t,n)=>{let r=G.useRef(n);r.current=n;let i=G.useRef(t);i.current=t;let a=p(e=>{if(!r.current)return;let t=e[0];if(!t)return;let n=t.borderBoxSize?.[0],a=n?n.blockSize:t.contentRect.height,o=n?n.inlineSize:t.contentRect.width;j(i.current,a,o)});f(e,a)},Sr=G.memo(e=>{let t=(0,he.c)(62),{content:n,part:r,messageId:i,isAnimated:a,skipFadeIn:o,className:s,isStreaming:u,disableStreamAnimation:d,variant:f,onShowPopup:m,enableFileReferences:h}=e,_=a===void 0||a,v=o!==void 0&&o,y=u!==void 0&&u,b=d!==void 0&&d,x=f===void 0?`assistant`:f,S=h===void 0||h,C=$n(),{editor:w,runtime:T}=c(),E=G.useRef(null),D=ee()??``,O=p(Er),k;t[0]!==D||t[1]!==O?(k=e=>{D&&O(D,e)},t[0]=D,t[1]=O,t[2]=k):k=t[2];let te=p(k),A=y&&!b,j;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(j=re(l()),t[3]=j):j=t[3];let M=gr(n,A,j.markdownPaceMs),[N,P]=br(A),F;t[4]===m?F=t[5]:(F={containerRef:E,onShowPopup:m,enableFullscreen:ir,enablePanZoom:rr.showPanZoomControls},t[4]=m,t[5]=F),cr(F);let se=S&&!y,I;t[6]!==w||t[7]!==D||t[8]!==m||t[9]!==T.isVSCode||t[10]!==se?(I={containerRef:E,effectiveDirectory:D,editor:w,preferRuntimeEditor:T.isVSCode,onShowPopup:m,enabled:se},t[6]=w,t[7]=D,t[8]=m,t[9]=T.isVSCode,t[10]=se,t[11]=I):I=t[11],sr(I);let L;t[12]!==w||t[13]!==D||t[14]!==S||t[15]!==y||t[16]!==m||t[17]!==T.isVSCode?(L=S&&!y?{effectiveDirectory:D,editor:w,preferRuntimeEditor:T.isVSCode,onShowPopup:m}:void 0,t[12]=w,t[13]=D,t[14]=S,t[15]=y,t[16]=m,t[17]=T.isVSCode,t[18]=L):L=t[18];let R;t[19]!==D||t[20]!==O||t[21]!==L?(R={containerRef:E,effectiveDirectory:D,openInAppBrowser:O,fileReference:L},t[19]=D,t[20]=O,t[21]=L,t[22]=R):R=t[22],er(R);let z;t[23]!==D||t[24]!==m?(z={containerRef:E,effectiveDirectory:D,onShowPopup:m},t[23]=D,t[24]=m,t[25]=z):z=t[25];let{reconcileMarkdownImageResources:B,transportIdentity:ce}=nr(z),V;t[26]===C?V=t[27]:(V=oe(C),t[26]=C,t[27]=V);let le=V,H=_r(C,A,D?te:void 0,rr,ce,D,!!m),U=`markdown-${r?.id?`part-${r.id}`:`message-${i}`}`,W;t[28]!==U||t[29]!==H||t[30]!==A||t[31]!==M||t[32]!==B||t[33]!==P||t[34]!==le?(W={containerRef:E,text:M,streaming:A,cacheKey:U,syntaxVars:le,ctx:H,reconcileMarkdownImageResources:B,onRichContentReady:P},t[28]=U,t[29]=H,t[30]=A,t[31]=M,t[32]=B,t[33]=P,t[34]=le,t[35]=W):W=t[35],vr(W);let ue;t[36]!==n||t[37]!==x?(ue=ae(n,x),t[36]=n,t[37]=x,t[38]=ue):ue=t[38],xr(E,ue,N&&!A);let de=!N||void 0,fe;t[39]===s?fe=t[40]:(fe=g(`relative break-words w-full min-w-0`,s),t[39]=s,t[40]=fe);let pe=N?`true`:`false`,me=N?`ready`:`pending`,K;t[41]!==M||t[42]!==N||t[43]!==x?(K=!N&&(0,Q.jsx)(`div`,{className:g(yr(x),`pointer-events-none absolute inset-0 overflow-clip`),children:(0,Q.jsx)(ie,{content:M})}),t[41]=M,t[42]=N,t[43]=x,t[44]=K):K=t[44];let ge=!N||void 0,q;t[45]!==N||t[46]!==x?(q=g(yr(x),!N&&`invisible`),t[45]=N,t[46]=x,t[47]=q):q=t[47];let J;t[48]!==ge||t[49]!==q?(J=(0,Q.jsx)(`div`,{"aria-hidden":ge,className:q,"data-markdown-content":!0}),t[48]=ge,t[49]=q,t[50]=J):J=t[50];let _e;t[51]!==de||t[52]!==fe||t[53]!==pe||t[54]!==me||t[55]!==K||t[56]!==J?(_e=(0,Q.jsxs)(`div`,{"aria-busy":de,className:fe,"data-markdown-ready":pe,"data-markdown-hydration":me,ref:E,children:[K,J]}),t[51]=de,t[52]=fe,t[53]=pe,t[54]=me,t[55]=K,t[56]=J,t[57]=_e):_e=t[57];let ve=_e;if(_){let e;return t[58]!==U||t[59]!==ve||t[60]!==v?(e=(0,Q.jsx)(ne,{skipAnimation:v,children:ve},U),t[58]=U,t[59]=ve,t[60]=v,t[61]=e):e=t[61],e}return ve},(e,t)=>e.content===t.content&&e.isStreaming===t.isStreaming&&e.disableStreamAnimation===t.disableStreamAnimation&&e.variant===t.variant&&e.isAnimated===t.isAnimated&&e.skipFadeIn===t.skipFadeIn&&e.className===t.className&&e.messageId===t.messageId&&e.onShowPopup===t.onShowPopup&&e.enableFileReferences===t.enableFileReferences&&e.part?.id===t.part?.id),Cr=G.memo(e=>{let t=(0,he.c)(55),{content:n,className:r,variant:i,disableLinkSafety:a,stripFrontmatter:o,onShowPopup:s,mermaidControls:l,mermaidTheme:u,allowMermaidWheelEvents:d,enableFileReferences:f}=e,m=i===void 0?`assistant`:i,h=o!==void 0&&o,_=l===void 0?rr:l,v=d!==void 0&&d,y=f===void 0||f,{editor:b,runtime:x}=c(),S=$n(),C=G.useRef(null),[w,T]=br(!1),E=ee()??``,D;t[0]!==n||t[1]!==h?(D=h?ar(n):n,t[0]=n,t[1]=h,t[2]=D):D=t[2];let O=D,k;t[3]!==v||t[4]!==_.showPanZoomControls||t[5]!==s?(k={containerRef:C,onShowPopup:s,enableFullscreen:ir,enablePanZoom:_.showPanZoomControls,allowMermaidWheelEvents:v},t[3]=v,t[4]=_.showPanZoomControls,t[5]=s,t[6]=k):k=t[6],cr(k);let te=p(Dr),ne;t[7]!==b||t[8]!==E||t[9]!==y||t[10]!==s||t[11]!==x.isVSCode?(ne={containerRef:C,effectiveDirectory:E,editor:b,preferRuntimeEditor:x.isVSCode,onShowPopup:s,enabled:y},t[7]=b,t[8]=E,t[9]=y,t[10]=s,t[11]=x.isVSCode,t[12]=ne):ne=t[12],sr(ne);let A=!a,re;t[13]!==b||t[14]!==E||t[15]!==y||t[16]!==s||t[17]!==x.isVSCode?(re=y?{effectiveDirectory:E,editor:b,preferRuntimeEditor:x.isVSCode,onShowPopup:s}:void 0,t[13]=b,t[14]=E,t[15]=y,t[16]=s,t[17]=x.isVSCode,t[18]=re):re=t[18];let j;t[19]!==E||t[20]!==te||t[21]!==re||t[22]!==A?(j={containerRef:C,enabled:A,effectiveDirectory:E,openInAppBrowser:te,fileReference:re},t[19]=E,t[20]=te,t[21]=re,t[22]=A,t[23]=j):j=t[23],er(j);let ae;t[24]!==E||t[25]!==s?(ae={containerRef:C,effectiveDirectory:E,onShowPopup:s},t[24]=E,t[25]=s,t[26]=ae):ae=t[26];let{reconcileMarkdownImageResources:M,transportIdentity:N}=nr(ae),P;t[27]===S?P=t[28]:(P=oe(S),t[27]=S,t[28]=P);let F=P,se=_r(u??S,!1,void 0,_,N,E,!!s),I=`simple:${m}`,L;t[29]!==se||t[30]!==M||t[31]!==O||t[32]!==T||t[33]!==F||t[34]!==I?(L={containerRef:C,text:O,streaming:!1,cacheKey:I,syntaxVars:F,ctx:se,reconcileMarkdownImageResources:M,onRichContentReady:T},t[29]=se,t[30]=M,t[31]=O,t[32]=T,t[33]=F,t[34]=I,t[35]=L):L=t[35],vr(L);let R=!w||void 0,z;t[36]===r?z=t[37]:(z=g(`relative break-words w-full min-w-0`,r),t[36]=r,t[37]=z);let B=w?`true`:`false`,ce=w?`ready`:`pending`,V;t[38]!==O||t[39]!==w||t[40]!==m?(V=!w&&(0,Q.jsx)(`div`,{className:g(yr(m),`pointer-events-none absolute inset-0 overflow-clip`),children:(0,Q.jsx)(ie,{content:O})}),t[38]=O,t[39]=w,t[40]=m,t[41]=V):V=t[41];let le=!w||void 0,H;t[42]!==w||t[43]!==m?(H=g(yr(m),!w&&`invisible`),t[42]=w,t[43]=m,t[44]=H):H=t[44];let U;t[45]!==le||t[46]!==H?(U=(0,Q.jsx)(`div`,{"aria-hidden":le,className:H,"data-markdown-content":!0}),t[45]=le,t[46]=H,t[47]=U):U=t[47];let W;return t[48]!==R||t[49]!==z||t[50]!==B||t[51]!==ce||t[52]!==V||t[53]!==U?(W=(0,Q.jsxs)(`div`,{"aria-busy":R,className:z,"data-markdown-ready":B,"data-markdown-hydration":ce,ref:C,children:[V,U]}),t[48]=R,t[49]=z,t[50]=B,t[51]=ce,t[52]=V,t[53]=U,t[54]=W):W=t[54],W},(e,t)=>{let n=e.mermaidControls??rr,r=t.mermaidControls??rr;return e.content===t.content&&e.variant===t.variant&&e.className===t.className&&e.disableLinkSafety===t.disableLinkSafety&&e.stripFrontmatter===t.stripFrontmatter&&e.onShowPopup===t.onShowPopup&&n.download===r.download&&n.copy===r.copy&&n.showPanZoomControls===r.showPanZoomControls&&e.mermaidTheme===t.mermaidTheme&&e.allowMermaidWheelEvents===t.allowMermaidWheelEvents&&e.enableFileReferences===t.enableFileReferences});function wr(e){e.removeAttribute(`data-yuri-file-link`),e.removeAttribute(`data-yuri-file-ref`),e.removeAttribute(`data-yuri-file-path`),e.removeAttribute(`data-yuri-file-binary`),e.getAttribute(`title`)===`Open file`&&e.removeAttribute(`title`),e.tagName.toLowerCase()!==`a`&&(e.removeAttribute(`role`),e.removeAttribute(`tabindex`))}function Tr(){}function Er(e,t){o.getState().openContextBrowser(e,t)}function Dr(e,t){o.getState().openContextBrowser(e,t)}export{Qn as n,Be as r,Sr as t};
10
+ `,l),n=t===-1?s.length:t,i=r[e];if(!i)continue;let o=wn(c,l),u=wn(c,n);!o||!u||l===n?Dn(i,a,a):Dn(i,On(o,u,a),a),l=n+1}}},An=e=>{window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>kn(e))})},jn=(e,t,n)=>{let r=e.querySelectorAll(`[data-component="markdown-code"]`);for(let e of Array.from(r)){let r=e.querySelector(`[data-md-code-body]`),i=e.querySelector(`pre`);r&&i&&!r.querySelector(`[data-md-code-line-numbers]`)&&(r.classList.add(`flex`,`gap-3`),r.insertBefore(Sn(i),i)),xn(e,t,n)}An(e)},Mn=(e,t,n,r)=>{yn(e,_n.check),e.setAttribute(`title`,t),e.setAttribute(`aria-label`,t),window.setTimeout(()=>{yn(e,_n[n]),e.setAttribute(`title`,r),e.setAttribute(`aria-label`,r)},2e3)},Nn=e=>{let t=e.querySelectorAll(`:not(pre) > code`);for(let e of Array.from(t))e.getAttribute(`data-markdown`)!==`inline-code`&&e.setAttribute(`data-markdown`,`inline-code`)},Pn=(e,t)=>{let n=e.querySelectorAll(`pre`);for(let e of Array.from(n)){if(e.querySelector(`code.language-mermaid`))continue;let n=e.parentElement;if(!n||n.closest(`[data-component="markdown-code"]`))continue;let r=e.querySelector(`code`)?.className.match(/language-([^\s"]+)/)?.[1],i=e.getAttribute(`data-md-label`)??e.getAttribute(`data-md-lang`)??Pe(r).label,a=document.createElement(`div`);a.setAttribute(`data-component`,`markdown-code`),a.className=`my-4 group overflow-clip rounded-2xl border border-border/80 bg-[var(--surface-elevated)]`;let o=document.createElement(`div`);o.className=`flex items-center justify-between border-b border-border/70 px-3 py-1.5`;let s=document.createElement(`span`);s.className=`font-mono text-[13px] text-muted-foreground`,s.textContent=i;let c=bn(`copy`,t.labels.copy,`copy-code`),l=bn(`textWrap`,t.codeBlockLineWrap?t.labels.disableCodeWrap:t.labels.enableCodeWrap,`toggle-code-wrap`);o.appendChild(s);let u=document.createElement(`div`);u.className=`flex items-center gap-1`,u.appendChild(l),u.appendChild(c),o.appendChild(u);let d=document.createElement(`div`);d.setAttribute(`data-md-code-body`,``),d.className=`px-3 py-2.5 overflow-x-auto`,n.replaceChild(a,e),e.style.margin=`0`,e.style.background=`transparent`,e.classList.add(`min-w-0`,`w-full`,`flex-1`),d.appendChild(e),a.appendChild(o),a.appendChild(d),xn(a,t.codeBlockLineWrap,t.labels)}},Fn=e=>{let t=e.querySelectorAll(`table`);for(let e of Array.from(t)){if(e.closest(`[data-markdown="table-wrapper"]`))continue;let t=document.createElement(`div`);t.className=`my-4`,t.setAttribute(`data-markdown`,`table-wrapper`);let n=document.createElement(`div`);n.setAttribute(`data-markdown`,`table-scroll`);let r=e.parentElement;if(r){r.replaceChild(t,e),e.setAttribute(`data-markdown`,`table`);for(let t of Array.from(e.querySelectorAll(`tr`)))t.setAttribute(`data-markdown`,`table-row`);for(let t of Array.from(e.querySelectorAll(`th`)))t.setAttribute(`data-markdown`,`table-header-cell`);for(let t of Array.from(e.querySelectorAll(`td`)))t.setAttribute(`data-markdown`,`table-cell`);n.appendChild(e),t.appendChild(n)}}},In=0,Ln=(e,t)=>{let n=e.querySelectorAll(`pre > code.language-mermaid`);for(let e of Array.from(n)){let n=e.parentElement;if(!n)continue;let r=(e.textContent??``).replace(/\s+$/,``),i=t.renderMermaid(r),a=document.createElement(`div`);a.setAttribute(`data-markdown`,`mermaid-block`),a.setAttribute(`data-md-source`,r),a.className=`group relative`;let o=document.createElement(`div`);o.setAttribute(`data-markdown`,`mermaid-scroll`);let s=document.createElement(`div`);if(s.setAttribute(`data-markdown`,`mermaid-toolbar`),s.className=`absolute top-1 right-2 flex items-center gap-1 opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 transition-opacity`,i.svg){a.setAttribute(`data-mermaid-render`,`svg`);let e=document.createElement(`div`);e.setAttribute(`data-markdown`,`mermaid-viewport`);let n=document.createElement(`div`);n.setAttribute(`data-markdown`,`mermaid`),n.setAttribute(`data-md-original-svg`,i.svg),n.innerHTML=i.svg;let c=n.querySelector(`svg`),l=++In;for(let[e,t]of[[`title[id]`,`aria-labelledby`],[`desc[id]`,`aria-describedby`]]){let n=c?.querySelector(e);n&&(n.id=`yuri-mermaid-${l}-${n.localName}`,c?.setAttribute(t,n.id))}if(e.appendChild(n),o.appendChild(e),t.mermaidControls.showPanZoomControls&&(s.appendChild(bn(`zoomIn`,t.labels.zoomInDiagram,`mermaid-zoom-in`)),s.appendChild(bn(`zoomOut`,t.labels.zoomOutDiagram,`mermaid-zoom-out`)),s.appendChild(bn(`fit`,t.labels.resetDiagramView,`mermaid-fit`))),t.mermaidControls.copy){let e=bn(`copy`,t.labels.copyDiagram,`mermaid-copy`);e.setAttribute(`data-md-source`,r),s.appendChild(e)}if(t.mermaidControls.download){let e=bn(`download`,t.labels.downloadDiagram,`mermaid-download`);e.setAttribute(`data-md-svg`,`1`),s.appendChild(e)}}else{a.setAttribute(`data-mermaid-render`,`source`);let e=document.createElement(`pre`);if(e.setAttribute(`data-markdown`,`mermaid-source`),e.textContent=r,o.appendChild(e),t.mermaidControls.copy){let e=bn(`copy`,t.labels.copyDiagram,`mermaid-copy`);e.setAttribute(`data-md-source`,r),s.appendChild(e)}}a.appendChild(o),a.appendChild(s);let c=n.parentElement;c&&c.replaceChild(a,n)}},Rn=(e,t)=>{let n=e.querySelectorAll(`a[href]`);for(let e of Array.from(n)){if(e.getAttribute(`data-md-link-decorated`)===`true`||e.getAttribute(`data-yuri-file-link`)===`true`)continue;let n=e.getAttribute(`href`)??``;if(!w(n))continue;e.setAttribute(`data-md-link-decorated`,`true`);let r=C(n);if(r){let t=document.createElement(`span`);t.className=`mr-1 inline-flex size-[18px] items-center justify-center rounded border border-[var(--border)] bg-[var(--interactive-hover)] align-middle`;let n=document.createElement(`img`);n.setAttribute(`data-md-link-favicon`,`true`),n.src=r,n.alt=``,n.setAttribute(`aria-hidden`,`true`),n.loading=`lazy`,n.decoding=`async`,n.className=`size-3.5 rounded-sm`,n.addEventListener(`error`,()=>t.remove(),{once:!0}),t.appendChild(n),e.parentNode?.insertBefore(t,e)}if(t.onPreviewLoopback&&S(n)){let r=document.createElement(`button`);r.type=`button`,r.className=`ml-1 align-middle ${vn}`,r.setAttribute(`data-md-action`,`preview-loopback`),r.setAttribute(`data-md-url`,n),r.setAttribute(`title`,t.labels.previewTitle),r.setAttribute(`aria-label`,t.labels.previewLabel),yn(r,_n.download),e.parentNode?.insertBefore(r,e.nextSibling)}}},zn=`img:not([data-md-link-favicon="true"])`,Bn=`[data-md-image-presentation="true"]`,Vn=`data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" width="576" height="324" viewBox="0 0 576 324"%3E%3C/svg%3E`,Hn=[`block`,`max-w-full`,`rounded-xl`,`border`,`border-border/80`,`bg-[var(--surface-muted)]`,`transition-colors`,`focus-visible:outline`,`focus-visible:outline-2`,`focus-visible:outline-offset-2`,`focus-visible:outline-[var(--interactive-focus-ring)]`],Un=[`cursor-pointer`,`hover:bg-interactive-hover/60`],Wn=[`object-contain`],Gn=e=>{let t=e.parentElement;if(t?.matches(Bn))return t;let n=document.createElement(`span`);n.setAttribute(`data-md-image-presentation`,`true`),n.className=`relative my-4 block w-fit max-w-full`;let r=document.createElement(`span`);r.setAttribute(`data-md-image-placeholder-visual`,`true`),r.setAttribute(`aria-hidden`,`true`),r.className=`pointer-events-none absolute inset-0 flex items-center justify-center text-muted-foreground`,r.classList.add(`yuri-image-loading`),_()&&n.setAttribute(`data-mobile-image`,`true`);let i=document.createElement(`span`);i.className=`relative flex size-14 items-center justify-center rounded-2xl border border-border/80 bg-[var(--surface-elevated)] shadow-sm`,yn(i,_n.image);let a=document.createElement(`span`);a.setAttribute(`data-md-image-download-badge`,`true`),a.className=`absolute -right-1.5 -bottom-1.5 flex size-6 items-center justify-center rounded-full border border-border bg-[var(--surface-elevated)] text-foreground shadow-sm`,yn(a,_n.imageDownload);let o=document.createElement(`span`);return o.setAttribute(`data-md-image-loading-badge`,`true`),o.className=`absolute -right-1.5 -bottom-1.5 hidden size-6 items-center justify-center rounded-full border border-border bg-[var(--surface-elevated)] text-foreground shadow-sm`,yn(o,_n.imageLoading),i.appendChild(a),i.appendChild(o),r.appendChild(i),t?.replaceChild(n,e),n.appendChild(e),n.appendChild(r),n},Kn=e=>{e.src=Vn,e.setAttribute(`data-md-placeholder-source`,Vn),e.setAttribute(`data-md-image-state`,`placeholder`),e.classList.add(...Wn)},qn=e=>{e.removeAttribute(`data-md-image-state`),e.removeAttribute(`data-md-placeholder-source`),e.removeAttribute(`aria-busy`),e.classList.remove(...Wn)},Jn=(e,t)=>{if(!t.imagePreviewEnabled)return;let n=e.querySelectorAll(zn);for(let e of Array.from(n)){let n=e.getAttribute(`data-md-image-source`)??e.getAttribute(`src`)??``,r=T(n,t.imageEffectiveDirectory);if(!E(r)){e.setAttribute(`data-md-image-source`,n),Gn(e),e.setAttribute(`data-md-image-state`,e.complete&&e.naturalWidth>0?`loaded`:`loading`);continue}e.classList.add(...Hn,...Un),e.setAttribute(`role`,`button`),e.setAttribute(`tabindex`,`0`),e.setAttribute(`data-md-image-source`,n),Gn(e),Kn(e)}},Yn=(e,t)=>{Nn(e),Ln(e,t),Pn(e,t),Fn(e),Rn(e,t),Jn(e,t),le(e)},Xn=(e,t,n)=>{let r=new Blob([t],{type:n}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=e,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i)},Zn=(e,t)=>{let n=e=>{let n=e.target;if(!(n instanceof Element))return;let r=n.closest(`[data-md-action]`);if(!r)return;let i=r.getAttribute(`data-md-action`)??``;if(i===`copy-code`){let e=r.closest(`[data-component="markdown-code"]`)?.querySelector(`code`)?.textContent??``;e&&m(e).then(()=>Mn(r,t.labels.copied,`copy`,t.labels.copy));return}if(i===`toggle-code-wrap`){e.preventDefault(),t.onToggleCodeBlockLineWrap?.();return}if(i===`mermaid-copy`){let e=r.getAttribute(`data-md-source`)??``;e&&m(e).then(()=>Mn(r,t.labels.copied,`copy`,t.labels.copyDiagram));return}if(i===`mermaid-zoom-in`||i===`mermaid-zoom-out`||i===`mermaid-fit`){e.preventDefault();let t=cn(r.closest(`[data-markdown="mermaid-block"]`));i===`mermaid-zoom-in`?t?.zoomIn():i===`mermaid-zoom-out`?t?.zoomOut():t?.fit();return}if(i===`mermaid-download`){let e=r.closest(`[data-markdown="mermaid-block"]`)?.querySelector(`[data-markdown="mermaid"]`),t=e?.getAttribute(`data-md-original-svg`)??e?.innerHTML??``;t&&Xn(`diagram.svg`,t,`image/svg+xml;charset=utf-8`);return}if(i===`preview-loopback`){e.preventDefault();let n=r.getAttribute(`data-md-url`)??``;n&&t.onPreviewLoopback?.(n);return}};return e.addEventListener(`click`,n),()=>e.removeEventListener(`click`,n)},Qn=e({MarkdownRenderer:()=>Sr,SimpleMarkdownRenderer:()=>Cr}),Q=i(),$n=()=>{let e=(0,he.c)(4),t=y(),n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=b(!1),e[0]=n):n=e[0];let r=n,i;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(i=b(!0),e[1]=i):i=e[1];let a=i,o;return e[2]===t?.currentTheme?o=e[3]:(o=t?.currentTheme??(typeof window<`u`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?a:r),e[2]=t?.currentTheme,e[3]=o),o},er=e=>{let t=(0,he.c)(5),{containerRef:n,enabled:r,effectiveDirectory:i,openInAppBrowser:a,fileReference:o}=e,s;t[0]!==i||t[1]!==r||t[2]!==o||t[3]!==a?(s=e=>{if(r===!1||e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;let t=e.target;if(!(t instanceof Element)||t.closest($))return;let n=t.closest(`a[href]`);if(!(n instanceof HTMLAnchorElement)||n.getAttribute(`data-yuri-file-link`)===`true`)return;let s=n.getAttribute(`href`)??``;if(H(s)){e.preventDefault(),e.stopPropagation(),o&&B(s,o.effectiveDirectory,`href`)&&de(n,o);return}if(!w(s))return;e.preventDefault(),e.stopPropagation();let c=(i||``).trim();if(!_()&&c&&a){a(c,s);return}x(s)},t[0]=i,t[1]=r,t[2]=o,t[3]=a,t[4]=s):s=t[4];let c=f(s);d(`click`,c,n)},$=`img:not([data-md-link-favicon="true"])`,tr=e=>e.getAttribute(`data-md-image-source`)??e.getAttribute(`src`)??``,nr=({containerRef:e,effectiveDirectory:t,onShowPopup:r})=>{let i=G.useRef(null);i.current??=n();let a=i.current,o=!!r,s=f(e=>r?.(e)),c=G.useRef(()=>{}),l=G.useRef(new Map),u=G.useRef(null),d=G.useMemo(()=>e=>c.current(e),[]);return G.useLayoutEffect(()=>{let n=l.current;if(u.current!==null&&(clearTimeout(u.current),u.current=null),c.current=()=>{},!o){for(let[e,t]of n)t.controller?.abort(),t.release?.(),n.delete(e);return}let r=e.current;if(!r)return;let i=e=>{let n=Array.from(r.querySelectorAll($));if(n.indexOf(e)<0)return;let i=n.map(e=>({url:tr(e),filename:e.alt||tr(e)||void 0})).filter(e=>e.url),a=tr(e),o=i.findIndex(e=>e.url===a),c=e.alt||a;s({open:!0,title:c,content:``,metadata:{tool:`image-preview`,filename:c},previewSource:e,image:{url:a,filename:c,gallery:i,index:Math.max(0,o),directory:t}})},d=e=>{let t=n.get(e);t&&(t.controller?.abort(),t.release?.(),n.delete(e))},f=e=>{let n=tr(e),r=T(n,t);if(E(r))return`${a}\n${t}\n${n}`},p=e=>{let t=f(e);if(!t){d(e);return}let r=n.get(e);if(r?.key===t)return r;d(e);let i={key:t};return n.set(e,i),i},m=(e,i)=>{if(i.controller||i.objectUrl||!r.contains(e))return;let a=tr(e),o=T(a,t);if(!E(o)){d(e);return}let s=new AbortController;i.controller=s,e.setAttribute(`data-md-image-state`,`loading`),e.setAttribute(`aria-busy`,`true`),D(o.path,s.signal).then(t=>{let r=n.get(e);if(!r||r!==i||r.controller!==s||s.signal.aborted){t.release();return}r.controller=void 0,r.objectUrl=t.url,r.release=t.release,e.src=t.url}).catch(()=>{let t=n.get(e);t===i&&(t.controller=void 0,e.removeAttribute(`aria-busy`),e.setAttribute(`data-md-image-state`,`error`))})};c.current=e=>{for(let[t,r]of n)(!e.contains(t)||f(t)!==r.key)&&d(t);for(let t of Array.from(e.querySelectorAll($))){let e=p(t);e&&!e.objectUrl&&m(t,e)}},c.current(r);let h=e=>{let t=p(e);if(t&&!t.objectUrl){m(e,t);return}i(e)},g=e=>{let t=e.target;if(!(t instanceof Element))return;let n=t.closest($);n&&(e.preventDefault(),e.stopPropagation(),h(n))},_=e=>{if(e.key!==`Enter`&&e.key!==` `)return;let t=e.target;!(t instanceof HTMLImageElement)||!t.matches($)||(e.preventDefault(),e.stopPropagation(),h(t))},v=e=>{let t=e.target;t instanceof Element&&t.closest($)&&(e.preventDefault(),e.stopPropagation())},y=e=>{let t=e.target;!(t instanceof HTMLImageElement)||!t.matches($)||t.getAttribute(`src`)!==t.getAttribute(`data-md-placeholder-source`)&&(qn(t),t.setAttribute(`data-md-image-state`,`loaded`))},b=e=>{let t=e.target;!(t instanceof HTMLImageElement)||!t.matches($)||(t.removeAttribute(`aria-busy`),t.setAttribute(`data-md-image-state`,`error`))};return r.addEventListener(`load`,y,!0),r.addEventListener(`error`,b,!0),r.addEventListener(`click`,g),r.addEventListener(`keydown`,_),r.addEventListener(`contextmenu`,v),()=>{c.current=()=>{},r.removeEventListener(`load`,y,!0),r.removeEventListener(`error`,b,!0),r.removeEventListener(`click`,g),r.removeEventListener(`keydown`,_),r.removeEventListener(`contextmenu`,v),u.current=setTimeout(()=>{u.current=null;for(let e of Array.from(n.keys()))r.contains(e)&&Kn(e),d(e)},0)}},[e,t,o,a]),{reconcileMarkdownImageResources:d,transportIdentity:a}},rr={download:!0,copy:!0,showPanZoomControls:!0},ir=!0,ar=e=>{let t=e.match(/^(?:\uFEFF)?(---|\+\+\+)[^\S\r\n]*\r?\n[\s\S]*?\r?\n\1[^\S\r\n]*(?:\r?\n|$)/);return t?e.slice(t[0].length):e},or=160,sr=e=>{let t=(0,he.c)(8),{containerRef:n,effectiveDirectory:r,editor:i,preferRuntimeEditor:a,onShowPopup:o,enabled:s}=e,c=G.useRef(null),l,u;t[0]!==n||t[1]!==i||t[2]!==r||t[3]!==s||t[4]!==o||t[5]!==a?(l=()=>{let e=n.current;if(!e)return;let t=!1,l=_(),u=U(),d=s,f=wr,p=()=>{let t=e.querySelectorAll(V);for(let e of Array.from(t))f(e)};if(!d){p();return}let m=e=>{let n=e===void 0?0:e;if(c.current!==null&&typeof window<`u`&&window.clearTimeout(c.current),typeof window>`u`){h();return}c.current=window.setTimeout(()=>{c.current=null,window.requestAnimationFrame(()=>{t||h()})},n)},h=()=>{let n=e.querySelectorAll(`[data-markdown="inline-code"], a, ${me}`),i=0;for(let a of Array.from(n)){let n=ue(a),o=B(n,r,a.tagName.toLowerCase()===`a`?`href`:`path`);if(!o){f(a);continue}if(i>=u){f(a);continue}i+=1,(a.getAttribute(`data-yuri-file-link`)!==`true`||a.getAttribute(`data-yuri-file-path`)!==o.resolvedPath)&&ce(o.resolvedPath,r).then(n=>{if(t||!e.contains(a))return;let i=ue(a),s=B(i,r,a.tagName.toLowerCase()===`a`?`href`:`path`);if(!(!s||s.resolvedPath!==o.resolvedPath)){if(!W(s.resolvedPath,n,l)){f(a);return}a.setAttribute(`data-yuri-file-link`,`true`),a.setAttribute(`data-yuri-file-ref`,i),a.setAttribute(`data-yuri-file-path`,s.resolvedPath),a.setAttribute(`data-yuri-file-binary`,String(n.isBinary)),a.setAttribute(`title`,pe),a.tagName.toLowerCase()!==`a`&&(a.setAttribute(`role`,`button`),a.setAttribute(`tabindex`,`0`))}}).catch(Tr)}},g=e=>de(e,{effectiveDirectory:r,editor:i,preferRuntimeEditor:a,onShowPopup:o}),v=e=>{let t=e.target;if(!(t instanceof Element)||t.closest($))return;let n=t.closest(V);n instanceof HTMLElement&&(e.preventDefault(),e.stopPropagation(),g(n))},y=e=>{if(e.key!==`Enter`&&e.key!==` `)return;let t=e.target;!(t instanceof HTMLElement)||t.getAttribute(`data-yuri-file-link`)!==`true`||(e.preventDefault(),e.stopPropagation(),g(t))};m(or);let b=new MutationObserver(()=>{m(or)});return b.observe(e,{childList:!0,subtree:!0}),e.addEventListener(`click`,v),e.addEventListener(`keydown`,y),()=>{t=!0,c.current!==null&&typeof window<`u`&&window.clearTimeout(c.current),c.current=null,b.disconnect(),e.removeEventListener(`click`,v),e.removeEventListener(`keydown`,y)}},u=[n,i,r,o,a,s],t[0]=n,t[1]=i,t[2]=r,t[3]=s,t[4]=o,t[5]=a,t[6]=l,t[7]=u):(l=t[6],u=t[7]),G.useEffect(l,u)},cr=({containerRef:e,onShowPopup:t,enableFullscreen:n,enablePanZoom:r,allowMermaidWheelEvents:i})=>{let a=f(e=>t?.(e)),o=!!t,s=f(t=>{if(!n||!o)return;let r=e.current;if(!r)return;let i=t.target;if(!(i instanceof Element)||i.closest(`button, a, [role="button"]`))return;let s=i.closest(qt);if(!s)return;if(s instanceof HTMLElement&&s.hasAttribute(`data-mermaid-suppress-click`)){s.removeAttribute(`data-mermaid-suppress-click`);return}let c=Array.from(r.querySelectorAll(qt)).indexOf(s);if(c<0)return;let l=s instanceof HTMLElement?s.getAttribute(`data-md-source`):null;if(!l||l.trim().length===0)return;let u=`Diagram ${c+1}`;a({open:!0,title:u,content:``,metadata:{tool:`mermaid-preview`,filename:u},mermaid:{url:`data:text/plain;charset=utf-8,${encodeURIComponent(l)}`,source:l,filename:u},previewSource:s instanceof HTMLElement?s:void 0})}),c=f(e=>{if(i||r)return;let t=e.target;t instanceof Element&&t.closest(`[data-markdown="mermaid-block"]`)&&e.stopPropagation()});d(`click`,s,e),G.useEffect(()=>{let t=e.current;if(t)return t.addEventListener(`wheel`,c,{capture:!0,passive:!0}),()=>{t.removeEventListener(`wheel`,c,!0)}},[e])},lr=24,ur=1,dr=12,fr=/[\s.,!?;:)\]]/,pr=(e,t)=>{let n=e<=12?2:e<=48?4:e<=96?8:Math.min(24,Math.ceil(e/8));return Math.max(1,Math.round(t/lr*n))},mr=(e,t)=>pr(e,t)*(1e3/t),hr=(e,t,n)=>{let r=Math.min(e.length,t+n);for(let t=r;t<Math.min(e.length,r+8);t+=1)if(fr.test(e[t]??``))return t+1;return r},gr=(e,t,n)=>{let[r,i]=G.useState(()=>t?0:e.length),a=G.useRef(r),o=G.useRef(0),s=G.useRef(null);return a.current=r,G.useEffect(()=>{if(!t||typeof window>`u`){o.current=0,s.current=null,i(e.length);return}a.current>e.length&&(a.current=e.length,o.current=0,i(e.length));let r=null,c=t=>{let l=Math.min(a.current,e.length);if(l>=e.length){r=null,s.current=null;return}let u=s.current;if(u===null){s.current=t,r=window.requestAnimationFrame(c);return}let d=Math.min(t-u,100);s.current=t,o.current+=mr(e.length-l,n)*(d/1e3);let f=Math.min(dr,Math.floor(o.current));if(f>=ur){o.current-=f;let t=hr(e,l,f);a.current=t,i(t)}r=window.requestAnimationFrame(c)};return a.current<e.length&&(r=window.requestAnimationFrame(c)),()=>{r!==null&&window.cancelAnimationFrame(r)}},[e,t,n]),t?e.slice(0,Math.min(r,e.length)):e},_r=(e,t,r,i=rr,a=n(),s=``,c=!1)=>{let{t:l}=h(),u=G.useMemo(()=>({copy:l(`markdownRenderer.code.actions.copyTitle`),copied:l(`markdownRenderer.code.actions.copiedTitle`),enableCodeWrap:l(`markdownRenderer.code.actions.enableWrapTitle`),disableCodeWrap:l(`markdownRenderer.code.actions.disableWrapTitle`),copyDiagram:l(`markdownRenderer.mermaid.actions.copySourceTitle`),downloadDiagram:l(`markdownRenderer.mermaid.actions.downloadSvgTitle`),zoomInDiagram:l(`markdownRenderer.mermaid.actions.zoomInTitle`),zoomOutDiagram:l(`markdownRenderer.mermaid.actions.zoomOutTitle`),resetDiagramView:l(`markdownRenderer.mermaid.actions.resetViewTitle`),previewLabel:l(`terminalView.preview.open`),previewTitle:l(`terminalView.preview.openTitle`)}),[l]),d=o(e=>e.codeBlockLineWrap),p=o(e=>e.setCodeBlockLineWrap),m=f(()=>{p(!o.getState().codeBlockLineWrap)});return G.useMemo(()=>({labels:u,mermaidControls:i,codeBlockLineWrap:d,deferCodeLineNumberSync:t,onToggleCodeBlockLineWrap:m,renderMermaid:t=>ge(t,e),onPreviewLoopback:r,imageTransportIdentity:a,imageEffectiveDirectory:s,imagePreviewEnabled:c}),[e,u,i,d,t,r,a,s,c])},vr=({containerRef:e,text:t,streaming:n,cacheKey:r,syntaxVars:i,ctx:a,reconcileMarkdownImageResources:o,onRichContentReady:s})=>{G.useEffect(()=>{M()},[]);let c=G.useRef(null),l=f(()=>{s?.()}),u=f(()=>{let t=e.current;if(t){if(!c.current){if(!Jt(t))return;c.current=gn(t);return}c.current.refresh()}});G.useLayoutEffect(()=>{let r=e.current,i=r?.querySelector(`[data-markdown-content]`)??r;if(i&&t&&i.childNodes.length===0){for(let e of kt(t)){let t=document.createElement(`div`);t.setAttribute(`data-md-block`,``),t.style.display=`contents`,t.innerHTML=e,Yn(t,a),i.appendChild(t)}o(i),n||l()}},[e,a,o,n,t]),G.useEffect(()=>()=>{c.current?.cleanup(),c.current=null},[]),G.useEffect(()=>{let i=e.current;if(!i)return;let s=i.querySelector(`[data-markdown-content]`)??i,c=!0,d=new AbortController,f=()=>{},p=()=>{},m=()=>{if(!c||n||d.signal.aborted)return;s.replaceChildren();let e=document.createElement(`div`);e.setAttribute(`data-md-block`,``),e.setAttribute(`data-md-render-fallback`,`text`),e.style.display=`contents`;let r=document.createElement(`span`);r.style.whiteSpace=`pre-wrap`,r.textContent=t,e.appendChild(r),s.appendChild(e),o(s),l()},h=e=>{if(!c)return;let t=Array.from(s.children);e.forEach((e,n)=>{let r=t[n];if(r||(r=document.createElement(`div`),r.setAttribute(`data-md-block`,``),r.style.display=`contents`,s.appendChild(r)),r.getAttribute(`data-md-id`)===e.id)return;let i=document.createElement(`div`);i.innerHTML=e.html,Yn(i,a);let o=Jt(r),c=Jt(i);se(r,i,{childrenOnly:!0,onBeforeElUpdated:(e,t)=>{if(we(e,t))return!1;if(fe(e,t),e instanceof HTMLImageElement&&t instanceof HTMLImageElement){let n=e.getAttribute(`data-md-image-source`);if(n&&n===t.getAttribute(`data-md-image-source`)){let n=e.getAttribute(`src`);n===null?t.removeAttribute(`src`):t.setAttribute(`src`,n),t.className=e.className;for(let n of[`data-md-image-state`,`data-md-placeholder-source`,`aria-busy`]){let r=e.getAttribute(n);r===null?t.removeAttribute(n):t.setAttribute(n,r)}}}return!e.isEqualNode(t)}}),r.setAttribute(`data-md-id`,e.id),(o||c||Jt(r))&&u()});let n=Jt(s),r=!1;for(let n=t.length-1;n>=e.length;--n){let e=t[n];e&&Jt(e)&&(r=!0),e?.remove()}(r||t.length>e.length&&n)&&u(),o(s),a.deferCodeLineNumberSync||jn(s,a.codeBlockLineWrap,a.labels),Oe(s,P,{signal:d.signal,priority:`visible`}),l()},g=e=>{try{h(e)}catch{m()}},_=()=>{It(t,n,r,d.signal).then(e=>{if(c){if(n){g(e);return}p=k(()=>g(e),{priority:`visible`})}}).catch(m)};return n?_():f=k(_,{priority:`visible`}),()=>{c=!1,d.abort(),f(),p()}},[e,t,n,r,a,o]),G.useEffect(()=>{let t=e.current;if(t)return Zn(t,a)},[e,a]),G.useEffect(()=>{let t=e.current,n=t?.querySelector(`[data-markdown-content]`)??t;if(n)for(let[e,t]of Object.entries(i))n.style.setProperty(e,t)},[e,i]),G.useEffect(()=>{let t=e.current,n=t?.querySelector(`[data-markdown-content]`)??t;n&&(a.deferCodeLineNumberSync||jn(n,a.codeBlockLineWrap,a.labels))},[e,a.codeBlockLineWrap,a.deferCodeLineNumberSync,a.labels]);let d=G.useRef(null),m=f(()=>{let t=e.current,n=t?.querySelector(`[data-markdown-content]`)??t;n&&(d.current!==null&&window.cancelAnimationFrame(d.current),d.current=window.requestAnimationFrame(()=>{d.current=null,kn(n)}))});p(e,m),G.useEffect(()=>()=>{d.current!==null&&window.cancelAnimationFrame(d.current)},[])},yr=e=>e===`tool`?`markdown-content markdown-tool`:e===`reasoning`?`markdown-content markdown-reasoning`:`markdown-content leading-relaxed`,br=e=>{let t=(0,he.c)(4),[n,r]=G.useState(e),i=G.useRef(e),a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>{i.current||(i.current=!0,r(!0))},t[0]=a):a=t[0];let o=f(a),s;return t[1]!==o||t[2]!==n?(s=[n,o],t[1]=o,t[2]=n,t[3]=s):s=t[3],s},xr=(e,t,n)=>{let r=G.useRef(n);r.current=n;let i=G.useRef(t);i.current=t;let a=f(e=>{if(!r.current)return;let t=e[0];if(!t)return;let n=t.borderBoxSize?.[0],a=n?n.blockSize:t.contentRect.height,o=n?n.inlineSize:t.contentRect.width;j(i.current,a,o)});p(e,a)},Sr=G.memo(e=>{let t=(0,he.c)(62),{content:n,part:r,messageId:i,isAnimated:a,skipFadeIn:o,className:s,isStreaming:u,disableStreamAnimation:d,variant:p,onShowPopup:m,enableFileReferences:h}=e,_=a===void 0||a,v=o!==void 0&&o,y=u!==void 0&&u,b=d!==void 0&&d,x=p===void 0?`assistant`:p,S=h===void 0||h,C=$n(),{editor:w,runtime:T}=c(),E=G.useRef(null),D=ee()??``,O=f(Er),k;t[0]!==D||t[1]!==O?(k=e=>{D&&O(D,e)},t[0]=D,t[1]=O,t[2]=k):k=t[2];let te=f(k),A=y&&!b,j;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(j=re(l()),t[3]=j):j=t[3];let M=gr(n,A,j.markdownPaceMs),[N,P]=br(A),F;t[4]===m?F=t[5]:(F={containerRef:E,onShowPopup:m,enableFullscreen:ir,enablePanZoom:rr.showPanZoomControls},t[4]=m,t[5]=F),cr(F);let se=S&&!y,I;t[6]!==w||t[7]!==D||t[8]!==m||t[9]!==T.isVSCode||t[10]!==se?(I={containerRef:E,effectiveDirectory:D,editor:w,preferRuntimeEditor:T.isVSCode,onShowPopup:m,enabled:se},t[6]=w,t[7]=D,t[8]=m,t[9]=T.isVSCode,t[10]=se,t[11]=I):I=t[11],sr(I);let L;t[12]!==w||t[13]!==D||t[14]!==S||t[15]!==y||t[16]!==m||t[17]!==T.isVSCode?(L=S&&!y?{effectiveDirectory:D,editor:w,preferRuntimeEditor:T.isVSCode,onShowPopup:m}:void 0,t[12]=w,t[13]=D,t[14]=S,t[15]=y,t[16]=m,t[17]=T.isVSCode,t[18]=L):L=t[18];let R;t[19]!==D||t[20]!==O||t[21]!==L?(R={containerRef:E,effectiveDirectory:D,openInAppBrowser:O,fileReference:L},t[19]=D,t[20]=O,t[21]=L,t[22]=R):R=t[22],er(R);let z;t[23]!==D||t[24]!==m?(z={containerRef:E,effectiveDirectory:D,onShowPopup:m},t[23]=D,t[24]=m,t[25]=z):z=t[25];let{reconcileMarkdownImageResources:B,transportIdentity:ce}=nr(z),V;t[26]===C?V=t[27]:(V=oe(C),t[26]=C,t[27]=V);let le=V,H=_r(C,A,D?te:void 0,rr,ce,D,!!m),U=`markdown-${r?.id?`part-${r.id}`:`message-${i}`}`,W;t[28]!==U||t[29]!==H||t[30]!==A||t[31]!==M||t[32]!==B||t[33]!==P||t[34]!==le?(W={containerRef:E,text:M,streaming:A,cacheKey:U,syntaxVars:le,ctx:H,reconcileMarkdownImageResources:B,onRichContentReady:P},t[28]=U,t[29]=H,t[30]=A,t[31]=M,t[32]=B,t[33]=P,t[34]=le,t[35]=W):W=t[35],vr(W);let ue;t[36]!==n||t[37]!==x?(ue=ae(n,x),t[36]=n,t[37]=x,t[38]=ue):ue=t[38],xr(E,ue,N&&!A);let de=!N||void 0,fe;t[39]===s?fe=t[40]:(fe=g(`relative break-words w-full min-w-0`,s),t[39]=s,t[40]=fe);let pe=N?`true`:`false`,me=N?`ready`:`pending`,K;t[41]!==M||t[42]!==N||t[43]!==x?(K=!N&&(0,Q.jsx)(`div`,{className:g(yr(x),`pointer-events-none absolute inset-0 overflow-clip`),children:(0,Q.jsx)(ie,{content:M})}),t[41]=M,t[42]=N,t[43]=x,t[44]=K):K=t[44];let ge=!N||void 0,q;t[45]!==N||t[46]!==x?(q=g(yr(x),!N&&`invisible`),t[45]=N,t[46]=x,t[47]=q):q=t[47];let J;t[48]!==ge||t[49]!==q?(J=(0,Q.jsx)(`div`,{"aria-hidden":ge,className:q,"data-markdown-content":!0}),t[48]=ge,t[49]=q,t[50]=J):J=t[50];let _e;t[51]!==de||t[52]!==fe||t[53]!==pe||t[54]!==me||t[55]!==K||t[56]!==J?(_e=(0,Q.jsxs)(`div`,{"aria-busy":de,className:fe,"data-markdown-ready":pe,"data-markdown-hydration":me,ref:E,children:[K,J]}),t[51]=de,t[52]=fe,t[53]=pe,t[54]=me,t[55]=K,t[56]=J,t[57]=_e):_e=t[57];let ve=_e;if(_){let e;return t[58]!==U||t[59]!==ve||t[60]!==v?(e=(0,Q.jsx)(ne,{skipAnimation:v,children:ve},U),t[58]=U,t[59]=ve,t[60]=v,t[61]=e):e=t[61],e}return ve},(e,t)=>e.content===t.content&&e.isStreaming===t.isStreaming&&e.disableStreamAnimation===t.disableStreamAnimation&&e.variant===t.variant&&e.isAnimated===t.isAnimated&&e.skipFadeIn===t.skipFadeIn&&e.className===t.className&&e.messageId===t.messageId&&e.onShowPopup===t.onShowPopup&&e.enableFileReferences===t.enableFileReferences&&e.part?.id===t.part?.id),Cr=G.memo(e=>{let t=(0,he.c)(55),{content:n,className:r,variant:i,disableLinkSafety:a,stripFrontmatter:o,onShowPopup:s,mermaidControls:l,mermaidTheme:u,allowMermaidWheelEvents:d,enableFileReferences:p}=e,m=i===void 0?`assistant`:i,h=o!==void 0&&o,_=l===void 0?rr:l,v=d!==void 0&&d,y=p===void 0||p,{editor:b,runtime:x}=c(),S=$n(),C=G.useRef(null),[w,T]=br(!1),E=ee()??``,D;t[0]!==n||t[1]!==h?(D=h?ar(n):n,t[0]=n,t[1]=h,t[2]=D):D=t[2];let O=D,k;t[3]!==v||t[4]!==_.showPanZoomControls||t[5]!==s?(k={containerRef:C,onShowPopup:s,enableFullscreen:ir,enablePanZoom:_.showPanZoomControls,allowMermaidWheelEvents:v},t[3]=v,t[4]=_.showPanZoomControls,t[5]=s,t[6]=k):k=t[6],cr(k);let te=f(Dr),ne;t[7]!==b||t[8]!==E||t[9]!==y||t[10]!==s||t[11]!==x.isVSCode?(ne={containerRef:C,effectiveDirectory:E,editor:b,preferRuntimeEditor:x.isVSCode,onShowPopup:s,enabled:y},t[7]=b,t[8]=E,t[9]=y,t[10]=s,t[11]=x.isVSCode,t[12]=ne):ne=t[12],sr(ne);let A=!a,re;t[13]!==b||t[14]!==E||t[15]!==y||t[16]!==s||t[17]!==x.isVSCode?(re=y?{effectiveDirectory:E,editor:b,preferRuntimeEditor:x.isVSCode,onShowPopup:s}:void 0,t[13]=b,t[14]=E,t[15]=y,t[16]=s,t[17]=x.isVSCode,t[18]=re):re=t[18];let j;t[19]!==E||t[20]!==te||t[21]!==re||t[22]!==A?(j={containerRef:C,enabled:A,effectiveDirectory:E,openInAppBrowser:te,fileReference:re},t[19]=E,t[20]=te,t[21]=re,t[22]=A,t[23]=j):j=t[23],er(j);let ae;t[24]!==E||t[25]!==s?(ae={containerRef:C,effectiveDirectory:E,onShowPopup:s},t[24]=E,t[25]=s,t[26]=ae):ae=t[26];let{reconcileMarkdownImageResources:M,transportIdentity:N}=nr(ae),P;t[27]===S?P=t[28]:(P=oe(S),t[27]=S,t[28]=P);let F=P,se=_r(u??S,!1,void 0,_,N,E,!!s),I=`simple:${m}`,L;t[29]!==se||t[30]!==M||t[31]!==O||t[32]!==T||t[33]!==F||t[34]!==I?(L={containerRef:C,text:O,streaming:!1,cacheKey:I,syntaxVars:F,ctx:se,reconcileMarkdownImageResources:M,onRichContentReady:T},t[29]=se,t[30]=M,t[31]=O,t[32]=T,t[33]=F,t[34]=I,t[35]=L):L=t[35],vr(L);let R=!w||void 0,z;t[36]===r?z=t[37]:(z=g(`relative break-words w-full min-w-0`,r),t[36]=r,t[37]=z);let B=w?`true`:`false`,ce=w?`ready`:`pending`,V;t[38]!==O||t[39]!==w||t[40]!==m?(V=!w&&(0,Q.jsx)(`div`,{className:g(yr(m),`pointer-events-none absolute inset-0 overflow-clip`),children:(0,Q.jsx)(ie,{content:O})}),t[38]=O,t[39]=w,t[40]=m,t[41]=V):V=t[41];let le=!w||void 0,H;t[42]!==w||t[43]!==m?(H=g(yr(m),!w&&`invisible`),t[42]=w,t[43]=m,t[44]=H):H=t[44];let U;t[45]!==le||t[46]!==H?(U=(0,Q.jsx)(`div`,{"aria-hidden":le,className:H,"data-markdown-content":!0}),t[45]=le,t[46]=H,t[47]=U):U=t[47];let W;return t[48]!==R||t[49]!==z||t[50]!==B||t[51]!==ce||t[52]!==V||t[53]!==U?(W=(0,Q.jsxs)(`div`,{"aria-busy":R,className:z,"data-markdown-ready":B,"data-markdown-hydration":ce,ref:C,children:[V,U]}),t[48]=R,t[49]=z,t[50]=B,t[51]=ce,t[52]=V,t[53]=U,t[54]=W):W=t[54],W},(e,t)=>{let n=e.mermaidControls??rr,r=t.mermaidControls??rr;return e.content===t.content&&e.variant===t.variant&&e.className===t.className&&e.disableLinkSafety===t.disableLinkSafety&&e.stripFrontmatter===t.stripFrontmatter&&e.onShowPopup===t.onShowPopup&&n.download===r.download&&n.copy===r.copy&&n.showPanZoomControls===r.showPanZoomControls&&e.mermaidTheme===t.mermaidTheme&&e.allowMermaidWheelEvents===t.allowMermaidWheelEvents&&e.enableFileReferences===t.enableFileReferences});function wr(e){e.removeAttribute(`data-yuri-file-link`),e.removeAttribute(`data-yuri-file-ref`),e.removeAttribute(`data-yuri-file-path`),e.removeAttribute(`data-yuri-file-binary`),e.getAttribute(`title`)===`Open file`&&e.removeAttribute(`title`),e.tagName.toLowerCase()!==`a`&&(e.removeAttribute(`role`),e.removeAttribute(`tabindex`))}function Tr(){}function Er(e,t){o.getState().openContextBrowser(e,t)}function Dr(e,t){o.getState().openContextBrowser(e,t)}export{Qn as n,Be as r,Sr as t};
@@ -0,0 +1,3 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{ot as t,st as n}from"./vendor-base-ui-CzHs0bHY.js";import{r}from"./useUIStore-BDZCXouA.js";import{n as i}from"./vendor-react-DlzBev0S.js";import{u as a}from"./fileQueries-DWj9yB2g.js";import{a as o,i as s,n as c,o as l,r as u,t as d}from"./vendor-markstream-react-DfLaSG3W.js";import{a as f,i as p,m}from"./vendor-reactuses-core-DWo5Wn6R.js";import{r as h}from"./button-BF2cNEuq.js";import{Rn as g}from"./useMobileNavigationStore-9lAGHZos.js";import{t as _}from"./useThemeSystem-CNzUUkFn.js";import{i as v,n as y,t as b}from"./tooltip-BoAbDVNP.js";import{a as x,r as S}from"./url-MRa-FtQa.js";import{n as C}from"./useEffectiveDirectory-esZ8PL08.js";import{o as w}from"./image-loading-BUouaouB.js";import{t as T}from"./LoadingImage-B89ghYMH.js";import{r as ee,t as E}from"./markdownHeightCache-D02GlOiy.js";import{r as D,t as O}from"./MarkdownRendererImpl-BLzRLmeZ.js";import{n as k}from"./fileReferenceParser-1HHDBUum.js";import{a as A,c as j,f as M,h as N,i as P,l as F,m as I,o as L,s as te,t as ne}from"./fileReferenceActions-BBLYnGEx.js";var R=e(n(),1),z=`img:not([data-md-link-favicon="true"])`,B=e=>e.getAttribute(`data-md-image-source`)??e.getAttribute(`src`)??``,V=(e,t)=>{if(e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;let n=e.target;if(!(n instanceof Element))return;let r=n.closest(z);if(r instanceof HTMLImageElement&&t.onShowPopup){let n=e.currentTarget;if(!(n instanceof HTMLElement))return;let i=Array.from(n.querySelectorAll(z)).map(e=>({url:B(e),filename:e.alt||B(e)||void 0})).filter(e=>e.url),a=B(r),o=i.findIndex(e=>e.url===a);if(!a)return;e.preventDefault(),e.stopPropagation(),t.onShowPopup({open:!0,title:r.alt||a,content:``,previewSource:r,image:{url:a,...t.effectiveDirectory?{directory:t.effectiveDirectory}:{},filename:r.alt||a,gallery:i,index:o>=0?o:0}});return}if(t.fileReference){let r=n.closest(M);if(r instanceof HTMLElement){e.preventDefault(),e.stopPropagation(),L(r,t.fileReference);return}}let i=n.closest(`a[href]`);if(!(i instanceof HTMLAnchorElement))return;let a=i.getAttribute(`href`)??``;if(N(a)){e.preventDefault(),e.stopPropagation(),t.fileReference&&I(a)&&L(i,t.fileReference);return}if(!S(a))return;e.preventDefault(),e.stopPropagation();let o=(t.effectiveDirectory||``).trim();if(!g()&&o&&t.openInAppBrowser){t.openInAppBrowser(o,a);return}x(a)},re=(e,t)=>{if(e.key!==`Enter`&&e.key!==` `||!t.fileReference)return;let n=e.target;if(!(n instanceof Element))return;let r=n.closest(M);!(r instanceof HTMLElement)||r.getAttribute(`data-yuri-file-link`)!==`true`||(e.preventDefault(),e.stopPropagation(),L(r,t.fileReference))},H=i(),ie=(e,t)=>{let n=t>=2?e.slice(t-2,t):``;return(t>=1?e.charAt(t-1):``)===`:`||n===`:/`},ae=e=>{if(!e.includes(`/`)||!e.includes(`.`))return[{kind:`text`,value:e}];k.lastIndex=0;let t=[],n=0,r=k.exec(e);for(;r;){let i=r[0];if(!i||ie(e,r.index)||!I(i)){r=k.exec(e);continue}r.index>n&&t.push({kind:`text`,value:e.slice(n,r.index)}),t.push({kind:`path`,value:i}),n=r.index+i.length,r=k.exec(e)}return n===0?[{kind:`text`,value:e}]:(n<e.length&&t.push({kind:`text`,value:e.slice(n)}),t)},U=t(),W=R.createContext({enabled:!1,insideLink:!1,isMobileSurface:!1,effectiveDirectory:``,preferRuntimeEditor:!1,slots:{used:0,limit:0}}),G=e=>{let t=(0,H.c)(11),{enabled:n,effectiveDirectory:r,editor:i,preferRuntimeEditor:a,onShowPopup:o,content:s,children:c}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=g(),t[0]=l):l=t[0];let u;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(u={used:0,limit:P()},t[1]=u):u=t[1];let d;t[2]!==i||t[3]!==r||t[4]!==n||t[5]!==o||t[6]!==a?(d={enabled:n,insideLink:!1,isMobileSurface:l,effectiveDirectory:r,editor:i,preferRuntimeEditor:a,onShowPopup:o,slots:u},t[2]=i,t[3]=r,t[4]=n,t[5]=o,t[6]=a,t[7]=d):d=t[7];let f=d,p;return t[8]!==c||t[9]!==f?(p=(0,U.jsx)(W.Provider,{value:f,children:c}),t[8]=c,t[9]=f,t[10]=p):p=t[10],p},K=({raw:e,referenceKind:t,children:n})=>{let r=R.useContext(W),i=A(e,r.effectiveDirectory,t),a=R.useRef(!1);r.enabled&&i&&!a.current&&r.slots.used<r.slots.limit&&(r.slots.used+=1,a.current=!0);let[o,s]=R.useState(i?te(i.resolvedPath,r.effectiveDirectory)??null:null),c=i?.resolvedPath;if(R.useEffect(()=>{if(!r.enabled||!c||!a.current)return;let e=!1;return j(c,r.effectiveDirectory).then(t=>{e||s(t)}).catch(()=>{}),()=>{e=!0}},[r.enabled,r.effectiveDirectory,c]),!i)return n??e;let l=!!(a.current&&o&&F(i.resolvedPath,o,r.isMobileSurface));return(0,U.jsx)(`span`,{"data-yuri-block-path-token":`true`,...l?{"data-yuri-file-link":`true`,"data-yuri-file-ref":e,"data-yuri-file-path":i.resolvedPath,"data-yuri-file-binary":String(o?.isBinary===!0),title:ne,...n?{}:{role:`button`,tabIndex:0}}:{},children:n??e})};function q(e){let t=(0,H.c)(12),n=R.useContext(W),r=e.node.content??``;if(!n.enabled||n.insideLink){let n;return t[0]===e?n=t[1]:(n=(0,U.jsx)(u,{...e}),t[0]=e,t[1]=n),n}let i,a;if(t[2]!==r||t[3]!==e){a=Symbol.for(`react.early_return_sentinel`);bb0:{let n=ae(r);if(n.length===1&&n[0]?.kind!==`path`){let n;t[6]===e?n=t[7]:(n=(0,U.jsx)(u,{...e}),t[6]=e,t[7]=n),a=n;break bb0}let o;t[8]===e?o=t[9]:(o=(t,n)=>t.kind===`path`?(0,U.jsx)(K,{raw:t.value},`path-${n}-${t.value}`):(0,U.jsx)(u,{...e,node:{...e.node,content:t.value}},`text-${n}`),t[8]=e,t[9]=o),i=n.map(o)}t[2]=r,t[3]=e,t[4]=i,t[5]=a}else i=t[4],a=t[5];if(a!==Symbol.for(`react.early_return_sentinel`))return a;let o;return t[10]===i?o=t[11]:(o=(0,U.jsx)(U.Fragment,{children:i}),t[10]=i,t[11]=o),o}function oe(e){let t=(0,H.c)(7),n=R.useContext(W),r=e.node.code??``;if(!n.enabled||!I(r)){let n;return t[0]===e?n=t[1]:(n=(0,U.jsx)(s,{...e}),t[0]=e,t[1]=n),n}let i;t[2]===r?i=t[3]:(i=(0,U.jsx)(K,{raw:r}),t[2]=r,t[3]=i);let a;return t[4]!==e||t[5]!==i?(a=(0,U.jsx)(s,{...e,children:i}),t[4]=e,t[5]=i,t[6]=a):a=t[6],a}function se(e){let t=(0,H.c)(20),n=R.useContext(W),r=e.node.href??``,i;t[0]!==n.enabled||t[1]!==r?(i=n.enabled&&I(r),t[0]=n.enabled,t[1]=r,t[2]=i):i=t[2];let a=i,o;t[3]===e?o=t[4]:(o=(0,U.jsx)(c,{...e,showTooltip:!1}),t[3]=e,t[4]=o);let s=o,l;t[5]!==n.isMobileSurface||t[6]!==r||t[7]!==s||t[8]!==e.node.title||t[9]!==e.showTooltip?(l=n.isMobileSurface||e.showTooltip===!1?s:(0,U.jsxs)(b,{children:[(0,U.jsx)(v,{asChild:!0,children:(0,U.jsx)(`span`,{children:s})}),(0,U.jsx)(y,{children:e.node.title||r})]}),t[5]=n.isMobileSurface,t[6]=r,t[7]=s,t[8]=e.node.title,t[9]=e.showTooltip,t[10]=l):l=t[10];let u=l,d;t[11]===n?d=t[12]:(d={...n,insideLink:!0},t[11]=n,t[12]=d);let f;t[13]!==u||t[14]!==a||t[15]!==r?(f=a?(0,U.jsx)(K,{raw:r,referenceKind:`href`,children:u}):u,t[13]=u,t[14]=a,t[15]=r,t[16]=f):f=t[16];let p;return t[17]!==d||t[18]!==f?(p=(0,U.jsx)(W.Provider,{value:d,children:f}),t[17]=d,t[18]=f,t[19]=p):p=t[19],p}var J=/^[ \t]{0,3}(`{3,}|~{3,})/,ce=e=>{if(typeof e!=`string`||e.length===0)return!1;let t=e.split(/\r?\n/,1)[0]??``;return J.test(t)},le=e=>{let t=0,n=0,r=e.match(/[`~]+/g)??[];for(let e of r)e[0]==="`"?t=Math.max(t,e.length):n=Math.max(n,e.length);return t>=3?"`".repeat(Math.max(3,t+1)):n>=3&&t===0?"```":n>=3?`~`.repeat(Math.max(3,n+1)):"```"},ue=e=>{let t=typeof e.raw==`string`?e.raw:``;if(ce(t))return t.endsWith(`
2
+ `)?t:`${t}\n`;let n=(e.language??``).trim(),r=e.code??``,i=le(r),a=r.endsWith(`
3
+ `)?r:`${r}\n`;return e.loading?`${i}${n}\n${a}`:`${i}${n}\n${a}${i}\n`},de=e=>{let t=e.partId?`part-${e.partId}`:`body`,n=e.indexKey!==void 0&&e.indexKey!==null&&String(e.indexKey).length>0?String(e.indexKey):e.language&&e.language.length>0?e.language:`code`;return`${e.messageId}:${t}:code:${n}`},Y=R.createContext({messageId:`markstream`,isStreaming:!1,disableStreamAnimation:!1,variant:`assistant`,enableFileReferences:!0}),X=()=>R.useContext(Y);function fe(e,t){let n=5381;for(let e=0;e<t.length;e+=1)n=Math.imul(n,33)^t.charCodeAt(e);return`${e}:${(n>>>0).toString(36)}:${t.length}`}function Z(e){let t=(0,H.c)(7),n;if(t[0]!==e.indexKey||t[1]!==e.node.code||t[2]!==e.node.language){let r=(e.node.language??``).trim().toLowerCase()||`diagram`;n=e.indexKey??fe(r,e.node.code??``),t[0]=e.indexKey,t[1]=e.node.code,t[2]=e.node.language,t[3]=n}else n=t[3];let r=n,i;return t[4]!==r||t[5]!==e?(i=(0,U.jsx)(Q,{...e,indexKey:r}),t[4]=r,t[5]=e,t[6]=i):i=t[6],i}function Q(e){let t=(0,H.c)(21),n=X(),r=e.node.language??``,i=e.node.code??``,a=e.node.raw??``,o=e.node.loading===!0||e.loading===!0,s;t[0]!==i||t[1]!==r||t[2]!==o||t[3]!==a?(s=ue({type:`code_block`,language:r,code:i,raw:a,loading:o}),t[0]=i,t[1]=r,t[2]=o,t[3]=a,t[4]=s):s=t[4];let c=s,l=n.isStreaming||e.loading===!0||e.node.loading===!0,u=n.part?.id,d;t[5]!==n.messageId||t[6]!==e.indexKey||t[7]!==e.node.language||t[8]!==u?(d=de({messageId:n.messageId,partId:u,indexKey:e.indexKey,language:e.node.language}),t[5]=n.messageId,t[6]=e.indexKey,t[7]=e.node.language,t[8]=u,t[9]=d):d=t[9];let f=d,p=n.enableFileReferences&&!l,m;t[10]!==c||t[11]!==n.disableStreamAnimation||t[12]!==n.onShowPopup||t[13]!==n.variant||t[14]!==f||t[15]!==l||t[16]!==p?(m=(0,U.jsx)(O,{content:c,messageId:f,isAnimated:!1,skipFadeIn:!0,isStreaming:l,disableStreamAnimation:n.disableStreamAnimation,variant:n.variant,onShowPopup:n.onShowPopup,enableFileReferences:p}),t[10]=c,t[11]=n.disableStreamAnimation,t[12]=n.onShowPopup,t[13]=n.variant,t[14]=f,t[15]=l,t[16]=p,t[17]=m):m=t[17];let h;return t[18]!==f||t[19]!==m?(h=(0,U.jsx)(`div`,{className:`yuri-markstream-code-host min-w-0 w-full`,"data-yuri-markstream-code":`markdown-impl`,"data-yuri-markstream-code-id":f,children:m}),t[18]=f,t[19]=m,t[20]=h):h=t[20],h}function pe(e){let t=(0,H.c)(9),{node:n}=e,r=C()??``,i=w(n.src,r),{onShowPopup:a}=X(),o=p(me),s=i.source||void 0,c=n.title??void 0,l=a?`button`:void 0,u=a?0:void 0,d=a?o:void 0,f;return t[0]!==n.alt||t[1]!==n.src||t[2]!==i.error||t[3]!==s||t[4]!==c||t[5]!==l||t[6]!==u||t[7]!==d?(f=(0,U.jsx)(T,{contentFrame:!0,src:s,resourceError:i.error,"data-md-image-source":n.src,alt:n.alt,title:c,className:`rounded-lg`,role:l,tabIndex:u,onKeyDown:d}),t[0]=n.alt,t[1]=n.src,t[2]=i.error,t[3]=s,t[4]=c,t[5]=l,t[6]=u,t[7]=d,t[8]=f):f=t[8],f}function me(e){(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.currentTarget.click())}function he(e){let t=(0,H.c)(4);if(e.node.type===`code_block`){let n=e,r;return t[0]===n?r=t[1]:(r=(0,U.jsx)(Q,{...n}),t[0]=n,t[1]=r),r}let n=e,r;return t[2]===n?r=t[3]:(r=(0,U.jsx)(pe,{...n}),t[2]=n,t[3]=r),r}var $=!1;function ge(e){return e.node?.type===`code_block`?R.createElement(Q,e):R.createElement(q,e)}var _e=()=>{$||($=!0,o({text:ge,inline_code:oe,link:se,image:he,code_block:l(Q,`block`),mermaid:l(Z,`block`),d2:l(Z,`block`),d2lang:l(Z,`block`),infographic:l(Z,`block`)}))},ve={maxLiveNodes:0,liveNodeBuffer:0,batchRendering:!1,deferNodesUntilVisible:!1,viewportPriority:!1,smoothStreaming:!1,typewriter:!1,fade:!1};_e();var ye=e=>(e.inline.ruler.at(`math`,(e,t)=>{let n=e.src.slice(e.pos),r=D(n),i=n.startsWith(`\\(`)?/^\\\(([\s\S]+?)\\\)/.exec(n):null,a=r?.raw??i?.[0],o=r?.text??i?.[1];if(!a||!o)return!1;if(!t){let t=e.push(`math_inline`,`math`,0);t.content=o,t.markup=r?r.display?`$$`:`$`:`\\(\\)`}return e.pos+=a.length,!0}),e),be=e=>e===`tool`?`markdown-content markdown-tool yuri-markstream-host`:e===`reasoning`?`markdown-content markdown-reasoning yuri-markstream-host`:`markdown-content leading-relaxed yuri-markstream-host`,xe=R.memo(({content:e,part:t,messageId:n,className:i,isStreaming:o=!1,disableStreamAnimation:s=!1,variant:c=`assistant`,onShowPopup:l,enableFileReferences:u=!0})=>{let g=_()?.currentTheme.metadata.variant===`dark`,{editor:v,runtime:y}=a(),b=C()??``,x=R.useRef(null),S=t?.id?`yuri-ms-${t.id}`:`yuri-ms-${n}`,w=E(e,`markstream:${c}`),T=!o,D=u&&!o,O=D?{effectiveDirectory:b,editor:v,preferRuntimeEditor:y.isVSCode,onShowPopup:l}:void 0,k=R.useMemo(()=>({messageId:n,part:t,isStreaming:o,disableStreamAnimation:s,variant:c,onShowPopup:l,enableFileReferences:u}),[n,t,o,s,c,l,u]),A=R.useRef(T);A.current=T;let j=R.useRef(w);j.current=w;let M=p(e=>{if(!A.current)return;let t=e[0];if(!t)return;let n=t.borderBoxSize?.[0],r=n?n.blockSize:t.contentRect.height,i=n?n.inlineSize:t.contentRect.width;ee(j.current,r,i)});m(x,M);let N=p((e,t)=>{r.getState().openContextBrowser(e,t)}),P=p(e=>{V(e,{onShowPopup:l,fileReference:O,effectiveDirectory:b,openInAppBrowser:N})}),F=p(e=>{re(e,{fileReference:O})});return f(`click`,P,x),f(`keydown`,F,x),(0,U.jsx)(`div`,{ref:x,className:h(`relative break-words w-full min-w-0`,be(c),i),"data-markdown-ready":`true`,"data-markdown-hydration":`ready`,"data-yuri-markdown-engine":`markstream`,"data-yuri-markstream-virtual":`off`,children:(0,U.jsx)(Y.Provider,{value:k,children:(0,U.jsx)(G,{enabled:D,effectiveDirectory:b,editor:v,preferRuntimeEditor:y.isVSCode,onShowPopup:l,content:e,children:(0,U.jsx)(d,{content:e,customMarkdownIt:ye,customId:S,final:!o,isDark:g,codeBlockStream:o,...ve})})})})},(e,t)=>e.content===t.content&&e.isStreaming===t.isStreaming&&e.disableStreamAnimation===t.disableStreamAnimation&&e.variant===t.variant&&e.isAnimated===t.isAnimated&&e.skipFadeIn===t.skipFadeIn&&e.className===t.className&&e.messageId===t.messageId&&e.onShowPopup===t.onShowPopup&&e.enableFileReferences===t.enableFileReferences&&e.part?.id===t.part?.id);export{xe as MarkstreamRenderer};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,n}from"./runtime-switch-DEZ1K7qW.js";import{n as r}from"./runtime-fetch-D0YWp3FJ.js";import{at as i,it as a}from"./vendor-base-ui-BQjbsJ43.js";import{n as o}from"./vendor-react-D5d-V1vN.js";import{s}from"./vendor-tanstack-react-query-C4SG3JZB.js";import{a as c}from"./queryRuntime-CTcigFdj.js";import{r as l,t as u}from"./button-Bjh2BSXh.js";import{i as d}from"./store-DVfZQktm.js";import{Ea as f,wa as p}from"./useMobileNavigationStore-DlvrZQ49.js";import{n as m}from"./Icon-CeRMtJa8.js";var h=e(i(),1),g=o(),_=class extends Error{code;status;resource;constructor(e,t,n,r){super(typeof r==`string`&&r.trim()?r.trim():e),this.code=e,this.status=t,this.resource=n}},v=e=>{if(!e||typeof e!=`object`)return!1;let t=`name`in e?String(e.name):``;return t===`AbortError`||t===`TimeoutError`},y=class extends _{operation;constructor(e,t,n){super(e,t,`share_operation`),this.operation=n}},b=(e,t=200)=>{throw new _(`invalid_${e}_response`,t,e)},x=(e,t)=>e&&typeof e==`object`&&!Array.isArray(e)?e:b(t),S=(e,t)=>typeof e==`string`?e:b(t),C=(e,t)=>e===null||typeof e==`string`?e:b(t),w=(e,t)=>typeof e==`number`&&Number.isFinite(e)?e:b(t),T=(e,t)=>e===null?null:w(e,t),E=(e,t)=>typeof e==`boolean`?e:b(t),D=(e,t,n)=>t.includes(e)?e:b(n),O=e=>{let t=x(e,`capability`);return{supported:E(t.supported,`capability`),enabled:E(t.enabled,`capability`),revision:w(t.revision,`capability`),serverInstanceID:C(t.serverInstanceID,`capability`),sharingAvailable:t.sharingAvailable!==void 0&&E(t.sharingAvailable,`capability`)}},k=e=>{if(e==null)return null;let t=x(e,`assistant`);return{turnID:S(t.turnID,`assistant`),messageID:S(t.messageID,`assistant`),status:D(t.status,[`queued`,`running`],`assistant`),admittedAt:w(t.admittedAt,`assistant`)}},A=e=>{if(e==null)return null;let t=x(e,`assistant_preview`),n=w(t.ordinal,`assistant_preview`);return!Number.isSafeInteger(n)||n<0?b(`assistant_preview`):{...t.createdAt===void 0?{}:{createdAt:w(t.createdAt,`assistant_preview`)},messageID:S(t.messageID,`assistant_preview`),ordinal:n,role:D(t.role,[`user`,`assistant`],`assistant_preview`),text:S(t.text,`assistant_preview`),fallbackKind:t.fallbackKind===null?null:D(t.fallbackKind,[`image`,`file`,`session`,`assistant`,`schedule`],`assistant_preview`)}},j=e=>{let t=w(e,`assistant_read`);return Number.isSafeInteger(t)&&t>=0?t:b(`assistant_read`)},M=e=>{let t=x(e,`assistant_read`);return{generation:j(t.generation),ordinal:j(t.ordinal),messageID:S(t.messageID,`assistant_read`)}},N=e=>({unreadCount:e.unreadCount===void 0?0:j(e.unreadCount),readWatermark:e.readWatermark==null?null:M(e.readWatermark),readTip:e.readTip==null?null:M(e.readTip)}),P=e=>{let t=x(e,`assistant_read`);return{assistantID:S(t.assistantID,`assistant_read`),changed:E(t.changed,`assistant_read`),unreadCount:j(t.unreadCount),readWatermark:M(t.readWatermark),readTip:M(t.readTip),revision:j(t.revision)}},F=e=>{let t=x(e,`assistant`),n=Array.isArray(t.historySessionIDs)?t.historySessionIDs.map(e=>S(e,`assistant`)):[],r=t.historySessionCount===void 0?n.length:w(t.historySessionCount,`assistant`);if(!Number.isSafeInteger(r)||r<n.length)return b(`assistant`);let i=Array.isArray(t.assignedSessionIDs)?t.assignedSessionIDs.map(e=>S(e,`assistant`)):[],a=t.activeContactTurn===void 0?null:k(t.activeContactTurn),o=t.working===void 0?a!=null:E(t.working,`assistant`);return{...N(t),pinnedAt:t.pinnedAt===void 0?void 0:T(t.pinnedAt,`assistant`),latestMessagePreview:A(t.latestMessagePreview),id:S(t.id,`assistant`),avatarSeed:S(t.avatarSeed??t.id,`assistant`),revision:w(t.revision,`assistant`),enabled:E(t.enabled,`assistant`),name:S(t.name,`assistant`),defaultPrompt:S(t.defaultPrompt,`assistant`),workspacePath:C(t.workspacePath,`assistant`),effectiveWorkspacePath:S(t.effectiveWorkspacePath,`assistant`),managedWorkspacePath:C(t.managedWorkspacePath??null,`assistant`),providerID:S(t.providerID,`assistant`),modelID:S(t.modelID,`assistant`),agent:C(t.agent,`assistant`),variant:C(t.variant??null,`assistant`),mode:D(t.mode,[`continuous`,`stateless`],`assistant`),sessionID:C(t.sessionID,`assistant`),sessionGeneration:w(t.sessionGeneration,`assistant`),historySessionIDs:n,historySessionCount:r,assignedSessionIDs:i,working:o,activeContactTurn:a,createdAt:T(t.createdAt,`assistant`),updatedAt:w(t.updatedAt,`assistant`),tombstoneAt:T(t.tombstoneAt,`assistant`)}},I=e=>{let t=x(e,`snapshot`);return{revision:w(t.revision,`snapshot`),enabled:E(t.enabled,`snapshot`),assistants:Array.isArray(t.assistants)?t.assistants.map(F):b(`snapshot`)}},L=e=>{let t=x(e,`binding`);return{sessionID:C(t.sessionID,`binding`),directory:S(t.directory,`binding`),sessionGeneration:w(t.sessionGeneration,`binding`)}},R=e=>{let t=x(e,`message_admission`);if(t.admitted!==!0)return b(`message_admission`);let n=t.revision===void 0||t.revision===null?null:w(t.revision,`message_admission`);return{binding:L(t.binding),messageID:S(t.messageID,`message_admission`),admitted:!0,revision:n,...t.replayed===!0?{replayed:!0}:{}}},z=e=>{let t=x(e,`share_operation`);return{operationID:S(t.operationID,`share_operation`),assistantID:S(t.assistantID,`share_operation`),sessionID:C(t.sessionID,`share_operation`),messageID:C(t.messageID,`share_operation`),state:D(t.state,[`submitting`,`running`,`completed`,`failed`,`unresolved`],`share_operation`),phase:S(t.phase,`share_operation`),attempt:w(t.attempt,`share_operation`),leaseExpiresAt:T(t.leaseExpiresAt,`share_operation`),errorCode:C(t.errorCode,`share_operation`)}},B=e=>{let t=x(e,`assistant_contact_part`);if(t.type===`text`)return{type:`text`,text:S(t.text,`assistant_contact_part`)};if(t.type===`file`){let e=t.filename===void 0||t.filename===null?void 0:S(t.filename,`assistant_contact_part`),n=S(t.mime,`assistant_contact_part`),r=t.url!==void 0&&t.url!==null,i=t.attachmentID!==void 0&&t.attachmentID!==null;if(r&&i)return b(`assistant_contact_part`);if(i){let r=w(t.size,`assistant_contact_part`);return!Number.isSafeInteger(r)||r<0?b(`assistant_contact_part`):{type:`file`,mime:n,attachmentID:S(t.attachmentID,`assistant_contact_part`),sha256:S(t.sha256,`assistant_contact_part`),size:r,...e?{filename:e}:{}}}return r?{type:`file`,mime:n,url:S(t.url,`assistant_contact_part`),...e?{filename:e}:{}}:b(`assistant_contact_part`)}if(t.type===`card`){let e=D(t.cardType,[`session`,`assistant`,`schedule`],`assistant_contact_part`);return e===`session`?{type:`card`,cardType:`session`,sessionID:S(t.sessionID,`assistant_contact_part`),directory:S(t.directory,`assistant_contact_part`),title:C(t.title??null,`assistant_contact_part`),status:C(t.status??null,`assistant_contact_part`),branch:C(t.branch??null,`assistant_contact_part`)}:e===`assistant`?{type:`card`,cardType:`assistant`,assistantID:S(t.assistantID,`assistant_contact_part`),name:S(t.name,`assistant_contact_part`),providerID:S(t.providerID,`assistant_contact_part`),modelID:S(t.modelID,`assistant_contact_part`),mode:D(t.mode??`continuous`,[`continuous`,`stateless`],`assistant_contact_part`)}:{type:`card`,cardType:`schedule`,taskID:S(t.taskID,`assistant_contact_part`),projectID:S(t.projectID,`assistant_contact_part`),name:S(t.name,`assistant_contact_part`),kind:C(t.kind??null,`assistant_contact_part`),time:C(t.time??null,`assistant_contact_part`),timezone:C(t.timezone??null,`assistant_contact_part`),prompt:C(t.prompt??null,`assistant_contact_part`),...t.cron===void 0?{}:{cron:C(t.cron,`assistant_contact_part`)},...t.date===void 0?{}:{date:C(t.date,`assistant_contact_part`)},...t.times===void 0?{}:{times:t.times===null?null:Array.isArray(t.times)?t.times.map(e=>S(e,`assistant_contact_part`)):b(`assistant_contact_part`)},...t.weekdays===void 0?{}:{weekdays:t.weekdays===null?null:Array.isArray(t.weekdays)?t.weekdays.map(e=>{let t=w(e,`assistant_contact_part`);return Number.isInteger(t)&&t>=0&&t<=6?t:b(`assistant_contact_part`)}):b(`assistant_contact_part`)}}}return b(`assistant_contact_part`)},ee=e=>{let t=x(e,`assistant_contact`),n=C(t.nextCursor,`assistant_contact`),r=E(t.complete,`assistant_contact`);if(!r&&!n||r&&n||!Array.isArray(t.messages))return b(`assistant_contact`);let i=w(t.generation,`assistant_contact`),a=w(t.revision,`assistant_contact`);return!Number.isSafeInteger(i)||i<0||!Number.isSafeInteger(a)||a<0?b(`assistant_contact`):{messages:t.messages.map(e=>{let t=x(e,`assistant_contact_message`);if(!Array.isArray(t.parts))return b(`assistant_contact_message`);let n=t.parts.map(B);return{messageID:S(t.messageID,`assistant_contact_message`),assistantID:S(t.assistantID,`assistant_contact_message`),role:D(t.role,[`user`,`assistant`,`peer`],`assistant_contact_message`),turnID:S(t.turnID,`assistant_contact_message`),bubbleIndex:w(t.bubbleIndex,`assistant_contact_message`),createdAt:w(t.createdAt,`assistant_contact_message`),ordinal:w(t.ordinal,`assistant_contact_message`),status:S(t.status,`assistant_contact_message`),fromAssistantID:C(t.fromAssistantID??null,`assistant_contact_message`),fromAssistantName:C(t.fromAssistantName??null,`assistant_contact_message`),parts:n,text:typeof t.text==`string`?t.text:n.filter(e=>e.type===`text`).map(e=>e.text).join(``),cards:n.filter(e=>e.type===`card`)}}),nextCursor:n,complete:r,generation:i,revision:a}},te=e=>{let t=x(e,`assistant_scheduled_tasks`);return Array.isArray(t.tasks)?{tasks:t.tasks.map(e=>{let t=x(e,`assistant_scheduled_task`),n=t.task===null||t.task===void 0?null:x(t.task,`assistant_scheduled_task_live`);return{assistantID:S(t.assistantID,`assistant_scheduled_task`),projectID:S(t.projectID,`assistant_scheduled_task`),taskID:S(t.taskID,`assistant_scheduled_task`),createdAt:w(t.createdAt,`assistant_scheduled_task`),projectPath:C(t.projectPath??null,`assistant_scheduled_task`),projectLabel:C(t.projectLabel??null,`assistant_scheduled_task`),task:n}})}:b(`assistant_scheduled_tasks`)},V=async(e,t)=>{try{let t=await e.json();if(t&&typeof t.error==`string`&&t.error.trim().length>0)return t.error}catch{return t}return t},H=e=>{let t=typeof e==`string`?e.trim():``;if(!t)throw Error(`projectId is required`);return t},U=e=>e===null||typeof e==`string`,ne=e=>e===null||typeof e==`number`&&Number.isFinite(e),re=e=>typeof e==`number`&&Number.isFinite(e)&&e>=0&&e<=864e13,ie=e=>e===null||re(e),ae=e=>{if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return typeof t.id==`string`&&t.id.length>0&&typeof t.projectId==`string`&&t.projectId.length>0&&typeof t.taskId==`string`&&t.taskId.length>0&&typeof t.taskName==`string`&&(t.trigger===`scheduled`||t.trigger===`manual`)&&(t.status===`running`||t.status===`success`||t.status===`error`)&&U(t.sessionId)&&U(t.directory)&&U(t.error)&&re(t.startedAt)&&ie(t.finishedAt)&&ne(t.durationMs)&&(t.durationMs===null||t.durationMs>=0)},oe=e=>{if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`Malformed scheduled task runs response`);let t=e;if(!Array.isArray(t.runs)||!t.runs.every(ae)||!U(t.nextCursor)||typeof t.complete!=`boolean`||t.complete!==(t.nextCursor===null)||t.nextCursor!==null&&t.nextCursor.length===0)throw Error(`Malformed scheduled task runs response`);return{runs:t.runs,nextCursor:t.nextCursor,complete:t.complete}},se=async(e,t)=>{let n=new URLSearchParams;e.before&&n.set(`before`,e.before);let i=e.limit??20;if(!Number.isInteger(i)||i<1)throw Error(`limit must be a positive integer`);n.set(`limit`,String(i)),e.projectId&&n.set(`projectId`,e.projectId),e.taskId&&n.set(`taskId`,e.taskId);let a=await r(`/api/yuri/scheduled-task-runs?${n.toString()}`,{signal:t});if(!a.ok)throw Error(await V(a,`Failed to load scheduled task history`));return oe(await a.json().catch(()=>null))},ce=async({signal:e}={})=>{let t=await r(`/api/yuri/scheduled-tasks`,{signal:e});if(!t.ok)throw Error(await V(t,`Failed to load schedules`));let n=await t.json().catch(()=>null);if(!n||!Array.isArray(n.tasks))throw Error(`Malformed schedules response`);return{tasks:Array.isArray(n?.tasks)?n.tasks:[],failedProjectIds:Array.isArray(n?.failedProjectIds)?n.failedProjectIds.filter(e=>typeof e==`string`):[]}},le=async(e,t)=>{let n=H(e),i=await r(`/api/projects/${encodeURIComponent(n)}/scheduled-tasks`,{method:`PUT`,headers:{"content-type":`application/json`,accept:`application/json`},body:JSON.stringify({task:t})});if(!i.ok)throw Error(await V(i,`Failed to save schedule`));let a=await i.json().catch(()=>null);return!a||!Array.isArray(a.tasks)?[]:a.tasks},ue=async(e,t)=>{let n=H(e),i=H(t),a=await r(`/api/projects/${encodeURIComponent(n)}/scheduled-tasks/${encodeURIComponent(i)}`,{method:`DELETE`,headers:{accept:`application/json`}});if(!a.ok)throw Error(await V(a,`Failed to delete schedule`));let o=await a.json().catch(()=>null);return!o||!Array.isArray(o.tasks)?[]:o.tasks},de=async(e,t)=>{let n=H(e),i=H(t),a=await r(`/api/projects/${encodeURIComponent(n)}/scheduled-tasks/${encodeURIComponent(i)}/run`,{method:`POST`,headers:{accept:`application/json`}});if(!a.ok)throw Error(await V(a,`Failed to run schedule`));let o=await a.json().catch(()=>null);return{sessionId:typeof o?.sessionId==`string`&&o.sessionId.length>0?o.sessionId:void 0}},fe=(e,t)=>e.ordinal===t.ordinal?e.messageID<t.messageID?-1:+(e.messageID>t.messageID):e.ordinal-t.ordinal,pe=e=>{if(e.type===`file`||e.type===`card`)return!0;if(e.type!==`text`)return!1;let t=typeof e.text==`string`?e.text.trim():``;return!!t&&!t.startsWith(`yuri.settle.`)&&!t.startsWith(`oc.settle.`)},me=(e,t)=>{if(!t||!e.readTip||!((e.unreadCount??0)>0))return null;let n=e.readTip;if(t.generation!==n.generation)return null;let r;for(let n=t.messages.length-1;n>=0;--n){let i=t.messages[n];if(i.assistantID===e.id&&(i.status===`complete`||i.status===`error`)&&i.parts.some(pe)){r=i;break}}if(!r)return null;let i=e.readWatermark;return i&&(i.generation>t.generation||i.generation===t.generation&&fe({ordinal:i.ordinal,messageID:i.messageID},{ordinal:r.ordinal,messageID:r.messageID})>=0)?null:{generation:t.generation,ordinal:r.ordinal,messageID:r.messageID}},he=()=>({messages:[],generation:-1,revision:0,olderCursor:null,olderComplete:!0,hasMessageGap:!1,gapCursor:null,gapRequestIDs:null,gapTargetIDs:null,liveWindowIDs:[]}),ge=e=>!!(e&&e.generation>=0),_e=(e,t)=>fe({ordinal:e.ordinal,messageID:e.messageID},{ordinal:t.ordinal,messageID:t.messageID}),W=(e,t,n=`incoming`)=>{let r=new Map;for(let t of e)r.set(t.messageID,t);for(let e of t)(n===`incoming`||!r.has(e.messageID))&&r.set(e.messageID,e);return[...r.values()].sort(_e)},ve=e=>{let t=1/0;for(let n of e)n.ordinal<t&&(t=n.ordinal);return Number.isFinite(t)?t:null},ye=e=>e.map(e=>e.messageID),be=(e,t)=>{for(let n of e)if(t.has(n))return!0;return!1},xe=e=>new Set(e),Se=(e,t)=>!e||!t||e.length!==t.length?!1:e.every((e,n)=>e===t[n]),Ce=e=>({...e,hasMessageGap:!1,gapCursor:null,gapRequestIDs:null,gapTargetIDs:null}),we=e=>({ordinal:e.ordinal,messageID:e.messageID}),Te=(e,t,n)=>{if(n)return[...t];if(t.length===0)return[...e];let r=t[0];return[...e.filter(e=>fe(we(e),we(r))<0),...t]},Ee=(e,t)=>{let n=e??he(),r=ge(n),i=[...t.messages].sort(_e),a=ye(i);if(r&&t.generation<n.generation)return n;if(r&&t.generation>n.generation)return{messages:i,generation:t.generation,revision:t.revision,olderCursor:t.nextCursor,olderComplete:t.complete,hasMessageGap:!1,gapCursor:null,gapRequestIDs:null,gapTargetIDs:null,liveWindowIDs:a};if(!r)return{messages:i,generation:t.generation,revision:t.revision,olderCursor:t.complete?null:t.nextCursor,olderComplete:t.complete,hasMessageGap:!1,gapCursor:null,gapRequestIDs:null,gapTargetIDs:null,liveWindowIDs:a};let o=Math.max(n.revision,t.revision),s=t.revision>=n.revision;if(i.length===0)return s&&t.complete?{messages:[],generation:t.generation,revision:o,olderCursor:null,olderComplete:!0,hasMessageGap:!1,gapCursor:null,gapRequestIDs:null,gapTargetIDs:null,liveWindowIDs:[]}:{...n,generation:t.generation,revision:o,olderCursor:n.olderCursor??t.nextCursor,olderComplete:n.olderComplete&&t.complete,liveWindowIDs:[],hasMessageGap:n.hasMessageGap,gapCursor:n.hasMessageGap?t.nextCursor??n.gapCursor:null,gapRequestIDs:n.hasMessageGap?n.gapRequestIDs:null,gapTargetIDs:n.hasMessageGap?n.gapTargetIDs:null};let c;if(s)c=Te(n.messages,i,t.complete);else{let e=ve(i);c=W(n.messages.filter(t=>t.ordinal<e),W(n.messages.filter(t=>t.ordinal>=e),i,`existing`),`incoming`)}let l=n.liveWindowIDs,u=xe(a),d=l.length>0&&be(l,u),f=n.hasMessageGap,p=n.gapCursor,m=n.gapRequestIDs,h=n.gapTargetIDs;if(!d&&l.length>0&&t.nextCursor){f=!0,p=t.nextCursor;let e=l.filter(e=>!u.has(e));m=e.length>0?e:[...l],h=n.hasMessageGap&&n.gapTargetIDs&&n.gapTargetIDs.length>0?n.gapTargetIDs:m}else n.hasMessageGap?(f=!0,p=n.gapCursor,m=n.gapRequestIDs,h=n.gapTargetIDs):(f=!1,p=null,m=null,h=null);return{messages:c,generation:t.generation,revision:o,olderCursor:n.liveWindowIDs.length===0&&n.messages.length===0?t.complete?null:t.nextCursor:n.olderCursor,olderComplete:!r||n.liveWindowIDs.length===0&&n.messages.length===0?t.complete:n.olderComplete,hasMessageGap:f,gapCursor:f?p:null,gapRequestIDs:f?m:null,gapTargetIDs:f?h:null,liveWindowIDs:a}},De=(e,t)=>{if(!ge(e)||t.generation!==e.generation)return e;let n=t.revision>=e.revision?`incoming`:`existing`,r=W(e.messages,t.messages,n);return{...e,messages:r,revision:Math.max(e.revision,t.revision),olderCursor:t.complete?null:t.nextCursor,olderComplete:t.complete}},Oe=(e,t,n)=>{if(!ge(e)||t.generation!==e.generation)return e;let r=t.revision>=e.revision?`incoming`:`existing`,i=W(e.messages,t.messages,r),a=Math.max(e.revision,t.revision),o=n?.requestIDs??e.gapRequestIDs;if(!(e.hasMessageGap&&o&&e.gapRequestIDs&&Se(o,e.gapRequestIDs)))return{...e,messages:i,revision:a};let s=ye(t.messages),c=e.gapTargetIDs??[],l=xe(c);return c.length>0&&be(s,l)||t.complete||!t.nextCursor?Ce({...e,messages:i,revision:a}):{...e,messages:i,revision:a,hasMessageGap:!0,gapCursor:t.nextCursor??e.gapCursor,gapRequestIDs:e.gapRequestIDs,gapTargetIDs:e.gapTargetIDs}},G={snapshot:(e=t())=>[e,`assistants`,`snapshot`],capability:(e=t())=>[e,`assistants`,`capability`],history:(e,r,i,a=t(),o=n())=>[a,o,`assistants`,`history`,e,r,i],contact:(e,r=t(),i=n())=>[r,i,`assistants`,`contact`,e],scheduledTasks:(e,r=t(),i=n())=>[r,i,`assistants`,`scheduled-tasks`,e],globalScheduledTasks:(e=t())=>[e,`scheduled-tasks`]},K=async(e,t={})=>{let n=await r(e,t),i=await n.json().catch(()=>null);if(!n.ok){let e=i&&typeof i==`object`&&`error`in i&&typeof i.error==`string`?i.error:`request_failed`,t=i&&typeof i==`object`&&`message`in i&&typeof i.message==`string`?i.message:void 0;throw new _(e,n.status,void 0,t)}return i},q=(e,t)=>({method:e,headers:{"Content-Type":`application/json`},body:t===void 0?void 0:JSON.stringify(t)}),J=(e,r)=>{if(t()!==e||n()!==r)throw new _(`runtime_stale`,409)},ke=(e,t,r)=>{c.setQueryData(G.snapshot(r),n=>n&&{...n,assistants:n.assistants.map(n=>n.id!==e||n.sessionGeneration>t.sessionGeneration?n:{...n,sessionID:t.sessionID,sessionGeneration:t.sessionGeneration,effectiveWorkspacePath:t.directory})}),c.invalidateQueries({queryKey:G.snapshot(r)}),c.invalidateQueries({queryKey:[r,n(),`assistants`,`history`,e]})},Ae=(e,t)=>{c.setQueryData(G.snapshot(t),t=>t&&{...t,assistants:t.assistants.some(t=>t.id===e.id)?t.assistants.map(t=>t.id===e.id?e:t):[...t.assistants,e]}),c.invalidateQueries({queryKey:G.snapshot(t)})},je=2500,Me=15e3,Ne=e=>!!e?.assistants.some(e=>e.working||e.activeContactTurn),Pe=(e,t={})=>{if(t.assistantID){let n=e?.assistants.find(e=>e.id===t.assistantID);return n?.working||n?.activeContactTurn?je:Me}return Ne(e)?je:Me},Y=(e=t())=>({queryKey:G.snapshot(e),queryFn:async({signal:e})=>I(await K(`/api/yuri/assistants/snapshot`,{signal:e})),staleTime:0,retry:2,refetchInterval:e=>Pe(e.state.data),refetchIntervalInBackground:!1,refetchOnWindowFocus:!0,refetchOnReconnect:!0}),X=new Map,Fe=e=>{let r=X.get(e);if(r)r.count+=1;else{let r=n(),i=!1,a=!1,o=!1,s=()=>!i&&t()===e&&n()===r,l=async()=>{if(o=!0,!a){a=!0;try{do o=!1,c.getQueryCache().find({queryKey:G.snapshot(e),exact:!0})?.state.fetchStatus===`fetching`&&(o=!0),await c.invalidateQueries({queryKey:G.snapshot(e),exact:!0},{cancelRefetch:!1});while(o&&s())}finally{a=!1}}},u=f(t=>{if(!s())return;let n=c.getQueryData(G.snapshot(e));(t.type===`event-stream-ready`||t.type===`contact-turn-start`||t.type===`contact-turn-end`||t.type===`assistants-changed`&&(!n||t.revision>n.revision))&&l()});X.set(e,{count:1,dispose:()=>{i=!0,u()}})}return()=>{let t=X.get(e);t&&--t.count===0&&(t.dispose(),X.delete(e))}},Ie=e=>{let n=(0,g.c)(7),r,i,a;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=t(),i=s,r=Y(a),n[0]=r,n[1]=i,n[2]=a):(r=n[0],i=n[1],a=n[2]);let o;n[3]===e?o=n[4]:(o={...r,select:e},n[3]=e,n[4]=o);let c=i(o),l,u;return n[5]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>Fe(a),u=[a],n[5]=l,n[6]=u):(l=n[5],u=n[6]),h.useEffect(l,u),c},Le=e=>e.enabled?e.assistants.reduce((e,t)=>e+(t.unreadCount??0),0):0,Re=()=>{let e=(0,g.c)(5),n,r,i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=t(),n=s,r={...Y(i),select:Le},e[0]=n,e[1]=r,e[2]=i):(n=e[0],r=e[1],i=e[2]);let a=n(r),o,c;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>Fe(i),c=[i],e[3]=o,e[4]=c):(o=e[3],c=e[4]),h.useEffect(o,c),a.data??0},ze=e=>e.enabled&&Ne(e),Be=()=>{let e=(0,g.c)(5),n,r,i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=t(),n=s,r={...Y(i),select:ze},e[0]=n,e[1]=r,e[2]=i):(n=e[0],r=e[1],i=e[2]);let a=n(r),o,c;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>Fe(i),c=[i],e[3]=o,e[4]=c):(o=e[3],c=e[4]),h.useEffect(o,c),a.data??!1},Ve=(e,t={})=>{let n=new URLSearchParams;return n.set(`limit`,String(t.limit??20)),t.before&&n.set(`before`,t.before),t.messageID&&n.set(`messageID`,t.messageID),`/api/yuri/assistants/${encodeURIComponent(e)}/contact/messages?${n}`},He=async(e,t,n)=>ee(await K(Ve(e,t),n?{signal:n}:{})),Ue=(e,t)=>e.generation===t.generation&&e.revision===t.revision&&e.olderCursor===t.olderCursor&&e.olderComplete===t.olderComplete&&e.hasMessageGap===t.hasMessageGap&&e.gapCursor===t.gapCursor&&e.messages===t.messages&&e.liveWindowIDs===t.liveWindowIDs&&e.gapRequestIDs===t.gapRequestIDs&&e.gapTargetIDs===t.gapTargetIDs,Z=new Map,We=new Map,Q=e=>e.join(``),Ge=async(e,t,n,r,i)=>{let a=Q(t),o=We.get(a);if(o)return o;let s=(async()=>{let a=c.getQueryData(t)??n,o=0,s=!1,l=!1,u=a.gapRequestIDs?[...a.gapRequestIDs]:null,d=a.gapCursor;for(;a.hasMessageGap&&a.gapCursor&&o<5&&!i?.aborted;){J(r.transport,r.runtimeGeneration),o+=1;let n=a.gapCursor;try{let o=await He(e,{limit:20,before:n},i);J(r.transport,r.runtimeGeneration);let l=c.getQueryData(t)??a;if(o.generation!==l.generation){a=l;break}let f=!u||!!(l.hasMessageGap&&l.gapRequestIDs&&l.gapRequestIDs.length===u.length&&l.gapRequestIDs.every((e,t)=>e===u[t]));if(a=Oe(l,o,u?{requestIDs:u,cursor:d}:void 0),c.setQueryData(t,a),!f)break;if(!a.hasMessageGap){s=!0;break}if(a.gapCursor&&a.gapCursor!==n)s=!0;else break}catch(e){if(i?.aborted||v(e))break;l=!0,a=c.getQueryData(t)??a;break}}return{view:c.getQueryData(t)??a,failed:l,progressed:s}})();We.set(a,s);try{return await s}finally{We.get(a)===s&&We.delete(a)}},Ke=(e,r=t(),i=n(),a={})=>({queryKey:G.contact(e,r,i),queryFn:async({signal:t})=>{J(r,i),await p(),J(r,i);let n=G.contact(e,r,i),a=c.getQueryData(n),o=await He(e,{limit:20},t);J(r,i);let s=Ee(c.getQueryData(n)??a??null,o);c.setQueryData(n,s);let l=Q(n);if(s.hasMessageGap&&s.gapCursor){Z.delete(l);let a=await Ge(e,n,s,{transport:r,runtimeGeneration:i},t);s=a.view,(a.failed||a.view.hasMessageGap&&!a.progressed)&&a.view.gapCursor&&Z.set(l,a.view.gapCursor)}else Z.delete(l);J(r,i);let u=c.getQueryData(n)??s;return a&&Ue(a,u)?a:u},retry:2,staleTime:0,refetchInterval:()=>a.reconcileInForeground?Pe(c.getQueryData(G.snapshot(r)),{assistantID:e}):!1,refetchIntervalInBackground:!1,refetchOnWindowFocus:!0,refetchOnReconnect:!0,structuralSharing:!0}),qe=(e,r=!0)=>{let i=t(),a=n(),[o,l]=h.useState(!1),[u,d]=h.useState(null),[p,m]=h.useState(!1),g=h.useRef(null),_=h.useRef(null),y=h.useRef(null),b=h.useRef(null),x=h.useRef({assistantID:e,transport:i,runtimeGeneration:a,enabled:r});x.current={assistantID:e,transport:i,runtimeGeneration:a,enabled:r};let S=s({...Ke(e,i,a,{reconcileInForeground:!0}),enabled:r&&!!e});h.useEffect(()=>{!r||!e||c.invalidateQueries({queryKey:G.snapshot(i),exact:!0},{cancelRefetch:!1})},[e,r,a,i]),h.useEffect(()=>f(n=>{t()===i&&(n.type===`assistants-changed`||n.type===`event-stream-ready`||n.type===`contact-turn-end`)&&(n.type===`contact-turn-end`&&`assistantID`in n&&n.assistantID!==e||c.invalidateQueries({queryKey:G.contact(e,i,a),exact:!0}))}),[e,a,i]),h.useEffect(()=>{let t=Q(G.contact(e,i,a));return()=>{y.current?.abort(),b.current?.abort(),y.current=null,b.current=null,g.current=null,_.current=null,Z.delete(t)}},[e,i,a,r]);let C=S.data,w=G.contact(e,i,a),T=async()=>{if(!e||!r)return;if(g.current)return g.current;let t=c.getQueryData(w)??C;if(!t||t.olderComplete||!t.olderCursor)return;d(null),l(!0);let n=new AbortController;b.current?.abort(),b.current=n;let o={transport:i,runtimeGeneration:a,assistantID:e,cursor:t.olderCursor},s=(async()=>{try{J(o.transport,o.runtimeGeneration);let e=await He(o.assistantID,{limit:20,before:o.cursor},n.signal);if(n.signal.aborted||(J(o.transport,o.runtimeGeneration),x.current.assistantID!==o.assistantID||x.current.transport!==o.transport||x.current.runtimeGeneration!==o.runtimeGeneration))return;let r=c.getQueryData(w)??t;if(e.generation!==r.generation)return;c.setQueryData(w,De(r,e))}catch(e){if(n.signal.aborted||v(e))return;let t=e instanceof Error?e:Error(String(e));throw d(t),t}finally{b.current===n&&(b.current=null),l(!1),g.current=null}})();return g.current=s,s},E=async(t=`explicit`)=>{if(!e||!r)return;if(_.current)return _.current;let n=c.getQueryData(w)??C;if(!n?.hasMessageGap||!n.gapCursor)return;let o=Q(w);if(t===`auto`&&Z.get(o)===n.gapCursor)return;t===`explicit`&&Z.delete(o),m(!0);let s=new AbortController;y.current?.abort(),y.current=s;let l={transport:i,runtimeGeneration:a,assistantID:e,cursor:n.gapCursor},u=(async()=>{try{J(l.transport,l.runtimeGeneration);let e=await Ge(l.assistantID,w,n,{transport:l.transport,runtimeGeneration:l.runtimeGeneration},s.signal);if(s.signal.aborted)return;if(J(l.transport,l.runtimeGeneration),e.failed||!e.progressed){e.view.gapCursor&&Z.set(o,e.view.gapCursor);return}e.view.hasMessageGap||Z.delete(o)}catch(e){if(s.signal.aborted||v(e))return;throw Z.set(o,l.cursor),e}finally{y.current===s&&(y.current=null),m(!1),_.current=null}})();return _.current=u,u};return h.useEffect(()=>{if(!r||!e||!C?.hasMessageGap||!C.gapCursor||S.isFetching||p)return;let t=Q(w);Z.get(t)!==C.gapCursor&&E(`auto`).catch(()=>void 0)},[r,e,C?.hasMessageGap,C?.gapCursor,S.isFetching,p,w]),{data:C?{messages:C.messages,generation:C.generation,revision:C.revision,nextCursor:C.olderCursor,complete:C.olderComplete}:void 0,status:S.status,fetchStatus:S.fetchStatus,isError:S.isError,isPending:S.isPending,isFetching:S.isFetching,isSuccess:S.isSuccess,error:S.error instanceof Error?S.error:S.error?Error(String(S.error)):null,refetch:()=>S.refetch(),fetchPreviousPage:T,hasPreviousPage:!!(C&&!C.olderComplete&&C.olderCursor),isFetchingPreviousPage:o,previousPageError:u,hasMessageGap:!!C?.hasMessageGap,isFillingMessageGap:p,retryMessageGap:()=>E(`explicit`)}},Je=async(e,r)=>{let i=t(),a=n();await p(),J(i,a);let o=await He(e,{messageID:r,limit:1});if(J(i,a),!o.messages.some(e=>e.messageID===r&&e.role===`user`))return null;c.invalidateQueries({queryKey:G.contact(e,i,a),exact:!0}),c.invalidateQueries({queryKey:G.snapshot(i),exact:!0});let s=c.getQueryData(G.snapshot(i));return{admitted:!0,messageID:r,revision:o.revision??s?.revision??null}},Ye=(e,r=t(),i=n())=>({queryKey:G.scheduledTasks(e,r,i),queryFn:async({signal:t})=>{J(r,i);let n=te(await K(`/api/yuri/assistants/${encodeURIComponent(e)}/scheduled-tasks`,{signal:t}));return J(r,i),n},refetchOnMount:`always`,retry:(e,t)=>!(t instanceof _&&t.status===404)&&e<2}),Xe=(e,r)=>{let i=(0,g.c)(6),a=r===void 0||r,o,c;if(i[0]!==e){let r=t(),a=n();c=s,o=Ye(e,r,a),i[0]=e,i[1]=o,i[2]=c}else o=i[1],c=i[2];let l=a&&!!e,u;return i[3]!==o||i[4]!==l?(u={...o,enabled:l},i[3]=o,i[4]=l,i[5]=u):u=i[5],c(u)},Ze=(e=t())=>({queryKey:G.globalScheduledTasks(e),queryFn:ce,refetchOnMount:`always`}),Qe=e=>{let t=(0,g.c)(3),n=e===void 0||e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=Ze(),t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i={...r,enabled:n},t[1]=n,t[2]=i),s(i)},$e=e=>e.tasks.some(({task:e})=>e.state.lastStatus===`running`),et=()=>{let e=(0,g.c)(5),n,r,i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=t(),n=s,r={...Ze(i),select:$e,staleTime:0,refetchInterval:yt,refetchIntervalInBackground:!1},e[0]=n,e[1]=r,e[2]=i):(n=e[0],r=e[1],i=e[2]);let a=n(r),o,l;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>f(e=>{t()===i&&(e.type===`scheduled-task-ran`||e.type===`event-stream-ready`)&&c.invalidateQueries({queryKey:Ze(i).queryKey,exact:!0})}),l=[i],e[3]=o,e[4]=l):(o=e[3],l=e[4]),h.useEffect(o,l),a.data===!0},tt=(e,r=t())=>{c.invalidateQueries({queryKey:[r,n(),`assistants`,`contact`,e]})},nt=(e=t())=>({queryKey:G.capability(e),queryFn:()=>gt(),retry:!1}),rt=()=>{let e=(0,g.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=nt(),e[0]=t):t=e[0],s(t)},it=(e=c,n=t())=>e.getQueryData(G.snapshot(n)),at=(e=c,n=t())=>e.fetchQuery(Y(n)),ot=async(e=c)=>{let r=t(),i=n();await e.invalidateQueries({queryKey:G.snapshot(r),exact:!0}),J(r,i);let a=await e.fetchQuery(Y(r));return J(r,i),a},st=15e3,ct=e=>{throw e instanceof _?e:v(e)?new _(`admission_timeout`,408):e},lt=async(e,r,i)=>{let a=t(),o=n(),s=typeof i==`string`?[{type:`text`,text:i}]:Array.isArray(i.parts)&&i.parts.length>0?i.parts:[{type:`text`,text:i.text??``}],c=AbortSignal.timeout(st);try{let t=R(await K(`/api/yuri/assistants/${encodeURIComponent(e)}/messages`,{...q(`POST`,{messageID:r,parts:s,language:d.getState().locale}),signal:c}));return J(a,o),ke(e,t.binding,a),tt(e,a),t}catch(e){return ct(e)}},ut=async(e,r,i,a,o)=>{let s=t(),c=n(),l=z(await K(`/api/yuri/assistants/${encodeURIComponent(e)}/share`,q(`POST`,{operationID:r,payload:{messageID:i,parts:a,source:o}})));return J(s,c),l},dt=async(e,r=t(),i=n())=>{J(r,i);let a=z(await K(`/api/yuri/assistants/share-operations/${encodeURIComponent(e)}`));return J(r,i),a},ft=async(e,r=t(),i=n())=>{let a=e;for(let e=0;e<60&&(a.state===`running`||a.state===`submitting`);e+=1)J(r,i),await new Promise(e=>setTimeout(e,750)),a=await dt(a.operationID,r,i);if(J(r,i),a.state===`completed`)return a;throw a.state===`failed`?new y(a.errorCode??`share_failed`,400,a):new y(`share_unresolved`,408,a)},pt=async e=>{let n=t(),r=F(await K(`/api/yuri/assistants`,q(`POST`,{...e,language:d.getState().locale})));return Ae(r,n),r},mt=async(e,r)=>{let i=t(),a=n(),o=F(await K(`/api/yuri/assistants/${encodeURIComponent(e.id)}`,q(`PATCH`,{...r,expectedRevision:e.revision})));return J(i,a),r.pinned===void 0?Ae(o,i):(await c.cancelQueries({queryKey:G.snapshot(i),exact:!0}),J(i,a),await c.fetchQuery(Y(i)),J(i,a)),o},ht=async e=>{await K(`/api/yuri/assistants/${encodeURIComponent(e.id)}`,q(`DELETE`,{expectedRevision:e.revision})),await c.invalidateQueries({queryKey:G.snapshot(t())})},gt=async()=>O(await K(`/api/yuri/assistants/capability`)),_t=async(e,r)=>{let i=t(),a=n(),o=M(r);try{let t=P(await K(`/api/yuri/assistants/${encodeURIComponent(e)}/contact/read`,{...q(`POST`,o),signal:AbortSignal.timeout(15e3)}));if(J(i,a),t.assistantID!==e)throw new _(`invalid_assistant_read_response`,200);return t}finally{t()===i&&n()===a&&c.invalidateQueries({queryKey:G.snapshot(i),exact:!0})}},vt=async e=>{let r=e.assistants.filter(e=>(e.unreadCount??0)>0&&e.readTip).map(e=>({id:e.id,position:{...e.readTip}})),i=t(),a=n(),o=[];for(let e=0;e<r.length;e+=4)o.push(...await Promise.allSettled(r.slice(e,e+4).map(async e=>(J(i,a),_t(e.id,e.position)))));return{failed:o.filter(e=>e.status===`rejected`).length}};function yt(e){return e.state.data&&$e(e.state.data)?2500:15e3}var $=a();function bt(e){let t=(0,g.c)(33),{title:n,subtitle:r,backAriaLabel:i,onBack:a,backDisabled:o,actions:s,trailing:c,sticky:d,overlay:f,elevated:p,collapsible:h}=e,_=o!==void 0&&o,v;t[0]===s?v=t[1]:(v=s===void 0?[]:s,t[0]=s,t[1]=v);let y=v,b=d!==void 0&&d,x=f!==void 0&&f,S=p!==void 0&&p,C=h!==void 0&&h,w=Array.isArray(c)?c.filter(Boolean).length:+!!c,T=S||y.some(St),E=C?`true`:void 0,D=b&&`yuri-mobile-detail-navigation-sticky`,O=x&&`absolute inset-x-0 top-0`,k=T?`z-[60]`:x?`z-30`:void 0,A;t[2]!==O||t[3]!==k||t[4]!==D?(A=l(`yuri-mobile-detail-navigation relative shrink-0 pt-[max(0.25rem,var(--yuri-safe-area-top,0px))]`,D,O,k),t[2]=O,t[3]=k,t[4]=D,t[5]=A):A=t[5];let j=y.length+w>1?`grid-cols-[2.75rem_minmax(0,1fr)_auto]`:`grid-cols-[2.75rem_minmax(0,1fr)_2.75rem]`,M;t[6]===j?M=t[7]:(M=l(`yuri-mobile-detail-navigation-content grid items-center gap-1 px-4`,j),t[6]=j,t[7]=M);let N;t[8]!==i||t[9]!==_||t[10]!==a?(N=a?(0,$.jsx)(u,{type:`button`,variant:`mobileGlass`,size:`mobileIcon`,className:`justify-self-start`,onClick:a,disabled:_,"aria-label":i,children:(0,$.jsx)(m,{name:`arrow-left-s`,className:`size-5`})}):(0,$.jsx)(`span`,{"aria-hidden":`true`}),t[8]=i,t[9]=_,t[10]=a,t[11]=N):N=t[11];let P;t[12]===n?P=t[13]:(P=(0,$.jsx)(`div`,{className:`yuri-mobile-detail-title w-full truncate typography-ui-label font-medium text-foreground`,children:n}),t[12]=n,t[13]=P);let F;t[14]===r?F=t[15]:(F=r?(0,$.jsx)(`div`,{className:`yuri-mobile-detail-subtitle w-full truncate text-muted-foreground`,"aria-live":`polite`,children:r}):null,t[14]=r,t[15]=F);let I;t[16]!==P||t[17]!==F?(I=(0,$.jsxs)(`div`,{className:`flex w-full max-w-72 min-w-0 flex-col items-center justify-center justify-self-center px-1`,children:[P,F]}),t[16]=P,t[17]=F,t[18]=I):I=t[18];let L;t[19]===y?L=t[20]:(L=y.map(xt),t[19]=y,t[20]=L);let R;t[21]!==L||t[22]!==c?(R=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-end gap-2`,children:[c,L]}),t[21]=L,t[22]=c,t[23]=R):R=t[23];let z;t[24]!==M||t[25]!==N||t[26]!==I||t[27]!==R?(z=(0,$.jsxs)(`div`,{className:M,children:[N,I,R]}),t[24]=M,t[25]=N,t[26]=I,t[27]=R,t[28]=z):z=t[28];let B;return t[29]!==A||t[30]!==z||t[31]!==E?(B=(0,$.jsx)(`header`,{"data-yuri-collapsible-header":E,className:A,children:z}),t[29]=A,t[30]=z,t[31]=E,t[32]=B):B=t[32],B}function xt(e,t){return(0,$.jsx)(u,{type:`button`,variant:`mobileGlass`,size:`mobileIcon`,className:l(e.elevated&&`relative z-[60]`),onClick:e.onClick,disabled:e.disabled,"aria-label":e.ariaLabel,"aria-expanded":e.pressed,title:e.title,children:(0,$.jsx)(m,{name:e.icon,className:`size-5`})},`${e.icon}:${t}`)}function St(e){return e.elevated}export{le as A,ft as C,ce as D,ue as E,y as M,v as N,se as O,et as S,pe as T,Xe as _,ht as a,Be as b,ot as c,it as d,lt as f,qe as g,rt as h,pt as i,_ as j,de as k,vt as l,mt as m,Ke as n,at as o,ut as p,Je as r,gt as s,bt as t,_t as u,Ie as v,me as w,Qe as x,Re as y};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,n}from"./runtime-switch-DEZ1K7qW.js";import{n as r}from"./runtime-fetch-D0YWp3FJ.js";import{ot as i,st as a}from"./vendor-base-ui-CzHs0bHY.js";import{n as o}from"./vendor-react-DlzBev0S.js";import{s}from"./vendor-tanstack-react-query-B2psfNaU.js";import{a as c}from"./queryRuntime-CTcigFdj.js";import{r as l,t as u}from"./button-BF2cNEuq.js";import{i as d}from"./store-BPYoxYhv.js";import{Ea as f,wa as p}from"./useMobileNavigationStore-9lAGHZos.js";import{n as m}from"./Icon-CLLDJn-P.js";var h=e(a(),1),g=o(),_=class extends Error{code;status;resource;constructor(e,t,n,r){super(typeof r==`string`&&r.trim()?r.trim():e),this.code=e,this.status=t,this.resource=n}},v=e=>{if(!e||typeof e!=`object`)return!1;let t=`name`in e?String(e.name):``;return t===`AbortError`||t===`TimeoutError`},y=class extends _{operation;constructor(e,t,n){super(e,t,`share_operation`),this.operation=n}},b=(e,t=200)=>{throw new _(`invalid_${e}_response`,t,e)},x=(e,t)=>e&&typeof e==`object`&&!Array.isArray(e)?e:b(t),S=(e,t)=>typeof e==`string`?e:b(t),C=(e,t)=>e===null||typeof e==`string`?e:b(t),w=(e,t)=>typeof e==`number`&&Number.isFinite(e)?e:b(t),T=(e,t)=>e===null?null:w(e,t),E=(e,t)=>typeof e==`boolean`?e:b(t),D=(e,t,n)=>t.includes(e)?e:b(n),O=e=>{let t=x(e,`capability`);return{supported:E(t.supported,`capability`),enabled:E(t.enabled,`capability`),revision:w(t.revision,`capability`),serverInstanceID:C(t.serverInstanceID,`capability`),sharingAvailable:t.sharingAvailable!==void 0&&E(t.sharingAvailable,`capability`)}},k=e=>{if(e==null)return null;let t=x(e,`assistant`);return{turnID:S(t.turnID,`assistant`),messageID:S(t.messageID,`assistant`),status:D(t.status,[`queued`,`running`],`assistant`),admittedAt:w(t.admittedAt,`assistant`)}},A=e=>{if(e==null)return null;let t=x(e,`assistant_preview`),n=w(t.ordinal,`assistant_preview`);return!Number.isSafeInteger(n)||n<0?b(`assistant_preview`):{...t.createdAt===void 0?{}:{createdAt:w(t.createdAt,`assistant_preview`)},messageID:S(t.messageID,`assistant_preview`),ordinal:n,role:D(t.role,[`user`,`assistant`],`assistant_preview`),text:S(t.text,`assistant_preview`),fallbackKind:t.fallbackKind===null?null:D(t.fallbackKind,[`image`,`file`,`session`,`assistant`,`schedule`],`assistant_preview`)}},j=e=>{let t=w(e,`assistant_read`);return Number.isSafeInteger(t)&&t>=0?t:b(`assistant_read`)},M=e=>{let t=x(e,`assistant_read`);return{generation:j(t.generation),ordinal:j(t.ordinal),messageID:S(t.messageID,`assistant_read`)}},N=e=>({unreadCount:e.unreadCount===void 0?0:j(e.unreadCount),readWatermark:e.readWatermark==null?null:M(e.readWatermark),readTip:e.readTip==null?null:M(e.readTip)}),P=e=>{let t=x(e,`assistant_read`);return{assistantID:S(t.assistantID,`assistant_read`),changed:E(t.changed,`assistant_read`),unreadCount:j(t.unreadCount),readWatermark:M(t.readWatermark),readTip:M(t.readTip),revision:j(t.revision)}},F=e=>{let t=x(e,`assistant`),n=Array.isArray(t.historySessionIDs)?t.historySessionIDs.map(e=>S(e,`assistant`)):[],r=t.historySessionCount===void 0?n.length:w(t.historySessionCount,`assistant`);if(!Number.isSafeInteger(r)||r<n.length)return b(`assistant`);let i=Array.isArray(t.assignedSessionIDs)?t.assignedSessionIDs.map(e=>S(e,`assistant`)):[],a=t.activeContactTurn===void 0?null:k(t.activeContactTurn),o=t.working===void 0?a!=null:E(t.working,`assistant`);return{...N(t),pinnedAt:t.pinnedAt===void 0?void 0:T(t.pinnedAt,`assistant`),latestMessagePreview:A(t.latestMessagePreview),id:S(t.id,`assistant`),avatarSeed:S(t.avatarSeed??t.id,`assistant`),revision:w(t.revision,`assistant`),enabled:E(t.enabled,`assistant`),name:S(t.name,`assistant`),defaultPrompt:S(t.defaultPrompt,`assistant`),workspacePath:C(t.workspacePath,`assistant`),effectiveWorkspacePath:S(t.effectiveWorkspacePath,`assistant`),managedWorkspacePath:C(t.managedWorkspacePath??null,`assistant`),providerID:S(t.providerID,`assistant`),modelID:S(t.modelID,`assistant`),agent:C(t.agent,`assistant`),variant:C(t.variant??null,`assistant`),mode:D(t.mode,[`continuous`,`stateless`],`assistant`),sessionID:C(t.sessionID,`assistant`),sessionGeneration:w(t.sessionGeneration,`assistant`),historySessionIDs:n,historySessionCount:r,assignedSessionIDs:i,working:o,activeContactTurn:a,createdAt:T(t.createdAt,`assistant`),updatedAt:w(t.updatedAt,`assistant`),tombstoneAt:T(t.tombstoneAt,`assistant`)}},I=e=>{let t=x(e,`snapshot`);return{revision:w(t.revision,`snapshot`),enabled:E(t.enabled,`snapshot`),assistants:Array.isArray(t.assistants)?t.assistants.map(F):b(`snapshot`)}},L=e=>{let t=x(e,`binding`);return{sessionID:C(t.sessionID,`binding`),directory:S(t.directory,`binding`),sessionGeneration:w(t.sessionGeneration,`binding`)}},R=e=>{let t=x(e,`message_admission`);if(t.admitted!==!0)return b(`message_admission`);let n=t.revision===void 0||t.revision===null?null:w(t.revision,`message_admission`);return{binding:L(t.binding),messageID:S(t.messageID,`message_admission`),admitted:!0,revision:n,...t.replayed===!0?{replayed:!0}:{}}},z=e=>{let t=x(e,`share_operation`);return{operationID:S(t.operationID,`share_operation`),assistantID:S(t.assistantID,`share_operation`),sessionID:C(t.sessionID,`share_operation`),messageID:C(t.messageID,`share_operation`),state:D(t.state,[`submitting`,`running`,`completed`,`failed`,`unresolved`],`share_operation`),phase:S(t.phase,`share_operation`),attempt:w(t.attempt,`share_operation`),leaseExpiresAt:T(t.leaseExpiresAt,`share_operation`),errorCode:C(t.errorCode,`share_operation`)}},B=e=>{let t=x(e,`assistant_contact_part`);if(t.type===`text`)return{type:`text`,text:S(t.text,`assistant_contact_part`)};if(t.type===`file`){let e=t.filename===void 0||t.filename===null?void 0:S(t.filename,`assistant_contact_part`),n=S(t.mime,`assistant_contact_part`),r=t.url!==void 0&&t.url!==null,i=t.attachmentID!==void 0&&t.attachmentID!==null;if(r&&i)return b(`assistant_contact_part`);if(i){let r=w(t.size,`assistant_contact_part`);return!Number.isSafeInteger(r)||r<0?b(`assistant_contact_part`):{type:`file`,mime:n,attachmentID:S(t.attachmentID,`assistant_contact_part`),sha256:S(t.sha256,`assistant_contact_part`),size:r,...e?{filename:e}:{}}}return r?{type:`file`,mime:n,url:S(t.url,`assistant_contact_part`),...e?{filename:e}:{}}:b(`assistant_contact_part`)}if(t.type===`card`){let e=D(t.cardType,[`session`,`assistant`,`schedule`],`assistant_contact_part`);return e===`session`?{type:`card`,cardType:`session`,sessionID:S(t.sessionID,`assistant_contact_part`),directory:S(t.directory,`assistant_contact_part`),title:C(t.title??null,`assistant_contact_part`),status:C(t.status??null,`assistant_contact_part`),branch:C(t.branch??null,`assistant_contact_part`)}:e===`assistant`?{type:`card`,cardType:`assistant`,assistantID:S(t.assistantID,`assistant_contact_part`),name:S(t.name,`assistant_contact_part`),providerID:S(t.providerID,`assistant_contact_part`),modelID:S(t.modelID,`assistant_contact_part`),mode:D(t.mode??`continuous`,[`continuous`,`stateless`],`assistant_contact_part`)}:{type:`card`,cardType:`schedule`,taskID:S(t.taskID,`assistant_contact_part`),projectID:S(t.projectID,`assistant_contact_part`),name:S(t.name,`assistant_contact_part`),kind:C(t.kind??null,`assistant_contact_part`),time:C(t.time??null,`assistant_contact_part`),timezone:C(t.timezone??null,`assistant_contact_part`),prompt:C(t.prompt??null,`assistant_contact_part`),...t.cron===void 0?{}:{cron:C(t.cron,`assistant_contact_part`)},...t.date===void 0?{}:{date:C(t.date,`assistant_contact_part`)},...t.times===void 0?{}:{times:t.times===null?null:Array.isArray(t.times)?t.times.map(e=>S(e,`assistant_contact_part`)):b(`assistant_contact_part`)},...t.weekdays===void 0?{}:{weekdays:t.weekdays===null?null:Array.isArray(t.weekdays)?t.weekdays.map(e=>{let t=w(e,`assistant_contact_part`);return Number.isInteger(t)&&t>=0&&t<=6?t:b(`assistant_contact_part`)}):b(`assistant_contact_part`)}}}return b(`assistant_contact_part`)},ee=e=>{let t=x(e,`assistant_contact`),n=C(t.nextCursor,`assistant_contact`),r=E(t.complete,`assistant_contact`);if(!r&&!n||r&&n||!Array.isArray(t.messages))return b(`assistant_contact`);let i=w(t.generation,`assistant_contact`),a=w(t.revision,`assistant_contact`);return!Number.isSafeInteger(i)||i<0||!Number.isSafeInteger(a)||a<0?b(`assistant_contact`):{messages:t.messages.map(e=>{let t=x(e,`assistant_contact_message`);if(!Array.isArray(t.parts))return b(`assistant_contact_message`);let n=t.parts.map(B);return{messageID:S(t.messageID,`assistant_contact_message`),assistantID:S(t.assistantID,`assistant_contact_message`),role:D(t.role,[`user`,`assistant`,`peer`],`assistant_contact_message`),turnID:S(t.turnID,`assistant_contact_message`),bubbleIndex:w(t.bubbleIndex,`assistant_contact_message`),createdAt:w(t.createdAt,`assistant_contact_message`),ordinal:w(t.ordinal,`assistant_contact_message`),status:S(t.status,`assistant_contact_message`),fromAssistantID:C(t.fromAssistantID??null,`assistant_contact_message`),fromAssistantName:C(t.fromAssistantName??null,`assistant_contact_message`),parts:n,text:typeof t.text==`string`?t.text:n.filter(e=>e.type===`text`).map(e=>e.text).join(``),cards:n.filter(e=>e.type===`card`)}}),nextCursor:n,complete:r,generation:i,revision:a}},te=e=>{let t=x(e,`assistant_scheduled_tasks`);return Array.isArray(t.tasks)?{tasks:t.tasks.map(e=>{let t=x(e,`assistant_scheduled_task`),n=t.task===null||t.task===void 0?null:x(t.task,`assistant_scheduled_task_live`);return{assistantID:S(t.assistantID,`assistant_scheduled_task`),projectID:S(t.projectID,`assistant_scheduled_task`),taskID:S(t.taskID,`assistant_scheduled_task`),createdAt:w(t.createdAt,`assistant_scheduled_task`),projectPath:C(t.projectPath??null,`assistant_scheduled_task`),projectLabel:C(t.projectLabel??null,`assistant_scheduled_task`),task:n}})}:b(`assistant_scheduled_tasks`)},V=async(e,t)=>{try{let t=await e.json();if(t&&typeof t.error==`string`&&t.error.trim().length>0)return t.error}catch{return t}return t},H=e=>{let t=typeof e==`string`?e.trim():``;if(!t)throw Error(`projectId is required`);return t},U=e=>e===null||typeof e==`string`,ne=e=>e===null||typeof e==`number`&&Number.isFinite(e),re=e=>typeof e==`number`&&Number.isFinite(e)&&e>=0&&e<=864e13,ie=e=>e===null||re(e),ae=e=>{if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return typeof t.id==`string`&&t.id.length>0&&typeof t.projectId==`string`&&t.projectId.length>0&&typeof t.taskId==`string`&&t.taskId.length>0&&typeof t.taskName==`string`&&(t.trigger===`scheduled`||t.trigger===`manual`)&&(t.status===`running`||t.status===`success`||t.status===`error`)&&U(t.sessionId)&&U(t.directory)&&U(t.error)&&re(t.startedAt)&&ie(t.finishedAt)&&ne(t.durationMs)&&(t.durationMs===null||t.durationMs>=0)},oe=e=>{if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`Malformed scheduled task runs response`);let t=e;if(!Array.isArray(t.runs)||!t.runs.every(ae)||!U(t.nextCursor)||typeof t.complete!=`boolean`||t.complete!==(t.nextCursor===null)||t.nextCursor!==null&&t.nextCursor.length===0)throw Error(`Malformed scheduled task runs response`);return{runs:t.runs,nextCursor:t.nextCursor,complete:t.complete}},se=async(e,t)=>{let n=new URLSearchParams;e.before&&n.set(`before`,e.before);let i=e.limit??20;if(!Number.isInteger(i)||i<1)throw Error(`limit must be a positive integer`);n.set(`limit`,String(i)),e.projectId&&n.set(`projectId`,e.projectId),e.taskId&&n.set(`taskId`,e.taskId);let a=await r(`/api/yuri/scheduled-task-runs?${n.toString()}`,{signal:t});if(!a.ok)throw Error(await V(a,`Failed to load scheduled task history`));return oe(await a.json().catch(()=>null))},ce=async({signal:e}={})=>{let t=await r(`/api/yuri/scheduled-tasks`,{signal:e});if(!t.ok)throw Error(await V(t,`Failed to load schedules`));let n=await t.json().catch(()=>null);if(!n||!Array.isArray(n.tasks))throw Error(`Malformed schedules response`);return{tasks:Array.isArray(n?.tasks)?n.tasks:[],failedProjectIds:Array.isArray(n?.failedProjectIds)?n.failedProjectIds.filter(e=>typeof e==`string`):[]}},le=async(e,t)=>{let n=H(e),i=await r(`/api/projects/${encodeURIComponent(n)}/scheduled-tasks`,{method:`PUT`,headers:{"content-type":`application/json`,accept:`application/json`},body:JSON.stringify({task:t})});if(!i.ok)throw Error(await V(i,`Failed to save schedule`));let a=await i.json().catch(()=>null);return!a||!Array.isArray(a.tasks)?[]:a.tasks},ue=async(e,t)=>{let n=H(e),i=H(t),a=await r(`/api/projects/${encodeURIComponent(n)}/scheduled-tasks/${encodeURIComponent(i)}`,{method:`DELETE`,headers:{accept:`application/json`}});if(!a.ok)throw Error(await V(a,`Failed to delete schedule`));let o=await a.json().catch(()=>null);return!o||!Array.isArray(o.tasks)?[]:o.tasks},de=async(e,t)=>{let n=H(e),i=H(t),a=await r(`/api/projects/${encodeURIComponent(n)}/scheduled-tasks/${encodeURIComponent(i)}/run`,{method:`POST`,headers:{accept:`application/json`}});if(!a.ok)throw Error(await V(a,`Failed to run schedule`));let o=await a.json().catch(()=>null);return{sessionId:typeof o?.sessionId==`string`&&o.sessionId.length>0?o.sessionId:void 0}},fe=(e,t)=>e.ordinal===t.ordinal?e.messageID<t.messageID?-1:+(e.messageID>t.messageID):e.ordinal-t.ordinal,pe=e=>{if(e.type===`file`||e.type===`card`)return!0;if(e.type!==`text`)return!1;let t=typeof e.text==`string`?e.text.trim():``;return!!t&&!t.startsWith(`yuri.settle.`)&&!t.startsWith(`oc.settle.`)},me=(e,t)=>{if(!t||!e.readTip||!((e.unreadCount??0)>0))return null;let n=e.readTip;if(t.generation!==n.generation)return null;let r;for(let n=t.messages.length-1;n>=0;--n){let i=t.messages[n];if(i.assistantID===e.id&&(i.status===`complete`||i.status===`error`)&&i.parts.some(pe)){r=i;break}}if(!r)return null;let i=e.readWatermark;return i&&(i.generation>t.generation||i.generation===t.generation&&fe({ordinal:i.ordinal,messageID:i.messageID},{ordinal:r.ordinal,messageID:r.messageID})>=0)?null:{generation:t.generation,ordinal:r.ordinal,messageID:r.messageID}},he=()=>({messages:[],generation:-1,revision:0,olderCursor:null,olderComplete:!0,hasMessageGap:!1,gapCursor:null,gapRequestIDs:null,gapTargetIDs:null,liveWindowIDs:[]}),ge=e=>!!(e&&e.generation>=0),_e=(e,t)=>fe({ordinal:e.ordinal,messageID:e.messageID},{ordinal:t.ordinal,messageID:t.messageID}),W=(e,t,n=`incoming`)=>{let r=new Map;for(let t of e)r.set(t.messageID,t);for(let e of t)(n===`incoming`||!r.has(e.messageID))&&r.set(e.messageID,e);return[...r.values()].sort(_e)},ve=e=>{let t=1/0;for(let n of e)n.ordinal<t&&(t=n.ordinal);return Number.isFinite(t)?t:null},ye=e=>e.map(e=>e.messageID),be=(e,t)=>{for(let n of e)if(t.has(n))return!0;return!1},xe=e=>new Set(e),Se=(e,t)=>!e||!t||e.length!==t.length?!1:e.every((e,n)=>e===t[n]),Ce=e=>({...e,hasMessageGap:!1,gapCursor:null,gapRequestIDs:null,gapTargetIDs:null}),we=e=>({ordinal:e.ordinal,messageID:e.messageID}),Te=(e,t,n)=>{if(n)return[...t];if(t.length===0)return[...e];let r=t[0];return[...e.filter(e=>fe(we(e),we(r))<0),...t]},Ee=(e,t)=>{let n=e??he(),r=ge(n),i=[...t.messages].sort(_e),a=ye(i);if(r&&t.generation<n.generation)return n;if(r&&t.generation>n.generation)return{messages:i,generation:t.generation,revision:t.revision,olderCursor:t.nextCursor,olderComplete:t.complete,hasMessageGap:!1,gapCursor:null,gapRequestIDs:null,gapTargetIDs:null,liveWindowIDs:a};if(!r)return{messages:i,generation:t.generation,revision:t.revision,olderCursor:t.complete?null:t.nextCursor,olderComplete:t.complete,hasMessageGap:!1,gapCursor:null,gapRequestIDs:null,gapTargetIDs:null,liveWindowIDs:a};let o=Math.max(n.revision,t.revision),s=t.revision>=n.revision;if(i.length===0)return s&&t.complete?{messages:[],generation:t.generation,revision:o,olderCursor:null,olderComplete:!0,hasMessageGap:!1,gapCursor:null,gapRequestIDs:null,gapTargetIDs:null,liveWindowIDs:[]}:{...n,generation:t.generation,revision:o,olderCursor:n.olderCursor??t.nextCursor,olderComplete:n.olderComplete&&t.complete,liveWindowIDs:[],hasMessageGap:n.hasMessageGap,gapCursor:n.hasMessageGap?t.nextCursor??n.gapCursor:null,gapRequestIDs:n.hasMessageGap?n.gapRequestIDs:null,gapTargetIDs:n.hasMessageGap?n.gapTargetIDs:null};let c;if(s)c=Te(n.messages,i,t.complete);else{let e=ve(i);c=W(n.messages.filter(t=>t.ordinal<e),W(n.messages.filter(t=>t.ordinal>=e),i,`existing`),`incoming`)}let l=n.liveWindowIDs,u=xe(a),d=l.length>0&&be(l,u),f=n.hasMessageGap,p=n.gapCursor,m=n.gapRequestIDs,h=n.gapTargetIDs;if(!d&&l.length>0&&t.nextCursor){f=!0,p=t.nextCursor;let e=l.filter(e=>!u.has(e));m=e.length>0?e:[...l],h=n.hasMessageGap&&n.gapTargetIDs&&n.gapTargetIDs.length>0?n.gapTargetIDs:m}else n.hasMessageGap?(f=!0,p=n.gapCursor,m=n.gapRequestIDs,h=n.gapTargetIDs):(f=!1,p=null,m=null,h=null);return{messages:c,generation:t.generation,revision:o,olderCursor:n.liveWindowIDs.length===0&&n.messages.length===0?t.complete?null:t.nextCursor:n.olderCursor,olderComplete:!r||n.liveWindowIDs.length===0&&n.messages.length===0?t.complete:n.olderComplete,hasMessageGap:f,gapCursor:f?p:null,gapRequestIDs:f?m:null,gapTargetIDs:f?h:null,liveWindowIDs:a}},De=(e,t)=>{if(!ge(e)||t.generation!==e.generation)return e;let n=t.revision>=e.revision?`incoming`:`existing`,r=W(e.messages,t.messages,n);return{...e,messages:r,revision:Math.max(e.revision,t.revision),olderCursor:t.complete?null:t.nextCursor,olderComplete:t.complete}},Oe=(e,t,n)=>{if(!ge(e)||t.generation!==e.generation)return e;let r=t.revision>=e.revision?`incoming`:`existing`,i=W(e.messages,t.messages,r),a=Math.max(e.revision,t.revision),o=n?.requestIDs??e.gapRequestIDs;if(!(e.hasMessageGap&&o&&e.gapRequestIDs&&Se(o,e.gapRequestIDs)))return{...e,messages:i,revision:a};let s=ye(t.messages),c=e.gapTargetIDs??[],l=xe(c);return c.length>0&&be(s,l)||t.complete||!t.nextCursor?Ce({...e,messages:i,revision:a}):{...e,messages:i,revision:a,hasMessageGap:!0,gapCursor:t.nextCursor??e.gapCursor,gapRequestIDs:e.gapRequestIDs,gapTargetIDs:e.gapTargetIDs}},G={snapshot:(e=t())=>[e,`assistants`,`snapshot`],capability:(e=t())=>[e,`assistants`,`capability`],history:(e,r,i,a=t(),o=n())=>[a,o,`assistants`,`history`,e,r,i],contact:(e,r=t(),i=n())=>[r,i,`assistants`,`contact`,e],scheduledTasks:(e,r=t(),i=n())=>[r,i,`assistants`,`scheduled-tasks`,e],globalScheduledTasks:(e=t())=>[e,`scheduled-tasks`]},K=async(e,t={})=>{let n=await r(e,t),i=await n.json().catch(()=>null);if(!n.ok){let e=i&&typeof i==`object`&&`error`in i&&typeof i.error==`string`?i.error:`request_failed`,t=i&&typeof i==`object`&&`message`in i&&typeof i.message==`string`?i.message:void 0;throw new _(e,n.status,void 0,t)}return i},q=(e,t)=>({method:e,headers:{"Content-Type":`application/json`},body:t===void 0?void 0:JSON.stringify(t)}),J=(e,r)=>{if(t()!==e||n()!==r)throw new _(`runtime_stale`,409)},ke=(e,t,r)=>{c.setQueryData(G.snapshot(r),n=>n&&{...n,assistants:n.assistants.map(n=>n.id!==e||n.sessionGeneration>t.sessionGeneration?n:{...n,sessionID:t.sessionID,sessionGeneration:t.sessionGeneration,effectiveWorkspacePath:t.directory})}),c.invalidateQueries({queryKey:G.snapshot(r)}),c.invalidateQueries({queryKey:[r,n(),`assistants`,`history`,e]})},Ae=(e,t)=>{c.setQueryData(G.snapshot(t),t=>t&&{...t,assistants:t.assistants.some(t=>t.id===e.id)?t.assistants.map(t=>t.id===e.id?e:t):[...t.assistants,e]}),c.invalidateQueries({queryKey:G.snapshot(t)})},je=2500,Me=15e3,Ne=e=>!!e?.assistants.some(e=>e.working||e.activeContactTurn),Pe=(e,t={})=>{if(t.assistantID){let n=e?.assistants.find(e=>e.id===t.assistantID);return n?.working||n?.activeContactTurn?je:Me}return Ne(e)?je:Me},Y=(e=t())=>({queryKey:G.snapshot(e),queryFn:async({signal:e})=>I(await K(`/api/yuri/assistants/snapshot`,{signal:e})),staleTime:0,retry:2,refetchInterval:e=>Pe(e.state.data),refetchIntervalInBackground:!1,refetchOnWindowFocus:!0,refetchOnReconnect:!0}),X=new Map,Fe=e=>{let r=X.get(e);if(r)r.count+=1;else{let r=n(),i=!1,a=!1,o=!1,s=()=>!i&&t()===e&&n()===r,l=async()=>{if(o=!0,!a){a=!0;try{do o=!1,c.getQueryCache().find({queryKey:G.snapshot(e),exact:!0})?.state.fetchStatus===`fetching`&&(o=!0),await c.invalidateQueries({queryKey:G.snapshot(e),exact:!0},{cancelRefetch:!1});while(o&&s())}finally{a=!1}}},u=f(t=>{if(!s())return;let n=c.getQueryData(G.snapshot(e));(t.type===`event-stream-ready`||t.type===`contact-turn-start`||t.type===`contact-turn-end`||t.type===`assistants-changed`&&(!n||t.revision>n.revision))&&l()});X.set(e,{count:1,dispose:()=>{i=!0,u()}})}return()=>{let t=X.get(e);t&&--t.count===0&&(t.dispose(),X.delete(e))}},Ie=e=>{let n=(0,g.c)(7),r,i,a;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=t(),i=s,r=Y(a),n[0]=r,n[1]=i,n[2]=a):(r=n[0],i=n[1],a=n[2]);let o;n[3]===e?o=n[4]:(o={...r,select:e},n[3]=e,n[4]=o);let c=i(o),l,u;return n[5]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>Fe(a),u=[a],n[5]=l,n[6]=u):(l=n[5],u=n[6]),h.useEffect(l,u),c},Le=e=>e.enabled?e.assistants.reduce((e,t)=>e+(t.unreadCount??0),0):0,Re=()=>{let e=(0,g.c)(5),n,r,i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=t(),n=s,r={...Y(i),select:Le},e[0]=n,e[1]=r,e[2]=i):(n=e[0],r=e[1],i=e[2]);let a=n(r),o,c;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>Fe(i),c=[i],e[3]=o,e[4]=c):(o=e[3],c=e[4]),h.useEffect(o,c),a.data??0},ze=e=>e.enabled&&Ne(e),Be=()=>{let e=(0,g.c)(5),n,r,i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=t(),n=s,r={...Y(i),select:ze},e[0]=n,e[1]=r,e[2]=i):(n=e[0],r=e[1],i=e[2]);let a=n(r),o,c;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>Fe(i),c=[i],e[3]=o,e[4]=c):(o=e[3],c=e[4]),h.useEffect(o,c),a.data??!1},Ve=(e,t={})=>{let n=new URLSearchParams;return n.set(`limit`,String(t.limit??20)),t.before&&n.set(`before`,t.before),t.messageID&&n.set(`messageID`,t.messageID),`/api/yuri/assistants/${encodeURIComponent(e)}/contact/messages?${n}`},He=async(e,t,n)=>ee(await K(Ve(e,t),n?{signal:n}:{})),Ue=(e,t)=>e.generation===t.generation&&e.revision===t.revision&&e.olderCursor===t.olderCursor&&e.olderComplete===t.olderComplete&&e.hasMessageGap===t.hasMessageGap&&e.gapCursor===t.gapCursor&&e.messages===t.messages&&e.liveWindowIDs===t.liveWindowIDs&&e.gapRequestIDs===t.gapRequestIDs&&e.gapTargetIDs===t.gapTargetIDs,Z=new Map,We=new Map,Q=e=>e.join(``),Ge=async(e,t,n,r,i)=>{let a=Q(t),o=We.get(a);if(o)return o;let s=(async()=>{let a=c.getQueryData(t)??n,o=0,s=!1,l=!1,u=a.gapRequestIDs?[...a.gapRequestIDs]:null,d=a.gapCursor;for(;a.hasMessageGap&&a.gapCursor&&o<5&&!i?.aborted;){J(r.transport,r.runtimeGeneration),o+=1;let n=a.gapCursor;try{let o=await He(e,{limit:20,before:n},i);J(r.transport,r.runtimeGeneration);let l=c.getQueryData(t)??a;if(o.generation!==l.generation){a=l;break}let f=!u||!!(l.hasMessageGap&&l.gapRequestIDs&&l.gapRequestIDs.length===u.length&&l.gapRequestIDs.every((e,t)=>e===u[t]));if(a=Oe(l,o,u?{requestIDs:u,cursor:d}:void 0),c.setQueryData(t,a),!f)break;if(!a.hasMessageGap){s=!0;break}if(a.gapCursor&&a.gapCursor!==n)s=!0;else break}catch(e){if(i?.aborted||v(e))break;l=!0,a=c.getQueryData(t)??a;break}}return{view:c.getQueryData(t)??a,failed:l,progressed:s}})();We.set(a,s);try{return await s}finally{We.get(a)===s&&We.delete(a)}},Ke=(e,r=t(),i=n(),a={})=>({queryKey:G.contact(e,r,i),queryFn:async({signal:t})=>{J(r,i),await p(),J(r,i);let n=G.contact(e,r,i),a=c.getQueryData(n),o=await He(e,{limit:20},t);J(r,i);let s=Ee(c.getQueryData(n)??a??null,o);c.setQueryData(n,s);let l=Q(n);if(s.hasMessageGap&&s.gapCursor){Z.delete(l);let a=await Ge(e,n,s,{transport:r,runtimeGeneration:i},t);s=a.view,(a.failed||a.view.hasMessageGap&&!a.progressed)&&a.view.gapCursor&&Z.set(l,a.view.gapCursor)}else Z.delete(l);J(r,i);let u=c.getQueryData(n)??s;return a&&Ue(a,u)?a:u},retry:2,staleTime:0,refetchInterval:()=>a.reconcileInForeground?Pe(c.getQueryData(G.snapshot(r)),{assistantID:e}):!1,refetchIntervalInBackground:!1,refetchOnWindowFocus:!0,refetchOnReconnect:!0,structuralSharing:!0}),qe=(e,r=!0)=>{let i=t(),a=n(),[o,l]=h.useState(!1),[u,d]=h.useState(null),[p,m]=h.useState(!1),g=h.useRef(null),_=h.useRef(null),y=h.useRef(null),b=h.useRef(null),x=h.useRef({assistantID:e,transport:i,runtimeGeneration:a,enabled:r});x.current={assistantID:e,transport:i,runtimeGeneration:a,enabled:r};let S=s({...Ke(e,i,a,{reconcileInForeground:!0}),enabled:r&&!!e});h.useEffect(()=>{!r||!e||c.invalidateQueries({queryKey:G.snapshot(i),exact:!0},{cancelRefetch:!1})},[e,r,a,i]),h.useEffect(()=>f(n=>{t()===i&&(n.type===`assistants-changed`||n.type===`event-stream-ready`||n.type===`contact-turn-end`)&&(n.type===`contact-turn-end`&&`assistantID`in n&&n.assistantID!==e||c.invalidateQueries({queryKey:G.contact(e,i,a),exact:!0}))}),[e,a,i]),h.useEffect(()=>{let t=Q(G.contact(e,i,a));return()=>{y.current?.abort(),b.current?.abort(),y.current=null,b.current=null,g.current=null,_.current=null,Z.delete(t)}},[e,i,a,r]);let C=S.data,w=G.contact(e,i,a),T=async()=>{if(!e||!r)return;if(g.current)return g.current;let t=c.getQueryData(w)??C;if(!t||t.olderComplete||!t.olderCursor)return;d(null),l(!0);let n=new AbortController;b.current?.abort(),b.current=n;let o={transport:i,runtimeGeneration:a,assistantID:e,cursor:t.olderCursor},s=(async()=>{try{J(o.transport,o.runtimeGeneration);let e=await He(o.assistantID,{limit:20,before:o.cursor},n.signal);if(n.signal.aborted||(J(o.transport,o.runtimeGeneration),x.current.assistantID!==o.assistantID||x.current.transport!==o.transport||x.current.runtimeGeneration!==o.runtimeGeneration))return;let r=c.getQueryData(w)??t;if(e.generation!==r.generation)return;c.setQueryData(w,De(r,e))}catch(e){if(n.signal.aborted||v(e))return;let t=e instanceof Error?e:Error(String(e));throw d(t),t}finally{b.current===n&&(b.current=null),l(!1),g.current=null}})();return g.current=s,s},E=async(t=`explicit`)=>{if(!e||!r)return;if(_.current)return _.current;let n=c.getQueryData(w)??C;if(!n?.hasMessageGap||!n.gapCursor)return;let o=Q(w);if(t===`auto`&&Z.get(o)===n.gapCursor)return;t===`explicit`&&Z.delete(o),m(!0);let s=new AbortController;y.current?.abort(),y.current=s;let l={transport:i,runtimeGeneration:a,assistantID:e,cursor:n.gapCursor},u=(async()=>{try{J(l.transport,l.runtimeGeneration);let e=await Ge(l.assistantID,w,n,{transport:l.transport,runtimeGeneration:l.runtimeGeneration},s.signal);if(s.signal.aborted)return;if(J(l.transport,l.runtimeGeneration),e.failed||!e.progressed){e.view.gapCursor&&Z.set(o,e.view.gapCursor);return}e.view.hasMessageGap||Z.delete(o)}catch(e){if(s.signal.aborted||v(e))return;throw Z.set(o,l.cursor),e}finally{y.current===s&&(y.current=null),m(!1),_.current=null}})();return _.current=u,u};return h.useEffect(()=>{if(!r||!e||!C?.hasMessageGap||!C.gapCursor||S.isFetching||p)return;let t=Q(w);Z.get(t)!==C.gapCursor&&E(`auto`).catch(()=>void 0)},[r,e,C?.hasMessageGap,C?.gapCursor,S.isFetching,p,w]),{data:C?{messages:C.messages,generation:C.generation,revision:C.revision,nextCursor:C.olderCursor,complete:C.olderComplete}:void 0,status:S.status,fetchStatus:S.fetchStatus,isError:S.isError,isPending:S.isPending,isFetching:S.isFetching,isSuccess:S.isSuccess,error:S.error instanceof Error?S.error:S.error?Error(String(S.error)):null,refetch:()=>S.refetch(),fetchPreviousPage:T,hasPreviousPage:!!(C&&!C.olderComplete&&C.olderCursor),isFetchingPreviousPage:o,previousPageError:u,hasMessageGap:!!C?.hasMessageGap,isFillingMessageGap:p,retryMessageGap:()=>E(`explicit`)}},Je=async(e,r)=>{let i=t(),a=n();await p(),J(i,a);let o=await He(e,{messageID:r,limit:1});if(J(i,a),!o.messages.some(e=>e.messageID===r&&e.role===`user`))return null;c.invalidateQueries({queryKey:G.contact(e,i,a),exact:!0}),c.invalidateQueries({queryKey:G.snapshot(i),exact:!0});let s=c.getQueryData(G.snapshot(i));return{admitted:!0,messageID:r,revision:o.revision??s?.revision??null}},Ye=(e,r=t(),i=n())=>({queryKey:G.scheduledTasks(e,r,i),queryFn:async({signal:t})=>{J(r,i);let n=te(await K(`/api/yuri/assistants/${encodeURIComponent(e)}/scheduled-tasks`,{signal:t}));return J(r,i),n},refetchOnMount:`always`,retry:(e,t)=>!(t instanceof _&&t.status===404)&&e<2}),Xe=(e,r)=>{let i=(0,g.c)(6),a=r===void 0||r,o,c;if(i[0]!==e){let r=t(),a=n();c=s,o=Ye(e,r,a),i[0]=e,i[1]=o,i[2]=c}else o=i[1],c=i[2];let l=a&&!!e,u;return i[3]!==o||i[4]!==l?(u={...o,enabled:l},i[3]=o,i[4]=l,i[5]=u):u=i[5],c(u)},Ze=(e=t())=>({queryKey:G.globalScheduledTasks(e),queryFn:ce,refetchOnMount:`always`}),Qe=e=>{let t=(0,g.c)(3),n=e===void 0||e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=Ze(),t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i={...r,enabled:n},t[1]=n,t[2]=i),s(i)},$e=e=>e.tasks.some(({task:e})=>e.state.lastStatus===`running`),et=()=>{let e=(0,g.c)(5),n,r,i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=t(),n=s,r={...Ze(i),select:$e,staleTime:0,refetchInterval:yt,refetchIntervalInBackground:!1},e[0]=n,e[1]=r,e[2]=i):(n=e[0],r=e[1],i=e[2]);let a=n(r),o,l;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>f(e=>{t()===i&&(e.type===`scheduled-task-ran`||e.type===`event-stream-ready`)&&c.invalidateQueries({queryKey:Ze(i).queryKey,exact:!0})}),l=[i],e[3]=o,e[4]=l):(o=e[3],l=e[4]),h.useEffect(o,l),a.data===!0},tt=(e,r=t())=>{c.invalidateQueries({queryKey:[r,n(),`assistants`,`contact`,e]})},nt=(e=t())=>({queryKey:G.capability(e),queryFn:()=>gt(),retry:!1}),rt=()=>{let e=(0,g.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=nt(),e[0]=t):t=e[0],s(t)},it=(e=c,n=t())=>e.getQueryData(G.snapshot(n)),at=(e=c,n=t())=>e.fetchQuery(Y(n)),ot=async(e=c)=>{let r=t(),i=n();await e.invalidateQueries({queryKey:G.snapshot(r),exact:!0}),J(r,i);let a=await e.fetchQuery(Y(r));return J(r,i),a},st=15e3,ct=e=>{throw e instanceof _?e:v(e)?new _(`admission_timeout`,408):e},lt=async(e,r,i)=>{let a=t(),o=n(),s=typeof i==`string`?[{type:`text`,text:i}]:Array.isArray(i.parts)&&i.parts.length>0?i.parts:[{type:`text`,text:i.text??``}],c=AbortSignal.timeout(st);try{let t=R(await K(`/api/yuri/assistants/${encodeURIComponent(e)}/messages`,{...q(`POST`,{messageID:r,parts:s,language:d.getState().locale}),signal:c}));return J(a,o),ke(e,t.binding,a),tt(e,a),t}catch(e){return ct(e)}},ut=async(e,r,i,a,o)=>{let s=t(),c=n(),l=z(await K(`/api/yuri/assistants/${encodeURIComponent(e)}/share`,q(`POST`,{operationID:r,payload:{messageID:i,parts:a,source:o}})));return J(s,c),l},dt=async(e,r=t(),i=n())=>{J(r,i);let a=z(await K(`/api/yuri/assistants/share-operations/${encodeURIComponent(e)}`));return J(r,i),a},ft=async(e,r=t(),i=n())=>{let a=e;for(let e=0;e<60&&(a.state===`running`||a.state===`submitting`);e+=1)J(r,i),await new Promise(e=>setTimeout(e,750)),a=await dt(a.operationID,r,i);if(J(r,i),a.state===`completed`)return a;throw a.state===`failed`?new y(a.errorCode??`share_failed`,400,a):new y(`share_unresolved`,408,a)},pt=async e=>{let n=t(),r=F(await K(`/api/yuri/assistants`,q(`POST`,{...e,language:d.getState().locale})));return Ae(r,n),r},mt=async(e,r)=>{let i=t(),a=n(),o=F(await K(`/api/yuri/assistants/${encodeURIComponent(e.id)}`,q(`PATCH`,{...r,expectedRevision:e.revision})));return J(i,a),r.pinned===void 0?Ae(o,i):(await c.cancelQueries({queryKey:G.snapshot(i),exact:!0}),J(i,a),await c.fetchQuery(Y(i)),J(i,a)),o},ht=async e=>{await K(`/api/yuri/assistants/${encodeURIComponent(e.id)}`,q(`DELETE`,{expectedRevision:e.revision})),await c.invalidateQueries({queryKey:G.snapshot(t())})},gt=async()=>O(await K(`/api/yuri/assistants/capability`)),_t=async(e,r)=>{let i=t(),a=n(),o=M(r);try{let t=P(await K(`/api/yuri/assistants/${encodeURIComponent(e)}/contact/read`,{...q(`POST`,o),signal:AbortSignal.timeout(15e3)}));if(J(i,a),t.assistantID!==e)throw new _(`invalid_assistant_read_response`,200);return t}finally{t()===i&&n()===a&&c.invalidateQueries({queryKey:G.snapshot(i),exact:!0})}},vt=async e=>{let r=e.assistants.filter(e=>(e.unreadCount??0)>0&&e.readTip).map(e=>({id:e.id,position:{...e.readTip}})),i=t(),a=n(),o=[];for(let e=0;e<r.length;e+=4)o.push(...await Promise.allSettled(r.slice(e,e+4).map(async e=>(J(i,a),_t(e.id,e.position)))));return{failed:o.filter(e=>e.status===`rejected`).length}};function yt(e){return e.state.data&&$e(e.state.data)?2500:15e3}var $=i();function bt(e){let t=(0,g.c)(33),{title:n,subtitle:r,backAriaLabel:i,onBack:a,backDisabled:o,actions:s,trailing:c,sticky:d,overlay:f,elevated:p,collapsible:h}=e,_=o!==void 0&&o,v;t[0]===s?v=t[1]:(v=s===void 0?[]:s,t[0]=s,t[1]=v);let y=v,b=d!==void 0&&d,x=f!==void 0&&f,S=p!==void 0&&p,C=h!==void 0&&h,w=Array.isArray(c)?c.filter(Boolean).length:+!!c,T=S||y.some(St),E=C?`true`:void 0,D=b&&`yuri-mobile-detail-navigation-sticky`,O=x&&`absolute inset-x-0 top-0`,k=T?`z-[60]`:x?`z-30`:void 0,A;t[2]!==O||t[3]!==k||t[4]!==D?(A=l(`yuri-mobile-detail-navigation relative shrink-0 pt-[max(0.25rem,var(--yuri-safe-area-top,0px))]`,D,O,k),t[2]=O,t[3]=k,t[4]=D,t[5]=A):A=t[5];let j=y.length+w>1?`grid-cols-[2.75rem_minmax(0,1fr)_auto]`:`grid-cols-[2.75rem_minmax(0,1fr)_2.75rem]`,M;t[6]===j?M=t[7]:(M=l(`yuri-mobile-detail-navigation-content grid items-center gap-1 px-4`,j),t[6]=j,t[7]=M);let N;t[8]!==i||t[9]!==_||t[10]!==a?(N=a?(0,$.jsx)(u,{type:`button`,variant:`mobileGlass`,size:`mobileIcon`,className:`justify-self-start`,onClick:a,disabled:_,"aria-label":i,children:(0,$.jsx)(m,{name:`arrow-left-s`,className:`size-5`})}):(0,$.jsx)(`span`,{"aria-hidden":`true`}),t[8]=i,t[9]=_,t[10]=a,t[11]=N):N=t[11];let P;t[12]===n?P=t[13]:(P=(0,$.jsx)(`div`,{className:`yuri-mobile-detail-title w-full truncate typography-ui-label font-medium text-foreground`,children:n}),t[12]=n,t[13]=P);let F;t[14]===r?F=t[15]:(F=r?(0,$.jsx)(`div`,{className:`yuri-mobile-detail-subtitle w-full truncate text-muted-foreground`,"aria-live":`polite`,children:r}):null,t[14]=r,t[15]=F);let I;t[16]!==P||t[17]!==F?(I=(0,$.jsxs)(`div`,{className:`flex w-full max-w-72 min-w-0 flex-col items-center justify-center justify-self-center px-1`,children:[P,F]}),t[16]=P,t[17]=F,t[18]=I):I=t[18];let L;t[19]===y?L=t[20]:(L=y.map(xt),t[19]=y,t[20]=L);let R;t[21]!==L||t[22]!==c?(R=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-end gap-2`,children:[c,L]}),t[21]=L,t[22]=c,t[23]=R):R=t[23];let z;t[24]!==M||t[25]!==N||t[26]!==I||t[27]!==R?(z=(0,$.jsxs)(`div`,{className:M,children:[N,I,R]}),t[24]=M,t[25]=N,t[26]=I,t[27]=R,t[28]=z):z=t[28];let B;return t[29]!==A||t[30]!==z||t[31]!==E?(B=(0,$.jsx)(`header`,{"data-yuri-collapsible-header":E,className:A,children:z}),t[29]=A,t[30]=z,t[31]=E,t[32]=B):B=t[32],B}function xt(e,t){return(0,$.jsx)(u,{type:`button`,variant:`mobileGlass`,size:`mobileIcon`,className:l(e.elevated&&`relative z-[60]`),onClick:e.onClick,disabled:e.disabled,"aria-label":e.ariaLabel,"aria-expanded":e.pressed,title:e.title,children:(0,$.jsx)(m,{name:e.icon,className:`size-5`})},`${e.icon}:${t}`)}function St(e){return e.elevated}export{le as A,ft as C,ce as D,ue as E,y as M,v as N,se as O,et as S,pe as T,Xe as _,ht as a,Be as b,ot as c,it as d,lt as f,qe as g,rt as h,pt as i,_ as j,de as k,vt as l,mt as m,Ke as n,at as o,ut as p,Je as r,gt as s,bt as t,_t as u,Ie as v,me as w,Qe as x,Re as y};