@yuriai/web 0.2.31 → 0.2.32-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (201) hide show
  1. package/README.md +19 -0
  2. package/dist/assets/{AgentAvatar-DLAQkFQe.js → AgentAvatar-DLzcNrQ0.js} +1 -1
  3. package/dist/assets/AssistantContactStatus-Bf1yg0yx.js +3 -0
  4. package/dist/assets/{AssistantUnreadBadge-BynxNQMk.js → AssistantUnreadBadge-BUFyxUrT.js} +1 -1
  5. package/dist/assets/{AssistantView-CDZyA9ft.js → AssistantView-CELFybSr.js} +1 -1
  6. package/dist/assets/{DiagramView-DdVFGHQQ.js → DiagramView-DV4P3-Wg.js} +1 -1
  7. package/dist/assets/{FadeInOnReveal-C9a7XnAh.js → FadeInOnReveal-BRrU2ivL.js} +1 -1
  8. package/dist/assets/{GuiPluginSurface-v8r-Hex5.js → GuiPluginSurface-NOHaJGy2.js} +1 -1
  9. package/dist/assets/{GuiPluginWindow-Ba1HfrjQ.js → GuiPluginWindow-BykPaQeY.js} +1 -1
  10. package/dist/assets/Icon-OJf0qBKf.js +1 -0
  11. package/dist/assets/{ImageLoadingPlaceholder-Dcy5lc7F.js → ImageLoadingPlaceholder-DlQbo9CM.js} +1 -1
  12. package/dist/assets/{LoadingImage-BxjJ_Xyj.js → LoadingImage-sZ5omN5L.js} +1 -1
  13. package/dist/assets/MarkdownRenderer-BFR9FWQL.js +2 -0
  14. package/dist/assets/MarkdownRendererImpl-iZFUMI3M.js +10 -0
  15. package/dist/assets/{MarkstreamRendererImpl-EpBnVy9J.css → MarkstreamRendererImpl-C6aiJnjl.css} +1 -1
  16. package/dist/assets/MarkstreamRendererImpl-DjC_Y4LS.js +3 -0
  17. package/dist/assets/{MobileDetailNavigation-o54juFXD.js → MobileDetailNavigation-BOZpHdI2.js} +1 -1
  18. package/dist/assets/{MobileResizableSheet-sV9XR-0k.js → MobileResizableSheet-DuAi_epR.js} +1 -1
  19. package/dist/assets/{MobileShareBridge-oqBZ_f6M.js → MobileShareBridge-D1DrqLWf.js} +1 -1
  20. package/dist/assets/MobileTabPageHeader-BT9gWugr.js +2 -0
  21. package/dist/assets/{MultiRunWindow-7W_86vL6.js → MultiRunWindow-C0GYNaUU.js} +1 -1
  22. package/dist/assets/{OnboardingScreen-CnkijSLE.js → OnboardingScreen-CqsI0632.js} +1 -1
  23. package/dist/assets/{OverlayScrollbar-CCtBTJQj.js → OverlayScrollbar-CZD1yU06.js} +1 -1
  24. package/dist/assets/SettingsView-BYO8LY5A.js +29 -0
  25. package/dist/assets/{SettingsWindow-C0HiNvXh.js → SettingsWindow-CM0Ph9WD.js} +1 -1
  26. package/dist/assets/SetupTourDialog-BYlSBPKZ.js +1 -0
  27. package/dist/assets/SetupTourDialog-DrL_4ODI.css +1 -0
  28. package/dist/assets/{TerminalView-y36H_fIe.js → TerminalView-DnyEAShU.js} +1 -1
  29. package/dist/assets/{ToolOutputDialog-BfjBeqGS.js → ToolOutputDialog-BWONfWze.js} +1 -1
  30. package/dist/assets/{VoiceSettings-BONwzGgR.js → VoiceSettings-Ru_0ySgM.js} +2 -2
  31. package/dist/assets/{YuriLogo-BA5FWp-g.js → YuriLogo-CMUoGUHc.js} +1 -1
  32. package/dist/assets/YuriWordmark-DHYo0FlR.js +1 -0
  33. package/dist/assets/{appThemeRegistry-BsLMp3bc.js → appThemeRegistry-BMlAlm0m.js} +1 -1
  34. package/dist/assets/{button-CBjOhOI0.js → button-C-gRcs_2.js} +1 -1
  35. package/dist/assets/{capgoAdapter-DjlyVxy_.js → capgoAdapter-GdNfjwXs.js} +1 -1
  36. package/dist/assets/checkbox-BrJBzET8.js +1 -0
  37. package/dist/assets/{collapsible-B0j5IQ0T.js → collapsible-B7esGYLd.js} +1 -1
  38. package/dist/assets/{context-menu-C4e_bpls.js → context-menu-DWn1nSZC.js} +1 -1
  39. package/dist/assets/desktopHosts-BLU1tGSX.js +1 -0
  40. package/dist/assets/{desktopRelayRestore-AE3_TnQz.js → desktopRelayRestore-2BIIs8mZ.js} +1 -1
  41. package/dist/assets/{diagram-WPmk0Qh6.js → diagram-Bnra5_6g.js} +1 -1
  42. package/dist/assets/{dialog-Dx3IT7dQ.js → dialog-3UseH0hM.js} +1 -1
  43. package/dist/assets/{es-JU--16Gd.js → es-J7a_sZ1u.js} +2 -2
  44. package/dist/assets/{fileMentionTouchSelection-Bizsisaj.js → fileMentionTouchSelection-ByaQJcTS.js} +1 -1
  45. package/dist/assets/{fr-BUZcRuMk.js → fr-BYxUMKWp.js} +2 -2
  46. package/dist/assets/{gitApi-CNgEj6X5.js → gitApi-BdwvoQFb.js} +1 -1
  47. package/dist/assets/historyImportQueries-C8VK9R5_.js +1 -0
  48. package/dist/assets/host-z9PU8q1e.js +1 -0
  49. package/dist/assets/{input-CEJGM-TS.js → input-CmLlZdeD.js} +1 -1
  50. package/dist/assets/insertionBoundaries-BpQ6nLjP.js +1 -0
  51. package/dist/assets/{ja-BwtVLTXD.js → ja-DCdBiJmD.js} +2 -2
  52. package/dist/assets/{ko--sLsRFpA.js → ko-D-Nb_RJY.js} +2 -2
  53. package/dist/assets/main-Dosy2jXg.js +2 -0
  54. package/dist/assets/main-oBh-dk5-.js +169 -0
  55. package/dist/assets/{markdownHeightCache-D6iSNJG2.js → markdownHeightCache-xNkQdlqi.js} +1 -1
  56. package/dist/assets/{mcpQueries-DVSsZeuk.js → mcpQueries-C8zsTQqJ.js} +1 -1
  57. package/dist/assets/miniChat-CI8ryDGT.js +2 -0
  58. package/dist/assets/mobile-e_mTK3dh.js +2 -0
  59. package/dist/assets/{mobileBackNavigation-Dmbf0kw1.js → mobileBackNavigation-sB7c0Pi4.js} +1 -1
  60. package/dist/assets/multirun-DbmgWrsY.js +3 -0
  61. package/dist/assets/{native-config-BaRHaY4y.js → native-config-C_mwkFzh.js} +1 -1
  62. package/dist/assets/{pl-C4_4J5yA.js → pl-AmU4w3aM.js} +2 -2
  63. package/dist/assets/{projectMeta-rrpZdm8D.js → projectMeta-1iUbVl_M.js} +1 -1
  64. package/dist/assets/{pt-BR-DvNC5K1q.js → pt-BR-BI4ft-Fj.js} +2 -2
  65. package/dist/assets/pwa-BdUAGhLt.js +2 -0
  66. package/dist/assets/{queue-abort-optimistic-CSkERbr4.js → queue-abort-optimistic-BwDsaym5.js} +1 -1
  67. package/dist/assets/react-a6PrrNTm.js +1 -0
  68. package/dist/assets/{readiness-BnO7IaZV.js → readiness-D2N0DtZF.js} +1 -1
  69. package/dist/assets/{renderElectronMiniChatApp-Bq3iNKtr.js → renderElectronMiniChatApp-DV0cNt_O.js} +2 -2
  70. package/dist/assets/{renderMobileApp-DiNeMgwp.js → renderMobileApp-b7--jT5z.js} +7 -7
  71. package/dist/assets/{runtimeConfig-BHOiBANF.js → runtimeConfig-DxmJLWUO.js} +1 -1
  72. package/dist/assets/runtimeEndpointReset-jYAYa3Rh.js +149 -0
  73. package/dist/assets/{select-bKMw5JE8.js → select-J8r9SxHt.js} +1 -1
  74. package/dist/assets/sessionLookup-CUQqj2N4.js +1 -0
  75. package/dist/assets/{sortable-tabs-strip-3sKiA7T1.js → sortable-tabs-strip-CiP6RIQa.js} +1 -1
  76. package/dist/assets/{speechSettingsQueries-BDDxw8LP.js → speechSettingsQueries-B3ziGQvb.js} +1 -1
  77. package/dist/assets/src-GtPQ8f4o.css +2 -0
  78. package/dist/assets/{store-X3lU0obe.js → store-OjrIiXCx.js} +5 -5
  79. package/dist/assets/{textarea-EsaDD051.js → textarea-BHgcxJdC.js} +1 -1
  80. package/dist/assets/{tooltip-LLDL5nIZ.js → tooltip-Degmpxnd.js} +1 -1
  81. package/dist/assets/tour-DDI0Zg7l.js +1 -0
  82. package/dist/assets/types-QETHY-S7.js +2 -0
  83. package/dist/assets/{uk-Dvj0JjiC.js → uk-CbdByxxj.js} +2 -2
  84. package/dist/assets/{useAppFontEffects-wIWWE59b.js → useAppFontEffects-LADr3Zl1.js} +53 -53
  85. package/dist/assets/useDesktopWindowControlsLayout-BVNnRHtc.js +1 -0
  86. package/dist/assets/{useDictation-DlEHSN6P.js → useDictation-DFVJpRbm.js} +1 -1
  87. package/dist/assets/{useEffectiveDirectory-DzqpWUC3.js → useEffectiveDirectory-8tqfGdV5.js} +1 -1
  88. package/dist/assets/{useMobileNavigationStore-BWLhXqci.js → useMobileNavigationStore-CLUFv-TZ.js} +13 -13
  89. package/dist/assets/usePluginsStore-B_SIDwsK.js +1 -0
  90. package/dist/assets/useStreamingTextThrottle-VhgGU_te.js +1 -0
  91. package/dist/assets/{useWorkerHighlightedLines-DMS69wKa.js → useWorkerHighlightedLines-jlxakDGs.js} +1 -1
  92. package/dist/assets/{vendor-markstream-react-DfLaSG3W.js → vendor-markstream-react-6zxyQLCD.js} +1 -1
  93. package/dist/assets/{zh-CN-2Y6u8t24.js → zh-CN-ufEVDbXp.js} +2 -2
  94. package/dist/assets/{zh-TW-Z5wVv4Fb.js → zh-TW-DTBlZ4YC.js} +2 -2
  95. package/dist/index.html +8 -8
  96. package/dist/mini-chat.html +8 -8
  97. package/dist/mobile.html +8 -8
  98. package/package.json +1 -1
  99. package/server/index.js +3 -0
  100. package/server/lib/client-auth/pairing.js +2 -0
  101. package/server/lib/client-auth/pairing.test.js +29 -0
  102. package/server/lib/config-sync/DOCUMENTATION.md +8 -4
  103. package/server/lib/config-sync/index.js +1 -1
  104. package/server/lib/config-sync/magpie-auth.js +10 -4
  105. package/server/lib/config-sync/magpie-auth.test.js +4 -0
  106. package/server/lib/config-sync/magpie.js +28 -22
  107. package/server/lib/config-sync/magpie.test.js +127 -2
  108. package/server/lib/config-sync/plugins.js +44 -0
  109. package/server/lib/config-sync/plugins.test.js +64 -0
  110. package/server/lib/config-sync/tar.js +61 -1
  111. package/server/lib/content-search/DOCUMENTATION.md +9 -0
  112. package/server/lib/content-search/routes.js +18 -1
  113. package/server/lib/content-search/routes.test.js +21 -0
  114. package/server/lib/content-search/runtime.js +7 -3
  115. package/server/lib/content-search/runtime.test.js +26 -0
  116. package/server/lib/gui-customization/DOCUMENTATION.md +21 -1
  117. package/server/lib/gui-customization/session-skill.js +2 -2
  118. package/server/lib/gui-customization/session-skill.test.js +3 -1
  119. package/server/lib/gui-customization/skill/SKILL.md +5 -1
  120. package/server/lib/gui-customization/skill/references/global-pages.md +1 -1
  121. package/server/lib/gui-customization/skill/references/gui-api.md +4 -1
  122. package/server/lib/gui-customization/skill/references/icons.md +134 -0
  123. package/server/lib/gui-customization/skill/references/plugin-styles.md +112 -0
  124. package/server/lib/gui-customization/skill/references/ui-surfaces.md +2 -0
  125. package/server/lib/gui-customization/skill/references/work-status.md +110 -0
  126. package/server/lib/history-import/AGENT_CONNECT_LICENSE +21 -0
  127. package/server/lib/history-import/DOCUMENTATION.md +223 -0
  128. package/server/lib/history-import/dev-proxy.integration.test.js +56 -0
  129. package/server/lib/history-import/events.js +322 -0
  130. package/server/lib/history-import/events.test.js +110 -0
  131. package/server/lib/history-import/installations.js +39 -0
  132. package/server/lib/history-import/installations.test.js +24 -0
  133. package/server/lib/history-import/native.js +49 -0
  134. package/server/lib/history-import/native.test.js +42 -0
  135. package/server/lib/history-import/routes.js +48 -0
  136. package/server/lib/history-import/routes.test.js +55 -0
  137. package/server/lib/history-import/service.js +374 -0
  138. package/server/lib/history-import/service.test.js +538 -0
  139. package/server/lib/history-import/settings.js +146 -0
  140. package/server/lib/history-import/settings.test.js +88 -0
  141. package/server/lib/history-import/sources.js +184 -0
  142. package/server/lib/history-import/sources.test.js +190 -0
  143. package/server/lib/history-import/sqlite.js +187 -0
  144. package/server/lib/history-import/store.js +58 -0
  145. package/server/lib/history-import/store.test.js +84 -0
  146. package/server/lib/history-import/targets.js +24 -0
  147. package/server/lib/host-update/DOCUMENTATION.md +6 -0
  148. package/server/lib/host-update/routes.test.js +1 -1
  149. package/server/lib/notifications/native-stream.relay.test.js +1 -0
  150. package/server/lib/opencode/DOCUMENTATION.md +14 -0
  151. package/server/lib/opencode/core-routes.js +1 -0
  152. package/server/lib/opencode/feature-routes-runtime.js +11 -1
  153. package/server/lib/opencode/plugin-routes.test.js +1 -0
  154. package/server/lib/opencode/plugins.js +1 -1
  155. package/server/lib/opencode/plugins.test.js +3 -2
  156. package/server/lib/opencode/proxy.js +29 -4
  157. package/server/lib/opencode/proxy.test.js +85 -1
  158. package/server/lib/opencode/server-utils-runtime.js +2 -0
  159. package/server/lib/opencode/settings-runtime.js +8 -6
  160. package/server/lib/opencode/settings-runtime.test.js +44 -0
  161. package/server/lib/opencode/yuri-routes.js +1 -1
  162. package/server/lib/relay/DOCUMENTATION.md +1 -1
  163. package/server/lib/relay/host-client.js +3 -1
  164. package/server/lib/relay/host-client.test.js +1 -0
  165. package/server/lib/relay/reasoning-projection.e2e.test.ts +1 -0
  166. package/server/lib/relay/relay-server.e2e.test.ts +32 -17
  167. package/server/lib/relay/service.js +2 -0
  168. package/server/lib/relay/tunnel-host.js +26 -1
  169. package/server/lib/relay/tunnel-host.test.js +27 -3
  170. package/server/lib/remote-desktop/runtime.test.js +2 -2
  171. package/server/lib/ui-auth/DOCUMENTATION.md +3 -0
  172. package/server/lib/ui-auth/ui-auth.js +27 -0
  173. package/server/lib/ui-auth/ui-auth.test.js +42 -1
  174. package/server/plugin-gui-proxy.test.js +1 -1
  175. package/dist/assets/AssistantContactStatus-DZGGspw4.js +0 -3
  176. package/dist/assets/Icon-Bh3TaKoN.js +0 -1
  177. package/dist/assets/MarkdownRenderer-CS6Pia5D.js +0 -2
  178. package/dist/assets/MarkdownRendererImpl-Bdwe3qUr.js +0 -10
  179. package/dist/assets/MarkstreamRendererImpl-CCQj9IkL.js +0 -3
  180. package/dist/assets/MobileTabPageHeader-CptcDWNS.js +0 -2
  181. package/dist/assets/SettingsView-CkJpYIMe.js +0 -29
  182. package/dist/assets/SetupTourDialog-BcEbaEO3.js +0 -1
  183. package/dist/assets/SetupTourDialog-CUzqT2sw.css +0 -1
  184. package/dist/assets/YuriWordmark-Cr1vkcue.js +0 -1
  185. package/dist/assets/desktopHosts-CMglnUdS.js +0 -1
  186. package/dist/assets/host-CBfSyi4l.js +0 -1
  187. package/dist/assets/insertionBoundaries-CgYf6gys.js +0 -1
  188. package/dist/assets/main-B8FcBwPM.js +0 -169
  189. package/dist/assets/main-DrqtyqDc.js +0 -2
  190. package/dist/assets/miniChat-CgeCl4RY.js +0 -2
  191. package/dist/assets/mobile-DAhJKHUq.js +0 -2
  192. package/dist/assets/multirun-BbWnHeaY.js +0 -3
  193. package/dist/assets/pwa-Dm_DJEr9.js +0 -2
  194. package/dist/assets/react-Bwr5-XPi.js +0 -1
  195. package/dist/assets/runtimeEndpointReset-DGxT24oE.js +0 -149
  196. package/dist/assets/sessionLookup-DGNxfDsP.js +0 -1
  197. package/dist/assets/src-PTWgTO6W.css +0 -2
  198. package/dist/assets/tour-Db44qwfs.js +0 -1
  199. package/dist/assets/types-Cl7nTpsb.js +0 -2
  200. package/dist/assets/useDesktopWindowControlsLayout-CdUr9mCZ.js +0 -1
  201. package/dist/assets/usePluginsStore-aZl0WTK8.js +0 -1
