@yuriai/web 0.2.32-beta.4 → 0.2.32-beta.6

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 (171) hide show
  1. package/README.md +18 -0
  2. package/dist/assets/{AgentAvatar-DG1RbFtI.js → AgentAvatar-BPGtFSJl.js} +1 -1
  3. package/dist/assets/AssistantContactStatus-aUqr2ugb.js +3 -0
  4. package/dist/assets/{AssistantUnreadBadge-ByetyaWn.js → AssistantUnreadBadge-DrGzknrO.js} +1 -1
  5. package/dist/assets/{AssistantView-CHt3RWEC.js → AssistantView-GTh6h8B4.js} +1 -1
  6. package/dist/assets/{DiagramView-DReVW5q9.js → DiagramView-CLxCIzOU.js} +1 -1
  7. package/dist/assets/{FadeInOnReveal-Bmxvkrf4.js → FadeInOnReveal-DoQ1DHcy.js} +1 -1
  8. package/dist/assets/{GuiPluginSurface-CIeyIzIp.js → GuiPluginSurface-Cnyb0Yg6.js} +1 -1
  9. package/dist/assets/{GuiPluginWindow-CwP_vUoC.js → GuiPluginWindow-CWjwMY19.js} +1 -1
  10. package/dist/assets/Icon-wD7peplo.js +1 -0
  11. package/dist/assets/{ImageLoadingPlaceholder-DlosWH_9.js → ImageLoadingPlaceholder-cfSg1uO0.js} +1 -1
  12. package/dist/assets/{LoadingImage-D9r0ukc0.js → LoadingImage-DTlBKb0t.js} +1 -1
  13. package/dist/assets/{MarkdownRenderer-D-0KHpNl.js → MarkdownRenderer-QhegFBTR.js} +2 -2
  14. package/dist/assets/{MarkdownRendererImpl-BEUnj4i_.js → MarkdownRendererImpl-rflXjuIs.js} +1 -1
  15. package/dist/assets/{MarkstreamRendererImpl-BufiC_bA.js → MarkstreamRendererImpl-DGuW5ssC.js} +1 -1
  16. package/dist/assets/{MobileDetailNavigation-32DAi6Mg.js → MobileDetailNavigation-DpEvfH1k.js} +1 -1
  17. package/dist/assets/{MobileResizableSheet-vAenroLZ.js → MobileResizableSheet-3pSxhm6y.js} +1 -1
  18. package/dist/assets/{MobileShareBridge-DukFTkwu.js → MobileShareBridge-DiIVhlyc.js} +1 -1
  19. package/dist/assets/MobileTabPageHeader-eWPfDPR9.js +2 -0
  20. package/dist/assets/{MultiRunWindow-B2e-JjFb.js → MultiRunWindow-ByORgIWm.js} +1 -1
  21. package/dist/assets/{OnboardingScreen-DNlK3zfZ.js → OnboardingScreen-De74T2ws.js} +1 -1
  22. package/dist/assets/{OverlayScrollbar-W17unuIx.js → OverlayScrollbar-C1VJiQk-.js} +1 -1
  23. package/dist/assets/{SettingsView-DXhstV_y.js → SettingsView-H9vzfUh1.js} +12 -12
  24. package/dist/assets/{SettingsWindow-D1BRJCx_.js → SettingsWindow-CdUQZdrH.js} +1 -1
  25. package/dist/assets/SetupTourDialog-DJQC2v_9.js +1 -0
  26. package/dist/assets/SetupTourDialog-DrL_4ODI.css +1 -0
  27. package/dist/assets/{TerminalView-B_jqEx8P.js → TerminalView-X8tMXHjR.js} +1 -1
  28. package/dist/assets/{ToolOutputDialog-BgwsFo9W.js → ToolOutputDialog-DzAxB4FS.js} +1 -1
  29. package/dist/assets/{VoiceSettings-DXHfWAgl.js → VoiceSettings-CnYY2qY_.js} +2 -2
  30. package/dist/assets/{YuriLogo-XH6UGXtF.js → YuriLogo-kLl6rb2d.js} +1 -1
  31. package/dist/assets/YuriWordmark-DHYo0FlR.js +1 -0
  32. package/dist/assets/{appThemeRegistry-ChXTWoVW.js → appThemeRegistry-DIjRw0x6.js} +1 -1
  33. package/dist/assets/{button-CyJvQsp5.js → button-DSfiaJr4.js} +1 -1
  34. package/dist/assets/{capgoAdapter-BAvjN_Nh.js → capgoAdapter-cbndHe7B.js} +1 -1
  35. package/dist/assets/checkbox-cWs92MsM.js +1 -0
  36. package/dist/assets/{collapsible-CXjDO6DW.js → collapsible-AUQp4jpe.js} +1 -1
  37. package/dist/assets/{context-menu-BajfnPcW.js → context-menu-DwQvyFO2.js} +1 -1
  38. package/dist/assets/{diagram-_Js3imTf.js → diagram-BTa5MQro.js} +1 -1
  39. package/dist/assets/{dialog-Bapd6e10.js → dialog-gWs6IrfL.js} +1 -1
  40. package/dist/assets/{es-CBhZ80Z7.js → es-mX3KOqnq.js} +1 -1
  41. package/dist/assets/{fileMentionTouchSelection-BqGxOZhB.js → fileMentionTouchSelection-plcnc8He.js} +1 -1
  42. package/dist/assets/{fr-D9s0sHDF.js → fr-DpWAkfly.js} +1 -1
  43. package/dist/assets/{gitApi-DtXTuozL.js → gitApi-B9CzBfkU.js} +1 -1
  44. package/dist/assets/historyImportQueries-DXif2xV2.js +1 -0
  45. package/dist/assets/host-z9PU8q1e.js +1 -0
  46. package/dist/assets/{input-SCAHBeSU.js → input-D2qPeIPD.js} +1 -1
  47. package/dist/assets/insertionBoundaries-mB_fOUPv.js +1 -0
  48. package/dist/assets/{ja-BXQ3ox8H.js → ja-BBtK3t8l.js} +1 -1
  49. package/dist/assets/{ko-DlUti1wK.js → ko-Cwp3wC4W.js} +1 -1
  50. package/dist/assets/main-GmcShJwn.js +169 -0
  51. package/dist/assets/main-PMsuxOz8.js +2 -0
  52. package/dist/assets/{markdownHeightCache-B3MTnGA8.js → markdownHeightCache-Cinxvo8I.js} +1 -1
  53. package/dist/assets/{mcpQueries-0BYnsVR6.js → mcpQueries-D4D9YExA.js} +1 -1
  54. package/dist/assets/miniChat-D6sCXrvt.js +2 -0
  55. package/dist/assets/mobile-BT_KeI5P.js +2 -0
  56. package/dist/assets/{mobileBackNavigation-C1Ow2avo.js → mobileBackNavigation-uUEjrscy.js} +1 -1
  57. package/dist/assets/multirun-T_ppFdUy.js +3 -0
  58. package/dist/assets/{native-config-DQIb-3qU.js → native-config-BuFjRBaY.js} +1 -1
  59. package/dist/assets/{pl-B7LIbV2C.js → pl-Ccedjy5w.js} +1 -1
  60. package/dist/assets/{projectMeta-CSiZ4I85.js → projectMeta-FCtpvvba.js} +1 -1
  61. package/dist/assets/{pt-BR-DyusczdZ.js → pt-BR-M2O45bRx.js} +1 -1
  62. package/dist/assets/{pwa-Cm-jO8eR.js → pwa-CT5wGYKz.js} +1 -1
  63. package/dist/assets/{queue-abort-optimistic-CxF6bGXx.js → queue-abort-optimistic-Dqb0K-4o.js} +1 -1
  64. package/dist/assets/react-a6PrrNTm.js +1 -0
  65. package/dist/assets/{readiness-CDywb9dh.js → readiness-B2YFCzzO.js} +1 -1
  66. package/dist/assets/{renderElectronMiniChatApp-CiVeccip.js → renderElectronMiniChatApp-oHllm8xZ.js} +2 -2
  67. package/dist/assets/{renderMobileApp-B9-hpVnc.js → renderMobileApp-BHHmg4QP.js} +7 -7
  68. package/dist/assets/{runtimeConfig-Rthccc9z.js → runtimeConfig-7V2FCxSF.js} +1 -1
  69. package/dist/assets/runtimeEndpointReset-RgJe46-h.js +149 -0
  70. package/dist/assets/{select-BCLecCtX.js → select-BOlDxL_9.js} +1 -1
  71. package/dist/assets/sessionLookup-Fwx-W5l-.js +1 -0
  72. package/dist/assets/{sortable-tabs-strip-D474PwS8.js → sortable-tabs-strip-CtkfOIVC.js} +1 -1
  73. package/dist/assets/{speechSettingsQueries-alV0B1bP.js → speechSettingsQueries-BjBvcUMN.js} +1 -1
  74. package/dist/assets/src-C5Lsul_L.css +2 -0
  75. package/dist/assets/{store-Diaywtmi.js → store-BMijqCTE.js} +3 -3
  76. package/dist/assets/{textarea-CWQIq-Mn.js → textarea-Cspgldlr.js} +1 -1
  77. package/dist/assets/{tooltip-D3WmiZ7G.js → tooltip-DBb-UCMU.js} +1 -1
  78. package/dist/assets/tour-DzjTres6.js +1 -0
  79. package/dist/assets/{types-_2Igbjc0.js → types-C1fTHpjE.js} +1 -1
  80. package/dist/assets/{uk-BrwM67Dh.js → uk-skNzlwtr.js} +1 -1
  81. package/dist/assets/{useAppFontEffects-B1n0YPn0.js → useAppFontEffects-BIioYkKK.js} +54 -54
  82. package/dist/assets/useDesktopWindowControlsLayout-BO0Lolpp.js +1 -0
  83. package/dist/assets/{useDictation-C-waWdAq.js → useDictation-CwZ6a6i7.js} +1 -1
  84. package/dist/assets/{useEffectiveDirectory-CvDy8Tyu.js → useEffectiveDirectory-Bqgyt9OS.js} +1 -1
  85. package/dist/assets/{useMobileNavigationStore-BHAEAnfr.js → useMobileNavigationStore-BGHhBg7N.js} +13 -13
  86. package/dist/assets/{usePluginsStore-DvvZ8a3q.js → usePluginsStore-DT2-z09d.js} +1 -1
  87. package/dist/assets/{useWorkerHighlightedLines-DUpdltuG.js → useWorkerHighlightedLines-B8ypYliw.js} +1 -1
  88. package/dist/assets/{zh-CN-D9NAFloZ.js → zh-CN-KsbHpHjS.js} +1 -1
  89. package/dist/assets/{zh-TW-tuUKOuhs.js → zh-TW-SdNEiQ7a.js} +1 -1
  90. package/dist/index.html +6 -6
  91. package/dist/mini-chat.html +6 -6
  92. package/dist/mobile.html +6 -6
  93. package/package.json +1 -1
  94. package/server/index.js +2 -0
  95. package/server/lib/client-auth/pairing.js +2 -0
  96. package/server/lib/client-auth/pairing.test.js +29 -0
  97. package/server/lib/content-search/DOCUMENTATION.md +9 -0
  98. package/server/lib/content-search/routes.js +18 -1
  99. package/server/lib/content-search/routes.test.js +21 -0
  100. package/server/lib/content-search/runtime.js +7 -3
  101. package/server/lib/content-search/runtime.test.js +26 -0
  102. package/server/lib/gui-customization/DOCUMENTATION.md +21 -1
  103. package/server/lib/gui-customization/session-skill.js +2 -2
  104. package/server/lib/gui-customization/session-skill.test.js +3 -1
  105. package/server/lib/gui-customization/skill/SKILL.md +5 -1
  106. package/server/lib/gui-customization/skill/references/global-pages.md +1 -1
  107. package/server/lib/gui-customization/skill/references/gui-api.md +4 -1
  108. package/server/lib/gui-customization/skill/references/icons.md +134 -0
  109. package/server/lib/gui-customization/skill/references/plugin-styles.md +112 -0
  110. package/server/lib/gui-customization/skill/references/ui-surfaces.md +2 -0
  111. package/server/lib/gui-customization/skill/references/work-status.md +110 -0
  112. package/server/lib/history-import/AGENT_CONNECT_LICENSE +21 -0
  113. package/server/lib/history-import/DOCUMENTATION.md +214 -0
  114. package/server/lib/history-import/dev-proxy.integration.test.js +56 -0
  115. package/server/lib/history-import/events.js +322 -0
  116. package/server/lib/history-import/events.test.js +110 -0
  117. package/server/lib/history-import/installations.js +39 -0
  118. package/server/lib/history-import/installations.test.js +24 -0
  119. package/server/lib/history-import/native.js +49 -0
  120. package/server/lib/history-import/native.test.js +42 -0
  121. package/server/lib/history-import/routes.js +48 -0
  122. package/server/lib/history-import/routes.test.js +55 -0
  123. package/server/lib/history-import/service.js +374 -0
  124. package/server/lib/history-import/service.test.js +508 -0
  125. package/server/lib/history-import/settings.js +146 -0
  126. package/server/lib/history-import/settings.test.js +88 -0
  127. package/server/lib/history-import/sources.js +184 -0
  128. package/server/lib/history-import/sources.test.js +190 -0
  129. package/server/lib/history-import/sqlite.js +187 -0
  130. package/server/lib/history-import/store.js +58 -0
  131. package/server/lib/history-import/store.test.js +72 -0
  132. package/server/lib/history-import/targets.js +24 -0
  133. package/server/lib/host-update/DOCUMENTATION.md +6 -0
  134. package/server/lib/host-update/routes.test.js +1 -1
  135. package/server/lib/notifications/native-stream.relay.test.js +1 -0
  136. package/server/lib/opencode/DOCUMENTATION.md +3 -0
  137. package/server/lib/opencode/core-routes.js +1 -0
  138. package/server/lib/opencode/feature-routes-runtime.js +11 -1
  139. package/server/lib/opencode/yuri-routes.js +1 -1
  140. package/server/lib/relay/DOCUMENTATION.md +1 -1
  141. package/server/lib/relay/host-client.js +3 -1
  142. package/server/lib/relay/host-client.test.js +1 -0
  143. package/server/lib/relay/reasoning-projection.e2e.test.ts +1 -0
  144. package/server/lib/relay/relay-server.e2e.test.ts +32 -17
  145. package/server/lib/relay/service.js +2 -0
  146. package/server/lib/relay/tunnel-host.js +26 -1
  147. package/server/lib/relay/tunnel-host.test.js +27 -3
  148. package/server/lib/remote-desktop/runtime.test.js +2 -2
  149. package/server/lib/ui-auth/DOCUMENTATION.md +3 -0
  150. package/server/lib/ui-auth/ui-auth.js +27 -0
  151. package/server/lib/ui-auth/ui-auth.test.js +42 -1
  152. package/server/plugin-gui-proxy.test.js +1 -1
  153. package/dist/assets/AssistantContactStatus-TjmyQVnm.js +0 -3
  154. package/dist/assets/Icon-BOYrvHyJ.js +0 -1
  155. package/dist/assets/MobileTabPageHeader-DEXatYlp.js +0 -2
  156. package/dist/assets/SetupTourDialog-CUzqT2sw.css +0 -1
  157. package/dist/assets/SetupTourDialog-CxgLkqcj.js +0 -1
  158. package/dist/assets/YuriWordmark-Cr1vkcue.js +0 -1
  159. package/dist/assets/host-CBfSyi4l.js +0 -1
  160. package/dist/assets/insertionBoundaries-DeBppC-3.js +0 -1
  161. package/dist/assets/main-BEYE305b.js +0 -2
  162. package/dist/assets/main-CYlSqUaZ.js +0 -169
  163. package/dist/assets/miniChat-CvclLJoR.js +0 -2
  164. package/dist/assets/mobile-BU75qxb4.js +0 -2
  165. package/dist/assets/multirun-4Pn9maGs.js +0 -3
  166. package/dist/assets/react-Bwr5-XPi.js +0 -1
  167. package/dist/assets/runtimeEndpointReset-CretKGD9.js +0 -149
  168. package/dist/assets/sessionLookup-BxPSStyI.js +0 -1
  169. package/dist/assets/src-CFd7QD5V.css +0 -2
  170. package/dist/assets/tour-DeA0Ksvj.js +0 -1
  171. package/dist/assets/useDesktopWindowControlsLayout-CpYYPIUB.js +0 -1
