@yuriai/web 0.2.35 → 0.2.36-beta.7

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 (113) hide show
  1. package/dist/assets/{AgentAvatar-DLzcNrQ0.js → AgentAvatar-D4JLZ7IL.js} +1 -1
  2. package/dist/assets/{AssistantContactStatus-9chQCNlQ.js → AssistantContactStatus-CqANenYS.js} +3 -3
  3. package/dist/assets/{AssistantUnreadBadge-DzZgExBt.js → AssistantUnreadBadge-j-O3lnH_.js} +1 -1
  4. package/dist/assets/{AssistantView-D6y9ECO7.js → AssistantView-DXibp8Nh.js} +1 -1
  5. package/dist/assets/{DiagramView-BO0AIQl-.js → DiagramView-BRW8DdSg.js} +1 -1
  6. package/dist/assets/{FadeInOnReveal-BRrU2ivL.js → FadeInOnReveal-CY1UuS2D.js} +1 -1
  7. package/dist/assets/{GuiPluginSurface-0_eilin-.js → GuiPluginSurface-BOWSgNtP.js} +1 -1
  8. package/dist/assets/{GuiPluginWindow-BykPaQeY.js → GuiPluginWindow-DlnxZgDZ.js} +1 -1
  9. package/dist/assets/{Icon-OJf0qBKf.js → Icon-D7VxRqha.js} +1 -1
  10. package/dist/assets/{ImageLoadingPlaceholder-DlQbo9CM.js → ImageLoadingPlaceholder-ClzN4oGS.js} +1 -1
  11. package/dist/assets/{LoadingImage-sZ5omN5L.js → LoadingImage-QfRXuKTy.js} +1 -1
  12. package/dist/assets/MarkdownRenderer-DjSn61IL.js +2 -0
  13. package/dist/assets/MarkdownRendererImpl-DIvSv3Rv.js +10 -0
  14. package/dist/assets/MarkstreamRendererImpl-AJvljij3.js +3 -0
  15. package/dist/assets/{MobileDetailNavigation-D107--jY.js → MobileDetailNavigation-CaO-fGvE.js} +1 -1
  16. package/dist/assets/{MobileResizableSheet-DuAi_epR.js → MobileResizableSheet-CNn25qxG.js} +1 -1
  17. package/dist/assets/{MobileShareBridge-Duya4-qV.js → MobileShareBridge-D8oRgnuW.js} +2 -2
  18. package/dist/assets/MobileTabPageHeader-CkuLCAUz.js +2 -0
  19. package/dist/assets/{MultiRunWindow-CKFLVBjQ.js → MultiRunWindow-PFfaS1N3.js} +1 -1
  20. package/dist/assets/{OnboardingScreen-CqsI0632.js → OnboardingScreen-BmAImZZZ.js} +1 -1
  21. package/dist/assets/{OverlayScrollbar-CZD1yU06.js → OverlayScrollbar-dxKlRNuH.js} +1 -1
  22. package/dist/assets/{SettingsView-By8wQ0io.js → SettingsView-Ci7GRXnm.js} +12 -12
  23. package/dist/assets/{SettingsWindow-BkYvnI4i.js → SettingsWindow-DjqjH8zU.js} +1 -1
  24. package/dist/assets/{SetupTourDialog-ER0fy_HE.js → SetupTourDialog-yJq3b29w.js} +1 -1
  25. package/dist/assets/{TerminalView-Bxwe5vPx.js → TerminalView-DsqOYj1E.js} +3 -3
  26. package/dist/assets/{ToolOutputDialog-wLULKJRN.js → ToolOutputDialog-CxlFIAQ4.js} +1 -1
  27. package/dist/assets/{VoiceSettings-BYFnku1a.js → VoiceSettings-BEtahqoU.js} +2 -2
  28. package/dist/assets/{YuriLogo-CMUoGUHc.js → YuriLogo-DADSHd1H.js} +1 -1
  29. package/dist/assets/{YuriWordmark-DHYo0FlR.js → YuriWordmark-CGDlDvEH.js} +1 -1
  30. package/dist/assets/{appThemeRegistry-z9y3dowq.js → appThemeRegistry-Bz6WZldU.js} +1 -1
  31. package/dist/assets/bootstrap-Bi91NjXG.js +3 -0
  32. package/dist/assets/{button-C-gRcs_2.js → button-B7w-b2yV.js} +1 -1
  33. package/dist/assets/{capgoAdapter-CmkP4lqS.js → capgoAdapter-BpF4euDL.js} +1 -1
  34. package/dist/assets/{checkbox-BrJBzET8.js → checkbox-DTPgJBK_.js} +1 -1
  35. package/dist/assets/{collapsible-B7esGYLd.js → collapsible-DZ4ykYM2.js} +1 -1
  36. package/dist/assets/{context-menu-DWn1nSZC.js → context-menu-BXHMb3Q-.js} +1 -1
  37. package/dist/assets/{diagram-Bnra5_6g.js → diagram-CldUPV-Z.js} +1 -1
  38. package/dist/assets/{dialog-3UseH0hM.js → dialog-gc3n4NXh.js} +1 -1
  39. package/dist/assets/{es-J7a_sZ1u.js → es-DDcXvUON.js} +1 -1
  40. package/dist/assets/{fileMentionTouchSelection-ByaQJcTS.js → fileMentionTouchSelection-CJtFYKAV.js} +1 -1
  41. package/dist/assets/{fileReferenceActions-COS3jfbf.js → fileReferenceActions-DrAZHld4.js} +1 -1
  42. package/dist/assets/{fr-BYxUMKWp.js → fr-pUULu88g.js} +2 -2
  43. package/dist/assets/{gitApi-Dw-LR3UG.js → gitApi-CJS823P8.js} +1 -1
  44. package/dist/assets/{gitApiHttp-MWsHNHuo.js → gitApiHttp-CKrsk1tw.js} +2 -2
  45. package/dist/assets/{input-CmLlZdeD.js → input-B7yPcQsA.js} +1 -1
  46. package/dist/assets/insertionBoundaries-D9Vc7ZK5.js +1 -0
  47. package/dist/assets/{ja-DCdBiJmD.js → ja-C7MjLXCG.js} +1 -1
  48. package/dist/assets/{ko-D-Nb_RJY.js → ko-U4JK9TxK.js} +1 -1
  49. package/dist/assets/{main-Dp8KQSBT.js → main-DD5kDabV.js} +2 -2
  50. package/dist/assets/{main-CRiKyn7G.js → main-Da12pxuy.js} +14 -14
  51. package/dist/assets/{markdownHeightCache-xNkQdlqi.js → markdownHeightCache-CLiBBW4n.js} +1 -1
  52. package/dist/assets/{mcpQueries-BZSAqZuN.js → mcpQueries-JrS0Bvb3.js} +1 -1
  53. package/dist/assets/{miniChat-BCW0br3M.js → miniChat-lRi18Hvu.js} +2 -2
  54. package/dist/assets/mobile-8eKyWn8a.js +2 -0
  55. package/dist/assets/{mobileBackNavigation-Bgo8TriP.js → mobileBackNavigation-BMaLnPn4.js} +1 -1
  56. package/dist/assets/multirun-Cui2oFM-.js +3 -0
  57. package/dist/assets/{native-config-ZqHOJ6fS.js → native-config-C8AlS30O.js} +1 -1
  58. package/dist/assets/{pl-AmU4w3aM.js → pl-Cy7NC-CJ.js} +1 -1
  59. package/dist/assets/projectMeta-A8jJRQk7.js +1 -0
  60. package/dist/assets/{pt-BR-BI4ft-Fj.js → pt-BR-qCU-EBEs.js} +1 -1
  61. package/dist/assets/pwa-CbR9DKyA.js +2 -0
  62. package/dist/assets/queue-abort-optimistic-B_crtkQx.js +1 -0
  63. package/dist/assets/{readiness-BYqlQeMk.js → readiness-BpeOajK9.js} +1 -1
  64. package/dist/assets/{renderElectronMiniChatApp-BJtTYEcH.js → renderElectronMiniChatApp-DqJy20-t.js} +2 -2
  65. package/dist/assets/{renderMobileApp-DYwORO8C.js → renderMobileApp-C9OxYnMu.js} +7 -7
  66. package/dist/assets/{runtimeConfig-DL4uXM0C.js → runtimeConfig-7LsY--_g.js} +1 -1
  67. package/dist/assets/{runtimeEndpointReset-C6j5YkJj.js → runtimeEndpointReset-NZMW9r3D.js} +7 -7
  68. package/dist/assets/{scheduledTaskNavigation-Cq5yavoC.js → scheduledTaskNavigation-7dD6PWMD.js} +1 -1
  69. package/dist/assets/{select-J8r9SxHt.js → select-WCptRb7Z.js} +1 -1
  70. package/dist/assets/sessionLookup-CxjYSDU2.js +1 -0
  71. package/dist/assets/{sortable-tabs-strip-CiP6RIQa.js → sortable-tabs-strip-DFKCoZZF.js} +1 -1
  72. package/dist/assets/{speechSettingsQueries-CufXiLkn.js → speechSettingsQueries-4gKyXBgi.js} +1 -1
  73. package/dist/assets/src-B_i0g2Ca.css +2 -0
  74. package/dist/assets/{store-OjrIiXCx.js → store-CVmc1U19.js} +3 -3
  75. package/dist/assets/{terminalApi-BMWW_0wH.js → terminalApi-Bo6KWljy.js} +1 -1
  76. package/dist/assets/{textarea-BHgcxJdC.js → textarea-CMVUhwQ2.js} +1 -1
  77. package/dist/assets/{tooltip-Degmpxnd.js → tooltip-L2xweVkb.js} +1 -1
  78. package/dist/assets/types-djs5o8aQ.js +2 -0
  79. package/dist/assets/{uk-CbdByxxj.js → uk-D5ulQPhM.js} +1 -1
  80. package/dist/assets/{useAppFontEffects-J3RrHTRd.js → useAppFontEffects-mxyvl0gj.js} +58 -54
  81. package/dist/assets/{useAssistantUIStore-D25VqrpK.js → useAssistantUIStore-cHle1U5H.js} +1 -1
  82. package/dist/assets/{useDesktopWindowControlsLayout-D22mutiT.js → useDesktopWindowControlsLayout-ZHw0VsJh.js} +1 -1
  83. package/dist/assets/{useDictation-DFVJpRbm.js → useDictation-DO12CgDE.js} +1 -1
  84. package/dist/assets/{useEffectiveDirectory-D1ga92jj.js → useEffectiveDirectory-B6ny9aem.js} +1 -1
  85. package/dist/assets/{useFontPreferences-CEK8G_Ps.js → useFontPreferences-D-AOjd9H.js} +1 -1
  86. package/dist/assets/useMobileNavigationStore-DRBFwjAg.js +17 -0
  87. package/dist/assets/{usePluginsStore-GuZu61OT.js → usePluginsStore-Bav6NFUH.js} +1 -1
  88. package/dist/assets/{useStreamingTextThrottle-VhgGU_te.js → useStreamingTextThrottle-DLR8xP-j.js} +1 -1
  89. package/dist/assets/useUIStore-B61bCFEM.js +1 -0
  90. package/dist/assets/{useWorkerHighlightedLines-DNj4Aa0S.js → useWorkerHighlightedLines-DdYDj9PN.js} +1 -1
  91. package/dist/assets/{vendor-marked-WVekxjAN.js → vendor-marked-S3gCOYp1.js} +1 -1
  92. package/dist/assets/{zh-CN-ufEVDbXp.js → zh-CN-C3SRM0mS.js} +1 -1
  93. package/dist/assets/{zh-TW-DTBlZ4YC.js → zh-TW-CZD-9AC2.js} +1 -1
  94. package/dist/index.html +10 -10
  95. package/dist/mini-chat.html +10 -10
  96. package/dist/mobile.html +10 -10
  97. package/package.json +1 -1
  98. package/dist/assets/MarkdownRenderer-64YkD1Ct.js +0 -2
  99. package/dist/assets/MarkdownRendererImpl-iosoqnCI.js +0 -10
  100. package/dist/assets/MarkstreamRendererImpl-BIxWqmEF.js +0 -3
  101. package/dist/assets/MobileTabPageHeader-CqhuzKJa.js +0 -2
  102. package/dist/assets/bootstrap-C8paoQ0j.js +0 -3
  103. package/dist/assets/insertionBoundaries-9KJWoqup.js +0 -1
  104. package/dist/assets/mobile-usXz8wZd.js +0 -2
  105. package/dist/assets/multirun-CflOv3TT.js +0 -3
  106. package/dist/assets/projectMeta-KP9BgEIm.js +0 -1
  107. package/dist/assets/pwa-BbBJQBpm.js +0 -2
  108. package/dist/assets/queue-abort-optimistic-BaOXtqLx.js +0 -1
  109. package/dist/assets/sessionLookup-LrqUcxJk.js +0 -1
  110. package/dist/assets/src-DHfmlFCj.css +0 -2
  111. package/dist/assets/types-DWyP764A.js +0 -2
  112. package/dist/assets/useMobileNavigationStore-BOlo2VUm.js +0 -17
  113. package/dist/assets/useUIStore-BerIUSLP.js +0 -1
@@ -1,29 +1,29 @@
1
- import{n as e,r as t}from"./rolldown-runtime-hePW80VL.js";import{E as n}from"./runtime-auth-DBn9yahL.js";import{c as r,i,l as a,n as o,r as s,t as c}from"./runtime-switch-DEZ1K7qW.js";import{n as l}from"./runtime-fetch-D0YWp3FJ.js";import{C as u,E as d,F as f,H as p,L as m,S as h,T as g,U as _,V as v,d as y,f as b,i as x,m as S,p as C,q as w,s as T,t as E,v as D,x as O,y as k}from"./desktop-BAmoc_34.js";import{t as A}from"./runtimeAPIRegistry-C2VogTny.js";import{_ as j,a as M,d as N,f as P,g as F,h as I,i as L,n as R,r as z,s as B,t as V,v as H}from"./desktopHosts-BLU1tGSX.js";import{n as U}from"./desktopRelayRestore-2BIIs8mZ.js";import{a as W,i as ee,r as te,t as ne}from"./vendor-zustand-vDaAPGfl.js";import{at as re,ot as ie,st as ae}from"./vendor-base-ui-CzHs0bHY.js";import{At as oe,Pn as se,bt as ce}from"./gitApiHttp-MWsHNHuo.js";import"./brand-storage-bootstrap-D4BW3w-M.js";import{a as le,c as ue,f as de,r as G,s as fe,x as pe}from"./useUIStore-BerIUSLP.js";import{O as me,c as he,f as ge,k as _e,l as ve,o as ye,tt as be,z as xe}from"./bootstrap-C8paoQ0j.js";import{n as Se}from"./vendor-react-DlzBev0S.js";import{i as Ce,l as we,n as Te,o as Ee,s as De}from"./vendor-tanstack-react-query-B-Wpqq5J.js";import{a as Oe}from"./queryRuntime-2dx7jbt9.js";import{u as ke}from"./fileQueries-C2Rs6TPz.js";import{n as Ae,t as je}from"./platform-sEg2IOLZ.js";import{a as Me,i as Ne,n as Pe}from"./types-DWyP764A.js";import{t as Fe}from"./native-config-ZqHOJ6fS.js";import{Q as Ie,S as Le,U as Re,lt as ze}from"./vendor-codemirror-autocomplete-C0FrlFqZ.js";import{r as Be}from"./vendor-sonner-BEHGipm5.js";import{a as Ve,i as He,s as Ue}from"./vendor-reactuses-core-DWo5Wn6R.js";import{d as We,f as Ge,n as Ke,o as qe,p as Je,r as K,t as q}from"./button-C-gRcs_2.js";import{i as Ye}from"./store-OjrIiXCx.js";import{i as Xe,r as Ze}from"./MobileShareBridge-Duya4-qV.js";import{_ as Qe,a as $e,d as et,g as tt,h as nt,i as rt,m as it,t as at,v as ot,x as st}from"./MobileDetailNavigation-D107--jY.js";import{$i as ct,$r as lt,Ai as ut,Ca as dt,Gi as ft,Ji as pt,Ki as mt,Mi as ht,Ni as gt,Pi as _t,Qi as vt,Sa as yt,Ur as bt,Xi as xt,Xr as St,Yi as Ct,Zi as wt,_a as Tt,aa as Et,ca as Dt,cn as Ot,da as kt,ea as At,ga as jt,ha as Mt,hi as Nt,ia as J,ki as Pt,la as Ft,li as It,ma as Lt,na as Rt,nr as zt,oa as Bt,p as Vt,pa as Ht,q as Ut,ra as Wt,ri as Y,rr as Gt,s as Kt,sa as qt,ta as Jt,tr as Yt,ua as Xt,ui as Zt,va as Qt,xa as $t}from"./useMobileNavigationStore-BOlo2VUm.js";import{i as en}from"./useAssistantUIStore-D25VqrpK.js";import{c as tn,d as nn,f as rn,l as an,o as on,s as sn,t as cn,u as ln}from"./AgentAvatar-DLzcNrQ0.js";import{n as un}from"./useThemeSystem-CNzUUkFn.js";import{n as X}from"./Icon-OJf0qBKf.js";import{a as dn,i as fn,n as pn,o as mn,r as hn,t as gn}from"./dialog-3UseH0hM.js";import{B as _n,H as vn,R as yn,U as bn,W as xn,z as Sn}from"./gitApi-Dw-LR3UG.js";import{t as Cn}from"./input-CmLlZdeD.js";import{i as wn,n as Tn,t as En}from"./tooltip-Degmpxnd.js";import{$ as Dn,A as On,At as kn,B as An,Ct as jn,D as Mn,Dt as Nn,Et as Pn,Ft as Fn,Gt as In,Ht as Ln,I as Rn,Kt as zn,M as Bn,Mt as Vn,N as Hn,Nt as Un,O as Wn,Ot as Gn,P as Kn,St as qn,T as Jn,Tt as Yn,Ut as Xn,X as Zn,Xt as Qn,Y as $n,Yt as er,Z as tr,a as nr,ct as rr,et as ir,ft as ar,ht as or,i as sr,jt as cr,kt as lr,l as ur,mt as dr,nt as fr,ot as pr,pt as mr,qt as hr,r as gr,rt as _r,st as vr,w as yr,wt as br,xt as xr}from"./pwa-BbBJQBpm.js";import{t as Sr}from"./YuriLogo-CMUoGUHc.js";import{n as Cr,r as wr}from"./device-w1ioiqv3.js";import{c as Tr,l as Er,s as Dr,t as Or,u as kr}from"./scheduledTaskNavigation-Cq5yavoC.js";import{c as Ar,i as jr,l as Mr,n as Nr,s as Pr,t as Fr}from"./select-J8r9SxHt.js";import{M as Ir,k as Lr,n as Rr}from"./appThemeRegistry-z9y3dowq.js";import{n as zr}from"./MarkdownRenderer-64YkD1Ct.js";import{a as Br}from"./url-MRa-FtQa.js";import{a as Vr}from"./toolHelpers-iEHVHQ9p.js";import{a as Hr}from"./react-a6PrrNTm.js";import{n as Ur,t as Wr}from"./textarea-BHgcxJdC.js";import{a as Gr,i as Kr,n as qr}from"./projectMeta-KP9BgEIm.js";import{t as Jr}from"./sortable-tabs-strip-CiP6RIQa.js";import{a as Yr}from"./markdownHeightCache-xNkQdlqi.js";import{C as Xr,D as Zr,F as Qr,H as $r,I as ei,J as ti,K as ni,L as ri,M as ii,N as ai,P as oi,R as si,S as ci,T as li,V as ui,X as di,Y as fi,Z as pi,_ as mi,b as hi,c as gi,f as _i,h as vi,i as yi,j as bi,l as xi,m as Si,o as Ci,p as wi,q as Ti,s as Ei,t as Di,u as Oi,v as ki,w as Ai,x as ji,y as Mi,z as Ni}from"./MobileTabPageHeader-CqhuzKJa.js";import{a as Pi,c as Fi,i as Ii,l as Li,o as Ri,r as zi,s as Bi}from"./mcpQueries-BZSAqZuN.js";import{a as Vi,c as Hi,d as Ui,f as Z,g as Wi,h as Gi,i as Ki,l as qi,m as Ji,o as Yi,p as Xi,r as Zi,s as Qi,t as $i,u as ea}from"./usePluginsStore-GuZu61OT.js";import{n as ta}from"./mobileBackNavigation-Bgo8TriP.js";import{a as na,n as ra,r as ia,t as aa}from"./context-menu-DWn1nSZC.js";import{n as oa,r as sa,t as ca}from"./collapsible-B7esGYLd.js";import{t as la}from"./vendor-qrcode-D7jBCyl-.js";import{a as ua,c as da,i as fa,l as pa,o as ma,s as ha,t as ga}from"./VoiceSettings-BYFnku1a.js";import{n as _a,t as va}from"./readiness-BYqlQeMk.js";import{t as ya}from"./GuiPluginWindow-BykPaQeY.js";import{n as ba,t as xa}from"./vendor-yaml-C9KlJAlj.js";var Sa=Se(),Ca=t(re(),1),Q=t(ae(),1),$=ie(),wa=`https://github.com/yee94/yuri`,Ta=`${wa}/issues/new`,Ea=800,Da={"manual-global":`settings.yuri.about.opencodeManagement.manual-global`,"manual-external":`settings.yuri.about.opencodeManagement.manual-external`,bundled:`settings.yuri.about.opencodeManagement.bundled`,"in-app":`settings.yuri.about.opencodeManagement.in-app`,none:`settings.yuri.about.opencodeManagement.none`},Oa=e=>typeof e==`string`&&e.trim()?e.trim():null,ka=(e,t,n)=>({queryKey:[t,`about`,n,e],queryFn:async({signal:r})=>{if(t!==i()||n!==o())throw Error(`Stale About runtime`);let a=await l(e,{method:`GET`,headers:{Accept:`application/json`},signal:r});if(!a.ok)throw Error(`About snapshot: ${a.status}`);let s=await a.json();if(!s||typeof s!=`object`||Array.isArray(s))throw Error(`Invalid About snapshot`);if(r.aborted||t!==i()||n!==o())throw Error(`Stale About runtime`);return s},retry:!1,staleTime:3e4}),Aa=({initialUpdateDialogOpen:e=!1})=>{let{t}=Ge(),[n,a]=Q.useState(e),[s,c]=Q.useState(!1),[l,d]=Q.useState(!1),[f,p]=Q.useState(null),[m,h]=Q.useState(null),g=Q.useSyncExternalStore(r,i,i),_=Q.useSyncExternalStore(r,o,o),v=De(ka(`/api/system/info`,g,_)),y=De(ka(`/api/opencode/upgrade-status`,g,_)),b=Oa(v.data?.yuriVersion),x=y.data,S=Oa(x?.serveVersion)??Oa(x?.currentVersion),C=Oa(x?.management),w=C&&Object.hasOwn(Da,C)?Da[C]:null,E=x?.canManage===!1&&w?t(w):null,D=S&&E?t(`settings.yuri.about.opencodeVersionWithManagement`,{version:S,management:E}):S,k=x?.canManage===!1?C===`manual-global`?t(`settings.yuri.about.opencodeGuidance.manualGlobal`):C===`manual-external`?t(`settings.yuri.about.opencodeGuidance.manualExternal`):C===`bundled`?t(`settings.yuri.about.opencodeGuidance.bundled`):null:null,A=ni(ne(e=>({info:e.info,checking:e.checking,available:e.available,error:e.error,downloading:e.downloading,downloaded:e.downloaded,progress:e.progress,runtimeType:e.runtimeType,checkForUpdates:e.checkForUpdates,downloadUpdate:e.downloadUpdate,restartToUpdate:e.restartToUpdate}))),j=G(e=>e.otaChannelOverride),M=G(e=>e.setOtaChannelOverride),N=Ae(),[P,F]=Q.useState(`stable`);Q.useEffect(()=>{u()&&T().then(e=>F(e?.includes(`-`)?`beta`:`stable`))},[]);let I=De({queryKey:[`native-update-config`],queryFn:Fe,enabled:N,staleTime:1/0,retry:!1}),L=I.data?.channel,R=j===`beta`||j===null&&(u()?P:L)===`beta`,[z,B]=Q.useState(!1),[V,H]=Q.useState(()=>Zt()),U=He(e=>{Nt(e),H(e)}),W=He(async e=>{if(e){M(`beta`),await ni.getState().checkForUpdates();return}M(`stable`),await ni.getState().checkForUpdates();let{info:t,otaDecision:n}=ni.getState();t?.isChannelRollback===!0&&n?.primaryAction===`apply_ota`&&c(!0)}),ee=He(()=>{c(!1),M(`beta`),ni.getState().checkForUpdates()}),te=He(()=>{c(!1),a(!0),ni.getState().downloadUpdate()}),re=He(e=>{e||ee()}),ie=f||t(`settings.yuri.about.state.unknown`),ae=He(async()=>{if(!z){B(!0);try{let{outcome:e,eventCount:n}=await It();if(e===`cancelled`)return;if(e===`failed`){Y.error(t(`settings.yuri.about.diagnostics.toast.failed`));return}Y.success(t(n>0?`settings.yuri.about.diagnostics.toast.exported`:`settings.yuri.about.diagnostics.toast.empty`))}catch{Y.error(t(`settings.yuri.about.diagnostics.toast.failed`))}finally{B(!1)}}});Q.useEffect(()=>{let e=!1;return Me().then(t=>{e||p(t)}),Ne().then(t=>{e||h(t)}),()=>{e=!0}},[]);let oe=Pe(f,m)??ie,se=Q.useRef(!1);Q.useEffect(()=>{if(A.checking)d(!0),se.current=!0;else if(l){let e=setTimeout(()=>{d(!1),se.current&&A.error?(Y.error(t(`settings.yuri.about.toast.checkFailed`),{description:A.error}),se.current=!1):se.current&&!A.available&&!A.error&&(Y.success(t(`settings.yuri.about.toast.latestVersion`)),se.current=!1)},Ea);return()=>clearTimeout(e)}},[t,A.checking,l,A.available,A.error]);let ce=A.checking||l;return(0,$.jsxs)(`div`,{className:`yuri-settings-section-stack w-full`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,$.jsx)(Sr,{width:72,height:72}),(0,$.jsx)(`h2`,{className:`mt-4 typography-ui-header font-semibold text-foreground`,children:`Yuri`})]}),(0,$.jsxs)(Z,{className:`yuri-settings-about`,children:[(0,$.jsx)(Xi,{label:t(`settings.yuri.about.field.clientVersion`),children:(0,$.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:oe})}),(0,$.jsx)(Xi,{label:t(`settings.yuri.about.field.instanceYuriVersion`),children:O()?(0,$.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:b||t(`settings.yuri.about.state.unknown`)}):(0,$.jsx)(ui,{transport:g,generation:_,itemId:`about.host-update`,channel:R?`beta`:`stable`,version:b||t(`settings.yuri.about.state.unknown`)},`${g}:${_}`)}),(0,$.jsx)(Xi,{label:t(`settings.yuri.about.field.instanceOpenCodeVersion`),description:k,children:(0,$.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:D||t(`settings.yuri.about.state.unknown`)})}),(0,$.jsx)(Xi,{className:`yuri-settings-split-row-stacked`,copyClassName:`hidden`,children:(0,$.jsxs)(`div`,{className:`flex w-full flex-wrap items-center justify-end gap-2`,children:[(0,$.jsx)(q,{asChild:!0,variant:`outline`,size:`sm`,className:`whitespace-nowrap`,"data-settings-item":`about.feedback`,children:(0,$.jsxs)(`a`,{href:Ta,target:`_blank`,rel:`noopener noreferrer`,children:[(0,$.jsx)(X,{name:`question`,className:`size-4`}),t(`settings.yuri.about.actions.submitFeedback`)]})}),!ce&&A.available?(0,$.jsxs)(q,{type:`button`,variant:`default`,size:`sm`,className:`whitespace-nowrap`,onClick:()=>a(!0),"data-settings-item":`about.check-updates`,children:[(0,$.jsx)(X,{name:`download`,className:`size-4`}),A.info?.inAppApply?t(`settings.yuri.about.actions.applyOtaToVersion`,{version:A.info?.version||``}):A.info?.manualUpdate?t(`settings.yuri.about.actions.installNativeToVersion`,{version:A.info?.version||``}):t(`settings.yuri.about.actions.updateToVersion`,{version:A.info?.version||``})]}):(0,$.jsxs)(q,{type:`button`,variant:`outline`,size:`sm`,className:`whitespace-nowrap`,onClick:()=>A.checkForUpdates(),"data-settings-item":`about.check-updates`,disabled:ce,children:[ce?(0,$.jsx)(X,{name:`loader`,className:`size-4 animate-spin`}):(0,$.jsx)(X,{name:`refresh`,className:`size-4`}),t(ce?`settings.yuri.about.state.checking`:`settings.yuri.about.actions.checkForUpdates`)]})]})}),A.error&&(0,$.jsx)(Xi,{children:(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:A.error})}),(N||u())&&(0,$.jsx)(Ji,{itemId:`about.beta-updates`,checked:R,onChange:W,label:t(`settings.yuri.about.betaUpdates.label`),description:t(`settings.yuri.about.betaUpdates.description`),ariaLabel:t(`settings.yuri.about.betaUpdates.label`),disabled:ce||N&&!I.data}),(0,$.jsx)(Ji,{itemId:`about.diagnostics`,checked:V,onChange:U,label:t(`settings.yuri.about.diagnostics.label`),ariaLabel:t(`settings.yuri.about.diagnostics.label`)}),V&&(0,$.jsx)(Xi,{itemId:`about.export-diagnostics`,label:t(`settings.yuri.about.diagnostics.export`),children:(0,$.jsx)(q,{type:`button`,variant:`outline`,size:`sm`,disabled:z,onClick:()=>void ae(),children:t(z?`settings.yuri.about.diagnostics.exporting`:`settings.yuri.about.diagnostics.export`)})})]}),(0,$.jsx)(`div`,{className:`flex flex-col items-center gap-3 text-center`,children:(0,$.jsx)(`div`,{className:`flex items-center justify-center gap-5`,children:(0,$.jsxs)(`a`,{href:wa,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground`,children:[(0,$.jsx)(X,{name:`github-fill`,className:`size-5`}),(0,$.jsx)(`span`,{children:`GitHub`})]})})}),(0,$.jsx)(`p`,{className:`text-center typography-ui text-muted-foreground/60`,children:t(`aboutDialog.footerNote`)}),(0,$.jsx)($r,{open:n,onOpenChange:a,info:A.info,downloading:A.downloading,downloaded:A.downloaded,progress:A.progress,error:A.error,onDownload:A.downloadUpdate,onRestart:A.restartToUpdate,runtimeType:A.runtimeType}),(0,$.jsx)(gn,{open:s,onOpenChange:re,children:(0,$.jsxs)(pn,{showCloseButton:!1,className:`max-w-sm gap-5`,children:[(0,$.jsxs)(dn,{children:[(0,$.jsx)(mn,{children:t(`settings.yuri.about.betaUpdates.rollback.title`)}),(0,$.jsx)(hn,{children:t(`settings.yuri.about.betaUpdates.rollback.description`,{version:A.info?.version||``})})]}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(q,{type:`button`,size:`sm`,variant:`ghost`,onClick:ee,children:t(`settings.yuri.about.betaUpdates.rollback.actions.cancel`)}),(0,$.jsx)(q,{type:`button`,size:`sm`,onClick:te,children:t(`settings.yuri.about.betaUpdates.rollback.actions.confirm`)})]})]})})]})},ja=16384,Ma=globalThis,Na=e=>{if(Ma.Buffer)return Ma.Buffer.from(e,`utf8`).toString(`base64url`);let t=new TextEncoder().encode(e),n=``;for(let e=0;e<t.length;e+=32768)n+=String.fromCharCode(...t.slice(e,e+32768));return btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/g,``)},Pa=e=>{try{if(Ma.Buffer)return Ma.Buffer.from(e,`base64url`).toString(`utf8`);let t=e.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(Math.ceil(e.length/4)*4,`=`),n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e+=1)r[e]=n.charCodeAt(e);return new TextDecoder().decode(r)}catch{return null}},Fa=e=>{if(typeof e!=`string`)return null;let t=e.trim();if(!t)return null;try{let e=new URL(t);return e.protocol!==`http:`&&e.protocol!==`https:`?null:(e.hash=``,e.toString().replace(/\/+$/g,``))}catch{return null}},Ia=e=>{if(typeof e!=`string`)return null;let t=e.trim();if(!t)return null;try{let e=new URL(t);return e.protocol!==`ws:`&&e.protocol!==`wss:`||e.username||e.password?null:(e.username=``,e.password=``,e.hash=``,e.search=``,e.toString())}catch{return null}},La=e=>typeof e==`string`&&e.length>0,Ra=e=>{if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e;return t.kty!==`EC`||t.crv!==`P-256`||!La(t.x)||!La(t.y)?null:{kty:`EC`,crv:`P-256`,x:t.x,y:t.y}},za=e=>typeof e==`number`&&Number.isFinite(e)?e:void 0,Ba=e=>{if(!e||typeof e!=`object`)return null;let t=e,n=za(t.priority);if(t.type===`lan`||t.type===`tunnel`){let e=Fa(t.url);return e?n===void 0?{type:t.type,url:e}:{type:t.type,url:e,priority:n}:null}if(t.type===`relay`){let e=Ia(t.relayUrl);if(!e)return null;let r=typeof t.serverId==`string`?t.serverId.trim():``;if(!r)return null;let i=Ra(t.hostEncPubJwk);if(!i)return null;let a=typeof t.grant==`string`&&t.grant.trim()?t.grant.trim():void 0;return{type:`relay`,relayUrl:e,serverId:r,hostEncPubJwk:i,...a?{grant:a}:{},...n===void 0?{}:{priority:n}}}return null},Va=e=>{if(!e||typeof e!=`object`)return null;let t=e;if(t.v!==2)return null;let n=typeof t.pairingId==`string`?t.pairingId.trim():``,r=typeof t.secret==`string`?t.secret.trim():``;if(!n||!r)return null;let i=Array.isArray(t.candidates)?t.candidates.map(Ba).filter(e=>!!e):[];if(i.length===0)return null;let a=typeof t.expiresAt==`string`&&t.expiresAt.trim()?t.expiresAt.trim():void 0;if(a){let e=Date.parse(a);if(!Number.isFinite(e)||e<=Date.now())return null}let o=typeof t.label==`string`&&t.label.trim()?t.label.trim():void 0,s=typeof t.fingerprint==`string`&&t.fingerprint.trim()?t.fingerprint.trim():void 0;return{v:2,pairingId:n,secret:r,...o?{label:o}:{},...s?{fingerprint:s}:{},...a?{expiresAt:a}:{},candidates:i}},Ha=e=>({v:2,pairingId:e.pairingId.trim(),secret:e.secret.trim(),...e.label?.trim()?{label:e.label.trim()}:{},...e.fingerprint?.trim()?{fingerprint:e.fingerprint.trim()}:{},...e.expiresAt?.trim()?{expiresAt:e.expiresAt.trim()}:{},candidates:e.candidates}),Ua=e=>{let t=Va(e);if(!t)throw Error(`Invalid pairing connection payload`);let n=new URLSearchParams;return n.set(`v`,`2`),n.set(`p`,Na(JSON.stringify(t))),`yuri://connect?${n.toString()}`},Wa=e=>{let t=e.trim();if(!t||t.length>ja)return null;let n=t.indexOf(`?`);if(n===-1||!/^(?:yuri|openchamber|openchambery):\/\/connect\/?$/i.test(t.slice(0,n)))return null;let r=null,i=null;for(let e of t.slice(n+1).split(`&`)){let t=e.indexOf(`=`);if(t===-1)continue;let n=e.slice(0,t),a=e.slice(t+1);n===`v`?r=a:n===`p`&&(i=a)}if(r!==`2`||!i||i.length>ja)return null;let a=Pa(i);if(!a||a.length>ja)return null;try{return Va(JSON.parse(a))}catch{return null}},Ga=e=>{let t=e.trim();if(!t||t.length>ja)return null;try{let e=new URL(t);if([`yuri:`,`openchamber:`,`openchambery:`].includes(e.protocol)&&e.hostname===`connect`){if(e.searchParams.get(`v`)!==`2`)return null;let t=e.searchParams.get(`p`)||``;if(!t||t.length>ja)return null;let n=Pa(t);return!n||n.length>ja?null:Va(JSON.parse(n))}}catch{}return Wa(t)},Ka=`useCommandsStore`,qa=new Set([`init`,`review`]),Ja=e=>qa.has(e.name),Ya=async(e,t)=>{await Mt(Oe,e,t),i()===t&&$t(`commands`,{source:Ka})},Xa=W()(te(ee(e=>({selectedCommandName:null,commandDraft:null,setSelectedCommand:t=>e({selectedCommandName:t}),setCommandDraft:t=>e({commandDraft:t}),loadCommands:async()=>{let e=jt(),t=i();try{return await Mt(Oe,e,t),!0}catch{return!1}},createCommand:async t=>Za(`POST`,t.name,t,e),updateCommand:async(t,n)=>Za(`PATCH`,t,n,e),deleteCommand:async t=>Za(`DELETE`,t,void 0,e),getCommandByName:e=>Lt().find(t=>t.name===e)}),{name:`commands-store`,storage:pe(),partialize:e=>({selectedCommandName:e.selectedCommandName})}),{name:`commands-store`}));async function Za(e,t,n,r){let a=jt(),o=i();try{let s={};if(e===`POST`&&(s.template=n?.template||``,n?.description&&(s.description=n.description),n?.agent&&(s.agent=n.agent),n?.model&&(s.model=n.model),n?.scope&&(s.scope=n.scope)),e===`PATCH`)for(let e of[`description`,`agent`,`model`,`template`])n?.[e]!==void 0&&(s[e]=n[e]);let c=a?`?directory=${encodeURIComponent(a)}`:``,u=await l(`/api/config/commands/${encodeURIComponent(t)}${c}`,{method:e,headers:e===`DELETE`?a?{"x-opencode-directory":a}:void 0:{"Content-Type":`application/json`,...a?{"x-opencode-directory":a}:{}},...e===`DELETE`?{}:{body:JSON.stringify(s)}}),d=await u.json().catch(()=>null);if(!u.ok)throw Error(d?.error||`Failed to ${e.toLowerCase()} command`);return i()!==o||(await Ya(a,o),i()!==o)||e===`DELETE`&&r({selectedCommandName:null}),!0}catch(e){return console.error(`[CommandsStore] Command mutation failed:`,e),!1}}typeof window<`u`&&(window.__zustand_commands_store__=Xa),dt(e=>{e.source!==Ka&&yt(e,`commands`)&&Xa.getState().loadCommands()});var Qa=()=>{try{let e=Qt.getState().getActiveProject?.();if(e?.path?.trim())return e.path.trim();let t=oe.getDirectory();if(t?.trim())return t.trim()}catch(e){console.warn(`[McpConfigStore] Error resolving config directory:`,e)}return null},$a=e=>e?Object.entries(e).map(([e,t])=>({key:e,value:t})):[],eo=e=>{let t=e.filter(e=>e.key.trim());if(t.length!==0)return Object.fromEntries(t.map(e=>[e.key.trim(),e.value]))},to=e=>{if(typeof e==`string`)return e.trim()||void 0},no=W()(te(ee((e,t)=>({selectedMcpName:null,mcpDraft:null,setSelectedMcp:t=>e({selectedMcpName:t}),setMcpDraft:t=>e({mcpDraft:t}),loadMcpConfigs:async e=>{let t=Qa();try{return!e?.force&&zi(Oe,t).length>0||await Pi(Oe,t,i()),!0}catch(e){return console.error(`[McpConfigStore] Failed to load MCP configs:`,e),!1}},createMcp:async(e,t)=>{let n=`directory`in(t??{})?t?.directory?.trim()||null:Qa(),r=t?.transportIdentity??i();try{let t=ro(e),a=n?`?directory=${encodeURIComponent(n)}`:``,o=await l(`/api/config/mcp/${encodeURIComponent(e.name)}${a}`,{method:`POST`,headers:{"Content-Type":`application/json`,...n?{"x-opencode-directory":n}:{}},body:JSON.stringify(t)}),s=await o.json().catch(()=>null);if(!o.ok)throw Error(s?.error||`Failed to create MCP server`);return i()===r?(await Pi(Oe,n,r),await Ri(Oe,n,r),{ok:!0,reloadFailed:s?.reloadFailed===!0,message:s?.message,warning:s?.warning}):{ok:!0}}catch(e){return console.error(`[McpConfigStore] Failed to create MCP:`,e),{ok:!1}}},updateMcp:async(e,t,n)=>{let r=`directory`in(n??{})?n?.directory?.trim()||null:Qa(),a=n?.transportIdentity??i();try{let n=ro(t),o=r?`?directory=${encodeURIComponent(r)}`:``,s=await l(`/api/config/mcp/${encodeURIComponent(e)}${o}`,{method:`PATCH`,headers:{"Content-Type":`application/json`,...r?{"x-opencode-directory":r}:{}},body:JSON.stringify(n)}),c=await s.json().catch(()=>null);if(!s.ok)throw Error(c?.error||`Failed to update MCP server`);return i()===a?(await Pi(Oe,r,a),await Ri(Oe,r,a),{ok:!0,reloadFailed:c?.reloadFailed===!0,message:c?.message,warning:c?.warning}):{ok:!0}}catch(e){throw console.error(`[McpConfigStore] Failed to update MCP:`,e),e}},deleteMcp:async(n,r)=>{let a=`directory`in(r??{})?r?.directory?.trim()||null:Qa(),o=r?.transportIdentity??i();try{let r=a?`?directory=${encodeURIComponent(a)}`:``,s=await l(`/api/config/mcp/${encodeURIComponent(n)}${r}`,{method:`DELETE`,headers:a?{"x-opencode-directory":a}:void 0}),c=await s.json().catch(()=>null);if(!s.ok)throw Error(c?.error||`Failed to delete MCP server`);return Ti.getState().clearDiagnostic(n,a,o),i()===o?(t().selectedMcpName===n&&e({selectedMcpName:null}),await Pi(Oe,a,o),await Ri(Oe,a,o),{ok:!0,reloadFailed:c?.reloadFailed===!0,message:c?.message,warning:c?.warning}):{ok:!0}}catch(e){return console.error(`[McpConfigStore] Failed to delete MCP:`,e),{ok:!1}}}}),{name:`mcp-config-store`,storage:pe(),partialize:e=>({selectedMcpName:e.selectedMcpName})}),{name:`mcp-config-store`}));function ro(e){let t={};if(e.scope!==void 0&&(t.scope=e.scope),e.type!==void 0&&(t.type=e.type),(e.type===`local`||e.command!==void 0)&&(t.command=(e.command??[]).filter(e=>e.trim())),(e.type===`remote`||e.url!==void 0)&&(t.url=e.url?.trim()??``),e.environment!==void 0&&(t.environment=eo(e.environment)??{}),e.headers!==void 0&&(t.headers=eo(e.headers)??{}),e.oauthEnabled!==void 0||e.oauthClientId!==void 0||e.oauthClientSecret!==void 0||e.oauthScope!==void 0||e.oauthRedirectUri!==void 0)if(e.oauthEnabled===!1)t.oauth=!1;else{let n={clientId:to(e.oauthClientId),clientSecret:to(e.oauthClientSecret),scope:to(e.oauthScope),redirectUri:to(e.oauthRedirectUri)};t.oauth=n.clientId||n.clientSecret||n.scope||n.redirectUri?n:e.oauthEnabled?{}:!1}if(e.timeout!==void 0){let n=Number(e.timeout);t.timeout=Number.isFinite(n)&&n>0?n:null}return e.enabled!==void 0&&(t.enabled=e.enabled),t}var io=()=>{let e=oe.getDirectory();if(typeof e==`string`&&e.trim().length>0)return e;try{let e=window.__zustand_directory_store__;if(e)return e.getState().currentDirectory}catch{}return null},ao=`useSkillsStore`,oo=e=>{if(e&&Object.prototype.hasOwnProperty.call(e,`directory`))return typeof e.directory==`string`&&e.directory.trim()||null;let t=io();return typeof t==`string`&&t.trim()||null},so=W()(te(ee((e,t)=>({selectedSkillName:null,skillDraft:null,setSelectedSkill:t=>{e({selectedSkillName:t})},setSkillDraft:t=>{e({skillDraft:t})},loadSkills:async()=>{try{return await vt(Oe,io(),i()),!0}catch{return!1}},getSkillDetail:async e=>{try{let t=io(),n=t?`?directory=${encodeURIComponent(t)}`:``,r=await l(`/api/config/skills/${encodeURIComponent(e)}${n}`);return r.ok?await r.json():null}catch{return null}},createSkill:async(e,t)=>{try{let n={name:e.name,description:e.description};e.instructions&&(n.instructions=e.instructions),e.scope&&(n.scope=e.scope),e.source&&(n.source=e.source),e.supportingFiles&&(n.supportingFiles=e.supportingFiles);let r=oo(t),a=i(),o=r?`?directory=${encodeURIComponent(r)}`:``,s=await l(`/api/config/skills/${encodeURIComponent(e.name)}${o}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)}),c=await s.json().catch(()=>null);if(!s.ok){let e=c?.error||`Failed to create skill`;throw Error(e)}return await co({directory:r,transportIdentity:a}),!0}catch{return!1}},updateSkill:async(e,t,n)=>{try{let r={};t.description!==void 0&&(r.description=t.description),t.instructions!==void 0&&(r.instructions=t.instructions),t.supportingFiles!==void 0&&(r.supportingFiles=t.supportingFiles),t.targetPath!==void 0&&(r.targetPath=t.targetPath);let a=oo(n),o=i(),s=a?`?directory=${encodeURIComponent(a)}`:``,c=await l(`/api/config/skills/${encodeURIComponent(e)}${s}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r)}),u=await c.json().catch(()=>null);if(!c.ok){let e=u?.error||`Failed to update skill`;throw Error(e)}return await co({directory:a,transportIdentity:o}),!0}catch{return!1}},deleteSkill:async(n,r)=>{try{let a=oo(r),o=i(),s=a?`?directory=${encodeURIComponent(a)}`:``,c=await l(`/api/config/skills/${encodeURIComponent(n)}${s}`,{method:`DELETE`}),u=await c.json().catch(()=>null);if(!c.ok){let e=u?.error||`Failed to delete skill`;throw Error(e)}return await co({directory:a,transportIdentity:o}),i()===o&&t().selectedSkillName===n&&e({selectedSkillName:null}),!0}catch{return!1}},getSkillByName:e=>wt(Oe,io()).find(t=>t.name===e),readSupportingFile:async(e,t)=>{try{let n=io(),r=n?`&directory=${encodeURIComponent(n)}`:``,i=await l(`/api/config/skills/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}?${r.slice(1)}`);return i.ok?(await i.json()).content??null:null}catch{return null}},writeSupportingFile:async(e,t,n)=>{try{let r=io(),i=r?`?directory=${encodeURIComponent(r)}`:``;return(await l(`/api/config/skills/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}${i}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({content:n})})).ok}catch{return!1}},deleteSupportingFile:async(e,t)=>{try{let n=io(),r=n?`?directory=${encodeURIComponent(n)}`:``;return(await l(`/api/config/skills/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}${r}`,{method:`DELETE`})).ok}catch{return!1}}}),{name:`skills-store`,storage:pe(),partialize:e=>({selectedSkillName:e.selectedSkillName})}),{name:`skills-store`}));typeof window<`u`&&(window.__zustand_skills_store__=so);async function co(e){let t=e&&`directory`in e?e.directory?.trim()||null:io(),n=e?.transportIdentity??i();i()===n&&(await vt(Oe,t,n),i()===n&&(await Wt(Oe,t,n),i()===n&&$t(`skills`,{source:ao})))}var lo=null;lo||=dt(e=>{if(e.source!==ao&&yt(e,`skills`)){let e=io(),t=i();vt(Oe,e,t).then(()=>Wt(Oe,e,t)).catch(()=>void 0)}});var uo=/^#[0-9a-fA-F]{6}$/,fo=/^\{file:.+\}$/i,po=e=>[...e].sort((e,t)=>{let n=e.permission.localeCompare(t.permission);return n===0?e.pattern.localeCompare(t.pattern):n}),mo=(e,t)=>{let n=po(e),r=po(t);return n.length===r.length&&n.every((e,t)=>{let n=r[t];return e.permission===n.permission&&e.pattern===n.pattern&&e.action===n.action})},ho=(e,t)=>t?e.globalPermission!==t.globalPermission||!mo(e.permissionRules,t.permissionRules):!1,go=e=>e===`bash`?`shell`:e===`task`?`subagent`:e===`write`||e===`patch`?`edit`:e,_o=(e,t)=>{let n=[{action:`*`,resource:`*`,effect:e}];for(let e of t)!e.permission||!e.pattern||(e.permission!==`*`||e.pattern!==`*`)&&n.push({action:go(e.permission),resource:e.pattern,effect:e.action});return n},vo=e=>{let t=e.trim();return t===``?null:t},yo=({isNewAgent:e,agentName:t,draftScope:n,initialScope:r,draftHasExplicitPermission:i,current:a,initial:o,confirmDrop:s})=>{let c=_o(a.globalPermission,a.permissionRules);if(e){let e=a.description.trim(),r=vo(a.model),l=a.system.trim(),u=ho(a,o)||i;return{name:t,mode:a.mode,...e?{description:e}:{},...r?{model:r}:{},...l?{system:l}:{},...u?{permissions:c}:{},...n?{scope:n}:{},...s?{confirmDrop:!0}:{}}}let l={name:t,...s?{confirmDrop:!0}:{}};return o?(a.description!==o.description&&(l.description=a.description.trim()||null),a.mode!==o.mode&&(l.mode=a.mode),a.model!==o.model&&(l.model=vo(a.model)),a.system!==o.system&&(l.system=a.system.trim()||null),ho(a,o)&&(l.permissions=c),n&&r&&n!==r&&(l.scope=n),l):l},bo=e=>{if(e){if(typeof e.prompt==`string`)return fo.test(e.prompt.trim())?void 0:e.prompt;if(typeof e.system==`string`)return e.system}},xo=e=>{let t=e?.model?.providerID,n=e?.model?.modelID||e?.model?.id;if(!t||!n)return``;let r=e?.model?.variant||e?.variant;return r?`${t}/${n}#${r}`:`${t}/${n}`},So=e=>{let t=e.trim(),n=t.indexOf(`/`);if(n<=0||n>=t.length-1)return null;let r=t.slice(0,n),i=t.slice(n+1),a=i.indexOf(`#`);return a===-1?{providerId:r,modelId:i,variant:``}:{providerId:r,modelId:i.slice(0,a),variant:i.slice(a+1)}},Co=e=>uo.test(e.trim()),wo=e=>{let t=e.trim();return t&&t.charAt(0).toUpperCase()+t.slice(1)},To=e=>{let t=(0,Sa.c)(37),{className:n}=e,{t:r}=Ge(),i=Qt(Eo),a=Qt(Do),o=Qt(Oo),s=g(),c;t[0]===i?c=t[1]:(c=[...i].sort(ko),t[0]=i,t[1]=c);let l=c,u;bb0:{if(l.length===0){u=null;break bb0}let e;t[2]!==a||t[3]!==l?(e=l.find(e=>e.id===a)??l[0],t[2]=a,t[3]=l,t[4]=e):e=t[4],u=e}let d=u;if(s||l.length===0)return null;let f;t[5]!==d?.path||t[6]!==r?(f=d?.path.split(`/`).filter(Boolean).pop()||d?.path||r(`settings.shared.projectSelector.fallbackProject`),t[5]=d?.path,t[6]=r,t[7]=f):f=t[7];let p=f,m;t[8]===n?m=t[9]:(m=K(n),t[8]=n,t[9]=m);let h;t[10]===r?h=t[11]:(h=r(`settings.shared.projectSelector.switchProjectAria`),t[10]=r,t[11]=h);let _;t[12]===r?_=t[13]:(_=r(`settings.shared.projectSelector.switchProjectTitle`),t[12]=r,t[13]=_);let v,y;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(v=K(`yuri-settings-sidebar-picker text-foreground appearance-none flex h-8 w-full min-w-0 rounded-lg px-3 py-1`,`flex items-center gap-1.5 text-left`),y=(0,$.jsx)(X,{name:`folder`,className:`h-4 w-4 text-muted-foreground`}),t[14]=v,t[15]=y):(v=t[14],y=t[15]);let b;t[16]===p?b=t[17]:(b=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-ui-label font-medium`,children:p}),t[16]=p,t[17]=b);let x;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(X,{name:`arrow-down-s`,className:`size-4 opacity-50`}),t[18]=x):x=t[18];let S;t[19]!==h||t[20]!==_||t[21]!==b?(S=(0,$.jsx)(fr,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,"aria-label":h,title:_,className:v,children:[y,b,x]})}),t[19]=h,t[20]=_,t[21]=b,t[22]=S):S=t[22];let C=d?.id??``,w;t[23]===o?w=t[24]:(w=e=>{e&&o(e)},t[23]=o,t[24]=w);let T;t[25]===l?T=t[26]:(T=l.map(Ao),t[25]=l,t[26]=T);let E;t[27]!==C||t[28]!==w||t[29]!==T?(E=(0,$.jsx)(Zn,{align:`start`,className:`w-auto`,children:(0,$.jsx)(Dn,{value:C,onValueChange:w,children:T})}),t[27]=C,t[28]=w,t[29]=T,t[30]=E):E=t[30];let D;t[31]!==S||t[32]!==E?(D=(0,$.jsxs)($n,{children:[S,E]}),t[31]=S,t[32]=E,t[33]=D):D=t[33];let O;return t[34]!==D||t[35]!==m?(O=(0,$.jsx)(`div`,{className:m,children:D}),t[34]=D,t[35]=m,t[36]=O):O=t[36],O};function Eo(e){return e.projects}function Do(e){return e.activeProjectId}function Oo(e){return e.setActiveProject}function ko(e,t){return(e.label||e.path).localeCompare(t.label||t.path)}function Ao(e){let t=e.path.split(`/`).filter(Boolean).pop()||e.path;return(0,$.jsx)(ir,{value:e.id,children:(0,$.jsx)(`span`,{className:`min-w-0 truncate typography-ui`,children:t})},e.id)}function jo(e,t){return`opencode:sidebar-group:${e}:${t}`}var Mo=e=>{let t=(0,Sa.c)(57),{label:n,count:r,storageKey:i,defaultExpanded:a,variant:o,labelPrefix:s,children:c}=e,l=a===void 0||a,u=o===void 0?`sidebar`:o,d;t[0]!==n||t[1]!==i?(d=jo(i,n),t[0]=n,t[1]=i,t[2]=d):d=t[2];let f=d,p=Q.useId(),m;t[3]!==l||t[4]!==f?(m=()=>{try{let e=localStorage.getItem(f);if(e!==null)return e===`true`}catch{}return l},t[3]=l,t[4]=f,t[5]=m):m=t[5];let[h,g]=(0,Q.useState)(m),_,v;if(t[6]!==h||t[7]!==f?(_=()=>{try{localStorage.setItem(f,String(h))}catch{}},v=[f,h],t[6]=h,t[7]=f,t[8]=_,t[9]=v):(_=t[8],v=t[9]),(0,Q.useEffect)(_,v),u===`settings-card`){let e;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(e=()=>g(No),t[10]=e):e=t[10];let i;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(i=K(`flex w-full items-center gap-1 text-left`,`text-inherit transition-colors duration-150 hover:text-foreground`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`),t[11]=i):i=t[11];let a=!h&&`-rotate-90`,o;t[12]===a?o=t[13]:(o=K(`h-3.5 w-3.5 flex-shrink-0 transition-transform duration-200`,a),t[12]=a,t[13]=o);let l;t[14]===o?l=t[15]:(l=(0,$.jsx)(X,{name:`arrow-down-s`,className:o}),t[14]=o,t[15]=l);let u=s?`${s} · `:``,d;t[16]!==n||t[17]!==u?(d=(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[u,n]}),t[16]=n,t[17]=u,t[18]=d):d=t[18];let f;t[19]===r?f=t[20]:(f=(0,$.jsx)(`span`,{className:`ml-1 tabular-nums opacity-60`,children:r}),t[19]=r,t[20]=f);let m;t[21]!==p||t[22]!==h||t[23]!==l||t[24]!==d||t[25]!==f?(m=(0,$.jsxs)(`button`,{type:`button`,onClick:e,"aria-expanded":h,"aria-controls":p,className:i,children:[l,d,f]}),t[21]=p,t[22]=h,t[23]=l,t[24]=d,t[25]=f,t[26]=m):m=t[26];let _=!h&&`hidden`,v;t[27]===_?v=t[28]:(v=K(_),t[27]=_,t[28]=v);let y;return t[29]!==c||t[30]!==p||t[31]!==m||t[32]!==v?(y=(0,$.jsx)(Z,{label:m,cardClassName:v,cardId:p,children:c}),t[29]=c,t[30]=p,t[31]=m,t[32]=v,t[33]=y):y=t[33],y}let y;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(y=()=>g(Po),t[34]=y):y=t[34];let b;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(b=K(`flex w-full items-center gap-1 rounded-md px-2 py-1 text-left`,`text-xs font-semibold uppercase tracking-wide text-muted-foreground`,`hover:bg-[var(--interactive-hover)] transition-colors duration-150`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`),t[35]=b):b=t[35];let x=!h&&`-rotate-90`,S;t[36]===x?S=t[37]:(S=K(`h-3.5 w-3.5 flex-shrink-0 transition-transform duration-200`,x),t[36]=x,t[37]=S);let C;t[38]===S?C=t[39]:(C=(0,$.jsx)(X,{name:`arrow-down-s`,className:S}),t[38]=S,t[39]=C);let w;t[40]===n?w=t[41]:(w=(0,$.jsx)(`span`,{className:`flex-1 truncate`,children:n}),t[40]=n,t[41]=w);let T;t[42]===r?T=t[43]:(T=(0,$.jsx)(`span`,{className:`ml-1 tabular-nums opacity-60`,children:r}),t[42]=r,t[43]=T);let E;t[44]!==p||t[45]!==h||t[46]!==C||t[47]!==w||t[48]!==T?(E=(0,$.jsxs)(`button`,{type:`button`,onClick:y,"aria-expanded":h,"aria-controls":p,className:b,children:[C,w,T]}),t[44]=p,t[45]=h,t[46]=C,t[47]=w,t[48]=T,t[49]=E):E=t[49];let D=!h,O;t[50]!==c||t[51]!==p||t[52]!==D?(O=(0,$.jsx)(`div`,{id:p,hidden:D,className:`mt-0.5 space-y-0.5 ml-2 pl-3 border-l-2 border-[var(--interactive-border)]`,children:c}),t[50]=c,t[51]=p,t[52]=D,t[53]=O):O=t[53];let k;return t[54]!==E||t[55]!==O?(k=(0,$.jsxs)(`div`,{children:[E,O]}),t[54]=E,t[55]=O,t[56]=k):k=t[56],k};function No(e){return!e}function Po(e){return!e}var Fo=e=>e===`bash`?`shell`:e===`task`?`subagent`:e===`write`||e===`patch`?`edit`:e,Io=e=>{let t=Kn(e).map(e=>({action:Fo(e.action),resource:e.resource,effect:e.effect}));return t.length>0?t:void 0},Lo=(e,t)=>{let n=e,r=ft(e)?void 0:typeof n.system==`string`?n.system:typeof e.prompt==`string`?e.prompt:void 0,i=typeof n.color==`string`&&Co(n.color)?n.color:void 0;return{name:t,scope:n.scope||`user`,description:e.description,model:xo(e)||null,...r?{system:r}:{},mode:e.mode,...typeof n.steps==`number`?{steps:n.steps}:{},...e.hidden===!0?{hidden:!0}:{},...n.disabledOverride?{disabled:!0}:{},...i?{color:i}:{},permissions:Io(n.permissions??e.permission)}},Ro=({onItemSelect:e})=>{let{t}=Ge(),[n,r]=Q.useState(null),[i,a]=Q.useState(``),[o,s]=Q.useState(null),[c,l]=Q.useState(null),[u,d]=Q.useState(!1),[f,p]=Q.useState(null),{selectedAgentName:m,setSelectedAgent:h,setAgentDraft:g,createAgent:_,deleteAgent:v,loadAgents:y}=xt(ne(e=>({selectedAgentName:e.selectedAgentName,setSelectedAgent:e.setSelectedAgent,setAgentDraft:e.setAgentDraft,createAgent:e.createAgent,deleteAgent:e.deleteAgent,loadAgents:e.loadAgents}))),{data:b=[]}=Xt();Q.useEffect(()=>{y()},[y]);let x=()=>{let t=`new-agent`,n=t,r=1;for(;b.some(e=>e.name===n);)n=`${t}-${r}`,r++;g({name:n,scope:`user`}),h(n),e?.()},S=async e=>{if(ft(e)){Y.error(t(`settings.agents.sidebar.toast.builtInCannotDelete`));return}s(e),l(`delete`)},C=async e=>{ft(e)&&(s(e),l(`reset`))},w=()=>{s(null),l(null)},T=async()=>{if(!(!o||!c)){d(!0);try{let e=await v(o.name,o.scope);e.ok?(e.requiresManualRestart?Y.warning(t(`settings.agents.page.toast.savedManualRestart`)):c===`delete`?Y.success(t(`settings.agents.sidebar.toast.agentDeleted`,{name:o.name})):Y.success(t(`settings.agents.sidebar.toast.agentReset`,{name:o.name})),w()):c===`delete`?Y.error(t(`settings.agents.sidebar.toast.deleteFailed`)):Y.error(t(`settings.agents.sidebar.toast.resetFailed`))}catch(e){let n=e instanceof Error?e.message:``,r=/built-in|not deletable|not found/i.test(n);c===`delete`?Y.error(t(r?`settings.agents.sidebar.toast.definitionNotFound`:`settings.agents.sidebar.toast.deleteFailed`)):Y.error(t(`settings.agents.sidebar.toast.resetFailed`))}d(!1)}},E=e=>{let t=e.name,n=1,r=`${t}-copy`;for(;b.some(e=>e.name===r);)n++,r=`${t}-copy-${n}`;g(Lo(e,r)),h(r)},D=e=>{a(e.name),r(e)},O=async()=>{if(!n)return;let e=i.trim().replace(/\s+/g,`-`);if(!e){Y.error(t(`settings.agents.sidebar.toast.agentNameRequired`));return}if(e===n.name){r(null);return}if(b.some(t=>t.name===e)){Y.error(t(`settings.agents.sidebar.toast.agentExists`));return}let a=n,o=await _({...Lo(n,e),scope:a.scope});if(o.ok){let r=await v(n.name,a.scope);r.ok?(o.requiresManualRestart||r.requiresManualRestart?Y.warning(t(`settings.agents.page.toast.savedManualRestart`)):Y.success(t(`settings.agents.sidebar.toast.agentRenamed`,{name:e})),h(e)):Y.error(t(`settings.agents.sidebar.toast.removeOldAfterRenameFailed`))}else Y.error(t(`settings.agents.sidebar.toast.renameFailed`));r(null)},k=e=>{switch(e){case`primary`:return(0,$.jsx)(X,{name:`ai-agent`,className:`h-3 w-3 text-primary`});case`all`:return(0,$.jsx)(X,{name:`ai-agent-fill`,className:`h-3 w-3 text-primary`});case`subagent`:return(0,$.jsx)(X,{name:`robot`,className:`h-3 w-3 text-primary`});default:return null}},A=b.filter(e=>{let t=e;return!mt(e)||!!t.scope||t.disabledOverride===!0}),j=A.filter(ft),M=A.filter(e=>!ft(e)),{groupedCustomAgents:N,ungroupedCustomAgents:P}=(0,Q.useMemo)(()=>{let e={},t=[];for(let n of M){let r=n;r.group?(e[r.group]||(e[r.group]=[]),e[r.group].push(n)):t.push(n)}return{groupedCustomAgents:Object.keys(e).sort((e,t)=>e.localeCompare(t)).map(t=>({name:t,agents:e[t]})),ungroupedCustomAgents:t}},[M]),F=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,$.jsx)(`span`,{children:t(`settings.agents.sidebar.section.custom`)}),(0,$.jsx)(q,{"data-settings-item":`agents.create`,size:`icon`,variant:`ghost`,onClick:x,"aria-label":t(`settings.agents.page.title.new`),children:(0,$.jsx)(X,{name:`add`,className:`h-4 w-4`})})]});return(0,$.jsxs)(`div`,{className:`yuri-settings-page-content h-full overflow-y-auto bg-background p-3`,children:[(0,$.jsx)(To,{}),(0,$.jsx)($.Fragment,{children:A.length===0?(0,$.jsx)(Z,{children:(0,$.jsxs)(`div`,{className:`yuri-settings-group-row py-12 text-center text-muted-foreground`,children:[(0,$.jsx)(X,{name:`robot-2`,className:`mx-auto mb-3 h-10 w-10 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-ui-label font-medium`,children:t(`settings.agents.sidebar.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:t(`settings.agents.sidebar.empty.description`)})]})}):(0,$.jsxs)($.Fragment,{children:[j.length>0&&(0,$.jsx)(Z,{label:t(`settings.agents.sidebar.section.builtIn`),children:j.map(t=>(0,$.jsx)(zo,{agent:t,isSelected:m===t.name,onSelect:()=>{h(t.name),e?.()},onReset:()=>C(t),onDuplicate:()=>E(t),getAgentModeIcon:k,isMenuOpen:f===t.name,onMenuOpenChange:e=>p(e?t.name:null)},t.name))}),M.length>0&&(0,$.jsxs)($.Fragment,{children:[N.map(({name:n,agents:r})=>(0,$.jsx)(Mo,{label:n,count:r.length,storageKey:`agents`,variant:`settings-card`,labelPrefix:t(`settings.agents.sidebar.section.custom`),children:r.map(t=>(0,$.jsx)(zo,{agent:t,isSelected:m===t.name,onSelect:()=>{h(t.name),e?.()},onRename:()=>D(t),onDelete:()=>S(t),onDuplicate:()=>E(t),getAgentModeIcon:k,isMenuOpen:f===t.name,onMenuOpenChange:e=>p(e?t.name:null)},t.name))},n)),P.length>0?(0,$.jsx)(Z,{label:F,children:P.map(t=>(0,$.jsx)(zo,{agent:t,isSelected:m===t.name,onSelect:()=>{h(t.name),e?.()},onRename:()=>D(t),onDelete:()=>S(t),onDuplicate:()=>E(t),getAgentModeIcon:k,isMenuOpen:f===t.name,onMenuOpenChange:e=>p(e?t.name:null)},t.name))}):(0,$.jsx)(Z,{label:F,cardClassName:`hidden`,children:(0,$.jsx)(`span`,{})})]}),M.length===0&&(0,$.jsx)(Z,{label:F,cardClassName:`hidden`,children:(0,$.jsx)(`span`,{})})]})}),(0,$.jsx)(gn,{open:o!==null&&c!==null,onOpenChange:e=>{!e&&!u&&w()},children:(0,$.jsxs)(pn,{className:`max-w-md`,children:[(0,$.jsxs)(dn,{children:[(0,$.jsx)(mn,{children:t(c===`delete`?`settings.agents.sidebar.dialog.deleteTitle`:`settings.agents.sidebar.dialog.resetTitle`)}),(0,$.jsx)(hn,{children:t(c===`delete`?`settings.agents.sidebar.dialog.deleteDescription`:`settings.agents.sidebar.dialog.resetDescription`,{name:o?.name??``})})]}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(q,{size:`sm`,variant:`ghost`,onClick:w,disabled:u,children:t(`settings.common.actions.cancel`)}),(0,$.jsx)(q,{size:`sm`,onClick:T,disabled:u,children:t(c===`delete`?`settings.common.actions.delete`:`settings.common.actions.reset`)})]})]})}),(0,$.jsx)(gn,{open:n!==null,onOpenChange:e=>!e&&r(null),children:(0,$.jsxs)(pn,{children:[(0,$.jsxs)(dn,{children:[(0,$.jsx)(mn,{children:t(`settings.agents.sidebar.renameDialog.title`)}),(0,$.jsx)(hn,{children:t(`settings.agents.sidebar.renameDialog.description`,{name:n?.name??``})})]}),(0,$.jsx)(Cn,{value:i,onChange:e=>a(e.target.value),placeholder:t(`settings.agents.sidebar.renameDialog.placeholder`),className:`text-foreground placeholder:text-muted-foreground`,onKeyDown:e=>{e.key===`Enter`&&O()}}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(q,{size:`sm`,variant:`ghost`,onClick:()=>r(null),children:t(`settings.common.actions.cancel`)}),(0,$.jsx)(q,{size:`sm`,onClick:O,children:t(`settings.common.actions.rename`)})]})]})})]})},zo=e=>{let t=(0,Sa.c)(55),{agent:n,isSelected:r,onSelect:i,onDelete:a,onReset:o,onRename:s,onDuplicate:c,getAgentModeIcon:l,isMenuOpen:u,onMenuOpenChange:d}=e,{t:f}=Ge(),p=n,m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=Cr(),t[0]=m):m=t[0];let h=m,[g,_]=Q.useState(!1),v;t[1]!==a||t[2]!==c||t[3]!==s||t[4]!==o||t[5]!==f?(v=e=>(0,$.jsxs)($.Fragment,{children:[s&&(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),s()},children:[(0,$.jsx)(X,{name:`edit`,className:`h-4 w-4 mr-px`}),f(`settings.common.actions.rename`)]}),(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),c()},children:[(0,$.jsx)(X,{name:`file-copy`,className:`h-4 w-4 mr-px`}),f(`settings.common.actions.duplicate`)]}),o&&(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),o()},children:[(0,$.jsx)(X,{name:`restart`,className:`h-4 w-4 mr-px`}),f(`settings.common.actions.reset`)]}),a&&(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),a()},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(X,{name:`delete-bin`,className:`h-4 w-4 mr-px`}),f(`settings.common.actions.delete`)]})]}),t[1]=a,t[2]=c,t[3]=s,t[4]=o,t[5]=f,t[6]=v):v=t[6];let y=v,b=r?`bg-interactive-selection`:`hover:bg-interactive-hover`,x;t[7]===b?x=t[8]:(x=K(`yuri-settings-group-row group relative flex items-center transition-colors duration-150 select-none`,b),t[7]=b,t[8]=x);let S;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(S=h?void 0:e=>{e.preventDefault(),_(!0)},t[9]=S):S=t[9];let C;t[10]===x?C=t[11]:(C=(0,$.jsx)(`div`,{className:x,onContextMenu:S}),t[10]=x,t[11]=C);let w;t[12]===n.name?w=t[13]:(w=wo(n.name),t[12]=n.name,t[13]=w);let T;t[14]===w?T=t[15]:(T=(0,$.jsx)(`span`,{className:`typography-ui-label font-normal truncate text-foreground`,children:w}),t[14]=w,t[15]=T);let E;t[16]!==n.mode||t[17]!==l?(E=l(n.mode),t[16]=n.mode,t[17]=l,t[18]=E):E=t[18];let D;t[19]!==n||t[20]!==p.disabledOverride||t[21]!==p.scope||t[22]!==f?(D=(p.scope||ft(n)||p.disabledOverride)&&(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-muted px-1 rounded flex-shrink-0 leading-none pb-px border border-border/50`,children:p.disabledOverride?f(`settings.agents.sidebar.badge.disabled`):ft(n)?f(`settings.agents.sidebar.badge.system`):p.scope===`project`?f(`settings.common.scope.project`):f(`settings.common.scope.global`)}),t[19]=n,t[20]=p.disabledOverride,t[21]=p.scope,t[22]=f,t[23]=D):D=t[23];let O;t[24]!==D||t[25]!==T||t[26]!==E?(O=(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[T,E,D]}),t[24]=D,t[25]=T,t[26]=E,t[27]=O):O=t[27];let k;t[28]===n.description?k=t[29]:(k=n.description&&(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/60 truncate leading-tight`,children:n.description}),t[28]=n.description,t[29]=k);let A;t[30]!==i||t[31]!==O||t[32]!==k?(A=(0,$.jsxs)(`button`,{onClick:i,className:`flex min-w-0 flex-1 flex-col gap-0 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,tabIndex:0,children:[O,k]}),t[30]=i,t[31]=O,t[32]=k,t[33]=A):A=t[33];let j;t[34]===d?j=t[35]:(j=e=>{e&&_(!1),d(e)},t[34]=d,t[35]=j);let M;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,$.jsx)(fr,{asChild:!0,children:(0,$.jsx)(q,{size:`sm`,variant:`ghost`,className:`h-6 w-6 px-0 flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100`,children:(0,$.jsx)(X,{name:`more-2`,className:`h-3.5 w-3.5`})})}),t[36]=M):M=t[36];let N;t[37]===y?N=t[38]:(N=(0,$.jsx)(Zn,{align:`end`,className:`w-fit min-w-20`,children:y(tr)}),t[37]=y,t[38]=N);let P;t[39]!==u||t[40]!==j||t[41]!==N?(P=(0,$.jsxs)($n,{open:u,onOpenChange:j,children:[M,N]}),t[39]=u,t[40]=j,t[41]=N,t[42]=P):P=t[42];let F;t[43]!==A||t[44]!==P?(F=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:[A,P]}),t[43]=A,t[44]=P,t[45]=F):F=t[45];let I;t[46]!==F||t[47]!==C?(I=(0,$.jsx)(na,{render:C,children:F}),t[46]=F,t[47]=C,t[48]=I):I=t[48];let L;t[49]===y?L=t[50]:(L=(0,$.jsx)(ra,{className:`w-fit min-w-20`,children:y(ia)}),t[49]=y,t[50]=L);let R;return t[51]!==g||t[52]!==I||t[53]!==L?(R=(0,$.jsxs)(aa,{open:g,onOpenChange:_,children:[I,L]}),t[51]=g,t[52]=I,t[53]=L,t[54]=R):R=t[54],R};function Bo(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function Vo(e){return typeof e==`string`&&e.length>0?e:void 0}function Ho(e){let t=Bo(e)?e:null,n=t&&Array.isArray(t.data)?t.data:Array.isArray(e)?e:null;if(!n)throw Error(`permission saved: expected list payload`);return n.map(e=>{if(!Bo(e))throw Error(`permission saved: invalid rule`);let t=Vo(e.id),n=Vo(e.projectID),r=Vo(e.action),i=Vo(e.resource);if(!t||!n||!r||!i)throw Error(`permission saved: invalid rule`);return{id:t,projectID:n,action:r,resource:i}})}async function Uo(e,t){if(!e.trim())throw Error(`permission saved: directory required`);t?.throwIfAborted();let n=await oe.getApiClient().location.get({location:{directory:e}},{signal:t});t?.throwIfAborted();let r=Vo(n?.project?.id);if(!r)throw Error(`permission saved: project ID required`);return r}async function Wo(e){e.signal?.throwIfAborted();let t=await oe.getApiClient().permission.saved.list({projectID:e.projectID??void 0},{signal:e.signal});e.signal?.throwIfAborted();let n=Ho(t);if(e.projectID&&n.some(t=>t.projectID!==e.projectID))throw Error(`permission saved: project mismatch`);return n}async function Go(e){e.signal?.throwIfAborted(),await oe.getApiClient().permission.saved.remove({id:e.id},{signal:e.signal})}function Ko(e){if(e.transport!==i()||e.generation!==o())throw Error(`Saved permission runtime changed`)}var qo=e=>Ee({queryKey:[e.transport,e.generation,`saved-permission-project`,e.directory],queryFn:async({signal:t})=>{Ko(e);let n=await Uo(e.directory,t);return Ko(e),n},retry:!1}),Jo=e=>Ee({queryKey:[e.transport,e.generation,`saved-permissions`,e.directory,e.projectID],queryFn:async({signal:t})=>{if(Ko(e),!e.directory||!e.projectID)throw Error(`Saved permission scope required`);let n=await Wo({projectID:e.projectID,signal:t});return Ko(e),n},retry:!1});function Yo(e){let t=(0,Sa.c)(3),n=(0,Q.useSyncExternalStore)(r,o,o),a={transport:i(),generation:n,directory:e.trim()},s=De({...qo(a),enabled:!!a.directory}),c={...a,projectID:s.data??``},l=Jo(c),u=!!(a.directory&&s.data)&&!s.isError,d;return t[0]!==l||t[1]!==u?(d={...l,enabled:u},t[0]=l,t[1]=u,t[2]=d):d=t[2],{project:s,list:De(d),scope:c}}async function Xo(e,t,n){Ko(t);let r=Jo(t).queryKey;if(!e.getQueryData(r)?.some(e=>e.id===n&&e.projectID===t.projectID))throw Error(`Saved permission is outside the captured scope`);await Go({id:n}),t.transport===i()&&t.generation===o()&&(await e.cancelQueries({queryKey:r,exact:!0}),t.transport===i()&&t.generation===o()&&e.setQueryData(r,e=>e?.filter(e=>e.id!==n)))}var Zo=()=>{let e=(0,Sa.c)(49),{t}=Ge(),n=ce(Qo),r=we(),{project:i,list:a,scope:o}=Yo(n),s;e[0]===r?s=e[1]:(s={mutationFn:e=>{let{scope:t,id:n}=e;return Xo(r,t,n)}},e[0]=r,e[1]=s);let c=Te(s),l;e[2]!==c.variables||e[3]!==o?(l=c.variables&&JSON.stringify(c.variables.scope)===JSON.stringify(o),e[2]=c.variables,e[3]=o,e[4]=l):l=e[4];let u=l,d=i.isError||a.isError,f=!!o.directory&&(i.isPending||a.isPending)&&!d,p;e[5]===a.data?p=e[6]:(p=a.data??[],e[5]=a.data,e[6]=p);let m=p,h;e[7]!==c||e[8]!==o?(h=e=>c.mutate({scope:o,id:e}),e[7]=c,e[8]=o,e[9]=h):h=e[9];let g=He(h),_;e[10]!==a||e[11]!==i?(_=()=>{i.isError?i.refetch():a.refetch()},e[10]=a,e[11]=i,e[12]=_):_=e[12];let v=He(_);if(!d&&!f&&m.length===0)return null;let y;e[13]===t?y=e[14]:(y=t(`settings.permissions.saved.title`),e[13]=t,e[14]=y);let b;e[15]!==f||e[16]!==t?(b=f?t(`common.loading`):void 0,e[15]=f,e[16]=t,e[17]=b):b=e[17];let x;e[18]!==d||e[19]!==a.isFetching||e[20]!==i.isFetching||e[21]!==v||e[22]!==t?(x=d&&(0,$.jsx)(Xi,{label:(0,$.jsx)(`span`,{role:`alert`,children:t(`settings.permissions.saved.loadFailed`)}),children:(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`xs`,onClick:v,disabled:i.isFetching||a.isFetching,children:t(`settings.permissions.saved.retry`)})}),e[18]=d,e[19]=a.isFetching,e[20]=i.isFetching,e[21]=v,e[22]=t,e[23]=x):x=e[23];let S;e[24]!==c.isError||e[25]!==u||e[26]!==t?(S=u&&c.isError&&(0,$.jsx)(Xi,{label:(0,$.jsx)(`span`,{role:`alert`,children:t(`settings.permissions.saved.deleteFailed`)}),children:null}),e[24]=c.isError,e[25]=u,e[26]=t,e[27]=S):S=e[27];let C;if(e[28]!==c.isPending||e[29]!==d||e[30]!==g||e[31]!==m||e[32]!==f||e[33]!==u||e[34]!==t){let n;e[36]!==c.isPending||e[37]!==d||e[38]!==g||e[39]!==f||e[40]!==u||e[41]!==t?(n=e=>(0,$.jsx)(Xi,{label:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{children:e.action}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground font-mono`,children:e.resource})]}),children:(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`xs`,disabled:d||f||!!(u&&c.isPending),onClick:()=>void g(e.id),children:t(`settings.permissions.saved.delete`)})},e.id),e[36]=c.isPending,e[37]=d,e[38]=g,e[39]=f,e[40]=u,e[41]=t,e[42]=n):n=e[42],C=m.map(n),e[28]=c.isPending,e[29]=d,e[30]=g,e[31]=m,e[32]=f,e[33]=u,e[34]=t,e[35]=C}else C=e[35];let w;return e[43]!==y||e[44]!==b||e[45]!==x||e[46]!==S||e[47]!==C?(w=(0,$.jsx)(`div`,{"data-settings-item":`permissions.saved`,className:`mb-6`,children:(0,$.jsxs)(Z,{label:y,description:b,children:[x,S,C]})}),e[43]=y,e[44]=b,e[45]=x,e[46]=S,e[47]=C,e[48]=w):w=e[48],w};function Qo(e){return e.currentDirectory}var $o=[`*`,`read`,`edit`,`glob`,`grep`,`shell`,`subagent`,`skill`,`webfetch`,`websearch`,`question`,`external_directory`,`execute`,`browser`],es={"*":`settings.agents.page.permissions.defaultLabel`,shell:`settings.agents.page.permissions.shell`,bash:`settings.agents.page.permissions.shell`,subagent:`settings.agents.page.permissions.subagent`,task:`settings.agents.page.permissions.subagent`,edit:`settings.agents.page.permissions.edit`,write:`settings.agents.page.permissions.edit`,patch:`settings.agents.page.permissions.edit`,apply_patch:`settings.agents.page.permissions.edit`,multiedit:`settings.agents.page.permissions.edit`,external_directory:`settings.agents.page.permissions.externalDirectory`,question:`settings.agents.page.permissions.question`,read:`settings.agents.page.permissions.read`,glob:`settings.agents.page.permissions.glob`,grep:`settings.agents.page.permissions.grep`,skill:`settings.agents.page.permissions.skill`,webfetch:`settings.agents.page.permissions.webfetch`,websearch:`settings.agents.page.permissions.websearch`,execute:`settings.agents.page.permissions.execute`,browser:`settings.agents.page.permissions.browser`,session_rename:`chat.tools.display.session_rename`,session_move:`chat.tools.display.session_move`},ts=e=>e===`allow`||e===`ask`||e===`deny`,ns=(e,t)=>`${e}::${t}`,rs=e=>e===`bash`?`shell`:e===`task`?`subagent`:e===`write`||e===`patch`?`edit`:e,is=e=>{let t=new Map;for(let n of e){let e=rs(n.permission);!e||e===`invalid`||n.pattern&&ts(n.action)&&t.set(ns(e,n.pattern),{permission:e,pattern:n.pattern,action:n.action})}return Array.from(t.values())},as=e=>{let t=new Map;for(let n of is(e))t.set(ns(n.permission,n.pattern),n);return t},os=e=>[...e].sort((e,t)=>{let n=e.permission.localeCompare(t.permission);return n===0?e.pattern.localeCompare(t.pattern):n}),ss=(e,t)=>{let n=os(is(e)),r=os(is(t));return n.length===r.length&&n.every((e,t)=>{let n=r[t];return e.permission===n.permission&&e.pattern===n.pattern&&e.action===n.action})},cs=e=>e.find(e=>e.permission===`*`&&e.pattern===`*`)?.action??`allow`,ls=(e,t)=>is(e).filter(e=>e.permission!==`*`||e.pattern!==`*`).filter(e=>e.pattern!==`*`||e.action!==t),us=e=>{if(Array.isArray(e))return is(e.flatMap(e=>!e||typeof e!=`object`||typeof e.action!=`string`||typeof e.resource!=`string`||!ts(e.effect)?[]:[{permission:e.action,pattern:e.resource,action:e.effect}]));if(ts(e))return[{permission:`*`,pattern:`*`,action:e}];if(!e||typeof e!=`object`||Array.isArray(e))return[];let t=[];for(let[n,r]of Object.entries(e))if(n!==`__originalKeys`){if(ts(r)){t.push({permission:n,pattern:`*`,action:r});continue}if(r&&typeof r==`object`&&!Array.isArray(r))for(let[e,i]of Object.entries(r))ts(i)&&t.push({permission:n,pattern:e,action:i})}return t},ds=()=>{let{t:e}=Ge(),{selectedAgentName:t,getAgentByName:n,createAgent:r,updateAgent:i,agentDraft:a,setAgentDraft:o}=xt(ne(e=>({selectedAgentName:e.selectedAgentName,getAgentByName:e.getAgentByName,createAgent:e.createAgent,updateAgent:e.updateAgent,agentDraft:e.agentDraft,setAgentDraft:e.setAgentDraft}))),{data:s=[]}=Xt(),c=t?n(t):null,u=!!(a&&a.name===t&&!c),[d,f]=Q.useState(``),[p,m]=Q.useState(`user`),[h,g]=Q.useState(``),[_,v]=Q.useState(`subagent`),[y,b]=Q.useState(``),[x,S]=Q.useState(``),[C,w]=Q.useState(!1),[T,E]=Q.useState(`allow`),[D,O]=Q.useState([]),[k,A]=Q.useState([]),[j,M]=Q.useState(``),[N,P]=Q.useState(`*`),[F,I]=Q.useState(!1),[L,R]=Q.useState(!1),z=Q.useRef(null),B=ce(e=>e.currentDirectory??null),[V,H]=Q.useState([]),U=Ut(e=>e.permission);Q.useEffect(()=>{let e=!1;return(async()=>{let t=await oe.listToolIds({directory:B});if(e)return;let n=new Set([`write`,`patch`,`multiedit`]),r=t.map(e=>typeof e==`string`?e.trim():``).filter(Boolean).filter(e=>e!==`*`).filter(e=>e!==`invalid`).filter(e=>!n.has(e));H(Array.from(new Set(r)).sort((e,t)=>e.localeCompare(t)))})(),()=>{e=!0}},[B]);let W=Q.useMemo(()=>{let e=new Set;for(let t of s){let n=is(us(t.permissions??t.permission));for(let t of n)t.permission&&t.permission!==`*`&&t.permission!==`invalid`&&e.add(t.permission)}for(let t of Object.values(U))for(let n of t){let t=n.permission?.trim();t&&t!==`invalid`&&e.add(t)}for(let t of V)e.add(t);return Array.from(e).sort((e,t)=>e.localeCompare(t))},[s,U,V]),ee=Q.useMemo(()=>as(D),[D]),te=Q.useMemo(()=>as(k),[k]),re=e=>te.get(ns(e,`*`))?.action,ie=e=>k.filter(t=>t.permission===e&&t.pattern!==`*`).sort((e,t)=>e.pattern.localeCompare(t.pattern)),ae=Q.useMemo(()=>{let e=new Set;for(let t of $o)e.add(t);for(let t of W)e.add(t);return Array.from(e).sort((e,t)=>e.localeCompare(t))},[W]),se=e=>{let t=e===`*`?T:re(e)??T,n=ie(e),r=n.reduce((e,t)=>(e[t.action]=(e[t.action]??0)+1,e),{allow:0,ask:0,deny:0}),i=[`allow`,`ask`,`deny`].filter(e=>r[e]>0).map(e=>`${r[e]} ${e}`).join(`, `);return{defaultAction:t,patternRulesCount:n.length,patternSummary:i,hasDefaultHint:!1}},le=t=>e(t===`allow`?`settings.common.permission.allow`:t===`deny`?`settings.common.permission.deny`:`settings.common.permission.ask`),ue=t=>t===`global`?e(`settings.common.scope.global`):le(t),de=Q.useMemo(()=>{let e=new Set;for(let t of $o)e.add(t);for(let t of W)e.add(t);return Array.from(e).sort((e,t)=>e.localeCompare(t))},[W]),G=(e,t,n)=>{A(r=>{let i=as(r);return i.set(ns(e,t),{permission:e,pattern:t,action:n}),Array.from(i.values())})},fe=(e,t)=>{A(n=>{let r=as(n);return r.delete(ns(e,t)),Array.from(r.values())})},pe=(e,t)=>{let n=ee.get(ns(e,t));if(n){G(e,t,n.action);return}fe(e,t)},me=(e,t,n)=>{G(e,t,n)},he=e=>{E(e),A(t=>t.filter(t=>t.pattern!==`*`||t.action!==e))},ge=t=>{let n=j.trim();if(!n){Y.error(e(`settings.agents.page.toast.permissionNameRequired`));return}let r=N.trim()||`*`;if(n===`*`&&r===`*`){he(t),M(``),P(`*`);return}r===`*`&&n!==`*`&&t===T?fe(n,`*`):G(n,r,t),M(``),P(`*`)},_e=t=>{let n=es[t];return n?e(n):t.split(/[_-]+/g).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)};Q.useEffect(()=>{M(``),P(`*`);let e=e=>{let t=is(e),n=cs(t),r=ls(t,n);return E(n),O(r),A(r),{global:n,rules:r}};if(u&&a){let t=a.name||``,n=a.scope||`user`,r=a.description||``,i=a.mode||`subagent`,o=a.model||``,s=a.system||``;f(t),m(n),g(r),v(i),b(o),S(s),w(!1);let c=e(us(a.permissions));z.current={draftName:t,draftScope:n,description:r,mode:i,model:o,system:s,globalPermission:c.global,permissionRules:c.rules};return}if(c&&t===c.name){let t=c,n=c.description||``,r=c.mode||`subagent`,i=xo(c),a=t.scope===`project`?`project`:`user`;m(a),g(n),v(r),b(i),S(``),w(!1);let o=e(us(t.permissions??c.permission));z.current={draftName:``,draftScope:a,description:n,mode:r,model:i,system:``,globalPermission:o.global,permissionRules:o.rules}}},[a,u,c,t]),Q.useEffect(()=>{if(!t||u)return;let e=new AbortController,n=jt();return l(`/api/config/agents/${encodeURIComponent(t)}/config`,{signal:e.signal,headers:n?{"x-opencode-directory":n}:{}}).then(async t=>{if(!t.ok||e.signal.aborted)return;let n=bo((await t.json()).config);e.signal.aborted||n===void 0||!z.current||(S(n),z.current={...z.current,system:n})}).catch(()=>void 0),()=>e.abort()},[u,t]);let ve=Q.useMemo(()=>{let e=z.current;return e?!!(u&&d!==e.draftName||p!==e.draftScope||h!==e.description||_!==e.mode||y!==e.model||x!==e.system||T!==e.globalPermission||!ss(k,e.permissionRules)):!1},[h,d,p,T,u,_,y,k,x]),ye=(!u&&c?c.document:void 0)?.dropped?.map(e=>e.key)??[],be=!L&&ve;return t?(0,$.jsx)(Ur,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`yuri-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsx)(Gi,{actions:(0,$.jsx)(q,{type:`button`,size:`sm`,onClick:async()=>{let n=u?d.trim().replace(/\s+/g,`-`):t?.trim();if(!n){Y.error(e(`settings.agents.sidebar.toast.agentNameRequired`));return}if(u&&s.some(e=>e.name===n)){Y.error(e(`settings.agents.sidebar.toast.agentExists`));return}R(!0);try{let t={description:h,mode:_,model:y,system:x,globalPermission:T,permissionRules:k},s=z.current,c=s?{description:s.description,mode:s.mode,model:s.model,system:s.system,globalPermission:s.globalPermission,permissionRules:s.permissionRules}:null,l=yo({isNewAgent:u,agentName:n,draftScope:p,initialScope:s?.draftScope,draftHasExplicitPermission:u&&a?.permissions!==void 0,current:t,initial:c,confirmDrop:C}),d;u?(d=await r(l),d.ok&&o(null)):d=await i(n,l),d.ok?d.requiresManualRestart?Y.warning(e(`settings.agents.page.toast.savedManualRestart`)):Y.success(e(`settings.agents.page.toast.savedNextRequest`)):Y.error(e(u?`settings.agents.page.toast.createFailed`:`settings.agents.page.toast.updateFailed`))}catch(t){console.error(`Error saving agent:`,t);let n=t instanceof Error&&t.message?t.message:e(`settings.agents.page.toast.saveUnexpectedError`);Y.error(n)}finally{R(!1)}},disabled:!be,"aria-busy":L,children:e(L?`settings.common.actions.saving`:`settings.common.actions.saveChanges`)}),children:(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:u?e(`settings.agents.page.title.new`):wo(t??``)}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground truncate`,children:e(u?`settings.agents.page.subtitle.new`:`settings.agents.page.subtitle.edit`)})]})}),(0,$.jsx)(Zo,{}),ye.length>0?(0,$.jsxs)(`div`,{className:`mt-3 flex flex-col gap-2`,children:[(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e(`settings.agents.page.legacy.dropped`,{fields:ye.join(`, `)})}),(0,$.jsx)(Ji,{checked:C,onChange:w,label:e(`settings.agents.page.legacy.confirmDrop`),ariaLabel:e(`settings.agents.page.legacy.confirmDrop`)})]}):null,(0,$.jsxs)(Z,{label:e(`settings.agents.page.section.identityRole`),children:[(0,$.jsx)(Xi,{itemId:`agents.scope`,label:e(`settings.agents.page.field.scope`),children:(0,$.jsxs)(Fr,{value:p,onValueChange:e=>m(e),children:[(0,$.jsx)(Pr,{className:`w-fit min-w-[100px]`,children:(0,$.jsx)(Ar,{placeholder:e(`settings.agents.page.field.scopePlaceholder`),children:t=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(X,{name:t===`project`?`folder`:`user-3`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:e(t===`project`?`settings.common.scope.project`:`settings.common.scope.global`)})]})})}),(0,$.jsxs)(Nr,{align:`end`,children:[(0,$.jsx)(jr,{value:`user`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(X,{name:`user-3`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:e(`settings.common.scope.global`)})]})}),(0,$.jsx)(jr,{value:`project`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(X,{name:`folder`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:e(`settings.common.scope.project`)})]})})]})]})}),u&&(0,$.jsx)(Xi,{itemId:`agents.name`,label:e(`settings.agents.page.field.agentName`),children:(0,$.jsxs)(`div`,{className:`flex items-center`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground mr-1`,children:`@`}),(0,$.jsx)(Cn,{value:d,onChange:e=>f(e.target.value),placeholder:e(`settings.agents.page.field.agentNamePlaceholder`),className:`h-7 w-40 px-2`})]})}),(0,$.jsx)(Xi,{label:e(`settings.common.field.description`),className:`yuri-settings-split-row-stacked`,children:(0,$.jsx)(Wr,{embedded:!0,value:h,onChange:e=>g(e.target.value),placeholder:e(`settings.agents.page.field.descriptionPlaceholder`),rows:2,className:`w-full resize-none min-h-[60px] bg-transparent`})}),(0,$.jsx)(Xi,{itemId:`agents.mode`,className:`yuri-settings-agents-mode-row`,label:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:e(`settings.agents.page.field.mode`)}),(0,$.jsxs)(En,{children:[(0,$.jsx)(wn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(Tn,{sideOffset:8,className:`max-w-xs`,children:e(`settings.agents.page.field.modeTooltip`)})]})]}),children:(0,$.jsxs)(`div`,{className:`flex flex-nowrap items-center justify-end gap-1`,children:[(0,$.jsx)(q,{variant:`chip`,size:`xs`,"aria-pressed":_===`primary`,onClick:()=>v(`primary`),className:`!font-normal shrink-0`,children:e(`settings.agents.page.mode.primary`)}),(0,$.jsx)(q,{variant:`chip`,size:`xs`,"aria-pressed":_===`subagent`,onClick:()=>v(`subagent`),className:`!font-normal shrink-0`,children:e(`settings.agents.page.mode.subagent`)}),(0,$.jsx)(q,{variant:`chip`,size:`xs`,"aria-pressed":_===`all`,onClick:()=>v(`all`),className:`!font-normal shrink-0`,children:e(`settings.agents.page.mode.all`)})]})})]}),(0,$.jsx)(Z,{label:e(`settings.agents.page.section.modelParameters`),children:(0,$.jsx)(Xi,{itemId:`agents.model`,label:e(`settings.agents.page.field.overrideModel`),children:(0,$.jsx)(ii,{providerId:So(y)?.providerId??``,modelId:So(y)?.modelId??``,variant:So(y)?.variant??``,onChange:(e,t,n)=>{b(e&&t?n?`${e}/${t}#${n}`:`${e}/${t}`:``)},className:`yuri-settings-inline-value`})})}),(0,$.jsx)(Ui,{itemId:`agents.system-prompt`,label:e(`settings.agents.page.section.systemPrompt`),className:`yuri-settings-split-row-stacked`,children:(0,$.jsx)(Wr,{embedded:!0,value:x,onChange:e=>S(e.target.value),placeholder:e(`settings.agents.page.field.systemPromptPlaceholder`),rows:8,className:`w-full font-mono typography-meta min-h-[120px] max-h-[60vh] bg-transparent resize-y`})}),(0,$.jsx)(`div`,{"data-settings-item":`agents.permissions`,children:(0,$.jsx)(Z,{label:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,$.jsx)(`span`,{children:e(`settings.agents.page.section.toolPermissions`)}),(0,$.jsx)(q,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>I(e=>!e),children:e(F?`settings.agents.page.permissions.hideEditor`:`settings.agents.page.permissions.advancedEditor`)})]}),children:F?(0,$.jsxs)(`div`,{className:`space-y-6 p-2`,children:[(0,$.jsx)(Xi,{label:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{children:e(`settings.agents.page.permissions.globalDefault`)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70 font-mono`,children:`*`})]}),children:(0,$.jsxs)(Fr,{value:T,onValueChange:e=>he(e),children:[(0,$.jsx)(Pr,{className:`w-[100px]`,children:(0,$.jsx)(Ar,{children:le(T)})}),(0,$.jsxs)(Nr,{children:[(0,$.jsx)(jr,{value:`allow`,children:e(`settings.common.permission.allow`)}),(0,$.jsx)(jr,{value:`ask`,children:e(`settings.common.permission.ask`)}),(0,$.jsx)(jr,{value:`deny`,children:e(`settings.common.permission.deny`)})]})]})}),(0,$.jsx)(`div`,{className:`space-y-4`,children:ae.filter(e=>e!==`*`).map(t=>{let n=_e(t),{defaultAction:r,patternRulesCount:i}=se(t),a=re(t),o=a??`global`,s=ie(t),c=[`allow`,`ask`,`deny`].filter(e=>e!==T);return(0,$.jsxs)(`div`,{className:`border-t border-[var(--surface-subtle)] pt-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between py-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:n}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70 font-mono`,children:t})]}),(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground`,children:i>0?e(`settings.agents.page.permissions.globalSummary`,{summary:r}):r})]}),(0,$.jsxs)(`div`,{className:`space-y-1 pl-2 mt-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 py-0.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:e(`settings.agents.page.permissions.pattern`)}),(0,$.jsx)(`span`,{className:`typography-micro font-mono text-foreground bg-[var(--surface-muted)] px-1 rounded`,children:`*`}),a&&(0,$.jsx)(q,{size:`sm`,variant:`ghost`,onClick:()=>pe(t,`*`),className:`px-1.5 py-0 h-5`,children:(0,$.jsx)(X,{name:`subtract`,className:`h-3.5 w-3.5 text-muted-foreground hover:text-foreground`})})]}),(0,$.jsxs)(Fr,{value:o,onValueChange:e=>{if(e===`global`){fe(t,`*`);return}G(t,`*`,e)},children:[(0,$.jsx)(Pr,{className:`w-[90px] shrink-0`,children:(0,$.jsx)(Ar,{children:ue(o)})}),(0,$.jsxs)(Nr,{children:[(0,$.jsx)(jr,{value:`global`,children:e(`settings.common.scope.global`)}),c.map(e=>(0,$.jsx)(jr,{value:e,className:`capitalize`,children:le(e)},e))]})]})]}),s.map(t=>{let n=ns(t.permission,t.pattern),r=ee.get(n),i=!r,a=!!(r&&r.action!==t.action);return(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 py-0.5 border-t border-[var(--surface-subtle)]`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:e(`settings.agents.page.permissions.pattern`)}),(0,$.jsx)(`span`,{className:`min-w-0 break-all typography-micro font-mono text-foreground bg-[var(--surface-muted)] px-1 rounded`,children:t.pattern}),i&&(0,$.jsx)(`span`,{className:`typography-micro text-[var(--status-success)]`,children:e(`settings.common.badge.new`)}),a&&(0,$.jsx)(`span`,{className:`typography-micro text-[var(--status-warning)]`,children:e(`settings.common.badge.modified`)}),(i||a)&&(0,$.jsx)(q,{size:`sm`,variant:`ghost`,onClick:()=>i?fe(t.permission,t.pattern):pe(t.permission,t.pattern),className:`px-1.5 py-0 h-5`,children:(0,$.jsx)(X,{name:`subtract`,className:`h-3.5 w-3.5 text-muted-foreground hover:text-foreground`})})]}),(0,$.jsxs)(Fr,{value:t.action,onValueChange:e=>me(t.permission,t.pattern,e),children:[(0,$.jsx)(Pr,{className:`w-[90px] shrink-0`,children:(0,$.jsx)(Ar,{children:le(t.action)})}),(0,$.jsxs)(Nr,{children:[(0,$.jsx)(jr,{value:`allow`,children:e(`settings.common.permission.allow`)}),(0,$.jsx)(jr,{value:`ask`,children:e(`settings.common.permission.ask`)}),(0,$.jsx)(jr,{value:`deny`,children:e(`settings.common.permission.deny`)})]})]})]},n)})]})]},t)})}),(0,$.jsxs)(`div`,{className:`border-t border-[var(--surface-subtle)] pt-3`,children:[(0,$.jsx)(`h4`,{className:`typography-ui-label text-foreground mb-2`,children:e(`settings.agents.page.permissions.addCustomRule`)}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,$.jsxs)(Fr,{value:j,onValueChange:M,children:[(0,$.jsx)(Pr,{className:`w-auto max-w-full sm:w-[160px]`,children:j?(0,$.jsx)(`span`,{className:`truncate`,children:_e(j)}):(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e(`settings.agents.page.permissions.permissionPlaceholder`)})}),(0,$.jsx)(Nr,{children:de.map(e=>(0,$.jsx)(jr,{value:e,children:(0,$.jsx)(`div`,{className:`flex items-center justify-between gap-2 w-full`,children:(0,$.jsx)(`span`,{children:_e(e)})})},e))})]}),(0,$.jsx)(Cn,{value:N,onChange:e=>P(e.target.value),placeholder:e(`settings.agents.page.permissions.patternPlaceholder`),className:`h-7 min-w-0 flex-1 basis-32 font-mono text-xs`}),(0,$.jsxs)(`div`,{className:`flex gap-1`,children:[(0,$.jsx)(q,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>ge(`allow`),children:e(`settings.common.permission.allow`)}),(0,$.jsx)(q,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>ge(`ask`),children:e(`settings.common.permission.ask`)}),(0,$.jsx)(q,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>ge(`deny`),children:e(`settings.common.permission.deny`)})]})]})]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground px-3 pt-2`,children:e(`settings.agents.page.permissions.lastMatchHint`)}),Hn(Kn(k)).map((e,t)=>(0,$.jsx)(Xi,{label:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground font-mono`,children:t+1}),(0,$.jsx)(`span`,{children:e.action}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70 font-mono`,children:e.resource})]}),children:(0,$.jsx)(`span`,{className:K(`typography-micro capitalize px-1.5 py-0.5 rounded`,e.effect===`allow`?`text-[var(--status-success)] bg-[var(--status-success)]/10`:e.effect===`deny`?`text-[var(--status-error)] bg-[var(--status-error)]/10`:`text-[var(--status-warning)] bg-[var(--status-warning)]/10`),children:e.effect})},`${e.action}::${e.resource}::${t}`))]})})})]})}):(0,$.jsx)(Ur,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`yuri-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsx)(Zo,{}),(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,$.jsxs)(`div`,{className:`text-center text-muted-foreground`,children:[(0,$.jsx)(X,{name:`robot-2`,className:`mx-auto mb-3 h-12 w-12 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.agents.page.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:e(`settings.agents.page.empty.description`)})]})})]})})};function fs(e){let t=(0,Sa.c)(46),{seed:n,disabled:r,onChange:i}=e,{t:a}=Ge(),o=rn(n),s;t[0]!==i||t[1]!==n?(s=e=>{i(nn({...rn(n),...e}))},t[0]=i,t[1]=n,t[2]=s):s=t[2];let c=He(s),l=Z,u;t[3]===a?u=t[4]:(u=a(`assistants.avatar.title`),t[3]=a,t[4]=u);let d=Xi,f;t[5]===a?f=t[6]:(f=a(`assistants.settings.randomAvatar`),t[5]=a,t[6]=f);let p;t[7]===a?p=t[8]:(p=a(`assistants.settings.randomAvatar`),t[7]=a,t[8]=p);let m;t[9]===i?m=t[10]:(m=()=>i(ln(crypto.randomUUID())),t[9]=i,t[10]=m);let h;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(X,{name:`refresh`,className:`size-3.5 sm:size-2.5`}),t[11]=h):h=t[11];let g;t[12]===a?g=t[13]:(g=a(`assistants.settings.randomAvatar`),t[12]=a,t[13]=g);let _;t[14]!==r||t[15]!==m||t[16]!==g||t[17]!==f||t[18]!==p?(_=(0,$.jsx)(`div`,{className:`absolute right-3 top-1 z-10 sm:right-2`,children:(0,$.jsxs)(q,{variant:`ghost`,size:`xs`,className:`gap-1.5 text-xs font-normal text-muted-foreground/80 hover:text-muted-foreground sm:gap-1 sm:text-[10px]`,disabled:r,"aria-label":f,title:p,onClick:m,children:[h,g]})}),t[14]=r,t[15]=m,t[16]=g,t[17]=f,t[18]=p,t[19]=_):_=t[19];let v;t[20]===a?v=t[21]:(v=a(`assistants.avatar.shape`),t[20]=a,t[21]=v);let y=tn.map(e=>(0,$.jsx)(q,{variant:`ghost`,size:`icon`,className:`size-11 rounded-lg ring-2 ring-transparent aria-pressed:ring-foreground/40 sm:size-9`,disabled:r,"aria-label":a(`assistants.avatar.shape.${e}`),title:a(`assistants.avatar.shape.${e}`),"aria-pressed":o.shape===e,"data-avatar-shape-option":e,onClick:()=>c({shape:e}),children:(0,$.jsx)(cn,{kind:`assistant`,name:nn({...o,shape:e}),size:32})},e)),b;t[22]!==v||t[23]!==y?(b=(0,$.jsx)(`div`,{className:`grid grid-cols-4 justify-items-center gap-3 sm:grid-cols-8 sm:gap-2`,role:`group`,"aria-label":v,children:y}),t[22]=v,t[23]=y,t[24]=b):b=t[24];let x;t[25]===a?x=t[26]:(x=a(`assistants.avatar.color`),t[25]=a,t[26]=x);let S;t[27]!==c||t[28]!==r||t[29]!==o||t[30]!==a?(S=sn.map(e=>(0,$.jsx)(q,{variant:`ghost`,size:`icon`,className:`rounded-full [corner-shape:round] ring-2 ring-transparent aria-pressed:ring-foreground/50`,disabled:r,"aria-label":a(`assistants.avatar.color.${e}`),title:a(`assistants.avatar.color.${e}`),"aria-pressed":o.color===e,"data-avatar-color-option":e,onClick:()=>c({color:e}),children:(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`size-5 rounded-full`,style:{backgroundColor:on(e)}})},e)),t[27]=c,t[28]=r,t[29]=o,t[30]=a,t[31]=S):S=t[31];let C;t[32]!==x||t[33]!==S?(C=(0,$.jsx)(`div`,{className:`grid grid-cols-6 justify-items-center gap-1`,role:`group`,"aria-label":x,children:S}),t[32]=x,t[33]=S,t[34]=C):C=t[34];let w;t[35]!==b||t[36]!==C?(w=(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-sm flex-col gap-6 sm:max-w-md sm:gap-4`,children:[b,C]}),t[35]=b,t[36]=C,t[37]=w):w=t[37];let T;t[38]!==d||t[39]!==_||t[40]!==w?(T=(0,$.jsxs)(d,{className:`yuri-settings-split-row-stacked`,copyClassName:`!hidden`,controlClassName:`!block !w-full !max-w-none px-3 py-6 sm:px-0 sm:py-3`,children:[_,w]}),t[38]=d,t[39]=_,t[40]=w,t[41]=T):T=t[41];let E;return t[42]!==l||t[43]!==T||t[44]!==u?(E=(0,$.jsx)(`div`,{className:`relative w-full`,"data-assistant-avatar-editor":``,children:(0,$.jsx)(l,{ariaLabel:u,children:T})}),t[42]=l,t[43]=T,t[44]=u,t[45]=E):E=t[45],E}var ps=e=>{let t=(0,Sa.c)(37),{title:n,metadata:r,selected:i,onSelect:a,icon:o,actions:s,className:c,rowId:l,compact:u}=e,d=i!==void 0&&i,f=u!==void 0&&u,p=s&&s.length>0,m=!f&&`yuri-settings-group-row`,h=d?`bg-interactive-selection`:`hover:bg-interactive-hover`,g;t[0]!==c||t[1]!==m||t[2]!==h?(g=K(`group relative flex items-center transition-colors duration-150`,m,h,c),t[0]=c,t[1]=m,t[2]=h,t[3]=g):g=t[3];let _=d?`true`:void 0,v;t[4]!==f||t[5]!==p?(v=f&&K(`px-3 py-2`,p&&`pr-9`),t[4]=f,t[5]=p,t[6]=v):v=t[6];let y;t[7]===v?y=t[8]:(y=K(`flex min-w-0 flex-1 self-stretch flex-col justify-center gap-0 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,v),t[7]=v,t[8]=y);let b=f?`flex flex-1 items-center gap-2 text-[13px] leading-5`:`typography-ui-label whitespace-normal [overflow-wrap:anywhere]`,x;t[9]===b?x=t[10]:(x=K(`min-w-0 font-normal text-foreground`,b),t[9]=b,t[10]=x);let S;t[11]!==x||t[12]!==n?(S=(0,$.jsx)(`span`,{className:x,children:n}),t[11]=x,t[12]=n,t[13]=S):S=t[13];let C;t[14]!==o||t[15]!==S?(C=(0,$.jsxs)(`div`,{className:`flex max-w-full min-w-0 items-center gap-1.5`,children:[o,S]}),t[14]=o,t[15]=S,t[16]=C):C=t[16];let w;t[17]!==f||t[18]!==r?(w=r&&(0,$.jsx)(`div`,{className:K(`max-w-full leading-tight text-muted-foreground/60`,f?`mt-0.5 min-w-0 w-full truncate pl-7 text-[11px]`:`typography-micro whitespace-normal [overflow-wrap:anywhere]`),children:r}),t[17]=f,t[18]=r,t[19]=w):w=t[19];let T;t[20]!==a||t[21]!==C||t[22]!==w||t[23]!==_||t[24]!==y?(T=(0,$.jsxs)(`button`,{onClick:a,"aria-current":_,"data-mobile-press-feedback":`soft`,className:y,tabIndex:0,children:[C,w]}),t[20]=a,t[21]=C,t[22]=w,t[23]=_,t[24]=y,t[25]=T):T=t[25];let E;t[26]!==s||t[27]!==f||t[28]!==p?(E=p&&(0,$.jsxs)($n,{children:[(0,$.jsx)(fr,{asChild:!0,children:(0,$.jsx)(q,{size:`icon`,variant:`ghost`,className:K(`h-6 w-6 flex-shrink-0 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100 focus-visible:opacity-100`,f?`absolute right-2 top-1/2 -translate-y-1/2`:`-mr-1`),children:(0,$.jsx)(X,{name:`more-2`,className:`h-3.5 w-3.5`})})}),(0,$.jsx)(Zn,{align:`end`,className:`w-fit min-w-20`,children:s.map(ms)})]}),t[26]=s,t[27]=f,t[28]=p,t[29]=E):E=t[29];let D;t[30]!==T||t[31]!==E?(D=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 self-stretch items-center`,children:[T,E]}),t[30]=T,t[31]=E,t[32]=D):D=t[32];let O;return t[33]!==l||t[34]!==D||t[35]!==g?(O=(0,$.jsx)(`div`,{"data-row-id":l,className:g,children:D}),t[33]=l,t[34]=D,t[35]=g,t[36]=O):O=t[36],O};function ms(e){let t=e.icon;return(0,$.jsxs)(tr,{onClick:t=>{t.stopPropagation(),e.onClick()},className:K(e.destructive&&`text-destructive focus:text-destructive`),children:[t&&(0,$.jsx)(X,{name:t,className:`h-4 w-4 mr-px`}),e.label]},e.label)}var hs=e=>{let t=(0,Sa.c)(8),{header:n,footer:r,children:i,className:a,variant:o}=e,s=o===void 0?`sidebar`:o,c=g(),l=s===`background`||c?`bg-background`:`bg-sidebar`,u;t[0]!==l||t[1]!==a?(u=K(`yuri-settings-sidebar yuri-settings-page-content h-full overflow-y-auto p-3`,l,a),t[0]=l,t[1]=a,t[2]=u):u=t[2];let d;return t[3]!==i||t[4]!==r||t[5]!==n||t[6]!==u?(d=(0,$.jsxs)(`div`,{className:u,children:[n,i,r]}),t[3]=i,t[4]=r,t[5]=n,t[6]=u,t[7]=d):d=t[7],d},gs=[{id:`wechat`,nameKey:`assistants.weixin.title`,summaryKey:`assistants.channels.wechat.summary`,logo:`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2033%2027'%20role='img'%20aria-label='WeChat'%3e%3cpath%20d='M7.98557%2019.5685C9.15835%2019.9072%2010.4238%2020.0965%2011.7342%2020.0965C18.0746%2020.0965%2023.2158%2015.7818%2023.2158%2010.4592C23.2158%205.1365%2018.0746%200.821838%2011.7316%200.821838C5.38852%200.821838%200.25%205.1365%200.25%2010.4592C0.25%2013.3632%201.79606%2015.9765%204.21838%2017.7445C4.41164%2017.8832%204.53872%2018.1125%204.53872%2018.3738C4.53872%2018.4592%204.52018%2018.5392%204.499%2018.6192C4.30575%2019.3445%203.99601%2020.5098%203.98277%2020.5632C3.95894%2020.6538%203.92188%2020.7498%203.92188%2020.8458C3.92188%2021.0592%204.09396%2021.2325%204.30575%2021.2325C4.39046%2021.2325%204.45665%2021.2005%204.52813%2021.1605L7.04311%2019.6992C7.23107%2019.5898%207.43227%2019.5205%207.652%2019.5205C7.76849%2019.5205%207.88232%2019.5392%207.99087%2019.5712L7.98557%2019.5685Z'%20fill='url(%23paint0_linear_2149_1261)'/%3e%3cpath%20d='M17.0935%207.37416C17.0935%208.22483%2016.4079%208.91549%2015.5634%208.91549C14.7189%208.91549%2014.0332%208.22483%2014.0332%207.37416C14.0332%206.52349%2014.7189%205.83282%2015.5634%205.83282C16.4079%205.83282%2017.0935%206.52349%2017.0935%207.37416Z'%20fill='%23168743'/%3e%3cpath%20d='M9.43534%207.3741C9.43534%208.22476%208.74968%208.91543%207.90517%208.91543C7.06067%208.91543%206.375%208.22476%206.375%207.3741C6.375%206.52343%207.06067%205.83276%207.90517%205.83276C8.74968%205.83276%209.43534%206.52343%209.43534%207.3741Z'%20fill='%23168743'/%3e%3cpath%20d='M25.573%2025.6191C24.5961%2025.9017%2023.5425%2026.0591%2022.4491%2026.0591C17.165%2026.0591%2012.8789%2022.4617%2012.8789%2018.0271C12.8789%2013.5924%2017.1623%209.99506%2022.4491%209.99506C27.7359%209.99506%2032.0166%2013.5924%2032.0166%2018.0271C32.0166%2020.4484%2030.7274%2022.6271%2028.7101%2024.0991C28.5486%2024.2164%2028.4427%2024.4057%2028.4427%2024.6217C28.4427%2024.6937%2028.4586%2024.7577%2028.4771%2024.8271C28.6386%2025.4324%2028.8954%2026.4004%2028.9086%2026.4457C28.9298%2026.5231%2028.9589%2026.6004%2028.9589%2026.6804C28.9589%2026.8591%2028.816%2027.0031%2028.6386%2027.0031C28.5698%2027.0031%2028.5142%2026.9764%2028.4533%2026.9417L26.3592%2025.7231C26.2004%2025.6324%2026.0336%2025.5737%2025.8509%2025.5737C25.753%2025.5737%2025.6577%2025.5897%2025.5703%2025.6164L25.573%2025.6191Z'%20fill='url(%23paint1_linear_2149_1261)'/%3e%3cpath%20d='M17.9844%2015.4569C17.9844%2016.1662%2018.5562%2016.7422%2019.2604%2016.7422C19.9646%2016.7422%2020.5364%2016.1662%2020.5364%2015.4569C20.5364%2014.7476%2019.9646%2014.1716%2019.2604%2014.1716C18.5562%2014.1716%2017.9844%2014.7476%2017.9844%2015.4569Z'%20fill='%23919191'/%3e%3cpath%20d='M24.3633%2015.457C24.3633%2016.1663%2024.9351%2016.7423%2025.6393%2016.7423C26.3435%2016.7423%2026.9153%2016.1663%2026.9153%2015.457C26.9153%2014.7476%2026.3435%2014.1716%2025.6393%2014.1716C24.9351%2014.1716%2024.3633%2014.7476%2024.3633%2015.457Z'%20fill='%23919191'/%3e%3cdefs%3e%3clinearGradient%20id='paint0_linear_2149_1261'%20x1='11.7316'%20y1='21.2298'%20x2='11.7316'%20y2='0.821838'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20offset='0.06'%20stop-color='%2305CD66'/%3e%3cstop%20offset='0.22'%20stop-color='%230DD068'/%3e%3cstop%20offset='0.48'%20stop-color='%2326DA6F'/%3e%3cstop%20offset='0.81'%20stop-color='%234DEB7A'/%3e%3cstop%20offset='0.95'%20stop-color='%2361F380'/%3e%3c/linearGradient%3e%3clinearGradient%20id='paint1_linear_2149_1261'%20x1='22.4517'%20y1='27.0031'%20x2='22.4517'%20y2='9.99506'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20offset='0.08'%20stop-color='%23D9D9D9'/%3e%3cstop%20offset='1'%20stop-color='%23F0F0F0'/%3e%3c/linearGradient%3e%3c/defs%3e%3c/svg%3e`},{id:`wecom`,nameKey:`assistants.channels.wecom.title`,summaryKey:`assistants.channels.wecom.summary`,logo:`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2031%2026'%20role='img'%20aria-label='WeCom'%3e%3cg%20fill='none'%20fill-rule='evenodd'%3e%3cpath%20fill='%230082F0'%20d='M24.27%206.9a10.746%2010.746%200%2000-1.945-2.764C20.295%202.034%2017.453.68%2014.322.323a14.773%2014.773%200%2000-1.656-.096c-.511%200-1.044.03-1.585.089-3.144.342-6.002%201.69-8.047%203.792a10.757%2010.757%200%2000-1.955%202.757%209.634%209.634%200%2000-1.003%204.277c0%201.909.58%203.79%201.678%205.442a14.96%2014.96%200%20002.302%202.634v.002l-.378%202.974c-.015.04-.031.08-.04.123-.01.039-.012.079-.016.119-.002.03-.01.06-.01.091%200%20.033.008.065.01.098.05.489.458.872.96.872.175%200%20.337-.05.478-.131l.014-.008c.02-.012.042-.023.062-.036l.903-.454%202.69-1.352a13.93%2013.93%200%20002.35.453%2014.54%2014.54%200%20003.243-.009%2014.092%2014.092%200%20003.173-.742%201.752%201.752%200%2001-1.192-1.832c-.72.23-1.472.393-2.25.482a12.172%2012.172%200%2001-2.716.008c-.09-.01-.182-.025-.274-.037a11.976%2011.976%200%2001-1.78-.373%201.217%201.217%200%2000-.37-.057c-.2%200-.392.053-.588.154-.026.014-.05.025-.076.04l-2.21%201.303-.096.057-.003.001c-.047.028-.075.039-.1.039a.15.15%200%2001-.146-.153l.085-.345.098-.375.162-.614.179-.686a.93.93%200%2000-.334-1.033%209.906%209.906%200%2001-.923-.777c-.5-.475-.94-.994-1.31-1.55-.869-1.308-1.328-2.792-1.328-4.293%200-1.164.266-2.297.79-3.366a8.633%208.633%200%20011.569-2.21c1.68-1.728%204.045-2.837%206.656-3.12.454-.05.901-.075%201.328-.075.449%200%20.916.027%201.388.08%202.599.296%204.949%201.41%206.617%203.138a8.618%208.618%200%20011.56%202.215%207.584%207.584%200%2001.778%203.338c0%20.12-.007.24-.013.36a1.746%201.746%200%20012.149.251c.03.03.054.062.08.093a9.11%209.11%200%2000.031-.739%209.634%209.634%200%2000-.986-4.243'/%3e%3cpath%20fill='%23FB6500'%20d='M24.149%2022.148a1.7%201.7%200%2000-.21-.035%205.377%205.377%200%2001-2.996-1.67v.001a.418.418%200%2010-.534.64c.041.04.082.078.121.118a5.39%205.39%200%20011.478%202.761%201.715%201.715%200%2000.059.356%201.749%201.749%200%20002.926.777%201.754%201.754%200%2000-.844-2.948'/%3e%3cpath%20fill='%230082F0'%20d='M29.944%2017.673a1.75%201.75%200%2000-2.98%201.056%205.388%205.388%200%2001-1.667%202.999.419.419%200%2010.641.534l.117-.121a5.376%205.376%200%20012.758-1.48%201.71%201.71%200%2000.355-.058%201.754%201.754%200%2000.776-2.93'/%3e%3cpath%20fill='%232DBC00'%20d='M22.53%2012.717a1.754%201.754%200%20001.054%202.982%205.376%205.376%200%20012.996%201.67.419.419%200%2010.534-.641%205.389%205.389%200%2001-1.6-2.879%201.625%201.625%200%2000-.058-.355%201.75%201.75%200%2000-2.926-.777'/%3e%3cpath%20fill='%23FC0'%20d='M20.543%2019.19a1.93%201.93%200%2000.015-.106%205.393%205.393%200%20011.668-3%20.42.42%200%2010-.64-.534%205.375%205.375%200%2001-2.876%201.6%201.73%201.73%200%2000-.355.06%201.754%201.754%200%2000-.776%202.93%201.75%201.75%200%20002.964-.95'/%3e%3c/g%3e%3c/svg%3e`},{id:`feishu`,nameKey:`assistants.channels.feishu.title`,summaryKey:`assistants.channels.feishu.summary`,logo:`/assets/feishu-Ct1ZxlzQ.svg`},{id:`dingtalk`,nameKey:`assistants.channels.dingtalk.title`,summaryKey:`assistants.channels.dingtalk.summary`,logo:`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2032%2032'%20role='img'%20aria-label='DingTalk'%3e%3cg%20transform='translate(6%201)'%20fill='none'%20fill-rule='evenodd'%3e%3cpath%20d='M18.975%2014.517C13.963%2010.704%208.313%205.654%202.118.24%201.63-.187%201.197-.02.98.548-.416%204.18.936%207.405%203.123%209.265c2.195%201.867%205.459%203.586%207.458%204.498.078.035.01.148-.069.114C6.84%2012.283%204.285%2011.132.82%208.5c-.373-.284-.75-.174-.796.38-.283%203.472%201.972%206.198%204.489%207.12%201.557.571%203.261.887%204.842%201.075.082.01.064.13-.02.13-2.036.007-4.497-.474-6.626-1.28-.45-.17-.605.183-.535.463.363%201.467%202.205%203.71%205.136%204.18.548.089%201.133.1%201.653.085.124-.003.154.064.114.158%200%200-1.992%203.362-2.079%203.505-.068.112-.026.202.115.202h2.628c.121%200%20.196.077.134.179-.062.101-3.509%205.733-3.672%206.002-.142.234.026.413.292.22l11.597-8.365c.144-.104.11-.245-.093-.245h-2.357c-.153%200-.188-.101-.083-.205.105-.103%202.675-2.627%203.587-3.57.952-.986%201.438-2.792-.171-4.016'%20fill='%23007FFF'/%3e%3c/g%3e%3c/svg%3e`}],_s=[`disabled`,`disconnected`,`connecting`,`connected`,`reconnecting`,`error`],vs=e=>!!e&&typeof e==`object`&&!Array.isArray(e),ys=(e,t)=>{if(e!==void 0){if(typeof e!=`string`||e.length>t)throw Error(`invalid_response`);return e}};function bs(e,t){if(!vs(e)||e.provider!==t||!_s.some(t=>t===e.status)||e.error!==null&&typeof e.error!=`string`||typeof e.configured!=`boolean`||typeof e.hasSecret!=`boolean`||e.transport!==`websocket`)throw Error(`invalid_response`);let n=ys(e.clientID,512),r=ys(e.ownerID,512),i;if(e.transferSources!==void 0){if(!Array.isArray(e.transferSources))throw Error(`invalid_response`);i=e.transferSources.map(e=>{if(!vs(e))throw Error(`invalid_response`);let t=ys(e.assistantID,512),n=ys(e.name,8192),r=ys(e.revision,512),i=ys(e.clientID,512);if(!t||n===void 0||!r||!i)throw Error(`invalid_response`);return{assistantID:t,name:n,revision:r,clientID:i}})}return{provider:t,status:e.status,error:typeof e.error==`string`?e.error:null,configured:e.configured,...n===void 0?{}:{clientID:n},...r===void 0?{}:{ownerID:r},hasSecret:e.hasSecret,transport:`websocket`,...i?{transferSources:i}:{}}}var xs=e=>({provider:e,status:`unsupported`,error:null,configured:!1,hasSecret:!1,transport:`websocket`}),Ss=e=>e&&typeof e==`object`&&`error`in e&&typeof e.error==`string`?e.error:`channel_error`,Cs=async(e,t,n=``,r={})=>{let i=await l(`/api/yuri/assistants/${encodeURIComponent(e)}/channels/${t}${n}`,r);if(i.status===501||i.status===404&&!n)return xs(t);if(i.status===204)return null;let a=await i.json();if(!i.ok)throw Error(Ss(a));return bs(a,t)},ws=(e,t,n=i())=>[n,`assistants`,`channels`,e,t],Ts=(e,t,n=i())=>({queryKey:ws(e,t,n),queryFn:async({signal:n})=>{let r=await Cs(e,t,``,{signal:n});if(!r)throw Error(`invalid_response`);return r},staleTime:0,gcTime:0,retry:1,refetchOnWindowFocus:!0,refetchIntervalInBackground:!1,refetchInterval:e=>{let t=e.state.data?.status;return t===`connecting`?2e3:t===`connected`||t===`reconnecting`?15e3:!1}});function Es(e,t){let n=(0,Sa.c)(23),r=i(),a;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=o(),n[0]=a):a=n[0];let s=a,c=De(Ts(e,t,r)),u=()=>{if(r!==i()||s!==o())throw Error(`runtime_stale`)},d;n[1]!==u||n[2]!==e||n[3]!==t?(d=async n=>{let{signal:r,...i}=n;u();let a=await l(`/api/yuri/assistants/${encodeURIComponent(e)}/channels/${t}/discover`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(i),signal:r}),o=await a.json();if(u(),r.aborted)throw Error(`cancelled`);if(!a.ok)throw Error(Ss(o));if(!vs(o)||typeof o.ownerID!=`string`||!o.ownerID.trim()||o.ownerID.length>512)throw Error(`invalid_response`);return{ownerID:o.ownerID}},n[1]=u,n[2]=e,n[3]=t,n[4]=d):d=n[4];let f=Te({mutationKey:[...ws(e,t,r),`discover`],gcTime:0,mutationFn:d}),p;n[5]!==u||n[6]!==e||n[7]!==t||n[8]!==r?(p=async n=>{await Oe.cancelQueries({queryKey:ws(e,t,r)}),n.type===`transfer`&&await Oe.cancelQueries({queryKey:ws(n.sourceAssistantID,t,r)}),u();let i=await Cs(e,t,n.type===`retry`?`/retry`:n.type===`transfer`?`/transfer`:``,n.type===`transfer`?{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sourceAssistantID:n.sourceAssistantID,revision:n.revision})}:n.type===`save`?{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({clientID:n.clientID,ownerID:n.ownerID,...n.clientSecret?{clientSecret:n.clientSecret}:{},language:Ye.getState().locale})}:{method:n.type===`disconnect`?`DELETE`:`POST`});return u(),i},n[5]=u,n[6]=e,n[7]=t,n[8]=r,n[9]=p):p=n[9];let m;n[10]!==e||n[11]!==t||n[12]!==r?(m=n=>{n&&Oe.setQueryData(ws(e,t,r),n)},n[10]=e,n[11]=t,n[12]=r,n[13]=m):m=n[13];let h;n[14]!==e||n[15]!==s||n[16]!==t||n[17]!==r?(h=(n,a,c)=>{r===i()&&s===o()&&(Oe.invalidateQueries({queryKey:ws(e,t,r)}),c.type===`transfer`&&Oe.invalidateQueries({queryKey:ws(c.sourceAssistantID,t,r)}))},n[14]=e,n[15]=s,n[16]=t,n[17]=r,n[18]=h):h=n[18];let g=Te({mutationKey:[...ws(e,t,r),`change`],gcTime:0,mutationFn:p,onSuccess:m,onSettled:h}),_;return n[19]!==f||n[20]!==g||n[21]!==c?(_={query:c,mutation:g,discovery:f},n[19]=f,n[20]=g,n[21]=c,n[22]=_):_=n[22],_}var Ds={wecom:{clientID:`assistants.channels.field.wecom.clientID`,secret:`assistants.channels.field.wecom.secret`,ownerID:`assistants.channels.field.wecom.ownerID`,ownerHelp:`assistants.channels.field.wecom.ownerHelp`,ownerHelpUrl:`https://github.com/WecomTeam/aibot-node-sdk#basemessage消息体基础结构`},feishu:{clientID:`assistants.channels.field.feishu.clientID`,secret:`assistants.channels.field.feishu.secret`,ownerID:`assistants.channels.field.feishu.ownerID`,ownerHelp:`assistants.channels.field.feishu.ownerHelp`,ownerHelpUrl:`https://open.feishu.cn/document/server-docs/contact-v3/user/batch_get_id`},dingtalk:{clientID:`assistants.channels.field.dingtalk.clientID`,secret:`assistants.channels.field.dingtalk.secret`,ownerID:`assistants.channels.field.dingtalk.ownerID`,ownerHelp:`assistants.channels.field.dingtalk.ownerHelp`,ownerHelpUrl:`https://open.dingtalk.com/document/dingstart/robot-receive-message`}},Os=e=>e===`invalid_credentials`||e===`auth_failed`||e===`unauthorized`?`assistants.channels.error.invalidCredentials`:e===`auth_expired`?`assistants.channels.error.authExpired`:e===`channel_in_use`?`assistants.channels.error.channelInUse`:e===`owner_required`||e===`invalid_owner`?`assistants.channels.error.ownerRequired`:e===`delivery_unknown`?`assistants.channels.error.deliveryUnknown`:e===`connection_replaced`?`assistants.channels.error.connectionReplaced`:e===`account_in_use`||e===`already_bound`?`assistants.channels.error.accountInUse`:e===`binding_changed`?`assistants.weixin.error.bindingChanged`:e===`discovery_timeout`?`assistants.channels.discovery.timeout`:`assistants.channels.error.generic`;function ks(e){let t=(0,Sa.c)(252),{assistantID:n,provider:i,onClose:a}=e,{t:s}=Ge(),{query:c,mutation:l,discovery:u}=Es(n,i),d=c.data,[f,p]=Q.useState(``),[m,h]=Q.useState(``),[g,_]=Q.useState(``),v=Q.useRef(!1),y=Q.useRef(null),[b,x]=Q.useState(!1),[S,C]=Q.useState(null),w=Ds[i],T=l.isPending,E=Q.useSyncExternalStore(r,o,o),D;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(D=()=>{y.current?.abort(),h(``),_(``),x(!1),C(null)},t[0]=D):D=t[0];let O;t[1]===E?O=t[2]:(O=[E],t[1]=E,t[2]=O),Q.useEffect(D,O);let k,A;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(k=()=>()=>{y.current?.abort()},A=[],t[3]=k,t[4]=A):(k=t[3],A=t[4]),Q.useEffect(k,A);let j,M;t[5]===d?(j=t[6],M=t[7]):(j=()=>{!d||v.current||(v.current=!0,p(d.clientID??``),_(d.ownerID??``))},M=[d],t[5]=d,t[6]=j,t[7]=M),Q.useEffect(j,M);let N;t[8]!==f||t[9]!==m||t[10]!==u.isPending||t[11]!==l||t[12]!==a||t[13]!==g||t[14]!==T||t[15]!==d||t[16]!==s?(N=e=>{if(e.preventDefault(),!d||T)return;let t=f.trim(),n=g.trim();!t||!n||u.isPending||(!d.hasSecret||t!==d.clientID)&&!m.trim()||l.mutate({type:`save`,clientID:t,ownerID:n,...m?{clientSecret:m}:{}},{onSuccess:e=>{e?.configured&&(h(``),Y.success(s(`assistants.channels.saved`)),a())}})},t[8]=f,t[9]=m,t[10]=u.isPending,t[11]=l,t[12]=a,t[13]=g,t[14]=T,t[15]=d,t[16]=s,t[17]=N):N=t[17];let P=N,F;t[18]!==f||t[19]!==m||t[20]!==u?(F=()=>{y.current?.abort();let e=new AbortController;y.current=e,u.mutate({clientID:f.trim(),...m?{clientSecret:m}:{},signal:e.signal},{onSuccess:t=>{e.signal.aborted||y.current!==e||_(t.ownerID)}})},t[18]=f,t[19]=m,t[20]=u,t[21]=F):F=t[21];let I=F,L;t[22]===u?L=t[23]:(L=()=>{y.current?.abort(),y.current=null,u.reset()},t[22]=u,t[23]=L);let R=L,z;t[24]===l?z=t[25]:(z=()=>l.mutate({type:`retry`}),t[24]=l,t[25]=z);let B=z,V;t[26]===l?V=t[27]:(V=()=>{l.mutate({type:`disconnect`},{onSuccess:()=>x(!1)})},t[26]=l,t[27]=V);let H=V;if(c.isPending){let e;t[28]===s?e=t[29]:(e=s(`common.loading`),t[28]=s,t[29]=e);let n;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin motion-reduce:animate-none`}),t[30]=n):n=t[30];let r;return t[31]===e?r=t[32]:(r=(0,$.jsx)(Z,{children:(0,$.jsx)(Xi,{label:e,children:n})}),t[31]=e,t[32]=r),r}if(c.isError&&!d){let e;t[33]===s?e=t[34]:(e=s(`assistants.channels.attention`),t[33]=s,t[34]=e);let n;t[35]===s?n=t[36]:(n=s(`assistants.channels.error.generic`),t[35]=s,t[36]=n);let r;t[37]===c?r=t[38]:(r=()=>{c.refetch()},t[37]=c,t[38]=r);let i;t[39]===s?i=t[40]:(i=s(`assistants.actions.retry`),t[39]=s,t[40]=i);let a;t[41]!==r||t[42]!==i?(a=(0,$.jsx)(q,{size:`sm`,onClick:r,children:i}),t[41]=r,t[42]=i,t[43]=a):a=t[43];let o;return t[44]!==e||t[45]!==n||t[46]!==a?(o=(0,$.jsx)(Z,{children:(0,$.jsx)(Xi,{label:e,description:n,children:a})}),t[44]=e,t[45]=n,t[46]=a,t[47]=o):o=t[47],o}if(!d||d.status===`unsupported`||d.status===`disabled`){let e=`assistants.channels.status.${d?.status??`unsupported`}`,n;t[48]!==s||t[49]!==e?(n=s(e),t[48]=s,t[49]=e,t[50]=n):n=t[50];let r;return t[51]===n?r=t[52]:(r=(0,$.jsx)(Z,{children:(0,$.jsx)(Xi,{description:n,children:null})}),t[51]=n,t[52]=r),r}let U;t[53]!==f||t[54]!==d.clientID||t[55]!==d.hasSecret?(U=!d.hasSecret||f.trim()!==(d.clientID??``),t[53]=f,t[54]=d.clientID,t[55]=d.hasSecret,t[56]=U):U=t[56];let W=U,ee;t[57]===f?ee=t[58]:(ee=f.trim(),t[57]=f,t[58]=ee);let te=ee,ne;t[59]!==m||t[60]!==W||t[61]!==te||t[62]!==T?(ne=!!(te&&(!W||m.trim()))&&!T,t[59]=m,t[60]=W,t[61]=te,t[62]=T,t[63]=ne):ne=t[63];let re=ne,ie;t[64]!==re||t[65]!==u.isPending||t[66]!==g?(ie=re&&!!g.trim()&&!u.isPending,t[64]=re,t[65]=u.isPending,t[66]=g,t[67]=ie):ie=t[67];let ae=ie,oe=d.configured,se,ce,le,ue,de,G,fe,pe,me;if(t[68]!==n||t[69]!==re||t[70]!==R||t[71]!==f||t[72]!==m||t[73]!==oe||t[74]!==I||t[75]!==u.error?.message||t[76]!==u.error?.name||t[77]!==u.isPending||t[78]!==w.clientID||t[79]!==w.ownerHelp||t[80]!==w.ownerHelpUrl||t[81]!==w.ownerID||t[82]!==w.secret||t[83]!==l||t[84]!==W||t[85]!==te||t[86]!==g||t[87]!==T||t[88]!==i||t[89]!==c.isError||t[90]!==P||t[91]!==d.error||t[92]!==d.status||t[93]!==d.transferSources||t[94]!==s||t[95]!==S){let e=oe?[]:(d.transferSources??[]).filter(e=>!te||e.clientID===te);le=oe&&d.status!==`connecting`;let r=(u.error?.name!==`AbortError`&&u.error?.message!==`cancelled`?u.error?.message:void 0)||l.error?.message||d.error,a=r?Os(r):c.isError?`assistants.channels.error.generic`:null;fe=`yuri-settings-section-stack yuri-settings-channel-form`,pe=P;let o;t[105]!==w.clientID||t[106]!==s?(o=s(w.clientID),t[105]=w.clientID,t[106]=s,t[107]=o):o=t[107];let v;t[108]===R?v=t[109]:(v=e=>{R(),p(e.target.value),_(``)},t[108]=R,t[109]=v);let y;t[110]!==w.clientID||t[111]!==s?(y=s(w.clientID),t[110]=w.clientID,t[111]=s,t[112]=y):y=t[112];let b;t[113]!==f||t[114]!==v||t[115]!==y?(b=(0,$.jsx)(Cn,{value:f,onChange:v,"aria-label":y,autoComplete:`off`,maxLength:512,required:!0}),t[113]=f,t[114]=v,t[115]=y,t[116]=b):b=t[116];let x;t[117]!==o||t[118]!==b?(x=(0,$.jsx)(Xi,{label:o,className:`yuri-settings-split-row-stacked`,children:b}),t[117]=o,t[118]=b,t[119]=x):x=t[119];let E;t[120]!==w.secret||t[121]!==s?(E=s(w.secret),t[120]=w.secret,t[121]=s,t[122]=E):E=t[122];let D=W?`assistants.channels.field.secretRequired`:`assistants.channels.field.secretKeep`,O;t[123]!==s||t[124]!==D?(O=s(D),t[123]=s,t[124]=D,t[125]=O):O=t[125];let k;t[126]===R?k=t[127]:(k=e=>{R(),h(e.target.value)},t[126]=R,t[127]=k);let A;t[128]!==w.secret||t[129]!==s?(A=s(w.secret),t[128]=w.secret,t[129]=s,t[130]=A):A=t[130];let j;t[131]!==m||t[132]!==W||t[133]!==k||t[134]!==A?(j=(0,$.jsx)(Cn,{type:`password`,value:m,onChange:k,"aria-label":A,autoComplete:`new-password`,maxLength:4096,required:W}),t[131]=m,t[132]=W,t[133]=k,t[134]=A,t[135]=j):j=t[135];let M;t[136]!==E||t[137]!==O||t[138]!==j?(M=(0,$.jsx)(Xi,{label:E,description:O,className:`yuri-settings-split-row-stacked`,children:j}),t[136]=E,t[137]=O,t[138]=j,t[139]=M):M=t[139];let N;t[140]!==w.ownerID||t[141]!==s?(N=s(w.ownerID),t[140]=w.ownerID,t[141]=s,t[142]=N):N=t[142];let F=`${n}-${i}-owner-help`,L;t[143]===s?L=t[144]:(L=s(`assistants.channels.field.ownerDescription`),t[143]=s,t[144]=L);let z;t[145]!==w.ownerHelp||t[146]!==s?(z=s(w.ownerHelp),t[145]=w.ownerHelp,t[146]=s,t[147]=z):z=t[147];let B=w.ownerHelpUrl,V;t[148]===w.ownerHelpUrl?V=t[149]:(V=e=>{e.preventDefault(),Br(w.ownerHelpUrl)},t[148]=w.ownerHelpUrl,t[149]=V);let H;t[150]===s?H=t[151]:(H=s(`assistants.channels.field.ownerHelpLink`),t[150]=s,t[151]=H);let U;t[152]!==w.ownerHelpUrl||t[153]!==V||t[154]!==H?(U=(0,$.jsx)(`a`,{href:B,target:`_blank`,rel:`noopener noreferrer`,className:`underline underline-offset-2`,onClick:V,children:H}),t[152]=w.ownerHelpUrl,t[153]=V,t[154]=H,t[155]=U):U=t[155];let ee;t[156]!==z||t[157]!==U?(ee=(0,$.jsxs)(`span`,{className:`block`,children:[z,` `,U]}),t[156]=z,t[157]=U,t[158]=ee):ee=t[158];let ne;t[159]!==F||t[160]!==L||t[161]!==ee?(ne=(0,$.jsxs)(`span`,{id:F,children:[L,ee]}),t[159]=F,t[160]=L,t[161]=ee,t[162]=ne):ne=t[162];let ie;t[163]===R?ie=t[164]:(ie=e=>{R(),_(e.target.value)},t[163]=R,t[164]=ie);let ae;t[165]!==w.ownerID||t[166]!==s?(ae=s(w.ownerID),t[165]=w.ownerID,t[166]=s,t[167]=ae):ae=t[167];let he=`${n}-${i}-owner-help`,ge;t[168]!==g||t[169]!==ie||t[170]!==ae||t[171]!==he?(ge=(0,$.jsx)(Cn,{value:g,onChange:ie,"aria-label":ae,"aria-describedby":he,autoComplete:`off`,maxLength:512,required:!0}),t[168]=g,t[169]=ie,t[170]=ae,t[171]=he,t[172]=ge):ge=t[172];let _e;t[173]!==N||t[174]!==ne||t[175]!==ge?(_e=(0,$.jsx)(Xi,{label:N,description:ne,className:`yuri-settings-split-row-stacked`,children:ge}),t[173]=N,t[174]=ne,t[175]=ge,t[176]=_e):_e=t[176];let ve;t[177]!==re||t[178]!==R||t[179]!==I||t[180]!==u.isPending||t[181]!==g||t[182]!==s?(ve=g.trim()?null:(0,$.jsxs)(Xi,{className:`yuri-settings-split-row-stacked`,description:s(u.isPending?`assistants.channels.discovery.waiting`:`assistants.channels.discovery.hint`),children:[(0,$.jsxs)(q,{size:`sm`,disabled:!re||u.isPending,"aria-busy":u.isPending,onClick:I,children:[u.isPending?(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin motion-reduce:animate-none`}):null,s(`assistants.channels.discovery.start`)]}),u.isPending?(0,$.jsx)(q,{size:`sm`,variant:`ghost`,onClick:R,children:s(`settings.common.actions.cancel`)}):null]}),t[177]=re,t[178]=R,t[179]=I,t[180]=u.isPending,t[181]=g,t[182]=s,t[183]=ve):ve=t[183],t[184]!==x||t[185]!==M||t[186]!==_e||t[187]!==ve?(me=(0,$.jsxs)(Z,{children:[x,M,_e,ve]}),t[184]=x,t[185]=M,t[186]=_e,t[187]=ve,t[188]=me):me=t[188],ce=Z;let ye;t[189]!==u.isPending||t[190]!==l||t[191]!==T||t[192]!==s||t[193]!==S?(ye=e=>(0,$.jsx)(Xi,{className:`yuri-settings-split-row-stacked`,label:s(`assistants.weixin.transferFrom`,{name:e.name}),description:S?.assistantID===e.assistantID?s(`assistants.weixin.transferWarning`):void 0,children:S?.assistantID===e.assistantID?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(q,{size:`sm`,variant:`ghost`,disabled:T,onClick:()=>C(null),children:s(`settings.common.actions.cancel`)}),(0,$.jsx)(q,{size:`sm`,disabled:T||u.isPending||S.revision!==e.revision,"aria-busy":T,onClick:()=>{l.mutate({type:`transfer`,sourceAssistantID:S.assistantID,revision:S.revision},{onSuccess:e=>{C(null),h(``),e&&(p(e.clientID??``),_(e.ownerID??``))}})},children:s(`assistants.weixin.transferConfirm`)})]}):(0,$.jsx)(q,{size:`sm`,disabled:T,onClick:()=>C({...e}),children:s(`assistants.weixin.transfer`)})},e.assistantID),t[189]=u.isPending,t[190]=l,t[191]=T,t[192]=s,t[193]=S,t[194]=ye):ye=t[194],G=e.map(ye),se=Xi;let be=`assistants.channels.status.${d.status}`;t[195]!==s||t[196]!==be?(ue=s(be),t[195]=s,t[196]=be,t[197]=ue):ue=t[197],de=a&&!(e.length&&a===`assistants.channels.error.accountInUse`)?s(a):void 0,t[68]=n,t[69]=re,t[70]=R,t[71]=f,t[72]=m,t[73]=oe,t[74]=I,t[75]=u.error?.message,t[76]=u.error?.name,t[77]=u.isPending,t[78]=w.clientID,t[79]=w.ownerHelp,t[80]=w.ownerHelpUrl,t[81]=w.ownerID,t[82]=w.secret,t[83]=l,t[84]=W,t[85]=te,t[86]=g,t[87]=T,t[88]=i,t[89]=c.isError,t[90]=P,t[91]=d.error,t[92]=d.status,t[93]=d.transferSources,t[94]=s,t[95]=S,t[96]=se,t[97]=ce,t[98]=le,t[99]=ue,t[100]=de,t[101]=G,t[102]=fe,t[103]=pe,t[104]=me}else se=t[96],ce=t[97],le=t[98],ue=t[99],de=t[100],G=t[101],fe=t[102],pe=t[103],me=t[104];let he;t[198]!==le||t[199]!==u.isPending||t[200]!==T||t[201]!==B||t[202]!==s?(he=le?(0,$.jsx)(q,{size:`sm`,variant:`ghost`,disabled:T||u.isPending,onClick:B,children:s(`assistants.channels.actions.retry`)}):null,t[198]=le,t[199]=u.isPending,t[200]=T,t[201]=B,t[202]=s,t[203]=he):he=t[203];let ge;t[204]!==oe||t[205]!==b||t[206]!==u.isPending||t[207]!==T||t[208]!==s?(ge=oe&&!b?(0,$.jsx)(q,{size:`sm`,variant:`ghost`,disabled:T||u.isPending,onClick:()=>x(!0),children:s(`assistants.channels.actions.disconnect`)}):null,t[204]=oe,t[205]=b,t[206]=u.isPending,t[207]=T,t[208]=s,t[209]=ge):ge=t[209];let _e;t[210]!==se||t[211]!==ue||t[212]!==de||t[213]!==he||t[214]!==ge?(_e=(0,$.jsxs)(se,{label:ue,description:de,className:`yuri-settings-split-row-stacked`,children:[he,ge]}),t[210]=se,t[211]=ue,t[212]=de,t[213]=he,t[214]=ge,t[215]=_e):_e=t[215];let ve;t[216]!==oe||t[217]!==b||t[218]!==H||t[219]!==u.isPending||t[220]!==T||t[221]!==s?(ve=oe&&b?(0,$.jsxs)(Xi,{className:`yuri-settings-split-row-stacked`,description:s(`assistants.channels.disconnectWarning`),children:[(0,$.jsx)(q,{size:`sm`,variant:`ghost`,disabled:T,onClick:()=>x(!1),children:s(`settings.common.actions.cancel`)}),(0,$.jsx)(q,{size:`sm`,variant:`destructive`,disabled:T||u.isPending,onClick:H,"aria-busy":T,children:s(`assistants.channels.actions.confirmDisconnect`)})]}):null,t[216]=oe,t[217]=b,t[218]=H,t[219]=u.isPending,t[220]=T,t[221]=s,t[222]=ve):ve=t[222];let ye;t[223]!==ce||t[224]!==G||t[225]!==_e||t[226]!==ve?(ye=(0,$.jsxs)(ce,{children:[G,_e,ve]}),t[223]=ce,t[224]=G,t[225]=_e,t[226]=ve,t[227]=ye):ye=t[227];let be;t[228]===s?be=t[229]:(be=s(`settings.common.actions.cancel`),t[228]=s,t[229]=be);let xe;t[230]!==a||t[231]!==T||t[232]!==be?(xe=(0,$.jsx)(q,{type:`button`,size:`sm`,variant:`ghost`,disabled:T,onClick:a,children:be}),t[230]=a,t[231]=T,t[232]=be,t[233]=xe):xe=t[233];let Se=!ae,Ce;t[234]===T?Ce=t[235]:(Ce=T?(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin motion-reduce:animate-none`}):null,t[234]=T,t[235]=Ce);let we;t[236]===s?we=t[237]:(we=s(`assistants.channels.actions.save`),t[236]=s,t[237]=we);let Te;t[238]!==T||t[239]!==Se||t[240]!==Ce||t[241]!==we?(Te=(0,$.jsxs)(q,{type:`submit`,size:`sm`,disabled:Se,"aria-busy":T,children:[Ce,we]}),t[238]=T,t[239]=Se,t[240]=Ce,t[241]=we,t[242]=Te):Te=t[242];let Ee;t[243]!==xe||t[244]!==Te?(Ee=(0,$.jsxs)(`div`,{className:`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end`,children:[xe,Te]}),t[243]=xe,t[244]=Te,t[245]=Ee):Ee=t[245];let De;return t[246]!==fe||t[247]!==pe||t[248]!==me||t[249]!==ye||t[250]!==Ee?(De=(0,$.jsxs)(`form`,{className:fe,onSubmit:pe,children:[me,ye,Ee]}),t[246]=fe,t[247]=pe,t[248]=me,t[249]=ye,t[250]=Ee,t[251]=De):De=t[251],De}var As=t(la(),1),js=[`disconnected`,`waiting`,`scanned`,`verify`,`connected`,`reconnecting`,`expired`,`error`,`unsupported`,`disabled`];function Ms(e){if(!e||typeof e!=`object`||!(`status`in e)||!js.some(t=>t===e.status))throw Error(`invalid_response`);let t=e,n;if(t.transferSources!==void 0){if(!Array.isArray(t.transferSources)||t.transferSources.length>100)throw Error(`invalid_response`);n=t.transferSources.map(e=>{if(!e||typeof e!=`object`||!(`assistantID`in e)||!(`name`in e)||!(`revision`in e)||typeof e.assistantID!=`string`||!e.assistantID||typeof e.name!=`string`||typeof e.revision!=`string`||!e.revision)throw Error(`invalid_response`);return{assistantID:e.assistantID,name:e.name,revision:e.revision}})}return{status:t.status,error:typeof t.error==`string`?t.error:null,...typeof t.qrCode==`string`&&t.qrCode.length<=8192?{qrCode:t.qrCode}:{},...typeof t.expiresAt==`number`?{expiresAt:t.expiresAt}:{},...n?{transferSources:n}:{}}}var Ns=(e,t=i())=>[t,`assistants`,`weixin`,e],Ps=async(e,t=``,n={})=>{let r=await l(`/api/yuri/assistants/${encodeURIComponent(e)}/weixin${t}`,n);if(r.status===501||r.status===404&&!t)return{status:`unsupported`,error:null};let i=await r.json();if(!r.ok){let e=i&&typeof i==`object`&&`error`in i&&typeof i.error==`string`?i.error:`channel_error`;throw Error(e)}return Ms(i)},Fs=(e,t=i())=>({queryKey:Ns(e,t),queryFn:({signal:t})=>Ps(e,``,{signal:t}),staleTime:0,gcTime:0,retry:1,refetchOnWindowFocus:!0,refetchIntervalInBackground:!1,refetchInterval:e=>{let t=e.state.data?.status;return t===`waiting`||t===`scanned`||t===`verify`?2e3:t===`connected`||t===`reconnecting`?15e3:!1}});function Is(e){let t=(0,Sa.c)(14),n=i(),r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=o(),t[0]=r):r=t[0];let a=r,s=De(Fs(e,n)),c=()=>{if(n!==i()||a!==o())throw Error(`runtime_stale`)},l;t[1]!==c||t[2]!==e||t[3]!==n?(l=async t=>{await Oe.cancelQueries({queryKey:[n,`assistants`,`weixin`]}),c();let r=await Ps(e,t.type===`disconnect`?``:`/${t.type}`,{method:t.type===`disconnect`?`DELETE`:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t.type===`verify`?{code:t.code}:{...t.type===`transfer`?{sourceAssistantID:t.sourceAssistantID,revision:t.revision}:{},language:Ye.getState().locale})});return c(),r},t[1]=c,t[2]=e,t[3]=n,t[4]=l):l=t[4];let u;t[5]!==e||t[6]!==n?(u=t=>Oe.setQueryData(Ns(e,n),t),t[5]=e,t[6]=n,t[7]=u):u=t[7];let d;t[8]!==a||t[9]!==n?(d=()=>{n===i()&&a===o()&&Oe.invalidateQueries({queryKey:[n,`assistants`,`weixin`]})},t[8]=a,t[9]=n,t[10]=d):d=t[10];let f=Te({mutationKey:[...Ns(e,n),`change`],gcTime:0,mutationFn:l,onSuccess:u,onSettled:d}),p;return t[11]!==f||t[12]!==s?(p={query:s,mutation:f},t[11]=f,t[12]=s,t[13]=p):p=t[13],p}var Ls=e=>e===`account_in_use`||e===`already_bound`?`assistants.weixin.error.accountInUse`:e===`auth_expired`?`assistants.weixin.error.authExpired`:e===`delivery_unknown`?`assistants.weixin.error.deliveryUnknown`:e===`reply_unavailable`?`assistants.weixin.error.replyUnavailable`:e===`channel_in_use`?`assistants.weixin.error.channelInUse`:e===`binding_changed`?`assistants.weixin.error.bindingChanged`:`assistants.weixin.error.generic`;function Rs(e){let t=(0,Sa.c)(4),{assistantID:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=i(),t[0]=r):r=t[0];let a=`${r}:${n}`,o;return t[1]!==n||t[2]!==a?(o=(0,$.jsx)(Z,{children:(0,$.jsx)(zs,{assistantID:n},a)}),t[1]=n,t[2]=a,t[3]=o):o=t[3],o}function zs(e){let t=(0,Sa.c)(76),{assistantID:n}=e,{t:r}=Ge(),{query:i,mutation:a}=Is(n),[o,s]=Q.useState(null),[c,l]=Q.useState(!1),[u,d]=Q.useState(``),[f,p]=Q.useState(null),m=i.data,h=m?.qrCode??``,g=a.isPending,_=m?.status===`waiting`||m?.status===`scanned`||m?.status===`verify`,v=m?.status===`connected`||m?.status===`reconnecting`,y=m?.status===`unsupported`||m?.status===`disabled`,b;t[0]!==v||t[1]!==m?.transferSources||t[2]!==y||t[3]!==_?(b=!v&&!_&&!y?m?.transferSources??[]:[],t[0]=v,t[1]=m?.transferSources,t[2]=y,t[3]=_,t[4]=b):b=t[4];let x=b,S,C;t[5]===h?(S=t[6],C=t[7]):(S=()=>{if(!h)return;let e=!1;return As.toDataURL(h,{width:640,margin:4,errorCorrectionLevel:`M`}).then(t=>{e||(s({value:h,url:t}),l(!1))}).catch(()=>{e||l(!0)}),()=>{e=!0}},C=[h],t[5]=h,t[6]=S,t[7]=C),Q.useEffect(S,C);let w;t[8]===a?w=t[9]:(w=()=>a.mutate({type:`login`}),t[8]=a,t[9]=w);let T=He(w),E;t[10]===a?E=t[11]:(E=()=>a.mutate({type:`disconnect`}),t[10]=a,t[11]=E);let D=He(E),O;t[12]===a?O=t[13]:(O=()=>a.mutate({type:`retry`}),t[12]=a,t[13]=O);let k=He(O),A;t[14]!==a||t[15]!==f?(A=()=>{f&&a.mutate({type:`transfer`,sourceAssistantID:f.assistantID,revision:f.revision},{onSuccess:()=>p(null)})},t[14]=a,t[15]=f,t[16]=A):A=t[16];let j=He(A),M;t[17]!==u||t[18]!==a?(M=e=>{e.preventDefault(),a.mutate({type:`verify`,code:u},{onSuccess:()=>d(``)})},t[17]=u,t[18]=a,t[19]=M):M=t[19];let N=He(M),P;t[20]===i?P=t[21]:(P=()=>{i.refetch()},t[20]=i,t[21]=P);let F=He(P),I=a.error?.message||m?.error||(i.isError||c?`channel_error`:null),L;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(X,{name:`chat-thread`,className:`size-4`}),t[22]=L):L=t[22];let R;t[23]===r?R=t[24]:(R=r(`assistants.weixin.title`),t[23]=r,t[24]=R);let z;t[25]===R?z=t[26]:(z=(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[L,R]}),t[25]=R,t[26]=z);let B;t[27]!==m||t[28]!==r?(B=r(m?`assistants.weixin.status.${m.status}`:`common.loading`),t[27]=m,t[28]=r,t[29]=B):B=t[29];let V;t[30]!==v||t[31]!==T||t[32]!==D||t[33]!==g||t[34]!==i.isPending||t[35]!==F||t[36]!==m||t[37]!==r||t[38]!==y||t[39]!==_?(V=i.isPending?(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin motion-reduce:animate-none`}):y?null:v||_?(0,$.jsx)(q,{size:`sm`,variant:`ghost`,disabled:g,onClick:D,children:r(v?`assistants.weixin.disconnect`:`settings.common.actions.cancel`)}):(0,$.jsxs)($.Fragment,{children:[m?.status===`expired`||m?.status===`error`?(0,$.jsx)(q,{size:`sm`,variant:`ghost`,disabled:g,onClick:D,children:r(`assistants.weixin.disconnect`)}):null,(0,$.jsxs)(q,{size:`sm`,disabled:g,onClick:m?T:F,"aria-busy":g,children:[g?(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin motion-reduce:animate-none`}):null,r(m?`assistants.weixin.connect`:`assistants.actions.retry`)]})]}),t[30]=v,t[31]=T,t[32]=D,t[33]=g,t[34]=i.isPending,t[35]=F,t[36]=m,t[37]=r,t[38]=y,t[39]=_,t[40]=V):V=t[40];let H;t[41]!==z||t[42]!==B||t[43]!==V?(H=(0,$.jsx)(Xi,{label:z,description:B,children:V}),t[41]=z,t[42]=B,t[43]=V,t[44]=H):H=t[44];let U;if(t[45]!==g||t[46]!==x||t[47]!==r||t[48]!==j||t[49]!==f){let e;t[51]!==g||t[52]!==r||t[53]!==j||t[54]!==f?(e=e=>(0,$.jsx)(Xi,{className:f?.assistantID===e.assistantID?`yuri-settings-split-row-stacked`:void 0,label:r(`assistants.weixin.transferFrom`,{name:e.name}),description:f?.assistantID===e.assistantID?r(`assistants.weixin.transferWarning`):void 0,children:f?.assistantID===e.assistantID?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(q,{size:`sm`,variant:`ghost`,disabled:g,onClick:()=>p(null),children:r(`settings.common.actions.cancel`)}),(0,$.jsx)(q,{size:`sm`,disabled:g||f.revision!==e.revision,onClick:j,"aria-busy":g,children:r(`assistants.weixin.transferConfirm`)})]}):(0,$.jsx)(q,{size:`sm`,disabled:g,onClick:()=>p(e),children:r(`assistants.weixin.transfer`)})},e.assistantID),t[51]=g,t[52]=r,t[53]=j,t[54]=f,t[55]=e):e=t[55],U=x.map(e),t[45]=g,t[46]=x,t[47]=r,t[48]=j,t[49]=f,t[50]=U}else U=t[50];let W;t[56]!==u||t[57]!==g||t[58]!==o||t[59]!==m?.status||t[60]!==r||t[61]!==h||t[62]!==N||t[63]!==_?(W=_?(0,$.jsxs)(Xi,{controlClassName:`flex-col items-center`,label:r(`assistants.weixin.scan`),children:[h&&o?.value===h?(0,$.jsx)(`img`,{src:o.url,alt:r(`assistants.weixin.qrAlt`),className:`size-48 max-w-full rounded-lg`,width:192,height:192}):(0,$.jsx)(`span`,{className:`flex size-48 items-center justify-center`,children:(0,$.jsx)(X,{name:`loader-4`,className:`size-5 animate-spin motion-reduce:animate-none`})}),m?.status===`verify`?(0,$.jsxs)(`form`,{onSubmit:N,className:`flex w-full min-w-0 items-center gap-2`,children:[(0,$.jsx)(Cn,{"aria-label":r(`assistants.weixin.verify`),placeholder:r(`assistants.weixin.verify`),inputMode:`numeric`,autoComplete:`one-time-code`,value:u,maxLength:12,onChange:e=>d(e.target.value.replace(/\D/g,``))}),(0,$.jsx)(q,{type:`submit`,size:`sm`,disabled:g||u.length<4,children:r(`assistants.weixin.verifySubmit`)})]}):null]}):null,t[56]=u,t[57]=g,t[58]=o,t[59]=m?.status,t[60]=r,t[61]=h,t[62]=N,t[63]=_,t[64]=W):W=t[64];let ee;t[65]!==v||t[66]!==I||t[67]!==g||t[68]!==k||t[69]!==r?(ee=I?(0,$.jsxs)(Xi,{description:r(Ls(I)),children:[(0,$.jsx)(`span`,{role:`status`,className:`typography-meta text-[var(--status-warning)]`,children:r(`assistants.weixin.attention`)}),v&&I!==`auth_expired`&&I!==`channel_in_use`?(0,$.jsx)(q,{size:`sm`,onClick:k,disabled:g,children:r(`assistants.actions.retry`)}):null]}):null,t[65]=v,t[66]=I,t[67]=g,t[68]=k,t[69]=r,t[70]=ee):ee=t[70];let te;return t[71]!==H||t[72]!==U||t[73]!==W||t[74]!==ee?(te=(0,$.jsxs)($.Fragment,{children:[H,U,W,ee]}),t[71]=H,t[72]=U,t[73]=W,t[74]=ee,t[75]=te):te=t[75],te}function Bs(e){let t=(0,Sa.c)(49),{assistantID:n,channel:a,open:o,onOpenChange:s}=e,{t:c}=Ge(),l=Q.useSyncExternalStore(r,i,i),u,d,f,p,m,h,g,_,v,y,b;if(t[0]!==a||t[1]!==s||t[2]!==o||t[3]!==c){let e=gs.find(e=>e.id===a)??gs[0],n;t[15]===s?n=t[16]:(n=()=>s(!1),t[15]=s,t[16]=n),m=n,p=gn,y=o,b=s,f=pn,v=`yuri-settings-workspace yuri-settings-workspace-desktop max-h-[85vh] max-w-lg overflow-y-auto`,d=dn,g=`flex items-center gap-2.5`,_=(0,$.jsx)(`img`,{src:e.logo,alt:``,"aria-hidden":!0,className:`size-7 shrink-0`}),u=mn,h=c(e.nameKey),t[0]=a,t[1]=s,t[2]=o,t[3]=c,t[4]=u,t[5]=d,t[6]=f,t[7]=p,t[8]=m,t[9]=h,t[10]=g,t[11]=_,t[12]=v,t[13]=y,t[14]=b}else u=t[4],d=t[5],f=t[6],p=t[7],m=t[8],h=t[9],g=t[10],_=t[11],v=t[12],y=t[13],b=t[14];let x;t[17]!==u||t[18]!==h?(x=(0,$.jsx)(u,{children:h}),t[17]=u,t[18]=h,t[19]=x):x=t[19];let S;t[20]!==g||t[21]!==_||t[22]!==x?(S=(0,$.jsxs)(`div`,{className:g,children:[_,x]}),t[20]=g,t[21]=_,t[22]=x,t[23]=S):S=t[23];let C;t[24]!==d||t[25]!==S?(C=(0,$.jsx)(d,{children:S}),t[24]=d,t[25]=S,t[26]=C):C=t[26];let w;t[27]!==n||t[28]!==a||t[29]!==o||t[30]!==l?(w=o&&a===`wechat`?(0,$.jsx)(Rs,{assistantID:n},`${l}:${n}:${a}`):null,t[27]=n,t[28]=a,t[29]=o,t[30]=l,t[31]=w):w=t[31];let T;t[32]!==n||t[33]!==a||t[34]!==m||t[35]!==o||t[36]!==l?(T=o&&a!==`wechat`?(0,$.jsx)(ks,{assistantID:n,provider:a,onClose:m},`${l}:${n}:${a}`):null,t[32]=n,t[33]=a,t[34]=m,t[35]=o,t[36]=l,t[37]=T):T=t[37];let E;t[38]!==f||t[39]!==w||t[40]!==T||t[41]!==v||t[42]!==C?(E=(0,$.jsxs)(f,{className:v,children:[C,w,T]}),t[38]=f,t[39]=w,t[40]=T,t[41]=v,t[42]=C,t[43]=E):E=t[43];let D;return t[44]!==p||t[45]!==E||t[46]!==y||t[47]!==b?(D=(0,$.jsx)(p,{open:y,onOpenChange:b,children:E}),t[44]=p,t[45]=E,t[46]=y,t[47]=b,t[48]=D):D=t[48],D}function Vs(e){let t=(0,Sa.c)(21),{assistantID:n}=e,{t:r}=Ge(),[i,a]=Q.useState(null),o;t[0]===r?o=t[1]:(o=r(`assistants.channels.title`),t[0]=r,t[1]=o);let s;t[2]===r?s=t[3]:(s=r(`assistants.channels.description`),t[2]=r,t[3]=s);let c;t[4]!==i||t[5]!==r?(c=gs.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>a(e.id),"aria-haspopup":`dialog`,"aria-expanded":i===e.id,className:`group flex min-h-20 w-full min-w-0 items-center gap-3 rounded-xl bg-transparent px-3 py-2.5 text-left ring-1 ring-inset ring-border/60 transition-colors hover:bg-[var(--interactive-hover)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,children:[(0,$.jsx)(`img`,{src:e.logo,alt:``,"aria-hidden":!0,className:`size-8 shrink-0`}),(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`block truncate typography-ui-label text-foreground`,children:r(e.nameKey)}),(0,$.jsx)(`span`,{className:`mt-0.5 block truncate typography-meta text-muted-foreground`,children:r(e.summaryKey)})]})]},e.id)),t[4]=i,t[5]=r,t[6]=c):c=t[6];let l;t[7]===c?l=t[8]:(l=(0,$.jsx)(Xi,{className:`yuri-settings-split-row-stacked`,copyClassName:`hidden`,controlClassName:`w-full`,children:(0,$.jsx)(`div`,{className:`grid w-full grid-cols-2 gap-2`,children:c})}),t[7]=c,t[8]=l);let u;t[9]!==o||t[10]!==s||t[11]!==l?(u=(0,$.jsx)(Z,{label:o,description:s,children:l}),t[9]=o,t[10]=s,t[11]=l,t[12]=u):u=t[12];let d=i??`wechat`,f=i!==null,p;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(p=e=>{e||a(null)},t[13]=p):p=t[13];let m;t[14]!==n||t[15]!==d||t[16]!==f?(m=(0,$.jsx)(Bs,{assistantID:n,channel:d,open:f,onOpenChange:p}),t[14]=n,t[15]=d,t[16]=f,t[17]=m):m=t[17];let h;return t[18]!==u||t[19]!==m?(h=(0,$.jsxs)($.Fragment,{children:[u,m]}),t[18]=u,t[19]=m,t[20]=h):h=t[20],h}var Hs=`__managed_workspace__`,Us=`__current_workspace__`,Ws=`Yuri`,Gs=()=>{let e=Pt.getState(),t=e.settingsDefaultModel??(e.currentModelId?void 0:e.opencodeDefaultModel);if(t){let n=Ht(t);if(n?.providerId&&n?.modelId)return{providerID:n.providerId,modelID:n.modelId,variant:n.variant??e.settingsDefaultVariant}}if(e.currentProviderId&&e.currentModelId)return{providerID:e.currentProviderId,modelID:e.currentModelId,variant:e.currentVariant};let n=e.providers;for(let e of n){let t=e.models;if(Array.isArray(t)&&t.length>0){let n=t[0];if(n?.id)return{providerID:e.id,modelID:n.id}}}return null},Ks=(e=``)=>{let t=Gs();return{name:e,avatarSeed:an(crypto.randomUUID()),defaultPrompt:``,workspacePath:null,providerID:t?.providerID??``,modelID:t?.modelID??``,variant:t?.variant??null}},qs=e=>({avatarSeed:e.avatarSeed??e.id,name:e.name,defaultPrompt:e.defaultPrompt,workspacePath:e.workspacePath,providerID:e.providerID,modelID:e.modelID,variant:e.variant}),Js=e=>({avatarSeed:e.avatarSeed,name:e.name,defaultPrompt:e.defaultPrompt,workspacePath:e.workspacePath,providerID:e.providerID,modelID:e.modelID,variant:e.variant??null}),Ys=e=>e.label?.trim()||e.path.replace(/[\\/]+$/,``).split(/[\\/]/).filter(Boolean).at(-1)||e.path,Xs=e=>{let t=Array.isArray(e.schedule.times)?e.schedule.times:e.schedule.time?[e.schedule.time]:[];return Array.from(new Set(t.filter(e=>/^([01]\d|2[0-3]):([0-5]\d)$/.test(e)))).sort((e,t)=>e.localeCompare(t))},Zs=e=>!!e&&typeof e==`object`&&!Array.isArray(e),Qs=e=>{if(!Zs(e)||!Zs(e.schedule)||!Zs(e.execution)||!Zs(e.state))return!1;let t=e.schedule.times===void 0||Array.isArray(e.schedule.times)&&e.schedule.times.every(e=>typeof e==`string`),n=e.schedule.weekdays===void 0||Array.isArray(e.schedule.weekdays)&&e.schedule.weekdays.every(e=>typeof e==`number`),r=e.state.lastStatus===void 0||e.state.lastStatus===`idle`||e.state.lastStatus===`running`||e.state.lastStatus===`success`||e.state.lastStatus===`error`;return typeof e.id==`string`&&typeof e.name==`string`&&typeof e.enabled==`boolean`&&(e.schedule.kind===`daily`||e.schedule.kind===`weekly`||e.schedule.kind===`once`||e.schedule.kind===`cron`)&&t&&n&&r&&typeof e.execution.prompt==`string`&&typeof e.execution.providerID==`string`&&typeof e.execution.modelID==`string`},$s=(e,t)=>{let n=Xs(e).join(`, `)||`—`,r=e=>t(e===0?`sessions.scheduledTasks.dialog.schedule.weekdayShort.sun`:e===1?`sessions.scheduledTasks.dialog.schedule.weekdayShort.mon`:e===2?`sessions.scheduledTasks.dialog.schedule.weekdayShort.tue`:e===3?`sessions.scheduledTasks.dialog.schedule.weekdayShort.wed`:e===4?`sessions.scheduledTasks.dialog.schedule.weekdayShort.thu`:e===5?`sessions.scheduledTasks.dialog.schedule.weekdayShort.fri`:e===6?`sessions.scheduledTasks.dialog.schedule.weekdayShort.sat`:`sessions.scheduledTasks.dialog.schedule.weekdayShort.unknown`);if(e.schedule.kind===`daily`)return e.schedule.timezone?t(`sessions.scheduledTasks.dialog.schedule.dailyWithTimezone`,{time:n,timezone:e.schedule.timezone}):t(`sessions.scheduledTasks.dialog.schedule.daily`,{time:n});if(e.schedule.kind===`weekly`){let i=(e.schedule.weekdays??[]).map(r).join(`, `);return e.schedule.timezone?t(`sessions.scheduledTasks.dialog.schedule.weeklyWithTimezone`,{days:i,time:n,timezone:e.schedule.timezone}):t(`sessions.scheduledTasks.dialog.schedule.weekly`,{days:i,time:n})}if(e.schedule.kind===`once`){let n=e.schedule.date?.trim()||t(`sessions.scheduledTasks.dialog.schedule.unknownDate`),r=e.schedule.time?.trim()||`—`;return e.schedule.timezone?t(`sessions.scheduledTasks.dialog.schedule.onceWithTimezone`,{date:n,time:r,timezone:e.schedule.timezone}):t(`sessions.scheduledTasks.dialog.schedule.once`,{date:n,time:r})}return e.schedule.timezone?t(`sessions.scheduledTasks.dialog.schedule.cronWithTimezone`,{cron:e.schedule.cron??``,timezone:e.schedule.timezone}):t(`sessions.scheduledTasks.dialog.schedule.cron`,{cron:e.schedule.cron??``})},ec={paused:{icon:`pause`,className:`text-muted-foreground`},idle:{icon:`pulse`,className:`text-muted-foreground`},running:{icon:`loader-4`,className:`text-[var(--status-warning)]`},success:{icon:`checkbox-circle`,className:`text-[var(--status-success)]`},error:{icon:`error-warning`,className:`text-[var(--status-error)]`}},tc=e=>`${e.projectId}:${e.task.id}`,nc=e=>{let t=(0,Sa.c)(38),{assistantID:n}=e,{t:r}=Ge(),i=Qe(n),a=i.isError,o=tt(n,a),s=st(a),c,l,u,d,f,p,m,h,g;if(t[0]!==o.data?.messages||t[1]!==o.isError||t[2]!==o.isPending||t[3]!==a||t[4]!==s||t[5]!==i.data||t[6]!==i.isError||t[7]!==i.isPending||t[8]!==r){h=Symbol.for(`react.early_return_sentinel`);bb0:{let e=new Set;for(let t of o.data?.messages??[])for(let n of t.cards)n.cardType===`schedule`&&e.add(`${n.projectID}:${n.taskID}`);let n=(i.data?.tasks??[]).flatMap(oc),_;t[18]===i.data?.tasks?_=t[19]:(_=i.data?.tasks.some(sc),t[18]=i.data?.tasks,t[19]=_);let v=!!_,y=(s.data?.tasks??[]).filter(t=>e.has(tc(t)));g=[...i.data?n:a?y:[]].sort(cc);let b=(s.data?.failedProjectIds??[]).some(t=>Array.from(e).some(e=>e.startsWith(`${t}:`)));if(u=i.isPending||a&&(o.isPending||s.isPending),l=i.isError||o.isError||s.isError||b||v,!u&&l&&g.length===0){h=null;break bb0}c=Z,t[20]===r?d=t[21]:(d=r(`assistants.settings.scheduledTasks.title`),t[20]=r,t[21]=d),t[22]===r?f=t[23]:(f=r(`assistants.settings.scheduledTasks.title`),t[22]=r,t[23]=f),p=u&&g.length===0?(0,$.jsx)(Xi,{label:r(`common.loading`),children:(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin text-muted-foreground`})}):null;let x;t[24]===r?x=t[25]:(x=e=>{let t=e.task.enabled?e.task.state?.lastStatus??`idle`:`paused`,n=ec[t],i=r(t===`paused`?`sessions.scheduledTasks.dialog.taskToggle.paused`:t===`running`?`sessions.scheduledTasks.dialog.status.running`:t===`success`?`sessions.scheduledTasks.dialog.status.success`:t===`error`?`sessions.scheduledTasks.dialog.status.error`:`sessions.scheduledTasks.dialog.status.idle`);return(0,$.jsxs)(q,{type:`button`,variant:`ghost`,className:`yuri-settings-group-row yuri-settings-split-row h-auto rounded-none text-left font-normal focus-visible:ring-inset`,onClick:()=>Or(e.projectId,e.task.id),"aria-label":r(`assistants.settings.scheduledTasks.open`,{name:e.task.name}),children:[(0,$.jsx)(`span`,{className:`yuri-settings-split-row-copy`,children:(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-3`,children:[(0,$.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center rounded-lg bg-[var(--surface-muted)] text-muted-foreground`,children:(0,$.jsx)(X,{name:`calendar`,className:`size-3.5`})}),(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`block truncate typography-ui-label font-medium text-foreground`,children:e.task.name}),(0,$.jsx)(`span`,{className:`mt-0.5 block typography-micro truncate text-muted-foreground`,children:$s(e.task,r)})]})]})}),(0,$.jsxs)(`span`,{className:`yuri-settings-split-row-control min-w-fit text-muted-foreground`,children:[(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 typography-micro ${n.className}`,children:[(0,$.jsx)(X,{name:n.icon,className:`size-3.5 ${t===`running`?`animate-spin`:``}`}),i]}),(0,$.jsx)(X,{name:`arrow-right-s`,className:`size-4`})]})]},tc(e))},t[24]=r,t[25]=x),m=g.map(x)}t[0]=o.data?.messages,t[1]=o.isError,t[2]=o.isPending,t[3]=a,t[4]=s,t[5]=i.data,t[6]=i.isError,t[7]=i.isPending,t[8]=r,t[9]=c,t[10]=l,t[11]=u,t[12]=d,t[13]=f,t[14]=p,t[15]=m,t[16]=h,t[17]=g}else c=t[9],l=t[10],u=t[11],d=t[12],f=t[13],p=t[14],m=t[15],h=t[16],g=t[17];if(h!==Symbol.for(`react.early_return_sentinel`))return h;let _;t[26]!==l||t[27]!==u||t[28]!==r||t[29]!==g?(_=!u&&!l&&g.length===0?(0,$.jsx)(Xi,{label:r(`assistants.settings.scheduledTasks.empty`),children:(0,$.jsx)(X,{name:`calendar`,className:`size-4 text-muted-foreground`})}):null,t[26]=l,t[27]=u,t[28]=r,t[29]=g,t[30]=_):_=t[30];let v;return t[31]!==c||t[32]!==d||t[33]!==f||t[34]!==p||t[35]!==m||t[36]!==_?(v=(0,$.jsxs)(c,{label:d,ariaLabel:f,children:[p,m,_]}),t[31]=c,t[32]=d,t[33]=f,t[34]=p,t[35]=m,t[36]=_,t[37]=v):v=t[37],v},rc=e=>{let t=(0,Sa.c)(11),{name:n,path:r,icon:i}=e,a=i===void 0?`folder`:i,o;t[0]===a?o=t[1]:(o=(0,$.jsx)(X,{name:a,className:`size-4 shrink-0 text-muted-foreground`}),t[0]=a,t[1]=o);let s=r?`max-w-[40%] shrink-0 truncate typography-ui-label text-foreground`:`min-w-0 truncate typography-ui-label text-foreground`,c;t[2]!==n||t[3]!==s?(c=(0,$.jsx)(`span`,{className:s,children:n}),t[2]=n,t[3]=s,t[4]=c):c=t[4];let l;t[5]===r?l=t[6]:(l=r?(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-micro text-muted-foreground`,title:r,children:r}):null,t[5]=r,t[6]=l);let u;return t[7]!==o||t[8]!==c||t[9]!==l?(u=(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[o,c,l]}),t[7]=o,t[8]=c,t[9]=l,t[10]=u):u=t[10],u},ic=e=>{let t=(0,Sa.c)(49),{onItemSelect:n}=e,{t:r}=Ge(),i=ot(),a=nt(),o=i.data,s=en(lc),c=en(uc),l=en(dc),u;t[0]!==n||t[1]!==c||t[2]!==s||t[3]!==o?(u=()=>{!n&&s===null&&o?.assistants[0]&&c(o.assistants[0].id)},t[0]=n,t[1]=c,t[2]=s,t[3]=o,t[4]=u):u=t[4];let d=o?.assistants,f;t[5]!==n||t[6]!==c||t[7]!==s||t[8]!==d?(f=[n,c,s,d],t[5]=n,t[6]=c,t[7]=s,t[8]=d,t[9]=f):f=t[9],Q.useEffect(u,f);let p;t[10]!==n||t[11]!==c||t[12]!==s||t[13]!==o?.assistants||t[14]!==i.isSuccess?(p=()=>{i.isSuccess&&s&&s!==`new`&&!o?.assistants.some(e=>e.id===s)&&c(n?null:o?.assistants[0]?.id??null)},t[10]=n,t[11]=c,t[12]=s,t[13]=o?.assistants,t[14]=i.isSuccess,t[15]=p):p=t[15];let m=o?.assistants,h;t[16]!==n||t[17]!==c||t[18]!==s||t[19]!==i.isSuccess||t[20]!==m?(h=[n,c,s,m,i.isSuccess],t[16]=n,t[17]=c,t[18]=s,t[19]=i.isSuccess,t[20]=m,t[21]=h):h=t[21],Q.useEffect(p,h);let g;t[22]!==n||t[23]!==l?(g=()=>{l(),n?.()},t[22]=n,t[23]=l,t[24]=g):g=t[24];let _=He(g);if(a.isSuccess&&!a.data.supported)return null;let v;t[25]===r?v=t[26]:(v=r(`assistants.settings.listTitle`),t[25]=r,t[26]=v);let y;t[27]===v?y=t[28]:(y=(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:v}),t[27]=v,t[28]=y);let b;t[29]===r?b=t[30]:(b=r(`assistants.settings.create`),t[29]=r,t[30]=b);let x;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(X,{name:`add`,className:`size-4`}),t[31]=x):x=t[31];let S;t[32]!==_||t[33]!==b?(S=(0,$.jsx)(q,{"data-settings-item":`assistants.create`,variant:`ghost`,size:`icon`,onClick:_,"aria-label":b,children:x}),t[32]=_,t[33]=b,t[34]=S):S=t[34];let C;t[35]!==S||t[36]!==y?(C=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2`,children:[y,S]}),t[35]=S,t[36]=y,t[37]=C):C=t[37];let w;t[38]!==a.isPending||t[39]!==n||t[40]!==c||t[41]!==s||t[42]!==o||t[43]!==i.isPending||t[44]!==r?(w=i.isPending||a.isPending?(0,$.jsxs)(`div`,{className:`yuri-settings-group-row flex items-center justify-center text-muted-foreground`,children:[(0,$.jsx)(X,{name:`loader-4`,className:`mr-2 size-4 animate-spin`}),r(`common.loading`)]}):o?.assistants.length?o.assistants.map(e=>{let t=Xe(e.name);return(0,$.jsx)(ps,{title:t.displayName,selected:s===e.id,onSelect:()=>{c(e.id),n?.()},icon:(0,$.jsx)(cn,{kind:`assistant`,name:e.avatarSeed??e.id,size:32,label:t.displayName||e.name})},e.id)}):(0,$.jsx)(`div`,{className:`yuri-settings-group-row text-muted-foreground`,children:r(`assistants.settings.empty`)}),t[38]=a.isPending,t[39]=n,t[40]=c,t[41]=s,t[42]=o,t[43]=i.isPending,t[44]=r,t[45]=w):w=t[45];let T;return t[46]!==C||t[47]!==w?(T=(0,$.jsx)(hs,{variant:`background`,children:(0,$.jsx)(Z,{label:C,children:w})}),t[46]=C,t[47]=w,t[48]=T):T=t[48],T},ac=({onItemDeleted:e,onSaved:t,assistantID:n,saveActionContainer:r})=>{let{t:i}=Ge(),a=ot(),o=nt(),s=a.data,c=Qt(e=>e.projects),l=en(e=>n??e.settingsSelectedAssistantID),u=en(e=>e.selectSettingsAssistant),d=en(e=>e.createRequestRevision),f=en(e=>e.requestCreate),[p,m]=Q.useState(Ks),[h,g]=Q.useState(!1),_=Q.useRef(0);Q.useEffect(()=>()=>{_.current+=1},[l]);let v=Q.useRef(0),y=s?.assistants.find(e=>e.id===l)??null,b=y?Xe(y.name):null,x=Xe(p.name),S=p.workspacePath??y?.managedWorkspacePath??null,C=kt(S,{enabled:!0}).data??[];Q.useEffect(()=>{y&&m(qs(y))},[y]),Q.useEffect(()=>{n===void 0&&a.isSuccess&&l&&l!==`new`&&!y&&u(null)},[n,u,y,l,a.isSuccess]),Q.useEffect(()=>{if(l!==`new`||d<=v.current)return;v.current=d;let e=Ks(s?.assistants.length?``:Ws);m(e),window.requestAnimationFrame(()=>document.getElementById(`assistant-name`)?.focus())},[d,l,s?.assistants.length]),Q.useEffect(()=>{a.isSuccess&&Ze()},[s?.revision,a.isSuccess]);let w=(e,t)=>{m(n=>({...n,[e]:t}))},T=He(()=>f()),E=He(async()=>{if(n!==void 0&&!y)return;if(!p.name.trim()||!p.providerID||!p.modelID){Be.error(i(`assistants.settings.validation.required`));return}let e=_.current;g(!0);try{let r=y?await it(y,Js(p)):await rt(p);n===void 0&&u(r.id),Be.success(i(`assistants.settings.toast.saved`)),_.current===e&&t?.()}catch{Be.error(i(`assistants.settings.toast.saveFailed`))}finally{g(!1)}}),D=He(async()=>{if(!(!y||!window.confirm(i(`assistants.settings.deleteConfirm`,{name:y.name})))){g(!0);try{await $e(y),n===void 0&&u(null),e?.(),Be.success(i(`assistants.settings.toast.deleted`))}catch{Be.error(i(`assistants.settings.toast.deleteFailed`))}finally{g(!1)}}}),O=p.workspacePath===null?null:c.find(e=>e.path===p.workspacePath)??null,k=p.workspacePath!==null&&!O?p.workspacePath:null,A=p.workspacePath===null?Hs:O?O.id:Us,j=p.workspacePath===null?(0,$.jsx)(rc,{name:i(`assistants.settings.workspacePlaceholder`),icon:`cloud`}):O?(0,$.jsx)(rc,{name:Ys(O),path:O.path}):(0,$.jsx)(rc,{name:i(`assistants.settings.workspaceCurrentPath`),path:k??``,icon:`history`});return o.isSuccess&&!o.data.supported?null:a.isPending||o.isPending?(0,$.jsxs)(`div`,{className:`flex h-full items-center justify-center text-muted-foreground`,children:[(0,$.jsx)(X,{name:`loader-4`,className:`mr-2 size-4 animate-spin`}),i(`common.loading`)]}):a.isError&&!s||n!==void 0&&!y?(0,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 px-6 text-center`,children:[(0,$.jsx)(X,{name:`cloud-off`,className:`size-6 text-muted-foreground`}),(0,$.jsx)(`p`,{className:`typography-ui text-muted-foreground`,children:i(`assistants.state.unavailable`)}),(0,$.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>void a.refetch(),children:i(`assistants.actions.retry`)})]}):(0,$.jsx)(Ur,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`yuri-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[a.isError&&s?(0,$.jsx)(`p`,{className:`mb-4 px-2 typography-meta text-[var(--status-warning)]`,children:i(`assistants.state.staleSnapshot`)}):null,l?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Gi,{actions:(0,$.jsxs)($.Fragment,{children:[y?(0,$.jsx)(q,{variant:`ghost`,size:`icon`,onClick:D,disabled:h,className:`text-[var(--status-error)]`,"aria-label":i(`assistants.settings.delete`),title:i(`assistants.settings.delete`),children:(0,$.jsx)(X,{name:`delete-bin`,className:`size-4`})}):null,r?null:(0,$.jsxs)(q,{size:`sm`,onClick:E,disabled:h,"aria-busy":h,children:[h?(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}):null,i(`assistants.settings.save`)]})]}),children:(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,$.jsx)(`div`,{className:`shrink-0`,children:(0,$.jsx)(cn,{kind:`assistant`,name:p.avatarSeed??y?.id??`new`,size:40,label:x.displayName||p.name||i(`assistants.settings.create`)})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h2`,{className:`truncate typography-ui-header font-semibold text-foreground`,children:y?b?.displayName:i(`assistants.settings.create`)}),p.providerID&&p.modelID?(0,$.jsx)(`p`,{className:`mt-0.5 truncate typography-micro leading-none text-muted-foreground/70`,children:`${p.providerID}/${p.modelID}`}):null]})]})}),(0,$.jsx)(fs,{seed:p.avatarSeed??y?.id??`new`,disabled:h,onChange:e=>w(`avatarSeed`,e)}),(0,$.jsxs)(Z,{children:[(0,$.jsx)(Xi,{itemId:`assistants.name`,label:i(`assistants.settings.name`),children:(0,$.jsx)(Cn,{id:`assistant-name`,value:p.name,onChange:e=>w(`name`,e.target.value),className:`min-w-0 flex-1`})}),(0,$.jsx)(Xi,{itemId:`assistants.model`,label:i(`assistants.settings.model`),children:(0,$.jsx)(ii,{providerId:p.providerID,modelId:p.modelID,variant:p.variant??``,providers:C,onChange:(e,t,n)=>m(r=>({...r,providerID:e,modelID:t,variant:n||null})),className:`yuri-settings-inline-value`})}),(0,$.jsx)(Xi,{itemId:`assistants.prompt`,label:i(`assistants.settings.defaultPrompt`),className:`yuri-settings-split-row-stacked`,children:(0,$.jsx)(Wr,{embedded:!0,id:`assistant-prompt`,value:p.defaultPrompt,onChange:e=>w(`defaultPrompt`,e.target.value),placeholder:i(`assistants.settings.defaultPromptPlaceholder`),rows:12,outerClassName:`min-h-[240px] max-h-[70vh]`})})]}),(0,$.jsx)(Ui,{itemId:`assistants.workspace`,label:i(`assistants.settings.workspace`),description:i(`assistants.settings.workspaceChangeHint`),descriptionPlacement:`outside`,children:(0,$.jsxs)(Fr,{value:A,onValueChange:e=>{if(e===Hs){w(`workspacePath`,null);return}let t=c.find(t=>t.id===e);t&&w(`workspacePath`,t.path)},children:[(0,$.jsx)(Pr,{title:p.workspacePath??i(`assistants.settings.workspacePlaceholder`),className:`w-full max-w-xl [&_[data-slot=select-value]]:min-w-0 [&_[data-slot=select-value]]:flex-1 [&_[data-slot=select-value]]:overflow-hidden`,children:(0,$.jsx)(Ar,{children:j})}),(0,$.jsxs)(Nr,{align:`start`,className:`w-[min(32rem,calc(100vw-2rem))]`,children:[(0,$.jsx)(jr,{value:Hs,children:(0,$.jsx)(rc,{name:i(`assistants.settings.workspacePlaceholder`),icon:`cloud`})}),c.map(e=>(0,$.jsx)(jr,{value:e.id,children:(0,$.jsx)(rc,{name:Ys(e),path:e.path})},e.id)),k?(0,$.jsx)(jr,{value:Us,disabled:!0,children:(0,$.jsx)(rc,{name:i(`assistants.settings.workspaceCurrentPath`),path:k,icon:`history`})}):null]})]})}),y?(0,$.jsx)(nc,{assistantID:y.id}):null,y?(0,$.jsx)(Vs,{assistantID:y.id},y.id):null,r?(0,Ca.createPortal)((0,$.jsx)(q,{type:`button`,size:`mobileIcon`,onClick:E,disabled:h,"aria-label":i(`assistants.settings.save`),"aria-busy":h,children:(0,$.jsx)(X,{name:h?`loader-4`:`check`,className:h?`size-5 animate-spin motion-reduce:animate-none`:`size-5`})}),r):null]}):(0,$.jsxs)(`div`,{className:`flex min-h-80 flex-col items-center justify-center gap-3 px-6 text-center text-muted-foreground`,children:[(0,$.jsx)(cn,{kind:`assistant`,name:`assistants-empty`,size:44}),(0,$.jsx)(`p`,{className:`typography-ui`,children:i(`assistants.settings.empty`)}),(0,$.jsxs)(q,{"data-settings-item":`assistants.create`,size:`sm`,onClick:T,children:[(0,$.jsx)(X,{name:`add`,className:`size-4`}),i(`assistants.settings.create`)]})]})]})})};function oc(e){return Qs(e.task)?[{projectId:e.projectID,task:e.task}]:[]}function sc(e){return!Qs(e.task)}function cc(e,t){return e.task.enabled===t.task.enabled?e.task.name.localeCompare(t.task.name):e.task.enabled?-1:1}function lc(e){return e.settingsSelectedAssistantID}function uc(e){return e.selectSettingsAssistant}function dc(e){return e.requestCreate}var fc=`~/.config/opencode/AGENTS.md`,pc=async(e,t)=>{let n=await e.json().catch(()=>null);return typeof n?.error==`string`&&n.error.trim()?n.error:t},mc=e=>e.length>0&&!e.endsWith(`
2
- `)?`${e}\n`:e,hc={prompt:``,responseStyleEnabled:!1,responseStylePreset:`concise`,responseStyleCustomInstructions:``},gc=(e,t)=>e===`custom`?t:ht(e),_c=e=>e===`custom`?`custom`:gt(e)?e:`concise`,vc={concise:`settings.behavior.page.responseStyle.option.concise`,detailed:`settings.behavior.page.responseStyle.option.detailed`,mentor:`settings.behavior.page.responseStyle.option.mentor`,pushback:`settings.behavior.page.responseStyle.option.pushback`,noFiller:`settings.behavior.page.responseStyle.option.noFiller`,matchEnergy:`settings.behavior.page.responseStyle.option.matchEnergy`,warmPeer:`settings.behavior.page.responseStyle.option.warmPeer`},yc=async(e,t)=>{let n=await l(`/api/config/settings`,{method:`PUT`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(e)});if(!n.ok)throw Error(await pc(n,t));return n.json().catch(()=>null)},bc=()=>{let{t:e}=Ge(),t=Q.useSyncExternalStore(r,i,i),[n,a]=Q.useState(``),[o,s]=Q.useState(hc.responseStyleEnabled),[c,u]=Q.useState(hc.responseStylePreset),[d,f]=Q.useState(hc.responseStyleCustomInstructions),[p,m]=Q.useState(!1),[h,g]=Q.useState(!1),[_,v]=Q.useState(!1),[y,b]=Q.useState(``),x=Q.useRef(null),S=Q.useRef(null),C=Q.useRef(0),w=Q.useRef(Promise.resolve());Q.useEffect(()=>{let e=!0;return g(!1),x.current=null,S.current=null,C.current+=1,he(t).then(n=>{if(!e||t!==i())return;let r={enabled:n.responseStyleEnabled===!0,preset:_c(n.responseStylePreset),custom:typeof n.responseStyleCustomInstructions==`string`?n.responseStyleCustomInstructions:``};s(r.enabled),u(r.preset),f(r.custom),_t({enabled:r.enabled,preset:r.preset,customInstructions:r.custom},t),x.current=r,S.current=r,g(!0)}).catch(t=>{e&&t?.name!==`AbortError`&&console.warn(`Failed to load behavior settings:`,t)}),()=>{e=!1,C.current+=1}},[t]),Q.useEffect(()=>{let e=new AbortController,n=!0;return m(!1),v(!1),(async()=>{try{let r=await l(`/api/behavior/agents-md`,{method:`GET`,headers:{Accept:`application/json`},signal:e.signal});if(!r.ok)throw Error(`Behavior prompt request failed (${r.status})`);let o=await r.json().catch(()=>null);if(typeof o?.content!=`string`)throw Error(`Invalid behavior prompt response`);if(!n||t!==i())return;a(o.content),b(o.content),m(!0)}catch(e){n&&e?.name!==`AbortError`&&console.warn(`Failed to load behavior prompt:`,e)}})(),()=>{n=!1,e.abort()}},[t]),Q.useEffect(()=>{if(!h)return;let n={enabled:o,preset:c,custom:d},r=S.current;if(r&&r.enabled===n.enabled&&r.preset===n.preset&&r.custom===n.custom)return;S.current=n;let a=C.current+1;C.current=a;let l=setTimeout(()=>{let r=async()=>{if(t===i())try{let r=await yc({responseStyleEnabled:n.enabled,responseStylePreset:n.preset,responseStyleCustomInstructions:n.custom},e(`settings.behavior.page.toast.saveFailed`));if(t!==i())return;let o=ge(r),c={enabled:o.responseStyleEnabled??n.enabled,preset:o.responseStylePreset??n.preset,custom:o.responseStyleCustomInstructions??n.custom};if(_t({enabled:c.enabled,preset:c.preset,customInstructions:c.custom},t),ve({responseStyleEnabled:c.enabled,responseStylePreset:c.preset,responseStyleCustomInstructions:c.custom},t),x.current=c,a!==C.current)return;S.current=c,s(c.enabled),u(c.preset),f(c.custom)}catch(n){if(t===i()&&a===C.current){let t=x.current;S.current=t,t&&(s(t.enabled),u(t.preset),f(t.custom));let r=n instanceof Error?n.message:e(`settings.behavior.page.toast.saveFailed`);Y.error(r)}}};w.current=w.current.then(r,r)},400);return()=>clearTimeout(l)},[o,c,d,h,e,t]);let T=gc(c,d),E=n!==y;return(0,$.jsx)(Ur,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`yuri-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsx)(`div`,{className:`space-y-1`,children:(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground`,children:e(`settings.behavior.page.title`)})}),(0,$.jsx)(Z,{itemId:`behavior.system-prompt`,actions:(0,$.jsx)(q,{onClick:async()=>{let r=t;if(r===i()){v(!0);try{let t=mc(n),o=await l(`/api/behavior/agents-md`,{method:`PUT`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({content:t})});if(!o.ok)throw Error(await pc(o,e(`settings.behavior.page.toast.saveFailed`)));if(r!==i()||(await yc({globalBehaviorPrompt:t},e(`settings.behavior.page.toast.saveFailed`)),r!==i()))return;a(t),b(t),Y.success(e(`settings.behavior.page.toast.saved`))}catch(t){if(r!==i())return;console.error(`Failed to save behavior:`,t);let n=t instanceof Error?t.message:e(`settings.behavior.page.toast.saveFailed`);Y.error(n)}finally{r===i()&&v(!1)}}},disabled:_||!E||!p,size:`sm`,"aria-busy":_,children:e(_?`settings.common.actions.saving`:`settings.common.actions.saveChanges`)}),label:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:e(`settings.behavior.page.section.systemPrompt`)}),(0,$.jsxs)(En,{children:[(0,$.jsx)(wn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(Tn,{sideOffset:8,className:`max-w-xs`,children:(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`p`,{className:`font-medium text-foreground`,children:e(`settings.behavior.page.warning.title`)}),(0,$.jsx)(`p`,{children:e(`settings.behavior.page.warning.description`,{path:fc})})]})})]})]}),children:(0,$.jsx)(`div`,{className:`yuri-settings-group-row flex flex-col gap-3`,children:(0,$.jsx)(Wr,{embedded:!0,value:n,onChange:e=>a(e.target.value),placeholder:e(`settings.behavior.page.field.systemPromptPlaceholder`),rows:12,disabled:!p,outerClassName:`min-h-[160px] max-h-[70vh]`,className:`w-full font-mono typography-meta bg-transparent`})})}),(0,$.jsxs)(Z,{itemId:`behavior.response-style`,actions:(0,$.jsx)(Wi,{checked:o,onChange:s,disabled:!h,ariaLabel:e(`settings.behavior.page.responseStyle.enableAria`)}),label:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:e(`settings.behavior.page.section.responseStyle`)}),(0,$.jsxs)(En,{children:[(0,$.jsx)(wn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(Tn,{sideOffset:8,className:`max-w-xs`,children:e(`settings.behavior.page.responseStyle.tooltip`)})]})]}),children:[(0,$.jsx)(Xi,{label:e(`settings.behavior.page.responseStyle.preset`),children:(0,$.jsxs)(Fr,{value:c,onValueChange:e=>u(e),disabled:!h||!o,children:[(0,$.jsx)(Pr,{className:`w-full sm:w-56`,children:(0,$.jsx)(Ar,{children:t=>t===`custom`?e(`settings.behavior.page.responseStyle.option.custom`):gt(t)?e(vc[t]):null})}),(0,$.jsxs)(Nr,{children:[ut.map(t=>(0,$.jsx)(jr,{value:t,children:e(vc[t])},t)),(0,$.jsx)(jr,{value:`custom`,children:e(`settings.behavior.page.responseStyle.option.custom`)})]})]})}),(0,$.jsx)(`div`,{className:`yuri-settings-group-row`,children:(0,$.jsx)(Wr,{embedded:!0,value:T,onChange:e=>f(e.target.value),placeholder:e(`settings.behavior.page.responseStyle.customPlaceholder`),rows:5,disabled:!h||!o||c!==`custom`,outerClassName:`min-h-[120px]`,className:`w-full font-mono typography-meta bg-transparent`})})]})]})})},xc=e=>{let t=(0,Sa.c)(158),{onItemSelect:n}=e,{t:r}=Ge(),[i,a]=Q.useState(null),[o,s]=Q.useState(``),[c,l]=Q.useState(null),[u,d]=Q.useState(null),[f,p]=Q.useState(!1),[m,h]=Q.useState(null),{selectedCommandName:g,setSelectedCommand:_,setCommandDraft:v,createCommand:y,deleteCommand:b}=Xa(ne(Cc)),x=Tt(),S;t[0]===x.data?S=t[1]:(S=x.data??[],t[0]=x.data,t[1]=S);let C=S,w=At(),T;t[2]===w.data?T=t[3]:(T=w.data??[],t[2]=w.data,t[3]=T);let E=T,{refetch:D}=w,O,k;t[4]===D?(O=t[5],k=t[6]):(O=()=>{D()},k=[D],t[4]=D,t[5]=O,t[6]=k),Q.useEffect(O,k);let A;t[7]===E?A=t[8]:(A=new Set(E.map(wc)),t[7]=E,t[8]=A);let j=A,M;if(t[9]!==C||t[10]!==j){let e;t[12]===j?e=t[13]:(e=e=>!j.has(e.name),t[12]=j,t[13]=e),M=C.filter(e),t[9]=C,t[10]=j,t[11]=M}else M=t[11];let N=M,P,F;t[14]!==g||t[15]!==_||t[16]!==j?(P=()=>{g&&j.has(g)&&_(null)},F=[g,_,j],t[14]=g,t[15]=_,t[16]=j,t[17]=P,t[18]=F):(P=t[17],F=t[18]),Q.useEffect(P,F);let I;t[19]!==C||t[20]!==n||t[21]!==v||t[22]!==_?(I=()=>{let e=`new-command`,t=1;for(;C.some(t=>t.name===e);)e=`new-command-${t}`,t++;v({name:e,scope:`user`}),_(e),n?.()},t[19]=C,t[20]=n,t[21]=v,t[22]=_,t[23]=I):I=t[23];let L=I,R;t[24]===r?R=t[25]:(R=async e=>{if(Ja(e)){Y.error(r(`settings.commands.sidebar.toast.builtInCannotDelete`));return}l(e),d(`delete`)},t[24]=r,t[25]=R);let z=R,B;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(B=async e=>{Ja(e)&&(l(e),d(`reset`))},t[26]=B):B=t[26];let V=B,H;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(H=()=>{l(null),d(null)},t[27]=H):H=t[27];let U=H,W;t[28]!==c||t[29]!==u||t[30]!==b||t[31]!==r?(W=async()=>{!c||!u||(p(!0),await b(c.name)?(u===`delete`?Y.success(r(`settings.commands.sidebar.toast.commandDeleted`,{name:c.name})):Y.success(r(`settings.commands.sidebar.toast.commandReset`,{name:c.name})),U()):u===`delete`?Y.error(r(`settings.commands.sidebar.toast.deleteFailed`)):Y.error(r(`settings.commands.sidebar.toast.resetFailed`)),p(!1))},t[28]=c,t[29]=u,t[30]=b,t[31]=r,t[32]=W):W=t[32];let ee=W,te;t[33]!==C||t[34]!==v||t[35]!==_?(te=e=>{let t=e.name,n=1,r=`${t}-copy`;for(;C.some(e=>e.name===r);)n++,r=`${t}-copy-${n}`;v({name:r,scope:e.scope||`user`,description:e.description,template:e.template,agent:e.agent,model:e.model}),_(r)},t[33]=C,t[34]=v,t[35]=_,t[36]=te):te=t[36];let re=te,ie;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(ie=e=>{s(e.name),a(e)},t[37]=ie):ie=t[37];let ae=ie,oe;t[38]!==C||t[39]!==y||t[40]!==b||t[41]!==i||t[42]!==o||t[43]!==_||t[44]!==r?(oe=async()=>{if(!i)return;let e=o.trim().replace(/\s+/g,`-`);if(!e){Y.error(r(`settings.commands.sidebar.toast.commandNameRequired`));return}if(e===i.name){a(null);return}if(C.some(t=>t.name===e)){Y.error(r(`settings.commands.sidebar.toast.commandExists`));return}await y({name:e,description:i.description,template:i.template,agent:i.agent,model:i.model})?await b(i.name)?(Y.success(`Command renamed to "${e}"`),_(e)):Y.error(r(`settings.commands.sidebar.toast.removeOldAfterRenameFailed`)):Y.error(r(`settings.commands.sidebar.toast.renameFailed`)),a(null)},t[38]=C,t[39]=y,t[40]=b,t[41]=i,t[42]=o,t[43]=_,t[44]=r,t[45]=oe):oe=t[45];let se=oe,ce,le,ue;if(t[46]!==N||t[47]!==L||t[48]!==z||t[49]!==re||t[50]!==n||t[51]!==m||t[52]!==g||t[53]!==_||t[54]!==r){let e=N.filter(Ja),i=N.filter(Tc),a;t[58]===r?a=t[59]:(a=r(`settings.commands.sidebar.section.custom`),t[58]=r,t[59]=a);let o;t[60]===a?o=t[61]:(o=(0,$.jsx)(`span`,{children:a}),t[60]=a,t[61]=o);let s;t[62]===r?s=t[63]:(s=r(`settings.commands.page.title.new`),t[62]=r,t[63]=s);let c;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(X,{name:`add`,className:`h-4 w-4`}),t[64]=c):c=t[64];let l;t[65]!==L||t[66]!==s?(l=(0,$.jsx)(q,{"data-settings-item":`commands.create`,size:`icon`,variant:`ghost`,onClick:L,"aria-label":s,children:c}),t[65]=L,t[66]=s,t[67]=l):l=t[67];let u;t[68]!==o||t[69]!==l?(u=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[o,l]}),t[68]=o,t[69]=l,t[70]=u):u=t[70];let d=u;ce=`yuri-settings-page-content h-full overflow-y-auto bg-background p-3`,t[71]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,$.jsx)(Z,{children:(0,$.jsx)(`div`,{className:`yuri-settings-group-row`,children:(0,$.jsx)(To,{})})}),t[71]=le):le=t[71],ue=(0,$.jsx)($.Fragment,{children:N.length===0?(0,$.jsx)(Z,{label:d,children:(0,$.jsxs)(`div`,{className:`yuri-settings-group-row py-12 text-center text-muted-foreground`,children:[(0,$.jsx)(X,{name:`terminal-box`,className:`mx-auto mb-3 h-10 w-10 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-ui-label font-medium`,children:r(`settings.commands.sidebar.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:r(`settings.commands.sidebar.empty.description`)})]})}):(0,$.jsxs)($.Fragment,{children:[e.length>0&&(0,$.jsx)(Z,{label:r(`settings.commands.sidebar.section.builtIn`),children:[...e].sort(Ec).map(e=>(0,$.jsx)(Sc,{command:e,isSelected:g===e.name,onSelect:()=>{_(e.name),n?.()},onReset:()=>V(e),onDuplicate:()=>re(e),isMenuOpen:m===e.name,onMenuOpenChange:t=>h(t?e.name:null)},e.name))}),i.length>0?(0,$.jsx)(Z,{label:d,children:[...i].sort(Dc).map(e=>(0,$.jsx)(Sc,{command:e,isSelected:g===e.name,onSelect:()=>{_(e.name),n?.()},onRename:()=>ae(e),onDelete:()=>z(e),onDuplicate:()=>re(e),isMenuOpen:m===e.name,onMenuOpenChange:t=>h(t?e.name:null)},e.name))}):(0,$.jsx)(Z,{label:d,cardClassName:`hidden`,children:(0,$.jsx)(`span`,{})})]})}),t[46]=N,t[47]=L,t[48]=z,t[49]=re,t[50]=n,t[51]=m,t[52]=g,t[53]=_,t[54]=r,t[55]=ce,t[56]=le,t[57]=ue}else ce=t[55],le=t[56],ue=t[57];let de=c!==null&&u!==null,G;t[72]===f?G=t[73]:(G=e=>{!e&&!f&&U()},t[72]=f,t[73]=G);let fe;t[74]!==u||t[75]!==r?(fe=r(u===`delete`?`settings.commands.sidebar.dialog.deleteTitle`:`settings.commands.sidebar.dialog.resetTitle`),t[74]=u,t[75]=r,t[76]=fe):fe=t[76];let pe;t[77]===fe?pe=t[78]:(pe=(0,$.jsx)(mn,{children:fe}),t[77]=fe,t[78]=pe);let me;t[79]!==c?.name||t[80]!==u||t[81]!==r?(me=r(u===`delete`?`settings.commands.sidebar.dialog.deleteDescription`:`settings.commands.sidebar.dialog.resetDescription`,{name:c?.name??``}),t[79]=c?.name,t[80]=u,t[81]=r,t[82]=me):me=t[82];let he;t[83]===me?he=t[84]:(he=(0,$.jsx)(hn,{children:me}),t[83]=me,t[84]=he);let ge;t[85]!==pe||t[86]!==he?(ge=(0,$.jsxs)(dn,{children:[pe,he]}),t[85]=pe,t[86]=he,t[87]=ge):ge=t[87];let _e;t[88]===r?_e=t[89]:(_e=r(`settings.common.actions.cancel`),t[88]=r,t[89]=_e);let ve;t[90]!==f||t[91]!==_e?(ve=(0,$.jsx)(q,{size:`sm`,variant:`ghost`,onClick:U,disabled:f,children:_e}),t[90]=f,t[91]=_e,t[92]=ve):ve=t[92];let ye;t[93]!==u||t[94]!==r?(ye=r(u===`delete`?`settings.common.actions.delete`:`settings.common.actions.reset`),t[93]=u,t[94]=r,t[95]=ye):ye=t[95];let be;t[96]!==ee||t[97]!==f||t[98]!==ye?(be=(0,$.jsx)(q,{size:`sm`,onClick:ee,disabled:f,children:ye}),t[96]=ee,t[97]=f,t[98]=ye,t[99]=be):be=t[99];let xe;t[100]!==ve||t[101]!==be?(xe=(0,$.jsxs)(fn,{children:[ve,be]}),t[100]=ve,t[101]=be,t[102]=xe):xe=t[102];let Se;t[103]!==ge||t[104]!==xe?(Se=(0,$.jsxs)(pn,{className:`max-w-md`,children:[ge,xe]}),t[103]=ge,t[104]=xe,t[105]=Se):Se=t[105];let Ce;t[106]!==de||t[107]!==G||t[108]!==Se?(Ce=(0,$.jsx)(gn,{open:de,onOpenChange:G,children:Se}),t[106]=de,t[107]=G,t[108]=Se,t[109]=Ce):Ce=t[109];let we=i!==null,Te;t[110]===Symbol.for(`react.memo_cache_sentinel`)?(Te=e=>!e&&a(null),t[110]=Te):Te=t[110];let Ee;t[111]===r?Ee=t[112]:(Ee=r(`settings.commands.sidebar.renameDialog.title`),t[111]=r,t[112]=Ee);let De;t[113]===Ee?De=t[114]:(De=(0,$.jsx)(mn,{children:Ee}),t[113]=Ee,t[114]=De);let Oe=i?.name??``,ke;t[115]!==r||t[116]!==Oe?(ke=r(`settings.commands.sidebar.renameDialog.description`,{name:Oe}),t[115]=r,t[116]=Oe,t[117]=ke):ke=t[117];let Ae;t[118]===ke?Ae=t[119]:(Ae=(0,$.jsx)(hn,{children:ke}),t[118]=ke,t[119]=Ae);let je;t[120]!==De||t[121]!==Ae?(je=(0,$.jsxs)(dn,{children:[De,Ae]}),t[120]=De,t[121]=Ae,t[122]=je):je=t[122];let Me;t[123]===Symbol.for(`react.memo_cache_sentinel`)?(Me=e=>s(e.target.value),t[123]=Me):Me=t[123];let Ne;t[124]===r?Ne=t[125]:(Ne=r(`settings.commands.sidebar.renameDialog.placeholder`),t[124]=r,t[125]=Ne);let Pe;t[126]===se?Pe=t[127]:(Pe=e=>{e.key===`Enter`&&se()},t[126]=se,t[127]=Pe);let Fe;t[128]!==o||t[129]!==Ne||t[130]!==Pe?(Fe=(0,$.jsx)(Cn,{value:o,onChange:Me,placeholder:Ne,className:`text-foreground placeholder:text-muted-foreground`,onKeyDown:Pe}),t[128]=o,t[129]=Ne,t[130]=Pe,t[131]=Fe):Fe=t[131];let Ie;t[132]===Symbol.for(`react.memo_cache_sentinel`)?(Ie=()=>a(null),t[132]=Ie):Ie=t[132];let Le;t[133]===r?Le=t[134]:(Le=r(`settings.common.actions.cancel`),t[133]=r,t[134]=Le);let Re;t[135]===Le?Re=t[136]:(Re=(0,$.jsx)(q,{size:`sm`,variant:`ghost`,onClick:Ie,children:Le}),t[135]=Le,t[136]=Re);let ze;t[137]===r?ze=t[138]:(ze=r(`settings.common.actions.rename`),t[137]=r,t[138]=ze);let Be;t[139]!==se||t[140]!==ze?(Be=(0,$.jsx)(q,{size:`sm`,onClick:se,children:ze}),t[139]=se,t[140]=ze,t[141]=Be):Be=t[141];let Ve;t[142]!==Re||t[143]!==Be?(Ve=(0,$.jsxs)(fn,{children:[Re,Be]}),t[142]=Re,t[143]=Be,t[144]=Ve):Ve=t[144];let He;t[145]!==je||t[146]!==Fe||t[147]!==Ve?(He=(0,$.jsxs)(pn,{children:[je,Fe,Ve]}),t[145]=je,t[146]=Fe,t[147]=Ve,t[148]=He):He=t[148];let Ue;t[149]!==we||t[150]!==He?(Ue=(0,$.jsx)(gn,{open:we,onOpenChange:Te,children:He}),t[149]=we,t[150]=He,t[151]=Ue):Ue=t[151];let We;return t[152]!==ce||t[153]!==le||t[154]!==ue||t[155]!==Ce||t[156]!==Ue?(We=(0,$.jsxs)(`div`,{className:ce,children:[le,ue,Ce,Ue]}),t[152]=ce,t[153]=le,t[154]=ue,t[155]=Ce,t[156]=Ue,t[157]=We):We=t[157],We},Sc=e=>{let t=(0,Sa.c)(47),{command:n,isSelected:r,onSelect:i,onDelete:a,onReset:o,onRename:s,onDuplicate:c,isMenuOpen:l,onMenuOpenChange:u}=e,{t:d}=Ge(),f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f=Cr(),t[0]=f):f=t[0];let p=f,[m,h]=Q.useState(!1),g;t[1]!==a||t[2]!==c||t[3]!==s||t[4]!==o||t[5]!==d?(g=e=>(0,$.jsxs)($.Fragment,{children:[s&&(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),s()},children:[(0,$.jsx)(X,{name:`edit`,className:`h-4 w-4 mr-px`}),d(`settings.common.actions.rename`)]}),(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),c()},children:[(0,$.jsx)(X,{name:`file-copy`,className:`h-4 w-4 mr-px`}),d(`settings.common.actions.duplicate`)]}),o&&(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),o()},children:[(0,$.jsx)(X,{name:`restart`,className:`h-4 w-4 mr-px`}),d(`settings.common.actions.reset`)]}),a&&(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),a()},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(X,{name:`delete-bin`,className:`h-4 w-4 mr-px`}),d(`settings.common.actions.delete`)]})]}),t[1]=a,t[2]=c,t[3]=s,t[4]=o,t[5]=d,t[6]=g):g=t[6];let _=g,v=r?`bg-interactive-selection`:`hover:bg-interactive-hover`,y;t[7]===v?y=t[8]:(y=K(`yuri-settings-group-row group relative flex items-center transition-colors duration-150 select-none`,v),t[7]=v,t[8]=y);let b;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(b=p?void 0:e=>{e.preventDefault(),h(!0)},t[9]=b):b=t[9];let x;t[10]===y?x=t[11]:(x=(0,$.jsx)(`div`,{className:y,onContextMenu:b}),t[10]=y,t[11]=x);let S;t[12]===n.name?S=t[13]:(S=(0,$.jsxs)(`span`,{className:`typography-ui-label font-normal truncate text-foreground`,children:[`/`,n.name]}),t[12]=n.name,t[13]=S);let C;t[14]!==n||t[15]!==d?(C=(n.scope||Ja(n))&&(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-muted px-1 rounded flex-shrink-0 leading-none pb-px border border-border/50`,children:Ja(n)?d(`settings.agents.sidebar.badge.system`):n.scope}),t[14]=n,t[15]=d,t[16]=C):C=t[16];let w;t[17]!==S||t[18]!==C?(w=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[S,C]}),t[17]=S,t[18]=C,t[19]=w):w=t[19];let T;t[20]===n.description?T=t[21]:(T=n.description&&(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/60 truncate leading-tight`,children:n.description}),t[20]=n.description,t[21]=T);let E;t[22]!==i||t[23]!==T||t[24]!==w?(E=(0,$.jsxs)(`button`,{onClick:i,className:`flex min-w-0 flex-1 flex-col gap-0 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,tabIndex:0,children:[w,T]}),t[22]=i,t[23]=T,t[24]=w,t[25]=E):E=t[25];let D;t[26]===u?D=t[27]:(D=e=>{e&&h(!1),u(e)},t[26]=u,t[27]=D);let O;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(fr,{asChild:!0,children:(0,$.jsx)(q,{size:`sm`,variant:`ghost`,className:`h-6 w-6 px-0 flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100`,children:(0,$.jsx)(X,{name:`more-2`,className:`h-3.5 w-3.5`})})}),t[28]=O):O=t[28];let k;t[29]===_?k=t[30]:(k=(0,$.jsx)(Zn,{align:`end`,className:`w-fit min-w-20`,children:_(tr)}),t[29]=_,t[30]=k);let A;t[31]!==l||t[32]!==D||t[33]!==k?(A=(0,$.jsxs)($n,{open:l,onOpenChange:D,children:[O,k]}),t[31]=l,t[32]=D,t[33]=k,t[34]=A):A=t[34];let j;t[35]!==E||t[36]!==A?(j=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:[E,A]}),t[35]=E,t[36]=A,t[37]=j):j=t[37];let M;t[38]!==j||t[39]!==x?(M=(0,$.jsx)(na,{render:x,children:j}),t[38]=j,t[39]=x,t[40]=M):M=t[40];let N;t[41]===_?N=t[42]:(N=(0,$.jsx)(ra,{className:`w-fit min-w-20`,children:_(ia)}),t[41]=_,t[42]=N);let P;return t[43]!==m||t[44]!==M||t[45]!==N?(P=(0,$.jsxs)(aa,{open:m,onOpenChange:h,children:[M,N]}),t[43]=m,t[44]=M,t[45]=N,t[46]=P):P=t[46],P};function Cc(e){return{selectedCommandName:e.selectedCommandName,setSelectedCommand:e.setSelectedCommand,setCommandDraft:e.setCommandDraft,createCommand:e.createCommand,deleteCommand:e.deleteCommand}}function wc(e){return e.name}function Tc(e){return!Ja(e)}function Ec(e,t){return e.name.localeCompare(t.name)}function Dc(e,t){return e.name.localeCompare(t.name)}var Oc=()=>{let{t:e}=Ge(),{selectedCommandName:t,createCommand:n,updateCommand:r,commandDraft:i,setCommandDraft:a}=Xa(ne(e=>({selectedCommandName:e.selectedCommandName,createCommand:e.createCommand,updateCommand:e.updateCommand,commandDraft:e.commandDraft,setCommandDraft:e.setCommandDraft}))),o=Tt(),s=Q.useMemo(()=>o.data??[],[o.data]),c=t?s.find(e=>e.name===t):null,l=!!(i&&i.name===t&&!c),[u,d]=Q.useState(``),[f,p]=Q.useState(`user`),[m,h]=Q.useState(``),[g,_]=Q.useState(``),[v,y]=Q.useState(``),[b,x]=Q.useState(``),[S,C]=Q.useState(!1),w=Q.useRef(null);Q.useEffect(()=>{if(l&&i){let e=i.name||``,t=i.scope||`user`,n=i.description||``,r=i.agent||``,a=i.model||``,o=i.template||``;d(e),p(t),h(n),_(r),y(a),x(o),w.current={draftName:e,draftScope:t,description:n,agent:r,model:a,template:o}}else if(c){let e=c.description||``,t=c.agent||``,n=c.model||``,r=c.template||``;h(e),_(t),y(n),x(r),w.current={draftName:``,draftScope:`user`,description:e,agent:t,model:n,template:r}}},[c,l,t,s,i]);let T=Q.useMemo(()=>{let e=w.current;return e?!!(l&&(u!==e.draftName||f!==e.draftScope)||m!==e.description||g!==e.agent||v!==e.model||b!==e.template):!1},[g,m,u,f,l,v,b]);return t?(0,$.jsx)(Ur,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`yuri-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsx)(Gi,{actions:(0,$.jsxs)(q,{onClick:async()=>{let i=l?u.trim().replace(/\s+/g,`-`):t?.trim();if(!i){Y.error(e(`settings.commands.sidebar.toast.commandNameRequired`));return}if(!b.trim()){Y.error(e(`settings.commands.page.toast.templateRequired`));return}if(l&&s.some(e=>e.name===i)){Y.error(e(`settings.commands.sidebar.toast.commandExists`));return}C(!0);try{let t=g.trim(),o=v.trim(),s=b.trim(),c={name:i,description:m.trim()||void 0,agent:t===``?null:t,model:o===``?null:o,template:s,scope:l?f:void 0},u;l?(u=await n(c),u&&a(null)):u=await r(i,c),u?Y.success(e(l?`settings.commands.page.toast.created`:`settings.commands.page.toast.updated`)):Y.error(e(l?`settings.commands.page.toast.createFailed`:`settings.commands.page.toast.updateFailed`))}catch(t){console.error(`Error saving command:`,t),Y.error(e(`settings.commands.page.toast.saveUnexpectedError`))}finally{C(!1)}},disabled:S||!T,size:`sm`,"aria-busy":S,children:[S?(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin motion-reduce:animate-none`}):null,e(S?`settings.common.actions.saving`:`settings.common.actions.saveChanges`)]}),children:(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:l?e(`settings.commands.page.title.new`):`/${t}`}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground truncate`,children:e(l?`settings.commands.page.subtitle.new`:`settings.commands.page.subtitle.edit`)})]})}),(0,$.jsxs)(Z,{label:e(`settings.commands.page.section.identity`),children:[l&&(0,$.jsxs)(Xi,{itemId:`commands.name`,label:e(`settings.commands.page.field.commandName`),children:[(0,$.jsxs)(`div`,{className:`flex items-center`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground mr-1`,children:`/`}),(0,$.jsx)(Cn,{value:u,onChange:e=>d(e.target.value),placeholder:e(`settings.commands.page.field.commandNamePlaceholder`),className:`h-7 w-40 px-2`})]}),(0,$.jsxs)(Fr,{value:f,onValueChange:e=>p(e),children:[(0,$.jsx)(Pr,{className:`w-fit min-w-[100px]`,children:(0,$.jsx)(Ar,{placeholder:e(`settings.agents.page.field.scopePlaceholder`)})}),(0,$.jsxs)(Nr,{align:`end`,children:[(0,$.jsx)(jr,{value:`user`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(X,{name:`user-3`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:e(`settings.common.scope.global`)})]})}),(0,$.jsx)(jr,{value:`project`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(X,{name:`folder`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:e(`settings.common.scope.project`)})]})})]})]})]}),(0,$.jsx)(Xi,{label:e(`settings.common.field.description`),className:`yuri-settings-split-row-stacked`,children:(0,$.jsx)(Wr,{embedded:!0,value:m,onChange:e=>h(e.target.value),placeholder:e(`settings.commands.page.field.descriptionPlaceholder`),rows:2,className:`w-full resize-none min-h-[60px] bg-transparent`})})]}),(0,$.jsxs)(Z,{label:e(`settings.commands.page.section.executionContext`),children:[(0,$.jsx)(Xi,{itemId:`commands.agent`,label:e(`settings.commands.page.field.overrideAgent`),children:(0,$.jsx)(bi,{agentName:g,onChange:e=>_(e),className:`yuri-settings-inline-value`})}),(0,$.jsx)(Xi,{itemId:`commands.model`,label:e(`settings.agents.page.field.overrideModel`),children:(0,$.jsx)(ii,{providerId:Ht(v)?.providerId??``,modelId:Ht(v)?.modelId??``,onChange:(e,t)=>{y(e&&t?`${e}/${t}`:``)},className:`yuri-settings-inline-value`})})]}),(0,$.jsx)(Ui,{itemId:`commands.template`,label:e(`settings.commands.page.section.template`),description:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`code`,{className:`text-foreground`,children:`$ARGUMENTS`}),` `,e(`settings.commands.page.templateHint.userInput`),` ·`,` `,(0,$.jsx)(`code`,{className:`text-foreground`,children:"!`cmd`"}),` `,e(`settings.commands.page.templateHint.shellOutput`),` ·`,` `,(0,$.jsx)(`code`,{className:`text-foreground`,children:`@file`}),` `,e(`settings.commands.page.templateHint.fileContents`)]}),descriptionPlacement:`outside`,className:`yuri-settings-split-row-stacked`,children:(0,$.jsx)(Wr,{embedded:!0,value:b,onChange:e=>x(e.target.value),placeholder:e(`settings.commands.page.field.templatePlaceholder`),rows:12,className:`w-full font-mono typography-meta min-h-[160px] max-h-[60vh] bg-transparent resize-y`})})]})}):(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,$.jsxs)(`div`,{className:`text-center text-muted-foreground`,children:[(0,$.jsx)(X,{name:`terminal-box`,className:`mx-auto mb-3 h-12 w-12 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.commands.page.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:e(`settings.commands.page.empty.description`)})]})})},kc=[],Ac=e=>{switch(e){case`connected`:return`success`;case`failed`:return`error`;case`needs_auth`:case`needs_client_registration`:return`warning`;default:return`idle`}},jc=e=>{let t=(0,Sa.c)(5),{tone:n,enabled:r}=e;if(!r){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`span`,{className:`inline-block h-2 w-2 rounded-full bg-muted-foreground/30 flex-shrink-0`}),t[0]=e):e=t[0],e}let i;t[1]===n?i=t[2]:(i=K(`inline-block h-2 w-2 rounded-full flex-shrink-0`,{success:`bg-[var(--status-success)]`,error:`bg-[var(--status-error)]`,warning:`bg-[var(--status-warning)]`,idle:`bg-muted-foreground/40`}[n]),t[1]=n,t[2]=i);let a;return t[3]===i?a=t[4]:(a=(0,$.jsx)(`span`,{className:i}),t[3]=i,t[4]=a),a},Mc=e=>{let t=(0,Sa.c)(115),{onItemSelect:n}=e,{t:r}=Ge(),{selectedMcpName:a,setSelectedMcp:o,setMcpDraft:s,deleteMcp:c}=no(ne(Nc)),l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=Bi(),t[0]=l):l=t[0];let u=l,d=Fi(u),f=Li(u),p=d.data??kc,m;t[1]===f.data?m=t[2]:(m=f.data??{},t[1]=f.data,t[2]=m);let h=m,[g,_]=Q.useState(null),[v,y]=Q.useState(!1),[b,x]=Q.useState(null),[S,C]=Q.useState(null),[w,T]=Q.useState(!1),E;t[3]===p?E=t[4]:(E=p.filter(Pc),t[3]=p,t[4]=E);let D=E,O;t[5]===p?O=t[6]:(O=p.filter(Fc),t[5]=p,t[6]=O);let k=O,A;t[7]===w?A=t[8]:(A=()=>{if(w)return;T(!0);let e=new Promise(Ic),t=i();Promise.all([Ri(Oe,u,t),e]).catch(Lc).finally(()=>{T(!1)})},t[7]=w,t[8]=A);let j=A,M;t[9]!==p||t[10]!==n||t[11]!==s||t[12]!==o?(M=()=>{let e=`new-mcp-server`,t=1;for(;p.some(t=>t.name===e);)e=`new-mcp-server-${t}`,t++;s({name:e,scope:`user`,type:`local`,command:[],url:``,environment:[],headers:[],oauthEnabled:!0,oauthClientId:``,oauthClientSecret:``,oauthScope:``,oauthRedirectUri:``,timeout:``,enabled:!0}),o(e),n?.()},t[9]=p,t[10]=n,t[11]=s,t[12]=o,t[13]=M):M=t[13];let N=M,P;t[14]!==c||t[15]!==g||t[16]!==r?(P=async()=>{if(!g)return;y(!0);let e=await c(g.name,{directory:Bi(),transportIdentity:i()});e.ok?e.reloadFailed?Y.warning(e.message||`MCP server "${g.name}" deleted, but OpenCode reload failed`,{description:e.warning||r(`settings.mcp.sidebar.toast.refreshListIfStale`)}):Y.success(e.message||r(`settings.mcp.sidebar.toast.serverDeleted`,{name:g.name})):Y.error(r(`settings.mcp.sidebar.toast.deleteFailed`)),_(null),y(!1)},t[14]=c,t[15]=g,t[16]=r,t[17]=P):P=t[17];let F=P,I;t[18]===r?I=t[19]:(I=(e,t)=>(0,$.jsxs)(t,{onClick:t=>{t.stopPropagation(),_(e)},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(X,{name:`delete-bin`,className:`h-4 w-4 mr-px`}),r(`settings.common.actions.delete`)]}),t[18]=r,t[19]=I);let L=I,R;t[20]===r?R=t[21]:(R=r(`settings.mcp.sidebar.group.userServers`),t[20]=r,t[21]=R);let z;t[22]===R?z=t[23]:(z=(0,$.jsx)(`span`,{children:R}),t[22]=R,t[23]=z);let B;t[24]===r?B=t[25]:(B=r(`settings.mcp.sidebar.actions.refreshStatusAria`),t[24]=r,t[25]=B);let V;t[26]===r?V=t[27]:(V=r(`settings.mcp.sidebar.actions.refreshStatusTitle`),t[26]=r,t[27]=V);let H=w&&`animate-spin`,U;t[28]===H?U=t[29]:(U=K(`h-4 w-4`,H),t[28]=H,t[29]=U);let W;t[30]===U?W=t[31]:(W=(0,$.jsx)(X,{name:`refresh`,className:U}),t[30]=U,t[31]=W);let ee;t[32]!==j||t[33]!==w||t[34]!==B||t[35]!==V||t[36]!==W?(ee=(0,$.jsx)(q,{type:`button`,size:`icon`,variant:`ghost`,disabled:w,onClick:j,"aria-label":B,title:V,children:W}),t[32]=j,t[33]=w,t[34]=B,t[35]=V,t[36]=W,t[37]=ee):ee=t[37];let te;t[38]===r?te=t[39]:(te=r(`settings.mcp.sidebar.actions.addServerTitle`),t[38]=r,t[39]=te);let re;t[40]===r?re=t[41]:(re=r(`settings.mcp.sidebar.actions.addServerTitle`),t[40]=r,t[41]=re);let ie;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,$.jsx)(X,{name:`add`,className:`h-4 w-4`}),t[42]=ie):ie=t[42];let ae;t[43]!==N||t[44]!==te||t[45]!==re?(ae=(0,$.jsx)(q,{"data-settings-item":`mcp.create`,size:`icon`,variant:`ghost`,onClick:N,"aria-label":te,title:re,children:ie}),t[43]=N,t[44]=te,t[45]=re,t[46]=ae):ae=t[46];let oe;t[47]!==ee||t[48]!==ae?(oe=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[ee,ae]}),t[47]=ee,t[48]=ae,t[49]=oe):oe=t[49];let se;t[50]!==z||t[51]!==oe?(se=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[z,oe]}),t[50]=z,t[51]=oe,t[52]=se):se=t[52];let ce=se,le;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,$.jsx)(Z,{children:(0,$.jsx)(`div`,{className:`yuri-settings-group-row`,children:(0,$.jsx)(To,{})})}),t[53]=le):le=t[53];let ue;t[54]!==d.data||t[55]!==d.error||t[56]!==d.isError||t[57]!==p.length||t[58]!==h||t[59]!==n||t[60]!==b||t[61]!==D||t[62]!==L||t[63]!==S||t[64]!==a||t[65]!==s||t[66]!==o||t[67]!==f.data||t[68]!==f.error||t[69]!==f.isError||t[70]!==r||t[71]!==k||t[72]!==ce?(ue=(0,$.jsx)($.Fragment,{children:d.isError&&!d.data?(0,$.jsx)(Z,{label:ce,children:(0,$.jsx)(`div`,{className:`yuri-settings-group-row py-12 text-center typography-meta text-[var(--status-error)]`,children:d.error.message})}):p.length===0?(0,$.jsx)(Z,{label:ce,children:(0,$.jsxs)(`div`,{className:`yuri-settings-group-row py-12 text-center text-muted-foreground`,children:[(0,$.jsx)(X,{name:`plug`,className:`mx-auto mb-3 h-10 w-10 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-ui-label font-medium`,children:r(`settings.mcp.sidebar.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:r(`settings.mcp.sidebar.empty.description`)})]})}):(0,$.jsxs)($.Fragment,{children:[D.length>0&&(0,$.jsx)(Z,{label:r(`settings.mcp.sidebar.group.projectServers`),children:D.map(e=>{let t=Ac((h[e.name]??(f.isError&&!f.data?{status:`failed`,error:f.error.message}:void 0))?.status),i=a===e.name,c=Cr();return(0,$.jsxs)(aa,{open:S===e.name,onOpenChange:t=>C(t?e.name:null),children:[(0,$.jsxs)(na,{render:(0,$.jsx)(`div`,{className:K(`yuri-settings-group-row group relative flex items-center transition-colors duration-150 select-none`,i?`bg-interactive-selection`:`hover:bg-interactive-hover`),onContextMenu:c?void 0:t=>{t.preventDefault(),C(e.name)}}),children:[(0,$.jsxs)(`button`,{onClick:()=>{o(e.name),s(null),n?.()},className:`flex min-w-0 flex-1 flex-col gap-0 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(jc,{tone:t,enabled:e.enabled}),(0,$.jsx)(`span`,{className:`typography-ui-label font-normal truncate text-foreground`,children:e.name}),(0,$.jsx)(`span`,{title:e.type===`local`?r(`settings.mcp.sidebar.serverType.localTitle`):r(`settings.mcp.sidebar.serverType.remoteTitle`),children:e.type===`local`?(0,$.jsx)(X,{name:`server`,className:`h-3 w-3 text-muted-foreground/60 flex-shrink-0`}):(0,$.jsx)(X,{name:`global`,className:`h-3 w-3 text-muted-foreground/60 flex-shrink-0`})})]}),(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/60 truncate leading-tight pl-4`,children:e.type===`local`?e.command?.join(` `)??``:e.url??``})]}),(0,$.jsxs)($n,{open:b===e.name,onOpenChange:t=>{t&&C(null),x(t?e.name:null)},children:[(0,$.jsx)(fr,{asChild:!0,children:(0,$.jsx)(q,{size:`xs`,variant:`ghost`,className:`flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100`,children:(0,$.jsx)(X,{name:`more-2`,className:`h-3.5 w-3.5`})})}),(0,$.jsx)(Zn,{align:`end`,className:`w-fit min-w-20`,children:L(e,tr)})]})]}),(0,$.jsx)(ra,{className:`w-fit min-w-20`,children:L(e,ia)})]},e.name)})}),k.length>0&&(0,$.jsx)(Z,{label:ce,children:k.map(e=>{let t=Ac((h[e.name]??(f.isError&&!f.data?{status:`failed`,error:f.error.message}:void 0))?.status),i=a===e.name,c=Cr();return(0,$.jsxs)(aa,{open:S===e.name,onOpenChange:t=>C(t?e.name:null),children:[(0,$.jsxs)(na,{render:(0,$.jsx)(`div`,{className:K(`yuri-settings-group-row group relative flex items-center transition-colors duration-150 select-none`,i?`bg-interactive-selection`:`hover:bg-interactive-hover`),onContextMenu:c?void 0:t=>{t.preventDefault(),C(e.name)}}),children:[(0,$.jsxs)(`button`,{onClick:()=>{o(e.name),s(null),n?.()},className:`flex min-w-0 flex-1 flex-col gap-0 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(jc,{tone:t,enabled:e.enabled}),(0,$.jsx)(`span`,{className:`typography-ui-label font-normal truncate text-foreground`,children:e.name}),(0,$.jsx)(`span`,{title:e.type===`local`?r(`settings.mcp.sidebar.serverType.localTitle`):r(`settings.mcp.sidebar.serverType.remoteTitle`),children:e.type===`local`?(0,$.jsx)(X,{name:`server`,className:`h-3 w-3 text-muted-foreground/60 flex-shrink-0`}):(0,$.jsx)(X,{name:`global`,className:`h-3 w-3 text-muted-foreground/60 flex-shrink-0`})})]}),(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/60 truncate leading-tight pl-4`,children:e.type===`local`?e.command?.join(` `)??``:e.url??``})]}),(0,$.jsxs)($n,{open:b===e.name,onOpenChange:t=>{t&&C(null),x(t?e.name:null)},children:[(0,$.jsx)(fr,{asChild:!0,children:(0,$.jsx)(q,{size:`xs`,variant:`ghost`,className:`flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100`,children:(0,$.jsx)(X,{name:`more-2`,className:`h-3.5 w-3.5`})})}),(0,$.jsx)(Zn,{align:`end`,className:`w-fit min-w-20`,children:L(e,tr)})]})]}),(0,$.jsx)(ra,{className:`w-fit min-w-20`,children:L(e,ia)})]},e.name)})}),k.length===0&&(0,$.jsx)(Z,{label:ce,cardClassName:`hidden`,children:(0,$.jsx)(`span`,{})})]})}),t[54]=d.data,t[55]=d.error,t[56]=d.isError,t[57]=p.length,t[58]=h,t[59]=n,t[60]=b,t[61]=D,t[62]=L,t[63]=S,t[64]=a,t[65]=s,t[66]=o,t[67]=f.data,t[68]=f.error,t[69]=f.isError,t[70]=r,t[71]=k,t[72]=ce,t[73]=ue):ue=t[73];let de=g!==null,G;t[74]===v?G=t[75]:(G=e=>{!e&&!v&&_(null)},t[74]=v,t[75]=G);let fe;t[76]===r?fe=t[77]:(fe=r(`settings.mcp.sidebar.deleteDialog.title`),t[76]=r,t[77]=fe);let pe;t[78]===fe?pe=t[79]:(pe=(0,$.jsx)(mn,{children:fe}),t[78]=fe,t[79]=pe);let me=g?.name||``,he;t[80]!==r||t[81]!==me?(he=r(`settings.mcp.sidebar.deleteDialog.descriptionPrefix`,{name:me}),t[80]=r,t[81]=me,t[82]=he):he=t[82];let ge;t[83]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,$.jsx)(`code`,{className:`text-foreground`,children:`opencode.json`}),t[83]=ge):ge=t[83];let _e;t[84]===he?_e=t[85]:(_e=(0,$.jsxs)(hn,{children:[he,` `,ge,`.`]}),t[84]=he,t[85]=_e);let ve;t[86]!==pe||t[87]!==_e?(ve=(0,$.jsxs)(dn,{children:[pe,_e]}),t[86]=pe,t[87]=_e,t[88]=ve):ve=t[88];let ye;t[89]===Symbol.for(`react.memo_cache_sentinel`)?(ye=()=>_(null),t[89]=ye):ye=t[89];let be;t[90]===r?be=t[91]:(be=r(`settings.common.actions.cancel`),t[90]=r,t[91]=be);let xe;t[92]!==v||t[93]!==be?(xe=(0,$.jsx)(q,{size:`sm`,variant:`ghost`,onClick:ye,disabled:v,children:be}),t[92]=v,t[93]=be,t[94]=xe):xe=t[94];let Se;t[95]!==v||t[96]!==r?(Se=r(v?`settings.mcp.sidebar.actions.deleting`:`settings.common.actions.delete`),t[95]=v,t[96]=r,t[97]=Se):Se=t[97];let Ce;t[98]!==F||t[99]!==v||t[100]!==Se?(Ce=(0,$.jsx)(q,{size:`sm`,onClick:F,disabled:v,children:Se}),t[98]=F,t[99]=v,t[100]=Se,t[101]=Ce):Ce=t[101];let we;t[102]!==xe||t[103]!==Ce?(we=(0,$.jsxs)(fn,{children:[xe,Ce]}),t[102]=xe,t[103]=Ce,t[104]=we):we=t[104];let Te;t[105]!==ve||t[106]!==we?(Te=(0,$.jsxs)(pn,{className:`max-w-md`,children:[ve,we]}),t[105]=ve,t[106]=we,t[107]=Te):Te=t[107];let Ee;t[108]!==de||t[109]!==G||t[110]!==Te?(Ee=(0,$.jsx)(gn,{open:de,onOpenChange:G,children:Te}),t[108]=de,t[109]=G,t[110]=Te,t[111]=Ee):Ee=t[111];let De;return t[112]!==ue||t[113]!==Ee?(De=(0,$.jsxs)(`div`,{className:`yuri-settings-page-content h-full overflow-y-auto bg-background p-3`,children:[le,ue,Ee]}),t[112]=ue,t[113]=Ee,t[114]=De):De=t[114],De};function Nc(e){return{selectedMcpName:e.selectedMcpName,setSelectedMcp:e.setSelectedMcp,setMcpDraft:e.setMcpDraft,deleteMcp:e.deleteMcp}}function Pc(e){return e.scope===`project`}function Fc(e){return e.scope!==`project`}function Ic(e){return setTimeout(e,500)}function Lc(e){Y.error(e instanceof Error?e.message:String(e))}function Rc(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function zc(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function Bc(e,t){return t===void 0?{ok:!1,error:e}:{ok:!1,error:e,parsed:t}}function Vc(e,t,n){return{ok:!0,name:e,type:t,command:Hc(n),url:typeof n.url==`string`?n.url.trim():``,environment:Uc(n,`env`,`environment`),headers:Uc(n,`headers`),oauthEnabled:Wc(n),oauthClientId:typeof n.oauth==`object`&&n.oauth!==null?String(n.oauth.clientId??``).trim():``,oauthClientSecret:typeof n.oauth==`object`&&n.oauth!==null?String(n.oauth.clientSecret??``).trim():``,oauthScope:typeof n.oauth==`object`&&n.oauth!==null?String(n.oauth.scope??``).trim():``,oauthRedirectUri:typeof n.oauth==`object`&&n.oauth!==null?String(n.oauth.redirectUri??``).trim():``,timeout:Gc(n),enabled:Kc(n)}}function Hc(e){let t=e.command,n=e.args;if(zc(t)&&zc(n))return[...t,...n];if(zc(t))return t;if(typeof t==`string`&&t.trim()){let e=t.trim().split(/\s+/);return zc(n)?[...e,...n]:e}return zc(n)?n:[]}function Uc(e,...t){for(let n of t){let t=e[n];if(!Rc(t))continue;let r=Object.entries(t).filter(([e,t])=>e&&typeof t==`string`);if(r.length>0)return r.map(([e,t])=>({key:e,value:String(t)}))}return[]}function Wc(e){if(e.oauth===!1||e.oauth===null||e.oauth===void 0||!Rc(e.oauth))return!1;let t=e.oauth;return!!(typeof t.clientId==`string`&&t.clientId.trim()||typeof t.clientSecret==`string`&&t.clientSecret.trim()||typeof t.scope==`string`&&t.scope.trim()||typeof t.redirectUri==`string`&&t.redirectUri.trim())}function Gc(e){let t=e.timeout;if(typeof t==`number`&&Number.isFinite(t)&&t>0)return String(Math.floor(t));if(typeof t==`string`&&t.trim()){let e=Number(t);if(Number.isFinite(e)&&e>0)return String(Math.floor(e))}return``}function Kc(e){return`disabled`in e&&e.disabled===!0?!1:`enabled`in e?!!e.enabled:!0}function qc(e){let t=e.mcpServers;if(Rc(t)){let e=Object.keys(t);if(e.length===1){let n=e[0],r=t[n];if(Rc(r))return{name:n,entry:r}}if(e.length>1)return null}let n=Object.keys(e).filter(t=>{let n=e[t];return t!==`mcpServers`&&Rc(n)});if(n.length===1){let t=n[0],r=e[t];if(Jc(r))return{name:t,entry:r}}return null}function Jc(e){return e.type===`local`||e.type===`remote`||Array.isArray(e.command)||typeof e.url==`string`||Array.isArray(e.args)}function Yc(e,t){let n;try{let t=e.trim();if(!t)return Bc(`No JSON content provided`);n=JSON.parse(t)}catch(e){return Bc(e instanceof Error?`Invalid JSON: ${e.message}`:`Invalid JSON`)}if(!Rc(n))return Bc(`Expected a JSON object, not an array or primitive`);let r=n,i=r.mcpServers;if(Rc(i)){let e=Object.keys(i);if(e.length===0)return Bc(`mcpServers object is empty`,n);if(e.length>1)return Bc(`Paste one server at a time. Found `+e.length+` servers in mcpServers`,n);let t=e[0],r=i[t];return Rc(r)?Vc(t,Xc(r),r):Bc(`Server entry is not a valid object`,n)}let a=r.mcp;if(Rc(a)){let e=Object.keys(a);if(e.length===0)return Bc(`mcp object is empty`,n);if(e.length>1)return Bc(`Paste one server at a time. Found `+e.length+` servers in mcp`,n);let t=e[0],r=a[t];return Rc(r)?Vc(t,Xc(r),r):Bc(`Server entry in mcp is not a valid object`,n)}let o=qc(r);if(o)return Vc(o.name,Xc(o.entry),o.entry);if(Jc(r)){let e=Xc(r);return Vc(typeof r.name==`string`&&r.name.trim()?r.name.trim():t?.fallbackName,e,r)}return Bc(`No recognizable MCP server configuration found in JSON`,n)}function Xc(e){return e.type===`remote`?`remote`:e.type===`local`?`local`:typeof e.url==`string`&&e.url.trim()?`remote`:(Array.isArray(e.command)||typeof e.command==`string`||Array.isArray(e.args),`local`)}function Zc(e,t,n){let r=n?.isNewServer??!1,i=e.name,a=r&&i?i:t.name??``;return{...t,name:a,type:e.type,command:e.type===`local`?e.command:[],url:e.type===`remote`?e.url:``,environment:e.environment,headers:e.type===`remote`?e.headers:[],oauthEnabled:e.type===`remote`&&e.oauthEnabled,oauthClientId:e.type===`remote`?e.oauthClientId:``,oauthClientSecret:e.type===`remote`?e.oauthClientSecret:``,oauthScope:e.type===`remote`?e.oauthScope:``,oauthRedirectUri:e.type===`remote`?e.oauthRedirectUri:``,timeout:e.type===`remote`?e.timeout:``,enabled:e.enabled}}function Qc(e){let t=[],n=``,r=!1,i=!1;for(let a=0;a<e.length;a++){let o=e[a];if(o===`'`&&!i){r=!r;continue}if(o===`"`&&!r){i=!i;continue}if((o===` `||o===` `)&&!r&&!i){n&&=(t.push(n),``);continue}n+=o}return n&&t.push(n),t}function $c(e){let t=e.trim();if(!t)return{code:null};try{let e=new URL(t).searchParams.get(`code`);if(typeof e==`string`&&e.trim())return{code:e.trim()}}catch{}return{code:t}}var el=({value:e,onChange:t,pasteCommandTitle:n,pasteCommandLabel:r,pasteSuccess:i,clipboardReadFailed:a,preview:o})=>{let[s,c]=Q.useState(()=>e.join(`
1
+ import{n as e,r as t}from"./rolldown-runtime-hePW80VL.js";import{E as n}from"./runtime-auth-DBn9yahL.js";import{c as r,i,l as a,n as o,r as s,t as c}from"./runtime-switch-DEZ1K7qW.js";import{n as l}from"./runtime-fetch-D0YWp3FJ.js";import{C as u,E as d,F as f,H as p,L as m,S as h,T as g,U as _,V as v,d as y,f as b,i as x,m as S,p as C,q as w,s as T,t as E,v as D,x as O,y as k}from"./desktop-BAmoc_34.js";import{t as A}from"./runtimeAPIRegistry-C2VogTny.js";import{_ as j,a as M,d as N,f as P,g as F,h as I,i as L,n as R,r as z,s as B,t as V,v as H}from"./desktopHosts-BLU1tGSX.js";import{n as U}from"./desktopRelayRestore-2BIIs8mZ.js";import{a as W,i as ee,r as te,t as ne}from"./vendor-zustand-vDaAPGfl.js";import{at as re,ot as ie,st as ae}from"./vendor-base-ui-CzHs0bHY.js";import{At as oe,Pn as se,bt as ce}from"./gitApiHttp-CKrsk1tw.js";import"./brand-storage-bootstrap-D4BW3w-M.js";import{c as le,d as ue,h as de,r as G,u as fe,w as pe}from"./useUIStore-B61bCFEM.js";import{O as me,c as he,f as ge,k as _e,l as ve,o as ye,tt as be,z as xe}from"./bootstrap-Bi91NjXG.js";import{n as Se}from"./vendor-react-DlzBev0S.js";import{i as Ce,l as we,n as Te,o as Ee,s as De}from"./vendor-tanstack-react-query-B-Wpqq5J.js";import{a as Oe}from"./queryRuntime-2dx7jbt9.js";import{u as ke}from"./fileQueries-C2Rs6TPz.js";import{n as Ae,t as je}from"./platform-sEg2IOLZ.js";import{a as Me,i as Ne,n as Pe}from"./types-djs5o8aQ.js";import{t as Fe}from"./native-config-C8AlS30O.js";import{Q as Ie,S as Le,U as Re,lt as ze}from"./vendor-codemirror-autocomplete-C0FrlFqZ.js";import{r as Be}from"./vendor-sonner-BEHGipm5.js";import{a as Ve,i as He,s as Ue}from"./vendor-reactuses-core-DWo5Wn6R.js";import{d as We,f as Ge,n as Ke,o as qe,p as Je,r as K,t as q}from"./button-B7w-b2yV.js";import{i as Ye}from"./store-CVmc1U19.js";import{i as Xe,r as Ze}from"./MobileShareBridge-D8oRgnuW.js";import{_ as Qe,a as $e,d as et,g as tt,h as nt,i as rt,m as it,t as at,v as ot,x as st}from"./MobileDetailNavigation-CaO-fGvE.js";import{$i as ct,$n as lt,Ai as ut,Br as dt,Di as ft,Ei as pt,Gi as mt,Hi as ht,Ji as gt,Ki as _t,Qi as vt,Qn as yt,Ui as bt,W as xt,Xi as St,Xr as Ct,Yi as wt,Zi as Tt,aa as Et,an as Dt,ba as Ot,ca as kt,da as At,ea as jt,ei as J,er as Mt,fa as Nt,fi as Pt,ha as Y,ia as Ft,ji as It,ki as Lt,ma as Rt,na as zt,oa as Bt,oi as Vt,p as Ht,pa as Ut,qi as Wt,qr as Gt,ra as Kt,s as qt,sa as Jt,si as Yt,ta as Xt,ua as Zt,va as Qt,ya as $t}from"./useMobileNavigationStore-DRBFwjAg.js";import{i as en}from"./useAssistantUIStore-cHle1U5H.js";import{c as tn,d as nn,f as rn,l as an,o as on,s as sn,t as cn,u as ln}from"./AgentAvatar-D4JLZ7IL.js";import{n as un}from"./useThemeSystem-CNzUUkFn.js";import{n as X}from"./Icon-D7VxRqha.js";import{a as dn,i as fn,n as pn,o as mn,r as hn,t as gn}from"./dialog-gc3n4NXh.js";import{B as _n,H as vn,R as yn,U as bn,W as xn,z as Sn}from"./gitApi-CJS823P8.js";import{t as Cn}from"./input-B7yPcQsA.js";import{i as wn,n as Tn,t as En}from"./tooltip-L2xweVkb.js";import{$ as Dn,A as On,At as kn,B as An,Ct as jn,D as Mn,Dt as Nn,Et as Pn,Ft as Fn,Gt as In,Ht as Ln,I as Rn,Kt as zn,M as Bn,Mt as Vn,N as Hn,Nt as Un,O as Wn,Ot as Gn,P as Kn,St as qn,T as Jn,Tt as Yn,Ut as Xn,X as Zn,Xt as Qn,Y as $n,Yt as er,Z as tr,a as nr,ct as rr,et as ir,ft as ar,ht as or,i as sr,jt as cr,kt as lr,l as ur,mt as dr,nt as fr,ot as pr,pt as mr,qt as hr,r as gr,rt as _r,st as vr,w as yr,wt as br,xt as xr}from"./pwa-CbR9DKyA.js";import{t as Sr}from"./YuriLogo-DADSHd1H.js";import{n as Cr,r as wr}from"./device-w1ioiqv3.js";import{c as Tr,l as Er,s as Dr,t as Or,u as kr}from"./scheduledTaskNavigation-7dD6PWMD.js";import{c as Ar,i as jr,l as Mr,n as Nr,s as Pr,t as Fr}from"./select-WCptRb7Z.js";import{M as Ir,k as Lr,n as Rr}from"./appThemeRegistry-Bz6WZldU.js";import{n as zr}from"./MarkdownRenderer-DjSn61IL.js";import{a as Br}from"./url-MRa-FtQa.js";import{a as Vr}from"./toolHelpers-iEHVHQ9p.js";import{a as Hr}from"./react-a6PrrNTm.js";import{n as Ur,t as Wr}from"./textarea-CMVUhwQ2.js";import{a as Gr,i as Kr,n as qr}from"./projectMeta-A8jJRQk7.js";import{t as Jr}from"./sortable-tabs-strip-DFKCoZZF.js";import{a as Yr}from"./markdownHeightCache-CLiBBW4n.js";import{C as Xr,D as Zr,F as Qr,H as $r,I as ei,J as ti,K as ni,L as ri,M as ii,N as ai,P as oi,R as si,S as ci,T as li,V as ui,X as di,Y as fi,Z as pi,_ as mi,b as hi,c as gi,f as _i,h as vi,i as yi,j as bi,l as xi,m as Si,o as Ci,p as wi,q as Ti,s as Ei,t as Di,u as Oi,v as ki,w as Ai,x as ji,y as Mi,z as Ni}from"./MobileTabPageHeader-CkuLCAUz.js";import{a as Pi,c as Fi,i as Ii,l as Li,o as Ri,r as zi,s as Bi}from"./mcpQueries-JrS0Bvb3.js";import{a as Vi,c as Hi,d as Ui,f as Z,g as Wi,h as Gi,i as Ki,l as qi,m as Ji,o as Yi,p as Xi,r as Zi,s as Qi,t as $i,u as ea}from"./usePluginsStore-Bav6NFUH.js";import{n as ta}from"./mobileBackNavigation-BMaLnPn4.js";import{a as na,n as ra,r as ia,t as aa}from"./context-menu-BXHMb3Q-.js";import{n as oa,r as sa,t as ca}from"./collapsible-DZ4ykYM2.js";import{t as la}from"./vendor-qrcode-D7jBCyl-.js";import{a as ua,c as da,i as fa,l as pa,o as ma,s as ha,t as ga}from"./VoiceSettings-BEtahqoU.js";import{n as _a,t as va}from"./readiness-BpeOajK9.js";import{t as ya}from"./GuiPluginWindow-DlnxZgDZ.js";import{n as ba,t as xa}from"./vendor-yaml-C9KlJAlj.js";var Sa=Se(),Ca=t(re(),1),Q=t(ae(),1),$=ie(),wa=`https://github.com/yee94/yuri`,Ta=`${wa}/issues/new`,Ea=800,Da={"manual-global":`settings.yuri.about.opencodeManagement.manual-global`,"manual-external":`settings.yuri.about.opencodeManagement.manual-external`,bundled:`settings.yuri.about.opencodeManagement.bundled`,"in-app":`settings.yuri.about.opencodeManagement.in-app`,none:`settings.yuri.about.opencodeManagement.none`},Oa=e=>typeof e==`string`&&e.trim()?e.trim():null,ka=(e,t,n)=>({queryKey:[t,`about`,n,e],queryFn:async({signal:r})=>{if(t!==i()||n!==o())throw Error(`Stale About runtime`);let a=await l(e,{method:`GET`,headers:{Accept:`application/json`},signal:r});if(!a.ok)throw Error(`About snapshot: ${a.status}`);let s=await a.json();if(!s||typeof s!=`object`||Array.isArray(s))throw Error(`Invalid About snapshot`);if(r.aborted||t!==i()||n!==o())throw Error(`Stale About runtime`);return s},retry:!1,staleTime:3e4}),Aa=({initialUpdateDialogOpen:e=!1})=>{let{t}=Ge(),[n,a]=Q.useState(e),[s,c]=Q.useState(!1),[l,d]=Q.useState(!1),[f,p]=Q.useState(null),[m,h]=Q.useState(null),g=Q.useSyncExternalStore(r,i,i),_=Q.useSyncExternalStore(r,o,o),v=De(ka(`/api/system/info`,g,_)),y=De(ka(`/api/opencode/upgrade-status`,g,_)),b=Oa(v.data?.yuriVersion),x=y.data,S=Oa(x?.serveVersion)??Oa(x?.currentVersion),C=Oa(x?.management),w=C&&Object.hasOwn(Da,C)?Da[C]:null,E=x?.canManage===!1&&w?t(w):null,D=S&&E?t(`settings.yuri.about.opencodeVersionWithManagement`,{version:S,management:E}):S,k=x?.canManage===!1?C===`manual-global`?t(`settings.yuri.about.opencodeGuidance.manualGlobal`):C===`manual-external`?t(`settings.yuri.about.opencodeGuidance.manualExternal`):C===`bundled`?t(`settings.yuri.about.opencodeGuidance.bundled`):null:null,A=ni(ne(e=>({info:e.info,checking:e.checking,available:e.available,error:e.error,downloading:e.downloading,downloaded:e.downloaded,progress:e.progress,runtimeType:e.runtimeType,checkForUpdates:e.checkForUpdates,downloadUpdate:e.downloadUpdate,restartToUpdate:e.restartToUpdate}))),j=G(e=>e.otaChannelOverride),M=G(e=>e.setOtaChannelOverride),N=Ae(),[P,F]=Q.useState(`stable`);Q.useEffect(()=>{u()&&T().then(e=>F(e?.includes(`-`)?`beta`:`stable`))},[]);let I=De({queryKey:[`native-update-config`],queryFn:Fe,enabled:N,staleTime:1/0,retry:!1}),L=I.data?.channel,R=j===`beta`||j===null&&(u()?P:L)===`beta`,[z,B]=Q.useState(!1),[V,H]=Q.useState(()=>Yt()),U=He(e=>{Pt(e),H(e)}),W=He(async e=>{if(e){M(`beta`),await ni.getState().checkForUpdates();return}M(`stable`),await ni.getState().checkForUpdates();let{info:t,otaDecision:n}=ni.getState();t?.isChannelRollback===!0&&n?.primaryAction===`apply_ota`&&c(!0)}),ee=He(()=>{c(!1),M(`beta`),ni.getState().checkForUpdates()}),te=He(()=>{c(!1),a(!0),ni.getState().downloadUpdate()}),re=He(e=>{e||ee()}),ie=f||t(`settings.yuri.about.state.unknown`),ae=He(async()=>{if(!z){B(!0);try{let{outcome:e,eventCount:n}=await Vt();if(e===`cancelled`)return;if(e===`failed`){J.error(t(`settings.yuri.about.diagnostics.toast.failed`));return}J.success(t(n>0?`settings.yuri.about.diagnostics.toast.exported`:`settings.yuri.about.diagnostics.toast.empty`))}catch{J.error(t(`settings.yuri.about.diagnostics.toast.failed`))}finally{B(!1)}}});Q.useEffect(()=>{let e=!1;return Me().then(t=>{e||p(t)}),Ne().then(t=>{e||h(t)}),()=>{e=!0}},[]);let oe=Pe(f,m)??ie,se=Q.useRef(!1);Q.useEffect(()=>{if(A.checking)d(!0),se.current=!0;else if(l){let e=setTimeout(()=>{d(!1),se.current&&A.error?(J.error(t(`settings.yuri.about.toast.checkFailed`),{description:A.error}),se.current=!1):se.current&&!A.available&&!A.error&&(J.success(t(`settings.yuri.about.toast.latestVersion`)),se.current=!1)},Ea);return()=>clearTimeout(e)}},[t,A.checking,l,A.available,A.error]);let ce=A.checking||l;return(0,$.jsxs)(`div`,{className:`yuri-settings-section-stack w-full`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,$.jsx)(Sr,{width:72,height:72}),(0,$.jsx)(`h2`,{className:`mt-4 typography-ui-header font-semibold text-foreground`,children:`Yuri`})]}),(0,$.jsxs)(Z,{className:`yuri-settings-about`,children:[(0,$.jsx)(Xi,{label:t(`settings.yuri.about.field.clientVersion`),children:(0,$.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:oe})}),(0,$.jsx)(Xi,{label:t(`settings.yuri.about.field.instanceYuriVersion`),children:O()?(0,$.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:b||t(`settings.yuri.about.state.unknown`)}):(0,$.jsx)(ui,{transport:g,generation:_,itemId:`about.host-update`,channel:R?`beta`:`stable`,version:b||t(`settings.yuri.about.state.unknown`)},`${g}:${_}`)}),(0,$.jsx)(Xi,{label:t(`settings.yuri.about.field.instanceOpenCodeVersion`),description:k,children:(0,$.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:D||t(`settings.yuri.about.state.unknown`)})}),(0,$.jsx)(Xi,{className:`yuri-settings-split-row-stacked`,copyClassName:`hidden`,children:(0,$.jsxs)(`div`,{className:`flex w-full flex-wrap items-center justify-end gap-2`,children:[(0,$.jsx)(q,{asChild:!0,variant:`outline`,size:`sm`,className:`whitespace-nowrap`,"data-settings-item":`about.feedback`,children:(0,$.jsxs)(`a`,{href:Ta,target:`_blank`,rel:`noopener noreferrer`,children:[(0,$.jsx)(X,{name:`question`,className:`size-4`}),t(`settings.yuri.about.actions.submitFeedback`)]})}),!ce&&A.available?(0,$.jsxs)(q,{type:`button`,variant:`default`,size:`sm`,className:`whitespace-nowrap`,onClick:()=>a(!0),"data-settings-item":`about.check-updates`,children:[(0,$.jsx)(X,{name:`download`,className:`size-4`}),A.info?.inAppApply?t(`settings.yuri.about.actions.applyOtaToVersion`,{version:A.info?.version||``}):A.info?.manualUpdate?t(`settings.yuri.about.actions.installNativeToVersion`,{version:A.info?.version||``}):t(`settings.yuri.about.actions.updateToVersion`,{version:A.info?.version||``})]}):(0,$.jsxs)(q,{type:`button`,variant:`outline`,size:`sm`,className:`whitespace-nowrap`,onClick:()=>A.checkForUpdates(),"data-settings-item":`about.check-updates`,disabled:ce,children:[ce?(0,$.jsx)(X,{name:`loader`,className:`size-4 animate-spin`}):(0,$.jsx)(X,{name:`refresh`,className:`size-4`}),t(ce?`settings.yuri.about.state.checking`:`settings.yuri.about.actions.checkForUpdates`)]})]})}),A.error&&(0,$.jsx)(Xi,{children:(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:A.error})}),(N||u())&&(0,$.jsx)(Ji,{itemId:`about.beta-updates`,checked:R,onChange:W,label:t(`settings.yuri.about.betaUpdates.label`),description:t(`settings.yuri.about.betaUpdates.description`),ariaLabel:t(`settings.yuri.about.betaUpdates.label`),disabled:ce||N&&!I.data}),(0,$.jsx)(Ji,{itemId:`about.diagnostics`,checked:V,onChange:U,label:t(`settings.yuri.about.diagnostics.label`),ariaLabel:t(`settings.yuri.about.diagnostics.label`)}),V&&(0,$.jsx)(Xi,{itemId:`about.export-diagnostics`,label:t(`settings.yuri.about.diagnostics.export`),children:(0,$.jsx)(q,{type:`button`,variant:`outline`,size:`sm`,disabled:z,onClick:()=>void ae(),children:t(z?`settings.yuri.about.diagnostics.exporting`:`settings.yuri.about.diagnostics.export`)})})]}),(0,$.jsx)(`div`,{className:`flex flex-col items-center gap-3 text-center`,children:(0,$.jsx)(`div`,{className:`flex items-center justify-center gap-5`,children:(0,$.jsxs)(`a`,{href:wa,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground`,children:[(0,$.jsx)(X,{name:`github-fill`,className:`size-5`}),(0,$.jsx)(`span`,{children:`GitHub`})]})})}),(0,$.jsx)(`p`,{className:`text-center typography-ui text-muted-foreground/60`,children:t(`aboutDialog.footerNote`)}),(0,$.jsx)($r,{open:n,onOpenChange:a,info:A.info,downloading:A.downloading,downloaded:A.downloaded,progress:A.progress,error:A.error,onDownload:A.downloadUpdate,onRestart:A.restartToUpdate,runtimeType:A.runtimeType}),(0,$.jsx)(gn,{open:s,onOpenChange:re,children:(0,$.jsxs)(pn,{showCloseButton:!1,className:`max-w-sm gap-5`,children:[(0,$.jsxs)(dn,{children:[(0,$.jsx)(mn,{children:t(`settings.yuri.about.betaUpdates.rollback.title`)}),(0,$.jsx)(hn,{children:t(`settings.yuri.about.betaUpdates.rollback.description`,{version:A.info?.version||``})})]}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(q,{type:`button`,size:`sm`,variant:`ghost`,onClick:ee,children:t(`settings.yuri.about.betaUpdates.rollback.actions.cancel`)}),(0,$.jsx)(q,{type:`button`,size:`sm`,onClick:te,children:t(`settings.yuri.about.betaUpdates.rollback.actions.confirm`)})]})]})})]})},ja=16384,Ma=globalThis,Na=e=>{if(Ma.Buffer)return Ma.Buffer.from(e,`utf8`).toString(`base64url`);let t=new TextEncoder().encode(e),n=``;for(let e=0;e<t.length;e+=32768)n+=String.fromCharCode(...t.slice(e,e+32768));return btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/g,``)},Pa=e=>{try{if(Ma.Buffer)return Ma.Buffer.from(e,`base64url`).toString(`utf8`);let t=e.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(Math.ceil(e.length/4)*4,`=`),n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e+=1)r[e]=n.charCodeAt(e);return new TextDecoder().decode(r)}catch{return null}},Fa=e=>{if(typeof e!=`string`)return null;let t=e.trim();if(!t)return null;try{let e=new URL(t);return e.protocol!==`http:`&&e.protocol!==`https:`?null:(e.hash=``,e.toString().replace(/\/+$/g,``))}catch{return null}},Ia=e=>{if(typeof e!=`string`)return null;let t=e.trim();if(!t)return null;try{let e=new URL(t);return e.protocol!==`ws:`&&e.protocol!==`wss:`||e.username||e.password?null:(e.username=``,e.password=``,e.hash=``,e.search=``,e.toString())}catch{return null}},La=e=>typeof e==`string`&&e.length>0,Ra=e=>{if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e;return t.kty!==`EC`||t.crv!==`P-256`||!La(t.x)||!La(t.y)?null:{kty:`EC`,crv:`P-256`,x:t.x,y:t.y}},za=e=>typeof e==`number`&&Number.isFinite(e)?e:void 0,Ba=e=>{if(!e||typeof e!=`object`)return null;let t=e,n=za(t.priority);if(t.type===`lan`||t.type===`tunnel`){let e=Fa(t.url);return e?n===void 0?{type:t.type,url:e}:{type:t.type,url:e,priority:n}:null}if(t.type===`relay`){let e=Ia(t.relayUrl);if(!e)return null;let r=typeof t.serverId==`string`?t.serverId.trim():``;if(!r)return null;let i=Ra(t.hostEncPubJwk);if(!i)return null;let a=typeof t.grant==`string`&&t.grant.trim()?t.grant.trim():void 0;return{type:`relay`,relayUrl:e,serverId:r,hostEncPubJwk:i,...a?{grant:a}:{},...n===void 0?{}:{priority:n}}}return null},Va=e=>{if(!e||typeof e!=`object`)return null;let t=e;if(t.v!==2)return null;let n=typeof t.pairingId==`string`?t.pairingId.trim():``,r=typeof t.secret==`string`?t.secret.trim():``;if(!n||!r)return null;let i=Array.isArray(t.candidates)?t.candidates.map(Ba).filter(e=>!!e):[];if(i.length===0)return null;let a=typeof t.expiresAt==`string`&&t.expiresAt.trim()?t.expiresAt.trim():void 0;if(a){let e=Date.parse(a);if(!Number.isFinite(e)||e<=Date.now())return null}let o=typeof t.label==`string`&&t.label.trim()?t.label.trim():void 0,s=typeof t.fingerprint==`string`&&t.fingerprint.trim()?t.fingerprint.trim():void 0;return{v:2,pairingId:n,secret:r,...o?{label:o}:{},...s?{fingerprint:s}:{},...a?{expiresAt:a}:{},candidates:i}},Ha=e=>({v:2,pairingId:e.pairingId.trim(),secret:e.secret.trim(),...e.label?.trim()?{label:e.label.trim()}:{},...e.fingerprint?.trim()?{fingerprint:e.fingerprint.trim()}:{},...e.expiresAt?.trim()?{expiresAt:e.expiresAt.trim()}:{},candidates:e.candidates}),Ua=e=>{let t=Va(e);if(!t)throw Error(`Invalid pairing connection payload`);let n=new URLSearchParams;return n.set(`v`,`2`),n.set(`p`,Na(JSON.stringify(t))),`yuri://connect?${n.toString()}`},Wa=e=>{let t=e.trim();if(!t||t.length>ja)return null;let n=t.indexOf(`?`);if(n===-1||!/^(?:yuri|openchamber|openchambery):\/\/connect\/?$/i.test(t.slice(0,n)))return null;let r=null,i=null;for(let e of t.slice(n+1).split(`&`)){let t=e.indexOf(`=`);if(t===-1)continue;let n=e.slice(0,t),a=e.slice(t+1);n===`v`?r=a:n===`p`&&(i=a)}if(r!==`2`||!i||i.length>ja)return null;let a=Pa(i);if(!a||a.length>ja)return null;try{return Va(JSON.parse(a))}catch{return null}},Ga=e=>{let t=e.trim();if(!t||t.length>ja)return null;try{let e=new URL(t);if([`yuri:`,`openchamber:`,`openchambery:`].includes(e.protocol)&&e.hostname===`connect`){if(e.searchParams.get(`v`)!==`2`)return null;let t=e.searchParams.get(`p`)||``;if(!t||t.length>ja)return null;let n=Pa(t);return!n||n.length>ja?null:Va(JSON.parse(n))}}catch{}return Wa(t)},Ka=`useCommandsStore`,qa=new Set([`init`,`review`]),Ja=e=>qa.has(e.name),Ya=async(e,t)=>{await Nt(Oe,e,t),i()===t&&Qt(`commands`,{source:Ka})},Xa=W()(te(ee(e=>({selectedCommandName:null,commandDraft:null,setSelectedCommand:t=>e({selectedCommandName:t}),setCommandDraft:t=>e({commandDraft:t}),loadCommands:async()=>{let e=Ut(),t=i();try{return await Nt(Oe,e,t),!0}catch{return!1}},createCommand:async t=>Za(`POST`,t.name,t,e),updateCommand:async(t,n)=>Za(`PATCH`,t,n,e),deleteCommand:async t=>Za(`DELETE`,t,void 0,e),getCommandByName:e=>At().find(t=>t.name===e)}),{name:`commands-store`,storage:pe(),partialize:e=>({selectedCommandName:e.selectedCommandName})}),{name:`commands-store`}));async function Za(e,t,n,r){let a=Ut(),o=i();try{let s={};if(e===`POST`&&(s.template=n?.template||``,n?.description&&(s.description=n.description),n?.agent&&(s.agent=n.agent),n?.model&&(s.model=n.model),n?.scope&&(s.scope=n.scope)),e===`PATCH`)for(let e of[`description`,`agent`,`model`,`template`])n?.[e]!==void 0&&(s[e]=n[e]);let c=a?`?directory=${encodeURIComponent(a)}`:``,u=await l(`/api/config/commands/${encodeURIComponent(t)}${c}`,{method:e,headers:e===`DELETE`?a?{"x-opencode-directory":a}:void 0:{"Content-Type":`application/json`,...a?{"x-opencode-directory":a}:{}},...e===`DELETE`?{}:{body:JSON.stringify(s)}}),d=await u.json().catch(()=>null);if(!u.ok)throw Error(d?.error||`Failed to ${e.toLowerCase()} command`);return i()!==o||(await Ya(a,o),i()!==o)||e===`DELETE`&&r({selectedCommandName:null}),!0}catch(e){return console.error(`[CommandsStore] Command mutation failed:`,e),!1}}typeof window<`u`&&(window.__zustand_commands_store__=Xa),Ot(e=>{e.source!==Ka&&$t(e,`commands`)&&Xa.getState().loadCommands()});var Qa=()=>{try{let e=Y.getState().getActiveProject?.();if(e?.path?.trim())return e.path.trim();let t=oe.getDirectory();if(t?.trim())return t.trim()}catch(e){console.warn(`[McpConfigStore] Error resolving config directory:`,e)}return null},$a=e=>e?Object.entries(e).map(([e,t])=>({key:e,value:t})):[],eo=e=>{let t=e.filter(e=>e.key.trim());if(t.length!==0)return Object.fromEntries(t.map(e=>[e.key.trim(),e.value]))},to=e=>{if(typeof e==`string`)return e.trim()||void 0},no=W()(te(ee((e,t)=>({selectedMcpName:null,mcpDraft:null,setSelectedMcp:t=>e({selectedMcpName:t}),setMcpDraft:t=>e({mcpDraft:t}),loadMcpConfigs:async e=>{let t=Qa();try{return!e?.force&&zi(Oe,t).length>0||await Pi(Oe,t,i()),!0}catch(e){return console.error(`[McpConfigStore] Failed to load MCP configs:`,e),!1}},createMcp:async(e,t)=>{let n=`directory`in(t??{})?t?.directory?.trim()||null:Qa(),r=t?.transportIdentity??i();try{let t=ro(e),a=n?`?directory=${encodeURIComponent(n)}`:``,o=await l(`/api/config/mcp/${encodeURIComponent(e.name)}${a}`,{method:`POST`,headers:{"Content-Type":`application/json`,...n?{"x-opencode-directory":n}:{}},body:JSON.stringify(t)}),s=await o.json().catch(()=>null);if(!o.ok)throw Error(s?.error||`Failed to create MCP server`);return i()===r?(await Pi(Oe,n,r),await Ri(Oe,n,r),{ok:!0,reloadFailed:s?.reloadFailed===!0,message:s?.message,warning:s?.warning}):{ok:!0}}catch(e){return console.error(`[McpConfigStore] Failed to create MCP:`,e),{ok:!1}}},updateMcp:async(e,t,n)=>{let r=`directory`in(n??{})?n?.directory?.trim()||null:Qa(),a=n?.transportIdentity??i();try{let n=ro(t),o=r?`?directory=${encodeURIComponent(r)}`:``,s=await l(`/api/config/mcp/${encodeURIComponent(e)}${o}`,{method:`PATCH`,headers:{"Content-Type":`application/json`,...r?{"x-opencode-directory":r}:{}},body:JSON.stringify(n)}),c=await s.json().catch(()=>null);if(!s.ok)throw Error(c?.error||`Failed to update MCP server`);return i()===a?(await Pi(Oe,r,a),await Ri(Oe,r,a),{ok:!0,reloadFailed:c?.reloadFailed===!0,message:c?.message,warning:c?.warning}):{ok:!0}}catch(e){throw console.error(`[McpConfigStore] Failed to update MCP:`,e),e}},deleteMcp:async(n,r)=>{let a=`directory`in(r??{})?r?.directory?.trim()||null:Qa(),o=r?.transportIdentity??i();try{let r=a?`?directory=${encodeURIComponent(a)}`:``,s=await l(`/api/config/mcp/${encodeURIComponent(n)}${r}`,{method:`DELETE`,headers:a?{"x-opencode-directory":a}:void 0}),c=await s.json().catch(()=>null);if(!s.ok)throw Error(c?.error||`Failed to delete MCP server`);return Ti.getState().clearDiagnostic(n,a,o),i()===o?(t().selectedMcpName===n&&e({selectedMcpName:null}),await Pi(Oe,a,o),await Ri(Oe,a,o),{ok:!0,reloadFailed:c?.reloadFailed===!0,message:c?.message,warning:c?.warning}):{ok:!0}}catch(e){return console.error(`[McpConfigStore] Failed to delete MCP:`,e),{ok:!1}}}}),{name:`mcp-config-store`,storage:pe(),partialize:e=>({selectedMcpName:e.selectedMcpName})}),{name:`mcp-config-store`}));function ro(e){let t={};if(e.scope!==void 0&&(t.scope=e.scope),e.type!==void 0&&(t.type=e.type),(e.type===`local`||e.command!==void 0)&&(t.command=(e.command??[]).filter(e=>e.trim())),(e.type===`remote`||e.url!==void 0)&&(t.url=e.url?.trim()??``),e.environment!==void 0&&(t.environment=eo(e.environment)??{}),e.headers!==void 0&&(t.headers=eo(e.headers)??{}),e.oauthEnabled!==void 0||e.oauthClientId!==void 0||e.oauthClientSecret!==void 0||e.oauthScope!==void 0||e.oauthRedirectUri!==void 0)if(e.oauthEnabled===!1)t.oauth=!1;else{let n={clientId:to(e.oauthClientId),clientSecret:to(e.oauthClientSecret),scope:to(e.oauthScope),redirectUri:to(e.oauthRedirectUri)};t.oauth=n.clientId||n.clientSecret||n.scope||n.redirectUri?n:e.oauthEnabled?{}:!1}if(e.timeout!==void 0){let n=Number(e.timeout);t.timeout=Number.isFinite(n)&&n>0?n:null}return e.enabled!==void 0&&(t.enabled=e.enabled),t}var io=()=>{let e=oe.getDirectory();if(typeof e==`string`&&e.trim().length>0)return e;try{let e=window.__zustand_directory_store__;if(e)return e.getState().currentDirectory}catch{}return null},ao=`useSkillsStore`,oo=e=>{if(e&&Object.prototype.hasOwnProperty.call(e,`directory`))return typeof e.directory==`string`&&e.directory.trim()||null;let t=io();return typeof t==`string`&&t.trim()||null},so=W()(te(ee((e,t)=>({selectedSkillName:null,skillDraft:null,setSelectedSkill:t=>{e({selectedSkillName:t})},setSkillDraft:t=>{e({skillDraft:t})},loadSkills:async()=>{try{return await wt(Oe,io(),i()),!0}catch{return!1}},getSkillDetail:async e=>{try{let t=io(),n=t?`?directory=${encodeURIComponent(t)}`:``,r=await l(`/api/config/skills/${encodeURIComponent(e)}${n}`);return r.ok?await r.json():null}catch{return null}},createSkill:async(e,t)=>{try{let n={name:e.name,description:e.description};e.instructions&&(n.instructions=e.instructions),e.scope&&(n.scope=e.scope),e.source&&(n.source=e.source),e.supportingFiles&&(n.supportingFiles=e.supportingFiles);let r=oo(t),a=i(),o=r?`?directory=${encodeURIComponent(r)}`:``,s=await l(`/api/config/skills/${encodeURIComponent(e.name)}${o}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)}),c=await s.json().catch(()=>null);if(!s.ok){let e=c?.error||`Failed to create skill`;throw Error(e)}return await co({directory:r,transportIdentity:a}),!0}catch{return!1}},updateSkill:async(e,t,n)=>{try{let r={};t.description!==void 0&&(r.description=t.description),t.instructions!==void 0&&(r.instructions=t.instructions),t.supportingFiles!==void 0&&(r.supportingFiles=t.supportingFiles),t.targetPath!==void 0&&(r.targetPath=t.targetPath);let a=oo(n),o=i(),s=a?`?directory=${encodeURIComponent(a)}`:``,c=await l(`/api/config/skills/${encodeURIComponent(e)}${s}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r)}),u=await c.json().catch(()=>null);if(!c.ok){let e=u?.error||`Failed to update skill`;throw Error(e)}return await co({directory:a,transportIdentity:o}),!0}catch{return!1}},deleteSkill:async(n,r)=>{try{let a=oo(r),o=i(),s=a?`?directory=${encodeURIComponent(a)}`:``,c=await l(`/api/config/skills/${encodeURIComponent(n)}${s}`,{method:`DELETE`}),u=await c.json().catch(()=>null);if(!c.ok){let e=u?.error||`Failed to delete skill`;throw Error(e)}return await co({directory:a,transportIdentity:o}),i()===o&&t().selectedSkillName===n&&e({selectedSkillName:null}),!0}catch{return!1}},getSkillByName:e=>gt(Oe,io()).find(t=>t.name===e),readSupportingFile:async(e,t)=>{try{let n=io(),r=n?`&directory=${encodeURIComponent(n)}`:``,i=await l(`/api/config/skills/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}?${r.slice(1)}`);return i.ok?(await i.json()).content??null:null}catch{return null}},writeSupportingFile:async(e,t,n)=>{try{let r=io(),i=r?`?directory=${encodeURIComponent(r)}`:``;return(await l(`/api/config/skills/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}${i}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({content:n})})).ok}catch{return!1}},deleteSupportingFile:async(e,t)=>{try{let n=io(),r=n?`?directory=${encodeURIComponent(n)}`:``;return(await l(`/api/config/skills/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}${r}`,{method:`DELETE`})).ok}catch{return!1}}}),{name:`skills-store`,storage:pe(),partialize:e=>({selectedSkillName:e.selectedSkillName})}),{name:`skills-store`}));typeof window<`u`&&(window.__zustand_skills_store__=so);async function co(e){let t=e&&`directory`in e?e.directory?.trim()||null:io(),n=e?.transportIdentity??i();i()===n&&(await wt(Oe,t,n),i()===n&&(await jt(Oe,t,n),i()===n&&Qt(`skills`,{source:ao})))}var lo=null;lo||=Ot(e=>{if(e.source!==ao&&$t(e,`skills`)){let e=io(),t=i();wt(Oe,e,t).then(()=>jt(Oe,e,t)).catch(()=>void 0)}});var uo=/^#[0-9a-fA-F]{6}$/,fo=/^\{file:.+\}$/i,po=e=>[...e].sort((e,t)=>{let n=e.permission.localeCompare(t.permission);return n===0?e.pattern.localeCompare(t.pattern):n}),mo=(e,t)=>{let n=po(e),r=po(t);return n.length===r.length&&n.every((e,t)=>{let n=r[t];return e.permission===n.permission&&e.pattern===n.pattern&&e.action===n.action})},ho=(e,t)=>t?e.globalPermission!==t.globalPermission||!mo(e.permissionRules,t.permissionRules):!1,go=e=>e===`bash`?`shell`:e===`task`?`subagent`:e===`write`||e===`patch`?`edit`:e,_o=(e,t)=>{let n=[{action:`*`,resource:`*`,effect:e}];for(let e of t)!e.permission||!e.pattern||(e.permission!==`*`||e.pattern!==`*`)&&n.push({action:go(e.permission),resource:e.pattern,effect:e.action});return n},vo=e=>{let t=e.trim();return t===``?null:t},yo=({isNewAgent:e,agentName:t,draftScope:n,initialScope:r,draftHasExplicitPermission:i,current:a,initial:o,confirmDrop:s})=>{let c=_o(a.globalPermission,a.permissionRules);if(e){let e=a.description.trim(),r=vo(a.model),l=a.system.trim(),u=ho(a,o)||i;return{name:t,mode:a.mode,...e?{description:e}:{},...r?{model:r}:{},...l?{system:l}:{},...u?{permissions:c}:{},...n?{scope:n}:{},...s?{confirmDrop:!0}:{}}}let l={name:t,...s?{confirmDrop:!0}:{}};return o?(a.description!==o.description&&(l.description=a.description.trim()||null),a.mode!==o.mode&&(l.mode=a.mode),a.model!==o.model&&(l.model=vo(a.model)),a.system!==o.system&&(l.system=a.system.trim()||null),ho(a,o)&&(l.permissions=c),n&&r&&n!==r&&(l.scope=n),l):l},bo=e=>{if(e){if(typeof e.prompt==`string`)return fo.test(e.prompt.trim())?void 0:e.prompt;if(typeof e.system==`string`)return e.system}},xo=e=>{let t=e?.model?.providerID,n=e?.model?.modelID||e?.model?.id;if(!t||!n)return``;let r=e?.model?.variant||e?.variant;return r?`${t}/${n}#${r}`:`${t}/${n}`},So=e=>{let t=e.trim(),n=t.indexOf(`/`);if(n<=0||n>=t.length-1)return null;let r=t.slice(0,n),i=t.slice(n+1),a=i.indexOf(`#`);return a===-1?{providerId:r,modelId:i,variant:``}:{providerId:r,modelId:i.slice(0,a),variant:i.slice(a+1)}},Co=e=>uo.test(e.trim()),wo=e=>{let t=e.trim();return t&&t.charAt(0).toUpperCase()+t.slice(1)},To=e=>{let t=(0,Sa.c)(37),{className:n}=e,{t:r}=Ge(),i=Y(Eo),a=Y(Do),o=Y(Oo),s=g(),c;t[0]===i?c=t[1]:(c=[...i].sort(ko),t[0]=i,t[1]=c);let l=c,u;bb0:{if(l.length===0){u=null;break bb0}let e;t[2]!==a||t[3]!==l?(e=l.find(e=>e.id===a)??l[0],t[2]=a,t[3]=l,t[4]=e):e=t[4],u=e}let d=u;if(s||l.length===0)return null;let f;t[5]!==d?.path||t[6]!==r?(f=d?.path.split(`/`).filter(Boolean).pop()||d?.path||r(`settings.shared.projectSelector.fallbackProject`),t[5]=d?.path,t[6]=r,t[7]=f):f=t[7];let p=f,m;t[8]===n?m=t[9]:(m=K(n),t[8]=n,t[9]=m);let h;t[10]===r?h=t[11]:(h=r(`settings.shared.projectSelector.switchProjectAria`),t[10]=r,t[11]=h);let _;t[12]===r?_=t[13]:(_=r(`settings.shared.projectSelector.switchProjectTitle`),t[12]=r,t[13]=_);let v,y;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(v=K(`yuri-settings-sidebar-picker text-foreground appearance-none flex h-8 w-full min-w-0 rounded-lg px-3 py-1`,`flex items-center gap-1.5 text-left`),y=(0,$.jsx)(X,{name:`folder`,className:`h-4 w-4 text-muted-foreground`}),t[14]=v,t[15]=y):(v=t[14],y=t[15]);let b;t[16]===p?b=t[17]:(b=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-ui-label font-medium`,children:p}),t[16]=p,t[17]=b);let x;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(X,{name:`arrow-down-s`,className:`size-4 opacity-50`}),t[18]=x):x=t[18];let S;t[19]!==h||t[20]!==_||t[21]!==b?(S=(0,$.jsx)(fr,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,"aria-label":h,title:_,className:v,children:[y,b,x]})}),t[19]=h,t[20]=_,t[21]=b,t[22]=S):S=t[22];let C=d?.id??``,w;t[23]===o?w=t[24]:(w=e=>{e&&o(e)},t[23]=o,t[24]=w);let T;t[25]===l?T=t[26]:(T=l.map(Ao),t[25]=l,t[26]=T);let E;t[27]!==C||t[28]!==w||t[29]!==T?(E=(0,$.jsx)(Zn,{align:`start`,className:`w-auto`,children:(0,$.jsx)(Dn,{value:C,onValueChange:w,children:T})}),t[27]=C,t[28]=w,t[29]=T,t[30]=E):E=t[30];let D;t[31]!==S||t[32]!==E?(D=(0,$.jsxs)($n,{children:[S,E]}),t[31]=S,t[32]=E,t[33]=D):D=t[33];let O;return t[34]!==D||t[35]!==m?(O=(0,$.jsx)(`div`,{className:m,children:D}),t[34]=D,t[35]=m,t[36]=O):O=t[36],O};function Eo(e){return e.projects}function Do(e){return e.activeProjectId}function Oo(e){return e.setActiveProject}function ko(e,t){return(e.label||e.path).localeCompare(t.label||t.path)}function Ao(e){let t=e.path.split(`/`).filter(Boolean).pop()||e.path;return(0,$.jsx)(ir,{value:e.id,children:(0,$.jsx)(`span`,{className:`min-w-0 truncate typography-ui`,children:t})},e.id)}function jo(e,t){return`opencode:sidebar-group:${e}:${t}`}var Mo=e=>{let t=(0,Sa.c)(57),{label:n,count:r,storageKey:i,defaultExpanded:a,variant:o,labelPrefix:s,children:c}=e,l=a===void 0||a,u=o===void 0?`sidebar`:o,d;t[0]!==n||t[1]!==i?(d=jo(i,n),t[0]=n,t[1]=i,t[2]=d):d=t[2];let f=d,p=Q.useId(),m;t[3]!==l||t[4]!==f?(m=()=>{try{let e=localStorage.getItem(f);if(e!==null)return e===`true`}catch{}return l},t[3]=l,t[4]=f,t[5]=m):m=t[5];let[h,g]=(0,Q.useState)(m),_,v;if(t[6]!==h||t[7]!==f?(_=()=>{try{localStorage.setItem(f,String(h))}catch{}},v=[f,h],t[6]=h,t[7]=f,t[8]=_,t[9]=v):(_=t[8],v=t[9]),(0,Q.useEffect)(_,v),u===`settings-card`){let e;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(e=()=>g(No),t[10]=e):e=t[10];let i;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(i=K(`flex w-full items-center gap-1 text-left`,`text-inherit transition-colors duration-150 hover:text-foreground`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`),t[11]=i):i=t[11];let a=!h&&`-rotate-90`,o;t[12]===a?o=t[13]:(o=K(`h-3.5 w-3.5 flex-shrink-0 transition-transform duration-200`,a),t[12]=a,t[13]=o);let l;t[14]===o?l=t[15]:(l=(0,$.jsx)(X,{name:`arrow-down-s`,className:o}),t[14]=o,t[15]=l);let u=s?`${s} · `:``,d;t[16]!==n||t[17]!==u?(d=(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[u,n]}),t[16]=n,t[17]=u,t[18]=d):d=t[18];let f;t[19]===r?f=t[20]:(f=(0,$.jsx)(`span`,{className:`ml-1 tabular-nums opacity-60`,children:r}),t[19]=r,t[20]=f);let m;t[21]!==p||t[22]!==h||t[23]!==l||t[24]!==d||t[25]!==f?(m=(0,$.jsxs)(`button`,{type:`button`,onClick:e,"aria-expanded":h,"aria-controls":p,className:i,children:[l,d,f]}),t[21]=p,t[22]=h,t[23]=l,t[24]=d,t[25]=f,t[26]=m):m=t[26];let _=!h&&`hidden`,v;t[27]===_?v=t[28]:(v=K(_),t[27]=_,t[28]=v);let y;return t[29]!==c||t[30]!==p||t[31]!==m||t[32]!==v?(y=(0,$.jsx)(Z,{label:m,cardClassName:v,cardId:p,children:c}),t[29]=c,t[30]=p,t[31]=m,t[32]=v,t[33]=y):y=t[33],y}let y;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(y=()=>g(Po),t[34]=y):y=t[34];let b;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(b=K(`flex w-full items-center gap-1 rounded-md px-2 py-1 text-left`,`text-xs font-semibold uppercase tracking-wide text-muted-foreground`,`hover:bg-[var(--interactive-hover)] transition-colors duration-150`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`),t[35]=b):b=t[35];let x=!h&&`-rotate-90`,S;t[36]===x?S=t[37]:(S=K(`h-3.5 w-3.5 flex-shrink-0 transition-transform duration-200`,x),t[36]=x,t[37]=S);let C;t[38]===S?C=t[39]:(C=(0,$.jsx)(X,{name:`arrow-down-s`,className:S}),t[38]=S,t[39]=C);let w;t[40]===n?w=t[41]:(w=(0,$.jsx)(`span`,{className:`flex-1 truncate`,children:n}),t[40]=n,t[41]=w);let T;t[42]===r?T=t[43]:(T=(0,$.jsx)(`span`,{className:`ml-1 tabular-nums opacity-60`,children:r}),t[42]=r,t[43]=T);let E;t[44]!==p||t[45]!==h||t[46]!==C||t[47]!==w||t[48]!==T?(E=(0,$.jsxs)(`button`,{type:`button`,onClick:y,"aria-expanded":h,"aria-controls":p,className:b,children:[C,w,T]}),t[44]=p,t[45]=h,t[46]=C,t[47]=w,t[48]=T,t[49]=E):E=t[49];let D=!h,O;t[50]!==c||t[51]!==p||t[52]!==D?(O=(0,$.jsx)(`div`,{id:p,hidden:D,className:`mt-0.5 space-y-0.5 ml-2 pl-3 border-l-2 border-[var(--interactive-border)]`,children:c}),t[50]=c,t[51]=p,t[52]=D,t[53]=O):O=t[53];let k;return t[54]!==E||t[55]!==O?(k=(0,$.jsxs)(`div`,{children:[E,O]}),t[54]=E,t[55]=O,t[56]=k):k=t[56],k};function No(e){return!e}function Po(e){return!e}var Fo=e=>e===`bash`?`shell`:e===`task`?`subagent`:e===`write`||e===`patch`?`edit`:e,Io=e=>{let t=Kn(e).map(e=>({action:Fo(e.action),resource:e.resource,effect:e.effect}));return t.length>0?t:void 0},Lo=(e,t)=>{let n=e,r=ht(e)?void 0:typeof n.system==`string`?n.system:typeof e.prompt==`string`?e.prompt:void 0,i=typeof n.color==`string`&&Co(n.color)?n.color:void 0;return{name:t,scope:n.scope||`user`,description:e.description,model:xo(e)||null,...r?{system:r}:{},mode:e.mode,...typeof n.steps==`number`?{steps:n.steps}:{},...e.hidden===!0?{hidden:!0}:{},...n.disabledOverride?{disabled:!0}:{},...i?{color:i}:{},permissions:Io(n.permissions??e.permission)}},Ro=({onItemSelect:e})=>{let{t}=Ge(),[n,r]=Q.useState(null),[i,a]=Q.useState(``),[o,s]=Q.useState(null),[c,l]=Q.useState(null),[u,d]=Q.useState(!1),[f,p]=Q.useState(null),{selectedAgentName:m,setSelectedAgent:h,setAgentDraft:g,createAgent:_,deleteAgent:v,loadAgents:y}=Wt(ne(e=>({selectedAgentName:e.selectedAgentName,setSelectedAgent:e.setSelectedAgent,setAgentDraft:e.setAgentDraft,createAgent:e.createAgent,deleteAgent:e.deleteAgent,loadAgents:e.loadAgents}))),{data:b=[]}=Jt();Q.useEffect(()=>{y()},[y]);let x=()=>{let t=`new-agent`,n=t,r=1;for(;b.some(e=>e.name===n);)n=`${t}-${r}`,r++;g({name:n,scope:`user`}),h(n),e?.()},S=async e=>{if(ht(e)){J.error(t(`settings.agents.sidebar.toast.builtInCannotDelete`));return}s(e),l(`delete`)},C=async e=>{ht(e)&&(s(e),l(`reset`))},w=()=>{s(null),l(null)},T=async()=>{if(!(!o||!c)){d(!0);try{let e=await v(o.name,o.scope);e.ok?(e.requiresManualRestart?J.warning(t(`settings.agents.page.toast.savedManualRestart`)):c===`delete`?J.success(t(`settings.agents.sidebar.toast.agentDeleted`,{name:o.name})):J.success(t(`settings.agents.sidebar.toast.agentReset`,{name:o.name})),w()):c===`delete`?J.error(t(`settings.agents.sidebar.toast.deleteFailed`)):J.error(t(`settings.agents.sidebar.toast.resetFailed`))}catch(e){let n=e instanceof Error?e.message:``,r=/built-in|not deletable|not found/i.test(n);c===`delete`?J.error(t(r?`settings.agents.sidebar.toast.definitionNotFound`:`settings.agents.sidebar.toast.deleteFailed`)):J.error(t(`settings.agents.sidebar.toast.resetFailed`))}d(!1)}},E=e=>{let t=e.name,n=1,r=`${t}-copy`;for(;b.some(e=>e.name===r);)n++,r=`${t}-copy-${n}`;g(Lo(e,r)),h(r)},D=e=>{a(e.name),r(e)},O=async()=>{if(!n)return;let e=i.trim().replace(/\s+/g,`-`);if(!e){J.error(t(`settings.agents.sidebar.toast.agentNameRequired`));return}if(e===n.name){r(null);return}if(b.some(t=>t.name===e)){J.error(t(`settings.agents.sidebar.toast.agentExists`));return}let a=n,o=await _({...Lo(n,e),scope:a.scope});if(o.ok){let r=await v(n.name,a.scope);r.ok?(o.requiresManualRestart||r.requiresManualRestart?J.warning(t(`settings.agents.page.toast.savedManualRestart`)):J.success(t(`settings.agents.sidebar.toast.agentRenamed`,{name:e})),h(e)):J.error(t(`settings.agents.sidebar.toast.removeOldAfterRenameFailed`))}else J.error(t(`settings.agents.sidebar.toast.renameFailed`));r(null)},k=e=>{switch(e){case`primary`:return(0,$.jsx)(X,{name:`ai-agent`,className:`h-3 w-3 text-primary`});case`all`:return(0,$.jsx)(X,{name:`ai-agent-fill`,className:`h-3 w-3 text-primary`});case`subagent`:return(0,$.jsx)(X,{name:`robot`,className:`h-3 w-3 text-primary`});default:return null}},A=b.filter(e=>{let t=e;return!bt(e)||!!t.scope||t.disabledOverride===!0}),j=A.filter(ht),M=A.filter(e=>!ht(e)),{groupedCustomAgents:N,ungroupedCustomAgents:P}=(0,Q.useMemo)(()=>{let e={},t=[];for(let n of M){let r=n;r.group?(e[r.group]||(e[r.group]=[]),e[r.group].push(n)):t.push(n)}return{groupedCustomAgents:Object.keys(e).sort((e,t)=>e.localeCompare(t)).map(t=>({name:t,agents:e[t]})),ungroupedCustomAgents:t}},[M]),F=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,$.jsx)(`span`,{children:t(`settings.agents.sidebar.section.custom`)}),(0,$.jsx)(q,{"data-settings-item":`agents.create`,size:`icon`,variant:`ghost`,onClick:x,"aria-label":t(`settings.agents.page.title.new`),children:(0,$.jsx)(X,{name:`add`,className:`h-4 w-4`})})]});return(0,$.jsxs)(`div`,{className:`yuri-settings-page-content h-full overflow-y-auto bg-background p-3`,children:[(0,$.jsx)(To,{}),(0,$.jsx)($.Fragment,{children:A.length===0?(0,$.jsx)(Z,{children:(0,$.jsxs)(`div`,{className:`yuri-settings-group-row py-12 text-center text-muted-foreground`,children:[(0,$.jsx)(X,{name:`robot-2`,className:`mx-auto mb-3 h-10 w-10 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-ui-label font-medium`,children:t(`settings.agents.sidebar.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:t(`settings.agents.sidebar.empty.description`)})]})}):(0,$.jsxs)($.Fragment,{children:[j.length>0&&(0,$.jsx)(Z,{label:t(`settings.agents.sidebar.section.builtIn`),children:j.map(t=>(0,$.jsx)(zo,{agent:t,isSelected:m===t.name,onSelect:()=>{h(t.name),e?.()},onReset:()=>C(t),onDuplicate:()=>E(t),getAgentModeIcon:k,isMenuOpen:f===t.name,onMenuOpenChange:e=>p(e?t.name:null)},t.name))}),M.length>0&&(0,$.jsxs)($.Fragment,{children:[N.map(({name:n,agents:r})=>(0,$.jsx)(Mo,{label:n,count:r.length,storageKey:`agents`,variant:`settings-card`,labelPrefix:t(`settings.agents.sidebar.section.custom`),children:r.map(t=>(0,$.jsx)(zo,{agent:t,isSelected:m===t.name,onSelect:()=>{h(t.name),e?.()},onRename:()=>D(t),onDelete:()=>S(t),onDuplicate:()=>E(t),getAgentModeIcon:k,isMenuOpen:f===t.name,onMenuOpenChange:e=>p(e?t.name:null)},t.name))},n)),P.length>0?(0,$.jsx)(Z,{label:F,children:P.map(t=>(0,$.jsx)(zo,{agent:t,isSelected:m===t.name,onSelect:()=>{h(t.name),e?.()},onRename:()=>D(t),onDelete:()=>S(t),onDuplicate:()=>E(t),getAgentModeIcon:k,isMenuOpen:f===t.name,onMenuOpenChange:e=>p(e?t.name:null)},t.name))}):(0,$.jsx)(Z,{label:F,cardClassName:`hidden`,children:(0,$.jsx)(`span`,{})})]}),M.length===0&&(0,$.jsx)(Z,{label:F,cardClassName:`hidden`,children:(0,$.jsx)(`span`,{})})]})}),(0,$.jsx)(gn,{open:o!==null&&c!==null,onOpenChange:e=>{!e&&!u&&w()},children:(0,$.jsxs)(pn,{className:`max-w-md`,children:[(0,$.jsxs)(dn,{children:[(0,$.jsx)(mn,{children:t(c===`delete`?`settings.agents.sidebar.dialog.deleteTitle`:`settings.agents.sidebar.dialog.resetTitle`)}),(0,$.jsx)(hn,{children:t(c===`delete`?`settings.agents.sidebar.dialog.deleteDescription`:`settings.agents.sidebar.dialog.resetDescription`,{name:o?.name??``})})]}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(q,{size:`sm`,variant:`ghost`,onClick:w,disabled:u,children:t(`settings.common.actions.cancel`)}),(0,$.jsx)(q,{size:`sm`,onClick:T,disabled:u,children:t(c===`delete`?`settings.common.actions.delete`:`settings.common.actions.reset`)})]})]})}),(0,$.jsx)(gn,{open:n!==null,onOpenChange:e=>!e&&r(null),children:(0,$.jsxs)(pn,{children:[(0,$.jsxs)(dn,{children:[(0,$.jsx)(mn,{children:t(`settings.agents.sidebar.renameDialog.title`)}),(0,$.jsx)(hn,{children:t(`settings.agents.sidebar.renameDialog.description`,{name:n?.name??``})})]}),(0,$.jsx)(Cn,{value:i,onChange:e=>a(e.target.value),placeholder:t(`settings.agents.sidebar.renameDialog.placeholder`),className:`text-foreground placeholder:text-muted-foreground`,onKeyDown:e=>{e.key===`Enter`&&O()}}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(q,{size:`sm`,variant:`ghost`,onClick:()=>r(null),children:t(`settings.common.actions.cancel`)}),(0,$.jsx)(q,{size:`sm`,onClick:O,children:t(`settings.common.actions.rename`)})]})]})})]})},zo=e=>{let t=(0,Sa.c)(55),{agent:n,isSelected:r,onSelect:i,onDelete:a,onReset:o,onRename:s,onDuplicate:c,getAgentModeIcon:l,isMenuOpen:u,onMenuOpenChange:d}=e,{t:f}=Ge(),p=n,m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=Cr(),t[0]=m):m=t[0];let h=m,[g,_]=Q.useState(!1),v;t[1]!==a||t[2]!==c||t[3]!==s||t[4]!==o||t[5]!==f?(v=e=>(0,$.jsxs)($.Fragment,{children:[s&&(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),s()},children:[(0,$.jsx)(X,{name:`edit`,className:`h-4 w-4 mr-px`}),f(`settings.common.actions.rename`)]}),(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),c()},children:[(0,$.jsx)(X,{name:`file-copy`,className:`h-4 w-4 mr-px`}),f(`settings.common.actions.duplicate`)]}),o&&(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),o()},children:[(0,$.jsx)(X,{name:`restart`,className:`h-4 w-4 mr-px`}),f(`settings.common.actions.reset`)]}),a&&(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),a()},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(X,{name:`delete-bin`,className:`h-4 w-4 mr-px`}),f(`settings.common.actions.delete`)]})]}),t[1]=a,t[2]=c,t[3]=s,t[4]=o,t[5]=f,t[6]=v):v=t[6];let y=v,b=r?`bg-interactive-selection`:`hover:bg-interactive-hover`,x;t[7]===b?x=t[8]:(x=K(`yuri-settings-group-row group relative flex items-center transition-colors duration-150 select-none`,b),t[7]=b,t[8]=x);let S;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(S=h?void 0:e=>{e.preventDefault(),_(!0)},t[9]=S):S=t[9];let C;t[10]===x?C=t[11]:(C=(0,$.jsx)(`div`,{className:x,onContextMenu:S}),t[10]=x,t[11]=C);let w;t[12]===n.name?w=t[13]:(w=wo(n.name),t[12]=n.name,t[13]=w);let T;t[14]===w?T=t[15]:(T=(0,$.jsx)(`span`,{className:`typography-ui-label font-normal truncate text-foreground`,children:w}),t[14]=w,t[15]=T);let E;t[16]!==n.mode||t[17]!==l?(E=l(n.mode),t[16]=n.mode,t[17]=l,t[18]=E):E=t[18];let D;t[19]!==n||t[20]!==p.disabledOverride||t[21]!==p.scope||t[22]!==f?(D=(p.scope||ht(n)||p.disabledOverride)&&(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-muted px-1 rounded flex-shrink-0 leading-none pb-px border border-border/50`,children:p.disabledOverride?f(`settings.agents.sidebar.badge.disabled`):ht(n)?f(`settings.agents.sidebar.badge.system`):p.scope===`project`?f(`settings.common.scope.project`):f(`settings.common.scope.global`)}),t[19]=n,t[20]=p.disabledOverride,t[21]=p.scope,t[22]=f,t[23]=D):D=t[23];let O;t[24]!==D||t[25]!==T||t[26]!==E?(O=(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[T,E,D]}),t[24]=D,t[25]=T,t[26]=E,t[27]=O):O=t[27];let k;t[28]===n.description?k=t[29]:(k=n.description&&(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/60 truncate leading-tight`,children:n.description}),t[28]=n.description,t[29]=k);let A;t[30]!==i||t[31]!==O||t[32]!==k?(A=(0,$.jsxs)(`button`,{onClick:i,className:`flex min-w-0 flex-1 flex-col gap-0 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,tabIndex:0,children:[O,k]}),t[30]=i,t[31]=O,t[32]=k,t[33]=A):A=t[33];let j;t[34]===d?j=t[35]:(j=e=>{e&&_(!1),d(e)},t[34]=d,t[35]=j);let M;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,$.jsx)(fr,{asChild:!0,children:(0,$.jsx)(q,{size:`sm`,variant:`ghost`,className:`h-6 w-6 px-0 flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100`,children:(0,$.jsx)(X,{name:`more-2`,className:`h-3.5 w-3.5`})})}),t[36]=M):M=t[36];let N;t[37]===y?N=t[38]:(N=(0,$.jsx)(Zn,{align:`end`,className:`w-fit min-w-20`,children:y(tr)}),t[37]=y,t[38]=N);let P;t[39]!==u||t[40]!==j||t[41]!==N?(P=(0,$.jsxs)($n,{open:u,onOpenChange:j,children:[M,N]}),t[39]=u,t[40]=j,t[41]=N,t[42]=P):P=t[42];let F;t[43]!==A||t[44]!==P?(F=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:[A,P]}),t[43]=A,t[44]=P,t[45]=F):F=t[45];let I;t[46]!==F||t[47]!==C?(I=(0,$.jsx)(na,{render:C,children:F}),t[46]=F,t[47]=C,t[48]=I):I=t[48];let L;t[49]===y?L=t[50]:(L=(0,$.jsx)(ra,{className:`w-fit min-w-20`,children:y(ia)}),t[49]=y,t[50]=L);let R;return t[51]!==g||t[52]!==I||t[53]!==L?(R=(0,$.jsxs)(aa,{open:g,onOpenChange:_,children:[I,L]}),t[51]=g,t[52]=I,t[53]=L,t[54]=R):R=t[54],R};function Bo(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function Vo(e){return typeof e==`string`&&e.length>0?e:void 0}function Ho(e){let t=Bo(e)?e:null,n=t&&Array.isArray(t.data)?t.data:Array.isArray(e)?e:null;if(!n)throw Error(`permission saved: expected list payload`);return n.map(e=>{if(!Bo(e))throw Error(`permission saved: invalid rule`);let t=Vo(e.id),n=Vo(e.projectID),r=Vo(e.action),i=Vo(e.resource);if(!t||!n||!r||!i)throw Error(`permission saved: invalid rule`);return{id:t,projectID:n,action:r,resource:i}})}async function Uo(e,t){if(!e.trim())throw Error(`permission saved: directory required`);t?.throwIfAborted();let n=await oe.getApiClient().location.get({location:{directory:e}},{signal:t});t?.throwIfAborted();let r=Vo(n?.project?.id);if(!r)throw Error(`permission saved: project ID required`);return r}async function Wo(e){e.signal?.throwIfAborted();let t=await oe.getApiClient().permission.saved.list({projectID:e.projectID??void 0},{signal:e.signal});e.signal?.throwIfAborted();let n=Ho(t);if(e.projectID&&n.some(t=>t.projectID!==e.projectID))throw Error(`permission saved: project mismatch`);return n}async function Go(e){e.signal?.throwIfAborted(),await oe.getApiClient().permission.saved.remove({id:e.id},{signal:e.signal})}function Ko(e){if(e.transport!==i()||e.generation!==o())throw Error(`Saved permission runtime changed`)}var qo=e=>Ee({queryKey:[e.transport,e.generation,`saved-permission-project`,e.directory],queryFn:async({signal:t})=>{Ko(e);let n=await Uo(e.directory,t);return Ko(e),n},retry:!1}),Jo=e=>Ee({queryKey:[e.transport,e.generation,`saved-permissions`,e.directory,e.projectID],queryFn:async({signal:t})=>{if(Ko(e),!e.directory||!e.projectID)throw Error(`Saved permission scope required`);let n=await Wo({projectID:e.projectID,signal:t});return Ko(e),n},retry:!1});function Yo(e){let t=(0,Sa.c)(3),n=(0,Q.useSyncExternalStore)(r,o,o),a={transport:i(),generation:n,directory:e.trim()},s=De({...qo(a),enabled:!!a.directory}),c={...a,projectID:s.data??``},l=Jo(c),u=!!(a.directory&&s.data)&&!s.isError,d;return t[0]!==l||t[1]!==u?(d={...l,enabled:u},t[0]=l,t[1]=u,t[2]=d):d=t[2],{project:s,list:De(d),scope:c}}async function Xo(e,t,n){Ko(t);let r=Jo(t).queryKey;if(!e.getQueryData(r)?.some(e=>e.id===n&&e.projectID===t.projectID))throw Error(`Saved permission is outside the captured scope`);await Go({id:n}),t.transport===i()&&t.generation===o()&&(await e.cancelQueries({queryKey:r,exact:!0}),t.transport===i()&&t.generation===o()&&e.setQueryData(r,e=>e?.filter(e=>e.id!==n)))}var Zo=()=>{let e=(0,Sa.c)(49),{t}=Ge(),n=ce(Qo),r=we(),{project:i,list:a,scope:o}=Yo(n),s;e[0]===r?s=e[1]:(s={mutationFn:e=>{let{scope:t,id:n}=e;return Xo(r,t,n)}},e[0]=r,e[1]=s);let c=Te(s),l;e[2]!==c.variables||e[3]!==o?(l=c.variables&&JSON.stringify(c.variables.scope)===JSON.stringify(o),e[2]=c.variables,e[3]=o,e[4]=l):l=e[4];let u=l,d=i.isError||a.isError,f=!!o.directory&&(i.isPending||a.isPending)&&!d,p;e[5]===a.data?p=e[6]:(p=a.data??[],e[5]=a.data,e[6]=p);let m=p,h;e[7]!==c||e[8]!==o?(h=e=>c.mutate({scope:o,id:e}),e[7]=c,e[8]=o,e[9]=h):h=e[9];let g=He(h),_;e[10]!==a||e[11]!==i?(_=()=>{i.isError?i.refetch():a.refetch()},e[10]=a,e[11]=i,e[12]=_):_=e[12];let v=He(_);if(!d&&!f&&m.length===0)return null;let y;e[13]===t?y=e[14]:(y=t(`settings.permissions.saved.title`),e[13]=t,e[14]=y);let b;e[15]!==f||e[16]!==t?(b=f?t(`common.loading`):void 0,e[15]=f,e[16]=t,e[17]=b):b=e[17];let x;e[18]!==d||e[19]!==a.isFetching||e[20]!==i.isFetching||e[21]!==v||e[22]!==t?(x=d&&(0,$.jsx)(Xi,{label:(0,$.jsx)(`span`,{role:`alert`,children:t(`settings.permissions.saved.loadFailed`)}),children:(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`xs`,onClick:v,disabled:i.isFetching||a.isFetching,children:t(`settings.permissions.saved.retry`)})}),e[18]=d,e[19]=a.isFetching,e[20]=i.isFetching,e[21]=v,e[22]=t,e[23]=x):x=e[23];let S;e[24]!==c.isError||e[25]!==u||e[26]!==t?(S=u&&c.isError&&(0,$.jsx)(Xi,{label:(0,$.jsx)(`span`,{role:`alert`,children:t(`settings.permissions.saved.deleteFailed`)}),children:null}),e[24]=c.isError,e[25]=u,e[26]=t,e[27]=S):S=e[27];let C;if(e[28]!==c.isPending||e[29]!==d||e[30]!==g||e[31]!==m||e[32]!==f||e[33]!==u||e[34]!==t){let n;e[36]!==c.isPending||e[37]!==d||e[38]!==g||e[39]!==f||e[40]!==u||e[41]!==t?(n=e=>(0,$.jsx)(Xi,{label:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{children:e.action}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground font-mono`,children:e.resource})]}),children:(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`xs`,disabled:d||f||!!(u&&c.isPending),onClick:()=>void g(e.id),children:t(`settings.permissions.saved.delete`)})},e.id),e[36]=c.isPending,e[37]=d,e[38]=g,e[39]=f,e[40]=u,e[41]=t,e[42]=n):n=e[42],C=m.map(n),e[28]=c.isPending,e[29]=d,e[30]=g,e[31]=m,e[32]=f,e[33]=u,e[34]=t,e[35]=C}else C=e[35];let w;return e[43]!==y||e[44]!==b||e[45]!==x||e[46]!==S||e[47]!==C?(w=(0,$.jsx)(`div`,{"data-settings-item":`permissions.saved`,className:`mb-6`,children:(0,$.jsxs)(Z,{label:y,description:b,children:[x,S,C]})}),e[43]=y,e[44]=b,e[45]=x,e[46]=S,e[47]=C,e[48]=w):w=e[48],w};function Qo(e){return e.currentDirectory}var $o=[`*`,`read`,`edit`,`glob`,`grep`,`shell`,`subagent`,`skill`,`webfetch`,`websearch`,`question`,`external_directory`,`execute`,`browser`],es={"*":`settings.agents.page.permissions.defaultLabel`,shell:`settings.agents.page.permissions.shell`,bash:`settings.agents.page.permissions.shell`,subagent:`settings.agents.page.permissions.subagent`,task:`settings.agents.page.permissions.subagent`,edit:`settings.agents.page.permissions.edit`,write:`settings.agents.page.permissions.edit`,patch:`settings.agents.page.permissions.edit`,apply_patch:`settings.agents.page.permissions.edit`,multiedit:`settings.agents.page.permissions.edit`,external_directory:`settings.agents.page.permissions.externalDirectory`,question:`settings.agents.page.permissions.question`,read:`settings.agents.page.permissions.read`,glob:`settings.agents.page.permissions.glob`,grep:`settings.agents.page.permissions.grep`,skill:`settings.agents.page.permissions.skill`,webfetch:`settings.agents.page.permissions.webfetch`,websearch:`settings.agents.page.permissions.websearch`,execute:`settings.agents.page.permissions.execute`,browser:`settings.agents.page.permissions.browser`,session_rename:`chat.tools.display.session_rename`,session_move:`chat.tools.display.session_move`},ts=e=>e===`allow`||e===`ask`||e===`deny`,ns=(e,t)=>`${e}::${t}`,rs=e=>e===`bash`?`shell`:e===`task`?`subagent`:e===`write`||e===`patch`?`edit`:e,is=e=>{let t=new Map;for(let n of e){let e=rs(n.permission);!e||e===`invalid`||n.pattern&&ts(n.action)&&t.set(ns(e,n.pattern),{permission:e,pattern:n.pattern,action:n.action})}return Array.from(t.values())},as=e=>{let t=new Map;for(let n of is(e))t.set(ns(n.permission,n.pattern),n);return t},os=e=>[...e].sort((e,t)=>{let n=e.permission.localeCompare(t.permission);return n===0?e.pattern.localeCompare(t.pattern):n}),ss=(e,t)=>{let n=os(is(e)),r=os(is(t));return n.length===r.length&&n.every((e,t)=>{let n=r[t];return e.permission===n.permission&&e.pattern===n.pattern&&e.action===n.action})},cs=e=>e.find(e=>e.permission===`*`&&e.pattern===`*`)?.action??`allow`,ls=(e,t)=>is(e).filter(e=>e.permission!==`*`||e.pattern!==`*`).filter(e=>e.pattern!==`*`||e.action!==t),us=e=>{if(Array.isArray(e))return is(e.flatMap(e=>!e||typeof e!=`object`||typeof e.action!=`string`||typeof e.resource!=`string`||!ts(e.effect)?[]:[{permission:e.action,pattern:e.resource,action:e.effect}]));if(ts(e))return[{permission:`*`,pattern:`*`,action:e}];if(!e||typeof e!=`object`||Array.isArray(e))return[];let t=[];for(let[n,r]of Object.entries(e))if(n!==`__originalKeys`){if(ts(r)){t.push({permission:n,pattern:`*`,action:r});continue}if(r&&typeof r==`object`&&!Array.isArray(r))for(let[e,i]of Object.entries(r))ts(i)&&t.push({permission:n,pattern:e,action:i})}return t},ds=()=>{let{t:e}=Ge(),{selectedAgentName:t,getAgentByName:n,createAgent:r,updateAgent:i,agentDraft:a,setAgentDraft:o}=Wt(ne(e=>({selectedAgentName:e.selectedAgentName,getAgentByName:e.getAgentByName,createAgent:e.createAgent,updateAgent:e.updateAgent,agentDraft:e.agentDraft,setAgentDraft:e.setAgentDraft}))),{data:s=[]}=Jt(),c=t?n(t):null,u=!!(a&&a.name===t&&!c),[d,f]=Q.useState(``),[p,m]=Q.useState(`user`),[h,g]=Q.useState(``),[_,v]=Q.useState(`subagent`),[y,b]=Q.useState(``),[x,S]=Q.useState(``),[C,w]=Q.useState(!1),[T,E]=Q.useState(`allow`),[D,O]=Q.useState([]),[k,A]=Q.useState([]),[j,M]=Q.useState(``),[N,P]=Q.useState(`*`),[F,I]=Q.useState(!1),[L,R]=Q.useState(!1),z=Q.useRef(null),B=ce(e=>e.currentDirectory??null),[V,H]=Q.useState([]),U=xt(e=>e.permission);Q.useEffect(()=>{let e=!1;return(async()=>{let t=await oe.listToolIds({directory:B});if(e)return;let n=new Set([`write`,`patch`,`multiedit`]),r=t.map(e=>typeof e==`string`?e.trim():``).filter(Boolean).filter(e=>e!==`*`).filter(e=>e!==`invalid`).filter(e=>!n.has(e));H(Array.from(new Set(r)).sort((e,t)=>e.localeCompare(t)))})(),()=>{e=!0}},[B]);let W=Q.useMemo(()=>{let e=new Set;for(let t of s){let n=is(us(t.permissions??t.permission));for(let t of n)t.permission&&t.permission!==`*`&&t.permission!==`invalid`&&e.add(t.permission)}for(let t of Object.values(U))for(let n of t){let t=n.permission?.trim();t&&t!==`invalid`&&e.add(t)}for(let t of V)e.add(t);return Array.from(e).sort((e,t)=>e.localeCompare(t))},[s,U,V]),ee=Q.useMemo(()=>as(D),[D]),te=Q.useMemo(()=>as(k),[k]),re=e=>te.get(ns(e,`*`))?.action,ie=e=>k.filter(t=>t.permission===e&&t.pattern!==`*`).sort((e,t)=>e.pattern.localeCompare(t.pattern)),ae=Q.useMemo(()=>{let e=new Set;for(let t of $o)e.add(t);for(let t of W)e.add(t);return Array.from(e).sort((e,t)=>e.localeCompare(t))},[W]),se=e=>{let t=e===`*`?T:re(e)??T,n=ie(e),r=n.reduce((e,t)=>(e[t.action]=(e[t.action]??0)+1,e),{allow:0,ask:0,deny:0}),i=[`allow`,`ask`,`deny`].filter(e=>r[e]>0).map(e=>`${r[e]} ${e}`).join(`, `);return{defaultAction:t,patternRulesCount:n.length,patternSummary:i,hasDefaultHint:!1}},le=t=>e(t===`allow`?`settings.common.permission.allow`:t===`deny`?`settings.common.permission.deny`:`settings.common.permission.ask`),ue=t=>t===`global`?e(`settings.common.scope.global`):le(t),de=Q.useMemo(()=>{let e=new Set;for(let t of $o)e.add(t);for(let t of W)e.add(t);return Array.from(e).sort((e,t)=>e.localeCompare(t))},[W]),G=(e,t,n)=>{A(r=>{let i=as(r);return i.set(ns(e,t),{permission:e,pattern:t,action:n}),Array.from(i.values())})},fe=(e,t)=>{A(n=>{let r=as(n);return r.delete(ns(e,t)),Array.from(r.values())})},pe=(e,t)=>{let n=ee.get(ns(e,t));if(n){G(e,t,n.action);return}fe(e,t)},me=(e,t,n)=>{G(e,t,n)},he=e=>{E(e),A(t=>t.filter(t=>t.pattern!==`*`||t.action!==e))},ge=t=>{let n=j.trim();if(!n){J.error(e(`settings.agents.page.toast.permissionNameRequired`));return}let r=N.trim()||`*`;if(n===`*`&&r===`*`){he(t),M(``),P(`*`);return}r===`*`&&n!==`*`&&t===T?fe(n,`*`):G(n,r,t),M(``),P(`*`)},_e=t=>{let n=es[t];return n?e(n):t.split(/[_-]+/g).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)};Q.useEffect(()=>{M(``),P(`*`);let e=e=>{let t=is(e),n=cs(t),r=ls(t,n);return E(n),O(r),A(r),{global:n,rules:r}};if(u&&a){let t=a.name||``,n=a.scope||`user`,r=a.description||``,i=a.mode||`subagent`,o=a.model||``,s=a.system||``;f(t),m(n),g(r),v(i),b(o),S(s),w(!1);let c=e(us(a.permissions));z.current={draftName:t,draftScope:n,description:r,mode:i,model:o,system:s,globalPermission:c.global,permissionRules:c.rules};return}if(c&&t===c.name){let t=c,n=c.description||``,r=c.mode||`subagent`,i=xo(c),a=t.scope===`project`?`project`:`user`;m(a),g(n),v(r),b(i),S(``),w(!1);let o=e(us(t.permissions??c.permission));z.current={draftName:``,draftScope:a,description:n,mode:r,model:i,system:``,globalPermission:o.global,permissionRules:o.rules}}},[a,u,c,t]),Q.useEffect(()=>{if(!t||u)return;let e=new AbortController,n=Ut();return l(`/api/config/agents/${encodeURIComponent(t)}/config`,{signal:e.signal,headers:n?{"x-opencode-directory":n}:{}}).then(async t=>{if(!t.ok||e.signal.aborted)return;let n=bo((await t.json()).config);e.signal.aborted||n===void 0||!z.current||(S(n),z.current={...z.current,system:n})}).catch(()=>void 0),()=>e.abort()},[u,t]);let ve=Q.useMemo(()=>{let e=z.current;return e?!!(u&&d!==e.draftName||p!==e.draftScope||h!==e.description||_!==e.mode||y!==e.model||x!==e.system||T!==e.globalPermission||!ss(k,e.permissionRules)):!1},[h,d,p,T,u,_,y,k,x]),ye=(!u&&c?c.document:void 0)?.dropped?.map(e=>e.key)??[],be=!L&&ve;return t?(0,$.jsx)(Ur,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`yuri-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsx)(Gi,{actions:(0,$.jsx)(q,{type:`button`,size:`sm`,onClick:async()=>{let n=u?d.trim().replace(/\s+/g,`-`):t?.trim();if(!n){J.error(e(`settings.agents.sidebar.toast.agentNameRequired`));return}if(u&&s.some(e=>e.name===n)){J.error(e(`settings.agents.sidebar.toast.agentExists`));return}R(!0);try{let t={description:h,mode:_,model:y,system:x,globalPermission:T,permissionRules:k},s=z.current,c=s?{description:s.description,mode:s.mode,model:s.model,system:s.system,globalPermission:s.globalPermission,permissionRules:s.permissionRules}:null,l=yo({isNewAgent:u,agentName:n,draftScope:p,initialScope:s?.draftScope,draftHasExplicitPermission:u&&a?.permissions!==void 0,current:t,initial:c,confirmDrop:C}),d;u?(d=await r(l),d.ok&&o(null)):d=await i(n,l),d.ok?d.requiresManualRestart?J.warning(e(`settings.agents.page.toast.savedManualRestart`)):J.success(e(`settings.agents.page.toast.savedNextRequest`)):J.error(e(u?`settings.agents.page.toast.createFailed`:`settings.agents.page.toast.updateFailed`))}catch(t){console.error(`Error saving agent:`,t);let n=t instanceof Error&&t.message?t.message:e(`settings.agents.page.toast.saveUnexpectedError`);J.error(n)}finally{R(!1)}},disabled:!be,"aria-busy":L,children:e(L?`settings.common.actions.saving`:`settings.common.actions.saveChanges`)}),children:(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:u?e(`settings.agents.page.title.new`):wo(t??``)}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground truncate`,children:e(u?`settings.agents.page.subtitle.new`:`settings.agents.page.subtitle.edit`)})]})}),(0,$.jsx)(Zo,{}),ye.length>0?(0,$.jsxs)(`div`,{className:`mt-3 flex flex-col gap-2`,children:[(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e(`settings.agents.page.legacy.dropped`,{fields:ye.join(`, `)})}),(0,$.jsx)(Ji,{checked:C,onChange:w,label:e(`settings.agents.page.legacy.confirmDrop`),ariaLabel:e(`settings.agents.page.legacy.confirmDrop`)})]}):null,(0,$.jsxs)(Z,{label:e(`settings.agents.page.section.identityRole`),children:[(0,$.jsx)(Xi,{itemId:`agents.scope`,label:e(`settings.agents.page.field.scope`),children:(0,$.jsxs)(Fr,{value:p,onValueChange:e=>m(e),children:[(0,$.jsx)(Pr,{className:`w-fit min-w-[100px]`,children:(0,$.jsx)(Ar,{placeholder:e(`settings.agents.page.field.scopePlaceholder`),children:t=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(X,{name:t===`project`?`folder`:`user-3`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:e(t===`project`?`settings.common.scope.project`:`settings.common.scope.global`)})]})})}),(0,$.jsxs)(Nr,{align:`end`,children:[(0,$.jsx)(jr,{value:`user`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(X,{name:`user-3`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:e(`settings.common.scope.global`)})]})}),(0,$.jsx)(jr,{value:`project`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(X,{name:`folder`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:e(`settings.common.scope.project`)})]})})]})]})}),u&&(0,$.jsx)(Xi,{itemId:`agents.name`,label:e(`settings.agents.page.field.agentName`),children:(0,$.jsxs)(`div`,{className:`flex items-center`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground mr-1`,children:`@`}),(0,$.jsx)(Cn,{value:d,onChange:e=>f(e.target.value),placeholder:e(`settings.agents.page.field.agentNamePlaceholder`),className:`h-7 w-40 px-2`})]})}),(0,$.jsx)(Xi,{label:e(`settings.common.field.description`),className:`yuri-settings-split-row-stacked`,children:(0,$.jsx)(Wr,{embedded:!0,value:h,onChange:e=>g(e.target.value),placeholder:e(`settings.agents.page.field.descriptionPlaceholder`),rows:2,className:`w-full resize-none min-h-[60px] bg-transparent`})}),(0,$.jsx)(Xi,{itemId:`agents.mode`,className:`yuri-settings-agents-mode-row`,label:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:e(`settings.agents.page.field.mode`)}),(0,$.jsxs)(En,{children:[(0,$.jsx)(wn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(Tn,{sideOffset:8,className:`max-w-xs`,children:e(`settings.agents.page.field.modeTooltip`)})]})]}),children:(0,$.jsxs)(`div`,{className:`flex flex-nowrap items-center justify-end gap-1`,children:[(0,$.jsx)(q,{variant:`chip`,size:`xs`,"aria-pressed":_===`primary`,onClick:()=>v(`primary`),className:`!font-normal shrink-0`,children:e(`settings.agents.page.mode.primary`)}),(0,$.jsx)(q,{variant:`chip`,size:`xs`,"aria-pressed":_===`subagent`,onClick:()=>v(`subagent`),className:`!font-normal shrink-0`,children:e(`settings.agents.page.mode.subagent`)}),(0,$.jsx)(q,{variant:`chip`,size:`xs`,"aria-pressed":_===`all`,onClick:()=>v(`all`),className:`!font-normal shrink-0`,children:e(`settings.agents.page.mode.all`)})]})})]}),(0,$.jsx)(Z,{label:e(`settings.agents.page.section.modelParameters`),children:(0,$.jsx)(Xi,{itemId:`agents.model`,label:e(`settings.agents.page.field.overrideModel`),children:(0,$.jsx)(ii,{providerId:So(y)?.providerId??``,modelId:So(y)?.modelId??``,variant:So(y)?.variant??``,onChange:(e,t,n)=>{b(e&&t?n?`${e}/${t}#${n}`:`${e}/${t}`:``)},className:`yuri-settings-inline-value`})})}),(0,$.jsx)(Ui,{itemId:`agents.system-prompt`,label:e(`settings.agents.page.section.systemPrompt`),className:`yuri-settings-split-row-stacked`,children:(0,$.jsx)(Wr,{embedded:!0,value:x,onChange:e=>S(e.target.value),placeholder:e(`settings.agents.page.field.systemPromptPlaceholder`),rows:8,className:`w-full font-mono typography-meta min-h-[120px] max-h-[60vh] bg-transparent resize-y`})}),(0,$.jsx)(`div`,{"data-settings-item":`agents.permissions`,children:(0,$.jsx)(Z,{label:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,$.jsx)(`span`,{children:e(`settings.agents.page.section.toolPermissions`)}),(0,$.jsx)(q,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>I(e=>!e),children:e(F?`settings.agents.page.permissions.hideEditor`:`settings.agents.page.permissions.advancedEditor`)})]}),children:F?(0,$.jsxs)(`div`,{className:`space-y-6 p-2`,children:[(0,$.jsx)(Xi,{label:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{children:e(`settings.agents.page.permissions.globalDefault`)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70 font-mono`,children:`*`})]}),children:(0,$.jsxs)(Fr,{value:T,onValueChange:e=>he(e),children:[(0,$.jsx)(Pr,{className:`w-[100px]`,children:(0,$.jsx)(Ar,{children:le(T)})}),(0,$.jsxs)(Nr,{children:[(0,$.jsx)(jr,{value:`allow`,children:e(`settings.common.permission.allow`)}),(0,$.jsx)(jr,{value:`ask`,children:e(`settings.common.permission.ask`)}),(0,$.jsx)(jr,{value:`deny`,children:e(`settings.common.permission.deny`)})]})]})}),(0,$.jsx)(`div`,{className:`space-y-4`,children:ae.filter(e=>e!==`*`).map(t=>{let n=_e(t),{defaultAction:r,patternRulesCount:i}=se(t),a=re(t),o=a??`global`,s=ie(t),c=[`allow`,`ask`,`deny`].filter(e=>e!==T);return(0,$.jsxs)(`div`,{className:`border-t border-[var(--surface-subtle)] pt-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between py-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:n}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70 font-mono`,children:t})]}),(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground`,children:i>0?e(`settings.agents.page.permissions.globalSummary`,{summary:r}):r})]}),(0,$.jsxs)(`div`,{className:`space-y-1 pl-2 mt-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 py-0.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:e(`settings.agents.page.permissions.pattern`)}),(0,$.jsx)(`span`,{className:`typography-micro font-mono text-foreground bg-[var(--surface-muted)] px-1 rounded`,children:`*`}),a&&(0,$.jsx)(q,{size:`sm`,variant:`ghost`,onClick:()=>pe(t,`*`),className:`px-1.5 py-0 h-5`,children:(0,$.jsx)(X,{name:`subtract`,className:`h-3.5 w-3.5 text-muted-foreground hover:text-foreground`})})]}),(0,$.jsxs)(Fr,{value:o,onValueChange:e=>{if(e===`global`){fe(t,`*`);return}G(t,`*`,e)},children:[(0,$.jsx)(Pr,{className:`w-[90px] shrink-0`,children:(0,$.jsx)(Ar,{children:ue(o)})}),(0,$.jsxs)(Nr,{children:[(0,$.jsx)(jr,{value:`global`,children:e(`settings.common.scope.global`)}),c.map(e=>(0,$.jsx)(jr,{value:e,className:`capitalize`,children:le(e)},e))]})]})]}),s.map(t=>{let n=ns(t.permission,t.pattern),r=ee.get(n),i=!r,a=!!(r&&r.action!==t.action);return(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 py-0.5 border-t border-[var(--surface-subtle)]`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:e(`settings.agents.page.permissions.pattern`)}),(0,$.jsx)(`span`,{className:`min-w-0 break-all typography-micro font-mono text-foreground bg-[var(--surface-muted)] px-1 rounded`,children:t.pattern}),i&&(0,$.jsx)(`span`,{className:`typography-micro text-[var(--status-success)]`,children:e(`settings.common.badge.new`)}),a&&(0,$.jsx)(`span`,{className:`typography-micro text-[var(--status-warning)]`,children:e(`settings.common.badge.modified`)}),(i||a)&&(0,$.jsx)(q,{size:`sm`,variant:`ghost`,onClick:()=>i?fe(t.permission,t.pattern):pe(t.permission,t.pattern),className:`px-1.5 py-0 h-5`,children:(0,$.jsx)(X,{name:`subtract`,className:`h-3.5 w-3.5 text-muted-foreground hover:text-foreground`})})]}),(0,$.jsxs)(Fr,{value:t.action,onValueChange:e=>me(t.permission,t.pattern,e),children:[(0,$.jsx)(Pr,{className:`w-[90px] shrink-0`,children:(0,$.jsx)(Ar,{children:le(t.action)})}),(0,$.jsxs)(Nr,{children:[(0,$.jsx)(jr,{value:`allow`,children:e(`settings.common.permission.allow`)}),(0,$.jsx)(jr,{value:`ask`,children:e(`settings.common.permission.ask`)}),(0,$.jsx)(jr,{value:`deny`,children:e(`settings.common.permission.deny`)})]})]})]},n)})]})]},t)})}),(0,$.jsxs)(`div`,{className:`border-t border-[var(--surface-subtle)] pt-3`,children:[(0,$.jsx)(`h4`,{className:`typography-ui-label text-foreground mb-2`,children:e(`settings.agents.page.permissions.addCustomRule`)}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,$.jsxs)(Fr,{value:j,onValueChange:M,children:[(0,$.jsx)(Pr,{className:`w-auto max-w-full sm:w-[160px]`,children:j?(0,$.jsx)(`span`,{className:`truncate`,children:_e(j)}):(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e(`settings.agents.page.permissions.permissionPlaceholder`)})}),(0,$.jsx)(Nr,{children:de.map(e=>(0,$.jsx)(jr,{value:e,children:(0,$.jsx)(`div`,{className:`flex items-center justify-between gap-2 w-full`,children:(0,$.jsx)(`span`,{children:_e(e)})})},e))})]}),(0,$.jsx)(Cn,{value:N,onChange:e=>P(e.target.value),placeholder:e(`settings.agents.page.permissions.patternPlaceholder`),className:`h-7 min-w-0 flex-1 basis-32 font-mono text-xs`}),(0,$.jsxs)(`div`,{className:`flex gap-1`,children:[(0,$.jsx)(q,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>ge(`allow`),children:e(`settings.common.permission.allow`)}),(0,$.jsx)(q,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>ge(`ask`),children:e(`settings.common.permission.ask`)}),(0,$.jsx)(q,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>ge(`deny`),children:e(`settings.common.permission.deny`)})]})]})]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground px-3 pt-2`,children:e(`settings.agents.page.permissions.lastMatchHint`)}),Hn(Kn(k)).map((e,t)=>(0,$.jsx)(Xi,{label:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground font-mono`,children:t+1}),(0,$.jsx)(`span`,{children:e.action}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70 font-mono`,children:e.resource})]}),children:(0,$.jsx)(`span`,{className:K(`typography-micro capitalize px-1.5 py-0.5 rounded`,e.effect===`allow`?`text-[var(--status-success)] bg-[var(--status-success)]/10`:e.effect===`deny`?`text-[var(--status-error)] bg-[var(--status-error)]/10`:`text-[var(--status-warning)] bg-[var(--status-warning)]/10`),children:e.effect})},`${e.action}::${e.resource}::${t}`))]})})})]})}):(0,$.jsx)(Ur,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`yuri-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsx)(Zo,{}),(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,$.jsxs)(`div`,{className:`text-center text-muted-foreground`,children:[(0,$.jsx)(X,{name:`robot-2`,className:`mx-auto mb-3 h-12 w-12 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.agents.page.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:e(`settings.agents.page.empty.description`)})]})})]})})};function fs(e){let t=(0,Sa.c)(46),{seed:n,disabled:r,onChange:i}=e,{t:a}=Ge(),o=rn(n),s;t[0]!==i||t[1]!==n?(s=e=>{i(nn({...rn(n),...e}))},t[0]=i,t[1]=n,t[2]=s):s=t[2];let c=He(s),l=Z,u;t[3]===a?u=t[4]:(u=a(`assistants.avatar.title`),t[3]=a,t[4]=u);let d=Xi,f;t[5]===a?f=t[6]:(f=a(`assistants.settings.randomAvatar`),t[5]=a,t[6]=f);let p;t[7]===a?p=t[8]:(p=a(`assistants.settings.randomAvatar`),t[7]=a,t[8]=p);let m;t[9]===i?m=t[10]:(m=()=>i(ln(crypto.randomUUID())),t[9]=i,t[10]=m);let h;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(X,{name:`refresh`,className:`size-3.5 sm:size-2.5`}),t[11]=h):h=t[11];let g;t[12]===a?g=t[13]:(g=a(`assistants.settings.randomAvatar`),t[12]=a,t[13]=g);let _;t[14]!==r||t[15]!==m||t[16]!==g||t[17]!==f||t[18]!==p?(_=(0,$.jsx)(`div`,{className:`absolute right-3 top-1 z-10 sm:right-2`,children:(0,$.jsxs)(q,{variant:`ghost`,size:`xs`,className:`gap-1.5 text-xs font-normal text-muted-foreground/80 hover:text-muted-foreground sm:gap-1 sm:text-[10px]`,disabled:r,"aria-label":f,title:p,onClick:m,children:[h,g]})}),t[14]=r,t[15]=m,t[16]=g,t[17]=f,t[18]=p,t[19]=_):_=t[19];let v;t[20]===a?v=t[21]:(v=a(`assistants.avatar.shape`),t[20]=a,t[21]=v);let y=tn.map(e=>(0,$.jsx)(q,{variant:`ghost`,size:`icon`,className:`size-11 rounded-lg ring-2 ring-transparent aria-pressed:ring-foreground/40 sm:size-9`,disabled:r,"aria-label":a(`assistants.avatar.shape.${e}`),title:a(`assistants.avatar.shape.${e}`),"aria-pressed":o.shape===e,"data-avatar-shape-option":e,onClick:()=>c({shape:e}),children:(0,$.jsx)(cn,{kind:`assistant`,name:nn({...o,shape:e}),size:32})},e)),b;t[22]!==v||t[23]!==y?(b=(0,$.jsx)(`div`,{className:`grid grid-cols-4 justify-items-center gap-3 sm:grid-cols-8 sm:gap-2`,role:`group`,"aria-label":v,children:y}),t[22]=v,t[23]=y,t[24]=b):b=t[24];let x;t[25]===a?x=t[26]:(x=a(`assistants.avatar.color`),t[25]=a,t[26]=x);let S;t[27]!==c||t[28]!==r||t[29]!==o||t[30]!==a?(S=sn.map(e=>(0,$.jsx)(q,{variant:`ghost`,size:`icon`,className:`rounded-full [corner-shape:round] ring-2 ring-transparent aria-pressed:ring-foreground/50`,disabled:r,"aria-label":a(`assistants.avatar.color.${e}`),title:a(`assistants.avatar.color.${e}`),"aria-pressed":o.color===e,"data-avatar-color-option":e,onClick:()=>c({color:e}),children:(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`size-5 rounded-full`,style:{backgroundColor:on(e)}})},e)),t[27]=c,t[28]=r,t[29]=o,t[30]=a,t[31]=S):S=t[31];let C;t[32]!==x||t[33]!==S?(C=(0,$.jsx)(`div`,{className:`grid grid-cols-6 justify-items-center gap-1`,role:`group`,"aria-label":x,children:S}),t[32]=x,t[33]=S,t[34]=C):C=t[34];let w;t[35]!==b||t[36]!==C?(w=(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-sm flex-col gap-6 sm:max-w-md sm:gap-4`,children:[b,C]}),t[35]=b,t[36]=C,t[37]=w):w=t[37];let T;t[38]!==d||t[39]!==_||t[40]!==w?(T=(0,$.jsxs)(d,{className:`yuri-settings-split-row-stacked`,copyClassName:`!hidden`,controlClassName:`!block !w-full !max-w-none px-3 py-6 sm:px-0 sm:py-3`,children:[_,w]}),t[38]=d,t[39]=_,t[40]=w,t[41]=T):T=t[41];let E;return t[42]!==l||t[43]!==T||t[44]!==u?(E=(0,$.jsx)(`div`,{className:`relative w-full`,"data-assistant-avatar-editor":``,children:(0,$.jsx)(l,{ariaLabel:u,children:T})}),t[42]=l,t[43]=T,t[44]=u,t[45]=E):E=t[45],E}var ps=e=>{let t=(0,Sa.c)(37),{title:n,metadata:r,selected:i,onSelect:a,icon:o,actions:s,className:c,rowId:l,compact:u}=e,d=i!==void 0&&i,f=u!==void 0&&u,p=s&&s.length>0,m=!f&&`yuri-settings-group-row`,h=d?`bg-interactive-selection`:`hover:bg-interactive-hover`,g;t[0]!==c||t[1]!==m||t[2]!==h?(g=K(`group relative flex items-center transition-colors duration-150`,m,h,c),t[0]=c,t[1]=m,t[2]=h,t[3]=g):g=t[3];let _=d?`true`:void 0,v;t[4]!==f||t[5]!==p?(v=f&&K(`px-3 py-2`,p&&`pr-9`),t[4]=f,t[5]=p,t[6]=v):v=t[6];let y;t[7]===v?y=t[8]:(y=K(`flex min-w-0 flex-1 self-stretch flex-col justify-center gap-0 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,v),t[7]=v,t[8]=y);let b=f?`flex flex-1 items-center gap-2 text-[13px] leading-5`:`typography-ui-label whitespace-normal [overflow-wrap:anywhere]`,x;t[9]===b?x=t[10]:(x=K(`min-w-0 font-normal text-foreground`,b),t[9]=b,t[10]=x);let S;t[11]!==x||t[12]!==n?(S=(0,$.jsx)(`span`,{className:x,children:n}),t[11]=x,t[12]=n,t[13]=S):S=t[13];let C;t[14]!==o||t[15]!==S?(C=(0,$.jsxs)(`div`,{className:`flex max-w-full min-w-0 items-center gap-1.5`,children:[o,S]}),t[14]=o,t[15]=S,t[16]=C):C=t[16];let w;t[17]!==f||t[18]!==r?(w=r&&(0,$.jsx)(`div`,{className:K(`max-w-full leading-tight text-muted-foreground/60`,f?`mt-0.5 min-w-0 w-full truncate pl-7 text-[11px]`:`typography-micro whitespace-normal [overflow-wrap:anywhere]`),children:r}),t[17]=f,t[18]=r,t[19]=w):w=t[19];let T;t[20]!==a||t[21]!==C||t[22]!==w||t[23]!==_||t[24]!==y?(T=(0,$.jsxs)(`button`,{onClick:a,"aria-current":_,"data-mobile-press-feedback":`soft`,className:y,tabIndex:0,children:[C,w]}),t[20]=a,t[21]=C,t[22]=w,t[23]=_,t[24]=y,t[25]=T):T=t[25];let E;t[26]!==s||t[27]!==f||t[28]!==p?(E=p&&(0,$.jsxs)($n,{children:[(0,$.jsx)(fr,{asChild:!0,children:(0,$.jsx)(q,{size:`icon`,variant:`ghost`,className:K(`h-6 w-6 flex-shrink-0 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100 focus-visible:opacity-100`,f?`absolute right-2 top-1/2 -translate-y-1/2`:`-mr-1`),children:(0,$.jsx)(X,{name:`more-2`,className:`h-3.5 w-3.5`})})}),(0,$.jsx)(Zn,{align:`end`,className:`w-fit min-w-20`,children:s.map(ms)})]}),t[26]=s,t[27]=f,t[28]=p,t[29]=E):E=t[29];let D;t[30]!==T||t[31]!==E?(D=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 self-stretch items-center`,children:[T,E]}),t[30]=T,t[31]=E,t[32]=D):D=t[32];let O;return t[33]!==l||t[34]!==D||t[35]!==g?(O=(0,$.jsx)(`div`,{"data-row-id":l,className:g,children:D}),t[33]=l,t[34]=D,t[35]=g,t[36]=O):O=t[36],O};function ms(e){let t=e.icon;return(0,$.jsxs)(tr,{onClick:t=>{t.stopPropagation(),e.onClick()},className:K(e.destructive&&`text-destructive focus:text-destructive`),children:[t&&(0,$.jsx)(X,{name:t,className:`h-4 w-4 mr-px`}),e.label]},e.label)}var hs=e=>{let t=(0,Sa.c)(8),{header:n,footer:r,children:i,className:a,variant:o}=e,s=o===void 0?`sidebar`:o,c=g(),l=s===`background`||c?`bg-background`:`bg-sidebar`,u;t[0]!==l||t[1]!==a?(u=K(`yuri-settings-sidebar yuri-settings-page-content h-full overflow-y-auto p-3`,l,a),t[0]=l,t[1]=a,t[2]=u):u=t[2];let d;return t[3]!==i||t[4]!==r||t[5]!==n||t[6]!==u?(d=(0,$.jsxs)(`div`,{className:u,children:[n,i,r]}),t[3]=i,t[4]=r,t[5]=n,t[6]=u,t[7]=d):d=t[7],d},gs=[{id:`wechat`,nameKey:`assistants.weixin.title`,summaryKey:`assistants.channels.wechat.summary`,logo:`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2033%2027'%20role='img'%20aria-label='WeChat'%3e%3cpath%20d='M7.98557%2019.5685C9.15835%2019.9072%2010.4238%2020.0965%2011.7342%2020.0965C18.0746%2020.0965%2023.2158%2015.7818%2023.2158%2010.4592C23.2158%205.1365%2018.0746%200.821838%2011.7316%200.821838C5.38852%200.821838%200.25%205.1365%200.25%2010.4592C0.25%2013.3632%201.79606%2015.9765%204.21838%2017.7445C4.41164%2017.8832%204.53872%2018.1125%204.53872%2018.3738C4.53872%2018.4592%204.52018%2018.5392%204.499%2018.6192C4.30575%2019.3445%203.99601%2020.5098%203.98277%2020.5632C3.95894%2020.6538%203.92188%2020.7498%203.92188%2020.8458C3.92188%2021.0592%204.09396%2021.2325%204.30575%2021.2325C4.39046%2021.2325%204.45665%2021.2005%204.52813%2021.1605L7.04311%2019.6992C7.23107%2019.5898%207.43227%2019.5205%207.652%2019.5205C7.76849%2019.5205%207.88232%2019.5392%207.99087%2019.5712L7.98557%2019.5685Z'%20fill='url(%23paint0_linear_2149_1261)'/%3e%3cpath%20d='M17.0935%207.37416C17.0935%208.22483%2016.4079%208.91549%2015.5634%208.91549C14.7189%208.91549%2014.0332%208.22483%2014.0332%207.37416C14.0332%206.52349%2014.7189%205.83282%2015.5634%205.83282C16.4079%205.83282%2017.0935%206.52349%2017.0935%207.37416Z'%20fill='%23168743'/%3e%3cpath%20d='M9.43534%207.3741C9.43534%208.22476%208.74968%208.91543%207.90517%208.91543C7.06067%208.91543%206.375%208.22476%206.375%207.3741C6.375%206.52343%207.06067%205.83276%207.90517%205.83276C8.74968%205.83276%209.43534%206.52343%209.43534%207.3741Z'%20fill='%23168743'/%3e%3cpath%20d='M25.573%2025.6191C24.5961%2025.9017%2023.5425%2026.0591%2022.4491%2026.0591C17.165%2026.0591%2012.8789%2022.4617%2012.8789%2018.0271C12.8789%2013.5924%2017.1623%209.99506%2022.4491%209.99506C27.7359%209.99506%2032.0166%2013.5924%2032.0166%2018.0271C32.0166%2020.4484%2030.7274%2022.6271%2028.7101%2024.0991C28.5486%2024.2164%2028.4427%2024.4057%2028.4427%2024.6217C28.4427%2024.6937%2028.4586%2024.7577%2028.4771%2024.8271C28.6386%2025.4324%2028.8954%2026.4004%2028.9086%2026.4457C28.9298%2026.5231%2028.9589%2026.6004%2028.9589%2026.6804C28.9589%2026.8591%2028.816%2027.0031%2028.6386%2027.0031C28.5698%2027.0031%2028.5142%2026.9764%2028.4533%2026.9417L26.3592%2025.7231C26.2004%2025.6324%2026.0336%2025.5737%2025.8509%2025.5737C25.753%2025.5737%2025.6577%2025.5897%2025.5703%2025.6164L25.573%2025.6191Z'%20fill='url(%23paint1_linear_2149_1261)'/%3e%3cpath%20d='M17.9844%2015.4569C17.9844%2016.1662%2018.5562%2016.7422%2019.2604%2016.7422C19.9646%2016.7422%2020.5364%2016.1662%2020.5364%2015.4569C20.5364%2014.7476%2019.9646%2014.1716%2019.2604%2014.1716C18.5562%2014.1716%2017.9844%2014.7476%2017.9844%2015.4569Z'%20fill='%23919191'/%3e%3cpath%20d='M24.3633%2015.457C24.3633%2016.1663%2024.9351%2016.7423%2025.6393%2016.7423C26.3435%2016.7423%2026.9153%2016.1663%2026.9153%2015.457C26.9153%2014.7476%2026.3435%2014.1716%2025.6393%2014.1716C24.9351%2014.1716%2024.3633%2014.7476%2024.3633%2015.457Z'%20fill='%23919191'/%3e%3cdefs%3e%3clinearGradient%20id='paint0_linear_2149_1261'%20x1='11.7316'%20y1='21.2298'%20x2='11.7316'%20y2='0.821838'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20offset='0.06'%20stop-color='%2305CD66'/%3e%3cstop%20offset='0.22'%20stop-color='%230DD068'/%3e%3cstop%20offset='0.48'%20stop-color='%2326DA6F'/%3e%3cstop%20offset='0.81'%20stop-color='%234DEB7A'/%3e%3cstop%20offset='0.95'%20stop-color='%2361F380'/%3e%3c/linearGradient%3e%3clinearGradient%20id='paint1_linear_2149_1261'%20x1='22.4517'%20y1='27.0031'%20x2='22.4517'%20y2='9.99506'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20offset='0.08'%20stop-color='%23D9D9D9'/%3e%3cstop%20offset='1'%20stop-color='%23F0F0F0'/%3e%3c/linearGradient%3e%3c/defs%3e%3c/svg%3e`},{id:`wecom`,nameKey:`assistants.channels.wecom.title`,summaryKey:`assistants.channels.wecom.summary`,logo:`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2031%2026'%20role='img'%20aria-label='WeCom'%3e%3cg%20fill='none'%20fill-rule='evenodd'%3e%3cpath%20fill='%230082F0'%20d='M24.27%206.9a10.746%2010.746%200%2000-1.945-2.764C20.295%202.034%2017.453.68%2014.322.323a14.773%2014.773%200%2000-1.656-.096c-.511%200-1.044.03-1.585.089-3.144.342-6.002%201.69-8.047%203.792a10.757%2010.757%200%2000-1.955%202.757%209.634%209.634%200%2000-1.003%204.277c0%201.909.58%203.79%201.678%205.442a14.96%2014.96%200%20002.302%202.634v.002l-.378%202.974c-.015.04-.031.08-.04.123-.01.039-.012.079-.016.119-.002.03-.01.06-.01.091%200%20.033.008.065.01.098.05.489.458.872.96.872.175%200%20.337-.05.478-.131l.014-.008c.02-.012.042-.023.062-.036l.903-.454%202.69-1.352a13.93%2013.93%200%20002.35.453%2014.54%2014.54%200%20003.243-.009%2014.092%2014.092%200%20003.173-.742%201.752%201.752%200%2001-1.192-1.832c-.72.23-1.472.393-2.25.482a12.172%2012.172%200%2001-2.716.008c-.09-.01-.182-.025-.274-.037a11.976%2011.976%200%2001-1.78-.373%201.217%201.217%200%2000-.37-.057c-.2%200-.392.053-.588.154-.026.014-.05.025-.076.04l-2.21%201.303-.096.057-.003.001c-.047.028-.075.039-.1.039a.15.15%200%2001-.146-.153l.085-.345.098-.375.162-.614.179-.686a.93.93%200%2000-.334-1.033%209.906%209.906%200%2001-.923-.777c-.5-.475-.94-.994-1.31-1.55-.869-1.308-1.328-2.792-1.328-4.293%200-1.164.266-2.297.79-3.366a8.633%208.633%200%20011.569-2.21c1.68-1.728%204.045-2.837%206.656-3.12.454-.05.901-.075%201.328-.075.449%200%20.916.027%201.388.08%202.599.296%204.949%201.41%206.617%203.138a8.618%208.618%200%20011.56%202.215%207.584%207.584%200%2001.778%203.338c0%20.12-.007.24-.013.36a1.746%201.746%200%20012.149.251c.03.03.054.062.08.093a9.11%209.11%200%2000.031-.739%209.634%209.634%200%2000-.986-4.243'/%3e%3cpath%20fill='%23FB6500'%20d='M24.149%2022.148a1.7%201.7%200%2000-.21-.035%205.377%205.377%200%2001-2.996-1.67v.001a.418.418%200%2010-.534.64c.041.04.082.078.121.118a5.39%205.39%200%20011.478%202.761%201.715%201.715%200%2000.059.356%201.749%201.749%200%20002.926.777%201.754%201.754%200%2000-.844-2.948'/%3e%3cpath%20fill='%230082F0'%20d='M29.944%2017.673a1.75%201.75%200%2000-2.98%201.056%205.388%205.388%200%2001-1.667%202.999.419.419%200%2010.641.534l.117-.121a5.376%205.376%200%20012.758-1.48%201.71%201.71%200%2000.355-.058%201.754%201.754%200%2000.776-2.93'/%3e%3cpath%20fill='%232DBC00'%20d='M22.53%2012.717a1.754%201.754%200%20001.054%202.982%205.376%205.376%200%20012.996%201.67.419.419%200%2010.534-.641%205.389%205.389%200%2001-1.6-2.879%201.625%201.625%200%2000-.058-.355%201.75%201.75%200%2000-2.926-.777'/%3e%3cpath%20fill='%23FC0'%20d='M20.543%2019.19a1.93%201.93%200%2000.015-.106%205.393%205.393%200%20011.668-3%20.42.42%200%2010-.64-.534%205.375%205.375%200%2001-2.876%201.6%201.73%201.73%200%2000-.355.06%201.754%201.754%200%2000-.776%202.93%201.75%201.75%200%20002.964-.95'/%3e%3c/g%3e%3c/svg%3e`},{id:`feishu`,nameKey:`assistants.channels.feishu.title`,summaryKey:`assistants.channels.feishu.summary`,logo:`/assets/feishu-Ct1ZxlzQ.svg`},{id:`dingtalk`,nameKey:`assistants.channels.dingtalk.title`,summaryKey:`assistants.channels.dingtalk.summary`,logo:`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2032%2032'%20role='img'%20aria-label='DingTalk'%3e%3cg%20transform='translate(6%201)'%20fill='none'%20fill-rule='evenodd'%3e%3cpath%20d='M18.975%2014.517C13.963%2010.704%208.313%205.654%202.118.24%201.63-.187%201.197-.02.98.548-.416%204.18.936%207.405%203.123%209.265c2.195%201.867%205.459%203.586%207.458%204.498.078.035.01.148-.069.114C6.84%2012.283%204.285%2011.132.82%208.5c-.373-.284-.75-.174-.796.38-.283%203.472%201.972%206.198%204.489%207.12%201.557.571%203.261.887%204.842%201.075.082.01.064.13-.02.13-2.036.007-4.497-.474-6.626-1.28-.45-.17-.605.183-.535.463.363%201.467%202.205%203.71%205.136%204.18.548.089%201.133.1%201.653.085.124-.003.154.064.114.158%200%200-1.992%203.362-2.079%203.505-.068.112-.026.202.115.202h2.628c.121%200%20.196.077.134.179-.062.101-3.509%205.733-3.672%206.002-.142.234.026.413.292.22l11.597-8.365c.144-.104.11-.245-.093-.245h-2.357c-.153%200-.188-.101-.083-.205.105-.103%202.675-2.627%203.587-3.57.952-.986%201.438-2.792-.171-4.016'%20fill='%23007FFF'/%3e%3c/g%3e%3c/svg%3e`}],_s=[`disabled`,`disconnected`,`connecting`,`connected`,`reconnecting`,`error`],vs=e=>!!e&&typeof e==`object`&&!Array.isArray(e),ys=(e,t)=>{if(e!==void 0){if(typeof e!=`string`||e.length>t)throw Error(`invalid_response`);return e}};function bs(e,t){if(!vs(e)||e.provider!==t||!_s.some(t=>t===e.status)||e.error!==null&&typeof e.error!=`string`||typeof e.configured!=`boolean`||typeof e.hasSecret!=`boolean`||e.transport!==`websocket`)throw Error(`invalid_response`);let n=ys(e.clientID,512),r=ys(e.ownerID,512),i;if(e.transferSources!==void 0){if(!Array.isArray(e.transferSources))throw Error(`invalid_response`);i=e.transferSources.map(e=>{if(!vs(e))throw Error(`invalid_response`);let t=ys(e.assistantID,512),n=ys(e.name,8192),r=ys(e.revision,512),i=ys(e.clientID,512);if(!t||n===void 0||!r||!i)throw Error(`invalid_response`);return{assistantID:t,name:n,revision:r,clientID:i}})}return{provider:t,status:e.status,error:typeof e.error==`string`?e.error:null,configured:e.configured,...n===void 0?{}:{clientID:n},...r===void 0?{}:{ownerID:r},hasSecret:e.hasSecret,transport:`websocket`,...i?{transferSources:i}:{}}}var xs=e=>({provider:e,status:`unsupported`,error:null,configured:!1,hasSecret:!1,transport:`websocket`}),Ss=e=>e&&typeof e==`object`&&`error`in e&&typeof e.error==`string`?e.error:`channel_error`,Cs=async(e,t,n=``,r={})=>{let i=await l(`/api/yuri/assistants/${encodeURIComponent(e)}/channels/${t}${n}`,r);if(i.status===501||i.status===404&&!n)return xs(t);if(i.status===204)return null;let a=await i.json();if(!i.ok)throw Error(Ss(a));return bs(a,t)},ws=(e,t,n=i())=>[n,`assistants`,`channels`,e,t],Ts=(e,t,n=i())=>({queryKey:ws(e,t,n),queryFn:async({signal:n})=>{let r=await Cs(e,t,``,{signal:n});if(!r)throw Error(`invalid_response`);return r},staleTime:0,gcTime:0,retry:1,refetchOnWindowFocus:!0,refetchIntervalInBackground:!1,refetchInterval:e=>{let t=e.state.data?.status;return t===`connecting`?2e3:t===`connected`||t===`reconnecting`?15e3:!1}});function Es(e,t){let n=(0,Sa.c)(23),r=i(),a;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=o(),n[0]=a):a=n[0];let s=a,c=De(Ts(e,t,r)),u=()=>{if(r!==i()||s!==o())throw Error(`runtime_stale`)},d;n[1]!==u||n[2]!==e||n[3]!==t?(d=async n=>{let{signal:r,...i}=n;u();let a=await l(`/api/yuri/assistants/${encodeURIComponent(e)}/channels/${t}/discover`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(i),signal:r}),o=await a.json();if(u(),r.aborted)throw Error(`cancelled`);if(!a.ok)throw Error(Ss(o));if(!vs(o)||typeof o.ownerID!=`string`||!o.ownerID.trim()||o.ownerID.length>512)throw Error(`invalid_response`);return{ownerID:o.ownerID}},n[1]=u,n[2]=e,n[3]=t,n[4]=d):d=n[4];let f=Te({mutationKey:[...ws(e,t,r),`discover`],gcTime:0,mutationFn:d}),p;n[5]!==u||n[6]!==e||n[7]!==t||n[8]!==r?(p=async n=>{await Oe.cancelQueries({queryKey:ws(e,t,r)}),n.type===`transfer`&&await Oe.cancelQueries({queryKey:ws(n.sourceAssistantID,t,r)}),u();let i=await Cs(e,t,n.type===`retry`?`/retry`:n.type===`transfer`?`/transfer`:``,n.type===`transfer`?{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sourceAssistantID:n.sourceAssistantID,revision:n.revision})}:n.type===`save`?{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({clientID:n.clientID,ownerID:n.ownerID,...n.clientSecret?{clientSecret:n.clientSecret}:{},language:Ye.getState().locale})}:{method:n.type===`disconnect`?`DELETE`:`POST`});return u(),i},n[5]=u,n[6]=e,n[7]=t,n[8]=r,n[9]=p):p=n[9];let m;n[10]!==e||n[11]!==t||n[12]!==r?(m=n=>{n&&Oe.setQueryData(ws(e,t,r),n)},n[10]=e,n[11]=t,n[12]=r,n[13]=m):m=n[13];let h;n[14]!==e||n[15]!==s||n[16]!==t||n[17]!==r?(h=(n,a,c)=>{r===i()&&s===o()&&(Oe.invalidateQueries({queryKey:ws(e,t,r)}),c.type===`transfer`&&Oe.invalidateQueries({queryKey:ws(c.sourceAssistantID,t,r)}))},n[14]=e,n[15]=s,n[16]=t,n[17]=r,n[18]=h):h=n[18];let g=Te({mutationKey:[...ws(e,t,r),`change`],gcTime:0,mutationFn:p,onSuccess:m,onSettled:h}),_;return n[19]!==f||n[20]!==g||n[21]!==c?(_={query:c,mutation:g,discovery:f},n[19]=f,n[20]=g,n[21]=c,n[22]=_):_=n[22],_}var Ds={wecom:{clientID:`assistants.channels.field.wecom.clientID`,secret:`assistants.channels.field.wecom.secret`,ownerID:`assistants.channels.field.wecom.ownerID`,ownerHelp:`assistants.channels.field.wecom.ownerHelp`,ownerHelpUrl:`https://github.com/WecomTeam/aibot-node-sdk#basemessage消息体基础结构`},feishu:{clientID:`assistants.channels.field.feishu.clientID`,secret:`assistants.channels.field.feishu.secret`,ownerID:`assistants.channels.field.feishu.ownerID`,ownerHelp:`assistants.channels.field.feishu.ownerHelp`,ownerHelpUrl:`https://open.feishu.cn/document/server-docs/contact-v3/user/batch_get_id`},dingtalk:{clientID:`assistants.channels.field.dingtalk.clientID`,secret:`assistants.channels.field.dingtalk.secret`,ownerID:`assistants.channels.field.dingtalk.ownerID`,ownerHelp:`assistants.channels.field.dingtalk.ownerHelp`,ownerHelpUrl:`https://open.dingtalk.com/document/dingstart/robot-receive-message`}},Os=e=>e===`invalid_credentials`||e===`auth_failed`||e===`unauthorized`?`assistants.channels.error.invalidCredentials`:e===`auth_expired`?`assistants.channels.error.authExpired`:e===`channel_in_use`?`assistants.channels.error.channelInUse`:e===`owner_required`||e===`invalid_owner`?`assistants.channels.error.ownerRequired`:e===`delivery_unknown`?`assistants.channels.error.deliveryUnknown`:e===`connection_replaced`?`assistants.channels.error.connectionReplaced`:e===`account_in_use`||e===`already_bound`?`assistants.channels.error.accountInUse`:e===`binding_changed`?`assistants.weixin.error.bindingChanged`:e===`discovery_timeout`?`assistants.channels.discovery.timeout`:`assistants.channels.error.generic`;function ks(e){let t=(0,Sa.c)(252),{assistantID:n,provider:i,onClose:a}=e,{t:s}=Ge(),{query:c,mutation:l,discovery:u}=Es(n,i),d=c.data,[f,p]=Q.useState(``),[m,h]=Q.useState(``),[g,_]=Q.useState(``),v=Q.useRef(!1),y=Q.useRef(null),[b,x]=Q.useState(!1),[S,C]=Q.useState(null),w=Ds[i],T=l.isPending,E=Q.useSyncExternalStore(r,o,o),D;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(D=()=>{y.current?.abort(),h(``),_(``),x(!1),C(null)},t[0]=D):D=t[0];let O;t[1]===E?O=t[2]:(O=[E],t[1]=E,t[2]=O),Q.useEffect(D,O);let k,A;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(k=()=>()=>{y.current?.abort()},A=[],t[3]=k,t[4]=A):(k=t[3],A=t[4]),Q.useEffect(k,A);let j,M;t[5]===d?(j=t[6],M=t[7]):(j=()=>{!d||v.current||(v.current=!0,p(d.clientID??``),_(d.ownerID??``))},M=[d],t[5]=d,t[6]=j,t[7]=M),Q.useEffect(j,M);let N;t[8]!==f||t[9]!==m||t[10]!==u.isPending||t[11]!==l||t[12]!==a||t[13]!==g||t[14]!==T||t[15]!==d||t[16]!==s?(N=e=>{if(e.preventDefault(),!d||T)return;let t=f.trim(),n=g.trim();!t||!n||u.isPending||(!d.hasSecret||t!==d.clientID)&&!m.trim()||l.mutate({type:`save`,clientID:t,ownerID:n,...m?{clientSecret:m}:{}},{onSuccess:e=>{e?.configured&&(h(``),J.success(s(`assistants.channels.saved`)),a())}})},t[8]=f,t[9]=m,t[10]=u.isPending,t[11]=l,t[12]=a,t[13]=g,t[14]=T,t[15]=d,t[16]=s,t[17]=N):N=t[17];let P=N,F;t[18]!==f||t[19]!==m||t[20]!==u?(F=()=>{y.current?.abort();let e=new AbortController;y.current=e,u.mutate({clientID:f.trim(),...m?{clientSecret:m}:{},signal:e.signal},{onSuccess:t=>{e.signal.aborted||y.current!==e||_(t.ownerID)}})},t[18]=f,t[19]=m,t[20]=u,t[21]=F):F=t[21];let I=F,L;t[22]===u?L=t[23]:(L=()=>{y.current?.abort(),y.current=null,u.reset()},t[22]=u,t[23]=L);let R=L,z;t[24]===l?z=t[25]:(z=()=>l.mutate({type:`retry`}),t[24]=l,t[25]=z);let B=z,V;t[26]===l?V=t[27]:(V=()=>{l.mutate({type:`disconnect`},{onSuccess:()=>x(!1)})},t[26]=l,t[27]=V);let H=V;if(c.isPending){let e;t[28]===s?e=t[29]:(e=s(`common.loading`),t[28]=s,t[29]=e);let n;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin motion-reduce:animate-none`}),t[30]=n):n=t[30];let r;return t[31]===e?r=t[32]:(r=(0,$.jsx)(Z,{children:(0,$.jsx)(Xi,{label:e,children:n})}),t[31]=e,t[32]=r),r}if(c.isError&&!d){let e;t[33]===s?e=t[34]:(e=s(`assistants.channels.attention`),t[33]=s,t[34]=e);let n;t[35]===s?n=t[36]:(n=s(`assistants.channels.error.generic`),t[35]=s,t[36]=n);let r;t[37]===c?r=t[38]:(r=()=>{c.refetch()},t[37]=c,t[38]=r);let i;t[39]===s?i=t[40]:(i=s(`assistants.actions.retry`),t[39]=s,t[40]=i);let a;t[41]!==r||t[42]!==i?(a=(0,$.jsx)(q,{size:`sm`,onClick:r,children:i}),t[41]=r,t[42]=i,t[43]=a):a=t[43];let o;return t[44]!==e||t[45]!==n||t[46]!==a?(o=(0,$.jsx)(Z,{children:(0,$.jsx)(Xi,{label:e,description:n,children:a})}),t[44]=e,t[45]=n,t[46]=a,t[47]=o):o=t[47],o}if(!d||d.status===`unsupported`||d.status===`disabled`){let e=`assistants.channels.status.${d?.status??`unsupported`}`,n;t[48]!==s||t[49]!==e?(n=s(e),t[48]=s,t[49]=e,t[50]=n):n=t[50];let r;return t[51]===n?r=t[52]:(r=(0,$.jsx)(Z,{children:(0,$.jsx)(Xi,{description:n,children:null})}),t[51]=n,t[52]=r),r}let U;t[53]!==f||t[54]!==d.clientID||t[55]!==d.hasSecret?(U=!d.hasSecret||f.trim()!==(d.clientID??``),t[53]=f,t[54]=d.clientID,t[55]=d.hasSecret,t[56]=U):U=t[56];let W=U,ee;t[57]===f?ee=t[58]:(ee=f.trim(),t[57]=f,t[58]=ee);let te=ee,ne;t[59]!==m||t[60]!==W||t[61]!==te||t[62]!==T?(ne=!!(te&&(!W||m.trim()))&&!T,t[59]=m,t[60]=W,t[61]=te,t[62]=T,t[63]=ne):ne=t[63];let re=ne,ie;t[64]!==re||t[65]!==u.isPending||t[66]!==g?(ie=re&&!!g.trim()&&!u.isPending,t[64]=re,t[65]=u.isPending,t[66]=g,t[67]=ie):ie=t[67];let ae=ie,oe=d.configured,se,ce,le,ue,de,G,fe,pe,me;if(t[68]!==n||t[69]!==re||t[70]!==R||t[71]!==f||t[72]!==m||t[73]!==oe||t[74]!==I||t[75]!==u.error?.message||t[76]!==u.error?.name||t[77]!==u.isPending||t[78]!==w.clientID||t[79]!==w.ownerHelp||t[80]!==w.ownerHelpUrl||t[81]!==w.ownerID||t[82]!==w.secret||t[83]!==l||t[84]!==W||t[85]!==te||t[86]!==g||t[87]!==T||t[88]!==i||t[89]!==c.isError||t[90]!==P||t[91]!==d.error||t[92]!==d.status||t[93]!==d.transferSources||t[94]!==s||t[95]!==S){let e=oe?[]:(d.transferSources??[]).filter(e=>!te||e.clientID===te);le=oe&&d.status!==`connecting`;let r=(u.error?.name!==`AbortError`&&u.error?.message!==`cancelled`?u.error?.message:void 0)||l.error?.message||d.error,a=r?Os(r):c.isError?`assistants.channels.error.generic`:null;fe=`yuri-settings-section-stack yuri-settings-channel-form`,pe=P;let o;t[105]!==w.clientID||t[106]!==s?(o=s(w.clientID),t[105]=w.clientID,t[106]=s,t[107]=o):o=t[107];let v;t[108]===R?v=t[109]:(v=e=>{R(),p(e.target.value),_(``)},t[108]=R,t[109]=v);let y;t[110]!==w.clientID||t[111]!==s?(y=s(w.clientID),t[110]=w.clientID,t[111]=s,t[112]=y):y=t[112];let b;t[113]!==f||t[114]!==v||t[115]!==y?(b=(0,$.jsx)(Cn,{value:f,onChange:v,"aria-label":y,autoComplete:`off`,maxLength:512,required:!0}),t[113]=f,t[114]=v,t[115]=y,t[116]=b):b=t[116];let x;t[117]!==o||t[118]!==b?(x=(0,$.jsx)(Xi,{label:o,className:`yuri-settings-split-row-stacked`,children:b}),t[117]=o,t[118]=b,t[119]=x):x=t[119];let E;t[120]!==w.secret||t[121]!==s?(E=s(w.secret),t[120]=w.secret,t[121]=s,t[122]=E):E=t[122];let D=W?`assistants.channels.field.secretRequired`:`assistants.channels.field.secretKeep`,O;t[123]!==s||t[124]!==D?(O=s(D),t[123]=s,t[124]=D,t[125]=O):O=t[125];let k;t[126]===R?k=t[127]:(k=e=>{R(),h(e.target.value)},t[126]=R,t[127]=k);let A;t[128]!==w.secret||t[129]!==s?(A=s(w.secret),t[128]=w.secret,t[129]=s,t[130]=A):A=t[130];let j;t[131]!==m||t[132]!==W||t[133]!==k||t[134]!==A?(j=(0,$.jsx)(Cn,{type:`password`,value:m,onChange:k,"aria-label":A,autoComplete:`new-password`,maxLength:4096,required:W}),t[131]=m,t[132]=W,t[133]=k,t[134]=A,t[135]=j):j=t[135];let M;t[136]!==E||t[137]!==O||t[138]!==j?(M=(0,$.jsx)(Xi,{label:E,description:O,className:`yuri-settings-split-row-stacked`,children:j}),t[136]=E,t[137]=O,t[138]=j,t[139]=M):M=t[139];let N;t[140]!==w.ownerID||t[141]!==s?(N=s(w.ownerID),t[140]=w.ownerID,t[141]=s,t[142]=N):N=t[142];let F=`${n}-${i}-owner-help`,L;t[143]===s?L=t[144]:(L=s(`assistants.channels.field.ownerDescription`),t[143]=s,t[144]=L);let z;t[145]!==w.ownerHelp||t[146]!==s?(z=s(w.ownerHelp),t[145]=w.ownerHelp,t[146]=s,t[147]=z):z=t[147];let B=w.ownerHelpUrl,V;t[148]===w.ownerHelpUrl?V=t[149]:(V=e=>{e.preventDefault(),Br(w.ownerHelpUrl)},t[148]=w.ownerHelpUrl,t[149]=V);let H;t[150]===s?H=t[151]:(H=s(`assistants.channels.field.ownerHelpLink`),t[150]=s,t[151]=H);let U;t[152]!==w.ownerHelpUrl||t[153]!==V||t[154]!==H?(U=(0,$.jsx)(`a`,{href:B,target:`_blank`,rel:`noopener noreferrer`,className:`underline underline-offset-2`,onClick:V,children:H}),t[152]=w.ownerHelpUrl,t[153]=V,t[154]=H,t[155]=U):U=t[155];let ee;t[156]!==z||t[157]!==U?(ee=(0,$.jsxs)(`span`,{className:`block`,children:[z,` `,U]}),t[156]=z,t[157]=U,t[158]=ee):ee=t[158];let ne;t[159]!==F||t[160]!==L||t[161]!==ee?(ne=(0,$.jsxs)(`span`,{id:F,children:[L,ee]}),t[159]=F,t[160]=L,t[161]=ee,t[162]=ne):ne=t[162];let ie;t[163]===R?ie=t[164]:(ie=e=>{R(),_(e.target.value)},t[163]=R,t[164]=ie);let ae;t[165]!==w.ownerID||t[166]!==s?(ae=s(w.ownerID),t[165]=w.ownerID,t[166]=s,t[167]=ae):ae=t[167];let he=`${n}-${i}-owner-help`,ge;t[168]!==g||t[169]!==ie||t[170]!==ae||t[171]!==he?(ge=(0,$.jsx)(Cn,{value:g,onChange:ie,"aria-label":ae,"aria-describedby":he,autoComplete:`off`,maxLength:512,required:!0}),t[168]=g,t[169]=ie,t[170]=ae,t[171]=he,t[172]=ge):ge=t[172];let _e;t[173]!==N||t[174]!==ne||t[175]!==ge?(_e=(0,$.jsx)(Xi,{label:N,description:ne,className:`yuri-settings-split-row-stacked`,children:ge}),t[173]=N,t[174]=ne,t[175]=ge,t[176]=_e):_e=t[176];let ve;t[177]!==re||t[178]!==R||t[179]!==I||t[180]!==u.isPending||t[181]!==g||t[182]!==s?(ve=g.trim()?null:(0,$.jsxs)(Xi,{className:`yuri-settings-split-row-stacked`,description:s(u.isPending?`assistants.channels.discovery.waiting`:`assistants.channels.discovery.hint`),children:[(0,$.jsxs)(q,{size:`sm`,disabled:!re||u.isPending,"aria-busy":u.isPending,onClick:I,children:[u.isPending?(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin motion-reduce:animate-none`}):null,s(`assistants.channels.discovery.start`)]}),u.isPending?(0,$.jsx)(q,{size:`sm`,variant:`ghost`,onClick:R,children:s(`settings.common.actions.cancel`)}):null]}),t[177]=re,t[178]=R,t[179]=I,t[180]=u.isPending,t[181]=g,t[182]=s,t[183]=ve):ve=t[183],t[184]!==x||t[185]!==M||t[186]!==_e||t[187]!==ve?(me=(0,$.jsxs)(Z,{children:[x,M,_e,ve]}),t[184]=x,t[185]=M,t[186]=_e,t[187]=ve,t[188]=me):me=t[188],ce=Z;let ye;t[189]!==u.isPending||t[190]!==l||t[191]!==T||t[192]!==s||t[193]!==S?(ye=e=>(0,$.jsx)(Xi,{className:`yuri-settings-split-row-stacked`,label:s(`assistants.weixin.transferFrom`,{name:e.name}),description:S?.assistantID===e.assistantID?s(`assistants.weixin.transferWarning`):void 0,children:S?.assistantID===e.assistantID?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(q,{size:`sm`,variant:`ghost`,disabled:T,onClick:()=>C(null),children:s(`settings.common.actions.cancel`)}),(0,$.jsx)(q,{size:`sm`,disabled:T||u.isPending||S.revision!==e.revision,"aria-busy":T,onClick:()=>{l.mutate({type:`transfer`,sourceAssistantID:S.assistantID,revision:S.revision},{onSuccess:e=>{C(null),h(``),e&&(p(e.clientID??``),_(e.ownerID??``))}})},children:s(`assistants.weixin.transferConfirm`)})]}):(0,$.jsx)(q,{size:`sm`,disabled:T,onClick:()=>C({...e}),children:s(`assistants.weixin.transfer`)})},e.assistantID),t[189]=u.isPending,t[190]=l,t[191]=T,t[192]=s,t[193]=S,t[194]=ye):ye=t[194],G=e.map(ye),se=Xi;let be=`assistants.channels.status.${d.status}`;t[195]!==s||t[196]!==be?(ue=s(be),t[195]=s,t[196]=be,t[197]=ue):ue=t[197],de=a&&!(e.length&&a===`assistants.channels.error.accountInUse`)?s(a):void 0,t[68]=n,t[69]=re,t[70]=R,t[71]=f,t[72]=m,t[73]=oe,t[74]=I,t[75]=u.error?.message,t[76]=u.error?.name,t[77]=u.isPending,t[78]=w.clientID,t[79]=w.ownerHelp,t[80]=w.ownerHelpUrl,t[81]=w.ownerID,t[82]=w.secret,t[83]=l,t[84]=W,t[85]=te,t[86]=g,t[87]=T,t[88]=i,t[89]=c.isError,t[90]=P,t[91]=d.error,t[92]=d.status,t[93]=d.transferSources,t[94]=s,t[95]=S,t[96]=se,t[97]=ce,t[98]=le,t[99]=ue,t[100]=de,t[101]=G,t[102]=fe,t[103]=pe,t[104]=me}else se=t[96],ce=t[97],le=t[98],ue=t[99],de=t[100],G=t[101],fe=t[102],pe=t[103],me=t[104];let he;t[198]!==le||t[199]!==u.isPending||t[200]!==T||t[201]!==B||t[202]!==s?(he=le?(0,$.jsx)(q,{size:`sm`,variant:`ghost`,disabled:T||u.isPending,onClick:B,children:s(`assistants.channels.actions.retry`)}):null,t[198]=le,t[199]=u.isPending,t[200]=T,t[201]=B,t[202]=s,t[203]=he):he=t[203];let ge;t[204]!==oe||t[205]!==b||t[206]!==u.isPending||t[207]!==T||t[208]!==s?(ge=oe&&!b?(0,$.jsx)(q,{size:`sm`,variant:`ghost`,disabled:T||u.isPending,onClick:()=>x(!0),children:s(`assistants.channels.actions.disconnect`)}):null,t[204]=oe,t[205]=b,t[206]=u.isPending,t[207]=T,t[208]=s,t[209]=ge):ge=t[209];let _e;t[210]!==se||t[211]!==ue||t[212]!==de||t[213]!==he||t[214]!==ge?(_e=(0,$.jsxs)(se,{label:ue,description:de,className:`yuri-settings-split-row-stacked`,children:[he,ge]}),t[210]=se,t[211]=ue,t[212]=de,t[213]=he,t[214]=ge,t[215]=_e):_e=t[215];let ve;t[216]!==oe||t[217]!==b||t[218]!==H||t[219]!==u.isPending||t[220]!==T||t[221]!==s?(ve=oe&&b?(0,$.jsxs)(Xi,{className:`yuri-settings-split-row-stacked`,description:s(`assistants.channels.disconnectWarning`),children:[(0,$.jsx)(q,{size:`sm`,variant:`ghost`,disabled:T,onClick:()=>x(!1),children:s(`settings.common.actions.cancel`)}),(0,$.jsx)(q,{size:`sm`,variant:`destructive`,disabled:T||u.isPending,onClick:H,"aria-busy":T,children:s(`assistants.channels.actions.confirmDisconnect`)})]}):null,t[216]=oe,t[217]=b,t[218]=H,t[219]=u.isPending,t[220]=T,t[221]=s,t[222]=ve):ve=t[222];let ye;t[223]!==ce||t[224]!==G||t[225]!==_e||t[226]!==ve?(ye=(0,$.jsxs)(ce,{children:[G,_e,ve]}),t[223]=ce,t[224]=G,t[225]=_e,t[226]=ve,t[227]=ye):ye=t[227];let be;t[228]===s?be=t[229]:(be=s(`settings.common.actions.cancel`),t[228]=s,t[229]=be);let xe;t[230]!==a||t[231]!==T||t[232]!==be?(xe=(0,$.jsx)(q,{type:`button`,size:`sm`,variant:`ghost`,disabled:T,onClick:a,children:be}),t[230]=a,t[231]=T,t[232]=be,t[233]=xe):xe=t[233];let Se=!ae,Ce;t[234]===T?Ce=t[235]:(Ce=T?(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin motion-reduce:animate-none`}):null,t[234]=T,t[235]=Ce);let we;t[236]===s?we=t[237]:(we=s(`assistants.channels.actions.save`),t[236]=s,t[237]=we);let Te;t[238]!==T||t[239]!==Se||t[240]!==Ce||t[241]!==we?(Te=(0,$.jsxs)(q,{type:`submit`,size:`sm`,disabled:Se,"aria-busy":T,children:[Ce,we]}),t[238]=T,t[239]=Se,t[240]=Ce,t[241]=we,t[242]=Te):Te=t[242];let Ee;t[243]!==xe||t[244]!==Te?(Ee=(0,$.jsxs)(`div`,{className:`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end`,children:[xe,Te]}),t[243]=xe,t[244]=Te,t[245]=Ee):Ee=t[245];let De;return t[246]!==fe||t[247]!==pe||t[248]!==me||t[249]!==ye||t[250]!==Ee?(De=(0,$.jsxs)(`form`,{className:fe,onSubmit:pe,children:[me,ye,Ee]}),t[246]=fe,t[247]=pe,t[248]=me,t[249]=ye,t[250]=Ee,t[251]=De):De=t[251],De}var As=t(la(),1),js=[`disconnected`,`waiting`,`scanned`,`verify`,`connected`,`reconnecting`,`expired`,`error`,`unsupported`,`disabled`];function Ms(e){if(!e||typeof e!=`object`||!(`status`in e)||!js.some(t=>t===e.status))throw Error(`invalid_response`);let t=e,n;if(t.transferSources!==void 0){if(!Array.isArray(t.transferSources)||t.transferSources.length>100)throw Error(`invalid_response`);n=t.transferSources.map(e=>{if(!e||typeof e!=`object`||!(`assistantID`in e)||!(`name`in e)||!(`revision`in e)||typeof e.assistantID!=`string`||!e.assistantID||typeof e.name!=`string`||typeof e.revision!=`string`||!e.revision)throw Error(`invalid_response`);return{assistantID:e.assistantID,name:e.name,revision:e.revision}})}return{status:t.status,error:typeof t.error==`string`?t.error:null,...typeof t.qrCode==`string`&&t.qrCode.length<=8192?{qrCode:t.qrCode}:{},...typeof t.expiresAt==`number`?{expiresAt:t.expiresAt}:{},...n?{transferSources:n}:{}}}var Ns=(e,t=i())=>[t,`assistants`,`weixin`,e],Ps=async(e,t=``,n={})=>{let r=await l(`/api/yuri/assistants/${encodeURIComponent(e)}/weixin${t}`,n);if(r.status===501||r.status===404&&!t)return{status:`unsupported`,error:null};let i=await r.json();if(!r.ok){let e=i&&typeof i==`object`&&`error`in i&&typeof i.error==`string`?i.error:`channel_error`;throw Error(e)}return Ms(i)},Fs=(e,t=i())=>({queryKey:Ns(e,t),queryFn:({signal:t})=>Ps(e,``,{signal:t}),staleTime:0,gcTime:0,retry:1,refetchOnWindowFocus:!0,refetchIntervalInBackground:!1,refetchInterval:e=>{let t=e.state.data?.status;return t===`waiting`||t===`scanned`||t===`verify`?2e3:t===`connected`||t===`reconnecting`?15e3:!1}});function Is(e){let t=(0,Sa.c)(14),n=i(),r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=o(),t[0]=r):r=t[0];let a=r,s=De(Fs(e,n)),c=()=>{if(n!==i()||a!==o())throw Error(`runtime_stale`)},l;t[1]!==c||t[2]!==e||t[3]!==n?(l=async t=>{await Oe.cancelQueries({queryKey:[n,`assistants`,`weixin`]}),c();let r=await Ps(e,t.type===`disconnect`?``:`/${t.type}`,{method:t.type===`disconnect`?`DELETE`:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t.type===`verify`?{code:t.code}:{...t.type===`transfer`?{sourceAssistantID:t.sourceAssistantID,revision:t.revision}:{},language:Ye.getState().locale})});return c(),r},t[1]=c,t[2]=e,t[3]=n,t[4]=l):l=t[4];let u;t[5]!==e||t[6]!==n?(u=t=>Oe.setQueryData(Ns(e,n),t),t[5]=e,t[6]=n,t[7]=u):u=t[7];let d;t[8]!==a||t[9]!==n?(d=()=>{n===i()&&a===o()&&Oe.invalidateQueries({queryKey:[n,`assistants`,`weixin`]})},t[8]=a,t[9]=n,t[10]=d):d=t[10];let f=Te({mutationKey:[...Ns(e,n),`change`],gcTime:0,mutationFn:l,onSuccess:u,onSettled:d}),p;return t[11]!==f||t[12]!==s?(p={query:s,mutation:f},t[11]=f,t[12]=s,t[13]=p):p=t[13],p}var Ls=e=>e===`account_in_use`||e===`already_bound`?`assistants.weixin.error.accountInUse`:e===`auth_expired`?`assistants.weixin.error.authExpired`:e===`delivery_unknown`?`assistants.weixin.error.deliveryUnknown`:e===`reply_unavailable`?`assistants.weixin.error.replyUnavailable`:e===`channel_in_use`?`assistants.weixin.error.channelInUse`:e===`binding_changed`?`assistants.weixin.error.bindingChanged`:`assistants.weixin.error.generic`;function Rs(e){let t=(0,Sa.c)(4),{assistantID:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=i(),t[0]=r):r=t[0];let a=`${r}:${n}`,o;return t[1]!==n||t[2]!==a?(o=(0,$.jsx)(Z,{children:(0,$.jsx)(zs,{assistantID:n},a)}),t[1]=n,t[2]=a,t[3]=o):o=t[3],o}function zs(e){let t=(0,Sa.c)(76),{assistantID:n}=e,{t:r}=Ge(),{query:i,mutation:a}=Is(n),[o,s]=Q.useState(null),[c,l]=Q.useState(!1),[u,d]=Q.useState(``),[f,p]=Q.useState(null),m=i.data,h=m?.qrCode??``,g=a.isPending,_=m?.status===`waiting`||m?.status===`scanned`||m?.status===`verify`,v=m?.status===`connected`||m?.status===`reconnecting`,y=m?.status===`unsupported`||m?.status===`disabled`,b;t[0]!==v||t[1]!==m?.transferSources||t[2]!==y||t[3]!==_?(b=!v&&!_&&!y?m?.transferSources??[]:[],t[0]=v,t[1]=m?.transferSources,t[2]=y,t[3]=_,t[4]=b):b=t[4];let x=b,S,C;t[5]===h?(S=t[6],C=t[7]):(S=()=>{if(!h)return;let e=!1;return As.toDataURL(h,{width:640,margin:4,errorCorrectionLevel:`M`}).then(t=>{e||(s({value:h,url:t}),l(!1))}).catch(()=>{e||l(!0)}),()=>{e=!0}},C=[h],t[5]=h,t[6]=S,t[7]=C),Q.useEffect(S,C);let w;t[8]===a?w=t[9]:(w=()=>a.mutate({type:`login`}),t[8]=a,t[9]=w);let T=He(w),E;t[10]===a?E=t[11]:(E=()=>a.mutate({type:`disconnect`}),t[10]=a,t[11]=E);let D=He(E),O;t[12]===a?O=t[13]:(O=()=>a.mutate({type:`retry`}),t[12]=a,t[13]=O);let k=He(O),A;t[14]!==a||t[15]!==f?(A=()=>{f&&a.mutate({type:`transfer`,sourceAssistantID:f.assistantID,revision:f.revision},{onSuccess:()=>p(null)})},t[14]=a,t[15]=f,t[16]=A):A=t[16];let j=He(A),M;t[17]!==u||t[18]!==a?(M=e=>{e.preventDefault(),a.mutate({type:`verify`,code:u},{onSuccess:()=>d(``)})},t[17]=u,t[18]=a,t[19]=M):M=t[19];let N=He(M),P;t[20]===i?P=t[21]:(P=()=>{i.refetch()},t[20]=i,t[21]=P);let F=He(P),I=a.error?.message||m?.error||(i.isError||c?`channel_error`:null),L;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(X,{name:`chat-thread`,className:`size-4`}),t[22]=L):L=t[22];let R;t[23]===r?R=t[24]:(R=r(`assistants.weixin.title`),t[23]=r,t[24]=R);let z;t[25]===R?z=t[26]:(z=(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[L,R]}),t[25]=R,t[26]=z);let B;t[27]!==m||t[28]!==r?(B=r(m?`assistants.weixin.status.${m.status}`:`common.loading`),t[27]=m,t[28]=r,t[29]=B):B=t[29];let V;t[30]!==v||t[31]!==T||t[32]!==D||t[33]!==g||t[34]!==i.isPending||t[35]!==F||t[36]!==m||t[37]!==r||t[38]!==y||t[39]!==_?(V=i.isPending?(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin motion-reduce:animate-none`}):y?null:v||_?(0,$.jsx)(q,{size:`sm`,variant:`ghost`,disabled:g,onClick:D,children:r(v?`assistants.weixin.disconnect`:`settings.common.actions.cancel`)}):(0,$.jsxs)($.Fragment,{children:[m?.status===`expired`||m?.status===`error`?(0,$.jsx)(q,{size:`sm`,variant:`ghost`,disabled:g,onClick:D,children:r(`assistants.weixin.disconnect`)}):null,(0,$.jsxs)(q,{size:`sm`,disabled:g,onClick:m?T:F,"aria-busy":g,children:[g?(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin motion-reduce:animate-none`}):null,r(m?`assistants.weixin.connect`:`assistants.actions.retry`)]})]}),t[30]=v,t[31]=T,t[32]=D,t[33]=g,t[34]=i.isPending,t[35]=F,t[36]=m,t[37]=r,t[38]=y,t[39]=_,t[40]=V):V=t[40];let H;t[41]!==z||t[42]!==B||t[43]!==V?(H=(0,$.jsx)(Xi,{label:z,description:B,children:V}),t[41]=z,t[42]=B,t[43]=V,t[44]=H):H=t[44];let U;if(t[45]!==g||t[46]!==x||t[47]!==r||t[48]!==j||t[49]!==f){let e;t[51]!==g||t[52]!==r||t[53]!==j||t[54]!==f?(e=e=>(0,$.jsx)(Xi,{className:f?.assistantID===e.assistantID?`yuri-settings-split-row-stacked`:void 0,label:r(`assistants.weixin.transferFrom`,{name:e.name}),description:f?.assistantID===e.assistantID?r(`assistants.weixin.transferWarning`):void 0,children:f?.assistantID===e.assistantID?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(q,{size:`sm`,variant:`ghost`,disabled:g,onClick:()=>p(null),children:r(`settings.common.actions.cancel`)}),(0,$.jsx)(q,{size:`sm`,disabled:g||f.revision!==e.revision,onClick:j,"aria-busy":g,children:r(`assistants.weixin.transferConfirm`)})]}):(0,$.jsx)(q,{size:`sm`,disabled:g,onClick:()=>p(e),children:r(`assistants.weixin.transfer`)})},e.assistantID),t[51]=g,t[52]=r,t[53]=j,t[54]=f,t[55]=e):e=t[55],U=x.map(e),t[45]=g,t[46]=x,t[47]=r,t[48]=j,t[49]=f,t[50]=U}else U=t[50];let W;t[56]!==u||t[57]!==g||t[58]!==o||t[59]!==m?.status||t[60]!==r||t[61]!==h||t[62]!==N||t[63]!==_?(W=_?(0,$.jsxs)(Xi,{controlClassName:`flex-col items-center`,label:r(`assistants.weixin.scan`),children:[h&&o?.value===h?(0,$.jsx)(`img`,{src:o.url,alt:r(`assistants.weixin.qrAlt`),className:`size-48 max-w-full rounded-lg`,width:192,height:192}):(0,$.jsx)(`span`,{className:`flex size-48 items-center justify-center`,children:(0,$.jsx)(X,{name:`loader-4`,className:`size-5 animate-spin motion-reduce:animate-none`})}),m?.status===`verify`?(0,$.jsxs)(`form`,{onSubmit:N,className:`flex w-full min-w-0 items-center gap-2`,children:[(0,$.jsx)(Cn,{"aria-label":r(`assistants.weixin.verify`),placeholder:r(`assistants.weixin.verify`),inputMode:`numeric`,autoComplete:`one-time-code`,value:u,maxLength:12,onChange:e=>d(e.target.value.replace(/\D/g,``))}),(0,$.jsx)(q,{type:`submit`,size:`sm`,disabled:g||u.length<4,children:r(`assistants.weixin.verifySubmit`)})]}):null]}):null,t[56]=u,t[57]=g,t[58]=o,t[59]=m?.status,t[60]=r,t[61]=h,t[62]=N,t[63]=_,t[64]=W):W=t[64];let ee;t[65]!==v||t[66]!==I||t[67]!==g||t[68]!==k||t[69]!==r?(ee=I?(0,$.jsxs)(Xi,{description:r(Ls(I)),children:[(0,$.jsx)(`span`,{role:`status`,className:`typography-meta text-[var(--status-warning)]`,children:r(`assistants.weixin.attention`)}),v&&I!==`auth_expired`&&I!==`channel_in_use`?(0,$.jsx)(q,{size:`sm`,onClick:k,disabled:g,children:r(`assistants.actions.retry`)}):null]}):null,t[65]=v,t[66]=I,t[67]=g,t[68]=k,t[69]=r,t[70]=ee):ee=t[70];let te;return t[71]!==H||t[72]!==U||t[73]!==W||t[74]!==ee?(te=(0,$.jsxs)($.Fragment,{children:[H,U,W,ee]}),t[71]=H,t[72]=U,t[73]=W,t[74]=ee,t[75]=te):te=t[75],te}function Bs(e){let t=(0,Sa.c)(49),{assistantID:n,channel:a,open:o,onOpenChange:s}=e,{t:c}=Ge(),l=Q.useSyncExternalStore(r,i,i),u,d,f,p,m,h,g,_,v,y,b;if(t[0]!==a||t[1]!==s||t[2]!==o||t[3]!==c){let e=gs.find(e=>e.id===a)??gs[0],n;t[15]===s?n=t[16]:(n=()=>s(!1),t[15]=s,t[16]=n),m=n,p=gn,y=o,b=s,f=pn,v=`yuri-settings-workspace yuri-settings-workspace-desktop max-h-[85vh] max-w-lg overflow-y-auto`,d=dn,g=`flex items-center gap-2.5`,_=(0,$.jsx)(`img`,{src:e.logo,alt:``,"aria-hidden":!0,className:`size-7 shrink-0`}),u=mn,h=c(e.nameKey),t[0]=a,t[1]=s,t[2]=o,t[3]=c,t[4]=u,t[5]=d,t[6]=f,t[7]=p,t[8]=m,t[9]=h,t[10]=g,t[11]=_,t[12]=v,t[13]=y,t[14]=b}else u=t[4],d=t[5],f=t[6],p=t[7],m=t[8],h=t[9],g=t[10],_=t[11],v=t[12],y=t[13],b=t[14];let x;t[17]!==u||t[18]!==h?(x=(0,$.jsx)(u,{children:h}),t[17]=u,t[18]=h,t[19]=x):x=t[19];let S;t[20]!==g||t[21]!==_||t[22]!==x?(S=(0,$.jsxs)(`div`,{className:g,children:[_,x]}),t[20]=g,t[21]=_,t[22]=x,t[23]=S):S=t[23];let C;t[24]!==d||t[25]!==S?(C=(0,$.jsx)(d,{children:S}),t[24]=d,t[25]=S,t[26]=C):C=t[26];let w;t[27]!==n||t[28]!==a||t[29]!==o||t[30]!==l?(w=o&&a===`wechat`?(0,$.jsx)(Rs,{assistantID:n},`${l}:${n}:${a}`):null,t[27]=n,t[28]=a,t[29]=o,t[30]=l,t[31]=w):w=t[31];let T;t[32]!==n||t[33]!==a||t[34]!==m||t[35]!==o||t[36]!==l?(T=o&&a!==`wechat`?(0,$.jsx)(ks,{assistantID:n,provider:a,onClose:m},`${l}:${n}:${a}`):null,t[32]=n,t[33]=a,t[34]=m,t[35]=o,t[36]=l,t[37]=T):T=t[37];let E;t[38]!==f||t[39]!==w||t[40]!==T||t[41]!==v||t[42]!==C?(E=(0,$.jsxs)(f,{className:v,children:[C,w,T]}),t[38]=f,t[39]=w,t[40]=T,t[41]=v,t[42]=C,t[43]=E):E=t[43];let D;return t[44]!==p||t[45]!==E||t[46]!==y||t[47]!==b?(D=(0,$.jsx)(p,{open:y,onOpenChange:b,children:E}),t[44]=p,t[45]=E,t[46]=y,t[47]=b,t[48]=D):D=t[48],D}function Vs(e){let t=(0,Sa.c)(21),{assistantID:n}=e,{t:r}=Ge(),[i,a]=Q.useState(null),o;t[0]===r?o=t[1]:(o=r(`assistants.channels.title`),t[0]=r,t[1]=o);let s;t[2]===r?s=t[3]:(s=r(`assistants.channels.description`),t[2]=r,t[3]=s);let c;t[4]!==i||t[5]!==r?(c=gs.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>a(e.id),"aria-haspopup":`dialog`,"aria-expanded":i===e.id,className:`group flex min-h-20 w-full min-w-0 items-center gap-3 rounded-xl bg-transparent px-3 py-2.5 text-left ring-1 ring-inset ring-border/60 transition-colors hover:bg-[var(--interactive-hover)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,children:[(0,$.jsx)(`img`,{src:e.logo,alt:``,"aria-hidden":!0,className:`size-8 shrink-0`}),(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`block truncate typography-ui-label text-foreground`,children:r(e.nameKey)}),(0,$.jsx)(`span`,{className:`mt-0.5 block truncate typography-meta text-muted-foreground`,children:r(e.summaryKey)})]})]},e.id)),t[4]=i,t[5]=r,t[6]=c):c=t[6];let l;t[7]===c?l=t[8]:(l=(0,$.jsx)(Xi,{className:`yuri-settings-split-row-stacked`,copyClassName:`hidden`,controlClassName:`w-full`,children:(0,$.jsx)(`div`,{className:`grid w-full grid-cols-2 gap-2`,children:c})}),t[7]=c,t[8]=l);let u;t[9]!==o||t[10]!==s||t[11]!==l?(u=(0,$.jsx)(Z,{label:o,description:s,children:l}),t[9]=o,t[10]=s,t[11]=l,t[12]=u):u=t[12];let d=i??`wechat`,f=i!==null,p;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(p=e=>{e||a(null)},t[13]=p):p=t[13];let m;t[14]!==n||t[15]!==d||t[16]!==f?(m=(0,$.jsx)(Bs,{assistantID:n,channel:d,open:f,onOpenChange:p}),t[14]=n,t[15]=d,t[16]=f,t[17]=m):m=t[17];let h;return t[18]!==u||t[19]!==m?(h=(0,$.jsxs)($.Fragment,{children:[u,m]}),t[18]=u,t[19]=m,t[20]=h):h=t[20],h}var Hs=`__managed_workspace__`,Us=`__current_workspace__`,Ws=`Yuri`,Gs=()=>{let e=pt.getState(),t=e.settingsDefaultModel??(e.currentModelId?void 0:e.opencodeDefaultModel);if(t){let n=Zt(t);if(n?.providerId&&n?.modelId)return{providerID:n.providerId,modelID:n.modelId,variant:n.variant??e.settingsDefaultVariant}}if(e.currentProviderId&&e.currentModelId)return{providerID:e.currentProviderId,modelID:e.currentModelId,variant:e.currentVariant};let n=e.providers;for(let e of n){let t=e.models;if(Array.isArray(t)&&t.length>0){let n=t[0];if(n?.id)return{providerID:e.id,modelID:n.id}}}return null},Ks=(e=``)=>{let t=Gs();return{name:e,avatarSeed:an(crypto.randomUUID()),defaultPrompt:``,workspacePath:null,providerID:t?.providerID??``,modelID:t?.modelID??``,variant:t?.variant??null}},qs=e=>({avatarSeed:e.avatarSeed??e.id,name:e.name,defaultPrompt:e.defaultPrompt,workspacePath:e.workspacePath,providerID:e.providerID,modelID:e.modelID,variant:e.variant}),Js=e=>({avatarSeed:e.avatarSeed,name:e.name,defaultPrompt:e.defaultPrompt,workspacePath:e.workspacePath,providerID:e.providerID,modelID:e.modelID,variant:e.variant??null}),Ys=e=>e.label?.trim()||e.path.replace(/[\\/]+$/,``).split(/[\\/]/).filter(Boolean).at(-1)||e.path,Xs=e=>{let t=Array.isArray(e.schedule.times)?e.schedule.times:e.schedule.time?[e.schedule.time]:[];return Array.from(new Set(t.filter(e=>/^([01]\d|2[0-3]):([0-5]\d)$/.test(e)))).sort((e,t)=>e.localeCompare(t))},Zs=e=>!!e&&typeof e==`object`&&!Array.isArray(e),Qs=e=>{if(!Zs(e)||!Zs(e.schedule)||!Zs(e.execution)||!Zs(e.state))return!1;let t=e.schedule.times===void 0||Array.isArray(e.schedule.times)&&e.schedule.times.every(e=>typeof e==`string`),n=e.schedule.weekdays===void 0||Array.isArray(e.schedule.weekdays)&&e.schedule.weekdays.every(e=>typeof e==`number`),r=e.state.lastStatus===void 0||e.state.lastStatus===`idle`||e.state.lastStatus===`running`||e.state.lastStatus===`success`||e.state.lastStatus===`error`;return typeof e.id==`string`&&typeof e.name==`string`&&typeof e.enabled==`boolean`&&(e.schedule.kind===`daily`||e.schedule.kind===`weekly`||e.schedule.kind===`once`||e.schedule.kind===`cron`)&&t&&n&&r&&typeof e.execution.prompt==`string`&&typeof e.execution.providerID==`string`&&typeof e.execution.modelID==`string`},$s=(e,t)=>{let n=Xs(e).join(`, `)||`—`,r=e=>t(e===0?`sessions.scheduledTasks.dialog.schedule.weekdayShort.sun`:e===1?`sessions.scheduledTasks.dialog.schedule.weekdayShort.mon`:e===2?`sessions.scheduledTasks.dialog.schedule.weekdayShort.tue`:e===3?`sessions.scheduledTasks.dialog.schedule.weekdayShort.wed`:e===4?`sessions.scheduledTasks.dialog.schedule.weekdayShort.thu`:e===5?`sessions.scheduledTasks.dialog.schedule.weekdayShort.fri`:e===6?`sessions.scheduledTasks.dialog.schedule.weekdayShort.sat`:`sessions.scheduledTasks.dialog.schedule.weekdayShort.unknown`);if(e.schedule.kind===`daily`)return e.schedule.timezone?t(`sessions.scheduledTasks.dialog.schedule.dailyWithTimezone`,{time:n,timezone:e.schedule.timezone}):t(`sessions.scheduledTasks.dialog.schedule.daily`,{time:n});if(e.schedule.kind===`weekly`){let i=(e.schedule.weekdays??[]).map(r).join(`, `);return e.schedule.timezone?t(`sessions.scheduledTasks.dialog.schedule.weeklyWithTimezone`,{days:i,time:n,timezone:e.schedule.timezone}):t(`sessions.scheduledTasks.dialog.schedule.weekly`,{days:i,time:n})}if(e.schedule.kind===`once`){let n=e.schedule.date?.trim()||t(`sessions.scheduledTasks.dialog.schedule.unknownDate`),r=e.schedule.time?.trim()||`—`;return e.schedule.timezone?t(`sessions.scheduledTasks.dialog.schedule.onceWithTimezone`,{date:n,time:r,timezone:e.schedule.timezone}):t(`sessions.scheduledTasks.dialog.schedule.once`,{date:n,time:r})}return e.schedule.timezone?t(`sessions.scheduledTasks.dialog.schedule.cronWithTimezone`,{cron:e.schedule.cron??``,timezone:e.schedule.timezone}):t(`sessions.scheduledTasks.dialog.schedule.cron`,{cron:e.schedule.cron??``})},ec={paused:{icon:`pause`,className:`text-muted-foreground`},idle:{icon:`pulse`,className:`text-muted-foreground`},running:{icon:`loader-4`,className:`text-[var(--status-warning)]`},success:{icon:`checkbox-circle`,className:`text-[var(--status-success)]`},error:{icon:`error-warning`,className:`text-[var(--status-error)]`}},tc=e=>`${e.projectId}:${e.task.id}`,nc=e=>{let t=(0,Sa.c)(38),{assistantID:n}=e,{t:r}=Ge(),i=Qe(n),a=i.isError,o=tt(n,a),s=st(a),c,l,u,d,f,p,m,h,g;if(t[0]!==o.data?.messages||t[1]!==o.isError||t[2]!==o.isPending||t[3]!==a||t[4]!==s||t[5]!==i.data||t[6]!==i.isError||t[7]!==i.isPending||t[8]!==r){h=Symbol.for(`react.early_return_sentinel`);bb0:{let e=new Set;for(let t of o.data?.messages??[])for(let n of t.cards)n.cardType===`schedule`&&e.add(`${n.projectID}:${n.taskID}`);let n=(i.data?.tasks??[]).flatMap(oc),_;t[18]===i.data?.tasks?_=t[19]:(_=i.data?.tasks.some(sc),t[18]=i.data?.tasks,t[19]=_);let v=!!_,y=(s.data?.tasks??[]).filter(t=>e.has(tc(t)));g=[...i.data?n:a?y:[]].sort(cc);let b=(s.data?.failedProjectIds??[]).some(t=>Array.from(e).some(e=>e.startsWith(`${t}:`)));if(u=i.isPending||a&&(o.isPending||s.isPending),l=i.isError||o.isError||s.isError||b||v,!u&&l&&g.length===0){h=null;break bb0}c=Z,t[20]===r?d=t[21]:(d=r(`assistants.settings.scheduledTasks.title`),t[20]=r,t[21]=d),t[22]===r?f=t[23]:(f=r(`assistants.settings.scheduledTasks.title`),t[22]=r,t[23]=f),p=u&&g.length===0?(0,$.jsx)(Xi,{label:r(`common.loading`),children:(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin text-muted-foreground`})}):null;let x;t[24]===r?x=t[25]:(x=e=>{let t=e.task.enabled?e.task.state?.lastStatus??`idle`:`paused`,n=ec[t],i=r(t===`paused`?`sessions.scheduledTasks.dialog.taskToggle.paused`:t===`running`?`sessions.scheduledTasks.dialog.status.running`:t===`success`?`sessions.scheduledTasks.dialog.status.success`:t===`error`?`sessions.scheduledTasks.dialog.status.error`:`sessions.scheduledTasks.dialog.status.idle`);return(0,$.jsxs)(q,{type:`button`,variant:`ghost`,className:`yuri-settings-group-row yuri-settings-split-row h-auto rounded-none text-left font-normal focus-visible:ring-inset`,onClick:()=>Or(e.projectId,e.task.id),"aria-label":r(`assistants.settings.scheduledTasks.open`,{name:e.task.name}),children:[(0,$.jsx)(`span`,{className:`yuri-settings-split-row-copy`,children:(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-3`,children:[(0,$.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center rounded-lg bg-[var(--surface-muted)] text-muted-foreground`,children:(0,$.jsx)(X,{name:`calendar`,className:`size-3.5`})}),(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`block truncate typography-ui-label font-medium text-foreground`,children:e.task.name}),(0,$.jsx)(`span`,{className:`mt-0.5 block typography-micro truncate text-muted-foreground`,children:$s(e.task,r)})]})]})}),(0,$.jsxs)(`span`,{className:`yuri-settings-split-row-control min-w-fit text-muted-foreground`,children:[(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 typography-micro ${n.className}`,children:[(0,$.jsx)(X,{name:n.icon,className:`size-3.5 ${t===`running`?`animate-spin`:``}`}),i]}),(0,$.jsx)(X,{name:`arrow-right-s`,className:`size-4`})]})]},tc(e))},t[24]=r,t[25]=x),m=g.map(x)}t[0]=o.data?.messages,t[1]=o.isError,t[2]=o.isPending,t[3]=a,t[4]=s,t[5]=i.data,t[6]=i.isError,t[7]=i.isPending,t[8]=r,t[9]=c,t[10]=l,t[11]=u,t[12]=d,t[13]=f,t[14]=p,t[15]=m,t[16]=h,t[17]=g}else c=t[9],l=t[10],u=t[11],d=t[12],f=t[13],p=t[14],m=t[15],h=t[16],g=t[17];if(h!==Symbol.for(`react.early_return_sentinel`))return h;let _;t[26]!==l||t[27]!==u||t[28]!==r||t[29]!==g?(_=!u&&!l&&g.length===0?(0,$.jsx)(Xi,{label:r(`assistants.settings.scheduledTasks.empty`),children:(0,$.jsx)(X,{name:`calendar`,className:`size-4 text-muted-foreground`})}):null,t[26]=l,t[27]=u,t[28]=r,t[29]=g,t[30]=_):_=t[30];let v;return t[31]!==c||t[32]!==d||t[33]!==f||t[34]!==p||t[35]!==m||t[36]!==_?(v=(0,$.jsxs)(c,{label:d,ariaLabel:f,children:[p,m,_]}),t[31]=c,t[32]=d,t[33]=f,t[34]=p,t[35]=m,t[36]=_,t[37]=v):v=t[37],v},rc=e=>{let t=(0,Sa.c)(11),{name:n,path:r,icon:i}=e,a=i===void 0?`folder`:i,o;t[0]===a?o=t[1]:(o=(0,$.jsx)(X,{name:a,className:`size-4 shrink-0 text-muted-foreground`}),t[0]=a,t[1]=o);let s=r?`max-w-[40%] shrink-0 truncate typography-ui-label text-foreground`:`min-w-0 truncate typography-ui-label text-foreground`,c;t[2]!==n||t[3]!==s?(c=(0,$.jsx)(`span`,{className:s,children:n}),t[2]=n,t[3]=s,t[4]=c):c=t[4];let l;t[5]===r?l=t[6]:(l=r?(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-micro text-muted-foreground`,title:r,children:r}):null,t[5]=r,t[6]=l);let u;return t[7]!==o||t[8]!==c||t[9]!==l?(u=(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[o,c,l]}),t[7]=o,t[8]=c,t[9]=l,t[10]=u):u=t[10],u},ic=e=>{let t=(0,Sa.c)(49),{onItemSelect:n}=e,{t:r}=Ge(),i=ot(),a=nt(),o=i.data,s=en(lc),c=en(uc),l=en(dc),u;t[0]!==n||t[1]!==c||t[2]!==s||t[3]!==o?(u=()=>{!n&&s===null&&o?.assistants[0]&&c(o.assistants[0].id)},t[0]=n,t[1]=c,t[2]=s,t[3]=o,t[4]=u):u=t[4];let d=o?.assistants,f;t[5]!==n||t[6]!==c||t[7]!==s||t[8]!==d?(f=[n,c,s,d],t[5]=n,t[6]=c,t[7]=s,t[8]=d,t[9]=f):f=t[9],Q.useEffect(u,f);let p;t[10]!==n||t[11]!==c||t[12]!==s||t[13]!==o?.assistants||t[14]!==i.isSuccess?(p=()=>{i.isSuccess&&s&&s!==`new`&&!o?.assistants.some(e=>e.id===s)&&c(n?null:o?.assistants[0]?.id??null)},t[10]=n,t[11]=c,t[12]=s,t[13]=o?.assistants,t[14]=i.isSuccess,t[15]=p):p=t[15];let m=o?.assistants,h;t[16]!==n||t[17]!==c||t[18]!==s||t[19]!==i.isSuccess||t[20]!==m?(h=[n,c,s,m,i.isSuccess],t[16]=n,t[17]=c,t[18]=s,t[19]=i.isSuccess,t[20]=m,t[21]=h):h=t[21],Q.useEffect(p,h);let g;t[22]!==n||t[23]!==l?(g=()=>{l(),n?.()},t[22]=n,t[23]=l,t[24]=g):g=t[24];let _=He(g);if(a.isSuccess&&!a.data.supported)return null;let v;t[25]===r?v=t[26]:(v=r(`assistants.settings.listTitle`),t[25]=r,t[26]=v);let y;t[27]===v?y=t[28]:(y=(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:v}),t[27]=v,t[28]=y);let b;t[29]===r?b=t[30]:(b=r(`assistants.settings.create`),t[29]=r,t[30]=b);let x;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(X,{name:`add`,className:`size-4`}),t[31]=x):x=t[31];let S;t[32]!==_||t[33]!==b?(S=(0,$.jsx)(q,{"data-settings-item":`assistants.create`,variant:`ghost`,size:`icon`,onClick:_,"aria-label":b,children:x}),t[32]=_,t[33]=b,t[34]=S):S=t[34];let C;t[35]!==S||t[36]!==y?(C=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2`,children:[y,S]}),t[35]=S,t[36]=y,t[37]=C):C=t[37];let w;t[38]!==a.isPending||t[39]!==n||t[40]!==c||t[41]!==s||t[42]!==o||t[43]!==i.isPending||t[44]!==r?(w=i.isPending||a.isPending?(0,$.jsxs)(`div`,{className:`yuri-settings-group-row flex items-center justify-center text-muted-foreground`,children:[(0,$.jsx)(X,{name:`loader-4`,className:`mr-2 size-4 animate-spin`}),r(`common.loading`)]}):o?.assistants.length?o.assistants.map(e=>{let t=Xe(e.name);return(0,$.jsx)(ps,{title:t.displayName,selected:s===e.id,onSelect:()=>{c(e.id),n?.()},icon:(0,$.jsx)(cn,{kind:`assistant`,name:e.avatarSeed??e.id,size:32,label:t.displayName||e.name})},e.id)}):(0,$.jsx)(`div`,{className:`yuri-settings-group-row text-muted-foreground`,children:r(`assistants.settings.empty`)}),t[38]=a.isPending,t[39]=n,t[40]=c,t[41]=s,t[42]=o,t[43]=i.isPending,t[44]=r,t[45]=w):w=t[45];let T;return t[46]!==C||t[47]!==w?(T=(0,$.jsx)(hs,{variant:`background`,children:(0,$.jsx)(Z,{label:C,children:w})}),t[46]=C,t[47]=w,t[48]=T):T=t[48],T},ac=({onItemDeleted:e,onSaved:t,assistantID:n,saveActionContainer:r})=>{let{t:i}=Ge(),a=ot(),o=nt(),s=a.data,c=Y(e=>e.projects),l=en(e=>n??e.settingsSelectedAssistantID),u=en(e=>e.selectSettingsAssistant),d=en(e=>e.createRequestRevision),f=en(e=>e.requestCreate),[p,m]=Q.useState(Ks),[h,g]=Q.useState(!1),_=Q.useRef(0);Q.useEffect(()=>()=>{_.current+=1},[l]);let v=Q.useRef(0),y=s?.assistants.find(e=>e.id===l)??null,b=y?Xe(y.name):null,x=Xe(p.name),S=p.workspacePath??y?.managedWorkspacePath??null,C=kt(S,{enabled:!0}).data??[];Q.useEffect(()=>{y&&m(qs(y))},[y]),Q.useEffect(()=>{n===void 0&&a.isSuccess&&l&&l!==`new`&&!y&&u(null)},[n,u,y,l,a.isSuccess]),Q.useEffect(()=>{if(l!==`new`||d<=v.current)return;v.current=d;let e=Ks(s?.assistants.length?``:Ws);m(e),window.requestAnimationFrame(()=>document.getElementById(`assistant-name`)?.focus())},[d,l,s?.assistants.length]),Q.useEffect(()=>{a.isSuccess&&Ze()},[s?.revision,a.isSuccess]);let w=(e,t)=>{m(n=>({...n,[e]:t}))},T=He(()=>f()),E=He(async()=>{if(n!==void 0&&!y)return;if(!p.name.trim()||!p.providerID||!p.modelID){Be.error(i(`assistants.settings.validation.required`));return}let e=_.current;g(!0);try{let r=y?await it(y,Js(p)):await rt(p);n===void 0&&u(r.id),Be.success(i(`assistants.settings.toast.saved`)),_.current===e&&t?.()}catch{Be.error(i(`assistants.settings.toast.saveFailed`))}finally{g(!1)}}),D=He(async()=>{if(!(!y||!window.confirm(i(`assistants.settings.deleteConfirm`,{name:y.name})))){g(!0);try{await $e(y),n===void 0&&u(null),e?.(),Be.success(i(`assistants.settings.toast.deleted`))}catch{Be.error(i(`assistants.settings.toast.deleteFailed`))}finally{g(!1)}}}),O=p.workspacePath===null?null:c.find(e=>e.path===p.workspacePath)??null,k=p.workspacePath!==null&&!O?p.workspacePath:null,A=p.workspacePath===null?Hs:O?O.id:Us,j=p.workspacePath===null?(0,$.jsx)(rc,{name:i(`assistants.settings.workspacePlaceholder`),icon:`cloud`}):O?(0,$.jsx)(rc,{name:Ys(O),path:O.path}):(0,$.jsx)(rc,{name:i(`assistants.settings.workspaceCurrentPath`),path:k??``,icon:`history`});return o.isSuccess&&!o.data.supported?null:a.isPending||o.isPending?(0,$.jsxs)(`div`,{className:`flex h-full items-center justify-center text-muted-foreground`,children:[(0,$.jsx)(X,{name:`loader-4`,className:`mr-2 size-4 animate-spin`}),i(`common.loading`)]}):a.isError&&!s||n!==void 0&&!y?(0,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 px-6 text-center`,children:[(0,$.jsx)(X,{name:`cloud-off`,className:`size-6 text-muted-foreground`}),(0,$.jsx)(`p`,{className:`typography-ui text-muted-foreground`,children:i(`assistants.state.unavailable`)}),(0,$.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>void a.refetch(),children:i(`assistants.actions.retry`)})]}):(0,$.jsx)(Ur,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`yuri-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[a.isError&&s?(0,$.jsx)(`p`,{className:`mb-4 px-2 typography-meta text-[var(--status-warning)]`,children:i(`assistants.state.staleSnapshot`)}):null,l?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Gi,{actions:(0,$.jsxs)($.Fragment,{children:[y?(0,$.jsx)(q,{variant:`ghost`,size:`icon`,onClick:D,disabled:h,className:`text-[var(--status-error)]`,"aria-label":i(`assistants.settings.delete`),title:i(`assistants.settings.delete`),children:(0,$.jsx)(X,{name:`delete-bin`,className:`size-4`})}):null,r?null:(0,$.jsxs)(q,{size:`sm`,onClick:E,disabled:h,"aria-busy":h,children:[h?(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}):null,i(`assistants.settings.save`)]})]}),children:(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,$.jsx)(`div`,{className:`shrink-0`,children:(0,$.jsx)(cn,{kind:`assistant`,name:p.avatarSeed??y?.id??`new`,size:40,label:x.displayName||p.name||i(`assistants.settings.create`)})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h2`,{className:`truncate typography-ui-header font-semibold text-foreground`,children:y?b?.displayName:i(`assistants.settings.create`)}),p.providerID&&p.modelID?(0,$.jsx)(`p`,{className:`mt-0.5 truncate typography-micro leading-none text-muted-foreground/70`,children:`${p.providerID}/${p.modelID}`}):null]})]})}),(0,$.jsx)(fs,{seed:p.avatarSeed??y?.id??`new`,disabled:h,onChange:e=>w(`avatarSeed`,e)}),(0,$.jsxs)(Z,{children:[(0,$.jsx)(Xi,{itemId:`assistants.name`,label:i(`assistants.settings.name`),children:(0,$.jsx)(Cn,{id:`assistant-name`,value:p.name,onChange:e=>w(`name`,e.target.value),className:`min-w-0 flex-1`})}),(0,$.jsx)(Xi,{itemId:`assistants.model`,label:i(`assistants.settings.model`),children:(0,$.jsx)(ii,{providerId:p.providerID,modelId:p.modelID,variant:p.variant??``,providers:C,onChange:(e,t,n)=>m(r=>({...r,providerID:e,modelID:t,variant:n||null})),className:`yuri-settings-inline-value`})}),(0,$.jsx)(Xi,{itemId:`assistants.prompt`,label:i(`assistants.settings.defaultPrompt`),className:`yuri-settings-split-row-stacked`,children:(0,$.jsx)(Wr,{embedded:!0,id:`assistant-prompt`,value:p.defaultPrompt,onChange:e=>w(`defaultPrompt`,e.target.value),placeholder:i(`assistants.settings.defaultPromptPlaceholder`),rows:12,outerClassName:`min-h-[240px] max-h-[70vh]`})})]}),(0,$.jsx)(Ui,{itemId:`assistants.workspace`,label:i(`assistants.settings.workspace`),description:i(`assistants.settings.workspaceChangeHint`),descriptionPlacement:`outside`,children:(0,$.jsxs)(Fr,{value:A,onValueChange:e=>{if(e===Hs){w(`workspacePath`,null);return}let t=c.find(t=>t.id===e);t&&w(`workspacePath`,t.path)},children:[(0,$.jsx)(Pr,{title:p.workspacePath??i(`assistants.settings.workspacePlaceholder`),className:`w-full max-w-xl [&_[data-slot=select-value]]:min-w-0 [&_[data-slot=select-value]]:flex-1 [&_[data-slot=select-value]]:overflow-hidden`,children:(0,$.jsx)(Ar,{children:j})}),(0,$.jsxs)(Nr,{align:`start`,className:`w-[min(32rem,calc(100vw-2rem))]`,children:[(0,$.jsx)(jr,{value:Hs,children:(0,$.jsx)(rc,{name:i(`assistants.settings.workspacePlaceholder`),icon:`cloud`})}),c.map(e=>(0,$.jsx)(jr,{value:e.id,children:(0,$.jsx)(rc,{name:Ys(e),path:e.path})},e.id)),k?(0,$.jsx)(jr,{value:Us,disabled:!0,children:(0,$.jsx)(rc,{name:i(`assistants.settings.workspaceCurrentPath`),path:k,icon:`history`})}):null]})]})}),y?(0,$.jsx)(nc,{assistantID:y.id}):null,y?(0,$.jsx)(Vs,{assistantID:y.id},y.id):null,r?(0,Ca.createPortal)((0,$.jsx)(q,{type:`button`,size:`mobileIcon`,onClick:E,disabled:h,"aria-label":i(`assistants.settings.save`),"aria-busy":h,children:(0,$.jsx)(X,{name:h?`loader-4`:`check`,className:h?`size-5 animate-spin motion-reduce:animate-none`:`size-5`})}),r):null]}):(0,$.jsxs)(`div`,{className:`flex min-h-80 flex-col items-center justify-center gap-3 px-6 text-center text-muted-foreground`,children:[(0,$.jsx)(cn,{kind:`assistant`,name:`assistants-empty`,size:44}),(0,$.jsx)(`p`,{className:`typography-ui`,children:i(`assistants.settings.empty`)}),(0,$.jsxs)(q,{"data-settings-item":`assistants.create`,size:`sm`,onClick:T,children:[(0,$.jsx)(X,{name:`add`,className:`size-4`}),i(`assistants.settings.create`)]})]})]})})};function oc(e){return Qs(e.task)?[{projectId:e.projectID,task:e.task}]:[]}function sc(e){return!Qs(e.task)}function cc(e,t){return e.task.enabled===t.task.enabled?e.task.name.localeCompare(t.task.name):e.task.enabled?-1:1}function lc(e){return e.settingsSelectedAssistantID}function uc(e){return e.selectSettingsAssistant}function dc(e){return e.requestCreate}var fc=`~/.config/opencode/AGENTS.md`,pc=async(e,t)=>{let n=await e.json().catch(()=>null);return typeof n?.error==`string`&&n.error.trim()?n.error:t},mc=e=>e.length>0&&!e.endsWith(`
2
+ `)?`${e}\n`:e,hc={prompt:``,responseStyleEnabled:!1,responseStylePreset:`concise`,responseStyleCustomInstructions:``},gc=(e,t)=>e===`custom`?t:Lt(e),_c=e=>e===`custom`?`custom`:ut(e)?e:`concise`,vc={concise:`settings.behavior.page.responseStyle.option.concise`,detailed:`settings.behavior.page.responseStyle.option.detailed`,mentor:`settings.behavior.page.responseStyle.option.mentor`,pushback:`settings.behavior.page.responseStyle.option.pushback`,noFiller:`settings.behavior.page.responseStyle.option.noFiller`,matchEnergy:`settings.behavior.page.responseStyle.option.matchEnergy`,warmPeer:`settings.behavior.page.responseStyle.option.warmPeer`},yc=async(e,t)=>{let n=await l(`/api/config/settings`,{method:`PUT`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(e)});if(!n.ok)throw Error(await pc(n,t));return n.json().catch(()=>null)},bc=()=>{let{t:e}=Ge(),t=Q.useSyncExternalStore(r,i,i),[n,a]=Q.useState(``),[o,s]=Q.useState(hc.responseStyleEnabled),[c,u]=Q.useState(hc.responseStylePreset),[d,f]=Q.useState(hc.responseStyleCustomInstructions),[p,m]=Q.useState(!1),[h,g]=Q.useState(!1),[_,v]=Q.useState(!1),[y,b]=Q.useState(``),x=Q.useRef(null),S=Q.useRef(null),C=Q.useRef(0),w=Q.useRef(Promise.resolve());Q.useEffect(()=>{let e=!0;return g(!1),x.current=null,S.current=null,C.current+=1,he(t).then(n=>{if(!e||t!==i())return;let r={enabled:n.responseStyleEnabled===!0,preset:_c(n.responseStylePreset),custom:typeof n.responseStyleCustomInstructions==`string`?n.responseStyleCustomInstructions:``};s(r.enabled),u(r.preset),f(r.custom),It({enabled:r.enabled,preset:r.preset,customInstructions:r.custom},t),x.current=r,S.current=r,g(!0)}).catch(t=>{e&&t?.name!==`AbortError`&&console.warn(`Failed to load behavior settings:`,t)}),()=>{e=!1,C.current+=1}},[t]),Q.useEffect(()=>{let e=new AbortController,n=!0;return m(!1),v(!1),(async()=>{try{let r=await l(`/api/behavior/agents-md`,{method:`GET`,headers:{Accept:`application/json`},signal:e.signal});if(!r.ok)throw Error(`Behavior prompt request failed (${r.status})`);let o=await r.json().catch(()=>null);if(typeof o?.content!=`string`)throw Error(`Invalid behavior prompt response`);if(!n||t!==i())return;a(o.content),b(o.content),m(!0)}catch(e){n&&e?.name!==`AbortError`&&console.warn(`Failed to load behavior prompt:`,e)}})(),()=>{n=!1,e.abort()}},[t]),Q.useEffect(()=>{if(!h)return;let n={enabled:o,preset:c,custom:d},r=S.current;if(r&&r.enabled===n.enabled&&r.preset===n.preset&&r.custom===n.custom)return;S.current=n;let a=C.current+1;C.current=a;let l=setTimeout(()=>{let r=async()=>{if(t===i())try{let r=await yc({responseStyleEnabled:n.enabled,responseStylePreset:n.preset,responseStyleCustomInstructions:n.custom},e(`settings.behavior.page.toast.saveFailed`));if(t!==i())return;let o=ge(r),c={enabled:o.responseStyleEnabled??n.enabled,preset:o.responseStylePreset??n.preset,custom:o.responseStyleCustomInstructions??n.custom};if(It({enabled:c.enabled,preset:c.preset,customInstructions:c.custom},t),ve({responseStyleEnabled:c.enabled,responseStylePreset:c.preset,responseStyleCustomInstructions:c.custom},t),x.current=c,a!==C.current)return;S.current=c,s(c.enabled),u(c.preset),f(c.custom)}catch(n){if(t===i()&&a===C.current){let t=x.current;S.current=t,t&&(s(t.enabled),u(t.preset),f(t.custom));let r=n instanceof Error?n.message:e(`settings.behavior.page.toast.saveFailed`);J.error(r)}}};w.current=w.current.then(r,r)},400);return()=>clearTimeout(l)},[o,c,d,h,e,t]);let T=gc(c,d),E=n!==y;return(0,$.jsx)(Ur,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`yuri-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsx)(`div`,{className:`space-y-1`,children:(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground`,children:e(`settings.behavior.page.title`)})}),(0,$.jsx)(Z,{itemId:`behavior.system-prompt`,actions:(0,$.jsx)(q,{onClick:async()=>{let r=t;if(r===i()){v(!0);try{let t=mc(n),o=await l(`/api/behavior/agents-md`,{method:`PUT`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({content:t})});if(!o.ok)throw Error(await pc(o,e(`settings.behavior.page.toast.saveFailed`)));if(r!==i()||(await yc({globalBehaviorPrompt:t},e(`settings.behavior.page.toast.saveFailed`)),r!==i()))return;a(t),b(t),J.success(e(`settings.behavior.page.toast.saved`))}catch(t){if(r!==i())return;console.error(`Failed to save behavior:`,t);let n=t instanceof Error?t.message:e(`settings.behavior.page.toast.saveFailed`);J.error(n)}finally{r===i()&&v(!1)}}},disabled:_||!E||!p,size:`sm`,"aria-busy":_,children:e(_?`settings.common.actions.saving`:`settings.common.actions.saveChanges`)}),label:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:e(`settings.behavior.page.section.systemPrompt`)}),(0,$.jsxs)(En,{children:[(0,$.jsx)(wn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(Tn,{sideOffset:8,className:`max-w-xs`,children:(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`p`,{className:`font-medium text-foreground`,children:e(`settings.behavior.page.warning.title`)}),(0,$.jsx)(`p`,{children:e(`settings.behavior.page.warning.description`,{path:fc})})]})})]})]}),children:(0,$.jsx)(`div`,{className:`yuri-settings-group-row flex flex-col gap-3`,children:(0,$.jsx)(Wr,{embedded:!0,value:n,onChange:e=>a(e.target.value),placeholder:e(`settings.behavior.page.field.systemPromptPlaceholder`),rows:12,disabled:!p,outerClassName:`min-h-[160px] max-h-[70vh]`,className:`w-full font-mono typography-meta bg-transparent`})})}),(0,$.jsxs)(Z,{itemId:`behavior.response-style`,actions:(0,$.jsx)(Wi,{checked:o,onChange:s,disabled:!h,ariaLabel:e(`settings.behavior.page.responseStyle.enableAria`)}),label:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:e(`settings.behavior.page.section.responseStyle`)}),(0,$.jsxs)(En,{children:[(0,$.jsx)(wn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(Tn,{sideOffset:8,className:`max-w-xs`,children:e(`settings.behavior.page.responseStyle.tooltip`)})]})]}),children:[(0,$.jsx)(Xi,{label:e(`settings.behavior.page.responseStyle.preset`),children:(0,$.jsxs)(Fr,{value:c,onValueChange:e=>u(e),disabled:!h||!o,children:[(0,$.jsx)(Pr,{className:`w-full sm:w-56`,children:(0,$.jsx)(Ar,{children:t=>t===`custom`?e(`settings.behavior.page.responseStyle.option.custom`):ut(t)?e(vc[t]):null})}),(0,$.jsxs)(Nr,{children:[ft.map(t=>(0,$.jsx)(jr,{value:t,children:e(vc[t])},t)),(0,$.jsx)(jr,{value:`custom`,children:e(`settings.behavior.page.responseStyle.option.custom`)})]})]})}),(0,$.jsx)(`div`,{className:`yuri-settings-group-row`,children:(0,$.jsx)(Wr,{embedded:!0,value:T,onChange:e=>f(e.target.value),placeholder:e(`settings.behavior.page.responseStyle.customPlaceholder`),rows:5,disabled:!h||!o||c!==`custom`,outerClassName:`min-h-[120px]`,className:`w-full font-mono typography-meta bg-transparent`})})]})]})})},xc=e=>{let t=(0,Sa.c)(158),{onItemSelect:n}=e,{t:r}=Ge(),[i,a]=Q.useState(null),[o,s]=Q.useState(``),[c,l]=Q.useState(null),[u,d]=Q.useState(null),[f,p]=Q.useState(!1),[m,h]=Q.useState(null),{selectedCommandName:g,setSelectedCommand:_,setCommandDraft:v,createCommand:y,deleteCommand:b}=Xa(ne(Cc)),x=Rt(),S;t[0]===x.data?S=t[1]:(S=x.data??[],t[0]=x.data,t[1]=S);let C=S,w=Tt(),T;t[2]===w.data?T=t[3]:(T=w.data??[],t[2]=w.data,t[3]=T);let E=T,{refetch:D}=w,O,k;t[4]===D?(O=t[5],k=t[6]):(O=()=>{D()},k=[D],t[4]=D,t[5]=O,t[6]=k),Q.useEffect(O,k);let A;t[7]===E?A=t[8]:(A=new Set(E.map(wc)),t[7]=E,t[8]=A);let j=A,M;if(t[9]!==C||t[10]!==j){let e;t[12]===j?e=t[13]:(e=e=>!j.has(e.name),t[12]=j,t[13]=e),M=C.filter(e),t[9]=C,t[10]=j,t[11]=M}else M=t[11];let N=M,P,F;t[14]!==g||t[15]!==_||t[16]!==j?(P=()=>{g&&j.has(g)&&_(null)},F=[g,_,j],t[14]=g,t[15]=_,t[16]=j,t[17]=P,t[18]=F):(P=t[17],F=t[18]),Q.useEffect(P,F);let I;t[19]!==C||t[20]!==n||t[21]!==v||t[22]!==_?(I=()=>{let e=`new-command`,t=1;for(;C.some(t=>t.name===e);)e=`new-command-${t}`,t++;v({name:e,scope:`user`}),_(e),n?.()},t[19]=C,t[20]=n,t[21]=v,t[22]=_,t[23]=I):I=t[23];let L=I,R;t[24]===r?R=t[25]:(R=async e=>{if(Ja(e)){J.error(r(`settings.commands.sidebar.toast.builtInCannotDelete`));return}l(e),d(`delete`)},t[24]=r,t[25]=R);let z=R,B;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(B=async e=>{Ja(e)&&(l(e),d(`reset`))},t[26]=B):B=t[26];let V=B,H;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(H=()=>{l(null),d(null)},t[27]=H):H=t[27];let U=H,W;t[28]!==c||t[29]!==u||t[30]!==b||t[31]!==r?(W=async()=>{!c||!u||(p(!0),await b(c.name)?(u===`delete`?J.success(r(`settings.commands.sidebar.toast.commandDeleted`,{name:c.name})):J.success(r(`settings.commands.sidebar.toast.commandReset`,{name:c.name})),U()):u===`delete`?J.error(r(`settings.commands.sidebar.toast.deleteFailed`)):J.error(r(`settings.commands.sidebar.toast.resetFailed`)),p(!1))},t[28]=c,t[29]=u,t[30]=b,t[31]=r,t[32]=W):W=t[32];let ee=W,te;t[33]!==C||t[34]!==v||t[35]!==_?(te=e=>{let t=e.name,n=1,r=`${t}-copy`;for(;C.some(e=>e.name===r);)n++,r=`${t}-copy-${n}`;v({name:r,scope:e.scope||`user`,description:e.description,template:e.template,agent:e.agent,model:e.model}),_(r)},t[33]=C,t[34]=v,t[35]=_,t[36]=te):te=t[36];let re=te,ie;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(ie=e=>{s(e.name),a(e)},t[37]=ie):ie=t[37];let ae=ie,oe;t[38]!==C||t[39]!==y||t[40]!==b||t[41]!==i||t[42]!==o||t[43]!==_||t[44]!==r?(oe=async()=>{if(!i)return;let e=o.trim().replace(/\s+/g,`-`);if(!e){J.error(r(`settings.commands.sidebar.toast.commandNameRequired`));return}if(e===i.name){a(null);return}if(C.some(t=>t.name===e)){J.error(r(`settings.commands.sidebar.toast.commandExists`));return}await y({name:e,description:i.description,template:i.template,agent:i.agent,model:i.model})?await b(i.name)?(J.success(`Command renamed to "${e}"`),_(e)):J.error(r(`settings.commands.sidebar.toast.removeOldAfterRenameFailed`)):J.error(r(`settings.commands.sidebar.toast.renameFailed`)),a(null)},t[38]=C,t[39]=y,t[40]=b,t[41]=i,t[42]=o,t[43]=_,t[44]=r,t[45]=oe):oe=t[45];let se=oe,ce,le,ue;if(t[46]!==N||t[47]!==L||t[48]!==z||t[49]!==re||t[50]!==n||t[51]!==m||t[52]!==g||t[53]!==_||t[54]!==r){let e=N.filter(Ja),i=N.filter(Tc),a;t[58]===r?a=t[59]:(a=r(`settings.commands.sidebar.section.custom`),t[58]=r,t[59]=a);let o;t[60]===a?o=t[61]:(o=(0,$.jsx)(`span`,{children:a}),t[60]=a,t[61]=o);let s;t[62]===r?s=t[63]:(s=r(`settings.commands.page.title.new`),t[62]=r,t[63]=s);let c;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(X,{name:`add`,className:`h-4 w-4`}),t[64]=c):c=t[64];let l;t[65]!==L||t[66]!==s?(l=(0,$.jsx)(q,{"data-settings-item":`commands.create`,size:`icon`,variant:`ghost`,onClick:L,"aria-label":s,children:c}),t[65]=L,t[66]=s,t[67]=l):l=t[67];let u;t[68]!==o||t[69]!==l?(u=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[o,l]}),t[68]=o,t[69]=l,t[70]=u):u=t[70];let d=u;ce=`yuri-settings-page-content h-full overflow-y-auto bg-background p-3`,t[71]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,$.jsx)(Z,{children:(0,$.jsx)(`div`,{className:`yuri-settings-group-row`,children:(0,$.jsx)(To,{})})}),t[71]=le):le=t[71],ue=(0,$.jsx)($.Fragment,{children:N.length===0?(0,$.jsx)(Z,{label:d,children:(0,$.jsxs)(`div`,{className:`yuri-settings-group-row py-12 text-center text-muted-foreground`,children:[(0,$.jsx)(X,{name:`terminal-box`,className:`mx-auto mb-3 h-10 w-10 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-ui-label font-medium`,children:r(`settings.commands.sidebar.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:r(`settings.commands.sidebar.empty.description`)})]})}):(0,$.jsxs)($.Fragment,{children:[e.length>0&&(0,$.jsx)(Z,{label:r(`settings.commands.sidebar.section.builtIn`),children:[...e].sort(Ec).map(e=>(0,$.jsx)(Sc,{command:e,isSelected:g===e.name,onSelect:()=>{_(e.name),n?.()},onReset:()=>V(e),onDuplicate:()=>re(e),isMenuOpen:m===e.name,onMenuOpenChange:t=>h(t?e.name:null)},e.name))}),i.length>0?(0,$.jsx)(Z,{label:d,children:[...i].sort(Dc).map(e=>(0,$.jsx)(Sc,{command:e,isSelected:g===e.name,onSelect:()=>{_(e.name),n?.()},onRename:()=>ae(e),onDelete:()=>z(e),onDuplicate:()=>re(e),isMenuOpen:m===e.name,onMenuOpenChange:t=>h(t?e.name:null)},e.name))}):(0,$.jsx)(Z,{label:d,cardClassName:`hidden`,children:(0,$.jsx)(`span`,{})})]})}),t[46]=N,t[47]=L,t[48]=z,t[49]=re,t[50]=n,t[51]=m,t[52]=g,t[53]=_,t[54]=r,t[55]=ce,t[56]=le,t[57]=ue}else ce=t[55],le=t[56],ue=t[57];let de=c!==null&&u!==null,G;t[72]===f?G=t[73]:(G=e=>{!e&&!f&&U()},t[72]=f,t[73]=G);let fe;t[74]!==u||t[75]!==r?(fe=r(u===`delete`?`settings.commands.sidebar.dialog.deleteTitle`:`settings.commands.sidebar.dialog.resetTitle`),t[74]=u,t[75]=r,t[76]=fe):fe=t[76];let pe;t[77]===fe?pe=t[78]:(pe=(0,$.jsx)(mn,{children:fe}),t[77]=fe,t[78]=pe);let me;t[79]!==c?.name||t[80]!==u||t[81]!==r?(me=r(u===`delete`?`settings.commands.sidebar.dialog.deleteDescription`:`settings.commands.sidebar.dialog.resetDescription`,{name:c?.name??``}),t[79]=c?.name,t[80]=u,t[81]=r,t[82]=me):me=t[82];let he;t[83]===me?he=t[84]:(he=(0,$.jsx)(hn,{children:me}),t[83]=me,t[84]=he);let ge;t[85]!==pe||t[86]!==he?(ge=(0,$.jsxs)(dn,{children:[pe,he]}),t[85]=pe,t[86]=he,t[87]=ge):ge=t[87];let _e;t[88]===r?_e=t[89]:(_e=r(`settings.common.actions.cancel`),t[88]=r,t[89]=_e);let ve;t[90]!==f||t[91]!==_e?(ve=(0,$.jsx)(q,{size:`sm`,variant:`ghost`,onClick:U,disabled:f,children:_e}),t[90]=f,t[91]=_e,t[92]=ve):ve=t[92];let ye;t[93]!==u||t[94]!==r?(ye=r(u===`delete`?`settings.common.actions.delete`:`settings.common.actions.reset`),t[93]=u,t[94]=r,t[95]=ye):ye=t[95];let be;t[96]!==ee||t[97]!==f||t[98]!==ye?(be=(0,$.jsx)(q,{size:`sm`,onClick:ee,disabled:f,children:ye}),t[96]=ee,t[97]=f,t[98]=ye,t[99]=be):be=t[99];let xe;t[100]!==ve||t[101]!==be?(xe=(0,$.jsxs)(fn,{children:[ve,be]}),t[100]=ve,t[101]=be,t[102]=xe):xe=t[102];let Se;t[103]!==ge||t[104]!==xe?(Se=(0,$.jsxs)(pn,{className:`max-w-md`,children:[ge,xe]}),t[103]=ge,t[104]=xe,t[105]=Se):Se=t[105];let Ce;t[106]!==de||t[107]!==G||t[108]!==Se?(Ce=(0,$.jsx)(gn,{open:de,onOpenChange:G,children:Se}),t[106]=de,t[107]=G,t[108]=Se,t[109]=Ce):Ce=t[109];let we=i!==null,Te;t[110]===Symbol.for(`react.memo_cache_sentinel`)?(Te=e=>!e&&a(null),t[110]=Te):Te=t[110];let Ee;t[111]===r?Ee=t[112]:(Ee=r(`settings.commands.sidebar.renameDialog.title`),t[111]=r,t[112]=Ee);let De;t[113]===Ee?De=t[114]:(De=(0,$.jsx)(mn,{children:Ee}),t[113]=Ee,t[114]=De);let Oe=i?.name??``,ke;t[115]!==r||t[116]!==Oe?(ke=r(`settings.commands.sidebar.renameDialog.description`,{name:Oe}),t[115]=r,t[116]=Oe,t[117]=ke):ke=t[117];let Ae;t[118]===ke?Ae=t[119]:(Ae=(0,$.jsx)(hn,{children:ke}),t[118]=ke,t[119]=Ae);let je;t[120]!==De||t[121]!==Ae?(je=(0,$.jsxs)(dn,{children:[De,Ae]}),t[120]=De,t[121]=Ae,t[122]=je):je=t[122];let Me;t[123]===Symbol.for(`react.memo_cache_sentinel`)?(Me=e=>s(e.target.value),t[123]=Me):Me=t[123];let Ne;t[124]===r?Ne=t[125]:(Ne=r(`settings.commands.sidebar.renameDialog.placeholder`),t[124]=r,t[125]=Ne);let Pe;t[126]===se?Pe=t[127]:(Pe=e=>{e.key===`Enter`&&se()},t[126]=se,t[127]=Pe);let Fe;t[128]!==o||t[129]!==Ne||t[130]!==Pe?(Fe=(0,$.jsx)(Cn,{value:o,onChange:Me,placeholder:Ne,className:`text-foreground placeholder:text-muted-foreground`,onKeyDown:Pe}),t[128]=o,t[129]=Ne,t[130]=Pe,t[131]=Fe):Fe=t[131];let Ie;t[132]===Symbol.for(`react.memo_cache_sentinel`)?(Ie=()=>a(null),t[132]=Ie):Ie=t[132];let Le;t[133]===r?Le=t[134]:(Le=r(`settings.common.actions.cancel`),t[133]=r,t[134]=Le);let Re;t[135]===Le?Re=t[136]:(Re=(0,$.jsx)(q,{size:`sm`,variant:`ghost`,onClick:Ie,children:Le}),t[135]=Le,t[136]=Re);let ze;t[137]===r?ze=t[138]:(ze=r(`settings.common.actions.rename`),t[137]=r,t[138]=ze);let Be;t[139]!==se||t[140]!==ze?(Be=(0,$.jsx)(q,{size:`sm`,onClick:se,children:ze}),t[139]=se,t[140]=ze,t[141]=Be):Be=t[141];let Ve;t[142]!==Re||t[143]!==Be?(Ve=(0,$.jsxs)(fn,{children:[Re,Be]}),t[142]=Re,t[143]=Be,t[144]=Ve):Ve=t[144];let He;t[145]!==je||t[146]!==Fe||t[147]!==Ve?(He=(0,$.jsxs)(pn,{children:[je,Fe,Ve]}),t[145]=je,t[146]=Fe,t[147]=Ve,t[148]=He):He=t[148];let Ue;t[149]!==we||t[150]!==He?(Ue=(0,$.jsx)(gn,{open:we,onOpenChange:Te,children:He}),t[149]=we,t[150]=He,t[151]=Ue):Ue=t[151];let We;return t[152]!==ce||t[153]!==le||t[154]!==ue||t[155]!==Ce||t[156]!==Ue?(We=(0,$.jsxs)(`div`,{className:ce,children:[le,ue,Ce,Ue]}),t[152]=ce,t[153]=le,t[154]=ue,t[155]=Ce,t[156]=Ue,t[157]=We):We=t[157],We},Sc=e=>{let t=(0,Sa.c)(47),{command:n,isSelected:r,onSelect:i,onDelete:a,onReset:o,onRename:s,onDuplicate:c,isMenuOpen:l,onMenuOpenChange:u}=e,{t:d}=Ge(),f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f=Cr(),t[0]=f):f=t[0];let p=f,[m,h]=Q.useState(!1),g;t[1]!==a||t[2]!==c||t[3]!==s||t[4]!==o||t[5]!==d?(g=e=>(0,$.jsxs)($.Fragment,{children:[s&&(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),s()},children:[(0,$.jsx)(X,{name:`edit`,className:`h-4 w-4 mr-px`}),d(`settings.common.actions.rename`)]}),(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),c()},children:[(0,$.jsx)(X,{name:`file-copy`,className:`h-4 w-4 mr-px`}),d(`settings.common.actions.duplicate`)]}),o&&(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),o()},children:[(0,$.jsx)(X,{name:`restart`,className:`h-4 w-4 mr-px`}),d(`settings.common.actions.reset`)]}),a&&(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),a()},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(X,{name:`delete-bin`,className:`h-4 w-4 mr-px`}),d(`settings.common.actions.delete`)]})]}),t[1]=a,t[2]=c,t[3]=s,t[4]=o,t[5]=d,t[6]=g):g=t[6];let _=g,v=r?`bg-interactive-selection`:`hover:bg-interactive-hover`,y;t[7]===v?y=t[8]:(y=K(`yuri-settings-group-row group relative flex items-center transition-colors duration-150 select-none`,v),t[7]=v,t[8]=y);let b;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(b=p?void 0:e=>{e.preventDefault(),h(!0)},t[9]=b):b=t[9];let x;t[10]===y?x=t[11]:(x=(0,$.jsx)(`div`,{className:y,onContextMenu:b}),t[10]=y,t[11]=x);let S;t[12]===n.name?S=t[13]:(S=(0,$.jsxs)(`span`,{className:`typography-ui-label font-normal truncate text-foreground`,children:[`/`,n.name]}),t[12]=n.name,t[13]=S);let C;t[14]!==n||t[15]!==d?(C=(n.scope||Ja(n))&&(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-muted px-1 rounded flex-shrink-0 leading-none pb-px border border-border/50`,children:Ja(n)?d(`settings.agents.sidebar.badge.system`):n.scope}),t[14]=n,t[15]=d,t[16]=C):C=t[16];let w;t[17]!==S||t[18]!==C?(w=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[S,C]}),t[17]=S,t[18]=C,t[19]=w):w=t[19];let T;t[20]===n.description?T=t[21]:(T=n.description&&(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/60 truncate leading-tight`,children:n.description}),t[20]=n.description,t[21]=T);let E;t[22]!==i||t[23]!==T||t[24]!==w?(E=(0,$.jsxs)(`button`,{onClick:i,className:`flex min-w-0 flex-1 flex-col gap-0 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,tabIndex:0,children:[w,T]}),t[22]=i,t[23]=T,t[24]=w,t[25]=E):E=t[25];let D;t[26]===u?D=t[27]:(D=e=>{e&&h(!1),u(e)},t[26]=u,t[27]=D);let O;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(fr,{asChild:!0,children:(0,$.jsx)(q,{size:`sm`,variant:`ghost`,className:`h-6 w-6 px-0 flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100`,children:(0,$.jsx)(X,{name:`more-2`,className:`h-3.5 w-3.5`})})}),t[28]=O):O=t[28];let k;t[29]===_?k=t[30]:(k=(0,$.jsx)(Zn,{align:`end`,className:`w-fit min-w-20`,children:_(tr)}),t[29]=_,t[30]=k);let A;t[31]!==l||t[32]!==D||t[33]!==k?(A=(0,$.jsxs)($n,{open:l,onOpenChange:D,children:[O,k]}),t[31]=l,t[32]=D,t[33]=k,t[34]=A):A=t[34];let j;t[35]!==E||t[36]!==A?(j=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:[E,A]}),t[35]=E,t[36]=A,t[37]=j):j=t[37];let M;t[38]!==j||t[39]!==x?(M=(0,$.jsx)(na,{render:x,children:j}),t[38]=j,t[39]=x,t[40]=M):M=t[40];let N;t[41]===_?N=t[42]:(N=(0,$.jsx)(ra,{className:`w-fit min-w-20`,children:_(ia)}),t[41]=_,t[42]=N);let P;return t[43]!==m||t[44]!==M||t[45]!==N?(P=(0,$.jsxs)(aa,{open:m,onOpenChange:h,children:[M,N]}),t[43]=m,t[44]=M,t[45]=N,t[46]=P):P=t[46],P};function Cc(e){return{selectedCommandName:e.selectedCommandName,setSelectedCommand:e.setSelectedCommand,setCommandDraft:e.setCommandDraft,createCommand:e.createCommand,deleteCommand:e.deleteCommand}}function wc(e){return e.name}function Tc(e){return!Ja(e)}function Ec(e,t){return e.name.localeCompare(t.name)}function Dc(e,t){return e.name.localeCompare(t.name)}var Oc=()=>{let{t:e}=Ge(),{selectedCommandName:t,createCommand:n,updateCommand:r,commandDraft:i,setCommandDraft:a}=Xa(ne(e=>({selectedCommandName:e.selectedCommandName,createCommand:e.createCommand,updateCommand:e.updateCommand,commandDraft:e.commandDraft,setCommandDraft:e.setCommandDraft}))),o=Rt(),s=Q.useMemo(()=>o.data??[],[o.data]),c=t?s.find(e=>e.name===t):null,l=!!(i&&i.name===t&&!c),[u,d]=Q.useState(``),[f,p]=Q.useState(`user`),[m,h]=Q.useState(``),[g,_]=Q.useState(``),[v,y]=Q.useState(``),[b,x]=Q.useState(``),[S,C]=Q.useState(!1),w=Q.useRef(null);Q.useEffect(()=>{if(l&&i){let e=i.name||``,t=i.scope||`user`,n=i.description||``,r=i.agent||``,a=i.model||``,o=i.template||``;d(e),p(t),h(n),_(r),y(a),x(o),w.current={draftName:e,draftScope:t,description:n,agent:r,model:a,template:o}}else if(c){let e=c.description||``,t=c.agent||``,n=c.model||``,r=c.template||``;h(e),_(t),y(n),x(r),w.current={draftName:``,draftScope:`user`,description:e,agent:t,model:n,template:r}}},[c,l,t,s,i]);let T=Q.useMemo(()=>{let e=w.current;return e?!!(l&&(u!==e.draftName||f!==e.draftScope)||m!==e.description||g!==e.agent||v!==e.model||b!==e.template):!1},[g,m,u,f,l,v,b]);return t?(0,$.jsx)(Ur,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`yuri-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsx)(Gi,{actions:(0,$.jsxs)(q,{onClick:async()=>{let i=l?u.trim().replace(/\s+/g,`-`):t?.trim();if(!i){J.error(e(`settings.commands.sidebar.toast.commandNameRequired`));return}if(!b.trim()){J.error(e(`settings.commands.page.toast.templateRequired`));return}if(l&&s.some(e=>e.name===i)){J.error(e(`settings.commands.sidebar.toast.commandExists`));return}C(!0);try{let t=g.trim(),o=v.trim(),s=b.trim(),c={name:i,description:m.trim()||void 0,agent:t===``?null:t,model:o===``?null:o,template:s,scope:l?f:void 0},u;l?(u=await n(c),u&&a(null)):u=await r(i,c),u?J.success(e(l?`settings.commands.page.toast.created`:`settings.commands.page.toast.updated`)):J.error(e(l?`settings.commands.page.toast.createFailed`:`settings.commands.page.toast.updateFailed`))}catch(t){console.error(`Error saving command:`,t),J.error(e(`settings.commands.page.toast.saveUnexpectedError`))}finally{C(!1)}},disabled:S||!T,size:`sm`,"aria-busy":S,children:[S?(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin motion-reduce:animate-none`}):null,e(S?`settings.common.actions.saving`:`settings.common.actions.saveChanges`)]}),children:(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:l?e(`settings.commands.page.title.new`):`/${t}`}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground truncate`,children:e(l?`settings.commands.page.subtitle.new`:`settings.commands.page.subtitle.edit`)})]})}),(0,$.jsxs)(Z,{label:e(`settings.commands.page.section.identity`),children:[l&&(0,$.jsxs)(Xi,{itemId:`commands.name`,label:e(`settings.commands.page.field.commandName`),children:[(0,$.jsxs)(`div`,{className:`flex items-center`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground mr-1`,children:`/`}),(0,$.jsx)(Cn,{value:u,onChange:e=>d(e.target.value),placeholder:e(`settings.commands.page.field.commandNamePlaceholder`),className:`h-7 w-40 px-2`})]}),(0,$.jsxs)(Fr,{value:f,onValueChange:e=>p(e),children:[(0,$.jsx)(Pr,{className:`w-fit min-w-[100px]`,children:(0,$.jsx)(Ar,{placeholder:e(`settings.agents.page.field.scopePlaceholder`)})}),(0,$.jsxs)(Nr,{align:`end`,children:[(0,$.jsx)(jr,{value:`user`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(X,{name:`user-3`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:e(`settings.common.scope.global`)})]})}),(0,$.jsx)(jr,{value:`project`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(X,{name:`folder`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:e(`settings.common.scope.project`)})]})})]})]})]}),(0,$.jsx)(Xi,{label:e(`settings.common.field.description`),className:`yuri-settings-split-row-stacked`,children:(0,$.jsx)(Wr,{embedded:!0,value:m,onChange:e=>h(e.target.value),placeholder:e(`settings.commands.page.field.descriptionPlaceholder`),rows:2,className:`w-full resize-none min-h-[60px] bg-transparent`})})]}),(0,$.jsxs)(Z,{label:e(`settings.commands.page.section.executionContext`),children:[(0,$.jsx)(Xi,{itemId:`commands.agent`,label:e(`settings.commands.page.field.overrideAgent`),children:(0,$.jsx)(bi,{agentName:g,onChange:e=>_(e),className:`yuri-settings-inline-value`})}),(0,$.jsx)(Xi,{itemId:`commands.model`,label:e(`settings.agents.page.field.overrideModel`),children:(0,$.jsx)(ii,{providerId:Zt(v)?.providerId??``,modelId:Zt(v)?.modelId??``,onChange:(e,t)=>{y(e&&t?`${e}/${t}`:``)},className:`yuri-settings-inline-value`})})]}),(0,$.jsx)(Ui,{itemId:`commands.template`,label:e(`settings.commands.page.section.template`),description:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`code`,{className:`text-foreground`,children:`$ARGUMENTS`}),` `,e(`settings.commands.page.templateHint.userInput`),` ·`,` `,(0,$.jsx)(`code`,{className:`text-foreground`,children:"!`cmd`"}),` `,e(`settings.commands.page.templateHint.shellOutput`),` ·`,` `,(0,$.jsx)(`code`,{className:`text-foreground`,children:`@file`}),` `,e(`settings.commands.page.templateHint.fileContents`)]}),descriptionPlacement:`outside`,className:`yuri-settings-split-row-stacked`,children:(0,$.jsx)(Wr,{embedded:!0,value:b,onChange:e=>x(e.target.value),placeholder:e(`settings.commands.page.field.templatePlaceholder`),rows:12,className:`w-full font-mono typography-meta min-h-[160px] max-h-[60vh] bg-transparent resize-y`})})]})}):(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,$.jsxs)(`div`,{className:`text-center text-muted-foreground`,children:[(0,$.jsx)(X,{name:`terminal-box`,className:`mx-auto mb-3 h-12 w-12 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.commands.page.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:e(`settings.commands.page.empty.description`)})]})})},kc=[],Ac=e=>{switch(e){case`connected`:return`success`;case`failed`:return`error`;case`needs_auth`:case`needs_client_registration`:return`warning`;default:return`idle`}},jc=e=>{let t=(0,Sa.c)(5),{tone:n,enabled:r}=e;if(!r){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`span`,{className:`inline-block h-2 w-2 rounded-full bg-muted-foreground/30 flex-shrink-0`}),t[0]=e):e=t[0],e}let i;t[1]===n?i=t[2]:(i=K(`inline-block h-2 w-2 rounded-full flex-shrink-0`,{success:`bg-[var(--status-success)]`,error:`bg-[var(--status-error)]`,warning:`bg-[var(--status-warning)]`,idle:`bg-muted-foreground/40`}[n]),t[1]=n,t[2]=i);let a;return t[3]===i?a=t[4]:(a=(0,$.jsx)(`span`,{className:i}),t[3]=i,t[4]=a),a},Mc=e=>{let t=(0,Sa.c)(115),{onItemSelect:n}=e,{t:r}=Ge(),{selectedMcpName:a,setSelectedMcp:o,setMcpDraft:s,deleteMcp:c}=no(ne(Nc)),l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=Bi(),t[0]=l):l=t[0];let u=l,d=Fi(u),f=Li(u),p=d.data??kc,m;t[1]===f.data?m=t[2]:(m=f.data??{},t[1]=f.data,t[2]=m);let h=m,[g,_]=Q.useState(null),[v,y]=Q.useState(!1),[b,x]=Q.useState(null),[S,C]=Q.useState(null),[w,T]=Q.useState(!1),E;t[3]===p?E=t[4]:(E=p.filter(Pc),t[3]=p,t[4]=E);let D=E,O;t[5]===p?O=t[6]:(O=p.filter(Fc),t[5]=p,t[6]=O);let k=O,A;t[7]===w?A=t[8]:(A=()=>{if(w)return;T(!0);let e=new Promise(Ic),t=i();Promise.all([Ri(Oe,u,t),e]).catch(Lc).finally(()=>{T(!1)})},t[7]=w,t[8]=A);let j=A,M;t[9]!==p||t[10]!==n||t[11]!==s||t[12]!==o?(M=()=>{let e=`new-mcp-server`,t=1;for(;p.some(t=>t.name===e);)e=`new-mcp-server-${t}`,t++;s({name:e,scope:`user`,type:`local`,command:[],url:``,environment:[],headers:[],oauthEnabled:!0,oauthClientId:``,oauthClientSecret:``,oauthScope:``,oauthRedirectUri:``,timeout:``,enabled:!0}),o(e),n?.()},t[9]=p,t[10]=n,t[11]=s,t[12]=o,t[13]=M):M=t[13];let N=M,P;t[14]!==c||t[15]!==g||t[16]!==r?(P=async()=>{if(!g)return;y(!0);let e=await c(g.name,{directory:Bi(),transportIdentity:i()});e.ok?e.reloadFailed?J.warning(e.message||`MCP server "${g.name}" deleted, but OpenCode reload failed`,{description:e.warning||r(`settings.mcp.sidebar.toast.refreshListIfStale`)}):J.success(e.message||r(`settings.mcp.sidebar.toast.serverDeleted`,{name:g.name})):J.error(r(`settings.mcp.sidebar.toast.deleteFailed`)),_(null),y(!1)},t[14]=c,t[15]=g,t[16]=r,t[17]=P):P=t[17];let F=P,I;t[18]===r?I=t[19]:(I=(e,t)=>(0,$.jsxs)(t,{onClick:t=>{t.stopPropagation(),_(e)},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(X,{name:`delete-bin`,className:`h-4 w-4 mr-px`}),r(`settings.common.actions.delete`)]}),t[18]=r,t[19]=I);let L=I,R;t[20]===r?R=t[21]:(R=r(`settings.mcp.sidebar.group.userServers`),t[20]=r,t[21]=R);let z;t[22]===R?z=t[23]:(z=(0,$.jsx)(`span`,{children:R}),t[22]=R,t[23]=z);let B;t[24]===r?B=t[25]:(B=r(`settings.mcp.sidebar.actions.refreshStatusAria`),t[24]=r,t[25]=B);let V;t[26]===r?V=t[27]:(V=r(`settings.mcp.sidebar.actions.refreshStatusTitle`),t[26]=r,t[27]=V);let H=w&&`animate-spin`,U;t[28]===H?U=t[29]:(U=K(`h-4 w-4`,H),t[28]=H,t[29]=U);let W;t[30]===U?W=t[31]:(W=(0,$.jsx)(X,{name:`refresh`,className:U}),t[30]=U,t[31]=W);let ee;t[32]!==j||t[33]!==w||t[34]!==B||t[35]!==V||t[36]!==W?(ee=(0,$.jsx)(q,{type:`button`,size:`icon`,variant:`ghost`,disabled:w,onClick:j,"aria-label":B,title:V,children:W}),t[32]=j,t[33]=w,t[34]=B,t[35]=V,t[36]=W,t[37]=ee):ee=t[37];let te;t[38]===r?te=t[39]:(te=r(`settings.mcp.sidebar.actions.addServerTitle`),t[38]=r,t[39]=te);let re;t[40]===r?re=t[41]:(re=r(`settings.mcp.sidebar.actions.addServerTitle`),t[40]=r,t[41]=re);let ie;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,$.jsx)(X,{name:`add`,className:`h-4 w-4`}),t[42]=ie):ie=t[42];let ae;t[43]!==N||t[44]!==te||t[45]!==re?(ae=(0,$.jsx)(q,{"data-settings-item":`mcp.create`,size:`icon`,variant:`ghost`,onClick:N,"aria-label":te,title:re,children:ie}),t[43]=N,t[44]=te,t[45]=re,t[46]=ae):ae=t[46];let oe;t[47]!==ee||t[48]!==ae?(oe=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[ee,ae]}),t[47]=ee,t[48]=ae,t[49]=oe):oe=t[49];let se;t[50]!==z||t[51]!==oe?(se=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[z,oe]}),t[50]=z,t[51]=oe,t[52]=se):se=t[52];let ce=se,le;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,$.jsx)(Z,{children:(0,$.jsx)(`div`,{className:`yuri-settings-group-row`,children:(0,$.jsx)(To,{})})}),t[53]=le):le=t[53];let ue;t[54]!==d.data||t[55]!==d.error||t[56]!==d.isError||t[57]!==p.length||t[58]!==h||t[59]!==n||t[60]!==b||t[61]!==D||t[62]!==L||t[63]!==S||t[64]!==a||t[65]!==s||t[66]!==o||t[67]!==f.data||t[68]!==f.error||t[69]!==f.isError||t[70]!==r||t[71]!==k||t[72]!==ce?(ue=(0,$.jsx)($.Fragment,{children:d.isError&&!d.data?(0,$.jsx)(Z,{label:ce,children:(0,$.jsx)(`div`,{className:`yuri-settings-group-row py-12 text-center typography-meta text-[var(--status-error)]`,children:d.error.message})}):p.length===0?(0,$.jsx)(Z,{label:ce,children:(0,$.jsxs)(`div`,{className:`yuri-settings-group-row py-12 text-center text-muted-foreground`,children:[(0,$.jsx)(X,{name:`plug`,className:`mx-auto mb-3 h-10 w-10 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-ui-label font-medium`,children:r(`settings.mcp.sidebar.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:r(`settings.mcp.sidebar.empty.description`)})]})}):(0,$.jsxs)($.Fragment,{children:[D.length>0&&(0,$.jsx)(Z,{label:r(`settings.mcp.sidebar.group.projectServers`),children:D.map(e=>{let t=Ac((h[e.name]??(f.isError&&!f.data?{status:`failed`,error:f.error.message}:void 0))?.status),i=a===e.name,c=Cr();return(0,$.jsxs)(aa,{open:S===e.name,onOpenChange:t=>C(t?e.name:null),children:[(0,$.jsxs)(na,{render:(0,$.jsx)(`div`,{className:K(`yuri-settings-group-row group relative flex items-center transition-colors duration-150 select-none`,i?`bg-interactive-selection`:`hover:bg-interactive-hover`),onContextMenu:c?void 0:t=>{t.preventDefault(),C(e.name)}}),children:[(0,$.jsxs)(`button`,{onClick:()=>{o(e.name),s(null),n?.()},className:`flex min-w-0 flex-1 flex-col gap-0 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(jc,{tone:t,enabled:e.enabled}),(0,$.jsx)(`span`,{className:`typography-ui-label font-normal truncate text-foreground`,children:e.name}),(0,$.jsx)(`span`,{title:e.type===`local`?r(`settings.mcp.sidebar.serverType.localTitle`):r(`settings.mcp.sidebar.serverType.remoteTitle`),children:e.type===`local`?(0,$.jsx)(X,{name:`server`,className:`h-3 w-3 text-muted-foreground/60 flex-shrink-0`}):(0,$.jsx)(X,{name:`global`,className:`h-3 w-3 text-muted-foreground/60 flex-shrink-0`})})]}),(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/60 truncate leading-tight pl-4`,children:e.type===`local`?e.command?.join(` `)??``:e.url??``})]}),(0,$.jsxs)($n,{open:b===e.name,onOpenChange:t=>{t&&C(null),x(t?e.name:null)},children:[(0,$.jsx)(fr,{asChild:!0,children:(0,$.jsx)(q,{size:`xs`,variant:`ghost`,className:`flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100`,children:(0,$.jsx)(X,{name:`more-2`,className:`h-3.5 w-3.5`})})}),(0,$.jsx)(Zn,{align:`end`,className:`w-fit min-w-20`,children:L(e,tr)})]})]}),(0,$.jsx)(ra,{className:`w-fit min-w-20`,children:L(e,ia)})]},e.name)})}),k.length>0&&(0,$.jsx)(Z,{label:ce,children:k.map(e=>{let t=Ac((h[e.name]??(f.isError&&!f.data?{status:`failed`,error:f.error.message}:void 0))?.status),i=a===e.name,c=Cr();return(0,$.jsxs)(aa,{open:S===e.name,onOpenChange:t=>C(t?e.name:null),children:[(0,$.jsxs)(na,{render:(0,$.jsx)(`div`,{className:K(`yuri-settings-group-row group relative flex items-center transition-colors duration-150 select-none`,i?`bg-interactive-selection`:`hover:bg-interactive-hover`),onContextMenu:c?void 0:t=>{t.preventDefault(),C(e.name)}}),children:[(0,$.jsxs)(`button`,{onClick:()=>{o(e.name),s(null),n?.()},className:`flex min-w-0 flex-1 flex-col gap-0 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(jc,{tone:t,enabled:e.enabled}),(0,$.jsx)(`span`,{className:`typography-ui-label font-normal truncate text-foreground`,children:e.name}),(0,$.jsx)(`span`,{title:e.type===`local`?r(`settings.mcp.sidebar.serverType.localTitle`):r(`settings.mcp.sidebar.serverType.remoteTitle`),children:e.type===`local`?(0,$.jsx)(X,{name:`server`,className:`h-3 w-3 text-muted-foreground/60 flex-shrink-0`}):(0,$.jsx)(X,{name:`global`,className:`h-3 w-3 text-muted-foreground/60 flex-shrink-0`})})]}),(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/60 truncate leading-tight pl-4`,children:e.type===`local`?e.command?.join(` `)??``:e.url??``})]}),(0,$.jsxs)($n,{open:b===e.name,onOpenChange:t=>{t&&C(null),x(t?e.name:null)},children:[(0,$.jsx)(fr,{asChild:!0,children:(0,$.jsx)(q,{size:`xs`,variant:`ghost`,className:`flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100`,children:(0,$.jsx)(X,{name:`more-2`,className:`h-3.5 w-3.5`})})}),(0,$.jsx)(Zn,{align:`end`,className:`w-fit min-w-20`,children:L(e,tr)})]})]}),(0,$.jsx)(ra,{className:`w-fit min-w-20`,children:L(e,ia)})]},e.name)})}),k.length===0&&(0,$.jsx)(Z,{label:ce,cardClassName:`hidden`,children:(0,$.jsx)(`span`,{})})]})}),t[54]=d.data,t[55]=d.error,t[56]=d.isError,t[57]=p.length,t[58]=h,t[59]=n,t[60]=b,t[61]=D,t[62]=L,t[63]=S,t[64]=a,t[65]=s,t[66]=o,t[67]=f.data,t[68]=f.error,t[69]=f.isError,t[70]=r,t[71]=k,t[72]=ce,t[73]=ue):ue=t[73];let de=g!==null,G;t[74]===v?G=t[75]:(G=e=>{!e&&!v&&_(null)},t[74]=v,t[75]=G);let fe;t[76]===r?fe=t[77]:(fe=r(`settings.mcp.sidebar.deleteDialog.title`),t[76]=r,t[77]=fe);let pe;t[78]===fe?pe=t[79]:(pe=(0,$.jsx)(mn,{children:fe}),t[78]=fe,t[79]=pe);let me=g?.name||``,he;t[80]!==r||t[81]!==me?(he=r(`settings.mcp.sidebar.deleteDialog.descriptionPrefix`,{name:me}),t[80]=r,t[81]=me,t[82]=he):he=t[82];let ge;t[83]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,$.jsx)(`code`,{className:`text-foreground`,children:`opencode.json`}),t[83]=ge):ge=t[83];let _e;t[84]===he?_e=t[85]:(_e=(0,$.jsxs)(hn,{children:[he,` `,ge,`.`]}),t[84]=he,t[85]=_e);let ve;t[86]!==pe||t[87]!==_e?(ve=(0,$.jsxs)(dn,{children:[pe,_e]}),t[86]=pe,t[87]=_e,t[88]=ve):ve=t[88];let ye;t[89]===Symbol.for(`react.memo_cache_sentinel`)?(ye=()=>_(null),t[89]=ye):ye=t[89];let be;t[90]===r?be=t[91]:(be=r(`settings.common.actions.cancel`),t[90]=r,t[91]=be);let xe;t[92]!==v||t[93]!==be?(xe=(0,$.jsx)(q,{size:`sm`,variant:`ghost`,onClick:ye,disabled:v,children:be}),t[92]=v,t[93]=be,t[94]=xe):xe=t[94];let Se;t[95]!==v||t[96]!==r?(Se=r(v?`settings.mcp.sidebar.actions.deleting`:`settings.common.actions.delete`),t[95]=v,t[96]=r,t[97]=Se):Se=t[97];let Ce;t[98]!==F||t[99]!==v||t[100]!==Se?(Ce=(0,$.jsx)(q,{size:`sm`,onClick:F,disabled:v,children:Se}),t[98]=F,t[99]=v,t[100]=Se,t[101]=Ce):Ce=t[101];let we;t[102]!==xe||t[103]!==Ce?(we=(0,$.jsxs)(fn,{children:[xe,Ce]}),t[102]=xe,t[103]=Ce,t[104]=we):we=t[104];let Te;t[105]!==ve||t[106]!==we?(Te=(0,$.jsxs)(pn,{className:`max-w-md`,children:[ve,we]}),t[105]=ve,t[106]=we,t[107]=Te):Te=t[107];let Ee;t[108]!==de||t[109]!==G||t[110]!==Te?(Ee=(0,$.jsx)(gn,{open:de,onOpenChange:G,children:Te}),t[108]=de,t[109]=G,t[110]=Te,t[111]=Ee):Ee=t[111];let De;return t[112]!==ue||t[113]!==Ee?(De=(0,$.jsxs)(`div`,{className:`yuri-settings-page-content h-full overflow-y-auto bg-background p-3`,children:[le,ue,Ee]}),t[112]=ue,t[113]=Ee,t[114]=De):De=t[114],De};function Nc(e){return{selectedMcpName:e.selectedMcpName,setSelectedMcp:e.setSelectedMcp,setMcpDraft:e.setMcpDraft,deleteMcp:e.deleteMcp}}function Pc(e){return e.scope===`project`}function Fc(e){return e.scope!==`project`}function Ic(e){return setTimeout(e,500)}function Lc(e){J.error(e instanceof Error?e.message:String(e))}function Rc(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function zc(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function Bc(e,t){return t===void 0?{ok:!1,error:e}:{ok:!1,error:e,parsed:t}}function Vc(e,t,n){return{ok:!0,name:e,type:t,command:Hc(n),url:typeof n.url==`string`?n.url.trim():``,environment:Uc(n,`env`,`environment`),headers:Uc(n,`headers`),oauthEnabled:Wc(n),oauthClientId:typeof n.oauth==`object`&&n.oauth!==null?String(n.oauth.clientId??``).trim():``,oauthClientSecret:typeof n.oauth==`object`&&n.oauth!==null?String(n.oauth.clientSecret??``).trim():``,oauthScope:typeof n.oauth==`object`&&n.oauth!==null?String(n.oauth.scope??``).trim():``,oauthRedirectUri:typeof n.oauth==`object`&&n.oauth!==null?String(n.oauth.redirectUri??``).trim():``,timeout:Gc(n),enabled:Kc(n)}}function Hc(e){let t=e.command,n=e.args;if(zc(t)&&zc(n))return[...t,...n];if(zc(t))return t;if(typeof t==`string`&&t.trim()){let e=t.trim().split(/\s+/);return zc(n)?[...e,...n]:e}return zc(n)?n:[]}function Uc(e,...t){for(let n of t){let t=e[n];if(!Rc(t))continue;let r=Object.entries(t).filter(([e,t])=>e&&typeof t==`string`);if(r.length>0)return r.map(([e,t])=>({key:e,value:String(t)}))}return[]}function Wc(e){if(e.oauth===!1||e.oauth===null||e.oauth===void 0||!Rc(e.oauth))return!1;let t=e.oauth;return!!(typeof t.clientId==`string`&&t.clientId.trim()||typeof t.clientSecret==`string`&&t.clientSecret.trim()||typeof t.scope==`string`&&t.scope.trim()||typeof t.redirectUri==`string`&&t.redirectUri.trim())}function Gc(e){let t=e.timeout;if(typeof t==`number`&&Number.isFinite(t)&&t>0)return String(Math.floor(t));if(typeof t==`string`&&t.trim()){let e=Number(t);if(Number.isFinite(e)&&e>0)return String(Math.floor(e))}return``}function Kc(e){return`disabled`in e&&e.disabled===!0?!1:`enabled`in e?!!e.enabled:!0}function qc(e){let t=e.mcpServers;if(Rc(t)){let e=Object.keys(t);if(e.length===1){let n=e[0],r=t[n];if(Rc(r))return{name:n,entry:r}}if(e.length>1)return null}let n=Object.keys(e).filter(t=>{let n=e[t];return t!==`mcpServers`&&Rc(n)});if(n.length===1){let t=n[0],r=e[t];if(Jc(r))return{name:t,entry:r}}return null}function Jc(e){return e.type===`local`||e.type===`remote`||Array.isArray(e.command)||typeof e.url==`string`||Array.isArray(e.args)}function Yc(e,t){let n;try{let t=e.trim();if(!t)return Bc(`No JSON content provided`);n=JSON.parse(t)}catch(e){return Bc(e instanceof Error?`Invalid JSON: ${e.message}`:`Invalid JSON`)}if(!Rc(n))return Bc(`Expected a JSON object, not an array or primitive`);let r=n,i=r.mcpServers;if(Rc(i)){let e=Object.keys(i);if(e.length===0)return Bc(`mcpServers object is empty`,n);if(e.length>1)return Bc(`Paste one server at a time. Found `+e.length+` servers in mcpServers`,n);let t=e[0],r=i[t];return Rc(r)?Vc(t,Xc(r),r):Bc(`Server entry is not a valid object`,n)}let a=r.mcp;if(Rc(a)){let e=Object.keys(a);if(e.length===0)return Bc(`mcp object is empty`,n);if(e.length>1)return Bc(`Paste one server at a time. Found `+e.length+` servers in mcp`,n);let t=e[0],r=a[t];return Rc(r)?Vc(t,Xc(r),r):Bc(`Server entry in mcp is not a valid object`,n)}let o=qc(r);if(o)return Vc(o.name,Xc(o.entry),o.entry);if(Jc(r)){let e=Xc(r);return Vc(typeof r.name==`string`&&r.name.trim()?r.name.trim():t?.fallbackName,e,r)}return Bc(`No recognizable MCP server configuration found in JSON`,n)}function Xc(e){return e.type===`remote`?`remote`:e.type===`local`?`local`:typeof e.url==`string`&&e.url.trim()?`remote`:(Array.isArray(e.command)||typeof e.command==`string`||Array.isArray(e.args),`local`)}function Zc(e,t,n){let r=n?.isNewServer??!1,i=e.name,a=r&&i?i:t.name??``;return{...t,name:a,type:e.type,command:e.type===`local`?e.command:[],url:e.type===`remote`?e.url:``,environment:e.environment,headers:e.type===`remote`?e.headers:[],oauthEnabled:e.type===`remote`&&e.oauthEnabled,oauthClientId:e.type===`remote`?e.oauthClientId:``,oauthClientSecret:e.type===`remote`?e.oauthClientSecret:``,oauthScope:e.type===`remote`?e.oauthScope:``,oauthRedirectUri:e.type===`remote`?e.oauthRedirectUri:``,timeout:e.type===`remote`?e.timeout:``,enabled:e.enabled}}function Qc(e){let t=[],n=``,r=!1,i=!1;for(let a=0;a<e.length;a++){let o=e[a];if(o===`'`&&!i){r=!r;continue}if(o===`"`&&!r){i=!i;continue}if((o===` `||o===` `)&&!r&&!i){n&&=(t.push(n),``);continue}n+=o}return n&&t.push(n),t}function $c(e){let t=e.trim();if(!t)return{code:null};try{let e=new URL(t).searchParams.get(`code`);if(typeof e==`string`&&e.trim())return{code:e.trim()}}catch{}return{code:t}}var el=({value:e,onChange:t,pasteCommandTitle:n,pasteCommandLabel:r,pasteSuccess:i,clipboardReadFailed:a,preview:o})=>{let[s,c]=Q.useState(()=>e.join(`
3
3
  `)),l=Q.useRef(e);Q.useEffect(()=>{JSON.stringify(l.current)!==JSON.stringify(e)&&(l.current=e,c(e.join(`
4
4
  `)))},[e]);let u=e=>{t(e.split(`
5
5
  `).filter(e=>e.trim().length>0))};return(0,$.jsxs)(`div`,{className:`space-y-2`,"data-bwignore":`true`,"data-1p-ignore":`true`,"data-lpignore":`true`,children:[(0,$.jsx)(`div`,{className:`flex items-center justify-end gap-2`,children:(0,$.jsxs)(q,{variant:`ghost`,size:`xs`,className:`!font-normal gap-1 text-muted-foreground`,onClick:async()=>{try{let e=(await navigator.clipboard.readText()).trim(),n=e.includes(`
6
6
  `)?e.split(`
7
7
  `).filter(e=>e.trim()):Qc(e);c(n.join(`
8
- `)),t(n),Y.success(i(n.length))}catch{Y.error(a)}},type:`button`,title:n,children:[(0,$.jsx)(X,{name:`clipboard`,className:`h-3 w-3`}),r]})}),(0,$.jsx)(Wr,{embedded:!0,value:s,onChange:e=>{c(e.target.value),u(e.target.value)},onBlur:()=>{let e=s.split(`
8
+ `)),t(n),J.success(i(n.length))}catch{J.error(a)}},type:`button`,title:n,children:[(0,$.jsx)(X,{name:`clipboard`,className:`h-3 w-3`}),r]})}),(0,$.jsx)(Wr,{embedded:!0,value:s,onChange:e=>{c(e.target.value),u(e.target.value)},onBlur:()=>{let e=s.split(`
9
9
  `).map(e=>e.trimEnd()).join(`
10
10
  `);c(e),u(e)},placeholder:`npx
11
11
  -y
12
12
  @modelcontextprotocol/server-postgres
13
13
  postgresql://user:pass@host/db`,rows:Math.max(4,e.length+1),className:`font-mono typography-meta resize-y min-h-[80px]`,spellCheck:!1}),e.length>0&&(0,$.jsxs)(`details`,{className:`group`,children:[(0,$.jsx)(`summary`,{className:`typography-micro text-muted-foreground/60 cursor-pointer select-none hover:text-muted-foreground`,children:o(e.length)}),(0,$.jsx)(`div`,{className:`mt-1 rounded-md bg-[var(--surface-elevated)] px-3 py-2 overflow-x-auto`,children:(0,$.jsx)(`code`,{className:`typography-micro text-foreground/80 whitespace-pre`,children:e.map((e,t)=>(0,$.jsxs)(`span`,{className:`block`,children:[(0,$.jsxs)(`span`,{className:`text-muted-foreground select-none mr-2`,children:[`[`,t,`]`]}),e]},t))})})]})]})},tl=e=>e.toUpperCase().replace(/[^A-Z0-9_]/g,`_`),nl=({value:e,onChange:t,keyTransform:n=tl,keyPlaceholder:r=`API_KEY`,keyInputClassName:i=`w-36 shrink-0 font-mono typography-meta uppercase`,pasteLabel:a=`Paste .env`,pasteTitle:o=`Paste KEY=VALUE lines from clipboard`,noPairsFoundError:s,importSuccess:c,clipboardReadFailed:l,keyLabel:u,valueLabel:d,valuePlaceholder:f,hideValueTitle:p,showValueTitle:m,addVariable:h,plainTextWarning:g,removeVariableAria:_})=>{let[v,y]=Q.useState(new Set),b=()=>t([...e,{key:``,value:``}]),x=n=>{t(e.filter((e,t)=>t!==n)),y(e=>{let t=new Set(e);return t.delete(n),t})},S=(n,r,i)=>{let a=[...e];a[n]={...a[n],[r]:i},t(a)},C=e=>{y(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},w=async()=>{try{let n=await navigator.clipboard.readText(),r=[];for(let e of n.split(`
14
- `)){let t=e.trim();if(!t||t.startsWith(`#`))continue;let n=t.indexOf(`=`);if(n===-1)continue;let i=t.slice(0,n).trim(),a=t.slice(n+1).trim();(a.startsWith(`"`)&&a.endsWith(`"`)||a.startsWith(`'`)&&a.endsWith(`'`))&&(a=a.slice(1,-1)),i&&r.push({key:i,value:a})}if(r.length===0){Y.error(s);return}let i=[...e];for(let e of r){let t=i.findIndex(t=>t.key===e.key);t===-1?i.push(e):i[t]=e}t(i),Y.success(c(r.length))}catch{Y.error(l)}},T=e.some(e=>e.value.length>0);return(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground w-32 shrink-0`,children:u}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:d})]}),(0,$.jsxs)(q,{variant:`ghost`,size:`xs`,className:`!font-normal gap-1 text-muted-foreground`,onClick:w,type:`button`,title:o,children:[(0,$.jsx)(X,{name:`clipboard`,className:`h-3 w-3`}),a]})]}),(0,$.jsx)(`div`,{className:`space-y-1.5`,children:e.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Cn,{value:e.key,onChange:e=>S(t,`key`,n(e.target.value)),placeholder:r,className:i,"data-bwignore":`true`,"data-1p-ignore":`true`,"data-lpignore":`true`,spellCheck:!1}),(0,$.jsxs)(`div`,{className:`relative flex-1 flex items-center`,children:[(0,$.jsx)(Cn,{type:v.has(t)?`text`:`password`,value:e.value,onChange:e=>S(t,`value`,e.target.value),placeholder:f,className:`font-mono typography-meta pr-8 w-full`,autoComplete:`new-password`,"data-bwignore":`true`,"data-1p-ignore":`true`,"data-lpignore":`true`,spellCheck:!1}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>C(t),className:`absolute right-2 text-muted-foreground/60 hover:text-muted-foreground`,title:v.has(t)?p:m,children:v.has(t)?(0,$.jsx)(X,{name:`eye-off`,className:`h-3.5 w-3.5`}):(0,$.jsx)(X,{name:`eye`,className:`h-3.5 w-3.5`})})]}),(0,$.jsx)(q,{size:`sm`,variant:`ghost`,className:`h-7 w-7 px-0 shrink-0 text-muted-foreground hover:text-[var(--status-error)]`,onClick:()=>x(t),"aria-label":_,children:(0,$.jsx)(X,{name:`delete-bin`,className:`h-3.5 w-3.5`})})]},t))}),(0,$.jsxs)(q,{variant:`outline`,size:`xs`,className:`!font-normal gap-1.5`,onClick:b,type:`button`,children:[(0,$.jsx)(X,{name:`add`,className:`h-3.5 w-3.5`}),h]}),T&&(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground/60`,children:g})]})},rl=e=>{let t=(0,Sa.c)(14),{status:n,enabled:r,getStatusLabel:i,variant:a}=e,o=a===void 0?`compact`:a;if(!r||!n)return null;let s,c;if(t[0]!==i||t[1]!==n||t[2]!==o){c=Symbol.for(`react.early_return_sentinel`);bb0:{let e={connected:{text:`text-[var(--status-success)]`,bg:`bg-[var(--status-success)]/10`},failed:{text:`text-[var(--status-error)]`,bg:`bg-[var(--status-error)]/10`},needs_auth:{text:`text-[var(--status-warning)]`,bg:`bg-[var(--status-warning)]/10`},needs_client_registration:{text:`text-[var(--status-warning)]`,bg:`bg-[var(--status-warning)]/10`}}[n]??{text:`text-muted-foreground`,bg:``};if(o===`pill`){let r=K(`typography-micro font-medium rounded-full px-2 py-0.5`,e.text,e.bg),a;t[5]!==i||t[6]!==n?(a=i(n),t[5]=i,t[6]=n,t[7]=a):a=t[7],c=(0,$.jsxs)(`span`,{className:r,children:[`● `,a]});break bb0}s=K(`typography-micro font-medium`,e.text)}t[0]=i,t[1]=n,t[2]=o,t[3]=s,t[4]=c}else s=t[3],c=t[4];if(c!==Symbol.for(`react.early_return_sentinel`))return c;let l;t[8]!==i||t[9]!==n?(l=i(n),t[8]=i,t[9]=n,t[10]=l):l=t[10];let u;return t[11]!==s||t[12]!==l?(u=(0,$.jsxs)(`span`,{className:s,children:[`● `,l]}),t[11]=s,t[12]=l,t[13]=u):u=t[13],u},il=(e,t,n)=>{switch(e){case`connected`:return t(`settings.mcp.page.status.description.connected`);case`failed`:return n?.trim()||t(`settings.mcp.page.status.description.failedDefault`);case`needs_auth`:return t(`settings.mcp.page.status.description.needsAuth`);case`needs_client_registration`:return n?.trim()||t(`settings.mcp.page.status.description.needsClientRegistrationDefault`);case`disabled`:return t(`settings.mcp.page.status.description.disabled`);default:return t(`settings.mcp.page.status.description.default`)}},al=e=>{switch(e){case`failed`:return`border-[var(--status-error-border)] bg-[var(--status-error-background)]`;case`needs_auth`:case`needs_client_registration`:return`border-[var(--status-warning-border)] bg-[var(--status-warning-background)]`;default:return`border-[var(--interactive-border)] bg-[var(--surface-elevated)]`}},ol=(e,t,n,r)=>!!(e===`failed`||e===`needs_auth`||e===`needs_client_registration`||t||n||r),sl=(e,t,n)=>{let r=e instanceof Error?e.message:t;return/oauth state required/i.test(r)?n(`settings.mcp.page.toast.authSessionExpired`):r},cl=(e,t,n)=>{let r=typeof t==`string`&&t.trim()?t.trim():`__global__`;return`${n}::${e??`__none__`}::${r}`},ll=()=>{let{t:e}=Ge(),t=Q.useCallback((t,n)=>e(t,n),[e]),{selectedMcpName:n,mcpDraft:r,setMcpDraft:a,setSelectedMcp:o,createMcp:s,updateMcp:c,deleteMcp:l}=no(ne(e=>({selectedMcpName:e.selectedMcpName,mcpDraft:e.mcpDraft,setMcpDraft:e.setMcpDraft,setSelectedMcp:e.setSelectedMcp,createMcp:e.createMcp,updateMcp:e.updateMcp,deleteMcp:e.deleteMcp}))),u=Bi(),d=i(),f=Fi(u),p=Li(u),m=f.data??[],h=p.data??{},g=Ti(e=>e.getDiagnosticForDirectory(u)),_=Ti(e=>e.connect),v=Ti(e=>e.disconnect),y=Ti(e=>e.startAuth),b=Ti(e=>e.authStatus),x=Ti(e=>e.completeAuth),S=Ti(e=>e.clearAuth),C=Ti(e=>e.testConnection),w=n?m.find(e=>e.name===n)??null:null,T=!!(r&&r.name===n&&!w),[E,D]=Q.useState(``),[O,k]=Q.useState(`user`),[A,j]=Q.useState(`local`),[M,N]=Q.useState([]),[P,F]=Q.useState(``),[I,L]=Q.useState([]),[R,z]=Q.useState([]),[B,V]=Q.useState(!0),[H,U]=Q.useState(``),[W,ee]=Q.useState(``),[te,re]=Q.useState(``),[ie,ae]=Q.useState(``),[oe,se]=Q.useState(``),[ce,le]=Q.useState(!0),[ue,de]=Q.useState(!1),[G,fe]=Q.useState(!1),[pe,me]=Q.useState(!1),[he,ge]=Q.useState(!1),[_e,ve]=Q.useState(!1),[ye,be]=Q.useState(!1),[xe,Se]=Q.useState(!1),[Ce,we]=Q.useState(!1),[Te,Ee]=Q.useState(null),[De,ke]=Q.useState(null),[Ae,je]=Q.useState(``),[Me,Ne]=Q.useState(!1),Pe=Q.useRef(0),[Fe,Ie]=Q.useState(!1),[Le,Re]=Q.useState(!1),[ze,Be]=Q.useState(``),[Ve,Ue]=Q.useState(null),Ke=Q.useMemo(()=>cl(n,u,d),[u,n,d]),qe=Q.useRef(Ke),Je=Q.useRef(null),Ye=He(()=>{Ee(null),ke(null),je(``),Ne(!1),Pe.current=0,we(!1),ve(!1),be(!1)}),Xe=Q.useCallback(()=>{Be(``),Ue(null),Re(!0)},[]),Ze=Q.useCallback(async()=>{try{let e=await navigator.clipboard.readText();Be(e),Ue(null)}catch{Y.error(e(`settings.mcp.page.toast.clipboardReadFailed`))}},[e]),Qe=Q.useCallback(()=>{let t=Yc(ze,{fallbackName:E});if(!t.ok){Ue(t.error);return}let n=Zc(t,{name:E,scope:O,type:A,command:M,url:P,environment:I,headers:R,oauthEnabled:B,oauthClientId:H,oauthClientSecret:W,oauthScope:te,oauthRedirectUri:ie,timeout:oe,enabled:ce},{isNewServer:T});D(n.name),j(n.type),N(n.command??[]),F(n.url??``),L(n.environment??[]),z(n.headers??[]),V(n.oauthEnabled??!1),U(n.oauthClientId??``),ee(n.oauthClientSecret??``),re(n.oauthScope??``),ae(n.oauthRedirectUri??``),se(n.timeout??``),le(n.enabled??!0),Re(!1),Be(``),Ue(null),Y.success(e(`settings.mcp.page.toast.configImported`))},[ze,E,O,A,M,P,I,R,B,H,W,te,ie,oe,ce,T,e]);Q.useEffect(()=>{if(T&&r){D(r.name),k(r.scope||`user`),j(r.type),N(r.command),F(r.url),L(r.environment),z(r.headers),V(r.oauthEnabled),U(r.oauthClientId),ee(r.oauthClientSecret),re(r.oauthScope),ae(r.oauthRedirectUri),se(r.timeout),le(r.enabled),Ie(!1),Je.current={mcpType:r.type,command:r.command,url:r.url,envEntries:r.environment,headerEntries:r.headers,oauthEnabled:r.oauthEnabled,oauthClientId:r.oauthClientId,oauthClientSecret:r.oauthClientSecret,oauthScope:r.oauthScope,oauthRedirectUri:r.oauthRedirectUri,timeout:r.timeout,enabled:r.enabled};return}if(w){k(w.scope===`project`?`project`:`user`);let e=$a(w.environment),t=w.type===`remote`?w:null,n=$a(t?.headers),r=t?.oauth,i=r&&typeof r==`object`?r:null,a=r!==!1,o=w.type,s=o===`local`?w.command??[]:[],c=o===`remote`?w.url??``:``,l=typeof t?.timeout==`number`&&Number.isFinite(t.timeout)?String(t.timeout):``;j(o),N(s),F(c),L(e),z(n),V(a),U(a?i?.clientId??``:``),ee(a?i?.clientSecret??``:``),re(a?i?.scope??``:``),ae(a?i?.redirectUri??``:``),se(l),le(w.enabled),Ie(!1),Je.current={mcpType:o,command:s,url:c,envEntries:e,headerEntries:n,oauthEnabled:a,oauthClientId:a?i?.clientId??``:``,oauthClientSecret:a?i?.clientSecret??``:``,oauthScope:a?i?.scope??``:``,oauthRedirectUri:a?i?.redirectUri??``:``,timeout:l,enabled:w.enabled}}},[w,T,r]);let $e=Q.useMemo(()=>{let e=Je.current;return e?A!==e.mcpType||ce!==e.enabled||JSON.stringify(M)!==JSON.stringify(e.command)||P!==e.url||JSON.stringify(I)!==JSON.stringify(e.envEntries)||JSON.stringify(R)!==JSON.stringify(e.headerEntries)||B!==e.oauthEnabled||H!==e.oauthClientId||W!==e.oauthClientSecret||te!==e.oauthScope||ie!==e.oauthRedirectUri||oe!==e.timeout:!1},[A,M,P,I,R,B,H,W,te,ie,oe,ce]),et=async()=>{let t=T?E.trim():n??``;if(!t){Y.error(e(`settings.mcp.page.toast.nameRequired`));return}if(T&&m.some(e=>e.name===t)){Y.error(e(`settings.mcp.page.toast.serverNameExists`));return}if(A===`local`&&M.filter(Boolean).length===0){Y.error(e(`settings.mcp.page.toast.localCommandRequired`));return}if(A===`remote`&&!P.trim()){Y.error(e(`settings.mcp.page.toast.remoteUrlRequired`));return}let r={name:t,scope:O,type:A,command:M,url:P,environment:I,headers:R,oauthEnabled:B,oauthClientId:H,oauthClientSecret:W,oauthScope:te,oauthRedirectUri:ie,timeout:oe,enabled:ce};de(!0);try{let n={directory:Bi(),transportIdentity:i()},l=T?await s(r,n):await c(t,r,n);l.ok?(Ye(),T&&(a(null),o(t)),l.reloadFailed?Y.warning(l.message||e(T?`settings.mcp.page.toast.serverCreatedReloadFailed`:`settings.mcp.page.toast.savedReloadFailed`),{description:l.warning||e(`settings.mcp.page.toast.retryRefreshHint`)}):Y.success(l.message||e(T?`settings.mcp.page.toast.serverCreatedReloading`:`settings.mcp.page.toast.savedReloading`))):Y.error(e(`settings.mcp.page.toast.saveFailed`))}catch(t){Y.error(t instanceof Error?t.message:e(`settings.mcp.page.toast.unexpectedError`))}finally{de(!1)}},tt=async()=>{if(!n)return;me(!0);let t=await l(n,{directory:Bi(),transportIdentity:i()});t.ok?(Ye(),t.reloadFailed?Y.warning(t.message||e(`settings.mcp.page.toast.serverDeletedReloadFailed`,{name:n}),{description:t.warning||e(`settings.mcp.page.toast.refreshListIfStale`)}):Y.success(t.message||e(`settings.mcp.page.toast.serverDeleted`,{name:n})),fe(!1)):Y.error(e(`settings.mcp.page.toast.deleteFailed`)),me(!1)},nt=async()=>{if(n){ge(!0);try{if(h[n]?.status===`connected`)await v(n,u),Y.success(e(`settings.mcp.page.toast.disconnected`));else{await _(n,u);let t=Ii(Oe,u)[n];t?.status===`connected`?Y.success(e(`settings.mcp.page.toast.connected`)):t?.status===`needs_auth`?Y.message(e(`settings.mcp.page.toast.connectionNeedsAuthorization`)):t?.status===`needs_client_registration`?Y.message(e(`settings.mcp.page.toast.connectionNeedsClientRegistration`)):t?.status===`failed`?Y.error(t.error||e(`settings.mcp.page.toast.connectionFailed`)):Y.message(e(`settings.mcp.page.toast.connectionAttemptFinished`));return}}catch(t){Y.error(t instanceof Error?t.message:e(`settings.mcp.page.toast.connectionFailed`))}finally{ge(!1)}}},rt=Q.useCallback(()=>T?(Y.error(e(`settings.mcp.page.toast.createServerBeforeLiveActions`)),!1):!$e||(Y.error(e(`settings.mcp.page.toast.saveBeforeLiveActions`)),!1),[$e,T,e]);Q.useEffect(()=>(qe.current=Ke,ge(!1),Se(!1),Ye(),()=>{qe.current=``}),[Ye,Ke]);let it=He(async()=>{if(!n||A!==`remote`||!rt())return;ve(!0);let r=Ke;try{if(ie&&new URL(ie).pathname===`/mcp/oauth/callback`){let t=await c(n,{oauthEnabled:B,oauthClientId:H,oauthClientSecret:W,oauthScope:te,oauthRedirectUri:``});if(!t.ok)throw Error(e(`settings.mcp.page.toast.oauthBrowserCallbackSaveFailed`));if(t.reloadFailed)throw Error(t.warning||t.message||e(`settings.mcp.page.toast.openCodeReloadFailedAfterCallbackSave`));if(qe.current!==r)return;ae(``),Je.current=Je.current?{...Je.current,oauthRedirectUri:``}:Je.current}let t=await y(n,u),i=t.url;if(qe.current!==r)return;Ee(i),ke(t.mode),Ne(t.mode===`auto`),Pe.current=0;let a=await Br(i);if(qe.current!==r)return;a?Y.message(t.mode===`code`?e(`settings.mcp.page.toast.completeAuthorizationInBrowserWithPaste`):e(`settings.mcp.page.toast.completeAuthorizationInBrowser`)):Y.error(e(`settings.mcp.page.toast.openAuthorizationUrlFailed`))}catch(n){qe.current===r&&Y.error(sl(n,e(`settings.mcp.page.toast.authorizationStartFailed`),t))}finally{qe.current===r&&ve(!1)}}),at=He(async()=>{if(!n||!rt())return;be(!0);let r=Ke;try{if(await S(n,u),qe.current!==r)return;Ee(null),je(``),Ne(!1),Pe.current=0,Y.success(e(`settings.mcp.page.toast.savedAuthorizationRemoved`))}catch(n){qe.current===r&&Y.error(sl(n,e(`settings.mcp.page.toast.clearAuthorizationFailed`),t))}finally{qe.current===r&&be(!1)}}),ot=Q.useCallback(async()=>{if(Te){if((await We(Te)).ok){Y.success(e(`settings.mcp.page.toast.authorizationUrlCopied`));return}Y.error(e(`settings.mcp.page.toast.authorizationUrlCopyFailed`))}},[Te,e]),st=He(async()=>{let r=$c(Ae);if(!r.code){Y.error(e(`settings.mcp.page.toast.pasteCallbackOrCodeFirst`));return}let i=n,a=u;if(!i){Y.error(e(`settings.mcp.page.toast.missingServerDetails`));return}if(!rt())return;we(!0);let o=Ke;try{if(await x(i,r.code,a),qe.current!==o)return;je(``),Ee(null),Ne(!1),Pe.current=0,Y.success(i===n?e(`settings.mcp.page.toast.authorizationCompleted`):e(`settings.mcp.page.toast.authorizationCompletedFor`,{name:i}))}catch(n){qe.current===o&&Y.error(sl(n,e(`settings.mcp.page.toast.authorizationCompleteFailed`),t))}finally{qe.current===o&&we(!1)}}),ct=Q.useCallback(async()=>{if(!(!n||!rt())){if(!ce){Y.error(e(`settings.mcp.page.toast.enableServerBeforeTest`));return}Se(!0);try{let t=await C(n,u),r=t.status?.status;t.warning?Y.warning(t.warning):r===`connected`?Y.success(e(`settings.mcp.page.toast.connectionTestSucceeded`)):r===`needs_auth`?Y.message(e(`settings.mcp.page.toast.connectionNeedsAuthorization`)):r===`needs_client_registration`?Y.message(e(`settings.mcp.page.toast.connectionNeedsClientRegistration`)):r===`failed`?Y.error(t.status?.error||t.error||e(`settings.mcp.page.toast.connectionTestFailed`)):t.error?Y.error(t.error):Y.message(e(`settings.mcp.page.toast.connectionTestFinished`))}catch(t){Y.error(t instanceof Error?t.message:e(`settings.mcp.page.toast.connectionTestFailed`))}finally{Se(!1)}}},[ce,u,rt,n,e,C]);if(Q.useEffect(()=>{if(!Me||!n)return;let t=!1,r=null,i=()=>{Ne(!1),Pe.current=0},a=async()=>{try{let o=await b(n,u);if(t)return;if(Pe.current+=1,o.status===`complete`){i(),Ee(null),je(``),Y.success(e(`settings.mcp.page.toast.authorizationCompleted`)),Ri(Oe,u,d).catch(()=>void 0);return}if(o.status===`failed`||o.status===`expired`){i(),Y.error(o.status===`failed`?o.message:e(`settings.mcp.page.toast.authSessionExpired`));return}if(Pe.current>=300){i(),Y.message(e(`settings.mcp.page.toast.authorizationStillInProgress`));return}r=window.setTimeout(()=>void a(),2e3)}catch{if(t)return;if(Pe.current+=1,Pe.current>=300){i(),Y.message(e(`settings.mcp.page.toast.authorizationStillInProgress`));return}r=window.setTimeout(()=>void a(),2e3)}};return r=window.setTimeout(()=>void a(),2e3),()=>{t=!0,r!==null&&window.clearTimeout(r)}},[b,Me,u,n,e,d]),f.isError&&!f.data)return(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6`,children:(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)] text-center`,children:f.error.message})});if(!n)return(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,$.jsxs)(`div`,{className:`text-center text-muted-foreground`,children:[(0,$.jsx)(X,{name:`plug`,className:`mx-auto mb-3 h-12 w-12 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.mcp.page.empty.selectServer`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:e(`settings.mcp.page.empty.addNewOne`)})]})});let lt=h[n],ut=n?g[n]:void 0,dt=lt??ut??(p.isError&&!p.data?{status:`failed`,error:p.error.message}:void 0),ft=lt?.status===`connected`,pt=lt?.status===`needs_auth`||lt?.status===`needs_client_registration`,mt=il(dt?.status,t,dt&&`error`in dt?dt.error:void 0),ht=t=>{switch(t){case`connected`:return e(`settings.mcp.page.status.label.connected`);case`failed`:return e(`settings.mcp.page.status.label.failed`);case`needs_auth`:return e(`settings.mcp.page.status.label.needsAuth`);case`needs_client_registration`:return e(`settings.mcp.page.status.label.needsRegistration`);default:return t}};return(0,$.jsxs)(Ur,{outerClassName:`h-full`,className:`w-full`,children:[(0,$.jsxs)(`div`,{className:`yuri-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsx)(Gi,{actions:(0,$.jsxs)($.Fragment,{children:[T?null:(0,$.jsx)(q,{variant:`ghost`,size:`icon`,onClick:()=>fe(!0),disabled:ue,"aria-label":e(`settings.common.actions.delete`),title:e(`settings.common.actions.delete`),className:`text-[var(--status-error)]`,children:(0,$.jsx)(X,{name:`delete-bin`,className:`size-4`})}),(0,$.jsx)(q,{onClick:et,disabled:ue||!$e&&!T,size:`sm`,"aria-busy":ue,children:e(ue?`settings.common.actions.saving`:T?`settings.common.actions.create`:`settings.common.actions.saveChanges`)})]}),children:(0,$.jsxs)(`div`,{className:`min-w-0`,children:[T?(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:e(`settings.mcp.page.header.newServer`)}):(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:n}),(0,$.jsx)(rl,{status:dt?.status,enabled:ce,getStatusLabel:ht,variant:`pill`})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 mt-0.5`,children:[(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground truncate`,children:T?e(`settings.mcp.page.header.configureNewServer`):e(`settings.mcp.page.header.transport`,{type:e(A===`local`?`settings.mcp.page.transport.local`:`settings.mcp.page.transport.remote`)})}),!T&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(q,{variant:ft?`outline`:`default`,size:`xs`,className:`!font-normal`,onClick:nt,disabled:he||!ce,children:e(he?`settings.mcp.page.actions.working`:ft?`settings.mcp.page.actions.disconnect`:`settings.mcp.page.actions.connect`)}),A===`remote`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(q,{variant:pt?`default`:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>void it(),disabled:_e||!ce,children:e(_e?`settings.mcp.page.actions.starting`:pt?`settings.mcp.page.actions.authorize`:`settings.mcp.page.actions.reauthorize`)}),(0,$.jsx)(q,{variant:`ghost`,size:`xs`,className:`!font-normal gap-1 text-muted-foreground`,onClick:()=>void at(),disabled:ye||!ce,children:e(ye?`settings.mcp.page.actions.clearing`:`settings.mcp.page.actions.clearAuth`)})]}),ft&&(0,$.jsx)(q,{variant:`ghost`,size:`xs`,className:`!font-normal gap-1 text-muted-foreground`,onClick:()=>void ct(),disabled:xe||!ce,children:e(xe?`settings.mcp.page.actions.testing`:`settings.mcp.page.actions.test`)})]})]})]})}),!T&&ol(dt?.status,Te,pt,Me)&&(0,$.jsx)(`div`,{className:`px-2`,children:(0,$.jsxs)(`div`,{className:K(`rounded-lg border p-3`,al(dt?.status)),children:[(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.mcp.page.status.runtimeStatus`)}),(0,$.jsx)(rl,{status:dt?.status,enabled:ce,getStatusLabel:ht})]}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:mt}),(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground/80`,children:O===`project`?e(`settings.mcp.page.status.projectScopedTo`,{directory:u??e(`settings.mcp.page.status.activeProject`)}):e(`settings.mcp.page.status.userScoped`)})]}),(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:!ft&&(0,$.jsx)(q,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>void ct(),disabled:xe||!ce,children:e(xe?`settings.mcp.page.actions.testing`:`settings.mcp.page.actions.testConnection`)})}),Te&&(0,$.jsx)(`div`,{className:`rounded-md border border-[var(--interactive-border)] bg-[var(--surface-background)] px-3 py-2`,children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground`,children:e(`settings.mcp.page.auth.authorizationUrl`)}),(0,$.jsx)(`div`,{className:`break-all typography-micro text-foreground font-mono`,children:Te}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsxs)(q,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>void Br(Te),children:[(0,$.jsx)(X,{name:`external-link`,className:`h-3.5 w-3.5`}),e(`settings.mcp.page.actions.openInBrowser`)]}),(0,$.jsxs)(q,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>void ot(),children:[(0,$.jsx)(X,{name:`clipboard`,className:`h-3.5 w-3.5`}),e(`settings.mcp.page.actions.copyLink`)]})]})]})}),A===`remote`&&De===`code`&&Te&&(0,$.jsx)(`div`,{className:`rounded-md border border-[var(--interactive-border)] bg-[var(--surface-background)] px-3 py-3`,children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:e(`settings.mcp.page.auth.manualFallbackTitle`)}),(0,$.jsx)(`p`,{className:`mt-1 typography-micro text-muted-foreground`,children:e(`settings.mcp.page.auth.manualFallbackDescription`)})]}),(0,$.jsx)(Wr,{embedded:!0,value:Ae,onChange:e=>je(e.target.value),placeholder:e(`settings.mcp.page.auth.callbackInputPlaceholder`),rows:3,className:`font-mono typography-meta resize-y`,"data-bwignore":`true`,"data-1p-ignore":`true`,spellCheck:!1}),(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:(0,$.jsx)(q,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>void st(),disabled:Ce,children:e(Ce?`settings.mcp.page.actions.completing`:`settings.mcp.page.actions.completeAuthorization`)})})]})})]}),Me&&(0,$.jsx)(`p`,{className:`mt-4 typography-micro text-muted-foreground`,children:e(`settings.mcp.page.auth.waitingForOpenCode`)})]})}),(0,$.jsx)(`div`,{"data-settings-item":`mcp.server`,children:(0,$.jsx)(Z,{label:e(`settings.mcp.page.server.title`),cardClassName:`p-3`,children:(0,$.jsxs)(`div`,{className:`space-y-3`,children:[T&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-8`,children:[(0,$.jsx)(`div`,{className:`flex min-w-0 flex-col sm:w-56 shrink-0`,children:(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.mcp.page.server.name`)})}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2 sm:w-fit sm:flex-initial`,children:[(0,$.jsx)(Cn,{value:E,onChange:e=>D(e.target.value.toLowerCase().replace(/[^a-z0-9_-]/g,`-`)),placeholder:e(`settings.mcp.page.server.namePlaceholder`),className:`h-7 w-48 font-mono px-2`,autoFocus:!0}),(0,$.jsxs)(Fr,{value:O,onValueChange:e=>k(e),children:[(0,$.jsx)(Pr,{className:`!h-7 !w-7 !min-w-0 !px-0 !py-0 justify-center [&>svg:last-child]:hidden`,title:e(O===`user`?`settings.common.scope.global`:`settings.common.scope.project`),children:O===`user`?(0,$.jsx)(X,{name:`user-3`,className:`h-3.5 w-3.5`}):(0,$.jsx)(X,{name:`folder`,className:`h-3.5 w-3.5`})}),(0,$.jsxs)(Nr,{align:`end`,children:[(0,$.jsx)(jr,{value:`user`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(X,{name:`user-3`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:e(`settings.common.scope.global`)})]})}),(0,$.jsx)(jr,{value:`project`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(X,{name:`folder`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:e(`settings.common.scope.project`)})]})})]})]})]})]}),T&&(0,$.jsx)(`div`,{children:(0,$.jsxs)(q,{variant:`outline`,size:`xs`,className:`!font-normal gap-1.5`,onClick:Xe,type:`button`,title:e(`settings.mcp.page.server.importJsonTitle`),children:[(0,$.jsx)(X,{name:`file-code`,className:`h-3.5 w-3.5`}),e(`settings.mcp.page.server.importJson`)]})}),(0,$.jsx)(Ji,{checked:ce,onChange:le,label:e(`settings.mcp.page.server.enable`),ariaLabel:e(`settings.mcp.page.server.enableAria`)}),(0,$.jsx)(`div`,{className:`flex min-w-0 items-center justify-between gap-2`,children:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.mcp.page.server.transportMode`)}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-1`,children:[(0,$.jsx)(q,{variant:`chip`,size:`xs`,"aria-pressed":A===`local`,onClick:()=>j(`local`),className:`!font-normal`,children:e(`settings.mcp.page.transport.local`)}),(0,$.jsx)(q,{variant:`chip`,size:`xs`,"aria-pressed":A===`remote`,onClick:()=>j(`remote`),className:`!font-normal`,children:e(`settings.mcp.page.transport.remote`)})]})]})})]})})}),(0,$.jsx)(`div`,{"data-settings-item":`mcp.command`,children:A===`local`?(0,$.jsx)(Z,{label:e(`settings.mcp.page.connection.command`),cardClassName:`p-3`,children:(0,$.jsx)(el,{value:M,onChange:N,pasteCommandTitle:e(`settings.mcp.page.connection.pasteCommandTitle`),pasteCommandLabel:e(`settings.mcp.page.connection.pasteCommand`),pasteSuccess:t=>e(`settings.mcp.page.toast.pastedArgumentsCount`,{count:t}),clipboardReadFailed:e(`settings.mcp.page.toast.clipboardReadFailed`),preview:t=>e(`settings.mcp.page.connection.previewArgs`,{count:t})})}):(0,$.jsx)(Z,{children:(0,$.jsx)(Xi,{label:e(`settings.mcp.page.connection.serverUrl`),children:(0,$.jsx)(Cn,{value:P,onChange:e=>F(e.target.value),placeholder:e(`settings.mcp.page.connection.serverUrlPlaceholder`),className:`font-mono typography-meta`})})})}),A===`remote`&&(0,$.jsx)(`div`,{"data-settings-item":`mcp.advanced`,children:(0,$.jsx)(Z,{label:e(`settings.mcp.page.advanced.title`),cardClassName:`p-3`,children:(0,$.jsxs)(ca,{open:Fe,onOpenChange:Ie,children:[(0,$.jsxs)(sa,{className:`flex w-full items-center justify-between py-0.5 group`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-left`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label font-normal text-foreground`,children:e(`settings.mcp.page.advanced.configure`)}),(0,$.jsxs)(`span`,{className:`typography-micro text-muted-foreground`,children:[`(`,e(B?`settings.mcp.page.advanced.autoDetect`:`settings.mcp.page.advanced.custom`),` · `,R.length,` `,e(`settings.mcp.page.advanced.headers`),oe?` · ${oe}ms`:``,`)`]})]}),Fe?(0,$.jsx)(X,{name:`arrow-down-s`,className:`h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors`}):(0,$.jsx)(X,{name:`arrow-right-s`,className:`h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors`})]}),(0,$.jsx)(oa,{className:`pt-2`,children:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(Xi,{label:e(`settings.mcp.page.advanced.timeoutMs`),description:e(`settings.mcp.page.advanced.timeoutHint`),children:(0,$.jsx)(Cn,{type:`number`,min:`1`,step:`1`,value:oe,onChange:e=>se(e.target.value),placeholder:`5000`,className:`w-32 font-mono`,"data-bwignore":`true`,"data-1p-ignore":`true`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`mb-2 typography-ui-label text-foreground`,children:[e(`settings.mcp.page.advanced.requestHeaders`),R.length>0&&(0,$.jsxs)(`span`,{className:`ml-1.5 typography-micro text-muted-foreground font-normal`,children:[`(`,R.length,`)`]})]}),(0,$.jsx)(nl,{value:R,onChange:z,keyTransform:e=>e.trimStart(),keyPlaceholder:e(`settings.mcp.page.advanced.headerNamePlaceholder`),keyInputClassName:`w-36 shrink-0 font-mono typography-meta`,pasteLabel:e(`settings.mcp.page.advanced.pasteHeaders`),pasteTitle:e(`settings.mcp.page.advanced.pasteHeadersTitle`),noPairsFoundError:e(`settings.mcp.page.toast.noKeyValuePairsFound`),importSuccess:t=>e(`settings.mcp.page.toast.importedVariablesCount`,{count:t}),clipboardReadFailed:e(`settings.mcp.page.toast.clipboardReadFailed`),keyLabel:e(`settings.mcp.page.env.key`),valueLabel:e(`settings.mcp.page.env.value`),valuePlaceholder:e(`settings.mcp.page.env.valuePlaceholder`),hideValueTitle:e(`settings.mcp.page.env.hide`),showValueTitle:e(`settings.mcp.page.env.show`),addVariable:e(`settings.mcp.page.env.addVariable`),plainTextWarning:e(`settings.mcp.page.env.plainTextWarning`),removeVariableAria:e(`settings.mcp.page.env.removeVariableAria`)})]}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(Ji,{checked:B,onChange:V,label:e(`settings.mcp.page.advanced.oauthAutoDetection`),ariaLabel:e(`settings.mcp.page.advanced.oauthAutoDetectionAria`)}),(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsx)(Cn,{value:H,onChange:e=>U(e.target.value),placeholder:e(`settings.mcp.page.advanced.oauthClientIdPlaceholder`),className:`font-mono typography-meta`,disabled:!B,"data-bwignore":`true`,"data-1p-ignore":`true`}),(0,$.jsx)(Cn,{value:W,onChange:e=>ee(e.target.value),placeholder:e(`settings.mcp.page.advanced.oauthClientSecretPlaceholder`),className:`font-mono typography-meta`,disabled:!B,"data-bwignore":`true`,"data-1p-ignore":`true`}),(0,$.jsx)(Cn,{value:te,onChange:e=>re(e.target.value),placeholder:e(`settings.mcp.page.advanced.oauthScopesPlaceholder`),className:`font-mono typography-meta`,disabled:!B,"data-bwignore":`true`,"data-1p-ignore":`true`}),(0,$.jsx)(Cn,{value:ie,onChange:e=>ae(e.target.value),placeholder:e(`settings.mcp.page.advanced.oauthRedirectUriPlaceholder`),className:`font-mono typography-meta`,disabled:!B,"data-bwignore":`true`,"data-1p-ignore":`true`})]}),(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground`,children:e(`settings.mcp.page.advanced.oauthHint`)})]})]})})]})})}),(0,$.jsx)(`div`,{"data-settings-item":`mcp.environment`,children:(0,$.jsx)(Z,{label:(0,$.jsxs)(`span`,{children:[e(`settings.mcp.page.env.title`),I.length>0&&(0,$.jsxs)(`span`,{className:`ml-1.5 typography-micro text-muted-foreground font-normal`,children:[`(`,I.length,`)`]})]}),cardClassName:`p-3`,children:I.length===0?(0,$.jsxs)(q,{variant:`outline`,size:`xs`,className:`!font-normal gap-1.5`,onClick:()=>L([{key:``,value:``}]),children:[(0,$.jsx)(X,{name:`add`,className:`h-3.5 w-3.5`}),e(`settings.mcp.page.env.addEnvironmentVariable`)]}):(0,$.jsx)(nl,{value:I,onChange:L,keyPlaceholder:e(`settings.mcp.page.env.keyPlaceholder`),pasteLabel:e(`settings.mcp.page.env.pasteEnv`),pasteTitle:e(`settings.mcp.page.env.pasteEnvTitle`),noPairsFoundError:e(`settings.mcp.page.toast.noKeyValuePairsFound`),importSuccess:t=>e(`settings.mcp.page.toast.importedVariablesCount`,{count:t}),clipboardReadFailed:e(`settings.mcp.page.toast.clipboardReadFailed`),keyLabel:e(`settings.mcp.page.env.key`),valueLabel:e(`settings.mcp.page.env.value`),valuePlaceholder:e(`settings.mcp.page.env.valuePlaceholder`),hideValueTitle:e(`settings.mcp.page.env.hide`),showValueTitle:e(`settings.mcp.page.env.show`),addVariable:e(`settings.mcp.page.env.addVariable`),plainTextWarning:e(`settings.mcp.page.env.plainTextWarning`),removeVariableAria:e(`settings.mcp.page.env.removeVariableAria`)})})})]}),(0,$.jsx)(gn,{open:Le,onOpenChange:e=>{e||(Re(!1),Be(``),Ue(null))},children:(0,$.jsxs)(pn,{className:`max-w-md`,children:[(0,$.jsxs)(dn,{children:[(0,$.jsx)(mn,{children:e(`settings.mcp.page.importDialog.title`)}),(0,$.jsx)(hn,{children:e(`settings.mcp.page.importDialog.description`)})]}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(Wr,{value:ze,onChange:e=>{Be(e.target.value),Ue(null)},placeholder:`{
14
+ `)){let t=e.trim();if(!t||t.startsWith(`#`))continue;let n=t.indexOf(`=`);if(n===-1)continue;let i=t.slice(0,n).trim(),a=t.slice(n+1).trim();(a.startsWith(`"`)&&a.endsWith(`"`)||a.startsWith(`'`)&&a.endsWith(`'`))&&(a=a.slice(1,-1)),i&&r.push({key:i,value:a})}if(r.length===0){J.error(s);return}let i=[...e];for(let e of r){let t=i.findIndex(t=>t.key===e.key);t===-1?i.push(e):i[t]=e}t(i),J.success(c(r.length))}catch{J.error(l)}},T=e.some(e=>e.value.length>0);return(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground w-32 shrink-0`,children:u}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:d})]}),(0,$.jsxs)(q,{variant:`ghost`,size:`xs`,className:`!font-normal gap-1 text-muted-foreground`,onClick:w,type:`button`,title:o,children:[(0,$.jsx)(X,{name:`clipboard`,className:`h-3 w-3`}),a]})]}),(0,$.jsx)(`div`,{className:`space-y-1.5`,children:e.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Cn,{value:e.key,onChange:e=>S(t,`key`,n(e.target.value)),placeholder:r,className:i,"data-bwignore":`true`,"data-1p-ignore":`true`,"data-lpignore":`true`,spellCheck:!1}),(0,$.jsxs)(`div`,{className:`relative flex-1 flex items-center`,children:[(0,$.jsx)(Cn,{type:v.has(t)?`text`:`password`,value:e.value,onChange:e=>S(t,`value`,e.target.value),placeholder:f,className:`font-mono typography-meta pr-8 w-full`,autoComplete:`new-password`,"data-bwignore":`true`,"data-1p-ignore":`true`,"data-lpignore":`true`,spellCheck:!1}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>C(t),className:`absolute right-2 text-muted-foreground/60 hover:text-muted-foreground`,title:v.has(t)?p:m,children:v.has(t)?(0,$.jsx)(X,{name:`eye-off`,className:`h-3.5 w-3.5`}):(0,$.jsx)(X,{name:`eye`,className:`h-3.5 w-3.5`})})]}),(0,$.jsx)(q,{size:`sm`,variant:`ghost`,className:`h-7 w-7 px-0 shrink-0 text-muted-foreground hover:text-[var(--status-error)]`,onClick:()=>x(t),"aria-label":_,children:(0,$.jsx)(X,{name:`delete-bin`,className:`h-3.5 w-3.5`})})]},t))}),(0,$.jsxs)(q,{variant:`outline`,size:`xs`,className:`!font-normal gap-1.5`,onClick:b,type:`button`,children:[(0,$.jsx)(X,{name:`add`,className:`h-3.5 w-3.5`}),h]}),T&&(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground/60`,children:g})]})},rl=e=>{let t=(0,Sa.c)(14),{status:n,enabled:r,getStatusLabel:i,variant:a}=e,o=a===void 0?`compact`:a;if(!r||!n)return null;let s,c;if(t[0]!==i||t[1]!==n||t[2]!==o){c=Symbol.for(`react.early_return_sentinel`);bb0:{let e={connected:{text:`text-[var(--status-success)]`,bg:`bg-[var(--status-success)]/10`},failed:{text:`text-[var(--status-error)]`,bg:`bg-[var(--status-error)]/10`},needs_auth:{text:`text-[var(--status-warning)]`,bg:`bg-[var(--status-warning)]/10`},needs_client_registration:{text:`text-[var(--status-warning)]`,bg:`bg-[var(--status-warning)]/10`}}[n]??{text:`text-muted-foreground`,bg:``};if(o===`pill`){let r=K(`typography-micro font-medium rounded-full px-2 py-0.5`,e.text,e.bg),a;t[5]!==i||t[6]!==n?(a=i(n),t[5]=i,t[6]=n,t[7]=a):a=t[7],c=(0,$.jsxs)(`span`,{className:r,children:[`● `,a]});break bb0}s=K(`typography-micro font-medium`,e.text)}t[0]=i,t[1]=n,t[2]=o,t[3]=s,t[4]=c}else s=t[3],c=t[4];if(c!==Symbol.for(`react.early_return_sentinel`))return c;let l;t[8]!==i||t[9]!==n?(l=i(n),t[8]=i,t[9]=n,t[10]=l):l=t[10];let u;return t[11]!==s||t[12]!==l?(u=(0,$.jsxs)(`span`,{className:s,children:[`● `,l]}),t[11]=s,t[12]=l,t[13]=u):u=t[13],u},il=(e,t,n)=>{switch(e){case`connected`:return t(`settings.mcp.page.status.description.connected`);case`failed`:return n?.trim()||t(`settings.mcp.page.status.description.failedDefault`);case`needs_auth`:return t(`settings.mcp.page.status.description.needsAuth`);case`needs_client_registration`:return n?.trim()||t(`settings.mcp.page.status.description.needsClientRegistrationDefault`);case`disabled`:return t(`settings.mcp.page.status.description.disabled`);default:return t(`settings.mcp.page.status.description.default`)}},al=e=>{switch(e){case`failed`:return`border-[var(--status-error-border)] bg-[var(--status-error-background)]`;case`needs_auth`:case`needs_client_registration`:return`border-[var(--status-warning-border)] bg-[var(--status-warning-background)]`;default:return`border-[var(--interactive-border)] bg-[var(--surface-elevated)]`}},ol=(e,t,n,r)=>!!(e===`failed`||e===`needs_auth`||e===`needs_client_registration`||t||n||r),sl=(e,t,n)=>{let r=e instanceof Error?e.message:t;return/oauth state required/i.test(r)?n(`settings.mcp.page.toast.authSessionExpired`):r},cl=(e,t,n)=>{let r=typeof t==`string`&&t.trim()?t.trim():`__global__`;return`${n}::${e??`__none__`}::${r}`},ll=()=>{let{t:e}=Ge(),t=Q.useCallback((t,n)=>e(t,n),[e]),{selectedMcpName:n,mcpDraft:r,setMcpDraft:a,setSelectedMcp:o,createMcp:s,updateMcp:c,deleteMcp:l}=no(ne(e=>({selectedMcpName:e.selectedMcpName,mcpDraft:e.mcpDraft,setMcpDraft:e.setMcpDraft,setSelectedMcp:e.setSelectedMcp,createMcp:e.createMcp,updateMcp:e.updateMcp,deleteMcp:e.deleteMcp}))),u=Bi(),d=i(),f=Fi(u),p=Li(u),m=f.data??[],h=p.data??{},g=Ti(e=>e.getDiagnosticForDirectory(u)),_=Ti(e=>e.connect),v=Ti(e=>e.disconnect),y=Ti(e=>e.startAuth),b=Ti(e=>e.authStatus),x=Ti(e=>e.completeAuth),S=Ti(e=>e.clearAuth),C=Ti(e=>e.testConnection),w=n?m.find(e=>e.name===n)??null:null,T=!!(r&&r.name===n&&!w),[E,D]=Q.useState(``),[O,k]=Q.useState(`user`),[A,j]=Q.useState(`local`),[M,N]=Q.useState([]),[P,F]=Q.useState(``),[I,L]=Q.useState([]),[R,z]=Q.useState([]),[B,V]=Q.useState(!0),[H,U]=Q.useState(``),[W,ee]=Q.useState(``),[te,re]=Q.useState(``),[ie,ae]=Q.useState(``),[oe,se]=Q.useState(``),[ce,le]=Q.useState(!0),[ue,de]=Q.useState(!1),[G,fe]=Q.useState(!1),[pe,me]=Q.useState(!1),[he,ge]=Q.useState(!1),[_e,ve]=Q.useState(!1),[ye,be]=Q.useState(!1),[xe,Se]=Q.useState(!1),[Ce,we]=Q.useState(!1),[Te,Ee]=Q.useState(null),[De,ke]=Q.useState(null),[Ae,je]=Q.useState(``),[Me,Ne]=Q.useState(!1),Pe=Q.useRef(0),[Fe,Ie]=Q.useState(!1),[Le,Re]=Q.useState(!1),[ze,Be]=Q.useState(``),[Ve,Ue]=Q.useState(null),Ke=Q.useMemo(()=>cl(n,u,d),[u,n,d]),qe=Q.useRef(Ke),Je=Q.useRef(null),Ye=He(()=>{Ee(null),ke(null),je(``),Ne(!1),Pe.current=0,we(!1),ve(!1),be(!1)}),Xe=Q.useCallback(()=>{Be(``),Ue(null),Re(!0)},[]),Ze=Q.useCallback(async()=>{try{let e=await navigator.clipboard.readText();Be(e),Ue(null)}catch{J.error(e(`settings.mcp.page.toast.clipboardReadFailed`))}},[e]),Qe=Q.useCallback(()=>{let t=Yc(ze,{fallbackName:E});if(!t.ok){Ue(t.error);return}let n=Zc(t,{name:E,scope:O,type:A,command:M,url:P,environment:I,headers:R,oauthEnabled:B,oauthClientId:H,oauthClientSecret:W,oauthScope:te,oauthRedirectUri:ie,timeout:oe,enabled:ce},{isNewServer:T});D(n.name),j(n.type),N(n.command??[]),F(n.url??``),L(n.environment??[]),z(n.headers??[]),V(n.oauthEnabled??!1),U(n.oauthClientId??``),ee(n.oauthClientSecret??``),re(n.oauthScope??``),ae(n.oauthRedirectUri??``),se(n.timeout??``),le(n.enabled??!0),Re(!1),Be(``),Ue(null),J.success(e(`settings.mcp.page.toast.configImported`))},[ze,E,O,A,M,P,I,R,B,H,W,te,ie,oe,ce,T,e]);Q.useEffect(()=>{if(T&&r){D(r.name),k(r.scope||`user`),j(r.type),N(r.command),F(r.url),L(r.environment),z(r.headers),V(r.oauthEnabled),U(r.oauthClientId),ee(r.oauthClientSecret),re(r.oauthScope),ae(r.oauthRedirectUri),se(r.timeout),le(r.enabled),Ie(!1),Je.current={mcpType:r.type,command:r.command,url:r.url,envEntries:r.environment,headerEntries:r.headers,oauthEnabled:r.oauthEnabled,oauthClientId:r.oauthClientId,oauthClientSecret:r.oauthClientSecret,oauthScope:r.oauthScope,oauthRedirectUri:r.oauthRedirectUri,timeout:r.timeout,enabled:r.enabled};return}if(w){k(w.scope===`project`?`project`:`user`);let e=$a(w.environment),t=w.type===`remote`?w:null,n=$a(t?.headers),r=t?.oauth,i=r&&typeof r==`object`?r:null,a=r!==!1,o=w.type,s=o===`local`?w.command??[]:[],c=o===`remote`?w.url??``:``,l=typeof t?.timeout==`number`&&Number.isFinite(t.timeout)?String(t.timeout):``;j(o),N(s),F(c),L(e),z(n),V(a),U(a?i?.clientId??``:``),ee(a?i?.clientSecret??``:``),re(a?i?.scope??``:``),ae(a?i?.redirectUri??``:``),se(l),le(w.enabled),Ie(!1),Je.current={mcpType:o,command:s,url:c,envEntries:e,headerEntries:n,oauthEnabled:a,oauthClientId:a?i?.clientId??``:``,oauthClientSecret:a?i?.clientSecret??``:``,oauthScope:a?i?.scope??``:``,oauthRedirectUri:a?i?.redirectUri??``:``,timeout:l,enabled:w.enabled}}},[w,T,r]);let $e=Q.useMemo(()=>{let e=Je.current;return e?A!==e.mcpType||ce!==e.enabled||JSON.stringify(M)!==JSON.stringify(e.command)||P!==e.url||JSON.stringify(I)!==JSON.stringify(e.envEntries)||JSON.stringify(R)!==JSON.stringify(e.headerEntries)||B!==e.oauthEnabled||H!==e.oauthClientId||W!==e.oauthClientSecret||te!==e.oauthScope||ie!==e.oauthRedirectUri||oe!==e.timeout:!1},[A,M,P,I,R,B,H,W,te,ie,oe,ce]),et=async()=>{let t=T?E.trim():n??``;if(!t){J.error(e(`settings.mcp.page.toast.nameRequired`));return}if(T&&m.some(e=>e.name===t)){J.error(e(`settings.mcp.page.toast.serverNameExists`));return}if(A===`local`&&M.filter(Boolean).length===0){J.error(e(`settings.mcp.page.toast.localCommandRequired`));return}if(A===`remote`&&!P.trim()){J.error(e(`settings.mcp.page.toast.remoteUrlRequired`));return}let r={name:t,scope:O,type:A,command:M,url:P,environment:I,headers:R,oauthEnabled:B,oauthClientId:H,oauthClientSecret:W,oauthScope:te,oauthRedirectUri:ie,timeout:oe,enabled:ce};de(!0);try{let n={directory:Bi(),transportIdentity:i()},l=T?await s(r,n):await c(t,r,n);l.ok?(Ye(),T&&(a(null),o(t)),l.reloadFailed?J.warning(l.message||e(T?`settings.mcp.page.toast.serverCreatedReloadFailed`:`settings.mcp.page.toast.savedReloadFailed`),{description:l.warning||e(`settings.mcp.page.toast.retryRefreshHint`)}):J.success(l.message||e(T?`settings.mcp.page.toast.serverCreatedReloading`:`settings.mcp.page.toast.savedReloading`))):J.error(e(`settings.mcp.page.toast.saveFailed`))}catch(t){J.error(t instanceof Error?t.message:e(`settings.mcp.page.toast.unexpectedError`))}finally{de(!1)}},tt=async()=>{if(!n)return;me(!0);let t=await l(n,{directory:Bi(),transportIdentity:i()});t.ok?(Ye(),t.reloadFailed?J.warning(t.message||e(`settings.mcp.page.toast.serverDeletedReloadFailed`,{name:n}),{description:t.warning||e(`settings.mcp.page.toast.refreshListIfStale`)}):J.success(t.message||e(`settings.mcp.page.toast.serverDeleted`,{name:n})),fe(!1)):J.error(e(`settings.mcp.page.toast.deleteFailed`)),me(!1)},nt=async()=>{if(n){ge(!0);try{if(h[n]?.status===`connected`)await v(n,u),J.success(e(`settings.mcp.page.toast.disconnected`));else{await _(n,u);let t=Ii(Oe,u)[n];t?.status===`connected`?J.success(e(`settings.mcp.page.toast.connected`)):t?.status===`needs_auth`?J.message(e(`settings.mcp.page.toast.connectionNeedsAuthorization`)):t?.status===`needs_client_registration`?J.message(e(`settings.mcp.page.toast.connectionNeedsClientRegistration`)):t?.status===`failed`?J.error(t.error||e(`settings.mcp.page.toast.connectionFailed`)):J.message(e(`settings.mcp.page.toast.connectionAttemptFinished`));return}}catch(t){J.error(t instanceof Error?t.message:e(`settings.mcp.page.toast.connectionFailed`))}finally{ge(!1)}}},rt=Q.useCallback(()=>T?(J.error(e(`settings.mcp.page.toast.createServerBeforeLiveActions`)),!1):!$e||(J.error(e(`settings.mcp.page.toast.saveBeforeLiveActions`)),!1),[$e,T,e]);Q.useEffect(()=>(qe.current=Ke,ge(!1),Se(!1),Ye(),()=>{qe.current=``}),[Ye,Ke]);let it=He(async()=>{if(!n||A!==`remote`||!rt())return;ve(!0);let r=Ke;try{if(ie&&new URL(ie).pathname===`/mcp/oauth/callback`){let t=await c(n,{oauthEnabled:B,oauthClientId:H,oauthClientSecret:W,oauthScope:te,oauthRedirectUri:``});if(!t.ok)throw Error(e(`settings.mcp.page.toast.oauthBrowserCallbackSaveFailed`));if(t.reloadFailed)throw Error(t.warning||t.message||e(`settings.mcp.page.toast.openCodeReloadFailedAfterCallbackSave`));if(qe.current!==r)return;ae(``),Je.current=Je.current?{...Je.current,oauthRedirectUri:``}:Je.current}let t=await y(n,u),i=t.url;if(qe.current!==r)return;Ee(i),ke(t.mode),Ne(t.mode===`auto`),Pe.current=0;let a=await Br(i);if(qe.current!==r)return;a?J.message(t.mode===`code`?e(`settings.mcp.page.toast.completeAuthorizationInBrowserWithPaste`):e(`settings.mcp.page.toast.completeAuthorizationInBrowser`)):J.error(e(`settings.mcp.page.toast.openAuthorizationUrlFailed`))}catch(n){qe.current===r&&J.error(sl(n,e(`settings.mcp.page.toast.authorizationStartFailed`),t))}finally{qe.current===r&&ve(!1)}}),at=He(async()=>{if(!n||!rt())return;be(!0);let r=Ke;try{if(await S(n,u),qe.current!==r)return;Ee(null),je(``),Ne(!1),Pe.current=0,J.success(e(`settings.mcp.page.toast.savedAuthorizationRemoved`))}catch(n){qe.current===r&&J.error(sl(n,e(`settings.mcp.page.toast.clearAuthorizationFailed`),t))}finally{qe.current===r&&be(!1)}}),ot=Q.useCallback(async()=>{if(Te){if((await We(Te)).ok){J.success(e(`settings.mcp.page.toast.authorizationUrlCopied`));return}J.error(e(`settings.mcp.page.toast.authorizationUrlCopyFailed`))}},[Te,e]),st=He(async()=>{let r=$c(Ae);if(!r.code){J.error(e(`settings.mcp.page.toast.pasteCallbackOrCodeFirst`));return}let i=n,a=u;if(!i){J.error(e(`settings.mcp.page.toast.missingServerDetails`));return}if(!rt())return;we(!0);let o=Ke;try{if(await x(i,r.code,a),qe.current!==o)return;je(``),Ee(null),Ne(!1),Pe.current=0,J.success(i===n?e(`settings.mcp.page.toast.authorizationCompleted`):e(`settings.mcp.page.toast.authorizationCompletedFor`,{name:i}))}catch(n){qe.current===o&&J.error(sl(n,e(`settings.mcp.page.toast.authorizationCompleteFailed`),t))}finally{qe.current===o&&we(!1)}}),ct=Q.useCallback(async()=>{if(!(!n||!rt())){if(!ce){J.error(e(`settings.mcp.page.toast.enableServerBeforeTest`));return}Se(!0);try{let t=await C(n,u),r=t.status?.status;t.warning?J.warning(t.warning):r===`connected`?J.success(e(`settings.mcp.page.toast.connectionTestSucceeded`)):r===`needs_auth`?J.message(e(`settings.mcp.page.toast.connectionNeedsAuthorization`)):r===`needs_client_registration`?J.message(e(`settings.mcp.page.toast.connectionNeedsClientRegistration`)):r===`failed`?J.error(t.status?.error||t.error||e(`settings.mcp.page.toast.connectionTestFailed`)):t.error?J.error(t.error):J.message(e(`settings.mcp.page.toast.connectionTestFinished`))}catch(t){J.error(t instanceof Error?t.message:e(`settings.mcp.page.toast.connectionTestFailed`))}finally{Se(!1)}}},[ce,u,rt,n,e,C]);if(Q.useEffect(()=>{if(!Me||!n)return;let t=!1,r=null,i=()=>{Ne(!1),Pe.current=0},a=async()=>{try{let o=await b(n,u);if(t)return;if(Pe.current+=1,o.status===`complete`){i(),Ee(null),je(``),J.success(e(`settings.mcp.page.toast.authorizationCompleted`)),Ri(Oe,u,d).catch(()=>void 0);return}if(o.status===`failed`||o.status===`expired`){i(),J.error(o.status===`failed`?o.message:e(`settings.mcp.page.toast.authSessionExpired`));return}if(Pe.current>=300){i(),J.message(e(`settings.mcp.page.toast.authorizationStillInProgress`));return}r=window.setTimeout(()=>void a(),2e3)}catch{if(t)return;if(Pe.current+=1,Pe.current>=300){i(),J.message(e(`settings.mcp.page.toast.authorizationStillInProgress`));return}r=window.setTimeout(()=>void a(),2e3)}};return r=window.setTimeout(()=>void a(),2e3),()=>{t=!0,r!==null&&window.clearTimeout(r)}},[b,Me,u,n,e,d]),f.isError&&!f.data)return(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6`,children:(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)] text-center`,children:f.error.message})});if(!n)return(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,$.jsxs)(`div`,{className:`text-center text-muted-foreground`,children:[(0,$.jsx)(X,{name:`plug`,className:`mx-auto mb-3 h-12 w-12 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.mcp.page.empty.selectServer`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:e(`settings.mcp.page.empty.addNewOne`)})]})});let lt=h[n],ut=n?g[n]:void 0,dt=lt??ut??(p.isError&&!p.data?{status:`failed`,error:p.error.message}:void 0),ft=lt?.status===`connected`,pt=lt?.status===`needs_auth`||lt?.status===`needs_client_registration`,mt=il(dt?.status,t,dt&&`error`in dt?dt.error:void 0),ht=t=>{switch(t){case`connected`:return e(`settings.mcp.page.status.label.connected`);case`failed`:return e(`settings.mcp.page.status.label.failed`);case`needs_auth`:return e(`settings.mcp.page.status.label.needsAuth`);case`needs_client_registration`:return e(`settings.mcp.page.status.label.needsRegistration`);default:return t}};return(0,$.jsxs)(Ur,{outerClassName:`h-full`,className:`w-full`,children:[(0,$.jsxs)(`div`,{className:`yuri-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsx)(Gi,{actions:(0,$.jsxs)($.Fragment,{children:[T?null:(0,$.jsx)(q,{variant:`ghost`,size:`icon`,onClick:()=>fe(!0),disabled:ue,"aria-label":e(`settings.common.actions.delete`),title:e(`settings.common.actions.delete`),className:`text-[var(--status-error)]`,children:(0,$.jsx)(X,{name:`delete-bin`,className:`size-4`})}),(0,$.jsx)(q,{onClick:et,disabled:ue||!$e&&!T,size:`sm`,"aria-busy":ue,children:e(ue?`settings.common.actions.saving`:T?`settings.common.actions.create`:`settings.common.actions.saveChanges`)})]}),children:(0,$.jsxs)(`div`,{className:`min-w-0`,children:[T?(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:e(`settings.mcp.page.header.newServer`)}):(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:n}),(0,$.jsx)(rl,{status:dt?.status,enabled:ce,getStatusLabel:ht,variant:`pill`})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 mt-0.5`,children:[(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground truncate`,children:T?e(`settings.mcp.page.header.configureNewServer`):e(`settings.mcp.page.header.transport`,{type:e(A===`local`?`settings.mcp.page.transport.local`:`settings.mcp.page.transport.remote`)})}),!T&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(q,{variant:ft?`outline`:`default`,size:`xs`,className:`!font-normal`,onClick:nt,disabled:he||!ce,children:e(he?`settings.mcp.page.actions.working`:ft?`settings.mcp.page.actions.disconnect`:`settings.mcp.page.actions.connect`)}),A===`remote`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(q,{variant:pt?`default`:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>void it(),disabled:_e||!ce,children:e(_e?`settings.mcp.page.actions.starting`:pt?`settings.mcp.page.actions.authorize`:`settings.mcp.page.actions.reauthorize`)}),(0,$.jsx)(q,{variant:`ghost`,size:`xs`,className:`!font-normal gap-1 text-muted-foreground`,onClick:()=>void at(),disabled:ye||!ce,children:e(ye?`settings.mcp.page.actions.clearing`:`settings.mcp.page.actions.clearAuth`)})]}),ft&&(0,$.jsx)(q,{variant:`ghost`,size:`xs`,className:`!font-normal gap-1 text-muted-foreground`,onClick:()=>void ct(),disabled:xe||!ce,children:e(xe?`settings.mcp.page.actions.testing`:`settings.mcp.page.actions.test`)})]})]})]})}),!T&&ol(dt?.status,Te,pt,Me)&&(0,$.jsx)(`div`,{className:`px-2`,children:(0,$.jsxs)(`div`,{className:K(`rounded-lg border p-3`,al(dt?.status)),children:[(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.mcp.page.status.runtimeStatus`)}),(0,$.jsx)(rl,{status:dt?.status,enabled:ce,getStatusLabel:ht})]}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:mt}),(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground/80`,children:O===`project`?e(`settings.mcp.page.status.projectScopedTo`,{directory:u??e(`settings.mcp.page.status.activeProject`)}):e(`settings.mcp.page.status.userScoped`)})]}),(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:!ft&&(0,$.jsx)(q,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>void ct(),disabled:xe||!ce,children:e(xe?`settings.mcp.page.actions.testing`:`settings.mcp.page.actions.testConnection`)})}),Te&&(0,$.jsx)(`div`,{className:`rounded-md border border-[var(--interactive-border)] bg-[var(--surface-background)] px-3 py-2`,children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground`,children:e(`settings.mcp.page.auth.authorizationUrl`)}),(0,$.jsx)(`div`,{className:`break-all typography-micro text-foreground font-mono`,children:Te}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsxs)(q,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>void Br(Te),children:[(0,$.jsx)(X,{name:`external-link`,className:`h-3.5 w-3.5`}),e(`settings.mcp.page.actions.openInBrowser`)]}),(0,$.jsxs)(q,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>void ot(),children:[(0,$.jsx)(X,{name:`clipboard`,className:`h-3.5 w-3.5`}),e(`settings.mcp.page.actions.copyLink`)]})]})]})}),A===`remote`&&De===`code`&&Te&&(0,$.jsx)(`div`,{className:`rounded-md border border-[var(--interactive-border)] bg-[var(--surface-background)] px-3 py-3`,children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:e(`settings.mcp.page.auth.manualFallbackTitle`)}),(0,$.jsx)(`p`,{className:`mt-1 typography-micro text-muted-foreground`,children:e(`settings.mcp.page.auth.manualFallbackDescription`)})]}),(0,$.jsx)(Wr,{embedded:!0,value:Ae,onChange:e=>je(e.target.value),placeholder:e(`settings.mcp.page.auth.callbackInputPlaceholder`),rows:3,className:`font-mono typography-meta resize-y`,"data-bwignore":`true`,"data-1p-ignore":`true`,spellCheck:!1}),(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:(0,$.jsx)(q,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>void st(),disabled:Ce,children:e(Ce?`settings.mcp.page.actions.completing`:`settings.mcp.page.actions.completeAuthorization`)})})]})})]}),Me&&(0,$.jsx)(`p`,{className:`mt-4 typography-micro text-muted-foreground`,children:e(`settings.mcp.page.auth.waitingForOpenCode`)})]})}),(0,$.jsx)(`div`,{"data-settings-item":`mcp.server`,children:(0,$.jsx)(Z,{label:e(`settings.mcp.page.server.title`),cardClassName:`p-3`,children:(0,$.jsxs)(`div`,{className:`space-y-3`,children:[T&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-8`,children:[(0,$.jsx)(`div`,{className:`flex min-w-0 flex-col sm:w-56 shrink-0`,children:(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.mcp.page.server.name`)})}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2 sm:w-fit sm:flex-initial`,children:[(0,$.jsx)(Cn,{value:E,onChange:e=>D(e.target.value.toLowerCase().replace(/[^a-z0-9_-]/g,`-`)),placeholder:e(`settings.mcp.page.server.namePlaceholder`),className:`h-7 w-48 font-mono px-2`,autoFocus:!0}),(0,$.jsxs)(Fr,{value:O,onValueChange:e=>k(e),children:[(0,$.jsx)(Pr,{className:`!h-7 !w-7 !min-w-0 !px-0 !py-0 justify-center [&>svg:last-child]:hidden`,title:e(O===`user`?`settings.common.scope.global`:`settings.common.scope.project`),children:O===`user`?(0,$.jsx)(X,{name:`user-3`,className:`h-3.5 w-3.5`}):(0,$.jsx)(X,{name:`folder`,className:`h-3.5 w-3.5`})}),(0,$.jsxs)(Nr,{align:`end`,children:[(0,$.jsx)(jr,{value:`user`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(X,{name:`user-3`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:e(`settings.common.scope.global`)})]})}),(0,$.jsx)(jr,{value:`project`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(X,{name:`folder`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:e(`settings.common.scope.project`)})]})})]})]})]})]}),T&&(0,$.jsx)(`div`,{children:(0,$.jsxs)(q,{variant:`outline`,size:`xs`,className:`!font-normal gap-1.5`,onClick:Xe,type:`button`,title:e(`settings.mcp.page.server.importJsonTitle`),children:[(0,$.jsx)(X,{name:`file-code`,className:`h-3.5 w-3.5`}),e(`settings.mcp.page.server.importJson`)]})}),(0,$.jsx)(Ji,{checked:ce,onChange:le,label:e(`settings.mcp.page.server.enable`),ariaLabel:e(`settings.mcp.page.server.enableAria`)}),(0,$.jsx)(`div`,{className:`flex min-w-0 items-center justify-between gap-2`,children:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.mcp.page.server.transportMode`)}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-1`,children:[(0,$.jsx)(q,{variant:`chip`,size:`xs`,"aria-pressed":A===`local`,onClick:()=>j(`local`),className:`!font-normal`,children:e(`settings.mcp.page.transport.local`)}),(0,$.jsx)(q,{variant:`chip`,size:`xs`,"aria-pressed":A===`remote`,onClick:()=>j(`remote`),className:`!font-normal`,children:e(`settings.mcp.page.transport.remote`)})]})]})})]})})}),(0,$.jsx)(`div`,{"data-settings-item":`mcp.command`,children:A===`local`?(0,$.jsx)(Z,{label:e(`settings.mcp.page.connection.command`),cardClassName:`p-3`,children:(0,$.jsx)(el,{value:M,onChange:N,pasteCommandTitle:e(`settings.mcp.page.connection.pasteCommandTitle`),pasteCommandLabel:e(`settings.mcp.page.connection.pasteCommand`),pasteSuccess:t=>e(`settings.mcp.page.toast.pastedArgumentsCount`,{count:t}),clipboardReadFailed:e(`settings.mcp.page.toast.clipboardReadFailed`),preview:t=>e(`settings.mcp.page.connection.previewArgs`,{count:t})})}):(0,$.jsx)(Z,{children:(0,$.jsx)(Xi,{label:e(`settings.mcp.page.connection.serverUrl`),children:(0,$.jsx)(Cn,{value:P,onChange:e=>F(e.target.value),placeholder:e(`settings.mcp.page.connection.serverUrlPlaceholder`),className:`font-mono typography-meta`})})})}),A===`remote`&&(0,$.jsx)(`div`,{"data-settings-item":`mcp.advanced`,children:(0,$.jsx)(Z,{label:e(`settings.mcp.page.advanced.title`),cardClassName:`p-3`,children:(0,$.jsxs)(ca,{open:Fe,onOpenChange:Ie,children:[(0,$.jsxs)(sa,{className:`flex w-full items-center justify-between py-0.5 group`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-left`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label font-normal text-foreground`,children:e(`settings.mcp.page.advanced.configure`)}),(0,$.jsxs)(`span`,{className:`typography-micro text-muted-foreground`,children:[`(`,e(B?`settings.mcp.page.advanced.autoDetect`:`settings.mcp.page.advanced.custom`),` · `,R.length,` `,e(`settings.mcp.page.advanced.headers`),oe?` · ${oe}ms`:``,`)`]})]}),Fe?(0,$.jsx)(X,{name:`arrow-down-s`,className:`h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors`}):(0,$.jsx)(X,{name:`arrow-right-s`,className:`h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors`})]}),(0,$.jsx)(oa,{className:`pt-2`,children:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(Xi,{label:e(`settings.mcp.page.advanced.timeoutMs`),description:e(`settings.mcp.page.advanced.timeoutHint`),children:(0,$.jsx)(Cn,{type:`number`,min:`1`,step:`1`,value:oe,onChange:e=>se(e.target.value),placeholder:`5000`,className:`w-32 font-mono`,"data-bwignore":`true`,"data-1p-ignore":`true`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`mb-2 typography-ui-label text-foreground`,children:[e(`settings.mcp.page.advanced.requestHeaders`),R.length>0&&(0,$.jsxs)(`span`,{className:`ml-1.5 typography-micro text-muted-foreground font-normal`,children:[`(`,R.length,`)`]})]}),(0,$.jsx)(nl,{value:R,onChange:z,keyTransform:e=>e.trimStart(),keyPlaceholder:e(`settings.mcp.page.advanced.headerNamePlaceholder`),keyInputClassName:`w-36 shrink-0 font-mono typography-meta`,pasteLabel:e(`settings.mcp.page.advanced.pasteHeaders`),pasteTitle:e(`settings.mcp.page.advanced.pasteHeadersTitle`),noPairsFoundError:e(`settings.mcp.page.toast.noKeyValuePairsFound`),importSuccess:t=>e(`settings.mcp.page.toast.importedVariablesCount`,{count:t}),clipboardReadFailed:e(`settings.mcp.page.toast.clipboardReadFailed`),keyLabel:e(`settings.mcp.page.env.key`),valueLabel:e(`settings.mcp.page.env.value`),valuePlaceholder:e(`settings.mcp.page.env.valuePlaceholder`),hideValueTitle:e(`settings.mcp.page.env.hide`),showValueTitle:e(`settings.mcp.page.env.show`),addVariable:e(`settings.mcp.page.env.addVariable`),plainTextWarning:e(`settings.mcp.page.env.plainTextWarning`),removeVariableAria:e(`settings.mcp.page.env.removeVariableAria`)})]}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(Ji,{checked:B,onChange:V,label:e(`settings.mcp.page.advanced.oauthAutoDetection`),ariaLabel:e(`settings.mcp.page.advanced.oauthAutoDetectionAria`)}),(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsx)(Cn,{value:H,onChange:e=>U(e.target.value),placeholder:e(`settings.mcp.page.advanced.oauthClientIdPlaceholder`),className:`font-mono typography-meta`,disabled:!B,"data-bwignore":`true`,"data-1p-ignore":`true`}),(0,$.jsx)(Cn,{value:W,onChange:e=>ee(e.target.value),placeholder:e(`settings.mcp.page.advanced.oauthClientSecretPlaceholder`),className:`font-mono typography-meta`,disabled:!B,"data-bwignore":`true`,"data-1p-ignore":`true`}),(0,$.jsx)(Cn,{value:te,onChange:e=>re(e.target.value),placeholder:e(`settings.mcp.page.advanced.oauthScopesPlaceholder`),className:`font-mono typography-meta`,disabled:!B,"data-bwignore":`true`,"data-1p-ignore":`true`}),(0,$.jsx)(Cn,{value:ie,onChange:e=>ae(e.target.value),placeholder:e(`settings.mcp.page.advanced.oauthRedirectUriPlaceholder`),className:`font-mono typography-meta`,disabled:!B,"data-bwignore":`true`,"data-1p-ignore":`true`})]}),(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground`,children:e(`settings.mcp.page.advanced.oauthHint`)})]})]})})]})})}),(0,$.jsx)(`div`,{"data-settings-item":`mcp.environment`,children:(0,$.jsx)(Z,{label:(0,$.jsxs)(`span`,{children:[e(`settings.mcp.page.env.title`),I.length>0&&(0,$.jsxs)(`span`,{className:`ml-1.5 typography-micro text-muted-foreground font-normal`,children:[`(`,I.length,`)`]})]}),cardClassName:`p-3`,children:I.length===0?(0,$.jsxs)(q,{variant:`outline`,size:`xs`,className:`!font-normal gap-1.5`,onClick:()=>L([{key:``,value:``}]),children:[(0,$.jsx)(X,{name:`add`,className:`h-3.5 w-3.5`}),e(`settings.mcp.page.env.addEnvironmentVariable`)]}):(0,$.jsx)(nl,{value:I,onChange:L,keyPlaceholder:e(`settings.mcp.page.env.keyPlaceholder`),pasteLabel:e(`settings.mcp.page.env.pasteEnv`),pasteTitle:e(`settings.mcp.page.env.pasteEnvTitle`),noPairsFoundError:e(`settings.mcp.page.toast.noKeyValuePairsFound`),importSuccess:t=>e(`settings.mcp.page.toast.importedVariablesCount`,{count:t}),clipboardReadFailed:e(`settings.mcp.page.toast.clipboardReadFailed`),keyLabel:e(`settings.mcp.page.env.key`),valueLabel:e(`settings.mcp.page.env.value`),valuePlaceholder:e(`settings.mcp.page.env.valuePlaceholder`),hideValueTitle:e(`settings.mcp.page.env.hide`),showValueTitle:e(`settings.mcp.page.env.show`),addVariable:e(`settings.mcp.page.env.addVariable`),plainTextWarning:e(`settings.mcp.page.env.plainTextWarning`),removeVariableAria:e(`settings.mcp.page.env.removeVariableAria`)})})})]}),(0,$.jsx)(gn,{open:Le,onOpenChange:e=>{e||(Re(!1),Be(``),Ue(null))},children:(0,$.jsxs)(pn,{className:`max-w-md`,children:[(0,$.jsxs)(dn,{children:[(0,$.jsx)(mn,{children:e(`settings.mcp.page.importDialog.title`)}),(0,$.jsx)(hn,{children:e(`settings.mcp.page.importDialog.description`)})]}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(Wr,{value:ze,onChange:e=>{Be(e.target.value),Ue(null)},placeholder:`{
15
15
  "mcpServers": {
16
16
  "postgres": {
17
17
  "command": "npx",
18
18
  "args": ["-y", "@modelcontextprotocol/server-postgres"]
19
19
  }
20
20
  }
21
- }`,rows:8,className:`font-mono typography-meta resize-y`,spellCheck:!1,"data-bwignore":`true`,"data-1p-ignore":`true`}),Ve&&(0,$.jsx)(`p`,{className:`typography-micro text-[var(--status-error)]`,children:Ve}),(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:(0,$.jsxs)(q,{variant:`outline`,size:`xs`,className:`!font-normal gap-1`,onClick:Ze,type:`button`,children:[(0,$.jsx)(X,{name:`clipboard`,className:`h-3.5 w-3.5`}),e(`settings.mcp.page.importDialog.pasteFromClipboard`)]})})]}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(q,{variant:`outline`,onClick:()=>{Re(!1),Be(``),Ue(null)},className:`text-foreground`,children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(q,{onClick:Qe,disabled:!ze.trim(),size:`sm`,children:e(`settings.common.actions.import`)})]})]})}),(0,$.jsx)(gn,{open:G,onOpenChange:e=>{!e&&!pe&&fe(!1)},children:(0,$.jsxs)(pn,{className:`max-w-md`,children:[(0,$.jsxs)(dn,{children:[(0,$.jsx)(mn,{children:e(`settings.mcp.page.deleteDialog.title`,{name:n??``})}),(0,$.jsxs)(hn,{children:[e(`settings.mcp.page.deleteDialog.descriptionPrefix`),` `,(0,$.jsx)(`code`,{className:`text-foreground`,children:`opencode.json`}),`.`,` `,e(`settings.mcp.page.deleteDialog.descriptionSuffix`)]})]}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(q,{variant:`outline`,onClick:()=>fe(!1),disabled:pe,className:`text-foreground`,children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(q,{variant:`destructive`,size:`sm`,onClick:tt,disabled:pe,children:e(pe?`settings.mcp.page.actions.deleting`:`settings.common.actions.delete`)})]})]})})]})};function ul(e){let t=(0,Sa.c)(51),{value:n,onChange:r,fileName:i,className:a,readOnly:o,hasError:s,id:c,ariaLabel:l,placeholder:u}=e,d=i===void 0?`config.json`:i,f=o!==void 0&&o,p=s!==void 0&&s,{t:m}=Ge(),{currentTheme:h}=un(),g=String(p),_=String(f),v,y,b,x,S,C,w;if(t[0]!==l||t[1]!==h||t[2]!==d||t[3]!==c||t[4]!==f||t[5]!==m||t[6]!==g||t[7]!==_){let e={"aria-invalid":g,"aria-disabled":_,spellcheck:`false`};c&&(e.id=c),l&&(e[`aria-label`]=l);let n;t[15]===d?n=t[16]:(n=li(d),t[15]=d,t[16]=n);let r=n;t[17]===h?x=t[18]:(x=Ai(h,{syntaxColors:!1}),t[17]=h,t[18]=x),t[19]===Symbol.for(`react.memo_cache_sentinel`)?(S=Le(),t[19]=S):S=t[19],t[20]===m?C=t[21]:(C=ze.phrases.of({"Fold line":m(`settings.jsonEditor.fold`),"Unfold line":m(`settings.jsonEditor.unfold`),unfold:m(`settings.jsonEditor.unfold`),"folded code":m(`settings.jsonEditor.foldedCode`)}),t[20]=m,t[21]=C),t[22]===r?w=t[23]:(w=r?[r]:[],t[22]=r,t[23]=w);let i=d.endsWith(`.jsonc`)?`jsonc`:`json`;t[24]!==h||t[25]!==i?(v=Xr({language:i,themeName:h.metadata.id,theme:Rr(h)}),t[24]=h,t[25]=i,t[26]=v):v=t[26],t[27]===f?y=t[28]:(y=ze.readOnly.of(f),t[27]=f,t[28]=y),b=Re.contentAttributes.of(e),t[0]=l,t[1]=h,t[2]=d,t[3]=c,t[4]=f,t[5]=m,t[6]=g,t[7]=_,t[8]=v,t[9]=y,t[10]=b,t[11]=x,t[12]=S,t[13]=C,t[14]=w}else v=t[8],y=t[9],b=t[10],x=t[11],S=t[12],C=t[13],w=t[14];let T;t[29]===u?T=t[30]:(T=u?[Ie(u)]:[],t[29]=u,t[30]=T);let E;t[31]!==v||t[32]!==y||t[33]!==b||t[34]!==T||t[35]!==x||t[36]!==S||t[37]!==C||t[38]!==w?(E=[x,S,C,...w,v,y,b,...T],t[31]=v,t[32]=y,t[33]=b,t[34]=T,t[35]=x,t[36]=S,t[37]=C,t[38]=w,t[39]=E):E=t[39];let D=E,O=p&&`ring-1 ring-inset ring-[var(--status-error)] focus-within:ring-[var(--status-error)]`,k;t[40]!==a||t[41]!==O?(k=K(`h-full min-w-0 overflow-hidden bg-background focus-within:ring-2 focus-within:ring-inset focus-within:ring-[var(--interactive-focus-ring)]`,O,a),t[40]=a,t[41]=O,t[42]=k):k=t[42];let A;t[43]!==D||t[44]!==r||t[45]!==f||t[46]!==n?(A=(0,$.jsx)(Zr,{value:n,onChange:r,readOnly:f,extensions:D,enableSearch:!0}),t[43]=D,t[44]=r,t[45]=f,t[46]=n,t[47]=A):A=t[47];let j;return t[48]!==k||t[49]!==A?(j=(0,$.jsx)(`div`,{className:k,children:A}),t[48]=k,t[49]=A,t[50]=j):j=t[50],j}var dl=/^[a-z0-9][a-z0-9-_.]*\.(js|ts|mjs|cjs)$/;function fl(e){let t=e.trim();if(t===``)return{ok:!0,value:void 0};try{let e=JSON.parse(t);return typeof e!=`object`||!e||Array.isArray(e)?{ok:!1}:{ok:!0,value:e}}catch{return{ok:!1}}}var pl=({open:e,onOpenChange:t,defaultScope:n=`user`})=>{let{t:r}=Ge(),i=$i(e=>e.createEntry),a=$i(e=>e.createFile),[o,s]=Q.useState(`npm`),[c,l]=Q.useState(``),[u,d]=Q.useState(``),[f,p]=Q.useState(``),[m,h]=Q.useState(``),[g,_]=Q.useState(n),[v,y]=Q.useState(!1),b=Q.useCallback(()=>{l(``),d(``),p(``),h(``),_(n)},[n]);Q.useEffect(()=>{e&&(s(`npm`),b())},[e,b]);let x=e=>{e!==o&&(s(e),b())},S=Q.useMemo(()=>fl(u),[u]),C=!S.ok,w=o===`file`&&f.trim()!==``&&!dl.test(f.trim()),T=(o===`npm`||o===`path`)&&c.trim()===``,E=o===`file`&&m.trim()===``,D=o===`file`&&f.trim()===``,O=v||C||o===`npm`&&T||o===`path`&&T||o===`file`&&(D||w||E),k=async()=>{if(!O){y(!0);try{let e;e=o===`file`?await a({fileName:f.trim(),content:m,scope:g}):await i({spec:c.trim(),options:S.ok?S.value:void 0,scope:g}),e.ok?(Y.success(e.message||r(`settings.plugins.toast.created`)),e.reloadFailed&&Y.warning(r(`settings.plugins.toast.reloadFailed`)),t(!1)):Y.error(e.message||r(`settings.plugins.sidebar.toast.deleteFailed`))}finally{y(!1)}}},A=Q.useMemo(()=>[{id:`npm`,label:r(`settings.plugins.dialog.add.tab.npm`)},{id:`path`,label:r(`settings.plugins.dialog.add.tab.path`)},{id:`file`,label:r(`settings.plugins.dialog.add.tab.file`)}],[r]);return(0,$.jsx)(gn,{open:e,onOpenChange:e=>{!e&&v||t(e)},children:(0,$.jsxs)(pn,{className:`max-w-xl`,children:[(0,$.jsxs)(dn,{children:[(0,$.jsx)(mn,{children:r(`settings.plugins.dialog.add.title`)}),(0,$.jsx)(hn,{children:r(`settings.plugins.sidebar.empty.description`)})]}),(0,$.jsx)(Jr,{items:A,activeId:o,onSelect:e=>x(e),layoutMode:`fit`,variant:`active-pill`,activePillLowercase:!1,className:`h-10`}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(o===`npm`||o===`path`)&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{"data-settings-item":`plugins.spec`,className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`plugin-spec`,className:`typography-ui-label text-foreground`,children:r(`settings.plugins.page.field.spec`)}),(0,$.jsx)(Cn,{id:`plugin-spec`,value:c,onChange:e=>l(e.target.value),placeholder:r(`settings.plugins.page.field.spec.placeholder`),"aria-invalid":!T&&void 0,disabled:v}),T&&(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:r(`settings.plugins.validation.specRequired`)})]}),(0,$.jsxs)(`div`,{"data-settings-item":`plugins.options`,className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`plugin-options`,className:`typography-ui-label text-foreground`,children:r(`settings.plugins.page.field.options`)}),(0,$.jsx)(ul,{id:`plugin-options`,value:u,onChange:d,className:`h-44 rounded-[var(--radius-xl)] ring-1 ring-inset ring-border/60`,ariaLabel:r(`settings.plugins.page.field.options`),placeholder:r(`settings.plugins.page.field.options.placeholder`),hasError:C,readOnly:v}),C&&(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:r(`settings.plugins.page.field.options.invalidJson`)})]})]}),o===`file`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{"data-settings-item":`plugins.content`,className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`plugin-filename`,className:`typography-ui-label text-foreground`,children:r(`settings.plugins.page.field.fileName`)}),(0,$.jsx)(Cn,{id:`plugin-filename`,value:f,onChange:e=>p(e.target.value),placeholder:`my-plugin.ts`,"aria-invalid":w||void 0,disabled:v}),w&&(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:r(`settings.plugins.validation.fileName`)})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`plugin-content`,className:`typography-ui-label text-foreground`,children:r(`settings.plugins.page.field.content`)}),(0,$.jsx)(Wr,{id:`plugin-content`,value:m,onChange:e=>h(e.target.value),rows:16,className:`font-mono`,disabled:v})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:r(`settings.plugins.page.field.scope`)}),(0,$.jsx)(`div`,{className:`flex items-center gap-4`,children:[`user`,`project`].map(e=>{let t=g===e,n=r(e===`user`?`settings.plugins.scope.user`:`settings.plugins.scope.project`);return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>_(e),disabled:v,className:`flex items-center gap-2 py-1 text-left disabled:opacity-50`,children:[(0,$.jsx)(pa,{checked:t,onChange:()=>_(e),ariaLabel:n}),(0,$.jsx)(`span`,{className:K(`typography-ui-label font-normal`,t?`text-foreground`:`text-foreground/60`),children:n})]},e)})})]})]}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(q,{size:`sm`,variant:`ghost`,onClick:()=>t(!1),disabled:v,children:r(`settings.plugins.dialog.add.action.cancel`)}),(0,$.jsxs)(q,{size:`sm`,onClick:()=>{k()},disabled:O,children:[v?(0,$.jsx)(X,{name:`loader-4`,className:`h-3.5 w-3.5 animate-spin`}):null,r(`settings.plugins.dialog.add.action.submit`)]})]})]})})},ml=e=>{let t=(0,Sa.c)(31),{info:n}=e,{t:r}=Ge();if(!n)return null;let i=hl;switch(n.kind){case`npm-ok`:{if(!n.hasUpdate||!n.latestVersion)return null;let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(X,{name:`arrow-up-s`,className:`h-3 w-3`}),t[0]=e):e=t[0];let a;t[1]===n.latestVersion?a=t[2]:(a=(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-[var(--status-success)]`,children:[e,n.latestVersion]}),t[1]=n.latestVersion,t[2]=a);let o;return t[3]!==n.currentVersion||t[4]!==n.latestVersion||t[5]!==r||t[6]!==a?(o=i(a,r(`settings.plugins.registry.badge.update.tooltip`,{current:n.currentVersion??``,latest:n.latestVersion})),t[3]=n.currentVersion,t[4]=n.latestVersion,t[5]=r,t[6]=a,t[7]=o):o=t[7],o}case`npm-missing-version`:{let e;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(X,{name:`error-warning`,className:`h-3 w-3 text-[var(--status-warning)]`}),t[8]=e):e=t[8];let a;return t[9]!==n.currentVersion||t[10]!==n.name||t[11]!==r?(a=i(e,r(`settings.plugins.registry.badge.missingVersion.tooltip`,{version:n.currentVersion,name:n.name})),t[9]=n.currentVersion,t[10]=n.name,t[11]=r,t[12]=a):a=t[12],a}case`npm-missing-package`:{let e;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(X,{name:`error-warning`,className:`h-3 w-3 text-[var(--status-error)]`}),t[13]=e):e=t[13];let a;return t[14]!==n.name||t[15]!==r?(a=i(e,r(`settings.plugins.registry.badge.missingPackage.tooltip`,{name:n.name})),t[14]=n.name,t[15]=r,t[16]=a):a=t[16],a}case`npm-malformed`:{let e;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(X,{name:`error-warning`,className:`h-3 w-3 text-[var(--status-error)]`}),t[17]=e):e=t[17];let n;return t[18]===r?n=t[19]:(n=i(e,r(`settings.plugins.registry.badge.malformed.tooltip`)),t[18]=r,t[19]=n),n}case`npm-network`:{let e;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(X,{name:`cloud-off`,className:`h-3 w-3 text-muted-foreground`}),t[20]=e):e=t[20];let n;return t[21]===r?n=t[22]:(n=i(e,r(`settings.plugins.registry.badge.network.tooltip`)),t[21]=r,t[22]=n),n}case`path-missing`:{let e;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(X,{name:`error-warning`,className:`h-3 w-3 text-[var(--status-error)]`}),t[23]=e):e=t[23];let a;return t[24]!==n.absolutePath||t[25]!==r?(a=i(e,r(`settings.plugins.registry.badge.pathMissing.tooltip`,{path:n.absolutePath})),t[24]=n.absolutePath,t[25]=r,t[26]=a):a=t[26],a}case`path-unreadable`:{let e;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(X,{name:`error-warning`,className:`h-3 w-3 text-[var(--status-warning)]`}),t[27]=e):e=t[27];let a;return t[28]!==n.absolutePath||t[29]!==r?(a=i(e,r(`settings.plugins.registry.badge.pathUnreadable.tooltip`,{path:n.absolutePath})),t[28]=n.absolutePath,t[29]=r,t[30]=a):a=t[30],a}case`path-ok`:return null;default:return null}};function hl(e,t){return(0,$.jsxs)(En,{children:[(0,$.jsx)(wn,{asChild:!0,children:(0,$.jsx)(`span`,{className:`inline-flex shrink-0 items-center gap-0.5 text-xs`,children:e})}),(0,$.jsx)(Tn,{children:t})]})}function gl(e,t){return e?t.filter(({source:t})=>{if(e.kind===`package`)return t?.type===`package`&&t.target===e.target;if(t?.type!==`local`)return!1;let n=oi(t.path,void 0);return n?.kind===`local`&&(n.path===e.path||n.path.startsWith(`${e.path}/`))}):[]}var _l=[`plugins`,`package-update`],vl=e=>[i(),`plugins`,`reload`,e??``],yl=(e,t,n,r,i)=>!!(e&&e.directory===t&&e.transport===r&&(e.target===n||e.entry?.spec===n||i&&e.entry?.id===i));function bl(e,t){let n=(0,Sa.c)(2),r=Vi(),a=i(),o;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(o={filters:{mutationKey:_l},select:Sl},n[0]=o):o=n[0];let s=Ce(o);if(!e&&!t)return{kind:`idle`};let c=s.filter(n=>yl(n.variables,r,e,a,t)).reduce(xl,null);if(!c)return{kind:`idle`};if(c.status===`pending`)return{kind:`pending`,entry:c.variables?.entry};if(c.status===`error`)return{kind:`error`,error:qi(c.error),entry:c.variables?.entry};let l;return n[1]===Symbol.for(`react.memo_cache_sentinel`)?(l={kind:`idle`},n[1]=l):l=n[1],l}function xl(e,t){return!e||t.submittedAt>=e.submittedAt?t:e}function Sl(e){return{variables:e.state.variables,status:e.state.status,error:e.state.error,submittedAt:e.state.submittedAt}}function Cl(){let e=(0,Sa.c)(5),t=Vi(),n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=i(),e[0]=n):n=e[0];let r=n,a;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(a={filters:{mutationKey:_l,status:`pending`},select:wl},e[1]=a):a=e[1];let o=Ce(a),s;if(e[2]!==t||e[3]!==o){s=new Set;for(let e of o)e&&e.directory===t&&e.transport===r&&(s.add(e.target),e.entry&&s.add(e.entry.spec));e[2]=t,e[3]=o,e[4]=s}else s=e[4];return s}function wl(e){return e.state.variables}function Tl(){let e=(0,Sa.c)(15),{t}=Ge(),n=we(),r=Vi(),a;e[0]===n?a=e[1]:(a=async e=>{let{target:t,directory:r,transport:a,entry:o}=e;if(i()!==a)throw Error(`Plugin runtime changed`);if(o){if(jt()!==r)throw Error(`Plugin directory changed`);let e=await $i.getState().updateEntry(o.id,{spec:o.spec});if(!e.ok||e.reloadFailed)throw Error(e.warning||e.message||`Plugin update failed`)}else await ea(r,t);await Ki(n,r,a).catch(Dl)},e[0]=n,e[1]=a);let o;e[2]!==n||e[3]!==t?(o=(e,r)=>{let{name:a,directory:o,transport:s}=r;i()===s&&(Y.success(t(`settings.plugins.update.toast.done`,{name:a})),n.invalidateQueries({queryKey:[s,`plugins`,`registry`,o]}))},e[2]=n,e[3]=t,e[4]=o):o=e[4];let s;e[5]===t?s=e[6]:(s=(e,n)=>{let{name:r,transport:a}=n;i()===a&&Y.error(t(`settings.plugins.update.toast.failed`,{name:r}))},e[5]=t,e[6]=s);let c;e[7]!==a||e[8]!==o||e[9]!==s?(c={mutationKey:_l,mutationFn:a,onSuccess:o,onError:s},e[7]=a,e[8]=o,e[9]=s,e[10]=c):c=e[10];let l=Te(c),u;return e[11]!==n||e[12]!==r||e[13]!==l?(u=(e,t,a)=>{let o=i();if(n.getMutationCache().findAll({mutationKey:_l,status:`pending`}).some(t=>yl(t.state.variables,r,e,o,a?.id)))return;let s=a?n.getQueryData(Zi(r,o).queryKey)?.entries.find(e=>e.id===a.id):void 0;return l.mutateAsync({target:e,name:t,directory:r,transport:o,entry:a?{...a,original:s}:void 0}).catch(El)},e[11]=n,e[12]=r,e[13]=l,e[14]=u):u=e[14],He(u)}function El(){}function Dl(){}function Ol(){let e=(0,Sa.c)(13),{t}=Ge(),n=we(),r=Vi(),a;e[0]===r?a=e[1]:(a=vl(r),e[0]=r,e[1]=a);let o;e[2]!==n||e[3]!==r?(o=async()=>{let e=i();await pt(),await Ki(n,r,e)},e[2]=n,e[3]=r,e[4]=o):o=e[4];let s,c;e[5]===t?(s=e[6],c=e[7]):(s=()=>{Y.success(t(`settings.plugins.page.toast.reloaded`))},c=e=>{Y.error(e.message||t(`settings.plugins.toast.reloadFailed`))},e[5]=t,e[6]=s,e[7]=c);let l;return e[8]!==a||e[9]!==o||e[10]!==s||e[11]!==c?(l={mutationKey:a,mutationFn:o,onSuccess:s,onError:c},e[8]=a,e[9]=o,e[10]=s,e[11]=c,e[12]=l):l=e[12],Te(l)}function kl(){let e=(0,Sa.c)(4),t=Vi(),n;e[0]===t?n=e[1]:(n=vl(t),e[0]=t,e[1]=n);let r;return e[2]===n?r=e[3]:(r={filters:{mutationKey:n,status:`pending`},select:Al},e[2]=n,e[3]=r),Ce(r).length>0}function Al(){return!0}var jl=e=>{let t=(0,Sa.c)(10),{children:n,className:r,outerClassName:i}=e,a;t[0]===i?a=t[1]:(a=K(`h-full`,i),t[0]=i,t[1]=a);let o;t[2]===r?o=t[3]:(o=K(`yuri-settings-page-content mx-auto max-w-3xl p-3 sm:p-6 sm:pt-8`,r),t[2]=r,t[3]=o);let s;t[4]!==n||t[5]!==o?(s=(0,$.jsx)(`div`,{className:o,children:n}),t[4]=n,t[5]=o,t[6]=s):s=t[6];let c;return t[7]!==a||t[8]!==s?(c=(0,$.jsx)(Ur,{outerClassName:a,className:`w-full`,children:s}),t[7]=a,t[8]=s,t[9]=c):c=t[9],c},Ml=[`62%`,`78%`,`54%`,`70%`,`48%`],Nl=e=>{let t=(0,Sa.c)(3),{className:n,style:r}=e,i=`rounded bg-muted-foreground/10 ${n??``}`,a;return t[0]!==r||t[1]!==i?(a=(0,$.jsx)(Yr,{className:i,style:r}),t[0]=r,t[1]=i,t[2]=a):a=t[2],a},Pl=()=>{let e=(0,Sa.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{role:`status`,"aria-busy":`true`,"data-plugin-skeleton":`list`,children:Ml.map(Il)}),e[0]=t):t=e[0],t},Fl=()=>{let e=(0,Sa.c)(4),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(Nl,{className:`size-7 shrink-0 rounded-md`}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5 py-3`,children:[t,(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(Nl,{className:`h-2.5 w-44`}),(0,$.jsx)(Nl,{className:`h-2 w-12`})]})]}),e[1]=n):n=e[1];let r;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[(0,$.jsx)(Nl,{className:`h-2 w-14`}),(0,$.jsx)(Nl,{className:`h-9 w-full rounded-md`})]}),e[2]=r):r=e[2];let i;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(jl,{className:`yuri-plugin-detail sm:pt-6`,children:(0,$.jsxs)(`div`,{role:`status`,"aria-busy":`true`,"data-plugin-skeleton":`detail`,children:[n,r,(0,$.jsxs)(`div`,{className:`mt-5 space-y-2`,children:[(0,$.jsx)(Nl,{className:`h-2 w-16`}),(0,$.jsx)(Nl,{className:`h-20 w-full rounded-md`})]})]})}),e[3]=i):i=e[3],i};function Il(e,t){return(0,$.jsxs)(`div`,{className:`flex h-[37px] items-center gap-2 px-3`,"data-plugin-skeleton-row":!0,children:[(0,$.jsx)(Nl,{className:`size-5 shrink-0 rounded-[4px]`}),(0,$.jsx)(Nl,{className:`h-2`,style:{width:e}})]},t)}var Ll=({onItemSelect:e,onAddClick:t})=>{let{t:n}=Ge(),r=Hr(),{selectedId:a,setSelected:o,loadPlugins:s}=$i(ne(e=>({selectedId:e.selectedId,setSelected:e.setSelected,loadPlugins:e.loadPlugins}))),c=Hi(),l=Q.useMemo(()=>c.data?.entries??[],[c.data?.entries]),u=Q.useMemo(()=>c.data?.files??[],[c.data?.files]),d=Q.useMemo(()=>l.map(e=>e.spec),[l]),{data:f,isFetching:p}=Yi(d,!1),m=Q.useMemo(()=>f??{},[f]),h=Qi(),g=h.isError&&h.data===void 0,_=Tl(),[v,y]=Q.useState(!1),b=Q.useRef(!1),x=Cl(),S=kl(),C=c.isPending&&c.data===void 0,[w,T]=Q.useState(!1);Q.useEffect(()=>{s()},[s]),Q.useEffect(()=>{let e=()=>T(!0);return window.addEventListener(`yuri:settings-open-plugin-add`,e),()=>window.removeEventListener(`yuri:settings-open-plugin-add`,e)},[]);let E=Q.useMemo(()=>{let e=h.data,t=new Map;if(!e)return t;for(let n of l){let r=oi(n.spec,n.sourcePath);r?.kind===`package`&&(x.has(r.target)||Ni(Qr(r,e))===`available`&&t.set(n.id,r.target))}return t},[l,x,h.data]),D=Q.useMemo(()=>[...l.filter(e=>e.scope===`user`),...l.filter(e=>e.scope===`project`)],[l]),O=Q.useMemo(()=>[...u.filter(e=>e.scope===`user`),...u.filter(e=>e.scope===`project`)],[u]);Q.useEffect(()=>{a&&document.querySelector(`[data-row-id="${CSS.escape(a)}"]`)?.scrollIntoView({block:`nearest`})},[a,l.length,u.length]);let k=l.length+u.length,A=k===0,j=Q.useCallback(()=>{t?t():T(!0)},[t]),M=Q.useCallback(t=>{o(t),e?.()},[e,o]),N=l.flatMap(e=>{let t=oi(e.spec,e.sourcePath);if(t?.kind!==`package`||x.has(t.target))return[];let n=m[e.spec],r=n?.kind===`npm-ok`&&n.hasUpdate&&n.latestVersion?n:null;return!r&&!E.has(e.id)?[]:[{target:t.target,name:ha(e.spec,!0).name,entry:r?{id:e.id,spec:`${r.name}@${r.latestVersion}`}:void 0}]}),P=He(async()=>{if(S||b.current||x.size>0)return;let e=i(),t=jt();b.current=!0,y(!0);try{let n=new Set;for(let r of N){if(i()!==e||jt()!==t)break;!r.entry&&n.has(r.target)||(await _(r.target,r.name,r.entry),n.add(r.target))}}finally{b.current=!1,y(!1)}}),F=e=>{let t=m[e.spec],i=ha(e.spec,e.parsedKind===`npm`),o=oi(e.spec,e.sourcePath),s=o&&h.data?Qr(o,h.data):[],c=h.data?si(s):null,l=ri(s),u=o?.kind===`package`&&x.has(o.target)||Ni(s)===`updating`,d=u||S,f=t?.kind===`npm-ok`&&t.hasUpdate&&!!t.latestVersion,p=t?.kind===`npm-ok`?t.latestVersion:null,g=u?p?n(`settings.plugins.update.running.toVersion`,{version:p}):n(`settings.plugins.update.running`):S?n(`settings.plugins.sidebar.reloading`):c?.kind===`failed`?c.error.split(`
21
+ }`,rows:8,className:`font-mono typography-meta resize-y`,spellCheck:!1,"data-bwignore":`true`,"data-1p-ignore":`true`}),Ve&&(0,$.jsx)(`p`,{className:`typography-micro text-[var(--status-error)]`,children:Ve}),(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:(0,$.jsxs)(q,{variant:`outline`,size:`xs`,className:`!font-normal gap-1`,onClick:Ze,type:`button`,children:[(0,$.jsx)(X,{name:`clipboard`,className:`h-3.5 w-3.5`}),e(`settings.mcp.page.importDialog.pasteFromClipboard`)]})})]}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(q,{variant:`outline`,onClick:()=>{Re(!1),Be(``),Ue(null)},className:`text-foreground`,children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(q,{onClick:Qe,disabled:!ze.trim(),size:`sm`,children:e(`settings.common.actions.import`)})]})]})}),(0,$.jsx)(gn,{open:G,onOpenChange:e=>{!e&&!pe&&fe(!1)},children:(0,$.jsxs)(pn,{className:`max-w-md`,children:[(0,$.jsxs)(dn,{children:[(0,$.jsx)(mn,{children:e(`settings.mcp.page.deleteDialog.title`,{name:n??``})}),(0,$.jsxs)(hn,{children:[e(`settings.mcp.page.deleteDialog.descriptionPrefix`),` `,(0,$.jsx)(`code`,{className:`text-foreground`,children:`opencode.json`}),`.`,` `,e(`settings.mcp.page.deleteDialog.descriptionSuffix`)]})]}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(q,{variant:`outline`,onClick:()=>fe(!1),disabled:pe,className:`text-foreground`,children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(q,{variant:`destructive`,size:`sm`,onClick:tt,disabled:pe,children:e(pe?`settings.mcp.page.actions.deleting`:`settings.common.actions.delete`)})]})]})})]})};function ul(e){let t=(0,Sa.c)(51),{value:n,onChange:r,fileName:i,className:a,readOnly:o,hasError:s,id:c,ariaLabel:l,placeholder:u}=e,d=i===void 0?`config.json`:i,f=o!==void 0&&o,p=s!==void 0&&s,{t:m}=Ge(),{currentTheme:h}=un(),g=String(p),_=String(f),v,y,b,x,S,C,w;if(t[0]!==l||t[1]!==h||t[2]!==d||t[3]!==c||t[4]!==f||t[5]!==m||t[6]!==g||t[7]!==_){let e={"aria-invalid":g,"aria-disabled":_,spellcheck:`false`};c&&(e.id=c),l&&(e[`aria-label`]=l);let n;t[15]===d?n=t[16]:(n=li(d),t[15]=d,t[16]=n);let r=n;t[17]===h?x=t[18]:(x=Ai(h,{syntaxColors:!1}),t[17]=h,t[18]=x),t[19]===Symbol.for(`react.memo_cache_sentinel`)?(S=Le(),t[19]=S):S=t[19],t[20]===m?C=t[21]:(C=ze.phrases.of({"Fold line":m(`settings.jsonEditor.fold`),"Unfold line":m(`settings.jsonEditor.unfold`),unfold:m(`settings.jsonEditor.unfold`),"folded code":m(`settings.jsonEditor.foldedCode`)}),t[20]=m,t[21]=C),t[22]===r?w=t[23]:(w=r?[r]:[],t[22]=r,t[23]=w);let i=d.endsWith(`.jsonc`)?`jsonc`:`json`;t[24]!==h||t[25]!==i?(v=Xr({language:i,themeName:h.metadata.id,theme:Rr(h)}),t[24]=h,t[25]=i,t[26]=v):v=t[26],t[27]===f?y=t[28]:(y=ze.readOnly.of(f),t[27]=f,t[28]=y),b=Re.contentAttributes.of(e),t[0]=l,t[1]=h,t[2]=d,t[3]=c,t[4]=f,t[5]=m,t[6]=g,t[7]=_,t[8]=v,t[9]=y,t[10]=b,t[11]=x,t[12]=S,t[13]=C,t[14]=w}else v=t[8],y=t[9],b=t[10],x=t[11],S=t[12],C=t[13],w=t[14];let T;t[29]===u?T=t[30]:(T=u?[Ie(u)]:[],t[29]=u,t[30]=T);let E;t[31]!==v||t[32]!==y||t[33]!==b||t[34]!==T||t[35]!==x||t[36]!==S||t[37]!==C||t[38]!==w?(E=[x,S,C,...w,v,y,b,...T],t[31]=v,t[32]=y,t[33]=b,t[34]=T,t[35]=x,t[36]=S,t[37]=C,t[38]=w,t[39]=E):E=t[39];let D=E,O=p&&`ring-1 ring-inset ring-[var(--status-error)] focus-within:ring-[var(--status-error)]`,k;t[40]!==a||t[41]!==O?(k=K(`h-full min-w-0 overflow-hidden bg-background focus-within:ring-2 focus-within:ring-inset focus-within:ring-[var(--interactive-focus-ring)]`,O,a),t[40]=a,t[41]=O,t[42]=k):k=t[42];let A;t[43]!==D||t[44]!==r||t[45]!==f||t[46]!==n?(A=(0,$.jsx)(Zr,{value:n,onChange:r,readOnly:f,extensions:D,enableSearch:!0}),t[43]=D,t[44]=r,t[45]=f,t[46]=n,t[47]=A):A=t[47];let j;return t[48]!==k||t[49]!==A?(j=(0,$.jsx)(`div`,{className:k,children:A}),t[48]=k,t[49]=A,t[50]=j):j=t[50],j}var dl=/^[a-z0-9][a-z0-9-_.]*\.(js|ts|mjs|cjs)$/;function fl(e){let t=e.trim();if(t===``)return{ok:!0,value:void 0};try{let e=JSON.parse(t);return typeof e!=`object`||!e||Array.isArray(e)?{ok:!1}:{ok:!0,value:e}}catch{return{ok:!1}}}var pl=({open:e,onOpenChange:t,defaultScope:n=`user`})=>{let{t:r}=Ge(),i=$i(e=>e.createEntry),a=$i(e=>e.createFile),[o,s]=Q.useState(`npm`),[c,l]=Q.useState(``),[u,d]=Q.useState(``),[f,p]=Q.useState(``),[m,h]=Q.useState(``),[g,_]=Q.useState(n),[v,y]=Q.useState(!1),b=Q.useCallback(()=>{l(``),d(``),p(``),h(``),_(n)},[n]);Q.useEffect(()=>{e&&(s(`npm`),b())},[e,b]);let x=e=>{e!==o&&(s(e),b())},S=Q.useMemo(()=>fl(u),[u]),C=!S.ok,w=o===`file`&&f.trim()!==``&&!dl.test(f.trim()),T=(o===`npm`||o===`path`)&&c.trim()===``,E=o===`file`&&m.trim()===``,D=o===`file`&&f.trim()===``,O=v||C||o===`npm`&&T||o===`path`&&T||o===`file`&&(D||w||E),k=async()=>{if(!O){y(!0);try{let e;e=o===`file`?await a({fileName:f.trim(),content:m,scope:g}):await i({spec:c.trim(),options:S.ok?S.value:void 0,scope:g}),e.ok?(J.success(e.message||r(`settings.plugins.toast.created`)),e.reloadFailed&&J.warning(r(`settings.plugins.toast.reloadFailed`)),t(!1)):J.error(e.message||r(`settings.plugins.sidebar.toast.deleteFailed`))}finally{y(!1)}}},A=Q.useMemo(()=>[{id:`npm`,label:r(`settings.plugins.dialog.add.tab.npm`)},{id:`path`,label:r(`settings.plugins.dialog.add.tab.path`)},{id:`file`,label:r(`settings.plugins.dialog.add.tab.file`)}],[r]);return(0,$.jsx)(gn,{open:e,onOpenChange:e=>{!e&&v||t(e)},children:(0,$.jsxs)(pn,{className:`max-w-xl`,children:[(0,$.jsxs)(dn,{children:[(0,$.jsx)(mn,{children:r(`settings.plugins.dialog.add.title`)}),(0,$.jsx)(hn,{children:r(`settings.plugins.sidebar.empty.description`)})]}),(0,$.jsx)(Jr,{items:A,activeId:o,onSelect:e=>x(e),layoutMode:`fit`,variant:`active-pill`,activePillLowercase:!1,className:`h-10`}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(o===`npm`||o===`path`)&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{"data-settings-item":`plugins.spec`,className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`plugin-spec`,className:`typography-ui-label text-foreground`,children:r(`settings.plugins.page.field.spec`)}),(0,$.jsx)(Cn,{id:`plugin-spec`,value:c,onChange:e=>l(e.target.value),placeholder:r(`settings.plugins.page.field.spec.placeholder`),"aria-invalid":!T&&void 0,disabled:v}),T&&(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:r(`settings.plugins.validation.specRequired`)})]}),(0,$.jsxs)(`div`,{"data-settings-item":`plugins.options`,className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`plugin-options`,className:`typography-ui-label text-foreground`,children:r(`settings.plugins.page.field.options`)}),(0,$.jsx)(ul,{id:`plugin-options`,value:u,onChange:d,className:`h-44 rounded-[var(--radius-xl)] ring-1 ring-inset ring-border/60`,ariaLabel:r(`settings.plugins.page.field.options`),placeholder:r(`settings.plugins.page.field.options.placeholder`),hasError:C,readOnly:v}),C&&(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:r(`settings.plugins.page.field.options.invalidJson`)})]})]}),o===`file`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{"data-settings-item":`plugins.content`,className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`plugin-filename`,className:`typography-ui-label text-foreground`,children:r(`settings.plugins.page.field.fileName`)}),(0,$.jsx)(Cn,{id:`plugin-filename`,value:f,onChange:e=>p(e.target.value),placeholder:`my-plugin.ts`,"aria-invalid":w||void 0,disabled:v}),w&&(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:r(`settings.plugins.validation.fileName`)})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`plugin-content`,className:`typography-ui-label text-foreground`,children:r(`settings.plugins.page.field.content`)}),(0,$.jsx)(Wr,{id:`plugin-content`,value:m,onChange:e=>h(e.target.value),rows:16,className:`font-mono`,disabled:v})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:r(`settings.plugins.page.field.scope`)}),(0,$.jsx)(`div`,{className:`flex items-center gap-4`,children:[`user`,`project`].map(e=>{let t=g===e,n=r(e===`user`?`settings.plugins.scope.user`:`settings.plugins.scope.project`);return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>_(e),disabled:v,className:`flex items-center gap-2 py-1 text-left disabled:opacity-50`,children:[(0,$.jsx)(pa,{checked:t,onChange:()=>_(e),ariaLabel:n}),(0,$.jsx)(`span`,{className:K(`typography-ui-label font-normal`,t?`text-foreground`:`text-foreground/60`),children:n})]},e)})})]})]}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(q,{size:`sm`,variant:`ghost`,onClick:()=>t(!1),disabled:v,children:r(`settings.plugins.dialog.add.action.cancel`)}),(0,$.jsxs)(q,{size:`sm`,onClick:()=>{k()},disabled:O,children:[v?(0,$.jsx)(X,{name:`loader-4`,className:`h-3.5 w-3.5 animate-spin`}):null,r(`settings.plugins.dialog.add.action.submit`)]})]})]})})},ml=e=>{let t=(0,Sa.c)(31),{info:n}=e,{t:r}=Ge();if(!n)return null;let i=hl;switch(n.kind){case`npm-ok`:{if(!n.hasUpdate||!n.latestVersion)return null;let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(X,{name:`arrow-up-s`,className:`h-3 w-3`}),t[0]=e):e=t[0];let a;t[1]===n.latestVersion?a=t[2]:(a=(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-[var(--status-success)]`,children:[e,n.latestVersion]}),t[1]=n.latestVersion,t[2]=a);let o;return t[3]!==n.currentVersion||t[4]!==n.latestVersion||t[5]!==r||t[6]!==a?(o=i(a,r(`settings.plugins.registry.badge.update.tooltip`,{current:n.currentVersion??``,latest:n.latestVersion})),t[3]=n.currentVersion,t[4]=n.latestVersion,t[5]=r,t[6]=a,t[7]=o):o=t[7],o}case`npm-missing-version`:{let e;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(X,{name:`error-warning`,className:`h-3 w-3 text-[var(--status-warning)]`}),t[8]=e):e=t[8];let a;return t[9]!==n.currentVersion||t[10]!==n.name||t[11]!==r?(a=i(e,r(`settings.plugins.registry.badge.missingVersion.tooltip`,{version:n.currentVersion,name:n.name})),t[9]=n.currentVersion,t[10]=n.name,t[11]=r,t[12]=a):a=t[12],a}case`npm-missing-package`:{let e;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(X,{name:`error-warning`,className:`h-3 w-3 text-[var(--status-error)]`}),t[13]=e):e=t[13];let a;return t[14]!==n.name||t[15]!==r?(a=i(e,r(`settings.plugins.registry.badge.missingPackage.tooltip`,{name:n.name})),t[14]=n.name,t[15]=r,t[16]=a):a=t[16],a}case`npm-malformed`:{let e;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(X,{name:`error-warning`,className:`h-3 w-3 text-[var(--status-error)]`}),t[17]=e):e=t[17];let n;return t[18]===r?n=t[19]:(n=i(e,r(`settings.plugins.registry.badge.malformed.tooltip`)),t[18]=r,t[19]=n),n}case`npm-network`:{let e;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(X,{name:`cloud-off`,className:`h-3 w-3 text-muted-foreground`}),t[20]=e):e=t[20];let n;return t[21]===r?n=t[22]:(n=i(e,r(`settings.plugins.registry.badge.network.tooltip`)),t[21]=r,t[22]=n),n}case`path-missing`:{let e;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(X,{name:`error-warning`,className:`h-3 w-3 text-[var(--status-error)]`}),t[23]=e):e=t[23];let a;return t[24]!==n.absolutePath||t[25]!==r?(a=i(e,r(`settings.plugins.registry.badge.pathMissing.tooltip`,{path:n.absolutePath})),t[24]=n.absolutePath,t[25]=r,t[26]=a):a=t[26],a}case`path-unreadable`:{let e;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(X,{name:`error-warning`,className:`h-3 w-3 text-[var(--status-warning)]`}),t[27]=e):e=t[27];let a;return t[28]!==n.absolutePath||t[29]!==r?(a=i(e,r(`settings.plugins.registry.badge.pathUnreadable.tooltip`,{path:n.absolutePath})),t[28]=n.absolutePath,t[29]=r,t[30]=a):a=t[30],a}case`path-ok`:return null;default:return null}};function hl(e,t){return(0,$.jsxs)(En,{children:[(0,$.jsx)(wn,{asChild:!0,children:(0,$.jsx)(`span`,{className:`inline-flex shrink-0 items-center gap-0.5 text-xs`,children:e})}),(0,$.jsx)(Tn,{children:t})]})}function gl(e,t){return e?t.filter(({source:t})=>{if(e.kind===`package`)return t?.type===`package`&&t.target===e.target;if(t?.type!==`local`)return!1;let n=oi(t.path,void 0);return n?.kind===`local`&&(n.path===e.path||n.path.startsWith(`${e.path}/`))}):[]}var _l=[`plugins`,`package-update`],vl=e=>[i(),`plugins`,`reload`,e??``],yl=(e,t,n,r,i)=>!!(e&&e.directory===t&&e.transport===r&&(e.target===n||e.entry?.spec===n||i&&e.entry?.id===i));function bl(e,t){let n=(0,Sa.c)(2),r=Vi(),a=i(),o;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(o={filters:{mutationKey:_l},select:Sl},n[0]=o):o=n[0];let s=Ce(o);if(!e&&!t)return{kind:`idle`};let c=s.filter(n=>yl(n.variables,r,e,a,t)).reduce(xl,null);if(!c)return{kind:`idle`};if(c.status===`pending`)return{kind:`pending`,entry:c.variables?.entry};if(c.status===`error`)return{kind:`error`,error:qi(c.error),entry:c.variables?.entry};let l;return n[1]===Symbol.for(`react.memo_cache_sentinel`)?(l={kind:`idle`},n[1]=l):l=n[1],l}function xl(e,t){return!e||t.submittedAt>=e.submittedAt?t:e}function Sl(e){return{variables:e.state.variables,status:e.state.status,error:e.state.error,submittedAt:e.state.submittedAt}}function Cl(){let e=(0,Sa.c)(5),t=Vi(),n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=i(),e[0]=n):n=e[0];let r=n,a;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(a={filters:{mutationKey:_l,status:`pending`},select:wl},e[1]=a):a=e[1];let o=Ce(a),s;if(e[2]!==t||e[3]!==o){s=new Set;for(let e of o)e&&e.directory===t&&e.transport===r&&(s.add(e.target),e.entry&&s.add(e.entry.spec));e[2]=t,e[3]=o,e[4]=s}else s=e[4];return s}function wl(e){return e.state.variables}function Tl(){let e=(0,Sa.c)(15),{t}=Ge(),n=we(),r=Vi(),a;e[0]===n?a=e[1]:(a=async e=>{let{target:t,directory:r,transport:a,entry:o}=e;if(i()!==a)throw Error(`Plugin runtime changed`);if(o){if(Ut()!==r)throw Error(`Plugin directory changed`);let e=await $i.getState().updateEntry(o.id,{spec:o.spec});if(!e.ok||e.reloadFailed)throw Error(e.warning||e.message||`Plugin update failed`)}else await ea(r,t);await Ki(n,r,a).catch(Dl)},e[0]=n,e[1]=a);let o;e[2]!==n||e[3]!==t?(o=(e,r)=>{let{name:a,directory:o,transport:s}=r;i()===s&&(J.success(t(`settings.plugins.update.toast.done`,{name:a})),n.invalidateQueries({queryKey:[s,`plugins`,`registry`,o]}))},e[2]=n,e[3]=t,e[4]=o):o=e[4];let s;e[5]===t?s=e[6]:(s=(e,n)=>{let{name:r,transport:a}=n;i()===a&&J.error(t(`settings.plugins.update.toast.failed`,{name:r}))},e[5]=t,e[6]=s);let c;e[7]!==a||e[8]!==o||e[9]!==s?(c={mutationKey:_l,mutationFn:a,onSuccess:o,onError:s},e[7]=a,e[8]=o,e[9]=s,e[10]=c):c=e[10];let l=Te(c),u;return e[11]!==n||e[12]!==r||e[13]!==l?(u=(e,t,a)=>{let o=i();if(n.getMutationCache().findAll({mutationKey:_l,status:`pending`}).some(t=>yl(t.state.variables,r,e,o,a?.id)))return;let s=a?n.getQueryData(Zi(r,o).queryKey)?.entries.find(e=>e.id===a.id):void 0;return l.mutateAsync({target:e,name:t,directory:r,transport:o,entry:a?{...a,original:s}:void 0}).catch(El)},e[11]=n,e[12]=r,e[13]=l,e[14]=u):u=e[14],He(u)}function El(){}function Dl(){}function Ol(){let e=(0,Sa.c)(13),{t}=Ge(),n=we(),r=Vi(),a;e[0]===r?a=e[1]:(a=vl(r),e[0]=r,e[1]=a);let o;e[2]!==n||e[3]!==r?(o=async()=>{let e=i();await mt(),await Ki(n,r,e)},e[2]=n,e[3]=r,e[4]=o):o=e[4];let s,c;e[5]===t?(s=e[6],c=e[7]):(s=()=>{J.success(t(`settings.plugins.page.toast.reloaded`))},c=e=>{J.error(e.message||t(`settings.plugins.toast.reloadFailed`))},e[5]=t,e[6]=s,e[7]=c);let l;return e[8]!==a||e[9]!==o||e[10]!==s||e[11]!==c?(l={mutationKey:a,mutationFn:o,onSuccess:s,onError:c},e[8]=a,e[9]=o,e[10]=s,e[11]=c,e[12]=l):l=e[12],Te(l)}function kl(){let e=(0,Sa.c)(4),t=Vi(),n;e[0]===t?n=e[1]:(n=vl(t),e[0]=t,e[1]=n);let r;return e[2]===n?r=e[3]:(r={filters:{mutationKey:n,status:`pending`},select:Al},e[2]=n,e[3]=r),Ce(r).length>0}function Al(){return!0}var jl=e=>{let t=(0,Sa.c)(10),{children:n,className:r,outerClassName:i}=e,a;t[0]===i?a=t[1]:(a=K(`h-full`,i),t[0]=i,t[1]=a);let o;t[2]===r?o=t[3]:(o=K(`yuri-settings-page-content mx-auto max-w-3xl p-3 sm:p-6 sm:pt-8`,r),t[2]=r,t[3]=o);let s;t[4]!==n||t[5]!==o?(s=(0,$.jsx)(`div`,{className:o,children:n}),t[4]=n,t[5]=o,t[6]=s):s=t[6];let c;return t[7]!==a||t[8]!==s?(c=(0,$.jsx)(Ur,{outerClassName:a,className:`w-full`,children:s}),t[7]=a,t[8]=s,t[9]=c):c=t[9],c},Ml=[`62%`,`78%`,`54%`,`70%`,`48%`],Nl=e=>{let t=(0,Sa.c)(3),{className:n,style:r}=e,i=`rounded bg-muted-foreground/10 ${n??``}`,a;return t[0]!==r||t[1]!==i?(a=(0,$.jsx)(Yr,{className:i,style:r}),t[0]=r,t[1]=i,t[2]=a):a=t[2],a},Pl=()=>{let e=(0,Sa.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{role:`status`,"aria-busy":`true`,"data-plugin-skeleton":`list`,children:Ml.map(Il)}),e[0]=t):t=e[0],t},Fl=()=>{let e=(0,Sa.c)(4),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(Nl,{className:`size-7 shrink-0 rounded-md`}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5 py-3`,children:[t,(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(Nl,{className:`h-2.5 w-44`}),(0,$.jsx)(Nl,{className:`h-2 w-12`})]})]}),e[1]=n):n=e[1];let r;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[(0,$.jsx)(Nl,{className:`h-2 w-14`}),(0,$.jsx)(Nl,{className:`h-9 w-full rounded-md`})]}),e[2]=r):r=e[2];let i;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(jl,{className:`yuri-plugin-detail sm:pt-6`,children:(0,$.jsxs)(`div`,{role:`status`,"aria-busy":`true`,"data-plugin-skeleton":`detail`,children:[n,r,(0,$.jsxs)(`div`,{className:`mt-5 space-y-2`,children:[(0,$.jsx)(Nl,{className:`h-2 w-16`}),(0,$.jsx)(Nl,{className:`h-20 w-full rounded-md`})]})]})}),e[3]=i):i=e[3],i};function Il(e,t){return(0,$.jsxs)(`div`,{className:`flex h-[37px] items-center gap-2 px-3`,"data-plugin-skeleton-row":!0,children:[(0,$.jsx)(Nl,{className:`size-5 shrink-0 rounded-[4px]`}),(0,$.jsx)(Nl,{className:`h-2`,style:{width:e}})]},t)}var Ll=({onItemSelect:e,onAddClick:t})=>{let{t:n}=Ge(),r=Hr(),{selectedId:a,setSelected:o,loadPlugins:s}=$i(ne(e=>({selectedId:e.selectedId,setSelected:e.setSelected,loadPlugins:e.loadPlugins}))),c=Hi(),l=Q.useMemo(()=>c.data?.entries??[],[c.data?.entries]),u=Q.useMemo(()=>c.data?.files??[],[c.data?.files]),d=Q.useMemo(()=>l.map(e=>e.spec),[l]),{data:f,isFetching:p}=Yi(d,!1),m=Q.useMemo(()=>f??{},[f]),h=Qi(),g=h.isError&&h.data===void 0,_=Tl(),[v,y]=Q.useState(!1),b=Q.useRef(!1),x=Cl(),S=kl(),C=c.isPending&&c.data===void 0,[w,T]=Q.useState(!1);Q.useEffect(()=>{s()},[s]),Q.useEffect(()=>{let e=()=>T(!0);return window.addEventListener(`yuri:settings-open-plugin-add`,e),()=>window.removeEventListener(`yuri:settings-open-plugin-add`,e)},[]);let E=Q.useMemo(()=>{let e=h.data,t=new Map;if(!e)return t;for(let n of l){let r=oi(n.spec,n.sourcePath);r?.kind===`package`&&(x.has(r.target)||Ni(Qr(r,e))===`available`&&t.set(n.id,r.target))}return t},[l,x,h.data]),D=Q.useMemo(()=>[...l.filter(e=>e.scope===`user`),...l.filter(e=>e.scope===`project`)],[l]),O=Q.useMemo(()=>[...u.filter(e=>e.scope===`user`),...u.filter(e=>e.scope===`project`)],[u]);Q.useEffect(()=>{a&&document.querySelector(`[data-row-id="${CSS.escape(a)}"]`)?.scrollIntoView({block:`nearest`})},[a,l.length,u.length]);let k=l.length+u.length,A=k===0,j=Q.useCallback(()=>{t?t():T(!0)},[t]),M=Q.useCallback(t=>{o(t),e?.()},[e,o]),N=l.flatMap(e=>{let t=oi(e.spec,e.sourcePath);if(t?.kind!==`package`||x.has(t.target))return[];let n=m[e.spec],r=n?.kind===`npm-ok`&&n.hasUpdate&&n.latestVersion?n:null;return!r&&!E.has(e.id)?[]:[{target:t.target,name:ha(e.spec,!0).name,entry:r?{id:e.id,spec:`${r.name}@${r.latestVersion}`}:void 0}]}),P=He(async()=>{if(S||b.current||x.size>0)return;let e=i(),t=Ut();b.current=!0,y(!0);try{let n=new Set;for(let r of N){if(i()!==e||Ut()!==t)break;!r.entry&&n.has(r.target)||(await _(r.target,r.name,r.entry),n.add(r.target))}}finally{b.current=!1,y(!1)}}),F=e=>{let t=m[e.spec],i=ha(e.spec,e.parsedKind===`npm`),o=oi(e.spec,e.sourcePath),s=o&&h.data?Qr(o,h.data):[],c=h.data?si(s):null,l=ri(s),u=o?.kind===`package`&&x.has(o.target)||Ni(s)===`updating`,d=u||S,f=t?.kind===`npm-ok`&&t.hasUpdate&&!!t.latestVersion,p=t?.kind===`npm-ok`?t.latestVersion:null,g=u?p?n(`settings.plugins.update.running.toVersion`,{version:p}):n(`settings.plugins.update.running`):S?n(`settings.plugins.sidebar.reloading`):c?.kind===`failed`?c.error.split(`
22
22
  `)[0]:f&&p?n(`settings.plugins.update.available.toVersion`,{version:p}):E.has(e.id)?n(`settings.plugins.update.available.title`):null,_=E.get(e.id)??null;return(0,$.jsx)(ps,{compact:!0,rowId:e.id,title:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.spec,children:i.name}),gl(o,r.inventory).length>0?(0,$.jsx)(`span`,{className:`yuri-plugin-gui-tag`,title:n(`guiPlugins.interface`),role:`img`,"aria-label":n(`guiPlugins.interface`),children:(0,$.jsx)(X,{name:`window`,className:`size-[13px]`})}):null,l?(0,$.jsx)(`span`,{className:`inline-flex h-5 shrink-0 items-center font-mono text-[11px] leading-none text-muted-foreground/60`,"data-plugin-version":!0,children:l}):null,e.scope===`project`?(0,$.jsx)(`span`,{className:`shrink-0 text-[10px] text-muted-foreground/60`,children:n(`settings.plugins.sidebar.group.projectEntries`)}):null]}),metadata:g?(0,$.jsx)(`span`,{title:g,className:c?.kind===`failed`&&!d?`text-[var(--status-error)] opacity-70`:`text-[var(--status-info)] opacity-80`,children:g}):t&&t.kind!==`npm-ok`?(0,$.jsx)(ml,{info:t}):null,selected:a===e.id,onSelect:()=>M(e.id),icon:(0,$.jsx)(da,{name:e.spec,src:t&&`icon`in t?t.icon:void 0,fallback:e.parsedKind===`npm`?void 0:`folder`,busy:d,marker:c?.kind===`failed`?(0,$.jsx)(`span`,{className:`size-1.5 rounded-full bg-[var(--status-error)]`}):f||_?(0,$.jsx)(`span`,{className:`size-1.5 rounded-full bg-[var(--status-info)]`}):null})},e.id)},I=e=>{let t=ei(e.absolutePath),i=t&&h.data?si(Qr(t,h.data)):null;return(0,$.jsx)(ps,{compact:!0,rowId:e.id,title:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.fileName,children:e.fileName}),gl(t,r.inventory).length>0?(0,$.jsx)(`span`,{className:`yuri-plugin-gui-tag`,title:n(`guiPlugins.interface`),role:`img`,"aria-label":n(`guiPlugins.interface`),children:(0,$.jsx)(X,{name:`window`,className:`size-[13px]`})}):null]}),metadata:S?n(`settings.plugins.sidebar.reloading`):i?.kind===`failed`?(0,$.jsx)(`span`,{className:`text-[var(--status-error)] opacity-70`,title:i.error,children:i.error.split(`
23
- `)[0]}):e.scope===`project`?n(`settings.plugins.sidebar.group.projectFiles`):null,selected:a===e.id,onSelect:()=>M(e.id),icon:(0,$.jsx)(da,{name:e.fileName,fallback:`file-text`,busy:S,marker:i?.kind===`failed`?(0,$.jsx)(`span`,{className:`size-1.5 rounded-full bg-[var(--status-error)]`}):null})},e.id)},L=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,$.jsxs)(q,{type:`button`,size:`xs`,"data-settings-item":`plugins.updateAll`,onClick:()=>void P(),"aria-busy":v,disabled:p||h.isFetching||v||S||C||x.size>0||N.length===0,"aria-label":n(`settings.plugins.sidebar.actions.updateAll`),title:n(`settings.plugins.sidebar.actions.updateAll`),children:[v?(0,$.jsx)(X,{name:`loader-4`,className:`size-3 animate-spin`,"aria-hidden":!0}):null,n(`settings.plugins.sidebar.actions.updateAll`)]}),(0,$.jsx)(q,{"data-settings-item":`plugins.create`,type:`button`,variant:`ghost`,size:`icon`,onClick:j,"aria-label":n(`settings.plugins.sidebar.actions.addTitle`),title:n(`settings.plugins.sidebar.actions.addTitle`),children:(0,$.jsx)(X,{name:`add`,className:`size-4`})})]});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(hs,{className:`yuri-plugin-collection`,variant:`background`,header:g?(0,$.jsxs)(`p`,{className:`typography-micro mb-2 flex items-center gap-1 text-muted-foreground`,role:`status`,children:[(0,$.jsx)(X,{name:`question`,className:`size-3 shrink-0`}),n(`settings.plugins.status.sidebar.unavailable`)]}):void 0,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2 px-1`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,$.jsx)(`h3`,{className:`typography-ui-label font-medium text-foreground`,children:n(`settings.plugins.sidebar.title`)}),S?(0,$.jsxs)(`span`,{className:`typography-micro text-muted-foreground/70`,role:`status`,children:[`· `,n(`settings.plugins.sidebar.reloading`)]}):k>0?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70`,children:k}):null]}),L]}),(0,$.jsx)(`div`,{className:`yuri-plugin-list`,children:C?(0,$.jsx)(Pl,{}):A?(0,$.jsxs)(`div`,{className:`yuri-settings-group-row py-8 text-center text-muted-foreground`,children:[(0,$.jsx)(X,{name:`plug`,className:`mx-auto mb-2 h-8 w-8 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-ui-label font-medium`,children:n(`settings.plugins.sidebar.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:n(`settings.plugins.sidebar.empty.description`)})]}):(0,$.jsxs)($.Fragment,{children:[D.map(F),O.map(I)]})})]}),(0,$.jsx)(pl,{open:w,onOpenChange:T})]})};function Rl(e){let t=(0,Sa.c)(36),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{pluginIds:r,disabled:i}=n,a=i!==void 0&&i,{host:o,snapshot:s,inventory:c,error:l,loading:u,requested:d,requestLoad:f,setEnabled:p,refresh:m}=Hr(),{t:h}=Ge(),[g,_]=Q.useState(null),[v,y]=Q.useState(null),b=g?.host===o?s.settings.find(e=>e.key===g?.key):void 0,x=!!b,S;t[2]===r?S=t[3]:(S=e=>!r||r.includes(e.id),t[2]=r,t[3]=S);let C=c.filter(S),w;t[4]===r?w=t[5]:(w=e=>!r||!!(e.pluginId&&r.includes(e.pluginId)),t[4]=r,t[5]=w);let T=w,E=s.commands.filter(T),D=s.panels.filter(T),O=s.menuItems.filter(T),k=s.settings.filter(T),A,j;t[6]!==f||t[7]!==d?(A=()=>{d||f()},j=[d,f],t[6]=f,t[7]=d,t[8]=A,t[9]=j):(A=t[8],j=t[9]),Q.useEffect(A,j);let M,N;t[10]!==o||t[11]!==g||t[12]!==x?(M=()=>{g&&(g.host!==o||!x)&&_(null)},N=[o,g,x],t[10]=o,t[11]=g,t[12]=x,t[13]=M,t[14]=N):(M=t[13],N=t[14]),Q.useEffect(M,N);let P;t[15]===s.plugins?P=t[16]:(P=new Map(s.plugins.map(zl)),t[15]=s.plugins,t[16]=P);let F=P,I;t[17]===h?I=t[18]:(I=async e=>{y(null);try{await e()}catch(e){let t=e;y(t instanceof Error?t.message:h(`guiPlugins.error`))}},t[17]=h,t[18]=I);let L=I,R=r?C.map(e=>{let t=F.get(e.id),n=e.error||t?.error,r=e.enabled&&!n&&t?.status===`active`;return(0,$.jsxs)(`div`,{className:`yuri-plugin-gui-control`,"data-gui-plugin-id":e.id,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-xs`,children:[(0,$.jsx)(`span`,{className:`shrink-0 text-foreground`,children:h(`guiPlugins.interface`)}),u&&e.enabled&&!n?(0,$.jsx)(X,{name:`loader-4`,className:`size-3 shrink-0 animate-spin text-muted-foreground`}):(0,$.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full ${n?`bg-[var(--status-error)]`:r?`bg-[var(--status-success)]`:`bg-muted-foreground/50`}`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0 truncate text-muted-foreground/80`,title:n||void 0,role:n?`alert`:`status`,children:n||h(e.enabled?r?`guiPlugins.active`:u?`common.loading`:`guiPlugins.pending`:`guiPlugins.off`)})]}),(0,$.jsx)(`p`,{className:`mt-0.5 text-[11px] text-muted-foreground/60`,children:h(`guiPlugins.interface.description`)})]}),(0,$.jsx)(ti,{checked:e.enabled,disabled:a||u,"aria-label":h(`guiPlugins.enable`,{id:e.id}),onCheckedChange:t=>void L(()=>p(e.id,t))})]},e.id)}):(0,$.jsxs)(Z,{label:h(`guiPlugins.title`),actions:(0,$.jsx)(q,{size:`sm`,disabled:u,onClick:()=>void L(m),children:h(`guiPlugins.refresh`)}),children:[u?(0,$.jsx)(Xi,{label:h(`common.loading`),children:(0,$.jsx)(`span`,{role:`status`,"aria-busy":!0})}):null,c.length===0&&!u?(0,$.jsx)(Xi,{label:h(`guiPlugins.empty`),children:null}):null,c.map(e=>{let t=F.get(e.id),n=e.error||t?.error;return(0,$.jsx)(Ji,{label:e.id,ariaLabel:h(`guiPlugins.enable`,{id:e.id}),checked:e.enabled,disabled:u,onChange:t=>void L(()=>p(e.id,t)),description:n?(0,$.jsx)(`span`,{role:`alert`,className:`text-[var(--status-error)]`,children:n}):h(e.enabled?t?.status===`active`?`guiPlugins.active`:t?.status===`failed`?`guiPlugins.failed`:`guiPlugins.pending`:`guiPlugins.disabled`)},e.id)})]}),z;t[19]!==v||t[20]!==l?(z=l||v?(0,$.jsx)(`div`,{role:`alert`,className:`text-[var(--status-error)]`,children:v||l}):null,t[19]=v,t[20]=l,t[21]=z):z=t[21];let B=E.length?(0,$.jsx)(Z,{label:h(`guiPlugins.commands`),children:E.map(e=>(0,$.jsx)(Xi,{label:e.title,description:e.description,children:(0,$.jsx)(q,{size:`sm`,disabled:!o,onClick:()=>void L(()=>o?.runCommand(e.key)),children:h(`guiPlugins.run`)})},e.key))}):null,V=D.length||O.length?(0,$.jsxs)(Z,{label:h(`guiPlugins.panels`),children:[O.map(e=>(0,$.jsx)(Xi,{label:e.title,description:e.description,children:(0,$.jsx)(q,{size:`sm`,disabled:!o,onClick:()=>void L(e.run),children:h(`guiPlugins.open`)})},`menu:${e.key}`)),D.map(e=>(0,$.jsx)(Xi,{label:e.title,children:(0,$.jsx)(q,{size:`sm`,disabled:!o,onClick:()=>void L(()=>o?.selectPanel(e.key)),children:h(`guiPlugins.open`)})},`panel:${e.key}`))]}):null,H=k.length?(0,$.jsx)(Z,{label:h(`guiPlugins.settings`),children:k.map(e=>(0,$.jsx)(Xi,{label:e.title,children:(0,$.jsx)(q,{size:`sm`,disabled:!o,onClick:()=>_({host:o,key:e.key}),children:h(`guiPlugins.open`)})},e.key))}):null,U=ya,W=!!(o&&b),ee=b?.title??h(`guiPlugins.settings`),te;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(te=()=>_(null),t[22]=te):te=t[22];let ne=o&&b?(0,$.jsx)(_a,{host:o,contributionKey:b.key,kind:`settings`,revision:va(s.plugins,b.pluginId)}):null,re;t[23]!==U||t[24]!==W||t[25]!==ee||t[26]!==te||t[27]!==ne?(re=(0,$.jsx)(U,{id:`gui-plugin-settings`,open:W,title:ee,onClose:te,children:ne}),t[23]=U,t[24]=W,t[25]=ee,t[26]=te,t[27]=ne,t[28]=re):re=t[28];let ie;return t[29]!==R||t[30]!==z||t[31]!==B||t[32]!==V||t[33]!==H||t[34]!==re?(ie=(0,$.jsxs)(`div`,{className:`yuri-settings-section-stack`,"data-plugin-gui-controls":!0,children:[R,z,B,V,H,re]}),t[29]=R,t[30]=z,t[31]=B,t[32]=V,t[33]=H,t[34]=re,t[35]=ie):ie=t[35],ie}function zl(e){return[e.id,e]}var Bl=e=>{let t=(0,Sa.c)(37),{spec:n}=e,{t:r}=Ge(),i;t[0]===n?i=t[1]:(i=[n],t[0]=n,t[1]=i);let{data:a}=Yi(i),o=a?.[n];if(!o||o.kind===`npm-ok`||o.kind===`path-ok`)return null;if(o.kind===`npm-network`){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(X,{name:`cloud-off`,className:`h-5 w-5 text-muted-foreground shrink-0 mt-0.5`}),t[2]=e):e=t[2];let n;t[3]===r?n=t[4]:(n=r(`settings.plugins.registry.badge.network.tooltip`),t[3]=r,t[4]=n);let i;return t[5]===n?i=t[6]:(i=(0,$.jsxs)(`div`,{className:`rounded-md border border-border bg-card p-3 flex items-start gap-3`,children:[e,(0,$.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground`,children:n})})]}),t[5]=n,t[6]=i),i}let s=o.kind===`path-unreadable`,c=s?`var(--status-warning)`:`var(--status-error)`,l=s?`alert`:`error-warning`,u;bb0:{switch(o.kind){case`npm-missing-version`:{let e;t[7]===r?e=t[8]:(e=r(`settings.plugins.registry.banner.invalid.missingVersion`),t[7]=r,t[8]=e),u=e;break bb0}case`npm-missing-package`:{let e;t[9]===r?e=t[10]:(e=r(`settings.plugins.registry.banner.invalid.missingPackage`),t[9]=r,t[10]=e),u=e;break bb0}case`npm-malformed`:{let e;t[11]===r?e=t[12]:(e=r(`settings.plugins.registry.banner.invalid.malformed`),t[11]=r,t[12]=e),u=e;break bb0}case`path-missing`:{let e;t[13]===r?e=t[14]:(e=r(`settings.plugins.registry.banner.invalid.pathMissing`),t[13]=r,t[14]=e),u=e;break bb0}case`path-unreadable`:{let e;t[15]===r?e=t[16]:(e=r(`settings.plugins.registry.banner.invalid.pathUnreadable`),t[15]=r,t[16]=e),u=e;break bb0}}u=void 0}let d=u,f;t[17]===c?f=t[18]:(f={color:c},t[17]=c,t[18]=f);let p;t[19]!==l||t[20]!==f?(p=(0,$.jsx)(X,{name:l,className:`h-5 w-5 shrink-0 mt-0.5`,style:f}),t[19]=l,t[20]=f,t[21]=p):p=t[21];let m;t[22]===c?m=t[23]:(m={color:c},t[22]=c,t[23]=m);let h;t[24]===r?h=t[25]:(h=r(`settings.plugins.registry.banner.invalid.title`),t[24]=r,t[25]=h);let g;t[26]!==m||t[27]!==h?(g=(0,$.jsx)(`p`,{className:`typography-label`,style:m,children:h}),t[26]=m,t[27]=h,t[28]=g):g=t[28];let _;t[29]===d?_=t[30]:(_=(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground mt-0.5`,children:d}),t[29]=d,t[30]=_);let v;t[31]!==g||t[32]!==_?(v=(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[g,_]}),t[31]=g,t[32]=_,t[33]=v):v=t[33];let y;return t[34]!==p||t[35]!==v?(y=(0,$.jsxs)(`div`,{className:`rounded-md border border-border bg-card p-3 flex items-start gap-3`,children:[p,v]}),t[34]=p,t[35]=v,t[36]=y):y=t[36],y};function Vl(e){let t=(0,Sa.c)(18),n=Qi(),r;t[0]===n?r=t[1]:(r=()=>{n.refetch()},t[0]=n,t[1]=r);let i=He(r),a;bb0:{if(n.isPending&&n.data===void 0){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e={kind:`loading`},t[2]=e):e=t[2],a=e;break bb0}if(n.data===void 0||!e){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e={kind:`unknown`},t[3]=e):e=t[3],a=e;break bb0}let r,i,o;if(t[4]!==n.data||t[5]!==e){let a=Qr(e,n.data);r=`known`,i=si(a),o=Ni(a),t[4]=n.data,t[5]=e,t[6]=r,t[7]=i,t[8]=o}else r=t[6],i=t[7],o=t[8];let s;t[9]!==r||t[10]!==i||t[11]!==o||t[12]!==e?(s={kind:r,load:i,update:o,target:e},t[9]=r,t[10]=i,t[11]=o,t[12]=e,t[13]=s):s=t[13],a=s}let o=a,s;return t[14]!==n.isFetching||t[15]!==i||t[16]!==o?(s={status:o,retry:i,isRefreshing:n.isFetching},t[14]=n.isFetching,t[15]=i,t[16]=o,t[17]=s):s=t[17],s}var Hl=2,Ul=e=>{let t=(0,Sa.c)(32),{error:n,reference:r}=e,{t:i}=Ge(),[a,o]=Q.useState(!1),s;t[0]===n?s=t[1]:(s=n.split(`
24
- `),t[0]=n,t[1]=s);let c=s.length,l=c>Hl,u;t[2]!==n||t[3]!==i?(u=async()=>{(await We(n)).ok?Y.success(i(`settings.plugins.status.failed.copied`)):Y.error(i(`settings.plugins.status.failed.copyFailed`))},t[2]=n,t[3]=i,t[4]=u):u=t[4];let d=He(u),f=!a&&`line-clamp-2`,p;t[5]===f?p=t[6]:(p=K(`whitespace-pre-wrap break-all px-3 pt-2.5 font-mono text-[11px] leading-relaxed text-muted-foreground`,f),t[5]=f,t[6]=p);let m;t[7]!==n||t[8]!==p?(m=(0,$.jsx)(`pre`,{className:p,children:n}),t[7]=n,t[8]=p,t[9]=m):m=t[9];let h;t[10]!==r||t[11]!==i?(h=r?(0,$.jsx)(`p`,{className:`typography-micro px-3 pt-1 text-muted-foreground/70`,children:i(`settings.plugins.status.failed.ref`,{ref:r})}):null,t[10]=r,t[11]=i,t[12]=h):h=t[12];let g;t[13]!==a||t[14]!==l||t[15]!==c||t[16]!==i?(g=l?(0,$.jsx)(`button`,{type:`button`,className:`hover:text-foreground`,"aria-expanded":a,onClick:()=>o(Gl),children:a?i(`settings.plugins.status.failed.collapse`):i(`settings.plugins.status.failed.expand`,{count:c})}):(0,$.jsx)(`span`,{}),t[13]=a,t[14]=l,t[15]=c,t[16]=i,t[17]=g):g=t[17];let _;t[18]===d?_=t[19]:(_=()=>void d(),t[18]=d,t[19]=_);let v;t[20]===i?v=t[21]:(v=i(`settings.plugins.status.failed.copy`),t[20]=i,t[21]=v);let y;t[22]!==_||t[23]!==v?(y=(0,$.jsx)(`button`,{type:`button`,className:`hover:text-foreground`,onClick:_,children:v}),t[22]=_,t[23]=v,t[24]=y):y=t[24];let b;t[25]!==y||t[26]!==g?(b=(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-1.5 text-[11px] text-muted-foreground/70`,children:[g,y]}),t[25]=y,t[26]=g,t[27]=b):b=t[27];let x;return t[28]!==b||t[29]!==m||t[30]!==h?(x=(0,$.jsxs)(`div`,{className:`rounded-md border border-[var(--status-error-border)] bg-[var(--status-error-background)]`,role:`alert`,"data-plugin-load-state":`failed`,children:[m,h,b]}),t[28]=b,t[29]=m,t[30]=h,t[31]=x):x=t[31],x},Wl=e=>{let t=(0,Sa.c)(56),{target:n,name:r,latestVersion:i,entryId:a,registry:o}=e,s=i===void 0?null:i,{t:c}=Ge(),{status:l,retry:u,isRefreshing:d}=Vl(n),f=n?.kind===`package`?n.target:null,p=bl(f,a),m=Tl(),h=kl(),g=p.kind===`pending`||l.kind===`known`&&l.update===`updating`,_=o?.kind===`npm-ok`&&o.hasUpdate&&o.latestVersion?o:null,v=_?.latestVersion??s,y;t[0]!==a||t[1]!==_?(y=_&&a?{id:a,spec:`${_.name}@${_.latestVersion}`}:void 0,t[0]=a,t[1]=_,t[2]=y):y=t[2];let b=y,x;t[3]===u?x=t[4]:(x=()=>{u()},t[3]=u,t[4]=x);let S=He(x),C;t[5]!==g||t[6]!==r||t[7]!==f||t[8]!==h||t[9]!==b||t[10]!==m?(C=()=>{!f||g||h||m(f,r,b)},t[5]=g,t[6]=r,t[7]=f,t[8]=h,t[9]=b,t[10]=m,t[11]=C):C=t[11];let w=He(C),T;bb0:{if(l.kind===`loading`){T=null;break bb0}if(l.kind===`unknown`){let e;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(X,{name:`question`,className:`mt-0.5 h-5 w-5 shrink-0 text-muted-foreground`}),t[12]=e):e=t[12];let n;t[13]===c?n=t[14]:(n=c(`settings.plugins.status.unknown.title`),t[13]=c,t[14]=n);let r;t[15]===n?r=t[16]:(r=(0,$.jsx)(`p`,{className:`typography-label text-foreground`,children:n}),t[15]=n,t[16]=r);let i;t[17]===c?i=t[18]:(i=c(`settings.plugins.status.unknown.description`),t[17]=c,t[18]=i);let a;t[19]===i?a=t[20]:(a=(0,$.jsx)(`p`,{className:`typography-micro mt-0.5 text-muted-foreground`,children:i}),t[19]=i,t[20]=a);let o;t[21]!==a||t[22]!==r?(o=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[r,a]}),t[21]=a,t[22]=r,t[23]=o):o=t[23];let s;t[24]===c?s=t[25]:(s=c(`settings.plugins.status.retry`),t[24]=c,t[25]=s);let l;t[26]!==S||t[27]!==d||t[28]!==s?(l=(0,$.jsx)(q,{variant:`outline`,size:`sm`,onClick:S,disabled:d,children:s}),t[26]=S,t[27]=d,t[28]=s,t[29]=l):l=t[29];let u;t[30]!==o||t[31]!==l?(u=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3 rounded-md border border-border bg-card p-3`,role:`status`,"data-plugin-load-state":`unknown`,children:[e,o,l]}),t[30]=o,t[31]=l,t[32]=u):u=t[32],T=u;break bb0}let{load:e}=l;switch(e.kind){case`active`:T=null;break bb0;case`notReported`:{if(p.kind!==`idle`||h){T=null;break bb0}let e;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(X,{name:`loader-4`,className:`size-3 shrink-0 animate-spin`,"aria-hidden":!0}),t[33]=e):e=t[33];let n;t[34]===c?n=t[35]:(n=c(`settings.plugins.status.notReported.description`),t[34]=c,t[35]=n);let r;t[36]===n?r=t[37]:(r=(0,$.jsxs)(`div`,{className:`yuri-plugin-update-strip flex items-center gap-1.5 rounded-md border px-3 py-1.5 text-xs text-[var(--status-info)]`,role:`status`,"data-plugin-load-state":`notReported`,children:[e,(0,$.jsx)(`span`,{className:`min-w-0`,children:n})]}),t[36]=n,t[37]=r),T=r;break bb0}case`failed`:{let n;t[38]!==e.error||t[39]!==e.ref?(n=(0,$.jsx)(Ul,{error:e.error,reference:e.ref},e.error),t[38]=e.error,t[39]=e.ref,t[40]=n):n=t[40],T=n;break bb0}}T=void 0}let E=T,D=f!==null&&(l.kind===`known`&&l.update!==`none`||_!==null||p.kind!==`idle`);if(!E&&!D)return null;let O;t[41]!==w||t[42]!==g||t[43]!==h||t[44]!==D||t[45]!==c||t[46]!==v?(O=D?(0,$.jsxs)(`div`,{className:`yuri-plugin-update-strip relative overflow-hidden rounded-md border px-3 py-1.5`,"aria-busy":g,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 text-xs text-[var(--status-info)]`,role:g?`status`:void 0,children:[g?(0,$.jsx)(X,{name:`loader-4`,className:`size-3 shrink-0 animate-spin text-[var(--status-info)]`,"aria-hidden":!0}):(0,$.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-[var(--status-info)]`,"aria-hidden":!0}),g?v?c(`settings.plugins.update.running.toVersion`,{version:v}):c(`settings.plugins.update.running`):v?c(`settings.plugins.update.available.toVersion`,{version:v}):c(`settings.plugins.update.available.title`)]}),(0,$.jsx)(`button`,{type:`button`,className:`shrink-0 text-[11px] text-muted-foreground/70 hover:text-foreground disabled:opacity-50`,onClick:w,disabled:g||h,children:c(g?`settings.plugins.update.running`:`settings.plugins.update.action`)})]}),g?(0,$.jsx)(`div`,{className:`absolute inset-x-0 bottom-0 h-0.5 overflow-hidden`,"aria-hidden":!0,children:(0,$.jsx)(`div`,{className:`animate-indeterminate-slide h-full w-[30%] bg-[var(--status-info)] opacity-60`})}):null]}):null,t[41]=w,t[42]=g,t[43]=h,t[44]=D,t[45]=c,t[46]=v,t[47]=O):O=t[47];let k;t[48]!==p.error||t[49]!==p.kind||t[50]!==c?(k=p.kind===`error`?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`sr-only`,children:c(`settings.plugins.update.failed.title`)}),(0,$.jsx)(Ul,{error:p.error,reference:null},p.error)]}):null,t[48]=p.error,t[49]=p.kind,t[50]=c,t[51]=k):k=t[51];let A;return t[52]!==E||t[53]!==O||t[54]!==k?(A=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,"data-plugin-feedback":!0,children:[E,O,k]}),t[52]=E,t[53]=O,t[54]=k,t[55]=A):A=t[55],A};function Gl(e){return!e}function Kl(e,t){let n=kl(),{status:r}=Vl(e);return bl(e?.kind===`package`?e.target:null,t).kind===`pending`||r.kind===`known`&&r.update===`updating`?`updating`:n?`reloading`:null}function ql(e){let t=e.trim();if(t.length===0)return{ok:!0,value:void 0};try{let e=JSON.parse(t);return typeof e!=`object`||!e||Array.isArray(e)?{ok:!1}:{ok:!0,value:e}}catch{return{ok:!1}}}function Jl(e){return!e||Object.keys(e).length===0?``:JSON.stringify(e,null,2)}function Yl(e){return{mode:`entry`,scope:e.scope,spec:e.spec,optionsJson:Jl(e.options),fileName:``,content:``}}function Xl(e,t){return{mode:`file`,scope:e.scope,spec:``,optionsJson:``,fileName:e.fileName,content:t}}var Zl=e=>{let t=(0,Sa.c)(14),{name:n,version:r,icon:i,fallback:a}=e,o;t[0]!==a||t[1]!==i||t[2]!==n?(o=(0,$.jsx)(da,{name:n,src:i,fallback:a,size:28}),t[0]=a,t[1]=i,t[2]=n,t[3]=o):o=t[3];let s;t[4]===n?s=t[5]:(s=(0,$.jsx)(`h2`,{className:`truncate text-[13px] font-medium leading-tight text-foreground`,title:n,children:n}),t[4]=n,t[5]=s);let c;t[6]===r?c=t[7]:(c=r?(0,$.jsxs)(`div`,{className:`mt-0.5 font-mono text-[10px] leading-tight text-muted-foreground/70`,children:[`v`,r]}):null,t[6]=r,t[7]=c);let l;t[8]!==s||t[9]!==c?(l=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[s,c]}),t[8]=s,t[9]=c,t[10]=l):l=t[10];let u;return t[11]!==o||t[12]!==l?(u=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[o,l]}),t[11]=o,t[12]=l,t[13]=u):u=t[13],u},Ql=()=>{let{t:e}=Ge(),t=$i(e=>e.selectedId),n=Hr(),r=Hi(),i=Qi(),a=Q.useMemo(()=>r.data?.entries??[],[r.data?.entries]),o=Q.useMemo(()=>r.data?.files??[],[r.data?.files]),s=$i(e=>e.draft),c=$i(e=>e.setDraft),l=$i(e=>e.updateEntry),u=$i(e=>e.updateFile),d=$i(e=>e.readFile),f=$i(e=>e.deleteEntry),p=$i(e=>e.deleteFile),[m,h]=Q.useState(null),[g,_]=Q.useState(!1),v=t?a.find(e=>e.id===t):void 0,y=v?oi(v.spec,v.sourcePath):null,b=bl(y?.kind===`package`?y.target:null,t??void 0),x=b.kind===`idle`?void 0:b.entry,S=x?.original,C=S&&x?a.find(e=>e.spec===x.spec&&e.scope===S.scope&&e.sourcePath===S.sourcePath):void 0,w=v??C??(b.kind===`pending`?S:void 0)??null;Q.useEffect(()=>{C&&t===S?.id&&$i.getState().selectedId===t&&$i.getState().setSelected(C.id)},[C,t,S?.id]);let T=Q.useMemo(()=>t?o.find(e=>e.id===t)??null:null,[o,t]),E=Q.useMemo(()=>w?oi(w.spec,w.sourcePath):null,[w]),D=Q.useMemo(()=>T?ei(T.absolutePath):null,[T]),O=Kl(E??D,w?.id)!==null||g,k=gl(E??D,n.inventory).map(e=>e.id),A=k.length>0?(0,$.jsx)(`div`,{className:K(`transition-opacity`,O&&`opacity-40`),inert:O||void 0,children:(0,$.jsx)(Rl,{pluginIds:k,disabled:O},t)}):null,j=Ol(),M=j.isPending,N=()=>j.mutate(),P=Q.useMemo(()=>a.map(e=>e.spec),[a]),F=Yi(P),I=w?F.data?.[w.spec]:void 0,L=I&&`icon`in I?I.icon:void 0,[R,z]=Q.useState(!1),[B,V]=Q.useState(!1),H=Q.useRef(new Map),U=async()=>{if(!(!m||O||R||B)){_(!0);try{let t=await(m.kind===`entry`?f(m.id):p(m.id));if(!t.ok){Y.error(t.message||e(`settings.plugins.sidebar.toast.deleteFailed`));return}h(null),t.reloadFailed?Y.warning(t.message||e(`settings.plugins.toast.reloadFailed`),{description:t.warning}):Y.success(e(`settings.plugins.sidebar.toast.deleted`,{name:m.name}))}finally{_(!1)}}},W=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(q,{variant:`ghost`,size:`icon`,"aria-label":e(`settings.common.actions.delete`),title:e(`settings.common.actions.delete`),disabled:O||R||B,onClick:()=>{w?h({kind:`entry`,id:w.id,name:w.spec}):T&&h({kind:`file`,id:T.id,name:T.fileName})},children:(0,$.jsx)(X,{name:`delete-bin`,className:`size-4`})}),(0,$.jsx)(gn,{open:m!==null,onOpenChange:e=>{!e&&!g&&h(null)},children:(0,$.jsxs)(pn,{className:`max-w-md`,children:[(0,$.jsxs)(dn,{children:[(0,$.jsx)(mn,{children:e(`settings.plugins.sidebar.deleteDialog.title`)}),(0,$.jsx)(hn,{children:e(`settings.plugins.sidebar.deleteDialog.description`,{name:m?.name??``})})]}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(q,{variant:`ghost`,size:`sm`,disabled:g,onClick:()=>h(null),children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(q,{variant:`destructive`,size:`sm`,disabled:O||R||B,"aria-busy":g,onClick:()=>void U(),children:e(g?`settings.plugins.sidebar.actions.deleting`:`settings.common.actions.delete`)})]})]})})]});Q.useEffect(()=>{let e=!1;return w?(c(Yl(w)),()=>{e=!0}):T?(V(!0),(async()=>{let t=await d(T.id);if(e)return;V(!1);let n=t?.content??``;H.current.set(T.id,n),c(Xl(T,n))})(),()=>{e=!0}):(c(null),()=>{e=!0})},[w,T,d,c]);let ee=(0,$.jsx)(Fl,{});if(r.isPending&&r.data===void 0)return ee;if(!t||!w&&!T)return(0,$.jsx)(jl,{children:(0,$.jsxs)(`div`,{className:`text-center text-muted-foreground`,children:[(0,$.jsx)(X,{name:`plug`,className:`mx-auto mb-3 h-12 w-12 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.plugins.page.empty.select`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:e(`settings.plugins.page.empty.add`)})]})});if(w&&s&&s.mode===`entry`){let t=ha(w.spec,w.parsedKind===`npm`),n=ql(s.optionsJson),r=n.ok,a=s.spec!==w.spec||s.optionsJson!==Jl(w.options),o=async()=>{if(!r||O)return;let t=s.spec.trim();if(!t){Y.error(e(`settings.plugins.validation.specRequired`));return}z(!0);try{let r=await l(w.id,{spec:t,options:n.value});r.ok?r.reloadFailed?Y.warning(r.message||e(`settings.plugins.toast.reloadFailed`),{description:r.warning}):Y.success(r.message||e(`settings.plugins.toast.updated`)):Y.error(r.message||e(`settings.plugins.toast.reloadFailed`))}finally{z(!1)}};return(0,$.jsxs)(jl,{className:`yuri-plugin-detail sm:pt-6`,children:[(0,$.jsx)(Gi,{className:`py-0`,actions:(0,$.jsxs)(`div`,{className:K(`flex flex-wrap items-center gap-1.5`,O&&`opacity-40`),children:[W,(0,$.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>void N(),disabled:M||R||O,children:e(`settings.plugins.page.action.reload`)}),(0,$.jsx)(q,{size:`sm`,onClick:()=>void o(),disabled:!a||!r||R||O,"aria-busy":R,children:e(`settings.plugins.page.action.save`)})]}),children:(0,$.jsx)(Zl,{name:t.name,version:E&&i.data?ri(Qr(E,i.data)):null,icon:L,fallback:w.parsedKind===`npm`?void 0:`folder`})}),(0,$.jsx)(Wl,{target:E,name:w.spec,latestVersion:I?.kind===`npm-ok`?I.latestVersion:null,entryId:w.id,registry:I}),(0,$.jsx)(Bl,{spec:w.spec}),A,(0,$.jsx)(`div`,{"data-settings-item":`plugins.spec`,className:K(`transition-opacity`,O&&`opacity-40`),inert:O||void 0,children:(0,$.jsx)(Z,{label:e(`settings.plugins.page.field.spec`),cardClassName:`contents`,children:(0,$.jsx)(Cn,{value:s.spec,"aria-label":e(`settings.plugins.page.field.spec`),onChange:e=>c({...s,spec:e.target.value}),placeholder:e(`settings.plugins.page.field.spec.placeholder`),className:`font-mono`,disabled:O,spellCheck:!1})})}),(0,$.jsx)(`div`,{"data-settings-item":`plugins.options`,className:K(`transition-opacity`,O&&`opacity-40`),inert:O||void 0,children:(0,$.jsx)(Z,{label:e(`settings.plugins.page.field.options`),description:r?void 0:e(`settings.plugins.page.field.options.invalidJson`),cardClassName:`overflow-hidden p-0`,children:(0,$.jsx)(ul,{value:s.optionsJson,onChange:e=>c({...s,optionsJson:e}),className:`h-[clamp(180px,32dvh,360px)]`,hasError:!r,ariaLabel:e(`settings.plugins.page.field.options`),placeholder:e(`settings.plugins.page.field.options.placeholder`),readOnly:O})})})]})}if(T&&s&&s.mode===`file`){let t=H.current.get(T.id)??``,n=s.content!==t||s.fileName!==T.fileName,r=async()=>{if(!O){z(!0);try{let t=await u(T.id,{content:s.content});t.ok?(H.current.set(T.id,s.content),t.reloadFailed?Y.warning(t.message||e(`settings.plugins.toast.reloadFailed`),{description:t.warning}):Y.success(t.message||e(`settings.plugins.toast.updated`))):Y.error(t.message||e(`settings.plugins.toast.reloadFailed`))}finally{z(!1)}}};return(0,$.jsxs)(jl,{className:`yuri-plugin-detail sm:pt-6`,children:[(0,$.jsx)(Gi,{className:`py-0`,actions:(0,$.jsxs)(`div`,{className:K(`flex flex-wrap items-center gap-1.5`,O&&`opacity-40`),children:[W,(0,$.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>void N(),disabled:M||R||O,children:e(`settings.plugins.page.action.reload`)}),(0,$.jsx)(q,{size:`sm`,onClick:()=>void r(),disabled:!n||R||B||O,"aria-busy":R,children:e(`settings.plugins.page.action.save`)})]}),children:(0,$.jsx)(Zl,{name:T.fileName,version:null,fallback:`file-text`})}),(0,$.jsx)(Wl,{target:D,name:T.fileName}),A,(0,$.jsx)(`div`,{"data-settings-item":`plugins.content`,className:K(`transition-opacity`,O&&`opacity-40`),inert:O||void 0,children:(0,$.jsx)(Z,{label:e(`settings.plugins.page.field.content`),cardClassName:`p-3`,children:(0,$.jsx)(Wr,{embedded:!0,value:s.content,"aria-label":e(`settings.plugins.page.field.content`),onChange:e=>c({...s,content:e.target.value}),rows:16,className:`font-mono typography-meta min-h-[320px]`,spellCheck:!1,disabled:B})})})]})}return ee};async function $l(e,t){let n=await e.json().catch(()=>null);return typeof n?.error==`string`&&n.error.trim()?n.error:t}function eu(){let{t:e}=Ge(),[t,n]=Q.useState(null),[r,i]=Q.useState(``),[a,o]=Q.useState(``),[s,c]=Q.useState(``),[u,d]=Q.useState(!0),[f,p]=Q.useState(!1),m=He(async()=>{d(!0);try{let t=await l(`/api/config/global/opencode`);if(!t.ok)throw Error(await $l(t,e(`settings.globalConfig.toast.loadFailed`)));let n=await t.json(),r=typeof n.content==`string`?n.content:``;i(r),o(r),c(typeof n.fileName==`string`?n.fileName:``)}catch(t){i(``),o(``),c(``),Y.error(t instanceof Error?t.message:e(`settings.globalConfig.toast.loadFailed`))}finally{d(!1)}});return Q.useEffect(()=>{let t=!1;return(async()=>{d(!0);try{let r=await l(`/api/config/global`);if(!r.ok)throw Error(await $l(r,e(`settings.globalConfig.toast.loadFailed`)));let i=await r.json(),a=Array.isArray(i.targets)&&i.targets.some(e=>e&&typeof e==`object`&&e.target===`opencode`&&typeof e.fileName==`string`);if(t)return;n(a?`opencode`:null)}catch(r){t||(n(null),Y.error(r instanceof Error?r.message:e(`settings.globalConfig.toast.loadFailed`)))}finally{t||d(!1)}})(),()=>{t=!0}},[e]),Q.useEffect(()=>{t&&m()},[m,t,e]),(0,$.jsx)(Ur,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsx)(`div`,{className:`yuri-settings-page-content mx-auto w-full max-w-4xl px-3 pt-3 pb-0 sm:px-6 sm:pt-8`,children:(0,$.jsx)(Z,{itemId:`global-config.editor`,actions:t?(0,$.jsx)(q,{onClick:async()=>{if(t){p(!0);try{let n=await l(`/api/config/global/${t}`,{method:`PUT`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({content:r})});if(!n.ok)throw Error(await $l(n,e(`settings.globalConfig.toast.saveFailed`)));let a=await n.json(),s=typeof a.content==`string`?a.content:r;i(s),o(s),Y.success(e(`settings.globalConfig.toast.saved`))}catch(t){Y.error(t instanceof Error?t.message:e(`settings.globalConfig.toast.saveFailed`))}finally{p(!1)}}},disabled:u||f||r===a,size:`sm`,"aria-busy":f,children:e(f?`settings.common.actions.saving`:`settings.common.actions.saveChanges`)}):void 0,label:e(`settings.globalConfig.title`),children:t?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3 px-3 py-1`,children:[(0,$.jsx)(`span`,{className:`typography-meta truncate text-muted-foreground`,children:s}),(0,$.jsx)(q,{variant:`ghost`,size:`xs`,onClick:()=>void m(),disabled:u||f,children:e(`settings.globalConfig.actions.reload`)})]}),(0,$.jsx)(`div`,{className:`h-[clamp(520px,75dvh,960px)] overflow-hidden bg-background`,children:(0,$.jsx)(ul,{value:r,onChange:i,readOnly:u,fileName:s||`opencode.json`,ariaLabel:s||`opencode.json`,className:`h-full`})})]}):(0,$.jsx)(`div`,{className:`min-h-12`,"aria-busy":u})})})})}var tu=`<built-in>`,nu=e=>e?.path===tu,ru=e=>{let t=(0,Sa.c)(172),{onItemSelect:n}=e,{t:r}=Ge(),[i,a]=Q.useState(null),[o,s]=Q.useState(``),[c,l]=Q.useState(null),[u,d]=Q.useState(!1),[f,p]=Q.useState(null),{selectedSkillName:m,setSelectedSkill:h,setSkillDraft:g,createSkill:_,deleteSkill:v,getSkillDetail:y}=so(ne(au)),b=At(),x;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(x=ct(),t[0]=x):x=t[0];let S=x,C;t[1]===b.data?C=t[2]:(C=b.data??[],t[1]=b.data,t[2]=C);let w=C,T;t[3]!==n||t[4]!==h||t[5]!==g||t[6]!==w?(T=()=>{let e=`new-skill`,t=1;for(;w.some(t=>t.name===e);)e=`new-skill-${t}`,t++;g({name:e,scope:`user`,source:`opencode`,description:``}),h(e),n?.()},t[3]=n,t[4]=h,t[5]=g,t[6]=w,t[7]=T):T=t[7];let E=T,D;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(D=async e=>{nu(e)||l(e)},t[8]=D):D=t[8];let O=D,k;t[9]!==c||t[10]!==v||t[11]!==r?(k=async()=>{if(c){if(nu(c)){l(null);return}d(!0),await v(c.name,{directory:S})?(Y.success(r(`settings.skills.sidebar.toast.skillDeleted`,{name:c.name})),l(null)):Y.error(r(`settings.skills.sidebar.toast.deleteSkillFailed`)),d(!1)}},t[9]=c,t[10]=v,t[11]=r,t[12]=k):k=t[12];let A=k,j;t[13]!==y||t[14]!==h||t[15]!==g||t[16]!==w||t[17]!==r?(j=async e=>{if(nu(e))return;let t=e.name,n=1,i=`${t}-copy`;for(;w.some(e=>e.name===i);)n++,i=`${t}-copy-${n}`;let a=await y(e.name);if(!a){Y.error(r(`settings.skills.sidebar.toast.duplicateLoadFailed`));return}g({name:i,scope:e.scope||`user`,source:e.source||`opencode`,description:(a.sources.md.fields.includes(`description`),``),instructions:``}),h(i)},t[13]=y,t[14]=h,t[15]=g,t[16]=w,t[17]=r,t[18]=j):j=t[18];let M=j,N;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(N=e=>{nu(e)||(s(e.name),a(e))},t[19]=N):N=t[19];let P=N,F;t[20]!==_||t[21]!==v||t[22]!==y||t[23]!==i||t[24]!==o||t[25]!==h||t[26]!==w||t[27]!==r?(F=async()=>{if(!i)return;if(nu(i)){a(null);return}let e=o.trim().replace(/\s+/g,`-`).toLowerCase();if(!e){Y.error(r(`settings.skills.page.toast.skillNameRequired`));return}if(e===i.name){a(null);return}if(w.some(t=>t.name===e)){Y.error(r(`settings.skills.page.toast.skillExists`));return}if(!await y(i.name)){Y.error(r(`settings.skills.sidebar.toast.renameLoadFailed`)),a(null);return}await _({name:e,description:`Renamed skill`,scope:i.scope,source:i.source},{directory:S})?await v(i.name,{directory:S})?(Y.success(`Skill renamed to "${e}"`),h(e)):Y.error(r(`settings.skills.sidebar.toast.removeOldAfterRenameFailed`)):Y.error(r(`settings.skills.sidebar.toast.renameFailed`)),a(null)},t[20]=_,t[21]=v,t[22]=y,t[23]=i,t[24]=o,t[25]=h,t[26]=w,t[27]=r,t[28]=F):F=t[28];let I=F,L;t[29]===w?L=t[30]:(L=w.filter(ou),t[29]=w,t[30]=L);let R=L,z;t[31]===w?z=t[32]:(z=w.filter(su),t[31]=w,t[32]=z);let B=z,V;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(V=function(e){let t={},n=[];for(let r of e)r.group?(t[r.group]||(t[r.group]=[]),t[r.group].push(r)):n.push(r);let r=Object.keys(t).sort(cu).map(e=>({name:e,skills:[...t[e]].sort(lu)}));return n.sort(uu),{sortedGroups:r,ungrouped:n}},t[33]=V):V=t[33];let H=V,U;t[34]===R?U=t[35]:(U=H(R),t[34]=R,t[35]=U);let W=U,ee;t[36]===B?ee=t[37]:(ee=H(B),t[36]=B,t[37]=ee);let te=ee,re;t[38]===r?re=t[39]:(re=r(`settings.skills.sidebar.section.project`),t[38]=r,t[39]=re);let ie=re,ae;t[40]===r?ae=t[41]:(ae=r(`settings.skills.sidebar.section.user`),t[40]=r,t[41]=ae);let oe=ae,se;t[42]===ie?se=t[43]:(se=(0,$.jsx)(`span`,{children:ie}),t[42]=ie,t[43]=se);let ce;t[44]===r?ce=t[45]:(ce=r(`settings.skills.page.title.newSkill`),t[44]=r,t[45]=ce);let le;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,$.jsx)(X,{name:`add`,className:`h-4 w-4`}),t[46]=le):le=t[46];let ue;t[47]!==E||t[48]!==ce?(ue=(0,$.jsx)(q,{"data-settings-item":`skills.create`,size:`icon`,variant:`ghost`,"aria-label":ce,onClick:E,children:le}),t[47]=E,t[48]=ce,t[49]=ue):ue=t[49];let de;t[50]!==se||t[51]!==ue?(de=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[se,ue]}),t[50]=se,t[51]=ue,t[52]=de):de=t[52];let G=de,fe;t[53]!==M||t[54]!==n||t[55]!==f||t[56]!==m||t[57]!==h?(fe=e=>(0,$.jsx)(iu,{skill:e,isSelected:m===e.name,onSelect:()=>{h(e.name),n?.()},onRename:()=>P(e),onDelete:()=>O(e),onDuplicate:()=>M(e),isMenuOpen:f===e.name,onMenuOpenChange:t=>p(t?e.name:null)},e.name),t[53]=M,t[54]=n,t[55]=f,t[56]=m,t[57]=h,t[58]=fe):fe=t[58];let pe=fe,me,he;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(me=K(`yuri-settings-page-content h-full overflow-y-auto p-3`,`bg-background`),he=(0,$.jsx)(To,{}),t[59]=me,t[60]=he):(me=t[59],he=t[60]);let ge;t[61]!==w.length||t[62]!==r?(ge=w.length===0?(0,$.jsx)(Z,{children:(0,$.jsxs)(`div`,{className:`yuri-settings-group-row py-12 text-center text-muted-foreground`,children:[(0,$.jsx)(X,{name:`book-open`,className:`mx-auto mb-3 h-10 w-10 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-ui-label font-medium`,children:r(`settings.skills.sidebar.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:r(`settings.skills.sidebar.empty.description`)})]})}):null,t[61]=w.length,t[62]=r,t[63]=ge):ge=t[63];let _e;t[64]!==W.ungrouped||t[65]!==G||t[66]!==pe?(_e=W.ungrouped.length>0?(0,$.jsx)(Z,{label:G,children:W.ungrouped.map(pe)}):(0,$.jsx)(Z,{label:G,cardClassName:`hidden`,children:(0,$.jsx)(`span`,{})}),t[64]=W.ungrouped,t[65]=G,t[66]=pe,t[67]=_e):_e=t[67];let ve;if(t[68]!==W.sortedGroups||t[69]!==ie||t[70]!==pe){let e;t[72]!==ie||t[73]!==pe?(e=e=>{let{name:t,skills:n}=e;return(0,$.jsx)(Mo,{label:t,labelPrefix:ie,count:n.length,storageKey:`project-skills`,variant:`settings-card`,children:n.map(pe)},t)},t[72]=ie,t[73]=pe,t[74]=e):e=t[74],ve=W.sortedGroups.map(e),t[68]=W.sortedGroups,t[69]=ie,t[70]=pe,t[71]=ve}else ve=t[71];let ye;t[75]!==te.ungrouped||t[76]!==pe||t[77]!==oe?(ye=te.ungrouped.length>0?(0,$.jsx)(Z,{label:oe,children:te.ungrouped.map(pe)}):null,t[75]=te.ungrouped,t[76]=pe,t[77]=oe,t[78]=ye):ye=t[78];let be;if(t[79]!==te.sortedGroups||t[80]!==pe||t[81]!==oe){let e;t[83]!==pe||t[84]!==oe?(e=e=>{let{name:t,skills:n}=e;return(0,$.jsx)(Mo,{label:t,labelPrefix:oe,count:n.length,storageKey:`user-skills`,variant:`settings-card`,children:n.map(pe)},t)},t[83]=pe,t[84]=oe,t[85]=e):e=t[85],be=te.sortedGroups.map(e),t[79]=te.sortedGroups,t[80]=pe,t[81]=oe,t[82]=be}else be=t[82];let xe=c!==null,Se;t[86]===u?Se=t[87]:(Se=e=>{!e&&!u&&l(null)},t[86]=u,t[87]=Se);let Ce;t[88]===r?Ce=t[89]:(Ce=r(`settings.skills.sidebar.deleteDialog.title`),t[88]=r,t[89]=Ce);let we;t[90]===Ce?we=t[91]:(we=(0,$.jsx)(mn,{children:Ce}),t[90]=Ce,t[91]=we);let Te=c?.name??``,Ee;t[92]!==r||t[93]!==Te?(Ee=r(`settings.skills.sidebar.deleteDialog.description`,{name:Te}),t[92]=r,t[93]=Te,t[94]=Ee):Ee=t[94];let De;t[95]===Ee?De=t[96]:(De=(0,$.jsx)(hn,{children:Ee}),t[95]=Ee,t[96]=De);let Oe;t[97]!==we||t[98]!==De?(Oe=(0,$.jsxs)(dn,{children:[we,De]}),t[97]=we,t[98]=De,t[99]=Oe):Oe=t[99];let ke;t[100]===Symbol.for(`react.memo_cache_sentinel`)?(ke=()=>l(null),t[100]=ke):ke=t[100];let Ae;t[101]===r?Ae=t[102]:(Ae=r(`settings.common.actions.cancel`),t[101]=r,t[102]=Ae);let je;t[103]!==u||t[104]!==Ae?(je=(0,$.jsx)(q,{size:`sm`,className:`text-foreground hover:bg-interactive-hover hover:text-foreground`,variant:`ghost`,onClick:ke,disabled:u,children:Ae}),t[103]=u,t[104]=Ae,t[105]=je):je=t[105];let Me;t[106]===r?Me=t[107]:(Me=r(`settings.common.actions.delete`),t[106]=r,t[107]=Me);let Ne;t[108]!==A||t[109]!==u||t[110]!==Me?(Ne=(0,$.jsx)(q,{size:`sm`,onClick:A,disabled:u,children:Me}),t[108]=A,t[109]=u,t[110]=Me,t[111]=Ne):Ne=t[111];let Pe;t[112]!==je||t[113]!==Ne?(Pe=(0,$.jsxs)(fn,{children:[je,Ne]}),t[112]=je,t[113]=Ne,t[114]=Pe):Pe=t[114];let Fe;t[115]!==Oe||t[116]!==Pe?(Fe=(0,$.jsxs)(pn,{className:`max-w-md`,children:[Oe,Pe]}),t[115]=Oe,t[116]=Pe,t[117]=Fe):Fe=t[117];let Ie;t[118]!==xe||t[119]!==Se||t[120]!==Fe?(Ie=(0,$.jsx)(gn,{open:xe,onOpenChange:Se,children:Fe}),t[118]=xe,t[119]=Se,t[120]=Fe,t[121]=Ie):Ie=t[121];let Le=i!==null,Re;t[122]===Symbol.for(`react.memo_cache_sentinel`)?(Re=e=>!e&&a(null),t[122]=Re):Re=t[122];let ze;t[123]===r?ze=t[124]:(ze=r(`settings.skills.sidebar.renameDialog.title`),t[123]=r,t[124]=ze);let Be;t[125]===ze?Be=t[126]:(Be=(0,$.jsx)(mn,{children:ze}),t[125]=ze,t[126]=Be);let Ve=i?.name??``,He;t[127]!==r||t[128]!==Ve?(He=r(`settings.skills.sidebar.renameDialog.description`,{name:Ve}),t[127]=r,t[128]=Ve,t[129]=He):He=t[129];let Ue;t[130]===He?Ue=t[131]:(Ue=(0,$.jsx)(hn,{children:He}),t[130]=He,t[131]=Ue);let We;t[132]!==Be||t[133]!==Ue?(We=(0,$.jsxs)(dn,{children:[Be,Ue]}),t[132]=Be,t[133]=Ue,t[134]=We):We=t[134];let Ke;t[135]===Symbol.for(`react.memo_cache_sentinel`)?(Ke=e=>s(e.target.value),t[135]=Ke):Ke=t[135];let qe;t[136]===r?qe=t[137]:(qe=r(`settings.skills.sidebar.renameDialog.placeholder`),t[136]=r,t[137]=qe);let Je;t[138]===I?Je=t[139]:(Je=e=>{e.key===`Enter`&&I()},t[138]=I,t[139]=Je);let Ye;t[140]!==o||t[141]!==qe||t[142]!==Je?(Ye=(0,$.jsx)(Cn,{value:o,onChange:Ke,placeholder:qe,className:`text-foreground placeholder:text-muted-foreground`,onKeyDown:Je}),t[140]=o,t[141]=qe,t[142]=Je,t[143]=Ye):Ye=t[143];let Xe;t[144]===Symbol.for(`react.memo_cache_sentinel`)?(Xe=()=>a(null),t[144]=Xe):Xe=t[144];let Ze;t[145]===r?Ze=t[146]:(Ze=r(`settings.common.actions.cancel`),t[145]=r,t[146]=Ze);let Qe;t[147]===Ze?Qe=t[148]:(Qe=(0,$.jsx)(q,{size:`sm`,className:`text-foreground hover:bg-interactive-hover hover:text-foreground`,variant:`ghost`,onClick:Xe,children:Ze}),t[147]=Ze,t[148]=Qe);let $e;t[149]===r?$e=t[150]:($e=r(`settings.common.actions.rename`),t[149]=r,t[150]=$e);let et;t[151]!==I||t[152]!==$e?(et=(0,$.jsx)(q,{size:`sm`,onClick:I,children:$e}),t[151]=I,t[152]=$e,t[153]=et):et=t[153];let tt;t[154]!==Qe||t[155]!==et?(tt=(0,$.jsxs)(fn,{children:[Qe,et]}),t[154]=Qe,t[155]=et,t[156]=tt):tt=t[156];let nt;t[157]!==We||t[158]!==Ye||t[159]!==tt?(nt=(0,$.jsxs)(pn,{children:[We,Ye,tt]}),t[157]=We,t[158]=Ye,t[159]=tt,t[160]=nt):nt=t[160];let rt;t[161]!==Le||t[162]!==nt?(rt=(0,$.jsx)(gn,{open:Le,onOpenChange:Re,children:nt}),t[161]=Le,t[162]=nt,t[163]=rt):rt=t[163];let it;return t[164]!==ge||t[165]!==_e||t[166]!==ve||t[167]!==ye||t[168]!==be||t[169]!==Ie||t[170]!==rt?(it=(0,$.jsxs)(`div`,{className:me,children:[he,ge,_e,ve,ye,be,Ie,rt]}),t[164]=ge,t[165]=_e,t[166]=ve,t[167]=ye,t[168]=be,t[169]=Ie,t[170]=rt,t[171]=it):it=t[171],it},iu=e=>{let t=(0,Sa.c)(51),{skill:n,isSelected:r,onSelect:i,onDelete:a,onRename:o,onDuplicate:s,isMenuOpen:c,onMenuOpenChange:l}=e,{t:u}=Ge(),d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=Cr(),t[0]=d):d=t[0];let f=d,p;t[1]!==n.source||t[2]!==u?(p=n.source===`claude`?u(`settings.skills.sidebar.badge.claude`):n.source===`agents`?u(`settings.skills.sidebar.badge.agents`):u(`settings.skills.sidebar.badge.opencode`),t[1]=n.source,t[2]=u,t[3]=p):p=t[3];let m=p,h;t[4]===n?h=t[5]:(h=nu(n),t[4]=n,t[5]=h);let g=h,[_,v]=Q.useState(!1),y;t[6]!==a||t[7]!==s||t[8]!==o||t[9]!==u?(y=e=>(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),o()},children:[(0,$.jsx)(X,{name:`edit`,className:`h-4 w-4 mr-px`}),u(`settings.common.actions.rename`)]}),(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),s()},children:[(0,$.jsx)(X,{name:`file-copy`,className:`h-4 w-4 mr-px`}),u(`settings.common.actions.duplicate`)]}),(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),a()},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(X,{name:`delete-bin`,className:`h-4 w-4 mr-px`}),u(`settings.common.actions.delete`)]})]}),t[6]=a,t[7]=s,t[8]=o,t[9]=u,t[10]=y):y=t[10];let b=y,x=!g&&_,S=r?`bg-interactive-selection`:`hover:bg-interactive-hover`,C;t[11]===S?C=t[12]:(C=K(`yuri-settings-group-row group relative flex items-center transition-colors duration-150 select-none`,S),t[11]=S,t[12]=C);let w;t[13]===g?w=t[14]:(w=!f&&!g?e=>{e.preventDefault(),v(!0)}:void 0,t[13]=g,t[14]=w);let T;t[15]!==C||t[16]!==w?(T=(0,$.jsx)(`div`,{className:C,onContextMenu:w}),t[15]=C,t[16]=w,t[17]=T):T=t[17];let E;t[18]===n.name?E=t[19]:(E=(0,$.jsx)(`span`,{className:`typography-ui-label font-normal whitespace-normal [overflow-wrap:anywhere] text-foreground`,children:n.name}),t[18]=n.name,t[19]=E);let D;t[20]===n.scope?D=t[21]:(D=(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-[var(--surface-muted)] px-1 rounded flex-shrink-0 leading-none pb-px border border-[var(--interactive-border)]/50`,children:n.scope}),t[20]=n.scope,t[21]=D);let O;t[22]===m?O=t[23]:(O=(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-[var(--surface-muted)] px-1 rounded flex-shrink-0 leading-none pb-px border border-[var(--interactive-border)]/50`,children:m}),t[22]=m,t[23]=O);let k;t[24]!==D||t[25]!==O?(k=(0,$.jsxs)(`span`,{className:`flex flex-wrap items-center gap-1.5`,children:[D,O]}),t[24]=D,t[25]=O,t[26]=k):k=t[26];let A;t[27]!==E||t[28]!==k?(A=(0,$.jsxs)(`div`,{className:`flex min-w-0 max-w-full flex-col items-start gap-1.5`,children:[E,k]}),t[27]=E,t[28]=k,t[29]=A):A=t[29];let j;t[30]!==i||t[31]!==A?(j=(0,$.jsx)(`button`,{onClick:i,className:`flex min-w-0 flex-1 flex-col gap-0 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,tabIndex:0,children:A}),t[30]=i,t[31]=A,t[32]=j):j=t[32];let M;t[33]!==g||t[34]!==c||t[35]!==l||t[36]!==b?(M=g?null:(0,$.jsxs)($n,{open:c,onOpenChange:e=>{e&&v(!1),l(e)},children:[(0,$.jsx)(fr,{asChild:!0,children:(0,$.jsx)(q,{size:`sm`,variant:`ghost`,className:`h-6 w-6 px-0 flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100`,children:(0,$.jsx)(X,{name:`more-2`,className:`h-3.5 w-3.5`})})}),(0,$.jsx)(Zn,{align:`end`,className:`w-fit min-w-20`,children:b(tr)})]}),t[33]=g,t[34]=c,t[35]=l,t[36]=b,t[37]=M):M=t[37];let N;t[38]!==j||t[39]!==M?(N=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:[j,M]}),t[38]=j,t[39]=M,t[40]=N):N=t[40];let P;t[41]!==N||t[42]!==T?(P=(0,$.jsx)(na,{render:T,children:N}),t[41]=N,t[42]=T,t[43]=P):P=t[43];let F;t[44]!==g||t[45]!==b?(F=g?null:(0,$.jsx)(ra,{className:`w-fit min-w-20`,children:b(ia)}),t[44]=g,t[45]=b,t[46]=F):F=t[46];let I;return t[47]!==P||t[48]!==F||t[49]!==x?(I=(0,$.jsxs)(aa,{open:x,onOpenChange:v,children:[P,F]}),t[47]=P,t[48]=F,t[49]=x,t[50]=I):I=t[50],I};function au(e){return{selectedSkillName:e.selectedSkillName,setSelectedSkill:e.setSelectedSkill,setSkillDraft:e.setSkillDraft,createSkill:e.createSkill,deleteSkill:e.deleteSkill,getSkillDetail:e.getSkillDetail}}function ou(e){return e.scope===`project`}function su(e){return e.scope===`user`}function cu(e,t){return e.localeCompare(t)}function lu(e,t){return e.name.localeCompare(t.name)}function uu(e,t){return e.name.localeCompare(t.name)}var du=()=>{let e=oe.getDirectory();if(typeof e==`string`&&e.trim().length>0)return e;try{let e=window.__zustand_directory_store__;if(e)return e.getState().currentDirectory}catch{}return null},fu=W()(te(e=>({selectedSourceId:Jt[0]?.id??null,isScanning:!1,isInstalling:!1,lastScanError:null,lastInstallError:null,scanResults:null,setSelectedSource:t=>e({selectedSourceId:t}),scanRepo:async(t,n)=>{e({isScanning:!0,lastScanError:null,scanResults:null});try{let r=n&&Object.prototype.hasOwnProperty.call(n,`directory`)?typeof n?.directory==`string`&&n.directory.trim()||null:du(),i=r?`?directory=${encodeURIComponent(r)}`:``,a=await l(`/api/config/skills/scan${i}`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(t)}),o=await a.json().catch(()=>null);if(!a.ok||!o){let t=o?.error||{kind:`unknown`,message:`Failed to scan repository`};return e({lastScanError:t}),{ok:!1,error:t}}return o.ok?(e({scanResults:o.items||[]}),o):(e({lastScanError:o.error||{kind:`unknown`,message:`Failed to scan repository`}}),o)}finally{e({isScanning:!1})}},installSkills:async(t,n)=>{let r=n&&Object.prototype.hasOwnProperty.call(n,`directory`)?typeof n?.directory==`string`&&n.directory.trim()||null:du(),a=n?.transportIdentity??i();if(i()!==a)return{ok:!1,error:{kind:`unknown`,message:`Failed to install skills`}};e({isInstalling:!0,lastInstallError:null});try{let n=r?`?directory=${encodeURIComponent(r)}`:``,o=await l(`/api/config/skills/install${n}`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(t)}),s=await o.json().catch(()=>null);if(!s){let t={kind:`unknown`,message:`Failed to install skills`};return e({lastInstallError:t}),{ok:!1,error:t}}if(!o.ok||!s.ok){let t=s.error||{kind:`unknown`,message:`Failed to install skills`};return e({lastInstallError:t}),{ok:!1,error:t}}return i()===a?(await vt(Oe,r,a),i()===a&&await Wt(Oe,r,a),s):s}catch(t){let n={kind:`unknown`,message:t instanceof Error?t.message:String(t)};return e({lastInstallError:n}),{ok:!1,error:n}}finally{e({isInstalling:!1})}}}),{name:`skills-catalog-store`})),pu=()=>`custom:${Date.now()}-${Math.random().toString(16).slice(2)}`,mu=e=>{let t=e.trim(),n=t.startsWith(`https://`)?`https`:t.startsWith(`git@`)?`ssh`:`shorthand`;if(n===`ssh`)return`${t.split(`:`)[1].replace(/\.git$/i,``)}`;if(n===`https`)return t.split(`/`).slice(3).filter(Boolean).join(`/`).replace(/\.git$/i,``);let r=t.match(/^([^/\s]+)\/([^/\s]+)(?:\/.+)?$/);return r?`${r[1]}/${r[2].replace(/\.git$/i,``)}`:t},hu=async()=>{try{let e=A()?.settings;if(e)return(await e.load())?.settings||{};let t=await l(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});return t.ok?await t.json().catch(()=>null):null}catch{return null}},gu=e=>{let t=(0,Sa.c)(158),{open:n,onOpenChange:r}=e,{t:a}=Ge(),o=fu(_u),s=fu(vu),c=fu(yu),l=ji(bu),u=ji(xu),[d,f]=Q.useState(``),[p,m]=Q.useState(``),[h,_]=Q.useState(``),v;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(v=[],t[0]=v):v=t[0];let[y,b]=Q.useState(v),[x,S]=Q.useState(null),[C,w]=Q.useState(!1),T;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(T=[],t[1]=T):T=t[1];let[E,D]=Q.useState(T),[O,k]=Q.useState(null),A=Q.useRef(0),j=Q.useRef(null),M;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(M=e=>{A.current+=1,w(!1),S(null),j.current=null,e?.clearIdentity&&(D([]),k(null))},t[2]=M):M=t[2];let N=M,P,F;t[3]!==u||t[4]!==n?(P=()=>{n&&(A.current+=1,f(``),m(``),_(``),S(null),w(!1),j.current=null,D([]),k(null),u(),(async()=>{let e=await hu(),t=Array.isArray(e?.skillCatalogs)?e?.skillCatalogs:[];b(t||[])})())},F=[n,u],t[3]=u,t[4]=n,t[5]=P,t[6]=F):(P=t[5],F=t[6]),Q.useEffect(P,F);let I;t[7]===p?I=t[8]:(I=p.trim(),t[7]=p,t[8]=I);let L=I,R;t[9]===h?R=t[10]:(R=h.trim(),t[9]=h,t[10]=R);let z=R,B;if(t[11]!==y||t[12]!==L||t[13]!==z){let e;t[15]!==L||t[16]!==z?(e=e=>{let t=(e.source||``).trim(),n=(e.subpath||``).trim();return t===L&&n===z},t[15]=L,t[16]=z,t[17]=e):e=t[17],B=y.some(e),t[11]=y,t[12]=L,t[13]=z,t[14]=B}else B=t[14];let V=B,H;t[18]!==l||t[19]!==O||t[20]!==d||t[21]!==o||t[22]!==p||t[23]!==h||t[24]!==a?(H=async()=>{let e=p.trim();if(!e){Y.error(a(`settings.skills.catalog.add.toast.repositoryRequired`));return}d.trim()||f(mu(e)),w(!1),S(null);let t=A.current+1;A.current=t;let n=Bt(),r=i(),s=await o({source:e,subpath:h.trim()||void 0,gitIdentityId:O||void 0},{directory:n});if(A.current!==t||i()!==r||Bt()!==n)return;if(!s.ok){if(s.error?.kind===`authRequired`){if(g()){Y.error(a(`settings.skills.catalog.shared.toast.privateRepoNotSupportedVsCode`));return}let e=s.error.identities||[];if(D(e),!O&&e.length>0){let t=l&&l!==`global`&&e.some(e=>e.id===l)?l:e[0].id;k(t)}Y.error(a(`settings.skills.catalog.add.toast.authenticationRequiredScan`));return}Y.error(s.error?.message||a(`settings.skills.catalog.add.toast.scanFailed`));return}let c=s.items?.length||0;if(S(c),c===0){Y.error(a(`settings.skills.catalog.add.toast.noSkillsFound`)),w(!1);return}D([]),w(!0),j.current={directory:n,transport:r},Y.success(a(`settings.skills.catalog.shared.toast.foundSkills`,{count:c}))},t[18]=l,t[19]=O,t[20]=d,t[21]=o,t[22]=p,t[23]=h,t[24]=a,t[25]=H):H=t[25];let U=H,W;t[26]!==y||t[27]!==O||t[28]!==V||t[29]!==d||t[30]!==r||t[31]!==C||t[32]!==s||t[33]!==p||t[34]!==h||t[35]!==a?(W=async()=>{let e=d.trim(),t=p.trim(),n=h.trim();if(!e){Y.error(a(`settings.skills.catalog.add.toast.catalogNameRequired`));return}if(!t){Y.error(a(`settings.skills.catalog.add.toast.repositoryRequired`));return}let o=Bt(),c=i();if(!C||j.current?.directory!==o||j.current?.transport!==c){w(!1),j.current=null,Y.error(a(`settings.skills.catalog.add.toast.scanBeforeAdd`));return}if(V){Y.error(a(`settings.skills.catalog.add.toast.catalogAlreadyExists`));return}let l={id:pu(),label:e,source:t,...n?{subpath:n}:{},...O?{gitIdentityId:O}:{}},u=[...y,l],f=Bt(),m=i();try{await ye({skillCatalogs:u}),b(u),Y.success(a(`settings.skills.catalog.add.toast.catalogAdded`)),await Oe.invalidateQueries({queryKey:[m,`skillsCatalog`,`sources`],exact:!1}),await Et(Oe,f,m),await J(Oe,f,l.id,m),i()===m&&(s(l.id),r(!1))}catch(e){let t=e;Y.error(t instanceof Error?t.message:a(`settings.skills.catalog.add.toast.saveFailed`))}},t[26]=y,t[27]=O,t[28]=V,t[29]=d,t[30]=r,t[31]=C,t[32]=s,t[33]=p,t[34]=h,t[35]=a,t[36]=W):W=t[36];let ee=W,te;t[37]===a?te=t[38]:(te=a(`settings.skills.catalog.add.title`),t[37]=a,t[38]=te);let ne;t[39]===te?ne=t[40]:(ne=(0,$.jsx)(mn,{children:te}),t[39]=te,t[40]=ne);let re;t[41]===a?re=t[42]:(re=a(`settings.skills.catalog.add.descriptionPrefix`),t[41]=a,t[42]=re);let ie;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,$.jsx)(`code`,{className:`font-mono`,children:`SKILL.md`}),t[43]=ie):ie=t[43];let ae;t[44]===a?ae=t[45]:(ae=a(`settings.skills.catalog.add.descriptionSuffix`),t[44]=a,t[45]=ae);let oe;t[46]!==re||t[47]!==ae?(oe=(0,$.jsxs)(hn,{children:[re,` `,ie,ae]}),t[46]=re,t[47]=ae,t[48]=oe):oe=t[48];let se;t[49]!==ne||t[50]!==oe?(se=(0,$.jsxs)(dn,{children:[ne,oe]}),t[49]=ne,t[50]=oe,t[51]=se):se=t[51];let ce;t[52]===a?ce=t[53]:(ce=a(`settings.skills.catalog.add.field.catalogName`),t[52]=a,t[53]=ce);let le;t[54]===ce?le=t[55]:(le=(0,$.jsx)(`label`,{className:`typography-ui-label text-foreground`,children:ce}),t[54]=ce,t[55]=le);let ue;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(ue=e=>f(e.target.value),t[56]=ue):ue=t[56];let de;t[57]===a?de=t[58]:(de=a(`settings.skills.catalog.add.field.catalogNamePlaceholder`),t[57]=a,t[58]=de);let G;t[59]!==d||t[60]!==de?(G=(0,$.jsx)(Cn,{value:d,onChange:ue,placeholder:de}),t[59]=d,t[60]=de,t[61]=G):G=t[61];let fe;t[62]!==le||t[63]!==G?(fe=(0,$.jsxs)(`div`,{className:`space-y-2`,children:[le,G]}),t[62]=le,t[63]=G,t[64]=fe):fe=t[64];let pe;t[65]===a?pe=t[66]:(pe=a(`settings.skills.catalog.add.field.repository`),t[65]=a,t[66]=pe);let me;t[67]===pe?me=t[68]:(me=(0,$.jsx)(`label`,{className:`typography-ui-label text-foreground`,children:pe}),t[67]=pe,t[68]=me);let he;t[69]===Symbol.for(`react.memo_cache_sentinel`)?(he=e=>{m(e.target.value),N({clearIdentity:!0})},t[69]=he):he=t[69];let ge;t[70]===a?ge=t[71]:(ge=a(`settings.skills.catalog.shared.field.repositoryPlaceholder`),t[70]=a,t[71]=ge);let _e;t[72]!==p||t[73]!==ge?(_e=(0,$.jsx)(Cn,{value:p,onChange:he,placeholder:ge}),t[72]=p,t[73]=ge,t[74]=_e):_e=t[74];let ve;t[75]===a?ve=t[76]:(ve=a(`settings.skills.catalog.add.field.repositoryHint`),t[75]=a,t[76]=ve);let be;t[77]===ve?be=t[78]:(be=(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground`,children:ve}),t[77]=ve,t[78]=be);let xe;t[79]!==me||t[80]!==_e||t[81]!==be?(xe=(0,$.jsxs)(`div`,{className:`space-y-2`,children:[me,_e,be]}),t[79]=me,t[80]=_e,t[81]=be,t[82]=xe):xe=t[82];let Se;t[83]===a?Se=t[84]:(Se=a(`settings.skills.catalog.add.field.optionalSubpath`),t[83]=a,t[84]=Se);let Ce;t[85]===Se?Ce=t[86]:(Ce=(0,$.jsx)(`label`,{className:`typography-ui-label text-foreground`,children:Se}),t[85]=Se,t[86]=Ce);let we;t[87]===Symbol.for(`react.memo_cache_sentinel`)?(we=e=>{_(e.target.value),N({clearIdentity:!0})},t[87]=we):we=t[87];let Te;t[88]===a?Te=t[89]:(Te=a(`settings.skills.catalog.shared.field.subpathPlaceholder`),t[88]=a,t[89]=Te);let Ee;t[90]!==h||t[91]!==Te?(Ee=(0,$.jsx)(Cn,{value:h,onChange:we,placeholder:Te}),t[90]=h,t[91]=Te,t[92]=Ee):Ee=t[92];let De;t[93]!==Ce||t[94]!==Ee?(De=(0,$.jsxs)(`div`,{className:`space-y-2`,children:[Ce,Ee]}),t[93]=Ce,t[94]=Ee,t[95]=De):De=t[95];let ke;t[96]!==O||t[97]!==E||t[98]!==a?(ke=E.length>0&&!g()?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-[var(--status-warning)]`,children:a(`settings.skills.catalog.shared.auth.title`)}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground ml-2`,children:a(`settings.skills.catalog.shared.auth.description`)})]}),(0,$.jsxs)(Fr,{value:O||``,onValueChange:e=>{k(e),N()},children:[(0,$.jsx)(Pr,{className:`w-fit`,children:(0,$.jsx)(`span`,{children:E.find(e=>e.id===O)?.name||a(`settings.skills.catalog.shared.auth.chooseIdentity`)})}),(0,$.jsx)(Nr,{align:`start`,children:E.map(Su)})]}),(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground`,children:a(`settings.skills.catalog.shared.auth.footerHint`)})]}):null,t[96]=O,t[97]=E,t[98]=a,t[99]=ke):ke=t[99];let Ae;t[100]!==x||t[101]!==a?(Ae=x===null?null:(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:a(`settings.skills.catalog.add.scanResult`,{count:x})}),t[100]=x,t[101]=a,t[102]=Ae):Ae=t[102];let je;t[103]!==V||t[104]!==a?(je=V?(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:a(`settings.skills.catalog.add.duplicateMessage`)}):null,t[103]=V,t[104]=a,t[105]=je):je=t[105];let Me;t[106]!==fe||t[107]!==xe||t[108]!==De||t[109]!==ke||t[110]!==Ae||t[111]!==je?(Me=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[fe,xe,De,ke,Ae,je]}),t[106]=fe,t[107]=xe,t[108]=De,t[109]=ke,t[110]=Ae,t[111]=je,t[112]=Me):Me=t[112];let Ne;t[113]===r?Ne=t[114]:(Ne=()=>r(!1),t[113]=r,t[114]=Ne);let Pe;t[115]===a?Pe=t[116]:(Pe=a(`settings.common.actions.cancel`),t[115]=a,t[116]=Pe);let Fe;t[117]!==Ne||t[118]!==Pe?(Fe=(0,$.jsx)(q,{size:`sm`,variant:`ghost`,onClick:Ne,children:Pe}),t[117]=Ne,t[118]=Pe,t[119]=Fe):Fe=t[119];let Ie;t[120]===U?Ie=t[121]:(Ie=()=>void U(),t[120]=U,t[121]=Ie);let Le;t[122]!==c||t[123]!==p?(Le=c||!p.trim(),t[122]=c,t[123]=p,t[124]=Le):Le=t[124];let Re;t[125]===Symbol.for(`react.memo_cache_sentinel`)?(Re=(0,$.jsx)(X,{name:`git-repository`,className:`h-4 w-4`}),t[125]=Re):Re=t[125];let ze;t[126]!==c||t[127]!==a?(ze=a(c?`settings.skills.catalog.shared.actions.scanning`:`settings.skills.catalog.shared.actions.scan`),t[126]=c,t[127]=a,t[128]=ze):ze=t[128];let Be;t[129]!==Ie||t[130]!==Le||t[131]!==ze?(Be=(0,$.jsxs)(q,{size:`sm`,className:`gap-2`,variant:`ghost`,onClick:Ie,disabled:Le,children:[Re,ze]}),t[129]=Ie,t[130]=Le,t[131]=ze,t[132]=Be):Be=t[132];let Ve;t[133]===ee?Ve=t[134]:(Ve=()=>void ee(),t[133]=ee,t[134]=Ve);let He;t[135]!==V||t[136]!==d||t[137]!==C||t[138]!==p?(He=!C||V||!d.trim()||!p.trim(),t[135]=V,t[136]=d,t[137]=C,t[138]=p,t[139]=He):He=t[139];let Ue;t[140]===a?Ue=t[141]:(Ue=a(`settings.skills.catalog.add.actions.addCatalog`),t[140]=a,t[141]=Ue);let We;t[142]!==Ve||t[143]!==He||t[144]!==Ue?(We=(0,$.jsx)(q,{size:`sm`,onClick:Ve,disabled:He,children:Ue}),t[142]=Ve,t[143]=He,t[144]=Ue,t[145]=We):We=t[145];let Ke;t[146]!==Fe||t[147]!==Be||t[148]!==We?(Ke=(0,$.jsxs)(fn,{children:[Fe,Be,We]}),t[146]=Fe,t[147]=Be,t[148]=We,t[149]=Ke):Ke=t[149];let qe;t[150]!==se||t[151]!==Me||t[152]!==Ke?(qe=(0,$.jsxs)(pn,{className:`max-w-xl`,children:[se,Me,Ke]}),t[150]=se,t[151]=Me,t[152]=Ke,t[153]=qe):qe=t[153];let Je;return t[154]!==r||t[155]!==n||t[156]!==qe?(Je=(0,$.jsx)(gn,{open:n,onOpenChange:r,children:qe}),t[154]=r,t[155]=n,t[156]=qe,t[157]=Je):Je=t[157],Je};function _u(e){return e.scanRepo}function vu(e){return e.setSelectedSource}function yu(e){return e.isScanning}function bu(e){return e.defaultGitIdentityId}function xu(e){return e.loadDefaultGitIdentityId}function Su(e){return(0,$.jsx)(jr,{value:e.id,children:e.name},e.id)}var Cu=e=>{let t=(0,Sa.c)(85),{open:n,onOpenChange:r,conflicts:i,onConfirm:a}=e,{t:o}=Ge(),s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s={},t[0]=s):s=t[0];let[c,l]=Q.useState(s),u,d;t[1]!==i||t[2]!==n?(u=()=>{if(!n)return;let e={};for(let t of i)e[t.skillName]=`skip`;l(e)},d=[n,i],t[1]=i,t[2]=n,t[3]=u,t[4]=d):(u=t[3],d=t[4]),Q.useEffect(u,d);let f;t[5]===i?f=t[6]:(f=e=>{let t={};for(let n of i)t[n.skillName]=e;l(t)},t[5]=i,t[6]=f);let p=f,m;t[7]!==i||t[8]!==c?(m=i.length>0&&i.every(e=>c[e.skillName]),t[7]=i,t[8]=c,t[9]=m):m=t[9];let h=m,g;t[10]===o?g=t[11]:(g=o(`settings.skills.catalog.conflicts.title`),t[10]=o,t[11]=g);let _;t[12]===g?_=t[13]:(_=(0,$.jsx)(mn,{children:g}),t[12]=g,t[13]=_);let v;t[14]===o?v=t[15]:(v=o(`settings.skills.catalog.conflicts.description`),t[14]=o,t[15]=v);let y;t[16]===v?y=t[17]:(y=(0,$.jsx)(hn,{children:v}),t[16]=v,t[17]=y);let b;t[18]!==_||t[19]!==y?(b=(0,$.jsxs)(dn,{children:[_,y]}),t[18]=_,t[19]=y,t[20]=b):b=t[20];let x;t[21]!==i.length||t[22]!==o?(x=o(`settings.skills.catalog.conflicts.count`,{count:i.length}),t[21]=i.length,t[22]=o,t[23]=x):x=t[23];let S;t[24]===x?S=t[25]:(S=(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:x}),t[24]=x,t[25]=S);let C;t[26]===p?C=t[27]:(C=()=>p(`skip`),t[26]=p,t[27]=C);let w;t[28]===o?w=t[29]:(w=o(`settings.skills.catalog.conflicts.actions.skipAll`),t[28]=o,t[29]=w);let T;t[30]!==C||t[31]!==w?(T=(0,$.jsx)(q,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:C,children:w}),t[30]=C,t[31]=w,t[32]=T):T=t[32];let E;t[33]===p?E=t[34]:(E=()=>p(`overwrite`),t[33]=p,t[34]=E);let D;t[35]===o?D=t[36]:(D=o(`settings.skills.catalog.conflicts.actions.overwriteAll`),t[35]=o,t[36]=D);let O;t[37]!==E||t[38]!==D?(O=(0,$.jsx)(q,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:E,children:D}),t[37]=E,t[38]=D,t[39]=O):O=t[39];let k;t[40]!==T||t[41]!==O?(k=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[T,O]}),t[40]=T,t[41]=O,t[42]=k):k=t[42];let A;t[43]!==S||t[44]!==k?(A=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[S,k]}),t[43]=S,t[44]=k,t[45]=A):A=t[45];let j;if(t[46]!==i||t[47]!==c||t[48]!==o){let e;t[50]!==c||t[51]!==o?(e=e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-1.5`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label truncate`,children:e.skillName}),(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground`,children:o(`settings.skills.catalog.conflicts.installedIn`,{scope:e.scope===`project`?o(`settings.skills.catalog.conflicts.scope.project`):o(`settings.skills.catalog.conflicts.scope.user`),source:e.source===`agents`?o(`settings.skills.catalog.conflicts.source.agents`):o(`settings.skills.catalog.conflicts.source.opencode`)})})]}),(0,$.jsxs)(Fr,{value:c[e.skillName]||`skip`,onValueChange:t=>l(n=>({...n,[e.skillName]:t})),children:[(0,$.jsx)(Pr,{className:`w-fit`,children:(0,$.jsx)(`span`,{className:`capitalize`,children:(c[e.skillName]||`skip`)===`overwrite`?o(`settings.skills.catalog.conflicts.decision.overwrite`):o(`settings.skills.catalog.conflicts.decision.skip`)})}),(0,$.jsxs)(Nr,{align:`end`,children:[(0,$.jsx)(jr,{value:`skip`,className:`pr-2 [&>span:first-child]:hidden`,children:o(`settings.skills.catalog.conflicts.decision.skip`)}),(0,$.jsx)(jr,{value:`overwrite`,className:`pr-2 [&>span:first-child]:hidden`,children:o(`settings.skills.catalog.conflicts.decision.overwrite`)})]})]})]},e.skillName),t[50]=c,t[51]=o,t[52]=e):e=t[52],j=i.map(e),t[46]=i,t[47]=c,t[48]=o,t[49]=j}else j=t[49];let M;t[53]===j?M=t[54]:(M=(0,$.jsx)(`div`,{className:`space-y-2`,children:j}),t[53]=j,t[54]=M);let N;t[55]!==A||t[56]!==M?(N=(0,$.jsxs)(`div`,{className:`space-y-3`,children:[A,M]}),t[55]=A,t[56]=M,t[57]=N):N=t[57];let P;t[58]===r?P=t[59]:(P=()=>r(!1),t[58]=r,t[59]=P);let F;t[60]===o?F=t[61]:(F=o(`settings.common.actions.cancel`),t[60]=o,t[61]=F);let I;t[62]!==P||t[63]!==F?(I=(0,$.jsx)(q,{size:`sm`,variant:`ghost`,onClick:P,children:F}),t[62]=P,t[63]=F,t[64]=I):I=t[64];let L;t[65]!==c||t[66]!==a?(L=()=>a(c),t[65]=c,t[66]=a,t[67]=L):L=t[67];let R=!h,z;t[68]===o?z=t[69]:(z=o(`settings.skills.catalog.conflicts.actions.continue`),t[68]=o,t[69]=z);let B;t[70]!==L||t[71]!==R||t[72]!==z?(B=(0,$.jsx)(q,{size:`sm`,onClick:L,disabled:R,children:z}),t[70]=L,t[71]=R,t[72]=z,t[73]=B):B=t[73];let V;t[74]!==I||t[75]!==B?(V=(0,$.jsxs)(fn,{children:[I,B]}),t[74]=I,t[75]=B,t[76]=V):V=t[76];let H;t[77]!==b||t[78]!==N||t[79]!==V?(H=(0,$.jsxs)(pn,{className:`max-w-2xl`,children:[b,N,V]}),t[77]=b,t[78]=N,t[79]=V,t[80]=H):H=t[80];let U;return t[81]!==r||t[82]!==n||t[83]!==H?(U=(0,$.jsx)(gn,{open:n,onOpenChange:r,children:H}),t[81]=r,t[82]=n,t[83]=H,t[84]=U):U=t[84],U},wu=[{value:`user-opencode`,scope:`user`,source:`opencode`,label:`User / OpenCode`,description:`Global OpenCode config location`},{value:`project-opencode`,scope:`project`,source:`opencode`,label:`Project / OpenCode`,description:`Current project .opencode location`},{value:`user-agents`,scope:`user`,source:`agents`,label:`User / Agents`,description:`Global .agents compatibility location`},{value:`project-agents`,scope:`project`,source:`agents`,label:`Project / Agents`,description:`Current project .agents compatibility location`}];function Tu(e,t){return e===`project`&&t===`claude`?`project-claude`:e===`project`&&t===`agents`?`project-agents`:t===`claude`?`user-claude`:e===`project`?`project-opencode`:t===`agents`?`user-agents`:`user-opencode`}function Eu(e){if(e===`user-claude`)return{scope:`user`,source:`claude`};if(e===`project-claude`)return{scope:`project`,source:`claude`};let t=wu.find(t=>t.value===e);return t?{scope:t.scope,source:t.source}:{scope:`user`,source:`opencode`}}var Du=e=>{let t=(0,Sa.c)(124),{open:n,onOpenChange:r,item:a}=e,{t:o}=Ge(),s=fu(Ou),c=fu(ku),[l,u]=Q.useState(`user`),[d,f]=Q.useState(`opencode`),p=Qt(Au),m=Qt(ju),[h,g]=Q.useState(null),[_,v]=Q.useState(!1),y;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(y=[],t[0]=y):y=t[0];let[b,x]=Q.useState(y),[S,C]=Q.useState(null),w,T;t[1]!==m||t[2]!==n?(w=()=>{n&&(u(`user`),f(`opencode`),g(m),v(!1),x([]),C(null))},T=[n,m],t[1]=m,t[2]=n,t[3]=w,t[4]=T):(w=t[3],T=t[4]),Q.useEffect(w,T);let E;t[5]===o?E=t[6]:(E=e=>{switch(e){case`project-opencode`:return o(`settings.skills.location.option.projectOpencode.label`);case`user-agents`:return o(`settings.skills.location.option.userAgents.label`);case`project-agents`:return o(`settings.skills.location.option.projectAgents.label`);default:return o(`settings.skills.location.option.userOpencode.label`)}},t[5]=o,t[6]=E);let D=E,O;t[7]===o?O=t[8]:(O=e=>{switch(e){case`project-opencode`:return o(`settings.skills.location.option.projectOpencode.description`);case`user-agents`:return o(`settings.skills.location.option.userAgents.description`);case`project-agents`:return o(`settings.skills.location.option.projectAgents.description`);default:return o(`settings.skills.location.option.userOpencode.description`)}},t[7]=o,t[8]=O);let k=O,A;bb0:{if(p.length===0){A=null;break bb0}if(h&&p.some(e=>e.id===h)){A=h;break bb0}if(m&&p.some(e=>e.id===m)){A=m;break bb0}A=p[0]?.id??null}let j=A,M;bb1:{if(l!==`project`){M=null;break bb1}let e=j;if(!e){M=null;break bb1}let n;if(t[9]!==e||t[10]!==p){let r;t[12]===e?r=t[13]:(r=t=>t.id===e,t[12]=e,t[13]=r),n=p.find(r),t[9]=e,t[10]=p,t[11]=n}else n=t[11];M=n?.path??null}let N=M,P;t[14]!==s||t[15]!==a||t[16]!==r||t[17]!==o?(P=async e=>{let t={skillDir:e.skillDir};a?.clawdhub&&(t.clawdhub={slug:a.clawdhub.slug,version:a.clawdhub.version});let n=await s({source:e.source,subpath:e.subpath,gitIdentityId:a?.gitIdentityId,scope:e.scope,targetSource:e.targetSource,selections:[t],conflictPolicy:`prompt`,conflictDecisions:e.conflictDecisions},{directory:e.effectiveDirectory,transportIdentity:e.transportIdentity});if(n.ok){Y.success(o(`settings.skills.catalog.installSkill.toast.installed`)),r(!1);return}if(n.error?.kind===`conflicts`){C({source:e.source,subpath:e.subpath,scope:e.scope,targetSource:e.targetSource,skillDir:e.skillDir,directoryOverride:e.directoryOverride??null,effectiveDirectory:e.effectiveDirectory,transportIdentity:e.transportIdentity}),x(n.error.conflicts),v(!0);return}if(n.error?.kind===`authRequired`){Y.error(n.error.message||o(`settings.skills.catalog.installSkill.toast.authRequired`));return}Y.error(n.error?.message||o(`settings.skills.catalog.installSkill.toast.installFailed`))},t[14]=s,t[15]=a,t[16]=r,t[17]=o,t[18]=P):P=t[18];let F=P;if(!a)return null;let I;t[19]===o?I=t[20]:(I=o(`settings.skills.catalog.installSkill.title`),t[19]=o,t[20]=I);let L;t[21]===I?L=t[22]:(L=(0,$.jsx)(mn,{children:I}),t[21]=I,t[22]=L);let R;t[23]===o?R=t[24]:(R=o(`settings.skills.catalog.installSkill.descriptionPrefix`),t[23]=o,t[24]=R);let z;t[25]===a.skillName?z=t[26]:(z=(0,$.jsx)(`span`,{className:`font-semibold text-foreground`,children:a.skillName}),t[25]=a.skillName,t[26]=z);let B;t[27]===o?B=t[28]:(B=o(`settings.skills.catalog.installSkill.descriptionSuffix`),t[27]=o,t[28]=B);let V;t[29]!==R||t[30]!==z||t[31]!==B?(V=(0,$.jsxs)(hn,{children:[R,` `,z,` `,B]}),t[29]=R,t[30]=z,t[31]=B,t[32]=V):V=t[32];let H;t[33]!==L||t[34]!==V?(H=(0,$.jsxs)(dn,{children:[L,V]}),t[33]=L,t[34]=V,t[35]=H):H=t[35];let U;t[36]===o?U=t[37]:(U=o(`settings.skills.catalog.installSkill.field.destination`),t[36]=o,t[37]=U);let W;t[38]===U?W=t[39]:(W=(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:U}),t[38]=U,t[39]=W);let ee;t[40]!==l||t[41]!==d?(ee=Tu(l,d),t[40]=l,t[41]=d,t[42]=ee):ee=t[42];let te;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(te=e=>{let t=Eu(e);u(t.scope),f(t.source===`agents`?`agents`:`opencode`)},t[43]=te):te=t[43];let ne;t[44]===l?ne=t[45]:(ne=l===`user`?(0,$.jsx)(X,{name:`user-3`,className:`h-3.5 w-3.5`}):(0,$.jsx)(X,{name:`folder`,className:`h-3.5 w-3.5`}),t[44]=l,t[45]=ne);let re;t[46]===d?re=t[47]:(re=d===`agents`?(0,$.jsx)(X,{name:`robot-2`,className:`h-3.5 w-3.5`}):null,t[46]=d,t[47]=re);let ie;t[48]!==D||t[49]!==l||t[50]!==d?(ie=D(Tu(l,d)),t[48]=D,t[49]=l,t[50]=d,t[51]=ie):ie=t[51];let ae;t[52]===ie?ae=t[53]:(ae=(0,$.jsx)(`span`,{children:ie}),t[52]=ie,t[53]=ae);let oe;t[54]!==ne||t[55]!==re||t[56]!==ae?(oe=(0,$.jsxs)(Pr,{className:`w-fit gap-1.5`,children:[ne,re,ae]}),t[54]=ne,t[55]=re,t[56]=ae,t[57]=oe):oe=t[57];let se;t[58]!==k||t[59]!==D?(se=wu.map(e=>(0,$.jsx)(jr,{value:e.value,className:`pr-2 [&>span:first-child]:hidden`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.scope===`user`?(0,$.jsx)(X,{name:`user-3`,className:`h-3.5 w-3.5`}):(0,$.jsx)(X,{name:`folder`,className:`h-3.5 w-3.5`}),e.source===`agents`?(0,$.jsx)(X,{name:`robot-2`,className:`h-3.5 w-3.5`}):null,(0,$.jsx)(`span`,{children:D(e.value)})]}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground ml-5`,children:k(e.value)})]})},e.value)),t[58]=k,t[59]=D,t[60]=se):se=t[60];let ce;t[61]===se?ce=t[62]:(ce=(0,$.jsx)(Nr,{align:`start`,children:se}),t[61]=se,t[62]=ce);let le;t[63]!==ee||t[64]!==oe||t[65]!==ce?(le=(0,$.jsxs)(Fr,{value:ee,onValueChange:te,children:[oe,ce]}),t[63]=ee,t[64]=oe,t[65]=ce,t[66]=le):le=t[66];let ue;t[67]!==W||t[68]!==le?(ue=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[W,le]}),t[67]=W,t[68]=le,t[69]=ue):ue=t[69];let de;t[70]!==p||t[71]!==j||t[72]!==l||t[73]!==o?(de=l===`project`&&(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:o(`settings.skills.catalog.installSkill.field.project`)}),p.length===0?(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:o(`settings.skills.catalog.installSkill.field.noProjects`)}):(0,$.jsxs)(Fr,{value:j??``,onValueChange:e=>g(e),disabled:p.length===1,children:[(0,$.jsx)(Pr,{className:`w-fit`,children:(0,$.jsx)(Ar,{placeholder:o(`settings.skills.catalog.installSkill.field.chooseProjectPlaceholder`)})}),(0,$.jsx)(Nr,{align:`start`,children:p.map(Mu)})]})]}),t[70]=p,t[71]=j,t[72]=l,t[73]=o,t[74]=de):de=t[74];let G;t[75]===a.warnings?G=t[76]:(G=a.warnings?.length?(0,$.jsx)(`div`,{className:`typography-micro text-[var(--status-warning)] bg-[var(--status-warning)]/10 px-2 py-1.5 rounded`,children:a.warnings.join(` · `)}):null,t[75]=a.warnings,t[76]=G);let fe;t[77]!==ue||t[78]!==de||t[79]!==G?(fe=(0,$.jsxs)(`div`,{className:`mt-2 space-y-3`,children:[ue,de,G]}),t[77]=ue,t[78]=de,t[79]=G,t[80]=fe):fe=t[80];let pe;t[81]===r?pe=t[82]:(pe=()=>r(!1),t[81]=r,t[82]=pe);let me;t[83]===o?me=t[84]:(me=o(`settings.common.actions.cancel`),t[83]=o,t[84]=me);let he;t[85]!==pe||t[86]!==me?(he=(0,$.jsx)(q,{size:`sm`,variant:`ghost`,onClick:pe,children:me}),t[85]=pe,t[86]=me,t[87]=he):he=t[87];let ge=c||!a.installable||l===`project`&&!N,_e;t[88]!==N||t[89]!==F||t[90]!==a.repoSource||t[91]!==a.repoSubpath||t[92]!==a.skillDir||t[93]!==l||t[94]!==d?(_e=()=>void F({source:a.repoSource,subpath:a.repoSubpath,scope:l,targetSource:d,skillDir:a.skillDir,directoryOverride:N,effectiveDirectory:N??Bt(),transportIdentity:i()}),t[88]=N,t[89]=F,t[90]=a.repoSource,t[91]=a.repoSubpath,t[92]=a.skillDir,t[93]=l,t[94]=d,t[95]=_e):_e=t[95];let ve;t[96]!==c||t[97]!==o?(ve=o(c?`settings.skills.catalog.installSkill.actions.installing`:`settings.skills.catalog.installSkill.actions.install`),t[96]=c,t[97]=o,t[98]=ve):ve=t[98];let ye;t[99]!==ge||t[100]!==_e||t[101]!==ve?(ye=(0,$.jsx)(q,{size:`sm`,disabled:ge,onClick:_e,children:ve}),t[99]=ge,t[100]=_e,t[101]=ve,t[102]=ye):ye=t[102];let be;t[103]!==he||t[104]!==ye?(be=(0,$.jsxs)(fn,{children:[he,ye]}),t[103]=he,t[104]=ye,t[105]=be):be=t[105];let xe;t[106]!==H||t[107]!==fe||t[108]!==be?(xe=(0,$.jsxs)(pn,{className:`max-w-md`,children:[H,fe,be]}),t[106]=H,t[107]=fe,t[108]=be,t[109]=xe):xe=t[109];let Se;t[110]!==r||t[111]!==n||t[112]!==xe?(Se=(0,$.jsx)(gn,{open:n,onOpenChange:r,children:xe}),t[110]=r,t[111]=n,t[112]=xe,t[113]=Se):Se=t[113];let Ce;t[114]!==S||t[115]!==F?(Ce=e=>{S&&(F({source:S.source,subpath:S.subpath,scope:S.scope,targetSource:S.targetSource,skillDir:S.skillDir,conflictDecisions:e,directoryOverride:S.directoryOverride??null,effectiveDirectory:S.effectiveDirectory,transportIdentity:S.transportIdentity}),v(!1))},t[114]=S,t[115]=F,t[116]=Ce):Ce=t[116];let we;t[117]!==b||t[118]!==_||t[119]!==Ce?(we=(0,$.jsx)(Cu,{open:_,onOpenChange:v,conflicts:b,onConfirm:Ce}),t[117]=b,t[118]=_,t[119]=Ce,t[120]=we):we=t[120];let Te;return t[121]!==Se||t[122]!==we?(Te=(0,$.jsxs)($.Fragment,{children:[Se,we]}),t[121]=Se,t[122]=we,t[123]=Te):Te=t[123],Te};function Ou(e){return e.installSkills}function ku(e){return e.isInstalling}function Au(e){return e.projects}function ju(e){return e.activeProjectId}function Mu(e){return(0,$.jsx)(jr,{value:e.id,children:e.label||e.path},e.id)}var Nu=async()=>{try{let e=A()?.settings;if(e)return(await e.load())?.settings||{};let t=await l(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});return t.ok?await t.json().catch(()=>null):null}catch{return null}},Pu=({mode:e,onModeChange:t,showModeTabs:n=!0})=>{let{t:r}=Ge(),{selectedSourceId:a,setSelectedSource:o}=fu(ne(e=>({selectedSourceId:e.selectedSourceId,setSelectedSource:e.setSelectedSource}))),s=Dt(),c=s.data??Jt,l=c.some(e=>e.id===a)?a:null,u=qt(l??``,{enabled:!!l}),[d,f]=Q.useState(``),[p,m]=Q.useState(!1),[h,g]=Q.useState(!1),[_,v]=Q.useState(null),[y,b]=Q.useState(!1),[x,S]=Q.useState(!1),[C,w]=Q.useState(!1),[T,E]=Q.useState(null);Q.useEffect(()=>{!s.data&&s.isFetching||c.some(e=>e.id===a)||o(c[0]?.id??null)},[a,o,c,s.data,s.isFetching]);let D=Bt(),O=i();Q.useEffect(()=>{E(null)},[l,D,O]);let k=Q.useMemo(()=>Rt(u.data?.pages??[]),[u.data]),A=Q.useMemo(()=>{let e=d.trim().toLowerCase();return e?k.filter(t=>{let n=t.skillName.toLowerCase(),r=(t.description||``).toLowerCase(),i=(t.frontmatterName||``).toLowerCase();return n.includes(e)||r.includes(e)||i.includes(e)}):k},[k,d]),j=Q.useMemo(()=>c.find(e=>e.id===l)||null,[c,l]),M=!!(l&&l.startsWith(`custom:`)),N=j?.source===`clawdhub:registry`||j?.sourceType===`clawdhub`,P=s.isLoading&&!s.data,F=u.isLoading&&!u.data,I=u.isFetchingNextPage,L=T??s.error??u.error,R=async()=>{if(!l||!M)return;let e=Bt(),t=i();b(!0),E(null);try{let n=await Nu(),r=(Array.isArray(n?.skillCatalogs)?n?.skillCatalogs:[]).filter(e=>e.id!==l);await ye({skillCatalogs:r}),Oe.setQueriesData({queryKey:[t,`skillsCatalog`,`sources`],exact:!1},e=>e?.filter(e=>e.id!==l)),Oe.removeQueries({queryKey:[t,`skillsCatalog`,`source`],exact:!1,predicate:e=>e.queryKey[4]===l}),i()===t&&(o(null),S(!1)),await Et(Oe,e,t)}catch(n){i()===t&&Bt()===e&&E(n instanceof Error?n:Error(String(n)))}finally{b(!1)}},z=async()=>{let e=Bt(),t=i(),n=l;w(!0),E(null);try{n?await J(Oe,e,n,t):await Et(Oe,e,t)}catch(r){let a=fu.getState().selectedSourceId;i()===t&&Bt()===e&&a===n&&E(r instanceof Error?r:Error(String(r)))}finally{w(!1)}};return(0,$.jsx)(Ur,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`yuri-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[n&&(0,$.jsx)(`div`,{className:`h-10`,children:(0,$.jsx)(Jr,{items:[{id:`manual`,label:r(`settings.skills.catalog.page.mode.manual`)},{id:`external`,label:r(`settings.skills.catalog.page.mode.external`)}],activeId:e,onSelect:e=>t(e),layoutMode:`fit`,variant:`animated`,animateActivePill:!1,className:`h-full`})}),(0,$.jsx)(Z,{itemId:`skills.catalog.source`,label:r(`settings.skills.catalog.page.section.sourceRepository`),children:(0,$.jsxs)(`div`,{className:`yuri-settings-group-row flex flex-wrap items-center gap-2`,children:[(0,$.jsxs)(Fr,{value:l||``,onValueChange:e=>o(e),children:[(0,$.jsx)(Pr,{className:`w-fit min-w-0 max-w-full`,"aria-label":r(`settings.skills.catalog.page.section.sourceRepository`),children:(0,$.jsx)(Ar,{placeholder:r(`settings.skills.catalog.page.field.selectSourcePlaceholder`),children:j?.label})}),(0,$.jsx)(Nr,{align:`start`,children:c.map(e=>(0,$.jsx)(jr,{value:e.id,children:e.label},e.id))})]}),(0,$.jsx)(q,{variant:`ghost`,size:`icon`,onClick:()=>void z(),disabled:C,title:r(`settings.skills.catalog.page.actions.refreshTitle`),"aria-label":r(`settings.skills.catalog.page.actions.refreshTitle`),children:(0,$.jsx)(X,{name:`refresh`,className:K(`h-3.5 w-3.5`,C&&`animate-spin`)})}),M&&(0,$.jsx)(q,{variant:`ghost`,size:`icon`,className:`text-[var(--status-error)] hover:text-[var(--status-error)]`,onClick:()=>S(!0),disabled:y,title:r(`settings.skills.catalog.page.actions.removeCatalogTitle`),"aria-label":r(`settings.skills.catalog.page.actions.removeCatalogTitle`),children:(0,$.jsx)(X,{name:`delete-bin`,className:`h-3.5 w-3.5`})}),(0,$.jsxs)(q,{"data-settings-item":`skills.catalog.add-catalog`,size:`sm`,className:`ml-auto`,onClick:()=>m(!0),children:[(0,$.jsx)(X,{name:`add`,className:`h-3.5 w-3.5`}),` `,r(`settings.skills.catalog.page.actions.addCatalog`)]})]})}),L&&(0,$.jsxs)(`div`,{className:`rounded-lg border border-[var(--status-error-border)] bg-[var(--status-error-background)] px-4 py-3`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label font-medium text-[var(--status-error)]`,children:r(`settings.skills.catalog.page.error.catalogTitle`)}),(0,$.jsx)(`div`,{className:`typography-meta text-[var(--status-error)]/80 mt-1`,children:L.message})]}),(0,$.jsxs)(`div`,{className:`min-w-0 space-y-3`,children:[(0,$.jsxs)(`div`,{"data-settings-item":`skills.catalog.search`,className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[(0,$.jsxs)(`div`,{className:`relative min-w-0 flex-1 basis-48`,children:[(0,$.jsx)(X,{name:`search`,className:`pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 size-4 text-muted-foreground`}),(0,$.jsx)(Cn,{value:d,onChange:e=>f(e.target.value),placeholder:r(`settings.skills.catalog.shared.field.searchSkillsPlaceholder`),"aria-label":r(`settings.skills.catalog.shared.field.searchSkillsPlaceholder`),className:`w-full pl-9`})]}),(0,$.jsx)(`span`,{className:`typography-meta shrink-0 text-muted-foreground tabular-nums`,role:`status`,children:P||F?r(`settings.skills.catalog.page.loading.catalog`):r(`settings.skills.catalog.page.foundCount`,{count:A.length})})]}),(0,$.jsx)(Z,{children:A.length===0&&!F?(0,$.jsxs)(`div`,{className:`py-8 text-center text-muted-foreground`,children:[(0,$.jsx)(`p`,{className:`typography-body`,children:r(`settings.skills.catalog.page.empty.noSkillsTitle`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:r(`settings.skills.catalog.page.empty.noSkillsDescription`)})]}):F?(0,$.jsxs)(`div`,{className:`py-8 text-center text-muted-foreground`,children:[(0,$.jsx)(X,{name:`refresh`,className:`mx-auto mb-3 h-5 w-5 animate-spin opacity-50`}),(0,$.jsx)(`p`,{className:`typography-meta`,children:r(`settings.skills.catalog.page.loading.skills`)})]}):(0,$.jsx)($.Fragment,{children:A.map(e=>{let t=e.installed?.isInstalled,n=e.installed?.scope;return(0,$.jsx)(`div`,{className:`yuri-settings-group-row`,children:(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label font-medium text-foreground [overflow-wrap:anywhere]`,children:e.skillName}),t&&(0,$.jsx)(`span`,{className:`typography-micro text-[var(--status-success)] bg-[var(--status-success)]/10 px-1.5 py-0.5 rounded flex-shrink-0`,children:r(`settings.skills.catalog.page.badge.installed`,{scope:n||r(`settings.skills.catalog.page.badge.unknown`)})}),!e.installable&&(0,$.jsx)(`span`,{className:`typography-micro text-[var(--status-warning)] bg-[var(--status-warning)]/10 px-1.5 py-0.5 rounded flex-shrink-0`,children:r(`settings.skills.catalog.page.badge.notInstallable`)})]}),e.description?(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground mt-1 line-clamp-2 max-w-prose [overflow-wrap:anywhere]`,children:e.description}):(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground/50 mt-0.5 italic`,children:r(`settings.skills.catalog.shared.noDescription`)}),e.clawdhub&&(0,$.jsxs)(`div`,{className:`typography-micro text-muted-foreground mt-1.5 flex flex-wrap items-center gap-x-3 gap-y-1 [overflow-wrap:anywhere]`,children:[e.clawdhub.owner&&(0,$.jsxs)(`span`,{children:[r(`settings.skills.catalog.page.byOwnerPrefix`),` `,(0,$.jsx)(`span`,{className:`font-medium text-foreground/80`,children:e.clawdhub.owner})]}),(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(X,{name:`download`,className:`h-3 w-3`}),e.clawdhub.downloads?.toLocaleString()??0]}),(e.clawdhub.stars??0)>0&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(X,{name:`star`,className:`h-3 w-3`}),e.clawdhub.stars]}),(0,$.jsxs)(`span`,{className:`bg-[var(--surface-muted)] px-1.5 py-0.5 rounded`,children:[`v`,e.clawdhub.version]})]}),e.warnings?.length?(0,$.jsx)(`div`,{className:`typography-micro text-[var(--status-warning)] mt-1.5 bg-[var(--status-warning)]/10 px-2 py-1 rounded w-fit [overflow-wrap:anywhere]`,children:e.warnings.join(` · `)}):null]}),(0,$.jsx)(q,{size:`sm`,className:`shrink-0`,disabled:!e.installable,onClick:()=>{v(e),g(!0)},children:r(`settings.skills.catalog.shared.actions.install`)})]})},`${e.sourceId}:${e.skillDir}`)})})}),N&&u.hasNextPage&&!F&&A.length>0&&(0,$.jsx)(`div`,{className:`flex justify-center mt-2 px-2`,children:(0,$.jsx)(q,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>void u.fetchNextPage(),disabled:I,children:r(I?`settings.skills.catalog.page.loading.more`:`settings.skills.catalog.page.actions.loadMoreSkills`)})})]}),(0,$.jsx)(gu,{open:p,onOpenChange:m}),(0,$.jsx)(Du,{open:h,onOpenChange:g,item:_}),(0,$.jsx)(gn,{open:x,onOpenChange:e=>{y||S(e)},children:(0,$.jsxs)(pn,{className:`max-w-md`,children:[(0,$.jsxs)(dn,{children:[(0,$.jsx)(mn,{children:r(`settings.skills.catalog.page.removeDialog.title`)}),(0,$.jsx)(hn,{children:r(`settings.skills.catalog.page.removeDialog.description`)})]}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(q,{size:`sm`,variant:`ghost`,onClick:()=>S(!1),disabled:y,children:r(`settings.common.actions.cancel`)}),(0,$.jsx)(q,{size:`sm`,variant:`destructive`,onClick:()=>void R(),disabled:y,children:r(`settings.skills.catalog.page.actions.removeCatalog`)})]})]})})]})})},Fu=()=>{let e=(0,Sa.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(Pu,{mode:`external`,onModeChange:Wu,showModeTabs:!1}),e[0]=t):t=e[0],t},Iu=`SKILL.md`,Lu=`h-[clamp(320px,58dvh,680px)] min-h-[260px] max-h-[calc(100dvh-220px)]`,Ru=(e,t)=>{let n=ba({description:e}).trimEnd(),r=t.trimStart();return`---\n${n}\n---${r?`\n\n${r}`:`
25
- `}`},zu=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Bu=e=>{let t=e.match(/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)([\s\S]*)$/);if(!t)return{description:null,instructions:e};let n=null;try{let e=xa(t[1]);if(zu(e)){let t=e.description;typeof t==`string`&&(n=t)}}catch{n=null}return{description:n,instructions:t[2].replace(/^\r?\n/,``)}},Vu=(e,t)=>Ru(t,Bu(e).instructions),Hu=()=>{let{t:e}=Ge(),{currentTheme:t}=un(),{selectedSkillName:n,getSkillDetail:r,createSkill:i,updateSkill:a,skillDraft:o,setSkillDraft:s,setSelectedSkill:c}=so(ne(e=>({selectedSkillName:e.selectedSkillName,getSkillDetail:e.getSkillDetail,createSkill:e.createSkill,updateSkill:e.updateSkill,skillDraft:e.skillDraft,setSkillDraft:e.setSkillDraft,setSelectedSkill:e.setSelectedSkill}))),l=At(),u=ct(),d=Q.useMemo(()=>l.data??[],[l.data]),f=n?d.find(e=>e.name===n)??null:null,p=!!(o&&o.name===n&&!f),m=!!(n&&!f&&!o),h=f?.path===`<built-in>`;Q.useEffect(()=>{m&&c(null)},[m,c]);let[g,_]=Q.useState(``),[v,y]=Q.useState(`user`),[b,x]=Q.useState(`opencode`),[S,C]=Q.useState(``),[w,T]=Q.useState(``),[E,D]=Q.useState(()=>Ru(``,``)),[O,k]=Q.useState(`edit`),[A,j]=Q.useState([]),[M,N]=Q.useState([]),[P,F]=Q.useState(!1),[I,L]=Q.useState(!1),[R,z]=Q.useState(``),[B,V]=Q.useState(``),[H,U]=Q.useState(!1),[W,ee]=Q.useState(``),[te,re]=Q.useState(``),[ie,ae]=Q.useState(null),[oe,se]=Q.useState(!1),[ce,le]=Q.useState(``),[ue,de]=Q.useState(null),[fe,pe]=Q.useState(!1),me=p?g.trim()!==``||S.trim()!==``||w.trim()!==``||M.length>0:S!==R||w!==B,he=ie?te!==ce:W.trim()!==``,ge=Q.useCallback(t=>{switch(t){case`project-opencode`:return e(`settings.skills.location.option.projectOpencode.label`);case`user-claude`:return e(`settings.skills.location.option.userClaude.label`);case`project-claude`:return e(`settings.skills.location.option.projectClaude.label`);case`user-agents`:return e(`settings.skills.location.option.userAgents.label`);case`project-agents`:return e(`settings.skills.location.option.projectAgents.label`);default:return e(`settings.skills.location.option.userOpencode.label`)}},[e]),_e=Q.useCallback(t=>{switch(t){case`project-opencode`:return e(`settings.skills.location.option.projectOpencode.description`);case`user-claude`:return e(`settings.skills.location.option.userClaude.description`);case`project-claude`:return e(`settings.skills.location.option.projectClaude.description`);case`user-agents`:return e(`settings.skills.location.option.userAgents.description`);case`project-agents`:return e(`settings.skills.location.option.projectAgents.description`);default:return e(`settings.skills.location.option.userOpencode.description`)}},[e]);Q.useEffect(()=>{(async()=>{if(p&&o){let e=o.description||``,t=o.instructions||``;_(o.name||``),y(o.scope||`user`),x(o.source===`agents`?`agents`:`opencode`),C(e),T(t),D(Ru(e,t)),z(``),V(``),j([]),N(o.pendingFiles||[])}else if(n&&f){L(!0);try{let e=await r(n);if(e){let t=e.sources.md,n=t.description||``,r=t.instructions||``;C(n),T(r),D(Ru(n,r)),z(n),V(r),j(t.supportingFiles||[])}}catch(e){console.error(`Failed to load skill details:`,e)}finally{L(!1)}}})()},[f,p,n,d,o,r]);let ve=G(e=>e.editorFontSize),ye=Q.useMemo(()=>{let e=[Ai(t,{fontSize:ve})],n=li(Iu);return n&&e.push(n),e.push(Re.lineWrapping),e},[t,ve]),be=Q.useMemo(()=>{let e=W.trim()||`supporting-file.md`,n=Vr(e),r=!!n&&n!==`markdown`,i=[Ai(t,r?{syntaxColors:!1,fontSize:ve}:{fontSize:ve})],a=li(e);return a&&i.push(a),r&&n&&i.push(Xr({language:n,themeName:t.metadata.id,theme:Rr(t)})),i.push(Re.lineWrapping),i},[t,W,ve]),xe=Q.useCallback(e=>{C(e),D(t=>Vu(t,e))},[]),Se=Q.useCallback(e=>{D(e);let t=Bu(e);C(t.description??``),T(t.instructions)},[]),Ce=async()=>{let t=p?g.trim().replace(/\s+/g,`-`).toLowerCase():n?.trim();if(!t){Y.error(e(`settings.skills.page.toast.skillNameRequired`));return}if(!/^[a-z0-9][a-z0-9-]*[a-z0-9]$|^[a-z0-9]$/.test(t)||t.length>64){Y.error(e(`settings.skills.page.toast.invalidSkillName`));return}if(!S.trim()){Y.error(e(`settings.skills.page.toast.descriptionRequired`));return}if(p&&d.some(e=>e.name===t)){Y.error(e(`settings.skills.page.toast.skillExists`));return}F(!0);try{let n={name:t,description:S.trim(),instructions:w.trim()||void 0,scope:p?v:void 0,source:p?b:void 0,targetPath:p?void 0:f?.path,supportingFiles:p&&M.length>0?M:void 0},r;p?(r=await i(n,{directory:u}),r&&(s(null),N([]),c(t))):(r=await a(t,n,{directory:u}),r&&(z(S.trim()),V(w.trim()))),r?Y.success(e(p?`settings.skills.page.toast.skillCreated`:`settings.skills.page.toast.skillUpdated`)):Y.error(e(p?`settings.skills.page.toast.createSkillFailed`:`settings.skills.page.toast.updateSkillFailed`))}catch(t){console.error(`Error saving skill:`,t),Y.error(e(`settings.skills.page.toast.saveUnexpectedError`))}finally{F(!1)}},we=()=>{ae(null),ee(``),re(``),le(``),U(!0)},Te=async t=>{if(ae(t),ee(t),p){let e=M.find(e=>e.path===t)?.content||``;re(e),le(e),U(!0);return}if(n){se(!0),U(!0);try{let{readSupportingFile:e}=so.getState(),r=await e(n,t);re(r||``),le(r||``)}catch{Y.error(e(`settings.skills.page.toast.loadFileContentFailed`)),re(``),le(``)}finally{se(!1)}}},Ee=async()=>{if(!W.trim()){Y.error(e(`settings.skills.page.toast.fileNameRequired`));return}let t=W.trim(),i=ie!==null;if(p){if(i)N(e=>e.map(e=>e.path===ie?{path:t,content:te}:e)),Y.success(e(`settings.skills.page.toast.fileUpdated`,{path:t}));else{if(M.some(e=>e.path===t)){Y.error(e(`settings.skills.page.toast.fileExists`));return}N(e=>[...e,{path:t,content:te}]),Y.success(e(`settings.skills.page.toast.fileAdded`,{path:t}))}U(!1),ae(null);return}if(!n){Y.error(e(`settings.skills.page.toast.noSkillSelected`));return}let{writeSupportingFile:a}=so.getState();if(await a(n,t,te)){Y.success(e(i?`settings.skills.page.toast.fileUpdated`:`settings.skills.page.toast.fileCreated`,{path:t})),U(!1),ae(null);let a=await r(n);a&&j(a.sources.md.supportingFiles||[])}else Y.error(e(i?`settings.skills.page.toast.updateFileFailed`:`settings.skills.page.toast.createFileFailed`))},De=t=>{if(p){N(e=>e.filter(e=>e.path!==t)),Y.success(e(`settings.skills.page.toast.fileRemoved`,{path:t}));return}n&&de(t)};return!n&&!o||m?(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-4`,children:(0,$.jsxs)(`div`,{className:`text-center text-muted-foreground`,children:[(0,$.jsx)(X,{name:`book-open`,className:`mx-auto mb-3 h-10 w-10 sm:h-12 sm:w-12 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.skills.page.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:e(`settings.skills.page.empty.description`)})]})}):I?(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-4`,children:(0,$.jsx)(`div`,{className:`text-center text-muted-foreground`,children:(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.skills.page.loading.details`)})})}):(0,$.jsxs)(Ur,{outerClassName:`h-full`,className:`w-full`,children:[(0,$.jsxs)(`div`,{className:`yuri-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsx)(Gi,{actions:(0,$.jsx)(q,{onClick:Ce,disabled:h||P||!me,size:`sm`,"aria-busy":P,children:e(P?`settings.common.actions.saving`:p?`settings.skills.page.actions.createSkill`:`settings.common.actions.saveChanges`)}),children:(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate flex items-center gap-2`,children:p?e(`settings.skills.page.title.newSkill`):n}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground truncate`,children:f?e(`settings.skills.page.subtitle.skillLocation`,{location:ge(Tu(f.scope,f.source))}):e(`settings.skills.page.subtitle.newSkill`)})]})}),(0,$.jsx)(`div`,{"data-settings-item":`skills.basic-information`,children:(0,$.jsx)(Z,{label:e(`settings.skills.page.section.basicInformation`),cardClassName:`p-3`,children:(0,$.jsxs)(`div`,{className:`space-y-3`,children:[p&&(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.skills.page.field.skillNameLocation`)}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground ml-2`,children:e(`settings.skills.page.field.skillNameHint`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mt-1.5`,children:[(0,$.jsx)(Cn,{value:g,onChange:e=>_(e.target.value.toLowerCase().replace(/\s+/g,`-`)),placeholder:e(`settings.skills.page.field.skillNamePlaceholder`),className:`h-7 w-40 px-2`}),(0,$.jsxs)(Fr,{value:Tu(v,b),onValueChange:e=>{let t=Eu(e);y(t.scope),x(t.source===`agents`?`agents`:`opencode`)},children:[(0,$.jsxs)(Pr,{className:`w-fit gap-1.5`,children:[v===`user`?(0,$.jsx)(X,{name:`user-3`,className:`h-3.5 w-3.5`}):(0,$.jsx)(X,{name:`folder`,className:`h-3.5 w-3.5`}),b===`agents`?(0,$.jsx)(X,{name:`robot-2`,className:`h-3.5 w-3.5`}):null,(0,$.jsx)(`span`,{children:ge(Tu(v,b))})]}),(0,$.jsx)(Nr,{align:`start`,children:wu.map(e=>(0,$.jsx)(jr,{value:e.value,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.scope===`user`?(0,$.jsx)(X,{name:`user-3`,className:`h-3.5 w-3.5`}):(0,$.jsx)(X,{name:`folder`,className:`h-3.5 w-3.5`}),e.source===`agents`?(0,$.jsx)(X,{name:`robot-2`,className:`h-3.5 w-3.5`}):null,(0,$.jsx)(`span`,{children:ge(e.value)})]}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground ml-6`,children:_e(e.value)})]})},e.value))})]})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`span`,{className:`typography-ui-label text-foreground`,children:[e(`settings.common.field.description`),` `,(0,$.jsx)(`span`,{className:`text-[var(--status-error)]`,children:`*`})]}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground ml-2`,children:e(`settings.skills.page.field.descriptionHint`)}),(0,$.jsx)(`div`,{className:`mt-1.5`,children:(0,$.jsx)(Wr,{embedded:!0,value:S,onChange:e=>xe(e.target.value),placeholder:e(`settings.skills.page.field.descriptionPlaceholder`),rows:2,className:`w-full resize-none min-h-[60px] max-h-32 bg-transparent`,disabled:h})})]})]})})}),(0,$.jsx)(`div`,{"data-settings-item":`skills.instructions`,children:(0,$.jsx)(Z,{label:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{children:e(`settings.skills.page.section.instructions`)}),(0,$.jsx)(ci,{currentMode:O===`preview`?`preview`:`edit`,onToggle:()=>k(e=>e===`preview`?`edit`:`preview`)})]}),children:(0,$.jsx)(`div`,{className:K(`overflow-hidden bg-background`,Lu),children:O===`preview`?(0,$.jsx)(Ur,{outerClassName:`h-full`,className:`h-full`,children:(0,$.jsx)(`div`,{className:`min-h-full px-4 py-3`,children:(0,$.jsx)(zr,{content:E,className:`typography-markdown-body`,stripFrontmatter:!0,enableFileReferences:!1})})}):(0,$.jsx)(Zr,{value:E,onChange:Se,readOnly:h,extensions:ye,className:`h-full`,enableSearch:!0})})})}),(0,$.jsx)(`div`,{"data-settings-item":`skills.supporting-files`,children:(0,$.jsx)(Z,{label:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{children:e(`settings.skills.page.section.supportingFiles`)}),(0,$.jsxs)(q,{variant:`outline`,size:`xs`,className:`!font-normal gap-1`,onClick:we,disabled:h,children:[(0,$.jsx)(X,{name:`add`,className:`h-3.5 w-3.5`}),` `,e(`settings.skills.page.actions.addFile`)]})]}),cardClassName:`p-3`,children:(()=>{let t=p?M:A;return t.length===0?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground py-1.5`,children:e(`settings.skills.page.supportingFiles.empty`)}):(0,$.jsx)(`div`,{className:`divide-y divide-[var(--surface-subtle)]`,children:t.map(t=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2 py-1.5 cursor-pointer group`,onClick:()=>Te(t.path),children:[(0,$.jsx)(X,{name:`file`,className:`h-3.5 w-3.5 text-muted-foreground flex-shrink-0`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:t.path}),p&&(0,$.jsx)(`span`,{className:`typography-micro text-[var(--status-warning)] bg-[var(--status-warning)]/10 px-1.5 py-0.5 rounded flex-shrink-0`,children:e(`settings.skills.page.badge.pending`)}),!h&&(0,$.jsx)(q,{size:`sm`,variant:`ghost`,className:`h-5 w-5 px-0 flex-shrink-0 text-muted-foreground hover:text-[var(--status-error)] opacity-0 group-hover:opacity-100 transition-opacity`,onClick:e=>{e.stopPropagation(),De(t.path)},children:(0,$.jsx)(X,{name:`delete-bin`,className:`h-3 w-3`})})]},t.path))})})()})})]}),(0,$.jsx)(gn,{open:ue!==null,onOpenChange:e=>{!e&&!fe&&de(null)},children:(0,$.jsxs)(pn,{className:`max-w-md`,children:[(0,$.jsxs)(dn,{children:[(0,$.jsx)(mn,{children:e(`settings.skills.page.deleteFileDialog.title`)}),(0,$.jsx)(hn,{children:e(`settings.skills.page.deleteFileDialog.description`,{path:ue??``})})]}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(q,{size:`sm`,variant:`ghost`,onClick:()=>de(null),disabled:fe,children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(q,{size:`sm`,variant:`destructive`,onClick:async()=>{if(!ue||!n)return;pe(!0);let{deleteSupportingFile:t}=so.getState();if(await t(n,ue)){Y.success(e(`settings.skills.page.toast.fileDeleted`,{path:ue}));let t=await r(n);t&&j(t.sources.md.supportingFiles||[]),de(null)}else Y.error(e(`settings.skills.page.toast.deleteFileFailed`));pe(!1)},disabled:fe,children:e(`settings.common.actions.delete`)})]})]})}),(0,$.jsx)(gn,{open:H,onOpenChange:e=>{U(e),e||ae(null)},children:(0,$.jsxs)(pn,{className:`max-w-3xl max-h-[85vh] flex flex-col`,children:[(0,$.jsx)(Gi,{className:`pr-8`,actions:(0,$.jsx)(q,{size:`sm`,onClick:Ee,disabled:oe||!he,children:e(ie?`settings.common.actions.saveChanges`:`settings.skills.page.actions.createFile`)}),children:(0,$.jsxs)(dn,{className:`flex-shrink-0`,children:[(0,$.jsx)(mn,{children:e(ie?`settings.skills.page.fileDialog.titleEdit`:`settings.skills.page.fileDialog.titleAdd`)}),(0,$.jsx)(hn,{children:e(ie?`settings.skills.page.fileDialog.descriptionEdit`:`settings.skills.page.fileDialog.descriptionAdd`)})]})}),oe?(0,$.jsx)(`div`,{className:`flex-1 flex items-center justify-center py-8`,children:(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:e(`settings.skills.page.loading.fileContent`)})}):(0,$.jsxs)(`div`,{className:`space-y-4 flex-1 min-h-0 flex flex-col pt-2`,children:[(0,$.jsxs)(`div`,{className:`space-y-2 flex-shrink-0`,children:[(0,$.jsx)(`label`,{className:`typography-ui-label font-medium text-foreground`,children:e(`settings.skills.page.fileDialog.field.filePath`)}),(0,$.jsx)(Cn,{value:W,onChange:e=>ee(e.target.value),placeholder:e(`settings.skills.page.fileDialog.field.filePathPlaceholder`),className:`text-foreground placeholder:text-muted-foreground focus-visible:ring-[var(--primary-base)]`,disabled:ie!==null}),!ie&&(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground`,children:e(`settings.skills.page.fileDialog.field.filePathHint`)})]}),(0,$.jsxs)(`div`,{className:`space-y-2 flex-1 min-h-0 flex flex-col`,children:[(0,$.jsx)(`label`,{className:`typography-ui-label font-medium text-foreground flex-shrink-0`,children:e(`settings.skills.page.fileDialog.field.content`)}),(0,$.jsx)(`div`,{className:`h-[45vh] min-h-[250px] max-h-[55vh] overflow-hidden rounded-md border border-[var(--surface-subtle)] bg-background`,children:(0,$.jsx)(Zr,{value:te,onChange:re,extensions:be,className:`h-full`,enableSearch:!0})})]})]}),(0,$.jsx)(fn,{className:`mt-4`,children:(0,$.jsx)(q,{size:`sm`,variant:`ghost`,onClick:()=>{U(!1),ae(null)},children:e(`settings.common.actions.cancel`)})})]})})]})},Uu=e=>{let t=(0,Sa.c)(2),{view:n}=e,r=n===void 0?`installed`:n,i;return t[0]===r?i=t[1]:(i=r===`catalog`?(0,$.jsx)(Fu,{}):(0,$.jsx)(Hu,{}),t[0]=r,t[1]=i),i};function Wu(){}var Gu=e=>{let t=(0,Sa.c)(26),{onItemSelect:n}=e,{t:r}=Ge(),i=Qt(Ku),a=Qt(qu),o=G(Ju),s=G(Yu),c=Q.useRef(null),l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=new Set,t[0]=l):l=t[0];let u=Q.useRef(l),d;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(d=g(),t[1]=d):d=t[1];let f=d,p=Xu,m,h;t[2]!==a||t[3]!==i||t[4]!==o||t[5]!==s?(m=()=>{let e=new Set(i.map(Zu)),t=c.current;if(t)for(let n of e)t.has(n)||u.current.add(n);if(c.current=e,a&&u.current.delete(a)){s(a);return}if(i.length===0){o!==null&&s(null);return}o&&i.some(e=>e.id===o)||s(i[0].id)},h=[a,i,o,s],t[2]=a,t[3]=i,t[4]=o,t[5]=s,t[6]=m,t[7]=h):(m=t[6],h=t[7]),Q.useEffect(m,h);let _;t[8]!==i.length||t[9]!==r?(_=r(`settings.projects.sidebar.total`,{count:i.length}),t[8]=i.length,t[9]=r,t[10]=_):_=t[10];let v;t[11]===_?v=t[12]:(v=(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:_}),t[11]=_,t[12]=v);let y;t[13]===r?y=t[14]:(y=!f&&(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`icon`,className:`h-7 w-7 -my-1 text-muted-foreground`,onClick:p,"aria-label":r(`settings.projects.sidebar.actions.addProject`),children:(0,$.jsx)(X,{name:`add`,className:`size-4`})}),t[13]=r,t[14]=y);let b;t[15]!==v||t[16]!==y?(b=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2 px-[var(--yuri-settings-row-inset)]`,children:[v,y]}),t[15]=v,t[16]=y,t[17]=b):b=t[17];let x;t[18]!==n||t[19]!==i||t[20]!==o||t[21]!==s?(x=i.length>0?(0,$.jsx)(Z,{children:i.map(e=>{let t=e.id===o,r=e.icon?Kr[e.icon]:null,i=e.color?qr[e.color]:void 0,a=(0,$.jsx)(X,{name:r??`folder`,className:`h-4 w-4`,style:i?{color:i}:void 0}),c=(0,$.jsx)(`span`,{className:K(`flex size-5 shrink-0 items-center justify-center overflow-hidden`,t?`text-foreground`:`text-muted-foreground`),children:e.iconImage?(0,$.jsx)(Gr,{project:e,className:`size-full object-contain`,fallback:a}):a});return(0,$.jsx)(ps,{title:e.path.split(/[\\/]/).filter(Boolean).at(-1)||e.path,icon:c,selected:t,onSelect:()=>{s(e.id),n?.()}},e.id)})}):null,t[18]=n,t[19]=i,t[20]=o,t[21]=s,t[22]=x):x=t[22];let S;return t[23]!==b||t[24]!==x?(S=(0,$.jsx)(hs,{variant:`background`,header:b,children:x}),t[23]=b,t[24]=x,t[25]=S):S=t[25],S};function Ku(e){return e.projects}function qu(e){return e.activeProjectId}function Ju(e){return e.settingsProjectsSelectedId}function Yu(e){return e.setSettingsProjectsSelectedId}function Xu(){Yt.requestDirectoryDialog()}function Zu(e){return e.id}var Qu=()=>{let e=(0,Sa.c)(18),{t}=Ge(),n=Qt($u),r=Qt(ed),i=G(td),a=G(nd),o;bb0:{if(!i){o=null;break bb0}let t;e[0]!==n||e[1]!==i?(t=n.find(e=>e.id===i)??null,e[0]=n,e[1]=i,e[2]=t):t=e[2],o=t}let s=o,c,l;e[3]!==n||e[4]!==i||e[5]!==a?(c=()=>{if(n.length===0){a(null);return}i&&n.some(e=>e.id===i)||a(n[0].id)},l=[n,i,a],e[3]=n,e[4]=i,e[5]=a,e[6]=c,e[7]=l):(c=e[6],l=e[7]),Q.useEffect(c,l);let u;e[8]!==s||e[9]!==r?(u=async e=>{s&&r(s.id,{label:e.label,icon:e.icon,color:e.color,iconBackground:e.iconBackground,defaultModel:e.defaultModel??null})},e[8]=s,e[9]=r,e[10]=u):u=e[10];let d=u;if(!s){let n;e[11]===t?n=e[12]:(n=t(`settings.projects.page.empty.noProjects`),e[11]=t,e[12]=n);let r;return e[13]===n?r=e[14]:(r=(0,$.jsx)(Ur,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsx)(`div`,{className:`mx-auto w-full max-w-4xl p-3 sm:p-6 sm:pt-8`,children:(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:n})})}),e[13]=n,e[14]=r),r}let f;return e[15]!==d||e[16]!==s?(f=(0,$.jsx)(Ur,{outerClassName:`h-full`,className:`w-full bg-background`,children:(0,$.jsx)(`div`,{className:`mx-auto w-full max-w-4xl p-3 sm:p-6 sm:pt-8`,children:(0,$.jsx)(Mi,{project:s,onIdentitySave:d})})}),e[15]=d,e[16]=s,e[17]=f):f=e[17],f};function $u(e){return e.projects}function ed(e){return e.updateProjectMeta}function td(e){return e.settingsProjectsSelectedId}function nd(e){return e.setSettingsProjectsSelectedId}var rd={justNowMinutes:1,minutes:60,hours:24,days:30,months:12},id=6e4,ad=60*id,od=24*ad,sd=30*od;function cd(e,t={}){if(typeof e!=`number`||!Number.isFinite(e))return``;let n=t.now??Date.now(),r=t.buckets??rd,i=e-n,a=Math.abs(i),o=new Intl.RelativeTimeFormat(t.locale,{numeric:`auto`});return a<r.justNowMinutes*id?o.format(0,`second`):a<r.minutes*id?o.format(Math.round(i/id),`minute`):a<r.hours*ad?o.format(Math.round(i/ad),`hour`):a<r.days*od?o.format(Math.round(i/od),`day`):a<r.months*sd?o.format(Math.round(i/sd),`month`):o.format(Math.round(i/(12*sd)),`year`)}var ld=`relay_identity_changed`,ud=class extends Error{code=ld;expectedServerId;actualServerId;constructor(e,t){super(`Relay identity changed (expected ${e}, got ${t||`unknown`})`),this.name=`RelayIdentityChangedError`,this.expectedServerId=e,this.actualServerId=t}},dd=new Map,fd=e=>{let t=e.trim();if(!t)throw Error(`Relay serverId is required`);return`relay:${t}`},pd=e=>{let t={Accept:`application/json`},n=typeof e.clientToken==`string`?e.clientToken.trim():``;if(n&&(t.Authorization=`Bearer ${n}`),e.requestHeaders)for(let[n,r]of Object.entries(e.requestHeaders))!n.trim()||!r.trim()||n.trim().toLowerCase()!==`authorization`&&(t[n.trim()]=r.trim());return t},md=e=>({files:e?.files?.length??0,directories:e?.directories?.length??0,deletes:e?.deletes?.length??0,totalBytes:e?.totalBytes??0}),hd=async e=>{D()&&await k(`desktop_sync_runs_append`,{record:e})},gd=async(e,t)=>{if(!t)return;let n=await t().catch(()=>null),r=typeof n?.serverId==`string`?n.serverId.trim():``;if(r&&r!==e)throw new ud(e,r)},_d=e=>({ok:!0,files:0,directories:0,deletes:e.deletes.length,totalBytes:0,agentsRoot:null,providerCredentials:null,plan:e}),vd=e=>{let t=e?.selectionShape;if(!t)throw Error(`Local sync inventory missing selectionShape (update the Yuri desktop app)`);return t},yd=(e,t)=>{let n=Fn(e,{includeProviderCredentials:!1}),r=t.selections;return{fileGroups:r?.fileGroups??n.fileGroups,singleFiles:r?.singleFiles??n.singleFiles,directories:r?.directories??n.directories,agentsRoot:r?.agentsRoot!==!1,providerCredentials:r?.providerCredentials===!0,magpie:r?.magpie===!0}},bd=(e,t,n)=>{let r=e.inventory&&typeof e.inventory==`object`?e.inventory:null;if(n.providerCredentials&&(!r||!Object.hasOwn(r,`providerCredentials`)))throw Error(`Provider credential inventory is missing`);if(n.magpie&&!r?.magpie?.available)throw Error(`Magpie source configuration is unavailable`);return{direction:`pull`,magpieAvailable:r?.magpie?.available===!0,magpie:n.magpie&&r?.magpie?.available?{bytes:0}:null,files:r?.files??t?.files??[],directories:r?.directories??t?.directories??[],agentsRoot:n.agentsRoot?r?.agentsRoot??null:null,providerCredentials:n.providerCredentials?r?.providerCredentials??null:null,deletes:t?.deletes??[],totalBytes:t?.totalBytes??0,selections:n}},xd=(e,t)=>({...e,direction:`push`,providerCredentials:t.providerCredentials?e.providerCredentials:null,magpie:t.magpie?e.magpie:null,agentsRoot:t.agentsRoot?e.agentsRoot:null,selections:t}),Sd=e=>e.files.length>0||e.directories.length>0||!!e.agentsRoot||!!e.providerCredentials||!!e.magpie,Cd=(e,t)=>{let r=n({relayUrl:e.relayUrl,serverId:e.serverId,hostEncPubJwk:e.hostEncPubJwk}),i=pd(t),a=async(e,t,n)=>{let a=await r.fetch(t,{method:e,headers:{...i,...n===void 0?{}:{"Content-Type":`application/json`}},body:n===void 0?void 0:JSON.stringify(n)}),o=await a.json().catch(()=>({}));if(!a.ok){let n=Error(typeof o.error==`string`?o.error:`Relay sync ${e} ${t} failed (${a.status})`);throw typeof o.code==`string`&&(n.code=o.code),n}return o};return{tunnel:r,async probe(e){let t=await a(`POST`,`/api/yuri/config-sync/probe`,{plan:e});return{remoteExisting:Array.isArray(t.remoteExisting)?t.remoteExisting:[],remoteAgentsRootExists:t.remoteAgentsRootExists===!0,remoteProviderCredentialsExists:t.remoteProviderCredentialsExists===!0,inventory:t.inventory}},async prepare(e,t){await a(`POST`,`/api/yuri/config-sync/prepare`,{plan:e,syncRunId:t})},async putTar(e,t,n){let a=await r.fetch(`/api/yuri/config-sync/put/${encodeURIComponent(e)}?syncRunId=${encodeURIComponent(n)}`,{method:`PUT`,headers:{...i,"Content-Type":e===`credentials`||e===`magpie`?`application/octet-stream`:`application/gzip`},body:new Blob([new Uint8Array(t)],{type:e===`credentials`||e===`magpie`?`application/octet-stream`:`application/gzip`})}),o=await a.json().catch(()=>({}));if(!a.ok){let t=Error(typeof o.error==`string`?o.error:`Relay sync put ${e} failed (${a.status})`);throw typeof o.code==`string`&&(t.code=o.code),t}},async download(e){let t=await r.fetch(`/api/yuri/config-sync/download/${encodeURIComponent(e)}`,{method:`GET`,headers:i});if(!t.ok){let n=await t.json().catch(()=>({})),r=Error(typeof n.error==`string`?n.error:`Relay sync download ${e} failed (${t.status})`);throw typeof n.code==`string`&&(r.code=n.code),r}return new Uint8Array(await t.arrayBuffer())},async finalize(e){let t=await a(`POST`,`/api/yuri/config-sync/finalize`,{syncRunId:e});return Array.isArray(t.magpieWarnings)?t.magpieWarnings.filter(e=>e===`sign_in_required`||e===`plugin_install_failed`||e===`agent_settings_skipped`):[]},async abort(e){await a(`POST`,`/api/yuri/config-sync/abort`,{syncRunId:e}).catch(()=>void 0)},close(){r.close()}}},wd=async(e,t,n,r)=>{if(dd.has(e)){let t=Error(`Config sync already in progress for ${e}`);throw t.code=`sync_in_progress`,t}let i=crypto.randomUUID(),a=new Date().toISOString();dd.set(e,i);try{let o=await r({syncRunId:i});return await hd({syncRunId:i,targetId:e,stage:t,direction:n,startedAt:a,endedAt:new Date().toISOString(),result:`success`,summary:md(o.plan)}),{...o,syncRunId:i}}catch(r){throw await hd({syncRunId:i,targetId:e,stage:t,direction:n,startedAt:a,endedAt:new Date().toISOString(),result:`failure`,summary:md(null),error:r instanceof Error?r.message:String(r)}).catch(()=>void 0),r}finally{dd.get(e)===i&&dd.delete(e)}},Td=async(e,t)=>{let n=await zn({direction:e,targetKind:`relay`}),r=vd(n),i=yd(r,t),a=e===`push`?await zn({direction:e,selections:i,targetKind:`relay`}):n;if(e===`push`&&!a)throw Error(`Local sync inventory unavailable`);return{selectionShape:r,selections:i,localPlan:a}},Ed=async(e,t={},n={})=>{let r=e.relay,i=fd(r.serverId),a=t.direction===`pull`?`pull`:`push`;return wd(i,`preview`,a,async()=>{await gd(r.serverId,n.refreshCandidates);let{selectionShape:i,selections:o,localPlan:s}=await Td(a,t),c=Cd(r,e);try{if(a===`pull`){let e=await c.probe({selections:o});return{plan:bd(e,s,o),remoteExisting:e.remoteExisting,remoteAgentsRootExists:e.remoteAgentsRootExists,remoteProviderCredentialsExists:e.remoteProviderCredentialsExists,selectionShape:i}}let e=xd(s,o),t=await c.probe(e);return{plan:e,remoteExisting:t.remoteExisting,remoteAgentsRootExists:t.remoteAgentsRootExists,remoteProviderCredentialsExists:t.remoteProviderCredentialsExists,selectionShape:s?.selectionShape??i}}finally{c.close()}})},Dd=async(e,t={},n={})=>{let r=e.relay,i=fd(r.serverId),a=t.direction===`pull`?`pull`:`push`;return wd(i,`apply`,a,async({syncRunId:i})=>{await gd(r.serverId,n.refreshCandidates);let{selections:o,localPlan:s}=await Td(a,t),c=Cd(r,e);try{if(a===`pull`){let e=bd(await c.probe({selections:o}),s,o);if(!Sd(e))return _d(e);let t=e.files.length>0||e.directories.length>0?await c.download(`config`):null,n=e.agentsRoot?await c.download(`agents`):null,r=e.providerCredentials?await c.download(`credentials`):null,a=e.magpie?await c.download(`magpie`):null;if(!D())throw Error(`Relay pull apply requires the Yuri desktop app`);let l=await k(`desktop_relay_sync_apply_local`,{syncRunId:i,plan:e,configTar:t,agentsTar:n,credentialPayload:r,magpiePayload:a});if(!l?.ok)throw Error(`Relay pull local apply failed`);return{...l,plan:e}}let e=xd(s,o);if(!Sd(e))return _d(e);if(!D())throw Error(`Relay push apply requires the Yuri desktop app`);let t=await k(`desktop_relay_sync_pack_local`,{plan:e});if(!t)throw Error(`Relay push local pack failed`);await c.prepare(e,i);let n=[];try{if(e.magpie){if(!t.magpiePayload?.byteLength)throw Error(`Magpie transfer incomplete`);await c.putTar(`magpie`,t.magpiePayload,i)}t.configTar&&t.configTar.byteLength>0&&await c.putTar(`config`,t.configTar,i),t.agentsTar&&t.agentsTar.byteLength>0&&await c.putTar(`agents`,t.agentsTar,i),t.credentialPayload&&t.credentialPayload.byteLength>0&&await c.putTar(`credentials`,t.credentialPayload,i),n=await c.finalize(i)}catch(e){throw await c.abort(i),e}return{ok:!0,files:e.files.length,directories:e.directories.length,deletes:e.deletes.length,totalBytes:e.totalBytes,agentsRoot:e.agentsRoot?{fileCount:e.agentsRoot.fileCount}:null,providerCredentials:e.providerCredentials?{bytes:e.providerCredentials.bytes}:null,...n.length?{magpieWarnings:n}:{},plan:e}}finally{c.close()}})},Od=()=>{let{t:e}=Ge(),t=h()&&O(),[n,r]=Q.useState(!1),[i,a]=Q.useState(!1),[o,s]=Q.useState(``),[u,d]=Q.useState(``),[f,p]=Q.useState(!1),[g,_]=Q.useState(null),[v,y]=Q.useState(!0),[x,S]=Q.useState(!1),[C,w]=Q.useState(null),[T,E]=Q.useState(null);Q.useEffect(()=>{if(!t){y(!1);return}let n=!1;return(async()=>{try{let t=await l(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});if(!t.ok)throw Error(e(`settings.yuri.desktopNetwork.error.loadFailed`));let i=await t.json().catch(()=>null);if(n)return;let o=i?.desktopLanAccessEnabled===!0,c=typeof i?.desktopUiPassword==`string`?i.desktopUiPassword:``;r(o),a(o),s(c),d(c),p(i?.desktopLanAccessActive===!0),_(typeof i?.desktopLanAccessBlockedReason==`string`?i.desktopLanAccessBlockedReason:null),w(null)}catch(t){n||w(t instanceof Error?t.message:e(`settings.yuri.desktopNetwork.error.loadFailed`))}finally{n||y(!1)}})(),()=>{n=!0}},[t,e]),Q.useEffect(()=>{if(!t||!i){E(null);return}let e=!1;return(async()=>{let t=await b();e||E(t)})(),()=>{e=!0}},[i,t]);let D=i!==n||u!==o,k=Q.useMemo(()=>{if(typeof window>`u`)return null;let e=c()||window.location.href,t=0;try{t=Number(new URL(e).port)}catch{t=Number(window.location.port)}return Number.isFinite(t)&&t>0?t:null},[]),A=i&&f&&T&&k?`http://${T}:${k}`:null,j=i&&!u.trim(),M=n&&!f&&g===`missing-password`,N=v||x||!D||j,P=Q.useCallback(()=>{a(e=>!e)},[]),F=Q.useCallback(e=>{d(e),e.trim()||a(!1)},[]),I=Q.useCallback(async()=>{if(D){S(!0),w(null);try{if(!(await l(`/api/config/settings`,{method:`PUT`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({desktopLanAccessEnabled:i,desktopUiPassword:u})})).ok)throw Error(e(`settings.yuri.desktopNetwork.error.saveFailed`));if(r(i),s(u),!await m())throw Error(e(`settings.yuri.desktopNetwork.error.savedRestartFailed`))}catch(t){w(t instanceof Error?t.message:e(`settings.yuri.desktopNetwork.error.saveFailed`)),S(!1)}}},[u,i,D,e]);return t?(0,$.jsxs)(Z,{className:`yuri-settings-detail-group`,label:e(`settings.yuri.desktopNetwork.title`),actions:(0,$.jsx)(q,{type:`button`,size:`xs`,className:`!font-normal`,onClick:I,disabled:N,"aria-busy":x,children:e(x?`settings.common.actions.saving`:`settings.yuri.desktopNetwork.actions.saveAndRestart`)}),children:[(0,$.jsx)(Xi,{itemId:`remote-instances.desktop-ui-password`,label:(0,$.jsx)(`label`,{htmlFor:`desktop-ui-password`,children:e(`settings.yuri.desktopPassword.field.password`)}),description:e(`settings.yuri.desktopPassword.field.passwordDescription`),children:(0,$.jsx)(Cn,{id:`desktop-ui-password`,type:`password`,className:`max-w-sm`,value:u,onChange:e=>F(e.target.value),placeholder:e(`settings.yuri.desktopPassword.field.passwordPlaceholder`),disabled:v||x,required:i,"aria-invalid":j})}),(0,$.jsxs)(`div`,{"data-settings-item":`remote-instances.desktop-lan-access`,className:`yuri-settings-group-row yuri-settings-split-row group cursor-pointer`,role:`button`,tabIndex:0,onClick:P,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),P())},children:[(0,$.jsxs)(`div`,{className:`yuri-settings-split-row-copy`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:e(`settings.yuri.desktopNetwork.field.allowLanAccess`)}),(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:e(`settings.yuri.desktopNetwork.field.allowLanAccessDescription`)}),(0,$.jsx)(`div`,{className:`typography-meta text-[var(--status-warning)]/85`,children:e(`settings.yuri.desktopNetwork.field.warning`)}),j||M?(0,$.jsx)(`div`,{className:`typography-meta text-[var(--status-warning)]/85`,children:e(`settings.yuri.desktopNetwork.field.passwordRequiredWarning`)}):null]}),(0,$.jsx)(`div`,{className:`yuri-settings-split-row-control`,children:(0,$.jsx)(Wi,{checked:i,onChange:P,ariaLabel:e(`settings.yuri.desktopNetwork.field.allowLanAccessAria`),disabled:v||x})})]}),C?(0,$.jsx)(`div`,{className:`yuri-settings-group-row typography-meta text-[var(--status-error)]`,children:C}):null,A?(0,$.jsxs)(`div`,{className:`yuri-settings-group-row typography-meta text-muted-foreground`,children:[e(D&&!n?`settings.yuri.desktopNetwork.hint.openAfterRestart`:`settings.yuri.desktopNetwork.hint.openNow`),(0,$.jsx)(`span`,{className:`font-mono text-foreground`,children:A})]}):null]}):null},kd=(e,t)=>{if(e!==i()||t!==o())throw Error(`runtime_changed`)},Ad=(e,t)=>({queryKey:[e,`remote-desktop-setup`,t],queryFn:async({signal:n})=>{kd(e,t),n.throwIfAborted();let r=await x({type:`status`});return n.throwIfAborted(),kd(e,t),r},retry:!1,refetchOnWindowFocus:`always`});function jd(){let e=(0,Sa.c)(10),t,n,r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=i(),t=o(),n=Ad(r,t),e[0]=t,e[1]=n,e[2]=r):(t=e[0],n=e[1],r=e[2]);let a=n,s=we(),c=De(a),l,u;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=[r,`remote-desktop-setup-action`,t],u=async e=>{kd(r,t);let n=await x(e);return kd(r,t),n},e[3]=l,e[4]=u):(l=e[3],u=e[4]);let d;e[5]===s?d=e[6]:(d={mutationKey:l,mutationFn:u,onSuccess:e=>{r===i()&&t===o()&&(s.setQueryData(a.queryKey,e),s.invalidateQueries({queryKey:[r,`remote-desktop`,t]}))},onError:()=>{r===i()&&t===o()&&s.invalidateQueries({queryKey:a.queryKey})}},e[5]=s,e[6]=d);let f=Te(d),p;return e[7]!==f||e[8]!==c?(p={query:c,mutation:f},e[7]=f,e[8]=c,e[9]=p):p=e[9],p}function Md(){let e=(0,Sa.c)(50),{t}=Ge(),{query:n,mutation:r}=jd(),i;e[0]!==r.isPending||e[1]!==n?(i=()=>{r.isPending||n.refetch({cancelRefetch:!1})},e[0]=r.isPending,e[1]=n,e[2]=i):i=e[2],Ve(`focus`,i,Nd);let a=n.data,o=r.isPending||n.isFetching,s;e[3]===t?s=e[4]:(s=e=>t(e===void 0?`common.loading`:e?`settings.remoteDesktop.granted`:`settings.remoteDesktop.required`),e[3]=t,e[4]=s);let c=s,l;e[5]===t?l=e[6]:(l=t(`remoteDesktop.title`),e[5]=t,e[6]=l);let u;e[7]===t?u=e[8]:(u=t(`settings.remoteDesktop.devices`),e[7]=t,e[8]=u);let d;e[9]!==r||e[10]!==n?(d=()=>{r.reset(),n.refetch()},e[9]=r,e[10]=n,e[11]=d):d=e[11];let f;e[12]===t?f=e[13]:(f=t(`settings.remoteDesktop.recheck`),e[12]=t,e[13]=f);let p;e[14]!==o||e[15]!==d||e[16]!==f?(p=(0,$.jsx)(q,{size:`xs`,className:`!font-normal`,disabled:o,onClick:d,children:f}),e[14]=o,e[15]=d,e[16]=f,e[17]=p):p=e[17];let m;e[18]===t?m=e[19]:(m=t(`settings.remoteDesktop.enable`),e[18]=t,e[19]=m);let h;e[20]===t?h=e[21]:(h=t(`settings.remoteDesktop.enable`),e[20]=t,e[21]=h);let g;e[22]===t?g=e[23]:(g=t(`settings.remoteDesktop.description`),e[22]=t,e[23]=g);let _=a?.enabled===!0,v=o||!a||!a.enabled&&!a.ready,y;e[24]===r?y=e[25]:(y=e=>r.mutate({type:`enabled`,enabled:e}),e[24]=r,e[25]=y);let b;e[26]!==_||e[27]!==v||e[28]!==y||e[29]!==m||e[30]!==h||e[31]!==g?(b=(0,$.jsx)(Ji,{itemId:`remote-instances.remote-desktop`,label:m,ariaLabel:h,description:g,checked:_,disabled:v,onChange:y}),e[26]=_,e[27]=v,e[28]=y,e[29]=m,e[30]=h,e[31]=g,e[32]=b):b=e[32];let x;e[33]!==o||e[34]!==r||e[35]!==c||e[36]!==a||e[37]!==t?(x=a?.supported===!1?(0,$.jsx)(Xi,{label:t(`settings.remoteDesktop.status`),children:(0,$.jsx)(`span`,{children:t(`remoteDesktop.unsupported`)})}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Xi,{itemId:`remote-instances.remote-desktop-screen`,label:t(`settings.remoteDesktop.screen`),description:t(`settings.remoteDesktop.screenHint`),children:[(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:c(a?a.screenRecording===`granted`:void 0)}),a&&a.screenRecording!==`granted`&&(0,$.jsx)(q,{size:`sm`,disabled:o,onClick:()=>r.mutate({type:`permission`,permission:`screen`}),children:t(`settings.remoteDesktop.authorize`)})]}),(0,$.jsxs)(Xi,{itemId:`remote-instances.remote-desktop-accessibility`,label:t(`settings.remoteDesktop.accessibility`),description:t(`settings.remoteDesktop.accessibilityHint`),children:[(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:c(a?.accessibility)}),a&&!a.accessibility&&(0,$.jsx)(q,{size:`sm`,disabled:o,onClick:()=>r.mutate({type:`permission`,permission:`accessibility`}),children:t(`settings.remoteDesktop.authorize`)})]}),(0,$.jsx)(Xi,{label:t(`settings.remoteDesktop.helper`),description:t(`settings.remoteDesktop.helperHint`),children:(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:t(a?a.helperAvailable?`settings.remoteDesktop.installed`:`settings.remoteDesktop.reinstall`:`common.loading`)})})]}),e[33]=o,e[34]=r,e[35]=c,e[36]=a,e[37]=t,e[38]=x):x=e[38];let S;e[39]!==r.error||e[40]!==n.error||e[41]!==t?(S=(n.error||r.error)&&(0,$.jsx)(Xi,{label:t(`settings.remoteDesktop.status`),children:(0,$.jsx)(`span`,{role:`alert`,className:`typography-meta text-[var(--status-error)]`,children:t(`settings.remoteDesktop.failed`)})}),e[39]=r.error,e[40]=n.error,e[41]=t,e[42]=S):S=e[42];let C;return e[43]!==b||e[44]!==x||e[45]!==S||e[46]!==l||e[47]!==u||e[48]!==p?(C=(0,$.jsxs)(Z,{label:l,description:u,actions:p,children:[b,x,S]}),e[43]=b,e[44]=x,e[45]=S,e[46]=l,e[47]=u,e[48]=p,e[49]=C):C=e[49],C}function Nd(){return window}function Pd(){let e=(0,Sa.c)(1);if(!h()||!O())return null;let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(Md,{}),e[0]=t):t=e[0],t}var Fd=`wss://relay.useyuri.top/ws`,Id=`yuri.pairing.relayUrl.v1`,Ld=e=>{if(typeof e!=`string`||!e.trim())return null;try{let t=new URL(e.trim());return t.protocol!==`ws:`&&t.protocol!==`wss:`||t.username||t.password?null:(t.username=``,t.password=``,t.hash=``,t.search=``,t.toString())}catch{return null}},Rd=(e=typeof window>`u`?null:window.localStorage)=>{if(!e)return null;try{return Ld(e.getItem(Id))}catch{return null}},zd=(e,t=typeof window>`u`?null:window.localStorage)=>{if(!t)return;let n=Ld(e);if(n)try{t.setItem(Id,n)}catch{}},Bd=`https://github.com/yee94/yuri/tree/main/packages/relay-server`,Vd=()=>Math.floor(2e4+Math.random()*3e4),Hd=e=>{if(!Number.isFinite(e)||e<0)return`0 B`;if(e<1024)return`${e} B`;let t=[`KB`,`MB`,`GB`,`TB`],n=e/1024;for(let e of t){if(n<1024||e===t[t.length-1])return`${n.toFixed(n>=10?0:1)} ${e}`;n/=1024}return`${e} B`},Ud={fileGroups:[],singleFiles:[],directories:[],agentsRoot:!0,providerCredentials:!1},Wd=e=>{let t=e.selectionShape;if(!t||typeof t!=`object`)return null;let n=typeof t.fileGroups==`number`?t.fileGroups:null,r=typeof t.singleFiles==`number`?t.singleFiles:null,i=typeof t.directories==`number`?t.directories:null;return n===null||r===null||i===null||n<0||r<0||i<0?null:{fileGroups:n,singleFiles:r,directories:i}},Gd=(e,t)=>e.fileGroups.length===t.fileGroups&&e.singleFiles.length===t.singleFiles&&e.directories.length===t.directories,Kd=[`settings.remoteInstances.page.sync.step.scanLocal`,`settings.remoteInstances.page.sync.step.compareRemote`,`settings.remoteInstances.page.sync.step.confirm`],qd=({open:e,instanceId:t,targetKind:n=`ssh`,relayHost:r=null,onOpenChange:i})=>{let{t:a}=Ge(),[o,s]=Q.useState(1),[c,l]=Q.useState(`scanning-local`),[u,d]=Q.useState(`push`),[f,p]=Q.useState(Ud),[m,h]=Q.useState(null),[g,_]=Q.useState(null),[v,y]=Q.useState(null),[b,x]=Q.useState(null),[S,C]=Q.useState(null),w=Q.useRef(Ud),T=Q.useRef(0),E=Q.useRef(Promise.resolve()),D=m!=null&&Gd(f,m),O=He(()=>{T.current+=1,s(1),l(`scanning-local`),d(`push`),p(Ud),h(null),_(null),y(null),x(null),C(null),w.current=Ud}),k=He(async(e=u,i=f)=>{if(!t)return;let o=++T.current,c=E.current,d;E.current=new Promise(e=>{d=e}),v||s(2),l(`comparing-remote`),x(null),C(null);try{if(await c,o!==T.current)return;let u=n===`relay`?r?await Ed(r,{direction:e,selections:i}):null:await hr(t,{targetKind:n,direction:e,selections:i});if(o!==T.current)return;if(!u){x(a(`settings.remoteInstances.page.sync.state.unavailable`)),C(2),l(`error`);return}y(u),w.current=i,s(3),l(`review`)}catch(e){if(o!==T.current)return;console.error(`[remote-instances] config sync compare-remote failed`,e),x(e instanceof Error?e.message:String(e)),C(2),l(`error`)}finally{d()}}),A=He(async(e=u,r=f)=>{if(!t)return;s(1);let i=++T.current;l(`scanning-local`),x(null),C(null),_(null),y(null);try{let t=m!=null&&Gd(r,m),o=await zn(t?{targetKind:n,direction:e,selections:r}:{targetKind:n,direction:e});if(i!==T.current)return;if(!o){h(null),x(a(`settings.remoteInstances.page.sync.state.unavailable`)),C(1),l(`error`);return}let s=Wd(o);if(!s){h(null),p(Ud),x(a(`settings.remoteInstances.page.sync.state.unavailable`)),C(1),l(`error`);return}h(s);let c=t?r:Fn(s,{includeProviderCredentials:!1});p(c),_(o),await k(e,c)}catch(e){if(i!==T.current)return;console.error(`[remote-instances] config sync scan-local failed`,e),x(e instanceof Error?e.message:String(e)),C(1),l(`error`)}});Q.useEffect(()=>{if(!(!e||!t))return A(`push`),()=>{T.current+=1}},[e,t,n,r,A]),Q.useEffect(()=>{e||O()},[e,O]);let j=Q.useMemo(()=>new Set(v?.remoteExisting??[]),[v]),M=v?.plan??g,N=!!(M&&(M.files.length>0||M.directories.length>0||M.agentsRoot!=null||M.providerCredentials!=null||M.magpie!=null)),P=c===`applying`,F=v!=null,I=M?M.deletes.length+(M.agentsRoot&&v?.remoteAgentsRootExists?1:0):0,L=He(()=>{if(S===2){k(u,f);return}A(u,f)}),R=He(e=>{if(e===u||P)return;d(e),y(null),_(null);let t={...f,magpie:!1};p(t),A(e,t)}),z=He(async()=>{if(!(!t||!N||P||c!==`review`)){l(`applying`);try{let e=n===`relay`?r?await Dd(r,{direction:u,selections:w.current}):null:await In(t,{targetKind:n,direction:u,selections:w.current});if(!e)throw Error(`Sync bridge unavailable`);let o=[...e.magpieWarnings?.includes(`sign_in_required`)?[a(`settings.remoteInstances.page.sync.magpie.signInRequired`)]:[],...e.magpieWarnings?.includes(`plugin_install_failed`)?[a(`settings.remoteInstances.page.sync.magpie.pluginInstallFailed`)]:[],...e.magpieWarnings?.includes(`agent_settings_skipped`)?[a(`settings.remoteInstances.page.sync.magpie.agentsSkipped`)]:[]];o.length?Y.warning(a(`settings.remoteInstances.page.sync.toast.success`),{description:o.join(`
26
- `)}):Y.success(a(`settings.remoteInstances.page.sync.toast.success`)),i(!1)}catch(e){console.error(`[remote-instances] config sync apply failed`,e),Y.error(a(`settings.remoteInstances.page.sync.toast.failed`),{description:e instanceof Error?e.message:String(e)}),l(`review`)}}}),B=e=>c===`error`&&S!=null?e<S?`done`:e===S?`active`:`pending`:c===`review`||c===`applying`||e<o?`done`:e===o?`active`:`pending`;return(0,$.jsx)(gn,{open:e,onOpenChange:i,children:(0,$.jsxs)(pn,{className:`min-h-0 sm:max-w-2xl`,children:[(0,$.jsxs)(dn,{className:`shrink-0`,children:[(0,$.jsx)(mn,{children:a(`settings.remoteInstances.page.sync.title`)}),(0,$.jsx)(hn,{children:a(`settings.remoteInstances.page.sync.description`)})]}),(0,$.jsxs)(`div`,{className:`shrink-0 space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsx)(q,{type:`button`,size:`xs`,variant:u===`push`?`default`:`outline`,className:`!font-normal`,"aria-pressed":u===`push`,disabled:P||c===`comparing-remote`||c===`scanning-local`,onClick:()=>R(`push`),children:a(`settings.remoteInstances.page.sync.direction.push`)}),(0,$.jsx)(q,{type:`button`,size:`xs`,variant:u===`pull`?`default`:`outline`,className:`!font-normal`,"aria-pressed":u===`pull`,disabled:P||c===`comparing-remote`||c===`scanning-local`,onClick:()=>R(`pull`),children:a(`settings.remoteInstances.page.sync.direction.pull`)})]}),(0,$.jsxs)(Z,{label:a(`settings.remoteInstances.page.sync.scope.title`),children:[D?null:(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground`,children:a(c===`scanning-local`||c===`comparing-remote`?`settings.remoteInstances.page.sync.step.scanLocal`:`settings.remoteInstances.page.sync.state.unavailable`)}),[{key:`config`,label:`config.json / opencode.json(c)`,index:0,kind:`fileGroups`},{key:`agents-md`,label:`AGENTS.md`,index:0,kind:`singleFiles`},{key:`cursor-models`,label:`cursor-models.json`,index:1,kind:`singleFiles`},{key:`agents`,label:`agents/`,index:0,kind:`directories`},{key:`commands`,label:`commands/`,index:1,kind:`directories`},{key:`skills`,label:`skills/`,index:2,kind:`directories`},{key:`plugins`,label:`plugins/`,index:5,kind:`directories`}].filter(e=>m!=null&&e.index<m[e.kind]).map(e=>{let t=f[e.kind][e.index]!==!1;return(0,$.jsx)(Ji,{label:(0,$.jsx)(`span`,{className:`font-mono break-all`,children:e.label}),checked:t,disabled:P||!D||!v,ariaLabel:e.label,onChange:t=>{if(!D)return;let n=[...f[e.kind]];n[e.index]=t;let r={...f,[e.kind]:n};p(r),k(u,r)}},e.key)}),(0,$.jsx)(Ji,{label:a(`settings.remoteInstances.page.sync.section.agentsRoot`),checked:f.agentsRoot,disabled:P||!D||!v,ariaLabel:a(`settings.remoteInstances.page.sync.section.agentsRoot`),onChange:e=>{if(!D)return;let t={...f,agentsRoot:e};p(t),k(u,t)}}),(0,$.jsx)(Ji,{label:(0,$.jsx)(`span`,{title:a(`settings.remoteInstances.page.sync.hint.providerCredentials`),children:a(`settings.remoteInstances.page.sync.section.providerCredentials`)}),checked:f.providerCredentials,disabled:P||!D||!v,ariaLabel:a(`settings.remoteInstances.page.sync.section.providerCredentials`),onChange:e=>{if(!D)return;let t={...f,providerCredentials:e};p(t),k(u,t)}}),v?.plan.magpieAvailable?(0,$.jsx)(Ji,{label:(0,$.jsx)(`span`,{title:a(`settings.remoteInstances.page.sync.hint.magpie`),children:a(`settings.remoteInstances.page.sync.section.magpie`)}),checked:f.magpie===!0,disabled:P,ariaLabel:a(`settings.remoteInstances.page.sync.section.magpie`),onChange:e=>{let t={...f,magpie:e};p(t),k(u,t)}}):null]}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-2`,"aria-busy":c===`scanning-local`||c===`comparing-remote`,children:Kd.map((e,t)=>{let n=t+1,r=B(n);return(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[r===`done`?(0,$.jsx)(X,{name:`check`,className:`h-3.5 w-3.5 shrink-0 text-[var(--status-success)]`}):r===`active`?(0,$.jsx)(X,{name:`refresh`,className:`h-3.5 w-3.5 shrink-0 animate-spin text-muted-foreground`}):(0,$.jsx)(`span`,{className:`flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-full border border-border/60 typography-micro text-muted-foreground`,children:n}),(0,$.jsx)(`span`,{className:K(`typography-meta`,r===`pending`?`text-muted-foreground`:`text-foreground`),children:a(e)})]},e)})}),c===`error`?(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`div`,{className:`typography-meta text-[var(--status-error)]`,children:a(`settings.remoteInstances.page.sync.state.error`,{message:b||``})}),(0,$.jsxs)(q,{type:`button`,variant:`outline`,size:`sm`,className:`!font-normal`,onClick:L,children:[(0,$.jsx)(X,{name:`refresh`,className:`h-3.5 w-3.5`}),a(`settings.remoteInstances.sidebar.actions.retry`)]})]}):null,F&&!N?(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:a(`settings.remoteInstances.page.sync.state.empty`)}):null,F&&N&&M?(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-3`,children:[(0,$.jsx)(`div`,{className:`overflow-hidden rounded-lg border border-border/60 bg-[var(--surface-elevated)]`,children:(0,$.jsxs)(`div`,{className:`divide-y divide-border/60`,children:[M.files.map(e=>{let t=j.has(e.path);return(0,$.jsxs)(`div`,{className:`flex h-8 items-center gap-2 px-2`,children:[(0,$.jsx)(X,{name:`file-text`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono typography-micro text-foreground`,title:e.path,children:[(0,$.jsxs)(`span`,{className:`sr-only`,children:[a(`settings.remoteInstances.page.sync.section.files`),`: `]}),e.path]}),(0,$.jsx)(`span`,{className:`shrink-0 tabular-nums typography-micro text-muted-foreground`,children:Hd(e.bytes)}),(0,$.jsx)(`span`,{className:K(`shrink-0 typography-micro`,t?`text-[var(--status-warning)]`:`text-[var(--status-success)]`),children:a(t?`settings.remoteInstances.page.sync.status.overwrite`:`settings.remoteInstances.page.sync.status.add`)})]},`file:${e.path}`)}),M.directories.map(e=>{let t=j.has(e.path);return(0,$.jsxs)(`div`,{className:`flex h-8 items-center gap-2 px-2`,children:[(0,$.jsx)(X,{name:`folder-3-fill`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono typography-micro text-foreground`,title:e.path,children:[(0,$.jsxs)(`span`,{className:`sr-only`,children:[a(`settings.remoteInstances.page.sync.section.directories`),`: `]}),e.path]}),(0,$.jsxs)(`span`,{className:`shrink-0 tabular-nums typography-micro text-muted-foreground`,children:[Hd(e.bytes),` · `,e.fileCount]}),(0,$.jsx)(`span`,{className:K(`shrink-0 typography-micro`,t?`text-[var(--status-warning)]`:`text-[var(--status-success)]`),children:a(t?`settings.remoteInstances.page.sync.status.overwrite`:`settings.remoteInstances.page.sync.status.add`)})]},`dir:${e.path}`)}),M.providerCredentials?(0,$.jsxs)(`div`,{className:`flex h-8 items-center gap-2 px-2`,children:[(0,$.jsx)(X,{name:`shield-keyhole`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate typography-micro text-foreground`,children:[(0,$.jsxs)(`span`,{className:`sr-only`,children:[a(`settings.remoteInstances.page.sync.section.providerCredentials`),`: `]}),a(`settings.remoteInstances.page.sync.section.providerCredentials`),(0,$.jsx)(`span`,{className:`ml-2 typography-micro text-muted-foreground`,children:a(`settings.remoteInstances.page.sync.hint.providerCredentials`)})]}),(0,$.jsx)(`span`,{className:`shrink-0 tabular-nums typography-micro text-muted-foreground`,children:Hd(M.providerCredentials.bytes)}),(0,$.jsx)(`span`,{className:K(`shrink-0 typography-micro`,v?.remoteProviderCredentialsExists?`text-[var(--status-warning)]`:`text-[var(--status-success)]`),children:v?.remoteProviderCredentialsExists?a(`settings.remoteInstances.page.sync.status.overwrite`):a(`settings.remoteInstances.page.sync.status.add`)})]}):null,M.magpie?(0,$.jsxs)(`div`,{className:`flex h-8 items-center gap-2 px-2`,children:[(0,$.jsx)(X,{name:`tools`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate typography-micro text-foreground`,title:a(`settings.remoteInstances.page.sync.hint.magpie`),children:[a(`settings.remoteInstances.page.sync.section.magpie`),(0,$.jsx)(`span`,{className:`ml-2 typography-micro text-muted-foreground`,children:a(`settings.remoteInstances.page.sync.hint.magpie`)})]})]}):null,M.agentsRoot?(0,$.jsxs)(`div`,{className:`flex h-8 items-center gap-2 px-2`,children:[(0,$.jsx)(X,{name:`tools`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono typography-micro text-foreground`,title:`~/.agents`,children:[(0,$.jsxs)(`span`,{className:`sr-only`,children:[a(`settings.remoteInstances.page.sync.section.agentsRoot`),`: `]}),`~/.agents`]}),(0,$.jsxs)(`span`,{className:`shrink-0 tabular-nums typography-micro text-muted-foreground`,children:[Hd(M.agentsRoot.bytes),` · `,a(`settings.remoteInstances.page.sync.section.agentsRootCount`,{count:M.agentsRoot.fileCount})]}),(0,$.jsx)(`span`,{className:K(`shrink-0 typography-micro`,v?.remoteAgentsRootExists?`text-[var(--status-warning)]`:`text-[var(--status-success)]`),children:v?.remoteAgentsRootExists?a(`settings.remoteInstances.page.sync.status.overwrite`):a(`settings.remoteInstances.page.sync.status.add`)})]}):null]})}),(0,$.jsx)(`div`,{className:`space-y-1 typography-micro text-muted-foreground`,children:I>0?(0,$.jsx)(`div`,{children:a(`settings.remoteInstances.page.sync.note.deletes`,{count:I})}):null})]}):null]}),(0,$.jsxs)(`div`,{className:`shrink-0 space-y-1 typography-micro text-muted-foreground`,children:[(0,$.jsx)(`div`,{children:a(`settings.remoteInstances.page.sync.note.backup`)}),(0,$.jsx)(`div`,{children:a(`settings.remoteInstances.page.sync.note.excluded`)})]}),(0,$.jsxs)(fn,{className:`shrink-0`,children:[(0,$.jsx)(q,{type:`button`,variant:`outline`,size:`sm`,className:`!font-normal`,onClick:()=>i(!1),disabled:P,children:a(`settings.remoteInstances.page.sync.actions.cancel`)}),(0,$.jsxs)(q,{type:`button`,size:`sm`,className:`!font-normal`,onClick:()=>void z(),disabled:!N||P||c!==`review`,children:[(0,$.jsx)(X,{name:`refresh`,className:K(`h-3.5 w-3.5`,P?`animate-spin`:``)}),a(P?`settings.remoteInstances.page.sync.applying`:`settings.remoteInstances.page.sync.actions.syncNow`)]})]})]})})},Jd=e=>{let t=(e instanceof Error?e.message:String(e)).toLowerCase();return t.includes(`address already in use`)||t.includes(`eaddrinuse`)||t.includes(`port already in use`)},Yd=()=>{if(typeof navigator>`u`)return;let e=(navigator.userAgent||``).toLowerCase();if(e.includes(`mac`))return`macos`;if(e.includes(`win`))return`windows`;if(e.includes(`linux`))return`linux`},Xd=e=>{switch((e||``).toLowerCase()){case`ios`:return`iOS`;case`android`:return`Android`;case`macos`:case`darwin`:return`macOS`;case`windows`:case`win32`:return`Windows`;case`linux`:return`Linux`;default:return null}},Zd=e=>{switch((e||``).toLowerCase()){case`ios`:return`device-ios`;case`android`:return`device-android`;case`macos`:case`darwin`:return`device-macos`;case`windows`:case`win32`:return`device-windows`;case`linux`:return`device-linux`;default:return null}},Qd=e=>{switch(e){case`config_resolved`:return`settings.remoteInstances.page.phase.resolvingConfiguration`;case`auth_check`:return`settings.remoteInstances.page.phase.checkingAuth`;case`master_connecting`:return`settings.remoteInstances.page.phase.establishingSsh`;case`remote_probe`:return`settings.remoteInstances.page.phase.probingRemote`;case`installing`:return`settings.remoteInstances.page.phase.installingYuri`;case`updating`:return`settings.remoteInstances.page.phase.updatingYuri`;case`server_detecting`:return`settings.remoteInstances.page.phase.detectingServer`;case`server_starting`:return`settings.remoteInstances.page.phase.startingServer`;case`forwarding`:return`settings.remoteInstances.page.phase.forwardingPorts`;case`ready`:return`settings.remoteInstances.sidebar.phase.ready`;case`degraded`:return`settings.remoteInstances.page.phase.reconnecting`;case`error`:return`settings.remoteInstances.sidebar.phase.error`;default:return`settings.remoteInstances.sidebar.phase.idle`}},$d=new Set([`config_resolved`,`auth_check`,`master_connecting`,`remote_probe`,`installing`,`updating`,`server_detecting`,`server_starting`,`forwarding`]),ef=e=>!!(e&&$d.has(e)),tf=e=>e===`ready`?`bg-[var(--status-success)] animate-pulse`:e===`error`?`bg-[var(--status-error)] animate-pulse`:e===`degraded`||ef(e)?`bg-[var(--status-warning)] animate-pulse`:`bg-muted-foreground/40`,nf=e=>{let t=(0,Sa.c)(8),{itemId:n,label:r,description:i,action:a,children:o}=e,s;t[0]===o?s=t[1]:(s=(0,$.jsx)(`div`,{className:`yuri-settings-group-row`,children:o}),t[0]=o,t[1]=s);let c;return t[2]!==a||t[3]!==i||t[4]!==n||t[5]!==r||t[6]!==s?(c=(0,$.jsx)(Z,{itemId:n,className:`yuri-settings-detail-group`,label:r,actions:a,description:i,children:s}),t[2]=a,t[3]=i,t[4]=n,t[5]=r,t[6]=s,t[7]=c):c=t[7],c},rf=e=>{let t=e.match(/^\[(\d{10,})\]\s*(?:\[([A-Z]+)\]\s*)?(.*)$/);if(!t)return e;let n=Number(t[1]);return`[${Number.isFinite(n)?new Date(n).toISOString():t[1]}] [${(t[2]||`INFO`).toUpperCase()}] ${t[3]||``}`},af=()=>{if(typeof window>`u`)return null;let e=c()||window.location.href;try{let t=Number(new URL(e).port||window.location.port);return Number.isFinite(t)&&t>0?t:null}catch{let e=Number(window.location.port);return Number.isFinite(e)&&e>0?e:null}},of=e=>{try{let t=new URL(e).hostname.toLowerCase();return t===`localhost`||t===`127.0.0.1`||t===`::1`||t===`[::1]`}catch{return!1}},sf=async()=>{let e=I(c())||window.location.origin;if(!h()||!O())return e;let t;try{t=await l(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}})}catch{return e}if(!t.ok||(await t.json().catch(()=>null))?.desktopLanAccessActive!==!0)return e;let n=await b(),r=af();return!n||!r?e:`http://${n}:${r}`},cf=e=>{let t=e.trim();if(t)try{window.location.assign(t)}catch{window.location.href=t}},lf=e=>{let t=e.sshCommand.trim(),n=e.nickname?.trim();return{...e,sshCommand:t,...n?{nickname:n}:{nickname:void 0}}},uf=({phase:e,onAction:t})=>{let{t:n}=Ge(),[r,i]=Q.useState(!1),a=Q.useRef(!1),o=r||ef(e)||e===`degraded`,s=e===`ready`;return(0,$.jsxs)(q,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,disabled:o,"aria-busy":o,onClick:async()=>{if(!(a.current||o)){a.current=!0,i(!0);try{await t()}finally{a.current=!1,i(!1)}}},children:[(0,$.jsx)(X,{name:o?`refresh`:s?`stop`:`plug-2`,className:`h-3.5 w-3.5 ${o?`animate-spin`:``}`}),n(s?`settings.remoteInstances.sidebar.actions.disconnect`:o?`settings.remoteInstances.page.actions.connecting`:`settings.remoteInstances.sidebar.actions.connect`)]})},df=()=>{let{t:e}=Ge(),{clientAuth:t}=ke(),i=D()?E():!1,o=hi(e=>e.instances),l=hi(e=>e.statusesById),u=hi(e=>e.isLoading),d=hi(e=>e.isSaving),f=hi(e=>e.error),p=hi(e=>e.load),m=hi(e=>e.loadImports),g=hi(e=>e.refreshStatuses),_=hi(e=>e.upsertInstance),v=hi(e=>e.createFromCommand),y=hi(e=>e.removeInstance),b=hi(e=>e.connect),x=hi(e=>e.disconnect),S=hi(e=>e.retry),C=G(e=>e.settingsRemoteInstancesSelectedId),w=G(e=>e.setSettingsRemoteInstancesSelectedId),T=Q.useMemo(()=>C&&o.find(e=>e.id===C)||null,[o,C]),[O,k]=Q.useState(null),[A,W]=Q.useState(!1),[ee,te]=Q.useState(!1),[ne,re]=Q.useState(null),[ie,ae]=Q.useState([]),[oe,se]=Q.useState(!1),[ce,le]=Q.useState(null),[ue,de]=Q.useState(`ssh`),[fe,pe]=Q.useState(null),[me,he]=Q.useState(null),[ge,_e]=Q.useState(``),[ve,ye]=Q.useState(!1),[xe,Se]=Q.useState(!1),Ce=Q.useRef(!1),[we,Te]=Q.useState(!1),[Ee,De]=Q.useState(!1),[Oe,Ae]=Q.useState(()=>Date.now()),[je,Me]=Q.useState([]),[Ne,Pe]=Q.useState({}),[Fe,Ie]=Q.useState(`local`),[Le,Re]=Q.useState(!1),[ze,Be]=Q.useState(!1),[Ve,Ue]=Q.useState(0),Ke=Qn(),[qe,Ye]=Q.useState(``),[Xe,Ze]=Q.useState(null),[Qe,$e]=Q.useState(!1),[et,tt]=Q.useState([]),[nt,rt]=Q.useState([]),[it,at]=Q.useState(!1),[ot,st]=Q.useState(``),ct=Q.useRef(!1),[lt,ut]=Q.useState(null),[dt,ft]=Q.useState(null),[pt,mt]=Q.useState(!1),[ht,gt]=Q.useState(null),[_t,vt]=Q.useState(null),[yt,bt]=Q.useState(null),[xt,St]=Q.useState(null),[Ct,wt]=Q.useState(!1),[Tt,Et]=Q.useState(!1),[Dt,Ot]=Q.useState(`configure`),[kt,At]=Q.useState(!1),[jt,Mt]=Q.useState(`relay`),[Nt,J]=Q.useState(!0),[Pt,Ft]=Q.useState(Fd),[It,Lt]=Q.useState(null),[Rt,zt]=Q.useState(!1),[Bt,Vt]=Q.useState(!1),Ht=Q.useRef(null);Q.useEffect(()=>{Rt&&It&&Ht.current?.focus()},[Rt,It]);let[Ut,Wt]=Q.useState(null),Gt=Q.useMemo(()=>et.filter(e=>!!e.revokedAt).length,[et]),[Kt,qt]=Q.useState(!1),[Jt,Yt]=Q.useState(`ssh user@example.com`),[Xt,Zt]=Q.useState(``);Q.useEffect(()=>{i&&(p(),m())},[p,m,i]);let Qt=Q.useCallback(async()=>{Re(!0);try{let e=await z();Me(e.hosts||[]),Ie(e.defaultHostId||`local`)}catch(t){Y.error(e(`desktopHostSwitcher.error.failedToLoad`),{description:t instanceof Error?t.message:String(t)})}finally{Re(!1)}},[e]);Q.useEffect(()=>{Qt()},[Qt]);let $t=Object.values(l).filter(e=>e.phase===`ready`).map(e=>`${e.id}:${e.localUrl||``}`).sort().join(`|`);Q.useEffect(()=>{$t&&Qt()},[Qt,$t]);let en=Q.useCallback(async(t,n=Fe)=>{Be(!0);try{return await L({hosts:t,defaultHostId:n,initialHostChoiceCompleted:!0}),Me(t),Ie(n),!0}catch(t){return Y.error(e(`desktopHostSwitcher.error.failedToSave`),{description:t instanceof Error?t.message:String(t)}),!1}finally{Be(!1)}},[Fe,e]),tn=Q.useMemo(()=>new Set(o.map(e=>e.id)),[o]),nn=Q.useMemo(()=>je.filter(e=>P(e,tn)),[je,tn]),rn=He(async()=>{Ze(null);let t=Ga(qe);if(!t){Ze(e(`settings.remoteInstances.direct.error.invalidConnectLink`));return}let r=await M().catch(()=>``),i={method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({pairingId:t.pairingId,secret:t.secret,clientLabel:t.label||`Yuri Desktop`,clientKind:`desktop`,deviceName:`Yuri Desktop`,devicePlatform:Yd(),...r?{dedupeKey:`desktop:${r}`}:{}})},a=async e=>{if(!e.ok)return null;let t=await e.json().catch(()=>null);return(typeof t?.clientToken==`string`?t.clientToken.trim():``)||null},o=[...t.candidates].sort((e,t)=>(e.type===`relay`)-+(t.type===`relay`)),s=null;for(let e of o){if(e.type===`relay`){let t=n({relayUrl:e.relayUrl,serverId:e.serverId,hostEncPubJwk:e.hostEncPubJwk,...e.grant?{grant:e.grant}:{}});try{let n=await a(await t.fetch(`/api/client-auth/pairing/redeem`,i));if(n){s={kind:`relay`,relay:{relayUrl:e.relayUrl,serverId:e.serverId,hostEncPubJwk:e.hostEncPubJwk},token:n,tunnel:t},t.close();break}}catch{}t.close();continue}let t=I(e.url);if(t)try{let e=await a(await fetch(`${t}/api/client-auth/pairing/redeem`,i));if(e){s={kind:`direct`,url:t,token:e};break}}catch{}}if(!s){Ze(e(`settings.remoteInstances.direct.error.pairingFailed`));return}let c=()=>be(),l=t.candidates.find(e=>e.type===`relay`),u=s.kind===`relay`?s.relay:l?{relayUrl:l.relayUrl,serverId:l.serverId,hostEncPubJwk:l.hostEncPubJwk}:void 0,d=t.candidates.filter(e=>e.type!==`relay`),f=d.map(e=>I(e.url)).find(e=>!!e),p=d.filter(e=>e.type===`lan`).map(e=>I(e.url)).find(e=>!!e),m=s.kind===`direct`?s.url:p||f||null,{token:h}=s,g=m||(u?H(u.serverId):null);if(!g){Ze(e(`settings.remoteInstances.direct.error.invalidConnectLink`));return}let _={url:g,apiUrl:m||void 0,clientToken:h,source:V,...u?{relay:u}:{}},v=je.find(e=>u?e.relay?.serverId===u.serverId&&e.relay?.relayUrl===u.relayUrl:!e.relay&&I(e.apiUrl||e.url)===g);if(v){let e=je.map(e=>e.id===v.id?{...e,label:t.label||e.label,..._}:e);if(!await en(e,Fe))return}else if(!await en([{id:c(),label:t.label||j(g),..._},...je],Fe))return;Ye(``),Ze(null),$e(!1)}),an=Q.useCallback(async e=>{let t=je.filter(t=>t.id!==e);await en(t,Fe===e?`local`:Fe)},[Fe,je,en]),on=Q.useCallback(async()=>{let t=Jt.trim();if(!t){Y.error(e(`settings.remoteInstances.page.toast.sshCommandRequired`));return}let n=`ssh-${Date.now()}-${Math.random().toString(16).slice(2)}`;try{await v(n,t,Xt.trim()||void 0),w(n),qt(!1),Yt(`ssh user@example.com`),Zt(``),Y.success(e(`settings.remoteInstances.page.toast.instanceCreated`))}catch(t){Y.error(e(`settings.remoteInstances.sidebar.toast.createFailed`),{description:t instanceof Error?t.message:String(t)})}},[v,w,Jt,Xt,e]),sn=Q.useCallback(async e=>{await en(je,e)},[je,en]),cn=He(async e=>{if(U(e)||Ke)return;let t=await er({host:e,cachedProbe:Ne[e.id]||null});Pe(n=>({...n,[e.id]:t.status}))}),ln=He(async t=>{if(Ke)return;let n=t.nickname?.trim()||t.sshParsed?.destination||t.id,r=je;try{let e=await z();r=e.hosts||[],Me(r),Ie(e.defaultHostId||`local`)}catch(t){Y.error(e(`desktopHostSwitcher.toast.instanceUnreachable`,{host:n}),{description:t instanceof Error?t.message:String(t)});return}let i=r.find(e=>e.id===t.id)??null;if(!i||!N(i)||!i.clientToken){Y.error(e(`desktopHostSwitcher.toast.instanceUnreachable`,{host:n}));return}U(i)||await er({host:i})});Q.useEffect(()=>{if(i)return r(()=>{Ue(e=>e+1)})},[i]),Q.useEffect(()=>{if(!i||nn.length===0)return;let e=!1;return Promise.all(nn.map(async e=>{let t=async()=>{let t=await F(e.relay,{clientToken:e.clientToken||null}).catch(()=>({status:`unreachable`,latencyMs:0}));return t.status===`ok`?{status:t.status,latencyMs:t.latencyMs,via:`relay`}:{status:t.status,latencyMs:t.latencyMs}};if(e.relay&&!e.apiUrl)return[e.id,await t()];let n=I(N(e));if(!n)return[e.id,e.relay?await t():{status:`unreachable`,latencyMs:0}];let r=await R(n,{clientToken:e.clientToken||null,requestHeaders:e.requestHeaders||null}).catch(()=>({status:`unreachable`,latencyMs:0}));if(r.status===`unreachable`&&e.relay){let n=await t();if(n.status===`ok`)return[e.id,n]}return[e.id,r]})).then(t=>{e||Pe(Object.fromEntries(t))}),()=>{e=!0}},[nn,i]);let un=Q.useCallback(async e=>{if(t){e?.silent||at(!0),e?.silent||ut(null);try{let[e,n]=await Promise.all([t.listClients(),t.listPendingPairings().catch(()=>null)]);tt(e),n&&rt(n)}catch(t){e?.silent||ut(t instanceof Error?t.message:String(t))}finally{e?.silent||at(!1)}}},[t]),_n=Q.useRef(!1);Q.useEffect(()=>{if(!(!Tt||Dt!==`result`||!yt)){if(nt.some(e=>e.id===yt)){_n.current=!0;return}_n.current&&(bt(null),Et(!1),et.some(e=>e.pairingId===yt)&&Y.success(e(`settings.remoteInstances.clientAuth.addDevice.connectedToast`)))}},[Tt,Dt,yt,nt,et,e]);let vn=Q.useCallback(async e=>{if(t)try{await t.cancelPairing(e),rt(t=>t.filter(t=>t.id!==e)),await un({silent:!0})}catch(e){ut(e instanceof Error?e.message:String(e))}},[t,un]);Q.useEffect(()=>{if(!t)return;un();let e=window.setInterval(()=>{typeof document<`u`&&document.visibilityState!==`visible`||un({silent:!0})},5e3);return()=>window.clearInterval(e)},[t,un]);let yn=Q.useCallback(async()=>{let e=s()!==`local`;if(t?.getPairingTransports)try{let n=await t.getPairingTransports(),r=Ld(n.relayUrl),i=Array.from(new Set([...Array.isArray(n.relayUrls)?n.relayUrls:[],...r?[r]:[]].map(e=>Ld(e)).filter(e=>!!e)));return{serverName:n.serverName,localUrl:n.local,lanUrl:n.lan,relayAvailable:n.relayAvailable,relayUrl:r,relayUrls:n.relayAvailable?i:[],relayUrlLocked:n.relayUrlLocked===!0,remoteHost:e}}catch{}let n=af(),r=n?`http://127.0.0.1:${n}`:of(window.location.origin)?window.location.origin:null,i=null;try{let e=I(await sf());i=e&&!of(e)?e:null}catch{}return{localUrl:r,lanUrl:i,relayAvailable:!1,relayUrl:null,relayUrls:[],relayUrlLocked:!1,remoteHost:e}},[t]),bn=He(async()=>{ct.current=!1,st(``),ut(null),vt(null),St(null),wt(!1),bt(null),Lt(null),Ot(`configure`),zt(!1),J(!0),Et(!0);let e=await yn();ct.current||st(e.serverName||``),Wt(e),Vt(!1);let t=e.remoteHost?null:Rd();Ft((e.relayUrlLocked||e.remoteHost?e.relayUrl:t||e.relayUrl)||`wss://relay.useyuri.top/ws`),Mt(e.relayAvailable?`relay`:e.lanUrl?`lan`:`local`)}),xn=G(e=>e.devicePairingRequested);Q.useEffect(()=>{!xn||!t||(G.setState({devicePairingRequested:!1}),bn())},[xn,t,bn]);let Sn=He(async()=>{if(!(!t?.createPairingSession||!Ut)){ut(null),At(!0);try{let n=ot.trim()||void 0,r,i,a=!0;jt===`local`?(r=Ut.localUrl??void 0,i=!1):jt===`lan`?(r=Ut.lanUrl??void 0,i=Nt):Nt&&Ut.lanUrl?(r=Ut.lanUrl,i=!0):(a=!1,i=!0),Ut.relayAvailable||(i=!1);let o=i?Ld(Pt):null;if(i&&!o){Lt(e(`settings.remoteInstances.clientAuth.addDevice.relayUrlInvalid`)),zt(!0);return}Lt(null);let{pairing:s,server:c}=await t.createPairingSession({label:n,allowedClientKinds:[`mobile`,`desktop`],serverUrl:r,includeRelay:i,includeDirect:a,...o?{relayUrl:o}:{}}),l=Ha({pairingId:s.id,secret:s.secret,label:n||c.label,fingerprint:s.fingerprint??void 0,expiresAt:s.expiresAt,candidates:c.candidates}),u=l.candidates.find(e=>e.type===`relay`);u&&(Ft(u.relayUrl),Ut?.remoteHost!==!0&&zd(u.relayUrl));let d=Ua(l);vt(d),St(await As.toDataURL(d,{width:1024,margin:2,errorCorrectionLevel:`L`})),wt(!1),_n.current=!1,bt(s.id),Ot(`result`),await un({silent:!0})}catch(e){ut(e instanceof Error?e.message:String(e))}finally{At(!1)}}}),Dn=Q.useCallback(()=>{_t&&We(_t).then(e=>{e.ok&&(wt(!0),window.setTimeout(()=>wt(!1),2e3))})},[_t]),On=He(async()=>{if(!(!t||!dt||pt||!dt.label.trim())){mt(!0),gt(null);try{let e=await t.renameClient(dt.id,dt.label.trim());tt(t=>t.map(t=>t.id===e.id?e:t)),ft(null),await un({silent:!0})}catch(e){gt(e instanceof Error?e.message:String(e))}finally{mt(!1)}}}),An=Q.useCallback(async e=>{if(!t)return;let n=e.clientKind===`desktop-local`;ut(null);try{if(await t.revokeClient(e.id),n&&h()){let t=await z();await L({hosts:t.hosts,defaultHostId:t.defaultHostId,initialHostChoiceCompleted:t.initialHostChoiceCompleted,localClientToken:null}),tt(t=>t.map(t=>t.id===e.id?{...t,revokedAt:new Date().toISOString()}:t)),a({apiBaseUrl:c(),clientToken:null,runtimeKey:`local`});return}await un()}catch(e){ut(e instanceof Error?e.message:String(e))}},[t,un]),jn=Q.useCallback(async()=>{if(t){ut(null);try{await t.purgeRevokedClients(),await un()}catch(e){ut(e instanceof Error?e.message:String(e))}}},[t,un]);Q.useEffect(()=>{k(T)},[T]),Q.useEffect(()=>{if(!i||!C)return;let e=window.setInterval(()=>{typeof document<`u`&&document.visibilityState!==`visible`||g()},2e3);return()=>{window.clearInterval(e)}},[g,C,i]),Q.useEffect(()=>{let e=null,t=Date.now(),n=()=>{let r=Date.now();r-t>=1e3&&(Ae(r),t=r),e=requestAnimationFrame(n)};(typeof document>`u`||document.visibilityState===`visible`)&&(e=requestAnimationFrame(n));let r=()=>{document.visibilityState===`visible`&&e===null?e=requestAnimationFrame(n):document.visibilityState!==`visible`&&e!==null&&(cancelAnimationFrame(e),e=null)};return document.addEventListener(`visibilitychange`,r),()=>{document.removeEventListener(`visibilitychange`,r),e!==null&&cancelAnimationFrame(e)}},[]);let Mn=C?l[C]:null,Nn=Mn?.phase,Pn=Nn===`ready`,Fn=Nn===`degraded`,In=ef(Nn),Rn=Pn||In||Fn,zn=Mn?Math.max(0,Oe-Mn.updatedAtMs):0,Bn=Fn&&zn>12e3,Hn=Q.useMemo(()=>!O||!T?!1:JSON.stringify(O)!==JSON.stringify(T),[O,T]),Wn=He(e=>{k(t=>t&&e(t))}),Gn=He(async()=>{if(!O||xe||d)return;let t=lf(O);if(!t.sshCommand.trim()){Y.error(e(`settings.remoteInstances.page.toast.sshCommandRequired`));return}if(t.auth.sshPassword?.enabled&&t.auth.sshPassword.value?.trim()&&t.auth.sshPassword.store!==`settings`){let n=window.confirm(e(`settings.remoteInstances.page.confirm.storeSshPasswordPlaintext`));t.auth.sshPassword.store=n?`settings`:`never`,n||(t.auth.sshPassword.value=void 0)}if(t.auth.yuriPassword?.enabled&&t.auth.yuriPassword.value?.trim()&&t.auth.yuriPassword.store!==`settings`){let n=window.confirm(e(`settings.remoteInstances.page.confirm.storeUiPasswordPlaintext`));t.auth.yuriPassword.store=n?`settings`:`never`,n||(t.auth.yuriPassword.value=void 0)}try{await _(t),Y.success(e(`settings.remoteInstances.page.toast.instanceSaved`))}catch(t){Y.error(e(`settings.remoteInstances.page.toast.saveFailed`),{description:t instanceof Error?t.message:String(t)})}}),Kn=He(async()=>{if(!O||Ce.current||d)return;Ce.current=!0,Se(!0);let t=O.id;try{await y(t),Me(e=>e.filter(e=>e.id!==t)),Ie(e=>e===t?`local`:e),w(null),Y.success(e(`settings.remoteInstances.page.toast.instanceRemoved`))}catch(t){Y.error(e(`settings.remoteInstances.page.toast.removeInstanceFailed`),{description:t instanceof Error?t.message:String(t)})}finally{Ce.current=!1,Se(!1)}}),qn=Q.useCallback(async(t,n)=>{let r=`ssh-${Date.now()}-${Math.random().toString(16).slice(2)}`;try{return await v(r,`ssh ${n}`,t),w(r),Y.success(e(`settings.remoteInstances.page.toast.instanceCreated`)),!0}catch(t){return Y.error(e(`settings.remoteInstances.sidebar.toast.createFailed`),{description:t instanceof Error?t.message:String(t)}),!1}},[v,w,e]),Jn=Q.useCallback(()=>{ve||(he(null),_e(``))},[ve]),Yn=Q.useCallback(async()=>{let t=me,n=ge.trim();if(t){if(!n){Y.error(e(`settings.remoteInstances.page.toast.destinationRequired`));return}ye(!0);try{await qn(t,n)&&(he(null),_e(``))}finally{ye(!1)}}},[qn,ge,me,e]),Zn=Q.useCallback(async()=>{if(T)try{await b(T.id);return}catch(t){if(!Jd(t)||!window.confirm(e(`settings.remoteInstances.sidebar.confirm.localPortInUseRetry`)))throw t;let n={...T,localForward:{...T.localForward,preferredLocalPort:Vd()}};await _(n),await b(n.id),Y.success(e(`settings.remoteInstances.sidebar.toast.retriedWithRandomPort`))}},[b,T,e,_]),$n=Q.useCallback(async e=>(await Ln(e,600)).map(e=>rf(e)),[]),tr=Q.useCallback(async()=>{if(O){W(!0),te(!0),re(null);try{let e=await $n(O.id);ae(e)}catch(e){ae([]),re(e instanceof Error?e.message:String(e))}finally{te(!1)}}},[O,$n]);Q.useEffect(()=>{if(!A||!O)return;let e=!1,t=async()=>{try{let t=await $n(O.id);e||(ae(t),re(null))}catch(t){e||re(t instanceof Error?t.message:String(t))}};t();let n=window.setInterval(()=>{typeof document<`u`&&document.visibilityState!==`visible`||t()},1e3);return()=>{e=!0,window.clearInterval(n)}},[O,A,$n]);let nr=Q.useMemo(()=>ie.join(`
27
- `),[ie]),rr=Q.useCallback(()=>{if(!nr.trim()){Y.error(e(`settings.remoteInstances.page.toast.noLogsToCopy`));return}We(nr).then(t=>{t.ok&&Y.success(e(`settings.remoteInstances.page.toast.logsCopied`))})},[nr,e]),ir=Q.useCallback(async()=>{if(O)try{await Xn(O.id),ae([]),Y.success(e(`settings.remoteInstances.page.toast.logsCleared`))}catch(t){Y.error(e(`settings.remoteInstances.page.toast.clearLogsFailed`),{description:t instanceof Error?t.message:String(t)})}},[O,e]),ar=Q.useCallback(async()=>{if(!Mn?.localUrl){Y.error(e(`settings.remoteInstances.page.toast.instanceUrlUnavailable`));return}let t=Mn.localUrl.trim();if(!t){Y.error(e(`settings.remoteInstances.page.toast.instanceUrlUnavailable`));return}cf(t)},[Mn?.localUrl,e]),or=Q.useCallback((e,t=`ssh`,n=null)=>{le(e),de(t),pe(n),se(!0)},[]),sr=Q.useCallback(()=>{if(!O)return;let t=Rn,n=O.id;Te(!0),(t?x(n):Zn()).catch(n=>{let r=t?Pn?`settings.remoteInstances.page.toast.disconnectFailed`:`settings.remoteInstances.page.toast.cancelConnectionFailed`:`settings.remoteInstances.page.toast.connectFailed`,i=Mn?.detail||(n instanceof Error?n.message:String(n)),a=Vn(Mn?.errorCode,i);Y.error(e(r),{description:t?n instanceof Error?n.message:String(n):cr(e(Un(a)),a,i)})}).finally(()=>{Te(!1)})},[Rn,Zn,x,O,Pn,Mn,e]),lr=Q.useCallback(()=>{O&&(In||(De(!0),(Fn?x(O.id).then(()=>Zn()):S(O.id)).catch(t=>{let n=Mn?.detail||(t instanceof Error?t.message:String(t)),r=Vn(Mn?.errorCode,n);Y.error(e(`settings.remoteInstances.page.toast.retryFailed`),{description:cr(e(Un(r)),r,n)})}).finally(()=>{De(!1)})))},[Zn,x,O,In,Fn,S,Mn,e]),ur=e(In?`settings.remoteInstances.page.actions.connecting`:Fn?Bn?`settings.remoteInstances.page.actions.reconnectNow`:`settings.remoteInstances.page.actions.reconnecting`:`settings.remoteInstances.sidebar.actions.retry`),dr=!we&&!Ee&&(Nn===`error`||Nn===`idle`||!Nn||Fn&&Bn)&&!In,fr=e(Pn?`settings.remoteInstances.sidebar.actions.disconnect`:Rn?`settings.remoteInstances.page.actions.cancel`:`settings.remoteInstances.sidebar.actions.connect`);if(!O)return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(jl,{children:[t?(0,$.jsxs)(nf,{itemId:`remote-instances.client-auth`,label:e(`settings.remoteInstances.clientAuth.title`),action:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,$.jsx)(q,{type:`button`,size:`xs`,className:`!font-normal`,onClick:()=>{Ze(null),$e(!0)},disabled:ze,children:e(`settings.remoteInstances.direct.import.action`)}),(0,$.jsxs)(q,{type:`button`,size:`xs`,className:`!font-normal`,onClick:()=>void bn(),children:[(0,$.jsx)(X,{name:`add`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.clientAuth.actions.addDevice`)]}),Gt>0?(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>void jn(),children:e(`settings.remoteInstances.clientAuth.actions.clearRevoked`)}):null]}),children:[(0,$.jsx)(`div`,{className:`space-y-1`,children:it&&et.length===0&&nt.length===0?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e(`settings.remoteInstances.clientAuth.state.loading`)}):et.length===0&&nt.length===0?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e(`settings.remoteInstances.clientAuth.state.empty`)}):(0,$.jsxs)($.Fragment,{children:[nt.map(t=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-1.5`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full bg-[var(--status-warning)] animate-pulse`}),(0,$.jsx)(`p`,{className:`typography-ui-label text-foreground truncate`,children:t.label||e(`settings.remoteInstances.clientAuth.field.labelPlaceholder`)}),t.usesRelay?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-muted px-1 rounded shrink-0 leading-none pb-px border border-border/50`,children:e(`settings.remoteInstances.clientAuth.state.viaRelay`)}):null]}),(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground truncate`,children:e(`settings.remoteInstances.clientAuth.state.pending`)})]}),(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>void vn(t.id),children:e(`settings.common.actions.cancel`)})]},`pending-${t.id}`)),et.map(t=>{let n=t.clientKind===`desktop-local`,r=t.lastUsedAt?Date.parse(t.lastUsedAt):NaN,i=!t.revokedAt&&(n||Number.isFinite(r)&&Date.now()-r<9e4),a=t.revokedAt?e(`settings.remoteInstances.clientAuth.state.revoked`):i?t.lastTransport===`relay`&&!n?e(`settings.remoteInstances.clientAuth.state.connectedRelay`):e(`settings.remoteInstances.clientAuth.state.connectedDirect`):t.lastUsedAt?e(`settings.remoteInstances.clientAuth.lastUsed`,{date:cd(r,{locale:Je()})}):e(`settings.remoteInstances.clientAuth.neverUsed`),o=Number.isFinite(r)?new Date(r).toLocaleString(Je()):void 0;return(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 py-1.5`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 basis-48`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:K(`h-2 w-2 shrink-0 rounded-full`,t.revokedAt?`bg-muted-foreground/20`:i?`bg-[var(--status-success)]`:`bg-muted-foreground/30`)}),(0,$.jsx)(`p`,{className:`typography-ui-label text-foreground truncate`,children:t.label}),(()=>{let e=Xd(t.devicePlatform),n=Zd(t.devicePlatform);return e&&n?(0,$.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 rounded-full border border-border/50 px-1.5 py-px text-muted-foreground`,title:e,"aria-label":e,children:[(0,$.jsx)(X,{name:n,className:`h-3 w-3`}),(0,$.jsx)(`span`,{className:`typography-micro leading-none`,children:e})]}):null})(),n?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-muted px-1 rounded flex-shrink-0 leading-none pb-px border border-border/50`,children:e(`settings.remoteInstances.clientAuth.state.thisDevice`)}):null]}),(0,$.jsx)(`p`,{className:K(`typography-micro truncate`,i&&!t.revokedAt?`text-[var(--status-success)]`:`text-muted-foreground`),title:o,children:a})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>{gt(null),ft({id:t.id,label:t.label})},disabled:pt,children:e(`settings.remoteInstances.clientAuth.edit.action`)}),(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>void An(t),disabled:!!t.revokedAt||pt,children:e(`settings.remoteInstances.clientAuth.actions.revoke`)})]})]},t.id)})]})}),lt?(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:lt}):null]}):null,!i&&D()?(0,$.jsx)(nf,{itemId:`remote-instances.instances`,label:e(`settings.remoteInstances.sidebar.title`),children:(0,$.jsx)(q,{size:`sm`,onClick:()=>void B().catch(e=>Y.error(String(e))),children:e(`settings.remoteInstances.openLocalManager`)})}):null,i?(0,$.jsx)(nf,{itemId:`remote-instances.instances`,label:e(`settings.remoteInstances.sidebar.title`),action:nn.length>0||o.length>0?(0,$.jsx)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:(0,$.jsxs)(q,{type:`button`,size:`xs`,className:`!font-normal`,onClick:()=>qt(!0),children:[(0,$.jsx)(X,{name:`add`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.sidebar.actions.addSshInstance`)]})}):void 0,children:(0,$.jsx)(`div`,{className:`space-y-1`,children:Le||u?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e(`settings.remoteInstances.direct.state.loading`)}):nn.length===0&&o.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center px-6 py-10 text-center`,children:[(0,$.jsx)(X,{name:`device-desktop`,className:`mb-5 size-16 text-muted-foreground/45`}),(0,$.jsx)(`p`,{className:`typography-ui-label font-medium text-foreground`,children:e(`settings.remoteInstances.quick.sshTitle`)}),(0,$.jsx)(`p`,{className:`mt-2 max-w-sm typography-meta leading-relaxed text-muted-foreground`,children:e(`settings.remoteInstances.quick.sshHint`)}),(0,$.jsxs)(q,{type:`button`,variant:`secondary`,size:`sm`,className:`mt-6 gap-2 rounded-xl`,onClick:()=>qt(!0),children:[(0,$.jsx)(X,{name:`add`,className:`size-4`}),e(`settings.remoteInstances.sidebar.actions.addSshInstance`)]})]}):(0,$.jsxs)($.Fragment,{children:[nn.map(t=>{let n=Ne[t.id],r=n?n.status===`ok`?`desktopHostSwitcher.status.connected`:n.status===`auth`?`desktopHostSwitcher.status.authRequired`:n.status===`update-recommended`?`desktopHostSwitcher.status.updateRecommended`:n.status===`incompatible`?`desktopHostSwitcher.status.incompatible`:n.status===`wrong-service`?`desktopHostSwitcher.status.wrongService`:`desktopHostSwitcher.status.unreachable`:`desktopHostSwitcher.status.checking`,i=n?.status===`ok`,a=U(t),o=a||Ke||ze;return(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-1.5`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:K(`h-2 w-2 shrink-0 rounded-full`,n?i||a?`bg-[var(--status-success)]`:`bg-[var(--status-error)]`:`bg-muted-foreground/30 animate-pulse`)}),(0,$.jsx)(`p`,{className:`typography-ui-label text-foreground truncate`,children:j(t.label)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-muted px-1 rounded flex-shrink-0 leading-none pb-px border border-border/50`,children:e(`settings.remoteInstances.channel.link`)}),a?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground shrink-0`,children:e(`desktopHostSwitcher.header.current`)}):null,Fe===t.id?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground shrink-0`,children:e(`desktopHostSwitcher.header.default`)}):null,(0,$.jsxs)(`span`,{className:K(`typography-micro shrink-0`,i||a?`text-[var(--status-success)]`:`text-muted-foreground`),children:[e(r),i&&typeof n?.latencyMs==`number`?e(`desktopHostSwitcher.status.ping`,{ms:Math.max(0,Math.round(n.latencyMs))}):``]})]}),(0,$.jsx)(`p`,{className:K(`typography-micro text-muted-foreground truncate`,t.apiUrl&&`font-mono`),children:t.relay&&!t.apiUrl?e(`mobile.connect.relay.badge`):j(t.apiUrl||t.url)})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,$.jsxs)(q,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>void cn(t),disabled:o,"aria-label":e(`desktopHostSwitcher.actions.switchToAria`,{instance:j(t.label)}),children:[(0,$.jsx)(X,{name:`arrow-left-right`,className:`h-3.5 w-3.5`}),e(a?`desktopHostSwitcher.header.current`:`desktopHostSwitcher.actions.switchInstance`)]}),(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>void sn(t.id),disabled:ze||Fe===t.id,"aria-label":e(`desktopHostSwitcher.actions.setAsDefaultAria`),children:Fe===t.id?(0,$.jsx)(X,{name:`star-fill`,className:`h-3.5 w-3.5`}):(0,$.jsx)(X,{name:`star`,className:`h-3.5 w-3.5`})}),(()=>{let n=N(t),r=!!n&&!n.startsWith(`relay://`)&&!t.relay;return t.relay?.serverId&&t.relay?.relayUrl&&t.relay?.hostEncPubJwk&&t.clientToken&&t.relay?(0,$.jsxs)(q,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>or(t.id,`relay`,t),"aria-label":e(`settings.remoteInstances.page.sync.title`),children:[(0,$.jsx)(X,{name:`refresh`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.page.sync.actions.syncNow`)]}):r?(0,$.jsxs)(q,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>or(t.id,`direct`),"aria-label":e(`settings.remoteInstances.page.sync.title`),children:[(0,$.jsx)(X,{name:`refresh`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.page.sync.actions.syncNow`)]}):null})(),(0,$.jsxs)(q,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>void an(t.id),disabled:ze||Ke,children:[(0,$.jsx)(X,{name:`delete-bin`,className:`h-3.5 w-3.5`}),e(`settings.common.actions.delete`)]})]})]},`link:${t.id}`)}),o.map(t=>{let n=l[t.id],r=t.nickname?.trim()||t.sshParsed?.destination||t.id,i=n?.phase,a=i===`ready`,o=je.find(e=>e.id===t.id),s=U({id:t.id,label:r,url:n?.localUrl||o?.url||``}),c=(0,$.jsxs)(q,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>void ln(t),disabled:s||Ke||!a,"aria-label":e(`desktopHostSwitcher.actions.switchToAria`,{instance:r}),children:[(0,$.jsx)(X,{name:`arrow-left-right`,className:`h-3.5 w-3.5`}),e(s?`desktopHostSwitcher.header.current`:`desktopHostSwitcher.actions.switchInstance`)]});return(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-1.5`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${tf(i)}`}),(0,$.jsx)(`p`,{className:`typography-ui-label text-foreground truncate`,children:r}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-muted px-1 rounded flex-shrink-0 leading-none pb-px border border-border/50`,children:e(`settings.remoteInstances.channel.ssh`)}),s?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground shrink-0`,children:e(`desktopHostSwitcher.header.current`)}):null]}),(0,$.jsxs)(`p`,{className:`typography-micro text-muted-foreground truncate`,children:[e(Qd(i)),n?.localUrl?` · ${n.localUrl}`:``]})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,$.jsx)(uf,{phase:i,onAction:()=>(a?x(t.id):b(t.id)).catch(t=>{let r=n?.detail||(t instanceof Error?t.message:String(t)),i=Vn(n?.errorCode,r);Y.error(e(a?`settings.remoteInstances.sidebar.toast.disconnectFailed`:`settings.remoteInstances.sidebar.toast.connectFailed`),{description:a?t instanceof Error?t.message:String(t):cr(e(Un(i)),i,r)})})}),a?c:(0,$.jsxs)(En,{children:[(0,$.jsx)(wn,{asChild:!0,children:(0,$.jsx)(`span`,{className:`inline-flex`,children:c})}),(0,$.jsx)(Tn,{sideOffset:8,className:`max-w-xs`,children:e(`settings.remoteInstances.sidebar.actions.switchInstanceDisabled`)})]}),a&&t.remoteYuri?.mode!==`external`?(0,$.jsxs)(q,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>or(t.id),children:[(0,$.jsx)(X,{name:`refresh`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.sidebar.actions.syncConfig`)]}):(0,$.jsxs)(En,{children:[(0,$.jsx)(wn,{asChild:!0,children:(0,$.jsx)(`span`,{className:`inline-flex`,children:(0,$.jsxs)(q,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,disabled:!0,"aria-label":e(`settings.remoteInstances.sidebar.actions.syncConfigDisabled`),children:[(0,$.jsx)(X,{name:`refresh`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.sidebar.actions.syncConfig`)]})})}),(0,$.jsx)(Tn,{sideOffset:8,className:`max-w-xs`,children:e(`settings.remoteInstances.sidebar.actions.syncConfigDisabled`)})]}),(0,$.jsxs)(q,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>w(t.id),children:[(0,$.jsx)(X,{name:`pencil`,className:`h-3.5 w-3.5`}),e(`desktopHostSwitcher.actions.edit`)]})]})]},`ssh:${t.id}`)})]})})}):null,(0,$.jsx)(gn,{open:dt!==null,onOpenChange:e=>{!e&&!pt&&ft(null)},children:(0,$.jsxs)(pn,{className:`sm:max-w-sm`,showCloseButton:!pt,children:[(0,$.jsx)(dn,{children:(0,$.jsx)(mn,{children:e(`settings.remoteInstances.clientAuth.edit.title`)})}),(0,$.jsxs)(`form`,{className:`space-y-4`,onSubmit:e=>{e.preventDefault(),On()},children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`label`,{htmlFor:`remote-client-name`,className:`typography-ui-label text-muted-foreground`,children:e(`settings.remoteInstances.clientAuth.edit.name`)}),(0,$.jsx)(Cn,{id:`remote-client-name`,className:`text-left`,autoFocus:!0,value:dt?.label??``,maxLength:80,disabled:pt,onChange:e=>ft(t=>t?{...t,label:e.target.value}:null),onKeyDown:e=>{e.key===`Enter`&&e.nativeEvent.isComposing&&e.preventDefault()},"aria-invalid":!!ht,"aria-describedby":ht?`remote-client-name-error`:void 0}),ht?(0,$.jsx)(`p`,{id:`remote-client-name-error`,role:`alert`,className:`typography-meta text-[var(--status-error)]`,children:ht}):null]}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>ft(null),disabled:pt,children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(q,{type:`submit`,size:`sm`,disabled:pt||!dt?.label.trim(),children:e(`settings.common.actions.saveChanges`)})]})]})]})}),i?(0,$.jsx)(gn,{open:Qe,onOpenChange:e=>{$e(e),Ze(null)},children:(0,$.jsxs)(pn,{className:`sm:max-w-lg`,children:[(0,$.jsxs)(dn,{children:[(0,$.jsx)(mn,{children:e(`settings.remoteInstances.direct.import.action`)}),(0,$.jsx)(hn,{children:e(`settings.remoteInstances.direct.import.description`)})]}),(0,$.jsxs)(`form`,{className:`space-y-4`,onSubmit:e=>{e.preventDefault(),rn()},children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Cn,{value:qe,onChange:e=>{Ye(e.target.value),Ze(null)},placeholder:e(`settings.remoteInstances.direct.import.placeholder`),"aria-label":e(`settings.remoteInstances.direct.import.action`),"aria-invalid":!!Xe,"aria-describedby":Xe?`remote-import-error`:void 0,disabled:ze,autoFocus:!0}),Xe?(0,$.jsx)(`div`,{id:`remote-import-error`,role:`alert`,className:`rounded-lg bg-[var(--status-error-background)] px-3 py-2.5 typography-meta leading-relaxed text-[var(--status-error)] break-words`,children:Xe}):null]}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>{$e(!1),Ze(null)},disabled:ze,children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(q,{type:`submit`,size:`sm`,disabled:ze||!qe.trim(),children:e(`settings.remoteInstances.direct.import.action`)})]})]})]})}):null,(0,$.jsx)(gn,{open:Tt,onOpenChange:Et,children:(0,$.jsxs)(pn,{className:`sm:max-w-xl`,children:[(0,$.jsxs)(dn,{className:`items-center pt-4 text-center sm:text-center`,children:[Dt===`configure`?(0,$.jsx)(X,{name:`devices-connected`,className:`mb-3 size-20 text-muted-foreground`}):null,(0,$.jsx)(mn,{className:`text-xl`,children:e(Dt===`result`?`settings.remoteInstances.clientAuth.qrDialogTitle`:`settings.remoteInstances.clientAuth.actions.addDevice`)}),(0,$.jsx)(hn,{className:`max-w-sm text-center leading-relaxed`,children:e(Dt===`result`?`settings.remoteInstances.clientAuth.qrScanHint`:`settings.remoteInstances.quick.emptyHint`)})]}),Dt===`configure`?(0,$.jsxs)(`ol`,{className:`grid grid-cols-3 gap-3 py-4 text-center`,children:[(0,$.jsxs)(`li`,{className:`flex min-w-0 flex-col items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`flex size-6 shrink-0 items-center justify-center rounded-full bg-[var(--surface-muted)] typography-micro text-muted-foreground`,"aria-hidden":`true`,children:`1`}),(0,$.jsxs)(`a`,{href:`https://github.com/yee94/yuri/releases`,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>{e.preventDefault(),Br(`https://github.com/yee94/yuri/releases`)},className:`inline-flex items-center justify-center gap-1 whitespace-nowrap typography-meta text-foreground underline decoration-[var(--interactive-border)] underline-offset-4 hover:decoration-current`,children:[e(`settings.remoteInstances.pairing.downloadStep`),(0,$.jsx)(X,{name:`external-link`,className:`size-3 shrink-0`})]})]}),(0,$.jsxs)(`li`,{className:`flex min-w-0 flex-col items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`flex size-6 shrink-0 items-center justify-center rounded-full bg-[var(--surface-muted)] typography-micro text-muted-foreground`,"aria-hidden":`true`,children:`2`}),(0,$.jsx)(`p`,{className:`typography-meta text-foreground`,children:e(`settings.remoteInstances.clientAuth.addDevice.create`)})]}),(0,$.jsxs)(`li`,{className:`flex min-w-0 flex-col items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`flex size-6 shrink-0 items-center justify-center rounded-full bg-[var(--surface-muted)] typography-micro text-muted-foreground`,"aria-hidden":`true`,children:`3`}),(0,$.jsx)(`p`,{className:`typography-meta text-foreground`,children:e(`settings.remoteInstances.clientAuth.qrDialogTitle`)})]})]}):null,Dt===`configure`?(0,$.jsxs)(`form`,{className:`space-y-4`,onSubmit:e=>{e.preventDefault(),Sn()},children:[(0,$.jsxs)(`label`,{className:`block space-y-3 rounded-2xl bg-[var(--surface-muted)] p-4`,children:[(0,$.jsxs)(`span`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.remoteInstances.pairing.name`)}),(0,$.jsx)(`span`,{id:`add-device-instance-name-hint`,className:`font-normal text-muted-foreground`,style:{fontSize:`var(--form-helper-font-size)`,lineHeight:`var(--form-helper-line-height)`},children:e(`settings.remoteInstances.clientAuth.field.labelHint`)})]}),(0,$.jsx)(Cn,{className:`w-full hover:[&:not(:focus)]:ring-border/60`,value:ot,onChange:e=>{ct.current=!0,st(e.target.value)},placeholder:e(`settings.remoteInstances.clientAuth.field.labelPlaceholder`),"aria-describedby":`add-device-instance-name-hint`})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label text-foreground`,children:e(`settings.remoteInstances.clientAuth.addDevice.transportLabel`)}),(0,$.jsx)(`div`,{role:`radiogroup`,"aria-label":e(`settings.remoteInstances.clientAuth.addDevice.transportLabel`),className:`grid grid-cols-3 gap-2 pt-2`,children:[{key:`relay`,label:e(`settings.remoteInstances.clientAuth.addDevice.transport.relay`),hint:e(`settings.remoteInstances.pairing.anywhere`),available:!!Ut?.relayAvailable},{key:`lan`,label:e(`settings.remoteInstances.clientAuth.addDevice.transport.lan`),hint:e(`settings.remoteInstances.pairing.lan`),available:!!Ut?.lanUrl},{key:`local`,label:e(`settings.remoteInstances.clientAuth.addDevice.transport.local`),hint:e(`settings.remoteInstances.pairing.local`),available:!!Ut?.localUrl}].map(e=>{let t=jt===e.key;return(0,$.jsxs)(`div`,{className:K(`flex min-w-0 flex-col gap-2 rounded-xl border p-3 transition-colors`,t?`border-[var(--interactive-selection)] bg-[var(--interactive-selection)]`:`border-[var(--interactive-border)]`,e.available?`cursor-pointer hover:bg-interactive-hover`:`opacity-45`),onClick:()=>{e.available&&Mt(e.key)},role:`presentation`,children:[(0,$.jsx)(pa,{checked:t,disabled:!e.available,onChange:()=>Mt(e.key),ariaLabel:e.label,className:`shrink-0 !self-start`}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:K(`typography-ui-label font-normal`,t?`text-foreground`:`text-foreground/70`),children:e.label}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e.hint})]})]},e.key)})}),jt===`lan`?(0,$.jsx)(Ji,{checked:Nt,onChange:J,label:e(`settings.remoteInstances.clientAuth.addDevice.fallback.relay`),ariaLabel:e(`settings.remoteInstances.clientAuth.addDevice.fallback.relay`)}):null,jt===`relay`&&Ut?.lanUrl?(0,$.jsx)(Ji,{checked:Nt,onChange:J,label:e(`settings.remoteInstances.clientAuth.addDevice.fallback.preferLocal`),ariaLabel:e(`settings.remoteInstances.clientAuth.addDevice.fallback.preferLocal`)}):null,(0,$.jsxs)(ca,{open:Rt,onOpenChange:zt,className:`pt-3`,children:[(0,$.jsxs)(sa,{className:`px-0 hover:bg-transparent`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label`,children:e(`settings.remoteInstances.pairing.advanced`)}),(0,$.jsx)(X,{name:Rt?`arrow-up-s`:`arrow-down-s`,className:`size-4 text-muted-foreground`})]}),(0,$.jsx)(`p`,{className:`mt-1 font-normal text-muted-foreground`,style:{fontSize:`var(--form-helper-font-size)`,lineHeight:`var(--form-helper-line-height)`},children:e(`settings.remoteInstances.pairing.relayHint`)}),(0,$.jsx)(oa,{children:(()=>{let t=Array.from(new Set([...Ut?.relayUrls??[],...Ut?.relayUrl?[Ut.relayUrl]:[]])),n=t.length>1,r=Ut?.relayUrlLocked!==!0,i=n&&!Bt;return(0,$.jsxs)(`label`,{className:`block space-y-1.5 pt-2`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.remoteInstances.clientAuth.addDevice.relayUrlLabel`)}),i?(0,$.jsxs)(Fr,{value:t.includes(Pt)?Pt:t[0],onValueChange:e=>{if(e===`__custom__`){Vt(!0);return}Ft(e),Lt(null)},children:[(0,$.jsx)(Pr,{className:`h-8 w-full font-mono`,"aria-label":e(`settings.remoteInstances.clientAuth.addDevice.relayUrlLabel`),children:(0,$.jsx)(Ar,{})}),(0,$.jsxs)(Nr,{children:[t.map(e=>(0,$.jsx)(jr,{value:e,className:`font-mono`,children:(0,$.jsx)(`span`,{className:`block max-w-[420px] truncate`,children:e})},e)),r?(0,$.jsx)(jr,{value:`__custom__`,children:e(`settings.remoteInstances.clientAuth.addDevice.relayUrlCustomOption`)}):null]})]}):(0,$.jsx)(Cn,{ref:Ht,className:`h-8 font-mono`,value:Pt,onChange:e=>{Ft(e.target.value),Lt(null)},placeholder:Fd,readOnly:Ut?.relayUrlLocked===!0,"aria-readonly":Ut?.relayUrlLocked===!0||void 0,"aria-invalid":!!It||void 0,"aria-describedby":It?`add-device-relay-url-hint add-device-relay-url-error`:`add-device-relay-url-hint`,spellCheck:!1,autoCapitalize:`none`,autoCorrect:`off`}),(0,$.jsx)(`span`,{id:`add-device-relay-url-hint`,className:`block typography-meta text-muted-foreground`,children:Ut?.relayUrlLocked?e(`settings.remoteInstances.clientAuth.addDevice.relayUrlLockedHint`):e(`settings.remoteInstances.clientAuth.addDevice.relayUrlHint`)}),(0,$.jsx)(`a`,{href:Bd,target:`_blank`,rel:`noopener noreferrer`,className:`block typography-meta text-muted-foreground underline underline-offset-2 hover:text-foreground`,onClick:e=>{e.preventDefault(),Br(Bd)},children:e(`settings.remoteInstances.clientAuth.addDevice.relayUrlDeployLink`)}),It?(0,$.jsx)(`span`,{id:`add-device-relay-url-error`,role:`alert`,"aria-live":`polite`,className:`block typography-meta text-[var(--status-error)]`,children:It}):null]})})()})]})]}),lt?(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:lt}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-3 pt-4`,children:[(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,className:`!font-normal`,onClick:()=>Et(!1),disabled:kt,children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(q,{type:`submit`,variant:`default`,size:`sm`,className:`!font-normal`,disabled:kt||!Ut,children:e(`settings.remoteInstances.clientAuth.addDevice.create`)})]})]}):(0,$.jsxs)(`div`,{className:`space-y-3`,children:[xt?(0,$.jsx)(`div`,{className:`flex justify-center`,children:(0,$.jsx)(`img`,{src:xt,alt:e(`settings.remoteInstances.clientAuth.qrAlt`),className:`w-full max-w-[420px] rounded-md bg-white p-4`})}):null,(0,$.jsxs)(`a`,{href:`https://github.com/yee94/yuri/releases`,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>{e.preventDefault(),Br(`https://github.com/yee94/yuri/releases`)},className:`flex items-center justify-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground`,children:[(0,$.jsx)(X,{name:`download`,className:`size-3.5`}),e(`settings.remoteInstances.quick.download`),(0,$.jsx)(X,{name:`external-link`,className:`size-3`})]}),_t?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-[var(--interactive-border)] p-2`,children:[(0,$.jsx)(`code`,{className:`min-w-0 flex-1 truncate typography-code text-muted-foreground`,children:_t}),(0,$.jsxs)(q,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal shrink-0`,onClick:Dn,children:[(0,$.jsx)(X,{name:Ct?`check`:`file-copy`,className:K(`h-3.5 w-3.5`,Ct&&`text-[var(--status-success)]`)}),e(Ct?`settings.remoteInstances.clientAuth.actions.copied`:`settings.common.actions.copyAll`)]})]}):null,(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(q,{type:`button`,size:`xs`,className:`!font-normal`,onClick:()=>Et(!1),children:e(`settings.remoteInstances.clientAuth.addDevice.done`)})})]})]})}),i?(0,$.jsx)(gn,{open:Kt,onOpenChange:qt,children:(0,$.jsxs)(pn,{className:`yuri-settings-workspace yuri-settings-workspace-desktop sm:max-w-2xl`,children:[(0,$.jsx)(dn,{children:(0,$.jsx)(mn,{children:e(`settings.remoteInstances.sidebar.actions.addSshInstance`)})}),(0,$.jsxs)(`form`,{className:`yuri-settings-section-stack`,onSubmit:e=>{e.preventDefault(),on()},children:[(0,$.jsxs)(Z,{children:[(0,$.jsx)(Xi,{label:e(`settings.remoteInstances.page.field.sshCommand`),className:`yuri-settings-ssh-command-row`,children:(0,$.jsx)(Cn,{value:Jt,onChange:e=>Yt(e.target.value),"aria-label":e(`settings.remoteInstances.page.field.sshCommand`),placeholder:e(`settings.remoteInstances.page.field.sshCommandPlaceholder`),disabled:d,autoFocus:!0})}),(0,$.jsx)(Xi,{label:e(`settings.remoteInstances.page.field.nickname`),children:(0,$.jsx)(Cn,{value:Xt,onChange:e=>Zt(e.target.value),"aria-label":e(`settings.remoteInstances.page.field.nickname`),placeholder:e(`settings.remoteInstances.page.field.nicknamePlaceholder`),disabled:d})})]}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(q,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>qt(!1),disabled:d,children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(q,{type:`submit`,size:`xs`,className:`!font-normal`,disabled:d||!Jt.trim(),children:e(`settings.common.actions.create`)})]})]})]})}):null,(0,$.jsx)(Od,{}),(0,$.jsx)(Pd,{}),(0,$.jsx)(gn,{open:!!me,onOpenChange:e=>{e||Jn()},children:(0,$.jsxs)(pn,{className:`sm:max-w-md`,children:[(0,$.jsxs)(dn,{children:[(0,$.jsx)(mn,{children:e(`settings.remoteInstances.page.patternDialog.title`)}),(0,$.jsx)(hn,{children:me?e(`settings.remoteInstances.page.patternDialog.descriptionWithHost`,{host:me}):e(`settings.remoteInstances.page.patternDialog.description`)})]}),(0,$.jsxs)(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),Yn()},children:[(0,$.jsx)(Cn,{value:ge,onChange:e=>_e(e.target.value),placeholder:e(`settings.remoteInstances.page.patternDialog.destinationPlaceholder`),autoFocus:!0}),(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,$.jsx)(q,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:Jn,disabled:ve,children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(q,{type:`submit`,size:`xs`,className:`!font-normal`,disabled:ve,children:e(`settings.remoteInstances.page.actions.create`)})]})]})]})})]}),(0,$.jsx)(qd,{open:oe,instanceId:ce,targetKind:ue,relayHost:fe,onOpenChange:e=>{se(e),e||(le(null),de(`ssh`),pe(null))}})]});let pr=O.nickname?.trim()||O.sshParsed?.destination||O.id;return(0,$.jsx)(gn,{open:!!O,onOpenChange:e=>{!e&&!xe&&w(null)},children:(0,$.jsxs)(pn,{className:`yuri-settings-workspace yuri-settings-workspace-desktop yuri-settings-section-stack sm:max-w-2xl`,children:[(0,$.jsx)(Gi,{actions:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>void Kn(),disabled:d||xe,"aria-busy":xe,"aria-label":e(`settings.common.actions.delete`),children:(0,$.jsx)(X,{name:xe?`refresh`:`delete-bin`,className:K(`size-4`,xe&&`animate-spin`)})}),(0,$.jsxs)(q,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>void tr(),disabled:xe,children:[(0,$.jsx)(X,{name:`terminal-window`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.page.actions.logs`)]}),Mn?.localUrl?(0,$.jsxs)(q,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>void ar(),disabled:xe,children:[(0,$.jsx)(X,{name:`external-link`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.page.actions.open`)]}):null,Bn?(0,$.jsxs)(q,{type:`button`,size:`xs`,className:`!font-normal`,onClick:lr,disabled:!dr||xe,children:[(0,$.jsx)(X,{name:`refresh`,className:`h-3.5 w-3.5`}),ur]}):null,(0,$.jsxs)(q,{type:`button`,size:`xs`,className:`!font-normal`,onClick:sr,disabled:we||Ee||xe,children:[(0,$.jsx)(X,{name:Rn?`stop`:`plug-2`,className:`h-3.5 w-3.5`}),fr]}),(0,$.jsx)(q,{type:`button`,size:`xs`,className:`!font-normal`,onClick:()=>void Gn(),disabled:!Hn||d||xe,"aria-busy":d,children:e(`settings.common.actions.saveChanges`)})]}),children:(0,$.jsxs)(dn,{className:`gap-1`,children:[(0,$.jsx)(mn,{className:`truncate`,children:pr}),(0,$.jsxs)(hn,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-full ${tf(Nn)}`}),(0,$.jsx)(`span`,{children:e(Qd(Nn))}),Bn?(0,$.jsx)(`span`,{children:e(`settings.remoteInstances.page.status.reconnectStale`)}):null]})]})}),Nn===`error`?(0,$.jsx)(kn,{errorCode:Mn?.errorCode,detail:Mn?.detail}):null,(0,$.jsxs)(Z,{label:e(`settings.remoteInstances.page.section.instance`),children:[(0,$.jsx)(Xi,{label:e(`settings.remoteInstances.page.field.sshCommand`),className:`yuri-settings-ssh-command-row`,children:(0,$.jsx)(Cn,{value:O.sshCommand,"aria-label":e(`settings.remoteInstances.page.field.sshCommand`),disabled:xe,onChange:e=>Wn(t=>({...t,sshCommand:e.target.value})),placeholder:e(`settings.remoteInstances.page.field.sshCommandPlaceholder`)})}),(0,$.jsx)(Xi,{label:e(`settings.remoteInstances.page.field.nickname`),children:(0,$.jsx)(Cn,{value:O.nickname||``,"aria-label":e(`settings.remoteInstances.page.field.nickname`),disabled:xe,onChange:e=>Wn(t=>({...t,nickname:e.target.value})),placeholder:e(`settings.remoteInstances.page.field.nicknamePlaceholder`)})}),O.remoteYuri.mode===`external`?(0,$.jsx)(Xi,{label:e(`settings.remoteInstances.page.field.preferredRemotePort`),children:(0,$.jsx)(ma,{min:1,max:65535,step:1,className:`tabular-nums`,"aria-label":e(`settings.remoteInstances.page.field.preferredRemotePort`),disabled:xe,value:O.remoteYuri.preferredPort,onValueChange:e=>{Wn(t=>({...t,remoteYuri:{...t.remoteYuri,preferredPort:Number.isFinite(e)&&e>0?e:void 0}}))},onClear:()=>{Wn(e=>({...e,remoteYuri:{...e.remoteYuri,preferredPort:void 0}}))},emptyLabel:e(`settings.remoteInstances.page.field.auto`)})}):null,(0,$.jsx)(Xi,{label:e(`settings.remoteInstances.page.field.sshPasswordOptional`),children:(0,$.jsx)(Cn,{type:`password`,value:O.auth.sshPassword?.value||``,"aria-label":e(`settings.remoteInstances.page.field.sshPasswordOptional`),disabled:xe,onChange:e=>Wn(t=>({...t,auth:{...t.auth,sshPassword:{enabled:e.target.value.trim().length>0,value:e.target.value,store:t.auth.sshPassword?.store||`never`}}})),placeholder:e(`settings.remoteInstances.page.field.sshPasswordPlaceholder`)})}),O.remoteYuri.mode===`external`||T?.auth.yuriPassword?.enabled?(0,$.jsx)(Xi,{label:e(`settings.remoteInstances.page.field.uiPasswordOptional`),children:(0,$.jsx)(Cn,{type:`password`,value:O.auth.yuriPassword?.value||``,"aria-label":e(`settings.remoteInstances.page.field.uiPasswordOptional`),disabled:xe,onChange:e=>Wn(t=>({...t,auth:{...t.auth,yuriPassword:{enabled:e.target.value.trim().length>0,value:e.target.value,store:t.auth.yuriPassword?.store||`never`}}})),placeholder:e(`settings.remoteInstances.page.field.uiPasswordPlaceholder`)})}):null]}),f?(0,$.jsx)(`div`,{role:`alert`,className:`typography-meta text-[var(--status-error)]`,children:f}):null,(0,$.jsx)(qd,{open:oe,instanceId:ce,targetKind:ue,relayHost:fe,onOpenChange:e=>{se(e),e||(le(null),de(`ssh`),pe(null))}}),(0,$.jsx)(gn,{open:A,onOpenChange:W,children:(0,$.jsxs)(pn,{className:`sm:max-w-2xl`,children:[(0,$.jsxs)(dn,{children:[(0,$.jsx)(mn,{children:e(`settings.remoteInstances.page.logsDialog.title`)}),(0,$.jsx)(hn,{children:O?.nickname?.trim()||O?.sshParsed?.destination||O?.id||e(`settings.remoteInstances.page.logsDialog.selectedInstanceFallback`)})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,$.jsxs)(q,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:rr,disabled:ee||!nr.trim(),children:[(0,$.jsx)(X,{name:`file-copy`,className:`h-3.5 w-3.5`}),e(`settings.common.actions.copyAll`)]}),(0,$.jsxs)(q,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>void ir(),disabled:ee,children:[(0,$.jsx)(X,{name:`delete-bin`,className:`h-3.5 w-3.5`}),e(`settings.common.actions.clear`)]})]}),ee?(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:e(`settings.remoteInstances.page.logsDialog.loading`)}):ne?(0,$.jsx)(`div`,{className:`typography-meta text-[var(--status-error)]`,children:ne}):(0,$.jsx)(`pre`,{className:`max-h-[55vh] overflow-auto rounded-md border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-3 typography-micro text-foreground whitespace-pre-wrap break-words`,children:ie.length>0?ie.join(`
28
- `):e(`settings.remoteInstances.page.logsDialog.empty`)})]})}),(0,$.jsx)(gn,{open:!!me,onOpenChange:e=>{e||Jn()},children:(0,$.jsxs)(pn,{className:`sm:max-w-md`,children:[(0,$.jsxs)(dn,{children:[(0,$.jsx)(mn,{children:e(`settings.remoteInstances.page.patternDialog.title`)}),(0,$.jsx)(hn,{children:me?e(`settings.remoteInstances.page.patternDialog.descriptionWithHost`,{host:me}):e(`settings.remoteInstances.page.patternDialog.description`)})]}),(0,$.jsxs)(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),Yn()},children:[(0,$.jsx)(Cn,{value:ge,onChange:e=>_e(e.target.value),placeholder:e(`settings.remoteInstances.page.patternDialog.destinationPlaceholder`),autoFocus:!0}),(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,$.jsx)(q,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:Jn,disabled:ve,children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(q,{type:`submit`,size:`xs`,className:`!font-normal`,disabled:ve,children:e(`settings.common.actions.create`)})]})]})]})})]})})},ff=`__add_provider__`,pf=`__custom_provider__`,mf=e=>{let t=(0,Sa.c)(85),{onItemSelect:n}=e,{t:i}=Ge(),a=Pt(gf),s=Pt(_f),c=Pt(vf),l=ce(yf);Q.useSyncExternalStore(r,o,o);let u=l??void 0,d;t[0]===u?d=t[1]:(d=ua(u),t[0]=u,t[1]=d);let f=De(d),p=f.data,[m,h]=Q.useState(``),g;t[2]!==p||t[3]!==i?(g=e=>{let t=p?.[e]?.auth.type;return i(t===`api`?`settings.providers.page.auth.apiKeyLabel`:t===`oauth`||t===`external`?`settings.providers.auth.account`:`settings.providers.auth.managed`)},t[2]=p,t[3]=i,t[4]=g):g=t[4];let _=g,v;if(t[5]!==a||t[6]!==m||t[7]!==p){let e;t[9]!==m||t[10]!==p?(e=e=>!!p?.[e.id]?.project?.exists&&`${e.name} ${e.id}`.toLowerCase().includes(m.trim().toLowerCase()),t[9]=m,t[10]=p,t[11]=e):e=t[11],v=a.filter(e),t[5]=a,t[6]=m,t[7]=p,t[8]=v}else v=t[8];let y=v,b;if(t[12]!==a||t[13]!==m||t[14]!==p){let e;t[16]!==m||t[17]!==p?(e=e=>!p?.[e.id]?.project?.exists&&`${e.name} ${e.id}`.toLowerCase().includes(m.trim().toLowerCase()),t[16]=m,t[17]=p,t[18]=e):e=t[18],b=a.filter(e),t[12]=a,t[13]=m,t[14]=p,t[15]=b}else b=t[15];let x=b,S;t[19]===i?S=t[20]:(S=i(`settings.providers.sidebar.title`),t[19]=i,t[20]=S);let C;t[21]===S?C=t[22]:(C=(0,$.jsx)(`span`,{children:S}),t[21]=S,t[22]=C);let w;t[23]!==n||t[24]!==c?(w=()=>{c(ff),n?.()},t[23]=n,t[24]=c,t[25]=w):w=t[25];let T;t[26]===i?T=t[27]:(T=i(`settings.providers.sidebar.actions.connectProviderAria`),t[26]=i,t[27]=T);let E;t[28]===i?E=t[29]:(E=i(`settings.providers.sidebar.actions.connectProviderTitle`),t[28]=i,t[29]=E);let D;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,$.jsx)(X,{name:`add`,className:`h-4 w-4`}),t[30]=D):D=t[30];let O;t[31]!==E||t[32]!==w||t[33]!==T?(O=(0,$.jsx)(q,{size:`icon`,variant:`ghost`,onClick:w,"aria-label":T,title:E,children:D}),t[31]=E,t[32]=w,t[33]=T,t[34]=O):O=t[34];let k;t[35]!==O||t[36]!==C?(k=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[C,O]}),t[35]=O,t[36]=C,t[37]=k):k=t[37];let A=k,j;t[38]===i?j=t[39]:(j=i(`settings.providers.custom.title`),t[38]=i,t[39]=j);let M;t[40]===j?M=t[41]:(M={id:pf,name:j},t[40]=j,t[41]=M);let N;t[42]!==n||t[43]!==c?(N=()=>{c(pf),n?.()},t[42]=n,t[43]=c,t[44]=N):N=t[44];let P;t[45]!==s||t[46]!==M||t[47]!==N?(P=(0,$.jsx)(hf,{provider:M,selectedProviderId:s,onSelect:N}),t[45]=s,t[46]=M,t[47]=N,t[48]=P):P=t[48];let F=P,I;t[49]!==f.isError||t[50]!==i?(I=f.isError&&(0,$.jsx)(`p`,{role:`alert`,className:`typography-meta text-muted-foreground`,children:i(`settings.providers.page.toast.providerSourcesLoadFailed`)}),t[49]=f.isError,t[50]=i,t[51]=I):I=t[51];let L;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(X,{name:`search`,className:`pointer-events-none absolute left-2 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`}),t[52]=L):L=t[52];let R;t[53]===i?R=t[54]:(R=i(`settings.providers.page.connect.searchProvidersPlaceholder`),t[53]=i,t[54]=R);let z;t[55]===i?z=t[56]:(z=i(`settings.providers.page.connect.searchProvidersPlaceholder`),t[55]=i,t[56]=z);let B;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(B=e=>h(e.target.value),t[57]=B):B=t[57];let V;t[58]!==m||t[59]!==R||t[60]!==z?(V=(0,$.jsxs)(`div`,{className:`relative`,children:[L,(0,$.jsx)(Cn,{className:`!h-8 !min-h-0 !pl-7 !text-left !text-[13px]`,"aria-label":R,placeholder:z,value:m,onChange:B})]}),t[58]=m,t[59]=R,t[60]=z,t[61]=V):V=t[61];let H;t[62]===F?H=t[63]:(H=(0,$.jsx)(Z,{cardClassName:`yuri-provider-collection-card`,children:F}),t[62]=F,t[63]=H);let U;t[64]!==_||t[65]!==n||t[66]!==y||t[67]!==a.length||t[68]!==s||t[69]!==c||t[70]!==i||t[71]!==x?(U=(0,$.jsx)($.Fragment,{children:a.length===0?(0,$.jsx)(Z,{children:(0,$.jsxs)(`div`,{className:`yuri-settings-group-row py-12 text-center text-muted-foreground`,children:[(0,$.jsx)(X,{name:`stack`,className:`mx-auto mb-3 h-10 w-10 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-ui-label font-medium`,children:i(`settings.providers.sidebar.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:i(`settings.providers.sidebar.empty.description`)})]})}):(0,$.jsxs)($.Fragment,{children:[x.length>0?(0,$.jsx)(Z,{label:i(`settings.providers.sidebar.section.userProviders`),cardClassName:`yuri-provider-collection-card`,children:x.map(e=>(0,$.jsx)(hf,{provider:e,description:_(e.id),selectedProviderId:s,onSelect:()=>{c(e.id),n?.()}},e.id))}):null,y.length>0&&(0,$.jsx)(Z,{label:i(`settings.providers.sidebar.section.projectProviders`),cardClassName:`yuri-provider-collection-card`,children:y.map(e=>(0,$.jsx)(hf,{provider:e,description:_(e.id),selectedProviderId:s,onSelect:()=>{c(e.id),n?.()}},e.id))})]})}),t[64]=_,t[65]=n,t[66]=y,t[67]=a.length,t[68]=s,t[69]=c,t[70]=i,t[71]=x,t[72]=U):U=t[72];let W;t[73]!==y||t[74]!==m||t[75]!==i||t[76]!==x?(W=m&&!x.length&&!y.length&&(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:i(`settings.providers.page.connect.noProvidersFound`)}),t[73]=y,t[74]=m,t[75]=i,t[76]=x,t[77]=W):W=t[77];let ee;return t[78]!==I||t[79]!==V||t[80]!==H||t[81]!==U||t[82]!==W||t[83]!==A?(ee=(0,$.jsxs)(`div`,{className:`yuri-settings-page-content h-full overflow-y-auto bg-background p-3`,children:[A,I,V,H,U,W]}),t[78]=I,t[79]=V,t[80]=H,t[81]=U,t[82]=W,t[83]=A,t[84]=ee):ee=t[84],ee},hf=e=>{let t=(0,Sa.c)(27),{provider:n,selectedProviderId:r,onSelect:i,description:a}=e,o=Array.isArray(n.models)?n.models.length:0,s=n.id===r,c=n.id,l=s?`bg-interactive-selection`:`hover:bg-interactive-hover`,u;t[0]===l?u=t[1]:(u=K(`yuri-provider-collection-row group relative flex items-center transition-colors duration-150`,l),t[0]=l,t[1]=u);let d=s?`page`:void 0,f;t[2]===n.id?f=t[3]:(f=n.id===pf?(0,$.jsx)(`span`,{className:`flex size-6 shrink-0 items-center justify-center rounded-lg border border-dashed border-[var(--interactive-border)]`,children:(0,$.jsx)(X,{name:`add`,className:`size-4`})}):(0,$.jsx)(Mr,{providerId:n.id,className:`size-5 shrink-0`}),t[2]=n.id,t[3]=f);let p=n.name||n.id,m;t[4]===p?m=t[5]:(m=(0,$.jsx)(`span`,{className:`block truncate text-[13px] leading-[18px] font-normal`,children:p}),t[4]=p,t[5]=m);let h;t[6]===a?h=t[7]:(h=a&&(0,$.jsx)(`span`,{className:`block truncate text-[11px] leading-4 text-muted-foreground`,children:a}),t[6]=a,t[7]=h);let g;t[8]!==m||t[9]!==h?(g=(0,$.jsxs)(`span`,{className:`flex-1 min-w-0 text-foreground`,children:[m,h]}),t[8]=m,t[9]=h,t[10]=g):g=t[10];let _;t[11]===n.id?_=t[12]:(_=n.id===pf&&(0,$.jsx)(X,{name:`arrow-right-s`,className:`size-4 text-muted-foreground`}),t[11]=n.id,t[12]=_);let v;t[13]!==o||t[14]!==n.id?(v=n.id!==pf&&(0,$.jsx)(`span`,{className:`text-[11px] leading-4 tabular-nums text-muted-foreground/60 flex-shrink-0`,children:o}),t[13]=o,t[14]=n.id,t[15]=v):v=t[15];let y;t[16]!==i||t[17]!==_||t[18]!==v||t[19]!==d||t[20]!==f||t[21]!==g?(y=(0,$.jsxs)(`button`,{type:`button`,onClick:i,className:`flex min-w-0 flex-1 items-center gap-2 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-foreground/20`,"aria-current":d,tabIndex:0,children:[f,g,_,v]}),t[16]=i,t[17]=_,t[18]=v,t[19]=d,t[20]=f,t[21]=g,t[22]=y):y=t[22];let b;return t[23]!==n.id||t[24]!==y||t[25]!==u?(b=(0,$.jsx)(`div`,{className:u,children:y},c),t[23]=n.id,t[24]=y,t[25]=u,t[26]=b):b=t[26],b};function gf(e){return e.providers}function _f(e){return e.selectedProviderId}function vf(e){return e.setSelectedProvider}function yf(e){return e.currentDirectory}function bf(){let{t:e}=Ge(),t=wi(e=>e.magpieUsageUrl),n=wi(e=>e.magpieSources),r=wi(e=>e.magpieError),a=wi(e=>e.fetchMagpieQuotas),[o,s]=Q.useState(null),[c,l]=Q.useState(!1),[u,d]=Q.useState(!1),f=Q.useId(),p=n.reduce((e,t)=>e+t.results.length,0),m=i();Q.useEffect(()=>{s(null),d(!1)},[m]);let h=He(async()=>{let e=i(),n=(o??t).trim();l(!0),d(!1);try{if(n){let e=new URL(n);if(![`http:`,`https:`].includes(e.protocol)||e.username||e.password||e.search||e.hash)throw Error(`Invalid URL`)}if(await ye({magpieUsageUrl:n}),e!==i())return;wi.setState({magpieUsageUrl:n}),s(null),await a()}catch{e===i()&&d(!0)}finally{l(!1)}});return(0,$.jsx)(Z,{label:`Magpie`,itemId:`usage.magpie`,actions:(0,$.jsx)(q,{size:`sm`,onClick:h,disabled:c||o===null||o===t,"aria-busy":c,children:e(`settings.usage.magpie.save`)}),children:(0,$.jsxs)(`div`,{className:`yuri-settings-group-row min-w-0`,children:[(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground break-words`,children:p>0?e(`settings.usage.magpie.connected`,{count:p}):e(`settings.usage.magpie.description`)}),(r||n.some(e=>e.identified&&e.error))&&(0,$.jsx)(`p`,{role:`status`,className:`typography-meta text-muted-foreground`,children:e(`settings.usage.magpie.unavailable`)}),(0,$.jsxs)(`details`,{className:`mt-2 min-w-0`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer typography-meta text-muted-foreground hover:text-foreground`,children:e(`settings.usage.magpie.manual`)}),(0,$.jsxs)(`div`,{className:`mt-3 flex min-w-0 flex-col gap-2`,children:[(0,$.jsx)(`label`,{htmlFor:f,className:`typography-meta text-muted-foreground`,children:e(`settings.usage.magpie.url`)}),(0,$.jsx)(Cn,{id:f,className:`w-full min-w-0`,value:o??t,disabled:c,onChange:e=>s(e.target.value),"aria-label":e(`settings.usage.magpie.url`)}),u&&(0,$.jsx)(`p`,{role:`alert`,className:`typography-meta text-[var(--status-error)]`,children:e(`settings.usage.page.state.refreshFailedTitle`)})]})]})]})})}var xf=e=>{let t=e?.windows??{},n=Object.values(t).map(e=>e.usedPercent).filter(e=>typeof e==`number`);return n.length===0?null:Math.max(...n)},Sf=e=>{let t=(0,Sa.c)(122),{onItemSelect:n,children:r}=e,{t:i}=Ge(),a=wi(Cf),o=wi(wf),s=wi(Tf),c=wi(Ef),l=wi(Df),u=wi(Of),d=wi(kf),f=wi(Af),p=wi(jf),m=wi(Mf),h=wi(Nf),g=wi(Pf),_=wi(Ff),v=wi(If),y,b;t[0]===v?(y=t[1],b=t[2]):(y=()=>{v()},b=[v],t[0]=v,t[1]=y,t[2]=b),Q.useEffect(y,b);let x=Lf,S;t[3]===p?S=t[4]:(S=e=>{p(e),x({usageAutoRefresh:e})},t[3]=p,t[4]=S);let C=S,w;t[5]===m?w=t[6]:(w=e=>{let t=Number(e);Number.isFinite(t)&&(m(t),x({usageRefreshIntervalMs:t}))},t[5]=m,t[6]=w);let T=w,E;t[7]===h?E=t[8]:(E=e=>{(e===`usage`||e===`remaining`)&&(h(e),x({usageDisplayMode:e}))},t[7]=h,t[8]=E);let D=E,O;t[9]===_?O=t[10]:(O=e=>{_(e),x({usageShowPredValues:e})},t[9]=_,t[10]=O);let k=O,A=r?`yuri-settings-usage-workspace`:`yuri-settings-usage-sidebar`,j;t[11]===A?j=t[12]:(j=K(`yuri-settings-page-content h-full min-w-0 overflow-y-auto bg-background p-3`,A),t[11]=A,t[12]=j);let M;t[13]===i?M=t[14]:(M=i(`settings.usage.sidebar.title`),t[13]=i,t[14]=M);let N;t[15]===c?N=t[16]:(N=()=>c(),t[15]=c,t[16]=N);let P;t[17]===i?P=t[18]:(P=i(`settings.usage.sidebar.actions.refreshAria`),t[17]=i,t[18]=P);let F;t[19]===i?F=t[20]:(F=i(`settings.usage.sidebar.actions.refreshTitle`),t[19]=i,t[20]=F);let I=l&&`animate-spin`,L;t[21]===I?L=t[22]:(L=K(`h-3.5 w-3.5`,I),t[21]=I,t[22]=L);let R;t[23]===L?R=t[24]:(R=(0,$.jsx)(X,{name:`refresh`,className:L}),t[23]=L,t[24]=R);let z;t[25]!==l||t[26]!==N||t[27]!==P||t[28]!==F||t[29]!==R?(z=(0,$.jsx)(q,{size:`icon`,variant:`ghost`,className:`text-muted-foreground`,onClick:N,"aria-label":P,title:F,disabled:l,children:R}),t[25]=l,t[26]=N,t[27]=P,t[28]=F,t[29]=R,t[30]=z):z=t[30];let B;t[31]!==z||t[32]!==M?(B=(0,$.jsx)(Xi,{label:M,children:z}),t[31]=z,t[32]=M,t[33]=B):B=t[33];let V;t[34]===i?V=t[35]:(V=i(`settings.usage.sidebar.field.autoRefresh`),t[34]=i,t[35]=V);let H;t[36]===i?H=t[37]:(H=i(`settings.usage.sidebar.actions.toggleAutoRefreshAria`),t[36]=i,t[37]=H);let U;t[38]!==C||t[39]!==H||t[40]!==u?(U=(0,$.jsx)(Wi,{checked:u,onChange:C,ariaLabel:H}),t[38]=C,t[39]=H,t[40]=u,t[41]=U):U=t[41];let W;t[42]!==V||t[43]!==U?(W=(0,$.jsx)(Xi,{label:V,children:U}),t[42]=V,t[43]=U,t[44]=W):W=t[44];let ee;t[45]===i?ee=t[46]:(ee=i(`settings.usage.sidebar.field.refreshInterval`),t[45]=i,t[46]=ee);let te=String(d),ne=!u,re;t[47]===i?re=t[48]:(re=i(`settings.usage.sidebar.field.intervalPlaceholder`),t[47]=i,t[48]=re);let ie;t[49]===re?ie=t[50]:(ie=(0,$.jsx)(Pr,{className:`w-fit`,children:(0,$.jsx)(Ar,{placeholder:re,children:Rf})}),t[49]=re,t[50]=ie);let ae;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,$.jsxs)(Nr,{children:[(0,$.jsx)(jr,{value:`30000`,children:`30s`}),(0,$.jsx)(jr,{value:`60000`,children:`1m`}),(0,$.jsx)(jr,{value:`300000`,children:`5m`})]}),t[51]=ae):ae=t[51];let oe;t[52]!==T||t[53]!==te||t[54]!==ne||t[55]!==ie?(oe=(0,$.jsxs)(Fr,{value:te,onValueChange:T,disabled:ne,children:[ie,ae]}),t[52]=T,t[53]=te,t[54]=ne,t[55]=ie,t[56]=oe):oe=t[56];let se;t[57]!==ee||t[58]!==oe?(se=(0,$.jsx)(Xi,{label:ee,children:oe}),t[57]=ee,t[58]=oe,t[59]=se):se=t[59];let ce;t[60]===i?ce=t[61]:(ce=i(`settings.usage.sidebar.field.display`),t[60]=i,t[61]=ce);let le;t[62]===i?le=t[63]:(le=i(`settings.usage.sidebar.field.displayModePlaceholder`),t[62]=i,t[63]=le);let ue;t[64]===i?ue=t[65]:(ue=e=>e===`usage`?i(`settings.usage.sidebar.field.displayModeUsage`):e===`remaining`?i(`settings.usage.sidebar.field.displayModeRemaining`):e,t[64]=i,t[65]=ue);let de;t[66]!==le||t[67]!==ue?(de=(0,$.jsx)(Pr,{className:`w-fit`,children:(0,$.jsx)(Ar,{placeholder:le,children:ue})}),t[66]=le,t[67]=ue,t[68]=de):de=t[68];let G;t[69]===i?G=t[70]:(G=i(`settings.usage.sidebar.field.displayModeUsage`),t[69]=i,t[70]=G);let fe;t[71]===G?fe=t[72]:(fe=(0,$.jsx)(jr,{value:`usage`,children:G}),t[71]=G,t[72]=fe);let pe;t[73]===i?pe=t[74]:(pe=i(`settings.usage.sidebar.field.displayModeRemaining`),t[73]=i,t[74]=pe);let me;t[75]===pe?me=t[76]:(me=(0,$.jsx)(jr,{value:`remaining`,children:pe}),t[75]=pe,t[76]=me);let he;t[77]!==fe||t[78]!==me?(he=(0,$.jsxs)(Nr,{children:[fe,me]}),t[77]=fe,t[78]=me,t[79]=he):he=t[79];let ge;t[80]!==D||t[81]!==de||t[82]!==he||t[83]!==f?(ge=(0,$.jsxs)(Fr,{value:f,onValueChange:D,children:[de,he]}),t[80]=D,t[81]=de,t[82]=he,t[83]=f,t[84]=ge):ge=t[84];let _e;t[85]!==ce||t[86]!==ge?(_e=(0,$.jsx)(Xi,{label:ce,children:ge}),t[85]=ce,t[86]=ge,t[87]=_e):_e=t[87];let ve;t[88]===i?ve=t[89]:(ve=i(`settings.usage.sidebar.field.showPredictions`),t[88]=i,t[89]=ve);let ye;t[90]===i?ye=t[91]:(ye=i(`settings.usage.sidebar.field.showPredictions`),t[90]=i,t[91]=ye);let be;t[92]!==k||t[93]!==g||t[94]!==ve||t[95]!==ye?(be=(0,$.jsx)(Ji,{checked:g,onChange:k,label:ve,ariaLabel:ye}),t[92]=k,t[93]=g,t[94]=ve,t[95]=ye,t[96]=be):be=t[96];let xe;t[97]!==B||t[98]!==W||t[99]!==se||t[100]!==_e||t[101]!==be?(xe=(0,$.jsxs)(Z,{children:[B,W,se,_e,be]}),t[97]=B,t[98]=W,t[99]=se,t[100]=_e,t[101]=be,t[102]=xe):xe=t[102];let Se;t[103]===Symbol.for(`react.memo_cache_sentinel`)?(Se=(0,$.jsx)(bf,{}),t[103]=Se):Se=t[103];let Ce=r?`yuri-settings-usage-results`:void 0,we;t[104]!==n||t[105]!==a||t[106]!==o||t[107]!==s||t[108]!==i?(we=pi(a).map(e=>{let t=a.find(t=>t?.providerId===e.id),r=xf(t?.usage),c=Bn(r),l=e.id===o,u=t?.configured??!1,d=u?c===`critical`?{backgroundColor:`var(--status-error)`}:c===`warn`?{backgroundColor:`var(--status-warning)`}:{backgroundColor:`var(--status-success)`}:{backgroundColor:`var(--surface-muted-foreground)`,opacity:.4};return(0,$.jsx)(`div`,{className:K(`yuri-settings-group-row group relative flex items-center transition-colors duration-150`,l?`bg-interactive-selection`:`hover:bg-interactive-hover`),children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{s(e.id),n?.()},className:`flex min-w-0 flex-1 items-center gap-2 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,children:[(0,$.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-full flex-shrink-0`,style:d}),(0,$.jsx)(Mr,{providerId:e.id,className:`h-4 w-4 flex-shrink-0`}),(0,$.jsx)(`span`,{className:`typography-ui-label font-normal truncate flex-1 min-w-0 text-foreground`,children:e.name}),!u&&(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/60 flex-shrink-0`,children:i(`settings.usage.sidebar.status.notSet`)})]})},e.id)}),t[104]=n,t[105]=a,t[106]=o,t[107]=s,t[108]=i,t[109]=we):we=t[109];let Te;t[110]===we?Te=t[111]:(Te=(0,$.jsx)(Z,{children:we}),t[110]=we,t[111]=Te);let Ee;t[112]===r?Ee=t[113]:(Ee=r&&(0,$.jsx)(`div`,{className:`yuri-settings-usage-detail min-w-0`,children:r}),t[112]=r,t[113]=Ee);let De;t[114]!==Ce||t[115]!==Te||t[116]!==Ee?(De=(0,$.jsxs)(`div`,{className:Ce,children:[Te,Ee]}),t[114]=Ce,t[115]=Te,t[116]=Ee,t[117]=De):De=t[117];let Oe;return t[118]!==xe||t[119]!==De||t[120]!==j?(Oe=(0,$.jsxs)(`div`,{className:j,children:[xe,Se,De]}),t[118]=xe,t[119]=De,t[120]=j,t[121]=Oe):Oe=t[121],Oe};function Cf(e){return e.results}function wf(e){return e.selectedProviderId}function Tf(e){return e.setSelectedProvider}function Ef(e){return e.fetchAllQuotas}function Df(e){return e.isLoading}function Of(e){return e.autoRefresh}function kf(e){return e.refreshIntervalMs}function Af(e){return e.displayMode}function jf(e){return e.setAutoRefresh}function Mf(e){return e.setRefreshInterval}function Nf(e){return e.setDisplayMode}function Pf(e){return e.showPredValues}function Ff(e){return e.setShowPredValues}function If(e){return e.loadSettings}async function Lf(e){try{await ye(e)}catch(e){console.warn(`Failed to save usage settings:`,e)}}function Rf(e){return e===`30000`?`30s`:e===`60000`?`1m`:e===`300000`?`5m`:e}var zf=e=>{let t=(0,Sa.c)(53),{title:n,window:r,subtitle:i,showToggle:a,toggleEnabled:o,onToggle:s}=e,c=a!==void 0&&a,l=o!==void 0&&o,{locale:u,t:d}=Ge(),[f,p]=Q.useState(Date.now),m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>p(Date.now()),t[0]=m):m=t[0],Ue(m,r.disablePace&&r.resetAt?3e4:null);let h=r.resetAt?Math.max(0,Math.ceil((r.resetAt-f)/6e4)):null,g;t[1]!==u||t[2]!==h?(g=h===null?``:[{unit:`day`,value:Math.floor(h/1440)},{unit:`hour`,value:Math.floor(h%1440/60)},{unit:`minute`,value:h%60}].filter(e=>{let{unit:t,value:n}=e;return n>0||t===`minute`&&h===0}).map(e=>{let{unit:t,value:n}=e;return new Intl.NumberFormat(u,{style:`unit`,unit:t,unitDisplay:`long`}).format(n)}).join(` `),t[1]=u,t[2]=h,t[3]=g):g=t[3];let _=g,v=wi(Bf),y=wi(Vf),b=G(Hf),x=v===`remaining`?r.remainingPercent:r.usedPercent,S=v===`remaining`?`remaining`:`used`,C;t[4]!==x||t[5]!==r.disablePace||t[6]!==r.valueLabel?(C=r.disablePace&&r.valueLabel&&x!==null?`${Wn(null,x)} · ${r.valueLabel}`:Wn(r.valueLabel,x),t[4]=x,t[5]=r.disablePace,t[6]=r.valueLabel,t[7]=C):C=t[7];let w=C,T=r.resetAfterFormatted??r.resetAtFormatted,E;t[8]!==T||t[9]!==b||t[10]!==r.resetAt?(E=Mn(r.resetAt,T,b),t[8]=T,t[9]=b,t[10]=r.resetAt,t[11]=E):E=t[11];let D=E,O;t[12]===n?O=t[13]:(O=On(n),t[12]=n,t[13]=O);let k=O,A;t[14]!==n||t[15]!==r.disablePace||t[16]!==r.resetAt||t[17]!==r.usedPercent||t[18]!==r.windowSeconds?(A=r.disablePace?null:Jn(r.usedPercent,r.resetAt,r.windowSeconds,n),t[14]=n,t[15]=r.disablePace,t[16]=r.resetAt,t[17]=r.usedPercent,t[18]=r.windowSeconds,t[19]=A):A=t[19];let j=A,M;bb0:{if(!j||j.dailyAllocationPercent===null){M=null;break bb0}let e=yr(j.elapsedRatio);M=v===`remaining`?100-e:e}let N=M,P;t[20]===k?P=t[21]:(P=(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:k}),t[20]=k,t[21]=P);let F;t[22]===i?F=t[23]:(F=i&&(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground truncate`,children:i}),t[22]=i,t[23]=F);let I;t[24]!==P||t[25]!==F?(I=(0,$.jsx)(`div`,{className:`min-w-0 flex-1 flex items-center gap-2`,children:(0,$.jsxs)(`div`,{className:`min-w-0 flex flex-col`,children:[P,F]})}),t[24]=P,t[25]=F,t[26]=I):I=t[26];let L=w===`-`?``:w,R;t[27]!==s||t[28]!==c||t[29]!==d||t[30]!==l?(R=c&&(0,$.jsx)(Wi,{checked:l,onChange:e=>s?.(e),ariaLabel:d(`settings.usage.page.options.showInHeaderAria`)}),t[27]=s,t[28]=c,t[29]=d,t[30]=l,t[31]=R):R=t[31];let z;t[32]!==L||t[33]!==R?(z=(0,$.jsxs)(`div`,{className:`typography-ui-label text-foreground tabular-nums flex items-center justify-end gap-2`,children:[L,R]}),t[32]=L,t[33]=R,t[34]=z):z=t[34];let B;t[35]!==I||t[36]!==z?(B=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[I,z]}),t[35]=I,t[36]=z,t[37]=B):B=t[37];let V;t[38]!==S||t[39]!==_||t[40]!==x||t[41]!==N||t[42]!==D||t[43]!==r.disablePace||t[44]!==r.usedPercent?(V=(!r.disablePace||x!==null||D)&&(0,$.jsxs)(`div`,{className:`mt-2.5`,children:[(!r.disablePace||x!==null)&&(0,$.jsx)(Oi,{percent:x,tonePercent:r.usedPercent,expectedMarkerPercent:N,className:`h-1.5`}),(0,$.jsxs)(`div`,{className:`mt-1 flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:D?r.disablePace?`${D} (${_})`:`Resets ${D}`:``}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:r.disablePace&&x===null?``:S})]})]}),t[38]=S,t[39]=_,t[40]=x,t[41]=N,t[42]=D,t[43]=r.disablePace,t[44]=r.usedPercent,t[45]=V):V=t[45];let H;t[46]!==j||t[47]!==y?(H=j&&y&&(0,$.jsx)(`div`,{className:`mt-1.5`,children:(0,$.jsx)(xi,{paceInfo:j})}),t[46]=j,t[47]=y,t[48]=H):H=t[48];let U;return t[49]!==B||t[50]!==V||t[51]!==H?(U=(0,$.jsxs)(`div`,{className:`py-3`,children:[B,V,H]}),t[49]=B,t[50]=V,t[51]=H,t[52]=U):U=t[52],U};function Bf(e){return e.displayMode}function Vf(e){return e.showPredValues}function Hf(e){return e.timeFormatPreference}var Uf=(e,t)=>{if(!e)return`-`;try{return Rn(e,t,{fallback:`-`})}catch{return`-`}},Wf=()=>{let{t:e}=Ge(),t=G(e=>e.timeFormatPreference),n=wi(e=>e.results),r=wi(e=>e.selectedProviderId),i=wi(e=>e.setSelectedProvider),a=wi(e=>e.loadSettings),o=wi(e=>e.fetchAllQuotas),s=wi(e=>e.isLoading),c=wi(e=>e.lastUpdated),l=wi(e=>e.error),u=wi(e=>e.dropdownProviderIds),d=wi(e=>e.setDropdownProviderIds),f=wi(e=>e.selectedModels),p=wi(e=>e.toggleModelSelected),m=wi(e=>e.applyDefaultSelections);_i(),Q.useEffect(()=>{a(),o()},[a,o]),Q.useEffect(()=>{if(r&&(!r.startsWith(`magpie:`)||n.some(e=>e.providerId===r))||n.length===0)return;let e=n.find(e=>e?.configured)?.providerId;i(e??di[0]?.id??null)},[n,r,i]);let h=n.find(e=>e?.providerId===r)??null,g=di.find(e=>e.id===r),_=h?.providerName??g?.name??r??e(`settings.usage.sidebar.title`),v=h?.usage,y=r?u.includes(r):!1,b=Q.useCallback(e=>{if(!r)return;let t=e?Array.from(new Set([...u,r])):u.filter(e=>e!==r);d(t),ye({usageDropdownProviders:t,magpieHiddenProviders:wi.getState().magpieHiddenProviders})},[u,r,d]),x=Q.useMemo(()=>v?.models?Object.entries(v.models).map(([e,t])=>({name:e,windows:t})).filter(e=>Object.keys(e.windows.windows).length>0):[],[v?.models]);Q.useEffect(()=>{r&&x.length>0&&m(r,x.map(e=>e.name))},[r,x,m]);let S=Q.useMemo(()=>!r||x.length===0?new Map:mi(x,e=>e.name,r),[x,r]),C=Q.useMemo(()=>{if(!r)return[];let e=Si(r);return ki(e)},[r]),[w,T]=Q.useState(()=>({})),E=Q.useCallback(e=>{T(t=>({...t,[e]:!t[e]}))},[]),D=Q.useCallback(e=>{if(!r)return;p(r,e);let t=f[r]??[],n=t.includes(e)?t.filter(t=>t!==e):[...t,e],i={...f,[r]:n};ye({usageSelectedModels:i})},[r,f,p]),O=r?f[r]??[]:[];return r?(0,$.jsx)(Ur,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`yuri-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(Mr,{providerId:r,className:`h-5 w-5 shrink-0`}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:e(`settings.usage.page.header.providerUsage`,{provider:_})}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground truncate`,children:s?(0,$.jsx)(`span`,{className:`animate-pulse`,children:e(`settings.usage.page.header.refreshing`)}):e(`settings.usage.page.header.lastUpdated`,{time:Uf(c,t)})})]})]}),(0,$.jsx)(Z,{children:(0,$.jsxs)(`div`,{"data-settings-item":`usage.header-menu`,className:`yuri-settings-group-row yuri-settings-split-row group cursor-pointer`,role:`button`,tabIndex:0,"aria-pressed":y,onClick:()=>b(!y),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),b(!y))},children:[(0,$.jsx)(`div`,{className:`yuri-settings-split-row-copy`,children:(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.usage.page.options.showInHeader`)}),(0,$.jsxs)(En,{children:[(0,$.jsx)(wn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 cursor-help text-muted-foreground/60`})}),(0,$.jsx)(Tn,{sideOffset:8,className:`max-w-xs`,children:e(`settings.usage.page.options.showInHeaderTooltip`)})]})]})}),(0,$.jsx)(`div`,{"data-settings-value":``,className:`yuri-settings-split-row-control`,children:(0,$.jsx)(Wi,{checked:y,onChange:b,ariaLabel:e(`settings.usage.page.options.showInHeaderAria`)})})]})}),!h&&(0,$.jsx)(`div`,{className:`px-2`,children:(0,$.jsx)(`p`,{className:`typography-ui-label text-foreground`,children:e(`settings.usage.page.state.noData`)})}),l&&(0,$.jsxs)(`div`,{className:`rounded-lg border border-[var(--status-error-border)] bg-[var(--status-error-background)] px-4 py-3`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label font-medium text-[var(--status-error)]`,children:e(`settings.usage.page.state.refreshFailedTitle`)}),(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]/80 mt-1`,children:l})]}),h?.configured&&!h.ok&&h.error&&(0,$.jsxs)(`div`,{className:`rounded-lg border border-[var(--status-error-border)] bg-[var(--status-error-background)] px-4 py-3`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label font-medium text-[var(--status-error)]`,children:e(`settings.usage.page.state.refreshFailedTitle`)}),(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]/80 mt-1`,children:h.error})]}),h&&!h.configured&&(0,$.jsxs)(`div`,{className:`rounded-lg border border-[var(--status-warning-border)] bg-[var(--status-warning-background)] px-4 py-3`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label font-medium text-[var(--status-warning)]`,children:e(`settings.usage.page.state.providerNotConfiguredTitle`)}),(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-warning)]/80 mt-1`,children:e(`settings.usage.page.state.providerNotConfiguredDescription`)})]}),v?.accounts?.map((n,r)=>(0,$.jsx)(Z,{label:n.name,children:(0,$.jsxs)(`div`,{className:`yuri-settings-group-row`,children:[(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground break-words`,children:[n.user,n.plan,n.from].filter(Boolean).join(` · `)}),n.readAt&&(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e(`settings.usage.page.header.lastUpdated`,{time:Uf(n.readAt,t)})}),n.stale&&(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e(`settings.usage.magpie.cached`)}),n.error&&(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:e(`settings.usage.page.state.refreshFailedTitle`)}),(0,$.jsx)(`div`,{className:`divide-y divide-[var(--surface-subtle)]`,children:Object.entries(n.windows).map(([e,t])=>(0,$.jsx)(zf,{title:t.label??e,window:t},e))})]})},`${n.id}:${r}`)),!v?.accounts&&v?.windows&&Object.keys(v.windows).length>0&&(0,$.jsx)(Z,{children:(0,$.jsx)(`div`,{"data-settings-item":`usage.model-quotas`,className:`yuri-settings-group-row`,children:(0,$.jsx)(`div`,{className:`divide-y divide-[var(--surface-subtle)]`,children:Object.entries(v.windows).map(([e,t])=>(0,$.jsx)(zf,{title:e,window:t},e))})})}),x.length>0&&(0,$.jsxs)(Z,{label:e(`settings.usage.page.section.modelQuotas`),children:[C.map(e=>{let t=S.get(e.id)??[];if(t.length===0)return null;let n=w[e.id]??!1;return(0,$.jsx)(`div`,{className:`yuri-settings-group-row`,children:(0,$.jsxs)(ca,{open:!n,onOpenChange:()=>E(e.id),children:[(0,$.jsxs)(sa,{className:`flex w-full items-center justify-between py-0.5 group`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-left`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label font-normal text-foreground`,children:e.label}),(0,$.jsxs)(`span`,{className:`typography-micro text-muted-foreground`,children:[`(`,t.length,`)`]})]}),n?(0,$.jsx)(X,{name:`arrow-right-s`,className:`h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors`}):(0,$.jsx)(X,{name:`arrow-down-s`,className:`h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors`})]}),(0,$.jsx)(oa,{children:(0,$.jsx)(`div`,{className:`divide-y divide-[var(--surface-subtle)] mt-1`,children:t.map(e=>{let t=Object.entries(e.windows.windows);if(t.length===0)return null;let[n,r]=t[0],i=O.includes(e.name);return(0,$.jsx)(zf,{title:n,subtitle:vi(e.name),window:r,showToggle:!0,toggleEnabled:i,onToggle:()=>D(e.name)},e.name)})})})]})},e.id)}),(()=>{let t=S.get(null)??[];if(t.length===0)return null;let n=w.other??!1;return(0,$.jsx)(`div`,{className:`yuri-settings-group-row`,children:(0,$.jsxs)(ca,{open:!n,onOpenChange:()=>E(`other`),children:[(0,$.jsxs)(sa,{className:`flex w-full items-center justify-between py-0.5 group`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-left`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label font-normal text-foreground`,children:e(`settings.usage.page.section.otherModels`)}),(0,$.jsxs)(`span`,{className:`typography-micro text-muted-foreground`,children:[`(`,t.length,`)`]})]}),n?(0,$.jsx)(X,{name:`arrow-right-s`,className:`h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors`}):(0,$.jsx)(X,{name:`arrow-down-s`,className:`h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors`})]}),(0,$.jsx)(oa,{children:(0,$.jsx)(`div`,{className:`divide-y divide-[var(--surface-subtle)] mt-1`,children:t.map(e=>{let t=Object.entries(e.windows.windows);if(t.length===0)return null;let[n,r]=t[0],i=O.includes(e.name);return(0,$.jsx)(zf,{title:n,subtitle:vi(e.name),window:r,showToggle:!0,toggleEnabled:i,onToggle:()=>D(e.name)},e.name)})})})]})})})()]}),h?.configured&&v&&Object.keys(v.windows??{}).length===0&&x.length===0&&(0,$.jsxs)(`div`,{className:`px-2`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label text-foreground`,children:e(`settings.usage.page.state.noQuotaWindowsTitle`)}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground mt-1`,children:e(`settings.usage.page.state.noQuotaWindowsDescription`)})]})]})}):(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center text-muted-foreground`,children:(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.usage.page.empty.selectProvider`)})})},Gf=`git.commit.generate`,Kf=W(e=>({selectedPromptId:Gf,setSelectedPromptId:t=>{e(e=>e.selectedPromptId===t?e:{selectedPromptId:t})}})),qf=e=>{let t=(0,Sa.c)(22),{onItemSelect:n}=e,{t:r}=Ge(),i=Kf(Jf),a=Kf(Yf),o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o={groupKey:`settings.magicPrompts.sidebar.group.git`,items:[{id:`git.commit.generate`,titleKey:`settings.magicPrompts.sidebar.item.gitCommitGenerate`},{id:`git.pr.generate`,titleKey:`settings.magicPrompts.sidebar.item.gitPrGenerate`},{id:`git.conflict.resolve`,titleKey:`settings.magicPrompts.sidebar.item.gitConflictResolve`},{id:`git.integrate.cherrypick.resolve`,titleKey:`settings.magicPrompts.sidebar.item.gitCherrypickConflictResolve`}]},t[0]=o):o=t[0];let s;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(s={groupKey:`settings.magicPrompts.sidebar.group.github`,items:[{id:`github.pr.review`,titleKey:`settings.magicPrompts.sidebar.item.githubPrReview`},{id:`github.issue.review`,titleKey:`settings.magicPrompts.sidebar.item.githubIssueReview`},{id:`github.pr.checks.review`,titleKey:`settings.magicPrompts.sidebar.item.githubPrFailedChecksReview`},{id:`github.pr.comments.review`,titleKey:`settings.magicPrompts.sidebar.item.githubPrCommentsReview`},{id:`github.pr.comment.single`,titleKey:`settings.magicPrompts.sidebar.item.githubSinglePrCommentReview`}]},t[1]=s):s=t[1];let c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=[o,s,{groupKey:`settings.magicPrompts.sidebar.group.session`,items:[{id:`session.explore`,titleKey:`settings.magicPrompts.sidebar.item.sessionExplore`},{id:`session.summary`,titleKey:`settings.magicPrompts.sidebar.item.sessionSummary`},{id:`session.review`,titleKey:`settings.magicPrompts.sidebar.item.sessionWorkspaceReview`},{id:`session.craftGoal`,titleKey:`settings.magicPrompts.sidebar.item.sessionCraftGoal`},{id:`session.catchup`,titleKey:`settings.magicPrompts.sidebar.item.sessionCatchUp`},{id:`session.debug`,titleKey:`settings.magicPrompts.sidebar.item.sessionDebug`},{id:`session.weigh`,titleKey:`settings.magicPrompts.sidebar.item.sessionWeigh`},{id:`session.fusion`,titleKey:`settings.magicPrompts.sidebar.item.sessionFusion`}]}],t[2]=c):c=t[2];let l=c,u;t[3]===r?u=t[4]:(u=r(`settings.magicPrompts.sidebar.title`),t[3]=r,t[4]=u);let d;t[5]===u?d=t[6]:(d=(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:u}),t[5]=u,t[6]=d);let f;t[7]===r?f=t[8]:(f=r(`settings.magicPrompts.sidebar.description`),t[7]=r,t[8]=f);let p;t[9]===f?p=t[10]:(p=(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:f}),t[9]=f,t[10]=p);let m;t[11]!==d||t[12]!==p?(m=(0,$.jsxs)(`div`,{className:`flex flex-col justify-center gap-1 px-2`,children:[d,p]}),t[11]=d,t[12]=p,t[13]=m):m=t[13];let h;t[14]!==n||t[15]!==i||t[16]!==a||t[17]!==r?(h=l.map(e=>(0,$.jsx)(Z,{label:r(e.groupKey),children:e.items.map(e=>{let t=i===e.id;return(0,$.jsx)(`button`,{type:`button`,onClick:()=>{a(e.id),n?.()},className:K(`yuri-settings-group-row flex w-full items-center text-left transition-colors`,t?`bg-interactive-selection text-foreground`:`text-foreground hover:bg-interactive-hover`),children:(0,$.jsx)(`span`,{className:`typography-ui-label truncate font-normal`,children:r(e.titleKey)})},e.id)})},e.groupKey)),t[14]=n,t[15]=i,t[16]=a,t[17]=r,t[18]=h):h=t[18];let g;return t[19]!==m||t[20]!==h?(g=(0,$.jsxs)(`div`,{className:`yuri-settings-page-content h-full overflow-y-auto bg-background p-3`,children:[m,h]}),t[19]=m,t[20]=h,t[21]=g):g=t[21],g};function Jf(e){return e.selectedPromptId}function Yf(e){return e.setSelectedPromptId}var Xf={"git.commit.generate":{titleKey:`settings.magicPrompts.page.group.gitCommitGenerate.title`,descriptionKey:`settings.magicPrompts.page.group.gitCommitGenerate.description`,blocks:[{id:`git.commit.generate.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`git.commit.generate.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"git.pr.generate":{titleKey:`settings.magicPrompts.page.group.gitPrGenerate.title`,descriptionKey:`settings.magicPrompts.page.group.gitPrGenerate.description`,blocks:[{id:`git.pr.generate.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`git.pr.generate.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"github.pr.review":{titleKey:`settings.magicPrompts.page.group.githubPrReview.title`,descriptionKey:`settings.magicPrompts.page.group.githubPrReview.description`,blocks:[{id:`github.pr.review.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`github.pr.review.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"github.issue.review":{titleKey:`settings.magicPrompts.page.group.githubIssueReview.title`,descriptionKey:`settings.magicPrompts.page.group.githubIssueReview.description`,blocks:[{id:`github.issue.review.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`github.issue.review.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"github.pr.checks.review":{titleKey:`settings.magicPrompts.page.group.githubPrFailedChecksReview.title`,descriptionKey:`settings.magicPrompts.page.group.githubPrFailedChecksReview.description`,blocks:[{id:`github.pr.checks.review.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`github.pr.checks.review.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"github.pr.comments.review":{titleKey:`settings.magicPrompts.page.group.githubPrCommentsReview.title`,descriptionKey:`settings.magicPrompts.page.group.githubPrCommentsReview.description`,blocks:[{id:`github.pr.comments.review.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`github.pr.comments.review.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"github.pr.comment.single":{titleKey:`settings.magicPrompts.page.group.githubSinglePrCommentReview.title`,descriptionKey:`settings.magicPrompts.page.group.githubSinglePrCommentReview.description`,blocks:[{id:`github.pr.comment.single.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`github.pr.comment.single.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"git.conflict.resolve":{titleKey:`settings.magicPrompts.page.group.gitConflictResolve.title`,descriptionKey:`settings.magicPrompts.page.group.gitConflictResolve.description`,blocks:[{id:`git.conflict.resolve.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`git.conflict.resolve.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"git.integrate.cherrypick.resolve":{titleKey:`settings.magicPrompts.page.group.gitCherrypickConflictResolve.title`,descriptionKey:`settings.magicPrompts.page.group.gitCherrypickConflictResolve.description`,blocks:[{id:`git.integrate.cherrypick.resolve.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`git.integrate.cherrypick.resolve.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"session.summary":{titleKey:`settings.magicPrompts.page.group.sessionSummary.title`,descriptionKey:`settings.magicPrompts.page.group.sessionSummary.description`,blocks:[{id:`session.summary.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`session.summary.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"session.review":{titleKey:`settings.magicPrompts.page.group.sessionWorkspaceReview.title`,descriptionKey:`settings.magicPrompts.page.group.sessionWorkspaceReview.description`,blocks:[{id:`session.review.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`session.review.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"session.craftGoal":{titleKey:`settings.magicPrompts.page.group.sessionCraftGoal.title`,descriptionKey:`settings.magicPrompts.page.group.sessionCraftGoal.description`,blocks:[{id:`session.craftGoal.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`session.craftGoal.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"session.catchup":{titleKey:`settings.magicPrompts.page.group.sessionCatchUp.title`,descriptionKey:`settings.magicPrompts.page.group.sessionCatchUp.description`,blocks:[{id:`session.catchup.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`session.catchup.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"session.debug":{titleKey:`settings.magicPrompts.page.group.sessionDebug.title`,descriptionKey:`settings.magicPrompts.page.group.sessionDebug.description`,blocks:[{id:`session.debug.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`session.debug.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"session.weigh":{titleKey:`settings.magicPrompts.page.group.sessionWeigh.title`,descriptionKey:`settings.magicPrompts.page.group.sessionWeigh.description`,blocks:[{id:`session.weigh.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`session.weigh.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"session.explore":{titleKey:`settings.magicPrompts.page.group.sessionExplore.title`,descriptionKey:`settings.magicPrompts.page.group.sessionExplore.description`,blocks:[{id:`session.explore.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`session.explore.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"session.fusion":{titleKey:`settings.magicPrompts.page.group.sessionFusion.title`,descriptionKey:`settings.magicPrompts.page.group.sessionFusion.description`,blocks:[{id:`session.fusion.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`session.fusion.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]}},Zf=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Qf=e=>e.endsWith(`.visible`),$f=()=>{let{t:e}=Ge(),t=Q.useCallback(t=>e(t),[e]),n=Kf(e=>e.selectedPromptId),[r,i]=Q.useState(!0),[a,o]=Q.useState({}),[s,c]=Q.useState({}),[l,u]=Q.useState({}),[d,f]=Q.useState({}),[p,m]=Q.useState(!1);Q.useEffect(()=>{let t=!0;return(async()=>{i(!0);try{let e=await yn();if(!t)return;o(e)}catch(t){console.warn(`Failed to load magic prompts:`,t),Y.error(e(`settings.magicPrompts.page.toast.loadFailed`))}finally{t&&i(!1)}})(),()=>{t=!1}},[e]);let h=Xf[n]??Xf[`git.commit.generate`],g=Q.useCallback(e=>Zf(a,e)?a[e]:Sn(e),[a]),_=Q.useCallback(e=>s[e]??g(e),[s,g]),v=Q.useCallback((e,t)=>{c(n=>n[e]===t?n:{...n,[e]:t})},[]),y=Q.useCallback(async t=>{let n=_(t);if(Qf(t)&&n.trim().length===0){Y.error(e(`settings.magicPrompts.page.toast.visiblePromptRequired`));return}u(e=>({...e,[t]:!0}));try{let r=n===Sn(t)?await bn(t):await xn(t,n);o(r.overrides),Y.success(e(`settings.magicPrompts.page.toast.saved`))}catch(t){let n=t instanceof Error?t.message:String(t);Y.error(e(`settings.magicPrompts.page.toast.saveFailed`),{description:n})}finally{u(e=>({...e,[t]:!1}))}},[_,e]),b=Q.useCallback(async t=>{f(e=>({...e,[t]:!0}));try{let n=await bn(t);o(n.overrides),c(e=>({...e,[t]:Sn(t)})),Y.success(e(`settings.magicPrompts.page.toast.resetSuccess`))}catch(t){let n=t instanceof Error?t.message:String(t);Y.error(e(`settings.magicPrompts.page.toast.resetFailed`),{description:n})}finally{f(e=>({...e,[t]:!1}))}},[e]),x=Q.useCallback(async()=>{m(!0);try{let t=await vn();o(t.overrides),c({}),Y.success(e(`settings.magicPrompts.page.toast.resetAllSuccess`))}catch(t){let n=t instanceof Error?t.message:String(t);Y.error(e(`settings.magicPrompts.page.toast.resetAllFailed`),{description:n})}finally{m(!1)}},[e]);return r?(0,$.jsxs)(`div`,{className:`py-6 px-6 flex items-center gap-2 text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-current animate-busy-pulse`,"aria-label":e(`settings.magicPrompts.page.loading.aria`)}),(0,$.jsx)(`span`,{className:`typography-ui`,children:e(`settings.magicPrompts.page.loading.text`)})]}):(0,$.jsx)(`div`,{className:`h-full overflow-auto`,children:(0,$.jsxs)(`div`,{className:`yuri-settings-page-content mx-auto w-full max-w-4xl px-6 py-6`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,$.jsx)(`div`,{className:`space-y-1`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground`,children:t(h.titleKey)}),(0,$.jsxs)(En,{children:[(0,$.jsx)(wn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(Tn,{sideOffset:8,className:`max-w-xs`,children:t(h.descriptionKey)})]})]})}),(0,$.jsx)(q,{"data-settings-item":`magic-prompts.reset-overrides`,variant:`outline`,size:`sm`,onClick:()=>{x()},disabled:p||Object.keys(a).length===0,children:e(p?`settings.magicPrompts.page.actions.resetting`:`settings.magicPrompts.page.actions.resetAllOverrides`)})]}),h.blocks.map(n=>{let r=_n(n.id),i=g(n.id),o=_(n.id),s=Zf(a,n.id),c=o!==i,u=Qf(n.id)&&o.trim().length===0,f=l[n.id]===!0,p=d[n.id]===!0;return(0,$.jsx)(Z,{actions:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>void b(n.id),disabled:!s||f||p,children:e(p?`settings.magicPrompts.page.actions.resetting`:`settings.magicPrompts.page.actions.resetToDefault`)}),(0,$.jsx)(q,{size:`sm`,onClick:()=>void y(n.id),disabled:!c||f||p||u,"aria-busy":f,children:e(f?`settings.common.actions.saving`:`settings.magicPrompts.page.actions.save`)})]}),label:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`span`,{children:t(n.titleKey)}),(0,$.jsxs)(En,{children:[(0,$.jsx)(wn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(Tn,{sideOffset:8,className:`max-w-xs`,children:r.description})]})]}),cardClassName:`p-3`,children:(0,$.jsxs)(`div`,{"data-settings-item":Qf(n.id)?`magic-prompts.visible-prompt`:`magic-prompts.instructions`,className:`space-y-3`,children:[r.placeholders&&r.placeholders.length>0&&(0,$.jsxs)(`div`,{className:`typography-micro text-muted-foreground`,children:[e(`settings.magicPrompts.page.placeholdersLabel`),` `,r.placeholders.map(e=>`{{${e.key}}}`).join(`, `)]}),(0,$.jsx)(Wr,{embedded:!0,value:o,onChange:e=>v(n.id,e.target.value),className:`min-h-[220px] font-mono text-sm`}),u&&(0,$.jsx)(`div`,{className:`typography-micro text-[var(--status-error)]`,children:e(`settings.magicPrompts.page.validation.visiblePromptRequired`)}),(0,$.jsx)(`div`,{className:`flex items-center justify-between gap-2`,children:(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:e(c?`settings.magicPrompts.page.status.unsavedChanges`:s?`settings.magicPrompts.page.status.usingSavedOverride`:`settings.magicPrompts.page.status.usingBuiltinDefault`)})})]})},n.id)})]})})},ep=()=>{let{t:e}=Ge(),t=Pt(e=>e.settingsGitmojiEnabled),n=Pt(e=>e.setSettingsGitmojiEnabled),r=_e(),i=G(e=>e.gitChangesViewMode),a=G(e=>e.setGitChangesViewMode),[o,s]=Q.useState(!0),c=Q.useMemo(()=>[{id:`flat`,label:e(`settings.yuri.git.option.flatList`)},{id:`tree`,label:e(`settings.yuri.git.option.treeView`)}],[e]);Q.useEffect(()=>{(async()=>{try{let e=null;if(!e){let t=A()?.settings;if(t)try{let n=(await t.load())?.settings;n&&(e={gitmojiEnabled:typeof n.gitmojiEnabled==`boolean`?n.gitmojiEnabled:void 0,gitChangesViewMode:n.gitChangesViewMode===`flat`||n.gitChangesViewMode===`tree`?n.gitChangesViewMode:void 0})}catch{}}if(!e){let t=await l(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});t.ok&&(e=await t.json())}e&&(typeof e.gitmojiEnabled==`boolean`&&n(e.gitmojiEnabled),(e.gitChangesViewMode===`flat`||e.gitChangesViewMode===`tree`)&&a(e.gitChangesViewMode))}catch(e){console.warn(`Failed to load git settings:`,e)}finally{s(!1)}})()},[a,n]);let u=Q.useCallback(async e=>{n(e);try{await ye({gitmojiEnabled:e})}catch(e){console.warn(`Failed to save gitmoji setting:`,e)}},[n]),d=Q.useCallback(e=>{e!==i&&(a(e),ye({gitChangesViewMode:e}))},[i,a]);return o?null:(0,$.jsxs)(Z,{label:e(`settings.yuri.git.title`),children:[(0,$.jsx)(Xi,{itemId:`git.changes-view`,label:e(`settings.yuri.git.changesViewTitle`),controlClassName:`items-end`,children:(0,$.jsx)(`div`,{role:`radiogroup`,"aria-label":e(`settings.yuri.git.changesViewAria`),className:`mt-0.5 space-y-0`,children:c.map(t=>{let n=i===t.id;return(0,$.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-pressed":n,onClick:()=>{d(t.id)},onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),d(t.id))},className:`flex w-full items-center gap-2 py-0 text-left`,children:[(0,$.jsx)(pa,{checked:n,onChange:()=>{d(t.id)},ariaLabel:e(`settings.yuri.git.optionAria`,{option:t.label})}),(0,$.jsx)(`span`,{className:n?`typography-ui-label font-normal text-foreground`:`typography-ui-label font-normal text-foreground/50`,children:t.label})]},t.id)})})}),(0,$.jsx)(Ji,{itemId:`git.gitmoji`,checked:t,onChange:e=>{u(e)},label:e(`settings.yuri.git.enableGitmoji`),ariaLabel:e(`settings.yuri.git.enableGitmojiAria`)}),(0,$.jsx)(Ji,{itemId:`git.gitignored-files`,checked:r,onChange:me,label:e(`settings.yuri.git.showGitignored`),ariaLabel:e(`settings.yuri.git.showGitignoredAria`)})]})},tp=({itemId:e})=>{let{t}=Ge(),{isMobile:n}=wr(),r=A()?.github,i=An(),a=i.data??null,o=i.isLoading&&!i.data,s=i.isFetched,c=gi(e=>e.refreshStatus),u=gi(e=>e.setStatus),d=Q.useCallback(async e=>{await Br(e)},[]),[f,p]=Q.useState(!1),[m,h]=Q.useState(null),[g,_]=Q.useState(null),v=Q.useRef(null),y=Q.useRef(0),b=Q.useCallback(()=>{v.current!=null&&(window.clearTimeout(v.current),v.current=null),_(null)},[]);Q.useEffect(()=>((async()=>{try{s||await c(r)}catch(e){console.warn(`Failed to load GitHub auth status:`,e)}})(),()=>{b()}),[s,c,r,b]);let x=Q.useCallback(async()=>{p(!0);try{let e=r?await r.authStart():await(async()=>{let e=await l(`/api/github/auth/start`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({})}),t=await e.json().catch(()=>null);if(!e.ok||!t||!(`deviceCode`in t))throw Error(t?.error||e.statusText);return t})();h(e),y.current=Date.now(),_(Math.max(1,e.interval)*1e3);let t=e.verificationUriComplete||e.verificationUri;d(t)}catch(e){console.error(`Failed to start GitHub connect:`,e),Y.error(t(`settings.github.page.toast.startConnectFailed`))}finally{p(!1)}},[d,r,t]),S=Q.useCallback(async e=>{if(r)return r.authComplete(e);let t=await l(`/api/github/auth/complete`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({deviceCode:e})}),n=await t.json().catch(()=>null);if(!t.ok||!n)throw Error(n?.error||t.statusText);return n},[r]);Q.useEffect(()=>{if(!m?.deviceCode||!g||v.current!=null)return;let e=!1,n=y.current+m.expiresIn*1e3,i=async()=>{if(Date.now()>=n){Y.error(t(`settings.github.page.toast.authorizationFailed`)),h(null),b();return}try{let n=await S(m.deviceCode);if(e)return;if(n.connected){Y.success(t(`settings.github.page.toast.connected`)),h(null),b(),await c(r,{force:!0});return}if(n.status===`slow_down`){_(e=>e?e+5e3:5e3);return}if(n.status===`expired_token`||n.status===`access_denied`){Y.error(n.error||t(`settings.github.page.toast.authorizationFailed`)),h(null),b();return}}catch(t){if(e)return;console.warn(`GitHub polling failed:`,t)}v.current=window.setTimeout(()=>void i(),g)};return v.current=window.setTimeout(()=>void i(),g),()=>{e=!0,v.current!=null&&(window.clearTimeout(v.current),v.current=null)}},[m,g,S,c,r,b,t]);let C=Q.useCallback(async e=>{p(!0);try{if(r)await r.authSetGhCliDisabled(e);else{let t=await l(`/api/github/auth/gh-cli`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({disabled:e})}),n=await t.json().catch(()=>null);if(!t.ok)throw Error(n?.error||t.statusText)}Y.success(t(e?`settings.github.page.toast.ghCliDisabled`:`settings.github.page.toast.ghCliEnabled`)),await c(r,{force:!0})}catch(e){console.error(`Failed to update gh CLI setting:`,e),Y.error(t(`settings.github.page.toast.ghCliUpdateFailed`))}finally{p(!1)}},[c,r,t]),w=Q.useCallback(async()=>{p(!0);try{if(b(),h(null),r)await r.authDisconnect();else{let e=await l(`/api/github/auth`,{method:`DELETE`,headers:{Accept:`application/json`}});if(!e.ok)throw Error(e.statusText)}Y.success(t(`settings.github.page.toast.disconnected`)),await c(r,{force:!0})}catch(e){console.error(`Failed to disconnect GitHub:`,e),Y.error(t(`settings.github.page.toast.disconnectFailed`))}finally{p(!1)}},[c,r,b,t]),T=Q.useCallback(async e=>{if(e){p(!0);try{let n=r?await r.authActivate(e):await(async()=>{let t=await l(`/api/github/auth/activate`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({accountId:e})}),n=await t.json().catch(()=>null);if(!t.ok||!n)throw Error(n?.error||t.statusText);return n})();u(n),Y.success(t(`settings.github.page.toast.accountSwitched`))}catch(e){console.error(`Failed to switch GitHub account:`,e),Y.error(t(`settings.github.page.toast.accountSwitchFailed`))}finally{p(!1)}}},[r,u,t]);if(o)return null;if(i.isError&&!i.data)return(0,$.jsx)(`div`,{className:`yuri-settings-group-description text-[var(--status-error)]`,children:i.error.message});let E=!!a?.connected,D=a?.user,O=(a?.accounts??[]).filter(e=>!e.current),k=a?.ghCli??null,j=k?.active?t(`settings.github.page.accountSource.cli`):t(`settings.github.page.accountSource.oauth`);return(0,$.jsxs)(`div`,{className:`yuri-settings-section-stack`,children:[(0,$.jsxs)(Z,{itemId:e,label:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{children:t(`settings.github.page.oauth.title`)}),(0,$.jsxs)(En,{children:[(0,$.jsx)(wn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(Tn,{sideOffset:8,className:`max-w-xs`,children:t(`settings.github.page.tooltip.connectAccount`)})]})]}),children:[(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[E?(0,$.jsxs)(`div`,{className:K(`yuri-settings-group-row`,n?`flex flex-col items-stretch gap-3`:`flex items-center justify-between gap-4`),children:[(0,$.jsxs)(`div`,{className:K(`flex min-w-0 items-center gap-3`,n?`w-full`:void 0),children:[D?.avatarUrl?(0,$.jsx)(`img`,{src:D.avatarUrl,alt:D.login?t(`settings.github.page.avatarAlt.withLogin`,{login:D.login}):t(`settings.github.page.avatarAlt.fallback`),className:`h-10 w-10 shrink-0 rounded-full border border-[var(--interactive-border)] bg-[var(--surface-muted)] object-cover`,loading:`lazy`,referrerPolicy:`no-referrer`}):(0,$.jsx)(`div`,{className:`h-10 w-10 shrink-0 rounded-full border border-[var(--interactive-border)] bg-[var(--surface-muted)]`}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:D?.name?.trim()||D?.login||`GitHub`}),(0,$.jsxs)(`div`,{className:K(`flex items-center gap-2 typography-meta text-muted-foreground mt-0.5`,n?`flex-wrap`:`truncate`),children:[(0,$.jsx)(X,{name:`github-fill`,className:`h-3.5 w-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`font-mono`,children:D?.login||t(`settings.github.page.label.unknownUser`)}),D?.email&&(0,$.jsx)(`span`,{className:`opacity-50`,children:`•`}),D?.email&&(0,$.jsx)(`span`,{children:D.email}),(0,$.jsx)(`span`,{className:`opacity-50`,children:`•`}),(0,$.jsx)(`span`,{children:j})]}),a?.scope&&(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/70 mt-0.5`,children:t(`settings.github.page.label.scopes`,{value:a.scope})}),k?.active&&(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/70 mt-0.5`,children:t(`settings.github.page.ghCli.activeDescription`)})]})]}),k?.active?(0,$.jsx)(q,{size:`sm`,variant:`outline`,onClick:()=>C(!0),disabled:f,className:K(n?`w-full`:void 0),children:t(`settings.github.page.ghCli.actions.disable`)}):(0,$.jsx)(q,{size:`sm`,variant:`outline`,onClick:w,disabled:f,className:K(`text-[var(--status-error)] hover:text-[var(--status-error)]`,n?`w-full`:void 0),children:t(`settings.github.page.actions.disconnect`)})]}):(0,$.jsxs)(`div`,{className:K(`yuri-settings-group-row`,n?`flex flex-col items-stretch gap-3`:`flex items-center justify-between gap-4`),children:[(0,$.jsx)(`div`,{className:`flex min-w-0 flex-col`,children:(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:t(`settings.github.page.status.notConnected`)})}),(0,$.jsx)(q,{size:`sm`,variant:`default`,onClick:x,disabled:f,className:K(n?`w-full`:void 0),children:t(`settings.github.page.actions.connect`)})]}),O.length>0&&(0,$.jsxs)(`div`,{className:`yuri-settings-group-row flex flex-col gap-2`,children:[(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground`,children:t(`settings.github.page.label.otherAccounts`)}),O.map(e=>{let n=e.user,r=e.source===`gh-cli`?t(`settings.github.page.accountSource.cli`):t(`settings.github.page.accountSource.oauth`);return(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[n?.avatarUrl?(0,$.jsx)(`img`,{src:n.avatarUrl,alt:n.login?t(`settings.github.page.avatarAlt.withLogin`,{login:n.login}):t(`settings.github.page.avatarAlt.fallback`),className:`h-6 w-6 shrink-0 rounded-full border border-[var(--interactive-border)] bg-[var(--surface-muted)] object-cover`,loading:`lazy`,referrerPolicy:`no-referrer`}):(0,$.jsx)(`div`,{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-full border border-[var(--interactive-border)] bg-[var(--surface-muted)]`,children:(0,$.jsx)(X,{name:`github-fill`,className:`h-3 w-3 text-muted-foreground`})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex flex-col`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:n?.name?.trim()||n?.login||`GitHub`}),n?.login&&(0,$.jsxs)(`span`,{className:`typography-micro text-muted-foreground truncate`,children:[(0,$.jsx)(`span`,{className:`font-mono`,children:n.login}),(0,$.jsx)(`span`,{className:`mx-1 opacity-50`,children:`·`}),(0,$.jsx)(`span`,{children:r})]})]})]}),(0,$.jsx)(q,{size:`sm`,variant:`ghost`,onClick:()=>T(e.id),disabled:f,children:t(`settings.github.page.actions.switchTo`)})]},e.id)})]})]}),E&&(0,$.jsx)(`div`,{className:`yuri-settings-group-row flex justify-end`,children:(0,$.jsx)(q,{size:`sm`,variant:`outline`,onClick:x,disabled:f,className:K(n?`w-full`:void 0),children:t(`settings.github.page.actions.addAccount`)})})]}),m&&(0,$.jsxs)(`div`,{className:`mt-4 rounded-lg bg-[var(--surface-elevated)]/70 p-4 border border-[var(--interactive-border)]`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`h4`,{className:`typography-ui-label text-foreground`,children:t(`settings.github.page.flow.title`)}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.github.page.flow.description`)})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 mt-4`,children:[(0,$.jsx)(`div`,{className:`font-mono text-xl tracking-widest text-foreground bg-[var(--surface-muted)] px-3 py-1.5 rounded-md border border-[var(--interactive-border)]`,children:m.userCode}),(0,$.jsx)(q,{size:`sm`,asChild:!0,children:(0,$.jsx)(`a`,{href:m.verificationUriComplete||m.verificationUri,target:`_blank`,rel:`noopener noreferrer`,children:t(`settings.github.page.actions.openGithub`)})})]}),(0,$.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground animate-pulse`,children:t(`settings.github.page.flow.waiting`)}),(0,$.jsx)(q,{size:`sm`,variant:`ghost`,disabled:f,onClick:()=>{b(),h(null)},children:t(`settings.common.actions.cancel`)})]})]}),k?.available&&!k?.active&&(!k.user||k.disabled)&&(0,$.jsx)(Z,{label:t(`settings.github.page.ghCli.title`),children:(0,$.jsx)(`div`,{className:`yuri-settings-group-row`,children:(0,$.jsxs)(`div`,{className:K(n?`flex flex-col gap-3`:`flex items-center justify-between gap-4`),children:[(0,$.jsxs)(`div`,{className:K(`flex min-w-0 items-center gap-3`,n?`w-full`:void 0),children:[k.user?.avatarUrl?(0,$.jsx)(`img`,{src:k.user.avatarUrl,alt:k.user.login?t(`settings.github.page.avatarAlt.withLogin`,{login:k.user.login}):t(`settings.github.page.avatarAlt.fallback`),className:`h-10 w-10 shrink-0 rounded-full border border-[var(--interactive-border)] bg-[var(--surface-muted)] object-cover`,loading:`lazy`,referrerPolicy:`no-referrer`}):(0,$.jsx)(`div`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-full border border-[var(--interactive-border)] bg-[var(--surface-muted)]`,children:(0,$.jsx)(X,{name:`github-fill`,className:`h-4 w-4 text-muted-foreground`})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[!k.disabled&&k.user&&(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground truncate`,children:k.user.name?.trim()||k.user.login||`GitHub`}),!k.disabled&&k.user?.login&&(0,$.jsxs)(`div`,{className:K(`flex items-center gap-2 typography-meta text-muted-foreground mt-0.5`,n?`flex-wrap`:`truncate`),children:[(0,$.jsx)(X,{name:`github-fill`,className:`h-3.5 w-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`font-mono`,children:k.user.login}),k.user.email&&(0,$.jsx)(`span`,{className:`opacity-50`,children:`•`}),k.user.email&&(0,$.jsx)(`span`,{children:k.user.email})]}),(0,$.jsx)(`div`,{className:K(`typography-meta text-muted-foreground`,k.disabled?`opacity-60`:void 0),children:k.disabled?t(`settings.github.page.ghCli.disabledDescription`):t(`settings.github.page.ghCli.fallbackDescription`)})]})]}),(0,$.jsx)(q,{size:`sm`,variant:`outline`,onClick:()=>C(!k.disabled),disabled:f,className:K(n?`w-full`:void 0),children:k.disabled?t(`settings.github.page.ghCli.actions.enable`):t(`settings.github.page.ghCli.actions.disable`)})]})})})]})},np=[{key:`keyword`,label:`Green`,cssVar:`var(--syntax-keyword)`},{key:`error`,label:`Red`,cssVar:`var(--status-error)`},{key:`string`,label:`Cyan`,cssVar:`var(--syntax-string)`},{key:`function`,label:`Orange`,cssVar:`var(--syntax-function)`},{key:`type`,label:`Yellow`,cssVar:`var(--syntax-type)`}],rp=[{key:`branch`,Icon:`git-branch`,label:`Branch`},{key:`briefcase`,Icon:`briefcase`,label:`Work`},{key:`house`,Icon:`home`,label:`Personal`},{key:`graduation`,Icon:`graduation-cap`,label:`School`},{key:`code`,Icon:`code`,label:`Code`}],ip=({open:e,onOpenChange:t,profileId:n,importData:r})=>{let{t:i}=Ge(),a=ji(e=>e.getProfileById),o=ji(e=>e.createProfile),s=ji(e=>e.updateProfile),c=ji(e=>e.deleteProfile),l=Q.useMemo(()=>n&&n!==`new`&&!r?a(n):null,[n,a,r]),u=n===`new`||r!=null,d=n===`global`,[f,p]=Q.useState(``),[m,h]=Q.useState(``),[g,_]=Q.useState(``),[v,y]=Q.useState(`ssh`),[b,x]=Q.useState(``),[S,C]=Q.useState(!1),[w,T]=Q.useState(``),[E,D]=Q.useState(``),[O,k]=Q.useState(`keyword`),[A,j]=Q.useState(`branch`),[M,N]=Q.useState(!1),[P,F]=Q.useState(!1),[I,L]=Q.useState(!1);Q.useEffect(()=>{if(e){if(r){let e=r.host.split(`/`),t=e.length>=3?e[e.length-1]:r.host;p(t),h(r.username),_(``),y(`token`),x(``),C(!1),T(``),D(r.host),k(`string`),j(`code`)}else if(u)p(``),h(``),_(``),y(`ssh`),x(``),C(!1),T(``),D(``),k(`keyword`),j(`branch`);else if(l)p(l.name),h(l.userName),_(l.userEmail),y(l.authType||`ssh`),x(l.sshKey||``),C(l.signCommits===!0),T(l.signingKey||``),D(l.host||``),k(l.color||`keyword`),j(l.icon||`branch`);else if(d){let e=a(`global`);e&&(p(e.name),h(e.userName),_(e.userEmail),y(e.authType||`ssh`),x(e.sshKey||``),C(!1),T(``),D(e.host||``),k(e.color||`keyword`),j(e.icon||`branch`))}}},[e,n,l,u,r,d,a]);let R=async()=>{if(!m.trim()||!g.trim()){Y.error(i(`settings.gitIdentities.editor.toast.userNameEmailRequired`));return}if(v===`token`&&!E.trim()){Y.error(i(`settings.gitIdentities.editor.toast.hostRequiredForToken`));return}if(S&&!w.trim()){Y.error(i(`settings.gitIdentities.editor.toast.signingKeyRequired`));return}N(!0);try{let e={name:f.trim()||m.trim(),userName:m.trim(),userEmail:g.trim(),authType:v,sshKey:v===`ssh`&&b.trim()||null,signCommits:S,signingKey:w.trim()||null,host:v===`token`&&E.trim()||null,color:O,icon:A},r;if(u)r=await o(e);else if(n)r=await s(n,e);else return;r?(Y.success(i(u?`settings.gitIdentities.editor.toast.profileCreated`:`settings.gitIdentities.editor.toast.profileUpdated`)),t(!1)):Y.error(i(u?`settings.gitIdentities.editor.toast.createProfileFailed`:`settings.gitIdentities.editor.toast.updateProfileFailed`))}catch(e){console.error(`Error saving profile:`,e),Y.error(i(`settings.gitIdentities.editor.toast.saveUnexpectedError`))}finally{N(!1)}},z=async()=>{if(!(!n||u)){L(!0);try{await c(n)?(Y.success(i(`settings.gitIdentities.editor.toast.profileDeleted`)),F(!1),t(!1)):Y.error(i(`settings.gitIdentities.editor.toast.deleteProfileFailed`))}catch(e){console.error(`Error deleting profile:`,e),Y.error(i(`settings.gitIdentities.editor.toast.deleteUnexpectedError`))}finally{L(!1)}}},B=Q.useMemo(()=>np.find(e=>e.key===O)?.cssVar||`var(--syntax-keyword)`,[O]),V=r?i(`settings.gitIdentities.editor.title.importCredential`):u?i(`settings.gitIdentities.editor.title.newIdentity`):d?i(`settings.gitIdentities.editor.title.globalIdentity`):l?.name||i(`settings.gitIdentities.editor.title.editIdentity`);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(gn,{open:e,onOpenChange:t,children:(0,$.jsxs)(pn,{className:`max-w-lg max-h-[85vh] overflow-y-auto`,children:[(0,$.jsx)(Gi,{className:`pr-8`,actions:d?null:(0,$.jsxs)($.Fragment,{children:[u?null:(0,$.jsx)(q,{variant:`ghost`,size:`icon`,onClick:()=>F(!0),disabled:M,"aria-label":i(`settings.common.actions.delete`),title:i(`settings.common.actions.delete`),className:`text-[var(--status-error)]`,children:(0,$.jsx)(X,{name:`delete-bin`,className:`size-4`})}),(0,$.jsx)(q,{size:`sm`,onClick:R,disabled:M,"aria-busy":M,children:i(M?`settings.common.actions.saving`:u?`settings.gitIdentities.editor.actions.create`:`settings.gitIdentities.editor.actions.save`)})]}),children:(0,$.jsxs)(dn,{children:[(0,$.jsx)(mn,{children:V}),(0,$.jsx)(hn,{children:i(d?`settings.gitIdentities.editor.description.globalReadOnly`:u?`settings.gitIdentities.editor.description.newProfile`:`settings.gitIdentities.editor.description.editProfile`)})]})}),(0,$.jsxs)(`div`,{className:`space-y-5 py-2`,children:[!d&&(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`typography-ui-label text-foreground block mb-1.5`,children:i(`settings.gitIdentities.editor.field.profileName`)}),(0,$.jsx)(Cn,{value:f,onChange:e=>p(e.target.value),placeholder:i(`settings.gitIdentities.editor.field.profileNamePlaceholder`),className:`h-8`})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:i(`settings.gitIdentities.editor.field.color`)}),(0,$.jsx)(`div`,{className:`flex gap-1.5`,children:np.map(e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>k(e.key),className:K(`w-6 h-6 rounded-md border-2 transition-all cursor-pointer`,O===e.key?`border-foreground scale-110`:`border-transparent hover:border-border`),style:{backgroundColor:e.cssVar},title:e.label},e.key))})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:i(`settings.gitIdentities.editor.field.icon`)}),(0,$.jsx)(`div`,{className:`flex gap-1.5`,children:rp.map(e=>{let t=e.Icon;return(0,$.jsx)(`button`,{type:`button`,onClick:()=>j(e.key),className:K(`w-7 h-7 rounded-md border-2 transition-all flex items-center justify-center cursor-pointer`,A===e.key?`border-[var(--interactive-border)] bg-[var(--surface-muted)]`:`border-transparent hover:border-[var(--interactive-border)] hover:bg-[var(--surface-muted)]/50`),title:e.label,children:(0,$.jsx)(X,{name:t,className:`w-3.5 h-3.5`,style:{color:A===e.key?B:`var(--surface-muted-foreground)`}})},e.key)})})]})]}),!d&&(0,$.jsx)(`div`,{className:`border-t border-border/40`}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1.5`,children:[(0,$.jsx)(`label`,{className:`typography-ui-label text-foreground`,children:i(`settings.gitIdentities.editor.field.userName`)}),!d&&(0,$.jsx)(`span`,{className:`text-[var(--status-error)] text-xs`,children:`*`}),(0,$.jsxs)(En,{children:[(0,$.jsx)(wn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(Tn,{sideOffset:8,className:`max-w-xs`,children:i(`settings.gitIdentities.editor.field.userNameTooltip`)})]})]}),(0,$.jsx)(Cn,{value:m,onChange:e=>h(e.target.value),placeholder:i(`settings.gitIdentities.editor.field.userNamePlaceholder`),required:!d,readOnly:d,disabled:d,className:`h-8`})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1.5`,children:[(0,$.jsx)(`label`,{className:`typography-ui-label text-foreground`,children:i(`settings.gitIdentities.editor.field.emailAddress`)}),!d&&(0,$.jsx)(`span`,{className:`text-[var(--status-error)] text-xs`,children:`*`}),(0,$.jsxs)(En,{children:[(0,$.jsx)(wn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(Tn,{sideOffset:8,className:`max-w-xs`,children:i(`settings.gitIdentities.editor.field.emailAddressTooltip`)})]})]}),(0,$.jsx)(Cn,{type:`email`,value:g,onChange:e=>_(e.target.value),placeholder:i(`settings.gitIdentities.editor.field.emailAddressPlaceholder`),required:!d,readOnly:d,disabled:d,className:`h-8`})]})]}),!d&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`border-t border-border/40`}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:i(`settings.gitIdentities.editor.field.authMethod`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsxs)(q,{size:`sm`,type:`button`,variant:`chip`,"aria-pressed":v===`ssh`,onClick:()=>y(`ssh`),children:[(0,$.jsx)(X,{name:`lock-2`,className:`w-3.5 h-3.5 mr-1`}),` SSH`]}),(0,$.jsxs)(q,{size:`sm`,type:`button`,variant:`chip`,"aria-pressed":v===`token`,onClick:()=>y(`token`),children:[(0,$.jsx)(X,{name:`key`,className:`w-3.5 h-3.5 mr-1`}),` `,i(`settings.gitIdentities.editor.field.authToken`)]})]})]}),v===`ssh`&&(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1.5`,children:[(0,$.jsx)(`label`,{className:`typography-ui-label text-foreground`,children:i(`settings.gitIdentities.editor.field.sshKeyPath`)}),(0,$.jsxs)(En,{children:[(0,$.jsx)(wn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(Tn,{sideOffset:8,className:`max-w-xs`,children:i(`settings.gitIdentities.editor.field.sshKeyPathTooltip`)})]})]}),(0,$.jsx)(Cn,{value:b,onChange:e=>x(e.target.value),placeholder:i(`settings.gitIdentities.editor.field.sshKeyPathPlaceholder`),className:`h-8 font-mono text-xs`})]}),(0,$.jsxs)(`div`,{className:`border-t border-border/40 pt-3 space-y-3`,children:[(0,$.jsx)(Ji,{checked:S,onChange:C,label:i(`settings.gitIdentities.editor.field.signCommits`),description:i(`settings.gitIdentities.editor.section.commitSigning`),ariaLabel:i(`settings.gitIdentities.editor.field.signCommits`)}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`flex items-center gap-1.5 mb-1.5`,children:(0,$.jsx)(`label`,{className:`typography-ui-label text-foreground`,children:i(`settings.gitIdentities.editor.field.signingKey`)})}),(0,$.jsx)(Cn,{value:w,onChange:e=>T(e.target.value),placeholder:i(`settings.gitIdentities.editor.field.signingKeyPlaceholder`),disabled:!S,className:`h-8 font-mono text-xs`})]})]}),v===`token`&&(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1.5`,children:[(0,$.jsx)(`label`,{className:`typography-ui-label text-foreground`,children:i(`settings.gitIdentities.editor.field.host`)}),(0,$.jsx)(`span`,{className:`text-[var(--status-error)] text-xs`,children:`*`}),(0,$.jsxs)(En,{children:[(0,$.jsx)(wn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(Tn,{sideOffset:8,className:`max-w-xs`,children:i(`settings.gitIdentities.editor.field.hostTooltip`)})]})]}),(0,$.jsx)(Cn,{value:E,onChange:e=>D(e.target.value),placeholder:i(`settings.gitIdentities.editor.field.hostPlaceholder`),required:!0,className:`h-8 font-mono text-xs`})]})]})]})]}),(0,$.jsx)(fn,{className:`gap-2`,children:(0,$.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>t(!1),className:`text-foreground hover:bg-interactive-hover hover:text-foreground`,children:i(d?`settings.gitIdentities.editor.actions.close`:`settings.common.actions.cancel`)})})]})}),(0,$.jsx)(gn,{open:P,onOpenChange:e=>{I||F(e)},children:(0,$.jsxs)(pn,{className:`max-w-md`,children:[(0,$.jsxs)(dn,{children:[(0,$.jsx)(mn,{children:i(`settings.gitIdentities.page.deleteDialog.title`)}),(0,$.jsx)(hn,{children:i(`settings.gitIdentities.page.deleteDialog.description`,{name:l?.name||f})})]}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(q,{variant:`ghost`,onClick:()=>F(!1),disabled:I,children:i(`settings.common.actions.cancel`)}),(0,$.jsx)(q,{size:`sm`,variant:`destructive`,onClick:()=>void z(),disabled:I,children:i(`settings.common.actions.delete`)})]})]})})]})},ap={branch:`git-branch`,briefcase:`briefcase`,house:`home`,graduation:`graduation-cap`,code:`code`,heart:`heart`},op={keyword:`var(--syntax-keyword)`,error:`var(--status-error)`,string:`var(--syntax-string)`,function:`var(--syntax-function)`,type:`var(--syntax-type)`},sp=()=>{let e=(0,Sa.c)(116),{t}=Ge(),{profiles:n,globalIdentity:r,defaultGitIdentityId:i,deleteProfile:a,loadProfiles:o,loadGlobalIdentity:s,loadDiscoveredCredentials:c,loadDefaultGitIdentityId:l,setDefaultGitIdentityId:u,getUnimportedCredentials:d}=ji(ne(up)),[f,p]=Q.useState(!1),[m,h]=Q.useState(null),[g,_]=Q.useState(null),[v,y]=Q.useState(null),[b,x]=Q.useState(!1),S,C;e[0]!==l||e[1]!==c||e[2]!==s||e[3]!==o?(S=()=>{o(),s(),c(),l()},C=[o,s,c,l],e[0]=l,e[1]=c,e[2]=s,e[3]=o,e[4]=S,e[5]=C):(S=e[4],C=e[5]),Q.useEffect(S,C);let w,T,E,D,O,k,A,j,M,N,P,F,I,L;if(e[6]!==i||e[7]!==v||e[8]!==a||e[9]!==d||e[10]!==r||e[11]!==n||e[12]!==u||e[13]!==t){let o=d(),s;e[28]===Symbol.for(`react.memo_cache_sentinel`)?(s=(e,t)=>{h(e),_(t??null),p(!0)},e[28]=s):s=e[28];let c=s,l;e[29]!==i||e[30]!==u||e[31]!==t?(l=async e=>{let n=i===e?null:e;if(!await u(n)){Y.error(t(`settings.gitIdentities.page.toast.updateDefaultFailed`));return}Y.success(t(n?`settings.gitIdentities.page.toast.defaultUpdated`:`settings.gitIdentities.page.toast.defaultUnset`))},e[29]=i,e[30]=u,e[31]=t,e[32]=l):l=e[32];let f=l,m;e[33]!==v||e[34]!==a||e[35]!==t?(m=async()=>{v&&(x(!0),await a(v.id)?(Y.success(t(`settings.gitIdentities.page.toast.profileDeleted`,{name:v.name})),y(null)):Y.error(t(`settings.gitIdentities.page.toast.deleteProfileFailed`)),x(!1))},e[33]=v,e[34]=a,e[35]=t,e[36]=m):m=e[36],E=m,T=Ur,O=`h-full`,k=`w-full bg-background`,L=`yuri-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,e[37]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,$.jsx)(tp,{itemId:`git.github-account`}),e[37]=D):D=e[37],w=Z,A=`git.identities`;let g;e[38]===t?g=e[39]:(g=t(`settings.gitIdentities.page.section.title`),e[38]=t,e[39]=g);let b;e[40]===g?b=e[41]:(b=(0,$.jsx)(`span`,{children:g}),e[40]=g,e[41]=b);let S,C;e[42]===Symbol.for(`react.memo_cache_sentinel`)?(S=()=>c(`new`),C=(0,$.jsx)(X,{name:`add`,className:`mr-1 size-3.5`}),e[42]=S,e[43]=C):(S=e[42],C=e[43]);let R;e[44]===t?R=e[45]:(R=t(`settings.common.badge.new`),e[44]=t,e[45]=R);let z;e[46]===R?z=e[47]:(z=(0,$.jsxs)(q,{size:`sm`,variant:`ghost`,onClick:S,children:[C,` `,R]}),e[46]=R,e[47]=z),e[48]!==b||e[49]!==z?(j=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[b,z]}),e[48]=b,e[49]=z,e[50]=j):j=e[50],M=`flex flex-col`,N=r&&(0,$.jsx)(cp,{profile:r,isDefault:i===`global`,onEdit:()=>c(`global`),onToggleDefault:()=>f(`global`),isReadOnly:!0,hasBorder:n.length>0||o.length>0}),P=n.map((e,t)=>(0,$.jsx)(cp,{profile:e,isDefault:i===e.id,onEdit:()=>c(e.id),onToggleDefault:()=>f(e.id),onDelete:()=>y(e),hasBorder:t<n.length-1||o.length>0},e.id)),F=!r&&n.length===0&&o.length===0&&(0,$.jsxs)(`div`,{className:`py-8 px-4 text-center text-muted-foreground`,children:[(0,$.jsx)(X,{name:`shield-keyhole`,className:`mx-auto mb-2 h-8 w-8 opacity-40`}),(0,$.jsx)(`p`,{className:`typography-ui-label`,children:t(`settings.gitIdentities.page.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:t(`settings.gitIdentities.page.empty.description`)})]}),I=o.length>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`px-4 py-2 border-t border-[var(--surface-subtle)]`,children:(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:t(`settings.gitIdentities.page.discoveredCredentials.title`)})}),o.map((e,t)=>(0,$.jsx)(lp,{credential:e,onImport:()=>c(`new`,{host:e.host,username:e.username}),hasBorder:t<o.length-1},`${e.host}-${e.username}`))]}),e[6]=i,e[7]=v,e[8]=a,e[9]=d,e[10]=r,e[11]=n,e[12]=u,e[13]=t,e[14]=w,e[15]=T,e[16]=E,e[17]=D,e[18]=O,e[19]=k,e[20]=A,e[21]=j,e[22]=M,e[23]=N,e[24]=P,e[25]=F,e[26]=I,e[27]=L}else w=e[14],T=e[15],E=e[16],D=e[17],O=e[18],k=e[19],A=e[20],j=e[21],M=e[22],N=e[23],P=e[24],F=e[25],I=e[26],L=e[27];let R;e[51]!==w||e[52]!==A||e[53]!==j||e[54]!==M||e[55]!==N||e[56]!==P||e[57]!==F||e[58]!==I?(R=(0,$.jsxs)(w,{itemId:A,label:j,cardClassName:M,children:[N,P,F,I]}),e[51]=w,e[52]=A,e[53]=j,e[54]=M,e[55]=N,e[56]=P,e[57]=F,e[58]=I,e[59]=R):R=e[59];let z;e[60]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(ep,{}),e[60]=z):z=e[60];let B;e[61]!==D||e[62]!==R||e[63]!==L?(B=(0,$.jsxs)(`div`,{className:L,children:[D,R,z]}),e[61]=D,e[62]=R,e[63]=L,e[64]=B):B=e[64];let V;e[65]!==T||e[66]!==O||e[67]!==k||e[68]!==B?(V=(0,$.jsx)(T,{outerClassName:O,className:k,children:B}),e[65]=T,e[66]=O,e[67]=k,e[68]=B,e[69]=V):V=e[69];let H;e[70]!==g||e[71]!==f||e[72]!==m?(H=(0,$.jsx)(ip,{open:f,onOpenChange:p,profileId:m,importData:g}),e[70]=g,e[71]=f,e[72]=m,e[73]=H):H=e[73];let U=v!==null,W;e[74]===b?W=e[75]:(W=e=>{b||e||y(null)},e[74]=b,e[75]=W);let ee;e[76]===t?ee=e[77]:(ee=t(`settings.gitIdentities.page.deleteDialog.title`),e[76]=t,e[77]=ee);let te;e[78]===ee?te=e[79]:(te=(0,$.jsx)(mn,{children:ee}),e[78]=ee,e[79]=te);let re=v?.name??``,ie;e[80]!==t||e[81]!==re?(ie=t(`settings.gitIdentities.page.deleteDialog.description`,{name:re}),e[80]=t,e[81]=re,e[82]=ie):ie=e[82];let ae;e[83]===ie?ae=e[84]:(ae=(0,$.jsx)(hn,{children:ie}),e[83]=ie,e[84]=ae);let oe;e[85]!==te||e[86]!==ae?(oe=(0,$.jsxs)(dn,{children:[te,ae]}),e[85]=te,e[86]=ae,e[87]=oe):oe=e[87];let se;e[88]===Symbol.for(`react.memo_cache_sentinel`)?(se=()=>y(null),e[88]=se):se=e[88];let ce;e[89]===t?ce=e[90]:(ce=t(`settings.common.actions.cancel`),e[89]=t,e[90]=ce);let le;e[91]!==b||e[92]!==ce?(le=(0,$.jsx)(q,{variant:`ghost`,onClick:se,disabled:b,children:ce}),e[91]=b,e[92]=ce,e[93]=le):le=e[93];let ue;e[94]===E?ue=e[95]:(ue=()=>void E(),e[94]=E,e[95]=ue);let de;e[96]===t?de=e[97]:(de=t(`settings.common.actions.delete`),e[96]=t,e[97]=de);let G;e[98]!==b||e[99]!==ue||e[100]!==de?(G=(0,$.jsx)(q,{size:`sm`,variant:`destructive`,onClick:ue,disabled:b,children:de}),e[98]=b,e[99]=ue,e[100]=de,e[101]=G):G=e[101];let fe;e[102]!==le||e[103]!==G?(fe=(0,$.jsxs)(fn,{children:[le,G]}),e[102]=le,e[103]=G,e[104]=fe):fe=e[104];let pe;e[105]!==oe||e[106]!==fe?(pe=(0,$.jsxs)(pn,{className:`max-w-md`,children:[oe,fe]}),e[105]=oe,e[106]=fe,e[107]=pe):pe=e[107];let me;e[108]!==U||e[109]!==W||e[110]!==pe?(me=(0,$.jsx)(gn,{open:U,onOpenChange:W,children:pe}),e[108]=U,e[109]=W,e[110]=pe,e[111]=me):me=e[111];let he;return e[112]!==V||e[113]!==H||e[114]!==me?(he=(0,$.jsxs)($.Fragment,{children:[V,H,me]}),e[112]=V,e[113]=H,e[114]=me,e[115]=he):he=e[115],he},cp=e=>{let t=(0,Sa.c)(56),{profile:n,isDefault:r,onEdit:i,onToggleDefault:a,onDelete:o,isReadOnly:s,hasBorder:c}=e,{t:l}=Ge(),[u,d]=Q.useState(!1),f=ap[n.icon||`branch`]||`git-branch`,p=op[n.color||``],m=n.authType||`ssh`,h;t[0]===i?h=t[1]:(h=e=>{e.currentTarget===e.target&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),i())},t[0]=i,t[1]=h);let g=h,_;t[2]!==r||t[3]!==s||t[4]!==o||t[5]!==a||t[6]!==l?(_=e=>(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(e,{onClick:e=>{e.stopPropagation(),a()},children:l(r?`settings.gitIdentities.page.actions.unsetDefault`:`settings.gitIdentities.page.actions.setAsDefault`)}),!s&&o&&(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),o()},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(X,{name:`delete-bin`,className:`h-4 w-4 mr-px`}),l(`settings.common.actions.delete`)]})]}),t[2]=r,t[3]=s,t[4]=o,t[5]=a,t[6]=l,t[7]=_):_=t[7];let v=_,y=c&&`border-b border-[var(--surface-subtle)]`,b;t[8]===y?b=t[9]:(b=K(`group flex items-center justify-between gap-3 px-4 py-2.5 transition-colors hover:bg-[var(--interactive-hover)]/30 cursor-pointer`,y),t[8]=y,t[9]=b);let x;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(x=e=>{e.preventDefault(),d(!0)},t[10]=x):x=t[10];let S;t[11]!==g||t[12]!==i||t[13]!==b?(S=(0,$.jsx)(`div`,{className:b,onClick:i,role:`button`,tabIndex:0,onKeyDown:g,onContextMenu:x}),t[11]=g,t[12]=i,t[13]=b,t[14]=S):S=t[14];let C;t[15]===p?C=t[16]:(C={color:p},t[15]=p,t[16]=C);let w;t[17]!==f||t[18]!==C?(w=(0,$.jsx)(X,{name:f,className:`w-4 h-4 shrink-0`,style:C}),t[17]=f,t[18]=C,t[19]=w):w=t[19];let T;t[20]===n.name?T=t[21]:(T=(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:n.name}),t[20]=n.name,t[21]=T);let E;t[22]===m?E=t[23]:(E=(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-muted px-1 rounded flex-shrink-0 leading-none pb-px border border-border/50`,children:m}),t[22]=m,t[23]=E);let D;t[24]!==r||t[25]!==l?(D=r&&(0,$.jsx)(`span`,{className:`typography-micro text-primary bg-primary/12 px-1 rounded flex-shrink-0 leading-none pb-px border border-primary/25`,children:l(`settings.gitIdentities.page.badge.default`)}),t[24]=r,t[25]=l,t[26]=D):D=t[26];let O;t[27]!==s||t[28]!==l?(O=s&&(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-muted px-1 rounded flex-shrink-0 leading-none pb-px border border-border/50`,children:l(`settings.agents.sidebar.badge.system`)}),t[27]=s,t[28]=l,t[29]=O):O=t[29];let k;t[30]!==E||t[31]!==D||t[32]!==O||t[33]!==T?(k=(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[T,E,D,O]}),t[30]=E,t[31]=D,t[32]=O,t[33]=T,t[34]=k):k=t[34];let A=m===`token`&&n.host?n.host:n.userEmail,j;t[35]===A?j=t[36]:(j=(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/60 truncate leading-tight`,children:A}),t[35]=A,t[36]=j);let M;t[37]!==k||t[38]!==j?(M=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[k,j]}),t[37]=k,t[38]=j,t[39]=M):M=t[39];let N;t[40]!==M||t[41]!==w?(N=(0,$.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[w,M]}),t[40]=M,t[41]=w,t[42]=N):N=t[42];let P;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,$.jsx)(fr,{asChild:!0,children:(0,$.jsx)(q,{size:`icon`,variant:`ghost`,className:`h-6 w-6 shrink-0 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100`,onClick:dp,children:(0,$.jsx)(X,{name:`more-2`,className:`h-3.5 w-3.5`})})}),t[43]=P):P=t[43];let F;t[44]===v?F=t[45]:(F=(0,$.jsxs)($n,{children:[P,(0,$.jsx)(Zn,{align:`end`,className:`w-fit min-w-28`,children:v(tr)})]}),t[44]=v,t[45]=F);let I;t[46]!==N||t[47]!==F||t[48]!==S?(I=(0,$.jsxs)(na,{render:S,children:[N,F]}),t[46]=N,t[47]=F,t[48]=S,t[49]=I):I=t[49];let L;t[50]===v?L=t[51]:(L=(0,$.jsx)(ra,{className:`w-fit min-w-28`,children:v(ia)}),t[50]=v,t[51]=L);let R;return t[52]!==u||t[53]!==I||t[54]!==L?(R=(0,$.jsxs)(aa,{open:u,onOpenChange:d,children:[I,L]}),t[52]=u,t[53]=I,t[54]=L,t[55]=R):R=t[55],R},lp=e=>{let t=(0,Sa.c)(21),{credential:n,onImport:r,hasBorder:i}=e,{t:a}=Ge(),o;t[0]===n.host?o=t[1]:(o=n.host.split(`/`),t[0]=n.host,t[1]=o);let s=o,c=s.length>=3?s[s.length-1]:n.host,l=n.host.includes(`/`),u=i&&`border-b border-[var(--surface-subtle)]`,d;t[2]===u?d=t[3]:(d=K(`flex items-center justify-between gap-3 px-4 py-2.5 transition-colors hover:bg-[var(--interactive-hover)]/30`,u),t[2]=u,t[3]=d);let f;t[4]===c?f=t[5]:(f=(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground truncate block`,children:c}),t[4]=c,t[5]=f);let p=l?n.host:n.username,m;t[6]===p?m=t[7]:(m=(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/60 truncate block leading-tight`,children:p}),t[6]=p,t[7]=m);let h;t[8]!==f||t[9]!==m?(h=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[f,m]}),t[8]=f,t[9]=m,t[10]=h):h=t[10];let g;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(X,{name:`download`,className:`h-3 w-3`}),t[11]=g):g=t[11];let _;t[12]===a?_=t[13]:(_=a(`settings.gitIdentities.page.actions.import`),t[12]=a,t[13]=_);let v;t[14]!==r||t[15]!==_?(v=(0,$.jsxs)(q,{size:`sm`,variant:`ghost`,onClick:r,className:`gap-1 shrink-0`,children:[g,_]}),t[14]=r,t[15]=_,t[16]=v):v=t[16];let y;return t[17]!==v||t[18]!==d||t[19]!==h?(y=(0,$.jsxs)(`div`,{className:d,children:[h,v]}),t[17]=v,t[18]=d,t[19]=h,t[20]=y):y=t[20],y};function up(e){return{profiles:e.profiles,globalIdentity:e.globalIdentity,defaultGitIdentityId:e.defaultGitIdentityId,deleteProfile:e.deleteProfile,loadProfiles:e.loadProfiles,loadGlobalIdentity:e.loadGlobalIdentity,loadDiscoveredCredentials:e.loadDiscoveredCredentials,loadDefaultGitIdentityId:e.loadDefaultGitIdentityId,setDefaultGitIdentityId:e.setDefaultGitIdentityId,getUnimportedCredentials:e.getUnimportedCredentials}}function dp(e){return e.stopPropagation()}function fp(){let e=(0,Sa.c)(32),{t}=Ge(),{settings:n}=ke(),r=Gt(),i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=o(),e[0]=i):i=e[0];let a=i,s;e[1]===n?s=e[2]:(s={mutationFn:async e=>{let t=o();if(await n.save({questionAutoDelegateEnabled:e}),t!==o())throw Error(`Runtime changed`);await zt()}},e[1]=n,e[2]=s);let c=Te(s,Oe),l=c.reset,u,d;e[3]===l?(u=e[4],d=e[5]):(u=()=>{l()},d=[a,l],e[3]=l,e[4]=u,e[5]=d),(0,Q.useEffect)(u,d);let f;e[6]===t?f=e[7]:(f=t(`settings.chat.questionDelegate.label`),e[6]=t,e[7]=f);let p;e[8]===t?p=e[9]:(p=t(`settings.chat.questionDelegate.label`),e[8]=t,e[9]=p);let m;e[10]===t?m=e[11]:(m=t(`settings.chat.questionDelegate.description`),e[10]=t,e[11]=m);let h=r.data?.snapshot.enabled??!0,g=c.isPending||!r.data||r.isError,_;e[12]===c?_=e[13]:(_=e=>c.mutate(e),e[12]=c,e[13]=_);let v;e[14]!==f||e[15]!==p||e[16]!==m||e[17]!==h||e[18]!==g||e[19]!==_?(v=(0,$.jsx)(Ji,{itemId:`chat.question-auto-delegate`,label:f,ariaLabel:p,description:m,checked:h,disabled:g,onChange:_}),e[14]=f,e[15]=p,e[16]=m,e[17]=h,e[18]=g,e[19]=_,e[20]=v):v=e[20];let y;e[21]!==c.isPending||e[22]!==t?(y=c.isPending?(0,$.jsx)(`div`,{className:`yuri-settings-group-row typography-meta text-muted-foreground`,role:`status`,children:t(`settings.common.actions.saving`)}):null,e[21]=c.isPending,e[22]=t,e[23]=y):y=e[23];let b;e[24]!==r||e[25]!==c||e[26]!==t?(b=r.isError||c.isError?(0,$.jsxs)(`div`,{className:`yuri-settings-group-row flex flex-wrap items-center gap-2`,role:`alert`,children:[(0,$.jsx)(`span`,{className:`typography-meta text-[var(--status-error)]`,children:t(c.isError?`settings.chat.questionDelegate.saveFailed`:`chat.questionDelegate.loadFailed`)}),(0,$.jsx)(q,{variant:`ghost`,size:`xs`,disabled:c.isPending,onClick:()=>c.isError?c.mutate(c.variables??!0):void r.refetch(),children:t(`chat.questionDelegate.retry`)})]}):null,e[24]=r,e[25]=c,e[26]=t,e[27]=b):b=e[27];let x;return e[28]!==v||e[29]!==y||e[30]!==b?(x=(0,$.jsxs)($.Fragment,{children:[v,y,b]}),e[28]=v,e[29]=y,e[30]=b,e[31]=x):x=e[31],x}var pp=e=>{let t=(0,Sa.c)(12),{isMobile:n,itemId:r,label:i,description:a,descriptionPlacement:o,children:s,className:c,copyClassName:l,controlClassName:u}=e,d=n&&`yuri-mobile-settings-detail-group`,f;t[0]===d?f=t[1]:(f=K(`yuri-settings-detail-group`,d),t[0]=d,t[1]=f);let p;return t[2]!==s||t[3]!==c||t[4]!==u||t[5]!==l||t[6]!==a||t[7]!==o||t[8]!==r||t[9]!==i||t[10]!==f?(p=(0,$.jsx)(Ui,{itemId:r,label:i,description:a,descriptionPlacement:o,groupClassName:f,className:c,copyClassName:l,controlClassName:u,children:s}),t[2]=s,t[3]=c,t[4]=u,t[5]=l,t[6]=a,t[7]=o,t[8]=r,t[9]=i,t[10]=f,t[11]=p):p=t[11],p},mp=e=>{let t=(0,Sa.c)(9),{isMobile:n,label:r,children:i,description:a,className:o,cardClassName:s}=e,c=n&&`yuri-mobile-settings-detail-group`,l;t[0]!==o||t[1]!==c?(l=K(`yuri-settings-detail-group`,c,o),t[0]=o,t[1]=c,t[2]=l):l=t[2];let u;return t[3]!==s||t[4]!==i||t[5]!==a||t[6]!==r||t[7]!==l?(u=(0,$.jsx)(Z,{label:r,description:a,className:l,cardClassName:s,children:i}),t[3]=s,t[4]=i,t[5]=a,t[6]=r,t[7]=l,t[8]=u):u=t[8],u},hp=e=>{let t=(0,Sa.c)(8),{isMobile:n,itemId:r,label:i,mobileLabel:a,description:o,children:s,className:c,copyClassName:l,controlClassName:u}=e,d=n&&a!==void 0?a:i,f;return t[0]!==s||t[1]!==c||t[2]!==u||t[3]!==l||t[4]!==o||t[5]!==r||t[6]!==d?(f=(0,$.jsx)(Xi,{itemId:r,label:d,description:o,className:c,copyClassName:l,controlClassName:u,children:s}),t[0]=s,t[1]=c,t[2]=u,t[3]=l,t[4]=o,t[5]=r,t[6]=d,t[7]=f):f=t[7],f},gp=e=>{let t=(0,Sa.c)(17),{selected:n,onSelect:r,label:i,ariaLabel:a}=e,o;t[0]===r?o=t[1]:(o=e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),r())},t[0]=r,t[1]=o);let s;t[2]!==a||t[3]!==r||t[4]!==n?(s=(0,$.jsx)(pa,{checked:n,onChange:r,ariaLabel:a}),t[2]=a,t[3]=r,t[4]=n,t[5]=s):s=t[5];let c=n?`text-foreground`:`text-foreground/50`,l;t[6]===c?l=t[7]:(l=K(`typography-ui-label font-normal`,c),t[6]=c,t[7]=l);let u;t[8]!==i||t[9]!==l?(u=(0,$.jsx)(`span`,{className:l,children:i}),t[8]=i,t[9]=l,t[10]=u):u=t[10];let d;return t[11]!==r||t[12]!==n||t[13]!==o||t[14]!==s||t[15]!==u?(d=(0,$.jsxs)(`div`,{className:`yuri-settings-group-row group flex cursor-pointer items-center gap-2 text-left`,role:`button`,tabIndex:0,"aria-pressed":n,onClick:r,onKeyDown:o,children:[s,u]}),t[11]=r,t[12]=n,t[13]=o,t[14]=s,t[15]=u,t[16]=d):d=t[16],d},_p=[{value:`system`,labelKey:`settings.yuri.visual.option.themeMode.system`},{value:`light`,labelKey:`settings.yuri.visual.option.themeMode.light`},{value:`dark`,labelKey:`settings.yuri.visual.option.themeMode.dark`}],vp=[{id:`dynamic`,labelKey:`settings.yuri.visual.option.diffLayout.auto.label`,descriptionKey:`settings.yuri.visual.option.diffLayout.auto.description`},{id:`inline`,labelKey:`settings.yuri.visual.option.diffLayout.inline.label`,descriptionKey:`settings.yuri.visual.option.diffLayout.inline.description`},{id:`side-by-side`,labelKey:`settings.yuri.visual.option.diffLayout.sideBySide.label`,descriptionKey:`settings.yuri.visual.option.diffLayout.sideBySide.description`}],yp=`Yuri - AI Coding Assistant`,bp=[{id:`system`,labelKey:`settings.yuri.visual.option.pwaOrientation.system.label`,descriptionKey:`settings.yuri.visual.option.pwaOrientation.system.description`},{id:`portrait`,labelKey:`settings.yuri.visual.option.pwaOrientation.portrait.label`,descriptionKey:`settings.yuri.visual.option.pwaOrientation.portrait.description`},{id:`landscape`,labelKey:`settings.yuri.visual.option.pwaOrientation.landscape.label`,descriptionKey:`settings.yuri.visual.option.pwaOrientation.landscape.description`}],xp=[{id:`native`,labelKey:`settings.yuri.visual.option.mobileKeyboardMode.native.label`,descriptionKey:`settings.yuri.visual.option.mobileKeyboardMode.native.description`},{id:`resize-content`,labelKey:`settings.yuri.visual.option.mobileKeyboardMode.resizeContent.label`,descriptionKey:`settings.yuri.visual.option.mobileKeyboardMode.resizeContent.description`}],Sp=[{id:`steer`,labelKey:`settings.yuri.visual.option.followUpBehavior.steer.label`},{id:`queue`,labelKey:`settings.yuri.visual.option.followUpBehavior.queue.label`}],Cp=e=>e===`portrait`||e===`landscape`?e:`system`,wp=[{id:`sorted`,labelKey:`settings.yuri.visual.option.chatRenderMode.sorted.label`,descriptionKey:`settings.yuri.visual.option.chatRenderMode.sorted.description`},{id:`live`,labelKey:`settings.yuri.visual.option.chatRenderMode.live.label`,descriptionKey:`settings.yuri.visual.option.chatRenderMode.live.description`}],Tp=[{id:`auto`,labelKey:`settings.yuri.visual.option.messageTransport.auto.label`,descriptionKey:`settings.yuri.visual.option.messageTransport.auto.description`},{id:`ws`,labelKey:`settings.yuri.visual.option.messageTransport.ws.label`,descriptionKey:`settings.yuri.visual.option.messageTransport.ws.description`},{id:`sse`,labelKey:`settings.yuri.visual.option.messageTransport.sse.label`,descriptionKey:`settings.yuri.visual.option.messageTransport.sse.description`}],Ep=[{id:`auto`,labelKey:`settings.yuri.visual.option.timeFormat.auto.label`,descriptionKey:`settings.yuri.visual.option.timeFormat.auto.description`},{id:`24h`,labelKey:`settings.yuri.visual.option.timeFormat.24h.label`,descriptionKey:`settings.yuri.visual.option.timeFormat.24h.description`},{id:`12h`,labelKey:`settings.yuri.visual.option.timeFormat.12h.label`,descriptionKey:`settings.yuri.visual.option.timeFormat.12h.description`}],Dp=[{id:`auto`,labelKey:`settings.yuri.visual.option.weekStart.auto.label`,descriptionKey:`settings.yuri.visual.option.weekStart.auto.description`},{id:`monday`,labelKey:`settings.yuri.visual.option.weekStart.monday.label`},{id:`sunday`,labelKey:`settings.yuri.visual.option.weekStart.sunday.label`}],Op=({visibleSettings:e,mobile:t})=>{let{locale:n,locales:r,setLocale:i,label:a,t:o}=Ge(),s=Q.useCallback(e=>o(e),[o]),{isMobile:c}=wr(),u=t??c,{browserTab:f}=Ei(),p=G(e=>e.showReasoningTraces),m=G(e=>e.sessionTitleRefreshEnabled),_=G(e=>e.setSessionTitleRefreshEnabled),v=G(e=>e.sessionGoalEnabled),y=G(e=>e.setSessionGoalEnabled),b=G(e=>e.setShowReasoningTraces),x=G(e=>e.collapsibleThinkingBlocks),S=G(e=>e.setCollapsibleThinkingBlocks),C=G(e=>e.collapsibleUserMessages),w=G(e=>e.setCollapsibleUserMessages),T=Ir(e=>e.enabled),E=Ir(e=>e.setEnabled),D=G(e=>e.chatRenderMode),O=G(e=>e.setChatRenderMode),A=G(e=>e.fontSize),j=G(e=>e.setFontSize),M=G(e=>e.codeFontSize),N=G(e=>e.setCodeFontSize),P=G(e=>e.terminalFontSize),F=G(e=>e.setTerminalFontSize),I=G(e=>e.editorFontSize),L=G(e=>e.setEditorFontSize),R=G(e=>e.uiFont),z=G(e=>e.setUiFont),B=G(e=>e.monoFont),V=G(e=>e.setMonoFont),H=G(e=>e.padding),U=G(e=>e.setPadding),W=G(e=>e.inputBarOffset),ee=G(e=>e.setInputBarOffset),te=G(e=>e.mobileKeyboardMode),ne=G(e=>e.setMobileKeyboardMode),re=G(e=>e.diffLayoutPreference),ie=G(e=>e.setDiffLayoutPreference),ae=G(e=>e.showTerminalQuickKeysOnDesktop),oe=G(e=>e.setShowTerminalQuickKeysOnDesktop),se=G(e=>e.fileEditorKeymap),ce=G(e=>e.setFileEditorKeymap),pe=xe(e=>e.followUpBehavior),me=xe(e=>e.setFollowUpBehavior),he=G(e=>e.persistChatDraft),ge=G(e=>e.setPersistChatDraft),_e=G(e=>e.inputSpellcheckEnabled),ve=G(e=>e.setInputSpellcheckEnabled),be=G(e=>e.showSubagentTaskDetails),Se=G(e=>e.setShowSubagentTaskDetails),Ce=G(e=>e.timeFormatPreference),we=G(e=>e.setTimeFormatPreference),Te=G(e=>e.weekStartPreference),Ee=G(e=>e.setWeekStartPreference),De=G(e=>e.showSplitAssistantMessageActions),Oe=G(e=>e.setShowSplitAssistantMessageActions),ke=G(e=>e.showAssistantTps),Ae=G(e=>e.setShowAssistantTps),je=Ci(e=>e.sidebarBrandName),Me=Ci(e=>e.setSidebarBrandName),Ne=G(e=>e.allowPromptingSubagentSessions),Pe=G(e=>e.setAllowPromptingSubagentSessions),Fe=Pt(e=>e.settingsMessageStreamTransport),Ie=Pt(e=>e.setSettingsMessageStreamTransport),Le=Fe,Re=G(e=>e.isSettingsDialogOpen),{themeMode:ze,setThemeMode:Be,availableThemes:Ve,customThemesLoading:He,reloadCustomThemes:Ue,lightThemeId:We,darkThemeId:Ke,setLightThemePreference:qe,setDarkThemePreference:Je}=un(),[Ye,Xe]=Q.useState(!1),[Ze,Qe]=Q.useState(!1),[$e,et]=Q.useState(!1),tt=Q.useMemo(()=>h()&&typeof window<`u`&&window.__YURI_ELECTRON__?.macVibrancySupported===!0,[]),nt=typeof window<`u`&&window.__YURI_ELECTRON__?.macVibrancy===!0,[rt,it]=Q.useState(nt),[at,ot]=Q.useState(null),[st,ct]=Q.useState(!1),lt=async()=>{if(!(at===null||st)){ct(!0);try{let e=await k(`desktop_set_vibrancy`,{enabled:at});if(!e||e.enabled!==at||!e.requiresRestart)throw Error(`Window transparency restart was not accepted`);it(e.enabled),ot(null)}catch{ct(!1),Y.error(o(`settings.yuri.visual.vibrancy.failed`))}}},ut=Q.useMemo(()=>h()&&typeof window<`u`&&window.__YURI_PLATFORM__===`darwin`,[]),dt=G(e=>e.dockBadgeEnabled),ft=G(e=>e.setDockBadgeEnabled),[pt,mt]=Q.useState(0),ht=G(e=>e.reportUsage),gt=G(e=>e.setReportUsage),_t=Q.useCallback(e=>{gt(e),ye({reportUsage:e})},[gt]),vt=Re&&(!e||e.includes(`chatRenderMode`));Q.useEffect(()=>{if(!vt)return;let e=null,t=Date.now(),n=()=>{let r=Date.now();r-t>=420&&(mt(e=>(e+1)%24),t=r),e=requestAnimationFrame(n)};(typeof document>`u`||document.visibilityState===`visible`)&&(e=requestAnimationFrame(n));let r=()=>{document.visibilityState===`visible`&&e===null?e=requestAnimationFrame(n):document.visibilityState!==`visible`&&e!==null&&(cancelAnimationFrame(e),e=null)};return document.addEventListener(`visibilitychange`,r),()=>{document.removeEventListener(`visibilitychange`,r),e!==null&&cancelAnimationFrame(e)}},[vt]);let yt=Q.useCallback(e=>{w(e),ye({collapsibleUserMessages:e})},[w]),bt=Q.useCallback(e=>{Oe(e),ye({showSplitAssistantMessageActions:e})},[Oe]),xt=Q.useCallback(e=>{Ae(e),ye({showAssistantTps:e})},[Ae]),St=Q.useCallback(e=>{ve(e),ye({inputSpellcheckEnabled:e})},[ve]),Ct=Q.useCallback(e=>{O(e),ye({chatRenderMode:e})},[O]),wt=Q.useCallback(e=>{Ie(e),ye({messageStreamTransport:e})},[Ie]),Tt=Q.useCallback(e=>{Se(e),ye({showSubagentTaskDetails:e})},[Se]),Et=Q.useCallback(e=>{we(e),ye({timeFormatPreference:e})},[we]),Dt=Q.useCallback(e=>{Ee(e),ye({weekStartPreference:e})},[Ee]),kt=Q.useMemo(()=>Ve.filter(e=>e.metadata.variant===`light`).sort((e,t)=>e.metadata.name.localeCompare(t.metadata.name)),[Ve]),At=Q.useMemo(()=>Ve.filter(e=>e.metadata.variant===`dark`).sort((e,t)=>e.metadata.name.localeCompare(t.metadata.name)),[Ve]),jt=Q.useMemo(()=>kt.find(e=>e.metadata.id===We)??kt[0],[kt,We]),Mt=Q.useMemo(()=>At.find(e=>e.metadata.id===Ke)??At[0],[At,Ke]),Nt=Q.useCallback((e,t)=>{let n=t===`dark`?` Dark`:` Light`;return e.endsWith(n)?e.slice(0,-n.length):e},[]),J=t=>t===`splitAssistantMessageActions`?!1:!e||e.includes(t),Ft=async()=>{if(!$e){et(!0);try{await Ot(),Qe(!1),Y.success(o(`settings.yuri.visual.transcriptCache.toast.cleared`))}catch{Y.error(o(`settings.yuri.visual.transcriptCache.toast.failed`))}finally{et(!1)}}},It=g(),Lt=Lr()&&J(`iosNativeUi`),Rt=J(`theme`)&&!It,zt=J(`theme`)||J(`timeFormat`)||J(`weekStart`),Bt=It?zt||J(`sidebarBrand`):J(`theme`)||J(`sidebarBrand`)||J(`pwaInstallName`)||J(`pwaOrientation`)||J(`mobileKeyboardMode`)||J(`timeFormat`)||J(`weekStart`)||Lt,Vt=J(`fontSize`)||J(`codeFontSize`)||J(`terminalFontSize`)||J(`editorFontSize`)||J(`spacing`)||J(`inputBarOffset`),Ht=J(`terminalQuickKeys`)&&!u||J(`fileEditorKeymap`),Ut=J(`questionAutoDelegate`)||J(`chatRenderMode`)||J(`messageTransport`)||J(`collapsibleUserMessages`)||J(`splitAssistantMessageActions`)||J(`showAssistantTps`)||J(`subagentReadOnlyBanner`)||J(`diffLayout`)||J(`reasoning`)||J(`followUpBehavior`)||J(`persistDraft`)||J(`showSubagentTaskDetails`)||!u&&J(`inputSpellcheck`),Wt=J(`pwaInstallName`)&&d()&&f&&!h()&&!It,Gt=J(`pwaOrientation`)&&d()&&!h()&&!It,Kt=J(`mobileKeyboardMode`)&&d()&&!h()&&!It&&fe(),[qt,Jt]=Q.useState(``),[Yt,Xt]=Q.useState(`system`),Zt=Q.useMemo(()=>{let e=Ep.find(e=>e.id===Ce);return s(e?.labelKey??`settings.yuri.visual.option.timeFormat.auto.label`)},[Ce,s]),Qt=Q.useMemo(()=>{let e=Dp.find(e=>e.id===Te);return s(e?.labelKey??`settings.yuri.visual.option.weekStart.auto.label`)},[Te,s]),$t=Q.useMemo(()=>{let e=bp.find(e=>e.id===Yt);return e?s(e.labelKey):void 0},[Yt,s]),en=Q.useMemo(()=>{let e=xp.find(e=>e.id===te);return e?s(e.labelKey):void 0},[te,s]),tn=Q.useCallback(async e=>{if(typeof window>`u`)return;let t=window,n=e.trim().replace(/\s+/g,` `).slice(0,64);if(await ye({pwaAppName:n}),typeof t.__YURI_SET_PWA_INSTALL_NAME__==`function`){let e=t.__YURI_SET_PWA_INSTALL_NAME__(n);Jt(e);return}Jt(n||yp),t.__YURI_UPDATE_PWA_MANIFEST__?.()},[]),nn=Q.useCallback(async e=>{if(typeof window>`u`)return;let t=window,n=Cp(e);if(await ye({pwaOrientation:n}),typeof t.__YURI_SET_PWA_ORIENTATION__==`function`){let e=t.__YURI_SET_PWA_ORIENTATION__(n);Xt(e);return}Xt(n),t.__YURI_UPDATE_PWA_MANIFEST__?.()},[]);return Q.useEffect(()=>{if(typeof window>`u`||!Wt&&!Gt&&!Kt)return;let e=!1;return(async()=>{try{let t=await l(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`},cache:`no-store`});if(!t.ok){e||Jt(yp);return}let n=await t.json().catch(()=>({})),r=(typeof n?.pwaAppName==`string`?n.pwaAppName:``).trim().replace(/\s+/g,` `).slice(0,64),i=Cp(n?.pwaOrientation),a=le(n?.mobileKeyboardMode);e||(Wt&&Jt(r||yp),Gt&&Xt(i),Kt&&ne(a))}catch{e||(Wt&&Jt(yp),Gt&&Xt(`system`),Kt&&ne(`native`))}})(),()=>{e=!0}},[ne,Kt,Wt,Gt]),(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`yuri-settings-section-stack`,children:[Bt&&(0,$.jsxs)($.Fragment,{children:[Rt&&(0,$.jsxs)(mp,{isMobile:u,label:(0,$.jsxs)(`div`,{className:`flex w-full min-w-0 items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{children:o(`settings.yuri.visual.section.colorMode`)}),(0,$.jsxs)(`div`,{className:`inline-flex shrink-0 items-center gap-1`,children:[(0,$.jsx)(`button`,{type:`button`,"data-settings-item":`appearance.reload-themes`,disabled:He||Ye,onClick:()=>{let e=Date.now();Xe(!0),Ue().finally(()=>{let t=Date.now()-e;if(t<500){window.setTimeout(()=>{Xe(!1)},500-t);return}Xe(!1)})},className:`inline-flex items-center typography-micro font-normal text-muted-foreground underline decoration-[1px] underline-offset-2 hover:text-foreground disabled:cursor-not-allowed disabled:text-muted-foreground/60`,children:o(Ye?`settings.yuri.visual.actions.reloadingThemes`:`settings.yuri.visual.actions.reloadThemes`)}),(0,$.jsxs)(En,{children:[(0,$.jsx)(wn,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`flex items-center justify-center rounded-md p-0.5 text-muted-foreground/70 hover:text-foreground`,"aria-label":o(`settings.yuri.visual.field.themeImportInfoAria`),children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5`})})}),(0,$.jsx)(Tn,{sideOffset:8,children:o(`settings.yuri.visual.field.themeImportInfoTooltip`)})]})]})]}),children:[(0,$.jsx)(hp,{isMobile:u,itemId:`appearance.color-mode`,label:o(`settings.yuri.visual.field.themeMode`),children:(0,$.jsx)(`div`,{className:`yuri-settings-switch`,style:{gridTemplateColumns:`auto auto auto`},role:`group`,"aria-label":o(`settings.yuri.visual.field.themeMode`),children:_p.map(e=>(0,$.jsxs)(q,{variant:`ghost`,size:`xs`,"aria-pressed":ze===e.value,className:`yuri-settings-switch-option`,onClick:()=>Be(e.value),children:[ze===e.value&&(0,$.jsx)(`span`,{"aria-hidden":!0,className:`yuri-segmented-selected-pill yuri-settings-switch-pill`}),(0,$.jsx)(`span`,{className:`relative`,children:s(e.labelKey)})]},e.value))})}),(0,$.jsx)(hp,{isMobile:u,itemId:`appearance.light-theme`,label:o(`settings.yuri.visual.field.lightTheme`),children:(0,$.jsxs)(Fr,{value:jt?.metadata.id??``,onValueChange:qe,children:[(0,$.jsx)(Pr,{"aria-label":o(`settings.yuri.visual.field.selectLightThemeAria`),className:`w-fit`,children:(0,$.jsx)(Ar,{placeholder:o(`settings.yuri.visual.field.selectThemePlaceholder`),children:jt?Nt(jt.metadata.name,`light`):void 0})}),(0,$.jsx)(Nr,{children:kt.map(e=>(0,$.jsx)(jr,{value:e.metadata.id,children:Nt(e.metadata.name,`light`)},e.metadata.id))})]})}),(0,$.jsx)(hp,{isMobile:u,itemId:`appearance.dark-theme`,label:o(`settings.yuri.visual.field.darkTheme`),children:(0,$.jsxs)(Fr,{value:Mt?.metadata.id??``,onValueChange:Je,children:[(0,$.jsx)(Pr,{"aria-label":o(`settings.yuri.visual.field.selectDarkThemeAria`),className:`w-fit`,children:(0,$.jsx)(Ar,{placeholder:o(`settings.yuri.visual.field.selectThemePlaceholder`),children:Mt?Nt(Mt.metadata.name,`dark`):void 0})}),(0,$.jsx)(Nr,{children:At.map(e=>(0,$.jsx)(jr,{value:e.metadata.id,children:Nt(e.metadata.name,`dark`)},e.metadata.id))})]})}),tt&&(0,$.jsx)(Ji,{itemId:`appearance.window-transparency`,checked:rt,onChange:ot,disabled:st,label:o(`settings.yuri.visual.field.macVibrancy`),description:o(`settings.yuri.visual.field.macVibrancyHint`),ariaLabel:o(`settings.yuri.visual.field.macVibrancy`)}),ut&&(0,$.jsx)(Ji,{itemId:`appearance.dock-badge`,checked:dt,onChange:ft,label:o(`settings.yuri.visual.field.dockBadge`),description:o(`settings.yuri.visual.field.dockBadgeHint`),ariaLabel:o(`settings.yuri.visual.field.dockBadge`)})]}),Lt&&(0,$.jsx)(mp,{isMobile:u,children:(0,$.jsx)(Ji,{itemId:`appearance.ios-native-ui`,checked:T,onChange:E,label:o(`settings.yuri.visual.field.iosNativeUi`),description:o(`settings.yuri.visual.field.iosNativeUiHint`),ariaLabel:o(`settings.yuri.visual.field.iosNativeUi`)})}),zt&&(0,$.jsxs)(mp,{isMobile:u,label:o(`settings.yuri.visual.section.localization`),children:[(0,$.jsx)(hp,{isMobile:u,itemId:`appearance.language`,label:o(`settings.appearance.language.label`),description:o(`settings.appearance.language.description`),children:(0,$.jsxs)(Fr,{value:n,onValueChange:e=>i(e),children:[(0,$.jsx)(Pr,{"aria-label":o(`settings.appearance.language.select`),className:`w-fit`,children:(0,$.jsx)(Ar,{children:a(n)})}),(0,$.jsx)(Nr,{children:r.map(e=>(0,$.jsx)(jr,{value:e,children:a(e)},e))})]})}),(J(`timeFormat`)||J(`weekStart`))&&(0,$.jsxs)($.Fragment,{children:[J(`timeFormat`)&&(0,$.jsx)(hp,{isMobile:u,itemId:`appearance.time-format`,label:o(`settings.yuri.visual.field.timeFormat`),children:(0,$.jsxs)(Fr,{value:Ce,onValueChange:e=>Et(e),children:[(0,$.jsx)(Pr,{"aria-label":o(`settings.yuri.visual.field.selectTimeFormatAria`),className:`w-fit`,children:(0,$.jsx)(Ar,{children:Zt})}),(0,$.jsx)(Nr,{children:Ep.map(e=>(0,$.jsx)(jr,{value:e.id,children:s(e.labelKey)},e.id))})]})}),J(`weekStart`)&&(0,$.jsx)(hp,{isMobile:u,itemId:`appearance.week-start`,label:o(`settings.yuri.visual.field.weekStartsOn`),children:(0,$.jsxs)(Fr,{value:Te,onValueChange:e=>Dt(e),children:[(0,$.jsx)(Pr,{"aria-label":o(`settings.yuri.visual.field.selectWeekStartAria`),className:`w-fit`,children:(0,$.jsx)(Ar,{children:Qt})}),(0,$.jsx)(Nr,{children:Dp.map(e=>(0,$.jsx)(jr,{value:e.id,children:s(e.labelKey)},e.id))})]})})]})]}),J(`sidebarBrand`)&&(0,$.jsx)(pp,{isMobile:u,itemId:`appearance.sidebar-brand`,label:o(`settings.yuri.visual.field.sidebarBrand`),description:o(`settings.yuri.visual.field.sidebarBrandHint`),descriptionPlacement:`outside`,children:(0,$.jsx)(Cn,{value:je,onChange:e=>Me(e.target.value),maxLength:64,"aria-label":o(`settings.yuri.visual.field.sidebarBrandAria`)})}),(Wt||Gt||Kt)&&(0,$.jsxs)($.Fragment,{children:[Wt&&(0,$.jsxs)(pp,{isMobile:u,itemId:`appearance.pwa-install-name`,label:o(`settings.yuri.visual.field.installAppName`),description:o(`settings.yuri.visual.field.installAppNameHint`),children:[(0,$.jsx)(Cn,{value:qt,onChange:e=>{Jt(e.target.value)},onBlur:()=>{tn(qt)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),tn(qt))},maxLength:64,"aria-label":o(`settings.yuri.visual.field.pwaInstallAppNameAria`)}),(0,$.jsx)(q,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>{Jt(yp),tn(``)},className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":o(`settings.yuri.visual.actions.resetInstallAppNameAria`),title:o(`settings.common.actions.reset`),children:(0,$.jsx)(X,{name:`restart`,className:`h-3.5 w-3.5`})})]}),Gt&&(0,$.jsxs)(pp,{isMobile:u,itemId:`appearance.pwa-orientation`,label:o(`settings.yuri.visual.field.installOrientation`),description:o(`settings.yuri.visual.field.installOrientationHint`),descriptionPlacement:`outside`,children:[(0,$.jsxs)(Fr,{value:Yt,onValueChange:e=>{let t=Cp(e);Xt(t),nn(t)},children:[(0,$.jsx)(Pr,{"aria-label":o(`settings.yuri.visual.field.pwaInstallOrientationAria`),className:`w-full`,children:(0,$.jsx)(Ar,{placeholder:o(`settings.yuri.visual.field.selectOrientationPlaceholder`),children:$t})}),(0,$.jsx)(Nr,{children:bp.map(e=>(0,$.jsx)(jr,{value:e.id,children:s(e.labelKey)},e.id))})]}),(0,$.jsx)(q,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>{Xt(`system`),nn(`system`)},disabled:Yt===`system`,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":o(`settings.yuri.visual.actions.resetInstallOrientationAria`),title:o(`settings.common.actions.reset`),children:(0,$.jsx)(X,{name:`restart`,className:`h-3.5 w-3.5`})})]}),Kt&&(0,$.jsxs)(pp,{isMobile:u,itemId:`appearance.mobile-keyboard-mode`,label:o(`settings.yuri.visual.field.mobileKeyboardMode`),description:o(`settings.yuri.visual.field.mobileKeyboardModeHint`),descriptionPlacement:`outside`,children:[(0,$.jsxs)(Fr,{value:te,onValueChange:e=>{let t=le(e);ne(t),ye({mobileKeyboardMode:t})},children:[(0,$.jsx)(Pr,{"aria-label":o(`settings.yuri.visual.field.mobileKeyboardModeAria`),className:`w-full`,children:(0,$.jsx)(Ar,{placeholder:o(`settings.yuri.visual.field.selectMobileKeyboardModePlaceholder`),children:en})}),(0,$.jsx)(Nr,{children:xp.map(e=>(0,$.jsx)(jr,{value:e.id,children:s(e.labelKey)},e.id))})]}),(0,$.jsx)(q,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>{ne(`native`),ye({mobileKeyboardMode:`native`})},disabled:te===`native`,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":o(`settings.yuri.visual.actions.resetMobileKeyboardModeAria`),title:o(`settings.common.actions.reset`),children:(0,$.jsx)(X,{name:`restart`,className:`h-3.5 w-3.5`})})]})]})]}),Vt&&(0,$.jsx)($.Fragment,{children:(0,$.jsx)(mp,{isMobile:u,label:o(`settings.yuri.visual.section.spacingAndLayout`),children:(0,$.jsxs)($.Fragment,{children:[J(`fontSize`)&&!u&&(0,$.jsxs)(hp,{isMobile:u,label:o(`settings.yuri.visual.field.interfaceFont`),children:[(0,$.jsxs)(Fr,{value:R,onValueChange:e=>z(e),children:[(0,$.jsx)(Pr,{"aria-label":o(`settings.yuri.visual.field.selectInterfaceFontAria`),className:`w-[13rem]`,children:(0,$.jsx)(Ar,{children:de.find(e=>e.id===R)?.label})}),(0,$.jsx)(Nr,{children:de.map(e=>(0,$.jsx)(jr,{value:e.id,children:(0,$.jsx)(`span`,{style:{fontFamily:e.stack},children:e.label})},e.id))})]}),(0,$.jsx)(q,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>z(`system`),disabled:R===`system`,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":o(`settings.yuri.visual.actions.resetInterfaceFontAria`),title:o(`settings.common.actions.reset`),children:(0,$.jsx)(X,{name:`restart`,className:`h-3.5 w-3.5`})})]}),J(`terminalFontSize`)&&(0,$.jsxs)(hp,{isMobile:u,itemId:`appearance.code-font`,label:o(`settings.yuri.visual.field.codeFont`),children:[(0,$.jsxs)(Fr,{value:B,onValueChange:e=>V(e),children:[(0,$.jsx)(Pr,{"aria-label":o(`settings.yuri.visual.field.selectCodeFontAria`),className:`w-full max-w-[13rem]`,children:(0,$.jsx)(Ar,{children:ue.find(e=>e.id===B)?.label})}),(0,$.jsx)(Nr,{children:ue.map(e=>(0,$.jsx)(jr,{value:e.id,children:(0,$.jsx)(`span`,{style:{fontFamily:e.stack},children:e.label})},e.id))})]}),(0,$.jsx)(q,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>V(`system-mono`),disabled:B===`system-mono`,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":o(`settings.yuri.visual.actions.resetCodeFontAria`),title:o(`settings.common.actions.reset`),children:(0,$.jsx)(X,{name:`restart`,className:`h-3.5 w-3.5`})})]}),J(`fontSize`)&&(0,$.jsxs)(hp,{isMobile:u,itemId:`appearance.interface-font-size`,label:o(`settings.yuri.visual.field.interfaceFontSize`),children:[(0,$.jsx)(ma,{value:A,onValueChange:j,min:50,max:200,step:5,"aria-label":o(`settings.yuri.visual.field.fontSizePercentageAria`),className:`w-16`}),(0,$.jsx)(q,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>j(100),disabled:A===100,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":o(`settings.yuri.visual.actions.resetFontSizeAria`),title:o(`settings.common.actions.reset`),children:(0,$.jsx)(X,{name:`restart`,className:`h-3.5 w-3.5`})})]}),J(`codeFontSize`)&&(0,$.jsxs)(hp,{isMobile:u,itemId:`appearance.code-font-size`,label:o(`settings.yuri.visual.field.codeFontSize`),children:[(0,$.jsx)(ma,{value:M,onValueChange:N,min:50,max:200,step:5,"aria-label":o(`settings.yuri.visual.field.codeFontSizePercentageAria`),className:`w-16`}),(0,$.jsx)(q,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>N(100),disabled:M===100,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":o(`settings.yuri.visual.actions.resetCodeFontSizeAria`),title:o(`settings.common.actions.reset`),children:(0,$.jsx)(X,{name:`restart`,className:`h-3.5 w-3.5`})})]}),J(`terminalFontSize`)&&(0,$.jsxs)(hp,{isMobile:u,itemId:`appearance.terminal-font-size`,label:o(`settings.yuri.visual.field.terminalFontSize`),children:[(0,$.jsx)(ma,{value:P,onValueChange:F,min:9,max:52,step:1,className:`w-16`}),(0,$.jsx)(q,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>F(13),disabled:P===13,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":o(`settings.yuri.visual.actions.resetTerminalFontSizeAria`),title:o(`settings.common.actions.reset`),children:(0,$.jsx)(X,{name:`restart`,className:`h-3.5 w-3.5`})})]}),J(`editorFontSize`)&&(0,$.jsxs)(hp,{isMobile:u,itemId:`appearance.editor-font-size`,label:o(`settings.yuri.visual.field.editorFontSize`),children:[(0,$.jsx)(ma,{value:I,onValueChange:L,min:9,max:32,step:1,className:`w-16`}),(0,$.jsx)(q,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>L(13),disabled:I===13,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":o(`settings.yuri.visual.actions.resetEditorFontSizeAria`),title:o(`settings.common.actions.reset`),children:(0,$.jsx)(X,{name:`restart`,className:`h-3.5 w-3.5`})})]}),J(`spacing`)&&(0,$.jsxs)(hp,{isMobile:u,itemId:`appearance.spacing-density`,label:o(`settings.yuri.visual.field.spacingDensity`),children:[(0,$.jsx)(ma,{value:H,onValueChange:U,min:50,max:200,step:5,className:`w-16`}),(0,$.jsx)(q,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>U(100),disabled:H===100,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":o(`settings.yuri.visual.actions.resetSpacingAria`),title:o(`settings.common.actions.reset`),children:(0,$.jsx)(X,{name:`restart`,className:`h-3.5 w-3.5`})})]}),J(`inputBarOffset`)&&(0,$.jsxs)(hp,{isMobile:u,itemId:`appearance.input-bar-offset`,label:(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:o(`settings.yuri.visual.field.inputBarOffset`)}),(0,$.jsxs)(En,{children:[(0,$.jsx)(wn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(Tn,{sideOffset:8,className:`max-w-xs`,children:o(`settings.yuri.visual.field.inputBarOffsetTooltip`)})]})]}),children:[(0,$.jsx)(ma,{value:W,onValueChange:ee,min:0,max:100,step:5,className:`w-16`}),(0,$.jsx)(q,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>ee(0),disabled:W===0,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":o(`settings.yuri.visual.actions.resetInputBarOffsetAria`),title:o(`settings.common.actions.reset`),children:(0,$.jsx)(X,{name:`restart`,className:`h-3.5 w-3.5`})})]})]})})}),Ht&&(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(mp,{isMobile:u,label:o(`settings.yuri.visual.section.navigation`),children:[J(`fileEditorKeymap`)&&(0,$.jsx)(hp,{isMobile:u,itemId:`appearance.file-editor-keymap`,label:o(`settings.yuri.visual.field.fileEditorKeymap`),children:(0,$.jsx)(`div`,{role:`radiogroup`,"aria-label":o(`settings.yuri.visual.field.fileEditorKeymap`),className:`flex flex-wrap items-center justify-end gap-x-3 gap-y-1`,children:[`default`,`vim`].map(e=>{let t=se===e,n=o(`settings.yuri.visual.option.fileEditorKeymap.${e}`);return(0,$.jsxs)(`button`,{type:`button`,className:`flex cursor-pointer items-center gap-2 py-0.5 text-left`,role:`radio`,"aria-checked":t,onClick:()=>ce(e),children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:K(`relative flex h-[14px] w-[14px] min-h-[14px] min-w-[14px] shrink-0 self-center items-center justify-center rounded-full transition-[background-color,box-shadow] duration-200 ease-out`,t?`bg-[color-mix(in_srgb,var(--primary-base)_80%,transparent)] shadow-none`:`bg-[var(--surface-muted)] shadow-[inset_0_0_0_1px_var(--interactive-border)]`),children:(0,$.jsx)(`span`,{className:K(`block h-[5px] w-[5px] rounded-full bg-white`,!t&&`opacity-0`)})}),(0,$.jsx)(`span`,{className:K(`typography-ui-label font-normal`,t?`text-foreground`:`text-foreground/50`),children:n})]},e)})})}),J(`terminalQuickKeys`)&&!u&&!h()&&(0,$.jsx)(hp,{isMobile:u,itemId:`appearance.terminal-quick-keys`,label:(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:o(`settings.yuri.visual.field.terminalQuickKeys`)}),(0,$.jsxs)(En,{children:[(0,$.jsx)(wn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(Tn,{sideOffset:8,className:`max-w-xs`,children:o(`settings.yuri.visual.field.terminalQuickKeysTooltip`)})]})]}),children:(0,$.jsx)(Wi,{checked:ae,onChange:oe,ariaLabel:o(`settings.yuri.visual.field.terminalQuickKeysAria`)})})]})}),Ut&&(0,$.jsxs)(`div`,{className:`yuri-settings-section-stack`,children:[(J(`chatRenderMode`)||J(`messageTransport`)||J(`diffLayout`)&&!It)&&(0,$.jsxs)(`div`,{className:`grid w-full grid-cols-1 gap-y-[var(--yuri-settings-section-stack-gap)]`,children:[J(`chatRenderMode`)&&(0,$.jsx)(mp,{isMobile:u,label:o(`settings.yuri.visual.section.chatRenderMode`),className:`w-full`,cardClassName:`!border-0 !bg-transparent !rounded-none overflow-visible`,children:(0,$.jsx)(`div`,{"data-settings-item":`chat.render-mode`,className:`min-w-0 w-full`,children:(0,$.jsx)(`div`,{role:`radiogroup`,"aria-label":o(`settings.yuri.visual.section.chatRenderModeAria`),className:`grid w-full grid-cols-1 gap-3 sm:grid-cols-2`,children:wp.map(e=>{let t=D===e.id,n=pt%12;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>Ct(e.id),"aria-pressed":t,className:K(`flex flex-col items-start gap-1 rounded-lg border p-3 text-left transition-colors`,t?`border-primary bg-primary/5`:`border-border hover:border-border/80 hover:bg-muted/50`),children:[(0,$.jsx)(`span`,{className:K(`typography-ui-label`,t?`text-foreground`:`text-muted-foreground`),children:s(e.labelKey)}),(0,$.jsx)(`div`,{className:`mt-2 w-full rounded-md border border-border/60 bg-muted/30 p-2`,children:e.id===`live`?(0,$.jsx)(`div`,{className:`space-y-1.5`,children:[0,1,2].map(e=>{let t=e*3+1,r=n-t+1,i=r<=0?0:r===1?42:r===2?68:92;return(0,$.jsxs)(`div`,{className:K(`flex items-center gap-1.5 transition-all duration-300 motion-reduce:transition-none`,i>0?`translate-y-0 opacity-100`:`translate-y-1 opacity-0`),children:[(0,$.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full bg-muted-foreground/55`}),(0,$.jsx)(`span`,{className:`h-1.5 rounded bg-muted-foreground/30 transition-all duration-300 motion-reduce:transition-none`,style:{width:`${i}%`}})]},e)})}):(0,$.jsx)(`div`,{className:`space-y-1.5`,children:[0,1,2].map(e=>{let t=n>=(e+1)*3;return(0,$.jsxs)(`div`,{className:K(`flex items-center gap-1.5 transition-all duration-300 motion-reduce:transition-none`,t?`translate-y-0 opacity-100`:`translate-y-1 opacity-0`),children:[(0,$.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full bg-muted-foreground/55`}),(0,$.jsx)(`span`,{className:`h-1.5 rounded bg-muted-foreground/30`,style:{width:`92%`}})]},e)})})})]},e.id)})})})}),J(`messageTransport`)&&(0,$.jsx)(mp,{isMobile:u,label:o(`settings.yuri.visual.section.messageStreamTransport`),className:`w-full`,children:(0,$.jsxs)(`div`,{"data-settings-item":`chat.message-transport`,className:`yuri-settings-group-row flex flex-col gap-2`,children:[(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-1`,children:Tp.map(e=>(0,$.jsx)(q,{variant:`chip`,size:`xs`,"aria-pressed":Le===e.id,className:`!font-normal`,onClick:()=>wt(e.id),children:s(e.labelKey)},e.id))}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:(()=>{let e=Tp.find(e=>e.id===Le);return e?.descriptionKey?s(e.descriptionKey):``})()})]})}),J(`diffLayout`)&&!It&&(0,$.jsx)(mp,{isMobile:u,label:o(`settings.yuri.visual.section.diffLayout`),className:`w-full`,children:(0,$.jsx)(`div`,{"data-settings-item":`chat.diff-layout`,role:`radiogroup`,"aria-label":o(`settings.yuri.visual.section.diffLayoutAria`),children:vp.map(e=>{let t=re===e.id;return(0,$.jsx)(gp,{selected:t,onSelect:()=>ie(e.id),label:s(e.labelKey),ariaLabel:o(`settings.yuri.visual.field.diffLayoutAria`,{option:s(e.labelKey)})},e.id)})})})]}),J(`sessionGoal`)&&(0,$.jsx)(mp,{isMobile:u,label:(0,$.jsx)(`div`,{className:`flex items-center gap-1.5`,children:(0,$.jsx)(`span`,{children:o(`settings.yuri.visual.goal.sectionTitle`)})}),children:(0,$.jsx)(hp,{isMobile:u,itemId:`chat.session-goal`,label:o(`settings.yuri.visual.field.sessionGoal`),children:(0,$.jsx)(Wi,{checked:v,onChange:y,ariaLabel:o(`settings.yuri.visual.field.sessionGoalAria`)})})}),(J(`sessionAssist`)||J(`collapsibleUserMessages`)||J(`splitAssistantMessageActions`)||J(`showAssistantTps`)||J(`subagentReadOnlyBanner`)||J(`persistDraft`)||J(`showSubagentTaskDetails`)||!u&&J(`inputSpellcheck`)||J(`reasoning`))&&(0,$.jsxs)(`div`,{className:`yuri-settings-section-stack`,children:[(J(`sessionAssist`)||J(`questionAutoDelegate`)||J(`subagentReadOnlyBanner`))&&(0,$.jsxs)(mp,{isMobile:u,label:(0,$.jsx)(`span`,{"data-settings-item":`chat.session-assistance`,children:o(`settings.yuri.visual.section.sessionAssistance`)}),children:[J(`sessionAssist`)&&(0,$.jsx)(Ji,{itemId:`chat.session-title-refresh`,checked:m,onChange:_,label:o(`settings.yuri.visual.field.sessionTitleRefresh`),ariaLabel:o(`settings.yuri.visual.field.sessionTitleRefreshAria`)}),J(`subagentReadOnlyBanner`)&&(0,$.jsx)(Ji,{itemId:`chat.subagent-read-only-banner`,checked:Ne,onChange:Pe,label:o(`settings.yuri.visual.field.allowPromptingSubagentSessions`),ariaLabel:o(`settings.yuri.visual.field.allowPromptingSubagentSessionsAria`)}),J(`questionAutoDelegate`)&&(0,$.jsx)(fp,{})]}),(J(`collapsibleUserMessages`)||J(`splitAssistantMessageActions`)||J(`showAssistantTps`)||J(`reasoning`))&&(0,$.jsxs)(mp,{isMobile:u,label:(0,$.jsx)(`span`,{"data-settings-item":`chat.message-appearance`,children:o(`settings.yuri.visual.section.messageAppearance`)}),children:[J(`reasoning`)&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{"data-settings-item":`chat.reasoning`,className:`hidden`,"aria-hidden":!0}),(0,$.jsx)(Ji,{checked:p,onChange:b,label:o(`settings.yuri.visual.field.showReasoningTraces`),description:o(`settings.yuri.visual.field.showReasoningTracesHint`),ariaLabel:o(`settings.yuri.visual.field.showReasoningTracesAria`)}),p&&(0,$.jsx)(Ji,{checked:x,onChange:S,label:o(`settings.yuri.visual.field.collapsibleThinkingBlocks`),ariaLabel:o(`settings.yuri.visual.field.collapsibleThinkingBlocksAria`)})]}),J(`collapsibleUserMessages`)&&(0,$.jsx)(Ji,{itemId:`chat.collapsible-user-messages`,checked:C,onChange:yt,label:o(`settings.yuri.visual.field.collapsibleUserMessages`),ariaLabel:o(`settings.yuri.visual.field.collapsibleUserMessagesAria`)}),J(`splitAssistantMessageActions`)&&(0,$.jsx)(Ji,{itemId:`chat.inline-assistant-actions`,checked:De,onChange:bt,ariaLabel:o(`settings.yuri.visual.field.showSplitAssistantMessageActionsAria`),label:(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:o(`settings.yuri.visual.field.showSplitAssistantMessageActions`)}),(0,$.jsxs)(En,{children:[(0,$.jsx)(wn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 cursor-help text-muted-foreground/60`})}),(0,$.jsx)(Tn,{sideOffset:8,className:`max-w-xs`,children:o(`settings.yuri.visual.field.showSplitAssistantMessageActionsTooltip`)})]})]})}),J(`showAssistantTps`)&&(0,$.jsx)(Ji,{itemId:`chat.assistant-tps`,checked:ke,onChange:xt,ariaLabel:o(`settings.yuri.visual.field.showAssistantTpsAria`),label:(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:o(`settings.yuri.visual.field.showAssistantTps`)}),(0,$.jsxs)(En,{children:[(0,$.jsx)(wn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 cursor-help text-muted-foreground/60`})}),(0,$.jsx)(Tn,{sideOffset:8,className:`max-w-xs`,children:o(`settings.yuri.visual.field.showAssistantTpsTooltip`)})]})]})})]}),J(`showSubagentTaskDetails`)&&(0,$.jsx)(mp,{isMobile:u,children:(0,$.jsx)(Ji,{itemId:`chat.subagent-task-details`,checked:be,onChange:Tt,label:o(`settings.yuri.visual.field.showSubagentTaskDetails`),description:o(`settings.yuri.visual.field.showSubagentTaskDetailsHint`),ariaLabel:o(`settings.yuri.visual.field.showSubagentTaskDetailsAria`)})}),(J(`persistDraft`)||J(`followUpBehavior`)||!u&&J(`inputSpellcheck`))&&(0,$.jsxs)(mp,{isMobile:u,label:(0,$.jsx)(`span`,{"data-settings-item":`chat.composer`,children:o(`settings.yuri.visual.section.composer`)}),children:[J(`followUpBehavior`)&&(0,$.jsx)(hp,{isMobile:u,itemId:`chat.follow-up-behavior`,label:o(`settings.yuri.visual.field.followUpBehavior`),description:o(`settings.yuri.visual.field.followUpBehaviorDescription`),children:(0,$.jsxs)(Fr,{value:pe,onValueChange:e=>me(e===`steer`?`steer`:`queue`),children:[(0,$.jsx)(Pr,{"aria-label":o(`settings.yuri.visual.field.followUpBehaviorAria`),className:`w-fit`,children:(0,$.jsx)(Ar,{children:o(`settings.yuri.visual.option.followUpBehavior.${pe}.label`)})}),(0,$.jsx)(Nr,{children:Sp.map(e=>(0,$.jsx)(jr,{value:e.id,children:s(e.labelKey)},e.id))})]})}),J(`persistDraft`)&&(0,$.jsx)(Ji,{itemId:`chat.persist-drafts`,checked:he,onChange:ge,label:o(`settings.yuri.visual.field.persistDraftMessages`),ariaLabel:o(`settings.yuri.visual.field.persistDraftMessagesAria`)}),!u&&J(`inputSpellcheck`)&&(0,$.jsx)(Ji,{itemId:`chat.spellcheck`,checked:_e,onChange:St,label:o(`settings.yuri.visual.field.enableSpellcheckInTextInputs`),ariaLabel:o(`settings.yuri.visual.field.enableSpellcheckInTextInputsAria`)})]})]})]}),J(`reportUsage`)&&(0,$.jsxs)(mp,{isMobile:u,label:o(`settings.yuri.visual.section.privacy`),children:[J(`reportUsage`)&&(0,$.jsx)(hp,{isMobile:u,itemId:`appearance.usage-reports`,label:o(`settings.yuri.visual.field.sendAnonymousUsageReports`),description:o(`settings.yuri.visual.field.sendAnonymousUsageReportsHint`),children:(0,$.jsx)(Wi,{checked:ht,onChange:_t,ariaLabel:o(`settings.yuri.visual.field.sendAnonymousUsageReportsAria`)})}),J(`reportUsage`)&&(0,$.jsx)(hp,{isMobile:u,itemId:`appearance.transcript-cache`,label:o(`settings.yuri.visual.transcriptCache.label`),description:o(`settings.yuri.visual.transcriptCache.description`),children:(0,$.jsx)(q,{type:`button`,variant:`destructive`,size:`sm`,disabled:$e,onClick:()=>Qe(!0),children:o(`settings.yuri.visual.transcriptCache.action`)})})]})]}),(0,$.jsx)(gn,{open:at!==null,onOpenChange:e=>{!e&&!st&&ot(null)},children:(0,$.jsxs)(pn,{showCloseButton:!st,children:[(0,$.jsxs)(dn,{children:[(0,$.jsx)(mn,{children:o(`settings.yuri.visual.field.macVibrancy`)}),(0,$.jsx)(hn,{children:o(`settings.yuri.visual.vibrancy.confirmDescription`)})]}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(q,{type:`button`,variant:`ghost`,disabled:st,onClick:()=>ot(null),children:o(`settings.common.actions.cancel`)}),(0,$.jsx)(q,{type:`button`,disabled:st,"aria-busy":st||void 0,onClick:()=>void lt(),children:o(st?`settings.yuri.visual.actions.restarting`:`settings.yuri.visual.vibrancy.confirmRestart`)})]})]})}),(0,$.jsx)(gn,{open:Ze,onOpenChange:e=>{$e||Qe(e)},children:(0,$.jsxs)(pn,{className:`max-w-[min(480px,100vw-2rem)]`,children:[(0,$.jsxs)(dn,{children:[(0,$.jsx)(mn,{children:o(`settings.yuri.visual.transcriptCache.dialog.title`)}),(0,$.jsx)(hn,{children:o(`settings.yuri.visual.transcriptCache.dialog.description`)})]}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(q,{type:`button`,variant:`ghost`,disabled:$e,onClick:()=>Qe(!1),children:o(`settings.common.actions.cancel`)}),(0,$.jsx)(q,{type:`button`,variant:`destructive`,disabled:$e,"aria-busy":$e||void 0,onClick:()=>void Ft(),children:o($e?`settings.yuri.visual.transcriptCache.dialog.clearing`:`settings.yuri.visual.transcriptCache.action`)})]})]})})]})},kp=864e5,Ap=5,jp=864e5,Mp=e=>e.time?.updated??e.time?.created??0,Np=({sessions:e,currentSessionId:t,cutoffDays:n,keepRecent:r=Ap,now:i=Date.now()})=>{if(!Array.isArray(e)||n<=0)return[];let a=i-n*kp,o=[...e].sort((e,t)=>Mp(t)-Mp(e)),s=new Set(o.slice(0,r).map(e=>e.id));return o.filter(e=>{if(!e?.id||s.has(e.id)||e.id===t||e.share)return!1;let n=Mp(e);return n?n<a:!1}).map(e=>e.id)},Pp=e=>{let t=typeof e==`object`?e:void 0,n=t?.autoRun!==!1,r=typeof e==`boolean`?e:t?.enabled??!0,i=Vt(e=>e.currentSessionId),a=Vt(e=>e.isLoading),o=lt(e=>e.activeSessions),s=lt(e=>e.hasLoadedFullCatalog),c=G(e=>e.autoDeleteEnabled),l=G(e=>e.autoDeleteAfterDays),u=G(e=>e.sessionRetentionAction),d=G(e=>e.autoDeleteLastRunAt),f=G(e=>e.setAutoDeleteLastRunAt),[p,m]=Q.useState(!1),h=Q.useRef(!1);Q.useEffect(()=>{if(!r||!n||!c||l<=0)return;let e=window.setTimeout(()=>{bt(se())},8e3);return()=>window.clearTimeout(e)},[l,c,n,r]);let g=Q.useMemo(()=>l<=0?[]:Np({sessions:o,currentSessionId:i,cutoffDays:l}),[l,i,o]),_=Q.useCallback(async({force:e=!1}={})=>{if(h.current)return{completedIds:[],failedIds:[],action:u,skippedReason:`running`};if((!c||l<=0)&&!e)return{completedIds:[],failedIds:[],action:u,skippedReason:`disabled`};if(a)return{completedIds:[],failedIds:[],action:u,skippedReason:`loading`};let t=Date.now();if(!e&&d&&t-d<jp)return{completedIds:[],failedIds:[],action:u,skippedReason:`cooldown`};let{activeSessions:n}=await bt(se());if(n.length===0)return{completedIds:[],failedIds:[],action:u,skippedReason:`no-candidates`};let r=Np({sessions:n,currentSessionId:i,cutoffDays:l,now:t});if(r.length===0)return f(t),{completedIds:[],failedIds:[],action:u,skippedReason:`no-candidates`};h.current=!0,m(!0);try{let e=new Map(n.map(e=>[e.id,e])),t=[],i=[];for(let n of r){let r=e.get(n),a=r?St(r):null;if(!a){i.push(n);continue}try{u===`archive`?await oe.updateSession(n,{time:{archived:Date.now()}},a):await oe.deleteSession(n,a),t.push(n)}catch{i.push(n)}}return u===`archive`?lt.getState().archiveSessions(t):lt.getState().removeSessions(t),{completedIds:t,failedIds:i,action:u}}finally{h.current=!1,m(!1),f(Date.now())}},[l,c,d,i,a,u,f]);return Q.useEffect(()=>{r&&n&&(!c||l<=0||a||!s||o.length===0||d&&Date.now()-d<jp||_())},[l,c,d,n,r,s,o.length,a,_]),{candidates:g,isRunning:p,runCleanup:_,keepRecentCount:Ap,action:u}},Fp=1,Ip=365,Lp=30,Rp=[{value:`archive`,labelKey:`settings.yuri.sessionRetention.action.archive`},{value:`delete`,labelKey:`settings.yuri.sessionRetention.action.delete`}],zp=()=>{let e=(0,Sa.c)(101),{t}=Ge(),n=G(Bp),r=G(Vp),i=G(Hp),a=G(Up),o=G(Wp),s=G(Gp),c;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(c={autoRun:!1},e[0]=c):c=e[0];let{candidates:l,isRunning:u,runCleanup:d,action:f}=Pp(c),p=l.length,m;e[1]!==d||e[2]!==t?(m=async()=>{let e=await d({force:!0});if(e.completedIds.length===0&&e.failedIds.length===0){Y.message(e.action===`archive`?t(`settings.yuri.sessionRetention.toast.noneEligibleArchive`):t(`settings.yuri.sessionRetention.toast.noneEligibleDelete`));return}e.completedIds.length>0&&Y.success(e.action===`archive`?t(`settings.yuri.sessionRetention.toast.archivedCount`,{count:e.completedIds.length}):t(`settings.yuri.sessionRetention.toast.deletedCount`,{count:e.completedIds.length})),e.failedIds.length>0&&Y.error(e.action===`archive`?t(`settings.yuri.sessionRetention.toast.failedArchiveCount`,{count:e.failedIds.length}):t(`settings.yuri.sessionRetention.toast.failedDeleteCount`,{count:e.failedIds.length}))},e[1]=d,e[2]=t,e[3]=m):m=e[3];let h=m,g;e[4]===t?g=e[5]:(g=t(`settings.yuri.sessionRetention.title`),e[4]=t,e[5]=g);let _;e[6]===g?_=e[7]:(_=(0,$.jsx)(`span`,{children:g}),e[6]=g,e[7]=_);let v;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(wn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 cursor-help text-muted-foreground/60`})}),e[8]=v):v=e[8];let y;e[9]===t?y=e[10]:(y=t(`settings.yuri.sessionRetention.tooltip`),e[9]=t,e[10]=y);let b;e[11]===y?b=e[12]:(b=(0,$.jsxs)(En,{children:[v,(0,$.jsx)(Tn,{sideOffset:8,className:`max-w-xs`,children:y})]}),e[11]=y,e[12]=b);let x;e[13]!==_||e[14]!==b?(x=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[_,b]}),e[13]=_,e[14]=b,e[15]=x):x=e[15];let S,C;e[16]!==n||e[17]!==a?(S=()=>a(!n),C=e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),a(!n))},e[16]=n,e[17]=a,e[18]=S,e[19]=C):(S=e[18],C=e[19]);let w;e[20]===t?w=e[21]:(w=t(`settings.yuri.sessionRetention.field.enableAutoCleanup`),e[20]=t,e[21]=w);let T;e[22]===w?T=e[23]:(T=(0,$.jsx)(`div`,{className:`yuri-settings-split-row-copy`,children:(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:w})}),e[22]=w,e[23]=T);let E;e[24]===t?E=e[25]:(E=t(`settings.yuri.sessionRetention.field.enableAutoCleanupAria`),e[24]=t,e[25]=E);let D;e[26]!==n||e[27]!==a||e[28]!==E?(D=(0,$.jsx)(`div`,{className:`yuri-settings-split-row-control`,children:(0,$.jsx)(Wi,{checked:n,onChange:a,ariaLabel:E})}),e[26]=n,e[27]=a,e[28]=E,e[29]=D):D=e[29];let O;e[30]!==n||e[31]!==T||e[32]!==D||e[33]!==S||e[34]!==C?(O=(0,$.jsxs)(`div`,{"data-settings-item":`sessions.auto-cleanup`,className:`yuri-settings-group-row yuri-settings-split-row group cursor-pointer`,role:`button`,tabIndex:0,"aria-pressed":n,onClick:S,onKeyDown:C,children:[T,D]}),e[30]=n,e[31]=T,e[32]=D,e[33]=S,e[34]=C,e[35]=O):O=e[35];let k;e[36]===t?k=e[37]:(k=t(`settings.yuri.sessionRetention.field.retentionPeriod`),e[36]=t,e[37]=k);let A;e[38]===t?A=e[39]:(A=t(`settings.yuri.sessionRetention.field.retentionPeriodAria`),e[38]=t,e[39]=A);let j;e[40]!==r||e[41]!==o||e[42]!==A?(j=(0,$.jsx)(ma,{value:r,onValueChange:o,min:Fp,max:Ip,step:1,"aria-label":A,className:`w-20 tabular-nums`}),e[40]=r,e[41]=o,e[42]=A,e[43]=j):j=e[43];let M;e[44]===t?M=e[45]:(M=t(`settings.yuri.sessionRetention.field.days`),e[44]=t,e[45]=M);let N;e[46]===M?N=e[47]:(N=(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground`,children:M}),e[46]=M,e[47]=N);let P;e[48]===o?P=e[49]:(P=()=>o(Lp),e[48]=o,e[49]=P);let F=r===Lp,I;e[50]===t?I=e[51]:(I=t(`settings.yuri.sessionRetention.actions.resetRetentionAria`),e[50]=t,e[51]=I);let L;e[52]===t?L=e[53]:(L=t(`settings.common.actions.reset`),e[52]=t,e[53]=L);let R;e[54]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,$.jsx)(X,{name:`restart`,className:`h-3.5 w-3.5`}),e[54]=R):R=e[54];let z;e[55]!==P||e[56]!==F||e[57]!==I||e[58]!==L?(z=(0,$.jsx)(q,{size:`sm`,type:`button`,variant:`ghost`,onClick:P,disabled:F,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":I,title:L,children:R}),e[55]=P,e[56]=F,e[57]=I,e[58]=L,e[59]=z):z=e[59];let B;e[60]!==k||e[61]!==j||e[62]!==N||e[63]!==z?(B=(0,$.jsxs)(Xi,{itemId:`sessions.retention-period`,label:k,children:[j,N,z]}),e[60]=k,e[61]=j,e[62]=N,e[63]=z,e[64]=B):B=e[64];let V;e[65]===t?V=e[66]:(V=t(`settings.yuri.sessionRetention.field.whenSessionsExpire`),e[65]=t,e[66]=V);let H;e[67]!==i||e[68]!==s||e[69]!==t?(H=Rp.map(e=>(0,$.jsx)(q,{type:`button`,variant:`chip`,size:`xs`,"aria-pressed":i===e.value,className:`!font-normal`,onClick:()=>s(e.value),children:t(e.labelKey)},e.value)),e[67]=i,e[68]=s,e[69]=t,e[70]=H):H=e[70];let U;e[71]===H?U=e[72]:(U=(0,$.jsx)(`div`,{className:`flex flex-wrap items-center justify-end gap-1`,children:H}),e[71]=H,e[72]=U);let W;e[73]!==V||e[74]!==U?(W=(0,$.jsx)(Xi,{itemId:`sessions.retention-action`,label:V,children:U}),e[73]=V,e[74]=U,e[75]=W):W=e[75];let ee;e[76]!==O||e[77]!==B||e[78]!==W||e[79]!==x?(ee=(0,$.jsxs)(Z,{label:x,children:[O,B,W]}),e[76]=O,e[77]=B,e[78]=W,e[79]=x,e[80]=ee):ee=e[80];let te;e[81]===t?te=e[82]:(te=t(`settings.yuri.sessionRetention.manualCleanup.title`),e[81]=t,e[82]=te);let ne;e[83]!==f||e[84]!==p||e[85]!==t?(ne=t(f===`archive`?`settings.yuri.sessionRetention.manualCleanup.eligibleArchiveNow`:`settings.yuri.sessionRetention.manualCleanup.eligibleDeleteNow`,{count:p}),e[83]=f,e[84]=p,e[85]=t,e[86]=ne):ne=e[86];let re;e[87]!==u||e[88]!==t?(re=t(u?`settings.yuri.sessionRetention.actions.cleaningUp`:`settings.yuri.sessionRetention.actions.runCleanupNow`),e[87]=u,e[88]=t,e[89]=re):re=e[89];let ie;e[90]!==h||e[91]!==u||e[92]!==re?(ie=(0,$.jsx)(q,{type:`button`,variant:`outline`,size:`xs`,onClick:h,disabled:u,className:`!font-normal`,children:re}),e[90]=h,e[91]=u,e[92]=re,e[93]=ie):ie=e[93];let ae;e[94]!==te||e[95]!==ne||e[96]!==ie?(ae=(0,$.jsx)(Ui,{label:te,description:ne,descriptionPlacement:`outside`,children:ie}),e[94]=te,e[95]=ne,e[96]=ie,e[97]=ae):ae=e[97];let oe;return e[98]!==ee||e[99]!==ae?(oe=(0,$.jsxs)(`div`,{className:`yuri-settings-section-stack`,children:[ee,ae]}),e[98]=ee,e[99]=ae,e[100]=oe):oe=e[100],oe};function Bp(e){return e.autoDeleteEnabled}function Vp(e){return e.autoDeleteAfterDays}function Hp(e){return e.sessionRetentionAction}function Up(e){return e.setAutoDeleteEnabled}function Wp(e){return e.setAutoDeleteAfterDays}function Gp(e){return e.setSessionRetentionAction}var Kp=(e,t,n)=>!e||!Number.isFinite(e)?t:new Intl.DateTimeFormat(Je(),{dateStyle:`medium`,timeStyle:`short`,hour12:n===`auto`?void 0:n===`12h`}).format(e),qp=()=>{let{t:e}=Ge(),t=G(e=>e.timeFormatPreference),[n,r]=Q.useState(!1),[i,a]=Q.useState(!0),[o,s]=Q.useState(!1),[c,l]=Q.useState(null),[u,d]=Q.useState(!1),[f,p]=Q.useState([]),[m,h]=Q.useState(qn),[g,_]=Q.useState(``),v=Q.useMemo(()=>Yn(),[]),y=Q.useCallback(async()=>{a(!0),_(``);try{let e=await br();p(e)}catch(t){let n=t instanceof Error?t.message:e(`settings.yuri.passkeys.toast.loadFailed`);_(n)}finally{a(!1)}},[e]);Q.useEffect(()=>{let e=!1;return(async()=>{try{if(!v.supported){e||(r(!1),a(!1));return}e||r(!0)}catch{e||r(!1)}if(!e){let e=await jn();if(h(e),!e.enabled){p([]),a(!1);return}await y()}})(),()=>{e=!0,xr()}},[y,v.supported]);let b=Q.useCallback(async()=>{if(!m.enabled){let t=e(`settings.yuri.passkeys.toast.enableUiPasswordFirst`);_(t),Y.message(t);return}if(!n){_(v.reason),Y.message(v.reason);return}if(o){xr(),s(!1);return}_(``),s(!0);try{await Nn(),h(await jn()),await y(),Y.success(e(`settings.yuri.passkeys.toast.added`))}catch(t){if(Pn(t)){Y.message(e(`settings.yuri.passkeys.toast.setupCanceled`));return}let n=t instanceof Error?t.message:e(`settings.yuri.passkeys.toast.addFailed`);_(n),Y.error(n)}finally{s(!1)}},[o,y,m.enabled,v.reason,n,e]),x=Q.useCallback(async t=>{l(t),_(``);try{await lr(t),h(await jn()),await y(),Y.success(e(`settings.yuri.passkeys.toast.removed`))}catch(t){let n=t instanceof Error?t.message:e(`settings.yuri.passkeys.toast.removeFailed`);_(n),Y.error(n)}finally{l(null)}},[y,e]),S=Q.useCallback(async()=>{d(!0),_(``);try{await Gn(),window.location.reload()}catch(t){let n=t instanceof Error?t.message:e(`settings.yuri.passkeys.toast.clearAuthFailed`);_(n),Y.error(n),d(!1)}},[e]);return(0,$.jsxs)(Z,{label:e(`settings.yuri.passkeys.title`),children:[(0,$.jsx)(Xi,{label:e(`settings.yuri.passkeys.field.currentDevice`),children:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,$.jsx)(q,{type:`button`,variant:o?`secondary`:`outline`,size:`xs`,onClick:()=>void b(),disabled:i||u,className:`!font-normal`,children:e(o?`settings.yuri.passkeys.actions.cancelSetup`:`settings.yuri.passkeys.actions.add`)}),(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`xs`,onClick:()=>void S(),disabled:i||o||u,className:`!font-normal text-muted-foreground hover:text-foreground`,children:e(u?`settings.yuri.passkeys.actions.signingOut`:`settings.yuri.passkeys.actions.signOutEverywhere`)})]})}),!m.enabled&&(0,$.jsx)(`p`,{className:`yuri-settings-group-row typography-meta text-muted-foreground`,children:e(`settings.yuri.passkeys.state.uiPasswordRequired`)}),m.enabled&&!n&&(0,$.jsx)(`p`,{className:`yuri-settings-group-row typography-meta text-muted-foreground`,children:v.reason}),i?(0,$.jsx)(`p`,{className:`yuri-settings-group-row typography-meta text-muted-foreground`,children:e(`settings.yuri.passkeys.state.loading`)}):f.length===0?(0,$.jsx)(`p`,{className:`yuri-settings-group-row typography-meta text-muted-foreground`,children:e(`settings.yuri.passkeys.state.noneSaved`)}):(0,$.jsx)($.Fragment,{children:f.map(n=>(0,$.jsx)(Xi,{label:n.label,copyClassName:`truncate`,children:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground truncate`,children:n.lastUsedAt?e(`settings.yuri.passkeys.item.lastUsed`,{time:Kp(n.lastUsedAt,e(`settings.yuri.passkeys.time.neverUsed`),t)}):e(`settings.yuri.passkeys.item.added`,{time:Kp(n.createdAt,e(`settings.yuri.passkeys.time.neverUsed`),t)})}),(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`xs`,onClick:()=>void x(n.id),disabled:c===n.id,className:`!font-normal text-muted-foreground hover:text-foreground`,children:c===n.id?e(`settings.yuri.passkeys.actions.removing`):e(`settings.common.actions.delete`)})]})},n.id))}),g&&(0,$.jsx)(`div`,{className:`yuri-settings-group-row`,children:(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:g})})]})},Jp=e=>Ht(e)||{providerId:``,modelId:``},Yp=()=>{let{t:e}=Ge(),t=Pt(e=>e.setProvider),n=Pt(e=>e.setModel),r=Pt(e=>e.setAgent),i=Pt(e=>e.setCurrentVariant),a=Pt(e=>e.setSettingsDefaultModel),o=Pt(e=>e.setSettingsDefaultVariant),s=Pt(e=>e.setSettingsDefaultAgent),c=G(e=>e.showDeletionDialog),u=G(e=>e.setShowDeletionDialog),d=Pt(e=>e.providers),[f,p]=Q.useState(),[m,h]=Q.useState(),[g,_]=Q.useState(),[v,y]=Q.useState(!0),b=Q.useMemo(()=>Jp(f),[f]);Q.useEffect(()=>{(async()=>{try{let e=null;if(!e){let t=A()?.settings;if(t)try{let n=(await t.load())?.settings;if(n){let t=n;e={defaultModel:typeof n.defaultModel==`string`?n.defaultModel:void 0,defaultVariant:typeof t.defaultVariant==`string`?t.defaultVariant:void 0,defaultAgent:typeof n.defaultAgent==`string`?n.defaultAgent:void 0}}}catch{}}if(!e){let t=await l(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});t.ok&&(e=await t.json())}if(e){let t=typeof e.defaultModel==`string`&&e.defaultModel.trim().length>0?e.defaultModel.trim():void 0,n=typeof e.defaultVariant==`string`&&e.defaultVariant.trim().length>0?e.defaultVariant.trim():void 0,r=typeof e.defaultAgent==`string`&&e.defaultAgent.trim().length>0?e.defaultAgent.trim():void 0;t!==void 0&&p(t),n!==void 0&&h(n),r!==void 0&&_(r)}}catch(e){console.warn(`Failed to load defaults settings:`,e)}finally{y(!1)}})()},[]);let x=Q.useCallback(async(e,r)=>{let s=e&&r?`${e}/${r}`:void 0;p(s),h(void 0),o(void 0),i(void 0),a(s),e&&r&&d.find(t=>t.id===e)&&(t(e),n(r));try{await ye({defaultModel:s??``,defaultVariant:``});let e=await l(`/api/config/settings`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({defaultModel:s})});e.ok||console.warn(`Failed to save default model to server:`,e.status,e.statusText)}catch(e){console.warn(`Failed to save default model:`,e)}},[d,i,n,t,a,o]),S=`__default__`,C=Q.useCallback(t=>t===S?e(`settings.yuri.defaults.option.default`):t.charAt(0).toUpperCase()+t.slice(1),[e]),w=Q.useCallback(async e=>{let t=e===S?void 0:e||void 0;h(t),o(t),i(t);try{await ye({defaultVariant:t??``})}catch(e){console.warn(`Failed to save default variant:`,e)}},[i,o]),T=Q.useCallback(async e=>{let t=e||void 0;_(t),s(t),e&&r(e);try{await ye({defaultAgent:t??``})}catch(e){console.warn(`Failed to save default agent:`,e)}},[r,s]),E=Q.useMemo(()=>{if(!b.providerId||!b.modelId)return[];let e=d.find(e=>e.id===b.providerId)?.models.find(e=>e.id===b.modelId)?.variants;return e?Object.keys(e):[]},[b.modelId,b.providerId,d]),D=E.length>0;return Q.useEffect(()=>{!D&&m&&(h(void 0),o(void 0),i(void 0),ye({defaultVariant:``}).catch(()=>{}))},[m,i,o,D]),v?null:(0,$.jsxs)(Z,{label:e(`settings.yuri.defaults.title`),description:(0,$.jsxs)($.Fragment,{children:[e(`settings.yuri.defaults.summaryPrefix`),` `,b.providerId?(0,$.jsxs)(`span`,{className:`text-foreground`,children:[b.providerId,`/`,b.modelId,D?` (${m??e(`settings.yuri.defaults.option.defaultLowercase`)})`:``]}):(0,$.jsx)(`span`,{className:`text-foreground`,children:e(`settings.yuri.defaults.summaryOpenCodeDefault`)}),g&&(0,$.jsxs)($.Fragment,{children:[` / `,(0,$.jsx)(`span`,{className:`text-foreground`,children:g})]})]}),children:[(0,$.jsx)(Xi,{itemId:`sessions.default-model`,label:e(`settings.yuri.defaults.field.defaultModel`),children:(0,$.jsx)(ii,{providerId:b.providerId,modelId:b.modelId,onChange:x,className:`yuri-settings-inline-value`})}),(0,$.jsx)(Xi,{itemId:`sessions.default-thinking`,label:e(`settings.yuri.defaults.field.defaultThinking`),children:(0,$.jsxs)(Fr,{value:m??S,onValueChange:w,disabled:!D,children:[(0,$.jsx)(Pr,{className:`w-fit min-w-[120px]`,children:(0,$.jsx)(Ar,{placeholder:e(`settings.yuri.defaults.field.thinkingPlaceholder`),children:C(m??S)})}),(0,$.jsxs)(Nr,{children:[(0,$.jsx)(jr,{value:S,children:e(`settings.yuri.defaults.option.default`)}),E.map(e=>(0,$.jsx)(jr,{value:e,children:C(e)},e))]})]})}),(0,$.jsx)(Xi,{itemId:`sessions.default-agent`,label:e(`settings.yuri.defaults.field.defaultAgent`),children:(0,$.jsx)(bi,{agentName:g||``,onChange:T,className:`yuri-settings-inline-value`})}),(0,$.jsxs)(`div`,{"data-settings-item":`sessions.deletion-dialog`,className:`yuri-settings-group-row yuri-settings-split-row group cursor-pointer`,role:`button`,tabIndex:0,"aria-pressed":c,onClick:()=>u(!c),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),u(!c))},children:[(0,$.jsx)(`div`,{className:`yuri-settings-split-row-copy`,children:(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:e(`settings.yuri.defaults.field.showDeletionDialog`)})}),(0,$.jsx)(`div`,{className:`yuri-settings-split-row-control`,children:(0,$.jsx)(Wi,{checked:c,onChange:u,ariaLabel:e(`settings.yuri.defaults.field.showDeletionDialogAria`)})})]})]})},Xp=`You are generating a Conventional Commits subject line from the diffs of the selected files.`,Zp=[`You are a title generator. Output ONLY a thread title.`,`Name the main subject of the work.`,`Keep that subject across follow-ups, polish, commit, push, tidy, and review.`,`Switch only when the user clearly starts a different topic.`,`One line, no explanation.`,`Hard limit: never exceed 6 CJK characters (or 6 words for English). No modifiers. No verbs.`,`Use the language of the user messages.`,`Keep technical terms, numbers, filenames, and HTTP codes exact.`,`Never include tool names, summarizing, or generating.`,`Always output a meaningful title.`].join(`
29
- `),Qp=()=>{let{t:e}=Ge(),[t,n]=Q.useState(``),[r,i]=Q.useState(``),[a,o]=Q.useState(Xp),[s,c]=Q.useState(Zp),[u,d]=Q.useState({commit:Xp,title:Zp}),[f,p]=Q.useState(!0),[m,h]=Q.useState(!1),[g,_]=Q.useState(!1),[v,y]=Q.useState(null);Q.useEffect(()=>{let e=!0;return(async()=>{try{let t=null,r=A()?.settings;if(r){let e=(await r.load())?.settings;e&&(t=e)}if(!t){let e=await l(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});e.ok&&(t=await e.json())}if(!e||!t)return;typeof t.summaryProviderID==`string`&&n(t.summaryProviderID),typeof t.summaryModelID==`string`&&i(t.summaryModelID),o(t.summaryCommitPrompt??Xp),c(t.summarySessionTitlePrompt??Zp),d({commit:t.summaryCommitPrompt??Xp,title:t.summarySessionTitlePrompt??Zp})}catch(e){console.warn(`Failed to load summary settings:`,e)}finally{e&&p(!1)}})(),()=>{e=!1}},[]);let b=He(async(t,r)=>{n(t),i(r);try{await ye({summaryModelMode:`provider`,summaryProviderID:t.trim(),summaryModelID:r.trim()})}catch(t){console.warn(`Failed to save summary model:`,t),Y.error(e(`settings.yuri.defaults.summary.saveFailed`))}}),x=He(async()=>{h(!0);try{await ye({summaryCommitPrompt:a,summarySessionTitlePrompt:s}),d({commit:a,title:s})}catch(t){console.warn(`Failed to save summary prompts:`,t),Y.error(e(`settings.yuri.defaults.summary.saveFailed`))}finally{h(!1)}}),S=He(async()=>{if(!g){y(null),_(!0);try{let n=await l(`/api/small-model/test`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({mode:`provider`,providerID:t,modelID:r})}),i=await n.json().catch(()=>null);if(n.ok&&i?.ok===!0){Y.success(e(`settings.yuri.defaults.summary.testConnectionOk`));return}let a=e(`settings.yuri.defaults.summary.testError.provider`,{code:typeof i?.code==`string`?i.code:`generation_failed`});y(typeof i?.message==`string`&&i.message.trim()?`${a}\n${i.message}`:a)}catch{y(e(`settings.yuri.defaults.summary.testError.provider`,{code:`network_error`}))}finally{_(!1)}}});if(f)return null;let C=a!==u.commit||s!==u.title;return(0,$.jsxs)(`div`,{className:`yuri-settings-section-stack`,children:[(0,$.jsx)(Z,{description:v?(0,$.jsx)(`span`,{role:`alert`,className:`whitespace-pre-wrap break-words text-[var(--status-error)]`,children:v}):void 0,children:(0,$.jsxs)(Xi,{itemId:`summary-ai.configuration`,label:e(`settings.yuri.defaults.summary.providerModel`),description:e(`settings.yuri.defaults.summary.description`),children:[(0,$.jsx)(ii,{providerId:t,modelId:r,placeholder:e(`settings.yuri.defaults.summary.providerModelDefault`),onChange:(e,t)=>void b(e,t),className:`yuri-settings-inline-value`}),(0,$.jsx)(q,{"data-settings-item":`summary-ai.test-connection`,variant:`outline`,size:`sm`,onClick:()=>void S(),disabled:g,children:e(g?`settings.yuri.defaults.summary.testingConnection`:`settings.yuri.defaults.summary.testConnection`)})]})}),(0,$.jsxs)(Z,{label:e(`settings.yuri.defaults.summary.promptTitle`),actions:(0,$.jsx)(q,{size:`sm`,onClick:()=>void x(),disabled:m||!C,"aria-busy":m,children:e(m?`settings.common.actions.saving`:`settings.yuri.defaults.summary.save`)}),children:[(0,$.jsx)(Xi,{label:e(`settings.yuri.defaults.summary.commitPrompt`),className:`yuri-settings-split-row-stacked`,controlClassName:`w-full max-w-none justify-self-stretch`,children:(0,$.jsx)(Wr,{embedded:!0,value:a,onChange:e=>o(e.target.value),"aria-label":e(`settings.yuri.defaults.summary.commitPrompt`),outerClassName:`h-64`,className:`font-mono typography-meta`})}),(0,$.jsx)(Xi,{label:e(`settings.yuri.defaults.summary.sessionTitlePrompt`),className:`yuri-settings-split-row-stacked`,controlClassName:`w-full max-w-none justify-self-stretch`,children:(0,$.jsx)(Wr,{embedded:!0,value:s,onChange:e=>c(e.target.value),"aria-label":e(`settings.yuri.defaults.summary.sessionTitlePrompt`),outerClassName:`h-64`,className:`font-mono typography-meta`})})]})]})},$p={completion:{titleKey:`settings.notifications.page.template.defaults.completion.title`,messageKey:`settings.notifications.page.template.defaults.completion.message`},error:{titleKey:`settings.notifications.page.template.defaults.error.title`,messageKey:`settings.notifications.page.template.defaults.error.message`},question:{titleKey:`settings.notifications.page.template.defaults.question.title`,messageKey:`settings.notifications.page.template.defaults.question.message`},subtask:{titleKey:`settings.notifications.page.template.defaults.subtask.title`,messageKey:`settings.notifications.page.template.defaults.subtask.message`}},em={completion:`settings.notifications.page.template.event.completion`,subtask:`settings.notifications.page.template.event.subtask`,error:`settings.notifications.page.template.event.error`,question:`settings.notifications.page.template.event.question`},tm=()=>{let{t:e}=Ge(),t=Q.useMemo(()=>h(),[]),n=Q.useMemo(()=>g(),[]),r=Q.useMemo(()=>typeof window>`u`?!1:window.Capacitor?.isNativePlatform?.()===!0||window.location.protocol===`capacitor:`,[]),i=!t&&!n&&!r,a=G(e=>e.nativeNotificationsEnabled),o=G(e=>e.setNativeNotificationsEnabled),s=G(e=>e.notificationMode),c=G(e=>e.setNotificationMode),l=G(e=>e.notifyOnSubtasks),u=G(e=>e.setNotifyOnSubtasks),d=G(e=>e.notifyOnCompletion),f=G(e=>e.setNotifyOnCompletion),p=G(e=>e.notifyOnError),m=G(e=>e.setNotifyOnError),_=G(e=>e.notifyOnQuestion),v=G(e=>e.setNotifyOnQuestion),y=G(e=>e.notifyOnPermission),b=G(e=>e.setNotifyOnPermission),x=G(e=>e.notifyOnScheduledTasks),S=G(e=>e.setNotifyOnScheduledTasks),C=G(e=>e.notifyOnAssistants),w=G(e=>e.setNotifyOnAssistants),T=G(e=>e.notifyOnGoals),E=G(e=>e.setNotifyOnGoals),D=G(e=>e.notificationTemplates),O=G(e=>e.setNotificationTemplates),[k,j]=Q.useState(`default`),[M,N]=Q.useState(!1),[P,F]=Q.useState(!1),[I,L]=Q.useState(!1);Q.useEffect(()=>{if(!i){N(!1),F(!1);return}typeof Notification<`u`&&j(Notification.permission);let e=typeof window<`u`&&`serviceWorker`in navigator&&`PushManager`in window&&`Notification`in window;N(e),(async()=>{if(!e){F(!1);return}try{let e=await navigator.serviceWorker.getRegistration();if(!e){F(!1);return}let t=await e.pushManager.getSubscription();F(!!t)}catch{F(!1)}})()},[i]);let R=async n=>{if(t){o(n);return}if(!i){o(n);return}if(n&&typeof Notification<`u`&&Notification.permission==="default")try{let t=await Notification.requestPermission();j(t),t===`granted`?o(!0):Y.error(e(`settings.notifications.page.toast.permissionDenied.title`),{description:e(`settings.notifications.page.toast.permissionDenied.description`)})}catch(t){console.error(`Failed to request notification permission:`,t),Y.error(e(`settings.notifications.page.toast.requestPermissionFailed`))}else o(!!(n&&k===`granted`))},z=t||n||r||i&&typeof Notification<`u`&&Notification.permission===`granted`,B=(e,t,n)=>{O({...D,[e]:{...D[e],[t]:n}})},V=e=>{let t=(e+`=`.repeat((4-e.length%4)%4)).replace(/-/g,`+`).replace(/_/g,`/`),n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e+=1)r[e]=n.charCodeAt(e);return r},H=async(e,t,n)=>{let r=null,i=new Promise((e,i)=>{r=setTimeout(()=>{i(Error(n))},t)});try{return await Promise.race([e,i])}finally{r&&clearTimeout(r)}},U=async e=>{if(e.active)return;let t=e.installing||e.waiting;t&&t.state!==`activated`&&await H(new Promise(e=>{let n=()=>{t.state===`activated`&&(t.removeEventListener(`statechange`,n),e())};t.addEventListener(`statechange`,n),n()}),15e3,`Service worker activation timed out`)},W=async()=>{if(typeof navigator.serviceWorker.register!=`function`)throw Error(`navigator.serviceWorker.register unavailable`);let e=[{label:`no-options`,opts:null},{label:`scope-root`,opts:{scope:`/`}},{label:`type-classic`,opts:{type:`classic`}},{label:`type-classic-scope`,opts:{type:`classic`,scope:`/`}},{label:`updateViaCache-none`,opts:{type:`classic`,updateViaCache:`none`,scope:`/`}}],t=null;for(let n of e)try{let e=n.opts?navigator.serviceWorker.register(`/sw.js`,n.opts):navigator.serviceWorker.register(`/sw.js`);return await H(e,1e4,`Service worker registration timed out (${n.label})`)}catch(e){t=e}throw t instanceof Error?t:Error(`Service worker registration failed`)},ee=async()=>{if(!(`serviceWorker`in navigator))throw Error(`Service worker not supported`);let e=await navigator.serviceWorker.getRegistration();if(e)return e;let t=await W();try{await t.update()}catch{}return await U(t),t},te=e=>{let t=e,n=[`type=${typeof e}`,`toString=${String(e)}`,`name=${String(t?.name??``)}`,`message=${String(t?.message??``)}`],r=``;try{r=JSON.stringify(e)}catch{}return{summary:n.filter(Boolean).join(` | `),json:r,stack:typeof t?.stack==`string`?t.stack:``}},ne=async()=>{let t=A();if(!t?.notifications){Y.error(e(`settings.notifications.page.toast.notificationsApiUnavailable`));return}try{await t.notifications.notifyAgentCompletion({title:e(`settings.notifications.page.testNotification.title`),body:e(`settings.notifications.page.testNotification.body`),tag:`yuri-test`})?Y.success(e(`settings.notifications.page.toast.testNotificationSent`)):Y.error(e(`settings.notifications.page.toast.testNotificationFailed`))}catch(t){console.error(`Test notification failed:`,t),Y.error(e(`settings.notifications.page.toast.testNotificationFailed`))}},re=async()=>{if(!M){Y.error(e(`settings.notifications.page.toast.pushUnsupported`));return}let t=A();if(!t?.push){Y.error(e(`settings.notifications.page.toast.pushApiUnavailable`));return}L(!0);try{if(typeof Notification<`u`&&Notification.permission==="default"){let t=await Notification.requestPermission();if(j(t),t!==`granted`){Y.error(e(`settings.notifications.page.toast.permissionDenied.title`),{description:e(`settings.notifications.page.toast.permissionDenied.enableInBrowser`)});return}}if(typeof Notification<`u`&&Notification.permission!==`granted`){Y.error(e(`settings.notifications.page.toast.permissionDenied.title`),{description:e(`settings.notifications.page.toast.permissionDenied.enableInBrowser`)});return}let n=await t.push.getVapidPublicKey();if(!n?.publicKey){Y.error(e(`settings.notifications.page.toast.pushKeyLoadFailed`));return}let r=await ee();await U(r);let i=await r.pushManager.getSubscription();if(!(`pushManager`in r)||!r.pushManager)throw Error(`PushManager unavailable (requires installed PWA + iOS 16.4+)`);let a=(i??await H(r.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:V(n.publicKey)}),15e3,`Push subscription timed out`)).toJSON(),o=a.keys;if(!a.endpoint||!o?.p256dh||!o.auth)throw Error(`Push subscription missing keys`);if(!(await H(t.push.subscribe({endpoint:a.endpoint,keys:{p256dh:o.p256dh,auth:o.auth},origin:typeof window<`u`?window.location.origin:void 0,platform:je()}),15e3,`Push subscribe request timed out`))?.ok){Y.error(e(`settings.notifications.page.toast.enableBackgroundFailed`));return}F(!0),Y.success(e(`settings.notifications.page.toast.backgroundEnabled`))}catch(t){console.error(`[Push] Enable failed:`,t);let n=te(t);Y.error(e(`settings.notifications.page.toast.enableBackgroundFailed`),{description:n.summary})}finally{L(!1)}},ie=async()=>{if(!M){F(!1);return}let t=A();if(!t?.push){Y.error(e(`settings.notifications.page.toast.pushApiUnavailable`));return}L(!0);try{let n=await(await ee()).pushManager.getSubscription();if(!n){F(!1);return}let r=n.endpoint;await n.unsubscribe(),await t.push.unsubscribe({endpoint:r}),F(!1),Y.success(e(`settings.notifications.page.toast.backgroundDisabled`))}finally{L(!1)}},ae=i?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`block`,children:e(`settings.notifications.page.delivery.browserPermissionHint`)}),k===`denied`?(0,$.jsx)(`span`,{className:`mt-1 block text-[var(--status-error)]`,children:e(`settings.notifications.page.delivery.permissionDenied`)}):null,k===`granted`&&!a?(0,$.jsx)(`span`,{className:`mt-1 block`,children:e(`settings.notifications.page.delivery.permissionGrantedButDisabled`)}):null]}):n?e(`settings.notifications.page.delivery.vscodeHint`):void 0;return(0,$.jsxs)(`div`,{className:`yuri-settings-section-stack`,children:[(0,$.jsxs)(Z,{label:e(`settings.notifications.page.delivery.title`),description:ae,className:`yuri-settings-detail-group`,children:[(0,$.jsx)(Ji,{itemId:`notifications.delivery`,checked:a&&z,onChange:e=>{R(e)},label:e(`settings.notifications.page.delivery.enableLabel`),ariaLabel:e(`settings.notifications.page.delivery.enableAria`)}),a&&z&&!r?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ji,{checked:s===`always`,onChange:e=>c(e?`always`:`hidden-only`),label:e(`settings.notifications.page.delivery.focusedLabel`),ariaLabel:e(`settings.notifications.page.delivery.focusedAria`)}),(0,$.jsx)(`div`,{className:`yuri-settings-group-row flex items-center`,children:(0,$.jsx)(q,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>void ne(),children:e(`settings.notifications.page.delivery.testAction`)})})]}):null]}),a&&z?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Z,{label:e(`settings.notifications.page.events.title`),className:`yuri-settings-detail-group`,children:[(0,$.jsx)(Ji,{itemId:`notifications.events`,checked:d,onChange:f,label:e(`settings.notifications.page.events.completionLabel`),ariaLabel:e(`settings.notifications.page.events.completionAria`)}),(0,$.jsx)(Ji,{checked:l,onChange:u,label:e(`settings.notifications.page.events.subtaskLabel`),ariaLabel:e(`settings.notifications.page.events.subtaskAria`)}),(0,$.jsx)(Ji,{checked:p,onChange:m,label:e(`settings.notifications.page.events.errorLabel`),ariaLabel:e(`settings.notifications.page.events.errorAria`)}),(0,$.jsx)(Ji,{checked:_,onChange:v,label:e(`settings.notifications.page.events.questionLabel`),ariaLabel:e(`settings.notifications.page.events.questionAria`)}),(0,$.jsx)(Ji,{checked:y,onChange:b,label:e(`settings.notifications.page.events.permissionLabel`),ariaLabel:e(`settings.notifications.page.events.permissionAria`)}),(0,$.jsx)(Ji,{checked:x,onChange:S,label:e(`settings.notifications.page.events.scheduledTasksLabel`),ariaLabel:e(`settings.notifications.page.events.scheduledTasksAria`)}),(0,$.jsx)(Ji,{checked:C,onChange:w,label:e(`settings.notifications.page.events.assistantsLabel`),ariaLabel:e(`settings.notifications.page.events.assistantsAria`)}),(0,$.jsx)(Ji,{checked:T,onChange:E,label:e(`settings.notifications.page.events.goalsLabel`),ariaLabel:e(`settings.notifications.page.events.goalsAria`)})]}),r?null:(0,$.jsx)(Z,{label:e(`settings.notifications.page.template.title`),description:(0,$.jsxs)($.Fragment,{children:[e(`settings.notifications.page.template.variablesLabel`),` `,(0,$.jsx)(`code`,{className:`text-[var(--primary-base)]`,children:`{project_name}`}),` `,(0,$.jsx)(`code`,{className:`text-[var(--primary-base)]`,children:`{worktree}`}),` `,(0,$.jsx)(`code`,{className:`text-[var(--primary-base)]`,children:`{branch}`}),` `,(0,$.jsx)(`code`,{className:`text-[var(--primary-base)]`,children:`{session_name}`}),` `,(0,$.jsx)(`code`,{className:`text-[var(--primary-base)]`,children:`{agent_name}`}),` `,(0,$.jsx)(`code`,{className:`text-[var(--primary-base)]`,children:`{model_name}`}),` `,(0,$.jsx)(`code`,{className:`text-[var(--primary-base)]`,children:`{last_message}`})]}),className:`yuri-settings-detail-group`,children:[`completion`,`subtask`,`error`,`question`].map(t=>(0,$.jsxs)(`div`,{className:`yuri-settings-group-row`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label block font-normal text-foreground`,children:e(em[t])}),(0,$.jsxs)(`div`,{className:`mt-2 grid grid-cols-1 gap-2 md:grid-cols-2 md:gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`label`,{className:`typography-micro mb-1 block text-muted-foreground`,children:e(`settings.notifications.page.template.field.title`)}),(0,$.jsx)(Cn,{value:D[t].title,onChange:e=>B(t,`title`,e.target.value),className:`w-full`,placeholder:e($p[t].titleKey)})]}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`label`,{className:`typography-micro mb-1 block text-muted-foreground`,children:e(`settings.notifications.page.template.field.message`)}),(0,$.jsx)(Cn,{value:D[t].message,onChange:e=>B(t,`message`,e.target.value),className:`w-full`,placeholder:e($p[t].messageKey)})]})]})]},t))})]}):null,i?(0,$.jsx)(Z,{label:e(`settings.notifications.page.push.title`),className:`yuri-settings-detail-group`,children:(0,$.jsx)(Ji,{itemId:`notifications.push`,checked:M?P:!1,disabled:!M||I,onChange:e=>{e?re():ie()},ariaLabel:e(`settings.notifications.page.push.enableAria`),label:(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:K(`typography-ui-label`,M?`text-foreground`:`text-muted-foreground`),children:e(`settings.notifications.page.push.enableLabel`)}),I&&(0,$.jsx)(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-current text-muted-foreground animate-busy-pulse`,"aria-label":e(`settings.notifications.page.push.loadingAria`)})]}),description:e(M?`settings.notifications.page.push.supportedHint`:`settings.notifications.page.push.unsupportedHint`)})}):null]})},nm=e=>{let t=(0,Sa.c)(45),{className:n}=e,{t:r}=Ge(),i=sr(),a=nr(),o;t[0]===i.data?.providers?o=t[1]:(o=i.data?.providers??[],t[0]=i.data?.providers,t[1]=o);let s=o,c=i.data?.selectedId??null,l=ur(i.data),u;t[2]!==s||t[3]!==c||t[4]!==a||t[5]!==r?(u=e=>{!s.some(t=>t.id===e)||e===c||a.mutate(e,{onError:()=>{Y.error(r(`settings.yuri.browserProvider.toast.selectFailed`))}})},t[2]=s,t[3]=c,t[4]=a,t[5]=r,t[6]=u):u=t[6];let d=He(u);if(!l)return null;let f;t[7]!==s||t[8]!==c?(f=s.find(e=>e.id===c)??null,t[7]=s,t[8]=c,t[9]=f):f=t[9];let p=f,m;t[10]===r?m=t[11]:(m=r(`settings.yuri.browserProvider.label`),t[10]=r,t[11]=m);let h;t[12]===r?h=t[13]:(h=r(`settings.yuri.browserProvider.info`),t[12]=r,t[13]=h);let g;t[14]===r?g=t[15]:(g=r(`settings.yuri.browserProvider.aria`),t[14]=r,t[15]=g);let _=p?.id,v=a.isPending,y;t[16]===r?y=t[17]:(y=r(`settings.yuri.browserProvider.aria`),t[16]=r,t[17]=y);let b;t[18]===r?b=t[19]:(b=r(`settings.yuri.browserProvider.placeholder`),t[18]=r,t[19]=b);let x;t[20]!==p?.name||t[21]!==r?(x=p?.name??r(`settings.yuri.browserProvider.placeholder`),t[20]=p?.name,t[21]=r,t[22]=x):x=t[22];let S;t[23]!==b||t[24]!==x?(S=(0,$.jsx)(Ar,{placeholder:b,children:x}),t[23]=b,t[24]=x,t[25]=S):S=t[25];let C;t[26]!==S||t[27]!==y?(C=(0,$.jsx)(Pr,{className:`yuri-settings-inline-value w-fit max-w-full`,"aria-label":y,children:S}),t[26]=S,t[27]=y,t[28]=C):C=t[28];let w;t[29]===s?w=t[30]:(w=s.map(rm),t[29]=s,t[30]=w);let T;t[31]===w?T=t[32]:(T=(0,$.jsx)(Nr,{children:w}),t[31]=w,t[32]=T);let E;t[33]!==d||t[34]!==a.isPending||t[35]!==C||t[36]!==T||t[37]!==_?(E=(0,$.jsxs)(Fr,{value:_,onValueChange:d,disabled:v,children:[C,T]}),t[33]=d,t[34]=a.isPending,t[35]=C,t[36]=T,t[37]=_,t[38]=E):E=t[38];let D;return t[39]!==n||t[40]!==E||t[41]!==m||t[42]!==h||t[43]!==g?(D=(0,$.jsx)(Ui,{itemId:`sessions.browser-provider`,label:m,description:h,descriptionPlacement:`outside`,groupClassName:n,ariaLabel:g,children:E}),t[39]=n,t[40]=E,t[41]=m,t[42]=h,t[43]=g,t[44]=D):D=t[44],D};function rm(e){return(0,$.jsx)(jr,{value:e.id,children:e.name},e.id)}var im=()=>{let{t:e}=Ge(),[t,n]=Q.useState(``),[r,i]=Q.useState(!0),[a,o]=Q.useState(!1),s=G(e=>e.showOpenCodeUpdateNotifications),c=G(e=>e.setShowOpenCodeUpdateNotifications);Q.useEffect(()=>{let e=!1;return(async()=>{try{let t=await l(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});if(!t.ok)return;let r=await t.json().catch(()=>null);if(e||!r)return;let i=typeof r.opencodeBinary==`string`?r.opencodeBinary.trim():``;n(i)}catch{}finally{e||i(!1)}})(),()=>{e=!0}},[]);let u=Q.useCallback(async()=>{if(!(typeof window>`u`)&&h())try{let e=await f();e.success&&e.path&&e.path.trim().length>0&&n(e.path.trim())}catch{}},[]),d=Q.useCallback(async()=>{o(!0);try{let n=t.trim(),r=n.length>=2&&(n.startsWith(`"`)&&n.endsWith(`"`)||n.startsWith(`'`)&&n.endsWith(`'`))?n.slice(1,-1).trim():n;await ye({opencodeBinary:r}),await Ct({message:e(`settings.yuri.opencodeCli.actions.restartingOpenCode`),mode:`projects`,scopes:[`all`]})}finally{o(!1)}},[e,t]),p=Q.useCallback(e=>{c(e),ye({showOpenCodeUpdateNotifications:e})},[c]);return(0,$.jsxs)(Z,{actions:(0,$.jsx)(q,{type:`button`,size:`sm`,onClick:d,disabled:r||a,"aria-busy":a,children:e(a?`settings.common.actions.saving`:`settings.yuri.opencodeCli.actions.saveAndReload`)}),label:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{children:e(`settings.yuri.opencodeCli.title`)}),(0,$.jsxs)(En,{children:[(0,$.jsx)(wn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 cursor-help text-muted-foreground/60`})}),(0,$.jsxs)(Tn,{sideOffset:8,className:`max-w-xs`,children:[e(`settings.yuri.opencodeCli.tooltipPrefix`),` `,(0,$.jsx)(`code`,{className:`font-mono text-xs`,children:`opencode`}),e(`settings.yuri.opencodeCli.tooltipSuffix`)]})]})]}),description:(0,$.jsxs)($.Fragment,{children:[e(`settings.yuri.opencodeCli.tipPrefix`),` `,(0,$.jsx)(`span`,{className:`font-mono`,children:`OPENCODE_BINARY`}),` `,e(`settings.yuri.opencodeCli.tipMiddle`),` `,(0,$.jsx)(`span`,{className:`font-mono`,children:`~/.config/yuri/settings.json`}),`.`]}),children:[(0,$.jsx)(Xi,{itemId:`sessions.opencode-binary`,label:e(`settings.yuri.opencodeCli.field.binaryPath`),children:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center justify-end gap-2`,children:[(0,$.jsx)(Cn,{value:t,onChange:e=>n(e.target.value),placeholder:e(`settings.yuri.opencodeCli.field.binaryPathPlaceholder`),disabled:r||a,className:`h-7 min-w-0 flex-1 font-mono text-xs`}),(0,$.jsx)(q,{type:`button`,variant:`outline`,size:`xs`,onClick:u,disabled:r||a||!h(),className:`h-7 w-7 p-0`,"aria-label":e(`settings.yuri.opencodeCli.actions.browseAria`),title:e(`settings.yuri.opencodeCli.actions.browse`),children:(0,$.jsx)(X,{name:`folder`,className:`h-4 w-4`})})]})}),(0,$.jsxs)(`div`,{"data-settings-item":`sessions.opencode-update-notifications`,className:`yuri-settings-group-row yuri-settings-split-row`,children:[(0,$.jsx)(`div`,{className:`yuri-settings-split-row-copy`,children:(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.yuri.opencodeCli.field.showUpdateNotifications`)})}),(0,$.jsx)(`div`,{className:`yuri-settings-split-row-control`,children:(0,$.jsx)(Wi,{checked:s,onChange:p,ariaLabel:e(`settings.yuri.opencodeCli.field.showUpdateNotificationsAria`)})})]})]})},am=[{id:`auto`,labelKey:`settings.yuri.desktopNetwork.option.windowControlsAuto`},{id:`left`,labelKey:`settings.yuri.desktopNetwork.option.windowControlsLeft`},{id:`right`,labelKey:`settings.yuri.desktopNetwork.option.windowControlsRight`}],om=()=>{let{t:e}=Ge(),t=Q.useCallback(t=>e(t),[e]),n=h()&&O(),r=w(),i=G(e=>e.desktopWindowControlsPosition),a=G(e=>e.setDesktopWindowControlsPosition),[o,s]=Q.useState(!1),[c,l]=Q.useState(!1),[u,d]=Q.useState(!1),[f,m]=Q.useState(!1),[g,b]=Q.useState(!1),[x,T]=Q.useState(!1),[E,D]=Q.useState(!1),[k,A]=Q.useState(!1),[j,M]=Q.useState(!1),[N,P]=Q.useState(null);Q.useEffect(()=>{if(!n){s(!1);return}let e=!1;return(async()=>{let t=await C();e||(s(t?.supported===!0),l(t?.enabled===!0))})(),()=>{e=!0}},[n]),Q.useEffect(()=>{if(!n){m(!1);return}let e=!1;return(async()=>{let t=await S();e||(m(t?.supported===!0),b(t?.enabled===!0))})(),()=>{e=!0}},[n]),Q.useEffect(()=>{if(!n){D(!1);return}let e=!1;return(async()=>{let t=await y();e||(D(t?.supported===!0),A(t?.enabled===!0))})(),()=>{e=!0}},[n]);let F=Q.useCallback(e=>{a(e),ye({desktopWindowControlsPosition:e})},[a]),I=Q.useCallback(async()=>{if(!o||u)return;let t=!c;l(t),d(!0),P(null);try{let n=await p(t);if(!n?.supported)throw Error(e(`settings.yuri.desktopNetwork.error.launchAtLoginUnsupported`));l(n.enabled)}catch(n){l(!t),P(n instanceof Error?n.message:e(`settings.yuri.desktopNetwork.error.launchAtLoginSaveFailed`))}finally{d(!1)}},[u,c,o,e]),L=Q.useCallback(async()=>{if(!f||x)return;let t=!g;b(t),T(!0),P(null);try{let n=await _(t);if(!n)throw Error(e(`settings.yuri.desktopNetwork.error.minimizeToTraySaveFailed`));if(!n.supported)throw Error(e(`settings.yuri.desktopNetwork.error.minimizeToTrayUnsupported`));b(n.enabled)}catch(n){b(!t),P(n instanceof Error?n.message:e(`settings.yuri.desktopNetwork.error.minimizeToTraySaveFailed`))}finally{T(!1)}},[x,g,f,e]),R=Q.useCallback(async()=>{if(!E||j)return;let t=!k;A(t),M(!0),P(null);try{let n=await v(t);if(!n?.supported)throw Error(e(`settings.yuri.desktopNetwork.error.keepAwakeUnsupported`));A(n.enabled)}catch(n){A(!t),P(n instanceof Error?n.message:e(`settings.yuri.desktopNetwork.error.keepAwakeSaveFailed`))}finally{M(!1)}},[j,k,E,e]);return!n&&!r?null:(0,$.jsxs)(`div`,{className:`yuri-settings-section-stack`,children:[r?(0,$.jsx)(Z,{label:e(`settings.yuri.desktopNetwork.field.windowControlsPosition`),children:(0,$.jsx)(Xi,{itemId:`sessions.desktop-window-controls-position`,label:e(`settings.yuri.desktopNetwork.field.windowControlsPosition`),description:e(`settings.yuri.desktopNetwork.field.windowControlsPositionDescription`),children:(0,$.jsx)(`div`,{className:`flex flex-wrap items-center justify-end gap-1`,role:`group`,"aria-label":e(`settings.yuri.desktopNetwork.field.windowControlsPositionAria`),children:am.map(e=>(0,$.jsx)(q,{type:`button`,variant:`chip`,size:`xs`,className:`!font-normal`,"aria-pressed":i===e.id,onClick:()=>F(e.id),children:t(e.labelKey)},e.id))})})}):null,!n||!(o||f||E||N)?null:(0,$.jsxs)(Z,{label:e(`settings.yuri.desktopNetwork.title`),children:[o?(0,$.jsxs)(`div`,{"data-settings-item":`sessions.desktop-launch-at-login`,className:`yuri-settings-group-row yuri-settings-split-row group cursor-pointer`,role:`button`,tabIndex:0,onClick:I,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),I())},children:[(0,$.jsxs)(`div`,{className:`yuri-settings-split-row-copy`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:e(`settings.yuri.desktopNetwork.field.launchAtLogin`)}),(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:e(`settings.yuri.desktopNetwork.field.launchAtLoginDescription`)})]}),(0,$.jsx)(`div`,{className:`yuri-settings-split-row-control`,children:(0,$.jsx)(Wi,{checked:c,onChange:I,ariaLabel:e(`settings.yuri.desktopNetwork.field.launchAtLoginAria`),disabled:u})})]}):null,f?(0,$.jsxs)(`div`,{"data-settings-item":`sessions.desktop-minimize-to-tray`,className:`yuri-settings-group-row yuri-settings-split-row group cursor-pointer`,role:`button`,tabIndex:0,onClick:L,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),L())},children:[(0,$.jsxs)(`div`,{className:`yuri-settings-split-row-copy`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:e(`settings.yuri.desktopNetwork.field.minimizeToTray`)}),(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:e(`settings.yuri.desktopNetwork.field.minimizeToTrayDescription`)})]}),(0,$.jsx)(`div`,{className:`yuri-settings-split-row-control`,children:(0,$.jsx)(Wi,{checked:g,onChange:L,ariaLabel:e(`settings.yuri.desktopNetwork.field.minimizeToTrayAria`),disabled:x})})]}):null,E?(0,$.jsxs)(`div`,{"data-settings-item":`sessions.desktop-keep-awake`,className:`yuri-settings-group-row yuri-settings-split-row group cursor-pointer`,role:`button`,tabIndex:0,onClick:R,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),R())},children:[(0,$.jsxs)(`div`,{className:`yuri-settings-split-row-copy`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:e(`settings.yuri.desktopNetwork.field.keepAwake`)}),(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:e(`settings.yuri.desktopNetwork.field.keepAwakeDescription`)})]}),(0,$.jsx)(`div`,{className:`yuri-settings-split-row-control`,children:(0,$.jsx)(Wi,{checked:k,onChange:R,ariaLabel:e(`settings.yuri.desktopNetwork.field.keepAwakeAria`),disabled:j})})]}):null,N?(0,$.jsx)(`div`,{className:`yuri-settings-group-row typography-meta text-[var(--status-error)]`,children:N}):null]})]})},sm=new Set([`shift`,`control`,`alt`,`meta`]),cm=e=>{if(sm.has(e.key.toLowerCase()))return null;let t=[];(e.metaKey||e.ctrlKey)&&t.push(`mod`),e.shiftKey&&t.push(`shift`),e.altKey&&t.push(`alt`);let n=mr(e.key);return n?(t.push(n),dr(t.join(`+`))):null},lm=()=>{let e=(0,Sa.c)(59),{t}=Ge(),n;e[0]===t?n=e[1]:(n=e=>t(e),e[0]=t,e[1]=n);let r=n,i=G(um),a=G(dm),o=G(fm),s=G(pm),c;if(e[2]===Symbol.for(`react.memo_cache_sentinel`)){bb0:{let e=vr();if(!g()){c=e;break bb0}c=e.filter(mm)}e[2]=c}else c=e[2];let l=c,u;e[3]===r?u=e[4]:(u=(e,t)=>{let n=`settings.yuri.keyboardShortcuts.action.${e}.label`,i=r(n);return i===n?t:i},e[3]=r,e[4]=u);let d=u,[f,p]=Q.useState(null),m;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(m={},e[5]=m):m=e[5];let[h,_]=Q.useState(m),[v,y]=Q.useState(``),[b,x]=Q.useState(``),[S,C]=Q.useState(null),w=hm,T;e[6]===i?T=e[7]:(T=(e,t)=>{let n=dr(t);for(let t of l){if(t.id===e)continue;let r=rr(t.id,i);if(dr(r)===n)return t.id}return null},e[6]=i,e[7]=T);let E=T,D;e[8]!==E||e[9]!==a||e[10]!==i||e[11]!==t?(D=(e,n)=>{let r=dr(n),o=E(e,r);if(o){C({actionId:e,combo:r,conflictActionId:o}),y(``);return}let s={...i,[e]:r};a(e,r),w(s),C(null),y(``),x(ar(r)?t(`settings.yuri.keyboardShortcuts.warning.riskyBrowserShortcut`):``),_(t=>{let n={...t};return delete n[e],n})},e[8]=E,e[9]=a,e[10]=i,e[11]=t,e[12]=D):D=e[12];let O=D,k;e[13]!==S||e[14]!==a||e[15]!==i||e[16]!==t?(k=()=>{if(!S)return;let e={...i,[S.conflictActionId]:_r,[S.actionId]:S.combo};a(S.conflictActionId,_r),a(S.actionId,S.combo),w(e),C(null),y(``),x(ar(S.combo)?t(`settings.yuri.keyboardShortcuts.warning.riskyBrowserShortcut`):``),_(e=>{let t={...e};return delete t[S.actionId],t})},e[13]=S,e[14]=a,e[15]=i,e[16]=t,e[17]=k):k=e[17];let A=k,j;e[18]!==o||e[19]!==i?(j=e=>{let t={...i};delete t[e],o(e),w(t),_(t=>{let n={...t};return delete n[e],n}),C(null),y(``),x(``)},e[18]=o,e[19]=i,e[20]=j):j=e[20];let M=j,N;e[21]===t?N=e[22]:(N=t(`settings.yuri.keyboardShortcuts.title`),e[21]=t,e[22]=N);let P;e[23]===N?P=e[24]:(P=(0,$.jsx)(`span`,{children:N}),e[23]=N,e[24]=P);let F;e[25]===s?F=e[26]:(F=()=>{s(),w({}),_({}),C(null),y(``),x(``)},e[25]=s,e[26]=F);let I;e[27]===t?I=e[28]:(I=t(`settings.yuri.keyboardShortcuts.actions.resetAll`),e[27]=t,e[28]=I);let L;e[29]!==F||e[30]!==I?(L=(0,$.jsx)(q,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:F,children:I}),e[29]=F,e[30]=I,e[31]=L):L=e[31];let R;e[32]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,$.jsx)(wn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),e[32]=R):R=e[32];let z;e[33]===t?z=e[34]:(z=t(`settings.yuri.keyboardShortcuts.tooltip`),e[33]=t,e[34]=z);let B;e[35]===z?B=e[36]:(B=(0,$.jsxs)(En,{children:[R,(0,$.jsx)(Tn,{sideOffset:8,className:`max-w-xs`,children:z})]}),e[35]=z,e[36]=B);let V;e[37]!==L||e[38]!==B||e[39]!==P?(V=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[P,L,B]}),e[37]=L,e[38]=B,e[39]=P,e[40]=V):V=e[40];let H;e[41]!==A||e[42]!==v||e[43]!==S||e[44]!==t||e[45]!==b?(H=(v||b||S)&&(0,$.jsxs)(`div`,{className:`mb-2 space-y-2 px-1`,children:[S&&(0,$.jsxs)(`div`,{className:`rounded-lg border border-[var(--status-warning-border)] bg-[var(--status-warning-background)] p-3 flex flex-col sm:flex-row sm:items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`typography-meta text-foreground`,children:t(`settings.yuri.keyboardShortcuts.overwritePrompt`)}),(0,$.jsxs)(`div`,{className:`flex gap-2 shrink-0`,children:[(0,$.jsx)(q,{type:`button`,size:`xs`,className:`!font-normal`,onClick:A,children:t(`settings.yuri.keyboardShortcuts.actions.overwrite`)}),(0,$.jsx)(q,{type:`button`,size:`xs`,className:`!font-normal`,variant:`ghost`,onClick:()=>C(null),children:t(`settings.common.actions.cancel`)})]})]}),v&&(0,$.jsx)(`div`,{className:`rounded-lg border border-[var(--status-error-border)] bg-[var(--status-error-background)] p-3 typography-meta text-foreground`,children:v}),b&&(0,$.jsx)(`div`,{className:`rounded-lg border border-[var(--status-warning-border)] bg-[var(--status-warning-background)] p-3 typography-meta text-foreground`,children:b})]}),e[41]=A,e[42]=v,e[43]=S,e[44]=t,e[45]=b,e[46]=H):H=e[46];let U;e[47]!==d||e[48]!==f||e[49]!==h||e[50]!==M||e[51]!==O||e[52]!==i||e[53]!==t?(U=l.map(e=>{let n=rr(e.id,i),r=h[e.id],a=r??n,o=typeof r==`string`&&dr(r)!==dr(n);return(0,$.jsxs)(Xi,{label:d(e.id,e.label),children:[(0,$.jsx)(Cn,{readOnly:!0,value:f===e.id?t(`settings.yuri.keyboardShortcuts.field.pressKeys`):pr(a),onFocus:()=>{p(e.id),y(``)},onBlur:()=>{f===e.id&&p(null)},onKeyDown:t=>{if(t.preventDefault(),t.stopPropagation(),t.key===`Escape`){p(null);return}let n=cm(t);n&&(_(t=>({...t,[e.id]:n})),p(null),C(null),y(``))},className:`w-40 min-w-0 typography-ui-label text-right`}),(0,$.jsx)(q,{type:`button`,variant:`secondary`,size:`xs`,className:`!font-normal`,onClick:()=>{let n=h[e.id];if(!n){y(t(`settings.yuri.keyboardShortcuts.error.captureFirst`));return}O(e.id,n)},disabled:!o,children:t(`settings.common.actions.saveChanges`)}),(0,$.jsx)(q,{type:`button`,size:`xs`,className:`!font-normal`,variant:`ghost`,onClick:()=>M(e.id),children:t(`settings.common.actions.reset`)})]},e.id)}),e[47]=d,e[48]=f,e[49]=h,e[50]=M,e[51]=O,e[52]=i,e[53]=t,e[54]=U):U=e[54];let W;return e[55]!==V||e[56]!==H||e[57]!==U?(W=(0,$.jsxs)(Z,{itemId:`shortcuts.keyboard-shortcuts`,label:V,children:[H,U]}),e[55]=V,e[56]=H,e[57]=U,e[58]=W):W=e[58],W};function um(e){return e.shortcutOverrides}function dm(e){return e.setShortcutOverride}function fm(e){return e.clearShortcutOverride}function pm(e){return e.resetAllShortcutOverrides}function mm(e){return e.id!==`toggle_prompt_navigator`}function hm(e){ye({shortcutOverrides:e})}var gm=()=>{let e=(0,Sa.c)(2),[t,n]=Q.useState(0),i,a;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=()=>r(()=>n(Em)),a=[],e[0]=i,e[1]=a):(i=e[0],a=e[1]),Q.useEffect(i,a),t},_m=e=>{let t=(0,Sa.c)(25),{section:n,flowMobile:r}=e,i=r!==void 0&&r,{isMobile:a}=wr();gm();let o;t[0]===a?o=t[1]:(o=a&&d(),t[0]=a,t[1]=o);let s=o,c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=g(),t[2]=c):c=t[2];let l=c,u;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(u=h()&&(O()||w()),t[3]=u):u=t[3];let f=u;if(!n){let e;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Op,{}),t[4]=e):e=t[4];let n;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`div`,{className:`yuri-settings-page-section`,children:(0,$.jsx)(Yp,{})}),t[5]=n):n=t[5];let r,i,a,o;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(`div`,{className:`yuri-settings-page-section`,children:(0,$.jsx)(Qp,{})}),a=f&&(0,$.jsx)(`div`,{className:`yuri-settings-page-section`,children:(0,$.jsx)(om,{})}),o=!l&&(0,$.jsx)(`div`,{className:`yuri-settings-page-section`,children:(0,$.jsx)(im,{})}),r=(0,$.jsx)(nm,{className:`yuri-settings-page-section`}),t[6]=r,t[7]=i,t[8]=a,t[9]=o):(r=t[6],i=t[7],a=t[8],o=t[9]);let c;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(`div`,{className:`yuri-settings-page-section`,children:(0,$.jsx)(zp,{})}),t[10]=c):c=t[10];let u;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(`div`,{className:`yuri-settings-page-section`,children:(0,$.jsx)(qp,{})}),t[11]=u):u=t[11];let d;t[12]===s?d=t[13]:(d=s&&(0,$.jsx)(`div`,{className:`yuri-settings-page-section`,children:(0,$.jsx)(Aa,{})}),t[12]=s,t[13]=d);let p;return t[14]===d?p=t[15]:(p=(0,$.jsx)(Ur,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`yuri-settings-page-content yuri-page-body mx-auto max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[e,n,i,a,o,r,c,u,d]})}),t[14]=d,t[15]=p),p}let p;t[16]!==i||t[17]!==n?(p=()=>{switch(n){case`visual`:return(0,$.jsx)(ym,{mobile:i});case`chat`:return(0,$.jsx)(bm,{});case`sessions`:return(0,$.jsx)(xm,{});case`summary-ai`:return(0,$.jsx)(Qp,{});case`shortcuts`:return(0,$.jsx)(vm,{});case`git`:return(0,$.jsx)(Sm,{});case`github`:return(0,$.jsx)(Cm,{});case`notifications`:return(0,$.jsx)(wm,{});case`voice`:return(0,$.jsx)(Tm,{});default:return null}},t[16]=i,t[17]=n,t[18]=p):p=t[18];let m=p,_;t[19]===m?_=t[20]:(_=m(),t[19]=m,t[20]=_);let v;t[21]===_?v=t[22]:(v=(0,$.jsx)(`div`,{className:`yuri-settings-page-content yuri-page-body mx-auto max-w-3xl p-3 sm:p-6 sm:pt-8`,children:_}),t[21]=_,t[22]=v);let y=v;if(i)return y;let b;return t[23]===y?b=t[24]:(b=(0,$.jsx)(Ur,{outerClassName:`h-full`,className:`w-full`,children:y}),t[23]=y,t[24]=b),b},vm=()=>{let e=(0,Sa.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(lm,{}),e[0]=t):t=e[0],t},ym=e=>{let t=(0,Sa.c)(5),{mobile:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=g(),t[0]=r):r=t[0];let i=r,a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=i?[]:[`weekStart`],t[1]=a):a=t[1];let o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=[`theme`,`sidebarBrand`,`pwaInstallName`,`pwaOrientation`,`mobileKeyboardMode`,`timeFormat`,...a,`iosNativeUi`,`fontSize`,`codeFontSize`,`terminalFontSize`,`editorFontSize`,`fileEditorKeymap`,`spacing`,`inputBarOffset`,...i?[]:[`terminalQuickKeys`],`reportUsage`],t[2]=o):o=t[2];let s;return t[3]===n?s=t[4]:(s=(0,$.jsx)(Op,{mobile:n,visibleSettings:o}),t[3]=n,t[4]=s),s},bm=()=>{let e=(0,Sa.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(Op,{visibleSettings:[`chatRenderMode`,`messageTransport`,`diffLayout`,`followUpBehavior`,`sessionGoal`,`questionAutoDelegate`,`sessionAssist`,`subagentReadOnlyBanner`,`reasoning`,`collapsibleUserMessages`,`showAssistantTps`,`persistDraft`,`inputSpellcheck`]}),e[0]=t):t=e[0],t},xm=()=>{let e=(0,Sa.c)(8),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=g(),e[0]=t):t=e[0];let n=t;gm();let r;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=h()&&(O()||w()),e[1]=r):r=e[1];let i=r,a,o,s,c;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(Yp,{}),o=i&&(0,$.jsx)(`div`,{className:`yuri-settings-page-section`,children:(0,$.jsx)(om,{})}),s=!n&&(0,$.jsx)(`div`,{className:`yuri-settings-page-section`,children:(0,$.jsx)(im,{})}),c=(0,$.jsx)(nm,{}),e[2]=a,e[3]=o,e[4]=s,e[5]=c):(a=e[2],o=e[3],s=e[4],c=e[5]);let l;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(`div`,{className:`yuri-settings-page-section`,children:(0,$.jsx)(zp,{})}),e[6]=l):l=e[6];let u;return e[7]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsxs)(`div`,{className:`yuri-settings-section-stack`,children:[a,o,s,c,l,(0,$.jsx)(`div`,{className:`yuri-settings-page-section`,children:(0,$.jsx)(qp,{})})]}),e[7]=u):u=e[7],u},Sm=()=>{let e=(0,Sa.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:`yuri-settings-section-stack`,children:(0,$.jsx)(ep,{})}),e[0]=t):t=e[0],t},Cm=()=>{let e=(0,Sa.c)(1);if(g())return null;let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(tp,{}),e[0]=t):t=e[0],t},wm=()=>{let e=(0,Sa.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(tm,{}),e[0]=t):t=e[0],t},Tm=()=>{let e=(0,Sa.c)(1);if(g())return null;let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(ga,{}),e[0]=t):t=e[0],t};function Em(e){return e+1}var Dm=()=>{let e=(0,Sa.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(jl,{children:(0,$.jsx)(yi,{mode:`page`})}),e[0]=t):t=e[0],t};function Om(){let e=(0,Sa.c)(11),t=Hi().data?.entries,n;e[0]===t?n=e[1]:(n=t?.map(km)??[],e[0]=t,e[1]=n);let r=Yi(n),i=Qi(),a;e[2]===t?a=e[3]:(a=t??[],e[2]=t,e[3]=a);let o;if(e[4]!==r||e[5]!==i||e[6]!==a){let t;e[8]!==r||e[9]!==i?(t=e=>{let t=r.data?.[e.spec];if(t?.kind===`npm-ok`&&t.hasUpdate)return!0;let n=oi(e.spec,e.sourcePath);return n?.kind===`package`&&i.data!==void 0&&Ni(Qr(n,i.data))===`available`},e[8]=r,e[9]=i,e[10]=t):t=e[10],o=a.some(t),e[4]=r,e[5]=i,e[6]=a,e[7]=o}else o=e[7];return o}function km(e){return e.spec}var Am=[{id:`remote-instances.remote-desktop`,page:`remote-instances`,titleKey:`settings.remoteDesktop.enable`,descriptionKey:`settings.remoteDesktop.description`,keywords:[`remote desktop`,`screen sharing`,`control`,`远程桌面`,`投屏`],isAvailable:e=>e.isDesktopLocalOrigin},{id:`remote-instances.remote-desktop-screen`,page:`remote-instances`,titleKey:`settings.remoteDesktop.screen`,descriptionKey:`settings.remoteDesktop.screenHint`,keywords:[`permission`,`screen recording`,`屏幕录制`,`权限`],isAvailable:e=>e.isDesktopLocalOrigin&&e.isMac},{id:`remote-instances.remote-desktop-accessibility`,page:`remote-instances`,titleKey:`settings.remoteDesktop.accessibility`,descriptionKey:`settings.remoteDesktop.accessibilityHint`,keywords:[`permission`,`accessibility`,`input`,`辅助功能`],isAvailable:e=>e.isDesktopLocalOrigin&&e.isMac},{id:`chat.question-auto-delegate`,page:`chat`,titleKey:`settings.chat.questionDelegate.label`,descriptionKey:`settings.chat.questionDelegate.description`,keywords:[`question`,`auto`,`delegate`,`30`,`subagent`,`托管`,`倒计时`]},{id:`instances.manage`,page:`instances`,titleKey:`mobile.settings.switchInstance`,keywords:[`instance`,`server`,`connection`,`switch`],isAvailable:e=>e.isMobile},{id:`global-config.editor`,page:`global-config`,titleKey:`settings.globalConfig.title`,descriptionKey:`settings.globalConfig.description`,keywords:[`opencode.json`,`opencode.jsonc`,`json`,`jsonc`]},{id:`appearance.language`,page:`appearance`,titleKey:`settings.appearance.language.label`,descriptionKey:`settings.appearance.language.description`,keywords:[`locale`,`translation`,`ui language`]},{id:`appearance.time-format`,page:`appearance`,titleKey:`settings.yuri.visual.field.timeFormat`,keywords:[`clock`,`12h`,`24h`]},{id:`appearance.week-start`,page:`appearance`,titleKey:`settings.yuri.visual.field.weekStartsOn`,keywords:[`calendar`,`monday`,`sunday`],isAvailable:e=>!e.isVSCode},{id:`appearance.light-theme`,page:`appearance`,titleKey:`settings.yuri.visual.field.lightTheme`,keywords:[`theme`,`color`,`light mode`],isAvailable:e=>!e.isVSCode},{id:`appearance.dark-theme`,page:`appearance`,titleKey:`settings.yuri.visual.field.darkTheme`,keywords:[`theme`,`color`,`dark mode`],isAvailable:e=>!e.isVSCode},{id:`appearance.window-transparency`,page:`appearance`,titleKey:`settings.yuri.visual.field.macVibrancy`,descriptionKey:`settings.yuri.visual.field.macVibrancyHint`,keywords:[`transparent`,`transparency`,`vibrancy`,`blur`,`macos`,`opaque`],isAvailable:e=>e.isDesktopLocalOrigin},{id:`appearance.dock-badge`,page:`appearance`,titleKey:`settings.yuri.visual.field.dockBadge`,descriptionKey:`settings.yuri.visual.field.dockBadgeHint`,keywords:[`dock`,`badge`,`unread`,`unseen`,`counter`,`count`,`notification`,`macos`],isAvailable:e=>e.isMac},{id:`appearance.sidebar-brand`,page:`appearance`,titleKey:`settings.yuri.visual.field.sidebarBrand`,descriptionKey:`settings.yuri.visual.field.sidebarBrandHint`,keywords:[`logo`,`brand`,`wordmark`,`sidebar`]},{id:`appearance.pwa-install-name`,page:`appearance`,titleKey:`settings.yuri.visual.field.installAppName`,descriptionKey:`settings.yuri.visual.field.installAppNameHint`,keywords:[`pwa`,`installed app`],isAvailable:e=>e.isWeb&&!e.isDesktop&&!e.isVSCode},{id:`appearance.pwa-orientation`,page:`appearance`,titleKey:`settings.yuri.visual.field.installOrientation`,descriptionKey:`settings.yuri.visual.field.installOrientationHint`,keywords:[`pwa`,`portrait`,`landscape`],isAvailable:e=>e.isWeb&&!e.isDesktop&&!e.isVSCode},{id:`appearance.mobile-keyboard-mode`,page:`appearance`,titleKey:`settings.yuri.visual.field.mobileKeyboardMode`,descriptionKey:`settings.yuri.visual.field.mobileKeyboardModeHint`,keywords:[`mobile`,`keyboard`,`resize`],isAvailable:e=>e.isMobile&&e.isWeb&&!e.isDesktop&&!e.isVSCode},{id:`appearance.ios-native-ui`,page:`appearance`,titleKey:`settings.yuri.visual.field.iosNativeUi`,descriptionKey:`settings.yuri.visual.field.iosNativeUiHint`,keywords:[`ios`,`native`,`webview`,`composer`,`tab bar`,`live activity`],isAvailable:()=>Lr()},{id:`appearance.interface-font-size`,page:`appearance`,titleKey:`settings.yuri.visual.field.interfaceFontSize`,keywords:[`font`,`text size`,`ui scale`]},{id:`appearance.code-font-size`,page:`appearance`,titleKey:`settings.yuri.visual.field.codeFontSize`,keywords:[`code`,`font`,`text size`,`diff`]},{id:`appearance.terminal-font-size`,page:`appearance`,titleKey:`settings.yuri.visual.field.terminalFontSize`,keywords:[`terminal`,`font`,`text size`]},{id:`appearance.editor-font-size`,page:`appearance`,titleKey:`settings.yuri.visual.field.editorFontSize`,keywords:[`editor`,`font`,`text size`,`code`]},{id:`appearance.spacing-density`,page:`appearance`,titleKey:`settings.yuri.visual.field.spacingDensity`,keywords:[`density`,`compact`,`comfortable`,`spacing`]},{id:`appearance.input-bar-offset`,page:`appearance`,titleKey:`settings.yuri.visual.field.inputBarOffset`,descriptionKey:`settings.yuri.visual.field.inputBarOffsetTooltip`,keywords:[`input`,`home bar`,`offset`]},{id:`appearance.file-editor-keymap`,page:`appearance`,titleKey:`settings.yuri.visual.field.fileEditorKeymap`,keywords:[`editor`,`vim`,`keymap`]},{id:`appearance.terminal-quick-keys`,page:`appearance`,titleKey:`settings.yuri.visual.field.terminalQuickKeys`,descriptionKey:`settings.yuri.visual.field.terminalQuickKeysTooltip`,keywords:[`terminal`,`keyboard`,`esc`,`ctrl`,`arrows`],isAvailable:e=>!e.isMobile&&!e.isDesktop&&!e.isVSCode},{id:`about.check-updates`,page:`about`,titleKey:`settings.yuri.about.actions.checkForUpdates`,keywords:[`updates`,`version`,`ota`]},{id:`about.host-update`,page:`about`,titleKey:`settings.yuri.about.hostUpdate.title`,descriptionKey:`settings.yuri.about.hostUpdate.description`,keywords:[`remote`,`host`,`relay`,`beta`,`ota`,`version`],isAvailable:e=>!e.isDesktopLocalOrigin},{id:`about.feedback`,page:`about`,titleKey:`settings.yuri.about.actions.submitFeedback`,keywords:[`feedback`,`issues`,`bugs`,`github`]},{id:`about.beta-updates`,page:`about`,titleKey:`settings.yuri.about.betaUpdates.label`,descriptionKey:`settings.yuri.about.betaUpdates.description`,keywords:[`beta`,`updates`,`channel`,`ota`],isAvailable:e=>e.isDesktop||Ae()},{id:`about.diagnostics`,page:`about`,titleKey:`settings.yuri.about.diagnostics.label`,keywords:[`diagnostics`,`logs`,`feat`,`transcript`,`task`]},{id:`about.export-diagnostics`,page:`about`,titleKey:`settings.yuri.about.diagnostics.export`,keywords:[`diagnostics`,`logs`,`export`,`feat`,`transcript`,`task`],isAvailable:()=>Zt()},{id:`appearance.usage-reports`,page:`appearance`,titleKey:`settings.yuri.visual.field.sendAnonymousUsageReports`,descriptionKey:`settings.yuri.visual.field.sendAnonymousUsageReportsHint`,keywords:[`telemetry`,`analytics`]},{id:`appearance.transcript-cache`,page:`appearance`,titleKey:`settings.yuri.visual.transcriptCache.label`,descriptionKey:`settings.yuri.visual.transcriptCache.description`,keywords:[`cache`,`local data`,`conversation history`,`transcript`,`privacy`]},{id:`chat.render-mode`,page:`chat`,titleKey:`settings.yuri.visual.section.chatRenderMode`,keywords:[`messages`,`conversation`,`rendering`]},{id:`chat.message-transport`,page:`chat`,titleKey:`settings.yuri.visual.section.messageStreamTransport`,keywords:[`streaming`,`sse`,`websocket`]},{id:`chat.session-assistance`,page:`chat`,titleKey:`settings.yuri.visual.section.sessionAssistance`,keywords:[`title`,`assist`,`subagent`]},{id:`chat.session-title-refresh`,page:`chat`,titleKey:`settings.yuri.visual.field.sessionTitleRefresh`,keywords:[`title`,`rename`,`refresh`,`throttle`,`small model`,`summary`]},{id:`chat.session-goal`,page:`chat`,titleKey:`settings.yuri.visual.field.sessionGoal`,keywords:[`goal`,`objective`,`auto continue`]},{id:`chat.reasoning-traces`,page:`chat`,titleKey:`settings.yuri.visual.field.showReasoningTraces`,descriptionKey:`settings.yuri.visual.field.showReasoningTracesHint`,keywords:[`thinking`,`reasoning`,`mobile`,`fetch time`]},{id:`chat.reasoning`,page:`chat`,titleKey:`settings.yuri.visual.section.reasoning`,keywords:[`thinking`,`traces`]},{id:`chat.diff-layout`,page:`chat`,titleKey:`settings.yuri.visual.section.diffLayout`,keywords:[`diff`,`inline`,`side by side`,`layout`],isAvailable:e=>!e.isVSCode},{id:`chat.collapsible-user-messages`,page:`chat`,titleKey:`settings.yuri.visual.field.collapsibleUserMessages`,keywords:[`collapse`,`expand`,`clamp`,`long messages`,`user messages`]},{id:`chat.message-appearance`,page:`chat`,titleKey:`settings.yuri.visual.section.messageAppearance`,keywords:[`layout`,`messages`,`appearance`]},{id:`chat.inline-assistant-actions`,page:`chat`,titleKey:`settings.yuri.visual.field.showSplitAssistantMessageActions`,descriptionKey:`settings.yuri.visual.field.showSplitAssistantMessageActionsTooltip`,keywords:[`copy`,`read aloud`],isAvailable:()=>!1},{id:`chat.assistant-tps`,page:`chat`,titleKey:`settings.yuri.visual.field.showAssistantTps`,descriptionKey:`settings.yuri.visual.field.showAssistantTpsTooltip`,keywords:[`tps`,`tokens`,`speed`,`rate`,`tok/s`,`throughput`]},{id:`chat.subagent-read-only-banner`,page:`chat`,titleKey:`settings.yuri.visual.field.allowPromptingSubagentSessions`,keywords:[`subagent`,`read only`,`prompt`,`banner`]},{id:`chat.follow-up-behavior`,page:`chat`,titleKey:`settings.yuri.visual.field.followUpBehavior`,descriptionKey:`settings.yuri.visual.field.followUpBehaviorDescription`,keywords:[`follow up`,`queue`,`steer`,`send immediately`]},{id:`chat.persist-drafts`,page:`chat`,titleKey:`settings.yuri.visual.field.persistDraftMessages`,keywords:[`draft`,`message`]},{id:`chat.composer`,page:`chat`,titleKey:`settings.yuri.visual.section.composer`,keywords:[`input`,`draft`,`spellcheck`]},{id:`chat.spellcheck`,page:`chat`,titleKey:`settings.yuri.visual.field.enableSpellcheckInTextInputs`,keywords:[`spelling`,`input`],isAvailable:e=>!e.isMobile},{id:`sessions.default-model`,page:`sessions`,titleKey:`settings.yuri.defaults.field.defaultModel`,keywords:[`model`,`provider`,`new sessions`]},{id:`sessions.default-thinking`,page:`sessions`,titleKey:`settings.yuri.defaults.field.defaultThinking`,keywords:[`thinking`,`reasoning`,`variant`]},{id:`sessions.default-agent`,page:`sessions`,titleKey:`settings.yuri.defaults.field.defaultAgent`,keywords:[`agent`,`new sessions`]},{id:`sessions.browser-provider`,page:`sessions`,titleKey:`settings.yuri.browserProvider.label`,descriptionKey:`settings.yuri.browserProvider.info`,keywords:[`browser`,`extension`,`provider`,`live view`],isAvailable:()=>ur(gr())},{id:`sessions.deletion-dialog`,page:`sessions`,titleKey:`settings.yuri.defaults.field.showDeletionDialog`,keywords:[`delete`,`confirmation`]},{id:`summary-ai.configuration`,page:`summary-ai`,titleKey:`settings.yuri.defaults.summary.title`,descriptionKey:`settings.yuri.defaults.summary.description`,keywords:[`summary`,`commit`,`session title`,`prompt`,`provider`,`model`]},{id:`summary-ai.test-connection`,page:`summary-ai`,titleKey:`settings.yuri.defaults.summary.testConnection`,keywords:[`summary`,`connection`,`test`,`provider`,`api`]},{id:`sessions.auto-cleanup`,page:`sessions`,titleKey:`settings.yuri.sessionRetention.field.enableAutoCleanup`,descriptionKey:`settings.yuri.sessionRetention.tooltip`,keywords:[`retention`,`archive`,`delete`]},{id:`sessions.retention-period`,page:`sessions`,titleKey:`settings.yuri.sessionRetention.field.retentionPeriod`,keywords:[`days`,`cleanup`,`retention`]},{id:`sessions.retention-action`,page:`sessions`,titleKey:`settings.yuri.sessionRetention.field.whenSessionsExpire`,keywords:[`archive`,`delete`,`expire`]},{id:`archived-sessions.manage`,page:`archived-sessions`,titleKey:`settings.yuri.archivedSessions.title`,descriptionKey:`settings.yuri.archivedSessions.description`,keywords:[`archive`,`archived`,`restore`,`preview`,`history`]},{id:`sessions.desktop-launch-at-login`,page:`sessions`,titleKey:`settings.yuri.desktopNetwork.field.launchAtLogin`,descriptionKey:`settings.yuri.desktopNetwork.field.launchAtLoginDescription`,keywords:[`desktop`,`startup`,`login`],isAvailable:e=>e.isDesktopLocalOrigin},{id:`sessions.desktop-window-controls-position`,page:`sessions`,titleKey:`settings.yuri.desktopNetwork.field.windowControlsPosition`,descriptionKey:`settings.yuri.desktopNetwork.field.windowControlsPositionDescription`,keywords:[`desktop`,`window`,`controls`,`minimize`,`maximize`,`close`,`titlebar`,`linux`,`windows`],isAvailable:e=>e.isDesktop&&(e.isWindows||!e.isMac)},{id:`sessions.desktop-minimize-to-tray`,page:`sessions`,titleKey:`settings.yuri.desktopNetwork.field.minimizeToTray`,descriptionKey:`settings.yuri.desktopNetwork.field.minimizeToTrayDescription`,keywords:[`desktop`,`tray`,`system tray`,`minimize`,`close`,`background`,`windows`],isAvailable:e=>e.isDesktopLocalOrigin&&e.isWindows},{id:`sessions.desktop-keep-awake`,page:`sessions`,titleKey:`settings.yuri.desktopNetwork.field.keepAwake`,descriptionKey:`settings.yuri.desktopNetwork.field.keepAwakeDescription`,keywords:[`desktop`,`sleep`,`awake`,`server`,`mobile`,`phone`],isAvailable:e=>e.isDesktopLocalOrigin},{id:`remote-instances.desktop-ui-password`,page:`remote-instances`,titleKey:`settings.yuri.desktopPassword.field.password`,descriptionKey:`settings.yuri.desktopPassword.field.passwordDescription`,keywords:[`desktop`,`password`,`auth`,`login`],isAvailable:e=>e.isDesktopLocalOrigin},{id:`remote-instances.desktop-lan-access`,page:`remote-instances`,titleKey:`settings.yuri.desktopNetwork.field.allowLanAccess`,descriptionKey:`settings.yuri.desktopNetwork.field.allowLanAccessDescription`,keywords:[`desktop`,`lan`,`network`,`phone`,`tablet`],isAvailable:e=>e.isDesktopLocalOrigin},{id:`sessions.opencode-binary`,page:`sessions`,titleKey:`settings.yuri.opencodeCli.field.binaryPath`,keywords:[`opencode`,`cli`,`binary`,`path`],isAvailable:e=>!e.isVSCode},{id:`sessions.opencode-update-notifications`,page:`sessions`,titleKey:`settings.yuri.opencodeCli.field.showUpdateNotifications`,keywords:[`opencode`,`cli`,`updates`],isAvailable:e=>!e.isVSCode},{id:`git.github-account`,page:`git`,titleKey:`settings.github.page.actions.connect`,keywords:[`github`,`account`,`oauth`,`prs`,`issues`]},{id:`git.identities`,page:`git`,titleKey:`settings.gitIdentities.page.section.title`,descriptionKey:`settings.gitIdentities.page.empty.description`,keywords:[`identity`,`profile`,`author`,`email`,`credentials`,`signing`,`commit signing`,`ssh signing`,`gpg`]},{id:`git.changes-view`,page:`git`,titleKey:`settings.yuri.git.changesViewTitle`,keywords:[`changes`,`flat list`,`tree view`]},{id:`git.gitmoji`,page:`git`,titleKey:`settings.yuri.git.enableGitmoji`,keywords:[`commit`,`emoji`]},{id:`git.gitignored-files`,page:`git`,titleKey:`settings.yuri.git.showGitignored`,keywords:[`ignored`,`files`,`gitignore`]},{id:`usage.magpie`,page:`usage`,titleKey:`settings.usage.magpie.url`,descriptionKey:`settings.usage.magpie.description`,keywords:[`magpie`,`quota`,`gateway`]},{id:`usage.header-menu`,page:`usage`,titleKey:`settings.usage.page.options.showInHeader`,descriptionKey:`settings.usage.page.options.showInHeaderTooltip`,keywords:[`quota`,`header`,`dropdown`]},{id:`usage.model-quotas`,page:`usage`,titleKey:`settings.usage.page.section.modelQuotas`,keywords:[`models`,`quota`,`limits`,`tokens`]},{id:`projects.name`,page:`projects`,titleKey:`settings.projects.page.field.projectName`,keywords:[`label`,`display name`,`project metadata`]},{id:`projects.accent-color`,page:`projects`,titleKey:`settings.projects.page.field.accentColor`,keywords:[`color`,`appearance`,`project metadata`]},{id:`projects.icon`,page:`projects`,titleKey:`settings.projects.page.field.projectIcon`,keywords:[`icon`,`favicon`,`upload`,`project metadata`]},{id:`projects.worktree`,page:`projects`,titleKey:`settings.projects.page.section.worktree`,keywords:[`worktree`,`branch`,`repository`]},{id:`projects.worktree.setup.wait`,page:`projects`,titleKey:`settings.yuri.worktrees.setup.waitForCommands`,keywords:[`worktree`,`setup commands`,`bootstrap`,`wait`]},{id:`remote-instances.client-auth`,page:`remote-instances`,titleKey:`settings.remoteInstances.clientAuth.title`,descriptionKey:`settings.remoteInstances.clientAuth.description`,keywords:[`pairing link`,`client token`,`connect desktop`,`remote access`,`relay`,`devices`,`connect from anywhere`],isAvailable:e=>!e.isVSCode},{id:`remote-instances.instances`,page:`remote-instances`,titleKey:`settings.remoteInstances.sidebar.title`,descriptionKey:`settings.remoteInstances.sidebar.description`,keywords:[`import link`,`pairing link`,`connect link`,`ssh`,`remote instance`,`host switcher`],isAvailable:e=>e.isDesktop},{id:`behavior.system-prompt`,page:`behavior`,titleKey:`settings.behavior.page.section.systemPrompt`,descriptionKey:`settings.behavior.page.warning.title`,keywords:[`agents.md`,`global instructions`,`system prompt`]},{id:`behavior.response-style`,page:`behavior`,titleKey:`settings.behavior.page.section.responseStyle`,descriptionKey:`settings.behavior.page.responseStyle.tooltip`,keywords:[`tone`,`concise`,`detailed`,`custom instructions`]},{id:`agents.create`,page:`agents`,titleKey:`settings.agents.page.title.new`,keywords:[`create`,`add`,`new agent`]},{id:`assistants.create`,page:`assistants`,titleKey:`assistants.settings.create`,keywords:[`bot`,`bots`,`assistant`,`new`,`add`]},{id:`assistants.name`,page:`assistants`,titleKey:`assistants.settings.name`,keywords:[`bot`,`bots`,`assistant`,`name`]},{id:`assistants.prompt`,page:`assistants`,titleKey:`assistants.settings.defaultPrompt`,keywords:[`prompt`,`instructions`]},{id:`assistants.model`,page:`assistants`,titleKey:`assistants.settings.model`,keywords:[`provider`,`model`]},{id:`assistants.workspace`,page:`assistants`,titleKey:`assistants.settings.workspace`,keywords:[`path`,`directory`,`workspace`]},{id:`agents.name`,page:`agents`,titleKey:`settings.agents.page.field.agentName`,keywords:[`agent`,`name`]},{id:`agents.mode`,page:`agents`,titleKey:`settings.agents.page.field.mode`,descriptionKey:`settings.agents.page.field.modeTooltip`,keywords:[`primary`,`subagent`,`visibility`]},{id:`agents.scope`,page:`agents`,titleKey:`settings.agents.page.field.scope`,keywords:[`scope`,`project`,`user`,`global`]},{id:`agents.model`,page:`agents`,titleKey:`settings.agents.page.field.overrideModel`,keywords:[`model`,`provider`,`variant`]},{id:`agents.system-prompt`,page:`agents`,titleKey:`settings.agents.page.section.systemPrompt`,keywords:[`prompt`,`instructions`]},{id:`agents.permissions`,page:`agents`,titleKey:`settings.agents.page.section.toolPermissions`,keywords:[`tools`,`permissions`,`allow`,`ask`,`deny`]},{id:`commands.create`,page:`commands`,titleKey:`settings.commands.page.title.new`,keywords:[`create`,`add`,`new command`]},{id:`commands.name`,page:`commands`,titleKey:`settings.commands.page.field.commandName`,keywords:[`slash command`,`name`]},{id:`commands.agent`,page:`commands`,titleKey:`settings.commands.page.field.overrideAgent`,keywords:[`agent`,`execution`]},{id:`commands.model`,page:`commands`,titleKey:`settings.agents.page.field.overrideModel`,keywords:[`model`,`provider`]},{id:`commands.template`,page:`commands`,titleKey:`settings.commands.page.section.template`,keywords:[`prompt`,`template`,`arguments`,`shell`,`file`]},{id:`mcp.create`,page:`mcp`,titleKey:`settings.mcp.sidebar.actions.addServerTitle`,keywords:[`create`,`add`,`server`]},{id:`mcp.server`,page:`mcp`,titleKey:`settings.mcp.page.server.title`,keywords:[`server`,`name`,`transport`]},{id:`mcp.command`,page:`mcp`,titleKey:`settings.mcp.page.connection.command`,keywords:[`stdio`,`local`,`command`]},{id:`mcp.environment`,page:`mcp`,titleKey:`settings.mcp.page.env.title`,keywords:[`env`,`variables`,`api key`]},{id:`mcp.advanced`,page:`mcp`,titleKey:`settings.mcp.page.advanced.title`,keywords:[`oauth`,`headers`,`timeout`]},{id:`plugins.create`,page:`plugins`,titleKey:`settings.plugins.sidebar.actions.addTitle`,keywords:[`add`,`plugin`,`npm`,`path`,`file`]},{id:`plugins.updateAll`,page:`plugins`,titleKey:`settings.plugins.sidebar.actions.updateAll`,keywords:[`update`,`upgrade`,`all`,`plugin`]},{id:`plugins.spec`,page:`plugins`,titleKey:`settings.plugins.page.field.spec`,keywords:[`npm`,`package`,`path`]},{id:`plugins.options`,page:`plugins`,titleKey:`settings.plugins.page.field.options`,keywords:[`json`,`configuration`]},{id:`plugins.content`,page:`plugins`,titleKey:`settings.plugins.page.field.content`,keywords:[`file`,`code`]},{id:`providers.connect`,page:`providers`,titleKey:`settings.providers.page.connect.title`,keywords:[`add provider`,`connect provider`,`credentials`,`custom`,`protocol`,`base url`,`openai`,`anthropic`,`gemini`,`sync models`,`add all models`,`自定义`,`协议`,`同步模型`,`添加全部模型`]},{id:`providers.auth`,page:`providers`,titleKey:`settings.providers.page.auth.title`,keywords:[`api key`,`oauth`,`credentials`]},{id:`providers.connection-details`,page:`providers`,titleKey:`settings.providers.page.connectionDetails.title`,keywords:[`config`,`source`,`disconnect`]},{id:`providers.models`,page:`providers`,titleKey:`settings.providers.page.models.title`,keywords:[`models`,`hide`,`show`]},{id:`skills.create`,page:`skills.installed`,titleKey:`settings.skills.page.title.newSkill`,keywords:[`create`,`add`,`new skill`]},{id:`skills.basic-information`,page:`skills.installed`,titleKey:`settings.skills.page.section.basicInformation`,keywords:[`name`,`location`,`description`]},{id:`skills.instructions`,page:`skills.installed`,titleKey:`settings.skills.page.section.instructions`,keywords:[`markdown`,`skill.md`,`content`]},{id:`skills.supporting-files`,page:`skills.installed`,titleKey:`settings.skills.page.section.supportingFiles`,keywords:[`files`,`resources`]},{id:`skills.catalog.source`,page:`skills.catalog`,titleKey:`settings.skills.catalog.page.section.sourceRepository`,keywords:[`catalog`,`repository`,`source`,`refresh`]},{id:`skills.catalog.search`,page:`skills.catalog`,titleKey:`settings.skills.catalog.shared.field.searchSkillsPlaceholder`,keywords:[`find skills`,`install skills`,`catalog search`]},{id:`skills.catalog.add-catalog`,page:`skills.catalog`,titleKey:`settings.skills.catalog.page.actions.addCatalog`,keywords:[`external repository`,`add source`,`catalog`]},{id:`magic-prompts.visible-prompt`,page:`magic-prompts`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`,keywords:[`prompt text`,`user message`,`template`],isAvailable:e=>!e.isVSCode},{id:`magic-prompts.instructions`,page:`magic-prompts`,titleKey:`settings.magicPrompts.page.block.instructions`,keywords:[`hidden prompt`,`instructions`,`template`],isAvailable:e=>!e.isVSCode},{id:`magic-prompts.reset-overrides`,page:`magic-prompts`,titleKey:`settings.magicPrompts.page.actions.resetAllOverrides`,keywords:[`reset`,`default prompts`,`overrides`],isAvailable:e=>!e.isVSCode},{id:`shortcuts.keyboard-shortcuts`,page:`shortcuts`,titleKey:`settings.yuri.keyboardShortcuts.title`,descriptionKey:`settings.yuri.keyboardShortcuts.tooltip`,keywords:[`keyboard`,`hotkeys`,`bindings`]},{id:`voice.playback`,page:`voice`,titleKey:`settings.voice.page.section.playbackAndSummary`,keywords:[`tts`,`read aloud`,`voice`,`provider`,`speech rate`,`speech pitch`,`speech volume`,`tts input mode`,`markdown`,`volcengine`,`doubao`,`火山`,`豆包`,`seed-tts`,`音色`,`api key`]},{id:`voice.speech-recognition`,page:`voice`,titleKey:`settings.voice.page.section.speechRecognition`,keywords:[`stt`,`dictation`,`voice input`,`transcribe`,`whisper`,`parakeet`,`microphone`,`volcengine`,`doubao`,`火山`,`豆包`,`asr`,`实时字幕`,`识别`,`api key`,`recognition context`,`terminology`,`语境`,`上下文`,`中英文`]},{id:`notifications.delivery`,page:`notifications`,titleKey:`settings.notifications.page.delivery.title`,keywords:[`desktop notifications`,`system notifications`]},{id:`notifications.events`,page:`notifications`,titleKey:`settings.notifications.page.events.title`,keywords:[`completion`,`subtasks`,`errors`,`questions`]},{id:`notifications.push`,page:`notifications`,titleKey:`settings.notifications.page.push.title`,keywords:[`background`,`push`],isAvailable:e=>e.isWeb&&!e.isDesktop&&!e.isVSCode}];function jm(e){return e.trim().toLocaleLowerCase()}function Mm({query:e,runtimeCtx:t,visiblePageSlugs:n,t:r,getPageTitle:i}){let a=jm(e);if(!a)return[];let o=n?new Set(n):null,s=a.split(/\s+/).filter(Boolean);return Am.flatMap(e=>{if(o&&!o.has(e.page))return[];let n=Tr(e.page);if(!n||n.isAvailable&&!n.isAvailable(t)||e.isAvailable&&!e.isAvailable(t))return[];let a=r(e.titleKey),c=e.descriptionKey?r(e.descriptionKey):null,l=jm([a,c,i(e.page),...e.keywords??[]].filter(Boolean).join(` `));return s.every(e=>l.includes(e))?[{...e,title:a,description:c,pageTitle:i(e.page)}]:[]})}function Nm(e){let t=(0,Sa.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({asChild:i,className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i!==void 0&&i?Ke:`div`,o;t[4]===n?o=t[5]:(o=K(`yuri-mobile-floating-surface`,n),t[4]=n,t[5]=o);let s;return t[6]!==a||t[7]!==r||t[8]!==o?(s=(0,$.jsx)(a,{className:o,...r}),t[6]=a,t[7]=r,t[8]=o,t[9]=s):s=t[9],s}function Pm(e){let t=(0,Sa.c)(20),n,r,i,a,o,s;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6]):({as:o,children:n,className:r,variant:s,surfaceProps:a,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s);let c=o===void 0?`div`:o,l=s===void 0?`actions`:s,u;t[7]===r?u=t[8]:(u=K(`yuri-mobile-floating-bottom-bar-frame`,r),t[7]=r,t[8]=u);let d=l===`navigation`?`yuri-mobile-floating-bottom-bar-navigation`:`yuri-mobile-floating-bottom-bar-actions`,f;t[9]===d?f=t[10]:(f=K(`yuri-mobile-floating-bottom-bar`,d),t[9]=d,t[10]=f);let p;t[11]!==n||t[12]!==a||t[13]!==f?(p=(0,$.jsx)(Nm,{...a,className:f,children:n}),t[11]=n,t[12]=a,t[13]=f,t[14]=p):p=t[14];let m;return t[15]!==c||t[16]!==i||t[17]!==u||t[18]!==p?(m=(0,$.jsx)(c,{className:u,...i,children:p}),t[15]=c,t[16]=i,t[17]=u,t[18]=p,t[19]=m):m=t[19],m}function Fm(e){let t=(0,Sa.c)(17),{title:n,children:r,surface:i,scrollsWithPage:a,showHeader:o,trailing:s,className:c,surfaceClassName:l,surfaceAriaLabel:u}=e,d=i===void 0||i,f=a!==void 0&&a,p=o===void 0||o,m=f&&`yuri-mobile-tab-page-flow`,h=!p&&`gap-0`,g;t[0]!==c||t[1]!==m||t[2]!==h?(g=K(`yuri-mobile-tab-page`,m,h,c),t[0]=c,t[1]=m,t[2]=h,t[3]=g):g=t[3];let _;t[4]!==p||t[5]!==n||t[6]!==s?(_=p?(0,$.jsx)(Di,{title:n,trailing:s}):null,t[4]=p,t[5]=n,t[6]=s,t[7]=_):_=t[7];let v;t[8]!==r||t[9]!==d||t[10]!==u||t[11]!==l?(v=d?(0,$.jsx)(Nm,{className:K(`yuri-mobile-tab-page-surface`,l),"aria-label":u,children:r}):(0,$.jsx)(`div`,{className:K(`yuri-mobile-tab-page-content`,l),"aria-label":u,children:r}),t[8]=r,t[9]=d,t[10]=u,t[11]=l,t[12]=v):v=t[12];let y;return t[13]!==g||t[14]!==_||t[15]!==v?(y=(0,$.jsxs)(`div`,{className:g,children:[_,v]}),t[13]=g,t[14]=_,t[15]=v,t[16]=y):y=t[16],y}function Im(e){let t=(0,Sa.c)(12),{label:n,children:r,className:i,cardClassName:a,ariaLabel:o}=e,s;t[0]!==a||t[1]!==i?(s=K(`yuri-mobile-labeled-surface-group`,a,i),t[0]=a,t[1]=i,t[2]=s):s=t[2];let c;t[3]===n?c=t[4]:(c=(0,$.jsx)(`div`,{className:`yuri-mobile-labeled-surface-group-label`,children:n}),t[3]=n,t[4]=c);let l;t[5]===r?l=t[6]:(l=r?(0,$.jsx)(`div`,{className:`yuri-mobile-labeled-surface-group-content`,children:r}):null,t[5]=r,t[6]=l);let u;return t[7]!==o||t[8]!==s||t[9]!==c||t[10]!==l?(u=(0,$.jsxs)(`section`,{className:s,"aria-label":o,children:[c,l]}),t[7]=o,t[8]=s,t[9]=c,t[10]=l,t[11]=u):u=t[11],u}function Lm(e){let t=(0,Sa.c)(10),{label:n,children:r,ariaLabel:i,className:a,borderless:o}=e,s=o!==void 0&&o,c;t[0]===a?c=t[1]:(c=K(`yuri-mobile-settings-group`,a),t[0]=a,t[1]=c);let l=s&&`yuri-mobile-settings-card-borderless`,u;t[2]===l?u=t[3]:(u=K(`yuri-mobile-settings-card`,l),t[2]=l,t[3]=u);let d;return t[4]!==i||t[5]!==r||t[6]!==n||t[7]!==c||t[8]!==u?(d=(0,$.jsx)(Z,{label:n,ariaLabel:i,className:c,cardClassName:u,children:r}),t[4]=i,t[5]=r,t[6]=n,t[7]=c,t[8]=u,t[9]=d):d=t[9],d}var Rm=e({SettingsView:()=>$m,getSettingsNavIcon:()=>Zm}),zm=176,Bm=280,Vm=8,Hm=`__yuriSettingsDetail`;function Um(e){return Math.min(Bm,Math.max(zm,e))}var Wm=`__add_provider__`;function Gm(e,t){return{isVSCode:g(),isWeb:!e&&d(),isDesktop:e,isMobile:t}}function Km(e,t){return!e.isAvailable||e.isAvailable(t)}function qm(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Jm(e,t){let n=new Set(t),r=e,i=1;for(;n.has(r);)r=`${e}-${i}`,i+=1;return r}function Ym(e){if(!qm(e))return null;let t=e[Hm];if(!qm(t))return null;let n=t.page,r=t.stage;return typeof n!=`string`||r!==`page-content`?null:{page:kr(n),stage:r}}function Xm(){return typeof window>`u`||!qm(window.history.state)?{}:window.history.state}function Zm(e){switch(e){case`projects`:return`folders`;case`instances`:return`server`;case`remote-instances`:return`server`;case`appearance`:return`palette`;case`chat`:return`chat-ai-3`;case`magic-prompts`:return`ai-generate-2`;case`notifications`:return`notification-3`;case`shortcuts`:return`command`;case`sessions`:return`chat-history`;case`archived-sessions`:return`archive`;case`summary-ai`:return`ai-generate-2`;case`providers`:return`cloud`;case`agents`:return`node-tree`;case`assistants`:return`robot-2`;case`behavior`:return`brain`;case`commands`:return`slash-commands-2`;case`mcp`:return null;case`plugins`:return`code-box`;case`global-config`:return`settings-3`;case`skills.installed`:return`book-open`;case`skills.catalog`:return`book`;case`git`:return`git-branch`;case`usage`:return`bar-chart-2`;case`voice`:return`mic`;case`about`:return`information`;case`home`:return null;default:return`robot-2`}}var Qm=e=>{let t=(0,Sa.c)(95),{onOpen:n}=e,{t:r}=Ge(),i;t[0]===r?i=t[1]:(i=r(`settings.view.home.title`),t[0]=r,t[1]=i);let a;t[2]===i?a=t[3]:(a=(0,$.jsx)(`h1`,{className:`typography-ui-header font-semibold text-foreground`,children:i}),t[2]=i,t[3]=a);let o;t[4]===r?o=t[5]:(o=r(`settings.view.home.description`),t[4]=r,t[5]=o);let s;t[6]===o?s=t[7]:(s=(0,$.jsx)(`p`,{className:`typography-ui text-muted-foreground`,children:o}),t[6]=o,t[7]=s);let c;t[8]!==a||t[9]!==s?(c=(0,$.jsxs)(`div`,{className:`space-y-1`,children:[a,s]}),t[8]=a,t[9]=s,t[10]=c):c=t[10];let l;t[11]===n?l=t[12]:(l=()=>n(`providers`),t[11]=n,t[12]=l);let u;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(u=K(`rounded-lg border border-border bg-[var(--surface-elevated)] p-4 text-left`,`hover:bg-[var(--interactive-hover)] transition-colors`),t[13]=u):u=t[13];let d;t[14]===r?d=t[15]:(d=r(`settings.view.home.cards.providers.title`),t[14]=r,t[15]=d);let f;t[16]===d?f=t[17]:(f=(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:d}),t[16]=d,t[17]=f);let p;t[18]===r?p=t[19]:(p=r(`settings.view.home.cards.providers.description`),t[18]=r,t[19]=p);let m;t[20]===p?m=t[21]:(m=(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/70`,children:p}),t[20]=p,t[21]=m);let h;t[22]!==m||t[23]!==l||t[24]!==f?(h=(0,$.jsxs)(`button`,{type:`button`,onClick:l,className:u,children:[f,m]}),t[22]=m,t[23]=l,t[24]=f,t[25]=h):h=t[25];let g;t[26]===n?g=t[27]:(g=()=>n(`agents`),t[26]=n,t[27]=g);let _;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(_=K(`rounded-lg border border-border bg-[var(--surface-elevated)] p-4 text-left`,`hover:bg-[var(--interactive-hover)] transition-colors`),t[28]=_):_=t[28];let v;t[29]===r?v=t[30]:(v=r(`settings.view.home.cards.agents.title`),t[29]=r,t[30]=v);let y;t[31]===v?y=t[32]:(y=(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:v}),t[31]=v,t[32]=y);let b;t[33]===r?b=t[34]:(b=r(`settings.view.home.cards.agents.description`),t[33]=r,t[34]=b);let x;t[35]===b?x=t[36]:(x=(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/70`,children:b}),t[35]=b,t[36]=x);let S;t[37]!==g||t[38]!==y||t[39]!==x?(S=(0,$.jsxs)(`button`,{type:`button`,onClick:g,className:_,children:[y,x]}),t[37]=g,t[38]=y,t[39]=x,t[40]=S):S=t[40];let C;t[41]===n?C=t[42]:(C=()=>n(`skills.catalog`),t[41]=n,t[42]=C);let w;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(w=K(`rounded-lg border border-border bg-[var(--surface-elevated)] p-4 text-left`,`hover:bg-[var(--interactive-hover)] transition-colors`),t[43]=w):w=t[43];let T;t[44]===r?T=t[45]:(T=r(`settings.view.home.cards.skillsCatalog.title`),t[44]=r,t[45]=T);let E;t[46]===T?E=t[47]:(E=(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:T}),t[46]=T,t[47]=E);let D;t[48]===r?D=t[49]:(D=r(`settings.view.home.cards.skillsCatalog.description`),t[48]=r,t[49]=D);let O;t[50]===D?O=t[51]:(O=(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/70`,children:D}),t[50]=D,t[51]=O);let k;t[52]!==C||t[53]!==E||t[54]!==O?(k=(0,$.jsxs)(`button`,{type:`button`,onClick:C,className:w,children:[E,O]}),t[52]=C,t[53]=E,t[54]=O,t[55]=k):k=t[55];let A;t[56]===n?A=t[57]:(A=()=>n(`mcp`),t[56]=n,t[57]=A);let j;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(j=K(`rounded-lg border border-border bg-[var(--surface-elevated)] p-4 text-left`,`hover:bg-[var(--interactive-hover)] transition-colors`),t[58]=j):j=t[58];let M;t[59]===r?M=t[60]:(M=r(`settings.view.home.cards.mcp.title`),t[59]=r,t[60]=M);let N;t[61]===M?N=t[62]:(N=(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:M}),t[61]=M,t[62]=N);let P;t[63]===r?P=t[64]:(P=r(`settings.view.home.cards.mcp.description`),t[63]=r,t[64]=P);let F;t[65]===P?F=t[66]:(F=(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/70`,children:P}),t[65]=P,t[66]=F);let I;t[67]!==A||t[68]!==N||t[69]!==F?(I=(0,$.jsxs)(`button`,{type:`button`,onClick:A,className:j,children:[N,F]}),t[67]=A,t[68]=N,t[69]=F,t[70]=I):I=t[70];let L;t[71]===n?L=t[72]:(L=()=>n(`usage`),t[71]=n,t[72]=L);let R;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(R=K(`rounded-lg border border-border bg-[var(--surface-elevated)] p-4 text-left`,`hover:bg-[var(--interactive-hover)] transition-colors`),t[73]=R):R=t[73];let z;t[74]===r?z=t[75]:(z=r(`settings.view.home.cards.usage.title`),t[74]=r,t[75]=z);let B;t[76]===z?B=t[77]:(B=(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:z}),t[76]=z,t[77]=B);let V;t[78]===r?V=t[79]:(V=r(`settings.view.home.cards.usage.description`),t[78]=r,t[79]=V);let H;t[80]===V?H=t[81]:(H=(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/70`,children:V}),t[80]=V,t[81]=H);let U;t[82]!==L||t[83]!==B||t[84]!==H?(U=(0,$.jsxs)(`button`,{type:`button`,onClick:L,className:R,children:[B,H]}),t[82]=L,t[83]=B,t[84]=H,t[85]=U):U=t[85];let W;t[86]!==h||t[87]!==S||t[88]!==k||t[89]!==I||t[90]!==U?(W=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[h,S,k,I,U]}),t[86]=h,t[87]=S,t[88]=k,t[89]=I,t[90]=U,t[91]=W):W=t[91];let ee;return t[92]!==W||t[93]!==c?(ee=(0,$.jsx)(`div`,{className:`h-full overflow-auto`,children:(0,$.jsxs)(`div`,{className:`mx-auto w-full max-w-3xl px-6 py-6 space-y-6`,children:[c,W]})}),t[92]=W,t[93]=c,t[94]=ee):ee=t[94],ee},$m=e=>{let t=(0,Sa.c)(183),{onClose:n,mobileInstancesPage:r,forceMobile:i,isWindowed:a,visiblePageSlugs:o,hideMobileHeader:s,flowMobile:c,autoOpenMobilePage:l,initialMobileStage:u,onMobileStageChange:d}=e,f=s!==void 0&&s,p=c!==void 0&&c,m=l===void 0||l,g=u===void 0?`nav`:u,{t:_}=Ge(),v;t[0]===_?v=t[1]:(v={mutationFn:pt,onError:()=>Be.error(_(`chat.chatInput.toast.reloadFailed`))},t[0]=_,t[1]=v);let y=Te(v),b;t[2]===y?b=t[3]:(b=()=>{y.isPending||y.mutate()},t[2]=y,t[3]=b);let x=He(b),S=wr(),C=i??S.isMobile,w=G(eh),T=G(th),E=G(nh),D;t[4]===w?D=t[5]:(D=kr(w),t[4]=w,t[5]=D);let k=D;sr();let A=k===`commands`,j;t[6]===A?j=t[7]:(j={enabled:A},t[6]=A,t[7]=j);let{refetch:M}=Tt(j),N,P;t[8]!==M||t[9]!==k?(N=()=>{k===`commands`&&M()},P=[M,k],t[8]=M,t[9]=k,t[10]=N,t[11]=P):(N=t[10],P=t[11]),Q.useEffect(N,P);let[F,I]=Q.useState(g),L=f&&F===`nav`,R=C&&p,z=Q.useRef(null),B=Q.useRef(0),V=en(rh),H,U;t[12]!==C||t[13]!==V||t[14]!==E||t[15]!==k?(H=()=>{if(!C||V<=B.current)return;let e=en.getState().settingsSelectedAssistantID;if(!(!e||e===`new`)){if(k!==`assistants`){E(`assistants`);return}B.current=V,z.current=`assistants`,I(`page-content`)}},U=[C,V,E,k],t[12]=C,t[13]=V,t[14]=E,t[15]=k,t[16]=H,t[17]=U):(H=t[16],U=t[17]),Q.useEffect(H,U);let W,ee;t[18]!==F||t[19]!==d?(W=()=>{d?.(F)},ee=[F,d],t[18]=F,t[19]=d,t[20]=W,t[21]=ee):(W=t[20],ee=t[21]),Q.useEffect(W,ee);let[te,ne]=Q.useState(216),[re,ie]=Q.useState(null),[ae,oe]=Q.useState(``),[se,ce]=Q.useState(null),[le,ue]=Q.useState(0),[de,fe]=Q.useState(!1),[pe,me]=Q.useState(!1),he=Q.useRef(0),ge=Q.useRef(te),_e=Q.useRef(null),ve=Q.useRef(null),ye=Q.useRef(null),be=Q.useRef(null),xe=Q.useRef(null),Se=Q.useRef(null),Ce;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(Ce=[],t[22]=Ce):Ce=t[22];let we=Q.useRef(Ce),Ee=Q.useRef(0),De=Q.useRef(!1),ke;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(ke=h(),t[23]=ke):ke=t[23];let je=ke,Me;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(Me=h()&&O(),t[24]=Me):Me=t[24];let Ne=Me,Pe;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(Pe=h()&&typeof window<`u`&&window.__YURI_PLATFORM__===`darwin`,t[25]=Pe):Pe=t[25];let Fe=Pe,Ie;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(Ie=h()&&typeof window<`u`&&window.__YURI_PLATFORM__===`win32`,t[26]=Ie):Ie=t[26];let Le=Ie,Re;t[27]===C?Re=t[28]:(Re=Gm(je,C),t[27]=C,t[28]=Re);let ze=Re,Ve;if(t[29]!==C||t[30]!==r||t[31]!==ze||t[32]!==o){let e=o?new Set(o):null,n;t[34]===ze?n=t[35]:(n=e=>Km(e,ze),t[34]=ze,t[35]=n);let i;t[36]===r?i=t[37]:(i=e=>e.slug!==`instances`||!!r,t[36]=r,t[37]=i);let a;t[38]===ze.isVSCode?a=t[39]:(a=e=>!(ze.isVSCode&&e.slug===`projects`),t[38]=ze.isVSCode,t[39]=a);let s;t[40]===C?s=t[41]:(s=e=>!(C&&e.slug===`shortcuts`),t[40]=C,t[41]=s),Ve=Dr.filter(ih).filter(t=>!e||e.has(t.slug)).filter(n).filter(i).filter(a).filter(s),t[29]=C,t[30]=r,t[31]=ze,t[32]=o,t[33]=Ve}else Ve=t[33];let Ue=Ve,We=ai().length,Ke=Om(),Je;t[42]===Ue?Je=t[43]:(Je=Er(Ue),t[42]=Ue,t[43]=Je);let Ye=Je,Xe=Qt(ah),Ze,Qe;t[44]===de?(Ze=t[45],Qe=t[46]):(Ze=()=>{if(typeof window>`u`)return;let e=()=>{if(!de){let e=Um(Math.floor(window.innerWidth*.12));ne(e)}};return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},Qe=[de],t[44]=de,t[45]=Ze,t[46]=Qe),Q.useEffect(Ze,Qe);let $e,et;t[47]===pe?($e=t[48],et=t[49]):($e=()=>{if(!pe)return;let e=e=>{let t=e.clientX-he.current,n=Um(ge.current+t);ne(n),fe(!0)},t=()=>me(!1);return window.addEventListener(`pointermove`,e),window.addEventListener(`pointerup`,t,{once:!0}),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,t)}},et=[pe],t[47]=pe,t[48]=$e,t[49]=et),Q.useEffect($e,et);let tt;t[50]===te?tt=t[51]:(tt=e=>{me(!0),he.current=e.clientX,ge.current=te,e.preventDefault()},t[50]=te,t[51]=tt);let nt=tt,rt;t[52]===te?rt=t[53]:(rt=e=>{let t=e.shiftKey?32:Vm,n;bb160:switch(e.key){case`ArrowLeft`:n=te-t;break bb160;case`ArrowRight`:n=te+t;break bb160;case`Home`:n=zm;break bb160;case`End`:n=Bm;break bb160;default:return}e.preventDefault(),ne(Um(n)),fe(!0)},t[52]=te,t[53]=rt);let it=rt,ot;t[54]!==T||t[55]!==a||t[56]!==ze.isVSCode||t[57]!==k?(ot=()=>{if(!(!T&&!ze.isVSCode&&!a)){if(k===`agents`){xt.getState().loadAgents();return}if(k!==`commands`&&k!==`mcp`){if(k===`plugins`){$i.getState().loadPlugins();return}(k===`skills.installed`||k===`skills.catalog`)&&vt(Oe,ct())}}},t[54]=T,t[55]=a,t[56]=ze.isVSCode,t[57]=k,t[58]=ot):ot=t[58];let st;t[59]!==Xe||t[60]!==T||t[61]!==a||t[62]!==ze.isVSCode||t[63]!==k?(st=[Xe,T,a,ze.isVSCode,k],t[59]=Xe,t[60]=T,t[61]=a,t[62]=ze.isVSCode,t[63]=k,t[64]=st):st=t[64],Q.useEffect(ot,st);let lt;t[65]!==C||t[66]!==E?(lt=(e,t)=>{if(e===`providers`&&!(t!==void 0&&t)&&Pt.getState().setSelectedProvider(Wm),E(e),z.current=e,!C)return;let n=Tr(e);if(!n||n.slug===`home`){I(`nav`);return}I(n.kind===`split`?`page-sidebar`:`page-content`)},t[65]=C,t[66]=E,t[67]=lt):lt=t[67];let ut=He(lt),dt;t[68]===k?dt=t[69]:(dt=Tr(k),t[68]=k,t[69]=dt);let ft=dt,mt;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(mt={appearance:`visual`,chat:`chat`,shortcuts:`shortcuts`,sessions:`sessions`,"summary-ai":`summary-ai`,notifications:`notifications`,voice:`voice`},t[70]=mt):mt=t[70];let ht=mt,gt;t[71]===_?gt=t[72]:(gt=e=>{switch(e){case`projects`:return _(`settings.page.projects.title`);case`instances`:return _(`mobile.settings.switchInstance`);case`remote-instances`:return _(`settings.page.remoteInstances.title`);case`providers`:return _(`settings.page.providers.title`);case`usage`:return _(`settings.page.usage.title`);case`agents`:return _(`settings.page.agents.title`);case`assistants`:return _(`settings.page.assistants.title`);case`behavior`:return _(`settings.page.behavior.title`);case`commands`:return _(`settings.page.commands.title`);case`mcp`:return _(`settings.page.mcp.title`);case`plugins`:return _(`settings.page.plugins.title`);case`global-config`:return _(`settings.globalConfig.title`);case`skills.installed`:return _(`settings.page.skills.title`);case`skills.catalog`:return _(`settings.page.skillsCatalog.title`);case`git`:return _(`settings.page.git.title`);case`appearance`:return _(`settings.page.appearance.title`);case`chat`:return _(`settings.page.chat.title`);case`shortcuts`:return _(`settings.page.shortcuts.title`);case`sessions`:return _(`settings.page.sessions.title`);case`archived-sessions`:return _(`settings.page.archivedSessions.title`);case`summary-ai`:return _(`settings.page.summaryAI.title`);case`magic-prompts`:return _(`settings.page.magicPrompts.title`);case`notifications`:return _(`settings.page.notifications.title`);case`voice`:return _(`settings.page.voice.title`);case`about`:return _(`settings.page.about.title`);default:return _(`settings.view.home.title`)}},t[71]=_,t[72]=gt);let _t=gt,yt;t[73]!==_t||t[74]!==ze||t[75]!==ae||t[76]!==_||t[77]!==Ue?(yt=Mm({query:ae,runtimeCtx:{...ze,isDesktopLocalOrigin:Ne,isMac:Fe,isWindows:Le},visiblePageSlugs:Ue.map(oh),t:_,getPageTitle:_t}),t[73]=_t,t[74]=ze,t[75]=ae,t[76]=_,t[77]=Ue,t[78]=yt):yt=t[78];let bt=yt,St=dh,Ct;if(t[79]!==bt){Ct=[];let e=new Map;for(let t of bt){let n=e.get(t.page);n||(n={page:t.page,pageTitle:t.pageTitle,results:[]},e.set(t.page,n),Ct.push(n)),n.results.push(t)}t[79]=bt,t[80]=Ct}else Ct=t[80];let wt=Ct,Et;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(Et=()=>{ue(0),Ee.current=0,De.current=!1},t[81]=Et):Et=t[81];let Dt;t[82]===ae?Dt=t[83]:(Dt=[ae],t[82]=ae,t[83]=Dt),Q.useEffect(Et,Dt);let Ot,kt;t[84]===le?(Ot=t[85],kt=t[86]):(Ot=()=>{Ee.current=le},kt=[le],t[84]=le,t[85]=Ot,t[86]=kt),Q.useEffect(Ot,kt);let At,jt;t[87]===le?(At=t[88],jt=t[89]):(At=()=>{we.current[le]?.scrollIntoView({block:`nearest`})},jt=[le],t[87]=le,t[88]=At,t[89]=jt),Q.useEffect(At,jt);let Mt,Nt;t[90]!==le||t[91]!==bt.length?(Mt=()=>{le>=bt.length&&ue(Math.max(0,bt.length-1)),we.current.length=bt.length},Nt=[le,bt.length],t[90]=le,t[91]=bt.length,t[92]=Mt,t[93]=Nt):(Mt=t[92],Nt=t[93]),Q.useEffect(Mt,Nt);let J;t[94]!==C||t[95]!==ut?(J=e=>{let t=St(e);ce(t),ut(e.page,!0),C&&I(`page-content`),e.id===`plugins.create`&&typeof window<`u`&&window.setTimeout(fh,50)},t[94]=C,t[95]=ut,t[96]=J):J=t[96];let Ft=J,It;t[97]!==Ft||t[98]!==ae||t[99]!==bt?(It=e=>{if(ae.trim()){if(e.key===`Escape`){e.preventDefault(),oe(``);return}if(bt.length!==0){if(e.key===`ArrowDown`){e.preventDefault(),De.current=!0,ue(e=>(e+1)%bt.length);return}if(e.key===`ArrowUp`){e.preventDefault(),De.current=!0,ue(e=>(e-1+bt.length)%bt.length);return}if(e.key===`Enter`){e.preventDefault();let t=(Ee.current%bt.length+bt.length)%bt.length,n=bt[t]??bt[0];n&&Ft(n)}}}},t[97]=Ft,t[98]=ae,t[99]=bt,t[100]=It):It=t[100];let Lt=It,Rt;t[101]===se?Rt=t[102]:(Rt=()=>{let e=se;if(!e)return;let t=!1,n=window.requestAnimationFrame(()=>{if(t)return;let n=typeof CSS<`u`&&CSS.escape?CSS.escape(e):e.replace(/[^a-zA-Z0-9_-]/g,`\\$&`),r=_e.current?.querySelector(`[data-settings-item="${n}"]`);r&&(ce(null),r.scrollIntoView({block:`center`,behavior:`smooth`}),r.setAttribute(`data-settings-search-highlight`,`true`),window.setTimeout(()=>{r.removeAttribute(`data-settings-search-highlight`)},1600))});return()=>{t=!0,window.cancelAnimationFrame(n)}},t[101]=se,t[102]=Rt);let zt;t[103]!==se||t[104]!==k?(zt=[se,k],t[103]=se,t[104]=k,t[105]=zt):zt=t[105],Q.useEffect(Rt,zt);let Bt;t[106]===_?Bt=t[107]:(Bt=()=>(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6`,children:(0,$.jsxs)(`div`,{className:`max-w-md text-center`,children:[(0,$.jsx)(`div`,{className:`typography-ui-header font-semibold text-foreground`,children:_(`settings.view.unavailable.title`)}),(0,$.jsx)(`p`,{className:`typography-ui text-muted-foreground mt-1`,children:_(`settings.view.unavailable.description`)})]})}),t[106]=_,t[107]=Bt);let Vt=Bt,Ht=ph,Ut;t[108]!==C||t[109]!==ze.isVSCode||t[110]!==k?(Ut=()=>{if(C){if(Ae()||ze.isVSCode){I(`page-sidebar`);return}if((typeof window<`u`?Ym(window.history.state):null)?.page===k){window.history.back();return}I(`page-sidebar`)}},t[108]=C,t[109]=ze.isVSCode,t[110]=k,t[111]=Ut):Ut=t[111];let Wt=Ut,Y;t[112]!==re||t[113]!==Wt||t[114]!==C||t[115]!==R||t[116]!==r||t[117]!==ut||t[118]!==Vt||t[119]!==ze?(Y=e=>{let t=Tr(e);if(t&&!Km(t,ze))return Vt();switch(e){case`home`:return(0,$.jsx)(Qm,{onOpen:ut});case`projects`:return(0,$.jsx)(Qu,{});case`instances`:return r??Vt();case`remote-instances`:return(0,$.jsx)(df,{});case`agents`:return(0,$.jsx)(ds,{});case`assistants`:return(0,$.jsx)(ac,{onItemDeleted:C?Wt:void 0,onSaved:C?Wt:void 0,saveActionContainer:C?re:void 0});case`behavior`:return(0,$.jsx)(bc,{});case`commands`:return(0,$.jsx)(Oc,{});case`mcp`:return(0,$.jsx)(ll,{});case`plugins`:return(0,$.jsx)(Ql,{});case`global-config`:return(0,$.jsx)(eu,{});case`skills.installed`:return(0,$.jsx)(Uu,{view:`installed`});case`skills.catalog`:return(0,$.jsx)(Uu,{view:`catalog`});case`providers`:return(0,$.jsx)(fa,{});case`usage`:return(0,$.jsx)(Wf,{});case`about`:return(0,$.jsx)(`div`,{className:K(`h-full overflow-auto px-5 py-6`,R&&`h-auto overflow-visible p-3`),children:(0,$.jsx)(Aa,{})});case`magic-prompts`:return(0,$.jsx)($f,{});case`git`:return(0,$.jsx)(sp,{});case`archived-sessions`:return(0,$.jsx)(Dm,{});case`appearance`:case`chat`:case`shortcuts`:case`sessions`:case`summary-ai`:case`notifications`:case`voice`:{let t=ht[e]??`visual`;return(0,$.jsx)(_m,{section:t,flowMobile:R})}default:return(0,$.jsx)(Qm,{onOpen:ut})}},t[112]=re,t[113]=Wt,t[114]=C,t[115]=R,t[116]=r,t[117]=ut,t[118]=Vt,t[119]=ze,t[120]=Y):Y=t[120];let Gt=Y,qt,Jt;t[121]!==m||t[122]!==C||t[123]!==F||t[124]!==k?(qt=()=>{if(!C||!m||F!==`nav`||k===`home`||z.current===k)return;let e=Tr(k);!e||e.slug===`home`||(z.current=k,I(e.kind===`split`?`page-sidebar`:`page-content`))},Jt=[m,C,F,k],t[121]=m,t[122]=C,t[123]=F,t[124]=k,t[125]=qt,t[126]=Jt):(qt=t[125],Jt=t[126]),Q.useEffect(qt,Jt);let Yt,Xt;t[127]!==p||t[128]!==k?(Yt=()=>{!p||k!==`home`||(z.current=null,I(`nav`))},Xt=[p,k],t[127]=p,t[128]=k,t[129]=Yt,t[130]=Xt):(Yt=t[129],Xt=t[130]),Q.useEffect(Yt,Xt);let Zt=C&&F!==`nav`,$t=C&&F===`page-content`&&ft?.kind===`split`,tn=F===`page-content`&&ft?.kind===`split`&&!$t,nn;t[131]!==$t||t[132]!==Zt||t[133]!==_?(nn=_($t?`settings.view.actions.back`:Zt?`settings.view.actions.backToSettings`:`settings.view.actions.closeSettings`),t[131]=$t,t[132]=Zt,t[133]=_,t[134]=nn):nn=t[134];let rn=nn,an=qe(),on;t[135]===ze.isVSCode?on=t[136]:(on=e=>{if(typeof window>`u`||ze.isVSCode||Ae())return;let t=Ym(window.history.state);(t?.page!==e||t.stage!==`page-content`)&&window.history.pushState({...Xm(),[Hm]:{page:e,stage:`page-content`}},``,window.location.href)},t[135]=ze.isVSCode,t[136]=on);let sn=on,cn;t[137]!==sn||t[138]!==k?(cn=()=>{I(`page-content`),sn(k)},t[137]=sn,t[138]=k,t[139]=cn):cn=t[139];let ln=cn,un;t[140]!==$t||t[141]!==p||t[142]!==Wt||t[143]!==E?(un=()=>{if(p&&Kt.getState().settingsReturnTo){z.current=null,I(`nav`),E(`home`),Kt.getState().restoreSettingsReturnTo();return}if($t){Wt();return}I(`nav`)},t[140]=$t,t[141]=p,t[142]=Wt,t[143]=E,t[144]=un):un=t[144];let dn=un,fn;t[145]!==ft?.kind||t[146]!==F?(fn=()=>{if(F===`page-content`){xe.current=be.current,Se.current=ft?.kind===`split`?ye.current:ve.current;return}xe.current=ye.current,Se.current=ve.current},t[145]=ft?.kind,t[146]=F,t[147]=fn):fn=t[147];let pn=ft?.kind,mn;t[148]!==F||t[149]!==pn?(mn=[pn,F],t[148]=F,t[149]=pn,t[150]=mn):mn=t[150],Q.useLayoutEffect(fn,mn);let hn=`mobile-settings:${k}`,gn=R&&F!==`nav`,_n;t[151]!==dn||t[152]!==hn||t[153]!==gn?(_n={id:hn,active:gn,onBack:dn,surfaceRef:xe,underlayRef:Se},t[151]=dn,t[152]=hn,t[153]=gn,t[154]=_n):_n=t[154],ta(_n);let vn,yn;t[155]!==C||t[156]!==ze.isVSCode||t[157]!==k?(vn=()=>{if(!C||ze.isVSCode||Ae())return;let e=e=>{if(Tr(k)?.kind===`split`){if(Ym(e.state)?.page===k){I(`page-content`);return}I(mh)}};return window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`popstate`,e)}},yn=[C,ze.isVSCode,k],t[155]=C,t[156]=ze.isVSCode,t[157]=k,t[158]=vn,t[159]=yn):(vn=t[158],yn=t[159]),Q.useEffect(vn,yn);let bn;t[160]===Symbol.for(`react.memo_cache_sentinel`)?(bn=()=>{I(`page-sidebar`)},t[160]=bn):bn=t[160];let xn=bn,Sn=()=>{let e=ae.trim().length>0;return(0,$.jsxs)(`div`,{className:K(`flex h-full flex-col overflow-hidden`,C&&`yuri-settings-navigation-content`,R&&`h-auto w-full overflow-visible`),children:[(0,$.jsx)(`div`,{className:K(`px-2 pt-3`,C&&`yuri-mobile-settings-search`),children:(0,$.jsxs)(`div`,{className:K(`flex h-10 items-center gap-1.5 rounded-md border border-border bg-background/70 px-2 text-muted-foreground focus-within:ring-2 focus-within:ring-primary/40 sm:h-8`,C&&`yuri-mobile-settings-search-field`),children:[(0,$.jsx)(X,{name:`search`,className:`h-4 w-4 shrink-0`}),(0,$.jsx)(`input`,{value:ae,onChange:e=>oe(e.target.value),onKeyDown:Lt,placeholder:_(`settings.view.search.placeholder`),"aria-label":_(`settings.view.search.aria`),className:`typography-ui min-w-0 flex-1 bg-transparent text-foreground outline-none placeholder:text-muted-foreground/70`}),e&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>oe(``),"aria-label":_(`settings.view.search.clear`),className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-interactive-hover hover:text-foreground sm:h-5 sm:w-5`,children:(0,$.jsx)(X,{name:`close`,className:`h-3.5 w-3.5`})})]})}),(0,$.jsx)(`div`,{className:K(`flex-1 min-h-0 overflow-y-auto overflow-x-hidden`,R&&`w-full flex-none overflow-visible`),children:(0,$.jsx)(`div`,{className:K(C?`yuri-mobile-settings-nav-list flex min-w-0 flex-col`:`flex flex-col gap-0.5 px-2 pb-2 pt-4`),children:e?bt.length>0?(()=>{let e=0;return wt.map(t=>{let n=t.results.map(t=>{let n=e;e+=1;let r=n===le,i=!!t.description;return(0,$.jsxs)(`button`,{type:`button`,ref:e=>{we.current[n]=e},onMouseMove:()=>{De.current=!1,ue(n)},onClick:()=>Ft(t),className:K(C?`yuri-mobile-settings-row yuri-mobile-settings-search-result`:`flex w-full flex-col rounded-md px-2 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,i?`min-h-11 py-1.5`:`py-2`,r?`bg-interactive-selection`:`hover:bg-interactive-hover`),children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:t.title}),i&&(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70 line-clamp-2`,children:t.description})]}),C?(0,$.jsx)(X,{name:`arrow-right-s`,className:`size-4 shrink-0 text-muted-foreground/60`}):null]},t.id)});return C?(0,$.jsx)(Lm,{label:t.pageTitle,ariaLabel:t.pageTitle,children:n},t.page):(0,$.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,$.jsx)(`div`,{className:`px-2 pb-0.5 pt-2 typography-micro font-medium text-muted-foreground/70`,children:t.pageTitle}),n]},t.page)})})():(0,$.jsx)(`div`,{className:`px-2 py-6 text-center typography-ui text-muted-foreground`,children:_(`settings.view.search.noResults`)}):(0,$.jsx)($.Fragment,{children:Ye.map((e,t)=>{let{group:n,pages:r}=e,i=_(`settings.view.navigation.groups.${n}`),a=r.map(e=>{let t=k===e.slug,n=Zm(e.slug);return!n&&e.slug!==`mcp`?null:(0,$.jsx)(En,{children:(0,$.jsx)(wn,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>ut(e.slug),"aria-current":t?`page`:void 0,className:K(C?`yuri-mobile-settings-row`:`flex h-8 w-full items-center gap-2 overflow-hidden rounded-md px-2 text-left`,t&&!C?`bg-interactive-selection text-foreground`:`text-foreground hover:bg-interactive-hover`),children:[e.slug===`mcp`?(0,$.jsx)(fi,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(X,{name:n,className:`h-4 w-4 shrink-0`}),(0,$.jsx)(`span`,{className:`flex min-w-0 flex-1 items-center gap-1.5 overflow-hidden whitespace-nowrap transition-opacity duration-150 opacity-100`,children:(0,$.jsx)(`span`,{className:`typography-ui-label font-normal truncate`,children:_t(e.slug)})}),e.slug===`plugins`&&(We>0||Ke)?(0,$.jsx)(`span`,{role:`img`,"aria-label":_(We>0?`settings.plugins.status.failed.title`:`settings.plugins.update.available.title`),"data-plugin-issue-badge":``,className:`size-1.5 shrink-0 rounded-full bg-[var(--status-error)]`}):null,C?(0,$.jsx)(X,{name:`arrow-right-s`,className:`size-4 shrink-0 text-muted-foreground/60`}):null]})})},e.slug)});return C?(0,$.jsx)(Lm,{label:i,ariaLabel:i,children:a},n):(0,$.jsxs)(`div`,{className:K(`space-y-0.5`,t>0&&`pt-3`),children:[(0,$.jsx)(`div`,{className:`px-2 pb-0.5 typography-micro font-medium text-muted-foreground/70`,children:i}),a]},n)})})})}),(0,$.jsx)(`div`,{className:K(`overflow-hidden transition-opacity duration-150 opacity-100`,C&&`yuri-mobile-settings-footer`),children:(0,$.jsx)(`div`,{className:K(`border-t-[0.5px] border-border/40 bg-sidebar px-2 py-1 space-y-0.5`,C&&`yuri-mobile-floating-surface yuri-mobile-settings-card`),children:!ze.isVSCode&&(0,$.jsxs)(q,{type:`button`,variant:`ghost`,size:`sm`,disabled:y.isPending,"aria-busy":y.isPending,className:K(C?`yuri-mobile-settings-row`:`w-full justify-start overflow-hidden`,`text-sm font-semibold text-sidebar-foreground/90`,`hover:text-sidebar-foreground hover:bg-interactive-hover`),onClick:x,children:[(0,$.jsx)(X,{name:`restart`,className:K(`h-4 w-4 shrink-0`,y.isPending&&`animate-spin`)}),(0,$.jsx)(`span`,{children:_(`settings.view.actions.reloadOpenCode`)})]})})})]})},Cn=()=>(0,$.jsx)(`div`,{className:K(`flex-1 min-h-0 overflow-hidden`,R?`w-full flex-none overflow-visible bg-transparent`:ze.isVSCode?`bg-background`:`bg-sidebar`),children:(0,$.jsx)(`div`,{className:K(`flex h-full min-h-0 flex-col`,R&&`h-auto w-full overflow-visible`),children:(0,$.jsx)(or,{children:Sn()})})}),Tn=e=>{let t=e===void 0?F:e;if(t===`nav`)return Cn();let n=K(`flex-1 min-h-0 overflow-hidden bg-transparent`,R?`w-full flex-none overflow-visible`:`px-[var(--yuri-mobile-page-inline-inset)]`);if(!ft)return(0,$.jsx)(`div`,{className:n});if(t===`page-sidebar`){if(ft.kind!==`split`){let e=Gt(k);return(0,$.jsx)(`div`,{className:n,children:(0,$.jsx)(Nm,{className:`yuri-mobile-settings-detail-card`,children:(0,$.jsx)(or,{children:e})})})}return(0,$.jsx)(`div`,{className:n,children:(0,$.jsx)(Nm,{className:`yuri-settings-sidebar yuri-mobile-settings-detail-card`,children:(0,$.jsx)(or,{children:Ht(k,{onItemSelect:ln})})})})}let r=Gt(k);return(0,$.jsx)(`div`,{className:n,children:(0,$.jsx)(Nm,{className:`yuri-mobile-settings-detail-card`,children:(0,$.jsx)(or,{children:r})})})},Dn;t[161]!==ft||t[162]!==ut||t[163]!==Gt||t[164]!==ze.isVSCode||t[165]!==k?(Dn=()=>!ft||k===`home`?(0,$.jsx)(Qm,{onOpen:ut}):k===`usage`?(0,$.jsx)(Sf,{children:(0,$.jsx)(or,{children:(0,$.jsx)(Wf,{})})}):ft.kind===`split`?(0,$.jsxs)(`div`,{className:`yuri-settings-entity-split flex h-full min-h-0 overflow-hidden`,children:[(0,$.jsx)(`div`,{className:K(`yuri-settings-sidebar yuri-settings-entity-list min-h-0 border-r-[0.5px] border-border/40`,ze.isVSCode?`bg-background`:`bg-sidebar`),children:(0,$.jsx)(or,{children:Ht(k,{})})}),(0,$.jsx)(`div`,{className:`flex-1 min-w-0 min-h-0 overflow-hidden bg-background`,children:(0,$.jsx)(or,{children:Gt(k)})})]}):(0,$.jsx)(`div`,{className:`h-full min-h-0 overflow-hidden bg-background`,children:(0,$.jsx)(or,{children:Gt(k)})}),t[161]=ft,t[162]=ut,t[163]=Gt,t[164]=ze.isVSCode,t[165]=k,t[166]=Dn):Dn=t[166];let On=Dn,kn=e=>{let t=e===void 0?F:e;return(0,$.jsx)(at,{sticky:!0,title:t===`nav`?_(`settings.view.home.title`):ft?_t(ft.slug):_(`settings.view.home.title`),backAriaLabel:rn,onBack:Zt?dn:n,trailing:t===`page-content`&&k===`assistants`?(0,$.jsx)(`div`,{ref:ie}):void 0,actions:[...tn?[{icon:`list-unordered`,ariaLabel:_(`settings.view.actions.openSectionList`),onClick:xn}]:[],...n?[{icon:`close`,ariaLabel:_(`settings.view.actions.closeSettings`),title:_(`settings.view.actions.closeSettingsWithShortcut`,{shortcut:an}),onClick:n}]:[]]})};if(R){let e=F!==`nav`,n=e&&ft?.kind===`split`,r=F===`page-content`,i=F===`page-sidebar`,a=r&&ft?.kind===`split`,o=e&&!a,s;t[167]===_?s=t[168]:(s=_(`mobile.settings.placeholder.title`),t[167]=_,t[168]=s);let c;return t[169]===s?c=t[170]:(c=(0,$.jsx)(Di,{title:s}),t[169]=s,t[170]=c),(0,$.jsxs)(`div`,{ref:_e,"data-settings-view":`true`,"data-mobile-settings-detail-active":e?`true`:void 0,className:`yuri-settings-workspace yuri-settings-workspace-mobile h-auto w-full min-w-0 overflow-visible bg-transparent`,children:[(0,$.jsxs)(`div`,{ref:ve,"data-mobile-settings-stage":`nav`,"data-mobile-navigation-underlay":o?`true`:void 0,"aria-hidden":e?`true`:void 0,inert:e?!0:void 0,className:`yuri-mobile-settings-root-surface fixed inset-0 z-20 flex h-[100dvh] w-full min-w-0 max-w-full flex-col gap-[var(--yuri-mobile-page-gap)] overflow-y-auto overflow-x-hidden overscroll-contain px-[var(--yuri-mobile-page-inline-inset)] pb-[calc(var(--yuri-mobile-dock-height)+2.5rem+var(--yuri-safe-area-bottom,env(safe-area-inset-bottom,0px)))] pt-[calc(var(--yuri-safe-area-top,env(safe-area-inset-top,0px))+1rem)] [contain:layout_paint]`,children:[c,Cn()]}),n?(0,$.jsxs)(`div`,{ref:ye,"data-mobile-settings-stage":`page-sidebar`,"data-mobile-navigation-underlay":a?`true`:void 0,"data-mobile-settings-push-surface":`true`,"aria-hidden":i?void 0:`true`,inert:!i||void 0,className:`fixed inset-0 z-40 flex h-[100dvh] w-full min-w-0 max-w-full touch-pan-y flex-col overflow-hidden bg-background [contain:layout_paint]`,children:[kn(`page-sidebar`),(0,$.jsx)(`div`,{className:`min-h-0 w-full flex-1 overflow-y-auto overflow-x-hidden overscroll-contain px-[var(--yuri-mobile-page-inline-inset)]`,children:Tn(`page-sidebar`)})]}):null,r?(0,$.jsxs)(`div`,{ref:be,"data-mobile-settings-stage":`page-content`,"data-mobile-settings-push-surface":`true`,className:`fixed inset-0 z-50 flex h-[100dvh] w-full min-w-0 max-w-full touch-pan-y flex-col overflow-hidden bg-background [contain:layout_paint]`,children:[kn(`page-content`),(0,$.jsx)(`div`,{className:`min-h-0 w-full flex-1 overflow-y-auto overflow-x-hidden overscroll-contain px-[var(--yuri-mobile-page-inline-inset)]`,children:Tn(`page-content`)})]}):null]})}let An=C?`yuri-settings-workspace-mobile bg-transparent`:`yuri-settings-workspace-desktop bg-background`,jn=R&&`h-auto w-full overflow-visible`,Mn;t[171]!==An||t[172]!==jn?(Mn=K(`yuri-settings-workspace relative flex h-full min-h-0 flex-col overflow-hidden`,An,jn),t[171]=An,t[172]=jn,t[173]=Mn):Mn=t[173];let Nn=C&&!L?kn():C?null:(0,$.jsxs)($.Fragment,{children:[Zt&&(0,$.jsx)(`div`,{className:K(`absolute left-3 z-50`,a?`top-2`:`top-3`),children:(0,$.jsx)(`button`,{type:`button`,onClick:dn,"aria-label":_(`settings.view.actions.back`),className:`inline-flex h-9 w-9 items-center justify-center rounded-lg p-2 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,children:(0,$.jsx)(X,{name:`arrow-left-s`,className:`h-5 w-5`})})}),n&&(0,$.jsx)(`div`,{className:K(`absolute right-0.5 z-50`,a?`top-0.5`:`top-1`),children:(0,$.jsx)(`button`,{type:`button`,onClick:n,"aria-label":_(`settings.view.actions.closeSettings`),title:_(`settings.view.actions.closeSettingsWithShortcut`,{shortcut:an}),className:`inline-flex h-7 w-7 items-center justify-center rounded-md p-0.5 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,children:(0,$.jsx)(X,{name:`close`,className:`h-5 w-5`})})})]}),Pn=R&&`w-full flex-none overflow-visible`,Fn;t[174]===Pn?Fn=t[175]:(Fn=K(`flex flex-1 min-h-0 overflow-hidden`,Pn),t[174]=Pn,t[175]=Fn);let In=C?Tn():(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:K(`relative flex h-full min-h-0 flex-col overflow-hidden border-r-[0.5px] border-border/40`,je?`bg-sidebar`:ze.isVSCode?`bg-background`:`bg-sidebar`,pe?``:`transition-[width,min-width] duration-200 ease-[cubic-bezier(0.25,0.1,0.25,1)]`),style:{width:`${te}px`,minWidth:`${te}px`},children:[(0,$.jsx)(`div`,{className:K(`absolute right-0 top-0 z-20 h-full w-[6px] -mr-[3px] cursor-col-resize`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,pe?`bg-primary/30`:`bg-transparent hover:bg-primary/20`),tabIndex:0,onPointerDown:nt,onKeyDown:it,role:`separator`,"aria-orientation":`vertical`,"aria-valuemin":zm,"aria-valuemax":Bm,"aria-valuenow":te,"aria-label":_(`settings.view.actions.resizeNavigation`)}),(0,$.jsx)(or,{children:Sn()})]}),(0,$.jsx)(`div`,{className:`yuri-settings-detail-pane flex-1 overflow-hidden bg-background`,children:On()})]}),Ln;t[176]!==Fn||t[177]!==In?(Ln=(0,$.jsx)(`div`,{className:Fn,children:In}),t[176]=Fn,t[177]=In,t[178]=Ln):Ln=t[178];let Rn;return t[179]!==Mn||t[180]!==Nn||t[181]!==Ln?(Rn=(0,$.jsxs)(`div`,{ref:_e,"data-settings-view":`true`,className:Mn,children:[Nn,Ln]}),t[179]=Mn,t[180]=Nn,t[181]=Ln,t[182]=Rn):Rn=t[182],Rn};function eh(e){return e.settingsPage}function th(e){return e.isSettingsDialogOpen}function nh(e){return e.setSettingsPage}function rh(e){return e.openSettingsRequestRevision}function ih(e){return e.slug!==`home`}function ah(e){return e.activeProjectId}function oh(e){return e.slug}function sh(e){return e.name}function ch(e){return e.name}function lh(e){return e.name}function uh(e){return e.name}function dh(e){if(e.id.startsWith(`assistants.`)){if(e.id===`assistants.default-share`){let t=en.getState(),n=et()?.assistants??[],r=n.some(e=>e.id===t.settingsSelectedAssistantID);return t.selectSettingsAssistant(r?t.settingsSelectedAssistantID:n[0]?.id??null),e.id}return en.getState().requestCreate(),e.id===`assistants.create`?`assistants.name`:e.id}if(e.id.startsWith(`agents.`)){let t=xt.getState(),n=Jm(`new-agent`,Ft().map(sh));return t.setAgentDraft({name:n,scope:`user`}),t.setSelectedAgent(n),e.id===`agents.create`?`agents.name`:e.id}if(e.id.startsWith(`commands.`)){let t=Xa.getState(),n=Jm(`new-command`,Lt().map(ch));return t.setCommandDraft({name:n,scope:`user`}),t.setSelectedCommand(n),e.id===`commands.create`?`commands.name`:e.id}if(e.id.startsWith(`mcp.`)){let t=no.getState(),n=Jm(`new-mcp-server`,zi().map(lh));return t.setMcpDraft({name:n,scope:`user`,type:`local`,command:[],url:``,environment:[],headers:[],oauthEnabled:!0,oauthClientId:``,oauthClientSecret:``,oauthScope:``,oauthRedirectUri:``,timeout:``,enabled:!0}),t.setSelectedMcp(n),e.id===`mcp.create`?`mcp.server`:e.id}if(e.id.startsWith(`skills.`)){let t=wt(Oe),n=so.getState(),r=Jm(`new-skill`,t.map(uh));return n.setSkillDraft({name:r,scope:`user`,source:`opencode`,description:``,instructions:``}),n.setSelectedSkill(r),e.id===`skills.create`?`skills.basic-information`:e.id}return e.id===`providers.connect`&&Pt.getState().setSelectedProvider(Wm),e.id===`plugins.create`?`plugins.spec`:e.id}function fh(){window.dispatchEvent(new CustomEvent(`yuri:settings-open-plugin-add`))}function ph(e,t){switch(e){case`projects`:return(0,$.jsx)(Gu,{onItemSelect:t.onItemSelect});case`agents`:return(0,$.jsx)(Ro,{onItemSelect:t.onItemSelect});case`assistants`:return(0,$.jsx)(ic,{onItemSelect:t.onItemSelect});case`commands`:return(0,$.jsx)(xc,{onItemSelect:t.onItemSelect});case`mcp`:return(0,$.jsx)(Mc,{onItemSelect:t.onItemSelect});case`plugins`:return(0,$.jsx)(Ll,{onItemSelect:t.onItemSelect});case`skills.installed`:return(0,$.jsx)(ru,{onItemSelect:t.onItemSelect});case`providers`:return(0,$.jsx)(mf,{onItemSelect:t.onItemSelect});case`usage`:return(0,$.jsx)(Sf,{onItemSelect:t.onItemSelect});case`magic-prompts`:return(0,$.jsx)(qf,{onItemSelect:t.onItemSelect});default:return null}}function mh(e){return e===`page-content`?`page-sidebar`:e}export{Im as a,no as c,Nm as i,Ga as l,Rm as n,Fm as o,Pm as r,ac as s,$m as t,Aa as u};
23
+ `)[0]}):e.scope===`project`?n(`settings.plugins.sidebar.group.projectFiles`):null,selected:a===e.id,onSelect:()=>M(e.id),icon:(0,$.jsx)(da,{name:e.fileName,fallback:`file-text`,busy:S,marker:i?.kind===`failed`?(0,$.jsx)(`span`,{className:`size-1.5 rounded-full bg-[var(--status-error)]`}):null})},e.id)},L=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[N.length>0||v?(0,$.jsxs)(q,{type:`button`,size:`xs`,"data-settings-item":`plugins.updateAll`,onClick:()=>void P(),"aria-busy":v,disabled:p||h.isFetching||v||S||C||x.size>0||N.length===0,"aria-label":n(`settings.plugins.sidebar.actions.updateAll`),title:n(`settings.plugins.sidebar.actions.updateAll`),children:[v?(0,$.jsx)(X,{name:`loader-4`,className:`size-3 animate-spin`,"aria-hidden":!0}):null,n(`settings.plugins.sidebar.actions.updateAll`)]}):null,(0,$.jsx)(q,{"data-settings-item":`plugins.create`,type:`button`,variant:`ghost`,size:`icon`,onClick:j,"aria-label":n(`settings.plugins.sidebar.actions.addTitle`),title:n(`settings.plugins.sidebar.actions.addTitle`),children:(0,$.jsx)(X,{name:`add`,className:`size-4`})})]});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(hs,{className:`yuri-plugin-collection`,variant:`background`,header:g?(0,$.jsxs)(`p`,{className:`typography-micro mb-2 flex items-center gap-1 text-muted-foreground`,role:`status`,children:[(0,$.jsx)(X,{name:`question`,className:`size-3 shrink-0`}),n(`settings.plugins.status.sidebar.unavailable`)]}):void 0,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2 px-1`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,$.jsx)(`h3`,{className:`typography-ui-label font-medium text-foreground`,children:n(`settings.plugins.sidebar.title`)}),S?(0,$.jsxs)(`span`,{className:`typography-micro text-muted-foreground/70`,role:`status`,children:[`· `,n(`settings.plugins.sidebar.reloading`)]}):k>0?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70`,children:k}):null]}),L]}),(0,$.jsx)(`div`,{className:`yuri-plugin-list`,children:C?(0,$.jsx)(Pl,{}):A?(0,$.jsxs)(`div`,{className:`yuri-settings-group-row py-8 text-center text-muted-foreground`,children:[(0,$.jsx)(X,{name:`plug`,className:`mx-auto mb-2 h-8 w-8 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-ui-label font-medium`,children:n(`settings.plugins.sidebar.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:n(`settings.plugins.sidebar.empty.description`)})]}):(0,$.jsxs)($.Fragment,{children:[D.map(F),O.map(I)]})})]}),(0,$.jsx)(pl,{open:w,onOpenChange:T})]})};function Rl(e){let t=(0,Sa.c)(36),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{pluginIds:r,disabled:i}=n,a=i!==void 0&&i,{host:o,snapshot:s,inventory:c,error:l,loading:u,requested:d,requestLoad:f,setEnabled:p,refresh:m}=Hr(),{t:h}=Ge(),[g,_]=Q.useState(null),[v,y]=Q.useState(null),b=g?.host===o?s.settings.find(e=>e.key===g?.key):void 0,x=!!b,S;t[2]===r?S=t[3]:(S=e=>!r||r.includes(e.id),t[2]=r,t[3]=S);let C=c.filter(S),w;t[4]===r?w=t[5]:(w=e=>!r||!!(e.pluginId&&r.includes(e.pluginId)),t[4]=r,t[5]=w);let T=w,E=s.commands.filter(T),D=s.panels.filter(T),O=s.menuItems.filter(T),k=s.settings.filter(T),A,j;t[6]!==f||t[7]!==d?(A=()=>{d||f()},j=[d,f],t[6]=f,t[7]=d,t[8]=A,t[9]=j):(A=t[8],j=t[9]),Q.useEffect(A,j);let M,N;t[10]!==o||t[11]!==g||t[12]!==x?(M=()=>{g&&(g.host!==o||!x)&&_(null)},N=[o,g,x],t[10]=o,t[11]=g,t[12]=x,t[13]=M,t[14]=N):(M=t[13],N=t[14]),Q.useEffect(M,N);let P;t[15]===s.plugins?P=t[16]:(P=new Map(s.plugins.map(zl)),t[15]=s.plugins,t[16]=P);let F=P,I;t[17]===h?I=t[18]:(I=async e=>{y(null);try{await e()}catch(e){let t=e;y(t instanceof Error?t.message:h(`guiPlugins.error`))}},t[17]=h,t[18]=I);let L=I,R=r?C.map(e=>{let t=F.get(e.id),n=e.error||t?.error,r=e.enabled&&!n&&t?.status===`active`;return(0,$.jsxs)(`div`,{className:`yuri-plugin-gui-control`,"data-gui-plugin-id":e.id,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-xs`,children:[(0,$.jsx)(`span`,{className:`shrink-0 text-foreground`,children:h(`guiPlugins.interface`)}),u&&e.enabled&&!n?(0,$.jsx)(X,{name:`loader-4`,className:`size-3 shrink-0 animate-spin text-muted-foreground`}):(0,$.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full ${n?`bg-[var(--status-error)]`:r?`bg-[var(--status-success)]`:`bg-muted-foreground/50`}`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0 truncate text-muted-foreground/80`,title:n||void 0,role:n?`alert`:`status`,children:n||h(e.enabled?r?`guiPlugins.active`:u?`common.loading`:`guiPlugins.pending`:`guiPlugins.off`)})]}),(0,$.jsx)(`p`,{className:`mt-0.5 text-[11px] text-muted-foreground/60`,children:h(`guiPlugins.interface.description`)})]}),(0,$.jsx)(ti,{checked:e.enabled,disabled:a||u,"aria-label":h(`guiPlugins.enable`,{id:e.id}),onCheckedChange:t=>void L(()=>p(e.id,t))})]},e.id)}):(0,$.jsxs)(Z,{label:h(`guiPlugins.title`),actions:(0,$.jsx)(q,{size:`sm`,disabled:u,onClick:()=>void L(m),children:h(`guiPlugins.refresh`)}),children:[u?(0,$.jsx)(Xi,{label:h(`common.loading`),children:(0,$.jsx)(`span`,{role:`status`,"aria-busy":!0})}):null,c.length===0&&!u?(0,$.jsx)(Xi,{label:h(`guiPlugins.empty`),children:null}):null,c.map(e=>{let t=F.get(e.id),n=e.error||t?.error;return(0,$.jsx)(Ji,{label:e.id,ariaLabel:h(`guiPlugins.enable`,{id:e.id}),checked:e.enabled,disabled:u,onChange:t=>void L(()=>p(e.id,t)),description:n?(0,$.jsx)(`span`,{role:`alert`,className:`text-[var(--status-error)]`,children:n}):h(e.enabled?t?.status===`active`?`guiPlugins.active`:t?.status===`failed`?`guiPlugins.failed`:`guiPlugins.pending`:`guiPlugins.disabled`)},e.id)})]}),z;t[19]!==v||t[20]!==l?(z=l||v?(0,$.jsx)(`div`,{role:`alert`,className:`text-[var(--status-error)]`,children:v||l}):null,t[19]=v,t[20]=l,t[21]=z):z=t[21];let B=E.length?(0,$.jsx)(Z,{label:h(`guiPlugins.commands`),children:E.map(e=>(0,$.jsx)(Xi,{label:e.title,description:e.description,children:(0,$.jsx)(q,{size:`sm`,disabled:!o,onClick:()=>void L(()=>o?.runCommand(e.key)),children:h(`guiPlugins.run`)})},e.key))}):null,V=D.length||O.length?(0,$.jsxs)(Z,{label:h(`guiPlugins.panels`),children:[O.map(e=>(0,$.jsx)(Xi,{label:e.title,description:e.description,children:(0,$.jsx)(q,{size:`sm`,disabled:!o,onClick:()=>void L(e.run),children:h(`guiPlugins.open`)})},`menu:${e.key}`)),D.map(e=>(0,$.jsx)(Xi,{label:e.title,children:(0,$.jsx)(q,{size:`sm`,disabled:!o,onClick:()=>void L(()=>o?.selectPanel(e.key)),children:h(`guiPlugins.open`)})},`panel:${e.key}`))]}):null,H=k.length?(0,$.jsx)(Z,{label:h(`guiPlugins.settings`),children:k.map(e=>(0,$.jsx)(Xi,{label:e.title,children:(0,$.jsx)(q,{size:`sm`,disabled:!o,onClick:()=>_({host:o,key:e.key}),children:h(`guiPlugins.open`)})},e.key))}):null,U=ya,W=!!(o&&b),ee=b?.title??h(`guiPlugins.settings`),te;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(te=()=>_(null),t[22]=te):te=t[22];let ne=o&&b?(0,$.jsx)(_a,{host:o,contributionKey:b.key,kind:`settings`,revision:va(s.plugins,b.pluginId)}):null,re;t[23]!==U||t[24]!==W||t[25]!==ee||t[26]!==te||t[27]!==ne?(re=(0,$.jsx)(U,{id:`gui-plugin-settings`,open:W,title:ee,onClose:te,children:ne}),t[23]=U,t[24]=W,t[25]=ee,t[26]=te,t[27]=ne,t[28]=re):re=t[28];let ie;return t[29]!==R||t[30]!==z||t[31]!==B||t[32]!==V||t[33]!==H||t[34]!==re?(ie=(0,$.jsxs)(`div`,{className:`yuri-settings-section-stack`,"data-plugin-gui-controls":!0,children:[R,z,B,V,H,re]}),t[29]=R,t[30]=z,t[31]=B,t[32]=V,t[33]=H,t[34]=re,t[35]=ie):ie=t[35],ie}function zl(e){return[e.id,e]}var Bl=e=>{let t=(0,Sa.c)(37),{spec:n}=e,{t:r}=Ge(),i;t[0]===n?i=t[1]:(i=[n],t[0]=n,t[1]=i);let{data:a}=Yi(i),o=a?.[n];if(!o||o.kind===`npm-ok`||o.kind===`path-ok`)return null;if(o.kind===`npm-network`){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(X,{name:`cloud-off`,className:`h-5 w-5 text-muted-foreground shrink-0 mt-0.5`}),t[2]=e):e=t[2];let n;t[3]===r?n=t[4]:(n=r(`settings.plugins.registry.badge.network.tooltip`),t[3]=r,t[4]=n);let i;return t[5]===n?i=t[6]:(i=(0,$.jsxs)(`div`,{className:`rounded-md border border-border bg-card p-3 flex items-start gap-3`,children:[e,(0,$.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground`,children:n})})]}),t[5]=n,t[6]=i),i}let s=o.kind===`path-unreadable`,c=s?`var(--status-warning)`:`var(--status-error)`,l=s?`alert`:`error-warning`,u;bb0:{switch(o.kind){case`npm-missing-version`:{let e;t[7]===r?e=t[8]:(e=r(`settings.plugins.registry.banner.invalid.missingVersion`),t[7]=r,t[8]=e),u=e;break bb0}case`npm-missing-package`:{let e;t[9]===r?e=t[10]:(e=r(`settings.plugins.registry.banner.invalid.missingPackage`),t[9]=r,t[10]=e),u=e;break bb0}case`npm-malformed`:{let e;t[11]===r?e=t[12]:(e=r(`settings.plugins.registry.banner.invalid.malformed`),t[11]=r,t[12]=e),u=e;break bb0}case`path-missing`:{let e;t[13]===r?e=t[14]:(e=r(`settings.plugins.registry.banner.invalid.pathMissing`),t[13]=r,t[14]=e),u=e;break bb0}case`path-unreadable`:{let e;t[15]===r?e=t[16]:(e=r(`settings.plugins.registry.banner.invalid.pathUnreadable`),t[15]=r,t[16]=e),u=e;break bb0}}u=void 0}let d=u,f;t[17]===c?f=t[18]:(f={color:c},t[17]=c,t[18]=f);let p;t[19]!==l||t[20]!==f?(p=(0,$.jsx)(X,{name:l,className:`h-5 w-5 shrink-0 mt-0.5`,style:f}),t[19]=l,t[20]=f,t[21]=p):p=t[21];let m;t[22]===c?m=t[23]:(m={color:c},t[22]=c,t[23]=m);let h;t[24]===r?h=t[25]:(h=r(`settings.plugins.registry.banner.invalid.title`),t[24]=r,t[25]=h);let g;t[26]!==m||t[27]!==h?(g=(0,$.jsx)(`p`,{className:`typography-label`,style:m,children:h}),t[26]=m,t[27]=h,t[28]=g):g=t[28];let _;t[29]===d?_=t[30]:(_=(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground mt-0.5`,children:d}),t[29]=d,t[30]=_);let v;t[31]!==g||t[32]!==_?(v=(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[g,_]}),t[31]=g,t[32]=_,t[33]=v):v=t[33];let y;return t[34]!==p||t[35]!==v?(y=(0,$.jsxs)(`div`,{className:`rounded-md border border-border bg-card p-3 flex items-start gap-3`,children:[p,v]}),t[34]=p,t[35]=v,t[36]=y):y=t[36],y};function Vl(e){let t=(0,Sa.c)(18),n=Qi(),r;t[0]===n?r=t[1]:(r=()=>{n.refetch()},t[0]=n,t[1]=r);let i=He(r),a;bb0:{if(n.isPending&&n.data===void 0){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e={kind:`loading`},t[2]=e):e=t[2],a=e;break bb0}if(n.data===void 0||!e){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e={kind:`unknown`},t[3]=e):e=t[3],a=e;break bb0}let r,i,o;if(t[4]!==n.data||t[5]!==e){let a=Qr(e,n.data);r=`known`,i=si(a),o=Ni(a),t[4]=n.data,t[5]=e,t[6]=r,t[7]=i,t[8]=o}else r=t[6],i=t[7],o=t[8];let s;t[9]!==r||t[10]!==i||t[11]!==o||t[12]!==e?(s={kind:r,load:i,update:o,target:e},t[9]=r,t[10]=i,t[11]=o,t[12]=e,t[13]=s):s=t[13],a=s}let o=a,s;return t[14]!==n.isFetching||t[15]!==i||t[16]!==o?(s={status:o,retry:i,isRefreshing:n.isFetching},t[14]=n.isFetching,t[15]=i,t[16]=o,t[17]=s):s=t[17],s}var Hl=2,Ul=e=>{let t=(0,Sa.c)(32),{error:n,reference:r}=e,{t:i}=Ge(),[a,o]=Q.useState(!1),s;t[0]===n?s=t[1]:(s=n.split(`
24
+ `),t[0]=n,t[1]=s);let c=s.length,l=c>Hl,u;t[2]!==n||t[3]!==i?(u=async()=>{(await We(n)).ok?J.success(i(`settings.plugins.status.failed.copied`)):J.error(i(`settings.plugins.status.failed.copyFailed`))},t[2]=n,t[3]=i,t[4]=u):u=t[4];let d=He(u),f=!a&&`line-clamp-2`,p;t[5]===f?p=t[6]:(p=K(`whitespace-pre-wrap break-all px-3 pt-2.5 font-mono text-[11px] leading-relaxed text-muted-foreground`,f),t[5]=f,t[6]=p);let m;t[7]!==n||t[8]!==p?(m=(0,$.jsx)(`pre`,{className:p,children:n}),t[7]=n,t[8]=p,t[9]=m):m=t[9];let h;t[10]!==r||t[11]!==i?(h=r?(0,$.jsx)(`p`,{className:`typography-micro px-3 pt-1 text-muted-foreground/70`,children:i(`settings.plugins.status.failed.ref`,{ref:r})}):null,t[10]=r,t[11]=i,t[12]=h):h=t[12];let g;t[13]!==a||t[14]!==l||t[15]!==c||t[16]!==i?(g=l?(0,$.jsx)(`button`,{type:`button`,className:`hover:text-foreground`,"aria-expanded":a,onClick:()=>o(Gl),children:a?i(`settings.plugins.status.failed.collapse`):i(`settings.plugins.status.failed.expand`,{count:c})}):(0,$.jsx)(`span`,{}),t[13]=a,t[14]=l,t[15]=c,t[16]=i,t[17]=g):g=t[17];let _;t[18]===d?_=t[19]:(_=()=>void d(),t[18]=d,t[19]=_);let v;t[20]===i?v=t[21]:(v=i(`settings.plugins.status.failed.copy`),t[20]=i,t[21]=v);let y;t[22]!==_||t[23]!==v?(y=(0,$.jsx)(`button`,{type:`button`,className:`hover:text-foreground`,onClick:_,children:v}),t[22]=_,t[23]=v,t[24]=y):y=t[24];let b;t[25]!==y||t[26]!==g?(b=(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-1.5 text-[11px] text-muted-foreground/70`,children:[g,y]}),t[25]=y,t[26]=g,t[27]=b):b=t[27];let x;return t[28]!==b||t[29]!==m||t[30]!==h?(x=(0,$.jsxs)(`div`,{className:`rounded-md border border-[var(--status-error-border)] bg-[var(--status-error-background)]`,role:`alert`,"data-plugin-load-state":`failed`,children:[m,h,b]}),t[28]=b,t[29]=m,t[30]=h,t[31]=x):x=t[31],x},Wl=e=>{let t=(0,Sa.c)(56),{target:n,name:r,latestVersion:i,entryId:a,registry:o}=e,s=i===void 0?null:i,{t:c}=Ge(),{status:l,retry:u,isRefreshing:d}=Vl(n),f=n?.kind===`package`?n.target:null,p=bl(f,a),m=Tl(),h=kl(),g=p.kind===`pending`||l.kind===`known`&&l.update===`updating`,_=o?.kind===`npm-ok`&&o.hasUpdate&&o.latestVersion?o:null,v=_?.latestVersion??s,y;t[0]!==a||t[1]!==_?(y=_&&a?{id:a,spec:`${_.name}@${_.latestVersion}`}:void 0,t[0]=a,t[1]=_,t[2]=y):y=t[2];let b=y,x;t[3]===u?x=t[4]:(x=()=>{u()},t[3]=u,t[4]=x);let S=He(x),C;t[5]!==g||t[6]!==r||t[7]!==f||t[8]!==h||t[9]!==b||t[10]!==m?(C=()=>{!f||g||h||m(f,r,b)},t[5]=g,t[6]=r,t[7]=f,t[8]=h,t[9]=b,t[10]=m,t[11]=C):C=t[11];let w=He(C),T;bb0:{if(l.kind===`loading`){T=null;break bb0}if(l.kind===`unknown`){let e;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(X,{name:`question`,className:`mt-0.5 h-5 w-5 shrink-0 text-muted-foreground`}),t[12]=e):e=t[12];let n;t[13]===c?n=t[14]:(n=c(`settings.plugins.status.unknown.title`),t[13]=c,t[14]=n);let r;t[15]===n?r=t[16]:(r=(0,$.jsx)(`p`,{className:`typography-label text-foreground`,children:n}),t[15]=n,t[16]=r);let i;t[17]===c?i=t[18]:(i=c(`settings.plugins.status.unknown.description`),t[17]=c,t[18]=i);let a;t[19]===i?a=t[20]:(a=(0,$.jsx)(`p`,{className:`typography-micro mt-0.5 text-muted-foreground`,children:i}),t[19]=i,t[20]=a);let o;t[21]!==a||t[22]!==r?(o=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[r,a]}),t[21]=a,t[22]=r,t[23]=o):o=t[23];let s;t[24]===c?s=t[25]:(s=c(`settings.plugins.status.retry`),t[24]=c,t[25]=s);let l;t[26]!==S||t[27]!==d||t[28]!==s?(l=(0,$.jsx)(q,{variant:`outline`,size:`sm`,onClick:S,disabled:d,children:s}),t[26]=S,t[27]=d,t[28]=s,t[29]=l):l=t[29];let u;t[30]!==o||t[31]!==l?(u=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3 rounded-md border border-border bg-card p-3`,role:`status`,"data-plugin-load-state":`unknown`,children:[e,o,l]}),t[30]=o,t[31]=l,t[32]=u):u=t[32],T=u;break bb0}let{load:e}=l;switch(e.kind){case`active`:T=null;break bb0;case`notReported`:{if(p.kind!==`idle`||h){T=null;break bb0}let e;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(X,{name:`loader-4`,className:`size-3 shrink-0 animate-spin`,"aria-hidden":!0}),t[33]=e):e=t[33];let n;t[34]===c?n=t[35]:(n=c(`settings.plugins.status.notReported.description`),t[34]=c,t[35]=n);let r;t[36]===n?r=t[37]:(r=(0,$.jsxs)(`div`,{className:`yuri-plugin-update-strip flex items-center gap-1.5 rounded-md border px-3 py-1.5 text-xs text-[var(--status-info)]`,role:`status`,"data-plugin-load-state":`notReported`,children:[e,(0,$.jsx)(`span`,{className:`min-w-0`,children:n})]}),t[36]=n,t[37]=r),T=r;break bb0}case`failed`:{let n;t[38]!==e.error||t[39]!==e.ref?(n=(0,$.jsx)(Ul,{error:e.error,reference:e.ref},e.error),t[38]=e.error,t[39]=e.ref,t[40]=n):n=t[40],T=n;break bb0}}T=void 0}let E=T,D=f!==null&&(l.kind===`known`&&l.update!==`none`||_!==null||p.kind!==`idle`);if(!E&&!D)return null;let O;t[41]!==w||t[42]!==g||t[43]!==h||t[44]!==D||t[45]!==c||t[46]!==v?(O=D?(0,$.jsxs)(`div`,{className:`yuri-plugin-update-strip relative overflow-hidden rounded-md border px-3 py-1.5`,"aria-busy":g,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 text-xs text-[var(--status-info)]`,role:g?`status`:void 0,children:[g?(0,$.jsx)(X,{name:`loader-4`,className:`size-3 shrink-0 animate-spin text-[var(--status-info)]`,"aria-hidden":!0}):(0,$.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-[var(--status-info)]`,"aria-hidden":!0}),g?v?c(`settings.plugins.update.running.toVersion`,{version:v}):c(`settings.plugins.update.running`):v?c(`settings.plugins.update.available.toVersion`,{version:v}):c(`settings.plugins.update.available.title`)]}),(0,$.jsx)(`button`,{type:`button`,className:`shrink-0 text-[11px] text-muted-foreground/70 hover:text-foreground disabled:opacity-50`,onClick:w,disabled:g||h,children:c(g?`settings.plugins.update.running`:`settings.plugins.update.action`)})]}),g?(0,$.jsx)(`div`,{className:`absolute inset-x-0 bottom-0 h-0.5 overflow-hidden`,"aria-hidden":!0,children:(0,$.jsx)(`div`,{className:`animate-indeterminate-slide h-full w-[30%] bg-[var(--status-info)] opacity-60`})}):null]}):null,t[41]=w,t[42]=g,t[43]=h,t[44]=D,t[45]=c,t[46]=v,t[47]=O):O=t[47];let k;t[48]!==p.error||t[49]!==p.kind||t[50]!==c?(k=p.kind===`error`?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`sr-only`,children:c(`settings.plugins.update.failed.title`)}),(0,$.jsx)(Ul,{error:p.error,reference:null},p.error)]}):null,t[48]=p.error,t[49]=p.kind,t[50]=c,t[51]=k):k=t[51];let A;return t[52]!==E||t[53]!==O||t[54]!==k?(A=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,"data-plugin-feedback":!0,children:[E,O,k]}),t[52]=E,t[53]=O,t[54]=k,t[55]=A):A=t[55],A};function Gl(e){return!e}function Kl(e,t){let n=kl(),{status:r}=Vl(e);return bl(e?.kind===`package`?e.target:null,t).kind===`pending`||r.kind===`known`&&r.update===`updating`?`updating`:n?`reloading`:null}function ql(e){let t=e.trim();if(t.length===0)return{ok:!0,value:void 0};try{let e=JSON.parse(t);return typeof e!=`object`||!e||Array.isArray(e)?{ok:!1}:{ok:!0,value:e}}catch{return{ok:!1}}}function Jl(e){return!e||Object.keys(e).length===0?``:JSON.stringify(e,null,2)}function Yl(e){return{mode:`entry`,scope:e.scope,spec:e.spec,optionsJson:Jl(e.options),fileName:``,content:``}}function Xl(e,t){return{mode:`file`,scope:e.scope,spec:``,optionsJson:``,fileName:e.fileName,content:t}}var Zl=e=>{let t=(0,Sa.c)(14),{name:n,version:r,icon:i,fallback:a}=e,o;t[0]!==a||t[1]!==i||t[2]!==n?(o=(0,$.jsx)(da,{name:n,src:i,fallback:a,size:28}),t[0]=a,t[1]=i,t[2]=n,t[3]=o):o=t[3];let s;t[4]===n?s=t[5]:(s=(0,$.jsx)(`h2`,{className:`truncate text-[13px] font-medium leading-tight text-foreground`,title:n,children:n}),t[4]=n,t[5]=s);let c;t[6]===r?c=t[7]:(c=r?(0,$.jsxs)(`div`,{className:`mt-0.5 font-mono text-[10px] leading-tight text-muted-foreground/70`,children:[`v`,r]}):null,t[6]=r,t[7]=c);let l;t[8]!==s||t[9]!==c?(l=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[s,c]}),t[8]=s,t[9]=c,t[10]=l):l=t[10];let u;return t[11]!==o||t[12]!==l?(u=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[o,l]}),t[11]=o,t[12]=l,t[13]=u):u=t[13],u},Ql=()=>{let{t:e}=Ge(),t=$i(e=>e.selectedId),n=Hr(),r=Hi(),i=Qi(),a=Q.useMemo(()=>r.data?.entries??[],[r.data?.entries]),o=Q.useMemo(()=>r.data?.files??[],[r.data?.files]),s=$i(e=>e.draft),c=$i(e=>e.setDraft),l=$i(e=>e.updateEntry),u=$i(e=>e.updateFile),d=$i(e=>e.readFile),f=$i(e=>e.deleteEntry),p=$i(e=>e.deleteFile),[m,h]=Q.useState(null),[g,_]=Q.useState(!1),v=t?a.find(e=>e.id===t):void 0,y=v?oi(v.spec,v.sourcePath):null,b=bl(y?.kind===`package`?y.target:null,t??void 0),x=b.kind===`idle`?void 0:b.entry,S=x?.original,C=S&&x?a.find(e=>e.spec===x.spec&&e.scope===S.scope&&e.sourcePath===S.sourcePath):void 0,w=v??C??(b.kind===`pending`?S:void 0)??null;Q.useEffect(()=>{C&&t===S?.id&&$i.getState().selectedId===t&&$i.getState().setSelected(C.id)},[C,t,S?.id]);let T=Q.useMemo(()=>t?o.find(e=>e.id===t)??null:null,[o,t]),E=Q.useMemo(()=>w?oi(w.spec,w.sourcePath):null,[w]),D=Q.useMemo(()=>T?ei(T.absolutePath):null,[T]),O=Kl(E??D,w?.id)!==null||g,k=gl(E??D,n.inventory).map(e=>e.id),A=k.length>0?(0,$.jsx)(`div`,{className:K(`transition-opacity`,O&&`opacity-40`),inert:O||void 0,children:(0,$.jsx)(Rl,{pluginIds:k,disabled:O},t)}):null,j=Ol(),M=j.isPending,N=()=>j.mutate(),P=Q.useMemo(()=>a.map(e=>e.spec),[a]),F=Yi(P),I=w?F.data?.[w.spec]:void 0,L=I&&`icon`in I?I.icon:void 0,[R,z]=Q.useState(!1),[B,V]=Q.useState(!1),H=Q.useRef(new Map),U=async()=>{if(!(!m||O||R||B)){_(!0);try{let t=await(m.kind===`entry`?f(m.id):p(m.id));if(!t.ok){J.error(t.message||e(`settings.plugins.sidebar.toast.deleteFailed`));return}h(null),t.reloadFailed?J.warning(t.message||e(`settings.plugins.toast.reloadFailed`),{description:t.warning}):J.success(e(`settings.plugins.sidebar.toast.deleted`,{name:m.name}))}finally{_(!1)}}},W=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(q,{variant:`ghost`,size:`icon`,"aria-label":e(`settings.common.actions.delete`),title:e(`settings.common.actions.delete`),disabled:O||R||B,onClick:()=>{w?h({kind:`entry`,id:w.id,name:w.spec}):T&&h({kind:`file`,id:T.id,name:T.fileName})},children:(0,$.jsx)(X,{name:`delete-bin`,className:`size-4`})}),(0,$.jsx)(gn,{open:m!==null,onOpenChange:e=>{!e&&!g&&h(null)},children:(0,$.jsxs)(pn,{className:`max-w-md`,children:[(0,$.jsxs)(dn,{children:[(0,$.jsx)(mn,{children:e(`settings.plugins.sidebar.deleteDialog.title`)}),(0,$.jsx)(hn,{children:e(`settings.plugins.sidebar.deleteDialog.description`,{name:m?.name??``})})]}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(q,{variant:`ghost`,size:`sm`,disabled:g,onClick:()=>h(null),children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(q,{variant:`destructive`,size:`sm`,disabled:O||R||B,"aria-busy":g,onClick:()=>void U(),children:e(g?`settings.plugins.sidebar.actions.deleting`:`settings.common.actions.delete`)})]})]})})]});Q.useEffect(()=>{let e=!1;return w?(c(Yl(w)),()=>{e=!0}):T?(V(!0),(async()=>{let t=await d(T.id);if(e)return;V(!1);let n=t?.content??``;H.current.set(T.id,n),c(Xl(T,n))})(),()=>{e=!0}):(c(null),()=>{e=!0})},[w,T,d,c]);let ee=(0,$.jsx)(Fl,{});if(r.isPending&&r.data===void 0)return ee;if(!t||!w&&!T)return(0,$.jsx)(jl,{children:(0,$.jsxs)(`div`,{className:`text-center text-muted-foreground`,children:[(0,$.jsx)(X,{name:`plug`,className:`mx-auto mb-3 h-12 w-12 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.plugins.page.empty.select`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:e(`settings.plugins.page.empty.add`)})]})});if(w&&s&&s.mode===`entry`){let t=ha(w.spec,w.parsedKind===`npm`),n=ql(s.optionsJson),r=n.ok,a=s.spec!==w.spec||s.optionsJson!==Jl(w.options),o=async()=>{if(!r||O)return;let t=s.spec.trim();if(!t){J.error(e(`settings.plugins.validation.specRequired`));return}z(!0);try{let r=await l(w.id,{spec:t,options:n.value});r.ok?r.reloadFailed?J.warning(r.message||e(`settings.plugins.toast.reloadFailed`),{description:r.warning}):J.success(r.message||e(`settings.plugins.toast.updated`)):J.error(r.message||e(`settings.plugins.toast.reloadFailed`))}finally{z(!1)}};return(0,$.jsxs)(jl,{className:`yuri-plugin-detail sm:pt-6`,children:[(0,$.jsx)(Gi,{className:`py-0`,actions:(0,$.jsxs)(`div`,{className:K(`flex flex-wrap items-center gap-1.5`,O&&`opacity-40`),children:[W,(0,$.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>void N(),disabled:M||R||O,children:e(`settings.plugins.page.action.reload`)}),(0,$.jsx)(q,{size:`sm`,onClick:()=>void o(),disabled:!a||!r||R||O,"aria-busy":R,children:e(`settings.plugins.page.action.save`)})]}),children:(0,$.jsx)(Zl,{name:t.name,version:E&&i.data?ri(Qr(E,i.data)):null,icon:L,fallback:w.parsedKind===`npm`?void 0:`folder`})}),(0,$.jsx)(Wl,{target:E,name:w.spec,latestVersion:I?.kind===`npm-ok`?I.latestVersion:null,entryId:w.id,registry:I}),(0,$.jsx)(Bl,{spec:w.spec}),A,(0,$.jsx)(`div`,{"data-settings-item":`plugins.spec`,className:K(`transition-opacity`,O&&`opacity-40`),inert:O||void 0,children:(0,$.jsx)(Z,{label:e(`settings.plugins.page.field.spec`),cardClassName:`contents`,children:(0,$.jsx)(Cn,{value:s.spec,"aria-label":e(`settings.plugins.page.field.spec`),onChange:e=>c({...s,spec:e.target.value}),placeholder:e(`settings.plugins.page.field.spec.placeholder`),className:`font-mono`,disabled:O,spellCheck:!1})})}),(0,$.jsx)(`div`,{"data-settings-item":`plugins.options`,className:K(`transition-opacity`,O&&`opacity-40`),inert:O||void 0,children:(0,$.jsx)(Z,{label:e(`settings.plugins.page.field.options`),description:r?void 0:e(`settings.plugins.page.field.options.invalidJson`),cardClassName:`overflow-hidden p-0`,children:(0,$.jsx)(ul,{value:s.optionsJson,onChange:e=>c({...s,optionsJson:e}),className:`h-[clamp(180px,32dvh,360px)]`,hasError:!r,ariaLabel:e(`settings.plugins.page.field.options`),placeholder:e(`settings.plugins.page.field.options.placeholder`),readOnly:O})})})]})}if(T&&s&&s.mode===`file`){let t=H.current.get(T.id)??``,n=s.content!==t||s.fileName!==T.fileName,r=async()=>{if(!O){z(!0);try{let t=await u(T.id,{content:s.content});t.ok?(H.current.set(T.id,s.content),t.reloadFailed?J.warning(t.message||e(`settings.plugins.toast.reloadFailed`),{description:t.warning}):J.success(t.message||e(`settings.plugins.toast.updated`))):J.error(t.message||e(`settings.plugins.toast.reloadFailed`))}finally{z(!1)}}};return(0,$.jsxs)(jl,{className:`yuri-plugin-detail sm:pt-6`,children:[(0,$.jsx)(Gi,{className:`py-0`,actions:(0,$.jsxs)(`div`,{className:K(`flex flex-wrap items-center gap-1.5`,O&&`opacity-40`),children:[W,(0,$.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>void N(),disabled:M||R||O,children:e(`settings.plugins.page.action.reload`)}),(0,$.jsx)(q,{size:`sm`,onClick:()=>void r(),disabled:!n||R||B||O,"aria-busy":R,children:e(`settings.plugins.page.action.save`)})]}),children:(0,$.jsx)(Zl,{name:T.fileName,version:null,fallback:`file-text`})}),(0,$.jsx)(Wl,{target:D,name:T.fileName}),A,(0,$.jsx)(`div`,{"data-settings-item":`plugins.content`,className:K(`transition-opacity`,O&&`opacity-40`),inert:O||void 0,children:(0,$.jsx)(Z,{label:e(`settings.plugins.page.field.content`),cardClassName:`p-3`,children:(0,$.jsx)(Wr,{embedded:!0,value:s.content,"aria-label":e(`settings.plugins.page.field.content`),onChange:e=>c({...s,content:e.target.value}),rows:16,className:`font-mono typography-meta min-h-[320px]`,spellCheck:!1,disabled:B})})})]})}return ee};async function $l(e,t){let n=await e.json().catch(()=>null);return typeof n?.error==`string`&&n.error.trim()?n.error:t}function eu(){let{t:e}=Ge(),[t,n]=Q.useState(null),[r,i]=Q.useState(``),[a,o]=Q.useState(``),[s,c]=Q.useState(``),[u,d]=Q.useState(!0),[f,p]=Q.useState(!1),m=He(async()=>{d(!0);try{let t=await l(`/api/config/global/opencode`);if(!t.ok)throw Error(await $l(t,e(`settings.globalConfig.toast.loadFailed`)));let n=await t.json(),r=typeof n.content==`string`?n.content:``;i(r),o(r),c(typeof n.fileName==`string`?n.fileName:``)}catch(t){i(``),o(``),c(``),J.error(t instanceof Error?t.message:e(`settings.globalConfig.toast.loadFailed`))}finally{d(!1)}});return Q.useEffect(()=>{let t=!1;return(async()=>{d(!0);try{let r=await l(`/api/config/global`);if(!r.ok)throw Error(await $l(r,e(`settings.globalConfig.toast.loadFailed`)));let i=await r.json(),a=Array.isArray(i.targets)&&i.targets.some(e=>e&&typeof e==`object`&&e.target===`opencode`&&typeof e.fileName==`string`);if(t)return;n(a?`opencode`:null)}catch(r){t||(n(null),J.error(r instanceof Error?r.message:e(`settings.globalConfig.toast.loadFailed`)))}finally{t||d(!1)}})(),()=>{t=!0}},[e]),Q.useEffect(()=>{t&&m()},[m,t,e]),(0,$.jsx)(Ur,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsx)(`div`,{className:`yuri-settings-page-content mx-auto w-full max-w-4xl px-3 pt-3 pb-0 sm:px-6 sm:pt-8`,children:(0,$.jsx)(Z,{itemId:`global-config.editor`,actions:t?(0,$.jsx)(q,{onClick:async()=>{if(t){p(!0);try{let n=await l(`/api/config/global/${t}`,{method:`PUT`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({content:r})});if(!n.ok)throw Error(await $l(n,e(`settings.globalConfig.toast.saveFailed`)));let a=await n.json(),s=typeof a.content==`string`?a.content:r;i(s),o(s),J.success(e(`settings.globalConfig.toast.saved`))}catch(t){J.error(t instanceof Error?t.message:e(`settings.globalConfig.toast.saveFailed`))}finally{p(!1)}}},disabled:u||f||r===a,size:`sm`,"aria-busy":f,children:e(f?`settings.common.actions.saving`:`settings.common.actions.saveChanges`)}):void 0,label:e(`settings.globalConfig.title`),children:t?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3 px-3 py-1`,children:[(0,$.jsx)(`span`,{className:`typography-meta truncate text-muted-foreground`,children:s}),(0,$.jsx)(q,{variant:`ghost`,size:`xs`,onClick:()=>void m(),disabled:u||f,children:e(`settings.globalConfig.actions.reload`)})]}),(0,$.jsx)(`div`,{className:`h-[clamp(520px,75dvh,960px)] overflow-hidden bg-background`,children:(0,$.jsx)(ul,{value:r,onChange:i,readOnly:u,fileName:s||`opencode.json`,ariaLabel:s||`opencode.json`,className:`h-full`})})]}):(0,$.jsx)(`div`,{className:`min-h-12`,"aria-busy":u})})})})}var tu=`<built-in>`,nu=e=>e?.path===tu,ru=e=>{let t=(0,Sa.c)(172),{onItemSelect:n}=e,{t:r}=Ge(),[i,a]=Q.useState(null),[o,s]=Q.useState(``),[c,l]=Q.useState(null),[u,d]=Q.useState(!1),[f,p]=Q.useState(null),{selectedSkillName:m,setSelectedSkill:h,setSkillDraft:g,createSkill:_,deleteSkill:v,getSkillDetail:y}=so(ne(au)),b=Tt(),x;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(x=St(),t[0]=x):x=t[0];let S=x,C;t[1]===b.data?C=t[2]:(C=b.data??[],t[1]=b.data,t[2]=C);let w=C,T;t[3]!==n||t[4]!==h||t[5]!==g||t[6]!==w?(T=()=>{let e=`new-skill`,t=1;for(;w.some(t=>t.name===e);)e=`new-skill-${t}`,t++;g({name:e,scope:`user`,source:`opencode`,description:``}),h(e),n?.()},t[3]=n,t[4]=h,t[5]=g,t[6]=w,t[7]=T):T=t[7];let E=T,D;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(D=async e=>{nu(e)||l(e)},t[8]=D):D=t[8];let O=D,k;t[9]!==c||t[10]!==v||t[11]!==r?(k=async()=>{if(c){if(nu(c)){l(null);return}d(!0),await v(c.name,{directory:S})?(J.success(r(`settings.skills.sidebar.toast.skillDeleted`,{name:c.name})),l(null)):J.error(r(`settings.skills.sidebar.toast.deleteSkillFailed`)),d(!1)}},t[9]=c,t[10]=v,t[11]=r,t[12]=k):k=t[12];let A=k,j;t[13]!==y||t[14]!==h||t[15]!==g||t[16]!==w||t[17]!==r?(j=async e=>{if(nu(e))return;let t=e.name,n=1,i=`${t}-copy`;for(;w.some(e=>e.name===i);)n++,i=`${t}-copy-${n}`;let a=await y(e.name);if(!a){J.error(r(`settings.skills.sidebar.toast.duplicateLoadFailed`));return}g({name:i,scope:e.scope||`user`,source:e.source||`opencode`,description:(a.sources.md.fields.includes(`description`),``),instructions:``}),h(i)},t[13]=y,t[14]=h,t[15]=g,t[16]=w,t[17]=r,t[18]=j):j=t[18];let M=j,N;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(N=e=>{nu(e)||(s(e.name),a(e))},t[19]=N):N=t[19];let P=N,F;t[20]!==_||t[21]!==v||t[22]!==y||t[23]!==i||t[24]!==o||t[25]!==h||t[26]!==w||t[27]!==r?(F=async()=>{if(!i)return;if(nu(i)){a(null);return}let e=o.trim().replace(/\s+/g,`-`).toLowerCase();if(!e){J.error(r(`settings.skills.page.toast.skillNameRequired`));return}if(e===i.name){a(null);return}if(w.some(t=>t.name===e)){J.error(r(`settings.skills.page.toast.skillExists`));return}if(!await y(i.name)){J.error(r(`settings.skills.sidebar.toast.renameLoadFailed`)),a(null);return}await _({name:e,description:`Renamed skill`,scope:i.scope,source:i.source},{directory:S})?await v(i.name,{directory:S})?(J.success(`Skill renamed to "${e}"`),h(e)):J.error(r(`settings.skills.sidebar.toast.removeOldAfterRenameFailed`)):J.error(r(`settings.skills.sidebar.toast.renameFailed`)),a(null)},t[20]=_,t[21]=v,t[22]=y,t[23]=i,t[24]=o,t[25]=h,t[26]=w,t[27]=r,t[28]=F):F=t[28];let I=F,L;t[29]===w?L=t[30]:(L=w.filter(ou),t[29]=w,t[30]=L);let R=L,z;t[31]===w?z=t[32]:(z=w.filter(su),t[31]=w,t[32]=z);let B=z,V;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(V=function(e){let t={},n=[];for(let r of e)r.group?(t[r.group]||(t[r.group]=[]),t[r.group].push(r)):n.push(r);let r=Object.keys(t).sort(cu).map(e=>({name:e,skills:[...t[e]].sort(lu)}));return n.sort(uu),{sortedGroups:r,ungrouped:n}},t[33]=V):V=t[33];let H=V,U;t[34]===R?U=t[35]:(U=H(R),t[34]=R,t[35]=U);let W=U,ee;t[36]===B?ee=t[37]:(ee=H(B),t[36]=B,t[37]=ee);let te=ee,re;t[38]===r?re=t[39]:(re=r(`settings.skills.sidebar.section.project`),t[38]=r,t[39]=re);let ie=re,ae;t[40]===r?ae=t[41]:(ae=r(`settings.skills.sidebar.section.user`),t[40]=r,t[41]=ae);let oe=ae,se;t[42]===ie?se=t[43]:(se=(0,$.jsx)(`span`,{children:ie}),t[42]=ie,t[43]=se);let ce;t[44]===r?ce=t[45]:(ce=r(`settings.skills.page.title.newSkill`),t[44]=r,t[45]=ce);let le;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,$.jsx)(X,{name:`add`,className:`h-4 w-4`}),t[46]=le):le=t[46];let ue;t[47]!==E||t[48]!==ce?(ue=(0,$.jsx)(q,{"data-settings-item":`skills.create`,size:`icon`,variant:`ghost`,"aria-label":ce,onClick:E,children:le}),t[47]=E,t[48]=ce,t[49]=ue):ue=t[49];let de;t[50]!==se||t[51]!==ue?(de=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[se,ue]}),t[50]=se,t[51]=ue,t[52]=de):de=t[52];let G=de,fe;t[53]!==M||t[54]!==n||t[55]!==f||t[56]!==m||t[57]!==h?(fe=e=>(0,$.jsx)(iu,{skill:e,isSelected:m===e.name,onSelect:()=>{h(e.name),n?.()},onRename:()=>P(e),onDelete:()=>O(e),onDuplicate:()=>M(e),isMenuOpen:f===e.name,onMenuOpenChange:t=>p(t?e.name:null)},e.name),t[53]=M,t[54]=n,t[55]=f,t[56]=m,t[57]=h,t[58]=fe):fe=t[58];let pe=fe,me,he;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(me=K(`yuri-settings-page-content h-full overflow-y-auto p-3`,`bg-background`),he=(0,$.jsx)(To,{}),t[59]=me,t[60]=he):(me=t[59],he=t[60]);let ge;t[61]!==w.length||t[62]!==r?(ge=w.length===0?(0,$.jsx)(Z,{children:(0,$.jsxs)(`div`,{className:`yuri-settings-group-row py-12 text-center text-muted-foreground`,children:[(0,$.jsx)(X,{name:`book-open`,className:`mx-auto mb-3 h-10 w-10 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-ui-label font-medium`,children:r(`settings.skills.sidebar.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:r(`settings.skills.sidebar.empty.description`)})]})}):null,t[61]=w.length,t[62]=r,t[63]=ge):ge=t[63];let _e;t[64]!==W.ungrouped||t[65]!==G||t[66]!==pe?(_e=W.ungrouped.length>0?(0,$.jsx)(Z,{label:G,children:W.ungrouped.map(pe)}):(0,$.jsx)(Z,{label:G,cardClassName:`hidden`,children:(0,$.jsx)(`span`,{})}),t[64]=W.ungrouped,t[65]=G,t[66]=pe,t[67]=_e):_e=t[67];let ve;if(t[68]!==W.sortedGroups||t[69]!==ie||t[70]!==pe){let e;t[72]!==ie||t[73]!==pe?(e=e=>{let{name:t,skills:n}=e;return(0,$.jsx)(Mo,{label:t,labelPrefix:ie,count:n.length,storageKey:`project-skills`,variant:`settings-card`,children:n.map(pe)},t)},t[72]=ie,t[73]=pe,t[74]=e):e=t[74],ve=W.sortedGroups.map(e),t[68]=W.sortedGroups,t[69]=ie,t[70]=pe,t[71]=ve}else ve=t[71];let ye;t[75]!==te.ungrouped||t[76]!==pe||t[77]!==oe?(ye=te.ungrouped.length>0?(0,$.jsx)(Z,{label:oe,children:te.ungrouped.map(pe)}):null,t[75]=te.ungrouped,t[76]=pe,t[77]=oe,t[78]=ye):ye=t[78];let be;if(t[79]!==te.sortedGroups||t[80]!==pe||t[81]!==oe){let e;t[83]!==pe||t[84]!==oe?(e=e=>{let{name:t,skills:n}=e;return(0,$.jsx)(Mo,{label:t,labelPrefix:oe,count:n.length,storageKey:`user-skills`,variant:`settings-card`,children:n.map(pe)},t)},t[83]=pe,t[84]=oe,t[85]=e):e=t[85],be=te.sortedGroups.map(e),t[79]=te.sortedGroups,t[80]=pe,t[81]=oe,t[82]=be}else be=t[82];let xe=c!==null,Se;t[86]===u?Se=t[87]:(Se=e=>{!e&&!u&&l(null)},t[86]=u,t[87]=Se);let Ce;t[88]===r?Ce=t[89]:(Ce=r(`settings.skills.sidebar.deleteDialog.title`),t[88]=r,t[89]=Ce);let we;t[90]===Ce?we=t[91]:(we=(0,$.jsx)(mn,{children:Ce}),t[90]=Ce,t[91]=we);let Te=c?.name??``,Ee;t[92]!==r||t[93]!==Te?(Ee=r(`settings.skills.sidebar.deleteDialog.description`,{name:Te}),t[92]=r,t[93]=Te,t[94]=Ee):Ee=t[94];let De;t[95]===Ee?De=t[96]:(De=(0,$.jsx)(hn,{children:Ee}),t[95]=Ee,t[96]=De);let Oe;t[97]!==we||t[98]!==De?(Oe=(0,$.jsxs)(dn,{children:[we,De]}),t[97]=we,t[98]=De,t[99]=Oe):Oe=t[99];let ke;t[100]===Symbol.for(`react.memo_cache_sentinel`)?(ke=()=>l(null),t[100]=ke):ke=t[100];let Ae;t[101]===r?Ae=t[102]:(Ae=r(`settings.common.actions.cancel`),t[101]=r,t[102]=Ae);let je;t[103]!==u||t[104]!==Ae?(je=(0,$.jsx)(q,{size:`sm`,className:`text-foreground hover:bg-interactive-hover hover:text-foreground`,variant:`ghost`,onClick:ke,disabled:u,children:Ae}),t[103]=u,t[104]=Ae,t[105]=je):je=t[105];let Me;t[106]===r?Me=t[107]:(Me=r(`settings.common.actions.delete`),t[106]=r,t[107]=Me);let Ne;t[108]!==A||t[109]!==u||t[110]!==Me?(Ne=(0,$.jsx)(q,{size:`sm`,onClick:A,disabled:u,children:Me}),t[108]=A,t[109]=u,t[110]=Me,t[111]=Ne):Ne=t[111];let Pe;t[112]!==je||t[113]!==Ne?(Pe=(0,$.jsxs)(fn,{children:[je,Ne]}),t[112]=je,t[113]=Ne,t[114]=Pe):Pe=t[114];let Fe;t[115]!==Oe||t[116]!==Pe?(Fe=(0,$.jsxs)(pn,{className:`max-w-md`,children:[Oe,Pe]}),t[115]=Oe,t[116]=Pe,t[117]=Fe):Fe=t[117];let Ie;t[118]!==xe||t[119]!==Se||t[120]!==Fe?(Ie=(0,$.jsx)(gn,{open:xe,onOpenChange:Se,children:Fe}),t[118]=xe,t[119]=Se,t[120]=Fe,t[121]=Ie):Ie=t[121];let Le=i!==null,Re;t[122]===Symbol.for(`react.memo_cache_sentinel`)?(Re=e=>!e&&a(null),t[122]=Re):Re=t[122];let ze;t[123]===r?ze=t[124]:(ze=r(`settings.skills.sidebar.renameDialog.title`),t[123]=r,t[124]=ze);let Be;t[125]===ze?Be=t[126]:(Be=(0,$.jsx)(mn,{children:ze}),t[125]=ze,t[126]=Be);let Ve=i?.name??``,He;t[127]!==r||t[128]!==Ve?(He=r(`settings.skills.sidebar.renameDialog.description`,{name:Ve}),t[127]=r,t[128]=Ve,t[129]=He):He=t[129];let Ue;t[130]===He?Ue=t[131]:(Ue=(0,$.jsx)(hn,{children:He}),t[130]=He,t[131]=Ue);let We;t[132]!==Be||t[133]!==Ue?(We=(0,$.jsxs)(dn,{children:[Be,Ue]}),t[132]=Be,t[133]=Ue,t[134]=We):We=t[134];let Ke;t[135]===Symbol.for(`react.memo_cache_sentinel`)?(Ke=e=>s(e.target.value),t[135]=Ke):Ke=t[135];let qe;t[136]===r?qe=t[137]:(qe=r(`settings.skills.sidebar.renameDialog.placeholder`),t[136]=r,t[137]=qe);let Je;t[138]===I?Je=t[139]:(Je=e=>{e.key===`Enter`&&I()},t[138]=I,t[139]=Je);let Ye;t[140]!==o||t[141]!==qe||t[142]!==Je?(Ye=(0,$.jsx)(Cn,{value:o,onChange:Ke,placeholder:qe,className:`text-foreground placeholder:text-muted-foreground`,onKeyDown:Je}),t[140]=o,t[141]=qe,t[142]=Je,t[143]=Ye):Ye=t[143];let Xe;t[144]===Symbol.for(`react.memo_cache_sentinel`)?(Xe=()=>a(null),t[144]=Xe):Xe=t[144];let Ze;t[145]===r?Ze=t[146]:(Ze=r(`settings.common.actions.cancel`),t[145]=r,t[146]=Ze);let Qe;t[147]===Ze?Qe=t[148]:(Qe=(0,$.jsx)(q,{size:`sm`,className:`text-foreground hover:bg-interactive-hover hover:text-foreground`,variant:`ghost`,onClick:Xe,children:Ze}),t[147]=Ze,t[148]=Qe);let $e;t[149]===r?$e=t[150]:($e=r(`settings.common.actions.rename`),t[149]=r,t[150]=$e);let et;t[151]!==I||t[152]!==$e?(et=(0,$.jsx)(q,{size:`sm`,onClick:I,children:$e}),t[151]=I,t[152]=$e,t[153]=et):et=t[153];let tt;t[154]!==Qe||t[155]!==et?(tt=(0,$.jsxs)(fn,{children:[Qe,et]}),t[154]=Qe,t[155]=et,t[156]=tt):tt=t[156];let nt;t[157]!==We||t[158]!==Ye||t[159]!==tt?(nt=(0,$.jsxs)(pn,{children:[We,Ye,tt]}),t[157]=We,t[158]=Ye,t[159]=tt,t[160]=nt):nt=t[160];let rt;t[161]!==Le||t[162]!==nt?(rt=(0,$.jsx)(gn,{open:Le,onOpenChange:Re,children:nt}),t[161]=Le,t[162]=nt,t[163]=rt):rt=t[163];let it;return t[164]!==ge||t[165]!==_e||t[166]!==ve||t[167]!==ye||t[168]!==be||t[169]!==Ie||t[170]!==rt?(it=(0,$.jsxs)(`div`,{className:me,children:[he,ge,_e,ve,ye,be,Ie,rt]}),t[164]=ge,t[165]=_e,t[166]=ve,t[167]=ye,t[168]=be,t[169]=Ie,t[170]=rt,t[171]=it):it=t[171],it},iu=e=>{let t=(0,Sa.c)(51),{skill:n,isSelected:r,onSelect:i,onDelete:a,onRename:o,onDuplicate:s,isMenuOpen:c,onMenuOpenChange:l}=e,{t:u}=Ge(),d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=Cr(),t[0]=d):d=t[0];let f=d,p;t[1]!==n.source||t[2]!==u?(p=n.source===`claude`?u(`settings.skills.sidebar.badge.claude`):n.source===`agents`?u(`settings.skills.sidebar.badge.agents`):u(`settings.skills.sidebar.badge.opencode`),t[1]=n.source,t[2]=u,t[3]=p):p=t[3];let m=p,h;t[4]===n?h=t[5]:(h=nu(n),t[4]=n,t[5]=h);let g=h,[_,v]=Q.useState(!1),y;t[6]!==a||t[7]!==s||t[8]!==o||t[9]!==u?(y=e=>(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),o()},children:[(0,$.jsx)(X,{name:`edit`,className:`h-4 w-4 mr-px`}),u(`settings.common.actions.rename`)]}),(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),s()},children:[(0,$.jsx)(X,{name:`file-copy`,className:`h-4 w-4 mr-px`}),u(`settings.common.actions.duplicate`)]}),(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),a()},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(X,{name:`delete-bin`,className:`h-4 w-4 mr-px`}),u(`settings.common.actions.delete`)]})]}),t[6]=a,t[7]=s,t[8]=o,t[9]=u,t[10]=y):y=t[10];let b=y,x=!g&&_,S=r?`bg-interactive-selection`:`hover:bg-interactive-hover`,C;t[11]===S?C=t[12]:(C=K(`yuri-settings-group-row group relative flex items-center transition-colors duration-150 select-none`,S),t[11]=S,t[12]=C);let w;t[13]===g?w=t[14]:(w=!f&&!g?e=>{e.preventDefault(),v(!0)}:void 0,t[13]=g,t[14]=w);let T;t[15]!==C||t[16]!==w?(T=(0,$.jsx)(`div`,{className:C,onContextMenu:w}),t[15]=C,t[16]=w,t[17]=T):T=t[17];let E;t[18]===n.name?E=t[19]:(E=(0,$.jsx)(`span`,{className:`typography-ui-label font-normal whitespace-normal [overflow-wrap:anywhere] text-foreground`,children:n.name}),t[18]=n.name,t[19]=E);let D;t[20]===n.scope?D=t[21]:(D=(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-[var(--surface-muted)] px-1 rounded flex-shrink-0 leading-none pb-px border border-[var(--interactive-border)]/50`,children:n.scope}),t[20]=n.scope,t[21]=D);let O;t[22]===m?O=t[23]:(O=(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-[var(--surface-muted)] px-1 rounded flex-shrink-0 leading-none pb-px border border-[var(--interactive-border)]/50`,children:m}),t[22]=m,t[23]=O);let k;t[24]!==D||t[25]!==O?(k=(0,$.jsxs)(`span`,{className:`flex flex-wrap items-center gap-1.5`,children:[D,O]}),t[24]=D,t[25]=O,t[26]=k):k=t[26];let A;t[27]!==E||t[28]!==k?(A=(0,$.jsxs)(`div`,{className:`flex min-w-0 max-w-full flex-col items-start gap-1.5`,children:[E,k]}),t[27]=E,t[28]=k,t[29]=A):A=t[29];let j;t[30]!==i||t[31]!==A?(j=(0,$.jsx)(`button`,{onClick:i,className:`flex min-w-0 flex-1 flex-col gap-0 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,tabIndex:0,children:A}),t[30]=i,t[31]=A,t[32]=j):j=t[32];let M;t[33]!==g||t[34]!==c||t[35]!==l||t[36]!==b?(M=g?null:(0,$.jsxs)($n,{open:c,onOpenChange:e=>{e&&v(!1),l(e)},children:[(0,$.jsx)(fr,{asChild:!0,children:(0,$.jsx)(q,{size:`sm`,variant:`ghost`,className:`h-6 w-6 px-0 flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100`,children:(0,$.jsx)(X,{name:`more-2`,className:`h-3.5 w-3.5`})})}),(0,$.jsx)(Zn,{align:`end`,className:`w-fit min-w-20`,children:b(tr)})]}),t[33]=g,t[34]=c,t[35]=l,t[36]=b,t[37]=M):M=t[37];let N;t[38]!==j||t[39]!==M?(N=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:[j,M]}),t[38]=j,t[39]=M,t[40]=N):N=t[40];let P;t[41]!==N||t[42]!==T?(P=(0,$.jsx)(na,{render:T,children:N}),t[41]=N,t[42]=T,t[43]=P):P=t[43];let F;t[44]!==g||t[45]!==b?(F=g?null:(0,$.jsx)(ra,{className:`w-fit min-w-20`,children:b(ia)}),t[44]=g,t[45]=b,t[46]=F):F=t[46];let I;return t[47]!==P||t[48]!==F||t[49]!==x?(I=(0,$.jsxs)(aa,{open:x,onOpenChange:v,children:[P,F]}),t[47]=P,t[48]=F,t[49]=x,t[50]=I):I=t[50],I};function au(e){return{selectedSkillName:e.selectedSkillName,setSelectedSkill:e.setSelectedSkill,setSkillDraft:e.setSkillDraft,createSkill:e.createSkill,deleteSkill:e.deleteSkill,getSkillDetail:e.getSkillDetail}}function ou(e){return e.scope===`project`}function su(e){return e.scope===`user`}function cu(e,t){return e.localeCompare(t)}function lu(e,t){return e.name.localeCompare(t.name)}function uu(e,t){return e.name.localeCompare(t.name)}var du=()=>{let e=oe.getDirectory();if(typeof e==`string`&&e.trim().length>0)return e;try{let e=window.__zustand_directory_store__;if(e)return e.getState().currentDirectory}catch{}return null},fu=W()(te(e=>({selectedSourceId:vt[0]?.id??null,isScanning:!1,isInstalling:!1,lastScanError:null,lastInstallError:null,scanResults:null,setSelectedSource:t=>e({selectedSourceId:t}),scanRepo:async(t,n)=>{e({isScanning:!0,lastScanError:null,scanResults:null});try{let r=n&&Object.prototype.hasOwnProperty.call(n,`directory`)?typeof n?.directory==`string`&&n.directory.trim()||null:du(),i=r?`?directory=${encodeURIComponent(r)}`:``,a=await l(`/api/config/skills/scan${i}`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(t)}),o=await a.json().catch(()=>null);if(!a.ok||!o){let t=o?.error||{kind:`unknown`,message:`Failed to scan repository`};return e({lastScanError:t}),{ok:!1,error:t}}return o.ok?(e({scanResults:o.items||[]}),o):(e({lastScanError:o.error||{kind:`unknown`,message:`Failed to scan repository`}}),o)}finally{e({isScanning:!1})}},installSkills:async(t,n)=>{let r=n&&Object.prototype.hasOwnProperty.call(n,`directory`)?typeof n?.directory==`string`&&n.directory.trim()||null:du(),a=n?.transportIdentity??i();if(i()!==a)return{ok:!1,error:{kind:`unknown`,message:`Failed to install skills`}};e({isInstalling:!0,lastInstallError:null});try{let n=r?`?directory=${encodeURIComponent(r)}`:``,o=await l(`/api/config/skills/install${n}`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(t)}),s=await o.json().catch(()=>null);if(!s){let t={kind:`unknown`,message:`Failed to install skills`};return e({lastInstallError:t}),{ok:!1,error:t}}if(!o.ok||!s.ok){let t=s.error||{kind:`unknown`,message:`Failed to install skills`};return e({lastInstallError:t}),{ok:!1,error:t}}return i()===a?(await wt(Oe,r,a),i()===a&&await jt(Oe,r,a),s):s}catch(t){let n={kind:`unknown`,message:t instanceof Error?t.message:String(t)};return e({lastInstallError:n}),{ok:!1,error:n}}finally{e({isInstalling:!1})}}}),{name:`skills-catalog-store`})),pu=()=>`custom:${Date.now()}-${Math.random().toString(16).slice(2)}`,mu=e=>{let t=e.trim(),n=t.startsWith(`https://`)?`https`:t.startsWith(`git@`)?`ssh`:`shorthand`;if(n===`ssh`)return`${t.split(`:`)[1].replace(/\.git$/i,``)}`;if(n===`https`)return t.split(`/`).slice(3).filter(Boolean).join(`/`).replace(/\.git$/i,``);let r=t.match(/^([^/\s]+)\/([^/\s]+)(?:\/.+)?$/);return r?`${r[1]}/${r[2].replace(/\.git$/i,``)}`:t},hu=async()=>{try{let e=A()?.settings;if(e)return(await e.load())?.settings||{};let t=await l(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});return t.ok?await t.json().catch(()=>null):null}catch{return null}},gu=e=>{let t=(0,Sa.c)(158),{open:n,onOpenChange:r}=e,{t:a}=Ge(),o=fu(_u),s=fu(vu),c=fu(yu),l=ji(bu),u=ji(xu),[d,f]=Q.useState(``),[p,m]=Q.useState(``),[h,_]=Q.useState(``),v;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(v=[],t[0]=v):v=t[0];let[y,b]=Q.useState(v),[x,S]=Q.useState(null),[C,w]=Q.useState(!1),T;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(T=[],t[1]=T):T=t[1];let[E,D]=Q.useState(T),[O,k]=Q.useState(null),A=Q.useRef(0),j=Q.useRef(null),M;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(M=e=>{A.current+=1,w(!1),S(null),j.current=null,e?.clearIdentity&&(D([]),k(null))},t[2]=M):M=t[2];let N=M,P,F;t[3]!==u||t[4]!==n?(P=()=>{n&&(A.current+=1,f(``),m(``),_(``),S(null),w(!1),j.current=null,D([]),k(null),u(),(async()=>{let e=await hu(),t=Array.isArray(e?.skillCatalogs)?e?.skillCatalogs:[];b(t||[])})())},F=[n,u],t[3]=u,t[4]=n,t[5]=P,t[6]=F):(P=t[5],F=t[6]),Q.useEffect(P,F);let I;t[7]===p?I=t[8]:(I=p.trim(),t[7]=p,t[8]=I);let L=I,R;t[9]===h?R=t[10]:(R=h.trim(),t[9]=h,t[10]=R);let z=R,B;if(t[11]!==y||t[12]!==L||t[13]!==z){let e;t[15]!==L||t[16]!==z?(e=e=>{let t=(e.source||``).trim(),n=(e.subpath||``).trim();return t===L&&n===z},t[15]=L,t[16]=z,t[17]=e):e=t[17],B=y.some(e),t[11]=y,t[12]=L,t[13]=z,t[14]=B}else B=t[14];let V=B,H;t[18]!==l||t[19]!==O||t[20]!==d||t[21]!==o||t[22]!==p||t[23]!==h||t[24]!==a?(H=async()=>{let e=p.trim();if(!e){J.error(a(`settings.skills.catalog.add.toast.repositoryRequired`));return}d.trim()||f(mu(e)),w(!1),S(null);let t=A.current+1;A.current=t;let n=Kt(),r=i(),s=await o({source:e,subpath:h.trim()||void 0,gitIdentityId:O||void 0},{directory:n});if(A.current!==t||i()!==r||Kt()!==n)return;if(!s.ok){if(s.error?.kind===`authRequired`){if(g()){J.error(a(`settings.skills.catalog.shared.toast.privateRepoNotSupportedVsCode`));return}let e=s.error.identities||[];if(D(e),!O&&e.length>0){let t=l&&l!==`global`&&e.some(e=>e.id===l)?l:e[0].id;k(t)}J.error(a(`settings.skills.catalog.add.toast.authenticationRequiredScan`));return}J.error(s.error?.message||a(`settings.skills.catalog.add.toast.scanFailed`));return}let c=s.items?.length||0;if(S(c),c===0){J.error(a(`settings.skills.catalog.add.toast.noSkillsFound`)),w(!1);return}D([]),w(!0),j.current={directory:n,transport:r},J.success(a(`settings.skills.catalog.shared.toast.foundSkills`,{count:c}))},t[18]=l,t[19]=O,t[20]=d,t[21]=o,t[22]=p,t[23]=h,t[24]=a,t[25]=H):H=t[25];let U=H,W;t[26]!==y||t[27]!==O||t[28]!==V||t[29]!==d||t[30]!==r||t[31]!==C||t[32]!==s||t[33]!==p||t[34]!==h||t[35]!==a?(W=async()=>{let e=d.trim(),t=p.trim(),n=h.trim();if(!e){J.error(a(`settings.skills.catalog.add.toast.catalogNameRequired`));return}if(!t){J.error(a(`settings.skills.catalog.add.toast.repositoryRequired`));return}let o=Kt(),c=i();if(!C||j.current?.directory!==o||j.current?.transport!==c){w(!1),j.current=null,J.error(a(`settings.skills.catalog.add.toast.scanBeforeAdd`));return}if(V){J.error(a(`settings.skills.catalog.add.toast.catalogAlreadyExists`));return}let l={id:pu(),label:e,source:t,...n?{subpath:n}:{},...O?{gitIdentityId:O}:{}},u=[...y,l],f=Kt(),m=i();try{await ye({skillCatalogs:u}),b(u),J.success(a(`settings.skills.catalog.add.toast.catalogAdded`)),await Oe.invalidateQueries({queryKey:[m,`skillsCatalog`,`sources`],exact:!1}),await zt(Oe,f,m),await Xt(Oe,f,l.id,m),i()===m&&(s(l.id),r(!1))}catch(e){let t=e;J.error(t instanceof Error?t.message:a(`settings.skills.catalog.add.toast.saveFailed`))}},t[26]=y,t[27]=O,t[28]=V,t[29]=d,t[30]=r,t[31]=C,t[32]=s,t[33]=p,t[34]=h,t[35]=a,t[36]=W):W=t[36];let ee=W,te;t[37]===a?te=t[38]:(te=a(`settings.skills.catalog.add.title`),t[37]=a,t[38]=te);let ne;t[39]===te?ne=t[40]:(ne=(0,$.jsx)(mn,{children:te}),t[39]=te,t[40]=ne);let re;t[41]===a?re=t[42]:(re=a(`settings.skills.catalog.add.descriptionPrefix`),t[41]=a,t[42]=re);let ie;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,$.jsx)(`code`,{className:`font-mono`,children:`SKILL.md`}),t[43]=ie):ie=t[43];let ae;t[44]===a?ae=t[45]:(ae=a(`settings.skills.catalog.add.descriptionSuffix`),t[44]=a,t[45]=ae);let oe;t[46]!==re||t[47]!==ae?(oe=(0,$.jsxs)(hn,{children:[re,` `,ie,ae]}),t[46]=re,t[47]=ae,t[48]=oe):oe=t[48];let se;t[49]!==ne||t[50]!==oe?(se=(0,$.jsxs)(dn,{children:[ne,oe]}),t[49]=ne,t[50]=oe,t[51]=se):se=t[51];let ce;t[52]===a?ce=t[53]:(ce=a(`settings.skills.catalog.add.field.catalogName`),t[52]=a,t[53]=ce);let le;t[54]===ce?le=t[55]:(le=(0,$.jsx)(`label`,{className:`typography-ui-label text-foreground`,children:ce}),t[54]=ce,t[55]=le);let ue;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(ue=e=>f(e.target.value),t[56]=ue):ue=t[56];let de;t[57]===a?de=t[58]:(de=a(`settings.skills.catalog.add.field.catalogNamePlaceholder`),t[57]=a,t[58]=de);let G;t[59]!==d||t[60]!==de?(G=(0,$.jsx)(Cn,{value:d,onChange:ue,placeholder:de}),t[59]=d,t[60]=de,t[61]=G):G=t[61];let fe;t[62]!==le||t[63]!==G?(fe=(0,$.jsxs)(`div`,{className:`space-y-2`,children:[le,G]}),t[62]=le,t[63]=G,t[64]=fe):fe=t[64];let pe;t[65]===a?pe=t[66]:(pe=a(`settings.skills.catalog.add.field.repository`),t[65]=a,t[66]=pe);let me;t[67]===pe?me=t[68]:(me=(0,$.jsx)(`label`,{className:`typography-ui-label text-foreground`,children:pe}),t[67]=pe,t[68]=me);let he;t[69]===Symbol.for(`react.memo_cache_sentinel`)?(he=e=>{m(e.target.value),N({clearIdentity:!0})},t[69]=he):he=t[69];let ge;t[70]===a?ge=t[71]:(ge=a(`settings.skills.catalog.shared.field.repositoryPlaceholder`),t[70]=a,t[71]=ge);let _e;t[72]!==p||t[73]!==ge?(_e=(0,$.jsx)(Cn,{value:p,onChange:he,placeholder:ge}),t[72]=p,t[73]=ge,t[74]=_e):_e=t[74];let ve;t[75]===a?ve=t[76]:(ve=a(`settings.skills.catalog.add.field.repositoryHint`),t[75]=a,t[76]=ve);let be;t[77]===ve?be=t[78]:(be=(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground`,children:ve}),t[77]=ve,t[78]=be);let xe;t[79]!==me||t[80]!==_e||t[81]!==be?(xe=(0,$.jsxs)(`div`,{className:`space-y-2`,children:[me,_e,be]}),t[79]=me,t[80]=_e,t[81]=be,t[82]=xe):xe=t[82];let Se;t[83]===a?Se=t[84]:(Se=a(`settings.skills.catalog.add.field.optionalSubpath`),t[83]=a,t[84]=Se);let Ce;t[85]===Se?Ce=t[86]:(Ce=(0,$.jsx)(`label`,{className:`typography-ui-label text-foreground`,children:Se}),t[85]=Se,t[86]=Ce);let we;t[87]===Symbol.for(`react.memo_cache_sentinel`)?(we=e=>{_(e.target.value),N({clearIdentity:!0})},t[87]=we):we=t[87];let Te;t[88]===a?Te=t[89]:(Te=a(`settings.skills.catalog.shared.field.subpathPlaceholder`),t[88]=a,t[89]=Te);let Ee;t[90]!==h||t[91]!==Te?(Ee=(0,$.jsx)(Cn,{value:h,onChange:we,placeholder:Te}),t[90]=h,t[91]=Te,t[92]=Ee):Ee=t[92];let De;t[93]!==Ce||t[94]!==Ee?(De=(0,$.jsxs)(`div`,{className:`space-y-2`,children:[Ce,Ee]}),t[93]=Ce,t[94]=Ee,t[95]=De):De=t[95];let ke;t[96]!==O||t[97]!==E||t[98]!==a?(ke=E.length>0&&!g()?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-[var(--status-warning)]`,children:a(`settings.skills.catalog.shared.auth.title`)}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground ml-2`,children:a(`settings.skills.catalog.shared.auth.description`)})]}),(0,$.jsxs)(Fr,{value:O||``,onValueChange:e=>{k(e),N()},children:[(0,$.jsx)(Pr,{className:`w-fit`,children:(0,$.jsx)(`span`,{children:E.find(e=>e.id===O)?.name||a(`settings.skills.catalog.shared.auth.chooseIdentity`)})}),(0,$.jsx)(Nr,{align:`start`,children:E.map(Su)})]}),(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground`,children:a(`settings.skills.catalog.shared.auth.footerHint`)})]}):null,t[96]=O,t[97]=E,t[98]=a,t[99]=ke):ke=t[99];let Ae;t[100]!==x||t[101]!==a?(Ae=x===null?null:(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:a(`settings.skills.catalog.add.scanResult`,{count:x})}),t[100]=x,t[101]=a,t[102]=Ae):Ae=t[102];let je;t[103]!==V||t[104]!==a?(je=V?(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:a(`settings.skills.catalog.add.duplicateMessage`)}):null,t[103]=V,t[104]=a,t[105]=je):je=t[105];let Me;t[106]!==fe||t[107]!==xe||t[108]!==De||t[109]!==ke||t[110]!==Ae||t[111]!==je?(Me=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[fe,xe,De,ke,Ae,je]}),t[106]=fe,t[107]=xe,t[108]=De,t[109]=ke,t[110]=Ae,t[111]=je,t[112]=Me):Me=t[112];let Ne;t[113]===r?Ne=t[114]:(Ne=()=>r(!1),t[113]=r,t[114]=Ne);let Pe;t[115]===a?Pe=t[116]:(Pe=a(`settings.common.actions.cancel`),t[115]=a,t[116]=Pe);let Fe;t[117]!==Ne||t[118]!==Pe?(Fe=(0,$.jsx)(q,{size:`sm`,variant:`ghost`,onClick:Ne,children:Pe}),t[117]=Ne,t[118]=Pe,t[119]=Fe):Fe=t[119];let Ie;t[120]===U?Ie=t[121]:(Ie=()=>void U(),t[120]=U,t[121]=Ie);let Le;t[122]!==c||t[123]!==p?(Le=c||!p.trim(),t[122]=c,t[123]=p,t[124]=Le):Le=t[124];let Re;t[125]===Symbol.for(`react.memo_cache_sentinel`)?(Re=(0,$.jsx)(X,{name:`git-repository`,className:`h-4 w-4`}),t[125]=Re):Re=t[125];let ze;t[126]!==c||t[127]!==a?(ze=a(c?`settings.skills.catalog.shared.actions.scanning`:`settings.skills.catalog.shared.actions.scan`),t[126]=c,t[127]=a,t[128]=ze):ze=t[128];let Be;t[129]!==Ie||t[130]!==Le||t[131]!==ze?(Be=(0,$.jsxs)(q,{size:`sm`,className:`gap-2`,variant:`ghost`,onClick:Ie,disabled:Le,children:[Re,ze]}),t[129]=Ie,t[130]=Le,t[131]=ze,t[132]=Be):Be=t[132];let Ve;t[133]===ee?Ve=t[134]:(Ve=()=>void ee(),t[133]=ee,t[134]=Ve);let He;t[135]!==V||t[136]!==d||t[137]!==C||t[138]!==p?(He=!C||V||!d.trim()||!p.trim(),t[135]=V,t[136]=d,t[137]=C,t[138]=p,t[139]=He):He=t[139];let Ue;t[140]===a?Ue=t[141]:(Ue=a(`settings.skills.catalog.add.actions.addCatalog`),t[140]=a,t[141]=Ue);let We;t[142]!==Ve||t[143]!==He||t[144]!==Ue?(We=(0,$.jsx)(q,{size:`sm`,onClick:Ve,disabled:He,children:Ue}),t[142]=Ve,t[143]=He,t[144]=Ue,t[145]=We):We=t[145];let Ke;t[146]!==Fe||t[147]!==Be||t[148]!==We?(Ke=(0,$.jsxs)(fn,{children:[Fe,Be,We]}),t[146]=Fe,t[147]=Be,t[148]=We,t[149]=Ke):Ke=t[149];let qe;t[150]!==se||t[151]!==Me||t[152]!==Ke?(qe=(0,$.jsxs)(pn,{className:`max-w-xl`,children:[se,Me,Ke]}),t[150]=se,t[151]=Me,t[152]=Ke,t[153]=qe):qe=t[153];let Je;return t[154]!==r||t[155]!==n||t[156]!==qe?(Je=(0,$.jsx)(gn,{open:n,onOpenChange:r,children:qe}),t[154]=r,t[155]=n,t[156]=qe,t[157]=Je):Je=t[157],Je};function _u(e){return e.scanRepo}function vu(e){return e.setSelectedSource}function yu(e){return e.isScanning}function bu(e){return e.defaultGitIdentityId}function xu(e){return e.loadDefaultGitIdentityId}function Su(e){return(0,$.jsx)(jr,{value:e.id,children:e.name},e.id)}var Cu=e=>{let t=(0,Sa.c)(85),{open:n,onOpenChange:r,conflicts:i,onConfirm:a}=e,{t:o}=Ge(),s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s={},t[0]=s):s=t[0];let[c,l]=Q.useState(s),u,d;t[1]!==i||t[2]!==n?(u=()=>{if(!n)return;let e={};for(let t of i)e[t.skillName]=`skip`;l(e)},d=[n,i],t[1]=i,t[2]=n,t[3]=u,t[4]=d):(u=t[3],d=t[4]),Q.useEffect(u,d);let f;t[5]===i?f=t[6]:(f=e=>{let t={};for(let n of i)t[n.skillName]=e;l(t)},t[5]=i,t[6]=f);let p=f,m;t[7]!==i||t[8]!==c?(m=i.length>0&&i.every(e=>c[e.skillName]),t[7]=i,t[8]=c,t[9]=m):m=t[9];let h=m,g;t[10]===o?g=t[11]:(g=o(`settings.skills.catalog.conflicts.title`),t[10]=o,t[11]=g);let _;t[12]===g?_=t[13]:(_=(0,$.jsx)(mn,{children:g}),t[12]=g,t[13]=_);let v;t[14]===o?v=t[15]:(v=o(`settings.skills.catalog.conflicts.description`),t[14]=o,t[15]=v);let y;t[16]===v?y=t[17]:(y=(0,$.jsx)(hn,{children:v}),t[16]=v,t[17]=y);let b;t[18]!==_||t[19]!==y?(b=(0,$.jsxs)(dn,{children:[_,y]}),t[18]=_,t[19]=y,t[20]=b):b=t[20];let x;t[21]!==i.length||t[22]!==o?(x=o(`settings.skills.catalog.conflicts.count`,{count:i.length}),t[21]=i.length,t[22]=o,t[23]=x):x=t[23];let S;t[24]===x?S=t[25]:(S=(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:x}),t[24]=x,t[25]=S);let C;t[26]===p?C=t[27]:(C=()=>p(`skip`),t[26]=p,t[27]=C);let w;t[28]===o?w=t[29]:(w=o(`settings.skills.catalog.conflicts.actions.skipAll`),t[28]=o,t[29]=w);let T;t[30]!==C||t[31]!==w?(T=(0,$.jsx)(q,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:C,children:w}),t[30]=C,t[31]=w,t[32]=T):T=t[32];let E;t[33]===p?E=t[34]:(E=()=>p(`overwrite`),t[33]=p,t[34]=E);let D;t[35]===o?D=t[36]:(D=o(`settings.skills.catalog.conflicts.actions.overwriteAll`),t[35]=o,t[36]=D);let O;t[37]!==E||t[38]!==D?(O=(0,$.jsx)(q,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:E,children:D}),t[37]=E,t[38]=D,t[39]=O):O=t[39];let k;t[40]!==T||t[41]!==O?(k=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[T,O]}),t[40]=T,t[41]=O,t[42]=k):k=t[42];let A;t[43]!==S||t[44]!==k?(A=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[S,k]}),t[43]=S,t[44]=k,t[45]=A):A=t[45];let j;if(t[46]!==i||t[47]!==c||t[48]!==o){let e;t[50]!==c||t[51]!==o?(e=e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-1.5`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label truncate`,children:e.skillName}),(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground`,children:o(`settings.skills.catalog.conflicts.installedIn`,{scope:e.scope===`project`?o(`settings.skills.catalog.conflicts.scope.project`):o(`settings.skills.catalog.conflicts.scope.user`),source:e.source===`agents`?o(`settings.skills.catalog.conflicts.source.agents`):o(`settings.skills.catalog.conflicts.source.opencode`)})})]}),(0,$.jsxs)(Fr,{value:c[e.skillName]||`skip`,onValueChange:t=>l(n=>({...n,[e.skillName]:t})),children:[(0,$.jsx)(Pr,{className:`w-fit`,children:(0,$.jsx)(`span`,{className:`capitalize`,children:(c[e.skillName]||`skip`)===`overwrite`?o(`settings.skills.catalog.conflicts.decision.overwrite`):o(`settings.skills.catalog.conflicts.decision.skip`)})}),(0,$.jsxs)(Nr,{align:`end`,children:[(0,$.jsx)(jr,{value:`skip`,className:`pr-2 [&>span:first-child]:hidden`,children:o(`settings.skills.catalog.conflicts.decision.skip`)}),(0,$.jsx)(jr,{value:`overwrite`,className:`pr-2 [&>span:first-child]:hidden`,children:o(`settings.skills.catalog.conflicts.decision.overwrite`)})]})]})]},e.skillName),t[50]=c,t[51]=o,t[52]=e):e=t[52],j=i.map(e),t[46]=i,t[47]=c,t[48]=o,t[49]=j}else j=t[49];let M;t[53]===j?M=t[54]:(M=(0,$.jsx)(`div`,{className:`space-y-2`,children:j}),t[53]=j,t[54]=M);let N;t[55]!==A||t[56]!==M?(N=(0,$.jsxs)(`div`,{className:`space-y-3`,children:[A,M]}),t[55]=A,t[56]=M,t[57]=N):N=t[57];let P;t[58]===r?P=t[59]:(P=()=>r(!1),t[58]=r,t[59]=P);let F;t[60]===o?F=t[61]:(F=o(`settings.common.actions.cancel`),t[60]=o,t[61]=F);let I;t[62]!==P||t[63]!==F?(I=(0,$.jsx)(q,{size:`sm`,variant:`ghost`,onClick:P,children:F}),t[62]=P,t[63]=F,t[64]=I):I=t[64];let L;t[65]!==c||t[66]!==a?(L=()=>a(c),t[65]=c,t[66]=a,t[67]=L):L=t[67];let R=!h,z;t[68]===o?z=t[69]:(z=o(`settings.skills.catalog.conflicts.actions.continue`),t[68]=o,t[69]=z);let B;t[70]!==L||t[71]!==R||t[72]!==z?(B=(0,$.jsx)(q,{size:`sm`,onClick:L,disabled:R,children:z}),t[70]=L,t[71]=R,t[72]=z,t[73]=B):B=t[73];let V;t[74]!==I||t[75]!==B?(V=(0,$.jsxs)(fn,{children:[I,B]}),t[74]=I,t[75]=B,t[76]=V):V=t[76];let H;t[77]!==b||t[78]!==N||t[79]!==V?(H=(0,$.jsxs)(pn,{className:`max-w-2xl`,children:[b,N,V]}),t[77]=b,t[78]=N,t[79]=V,t[80]=H):H=t[80];let U;return t[81]!==r||t[82]!==n||t[83]!==H?(U=(0,$.jsx)(gn,{open:n,onOpenChange:r,children:H}),t[81]=r,t[82]=n,t[83]=H,t[84]=U):U=t[84],U},wu=[{value:`user-opencode`,scope:`user`,source:`opencode`,label:`User / OpenCode`,description:`Global OpenCode config location`},{value:`project-opencode`,scope:`project`,source:`opencode`,label:`Project / OpenCode`,description:`Current project .opencode location`},{value:`user-agents`,scope:`user`,source:`agents`,label:`User / Agents`,description:`Global .agents compatibility location`},{value:`project-agents`,scope:`project`,source:`agents`,label:`Project / Agents`,description:`Current project .agents compatibility location`}];function Tu(e,t){return e===`project`&&t===`claude`?`project-claude`:e===`project`&&t===`agents`?`project-agents`:t===`claude`?`user-claude`:e===`project`?`project-opencode`:t===`agents`?`user-agents`:`user-opencode`}function Eu(e){if(e===`user-claude`)return{scope:`user`,source:`claude`};if(e===`project-claude`)return{scope:`project`,source:`claude`};let t=wu.find(t=>t.value===e);return t?{scope:t.scope,source:t.source}:{scope:`user`,source:`opencode`}}var Du=e=>{let t=(0,Sa.c)(124),{open:n,onOpenChange:r,item:a}=e,{t:o}=Ge(),s=fu(Ou),c=fu(ku),[l,u]=Q.useState(`user`),[d,f]=Q.useState(`opencode`),p=Y(Au),m=Y(ju),[h,g]=Q.useState(null),[_,v]=Q.useState(!1),y;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(y=[],t[0]=y):y=t[0];let[b,x]=Q.useState(y),[S,C]=Q.useState(null),w,T;t[1]!==m||t[2]!==n?(w=()=>{n&&(u(`user`),f(`opencode`),g(m),v(!1),x([]),C(null))},T=[n,m],t[1]=m,t[2]=n,t[3]=w,t[4]=T):(w=t[3],T=t[4]),Q.useEffect(w,T);let E;t[5]===o?E=t[6]:(E=e=>{switch(e){case`project-opencode`:return o(`settings.skills.location.option.projectOpencode.label`);case`user-agents`:return o(`settings.skills.location.option.userAgents.label`);case`project-agents`:return o(`settings.skills.location.option.projectAgents.label`);default:return o(`settings.skills.location.option.userOpencode.label`)}},t[5]=o,t[6]=E);let D=E,O;t[7]===o?O=t[8]:(O=e=>{switch(e){case`project-opencode`:return o(`settings.skills.location.option.projectOpencode.description`);case`user-agents`:return o(`settings.skills.location.option.userAgents.description`);case`project-agents`:return o(`settings.skills.location.option.projectAgents.description`);default:return o(`settings.skills.location.option.userOpencode.description`)}},t[7]=o,t[8]=O);let k=O,A;bb0:{if(p.length===0){A=null;break bb0}if(h&&p.some(e=>e.id===h)){A=h;break bb0}if(m&&p.some(e=>e.id===m)){A=m;break bb0}A=p[0]?.id??null}let j=A,M;bb1:{if(l!==`project`){M=null;break bb1}let e=j;if(!e){M=null;break bb1}let n;if(t[9]!==e||t[10]!==p){let r;t[12]===e?r=t[13]:(r=t=>t.id===e,t[12]=e,t[13]=r),n=p.find(r),t[9]=e,t[10]=p,t[11]=n}else n=t[11];M=n?.path??null}let N=M,P;t[14]!==s||t[15]!==a||t[16]!==r||t[17]!==o?(P=async e=>{let t={skillDir:e.skillDir};a?.clawdhub&&(t.clawdhub={slug:a.clawdhub.slug,version:a.clawdhub.version});let n=await s({source:e.source,subpath:e.subpath,gitIdentityId:a?.gitIdentityId,scope:e.scope,targetSource:e.targetSource,selections:[t],conflictPolicy:`prompt`,conflictDecisions:e.conflictDecisions},{directory:e.effectiveDirectory,transportIdentity:e.transportIdentity});if(n.ok){J.success(o(`settings.skills.catalog.installSkill.toast.installed`)),r(!1);return}if(n.error?.kind===`conflicts`){C({source:e.source,subpath:e.subpath,scope:e.scope,targetSource:e.targetSource,skillDir:e.skillDir,directoryOverride:e.directoryOverride??null,effectiveDirectory:e.effectiveDirectory,transportIdentity:e.transportIdentity}),x(n.error.conflicts),v(!0);return}if(n.error?.kind===`authRequired`){J.error(n.error.message||o(`settings.skills.catalog.installSkill.toast.authRequired`));return}J.error(n.error?.message||o(`settings.skills.catalog.installSkill.toast.installFailed`))},t[14]=s,t[15]=a,t[16]=r,t[17]=o,t[18]=P):P=t[18];let F=P;if(!a)return null;let I;t[19]===o?I=t[20]:(I=o(`settings.skills.catalog.installSkill.title`),t[19]=o,t[20]=I);let L;t[21]===I?L=t[22]:(L=(0,$.jsx)(mn,{children:I}),t[21]=I,t[22]=L);let R;t[23]===o?R=t[24]:(R=o(`settings.skills.catalog.installSkill.descriptionPrefix`),t[23]=o,t[24]=R);let z;t[25]===a.skillName?z=t[26]:(z=(0,$.jsx)(`span`,{className:`font-semibold text-foreground`,children:a.skillName}),t[25]=a.skillName,t[26]=z);let B;t[27]===o?B=t[28]:(B=o(`settings.skills.catalog.installSkill.descriptionSuffix`),t[27]=o,t[28]=B);let V;t[29]!==R||t[30]!==z||t[31]!==B?(V=(0,$.jsxs)(hn,{children:[R,` `,z,` `,B]}),t[29]=R,t[30]=z,t[31]=B,t[32]=V):V=t[32];let H;t[33]!==L||t[34]!==V?(H=(0,$.jsxs)(dn,{children:[L,V]}),t[33]=L,t[34]=V,t[35]=H):H=t[35];let U;t[36]===o?U=t[37]:(U=o(`settings.skills.catalog.installSkill.field.destination`),t[36]=o,t[37]=U);let W;t[38]===U?W=t[39]:(W=(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:U}),t[38]=U,t[39]=W);let ee;t[40]!==l||t[41]!==d?(ee=Tu(l,d),t[40]=l,t[41]=d,t[42]=ee):ee=t[42];let te;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(te=e=>{let t=Eu(e);u(t.scope),f(t.source===`agents`?`agents`:`opencode`)},t[43]=te):te=t[43];let ne;t[44]===l?ne=t[45]:(ne=l===`user`?(0,$.jsx)(X,{name:`user-3`,className:`h-3.5 w-3.5`}):(0,$.jsx)(X,{name:`folder`,className:`h-3.5 w-3.5`}),t[44]=l,t[45]=ne);let re;t[46]===d?re=t[47]:(re=d===`agents`?(0,$.jsx)(X,{name:`robot-2`,className:`h-3.5 w-3.5`}):null,t[46]=d,t[47]=re);let ie;t[48]!==D||t[49]!==l||t[50]!==d?(ie=D(Tu(l,d)),t[48]=D,t[49]=l,t[50]=d,t[51]=ie):ie=t[51];let ae;t[52]===ie?ae=t[53]:(ae=(0,$.jsx)(`span`,{children:ie}),t[52]=ie,t[53]=ae);let oe;t[54]!==ne||t[55]!==re||t[56]!==ae?(oe=(0,$.jsxs)(Pr,{className:`w-fit gap-1.5`,children:[ne,re,ae]}),t[54]=ne,t[55]=re,t[56]=ae,t[57]=oe):oe=t[57];let se;t[58]!==k||t[59]!==D?(se=wu.map(e=>(0,$.jsx)(jr,{value:e.value,className:`pr-2 [&>span:first-child]:hidden`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.scope===`user`?(0,$.jsx)(X,{name:`user-3`,className:`h-3.5 w-3.5`}):(0,$.jsx)(X,{name:`folder`,className:`h-3.5 w-3.5`}),e.source===`agents`?(0,$.jsx)(X,{name:`robot-2`,className:`h-3.5 w-3.5`}):null,(0,$.jsx)(`span`,{children:D(e.value)})]}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground ml-5`,children:k(e.value)})]})},e.value)),t[58]=k,t[59]=D,t[60]=se):se=t[60];let ce;t[61]===se?ce=t[62]:(ce=(0,$.jsx)(Nr,{align:`start`,children:se}),t[61]=se,t[62]=ce);let le;t[63]!==ee||t[64]!==oe||t[65]!==ce?(le=(0,$.jsxs)(Fr,{value:ee,onValueChange:te,children:[oe,ce]}),t[63]=ee,t[64]=oe,t[65]=ce,t[66]=le):le=t[66];let ue;t[67]!==W||t[68]!==le?(ue=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[W,le]}),t[67]=W,t[68]=le,t[69]=ue):ue=t[69];let de;t[70]!==p||t[71]!==j||t[72]!==l||t[73]!==o?(de=l===`project`&&(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:o(`settings.skills.catalog.installSkill.field.project`)}),p.length===0?(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:o(`settings.skills.catalog.installSkill.field.noProjects`)}):(0,$.jsxs)(Fr,{value:j??``,onValueChange:e=>g(e),disabled:p.length===1,children:[(0,$.jsx)(Pr,{className:`w-fit`,children:(0,$.jsx)(Ar,{placeholder:o(`settings.skills.catalog.installSkill.field.chooseProjectPlaceholder`)})}),(0,$.jsx)(Nr,{align:`start`,children:p.map(Mu)})]})]}),t[70]=p,t[71]=j,t[72]=l,t[73]=o,t[74]=de):de=t[74];let G;t[75]===a.warnings?G=t[76]:(G=a.warnings?.length?(0,$.jsx)(`div`,{className:`typography-micro text-[var(--status-warning)] bg-[var(--status-warning)]/10 px-2 py-1.5 rounded`,children:a.warnings.join(` · `)}):null,t[75]=a.warnings,t[76]=G);let fe;t[77]!==ue||t[78]!==de||t[79]!==G?(fe=(0,$.jsxs)(`div`,{className:`mt-2 space-y-3`,children:[ue,de,G]}),t[77]=ue,t[78]=de,t[79]=G,t[80]=fe):fe=t[80];let pe;t[81]===r?pe=t[82]:(pe=()=>r(!1),t[81]=r,t[82]=pe);let me;t[83]===o?me=t[84]:(me=o(`settings.common.actions.cancel`),t[83]=o,t[84]=me);let he;t[85]!==pe||t[86]!==me?(he=(0,$.jsx)(q,{size:`sm`,variant:`ghost`,onClick:pe,children:me}),t[85]=pe,t[86]=me,t[87]=he):he=t[87];let ge=c||!a.installable||l===`project`&&!N,_e;t[88]!==N||t[89]!==F||t[90]!==a.repoSource||t[91]!==a.repoSubpath||t[92]!==a.skillDir||t[93]!==l||t[94]!==d?(_e=()=>void F({source:a.repoSource,subpath:a.repoSubpath,scope:l,targetSource:d,skillDir:a.skillDir,directoryOverride:N,effectiveDirectory:N??Kt(),transportIdentity:i()}),t[88]=N,t[89]=F,t[90]=a.repoSource,t[91]=a.repoSubpath,t[92]=a.skillDir,t[93]=l,t[94]=d,t[95]=_e):_e=t[95];let ve;t[96]!==c||t[97]!==o?(ve=o(c?`settings.skills.catalog.installSkill.actions.installing`:`settings.skills.catalog.installSkill.actions.install`),t[96]=c,t[97]=o,t[98]=ve):ve=t[98];let ye;t[99]!==ge||t[100]!==_e||t[101]!==ve?(ye=(0,$.jsx)(q,{size:`sm`,disabled:ge,onClick:_e,children:ve}),t[99]=ge,t[100]=_e,t[101]=ve,t[102]=ye):ye=t[102];let be;t[103]!==he||t[104]!==ye?(be=(0,$.jsxs)(fn,{children:[he,ye]}),t[103]=he,t[104]=ye,t[105]=be):be=t[105];let xe;t[106]!==H||t[107]!==fe||t[108]!==be?(xe=(0,$.jsxs)(pn,{className:`max-w-md`,children:[H,fe,be]}),t[106]=H,t[107]=fe,t[108]=be,t[109]=xe):xe=t[109];let Se;t[110]!==r||t[111]!==n||t[112]!==xe?(Se=(0,$.jsx)(gn,{open:n,onOpenChange:r,children:xe}),t[110]=r,t[111]=n,t[112]=xe,t[113]=Se):Se=t[113];let Ce;t[114]!==S||t[115]!==F?(Ce=e=>{S&&(F({source:S.source,subpath:S.subpath,scope:S.scope,targetSource:S.targetSource,skillDir:S.skillDir,conflictDecisions:e,directoryOverride:S.directoryOverride??null,effectiveDirectory:S.effectiveDirectory,transportIdentity:S.transportIdentity}),v(!1))},t[114]=S,t[115]=F,t[116]=Ce):Ce=t[116];let we;t[117]!==b||t[118]!==_||t[119]!==Ce?(we=(0,$.jsx)(Cu,{open:_,onOpenChange:v,conflicts:b,onConfirm:Ce}),t[117]=b,t[118]=_,t[119]=Ce,t[120]=we):we=t[120];let Te;return t[121]!==Se||t[122]!==we?(Te=(0,$.jsxs)($.Fragment,{children:[Se,we]}),t[121]=Se,t[122]=we,t[123]=Te):Te=t[123],Te};function Ou(e){return e.installSkills}function ku(e){return e.isInstalling}function Au(e){return e.projects}function ju(e){return e.activeProjectId}function Mu(e){return(0,$.jsx)(jr,{value:e.id,children:e.label||e.path},e.id)}var Nu=async()=>{try{let e=A()?.settings;if(e)return(await e.load())?.settings||{};let t=await l(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});return t.ok?await t.json().catch(()=>null):null}catch{return null}},Pu=({mode:e,onModeChange:t,showModeTabs:n=!0})=>{let{t:r}=Ge(),{selectedSourceId:a,setSelectedSource:o}=fu(ne(e=>({selectedSourceId:e.selectedSourceId,setSelectedSource:e.setSelectedSource}))),s=Et(),c=s.data??vt,l=c.some(e=>e.id===a)?a:null,u=Ft(l??``,{enabled:!!l}),[d,f]=Q.useState(``),[p,m]=Q.useState(!1),[h,g]=Q.useState(!1),[_,v]=Q.useState(null),[y,b]=Q.useState(!1),[x,S]=Q.useState(!1),[C,w]=Q.useState(!1),[T,E]=Q.useState(null);Q.useEffect(()=>{!s.data&&s.isFetching||c.some(e=>e.id===a)||o(c[0]?.id??null)},[a,o,c,s.data,s.isFetching]);let D=Kt(),O=i();Q.useEffect(()=>{E(null)},[l,D,O]);let k=Q.useMemo(()=>ct(u.data?.pages??[]),[u.data]),A=Q.useMemo(()=>{let e=d.trim().toLowerCase();return e?k.filter(t=>{let n=t.skillName.toLowerCase(),r=(t.description||``).toLowerCase(),i=(t.frontmatterName||``).toLowerCase();return n.includes(e)||r.includes(e)||i.includes(e)}):k},[k,d]),j=Q.useMemo(()=>c.find(e=>e.id===l)||null,[c,l]),M=!!(l&&l.startsWith(`custom:`)),N=j?.source===`clawdhub:registry`||j?.sourceType===`clawdhub`,P=s.isLoading&&!s.data,F=u.isLoading&&!u.data,I=u.isFetchingNextPage,L=T??s.error??u.error,R=async()=>{if(!l||!M)return;let e=Kt(),t=i();b(!0),E(null);try{let n=await Nu(),r=(Array.isArray(n?.skillCatalogs)?n?.skillCatalogs:[]).filter(e=>e.id!==l);await ye({skillCatalogs:r}),Oe.setQueriesData({queryKey:[t,`skillsCatalog`,`sources`],exact:!1},e=>e?.filter(e=>e.id!==l)),Oe.removeQueries({queryKey:[t,`skillsCatalog`,`source`],exact:!1,predicate:e=>e.queryKey[4]===l}),i()===t&&(o(null),S(!1)),await zt(Oe,e,t)}catch(n){i()===t&&Kt()===e&&E(n instanceof Error?n:Error(String(n)))}finally{b(!1)}},z=async()=>{let e=Kt(),t=i(),n=l;w(!0),E(null);try{n?await Xt(Oe,e,n,t):await zt(Oe,e,t)}catch(r){let a=fu.getState().selectedSourceId;i()===t&&Kt()===e&&a===n&&E(r instanceof Error?r:Error(String(r)))}finally{w(!1)}};return(0,$.jsx)(Ur,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`yuri-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[n&&(0,$.jsx)(`div`,{className:`h-10`,children:(0,$.jsx)(Jr,{items:[{id:`manual`,label:r(`settings.skills.catalog.page.mode.manual`)},{id:`external`,label:r(`settings.skills.catalog.page.mode.external`)}],activeId:e,onSelect:e=>t(e),layoutMode:`fit`,variant:`animated`,animateActivePill:!1,className:`h-full`})}),(0,$.jsx)(Z,{itemId:`skills.catalog.source`,label:r(`settings.skills.catalog.page.section.sourceRepository`),children:(0,$.jsxs)(`div`,{className:`yuri-settings-group-row flex flex-wrap items-center gap-2`,children:[(0,$.jsxs)(Fr,{value:l||``,onValueChange:e=>o(e),children:[(0,$.jsx)(Pr,{className:`w-fit min-w-0 max-w-full`,"aria-label":r(`settings.skills.catalog.page.section.sourceRepository`),children:(0,$.jsx)(Ar,{placeholder:r(`settings.skills.catalog.page.field.selectSourcePlaceholder`),children:j?.label})}),(0,$.jsx)(Nr,{align:`start`,children:c.map(e=>(0,$.jsx)(jr,{value:e.id,children:e.label},e.id))})]}),(0,$.jsx)(q,{variant:`ghost`,size:`icon`,onClick:()=>void z(),disabled:C,title:r(`settings.skills.catalog.page.actions.refreshTitle`),"aria-label":r(`settings.skills.catalog.page.actions.refreshTitle`),children:(0,$.jsx)(X,{name:`refresh`,className:K(`h-3.5 w-3.5`,C&&`animate-spin`)})}),M&&(0,$.jsx)(q,{variant:`ghost`,size:`icon`,className:`text-[var(--status-error)] hover:text-[var(--status-error)]`,onClick:()=>S(!0),disabled:y,title:r(`settings.skills.catalog.page.actions.removeCatalogTitle`),"aria-label":r(`settings.skills.catalog.page.actions.removeCatalogTitle`),children:(0,$.jsx)(X,{name:`delete-bin`,className:`h-3.5 w-3.5`})}),(0,$.jsxs)(q,{"data-settings-item":`skills.catalog.add-catalog`,size:`sm`,className:`ml-auto`,onClick:()=>m(!0),children:[(0,$.jsx)(X,{name:`add`,className:`h-3.5 w-3.5`}),` `,r(`settings.skills.catalog.page.actions.addCatalog`)]})]})}),L&&(0,$.jsxs)(`div`,{className:`rounded-lg border border-[var(--status-error-border)] bg-[var(--status-error-background)] px-4 py-3`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label font-medium text-[var(--status-error)]`,children:r(`settings.skills.catalog.page.error.catalogTitle`)}),(0,$.jsx)(`div`,{className:`typography-meta text-[var(--status-error)]/80 mt-1`,children:L.message})]}),(0,$.jsxs)(`div`,{className:`min-w-0 space-y-3`,children:[(0,$.jsxs)(`div`,{"data-settings-item":`skills.catalog.search`,className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[(0,$.jsxs)(`div`,{className:`relative min-w-0 flex-1 basis-48`,children:[(0,$.jsx)(X,{name:`search`,className:`pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 size-4 text-muted-foreground`}),(0,$.jsx)(Cn,{value:d,onChange:e=>f(e.target.value),placeholder:r(`settings.skills.catalog.shared.field.searchSkillsPlaceholder`),"aria-label":r(`settings.skills.catalog.shared.field.searchSkillsPlaceholder`),className:`w-full pl-9`})]}),(0,$.jsx)(`span`,{className:`typography-meta shrink-0 text-muted-foreground tabular-nums`,role:`status`,children:P||F?r(`settings.skills.catalog.page.loading.catalog`):r(`settings.skills.catalog.page.foundCount`,{count:A.length})})]}),(0,$.jsx)(Z,{children:A.length===0&&!F?(0,$.jsxs)(`div`,{className:`py-8 text-center text-muted-foreground`,children:[(0,$.jsx)(`p`,{className:`typography-body`,children:r(`settings.skills.catalog.page.empty.noSkillsTitle`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:r(`settings.skills.catalog.page.empty.noSkillsDescription`)})]}):F?(0,$.jsxs)(`div`,{className:`py-8 text-center text-muted-foreground`,children:[(0,$.jsx)(X,{name:`refresh`,className:`mx-auto mb-3 h-5 w-5 animate-spin opacity-50`}),(0,$.jsx)(`p`,{className:`typography-meta`,children:r(`settings.skills.catalog.page.loading.skills`)})]}):(0,$.jsx)($.Fragment,{children:A.map(e=>{let t=e.installed?.isInstalled,n=e.installed?.scope;return(0,$.jsx)(`div`,{className:`yuri-settings-group-row`,children:(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label font-medium text-foreground [overflow-wrap:anywhere]`,children:e.skillName}),t&&(0,$.jsx)(`span`,{className:`typography-micro text-[var(--status-success)] bg-[var(--status-success)]/10 px-1.5 py-0.5 rounded flex-shrink-0`,children:r(`settings.skills.catalog.page.badge.installed`,{scope:n||r(`settings.skills.catalog.page.badge.unknown`)})}),!e.installable&&(0,$.jsx)(`span`,{className:`typography-micro text-[var(--status-warning)] bg-[var(--status-warning)]/10 px-1.5 py-0.5 rounded flex-shrink-0`,children:r(`settings.skills.catalog.page.badge.notInstallable`)})]}),e.description?(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground mt-1 line-clamp-2 max-w-prose [overflow-wrap:anywhere]`,children:e.description}):(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground/50 mt-0.5 italic`,children:r(`settings.skills.catalog.shared.noDescription`)}),e.clawdhub&&(0,$.jsxs)(`div`,{className:`typography-micro text-muted-foreground mt-1.5 flex flex-wrap items-center gap-x-3 gap-y-1 [overflow-wrap:anywhere]`,children:[e.clawdhub.owner&&(0,$.jsxs)(`span`,{children:[r(`settings.skills.catalog.page.byOwnerPrefix`),` `,(0,$.jsx)(`span`,{className:`font-medium text-foreground/80`,children:e.clawdhub.owner})]}),(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(X,{name:`download`,className:`h-3 w-3`}),e.clawdhub.downloads?.toLocaleString()??0]}),(e.clawdhub.stars??0)>0&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(X,{name:`star`,className:`h-3 w-3`}),e.clawdhub.stars]}),(0,$.jsxs)(`span`,{className:`bg-[var(--surface-muted)] px-1.5 py-0.5 rounded`,children:[`v`,e.clawdhub.version]})]}),e.warnings?.length?(0,$.jsx)(`div`,{className:`typography-micro text-[var(--status-warning)] mt-1.5 bg-[var(--status-warning)]/10 px-2 py-1 rounded w-fit [overflow-wrap:anywhere]`,children:e.warnings.join(` · `)}):null]}),(0,$.jsx)(q,{size:`sm`,className:`shrink-0`,disabled:!e.installable,onClick:()=>{v(e),g(!0)},children:r(`settings.skills.catalog.shared.actions.install`)})]})},`${e.sourceId}:${e.skillDir}`)})})}),N&&u.hasNextPage&&!F&&A.length>0&&(0,$.jsx)(`div`,{className:`flex justify-center mt-2 px-2`,children:(0,$.jsx)(q,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>void u.fetchNextPage(),disabled:I,children:r(I?`settings.skills.catalog.page.loading.more`:`settings.skills.catalog.page.actions.loadMoreSkills`)})})]}),(0,$.jsx)(gu,{open:p,onOpenChange:m}),(0,$.jsx)(Du,{open:h,onOpenChange:g,item:_}),(0,$.jsx)(gn,{open:x,onOpenChange:e=>{y||S(e)},children:(0,$.jsxs)(pn,{className:`max-w-md`,children:[(0,$.jsxs)(dn,{children:[(0,$.jsx)(mn,{children:r(`settings.skills.catalog.page.removeDialog.title`)}),(0,$.jsx)(hn,{children:r(`settings.skills.catalog.page.removeDialog.description`)})]}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(q,{size:`sm`,variant:`ghost`,onClick:()=>S(!1),disabled:y,children:r(`settings.common.actions.cancel`)}),(0,$.jsx)(q,{size:`sm`,variant:`destructive`,onClick:()=>void R(),disabled:y,children:r(`settings.skills.catalog.page.actions.removeCatalog`)})]})]})})]})})},Fu=()=>{let e=(0,Sa.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(Pu,{mode:`external`,onModeChange:Wu,showModeTabs:!1}),e[0]=t):t=e[0],t},Iu=`SKILL.md`,Lu=`h-[clamp(320px,58dvh,680px)] min-h-[260px] max-h-[calc(100dvh-220px)]`,Ru=(e,t)=>{let n=ba({description:e}).trimEnd(),r=t.trimStart();return`---\n${n}\n---${r?`\n\n${r}`:`
25
+ `}`},zu=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Bu=e=>{let t=e.match(/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)([\s\S]*)$/);if(!t)return{description:null,instructions:e};let n=null;try{let e=xa(t[1]);if(zu(e)){let t=e.description;typeof t==`string`&&(n=t)}}catch{n=null}return{description:n,instructions:t[2].replace(/^\r?\n/,``)}},Vu=(e,t)=>Ru(t,Bu(e).instructions),Hu=()=>{let{t:e}=Ge(),{currentTheme:t}=un(),{selectedSkillName:n,getSkillDetail:r,createSkill:i,updateSkill:a,skillDraft:o,setSkillDraft:s,setSelectedSkill:c}=so(ne(e=>({selectedSkillName:e.selectedSkillName,getSkillDetail:e.getSkillDetail,createSkill:e.createSkill,updateSkill:e.updateSkill,skillDraft:e.skillDraft,setSkillDraft:e.setSkillDraft,setSelectedSkill:e.setSelectedSkill}))),l=Tt(),u=St(),d=Q.useMemo(()=>l.data??[],[l.data]),f=n?d.find(e=>e.name===n)??null:null,p=!!(o&&o.name===n&&!f),m=!!(n&&!f&&!o),h=f?.path===`<built-in>`;Q.useEffect(()=>{m&&c(null)},[m,c]);let[g,_]=Q.useState(``),[v,y]=Q.useState(`user`),[b,x]=Q.useState(`opencode`),[S,C]=Q.useState(``),[w,T]=Q.useState(``),[E,D]=Q.useState(()=>Ru(``,``)),[O,k]=Q.useState(`edit`),[A,j]=Q.useState([]),[M,N]=Q.useState([]),[P,F]=Q.useState(!1),[I,L]=Q.useState(!1),[R,z]=Q.useState(``),[B,V]=Q.useState(``),[H,U]=Q.useState(!1),[W,ee]=Q.useState(``),[te,re]=Q.useState(``),[ie,ae]=Q.useState(null),[oe,se]=Q.useState(!1),[ce,le]=Q.useState(``),[ue,de]=Q.useState(null),[fe,pe]=Q.useState(!1),me=p?g.trim()!==``||S.trim()!==``||w.trim()!==``||M.length>0:S!==R||w!==B,he=ie?te!==ce:W.trim()!==``,ge=Q.useCallback(t=>{switch(t){case`project-opencode`:return e(`settings.skills.location.option.projectOpencode.label`);case`user-claude`:return e(`settings.skills.location.option.userClaude.label`);case`project-claude`:return e(`settings.skills.location.option.projectClaude.label`);case`user-agents`:return e(`settings.skills.location.option.userAgents.label`);case`project-agents`:return e(`settings.skills.location.option.projectAgents.label`);default:return e(`settings.skills.location.option.userOpencode.label`)}},[e]),_e=Q.useCallback(t=>{switch(t){case`project-opencode`:return e(`settings.skills.location.option.projectOpencode.description`);case`user-claude`:return e(`settings.skills.location.option.userClaude.description`);case`project-claude`:return e(`settings.skills.location.option.projectClaude.description`);case`user-agents`:return e(`settings.skills.location.option.userAgents.description`);case`project-agents`:return e(`settings.skills.location.option.projectAgents.description`);default:return e(`settings.skills.location.option.userOpencode.description`)}},[e]);Q.useEffect(()=>{(async()=>{if(p&&o){let e=o.description||``,t=o.instructions||``;_(o.name||``),y(o.scope||`user`),x(o.source===`agents`?`agents`:`opencode`),C(e),T(t),D(Ru(e,t)),z(``),V(``),j([]),N(o.pendingFiles||[])}else if(n&&f){L(!0);try{let e=await r(n);if(e){let t=e.sources.md,n=t.description||``,r=t.instructions||``;C(n),T(r),D(Ru(n,r)),z(n),V(r),j(t.supportingFiles||[])}}catch(e){console.error(`Failed to load skill details:`,e)}finally{L(!1)}}})()},[f,p,n,d,o,r]);let ve=G(e=>e.editorFontSize),ye=Q.useMemo(()=>{let e=[Ai(t,{fontSize:ve})],n=li(Iu);return n&&e.push(n),e.push(Re.lineWrapping),e},[t,ve]),be=Q.useMemo(()=>{let e=W.trim()||`supporting-file.md`,n=Vr(e),r=!!n&&n!==`markdown`,i=[Ai(t,r?{syntaxColors:!1,fontSize:ve}:{fontSize:ve})],a=li(e);return a&&i.push(a),r&&n&&i.push(Xr({language:n,themeName:t.metadata.id,theme:Rr(t)})),i.push(Re.lineWrapping),i},[t,W,ve]),xe=Q.useCallback(e=>{C(e),D(t=>Vu(t,e))},[]),Se=Q.useCallback(e=>{D(e);let t=Bu(e);C(t.description??``),T(t.instructions)},[]),Ce=async()=>{let t=p?g.trim().replace(/\s+/g,`-`).toLowerCase():n?.trim();if(!t){J.error(e(`settings.skills.page.toast.skillNameRequired`));return}if(!/^[a-z0-9][a-z0-9-]*[a-z0-9]$|^[a-z0-9]$/.test(t)||t.length>64){J.error(e(`settings.skills.page.toast.invalidSkillName`));return}if(!S.trim()){J.error(e(`settings.skills.page.toast.descriptionRequired`));return}if(p&&d.some(e=>e.name===t)){J.error(e(`settings.skills.page.toast.skillExists`));return}F(!0);try{let n={name:t,description:S.trim(),instructions:w.trim()||void 0,scope:p?v:void 0,source:p?b:void 0,targetPath:p?void 0:f?.path,supportingFiles:p&&M.length>0?M:void 0},r;p?(r=await i(n,{directory:u}),r&&(s(null),N([]),c(t))):(r=await a(t,n,{directory:u}),r&&(z(S.trim()),V(w.trim()))),r?J.success(e(p?`settings.skills.page.toast.skillCreated`:`settings.skills.page.toast.skillUpdated`)):J.error(e(p?`settings.skills.page.toast.createSkillFailed`:`settings.skills.page.toast.updateSkillFailed`))}catch(t){console.error(`Error saving skill:`,t),J.error(e(`settings.skills.page.toast.saveUnexpectedError`))}finally{F(!1)}},we=()=>{ae(null),ee(``),re(``),le(``),U(!0)},Te=async t=>{if(ae(t),ee(t),p){let e=M.find(e=>e.path===t)?.content||``;re(e),le(e),U(!0);return}if(n){se(!0),U(!0);try{let{readSupportingFile:e}=so.getState(),r=await e(n,t);re(r||``),le(r||``)}catch{J.error(e(`settings.skills.page.toast.loadFileContentFailed`)),re(``),le(``)}finally{se(!1)}}},Ee=async()=>{if(!W.trim()){J.error(e(`settings.skills.page.toast.fileNameRequired`));return}let t=W.trim(),i=ie!==null;if(p){if(i)N(e=>e.map(e=>e.path===ie?{path:t,content:te}:e)),J.success(e(`settings.skills.page.toast.fileUpdated`,{path:t}));else{if(M.some(e=>e.path===t)){J.error(e(`settings.skills.page.toast.fileExists`));return}N(e=>[...e,{path:t,content:te}]),J.success(e(`settings.skills.page.toast.fileAdded`,{path:t}))}U(!1),ae(null);return}if(!n){J.error(e(`settings.skills.page.toast.noSkillSelected`));return}let{writeSupportingFile:a}=so.getState();if(await a(n,t,te)){J.success(e(i?`settings.skills.page.toast.fileUpdated`:`settings.skills.page.toast.fileCreated`,{path:t})),U(!1),ae(null);let a=await r(n);a&&j(a.sources.md.supportingFiles||[])}else J.error(e(i?`settings.skills.page.toast.updateFileFailed`:`settings.skills.page.toast.createFileFailed`))},De=t=>{if(p){N(e=>e.filter(e=>e.path!==t)),J.success(e(`settings.skills.page.toast.fileRemoved`,{path:t}));return}n&&de(t)};return!n&&!o||m?(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-4`,children:(0,$.jsxs)(`div`,{className:`text-center text-muted-foreground`,children:[(0,$.jsx)(X,{name:`book-open`,className:`mx-auto mb-3 h-10 w-10 sm:h-12 sm:w-12 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.skills.page.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:e(`settings.skills.page.empty.description`)})]})}):I?(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-4`,children:(0,$.jsx)(`div`,{className:`text-center text-muted-foreground`,children:(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.skills.page.loading.details`)})})}):(0,$.jsxs)(Ur,{outerClassName:`h-full`,className:`w-full`,children:[(0,$.jsxs)(`div`,{className:`yuri-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsx)(Gi,{actions:(0,$.jsx)(q,{onClick:Ce,disabled:h||P||!me,size:`sm`,"aria-busy":P,children:e(P?`settings.common.actions.saving`:p?`settings.skills.page.actions.createSkill`:`settings.common.actions.saveChanges`)}),children:(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate flex items-center gap-2`,children:p?e(`settings.skills.page.title.newSkill`):n}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground truncate`,children:f?e(`settings.skills.page.subtitle.skillLocation`,{location:ge(Tu(f.scope,f.source))}):e(`settings.skills.page.subtitle.newSkill`)})]})}),(0,$.jsx)(`div`,{"data-settings-item":`skills.basic-information`,children:(0,$.jsx)(Z,{label:e(`settings.skills.page.section.basicInformation`),cardClassName:`p-3`,children:(0,$.jsxs)(`div`,{className:`space-y-3`,children:[p&&(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.skills.page.field.skillNameLocation`)}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground ml-2`,children:e(`settings.skills.page.field.skillNameHint`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mt-1.5`,children:[(0,$.jsx)(Cn,{value:g,onChange:e=>_(e.target.value.toLowerCase().replace(/\s+/g,`-`)),placeholder:e(`settings.skills.page.field.skillNamePlaceholder`),className:`h-7 w-40 px-2`}),(0,$.jsxs)(Fr,{value:Tu(v,b),onValueChange:e=>{let t=Eu(e);y(t.scope),x(t.source===`agents`?`agents`:`opencode`)},children:[(0,$.jsxs)(Pr,{className:`w-fit gap-1.5`,children:[v===`user`?(0,$.jsx)(X,{name:`user-3`,className:`h-3.5 w-3.5`}):(0,$.jsx)(X,{name:`folder`,className:`h-3.5 w-3.5`}),b===`agents`?(0,$.jsx)(X,{name:`robot-2`,className:`h-3.5 w-3.5`}):null,(0,$.jsx)(`span`,{children:ge(Tu(v,b))})]}),(0,$.jsx)(Nr,{align:`start`,children:wu.map(e=>(0,$.jsx)(jr,{value:e.value,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.scope===`user`?(0,$.jsx)(X,{name:`user-3`,className:`h-3.5 w-3.5`}):(0,$.jsx)(X,{name:`folder`,className:`h-3.5 w-3.5`}),e.source===`agents`?(0,$.jsx)(X,{name:`robot-2`,className:`h-3.5 w-3.5`}):null,(0,$.jsx)(`span`,{children:ge(e.value)})]}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground ml-6`,children:_e(e.value)})]})},e.value))})]})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`span`,{className:`typography-ui-label text-foreground`,children:[e(`settings.common.field.description`),` `,(0,$.jsx)(`span`,{className:`text-[var(--status-error)]`,children:`*`})]}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground ml-2`,children:e(`settings.skills.page.field.descriptionHint`)}),(0,$.jsx)(`div`,{className:`mt-1.5`,children:(0,$.jsx)(Wr,{embedded:!0,value:S,onChange:e=>xe(e.target.value),placeholder:e(`settings.skills.page.field.descriptionPlaceholder`),rows:2,className:`w-full resize-none min-h-[60px] max-h-32 bg-transparent`,disabled:h})})]})]})})}),(0,$.jsx)(`div`,{"data-settings-item":`skills.instructions`,children:(0,$.jsx)(Z,{label:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{children:e(`settings.skills.page.section.instructions`)}),(0,$.jsx)(ci,{currentMode:O===`preview`?`preview`:`edit`,onToggle:()=>k(e=>e===`preview`?`edit`:`preview`)})]}),children:(0,$.jsx)(`div`,{className:K(`overflow-hidden bg-background`,Lu),children:O===`preview`?(0,$.jsx)(Ur,{outerClassName:`h-full`,className:`h-full`,children:(0,$.jsx)(`div`,{className:`min-h-full px-4 py-3`,children:(0,$.jsx)(zr,{content:E,className:`typography-markdown-body`,stripFrontmatter:!0,enableFileReferences:!1})})}):(0,$.jsx)(Zr,{value:E,onChange:Se,readOnly:h,extensions:ye,className:`h-full`,enableSearch:!0})})})}),(0,$.jsx)(`div`,{"data-settings-item":`skills.supporting-files`,children:(0,$.jsx)(Z,{label:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{children:e(`settings.skills.page.section.supportingFiles`)}),(0,$.jsxs)(q,{variant:`outline`,size:`xs`,className:`!font-normal gap-1`,onClick:we,disabled:h,children:[(0,$.jsx)(X,{name:`add`,className:`h-3.5 w-3.5`}),` `,e(`settings.skills.page.actions.addFile`)]})]}),cardClassName:`p-3`,children:(()=>{let t=p?M:A;return t.length===0?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground py-1.5`,children:e(`settings.skills.page.supportingFiles.empty`)}):(0,$.jsx)(`div`,{className:`divide-y divide-[var(--surface-subtle)]`,children:t.map(t=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2 py-1.5 cursor-pointer group`,onClick:()=>Te(t.path),children:[(0,$.jsx)(X,{name:`file`,className:`h-3.5 w-3.5 text-muted-foreground flex-shrink-0`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:t.path}),p&&(0,$.jsx)(`span`,{className:`typography-micro text-[var(--status-warning)] bg-[var(--status-warning)]/10 px-1.5 py-0.5 rounded flex-shrink-0`,children:e(`settings.skills.page.badge.pending`)}),!h&&(0,$.jsx)(q,{size:`sm`,variant:`ghost`,className:`h-5 w-5 px-0 flex-shrink-0 text-muted-foreground hover:text-[var(--status-error)] opacity-0 group-hover:opacity-100 transition-opacity`,onClick:e=>{e.stopPropagation(),De(t.path)},children:(0,$.jsx)(X,{name:`delete-bin`,className:`h-3 w-3`})})]},t.path))})})()})})]}),(0,$.jsx)(gn,{open:ue!==null,onOpenChange:e=>{!e&&!fe&&de(null)},children:(0,$.jsxs)(pn,{className:`max-w-md`,children:[(0,$.jsxs)(dn,{children:[(0,$.jsx)(mn,{children:e(`settings.skills.page.deleteFileDialog.title`)}),(0,$.jsx)(hn,{children:e(`settings.skills.page.deleteFileDialog.description`,{path:ue??``})})]}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(q,{size:`sm`,variant:`ghost`,onClick:()=>de(null),disabled:fe,children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(q,{size:`sm`,variant:`destructive`,onClick:async()=>{if(!ue||!n)return;pe(!0);let{deleteSupportingFile:t}=so.getState();if(await t(n,ue)){J.success(e(`settings.skills.page.toast.fileDeleted`,{path:ue}));let t=await r(n);t&&j(t.sources.md.supportingFiles||[]),de(null)}else J.error(e(`settings.skills.page.toast.deleteFileFailed`));pe(!1)},disabled:fe,children:e(`settings.common.actions.delete`)})]})]})}),(0,$.jsx)(gn,{open:H,onOpenChange:e=>{U(e),e||ae(null)},children:(0,$.jsxs)(pn,{className:`max-w-3xl max-h-[85vh] flex flex-col`,children:[(0,$.jsx)(Gi,{className:`pr-8`,actions:(0,$.jsx)(q,{size:`sm`,onClick:Ee,disabled:oe||!he,children:e(ie?`settings.common.actions.saveChanges`:`settings.skills.page.actions.createFile`)}),children:(0,$.jsxs)(dn,{className:`flex-shrink-0`,children:[(0,$.jsx)(mn,{children:e(ie?`settings.skills.page.fileDialog.titleEdit`:`settings.skills.page.fileDialog.titleAdd`)}),(0,$.jsx)(hn,{children:e(ie?`settings.skills.page.fileDialog.descriptionEdit`:`settings.skills.page.fileDialog.descriptionAdd`)})]})}),oe?(0,$.jsx)(`div`,{className:`flex-1 flex items-center justify-center py-8`,children:(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:e(`settings.skills.page.loading.fileContent`)})}):(0,$.jsxs)(`div`,{className:`space-y-4 flex-1 min-h-0 flex flex-col pt-2`,children:[(0,$.jsxs)(`div`,{className:`space-y-2 flex-shrink-0`,children:[(0,$.jsx)(`label`,{className:`typography-ui-label font-medium text-foreground`,children:e(`settings.skills.page.fileDialog.field.filePath`)}),(0,$.jsx)(Cn,{value:W,onChange:e=>ee(e.target.value),placeholder:e(`settings.skills.page.fileDialog.field.filePathPlaceholder`),className:`text-foreground placeholder:text-muted-foreground focus-visible:ring-[var(--primary-base)]`,disabled:ie!==null}),!ie&&(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground`,children:e(`settings.skills.page.fileDialog.field.filePathHint`)})]}),(0,$.jsxs)(`div`,{className:`space-y-2 flex-1 min-h-0 flex flex-col`,children:[(0,$.jsx)(`label`,{className:`typography-ui-label font-medium text-foreground flex-shrink-0`,children:e(`settings.skills.page.fileDialog.field.content`)}),(0,$.jsx)(`div`,{className:`h-[45vh] min-h-[250px] max-h-[55vh] overflow-hidden rounded-md border border-[var(--surface-subtle)] bg-background`,children:(0,$.jsx)(Zr,{value:te,onChange:re,extensions:be,className:`h-full`,enableSearch:!0})})]})]}),(0,$.jsx)(fn,{className:`mt-4`,children:(0,$.jsx)(q,{size:`sm`,variant:`ghost`,onClick:()=>{U(!1),ae(null)},children:e(`settings.common.actions.cancel`)})})]})})]})},Uu=e=>{let t=(0,Sa.c)(2),{view:n}=e,r=n===void 0?`installed`:n,i;return t[0]===r?i=t[1]:(i=r===`catalog`?(0,$.jsx)(Fu,{}):(0,$.jsx)(Hu,{}),t[0]=r,t[1]=i),i};function Wu(){}var Gu=e=>{let t=(0,Sa.c)(26),{onItemSelect:n}=e,{t:r}=Ge(),i=Y(Ku),a=Y(qu),o=G(Ju),s=G(Yu),c=Q.useRef(null),l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=new Set,t[0]=l):l=t[0];let u=Q.useRef(l),d;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(d=g(),t[1]=d):d=t[1];let f=d,p=Xu,m,h;t[2]!==a||t[3]!==i||t[4]!==o||t[5]!==s?(m=()=>{let e=new Set(i.map(Zu)),t=c.current;if(t)for(let n of e)t.has(n)||u.current.add(n);if(c.current=e,a&&u.current.delete(a)){s(a);return}if(i.length===0){o!==null&&s(null);return}o&&i.some(e=>e.id===o)||s(i[0].id)},h=[a,i,o,s],t[2]=a,t[3]=i,t[4]=o,t[5]=s,t[6]=m,t[7]=h):(m=t[6],h=t[7]),Q.useEffect(m,h);let _;t[8]!==i.length||t[9]!==r?(_=r(`settings.projects.sidebar.total`,{count:i.length}),t[8]=i.length,t[9]=r,t[10]=_):_=t[10];let v;t[11]===_?v=t[12]:(v=(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:_}),t[11]=_,t[12]=v);let y;t[13]===r?y=t[14]:(y=!f&&(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`icon`,className:`h-7 w-7 -my-1 text-muted-foreground`,onClick:p,"aria-label":r(`settings.projects.sidebar.actions.addProject`),children:(0,$.jsx)(X,{name:`add`,className:`size-4`})}),t[13]=r,t[14]=y);let b;t[15]!==v||t[16]!==y?(b=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2 px-[var(--yuri-settings-row-inset)]`,children:[v,y]}),t[15]=v,t[16]=y,t[17]=b):b=t[17];let x;t[18]!==n||t[19]!==i||t[20]!==o||t[21]!==s?(x=i.length>0?(0,$.jsx)(Z,{children:i.map(e=>{let t=e.id===o,r=e.icon?Kr[e.icon]:null,i=e.color?qr[e.color]:void 0,a=(0,$.jsx)(X,{name:r??`folder`,className:`h-4 w-4`,style:i?{color:i}:void 0}),c=(0,$.jsx)(`span`,{className:K(`flex size-5 shrink-0 items-center justify-center overflow-hidden`,t?`text-foreground`:`text-muted-foreground`),children:e.iconImage?(0,$.jsx)(Gr,{project:e,className:`size-full object-contain`,fallback:a}):a});return(0,$.jsx)(ps,{title:e.path.split(/[\\/]/).filter(Boolean).at(-1)||e.path,icon:c,selected:t,onSelect:()=>{s(e.id),n?.()}},e.id)})}):null,t[18]=n,t[19]=i,t[20]=o,t[21]=s,t[22]=x):x=t[22];let S;return t[23]!==b||t[24]!==x?(S=(0,$.jsx)(hs,{variant:`background`,header:b,children:x}),t[23]=b,t[24]=x,t[25]=S):S=t[25],S};function Ku(e){return e.projects}function qu(e){return e.activeProjectId}function Ju(e){return e.settingsProjectsSelectedId}function Yu(e){return e.setSettingsProjectsSelectedId}function Xu(){yt.requestDirectoryDialog()}function Zu(e){return e.id}var Qu=()=>{let e=(0,Sa.c)(18),{t}=Ge(),n=Y($u),r=Y(ed),i=G(td),a=G(nd),o;bb0:{if(!i){o=null;break bb0}let t;e[0]!==n||e[1]!==i?(t=n.find(e=>e.id===i)??null,e[0]=n,e[1]=i,e[2]=t):t=e[2],o=t}let s=o,c,l;e[3]!==n||e[4]!==i||e[5]!==a?(c=()=>{if(n.length===0){a(null);return}i&&n.some(e=>e.id===i)||a(n[0].id)},l=[n,i,a],e[3]=n,e[4]=i,e[5]=a,e[6]=c,e[7]=l):(c=e[6],l=e[7]),Q.useEffect(c,l);let u;e[8]!==s||e[9]!==r?(u=async e=>{s&&r(s.id,{label:e.label,icon:e.icon,color:e.color,iconBackground:e.iconBackground,defaultModel:e.defaultModel??null})},e[8]=s,e[9]=r,e[10]=u):u=e[10];let d=u;if(!s){let n;e[11]===t?n=e[12]:(n=t(`settings.projects.page.empty.noProjects`),e[11]=t,e[12]=n);let r;return e[13]===n?r=e[14]:(r=(0,$.jsx)(Ur,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsx)(`div`,{className:`mx-auto w-full max-w-4xl p-3 sm:p-6 sm:pt-8`,children:(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:n})})}),e[13]=n,e[14]=r),r}let f;return e[15]!==d||e[16]!==s?(f=(0,$.jsx)(Ur,{outerClassName:`h-full`,className:`w-full bg-background`,children:(0,$.jsx)(`div`,{className:`mx-auto w-full max-w-4xl p-3 sm:p-6 sm:pt-8`,children:(0,$.jsx)(Mi,{project:s,onIdentitySave:d})})}),e[15]=d,e[16]=s,e[17]=f):f=e[17],f};function $u(e){return e.projects}function ed(e){return e.updateProjectMeta}function td(e){return e.settingsProjectsSelectedId}function nd(e){return e.setSettingsProjectsSelectedId}var rd={justNowMinutes:1,minutes:60,hours:24,days:30,months:12},id=6e4,ad=60*id,od=24*ad,sd=30*od;function cd(e,t={}){if(typeof e!=`number`||!Number.isFinite(e))return``;let n=t.now??Date.now(),r=t.buckets??rd,i=e-n,a=Math.abs(i),o=new Intl.RelativeTimeFormat(t.locale,{numeric:`auto`});return a<r.justNowMinutes*id?o.format(0,`second`):a<r.minutes*id?o.format(Math.round(i/id),`minute`):a<r.hours*ad?o.format(Math.round(i/ad),`hour`):a<r.days*od?o.format(Math.round(i/od),`day`):a<r.months*sd?o.format(Math.round(i/sd),`month`):o.format(Math.round(i/(12*sd)),`year`)}var ld=`relay_identity_changed`,ud=class extends Error{code=ld;expectedServerId;actualServerId;constructor(e,t){super(`Relay identity changed (expected ${e}, got ${t||`unknown`})`),this.name=`RelayIdentityChangedError`,this.expectedServerId=e,this.actualServerId=t}},dd=new Map,fd=e=>{let t=e.trim();if(!t)throw Error(`Relay serverId is required`);return`relay:${t}`},pd=e=>{let t={Accept:`application/json`},n=typeof e.clientToken==`string`?e.clientToken.trim():``;if(n&&(t.Authorization=`Bearer ${n}`),e.requestHeaders)for(let[n,r]of Object.entries(e.requestHeaders))!n.trim()||!r.trim()||n.trim().toLowerCase()!==`authorization`&&(t[n.trim()]=r.trim());return t},md=e=>({files:e?.files?.length??0,directories:e?.directories?.length??0,deletes:e?.deletes?.length??0,totalBytes:e?.totalBytes??0}),hd=async e=>{D()&&await k(`desktop_sync_runs_append`,{record:e})},gd=async(e,t)=>{if(!t)return;let n=await t().catch(()=>null),r=typeof n?.serverId==`string`?n.serverId.trim():``;if(r&&r!==e)throw new ud(e,r)},_d=e=>({ok:!0,files:0,directories:0,deletes:e.deletes.length,totalBytes:0,agentsRoot:null,providerCredentials:null,plan:e}),vd=e=>{let t=e?.selectionShape;if(!t)throw Error(`Local sync inventory missing selectionShape (update the Yuri desktop app)`);return t},yd=(e,t)=>{let n=Fn(e,{includeProviderCredentials:!1}),r=t.selections;return{fileGroups:r?.fileGroups??n.fileGroups,singleFiles:r?.singleFiles??n.singleFiles,directories:r?.directories??n.directories,agentsRoot:r?.agentsRoot!==!1,providerCredentials:r?.providerCredentials===!0,magpie:r?.magpie===!0}},bd=(e,t,n)=>{let r=e.inventory&&typeof e.inventory==`object`?e.inventory:null;if(n.providerCredentials&&(!r||!Object.hasOwn(r,`providerCredentials`)))throw Error(`Provider credential inventory is missing`);if(n.magpie&&!r?.magpie?.available)throw Error(`Magpie source configuration is unavailable`);return{direction:`pull`,magpieAvailable:r?.magpie?.available===!0,magpie:n.magpie&&r?.magpie?.available?{bytes:0}:null,files:r?.files??t?.files??[],directories:r?.directories??t?.directories??[],agentsRoot:n.agentsRoot?r?.agentsRoot??null:null,providerCredentials:n.providerCredentials?r?.providerCredentials??null:null,deletes:t?.deletes??[],totalBytes:t?.totalBytes??0,selections:n}},xd=(e,t)=>({...e,direction:`push`,providerCredentials:t.providerCredentials?e.providerCredentials:null,magpie:t.magpie?e.magpie:null,agentsRoot:t.agentsRoot?e.agentsRoot:null,selections:t}),Sd=e=>e.files.length>0||e.directories.length>0||!!e.agentsRoot||!!e.providerCredentials||!!e.magpie,Cd=(e,t)=>{let r=n({relayUrl:e.relayUrl,serverId:e.serverId,hostEncPubJwk:e.hostEncPubJwk}),i=pd(t),a=async(e,t,n)=>{let a=await r.fetch(t,{method:e,headers:{...i,...n===void 0?{}:{"Content-Type":`application/json`}},body:n===void 0?void 0:JSON.stringify(n)}),o=await a.json().catch(()=>({}));if(!a.ok){let n=Error(typeof o.error==`string`?o.error:`Relay sync ${e} ${t} failed (${a.status})`);throw typeof o.code==`string`&&(n.code=o.code),n}return o};return{tunnel:r,async probe(e){let t=await a(`POST`,`/api/yuri/config-sync/probe`,{plan:e});return{remoteExisting:Array.isArray(t.remoteExisting)?t.remoteExisting:[],remoteAgentsRootExists:t.remoteAgentsRootExists===!0,remoteProviderCredentialsExists:t.remoteProviderCredentialsExists===!0,inventory:t.inventory}},async prepare(e,t){await a(`POST`,`/api/yuri/config-sync/prepare`,{plan:e,syncRunId:t})},async putTar(e,t,n){let a=await r.fetch(`/api/yuri/config-sync/put/${encodeURIComponent(e)}?syncRunId=${encodeURIComponent(n)}`,{method:`PUT`,headers:{...i,"Content-Type":e===`credentials`||e===`magpie`?`application/octet-stream`:`application/gzip`},body:new Blob([new Uint8Array(t)],{type:e===`credentials`||e===`magpie`?`application/octet-stream`:`application/gzip`})}),o=await a.json().catch(()=>({}));if(!a.ok){let t=Error(typeof o.error==`string`?o.error:`Relay sync put ${e} failed (${a.status})`);throw typeof o.code==`string`&&(t.code=o.code),t}},async download(e){let t=await r.fetch(`/api/yuri/config-sync/download/${encodeURIComponent(e)}`,{method:`GET`,headers:i});if(!t.ok){let n=await t.json().catch(()=>({})),r=Error(typeof n.error==`string`?n.error:`Relay sync download ${e} failed (${t.status})`);throw typeof n.code==`string`&&(r.code=n.code),r}return new Uint8Array(await t.arrayBuffer())},async finalize(e){let t=await a(`POST`,`/api/yuri/config-sync/finalize`,{syncRunId:e});return Array.isArray(t.magpieWarnings)?t.magpieWarnings.filter(e=>e===`sign_in_required`||e===`plugin_install_failed`||e===`agent_settings_skipped`):[]},async abort(e){await a(`POST`,`/api/yuri/config-sync/abort`,{syncRunId:e}).catch(()=>void 0)},close(){r.close()}}},wd=async(e,t,n,r)=>{if(dd.has(e)){let t=Error(`Config sync already in progress for ${e}`);throw t.code=`sync_in_progress`,t}let i=crypto.randomUUID(),a=new Date().toISOString();dd.set(e,i);try{let o=await r({syncRunId:i});return await hd({syncRunId:i,targetId:e,stage:t,direction:n,startedAt:a,endedAt:new Date().toISOString(),result:`success`,summary:md(o.plan)}),{...o,syncRunId:i}}catch(r){throw await hd({syncRunId:i,targetId:e,stage:t,direction:n,startedAt:a,endedAt:new Date().toISOString(),result:`failure`,summary:md(null),error:r instanceof Error?r.message:String(r)}).catch(()=>void 0),r}finally{dd.get(e)===i&&dd.delete(e)}},Td=async(e,t)=>{let n=await zn({direction:e,targetKind:`relay`}),r=vd(n),i=yd(r,t),a=e===`push`?await zn({direction:e,selections:i,targetKind:`relay`}):n;if(e===`push`&&!a)throw Error(`Local sync inventory unavailable`);return{selectionShape:r,selections:i,localPlan:a}},Ed=async(e,t={},n={})=>{let r=e.relay,i=fd(r.serverId),a=t.direction===`pull`?`pull`:`push`;return wd(i,`preview`,a,async()=>{await gd(r.serverId,n.refreshCandidates);let{selectionShape:i,selections:o,localPlan:s}=await Td(a,t),c=Cd(r,e);try{if(a===`pull`){let e=await c.probe({selections:o});return{plan:bd(e,s,o),remoteExisting:e.remoteExisting,remoteAgentsRootExists:e.remoteAgentsRootExists,remoteProviderCredentialsExists:e.remoteProviderCredentialsExists,selectionShape:i}}let e=xd(s,o),t=await c.probe(e);return{plan:e,remoteExisting:t.remoteExisting,remoteAgentsRootExists:t.remoteAgentsRootExists,remoteProviderCredentialsExists:t.remoteProviderCredentialsExists,selectionShape:s?.selectionShape??i}}finally{c.close()}})},Dd=async(e,t={},n={})=>{let r=e.relay,i=fd(r.serverId),a=t.direction===`pull`?`pull`:`push`;return wd(i,`apply`,a,async({syncRunId:i})=>{await gd(r.serverId,n.refreshCandidates);let{selections:o,localPlan:s}=await Td(a,t),c=Cd(r,e);try{if(a===`pull`){let e=bd(await c.probe({selections:o}),s,o);if(!Sd(e))return _d(e);let t=e.files.length>0||e.directories.length>0?await c.download(`config`):null,n=e.agentsRoot?await c.download(`agents`):null,r=e.providerCredentials?await c.download(`credentials`):null,a=e.magpie?await c.download(`magpie`):null;if(!D())throw Error(`Relay pull apply requires the Yuri desktop app`);let l=await k(`desktop_relay_sync_apply_local`,{syncRunId:i,plan:e,configTar:t,agentsTar:n,credentialPayload:r,magpiePayload:a});if(!l?.ok)throw Error(`Relay pull local apply failed`);return{...l,plan:e}}let e=xd(s,o);if(!Sd(e))return _d(e);if(!D())throw Error(`Relay push apply requires the Yuri desktop app`);let t=await k(`desktop_relay_sync_pack_local`,{plan:e});if(!t)throw Error(`Relay push local pack failed`);await c.prepare(e,i);let n=[];try{if(e.magpie){if(!t.magpiePayload?.byteLength)throw Error(`Magpie transfer incomplete`);await c.putTar(`magpie`,t.magpiePayload,i)}t.configTar&&t.configTar.byteLength>0&&await c.putTar(`config`,t.configTar,i),t.agentsTar&&t.agentsTar.byteLength>0&&await c.putTar(`agents`,t.agentsTar,i),t.credentialPayload&&t.credentialPayload.byteLength>0&&await c.putTar(`credentials`,t.credentialPayload,i),n=await c.finalize(i)}catch(e){throw await c.abort(i),e}return{ok:!0,files:e.files.length,directories:e.directories.length,deletes:e.deletes.length,totalBytes:e.totalBytes,agentsRoot:e.agentsRoot?{fileCount:e.agentsRoot.fileCount}:null,providerCredentials:e.providerCredentials?{bytes:e.providerCredentials.bytes}:null,...n.length?{magpieWarnings:n}:{},plan:e}}finally{c.close()}})},Od=()=>{let{t:e}=Ge(),t=h()&&O(),[n,r]=Q.useState(!1),[i,a]=Q.useState(!1),[o,s]=Q.useState(``),[u,d]=Q.useState(``),[f,p]=Q.useState(!1),[g,_]=Q.useState(null),[v,y]=Q.useState(!0),[x,S]=Q.useState(!1),[C,w]=Q.useState(null),[T,E]=Q.useState(null);Q.useEffect(()=>{if(!t){y(!1);return}let n=!1;return(async()=>{try{let t=await l(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});if(!t.ok)throw Error(e(`settings.yuri.desktopNetwork.error.loadFailed`));let i=await t.json().catch(()=>null);if(n)return;let o=i?.desktopLanAccessEnabled===!0,c=typeof i?.desktopUiPassword==`string`?i.desktopUiPassword:``;r(o),a(o),s(c),d(c),p(i?.desktopLanAccessActive===!0),_(typeof i?.desktopLanAccessBlockedReason==`string`?i.desktopLanAccessBlockedReason:null),w(null)}catch(t){n||w(t instanceof Error?t.message:e(`settings.yuri.desktopNetwork.error.loadFailed`))}finally{n||y(!1)}})(),()=>{n=!0}},[t,e]),Q.useEffect(()=>{if(!t||!i){E(null);return}let e=!1;return(async()=>{let t=await b();e||E(t)})(),()=>{e=!0}},[i,t]);let D=i!==n||u!==o,k=Q.useMemo(()=>{if(typeof window>`u`)return null;let e=c()||window.location.href,t=0;try{t=Number(new URL(e).port)}catch{t=Number(window.location.port)}return Number.isFinite(t)&&t>0?t:null},[]),A=i&&f&&T&&k?`http://${T}:${k}`:null,j=i&&!u.trim(),M=n&&!f&&g===`missing-password`,N=v||x||!D||j,P=Q.useCallback(()=>{a(e=>!e)},[]),F=Q.useCallback(e=>{d(e),e.trim()||a(!1)},[]),I=Q.useCallback(async()=>{if(D){S(!0),w(null);try{if(!(await l(`/api/config/settings`,{method:`PUT`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({desktopLanAccessEnabled:i,desktopUiPassword:u})})).ok)throw Error(e(`settings.yuri.desktopNetwork.error.saveFailed`));if(r(i),s(u),!await m())throw Error(e(`settings.yuri.desktopNetwork.error.savedRestartFailed`))}catch(t){w(t instanceof Error?t.message:e(`settings.yuri.desktopNetwork.error.saveFailed`)),S(!1)}}},[u,i,D,e]);return t?(0,$.jsxs)(Z,{className:`yuri-settings-detail-group`,label:e(`settings.yuri.desktopNetwork.title`),actions:(0,$.jsx)(q,{type:`button`,size:`xs`,className:`!font-normal`,onClick:I,disabled:N,"aria-busy":x,children:e(x?`settings.common.actions.saving`:`settings.yuri.desktopNetwork.actions.saveAndRestart`)}),children:[(0,$.jsx)(Xi,{itemId:`remote-instances.desktop-ui-password`,label:(0,$.jsx)(`label`,{htmlFor:`desktop-ui-password`,children:e(`settings.yuri.desktopPassword.field.password`)}),description:e(`settings.yuri.desktopPassword.field.passwordDescription`),children:(0,$.jsx)(Cn,{id:`desktop-ui-password`,type:`password`,className:`max-w-sm`,value:u,onChange:e=>F(e.target.value),placeholder:e(`settings.yuri.desktopPassword.field.passwordPlaceholder`),disabled:v||x,required:i,"aria-invalid":j})}),(0,$.jsxs)(`div`,{"data-settings-item":`remote-instances.desktop-lan-access`,className:`yuri-settings-group-row yuri-settings-split-row group cursor-pointer`,role:`button`,tabIndex:0,onClick:P,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),P())},children:[(0,$.jsxs)(`div`,{className:`yuri-settings-split-row-copy`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:e(`settings.yuri.desktopNetwork.field.allowLanAccess`)}),(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:e(`settings.yuri.desktopNetwork.field.allowLanAccessDescription`)}),(0,$.jsx)(`div`,{className:`typography-meta text-[var(--status-warning)]/85`,children:e(`settings.yuri.desktopNetwork.field.warning`)}),j||M?(0,$.jsx)(`div`,{className:`typography-meta text-[var(--status-warning)]/85`,children:e(`settings.yuri.desktopNetwork.field.passwordRequiredWarning`)}):null]}),(0,$.jsx)(`div`,{className:`yuri-settings-split-row-control`,children:(0,$.jsx)(Wi,{checked:i,onChange:P,ariaLabel:e(`settings.yuri.desktopNetwork.field.allowLanAccessAria`),disabled:v||x})})]}),C?(0,$.jsx)(`div`,{className:`yuri-settings-group-row typography-meta text-[var(--status-error)]`,children:C}):null,A?(0,$.jsxs)(`div`,{className:`yuri-settings-group-row typography-meta text-muted-foreground`,children:[e(D&&!n?`settings.yuri.desktopNetwork.hint.openAfterRestart`:`settings.yuri.desktopNetwork.hint.openNow`),(0,$.jsx)(`span`,{className:`font-mono text-foreground`,children:A})]}):null]}):null},kd=(e,t)=>{if(e!==i()||t!==o())throw Error(`runtime_changed`)},Ad=(e,t)=>({queryKey:[e,`remote-desktop-setup`,t],queryFn:async({signal:n})=>{kd(e,t),n.throwIfAborted();let r=await x({type:`status`});return n.throwIfAborted(),kd(e,t),r},retry:!1,refetchOnWindowFocus:`always`});function jd(){let e=(0,Sa.c)(10),t,n,r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=i(),t=o(),n=Ad(r,t),e[0]=t,e[1]=n,e[2]=r):(t=e[0],n=e[1],r=e[2]);let a=n,s=we(),c=De(a),l,u;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=[r,`remote-desktop-setup-action`,t],u=async e=>{kd(r,t);let n=await x(e);return kd(r,t),n},e[3]=l,e[4]=u):(l=e[3],u=e[4]);let d;e[5]===s?d=e[6]:(d={mutationKey:l,mutationFn:u,onSuccess:e=>{r===i()&&t===o()&&(s.setQueryData(a.queryKey,e),s.invalidateQueries({queryKey:[r,`remote-desktop`,t]}))},onError:()=>{r===i()&&t===o()&&s.invalidateQueries({queryKey:a.queryKey})}},e[5]=s,e[6]=d);let f=Te(d),p;return e[7]!==f||e[8]!==c?(p={query:c,mutation:f},e[7]=f,e[8]=c,e[9]=p):p=e[9],p}function Md(){let e=(0,Sa.c)(50),{t}=Ge(),{query:n,mutation:r}=jd(),i;e[0]!==r.isPending||e[1]!==n?(i=()=>{r.isPending||n.refetch({cancelRefetch:!1})},e[0]=r.isPending,e[1]=n,e[2]=i):i=e[2],Ve(`focus`,i,Nd);let a=n.data,o=r.isPending||n.isFetching,s;e[3]===t?s=e[4]:(s=e=>t(e===void 0?`common.loading`:e?`settings.remoteDesktop.granted`:`settings.remoteDesktop.required`),e[3]=t,e[4]=s);let c=s,l;e[5]===t?l=e[6]:(l=t(`remoteDesktop.title`),e[5]=t,e[6]=l);let u;e[7]===t?u=e[8]:(u=t(`settings.remoteDesktop.devices`),e[7]=t,e[8]=u);let d;e[9]!==r||e[10]!==n?(d=()=>{r.reset(),n.refetch()},e[9]=r,e[10]=n,e[11]=d):d=e[11];let f;e[12]===t?f=e[13]:(f=t(`settings.remoteDesktop.recheck`),e[12]=t,e[13]=f);let p;e[14]!==o||e[15]!==d||e[16]!==f?(p=(0,$.jsx)(q,{size:`xs`,className:`!font-normal`,disabled:o,onClick:d,children:f}),e[14]=o,e[15]=d,e[16]=f,e[17]=p):p=e[17];let m;e[18]===t?m=e[19]:(m=t(`settings.remoteDesktop.enable`),e[18]=t,e[19]=m);let h;e[20]===t?h=e[21]:(h=t(`settings.remoteDesktop.enable`),e[20]=t,e[21]=h);let g;e[22]===t?g=e[23]:(g=t(`settings.remoteDesktop.description`),e[22]=t,e[23]=g);let _=a?.enabled===!0,v=o||!a||!a.enabled&&!a.ready,y;e[24]===r?y=e[25]:(y=e=>r.mutate({type:`enabled`,enabled:e}),e[24]=r,e[25]=y);let b;e[26]!==_||e[27]!==v||e[28]!==y||e[29]!==m||e[30]!==h||e[31]!==g?(b=(0,$.jsx)(Ji,{itemId:`remote-instances.remote-desktop`,label:m,ariaLabel:h,description:g,checked:_,disabled:v,onChange:y}),e[26]=_,e[27]=v,e[28]=y,e[29]=m,e[30]=h,e[31]=g,e[32]=b):b=e[32];let x;e[33]!==o||e[34]!==r||e[35]!==c||e[36]!==a||e[37]!==t?(x=a?.supported===!1?(0,$.jsx)(Xi,{label:t(`settings.remoteDesktop.status`),children:(0,$.jsx)(`span`,{children:t(`remoteDesktop.unsupported`)})}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Xi,{itemId:`remote-instances.remote-desktop-screen`,label:t(`settings.remoteDesktop.screen`),description:t(`settings.remoteDesktop.screenHint`),children:[(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:c(a?a.screenRecording===`granted`:void 0)}),a&&a.screenRecording!==`granted`&&(0,$.jsx)(q,{size:`sm`,disabled:o,onClick:()=>r.mutate({type:`permission`,permission:`screen`}),children:t(`settings.remoteDesktop.authorize`)})]}),(0,$.jsxs)(Xi,{itemId:`remote-instances.remote-desktop-accessibility`,label:t(`settings.remoteDesktop.accessibility`),description:t(`settings.remoteDesktop.accessibilityHint`),children:[(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:c(a?.accessibility)}),a&&!a.accessibility&&(0,$.jsx)(q,{size:`sm`,disabled:o,onClick:()=>r.mutate({type:`permission`,permission:`accessibility`}),children:t(`settings.remoteDesktop.authorize`)})]}),(0,$.jsx)(Xi,{label:t(`settings.remoteDesktop.helper`),description:t(`settings.remoteDesktop.helperHint`),children:(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:t(a?a.helperAvailable?`settings.remoteDesktop.installed`:`settings.remoteDesktop.reinstall`:`common.loading`)})})]}),e[33]=o,e[34]=r,e[35]=c,e[36]=a,e[37]=t,e[38]=x):x=e[38];let S;e[39]!==r.error||e[40]!==n.error||e[41]!==t?(S=(n.error||r.error)&&(0,$.jsx)(Xi,{label:t(`settings.remoteDesktop.status`),children:(0,$.jsx)(`span`,{role:`alert`,className:`typography-meta text-[var(--status-error)]`,children:t(`settings.remoteDesktop.failed`)})}),e[39]=r.error,e[40]=n.error,e[41]=t,e[42]=S):S=e[42];let C;return e[43]!==b||e[44]!==x||e[45]!==S||e[46]!==l||e[47]!==u||e[48]!==p?(C=(0,$.jsxs)(Z,{label:l,description:u,actions:p,children:[b,x,S]}),e[43]=b,e[44]=x,e[45]=S,e[46]=l,e[47]=u,e[48]=p,e[49]=C):C=e[49],C}function Nd(){return window}function Pd(){let e=(0,Sa.c)(1);if(!h()||!O())return null;let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(Md,{}),e[0]=t):t=e[0],t}var Fd=`wss://relay.useyuri.top/ws`,Id=`yuri.pairing.relayUrl.v1`,Ld=e=>{if(typeof e!=`string`||!e.trim())return null;try{let t=new URL(e.trim());return t.protocol!==`ws:`&&t.protocol!==`wss:`||t.username||t.password?null:(t.username=``,t.password=``,t.hash=``,t.search=``,t.toString())}catch{return null}},Rd=(e=typeof window>`u`?null:window.localStorage)=>{if(!e)return null;try{return Ld(e.getItem(Id))}catch{return null}},zd=(e,t=typeof window>`u`?null:window.localStorage)=>{if(!t)return;let n=Ld(e);if(n)try{t.setItem(Id,n)}catch{}},Bd=`https://github.com/yee94/yuri/tree/main/packages/relay-server`,Vd=()=>Math.floor(2e4+Math.random()*3e4),Hd=e=>{if(!Number.isFinite(e)||e<0)return`0 B`;if(e<1024)return`${e} B`;let t=[`KB`,`MB`,`GB`,`TB`],n=e/1024;for(let e of t){if(n<1024||e===t[t.length-1])return`${n.toFixed(n>=10?0:1)} ${e}`;n/=1024}return`${e} B`},Ud={fileGroups:[],singleFiles:[],directories:[],agentsRoot:!0,providerCredentials:!1},Wd=e=>{let t=e.selectionShape;if(!t||typeof t!=`object`)return null;let n=typeof t.fileGroups==`number`?t.fileGroups:null,r=typeof t.singleFiles==`number`?t.singleFiles:null,i=typeof t.directories==`number`?t.directories:null;return n===null||r===null||i===null||n<0||r<0||i<0?null:{fileGroups:n,singleFiles:r,directories:i}},Gd=(e,t)=>e.fileGroups.length===t.fileGroups&&e.singleFiles.length===t.singleFiles&&e.directories.length===t.directories,Kd=[`settings.remoteInstances.page.sync.step.scanLocal`,`settings.remoteInstances.page.sync.step.compareRemote`,`settings.remoteInstances.page.sync.step.confirm`],qd=({open:e,instanceId:t,targetKind:n=`ssh`,relayHost:r=null,onOpenChange:i})=>{let{t:a}=Ge(),[o,s]=Q.useState(1),[c,l]=Q.useState(`scanning-local`),[u,d]=Q.useState(`push`),[f,p]=Q.useState(Ud),[m,h]=Q.useState(null),[g,_]=Q.useState(null),[v,y]=Q.useState(null),[b,x]=Q.useState(null),[S,C]=Q.useState(null),w=Q.useRef(Ud),T=Q.useRef(0),E=Q.useRef(Promise.resolve()),D=m!=null&&Gd(f,m),O=He(()=>{T.current+=1,s(1),l(`scanning-local`),d(`push`),p(Ud),h(null),_(null),y(null),x(null),C(null),w.current=Ud}),k=He(async(e=u,i=f)=>{if(!t)return;let o=++T.current,c=E.current,d;E.current=new Promise(e=>{d=e}),v||s(2),l(`comparing-remote`),x(null),C(null);try{if(await c,o!==T.current)return;let u=n===`relay`?r?await Ed(r,{direction:e,selections:i}):null:await hr(t,{targetKind:n,direction:e,selections:i});if(o!==T.current)return;if(!u){x(a(`settings.remoteInstances.page.sync.state.unavailable`)),C(2),l(`error`);return}y(u),w.current=i,s(3),l(`review`)}catch(e){if(o!==T.current)return;console.error(`[remote-instances] config sync compare-remote failed`,e),x(e instanceof Error?e.message:String(e)),C(2),l(`error`)}finally{d()}}),A=He(async(e=u,r=f)=>{if(!t)return;s(1);let i=++T.current;l(`scanning-local`),x(null),C(null),_(null),y(null);try{let t=m!=null&&Gd(r,m),o=await zn(t?{targetKind:n,direction:e,selections:r}:{targetKind:n,direction:e});if(i!==T.current)return;if(!o){h(null),x(a(`settings.remoteInstances.page.sync.state.unavailable`)),C(1),l(`error`);return}let s=Wd(o);if(!s){h(null),p(Ud),x(a(`settings.remoteInstances.page.sync.state.unavailable`)),C(1),l(`error`);return}h(s);let c=t?r:Fn(s,{includeProviderCredentials:!1});p(c),_(o),await k(e,c)}catch(e){if(i!==T.current)return;console.error(`[remote-instances] config sync scan-local failed`,e),x(e instanceof Error?e.message:String(e)),C(1),l(`error`)}});Q.useEffect(()=>{if(!(!e||!t))return A(`push`),()=>{T.current+=1}},[e,t,n,r,A]),Q.useEffect(()=>{e||O()},[e,O]);let j=Q.useMemo(()=>new Set(v?.remoteExisting??[]),[v]),M=v?.plan??g,N=!!(M&&(M.files.length>0||M.directories.length>0||M.agentsRoot!=null||M.providerCredentials!=null||M.magpie!=null)),P=c===`applying`,F=v!=null,I=M?M.deletes.length+(M.agentsRoot&&v?.remoteAgentsRootExists?1:0):0,L=He(()=>{if(S===2){k(u,f);return}A(u,f)}),R=He(e=>{if(e===u||P)return;d(e),y(null),_(null);let t={...f,magpie:!1};p(t),A(e,t)}),z=He(async()=>{if(!(!t||!N||P||c!==`review`)){l(`applying`);try{let e=n===`relay`?r?await Dd(r,{direction:u,selections:w.current}):null:await In(t,{targetKind:n,direction:u,selections:w.current});if(!e)throw Error(`Sync bridge unavailable`);let o=[...e.magpieWarnings?.includes(`sign_in_required`)?[a(`settings.remoteInstances.page.sync.magpie.signInRequired`)]:[],...e.magpieWarnings?.includes(`plugin_install_failed`)?[a(`settings.remoteInstances.page.sync.magpie.pluginInstallFailed`)]:[],...e.magpieWarnings?.includes(`agent_settings_skipped`)?[a(`settings.remoteInstances.page.sync.magpie.agentsSkipped`)]:[]];o.length?J.warning(a(`settings.remoteInstances.page.sync.toast.success`),{description:o.join(`
26
+ `)}):J.success(a(`settings.remoteInstances.page.sync.toast.success`)),i(!1)}catch(e){console.error(`[remote-instances] config sync apply failed`,e),J.error(a(`settings.remoteInstances.page.sync.toast.failed`),{description:e instanceof Error?e.message:String(e)}),l(`review`)}}}),B=e=>c===`error`&&S!=null?e<S?`done`:e===S?`active`:`pending`:c===`review`||c===`applying`||e<o?`done`:e===o?`active`:`pending`;return(0,$.jsx)(gn,{open:e,onOpenChange:i,children:(0,$.jsxs)(pn,{className:`min-h-0 sm:max-w-2xl`,children:[(0,$.jsxs)(dn,{className:`shrink-0`,children:[(0,$.jsx)(mn,{children:a(`settings.remoteInstances.page.sync.title`)}),(0,$.jsx)(hn,{children:a(`settings.remoteInstances.page.sync.description`)})]}),(0,$.jsxs)(`div`,{className:`shrink-0 space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsx)(q,{type:`button`,size:`xs`,variant:u===`push`?`default`:`outline`,className:`!font-normal`,"aria-pressed":u===`push`,disabled:P||c===`comparing-remote`||c===`scanning-local`,onClick:()=>R(`push`),children:a(`settings.remoteInstances.page.sync.direction.push`)}),(0,$.jsx)(q,{type:`button`,size:`xs`,variant:u===`pull`?`default`:`outline`,className:`!font-normal`,"aria-pressed":u===`pull`,disabled:P||c===`comparing-remote`||c===`scanning-local`,onClick:()=>R(`pull`),children:a(`settings.remoteInstances.page.sync.direction.pull`)})]}),(0,$.jsxs)(Z,{label:a(`settings.remoteInstances.page.sync.scope.title`),children:[D?null:(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground`,children:a(c===`scanning-local`||c===`comparing-remote`?`settings.remoteInstances.page.sync.step.scanLocal`:`settings.remoteInstances.page.sync.state.unavailable`)}),[{key:`config`,label:`config.json / opencode.json(c)`,index:0,kind:`fileGroups`},{key:`agents-md`,label:`AGENTS.md`,index:0,kind:`singleFiles`},{key:`cursor-models`,label:`cursor-models.json`,index:1,kind:`singleFiles`},{key:`agents`,label:`agents/`,index:0,kind:`directories`},{key:`commands`,label:`commands/`,index:1,kind:`directories`},{key:`skills`,label:`skills/`,index:2,kind:`directories`},{key:`plugins`,label:`plugins/`,index:5,kind:`directories`}].filter(e=>m!=null&&e.index<m[e.kind]).map(e=>{let t=f[e.kind][e.index]!==!1;return(0,$.jsx)(Ji,{label:(0,$.jsx)(`span`,{className:`font-mono break-all`,children:e.label}),checked:t,disabled:P||!D||!v,ariaLabel:e.label,onChange:t=>{if(!D)return;let n=[...f[e.kind]];n[e.index]=t;let r={...f,[e.kind]:n};p(r),k(u,r)}},e.key)}),(0,$.jsx)(Ji,{label:a(`settings.remoteInstances.page.sync.section.agentsRoot`),checked:f.agentsRoot,disabled:P||!D||!v,ariaLabel:a(`settings.remoteInstances.page.sync.section.agentsRoot`),onChange:e=>{if(!D)return;let t={...f,agentsRoot:e};p(t),k(u,t)}}),(0,$.jsx)(Ji,{label:(0,$.jsx)(`span`,{title:a(`settings.remoteInstances.page.sync.hint.providerCredentials`),children:a(`settings.remoteInstances.page.sync.section.providerCredentials`)}),checked:f.providerCredentials,disabled:P||!D||!v,ariaLabel:a(`settings.remoteInstances.page.sync.section.providerCredentials`),onChange:e=>{if(!D)return;let t={...f,providerCredentials:e};p(t),k(u,t)}}),v?.plan.magpieAvailable?(0,$.jsx)(Ji,{label:(0,$.jsx)(`span`,{title:a(`settings.remoteInstances.page.sync.hint.magpie`),children:a(`settings.remoteInstances.page.sync.section.magpie`)}),checked:f.magpie===!0,disabled:P,ariaLabel:a(`settings.remoteInstances.page.sync.section.magpie`),onChange:e=>{let t={...f,magpie:e};p(t),k(u,t)}}):null]}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-2`,"aria-busy":c===`scanning-local`||c===`comparing-remote`,children:Kd.map((e,t)=>{let n=t+1,r=B(n);return(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[r===`done`?(0,$.jsx)(X,{name:`check`,className:`h-3.5 w-3.5 shrink-0 text-[var(--status-success)]`}):r===`active`?(0,$.jsx)(X,{name:`refresh`,className:`h-3.5 w-3.5 shrink-0 animate-spin text-muted-foreground`}):(0,$.jsx)(`span`,{className:`flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-full border border-border/60 typography-micro text-muted-foreground`,children:n}),(0,$.jsx)(`span`,{className:K(`typography-meta`,r===`pending`?`text-muted-foreground`:`text-foreground`),children:a(e)})]},e)})}),c===`error`?(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`div`,{className:`typography-meta text-[var(--status-error)]`,children:a(`settings.remoteInstances.page.sync.state.error`,{message:b||``})}),(0,$.jsxs)(q,{type:`button`,variant:`outline`,size:`sm`,className:`!font-normal`,onClick:L,children:[(0,$.jsx)(X,{name:`refresh`,className:`h-3.5 w-3.5`}),a(`settings.remoteInstances.sidebar.actions.retry`)]})]}):null,F&&!N?(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:a(`settings.remoteInstances.page.sync.state.empty`)}):null,F&&N&&M?(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-3`,children:[(0,$.jsx)(`div`,{className:`overflow-hidden rounded-lg border border-border/60 bg-[var(--surface-elevated)]`,children:(0,$.jsxs)(`div`,{className:`divide-y divide-border/60`,children:[M.files.map(e=>{let t=j.has(e.path);return(0,$.jsxs)(`div`,{className:`flex h-8 items-center gap-2 px-2`,children:[(0,$.jsx)(X,{name:`file-text`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono typography-micro text-foreground`,title:e.path,children:[(0,$.jsxs)(`span`,{className:`sr-only`,children:[a(`settings.remoteInstances.page.sync.section.files`),`: `]}),e.path]}),(0,$.jsx)(`span`,{className:`shrink-0 tabular-nums typography-micro text-muted-foreground`,children:Hd(e.bytes)}),(0,$.jsx)(`span`,{className:K(`shrink-0 typography-micro`,t?`text-[var(--status-warning)]`:`text-[var(--status-success)]`),children:a(t?`settings.remoteInstances.page.sync.status.overwrite`:`settings.remoteInstances.page.sync.status.add`)})]},`file:${e.path}`)}),M.directories.map(e=>{let t=j.has(e.path);return(0,$.jsxs)(`div`,{className:`flex h-8 items-center gap-2 px-2`,children:[(0,$.jsx)(X,{name:`folder-3-fill`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono typography-micro text-foreground`,title:e.path,children:[(0,$.jsxs)(`span`,{className:`sr-only`,children:[a(`settings.remoteInstances.page.sync.section.directories`),`: `]}),e.path]}),(0,$.jsxs)(`span`,{className:`shrink-0 tabular-nums typography-micro text-muted-foreground`,children:[Hd(e.bytes),` · `,e.fileCount]}),(0,$.jsx)(`span`,{className:K(`shrink-0 typography-micro`,t?`text-[var(--status-warning)]`:`text-[var(--status-success)]`),children:a(t?`settings.remoteInstances.page.sync.status.overwrite`:`settings.remoteInstances.page.sync.status.add`)})]},`dir:${e.path}`)}),M.providerCredentials?(0,$.jsxs)(`div`,{className:`flex h-8 items-center gap-2 px-2`,children:[(0,$.jsx)(X,{name:`shield-keyhole`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate typography-micro text-foreground`,children:[(0,$.jsxs)(`span`,{className:`sr-only`,children:[a(`settings.remoteInstances.page.sync.section.providerCredentials`),`: `]}),a(`settings.remoteInstances.page.sync.section.providerCredentials`),(0,$.jsx)(`span`,{className:`ml-2 typography-micro text-muted-foreground`,children:a(`settings.remoteInstances.page.sync.hint.providerCredentials`)})]}),(0,$.jsx)(`span`,{className:`shrink-0 tabular-nums typography-micro text-muted-foreground`,children:Hd(M.providerCredentials.bytes)}),(0,$.jsx)(`span`,{className:K(`shrink-0 typography-micro`,v?.remoteProviderCredentialsExists?`text-[var(--status-warning)]`:`text-[var(--status-success)]`),children:v?.remoteProviderCredentialsExists?a(`settings.remoteInstances.page.sync.status.overwrite`):a(`settings.remoteInstances.page.sync.status.add`)})]}):null,M.magpie?(0,$.jsxs)(`div`,{className:`flex h-8 items-center gap-2 px-2`,children:[(0,$.jsx)(X,{name:`tools`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate typography-micro text-foreground`,title:a(`settings.remoteInstances.page.sync.hint.magpie`),children:[a(`settings.remoteInstances.page.sync.section.magpie`),(0,$.jsx)(`span`,{className:`ml-2 typography-micro text-muted-foreground`,children:a(`settings.remoteInstances.page.sync.hint.magpie`)})]})]}):null,M.agentsRoot?(0,$.jsxs)(`div`,{className:`flex h-8 items-center gap-2 px-2`,children:[(0,$.jsx)(X,{name:`tools`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono typography-micro text-foreground`,title:`~/.agents`,children:[(0,$.jsxs)(`span`,{className:`sr-only`,children:[a(`settings.remoteInstances.page.sync.section.agentsRoot`),`: `]}),`~/.agents`]}),(0,$.jsxs)(`span`,{className:`shrink-0 tabular-nums typography-micro text-muted-foreground`,children:[Hd(M.agentsRoot.bytes),` · `,a(`settings.remoteInstances.page.sync.section.agentsRootCount`,{count:M.agentsRoot.fileCount})]}),(0,$.jsx)(`span`,{className:K(`shrink-0 typography-micro`,v?.remoteAgentsRootExists?`text-[var(--status-warning)]`:`text-[var(--status-success)]`),children:v?.remoteAgentsRootExists?a(`settings.remoteInstances.page.sync.status.overwrite`):a(`settings.remoteInstances.page.sync.status.add`)})]}):null]})}),(0,$.jsx)(`div`,{className:`space-y-1 typography-micro text-muted-foreground`,children:I>0?(0,$.jsx)(`div`,{children:a(`settings.remoteInstances.page.sync.note.deletes`,{count:I})}):null})]}):null]}),(0,$.jsxs)(`div`,{className:`shrink-0 space-y-1 typography-micro text-muted-foreground`,children:[(0,$.jsx)(`div`,{children:a(`settings.remoteInstances.page.sync.note.backup`)}),(0,$.jsx)(`div`,{children:a(`settings.remoteInstances.page.sync.note.excluded`)})]}),(0,$.jsxs)(fn,{className:`shrink-0`,children:[(0,$.jsx)(q,{type:`button`,variant:`outline`,size:`sm`,className:`!font-normal`,onClick:()=>i(!1),disabled:P,children:a(`settings.remoteInstances.page.sync.actions.cancel`)}),(0,$.jsxs)(q,{type:`button`,size:`sm`,className:`!font-normal`,onClick:()=>void z(),disabled:!N||P||c!==`review`,children:[(0,$.jsx)(X,{name:`refresh`,className:K(`h-3.5 w-3.5`,P?`animate-spin`:``)}),a(P?`settings.remoteInstances.page.sync.applying`:`settings.remoteInstances.page.sync.actions.syncNow`)]})]})]})})},Jd=e=>{let t=(e instanceof Error?e.message:String(e)).toLowerCase();return t.includes(`address already in use`)||t.includes(`eaddrinuse`)||t.includes(`port already in use`)},Yd=()=>{if(typeof navigator>`u`)return;let e=(navigator.userAgent||``).toLowerCase();if(e.includes(`mac`))return`macos`;if(e.includes(`win`))return`windows`;if(e.includes(`linux`))return`linux`},Xd=e=>{switch((e||``).toLowerCase()){case`ios`:return`iOS`;case`android`:return`Android`;case`macos`:case`darwin`:return`macOS`;case`windows`:case`win32`:return`Windows`;case`linux`:return`Linux`;default:return null}},Zd=e=>{switch((e||``).toLowerCase()){case`ios`:return`device-ios`;case`android`:return`device-android`;case`macos`:case`darwin`:return`device-macos`;case`windows`:case`win32`:return`device-windows`;case`linux`:return`device-linux`;default:return null}},Qd=e=>{switch(e){case`config_resolved`:return`settings.remoteInstances.page.phase.resolvingConfiguration`;case`auth_check`:return`settings.remoteInstances.page.phase.checkingAuth`;case`master_connecting`:return`settings.remoteInstances.page.phase.establishingSsh`;case`remote_probe`:return`settings.remoteInstances.page.phase.probingRemote`;case`installing`:return`settings.remoteInstances.page.phase.installingYuri`;case`updating`:return`settings.remoteInstances.page.phase.updatingYuri`;case`server_detecting`:return`settings.remoteInstances.page.phase.detectingServer`;case`server_starting`:return`settings.remoteInstances.page.phase.startingServer`;case`forwarding`:return`settings.remoteInstances.page.phase.forwardingPorts`;case`ready`:return`settings.remoteInstances.sidebar.phase.ready`;case`degraded`:return`settings.remoteInstances.page.phase.reconnecting`;case`error`:return`settings.remoteInstances.sidebar.phase.error`;default:return`settings.remoteInstances.sidebar.phase.idle`}},$d=new Set([`config_resolved`,`auth_check`,`master_connecting`,`remote_probe`,`installing`,`updating`,`server_detecting`,`server_starting`,`forwarding`]),ef=e=>!!(e&&$d.has(e)),tf=e=>e===`ready`?`bg-[var(--status-success)] animate-pulse`:e===`error`?`bg-[var(--status-error)] animate-pulse`:e===`degraded`||ef(e)?`bg-[var(--status-warning)] animate-pulse`:`bg-muted-foreground/40`,nf=e=>{let t=(0,Sa.c)(8),{itemId:n,label:r,description:i,action:a,children:o}=e,s;t[0]===o?s=t[1]:(s=(0,$.jsx)(`div`,{className:`yuri-settings-group-row`,children:o}),t[0]=o,t[1]=s);let c;return t[2]!==a||t[3]!==i||t[4]!==n||t[5]!==r||t[6]!==s?(c=(0,$.jsx)(Z,{itemId:n,className:`yuri-settings-detail-group`,label:r,actions:a,description:i,children:s}),t[2]=a,t[3]=i,t[4]=n,t[5]=r,t[6]=s,t[7]=c):c=t[7],c},rf=e=>{let t=e.match(/^\[(\d{10,})\]\s*(?:\[([A-Z]+)\]\s*)?(.*)$/);if(!t)return e;let n=Number(t[1]);return`[${Number.isFinite(n)?new Date(n).toISOString():t[1]}] [${(t[2]||`INFO`).toUpperCase()}] ${t[3]||``}`},af=()=>{if(typeof window>`u`)return null;let e=c()||window.location.href;try{let t=Number(new URL(e).port||window.location.port);return Number.isFinite(t)&&t>0?t:null}catch{let e=Number(window.location.port);return Number.isFinite(e)&&e>0?e:null}},of=e=>{try{let t=new URL(e).hostname.toLowerCase();return t===`localhost`||t===`127.0.0.1`||t===`::1`||t===`[::1]`}catch{return!1}},sf=async()=>{let e=I(c())||window.location.origin;if(!h()||!O())return e;let t;try{t=await l(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}})}catch{return e}if(!t.ok||(await t.json().catch(()=>null))?.desktopLanAccessActive!==!0)return e;let n=await b(),r=af();return!n||!r?e:`http://${n}:${r}`},cf=e=>{let t=e.trim();if(t)try{window.location.assign(t)}catch{window.location.href=t}},lf=e=>{let t=e.sshCommand.trim(),n=e.nickname?.trim();return{...e,sshCommand:t,...n?{nickname:n}:{nickname:void 0}}},uf=({phase:e,onAction:t})=>{let{t:n}=Ge(),[r,i]=Q.useState(!1),a=Q.useRef(!1),o=r||ef(e)||e===`degraded`,s=e===`ready`;return(0,$.jsxs)(q,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,disabled:o,"aria-busy":o,onClick:async()=>{if(!(a.current||o)){a.current=!0,i(!0);try{await t()}finally{a.current=!1,i(!1)}}},children:[(0,$.jsx)(X,{name:o?`refresh`:s?`stop`:`plug-2`,className:`h-3.5 w-3.5 ${o?`animate-spin`:``}`}),n(s?`settings.remoteInstances.sidebar.actions.disconnect`:o?`settings.remoteInstances.page.actions.connecting`:`settings.remoteInstances.sidebar.actions.connect`)]})},df=()=>{let{t:e}=Ge(),{clientAuth:t}=ke(),i=D()?E():!1,o=hi(e=>e.instances),l=hi(e=>e.statusesById),u=hi(e=>e.isLoading),d=hi(e=>e.isSaving),f=hi(e=>e.error),p=hi(e=>e.load),m=hi(e=>e.loadImports),g=hi(e=>e.refreshStatuses),_=hi(e=>e.upsertInstance),v=hi(e=>e.createFromCommand),y=hi(e=>e.removeInstance),b=hi(e=>e.connect),x=hi(e=>e.disconnect),S=hi(e=>e.retry),C=G(e=>e.settingsRemoteInstancesSelectedId),w=G(e=>e.setSettingsRemoteInstancesSelectedId),T=Q.useMemo(()=>C&&o.find(e=>e.id===C)||null,[o,C]),[O,k]=Q.useState(null),[A,W]=Q.useState(!1),[ee,te]=Q.useState(!1),[ne,re]=Q.useState(null),[ie,ae]=Q.useState([]),[oe,se]=Q.useState(!1),[ce,le]=Q.useState(null),[ue,de]=Q.useState(`ssh`),[fe,pe]=Q.useState(null),[me,he]=Q.useState(null),[ge,_e]=Q.useState(``),[ve,ye]=Q.useState(!1),[xe,Se]=Q.useState(!1),Ce=Q.useRef(!1),[we,Te]=Q.useState(!1),[Ee,De]=Q.useState(!1),[Oe,Ae]=Q.useState(()=>Date.now()),[je,Me]=Q.useState([]),[Ne,Pe]=Q.useState({}),[Fe,Ie]=Q.useState(`local`),[Le,Re]=Q.useState(!1),[ze,Be]=Q.useState(!1),[Ve,Ue]=Q.useState(0),Ke=Qn(),[qe,Ye]=Q.useState(``),[Xe,Ze]=Q.useState(null),[Qe,$e]=Q.useState(!1),[et,tt]=Q.useState([]),[nt,rt]=Q.useState([]),[it,at]=Q.useState(!1),[ot,st]=Q.useState(``),ct=Q.useRef(!1),[lt,ut]=Q.useState(null),[dt,ft]=Q.useState(null),[pt,mt]=Q.useState(!1),[ht,gt]=Q.useState(null),[_t,vt]=Q.useState(null),[yt,bt]=Q.useState(null),[xt,St]=Q.useState(null),[Ct,wt]=Q.useState(!1),[Tt,Et]=Q.useState(!1),[Dt,Ot]=Q.useState(`configure`),[kt,At]=Q.useState(!1),[jt,Mt]=Q.useState(`relay`),[Nt,Pt]=Q.useState(!0),[Y,Ft]=Q.useState(Fd),[It,Lt]=Q.useState(null),[Rt,zt]=Q.useState(!1),[Bt,Vt]=Q.useState(!1),Ht=Q.useRef(null);Q.useEffect(()=>{Rt&&It&&Ht.current?.focus()},[Rt,It]);let[Ut,Wt]=Q.useState(null),Gt=Q.useMemo(()=>et.filter(e=>!!e.revokedAt).length,[et]),[Kt,qt]=Q.useState(!1),[Jt,Yt]=Q.useState(`ssh user@example.com`),[Xt,Zt]=Q.useState(``);Q.useEffect(()=>{i&&(p(),m())},[p,m,i]);let Qt=Q.useCallback(async()=>{Re(!0);try{let e=await z();Me(e.hosts||[]),Ie(e.defaultHostId||`local`)}catch(t){J.error(e(`desktopHostSwitcher.error.failedToLoad`),{description:t instanceof Error?t.message:String(t)})}finally{Re(!1)}},[e]);Q.useEffect(()=>{Qt()},[Qt]);let $t=Object.values(l).filter(e=>e.phase===`ready`).map(e=>`${e.id}:${e.localUrl||``}`).sort().join(`|`);Q.useEffect(()=>{$t&&Qt()},[Qt,$t]);let en=Q.useCallback(async(t,n=Fe)=>{Be(!0);try{return await L({hosts:t,defaultHostId:n,initialHostChoiceCompleted:!0}),Me(t),Ie(n),!0}catch(t){return J.error(e(`desktopHostSwitcher.error.failedToSave`),{description:t instanceof Error?t.message:String(t)}),!1}finally{Be(!1)}},[Fe,e]),tn=Q.useMemo(()=>new Set(o.map(e=>e.id)),[o]),nn=Q.useMemo(()=>je.filter(e=>P(e,tn)),[je,tn]),rn=He(async()=>{Ze(null);let t=Ga(qe);if(!t){Ze(e(`settings.remoteInstances.direct.error.invalidConnectLink`));return}let r=await M().catch(()=>``),i={method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({pairingId:t.pairingId,secret:t.secret,clientLabel:t.label||`Yuri Desktop`,clientKind:`desktop`,deviceName:`Yuri Desktop`,devicePlatform:Yd(),...r?{dedupeKey:`desktop:${r}`}:{}})},a=async e=>{if(!e.ok)return null;let t=await e.json().catch(()=>null);return(typeof t?.clientToken==`string`?t.clientToken.trim():``)||null},o=[...t.candidates].sort((e,t)=>(e.type===`relay`)-+(t.type===`relay`)),s=null;for(let e of o){if(e.type===`relay`){let t=n({relayUrl:e.relayUrl,serverId:e.serverId,hostEncPubJwk:e.hostEncPubJwk,...e.grant?{grant:e.grant}:{}});try{let n=await a(await t.fetch(`/api/client-auth/pairing/redeem`,i));if(n){s={kind:`relay`,relay:{relayUrl:e.relayUrl,serverId:e.serverId,hostEncPubJwk:e.hostEncPubJwk},token:n,tunnel:t},t.close();break}}catch{}t.close();continue}let t=I(e.url);if(t)try{let e=await a(await fetch(`${t}/api/client-auth/pairing/redeem`,i));if(e){s={kind:`direct`,url:t,token:e};break}}catch{}}if(!s){Ze(e(`settings.remoteInstances.direct.error.pairingFailed`));return}let c=()=>be(),l=t.candidates.find(e=>e.type===`relay`),u=s.kind===`relay`?s.relay:l?{relayUrl:l.relayUrl,serverId:l.serverId,hostEncPubJwk:l.hostEncPubJwk}:void 0,d=t.candidates.filter(e=>e.type!==`relay`),f=d.map(e=>I(e.url)).find(e=>!!e),p=d.filter(e=>e.type===`lan`).map(e=>I(e.url)).find(e=>!!e),m=s.kind===`direct`?s.url:p||f||null,{token:h}=s,g=m||(u?H(u.serverId):null);if(!g){Ze(e(`settings.remoteInstances.direct.error.invalidConnectLink`));return}let _={url:g,apiUrl:m||void 0,clientToken:h,source:V,...u?{relay:u}:{}},v=je.find(e=>u?e.relay?.serverId===u.serverId&&e.relay?.relayUrl===u.relayUrl:!e.relay&&I(e.apiUrl||e.url)===g);if(v){let e=je.map(e=>e.id===v.id?{...e,label:t.label||e.label,..._}:e);if(!await en(e,Fe))return}else if(!await en([{id:c(),label:t.label||j(g),..._},...je],Fe))return;Ye(``),Ze(null),$e(!1)}),an=Q.useCallback(async e=>{let t=je.filter(t=>t.id!==e);await en(t,Fe===e?`local`:Fe)},[Fe,je,en]),on=Q.useCallback(async()=>{let t=Jt.trim();if(!t){J.error(e(`settings.remoteInstances.page.toast.sshCommandRequired`));return}let n=`ssh-${Date.now()}-${Math.random().toString(16).slice(2)}`;try{await v(n,t,Xt.trim()||void 0),w(n),qt(!1),Yt(`ssh user@example.com`),Zt(``),J.success(e(`settings.remoteInstances.page.toast.instanceCreated`))}catch(t){J.error(e(`settings.remoteInstances.sidebar.toast.createFailed`),{description:t instanceof Error?t.message:String(t)})}},[v,w,Jt,Xt,e]),sn=Q.useCallback(async e=>{await en(je,e)},[je,en]),cn=He(async e=>{if(U(e)||Ke)return;let t=await er({host:e,cachedProbe:Ne[e.id]||null});Pe(n=>({...n,[e.id]:t.status}))}),ln=He(async t=>{if(Ke)return;let n=t.nickname?.trim()||t.sshParsed?.destination||t.id,r=je;try{let e=await z();r=e.hosts||[],Me(r),Ie(e.defaultHostId||`local`)}catch(t){J.error(e(`desktopHostSwitcher.toast.instanceUnreachable`,{host:n}),{description:t instanceof Error?t.message:String(t)});return}let i=r.find(e=>e.id===t.id)??null;if(!i||!N(i)||!i.clientToken){J.error(e(`desktopHostSwitcher.toast.instanceUnreachable`,{host:n}));return}U(i)||await er({host:i})});Q.useEffect(()=>{if(i)return r(()=>{Ue(e=>e+1)})},[i]),Q.useEffect(()=>{if(!i||nn.length===0)return;let e=!1;return Promise.all(nn.map(async e=>{let t=async()=>{let t=await F(e.relay,{clientToken:e.clientToken||null}).catch(()=>({status:`unreachable`,latencyMs:0}));return t.status===`ok`?{status:t.status,latencyMs:t.latencyMs,via:`relay`}:{status:t.status,latencyMs:t.latencyMs}};if(e.relay&&!e.apiUrl)return[e.id,await t()];let n=I(N(e));if(!n)return[e.id,e.relay?await t():{status:`unreachable`,latencyMs:0}];let r=await R(n,{clientToken:e.clientToken||null,requestHeaders:e.requestHeaders||null}).catch(()=>({status:`unreachable`,latencyMs:0}));if(r.status===`unreachable`&&e.relay){let n=await t();if(n.status===`ok`)return[e.id,n]}return[e.id,r]})).then(t=>{e||Pe(Object.fromEntries(t))}),()=>{e=!0}},[nn,i]);let un=Q.useCallback(async e=>{if(t){e?.silent||at(!0),e?.silent||ut(null);try{let[e,n]=await Promise.all([t.listClients(),t.listPendingPairings().catch(()=>null)]);tt(e),n&&rt(n)}catch(t){e?.silent||ut(t instanceof Error?t.message:String(t))}finally{e?.silent||at(!1)}}},[t]),_n=Q.useRef(!1);Q.useEffect(()=>{if(!(!Tt||Dt!==`result`||!yt)){if(nt.some(e=>e.id===yt)){_n.current=!0;return}_n.current&&(bt(null),Et(!1),et.some(e=>e.pairingId===yt)&&J.success(e(`settings.remoteInstances.clientAuth.addDevice.connectedToast`)))}},[Tt,Dt,yt,nt,et,e]);let vn=Q.useCallback(async e=>{if(t)try{await t.cancelPairing(e),rt(t=>t.filter(t=>t.id!==e)),await un({silent:!0})}catch(e){ut(e instanceof Error?e.message:String(e))}},[t,un]);Q.useEffect(()=>{if(!t)return;un();let e=window.setInterval(()=>{typeof document<`u`&&document.visibilityState!==`visible`||un({silent:!0})},5e3);return()=>window.clearInterval(e)},[t,un]);let yn=Q.useCallback(async()=>{let e=s()!==`local`;if(t?.getPairingTransports)try{let n=await t.getPairingTransports(),r=Ld(n.relayUrl),i=Array.from(new Set([...Array.isArray(n.relayUrls)?n.relayUrls:[],...r?[r]:[]].map(e=>Ld(e)).filter(e=>!!e)));return{serverName:n.serverName,localUrl:n.local,lanUrl:n.lan,relayAvailable:n.relayAvailable,relayUrl:r,relayUrls:n.relayAvailable?i:[],relayUrlLocked:n.relayUrlLocked===!0,remoteHost:e}}catch{}let n=af(),r=n?`http://127.0.0.1:${n}`:of(window.location.origin)?window.location.origin:null,i=null;try{let e=I(await sf());i=e&&!of(e)?e:null}catch{}return{localUrl:r,lanUrl:i,relayAvailable:!1,relayUrl:null,relayUrls:[],relayUrlLocked:!1,remoteHost:e}},[t]),bn=He(async()=>{ct.current=!1,st(``),ut(null),vt(null),St(null),wt(!1),bt(null),Lt(null),Ot(`configure`),zt(!1),Pt(!0),Et(!0);let e=await yn();ct.current||st(e.serverName||``),Wt(e),Vt(!1);let t=e.remoteHost?null:Rd();Ft((e.relayUrlLocked||e.remoteHost?e.relayUrl:t||e.relayUrl)||`wss://relay.useyuri.top/ws`),Mt(e.relayAvailable?`relay`:e.lanUrl?`lan`:`local`)}),xn=G(e=>e.devicePairingRequested);Q.useEffect(()=>{!xn||!t||(G.setState({devicePairingRequested:!1}),bn())},[xn,t,bn]);let Sn=He(async()=>{if(!(!t?.createPairingSession||!Ut)){ut(null),At(!0);try{let n=ot.trim()||void 0,r,i,a=!0;jt===`local`?(r=Ut.localUrl??void 0,i=!1):jt===`lan`?(r=Ut.lanUrl??void 0,i=Nt):Nt&&Ut.lanUrl?(r=Ut.lanUrl,i=!0):(a=!1,i=!0),Ut.relayAvailable||(i=!1);let o=i?Ld(Y):null;if(i&&!o){Lt(e(`settings.remoteInstances.clientAuth.addDevice.relayUrlInvalid`)),zt(!0);return}Lt(null);let{pairing:s,server:c}=await t.createPairingSession({label:n,allowedClientKinds:[`mobile`,`desktop`],serverUrl:r,includeRelay:i,includeDirect:a,...o?{relayUrl:o}:{}}),l=Ha({pairingId:s.id,secret:s.secret,label:n||c.label,fingerprint:s.fingerprint??void 0,expiresAt:s.expiresAt,candidates:c.candidates}),u=l.candidates.find(e=>e.type===`relay`);u&&(Ft(u.relayUrl),Ut?.remoteHost!==!0&&zd(u.relayUrl));let d=Ua(l);vt(d),St(await As.toDataURL(d,{width:1024,margin:2,errorCorrectionLevel:`L`})),wt(!1),_n.current=!1,bt(s.id),Ot(`result`),await un({silent:!0})}catch(e){ut(e instanceof Error?e.message:String(e))}finally{At(!1)}}}),Dn=Q.useCallback(()=>{_t&&We(_t).then(e=>{e.ok&&(wt(!0),window.setTimeout(()=>wt(!1),2e3))})},[_t]),On=He(async()=>{if(!(!t||!dt||pt||!dt.label.trim())){mt(!0),gt(null);try{let e=await t.renameClient(dt.id,dt.label.trim());tt(t=>t.map(t=>t.id===e.id?e:t)),ft(null),await un({silent:!0})}catch(e){gt(e instanceof Error?e.message:String(e))}finally{mt(!1)}}}),An=Q.useCallback(async e=>{if(!t)return;let n=e.clientKind===`desktop-local`;ut(null);try{if(await t.revokeClient(e.id),n&&h()){let t=await z();await L({hosts:t.hosts,defaultHostId:t.defaultHostId,initialHostChoiceCompleted:t.initialHostChoiceCompleted,localClientToken:null}),tt(t=>t.map(t=>t.id===e.id?{...t,revokedAt:new Date().toISOString()}:t)),a({apiBaseUrl:c(),clientToken:null,runtimeKey:`local`});return}await un()}catch(e){ut(e instanceof Error?e.message:String(e))}},[t,un]),jn=Q.useCallback(async()=>{if(t){ut(null);try{await t.purgeRevokedClients(),await un()}catch(e){ut(e instanceof Error?e.message:String(e))}}},[t,un]);Q.useEffect(()=>{k(T)},[T]),Q.useEffect(()=>{if(!i||!C)return;let e=window.setInterval(()=>{typeof document<`u`&&document.visibilityState!==`visible`||g()},2e3);return()=>{window.clearInterval(e)}},[g,C,i]),Q.useEffect(()=>{let e=null,t=Date.now(),n=()=>{let r=Date.now();r-t>=1e3&&(Ae(r),t=r),e=requestAnimationFrame(n)};(typeof document>`u`||document.visibilityState===`visible`)&&(e=requestAnimationFrame(n));let r=()=>{document.visibilityState===`visible`&&e===null?e=requestAnimationFrame(n):document.visibilityState!==`visible`&&e!==null&&(cancelAnimationFrame(e),e=null)};return document.addEventListener(`visibilitychange`,r),()=>{document.removeEventListener(`visibilitychange`,r),e!==null&&cancelAnimationFrame(e)}},[]);let Mn=C?l[C]:null,Nn=Mn?.phase,Pn=Nn===`ready`,Fn=Nn===`degraded`,In=ef(Nn),Rn=Pn||In||Fn,zn=Mn?Math.max(0,Oe-Mn.updatedAtMs):0,Bn=Fn&&zn>12e3,Hn=Q.useMemo(()=>!O||!T?!1:JSON.stringify(O)!==JSON.stringify(T),[O,T]),Wn=He(e=>{k(t=>t&&e(t))}),Gn=He(async()=>{if(!O||xe||d)return;let t=lf(O);if(!t.sshCommand.trim()){J.error(e(`settings.remoteInstances.page.toast.sshCommandRequired`));return}if(t.auth.sshPassword?.enabled&&t.auth.sshPassword.value?.trim()&&t.auth.sshPassword.store!==`settings`){let n=window.confirm(e(`settings.remoteInstances.page.confirm.storeSshPasswordPlaintext`));t.auth.sshPassword.store=n?`settings`:`never`,n||(t.auth.sshPassword.value=void 0)}if(t.auth.yuriPassword?.enabled&&t.auth.yuriPassword.value?.trim()&&t.auth.yuriPassword.store!==`settings`){let n=window.confirm(e(`settings.remoteInstances.page.confirm.storeUiPasswordPlaintext`));t.auth.yuriPassword.store=n?`settings`:`never`,n||(t.auth.yuriPassword.value=void 0)}try{await _(t),J.success(e(`settings.remoteInstances.page.toast.instanceSaved`))}catch(t){J.error(e(`settings.remoteInstances.page.toast.saveFailed`),{description:t instanceof Error?t.message:String(t)})}}),Kn=He(async()=>{if(!O||Ce.current||d)return;Ce.current=!0,Se(!0);let t=O.id;try{await y(t),Me(e=>e.filter(e=>e.id!==t)),Ie(e=>e===t?`local`:e),w(null),J.success(e(`settings.remoteInstances.page.toast.instanceRemoved`))}catch(t){J.error(e(`settings.remoteInstances.page.toast.removeInstanceFailed`),{description:t instanceof Error?t.message:String(t)})}finally{Ce.current=!1,Se(!1)}}),qn=Q.useCallback(async(t,n)=>{let r=`ssh-${Date.now()}-${Math.random().toString(16).slice(2)}`;try{return await v(r,`ssh ${n}`,t),w(r),J.success(e(`settings.remoteInstances.page.toast.instanceCreated`)),!0}catch(t){return J.error(e(`settings.remoteInstances.sidebar.toast.createFailed`),{description:t instanceof Error?t.message:String(t)}),!1}},[v,w,e]),Jn=Q.useCallback(()=>{ve||(he(null),_e(``))},[ve]),Yn=Q.useCallback(async()=>{let t=me,n=ge.trim();if(t){if(!n){J.error(e(`settings.remoteInstances.page.toast.destinationRequired`));return}ye(!0);try{await qn(t,n)&&(he(null),_e(``))}finally{ye(!1)}}},[qn,ge,me,e]),Zn=Q.useCallback(async()=>{if(T)try{await b(T.id);return}catch(t){if(!Jd(t)||!window.confirm(e(`settings.remoteInstances.sidebar.confirm.localPortInUseRetry`)))throw t;let n={...T,localForward:{...T.localForward,preferredLocalPort:Vd()}};await _(n),await b(n.id),J.success(e(`settings.remoteInstances.sidebar.toast.retriedWithRandomPort`))}},[b,T,e,_]),$n=Q.useCallback(async e=>(await Ln(e,600)).map(e=>rf(e)),[]),tr=Q.useCallback(async()=>{if(O){W(!0),te(!0),re(null);try{let e=await $n(O.id);ae(e)}catch(e){ae([]),re(e instanceof Error?e.message:String(e))}finally{te(!1)}}},[O,$n]);Q.useEffect(()=>{if(!A||!O)return;let e=!1,t=async()=>{try{let t=await $n(O.id);e||(ae(t),re(null))}catch(t){e||re(t instanceof Error?t.message:String(t))}};t();let n=window.setInterval(()=>{typeof document<`u`&&document.visibilityState!==`visible`||t()},1e3);return()=>{e=!0,window.clearInterval(n)}},[O,A,$n]);let nr=Q.useMemo(()=>ie.join(`
27
+ `),[ie]),rr=Q.useCallback(()=>{if(!nr.trim()){J.error(e(`settings.remoteInstances.page.toast.noLogsToCopy`));return}We(nr).then(t=>{t.ok&&J.success(e(`settings.remoteInstances.page.toast.logsCopied`))})},[nr,e]),ir=Q.useCallback(async()=>{if(O)try{await Xn(O.id),ae([]),J.success(e(`settings.remoteInstances.page.toast.logsCleared`))}catch(t){J.error(e(`settings.remoteInstances.page.toast.clearLogsFailed`),{description:t instanceof Error?t.message:String(t)})}},[O,e]),ar=Q.useCallback(async()=>{if(!Mn?.localUrl){J.error(e(`settings.remoteInstances.page.toast.instanceUrlUnavailable`));return}let t=Mn.localUrl.trim();if(!t){J.error(e(`settings.remoteInstances.page.toast.instanceUrlUnavailable`));return}cf(t)},[Mn?.localUrl,e]),or=Q.useCallback((e,t=`ssh`,n=null)=>{le(e),de(t),pe(n),se(!0)},[]),sr=Q.useCallback(()=>{if(!O)return;let t=Rn,n=O.id;Te(!0),(t?x(n):Zn()).catch(n=>{let r=t?Pn?`settings.remoteInstances.page.toast.disconnectFailed`:`settings.remoteInstances.page.toast.cancelConnectionFailed`:`settings.remoteInstances.page.toast.connectFailed`,i=Mn?.detail||(n instanceof Error?n.message:String(n)),a=Vn(Mn?.errorCode,i);J.error(e(r),{description:t?n instanceof Error?n.message:String(n):cr(e(Un(a)),a,i)})}).finally(()=>{Te(!1)})},[Rn,Zn,x,O,Pn,Mn,e]),lr=Q.useCallback(()=>{O&&(In||(De(!0),(Fn?x(O.id).then(()=>Zn()):S(O.id)).catch(t=>{let n=Mn?.detail||(t instanceof Error?t.message:String(t)),r=Vn(Mn?.errorCode,n);J.error(e(`settings.remoteInstances.page.toast.retryFailed`),{description:cr(e(Un(r)),r,n)})}).finally(()=>{De(!1)})))},[Zn,x,O,In,Fn,S,Mn,e]),ur=e(In?`settings.remoteInstances.page.actions.connecting`:Fn?Bn?`settings.remoteInstances.page.actions.reconnectNow`:`settings.remoteInstances.page.actions.reconnecting`:`settings.remoteInstances.sidebar.actions.retry`),dr=!we&&!Ee&&(Nn===`error`||Nn===`idle`||!Nn||Fn&&Bn)&&!In,fr=e(Pn?`settings.remoteInstances.sidebar.actions.disconnect`:Rn?`settings.remoteInstances.page.actions.cancel`:`settings.remoteInstances.sidebar.actions.connect`);if(!O)return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(jl,{children:[t?(0,$.jsxs)(nf,{itemId:`remote-instances.client-auth`,label:e(`settings.remoteInstances.clientAuth.title`),action:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,$.jsx)(q,{type:`button`,size:`xs`,className:`!font-normal`,onClick:()=>{Ze(null),$e(!0)},disabled:ze,children:e(`settings.remoteInstances.direct.import.action`)}),(0,$.jsxs)(q,{type:`button`,size:`xs`,className:`!font-normal`,onClick:()=>void bn(),children:[(0,$.jsx)(X,{name:`add`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.clientAuth.actions.addDevice`)]}),Gt>0?(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>void jn(),children:e(`settings.remoteInstances.clientAuth.actions.clearRevoked`)}):null]}),children:[(0,$.jsx)(`div`,{className:`space-y-1`,children:it&&et.length===0&&nt.length===0?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e(`settings.remoteInstances.clientAuth.state.loading`)}):et.length===0&&nt.length===0?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e(`settings.remoteInstances.clientAuth.state.empty`)}):(0,$.jsxs)($.Fragment,{children:[nt.map(t=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-1.5`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full bg-[var(--status-warning)] animate-pulse`}),(0,$.jsx)(`p`,{className:`typography-ui-label text-foreground truncate`,children:t.label||e(`settings.remoteInstances.clientAuth.field.labelPlaceholder`)}),t.usesRelay?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-muted px-1 rounded shrink-0 leading-none pb-px border border-border/50`,children:e(`settings.remoteInstances.clientAuth.state.viaRelay`)}):null]}),(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground truncate`,children:e(`settings.remoteInstances.clientAuth.state.pending`)})]}),(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>void vn(t.id),children:e(`settings.common.actions.cancel`)})]},`pending-${t.id}`)),et.map(t=>{let n=t.clientKind===`desktop-local`,r=t.lastUsedAt?Date.parse(t.lastUsedAt):NaN,i=!t.revokedAt&&(n||Number.isFinite(r)&&Date.now()-r<9e4),a=t.revokedAt?e(`settings.remoteInstances.clientAuth.state.revoked`):i?t.lastTransport===`relay`&&!n?e(`settings.remoteInstances.clientAuth.state.connectedRelay`):e(`settings.remoteInstances.clientAuth.state.connectedDirect`):t.lastUsedAt?e(`settings.remoteInstances.clientAuth.lastUsed`,{date:cd(r,{locale:Je()})}):e(`settings.remoteInstances.clientAuth.neverUsed`),o=Number.isFinite(r)?new Date(r).toLocaleString(Je()):void 0;return(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 py-1.5`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 basis-48`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:K(`h-2 w-2 shrink-0 rounded-full`,t.revokedAt?`bg-muted-foreground/20`:i?`bg-[var(--status-success)]`:`bg-muted-foreground/30`)}),(0,$.jsx)(`p`,{className:`typography-ui-label text-foreground truncate`,children:t.label}),(()=>{let e=Xd(t.devicePlatform),n=Zd(t.devicePlatform);return e&&n?(0,$.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 rounded-full border border-border/50 px-1.5 py-px text-muted-foreground`,title:e,"aria-label":e,children:[(0,$.jsx)(X,{name:n,className:`h-3 w-3`}),(0,$.jsx)(`span`,{className:`typography-micro leading-none`,children:e})]}):null})(),n?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-muted px-1 rounded flex-shrink-0 leading-none pb-px border border-border/50`,children:e(`settings.remoteInstances.clientAuth.state.thisDevice`)}):null]}),(0,$.jsx)(`p`,{className:K(`typography-micro truncate`,i&&!t.revokedAt?`text-[var(--status-success)]`:`text-muted-foreground`),title:o,children:a})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>{gt(null),ft({id:t.id,label:t.label})},disabled:pt,children:e(`settings.remoteInstances.clientAuth.edit.action`)}),(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>void An(t),disabled:!!t.revokedAt||pt,children:e(`settings.remoteInstances.clientAuth.actions.revoke`)})]})]},t.id)})]})}),lt?(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:lt}):null]}):null,!i&&D()?(0,$.jsx)(nf,{itemId:`remote-instances.instances`,label:e(`settings.remoteInstances.sidebar.title`),children:(0,$.jsx)(q,{size:`sm`,onClick:()=>void B().catch(e=>J.error(String(e))),children:e(`settings.remoteInstances.openLocalManager`)})}):null,i?(0,$.jsx)(nf,{itemId:`remote-instances.instances`,label:e(`settings.remoteInstances.sidebar.title`),action:nn.length>0||o.length>0?(0,$.jsx)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:(0,$.jsxs)(q,{type:`button`,size:`xs`,className:`!font-normal`,onClick:()=>qt(!0),children:[(0,$.jsx)(X,{name:`add`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.sidebar.actions.addSshInstance`)]})}):void 0,children:(0,$.jsx)(`div`,{className:`space-y-1`,children:Le||u?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e(`settings.remoteInstances.direct.state.loading`)}):nn.length===0&&o.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center px-6 py-10 text-center`,children:[(0,$.jsx)(X,{name:`device-desktop`,className:`mb-5 size-16 text-muted-foreground/45`}),(0,$.jsx)(`p`,{className:`typography-ui-label font-medium text-foreground`,children:e(`settings.remoteInstances.quick.sshTitle`)}),(0,$.jsx)(`p`,{className:`mt-2 max-w-sm typography-meta leading-relaxed text-muted-foreground`,children:e(`settings.remoteInstances.quick.sshHint`)}),(0,$.jsxs)(q,{type:`button`,variant:`secondary`,size:`sm`,className:`mt-6 gap-2 rounded-xl`,onClick:()=>qt(!0),children:[(0,$.jsx)(X,{name:`add`,className:`size-4`}),e(`settings.remoteInstances.sidebar.actions.addSshInstance`)]})]}):(0,$.jsxs)($.Fragment,{children:[nn.map(t=>{let n=Ne[t.id],r=n?n.status===`ok`?`desktopHostSwitcher.status.connected`:n.status===`auth`?`desktopHostSwitcher.status.authRequired`:n.status===`update-recommended`?`desktopHostSwitcher.status.updateRecommended`:n.status===`incompatible`?`desktopHostSwitcher.status.incompatible`:n.status===`wrong-service`?`desktopHostSwitcher.status.wrongService`:`desktopHostSwitcher.status.unreachable`:`desktopHostSwitcher.status.checking`,i=n?.status===`ok`,a=U(t),o=a||Ke||ze;return(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-1.5`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:K(`h-2 w-2 shrink-0 rounded-full`,n?i||a?`bg-[var(--status-success)]`:`bg-[var(--status-error)]`:`bg-muted-foreground/30 animate-pulse`)}),(0,$.jsx)(`p`,{className:`typography-ui-label text-foreground truncate`,children:j(t.label)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-muted px-1 rounded flex-shrink-0 leading-none pb-px border border-border/50`,children:e(`settings.remoteInstances.channel.link`)}),a?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground shrink-0`,children:e(`desktopHostSwitcher.header.current`)}):null,Fe===t.id?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground shrink-0`,children:e(`desktopHostSwitcher.header.default`)}):null,(0,$.jsxs)(`span`,{className:K(`typography-micro shrink-0`,i||a?`text-[var(--status-success)]`:`text-muted-foreground`),children:[e(r),i&&typeof n?.latencyMs==`number`?e(`desktopHostSwitcher.status.ping`,{ms:Math.max(0,Math.round(n.latencyMs))}):``]})]}),(0,$.jsx)(`p`,{className:K(`typography-micro text-muted-foreground truncate`,t.apiUrl&&`font-mono`),children:t.relay&&!t.apiUrl?e(`mobile.connect.relay.badge`):j(t.apiUrl||t.url)})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,$.jsxs)(q,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>void cn(t),disabled:o,"aria-label":e(`desktopHostSwitcher.actions.switchToAria`,{instance:j(t.label)}),children:[(0,$.jsx)(X,{name:`arrow-left-right`,className:`h-3.5 w-3.5`}),e(a?`desktopHostSwitcher.header.current`:`desktopHostSwitcher.actions.switchInstance`)]}),(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>void sn(t.id),disabled:ze||Fe===t.id,"aria-label":e(`desktopHostSwitcher.actions.setAsDefaultAria`),children:Fe===t.id?(0,$.jsx)(X,{name:`star-fill`,className:`h-3.5 w-3.5`}):(0,$.jsx)(X,{name:`star`,className:`h-3.5 w-3.5`})}),(()=>{let n=N(t),r=!!n&&!n.startsWith(`relay://`)&&!t.relay;return t.relay?.serverId&&t.relay?.relayUrl&&t.relay?.hostEncPubJwk&&t.clientToken&&t.relay?(0,$.jsxs)(q,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>or(t.id,`relay`,t),"aria-label":e(`settings.remoteInstances.page.sync.title`),children:[(0,$.jsx)(X,{name:`refresh`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.page.sync.actions.syncNow`)]}):r?(0,$.jsxs)(q,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>or(t.id,`direct`),"aria-label":e(`settings.remoteInstances.page.sync.title`),children:[(0,$.jsx)(X,{name:`refresh`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.page.sync.actions.syncNow`)]}):null})(),(0,$.jsxs)(q,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>void an(t.id),disabled:ze||Ke,children:[(0,$.jsx)(X,{name:`delete-bin`,className:`h-3.5 w-3.5`}),e(`settings.common.actions.delete`)]})]})]},`link:${t.id}`)}),o.map(t=>{let n=l[t.id],r=t.nickname?.trim()||t.sshParsed?.destination||t.id,i=n?.phase,a=i===`ready`,o=je.find(e=>e.id===t.id),s=U({id:t.id,label:r,url:n?.localUrl||o?.url||``}),c=(0,$.jsxs)(q,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>void ln(t),disabled:s||Ke||!a,"aria-label":e(`desktopHostSwitcher.actions.switchToAria`,{instance:r}),children:[(0,$.jsx)(X,{name:`arrow-left-right`,className:`h-3.5 w-3.5`}),e(s?`desktopHostSwitcher.header.current`:`desktopHostSwitcher.actions.switchInstance`)]});return(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-1.5`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${tf(i)}`}),(0,$.jsx)(`p`,{className:`typography-ui-label text-foreground truncate`,children:r}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-muted px-1 rounded flex-shrink-0 leading-none pb-px border border-border/50`,children:e(`settings.remoteInstances.channel.ssh`)}),s?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground shrink-0`,children:e(`desktopHostSwitcher.header.current`)}):null]}),(0,$.jsxs)(`p`,{className:`typography-micro text-muted-foreground truncate`,children:[e(Qd(i)),n?.localUrl?` · ${n.localUrl}`:``]})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,$.jsx)(uf,{phase:i,onAction:()=>(a?x(t.id):b(t.id)).catch(t=>{let r=n?.detail||(t instanceof Error?t.message:String(t)),i=Vn(n?.errorCode,r);J.error(e(a?`settings.remoteInstances.sidebar.toast.disconnectFailed`:`settings.remoteInstances.sidebar.toast.connectFailed`),{description:a?t instanceof Error?t.message:String(t):cr(e(Un(i)),i,r)})})}),a?c:(0,$.jsxs)(En,{children:[(0,$.jsx)(wn,{asChild:!0,children:(0,$.jsx)(`span`,{className:`inline-flex`,children:c})}),(0,$.jsx)(Tn,{sideOffset:8,className:`max-w-xs`,children:e(`settings.remoteInstances.sidebar.actions.switchInstanceDisabled`)})]}),a&&t.remoteYuri?.mode!==`external`?(0,$.jsxs)(q,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>or(t.id),children:[(0,$.jsx)(X,{name:`refresh`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.sidebar.actions.syncConfig`)]}):(0,$.jsxs)(En,{children:[(0,$.jsx)(wn,{asChild:!0,children:(0,$.jsx)(`span`,{className:`inline-flex`,children:(0,$.jsxs)(q,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,disabled:!0,"aria-label":e(`settings.remoteInstances.sidebar.actions.syncConfigDisabled`),children:[(0,$.jsx)(X,{name:`refresh`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.sidebar.actions.syncConfig`)]})})}),(0,$.jsx)(Tn,{sideOffset:8,className:`max-w-xs`,children:e(`settings.remoteInstances.sidebar.actions.syncConfigDisabled`)})]}),(0,$.jsxs)(q,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>w(t.id),children:[(0,$.jsx)(X,{name:`pencil`,className:`h-3.5 w-3.5`}),e(`desktopHostSwitcher.actions.edit`)]})]})]},`ssh:${t.id}`)})]})})}):null,(0,$.jsx)(gn,{open:dt!==null,onOpenChange:e=>{!e&&!pt&&ft(null)},children:(0,$.jsxs)(pn,{className:`sm:max-w-sm`,showCloseButton:!pt,children:[(0,$.jsx)(dn,{children:(0,$.jsx)(mn,{children:e(`settings.remoteInstances.clientAuth.edit.title`)})}),(0,$.jsxs)(`form`,{className:`space-y-4`,onSubmit:e=>{e.preventDefault(),On()},children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`label`,{htmlFor:`remote-client-name`,className:`typography-ui-label text-muted-foreground`,children:e(`settings.remoteInstances.clientAuth.edit.name`)}),(0,$.jsx)(Cn,{id:`remote-client-name`,className:`text-left`,autoFocus:!0,value:dt?.label??``,maxLength:80,disabled:pt,onChange:e=>ft(t=>t?{...t,label:e.target.value}:null),onKeyDown:e=>{e.key===`Enter`&&e.nativeEvent.isComposing&&e.preventDefault()},"aria-invalid":!!ht,"aria-describedby":ht?`remote-client-name-error`:void 0}),ht?(0,$.jsx)(`p`,{id:`remote-client-name-error`,role:`alert`,className:`typography-meta text-[var(--status-error)]`,children:ht}):null]}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>ft(null),disabled:pt,children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(q,{type:`submit`,size:`sm`,disabled:pt||!dt?.label.trim(),children:e(`settings.common.actions.saveChanges`)})]})]})]})}),i?(0,$.jsx)(gn,{open:Qe,onOpenChange:e=>{$e(e),Ze(null)},children:(0,$.jsxs)(pn,{className:`sm:max-w-lg`,children:[(0,$.jsxs)(dn,{children:[(0,$.jsx)(mn,{children:e(`settings.remoteInstances.direct.import.action`)}),(0,$.jsx)(hn,{children:e(`settings.remoteInstances.direct.import.description`)})]}),(0,$.jsxs)(`form`,{className:`space-y-4`,onSubmit:e=>{e.preventDefault(),rn()},children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Cn,{value:qe,onChange:e=>{Ye(e.target.value),Ze(null)},placeholder:e(`settings.remoteInstances.direct.import.placeholder`),"aria-label":e(`settings.remoteInstances.direct.import.action`),"aria-invalid":!!Xe,"aria-describedby":Xe?`remote-import-error`:void 0,disabled:ze,autoFocus:!0}),Xe?(0,$.jsx)(`div`,{id:`remote-import-error`,role:`alert`,className:`rounded-lg bg-[var(--status-error-background)] px-3 py-2.5 typography-meta leading-relaxed text-[var(--status-error)] break-words`,children:Xe}):null]}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>{$e(!1),Ze(null)},disabled:ze,children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(q,{type:`submit`,size:`sm`,disabled:ze||!qe.trim(),children:e(`settings.remoteInstances.direct.import.action`)})]})]})]})}):null,(0,$.jsx)(gn,{open:Tt,onOpenChange:Et,children:(0,$.jsxs)(pn,{className:`sm:max-w-xl`,children:[(0,$.jsxs)(dn,{className:`items-center pt-4 text-center sm:text-center`,children:[Dt===`configure`?(0,$.jsx)(X,{name:`devices-connected`,className:`mb-3 size-20 text-muted-foreground`}):null,(0,$.jsx)(mn,{className:`text-xl`,children:e(Dt===`result`?`settings.remoteInstances.clientAuth.qrDialogTitle`:`settings.remoteInstances.clientAuth.actions.addDevice`)}),(0,$.jsx)(hn,{className:`max-w-sm text-center leading-relaxed`,children:e(Dt===`result`?`settings.remoteInstances.clientAuth.qrScanHint`:`settings.remoteInstances.quick.emptyHint`)})]}),Dt===`configure`?(0,$.jsxs)(`ol`,{className:`grid grid-cols-3 gap-3 py-4 text-center`,children:[(0,$.jsxs)(`li`,{className:`flex min-w-0 flex-col items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`flex size-6 shrink-0 items-center justify-center rounded-full bg-[var(--surface-muted)] typography-micro text-muted-foreground`,"aria-hidden":`true`,children:`1`}),(0,$.jsxs)(`a`,{href:`https://github.com/yee94/yuri/releases`,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>{e.preventDefault(),Br(`https://github.com/yee94/yuri/releases`)},className:`inline-flex items-center justify-center gap-1 whitespace-nowrap typography-meta text-foreground underline decoration-[var(--interactive-border)] underline-offset-4 hover:decoration-current`,children:[e(`settings.remoteInstances.pairing.downloadStep`),(0,$.jsx)(X,{name:`external-link`,className:`size-3 shrink-0`})]})]}),(0,$.jsxs)(`li`,{className:`flex min-w-0 flex-col items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`flex size-6 shrink-0 items-center justify-center rounded-full bg-[var(--surface-muted)] typography-micro text-muted-foreground`,"aria-hidden":`true`,children:`2`}),(0,$.jsx)(`p`,{className:`typography-meta text-foreground`,children:e(`settings.remoteInstances.clientAuth.addDevice.create`)})]}),(0,$.jsxs)(`li`,{className:`flex min-w-0 flex-col items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`flex size-6 shrink-0 items-center justify-center rounded-full bg-[var(--surface-muted)] typography-micro text-muted-foreground`,"aria-hidden":`true`,children:`3`}),(0,$.jsx)(`p`,{className:`typography-meta text-foreground`,children:e(`settings.remoteInstances.clientAuth.qrDialogTitle`)})]})]}):null,Dt===`configure`?(0,$.jsxs)(`form`,{className:`space-y-4`,onSubmit:e=>{e.preventDefault(),Sn()},children:[(0,$.jsxs)(`label`,{className:`block space-y-3 rounded-2xl bg-[var(--surface-muted)] p-4`,children:[(0,$.jsxs)(`span`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.remoteInstances.pairing.name`)}),(0,$.jsx)(`span`,{id:`add-device-instance-name-hint`,className:`font-normal text-muted-foreground`,style:{fontSize:`var(--form-helper-font-size)`,lineHeight:`var(--form-helper-line-height)`},children:e(`settings.remoteInstances.clientAuth.field.labelHint`)})]}),(0,$.jsx)(Cn,{className:`w-full hover:[&:not(:focus)]:ring-border/60`,value:ot,onChange:e=>{ct.current=!0,st(e.target.value)},placeholder:e(`settings.remoteInstances.clientAuth.field.labelPlaceholder`),"aria-describedby":`add-device-instance-name-hint`})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label text-foreground`,children:e(`settings.remoteInstances.clientAuth.addDevice.transportLabel`)}),(0,$.jsx)(`div`,{role:`radiogroup`,"aria-label":e(`settings.remoteInstances.clientAuth.addDevice.transportLabel`),className:`grid grid-cols-3 gap-2 pt-2`,children:[{key:`relay`,label:e(`settings.remoteInstances.clientAuth.addDevice.transport.relay`),hint:e(`settings.remoteInstances.pairing.anywhere`),available:!!Ut?.relayAvailable},{key:`lan`,label:e(`settings.remoteInstances.clientAuth.addDevice.transport.lan`),hint:e(`settings.remoteInstances.pairing.lan`),available:!!Ut?.lanUrl},{key:`local`,label:e(`settings.remoteInstances.clientAuth.addDevice.transport.local`),hint:e(`settings.remoteInstances.pairing.local`),available:!!Ut?.localUrl}].map(e=>{let t=jt===e.key;return(0,$.jsxs)(`div`,{className:K(`flex min-w-0 flex-col gap-2 rounded-xl border p-3 transition-colors`,t?`border-[var(--interactive-selection)] bg-[var(--interactive-selection)]`:`border-[var(--interactive-border)]`,e.available?`cursor-pointer hover:bg-interactive-hover`:`opacity-45`),onClick:()=>{e.available&&Mt(e.key)},role:`presentation`,children:[(0,$.jsx)(pa,{checked:t,disabled:!e.available,onChange:()=>Mt(e.key),ariaLabel:e.label,className:`shrink-0 !self-start`}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:K(`typography-ui-label font-normal`,t?`text-foreground`:`text-foreground/70`),children:e.label}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e.hint})]})]},e.key)})}),jt===`lan`?(0,$.jsx)(Ji,{checked:Nt,onChange:Pt,label:e(`settings.remoteInstances.clientAuth.addDevice.fallback.relay`),ariaLabel:e(`settings.remoteInstances.clientAuth.addDevice.fallback.relay`)}):null,jt===`relay`&&Ut?.lanUrl?(0,$.jsx)(Ji,{checked:Nt,onChange:Pt,label:e(`settings.remoteInstances.clientAuth.addDevice.fallback.preferLocal`),ariaLabel:e(`settings.remoteInstances.clientAuth.addDevice.fallback.preferLocal`)}):null,(0,$.jsxs)(ca,{open:Rt,onOpenChange:zt,className:`pt-3`,children:[(0,$.jsxs)(sa,{className:`px-0 hover:bg-transparent`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label`,children:e(`settings.remoteInstances.pairing.advanced`)}),(0,$.jsx)(X,{name:Rt?`arrow-up-s`:`arrow-down-s`,className:`size-4 text-muted-foreground`})]}),(0,$.jsx)(`p`,{className:`mt-1 font-normal text-muted-foreground`,style:{fontSize:`var(--form-helper-font-size)`,lineHeight:`var(--form-helper-line-height)`},children:e(`settings.remoteInstances.pairing.relayHint`)}),(0,$.jsx)(oa,{children:(()=>{let t=Array.from(new Set([...Ut?.relayUrls??[],...Ut?.relayUrl?[Ut.relayUrl]:[]])),n=t.length>1,r=Ut?.relayUrlLocked!==!0,i=n&&!Bt;return(0,$.jsxs)(`label`,{className:`block space-y-1.5 pt-2`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.remoteInstances.clientAuth.addDevice.relayUrlLabel`)}),i?(0,$.jsxs)(Fr,{value:t.includes(Y)?Y:t[0],onValueChange:e=>{if(e===`__custom__`){Vt(!0);return}Ft(e),Lt(null)},children:[(0,$.jsx)(Pr,{className:`h-8 w-full font-mono`,"aria-label":e(`settings.remoteInstances.clientAuth.addDevice.relayUrlLabel`),children:(0,$.jsx)(Ar,{})}),(0,$.jsxs)(Nr,{children:[t.map(e=>(0,$.jsx)(jr,{value:e,className:`font-mono`,children:(0,$.jsx)(`span`,{className:`block max-w-[420px] truncate`,children:e})},e)),r?(0,$.jsx)(jr,{value:`__custom__`,children:e(`settings.remoteInstances.clientAuth.addDevice.relayUrlCustomOption`)}):null]})]}):(0,$.jsx)(Cn,{ref:Ht,className:`h-8 font-mono`,value:Y,onChange:e=>{Ft(e.target.value),Lt(null)},placeholder:Fd,readOnly:Ut?.relayUrlLocked===!0,"aria-readonly":Ut?.relayUrlLocked===!0||void 0,"aria-invalid":!!It||void 0,"aria-describedby":It?`add-device-relay-url-hint add-device-relay-url-error`:`add-device-relay-url-hint`,spellCheck:!1,autoCapitalize:`none`,autoCorrect:`off`}),(0,$.jsx)(`span`,{id:`add-device-relay-url-hint`,className:`block typography-meta text-muted-foreground`,children:Ut?.relayUrlLocked?e(`settings.remoteInstances.clientAuth.addDevice.relayUrlLockedHint`):e(`settings.remoteInstances.clientAuth.addDevice.relayUrlHint`)}),(0,$.jsx)(`a`,{href:Bd,target:`_blank`,rel:`noopener noreferrer`,className:`block typography-meta text-muted-foreground underline underline-offset-2 hover:text-foreground`,onClick:e=>{e.preventDefault(),Br(Bd)},children:e(`settings.remoteInstances.clientAuth.addDevice.relayUrlDeployLink`)}),It?(0,$.jsx)(`span`,{id:`add-device-relay-url-error`,role:`alert`,"aria-live":`polite`,className:`block typography-meta text-[var(--status-error)]`,children:It}):null]})})()})]})]}),lt?(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:lt}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-3 pt-4`,children:[(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,className:`!font-normal`,onClick:()=>Et(!1),disabled:kt,children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(q,{type:`submit`,variant:`default`,size:`sm`,className:`!font-normal`,disabled:kt||!Ut,children:e(`settings.remoteInstances.clientAuth.addDevice.create`)})]})]}):(0,$.jsxs)(`div`,{className:`space-y-3`,children:[xt?(0,$.jsx)(`div`,{className:`flex justify-center`,children:(0,$.jsx)(`img`,{src:xt,alt:e(`settings.remoteInstances.clientAuth.qrAlt`),className:`w-full max-w-[420px] rounded-md bg-white p-4`})}):null,(0,$.jsxs)(`a`,{href:`https://github.com/yee94/yuri/releases`,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>{e.preventDefault(),Br(`https://github.com/yee94/yuri/releases`)},className:`flex items-center justify-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground`,children:[(0,$.jsx)(X,{name:`download`,className:`size-3.5`}),e(`settings.remoteInstances.quick.download`),(0,$.jsx)(X,{name:`external-link`,className:`size-3`})]}),_t?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-[var(--interactive-border)] p-2`,children:[(0,$.jsx)(`code`,{className:`min-w-0 flex-1 truncate typography-code text-muted-foreground`,children:_t}),(0,$.jsxs)(q,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal shrink-0`,onClick:Dn,children:[(0,$.jsx)(X,{name:Ct?`check`:`file-copy`,className:K(`h-3.5 w-3.5`,Ct&&`text-[var(--status-success)]`)}),e(Ct?`settings.remoteInstances.clientAuth.actions.copied`:`settings.common.actions.copyAll`)]})]}):null,(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(q,{type:`button`,size:`xs`,className:`!font-normal`,onClick:()=>Et(!1),children:e(`settings.remoteInstances.clientAuth.addDevice.done`)})})]})]})}),i?(0,$.jsx)(gn,{open:Kt,onOpenChange:qt,children:(0,$.jsxs)(pn,{className:`yuri-settings-workspace yuri-settings-workspace-desktop sm:max-w-2xl`,children:[(0,$.jsx)(dn,{children:(0,$.jsx)(mn,{children:e(`settings.remoteInstances.sidebar.actions.addSshInstance`)})}),(0,$.jsxs)(`form`,{className:`yuri-settings-section-stack`,onSubmit:e=>{e.preventDefault(),on()},children:[(0,$.jsxs)(Z,{children:[(0,$.jsx)(Xi,{label:e(`settings.remoteInstances.page.field.sshCommand`),className:`yuri-settings-ssh-command-row`,children:(0,$.jsx)(Cn,{value:Jt,onChange:e=>Yt(e.target.value),"aria-label":e(`settings.remoteInstances.page.field.sshCommand`),placeholder:e(`settings.remoteInstances.page.field.sshCommandPlaceholder`),disabled:d,autoFocus:!0})}),(0,$.jsx)(Xi,{label:e(`settings.remoteInstances.page.field.nickname`),children:(0,$.jsx)(Cn,{value:Xt,onChange:e=>Zt(e.target.value),"aria-label":e(`settings.remoteInstances.page.field.nickname`),placeholder:e(`settings.remoteInstances.page.field.nicknamePlaceholder`),disabled:d})})]}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(q,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>qt(!1),disabled:d,children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(q,{type:`submit`,size:`xs`,className:`!font-normal`,disabled:d||!Jt.trim(),children:e(`settings.common.actions.create`)})]})]})]})}):null,(0,$.jsx)(Od,{}),(0,$.jsx)(Pd,{}),(0,$.jsx)(gn,{open:!!me,onOpenChange:e=>{e||Jn()},children:(0,$.jsxs)(pn,{className:`sm:max-w-md`,children:[(0,$.jsxs)(dn,{children:[(0,$.jsx)(mn,{children:e(`settings.remoteInstances.page.patternDialog.title`)}),(0,$.jsx)(hn,{children:me?e(`settings.remoteInstances.page.patternDialog.descriptionWithHost`,{host:me}):e(`settings.remoteInstances.page.patternDialog.description`)})]}),(0,$.jsxs)(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),Yn()},children:[(0,$.jsx)(Cn,{value:ge,onChange:e=>_e(e.target.value),placeholder:e(`settings.remoteInstances.page.patternDialog.destinationPlaceholder`),autoFocus:!0}),(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,$.jsx)(q,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:Jn,disabled:ve,children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(q,{type:`submit`,size:`xs`,className:`!font-normal`,disabled:ve,children:e(`settings.remoteInstances.page.actions.create`)})]})]})]})})]}),(0,$.jsx)(qd,{open:oe,instanceId:ce,targetKind:ue,relayHost:fe,onOpenChange:e=>{se(e),e||(le(null),de(`ssh`),pe(null))}})]});let pr=O.nickname?.trim()||O.sshParsed?.destination||O.id;return(0,$.jsx)(gn,{open:!!O,onOpenChange:e=>{!e&&!xe&&w(null)},children:(0,$.jsxs)(pn,{className:`yuri-settings-workspace yuri-settings-workspace-desktop yuri-settings-section-stack sm:max-w-2xl`,children:[(0,$.jsx)(Gi,{actions:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>void Kn(),disabled:d||xe,"aria-busy":xe,"aria-label":e(`settings.common.actions.delete`),children:(0,$.jsx)(X,{name:xe?`refresh`:`delete-bin`,className:K(`size-4`,xe&&`animate-spin`)})}),(0,$.jsxs)(q,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>void tr(),disabled:xe,children:[(0,$.jsx)(X,{name:`terminal-window`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.page.actions.logs`)]}),Mn?.localUrl?(0,$.jsxs)(q,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>void ar(),disabled:xe,children:[(0,$.jsx)(X,{name:`external-link`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.page.actions.open`)]}):null,Bn?(0,$.jsxs)(q,{type:`button`,size:`xs`,className:`!font-normal`,onClick:lr,disabled:!dr||xe,children:[(0,$.jsx)(X,{name:`refresh`,className:`h-3.5 w-3.5`}),ur]}):null,(0,$.jsxs)(q,{type:`button`,size:`xs`,className:`!font-normal`,onClick:sr,disabled:we||Ee||xe,children:[(0,$.jsx)(X,{name:Rn?`stop`:`plug-2`,className:`h-3.5 w-3.5`}),fr]}),(0,$.jsx)(q,{type:`button`,size:`xs`,className:`!font-normal`,onClick:()=>void Gn(),disabled:!Hn||d||xe,"aria-busy":d,children:e(`settings.common.actions.saveChanges`)})]}),children:(0,$.jsxs)(dn,{className:`gap-1`,children:[(0,$.jsx)(mn,{className:`truncate`,children:pr}),(0,$.jsxs)(hn,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-full ${tf(Nn)}`}),(0,$.jsx)(`span`,{children:e(Qd(Nn))}),Bn?(0,$.jsx)(`span`,{children:e(`settings.remoteInstances.page.status.reconnectStale`)}):null]})]})}),Nn===`error`?(0,$.jsx)(kn,{errorCode:Mn?.errorCode,detail:Mn?.detail}):null,(0,$.jsxs)(Z,{label:e(`settings.remoteInstances.page.section.instance`),children:[(0,$.jsx)(Xi,{label:e(`settings.remoteInstances.page.field.sshCommand`),className:`yuri-settings-ssh-command-row`,children:(0,$.jsx)(Cn,{value:O.sshCommand,"aria-label":e(`settings.remoteInstances.page.field.sshCommand`),disabled:xe,onChange:e=>Wn(t=>({...t,sshCommand:e.target.value})),placeholder:e(`settings.remoteInstances.page.field.sshCommandPlaceholder`)})}),(0,$.jsx)(Xi,{label:e(`settings.remoteInstances.page.field.nickname`),children:(0,$.jsx)(Cn,{value:O.nickname||``,"aria-label":e(`settings.remoteInstances.page.field.nickname`),disabled:xe,onChange:e=>Wn(t=>({...t,nickname:e.target.value})),placeholder:e(`settings.remoteInstances.page.field.nicknamePlaceholder`)})}),O.remoteYuri.mode===`external`?(0,$.jsx)(Xi,{label:e(`settings.remoteInstances.page.field.preferredRemotePort`),children:(0,$.jsx)(ma,{min:1,max:65535,step:1,className:`tabular-nums`,"aria-label":e(`settings.remoteInstances.page.field.preferredRemotePort`),disabled:xe,value:O.remoteYuri.preferredPort,onValueChange:e=>{Wn(t=>({...t,remoteYuri:{...t.remoteYuri,preferredPort:Number.isFinite(e)&&e>0?e:void 0}}))},onClear:()=>{Wn(e=>({...e,remoteYuri:{...e.remoteYuri,preferredPort:void 0}}))},emptyLabel:e(`settings.remoteInstances.page.field.auto`)})}):null,(0,$.jsx)(Xi,{label:e(`settings.remoteInstances.page.field.sshPasswordOptional`),children:(0,$.jsx)(Cn,{type:`password`,value:O.auth.sshPassword?.value||``,"aria-label":e(`settings.remoteInstances.page.field.sshPasswordOptional`),disabled:xe,onChange:e=>Wn(t=>({...t,auth:{...t.auth,sshPassword:{enabled:e.target.value.trim().length>0,value:e.target.value,store:t.auth.sshPassword?.store||`never`}}})),placeholder:e(`settings.remoteInstances.page.field.sshPasswordPlaceholder`)})}),O.remoteYuri.mode===`external`||T?.auth.yuriPassword?.enabled?(0,$.jsx)(Xi,{label:e(`settings.remoteInstances.page.field.uiPasswordOptional`),children:(0,$.jsx)(Cn,{type:`password`,value:O.auth.yuriPassword?.value||``,"aria-label":e(`settings.remoteInstances.page.field.uiPasswordOptional`),disabled:xe,onChange:e=>Wn(t=>({...t,auth:{...t.auth,yuriPassword:{enabled:e.target.value.trim().length>0,value:e.target.value,store:t.auth.yuriPassword?.store||`never`}}})),placeholder:e(`settings.remoteInstances.page.field.uiPasswordPlaceholder`)})}):null]}),f?(0,$.jsx)(`div`,{role:`alert`,className:`typography-meta text-[var(--status-error)]`,children:f}):null,(0,$.jsx)(qd,{open:oe,instanceId:ce,targetKind:ue,relayHost:fe,onOpenChange:e=>{se(e),e||(le(null),de(`ssh`),pe(null))}}),(0,$.jsx)(gn,{open:A,onOpenChange:W,children:(0,$.jsxs)(pn,{className:`sm:max-w-2xl`,children:[(0,$.jsxs)(dn,{children:[(0,$.jsx)(mn,{children:e(`settings.remoteInstances.page.logsDialog.title`)}),(0,$.jsx)(hn,{children:O?.nickname?.trim()||O?.sshParsed?.destination||O?.id||e(`settings.remoteInstances.page.logsDialog.selectedInstanceFallback`)})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,$.jsxs)(q,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:rr,disabled:ee||!nr.trim(),children:[(0,$.jsx)(X,{name:`file-copy`,className:`h-3.5 w-3.5`}),e(`settings.common.actions.copyAll`)]}),(0,$.jsxs)(q,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>void ir(),disabled:ee,children:[(0,$.jsx)(X,{name:`delete-bin`,className:`h-3.5 w-3.5`}),e(`settings.common.actions.clear`)]})]}),ee?(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:e(`settings.remoteInstances.page.logsDialog.loading`)}):ne?(0,$.jsx)(`div`,{className:`typography-meta text-[var(--status-error)]`,children:ne}):(0,$.jsx)(`pre`,{className:`max-h-[55vh] overflow-auto rounded-md border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-3 typography-micro text-foreground whitespace-pre-wrap break-words`,children:ie.length>0?ie.join(`
28
+ `):e(`settings.remoteInstances.page.logsDialog.empty`)})]})}),(0,$.jsx)(gn,{open:!!me,onOpenChange:e=>{e||Jn()},children:(0,$.jsxs)(pn,{className:`sm:max-w-md`,children:[(0,$.jsxs)(dn,{children:[(0,$.jsx)(mn,{children:e(`settings.remoteInstances.page.patternDialog.title`)}),(0,$.jsx)(hn,{children:me?e(`settings.remoteInstances.page.patternDialog.descriptionWithHost`,{host:me}):e(`settings.remoteInstances.page.patternDialog.description`)})]}),(0,$.jsxs)(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),Yn()},children:[(0,$.jsx)(Cn,{value:ge,onChange:e=>_e(e.target.value),placeholder:e(`settings.remoteInstances.page.patternDialog.destinationPlaceholder`),autoFocus:!0}),(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,$.jsx)(q,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:Jn,disabled:ve,children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(q,{type:`submit`,size:`xs`,className:`!font-normal`,disabled:ve,children:e(`settings.common.actions.create`)})]})]})]})})]})})},ff=`__add_provider__`,pf=`__custom_provider__`,mf=e=>{let t=(0,Sa.c)(85),{onItemSelect:n}=e,{t:i}=Ge(),a=pt(gf),s=pt(_f),c=pt(vf),l=ce(yf);Q.useSyncExternalStore(r,o,o);let u=l??void 0,d;t[0]===u?d=t[1]:(d=ua(u),t[0]=u,t[1]=d);let f=De(d),p=f.data,[m,h]=Q.useState(``),g;t[2]!==p||t[3]!==i?(g=e=>{let t=p?.[e]?.auth.type;return i(t===`api`?`settings.providers.page.auth.apiKeyLabel`:t===`oauth`||t===`external`?`settings.providers.auth.account`:`settings.providers.auth.managed`)},t[2]=p,t[3]=i,t[4]=g):g=t[4];let _=g,v;if(t[5]!==a||t[6]!==m||t[7]!==p){let e;t[9]!==m||t[10]!==p?(e=e=>!!p?.[e.id]?.project?.exists&&`${e.name} ${e.id}`.toLowerCase().includes(m.trim().toLowerCase()),t[9]=m,t[10]=p,t[11]=e):e=t[11],v=a.filter(e),t[5]=a,t[6]=m,t[7]=p,t[8]=v}else v=t[8];let y=v,b;if(t[12]!==a||t[13]!==m||t[14]!==p){let e;t[16]!==m||t[17]!==p?(e=e=>!p?.[e.id]?.project?.exists&&`${e.name} ${e.id}`.toLowerCase().includes(m.trim().toLowerCase()),t[16]=m,t[17]=p,t[18]=e):e=t[18],b=a.filter(e),t[12]=a,t[13]=m,t[14]=p,t[15]=b}else b=t[15];let x=b,S;t[19]===i?S=t[20]:(S=i(`settings.providers.sidebar.title`),t[19]=i,t[20]=S);let C;t[21]===S?C=t[22]:(C=(0,$.jsx)(`span`,{children:S}),t[21]=S,t[22]=C);let w;t[23]!==n||t[24]!==c?(w=()=>{c(ff),n?.()},t[23]=n,t[24]=c,t[25]=w):w=t[25];let T;t[26]===i?T=t[27]:(T=i(`settings.providers.sidebar.actions.connectProviderAria`),t[26]=i,t[27]=T);let E;t[28]===i?E=t[29]:(E=i(`settings.providers.sidebar.actions.connectProviderTitle`),t[28]=i,t[29]=E);let D;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,$.jsx)(X,{name:`add`,className:`h-4 w-4`}),t[30]=D):D=t[30];let O;t[31]!==E||t[32]!==w||t[33]!==T?(O=(0,$.jsx)(q,{size:`icon`,variant:`ghost`,onClick:w,"aria-label":T,title:E,children:D}),t[31]=E,t[32]=w,t[33]=T,t[34]=O):O=t[34];let k;t[35]!==O||t[36]!==C?(k=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[C,O]}),t[35]=O,t[36]=C,t[37]=k):k=t[37];let A=k,j;t[38]===i?j=t[39]:(j=i(`settings.providers.custom.title`),t[38]=i,t[39]=j);let M;t[40]===j?M=t[41]:(M={id:pf,name:j},t[40]=j,t[41]=M);let N;t[42]!==n||t[43]!==c?(N=()=>{c(pf),n?.()},t[42]=n,t[43]=c,t[44]=N):N=t[44];let P;t[45]!==s||t[46]!==M||t[47]!==N?(P=(0,$.jsx)(hf,{provider:M,selectedProviderId:s,onSelect:N}),t[45]=s,t[46]=M,t[47]=N,t[48]=P):P=t[48];let F=P,I;t[49]!==f.isError||t[50]!==i?(I=f.isError&&(0,$.jsx)(`p`,{role:`alert`,className:`typography-meta text-muted-foreground`,children:i(`settings.providers.page.toast.providerSourcesLoadFailed`)}),t[49]=f.isError,t[50]=i,t[51]=I):I=t[51];let L;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(X,{name:`search`,className:`pointer-events-none absolute left-2 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`}),t[52]=L):L=t[52];let R;t[53]===i?R=t[54]:(R=i(`settings.providers.page.connect.searchProvidersPlaceholder`),t[53]=i,t[54]=R);let z;t[55]===i?z=t[56]:(z=i(`settings.providers.page.connect.searchProvidersPlaceholder`),t[55]=i,t[56]=z);let B;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(B=e=>h(e.target.value),t[57]=B):B=t[57];let V;t[58]!==m||t[59]!==R||t[60]!==z?(V=(0,$.jsxs)(`div`,{className:`relative`,children:[L,(0,$.jsx)(Cn,{className:`!h-8 !min-h-0 !pl-7 !text-left !text-[13px]`,"aria-label":R,placeholder:z,value:m,onChange:B})]}),t[58]=m,t[59]=R,t[60]=z,t[61]=V):V=t[61];let H;t[62]===F?H=t[63]:(H=(0,$.jsx)(Z,{cardClassName:`yuri-provider-collection-card`,children:F}),t[62]=F,t[63]=H);let U;t[64]!==_||t[65]!==n||t[66]!==y||t[67]!==a.length||t[68]!==s||t[69]!==c||t[70]!==i||t[71]!==x?(U=(0,$.jsx)($.Fragment,{children:a.length===0?(0,$.jsx)(Z,{children:(0,$.jsxs)(`div`,{className:`yuri-settings-group-row py-12 text-center text-muted-foreground`,children:[(0,$.jsx)(X,{name:`stack`,className:`mx-auto mb-3 h-10 w-10 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-ui-label font-medium`,children:i(`settings.providers.sidebar.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:i(`settings.providers.sidebar.empty.description`)})]})}):(0,$.jsxs)($.Fragment,{children:[x.length>0?(0,$.jsx)(Z,{label:i(`settings.providers.sidebar.section.userProviders`),cardClassName:`yuri-provider-collection-card`,children:x.map(e=>(0,$.jsx)(hf,{provider:e,description:_(e.id),selectedProviderId:s,onSelect:()=>{c(e.id),n?.()}},e.id))}):null,y.length>0&&(0,$.jsx)(Z,{label:i(`settings.providers.sidebar.section.projectProviders`),cardClassName:`yuri-provider-collection-card`,children:y.map(e=>(0,$.jsx)(hf,{provider:e,description:_(e.id),selectedProviderId:s,onSelect:()=>{c(e.id),n?.()}},e.id))})]})}),t[64]=_,t[65]=n,t[66]=y,t[67]=a.length,t[68]=s,t[69]=c,t[70]=i,t[71]=x,t[72]=U):U=t[72];let W;t[73]!==y||t[74]!==m||t[75]!==i||t[76]!==x?(W=m&&!x.length&&!y.length&&(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:i(`settings.providers.page.connect.noProvidersFound`)}),t[73]=y,t[74]=m,t[75]=i,t[76]=x,t[77]=W):W=t[77];let ee;return t[78]!==I||t[79]!==V||t[80]!==H||t[81]!==U||t[82]!==W||t[83]!==A?(ee=(0,$.jsxs)(`div`,{className:`yuri-settings-page-content h-full overflow-y-auto bg-background p-3`,children:[A,I,V,H,U,W]}),t[78]=I,t[79]=V,t[80]=H,t[81]=U,t[82]=W,t[83]=A,t[84]=ee):ee=t[84],ee},hf=e=>{let t=(0,Sa.c)(27),{provider:n,selectedProviderId:r,onSelect:i,description:a}=e,o=Array.isArray(n.models)?n.models.length:0,s=n.id===r,c=n.id,l=s?`bg-interactive-selection`:`hover:bg-interactive-hover`,u;t[0]===l?u=t[1]:(u=K(`yuri-provider-collection-row group relative flex items-center transition-colors duration-150`,l),t[0]=l,t[1]=u);let d=s?`page`:void 0,f;t[2]===n.id?f=t[3]:(f=n.id===pf?(0,$.jsx)(`span`,{className:`flex size-6 shrink-0 items-center justify-center rounded-lg border border-dashed border-[var(--interactive-border)]`,children:(0,$.jsx)(X,{name:`add`,className:`size-4`})}):(0,$.jsx)(Mr,{providerId:n.id,className:`size-5 shrink-0`}),t[2]=n.id,t[3]=f);let p=n.name||n.id,m;t[4]===p?m=t[5]:(m=(0,$.jsx)(`span`,{className:`block truncate text-[13px] leading-[18px] font-normal`,children:p}),t[4]=p,t[5]=m);let h;t[6]===a?h=t[7]:(h=a&&(0,$.jsx)(`span`,{className:`block truncate text-[11px] leading-4 text-muted-foreground`,children:a}),t[6]=a,t[7]=h);let g;t[8]!==m||t[9]!==h?(g=(0,$.jsxs)(`span`,{className:`flex-1 min-w-0 text-foreground`,children:[m,h]}),t[8]=m,t[9]=h,t[10]=g):g=t[10];let _;t[11]===n.id?_=t[12]:(_=n.id===pf&&(0,$.jsx)(X,{name:`arrow-right-s`,className:`size-4 text-muted-foreground`}),t[11]=n.id,t[12]=_);let v;t[13]!==o||t[14]!==n.id?(v=n.id!==pf&&(0,$.jsx)(`span`,{className:`text-[11px] leading-4 tabular-nums text-muted-foreground/60 flex-shrink-0`,children:o}),t[13]=o,t[14]=n.id,t[15]=v):v=t[15];let y;t[16]!==i||t[17]!==_||t[18]!==v||t[19]!==d||t[20]!==f||t[21]!==g?(y=(0,$.jsxs)(`button`,{type:`button`,onClick:i,className:`flex min-w-0 flex-1 items-center gap-2 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-foreground/20`,"aria-current":d,tabIndex:0,children:[f,g,_,v]}),t[16]=i,t[17]=_,t[18]=v,t[19]=d,t[20]=f,t[21]=g,t[22]=y):y=t[22];let b;return t[23]!==n.id||t[24]!==y||t[25]!==u?(b=(0,$.jsx)(`div`,{className:u,children:y},c),t[23]=n.id,t[24]=y,t[25]=u,t[26]=b):b=t[26],b};function gf(e){return e.providers}function _f(e){return e.selectedProviderId}function vf(e){return e.setSelectedProvider}function yf(e){return e.currentDirectory}function bf(){let{t:e}=Ge(),t=wi(e=>e.magpieUsageUrl),n=wi(e=>e.magpieSources),r=wi(e=>e.magpieError),a=wi(e=>e.fetchMagpieQuotas),[o,s]=Q.useState(null),[c,l]=Q.useState(!1),[u,d]=Q.useState(!1),f=Q.useId(),p=n.reduce((e,t)=>e+t.results.length,0),m=i();Q.useEffect(()=>{s(null),d(!1)},[m]);let h=He(async()=>{let e=i(),n=(o??t).trim();l(!0),d(!1);try{if(n){let e=new URL(n);if(![`http:`,`https:`].includes(e.protocol)||e.username||e.password||e.search||e.hash)throw Error(`Invalid URL`)}if(await ye({magpieUsageUrl:n}),e!==i())return;wi.setState({magpieUsageUrl:n}),s(null),await a()}catch{e===i()&&d(!0)}finally{l(!1)}});return(0,$.jsx)(Z,{label:`Magpie`,itemId:`usage.magpie`,actions:(0,$.jsx)(q,{size:`sm`,onClick:h,disabled:c||o===null||o===t,"aria-busy":c,children:e(`settings.usage.magpie.save`)}),children:(0,$.jsxs)(`div`,{className:`yuri-settings-group-row min-w-0`,children:[(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground break-words`,children:p>0?e(`settings.usage.magpie.connected`,{count:p}):e(`settings.usage.magpie.description`)}),(r||n.some(e=>e.identified&&e.error))&&(0,$.jsx)(`p`,{role:`status`,className:`typography-meta text-muted-foreground`,children:e(`settings.usage.magpie.unavailable`)}),(0,$.jsxs)(`details`,{className:`mt-2 min-w-0`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer typography-meta text-muted-foreground hover:text-foreground`,children:e(`settings.usage.magpie.manual`)}),(0,$.jsxs)(`div`,{className:`mt-3 flex min-w-0 flex-col gap-2`,children:[(0,$.jsx)(`label`,{htmlFor:f,className:`typography-meta text-muted-foreground`,children:e(`settings.usage.magpie.url`)}),(0,$.jsx)(Cn,{id:f,className:`w-full min-w-0`,value:o??t,disabled:c,onChange:e=>s(e.target.value),"aria-label":e(`settings.usage.magpie.url`)}),u&&(0,$.jsx)(`p`,{role:`alert`,className:`typography-meta text-[var(--status-error)]`,children:e(`settings.usage.page.state.refreshFailedTitle`)})]})]})]})})}var xf=e=>{let t=e?.windows??{},n=Object.values(t).map(e=>e.usedPercent).filter(e=>typeof e==`number`);return n.length===0?null:Math.max(...n)},Sf=e=>{let t=(0,Sa.c)(122),{onItemSelect:n,children:r}=e,{t:i}=Ge(),a=wi(Cf),o=wi(wf),s=wi(Tf),c=wi(Ef),l=wi(Df),u=wi(Of),d=wi(kf),f=wi(Af),p=wi(jf),m=wi(Mf),h=wi(Nf),g=wi(Pf),_=wi(Ff),v=wi(If),y,b;t[0]===v?(y=t[1],b=t[2]):(y=()=>{v()},b=[v],t[0]=v,t[1]=y,t[2]=b),Q.useEffect(y,b);let x=Lf,S;t[3]===p?S=t[4]:(S=e=>{p(e),x({usageAutoRefresh:e})},t[3]=p,t[4]=S);let C=S,w;t[5]===m?w=t[6]:(w=e=>{let t=Number(e);Number.isFinite(t)&&(m(t),x({usageRefreshIntervalMs:t}))},t[5]=m,t[6]=w);let T=w,E;t[7]===h?E=t[8]:(E=e=>{(e===`usage`||e===`remaining`)&&(h(e),x({usageDisplayMode:e}))},t[7]=h,t[8]=E);let D=E,O;t[9]===_?O=t[10]:(O=e=>{_(e),x({usageShowPredValues:e})},t[9]=_,t[10]=O);let k=O,A=r?`yuri-settings-usage-workspace`:`yuri-settings-usage-sidebar`,j;t[11]===A?j=t[12]:(j=K(`yuri-settings-page-content h-full min-w-0 overflow-y-auto bg-background p-3`,A),t[11]=A,t[12]=j);let M;t[13]===i?M=t[14]:(M=i(`settings.usage.sidebar.title`),t[13]=i,t[14]=M);let N;t[15]===c?N=t[16]:(N=()=>c(),t[15]=c,t[16]=N);let P;t[17]===i?P=t[18]:(P=i(`settings.usage.sidebar.actions.refreshAria`),t[17]=i,t[18]=P);let F;t[19]===i?F=t[20]:(F=i(`settings.usage.sidebar.actions.refreshTitle`),t[19]=i,t[20]=F);let I=l&&`animate-spin`,L;t[21]===I?L=t[22]:(L=K(`h-3.5 w-3.5`,I),t[21]=I,t[22]=L);let R;t[23]===L?R=t[24]:(R=(0,$.jsx)(X,{name:`refresh`,className:L}),t[23]=L,t[24]=R);let z;t[25]!==l||t[26]!==N||t[27]!==P||t[28]!==F||t[29]!==R?(z=(0,$.jsx)(q,{size:`icon`,variant:`ghost`,className:`text-muted-foreground`,onClick:N,"aria-label":P,title:F,disabled:l,children:R}),t[25]=l,t[26]=N,t[27]=P,t[28]=F,t[29]=R,t[30]=z):z=t[30];let B;t[31]!==z||t[32]!==M?(B=(0,$.jsx)(Xi,{label:M,children:z}),t[31]=z,t[32]=M,t[33]=B):B=t[33];let V;t[34]===i?V=t[35]:(V=i(`settings.usage.sidebar.field.autoRefresh`),t[34]=i,t[35]=V);let H;t[36]===i?H=t[37]:(H=i(`settings.usage.sidebar.actions.toggleAutoRefreshAria`),t[36]=i,t[37]=H);let U;t[38]!==C||t[39]!==H||t[40]!==u?(U=(0,$.jsx)(Wi,{checked:u,onChange:C,ariaLabel:H}),t[38]=C,t[39]=H,t[40]=u,t[41]=U):U=t[41];let W;t[42]!==V||t[43]!==U?(W=(0,$.jsx)(Xi,{label:V,children:U}),t[42]=V,t[43]=U,t[44]=W):W=t[44];let ee;t[45]===i?ee=t[46]:(ee=i(`settings.usage.sidebar.field.refreshInterval`),t[45]=i,t[46]=ee);let te=String(d),ne=!u,re;t[47]===i?re=t[48]:(re=i(`settings.usage.sidebar.field.intervalPlaceholder`),t[47]=i,t[48]=re);let ie;t[49]===re?ie=t[50]:(ie=(0,$.jsx)(Pr,{className:`w-fit`,children:(0,$.jsx)(Ar,{placeholder:re,children:Rf})}),t[49]=re,t[50]=ie);let ae;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,$.jsxs)(Nr,{children:[(0,$.jsx)(jr,{value:`30000`,children:`30s`}),(0,$.jsx)(jr,{value:`60000`,children:`1m`}),(0,$.jsx)(jr,{value:`300000`,children:`5m`})]}),t[51]=ae):ae=t[51];let oe;t[52]!==T||t[53]!==te||t[54]!==ne||t[55]!==ie?(oe=(0,$.jsxs)(Fr,{value:te,onValueChange:T,disabled:ne,children:[ie,ae]}),t[52]=T,t[53]=te,t[54]=ne,t[55]=ie,t[56]=oe):oe=t[56];let se;t[57]!==ee||t[58]!==oe?(se=(0,$.jsx)(Xi,{label:ee,children:oe}),t[57]=ee,t[58]=oe,t[59]=se):se=t[59];let ce;t[60]===i?ce=t[61]:(ce=i(`settings.usage.sidebar.field.display`),t[60]=i,t[61]=ce);let le;t[62]===i?le=t[63]:(le=i(`settings.usage.sidebar.field.displayModePlaceholder`),t[62]=i,t[63]=le);let ue;t[64]===i?ue=t[65]:(ue=e=>e===`usage`?i(`settings.usage.sidebar.field.displayModeUsage`):e===`remaining`?i(`settings.usage.sidebar.field.displayModeRemaining`):e,t[64]=i,t[65]=ue);let de;t[66]!==le||t[67]!==ue?(de=(0,$.jsx)(Pr,{className:`w-fit`,children:(0,$.jsx)(Ar,{placeholder:le,children:ue})}),t[66]=le,t[67]=ue,t[68]=de):de=t[68];let G;t[69]===i?G=t[70]:(G=i(`settings.usage.sidebar.field.displayModeUsage`),t[69]=i,t[70]=G);let fe;t[71]===G?fe=t[72]:(fe=(0,$.jsx)(jr,{value:`usage`,children:G}),t[71]=G,t[72]=fe);let pe;t[73]===i?pe=t[74]:(pe=i(`settings.usage.sidebar.field.displayModeRemaining`),t[73]=i,t[74]=pe);let me;t[75]===pe?me=t[76]:(me=(0,$.jsx)(jr,{value:`remaining`,children:pe}),t[75]=pe,t[76]=me);let he;t[77]!==fe||t[78]!==me?(he=(0,$.jsxs)(Nr,{children:[fe,me]}),t[77]=fe,t[78]=me,t[79]=he):he=t[79];let ge;t[80]!==D||t[81]!==de||t[82]!==he||t[83]!==f?(ge=(0,$.jsxs)(Fr,{value:f,onValueChange:D,children:[de,he]}),t[80]=D,t[81]=de,t[82]=he,t[83]=f,t[84]=ge):ge=t[84];let _e;t[85]!==ce||t[86]!==ge?(_e=(0,$.jsx)(Xi,{label:ce,children:ge}),t[85]=ce,t[86]=ge,t[87]=_e):_e=t[87];let ve;t[88]===i?ve=t[89]:(ve=i(`settings.usage.sidebar.field.showPredictions`),t[88]=i,t[89]=ve);let ye;t[90]===i?ye=t[91]:(ye=i(`settings.usage.sidebar.field.showPredictions`),t[90]=i,t[91]=ye);let be;t[92]!==k||t[93]!==g||t[94]!==ve||t[95]!==ye?(be=(0,$.jsx)(Ji,{checked:g,onChange:k,label:ve,ariaLabel:ye}),t[92]=k,t[93]=g,t[94]=ve,t[95]=ye,t[96]=be):be=t[96];let xe;t[97]!==B||t[98]!==W||t[99]!==se||t[100]!==_e||t[101]!==be?(xe=(0,$.jsxs)(Z,{children:[B,W,se,_e,be]}),t[97]=B,t[98]=W,t[99]=se,t[100]=_e,t[101]=be,t[102]=xe):xe=t[102];let Se;t[103]===Symbol.for(`react.memo_cache_sentinel`)?(Se=(0,$.jsx)(bf,{}),t[103]=Se):Se=t[103];let Ce=r?`yuri-settings-usage-results`:void 0,we;t[104]!==n||t[105]!==a||t[106]!==o||t[107]!==s||t[108]!==i?(we=pi(a).map(e=>{let t=a.find(t=>t?.providerId===e.id),r=xf(t?.usage),c=Bn(r),l=e.id===o,u=t?.configured??!1,d=u?c===`critical`?{backgroundColor:`var(--status-error)`}:c===`warn`?{backgroundColor:`var(--status-warning)`}:{backgroundColor:`var(--status-success)`}:{backgroundColor:`var(--surface-muted-foreground)`,opacity:.4};return(0,$.jsx)(`div`,{className:K(`yuri-settings-group-row group relative flex items-center transition-colors duration-150`,l?`bg-interactive-selection`:`hover:bg-interactive-hover`),children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{s(e.id),n?.()},className:`flex min-w-0 flex-1 items-center gap-2 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,children:[(0,$.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-full flex-shrink-0`,style:d}),(0,$.jsx)(Mr,{providerId:e.id,className:`h-4 w-4 flex-shrink-0`}),(0,$.jsx)(`span`,{className:`typography-ui-label font-normal truncate flex-1 min-w-0 text-foreground`,children:e.name}),!u&&(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/60 flex-shrink-0`,children:i(`settings.usage.sidebar.status.notSet`)})]})},e.id)}),t[104]=n,t[105]=a,t[106]=o,t[107]=s,t[108]=i,t[109]=we):we=t[109];let Te;t[110]===we?Te=t[111]:(Te=(0,$.jsx)(Z,{children:we}),t[110]=we,t[111]=Te);let Ee;t[112]===r?Ee=t[113]:(Ee=r&&(0,$.jsx)(`div`,{className:`yuri-settings-usage-detail min-w-0`,children:r}),t[112]=r,t[113]=Ee);let De;t[114]!==Ce||t[115]!==Te||t[116]!==Ee?(De=(0,$.jsxs)(`div`,{className:Ce,children:[Te,Ee]}),t[114]=Ce,t[115]=Te,t[116]=Ee,t[117]=De):De=t[117];let Oe;return t[118]!==xe||t[119]!==De||t[120]!==j?(Oe=(0,$.jsxs)(`div`,{className:j,children:[xe,Se,De]}),t[118]=xe,t[119]=De,t[120]=j,t[121]=Oe):Oe=t[121],Oe};function Cf(e){return e.results}function wf(e){return e.selectedProviderId}function Tf(e){return e.setSelectedProvider}function Ef(e){return e.fetchAllQuotas}function Df(e){return e.isLoading}function Of(e){return e.autoRefresh}function kf(e){return e.refreshIntervalMs}function Af(e){return e.displayMode}function jf(e){return e.setAutoRefresh}function Mf(e){return e.setRefreshInterval}function Nf(e){return e.setDisplayMode}function Pf(e){return e.showPredValues}function Ff(e){return e.setShowPredValues}function If(e){return e.loadSettings}async function Lf(e){try{await ye(e)}catch(e){console.warn(`Failed to save usage settings:`,e)}}function Rf(e){return e===`30000`?`30s`:e===`60000`?`1m`:e===`300000`?`5m`:e}var zf=e=>{let t=(0,Sa.c)(53),{title:n,window:r,subtitle:i,showToggle:a,toggleEnabled:o,onToggle:s}=e,c=a!==void 0&&a,l=o!==void 0&&o,{locale:u,t:d}=Ge(),[f,p]=Q.useState(Date.now),m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>p(Date.now()),t[0]=m):m=t[0],Ue(m,r.disablePace&&r.resetAt?3e4:null);let h=r.resetAt?Math.max(0,Math.ceil((r.resetAt-f)/6e4)):null,g;t[1]!==u||t[2]!==h?(g=h===null?``:[{unit:`day`,value:Math.floor(h/1440)},{unit:`hour`,value:Math.floor(h%1440/60)},{unit:`minute`,value:h%60}].filter(e=>{let{unit:t,value:n}=e;return n>0||t===`minute`&&h===0}).map(e=>{let{unit:t,value:n}=e;return new Intl.NumberFormat(u,{style:`unit`,unit:t,unitDisplay:`long`}).format(n)}).join(` `),t[1]=u,t[2]=h,t[3]=g):g=t[3];let _=g,v=wi(Bf),y=wi(Vf),b=G(Hf),x=v===`remaining`?r.remainingPercent:r.usedPercent,S=v===`remaining`?`remaining`:`used`,C;t[4]!==x||t[5]!==r.disablePace||t[6]!==r.valueLabel?(C=r.disablePace&&r.valueLabel&&x!==null?`${Wn(null,x)} · ${r.valueLabel}`:Wn(r.valueLabel,x),t[4]=x,t[5]=r.disablePace,t[6]=r.valueLabel,t[7]=C):C=t[7];let w=C,T=r.resetAfterFormatted??r.resetAtFormatted,E;t[8]!==T||t[9]!==b||t[10]!==r.resetAt?(E=Mn(r.resetAt,T,b),t[8]=T,t[9]=b,t[10]=r.resetAt,t[11]=E):E=t[11];let D=E,O;t[12]===n?O=t[13]:(O=On(n),t[12]=n,t[13]=O);let k=O,A;t[14]!==n||t[15]!==r.disablePace||t[16]!==r.resetAt||t[17]!==r.usedPercent||t[18]!==r.windowSeconds?(A=r.disablePace?null:Jn(r.usedPercent,r.resetAt,r.windowSeconds,n),t[14]=n,t[15]=r.disablePace,t[16]=r.resetAt,t[17]=r.usedPercent,t[18]=r.windowSeconds,t[19]=A):A=t[19];let j=A,M;bb0:{if(!j||j.dailyAllocationPercent===null){M=null;break bb0}let e=yr(j.elapsedRatio);M=v===`remaining`?100-e:e}let N=M,P;t[20]===k?P=t[21]:(P=(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:k}),t[20]=k,t[21]=P);let F;t[22]===i?F=t[23]:(F=i&&(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground truncate`,children:i}),t[22]=i,t[23]=F);let I;t[24]!==P||t[25]!==F?(I=(0,$.jsx)(`div`,{className:`min-w-0 flex-1 flex items-center gap-2`,children:(0,$.jsxs)(`div`,{className:`min-w-0 flex flex-col`,children:[P,F]})}),t[24]=P,t[25]=F,t[26]=I):I=t[26];let L=w===`-`?``:w,R;t[27]!==s||t[28]!==c||t[29]!==d||t[30]!==l?(R=c&&(0,$.jsx)(Wi,{checked:l,onChange:e=>s?.(e),ariaLabel:d(`settings.usage.page.options.showInHeaderAria`)}),t[27]=s,t[28]=c,t[29]=d,t[30]=l,t[31]=R):R=t[31];let z;t[32]!==L||t[33]!==R?(z=(0,$.jsxs)(`div`,{className:`typography-ui-label text-foreground tabular-nums flex items-center justify-end gap-2`,children:[L,R]}),t[32]=L,t[33]=R,t[34]=z):z=t[34];let B;t[35]!==I||t[36]!==z?(B=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[I,z]}),t[35]=I,t[36]=z,t[37]=B):B=t[37];let V;t[38]!==S||t[39]!==_||t[40]!==x||t[41]!==N||t[42]!==D||t[43]!==r.disablePace||t[44]!==r.usedPercent?(V=(!r.disablePace||x!==null||D)&&(0,$.jsxs)(`div`,{className:`mt-2.5`,children:[(!r.disablePace||x!==null)&&(0,$.jsx)(Oi,{percent:x,tonePercent:r.usedPercent,expectedMarkerPercent:N,className:`h-1.5`}),(0,$.jsxs)(`div`,{className:`mt-1 flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:D?r.disablePace?`${D} (${_})`:`Resets ${D}`:``}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:r.disablePace&&x===null?``:S})]})]}),t[38]=S,t[39]=_,t[40]=x,t[41]=N,t[42]=D,t[43]=r.disablePace,t[44]=r.usedPercent,t[45]=V):V=t[45];let H;t[46]!==j||t[47]!==y?(H=j&&y&&(0,$.jsx)(`div`,{className:`mt-1.5`,children:(0,$.jsx)(xi,{paceInfo:j})}),t[46]=j,t[47]=y,t[48]=H):H=t[48];let U;return t[49]!==B||t[50]!==V||t[51]!==H?(U=(0,$.jsxs)(`div`,{className:`py-3`,children:[B,V,H]}),t[49]=B,t[50]=V,t[51]=H,t[52]=U):U=t[52],U};function Bf(e){return e.displayMode}function Vf(e){return e.showPredValues}function Hf(e){return e.timeFormatPreference}var Uf=(e,t)=>{if(!e)return`-`;try{return Rn(e,t,{fallback:`-`})}catch{return`-`}},Wf=()=>{let{t:e}=Ge(),t=G(e=>e.timeFormatPreference),n=wi(e=>e.results),r=wi(e=>e.selectedProviderId),i=wi(e=>e.setSelectedProvider),a=wi(e=>e.loadSettings),o=wi(e=>e.fetchAllQuotas),s=wi(e=>e.isLoading),c=wi(e=>e.lastUpdated),l=wi(e=>e.error),u=wi(e=>e.dropdownProviderIds),d=wi(e=>e.setDropdownProviderIds),f=wi(e=>e.selectedModels),p=wi(e=>e.toggleModelSelected),m=wi(e=>e.applyDefaultSelections);_i(),Q.useEffect(()=>{a(),o()},[a,o]),Q.useEffect(()=>{if(r&&(!r.startsWith(`magpie:`)||n.some(e=>e.providerId===r))||n.length===0)return;let e=n.find(e=>e?.configured)?.providerId;i(e??di[0]?.id??null)},[n,r,i]);let h=n.find(e=>e?.providerId===r)??null,g=di.find(e=>e.id===r),_=h?.providerName??g?.name??r??e(`settings.usage.sidebar.title`),v=h?.usage,y=r?u.includes(r):!1,b=Q.useCallback(e=>{if(!r)return;let t=e?Array.from(new Set([...u,r])):u.filter(e=>e!==r);d(t),ye({usageDropdownProviders:t,magpieHiddenProviders:wi.getState().magpieHiddenProviders})},[u,r,d]),x=Q.useMemo(()=>v?.models?Object.entries(v.models).map(([e,t])=>({name:e,windows:t})).filter(e=>Object.keys(e.windows.windows).length>0):[],[v?.models]);Q.useEffect(()=>{r&&x.length>0&&m(r,x.map(e=>e.name))},[r,x,m]);let S=Q.useMemo(()=>!r||x.length===0?new Map:mi(x,e=>e.name,r),[x,r]),C=Q.useMemo(()=>{if(!r)return[];let e=Si(r);return ki(e)},[r]),[w,T]=Q.useState(()=>({})),E=Q.useCallback(e=>{T(t=>({...t,[e]:!t[e]}))},[]),D=Q.useCallback(e=>{if(!r)return;p(r,e);let t=f[r]??[],n=t.includes(e)?t.filter(t=>t!==e):[...t,e],i={...f,[r]:n};ye({usageSelectedModels:i})},[r,f,p]),O=r?f[r]??[]:[];return r?(0,$.jsx)(Ur,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`yuri-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(Mr,{providerId:r,className:`h-5 w-5 shrink-0`}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:e(`settings.usage.page.header.providerUsage`,{provider:_})}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground truncate`,children:s?(0,$.jsx)(`span`,{className:`animate-pulse`,children:e(`settings.usage.page.header.refreshing`)}):e(`settings.usage.page.header.lastUpdated`,{time:Uf(c,t)})})]})]}),(0,$.jsx)(Z,{children:(0,$.jsxs)(`div`,{"data-settings-item":`usage.header-menu`,className:`yuri-settings-group-row yuri-settings-split-row group cursor-pointer`,role:`button`,tabIndex:0,"aria-pressed":y,onClick:()=>b(!y),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),b(!y))},children:[(0,$.jsx)(`div`,{className:`yuri-settings-split-row-copy`,children:(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.usage.page.options.showInHeader`)}),(0,$.jsxs)(En,{children:[(0,$.jsx)(wn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 cursor-help text-muted-foreground/60`})}),(0,$.jsx)(Tn,{sideOffset:8,className:`max-w-xs`,children:e(`settings.usage.page.options.showInHeaderTooltip`)})]})]})}),(0,$.jsx)(`div`,{"data-settings-value":``,className:`yuri-settings-split-row-control`,children:(0,$.jsx)(Wi,{checked:y,onChange:b,ariaLabel:e(`settings.usage.page.options.showInHeaderAria`)})})]})}),!h&&(0,$.jsx)(`div`,{className:`px-2`,children:(0,$.jsx)(`p`,{className:`typography-ui-label text-foreground`,children:e(`settings.usage.page.state.noData`)})}),l&&(0,$.jsxs)(`div`,{className:`rounded-lg border border-[var(--status-error-border)] bg-[var(--status-error-background)] px-4 py-3`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label font-medium text-[var(--status-error)]`,children:e(`settings.usage.page.state.refreshFailedTitle`)}),(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]/80 mt-1`,children:l})]}),h?.configured&&!h.ok&&h.error&&(0,$.jsxs)(`div`,{className:`rounded-lg border border-[var(--status-error-border)] bg-[var(--status-error-background)] px-4 py-3`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label font-medium text-[var(--status-error)]`,children:e(`settings.usage.page.state.refreshFailedTitle`)}),(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]/80 mt-1`,children:h.error})]}),h&&!h.configured&&(0,$.jsxs)(`div`,{className:`rounded-lg border border-[var(--status-warning-border)] bg-[var(--status-warning-background)] px-4 py-3`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label font-medium text-[var(--status-warning)]`,children:e(`settings.usage.page.state.providerNotConfiguredTitle`)}),(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-warning)]/80 mt-1`,children:e(`settings.usage.page.state.providerNotConfiguredDescription`)})]}),v?.accounts?.map((n,r)=>(0,$.jsx)(Z,{label:n.name,children:(0,$.jsxs)(`div`,{className:`yuri-settings-group-row`,children:[(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground break-words`,children:[n.user,n.plan,n.from].filter(Boolean).join(` · `)}),n.readAt&&(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e(`settings.usage.page.header.lastUpdated`,{time:Uf(n.readAt,t)})}),n.stale&&(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e(`settings.usage.magpie.cached`)}),n.error&&(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:e(`settings.usage.page.state.refreshFailedTitle`)}),(0,$.jsx)(`div`,{className:`divide-y divide-[var(--surface-subtle)]`,children:Object.entries(n.windows).map(([e,t])=>(0,$.jsx)(zf,{title:t.label??e,window:t},e))})]})},`${n.id}:${r}`)),!v?.accounts&&v?.windows&&Object.keys(v.windows).length>0&&(0,$.jsx)(Z,{children:(0,$.jsx)(`div`,{"data-settings-item":`usage.model-quotas`,className:`yuri-settings-group-row`,children:(0,$.jsx)(`div`,{className:`divide-y divide-[var(--surface-subtle)]`,children:Object.entries(v.windows).map(([e,t])=>(0,$.jsx)(zf,{title:e,window:t},e))})})}),x.length>0&&(0,$.jsxs)(Z,{label:e(`settings.usage.page.section.modelQuotas`),children:[C.map(e=>{let t=S.get(e.id)??[];if(t.length===0)return null;let n=w[e.id]??!1;return(0,$.jsx)(`div`,{className:`yuri-settings-group-row`,children:(0,$.jsxs)(ca,{open:!n,onOpenChange:()=>E(e.id),children:[(0,$.jsxs)(sa,{className:`flex w-full items-center justify-between py-0.5 group`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-left`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label font-normal text-foreground`,children:e.label}),(0,$.jsxs)(`span`,{className:`typography-micro text-muted-foreground`,children:[`(`,t.length,`)`]})]}),n?(0,$.jsx)(X,{name:`arrow-right-s`,className:`h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors`}):(0,$.jsx)(X,{name:`arrow-down-s`,className:`h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors`})]}),(0,$.jsx)(oa,{children:(0,$.jsx)(`div`,{className:`divide-y divide-[var(--surface-subtle)] mt-1`,children:t.map(e=>{let t=Object.entries(e.windows.windows);if(t.length===0)return null;let[n,r]=t[0],i=O.includes(e.name);return(0,$.jsx)(zf,{title:n,subtitle:vi(e.name),window:r,showToggle:!0,toggleEnabled:i,onToggle:()=>D(e.name)},e.name)})})})]})},e.id)}),(()=>{let t=S.get(null)??[];if(t.length===0)return null;let n=w.other??!1;return(0,$.jsx)(`div`,{className:`yuri-settings-group-row`,children:(0,$.jsxs)(ca,{open:!n,onOpenChange:()=>E(`other`),children:[(0,$.jsxs)(sa,{className:`flex w-full items-center justify-between py-0.5 group`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-left`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label font-normal text-foreground`,children:e(`settings.usage.page.section.otherModels`)}),(0,$.jsxs)(`span`,{className:`typography-micro text-muted-foreground`,children:[`(`,t.length,`)`]})]}),n?(0,$.jsx)(X,{name:`arrow-right-s`,className:`h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors`}):(0,$.jsx)(X,{name:`arrow-down-s`,className:`h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors`})]}),(0,$.jsx)(oa,{children:(0,$.jsx)(`div`,{className:`divide-y divide-[var(--surface-subtle)] mt-1`,children:t.map(e=>{let t=Object.entries(e.windows.windows);if(t.length===0)return null;let[n,r]=t[0],i=O.includes(e.name);return(0,$.jsx)(zf,{title:n,subtitle:vi(e.name),window:r,showToggle:!0,toggleEnabled:i,onToggle:()=>D(e.name)},e.name)})})})]})})})()]}),h?.configured&&v&&Object.keys(v.windows??{}).length===0&&x.length===0&&(0,$.jsxs)(`div`,{className:`px-2`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label text-foreground`,children:e(`settings.usage.page.state.noQuotaWindowsTitle`)}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground mt-1`,children:e(`settings.usage.page.state.noQuotaWindowsDescription`)})]})]})}):(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center text-muted-foreground`,children:(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.usage.page.empty.selectProvider`)})})},Gf=`git.commit.generate`,Kf=W(e=>({selectedPromptId:Gf,setSelectedPromptId:t=>{e(e=>e.selectedPromptId===t?e:{selectedPromptId:t})}})),qf=e=>{let t=(0,Sa.c)(22),{onItemSelect:n}=e,{t:r}=Ge(),i=Kf(Jf),a=Kf(Yf),o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o={groupKey:`settings.magicPrompts.sidebar.group.git`,items:[{id:`git.commit.generate`,titleKey:`settings.magicPrompts.sidebar.item.gitCommitGenerate`},{id:`git.pr.generate`,titleKey:`settings.magicPrompts.sidebar.item.gitPrGenerate`},{id:`git.conflict.resolve`,titleKey:`settings.magicPrompts.sidebar.item.gitConflictResolve`},{id:`git.integrate.cherrypick.resolve`,titleKey:`settings.magicPrompts.sidebar.item.gitCherrypickConflictResolve`}]},t[0]=o):o=t[0];let s;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(s={groupKey:`settings.magicPrompts.sidebar.group.github`,items:[{id:`github.pr.review`,titleKey:`settings.magicPrompts.sidebar.item.githubPrReview`},{id:`github.issue.review`,titleKey:`settings.magicPrompts.sidebar.item.githubIssueReview`},{id:`github.pr.checks.review`,titleKey:`settings.magicPrompts.sidebar.item.githubPrFailedChecksReview`},{id:`github.pr.comments.review`,titleKey:`settings.magicPrompts.sidebar.item.githubPrCommentsReview`},{id:`github.pr.comment.single`,titleKey:`settings.magicPrompts.sidebar.item.githubSinglePrCommentReview`}]},t[1]=s):s=t[1];let c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=[o,s,{groupKey:`settings.magicPrompts.sidebar.group.session`,items:[{id:`session.explore`,titleKey:`settings.magicPrompts.sidebar.item.sessionExplore`},{id:`session.summary`,titleKey:`settings.magicPrompts.sidebar.item.sessionSummary`},{id:`session.review`,titleKey:`settings.magicPrompts.sidebar.item.sessionWorkspaceReview`},{id:`session.craftGoal`,titleKey:`settings.magicPrompts.sidebar.item.sessionCraftGoal`},{id:`session.catchup`,titleKey:`settings.magicPrompts.sidebar.item.sessionCatchUp`},{id:`session.debug`,titleKey:`settings.magicPrompts.sidebar.item.sessionDebug`},{id:`session.weigh`,titleKey:`settings.magicPrompts.sidebar.item.sessionWeigh`},{id:`session.fusion`,titleKey:`settings.magicPrompts.sidebar.item.sessionFusion`}]}],t[2]=c):c=t[2];let l=c,u;t[3]===r?u=t[4]:(u=r(`settings.magicPrompts.sidebar.title`),t[3]=r,t[4]=u);let d;t[5]===u?d=t[6]:(d=(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:u}),t[5]=u,t[6]=d);let f;t[7]===r?f=t[8]:(f=r(`settings.magicPrompts.sidebar.description`),t[7]=r,t[8]=f);let p;t[9]===f?p=t[10]:(p=(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:f}),t[9]=f,t[10]=p);let m;t[11]!==d||t[12]!==p?(m=(0,$.jsxs)(`div`,{className:`flex flex-col justify-center gap-1 px-2`,children:[d,p]}),t[11]=d,t[12]=p,t[13]=m):m=t[13];let h;t[14]!==n||t[15]!==i||t[16]!==a||t[17]!==r?(h=l.map(e=>(0,$.jsx)(Z,{label:r(e.groupKey),children:e.items.map(e=>{let t=i===e.id;return(0,$.jsx)(`button`,{type:`button`,onClick:()=>{a(e.id),n?.()},className:K(`yuri-settings-group-row flex w-full items-center text-left transition-colors`,t?`bg-interactive-selection text-foreground`:`text-foreground hover:bg-interactive-hover`),children:(0,$.jsx)(`span`,{className:`typography-ui-label truncate font-normal`,children:r(e.titleKey)})},e.id)})},e.groupKey)),t[14]=n,t[15]=i,t[16]=a,t[17]=r,t[18]=h):h=t[18];let g;return t[19]!==m||t[20]!==h?(g=(0,$.jsxs)(`div`,{className:`yuri-settings-page-content h-full overflow-y-auto bg-background p-3`,children:[m,h]}),t[19]=m,t[20]=h,t[21]=g):g=t[21],g};function Jf(e){return e.selectedPromptId}function Yf(e){return e.setSelectedPromptId}var Xf={"git.commit.generate":{titleKey:`settings.magicPrompts.page.group.gitCommitGenerate.title`,descriptionKey:`settings.magicPrompts.page.group.gitCommitGenerate.description`,blocks:[{id:`git.commit.generate.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`git.commit.generate.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"git.pr.generate":{titleKey:`settings.magicPrompts.page.group.gitPrGenerate.title`,descriptionKey:`settings.magicPrompts.page.group.gitPrGenerate.description`,blocks:[{id:`git.pr.generate.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`git.pr.generate.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"github.pr.review":{titleKey:`settings.magicPrompts.page.group.githubPrReview.title`,descriptionKey:`settings.magicPrompts.page.group.githubPrReview.description`,blocks:[{id:`github.pr.review.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`github.pr.review.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"github.issue.review":{titleKey:`settings.magicPrompts.page.group.githubIssueReview.title`,descriptionKey:`settings.magicPrompts.page.group.githubIssueReview.description`,blocks:[{id:`github.issue.review.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`github.issue.review.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"github.pr.checks.review":{titleKey:`settings.magicPrompts.page.group.githubPrFailedChecksReview.title`,descriptionKey:`settings.magicPrompts.page.group.githubPrFailedChecksReview.description`,blocks:[{id:`github.pr.checks.review.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`github.pr.checks.review.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"github.pr.comments.review":{titleKey:`settings.magicPrompts.page.group.githubPrCommentsReview.title`,descriptionKey:`settings.magicPrompts.page.group.githubPrCommentsReview.description`,blocks:[{id:`github.pr.comments.review.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`github.pr.comments.review.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"github.pr.comment.single":{titleKey:`settings.magicPrompts.page.group.githubSinglePrCommentReview.title`,descriptionKey:`settings.magicPrompts.page.group.githubSinglePrCommentReview.description`,blocks:[{id:`github.pr.comment.single.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`github.pr.comment.single.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"git.conflict.resolve":{titleKey:`settings.magicPrompts.page.group.gitConflictResolve.title`,descriptionKey:`settings.magicPrompts.page.group.gitConflictResolve.description`,blocks:[{id:`git.conflict.resolve.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`git.conflict.resolve.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"git.integrate.cherrypick.resolve":{titleKey:`settings.magicPrompts.page.group.gitCherrypickConflictResolve.title`,descriptionKey:`settings.magicPrompts.page.group.gitCherrypickConflictResolve.description`,blocks:[{id:`git.integrate.cherrypick.resolve.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`git.integrate.cherrypick.resolve.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"session.summary":{titleKey:`settings.magicPrompts.page.group.sessionSummary.title`,descriptionKey:`settings.magicPrompts.page.group.sessionSummary.description`,blocks:[{id:`session.summary.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`session.summary.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"session.review":{titleKey:`settings.magicPrompts.page.group.sessionWorkspaceReview.title`,descriptionKey:`settings.magicPrompts.page.group.sessionWorkspaceReview.description`,blocks:[{id:`session.review.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`session.review.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"session.craftGoal":{titleKey:`settings.magicPrompts.page.group.sessionCraftGoal.title`,descriptionKey:`settings.magicPrompts.page.group.sessionCraftGoal.description`,blocks:[{id:`session.craftGoal.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`session.craftGoal.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"session.catchup":{titleKey:`settings.magicPrompts.page.group.sessionCatchUp.title`,descriptionKey:`settings.magicPrompts.page.group.sessionCatchUp.description`,blocks:[{id:`session.catchup.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`session.catchup.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"session.debug":{titleKey:`settings.magicPrompts.page.group.sessionDebug.title`,descriptionKey:`settings.magicPrompts.page.group.sessionDebug.description`,blocks:[{id:`session.debug.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`session.debug.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"session.weigh":{titleKey:`settings.magicPrompts.page.group.sessionWeigh.title`,descriptionKey:`settings.magicPrompts.page.group.sessionWeigh.description`,blocks:[{id:`session.weigh.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`session.weigh.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"session.explore":{titleKey:`settings.magicPrompts.page.group.sessionExplore.title`,descriptionKey:`settings.magicPrompts.page.group.sessionExplore.description`,blocks:[{id:`session.explore.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`session.explore.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"session.fusion":{titleKey:`settings.magicPrompts.page.group.sessionFusion.title`,descriptionKey:`settings.magicPrompts.page.group.sessionFusion.description`,blocks:[{id:`session.fusion.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`session.fusion.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]}},Zf=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Qf=e=>e.endsWith(`.visible`),$f=()=>{let{t:e}=Ge(),t=Q.useCallback(t=>e(t),[e]),n=Kf(e=>e.selectedPromptId),[r,i]=Q.useState(!0),[a,o]=Q.useState({}),[s,c]=Q.useState({}),[l,u]=Q.useState({}),[d,f]=Q.useState({}),[p,m]=Q.useState(!1);Q.useEffect(()=>{let t=!0;return(async()=>{i(!0);try{let e=await yn();if(!t)return;o(e)}catch(t){console.warn(`Failed to load magic prompts:`,t),J.error(e(`settings.magicPrompts.page.toast.loadFailed`))}finally{t&&i(!1)}})(),()=>{t=!1}},[e]);let h=Xf[n]??Xf[`git.commit.generate`],g=Q.useCallback(e=>Zf(a,e)?a[e]:Sn(e),[a]),_=Q.useCallback(e=>s[e]??g(e),[s,g]),v=Q.useCallback((e,t)=>{c(n=>n[e]===t?n:{...n,[e]:t})},[]),y=Q.useCallback(async t=>{let n=_(t);if(Qf(t)&&n.trim().length===0){J.error(e(`settings.magicPrompts.page.toast.visiblePromptRequired`));return}u(e=>({...e,[t]:!0}));try{let r=n===Sn(t)?await bn(t):await xn(t,n);o(r.overrides),J.success(e(`settings.magicPrompts.page.toast.saved`))}catch(t){let n=t instanceof Error?t.message:String(t);J.error(e(`settings.magicPrompts.page.toast.saveFailed`),{description:n})}finally{u(e=>({...e,[t]:!1}))}},[_,e]),b=Q.useCallback(async t=>{f(e=>({...e,[t]:!0}));try{let n=await bn(t);o(n.overrides),c(e=>({...e,[t]:Sn(t)})),J.success(e(`settings.magicPrompts.page.toast.resetSuccess`))}catch(t){let n=t instanceof Error?t.message:String(t);J.error(e(`settings.magicPrompts.page.toast.resetFailed`),{description:n})}finally{f(e=>({...e,[t]:!1}))}},[e]),x=Q.useCallback(async()=>{m(!0);try{let t=await vn();o(t.overrides),c({}),J.success(e(`settings.magicPrompts.page.toast.resetAllSuccess`))}catch(t){let n=t instanceof Error?t.message:String(t);J.error(e(`settings.magicPrompts.page.toast.resetAllFailed`),{description:n})}finally{m(!1)}},[e]);return r?(0,$.jsxs)(`div`,{className:`py-6 px-6 flex items-center gap-2 text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-current animate-busy-pulse`,"aria-label":e(`settings.magicPrompts.page.loading.aria`)}),(0,$.jsx)(`span`,{className:`typography-ui`,children:e(`settings.magicPrompts.page.loading.text`)})]}):(0,$.jsx)(`div`,{className:`h-full overflow-auto`,children:(0,$.jsxs)(`div`,{className:`yuri-settings-page-content mx-auto w-full max-w-4xl px-6 py-6`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,$.jsx)(`div`,{className:`space-y-1`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground`,children:t(h.titleKey)}),(0,$.jsxs)(En,{children:[(0,$.jsx)(wn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(Tn,{sideOffset:8,className:`max-w-xs`,children:t(h.descriptionKey)})]})]})}),(0,$.jsx)(q,{"data-settings-item":`magic-prompts.reset-overrides`,variant:`outline`,size:`sm`,onClick:()=>{x()},disabled:p||Object.keys(a).length===0,children:e(p?`settings.magicPrompts.page.actions.resetting`:`settings.magicPrompts.page.actions.resetAllOverrides`)})]}),h.blocks.map(n=>{let r=_n(n.id),i=g(n.id),o=_(n.id),s=Zf(a,n.id),c=o!==i,u=Qf(n.id)&&o.trim().length===0,f=l[n.id]===!0,p=d[n.id]===!0;return(0,$.jsx)(Z,{actions:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>void b(n.id),disabled:!s||f||p,children:e(p?`settings.magicPrompts.page.actions.resetting`:`settings.magicPrompts.page.actions.resetToDefault`)}),(0,$.jsx)(q,{size:`sm`,onClick:()=>void y(n.id),disabled:!c||f||p||u,"aria-busy":f,children:e(f?`settings.common.actions.saving`:`settings.magicPrompts.page.actions.save`)})]}),label:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`span`,{children:t(n.titleKey)}),(0,$.jsxs)(En,{children:[(0,$.jsx)(wn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(Tn,{sideOffset:8,className:`max-w-xs`,children:r.description})]})]}),cardClassName:`p-3`,children:(0,$.jsxs)(`div`,{"data-settings-item":Qf(n.id)?`magic-prompts.visible-prompt`:`magic-prompts.instructions`,className:`space-y-3`,children:[r.placeholders&&r.placeholders.length>0&&(0,$.jsxs)(`div`,{className:`typography-micro text-muted-foreground`,children:[e(`settings.magicPrompts.page.placeholdersLabel`),` `,r.placeholders.map(e=>`{{${e.key}}}`).join(`, `)]}),(0,$.jsx)(Wr,{embedded:!0,value:o,onChange:e=>v(n.id,e.target.value),className:`min-h-[220px] font-mono text-sm`}),u&&(0,$.jsx)(`div`,{className:`typography-micro text-[var(--status-error)]`,children:e(`settings.magicPrompts.page.validation.visiblePromptRequired`)}),(0,$.jsx)(`div`,{className:`flex items-center justify-between gap-2`,children:(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:e(c?`settings.magicPrompts.page.status.unsavedChanges`:s?`settings.magicPrompts.page.status.usingSavedOverride`:`settings.magicPrompts.page.status.usingBuiltinDefault`)})})]})},n.id)})]})})},ep=()=>{let{t:e}=Ge(),t=pt(e=>e.settingsGitmojiEnabled),n=pt(e=>e.setSettingsGitmojiEnabled),r=_e(),i=G(e=>e.gitChangesViewMode),a=G(e=>e.setGitChangesViewMode),[o,s]=Q.useState(!0),c=Q.useMemo(()=>[{id:`flat`,label:e(`settings.yuri.git.option.flatList`)},{id:`tree`,label:e(`settings.yuri.git.option.treeView`)}],[e]);Q.useEffect(()=>{(async()=>{try{let e=null;if(!e){let t=A()?.settings;if(t)try{let n=(await t.load())?.settings;n&&(e={gitmojiEnabled:typeof n.gitmojiEnabled==`boolean`?n.gitmojiEnabled:void 0,gitChangesViewMode:n.gitChangesViewMode===`flat`||n.gitChangesViewMode===`tree`?n.gitChangesViewMode:void 0})}catch{}}if(!e){let t=await l(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});t.ok&&(e=await t.json())}e&&(typeof e.gitmojiEnabled==`boolean`&&n(e.gitmojiEnabled),(e.gitChangesViewMode===`flat`||e.gitChangesViewMode===`tree`)&&a(e.gitChangesViewMode))}catch(e){console.warn(`Failed to load git settings:`,e)}finally{s(!1)}})()},[a,n]);let u=Q.useCallback(async e=>{n(e);try{await ye({gitmojiEnabled:e})}catch(e){console.warn(`Failed to save gitmoji setting:`,e)}},[n]),d=Q.useCallback(e=>{e!==i&&(a(e),ye({gitChangesViewMode:e}))},[i,a]);return o?null:(0,$.jsxs)(Z,{label:e(`settings.yuri.git.title`),children:[(0,$.jsx)(Xi,{itemId:`git.changes-view`,label:e(`settings.yuri.git.changesViewTitle`),controlClassName:`items-end`,children:(0,$.jsx)(`div`,{role:`radiogroup`,"aria-label":e(`settings.yuri.git.changesViewAria`),className:`mt-0.5 space-y-0`,children:c.map(t=>{let n=i===t.id;return(0,$.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-pressed":n,onClick:()=>{d(t.id)},onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),d(t.id))},className:`flex w-full items-center gap-2 py-0 text-left`,children:[(0,$.jsx)(pa,{checked:n,onChange:()=>{d(t.id)},ariaLabel:e(`settings.yuri.git.optionAria`,{option:t.label})}),(0,$.jsx)(`span`,{className:n?`typography-ui-label font-normal text-foreground`:`typography-ui-label font-normal text-foreground/50`,children:t.label})]},t.id)})})}),(0,$.jsx)(Ji,{itemId:`git.gitmoji`,checked:t,onChange:e=>{u(e)},label:e(`settings.yuri.git.enableGitmoji`),ariaLabel:e(`settings.yuri.git.enableGitmojiAria`)}),(0,$.jsx)(Ji,{itemId:`git.gitignored-files`,checked:r,onChange:me,label:e(`settings.yuri.git.showGitignored`),ariaLabel:e(`settings.yuri.git.showGitignoredAria`)})]})},tp=({itemId:e})=>{let{t}=Ge(),{isMobile:n}=wr(),r=A()?.github,i=An(),a=i.data??null,o=i.isLoading&&!i.data,s=i.isFetched,c=gi(e=>e.refreshStatus),u=gi(e=>e.setStatus),d=Q.useCallback(async e=>{await Br(e)},[]),[f,p]=Q.useState(!1),[m,h]=Q.useState(null),[g,_]=Q.useState(null),v=Q.useRef(null),y=Q.useRef(0),b=Q.useCallback(()=>{v.current!=null&&(window.clearTimeout(v.current),v.current=null),_(null)},[]);Q.useEffect(()=>((async()=>{try{s||await c(r)}catch(e){console.warn(`Failed to load GitHub auth status:`,e)}})(),()=>{b()}),[s,c,r,b]);let x=Q.useCallback(async()=>{p(!0);try{let e=r?await r.authStart():await(async()=>{let e=await l(`/api/github/auth/start`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({})}),t=await e.json().catch(()=>null);if(!e.ok||!t||!(`deviceCode`in t))throw Error(t?.error||e.statusText);return t})();h(e),y.current=Date.now(),_(Math.max(1,e.interval)*1e3);let t=e.verificationUriComplete||e.verificationUri;d(t)}catch(e){console.error(`Failed to start GitHub connect:`,e),J.error(t(`settings.github.page.toast.startConnectFailed`))}finally{p(!1)}},[d,r,t]),S=Q.useCallback(async e=>{if(r)return r.authComplete(e);let t=await l(`/api/github/auth/complete`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({deviceCode:e})}),n=await t.json().catch(()=>null);if(!t.ok||!n)throw Error(n?.error||t.statusText);return n},[r]);Q.useEffect(()=>{if(!m?.deviceCode||!g||v.current!=null)return;let e=!1,n=y.current+m.expiresIn*1e3,i=async()=>{if(Date.now()>=n){J.error(t(`settings.github.page.toast.authorizationFailed`)),h(null),b();return}try{let n=await S(m.deviceCode);if(e)return;if(n.connected){J.success(t(`settings.github.page.toast.connected`)),h(null),b(),await c(r,{force:!0});return}if(n.status===`slow_down`){_(e=>e?e+5e3:5e3);return}if(n.status===`expired_token`||n.status===`access_denied`){J.error(n.error||t(`settings.github.page.toast.authorizationFailed`)),h(null),b();return}}catch(t){if(e)return;console.warn(`GitHub polling failed:`,t)}v.current=window.setTimeout(()=>void i(),g)};return v.current=window.setTimeout(()=>void i(),g),()=>{e=!0,v.current!=null&&(window.clearTimeout(v.current),v.current=null)}},[m,g,S,c,r,b,t]);let C=Q.useCallback(async e=>{p(!0);try{if(r)await r.authSetGhCliDisabled(e);else{let t=await l(`/api/github/auth/gh-cli`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({disabled:e})}),n=await t.json().catch(()=>null);if(!t.ok)throw Error(n?.error||t.statusText)}J.success(t(e?`settings.github.page.toast.ghCliDisabled`:`settings.github.page.toast.ghCliEnabled`)),await c(r,{force:!0})}catch(e){console.error(`Failed to update gh CLI setting:`,e),J.error(t(`settings.github.page.toast.ghCliUpdateFailed`))}finally{p(!1)}},[c,r,t]),w=Q.useCallback(async()=>{p(!0);try{if(b(),h(null),r)await r.authDisconnect();else{let e=await l(`/api/github/auth`,{method:`DELETE`,headers:{Accept:`application/json`}});if(!e.ok)throw Error(e.statusText)}J.success(t(`settings.github.page.toast.disconnected`)),await c(r,{force:!0})}catch(e){console.error(`Failed to disconnect GitHub:`,e),J.error(t(`settings.github.page.toast.disconnectFailed`))}finally{p(!1)}},[c,r,b,t]),T=Q.useCallback(async e=>{if(e){p(!0);try{let n=r?await r.authActivate(e):await(async()=>{let t=await l(`/api/github/auth/activate`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({accountId:e})}),n=await t.json().catch(()=>null);if(!t.ok||!n)throw Error(n?.error||t.statusText);return n})();u(n),J.success(t(`settings.github.page.toast.accountSwitched`))}catch(e){console.error(`Failed to switch GitHub account:`,e),J.error(t(`settings.github.page.toast.accountSwitchFailed`))}finally{p(!1)}}},[r,u,t]);if(o)return null;if(i.isError&&!i.data)return(0,$.jsx)(`div`,{className:`yuri-settings-group-description text-[var(--status-error)]`,children:i.error.message});let E=!!a?.connected,D=a?.user,O=(a?.accounts??[]).filter(e=>!e.current),k=a?.ghCli??null,j=k?.active?t(`settings.github.page.accountSource.cli`):t(`settings.github.page.accountSource.oauth`);return(0,$.jsxs)(`div`,{className:`yuri-settings-section-stack`,children:[(0,$.jsxs)(Z,{itemId:e,label:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{children:t(`settings.github.page.oauth.title`)}),(0,$.jsxs)(En,{children:[(0,$.jsx)(wn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(Tn,{sideOffset:8,className:`max-w-xs`,children:t(`settings.github.page.tooltip.connectAccount`)})]})]}),children:[(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[E?(0,$.jsxs)(`div`,{className:K(`yuri-settings-group-row`,n?`flex flex-col items-stretch gap-3`:`flex items-center justify-between gap-4`),children:[(0,$.jsxs)(`div`,{className:K(`flex min-w-0 items-center gap-3`,n?`w-full`:void 0),children:[D?.avatarUrl?(0,$.jsx)(`img`,{src:D.avatarUrl,alt:D.login?t(`settings.github.page.avatarAlt.withLogin`,{login:D.login}):t(`settings.github.page.avatarAlt.fallback`),className:`h-10 w-10 shrink-0 rounded-full border border-[var(--interactive-border)] bg-[var(--surface-muted)] object-cover`,loading:`lazy`,referrerPolicy:`no-referrer`}):(0,$.jsx)(`div`,{className:`h-10 w-10 shrink-0 rounded-full border border-[var(--interactive-border)] bg-[var(--surface-muted)]`}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:D?.name?.trim()||D?.login||`GitHub`}),(0,$.jsxs)(`div`,{className:K(`flex items-center gap-2 typography-meta text-muted-foreground mt-0.5`,n?`flex-wrap`:`truncate`),children:[(0,$.jsx)(X,{name:`github-fill`,className:`h-3.5 w-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`font-mono`,children:D?.login||t(`settings.github.page.label.unknownUser`)}),D?.email&&(0,$.jsx)(`span`,{className:`opacity-50`,children:`•`}),D?.email&&(0,$.jsx)(`span`,{children:D.email}),(0,$.jsx)(`span`,{className:`opacity-50`,children:`•`}),(0,$.jsx)(`span`,{children:j})]}),a?.scope&&(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/70 mt-0.5`,children:t(`settings.github.page.label.scopes`,{value:a.scope})}),k?.active&&(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/70 mt-0.5`,children:t(`settings.github.page.ghCli.activeDescription`)})]})]}),k?.active?(0,$.jsx)(q,{size:`sm`,variant:`outline`,onClick:()=>C(!0),disabled:f,className:K(n?`w-full`:void 0),children:t(`settings.github.page.ghCli.actions.disable`)}):(0,$.jsx)(q,{size:`sm`,variant:`outline`,onClick:w,disabled:f,className:K(`text-[var(--status-error)] hover:text-[var(--status-error)]`,n?`w-full`:void 0),children:t(`settings.github.page.actions.disconnect`)})]}):(0,$.jsxs)(`div`,{className:K(`yuri-settings-group-row`,n?`flex flex-col items-stretch gap-3`:`flex items-center justify-between gap-4`),children:[(0,$.jsx)(`div`,{className:`flex min-w-0 flex-col`,children:(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:t(`settings.github.page.status.notConnected`)})}),(0,$.jsx)(q,{size:`sm`,variant:`default`,onClick:x,disabled:f,className:K(n?`w-full`:void 0),children:t(`settings.github.page.actions.connect`)})]}),O.length>0&&(0,$.jsxs)(`div`,{className:`yuri-settings-group-row flex flex-col gap-2`,children:[(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground`,children:t(`settings.github.page.label.otherAccounts`)}),O.map(e=>{let n=e.user,r=e.source===`gh-cli`?t(`settings.github.page.accountSource.cli`):t(`settings.github.page.accountSource.oauth`);return(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[n?.avatarUrl?(0,$.jsx)(`img`,{src:n.avatarUrl,alt:n.login?t(`settings.github.page.avatarAlt.withLogin`,{login:n.login}):t(`settings.github.page.avatarAlt.fallback`),className:`h-6 w-6 shrink-0 rounded-full border border-[var(--interactive-border)] bg-[var(--surface-muted)] object-cover`,loading:`lazy`,referrerPolicy:`no-referrer`}):(0,$.jsx)(`div`,{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-full border border-[var(--interactive-border)] bg-[var(--surface-muted)]`,children:(0,$.jsx)(X,{name:`github-fill`,className:`h-3 w-3 text-muted-foreground`})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex flex-col`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:n?.name?.trim()||n?.login||`GitHub`}),n?.login&&(0,$.jsxs)(`span`,{className:`typography-micro text-muted-foreground truncate`,children:[(0,$.jsx)(`span`,{className:`font-mono`,children:n.login}),(0,$.jsx)(`span`,{className:`mx-1 opacity-50`,children:`·`}),(0,$.jsx)(`span`,{children:r})]})]})]}),(0,$.jsx)(q,{size:`sm`,variant:`ghost`,onClick:()=>T(e.id),disabled:f,children:t(`settings.github.page.actions.switchTo`)})]},e.id)})]})]}),E&&(0,$.jsx)(`div`,{className:`yuri-settings-group-row flex justify-end`,children:(0,$.jsx)(q,{size:`sm`,variant:`outline`,onClick:x,disabled:f,className:K(n?`w-full`:void 0),children:t(`settings.github.page.actions.addAccount`)})})]}),m&&(0,$.jsxs)(`div`,{className:`mt-4 rounded-lg bg-[var(--surface-elevated)]/70 p-4 border border-[var(--interactive-border)]`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`h4`,{className:`typography-ui-label text-foreground`,children:t(`settings.github.page.flow.title`)}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.github.page.flow.description`)})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 mt-4`,children:[(0,$.jsx)(`div`,{className:`font-mono text-xl tracking-widest text-foreground bg-[var(--surface-muted)] px-3 py-1.5 rounded-md border border-[var(--interactive-border)]`,children:m.userCode}),(0,$.jsx)(q,{size:`sm`,asChild:!0,children:(0,$.jsx)(`a`,{href:m.verificationUriComplete||m.verificationUri,target:`_blank`,rel:`noopener noreferrer`,children:t(`settings.github.page.actions.openGithub`)})})]}),(0,$.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground animate-pulse`,children:t(`settings.github.page.flow.waiting`)}),(0,$.jsx)(q,{size:`sm`,variant:`ghost`,disabled:f,onClick:()=>{b(),h(null)},children:t(`settings.common.actions.cancel`)})]})]}),k?.available&&!k?.active&&(!k.user||k.disabled)&&(0,$.jsx)(Z,{label:t(`settings.github.page.ghCli.title`),children:(0,$.jsx)(`div`,{className:`yuri-settings-group-row`,children:(0,$.jsxs)(`div`,{className:K(n?`flex flex-col gap-3`:`flex items-center justify-between gap-4`),children:[(0,$.jsxs)(`div`,{className:K(`flex min-w-0 items-center gap-3`,n?`w-full`:void 0),children:[k.user?.avatarUrl?(0,$.jsx)(`img`,{src:k.user.avatarUrl,alt:k.user.login?t(`settings.github.page.avatarAlt.withLogin`,{login:k.user.login}):t(`settings.github.page.avatarAlt.fallback`),className:`h-10 w-10 shrink-0 rounded-full border border-[var(--interactive-border)] bg-[var(--surface-muted)] object-cover`,loading:`lazy`,referrerPolicy:`no-referrer`}):(0,$.jsx)(`div`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-full border border-[var(--interactive-border)] bg-[var(--surface-muted)]`,children:(0,$.jsx)(X,{name:`github-fill`,className:`h-4 w-4 text-muted-foreground`})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[!k.disabled&&k.user&&(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground truncate`,children:k.user.name?.trim()||k.user.login||`GitHub`}),!k.disabled&&k.user?.login&&(0,$.jsxs)(`div`,{className:K(`flex items-center gap-2 typography-meta text-muted-foreground mt-0.5`,n?`flex-wrap`:`truncate`),children:[(0,$.jsx)(X,{name:`github-fill`,className:`h-3.5 w-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`font-mono`,children:k.user.login}),k.user.email&&(0,$.jsx)(`span`,{className:`opacity-50`,children:`•`}),k.user.email&&(0,$.jsx)(`span`,{children:k.user.email})]}),(0,$.jsx)(`div`,{className:K(`typography-meta text-muted-foreground`,k.disabled?`opacity-60`:void 0),children:k.disabled?t(`settings.github.page.ghCli.disabledDescription`):t(`settings.github.page.ghCli.fallbackDescription`)})]})]}),(0,$.jsx)(q,{size:`sm`,variant:`outline`,onClick:()=>C(!k.disabled),disabled:f,className:K(n?`w-full`:void 0),children:k.disabled?t(`settings.github.page.ghCli.actions.enable`):t(`settings.github.page.ghCli.actions.disable`)})]})})})]})},np=[{key:`keyword`,label:`Green`,cssVar:`var(--syntax-keyword)`},{key:`error`,label:`Red`,cssVar:`var(--status-error)`},{key:`string`,label:`Cyan`,cssVar:`var(--syntax-string)`},{key:`function`,label:`Orange`,cssVar:`var(--syntax-function)`},{key:`type`,label:`Yellow`,cssVar:`var(--syntax-type)`}],rp=[{key:`branch`,Icon:`git-branch`,label:`Branch`},{key:`briefcase`,Icon:`briefcase`,label:`Work`},{key:`house`,Icon:`home`,label:`Personal`},{key:`graduation`,Icon:`graduation-cap`,label:`School`},{key:`code`,Icon:`code`,label:`Code`}],ip=({open:e,onOpenChange:t,profileId:n,importData:r})=>{let{t:i}=Ge(),a=ji(e=>e.getProfileById),o=ji(e=>e.createProfile),s=ji(e=>e.updateProfile),c=ji(e=>e.deleteProfile),l=Q.useMemo(()=>n&&n!==`new`&&!r?a(n):null,[n,a,r]),u=n===`new`||r!=null,d=n===`global`,[f,p]=Q.useState(``),[m,h]=Q.useState(``),[g,_]=Q.useState(``),[v,y]=Q.useState(`ssh`),[b,x]=Q.useState(``),[S,C]=Q.useState(!1),[w,T]=Q.useState(``),[E,D]=Q.useState(``),[O,k]=Q.useState(`keyword`),[A,j]=Q.useState(`branch`),[M,N]=Q.useState(!1),[P,F]=Q.useState(!1),[I,L]=Q.useState(!1);Q.useEffect(()=>{if(e){if(r){let e=r.host.split(`/`),t=e.length>=3?e[e.length-1]:r.host;p(t),h(r.username),_(``),y(`token`),x(``),C(!1),T(``),D(r.host),k(`string`),j(`code`)}else if(u)p(``),h(``),_(``),y(`ssh`),x(``),C(!1),T(``),D(``),k(`keyword`),j(`branch`);else if(l)p(l.name),h(l.userName),_(l.userEmail),y(l.authType||`ssh`),x(l.sshKey||``),C(l.signCommits===!0),T(l.signingKey||``),D(l.host||``),k(l.color||`keyword`),j(l.icon||`branch`);else if(d){let e=a(`global`);e&&(p(e.name),h(e.userName),_(e.userEmail),y(e.authType||`ssh`),x(e.sshKey||``),C(!1),T(``),D(e.host||``),k(e.color||`keyword`),j(e.icon||`branch`))}}},[e,n,l,u,r,d,a]);let R=async()=>{if(!m.trim()||!g.trim()){J.error(i(`settings.gitIdentities.editor.toast.userNameEmailRequired`));return}if(v===`token`&&!E.trim()){J.error(i(`settings.gitIdentities.editor.toast.hostRequiredForToken`));return}if(S&&!w.trim()){J.error(i(`settings.gitIdentities.editor.toast.signingKeyRequired`));return}N(!0);try{let e={name:f.trim()||m.trim(),userName:m.trim(),userEmail:g.trim(),authType:v,sshKey:v===`ssh`&&b.trim()||null,signCommits:S,signingKey:w.trim()||null,host:v===`token`&&E.trim()||null,color:O,icon:A},r;if(u)r=await o(e);else if(n)r=await s(n,e);else return;r?(J.success(i(u?`settings.gitIdentities.editor.toast.profileCreated`:`settings.gitIdentities.editor.toast.profileUpdated`)),t(!1)):J.error(i(u?`settings.gitIdentities.editor.toast.createProfileFailed`:`settings.gitIdentities.editor.toast.updateProfileFailed`))}catch(e){console.error(`Error saving profile:`,e),J.error(i(`settings.gitIdentities.editor.toast.saveUnexpectedError`))}finally{N(!1)}},z=async()=>{if(!(!n||u)){L(!0);try{await c(n)?(J.success(i(`settings.gitIdentities.editor.toast.profileDeleted`)),F(!1),t(!1)):J.error(i(`settings.gitIdentities.editor.toast.deleteProfileFailed`))}catch(e){console.error(`Error deleting profile:`,e),J.error(i(`settings.gitIdentities.editor.toast.deleteUnexpectedError`))}finally{L(!1)}}},B=Q.useMemo(()=>np.find(e=>e.key===O)?.cssVar||`var(--syntax-keyword)`,[O]),V=r?i(`settings.gitIdentities.editor.title.importCredential`):u?i(`settings.gitIdentities.editor.title.newIdentity`):d?i(`settings.gitIdentities.editor.title.globalIdentity`):l?.name||i(`settings.gitIdentities.editor.title.editIdentity`);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(gn,{open:e,onOpenChange:t,children:(0,$.jsxs)(pn,{className:`max-w-lg max-h-[85vh] overflow-y-auto`,children:[(0,$.jsx)(Gi,{className:`pr-8`,actions:d?null:(0,$.jsxs)($.Fragment,{children:[u?null:(0,$.jsx)(q,{variant:`ghost`,size:`icon`,onClick:()=>F(!0),disabled:M,"aria-label":i(`settings.common.actions.delete`),title:i(`settings.common.actions.delete`),className:`text-[var(--status-error)]`,children:(0,$.jsx)(X,{name:`delete-bin`,className:`size-4`})}),(0,$.jsx)(q,{size:`sm`,onClick:R,disabled:M,"aria-busy":M,children:i(M?`settings.common.actions.saving`:u?`settings.gitIdentities.editor.actions.create`:`settings.gitIdentities.editor.actions.save`)})]}),children:(0,$.jsxs)(dn,{children:[(0,$.jsx)(mn,{children:V}),(0,$.jsx)(hn,{children:i(d?`settings.gitIdentities.editor.description.globalReadOnly`:u?`settings.gitIdentities.editor.description.newProfile`:`settings.gitIdentities.editor.description.editProfile`)})]})}),(0,$.jsxs)(`div`,{className:`space-y-5 py-2`,children:[!d&&(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`typography-ui-label text-foreground block mb-1.5`,children:i(`settings.gitIdentities.editor.field.profileName`)}),(0,$.jsx)(Cn,{value:f,onChange:e=>p(e.target.value),placeholder:i(`settings.gitIdentities.editor.field.profileNamePlaceholder`),className:`h-8`})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:i(`settings.gitIdentities.editor.field.color`)}),(0,$.jsx)(`div`,{className:`flex gap-1.5`,children:np.map(e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>k(e.key),className:K(`w-6 h-6 rounded-md border-2 transition-all cursor-pointer`,O===e.key?`border-foreground scale-110`:`border-transparent hover:border-border`),style:{backgroundColor:e.cssVar},title:e.label},e.key))})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:i(`settings.gitIdentities.editor.field.icon`)}),(0,$.jsx)(`div`,{className:`flex gap-1.5`,children:rp.map(e=>{let t=e.Icon;return(0,$.jsx)(`button`,{type:`button`,onClick:()=>j(e.key),className:K(`w-7 h-7 rounded-md border-2 transition-all flex items-center justify-center cursor-pointer`,A===e.key?`border-[var(--interactive-border)] bg-[var(--surface-muted)]`:`border-transparent hover:border-[var(--interactive-border)] hover:bg-[var(--surface-muted)]/50`),title:e.label,children:(0,$.jsx)(X,{name:t,className:`w-3.5 h-3.5`,style:{color:A===e.key?B:`var(--surface-muted-foreground)`}})},e.key)})})]})]}),!d&&(0,$.jsx)(`div`,{className:`border-t border-border/40`}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1.5`,children:[(0,$.jsx)(`label`,{className:`typography-ui-label text-foreground`,children:i(`settings.gitIdentities.editor.field.userName`)}),!d&&(0,$.jsx)(`span`,{className:`text-[var(--status-error)] text-xs`,children:`*`}),(0,$.jsxs)(En,{children:[(0,$.jsx)(wn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(Tn,{sideOffset:8,className:`max-w-xs`,children:i(`settings.gitIdentities.editor.field.userNameTooltip`)})]})]}),(0,$.jsx)(Cn,{value:m,onChange:e=>h(e.target.value),placeholder:i(`settings.gitIdentities.editor.field.userNamePlaceholder`),required:!d,readOnly:d,disabled:d,className:`h-8`})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1.5`,children:[(0,$.jsx)(`label`,{className:`typography-ui-label text-foreground`,children:i(`settings.gitIdentities.editor.field.emailAddress`)}),!d&&(0,$.jsx)(`span`,{className:`text-[var(--status-error)] text-xs`,children:`*`}),(0,$.jsxs)(En,{children:[(0,$.jsx)(wn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(Tn,{sideOffset:8,className:`max-w-xs`,children:i(`settings.gitIdentities.editor.field.emailAddressTooltip`)})]})]}),(0,$.jsx)(Cn,{type:`email`,value:g,onChange:e=>_(e.target.value),placeholder:i(`settings.gitIdentities.editor.field.emailAddressPlaceholder`),required:!d,readOnly:d,disabled:d,className:`h-8`})]})]}),!d&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`border-t border-border/40`}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:i(`settings.gitIdentities.editor.field.authMethod`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsxs)(q,{size:`sm`,type:`button`,variant:`chip`,"aria-pressed":v===`ssh`,onClick:()=>y(`ssh`),children:[(0,$.jsx)(X,{name:`lock-2`,className:`w-3.5 h-3.5 mr-1`}),` SSH`]}),(0,$.jsxs)(q,{size:`sm`,type:`button`,variant:`chip`,"aria-pressed":v===`token`,onClick:()=>y(`token`),children:[(0,$.jsx)(X,{name:`key`,className:`w-3.5 h-3.5 mr-1`}),` `,i(`settings.gitIdentities.editor.field.authToken`)]})]})]}),v===`ssh`&&(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1.5`,children:[(0,$.jsx)(`label`,{className:`typography-ui-label text-foreground`,children:i(`settings.gitIdentities.editor.field.sshKeyPath`)}),(0,$.jsxs)(En,{children:[(0,$.jsx)(wn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(Tn,{sideOffset:8,className:`max-w-xs`,children:i(`settings.gitIdentities.editor.field.sshKeyPathTooltip`)})]})]}),(0,$.jsx)(Cn,{value:b,onChange:e=>x(e.target.value),placeholder:i(`settings.gitIdentities.editor.field.sshKeyPathPlaceholder`),className:`h-8 font-mono text-xs`})]}),(0,$.jsxs)(`div`,{className:`border-t border-border/40 pt-3 space-y-3`,children:[(0,$.jsx)(Ji,{checked:S,onChange:C,label:i(`settings.gitIdentities.editor.field.signCommits`),description:i(`settings.gitIdentities.editor.section.commitSigning`),ariaLabel:i(`settings.gitIdentities.editor.field.signCommits`)}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`flex items-center gap-1.5 mb-1.5`,children:(0,$.jsx)(`label`,{className:`typography-ui-label text-foreground`,children:i(`settings.gitIdentities.editor.field.signingKey`)})}),(0,$.jsx)(Cn,{value:w,onChange:e=>T(e.target.value),placeholder:i(`settings.gitIdentities.editor.field.signingKeyPlaceholder`),disabled:!S,className:`h-8 font-mono text-xs`})]})]}),v===`token`&&(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1.5`,children:[(0,$.jsx)(`label`,{className:`typography-ui-label text-foreground`,children:i(`settings.gitIdentities.editor.field.host`)}),(0,$.jsx)(`span`,{className:`text-[var(--status-error)] text-xs`,children:`*`}),(0,$.jsxs)(En,{children:[(0,$.jsx)(wn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(Tn,{sideOffset:8,className:`max-w-xs`,children:i(`settings.gitIdentities.editor.field.hostTooltip`)})]})]}),(0,$.jsx)(Cn,{value:E,onChange:e=>D(e.target.value),placeholder:i(`settings.gitIdentities.editor.field.hostPlaceholder`),required:!0,className:`h-8 font-mono text-xs`})]})]})]})]}),(0,$.jsx)(fn,{className:`gap-2`,children:(0,$.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>t(!1),className:`text-foreground hover:bg-interactive-hover hover:text-foreground`,children:i(d?`settings.gitIdentities.editor.actions.close`:`settings.common.actions.cancel`)})})]})}),(0,$.jsx)(gn,{open:P,onOpenChange:e=>{I||F(e)},children:(0,$.jsxs)(pn,{className:`max-w-md`,children:[(0,$.jsxs)(dn,{children:[(0,$.jsx)(mn,{children:i(`settings.gitIdentities.page.deleteDialog.title`)}),(0,$.jsx)(hn,{children:i(`settings.gitIdentities.page.deleteDialog.description`,{name:l?.name||f})})]}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(q,{variant:`ghost`,onClick:()=>F(!1),disabled:I,children:i(`settings.common.actions.cancel`)}),(0,$.jsx)(q,{size:`sm`,variant:`destructive`,onClick:()=>void z(),disabled:I,children:i(`settings.common.actions.delete`)})]})]})})]})},ap={branch:`git-branch`,briefcase:`briefcase`,house:`home`,graduation:`graduation-cap`,code:`code`,heart:`heart`},op={keyword:`var(--syntax-keyword)`,error:`var(--status-error)`,string:`var(--syntax-string)`,function:`var(--syntax-function)`,type:`var(--syntax-type)`},sp=()=>{let e=(0,Sa.c)(116),{t}=Ge(),{profiles:n,globalIdentity:r,defaultGitIdentityId:i,deleteProfile:a,loadProfiles:o,loadGlobalIdentity:s,loadDiscoveredCredentials:c,loadDefaultGitIdentityId:l,setDefaultGitIdentityId:u,getUnimportedCredentials:d}=ji(ne(up)),[f,p]=Q.useState(!1),[m,h]=Q.useState(null),[g,_]=Q.useState(null),[v,y]=Q.useState(null),[b,x]=Q.useState(!1),S,C;e[0]!==l||e[1]!==c||e[2]!==s||e[3]!==o?(S=()=>{o(),s(),c(),l()},C=[o,s,c,l],e[0]=l,e[1]=c,e[2]=s,e[3]=o,e[4]=S,e[5]=C):(S=e[4],C=e[5]),Q.useEffect(S,C);let w,T,E,D,O,k,A,j,M,N,P,F,I,L;if(e[6]!==i||e[7]!==v||e[8]!==a||e[9]!==d||e[10]!==r||e[11]!==n||e[12]!==u||e[13]!==t){let o=d(),s;e[28]===Symbol.for(`react.memo_cache_sentinel`)?(s=(e,t)=>{h(e),_(t??null),p(!0)},e[28]=s):s=e[28];let c=s,l;e[29]!==i||e[30]!==u||e[31]!==t?(l=async e=>{let n=i===e?null:e;if(!await u(n)){J.error(t(`settings.gitIdentities.page.toast.updateDefaultFailed`));return}J.success(t(n?`settings.gitIdentities.page.toast.defaultUpdated`:`settings.gitIdentities.page.toast.defaultUnset`))},e[29]=i,e[30]=u,e[31]=t,e[32]=l):l=e[32];let f=l,m;e[33]!==v||e[34]!==a||e[35]!==t?(m=async()=>{v&&(x(!0),await a(v.id)?(J.success(t(`settings.gitIdentities.page.toast.profileDeleted`,{name:v.name})),y(null)):J.error(t(`settings.gitIdentities.page.toast.deleteProfileFailed`)),x(!1))},e[33]=v,e[34]=a,e[35]=t,e[36]=m):m=e[36],E=m,T=Ur,O=`h-full`,k=`w-full bg-background`,L=`yuri-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,e[37]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,$.jsx)(tp,{itemId:`git.github-account`}),e[37]=D):D=e[37],w=Z,A=`git.identities`;let g;e[38]===t?g=e[39]:(g=t(`settings.gitIdentities.page.section.title`),e[38]=t,e[39]=g);let b;e[40]===g?b=e[41]:(b=(0,$.jsx)(`span`,{children:g}),e[40]=g,e[41]=b);let S,C;e[42]===Symbol.for(`react.memo_cache_sentinel`)?(S=()=>c(`new`),C=(0,$.jsx)(X,{name:`add`,className:`mr-1 size-3.5`}),e[42]=S,e[43]=C):(S=e[42],C=e[43]);let R;e[44]===t?R=e[45]:(R=t(`settings.common.badge.new`),e[44]=t,e[45]=R);let z;e[46]===R?z=e[47]:(z=(0,$.jsxs)(q,{size:`sm`,variant:`ghost`,onClick:S,children:[C,` `,R]}),e[46]=R,e[47]=z),e[48]!==b||e[49]!==z?(j=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[b,z]}),e[48]=b,e[49]=z,e[50]=j):j=e[50],M=`flex flex-col`,N=r&&(0,$.jsx)(cp,{profile:r,isDefault:i===`global`,onEdit:()=>c(`global`),onToggleDefault:()=>f(`global`),isReadOnly:!0,hasBorder:n.length>0||o.length>0}),P=n.map((e,t)=>(0,$.jsx)(cp,{profile:e,isDefault:i===e.id,onEdit:()=>c(e.id),onToggleDefault:()=>f(e.id),onDelete:()=>y(e),hasBorder:t<n.length-1||o.length>0},e.id)),F=!r&&n.length===0&&o.length===0&&(0,$.jsxs)(`div`,{className:`py-8 px-4 text-center text-muted-foreground`,children:[(0,$.jsx)(X,{name:`shield-keyhole`,className:`mx-auto mb-2 h-8 w-8 opacity-40`}),(0,$.jsx)(`p`,{className:`typography-ui-label`,children:t(`settings.gitIdentities.page.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:t(`settings.gitIdentities.page.empty.description`)})]}),I=o.length>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`px-4 py-2 border-t border-[var(--surface-subtle)]`,children:(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:t(`settings.gitIdentities.page.discoveredCredentials.title`)})}),o.map((e,t)=>(0,$.jsx)(lp,{credential:e,onImport:()=>c(`new`,{host:e.host,username:e.username}),hasBorder:t<o.length-1},`${e.host}-${e.username}`))]}),e[6]=i,e[7]=v,e[8]=a,e[9]=d,e[10]=r,e[11]=n,e[12]=u,e[13]=t,e[14]=w,e[15]=T,e[16]=E,e[17]=D,e[18]=O,e[19]=k,e[20]=A,e[21]=j,e[22]=M,e[23]=N,e[24]=P,e[25]=F,e[26]=I,e[27]=L}else w=e[14],T=e[15],E=e[16],D=e[17],O=e[18],k=e[19],A=e[20],j=e[21],M=e[22],N=e[23],P=e[24],F=e[25],I=e[26],L=e[27];let R;e[51]!==w||e[52]!==A||e[53]!==j||e[54]!==M||e[55]!==N||e[56]!==P||e[57]!==F||e[58]!==I?(R=(0,$.jsxs)(w,{itemId:A,label:j,cardClassName:M,children:[N,P,F,I]}),e[51]=w,e[52]=A,e[53]=j,e[54]=M,e[55]=N,e[56]=P,e[57]=F,e[58]=I,e[59]=R):R=e[59];let z;e[60]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(ep,{}),e[60]=z):z=e[60];let B;e[61]!==D||e[62]!==R||e[63]!==L?(B=(0,$.jsxs)(`div`,{className:L,children:[D,R,z]}),e[61]=D,e[62]=R,e[63]=L,e[64]=B):B=e[64];let V;e[65]!==T||e[66]!==O||e[67]!==k||e[68]!==B?(V=(0,$.jsx)(T,{outerClassName:O,className:k,children:B}),e[65]=T,e[66]=O,e[67]=k,e[68]=B,e[69]=V):V=e[69];let H;e[70]!==g||e[71]!==f||e[72]!==m?(H=(0,$.jsx)(ip,{open:f,onOpenChange:p,profileId:m,importData:g}),e[70]=g,e[71]=f,e[72]=m,e[73]=H):H=e[73];let U=v!==null,W;e[74]===b?W=e[75]:(W=e=>{b||e||y(null)},e[74]=b,e[75]=W);let ee;e[76]===t?ee=e[77]:(ee=t(`settings.gitIdentities.page.deleteDialog.title`),e[76]=t,e[77]=ee);let te;e[78]===ee?te=e[79]:(te=(0,$.jsx)(mn,{children:ee}),e[78]=ee,e[79]=te);let re=v?.name??``,ie;e[80]!==t||e[81]!==re?(ie=t(`settings.gitIdentities.page.deleteDialog.description`,{name:re}),e[80]=t,e[81]=re,e[82]=ie):ie=e[82];let ae;e[83]===ie?ae=e[84]:(ae=(0,$.jsx)(hn,{children:ie}),e[83]=ie,e[84]=ae);let oe;e[85]!==te||e[86]!==ae?(oe=(0,$.jsxs)(dn,{children:[te,ae]}),e[85]=te,e[86]=ae,e[87]=oe):oe=e[87];let se;e[88]===Symbol.for(`react.memo_cache_sentinel`)?(se=()=>y(null),e[88]=se):se=e[88];let ce;e[89]===t?ce=e[90]:(ce=t(`settings.common.actions.cancel`),e[89]=t,e[90]=ce);let le;e[91]!==b||e[92]!==ce?(le=(0,$.jsx)(q,{variant:`ghost`,onClick:se,disabled:b,children:ce}),e[91]=b,e[92]=ce,e[93]=le):le=e[93];let ue;e[94]===E?ue=e[95]:(ue=()=>void E(),e[94]=E,e[95]=ue);let de;e[96]===t?de=e[97]:(de=t(`settings.common.actions.delete`),e[96]=t,e[97]=de);let G;e[98]!==b||e[99]!==ue||e[100]!==de?(G=(0,$.jsx)(q,{size:`sm`,variant:`destructive`,onClick:ue,disabled:b,children:de}),e[98]=b,e[99]=ue,e[100]=de,e[101]=G):G=e[101];let fe;e[102]!==le||e[103]!==G?(fe=(0,$.jsxs)(fn,{children:[le,G]}),e[102]=le,e[103]=G,e[104]=fe):fe=e[104];let pe;e[105]!==oe||e[106]!==fe?(pe=(0,$.jsxs)(pn,{className:`max-w-md`,children:[oe,fe]}),e[105]=oe,e[106]=fe,e[107]=pe):pe=e[107];let me;e[108]!==U||e[109]!==W||e[110]!==pe?(me=(0,$.jsx)(gn,{open:U,onOpenChange:W,children:pe}),e[108]=U,e[109]=W,e[110]=pe,e[111]=me):me=e[111];let he;return e[112]!==V||e[113]!==H||e[114]!==me?(he=(0,$.jsxs)($.Fragment,{children:[V,H,me]}),e[112]=V,e[113]=H,e[114]=me,e[115]=he):he=e[115],he},cp=e=>{let t=(0,Sa.c)(56),{profile:n,isDefault:r,onEdit:i,onToggleDefault:a,onDelete:o,isReadOnly:s,hasBorder:c}=e,{t:l}=Ge(),[u,d]=Q.useState(!1),f=ap[n.icon||`branch`]||`git-branch`,p=op[n.color||``],m=n.authType||`ssh`,h;t[0]===i?h=t[1]:(h=e=>{e.currentTarget===e.target&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),i())},t[0]=i,t[1]=h);let g=h,_;t[2]!==r||t[3]!==s||t[4]!==o||t[5]!==a||t[6]!==l?(_=e=>(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(e,{onClick:e=>{e.stopPropagation(),a()},children:l(r?`settings.gitIdentities.page.actions.unsetDefault`:`settings.gitIdentities.page.actions.setAsDefault`)}),!s&&o&&(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),o()},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(X,{name:`delete-bin`,className:`h-4 w-4 mr-px`}),l(`settings.common.actions.delete`)]})]}),t[2]=r,t[3]=s,t[4]=o,t[5]=a,t[6]=l,t[7]=_):_=t[7];let v=_,y=c&&`border-b border-[var(--surface-subtle)]`,b;t[8]===y?b=t[9]:(b=K(`group flex items-center justify-between gap-3 px-4 py-2.5 transition-colors hover:bg-[var(--interactive-hover)]/30 cursor-pointer`,y),t[8]=y,t[9]=b);let x;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(x=e=>{e.preventDefault(),d(!0)},t[10]=x):x=t[10];let S;t[11]!==g||t[12]!==i||t[13]!==b?(S=(0,$.jsx)(`div`,{className:b,onClick:i,role:`button`,tabIndex:0,onKeyDown:g,onContextMenu:x}),t[11]=g,t[12]=i,t[13]=b,t[14]=S):S=t[14];let C;t[15]===p?C=t[16]:(C={color:p},t[15]=p,t[16]=C);let w;t[17]!==f||t[18]!==C?(w=(0,$.jsx)(X,{name:f,className:`w-4 h-4 shrink-0`,style:C}),t[17]=f,t[18]=C,t[19]=w):w=t[19];let T;t[20]===n.name?T=t[21]:(T=(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:n.name}),t[20]=n.name,t[21]=T);let E;t[22]===m?E=t[23]:(E=(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-muted px-1 rounded flex-shrink-0 leading-none pb-px border border-border/50`,children:m}),t[22]=m,t[23]=E);let D;t[24]!==r||t[25]!==l?(D=r&&(0,$.jsx)(`span`,{className:`typography-micro text-primary bg-primary/12 px-1 rounded flex-shrink-0 leading-none pb-px border border-primary/25`,children:l(`settings.gitIdentities.page.badge.default`)}),t[24]=r,t[25]=l,t[26]=D):D=t[26];let O;t[27]!==s||t[28]!==l?(O=s&&(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-muted px-1 rounded flex-shrink-0 leading-none pb-px border border-border/50`,children:l(`settings.agents.sidebar.badge.system`)}),t[27]=s,t[28]=l,t[29]=O):O=t[29];let k;t[30]!==E||t[31]!==D||t[32]!==O||t[33]!==T?(k=(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[T,E,D,O]}),t[30]=E,t[31]=D,t[32]=O,t[33]=T,t[34]=k):k=t[34];let A=m===`token`&&n.host?n.host:n.userEmail,j;t[35]===A?j=t[36]:(j=(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/60 truncate leading-tight`,children:A}),t[35]=A,t[36]=j);let M;t[37]!==k||t[38]!==j?(M=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[k,j]}),t[37]=k,t[38]=j,t[39]=M):M=t[39];let N;t[40]!==M||t[41]!==w?(N=(0,$.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[w,M]}),t[40]=M,t[41]=w,t[42]=N):N=t[42];let P;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,$.jsx)(fr,{asChild:!0,children:(0,$.jsx)(q,{size:`icon`,variant:`ghost`,className:`h-6 w-6 shrink-0 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100`,onClick:dp,children:(0,$.jsx)(X,{name:`more-2`,className:`h-3.5 w-3.5`})})}),t[43]=P):P=t[43];let F;t[44]===v?F=t[45]:(F=(0,$.jsxs)($n,{children:[P,(0,$.jsx)(Zn,{align:`end`,className:`w-fit min-w-28`,children:v(tr)})]}),t[44]=v,t[45]=F);let I;t[46]!==N||t[47]!==F||t[48]!==S?(I=(0,$.jsxs)(na,{render:S,children:[N,F]}),t[46]=N,t[47]=F,t[48]=S,t[49]=I):I=t[49];let L;t[50]===v?L=t[51]:(L=(0,$.jsx)(ra,{className:`w-fit min-w-28`,children:v(ia)}),t[50]=v,t[51]=L);let R;return t[52]!==u||t[53]!==I||t[54]!==L?(R=(0,$.jsxs)(aa,{open:u,onOpenChange:d,children:[I,L]}),t[52]=u,t[53]=I,t[54]=L,t[55]=R):R=t[55],R},lp=e=>{let t=(0,Sa.c)(21),{credential:n,onImport:r,hasBorder:i}=e,{t:a}=Ge(),o;t[0]===n.host?o=t[1]:(o=n.host.split(`/`),t[0]=n.host,t[1]=o);let s=o,c=s.length>=3?s[s.length-1]:n.host,l=n.host.includes(`/`),u=i&&`border-b border-[var(--surface-subtle)]`,d;t[2]===u?d=t[3]:(d=K(`flex items-center justify-between gap-3 px-4 py-2.5 transition-colors hover:bg-[var(--interactive-hover)]/30`,u),t[2]=u,t[3]=d);let f;t[4]===c?f=t[5]:(f=(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground truncate block`,children:c}),t[4]=c,t[5]=f);let p=l?n.host:n.username,m;t[6]===p?m=t[7]:(m=(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/60 truncate block leading-tight`,children:p}),t[6]=p,t[7]=m);let h;t[8]!==f||t[9]!==m?(h=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[f,m]}),t[8]=f,t[9]=m,t[10]=h):h=t[10];let g;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(X,{name:`download`,className:`h-3 w-3`}),t[11]=g):g=t[11];let _;t[12]===a?_=t[13]:(_=a(`settings.gitIdentities.page.actions.import`),t[12]=a,t[13]=_);let v;t[14]!==r||t[15]!==_?(v=(0,$.jsxs)(q,{size:`sm`,variant:`ghost`,onClick:r,className:`gap-1 shrink-0`,children:[g,_]}),t[14]=r,t[15]=_,t[16]=v):v=t[16];let y;return t[17]!==v||t[18]!==d||t[19]!==h?(y=(0,$.jsxs)(`div`,{className:d,children:[h,v]}),t[17]=v,t[18]=d,t[19]=h,t[20]=y):y=t[20],y};function up(e){return{profiles:e.profiles,globalIdentity:e.globalIdentity,defaultGitIdentityId:e.defaultGitIdentityId,deleteProfile:e.deleteProfile,loadProfiles:e.loadProfiles,loadGlobalIdentity:e.loadGlobalIdentity,loadDiscoveredCredentials:e.loadDiscoveredCredentials,loadDefaultGitIdentityId:e.loadDefaultGitIdentityId,setDefaultGitIdentityId:e.setDefaultGitIdentityId,getUnimportedCredentials:e.getUnimportedCredentials}}function dp(e){return e.stopPropagation()}function fp(){let e=(0,Sa.c)(32),{t}=Ge(),{settings:n}=ke(),r=Mt(),i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=o(),e[0]=i):i=e[0];let a=i,s;e[1]===n?s=e[2]:(s={mutationFn:async e=>{let t=o();if(await n.save({questionAutoDelegateEnabled:e}),t!==o())throw Error(`Runtime changed`);await lt()}},e[1]=n,e[2]=s);let c=Te(s,Oe),l=c.reset,u,d;e[3]===l?(u=e[4],d=e[5]):(u=()=>{l()},d=[a,l],e[3]=l,e[4]=u,e[5]=d),(0,Q.useEffect)(u,d);let f;e[6]===t?f=e[7]:(f=t(`settings.chat.questionDelegate.label`),e[6]=t,e[7]=f);let p;e[8]===t?p=e[9]:(p=t(`settings.chat.questionDelegate.label`),e[8]=t,e[9]=p);let m;e[10]===t?m=e[11]:(m=t(`settings.chat.questionDelegate.description`),e[10]=t,e[11]=m);let h=r.data?.snapshot.enabled??!0,g=c.isPending||!r.data||r.isError,_;e[12]===c?_=e[13]:(_=e=>c.mutate(e),e[12]=c,e[13]=_);let v;e[14]!==f||e[15]!==p||e[16]!==m||e[17]!==h||e[18]!==g||e[19]!==_?(v=(0,$.jsx)(Ji,{itemId:`chat.question-auto-delegate`,label:f,ariaLabel:p,description:m,checked:h,disabled:g,onChange:_}),e[14]=f,e[15]=p,e[16]=m,e[17]=h,e[18]=g,e[19]=_,e[20]=v):v=e[20];let y;e[21]!==c.isPending||e[22]!==t?(y=c.isPending?(0,$.jsx)(`div`,{className:`yuri-settings-group-row typography-meta text-muted-foreground`,role:`status`,children:t(`settings.common.actions.saving`)}):null,e[21]=c.isPending,e[22]=t,e[23]=y):y=e[23];let b;e[24]!==r||e[25]!==c||e[26]!==t?(b=r.isError||c.isError?(0,$.jsxs)(`div`,{className:`yuri-settings-group-row flex flex-wrap items-center gap-2`,role:`alert`,children:[(0,$.jsx)(`span`,{className:`typography-meta text-[var(--status-error)]`,children:t(c.isError?`settings.chat.questionDelegate.saveFailed`:`chat.questionDelegate.loadFailed`)}),(0,$.jsx)(q,{variant:`ghost`,size:`xs`,disabled:c.isPending,onClick:()=>c.isError?c.mutate(c.variables??!0):void r.refetch(),children:t(`chat.questionDelegate.retry`)})]}):null,e[24]=r,e[25]=c,e[26]=t,e[27]=b):b=e[27];let x;return e[28]!==v||e[29]!==y||e[30]!==b?(x=(0,$.jsxs)($.Fragment,{children:[v,y,b]}),e[28]=v,e[29]=y,e[30]=b,e[31]=x):x=e[31],x}var pp=e=>{let t=(0,Sa.c)(12),{isMobile:n,itemId:r,label:i,description:a,descriptionPlacement:o,children:s,className:c,copyClassName:l,controlClassName:u}=e,d=n&&`yuri-mobile-settings-detail-group`,f;t[0]===d?f=t[1]:(f=K(`yuri-settings-detail-group`,d),t[0]=d,t[1]=f);let p;return t[2]!==s||t[3]!==c||t[4]!==u||t[5]!==l||t[6]!==a||t[7]!==o||t[8]!==r||t[9]!==i||t[10]!==f?(p=(0,$.jsx)(Ui,{itemId:r,label:i,description:a,descriptionPlacement:o,groupClassName:f,className:c,copyClassName:l,controlClassName:u,children:s}),t[2]=s,t[3]=c,t[4]=u,t[5]=l,t[6]=a,t[7]=o,t[8]=r,t[9]=i,t[10]=f,t[11]=p):p=t[11],p},mp=e=>{let t=(0,Sa.c)(9),{isMobile:n,label:r,children:i,description:a,className:o,cardClassName:s}=e,c=n&&`yuri-mobile-settings-detail-group`,l;t[0]!==o||t[1]!==c?(l=K(`yuri-settings-detail-group`,c,o),t[0]=o,t[1]=c,t[2]=l):l=t[2];let u;return t[3]!==s||t[4]!==i||t[5]!==a||t[6]!==r||t[7]!==l?(u=(0,$.jsx)(Z,{label:r,description:a,className:l,cardClassName:s,children:i}),t[3]=s,t[4]=i,t[5]=a,t[6]=r,t[7]=l,t[8]=u):u=t[8],u},hp=e=>{let t=(0,Sa.c)(8),{isMobile:n,itemId:r,label:i,mobileLabel:a,description:o,children:s,className:c,copyClassName:l,controlClassName:u}=e,d=n&&a!==void 0?a:i,f;return t[0]!==s||t[1]!==c||t[2]!==u||t[3]!==l||t[4]!==o||t[5]!==r||t[6]!==d?(f=(0,$.jsx)(Xi,{itemId:r,label:d,description:o,className:c,copyClassName:l,controlClassName:u,children:s}),t[0]=s,t[1]=c,t[2]=u,t[3]=l,t[4]=o,t[5]=r,t[6]=d,t[7]=f):f=t[7],f},gp=e=>{let t=(0,Sa.c)(17),{selected:n,onSelect:r,label:i,ariaLabel:a}=e,o;t[0]===r?o=t[1]:(o=e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),r())},t[0]=r,t[1]=o);let s;t[2]!==a||t[3]!==r||t[4]!==n?(s=(0,$.jsx)(pa,{checked:n,onChange:r,ariaLabel:a}),t[2]=a,t[3]=r,t[4]=n,t[5]=s):s=t[5];let c=n?`text-foreground`:`text-foreground/50`,l;t[6]===c?l=t[7]:(l=K(`typography-ui-label font-normal`,c),t[6]=c,t[7]=l);let u;t[8]!==i||t[9]!==l?(u=(0,$.jsx)(`span`,{className:l,children:i}),t[8]=i,t[9]=l,t[10]=u):u=t[10];let d;return t[11]!==r||t[12]!==n||t[13]!==o||t[14]!==s||t[15]!==u?(d=(0,$.jsxs)(`div`,{className:`yuri-settings-group-row group flex cursor-pointer items-center gap-2 text-left`,role:`button`,tabIndex:0,"aria-pressed":n,onClick:r,onKeyDown:o,children:[s,u]}),t[11]=r,t[12]=n,t[13]=o,t[14]=s,t[15]=u,t[16]=d):d=t[16],d},_p=[{value:`system`,labelKey:`settings.yuri.visual.option.themeMode.system`},{value:`light`,labelKey:`settings.yuri.visual.option.themeMode.light`},{value:`dark`,labelKey:`settings.yuri.visual.option.themeMode.dark`}],vp=[{id:`dynamic`,labelKey:`settings.yuri.visual.option.diffLayout.auto.label`,descriptionKey:`settings.yuri.visual.option.diffLayout.auto.description`},{id:`inline`,labelKey:`settings.yuri.visual.option.diffLayout.inline.label`,descriptionKey:`settings.yuri.visual.option.diffLayout.inline.description`},{id:`side-by-side`,labelKey:`settings.yuri.visual.option.diffLayout.sideBySide.label`,descriptionKey:`settings.yuri.visual.option.diffLayout.sideBySide.description`}],yp=`Yuri - AI Coding Assistant`,bp=[{id:`system`,labelKey:`settings.yuri.visual.option.pwaOrientation.system.label`,descriptionKey:`settings.yuri.visual.option.pwaOrientation.system.description`},{id:`portrait`,labelKey:`settings.yuri.visual.option.pwaOrientation.portrait.label`,descriptionKey:`settings.yuri.visual.option.pwaOrientation.portrait.description`},{id:`landscape`,labelKey:`settings.yuri.visual.option.pwaOrientation.landscape.label`,descriptionKey:`settings.yuri.visual.option.pwaOrientation.landscape.description`}],xp=[{id:`native`,labelKey:`settings.yuri.visual.option.mobileKeyboardMode.native.label`,descriptionKey:`settings.yuri.visual.option.mobileKeyboardMode.native.description`},{id:`resize-content`,labelKey:`settings.yuri.visual.option.mobileKeyboardMode.resizeContent.label`,descriptionKey:`settings.yuri.visual.option.mobileKeyboardMode.resizeContent.description`}],Sp=[{id:`steer`,labelKey:`settings.yuri.visual.option.followUpBehavior.steer.label`},{id:`queue`,labelKey:`settings.yuri.visual.option.followUpBehavior.queue.label`}],Cp=e=>e===`portrait`||e===`landscape`?e:`system`,wp=[{id:`sorted`,labelKey:`settings.yuri.visual.option.chatRenderMode.sorted.label`,descriptionKey:`settings.yuri.visual.option.chatRenderMode.sorted.description`},{id:`live`,labelKey:`settings.yuri.visual.option.chatRenderMode.live.label`,descriptionKey:`settings.yuri.visual.option.chatRenderMode.live.description`}],Tp=[{id:`auto`,labelKey:`settings.yuri.visual.option.messageTransport.auto.label`,descriptionKey:`settings.yuri.visual.option.messageTransport.auto.description`},{id:`ws`,labelKey:`settings.yuri.visual.option.messageTransport.ws.label`,descriptionKey:`settings.yuri.visual.option.messageTransport.ws.description`},{id:`sse`,labelKey:`settings.yuri.visual.option.messageTransport.sse.label`,descriptionKey:`settings.yuri.visual.option.messageTransport.sse.description`}],Ep=[{id:`auto`,labelKey:`settings.yuri.visual.option.timeFormat.auto.label`,descriptionKey:`settings.yuri.visual.option.timeFormat.auto.description`},{id:`24h`,labelKey:`settings.yuri.visual.option.timeFormat.24h.label`,descriptionKey:`settings.yuri.visual.option.timeFormat.24h.description`},{id:`12h`,labelKey:`settings.yuri.visual.option.timeFormat.12h.label`,descriptionKey:`settings.yuri.visual.option.timeFormat.12h.description`}],Dp=[{id:`auto`,labelKey:`settings.yuri.visual.option.weekStart.auto.label`,descriptionKey:`settings.yuri.visual.option.weekStart.auto.description`},{id:`monday`,labelKey:`settings.yuri.visual.option.weekStart.monday.label`},{id:`sunday`,labelKey:`settings.yuri.visual.option.weekStart.sunday.label`}],Op=({visibleSettings:e,mobile:t})=>{let{locale:n,locales:r,setLocale:i,label:a,t:o}=Ge(),s=Q.useCallback(e=>o(e),[o]),{isMobile:c}=wr(),u=t??c,{browserTab:f}=Ei(),p=G(e=>e.showReasoningTraces),m=G(e=>e.sessionTitleRefreshEnabled),_=G(e=>e.setSessionTitleRefreshEnabled),v=G(e=>e.sessionGoalEnabled),y=G(e=>e.setSessionGoalEnabled),b=G(e=>e.setShowReasoningTraces),x=G(e=>e.collapsibleThinkingBlocks),S=G(e=>e.setCollapsibleThinkingBlocks),C=G(e=>e.collapsibleUserMessages),w=G(e=>e.setCollapsibleUserMessages),T=Ir(e=>e.enabled),E=Ir(e=>e.setEnabled),D=G(e=>e.chatRenderMode),O=G(e=>e.setChatRenderMode),A=G(e=>e.fontSize),j=G(e=>e.setFontSize),M=G(e=>e.codeFontSize),N=G(e=>e.setCodeFontSize),P=G(e=>e.terminalFontSize),F=G(e=>e.setTerminalFontSize),I=G(e=>e.editorFontSize),L=G(e=>e.setEditorFontSize),R=G(e=>e.uiFont),z=G(e=>e.setUiFont),B=G(e=>e.monoFont),V=G(e=>e.setMonoFont),H=G(e=>e.padding),U=G(e=>e.setPadding),W=G(e=>e.inputBarOffset),ee=G(e=>e.setInputBarOffset),te=G(e=>e.mobileKeyboardMode),ne=G(e=>e.setMobileKeyboardMode),re=G(e=>e.diffLayoutPreference),ie=G(e=>e.setDiffLayoutPreference),ae=G(e=>e.showTerminalQuickKeysOnDesktop),oe=G(e=>e.setShowTerminalQuickKeysOnDesktop),se=G(e=>e.fileEditorKeymap),ce=G(e=>e.setFileEditorKeymap),pe=xe(e=>e.followUpBehavior),me=xe(e=>e.setFollowUpBehavior),he=G(e=>e.persistChatDraft),ge=G(e=>e.setPersistChatDraft),_e=G(e=>e.inputSpellcheckEnabled),ve=G(e=>e.setInputSpellcheckEnabled),be=G(e=>e.showSubagentTaskDetails),Se=G(e=>e.setShowSubagentTaskDetails),Ce=G(e=>e.timeFormatPreference),we=G(e=>e.setTimeFormatPreference),Te=G(e=>e.weekStartPreference),Ee=G(e=>e.setWeekStartPreference),De=G(e=>e.showSplitAssistantMessageActions),Oe=G(e=>e.setShowSplitAssistantMessageActions),ke=G(e=>e.showAssistantTps),Ae=G(e=>e.setShowAssistantTps),je=Ci(e=>e.sidebarBrandName),Me=Ci(e=>e.setSidebarBrandName),Ne=G(e=>e.allowPromptingSubagentSessions),Pe=G(e=>e.setAllowPromptingSubagentSessions),Fe=pt(e=>e.settingsMessageStreamTransport),Ie=pt(e=>e.setSettingsMessageStreamTransport),Le=Fe,Re=G(e=>e.isSettingsDialogOpen),{themeMode:ze,setThemeMode:Be,availableThemes:Ve,customThemesLoading:He,reloadCustomThemes:Ue,lightThemeId:We,darkThemeId:Ke,setLightThemePreference:qe,setDarkThemePreference:Je}=un(),[Ye,Xe]=Q.useState(!1),[Ze,Qe]=Q.useState(!1),[$e,et]=Q.useState(!1),tt=Q.useMemo(()=>h()&&typeof window<`u`&&window.__YURI_ELECTRON__?.macVibrancySupported===!0,[]),nt=typeof window<`u`&&window.__YURI_ELECTRON__?.macVibrancy===!0,[rt,it]=Q.useState(nt),[at,ot]=Q.useState(null),[st,ct]=Q.useState(!1),lt=async()=>{if(!(at===null||st)){ct(!0);try{let e=await k(`desktop_set_vibrancy`,{enabled:at});if(!e||e.enabled!==at||!e.requiresRestart)throw Error(`Window transparency restart was not accepted`);it(e.enabled),ot(null)}catch{ct(!1),J.error(o(`settings.yuri.visual.vibrancy.failed`))}}},ut=Q.useMemo(()=>h()&&typeof window<`u`&&window.__YURI_PLATFORM__===`darwin`,[]),dt=G(e=>e.dockBadgeEnabled),ft=G(e=>e.setDockBadgeEnabled),[mt,ht]=Q.useState(0),gt=G(e=>e.reportUsage),_t=G(e=>e.setReportUsage),vt=Q.useCallback(e=>{_t(e),ye({reportUsage:e})},[_t]),yt=Re&&(!e||e.includes(`chatRenderMode`));Q.useEffect(()=>{if(!yt)return;let e=null,t=Date.now(),n=()=>{let r=Date.now();r-t>=420&&(ht(e=>(e+1)%24),t=r),e=requestAnimationFrame(n)};(typeof document>`u`||document.visibilityState===`visible`)&&(e=requestAnimationFrame(n));let r=()=>{document.visibilityState===`visible`&&e===null?e=requestAnimationFrame(n):document.visibilityState!==`visible`&&e!==null&&(cancelAnimationFrame(e),e=null)};return document.addEventListener(`visibilitychange`,r),()=>{document.removeEventListener(`visibilitychange`,r),e!==null&&cancelAnimationFrame(e)}},[yt]);let bt=Q.useCallback(e=>{w(e),ye({collapsibleUserMessages:e})},[w]),xt=Q.useCallback(e=>{Oe(e),ye({showSplitAssistantMessageActions:e})},[Oe]),St=Q.useCallback(e=>{Ae(e),ye({showAssistantTps:e})},[Ae]),Ct=Q.useCallback(e=>{ve(e),ye({inputSpellcheckEnabled:e})},[ve]),wt=Q.useCallback(e=>{O(e),ye({chatRenderMode:e})},[O]),Tt=Q.useCallback(e=>{Ie(e),ye({messageStreamTransport:e})},[Ie]),Et=Q.useCallback(e=>{Se(e),ye({showSubagentTaskDetails:e})},[Se]),Ot=Q.useCallback(e=>{we(e),ye({timeFormatPreference:e})},[we]),kt=Q.useCallback(e=>{Ee(e),ye({weekStartPreference:e})},[Ee]),At=Q.useMemo(()=>Ve.filter(e=>e.metadata.variant===`light`).sort((e,t)=>e.metadata.name.localeCompare(t.metadata.name)),[Ve]),jt=Q.useMemo(()=>Ve.filter(e=>e.metadata.variant===`dark`).sort((e,t)=>e.metadata.name.localeCompare(t.metadata.name)),[Ve]),Mt=Q.useMemo(()=>At.find(e=>e.metadata.id===We)??At[0],[At,We]),Nt=Q.useMemo(()=>jt.find(e=>e.metadata.id===Ke)??jt[0],[jt,Ke]),Pt=Q.useCallback((e,t)=>{let n=t===`dark`?` Dark`:` Light`;return e.endsWith(n)?e.slice(0,-n.length):e},[]),Y=t=>t===`splitAssistantMessageActions`?!1:!e||e.includes(t),Ft=async()=>{if(!$e){et(!0);try{await Dt(),Qe(!1),J.success(o(`settings.yuri.visual.transcriptCache.toast.cleared`))}catch{J.error(o(`settings.yuri.visual.transcriptCache.toast.failed`))}finally{et(!1)}}},It=g(),Lt=Lr()&&Y(`iosNativeUi`),Rt=Y(`theme`)&&!It,zt=Y(`theme`)||Y(`timeFormat`)||Y(`weekStart`),Bt=It?zt||Y(`sidebarBrand`):Y(`theme`)||Y(`sidebarBrand`)||Y(`pwaInstallName`)||Y(`pwaOrientation`)||Y(`mobileKeyboardMode`)||Y(`timeFormat`)||Y(`weekStart`)||Lt,Vt=Y(`fontSize`)||Y(`codeFontSize`)||Y(`terminalFontSize`)||Y(`editorFontSize`)||Y(`spacing`)||Y(`inputBarOffset`),Ht=Y(`terminalQuickKeys`)&&!u||Y(`fileEditorKeymap`),Ut=Y(`questionAutoDelegate`)||Y(`chatRenderMode`)||Y(`messageTransport`)||Y(`collapsibleUserMessages`)||Y(`splitAssistantMessageActions`)||Y(`showAssistantTps`)||Y(`subagentReadOnlyBanner`)||Y(`diffLayout`)||Y(`reasoning`)||Y(`followUpBehavior`)||Y(`persistDraft`)||Y(`showSubagentTaskDetails`)||!u&&Y(`inputSpellcheck`),Wt=Y(`pwaInstallName`)&&d()&&f&&!h()&&!It,Gt=Y(`pwaOrientation`)&&d()&&!h()&&!It,Kt=Y(`mobileKeyboardMode`)&&d()&&!h()&&!It&&fe(),[qt,Jt]=Q.useState(``),[Yt,Xt]=Q.useState(`system`),Zt=Q.useMemo(()=>{let e=Ep.find(e=>e.id===Ce);return s(e?.labelKey??`settings.yuri.visual.option.timeFormat.auto.label`)},[Ce,s]),Qt=Q.useMemo(()=>{let e=Dp.find(e=>e.id===Te);return s(e?.labelKey??`settings.yuri.visual.option.weekStart.auto.label`)},[Te,s]),$t=Q.useMemo(()=>{let e=bp.find(e=>e.id===Yt);return e?s(e.labelKey):void 0},[Yt,s]),en=Q.useMemo(()=>{let e=xp.find(e=>e.id===te);return e?s(e.labelKey):void 0},[te,s]),tn=Q.useCallback(async e=>{if(typeof window>`u`)return;let t=window,n=e.trim().replace(/\s+/g,` `).slice(0,64);if(await ye({pwaAppName:n}),typeof t.__YURI_SET_PWA_INSTALL_NAME__==`function`){let e=t.__YURI_SET_PWA_INSTALL_NAME__(n);Jt(e);return}Jt(n||yp),t.__YURI_UPDATE_PWA_MANIFEST__?.()},[]),nn=Q.useCallback(async e=>{if(typeof window>`u`)return;let t=window,n=Cp(e);if(await ye({pwaOrientation:n}),typeof t.__YURI_SET_PWA_ORIENTATION__==`function`){let e=t.__YURI_SET_PWA_ORIENTATION__(n);Xt(e);return}Xt(n),t.__YURI_UPDATE_PWA_MANIFEST__?.()},[]);return Q.useEffect(()=>{if(typeof window>`u`||!Wt&&!Gt&&!Kt)return;let e=!1;return(async()=>{try{let t=await l(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`},cache:`no-store`});if(!t.ok){e||Jt(yp);return}let n=await t.json().catch(()=>({})),r=(typeof n?.pwaAppName==`string`?n.pwaAppName:``).trim().replace(/\s+/g,` `).slice(0,64),i=Cp(n?.pwaOrientation),a=le(n?.mobileKeyboardMode);e||(Wt&&Jt(r||yp),Gt&&Xt(i),Kt&&ne(a))}catch{e||(Wt&&Jt(yp),Gt&&Xt(`system`),Kt&&ne(`native`))}})(),()=>{e=!0}},[ne,Kt,Wt,Gt]),(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`yuri-settings-section-stack`,children:[Bt&&(0,$.jsxs)($.Fragment,{children:[Rt&&(0,$.jsxs)(mp,{isMobile:u,label:(0,$.jsxs)(`div`,{className:`flex w-full min-w-0 items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{children:o(`settings.yuri.visual.section.colorMode`)}),(0,$.jsxs)(`div`,{className:`inline-flex shrink-0 items-center gap-1`,children:[(0,$.jsx)(`button`,{type:`button`,"data-settings-item":`appearance.reload-themes`,disabled:He||Ye,onClick:()=>{let e=Date.now();Xe(!0),Ue().finally(()=>{let t=Date.now()-e;if(t<500){window.setTimeout(()=>{Xe(!1)},500-t);return}Xe(!1)})},className:`inline-flex items-center typography-micro font-normal text-muted-foreground underline decoration-[1px] underline-offset-2 hover:text-foreground disabled:cursor-not-allowed disabled:text-muted-foreground/60`,children:o(Ye?`settings.yuri.visual.actions.reloadingThemes`:`settings.yuri.visual.actions.reloadThemes`)}),(0,$.jsxs)(En,{children:[(0,$.jsx)(wn,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`flex items-center justify-center rounded-md p-0.5 text-muted-foreground/70 hover:text-foreground`,"aria-label":o(`settings.yuri.visual.field.themeImportInfoAria`),children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5`})})}),(0,$.jsx)(Tn,{sideOffset:8,children:o(`settings.yuri.visual.field.themeImportInfoTooltip`)})]})]})]}),children:[(0,$.jsx)(hp,{isMobile:u,itemId:`appearance.color-mode`,label:o(`settings.yuri.visual.field.themeMode`),children:(0,$.jsx)(`div`,{className:`yuri-settings-switch`,style:{gridTemplateColumns:`auto auto auto`},role:`group`,"aria-label":o(`settings.yuri.visual.field.themeMode`),children:_p.map(e=>(0,$.jsxs)(q,{variant:`ghost`,size:`xs`,"aria-pressed":ze===e.value,className:`yuri-settings-switch-option`,onClick:()=>Be(e.value),children:[ze===e.value&&(0,$.jsx)(`span`,{"aria-hidden":!0,className:`yuri-segmented-selected-pill yuri-settings-switch-pill`}),(0,$.jsx)(`span`,{className:`relative`,children:s(e.labelKey)})]},e.value))})}),(0,$.jsx)(hp,{isMobile:u,itemId:`appearance.light-theme`,label:o(`settings.yuri.visual.field.lightTheme`),children:(0,$.jsxs)(Fr,{value:Mt?.metadata.id??``,onValueChange:qe,children:[(0,$.jsx)(Pr,{"aria-label":o(`settings.yuri.visual.field.selectLightThemeAria`),className:`w-fit`,children:(0,$.jsx)(Ar,{placeholder:o(`settings.yuri.visual.field.selectThemePlaceholder`),children:Mt?Pt(Mt.metadata.name,`light`):void 0})}),(0,$.jsx)(Nr,{children:At.map(e=>(0,$.jsx)(jr,{value:e.metadata.id,children:Pt(e.metadata.name,`light`)},e.metadata.id))})]})}),(0,$.jsx)(hp,{isMobile:u,itemId:`appearance.dark-theme`,label:o(`settings.yuri.visual.field.darkTheme`),children:(0,$.jsxs)(Fr,{value:Nt?.metadata.id??``,onValueChange:Je,children:[(0,$.jsx)(Pr,{"aria-label":o(`settings.yuri.visual.field.selectDarkThemeAria`),className:`w-fit`,children:(0,$.jsx)(Ar,{placeholder:o(`settings.yuri.visual.field.selectThemePlaceholder`),children:Nt?Pt(Nt.metadata.name,`dark`):void 0})}),(0,$.jsx)(Nr,{children:jt.map(e=>(0,$.jsx)(jr,{value:e.metadata.id,children:Pt(e.metadata.name,`dark`)},e.metadata.id))})]})}),tt&&(0,$.jsx)(Ji,{itemId:`appearance.window-transparency`,checked:rt,onChange:ot,disabled:st,label:o(`settings.yuri.visual.field.macVibrancy`),description:o(`settings.yuri.visual.field.macVibrancyHint`),ariaLabel:o(`settings.yuri.visual.field.macVibrancy`)}),ut&&(0,$.jsx)(Ji,{itemId:`appearance.dock-badge`,checked:dt,onChange:ft,label:o(`settings.yuri.visual.field.dockBadge`),description:o(`settings.yuri.visual.field.dockBadgeHint`),ariaLabel:o(`settings.yuri.visual.field.dockBadge`)})]}),Lt&&(0,$.jsx)(mp,{isMobile:u,children:(0,$.jsx)(Ji,{itemId:`appearance.ios-native-ui`,checked:T,onChange:E,label:o(`settings.yuri.visual.field.iosNativeUi`),description:o(`settings.yuri.visual.field.iosNativeUiHint`),ariaLabel:o(`settings.yuri.visual.field.iosNativeUi`)})}),zt&&(0,$.jsxs)(mp,{isMobile:u,label:o(`settings.yuri.visual.section.localization`),children:[(0,$.jsx)(hp,{isMobile:u,itemId:`appearance.language`,label:o(`settings.appearance.language.label`),description:o(`settings.appearance.language.description`),children:(0,$.jsxs)(Fr,{value:n,onValueChange:e=>i(e),children:[(0,$.jsx)(Pr,{"aria-label":o(`settings.appearance.language.select`),className:`w-fit`,children:(0,$.jsx)(Ar,{children:a(n)})}),(0,$.jsx)(Nr,{children:r.map(e=>(0,$.jsx)(jr,{value:e,children:a(e)},e))})]})}),(Y(`timeFormat`)||Y(`weekStart`))&&(0,$.jsxs)($.Fragment,{children:[Y(`timeFormat`)&&(0,$.jsx)(hp,{isMobile:u,itemId:`appearance.time-format`,label:o(`settings.yuri.visual.field.timeFormat`),children:(0,$.jsxs)(Fr,{value:Ce,onValueChange:e=>Ot(e),children:[(0,$.jsx)(Pr,{"aria-label":o(`settings.yuri.visual.field.selectTimeFormatAria`),className:`w-fit`,children:(0,$.jsx)(Ar,{children:Zt})}),(0,$.jsx)(Nr,{children:Ep.map(e=>(0,$.jsx)(jr,{value:e.id,children:s(e.labelKey)},e.id))})]})}),Y(`weekStart`)&&(0,$.jsx)(hp,{isMobile:u,itemId:`appearance.week-start`,label:o(`settings.yuri.visual.field.weekStartsOn`),children:(0,$.jsxs)(Fr,{value:Te,onValueChange:e=>kt(e),children:[(0,$.jsx)(Pr,{"aria-label":o(`settings.yuri.visual.field.selectWeekStartAria`),className:`w-fit`,children:(0,$.jsx)(Ar,{children:Qt})}),(0,$.jsx)(Nr,{children:Dp.map(e=>(0,$.jsx)(jr,{value:e.id,children:s(e.labelKey)},e.id))})]})})]})]}),Y(`sidebarBrand`)&&(0,$.jsx)(pp,{isMobile:u,itemId:`appearance.sidebar-brand`,label:o(`settings.yuri.visual.field.sidebarBrand`),description:o(`settings.yuri.visual.field.sidebarBrandHint`),descriptionPlacement:`outside`,children:(0,$.jsx)(Cn,{value:je,onChange:e=>Me(e.target.value),maxLength:64,"aria-label":o(`settings.yuri.visual.field.sidebarBrandAria`)})}),(Wt||Gt||Kt)&&(0,$.jsxs)($.Fragment,{children:[Wt&&(0,$.jsxs)(pp,{isMobile:u,itemId:`appearance.pwa-install-name`,label:o(`settings.yuri.visual.field.installAppName`),description:o(`settings.yuri.visual.field.installAppNameHint`),children:[(0,$.jsx)(Cn,{value:qt,onChange:e=>{Jt(e.target.value)},onBlur:()=>{tn(qt)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),tn(qt))},maxLength:64,"aria-label":o(`settings.yuri.visual.field.pwaInstallAppNameAria`)}),(0,$.jsx)(q,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>{Jt(yp),tn(``)},className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":o(`settings.yuri.visual.actions.resetInstallAppNameAria`),title:o(`settings.common.actions.reset`),children:(0,$.jsx)(X,{name:`restart`,className:`h-3.5 w-3.5`})})]}),Gt&&(0,$.jsxs)(pp,{isMobile:u,itemId:`appearance.pwa-orientation`,label:o(`settings.yuri.visual.field.installOrientation`),description:o(`settings.yuri.visual.field.installOrientationHint`),descriptionPlacement:`outside`,children:[(0,$.jsxs)(Fr,{value:Yt,onValueChange:e=>{let t=Cp(e);Xt(t),nn(t)},children:[(0,$.jsx)(Pr,{"aria-label":o(`settings.yuri.visual.field.pwaInstallOrientationAria`),className:`w-full`,children:(0,$.jsx)(Ar,{placeholder:o(`settings.yuri.visual.field.selectOrientationPlaceholder`),children:$t})}),(0,$.jsx)(Nr,{children:bp.map(e=>(0,$.jsx)(jr,{value:e.id,children:s(e.labelKey)},e.id))})]}),(0,$.jsx)(q,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>{Xt(`system`),nn(`system`)},disabled:Yt===`system`,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":o(`settings.yuri.visual.actions.resetInstallOrientationAria`),title:o(`settings.common.actions.reset`),children:(0,$.jsx)(X,{name:`restart`,className:`h-3.5 w-3.5`})})]}),Kt&&(0,$.jsxs)(pp,{isMobile:u,itemId:`appearance.mobile-keyboard-mode`,label:o(`settings.yuri.visual.field.mobileKeyboardMode`),description:o(`settings.yuri.visual.field.mobileKeyboardModeHint`),descriptionPlacement:`outside`,children:[(0,$.jsxs)(Fr,{value:te,onValueChange:e=>{let t=le(e);ne(t),ye({mobileKeyboardMode:t})},children:[(0,$.jsx)(Pr,{"aria-label":o(`settings.yuri.visual.field.mobileKeyboardModeAria`),className:`w-full`,children:(0,$.jsx)(Ar,{placeholder:o(`settings.yuri.visual.field.selectMobileKeyboardModePlaceholder`),children:en})}),(0,$.jsx)(Nr,{children:xp.map(e=>(0,$.jsx)(jr,{value:e.id,children:s(e.labelKey)},e.id))})]}),(0,$.jsx)(q,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>{ne(`native`),ye({mobileKeyboardMode:`native`})},disabled:te===`native`,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":o(`settings.yuri.visual.actions.resetMobileKeyboardModeAria`),title:o(`settings.common.actions.reset`),children:(0,$.jsx)(X,{name:`restart`,className:`h-3.5 w-3.5`})})]})]})]}),Vt&&(0,$.jsx)($.Fragment,{children:(0,$.jsx)(mp,{isMobile:u,label:o(`settings.yuri.visual.section.spacingAndLayout`),children:(0,$.jsxs)($.Fragment,{children:[Y(`fontSize`)&&!u&&(0,$.jsxs)(hp,{isMobile:u,label:o(`settings.yuri.visual.field.interfaceFont`),children:[(0,$.jsxs)(Fr,{value:R,onValueChange:e=>z(e),children:[(0,$.jsx)(Pr,{"aria-label":o(`settings.yuri.visual.field.selectInterfaceFontAria`),className:`w-[13rem]`,children:(0,$.jsx)(Ar,{children:de.find(e=>e.id===R)?.label})}),(0,$.jsx)(Nr,{children:de.map(e=>(0,$.jsx)(jr,{value:e.id,children:(0,$.jsx)(`span`,{style:{fontFamily:e.stack},children:e.label})},e.id))})]}),(0,$.jsx)(q,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>z(`system`),disabled:R===`system`,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":o(`settings.yuri.visual.actions.resetInterfaceFontAria`),title:o(`settings.common.actions.reset`),children:(0,$.jsx)(X,{name:`restart`,className:`h-3.5 w-3.5`})})]}),Y(`terminalFontSize`)&&(0,$.jsxs)(hp,{isMobile:u,itemId:`appearance.code-font`,label:o(`settings.yuri.visual.field.codeFont`),children:[(0,$.jsxs)(Fr,{value:B,onValueChange:e=>V(e),children:[(0,$.jsx)(Pr,{"aria-label":o(`settings.yuri.visual.field.selectCodeFontAria`),className:`w-full max-w-[13rem]`,children:(0,$.jsx)(Ar,{children:ue.find(e=>e.id===B)?.label})}),(0,$.jsx)(Nr,{children:ue.map(e=>(0,$.jsx)(jr,{value:e.id,children:(0,$.jsx)(`span`,{style:{fontFamily:e.stack},children:e.label})},e.id))})]}),(0,$.jsx)(q,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>V(`system-mono`),disabled:B===`system-mono`,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":o(`settings.yuri.visual.actions.resetCodeFontAria`),title:o(`settings.common.actions.reset`),children:(0,$.jsx)(X,{name:`restart`,className:`h-3.5 w-3.5`})})]}),Y(`fontSize`)&&(0,$.jsxs)(hp,{isMobile:u,itemId:`appearance.interface-font-size`,label:o(`settings.yuri.visual.field.interfaceFontSize`),children:[(0,$.jsx)(ma,{value:A,onValueChange:j,min:50,max:200,step:5,"aria-label":o(`settings.yuri.visual.field.fontSizePercentageAria`),className:`w-16`}),(0,$.jsx)(q,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>j(100),disabled:A===100,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":o(`settings.yuri.visual.actions.resetFontSizeAria`),title:o(`settings.common.actions.reset`),children:(0,$.jsx)(X,{name:`restart`,className:`h-3.5 w-3.5`})})]}),Y(`codeFontSize`)&&(0,$.jsxs)(hp,{isMobile:u,itemId:`appearance.code-font-size`,label:o(`settings.yuri.visual.field.codeFontSize`),children:[(0,$.jsx)(ma,{value:M,onValueChange:N,min:50,max:200,step:5,"aria-label":o(`settings.yuri.visual.field.codeFontSizePercentageAria`),className:`w-16`}),(0,$.jsx)(q,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>N(100),disabled:M===100,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":o(`settings.yuri.visual.actions.resetCodeFontSizeAria`),title:o(`settings.common.actions.reset`),children:(0,$.jsx)(X,{name:`restart`,className:`h-3.5 w-3.5`})})]}),Y(`terminalFontSize`)&&(0,$.jsxs)(hp,{isMobile:u,itemId:`appearance.terminal-font-size`,label:o(`settings.yuri.visual.field.terminalFontSize`),children:[(0,$.jsx)(ma,{value:P,onValueChange:F,min:9,max:52,step:1,className:`w-16`}),(0,$.jsx)(q,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>F(13),disabled:P===13,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":o(`settings.yuri.visual.actions.resetTerminalFontSizeAria`),title:o(`settings.common.actions.reset`),children:(0,$.jsx)(X,{name:`restart`,className:`h-3.5 w-3.5`})})]}),Y(`editorFontSize`)&&(0,$.jsxs)(hp,{isMobile:u,itemId:`appearance.editor-font-size`,label:o(`settings.yuri.visual.field.editorFontSize`),children:[(0,$.jsx)(ma,{value:I,onValueChange:L,min:9,max:32,step:1,className:`w-16`}),(0,$.jsx)(q,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>L(13),disabled:I===13,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":o(`settings.yuri.visual.actions.resetEditorFontSizeAria`),title:o(`settings.common.actions.reset`),children:(0,$.jsx)(X,{name:`restart`,className:`h-3.5 w-3.5`})})]}),Y(`spacing`)&&(0,$.jsxs)(hp,{isMobile:u,itemId:`appearance.spacing-density`,label:o(`settings.yuri.visual.field.spacingDensity`),children:[(0,$.jsx)(ma,{value:H,onValueChange:U,min:50,max:200,step:5,className:`w-16`}),(0,$.jsx)(q,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>U(100),disabled:H===100,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":o(`settings.yuri.visual.actions.resetSpacingAria`),title:o(`settings.common.actions.reset`),children:(0,$.jsx)(X,{name:`restart`,className:`h-3.5 w-3.5`})})]}),Y(`inputBarOffset`)&&(0,$.jsxs)(hp,{isMobile:u,itemId:`appearance.input-bar-offset`,label:(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:o(`settings.yuri.visual.field.inputBarOffset`)}),(0,$.jsxs)(En,{children:[(0,$.jsx)(wn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(Tn,{sideOffset:8,className:`max-w-xs`,children:o(`settings.yuri.visual.field.inputBarOffsetTooltip`)})]})]}),children:[(0,$.jsx)(ma,{value:W,onValueChange:ee,min:0,max:100,step:5,className:`w-16`}),(0,$.jsx)(q,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>ee(0),disabled:W===0,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":o(`settings.yuri.visual.actions.resetInputBarOffsetAria`),title:o(`settings.common.actions.reset`),children:(0,$.jsx)(X,{name:`restart`,className:`h-3.5 w-3.5`})})]})]})})}),Ht&&(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(mp,{isMobile:u,label:o(`settings.yuri.visual.section.navigation`),children:[Y(`fileEditorKeymap`)&&(0,$.jsx)(hp,{isMobile:u,itemId:`appearance.file-editor-keymap`,label:o(`settings.yuri.visual.field.fileEditorKeymap`),children:(0,$.jsx)(`div`,{role:`radiogroup`,"aria-label":o(`settings.yuri.visual.field.fileEditorKeymap`),className:`flex flex-wrap items-center justify-end gap-x-3 gap-y-1`,children:[`default`,`vim`].map(e=>{let t=se===e,n=o(`settings.yuri.visual.option.fileEditorKeymap.${e}`);return(0,$.jsxs)(`button`,{type:`button`,className:`flex cursor-pointer items-center gap-2 py-0.5 text-left`,role:`radio`,"aria-checked":t,onClick:()=>ce(e),children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:K(`relative flex h-[14px] w-[14px] min-h-[14px] min-w-[14px] shrink-0 self-center items-center justify-center rounded-full transition-[background-color,box-shadow] duration-200 ease-out`,t?`bg-[color-mix(in_srgb,var(--primary-base)_80%,transparent)] shadow-none`:`bg-[var(--surface-muted)] shadow-[inset_0_0_0_1px_var(--interactive-border)]`),children:(0,$.jsx)(`span`,{className:K(`block h-[5px] w-[5px] rounded-full bg-white`,!t&&`opacity-0`)})}),(0,$.jsx)(`span`,{className:K(`typography-ui-label font-normal`,t?`text-foreground`:`text-foreground/50`),children:n})]},e)})})}),Y(`terminalQuickKeys`)&&!u&&!h()&&(0,$.jsx)(hp,{isMobile:u,itemId:`appearance.terminal-quick-keys`,label:(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:o(`settings.yuri.visual.field.terminalQuickKeys`)}),(0,$.jsxs)(En,{children:[(0,$.jsx)(wn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(Tn,{sideOffset:8,className:`max-w-xs`,children:o(`settings.yuri.visual.field.terminalQuickKeysTooltip`)})]})]}),children:(0,$.jsx)(Wi,{checked:ae,onChange:oe,ariaLabel:o(`settings.yuri.visual.field.terminalQuickKeysAria`)})})]})}),Ut&&(0,$.jsxs)(`div`,{className:`yuri-settings-section-stack`,children:[(Y(`chatRenderMode`)||Y(`messageTransport`)||Y(`diffLayout`)&&!It)&&(0,$.jsxs)(`div`,{className:`grid w-full grid-cols-1 gap-y-[var(--yuri-settings-section-stack-gap)]`,children:[Y(`chatRenderMode`)&&(0,$.jsx)(mp,{isMobile:u,label:o(`settings.yuri.visual.section.chatRenderMode`),className:`w-full`,cardClassName:`!border-0 !bg-transparent !rounded-none overflow-visible`,children:(0,$.jsx)(`div`,{"data-settings-item":`chat.render-mode`,className:`min-w-0 w-full`,children:(0,$.jsx)(`div`,{role:`radiogroup`,"aria-label":o(`settings.yuri.visual.section.chatRenderModeAria`),className:`grid w-full grid-cols-1 gap-3 sm:grid-cols-2`,children:wp.map(e=>{let t=D===e.id,n=mt%12;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>wt(e.id),"aria-pressed":t,className:K(`flex flex-col items-start gap-1 rounded-lg border p-3 text-left transition-colors`,t?`border-primary bg-primary/5`:`border-border hover:border-border/80 hover:bg-muted/50`),children:[(0,$.jsx)(`span`,{className:K(`typography-ui-label`,t?`text-foreground`:`text-muted-foreground`),children:s(e.labelKey)}),(0,$.jsx)(`div`,{className:`mt-2 w-full rounded-md border border-border/60 bg-muted/30 p-2`,children:e.id===`live`?(0,$.jsx)(`div`,{className:`space-y-1.5`,children:[0,1,2].map(e=>{let t=e*3+1,r=n-t+1,i=r<=0?0:r===1?42:r===2?68:92;return(0,$.jsxs)(`div`,{className:K(`flex items-center gap-1.5 transition-all duration-300 motion-reduce:transition-none`,i>0?`translate-y-0 opacity-100`:`translate-y-1 opacity-0`),children:[(0,$.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full bg-muted-foreground/55`}),(0,$.jsx)(`span`,{className:`h-1.5 rounded bg-muted-foreground/30 transition-all duration-300 motion-reduce:transition-none`,style:{width:`${i}%`}})]},e)})}):(0,$.jsx)(`div`,{className:`space-y-1.5`,children:[0,1,2].map(e=>{let t=n>=(e+1)*3;return(0,$.jsxs)(`div`,{className:K(`flex items-center gap-1.5 transition-all duration-300 motion-reduce:transition-none`,t?`translate-y-0 opacity-100`:`translate-y-1 opacity-0`),children:[(0,$.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full bg-muted-foreground/55`}),(0,$.jsx)(`span`,{className:`h-1.5 rounded bg-muted-foreground/30`,style:{width:`92%`}})]},e)})})})]},e.id)})})})}),Y(`messageTransport`)&&(0,$.jsx)(mp,{isMobile:u,label:o(`settings.yuri.visual.section.messageStreamTransport`),className:`w-full`,children:(0,$.jsxs)(`div`,{"data-settings-item":`chat.message-transport`,className:`yuri-settings-group-row flex flex-col gap-2`,children:[(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-1`,children:Tp.map(e=>(0,$.jsx)(q,{variant:`chip`,size:`xs`,"aria-pressed":Le===e.id,className:`!font-normal`,onClick:()=>Tt(e.id),children:s(e.labelKey)},e.id))}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:(()=>{let e=Tp.find(e=>e.id===Le);return e?.descriptionKey?s(e.descriptionKey):``})()})]})}),Y(`diffLayout`)&&!It&&(0,$.jsx)(mp,{isMobile:u,label:o(`settings.yuri.visual.section.diffLayout`),className:`w-full`,children:(0,$.jsx)(`div`,{"data-settings-item":`chat.diff-layout`,role:`radiogroup`,"aria-label":o(`settings.yuri.visual.section.diffLayoutAria`),children:vp.map(e=>{let t=re===e.id;return(0,$.jsx)(gp,{selected:t,onSelect:()=>ie(e.id),label:s(e.labelKey),ariaLabel:o(`settings.yuri.visual.field.diffLayoutAria`,{option:s(e.labelKey)})},e.id)})})})]}),Y(`sessionGoal`)&&(0,$.jsx)(mp,{isMobile:u,label:(0,$.jsx)(`div`,{className:`flex items-center gap-1.5`,children:(0,$.jsx)(`span`,{children:o(`settings.yuri.visual.goal.sectionTitle`)})}),children:(0,$.jsx)(hp,{isMobile:u,itemId:`chat.session-goal`,label:o(`settings.yuri.visual.field.sessionGoal`),children:(0,$.jsx)(Wi,{checked:v,onChange:y,ariaLabel:o(`settings.yuri.visual.field.sessionGoalAria`)})})}),(Y(`sessionAssist`)||Y(`collapsibleUserMessages`)||Y(`splitAssistantMessageActions`)||Y(`showAssistantTps`)||Y(`subagentReadOnlyBanner`)||Y(`persistDraft`)||Y(`showSubagentTaskDetails`)||!u&&Y(`inputSpellcheck`)||Y(`reasoning`))&&(0,$.jsxs)(`div`,{className:`yuri-settings-section-stack`,children:[(Y(`sessionAssist`)||Y(`questionAutoDelegate`)||Y(`subagentReadOnlyBanner`))&&(0,$.jsxs)(mp,{isMobile:u,label:(0,$.jsx)(`span`,{"data-settings-item":`chat.session-assistance`,children:o(`settings.yuri.visual.section.sessionAssistance`)}),children:[Y(`sessionAssist`)&&(0,$.jsx)(Ji,{itemId:`chat.session-title-refresh`,checked:m,onChange:_,label:o(`settings.yuri.visual.field.sessionTitleRefresh`),ariaLabel:o(`settings.yuri.visual.field.sessionTitleRefreshAria`)}),Y(`subagentReadOnlyBanner`)&&(0,$.jsx)(Ji,{itemId:`chat.subagent-read-only-banner`,checked:Ne,onChange:Pe,label:o(`settings.yuri.visual.field.allowPromptingSubagentSessions`),ariaLabel:o(`settings.yuri.visual.field.allowPromptingSubagentSessionsAria`)}),Y(`questionAutoDelegate`)&&(0,$.jsx)(fp,{})]}),(Y(`collapsibleUserMessages`)||Y(`splitAssistantMessageActions`)||Y(`showAssistantTps`)||Y(`reasoning`))&&(0,$.jsxs)(mp,{isMobile:u,label:(0,$.jsx)(`span`,{"data-settings-item":`chat.message-appearance`,children:o(`settings.yuri.visual.section.messageAppearance`)}),children:[Y(`reasoning`)&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{"data-settings-item":`chat.reasoning`,className:`hidden`,"aria-hidden":!0}),(0,$.jsx)(Ji,{checked:p,onChange:b,label:o(`settings.yuri.visual.field.showReasoningTraces`),description:o(`settings.yuri.visual.field.showReasoningTracesHint`),ariaLabel:o(`settings.yuri.visual.field.showReasoningTracesAria`)}),p&&(0,$.jsx)(Ji,{checked:x,onChange:S,label:o(`settings.yuri.visual.field.collapsibleThinkingBlocks`),ariaLabel:o(`settings.yuri.visual.field.collapsibleThinkingBlocksAria`)})]}),Y(`collapsibleUserMessages`)&&(0,$.jsx)(Ji,{itemId:`chat.collapsible-user-messages`,checked:C,onChange:bt,label:o(`settings.yuri.visual.field.collapsibleUserMessages`),ariaLabel:o(`settings.yuri.visual.field.collapsibleUserMessagesAria`)}),Y(`splitAssistantMessageActions`)&&(0,$.jsx)(Ji,{itemId:`chat.inline-assistant-actions`,checked:De,onChange:xt,ariaLabel:o(`settings.yuri.visual.field.showSplitAssistantMessageActionsAria`),label:(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:o(`settings.yuri.visual.field.showSplitAssistantMessageActions`)}),(0,$.jsxs)(En,{children:[(0,$.jsx)(wn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 cursor-help text-muted-foreground/60`})}),(0,$.jsx)(Tn,{sideOffset:8,className:`max-w-xs`,children:o(`settings.yuri.visual.field.showSplitAssistantMessageActionsTooltip`)})]})]})}),Y(`showAssistantTps`)&&(0,$.jsx)(Ji,{itemId:`chat.assistant-tps`,checked:ke,onChange:St,ariaLabel:o(`settings.yuri.visual.field.showAssistantTpsAria`),label:(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:o(`settings.yuri.visual.field.showAssistantTps`)}),(0,$.jsxs)(En,{children:[(0,$.jsx)(wn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 cursor-help text-muted-foreground/60`})}),(0,$.jsx)(Tn,{sideOffset:8,className:`max-w-xs`,children:o(`settings.yuri.visual.field.showAssistantTpsTooltip`)})]})]})})]}),Y(`showSubagentTaskDetails`)&&(0,$.jsx)(mp,{isMobile:u,children:(0,$.jsx)(Ji,{itemId:`chat.subagent-task-details`,checked:be,onChange:Et,label:o(`settings.yuri.visual.field.showSubagentTaskDetails`),description:o(`settings.yuri.visual.field.showSubagentTaskDetailsHint`),ariaLabel:o(`settings.yuri.visual.field.showSubagentTaskDetailsAria`)})}),(Y(`persistDraft`)||Y(`followUpBehavior`)||!u&&Y(`inputSpellcheck`))&&(0,$.jsxs)(mp,{isMobile:u,label:(0,$.jsx)(`span`,{"data-settings-item":`chat.composer`,children:o(`settings.yuri.visual.section.composer`)}),children:[Y(`followUpBehavior`)&&(0,$.jsx)(hp,{isMobile:u,itemId:`chat.follow-up-behavior`,label:o(`settings.yuri.visual.field.followUpBehavior`),description:o(`settings.yuri.visual.field.followUpBehaviorDescription`),children:(0,$.jsxs)(Fr,{value:pe,onValueChange:e=>me(e===`steer`?`steer`:`queue`),children:[(0,$.jsx)(Pr,{"aria-label":o(`settings.yuri.visual.field.followUpBehaviorAria`),className:`w-fit`,children:(0,$.jsx)(Ar,{children:o(`settings.yuri.visual.option.followUpBehavior.${pe}.label`)})}),(0,$.jsx)(Nr,{children:Sp.map(e=>(0,$.jsx)(jr,{value:e.id,children:s(e.labelKey)},e.id))})]})}),Y(`persistDraft`)&&(0,$.jsx)(Ji,{itemId:`chat.persist-drafts`,checked:he,onChange:ge,label:o(`settings.yuri.visual.field.persistDraftMessages`),ariaLabel:o(`settings.yuri.visual.field.persistDraftMessagesAria`)}),!u&&Y(`inputSpellcheck`)&&(0,$.jsx)(Ji,{itemId:`chat.spellcheck`,checked:_e,onChange:Ct,label:o(`settings.yuri.visual.field.enableSpellcheckInTextInputs`),ariaLabel:o(`settings.yuri.visual.field.enableSpellcheckInTextInputsAria`)})]})]})]}),Y(`reportUsage`)&&(0,$.jsxs)(mp,{isMobile:u,label:o(`settings.yuri.visual.section.privacy`),children:[Y(`reportUsage`)&&(0,$.jsx)(hp,{isMobile:u,itemId:`appearance.usage-reports`,label:o(`settings.yuri.visual.field.sendAnonymousUsageReports`),description:o(`settings.yuri.visual.field.sendAnonymousUsageReportsHint`),children:(0,$.jsx)(Wi,{checked:gt,onChange:vt,ariaLabel:o(`settings.yuri.visual.field.sendAnonymousUsageReportsAria`)})}),Y(`reportUsage`)&&(0,$.jsx)(hp,{isMobile:u,itemId:`appearance.transcript-cache`,label:o(`settings.yuri.visual.transcriptCache.label`),description:o(`settings.yuri.visual.transcriptCache.description`),children:(0,$.jsx)(q,{type:`button`,variant:`destructive`,size:`sm`,disabled:$e,onClick:()=>Qe(!0),children:o(`settings.yuri.visual.transcriptCache.action`)})})]})]}),(0,$.jsx)(gn,{open:at!==null,onOpenChange:e=>{!e&&!st&&ot(null)},children:(0,$.jsxs)(pn,{showCloseButton:!st,children:[(0,$.jsxs)(dn,{children:[(0,$.jsx)(mn,{children:o(`settings.yuri.visual.field.macVibrancy`)}),(0,$.jsx)(hn,{children:o(`settings.yuri.visual.vibrancy.confirmDescription`)})]}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(q,{type:`button`,variant:`ghost`,disabled:st,onClick:()=>ot(null),children:o(`settings.common.actions.cancel`)}),(0,$.jsx)(q,{type:`button`,disabled:st,"aria-busy":st||void 0,onClick:()=>void lt(),children:o(st?`settings.yuri.visual.actions.restarting`:`settings.yuri.visual.vibrancy.confirmRestart`)})]})]})}),(0,$.jsx)(gn,{open:Ze,onOpenChange:e=>{$e||Qe(e)},children:(0,$.jsxs)(pn,{className:`max-w-[min(480px,100vw-2rem)]`,children:[(0,$.jsxs)(dn,{children:[(0,$.jsx)(mn,{children:o(`settings.yuri.visual.transcriptCache.dialog.title`)}),(0,$.jsx)(hn,{children:o(`settings.yuri.visual.transcriptCache.dialog.description`)})]}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(q,{type:`button`,variant:`ghost`,disabled:$e,onClick:()=>Qe(!1),children:o(`settings.common.actions.cancel`)}),(0,$.jsx)(q,{type:`button`,variant:`destructive`,disabled:$e,"aria-busy":$e||void 0,onClick:()=>void Ft(),children:o($e?`settings.yuri.visual.transcriptCache.dialog.clearing`:`settings.yuri.visual.transcriptCache.action`)})]})]})})]})},kp=864e5,Ap=5,jp=864e5,Mp=e=>e.time?.updated??e.time?.created??0,Np=({sessions:e,currentSessionId:t,cutoffDays:n,keepRecent:r=Ap,now:i=Date.now()})=>{if(!Array.isArray(e)||n<=0)return[];let a=i-n*kp,o=[...e].sort((e,t)=>Mp(t)-Mp(e)),s=new Set(o.slice(0,r).map(e=>e.id));return o.filter(e=>{if(!e?.id||s.has(e.id)||e.id===t||e.share)return!1;let n=Mp(e);return n?n<a:!1}).map(e=>e.id)},Pp=e=>{let t=typeof e==`object`?e:void 0,n=t?.autoRun!==!1,r=typeof e==`boolean`?e:t?.enabled??!0,i=Ht(e=>e.currentSessionId),a=Ht(e=>e.isLoading),o=Ct(e=>e.activeSessions),s=Ct(e=>e.hasLoadedFullCatalog),c=G(e=>e.autoDeleteEnabled),l=G(e=>e.autoDeleteAfterDays),u=G(e=>e.sessionRetentionAction),d=G(e=>e.autoDeleteLastRunAt),f=G(e=>e.setAutoDeleteLastRunAt),[p,m]=Q.useState(!1),h=Q.useRef(!1);Q.useEffect(()=>{if(!r||!n||!c||l<=0)return;let e=window.setTimeout(()=>{dt(se())},8e3);return()=>window.clearTimeout(e)},[l,c,n,r]);let g=Q.useMemo(()=>l<=0?[]:Np({sessions:o,currentSessionId:i,cutoffDays:l}),[l,i,o]),_=Q.useCallback(async({force:e=!1}={})=>{if(h.current)return{completedIds:[],failedIds:[],action:u,skippedReason:`running`};if((!c||l<=0)&&!e)return{completedIds:[],failedIds:[],action:u,skippedReason:`disabled`};if(a)return{completedIds:[],failedIds:[],action:u,skippedReason:`loading`};let t=Date.now();if(!e&&d&&t-d<jp)return{completedIds:[],failedIds:[],action:u,skippedReason:`cooldown`};let{activeSessions:n}=await dt(se());if(n.length===0)return{completedIds:[],failedIds:[],action:u,skippedReason:`no-candidates`};let r=Np({sessions:n,currentSessionId:i,cutoffDays:l,now:t});if(r.length===0)return f(t),{completedIds:[],failedIds:[],action:u,skippedReason:`no-candidates`};h.current=!0,m(!0);try{let e=new Map(n.map(e=>[e.id,e])),t=[],i=[];for(let n of r){let r=e.get(n),a=r?Gt(r):null;if(!a){i.push(n);continue}try{u===`archive`?await oe.updateSession(n,{time:{archived:Date.now()}},a):await oe.deleteSession(n,a),t.push(n)}catch{i.push(n)}}return u===`archive`?Ct.getState().archiveSessions(t):Ct.getState().removeSessions(t),{completedIds:t,failedIds:i,action:u}}finally{h.current=!1,m(!1),f(Date.now())}},[l,c,d,i,a,u,f]);return Q.useEffect(()=>{r&&n&&(!c||l<=0||a||!s||o.length===0||d&&Date.now()-d<jp||_())},[l,c,d,n,r,s,o.length,a,_]),{candidates:g,isRunning:p,runCleanup:_,keepRecentCount:Ap,action:u}},Fp=1,Ip=365,Lp=30,Rp=[{value:`archive`,labelKey:`settings.yuri.sessionRetention.action.archive`},{value:`delete`,labelKey:`settings.yuri.sessionRetention.action.delete`}],zp=()=>{let e=(0,Sa.c)(101),{t}=Ge(),n=G(Bp),r=G(Vp),i=G(Hp),a=G(Up),o=G(Wp),s=G(Gp),c;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(c={autoRun:!1},e[0]=c):c=e[0];let{candidates:l,isRunning:u,runCleanup:d,action:f}=Pp(c),p=l.length,m;e[1]!==d||e[2]!==t?(m=async()=>{let e=await d({force:!0});if(e.completedIds.length===0&&e.failedIds.length===0){J.message(e.action===`archive`?t(`settings.yuri.sessionRetention.toast.noneEligibleArchive`):t(`settings.yuri.sessionRetention.toast.noneEligibleDelete`));return}e.completedIds.length>0&&J.success(e.action===`archive`?t(`settings.yuri.sessionRetention.toast.archivedCount`,{count:e.completedIds.length}):t(`settings.yuri.sessionRetention.toast.deletedCount`,{count:e.completedIds.length})),e.failedIds.length>0&&J.error(e.action===`archive`?t(`settings.yuri.sessionRetention.toast.failedArchiveCount`,{count:e.failedIds.length}):t(`settings.yuri.sessionRetention.toast.failedDeleteCount`,{count:e.failedIds.length}))},e[1]=d,e[2]=t,e[3]=m):m=e[3];let h=m,g;e[4]===t?g=e[5]:(g=t(`settings.yuri.sessionRetention.title`),e[4]=t,e[5]=g);let _;e[6]===g?_=e[7]:(_=(0,$.jsx)(`span`,{children:g}),e[6]=g,e[7]=_);let v;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(wn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 cursor-help text-muted-foreground/60`})}),e[8]=v):v=e[8];let y;e[9]===t?y=e[10]:(y=t(`settings.yuri.sessionRetention.tooltip`),e[9]=t,e[10]=y);let b;e[11]===y?b=e[12]:(b=(0,$.jsxs)(En,{children:[v,(0,$.jsx)(Tn,{sideOffset:8,className:`max-w-xs`,children:y})]}),e[11]=y,e[12]=b);let x;e[13]!==_||e[14]!==b?(x=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[_,b]}),e[13]=_,e[14]=b,e[15]=x):x=e[15];let S,C;e[16]!==n||e[17]!==a?(S=()=>a(!n),C=e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),a(!n))},e[16]=n,e[17]=a,e[18]=S,e[19]=C):(S=e[18],C=e[19]);let w;e[20]===t?w=e[21]:(w=t(`settings.yuri.sessionRetention.field.enableAutoCleanup`),e[20]=t,e[21]=w);let T;e[22]===w?T=e[23]:(T=(0,$.jsx)(`div`,{className:`yuri-settings-split-row-copy`,children:(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:w})}),e[22]=w,e[23]=T);let E;e[24]===t?E=e[25]:(E=t(`settings.yuri.sessionRetention.field.enableAutoCleanupAria`),e[24]=t,e[25]=E);let D;e[26]!==n||e[27]!==a||e[28]!==E?(D=(0,$.jsx)(`div`,{className:`yuri-settings-split-row-control`,children:(0,$.jsx)(Wi,{checked:n,onChange:a,ariaLabel:E})}),e[26]=n,e[27]=a,e[28]=E,e[29]=D):D=e[29];let O;e[30]!==n||e[31]!==T||e[32]!==D||e[33]!==S||e[34]!==C?(O=(0,$.jsxs)(`div`,{"data-settings-item":`sessions.auto-cleanup`,className:`yuri-settings-group-row yuri-settings-split-row group cursor-pointer`,role:`button`,tabIndex:0,"aria-pressed":n,onClick:S,onKeyDown:C,children:[T,D]}),e[30]=n,e[31]=T,e[32]=D,e[33]=S,e[34]=C,e[35]=O):O=e[35];let k;e[36]===t?k=e[37]:(k=t(`settings.yuri.sessionRetention.field.retentionPeriod`),e[36]=t,e[37]=k);let A;e[38]===t?A=e[39]:(A=t(`settings.yuri.sessionRetention.field.retentionPeriodAria`),e[38]=t,e[39]=A);let j;e[40]!==r||e[41]!==o||e[42]!==A?(j=(0,$.jsx)(ma,{value:r,onValueChange:o,min:Fp,max:Ip,step:1,"aria-label":A,className:`w-20 tabular-nums`}),e[40]=r,e[41]=o,e[42]=A,e[43]=j):j=e[43];let M;e[44]===t?M=e[45]:(M=t(`settings.yuri.sessionRetention.field.days`),e[44]=t,e[45]=M);let N;e[46]===M?N=e[47]:(N=(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground`,children:M}),e[46]=M,e[47]=N);let P;e[48]===o?P=e[49]:(P=()=>o(Lp),e[48]=o,e[49]=P);let F=r===Lp,I;e[50]===t?I=e[51]:(I=t(`settings.yuri.sessionRetention.actions.resetRetentionAria`),e[50]=t,e[51]=I);let L;e[52]===t?L=e[53]:(L=t(`settings.common.actions.reset`),e[52]=t,e[53]=L);let R;e[54]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,$.jsx)(X,{name:`restart`,className:`h-3.5 w-3.5`}),e[54]=R):R=e[54];let z;e[55]!==P||e[56]!==F||e[57]!==I||e[58]!==L?(z=(0,$.jsx)(q,{size:`sm`,type:`button`,variant:`ghost`,onClick:P,disabled:F,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":I,title:L,children:R}),e[55]=P,e[56]=F,e[57]=I,e[58]=L,e[59]=z):z=e[59];let B;e[60]!==k||e[61]!==j||e[62]!==N||e[63]!==z?(B=(0,$.jsxs)(Xi,{itemId:`sessions.retention-period`,label:k,children:[j,N,z]}),e[60]=k,e[61]=j,e[62]=N,e[63]=z,e[64]=B):B=e[64];let V;e[65]===t?V=e[66]:(V=t(`settings.yuri.sessionRetention.field.whenSessionsExpire`),e[65]=t,e[66]=V);let H;e[67]!==i||e[68]!==s||e[69]!==t?(H=Rp.map(e=>(0,$.jsx)(q,{type:`button`,variant:`chip`,size:`xs`,"aria-pressed":i===e.value,className:`!font-normal`,onClick:()=>s(e.value),children:t(e.labelKey)},e.value)),e[67]=i,e[68]=s,e[69]=t,e[70]=H):H=e[70];let U;e[71]===H?U=e[72]:(U=(0,$.jsx)(`div`,{className:`flex flex-wrap items-center justify-end gap-1`,children:H}),e[71]=H,e[72]=U);let W;e[73]!==V||e[74]!==U?(W=(0,$.jsx)(Xi,{itemId:`sessions.retention-action`,label:V,children:U}),e[73]=V,e[74]=U,e[75]=W):W=e[75];let ee;e[76]!==O||e[77]!==B||e[78]!==W||e[79]!==x?(ee=(0,$.jsxs)(Z,{label:x,children:[O,B,W]}),e[76]=O,e[77]=B,e[78]=W,e[79]=x,e[80]=ee):ee=e[80];let te;e[81]===t?te=e[82]:(te=t(`settings.yuri.sessionRetention.manualCleanup.title`),e[81]=t,e[82]=te);let ne;e[83]!==f||e[84]!==p||e[85]!==t?(ne=t(f===`archive`?`settings.yuri.sessionRetention.manualCleanup.eligibleArchiveNow`:`settings.yuri.sessionRetention.manualCleanup.eligibleDeleteNow`,{count:p}),e[83]=f,e[84]=p,e[85]=t,e[86]=ne):ne=e[86];let re;e[87]!==u||e[88]!==t?(re=t(u?`settings.yuri.sessionRetention.actions.cleaningUp`:`settings.yuri.sessionRetention.actions.runCleanupNow`),e[87]=u,e[88]=t,e[89]=re):re=e[89];let ie;e[90]!==h||e[91]!==u||e[92]!==re?(ie=(0,$.jsx)(q,{type:`button`,variant:`outline`,size:`xs`,onClick:h,disabled:u,className:`!font-normal`,children:re}),e[90]=h,e[91]=u,e[92]=re,e[93]=ie):ie=e[93];let ae;e[94]!==te||e[95]!==ne||e[96]!==ie?(ae=(0,$.jsx)(Ui,{label:te,description:ne,descriptionPlacement:`outside`,children:ie}),e[94]=te,e[95]=ne,e[96]=ie,e[97]=ae):ae=e[97];let oe;return e[98]!==ee||e[99]!==ae?(oe=(0,$.jsxs)(`div`,{className:`yuri-settings-section-stack`,children:[ee,ae]}),e[98]=ee,e[99]=ae,e[100]=oe):oe=e[100],oe};function Bp(e){return e.autoDeleteEnabled}function Vp(e){return e.autoDeleteAfterDays}function Hp(e){return e.sessionRetentionAction}function Up(e){return e.setAutoDeleteEnabled}function Wp(e){return e.setAutoDeleteAfterDays}function Gp(e){return e.setSessionRetentionAction}var Kp=(e,t,n)=>!e||!Number.isFinite(e)?t:new Intl.DateTimeFormat(Je(),{dateStyle:`medium`,timeStyle:`short`,hour12:n===`auto`?void 0:n===`12h`}).format(e),qp=()=>{let{t:e}=Ge(),t=G(e=>e.timeFormatPreference),[n,r]=Q.useState(!1),[i,a]=Q.useState(!0),[o,s]=Q.useState(!1),[c,l]=Q.useState(null),[u,d]=Q.useState(!1),[f,p]=Q.useState([]),[m,h]=Q.useState(qn),[g,_]=Q.useState(``),v=Q.useMemo(()=>Yn(),[]),y=Q.useCallback(async()=>{a(!0),_(``);try{let e=await br();p(e)}catch(t){let n=t instanceof Error?t.message:e(`settings.yuri.passkeys.toast.loadFailed`);_(n)}finally{a(!1)}},[e]);Q.useEffect(()=>{let e=!1;return(async()=>{try{if(!v.supported){e||(r(!1),a(!1));return}e||r(!0)}catch{e||r(!1)}if(!e){let e=await jn();if(h(e),!e.enabled){p([]),a(!1);return}await y()}})(),()=>{e=!0,xr()}},[y,v.supported]);let b=Q.useCallback(async()=>{if(!m.enabled){let t=e(`settings.yuri.passkeys.toast.enableUiPasswordFirst`);_(t),J.message(t);return}if(!n){_(v.reason),J.message(v.reason);return}if(o){xr(),s(!1);return}_(``),s(!0);try{await Nn(),h(await jn()),await y(),J.success(e(`settings.yuri.passkeys.toast.added`))}catch(t){if(Pn(t)){J.message(e(`settings.yuri.passkeys.toast.setupCanceled`));return}let n=t instanceof Error?t.message:e(`settings.yuri.passkeys.toast.addFailed`);_(n),J.error(n)}finally{s(!1)}},[o,y,m.enabled,v.reason,n,e]),x=Q.useCallback(async t=>{l(t),_(``);try{await lr(t),h(await jn()),await y(),J.success(e(`settings.yuri.passkeys.toast.removed`))}catch(t){let n=t instanceof Error?t.message:e(`settings.yuri.passkeys.toast.removeFailed`);_(n),J.error(n)}finally{l(null)}},[y,e]),S=Q.useCallback(async()=>{d(!0),_(``);try{await Gn(),window.location.reload()}catch(t){let n=t instanceof Error?t.message:e(`settings.yuri.passkeys.toast.clearAuthFailed`);_(n),J.error(n),d(!1)}},[e]);return(0,$.jsxs)(Z,{label:e(`settings.yuri.passkeys.title`),children:[(0,$.jsx)(Xi,{label:e(`settings.yuri.passkeys.field.currentDevice`),children:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,$.jsx)(q,{type:`button`,variant:o?`secondary`:`outline`,size:`xs`,onClick:()=>void b(),disabled:i||u,className:`!font-normal`,children:e(o?`settings.yuri.passkeys.actions.cancelSetup`:`settings.yuri.passkeys.actions.add`)}),(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`xs`,onClick:()=>void S(),disabled:i||o||u,className:`!font-normal text-muted-foreground hover:text-foreground`,children:e(u?`settings.yuri.passkeys.actions.signingOut`:`settings.yuri.passkeys.actions.signOutEverywhere`)})]})}),!m.enabled&&(0,$.jsx)(`p`,{className:`yuri-settings-group-row typography-meta text-muted-foreground`,children:e(`settings.yuri.passkeys.state.uiPasswordRequired`)}),m.enabled&&!n&&(0,$.jsx)(`p`,{className:`yuri-settings-group-row typography-meta text-muted-foreground`,children:v.reason}),i?(0,$.jsx)(`p`,{className:`yuri-settings-group-row typography-meta text-muted-foreground`,children:e(`settings.yuri.passkeys.state.loading`)}):f.length===0?(0,$.jsx)(`p`,{className:`yuri-settings-group-row typography-meta text-muted-foreground`,children:e(`settings.yuri.passkeys.state.noneSaved`)}):(0,$.jsx)($.Fragment,{children:f.map(n=>(0,$.jsx)(Xi,{label:n.label,copyClassName:`truncate`,children:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground truncate`,children:n.lastUsedAt?e(`settings.yuri.passkeys.item.lastUsed`,{time:Kp(n.lastUsedAt,e(`settings.yuri.passkeys.time.neverUsed`),t)}):e(`settings.yuri.passkeys.item.added`,{time:Kp(n.createdAt,e(`settings.yuri.passkeys.time.neverUsed`),t)})}),(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`xs`,onClick:()=>void x(n.id),disabled:c===n.id,className:`!font-normal text-muted-foreground hover:text-foreground`,children:c===n.id?e(`settings.yuri.passkeys.actions.removing`):e(`settings.common.actions.delete`)})]})},n.id))}),g&&(0,$.jsx)(`div`,{className:`yuri-settings-group-row`,children:(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:g})})]})},Jp=e=>Zt(e)||{providerId:``,modelId:``},Yp=()=>{let{t:e}=Ge(),t=pt(e=>e.setProvider),n=pt(e=>e.setModel),r=pt(e=>e.setAgent),i=pt(e=>e.setCurrentVariant),a=pt(e=>e.setSettingsDefaultModel),o=pt(e=>e.setSettingsDefaultVariant),s=pt(e=>e.setSettingsDefaultAgent),c=G(e=>e.showDeletionDialog),u=G(e=>e.setShowDeletionDialog),d=pt(e=>e.providers),[f,p]=Q.useState(),[m,h]=Q.useState(),[g,_]=Q.useState(),[v,y]=Q.useState(!0),b=Q.useMemo(()=>Jp(f),[f]);Q.useEffect(()=>{(async()=>{try{let e=null;if(!e){let t=A()?.settings;if(t)try{let n=(await t.load())?.settings;if(n){let t=n;e={defaultModel:typeof n.defaultModel==`string`?n.defaultModel:void 0,defaultVariant:typeof t.defaultVariant==`string`?t.defaultVariant:void 0,defaultAgent:typeof n.defaultAgent==`string`?n.defaultAgent:void 0}}}catch{}}if(!e){let t=await l(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});t.ok&&(e=await t.json())}if(e){let t=typeof e.defaultModel==`string`&&e.defaultModel.trim().length>0?e.defaultModel.trim():void 0,n=typeof e.defaultVariant==`string`&&e.defaultVariant.trim().length>0?e.defaultVariant.trim():void 0,r=typeof e.defaultAgent==`string`&&e.defaultAgent.trim().length>0?e.defaultAgent.trim():void 0;t!==void 0&&p(t),n!==void 0&&h(n),r!==void 0&&_(r)}}catch(e){console.warn(`Failed to load defaults settings:`,e)}finally{y(!1)}})()},[]);let x=Q.useCallback(async(e,r)=>{let s=e&&r?`${e}/${r}`:void 0;p(s),h(void 0),o(void 0),i(void 0),a(s),e&&r&&d.find(t=>t.id===e)&&(t(e),n(r));try{await ye({defaultModel:s??``,defaultVariant:``});let e=await l(`/api/config/settings`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({defaultModel:s})});e.ok||console.warn(`Failed to save default model to server:`,e.status,e.statusText)}catch(e){console.warn(`Failed to save default model:`,e)}},[d,i,n,t,a,o]),S=`__default__`,C=Q.useCallback(t=>t===S?e(`settings.yuri.defaults.option.default`):t.charAt(0).toUpperCase()+t.slice(1),[e]),w=Q.useCallback(async e=>{let t=e===S?void 0:e||void 0;h(t),o(t),i(t);try{await ye({defaultVariant:t??``})}catch(e){console.warn(`Failed to save default variant:`,e)}},[i,o]),T=Q.useCallback(async e=>{let t=e||void 0;_(t),s(t),e&&r(e);try{await ye({defaultAgent:t??``})}catch(e){console.warn(`Failed to save default agent:`,e)}},[r,s]),E=Q.useMemo(()=>{if(!b.providerId||!b.modelId)return[];let e=d.find(e=>e.id===b.providerId)?.models.find(e=>e.id===b.modelId)?.variants;return e?Object.keys(e):[]},[b.modelId,b.providerId,d]),D=E.length>0;return Q.useEffect(()=>{!D&&m&&(h(void 0),o(void 0),i(void 0),ye({defaultVariant:``}).catch(()=>{}))},[m,i,o,D]),v?null:(0,$.jsxs)(Z,{label:e(`settings.yuri.defaults.title`),description:(0,$.jsxs)($.Fragment,{children:[e(`settings.yuri.defaults.summaryPrefix`),` `,b.providerId?(0,$.jsxs)(`span`,{className:`text-foreground`,children:[b.providerId,`/`,b.modelId,D?` (${m??e(`settings.yuri.defaults.option.defaultLowercase`)})`:``]}):(0,$.jsx)(`span`,{className:`text-foreground`,children:e(`settings.yuri.defaults.summaryOpenCodeDefault`)}),g&&(0,$.jsxs)($.Fragment,{children:[` / `,(0,$.jsx)(`span`,{className:`text-foreground`,children:g})]})]}),children:[(0,$.jsx)(Xi,{itemId:`sessions.default-model`,label:e(`settings.yuri.defaults.field.defaultModel`),children:(0,$.jsx)(ii,{providerId:b.providerId,modelId:b.modelId,onChange:x,className:`yuri-settings-inline-value`})}),(0,$.jsx)(Xi,{itemId:`sessions.default-thinking`,label:e(`settings.yuri.defaults.field.defaultThinking`),children:(0,$.jsxs)(Fr,{value:m??S,onValueChange:w,disabled:!D,children:[(0,$.jsx)(Pr,{className:`w-fit min-w-[120px]`,children:(0,$.jsx)(Ar,{placeholder:e(`settings.yuri.defaults.field.thinkingPlaceholder`),children:C(m??S)})}),(0,$.jsxs)(Nr,{children:[(0,$.jsx)(jr,{value:S,children:e(`settings.yuri.defaults.option.default`)}),E.map(e=>(0,$.jsx)(jr,{value:e,children:C(e)},e))]})]})}),(0,$.jsx)(Xi,{itemId:`sessions.default-agent`,label:e(`settings.yuri.defaults.field.defaultAgent`),children:(0,$.jsx)(bi,{agentName:g||``,onChange:T,className:`yuri-settings-inline-value`})}),(0,$.jsxs)(`div`,{"data-settings-item":`sessions.deletion-dialog`,className:`yuri-settings-group-row yuri-settings-split-row group cursor-pointer`,role:`button`,tabIndex:0,"aria-pressed":c,onClick:()=>u(!c),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),u(!c))},children:[(0,$.jsx)(`div`,{className:`yuri-settings-split-row-copy`,children:(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:e(`settings.yuri.defaults.field.showDeletionDialog`)})}),(0,$.jsx)(`div`,{className:`yuri-settings-split-row-control`,children:(0,$.jsx)(Wi,{checked:c,onChange:u,ariaLabel:e(`settings.yuri.defaults.field.showDeletionDialogAria`)})})]})]})},Xp=`You are generating a Conventional Commits subject line from the diffs of the selected files.`,Zp=[`You are a title generator. Output ONLY a thread title.`,`Name the main subject of the work.`,`Keep that subject across follow-ups, polish, commit, push, tidy, and review.`,`Switch only when the user clearly starts a different topic.`,`One line, no explanation.`,`Hard limit: never exceed 6 CJK characters (or 6 words for English). No modifiers. No verbs.`,`Use the language of the user messages.`,`Keep technical terms, numbers, filenames, and HTTP codes exact.`,`Never include tool names, summarizing, or generating.`,`Always output a meaningful title.`].join(`
29
+ `),Qp=()=>{let{t:e}=Ge(),[t,n]=Q.useState(``),[r,i]=Q.useState(``),[a,o]=Q.useState(Xp),[s,c]=Q.useState(Zp),[u,d]=Q.useState({commit:Xp,title:Zp}),[f,p]=Q.useState(!0),[m,h]=Q.useState(!1),[g,_]=Q.useState(!1),[v,y]=Q.useState(null);Q.useEffect(()=>{let e=!0;return(async()=>{try{let t=null,r=A()?.settings;if(r){let e=(await r.load())?.settings;e&&(t=e)}if(!t){let e=await l(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});e.ok&&(t=await e.json())}if(!e||!t)return;typeof t.summaryProviderID==`string`&&n(t.summaryProviderID),typeof t.summaryModelID==`string`&&i(t.summaryModelID),o(t.summaryCommitPrompt??Xp),c(t.summarySessionTitlePrompt??Zp),d({commit:t.summaryCommitPrompt??Xp,title:t.summarySessionTitlePrompt??Zp})}catch(e){console.warn(`Failed to load summary settings:`,e)}finally{e&&p(!1)}})(),()=>{e=!1}},[]);let b=He(async(t,r)=>{n(t),i(r);try{await ye({summaryModelMode:`provider`,summaryProviderID:t.trim(),summaryModelID:r.trim()})}catch(t){console.warn(`Failed to save summary model:`,t),J.error(e(`settings.yuri.defaults.summary.saveFailed`))}}),x=He(async()=>{h(!0);try{await ye({summaryCommitPrompt:a,summarySessionTitlePrompt:s}),d({commit:a,title:s})}catch(t){console.warn(`Failed to save summary prompts:`,t),J.error(e(`settings.yuri.defaults.summary.saveFailed`))}finally{h(!1)}}),S=He(async()=>{if(!g){y(null),_(!0);try{let n=await l(`/api/small-model/test`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({mode:`provider`,providerID:t,modelID:r})}),i=await n.json().catch(()=>null);if(n.ok&&i?.ok===!0){J.success(e(`settings.yuri.defaults.summary.testConnectionOk`));return}let a=e(`settings.yuri.defaults.summary.testError.provider`,{code:typeof i?.code==`string`?i.code:`generation_failed`});y(typeof i?.message==`string`&&i.message.trim()?`${a}\n${i.message}`:a)}catch{y(e(`settings.yuri.defaults.summary.testError.provider`,{code:`network_error`}))}finally{_(!1)}}});if(f)return null;let C=a!==u.commit||s!==u.title;return(0,$.jsxs)(`div`,{className:`yuri-settings-section-stack`,children:[(0,$.jsx)(Z,{description:v?(0,$.jsx)(`span`,{role:`alert`,className:`whitespace-pre-wrap break-words text-[var(--status-error)]`,children:v}):void 0,children:(0,$.jsxs)(Xi,{itemId:`summary-ai.configuration`,label:e(`settings.yuri.defaults.summary.providerModel`),description:e(`settings.yuri.defaults.summary.description`),children:[(0,$.jsx)(ii,{providerId:t,modelId:r,placeholder:e(`settings.yuri.defaults.summary.providerModelDefault`),onChange:(e,t)=>void b(e,t),className:`yuri-settings-inline-value`}),(0,$.jsx)(q,{"data-settings-item":`summary-ai.test-connection`,variant:`outline`,size:`sm`,onClick:()=>void S(),disabled:g,children:e(g?`settings.yuri.defaults.summary.testingConnection`:`settings.yuri.defaults.summary.testConnection`)})]})}),(0,$.jsxs)(Z,{label:e(`settings.yuri.defaults.summary.promptTitle`),actions:(0,$.jsx)(q,{size:`sm`,onClick:()=>void x(),disabled:m||!C,"aria-busy":m,children:e(m?`settings.common.actions.saving`:`settings.yuri.defaults.summary.save`)}),children:[(0,$.jsx)(Xi,{label:e(`settings.yuri.defaults.summary.commitPrompt`),className:`yuri-settings-split-row-stacked`,controlClassName:`w-full max-w-none justify-self-stretch`,children:(0,$.jsx)(Wr,{embedded:!0,value:a,onChange:e=>o(e.target.value),"aria-label":e(`settings.yuri.defaults.summary.commitPrompt`),outerClassName:`h-64`,className:`font-mono typography-meta`})}),(0,$.jsx)(Xi,{label:e(`settings.yuri.defaults.summary.sessionTitlePrompt`),className:`yuri-settings-split-row-stacked`,controlClassName:`w-full max-w-none justify-self-stretch`,children:(0,$.jsx)(Wr,{embedded:!0,value:s,onChange:e=>c(e.target.value),"aria-label":e(`settings.yuri.defaults.summary.sessionTitlePrompt`),outerClassName:`h-64`,className:`font-mono typography-meta`})})]})]})},$p={completion:{titleKey:`settings.notifications.page.template.defaults.completion.title`,messageKey:`settings.notifications.page.template.defaults.completion.message`},error:{titleKey:`settings.notifications.page.template.defaults.error.title`,messageKey:`settings.notifications.page.template.defaults.error.message`},question:{titleKey:`settings.notifications.page.template.defaults.question.title`,messageKey:`settings.notifications.page.template.defaults.question.message`},subtask:{titleKey:`settings.notifications.page.template.defaults.subtask.title`,messageKey:`settings.notifications.page.template.defaults.subtask.message`}},em={completion:`settings.notifications.page.template.event.completion`,subtask:`settings.notifications.page.template.event.subtask`,error:`settings.notifications.page.template.event.error`,question:`settings.notifications.page.template.event.question`},tm=()=>{let{t:e}=Ge(),t=Q.useMemo(()=>h(),[]),n=Q.useMemo(()=>g(),[]),r=Q.useMemo(()=>typeof window>`u`?!1:window.Capacitor?.isNativePlatform?.()===!0||window.location.protocol===`capacitor:`,[]),i=!t&&!n&&!r,a=G(e=>e.nativeNotificationsEnabled),o=G(e=>e.setNativeNotificationsEnabled),s=G(e=>e.notificationMode),c=G(e=>e.setNotificationMode),l=G(e=>e.notifyOnSubtasks),u=G(e=>e.setNotifyOnSubtasks),d=G(e=>e.notifyOnCompletion),f=G(e=>e.setNotifyOnCompletion),p=G(e=>e.notifyOnError),m=G(e=>e.setNotifyOnError),_=G(e=>e.notifyOnQuestion),v=G(e=>e.setNotifyOnQuestion),y=G(e=>e.notifyOnPermission),b=G(e=>e.setNotifyOnPermission),x=G(e=>e.notifyOnScheduledTasks),S=G(e=>e.setNotifyOnScheduledTasks),C=G(e=>e.notifyOnAssistants),w=G(e=>e.setNotifyOnAssistants),T=G(e=>e.notifyOnGoals),E=G(e=>e.setNotifyOnGoals),D=G(e=>e.notificationTemplates),O=G(e=>e.setNotificationTemplates),[k,j]=Q.useState(`default`),[M,N]=Q.useState(!1),[P,F]=Q.useState(!1),[I,L]=Q.useState(!1);Q.useEffect(()=>{if(!i){N(!1),F(!1);return}typeof Notification<`u`&&j(Notification.permission);let e=typeof window<`u`&&`serviceWorker`in navigator&&`PushManager`in window&&`Notification`in window;N(e),(async()=>{if(!e){F(!1);return}try{let e=await navigator.serviceWorker.getRegistration();if(!e){F(!1);return}let t=await e.pushManager.getSubscription();F(!!t)}catch{F(!1)}})()},[i]);let R=async n=>{if(t){o(n);return}if(!i){o(n);return}if(n&&typeof Notification<`u`&&Notification.permission==="default")try{let t=await Notification.requestPermission();j(t),t===`granted`?o(!0):J.error(e(`settings.notifications.page.toast.permissionDenied.title`),{description:e(`settings.notifications.page.toast.permissionDenied.description`)})}catch(t){console.error(`Failed to request notification permission:`,t),J.error(e(`settings.notifications.page.toast.requestPermissionFailed`))}else o(!!(n&&k===`granted`))},z=t||n||r||i&&typeof Notification<`u`&&Notification.permission===`granted`,B=(e,t,n)=>{O({...D,[e]:{...D[e],[t]:n}})},V=e=>{let t=(e+`=`.repeat((4-e.length%4)%4)).replace(/-/g,`+`).replace(/_/g,`/`),n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e+=1)r[e]=n.charCodeAt(e);return r},H=async(e,t,n)=>{let r=null,i=new Promise((e,i)=>{r=setTimeout(()=>{i(Error(n))},t)});try{return await Promise.race([e,i])}finally{r&&clearTimeout(r)}},U=async e=>{if(e.active)return;let t=e.installing||e.waiting;t&&t.state!==`activated`&&await H(new Promise(e=>{let n=()=>{t.state===`activated`&&(t.removeEventListener(`statechange`,n),e())};t.addEventListener(`statechange`,n),n()}),15e3,`Service worker activation timed out`)},W=async()=>{if(typeof navigator.serviceWorker.register!=`function`)throw Error(`navigator.serviceWorker.register unavailable`);let e=[{label:`no-options`,opts:null},{label:`scope-root`,opts:{scope:`/`}},{label:`type-classic`,opts:{type:`classic`}},{label:`type-classic-scope`,opts:{type:`classic`,scope:`/`}},{label:`updateViaCache-none`,opts:{type:`classic`,updateViaCache:`none`,scope:`/`}}],t=null;for(let n of e)try{let e=n.opts?navigator.serviceWorker.register(`/sw.js`,n.opts):navigator.serviceWorker.register(`/sw.js`);return await H(e,1e4,`Service worker registration timed out (${n.label})`)}catch(e){t=e}throw t instanceof Error?t:Error(`Service worker registration failed`)},ee=async()=>{if(!(`serviceWorker`in navigator))throw Error(`Service worker not supported`);let e=await navigator.serviceWorker.getRegistration();if(e)return e;let t=await W();try{await t.update()}catch{}return await U(t),t},te=e=>{let t=e,n=[`type=${typeof e}`,`toString=${String(e)}`,`name=${String(t?.name??``)}`,`message=${String(t?.message??``)}`],r=``;try{r=JSON.stringify(e)}catch{}return{summary:n.filter(Boolean).join(` | `),json:r,stack:typeof t?.stack==`string`?t.stack:``}},ne=async()=>{let t=A();if(!t?.notifications){J.error(e(`settings.notifications.page.toast.notificationsApiUnavailable`));return}try{await t.notifications.notifyAgentCompletion({title:e(`settings.notifications.page.testNotification.title`),body:e(`settings.notifications.page.testNotification.body`),tag:`yuri-test`})?J.success(e(`settings.notifications.page.toast.testNotificationSent`)):J.error(e(`settings.notifications.page.toast.testNotificationFailed`))}catch(t){console.error(`Test notification failed:`,t),J.error(e(`settings.notifications.page.toast.testNotificationFailed`))}},re=async()=>{if(!M){J.error(e(`settings.notifications.page.toast.pushUnsupported`));return}let t=A();if(!t?.push){J.error(e(`settings.notifications.page.toast.pushApiUnavailable`));return}L(!0);try{if(typeof Notification<`u`&&Notification.permission==="default"){let t=await Notification.requestPermission();if(j(t),t!==`granted`){J.error(e(`settings.notifications.page.toast.permissionDenied.title`),{description:e(`settings.notifications.page.toast.permissionDenied.enableInBrowser`)});return}}if(typeof Notification<`u`&&Notification.permission!==`granted`){J.error(e(`settings.notifications.page.toast.permissionDenied.title`),{description:e(`settings.notifications.page.toast.permissionDenied.enableInBrowser`)});return}let n=await t.push.getVapidPublicKey();if(!n?.publicKey){J.error(e(`settings.notifications.page.toast.pushKeyLoadFailed`));return}let r=await ee();await U(r);let i=await r.pushManager.getSubscription();if(!(`pushManager`in r)||!r.pushManager)throw Error(`PushManager unavailable (requires installed PWA + iOS 16.4+)`);let a=(i??await H(r.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:V(n.publicKey)}),15e3,`Push subscription timed out`)).toJSON(),o=a.keys;if(!a.endpoint||!o?.p256dh||!o.auth)throw Error(`Push subscription missing keys`);if(!(await H(t.push.subscribe({endpoint:a.endpoint,keys:{p256dh:o.p256dh,auth:o.auth},origin:typeof window<`u`?window.location.origin:void 0,platform:je()}),15e3,`Push subscribe request timed out`))?.ok){J.error(e(`settings.notifications.page.toast.enableBackgroundFailed`));return}F(!0),J.success(e(`settings.notifications.page.toast.backgroundEnabled`))}catch(t){console.error(`[Push] Enable failed:`,t);let n=te(t);J.error(e(`settings.notifications.page.toast.enableBackgroundFailed`),{description:n.summary})}finally{L(!1)}},ie=async()=>{if(!M){F(!1);return}let t=A();if(!t?.push){J.error(e(`settings.notifications.page.toast.pushApiUnavailable`));return}L(!0);try{let n=await(await ee()).pushManager.getSubscription();if(!n){F(!1);return}let r=n.endpoint;await n.unsubscribe(),await t.push.unsubscribe({endpoint:r}),F(!1),J.success(e(`settings.notifications.page.toast.backgroundDisabled`))}finally{L(!1)}},ae=i?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`block`,children:e(`settings.notifications.page.delivery.browserPermissionHint`)}),k===`denied`?(0,$.jsx)(`span`,{className:`mt-1 block text-[var(--status-error)]`,children:e(`settings.notifications.page.delivery.permissionDenied`)}):null,k===`granted`&&!a?(0,$.jsx)(`span`,{className:`mt-1 block`,children:e(`settings.notifications.page.delivery.permissionGrantedButDisabled`)}):null]}):n?e(`settings.notifications.page.delivery.vscodeHint`):void 0;return(0,$.jsxs)(`div`,{className:`yuri-settings-section-stack`,children:[(0,$.jsxs)(Z,{label:e(`settings.notifications.page.delivery.title`),description:ae,className:`yuri-settings-detail-group`,children:[(0,$.jsx)(Ji,{itemId:`notifications.delivery`,checked:a&&z,onChange:e=>{R(e)},label:e(`settings.notifications.page.delivery.enableLabel`),ariaLabel:e(`settings.notifications.page.delivery.enableAria`)}),a&&z&&!r?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ji,{checked:s===`always`,onChange:e=>c(e?`always`:`hidden-only`),label:e(`settings.notifications.page.delivery.focusedLabel`),ariaLabel:e(`settings.notifications.page.delivery.focusedAria`)}),(0,$.jsx)(`div`,{className:`yuri-settings-group-row flex items-center`,children:(0,$.jsx)(q,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>void ne(),children:e(`settings.notifications.page.delivery.testAction`)})})]}):null]}),a&&z?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Z,{label:e(`settings.notifications.page.events.title`),className:`yuri-settings-detail-group`,children:[(0,$.jsx)(Ji,{itemId:`notifications.events`,checked:d,onChange:f,label:e(`settings.notifications.page.events.completionLabel`),ariaLabel:e(`settings.notifications.page.events.completionAria`)}),(0,$.jsx)(Ji,{checked:l,onChange:u,label:e(`settings.notifications.page.events.subtaskLabel`),ariaLabel:e(`settings.notifications.page.events.subtaskAria`)}),(0,$.jsx)(Ji,{checked:p,onChange:m,label:e(`settings.notifications.page.events.errorLabel`),ariaLabel:e(`settings.notifications.page.events.errorAria`)}),(0,$.jsx)(Ji,{checked:_,onChange:v,label:e(`settings.notifications.page.events.questionLabel`),ariaLabel:e(`settings.notifications.page.events.questionAria`)}),(0,$.jsx)(Ji,{checked:y,onChange:b,label:e(`settings.notifications.page.events.permissionLabel`),ariaLabel:e(`settings.notifications.page.events.permissionAria`)}),(0,$.jsx)(Ji,{checked:x,onChange:S,label:e(`settings.notifications.page.events.scheduledTasksLabel`),ariaLabel:e(`settings.notifications.page.events.scheduledTasksAria`)}),(0,$.jsx)(Ji,{checked:C,onChange:w,label:e(`settings.notifications.page.events.assistantsLabel`),ariaLabel:e(`settings.notifications.page.events.assistantsAria`)}),(0,$.jsx)(Ji,{checked:T,onChange:E,label:e(`settings.notifications.page.events.goalsLabel`),ariaLabel:e(`settings.notifications.page.events.goalsAria`)})]}),r?null:(0,$.jsx)(Z,{label:e(`settings.notifications.page.template.title`),description:(0,$.jsxs)($.Fragment,{children:[e(`settings.notifications.page.template.variablesLabel`),` `,(0,$.jsx)(`code`,{className:`text-[var(--primary-base)]`,children:`{project_name}`}),` `,(0,$.jsx)(`code`,{className:`text-[var(--primary-base)]`,children:`{worktree}`}),` `,(0,$.jsx)(`code`,{className:`text-[var(--primary-base)]`,children:`{branch}`}),` `,(0,$.jsx)(`code`,{className:`text-[var(--primary-base)]`,children:`{session_name}`}),` `,(0,$.jsx)(`code`,{className:`text-[var(--primary-base)]`,children:`{agent_name}`}),` `,(0,$.jsx)(`code`,{className:`text-[var(--primary-base)]`,children:`{model_name}`}),` `,(0,$.jsx)(`code`,{className:`text-[var(--primary-base)]`,children:`{last_message}`})]}),className:`yuri-settings-detail-group`,children:[`completion`,`subtask`,`error`,`question`].map(t=>(0,$.jsxs)(`div`,{className:`yuri-settings-group-row`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label block font-normal text-foreground`,children:e(em[t])}),(0,$.jsxs)(`div`,{className:`mt-2 grid grid-cols-1 gap-2 md:grid-cols-2 md:gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`label`,{className:`typography-micro mb-1 block text-muted-foreground`,children:e(`settings.notifications.page.template.field.title`)}),(0,$.jsx)(Cn,{value:D[t].title,onChange:e=>B(t,`title`,e.target.value),className:`w-full`,placeholder:e($p[t].titleKey)})]}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`label`,{className:`typography-micro mb-1 block text-muted-foreground`,children:e(`settings.notifications.page.template.field.message`)}),(0,$.jsx)(Cn,{value:D[t].message,onChange:e=>B(t,`message`,e.target.value),className:`w-full`,placeholder:e($p[t].messageKey)})]})]})]},t))})]}):null,i?(0,$.jsx)(Z,{label:e(`settings.notifications.page.push.title`),className:`yuri-settings-detail-group`,children:(0,$.jsx)(Ji,{itemId:`notifications.push`,checked:M?P:!1,disabled:!M||I,onChange:e=>{e?re():ie()},ariaLabel:e(`settings.notifications.page.push.enableAria`),label:(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:K(`typography-ui-label`,M?`text-foreground`:`text-muted-foreground`),children:e(`settings.notifications.page.push.enableLabel`)}),I&&(0,$.jsx)(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-current text-muted-foreground animate-busy-pulse`,"aria-label":e(`settings.notifications.page.push.loadingAria`)})]}),description:e(M?`settings.notifications.page.push.supportedHint`:`settings.notifications.page.push.unsupportedHint`)})}):null]})},nm=e=>{let t=(0,Sa.c)(45),{className:n}=e,{t:r}=Ge(),i=sr(),a=nr(),o;t[0]===i.data?.providers?o=t[1]:(o=i.data?.providers??[],t[0]=i.data?.providers,t[1]=o);let s=o,c=i.data?.selectedId??null,l=ur(i.data),u;t[2]!==s||t[3]!==c||t[4]!==a||t[5]!==r?(u=e=>{!s.some(t=>t.id===e)||e===c||a.mutate(e,{onError:()=>{J.error(r(`settings.yuri.browserProvider.toast.selectFailed`))}})},t[2]=s,t[3]=c,t[4]=a,t[5]=r,t[6]=u):u=t[6];let d=He(u);if(!l)return null;let f;t[7]!==s||t[8]!==c?(f=s.find(e=>e.id===c)??null,t[7]=s,t[8]=c,t[9]=f):f=t[9];let p=f,m;t[10]===r?m=t[11]:(m=r(`settings.yuri.browserProvider.label`),t[10]=r,t[11]=m);let h;t[12]===r?h=t[13]:(h=r(`settings.yuri.browserProvider.info`),t[12]=r,t[13]=h);let g;t[14]===r?g=t[15]:(g=r(`settings.yuri.browserProvider.aria`),t[14]=r,t[15]=g);let _=p?.id,v=a.isPending,y;t[16]===r?y=t[17]:(y=r(`settings.yuri.browserProvider.aria`),t[16]=r,t[17]=y);let b;t[18]===r?b=t[19]:(b=r(`settings.yuri.browserProvider.placeholder`),t[18]=r,t[19]=b);let x;t[20]!==p?.name||t[21]!==r?(x=p?.name??r(`settings.yuri.browserProvider.placeholder`),t[20]=p?.name,t[21]=r,t[22]=x):x=t[22];let S;t[23]!==b||t[24]!==x?(S=(0,$.jsx)(Ar,{placeholder:b,children:x}),t[23]=b,t[24]=x,t[25]=S):S=t[25];let C;t[26]!==S||t[27]!==y?(C=(0,$.jsx)(Pr,{className:`yuri-settings-inline-value w-fit max-w-full`,"aria-label":y,children:S}),t[26]=S,t[27]=y,t[28]=C):C=t[28];let w;t[29]===s?w=t[30]:(w=s.map(rm),t[29]=s,t[30]=w);let T;t[31]===w?T=t[32]:(T=(0,$.jsx)(Nr,{children:w}),t[31]=w,t[32]=T);let E;t[33]!==d||t[34]!==a.isPending||t[35]!==C||t[36]!==T||t[37]!==_?(E=(0,$.jsxs)(Fr,{value:_,onValueChange:d,disabled:v,children:[C,T]}),t[33]=d,t[34]=a.isPending,t[35]=C,t[36]=T,t[37]=_,t[38]=E):E=t[38];let D;return t[39]!==n||t[40]!==E||t[41]!==m||t[42]!==h||t[43]!==g?(D=(0,$.jsx)(Ui,{itemId:`sessions.browser-provider`,label:m,description:h,descriptionPlacement:`outside`,groupClassName:n,ariaLabel:g,children:E}),t[39]=n,t[40]=E,t[41]=m,t[42]=h,t[43]=g,t[44]=D):D=t[44],D};function rm(e){return(0,$.jsx)(jr,{value:e.id,children:e.name},e.id)}var im=()=>{let{t:e}=Ge(),[t,n]=Q.useState(``),[r,i]=Q.useState(!0),[a,o]=Q.useState(!1),s=G(e=>e.showOpenCodeUpdateNotifications),c=G(e=>e.setShowOpenCodeUpdateNotifications);Q.useEffect(()=>{let e=!1;return(async()=>{try{let t=await l(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});if(!t.ok)return;let r=await t.json().catch(()=>null);if(e||!r)return;let i=typeof r.opencodeBinary==`string`?r.opencodeBinary.trim():``;n(i)}catch{}finally{e||i(!1)}})(),()=>{e=!0}},[]);let u=Q.useCallback(async()=>{if(!(typeof window>`u`)&&h())try{let e=await f();e.success&&e.path&&e.path.trim().length>0&&n(e.path.trim())}catch{}},[]),d=Q.useCallback(async()=>{o(!0);try{let n=t.trim(),r=n.length>=2&&(n.startsWith(`"`)&&n.endsWith(`"`)||n.startsWith(`'`)&&n.endsWith(`'`))?n.slice(1,-1).trim():n;await ye({opencodeBinary:r}),await _t({message:e(`settings.yuri.opencodeCli.actions.restartingOpenCode`),mode:`projects`,scopes:[`all`]})}finally{o(!1)}},[e,t]),p=Q.useCallback(e=>{c(e),ye({showOpenCodeUpdateNotifications:e})},[c]);return(0,$.jsxs)(Z,{actions:(0,$.jsx)(q,{type:`button`,size:`sm`,onClick:d,disabled:r||a,"aria-busy":a,children:e(a?`settings.common.actions.saving`:`settings.yuri.opencodeCli.actions.saveAndReload`)}),label:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{children:e(`settings.yuri.opencodeCli.title`)}),(0,$.jsxs)(En,{children:[(0,$.jsx)(wn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 cursor-help text-muted-foreground/60`})}),(0,$.jsxs)(Tn,{sideOffset:8,className:`max-w-xs`,children:[e(`settings.yuri.opencodeCli.tooltipPrefix`),` `,(0,$.jsx)(`code`,{className:`font-mono text-xs`,children:`opencode`}),e(`settings.yuri.opencodeCli.tooltipSuffix`)]})]})]}),description:(0,$.jsxs)($.Fragment,{children:[e(`settings.yuri.opencodeCli.tipPrefix`),` `,(0,$.jsx)(`span`,{className:`font-mono`,children:`OPENCODE_BINARY`}),` `,e(`settings.yuri.opencodeCli.tipMiddle`),` `,(0,$.jsx)(`span`,{className:`font-mono`,children:`~/.config/yuri/settings.json`}),`.`]}),children:[(0,$.jsx)(Xi,{itemId:`sessions.opencode-binary`,label:e(`settings.yuri.opencodeCli.field.binaryPath`),children:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center justify-end gap-2`,children:[(0,$.jsx)(Cn,{value:t,onChange:e=>n(e.target.value),placeholder:e(`settings.yuri.opencodeCli.field.binaryPathPlaceholder`),disabled:r||a,className:`h-7 min-w-0 flex-1 font-mono text-xs`}),(0,$.jsx)(q,{type:`button`,variant:`outline`,size:`xs`,onClick:u,disabled:r||a||!h(),className:`h-7 w-7 p-0`,"aria-label":e(`settings.yuri.opencodeCli.actions.browseAria`),title:e(`settings.yuri.opencodeCli.actions.browse`),children:(0,$.jsx)(X,{name:`folder`,className:`h-4 w-4`})})]})}),(0,$.jsxs)(`div`,{"data-settings-item":`sessions.opencode-update-notifications`,className:`yuri-settings-group-row yuri-settings-split-row`,children:[(0,$.jsx)(`div`,{className:`yuri-settings-split-row-copy`,children:(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.yuri.opencodeCli.field.showUpdateNotifications`)})}),(0,$.jsx)(`div`,{className:`yuri-settings-split-row-control`,children:(0,$.jsx)(Wi,{checked:s,onChange:p,ariaLabel:e(`settings.yuri.opencodeCli.field.showUpdateNotificationsAria`)})})]})]})},am=[{id:`auto`,labelKey:`settings.yuri.desktopNetwork.option.windowControlsAuto`},{id:`left`,labelKey:`settings.yuri.desktopNetwork.option.windowControlsLeft`},{id:`right`,labelKey:`settings.yuri.desktopNetwork.option.windowControlsRight`}],om=()=>{let{t:e}=Ge(),t=Q.useCallback(t=>e(t),[e]),n=h()&&O(),r=w(),i=G(e=>e.desktopWindowControlsPosition),a=G(e=>e.setDesktopWindowControlsPosition),[o,s]=Q.useState(!1),[c,l]=Q.useState(!1),[u,d]=Q.useState(!1),[f,m]=Q.useState(!1),[g,b]=Q.useState(!1),[x,T]=Q.useState(!1),[E,D]=Q.useState(!1),[k,A]=Q.useState(!1),[j,M]=Q.useState(!1),[N,P]=Q.useState(null);Q.useEffect(()=>{if(!n){s(!1);return}let e=!1;return(async()=>{let t=await C();e||(s(t?.supported===!0),l(t?.enabled===!0))})(),()=>{e=!0}},[n]),Q.useEffect(()=>{if(!n){m(!1);return}let e=!1;return(async()=>{let t=await S();e||(m(t?.supported===!0),b(t?.enabled===!0))})(),()=>{e=!0}},[n]),Q.useEffect(()=>{if(!n){D(!1);return}let e=!1;return(async()=>{let t=await y();e||(D(t?.supported===!0),A(t?.enabled===!0))})(),()=>{e=!0}},[n]);let F=Q.useCallback(e=>{a(e),ye({desktopWindowControlsPosition:e})},[a]),I=Q.useCallback(async()=>{if(!o||u)return;let t=!c;l(t),d(!0),P(null);try{let n=await p(t);if(!n?.supported)throw Error(e(`settings.yuri.desktopNetwork.error.launchAtLoginUnsupported`));l(n.enabled)}catch(n){l(!t),P(n instanceof Error?n.message:e(`settings.yuri.desktopNetwork.error.launchAtLoginSaveFailed`))}finally{d(!1)}},[u,c,o,e]),L=Q.useCallback(async()=>{if(!f||x)return;let t=!g;b(t),T(!0),P(null);try{let n=await _(t);if(!n)throw Error(e(`settings.yuri.desktopNetwork.error.minimizeToTraySaveFailed`));if(!n.supported)throw Error(e(`settings.yuri.desktopNetwork.error.minimizeToTrayUnsupported`));b(n.enabled)}catch(n){b(!t),P(n instanceof Error?n.message:e(`settings.yuri.desktopNetwork.error.minimizeToTraySaveFailed`))}finally{T(!1)}},[x,g,f,e]),R=Q.useCallback(async()=>{if(!E||j)return;let t=!k;A(t),M(!0),P(null);try{let n=await v(t);if(!n?.supported)throw Error(e(`settings.yuri.desktopNetwork.error.keepAwakeUnsupported`));A(n.enabled)}catch(n){A(!t),P(n instanceof Error?n.message:e(`settings.yuri.desktopNetwork.error.keepAwakeSaveFailed`))}finally{M(!1)}},[j,k,E,e]);return!n&&!r?null:(0,$.jsxs)(`div`,{className:`yuri-settings-section-stack`,children:[r?(0,$.jsx)(Z,{label:e(`settings.yuri.desktopNetwork.field.windowControlsPosition`),children:(0,$.jsx)(Xi,{itemId:`sessions.desktop-window-controls-position`,label:e(`settings.yuri.desktopNetwork.field.windowControlsPosition`),description:e(`settings.yuri.desktopNetwork.field.windowControlsPositionDescription`),children:(0,$.jsx)(`div`,{className:`flex flex-wrap items-center justify-end gap-1`,role:`group`,"aria-label":e(`settings.yuri.desktopNetwork.field.windowControlsPositionAria`),children:am.map(e=>(0,$.jsx)(q,{type:`button`,variant:`chip`,size:`xs`,className:`!font-normal`,"aria-pressed":i===e.id,onClick:()=>F(e.id),children:t(e.labelKey)},e.id))})})}):null,!n||!(o||f||E||N)?null:(0,$.jsxs)(Z,{label:e(`settings.yuri.desktopNetwork.title`),children:[o?(0,$.jsxs)(`div`,{"data-settings-item":`sessions.desktop-launch-at-login`,className:`yuri-settings-group-row yuri-settings-split-row group cursor-pointer`,role:`button`,tabIndex:0,onClick:I,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),I())},children:[(0,$.jsxs)(`div`,{className:`yuri-settings-split-row-copy`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:e(`settings.yuri.desktopNetwork.field.launchAtLogin`)}),(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:e(`settings.yuri.desktopNetwork.field.launchAtLoginDescription`)})]}),(0,$.jsx)(`div`,{className:`yuri-settings-split-row-control`,children:(0,$.jsx)(Wi,{checked:c,onChange:I,ariaLabel:e(`settings.yuri.desktopNetwork.field.launchAtLoginAria`),disabled:u})})]}):null,f?(0,$.jsxs)(`div`,{"data-settings-item":`sessions.desktop-minimize-to-tray`,className:`yuri-settings-group-row yuri-settings-split-row group cursor-pointer`,role:`button`,tabIndex:0,onClick:L,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),L())},children:[(0,$.jsxs)(`div`,{className:`yuri-settings-split-row-copy`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:e(`settings.yuri.desktopNetwork.field.minimizeToTray`)}),(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:e(`settings.yuri.desktopNetwork.field.minimizeToTrayDescription`)})]}),(0,$.jsx)(`div`,{className:`yuri-settings-split-row-control`,children:(0,$.jsx)(Wi,{checked:g,onChange:L,ariaLabel:e(`settings.yuri.desktopNetwork.field.minimizeToTrayAria`),disabled:x})})]}):null,E?(0,$.jsxs)(`div`,{"data-settings-item":`sessions.desktop-keep-awake`,className:`yuri-settings-group-row yuri-settings-split-row group cursor-pointer`,role:`button`,tabIndex:0,onClick:R,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),R())},children:[(0,$.jsxs)(`div`,{className:`yuri-settings-split-row-copy`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:e(`settings.yuri.desktopNetwork.field.keepAwake`)}),(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:e(`settings.yuri.desktopNetwork.field.keepAwakeDescription`)})]}),(0,$.jsx)(`div`,{className:`yuri-settings-split-row-control`,children:(0,$.jsx)(Wi,{checked:k,onChange:R,ariaLabel:e(`settings.yuri.desktopNetwork.field.keepAwakeAria`),disabled:j})})]}):null,N?(0,$.jsx)(`div`,{className:`yuri-settings-group-row typography-meta text-[var(--status-error)]`,children:N}):null]})]})},sm=new Set([`shift`,`control`,`alt`,`meta`]),cm=e=>{if(sm.has(e.key.toLowerCase()))return null;let t=[];(e.metaKey||e.ctrlKey)&&t.push(`mod`),e.shiftKey&&t.push(`shift`),e.altKey&&t.push(`alt`);let n=mr(e.key);return n?(t.push(n),dr(t.join(`+`))):null},lm=()=>{let e=(0,Sa.c)(59),{t}=Ge(),n;e[0]===t?n=e[1]:(n=e=>t(e),e[0]=t,e[1]=n);let r=n,i=G(um),a=G(dm),o=G(fm),s=G(pm),c;if(e[2]===Symbol.for(`react.memo_cache_sentinel`)){bb0:{let e=vr();if(!g()){c=e;break bb0}c=e.filter(mm)}e[2]=c}else c=e[2];let l=c,u;e[3]===r?u=e[4]:(u=(e,t)=>{let n=`settings.yuri.keyboardShortcuts.action.${e}.label`,i=r(n);return i===n?t:i},e[3]=r,e[4]=u);let d=u,[f,p]=Q.useState(null),m;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(m={},e[5]=m):m=e[5];let[h,_]=Q.useState(m),[v,y]=Q.useState(``),[b,x]=Q.useState(``),[S,C]=Q.useState(null),w=hm,T;e[6]===i?T=e[7]:(T=(e,t)=>{let n=dr(t);for(let t of l){if(t.id===e)continue;let r=rr(t.id,i);if(dr(r)===n)return t.id}return null},e[6]=i,e[7]=T);let E=T,D;e[8]!==E||e[9]!==a||e[10]!==i||e[11]!==t?(D=(e,n)=>{let r=dr(n),o=E(e,r);if(o){C({actionId:e,combo:r,conflictActionId:o}),y(``);return}let s={...i,[e]:r};a(e,r),w(s),C(null),y(``),x(ar(r)?t(`settings.yuri.keyboardShortcuts.warning.riskyBrowserShortcut`):``),_(t=>{let n={...t};return delete n[e],n})},e[8]=E,e[9]=a,e[10]=i,e[11]=t,e[12]=D):D=e[12];let O=D,k;e[13]!==S||e[14]!==a||e[15]!==i||e[16]!==t?(k=()=>{if(!S)return;let e={...i,[S.conflictActionId]:_r,[S.actionId]:S.combo};a(S.conflictActionId,_r),a(S.actionId,S.combo),w(e),C(null),y(``),x(ar(S.combo)?t(`settings.yuri.keyboardShortcuts.warning.riskyBrowserShortcut`):``),_(e=>{let t={...e};return delete t[S.actionId],t})},e[13]=S,e[14]=a,e[15]=i,e[16]=t,e[17]=k):k=e[17];let A=k,j;e[18]!==o||e[19]!==i?(j=e=>{let t={...i};delete t[e],o(e),w(t),_(t=>{let n={...t};return delete n[e],n}),C(null),y(``),x(``)},e[18]=o,e[19]=i,e[20]=j):j=e[20];let M=j,N;e[21]===t?N=e[22]:(N=t(`settings.yuri.keyboardShortcuts.title`),e[21]=t,e[22]=N);let P;e[23]===N?P=e[24]:(P=(0,$.jsx)(`span`,{children:N}),e[23]=N,e[24]=P);let F;e[25]===s?F=e[26]:(F=()=>{s(),w({}),_({}),C(null),y(``),x(``)},e[25]=s,e[26]=F);let I;e[27]===t?I=e[28]:(I=t(`settings.yuri.keyboardShortcuts.actions.resetAll`),e[27]=t,e[28]=I);let L;e[29]!==F||e[30]!==I?(L=(0,$.jsx)(q,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:F,children:I}),e[29]=F,e[30]=I,e[31]=L):L=e[31];let R;e[32]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,$.jsx)(wn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),e[32]=R):R=e[32];let z;e[33]===t?z=e[34]:(z=t(`settings.yuri.keyboardShortcuts.tooltip`),e[33]=t,e[34]=z);let B;e[35]===z?B=e[36]:(B=(0,$.jsxs)(En,{children:[R,(0,$.jsx)(Tn,{sideOffset:8,className:`max-w-xs`,children:z})]}),e[35]=z,e[36]=B);let V;e[37]!==L||e[38]!==B||e[39]!==P?(V=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[P,L,B]}),e[37]=L,e[38]=B,e[39]=P,e[40]=V):V=e[40];let H;e[41]!==A||e[42]!==v||e[43]!==S||e[44]!==t||e[45]!==b?(H=(v||b||S)&&(0,$.jsxs)(`div`,{className:`mb-2 space-y-2 px-1`,children:[S&&(0,$.jsxs)(`div`,{className:`rounded-lg border border-[var(--status-warning-border)] bg-[var(--status-warning-background)] p-3 flex flex-col sm:flex-row sm:items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`typography-meta text-foreground`,children:t(`settings.yuri.keyboardShortcuts.overwritePrompt`)}),(0,$.jsxs)(`div`,{className:`flex gap-2 shrink-0`,children:[(0,$.jsx)(q,{type:`button`,size:`xs`,className:`!font-normal`,onClick:A,children:t(`settings.yuri.keyboardShortcuts.actions.overwrite`)}),(0,$.jsx)(q,{type:`button`,size:`xs`,className:`!font-normal`,variant:`ghost`,onClick:()=>C(null),children:t(`settings.common.actions.cancel`)})]})]}),v&&(0,$.jsx)(`div`,{className:`rounded-lg border border-[var(--status-error-border)] bg-[var(--status-error-background)] p-3 typography-meta text-foreground`,children:v}),b&&(0,$.jsx)(`div`,{className:`rounded-lg border border-[var(--status-warning-border)] bg-[var(--status-warning-background)] p-3 typography-meta text-foreground`,children:b})]}),e[41]=A,e[42]=v,e[43]=S,e[44]=t,e[45]=b,e[46]=H):H=e[46];let U;e[47]!==d||e[48]!==f||e[49]!==h||e[50]!==M||e[51]!==O||e[52]!==i||e[53]!==t?(U=l.map(e=>{let n=rr(e.id,i),r=h[e.id],a=r??n,o=typeof r==`string`&&dr(r)!==dr(n);return(0,$.jsxs)(Xi,{label:d(e.id,e.label),children:[(0,$.jsx)(Cn,{readOnly:!0,value:f===e.id?t(`settings.yuri.keyboardShortcuts.field.pressKeys`):pr(a),onFocus:()=>{p(e.id),y(``)},onBlur:()=>{f===e.id&&p(null)},onKeyDown:t=>{if(t.preventDefault(),t.stopPropagation(),t.key===`Escape`){p(null);return}let n=cm(t);n&&(_(t=>({...t,[e.id]:n})),p(null),C(null),y(``))},className:`w-40 min-w-0 typography-ui-label text-right`}),(0,$.jsx)(q,{type:`button`,variant:`secondary`,size:`xs`,className:`!font-normal`,onClick:()=>{let n=h[e.id];if(!n){y(t(`settings.yuri.keyboardShortcuts.error.captureFirst`));return}O(e.id,n)},disabled:!o,children:t(`settings.common.actions.saveChanges`)}),(0,$.jsx)(q,{type:`button`,size:`xs`,className:`!font-normal`,variant:`ghost`,onClick:()=>M(e.id),children:t(`settings.common.actions.reset`)})]},e.id)}),e[47]=d,e[48]=f,e[49]=h,e[50]=M,e[51]=O,e[52]=i,e[53]=t,e[54]=U):U=e[54];let W;return e[55]!==V||e[56]!==H||e[57]!==U?(W=(0,$.jsxs)(Z,{itemId:`shortcuts.keyboard-shortcuts`,label:V,children:[H,U]}),e[55]=V,e[56]=H,e[57]=U,e[58]=W):W=e[58],W};function um(e){return e.shortcutOverrides}function dm(e){return e.setShortcutOverride}function fm(e){return e.clearShortcutOverride}function pm(e){return e.resetAllShortcutOverrides}function mm(e){return e.id!==`toggle_prompt_navigator`}function hm(e){ye({shortcutOverrides:e})}var gm=()=>{let e=(0,Sa.c)(2),[t,n]=Q.useState(0),i,a;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=()=>r(()=>n(Em)),a=[],e[0]=i,e[1]=a):(i=e[0],a=e[1]),Q.useEffect(i,a),t},_m=e=>{let t=(0,Sa.c)(25),{section:n,flowMobile:r}=e,i=r!==void 0&&r,{isMobile:a}=wr();gm();let o;t[0]===a?o=t[1]:(o=a&&d(),t[0]=a,t[1]=o);let s=o,c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=g(),t[2]=c):c=t[2];let l=c,u;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(u=h()&&(O()||w()),t[3]=u):u=t[3];let f=u;if(!n){let e;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Op,{}),t[4]=e):e=t[4];let n;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`div`,{className:`yuri-settings-page-section`,children:(0,$.jsx)(Yp,{})}),t[5]=n):n=t[5];let r,i,a,o;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(`div`,{className:`yuri-settings-page-section`,children:(0,$.jsx)(Qp,{})}),a=f&&(0,$.jsx)(`div`,{className:`yuri-settings-page-section`,children:(0,$.jsx)(om,{})}),o=!l&&(0,$.jsx)(`div`,{className:`yuri-settings-page-section`,children:(0,$.jsx)(im,{})}),r=(0,$.jsx)(nm,{className:`yuri-settings-page-section`}),t[6]=r,t[7]=i,t[8]=a,t[9]=o):(r=t[6],i=t[7],a=t[8],o=t[9]);let c;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(`div`,{className:`yuri-settings-page-section`,children:(0,$.jsx)(zp,{})}),t[10]=c):c=t[10];let u;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(`div`,{className:`yuri-settings-page-section`,children:(0,$.jsx)(qp,{})}),t[11]=u):u=t[11];let d;t[12]===s?d=t[13]:(d=s&&(0,$.jsx)(`div`,{className:`yuri-settings-page-section`,children:(0,$.jsx)(Aa,{})}),t[12]=s,t[13]=d);let p;return t[14]===d?p=t[15]:(p=(0,$.jsx)(Ur,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`yuri-settings-page-content yuri-page-body mx-auto max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[e,n,i,a,o,r,c,u,d]})}),t[14]=d,t[15]=p),p}let p;t[16]!==i||t[17]!==n?(p=()=>{switch(n){case`visual`:return(0,$.jsx)(ym,{mobile:i});case`chat`:return(0,$.jsx)(bm,{});case`sessions`:return(0,$.jsx)(xm,{});case`summary-ai`:return(0,$.jsx)(Qp,{});case`shortcuts`:return(0,$.jsx)(vm,{});case`git`:return(0,$.jsx)(Sm,{});case`github`:return(0,$.jsx)(Cm,{});case`notifications`:return(0,$.jsx)(wm,{});case`voice`:return(0,$.jsx)(Tm,{});default:return null}},t[16]=i,t[17]=n,t[18]=p):p=t[18];let m=p,_;t[19]===m?_=t[20]:(_=m(),t[19]=m,t[20]=_);let v;t[21]===_?v=t[22]:(v=(0,$.jsx)(`div`,{className:`yuri-settings-page-content yuri-page-body mx-auto max-w-3xl p-3 sm:p-6 sm:pt-8`,children:_}),t[21]=_,t[22]=v);let y=v;if(i)return y;let b;return t[23]===y?b=t[24]:(b=(0,$.jsx)(Ur,{outerClassName:`h-full`,className:`w-full`,children:y}),t[23]=y,t[24]=b),b},vm=()=>{let e=(0,Sa.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(lm,{}),e[0]=t):t=e[0],t},ym=e=>{let t=(0,Sa.c)(5),{mobile:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=g(),t[0]=r):r=t[0];let i=r,a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=i?[]:[`weekStart`],t[1]=a):a=t[1];let o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=[`theme`,`sidebarBrand`,`pwaInstallName`,`pwaOrientation`,`mobileKeyboardMode`,`timeFormat`,...a,`iosNativeUi`,`fontSize`,`codeFontSize`,`terminalFontSize`,`editorFontSize`,`fileEditorKeymap`,`spacing`,`inputBarOffset`,...i?[]:[`terminalQuickKeys`],`reportUsage`],t[2]=o):o=t[2];let s;return t[3]===n?s=t[4]:(s=(0,$.jsx)(Op,{mobile:n,visibleSettings:o}),t[3]=n,t[4]=s),s},bm=()=>{let e=(0,Sa.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(Op,{visibleSettings:[`chatRenderMode`,`messageTransport`,`diffLayout`,`followUpBehavior`,`sessionGoal`,`questionAutoDelegate`,`sessionAssist`,`subagentReadOnlyBanner`,`reasoning`,`collapsibleUserMessages`,`showAssistantTps`,`persistDraft`,`inputSpellcheck`]}),e[0]=t):t=e[0],t},xm=()=>{let e=(0,Sa.c)(8),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=g(),e[0]=t):t=e[0];let n=t;gm();let r;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=h()&&(O()||w()),e[1]=r):r=e[1];let i=r,a,o,s,c;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(Yp,{}),o=i&&(0,$.jsx)(`div`,{className:`yuri-settings-page-section`,children:(0,$.jsx)(om,{})}),s=!n&&(0,$.jsx)(`div`,{className:`yuri-settings-page-section`,children:(0,$.jsx)(im,{})}),c=(0,$.jsx)(nm,{}),e[2]=a,e[3]=o,e[4]=s,e[5]=c):(a=e[2],o=e[3],s=e[4],c=e[5]);let l;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(`div`,{className:`yuri-settings-page-section`,children:(0,$.jsx)(zp,{})}),e[6]=l):l=e[6];let u;return e[7]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsxs)(`div`,{className:`yuri-settings-section-stack`,children:[a,o,s,c,l,(0,$.jsx)(`div`,{className:`yuri-settings-page-section`,children:(0,$.jsx)(qp,{})})]}),e[7]=u):u=e[7],u},Sm=()=>{let e=(0,Sa.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:`yuri-settings-section-stack`,children:(0,$.jsx)(ep,{})}),e[0]=t):t=e[0],t},Cm=()=>{let e=(0,Sa.c)(1);if(g())return null;let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(tp,{}),e[0]=t):t=e[0],t},wm=()=>{let e=(0,Sa.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(tm,{}),e[0]=t):t=e[0],t},Tm=()=>{let e=(0,Sa.c)(1);if(g())return null;let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(ga,{}),e[0]=t):t=e[0],t};function Em(e){return e+1}var Dm=()=>{let e=(0,Sa.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(jl,{children:(0,$.jsx)(yi,{mode:`page`})}),e[0]=t):t=e[0],t};function Om(){let e=(0,Sa.c)(11),t=Hi().data?.entries,n;e[0]===t?n=e[1]:(n=t?.map(km)??[],e[0]=t,e[1]=n);let r=Yi(n),i=Qi(),a;e[2]===t?a=e[3]:(a=t??[],e[2]=t,e[3]=a);let o;if(e[4]!==r||e[5]!==i||e[6]!==a){let t;e[8]!==r||e[9]!==i?(t=e=>{let t=r.data?.[e.spec];if(t?.kind===`npm-ok`&&t.hasUpdate)return!0;let n=oi(e.spec,e.sourcePath);return n?.kind===`package`&&i.data!==void 0&&Ni(Qr(n,i.data))===`available`},e[8]=r,e[9]=i,e[10]=t):t=e[10],o=a.some(t),e[4]=r,e[5]=i,e[6]=a,e[7]=o}else o=e[7];return o}function km(e){return e.spec}var Am=[{id:`remote-instances.remote-desktop`,page:`remote-instances`,titleKey:`settings.remoteDesktop.enable`,descriptionKey:`settings.remoteDesktop.description`,keywords:[`remote desktop`,`screen sharing`,`control`,`远程桌面`,`投屏`],isAvailable:e=>e.isDesktopLocalOrigin},{id:`remote-instances.remote-desktop-screen`,page:`remote-instances`,titleKey:`settings.remoteDesktop.screen`,descriptionKey:`settings.remoteDesktop.screenHint`,keywords:[`permission`,`screen recording`,`屏幕录制`,`权限`],isAvailable:e=>e.isDesktopLocalOrigin&&e.isMac},{id:`remote-instances.remote-desktop-accessibility`,page:`remote-instances`,titleKey:`settings.remoteDesktop.accessibility`,descriptionKey:`settings.remoteDesktop.accessibilityHint`,keywords:[`permission`,`accessibility`,`input`,`辅助功能`],isAvailable:e=>e.isDesktopLocalOrigin&&e.isMac},{id:`chat.question-auto-delegate`,page:`chat`,titleKey:`settings.chat.questionDelegate.label`,descriptionKey:`settings.chat.questionDelegate.description`,keywords:[`question`,`auto`,`delegate`,`30`,`subagent`,`托管`,`倒计时`]},{id:`instances.manage`,page:`instances`,titleKey:`mobile.settings.switchInstance`,keywords:[`instance`,`server`,`connection`,`switch`],isAvailable:e=>e.isMobile},{id:`global-config.editor`,page:`global-config`,titleKey:`settings.globalConfig.title`,descriptionKey:`settings.globalConfig.description`,keywords:[`opencode.json`,`opencode.jsonc`,`json`,`jsonc`]},{id:`appearance.language`,page:`appearance`,titleKey:`settings.appearance.language.label`,descriptionKey:`settings.appearance.language.description`,keywords:[`locale`,`translation`,`ui language`]},{id:`appearance.time-format`,page:`appearance`,titleKey:`settings.yuri.visual.field.timeFormat`,keywords:[`clock`,`12h`,`24h`]},{id:`appearance.week-start`,page:`appearance`,titleKey:`settings.yuri.visual.field.weekStartsOn`,keywords:[`calendar`,`monday`,`sunday`],isAvailable:e=>!e.isVSCode},{id:`appearance.light-theme`,page:`appearance`,titleKey:`settings.yuri.visual.field.lightTheme`,keywords:[`theme`,`color`,`light mode`],isAvailable:e=>!e.isVSCode},{id:`appearance.dark-theme`,page:`appearance`,titleKey:`settings.yuri.visual.field.darkTheme`,keywords:[`theme`,`color`,`dark mode`],isAvailable:e=>!e.isVSCode},{id:`appearance.window-transparency`,page:`appearance`,titleKey:`settings.yuri.visual.field.macVibrancy`,descriptionKey:`settings.yuri.visual.field.macVibrancyHint`,keywords:[`transparent`,`transparency`,`vibrancy`,`blur`,`macos`,`opaque`],isAvailable:e=>e.isDesktopLocalOrigin},{id:`appearance.dock-badge`,page:`appearance`,titleKey:`settings.yuri.visual.field.dockBadge`,descriptionKey:`settings.yuri.visual.field.dockBadgeHint`,keywords:[`dock`,`badge`,`unread`,`unseen`,`counter`,`count`,`notification`,`macos`],isAvailable:e=>e.isMac},{id:`appearance.sidebar-brand`,page:`appearance`,titleKey:`settings.yuri.visual.field.sidebarBrand`,descriptionKey:`settings.yuri.visual.field.sidebarBrandHint`,keywords:[`logo`,`brand`,`wordmark`,`sidebar`]},{id:`appearance.pwa-install-name`,page:`appearance`,titleKey:`settings.yuri.visual.field.installAppName`,descriptionKey:`settings.yuri.visual.field.installAppNameHint`,keywords:[`pwa`,`installed app`],isAvailable:e=>e.isWeb&&!e.isDesktop&&!e.isVSCode},{id:`appearance.pwa-orientation`,page:`appearance`,titleKey:`settings.yuri.visual.field.installOrientation`,descriptionKey:`settings.yuri.visual.field.installOrientationHint`,keywords:[`pwa`,`portrait`,`landscape`],isAvailable:e=>e.isWeb&&!e.isDesktop&&!e.isVSCode},{id:`appearance.mobile-keyboard-mode`,page:`appearance`,titleKey:`settings.yuri.visual.field.mobileKeyboardMode`,descriptionKey:`settings.yuri.visual.field.mobileKeyboardModeHint`,keywords:[`mobile`,`keyboard`,`resize`],isAvailable:e=>e.isMobile&&e.isWeb&&!e.isDesktop&&!e.isVSCode},{id:`appearance.ios-native-ui`,page:`appearance`,titleKey:`settings.yuri.visual.field.iosNativeUi`,descriptionKey:`settings.yuri.visual.field.iosNativeUiHint`,keywords:[`ios`,`native`,`webview`,`composer`,`tab bar`,`live activity`],isAvailable:()=>Lr()},{id:`appearance.interface-font-size`,page:`appearance`,titleKey:`settings.yuri.visual.field.interfaceFontSize`,keywords:[`font`,`text size`,`ui scale`]},{id:`appearance.code-font-size`,page:`appearance`,titleKey:`settings.yuri.visual.field.codeFontSize`,keywords:[`code`,`font`,`text size`,`diff`]},{id:`appearance.terminal-font-size`,page:`appearance`,titleKey:`settings.yuri.visual.field.terminalFontSize`,keywords:[`terminal`,`font`,`text size`]},{id:`appearance.editor-font-size`,page:`appearance`,titleKey:`settings.yuri.visual.field.editorFontSize`,keywords:[`editor`,`font`,`text size`,`code`]},{id:`appearance.spacing-density`,page:`appearance`,titleKey:`settings.yuri.visual.field.spacingDensity`,keywords:[`density`,`compact`,`comfortable`,`spacing`]},{id:`appearance.input-bar-offset`,page:`appearance`,titleKey:`settings.yuri.visual.field.inputBarOffset`,descriptionKey:`settings.yuri.visual.field.inputBarOffsetTooltip`,keywords:[`input`,`home bar`,`offset`]},{id:`appearance.file-editor-keymap`,page:`appearance`,titleKey:`settings.yuri.visual.field.fileEditorKeymap`,keywords:[`editor`,`vim`,`keymap`]},{id:`appearance.terminal-quick-keys`,page:`appearance`,titleKey:`settings.yuri.visual.field.terminalQuickKeys`,descriptionKey:`settings.yuri.visual.field.terminalQuickKeysTooltip`,keywords:[`terminal`,`keyboard`,`esc`,`ctrl`,`arrows`],isAvailable:e=>!e.isMobile&&!e.isDesktop&&!e.isVSCode},{id:`about.check-updates`,page:`about`,titleKey:`settings.yuri.about.actions.checkForUpdates`,keywords:[`updates`,`version`,`ota`]},{id:`about.host-update`,page:`about`,titleKey:`settings.yuri.about.hostUpdate.title`,descriptionKey:`settings.yuri.about.hostUpdate.description`,keywords:[`remote`,`host`,`relay`,`beta`,`ota`,`version`],isAvailable:e=>!e.isDesktopLocalOrigin},{id:`about.feedback`,page:`about`,titleKey:`settings.yuri.about.actions.submitFeedback`,keywords:[`feedback`,`issues`,`bugs`,`github`]},{id:`about.beta-updates`,page:`about`,titleKey:`settings.yuri.about.betaUpdates.label`,descriptionKey:`settings.yuri.about.betaUpdates.description`,keywords:[`beta`,`updates`,`channel`,`ota`],isAvailable:e=>e.isDesktop||Ae()},{id:`about.diagnostics`,page:`about`,titleKey:`settings.yuri.about.diagnostics.label`,keywords:[`diagnostics`,`logs`,`feat`,`transcript`,`task`]},{id:`about.export-diagnostics`,page:`about`,titleKey:`settings.yuri.about.diagnostics.export`,keywords:[`diagnostics`,`logs`,`export`,`feat`,`transcript`,`task`],isAvailable:()=>Yt()},{id:`appearance.usage-reports`,page:`appearance`,titleKey:`settings.yuri.visual.field.sendAnonymousUsageReports`,descriptionKey:`settings.yuri.visual.field.sendAnonymousUsageReportsHint`,keywords:[`telemetry`,`analytics`]},{id:`appearance.transcript-cache`,page:`appearance`,titleKey:`settings.yuri.visual.transcriptCache.label`,descriptionKey:`settings.yuri.visual.transcriptCache.description`,keywords:[`cache`,`local data`,`conversation history`,`transcript`,`privacy`]},{id:`chat.render-mode`,page:`chat`,titleKey:`settings.yuri.visual.section.chatRenderMode`,keywords:[`messages`,`conversation`,`rendering`]},{id:`chat.message-transport`,page:`chat`,titleKey:`settings.yuri.visual.section.messageStreamTransport`,keywords:[`streaming`,`sse`,`websocket`]},{id:`chat.session-assistance`,page:`chat`,titleKey:`settings.yuri.visual.section.sessionAssistance`,keywords:[`title`,`assist`,`subagent`]},{id:`chat.session-title-refresh`,page:`chat`,titleKey:`settings.yuri.visual.field.sessionTitleRefresh`,keywords:[`title`,`rename`,`refresh`,`throttle`,`small model`,`summary`]},{id:`chat.session-goal`,page:`chat`,titleKey:`settings.yuri.visual.field.sessionGoal`,keywords:[`goal`,`objective`,`auto continue`]},{id:`chat.reasoning-traces`,page:`chat`,titleKey:`settings.yuri.visual.field.showReasoningTraces`,descriptionKey:`settings.yuri.visual.field.showReasoningTracesHint`,keywords:[`thinking`,`reasoning`,`mobile`,`fetch time`]},{id:`chat.reasoning`,page:`chat`,titleKey:`settings.yuri.visual.section.reasoning`,keywords:[`thinking`,`traces`]},{id:`chat.diff-layout`,page:`chat`,titleKey:`settings.yuri.visual.section.diffLayout`,keywords:[`diff`,`inline`,`side by side`,`layout`],isAvailable:e=>!e.isVSCode},{id:`chat.collapsible-user-messages`,page:`chat`,titleKey:`settings.yuri.visual.field.collapsibleUserMessages`,keywords:[`collapse`,`expand`,`clamp`,`long messages`,`user messages`]},{id:`chat.message-appearance`,page:`chat`,titleKey:`settings.yuri.visual.section.messageAppearance`,keywords:[`layout`,`messages`,`appearance`]},{id:`chat.inline-assistant-actions`,page:`chat`,titleKey:`settings.yuri.visual.field.showSplitAssistantMessageActions`,descriptionKey:`settings.yuri.visual.field.showSplitAssistantMessageActionsTooltip`,keywords:[`copy`,`read aloud`],isAvailable:()=>!1},{id:`chat.assistant-tps`,page:`chat`,titleKey:`settings.yuri.visual.field.showAssistantTps`,descriptionKey:`settings.yuri.visual.field.showAssistantTpsTooltip`,keywords:[`tps`,`tokens`,`speed`,`rate`,`tok/s`,`throughput`]},{id:`chat.subagent-read-only-banner`,page:`chat`,titleKey:`settings.yuri.visual.field.allowPromptingSubagentSessions`,keywords:[`subagent`,`read only`,`prompt`,`banner`]},{id:`chat.follow-up-behavior`,page:`chat`,titleKey:`settings.yuri.visual.field.followUpBehavior`,descriptionKey:`settings.yuri.visual.field.followUpBehaviorDescription`,keywords:[`follow up`,`queue`,`steer`,`send immediately`]},{id:`chat.persist-drafts`,page:`chat`,titleKey:`settings.yuri.visual.field.persistDraftMessages`,keywords:[`draft`,`message`]},{id:`chat.composer`,page:`chat`,titleKey:`settings.yuri.visual.section.composer`,keywords:[`input`,`draft`,`spellcheck`]},{id:`chat.spellcheck`,page:`chat`,titleKey:`settings.yuri.visual.field.enableSpellcheckInTextInputs`,keywords:[`spelling`,`input`],isAvailable:e=>!e.isMobile},{id:`sessions.default-model`,page:`sessions`,titleKey:`settings.yuri.defaults.field.defaultModel`,keywords:[`model`,`provider`,`new sessions`]},{id:`sessions.default-thinking`,page:`sessions`,titleKey:`settings.yuri.defaults.field.defaultThinking`,keywords:[`thinking`,`reasoning`,`variant`]},{id:`sessions.default-agent`,page:`sessions`,titleKey:`settings.yuri.defaults.field.defaultAgent`,keywords:[`agent`,`new sessions`]},{id:`sessions.browser-provider`,page:`sessions`,titleKey:`settings.yuri.browserProvider.label`,descriptionKey:`settings.yuri.browserProvider.info`,keywords:[`browser`,`extension`,`provider`,`live view`],isAvailable:()=>ur(gr())},{id:`sessions.deletion-dialog`,page:`sessions`,titleKey:`settings.yuri.defaults.field.showDeletionDialog`,keywords:[`delete`,`confirmation`]},{id:`summary-ai.configuration`,page:`summary-ai`,titleKey:`settings.yuri.defaults.summary.title`,descriptionKey:`settings.yuri.defaults.summary.description`,keywords:[`summary`,`commit`,`session title`,`prompt`,`provider`,`model`]},{id:`summary-ai.test-connection`,page:`summary-ai`,titleKey:`settings.yuri.defaults.summary.testConnection`,keywords:[`summary`,`connection`,`test`,`provider`,`api`]},{id:`sessions.auto-cleanup`,page:`sessions`,titleKey:`settings.yuri.sessionRetention.field.enableAutoCleanup`,descriptionKey:`settings.yuri.sessionRetention.tooltip`,keywords:[`retention`,`archive`,`delete`]},{id:`sessions.retention-period`,page:`sessions`,titleKey:`settings.yuri.sessionRetention.field.retentionPeriod`,keywords:[`days`,`cleanup`,`retention`]},{id:`sessions.retention-action`,page:`sessions`,titleKey:`settings.yuri.sessionRetention.field.whenSessionsExpire`,keywords:[`archive`,`delete`,`expire`]},{id:`archived-sessions.manage`,page:`archived-sessions`,titleKey:`settings.yuri.archivedSessions.title`,descriptionKey:`settings.yuri.archivedSessions.description`,keywords:[`archive`,`archived`,`restore`,`preview`,`history`]},{id:`sessions.desktop-launch-at-login`,page:`sessions`,titleKey:`settings.yuri.desktopNetwork.field.launchAtLogin`,descriptionKey:`settings.yuri.desktopNetwork.field.launchAtLoginDescription`,keywords:[`desktop`,`startup`,`login`],isAvailable:e=>e.isDesktopLocalOrigin},{id:`sessions.desktop-window-controls-position`,page:`sessions`,titleKey:`settings.yuri.desktopNetwork.field.windowControlsPosition`,descriptionKey:`settings.yuri.desktopNetwork.field.windowControlsPositionDescription`,keywords:[`desktop`,`window`,`controls`,`minimize`,`maximize`,`close`,`titlebar`,`linux`,`windows`],isAvailable:e=>e.isDesktop&&(e.isWindows||!e.isMac)},{id:`sessions.desktop-minimize-to-tray`,page:`sessions`,titleKey:`settings.yuri.desktopNetwork.field.minimizeToTray`,descriptionKey:`settings.yuri.desktopNetwork.field.minimizeToTrayDescription`,keywords:[`desktop`,`tray`,`system tray`,`minimize`,`close`,`background`,`windows`],isAvailable:e=>e.isDesktopLocalOrigin&&e.isWindows},{id:`sessions.desktop-keep-awake`,page:`sessions`,titleKey:`settings.yuri.desktopNetwork.field.keepAwake`,descriptionKey:`settings.yuri.desktopNetwork.field.keepAwakeDescription`,keywords:[`desktop`,`sleep`,`awake`,`server`,`mobile`,`phone`],isAvailable:e=>e.isDesktopLocalOrigin},{id:`remote-instances.desktop-ui-password`,page:`remote-instances`,titleKey:`settings.yuri.desktopPassword.field.password`,descriptionKey:`settings.yuri.desktopPassword.field.passwordDescription`,keywords:[`desktop`,`password`,`auth`,`login`],isAvailable:e=>e.isDesktopLocalOrigin},{id:`remote-instances.desktop-lan-access`,page:`remote-instances`,titleKey:`settings.yuri.desktopNetwork.field.allowLanAccess`,descriptionKey:`settings.yuri.desktopNetwork.field.allowLanAccessDescription`,keywords:[`desktop`,`lan`,`network`,`phone`,`tablet`],isAvailable:e=>e.isDesktopLocalOrigin},{id:`sessions.opencode-binary`,page:`sessions`,titleKey:`settings.yuri.opencodeCli.field.binaryPath`,keywords:[`opencode`,`cli`,`binary`,`path`],isAvailable:e=>!e.isVSCode},{id:`sessions.opencode-update-notifications`,page:`sessions`,titleKey:`settings.yuri.opencodeCli.field.showUpdateNotifications`,keywords:[`opencode`,`cli`,`updates`],isAvailable:e=>!e.isVSCode},{id:`git.github-account`,page:`git`,titleKey:`settings.github.page.actions.connect`,keywords:[`github`,`account`,`oauth`,`prs`,`issues`]},{id:`git.identities`,page:`git`,titleKey:`settings.gitIdentities.page.section.title`,descriptionKey:`settings.gitIdentities.page.empty.description`,keywords:[`identity`,`profile`,`author`,`email`,`credentials`,`signing`,`commit signing`,`ssh signing`,`gpg`]},{id:`git.changes-view`,page:`git`,titleKey:`settings.yuri.git.changesViewTitle`,keywords:[`changes`,`flat list`,`tree view`]},{id:`git.gitmoji`,page:`git`,titleKey:`settings.yuri.git.enableGitmoji`,keywords:[`commit`,`emoji`]},{id:`git.gitignored-files`,page:`git`,titleKey:`settings.yuri.git.showGitignored`,keywords:[`ignored`,`files`,`gitignore`]},{id:`usage.magpie`,page:`usage`,titleKey:`settings.usage.magpie.url`,descriptionKey:`settings.usage.magpie.description`,keywords:[`magpie`,`quota`,`gateway`]},{id:`usage.header-menu`,page:`usage`,titleKey:`settings.usage.page.options.showInHeader`,descriptionKey:`settings.usage.page.options.showInHeaderTooltip`,keywords:[`quota`,`header`,`dropdown`]},{id:`usage.model-quotas`,page:`usage`,titleKey:`settings.usage.page.section.modelQuotas`,keywords:[`models`,`quota`,`limits`,`tokens`]},{id:`projects.name`,page:`projects`,titleKey:`settings.projects.page.field.projectName`,keywords:[`label`,`display name`,`project metadata`]},{id:`projects.accent-color`,page:`projects`,titleKey:`settings.projects.page.field.accentColor`,keywords:[`color`,`appearance`,`project metadata`]},{id:`projects.icon`,page:`projects`,titleKey:`settings.projects.page.field.projectIcon`,keywords:[`icon`,`favicon`,`upload`,`project metadata`]},{id:`projects.worktree`,page:`projects`,titleKey:`settings.projects.page.section.worktree`,keywords:[`worktree`,`branch`,`repository`]},{id:`projects.worktree.setup.wait`,page:`projects`,titleKey:`settings.yuri.worktrees.setup.waitForCommands`,keywords:[`worktree`,`setup commands`,`bootstrap`,`wait`]},{id:`remote-instances.client-auth`,page:`remote-instances`,titleKey:`settings.remoteInstances.clientAuth.title`,descriptionKey:`settings.remoteInstances.clientAuth.description`,keywords:[`pairing link`,`client token`,`connect desktop`,`remote access`,`relay`,`devices`,`connect from anywhere`],isAvailable:e=>!e.isVSCode},{id:`remote-instances.instances`,page:`remote-instances`,titleKey:`settings.remoteInstances.sidebar.title`,descriptionKey:`settings.remoteInstances.sidebar.description`,keywords:[`import link`,`pairing link`,`connect link`,`ssh`,`remote instance`,`host switcher`],isAvailable:e=>e.isDesktop},{id:`behavior.system-prompt`,page:`behavior`,titleKey:`settings.behavior.page.section.systemPrompt`,descriptionKey:`settings.behavior.page.warning.title`,keywords:[`agents.md`,`global instructions`,`system prompt`]},{id:`behavior.response-style`,page:`behavior`,titleKey:`settings.behavior.page.section.responseStyle`,descriptionKey:`settings.behavior.page.responseStyle.tooltip`,keywords:[`tone`,`concise`,`detailed`,`custom instructions`]},{id:`agents.create`,page:`agents`,titleKey:`settings.agents.page.title.new`,keywords:[`create`,`add`,`new agent`]},{id:`assistants.create`,page:`assistants`,titleKey:`assistants.settings.create`,keywords:[`bot`,`bots`,`assistant`,`new`,`add`]},{id:`assistants.name`,page:`assistants`,titleKey:`assistants.settings.name`,keywords:[`bot`,`bots`,`assistant`,`name`]},{id:`assistants.prompt`,page:`assistants`,titleKey:`assistants.settings.defaultPrompt`,keywords:[`prompt`,`instructions`]},{id:`assistants.model`,page:`assistants`,titleKey:`assistants.settings.model`,keywords:[`provider`,`model`]},{id:`assistants.workspace`,page:`assistants`,titleKey:`assistants.settings.workspace`,keywords:[`path`,`directory`,`workspace`]},{id:`agents.name`,page:`agents`,titleKey:`settings.agents.page.field.agentName`,keywords:[`agent`,`name`]},{id:`agents.mode`,page:`agents`,titleKey:`settings.agents.page.field.mode`,descriptionKey:`settings.agents.page.field.modeTooltip`,keywords:[`primary`,`subagent`,`visibility`]},{id:`agents.scope`,page:`agents`,titleKey:`settings.agents.page.field.scope`,keywords:[`scope`,`project`,`user`,`global`]},{id:`agents.model`,page:`agents`,titleKey:`settings.agents.page.field.overrideModel`,keywords:[`model`,`provider`,`variant`]},{id:`agents.system-prompt`,page:`agents`,titleKey:`settings.agents.page.section.systemPrompt`,keywords:[`prompt`,`instructions`]},{id:`agents.permissions`,page:`agents`,titleKey:`settings.agents.page.section.toolPermissions`,keywords:[`tools`,`permissions`,`allow`,`ask`,`deny`]},{id:`commands.create`,page:`commands`,titleKey:`settings.commands.page.title.new`,keywords:[`create`,`add`,`new command`]},{id:`commands.name`,page:`commands`,titleKey:`settings.commands.page.field.commandName`,keywords:[`slash command`,`name`]},{id:`commands.agent`,page:`commands`,titleKey:`settings.commands.page.field.overrideAgent`,keywords:[`agent`,`execution`]},{id:`commands.model`,page:`commands`,titleKey:`settings.agents.page.field.overrideModel`,keywords:[`model`,`provider`]},{id:`commands.template`,page:`commands`,titleKey:`settings.commands.page.section.template`,keywords:[`prompt`,`template`,`arguments`,`shell`,`file`]},{id:`mcp.create`,page:`mcp`,titleKey:`settings.mcp.sidebar.actions.addServerTitle`,keywords:[`create`,`add`,`server`]},{id:`mcp.server`,page:`mcp`,titleKey:`settings.mcp.page.server.title`,keywords:[`server`,`name`,`transport`]},{id:`mcp.command`,page:`mcp`,titleKey:`settings.mcp.page.connection.command`,keywords:[`stdio`,`local`,`command`]},{id:`mcp.environment`,page:`mcp`,titleKey:`settings.mcp.page.env.title`,keywords:[`env`,`variables`,`api key`]},{id:`mcp.advanced`,page:`mcp`,titleKey:`settings.mcp.page.advanced.title`,keywords:[`oauth`,`headers`,`timeout`]},{id:`plugins.create`,page:`plugins`,titleKey:`settings.plugins.sidebar.actions.addTitle`,keywords:[`add`,`plugin`,`npm`,`path`,`file`]},{id:`plugins.spec`,page:`plugins`,titleKey:`settings.plugins.page.field.spec`,keywords:[`npm`,`package`,`path`]},{id:`plugins.options`,page:`plugins`,titleKey:`settings.plugins.page.field.options`,keywords:[`json`,`configuration`]},{id:`plugins.content`,page:`plugins`,titleKey:`settings.plugins.page.field.content`,keywords:[`file`,`code`]},{id:`providers.connect`,page:`providers`,titleKey:`settings.providers.page.connect.title`,keywords:[`add provider`,`connect provider`,`credentials`,`custom`,`protocol`,`base url`,`openai`,`anthropic`,`gemini`,`sync models`,`add all models`,`自定义`,`协议`,`同步模型`,`添加全部模型`]},{id:`providers.auth`,page:`providers`,titleKey:`settings.providers.page.auth.title`,keywords:[`api key`,`oauth`,`credentials`]},{id:`providers.connection-details`,page:`providers`,titleKey:`settings.providers.page.connectionDetails.title`,keywords:[`config`,`source`,`disconnect`]},{id:`providers.models`,page:`providers`,titleKey:`settings.providers.page.models.title`,keywords:[`models`,`hide`,`show`]},{id:`skills.create`,page:`skills.installed`,titleKey:`settings.skills.page.title.newSkill`,keywords:[`create`,`add`,`new skill`]},{id:`skills.basic-information`,page:`skills.installed`,titleKey:`settings.skills.page.section.basicInformation`,keywords:[`name`,`location`,`description`]},{id:`skills.instructions`,page:`skills.installed`,titleKey:`settings.skills.page.section.instructions`,keywords:[`markdown`,`skill.md`,`content`]},{id:`skills.supporting-files`,page:`skills.installed`,titleKey:`settings.skills.page.section.supportingFiles`,keywords:[`files`,`resources`]},{id:`skills.catalog.source`,page:`skills.catalog`,titleKey:`settings.skills.catalog.page.section.sourceRepository`,keywords:[`catalog`,`repository`,`source`,`refresh`]},{id:`skills.catalog.search`,page:`skills.catalog`,titleKey:`settings.skills.catalog.shared.field.searchSkillsPlaceholder`,keywords:[`find skills`,`install skills`,`catalog search`]},{id:`skills.catalog.add-catalog`,page:`skills.catalog`,titleKey:`settings.skills.catalog.page.actions.addCatalog`,keywords:[`external repository`,`add source`,`catalog`]},{id:`magic-prompts.visible-prompt`,page:`magic-prompts`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`,keywords:[`prompt text`,`user message`,`template`],isAvailable:e=>!e.isVSCode},{id:`magic-prompts.instructions`,page:`magic-prompts`,titleKey:`settings.magicPrompts.page.block.instructions`,keywords:[`hidden prompt`,`instructions`,`template`],isAvailable:e=>!e.isVSCode},{id:`magic-prompts.reset-overrides`,page:`magic-prompts`,titleKey:`settings.magicPrompts.page.actions.resetAllOverrides`,keywords:[`reset`,`default prompts`,`overrides`],isAvailable:e=>!e.isVSCode},{id:`shortcuts.keyboard-shortcuts`,page:`shortcuts`,titleKey:`settings.yuri.keyboardShortcuts.title`,descriptionKey:`settings.yuri.keyboardShortcuts.tooltip`,keywords:[`keyboard`,`hotkeys`,`bindings`]},{id:`voice.playback`,page:`voice`,titleKey:`settings.voice.page.section.playbackAndSummary`,keywords:[`tts`,`read aloud`,`voice`,`provider`,`speech rate`,`speech pitch`,`speech volume`,`tts input mode`,`markdown`,`volcengine`,`doubao`,`火山`,`豆包`,`seed-tts`,`音色`,`api key`]},{id:`voice.speech-recognition`,page:`voice`,titleKey:`settings.voice.page.section.speechRecognition`,keywords:[`stt`,`dictation`,`voice input`,`transcribe`,`whisper`,`parakeet`,`microphone`,`volcengine`,`doubao`,`火山`,`豆包`,`asr`,`实时字幕`,`识别`,`api key`,`recognition context`,`terminology`,`语境`,`上下文`,`中英文`]},{id:`notifications.delivery`,page:`notifications`,titleKey:`settings.notifications.page.delivery.title`,keywords:[`desktop notifications`,`system notifications`]},{id:`notifications.events`,page:`notifications`,titleKey:`settings.notifications.page.events.title`,keywords:[`completion`,`subtasks`,`errors`,`questions`]},{id:`notifications.push`,page:`notifications`,titleKey:`settings.notifications.page.push.title`,keywords:[`background`,`push`],isAvailable:e=>e.isWeb&&!e.isDesktop&&!e.isVSCode}];function jm(e){return e.trim().toLocaleLowerCase()}function Mm({query:e,runtimeCtx:t,visiblePageSlugs:n,t:r,getPageTitle:i}){let a=jm(e);if(!a)return[];let o=n?new Set(n):null,s=a.split(/\s+/).filter(Boolean);return Am.flatMap(e=>{if(o&&!o.has(e.page))return[];let n=Tr(e.page);if(!n||n.isAvailable&&!n.isAvailable(t)||e.isAvailable&&!e.isAvailable(t))return[];let a=r(e.titleKey),c=e.descriptionKey?r(e.descriptionKey):null,l=jm([a,c,i(e.page),...e.keywords??[]].filter(Boolean).join(` `));return s.every(e=>l.includes(e))?[{...e,title:a,description:c,pageTitle:i(e.page)}]:[]})}function Nm(e){let t=(0,Sa.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({asChild:i,className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i!==void 0&&i?Ke:`div`,o;t[4]===n?o=t[5]:(o=K(`yuri-mobile-floating-surface`,n),t[4]=n,t[5]=o);let s;return t[6]!==a||t[7]!==r||t[8]!==o?(s=(0,$.jsx)(a,{className:o,...r}),t[6]=a,t[7]=r,t[8]=o,t[9]=s):s=t[9],s}function Pm(e){let t=(0,Sa.c)(20),n,r,i,a,o,s;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6]):({as:o,children:n,className:r,variant:s,surfaceProps:a,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s);let c=o===void 0?`div`:o,l=s===void 0?`actions`:s,u;t[7]===r?u=t[8]:(u=K(`yuri-mobile-floating-bottom-bar-frame`,r),t[7]=r,t[8]=u);let d=l===`navigation`?`yuri-mobile-floating-bottom-bar-navigation`:`yuri-mobile-floating-bottom-bar-actions`,f;t[9]===d?f=t[10]:(f=K(`yuri-mobile-floating-bottom-bar`,d),t[9]=d,t[10]=f);let p;t[11]!==n||t[12]!==a||t[13]!==f?(p=(0,$.jsx)(Nm,{...a,className:f,children:n}),t[11]=n,t[12]=a,t[13]=f,t[14]=p):p=t[14];let m;return t[15]!==c||t[16]!==i||t[17]!==u||t[18]!==p?(m=(0,$.jsx)(c,{className:u,...i,children:p}),t[15]=c,t[16]=i,t[17]=u,t[18]=p,t[19]=m):m=t[19],m}function Fm(e){let t=(0,Sa.c)(17),{title:n,children:r,surface:i,scrollsWithPage:a,showHeader:o,trailing:s,className:c,surfaceClassName:l,surfaceAriaLabel:u}=e,d=i===void 0||i,f=a!==void 0&&a,p=o===void 0||o,m=f&&`yuri-mobile-tab-page-flow`,h=!p&&`gap-0`,g;t[0]!==c||t[1]!==m||t[2]!==h?(g=K(`yuri-mobile-tab-page`,m,h,c),t[0]=c,t[1]=m,t[2]=h,t[3]=g):g=t[3];let _;t[4]!==p||t[5]!==n||t[6]!==s?(_=p?(0,$.jsx)(Di,{title:n,trailing:s}):null,t[4]=p,t[5]=n,t[6]=s,t[7]=_):_=t[7];let v;t[8]!==r||t[9]!==d||t[10]!==u||t[11]!==l?(v=d?(0,$.jsx)(Nm,{className:K(`yuri-mobile-tab-page-surface`,l),"aria-label":u,children:r}):(0,$.jsx)(`div`,{className:K(`yuri-mobile-tab-page-content`,l),"aria-label":u,children:r}),t[8]=r,t[9]=d,t[10]=u,t[11]=l,t[12]=v):v=t[12];let y;return t[13]!==g||t[14]!==_||t[15]!==v?(y=(0,$.jsxs)(`div`,{className:g,children:[_,v]}),t[13]=g,t[14]=_,t[15]=v,t[16]=y):y=t[16],y}function Im(e){let t=(0,Sa.c)(12),{label:n,children:r,className:i,cardClassName:a,ariaLabel:o}=e,s;t[0]!==a||t[1]!==i?(s=K(`yuri-mobile-labeled-surface-group`,a,i),t[0]=a,t[1]=i,t[2]=s):s=t[2];let c;t[3]===n?c=t[4]:(c=(0,$.jsx)(`div`,{className:`yuri-mobile-labeled-surface-group-label`,children:n}),t[3]=n,t[4]=c);let l;t[5]===r?l=t[6]:(l=r?(0,$.jsx)(`div`,{className:`yuri-mobile-labeled-surface-group-content`,children:r}):null,t[5]=r,t[6]=l);let u;return t[7]!==o||t[8]!==s||t[9]!==c||t[10]!==l?(u=(0,$.jsxs)(`section`,{className:s,"aria-label":o,children:[c,l]}),t[7]=o,t[8]=s,t[9]=c,t[10]=l,t[11]=u):u=t[11],u}function Lm(e){let t=(0,Sa.c)(10),{label:n,children:r,ariaLabel:i,className:a,borderless:o}=e,s=o!==void 0&&o,c;t[0]===a?c=t[1]:(c=K(`yuri-mobile-settings-group`,a),t[0]=a,t[1]=c);let l=s&&`yuri-mobile-settings-card-borderless`,u;t[2]===l?u=t[3]:(u=K(`yuri-mobile-settings-card`,l),t[2]=l,t[3]=u);let d;return t[4]!==i||t[5]!==r||t[6]!==n||t[7]!==c||t[8]!==u?(d=(0,$.jsx)(Z,{label:n,ariaLabel:i,className:c,cardClassName:u,children:r}),t[4]=i,t[5]=r,t[6]=n,t[7]=c,t[8]=u,t[9]=d):d=t[9],d}var Rm=e({SettingsView:()=>$m,getSettingsNavIcon:()=>Zm}),zm=176,Bm=280,Vm=8,Hm=`__yuriSettingsDetail`;function Um(e){return Math.min(Bm,Math.max(zm,e))}var Wm=`__add_provider__`;function Gm(e,t){return{isVSCode:g(),isWeb:!e&&d(),isDesktop:e,isMobile:t}}function Km(e,t){return!e.isAvailable||e.isAvailable(t)}function qm(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Jm(e,t){let n=new Set(t),r=e,i=1;for(;n.has(r);)r=`${e}-${i}`,i+=1;return r}function Ym(e){if(!qm(e))return null;let t=e[Hm];if(!qm(t))return null;let n=t.page,r=t.stage;return typeof n!=`string`||r!==`page-content`?null:{page:kr(n),stage:r}}function Xm(){return typeof window>`u`||!qm(window.history.state)?{}:window.history.state}function Zm(e){switch(e){case`projects`:return`folders`;case`instances`:return`server`;case`remote-instances`:return`server`;case`appearance`:return`palette`;case`chat`:return`chat-ai-3`;case`magic-prompts`:return`ai-generate-2`;case`notifications`:return`notification-3`;case`shortcuts`:return`command`;case`sessions`:return`chat-history`;case`archived-sessions`:return`archive`;case`summary-ai`:return`ai-generate-2`;case`providers`:return`cloud`;case`agents`:return`node-tree`;case`assistants`:return`robot-2`;case`behavior`:return`brain`;case`commands`:return`slash-commands-2`;case`mcp`:return null;case`plugins`:return`code-box`;case`global-config`:return`settings-3`;case`skills.installed`:return`book-open`;case`skills.catalog`:return`book`;case`git`:return`git-branch`;case`usage`:return`bar-chart-2`;case`voice`:return`mic`;case`about`:return`information`;case`home`:return null;default:return`robot-2`}}var Qm=e=>{let t=(0,Sa.c)(95),{onOpen:n}=e,{t:r}=Ge(),i;t[0]===r?i=t[1]:(i=r(`settings.view.home.title`),t[0]=r,t[1]=i);let a;t[2]===i?a=t[3]:(a=(0,$.jsx)(`h1`,{className:`typography-ui-header font-semibold text-foreground`,children:i}),t[2]=i,t[3]=a);let o;t[4]===r?o=t[5]:(o=r(`settings.view.home.description`),t[4]=r,t[5]=o);let s;t[6]===o?s=t[7]:(s=(0,$.jsx)(`p`,{className:`typography-ui text-muted-foreground`,children:o}),t[6]=o,t[7]=s);let c;t[8]!==a||t[9]!==s?(c=(0,$.jsxs)(`div`,{className:`space-y-1`,children:[a,s]}),t[8]=a,t[9]=s,t[10]=c):c=t[10];let l;t[11]===n?l=t[12]:(l=()=>n(`providers`),t[11]=n,t[12]=l);let u;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(u=K(`rounded-lg border border-border bg-[var(--surface-elevated)] p-4 text-left`,`hover:bg-[var(--interactive-hover)] transition-colors`),t[13]=u):u=t[13];let d;t[14]===r?d=t[15]:(d=r(`settings.view.home.cards.providers.title`),t[14]=r,t[15]=d);let f;t[16]===d?f=t[17]:(f=(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:d}),t[16]=d,t[17]=f);let p;t[18]===r?p=t[19]:(p=r(`settings.view.home.cards.providers.description`),t[18]=r,t[19]=p);let m;t[20]===p?m=t[21]:(m=(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/70`,children:p}),t[20]=p,t[21]=m);let h;t[22]!==m||t[23]!==l||t[24]!==f?(h=(0,$.jsxs)(`button`,{type:`button`,onClick:l,className:u,children:[f,m]}),t[22]=m,t[23]=l,t[24]=f,t[25]=h):h=t[25];let g;t[26]===n?g=t[27]:(g=()=>n(`agents`),t[26]=n,t[27]=g);let _;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(_=K(`rounded-lg border border-border bg-[var(--surface-elevated)] p-4 text-left`,`hover:bg-[var(--interactive-hover)] transition-colors`),t[28]=_):_=t[28];let v;t[29]===r?v=t[30]:(v=r(`settings.view.home.cards.agents.title`),t[29]=r,t[30]=v);let y;t[31]===v?y=t[32]:(y=(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:v}),t[31]=v,t[32]=y);let b;t[33]===r?b=t[34]:(b=r(`settings.view.home.cards.agents.description`),t[33]=r,t[34]=b);let x;t[35]===b?x=t[36]:(x=(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/70`,children:b}),t[35]=b,t[36]=x);let S;t[37]!==g||t[38]!==y||t[39]!==x?(S=(0,$.jsxs)(`button`,{type:`button`,onClick:g,className:_,children:[y,x]}),t[37]=g,t[38]=y,t[39]=x,t[40]=S):S=t[40];let C;t[41]===n?C=t[42]:(C=()=>n(`skills.catalog`),t[41]=n,t[42]=C);let w;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(w=K(`rounded-lg border border-border bg-[var(--surface-elevated)] p-4 text-left`,`hover:bg-[var(--interactive-hover)] transition-colors`),t[43]=w):w=t[43];let T;t[44]===r?T=t[45]:(T=r(`settings.view.home.cards.skillsCatalog.title`),t[44]=r,t[45]=T);let E;t[46]===T?E=t[47]:(E=(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:T}),t[46]=T,t[47]=E);let D;t[48]===r?D=t[49]:(D=r(`settings.view.home.cards.skillsCatalog.description`),t[48]=r,t[49]=D);let O;t[50]===D?O=t[51]:(O=(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/70`,children:D}),t[50]=D,t[51]=O);let k;t[52]!==C||t[53]!==E||t[54]!==O?(k=(0,$.jsxs)(`button`,{type:`button`,onClick:C,className:w,children:[E,O]}),t[52]=C,t[53]=E,t[54]=O,t[55]=k):k=t[55];let A;t[56]===n?A=t[57]:(A=()=>n(`mcp`),t[56]=n,t[57]=A);let j;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(j=K(`rounded-lg border border-border bg-[var(--surface-elevated)] p-4 text-left`,`hover:bg-[var(--interactive-hover)] transition-colors`),t[58]=j):j=t[58];let M;t[59]===r?M=t[60]:(M=r(`settings.view.home.cards.mcp.title`),t[59]=r,t[60]=M);let N;t[61]===M?N=t[62]:(N=(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:M}),t[61]=M,t[62]=N);let P;t[63]===r?P=t[64]:(P=r(`settings.view.home.cards.mcp.description`),t[63]=r,t[64]=P);let F;t[65]===P?F=t[66]:(F=(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/70`,children:P}),t[65]=P,t[66]=F);let I;t[67]!==A||t[68]!==N||t[69]!==F?(I=(0,$.jsxs)(`button`,{type:`button`,onClick:A,className:j,children:[N,F]}),t[67]=A,t[68]=N,t[69]=F,t[70]=I):I=t[70];let L;t[71]===n?L=t[72]:(L=()=>n(`usage`),t[71]=n,t[72]=L);let R;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(R=K(`rounded-lg border border-border bg-[var(--surface-elevated)] p-4 text-left`,`hover:bg-[var(--interactive-hover)] transition-colors`),t[73]=R):R=t[73];let z;t[74]===r?z=t[75]:(z=r(`settings.view.home.cards.usage.title`),t[74]=r,t[75]=z);let B;t[76]===z?B=t[77]:(B=(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:z}),t[76]=z,t[77]=B);let V;t[78]===r?V=t[79]:(V=r(`settings.view.home.cards.usage.description`),t[78]=r,t[79]=V);let H;t[80]===V?H=t[81]:(H=(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/70`,children:V}),t[80]=V,t[81]=H);let U;t[82]!==L||t[83]!==B||t[84]!==H?(U=(0,$.jsxs)(`button`,{type:`button`,onClick:L,className:R,children:[B,H]}),t[82]=L,t[83]=B,t[84]=H,t[85]=U):U=t[85];let W;t[86]!==h||t[87]!==S||t[88]!==k||t[89]!==I||t[90]!==U?(W=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[h,S,k,I,U]}),t[86]=h,t[87]=S,t[88]=k,t[89]=I,t[90]=U,t[91]=W):W=t[91];let ee;return t[92]!==W||t[93]!==c?(ee=(0,$.jsx)(`div`,{className:`h-full overflow-auto`,children:(0,$.jsxs)(`div`,{className:`mx-auto w-full max-w-3xl px-6 py-6 space-y-6`,children:[c,W]})}),t[92]=W,t[93]=c,t[94]=ee):ee=t[94],ee},$m=e=>{let t=(0,Sa.c)(183),{onClose:n,mobileInstancesPage:r,forceMobile:i,isWindowed:a,visiblePageSlugs:o,hideMobileHeader:s,flowMobile:c,autoOpenMobilePage:l,initialMobileStage:u,onMobileStageChange:d}=e,f=s!==void 0&&s,p=c!==void 0&&c,m=l===void 0||l,g=u===void 0?`nav`:u,{t:_}=Ge(),v;t[0]===_?v=t[1]:(v={mutationFn:mt,onError:()=>Be.error(_(`chat.chatInput.toast.reloadFailed`))},t[0]=_,t[1]=v);let y=Te(v),b;t[2]===y?b=t[3]:(b=()=>{y.isPending||y.mutate()},t[2]=y,t[3]=b);let x=He(b),S=wr(),C=i??S.isMobile,w=G(eh),T=G(th),E=G(nh),D;t[4]===w?D=t[5]:(D=kr(w),t[4]=w,t[5]=D);let k=D;sr();let A=k===`commands`,j;t[6]===A?j=t[7]:(j={enabled:A},t[6]=A,t[7]=j);let{refetch:M}=Rt(j),N,P;t[8]!==M||t[9]!==k?(N=()=>{k===`commands`&&M()},P=[M,k],t[8]=M,t[9]=k,t[10]=N,t[11]=P):(N=t[10],P=t[11]),Q.useEffect(N,P);let[F,I]=Q.useState(g),L=f&&F===`nav`,R=C&&p,z=Q.useRef(null),B=Q.useRef(0),V=en(rh),H,U;t[12]!==C||t[13]!==V||t[14]!==E||t[15]!==k?(H=()=>{if(!C||V<=B.current)return;let e=en.getState().settingsSelectedAssistantID;if(!(!e||e===`new`)){if(k!==`assistants`){E(`assistants`);return}B.current=V,z.current=`assistants`,I(`page-content`)}},U=[C,V,E,k],t[12]=C,t[13]=V,t[14]=E,t[15]=k,t[16]=H,t[17]=U):(H=t[16],U=t[17]),Q.useEffect(H,U);let W,ee;t[18]!==F||t[19]!==d?(W=()=>{d?.(F)},ee=[F,d],t[18]=F,t[19]=d,t[20]=W,t[21]=ee):(W=t[20],ee=t[21]),Q.useEffect(W,ee);let[te,ne]=Q.useState(216),[re,ie]=Q.useState(null),[ae,oe]=Q.useState(``),[se,ce]=Q.useState(null),[le,ue]=Q.useState(0),[de,fe]=Q.useState(!1),[pe,me]=Q.useState(!1),he=Q.useRef(0),ge=Q.useRef(te),_e=Q.useRef(null),ve=Q.useRef(null),ye=Q.useRef(null),be=Q.useRef(null),xe=Q.useRef(null),Se=Q.useRef(null),Ce;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(Ce=[],t[22]=Ce):Ce=t[22];let we=Q.useRef(Ce),Ee=Q.useRef(0),De=Q.useRef(!1),ke;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(ke=h(),t[23]=ke):ke=t[23];let je=ke,Me;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(Me=h()&&O(),t[24]=Me):Me=t[24];let Ne=Me,Pe;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(Pe=h()&&typeof window<`u`&&window.__YURI_PLATFORM__===`darwin`,t[25]=Pe):Pe=t[25];let Fe=Pe,Ie;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(Ie=h()&&typeof window<`u`&&window.__YURI_PLATFORM__===`win32`,t[26]=Ie):Ie=t[26];let Le=Ie,Re;t[27]===C?Re=t[28]:(Re=Gm(je,C),t[27]=C,t[28]=Re);let ze=Re,Ve;if(t[29]!==C||t[30]!==r||t[31]!==ze||t[32]!==o){let e=o?new Set(o):null,n;t[34]===ze?n=t[35]:(n=e=>Km(e,ze),t[34]=ze,t[35]=n);let i;t[36]===r?i=t[37]:(i=e=>e.slug!==`instances`||!!r,t[36]=r,t[37]=i);let a;t[38]===ze.isVSCode?a=t[39]:(a=e=>!(ze.isVSCode&&e.slug===`projects`),t[38]=ze.isVSCode,t[39]=a);let s;t[40]===C?s=t[41]:(s=e=>!(C&&e.slug===`shortcuts`),t[40]=C,t[41]=s),Ve=Dr.filter(ih).filter(t=>!e||e.has(t.slug)).filter(n).filter(i).filter(a).filter(s),t[29]=C,t[30]=r,t[31]=ze,t[32]=o,t[33]=Ve}else Ve=t[33];let Ue=Ve,We=ai().length,Ke=Om(),Je;t[42]===Ue?Je=t[43]:(Je=Er(Ue),t[42]=Ue,t[43]=Je);let Ye=Je,Xe=Y(ah),Ze,Qe;t[44]===de?(Ze=t[45],Qe=t[46]):(Ze=()=>{if(typeof window>`u`)return;let e=()=>{if(!de){let e=Um(Math.floor(window.innerWidth*.12));ne(e)}};return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},Qe=[de],t[44]=de,t[45]=Ze,t[46]=Qe),Q.useEffect(Ze,Qe);let $e,et;t[47]===pe?($e=t[48],et=t[49]):($e=()=>{if(!pe)return;let e=e=>{let t=e.clientX-he.current,n=Um(ge.current+t);ne(n),fe(!0)},t=()=>me(!1);return window.addEventListener(`pointermove`,e),window.addEventListener(`pointerup`,t,{once:!0}),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,t)}},et=[pe],t[47]=pe,t[48]=$e,t[49]=et),Q.useEffect($e,et);let tt;t[50]===te?tt=t[51]:(tt=e=>{me(!0),he.current=e.clientX,ge.current=te,e.preventDefault()},t[50]=te,t[51]=tt);let nt=tt,rt;t[52]===te?rt=t[53]:(rt=e=>{let t=e.shiftKey?32:Vm,n;bb160:switch(e.key){case`ArrowLeft`:n=te-t;break bb160;case`ArrowRight`:n=te+t;break bb160;case`Home`:n=zm;break bb160;case`End`:n=Bm;break bb160;default:return}e.preventDefault(),ne(Um(n)),fe(!0)},t[52]=te,t[53]=rt);let it=rt,ot;t[54]!==T||t[55]!==a||t[56]!==ze.isVSCode||t[57]!==k?(ot=()=>{if(!(!T&&!ze.isVSCode&&!a)){if(k===`agents`){Wt.getState().loadAgents();return}if(k!==`commands`&&k!==`mcp`){if(k===`plugins`){$i.getState().loadPlugins();return}(k===`skills.installed`||k===`skills.catalog`)&&wt(Oe,St())}}},t[54]=T,t[55]=a,t[56]=ze.isVSCode,t[57]=k,t[58]=ot):ot=t[58];let st;t[59]!==Xe||t[60]!==T||t[61]!==a||t[62]!==ze.isVSCode||t[63]!==k?(st=[Xe,T,a,ze.isVSCode,k],t[59]=Xe,t[60]=T,t[61]=a,t[62]=ze.isVSCode,t[63]=k,t[64]=st):st=t[64],Q.useEffect(ot,st);let ct;t[65]!==C||t[66]!==E?(ct=(e,t)=>{if(e===`providers`&&!(t!==void 0&&t)&&pt.getState().setSelectedProvider(Wm),E(e),z.current=e,!C)return;let n=Tr(e);if(!n||n.slug===`home`){I(`nav`);return}I(n.kind===`split`?`page-sidebar`:`page-content`)},t[65]=C,t[66]=E,t[67]=ct):ct=t[67];let lt=He(ct),ut;t[68]===k?ut=t[69]:(ut=Tr(k),t[68]=k,t[69]=ut);let dt=ut,ft;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(ft={appearance:`visual`,chat:`chat`,shortcuts:`shortcuts`,sessions:`sessions`,"summary-ai":`summary-ai`,notifications:`notifications`,voice:`voice`},t[70]=ft):ft=t[70];let ht=ft,gt;t[71]===_?gt=t[72]:(gt=e=>{switch(e){case`projects`:return _(`settings.page.projects.title`);case`instances`:return _(`mobile.settings.switchInstance`);case`remote-instances`:return _(`settings.page.remoteInstances.title`);case`providers`:return _(`settings.page.providers.title`);case`usage`:return _(`settings.page.usage.title`);case`agents`:return _(`settings.page.agents.title`);case`assistants`:return _(`settings.page.assistants.title`);case`behavior`:return _(`settings.page.behavior.title`);case`commands`:return _(`settings.page.commands.title`);case`mcp`:return _(`settings.page.mcp.title`);case`plugins`:return _(`settings.page.plugins.title`);case`global-config`:return _(`settings.globalConfig.title`);case`skills.installed`:return _(`settings.page.skills.title`);case`skills.catalog`:return _(`settings.page.skillsCatalog.title`);case`git`:return _(`settings.page.git.title`);case`appearance`:return _(`settings.page.appearance.title`);case`chat`:return _(`settings.page.chat.title`);case`shortcuts`:return _(`settings.page.shortcuts.title`);case`sessions`:return _(`settings.page.sessions.title`);case`archived-sessions`:return _(`settings.page.archivedSessions.title`);case`summary-ai`:return _(`settings.page.summaryAI.title`);case`magic-prompts`:return _(`settings.page.magicPrompts.title`);case`notifications`:return _(`settings.page.notifications.title`);case`voice`:return _(`settings.page.voice.title`);case`about`:return _(`settings.page.about.title`);default:return _(`settings.view.home.title`)}},t[71]=_,t[72]=gt);let _t=gt,vt;t[73]!==_t||t[74]!==ze||t[75]!==ae||t[76]!==_||t[77]!==Ue?(vt=Mm({query:ae,runtimeCtx:{...ze,isDesktopLocalOrigin:Ne,isMac:Fe,isWindows:Le},visiblePageSlugs:Ue.map(oh),t:_,getPageTitle:_t}),t[73]=_t,t[74]=ze,t[75]=ae,t[76]=_,t[77]=Ue,t[78]=vt):vt=t[78];let yt=vt,bt=dh,xt;if(t[79]!==yt){xt=[];let e=new Map;for(let t of yt){let n=e.get(t.page);n||(n={page:t.page,pageTitle:t.pageTitle,results:[]},e.set(t.page,n),xt.push(n)),n.results.push(t)}t[79]=yt,t[80]=xt}else xt=t[80];let Ct=xt,Tt;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(Tt=()=>{ue(0),Ee.current=0,De.current=!1},t[81]=Tt):Tt=t[81];let Et;t[82]===ae?Et=t[83]:(Et=[ae],t[82]=ae,t[83]=Et),Q.useEffect(Tt,Et);let Dt,Ot;t[84]===le?(Dt=t[85],Ot=t[86]):(Dt=()=>{Ee.current=le},Ot=[le],t[84]=le,t[85]=Dt,t[86]=Ot),Q.useEffect(Dt,Ot);let kt,At;t[87]===le?(kt=t[88],At=t[89]):(kt=()=>{we.current[le]?.scrollIntoView({block:`nearest`})},At=[le],t[87]=le,t[88]=kt,t[89]=At),Q.useEffect(kt,At);let jt,J;t[90]!==le||t[91]!==yt.length?(jt=()=>{le>=yt.length&&ue(Math.max(0,yt.length-1)),we.current.length=yt.length},J=[le,yt.length],t[90]=le,t[91]=yt.length,t[92]=jt,t[93]=J):(jt=t[92],J=t[93]),Q.useEffect(jt,J);let Mt;t[94]!==C||t[95]!==lt?(Mt=e=>{let t=bt(e);ce(t),lt(e.page,!0),C&&I(`page-content`),e.id===`plugins.create`&&typeof window<`u`&&window.setTimeout(fh,50)},t[94]=C,t[95]=lt,t[96]=Mt):Mt=t[96];let Nt=Mt,Pt;t[97]!==Nt||t[98]!==ae||t[99]!==yt?(Pt=e=>{if(ae.trim()){if(e.key===`Escape`){e.preventDefault(),oe(``);return}if(yt.length!==0){if(e.key===`ArrowDown`){e.preventDefault(),De.current=!0,ue(e=>(e+1)%yt.length);return}if(e.key===`ArrowUp`){e.preventDefault(),De.current=!0,ue(e=>(e-1+yt.length)%yt.length);return}if(e.key===`Enter`){e.preventDefault();let t=(Ee.current%yt.length+yt.length)%yt.length,n=yt[t]??yt[0];n&&Nt(n)}}}},t[97]=Nt,t[98]=ae,t[99]=yt,t[100]=Pt):Pt=t[100];let Ft=Pt,It;t[101]===se?It=t[102]:(It=()=>{let e=se;if(!e)return;let t=!1,n=window.requestAnimationFrame(()=>{if(t)return;let n=typeof CSS<`u`&&CSS.escape?CSS.escape(e):e.replace(/[^a-zA-Z0-9_-]/g,`\\$&`),r=_e.current?.querySelector(`[data-settings-item="${n}"]`);r&&(ce(null),r.scrollIntoView({block:`center`,behavior:`smooth`}),r.setAttribute(`data-settings-search-highlight`,`true`),window.setTimeout(()=>{r.removeAttribute(`data-settings-search-highlight`)},1600))});return()=>{t=!0,window.cancelAnimationFrame(n)}},t[101]=se,t[102]=It);let Lt;t[103]!==se||t[104]!==k?(Lt=[se,k],t[103]=se,t[104]=k,t[105]=Lt):Lt=t[105],Q.useEffect(It,Lt);let zt;t[106]===_?zt=t[107]:(zt=()=>(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6`,children:(0,$.jsxs)(`div`,{className:`max-w-md text-center`,children:[(0,$.jsx)(`div`,{className:`typography-ui-header font-semibold text-foreground`,children:_(`settings.view.unavailable.title`)}),(0,$.jsx)(`p`,{className:`typography-ui text-muted-foreground mt-1`,children:_(`settings.view.unavailable.description`)})]})}),t[106]=_,t[107]=zt);let Bt=zt,Vt=ph,Ht;t[108]!==C||t[109]!==ze.isVSCode||t[110]!==k?(Ht=()=>{if(C){if(Ae()||ze.isVSCode){I(`page-sidebar`);return}if((typeof window<`u`?Ym(window.history.state):null)?.page===k){window.history.back();return}I(`page-sidebar`)}},t[108]=C,t[109]=ze.isVSCode,t[110]=k,t[111]=Ht):Ht=t[111];let Ut=Ht,Gt;t[112]!==re||t[113]!==Ut||t[114]!==C||t[115]!==R||t[116]!==r||t[117]!==lt||t[118]!==Bt||t[119]!==ze?(Gt=e=>{let t=Tr(e);if(t&&!Km(t,ze))return Bt();switch(e){case`home`:return(0,$.jsx)(Qm,{onOpen:lt});case`projects`:return(0,$.jsx)(Qu,{});case`instances`:return r??Bt();case`remote-instances`:return(0,$.jsx)(df,{});case`agents`:return(0,$.jsx)(ds,{});case`assistants`:return(0,$.jsx)(ac,{onItemDeleted:C?Ut:void 0,onSaved:C?Ut:void 0,saveActionContainer:C?re:void 0});case`behavior`:return(0,$.jsx)(bc,{});case`commands`:return(0,$.jsx)(Oc,{});case`mcp`:return(0,$.jsx)(ll,{});case`plugins`:return(0,$.jsx)(Ql,{});case`global-config`:return(0,$.jsx)(eu,{});case`skills.installed`:return(0,$.jsx)(Uu,{view:`installed`});case`skills.catalog`:return(0,$.jsx)(Uu,{view:`catalog`});case`providers`:return(0,$.jsx)(fa,{});case`usage`:return(0,$.jsx)(Wf,{});case`about`:return(0,$.jsx)(`div`,{className:K(`h-full overflow-auto px-5 py-6`,R&&`h-auto overflow-visible p-3`),children:(0,$.jsx)(Aa,{})});case`magic-prompts`:return(0,$.jsx)($f,{});case`git`:return(0,$.jsx)(sp,{});case`archived-sessions`:return(0,$.jsx)(Dm,{});case`appearance`:case`chat`:case`shortcuts`:case`sessions`:case`summary-ai`:case`notifications`:case`voice`:{let t=ht[e]??`visual`;return(0,$.jsx)(_m,{section:t,flowMobile:R})}default:return(0,$.jsx)(Qm,{onOpen:lt})}},t[112]=re,t[113]=Ut,t[114]=C,t[115]=R,t[116]=r,t[117]=lt,t[118]=Bt,t[119]=ze,t[120]=Gt):Gt=t[120];let Kt=Gt,Jt,Yt;t[121]!==m||t[122]!==C||t[123]!==F||t[124]!==k?(Jt=()=>{if(!C||!m||F!==`nav`||k===`home`||z.current===k)return;let e=Tr(k);!e||e.slug===`home`||(z.current=k,I(e.kind===`split`?`page-sidebar`:`page-content`))},Yt=[m,C,F,k],t[121]=m,t[122]=C,t[123]=F,t[124]=k,t[125]=Jt,t[126]=Yt):(Jt=t[125],Yt=t[126]),Q.useEffect(Jt,Yt);let Xt,Zt;t[127]!==p||t[128]!==k?(Xt=()=>{!p||k!==`home`||(z.current=null,I(`nav`))},Zt=[p,k],t[127]=p,t[128]=k,t[129]=Xt,t[130]=Zt):(Xt=t[129],Zt=t[130]),Q.useEffect(Xt,Zt);let Qt=C&&F!==`nav`,$t=C&&F===`page-content`&&dt?.kind===`split`,tn=F===`page-content`&&dt?.kind===`split`&&!$t,nn;t[131]!==$t||t[132]!==Qt||t[133]!==_?(nn=_($t?`settings.view.actions.back`:Qt?`settings.view.actions.backToSettings`:`settings.view.actions.closeSettings`),t[131]=$t,t[132]=Qt,t[133]=_,t[134]=nn):nn=t[134];let rn=nn,an=qe(),on;t[135]===ze.isVSCode?on=t[136]:(on=e=>{if(typeof window>`u`||ze.isVSCode||Ae())return;let t=Ym(window.history.state);(t?.page!==e||t.stage!==`page-content`)&&window.history.pushState({...Xm(),[Hm]:{page:e,stage:`page-content`}},``,window.location.href)},t[135]=ze.isVSCode,t[136]=on);let sn=on,cn;t[137]!==sn||t[138]!==k?(cn=()=>{I(`page-content`),sn(k)},t[137]=sn,t[138]=k,t[139]=cn):cn=t[139];let ln=cn,un;t[140]!==$t||t[141]!==p||t[142]!==Ut||t[143]!==E?(un=()=>{if(p&&qt.getState().settingsReturnTo){z.current=null,I(`nav`),E(`home`),qt.getState().restoreSettingsReturnTo();return}if($t){Ut();return}I(`nav`)},t[140]=$t,t[141]=p,t[142]=Ut,t[143]=E,t[144]=un):un=t[144];let dn=un,fn;t[145]!==dt?.kind||t[146]!==F?(fn=()=>{if(F===`page-content`){xe.current=be.current,Se.current=dt?.kind===`split`?ye.current:ve.current;return}xe.current=ye.current,Se.current=ve.current},t[145]=dt?.kind,t[146]=F,t[147]=fn):fn=t[147];let pn=dt?.kind,mn;t[148]!==F||t[149]!==pn?(mn=[pn,F],t[148]=F,t[149]=pn,t[150]=mn):mn=t[150],Q.useLayoutEffect(fn,mn);let hn=`mobile-settings:${k}`,gn=R&&F!==`nav`,_n;t[151]!==dn||t[152]!==hn||t[153]!==gn?(_n={id:hn,active:gn,onBack:dn,surfaceRef:xe,underlayRef:Se},t[151]=dn,t[152]=hn,t[153]=gn,t[154]=_n):_n=t[154],ta(_n);let vn,yn;t[155]!==C||t[156]!==ze.isVSCode||t[157]!==k?(vn=()=>{if(!C||ze.isVSCode||Ae())return;let e=e=>{if(Tr(k)?.kind===`split`){if(Ym(e.state)?.page===k){I(`page-content`);return}I(mh)}};return window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`popstate`,e)}},yn=[C,ze.isVSCode,k],t[155]=C,t[156]=ze.isVSCode,t[157]=k,t[158]=vn,t[159]=yn):(vn=t[158],yn=t[159]),Q.useEffect(vn,yn);let bn;t[160]===Symbol.for(`react.memo_cache_sentinel`)?(bn=()=>{I(`page-sidebar`)},t[160]=bn):bn=t[160];let xn=bn,Sn=()=>{let e=ae.trim().length>0;return(0,$.jsxs)(`div`,{className:K(`flex h-full flex-col overflow-hidden`,C&&`yuri-settings-navigation-content`,R&&`h-auto w-full overflow-visible`),children:[(0,$.jsx)(`div`,{className:K(`px-2 pt-3`,C&&`yuri-mobile-settings-search`),children:(0,$.jsxs)(`div`,{className:K(`flex h-10 items-center gap-1.5 rounded-md border border-border bg-background/70 px-2 text-muted-foreground focus-within:ring-2 focus-within:ring-primary/40 sm:h-8`,C&&`yuri-mobile-settings-search-field`),children:[(0,$.jsx)(X,{name:`search`,className:`h-4 w-4 shrink-0`}),(0,$.jsx)(`input`,{value:ae,onChange:e=>oe(e.target.value),onKeyDown:Ft,placeholder:_(`settings.view.search.placeholder`),"aria-label":_(`settings.view.search.aria`),className:`typography-ui min-w-0 flex-1 bg-transparent text-foreground outline-none placeholder:text-muted-foreground/70`}),e&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>oe(``),"aria-label":_(`settings.view.search.clear`),className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-interactive-hover hover:text-foreground sm:h-5 sm:w-5`,children:(0,$.jsx)(X,{name:`close`,className:`h-3.5 w-3.5`})})]})}),(0,$.jsx)(`div`,{className:K(`flex-1 min-h-0 overflow-y-auto overflow-x-hidden`,R&&`w-full flex-none overflow-visible`),children:(0,$.jsx)(`div`,{className:K(C?`yuri-mobile-settings-nav-list flex min-w-0 flex-col`:`flex flex-col gap-0.5 px-2 pb-2 pt-4`),children:e?yt.length>0?(()=>{let e=0;return Ct.map(t=>{let n=t.results.map(t=>{let n=e;e+=1;let r=n===le,i=!!t.description;return(0,$.jsxs)(`button`,{type:`button`,ref:e=>{we.current[n]=e},onMouseMove:()=>{De.current=!1,ue(n)},onClick:()=>Nt(t),className:K(C?`yuri-mobile-settings-row yuri-mobile-settings-search-result`:`flex w-full flex-col rounded-md px-2 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,i?`min-h-11 py-1.5`:`py-2`,r?`bg-interactive-selection`:`hover:bg-interactive-hover`),children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:t.title}),i&&(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70 line-clamp-2`,children:t.description})]}),C?(0,$.jsx)(X,{name:`arrow-right-s`,className:`size-4 shrink-0 text-muted-foreground/60`}):null]},t.id)});return C?(0,$.jsx)(Lm,{label:t.pageTitle,ariaLabel:t.pageTitle,children:n},t.page):(0,$.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,$.jsx)(`div`,{className:`px-2 pb-0.5 pt-2 typography-micro font-medium text-muted-foreground/70`,children:t.pageTitle}),n]},t.page)})})():(0,$.jsx)(`div`,{className:`px-2 py-6 text-center typography-ui text-muted-foreground`,children:_(`settings.view.search.noResults`)}):(0,$.jsx)($.Fragment,{children:Ye.map((e,t)=>{let{group:n,pages:r}=e,i=_(`settings.view.navigation.groups.${n}`),a=r.map(e=>{let t=k===e.slug,n=Zm(e.slug);return!n&&e.slug!==`mcp`?null:(0,$.jsx)(En,{children:(0,$.jsx)(wn,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>lt(e.slug),"aria-current":t?`page`:void 0,className:K(C?`yuri-mobile-settings-row`:`flex h-8 w-full items-center gap-2 overflow-hidden rounded-md px-2 text-left`,t&&!C?`bg-interactive-selection text-foreground`:`text-foreground hover:bg-interactive-hover`),children:[e.slug===`mcp`?(0,$.jsx)(fi,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(X,{name:n,className:`h-4 w-4 shrink-0`}),(0,$.jsx)(`span`,{className:`flex min-w-0 flex-1 items-center gap-1.5 overflow-hidden whitespace-nowrap transition-opacity duration-150 opacity-100`,children:(0,$.jsx)(`span`,{className:`typography-ui-label font-normal truncate`,children:_t(e.slug)})}),e.slug===`plugins`&&(We>0||Ke)?(0,$.jsx)(`span`,{role:`img`,"aria-label":_(We>0?`settings.plugins.status.failed.title`:`settings.plugins.update.available.title`),"data-plugin-issue-badge":``,className:`size-1.5 shrink-0 rounded-full bg-[var(--status-error)]`}):null,C?(0,$.jsx)(X,{name:`arrow-right-s`,className:`size-4 shrink-0 text-muted-foreground/60`}):null]})})},e.slug)});return C?(0,$.jsx)(Lm,{label:i,ariaLabel:i,children:a},n):(0,$.jsxs)(`div`,{className:K(`space-y-0.5`,t>0&&`pt-3`),children:[(0,$.jsx)(`div`,{className:`px-2 pb-0.5 typography-micro font-medium text-muted-foreground/70`,children:i}),a]},n)})})})}),(0,$.jsx)(`div`,{className:K(`overflow-hidden transition-opacity duration-150 opacity-100`,C&&`yuri-mobile-settings-footer`),children:(0,$.jsx)(`div`,{className:K(`border-t-[0.5px] border-border/40 bg-sidebar px-2 py-1 space-y-0.5`,C&&`yuri-mobile-floating-surface yuri-mobile-settings-card`),children:!ze.isVSCode&&(0,$.jsxs)(q,{type:`button`,variant:`ghost`,size:`sm`,disabled:y.isPending,"aria-busy":y.isPending,className:K(C?`yuri-mobile-settings-row`:`w-full justify-start overflow-hidden`,`text-sm font-semibold text-sidebar-foreground/90`,`hover:text-sidebar-foreground hover:bg-interactive-hover`),onClick:x,children:[(0,$.jsx)(X,{name:`restart`,className:K(`h-4 w-4 shrink-0`,y.isPending&&`animate-spin`)}),(0,$.jsx)(`span`,{children:_(`settings.view.actions.reloadOpenCode`)})]})})})]})},Cn=()=>(0,$.jsx)(`div`,{className:K(`flex-1 min-h-0 overflow-hidden`,R?`w-full flex-none overflow-visible bg-transparent`:ze.isVSCode?`bg-background`:`bg-sidebar`),children:(0,$.jsx)(`div`,{className:K(`flex h-full min-h-0 flex-col`,R&&`h-auto w-full overflow-visible`),children:(0,$.jsx)(or,{children:Sn()})})}),Tn=e=>{let t=e===void 0?F:e;if(t===`nav`)return Cn();let n=K(`flex-1 min-h-0 overflow-hidden bg-transparent`,R?`w-full flex-none overflow-visible`:`px-[var(--yuri-mobile-page-inline-inset)]`);if(!dt)return(0,$.jsx)(`div`,{className:n});if(t===`page-sidebar`){if(dt.kind!==`split`){let e=Kt(k);return(0,$.jsx)(`div`,{className:n,children:(0,$.jsx)(Nm,{className:`yuri-mobile-settings-detail-card`,children:(0,$.jsx)(or,{children:e})})})}return(0,$.jsx)(`div`,{className:n,children:(0,$.jsx)(Nm,{className:`yuri-settings-sidebar yuri-mobile-settings-detail-card`,children:(0,$.jsx)(or,{children:Vt(k,{onItemSelect:ln})})})})}let r=Kt(k);return(0,$.jsx)(`div`,{className:n,children:(0,$.jsx)(Nm,{className:`yuri-mobile-settings-detail-card`,children:(0,$.jsx)(or,{children:r})})})},Dn;t[161]!==dt||t[162]!==lt||t[163]!==Kt||t[164]!==ze.isVSCode||t[165]!==k?(Dn=()=>!dt||k===`home`?(0,$.jsx)(Qm,{onOpen:lt}):k===`usage`?(0,$.jsx)(Sf,{children:(0,$.jsx)(or,{children:(0,$.jsx)(Wf,{})})}):dt.kind===`split`?(0,$.jsxs)(`div`,{className:`yuri-settings-entity-split flex h-full min-h-0 overflow-hidden`,children:[(0,$.jsx)(`div`,{className:K(`yuri-settings-sidebar yuri-settings-entity-list min-h-0 border-r-[0.5px] border-border/40`,ze.isVSCode?`bg-background`:`bg-sidebar`),children:(0,$.jsx)(or,{children:Vt(k,{})})}),(0,$.jsx)(`div`,{className:`flex-1 min-w-0 min-h-0 overflow-hidden bg-background`,children:(0,$.jsx)(or,{children:Kt(k)})})]}):(0,$.jsx)(`div`,{className:`h-full min-h-0 overflow-hidden bg-background`,children:(0,$.jsx)(or,{children:Kt(k)})}),t[161]=dt,t[162]=lt,t[163]=Kt,t[164]=ze.isVSCode,t[165]=k,t[166]=Dn):Dn=t[166];let On=Dn,kn=e=>{let t=e===void 0?F:e;return(0,$.jsx)(at,{sticky:!0,title:t===`nav`?_(`settings.view.home.title`):dt?_t(dt.slug):_(`settings.view.home.title`),backAriaLabel:rn,onBack:Qt?dn:n,trailing:t===`page-content`&&k===`assistants`?(0,$.jsx)(`div`,{ref:ie}):void 0,actions:[...tn?[{icon:`list-unordered`,ariaLabel:_(`settings.view.actions.openSectionList`),onClick:xn}]:[],...n?[{icon:`close`,ariaLabel:_(`settings.view.actions.closeSettings`),title:_(`settings.view.actions.closeSettingsWithShortcut`,{shortcut:an}),onClick:n}]:[]]})};if(R){let e=F!==`nav`,n=e&&dt?.kind===`split`,r=F===`page-content`,i=F===`page-sidebar`,a=r&&dt?.kind===`split`,o=e&&!a,s;t[167]===_?s=t[168]:(s=_(`mobile.settings.placeholder.title`),t[167]=_,t[168]=s);let c;return t[169]===s?c=t[170]:(c=(0,$.jsx)(Di,{title:s}),t[169]=s,t[170]=c),(0,$.jsxs)(`div`,{ref:_e,"data-settings-view":`true`,"data-mobile-settings-detail-active":e?`true`:void 0,className:`yuri-settings-workspace yuri-settings-workspace-mobile h-auto w-full min-w-0 overflow-visible bg-transparent`,children:[(0,$.jsxs)(`div`,{ref:ve,"data-mobile-settings-stage":`nav`,"data-mobile-navigation-underlay":o?`true`:void 0,"aria-hidden":e?`true`:void 0,inert:e?!0:void 0,className:`yuri-mobile-settings-root-surface fixed inset-0 z-20 flex h-[100dvh] w-full min-w-0 max-w-full flex-col gap-[var(--yuri-mobile-page-gap)] overflow-y-auto overflow-x-hidden overscroll-contain px-[var(--yuri-mobile-page-inline-inset)] pb-[calc(var(--yuri-mobile-dock-height)+2.5rem+var(--yuri-safe-area-bottom,env(safe-area-inset-bottom,0px)))] pt-[calc(var(--yuri-safe-area-top,env(safe-area-inset-top,0px))+1rem)] [contain:layout_paint]`,children:[c,Cn()]}),n?(0,$.jsxs)(`div`,{ref:ye,"data-mobile-settings-stage":`page-sidebar`,"data-mobile-navigation-underlay":a?`true`:void 0,"data-mobile-settings-push-surface":`true`,"aria-hidden":i?void 0:`true`,inert:!i||void 0,className:`fixed inset-0 z-40 flex h-[100dvh] w-full min-w-0 max-w-full touch-pan-y flex-col overflow-hidden bg-background [contain:layout_paint]`,children:[kn(`page-sidebar`),(0,$.jsx)(`div`,{className:`min-h-0 w-full flex-1 overflow-y-auto overflow-x-hidden overscroll-contain px-[var(--yuri-mobile-page-inline-inset)]`,children:Tn(`page-sidebar`)})]}):null,r?(0,$.jsxs)(`div`,{ref:be,"data-mobile-settings-stage":`page-content`,"data-mobile-settings-push-surface":`true`,className:`fixed inset-0 z-50 flex h-[100dvh] w-full min-w-0 max-w-full touch-pan-y flex-col overflow-hidden bg-background [contain:layout_paint]`,children:[kn(`page-content`),(0,$.jsx)(`div`,{className:`min-h-0 w-full flex-1 overflow-y-auto overflow-x-hidden overscroll-contain px-[var(--yuri-mobile-page-inline-inset)]`,children:Tn(`page-content`)})]}):null]})}let An=C?`yuri-settings-workspace-mobile bg-transparent`:`yuri-settings-workspace-desktop bg-background`,jn=R&&`h-auto w-full overflow-visible`,Mn;t[171]!==An||t[172]!==jn?(Mn=K(`yuri-settings-workspace relative flex h-full min-h-0 flex-col overflow-hidden`,An,jn),t[171]=An,t[172]=jn,t[173]=Mn):Mn=t[173];let Nn=C&&!L?kn():C?null:(0,$.jsxs)($.Fragment,{children:[Qt&&(0,$.jsx)(`div`,{className:K(`absolute left-3 z-50`,a?`top-2`:`top-3`),children:(0,$.jsx)(`button`,{type:`button`,onClick:dn,"aria-label":_(`settings.view.actions.back`),className:`inline-flex h-9 w-9 items-center justify-center rounded-lg p-2 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,children:(0,$.jsx)(X,{name:`arrow-left-s`,className:`h-5 w-5`})})}),n&&(0,$.jsx)(`div`,{className:K(`absolute right-0.5 z-50`,a?`top-0.5`:`top-1`),children:(0,$.jsx)(`button`,{type:`button`,onClick:n,"aria-label":_(`settings.view.actions.closeSettings`),title:_(`settings.view.actions.closeSettingsWithShortcut`,{shortcut:an}),className:`inline-flex h-7 w-7 items-center justify-center rounded-md p-0.5 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,children:(0,$.jsx)(X,{name:`close`,className:`h-5 w-5`})})})]}),Pn=R&&`w-full flex-none overflow-visible`,Fn;t[174]===Pn?Fn=t[175]:(Fn=K(`flex flex-1 min-h-0 overflow-hidden`,Pn),t[174]=Pn,t[175]=Fn);let In=C?Tn():(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:K(`relative flex h-full min-h-0 flex-col overflow-hidden border-r-[0.5px] border-border/40`,je?`bg-sidebar`:ze.isVSCode?`bg-background`:`bg-sidebar`,pe?``:`transition-[width,min-width] duration-200 ease-[cubic-bezier(0.25,0.1,0.25,1)]`),style:{width:`${te}px`,minWidth:`${te}px`},children:[(0,$.jsx)(`div`,{className:K(`absolute right-0 top-0 z-20 h-full w-[6px] -mr-[3px] cursor-col-resize`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,pe?`bg-primary/30`:`bg-transparent hover:bg-primary/20`),tabIndex:0,onPointerDown:nt,onKeyDown:it,role:`separator`,"aria-orientation":`vertical`,"aria-valuemin":zm,"aria-valuemax":Bm,"aria-valuenow":te,"aria-label":_(`settings.view.actions.resizeNavigation`)}),(0,$.jsx)(or,{children:Sn()})]}),(0,$.jsx)(`div`,{className:`yuri-settings-detail-pane flex-1 overflow-hidden bg-background`,children:On()})]}),Ln;t[176]!==Fn||t[177]!==In?(Ln=(0,$.jsx)(`div`,{className:Fn,children:In}),t[176]=Fn,t[177]=In,t[178]=Ln):Ln=t[178];let Rn;return t[179]!==Mn||t[180]!==Nn||t[181]!==Ln?(Rn=(0,$.jsxs)(`div`,{ref:_e,"data-settings-view":`true`,className:Mn,children:[Nn,Ln]}),t[179]=Mn,t[180]=Nn,t[181]=Ln,t[182]=Rn):Rn=t[182],Rn};function eh(e){return e.settingsPage}function th(e){return e.isSettingsDialogOpen}function nh(e){return e.setSettingsPage}function rh(e){return e.openSettingsRequestRevision}function ih(e){return e.slug!==`home`}function ah(e){return e.activeProjectId}function oh(e){return e.slug}function sh(e){return e.name}function ch(e){return e.name}function lh(e){return e.name}function uh(e){return e.name}function dh(e){if(e.id.startsWith(`assistants.`)){if(e.id===`assistants.default-share`){let t=en.getState(),n=et()?.assistants??[],r=n.some(e=>e.id===t.settingsSelectedAssistantID);return t.selectSettingsAssistant(r?t.settingsSelectedAssistantID:n[0]?.id??null),e.id}return en.getState().requestCreate(),e.id===`assistants.create`?`assistants.name`:e.id}if(e.id.startsWith(`agents.`)){let t=Wt.getState(),n=Jm(`new-agent`,Bt().map(sh));return t.setAgentDraft({name:n,scope:`user`}),t.setSelectedAgent(n),e.id===`agents.create`?`agents.name`:e.id}if(e.id.startsWith(`commands.`)){let t=Xa.getState(),n=Jm(`new-command`,At().map(ch));return t.setCommandDraft({name:n,scope:`user`}),t.setSelectedCommand(n),e.id===`commands.create`?`commands.name`:e.id}if(e.id.startsWith(`mcp.`)){let t=no.getState(),n=Jm(`new-mcp-server`,zi().map(lh));return t.setMcpDraft({name:n,scope:`user`,type:`local`,command:[],url:``,environment:[],headers:[],oauthEnabled:!0,oauthClientId:``,oauthClientSecret:``,oauthScope:``,oauthRedirectUri:``,timeout:``,enabled:!0}),t.setSelectedMcp(n),e.id===`mcp.create`?`mcp.server`:e.id}if(e.id.startsWith(`skills.`)){let t=gt(Oe),n=so.getState(),r=Jm(`new-skill`,t.map(uh));return n.setSkillDraft({name:r,scope:`user`,source:`opencode`,description:``,instructions:``}),n.setSelectedSkill(r),e.id===`skills.create`?`skills.basic-information`:e.id}return e.id===`providers.connect`&&pt.getState().setSelectedProvider(Wm),e.id===`plugins.create`?`plugins.spec`:e.id}function fh(){window.dispatchEvent(new CustomEvent(`yuri:settings-open-plugin-add`))}function ph(e,t){switch(e){case`projects`:return(0,$.jsx)(Gu,{onItemSelect:t.onItemSelect});case`agents`:return(0,$.jsx)(Ro,{onItemSelect:t.onItemSelect});case`assistants`:return(0,$.jsx)(ic,{onItemSelect:t.onItemSelect});case`commands`:return(0,$.jsx)(xc,{onItemSelect:t.onItemSelect});case`mcp`:return(0,$.jsx)(Mc,{onItemSelect:t.onItemSelect});case`plugins`:return(0,$.jsx)(Ll,{onItemSelect:t.onItemSelect});case`skills.installed`:return(0,$.jsx)(ru,{onItemSelect:t.onItemSelect});case`providers`:return(0,$.jsx)(mf,{onItemSelect:t.onItemSelect});case`usage`:return(0,$.jsx)(Sf,{onItemSelect:t.onItemSelect});case`magic-prompts`:return(0,$.jsx)(qf,{onItemSelect:t.onItemSelect});default:return null}}function mh(e){return e===`page-content`?`page-sidebar`:e}export{Im as a,no as c,Nm as i,Ga as l,Rm as n,Fm as o,Pm as r,ac as s,$m as t,Aa as u};