@@ -1,10 +0,0 @@
1
- import{n as e,r as t}from"./rolldown-runtime-hePW80VL.js";import{i as n}from"./runtime-switch-DEZ1K7qW.js";import{T as r}from"./desktop-BAmoc_34.js";import{ot as i,st as a}from"./vendor-base-ui-CzHs0bHY.js";import{r as o}from"./useUIStore-BerIUSLP.js";import{n as s}from"./vendor-react-DlzBev0S.js";import{u as c}from"./fileQueries-C2Rs6TPz.js";import{t as l}from"./platform-sEg2IOLZ.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-CBjOhOI0.js";import{Vn as _}from"./useMobileNavigationStore-BWLhXqci.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-DzqpWUC3.js";import{a as T,i as E,t as D}from"./image-loading-DKQOYtti.js";import{c as O,i as k,l as te,n as ne,o as A,r as re}from"./FadeInOnReveal-C9a7XnAh.js";import{i as ie,r as j,t as ae}from"./markdownHeightCache-D6iSNJG2.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-COS3jfbf.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
- `)),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
- `)),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
- `).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
- `||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))},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
- `)?n.split(`
8
- `).length-1:n.split(`
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(!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};
@@ -1,3 +0,0 @@
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-BerIUSLP.js";import{n as i}from"./vendor-react-DlzBev0S.js";import{u as a}from"./fileQueries-C2Rs6TPz.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-CBjOhOI0.js";import{Vn as g}from"./useMobileNavigationStore-BWLhXqci.js";import{t as _}from"./useThemeSystem-CNzUUkFn.js";import{i as v,n as y,t as b}from"./tooltip-LLDL5nIZ.js";import{a as x,r as S}from"./url-MRa-FtQa.js";import{n as C}from"./useEffectiveDirectory-DzqpWUC3.js";import{o as w}from"./image-loading-DKQOYtti.js";import{t as T}from"./LoadingImage-BxjJ_Xyj.js";import{r as ee,t as E}from"./markdownHeightCache-D6iSNJG2.js";import{r as D,t as O}from"./MarkdownRendererImpl-Bdwe3qUr.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-COS3jfbf.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,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js","assets/rolldown-runtime-hePW80VL.js"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,i as n,n as r,o as i}from"./runtime-switch-DEZ1K7qW.js";import{n as a}from"./runtime-fetch-D0YWp3FJ.js";import{C as o,D as s,E as c,O as l,R as u,S as d,T as f,a as p,r as m,x as h}from"./desktop-BAmoc_34.js";import{t as g}from"./runtimeAPIRegistry-C2VogTny.js";import{a as _,i as v,r as y}from"./vendor-zustand-vDaAPGfl.js";import{at as b,c as x,l as S,ot as C,st as w}from"./vendor-base-ui-CzHs0bHY.js";import{At as T,bt as E}from"./gitApiHttp-MWsHNHuo.js";import{r as D,x as O}from"./useUIStore-BerIUSLP.js";import{o as k,p as A,tt as j}from"./bootstrap-C8paoQ0j.js";import{n as M}from"./vendor-react-DlzBev0S.js";import{l as N,n as P,o as F,s as I}from"./vendor-tanstack-react-query-B-Wpqq5J.js";import{a as L,o as R,r as z,t as ee}from"./queryRuntime-2dx7jbt9.js";import{o as te}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{n as B}from"./pathNormalization-ewtPqJWn.js";import{n as V,t as ne}from"./platform-sEg2IOLZ.js";import{a as H,t as re}from"./types-Cl7nTpsb.js";import{B as U,E as ie,F as W,G as ae,K as oe,R as se,U as ce,V as le,W as ue,X as de,Y as fe,Z as pe,a as me,f as he,g as ge,ht as _e,j as ve,l as ye,lt as be,mt as xe,pt as Se,st as G,tt as Ce}from"./vendor-codemirror-autocomplete-C0FrlFqZ.js";import{c as we,o as K,r as Te}from"./vendor-codemirror-lang-angular-Cm7vBE3E.js";import{n as Ee,r as De}from"./vendor-codemirror-lang-json-DowyFczU.js";import{n as Oe}from"./vendor-codemirror-lang-markdown-npWBZIoE.js";import{n as ke}from"./vendor-codemirror-lang-python-OPRdU26g.js";import{O as Ae}from"./vendor-codemirror-legacy-modes-DwltVFbT.js";import{i as je}from"./vendor-reactuses-core-DWo5Wn6R.js";import{a as Me,d as Ne,f as Pe,p as Fe,r as q,t as J}from"./button-CBjOhOI0.js";import{Cr as Ie,Hr as Le,Oi as Re,Qr as ze,Sr as Be,St as Ve,Ui as He,Yi as Ue,Yr as We,_a as Ge,br as Ke,fa as qe,gr as Je,la as Ye,ni as Y,p as Xe,tn as Ze,tr as Qe,vr as $e,yr as et}from"./useMobileNavigationStore-BWLhXqci.js";import{t as tt}from"./AgentAvatar-DLAQkFQe.js";import{n as nt}from"./useThemeSystem-CNzUUkFn.js";import{n as X,r as rt}from"./Icon-Bh3TaKoN.js";import{a as it,n as at,o as ot,r as st,t as ct}from"./dialog-Dx3IT7dQ.js";import{L as lt,_ as ut,b as dt,c as ft,n as pt,s as mt,u as ht}from"./gitApi-CNgEj6X5.js";import{t as gt}from"./input-CEJGM-TS.js";import{i as _t,n as vt,t as yt}from"./tooltip-LLDL5nIZ.js";import{Bt as bt,E as xt,H as St,It as Ct,J as wt,L as Tt,Lt as Et,M as Dt,R as Ot,Rt as kt,V as At,Vt as jt,Wt as Mt,X as Nt,Y as Pt,Yt as Ft,Z as It,h as Lt,j as Rt,k as zt,n as Bt,nt as Vt,z as Ht,zt as Ut}from"./pwa-Dm_DJEr9.js";import{r as Wt,t as Gt}from"./device-w1ioiqv3.js";import{t as Kt}from"./MobileResizableSheet-sV9XR-0k.js";import{c as qt,d as Jt,i as Yt,n as Xt,s as Zt,t as Qt}from"./select-bKMw5JE8.js";import{n as $t}from"./MarkdownRenderer-CS6Pia5D.js";import{a as en}from"./url-MRa-FtQa.js";import{i as tn}from"./react-Bwr5-XPi.js";import{n as nn,t as rn}from"./textarea-EsaDD051.js";import{a as an,c as on,h as sn,m as cn,n as ln,r as un,t as dn}from"./projectMeta-rrpZdm8D.js";import{r as fn}from"./markdown-worker-oBGEB9Eg.js";import{i as pn,n as mn,o as hn}from"./mcpQueries-DVSsZeuk.js";import{d as gn,g as _n,h as vn,u as yn,v as bn}from"./usePluginsStore-aZl0WTK8.js";import{n as xn,r as Sn,t as Cn}from"./collapsible-B0j5IQ0T.js";import{a as wn,d as Tn,o as En,s as Dn}from"./vendor-codemirror-commands-5saeUOVY.js";import{a as On,c as kn,i as An,l as jn,o as Mn,r as Nn,s as Pn}from"./vendor-codemirror-search-hZY-L2l8.js";import{n as Fn,t as In}from"./vendor-replit-codemirror-vim-BmQmU1lR.js";import{t as Ln}from"./vendor-codemirror-language-data-B3pLWvv-.js";import{i as Rn,n as zn,r as Bn,t as Vn}from"./projectActions-BX0cjZoq.js";var Hn=[{id:`claude`,name:`Claude`},{id:`codex`,name:`Codex`},{id:`cursor`,name:`Cursor`},{id:`github-copilot`,name:`GitHub Copilot`},{id:`google`,name:`Google`},{id:`kimi-for-coding`,name:`Kimi for Coding`},{id:`nano-gpt`,name:`NanoGPT`},{id:`openrouter`,name:`OpenRouter`},{id:`zai-coding-plan`,name:`z.ai`},{id:`zhipuai-coding-plan`,name:`Zhipu AI Coding Plan`},{id:`minimax-cn-coding-plan`,name:`MiniMax Coding Plan (minimaxi.com)`},{id:`minimax-coding-plan`,name:`MiniMax Coding Plan (minimax.io)`},{id:`ollama-cloud`,name:`Ollama Cloud`},{id:`wafer`,name:`Wafer.ai`},{id:`opencode-go`,name:`OpenCode Go`},{id:`xai`,name:`Grok`}],Un=e=>[...Hn,...e.filter(e=>e.source===`magpie`).map(e=>({id:e.providerId,name:e.providerName}))],Z=M(),Q=C();function Wn(e){let t=(0,Z.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Q.jsx)(`path`,{d:`M15.688 2.343a2.588 2.588 0 00-3.61 0l-9.626 9.44a.863.863 0 01-1.203 0 .823.823 0 010-1.18l9.626-9.44a4.313 4.313 0 016.016 0 4.116 4.116 0 011.204 3.54 4.3 4.3 0 013.609 1.18l.05.05a4.115 4.115 0 010 5.9l-8.706 8.537a.274.274 0 000 .393l1.788 1.754a.823.823 0 010 1.18.863.863 0 01-1.203 0l-1.788-1.753a1.92 1.92 0 010-2.754l8.706-8.538a2.47 2.47 0 000-3.54l-.05-.049a2.588 2.588 0 00-3.607-.003l-7.172 7.034-.002.002-.098.097a.863.863 0 01-1.204 0 .823.823 0 010-1.18l7.273-7.133a2.47 2.47 0 00-.003-3.537z`}),r=(0,Q.jsx)(`path`,{d:`M14.485 4.703a.823.823 0 000-1.18.863.863 0 00-1.204 0l-7.119 6.982a4.115 4.115 0 000 5.9 4.314 4.314 0 006.016 0l7.12-6.982a.823.823 0 000-1.18.863.863 0 00-1.204 0l-7.119 6.982a2.588 2.588 0 01-3.61 0 2.47 2.47 0 010-3.54l7.12-6.982z`}),t[0]=n,t[1]=r):(n=t[0],r=t[1]);let i;return t[2]===e?i=t[3]:(i=(0,Q.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,fill:`currentColor`,stroke:`currentColor`,strokeWidth:`0.5`,fillRule:`evenodd`,viewBox:`-0.5 -0.5 25 25`,...e,children:[n,r]}),t[2]=e,t[3]=i),i}var $=e(w(),1),Gn=$.forwardRef((e,t)=>{let n=(0,Z.c)(11),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=q(`peer inline-flex shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-none transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[checked]:bg-primary data-[unchecked]:bg-[var(--interactive-border)]`,r),n[3]=r,n[4]=a);let o;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(o={width:`36px`,height:`20px`,minWidth:`36px`,minHeight:`20px`},n[5]=o):o=n[5];let s;n[6]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Q.jsx)(x,{className:q(`pointer-events-none block rounded-full bg-background shadow-none ring-0 transition-transform data-[checked]:translate-x-4 data-[unchecked]:translate-x-0`),style:{width:`16px`,height:`16px`,minWidth:`16px`,minHeight:`16px`}}),n[6]=s):s=n[6];let c;return n[7]!==i||n[8]!==t||n[9]!==a?(c=(0,Q.jsx)(S,{className:a,style:o,...i,ref:t,children:s}),n[7]=i,n[8]=t,n[9]=a,n[10]=c):c=n[10],c});Gn.displayName=`Switch`;var Kn={},qn=(e,t=n())=>JSON.stringify([t,mn(e)]),Jn=(e,t,n)=>{if(!e[t]?.[n])return e;let r={...e[t]};return delete r[n],{...e,[t]:r}},Yn=e=>{let t=mn(e);return t?T.getScopedApiClient(t):T.getApiClient()},Xn=e=>e?{location:{directory:e}}:void 0,Zn=new Map,Qn=(e,t)=>JSON.stringify([r(),qn(t),e]),$n=async(e,t,n)=>{let r=(await e.mcp.list(Xn(n))).data.find(e=>e.name===t)?.integrationID;if(!r)throw Error(`MCP server "${t}" has no authentication integration`);return(await e.integration.get({integrationID:r,...Xn(n)})).data},er=e=>mn(e===void 0?E.getState().currentDirectory:e),tr=_()(y((e,t)=>({diagnosticsByDirectory:{},getDiagnosticForDirectory:e=>{let n=qn(er(e));return t().diagnosticsByDirectory[n]??Kn},clearDiagnostic:(t,n,r)=>{let i=qn(er(n),r);e(e=>({diagnosticsByDirectory:Jn(e.diagnosticsByDirectory,i,t)}))},connect:async(t,r)=>{let i=er(r),a=n(),o=qn(i,a),s=Yn(i);try{await s.mcp.connect({server:t,...Xn(i)})}catch(n){let r=n instanceof Error?n.message:`Connection failed`;throw e(e=>({diagnosticsByDirectory:{...e.diagnosticsByDirectory,[o]:{...e.diagnosticsByDirectory[o]??{},[t]:{status:`failed`,error:r}}}})),n}await hn(L,i,a),e(e=>({diagnosticsByDirectory:Jn(e.diagnosticsByDirectory,o,t)}))},disconnect:async(t,r)=>{let i=er(r),a=n(),o=qn(i,a);await Yn(i).mcp.disconnect({server:t,...Xn(i)}),await hn(L,i,a),e(e=>({diagnosticsByDirectory:Jn(e.diagnosticsByDirectory,o,t)}))},startAuth:async(e,t)=>{let n=er(t),r=Qn(e,n),i=Yn(n),a=await $n(i,e,n),o=a.methods.find(e=>e.type===`oauth`);if(!o)throw Error(`MCP server "${e}" has no OAuth method`);if(r!==Qn(e,n))throw Error(`MCP authorization runtime changed`);let s=Zn.get(r);if(s&&(await i.integration.oauth.cancel({integrationID:s.integrationID,attemptID:s.attempt.attemptID,...Xn(n)}),Zn.delete(r)),r!==Qn(e,n))throw Error(`MCP authorization runtime changed`);let{data:c}=await i.integration.oauth.connect({integrationID:a.id,methodID:o.id,...Xn(n)});if(r!==Qn(e,n))throw Error(`MCP authorization runtime changed`);for(let[e,t]of Zn)t.attempt.time.expires<=Date.now()&&Zn.delete(e);return Zn.set(r,{integrationID:a.id,attempt:c}),c},authStatus:async(e,t)=>{let n=er(t),r=Qn(e,n),i=Zn.get(r);if(!i)throw Error(`MCP authorization attempt not found`);let{data:a}=await Yn(n).integration.oauth.status({integrationID:i.integrationID,attemptID:i.attempt.attemptID,...Xn(n)});if(r!==Qn(e,n))throw Error(`MCP authorization runtime changed`);return a.status!==`pending`&&Zn.get(r)===i&&Zn.delete(r),a},completeAuth:async(e,t,r)=>{let i=er(r),a=n(),o=Qn(e,i),s=Zn.get(o);if(!s||s.attempt.mode!==`code`)throw Error(`MCP authorization requires the browser callback`);if(!t.trim())throw Error(`MCP authorization code is empty`);if(await Yn(i).integration.oauth.complete({integrationID:s.integrationID,attemptID:s.attempt.attemptID,code:t.trim(),...Xn(i)}),Zn.get(o)===s&&Zn.delete(o),o!==Qn(e,i))throw Error(`MCP authorization runtime changed`);await hn(L,i,a)},clearAuth:async(e,t)=>{let r=er(t),i=n(),a=Qn(e,r),o=Yn(r),s=await $n(o,e,r);if(a!==Qn(e,r))throw Error(`MCP authorization runtime changed`);let c=Zn.get(a);c&&(await o.integration.oauth.cancel({integrationID:c.integrationID,attemptID:c.attempt.attemptID,...Xn(r)}),Zn.delete(a));let l=new Set(s.connections.flatMap(e=>e.type===`credential`?[e.id]:[]));for(let t of l){if(a!==Qn(e,r))throw Error(`MCP authorization runtime changed`);await o.credential.remove({credentialID:t})}if(a!==Qn(e,r))throw Error(`MCP authorization runtime changed`);await hn(L,r,i)},testConnection:async(t,r)=>{let i=er(r),a=n(),o=qn(i,a),s=Yn(i),c=pn(L,i,a)[t]?.status===`connected`,l,u;try{await s.mcp.connect({server:t,...Xn(i)})}catch(n){l=n instanceof Error?n.message:`Connection failed`,e(e=>({diagnosticsByDirectory:{...e.diagnosticsByDirectory,[o]:{...e.diagnosticsByDirectory[o]??{},[t]:{status:`failed`,error:l??`Connection failed`}}}}))}let d=(await hn(L,i,a))[t],f=d;if(!c&&d?.status===`connected`){try{await s.mcp.disconnect({server:t,...Xn(i)})}catch(e){u=`Connection test succeeded, but cleanup disconnect failed: ${e instanceof Error?e.message:`Disconnect failed`}`}await hn(L,i,a)}return l||e(e=>({diagnosticsByDirectory:Jn(e.diagnosticsByDirectory,o,t)})),{status:f??pn(L,i,a)[t],error:l,warning:u}}}))),nr=`https://yuri-updates.xiaobe.top/v1/update/check`,rr=`https://yuri-origin.xiaobe.top/v1/update/check`,ir=`https://github.com/yee94/yuri/releases/latest`,ar=`https://github.com/yee94/yuri/releases`,or=`https://testflight.apple.com/join/pN5SSHeg`,sr=1e4;function cr(e){let t=String(e||``).replace(/^v/,``).split(`+`)[0]??``,n=t.indexOf(`-`);return{parts:(n>=0?t.slice(0,n):t).split(`.`).map(e=>{let t=Number.parseInt(e||`0`,10);return Number.isFinite(t)?t:0}),prerelease:n>=0}}function lr(e,t){let n=cr(e),r=cr(t),i=Math.max(n.parts.length,r.parts.length);for(let e=0;e<i;e+=1){let t=(n.parts[e]||0)-(r.parts[e]||0);if(t!==0)return t}return n.prerelease===r.prerelease?0:n.prerelease?-1:1}function ur(){return[nr,rr]}function dr(e,t,n=Date.now){let r=e-n();return r<=0||t<=0?null:Math.max(1,Math.ceil(r/t))}function fr(e){return{appType:`mobile-capacitor`,deviceClass:e.deviceClass||`mobile`,platform:e.platform===`ios`||e.platform===`android`?e.platform:`android`,arch:e.arch||`unknown`,channel:`stable`,currentVersion:e.currentVersion,instanceMode:`remote`,reportUsage:e.reportUsage===!0}}async function pr(e,t,n,r){try{if(V())try{let{CapacitorHttp:r}=await te(async()=>{let{CapacitorHttp:e}=await import(`./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js`).then(e=>e.i);return{CapacitorHttp:e}},__vite__mapDeps([0,1])),i=Object.fromEntries(new Headers(t.headers).entries()),a;if(typeof t.body==`string`)try{a=JSON.parse(t.body)}catch{a=t.body}let o=await Promise.race([r.request({url:e,method:t.method||`GET`,headers:i,data:a,connectTimeout:n,readTimeout:n}),new Promise(e=>{window.setTimeout(()=>e(null),n)})]);return o?{ok:o.status>=200&&o.status<300,status:o.status,url:typeof o.url==`string`?o.url:e,json:async()=>{if(typeof o.data==`string`)try{return JSON.parse(o.data)}catch{return o.data}return o.data}}:null}catch{}let i=await r(e,{...t,signal:AbortSignal.timeout(n)});return{ok:i.ok,status:i.status,url:i.url,json:()=>i.json()}}catch{return null}}function mr(e,t){return e===`ios`?or:`${ar}/download/v${t}/app-release.apk`}function hr(e,t,n){if(typeof e.latestVersion!=`string`||e.latestVersion.trim().length===0)return null;let r=e.latestVersion.trim(),i=lr(r,t);if(i<0)return null;let a=typeof e.releaseNotesUrl==`string`&&e.releaseNotesUrl.trim().length>0?e.releaseNotesUrl.trim():`${ar}/tag/v${r}`,o=typeof e.downloadUrl==`string`&&e.downloadUrl.trim().length>0?e.downloadUrl.trim():typeof e.download?.url==`string`&&e.download.url.trim().length>0?e.download.url.trim():mr(n,r);return{available:!!e.updateAvailable&&i>0,version:r,currentVersion:t,body:typeof e.releaseNotes==`string`?e.releaseNotes:void 0,releaseUrl:a,downloadUrl:o,nextSuggestedCheckInSec:typeof e.nextSuggestedCheckInSec==`number`&&Number.isFinite(e.nextSuggestedCheckInSec)?e.nextSuggestedCheckInSec:void 0}}async function gr(e,t,n,r){let i=await pr(e,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify(fr(t))},n,r);if(!i?.ok)return null;let a;try{a=await i.json()}catch{return null}return hr(a,t.currentVersion,t.platform)}async function _r(e,t,n,r){let i=await pr(ir,{method:`GET`,headers:{Accept:`text/html`},redirect:`follow`},n,r);if(!i?.ok)return null;let a=typeof i.url==`string`&&i.url.length>0?i.url:ir,o=null;try{o=new URL(a).pathname.match(/\/releases\/tag\/v(\d+\.\d+\.\d+(?:-[\w.]+)?)/)}catch{return null}if(!o?.[1])return null;let s=o[1],c=lr(s,e),l=`${ar}/tag/v${s}`;return{available:c>0,version:s,currentVersion:e,releaseUrl:l,downloadUrl:mr(t,s)}}async function vr(e){let t=e.currentVersion?.trim()||`unknown`;if(t===`unknown`)return{available:!1,currentVersion:t,error:`Unable to check for mobile updates`};let n=e.fetchImpl??fetch,r=e.now??Date.now,i=ur(),a=r()+sr;for(let[t,o]of i.entries()){let s=dr(a,i.length-t+1,r);if(s===null)break;let c=await gr(o,e,s,n);if(c)return c}let o=dr(a,1,r);if(o!==null){let r=await _r(t,e.platform,o,n);if(r)return r}return{available:!1,currentVersion:t,error:`Unable to check for mobile updates`}}function yr(){if(typeof window>`u`)return`unknown`;try{let{deviceType:e}=Gt();return e}catch{return`unknown`}}function br(){let e=typeof window<`u`?window.__VSCODE_CONFIG__?.arch?.toLowerCase?.():void 0;if(e===`arm64`||e===`aarch64`)return`arm64`;if(e===`x64`||e===`amd64`||e===`x86_64`)return`x64`;let t=(typeof navigator<`u`?navigator.userAgentData:void 0)?.architecture?.toLowerCase?.();if(t===`arm`||t===`arm64`||t===`aarch64`)return`arm64`;if(t===`x86`||t===`x64`||t===`amd64`)return`x64`;let n=typeof navigator<`u`?navigator.userAgent.toLowerCase():``;return n.includes(`aarch64`)||n.includes(`arm64`)||n.includes(`armv`)?`arm64`:n.includes(`x86_64`)||n.includes(`x64`)||n.includes(`amd64`)||n.includes(`win64`)?`x64`:`unknown`}function xr(){let e=ne();if(e===`android`||e===`ios`)return e;if(typeof navigator>`u`)return`web`;let t=(navigator.platform||``).toLowerCase();return t.includes(`mac`)?`macos`:t.includes(`win`)?`windows`:t.includes(`linux`)?`linux`:`web`}function Sr(e){let t=D.getState().reportUsage,n=new URLSearchParams({reportUsage:t?`true`:`false`});return n.set(`deviceClass`,yr()),n.set(`arch`,br()),n.set(`platform`,xr()),e===`desktop`?(n.set(`appType`,`desktop-electron`),n.set(`instanceMode`,h()?`local`:`remote`),n):e===`vscode`?(n.set(`appType`,`vscode`),n.set(`instanceMode`,`local`),n):e===`mobile`?(n.set(`appType`,`mobile-capacitor`),n.set(`instanceMode`,`remote`),n):(n.set(`appType`,`web`),n.set(`instanceMode`,`unknown`),n)}async function Cr(e,t){let n=t??`unknown`;try{let r=Sr(e),i=typeof window<`u`?window.__VSCODE_CONFIG__?.extensionVersion:void 0;t?r.set(`currentVersion`,t):e===`vscode`&&i&&r.set(`currentVersion`,i);let o=await a(`/api/yuri/update-check?${r.toString()}`,{method:`GET`,headers:{Accept:`application/json`}}),s=null;try{s=await o.json()}catch{s=null}if(!o.ok)return{available:!1,currentVersion:n,error:typeof s?.error==`string`&&s.error.trim().length>0?s.error.trim():`Server responded with ${o.status}`};if(!s)return{available:!1,currentVersion:n,error:`Update check returned an invalid response`};let c=typeof s.error==`string`&&s.error.trim().length>0?s.error.trim():void 0;return{available:s.available===!0,version:typeof s.version==`string`?s.version:void 0,currentVersion:typeof s.currentVersion==`string`?s.currentVersion:n,body:typeof s.body==`string`?s.body:void 0,releaseUrl:typeof s.releaseUrl==`string`?s.releaseUrl:void 0,downloadUrl:typeof s.downloadUrl==`string`?s.downloadUrl:void 0,nextSuggestedCheckInSec:typeof s.nextSuggestedCheckInSec==`number`&&Number.isFinite(s.nextSuggestedCheckInSec)?s.nextSuggestedCheckInSec:void 0,packageManager:typeof s.packageManager==`string`?s.packageManager:void 0,updateCommand:typeof s.updateCommand==`string`?s.updateCommand:void 0,error:c}}catch(e){return console.warn(`Failed to check for updates:`,e),{available:!1,currentVersion:n,error:e instanceof Error?e.message:`Failed to check for updates`}}}function wr(){return V()?`mobile`:o()?`desktop`:f()?`vscode`:c()?`web`:null}var Tr={checking:!1,available:!1,downloading:!1,downloaded:!1,info:null,progress:null,error:null,runtimeType:null,lastChecked:null,nextCheckInSec:null,otaDecision:null,otaPhase:`idle`,otaDownloadSkipped:!1,lastOtaChannelOverride:null};function Er(e,t){let n=e.isChannelRollback===!0?{isChannelRollback:!0}:{};if(e.primaryAction===`apply_ota`&&e.ota.bundle)return e.ota.bundle.releaseVersion===t?{available:!1,otaPhase:`idle`,info:{available:!1,currentVersion:t,nextSuggestedCheckInSec:e.nextCheckInSec,...n}}:{available:!0,otaPhase:`available`,info:{available:!0,version:e.ota.bundle.releaseVersion,currentVersion:t,downloadUrl:e.ota.bundle.url,nextSuggestedCheckInSec:e.nextCheckInSec,inAppApply:!0,...e.releaseNotes?{body:e.releaseNotes}:{},...n}};if(e.primaryAction===`install_native_required`){if(!e.native.version?.trim()||!e.native.installUrl?.trim())throw Error(`Native update required, but the update service supplied no complete installation target`);return{available:e.native.state===`required`||e.native.state===`available`,otaPhase:`idle`,info:{available:e.native.state===`required`||e.native.state===`available`,version:e.native.version,currentVersion:t,downloadUrl:e.native.installUrl,nextSuggestedCheckInSec:e.nextCheckInSec,manualUpdate:!0,...e.releaseNotes?{body:e.releaseNotes}:{},...n}}}return{available:!1,otaPhase:`idle`,info:{available:!1,currentVersion:t,nextSuggestedCheckInSec:e.nextCheckInSec,...n}}}var Dr=0,Or=_()((e,t)=>({...Tr,checkForUpdates:async()=>{let n=wr();if(!n)return null;let r=++Dr;e({checking:!0,error:null,runtimeType:n});try{let i=null,a=null;if(n===`desktop`){let n=D.getState().otaChannelOverride;t().lastOtaChannelOverride!==n&&e({downloaded:!1,downloading:!1,available:!1,info:null,otaDecision:null,progress:null,otaPhase:`checking`});let i=await m(n);if(r!==Dr||D.getState().otaChannelOverride!==n)return null;let a=i?.downloaded===!0;return e({checking:!1,available:i?.available??!1,downloaded:a,...a?{downloading:!1,progress:null}:{},info:i,error:null,lastChecked:Date.now(),nextCheckInSec:i?.nextSuggestedCheckInSec??null,otaDecision:i?.otaDecision??null,otaPhase:a?`pending_restart`:i?.inAppApply?`available`:`idle`,lastOtaChannelOverride:n}),i?.nextSuggestedCheckInSec??null}if(n===`web`)i=await Cr(`web`),a=i?.nextSuggestedCheckInSec??null;else if(n===`vscode`)a=(await Cr(`vscode`))?.nextSuggestedCheckInSec??null;else if(n===`mobile`){let n=await H()??`unknown`,r=V()?g()?.mobileUpdates:void 0,o=D.getState().otaChannelOverride;if(r)try{let i=t().lastOtaChannelOverride!==o;e(i?{otaDecision:null,otaPhase:`checking`,downloaded:!1,otaDownloadSkipped:!1,progress:null,available:!1,info:null}:{otaPhase:`checking`});let a=await r.checkForOtaUpdate(o===`beta`||o===`stable`?{channelOverride:o}:void 0),s=Er(a,n),c=(i?void 0:t().otaDecision?.ota.bundle?.bundleId)!==a.ota.bundle?.bundleId,l=!i&&t().downloaded&&!c;return e({checking:!1,available:s.available,info:s.info,error:s.info.error??null,lastChecked:Date.now(),nextCheckInSec:a.nextCheckInSec,otaDecision:a,otaPhase:l?`pending_restart`:s.otaPhase,lastOtaChannelOverride:o,...c||i?{downloaded:!1,otaDownloadSkipped:!1,progress:null}:{}}),a.nextCheckInSec}catch(t){if(!(t instanceof re)){let r=t instanceof Error?t.message:`Mobile OTA check failed`;return e({checking:!1,available:!1,info:{available:!1,currentVersion:n},error:r,lastChecked:Date.now(),otaDecision:null,otaPhase:`error`,lastOtaChannelOverride:o}),null}}return i=await vr({currentVersion:n,platform:xr()===`ios`?`ios`:`android`,deviceClass:yr(),arch:br(),reportUsage:D.getState().reportUsage}),a=i?.nextSuggestedCheckInSec??null,e({checking:!1,available:i?.available??!1,info:i,error:i?.error??null,lastChecked:Date.now(),nextCheckInSec:a,otaDecision:null,otaPhase:`idle`}),a}return e({checking:!1,available:n===`vscode`?!1:i?.available??!1,info:n===`vscode`?null:i,error:n===`vscode`?null:i?.error??null,lastChecked:Date.now(),nextCheckInSec:a}),a}catch(i){return r===Dr&&e({checking:!1,error:i instanceof Error?i.message:`Failed to check for updates`,...n===`desktop`&&!t().downloaded?{otaPhase:`error`}:{}}),null}},downloadUpdate:async()=>{let{available:n,runtimeType:r,otaDecision:i,downloading:a,downloaded:o}=t();if(r===`mobile`&&i?.primaryAction===`apply_ota`&&i.ota.bundle){if(a||o)return;let t=g()?.mobileUpdates;if(!t){e({error:`Mobile OTA updates are unavailable in this runtime`,otaPhase:`error`});return}e({downloading:!0,error:null,progress:null,otaPhase:`downloading`,otaDownloadSkipped:!1});try{let{skipped:n}=await t.downloadOtaUpdate(i.ota.bundle);await t.queueOtaUpdateForNextLaunch(),e({downloading:!1,downloaded:!0,progress:null,otaPhase:`pending_restart`,otaDownloadSkipped:n})}catch(t){e({downloading:!1,error:t instanceof Error?t.message:`Failed to download update`,otaPhase:`error`})}return}if(!(r!==`desktop`||!n)){e({downloading:!0,error:null,progress:null});try{let n=D.getState().otaChannelOverride,r=await m(n);if(n!==D.getState().otaChannelOverride)throw Error(`OTA channel changed`);if(!r?.available||r.manualUpdate)throw Error(`Update detected, but desktop package is not ready yet. Retry in a moment.`);if(e(e=>({info:e.info?{...e.info,...r,body:r.body||e.info.body,available:e.info.available}:r})),r.downloaded||t().downloaded){e({downloading:!1,downloaded:!0,progress:null});return}if(r.downloading&&e({downloading:!0,progress:r.progress??{downloaded:0}}),!await p(t=>{e({progress:t})}))throw Error(`Failed to download update`);e({downloading:!1,downloaded:!0,progress:null,otaPhase:`pending_restart`})}catch(t){e({downloading:!1,error:t instanceof Error?t.message:`Failed to download update`})}}},subscribeDesktopUpdateEvents:async()=>{if(!o())return()=>{};let n=[],r=await s(n=>{let r=n.event,i=n.data??null;if(r===`Started`){if(!t().downloading)return;e({error:null,progress:{downloaded:0,total:typeof i?.contentLength==`number`?i.contentLength:void 0}});return}if(r===`Progress`){if(!t().downloading)return;e({progress:{downloaded:typeof i?.downloaded==`number`?i.downloaded:0,total:typeof i?.total==`number`?i.total:void 0}});return}r===`Finished`&&e({downloading:!1,downloaded:!0,progress:null})});r&&n.push(r);let i=await l(t=>{t.downloaded&&e({downloading:!1,downloaded:!0,available:!0,progress:null})});return i&&n.push(i),async()=>{for(let e of n)try{let t=e();t instanceof Promise&&await t}catch{}}},restartToUpdate:async()=>{let{downloaded:n,runtimeType:r,otaDecision:i}=t();if(r===`mobile`&&i?.primaryAction===`apply_ota`){if(!n)return;let t=g()?.mobileUpdates;if(!t){e({error:`Mobile OTA updates are unavailable in this runtime`,otaPhase:`error`});return}try{await t.applyOtaUpdateNow()}catch(t){e({error:t instanceof Error?t.message:`Failed to restart`,otaPhase:`error`})}return}if(!(r!==`desktop`||!n))try{if(!await u())throw Error(`Failed to restart`)}catch(t){e({error:t instanceof Error?t.message:`Failed to restart`})}},setOtaPhase:(t,n=null)=>{e({otaPhase:t,...n===void 0?{}:{error:n}})},setOtaDownloadPercent:n=>{if(!Number.isFinite(n)||n<0||n>100)return;let r=t();if(!r.downloading)return;let i=Math.round(n);if((r.progress?.total?Math.round(r.progress.downloaded/r.progress.total*100):null)===i)return;let a=r.otaDecision?.ota.bundle?.size;if(typeof a==`number`&&Number.isFinite(a)&&a>0){e({progress:{downloaded:Math.round(a*n/100),total:a}});return}e({progress:{downloaded:n,total:100}})},setOtaDownloadFailed:t=>{e({downloading:!1,downloaded:!1,error:t??`Failed to download update`,otaPhase:`error`})},dismiss:()=>{t().otaPhase!==`pending_restart`&&e({available:!1,downloaded:!1,info:null,otaDecision:null,otaPhase:`idle`,otaDownloadSkipped:!1})},reset:()=>{e(Tr)}})),kr=8e3,Ar=e=>!!(e&&![`succeeded`,`failed`].includes(e.status));function jr(e,t){if(e!==n()||t!==r())throw Error(`Stale update runtime`)}var Mr=(e=n(),t=r(),i)=>({queryKey:[e,`host-update`,t,i??`current`],queryFn:async({signal:n})=>{jr(e,t);let r=new AbortController,o=()=>r.abort();n.addEventListener(`abort`,o,{once:!0});let s;try{return await Promise.race([(async()=>{let n=await a(`/api/system/update${i?`?channel=${i}`:``}`,{headers:{Accept:`application/json`},signal:r.signal});if([404,501].includes(n.status))throw Error(`host_update_unsupported`);let o=await n.json();if(jr(e,t),!n.ok&&n.status!==502||typeof o.serverId!=`string`||typeof o.supported!=`boolean`||![`cli`,`electron`].includes(o.host))throw Error(`Host update check failed`);return o})(),new Promise((e,t)=>{s=setTimeout(()=>{r.abort(),t(Error(`host_update_timeout`))},kr)})])}finally{s!==void 0&&clearTimeout(s),n.removeEventListener(`abort`,o)}},staleTime:6e4,retry:!1}),Nr=(e=n(),t=r(),i)=>L.getQueryData(Mr(e,t,i).queryKey),Pr=(e=n(),t=r(),i)=>{let a=Nr(e,t,i);return L.fetchQuery({...Mr(e,t,i),staleTime:a?.checkError||Ar(a?.operation)?0:6e4})},Fr=(e=n(),t=r(),i)=>L.fetchQuery({...Mr(e,t,i),staleTime:0}),Ir=(e,t,n)=>{let r=(0,Z.c)(6),i;r[0]!==n||r[1]!==t||r[2]!==e?(i=Mr(e,t,n),r[0]=n,r[1]=t,r[2]=e,r[3]=i):i=r[3];let a;return r[4]===i?a=r[5]:(a={...i,refetchInterval:Rr,refetchIntervalInBackground:!1},r[4]=i,r[5]=a),I(a)};async function Lr(e,t,n){if(jr(t,n),!e.update)throw Error(`No update plan`);let r=await a(`/api/system/update`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({version:e.update.version,channel:e.channel,planId:e.update.planId,allowDowngrade:e.update.rollback===!0})});if(jr(t,n),!r.ok)throw Error(`Host update was not accepted`);let i=await r.json();if(typeof i.operation?.id!=`string`)throw Error(`Invalid update operation`);return i.operation}function Rr(e){return Ar(e.state.data?.operation)?2e3:e.state.error?.message===`host_update_unsupported`?!1:e.state.error?15e3:3e5}function zr(e){let t=new Date(`${e}T00:00:00`);return Number.isNaN(t.getTime())?e:new Intl.DateTimeFormat(Fe(),{year:`numeric`,month:`short`,day:`numeric`}).format(t)}function Br(e){return e.replace(/^## \[[^\]]+\] - \d{4}-\d{2}-\d{2}\s*\n?/,``).trim()}function Vr(e){return e.replace(/(^|[^a-zA-Z0-9])@([a-zA-Z0-9-]+)/g,`$1[@$2](https://github.com/$2)`)}function Hr(e,t){let n=e.split(`.`).map(e=>Number.parseInt(e,10)),r=t.split(`.`).map(e=>Number.parseInt(e,10));for(let e=0;e<3;e+=1){let t=Number.isFinite(n[e])?n[e]:0,i=Number.isFinite(r[e])?r[e]:0;if(t!==i)return i-t}return 0}function Ur(e){let t=/^## \[(\d+\.\d+\.\d+)\] - (\d{4}-\d{2}-\d{2})\s*$/gm,n=[],r;for(;(r=t.exec(e))!==null;)n.push({version:r[1]??``,date:r[2]??``,start:r.index});return n.map((t,r)=>{let i=n[r+1]?.start??e.length;return{version:t.version,date:t.date,start:t.start,end:i,raw:e.slice(t.start,i).trim()}})}function Wr(e){let t=(0,Z.c)(67),{open:n,onOpenChange:r,model:i,onAction:a}=e,{t:o}=Pe(),[s,c]=(0,$.useState)(!1),l=je(Kr),u;t[0]===l?u=t[1]:(u=e=>{let t=e.target.closest(`a`);t?.href&&(e.preventDefault(),e.stopPropagation(),l(t.href))},t[0]=l,t[1]=u);let d=je(u),f;t[2]===i.fallbackCommand?f=t[3]:(f=async()=>{i.fallbackCommand&&(await Ne(i.fallbackCommand)).ok&&(c(!0),setTimeout(()=>c(!1),2e3))},t[2]=i.fallbackCommand,t[3]=f);let p=je(f),m;if(t[4]!==i.body||t[5]!==o){bb0:{let e=i.body?.trim();if(!e){m=null;break bb0}let n=Ur(e);if(!n.length){m={kind:`raw`,title:o(`updateDialog.changelog.title`),content:Vr(e)};break bb0}let r;t[7]===o?r=t[8]:(r=o(`updateDialog.changelog.title`),t[7]=o,t[8]=r),m={kind:`sections`,title:r,sections:[...n].sort(Gr).map(t=>({version:t.version,dateLabel:zr(t.date),content:Vr(Br(t.raw)||e)}))}}t[4]=i.body,t[5]=o,t[6]=m}else m=t[6];let h=m,g=i.dismissible===!1?void 0:r,_=i.stableLayout&&`h-[min(38rem,calc(100dvh-2rem))] overflow-hidden transition-[opacity,transform,filter]`,v;t[9]===_?v=t[10]:(v=q(`max-w-4xl gap-0 p-4 sm:p-5 bg-background border-[var(--interactive-border)]`,_),t[9]=_,t[10]=v);let y;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Q.jsx)(X,{name:`download-cloud`,className:`h-5 w-5 text-[var(--primary-base)]`}),t[11]=y):y=t[11];let b;t[12]===i.title?b=t[13]:(b=(0,Q.jsxs)(ot,{className:`flex items-center gap-2`,children:[y,(0,Q.jsx)(`span`,{className:`font-semibold text-foreground`,children:i.title})]}),t[12]=i.title,t[13]=b);let x;t[14]!==i.currentVersion||t[15]!==i.methodLabel||t[16]!==i.version?(x=(i.currentVersion||i.version)&&(0,Q.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-1.5 pl-7 font-mono text-[11px] leading-4 tracking-[-0.01em] tabular-nums sm:text-xs`,children:[i.currentVersion&&(0,Q.jsx)(`span`,{className:`text-muted-foreground/75`,children:i.currentVersion}),i.currentVersion&&i.version&&(0,Q.jsx)(`span`,{className:`text-muted-foreground/40`,children:`→`}),i.version&&(0,Q.jsx)(`span`,{className:`font-medium text-[var(--primary-base)]`,children:i.version}),i.methodLabel&&(0,Q.jsxs)(`span`,{className:`text-muted-foreground`,children:[`· `,i.methodLabel]})]}),t[14]=i.currentVersion,t[15]=i.methodLabel,t[16]=i.version,t[17]=x):x=t[17];let S;t[18]===i.description?S=t[19]:(S=i.description&&(0,Q.jsx)(st,{className:`mt-2`,children:i.description}),t[18]=i.description,t[19]=S);let C;t[20]!==S||t[21]!==b||t[22]!==x?(C=(0,Q.jsxs)(`div`,{className:`mb-3 shrink-0 pr-8 sm:mb-4`,children:[b,x,S]}),t[20]=S,t[21]=b,t[22]=x,t[23]=C):C=t[23];let w=i.stableLayout?`flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto`:`space-y-3 sm:space-y-4`,T;t[24]===i.message?T=t[25]:(T=i.message&&(0,Q.jsx)(`p`,{role:`status`,className:`typography-ui-label text-muted-foreground`,children:i.message}),t[24]=i.message,t[25]=T);let E;t[26]===i.warning?E=t[27]:(E=i.warning&&(0,Q.jsx)(`p`,{className:`typography-meta text-[var(--status-warning)]`,children:i.warning}),t[26]=i.warning,t[27]=E);let D;t[28]!==h||t[29]!==d||t[30]!==i.hideChangelog||t[31]!==i.stableLayout?(D=h&&!i.hideChangelog&&(0,Q.jsxs)(`section`,{className:q(`overflow-hidden rounded-xl border border-[var(--surface-subtle)] bg-[var(--surface-elevated)]/20`,i.stableLayout&&`flex min-h-0 flex-1 flex-col`),children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-[var(--surface-subtle)] px-3.5 py-2.5 sm:px-4 sm:py-3`,children:[(0,Q.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-[var(--primary-base)]`,"aria-hidden":`true`}),(0,Q.jsx)(`h3`,{className:`typography-ui-caption font-medium text-muted-foreground`,children:h.title})]}),(0,Q.jsx)(nn,{className:i.stableLayout?`p-0`:`max-h-[min(42dvh,22rem)] p-0 sm:max-h-[400px]`,outerClassName:i.stableLayout?`flex-1`:void 0,fillContainer:!!i.stableLayout,children:h.kind===`raw`?(0,Q.jsx)(`div`,{className:`break-words p-3.5 text-[13px] leading-[1.65] text-foreground sm:p-4 sm:text-sm [&_.markdown-content]:leading-[1.65] [&_a]:!text-[var(--primary-base)] [&_a]:!no-underline [&_a:hover]:!underline`,onClickCapture:d,children:(0,Q.jsx)($t,{content:h.content,disableLinkSafety:!0,enableFileReferences:!1})}):(0,Q.jsx)(`div`,{className:`divide-y divide-[var(--surface-subtle)]`,children:h.sections.map(e=>(0,Q.jsxs)(`div`,{className:`p-3.5 sm:p-4`,children:[(0,Q.jsxs)(`div`,{className:`mb-2.5 flex flex-wrap items-center gap-x-2 gap-y-1 sm:mb-3`,children:[(0,Q.jsxs)(`span`,{className:`rounded-md bg-[var(--primary-base)]/10 px-1.5 py-0.5 font-mono text-[11px] font-medium leading-4 text-[var(--primary-base)] tabular-nums sm:text-xs`,children:[`v`,e.version]}),(0,Q.jsx)(`span`,{className:`text-[11px] leading-4 text-muted-foreground/75 sm:text-xs`,children:e.dateLabel})]}),(0,Q.jsx)(`div`,{className:`break-words text-[13px] leading-[1.65] text-foreground sm:text-sm [&_.markdown-content]:leading-[1.65] [&_a]:!text-[var(--primary-base)] [&_a]:!no-underline [&_a:hover]:!underline`,onClickCapture:d,children:(0,Q.jsx)($t,{content:e.content,disableLinkSafety:!0,enableFileReferences:!1})})]},e.version))})})]}),t[28]=h,t[29]=d,t[30]=i.hideChangelog,t[31]=i.stableLayout,t[32]=D):D=t[32];let O;t[33]!==s||t[34]!==p||t[35]!==i.fallbackCommand||t[36]!==o?(O=i.fallbackCommand&&(0,Q.jsxs)(`div`,{className:`space-y-2 mt-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 typography-meta text-muted-foreground`,children:[(0,Q.jsx)(X,{name:`terminal`,className:`h-4 w-4`}),(0,Q.jsx)(`span`,{children:o(`updateDialog.fallback.updateViaTerminal`)})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 p-1 pl-3 bg-[var(--surface-elevated)]/50 rounded-md border border-[var(--surface-subtle)]`,children:[(0,Q.jsx)(`code`,{className:`flex-1 font-mono text-sm text-foreground overflow-x-auto whitespace-nowrap`,children:i.fallbackCommand}),(0,Q.jsx)(`button`,{onClick:p,className:q(`flex items-center justify-center p-2 rounded`,`text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]`,`transition-colors`,s&&`text-[var(--status-success)]`),title:o(s?`updateDialog.actions.copied`:`updateDialog.actions.copyCommand`),children:(0,Q.jsx)(X,{name:s?`check`:`clipboard`,className:`h-4 w-4`})})]})]}),t[33]=s,t[34]=p,t[35]=i.fallbackCommand,t[36]=o,t[37]=O):O=t[37];let k;t[38]!==i.stableLayout||t[39]!==i.status?(k=i.status&&(0,Q.jsxs)(`div`,{role:`status`,className:q(`space-y-2`,i.stableLayout&&`min-h-9 shrink-0`),children:[(0,Q.jsxs)(`div`,{className:`flex h-5 items-center justify-between gap-3`,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 text-xs font-medium text-muted-foreground sm:text-[13px]`,children:[i.status.kind===`activity`&&(0,Q.jsx)(X,{name:`loader`,className:`h-3.5 w-3.5 shrink-0 animate-spin text-[var(--primary-base)]`}),(0,Q.jsx)(`span`,{className:`truncate`,title:i.status.label,children:i.status.label})]}),i.status.progress!=null&&(0,Q.jsxs)(`span`,{className:`shrink-0 font-mono text-[11px] leading-4 text-foreground tabular-nums sm:text-xs`,children:[Math.round(i.status.progress),`%`]})]}),(0,Q.jsx)(`div`,{className:`h-1 overflow-hidden rounded-full bg-[var(--surface-subtle)] sm:h-1.5`,children:i.status.progress==null?(0,Q.jsx)(`div`,{className:`h-full w-1/3 animate-pulse rounded-full bg-[var(--primary-base)]/60`}):(0,Q.jsx)(`div`,{className:`h-full rounded-full bg-[var(--primary-base)] transition-[width] duration-500`,style:{width:`${i.status.progress}%`}})}),i.status.detail&&(0,Q.jsx)(`p`,{className:`text-xs leading-4 text-muted-foreground`,children:i.status.detail})]}),t[38]=i.stableLayout,t[39]=i.status,t[40]=k):k=t[40];let A;t[41]===i.error?A=t[42]:(A=i.error&&(0,Q.jsx)(`div`,{role:`alert`,className:`p-3 mt-4 bg-[var(--status-error-background)] border border-[var(--status-error-border)] rounded-lg`,children:(0,Q.jsx)(`p`,{className:`text-sm text-[var(--status-error)]`,children:i.error})}),t[41]=i.error,t[42]=A);let j;t[43]!==w||t[44]!==T||t[45]!==E||t[46]!==D||t[47]!==O||t[48]!==k||t[49]!==A?(j=(0,Q.jsxs)(`div`,{className:w,children:[T,E,D,O,k,A]}),t[43]=w,t[44]=T,t[45]=E,t[46]=D,t[47]=O,t[48]=k,t[49]=A,t[50]=j):j=t[50];let M;t[51]===i.notice?M=t[52]:(M=i.notice&&(0,Q.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 rounded-lg border border-[var(--status-success-border)] bg-[var(--status-success-background)] px-3 py-2.5 text-sm text-[var(--status-success)]`,children:[(0,Q.jsx)(X,{name:`check`,className:`h-4 w-4 shrink-0`}),(0,Q.jsx)(`span`,{children:i.notice})]}),t[51]=i.notice,t[52]=M);let N;t[53]!==i.actions||t[54]!==i.releaseLink||t[55]!==a?(N=(i.releaseLink||i.actions.length>0)&&(0,Q.jsxs)(`div`,{className:`mt-4 flex shrink-0 items-center justify-between gap-4`,children:[i.releaseLink&&(0,Q.jsxs)(`a`,{href:i.releaseLink.url,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 typography-ui-label text-muted-foreground hover:text-foreground transition-colors shrink-0`,children:[(0,Q.jsx)(X,{name:`external-link`,className:`h-4 w-4`}),i.releaseLink.label]}),(0,Q.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-nowrap items-center justify-end gap-2`,children:i.actions.map(e=>(0,Q.jsxs)(J,{onClick:()=>a(e.id),disabled:e.disabled,variant:e.variant??`default`,size:`default`,className:`min-w-0 shrink`,title:e.label,children:[e.icon&&(0,Q.jsx)(X,{name:e.icon,className:q(`h-4 w-4`,e.loading&&`animate-spin`)}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.label})]},e.id))})]}),t[53]=i.actions,t[54]=i.releaseLink,t[55]=a,t[56]=N):N=t[56];let P;t[57]!==C||t[58]!==j||t[59]!==M||t[60]!==N||t[61]!==v?(P=(0,Q.jsxs)(at,{className:v,showCloseButton:!0,children:[C,j,M,N]}),t[57]=C,t[58]=j,t[59]=M,t[60]=N,t[61]=v,t[62]=P):P=t[62];let F;return t[63]!==n||t[64]!==P||t[65]!==g?(F=(0,Q.jsx)(ct,{open:n,onOpenChange:g,children:P}),t[63]=n,t[64]=P,t[65]=g,t[66]=F):F=t[66],F}function Gr(e,t){return Hr(e.version,t.version)}function Kr(e){en(e)}var qr=`https://github.com/yee94/yuri/releases`,Jr=2e3,Yr=6e5,Xr=e=>e.transport===n()&&e.generation===r();async function Zr(e,t){try{if(!Xr(t))return{success:!1};let n=await Pr(t.transport,t.generation);return!Xr(t)||!e||!n.supported||n.update?.version!==e||n.update.rollback?{success:!1}:(await Lr(n,t.transport,t.generation),{success:!0,autoRestart:!0})}catch(e){return{success:!1,error:e instanceof Error?e.message:void 0}}}async function Qr(e,t,n=Math.ceil(Yr/Jr),r=Jr){for(let i=0;i<n;i++){if(!Xr(t))return!1;try{let n=await Fr(t.transport,t.generation);if(n.operation?.status===`failed`)return!1;if(n.currentVersion===e&&n.operation?.status===`succeeded`&&Xr(t))return!0}catch{}await new Promise(e=>setTimeout(e,r))}return!1}var $r=e=>{let t=(0,Z.c)(107),{open:i,onOpenChange:a,info:o,downloading:s,downloaded:c,progress:l,error:u,onDownload:d,onRestart:f,runtimeType:p}=e,m=p===void 0?`desktop`:p,{t:h}=Pe(),[g,_]=(0,$.useState)(`idle`),[v,y]=(0,$.useState)(null),b=Or(ei),x=o?.releaseUrl||(o?.version?`${qr}/tag/v${o.version}`:qr),S=o?.downloadUrl,C=m===`web`,w=m===`mobile`,T=w&&o?.manualUpdate===!0&&!!S,E=w&&o?.inAppApply===!0,D=m===`desktop`&&o?.manualUpdate===!0,O=g!==`idle`&&g!==`error`,k=w?S:x,A;t[0]!==c||t[1]!==E||t[2]!==a?(A=e=>{!e&&E&&c&&Or.getState().dismiss(),a(e)},t[0]=c,t[1]=E,t[2]=a,t[3]=A):A=t[3];let j=je(A),M,N;t[4]===i?(M=t[5],N=t[6]):(M=()=>{i||(_(`idle`),y(null))},N=[i],t[4]=i,t[5]=M,t[6]=N),(0,$.useEffect)(M,N);let P;t[7]!==o?.version||t[8]!==h?(P=async()=>{let e={transport:n(),generation:r()};_(`updating`),y(null);let t=await Zr(o?.version,e);if(!Xr(e))return;if(!t.success){_(`error`),y(t.error||h(`updateDialog.error.updateFailed`));return}t.autoRestart&&(_(`restarting`),await new Promise(ti)),_(`reconnecting`);let i=await Qr(o?.version,e);Xr(e)&&(i?window.location.reload():(_(`error`),y(h(`updateDialog.error.takingLonger`))))},t[7]=o?.version,t[8]=h,t[9]=P):P=t[9];let F=je(P),I;t[10]!==F||t[11]!==w||t[12]!==d||t[13]!==a||t[14]!==f||t[15]!==S||t[16]!==x?(I=e=>{bb107:switch(e){case`download`:d();break bb107;case`restart`:f();break bb107;case`later`:Or.getState().dismiss(),a(!1);break bb107;case`open-external`:{let e=w?S:x;e&&en(e);break bb107}case`web-update`:F()}},t[10]=F,t[11]=w,t[12]=d,t[13]=a,t[14]=f,t[15]=S,t[16]=x,t[17]=I):I=t[17];let L=je(I),R;if(t[18]!==c||t[19]!==s||t[20]!==E||t[21]!==D||t[22]!==w||t[23]!==C||t[24]!==O||t[25]!==T||t[26]!==h){if(R=[],!C&&(!w||E)){if(!D&&!c&&!s){let e;t[28]!==E||t[29]!==h?(e=h(E?`updateDialog.actions.applyOtaNow`:`updateDialog.actions.downloadUpdate`),t[28]=E,t[29]=h,t[30]=e):e=t[30];let n;t[31]===e?n=t[32]:(n={id:`download`,icon:`download`,label:e},t[31]=e,t[32]=n),R.push(n)}if(D&&!c&&!s){let e;t[33]===h?e=t[34]:(e=h(`updateDialog.actions.openMobileUpdate`),t[33]=h,t[34]=e);let n;t[35]===e?n=t[36]:(n={id:`open-external`,icon:`external-link`,label:e},t[35]=e,t[36]=n),R.push(n)}if(s){let e;t[37]===h?e=t[38]:(e=h(`updateDialog.status.downloading`),t[37]=h,t[38]=e);let n;t[39]===e?n=t[40]:(n={id:`downloading`,icon:`loader`,loading:!0,disabled:!0,label:e},t[39]=e,t[40]=n),R.push(n)}if(c){if(E){let e;t[41]===h?e=t[42]:(e=h(`updateDialog.actions.later`),t[41]=h,t[42]=e);let n;t[43]===e?n=t[44]:(n={id:`later`,variant:`ghost`,label:e},t[43]=e,t[44]=n),R.push(n)}let e;t[45]===h?e=t[46]:(e=h(`updateDialog.actions.restartToUpdate`),t[45]=h,t[46]=e);let n;t[47]===e?n=t[48]:(n={id:`restart`,icon:`restart`,label:e},t[47]=e,t[48]=n),R.push(n)}}if(w&&!E&&T){let e;t[49]===h?e=t[50]:(e=h(`updateDialog.actions.openMobileUpdate`),t[49]=h,t[50]=e);let n;t[51]===e?n=t[52]:(n={id:`open-external`,icon:`external-link`,label:e},t[51]=e,t[52]=n),R.push(n)}if(C){let e;t[53]!==O||t[54]!==h?(e=O?{id:`updating`,icon:`loader`,loading:!0,disabled:!0,label:h(`updateDialog.status.updating`)}:{id:`web-update`,icon:`download`,label:h(`updateDialog.actions.updateNow`)},t[53]=O,t[54]=h,t[55]=e):e=t[55],R.push(e)}t[18]=c,t[19]=s,t[20]=E,t[21]=D,t[22]=w,t[23]=C,t[24]=O,t[25]=T,t[26]=h,t[27]=R}else R=t[27];let z;t[56]!==h||t[57]!==g?(z=h(g===`restarting`||g===`reconnecting`?`updateDialog.header.updating`:`updateDialog.header.updateAvailable`),t[56]=h,t[57]=g,t[58]=z):z=t[58];let ee=o?.currentVersion,te=o?.version,B=o?.body,V=!O,ne=u||v,H=C&&g===`error`?o?.updateCommand||`yuri update`:void 0,re;t[59]!==c||t[60]!==E||t[61]!==b||t[62]!==h?(re=E&&c&&b?h(`updateDialog.status.otaBundleReused`):void 0,t[59]=c,t[60]=E,t[61]=b,t[62]=h,t[63]=re):re=t[63];let U;t[64]!==w||t[65]!==k||t[66]!==T?(U=(!w||T)&&k?{url:k,label:`GitHub`}:void 0,t[64]=w,t[65]=k,t[66]=T,t[67]=U):U=t[67];let ie;if(t[68]!==R||t[69]!==s||t[70]!==E||t[71]!==w||t[72]!==C||t[73]!==O||t[74]!==l||t[75]!==h||t[76]!==B||t[77]!==V||t[78]!==ne||t[79]!==H||t[80]!==re||t[81]!==U||t[82]!==z||t[83]!==ee||t[84]!==te||t[85]!==g){if(ie={title:z,currentVersion:ee,version:te,body:B,hideChangelog:O,dismissible:V,error:ne,fallbackCommand:H,notice:re,releaseLink:U,actions:R},C&&O){let e;t[87]!==h||t[88]!==g?(e=h(g===`updating`?`updateDialog.status.installingUpdate`:g===`restarting`?`updateDialog.status.serverRestarting`:`updateDialog.status.waitingForServer`),t[87]=h,t[88]=g,t[89]=e):e=t[89];let n;t[90]===h?n=t[91]:(n=h(`updateDialog.status.autoReloadHint`),t[90]=h,t[91]=n);let r;t[92]!==e||t[93]!==n?(r={kind:`activity`,label:e,detail:n},t[92]=e,t[93]=n,t[94]=r):r=t[94],ie.status=r}if(!C&&(!w||E)&&s){let e;t[95]===h?e=t[96]:(e=h(`updateDialog.status.downloadingPayload`),t[95]=h,t[96]=e);let n;t[97]===l?n=t[98]:(n=l?.total?Math.round(l.downloaded/l.total*100):0,t[97]=l,t[98]=n);let r;t[99]!==e||t[100]!==n?(r={kind:`download`,label:e,progress:n},t[99]=e,t[100]=n,t[101]=r):r=t[101],ie.status=r}t[68]=R,t[69]=s,t[70]=E,t[71]=w,t[72]=C,t[73]=O,t[74]=l,t[75]=h,t[76]=B,t[77]=V,t[78]=ne,t[79]=H,t[80]=re,t[81]=U,t[82]=z,t[83]=ee,t[84]=te,t[85]=g,t[86]=ie}else ie=t[86];let W;return t[102]!==L||t[103]!==j||t[104]!==ie||t[105]!==i?(W=(0,Q.jsx)(Wr,{open:i,onOpenChange:j,model:ie,onAction:L}),t[102]=L,t[103]=j,t[104]=ie,t[105]=i,t[106]=W):W=t[106],W};function ei(e){return e.otaDownloadSkipped}function ti(e){return setTimeout(e,2e3)}function ni(e,t){return e===`checking`?5:e===`downloading`?5+Math.min(Math.max(t??0,0),100)*.75:e===`installing`?85:e===`restarting`?95:100}function ri(e,t,n){let r=e?.operation,i=e?.update,a=i??(r&&t.updateDetails&&r.planId===t.updateDetails.planId&&r.version===t.updateDetails.version?t.updateDetails:void 0),o=Ar(r),s=e?.supported===!1||t.failure===`unsupported`,c={title:n(`settings.yuri.about.hostUpdate.title`),stableLayout:!0,description:n(`settings.yuri.about.hostUpdate.description`),currentVersion:e?.currentVersion??t.versionFallback,version:i?.version??r?.version,body:a||r?a?.releaseNotes||n(`settings.yuri.about.hostUpdate.noNotes`):void 0,warning:!o&&i?.rollback?n(`settings.yuri.about.hostUpdate.downgrade`):void 0,actions:o||t.submitting||t.completed||!i?[]:[{id:`confirm`,icon:`download`,label:n(`settings.yuri.about.hostUpdate.confirm`),disabled:!e?.supported||!!t.failure||!!t.checking}]};return o&&r?c.status={kind:r.status===`downloading`?`download`:`activity`,label:n(t.failure===`disconnected`?`settings.yuri.about.hostUpdate.reconnecting`:`settings.yuri.about.hostUpdate.status.${r.status}`),progress:ni(r.status,r.progress)}:t.completed&&!i?c.status={kind:`download`,label:n(`settings.yuri.about.hostUpdate.status.succeeded`),progress:100}:t.submitting?c.status={kind:`activity`,label:n(`settings.yuri.about.state.checking`),progress:0}:t.checking===`initial`?c.status={kind:`activity`,label:n(`settings.yuri.about.state.checking`)}:s?c.message=n(`settings.yuri.about.hostUpdate.unsupported`):t.failure?c.error=n(t.failure===`disconnected`?`settings.yuri.about.hostUpdate.reconnecting`:`settings.yuri.about.toast.checkFailed`):!i&&e?.supported&&(c.message=r?.status===`succeeded`?n(`settings.yuri.about.hostUpdate.status.succeeded`):n(`settings.yuri.about.toast.latestVersion`)),r?.status===`failed`&&(c.error=n(`settings.yuri.about.hostUpdate.status.failed`)),c}function ii(){let e=(0,Z.c)(7),{t:i}=Pe(),a=$.useSyncExternalStore(t,n,n),o=$.useSyncExternalStore(t,r,r),s=`${a}:${o}`,c;e[0]===i?c=e[1]:(c=i(`settings.yuri.about.state.unknown`),e[0]=i,e[1]=c);let l;return e[2]!==o||e[3]!==s||e[4]!==c||e[5]!==a?(l=(0,Q.jsx)(ai,{transport:a,generation:o,version:c},s),e[2]=o,e[3]=s,e[4]=c,e[5]=a,e[6]=l):l=e[6],l}function ai({version:e,transport:t,generation:i,itemId:a,channel:o}){let{t:s}=Pe(),c=N(),[l,u]=$.useState(!1),d=D(e=>e.otaChannelOverride),f=o??d??void 0,p=Ir(t,i,f),m=p.data,h=m?.operation,g=Ar(h),_=JSON.stringify([t,i,f??`current`]),[v,y]=$.useState(null);m?.update&&(v?.scope!==_||v.update!==m.update)&&y({scope:_,update:m.update});let b=P({mutationFn:({plan:e})=>Lr(e,t,i),onSuccess:(e,a)=>{t===n()&&i===r()&&c.setQueryData(Mr(t,i,a.channel).queryKey,t=>t&&{...t,operation:e})},onSettled:(e,a,o)=>{t===n()&&i===r()&&c.invalidateQueries({queryKey:Mr(t,i,o.channel).queryKey,exact:!0})}}),[x,S]=$.useState(null);l&&g&&h&&h.id!==x&&S(h.id);let C=h?.status===`succeeded`&&h.id===x,w=s(`settings.yuri.about.hostUpdate.status.succeeded`);$.useEffect(()=>{!C||p.isError||t!==n()||i!==r()||(S(null),u(!1),Y.success(w,{id:`host-update:${t}:${i}:${x}`}))},[C,p.isError,t,i,x,w]);let T=$.useRef(null),E=je(()=>_),O=je(async()=>{if(g){u(!0),p.refetch({cancelRefetch:!1});return}if(T.current===_)return;let e=_;T.current=e;try{let a=await p.refetch({cancelRefetch:!1});if(e!==E()||t!==n()||i!==r())return;if(a.isError||!a.data||a.data.checkError){a.error?.message===`host_update_unsupported`?Y.info(s(`settings.yuri.about.hostUpdate.unsupported`)):Y.error(s(`settings.yuri.about.toast.checkFailed`));return}Ar(a.data.operation)?u(!0):a.data.supported?a.data.update?u(!0):(u(!1),Y.success(s(`settings.yuri.about.toast.latestVersion`))):Y.info(s(`settings.yuri.about.hostUpdate.unsupported`))}finally{T.current===e&&(T.current=null)}}),k=m?.supported===!1||!g&&p.error?.message===`host_update_unsupported`,A=p.isError||!!m?.checkError,j=b.isError&&b.variables?.channel===f,M=ri(m,{versionFallback:e,checking:p.isPending?`initial`:p.isFetching?`refresh`:!1,submitting:b.isPending,failure:k?`unsupported`:p.isError&&(g||j)?`disconnected`:A||j?`check`:null,completed:C,updateDetails:v?.scope===_?v.update:void 0},s),F=je(e=>{e===`confirm`&&m?.update&&b.mutate({plan:m,channel:f})});return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,"data-settings-item":a,children:[(0,Q.jsxs)(`span`,{className:`relative typography-ui-label font-mono text-foreground text-right`,children:[m?.currentVersion??e,m?.update&&!g&&(0,Q.jsx)(`span`,{"aria-label":s(`settings.yuri.about.hostUpdate.available`),className:`absolute -right-1.5 -top-0.5 size-1.5 rounded-full bg-[var(--status-error)]`})]}),(0,Q.jsx)(J,{type:`button`,size:`icon`,variant:`ghost`,onClick:O,disabled:p.isFetching&&!g,"aria-label":s(`settings.yuri.about.hostUpdate.title`),title:s(`settings.yuri.about.hostUpdate.title`),children:(0,Q.jsx)(X,{name:g||p.isFetching?`loader`:m?.update?`download`:`refresh`,className:g||p.isFetching?`size-4 animate-spin`:`size-4`})})]}),(0,Q.jsx)(Wr,{open:l,onOpenChange:u,model:M,onAction:F})]})}var oi=e=>e.startsWith(`/`)||/^[A-Za-z]:[\\/]/.test(e),si=e=>{let t=e.replace(/\\/g,`/`),n=[],[r,...i]=t.split(`/`);for(let e of i)if(e!==``&&e!==`.`){if(e===`..`){n.pop();continue}n.push(e)}return`${/^[A-Za-z]:$/.test(r)?`${r.toUpperCase()}/`:`/`}${n.join(`/`)}`},ci=e=>si(`${e.replace(/\\/g,`/`)}/..`),li=e=>{try{let t=decodeURIComponent(new URL(e).pathname);return/^\/[A-Za-z]:\//.test(t)?t.slice(1):t}catch{return null}};function ui(e,t){if(e.startsWith(`file://`)){let t=li(e);return t?{kind:`local`,path:si(t)}:null}return e.startsWith(`./`)||e.startsWith(`../`)?t?{kind:`local`,path:si(`${ci(t)}/${e}`)}:null:oi(e)?{kind:`local`,path:si(e)}:{kind:`package`,target:e}}function di(e){return e?{kind:`local`,path:si(e)}:null}var fi=(e,t)=>{if(e.kind===`package`)return t.source.kind===`package`&&t.source.target===e.target;if(t.source.kind!==`local`)return!1;let n=si(t.source.path);return n===e.path||n.startsWith(`${e.path}/`)};function pi(e,t){return t.filter(t=>fi(e,t))}function mi(e){for(let t of e)if(t.state.kind===`active`&&t.source.kind===`package`&&t.source.version?.trim())return t.source.version.trim();return null}function hi(e){let t=e.find(e=>e.state.kind===`failed`);if(t&&t.state.kind===`failed`)return{kind:`failed`,error:t.state.error,ref:t.state.ref};let n=e[0];return n?{kind:`active`,version:n.source.kind===`package`?n.source.version:null}:{kind:`notReported`}}function gi(e){let t=e.flatMap(e=>e.source.kind===`package`?[e.source]:[]);return t.some(e=>e.updating)?`updating`:t.some(e=>e.outdated)?`available`:`none`}function _i(){let e=(0,Z.c)(5),t=gn(),n=yn(),r=t.data?.entries,i=t.data?.files,a=n.data,o;bb0:{if(!a){let t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=[],e[0]=t):t=e[0],o=t;break bb0}let t;if(e[1]!==r||e[2]!==i||e[3]!==a){t=[];let n=(e,n,r)=>{if(!r)return;let i=hi(pi(r,a));i.kind===`failed`&&t.push({id:e,label:n,error:i.error})};for(let e of r??[])n(e.id,e.spec,ui(e.spec,e.sourcePath));for(let e of i??[])n(e.id,e.fileName,di(e.absolutePath));e[1]=r,e[2]=i,e[3]=a,e[4]=t}else t=e[4];o=t}return o}var vi=e(b(),1),yi=e=>{let t=(0,Z.c)(217),{providerId:n,modelId:r,variant:i,onChange:a,className:o,allowedProviderIds:s,allowedModelIdsByProvider:c,placeholder:l,tooltipsEnabled:u,dropdownPortalToBody:d,showIcon:f,providers:p}=e,m=u===void 0||u,h=d!==void 0&&d,g=f===void 0||f,{t:_}=Pe(),{isReady:v,isUnavailable:y}=At(),b=Re(bi),x=p??b,S=Re(xi),C=D(Si),w=D(Ci),T=D(wi),E=D(Ti),O=D(Ei),k=D(Di),A;t[0]!==r||t[1]!==n?(A={currentProviderID:n,currentModelID:r},t[0]=r,t[1]=n,t[2]=A):A=t[2];let{favoriteModelsList:j,recentModelsList:M}=cn(A),{isMobile:N}=Wt(),P=C||N,[F,I]=$.useState(!1),[L,R]=$.useState(!1),z;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(z=()=>{I(!0),Re.getState().refreshCatalogsOnPickerOpen({source:`modelSelector:mobilePanel`})},t[3]=z):z=t[3];let ee=je(z),te;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(te=e=>{R(e),e&&Re.getState().refreshCatalogsOnPickerOpen({source:`modelSelector:desktopMenu`})},t[4]=te):te=t[4];let B=je(te),[V,ne]=$.useState(``),[H,re]=$.useState(null),U=i!==void 0,ie;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(ie=()=>{I(!1),R(!1),ne(``),re(null)},t[5]=ie):ie=t[5];let W=ie,ae;t[6]===x?ae=t[7]:(ae=e=>{let t=x.find(t=>t.id===e.providerID)?.models?.find(t=>t.id===e.modelID);return t?.variants?Object.keys(t.variants):[]},t[6]=x,t[7]=ae);let oe=ae,se;t[8]!==O||t[9]!==oe||t[10]!==r||t[11]!==a||t[12]!==n||t[13]!==i||t[14]!==U?(se=e=>{let t=oe(e),o=e.providerID===n&&e.modelID===r,s=e.variant!==void 0&&t.includes(e.variant)?e.variant:void 0,c=o&&i&&t.includes(i)?i:s??``;a(e.providerID,e.modelID,U?c:void 0),O(e.providerID,e.modelID,U&&c||void 0),W()},t[8]=O,t[9]=oe,t[10]=r,t[11]=a,t[12]=n,t[13]=i,t[14]=U,t[15]=se):se=t[15];let ce=se,le;t[16]!==a||t[17]!==U?(le=()=>{a(``,``,U?``:void 0),W()},t[16]=a,t[17]=U,t[18]=le):le=t[18];let ue=le,de;t[19]!==O||t[20]!==a||t[21]!==H?(de=e=>{H&&(a(H.providerID,H.modelID,e),O(H.providerID,H.modelID,e||void 0),W())},t[19]=O,t[20]=a,t[21]=H,t[22]=de):de=t[22];let fe=de,pe;t[23]===_?pe=t[24]:(pe=_(`settings.agents.modelSelector.searchPlaceholder`),t[23]=_,t[24]=pe);let me;t[25]===_?me=t[26]:(me=_(`settings.agents.modelSelector.state.noModelsFound`),t[25]=_,t[26]=me);let he;t[27]===_?he=t[28]:(he=_(`settings.agents.modelSelector.section.favorites`),t[27]=_,t[28]=he);let ge;t[29]===_?ge=t[30]:(ge=_(`settings.agents.modelSelector.section.recent`),t[29]=_,t[30]=ge);let _e;t[31]===_?_e=t[32]:(_e=_(`settings.agents.modelSelector.keyboardHints`),t[31]=_,t[32]=_e);let ve;t[33]!==l||t[34]!==_?(ve=l||_(`settings.agents.modelSelector.notSelected`),t[33]=l,t[34]=_,t[35]=ve):ve=t[35];let ye;t[36]===_?ye=t[37]:(ye=_(`settings.agents.modelSelector.actions.favorite`),t[36]=_,t[37]=ye);let be;t[38]===_?be=t[39]:(be=_(`settings.agents.modelSelector.actions.unfavorite`),t[38]=_,t[39]=be);let xe;t[40]===_?xe=t[41]:(xe=_(`chat.modelControls.provider`),t[40]=_,t[41]=xe);let Se;t[42]===_?Se=t[43]:(Se=_(`chat.modelControls.capabilities`),t[42]=_,t[43]=Se);let G;t[44]===_?G=t[45]:(G=_(`chat.modelControls.capability.toolCalling`),t[44]=_,t[45]=G);let Ce;t[46]===_?Ce=t[47]:(Ce=_(`chat.modelControls.capability.reasoning`),t[46]=_,t[47]=Ce);let we;t[48]===_?we=t[49]:(we=_(`chat.modelControls.modality.image`),t[48]=_,t[49]=we);let K;t[50]===_?K=t[51]:(K=_(`chat.modelControls.modality.video`),t[50]=_,t[51]=K);let Te;t[52]===_?Te=t[53]:(Te=_(`chat.modelControls.modality.audio`),t[52]=_,t[53]=Te);let Ee;t[54]===_?Ee=t[55]:(Ee=_(`chat.modelControls.costPerMillion`),t[54]=_,t[55]=Ee);let De;t[56]===_?De=t[57]:(De=_(`chat.modelControls.costInput`),t[56]=_,t[57]=De);let Oe;t[58]===_?Oe=t[59]:(Oe=_(`chat.modelControls.costOutput`),t[58]=_,t[59]=Oe);let ke;t[60]!==pe||t[61]!==me||t[62]!==he||t[63]!==ge||t[64]!==_e||t[65]!==ve||t[66]!==ye||t[67]!==be||t[68]!==xe||t[69]!==Se||t[70]!==G||t[71]!==Ce||t[72]!==we||t[73]!==K||t[74]!==Te||t[75]!==Ee||t[76]!==De||t[77]!==Oe?(ke={searchPlaceholder:pe,noResults:me,favorites:he,recent:ge,keyboardHint:_e,notSelected:ve,favorite:ye,unfavorite:be,provider:xe,capabilities:Se,capabilityToolCalling:G,capabilityReasoning:Ce,modalityImage:we,modalityVideo:K,modalityAudio:Te,costPerMillion:Ee,costInput:De,costOutput:Oe},t[60]=pe,t[61]=me,t[62]=he,t[63]=ge,t[64]=_e,t[65]=ve,t[66]=ye,t[67]=be,t[68]=xe,t[69]=Se,t[70]=G,t[71]=Ce,t[72]=we,t[73]=K,t[74]=Te,t[75]=Ee,t[76]=De,t[77]=Oe,t[78]=ke):ke=t[78];let Ae=ke,Me;t[79]!==r||t[80]!==n?(Me=n&&r?{providerID:n,modelID:r}:null,t[79]=r,t[80]=n,t[81]=Me):Me=t[81];let Ne=Me,Fe;t[82]!==r||t[83]!==l||t[84]!==n||t[85]!==_?(Fe=n&&r?`${n}/${r}`:l||_(`settings.agents.modelSelector.notSelected`),t[82]=r,t[83]=l,t[84]=n,t[85]=_,t[86]=Fe):Fe=t[86];let J=Fe,Ie;t[87]!==_||t[88]!==i||t[89]!==U?(Ie=U?i||_(`chat.modelControls.default`):null,t[87]=_,t[88]=i,t[89]=U,t[90]=Ie):Ie=t[90];let Le=Ie,ze;t[91]!==r||t[92]!==n||t[93]!==i||t[94]!==U?(ze=(e,t)=>{if(!(!U||e!==n||t!==r))return i||void 0},t[91]=r,t[92]=n,t[93]=i,t[94]=U,t[95]=ze):ze=t[95];let Be=ze,Ve;t[96]!==O||t[97]!==a||t[98]!==U?(Ve=(e,t,n)=>{a(e,t,U?n??``:void 0),O(e,t,U&&n||void 0),W()},t[96]=O,t[97]=a,t[98]=U,t[99]=Ve):Ve=t[99];let He=Ve,Ue;t[100]!==oe||t[101]!==_||t[102]!==i||t[103]!==U?(Ue=(e,t)=>{let n=oe(e);if(!U||n.length===0)return null;let r=e.variant!==void 0&&n.includes(e.variant)?e.variant:void 0,a=t.isSelected?i:r??``;return(0,Q.jsxs)(`button`,{type:`button`,className:`flex shrink-0 items-center gap-0.5 rounded-md px-1.5 py-0.5 typography-micro font-medium text-muted-foreground hover:bg-interactive-hover hover:text-foreground`,onClick:t=>{t.preventDefault(),t.stopPropagation(),re(e)},"aria-label":_(`chat.modelControls.showThinkingModes`),children:[(0,Q.jsx)(`span`,{className:`max-w-24 truncate`,children:a||_(`chat.modelControls.default`)}),(0,Q.jsx)(X,{name:`arrow-right-s`,className:`size-3.5`})]})},t[100]=oe,t[101]=_,t[102]=i,t[103]=U,t[104]=Ue):Ue=t[104];let We=Ue,Ge=P?`max-h-none flex-1`:void 0,Ke=m&&(P?F:L),qe;t[105]===E?qe=t[106]:(qe=e=>E(e.providerID,e.modelID),t[105]=E,t[106]=qe);let Je;t[107]!==r||t[108]!==n||t[109]!==T||t[110]!==i?(Je=e=>T(e.providerID,e.modelID,e.providerID===n&&e.modelID===r?i||void 0:e.variant),t[107]=r,t[108]=n,t[109]=T,t[110]=i,t[111]=Je):Je=t[111];let Ye;t[112]!==c||t[113]!==s||t[114]!==j||t[115]!==S||t[116]!==ce||t[117]!==ue||t[118]!==w||t[119]!==Ae||t[120]!==k||t[121]!==x||t[122]!==M||t[123]!==We||t[124]!==V||t[125]!==Ne||t[126]!==Ge||t[127]!==Ke||t[128]!==qe||t[129]!==Je?(Ye=(0,Q.jsx)(sn,{providers:x,providerOrder:k,favoriteModels:j,recentModels:M,getMetadata:S,searchQuery:V,onSearchQueryChange:ne,onSelect:ce,labels:Ae,selectedModel:Ne,hiddenModels:w,allowedProviderIds:s,allowedModelIdsByProvider:c,includeNotSelected:!0,onSelectNone:ue,onEscape:W,maxHeightClassName:Ge,tooltipsEnabled:Ke,isFavorite:qe,onToggleFavorite:Je,renderRowEnd:We}),t[112]=c,t[113]=s,t[114]=j,t[115]=S,t[116]=ce,t[117]=ue,t[118]=w,t[119]=Ae,t[120]=k,t[121]=x,t[122]=M,t[123]=We,t[124]=V,t[125]=Ne,t[126]=Ge,t[127]=Ke,t[128]=qe,t[129]=Je,t[130]=Ye):Ye=t[130];let Y=Ye,Xe;t[131]!==oe||t[132]!==H?(Xe=H?oe(H):[],t[131]=oe,t[132]=H,t[133]=Xe):Xe=t[133];let Ze=Xe,Qe;bb0:{if(!H){Qe=``;break bb0}if(H.providerID===n&&H.modelID===r){Qe=i||``;break bb0}Qe=H.variant!==void 0&&Ze.includes(H.variant)?H.variant:``}let $e=Qe,et;t[134]!==fe||t[135]!==_||t[136]!==H||t[137]!==$e||t[138]!==Ze?(et=H?(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,Q.jsxs)(`button`,{type:`button`,className:`flex min-h-11 items-center gap-2 border-b border-border/40 px-3 text-left typography-ui-label font-medium text-foreground hover:bg-interactive-hover`,onClick:()=>re(null),"aria-label":_(`header.actions.backAria`),children:[(0,Q.jsx)(X,{name:`arrow-left`,className:`size-4`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:H.modelID})]}),(0,Q.jsx)(`div`,{className:`space-y-1 p-2`,role:`listbox`,"aria-label":_(`chat.modelControls.thinking`),children:[``,...Ze].map(e=>{let t=$e===e;return(0,Q.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t,className:q(`flex min-h-11 w-full items-center justify-between rounded-lg px-3 text-left typography-ui-label transition-colors`,t?`bg-interactive-selection text-interactive-selection-foreground`:`hover:bg-interactive-hover`),onClick:()=>fe(e),children:[(0,Q.jsx)(`span`,{className:`truncate`,children:e||_(`chat.modelControls.default`)}),t?(0,Q.jsx)(X,{name:`check`,className:`size-4 shrink-0`}):null]},e||`__default`)})})]}):null,t[134]=fe,t[135]=_,t[136]=H,t[137]=$e,t[138]=Ze,t[139]=et):et=t[139];let tt=et||Y;if(P){let e=v?ee:void 0,a=!v,l=!v&&`opacity-60 cursor-not-allowed`,u;t[140]!==o||t[141]!==l?(u=q(`flex w-full items-center justify-between gap-2 rounded-lg border border-border/40 bg-[var(--surface-elevated)] px-2 py-1.5 text-left`,l,o),t[140]=o,t[141]=l,t[142]=u):u=t[142];let d;t[143]!==v||t[144]!==y||t[145]!==r||t[146]!==n||t[147]!==g||t[148]!==_?(d=v?g&&(n||r)?(0,Q.jsx)(Jt,{modelId:r,providerId:n,className:`h-3.5 w-3.5 flex-shrink-0`}):g?(0,Q.jsx)(X,{name:`pencil-ai`,className:`h-3 w-3 text-muted-foreground`}):null:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(X,{name:`loader-4`,className:`h-3.5 w-3.5 animate-spin text-muted-foreground`}),(0,Q.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:_(y?`common.unavailable`:`common.loading`)})]}),t[143]=v,t[144]=y,t[145]=r,t[146]=n,t[147]=g,t[148]=_,t[149]=d):d=t[149];let f;t[150]!==v||t[151]!==J?(f=v?(0,Q.jsx)(`span`,{className:`typography-meta font-medium text-foreground truncate`,children:J}):null,t[150]=v,t[151]=J,t[152]=f):f=t[152];let p;t[153]!==v||t[154]!==Le?(p=v&&Le?(0,Q.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground`,children:Le}):null,t[153]=v,t[154]=Le,t[155]=p):p=t[155];let m;t[156]!==d||t[157]!==f||t[158]!==p?(m=(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[d,f,p]}),t[156]=d,t[157]=f,t[158]=p,t[159]=m):m=t[159];let h;t[160]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,Q.jsx)(X,{name:`arrow-down-s`,className:`h-3 w-3 flex-shrink-0 text-muted-foreground`}),t[160]=h):h=t[160];let b;t[161]!==e||t[162]!==a||t[163]!==u||t[164]!==m?(b=(0,Q.jsxs)(`button`,{type:`button`,onClick:e,disabled:a,className:u,children:[m,h]}),t[161]=e,t[162]=a,t[163]=u,t[164]=m,t[165]=b):b=t[165];let C;t[166]!==j||t[167]!==r||t[168]!==n||t[169]!==M||t[170]!==T||t[171]!==i?(C=(e,t)=>T(e,t,e===n&&t===r?i||void 0:j.find(n=>n.providerID===e&&n.modelID===t)?.variant??M.find(n=>n.providerID===e&&n.modelID===t)?.variant),t[166]=j,t[167]=r,t[168]=n,t[169]=M,t[170]=T,t[171]=i,t[172]=C):C=t[172];let D;t[173]!==c||t[174]!==s||t[175]!==j||t[176]!==S||t[177]!==He||t[178]!==w||t[179]!==E||t[180]!==F||t[181]!==r||t[182]!==n||t[183]!==k||t[184]!==x||t[185]!==M||t[186]!==Be||t[187]!==C||t[188]!==U?(D=(0,Q.jsx)(St,{open:F,onClose:W,selectedProviderID:n,selectedModelID:r,resolveSelectedVariant:Be,onSelect:He,providers:x,favoriteModels:j,recentModels:M,getMetadata:S,hiddenModels:w,allowedProviderIds:s,allowedModelIdsByProvider:c,providerOrder:k,variantSelectionEnabled:U,isFavorite:E,onToggleFavorite:C}),t[173]=c,t[174]=s,t[175]=j,t[176]=S,t[177]=He,t[178]=w,t[179]=E,t[180]=F,t[181]=r,t[182]=n,t[183]=k,t[184]=x,t[185]=M,t[186]=Be,t[187]=C,t[188]=U,t[189]=D):D=t[189];let O;return t[190]!==b||t[191]!==D?(O=(0,Q.jsxs)(Q.Fragment,{children:[b,D]}),t[190]=b,t[191]=D,t[192]=O):O=t[192],O}let nt=v&&L,rt=v?B:void 0,it=!v&&`opacity-60 cursor-not-allowed`,at;t[193]!==o||t[194]!==it?(at=q(`border-input data-[placeholder]:text-muted-foreground flex min-w-0 items-center justify-between gap-2 rounded-lg border bg-transparent px-2 py-2 typography-ui-label whitespace-nowrap shadow-none outline-none hover:bg-interactive-hover data-[popup-open]:bg-interactive-active h-6 w-fit`,it,o),t[193]=o,t[194]=it,t[195]=at):at=t[195];let ot;t[196]!==v||t[197]!==y||t[198]!==r||t[199]!==n||t[200]!==g||t[201]!==_||t[202]!==J||t[203]!==Le?(ot=v?(0,Q.jsxs)(Q.Fragment,{children:[g?n||r?(0,Q.jsx)(Jt,{modelId:r,providerId:n,className:`h-3.5 w-3.5 flex-shrink-0`}):(0,Q.jsx)(X,{name:`pencil-ai`,className:`h-3.5 w-3.5 flex-shrink-0 text-muted-foreground`}):null,(0,Q.jsx)(`span`,{className:`typography-ui-label min-w-0 flex-1 truncate text-left font-normal text-foreground`,children:J}),Le?(0,Q.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground`,children:Le}):null]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(X,{name:`loader-4`,className:`h-3.5 w-3.5 animate-spin text-muted-foreground flex-shrink-0`}),(0,Q.jsx)(`span`,{className:`typography-ui-label font-normal whitespace-nowrap text-muted-foreground`,children:_(y?`common.unavailable`:`common.loading`)})]}),t[196]=v,t[197]=y,t[198]=r,t[199]=n,t[200]=g,t[201]=_,t[202]=J,t[203]=Le,t[204]=ot):ot=t[204];let st;t[205]===Symbol.for(`react.memo_cache_sentinel`)?(st=(0,Q.jsx)(X,{name:`arrow-down-s`,className:`h-4 w-4 flex-shrink-0 text-muted-foreground/50`}),t[205]=st):st=t[205];let ct;t[206]!==at||t[207]!==ot?(ct=(0,Q.jsx)(Vt,{asChild:!0,children:(0,Q.jsxs)(`div`,{className:at,children:[ot,st]})}),t[206]=at,t[207]=ot,t[208]=ct):ct=t[208];let lt;t[209]!==h||t[210]!==tt?(lt=(0,Q.jsx)(Nt,{className:`w-[min(380px,calc(100vw-2rem))] p-0 flex flex-col`,align:`start`,portalToBody:h,children:tt}),t[209]=h,t[210]=tt,t[211]=lt):lt=t[211];let ut;return t[212]!==nt||t[213]!==rt||t[214]!==ct||t[215]!==lt?(ut=(0,Q.jsxs)(Pt,{open:nt,onOpenChange:rt,children:[ct,lt]}),t[212]=nt,t[213]=rt,t[214]=ct,t[215]=lt,t[216]=ut):ut=t[216],ut};function bi(e){return e.providers}function xi(e){return e.getModelMetadata}function Si(e){return e.isMobile}function Ci(e){return e.hiddenModels}function wi(e){return e.toggleFavoriteModel}function Ti(e){return e.isFavoriteModel}function Ei(e){return e.addRecentModel}function Di(e){return e.providerOrder}var Oi=e=>{let t=(0,Z.c)(41),{agentName:n,onChange:r,className:i,filter:a,dropdownPortalToBody:o,showIcon:s,agents:c}=e,l=o!==void 0&&o,u=s===void 0||s,{t:d}=Pe(),{isReady:f,isUnavailable:p}=At(),m=Re(ki),h=Ue(Ai),g=Re(ji),{data:_}=Ye(),v;t[0]===_?v=t[1]:(v=_===void 0?[]:_,t[0]=_,t[1]=v);let y=v,b;bb0:{if(c){b=c;break bb0}if(Array.isArray(m)&&m.length>0){b=m;break bb0}b=y}let x=b,S;if(t[2]!==a||t[3]!==x){let e=He(x);S=a?e.filter(a):e,t[2]=a,t[3]=x,t[4]=S}else S=t[4];let C=S,w=D(Mi),{isMobile:T}=Wt(),E=w||T,[O,k]=$.useState(!1),A;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(A=()=>{k(!0),Re.getState().refreshCatalogsOnPickerOpen({source:`agentSelector:mobilePanel`})},t[5]=A):A=t[5];let j=je(A),M=je(Ni),N=$.useId(),P,F;t[6]!==c||t[7]!==h||t[8]!==g||t[9]!==x.length?(P=()=>{c||x.length>0||(g(),h())},F=[c,x.length,g,h],t[6]=c,t[7]=h,t[8]=g,t[9]=x.length,t[10]=P,t[11]=F):(P=t[10],F=t[11]),$.useEffect(P,F);let I;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(I=()=>k(!1),t[12]=I):I=t[12];let L=I,R;t[13]===r?R=t[14]:(R=e=>{r(e)},t[13]=r,t[14]=R);let z=R,ee;t[15]!==n||t[16]!==C||t[17]!==z||t[18]!==E||t[19]!==O||t[20]!==N||t[21]!==d?(ee=()=>E?(0,Q.jsx)(Kt,{id:`mobile-agent-selector-sheet-${N}`,open:O,onOpenChange:e=>{e||L()},ariaLabel:d(`settings.commands.agentSelector.title`),closeAriaLabel:d(`mobile.surface.closeAria`),resizeAriaLabel:d(`mobile.sessions.sheet.resizeAria`),bodyClassName:`px-2`,children:(0,Q.jsxs)(nn,{useScrollShadow:!0,disableHorizontal:!0,preventOverscroll:!0,outerClassName:`min-h-0 flex-1`,className:`flex flex-col gap-1 overscroll-contain`,children:[(0,Q.jsxs)(`button`,{type:`button`,className:q(`grid w-full grid-cols-[1rem_minmax(0,1fr)_auto] items-center gap-x-2 rounded-lg border border-border/40 bg-background/95 px-2 py-1.5 text-left`,n?`text-foreground`:`bg-primary/10 text-primary`),onClick:()=>{z(``),L()},children:[(0,Q.jsx)(tt,{name:`default`,size:16}),(0,Q.jsx)(`span`,{className:q(`min-w-0 typography-meta`,n?`text-muted-foreground`:`font-medium`),children:d(`settings.commands.agentSelector.notSelected`)}),!n&&(0,Q.jsx)(`div`,{className:`h-2 w-2 rounded-full bg-primary`})]}),C.map(e=>{let t=e.name===n;return(0,Q.jsxs)(`button`,{type:`button`,className:q(`grid w-full grid-cols-[1rem_minmax(0,1fr)_auto] items-start gap-x-2 rounded-lg border border-border/40 bg-background/95 px-2 py-1.5 text-left`,t?`bg-primary/10 text-primary`:`text-foreground`),onClick:()=>{z(e.name),L()},children:[(0,Q.jsx)(tt,{name:e.name,size:16,className:`mt-1.5`}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`span`,{className:`typography-meta font-medium`,children:e.name}),e.description&&(0,Q.jsx)(`span`,{className:`mt-0.5 block whitespace-normal break-words typography-micro text-muted-foreground`,children:e.description})]}),t&&(0,Q.jsx)(`div`,{className:`mt-2 h-2 w-2 rounded-full bg-primary`})]},e.name)})]})}):null,t[15]=n,t[16]=C,t[17]=z,t[18]=E,t[19]=O,t[20]=N,t[21]=d,t[22]=ee):ee=t[22];let te=ee,B;t[23]!==n||t[24]!==C||t[25]!==i||t[26]!==l||t[27]!==z||t[28]!==M||t[29]!==E||t[30]!==f||t[31]!==p||t[32]!==j||t[33]!==u||t[34]!==d?(B=E?(0,Q.jsxs)(`button`,{type:`button`,onClick:f?j:void 0,disabled:!f,className:q(`flex w-full items-center justify-between gap-2 rounded-lg border border-border/40 bg-background/95 px-2 py-1.5 text-left`,!f&&`opacity-60 cursor-not-allowed`,i),children:[(0,Q.jsx)(`div`,{className:`flex items-center gap-2`,children:f?(0,Q.jsxs)(Q.Fragment,{children:[u?(0,Q.jsx)(tt,{name:n||`default`,size:14}):null,(0,Q.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:n||d(`settings.commands.agentSelector.selectAgentPlaceholder`)})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(X,{name:`loader-4`,className:`h-3.5 w-3.5 animate-spin text-muted-foreground`}),(0,Q.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:d(p?`common.unavailable`:`common.loading`)})]})}),(0,Q.jsx)(X,{name:`arrow-down-s`,className:`h-3 w-3 text-muted-foreground`})]}):f?(0,Q.jsxs)(Pt,{onOpenChange:M,children:[(0,Q.jsx)(Vt,{asChild:!0,children:(0,Q.jsxs)(`div`,{className:q(`flex items-center gap-2 px-2 rounded-lg bg-interactive-selection/20 border border-border/20 cursor-pointer hover:bg-interactive-hover/30 h-6 w-fit`,i),children:[u?(0,Q.jsx)(tt,{name:n||`default`,size:14}):null,(0,Q.jsx)(`span`,{className:`typography-micro font-medium whitespace-nowrap`,children:n||d(`settings.commands.agentSelector.notSelected`)}),(0,Q.jsx)(X,{name:`arrow-down-s`,className:`h-3 w-3 flex-shrink-0 text-muted-foreground`})]})}),(0,Q.jsxs)(Nt,{className:`max-w-[300px]`,portalToBody:l,children:[(0,Q.jsxs)(It,{className:`typography-meta`,onSelect:()=>z(``),children:[(0,Q.jsx)(tt,{name:`default`,size:14}),(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:d(`settings.commands.agentSelector.notSelected`)})]}),C.map(e=>(0,Q.jsxs)(It,{className:`typography-meta`,onSelect:()=>z(e.name),children:[(0,Q.jsx)(tt,{name:e.name,size:14}),(0,Q.jsx)(`span`,{className:`font-medium`,children:e.name})]},e.name))]})]}):(0,Q.jsxs)(`div`,{className:q(`flex items-center gap-2 px-2 rounded-lg bg-interactive-selection/20 border border-border/20 h-6 w-fit opacity-60`,i),children:[(0,Q.jsx)(X,{name:`loader-4`,className:`h-3 w-3 animate-spin text-muted-foreground flex-shrink-0`}),(0,Q.jsx)(`span`,{className:`typography-micro font-medium whitespace-nowrap text-muted-foreground`,children:d(p?`common.unavailable`:`common.loading`)})]}),t[23]=n,t[24]=C,t[25]=i,t[26]=l,t[27]=z,t[28]=M,t[29]=E,t[30]=f,t[31]=p,t[32]=j,t[33]=u,t[34]=d,t[35]=B):B=t[35];let V;t[36]===te?V=t[37]:(V=te(),t[36]=te,t[37]=V);let ne;return t[38]!==B||t[39]!==V?(ne=(0,Q.jsxs)(Q.Fragment,{children:[B,V]}),t[38]=B,t[39]=V,t[40]=ne):ne=t[40],ne};function ki(e){return e.agents}function Ai(e){return e.loadAgents}function ji(e){return e.loadAgents}function Mi(e){return e.isMobile}function Ni(e){e&&Re.getState().refreshCatalogsOnPickerOpen({source:`agentSelector:desktopMenu`})}var Pi=`/mcp/oauth/callback`,Fi=e=>{if(typeof window>`u`)return null;try{let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=t.length%4==0?``:`=`.repeat(4-t.length%4),r=window.atob(t+n),i=Uint8Array.from(r,e=>e.charCodeAt(0));return new TextDecoder().decode(i)}catch{return null}},Ii=e=>{let t=Ri(e.get(`state`));if(t)return t;let n=e.get(`server`);if(typeof n!=`string`||!n.trim())return null;let r=e.get(`directory`);return{name:n.trim(),directory:typeof r==`string`&&r.trim()?r.trim():null}},Li=e=>{let t=e.get(`state`);return typeof t==`string`&&t.trim()||null},Ri=e=>{if(typeof e!=`string`||!e.trim())return null;let t=Fi(e.trim());if(!t)return null;try{let e=JSON.parse(t);return e?.v!==1||typeof e.n!=`string`||!e.n.trim()?null:{name:e.n.trim(),directory:typeof e.d==`string`&&e.d.trim()?e.d.trim():null}}catch{return null}},zi=e=>typeof e==`object`&&!!e&&`updateStatus`in e&&typeof e.updateStatus==`function`,Bi=e=>{let t=document.createElement(`div`);t.className=`cm-vim-panel`;let n=In(e);if(!n)return{top:!1,dom:t};n.state.statusbar=t;let r=n.state.vimPlugin;return zi(r)&&r.updateStatus(),{top:!1,dom:t,destroy(){n.state.statusbar===t&&(n.state.statusbar=null)}}};function Vi(e){return e?[Fn(),Ce.of(Bi),oe()]:[]}var Hi={next:`Next match`,prev:`Previous match`,select:`Select all matches`,replace:`Replace`,replaceAll:`Replace all`,close:`Close`},Ui={case:`Match case`,re:`Regular expression`,word:`Match whole word`};function Wi(e){let t=e.querySelector(`.cm-search`);if(t){for(let[e,n]of Object.entries(Hi)){let r=t.querySelector(`button[name="${e}"]`);r&&!r.title&&(r.title=n)}for(let[e,n]of Object.entries(Ui)){let r=t.querySelector(`input[name="${e}"]`)?.parentElement;r&&!r.title&&(r.title=n)}}}var Gi=new WeakMap;function Ki(e,t){let n=An(e.state);if(!n.valid)return Gi.delete(e),0;let r=Gi.get(e);if(!t&&r?.doc===e.state.doc&&r.query.eq(n))return r.total;let i=n.getCursor(e.state),a=0;for(let e=i.next();!e.done;e=i.next())a+=1;return Gi.set(e,{query:n,doc:e.state.doc,total:a}),a}function qi(e){let t=An(e.state);if(!t.valid)return 0;let n=e.state.selection.main,r=t.getCursor(e.state),i=0,a=0;for(let e=r.next();!e.done;e=r.next()){let t=e.value;if(i+=1,a===0&&(a=i),n.from===t.from&&n.to===t.to||n.from<t.to&&n.to>t.from||t.from>=n.head)return i}return a}function Ji(e,t,n=!1){let r=e.querySelector(`.cm-search`);if(!r)return;let i=r.querySelector(`.cm-search-message`);if(!i){i=document.createElement(`span`),i.className=`cm-search-message`,i.setAttribute(`aria-live`,`polite`);let e=r.querySelector(`button[name="next"]`),t=e?.parentNode===r?e:r.firstChild;r.insertBefore(i,t)}let a=Ki(t,n),o=a===0?0:qi(t);i.textContent=a===0?``:`${o}/${a}`}var Yi=new G,Xi=new G,Zi=new G,Qi=new G,$i=new G,ea=new G,ta=new G,na=(e=>e)(kn.filter(e=>e.run!==On)),ra=ie,ia=Mn,aa=Nn,oa=class extends ae{id;containerMap;constructor(e,t){super(),this.id=e,this.containerMap=t}toDOM(){let e=this.containerMap.get(this.id);return e||(e=document.createElement(`div`),e.className=`yuri-block-widget`,e.dataset.widgetId=this.id,this.containerMap.set(this.id,e)),e}eq(e){return e.id===this.id}destroy(){}},sa=(e,t)=>!e||e.length===0?[]:_e.define({create(n){let r=new Se,i=[...e].sort((e,t)=>e.afterLine-t.afterLine);for(let e of i){let i=n.doc.lines;if(e.afterLine>i)continue;let a=n.doc.line(e.afterLine);r.add(a.to,a.to,le.widget({widget:new oa(e.id,t),block:!0,side:1}))}return r.finish()},update(e,t){return e.map(t.changes)},provide:e=>ce.decorations.from(e)}),ca=e=>{if(!e)return[];let t=Math.max(1,e.start),n=Math.max(t,e.end);return ue.fromClass(class{decorations;constructor(e){this.decorations=this.build(e)}update(e){(e.docChanged||e.viewportChanged)&&(this.decorations=this.build(e.view))}build(e){let r=new Se;for(let i=t;i<=n&&i<=e.state.doc.lines;i+=1){let t=e.state.doc.line(i);r.add(t.from,t.from,le.line({class:`yuri-cm-selected-line`}))}return r.finish()}},{decorations:e=>e.decorations})};function la({value:e,onChange:t,extensions:n,className:r,readOnly:i,lineNumbersConfig:a,highlightLines:o,onViewReady:s,onViewDestroy:c,blockWidgets:l,enableSearch:u,searchOpen:d,onSearchOpenChange:f,vimMode:p}){let m=$.useRef(null),h=$.useRef(null),g=$.useRef(e),_=$.useRef(t),v=$.useRef(s),y=$.useRef(c),b=$.useRef(f),x=$.useRef(l),S=$.useRef(p),C=$.useRef(new Map),[w,T]=$.useState([]),E=$.useCallback(e=>{let t=(e??[]).map(e=>{let t=C.current.get(e.id);return t?{id:e.id,content:e.content,container:t}:null}).filter(e=>e!==null);T(e=>e.length===t.length&&e.every((e,n)=>{let r=t[n];return e.id===r.id&&e.content===r.content&&e.container===r.container})?e:t)},[]),D=$.useCallback(e=>{let t=m.current,n=e??h.current;if(!t||!n)return;let r=n.dom.querySelector(`.cm-gutters`),i=r instanceof HTMLElement?r.getBoundingClientRect().width:0;t.style.setProperty(`--yuri-editor-gutter-width`,`${i}px`)},[]);return $.useEffect(()=>{g.current=e},[e]),$.useEffect(()=>{_.current=t},[t]),$.useEffect(()=>{v.current=s,y.current=c},[s,c]),$.useEffect(()=>{b.current=f},[f]),$.useEffect(()=>{x.current=l,E(l)},[l,E]),$.useEffect(()=>{if(!m.current)return;let e=(()=>{if(typeof document>`u`)return null;let e=document.querySelector(`meta[name="csp-nonce"]`)?.getAttribute(`content`);if(e)return e;let t=window.__YURI_CSP_NONCE__;return typeof t==`string`&&t.length>0?t:null})(),t=be.create({doc:g.current,extensions:[...e?[ce.cspNonce.of(e)]:[],fe({fixed:!0}),Yi.of(pe(a)),En(),ve.of(` `),ta.of(Vi(p)),de.of([Tn,...wn,...Dn]),ce.updateListener.of(e=>{D(e.view),(e.viewportChanged||e.geometryChanged)&&E(x.current);let t=jn(e.startState),n=jn(e.state);t!==n&&b.current?.(n);let r=!An(e.startState).eq(An(e.state));if(n&&(t!==n||r||e.docChanged||e.selectionSet)&&Ji(e.view.dom,e.view,t!==n||r||e.docChanged),!e.docChanged)return;let i=e.state.doc.toString();g.current=i,_.current(i),E(x.current)}),Xi.of(ce.editable.of(!i)),Zi.of(n??[]),Qi.of(ca(o)),$i.of(sa(l,C.current)),ea.of(u?[Pn({top:!0}),de.of(na)]:[])]});return h.current=new ce({state:t,parent:m.current}),ra(h.current,h.current.state.doc.length,200),h.current.requestMeasure(),requestAnimationFrame(()=>{D(h.current),E(x.current)}),h.current&&v.current?.(h.current),()=>{y.current?.(),h.current?.destroy(),h.current=null,T([])}},[x,D,E]),$.useEffect(()=>{let e=h.current;e&&(e.dispatch({effects:[Yi.reconfigure(pe(a)),Xi.reconfigure(ce.editable.of(!i)),Zi.reconfigure(n??[]),Qi.reconfigure(ca(o)),$i.reconfigure(sa(l,C.current)),ea.reconfigure(u?[Pn({top:!0}),de.of(na)]:[])]}),ra(e,e.state.doc.length,200),e.requestMeasure(),requestAnimationFrame(()=>{D(e),E(x.current)}))},[n,o,a,i,l,u,D,E]),$.useEffect(()=>{let e=h.current;if(!e){S.current=p;return}S.current!==p&&(S.current=p,e.dispatch({effects:ta.reconfigure(Vi(p))}))},[p]),$.useEffect(()=>{let e=h.current;!e||u===!1||(d?(ia(e),requestAnimationFrame(()=>{Wi(e.dom),Ji(e.dom,e,!0)})):aa(e))},[d,u]),$.useEffect(()=>{let t=h.current;if(!t)return;let n=t.state.doc.toString();n!==e&&(t.dispatch({changes:{from:0,to:n.length,insert:e}}),ra(t,t.state.doc.length,300),t.requestMeasure(),requestAnimationFrame(()=>D(t)))},[e,D]),(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{ref:m,className:q(`h-full w-full`,`[&_.cm-editor]:h-full [&_.cm-editor]:w-full`,`[&_.cm-scroller]:font-mono [&_.cm-scroller]:text-[var(--text-code)] [&_.cm-scroller]:leading-6`,`[&_.cm-lineNumbers]:text-[var(--tools-edit-line-number)]`,r)}),w.map(e=>(0,vi.createPortal)(e.content,e.container,e.id))]})}var ua=he.define(Ae),da=De.data.of({commentTokens:{line:`//`,block:{open:`/*`,close:`*/`}}});function fa(e){let t=e.trim().toLowerCase();switch(t){case`bash`:case`sh`:case`zsh`:case`shell`:case`shellsession`:case`console`:return ua;case`json`:case`jsonc`:case`json5`:return Ee().language;case`js`:case`javascript`:return K().language;case`jsx`:return K({jsx:!0}).language;case`ts`:case`typescript`:return K({typescript:!0}).language;case`tsx`:return K({typescript:!0,jsx:!0}).language;case`html`:return Te().language;case`css`:return we().language;case`py`:case`python`:return ke().language;case`md`:case`markdown`:case`mdown`:case`mkd`:return Oe().language;case`heex`:case`eex`:case`leex`:return Te().language;default:return ye.matchLanguageName(Ln,t,!0)}}var pa=e=>e.split(`/`).pop()?.toLowerCase()??``,ma=e=>{let t=pa(e);return t?ye.matchFilename(Ln,t):null},ha=()=>W(me.define([{tag:[U.heading1,U.heading2,U.heading3,U.heading4,U.heading5,U.heading6],fontWeight:`600`},{tag:U.strong,fontWeight:`600`},{tag:U.emphasis,fontStyle:`italic`},{tag:U.strikethrough,textDecoration:`line-through`},{tag:[U.link,U.url],color:`var(--markdown-link, currentColor)`,textDecoration:`underline`},{tag:U.monospace,color:`var(--markdown-inline-code, currentColor)`,backgroundColor:`var(--markdown-inline-code-bg, transparent)`},{tag:U.quote,color:`var(--markdown-blockquote, currentColor)`,fontStyle:`italic`},{tag:U.list,color:`color-mix(in srgb, var(--muted-foreground) 40%, var(--foreground) 60%)`},{tag:U.heading,color:`var(--markdown-heading1, currentColor)`}]));function ga(e){let t=e.toLowerCase();switch(pa(t)){case`makefile`:case`gnumakefile`:return ua}let n=t.lastIndexOf(`.`),r=n>=0?t.slice(n+1):``;switch(r){case`ts`:case`tsx`:case`mts`:case`cts`:return K({typescript:!0,jsx:r===`tsx`});case`js`:case`jsx`:case`mjs`:case`cjs`:return K({typescript:!1,jsx:r===`jsx`});case`jsonc`:case`json5`:return[Ee(),da];case`json`:case`jsonl`:case`ndjson`:case`geojson`:return Ee();case`css`:case`scss`:case`sass`:case`less`:return we();case`html`:case`htm`:case`xml`:case`drawio`:case`dio`:return Te();case`md`:case`mdx`:case`markdown`:case`mdown`:case`mkd`:return[Oe({codeLanguages:fa}),ha()];case`sh`:case`bash`:case`zsh`:case`fish`:case`env`:return ua;case`py`:case`pyw`:case`pyi`:return ke();default:return null}}async function _a(e){let t=ma(e);if(!t)return null;if(t.support)return t.support;try{return await t.load()}catch{return null}}function va(e,t){let n=e.metadata.variant===`dark`,r=e.config?.fonts?.mono||`monospace`,i=e.colors.syntax.highlights||{},a=e.colors.syntax.tokens||{},o=t?.fontSize?`${t.fontSize}px`:`var(--text-code)`,s=ce.theme({"&":{backgroundColor:`var(--background)`,color:e.colors.syntax.base.foreground,fontSize:o,lineHeight:`1.5`,position:`relative`},".cm-scroller":{fontFamily:r,backgroundColor:`var(--background)`},".cm-comment":{color:e.colors.syntax.base.comment},".cm-keyword":{color:e.colors.syntax.base.keyword},".cm-string":{color:e.colors.syntax.base.string},".cm-string-2":{color:a.stringEscape||e.colors.syntax.base.string},".cm-number":{color:e.colors.syntax.base.number},".cm-operator":{color:e.colors.syntax.base.operator},".cm-punctuation":{color:a.punctuation||e.colors.syntax.base.comment},".cm-atom":{color:a.boolean||e.colors.syntax.base.number},".cm-builtin":{color:a.functionCall||e.colors.syntax.base.function},".cm-def":{color:a.variableGlobal||e.colors.syntax.base.variable},".cm-attribute":{color:a.variableOther||a.variableProperty||e.colors.syntax.base.operator},".cm-meta":{color:e.colors.syntax.base.comment},".cm-property":{color:a.variableProperty||e.colors.syntax.base.keyword},".cm-variable":{color:e.colors.syntax.base.variable},".cm-variable-2":{color:a.variableOther||e.colors.syntax.base.function},".cm-variable-3":{color:a.variableGlobal||e.colors.syntax.base.type},".cm-tag":{color:a.tag||e.colors.syntax.base.keyword},".cm-link":{color:a.url||e.colors.syntax.base.keyword,textDecoration:`underline`},".cm-content":{caretColor:e.colors.interactive.cursor},".cm-cursor, .cm-dropCursor":{borderLeftColor:e.colors.interactive.cursor},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:e.colors.interactive.selection},".cm-gutters":{backgroundColor:`var(--background)`,color:i.lineNumber||e.colors.syntax.base.comment,borderRight:`1px solid ${e.colors.interactive.border}`,position:`sticky`,paddingRight:`8px`,left:0,zIndex:2,boxShadow:`0 0 0 var(--background)`},".cm-gutter":{backgroundColor:`var(--background)`},".cm-gutterElement":{backgroundColor:`var(--background)`},".cm-lineNumbers":{backgroundColor:`var(--background)`},".cm-lineNumbers .cm-gutterElement":{paddingLeft:`8px`,paddingRight:`8px`,minWidth:`42px`},".cm-activeLineGutter":{color:i.lineNumberActive||e.colors.syntax.base.foreground},".cm-activeLine":{backgroundColor:e.colors.surface.overlay},".cm-foldPlaceholder":{backgroundColor:e.colors.surface.muted,color:e.colors.surface.foreground,borderColor:e.colors.interactive.border},".cm-panels":{backgroundColor:`transparent`,color:e.colors.surface.foreground,position:`absolute`,top:`0`,right:`0`,left:`auto`,width:`auto`,zIndex:10,pointerEvents:`none`},".cm-panels-top":{borderBottom:`none`,position:`absolute`,top:`6px`,right:`14px`,left:`auto`,width:`auto`},".cm-panels-bottom":{position:`static`,width:`100%`,pointerEvents:`auto`},".cm-panels-bottom .cm-vim-panel":{borderTop:`1px solid ${e.colors.interactive.border}`,backgroundColor:e.colors.surface.elevated,color:e.colors.surface.mutedForeground,fontFamily:`var(--font-mono)`,fontSize:`12px`,minHeight:`22px`,padding:`2px 8px`},".cm-panel.cm-search":{pointerEvents:`auto`,padding:`4px`,backgroundColor:`color-mix(in srgb, ${e.colors.surface.elevated} 85%, transparent)`,border:`1px solid ${e.colors.interactive.border}`,borderRadius:`10px`,boxShadow:`0 2px 8px color-mix(in srgb, ${e.colors.surface.background} 60%, transparent)`,width:`auto`,minWidth:`360px`,maxWidth:`480px`},".cm-search":{display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:`0`,width:`100%`,color:e.colors.surface.foreground,fontFamily:`inherit`,fontSize:`13px`,lineHeight:`1`},".cm-search br":{display:`none`},".cm-search .cm-textfield":{appearance:`none`,height:`26px`,margin:0,padding:`0 8px`,borderRadius:`6px !important`,border:`1px solid ${e.colors.interactive.border}`,backgroundColor:e.colors.surface.background,color:e.colors.surface.foreground,fontFamily:`inherit`,fontSize:`12px`,lineHeight:`1`,outline:`none`,transition:`border-color 150ms ease`},".cm-search .cm-textfield::placeholder":{color:e.colors.surface.mutedForeground,opacity:1},".cm-search .cm-textfield:focus":{borderColor:e.colors.primary.base},'.cm-search .cm-textfield[name="search"]':{order:1,flex:`1 1 120px`,maxWidth:`calc(100% - 142px)`,minWidth:`100px`},".cm-search label":{order:2,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:`26px`,height:`26px`,minWidth:`26px`,flexShrink:`0`,margin:0,marginLeft:`1px`,padding:0,borderRadius:`4px`,border:`1px solid transparent`,backgroundColor:`transparent`,color:`transparent`,cursor:`pointer`,userSelect:`none`,fontSize:`1px`,lineHeight:`0`,overflow:`hidden`,position:`relative`,transition:`background-color 120ms ease, border-color 120ms ease`},".cm-search label:hover":{backgroundColor:e.colors.interactive.hover},'.cm-search label:has(input[type="checkbox"]:checked)':{backgroundColor:e.colors.interactive.hover,borderColor:e.colors.interactive.border},'.cm-search [type="checkbox"]':{appearance:`none`,WebkitAppearance:`none`,width:`0`,height:`0`,margin:`0`,padding:`0`,border:`none`,position:`absolute`,opacity:`0`,pointerEvents:`none`},".cm-search label::after":{position:`absolute`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,fontSize:`13px`,fontWeight:`600`,lineHeight:`1`,fontFamily:`inherit`,color:e.colors.surface.mutedForeground,pointerEvents:`none`},".cm-search label:hover::after":{color:e.colors.surface.foreground},'.cm-search label:has(input[type="checkbox"]:checked)::after':{color:e.colors.surface.foreground},'.cm-search label:has(input[name="case"])::after':{content:`"Aa"`,fontSize:`12px`,letterSpacing:`-0.5px`},'.cm-search label:has(input[name="re"])::after':{content:`".*"`,fontSize:`13px`,fontFamily:`monospace`},'.cm-search label:has(input[name="word"])::after':{content:`"ab"`,fontSize:`12px`,textDecoration:`underline`,textUnderlineOffset:`2px`},".cm-search .cm-search-message":{order:3,color:e.colors.surface.mutedForeground,backgroundColor:`transparent`,border:`none`,borderRadius:`0`,padding:`0 6px`,fontSize:`11px`,whiteSpace:`nowrap`,lineHeight:`26px`},".cm-search .cm-button":{appearance:`none`,WebkitAppearance:`none`,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:`26px`,height:`26px`,minWidth:`26px`,flexShrink:`0`,margin:0,marginLeft:`1px`,padding:0,borderRadius:`4px`,border:`none`,backgroundColor:`transparent`,backgroundImage:`none`,color:`transparent`,cursor:`pointer`,fontSize:`1px`,fontWeight:`400`,lineHeight:`0`,overflow:`hidden`,position:`relative`,boxShadow:`none`,transition:`background-color 120ms ease`},".cm-search .cm-button::after":{position:`absolute`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,fontSize:`15px`,lineHeight:`1`,color:e.colors.surface.mutedForeground,pointerEvents:`none`},".cm-search .cm-button:hover":{backgroundColor:e.colors.interactive.hover},".cm-search .cm-button:hover::after":{color:e.colors.surface.foreground},".cm-search .cm-button:active":{backgroundColor:e.colors.interactive.active},".cm-search .cm-button:focus-visible":{outline:`none`,boxShadow:`0 0 0 1px ${e.colors.interactive.focusRing}`},".cm-search .cm-button:disabled":{opacity:.4,cursor:`default`,pointerEvents:`none`},'.cm-search .cm-button[name="prev"]':{order:21,marginTop:`2px`},'.cm-search .cm-button[name="prev"]::after':{content:`"↑"`},'.cm-search .cm-button[name="next"]':{order:22,marginTop:`2px`},'.cm-search .cm-button[name="next"]::after':{content:`"↓"`},'.cm-search .cm-button[name="select"]':{order:23,marginTop:`2px`},'.cm-search .cm-button[name="select"]::after':{content:`"≡"`,fontSize:`17px`},'.cm-panel.cm-search button[name="close"]':{order:5,appearance:`none`,WebkitAppearance:`none`,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:`26px`,height:`26px`,minWidth:`26px`,flexShrink:`0`,margin:`0 0 0 auto`,padding:`0`,borderRadius:`4px`,border:`none`,backgroundColor:`transparent`,backgroundImage:`none`,color:e.colors.surface.mutedForeground,cursor:`pointer`,fontSize:`16px`,lineHeight:`1`,boxShadow:`none`,position:`relative`,overflow:`visible`,transition:`background-color 120ms ease, color 120ms ease`},'.cm-panel.cm-search button[name="close"]:hover':{backgroundColor:e.colors.interactive.hover,color:e.colors.surface.foreground},'.cm-search .cm-button[name="replace"]':{order:24,marginTop:`2px`},'.cm-search .cm-button[name="replace"]::after':{content:`"⇄"`},'.cm-search .cm-button[name="replaceAll"], .cm-search .cm-button[name="replace-all"]':{order:25,marginTop:`2px`},'.cm-search .cm-button[name="replaceAll"]::after, .cm-search .cm-button[name="replace-all"]::after':{content:`"⇉"`},'.cm-search .cm-textfield[name="replace"]':{order:20,flex:`1 1 100%`,maxWidth:`calc(100% - 142px)`,minWidth:`80px`,marginTop:`2px`},".cm-searchMatch":{backgroundColor:e.colors.status.infoBackground,boxShadow:`inset 0 0 0 1px ${e.colors.status.infoBorder}`,borderRadius:`2px`},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:e.colors.interactive.selection,color:e.colors.interactive.selectionForeground,boxShadow:`inset 0 0 0 1px ${e.colors.interactive.borderFocus}`},"&.cm-focused":{outline:`none`}},{dark:n}),c=me.define([{tag:[U.comment,U.docComment,U.meta,U.documentMeta],class:`cm-comment`},{tag:[U.keyword,U.controlKeyword,U.moduleKeyword,U.definitionKeyword,U.modifier],class:`cm-keyword`},{tag:[U.operatorKeyword,U.operator,U.derefOperator,U.updateOperator,U.definitionOperator,U.typeOperator,U.controlOperator,U.logicOperator,U.bitwiseOperator,U.arithmeticOperator,U.compareOperator],class:`cm-operator`},{tag:[U.punctuation,U.separator,U.bracket,U.paren,U.brace,U.squareBracket,U.angleBracket],class:`cm-punctuation`},{tag:[U.string,U.regexp,U.attributeValue,U.special(U.string),U.monospace],class:`cm-string`},{tag:U.escape,class:`cm-string-2`},{tag:[U.number,U.bool,U.atom,U.null,U.self],class:`cm-number`},{tag:[U.function(U.variableName),U.function(U.definition(U.variableName)),U.function(U.propertyName),U.standard(U.variableName),U.special(U.variableName)],class:`cm-builtin`},{tag:U.definition(U.variableName),class:`cm-def`},{tag:[U.variableName,U.local(U.variableName),U.constant(U.variableName),U.literal],class:`cm-variable`},{tag:U.propertyName,class:`cm-property`},{tag:U.attributeName,class:`cm-attribute`},{tag:[U.className,U.typeName,U.namespace],class:`cm-variable-3`},{tag:[U.tagName,U.labelName,U.annotation,U.macroName],class:`cm-tag`},{tag:U.link,class:`cm-link`},{tag:[U.heading,U.heading1,U.heading2,U.heading3,U.heading4,U.heading5,U.heading6],class:`cm-keyword`}]),l=me.define([{tag:[U.comment,U.docComment,U.meta,U.documentMeta],color:e.colors.syntax.base.comment},{tag:[U.keyword,U.controlKeyword,U.moduleKeyword,U.definitionKeyword,U.modifier],color:e.colors.syntax.base.keyword},{tag:[U.operatorKeyword,U.operator,U.derefOperator,U.updateOperator,U.definitionOperator,U.typeOperator,U.controlOperator,U.logicOperator,U.bitwiseOperator,U.arithmeticOperator,U.compareOperator],color:e.colors.syntax.base.operator},{tag:[U.string,U.regexp,U.attributeValue,U.special(U.string),U.monospace],color:e.colors.syntax.base.string},{tag:U.escape,color:a.stringEscape||e.colors.syntax.base.string},{tag:[U.number,U.bool,U.atom,U.null,U.self],color:e.colors.syntax.base.number},{tag:[U.function(U.variableName),U.function(U.definition(U.variableName)),U.function(U.propertyName),U.standard(U.variableName),U.special(U.variableName)],color:e.colors.syntax.base.function},{tag:U.definition(U.variableName),color:a.variableGlobal||e.colors.syntax.base.variable},{tag:[U.variableName,U.local(U.variableName),U.constant(U.variableName),U.literal],color:e.colors.syntax.base.variable},{tag:U.propertyName,color:a.variableProperty||e.colors.syntax.base.variable},{tag:U.attributeName,color:a.variableOther||e.colors.syntax.base.variable},{tag:[U.className,U.typeName,U.namespace],color:e.colors.syntax.base.type},{tag:[U.tagName,U.labelName,U.annotation,U.macroName],color:a.tag||e.colors.syntax.base.keyword},{tag:U.link,color:a.url||e.colors.syntax.base.function,textDecoration:`underline`},{tag:[U.punctuation,U.separator,U.bracket,U.paren,U.brace,U.squareBracket,U.angleBracket],color:a.punctuation||e.colors.syntax.base.comment}]);return t?.syntaxColors===!1?[s]:[s,W(ge,{fallback:!0}),W(se),W(c),W(l)]}var ya=180,ba=xe.define(),xa=1,Sa=2,Ca=4,wa=new Map,Ta=(e,t)=>{let n=`${e}|${t}`,r=wa.get(n);if(r)return r;let i=``;e&&(i+=`color:${e};`),t&xa&&(i+=`font-style:italic;`),t&Sa&&(i+=`font-weight:bold;`),t&Ca&&(i+=`text-decoration:underline;`);let a=le.mark({attributes:{style:i}});return wa.set(n,a),a},Ea=(e,t)=>{let n=new Se,r=e.state.doc,i=Math.min(t.length,r.lines);for(let e=0;e<i;e+=1){let i=t[e];if(!i||i.length===0)continue;let a=r.line(e+1),o=a.from;for(let[e,t,r]of i){if(e<=0)continue;let i=o,s=Math.min(o+e,a.to);o+=e,!(s<=i)&&(!t&&!r||n.add(i,s,Ta(t,r)))}}return n.finish()},Da=_e.define({create(){return le.none},update(e,t){let n=e.map(t.changes);for(let e of t.effects)e.is(ba)&&(n=e.value);return n},provide:e=>ce.decorations.from(e)}),Oa=e=>ue.fromClass(class{timer;generation=0;abortController;constructor(e){this.tokenize(e)}update(e){e.docChanged&&this.schedule(e.view)}schedule(e){this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.timer=void 0,this.tokenize(e)},ya)}async tokenize(t){let n=++this.generation;this.abortController?.abort();let r=new AbortController;this.abortController=r;let i=t.state.doc.toString(),a=await fn(i,e.language,e.themeName,e.theme,{signal:r.signal,priority:`visible`});a&&(r.signal.aborted||n===this.generation&&t.state.doc.length===i.length&&t.dispatch({effects:ba.of(Ea(t,a))}))}destroy(){this.timer&&clearTimeout(this.timer),this.abortController?.abort(),this.abortController=void 0}}),ka=e=>[Da,Oa(e)],Aa=e=>{let t=(0,Z.c)(11),{currentMode:n,onToggle:r}=e,i=n===`preview`,a=i?`Switch to edit mode`:`Switch to preview mode`,o=i?`Edit`:`Preview`,s;t[0]===i?s=t[1]:(s=i?(0,Q.jsx)(X,{name:`eye`,className:`size-4`,"aria-hidden":`true`}):(0,Q.jsx)(X,{name:`eye-off`,className:`size-4`,"aria-hidden":`true`}),t[0]=i,t[1]=s);let c;t[2]!==a||t[3]!==r||t[4]!==s?(c=(0,Q.jsx)(_t,{asChild:!0,children:(0,Q.jsx)(J,{variant:`ghost`,size:`sm`,onClick:r,"aria-label":a,className:`h-5 w-5 p-0`,children:s})}),t[2]=a,t[3]=r,t[4]=s,t[5]=c):c=t[5];let l;t[6]===o?l=t[7]:(l=(0,Q.jsx)(vt,{sideOffset:8,children:o}),t[6]=o,t[7]=l);let u;return t[8]!==c||t[9]!==l?(u=(0,Q.jsxs)(yt,{children:[c,l]}),t[8]=c,t[9]=l,t[10]=u):u=t[10],u},ja=_()(y(v((e,t)=>({selectedProfileId:null,defaultGitIdentityId:null,profiles:[],globalIdentity:null,discoveredCredentials:[],isLoading:!1,setSelectedProfile:t=>{e({selectedProfileId:t})},loadProfiles:async()=>{e({isLoading:!0});let n=t().profiles;try{return e({profiles:await ut(),isLoading:!1}),!0}catch(t){return console.error(`Failed to load git identity profiles:`,t),e({profiles:n,isLoading:!1}),!1}},loadGlobalIdentity:async()=>{try{let t=await dt();return t&&t.userName&&t.userEmail?e({globalIdentity:{id:`global`,name:`Global Identity`,userName:t.userName,userEmail:t.userEmail,authType:t.sshCommand?`ssh`:void 0,sshKey:t.sshCommand?t.sshCommand.replace(`ssh -i `,``):null,color:`info`,icon:`house`}}):e({globalIdentity:null}),!0}catch(t){return console.error(`Failed to load global git identity:`,t),e({globalIdentity:null}),!1}},loadDiscoveredCredentials:async()=>{try{return e({discoveredCredentials:await ht()}),!0}catch(t){return console.error(`Failed to discover git credentials:`,t),e({discoveredCredentials:[]}),!1}},loadDefaultGitIdentityId:async()=>{let t=e=>{if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null};try{let n=null;if(n===null){let e=g()?.settings;if(e)try{n=t(((await e.load())?.settings||{}).defaultGitIdentityId)}catch{}}if(n===null)try{let e=await a(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});e.ok&&(n=t((await e.json().catch(()=>null))?.defaultGitIdentityId))}catch{}return e({defaultGitIdentityId:n}),!0}catch(e){return console.error(`Failed to load default git identity setting:`,e),!1}},setDefaultGitIdentityId:async t=>{try{let n=typeof t==`string`?t.trim():``,r=n.length>0?n:``;return await k({defaultGitIdentityId:r}),e({defaultGitIdentityId:r.length>0?r:null}),!0}catch(e){return console.error(`Failed to save default git identity setting:`,e),!1}},createProfile:async e=>{try{let n={...e,id:e.id||`profile-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,color:e.color||`keyword`,icon:e.icon||`branch`};return await mt(n),await t().loadProfiles(),!0}catch(e){return console.error(`Failed to create git identity profile:`,e),!1}},updateProfile:async(e,n)=>{try{let r=t().profiles.find(t=>t.id===e);if(!r)throw Error(`Profile not found`);let i={...r,...n};return await lt(e,i),await t().loadProfiles(),!0}catch(e){return console.error(`Failed to update git identity profile:`,e),!1}},deleteProfile:async n=>{try{return await ft(n),t().selectedProfileId===n&&e({selectedProfileId:null}),await t().loadProfiles(),!0}catch(e){return console.error(`Failed to delete git identity profile:`,e),!1}},getProfileById:e=>{let{profiles:n,globalIdentity:r}=t();return e===`global`?r||void 0:n.find(t=>t.id===e)},getUnimportedCredentials:()=>{let{profiles:e,discoveredCredentials:n}=t();return n.filter(t=>!e.some(e=>e.authType===`token`&&e.host===t.host))}}),{name:`git-identities-store`,storage:O(),partialize:e=>({selectedProfileId:e.selectedProfileId})}),{name:`git-identities-store`}));typeof window<`u`&&(window.__zustand_git_identities_store__=ja);var Ma=`w-full max-w-[30rem]`,Na=e=>{let t=(0,Z.c)(23),{title:n,description:r,settingsItem:i,titleAccessory:a,headerAction:o,children:s,className:c,contentClassName:l}=e,u;t[0]===n?u=t[1]:(u=(0,Q.jsx)(`span`,{className:`truncate`,children:n}),t[0]=n,t[1]=u);let d;t[2]!==u||t[3]!==a?(d=(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[u,a]}),t[2]=u,t[3]=a,t[4]=d):d=t[4];let f;t[5]===o?f=t[6]:(f=o?(0,Q.jsx)(`div`,{className:`shrink-0`,children:o}):null,t[5]=o,t[6]=f);let p;t[7]!==d||t[8]!==f?(p=(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[d,f]}),t[7]=d,t[8]=f,t[9]=p):p=t[9];let m;t[10]===l?m=t[11]:(m=q(`yuri-settings-group-row`,l),t[10]=l,t[11]=m);let h;t[12]!==s||t[13]!==m?(h=(0,Q.jsx)(`div`,{className:m,children:s}),t[12]=s,t[13]=m,t[14]=h):h=t[14];let g;t[15]!==r||t[16]!==p||t[17]!==h?(g=(0,Q.jsx)(_n,{className:`yuri-settings-detail-group`,label:p,description:r,children:h}),t[15]=r,t[16]=p,t[17]=h,t[18]=g):g=t[18];let _;return t[19]!==c||t[20]!==i||t[21]!==g?(_=(0,Q.jsx)(`div`,{"data-settings-item":i,className:c,children:g}),t[19]=c,t[20]=i,t[21]=g,t[22]=_):_=t[22],_},Pa=450,Fa=({projectRef:e=null})=>{let{t}=Pe(),{isMobile:n,isTablet:r}=Wt(),i=n||r,a=Ge(e=>e.getActiveProject()),o=e?.path??a?.path??null,s=Xe(e=>e.getWorktreeMetadata),c=Ve(),l=E(e=>e.homeDirectory),[u,d]=$.useState([]),[f,p]=$.useState(!1),[m,h]=$.useState(!1),[g,_]=$.useState(null),[v,y]=$.useState(null),[b,x]=$.useState([]),[S,C]=$.useState(!1),w=$.useRef(!1),T=$.useMemo(()=>e?.id&&e?.path?{id:e.id,path:e.path}:!a?.id||!o?null:{id:a.id,path:o},[a?.id,o,e?.id,e?.path]),D=$.useCallback(async()=>{if(!(!T||v===!1))try{let e=await on(T);x(e)}catch{}},[T,v]);$.useEffect(()=>{if(!o)return;let e=!1;return y(null),(async()=>{try{let t=await pt(o);if(e)return;y(t)}catch{}})(),()=>{e=!0}},[o]),$.useEffect(()=>{if(!T){x([]),C(!1);return}if(v===!1){x([]),C(!1);return}let e=!1;return C(!0),x([]),(async()=>{try{let t=await on(T);if(e)return;x(t)}catch{}finally{e||C(!1)}})(),()=>{e=!0}},[T,v]),$.useEffect(()=>{if(!T)return;let e=!1;return h(!0),(async()=>{try{let[t,n]=await Promise.all([$e(T),et(T)]);if(!e){let e=t.length>0?t:[``];d(e),_(JSON.stringify(e)),p(n)}}catch{e||(d([``]),_(JSON.stringify([``])),p(!1))}finally{e||h(!1)}})(),()=>{e=!0}},[T]);let O=$.useCallback(async e=>{if(!T)return!1;let n=e.filter(e=>e.trim().length>0);try{return await Be(T,n)?(_(JSON.stringify(e)),!0):(Y.error(t(`settings.yuri.worktrees.setup.toast.saveFailed`)),!1)}catch{return Y.error(t(`settings.yuri.worktrees.setup.toast.saveFailed`)),!1}},[T,t]),k=$.useMemo(()=>g!==null&&g!==JSON.stringify(u),[g,u]);$.useEffect(()=>{if(!k||m||w.current)return;let e=window.setTimeout(()=>{w.current||(w.current=!0,(async()=>{try{await O(u)}finally{w.current=!1}})())},Pa);return()=>{window.clearTimeout(e)}},[k,m,O,u]);let A=$.useCallback((e,t)=>{d(n=>{let r=[...n];return r[e]=t,r})},[]),j=$.useCallback(()=>{d(e=>[...e,``])},[]),M=$.useCallback(e=>{d(t=>{let n=t.filter((t,n)=>n!==e);return n.length>0?n:[``]})},[]),N=$.useCallback(()=>{!k||w.current||(w.current=!0,(async()=>{try{await O(u)}finally{w.current=!1}})())},[k,O,u]),P=$.useCallback(e=>{p(e),T&&Ie(T,e)},[T]),F=$.useCallback(e=>{let t=e=>e.replace(/\\/g,`/`).replace(/\/+$/,``),n=t(e.path),r=c.filter(e=>{let r=s(e.id);if(r?.path&&t(r.path)===n)return!0;let i=e.directory;return!!(i&&t(i)===n)}),i=new Set(r.map(e=>e.id)),a=[...ze.getState().activeSessions,...ze.getState().archivedSessions],o=e=>{let t=a.filter(t=>{let n=t.parentID;return n&&e.has(n)});if(t.length===0)return[];let n=new Set(t.map(e=>e.id));return[...t,...o(n)]},l=o(i),u=new Set,d=[...r,...l].filter(e=>!u.has(e.id)&&(u.add(e.id),!0));Qe.requestDelete({sessions:d,mode:`worktree`,worktree:e})},[c,s]),I=$.useMemo(()=>c.map(e=>e.id).join(`,`),[c]);$.useEffect(()=>{v&&o&&D()},[I,v,o,D]);let L=(0,Q.jsxs)(yt,{children:[(0,Q.jsx)(_t,{asChild:!0,children:(0,Q.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,Q.jsxs)(vt,{sideOffset:8,className:`max-w-xs`,children:[t(`settings.yuri.worktrees.setup.tooltipPrefix`),` `,(0,Q.jsx)(`code`,{className:`font-mono text-xs bg-sidebar-accent/50 px-1 rounded`,children:`$ROOT_PROJECT_PATH`}),` `,t(`settings.yuri.worktrees.setup.tooltipSuffix`)]})]}),R=(0,Q.jsxs)(yt,{children:[(0,Q.jsx)(_t,{asChild:!0,children:(0,Q.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,Q.jsx)(vt,{sideOffset:8,className:`max-w-xs`,children:t(`settings.yuri.worktrees.list.tooltip`)})]});return o?v===!1?(0,Q.jsx)(Na,{title:t(`settings.projects.page.section.worktree`),settingsItem:`projects.worktree`,children:(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.yuri.worktrees.state.gitOnly`)})}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Na,{title:t(`settings.projects.page.section.worktree`),settingsItem:`projects.worktree`,titleAccessory:L,children:m?(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.yuri.worktrees.setup.loading`)}):(0,Q.jsxs)(`div`,{className:q(`flex flex-col gap-2`,Ma),children:[u.map((e,n)=>(0,Q.jsxs)(`div`,{className:`yuri-settings-group-row flex w-full items-center gap-2`,children:[(0,Q.jsx)(gt,{value:e,onChange:e=>A(n,e.target.value),onBlur:N,placeholder:t(`settings.yuri.worktrees.setup.commandPlaceholder`),className:`min-w-0 flex-1 font-mono text-xs`}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>M(n),className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,"aria-label":t(`settings.yuri.worktrees.setup.removeCommandAria`),children:(0,Q.jsx)(X,{name:`close`,className:`h-4 w-4`})})]},n)),(0,Q.jsxs)(J,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:j,children:[(0,Q.jsx)(X,{name:`add`,className:`h-3.5 w-3.5`}),t(`settings.yuri.worktrees.setup.addCommand`)]}),(0,Q.jsx)(bn,{itemId:`projects.worktree.setup.wait`,checked:f,onChange:P,label:t(`settings.yuri.worktrees.setup.waitForCommands`),ariaLabel:t(`settings.yuri.worktrees.setup.waitForCommandsAria`)})]})}),(0,Q.jsx)(Na,{title:t(`settings.yuri.worktrees.list.title`),titleAccessory:R,children:S?(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.yuri.worktrees.list.loading`)}):b.length===0?(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground/70`,children:t(`settings.yuri.worktrees.list.empty`)}):(0,Q.jsx)(`div`,{className:q(`space-y-1`,Ma),children:b.map(e=>(0,Q.jsxs)(`div`,{className:`group flex w-full items-center gap-2 py-1.5`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(`p`,{className:`typography-meta min-w-0 truncate text-foreground`,children:e.label||e.branch||t(`settings.yuri.worktrees.list.detachedHead`)}),(0,Q.jsx)(`span`,{className:`typography-micro flex-shrink-0 self-center rounded bg-sidebar-accent/40 px-1.5 py-[1px] leading-none text-muted-foreground/60`,children:`OpenCode`})]}),(0,Q.jsx)(`p`,{className:`typography-micro truncate text-muted-foreground/60`,children:Me(e.path,l)})]}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>F(e),className:q(`flex h-7 w-7 shrink-0 items-center justify-center rounded text-muted-foreground/50 transition-opacity hover:bg-destructive/10 hover:text-destructive focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,i?`opacity-100`:`opacity-0 group-hover:opacity-100`),"aria-label":t(`settings.yuri.worktrees.list.deleteWorktreeAria`,{name:e.branch||e.label||e.path}),children:(0,Q.jsx)(X,{name:`delete-bin`,className:`h-4 w-4`})})]},e.path))})})]}):(0,Q.jsx)(Na,{title:t(`settings.projects.page.section.worktree`),settingsItem:`projects.worktree`,children:(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.yuri.worktrees.state.selectProject`)})})},Ia=(e,t)=>t.updatedAtMs-e.updatedAtMs,La=_((e,t)=>({instances:[],statusesById:{},importCandidates:[],isLoading:!1,isSaving:!1,isImportsLoading:!1,initialized:!1,listenerReady:!1,error:null,load:async()=>{if(!t().isLoading){e({isLoading:!0,error:null});try{let[n,r]=await Promise.all([bt(),Mt()]),i={};for(let e of r.sort(Ia))i[e.id]=e;t().listenerReady||await Ft(t=>{e(e=>({statusesById:{...e.statusesById,[t.id]:t}}))}),e({instances:n.instances,statusesById:i,isLoading:!1,initialized:!0,listenerReady:!0})}catch(t){e({isLoading:!1,error:t instanceof Error?t.message:String(t)})}}},loadImports:async()=>{if(!t().isImportsLoading){e({isImportsLoading:!0,error:null});try{e({importCandidates:await Ut(),isImportsLoading:!1})}catch(t){e({isImportsLoading:!1,error:t instanceof Error?t.message:String(t)})}}},refreshStatuses:async()=>{try{let t=await Mt(),n={};for(let e of t.sort(Ia))n[e.id]=e;e({statusesById:n})}catch(t){e({error:t instanceof Error?t.message:String(t)})}},setInstances:async n=>{e({isSaving:!0,error:null});try{await jt({instances:n}),e({instances:n,isSaving:!1}),await t().refreshStatuses()}catch(t){throw e({isSaving:!1,error:t instanceof Error?t.message:String(t)}),t}},upsertInstance:async e=>{let n=t().instances,r=n.some(t=>t.id===e.id)?n.map(t=>t.id===e.id?e:t):[e,...n];await t().setInstances(r)},createFromCommand:async(e,n,r)=>{let i=Ct(e,n);r&&r.trim()&&(i.nickname=r.trim()),await t().upsertInstance(i)},removeInstance:async n=>{await kt(n).catch(()=>void 0);let r=t().instances.filter(e=>e.id!==n);await t().setInstances(r),e(e=>{let t={...e.statusesById};return delete t[n],{statusesById:t}})},connect:async n=>{e({error:null});try{await Et(n),await t().refreshStatuses()}catch(t){throw e({error:t instanceof Error?t.message:String(t)}),t}},disconnect:async n=>{e({error:null});try{await kt(n),await t().refreshStatuses()}catch(t){throw e({error:t instanceof Error?t.message:String(t)}),t}},retry:async e=>{await t().connect(e)},getStatus:e=>t().statusesById[e]||null,clearError:()=>e({error:null})})),Ra=450,za=()=>j(),Ba=()=>({id:za(),name:``,command:``,icon:`play`}),Va=({projectRef:e})=>{let{t}=Pe(),n=$.useMemo(()=>d(),[]),r=La(e=>e.instances),i=La(e=>e.load),[a,o]=$.useState([]),[s,c]=$.useState(!1),[l,u]=$.useState(null),[f,p]=$.useState({}),m=$.useRef(!1),h=$.useRef(null);$.useEffect(()=>{n&&i().catch(()=>void 0)},[n,i]),$.useEffect(()=>{let t=!1;return c(!0),(async()=>{try{let n=await Je(e);if(t)return;o(n.actions),u(JSON.stringify({actions:n.actions}))}catch{if(t)return;o([]),u(JSON.stringify({actions:[]}))}finally{t||c(!1)}})(),()=>{t=!0}},[e]);let g=$.useMemo(()=>n?Rn(r):[],[r,n]),_=$.useMemo(()=>a.some(e=>e.name.trim().length===0||e.command.trim().length===0)?t(`settings.projects.actions.validation.fillNameAndCommand`):null,[a,t]),v=$.useMemo(()=>l!==null&&l!==JSON.stringify({actions:a}),[a,l]),y=$.useCallback(async n=>await Ke(e,{actions:n,primaryActionId:null})?(u(JSON.stringify({actions:n})),typeof window<`u`&&window.dispatchEvent(new CustomEvent(Vn,{detail:{projectId:e.id}})),!0):(Y.error(t(`settings.projects.actions.toast.saveFailed`)),!1),[e,t]);$.useEffect(()=>{if(!v||s||_||m.current)return;let e=window.setTimeout(()=>{m.current||(m.current=!0,(async()=>{try{await y(a)}finally{m.current=!1}})())},Ra);return()=>{window.clearTimeout(e)}},[a,v,s,y,_]),$.useEffect(()=>{if(!v||!_||s){_||(h.current=null);return}let e=window.setTimeout(()=>{h.current!==_&&(h.current=_,Y.error(_))},1e3);return()=>{window.clearTimeout(e)}},[v,s,_]);let b=$.useCallback(()=>{let e=Ba();o(t=>[...t,e]),p(t=>({...t,[e.id]:!0}))},[]),x=$.useCallback(e=>{o(t=>t.filter(t=>t.id!==e)),p(t=>{let n={...t};return delete n[e],n})},[]),S=$.useCallback((e,t)=>{o(n=>n.map(n=>n.id===e?t(n):n))},[]);return(0,Q.jsxs)(Na,{title:t(`settings.projects.actions.title`),description:t(`settings.projects.actions.description`),settingsItem:`projects.actions`,headerAction:(0,Q.jsxs)(J,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:b,children:[(0,Q.jsx)(X,{name:`add`,className:`h-3.5 w-3.5`}),t(`settings.projects.actions.actions.add`)]}),contentClassName:`space-y-0`,children:[s?(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.projects.actions.state.loading`)}):a.length===0?(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.projects.actions.state.empty`)}):(0,Q.jsx)(`div`,{className:q(`space-y-0`,Ma),children:a.map(e=>{let r=e.icon||`play`,i=Bn[r]||`play`,a=f[e.id]??!1,o=e.name.trim()||t(`settings.projects.actions.state.untitled`);return(0,Q.jsxs)(Cn,{open:a,onOpenChange:t=>{p(n=>({...n,[e.id]:t}))},className:`py-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Q.jsxs)(Sn,{className:`group flex-1 justify-start gap-2 rounded-md px-0 pr-1 py-1 hover:bg-[var(--interactive-hover)] focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,children:[a?(0,Q.jsx)(X,{name:`arrow-down-s`,className:`h-4 w-4 text-muted-foreground`}):(0,Q.jsx)(X,{name:`arrow-right-s`,className:`h-4 w-4 text-muted-foreground`}),(0,Q.jsx)(X,{name:i,className:`mt-0.5 h-4 w-4 shrink-0 text-muted-foreground`}),(0,Q.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Q.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:o})})]}),(0,Q.jsx)(J,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal h-7 w-7 px-0 text-muted-foreground hover:text-[var(--status-error)]`,onClick:()=>x(e.id),children:(0,Q.jsx)(X,{name:`delete-bin`,className:`h-3.5 w-3.5`})})]}),(0,Q.jsx)(xn,{className:`pt-1.5`,children:(0,Q.jsxs)(`div`,{className:`space-y-2 pb-4 pl-3 pr-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 py-1`,children:[(0,Q.jsxs)(Pt,{children:[(0,Q.jsx)(Vt,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-[var(--interactive-border)] text-foreground hover:bg-[var(--interactive-hover)]`,"aria-label":t(`settings.projects.actions.field.selectIconAria`),children:(0,Q.jsx)(X,{name:i,className:`h-4 w-4`})})}),(0,Q.jsx)(Nt,{align:`start`,className:`w-56 p-2`,children:(0,Q.jsx)(`div`,{className:`grid grid-cols-6 gap-1`,children:zn.map(n=>{let r=n.Icon,i=(e.icon||`play`)===n.key;return(0,Q.jsx)(`button`,{type:`button`,onClick:()=>S(e.id,e=>({...e,icon:n.key})),className:q(`inline-flex h-8 w-8 items-center justify-center rounded-md border border-transparent text-foreground hover:bg-[var(--interactive-hover)]`,i&&`border-[var(--primary-base)] bg-[var(--primary-base)]/10 text-[var(--primary-base)]`),"aria-label":t(`settings.projects.actions.field.iconAria`,{icon:n.label}),children:(0,Q.jsx)(X,{name:r,className:`h-4 w-4`})},n.key)})})})]}),(0,Q.jsx)(gt,{value:e.name,onChange:t=>S(e.id,e=>({...e,name:t.target.value})),placeholder:t(`settings.projects.actions.field.actionNamePlaceholder`),className:`h-7 flex-1 min-w-0`})]}),(0,Q.jsxs)(`div`,{className:`py-1`,children:[(0,Q.jsx)(`p`,{className:`typography-meta mb-0.5 text-muted-foreground`,children:t(`settings.projects.actions.field.command`)}),(0,Q.jsx)(rn,{embedded:!0,value:e.command,onChange:t=>S(e.id,e=>({...e,command:t.target.value})),placeholder:t(`settings.projects.actions.field.commandPlaceholder`),className:`min-h-[88px] w-full font-mono text-xs`})]}),(0,Q.jsxs)(`div`,{className:`py-1`,children:[(0,Q.jsx)(bn,{checked:e.autoOpenUrl===!0,onChange:t=>S(e.id,e=>({...e,...t?{autoOpenUrl:!0}:{autoOpenUrl:void 0}})),label:t(`settings.projects.actions.field.autoOpenUrl`),description:t(`settings.projects.actions.field.autoOpenUrlDescription`),ariaLabel:t(`settings.projects.actions.field.autoOpenUrlForAria`,{title:o})}),e.autoOpenUrl===!0?(0,Q.jsxs)(`div`,{className:`mt-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(gt,{value:e.openUrl||``,onChange:t=>S(e.id,e=>({...e,openUrl:t.target.value})),placeholder:t(`settings.projects.actions.field.overrideUrlPlaceholder`),className:`h-7 w-full max-w-[24rem]`}),(0,Q.jsxs)(yt,{children:[(0,Q.jsx)(_t,{asChild:!0,children:(0,Q.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 shrink-0 text-muted-foreground/60 cursor-help`})}),(0,Q.jsx)(vt,{sideOffset:8,className:`max-w-xs`,children:t(`settings.projects.actions.field.overrideUrlTooltip`)})]})]}),n?(0,Q.jsxs)(`div`,{className:`mt-2`,children:[(0,Q.jsx)(`p`,{className:`typography-meta mb-0.5 text-muted-foreground`,children:t(`settings.projects.actions.field.desktopSshForward`)}),g.length>0?(0,Q.jsxs)(Qt,{value:e.desktopOpenSshForward&&g.some(t=>t.id===e.desktopOpenSshForward)?e.desktopOpenSshForward:`__none__`,onValueChange:t=>{S(e.id,e=>({...e,...t===`__none__`?{desktopOpenSshForward:void 0}:{desktopOpenSshForward:t}}))},children:[(0,Q.jsx)(Zt,{className:`h-7 w-full`,children:(0,Q.jsx)(qt,{placeholder:t(`settings.projects.actions.field.useOutputManualUrl`)})}),(0,Q.jsxs)(Xt,{children:[(0,Q.jsx)(Yt,{value:`__none__`,children:t(`settings.projects.actions.field.useOutputManualUrl`)}),g.map(e=>(0,Q.jsx)(Yt,{value:e.id,children:e.label},e.id))]})]}):(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.projects.actions.state.noDesktopSshForwards`)})]}):null]}):null]})]})})]},e.id)})}),_&&a.length>0?(0,Q.jsx)(`p`,{className:`typography-meta text-[var(--status-warning)]`,children:_}):null]})},Ha=e=>{let t=(0,Z.c)(123),{form:n}=e,{t:r}=Pe(),{currentTheme:i}=nt(),{name:a,setName:o,icon:s,setIcon:c,color:l,setColor:u,iconBackground:d,setIconBackground:f,parsedDefaultModel:p,handleDefaultModelChange:m,isUploadingIcon:h,isRemovingCustomIcon:g,isDiscoveringIcon:_,pendingRemoveImageIcon:v,setPendingRemoveImageIcon:y,pendingUploadIconPreviewUrl:b,setPreviewImageFailed:x,hasPendingUploadImageIcon:S,hasCustomIcon:C,effectiveHasImageIcon:w,hasRemovableImageIcon:T,showImagePreview:E,fileInputRef:D,handleUploadIcon:O,handleRemoveImageIcon:k,handleDiscoverIcon:A,currentIconImage:j,project:M}=n;if(!M)return null;let N=l?ln[l]??null:null,P;t[0]===r?P=t[1]:(P=r(`settings.projects.page.field.projectName`),t[0]=r,t[1]=P);let F;t[2]===o?F=t[3]:(F=e=>o(e.target.value),t[2]=o,t[3]=F);let I;t[4]===r?I=t[5]:(I=r(`settings.projects.page.field.projectNamePlaceholder`),t[4]=r,t[5]=I);let L;t[6]!==a||t[7]!==F||t[8]!==I?(L=(0,Q.jsx)(gt,{value:a,onChange:F,placeholder:I}),t[6]=a,t[7]=F,t[8]=I,t[9]=L):L=t[9];let R;t[10]!==P||t[11]!==L?(R=(0,Q.jsx)(vn,{label:P,itemId:`projects.name`,children:L}),t[10]=P,t[11]=L,t[12]=R):R=t[12];let z;t[13]===r?z=t[14]:(z=r(`settings.projects.page.field.defaultModel`),t[13]=r,t[14]=z);let ee;t[15]===r?ee=t[16]:(ee=r(`settings.projects.page.field.defaultModelDescription`),t[15]=r,t[16]=ee);let te;t[17]!==m||t[18]!==p.modelId||t[19]!==p.providerId?(te=(0,Q.jsx)(yi,{providerId:p.providerId,modelId:p.modelId,onChange:m,className:`yuri-settings-inline-value`}),t[17]=m,t[18]=p.modelId,t[19]=p.providerId,t[20]=te):te=t[20];let B;t[21]!==z||t[22]!==ee||t[23]!==te?(B=(0,Q.jsx)(vn,{label:z,description:ee,descriptionPlacement:`outside`,itemId:`projects.default-model`,children:te}),t[21]=z,t[22]=ee,t[23]=te,t[24]=B):B=t[24];let V;t[25]===r?V=t[26]:(V=r(`settings.projects.page.field.accentColor`),t[25]=r,t[26]=V);let ne;t[27]===u?ne=t[28]:(ne=()=>u(null),t[27]=u,t[28]=ne);let H=l===null?`border-2 border-foreground bg-[var(--primary-base)]/10`:`border-border/40 hover:border-border hover:bg-[var(--surface-muted)]`,re;t[29]===H?re=t[30]:(re=q(`h-7 w-7 rounded-md border transition-colors flex items-center justify-center`,H),t[29]=H,t[30]=re);let U;t[31]===r?U=t[32]:(U=r(`settings.projects.page.field.none`),t[31]=r,t[32]=U);let ie;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,Q.jsx)(X,{name:`close`,className:`h-4 w-4 text-muted-foreground`}),t[33]=ie):ie=t[33];let W;t[34]!==ne||t[35]!==re||t[36]!==U?(W=(0,Q.jsx)(`button`,{type:`button`,onClick:ne,className:re,title:U,children:ie}),t[34]=ne,t[35]=re,t[36]=U,t[37]=W):W=t[37];let ae;t[38]!==l||t[39]!==u?(ae=dn.map(e=>(0,Q.jsx)(`button`,{type:`button`,onClick:()=>u(e.key),className:q(`h-7 w-7 rounded-md border transition-colors`,l===e.key?`border-2 border-foreground ring-1 ring-[var(--primary-base)]/40`:`border-transparent hover:border-border/70`),style:{backgroundColor:e.cssVar},title:e.label},e.key)),t[38]=l,t[39]=u,t[40]=ae):ae=t[40];let oe;t[41]!==W||t[42]!==ae?(oe=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[W,ae]}),t[41]=W,t[42]=ae,t[43]=oe):oe=t[43];let se;t[44]!==V||t[45]!==oe?(se=(0,Q.jsx)(vn,{label:V,itemId:`projects.accent-color`,children:oe}),t[44]=V,t[45]=oe,t[46]=se):se=t[46];let ce;t[47]===r?ce=t[48]:(ce=r(`settings.projects.page.field.projectIcon`),t[47]=r,t[48]=ce);let le;t[49]===O?le=t[50]:(le=e=>{let t=e.target.files?.[0]??null;O(t),e.currentTarget.value=``},t[49]=O,t[50]=le);let ue;t[51]!==D||t[52]!==le?(ue=(0,Q.jsx)(`input`,{ref:D,type:`file`,accept:`image/png,image/jpeg,image/svg+xml,.png,.jpg,.jpeg,.svg`,className:`hidden`,onChange:le}),t[51]=D,t[52]=le,t[53]=ue):ue=t[53];let de;t[54]===c?de=t[55]:(de=()=>c(null),t[54]=c,t[55]=de);let fe=s===null?`border-2 border-foreground bg-[var(--primary-base)]/10`:`border-border/40 hover:border-border hover:bg-[var(--surface-muted)]`,pe;t[56]===fe?pe=t[57]:(pe=q(`h-7 w-7 rounded-md border transition-colors flex items-center justify-center`,fe),t[56]=fe,t[57]=pe);let me;t[58]===r?me=t[59]:(me=r(`settings.projects.page.field.none`),t[58]=r,t[59]=me);let he;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(he=(0,Q.jsx)(X,{name:`close`,className:`h-4 w-4 text-muted-foreground`}),t[60]=he):he=t[60];let ge;t[61]!==de||t[62]!==pe||t[63]!==me?(ge=(0,Q.jsx)(`button`,{type:`button`,onClick:de,className:pe,title:me,children:he}),t[61]=de,t[62]=pe,t[63]=me,t[64]=ge):ge=t[64];let _e;t[65]!==N||t[66]!==s||t[67]!==c?(_e=un.map(e=>{let t=e.Icon;return(0,Q.jsx)(`button`,{type:`button`,onClick:()=>c(e.key),className:q(`h-7 w-7 rounded-md border transition-colors flex items-center justify-center`,s===e.key?`border-2 border-foreground bg-[var(--primary-base)]/10`:`border-transparent hover:border-border hover:bg-[var(--surface-muted)]`),title:e.label,children:(0,Q.jsx)(X,{name:t,className:`w-4 h-4`,style:N&&s===e.key?{color:N}:void 0})},e.key)}),t[65]=N,t[66]=s,t[67]=c,t[68]=_e):_e=t[68];let ve;t[69]!==ge||t[70]!==_e?(ve=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[ge,_e]}),t[69]=ge,t[70]=_e,t[71]=ve):ve=t[71];let ye;t[72]!==j||t[73]!==i||t[74]!==w||t[75]!==S||t[76]!==d||t[77]!==b||t[78]!==M||t[79]!==x||t[80]!==E||t[81]!==r?(ye=w&&E&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,Q.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:r(`settings.projects.page.field.preview`)}),(0,Q.jsx)(`span`,{className:`inline-flex h-7 w-7 items-center justify-center rounded-md border border-border/60 bg-[var(--surface-elevated)] p-1`,children:(0,Q.jsx)(`span`,{className:`inline-flex h-4 w-4 items-center justify-center overflow-hidden rounded-[2px]`,style:d?{backgroundColor:d}:void 0,children:S&&b?(0,Q.jsx)(`img`,{src:b,alt:``,className:`h-full w-full object-contain`,draggable:!1,onError:()=>x(!0)}):(0,Q.jsx)(an,{project:{...M,iconImage:j??M.iconImage},options:{themeVariant:i.metadata.variant,iconColor:i.colors.surface.foreground},className:`h-full w-full object-contain`,onError:()=>x(!0)})})})]}),t[72]=j,t[73]=i,t[74]=w,t[75]=S,t[76]=d,t[77]=b,t[78]=M,t[79]=x,t[80]=E,t[81]=r,t[82]=ye):ye=t[82];let be;t[83]!==w||t[84]!==d||t[85]!==f||t[86]!==r?(be=w&&(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,Q.jsx)(`input`,{type:`color`,value:d??`#000000`,onChange:e=>f(e.target.value),className:`h-7 w-9 cursor-pointer rounded border border-border bg-transparent p-1`,"aria-label":r(`settings.projects.page.field.projectIconBackgroundAria`)}),(0,Q.jsx)(gt,{value:d??``,onChange:e=>f(e.target.value),placeholder:`#000000`,className:`h-7 w-[8rem]`}),(0,Q.jsx)(J,{type:`button`,size:`xs`,variant:`outline`,onClick:()=>f(null),className:`h-7 w-7 p-0`,"aria-label":r(`settings.projects.page.field.clearIconBackgroundAria`),title:r(`settings.projects.page.field.clearBackground`),disabled:!d,children:(0,Q.jsx)(X,{name:`close`,className:`h-3.5 w-3.5`})})]}),t[83]=w,t[84]=d,t[85]=f,t[86]=r,t[87]=be):be=t[87];let xe;t[88]!==D||t[89]!==A||t[90]!==C||t[91]!==_||t[92]!==h||t[93]!==r?(xe=!C&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(J,{size:`xs`,className:`h-6 !font-normal`,onClick:()=>D.current?.click(),disabled:h,children:r(h?`settings.projects.page.actions.uploading`:`settings.projects.page.actions.uploadIcon`)}),(0,Q.jsx)(J,{size:`xs`,className:`h-6 !font-normal`,variant:`outline`,onClick:()=>void A(),disabled:_,children:r(_?`settings.projects.page.actions.discovering`:`settings.projects.page.actions.discoverFavicon`)})]}),t[88]=D,t[89]=A,t[90]=C,t[91]=_,t[92]=h,t[93]=r,t[94]=xe):xe=t[94];let Se;t[95]!==k||t[96]!==T||t[97]!==g||t[98]!==r?(Se=T&&(0,Q.jsx)(J,{size:`xs`,className:`!font-normal`,variant:`outline`,onClick:()=>void k(),disabled:g,children:r(g?`settings.projects.page.actions.removing`:`settings.projects.page.actions.removeProjectIcon`)}),t[95]=k,t[96]=T,t[97]=g,t[98]=r,t[99]=Se):Se=t[99];let G;t[100]!==g||t[101]!==v||t[102]!==y||t[103]!==r?(G=v&&(0,Q.jsx)(J,{size:`xs`,className:`!font-normal`,variant:`outline`,onClick:()=>y(!1),disabled:g,children:r(`settings.projects.page.actions.undoRemove`)}),t[100]=g,t[101]=v,t[102]=y,t[103]=r,t[104]=G):G=t[104];let Ce;t[105]!==xe||t[106]!==Se||t[107]!==G?(Ce=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[xe,Se,G]}),t[105]=xe,t[106]=Se,t[107]=G,t[108]=Ce):Ce=t[108];let we;t[109]!==ue||t[110]!==ve||t[111]!==ye||t[112]!==be||t[113]!==Ce?(we=(0,Q.jsxs)(`div`,{className:`flex w-full flex-col items-end gap-2`,children:[ue,ve,ye,be,Ce]}),t[109]=ue,t[110]=ve,t[111]=ye,t[112]=be,t[113]=Ce,t[114]=we):we=t[114];let K;t[115]!==ce||t[116]!==we?(K=(0,Q.jsx)(vn,{label:ce,itemId:`projects.icon`,children:we}),t[115]=ce,t[116]=we,t[117]=K):K=t[117];let Te;return t[118]!==se||t[119]!==K||t[120]!==R||t[121]!==B?(Te=(0,Q.jsxs)(`div`,{className:`yuri-settings-section-stack`,children:[R,B,se,K]}),t[118]=se,t[119]=K,t[120]=R,t[121]=B,t[122]=Te):Te=t[122],Te},Ua=/^#(?:[\da-fA-F]{3}|[\da-fA-F]{6})$/,Wa=e=>{if(!e)return null;let t=e.trim();return t&&Ua.test(t)?t.toLowerCase():null},Ga=e=>{let{t}=Pe(),n=Ge(e=>e.uploadProjectIcon),r=Ge(e=>e.removeProjectIcon),i=Ge(e=>e.discoverProjectIcon),a=Ge(t=>e?t.projects.find(t=>t.id===e.id)?.iconImage??null:null),[o,s]=$.useState(``),[c,l]=$.useState(null),[u,d]=$.useState(null),[f,p]=$.useState(null),[m,h]=$.useState(void 0),[g,_]=$.useState(!1),[v,y]=$.useState(!1),[b,x]=$.useState(!1),[S,C]=$.useState(!1),[w,T]=$.useState(null),[E,D]=$.useState(null),[O,k]=$.useState(!1),A=$.useRef(null),j=$.useCallback(()=>{T(null),D(e=>(e&&URL.revokeObjectURL(e),null))},[]),M=e?.id??null;$.useEffect(()=>{if(!e){s(``),l(null),d(null),p(null),h(void 0);return}s(e.label??``),l(e.icon??null),d(e.color??null),p(e.iconBackground??null),h(e.defaultModel),C(!1),j(),k(!1)},[e,j]),$.useEffect(()=>()=>{j()},[j]);let N=$.useMemo(()=>qe(m)??{providerId:``,modelId:``},[m]),P=!!e?.iconImage,F=!!(w&&E),I=e?.iconImage?.source===`custom`,L=P&&!S||F,R=L,z=!!(e&&P&&!S),ee=!O&&(F||z),te=!!e&&(o.trim()!==(e?.label??``).trim()||c!==(e?.icon??null)||u!==(e?.color??null)||f!==(e?.iconBackground??null)||(m??void 0)!==(e?.defaultModel??void 0)||S||!!w),B=$.useCallback((e,t)=>{h(e&&t?`${e}/${t}`:void 0)},[]),V=$.useCallback(t=>{!e||!t||g||(C(!1),k(!1),T(t),D(e=>(e&&URL.revokeObjectURL(e),URL.createObjectURL(t))))},[g,e]),ne=$.useCallback(()=>{!e||!R||v||(F&&j(),C(!!P),k(!1))},[j,F,R,P,v,e]),H=$.useCallback(async()=>{if(!(!e||b)){j(),C(!1),k(!1),x(!0);try{let n=await i(e.id);if(!n.ok){Y.error(n.error||t(`settings.projects.page.toast.discoverIconFailed`));return}if(n.skipped){Y.success(t(`settings.projects.page.toast.customIconAlreadySet`));return}Y.success(t(`settings.projects.page.toast.iconDiscovered`))}finally{x(!1)}}},[j,i,b,e,t]),re=$.useCallback(async i=>{let a=i?.silent===!0;if(!e)return null;let s=o.trim();if(!s)return null;if(w){_(!0);let r=await n(e.id,w);if(_(!1),!r.ok)return Y.error(r.error||t(`settings.projects.page.toast.uploadIconFailed`)),null;a||Y.success(t(`settings.projects.page.toast.iconUpdated`)),j(),C(!1)}let l=S&&!!e.iconImage;if(l){y(!0);let n=await r(e.id);if(y(!1),!n.ok)return Y.error(n.error||t(`settings.projects.page.toast.removeIconFailed`)),null;a||Y.success(t(`settings.projects.page.toast.iconRemoved`)),C(!1),p(null)}return{label:s,icon:c,color:u,iconBackground:Wa(l?null:f),defaultModel:m??null}},[j,u,m,c,f,o,S,w,e,r,t,n]);return $.useEffect(()=>{k(!1)},[M,a?.updatedAt]),{name:o,setName:s,icon:c,setIcon:l,color:u,setColor:d,iconBackground:f,setIconBackground:p,defaultModel:m,parsedDefaultModel:N,handleDefaultModelChange:B,isUploadingIcon:g,isRemovingCustomIcon:v,isDiscoveringIcon:b,pendingRemoveImageIcon:S,setPendingRemoveImageIcon:C,pendingUploadIconFile:w,pendingUploadIconPreviewUrl:E,previewImageFailed:O,setPreviewImageFailed:k,hasStoredImageIcon:P,hasPendingUploadImageIcon:F,hasCustomIcon:I,effectiveHasImageIcon:L,hasRemovableImageIcon:R,showStoredImagePreview:z,showImagePreview:ee,fileInputRef:A,clearPendingUploadIcon:j,handleUploadIcon:V,handleRemoveImageIcon:ne,handleDiscoverIcon:H,hasChanges:te,prepareSaveData:re,currentIconImage:a,project:e}},Ka=450,qa=(e,t)=>{let{t:n}=Pe(),{hasChanges:r,name:i,icon:a,color:o,iconBackground:s,defaultModel:c,pendingRemoveImageIcon:l,pendingUploadIconFile:u,isUploadingIcon:d,isRemovingCustomIcon:f,prepareSaveData:p}=e,m=$.useRef(!1);$.useEffect(()=>{if(!r||!i.trim()||d||f||m.current)return;let e=window.setTimeout(()=>{m.current||(m.current=!0,(async()=>{try{let e=await p({silent:!0});if(e)try{await t(e)}catch{Y.error(n(`settings.projects.page.toast.saveFailed`))}}finally{m.current=!1}})())},Ka);return()=>{window.clearTimeout(e)}},[o,c,r,a,s,f,d,i,t,l,u,p,n])},Ja=e=>{let t=(0,Z.c)(25),{project:n,onIdentitySave:r}=e,{t:i}=Pe(),a=Ga(n),o;bb0:{if(!n){o=null;break bb0}let e;t[0]!==n.id||t[1]!==n.path?(e={id:n.id,path:n.path},t[0]=n.id,t[1]=n.path,t[2]=e):e=t[2],o=e}let s=o,c;if(t[3]===r?c=t[4]:(c=async e=>{await r(e)},t[3]=r,t[4]=c),qa(a,c),!n||!s)return null;let l;t[5]!==n.path||t[6]!==i?(l=n.path.split(/[\\/]/).filter(Boolean).at(-1)??i(`settings.projects.page.title.default`),t[5]=n.path,t[6]=i,t[7]=l):l=t[7];let u=l,d;t[8]===u?d=t[9]:(d=(0,Q.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:u}),t[8]=u,t[9]=d);let f;t[10]===n.path?f=t[11]:(f=(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground truncate`,title:n.path,children:n.path}),t[10]=n.path,t[11]=f);let p;t[12]!==d||t[13]!==f?(p=(0,Q.jsxs)(`div`,{className:`px-1`,children:[d,f]}),t[12]=d,t[13]=f,t[14]=p):p=t[14];let m;t[15]===a?m=t[16]:(m=(0,Q.jsx)(Ha,{form:a}),t[15]=a,t[16]=m);let h,g;t[17]===s?(h=t[18],g=t[19]):(h=(0,Q.jsx)(Va,{projectRef:s}),g=(0,Q.jsx)(Fa,{projectRef:s}),t[17]=s,t[18]=h,t[19]=g);let _;return t[20]!==p||t[21]!==m||t[22]!==h||t[23]!==g?(_=(0,Q.jsxs)(`div`,{className:`yuri-settings-section-stack`,children:[p,m,h,g]}),t[20]=p,t[21]=m,t[22]=h,t[23]=g,t[24]=_):_=t[24],_};function Ya(e){let t=e.indexOf(`/`);if(t!==-1){let n=e.substring(0,t);if(n===`gemini`||n===`antigravity`)return e.substring(t+1)}return e}var Xa={google:[{id:`gemini-auth`,label:`Gemini`,matcher:e=>e.startsWith(`gemini/`),order:1},{id:`antigravity-auth`,label:`Antigravity`,matcher:e=>e.startsWith(`antigravity/`),order:2}]};function Za(e,t){let n=Xa[t]??[];for(let t of n)if(t.matcher(e))return t;return null}function Qa(e){return Xa[e]??[]}function $a(e){return[...e].sort((e,t)=>e.order-t.order)}function eo(e,t){let n=new Map;for(let r of Object.keys(e)){let e=Za(r,t)?.id??null;n.has(e)||n.set(e,[]),n.get(e).push(r)}return n}function to(e,t,n){let r=new Map;for(let i of e){let e=Za(t(i),n)?.id??null;r.has(e)||r.set(e,[]),r.get(e).push(i)}return r}function no(e,t){return t.filter(e=>{let t=e.toLowerCase(),n=t.includes(`/`)?t.split(`/`)[1]:t;return!!(n.startsWith(`gemini-3-`)||n.startsWith(`claude-`))})}var ro=(e,t=``,n=!1)=>F({queryKey:R.scoped(`magpie-quotas`,e,t,n),staleTime:0,retry:!1,queryFn:async({signal:t})=>{let r=await a(`/api/quota/magpie`,{signal:t,query:{...e?{directory:e}:{},...n?{refresh:`1`}:{}}});if(!r.ok)throw Error(`Unable to discover Magpie quota sources`);let i=await r.json();if(!i||!Array.isArray(i.sources)||!i.sources.every(e=>e&&typeof e.id==`string`&&typeof e.name==`string`&&Array.isArray(e.results)&&e.results.every(t=>z(t)&&t.source===`magpie`&&t.sourceId===e.id&&t.providerId.startsWith(`magpie:${e.id}:`))))throw Error(`Invalid Magpie quota response`);return i}}),io=6e4,ao=0,oo=0,so,co=0,lo=0,uo=0,fo=new Map,po=e=>{let t=Hn.map(e=>e.id),n=typeof e?.usageAutoRefresh==`boolean`&&e.usageAutoRefresh,r=typeof e?.usageRefreshIntervalMs==`number`&&Number.isFinite(e.usageRefreshIntervalMs)?Math.max(3e4,Math.min(3e5,Math.round(e.usageRefreshIntervalMs))):io,i=e?.usageDisplayMode===`remaining`?`remaining`:`usage`,a=typeof e?.usageShowPredValues==`boolean`&&e.usageShowPredValues,o=Array.isArray(e?.usageDropdownProviders)?e?.usageDropdownProviders:null,s=o?o.filter(e=>typeof e==`string`&&(e.startsWith(`magpie:`)||t.includes(e))):t,c={},l=e?.usageSelectedModels;if(l&&typeof l==`object`)for(let[e,t]of Object.entries(l))Array.isArray(t)&&(c[e]=t.filter(e=>typeof e==`string`));let u={},d=e?.usageExpandedFamilies;if(d&&typeof d==`object`)for(let[e,t]of Object.entries(d))Array.isArray(t)&&(u[e]=t.filter(e=>typeof e==`string`));return{magpieUsageUrl:typeof e?.magpieUsageUrl==`string`?e.magpieUsageUrl:``,magpieHiddenProviders:Array.isArray(e?.magpieHiddenProviders)?e.magpieHiddenProviders.filter(e=>typeof e==`string`&&e.startsWith(`magpie:`)):[],autoRefresh:n,refreshIntervalMs:r,displayMode:i,showPredValues:a,dropdownProviderIds:s,selectedModels:c,expandedFamilies:u}},mo=async()=>{let e=g()?.settings;if(e)try{let t=(await e.load())?.settings;return po(t??null)}catch{}if(!f()){let e=await a(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});if(e.ok)return po(await e.json().catch(()=>null))}return{magpieUsageUrl:``,magpieHiddenProviders:[],autoRefresh:!1,refreshIntervalMs:io,displayMode:`usage`,showPredValues:!1,dropdownProviderIds:Hn.map(e=>e.id),selectedModels:{},expandedFamilies:{}}},ho=(e,t,n)=>{let r=e.filter(e=>e?.providerId&&e.providerId!==t);return z(n)&&r.push(n),r},go=async(e,t)=>{let n=oo;fo.set(e,(fo.get(e)??0)+1),t(t=>({isFetchingProvider:{...t.isFetchingProvider,[e]:!0}}));try{let r=await L.fetchQuery({queryKey:R.quota(e),queryFn:({signal:t})=>ee(e,t),staleTime:0,retry:!1});if(n!==oo)return{providerId:e,stale:!0};if(!z(r))throw Error(`Invalid quota response`);return t(t=>({results:ho(t.results,e,r)})),{providerId:e,result:r}}catch(r){return n===oo?(t(e=>e.results.every(e=>e?.providerId)?{}:{results:e.results.filter(e=>e?.providerId)}),{providerId:e,error:r instanceof Error?r.message:`Failed to fetch quota`}):{providerId:e,stale:!0}}finally{if(n===oo){let n=(fo.get(e)??1)-1;n>0?fo.set(e,n):fo.delete(e),t(t=>({isFetchingProvider:{...t.isFetchingProvider,[e]:n>0}}))}}},_o=()=>{so=void 0,co+=1,oo+=1,ao+=1,fo.clear(),vo.setState({magpieUsageUrl:``,magpieHiddenProviders:[],magpieSources:[],magpieError:null,results:[],isLoading:!1,isFetchingProvider:{},lastUpdated:null,error:null})},vo=_()(y((e,t)=>({magpieSources:[],magpieError:null,magpieHiddenProviders:[],magpieUsageUrl:``,results:[],selectedProviderId:null,isLoading:!1,isFetchingProvider:{},lastUpdated:null,error:null,autoRefresh:!1,refreshIntervalMs:io,displayMode:`usage`,showPredValues:!1,dropdownProviderIds:Hn.map(e=>e.id),selectedModels:{},expandedFamilies:{},loadSettings:async()=>{let t=oo;try{let n=await mo();if(t!==oo)return;e(e=>({...n,dropdownProviderIds:[...n.dropdownProviderIds.filter(e=>!e.startsWith(`magpie:`)),...e.results.filter(e=>e.source===`magpie`&&!n.magpieHiddenProviders.includes(e.providerId)).map(e=>e.providerId)]}))}catch(e){console.warn(`Failed to load usage settings:`,e)}},fetchAllQuotas:async()=>{let n=++ao;e({isLoading:!0,error:null});let r=Hn.map(e=>e.id),[i]=await Promise.all([Promise.all(r.map(t=>go(t,e))),t().fetchMagpieQuotas(!0)]);if(n===ao){let t=i.find(e=>`error`in e);e({isLoading:!1,...i.some(e=>`result`in e)?{lastUpdated:Date.now()}:{},error:t?.error??null})}},fetchProviderQuota:async n=>{if(n.startsWith(`magpie:`))return t().fetchMagpieQuotas(!0);let r=await go(n,e);`stale`in r||e({error:`error`in r?r.error:null})},fetchMagpieQuotas:async(n=!1)=>{let r=oo,i=E.getState().currentDirectory,a=t().magpieUsageUrl,o=JSON.stringify([i,a]);so!==o&&(so=o,co+=1,e(e=>({results:e.results.filter(e=>e?.source!==`magpie`),magpieSources:[],magpieError:null})));let s=co,c=++lo;try{let{sources:o,incomplete:l}=await L.fetchQuery(ro(i,a,n));if(r!==oo||s!==co||c<uo||i!==E.getState().currentDirectory||a!==t().magpieUsageUrl)return;uo=c,e(e=>{let t=new Map(o.filter(e=>e.error&&!e.clearPrevious&&e.results.length===0).map(e=>[e.id,e.error]));if(l){let n=new Set(o.map(e=>e.id));for(let r of e.results)r.sourceId&&!n.has(r.sourceId)&&t.set(r.sourceId,`Magpie discovery is incomplete`)}let n=e.results.filter(e=>e?.providerId&&(e.source!==`magpie`||t.has(e.sourceId??``))).map(e=>e.source===`magpie`&&t.has(e.sourceId??``)?{...e,ok:!1,error:t.get(e.sourceId??``)}:e);n.push(...o.flatMap(e=>e.results));let r=n.filter(e=>e.source===`magpie`).map(e=>e.providerId);return{results:n,magpieSources:o,magpieError:null,dropdownProviderIds:[...e.dropdownProviderIds.filter(e=>!e.startsWith(`magpie:`)),...r.filter(t=>!e.magpieHiddenProviders.includes(t))]}})}catch(n){if(r!==oo||s!==co||c<uo||i!==E.getState().currentDirectory||a!==t().magpieUsageUrl)return;uo=c,e({magpieError:n instanceof Error?n.message:`Unable to read Magpie quotas`})}},setSelectedProvider:t=>e({selectedProviderId:t}),setAutoRefresh:t=>e({autoRefresh:t}),setRefreshInterval:t=>{e({refreshIntervalMs:Math.max(3e4,Math.min(3e5,Math.round(t)))})},setDisplayMode:t=>e({displayMode:t}),setShowPredValues:t=>e({showPredValues:t}),setDropdownProviderIds:n=>{let r=t().results.filter(e=>e.source===`magpie`),i=new Set(r.map(e=>e.providerId));e({dropdownProviderIds:n,magpieHiddenProviders:[...t().magpieHiddenProviders.filter(e=>!i.has(e)),...r.filter(e=>!n.includes(e.providerId)).map(e=>e.providerId)]})},setSelectedModels:(t,n)=>{e(e=>({selectedModels:{...e.selectedModels,[t]:n}}))},toggleModelSelected:(t,n)=>{e(e=>{let r=e.selectedModels[t]??[],i=r.includes(n)?r.filter(e=>e!==n):[...r,n];return{selectedModels:{...e.selectedModels,[t]:i}}})},setExpandedFamilies:(n,r)=>{e(e=>({expandedFamilies:{...e.expandedFamilies,[n]:r}})),k({usageExpandedFamilies:t().expandedFamilies})},toggleFamilyExpanded:(n,r)=>{e(e=>{let t=e.expandedFamilies[n]??[],i=t.includes(r)?t.filter(e=>e!==r):[...t,r];return{expandedFamilies:{...e.expandedFamilies,[n]:i}}}),k({usageExpandedFamilies:t().expandedFamilies})},applyDefaultSelections:(n,r)=>{if((t().selectedModels[n]?.length??0)>0)return;let i=no(n,r);i.length!==0&&(e(e=>({selectedModels:{...e.selectedModels,[n]:i}})),k({usageSelectedModels:t().selectedModels}))}}),{name:`quota-store`})),yo=()=>{let e=(0,Z.c)(11),t=E(bo),n=vo(xo),r=vo(So),i;e[0]===r?i=e[1]:(i=()=>{r()},e[0]=r,e[1]=i);let a;e[2]!==t||e[3]!==r||e[4]!==n?(a=[t,n,r],e[2]=t,e[3]=r,e[4]=n,e[5]=a):a=e[5],$.useEffect(i,a);let o=vo(Co),s=vo(wo),c=vo(To),l,u;e[6]!==o||e[7]!==c||e[8]!==s?(l=()=>{if(!o)return;let e=window.setInterval(()=>{c()},s);return()=>window.clearInterval(e)},u=[o,s,c],e[6]=o,e[7]=c,e[8]=s,e[9]=l,e[10]=u):(l=e[9],u=e[10]),$.useEffect(l,u)};function bo(e){return e.currentDirectory}function xo(e){return e.magpieUsageUrl}function So(e){return e.fetchMagpieQuotas}function Co(e){return e.autoRefresh}function wo(e){return e.refreshIntervalMs}function To(e){return e.fetchAllQuotas}var Eo=e=>{let t=(0,Z.c)(20),{percent:n,tonePercent:r,className:i,expectedMarkerPercent:a}=e,o;t[0]===n?o=t[1]:(o=xt(n)??0,t[0]=n,t[1]=o);let s=o,c=r??n,l;t[2]===c?l=t[3]:(l=Dt(c),t[2]=c,t[3]=l);let u=l,d=a==null?null:Math.max(0,Math.min(100,a)),f;t[4]===u?f=t[5]:(f=u===`critical`?{backgroundColor:`var(--status-error)`}:u===`warn`?{backgroundColor:`var(--status-warning)`}:{backgroundColor:`var(--status-success)`},t[4]=u,t[5]=f);let p=f,m;t[6]===i?m=t[7]:(m=q(`relative h-2.5 rounded-full bg-[var(--interactive-border)] overflow-hidden`,i),t[6]=i,t[7]=m);let h=`${s}%`,g;t[8]!==p||t[9]!==h?(g={...p,width:h},t[8]=p,t[9]=h,t[10]=g):g=t[10];let _;t[11]!==s||t[12]!==g?(_=(0,Q.jsx)(`div`,{className:`h-full transition-all duration-300`,style:g,role:`progressbar`,"aria-valuenow":s,"aria-valuemin":0,"aria-valuemax":100}),t[11]=s,t[12]=g,t[13]=_):_=t[13];let v;t[14]===d?v=t[15]:(v=d!=null&&d>0&&d<100&&(0,Q.jsx)(`div`,{className:`absolute top-0 h-full w-0.5 bg-foreground`,style:{left:`${d}%`},title:`Expected usage if spread evenly: ${Math.round(d)}% of quota`,"aria-hidden":`true`}),t[14]=d,t[15]=v);let y;return t[16]!==m||t[17]!==_||t[18]!==v?(y=(0,Q.jsxs)(`div`,{className:m,children:[_,v]}),t[16]=m,t[17]=_,t[18]=v,t[19]=y):y=t[19],y},Do=e=>{let t=(0,Z.c)(67),{paceInfo:n,className:r,compact:i}=e,a=i!==void 0&&i,{t:o}=Pe(),s;t[0]===n.status?s=t[1]:(s=Rt(n.status),t[0]=n.status,t[1]=s);let c=s,l;bb0:{switch(n.status){case`on-track`:{let e;t[2]===o?e=t[3]:(e=o(`settings.usage.pace.status.onTrack`),t[2]=o,t[3]=e),l=e;break bb0}case`slightly-fast`:{let e;t[4]===o?e=t[5]:(e=o(`settings.usage.pace.status.slightlyFast`),t[4]=o,t[5]=e),l=e;break bb0}case`too-fast`:{let e;t[6]===o?e=t[7]:(e=o(`settings.usage.pace.status.tooFast`),t[6]=o,t[7]=e),l=e;break bb0}case`exhausted`:{let e;t[8]===o?e=t[9]:(e=o(`settings.usage.pace.status.usedUp`),t[8]=o,t[9]=e),l=e;break bb0}}l=void 0}let u=l,d;t[10]!==n.predictText||t[11]!==o?(d=o(`settings.usage.pace.predictionTooltip`,{prediction:n.predictText}),t[10]=n.predictText,t[11]=o,t[12]=d):d=t[12];let f=d;if(a){let e;t[13]===r?e=t[14]:(e=q(`flex items-center gap-1.5`,r),t[13]=r,t[14]=e);let i;t[15]===c?i=t[16]:(i={backgroundColor:c},t[15]=c,t[16]=i);let a;t[17]!==u||t[18]!==i?(a=(0,Q.jsx)(`div`,{className:`h-2 w-2 rounded-full flex-shrink-0`,style:i,title:u}),t[17]=u,t[18]=i,t[19]=a):a=t[19];let s;t[20]===c?s=t[21]:(s={color:c},t[20]=c,t[21]=s);let l=n.isExhausted?void 0:f,d;t[22]!==n.isExhausted||t[23]!==n.predictText||t[24]!==n.remainingSeconds||t[25]!==o?(d=n.isExhausted?(0,Q.jsx)(Q.Fragment,{children:o(`settings.usage.pace.wait`,{duration:zt(n.remainingSeconds)})}):(0,Q.jsx)(Q.Fragment,{children:o(`settings.usage.pace.prediction`,{prediction:n.predictText})}),t[22]=n.isExhausted,t[23]=n.predictText,t[24]=n.remainingSeconds,t[25]=o,t[26]=d):d=t[26];let p;t[27]!==d||t[28]!==s||t[29]!==l?(p=(0,Q.jsx)(`span`,{className:`typography-micro tabular-nums`,style:s,title:l,children:d}),t[27]=d,t[28]=s,t[29]=l,t[30]=p):p=t[30];let m;return t[31]!==p||t[32]!==e||t[33]!==a?(m=(0,Q.jsxs)(`div`,{className:e,children:[a,p]}),t[31]=p,t[32]=e,t[33]=a,t[34]=m):m=t[34],m}let p;t[35]===r?p=t[36]:(p=q(`flex items-center justify-between gap-2`,r),t[35]=r,t[36]=p);let m;t[37]!==n.isExhausted||t[38]!==n.paceRateText||t[39]!==o?(m=!n.isExhausted&&(0,Q.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:o(`settings.usage.pace.rate`,{rate:n.paceRateText})}),t[37]=n.isExhausted,t[38]=n.paceRateText,t[39]=o,t[40]=m):m=t[40];let h;t[41]===m?h=t[42]:(h=(0,Q.jsx)(`div`,{className:`flex items-center gap-1.5`,children:m}),t[41]=m,t[42]=h);let g;t[43]===c?g=t[44]:(g={color:c},t[43]=c,t[44]=g);let _;t[45]!==n.isExhausted||t[46]!==n.predictText||t[47]!==n.remainingSeconds||t[48]!==f||t[49]!==u||t[50]!==o?(_=n.isExhausted?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:u}),(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:o(`settings.usage.pace.waitSeparator`)}),(0,Q.jsx)(`span`,{className:`font-medium`,children:zt(n.remainingSeconds)})]}):(0,Q.jsxs)(`span`,{title:f,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:o(`settings.usage.pace.predictionLabel`)}),(0,Q.jsx)(`span`,{className:`font-medium`,children:n.predictText})]}),t[45]=n.isExhausted,t[46]=n.predictText,t[47]=n.remainingSeconds,t[48]=f,t[49]=u,t[50]=o,t[51]=_):_=t[51];let v;t[52]!==g||t[53]!==_?(v=(0,Q.jsx)(`span`,{className:`typography-micro tabular-nums`,style:g,children:_}),t[52]=g,t[53]=_,t[54]=v):v=t[54];let y;t[55]===c?y=t[56]:(y={backgroundColor:c},t[55]=c,t[56]=y);let b;t[57]!==u||t[58]!==y?(b=(0,Q.jsx)(`div`,{className:`h-2 w-2 rounded-full flex-shrink-0`,style:y,title:u}),t[57]=u,t[58]=y,t[59]=b):b=t[59];let x;t[60]!==v||t[61]!==b?(x=(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[v,b]}),t[60]=v,t[61]=b,t[62]=x):x=t[62];let S;return t[63]!==x||t[64]!==p||t[65]!==h?(S=(0,Q.jsxs)(`div`,{className:p,children:[h,x]}),t[63]=x,t[64]=p,t[65]=h,t[66]=S):S=t[66],S},Oo=e=>e instanceof Error&&e.name===`CancelledError`,ko=_(()=>({setStatus:e=>Ht(L,e),refreshStatus:async(e,t)=>{let r=n();t?.force&&await L.cancelQueries({queryKey:R.github.auth(r),exact:!0});try{return await Ot(L,e,r)}catch(e){if(Oo(e))return Tt(L,r);throw e}}})),Ao={displayMode:`browser`,installed:!1,browserTab:!0},jo=new Set,Mo=Ao,No=!1,Po,Fo=()=>{let e=Bt();return{displayMode:e,installed:e!==`browser`,browserTab:e===`browser`}},Io=()=>(!No&&typeof window<`u`&&(Mo=Fo(),No=!0),Mo),Lo=()=>{let e=Fo();No=!0,e.displayMode!==Mo.displayMode&&(Mo=e,jo.forEach(e=>e()))},Ro=()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=[window.matchMedia(`(display-mode: standalone)`),window.matchMedia(`(display-mode: minimal-ui)`),window.matchMedia(`(display-mode: fullscreen)`),window.matchMedia(`(display-mode: window-controls-overlay)`)];for(let t of e)typeof t.addEventListener==`function`?t.addEventListener(`change`,Lo):typeof t.addListener==`function`&&t.addListener(Lo);return window.addEventListener(`appinstalled`,Lo),window.addEventListener(`focus`,Lo),()=>{for(let t of e)typeof t.removeEventListener==`function`?t.removeEventListener(`change`,Lo):typeof t.removeListener==`function`&&t.removeListener(Lo);window.removeEventListener(`appinstalled`,Lo),window.removeEventListener(`focus`,Lo)}},zo=e=>(jo.add(e),Po??=Ro(),Lo(),()=>{jo.delete(e),jo.size===0&&(Po?.(),Po=void 0)}),Bo=()=>$.useSyncExternalStore(zo,Io,Vo);function Vo(){return Ao}var Ho=`Yuri`,Uo=_()(v(e=>({sidebarBrandName:Ho,setSidebarBrandName:t=>{let n=t.slice(0,64);e(e=>e.sidebarBrandName===n?e:{sidebarBrandName:n})}}),{name:`sidebar-brand-store`,storage:A(),version:3,migrate:(e,t)=>{if(!e||typeof e!=`object`)return e;let n={...e};return t<1&&n.sidebarBrandName===`YEE CODE`&&(n.sidebarBrandName=Ho),t<2&&n.sidebarBrandName===`Open Chamber`&&(n.sidebarBrandName=Ho),t<3&&(n.sidebarBrandName===`OPEN CHAMBER`||n.sidebarBrandName===`Open Chamber`)&&(n.sidebarBrandName=Ho),n}}));typeof window<`u`&&t(e=>{i(e)&&Uo.persist.rehydrate()});var Wo=(e,t)=>e?t.kind===e.kind?t.projectRoot.length===e.projectRoot.length?t.projectId.localeCompare(e.projectId)<0:t.projectRoot.length>e.projectRoot.length:t.kind===`project`:!0,Go=(e,t,n)=>{Wo(e.get(t),n)&&e.set(t,n)},Ko=e=>{let t=e;return B(t.directory)??B(t.project?.worktree)},qo=e=>{if(e===`/`||/^[A-Z]:$/.test(e))return null;let t=e.lastIndexOf(`/`);return t<0?null:t===0?`/`:t===2&&/^[A-Z]:\//.test(e)?e.slice(0,2):e.slice(0,t)},Jo=(e,t,n,r,i=[])=>{let a=new Map,o=new Map;for(let e of t){let t=B(e.normalizedPath);if(!t)continue;let n=o.get(t);(!n||e.id.localeCompare(n.id)<0)&&o.set(t,e),Go(a,t,{projectId:e.id,projectRoot:t,scopeDirectory:t,kind:`project`})}if(!r)for(let[e,t]of n){let n=B(e),r=n?o.get(n):void 0;if(!(!r||!n))for(let e of t){let t=B(e.path);t&&Go(a,t,{projectId:r.id,projectRoot:n,scopeDirectory:t,kind:`worktree`})}}let s=new Map,c=new Map,l=new Map,u=new Map,d=new Map,f=e=>{if(!e)return null;if(s.has(e))return s.get(e)??null;if(r){let t=a.get(e)??null;return s.set(e,t),t}let t=[],n=e,i=null;for(;n;){if(s.has(n)){i=s.get(n)??null;break}if(t.push(n),i=a.get(n)??null,i)break;n=qo(n)}for(let e of t)s.set(e,i);return i},p=(e,t,n)=>{for(let r of e){let e=f(Ko(r));if(!e)continue;c.set(r.id,e);let i=t.get(e.projectId);if(i?i.push(r):t.set(e.projectId,[r]),!n)continue;let a=n.get(e.scopeDirectory);a?a.add(r.id):n.set(e.scopeDirectory,new Set([r.id]))}};return p(e,l,d),p(i,u),{bySessionId:c,sessionsByProject:l,archivedSessionsByProject:u,sessionsByScope:d,directoryResolutions:s.size}},Yo=`__other__`;function Xo(e){return e.time?.updated??e.time?.archived??e.time?.created??0}function Zo({mode:e=`dialog`}){let{t}=Pe(),{isMobile:n,isTablet:r,hasTouchInput:i}=Wt(),a=n||r||i,o=e===`page`,s=D(e=>e.isArchivedSessionsDialogOpen),c=D(e=>e.setArchivedSessionsDialogOpen),l=o||s,u=Ge(e=>e.projects),d=ze(e=>e.archivedSessions),p=Xe(e=>e.setCurrentSession),m=D(e=>e.setSettingsDialogOpen),[h,g]=$.useState(!1),[_,v]=$.useState(null),[y,b]=$.useState(null);$.useEffect(()=>{if(!l){v(null),b(null);return}let e=!1;return g(!0),Le().catch(()=>{e||Y.error(t(`settings.yuri.archivedSessions.toast.loadFailed`))}).finally(()=>{e||g(!1)}),()=>{e=!0}},[l,t]);let x=$.useMemo(()=>{let e=Jo([],u.map(e=>({id:e.id,normalizedPath:e.path})),new Map,f(),d),n=new Map;for(let[t,r]of e.archivedSessionsByProject)n.set(t,[...r].sort((e,t)=>Xo(t)-Xo(e)));let r=new Set;for(let e of n.values())for(let t of e)r.add(t.id);let i=d.filter(e=>!r.has(e.id)).sort((e,t)=>Xo(t)-Xo(e));i.length>0&&n.set(Yo,i);let a=[];for(let e of u){let t=n.get(e.id)??[];t.length!==0&&a.push({projectId:e.id,label:e.label||e.path,path:e.path,sessions:t})}let o=n.get(Yo);return o&&o.length>0&&a.push({projectId:Yo,label:t(`settings.yuri.archivedSessions.otherProjects`),path:null,sessions:o}),a.sort((e,t)=>t.sessions.length-e.sessions.length||e.label.localeCompare(t.label)),a},[d,u,t]),S=d.length,C=_?x.find(e=>e.projectId===_)??null:null,w=$.useCallback(async e=>{b(e.id);try{await Ze(e.id)?Y.success(t(`settings.yuri.archivedSessions.toast.restored`)):Y.error(t(`settings.yuri.archivedSessions.toast.restoreFailed`))}finally{b(null)}},[t]),T=$.useCallback(e=>{let t=We(e);p(e.id,t),c(!1),m(!1)},[p,c,m]),E=C?C.label:t(`settings.yuri.archivedSessions.dialog.title`),O=C?C.sessions.length===1?t(`settings.yuri.archivedSessions.dialog.sessionCountSingle`,{count:C.sessions.length}):t(`settings.yuri.archivedSessions.dialog.sessionCountPlural`,{count:C.sessions.length}):t(`settings.yuri.archivedSessions.dialog.description`),k=(0,Q.jsxs)(`div`,{className:`yuri-picker-list space-y-3`,children:[C?(0,Q.jsxs)(J,{type:`button`,variant:`ghost`,size:`sm`,className:`!h-7 !px-2 !font-normal text-muted-foreground`,onClick:()=>v(null),children:[(0,Q.jsx)(X,{name:`arrow-left-s`,className:`mr-1 h-4 w-4`}),t(`settings.yuri.archivedSessions.dialog.backToProjects`)]}):null,h?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 typography-meta text-muted-foreground py-6`,children:[(0,Q.jsx)(X,{name:`loader-4`,className:`h-4 w-4 animate-spin`}),t(`settings.yuri.archivedSessions.dialog.loading`)]}):C?C.sessions.length===0?(0,Q.jsx)(`div`,{className:`yuri-picker-empty rounded-lg border border-dashed border-border p-4 typography-meta text-muted-foreground`,children:t(`settings.yuri.archivedSessions.dialog.emptyProject`)}):(0,Q.jsx)(`div`,{className:`yuri-picker-rows space-y-1.5`,children:C.sessions.map(e=>{let n=We(e),r=Xo(e),i=y===e.id;return(0,Q.jsxs)(`div`,{className:`yuri-picker-row flex flex-col gap-2 rounded-lg border border-border/60 px-3 py-2.5 sm:flex-row sm:items-center sm:gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`yuri-picker-label typography-ui-label font-medium text-foreground truncate`,children:e.title||t(`sessions.sidebar.session.untitled`)}),(0,Q.jsxs)(`div`,{className:`yuri-picker-meta typography-meta text-muted-foreground truncate`,children:[r>0?Lt(r):null,r>0&&n?` · `:null,n?Me(n):null]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,Q.jsx)(J,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,disabled:i,onClick:()=>T(e),children:t(`settings.yuri.archivedSessions.actions.preview`)}),(0,Q.jsxs)(J,{type:`button`,variant:`default`,size:`xs`,className:`!font-normal`,disabled:i,onClick:()=>void w(e),children:[i?(0,Q.jsx)(X,{name:`loader-4`,className:`mr-1 h-3.5 w-3.5 animate-spin`}):(0,Q.jsx)(X,{name:`inbox-unarchive`,className:`mr-1 h-3.5 w-3.5`}),t(`settings.yuri.archivedSessions.actions.restore`)]})]})]},e.id)})}):x.length===0?(0,Q.jsx)(`div`,{className:`yuri-picker-empty rounded-lg border border-dashed border-border p-4 typography-meta text-muted-foreground`,children:t(`settings.yuri.archivedSessions.dialog.empty`)}):(0,Q.jsx)(`div`,{className:`yuri-picker-rows space-y-1.5`,children:x.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>v(e.projectId),className:q(`yuri-picker-row flex w-full items-center gap-3 rounded-lg border border-border/60 px-3 py-2.5 text-left`,`hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`),children:[(0,Q.jsx)(X,{name:`folder`,className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`yuri-picker-label typography-ui-label font-medium text-foreground truncate`,children:e.label}),e.path?(0,Q.jsx)(`div`,{className:`yuri-picker-meta typography-meta text-muted-foreground truncate`,children:Me(e.path)}):null]}),(0,Q.jsx)(`span`,{className:`typography-meta tabular-nums text-muted-foreground shrink-0`,children:e.sessions.length===1?t(`settings.yuri.archivedSessions.dialog.sessionCountSingle`,{count:e.sessions.length}):t(`settings.yuri.archivedSessions.dialog.sessionCountPlural`,{count:e.sessions.length})}),(0,Q.jsx)(X,{name:`arrow-right-s`,className:`h-4 w-4 shrink-0 text-muted-foreground`})]},e.projectId))}),!C&&!h&&S>0?(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(S===1?`settings.yuri.archivedSessions.summarySingle`:`settings.yuri.archivedSessions.summaryPlural`,{count:S})}):null]});return o?(0,Q.jsxs)(`div`,{"data-settings-item":`archived-sessions.manage`,className:`yuri-settings-section-stack`,children:[(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.yuri.archivedSessions.description`)}),k]}):a?(0,Q.jsx)(wt,{open:s,title:E,onClose:()=>c(!1),contentMaxHeightClassName:`max-h-[min(80vh,640px)]`,renderHeader:e=>(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 border-b border-border/40 px-3 py-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`h2`,{className:`typography-ui-label font-semibold text-foreground`,children:E}),e]}),(0,Q.jsx)(`p`,{className:`typography-micro text-muted-foreground`,children:O})]}),children:k}):(0,Q.jsx)(ct,{open:s,onOpenChange:c,children:(0,Q.jsxs)(at,{presentation:`picker`,children:[(0,Q.jsx)(it,{className:`yuri-picker-header`,children:(0,Q.jsx)(ot,{className:`yuri-picker-title truncate`,children:E})}),k]})})}function Qo(){let e=(0,Z.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Q.jsx)(Zo,{mode:`dialog`}),e[0]=t):t=e[0],t}var $o={globe:`global`,server:`server`,"circle-check":`checkbox-circle`,"circle-x":`close-circle`,"window-analytics":`bar-chart-box`};function es(e){let t=(0,Z.c)(14),{mobile:n,sidebar:r}=e,i=n!==void 0&&n,a=r!==void 0&&r,{host:o,snapshot:s}=tn();if(!o||s.titlebarItems.length===0)return null;let c=!a||void 0,l=a||void 0,u=a?`app-region-no-drag space-y-0.5`:`app-region-no-drag flex min-w-0 max-w-32 items-center gap-1 overflow-x-auto scrollbar-hidden`,d;if(t[0]!==o||t[1]!==i||t[2]!==a||t[3]!==s.titlebarItems){let e;t[5]!==o||t[6]!==i||t[7]!==a?(e=e=>{let t=e.icon&&($o[e.icon]??(Object.hasOwn(rt,e.icon)?e.icon:void 0)),n=(0,Q.jsxs)(Q.Fragment,{children:[e.busy?(0,Q.jsx)(X,{name:`loader-4`,className:q(a?`size-4`:`size-3.5`,`shrink-0 animate-spin motion-reduce:animate-none`)}):t?(0,Q.jsx)(X,{name:t,className:a?`size-4 shrink-0`:`size-3.5`}):a?(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`size-4 shrink-0`}):null,a||!t?(0,Q.jsx)(`span`,{className:a?`truncate`:`max-w-24 truncate`,children:e.label}):null]});return e.actionable?(0,Q.jsx)(J,{size:a||i?`sm`:`xs`,variant:a?`ghost`:`default`,className:q(`aria-pressed:bg-interactive-selection aria-pressed:text-interactive-selection-foreground`,a&&`w-full justify-start px-2 font-normal`,a&&i&&`h-11`),title:e.label,"aria-label":e.title??e.label,"aria-pressed":e.pressed,"aria-busy":!!e.busy,disabled:!!e.busy,onClick:()=>void o.runTitlebarItem(e.key),children:n},e.key):(0,Q.jsx)(`span`,{role:`status`,title:e.label,"aria-label":e.title??e.label,"aria-busy":!!e.busy,className:q(`inline-flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-muted-foreground`,a?`w-full text-sm`:`bg-muted text-xs`),children:n},e.key)},t[5]=o,t[6]=i,t[7]=a,t[8]=e):e=t[8],d=s.titlebarItems.map(e),t[0]=o,t[1]=i,t[2]=a,t[3]=s.titlebarItems,t[4]=d}else d=t[4];let f;return t[9]!==c||t[10]!==l||t[11]!==u||t[12]!==d?(f=(0,Q.jsx)(`div`,{"data-gui-titlebar-items":c,"data-gui-sidebar-items":l,className:u,children:d}),t[9]=c,t[10]=l,t[11]=u,t[12]=d,t[13]=f):f=t[13],f}var ts=48;function ns({title:e,eyebrow:t,trailing:n,className:r}){let i=(0,$.useRef)(null),a=(0,$.useRef)(null),o=(0,$.useRef)(null),s=(0,$.useRef)(null),c=(0,$.useRef)(null),l=je(()=>{s.current=null;let e=i.current,t=a.current;if(!e||!t)return;let n=Math.min(1,Math.max(0,t.scrollTop/ts)),r=o.current?.matches?Number(n>=.5):n;c.current!==null&&Math.abs(c.current-r)<.001||(c.current=r,e.style.setProperty(`--yuri-mobile-title-collapse`,r.toFixed(4)))}),u=je(()=>{s.current===null&&(s.current=window.requestAnimationFrame(l))});return(0,$.useEffect)(()=>{let e=i.current;if(!e)return;let t=e.closest(`.yuri-mobile-settings-root-surface, [role="tabpanel"]`);if(!t)return;let n=window.matchMedia(`(prefers-reduced-motion: reduce)`);return a.current=t,o.current=n,c.current=null,t.addEventListener(`scroll`,u,{passive:!0}),n.addEventListener(`change`,u),l(),()=>{t.removeEventListener(`scroll`,u),n.removeEventListener(`change`,u),s.current!==null&&window.cancelAnimationFrame(s.current),s.current=null,a.current=null,o.current=null,c.current=null}},[]),(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`header`,{ref:i,className:q(`yuri-mobile-collapsing-header flex shrink-0 items-start gap-4`,r),children:(0,Q.jsxs)(`div`,{className:`yuri-mobile-collapsing-header-inner`,children:[(0,Q.jsxs)(`div`,{className:`yuri-mobile-collapsing-header-title-block min-w-0 flex-1`,children:[t?(0,Q.jsx)(`p`,{className:`yuri-mobile-collapsing-header-eyebrow truncate typography-micro font-medium text-muted-foreground`,children:t}):null,(0,Q.jsx)(`h1`,{className:`yuri-mobile-root-page-title truncate font-semibold text-foreground`,children:e})]}),(0,Q.jsxs)(`div`,{className:`yuri-mobile-collapsing-header-trailing flex min-h-10 shrink-0 items-center gap-3.5`,children:[(0,Q.jsx)(es,{mobile:!0}),n]})]})}),(0,Q.jsx)(`div`,{className:`yuri-mobile-collapsing-header-spacer`,"aria-hidden":`true`})]})}export{Li as A,ii as B,ka as C,la as D,_a as E,pi as F,Gn as G,$r as H,di as I,Un as J,Wn as K,mi as L,yi as M,_i as N,Pi as O,ui as P,hi as R,Aa as S,ga as T,Or as U,ai as V,tr as W,to as _,Jo as a,La as b,ko as c,_o as d,yo as f,eo as g,Ya as h,Zo as i,Oi as j,Ii as k,Do as l,Qa as m,es as n,Uo as o,vo as p,Hn as q,Qo as r,Bo as s,ns as t,Eo as u,$a as v,va as w,ja as x,Ja as y,gi as z};