@@ -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-_2Igbjc0.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-CyJvQsp5.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-BHAEAnfr.js";import{t as tt}from"./AgentAvatar-DG1RbFtI.js";import{n as nt}from"./useThemeSystem-CNzUUkFn.js";import{n as X,r as rt}from"./Icon-BOYrvHyJ.js";import{a as it,n as at,o as ot,r as st,t as ct}from"./dialog-Bapd6e10.js";import{L as lt,_ as ut,b as dt,c as ft,n as pt,s as mt,u as ht}from"./gitApi-DtXTuozL.js";import{t as gt}from"./input-SCAHBeSU.js";import{i as _t,n as vt,t as yt}from"./tooltip-D3WmiZ7G.js";import{Bt as bt,E as xt,H as St,It as Ct,J as wt,Jt as Tt,L as Et,Lt as Dt,M as Ot,R as kt,Rt as At,V as jt,Vt as Mt,Wt as Nt,X as Pt,Y 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-Cm-jO8eR.js";import{r as Wt,t as Gt}from"./device-w1ioiqv3.js";import{t as Kt}from"./MobileResizableSheet-vAenroLZ.js";import{c as qt,d as Jt,i as Yt,n as Xt,s as Zt,t as Qt}from"./select-BCLecCtX.js";import{n as $t}from"./MarkdownRenderer-D-0KHpNl.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-CWQIq-Mn.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-CSiZ4I85.js";import{r as fn}from"./markdown-worker-oBGEB9Eg.js";import{i as pn,n as mn,o as hn}from"./mcpQueries-0BYnsVR6.js";import{c as gn,d as _n,f as vn,m as yn,s as bn}from"./usePluginsStore-DvvZ8a3q.js";import{n as xn,r as Sn,t as Cn}from"./collapsible-CXjDO6DW.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=bn(),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}=jt(),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)(Pt,{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)(Ft,{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}=jt(),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)(Ft,{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)(Pt,{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)(vn,{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)(yn,{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(),Nt()]),i={};for(let e of r.sort(Ia))i[e.id]=e;t().listenerReady||await Tt(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 Nt(),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 Mt({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 At(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 Dt(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 At(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)(Ft,{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)(Pt,{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)(yn,{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)(_n,{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)(_n,{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)(_n,{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)(_n,{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=Ot(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 kt(L,e,r)}catch(e){if(Oo(e))return Et(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};
@@ -1 +0,0 @@
1
- .yuri-setup-tour[data-slot=dialog-content]{isolation:isolate;gap:18px;width:min(980px,100vw - 32px);max-width:980px;height:auto;min-height:min(640px,100dvh - 32px);max-height:calc(100dvh - 32px);padding:26px 28px 20px;overflow:hidden}.yuri-tour-watermark{aspect-ratio:1;z-index:-1;pointer-events:none;-webkit-user-select:none;user-select:none;opacity:.12;width:min(440px,55%);color:var(--surface-foreground);position:absolute;top:-60px;right:-90px;-webkit-mask-image:linear-gradient(225deg,#000 10%,#0000 76%);mask-image:linear-gradient(225deg,#000 10%,#0000 76%)}.yuri-tour-watermark>[data-yuri-logo]{width:100%;height:100%}.yuri-tour-watermark svg path{fill:currentColor}.yuri-tour-title[data-slot=dialog-title]{font-size:calc(24 * var(--dpt));text-align:left;flex-wrap:wrap;justify-content:flex-start;align-items:center;gap:.15em .2em;line-height:1.4;display:flex}.yuri-setup-tour>[data-slot=dialog-header]{margin-bottom:16px}.yuri-tour-body{flex:1;grid-template-columns:150px minmax(0,1fr);gap:24px;min-height:0;display:grid}.yuri-tour-progress{flex-direction:column;align-items:stretch;gap:24px;display:flex}.yuri-tour-progress>button{min-width:0;color:var(--surface-muted-foreground);justify-content:flex-start;gap:14px;padding-inline:8px;position:relative}.yuri-tour-progress>button[aria-current=step]{color:var(--surface-foreground)}.yuri-tour-progress>button:after{content:"";background:var(--interactive-border);height:1px;position:absolute;bottom:-6px;left:8px;right:8px}.yuri-tour-progress>button[aria-current=step]:after{background:var(--surface-foreground)}.yuri-tour-number{font-size:calc(32 * var(--dpt));letter-spacing:-.05em;font-variant-numeric:tabular-nums;opacity:.6;flex-shrink:0;font-weight:300;line-height:1}.yuri-tour-progress>button[aria-current=step] .yuri-tour-number{opacity:1}.yuri-tour-content{scrollbar-gutter:stable;flex:1;min-height:0;overflow:auto}.yuri-tour-provider-content{scrollbar-gutter:auto;overflow:hidden}.yuri-tour-provider-content .yuri-settings-section-stack.mx-auto{max-width:none;padding:0}.yuri-tour-plugins{grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;display:grid}.yuri-tour-magpie{border:1px solid var(--interactive-border);border-radius:10px;flex-direction:column;align-items:flex-start;gap:14px;padding:18px;display:flex}.yuri-tour-recommended{background:var(--interactive-selection);color:var(--interactive-selection-foreground);font-size:calc(11 * var(--dpt));border-radius:6px;padding:2px 6px}.yuri-tour-provider-heading{justify-content:space-between;align-items:center;margin:24px 0 12px;display:flex}.yuri-tour-provider-grid{grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;display:grid}.yuri-tour-provider-choice{border:1px solid var(--interactive-border);white-space:normal;text-align:left;justify-content:flex-start}.yuri-tour-plugin{border:1px solid var(--interactive-border);border-radius:10px;flex-direction:column;gap:14px;padding:16px;display:flex}.yuri-tour-select-card{isolation:isolate;position:relative}.yuri-tour-select-card>:not(.yuri-tour-card-toggle){pointer-events:none}.yuri-tour-select-card .yuri-tour-card-link{z-index:1;pointer-events:auto;position:relative}.yuri-tour-card-toggle{z-index:-1;border-radius:inherit;width:100%;height:100%;padding:0;position:absolute;inset:0}.yuri-tour-card-toggle:hover,.yuri-tour-card-toggle:active{box-shadow:none;background:0 0}.yuri-tour-select-card:has(.yuri-tour-card-toggle:hover){border-color:var(--interactive-selection-foreground)}.yuri-tour-card-selected{border-color:var(--interactive-selection-foreground);box-shadow:inset 0 0 0 1px var(--interactive-selection-foreground);background:color-mix(in srgb, var(--interactive-selection) 35%, var(--surface-background))}.yuri-tour-card-check{border:1px solid var(--interactive-border);width:28px;height:28px;color:var(--interactive-selection-foreground);border-radius:50%;place-items:center;display:grid;position:absolute;top:16px;right:16px}.yuri-tour-card-selected .yuri-tour-card-check{border-color:var(--interactive-selection-foreground);background:var(--interactive-selection)}.yuri-tour-note{font-size:calc(12 * var(--dpt));color:var(--surface-muted-foreground);margin:14px 0;line-height:1.8}.yuri-tour-feedback{font-size:calc(12 * var(--dpt));color:var(--surface-muted-foreground);overflow-wrap:anywhere;margin-top:12px;line-height:1.7}.yuri-tour-footer{flex-shrink:0;justify-content:space-between;align-items:center;gap:8px;display:flex}.yuri-tour-voice-intro{padding:8px 0 28px}.yuri-tour-voice-intro h2{letter-spacing:-.03em;font-size:clamp(24px,3vw,32px);font-weight:500;line-height:1.35}.yuri-tour-voice-intro p{max-width:54ch;color:var(--surface-muted-foreground);font-size:calc(13 * var(--dpt));margin-top:12px;line-height:1.8}.yuri-tour-voice-capabilities{grid-template-columns:repeat(2,minmax(0,1fr));gap:28px;display:grid}.yuri-tour-voice-capabilities>section{border-top:1px solid var(--interactive-border);flex-direction:column;align-items:flex-start;gap:12px;padding-block:20px;display:flex}.yuri-tour-voice-icon{width:32px;height:32px;color:var(--surface-foreground);margin-bottom:8px}.yuri-tour-voice-capabilities h3{font-size:calc(18 * var(--dpt));font-weight:500}.yuri-tour-voice-capabilities p{font-size:calc(13 * var(--dpt));color:var(--surface-muted-foreground);line-height:1.7}.yuri-tour-voice-services{color:var(--surface-muted-foreground);font-size:calc(11 * var(--dpt));flex-wrap:wrap;flex:1;gap:8px 14px;margin:4px 0 12px;display:flex}.yuri-tour-voice-services>span{align-items:center;gap:6px;display:inline-flex}.yuri-tour-voice-services svg{width:14px;height:14px}.yuri-tour-voice-recommendation{background:var(--surface-muted);border-radius:10px;align-items:center;gap:16px;margin-top:16px;padding:18px;display:flex}.yuri-tour-voice-recommendation>div{flex:1;min-width:0}.yuri-tour-voice-recommendation h3{font-size:calc(13 * var(--dpt));font-weight:500}.yuri-tour-voice-recommendation p{color:var(--surface-muted-foreground);font-size:calc(12 * var(--dpt));margin-top:6px;line-height:1.7}@media (width<=600px){.yuri-tour-voice-capabilities{grid-template-columns:1fr;gap:8px}.yuri-tour-voice-recommendation{flex-wrap:wrap}.yuri-setup-tour[data-slot=dialog-content]{gap:16px;padding:22px 18px 18px}.yuri-tour-plugins{grid-template-columns:1fr}.yuri-tour-provider-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.yuri-tour-body{grid-template-rows:auto minmax(0,1fr);grid-template-columns:minmax(0,1fr);gap:16px}.yuri-tour-progress{flex-direction:row;gap:8px}.yuri-tour-progress>button{font-size:calc(11 * var(--dpt));flex:1;gap:6px;padding-inline:4px}.yuri-tour-number{font-size:calc(24 * var(--dpt))}}
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,n}from"./runtime-switch-DEZ1K7qW.js";import{ot as r,st as i}from"./vendor-base-ui-CzHs0bHY.js";import{n as a}from"./vendor-react-DlzBev0S.js";import{s as o}from"./vendor-tanstack-react-query-B-Wpqq5J.js";import{a as s}from"./queryRuntime-2dx7jbt9.js";import{i as c}from"./vendor-reactuses-core-DWo5Wn6R.js";import{f as l,r as u,t as d}from"./button-CyJvQsp5.js";import{Oi as f,da as p}from"./useMobileNavigationStore-BHAEAnfr.js";import{n as m}from"./Icon-BOYrvHyJ.js";import{a as h,n as g,o as _,t as v}from"./dialog-Bapd6e10.js";import{t as y}from"./YuriLogo-XH6UGXtF.js";import{l as b}from"./select-BCLecCtX.js";import{n as x}from"./MarkdownRenderer-D-0KHpNl.js";import{n as S}from"./speechSettingsQueries-alV0B1bP.js";import{n as C,t as w}from"./YuriWordmark-Cr1vkcue.js";import{a as T,c as E,f as D,n as O,r as k,t as A}from"./usePluginsStore-DvvZ8a3q.js";import{c as ee,i as j,n as M,r as N,s as P,t as te}from"./VoiceSettings-DXHfWAgl.js";var F=e(i(),1),I=a(),L=[{name:`Magpie`,spec:`opencode-magpie-plugin`},{name:`Eficy`,spec:`@eficy/opencode2-plugin`},{name:`yee-profile`,spec:`@yee94/opencode-profile`}];function ne(e,t){return e.some(e=>e.parsedKind===`npm`&&P(e.spec).name===t)}async function R(e,t){let n=[];for(let r of new Set(e)){if(!t.current())throw Error(`Runtime changed`);try{let e=await t.list();if(!t.current())throw Error(`Runtime changed`);ne(e,r)||(await t.create(r)).ok||n.push(r)}catch{n.push(r)}}if(!t.current())throw Error(`Runtime changed`);return{failed:n}}function re(e,r,i){let a=t(),o=n();return R(e,{current:()=>!i.aborted&&o===n()&&a===t(),list:async()=>(await s.fetchQuery({...k(r,a),staleTime:0})).entries,create:e=>A.getState().createEntry({spec:e,scope:`user`})})}var z=r(),B=L.map(e=>e.spec),ie=[`tour.models`,`tour.plugins`,`tour.voice`],ae=[{id:`openai`,name:`OpenAI`},{id:`anthropic`,name:`Anthropic`},{id:`google`,name:`Google Gemini`},{id:`github-copilot`,name:`GitHub Copilot`},{id:`deepseek`,name:`DeepSeek`},{id:`openrouter`,name:`OpenRouter`}];function oe(e){let t=(0,I.c)(48),{index:n,info:r,installed:i,selected:a,onSelect:o,onReadme:s}=e,{t:c}=l(),f=L[n],p=r?.kind===`npm-ok`?r:void 0,h=a&&`yuri-tour-card-selected`,g;t[0]===h?g=t[1]:(g=u(`yuri-tour-plugin yuri-tour-select-card`,h),t[0]=h,t[1]=g);let _;t[2]===a?_=t[3]:(_=a&&(0,z.jsx)(m,{name:`check`,className:`size-5`}),t[2]=a,t[3]=_);let v;t[4]===_?v=t[5]:(v=(0,z.jsx)(`span`,{className:`yuri-tour-card-check`,"aria-hidden":`true`,children:_}),t[4]=_,t[5]=v);let y;t[6]!==o||t[7]!==f.name||t[8]!==a||t[9]!==v?(y=(0,z.jsx)(d,{variant:`ghost`,className:`yuri-tour-card-toggle`,"aria-label":f.name,"aria-pressed":a,onClick:o,children:v}),t[6]=o,t[7]=f.name,t[8]=a,t[9]=v,t[10]=y):y=t[10];let b=p?.icon,x;t[11]!==f.name||t[12]!==b?(x=(0,z.jsx)(ee,{name:f.name,src:b,size:30}),t[11]=f.name,t[12]=b,t[13]=x):x=t[13];let S;t[14]===f.name?S=t[15]:(S=(0,z.jsx)(`h3`,{className:`typography-ui-label font-medium`,children:f.name}),t[14]=f.name,t[15]=S);let C;t[16]===f.spec?C=t[17]:(C=(0,z.jsx)(`p`,{className:`break-all typography-micro text-muted-foreground`,children:f.spec}),t[16]=f.spec,t[17]=C);let w;t[18]!==S||t[19]!==C?(w=(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[S,C]}),t[18]=S,t[19]=C,t[20]=w):w=t[20];let T;t[21]===p?T=t[22]:(T=p?.latestVersion&&(0,z.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:p.latestVersion}),t[21]=p,t[22]=T);let E;t[23]!==w||t[24]!==T||t[25]!==x?(E=(0,z.jsxs)(`div`,{className:`flex items-start gap-3 pr-10`,children:[x,w,T]}),t[23]=w,t[24]=T,t[25]=x,t[26]=E):E=t[26];let D;t[27]!==r||t[28]!==p?.description||t[29]!==c?(D=p?.description||c(r?`tour.metadataUnavailable`:`common.loading`),t[27]=r,t[28]=p?.description,t[29]=c,t[30]=D):D=t[30];let O;t[31]===D?O=t[32]:(O=(0,z.jsx)(`p`,{className:`flex-1 typography-meta text-muted-foreground`,children:D}),t[31]=D,t[32]=O);let k=!p,A;t[33]!==s||t[34]!==k?(A=(0,z.jsx)(d,{size:`xs`,variant:`ghost`,className:`yuri-tour-card-link`,disabled:k,onClick:s,children:`README`}),t[33]=s,t[34]=k,t[35]=A):A=t[35];let j;t[36]!==i||t[37]!==c?(j=i&&(0,z.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:c(`tour.saved`)}),t[36]=i,t[37]=c,t[38]=j):j=t[38];let M;t[39]!==A||t[40]!==j?(M=(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[A,j]}),t[39]=A,t[40]=j,t[41]=M):M=t[41];let N;return t[42]!==E||t[43]!==O||t[44]!==M||t[45]!==g||t[46]!==y?(N=(0,z.jsxs)(`section`,{className:g,children:[y,E,O,M]}),t[42]=E,t[43]=O,t[44]=M,t[45]=g,t[46]=y,t[47]=N):N=t[47],N}function se(e){let t=(0,I.c)(28),{settings:n,onComplete:r,onBusy:i}=e,{t:a}=l(),o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o={voiceProvider:`volcengine`,sttProvider:`volcengine`,dictationEnabled:!0,showMessageTTSButtons:!0},t[0]=o):o=t[0];let s=M(n,o),u=c(i),d,f;t[1]!==s.saving||t[2]!==u?(d=()=>(u(s.saving),()=>u(!1)),f=[s.saving,u],t[1]=s.saving,t[2]=u,t[3]=d,t[4]=f):(d=t[3],f=t[4]),F.useEffect(d,f);let p;t[5]!==s||t[6]!==r||t[7]!==n.configured?(p=async e=>{e.preventDefault(),!(!n.configured&&!s.draft.apiKey?.trim())&&(await s.save())?.configured&&r()},t[5]=s,t[6]=r,t[7]=n.configured,t[8]=p):p=t[8];let m=p,h;t[9]===m?h=t[10]:(h=e=>void m(e),t[9]=m,t[10]=h);let g;t[11]===a?g=t[12]:(g=a(`settings.voice.volcengine.name`),t[11]=a,t[12]=g);let _,v;t[13]===s?(_=t[14],v=t[15]):(_=(0,z.jsx)(N,{mode:`tts`,form:s}),v=(0,z.jsx)(N,{mode:`asr`,form:s,showCredentials:!1}),t[13]=s,t[14]=_,t[15]=v);let y;t[16]!==g||t[17]!==_||t[18]!==v?(y=(0,z.jsxs)(D,{label:g,children:[_,v]}),t[16]=g,t[17]=_,t[18]=v,t[19]=y):y=t[19];let b;t[20]!==s.draft||t[21]!==n.configured||t[22]!==a?(b=!n.configured&&!s.draft.apiKey?.trim()&&(0,z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:a(`settings.providers.page.toast.apiKeyRequired`)}),t[20]=s.draft,t[21]=n.configured,t[22]=a,t[23]=b):b=t[23];let x;return t[24]!==b||t[25]!==h||t[26]!==y?(x=(0,z.jsxs)(`form`,{id:`yuri-tour-voice`,onSubmit:h,className:`yuri-settings-section-stack`,children:[y,b]}),t[24]=b,t[25]=h,t[26]=y,t[27]=x):x=t[27],x}function V({runtime:e,onClose:r}){let{t:i}=l(),a=T(),c=C(t=>t.progress[e]?.step??0),[D,k]=F.useState(`magpie`),[A,ee]=F.useState(),[M,N]=F.useState(B.slice(1)),[P,I]=F.useState(`tour`),[R,V]=F.useState(null),[H,U]=F.useState(!1),[ce,W]=F.useState(null),le=n(),G=t(),K=F.useRef(null),q=F.useRef(!1);F.useEffect(()=>{let e=new AbortController;return K.current=e,()=>e.abort()},[]);let J=E(),Y=o({...O(a,B.slice(1),!1,G,!0),enabled:c===1}),X=o({...S(G),enabled:c===2}),ue=J.data?.entries??[],de=e=>{let t=f.getState(),n=e&&t.providers.some(t=>t.id===e);k(`other`),ee(n?void 0:e),t.setSelectedProvider(n?e:`__add_provider__`),I(`providers`)},Z=()=>!K.current?.signal.aborted&&le===n()&&G===t(),Q=t=>{I(`tour`),W(null),C.getState().move(e,t)},$=()=>{Z()&&r()},fe=()=>{c===2?$():Q(c+1)},pe=async()=>{if(!(q.current||H||!K.current)){q.current=!0,U(!0),W(null);try{let e=c===0?D===`magpie`?[B[0]]:[]:M;if(e.length){let t=await re(e,a,K.current.signal);if(!Z())return;if(t.failed.length){W(i(`tour.saveFailed`,{names:t.failed.join(`, `)}));return}}if(c===0&&D===`other`){let e=await s.fetchQuery({...p(a,G),staleTime:0});if(!Z())return;if(e.partial||!e.providers.some(e=>Object.keys(e.models).length>0)){W(i(`tour.noModels`));return}await f.getState().loadProviders({directory:a,forceRefresh:!0,source:`setup-tour`})}Z()&&fe()}catch{Z()&&W(i(`tour.operationFailed`))}finally{q.current=!1,Z()&&U(!1)}}},me=()=>{R===null?P===`tour`?c>0&&Q(c-1):I(`tour`):V(null)},he=R===null?void 0:Y.data?.[B[R]],ge=he?.kind===`npm-ok`?he.readme:void 0;return(0,z.jsx)(v,{open:!0,onOpenChange:e=>{!e&&!H&&(R!==null||P!==`tour`?me():$())},children:(0,z.jsxs)(g,{className:`yuri-setup-tour yuri-settings-workspace`,showCloseButton:!1,"aria-describedby":void 0,children:[(0,z.jsx)(`div`,{className:`yuri-tour-watermark`,"aria-hidden":`true`,children:(0,z.jsx)(y,{width:440,height:440})}),(0,z.jsx)(h,{children:(0,z.jsxs)(_,{className:`yuri-tour-title`,children:[(0,z.jsx)(`span`,{"aria-hidden":`true`,children:`👋`}),i(`tour.title`).split(`Yuri`).map((e,t)=>(0,z.jsxs)(F.Fragment,{children:[t>0&&(0,z.jsx)(w,{width:`2.05em`}),(0,z.jsx)(`span`,{children:e.trim()})]},t))]})}),(0,z.jsxs)(`div`,{className:`yuri-tour-body`,children:[(0,z.jsx)(`nav`,{className:`yuri-tour-progress`,"aria-label":i(`tour.title`),children:ie.map((e,t)=>(0,z.jsxs)(d,{variant:`ghost`,size:`lg`,disabled:H,"aria-current":c===t?`step`:void 0,onClick:()=>{V(null),Q(t)},children:[(0,z.jsx)(`span`,{className:`yuri-tour-number`,"aria-hidden":`true`,children:String(t+1).padStart(2,`0`)}),(0,z.jsx)(`span`,{children:i(e)})]},e))}),(0,z.jsx)(`div`,{className:u(`yuri-tour-content`,P===`providers`&&R===null&&`yuri-tour-provider-content`),children:(0,z.jsxs)(`fieldset`,{disabled:H,className:`contents`,children:[R===null?P===`providers`?(0,z.jsx)(j,{initialConnectionId:A}):P===`voice`&&X.data?(0,z.jsx)(se,{settings:X.data,onComplete:$,onBusy:U}):P===`asr`||P===`tts`?(0,z.jsx)(te,{section:P}):(0,z.jsxs)(z.Fragment,{children:[c<2&&(c===1&&Y.isError||J.isError)&&(0,z.jsxs)(`div`,{role:`alert`,className:`yuri-tour-feedback`,children:[(0,z.jsx)(`p`,{children:i(`tour.metadataUnavailable`)}),(0,z.jsx)(d,{size:`xs`,onClick:()=>{c===1&&Y.refetch(),J.refetch()},children:i(`settings.plugins.status.retry`)})]}),c===0&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`section`,{className:u(`yuri-tour-magpie yuri-tour-select-card`,D===`magpie`&&`yuri-tour-card-selected`),children:[(0,z.jsx)(d,{variant:`ghost`,className:`yuri-tour-card-toggle`,"aria-label":`Magpie`,"aria-pressed":D===`magpie`,onClick:()=>k(D===`magpie`?`other`:`magpie`),children:(0,z.jsx)(`span`,{className:`yuri-tour-card-check`,"aria-hidden":`true`,children:D===`magpie`&&(0,z.jsx)(m,{name:`check`,className:`size-5`})})}),(0,z.jsxs)(`div`,{className:`flex w-full items-center gap-3 pr-10`,children:[(0,z.jsx)(b,{providerId:`magpie`,alt:`Magpie`,className:`size-8 shrink-0`}),(0,z.jsx)(`span`,{className:`typography-ui-label`,children:`Magpie`}),(0,z.jsx)(`span`,{className:`yuri-tour-recommended`,children:i(`tour.recommended`)})]}),(0,z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:i(`tour.magpieDescription`)}),(0,z.jsxs)(`a`,{className:`yuri-tour-card-link typography-meta text-muted-foreground underline`,href:`https://usemagpie.ai/docs/start`,target:`_blank`,rel:`noreferrer`,children:[i(`tour.docs`),` ↗`]})]}),(0,z.jsxs)(`div`,{className:`yuri-tour-provider-heading`,children:[(0,z.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:`OpenCode`}),(0,z.jsxs)(`a`,{className:`typography-meta text-muted-foreground underline`,href:`https://opencode.ai/docs/providers/`,target:`_blank`,rel:`noreferrer`,children:[i(`tour.docs`),` ↗`]})]}),(0,z.jsx)(`div`,{className:`yuri-tour-provider-grid`,children:ae.map(e=>(0,z.jsxs)(d,{variant:`ghost`,className:`yuri-tour-provider-choice`,onClick:()=>de(e.id),children:[(0,z.jsx)(b,{providerId:e.id,alt:e.name,className:`size-6 shrink-0`}),(0,z.jsx)(`span`,{children:e.name})]},e.id))}),(0,z.jsxs)(d,{className:`mt-3`,size:`sm`,variant:`ghost`,onClick:()=>de(),children:[i(`tour.otherProvider`),(0,z.jsx)(m,{name:`arrow-right-s`,className:`size-4`})]})]}),c===1&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`yuri-tour-plugins`,children:[1,2].map(e=>(0,z.jsx)(oe,{index:e,info:Y.data?.[B[e]],installed:ne(ue,B[e]),selected:M.includes(B[e]),onSelect:()=>N(t=>t.includes(B[e])?t.filter(t=>t!==B[e]):[...t,B[e]]),onReadme:()=>V(e)},e))}),(0,z.jsxs)(`a`,{className:`mt-4 inline-block typography-meta text-muted-foreground underline underline-offset-4 hover:text-foreground`,href:`https://opencode.ai/docs/ecosystem/#plugins`,target:`_blank`,rel:`noopener noreferrer`,children:[i(`tour.morePlugins`),` ↗`]})]}),c===2&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`yuri-tour-voice-intro`,children:[(0,z.jsx)(`h2`,{children:i(`tour.voiceHeading`)}),(0,z.jsx)(`p`,{children:i(`tour.voiceIntro`)})]}),(0,z.jsxs)(`div`,{className:`yuri-tour-voice-capabilities`,children:[(0,z.jsxs)(`section`,{children:[(0,z.jsx)(m,{name:`mic`,className:`yuri-tour-voice-icon`}),(0,z.jsx)(`h3`,{children:i(`settings.voice.page.section.speechRecognition`)}),(0,z.jsx)(`p`,{children:i(`tour.dictationDescription`)}),(0,z.jsxs)(`div`,{className:`yuri-tour-voice-services`,children:[(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`img`,{src:`data:image/svg+xml,%3csvg%20height='24'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='24'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eDoubao%3c/title%3e%3cpath%20d='M5.31%2015.756c.172-3.75%201.883-5.999%202.549-6.739-3.26%202.058-5.425%205.658-6.358%208.308v1.12C1.501%2021.513%204.226%2024%207.59%2024a6.59%206.59%200%20002.2-.375c.353-.12.7-.248%201.039-.378.913-.899%201.65-1.91%202.243-2.992-4.877%202.431-7.974.072-7.763-4.5l.002.001z'%20fill='%231E37FC'%3e%3c/path%3e%3cpath%20d='M22.57%2010.283c-1.212-.901-4.109-2.404-7.397-2.8.295%203.792.093%208.766-2.1%2012.773a12.782%2012.782%200%2001-2.244%202.992c3.764-1.448%206.746-3.457%208.596-5.219%202.82-2.683%203.353-5.178%203.361-6.66a2.737%202.737%200%2000-.216-1.084v-.002z'%20fill='%2337E1BE'%3e%3c/path%3e%3cpath%20d='M14.303%201.867C12.955.7%2011.248%200%209.39%200%207.532%200%205.883.677%204.545%201.807%202.791%203.29%201.627%205.557%201.5%208.125v9.201c.932-2.65%203.097-6.25%206.357-8.307.5-.318%201.025-.595%201.569-.829%201.883-.801%203.878-.932%205.746-.706-.222-2.83-.718-5.002-.87-5.617h.001z'%20fill='%23A569FF'%3e%3c/path%3e%3cpath%20d='M17.305%204.961a199.47%20199.47%200%2001-1.08-1.094c-.202-.213-.398-.419-.586-.622l-1.333-1.378c.151.615.648%202.786.869%205.617%203.288.395%206.185%201.898%207.396%202.8-1.306-1.275-3.475-3.487-5.266-5.323z'%20fill='%231E37FC'%3e%3c/path%3e%3c/svg%3e`,alt:``,className:`size-4`}),i(`settings.voice.volcengine.name`)]}),(0,z.jsxs)(`span`,{children:[(0,z.jsx)(m,{name:`computer`}),i(`settings.voice.page.provider.local`)]}),(0,z.jsxs)(`span`,{children:[(0,z.jsx)(m,{name:`server`}),i(`settings.voice.page.provider.server`)]})]}),(0,z.jsxs)(d,{size:`sm`,onClick:()=>I(`asr`),children:[i(`tour.configureInput`),(0,z.jsx)(m,{name:`arrow-right-s`,className:`size-4`})]})]}),(0,z.jsxs)(`section`,{children:[(0,z.jsx)(m,{name:`volume-up`,className:`yuri-tour-voice-icon`}),(0,z.jsx)(`h3`,{children:i(`tour.readAloudTitle`)}),(0,z.jsx)(`p`,{children:i(`tour.readAloudDescription`)}),(0,z.jsxs)(`div`,{className:`yuri-tour-voice-services`,children:[(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`img`,{src:`data:image/svg+xml,%3csvg%20height='24'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='24'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eDoubao%3c/title%3e%3cpath%20d='M5.31%2015.756c.172-3.75%201.883-5.999%202.549-6.739-3.26%202.058-5.425%205.658-6.358%208.308v1.12C1.501%2021.513%204.226%2024%207.59%2024a6.59%206.59%200%20002.2-.375c.353-.12.7-.248%201.039-.378.913-.899%201.65-1.91%202.243-2.992-4.877%202.431-7.974.072-7.763-4.5l.002.001z'%20fill='%231E37FC'%3e%3c/path%3e%3cpath%20d='M22.57%2010.283c-1.212-.901-4.109-2.404-7.397-2.8.295%203.792.093%208.766-2.1%2012.773a12.782%2012.782%200%2001-2.244%202.992c3.764-1.448%206.746-3.457%208.596-5.219%202.82-2.683%203.353-5.178%203.361-6.66a2.737%202.737%200%2000-.216-1.084v-.002z'%20fill='%2337E1BE'%3e%3c/path%3e%3cpath%20d='M14.303%201.867C12.955.7%2011.248%200%209.39%200%207.532%200%205.883.677%204.545%201.807%202.791%203.29%201.627%205.557%201.5%208.125v9.201c.932-2.65%203.097-6.25%206.357-8.307.5-.318%201.025-.595%201.569-.829%201.883-.801%203.878-.932%205.746-.706-.222-2.83-.718-5.002-.87-5.617h.001z'%20fill='%23A569FF'%3e%3c/path%3e%3cpath%20d='M17.305%204.961a199.47%20199.47%200%2001-1.08-1.094c-.202-.213-.398-.419-.586-.622l-1.333-1.378c.151.615.648%202.786.869%205.617%203.288.395%206.185%201.898%207.396%202.8-1.306-1.275-3.475-3.487-5.266-5.323z'%20fill='%231E37FC'%3e%3c/path%3e%3c/svg%3e`,alt:``,className:`size-4`}),i(`settings.voice.volcengine.name`)]}),(0,z.jsxs)(`span`,{children:[(0,z.jsx)(b,{providerId:`openai`,alt:`OpenAI`,className:`size-4`}),`OpenAI`]}),(0,z.jsxs)(`span`,{children:[(0,z.jsx)(m,{name:`computer`}),i(`settings.voice.page.provider.browser`)]}),(0,z.jsxs)(`span`,{children:[(0,z.jsx)(m,{name:`cloud`}),i(`settings.voice.page.provider.custom`)]})]}),(0,z.jsxs)(d,{size:`sm`,onClick:()=>I(`tts`),children:[i(`tour.configureReadAloud`),(0,z.jsx)(m,{name:`arrow-right-s`,className:`size-4`})]})]})]}),(0,z.jsxs)(`section`,{className:`yuri-tour-voice-recommendation`,children:[(0,z.jsx)(`img`,{src:`data:image/svg+xml,%3csvg%20height='24'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='24'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eDoubao%3c/title%3e%3cpath%20d='M5.31%2015.756c.172-3.75%201.883-5.999%202.549-6.739-3.26%202.058-5.425%205.658-6.358%208.308v1.12C1.501%2021.513%204.226%2024%207.59%2024a6.59%206.59%200%20002.2-.375c.353-.12.7-.248%201.039-.378.913-.899%201.65-1.91%202.243-2.992-4.877%202.431-7.974.072-7.763-4.5l.002.001z'%20fill='%231E37FC'%3e%3c/path%3e%3cpath%20d='M22.57%2010.283c-1.212-.901-4.109-2.404-7.397-2.8.295%203.792.093%208.766-2.1%2012.773a12.782%2012.782%200%2001-2.244%202.992c3.764-1.448%206.746-3.457%208.596-5.219%202.82-2.683%203.353-5.178%203.361-6.66a2.737%202.737%200%2000-.216-1.084v-.002z'%20fill='%2337E1BE'%3e%3c/path%3e%3cpath%20d='M14.303%201.867C12.955.7%2011.248%200%209.39%200%207.532%200%205.883.677%204.545%201.807%202.791%203.29%201.627%205.557%201.5%208.125v9.201c.932-2.65%203.097-6.25%206.357-8.307.5-.318%201.025-.595%201.569-.829%201.883-.801%203.878-.932%205.746-.706-.222-2.83-.718-5.002-.87-5.617h.001z'%20fill='%23A569FF'%3e%3c/path%3e%3cpath%20d='M17.305%204.961a199.47%20199.47%200%2001-1.08-1.094c-.202-.213-.398-.419-.586-.622l-1.333-1.378c.151.615.648%202.786.869%205.617%203.288.395%206.185%201.898%207.396%202.8-1.306-1.275-3.475-3.487-5.266-5.323z'%20fill='%231E37FC'%3e%3c/path%3e%3c/svg%3e`,alt:``,className:`size-6 shrink-0`}),(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,z.jsx)(`h3`,{children:i(`settings.voice.volcengine.name`)}),(0,z.jsx)(`span`,{className:`yuri-tour-recommended`,children:i(`tour.recommended`)})]}),(0,z.jsx)(`p`,{children:i(`tour.voiceAllowance`)})]}),(0,z.jsx)(d,{disabled:!X.data,size:`sm`,onClick:()=>I(`voice`),children:i(`tour.configureVoice`)})]}),X.isError&&(0,z.jsxs)(`div`,{role:`alert`,className:`yuri-tour-feedback`,children:[(0,z.jsx)(`p`,{children:i(`settings.voice.volcengine.loadFailed`)}),(0,z.jsx)(d,{size:`xs`,onClick:()=>void X.refetch(),children:i(`settings.voice.volcengine.retry`)})]})]})]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`h3`,{className:`typography-ui-label mb-4`,children:[L[R].name,` · README`]}),ge?(0,z.jsx)(x,{content:ge,enableFileReferences:!1}):(0,z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:i(`tour.metadataUnavailable`)})]}),ce&&R===null&&(0,z.jsx)(`p`,{role:`alert`,className:`yuri-tour-feedback`,children:ce})]})})]}),(0,z.jsxs)(`footer`,{className:`yuri-tour-footer`,children:[(P!==`tour`||R!==null)&&(0,z.jsx)(d,{variant:`ghost`,size:`sm`,disabled:H,onClick:me,children:i(`onboarding.common.actions.back`)}),R===null&&(0,z.jsxs)(`div`,{className:`ml-auto flex flex-wrap justify-end gap-2`,children:[(0,z.jsx)(d,{variant:`ghost`,size:`sm`,disabled:H,onClick:fe,children:i(`tour.later`)}),c===2?(0,z.jsx)(d,{size:`sm`,disabled:H,type:P===`voice`?`submit`:`button`,form:P===`voice`?`yuri-tour-voice`:void 0,onClick:P===`voice`?void 0:$,children:i(P===`voice`?`settings.common.actions.saveChanges`:`tour.finish`)}):(0,z.jsxs)(d,{size:`sm`,disabled:H||!J.data||J.isError,"aria-busy":H,onClick:()=>void pe(),children:[H&&(0,z.jsx)(m,{name:`loader-4`,className:`size-3 animate-spin`}),i(`tour.continue`)]})]})]})]})})}export{V as SetupTourDialog};
@@ -1 +0,0 @@
1
- import"./rolldown-runtime-hePW80VL.js";import{c as e,s as t}from"./runtime-switch-DEZ1K7qW.js";import{a as n,i as r}from"./vendor-zustand-vDaAPGfl.js";import{ot as i,st as a}from"./vendor-base-ui-CzHs0bHY.js";import{Mt as o}from"./bootstrap-C8paoQ0j.js";import{n as s}from"./vendor-react-DlzBev0S.js";var c=n()(r(e=>({progress:{},openedRuntime:null,open:t=>e(e=>({openedRuntime:t,progress:{...e.progress,[t]:e.progress[t]??{step:0,dismissed:!1}}})),move:(t,n)=>e(e=>({progress:{...e.progress,[t]:{step:n,dismissed:e.progress[t]?.dismissed??!1}}})),dismiss:t=>e(e=>({openedRuntime:e.openedRuntime===t?null:e.openedRuntime,progress:{...e.progress,[t]:{step:e.progress[t]?.step??0,dismissed:!0}}}))}),{name:`yuri-setup-tour`,storage:o(),partialize:e=>({progress:e.progress}),merge:(e,t)=>{let n=e,r={};if(n?.progress&&typeof n.progress==`object`)for(let[e,t]of Object.entries(n.progress))t&&[0,1,2].includes(t.step)&&typeof t.dismissed==`boolean`&&(r[e]={step:t.step,dismissed:t.dismissed});return{...t,progress:r,openedRuntime:null}}}));e(e=>{t(e)&&c.persist.rehydrate()}),a();var l=s(),u=`/assets/yuri-wordmark-DSJqXYVo.svg`,d=i();function f(e){let t=(0,l.c)(5),{className:n,width:r}=e,i=n===void 0?``:n,a=r===void 0?112:r,o=`inline-block shrink-0 ${i}`,s;t[0]===a?s=t[1]:(s={width:a,aspectRatio:`626.723 / 280`,backgroundColor:`currentColor`,mask:`url("${u}") center / contain no-repeat`,WebkitMask:`url("${u}") center / contain no-repeat`},t[0]=a,t[1]=s);let c;return t[2]!==o||t[3]!==s?(c=(0,d.jsx)(`span`,{role:`img`,"aria-label":`Yuri`,className:o,style:s}),t[2]=o,t[3]=s,t[4]=c):c=t[4],c}export{c as n,f as t};
@@ -1 +0,0 @@
1
- import{C as e,D as t,I as n,L as r,M as i,O as a,P as o,S as s,T as c,_ as l,a as u,b as d,c as f,j as p,n as m,o as h,r as g,s as _,t as v,v as y,w as b,y as x}from"./vendor-opencode-client-cQ47ywrT.js";import{i as ee}from"./vendor-tanstack-query-core-Y_YoRHtC.js";import{n as te,r as ne}from"./fileQueries-C2Rs6TPz.js";import{o as re}from"./path-utils-jGozTg9d.js";import{a as ie,n as ae}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{n as oe}from"./pathNormalization-ewtPqJWn.js";import{n as se}from"./platform-sEg2IOLZ.js";import{Dt as S,ht as C,mt as w,y as T}from"./vendor-effect-X1Hqc7ba.js";import{t as E}from"./native-errors-06if6eu-.js";import{a as ce,i as le,n as ue,o as de,r as fe}from"./appearance--vFosLNi.js";import{i as pe,o as me}from"./fileReferenceParser-1HHDBUum.js";import{n as he,t as ge}from"./vendor-solid-js-D98iXT7C.js";import{a as _e,c as ve,d as D,f as O,g as k,h as A,i as j,l as M,m as N,n as P,o as F,p as I,r as ye,s as be,t as xe,u as Se}from"./vendor-opencode-plugin-BmdTE4Te.js";var L={"@opencode/plugin/gui":F,"@opencode/plugin/gui/main":F,"@opencode/plugin/gui/file":_e,"@opencode/plugin/gui/review":j,"@opencode/plugin/gui/browser":ye,"@opencode/plugin/rpc":xe,"@opencode/schema/rpc":P,"@opencode/client":g,"@opencode/client/effect":m,"@opencode/client/solid":v,effect:T,"solid-js":o,"solid-js/web":he,"solid-js/store":_},Ce=new Set(`assert assert/strict async_hooks buffer child_process cluster console constants crypto dgram diagnostics_channel dns dns/promises domain events fs fs/promises http http2 https inspector inspector/promises module net os path path/posix path/win32 perf_hooks process punycode querystring readline readline/promises repl stream stream/consumers stream/promises stream/web string_decoder sys timers timers/promises tls trace_events tty url util util/types v8 vm wasi worker_threads zlib`.split(` `));function we(){let e=new Proxy(function(){},{get:(t,n)=>n===`then`?void 0:n===Symbol.hasInstance?()=>!1:n===Symbol.toPrimitive||n===`toString`?()=>`[main-only module]`:e,apply:()=>e,construct:()=>e,set:()=>!0});return e}function Te(e,t){if(e.length>16777216)throw Error(`GUI bundle exceeds 16 MiB`);let n={exports:{}};Function(`require`,`module`,`exports`,e)(e=>{if(Object.hasOwn(L,e))return L[e];if(e===`electron`||e.startsWith(`node:`)||Ce.has(e))return we();throw Error(`Unsupported GUI shared module: ${e}`)},n,n.exports);let r=n.exports,i=r&&typeof r==`object`&&`default`in r?r.default:r;if(!i||typeof i!=`object`)throw Error(`GUI bundle must default-export Plugin.define`);if((!(`setup`in i)||typeof i.setup!=`function`)&&!(t&&`main`in i&&typeof i.main==`function`))throw new E(`GUI_PLUGIN_UNSUPPORTED`,`This host requires a window setup; main-only plugins are unsupported`);if(`os`in i&&i.os!==void 0){if(!t)throw new E(`GUI_PLUGIN_UNSUPPORTED`,`OS-restricted plugins require the native GUI host`);if(!Array.isArray(i.os)||!i.os.includes(t))throw new E(`GUI_PLUGIN_UNSUPPORTED`,`GUI plugin is unavailable on this OS`)}if(`main`in i&&i.main!==void 0&&typeof i.main!=`function`)throw Error(`Invalid GUI main entry`);if(`stores`in i&&i.stores!==void 0){if(!i.stores||typeof i.stores!=`object`||Array.isArray(i.stores))throw Error(`Invalid GUI stores`);for(let e of Object.values(i.stores))if(!e||typeof e!=`object`||!(`schema`in e)||!S(e.schema)||!(`scope`in e)||![`global`,`session`].includes(String(e.scope))||!(`initial`in e))throw Error(`Invalid GUI store declaration`)}if(`i18n`in i&&i.i18n!==void 0){if(!i.i18n||typeof i.i18n!=`object`||Array.isArray(i.i18n))throw Error(`Invalid GUI locale catalog`);for(let e of Object.values(i.i18n))if(!e||typeof e!=`object`||Array.isArray(e)||Object.values(e).some(e=>typeof e!=`string`))throw Error(`GUI locales must be inline string dictionaries`)}return i}function R(e){let t=e;if(/^file:/i.test(t)){let e=new URL(t);t=`${e.hostname&&e.hostname!==`localhost`?`//${e.hostname}`:``}${decodeURIComponent(e.pathname)}`,/^\/[a-z]:\//i.test(t)&&(t=t.slice(1))}let n=oe(t)??``;return n===`.`?``:n}var z=e=>/^(?:\/|[a-z]:\/)/i.test(e),B=()=>{throw Error(`Unsupported GUI file API: tree`)},V=class extends Error{},H=e=>new TextEncoder().encode(e).byteLength,Ee=class{files;query;transport;root;api;ended=!1;states=new Map;inflight=new Map;watches=new Map;apiLeases=new Map;registeredOwners=new WeakSet;endedOwners=new WeakSet;leaseCount=0;rerun=new Set;selections=new Map;scrolls=new Map;subscriptions=new Map;constructor(e,t,n,r){this.files=e,this.query=t,this.transport=n,this.root=r,this.root=R(r),this.api={root:this.root,ready:()=>!this.ended,resolve:e=>this.resolve(e),absolute:z,get:e=>{let t=this.track(e,`file`);return this.states.get(t)},missing:e=>{let t=this.track(e,`missing`);return this.states.get(t)?.notFound===!0},sync:(e,t)=>{let n=a();return this.ended||n&&this.endedOwners.has(n)?Promise.resolve():(this.acquireApiLease(e),this.sync(e,t?.force))},unwatch:e=>this.releaseApiLease(a(),this.resolve(e)),exists:async e=>{try{if(this.files.statFile)return(await this.query.fetchQuery(this.statOptions(e))).isFile;let t=this.full(e);return(await this.files.listDirectory(t.slice(0,t.lastIndexOf(`/`)))).entries.some(e=>!e.isDirectory&&R(e.path)===t)}catch{return!1}},search:async(e,t)=>{if(t?.kind===`any`)throw Error(`Unsupported GUI file search: directories`);t?.signal?.throwIfAborted();let r=await this.query.fetchQuery({queryKey:[`gui-plugin-files`,n,this.root,`search`,e,t?.limit],gcTime:3e4,queryFn:async({signal:n})=>(n.throwIfAborted(),this.files.search({directory:this.root,query:e,maxResults:t?.limit??100}))});if(t?.signal?.throwIfAborted(),this.ended)throw new DOMException(`GUI file model was disposed`,`AbortError`);return r.map(e=>this.resolve(e.path))},selection:{get:e=>this.selections.get(this.track(e,`selection`)),set:(e,t)=>{let n=this.resolve(e),r=this.selections.get(n);r===t||r&&t&&r.start===t.start&&r.end===t.end&&r.side===t.side&&r.endSide===t.endSide||(this.selections.set(n,t),this.trim(this.selections,`selection`),this.changed(n,`selection`))}},scroll:{get:e=>this.scrolls.get(this.track(e,`scroll`))??{},set:(e,t)=>{let n=this.resolve(e),r=this.scrolls.get(n),i={...r,...t};(r?.top!==i.top||r?.left!==i.left)&&(this.scrolls.set(n,i),this.trim(this.scrolls,`scroll`),this.changed(n,`scroll`))}},tree:{list:B,state:B,sync:B,expand:B,collapse:B}}}resolve(e){let t=R(e);if(!z(t))return t;if(t===this.root)return``;let n=this.root.endsWith(`/`)?this.root:`${this.root}/`;return t.startsWith(n)?t.slice(n.length):t}full(e){let t=this.resolve(e);return z(t)?t:R(`${this.root}/${t}`)}input(e){return{scopeDirectory:this.root,path:this.full(e),options:{directory:this.root}}}statOptions(e){return{...ne(this.files,this.input(e),this.transport),gcTime:3e4}}track(e,n){let r=this.resolve(e),a=t();if(!a||this.ended)return r;let o=`${n}:${r}`,s=this.subscriptions.get(o);s||(s={revision:c(0),listeners:new Set},this.subscriptions.set(o,s));let l=s;return l.listeners.has(a)||(l.listeners.add(a),i(a,()=>p(()=>{l.listeners.delete(a),!l.listeners.size&&this.subscriptions.get(o)===l&&this.subscriptions.delete(o)}))),l.revision[0](),r}changed(e,t){this.ended||this.subscriptions.get(`${t}:${e}`)?.revision[1](e=>e+1)}trim(e,t){for(;e.size>64;){let n=e.keys().next().value;e.delete(n),this.changed(n,t)}}setState(e,t){let n=this.states.get(e);n?.content?.content===t.content?.content&&n?.content?.type===t.content?.type&&(t.content=n?.content),!(n&&n.loaded===t.loaded&&n.loading===t.loading&&n.error===t.error&&n.notFound===t.notFound&&n.content===t.content)&&(this.states.set(e,t),l(()=>{this.changed(e,`file`),n?.notFound===!0!=(t.notFound===!0)&&this.changed(e,`missing`)}))}acquireApiLease(e){let t=a();if(this.ended||t&&this.endedOwners.has(t)||!this.files.statFile)return;let n=this.resolve(e),r=this.apiLeases.get(t);if(r?.has(n))return;if(this.leaseCount>=256)throw Error(`GUI file consumer limit exceeded`);let i=this.watch(n);r||(r=new Map,this.apiLeases.set(t,r)),r.set(n,i),this.leaseCount++,t&&!this.registeredOwners.has(t)&&(this.registeredOwners.add(t),p(()=>{`fn`in t||this.endedOwners.add(t),this.registeredOwners.delete(t);for(let e of[...this.apiLeases.get(t)?.keys()??[]])this.releaseApiLease(t,e)}))}releaseApiLease(e,t){let n=this.apiLeases.get(e),r=n?.get(t);r&&(n.delete(t),this.leaseCount--,n.size||this.apiLeases.delete(e),r())}reserve(e){if(!this.states.has(e)){if(this.states.size>=64){let e=[...this.states.keys()].find(e=>!this.watches.has(e)&&!this.inflight.has(e));if(!e)throw Error(`GUI file cache limit exceeded`);let t=this.states.get(e)?.notFound===!0;this.states.delete(e),l(()=>{this.changed(e,`file`),t&&this.changed(e,`missing`)})}this.states.set(e,{path:e,name:e.split(`/`).at(-1)??e})}}async sync(e,t=!1){if(this.ended)return;let n=this.resolve(e);if(this.inflight.has(n))return t&&this.rerun.add(n),this.inflight.get(n);if(!t&&this.states.get(n)?.loaded&&!this.states.get(n)?.error)return;this.reserve(n);let r=this.states.get(n);this.setState(n,{...r,path:n,name:n.split(`/`).at(-1)??n,loading:!r?.loaded&&!this.watches.get(n)?.failed});let i=(async()=>{try{do{this.rerun.delete(n);let e=this.watches.get(n),r=e?.epoch;try{let i=te(this.files,this.input(n),this.transport),a=await this.query.fetchQuery({...i,gcTime:3e4,staleTime:t?0:3e4,queryFn:async()=>{if(!this.files.readFile)throw Error(`File content reads are unavailable in this runtime`);let e=await this.files.readFile(this.full(n),{directory:this.root});if(e.exists===!1)throw new V(`File does not exist`);let t=e.content;if(H(t)>131072)throw Error(`GUI file preview exceeds 128 KiB`);return t}});if(this.ended)return;if(H(a)>131072)throw Error(`GUI file preview exceeds 128 KiB`);(!e||e.epoch===r&&!e.failed)&&this.setState(n,{path:n,name:n.split(`/`).at(-1)??n,loaded:!0,loading:!1,content:{type:`text`,content:a}})}catch(t){if(this.ended)return;if((!e||e.epoch===r&&!e.failed)&&this.setState(n,{...this.states.get(n),loading:!1,...t instanceof V?{notFound:!0}:{},error:String(t)}),!this.rerun.has(n))throw t}t=!0}while(!this.ended&&this.rerun.has(n))}finally{this.inflight.delete(n),this.rerun.delete(n)}})();return this.inflight.set(n,i),i}watch(e){if(this.ended||!this.files.statFile)return()=>{};let t=this.resolve(e),n=this.watches.get(t);if(!n){if(this.watches.size>=64)throw Error(`GUI file watch limit exceeded`);this.reserve(t),n={count:0,epoch:0,failed:!1,stop:()=>{}};let e=n;this.watches.set(t,e);let r,i=new ee(this.query,{...this.statOptions(t),refetchInterval:2e3,refetchIntervalInBackground:!1}),a=i.subscribe(n=>{if(this.ended||this.watches.get(t)!==e||n.isFetching)return;if(n.isError||n.isSuccess&&!n.data.isFile){e.failed=!0,e.epoch++,this.setState(t,{...this.states.get(t),loading:!1,notFound:n.isSuccess?!0:this.states.get(t)?.notFound,error:n.isError?String(n.error):`File does not exist`});return}if(!n.data||!n.isSuccess)return;let i=`${n.data.size}:${n.data.mtimeMs??``}`,a=e.failed||r!==void 0&&i!==r;e.failed=!1,r=i,a&&(e.epoch++,this.sync(t,!0).catch(()=>{}))});e.stop=()=>{a(),i.destroy()},this.states.get(t)?.loaded&&this.sync(t,!0).catch(()=>{})}n.count++;let r=!0;return()=>{r&&(r=!1,--n.count===0&&this.watches.get(t)===n&&this.stopWatch(t))}}stopWatch(e){this.watches.get(e)?.stop(),this.watches.delete(e)}dispose(){this.ended=!0;for(let e of this.watches.values())e.stop();this.watches.clear(),this.apiLeases.clear(),this.leaseCount=0,this.rerun.clear(),this.states.clear(),this.inflight.clear(),this.selections.clear(),this.scrolls.clear(),this.subscriptions.clear()}},U=256,W=2097152,G=e=>structuredClone(f(e)),De=class{backend;transport;memory=new Map;resets=new Map;constructor(e,t){this.backend=e,this.transport=t}forPlugin(e,t){let n=(t,n=`global`)=>{if(typeof n==`object`&&`session`in n&&!n.session.location)throw Error(`Unsupported GUI storage: session location is unknown`);let r=n===`global`?n:`session`in n?[n.session.server.id,n.session.id,n.session.location]:[n.server,n.directory];return`yuri.gui-plugin.${JSON.stringify([this.transport,e,r,t])}`},r=e=>{if(t.aborted)throw Error(`GUI plugin has been disposed`);if(e!==void 0)throw Error(`Unsupported GUI storage migration: from`)},i=new Map;return{store:(e,a)=>{r(a.from);let o=n(e,a.scope),s=i.get(o);if(s)return s;if(i.size>=U)throw Error(`GUI plugin store limit exceeded`);let l=w(a.schema),u=C(a.schema),d=l(u(G(a.initial)));if(JSON.stringify(u(d)).length>W)throw Error(`GUI plugin store exceeds 2 MiB`);let f=d,p=this.backend.getItem(o);if(p!==null&&p.length<=W)try{f=l(JSON.parse(p))}catch{f=d}let[m,h]=c(f),g=e=>{r();let t=JSON.stringify(u(G(e)));if(t.length>W)throw Error(`GUI plugin store exceeds 2 MiB`);let n=l(JSON.parse(t));this.backend.setItem(o,t),h(()=>n)},_={get value(){return m()},ready:()=>!0,set:g,update:e=>{let t=G(m());if(e(t)!==void 0)throw Error(`Store update must not return a replacement`);g(t)}},v=()=>h(()=>G(d)),y=this.resets.get(o)??new Set;return y.add(v),this.resets.set(o,y),t.addEventListener(`abort`,()=>{y.delete(v),y.size||this.resets.delete(o),i.clear()},{once:!0}),i.set(o,_),_},memory:(e,t)=>{r();let i=n(e),a=this.memory.get(i);if(a)return[a[0],e=>{r(),a[1](e)}];if(this.memory.size>=U)throw Error(`GUI plugin memory store limit exceeded`);if(JSON.stringify(t.initial).length>W)throw Error(`GUI plugin memory exceeds 2 MiB`);let[o,s]=u(G(t.initial)),c=[o,e=>{r();let t=G(f(o));if(e(t)!==void 0)throw Error(`Memory update must not return a replacement`);if(JSON.stringify(t).length>W)throw Error(`GUI plugin memory exceeds 2 MiB`);s(h(t))}];return this.memory.set(i,[o,e=>{let t=G(f(o));if(e(t)!==void 0)throw Error(`Memory update must not return a replacement`);if(JSON.stringify(t).length>W)throw Error(`GUI plugin memory exceeds 2 MiB`);s(h(t))}]),c},remove:(e,t)=>{r(t?.from);let i=n(e,t?.scope);this.backend.removeItem(i);for(let e of this.resets.get(i)??[])e()}}}dispose(){this.memory.clear(),this.resets.clear()}},K=e=>e===`yuri.exportPDF`||e===`yuri.exportLongImage`,Oe=class{api;probe;clients=new Map;ended=!1;constructor(e){this.api=e}use(e,t){let n=this.clients.get(t),r=n?.get(e);if(r)return r.live;let[i,a]=c(this.api&&!t.aborted&&!this.ended?{status:`pending`}:{status:`inactive`,reason:`disabled`}),o=()=>{a({status:`inactive`,reason:`disabled`}),t.removeEventListener(`abort`,o),this.clients.delete(t)},s={live:k(i),stop:o};if(this.ended||t.aborted||(n||(n=new Map,this.clients.set(t,n)),n.set(e,s),t.addEventListener(`abort`,o,{once:!0}),!this.api))return s.live;let l=this.api;return this.probe??=Promise.resolve().then(()=>l.capabilities()),this.probe.then(n=>{if(this.ended||t.aborted)return;let r=e===`yuri.exportPDF`?`exportPDF`:`exportLongImage`;if(n.version!==1||!n[r]){a({status:`inactive`,reason:`disabled`});return}let o=async(e,n={})=>{if(this.ended||t.aborted||i().status!==`active`)return{status:`cancelled`};let o=AbortSignal.any([t,...n.signal?[n.signal]:[]]);try{return await l[r](e,{...n,signal:o})}catch(e){throw e&&typeof e==`object`&&`code`in e&&e.code===`EXPORT_UNSUPPORTED`&&a({status:`inactive`,reason:`failed`}),e}},s=Object.freeze(e===`yuri.exportPDF`?{version:1,limits:n.limits,exportPDF:o}:{version:1,limits:n.limits,exportLongImage:o});a({status:`active`,generation:1,value:s})}).catch(()=>{!this.ended&&!t.aborted&&a({status:`inactive`,reason:`failed`})}),s.live}dispose(){this.ended=!0;for(let e of this.clients.values())for(let t of e.values())t.stop();this.clients.clear()}};function q(e,t){let n=new Map,r=Object.freeze({dismiss(){}});return e.addEventListener(`abort`,()=>{for(let e of[...n.values()])e.handle.dismiss()},{once:!0}),Object.freeze({show(i){if(e.aborted)return r;if(!t)throw new E(`GUI_PLUGIN_UNSUPPORTED`,`GUI toast is unavailable`);if(!i||typeof i!=`object`)throw new E(`GUI_PLUGIN_INVALID_INPUT`,`Expected toast options`);let{title:a,description:o,variant:s=`default`,duration:c=5e3,persistent:l=!1,icon:u,actions:d}=i;if(typeof a!=`string`||o!==void 0&&typeof o!=`string`||![`default`,`success`,`error`,`loading`].includes(s)||typeof l!=`boolean`||typeof c!=`number`||!Number.isFinite(c)||c<0)throw new E(`GUI_PLUGIN_INVALID_INPUT`,`Invalid toast options`);if(u!==void 0||d!==void 0)throw new E(`GUI_PLUGIN_UNSUPPORTED`,`GUI toast icon/actions are unsupported`);if(e.aborted)return r;let f=JSON.stringify([a,o??null,s,c,l]),p=n.get(f),m=()=>{let e=n.get(f);!e||e.id!==h||(clearTimeout(e.timer),n.delete(f))},h=(s==="default"?t:t[s])(a,{id:p?.id,description:o,duration:l?1/0:c,onDismiss:m,onAutoClose:m}),g=p?.handle??Object.freeze({dismiss(){m(),t.dismiss(h)}});clearTimeout(p?.timer);let _=s===`loading`&&!l?setTimeout(()=>g.dismiss(),c):void 0;return n.set(f,{id:h,handle:g,timer:_}),g}})}var ke=ie(`YuriMedia`);async function Ae(e){let t=/\.html?$/i.test(e.name)?`text/html`:`text/plain`,n=new Blob([e.content],{type:t});if(se()){if(!ae.isPluginAvailable(`YuriMedia`))throw new E(`GUI_PLUGIN_UNSUPPORTED`,`Native file saving is unavailable`);if(n.size>33554432)throw new E(`GUI_PLUGIN_INVALID_INPUT`,`File exceeds maximum size`);let r=await new Promise((e,t)=>{let r=new FileReader;r.onload=()=>{if(typeof r.result!=`string`){t(Error(`Failed to encode file`));return}e(r.result.slice(r.result.indexOf(`,`)+1))},r.onerror=()=>t(r.error??Error(`Failed to encode file`)),r.readAsDataURL(n)});return!(await ke.saveFile({dataBase64:r,mimeType:t,filename:e.name})).cancelled}let r=URL.createObjectURL(n),i=document.createElement(`a`);try{return i.href=r,i.download=e.name,document.body.append(i),i.click(),!0}finally{i.remove(),setTimeout(()=>URL.revokeObjectURL(r),1e3)}}var J=d();function je(e){return{version:1,register(t){let n=r(J);if(!n||n.plugin!==e||n.signal.aborted||e.aborted)throw Error(`Preview actions require the owning mounted panel`);let i=new AbortController,a=AbortSignal.any([e,n.signal,i.signal]),o,s=()=>{a.removeEventListener(`abort`,s),i.abort(),o?.remove()};p(s),a.addEventListener(`abort`,s,{once:!0});try{o=t.render({element:t.element,signal:a,async snapshot(e={}){let r=AbortSignal.any([a,...e.signal?[e.signal]:[]]);if(r.throwIfAborted(),!n.content.contains(t.element)||n.target.contains(t.element))throw Error(`Preview capture region is no longer in its owning panel`);let i=await t.capture({...e,signal:r});if(r.throwIfAborted(),!n.content.contains(t.element))throw Error(`Preview capture region was replaced`);return i}}),a.throwIfAborted(),n.target.append(o)}catch(e){throw s(),e}return s}}}function Y(e,t){return JSON.stringify([e,t])}function Me(e){if(!e||typeof e!=`object`||!(`id`in e)||typeof e.id!=`string`||!e.id.trim()||e.id.length>128||!(`title`in e)||typeof e.title!=`string`||!(`render`in e)||typeof e.render!=`function`)throw Error(`Invalid yuri.page contribution`);return e}var X=e=>{throw new E(`GUI_PLUGIN_UNSUPPORTED`,`Unsupported GUI host API: ${e}`)};function Z(e,t){return new Proxy(t,{get:(t,n)=>n in t?Reflect.get(t,n):X(`${e}.${String(n)}`)})}var Q=e=>Object.freeze(e.map(e=>Object.freeze(e)));function Ne(e,t){if(!e.fields||!t.fields)return!1;let n=Reflect.ownKeys(e.fields);return n.length===Reflect.ownKeys(t.fields).length&&n.every(n=>{let r=e.fields[n],i=t.fields[n];return i!==void 0&&`value`in r&&`value`in i&&Object.is(r.value,i.value)&&r.enumerable===i.enumerable&&r.configurable===i.configurable&&r.writable===i.writable})}function $(e,t){if(e){for(let n of e.owned??[])$(n,t);e.cleanups&&=e.cleanups.map(e=>()=>{try{Promise.resolve(e()).catch(t)}catch(e){t(e)}})}}var Pe=class{options;fileIcons=new de;appearanceCatalog=new le;instances=new Map;listeners=new Set;panelMounts=new Set;fileViews=new Map;changes=c(0);views=c(0);session=c();currentPage=c();appearance;layouts=new Map;files;storage;ended=!1;contracts=new Map;snapshot=Object.freeze({plugins:Object.freeze([]),commands:Object.freeze([]),titlebarItems:Object.freeze([]),panels:Object.freeze([]),pages:Object.freeze([]),settings:Object.freeze([]),menuItems:Object.freeze([]),activePanel:null});#e;viewExports;constructor(e){this.options=e,this.viewExports=new Oe(e.viewExport),this.appearance=c({locale:e.locale,mode:e.mode,narrow:e.narrow}),this.storage=new De(e.storage,e.transport);let t=()=>(this.session[0](),this.files?.api??X(`screen.file without a session`));this.#e=Z(`screen`,{get file(){return t()}})}subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getSnapshot=()=>this.snapshot;changed(e=!1){let t=this.snapshot;this.changes[1](e=>e+1),e&&t===this.snapshot&&this.publish()}setSession(e){if(this.ended)return;let t=this.session[0]();if(t?.id===e?.id&&t?.directory===e?.directory)return;if(!e)for(let e of[...this.panelMounts])e();this.files?.dispose(),this.files=e?new Ee(this.options.files,this.options.queryClient,this.options.transport,e.directory):void 0;let n=Z(`session.server`,{id:this.options.transport,name:this.options.transport,client:this.options.client}),r=e?Object.freeze(Z(`session`,{id:e.id,directory:e.directory,key:`${this.options.transport}\n${e.id}`,tab:e.id,server:n,pending:!1,visit:{},location:{directory:e.directory}})):void 0,i=this.snapshot;this.session[1](r),i===this.snapshot&&this.publish()}setAppearance(e){if(this.ended)return;let t=this.appearance[0]();(t.locale!==e.locale||t.mode!==e.mode||t.narrow!==e.narrow)&&this.appearance[1]({...e})}setPage(e){this.ended||this.currentPage[1](e)}install(t,r,o){let s=this.instances.get(t);if(this.ended||s?.status===`active`&&s.revision===r.revision&&s.native?.active!==!1){o?.dispose();return}s&&(this.instances.delete(t),this.release(s));let l={id:t,native:o,revision:r.revision,controller:new AbortController,status:`active`,cleanups:new Set,contributions:new Set,iconChanges:c(0),appearanceChanges:c(0),commands:[],titlebarItems:[],panels:[],pages:[],settings:[],menus:[]};this.instances.set(t,l);try{if(t===`yuri`||t.startsWith(`yuri.`))throw Error(`The yuri namespace is reserved to the host`);let s=Te(r.code,o?.activation.os);b(t=>{l.dispose=t,l.root=a(),y(()=>x(A.Provider,{value:l.context=this.context(l,s,r.options),get children(){l.owner=a();let e=n(()=>s.setup?.(l.context));if(typeof e==`function`)l.cleanups.add(()=>{Promise.resolve(e()).catch(e=>{l.error=String(e)})});else if(e!==void 0)throw e&&typeof e==`object`&&`then`in e&&Promise.resolve(e).catch(()=>{}),Error(`GUI setup must be synchronous and return only cleanup`);return null}}),e=>this.fail(l,e)),l.controller.signal.aborted||i(l.owner,()=>e(()=>{if(l.iconChanges[0](),!l.controller.signal.aborted)try{let e=[...l.contributions].filter(e=>e.registry===ce).map(e=>e.read()).filter(e=>e!==void 0);this.fileIcons.replace(l.id,e),l.iconError!==void 0&&n(()=>{l.iconError=void 0,this.publish()})}catch(e){n(()=>{this.fileIcons.remove(l.id),l.iconError=e instanceof Error?e.message:String(e),this.publish()})}})),l.controller.signal.aborted||i(l.owner,()=>e(()=>{if(l.appearanceChanges[0](),!l.controller.signal.aborted)try{let e=e=>[...l.contributions].filter(t=>t.registry===e).map(e=>e.read()).filter(e=>e!==void 0);this.appearanceCatalog.replace(l.id,e(fe),e(ue),l.native?.activation.capabilities?.dockIcon===!0)}catch(e){n(()=>this.fail(l,e))}})),l.controller.signal.aborted||i(l.owner,()=>e(()=>{this.changes[0](),this.session[0](),this.appearance[0]();try{this.derive(l)}catch(e){n(()=>this.fail(l,e))}n(()=>this.publish())}))})}catch(e){this.fail(l,e)}this.changed(!0)}release(e){e.controller.abort(),e.native?.dispose();for(let t of[...e.cleanups])try{t()}catch(t){e.error??=String(t)}e.cleanups.clear(),$(e.root,t=>{e.error??=String(t)});try{e.dispose?.()}catch(t){e.error??=String(t)}e.contributions.clear(),e.commands=[],e.titlebarItems=[],e.panels=[],e.pages=[],e.settings=[],e.menus=[],this.fileIcons.remove(e.id),this.appearanceCatalog.remove(e.id);for(let t of this.contracts.values())t.provider===e&&(t.provider=void 0,t.live[1]({status:`inactive`,reason:e.status===`failed`?`failed`:`disabled`}))}fail(e,t){e.status!==`failed`&&this.instances.get(e.id)===e&&(e.status=`failed`,e.error=t instanceof Error?t.message:String(t),t instanceof E&&(e.errorCode=t.code),this.release(e),this.publish())}uninstall(e){let t=this.instances.get(e);if(t){this.instances.delete(e),this.release(t);for(let t of this.layouts.values())t.open=t.open.filter(t=>!t.startsWith(`${e}:`)),t.active?.startsWith(`${e}:`)&&(t.active=null);this.changed(!0)}}dispose(){this.ended||(this.ended=!0,l(()=>{for(let e of[...this.instances.keys()])this.uninstall(e)}),this.viewExports.dispose(),this.files?.dispose(),this.fileIcons.dispose(),this.appearanceCatalog.dispose(),this.storage.dispose(),this.layouts.clear(),this.fileViews.clear(),this.contracts.clear(),this.listeners.clear())}async setDockIcon(e,t){let n=this.instances.get(e),r=n?.native;if(!r?.active||!r.activation.capabilities?.dockIcon)return X(`Dock icon`);try{await r.setDockIcon(t)}catch(e){throw t!==null&&n&&this.fail(n,e),e}}own(e,t){let n=!0,i=()=>{n&&(n=!1,e.cleanups.delete(i),t())};return e.controller.signal.aborted||r(I)?.ended?(i(),i):(e.cleanups.add(i),a()&&p(i),i)}list(e){this.changes[0]();let t=[];for(let n of this.instances.values())if(n.status===`active`){for(let r of n.contributions)if(r.registry===e.id){let e=r.read();e!==void 0&&t.push(e)}}return t}context(t,i,o){let c=this.storage.forPlugin(t.id,t.controller.signal),l=Object.fromEntries(Object.entries(i.stores??{}).map(([e,t])=>[e,t.scope===`global`?c.store(e,{...t,scope:`global`}):n=>c.store(e,{...t,scope:{session:n}})])),u=(e,t)=>{let n=this.appearance[0]().locale;return(i.i18n?.[n]?.[e]??i.i18n?.[n.split(`-`)[0]]?.[e]??i.i18n?.en?.[e]??e).replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t?.[n]??e))},d=Z(`layout`,{narrow:()=>this.appearance[0]().narrow,ready:()=>!!this.session[0](),open:(e,n,r)=>{t.controller.signal.aborted||this.openPanel(e,n,r)},close:(e,n)=>{t.controller.signal.aborted||this.closeFor(e,n)},toggle:(e,t)=>d.state(e,t)===`visible`?d.close(e,t):d.open(e,t),hide:(e,n)=>{if(t.controller.signal.aborted)return;let r=this.layout(n);r.active===e&&r.shown&&(r.shown=!1,this.changed())},state:(e,t)=>{this.changes[0]();let n=this.layout(t);return n.active===e?n.shown?`visible`:`active`:n.open.includes(e)?`open`:`closed`},stored:e=>(this.changes[0](),this.layout(e).open.filter(e=>e.startsWith(`${t.id}:`)).map(e=>e.slice(t.id.length+1))),side:{opened:e=>(this.changes[0](),this.layout(e).shown),toggle:e=>{if(t.controller.signal.aborted)return;let n=this.layout(e);n.shown=!n.shown,this.changed()},menu:()=>this.list(M).filter(e=>e.menu===`session.panel`).sort((e,t)=>(e.order??0)-(t.order??0))},scroll:{get:(e,t)=>(this.changes[0](),this.layout(e).scroll.get(t)),set:(e,n,r)=>{if(t.controller.signal.aborted)return;let i=this.layout(e).scroll;if(!i.has(n)&&i.size>=128)throw Error(`GUI layout scroll limit exceeded`);i.set(n,{...r}),this.changed()}}}),f=je(t.controller.signal),m=k(()=>t.controller.signal.aborted?{status:`inactive`,reason:`disabled`}:{status:`active`,generation:1,value:f}),h={open:e=>t.controller.signal.aborted||this.appearance[0]().narrow||!t.pages.some(t=>t.id===e)?!1:this.options.openPage?.(Y(t.id,e))??!1,current:()=>{let e=this.currentPage[0]();return t.pages.find(n=>Y(t.id,n.id)===e)?.id}},g=k(()=>t.controller.signal.aborted||!this.options.openPage||this.appearance[0]().narrow?{status:`inactive`,reason:`disabled`}:{status:`active`,generation:1,value:h});return Z(`ctx`,{id:t.id,options:o,signal:t.controller.signal,client:this.options.client,storage:c,stores:l,toast:q(t.controller.signal,this.options.toast),app:{name:`yuri`,version:t.native?.activation.app.version??``,channel:t.native?.activation.app.packaged?`prod`:`local`,platform:t.native?`desktop`:`web`,packaged:t.native?.activation.app.packaged??!1},desktop:t.native?Z(`desktop`,{os:t.native.activation.os}):void 0,t:u,plural:(e,t,n)=>{let r=`${e}.${new Intl.PluralRules(this.appearance[0]().locale).select(t)}`;return u(r,{...n,count:t})===r?u(`${e}.other`,{...n,count:t}):u(r,{...n,count:t})},add:(i,o)=>{if(t.controller.signal.aborted||r(I)?.ended)return()=>{};if([`server`,`composer-pill`,`slot`,`file.viewer`,`menubar-item`].includes(i.id)&&X(`registry.${i.id}`),t.contributions.size>=256)throw Error(`GUI contribution limit exceeded`);let c=()=>{},l,u=b(n=>{c=n,l=a();let r=()=>typeof o==`function`?o():o,u;if(i.id===`yuri.file-icon`){let e=s(()=>{try{return{ok:!0,value:r()}}catch(e){return{ok:!1,error:e}}});u=()=>{let t=e();if(!t.ok)throw t.error;return t.value}}else u=s(r);if(i.id===`style`){let n=document.createElement(`style`);n.dataset.yuriPluginStyle=t.id,document.head.append(n),p(()=>n.remove()),e(()=>{let e=u();n.textContent=e===void 0?``:String(e)})}return{registry:i.id,read:u}},a()??t.owner);t.contributions.add(u);let d=()=>{i.id===`yuri.file-icon`&&t.iconChanges[1](e=>e+1)},f=()=>{(i.id===`yuri.theme`||i.id===`yuri.branding`)&&t.appearanceChanges[1](e=>e+1)};return n(d),n(f),n(()=>this.changed()),this.own(t,()=>{$(l,e=>{t.error??=String(e)}),c(),t.contributions.delete(u),n(d),n(f),n(()=>this.changed())})},list:e=>this.list(e),provide:(e,n)=>{if(t.controller.signal.aborted||r(I)?.ended)return()=>{};if(K(e.id)||e.id===`yuri.previewActions`||e.id===`yuri.pages`)throw Error(`Preview/export/page contracts are provided only by the Yuri host`);if(e.kind!==`contract`||!(e.id===t.id||e.id.startsWith(`${t.id}.`)))throw Error(`Contract must belong to the providing plugin`);let i=this.contract(e.id);if(i.provider)throw Error(`Contract already provided: ${e.id}`);return i.provider=t,i.live[1]({status:`active`,value:n,generation:++i.generation}),this.own(t,()=>{i.provider===t&&(i.provider=void 0,i.live[1]({status:`inactive`,reason:t.status===`failed`?`failed`:`disabled`}))})},use:e=>e.id===`yuri.pages`?e.kind===`contract`?g:X(`pages token must be a Contract`):e.id===`yuri.previewActions`?e.kind===`contract`?m:X(`preview actions token must be a Contract`):K(e.id)?e.kind===`contract`?this.viewExports.use(e.id,t.controller.signal):X(`export token must be a Contract`):e.kind===`ipc`&&t.native?t.native.token(e).live:this.contract(e.id,e.kind===`ipc`).live[0],main:e=>{if(!(e.id===t.id||e.id.startsWith(`${t.id}.`)))throw new E(`GUI_PLUGIN_FORBIDDEN`,`IPC must belong to the plugin`);return t.native?t.native.token(e).value:new Proxy({state:()=>void 0},{get:(e,t)=>t===`state`?e.state:t===`on`?()=>{throw new E(`GUI_PLUGIN_UNSUPPORTED`)}:()=>Promise.reject(new E(`GUI_PLUGIN_UNSUPPORTED`))})},sessions:{current:this.session[0],list:()=>{let e=this.session[0]();return e?[e]:[]}},screen:{current:()=>this.session[0]()?this.#e:void 0},layout:d,appearance:{mode:()=>this.appearance[0]().mode,font:()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||`monospace`},locale:{locale:()=>this.appearance[0]().locale,direction:()=>/^(ar|fa|he|ur)(-|$)/i.test(this.appearance[0]().locale)?`rtl`:`ltr`},system:{copy:e=>navigator.clipboard.writeText(e),openExternal:e=>{let t=new URL(e);[`https:`,`http:`,`mailto:`].includes(t.protocol)||X(`system.openExternal protocol`),window.open(e,`_blank`,`noopener,noreferrer`)},save:Ae},commands:{run:e=>t.controller.signal.aborted||!this.command(e)?!1:(this.runCommand(e),!0)},links:{open:e=>!t.controller.signal.aborted&&this.navigateLink(t,e),exists:e=>n(()=>{if(t.controller.signal.aborted)return!1;let n=this.linkHandler(e);try{return Promise.resolve(n?.value.exists?.(e)??!1).catch(()=>!1)}catch{return!1}})}})}contract(e,t=!1){let n=this.contracts.get(e);if(!n){if(this.contracts.size>=256)throw Error(`GUI contract limit exceeded`);let t=c({status:`inactive`,reason:`disabled`});n={live:[k(t[0]),t[1]],generation:0},this.contracts.set(e,n)}return t&&n.provider&&X(`IPC contract collision`),n}derive(e){if(e.status!==`active`)return;let t=[],r=[],i=[],a=[],o=[],s=[],c=this.session[0]();for(let n of e.contributions){if([`yuri.file-icon`,`yuri.theme`,`yuri.branding`].includes(n.registry))continue;let l=n.read();if(l!==void 0){if(n.registry===`yuri.page`){let e=Me(l);if(s.some(t=>t.id===e.id))throw Error(`Duplicate yuri.page id`);s.push(e)}else if(n.registry===be.id){let n=l;n.enabled!==!1&&t.push({key:`${e.id}.${n.id}`,pluginId:e.id,title:n.title,description:n.description,bind:n.bind,hidden:n.hidden,run:()=>this.invoke(e,()=>n.run())})}else if(n.registry===O.id){let t=l;o.push({key:JSON.stringify([e.id,t.id]),pluginId:e.id,label:t.label,title:t.title,icon:t.icon,busy:t.busy,pressed:t.pressed,actionable:!!t.run,run:t.run})}else if(n.registry===Se.id&&c){let t=l,n=`${e.id}:`,i=this.layout(c).open.filter(e=>e.startsWith(n)).map(e=>e.slice(n.length));for(let n of t.list({session:c,screen:this.#e,open:i}))r.push({plugin:e,panel:t,tab:n})}else if(n.registry===D.id){let e=l;(e.page||e.section)&&X(`SettingsPage host sections`),e.title,i.push(e)}else if(n.registry===M.id){let e=l;e.menu===`session.panel`?(e.title,a.push(e)):X(`MenuItem.${e.menu}`)}}}for(let e of r)e.tab.title;e.commands=t,e.titlebarItems=o,e.panels=r,e.pages=s,e.settings=i,e.menus=a,n(()=>this.views[1](e=>e+1))}publish(){let e=n(this.session[0]),t=e?this.layouts.get(e.key):void 0,r=[...this.instances.values()],i=r.filter(e=>e.status===`active`),a=i.flatMap(e=>e.panels.map(({tab:n})=>{let r=n.file?this.filePath(n.file):void 0;return{key:`${e.id}:${n.id}`,pluginId:e.id,title:n.title,file:r,inline:!!(r&&this.fileViews.has(r)),active:t?.shown===!0&&t.active===`${e.id}:${n.id}`}}));this.snapshot=Object.freeze({plugins:Q(r.map(({id:e,revision:t,status:n,error:r,errorCode:i,iconError:a})=>({id:e,revision:t,status:n,error:r??a,...i?{errorCode:i}:{}}))),commands:Q(i.flatMap(e=>e.commands.filter(e=>!e.hidden))),panels:Q(a),titlebarItems:Q(i.flatMap(e=>e.titlebarItems.map(({run:e,...t})=>t))),pages:Q(i.flatMap(e=>e.pages.map(t=>({key:Y(e.id,t.id),pluginId:e.id,title:t.title,icon:t.icon})))),settings:Q(i.flatMap(e=>e.settings.map(t=>({key:`${e.id}:${t.id}`,pluginId:e.id,title:t.title})))),menuItems:Q(i.flatMap(e=>e.menus.map(t=>({key:`${e.id}:${t.id}`,pluginId:e.id,title:t.title,description:t.description,run:()=>{this.invoke(e,()=>t.run())}})))),activePanel:t?.shown&&a.some(e=>e.key===t.active)?t.active:null,sessionKey:e?.key});for(let e of this.listeners)e()}invoke(e,t){if(!e.controller.signal.aborted)try{let n=i(e.owner??null,t);if(n instanceof Promise)return n.catch(t=>this.fail(e,t))}catch(t){this.fail(e,t)}}command(e){return[...this.instances.values()].flatMap(e=>e.commands).find(t=>t.key===e)}runCommand(e){return this.command(e)?.run()}runTitlebarItem(e){for(let t of this.instances.values()){let n=t.titlebarItems.find(t=>t.key===e);if(n?.run&&!n.busy)return this.invoke(t,n.run)}}linkHandler(e){let t=[];for(let e of this.instances.values())for(let n of e.contributions)if(n.registry===ve.id){let r=n.read();r&&t.push({instance:e,value:r})}for(let n of t.sort((e,t)=>(t.value.priority??0)-(e.value.priority??0)))try{if(n.value.match(e))return n}catch(e){this.fail(n.instance,e)}}navigateLink(e,t){if(this.ended)return!1;let n=me(t.href);if(!n||!pe(n.path))return this.openLink(t);let r=this.session[0]();if(!r||t.session&&(t.session.key!==r.key||t.session.server.id!==r.server.id))return!1;if(!this.options.focusFile)return this.openLink(t);let i=re(t.base??r.directory,n.path),a=n.line===void 0?``:`:${n.line}${n.column===void 0?``:`:${n.column}`}`;return this.invoke(e,()=>this.options.focusFile(i+a,r.directory)),!0}openLink(e){if(this.ended)return!1;let t={...e,session:e.session??this.session[0]()},n=this.linkHandler(t);return n?(this.invoke(n.instance,()=>n.value.open(t)),!0):!1}filePath(e,t=this.session[0]()?.directory){let n=R(e);return/^(?:\/|[a-z]:\/)/i.test(n)||!t?n:R(`${t}/${n}`)}registerFileView(e,t){if(this.ended)return()=>{};let n=this.filePath(e,t),r=this.fileViews.get(n)??0;this.fileViews.set(n,r+1),r===0&&this.changed(!0);let i=!1;return()=>{if(i||this.ended)return;i=!0;let e=(this.fileViews.get(n)??1)-1;if(e){this.fileViews.set(n,e);return}{let e=this.session[0](),t=e&&this.layouts.get(e.key);t?.active&&this.snapshot.panels.some(e=>e.key===t.active&&e.file===n)&&(t.shown=!1),this.fileViews.delete(n)}this.changed(!0)}}filePanel(e,t){let n=this.filePath(e,t);return this.snapshot.panels.find(e=>e.file===n&&e.inline)}panelVisible(e){let t=this.session[0]();if(!t)return!1;let n=this.panel(e)?.tab.file;if(n&&this.fileViews.has(this.filePath(n)))return!0;let r=this.layouts.get(t.key);return!!(r?.shown&&r.active===e)}layout(e){let t=this.layouts.get(e.key);if(!t){if(this.layouts.size>=128)throw Error(`GUI session layout limit exceeded`);t={open:[],active:null,shown:!1,scroll:new Map},this.layouts.set(e.key,t)}return t}openPanel(e,t,n){if(this.ended)return;let r=this.layout(t),i=r.active,a=r.shown,o=r.open.length;if(!r.open.includes(e)){if(r.open.length>=64)throw Error(`GUI panel tab limit exceeded`);r.open=[...r.open,e]}n?.tab!==`append`&&(r.active=e,r.shown=!(this.appearance[0]().narrow&&n?.background)),(i!==r.active||a!==r.shown||o!==r.open.length)&&this.changed(!0);let s=this.panel(e);t.key===this.session[0]()?.key&&s&&n?.tab!==`append`&&this.invoke(s.plugin,()=>s.panel.focus?.({...this.props(e),restored:!1}))}selectPanel(e){let t=this.session[0]();t&&this.openPanel(e,t)}closeFor(e,t){let n=this.layout(t),r=t.key===this.session[0]()?.key?this.panel(e):void 0;if(!n.open.includes(e)||r?.tab.pinned||r?.tab.closable===!1)return;let i=this.session[0](),a=r&&i?{tab:r.tab,session:i,screen:this.#e}:void 0;n.open=n.open.filter(t=>t!==e),n.active===e&&(n.active=n.open.at(-1)??null),this.changed(!0),r&&a&&this.invoke(r.plugin,()=>r.panel.close?.(a))}closePanel(e){let t=this.session[0]();t&&this.closeFor(e,t)}hidePanel(){let e=this.session[0]();if(!e)return;let t=this.layout(e);t.shown&&(t.shown=!1,this.changed(!0))}panel(e){return[...this.instances.values()].flatMap(e=>e.panels).find(t=>`${t.plugin.id}:${t.tab.id}`===e)}props(e,t=!1){let n=this.panel(e)?.tab,r=()=>(this.views[0](),this.panel(e)?.tab??n??X(`panel no longer listed`)),i=t?s(()=>{let e=r();return{tab:e,fields:Object.getPrototypeOf(e)===Object.prototype?Object.getOwnPropertyDescriptors(e):void 0}},void 0,{equals:Ne}):void 0,a=i?()=>i().tab:r,o=()=>this.session[0]()??X(`panel without session`);return{get tab(){return a()},get session(){return o()},screen:this.#e}}mountPanel(t,r,i){let a=this.panel(t);if(!a)return()=>{};let o=new AbortController,c=()=>{let c=s(()=>{this.session[0](),this.changes[0](),this.views[0]();let e=this.panel(t)?.tab.file;return e&&this.files&&this.panelVisible(t)?{model:this.files,file:e}:void 0},void 0,{equals:(e,t)=>e?.model===t?.model&&e?.file===t?.file});e(()=>{let e=c();e&&(p(e.model.watch(e.file)),e.model.sync(e.file).catch(()=>{}))});let l=()=>n(()=>a.panel.render(this.props(t,!0)));return x(J.Provider,{value:i?{plugin:a.plugin.controller.signal,signal:o.signal,content:r,target:i}:void 0,get children(){return l()}})},l=this.mount(a.plugin,r,()=>x(N.Provider,{value:{visible:()=>(this.changes[0](),this.panelVisible(t)),present:()=>(this.changes[0](),this.panelVisible(t)),placement:()=>this.appearance[0]().narrow?`mobile`:`side`,reserve:()=>!1,animate:()=>!1,sidebar:Z(`panel.sidebar`,{}),open:()=>{let e=this.session[0]();return e?a.plugin.context.layout.stored(e):[]}},get children(){return c()}})),u=()=>{this.panelMounts.delete(u),o.abort(),l()};return this.panelMounts.add(u),this.own(a.plugin,u)}mountSettings(e,t){for(let n of this.instances.values()){let r=n.settings.find(t=>`${n.id}:${t.id}`===e);if(r)return this.mount(n,t,()=>r.render({}))}return()=>{}}mountPage(e,t){if(this.appearance[0]().narrow)return()=>{};for(let n of this.instances.values()){let r=n.pages.find(t=>Y(n.id,t.id)===e);if(r)return this.mount(n,t,()=>r.render())}return()=>{}}mount(e,t,r){if(e.controller.signal.aborted)return()=>{};let i=()=>{},o,s=t=>{queueMicrotask(()=>this.fail(e,t))};try{i=ge(()=>x(A.Provider,{value:e.context,get children(){return o=a(),y(()=>n(r),s)}}),t)}catch(t){this.fail(e,t)}return this.own(e,()=>{$(o,t=>{e.error??=String(t)}),i(),t.replaceChildren()})}};export{Pe as GuiPluginHost};